query
stringlengths
7
9.55k
document
stringlengths
10
363k
metadata
dict
negatives
listlengths
0
101
negative_scores
listlengths
0
101
document_score
stringlengths
3
10
document_rank
stringclasses
102 values
Verify that we pass all of the checks. The argument determines whether we skip the :refreshonly check, which is necessary because we now check within refresh
def check_all_attributes(refreshing = false) self.class.checks.each do |check| next if refreshing && check == :refreshonly next unless @parameters.include?(check) val = @parameters[check].value val = [val] unless val.is_a? Array # return false if any check returns false val.each ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check(refreshing = false)\n self.class.checks.each do |check|\n next if refreshing and check == :refreshonly\n if @parameters.include?(check)\n val = @parameters[check].value\n val = [val] unless val.is_a? Array\n val.each do |value|\n return false unless @parameters[...
[ "0.69237924", "0.66634756", "0.6336441", "0.6332119", "0.6163027", "0.6129915", "0.6112503", "0.6079987", "0.60205144", "0.6019559", "0.6005145", "0.59308034", "0.5922238", "0.5922238", "0.5917741", "0.5905543", "0.58953446", "0.5882942", "0.5869667", "0.5849718", "0.58438885...
0.6641415
2
Not cross platform will need to revisit
def executable_exists?(executable_handle) %x[which #{executable_handle} 2>/dev/null][0] == "/" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def platform; end", "def platform; end", "def platform; end", "def user_os_complex\r\n end", "def valid_for_platform?; true; end", "def host_os; end", "def host_os; end", "def ios; end", "def platform_end_point; end", "def platform\n raise NotImplementedError\n end", "def platform\n rai...
[ "0.6736933", "0.6736933", "0.6736933", "0.67215", "0.65272444", "0.6473369", "0.6473369", "0.6395048", "0.63803333", "0.62602705", "0.62602705", "0.62440866", "0.6219257", "0.61216456", "0.6019199", "0.59866095", "0.59571594", "0.59151924", "0.59130543", "0.5907898", "0.58658...
0.0
-1
HELPER METHODS Method initalizes the global variable for the board to reduce redundancy within other methods.
def initialize(board = nil) # Creates a new array that's 9 units in length # and all filled in with the blank string " ". @board = board || Array.new(9, " ") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def initialize\n @@BOARD_SIZE = 8\n @board = create_board\n @god_mode = false\n end", "def initialize\n\t\treset_board\n\tend", "def setup_board!\n\t\t@board = Array.new($dimensions[:y]){ Array.new($dimensions[:x]) {:empty} }\n\tend", "def initialize board\n @board = board\n end", "def init_b...
[ "0.7743713", "0.74425435", "0.7387193", "0.7353746", "0.7344709", "0.7314298", "0.7284906", "0.72675467", "0.7241382", "0.7221128", "0.7177268", "0.71065253", "0.7090448", "0.7072811", "0.7071929", "0.7053421", "0.7050917", "0.70453995", "0.70392686", "0.70291716", "0.701785"...
0.0
-1
Method to initalize the display of the Tictactoe board.
def display_board() puts " #{@board[0]} | #{@board[1]} | #{@board[2]} " puts "-----------" puts " #{@board[3]} | #{@board[4]} | #{@board[5]} " puts "-----------" puts " #{@board[6]} | #{@board[7]} | #{@board[8]} " end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def init_board\n @board = Board.new\n @board.display_board\n end", "def setup_display\n gameboard.build_display\n build_white_side\n build_black_side\n end", "def initialize\n @@cells = [1, 2, 3, 4, 5, 6, 7, 8, 9]\n display_board\n end", "def initialize\n\n\t\t# Set up some default va...
[ "0.7549707", "0.73425", "0.6907094", "0.68942595", "0.6841467", "0.66893274", "0.66635996", "0.66099894", "0.65659595", "0.6526096", "0.646911", "0.6434915", "0.64309114", "0.6425723", "0.64201033", "0.64078593", "0.6401751", "0.63944966", "0.6393503", "0.6392605", "0.639076"...
0.62706214
45
Method to convert the user input into the correct position in the array. Eg. humans start counting at 1 and programs start counting at 0.
def input_to_index(user_input) user_input.to_i - 1 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def input_to_index(user_input) \n #converts the user's input (a string) into an integer / would use .to_i\n #converts the user's input from the user-friendly format (on a 1-9 scale) to the array-friendly format (where the first index starts at 0) \n user_input.to_i - 1\n end", "def input...
[ "0.8193819", "0.79709166", "0.7902703", "0.767492", "0.75710297", "0.73838407", "0.73575413", "0.7165649", "0.7165649", "0.7122644", "0.7087391", "0.7038188", "0.7004243", "0.6995765", "0.69862634", "0.6981495", "0.6972484", "0.6972484", "0.6972484", "0.6972484", "0.696982", ...
0.6906879
31
Method to check whether the input is within the index or is already occupied.
def valid_move?(index) if (index>=0 && index <=8 && @board[index]==" ") return true end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def position_taken?(board,index)\n #This method must take in both the existing board and the index that the user\n #is trying to fill if the index is already occupied it will not allow this\n position_value=board[index]\n if position_value != nil\n if position_value.include? \"x\" or position_value.include?...
[ "0.7104788", "0.7103605", "0.706787", "0.7067758", "0.69066614", "0.6905295", "0.6862908", "0.68321806", "0.6806577", "0.68050575", "0.670032", "0.6692823", "0.6684765", "0.6655471", "0.66461664", "0.66388774", "0.66181856", "0.66100264", "0.66004276", "0.66004276", "0.659444...
0.0
-1
Method to allow recurring turns for the user.
def turn # Asks user for input. puts "Please enter 1-9:" # Places the user's answer into the variable 'input'. input = gets.strip # Uses the conversion method to place it into variable 'index'. index = input_to_index(input) # Goes through an if/else loop to check if move is valid. if val...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def recurring; end", "def recurring\n !on_trial && !cancelled\n end", "def recurring(authorization, money, options={})\n post = {\n ticketId: authorization\n }\n\n add_order_id(post, options)\n add_amount(post, money ,options)\n add_currency(post, options)\n...
[ "0.66548544", "0.6633815", "0.58690417", "0.57438767", "0.57061845", "0.5690161", "0.56836057", "0.5582295", "0.5487991", "0.54866797", "0.54568356", "0.54312384", "0.540379", "0.5390863", "0.5386664", "0.5373352", "0.5353881", "0.5332506", "0.532149", "0.5267087", "0.5265257...
0.0
-1
Helper Method that detects if a position has already been taken.
def position_taken?(index) # If the board's index is nil or empty, will return a "truthy" value. !(@board[index].nil? || @board[index] == " ") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def position_taken?(board, position)\n\tif board[position] == \"X\" || board[position] == \"0\"\n\t\treturn true\n\telse\n\t\treturn false\n\tend\nend", "def position_taken?\nend", "def position_taken?(board, pos)\n if board[pos]==\"X\" || board[pos]==\"O\"\n taken = true\n else\n taken = false\n end\...
[ "0.76531607", "0.7615342", "0.75369245", "0.7527579", "0.74886155", "0.74882597", "0.74749553", "0.74655026", "0.74655026", "0.7445147", "0.7442871", "0.74287933", "0.74184287", "0.74030143", "0.7397123", "0.73769", "0.73713624", "0.7364252", "0.7353917", "0.73339885", "0.732...
0.0
-1
Method goes through board array and checks each position in the array, and adds to the amount of turns played if the checked position isn't blank.
def turn_count turns_played = 0 @board.each do |index| if index != " " turns_played += 1 end end return turns_played end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def turn_count\r\n turns_so_far = 0\r\n @board.each do |arr_item|\r\n if arr_item == \"X\" || arr_item ==\"O\"\r\n turns_so_far += 1\r\n end\r\n end\r\n return turns_so_far\r\n end", "def turn_count(board)\n turn_counter = 0\n (board.length).times do |i|\n if position_taken?(bo...
[ "0.7420311", "0.73316216", "0.72552645", "0.722082", "0.71853435", "0.7155959", "0.71534646", "0.7142863", "0.7136154", "0.70924747", "0.70103043", "0.6993", "0.69909805", "0.6972424", "0.69702274", "0.68814576", "0.68778557", "0.6876927", "0.6860996", "0.6856106", "0.6847809...
0.7407617
1
Method defines the current player of the game by checking the count of turns played from above method and subsequently returns "X" or "O" for even and odd turns, respectively.
def current_player turns_played = turn_count() if turns_played % 2 == 0 return "X" else return "O" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def current_player\n turn_count == 0 || turn_count % 2 == 0 ? \"X\" : \"O\"\n end", "def current_player\n turn = turn_count\n if turn%2 == 0\n return \"X\"\n else\n return 'O'\n end\n end", "def current_player\n if turn_count % 2 == 0\n return \"X\"\n else\n return ...
[ "0.85293055", "0.8490617", "0.84603107", "0.84220535", "0.84219116", "0.84219116", "0.8418471", "0.8410444", "0.8401298", "0.8391028", "0.83904094", "0.8380849", "0.8374006", "0.8371563", "0.836329", "0.836329", "0.8329731", "0.83176386", "0.83176386", "0.83176386", "0.831336...
0.84757465
2
Method that goes through each possible array combination within
def won? # for each win_combo in WIN_COMBINATIONS WIN_COMBINATIONS.each do |win_combo| # win_combination is a 3 element array of indexes that compose a win, eg. [0,1,2] # grab each index from the win_combo that composes a win. win_index_1 = win_combo[0] win_index_2 = win_combo[1] w...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def each_combination\n \n end", "def combinations(arr)\n\n arr.each_with_index do |ele1, idx|\n arr.each_with_index do |ele2, idx2|\n puts ele1 + ele2\n end\n end\n\nend", "def pbEachCombination(array,num)\n return if array.length<num || num<=0\n if array.length==num\n y...
[ "0.7711321", "0.7624715", "0.7403822", "0.7363292", "0.72697645", "0.72665745", "0.7223739", "0.7206656", "0.7185483", "0.7157219", "0.7157219", "0.7157219", "0.7157219", "0.71253216", "0.71241903", "0.71230215", "0.7106451", "0.70776635", "0.69993454", "0.6957293", "0.692248...
0.0
-1
Method checks if board is full by only returning a "truthy" value if there is no position on the board that is nil or empty.
def full? !@board.any? { |value| value.nil? || value == "" || value == " " } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def full?\n # If no 'board_position'/s are empty, returns 'true'. If 'board_position'/s remain empty, returns 'false'.\n if @board.none? {|board_position| board_position == \" \"}\n true\n end\n end", "def isBoardFull()\n #\n # TO DO: add your code below\n\t\t#\n\t\tfor i...
[ "0.90218514", "0.8688075", "0.86717504", "0.86366194", "0.8629453", "0.8593771", "0.8589833", "0.85538167", "0.85538167", "0.84197253", "0.83819556", "0.8277664", "0.8228152", "0.82262295", "0.8224908", "0.8213173", "0.8207676", "0.8207676", "0.82047987", "0.8154539", "0.8143...
0.8042301
31
Method that checks if the game is over by checking the return values of the won? and draw? method to see whether they're true or false.
def over? won = won?() draw = draw?() # Due to the won? method never explicitly returning a true value, # the program must instead check if it isn't false. if draw == true || won != false return true else return false end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def over?\n if won?\n return true\n elsif draw?\n return true\n else\n return false\n end\n end", "def over?\n if won? != false && won? != nil || draw? == true\n return true\n else\n return false\n end\n end", "def over?\n if draw? == true or won? != fa...
[ "0.87102", "0.8643672", "0.8636116", "0.8619649", "0.86185044", "0.86170095", "0.8558377", "0.85210425", "0.85113096", "0.85072845", "0.848857", "0.84288204", "0.83988035", "0.83848614", "0.8372384", "0.8369034", "0.8348665", "0.8348665", "0.83447397", "0.8339503", "0.8325404...
0.8698807
1
Method that declares the winner of the game by checking the token value of the 'won?; method. Returns nil if there is no winner (yet).
def winner won = won?() if won != false if @board[won[0]] == "X" return "X" elsif @board[won[0]] == "O" return "O" end else return nil end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def winner\n if won?\n win_combination = won?\n token = @board[win_combination[0]]\n return token\n end\n end", "def winner(board)\n token = nil\n if won?(board) != nil\n win_combo = won?(board)\n token = board[win_combo[0]]\n end\n token\nend", "def winner(board)\n if wo...
[ "0.81902844", "0.8036252", "0.80302435", "0.8024476", "0.79827094", "0.7803413", "0.7734259", "0.7577003", "0.745451", "0.7356693", "0.73044014", "0.72976196", "0.72914416", "0.7273424", "0.7273268", "0.72591305", "0.7211531", "0.71844906", "0.71419585", "0.7136251", "0.71319...
0.74484
9
MAIN METHOD Method is run by the CLI by the user, and goes through
def play until over?() == true puts "Please enter 1-9: " turn() end if draw?() == true puts "Cat's Game!" elsif won?() == true winner() end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def execute\n setup\n begin\n data = main\n rescue ArgumentError => e\n warn e.message\n exit 1\n end\n puts format_data(data)\n end", "def main\n\n end", "def main\n end", "def main(*args)\n #puts self.class # TODO: fix help\n raise NoCommandErro...
[ "0.778681", "0.77294993", "0.76544446", "0.7638185", "0.763159", "0.7550795", "0.74092627", "0.7139739", "0.70713216", "0.70217776", "0.70217776", "0.69823027", "0.698017", "0.698017", "0.698017", "0.698017", "0.698017", "0.698017", "0.698017", "0.6946221", "0.6910278", "0....
0.0
-1
Creates new `Author` from Ravelry API PatternAuthor attributes. All class variables are readonly.
def initialize(pattern_author) @id = pattern_author[:id] @name = pattern_author[:name] @permalink = pattern_author[:permalink] @patterns_count = pattern_author[:patterns_count] @favorites_count = pattern_author[:favorites_count] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def author\n @author ||= Person.new(connection, @attributes[:author])\n end", "def author\n @author ||= Author.new @instance, author_id\n end", "def author\n if @author.nil?\n @author = FeedTools::Author.new\n author_node = FeedTools::XmlHelper.try_xpaths(self.channel_node, [...
[ "0.71000904", "0.6702347", "0.64240736", "0.63792276", "0.63453203", "0.6327158", "0.6317974", "0.62379575", "0.62177753", "0.62177753", "0.62122464", "0.6162844", "0.61284435", "0.61277384", "0.6119555", "0.60853875", "0.6058227", "0.60349333", "0.59761596", "0.5956108", "0....
0.6870114
1
GET /tracks or /tracks.json
def index @album = Album.find_by(id: params[:album_id]) @tracks = Track.where(album_id: params[:album_id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def tracks_search params = { :query => 'love', :page => 1 }\n json = send_request 'tracks_search', params\n if json['success'] == true\n json['tracks']\n else\n puts \"Error: \" + json['message']\n exit\n end\n end", "def tracks_get_info params = { :track_id => nil }\n json = send_...
[ "0.73931235", "0.7371618", "0.7221655", "0.7220333", "0.71722025", "0.709271", "0.70530516", "0.7008016", "0.69487834", "0.69011587", "0.6869924", "0.6869727", "0.6869727", "0.6869727", "0.685836", "0.68381023", "0.68317014", "0.67225647", "0.66717225", "0.66647786", "0.66566...
0.6408871
35
GET /tracks/1 or /tracks/1.json
def show @album = @track.album @notes = @track.notes end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def tracks_get_info params = { :track_id => nil }\n json = send_request 'tracks_get_info', params\n if json['success'] == true\n json['data']\n else\n puts \"Error: \" + json['message']\n exit\n end\n end", "def tracks_search params = { :query => 'love', :page => 1 }\n json = send_...
[ "0.74489194", "0.7213318", "0.7013623", "0.700754", "0.6985088", "0.697498", "0.6971131", "0.6971131", "0.6971131", "0.6958317", "0.6836496", "0.6721177", "0.668264", "0.66439676", "0.66134435", "0.6604076", "0.6574589", "0.6572535", "0.6565873", "0.6550363", "0.65411484", ...
0.0
-1
POST /tracks or /tracks.json
def create @track = Track.new(track_params) if @track.save redirect_to track_url(@track) else flash.now[:errors] = @track.errors.full_messages render :new end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @track = Track.new(track_params)\n if @track.save\n render json: @track, status: :created, location: @track\n else\n render json: @track.errors, status: :unprocessable_entity\n end\n end", "def create\n @track = Track.new(params[:track])\n\n respond_to do |format|\n ...
[ "0.7363015", "0.71996236", "0.71304667", "0.71125215", "0.7065321", "0.7065321", "0.6977381", "0.6832499", "0.68309593", "0.6776067", "0.672373", "0.67194974", "0.6669662", "0.6666111", "0.66517943", "0.66236794", "0.6574219", "0.65013784", "0.6468283", "0.6451735", "0.643797...
0.6340607
29
PATCH/PUT /tracks/1 or /tracks/1.json
def update if @track.update_attributes(track_params) redirect_to track_url(@track) else flash.now[:errors] = @track.errors.full_messages render :edit end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n if @track.update(edit_track_params)\n render json: @track\n else\n render json: @track.errors, status: :unprocessable_entity\n end\n end", "def update\n if @track.update(track_params)\n render json: @track\n else\n render json: { error: @track.errors }, st...
[ "0.7197396", "0.71767485", "0.7112221", "0.70684946", "0.7059572", "0.7049803", "0.7049803", "0.7049803", "0.6846695", "0.68137485", "0.67744917", "0.67632383", "0.674611", "0.6718066", "0.67114866", "0.65691847", "0.65341526", "0.646354", "0.64333993", "0.63278055", "0.62813...
0.6180596
24
DELETE /tracks/1 or /tracks/1.json
def destroy @album = @track.album @track.destroy redirect_to album_tracks_url(@album) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @track = Track.find(params[:id])\n @track.destroy\n\n respond_to do |format|\n format.html { redirect_to tracks_url }\n format.json { head :ok }\n end\n end", "def destroy\n @track = Track.find(params[:id])\n @track.destroy\n\n respond_to do |format|\n format.ht...
[ "0.77126336", "0.7694061", "0.76513463", "0.757257", "0.7523104", "0.7495363", "0.74683374", "0.74671394", "0.74035966", "0.7360571", "0.7360571", "0.73584455", "0.73561007", "0.7274949", "0.72514856", "0.7240777", "0.71790487", "0.7116626", "0.7105368", "0.70169437", "0.6962...
0.67919207
45
Use callbacks to share common setup or constraints between actions.
def set_track @track = Track.find_by(id: 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_...
[ "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.0
-1
Only allow a list of trusted parameters through.
def track_params params.require(:track).permit(:title, :ord, :lyrics, :album_id, :band_id) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def allowed_params\n ALLOWED_PARAMS\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\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]\...
[ "0.6948149", "0.68135875", "0.68015283", "0.67953765", "0.6745843", "0.67416775", "0.652725", "0.6521263", "0.649084", "0.64307743", "0.64307743", "0.64307743", "0.6398334", "0.63553715", "0.6355045", "0.6346211", "0.63444513", "0.6338212", "0.63267356", "0.63267356", "0.6326...
0.0
-1
actually get the form data and create a comment
def create @story = Story.find(params[:story_id]) @comment = @story.comments.new(comment_params) if @comment.save flash[:sucess] = "You've added a comment" redirect_to story_path(@story) else render "new" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _form\n @comment = Comment.new\n end", "def create\n\n\t\tupload = Upload.find(params[:upload_id])\n\n\t\tcomment_params = Hash.new \n\t\tcomment_params[:upload_id] = params[:upload_id]\n\t\tcomment_params[:description] = params[:description]\n\t\tcomment_params[:user_id] = params[:user_id]\t\n\n\n\n\t\t#...
[ "0.7599366", "0.72303873", "0.7004231", "0.6971412", "0.6942913", "0.6937949", "0.6905318", "0.6875069", "0.68386054", "0.6798861", "0.6750666", "0.67400897", "0.6735921", "0.6730976", "0.6724781", "0.6716414", "0.6712682", "0.6712682", "0.6712682", "0.6711247", "0.66848165",...
0.0
-1
lets make a shortcut for grabbing the form data our white list for form datap
def comment_params params.require(:comment).permit(:body) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def form_data?; end", "def form_data\n @form_data ||= {\n \"c\" => [\"China\", \"Venezuela\", \"Brazil\", \"United States\", \"Thailand\", \"Ukraine\", \"Indonesia\", \"Nepal\", \"Russian Federation\", \"Argentina\", \"Czech Republic\", \"Korea, Republic of\", \"Colombia\", \"France\", \"Bangladesh\", \...
[ "0.6796383", "0.63022715", "0.60957485", "0.6042398", "0.5747716", "0.5732692", "0.57217115", "0.5719445", "0.5712989", "0.56871456", "0.56612766", "0.5660578", "0.5646129", "0.56382483", "0.56380045", "0.5612735", "0.5610445", "0.56070286", "0.5583275", "0.55547255", "0.5553...
0.0
-1
return [String] branch_of_service code and rank_code joined with ':'
def id branch_of_service_code + ':' + rank_code end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def service_code\n \"#{shipment_mode_code}#{service_type_code}#{services_code}\"\n end", "def bic_with_branch_code\n if self.bic.length == 8\n return \"#{self.bic}XXX\"\n else\n return self.bic\n end\n end", "def to_s\n branch.to_s\n end", "def rank_to_s\n\t\t\tRanking...
[ "0.6294864", "0.61894995", "0.617513", "0.6005978", "0.59955555", "0.5923842", "0.5902942", "0.5902942", "0.5866536", "0.58470607", "0.580447", "0.5786178", "0.5761859", "0.5755752", "0.5674943", "0.56735796", "0.56549925", "0.5653082", "0.56392306", "0.56390965", "0.56378835...
0.66203624
0
Fetch data from path
def get(options, path, ssl = true) # Get proxy params (needed for ruby 1.9.3) http_proxy = ENV['http_proxy'] || ENV['HTTP_PROXY'] p_host = nil p_port = nil if http_proxy p_uri = URI(http_proxy) p_host = p_uri.host ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def fetch_path(path=\"\")\n read_data(@uri + path)\n end", "def fetch!\n old_path = path\n if old_path && path.length > 0\n path = \"\"\n @results = get(old_path, @options)\n end\n end", "def fetch_path(path=\"\")\n @fetcher.fetch_path(path)\n end", "def fetch...
[ "0.82785594", "0.74305445", "0.72390485", "0.66133416", "0.65959966", "0.65886134", "0.65376455", "0.6515805", "0.6483323", "0.64813185", "0.6446524", "0.6446524", "0.6381526", "0.6377312", "0.632699", "0.6322861", "0.62740976", "0.6232883", "0.62230474", "0.62038326", "0.620...
0.0
-1
Calculate cross product of this and another vector repsented by array class. Only applicable to vectors in 3D space.
def cross_product(nv2) [self[1]*nv2[2]-self[2]*nv2[1], self[2]*nv2[0]-self[0]*nv2[2], self[0]*nv2[1]-self[1]*nv2[0]] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cross v\n x = @y * v.z - @z * v.y\n y = @z * v.x - @x * v.z\n z = @x * v.y - @y * v.x\n Vector.new x, y, z\n end", "def cross_product(vector2)\n self.class.cross_product(self, vector2)\n end", "def cross(b,c)\n unless b.size == 3 and c.size == 3\n raise \"Vectors must be of...
[ "0.76259816", "0.7616073", "0.7560348", "0.7477579", "0.74529296", "0.74057156", "0.7344543", "0.7285841", "0.7253698", "0.7188635", "0.7170961", "0.7069532", "0.70500666", "0.7001195", "0.68604517", "0.669117", "0.662599", "0.65599185", "0.6546519", "0.648787", "0.6382368", ...
0.690822
14
substract self vector from another 3D vector
def v_minus(v) [v[0]-self[0],v[1]-self[1],v[2]-self[2]] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def subtract v\n Vector.new @x - v.x, @y - v.y, @z - v.z\n end", "def -(other_vector)\n Vector.new @x - other_vector.x, @y - other_vector.y\n end", "def vector\n head.subtract tail\n end", "def sub(v)\n @x -= v.x\n @y -= v.y\n self\n end", "def -( otherVector )\n\t\t\trais...
[ "0.7568874", "0.73041457", "0.72705823", "0.72217196", "0.7189016", "0.7178372", "0.71107465", "0.71016043", "0.7011256", "0.70094085", "0.7001839", "0.69418293", "0.68828434", "0.6796317", "0.67829853", "0.6769175", "0.6722774", "0.6648173", "0.65982306", "0.6556725", "0.640...
0.6843724
13
Perform mesh refinement by adding new vertex points to the tiles, curvature for which exceeds provied max_curvature value. To reach desired smoothness you need repeatedly call this function until amount of tiles that were split (returned by this function ) is zero. Alternatively you can call ''
def refine(max_curvature) @nvariance_limit = max_curvature refined = 0 tiles_to_split=[] @tiles.each { |i, t| nvr = t.value.nvariance() if nvr[1] > max_curvature # Something needs to be split, either this tile or its counterpart which gives # us highest nva...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_mesh\r\n Console.log( 'BezierSurface.update_mesh' )\r\n d = TT::Instance.definition( @instance )\r\n transformation = d.model.edit_transform\r\n subdivisions = final_subdivs()\r\n # Init a PolygonMesh with an rough geometry estimate for best performance.\r\n points = count_...
[ "0.627872", "0.5675655", "0.5548027", "0.54407775", "0.54233825", "0.5248542", "0.50401896", "0.50072116", "0.50071335", "0.49972454", "0.49906886", "0.49645856", "0.4909804", "0.48935342", "0.4881993", "0.48580468", "0.48510474", "0.48431414", "0.48099142", "0.47552785", "0....
0.6946713
0
of refine(...) Same as 'refine(max_curvature)', but will contain recursively until maximum tile curvature falls bellow max_curvature
def refine_recursively(max_curvature) refined = self.refine(max_curvature) while refined > 0 if not @iter_callback.nil? @iter_callback.call(self, refined) end refined = self.refine(max_curvature) end if not @iter_callback.nil? # last callback ca...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def refine(max_curvature)\n @nvariance_limit = max_curvature\n refined = 0\n tiles_to_split=[]\n @tiles.each { |i, t| \n nvr = t.value.nvariance()\n if nvr[1] > max_curvature \n # Something needs to be split, either this tile or its counterpart which gives \n # u...
[ "0.82258177", "0.5646049", "0.55215144", "0.49735272", "0.4927844", "0.48244035", "0.47938368", "0.47853062", "0.4710977", "0.46919158", "0.46494424", "0.46343789", "0.46209347", "0.46201226", "0.45666495", "0.4522838", "0.45077762", "0.4503906", "0.45010763", "0.44843978", "...
0.7963892
1
Perform evaluation of zvalue on each vertex in the grid
def compute(computer=nil) cmptr = @computer cmptr = computer if !computer.nil? @vtxs.each { |v| val = v.compute(cmptr) } if not @iter_callback.nil? @iter_callback.call(self, @vtxs.size) end self end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def surface\n values.sum\n end", "def calc_z_scores # calculate all z-scores\n self.deviation ||= values.sd\n self.mean ||= values.mean\n self.z_scores = values.map { |v| ((v-mean)/deviation).round(4) }\n self.t_scores = self.z_scores.map { |z| 10*z + 50 }\n self.deviation = self.deviation...
[ "0.5610801", "0.5552732", "0.550222", "0.5488089", "0.54571044", "0.5452045", "0.5405929", "0.53848755", "0.5319035", "0.5263482", "0.5233689", "0.52046", "0.51862854", "0.5134466", "0.5105936", "0.5088529", "0.50789416", "0.50789416", "0.5063663", "0.5057739", "0.504423", ...
0.0
-1
Find all nearby tiles connected to this one through the common edges ( up to three tiles ) and for each tile calculate cross product between normal vectors of this tile and nearby ones. Find the one that give maximum of these three cross products by absolute value and return array where first element is adjacent tile t...
def nvariance(debug=false) nv0 = self.normal_vector all_near_by_tiles = [] all_near_by_tiles << ( @grd.vtxs[vtx[0]-1].tiles & @grd.vtxs[vtx[1]-1].tiles ) all_near_by_tiles << ( @grd.vtxs[vtx[0]-1].tiles & @grd.vtxs[vtx[2]-1].tiles ) all_near_by_tiles << ( @grd.vtxs[vtx[1]-1].tiles & @grd.v...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def refine(max_curvature)\n @nvariance_limit = max_curvature\n refined = 0\n tiles_to_split=[]\n @tiles.each { |i, t| \n nvr = t.value.nvariance()\n if nvr[1] > max_curvature \n # Something needs to be split, either this tile or its counterpart which gives \n # u...
[ "0.62787354", "0.54327226", "0.54217875", "0.53904384", "0.5148078", "0.51241624", "0.5063277", "0.5017176", "0.5010877", "0.49718472", "0.49580172", "0.49520072", "0.4932369", "0.49311247", "0.4930646", "0.49087206", "0.49041092", "0.49033538", "0.49008226", "0.4869868", "0....
0.6595781
0
Create back reference to LNode in which this tile is a payload.
def connect(lnode) @lnode = lnode end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new_leaf(payload, **kwargs)\n factory.leaf_node(payload, **kwargs)\n end", "def create_payload(payload_type,lhost,lport)\n print_status(\"Creating a reverse meterpreter stager: LHOST=#{lhost} LPORT=#{lport}\")\n payload = payload_type\n pay = client.framework.payloads.create(payload)\n pa...
[ "0.61723304", "0.57945585", "0.5747753", "0.5664892", "0.5652529", "0.5592784", "0.55553687", "0.55308026", "0.55106735", "0.5492107", "0.548839", "0.54705596", "0.54602826", "0.5372844", "0.5372844", "0.53587204", "0.5339252", "0.5339229", "0.53220886", "0.53174883", "0.5313...
0.0
-1
Remove from linked list of tiles
def unlink @lnode.unlink unless @lnode.nil? end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def del\r\n @@tiles.delete_at(@tileno)\r\n @x1,@y1,@x2,@y2,@inclusive,@id,@tileno=nil\r\n end", "def remove_sprite(tile)\n @source_sprites.delete(tile)\n end", "def remove(entry); end", "def remove_from_list\n return unless in_list?\n decrement_positions_on_lower_items\n ...
[ "0.7302336", "0.6669763", "0.65243435", "0.6386418", "0.6336229", "0.6280062", "0.6263596", "0.6237697", "0.62279266", "0.6198479", "0.6181027", "0.59985673", "0.59913075", "0.5947947", "0.5937672", "0.59260255", "0.5921729", "0.5911215", "0.59051496", "0.5900077", "0.5867947...
0.0
-1
Two tiles are equal when their vertixes are geometrically equal.
def ==(tile) self.vtx == tile.vtx end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_tile_flipped_v?(x, y)\n false\n end", "def is_tile_flipped_h?(x, y)\n false\n end", "def test_for_equality_of_two_dead_grids\n grid1 = Grid.new\n grid2 = Grid.new\n assert_equal grid1, grid2\n end", "def eql?(other_grid)\n return @id == other_grid.id\n #return @id...
[ "0.6994324", "0.6765181", "0.6724114", "0.6678922", "0.6668054", "0.6648671", "0.65742254", "0.65698117", "0.65181345", "0.6461538", "0.6391877", "0.6373408", "0.6350372", "0.63329536", "0.6331863", "0.631756", "0.62612414", "0.6247491", "0.6247491", "0.62436706", "0.62027043...
0.71569157
0
Form normal vector to this tile if needed and return it.
def normal_vector return @nv unless @nv.nil? nv = self.area_vector length = nv.abs nvv=nv.map { |e| e/length } def nvv.to_s "NV:=(#{self[0]}, #{self[1]}, #{self[2]})" end @nv = nvv end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def normalize\n mag = self.magnitude\n Vector.new @x/mag, @y/mag, @z/mag\n end", "def unit_vector\n\t\tlen = self.r\n\t\traise Vector::ZeroOperation if (len == 0)\n\t\tself * (1/len)\n\t\t# Vector3D.new(@x*(1.0/len), @y*(1.0/len), @z*(1.0/len))\n\tend", "def unit_vector\n len = self.r\n raise Vect...
[ "0.6966492", "0.666255", "0.6600545", "0.65119594", "0.6344839", "0.6292786", "0.621762", "0.62027836", "0.6172049", "0.60246676", "0.60222006", "0.5916616", "0.5903314", "0.58536124", "0.5808879", "0.5791828", "0.5781592", "0.5687149", "0.56798667", "0.5670848", "0.5645632",...
0.63966465
4
Has this tile been inspected
def inspect? @inspect end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def won?\n safe_tiles = @grid.flatten.select { | tile | tile.value != BOMB }\n safe_tiles.all? { | tile | tile.revealed }\n end", "def touched_a_mine?\n self.grid.flatten.any?{ |cell| cell.visible && cell.mine }\n end", "def won?\n @grid.flatten.all? { |el| el.face_down == false }\n en...
[ "0.6543431", "0.6492921", "0.63728094", "0.6316987", "0.62072676", "0.62072676", "0.6169053", "0.6141601", "0.6071136", "0.60235035", "0.60069615", "0.5982639", "0.5982639", "0.59801763", "0.5956149", "0.5955802", "0.5940457", "0.5937477", "0.593631", "0.5922819", "0.5913911"...
0.59713507
14
Split new tile and calculate new value for new vertex
def split_and_evaluate self.split(true) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def split(evaluate=false)\n @inspect = false # no more ispection for this tile\n\n l=[0,1,2].map { |m| \n ((m+1)..2).to_a.map { |n| \n (@grd.vtxs[@vtx[m]-1].x-@grd.vtxs[@vtx[n]-1].x)**2+(@grd.vtxs[@vtx[m]-1].y-@grd.vtxs[@vtx[n]-1].y)**2\n }\n }.flatten.each_with_index.max[1]\n...
[ "0.7113034", "0.5637441", "0.5544071", "0.54419273", "0.54380554", "0.5409569", "0.536772", "0.53453314", "0.53110987", "0.5287528", "0.5205208", "0.519222", "0.5181941", "0.51650023", "0.5146524", "0.51146394", "0.50906897", "0.5081019", "0.5065067", "0.5064737", "0.5038342"...
0.0
-1
If curvature returned by nvariance() is greater then some prescribed value then this method can be called to split this tile by adding new vertex and optionally evaluate value at that new vertex
def split(evaluate=false) @inspect = false # no more ispection for this tile l=[0,1,2].map { |m| ((m+1)..2).to_a.map { |n| (@grd.vtxs[@vtx[m]-1].x-@grd.vtxs[@vtx[n]-1].x)**2+(@grd.vtxs[@vtx[m]-1].y-@grd.vtxs[@vtx[n]-1].y)**2 } }.flatten.each_with_index.max[1] # intr...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def refine(max_curvature)\n @nvariance_limit = max_curvature\n refined = 0\n tiles_to_split=[]\n @tiles.each { |i, t| \n nvr = t.value.nvariance()\n if nvr[1] > max_curvature \n # Something needs to be split, either this tile or its counterpart which gives \n # u...
[ "0.6421781", "0.52466446", "0.5030239", "0.48253778", "0.48179516", "0.4817816", "0.47594798", "0.47289082", "0.46335474", "0.46302435", "0.46219453", "0.46173134", "0.46022883", "0.4594886", "0.4568335", "0.45361236", "0.4529395", "0.44974506", "0.4488614", "0.44869852", "0....
0.6116179
1
The stop on nongraceful shutdown is executed twice: `stop(false)` and `stop`. The first stop will wipeout all workers, so we need to check the flag and a list of workers
def stop(graceful = true) if graceful && @workers.any? # rubocop:disable Gitlab/ModuleWithInstanceVariables Gitlab::Cluster::LifecycleEvents.do_before_graceful_shutdown end super end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def stop\n log(:debug) { 'Graceful shutdown requested.' }\n\n @running = false\n idle.each { |worker| worker.terminate }\n idle.clear\n\n if busy.any?\n log(:debug) { \"Wait for #{busy.size} workers to terminate.\" }\n\n wait :shutdown\n end\n\n log(:debug) { 'Grace...
[ "0.76107794", "0.7531839", "0.73700273", "0.7367013", "0.71688956", "0.70974433", "0.7059394", "0.7046478", "0.70302194", "0.70287305", "0.70052344", "0.69866514", "0.69554406", "0.6904116", "0.6902874", "0.6834527", "0.6826884", "0.6793125", "0.6790276", "0.6785692", "0.6776...
0.68780166
15
Creates a new HTML renderer.
def initialize(opts={}) super RENDERER_CONFIG.merge opts end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def renderer\n HtmlRenderer.new(self)\n end", "def renderer\n HtmlRenderer.new(self)\n end", "def renderer\n @renderer ||= HtmlRenderer.new(self)\n end", "def renderer r\n @renderer = r\n end", "def renderer r\n @renderer = r\n end", "def create_renderer(format)\n ...
[ "0.81490827", "0.81490827", "0.8069944", "0.684632", "0.684632", "0.6841386", "0.67470384", "0.65295726", "0.6367204", "0.63052213", "0.62986165", "0.6212737", "0.6203266", "0.61271906", "0.60633606", "0.60633606", "0.60480577", "0.6005265", "0.59959966", "0.5994342", "0.5987...
0.0
-1
Accesses the current user from the session.
def current_user @current_user ||= session[:user] ? User.find_by_id(session[:user]) : nil end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def current_user\n load_session\n @current_user\n end", "def current_user\n @user = User.find(@session.user_id)\n end", "def current_user\n session[:user]\n end", "def current_user\n\t\t\tUser.find(session[:user_id])\n\t\tend", "def current_user\n\t\t\tUser.find(session[:user...
[ "0.82363194", "0.81801116", "0.8137778", "0.81043464", "0.81043464", "0.80641705", "0.80641705", "0.8064157", "0.80606633", "0.8048921", "0.8042395", "0.80403244", "0.7997362", "0.7997362", "0.7980242", "0.7976951", "0.7975397", "0.7975397", "0.79686034", "0.79640454", "0.795...
0.0
-1
Store the given user in the session.
def current_user=(new_user) session[:user] = new_user.nil? ? nil : new_user.id @current_user = new_user end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def store(user)\n @session[:user_id] = user.id\n end", "def set_session_for(user)\n UserSession.create(user)\n end", "def user=(user)\n session[:user] = nil && return if user.nil?\n session[:user] = store_user(user)\n @user = session[:user] ? user : session[:user] \n end", "def use...
[ "0.80911386", "0.780224", "0.772401", "0.772401", "0.772401", "0.76050115", "0.7504764", "0.75008523", "0.75008523", "0.7476588", "0.74609214", "0.74468493", "0.74215066", "0.74198914", "0.73406714", "0.73339564", "0.73301226", "0.7305699", "0.7249476", "0.72161084", "0.72013...
0.0
-1
Check if the user is authorized. Override this method in your controllers if you want to restrict access to only a few actions or if you want to check if the user has the correct rights. Example: only allow nonbobs def authorize?(user) user.login != "bob" end
def authorized?(user) true end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def authorize?(user)\n required_perm = \"%s/%s\" % [ params[:controller], params[:action] ]\n\n if user.authorized? required_perm\n return true\n end\n\n return false\n end", "def authorize?(user)\n true\n end", "def user_authorized?(user)\n user == current_user || is_admin?\n end", ...
[ "0.8148651", "0.8031374", "0.803127", "0.80291843", "0.79955035", "0.79925644", "0.7950582", "0.79428625", "0.79093134", "0.79093134", "0.7907148", "0.7899388", "0.78761023", "0.78747207", "0.7828147", "0.7822263", "0.78021014", "0.7784675", "0.77694654", "0.77629685", "0.774...
0.8049178
1
Check whether or not to protect an action. Override this method in your controllers if you only want to protect certain actions. Example: don't protect the login and the about method def protect?(action) if ['action', 'about'].include?(action) return false else return true end end
def protect?(action) true end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def protect?(action)\n if ['login', 'signup', 'forgot_password'].include?(action)\n return false\n else\n return true\n end\n end", "def protect?(action)\n true\n end", "def protect?(action)\n\t\ttrue\n\tend", "def protect?(_action)\n true\n end", "def protect?(_action)\...
[ "0.87989885", "0.8682244", "0.85914457", "0.8354134", "0.8354134", "0.8152718", "0.7539698", "0.7465722", "0.7451467", "0.7412297", "0.73124576", "0.7309036", "0.730691", "0.71949923", "0.7129502", "0.71263164", "0.7094244", "0.70669687", "0.704649", "0.70459306", "0.6999595"...
0.8538214
6
Filter method to enforce a login requirement. To require logins for all actions, use this in your controllers: before_filter :login_required To require logins for specific actions, use this in your controllers: before_filter :login_required, :only => [ :edit, :update ] To skip this in a subclassed controller: skip_befo...
def login_required # Skip this filter if the requested action is not protected return true unless protect?(action_name) # Check if user is logged in and authorized return true if logged_in? and authorized?(current_user) # Store current location so that we can redirect back after login store_lo...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "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 = Use...
[ "0.7646216", "0.7435264", "0.7360612", "0.7268464", "0.71856695", "0.71572465", "0.7125798", "0.7107564", "0.70563394", "0.70536214", "0.70216584", "0.70207024", "0.70019275", "0.70019275", "0.70019275", "0.6989547", "0.6973472", "0.6967009", "0.6937899", "0.69274527", "0.692...
0.78820205
0
Redirect as appropriate when an access request fails. The default action is to redirect to the login screen. Override this method in your controllers if you want to have special behavior in case the user is not authorized to access the requested action. For example, a popup window might simply close itself.
def access_denied redirect_to :controller => '/account', :action => 'login' end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def access_denied\n unless logged_in?\n return redirect_to root_url\n end\n store_location(request.referer) unless session[:return_to] || request.referer.blank?\n flash_and_redirect_back(I18n.t(:you_are_not_authorized_to_perform_this_action), 403)\n end", "def access_denied\n redirect_to con...
[ "0.76617897", "0.75703347", "0.7553827", "0.7534081", "0.7529024", "0.7491922", "0.74263024", "0.7362403", "0.7358952", "0.7323035", "0.724715", "0.7247033", "0.72121555", "0.7207165", "0.7187631", "0.7187631", "0.71544224", "0.715291", "0.7143917", "0.71409726", "0.7129224",...
0.73850644
7
Store the URI of the current request in the session. We can return to this location by calling redirect_back_or_default.
def store_location session[:return_to] = request.request_uri end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def store_location\n session[:redirect_path] = request.path\n end", "def store_location\n session[:return_to] = request.request_uri if not current_user\n end", "def store_location\n session[:return_to] = request.uri\n end", "def store_location\n session[:return_to] = ...
[ "0.8091558", "0.8024166", "0.8011449", "0.80046636", "0.7896436", "0.7896008", "0.78846407", "0.7874102", "0.78736126", "0.78480256", "0.7847377", "0.7842461", "0.7842461", "0.7842461", "0.7842461", "0.7828938", "0.7808239", "0.7801609", "0.7800365", "0.7781793", "0.7781793",...
0.76822656
44
Redirect to the URI stored by the most recent store_location call or to the passed default.
def redirect_back_or_default(default) session[:return_to] ? redirect_to_url(session[:return_to]) : redirect_to(default) session[:return_to] = nil end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def redirect_back_or_default(default)\n redirect_to(pop_stored_location || default)\n end", "def redirect_back_or_default(default)\n redirect_to(pop_stored_location || default)\n end", "def redirect_to_stored_location_or(default)\n redirect_to(session[:forward_url] || default)\n sessi...
[ "0.8189429", "0.81658125", "0.8076723", "0.7892677", "0.77718544", "0.77380234", "0.76318663", "0.7475492", "0.74571997", "0.7427644", "0.7422457", "0.7355235", "0.73458606", "0.7312342", "0.7303291", "0.7278116", "0.7278116", "0.7278116", "0.7278116", "0.7278116", "0.7275049...
0.0
-1
Instance Methods returns true if this instance has a maintenance schedule, false otherwise
def has_maintenance_schedules? maintenance_schedules.count > 0 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def has_schedule?\n self.schedule != nil\n end", "def do_scheduling?\n\t\t!self.scheduled_at.blank?\n\tend", "def active?\n schedule.active?\n end", "def scheduled?\r\n @time != :forever\r\n end", "def scheduled?\n status == Status[:scheduled]\n end", "def scheduled?\n self...
[ "0.7654308", "0.744693", "0.74240285", "0.7363587", "0.72190464", "0.7177085", "0.71573764", "0.7131449", "0.7106842", "0.69813794", "0.6916223", "0.6902622", "0.68938506", "0.68878615", "0.6886668", "0.67657167", "0.6647699", "0.6644699", "0.6639099", "0.6615866", "0.6614203...
0.87801516
0
Ruta interna de cada fichero.
def file_system_path path_prefix = (thumbnail ? thumbnail_class : self).attachment_options[:path_prefix].to_s [path_prefix, self.parent_type.underscore, attachment_path_id.to_s, self.id.to_s] + partitioned_path(thumbnail_name_for(thumbnail)) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def files\n real_path = self.path[2...-1] + \"s/*\"#trim './' and add 's/*' \n \n Dir[real_path].map{|file| file.split(\"/\")[-1]} \n end", "def files\n file = Dir[self.path + \"/*\"]\n file.each do |file_name|\n file_name.slice!(self.path + \"/\...
[ "0.6478239", "0.64590013", "0.6257271", "0.6161855", "0.6112664", "0.60625666", "0.60160536", "0.59907013", "0.59907013", "0.59907013", "0.59907013", "0.59907013", "0.59907013", "0.5967563", "0.59642184", "0.59605134", "0.59153473", "0.5781407", "0.5780372", "0.5779115", "0.5...
0.0
-1
Identify and describe the Ruby method(s) you implemented. .select Returns an array containing all elements of an enumerator for which the given block returns a true value. .to_s Returns a string representation of what is called. .inlude?() Checks whether a particular item is included in the array. Person 2
def my_array_modification_method!(source, thing_to_modify) source.map! do |e| if e.class == Fixnum e = e + thing_to_modify elsif e.class == String e = e end end return source end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def not_mutate(arr)\n # calls the '.select' method on the 'arr' parameter with a condition given\n arr.select { |i| i > 3 }\nend", "def filter_methods; end", "def discard(a)\n clean = a.select {|x| x >= 5}\n print clean\n \nend", "def excluded; end", "def exclude\n all - methods\n end", "d...
[ "0.5959447", "0.5856049", "0.5839577", "0.5553825", "0.55512124", "0.5530916", "0.5510879", "0.5419474", "0.538862", "0.538862", "0.538862", "0.5316892", "0.5303111", "0.52942693", "0.5264114", "0.5261984", "0.5260056", "0.5240531", "0.52375615", "0.520102", "0.5163784", "0...
0.0
-1
Identify and describe the Ruby method(s) you implemented. .map! > changes array in place (destructively) .keys.each > enumerates through the keys in the hash Person 3
def my_array_sorting_method(source) source # This line is here to make sure all tests initially fail. Delete it when you begin coding. end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def each_map_exp\n\n \tletters = [\"aaa\", \"b\", \"c\", \"d\", \"e\", \"a\", \"b\", \"h\"]\n\n\tsuperheroes = {\n\t\tsuperman: \"flying\",\n\t\tbatman: \"World's greatest butler\",\n\t\tspiderman: \"shooting web\"\n\t}\n\n\n\tputs \"\\n\\n Using .each\\n\"\n\t#---------------------------------------\n\tputs \"Thi...
[ "0.61500216", "0.59393996", "0.5797689", "0.57718676", "0.57717013", "0.5755111", "0.5742484", "0.5654035", "0.55877733", "0.5566423", "0.5560355", "0.5559929", "0.5545523", "0.5516701", "0.5501736", "0.5501736", "0.5501736", "0.5501736", "0.5501736", "0.5501736", "0.5501736"...
0.0
-1
Identify and describe the Ruby method(s) you implemented. Person 4
def my_array_deletion_method!(source, thing_to_delete) source.dup # This line is here to make sure all tests initially fail. Delete it when you begin coding. end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def methods() end", "def extract_method_details; end", "def method_name; end", "def method_name; end", "def method_name; end", "def method_name; end", "def method_name; end", "def method_name; end", "def method_name; end", "def method_name; end", "def method_name; end", "def method_name; end"...
[ "0.7253813", "0.7076371", "0.7058754", "0.7058754", "0.7058754", "0.7058754", "0.7058754", "0.7058754", "0.7058754", "0.7058754", "0.7058754", "0.7058754", "0.7058754", "0.7058754", "0.69988453", "0.69988453", "0.69988453", "0.69988453", "0.6904427", "0.6849958", "0.6849958",...
0.0
-1
Identify and describe the Ruby method(s) you implemented. Person 5
def my_array_splitting_method(source) source # This line is here to make sure all tests initially fail. Delete it when you begin coding. end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def methods() end", "def method_name; end", "def method_name; end", "def method_name; end", "def method_name; end", "def method_name; end", "def method_name; end", "def method_name; end", "def method_name; end", "def method_name; end", "def method_name; end", "def method_name; end", "def me...
[ "0.7143743", "0.70301783", "0.70301783", "0.70301783", "0.70301783", "0.70301783", "0.70301783", "0.70301783", "0.70301783", "0.70301783", "0.70301783", "0.70301783", "0.70301783", "0.6950313", "0.6890645", "0.6890645", "0.6890645", "0.6890645", "0.6845975", "0.6792564", "0.6...
0.0
-1
show the user email in the admin UI instead of the user id
def show_username_label_method username end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def u_email\n (self.user).email\n end", "def get_user_email\n user = User.find(self.user_id)\n user.email\n end", "def display_name\n email\n end", "def user_email\n @gapi.user_email\n end", "def email\n admin.try(:email)\n end", "def me_user_email\n email = Emai...
[ "0.76300097", "0.7560558", "0.75405484", "0.74504733", "0.74186754", "0.7388461", "0.7369356", "0.736829", "0.73680633", "0.7353916", "0.73236823", "0.72593164", "0.72558826", "0.72456616", "0.72195035", "0.72195035", "0.7184307", "0.7167534", "0.7134524", "0.71032107", "0.70...
0.0
-1
Updates comment count for this article.
def count_comments! self.update_attribute(:num_comments, comments.viewable.size) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_commentable_comments_count\n if self.commentable && self.commentable.class.columns.to_a.map {|a| a.name.to_sym}.include?(:comments_count)\n self.commentable.class.transaction do \n self.commentable.lock!\n self.commentable.update_attribute(:comments_count,\n self.commentab...
[ "0.7678301", "0.76770145", "0.76391786", "0.7570387", "0.7087299", "0.6991813", "0.6941275", "0.6898958", "0.6876832", "0.6854972", "0.66938263", "0.66837376", "0.6592451", "0.64824647", "0.6430953", "0.6363921", "0.6342089", "0.6290532", "0.6290532", "0.6259647", "0.62508124...
0.75367606
4
Work around error e.g.: method `description' created by attr_reader/writer or define_method cannot be called from ObjectiveC. Please manually define the method instead (using the `def' keyword)
def age; @age; end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_model_design_doc_reader\n model.instance_eval \"def #{method}; @#{method}; end\"\n end", "def macro; raise NotImplementedError; end", "def macro; raise NotImplementedError; end", "def macro; raise NotImplementedError; end", "def desc_to\n raise NoMethodError, \"#{self.clas...
[ "0.63658", "0.6350674", "0.6350674", "0.6350674", "0.6215288", "0.61976343", "0.6197565", "0.6196422", "0.61519706", "0.6144609", "0.6144609", "0.6144609", "0.6144609", "0.6144609", "0.6144609", "0.6144609", "0.6144609", "0.6144609", "0.6144609", "0.61373466", "0.60924685", ...
0.0
-1
chooses from adminuploaded slide, original slide, or default slide
def image if attachment? attachment.url(:large) elsif filename? "/images/slides/#{filename}" else "/images/slides/default.jpg" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_slide\n @slide = @presentation.slides.friendly.find(params[:id]) \n end", "def set_slide\n @slide = Slide.nondraft.find(params[:id])\n end", "def set_slide\n @slide = Slide.where(id: params[:id]).accessible_by(current_ability).take\n end", "def set_slide\n @slide = Sli...
[ "0.7110734", "0.6858387", "0.64932644", "0.64927346", "0.644004", "0.644004", "0.644004", "0.644004", "0.644004", "0.63848466", "0.6378179", "0.63469094", "0.6329821", "0.61753255", "0.60492384", "0.6028375", "0.5826286", "0.5807997", "0.58069897", "0.5763813", "0.5754875", ...
0.52740836
54
Gets the ConceptScheme, etc
def terms_id parse_terms_id_response(SolrQuery.new.solr_query(q='rdftype_tesim:"http://www.w3.org/2004/02/skos/core#ConceptScheme" AND preflabel_tesim:"places"')) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def concept_themes\n find_related_frbr_objects( :has_as_its_theme, :which_concepts?) \n end", "def concept_themes\n find_related_frbr_objects( :has_as_its_theme, :which_concepts?) \n end", "def concept_genres\n find_related_frbr_objects( :has_as_its_genre, :which_concep...
[ "0.64924705", "0.64924705", "0.6206174", "0.6206174", "0.6075139", "0.59762126", "0.59762126", "0.5855563", "0.57979", "0.5788328", "0.5788328", "0.5788328", "0.5788328", "0.57820225", "0.57820225", "0.55848396", "0.55573624", "0.549864", "0.5482248", "0.5482248", "0.5481207"...
0.0
-1
Reformats the data received from the service
def parse_authority_response(response) response['response']['docs'].map do |result| geo = TermsHelper::Geo.new #al = geo.adminlevel(result['parentADM1_tesim'].first,result['parentADM2_tesim'].first) { 'id' => result['id'], #'label' => "#{result['preflabel_tesim'].first} (#{al})", '...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def format data\n data\n end", "def format_service_response\n formatted_response = @service_response\n\n if formatted_response.success?\n formatted_response.data = get_formatter_class.send(params['action'], formatted_response.data.dup)\n end\n\n # puts \"\\nFinal formatted response : #{f...
[ "0.6733846", "0.67071843", "0.6347372", "0.61690414", "0.60347164", "0.60347164", "0.5986301", "0.59549576", "0.58699375", "0.58362377", "0.57547903", "0.57325584", "0.57325584", "0.5709452", "0.5606003", "0.5581652", "0.5546628", "0.552456", "0.552456", "0.5500004", "0.54899...
0.0
-1
Override this method in subclasses
def handle_results(env, request = nil) # override me! end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def overrides; end", "def private; end", "def tag; raise 'Override this method'; end", "def special\n override\n end", "def custom; end", "def custom; end", "def proxy\n super\n end", "def type; super; end", "def super_method; end", "def implementation; end", "def implementation; en...
[ "0.7491074", "0.72695434", "0.7070855", "0.70639527", "0.7056432", "0.7056432", "0.6886435", "0.68100846", "0.6770186", "0.67684007", "0.67684007", "0.67252684", "0.6711094", "0.6694478", "0.660578", "0.66050726", "0.66050726", "0.6591114", "0.6591114", "0.6526841", "0.646655...
0.0
-1
Returns elapsed time since start_time in milliseconds.
def run_time ((Time.now - start_time) * 1000).round end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def elapsed_time\n (Time.now.to_f - @start_time) * 1000000\n end", "def elapsed_time\n (Time.now.to_f - @start_time) * 1000\n end", "def time_elapsed\n Time.now - @start_time\n end", "def elapsed\n (Time.now - @start_time).round\n end", "def time_elapsed\n\t\tret...
[ "0.8620768", "0.86205447", "0.8329055", "0.82164234", "0.7994374", "0.7930881", "0.7919736", "0.76255757", "0.76055455", "0.73378897", "0.7324695", "0.7245133", "0.7219967", "0.7201698", "0.7197708", "0.7177086", "0.71172637", "0.708315", "0.7064483", "0.70423293", "0.7026613...
0.6831787
29
In order to prove it's success and gain funding, the wilderness zoo needs to prove to environmentalists that it has x number of mating pairs of bears. You must check within string (s) to find all of the mating pairs, and return a string containing only them. Line them up for inspection. Rules: Bears are either 'B' (mal...
def bears(num, str) i = 0 answer = [] arr = str.split('') while i < arr.length - 1 if (arr[i] == 'B' && arr[i + 1] == '8') || (arr[i] == '8' && arr[i + 1] == 'B') answer << arr[i] << arr[i + 1] i += 2 else i += 1 end end [answer.join, answer.length / 2 >= num] en...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def bears(x, s)\n mating_bears = s.scan(/8B|B8/) \n p [mating_bears.join, mating_bears.size >= x]\nend", "def pairs_of_bears(x,s)\n pairs = s.scan(/(B8|8B)/)\n [pairs.join, pairs.size >= x]\nend", "def bears(x,s)\n\n #scan for occurrences of 8B or B8\n bear_array = s.scan(/(8B)|(B8)/) || []\n\n #if the ...
[ "0.7437662", "0.74280864", "0.7284417", "0.59164095", "0.58820295", "0.57880175", "0.57716864", "0.56907254", "0.5670439", "0.56578207", "0.56192636", "0.55979604", "0.55963457", "0.5596101", "0.55908126", "0.558656", "0.5561122", "0.5559283", "0.5539468", "0.5529371", "0.550...
0.69592524
3
value of assignments amounts must total the amount of the bill
def validate_assignments assignments.sum(:amount_in_cents) == self[:amount_in_cents] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def amount_to_set\n # if (report && Response.payment_node(report) && Response.payment_node(report)[:authorization] && Response.payment_node(report)[:authorization][:amount].present?)\n if (report && Response.payment_node(report) && Response.payment_node(report)[:authorization] && Response.payment_node(r...
[ "0.6553415", "0.65416026", "0.6397203", "0.6337896", "0.6327445", "0.63042444", "0.62926185", "0.62299985", "0.62053925", "0.61968434", "0.61941457", "0.61912656", "0.6160207", "0.61516637", "0.6148951", "0.6127773", "0.6121066", "0.6103509", "0.60988146", "0.60812163", "0.60...
0.80089724
0
Then it needs to ask them how many widgets they're ordering. It should wait for them to type in a quantity and press Enter. The program will need to store whatever quantity they enter in the computer's memory. Each widget costs $10, so the program should multiply the quantity by 10 to get the total cost. It should prin...
def ask(question) print question + " " gets.to_i end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def quantity(fruit, receipt)\n\n\tapple_cost = 2\n\tbanana_cost = 1\n\tlemon_cost = 3\n\tmango_cost = 2\n\tpear_cost = 4\n\n\tputs \"How many would you like?\"\n\tamount = gets.chomp.to_i\n\n\tif fruit == 1\n fruit_item = \"Apple\"\n item_price = apple_cost\n total_price = apple_cost * amount\n receipt...
[ "0.69330996", "0.6919303", "0.66264635", "0.65627795", "0.65363216", "0.65008575", "0.6450124", "0.6447968", "0.64119506", "0.6300934", "0.6211646", "0.6186255", "0.6170969", "0.6139829", "0.61323357", "0.61196595", "0.611951", "0.61181694", "0.6105991", "0.6089451", "0.60543...
0.0
-1
Wrap resource into Reform::Form if needed
def apply_form(resource) if apply_form? form = form_class.new(resource) form.prepopulate! if prepopulate_form? form else resource end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def to_resource(mapper)\n Resource::Form::Field.new(\n resource_attributes.each_with_object({}) do |attr, attrs|\n attrs[attr] = mapper.expand_value(public_send(attr))\n end.merge(options: options.map(&:to_resource))\n )\n end", "def form\n @form |...
[ "0.6628789", "0.660049", "0.6169119", "0.6095209", "0.6095049", "0.60832584", "0.5998638", "0.5927675", "0.59091574", "0.5908354", "0.5890264", "0.58658683", "0.5852071", "0.583952", "0.5838246", "0.58320266", "0.5801889", "0.5800996", "0.57645804", "0.5747202", "0.5747073", ...
0.716084
0
Public: Provides a configuration option that sets the key_path Examples AWS::CF::Signer.configure do |config| config.key_path = "/path/to/your/keyfile.pem" end Returns nothing.
def key_path=(path) raise ArgumentError.new("The signing key could not be found at #{path}") unless File.exists?(path) @key_path = path self.key=(File.readlines(path).join("")) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def with_config(signing_key:, encryption_key: nil)\n old_config = @config\n configure(signing_key: signing_key, encryption_key: encryption_key)\n yield\n ensure\n @config = old_config\n end", "def signing_key; end", "def signing_key= new_key\n @signing_key = new_key\n end"...
[ "0.5982389", "0.5786115", "0.5682375", "0.563493", "0.56191486", "0.56043154", "0.55620784", "0.5514017", "0.5444496", "0.54410344", "0.54210496", "0.53675425", "0.53639", "0.5359166", "0.5343199", "0.53091395", "0.5296704", "0.5294945", "0.52832067", "0.5261242", "0.52607095...
0.60425824
0
Public: Provides a configuration option to set the key directly as a string e.g. as an ENV var Examples AWS::CF::Signer.configure do |config| config.key = ENV.fetch('KEY') end Returns nothing.
def key=(key) @key = OpenSSL::PKey::RSA.new(key) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def keyfile_arg\n return '' unless ENV['BEAKER_KEYFILE']\n \"--keyfile=#{ENV['BEAKER_KEYFILE']}\"\nend", "def aws_access_key(arg = nil)\n if arg.nil? && @aws_access_key.nil?\n @aws_access_key_id\n else\n set_or_return(:aws_access_key, arg, kind_of: String)\n end\nend", "def app_config_key=(value)\n ...
[ "0.62985677", "0.61076385", "0.6080518", "0.600895", "0.5998317", "0.5996153", "0.5962927", "0.59327316", "0.59084904", "0.5908036", "0.58786374", "0.5875457", "0.5826351", "0.581085", "0.57693523", "0.5742388", "0.5707769", "0.5679819", "0.56493187", "0.5644529", "0.5625911"...
0.0
-1
Public: Provides an accessor to the key_path Returns a String value indicating the current setting
def key_path @key_path end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def Path\n @key\n end", "def key \n path\n end", "def path_key\n env.keys.grep(/\\Apath\\Z/i).first\n end", "def full_key_path\n Pathname.new(spec.key_path).expand_path(@base_dir)\n end", "def key_path\n\t\t\tFile.join(@root, \"#{@hostname}.key\")\n\t\tend", "def value_for...
[ "0.76133853", "0.75183004", "0.69477147", "0.6617524", "0.6507414", "0.64689106", "0.6446792", "0.6413818", "0.63779384", "0.637739", "0.63438207", "0.6309219", "0.6272847", "0.62621236", "0.62572086", "0.62572086", "0.62493396", "0.6248253", "0.6191474", "0.61474556", "0.614...
0.78608155
0
Public: Provides a configuration option that sets the default_expires in seconds Examples AWS::CF::Signer.configure do |config| config.default_expires = 3600 end Returns nothing.
def default_expires=(value) @default_expires = value end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def default_expires\n @default_expires ||= 3600\n end", "def default_expiration= new_default_expiration\n patch_gapi! default_expiration: new_default_expiration\n end", "def set_expires_at\n self[:expires_at] = case self.expiry_option \n when :in then Time.now.utc + (self.ex...
[ "0.6736713", "0.65374196", "0.62921286", "0.6230385", "0.6156935", "0.5954144", "0.5949323", "0.5839786", "0.5797623", "0.5767499", "0.57605356", "0.5740564", "0.56973386", "0.5679036", "0.5653441", "0.56428057", "0.56330186", "0.5614058", "0.5582065", "0.55803126", "0.557188...
0.70232624
0
Public: Provides an accessor to the default_expires value Returns an Integer value indicating the current setting (seconds)
def default_expires @default_expires ||= 3600 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def default_expires=(value)\n @default_expires = value\n end", "def default_expire; @@default_expire; end", "def default_expire=(value)\n raise ArgumentError, \"#{name}.default_expire value must be greater than 0\" unless (value = value.to_f) > 0\n @@default_expire = value\n ...
[ "0.85520506", "0.77085817", "0.7587904", "0.7402168", "0.7266429", "0.70804995", "0.7040611", "0.7040611", "0.702865", "0.702053", "0.6997637", "0.6996345", "0.6952876", "0.6904973", "0.6904973", "0.6899669", "0.68952835", "0.6798197", "0.676351", "0.67526454", "0.6718336", ...
0.85942554
0
Private: Provides an accessor to the RSA key value Returns an RSA key pair.
def private_key @key end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def private_key\n OpenSSL::PKey::RSA.new(_keypair)\n end", "def rsa_key(key_as_string)\n OpenSSL::PKey::RSA.new key_as_string\n end", "def private_rsa\n if @key\n private_key = @private_key.decrypt(:symmetric, :key => @key, :algorithm => @algorithm)\n OpenSSL::PKey::RSA.new...
[ "0.7070235", "0.68649274", "0.6837868", "0.68310463", "0.6741538", "0.6741538", "0.6686422", "0.6514021", "0.6511261", "0.6429633", "0.6429633", "0.6425417", "0.63355315", "0.6328584", "0.6320357", "0.6269216", "0.6251924", "0.6243478", "0.6185443", "0.616084", "0.613452", ...
0.63511825
12
Method to initialize a new planet
def init =begin Positions in array @spec for factors: 0 orefactor 1 energyfactor 2 populationfactor 3 credtitfactor 4 crysstalfactor 5 lagerfactor 6 buildfactor 7 forschungfactor =end @spec = [1, 1, 1, 1, 1, 1, 1, 1] self.calc_spec if self.name.nil? #self.under_co...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_planet(name, mass, year_length, diameter, number_of_moons, distance_from_sun)\n return Planet.new(name, mass, year_length, diameter, number_of_moons, distance_from_sun)\nend", "def set_planet\n end", "def initialize(planet_hash)\n @name = planet_hash[:name]\n @moons = planet_hash[:moons]\n...
[ "0.7716384", "0.7693172", "0.7609123", "0.7578565", "0.7507842", "0.74760807", "0.7476052", "0.74706596", "0.7407709", "0.74006355", "0.73726916", "0.7371227", "0.7366412", "0.69579375", "0.69579375", "0.68996006", "0.6862272", "0.68609506", "0.68609506", "0.68609506", "0.686...
0.0
-1
Method which increases and updates all the resources a player has every ...Minute
def update_resources if energy > 0 # # updates ore production # ore_production = self.get_production(:Oremine).to_i if ore_production.integer? then if (self.ore + ore_production) < self.maxore then self.ore += ore_production else self.ore = s...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_counters\n player.plays_count.increment\n opponent.plays_count.increment\n true\n end", "def player_win\n @player_win += 1\n end", "def update_summons\n # for each summoned battler\n @summon_time.each_key {|summon|\n # decrease counter\n @summon_time[summon]...
[ "0.6559784", "0.6478728", "0.61921036", "0.6138324", "0.6106876", "0.6072764", "0.60399467", "0.59800184", "0.59120685", "0.5868073", "0.583714", "0.5835432", "0.5813274", "0.58072275", "0.5786557", "0.5781787", "0.5768647", "0.5758662", "0.5734632", "0.5727251", "0.5688787",...
0.5757259
18
GET /reservations GET /reservations.json
def index @reservations = Reservation.all respond_to do |format| format.html # index.html.erb format.json { render json: @reservations } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n render json: reservations\n end", "def index\n @reservations = Reservation.all\n end", "def index\n @reservations = Reservation.all\n end", "def index\n @reservations = Reservation.all\n end", "def index\n @reservations = Reservation.all\n end", "def index\n @reservatio...
[ "0.80168474", "0.77413225", "0.77413225", "0.77413225", "0.77413225", "0.77413225", "0.77413225", "0.77413225", "0.77413225", "0.77413225", "0.77413225", "0.77413225", "0.77413225", "0.77413225", "0.77413225", "0.77413225", "0.7642628", "0.7595051", "0.75216544", "0.73537683", ...
0.7786847
2
GET /reservations/1 GET /reservations/1.json
def show @reservation = Reservation.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render json: @reservation } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n render json: reservations\n end", "def index\n @reservations = Reservation.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @reservations }\n end\n end", "def index\n @reservations = Reservation.all\n\n respond_to do |format|\n...
[ "0.77576584", "0.74549264", "0.74549264", "0.7452395", "0.74071085", "0.74071085", "0.74071085", "0.74071085", "0.74071085", "0.74071085", "0.74071085", "0.74071085", "0.74071085", "0.74071085", "0.74071085", "0.74071085", "0.74071085", "0.74071085", "0.74071085", "0.7223718", ...
0.74343014
9
GET /reservations/new GET /reservations/new.json
def new @reservation = Reservation.new respond_to do |format| format.html # new.html.erb format.json { render json: @reservation } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @reservation = Reservation.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @reservation }\n end\n end", "def new\n\t\t@reservation = Reservation.new\n\tend", "def new\n @reserf = Reserve.new\n\n respond_to do |format|\n format.html...
[ "0.79766536", "0.7523747", "0.7430607", "0.74195325", "0.73914725", "0.73392314", "0.7239241", "0.7237717", "0.71611136", "0.7113653", "0.70620835", "0.70620835", "0.70610356", "0.69741124", "0.69482565", "0.6942841", "0.6942841", "0.693652", "0.6850221", "0.68151796", "0.679...
0.79906124
2
POST /reservations POST /reservations.json
def create @reservation = Reservation.new(params[:reservation]) @reservation.status = "Pending" @reservation.user = current_user place = Place.find_by_id(params[:reservation][:place_id]) @reservation.object_resources << place.object_resources if place respond_to do |format| if @reservat...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @reservation = Reservation.new(reservation_params)\n\n if @reservation.save\n render :show, status: :created, location: @reservation\n else\n render json: @reservation.errors, status: :unprocessable_entity\n end\n end", "def create_reservations\n Time.use_zone(@timezone) do...
[ "0.7194919", "0.7160964", "0.71429306", "0.71429306", "0.71309876", "0.7122873", "0.7094922", "0.7020014", "0.6982723", "0.6949989", "0.69223315", "0.69049865", "0.69049865", "0.6894482", "0.68926275", "0.6880973", "0.6826599", "0.68029755", "0.6785963", "0.67706347", "0.6745...
0.6445297
60
DELETE /reservations/1 DELETE /reservations/1.json
def destroy @reservation = Reservation.find(params[:id]) @reservation.destroy respond_to do |format| format.html { redirect_to reservations_url } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n reservation = Reservation.find(params[:id])\n if reservation\n reservation.destroy\n render json: reservation\n else \n render json: [\"Reservation doesnt exist\"], status: 404 \n end \n end", "def destroy\n @reservation.destroy\n\n respond_to do |format|\n fo...
[ "0.7747309", "0.7567083", "0.7545028", "0.7545028", "0.7545028", "0.74918175", "0.7434657", "0.73913974", "0.73028004", "0.73028004", "0.73028004", "0.73028004", "0.73028004", "0.73028004", "0.73028004", "0.73028004", "0.73028004", "0.73028004", "0.73028004", "0.73028004", "0...
0.7607613
4
Syncs up the milestone with lighthouse updates
def sync_with_lighthouse results = Lighthouse.get_milestone(self.remote_id, self.project.remote_id, self.project.token.account, self.project.token.token) return false unless milestone = results["milestone"] self.update(:name => milestone["title"], :due_on => milestone["due_on"], :tickets_count => mile...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def mte_prepare_updating; send_request_to_mite(\"update\"); end", "def updates\n display \"Populating updates...\"\n TrelloStandup::Trello.generate_updates\n display \"Completed.\"\n end", "def push!(local)\n if remote_id = local.remote_id(project.id)\n type = local.is_a?(Milestone) ? 'Milest...
[ "0.59911335", "0.59337056", "0.5797835", "0.5594173", "0.55906135", "0.55398047", "0.5539003", "0.55244297", "0.5520792", "0.5508697", "0.54690254", "0.54122174", "0.5351052", "0.53459936", "0.5343829", "0.5343829", "0.5336772", "0.53259176", "0.5324314", "0.5319448", "0.5315...
0.7660768
0
returns a BOSH provider (CPI) specific object with helpers related to that provider
def for_bosh_provider_name(system_config) case system_config.bosh_provider.to_sym when :aws Bosh::CloudFoundry::Providers::AWS.new(system_config.microbosh.fog_compute) when :openstack Bosh::CloudFoundry::Providers::OpenStack.new(system_config.microbosh.fog_compute) else raise "please s...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def provider\n @provider ||= Bosh::CloudFoundry::Providers.for_bosh_provider_name(system_config)\n end", "def cim_gateway\n @provider\n end", "def provider\n @provider ||= Bosh::CloudFoundry::Providers.for_bosh_provider_name(system_config)\n end", "def provider_cli\n @provider_cli ||= begi...
[ "0.6294546", "0.62511396", "0.61833036", "0.6147636", "0.6146993", "0.61357707", "0.6079126", "0.6047706", "0.6047706", "0.60328925", "0.5995505", "0.5843701", "0.5749539", "0.5686109", "0.5675222", "0.56664526", "0.56576973", "0.56239647", "0.56127876", "0.5606567", "0.55182...
0.58687913
11
def generate_starting_board generate_white_pieces generate_black_pieces end
def ensure_valid_origin_and_destination(player) reset_origin_and_destination ensure_valid_origin(player) until !@origin.nil? && valid_coordinate?(@origin) ensure_valid_destination(player) until !@destination.nil? && valid_coordinate?(@destination) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def generate_board\n [0, 1, 2].each do |row|\n 0.upto(7) do |col|\n offset = row + col\n self[[row, col]] = Piece.new([row, col], self, :B) if offset.odd?\n end\n end\n\n [5, 6, 7].each do |row|\n 0.upto(7) do |col|\n offset = row + col\n self[[row, col]] = Piece...
[ "0.8059692", "0.7908037", "0.7523565", "0.7488134", "0.7348603", "0.7336573", "0.73270035", "0.7310835", "0.7310452", "0.7217845", "0.7192138", "0.7185803", "0.71836317", "0.71363056", "0.71304715", "0.7107911", "0.70947665", "0.70680165", "0.7043803", "0.7042884", "0.7014665...
0.0
-1
Coding 1 Here num1 and num2 will be added by using my_result method
def add(num1, num2) my_result = (num1 + num2) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add(first_num, second_num)\n @result = (first_num + second_num)\nend", "def add(num_1, num_2)\n\tresult = num_1 + num_2\n\treturn result\nend", "def add(num_1, num_2)\n #your code here\n \treturn (num_1 + num_2)\nend", "def additionm(num_1,num_2)\n return num_1 + num_2\nend", "def numbers(num1, num...
[ "0.7517499", "0.7306435", "0.7196106", "0.71569127", "0.71069354", "0.7071656", "0.7070748", "0.7068055", "0.7066309", "0.7056129", "0.70360166", "0.7021447", "0.7021447", "0.7000857", "0.69466853", "0.6945204", "0.6925389", "0.6925389", "0.6925389", "0.6925389", "0.6922138",...
0.73079985
1
GET /korans GET /korans.json
def index @korans = Koran.all @days=Day.all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @kraje = Kraj.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @kraje }\n end\n end", "def index \n fans = Fan.all \n render json: fans \n end", "def show\n @kazoku = Kazoku.find(params[:id])\n\n respond_to do |for...
[ "0.6867355", "0.66476727", "0.6506886", "0.6472898", "0.64320487", "0.64207923", "0.63938916", "0.63909566", "0.63626873", "0.63531303", "0.63497615", "0.63268334", "0.6310715", "0.6289736", "0.6269072", "0.6232667", "0.6231111", "0.6230927", "0.6230714", "0.62250245", "0.622...
0.0
-1
GET /korans/1 GET /korans/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @kraje = Kraj.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @kraje }\n end\n end", "def show\n @kolegiji = Kolegiji.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: ...
[ "0.67918015", "0.6763048", "0.6744727", "0.67391425", "0.66812056", "0.6678818", "0.66083544", "0.6545257", "0.65374357", "0.6463358", "0.6461304", "0.64381725", "0.64206964", "0.640083", "0.6396942", "0.63587373", "0.6335598", "0.630637", "0.630557", "0.6304121", "0.6294172"...
0.0
-1
POST /korans POST /korans.json
def create @koran = Koran.new(koran_params) respond_to do |format| if @koran.save format.html { redirect_to @koran, notice: 'Koran was successfully created.' } format.json { render :show, status: :created, location: @koran } else format.html { render :new } format.js...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @kraj = Kraj.new(params[:kraj])\n\n respond_to do |format|\n if @kraj.save\n format.html { redirect_to @kraj, notice: 'Kraj was successfully created.' }\n format.json { render json: @kraj, status: :created, location: @kraj }\n else\n format.html { render action: \"...
[ "0.6217024", "0.6180654", "0.612072", "0.60586643", "0.60194993", "0.59964687", "0.5983726", "0.595036", "0.59369504", "0.5928083", "0.5919577", "0.5895961", "0.58753735", "0.58652943", "0.58468395", "0.5846724", "0.584665", "0.58308667", "0.5792299", "0.5758415", "0.57566506...
0.6560198
0
PATCH/PUT /korans/1 PATCH/PUT /korans/1.json
def update respond_to do |format| if @koran.update(koran_params) format.html { redirect_to @koran, notice: 'Koran was successfully updated.' } format.json { render :show, status: :ok, location: @koran } else format.html { render :edit } format.json { render json: @koran.e...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def patch!\n request! :patch\n end", "def update\n @kraj = Kraj.find(params[:id])\n\n respond_to do |format|\n if @kraj.update_attributes(params[:kraj])\n format.html { redirect_to @kraj, notice: 'Kraj was successfully updated.' }\n format.json { head :no_content }\n else\n ...
[ "0.6465524", "0.63497335", "0.6232374", "0.6231447", "0.61973095", "0.6189094", "0.6187938", "0.6184724", "0.61774296", "0.61755943", "0.6169128", "0.61562085", "0.61562085", "0.61497504", "0.61371416", "0.61266303", "0.6093443", "0.6076625", "0.6061629", "0.6056563", "0.6054...
0.6372777
1
DELETE /korans/1 DELETE /korans/1.json
def destroy @koran.destroy respond_to do |format| format.html { redirect_to korans_url, notice: 'Koran was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete\n render json: Alien.delete(params[\"id\"])\n end", "def delete\n client.delete(\"/#{id}\")\n end", "def delete\n request(:delete)\n end", "def delete path\n make_request(path, \"delete\", {})\n end", "def destroy\n @kota_stone.destroy\n respond_to do |format|\n...
[ "0.71480894", "0.70938116", "0.6914788", "0.6914752", "0.6900177", "0.68669105", "0.6860165", "0.6853512", "0.68475807", "0.68190914", "0.6814453", "0.68040824", "0.679052", "0.679052", "0.678028", "0.6765948", "0.67643183", "0.676119", "0.6750238", "0.67463917", "0.6736981",...
0.68911004
5
Use callbacks to share common setup or constraints between actions.
def set_koran @koran = Koran.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_...
[ "0.61637366", "0.60446453", "0.59452957", "0.591511", "0.58885515", "0.5834122", "0.57761765", "0.5702554", "0.5702554", "0.5652102", "0.5619581", "0.5423898", "0.5409782", "0.5409782", "0.5409782", "0.5394745", "0.53780794", "0.5356209", "0.5338898", "0.53381324", "0.5328622...
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def koran_params params[:koran].permit(:name, :image, :website, :monday, :tuesday, :wednesday, :thursday, :friday, :saturday, :sunday) # params[:koran] 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...
[ "0.69811666", "0.6782836", "0.6747644", "0.6742015", "0.6735273", "0.6593917", "0.65037674", "0.6498627", "0.6482372", "0.64795715", "0.64566946", "0.6439213", "0.6380714", "0.6378147", "0.63657266", "0.63206697", "0.6300169", "0.62992156", "0.6295538", "0.62943023", "0.62915...
0.0
-1
initalize board and players
def initialize(player_1 = Players::Human.new("X"), player_2 = Players::Human.new("O"), board = Board.new) @board = board @player_1 = player_1 @player_2 = player_2 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def init_player_board\n board = Board.create_player_board(self.id)\n board.place_ships\n end", "def setup_board\n @startup = true\n @board = @board.map{|col| col.map{|piece| Piece.new if piece.nil?}}\n clear_matches\n @startup = false\n @pieces_removed = 0\n end", "def initialize_game\n ...
[ "0.8218808", "0.79941744", "0.7887816", "0.77463317", "0.77332187", "0.7721634", "0.76599", "0.7648713", "0.76458925", "0.7638827", "0.7630411", "0.7602778", "0.75775117", "0.7574959", "0.75636613", "0.7533807", "0.7532357", "0.75277215", "0.752205", "0.75100255", "0.7505977"...
0.7208114
58
If the turn count is an even number, the current_player method should return "X", otherwise, it should return "O"
def current_player @board.turn_count.even? ? @player_1 : @player_2 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def current_player(board)\n if turn_count(board) % 2 == 0\n return \"X\" #even turn count == X\n end \n return \"O\" #odd turn count == O \nend", "def current_player\n turn_count \n if turn_count%2 != 0 \n \"O\"\n else\n \"X\"\n end\nend", "def current_player\n turn_count.even? ? \"X\" : \"O...
[ "0.9081944", "0.90653443", "0.90579337", "0.9038657", "0.90308374", "0.9022416", "0.9012328", "0.90083635", "0.90083635", "0.90083635", "0.89999574", "0.89999574", "0.8947306", "0.8919674", "0.8906048", "0.89006805", "0.88945234", "0.8888458", "0.8883748", "0.887845", "0.8875...
0.0
-1
helper method for delete:
def maximum(tree_node = @root) return tree_node unless tree_node.right return maximum(tree_node.right) if tree_node.right end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete\n \n end", "def delete\n \n end", "def delete\n end", "def delete\n\n end", "def delete\n end", "def delete\n end", "def delete\n end", "def delete\n end", "def delete\n end", "def delete\n end", "def delete\n end", "def delete\n\n\tend", "def delete\n ...
[ "0.8373501", "0.80260485", "0.8013269", "0.80042505", "0.7956913", "0.7956913", "0.7956913", "0.7956913", "0.7956913", "0.7956913", "0.7956913", "0.79107374", "0.7799738", "0.77781236", "0.7493549", "0.7422571", "0.74152577", "0.7396308", "0.73679674", "0.7326224", "0.7326224...
0.0
-1
optional helper methods go here:
def parent_for_new(tree_node, value) return tree_node if !tree_node.left && value < tree_node.value return tree_node if !tree_node.right && value > tree_node.value if value > tree_node.value return parent_for_new(tree_node.right, value) else return parent_for_new(tree_node.left, value) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def optional; end", "def private; end", "def extra; end", "def maybe; end", "def missing?; end", "def optional_positionals; end", "def specie; end", "def specie; end", "def specie; end", "def specie; end", "def required_defaults; end", "def missing; end", "def fallbacks=(_arg0); end", "de...
[ "0.69149244", "0.6380973", "0.6307633", "0.63048226", "0.6273559", "0.61832875", "0.612033", "0.612033", "0.612033", "0.612033", "0.6086", "0.6078848", "0.606526", "0.59968525", "0.59968525", "0.5963383", "0.5963383", "0.59312886", "0.59266454", "0.5921919", "0.59062934", "...
0.0
-1
Returns array of permitted events
def permitted_events events = self.states_events_config.map { |se| se[:event] } events.delete_if { |e| !event_permitted(e) } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def available_events\n events = permitted_events\n if respond_to?(:sort_available_events)\n events = sort_available_events(events)\n end\n events\n end", "def available_events\n\t\treturn current_room.events || []\n\tend", "def events\n @events ||= []\n @events\n ...
[ "0.7695083", "0.7205331", "0.713691", "0.7032222", "0.7032222", "0.7027499", "0.69326246", "0.6925656", "0.69169474", "0.68804353", "0.6784602", "0.6732573", "0.6714068", "0.6706673", "0.66893464", "0.66811424", "0.66796315", "0.66291", "0.6626087", "0.6592322", "0.6564667", ...
0.77159274
0
Returns array of available events
def available_events events = permitted_events if respond_to?(:sort_available_events) events = sort_available_events(events) end events end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def available_events\n\t\treturn current_room.events || []\n\tend", "def events\n @events ||= []\n @events\n end", "def events\n event_lookup()\n end", "def events\n event_lookup()\n end", "def event_list\n @_events\n end", "def all_events\n events.keys...
[ "0.84179866", "0.824708", "0.81303895", "0.81303895", "0.78472155", "0.78192896", "0.7803287", "0.77538127", "0.77538127", "0.77185905", "0.7669201", "0.7572841", "0.7524954", "0.7500847", "0.74978113", "0.74771607", "0.7462864", "0.7447164", "0.74182427", "0.7403136", "0.733...
0.7948607
4
Returns state to which given event will transition the record
def event_to_state(event) to_states = {} self.states_events_config.each { |se| to_states[se[:event]] = se[:to_state] } to_states[event] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def next_state_for_event(event)\r\n ns = next_states_for_event(event)\r\n ns.empty? ? nil : ns.first.to\r\n end", "def next_state(event_name)\n transition = transitions.select{|t| t.is_transition_for?(event_name, @subject.send(state_method))}.first\n transition ? transition.to ...
[ "0.73098654", "0.6971465", "0.6894719", "0.67888975", "0.6755599", "0.654114", "0.6414251", "0.62226254", "0.6221687", "0.6196697", "0.6151442", "0.6147932", "0.61257935", "0.6124109", "0.6118928", "0.6116004", "0.6113557", "0.6105177", "0.60935897", "0.60762113", "0.60510015...
0.687138
3
Triggers an event, moving record to associated state, if permitted Returns false if event not permitted
def trigger(event, metadata={}) if (event_permitted(event) || User.is_admin?(metadata[:user_id])) && required_metadata_present?(event, metadata) to_state = self.event_to_state(event) callback_metadata = metadata.clone transition_to(to_state, metadata) if respond_to?(:even...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def save_event?(event)\n event.save\n end", "def fire_event(event, record, persist, *args)\n state_index[record.current_state].call_action(:exit, record)\n begin\n if new_state = @events[event].fire(record, nil, *args)\n state_index[new_state].call_action(:enter, record)\n\n...
[ "0.5938552", "0.59344345", "0.5882169", "0.5805564", "0.5801656", "0.5801656", "0.578346", "0.56976825", "0.56562376", "0.56395674", "0.56344295", "0.5570959", "0.550621", "0.54783267", "0.5476204", "0.5457513", "0.54280984", "0.54174125", "0.53826636", "0.5373344", "0.534877...
0.6447481
0