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
Adds underscores to all ids and classes
def prefix_css_selectors(prefix = "_") selector_regex = /^\s*?(?!\/\*)+?[^:]*?(?!:\s)([\.#][^,\s]*[:]?[^\s,])$/ new_sass = "" sass.each_line do |line| # Skip blank lines next if line =~ /^\s*$/ line = line.gsub(selector_regex) do |str| # Add the underscores str.gsub!(/([#.])/, "\\1#{prefix}") end new_sass << line end sass = new_sass end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def underscore(class_name)\n class_name.gsub(/::/, '/').\n gsub(/([A-Z]+)([A-Z][a-z])/,'\\1_\\2').\n gsub(/([a-z\\d])([A-Z])/,'\\1_\\2').\n tr(\"-\", \"_\").\n downcase\n end", "def id\n super.to_s.tr('.', '_')\n end", "def underscore\n class_nam...
[ "0.6998579", "0.67214453", "0.665972", "0.6657908", "0.6646169", "0.6638016", "0.6460274", "0.6432089", "0.64223313", "0.64223313", "0.6405076", "0.6368335", "0.63256145", "0.62615126", "0.6243535", "0.6208079", "0.6168025", "0.615419", "0.61436385", "0.613395", "0.6108174", ...
0.0
-1
rewrite internal paths to normalized paths
def normalize_paths new_sass = "" sass.each_line do |line| line = SassLine.new(@epub, self, line) line.normalize_paths if line.has_path? new_sass += "#{line.to_s}\n" end self.sass = new_sass end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def normalize_path(path); end", "def normalize_path(path); end", "def normalize(path)\n path.gsub(/\\\\/, \"/\")\n end", "def normalize_paths(paths)\n # do the hokey-pokey of path normalization...\n paths = paths.collect do |path|\n path = path.\n gsub(\"//\", \"...
[ "0.81686854", "0.81686854", "0.73655075", "0.7336732", "0.73290545", "0.73013103", "0.7231049", "0.72004396", "0.70407486", "0.70407486", "0.6906958", "0.68598604", "0.6854583", "0.6842715", "0.67916447", "0.66807663", "0.66719455", "0.66707265", "0.6633365", "0.6625123", "0....
0.6495284
24
Convert all fonts to ems
def convert_fonts out = "" sass.each_line do |line| line.gsub!(/(\s*)(word-spacing|letter-spacing|font-size|line-height|margin-[^\s]+|margin|padding-[\s]+|padding)\s*:(.*)/) do |m| # indent rule: value m = "#{$1}#{$2}: #{CSS.val_to_em($3)}" end out << line end self.sass = out end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def convert_fonts(sass)\n out = \"\"\n sass.each_line do |line|\n line.gsub!(/(\\s*)(word-spacing|letter-spacing|font-size|line-height|margin-[^\\s]+|margin|padding-[\\s]+|padding)\\s*:(.*)/) do |m|\n # :spacing :rule :value\n m = \"%s%s: %s\" % [$1, ...
[ "0.6490057", "0.61487615", "0.6108373", "0.5908551", "0.5895589", "0.5843664", "0.5416169", "0.53674954", "0.5332667", "0.5294704", "0.52872396", "0.52648693", "0.5236899", "0.5188425", "0.51730424", "0.5149428", "0.51386946", "0.5102211", "0.50768965", "0.50674284", "0.50339...
0.7056603
0
Indent all lines with two spaces
def indent_sass puts "indenting sass" self.sass.gsub!(/^/, " ") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def indent; end", "def indent; end", "def indent; end", "def indent; end", "def indent; end", "def indent_for(line); end", "def with_indent ()\n thread[:indent] += 1\n yield\n ensure\n thread[:indent] -= 1\n end", "def indent_each_line!(indent_sequence=\"\\t\")\n\t\treturn self.c...
[ "0.8057547", "0.8057547", "0.8057547", "0.8057547", "0.8057547", "0.79419297", "0.78856844", "0.78558975", "0.7758355", "0.772004", "0.77150697", "0.77150697", "0.75030845", "0.7484368", "0.74525356", "0.73740333", "0.73607564", "0.7356838", "0.7325362", "0.73075616", "0.7219...
0.0
-1
Replace body css rule and add it to the above rule using the sass '&'
def rename_body puts "renaming sass body element" self.sass.gsub!(/^(\s*)body\n/, "\n#{$1}&\n") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def write_unmergable_css_rules(doc, unmergable_rules) # :nodoc:\n styles = unmergable_rules.to_s\n\n unless styles.empty?\n style_tag = \"<style type=\\\"text/css\\\">\\n#{styles}</style>\"\n if body = doc.search('body')\n if doc.at_css('body').children && !doc.at_css('bo...
[ "0.57379687", "0.569437", "0.5649964", "0.5635443", "0.56238586", "0.5512798", "0.5507444", "0.5490131", "0.54834735", "0.54481226", "0.54481226", "0.54370546", "0.531204", "0.5301126", "0.52723217", "0.5248213", "0.52280563", "0.5198434", "0.5193462", "0.51603824", "0.511317...
0.6865634
0
CSS directives must be top levl We namespace the css so these will bork So loop through identifying directives and remove them an anything indented inside
def move_css_directives puts "moving css directives to top of file" css_directives = "" new_sass = "" directive_indent = 0 # Go through the lines rewriting paths as appropriate sass.each_line do |line| sass_line = SassLine.new(@epub, self, line.to_s, directive_indent) if sass_line.inside_css_directive? # NOTE: Want to indent by the line indent relative to the directive css_directives += (" " * (sass_line.indent - directive_indent) + sass_line.to_s.strip + "\n") next elsif sass_line.is_css_directive? # NOTE: Strip whitespace as want directives at the root of the line css_directives += "#{sass_line.to_s.strip}\n" # NOTE: The indent is the whitespace from the start of the line to the directive directive_indent = sass_line.indent else directive_indent = 0 new_sass += "#{sass_line.to_s}\n" end if sass_line.missing_item? create_manifest_entry(sass_line.old_src) end end self.sass = "#{css_directives}\n\n#{new_sass}" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def css_omit\n %w()\nend", "def directives; end", "def directives; end", "def clean_css\n return if self.css.blank?\n prefix = \"#workskin\"\n scanner = StringScanner.new(self.css)\n if !scanner.exist?(/\\/\\*/)\n # no comments, clean the whole thing\n self.css = clean_css_code(self.cs...
[ "0.6319556", "0.6056606", "0.6056606", "0.59757024", "0.5853228", "0.5581586", "0.55681336", "0.55295616", "0.53764224", "0.53764224", "0.53764224", "0.5369006", "0.53676164", "0.53469825", "0.52993876", "0.5289558", "0.5286437", "0.52749735", "0.5210161", "0.5190277", "0.516...
0.6912303
0
Add a wrapper to the sytlesheet so multiple stylesheets with same identifiers don't conflict
def namespace_by_filename rename_body indent_sass namespace_sass # remove the @char style css directives (can't be indented) move_css_directives puts sass end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def stylesheet; end", "def add_stylesheet(doc, location)\n xml_stylesheet = Nokogiri::XML::ProcessingInstruction.new(doc, \"xml-stylesheet\", %Q{type=\"text/xsl\" href=\"#{location}\"})\n doc.root.add_previous_sibling xml_stylesheet\n doc\n end", "def style_sheet(url=\"\")\n self.tag('css', self....
[ "0.5955989", "0.584337", "0.57436407", "0.5674028", "0.5650319", "0.5650319", "0.5650319", "0.5633989", "0.5601928", "0.5593755", "0.5503194", "0.5490732", "0.5478746", "0.54247344", "0.5405826", "0.539675", "0.5390448", "0.538945", "0.53697157", "0.5367086", "0.5365855", "...
0.0
-1
Creates a new logger
def initialize(pipe, *args) super(pipe, *args) self.io = pipe self.show_backtraces = true self.show_progress = false self.level = WARN self.formatter = method(:format_log) self.warned = false @progress_indicator = 0 @mutex = Mutex.new @progress_msg = nil @progress_last_update = Time.now end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_logger\n raise \"You should create your own `create_logger` method\"\n end", "def create_logger\n raise \"You should create your own `create_logger` method\"\n end", "def create(name = nil)\n logger_name = name || caller(1..1).first[/`(.+)'/, 1]\n Logger.new(logger_name)\n ...
[ "0.7998339", "0.7998339", "0.7969774", "0.78619343", "0.7503952", "0.74591607", "0.7391643", "0.730702", "0.7250956", "0.72279227", "0.70957506", "0.7012958", "0.7012958", "0.69630843", "0.69525987", "0.68740416", "0.68737173", "0.6858736", "0.68555224", "0.6845333", "0.68349...
0.0
-1
Changes the debug level to DEBUG if $DEBUG is set and writes a debugging message.
def debug(*args) self.level = DEBUG if $DEBUG super end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def debug message; write DEBUG, message, caller[0] unless level > @level end", "def debug(msg=nil)\n log \"DEBUG: #{msg}\" if $debug\n end", "def debug(message)\n $stdout.puts \"D #{message}\" if @debug\n end", "def debug(message)\n puts message if debug?\n end", "def d...
[ "0.76727146", "0.7578764", "0.7550893", "0.7550796", "0.754063", "0.75295454", "0.7517472", "0.7489531", "0.7460408", "0.7451659", "0.7451659", "0.7442279", "0.74192107", "0.7381547", "0.7360501", "0.73530364", "0.723405", "0.71916807", "0.7181005", "0.7138657", "0.7132161", ...
0.7191312
18
Remembers when a warning occurs and writes a warning message.
def warn(*args) self.warned = true super end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def warning(message)\n write_message message, 'warning'\n end", "def warning(msg)\n @warnings << msg\n owarn @warnings.last\n end", "def warn(message)\n output[:warnings] << message\n end", "def warn(msg)\n $warnings << msg if $warnings\nend", "def warning\n sta...
[ "0.77955663", "0.7786037", "0.7666773", "0.7564739", "0.7452888", "0.74487823", "0.73752314", "0.7362536", "0.73564875", "0.7344176", "0.7338517", "0.7338517", "0.7338517", "0.72915035", "0.7178832", "0.7129849", "0.7101731", "0.7099894", "0.7068309", "0.70676357", "0.7067214...
0.66540354
68
Displays a progress indicator for a given message. This progress report is only displayed on TTY displays, otherwise the message is passed to the +nontty_log+ level.
def progress(msg, nontty_log = :debug) send(nontty_log, msg) if nontty_log return unless show_progress icon = "" if defined?(::Encoding) icon = PROGRESS_INDICATORS[@progress_indicator] + " " end @mutex.synchronize do print("\e[2K\e[?25l\e[1m#{icon}#{msg}\e[0m\r") @progress_msg = msg if Time.now - @progress_last_update > 0.2 @progress_indicator += 1 @progress_indicator %= PROGRESS_INDICATORS.size @progress_last_update = Time.now end end Thread.new do sleep(0.05) progress(msg + ".", nil) if @progress_msg == msg end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def progress(msg, nontty_log = T.unsafe(nil)); end", "def report_progress(message)\n @progress_block.call(message) if @progress_block\n end", "def ReportProgress(progress_s)\n progress_s = Builtins.sformat(\"=== %1 ===\", progress_s)\n\n Builtins.y2milestone(\"%1\", progress_s)\n UI.ChangeWi...
[ "0.77027094", "0.6517017", "0.6432016", "0.63986486", "0.63013893", "0.62673146", "0.5994179", "0.5977254", "0.59584814", "0.58779776", "0.58413565", "0.5832809", "0.573447", "0.57272077", "0.57156104", "0.57072085", "0.56922144", "0.5677506", "0.5674355", "0.5667573", "0.565...
0.8307875
0
Clears the progress indicator in the TTY display.
def clear_progress return unless show_progress print_no_newline("\e[?25h\e[2K") @progress_msg = nil end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def clear_progress; end", "def clear_output(wait=false)\n Display.clear_output(wait)\n end", "def clear\n $stdout.print \"\\n\"\n $stdout.flush\n end", "def clear\n Vedeu::Terminal.clear\n end", "def clear_screen\n puts \"\\e[H\\e[2J\"\n end", "def clear\n # If n is 2, c...
[ "0.76503116", "0.7068279", "0.70485336", "0.69376385", "0.6849531", "0.6820603", "0.68204975", "0.6789234", "0.6782584", "0.67592484", "0.67498493", "0.6729563", "0.6717679", "0.6708802", "0.6690987", "0.6677897", "0.6676975", "0.66718906", "0.667078", "0.6648937", "0.6631548...
0.85260814
0
Displays an unformatted line to the logger output stream, adding a newline.
def puts(msg = '') print("#{msg}\n") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def newline\n log\n end", "def newline\n log('')\n end", "def newline\n log('')\n end", "def ReportLine(line)\n Builtins.y2milestone(\"%1\", line)\n UI.ChangeWidget(Id(:log_view), :LastLine, Ops.add(line, \"\\n\"))\n\n nil\n end", "def log_line(line)\n if co...
[ "0.7241168", "0.7230651", "0.7230651", "0.7191988", "0.7018187", "0.68045485", "0.67703605", "0.6522741", "0.6515393", "0.64406544", "0.6417612", "0.638652", "0.63512725", "0.6301302", "0.6262147", "0.62473214", "0.62353235", "0.6183429", "0.61749005", "0.6151485", "0.6148638...
0.0
-1
Displays an unformatted line to the logger output stream.
def print(msg = '') clear_line print_no_newline(msg) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def log_line(line)\n if config.colorize_logging\n @@row_even, message_color = if @@row_even\n [false, '4;32;1']\n else\n [true, '4;33;1']\n end\n\n config.logger.info(\" [\\e[#{message_color}m%s\\e[0m] %s\" % [@name, line])\n else\n ...
[ "0.7140746", "0.6922101", "0.6441453", "0.6429609", "0.64163303", "0.6390289", "0.6370111", "0.6343696", "0.62569064", "0.6244328", "0.6244328", "0.6238196", "0.6227454", "0.61564016", "0.6131584", "0.61305743", "0.60429645", "0.6029203", "0.60040027", "0.59866387", "0.598101...
0.0
-1
Prints the backtrace +exc+ to the logger as error data.
def backtrace(exc, level_meth = :error) return unless show_backtraces send(level_meth, "#{exc.class.class_name}: #{exc.message}") send(level_meth, "Stack trace:" + exc.backtrace[0..5].map {|x| "\n\t#{x}" }.join + "\n") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def error(msg, exc=nil)\n return synchronize{@out.print(\"#{@error}#{msg}\\n\")} unless exc\n synchronize{@out.print(\"#{@error}#{msg}: #{exc}\\n#{exc.backtrace.join(\"\\n\")}\\n\")}\n end", "def exception(ex, msg='')\n line = ''\n ex.backtrace.each do |l|\n line += \"\\n #{l}\"\n end...
[ "0.6682094", "0.6382295", "0.63343036", "0.61962634", "0.6130218", "0.6102125", "0.6064013", "0.602026", "0.5987188", "0.5961902", "0.59611785", "0.59099096", "0.5905247", "0.58743876", "0.5774503", "0.5765145", "0.57406294", "0.57210904", "0.57158697", "0.5700352", "0.567704...
0.6421739
1
Warns that the Ruby environment does not support continuations. Applies to JRuby, Rubinius and MacRuby. This warning will only display once per Ruby process.
def warn_no_continuations end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def warn_no_continuations; end", "def rubinius_skip(message = '')\n skip message if RUBY_ENGINE == 'rbx'\nend", "def rubinius_skip(message = '')\n skip message if RUBY_ENGINE == 'rbx'\nend", "def rubinius_skip(message = '')\n skip message if RUBY_ENGINE == 'rbx'\nend", "def warn(progname = T.unsafe(nil)...
[ "0.7130728", "0.5488456", "0.5488456", "0.5488456", "0.5397916", "0.53552765", "0.5345994", "0.5299118", "0.5293796", "0.5293796", "0.5293796", "0.5215354", "0.5186471", "0.5135099", "0.5126447", "0.50751024", "0.506705", "0.5034577", "0.49753577", "0.49483946", "0.49292287",...
0.70627606
1
Sets the logger level for the duration of the block
def enter_level(new_level = level) old_level = level self.level = new_level yield ensure self.level = old_level end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def level=(level)\n logger.level = level\n end", "def log_level=(level); end", "def log_level=(level)\n logger.level = level\n end", "def level=(level)\n @level = level\n @log.level = @level\n end", "def log_level=(level)\n @logger.level = level\n end", ...
[ "0.73622376", "0.72888374", "0.7279045", "0.7187214", "0.71639913", "0.71154404", "0.71154106", "0.71154106", "0.7100337", "0.69813406", "0.68378246", "0.67927706", "0.67653644", "0.6710115", "0.66007537", "0.6577039", "0.653901", "0.65349805", "0.6527687", "0.6469205", "0.64...
0.0
-1
Override this internal Logger method to clear line
def add(*args) clear_line super(*args) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def clear_line\n CLEAR_LINE\n end", "def clear_line; print \"\\e[2K\" end", "def clear\n @lines.clear\n end", "def clear_line\n puts \"\\e[0A\\e[0G\"\n end", "def clear_line!\n print \"\\r\\e[2K\"\n end", "def clear_line\n CSI + '2K' + column(1)\n end", "def clea...
[ "0.76990247", "0.71693414", "0.701906", "0.69899535", "0.68916905", "0.68834376", "0.6804096", "0.67651963", "0.6668352", "0.66344136", "0.661538", "0.64576143", "0.6420297", "0.63490784", "0.6344306", "0.6299547", "0.628575", "0.6260652", "0.62599903", "0.6233663", "0.618113...
0.0
-1
Log format (from Logger implementation). Used by Logger internally
def format_log(sev, _time, _prog, msg) "[#{sev.downcase}]: #{msg}\n" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def log_formatter; end", "def log_formatter; end", "def log_format\n if configuration.log_format.nil? || configuration.log_format.empty?\n format = '%{KIND}: %{message} on line %{line}'\n format.prepend('%{path} - ') if configuration.with_filename\n format.concat(' (check: %{check})')\n ...
[ "0.7837322", "0.7837322", "0.76155096", "0.7320731", "0.728268", "0.728268", "0.70351446", "0.6886894", "0.68730956", "0.685765", "0.680251", "0.66508776", "0.66429925", "0.65977913", "0.65487", "0.65487", "0.65487", "0.65487", "0.65487", "0.65487", "0.65487", "0.65487", ...
0.6956505
7
Subject can be set in your I18n file at config/locales/en.yml with the following lookup: en.voicemail.new_voicemail.subject
def new_voicemail_email(call) @user = call.user @call = call @recording = call.recording mail to: @user.email, subject: "Voicemail message from #{@call.caller_number}" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def message_subject=(value)\n @message_subject = value\n end", "def subject=(string)\n set('Subject', string)\n end", "def set_EmailSubject(value)\n set_input(\"EmailSubject\", value)\n end", "def set_EmailSubject(value)\n set_input(\"EmailSubject\",...
[ "0.71846175", "0.71302485", "0.7091707", "0.70904136", "0.7049268", "0.7047499", "0.7041125", "0.69457525", "0.69068485", "0.68505824", "0.6829657", "0.6810427", "0.67638105", "0.6753094", "0.6753094", "0.6753094", "0.6753094", "0.6749162", "0.6747826", "0.67249143", "0.67249...
0.0
-1
Initializes and returns an Iterator
def iter @iter ||= Iterator.new(self) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_iterator\n\t\tend", "def begin_iterator\n ListIterator.new @head, self\n end", "def to_iter\n Iterator.new @entries, @capacity\n end", "def iterator()\n raise NotImplementedError\n end", "def getIterator() \n XMLDB::Base::ResourceIterator.getInstance(@obj.getIterator())\n ...
[ "0.7022715", "0.7019512", "0.6894122", "0.6449395", "0.63852686", "0.62473184", "0.6089897", "0.58430946", "0.5811757", "0.57916164", "0.5742037", "0.57390785", "0.57236403", "0.56869006", "0.56869006", "0.56869006", "0.56869006", "0.5675764", "0.5662358", "0.56622213", "0.56...
0.7505006
0
End getter Method to create elevators
def makeElevator for elevatorID in 1..@amountOfElevators elevator = Elevator.new(elevatorID, 'idle', @amountOfFloors, 1) @elevatorsList.push(elevator) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def createElevatorsList\n for x in 1..@numberOfElevators do\n @elevatorsList.append(Elevator.new(x, @numberOfFloors, 1, ElevatorStatus::IDLE, SensorStatus::OFF, SensorStatus::OFF))\n # puts \"elevator#{@id} created\"\n end\n end", "def initialize(elevators, request)\n ...
[ "0.5552878", "0.5515432", "0.5512229", "0.5428644", "0.5341815", "0.5265337", "0.5244366", "0.5115202", "0.50719696", "0.5021893", "0.49993384", "0.49921983", "0.4962259", "0.4944366", "0.49434", "0.49343783", "0.493177", "0.49247643", "0.49219114", "0.49016005", "0.4888956",...
0.53873336
4
Method to create call buttons
def makeCallButtons callButtonId = 1 callButtonFloor = 1 for callButtonCounter in 1..@amountOfFloors #If not first floor if callButtonCounter > 1 callButton = CallButton.new(callButtonId, 'off', callButtonFloor, 'down') @callButtonsList.push(callButton) callButtonId += 1 end #If not last floor if callButtonCounter < @amountOfFloors callButton = CallButton.new(callButtonId, 'off', callButtonFloor, 'up') @callButtonsList.push(callButton) callButtonId += 1 end callButtonFloor += 1 end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_call_buttons\n \n for floor in 1..Elevator.num_floors do\n \n up_btn = CallButton.new(floor, \"up\", self)\n @up_call_buttons.append(up_btn)\n\n down_btn = CallButton.new(floor, \"down\", self)\n @down_call_buttons.append(down_btn)\n ...
[ "0.77627116", "0.70357776", "0.687819", "0.642321", "0.6366342", "0.63557315", "0.63054556", "0.61518234", "0.6036808", "0.5992619", "0.59743303", "0.59697795", "0.59416395", "0.59394103", "0.59263223", "0.5892963", "0.58894134", "0.588759", "0.58850175", "0.5856869", "0.5856...
0.6872888
3
User calls an elevator
def requestElevator(floor, direction) puts "A request for an elevator is made from floor #{floor}, going #{direction}." elevator = findBestElevator(floor, direction) puts "Elevator #{elevator.elevatorId} is the best elevator, so it is sent." elevator.elevatorFloorRequestList.push(floor) elevator.sortFloorList() puts "Elevator is moving." elevator.moveElevator() puts "Elevator is #{elevator.elevatorStatus}." elevator.doorController() return elevator end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def call_elevator elevator_number=0\n\t\t@elevators[elevator_number].add_to_floors_to_visit @floor_number\n\tend", "def requestElevator(requestedFloor, direction)\n if direction == ButtonDirection::UP\n @buttonsUpList[requestedFloor-1].status = ButtonStatus::ON\n else\n @butto...
[ "0.7893657", "0.6704976", "0.66869915", "0.6633177", "0.6372739", "0.62872225", "0.60688555", "0.6042272", "0.6025063", "0.60061514", "0.59596217", "0.5956157", "0.58742386", "0.58642185", "0.5857096", "0.58437794", "0.5784931", "0.5744474", "0.5700002", "0.56890196", "0.5662...
0.66954315
2
Comparing elevator to previous best
def checkBestElevator(scoreToCheck, newElevator, bestElevatorInfo, floor) #If elevators situation is more favourable if scoreToCheck < bestElevatorInfo[1] bestElevatorInfo[1] = scoreToCheck bestElevatorInfo[0] = newElevator bestElevatorInfo[2] = (newElevator.elevatorCurrentFloor - floor).abs #If elevators are in a similar situation, set the closest one to the best elevator elsif bestElevatorInfo[1] == scoreToCheck gap = (newElevator.elevatorCurrentFloor - floor).abs if bestElevatorInfo[2] > gap bestElevatorInfo[1] = scoreToCheck bestElevatorInfo[0] = newElevator bestElevatorInfo[2] = gap end end return bestElevatorInfo end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def choose_elevator\n elevator_scores = []\n\n for elevator in @column.elevator_list do\n \n # Initialize score to 0\n score = 0\n floor_difference = elevator.current_floor - @floor\n\n # Prevents use of any offline/under-maintenance elevators\n ...
[ "0.7092161", "0.6612731", "0.65469885", "0.6142631", "0.5933778", "0.5923163", "0.59172934", "0.5877978", "0.58687085", "0.5857423", "0.58505124", "0.58122474", "0.57705396", "0.5767235", "0.57530624", "0.5752622", "0.5724877", "0.5722437", "0.57156116", "0.57017064", "0.5698...
0.73192716
0
End getters Method to create floor request buttons
def makeFloorRequestButton floorRequestButtonFloor = 1 for i in 1..@amountOfFloors floorRequestButton = FloorRequestButton.new(i, 'off', floorRequestButtonFloor) @floorRequestButtonsList.push(floorRequestButton) floorRequestButtonFloor += 1 end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_floor_buttons\n for floor in 1..Elevator.num_floors do\n button = FloorButton.new(floor, self)\n @floor_buttons.append(button)\n end\n end", "def create_call_buttons\n \n for floor in 1..Elevator.num_floors do\n \n up_btn = Cal...
[ "0.725043", "0.6995777", "0.6883464", "0.6748535", "0.65568984", "0.6451425", "0.6248393", "0.6185009", "0.61505955", "0.59828275", "0.59518325", "0.5936965", "0.59348613", "0.58649135", "0.58584106", "0.5817088", "0.5807335", "0.5726247", "0.57021666", "0.56969005", "0.56808...
0.77983236
0
User requesting floor inside elevator
def requestFloor(floor) puts "The elevator is requested to move to floor #{floor}." @floorRequestList.push(floor) sortFloorList() puts "Elevator is moving." moveElevator() puts "Elevator is #{@status}." doorController() if @floorRequestList.length() == 0 @direction = nil @status = 'idle' end puts "Elevator is #{@status}." end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def request_floor(elevator, requested_floor)\n floor_btn_to_press = elevator.floor_buttons.find { |btn| btn.floor == requested_floor } \n \n floor_btn_to_press.press()\n elevator.do_requests()\n end", "def requestElevator(floor, direction)\n puts \"A request for an eleva...
[ "0.793773", "0.7650569", "0.7575021", "0.74889666", "0.74183387", "0.7154896", "0.7093107", "0.7078495", "0.70356715", "0.6796759", "0.6785355", "0.6701571", "0.6570387", "0.65656316", "0.6461453", "0.6383427", "0.6357844", "0.634533", "0.62568986", "0.62568986", "0.6230515",...
0.8025594
0
Sorting floor request list
def sortFloorList if @direction == 'up' @floorRequestList.sort! elsif @direction == 'down' @floorRequestList.sort!.reverse end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sort_params; end", "def sort_params; end", "def sort_entries; end", "def sort_requests_queue\n request = @requests_queue[0]\n get_movement()\n\n if @requests_queue.length() > 1\n\n if @movement == \"up\"\n # Sort the queue in ascending order\n ...
[ "0.68617064", "0.68617064", "0.6753194", "0.6752096", "0.6388564", "0.6361775", "0.6293843", "0.6293843", "0.6278227", "0.62235636", "0.6135104", "0.6038651", "0.59794766", "0.597288", "0.5957384", "0.5868069", "0.58595574", "0.58451015", "0.58067507", "0.579388", "0.57817155...
0.79077053
0
num1 First number. num2 Second number. num3 Third number. Examples min_of_three(7,12,2) => 2 Returns smallest of three numbers.
def min_of_three(num1, num2, num3) if num1 < num2 if num1 < num3 return num1 end else if num2 < num3 return num2 end end return num3 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def min_of_three(min,num2,num3)\n if min > num2\n min = num2\n end\n if min > num3\n min = num3\n end\n return min\nend", "def min_of_three(num1, num2, num3)\n if num1 < num2 and num1 < num3\n return num1\n end\n if num2 < num1 and num2 < num3\n return num2\n ...
[ "0.8710521", "0.8630299", "0.8625952", "0.8618415", "0.8486882", "0.84854436", "0.84593624", "0.8367043", "0.8249906", "0.8190739", "0.81882954", "0.7978395", "0.78643876", "0.77731806", "0.7709521", "0.7591844", "0.7572726", "0.7541311", "0.7486121", "0.7462298", "0.74243444...
0.85761714
4
Show invalid properties with the reasons. Usually used together with valid?
def list_invalid_properties invalid_properties = Array.new if @id.nil? invalid_properties.push('invalid value for "id", id cannot be nil.') end if @title.nil? invalid_properties.push('invalid value for "title", title cannot be nil.') end if @title.to_s.length < 1 invalid_properties.push('invalid value for "title", the character length must be great than or equal to 1.') end if @image.nil? invalid_properties.push('invalid value for "image", image cannot be nil.') end if @image.to_s.length < 1 invalid_properties.push('invalid value for "image", the character length must be great than or equal to 1.') end if @image_type.nil? invalid_properties.push('invalid value for "image_type", image_type cannot be nil.') end if @image_type.to_s.length < 1 invalid_properties.push('invalid value for "image_type", the character length must be great than or equal to 1.') end if @servings.nil? invalid_properties.push('invalid value for "servings", servings cannot be nil.') end if @ready_in_minutes.nil? invalid_properties.push('invalid value for "ready_in_minutes", ready_in_minutes cannot be nil.') end if @license.nil? invalid_properties.push('invalid value for "license", license cannot be nil.') end if @license.to_s.length < 1 invalid_properties.push('invalid value for "license", the character length must be great than or equal to 1.') end if @source_name.nil? invalid_properties.push('invalid value for "source_name", source_name cannot be nil.') end if @source_name.to_s.length < 1 invalid_properties.push('invalid value for "source_name", the character length must be great than or equal to 1.') end if @source_url.nil? invalid_properties.push('invalid value for "source_url", source_url cannot be nil.') end if @source_url.to_s.length < 1 invalid_properties.push('invalid value for "source_url", the character length must be great than or equal to 1.') end if @spoonacular_source_url.nil? invalid_properties.push('invalid value for "spoonacular_source_url", spoonacular_source_url cannot be nil.') end if @spoonacular_source_url.to_s.length < 1 invalid_properties.push('invalid value for "spoonacular_source_url", the character length must be great than or equal to 1.') end if @aggregate_likes.nil? invalid_properties.push('invalid value for "aggregate_likes", aggregate_likes cannot be nil.') end if @health_score.nil? invalid_properties.push('invalid value for "health_score", health_score cannot be nil.') end if @spoonacular_score.nil? invalid_properties.push('invalid value for "spoonacular_score", spoonacular_score cannot be nil.') end if @price_per_serving.nil? invalid_properties.push('invalid value for "price_per_serving", price_per_serving cannot be nil.') end if @cheap.nil? invalid_properties.push('invalid value for "cheap", cheap cannot be nil.') end if @credits_text.nil? invalid_properties.push('invalid value for "credits_text", credits_text cannot be nil.') end if @credits_text.to_s.length < 1 invalid_properties.push('invalid value for "credits_text", the character length must be great than or equal to 1.') end if @dairy_free.nil? invalid_properties.push('invalid value for "dairy_free", dairy_free cannot be nil.') end if @gaps.nil? invalid_properties.push('invalid value for "gaps", gaps cannot be nil.') end if @gaps.to_s.length < 1 invalid_properties.push('invalid value for "gaps", the character length must be great than or equal to 1.') end if @gluten_free.nil? invalid_properties.push('invalid value for "gluten_free", gluten_free cannot be nil.') end if @instructions.nil? invalid_properties.push('invalid value for "instructions", instructions cannot be nil.') end if @ketogenic.nil? invalid_properties.push('invalid value for "ketogenic", ketogenic cannot be nil.') end if @low_fodmap.nil? invalid_properties.push('invalid value for "low_fodmap", low_fodmap cannot be nil.') end if @sustainable.nil? invalid_properties.push('invalid value for "sustainable", sustainable cannot be nil.') end if @vegan.nil? invalid_properties.push('invalid value for "vegan", vegan cannot be nil.') end if @vegetarian.nil? invalid_properties.push('invalid value for "vegetarian", vegetarian cannot be nil.') end if @very_healthy.nil? invalid_properties.push('invalid value for "very_healthy", very_healthy cannot be nil.') end if @very_popular.nil? invalid_properties.push('invalid value for "very_popular", very_popular cannot be nil.') end if @whole30.nil? invalid_properties.push('invalid value for "whole30", whole30 cannot be nil.') end if @weight_watcher_smart_points.nil? invalid_properties.push('invalid value for "weight_watcher_smart_points", weight_watcher_smart_points cannot be nil.') end if !@extended_ingredients.nil? && @extended_ingredients.length < 0 invalid_properties.push('invalid value for "extended_ingredients", number of items must be greater than or equal to 0.') end if @summary.nil? invalid_properties.push('invalid value for "summary", summary cannot be nil.') end if @summary.to_s.length < 1 invalid_properties.push('invalid value for "summary", the character length must be great than or equal to 1.') end invalid_properties end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def list_invalid_properties\n invalid_properties = super\n if @class_id.nil?\n invalid_properties.push('invalid value for \"class_id\", class_id cannot be nil.')\n end\n\n if @object_type.nil?\n invalid_properties.push('invalid value for \"object_type\", object_type cannot be nil....
[ "0.76497203", "0.76497203", "0.76497203", "0.76497203", "0.7637422", "0.7637422", "0.7637422", "0.7637422", "0.7637422", "0.7637422", "0.7637422", "0.7637422", "0.7356452", "0.7334807", "0.72685325", "0.7238964", "0.7231359", "0.72258264", "0.7208294", "0.71760833", "0.717024...
0.0
-1
Check to see if the all the properties in the model are valid
def valid? return false if @id.nil? return false if @title.nil? return false if @title.to_s.length < 1 return false if @image.nil? return false if @image.to_s.length < 1 return false if @image_type.nil? return false if @image_type.to_s.length < 1 return false if @servings.nil? return false if @ready_in_minutes.nil? return false if @license.nil? return false if @license.to_s.length < 1 return false if @source_name.nil? return false if @source_name.to_s.length < 1 return false if @source_url.nil? return false if @source_url.to_s.length < 1 return false if @spoonacular_source_url.nil? return false if @spoonacular_source_url.to_s.length < 1 return false if @aggregate_likes.nil? return false if @health_score.nil? return false if @spoonacular_score.nil? return false if @price_per_serving.nil? return false if @cheap.nil? return false if @credits_text.nil? return false if @credits_text.to_s.length < 1 return false if @dairy_free.nil? return false if @gaps.nil? return false if @gaps.to_s.length < 1 return false if @gluten_free.nil? return false if @instructions.nil? return false if @ketogenic.nil? return false if @low_fodmap.nil? return false if @sustainable.nil? return false if @vegan.nil? return false if @vegetarian.nil? return false if @very_healthy.nil? return false if @very_popular.nil? return false if @whole30.nil? return false if @weight_watcher_smart_points.nil? return false if !@extended_ingredients.nil? && @extended_ingredients.length < 0 return false if @summary.nil? return false if @summary.to_s.length < 1 true end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def validate_properties\n true\n end", "def validate_properties\n true\n end", "def validate\n super\n\n check_optional_property :collection, String\n check_optional_property :create, String\n check_optional_property :delete, String\n check_optional_property :...
[ "0.78992486", "0.78992486", "0.70971805", "0.70782334", "0.7032205", "0.7031276", "0.69510347", "0.6869891", "0.6858077", "0.6858077", "0.68287027", "0.6823878", "0.6820306", "0.68144894", "0.6794656", "0.6752167", "0.66843414", "0.6676546", "0.6667755", "0.66296124", "0.6618...
0.0
-1
Custom attribute writer method with validation
def title=(title) if title.nil? fail ArgumentError, 'title cannot be nil' end if title.to_s.length < 1 fail ArgumentError, 'invalid value for "title", the character length must be great than or equal to 1.' end @title = title end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def attr_writer_tag(text); end", "def allowed_attributes=(_arg0); end", "def allowed_attributes=(_arg0); end", "def writer(*args)\n attr_writer(*args)\n args\n end", "def define_write_method(attr_name)\n evaluate_attribute_method attr_name, \"def #{attr_name}=(new_value);write_attribute('#{at...
[ "0.64708173", "0.63147706", "0.63147706", "0.62832147", "0.6279096", "0.6211268", "0.6187812", "0.6180797", "0.6068028", "0.6033098", "0.59972554", "0.59903276", "0.596004", "0.59378564", "0.59287316", "0.58953243", "0.5859936", "0.58510554", "0.58483785", "0.58452195", "0.58...
0.0
-1
Custom attribute writer method with validation
def image=(image) if image.nil? fail ArgumentError, 'image cannot be nil' end if image.to_s.length < 1 fail ArgumentError, 'invalid value for "image", the character length must be great than or equal to 1.' end @image = image end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def attr_writer_tag(text); end", "def allowed_attributes=(_arg0); end", "def allowed_attributes=(_arg0); end", "def writer(*args)\n attr_writer(*args)\n args\n end", "def define_write_method(attr_name)\n evaluate_attribute_method attr_name, \"def #{attr_name}=(new_value);write_attribute('#{at...
[ "0.6472992", "0.6315012", "0.6315012", "0.62821025", "0.6279224", "0.6211609", "0.61891466", "0.6182247", "0.60683644", "0.6032628", "0.5995443", "0.5988785", "0.5959885", "0.5938289", "0.5931089", "0.58951056", "0.5859927", "0.5851703", "0.58493423", "0.58465594", "0.5832836...
0.0
-1
Custom attribute writer method with validation
def image_type=(image_type) if image_type.nil? fail ArgumentError, 'image_type cannot be nil' end if image_type.to_s.length < 1 fail ArgumentError, 'invalid value for "image_type", the character length must be great than or equal to 1.' end @image_type = image_type end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def attr_writer_tag(text); end", "def allowed_attributes=(_arg0); end", "def allowed_attributes=(_arg0); end", "def writer(*args)\n attr_writer(*args)\n args\n end", "def define_write_method(attr_name)\n evaluate_attribute_method attr_name, \"def #{attr_name}=(new_value);write_attribute('#{at...
[ "0.6472992", "0.6315012", "0.6315012", "0.62821025", "0.6279224", "0.6211609", "0.61891466", "0.6182247", "0.60683644", "0.6032628", "0.5995443", "0.5988785", "0.5959885", "0.5938289", "0.5931089", "0.58951056", "0.5859927", "0.5851703", "0.58493423", "0.58465594", "0.5832836...
0.0
-1
Custom attribute writer method with validation
def license=(license) if license.nil? fail ArgumentError, 'license cannot be nil' end if license.to_s.length < 1 fail ArgumentError, 'invalid value for "license", the character length must be great than or equal to 1.' end @license = license end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def attr_writer_tag(text); end", "def allowed_attributes=(_arg0); end", "def allowed_attributes=(_arg0); end", "def writer(*args)\n attr_writer(*args)\n args\n end", "def define_write_method(attr_name)\n evaluate_attribute_method attr_name, \"def #{attr_name}=(new_value);write_attribute('#{at...
[ "0.6472992", "0.6315012", "0.6315012", "0.62821025", "0.6279224", "0.6211609", "0.61891466", "0.6182247", "0.60683644", "0.6032628", "0.5995443", "0.5988785", "0.5959885", "0.5938289", "0.5931089", "0.58951056", "0.5859927", "0.5851703", "0.58493423", "0.58465594", "0.5832836...
0.0
-1
Custom attribute writer method with validation
def source_name=(source_name) if source_name.nil? fail ArgumentError, 'source_name cannot be nil' end if source_name.to_s.length < 1 fail ArgumentError, 'invalid value for "source_name", the character length must be great than or equal to 1.' end @source_name = source_name end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def attr_writer_tag(text); end", "def allowed_attributes=(_arg0); end", "def allowed_attributes=(_arg0); end", "def writer(*args)\n attr_writer(*args)\n args\n end", "def define_write_method(attr_name)\n evaluate_attribute_method attr_name, \"def #{attr_name}=(new_value);write_attribute('#{at...
[ "0.64708173", "0.63147706", "0.63147706", "0.62832147", "0.6279096", "0.6211268", "0.6187812", "0.6180797", "0.6068028", "0.6033098", "0.59972554", "0.59903276", "0.596004", "0.59378564", "0.59287316", "0.58953243", "0.5859936", "0.58510554", "0.58483785", "0.58452195", "0.58...
0.0
-1
Custom attribute writer method with validation
def source_url=(source_url) if source_url.nil? fail ArgumentError, 'source_url cannot be nil' end if source_url.to_s.length < 1 fail ArgumentError, 'invalid value for "source_url", the character length must be great than or equal to 1.' end @source_url = source_url end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def attr_writer_tag(text); end", "def allowed_attributes=(_arg0); end", "def allowed_attributes=(_arg0); end", "def writer(*args)\n attr_writer(*args)\n args\n end", "def define_write_method(attr_name)\n evaluate_attribute_method attr_name, \"def #{attr_name}=(new_value);write_attribute('#{at...
[ "0.6472992", "0.6315012", "0.6315012", "0.62821025", "0.6279224", "0.6211609", "0.61891466", "0.6182247", "0.60683644", "0.6032628", "0.5995443", "0.5988785", "0.5959885", "0.5938289", "0.5931089", "0.58951056", "0.5859927", "0.5851703", "0.58493423", "0.58465594", "0.5832836...
0.0
-1
Custom attribute writer method with validation
def spoonacular_source_url=(spoonacular_source_url) if spoonacular_source_url.nil? fail ArgumentError, 'spoonacular_source_url cannot be nil' end if spoonacular_source_url.to_s.length < 1 fail ArgumentError, 'invalid value for "spoonacular_source_url", the character length must be great than or equal to 1.' end @spoonacular_source_url = spoonacular_source_url end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def attr_writer_tag(text); end", "def allowed_attributes=(_arg0); end", "def allowed_attributes=(_arg0); end", "def writer(*args)\n attr_writer(*args)\n args\n end", "def define_write_method(attr_name)\n evaluate_attribute_method attr_name, \"def #{attr_name}=(new_value);write_attribute('#{at...
[ "0.6472992", "0.6315012", "0.6315012", "0.62821025", "0.6279224", "0.6211609", "0.61891466", "0.6182247", "0.60683644", "0.6032628", "0.5995443", "0.5988785", "0.5959885", "0.5938289", "0.5931089", "0.58951056", "0.5859927", "0.5851703", "0.58493423", "0.58465594", "0.5832836...
0.0
-1
Custom attribute writer method with validation
def credits_text=(credits_text) if credits_text.nil? fail ArgumentError, 'credits_text cannot be nil' end if credits_text.to_s.length < 1 fail ArgumentError, 'invalid value for "credits_text", the character length must be great than or equal to 1.' end @credits_text = credits_text end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def attr_writer_tag(text); end", "def allowed_attributes=(_arg0); end", "def allowed_attributes=(_arg0); end", "def writer(*args)\n attr_writer(*args)\n args\n end", "def define_write_method(attr_name)\n evaluate_attribute_method attr_name, \"def #{attr_name}=(new_value);write_attribute('#{at...
[ "0.6472992", "0.6315012", "0.6315012", "0.62821025", "0.6279224", "0.6211609", "0.61891466", "0.6182247", "0.60683644", "0.6032628", "0.5995443", "0.5988785", "0.5959885", "0.5938289", "0.5931089", "0.58951056", "0.5859927", "0.5851703", "0.58493423", "0.58465594", "0.5832836...
0.0
-1
Custom attribute writer method with validation
def gaps=(gaps) if gaps.nil? fail ArgumentError, 'gaps cannot be nil' end if gaps.to_s.length < 1 fail ArgumentError, 'invalid value for "gaps", the character length must be great than or equal to 1.' end @gaps = gaps end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def attr_writer_tag(text); end", "def allowed_attributes=(_arg0); end", "def allowed_attributes=(_arg0); end", "def writer(*args)\n attr_writer(*args)\n args\n end", "def define_write_method(attr_name)\n evaluate_attribute_method attr_name, \"def #{attr_name}=(new_value);write_attribute('#{at...
[ "0.64708173", "0.63147706", "0.63147706", "0.62832147", "0.6279096", "0.6211268", "0.6187812", "0.6180797", "0.6068028", "0.6033098", "0.59972554", "0.59903276", "0.596004", "0.59378564", "0.59287316", "0.58953243", "0.5859936", "0.58510554", "0.58483785", "0.58452195", "0.58...
0.0
-1
Custom attribute writer method with validation
def extended_ingredients=(extended_ingredients) if !extended_ingredients.nil? && extended_ingredients.length < 0 fail ArgumentError, 'invalid value for "extended_ingredients", number of items must be greater than or equal to 0.' end @extended_ingredients = extended_ingredients end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def attr_writer_tag(text); end", "def allowed_attributes=(_arg0); end", "def allowed_attributes=(_arg0); end", "def writer(*args)\n attr_writer(*args)\n args\n end", "def define_write_method(attr_name)\n evaluate_attribute_method attr_name, \"def #{attr_name}=(new_value);write_attribute('#{at...
[ "0.6472992", "0.6315012", "0.6315012", "0.62821025", "0.6279224", "0.6211609", "0.61891466", "0.6182247", "0.60683644", "0.6032628", "0.5995443", "0.5988785", "0.5959885", "0.5938289", "0.5931089", "0.58951056", "0.5859927", "0.5851703", "0.58493423", "0.58465594", "0.5832836...
0.0
-1
Custom attribute writer method with validation
def summary=(summary) if summary.nil? fail ArgumentError, 'summary cannot be nil' end if summary.to_s.length < 1 fail ArgumentError, 'invalid value for "summary", the character length must be great than or equal to 1.' end @summary = summary end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def attr_writer_tag(text); end", "def allowed_attributes=(_arg0); end", "def allowed_attributes=(_arg0); end", "def writer(*args)\n attr_writer(*args)\n args\n end", "def define_write_method(attr_name)\n evaluate_attribute_method attr_name, \"def #{attr_name}=(new_value);write_attribute('#{at...
[ "0.6472992", "0.6315012", "0.6315012", "0.62821025", "0.6279224", "0.6211609", "0.61891466", "0.6182247", "0.60683644", "0.6032628", "0.5995443", "0.5988785", "0.5959885", "0.5938289", "0.5931089", "0.58951056", "0.5859927", "0.5851703", "0.58493423", "0.58465594", "0.5832836...
0.0
-1
Checks equality by comparing each attribute.
def ==(o) return true if self.equal?(o) self.class == o.class && id == o.id && title == o.title && image == o.image && image_type == o.image_type && servings == o.servings && ready_in_minutes == o.ready_in_minutes && license == o.license && source_name == o.source_name && source_url == o.source_url && spoonacular_source_url == o.spoonacular_source_url && aggregate_likes == o.aggregate_likes && health_score == o.health_score && spoonacular_score == o.spoonacular_score && price_per_serving == o.price_per_serving && analyzed_instructions == o.analyzed_instructions && cheap == o.cheap && credits_text == o.credits_text && cuisines == o.cuisines && dairy_free == o.dairy_free && diets == o.diets && gaps == o.gaps && gluten_free == o.gluten_free && instructions == o.instructions && ketogenic == o.ketogenic && low_fodmap == o.low_fodmap && occasions == o.occasions && sustainable == o.sustainable && vegan == o.vegan && vegetarian == o.vegetarian && very_healthy == o.very_healthy && very_popular == o.very_popular && whole30 == o.whole30 && weight_watcher_smart_points == o.weight_watcher_smart_points && dish_types == o.dish_types && extended_ingredients == o.extended_ingredients && summary == o.summary && wine_pairing == o.wine_pairing end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ==(other)\n attributes == other.attributes\n end", "def ==(other) # :nodoc:\n @attrs == other.attrs\n end", "def eql?(other)\n return true if self == other\n @@ATTRIBUTES.each do |att|\n return false unless self.send(att).eql?(other.send(att))\n end\n true\n en...
[ "0.7291717", "0.7188103", "0.70395297", "0.7007927", "0.68874705", "0.6861532", "0.6707156", "0.6660597", "0.66147524", "0.658478", "0.6584619", "0.6580019", "0.65543133", "0.6543933", "0.65068495", "0.6479513", "0.6456241", "0.6415999", "0.6412208", "0.6412208", "0.6412208",...
0.0
-1
Calculates hash code according to all attributes.
def hash [id, title, image, image_type, servings, ready_in_minutes, license, source_name, source_url, spoonacular_source_url, aggregate_likes, health_score, spoonacular_score, price_per_serving, analyzed_instructions, cheap, credits_text, cuisines, dairy_free, diets, gaps, gluten_free, instructions, ketogenic, low_fodmap, occasions, sustainable, vegan, vegetarian, very_healthy, very_popular, whole30, weight_watcher_smart_points, dish_types, extended_ingredients, summary, wine_pairing].hash end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def attr_hash\n Digest::MD5.hexdigest(\"#{@name}:#{@ruby_type}\")\n end", "def hash() end", "def hash() end", "def hash() end", "def hash() end", "def hash() end", "def hash() end", "def hash() end", "def hash\n code = 17\n code = 37*code + @x.hash\n code = 37*code + @y.hash\n ...
[ "0.7121255", "0.7037823", "0.7037823", "0.7037823", "0.7037823", "0.7037823", "0.7037823", "0.7037823", "0.68942124", "0.6782416", "0.6706031", "0.66977906", "0.66866964", "0.6668208", "0.6487407", "0.6460204", "0.6460204", "0.64430994", "0.64097935", "0.63958734", "0.6387996...
0.0
-1
Builds the object from hash
def build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) self.class.openapi_types.each_pair do |key, type| if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key) self.send("#{key}=", nil) elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not if attributes[self.class.attribute_map[key]].is_a?(Array) self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) }) end elsif !attributes[self.class.attribute_map[key]].nil? self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) end end self end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def build(hash)\n obj = new\n hash.each_pair do |k,v|\n obj[k] = v if variables[k]\n end\n return obj\n end", "def build_from_hash(attributes)\n\n end", "def build_from_hash(hash)\n instance = self.new\n\n # Add the instance attributes dynamically ...
[ "0.8011074", "0.7470833", "0.7457607", "0.7256629", "0.72455454", "0.70060325", "0.6973257", "0.6955014", "0.69459796", "0.69398683", "0.69363195", "0.6917627", "0.6872358", "0.6796184", "0.6783521", "0.67575246", "0.67575246", "0.67560464", "0.67514306", "0.67136854", "0.666...
0.0
-1
Deserializes the data based on type
def _deserialize(type, value) case type.to_sym when :Time Time.parse(value) when :Date Date.parse(value) when :String value.to_s when :Integer value.to_i when :Float value.to_f when :Boolean if value.to_s =~ /\A(true|t|yes|y|1)\z/i true else false end when :Object # generic object (usually a Hash), return directly value when /\AArray<(?<inner_type>.+)>\z/ inner_type = Regexp.last_match[:inner_type] value.map { |v| _deserialize(inner_type, v) } when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/ k_type = Regexp.last_match[:k_type] v_type = Regexp.last_match[:v_type] {}.tap do |hash| value.each do |k, v| hash[_deserialize(k_type, k)] = _deserialize(v_type, v) end end else # model # models (e.g. Pet) or oneOf klass = OpenapiClient.const_get(type) klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _deserialize(type, value)\n case type.to_sym\n when :DateTime\n DateTime.parse(value)\n when :Date\n Date.parse(value)\n when :String\n value.to_s\n when :Integer\n value.to_i\n when :Float\n value.to_f\n when :BOOLEAN\n if value.to_s...
[ "0.7330926", "0.7274019", "0.72504056", "0.7245751", "0.72291344", "0.72291344", "0.72291344", "0.72291344", "0.72291344", "0.72291344", "0.72291344", "0.72291344", "0.72291344", "0.72291344", "0.72291344", "0.72291344", "0.72291344", "0.72291344", "0.72291344", "0.72291344", ...
0.0
-1
Returns the string representation of the object
def to_s to_hash.to_s end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def to_s\n @object.to_s\n end", "def to_s\n object.to_s\n end", "def serialize(object)\n object.to_s\n end", "def to_s\n self.inspect\n end", "def to_s\n @string || @object.to_s('F')\n end", "def to_s\n @string || @object.to_s('F')\n end", "de...
[ "0.901024", "0.89506465", "0.84703195", "0.83409667", "0.8337169", "0.8337169", "0.8332247", "0.82546586", "0.8145818", "0.8144667", "0.81357557", "0.812714", "0.8093436", "0.8086725", "0.8073356", "0.8039774", "0.80308646", "0.80064154", "0.80064154", "0.80064154", "0.800641...
0.0
-1
to_body is an alias to to_hash (backward compatibility)
def to_body to_hash end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def to_body\r\n to_hash\r\n end", "def to_body\n to_hash\nend", "def to_body\n to_hash\nend" ]
[ "0.8429809", "0.8347024", "0.8347024" ]
0.0
-1
Returns the object in the form of hash
def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) if value.nil? is_nullable = self.class.openapi_nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end hash[param] = _to_hash(value) end hash end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def to_hash\n object\n end", "def hash\r\n return to_s.hash\r\n end", "def hash\n to_a.hash\n end", "def hash\n [_hash, name, owner].hash\n end", "def hash\n return to_s.hash\n end", "def hash\n @hash\n end", "def hash\n @hash.hash\n end", "def hash\n ...
[ "0.8270299", "0.78767854", "0.78726953", "0.7802364", "0.7789188", "0.77806795", "0.7775915", "0.7767511", "0.7760525", "0.7760525", "0.77559966", "0.7731286", "0.7713916", "0.7713916", "0.7713916", "0.7713916", "0.7713916", "0.7713916", "0.7713916", "0.7713916", "0.7713916",...
0.0
-1
Outputs nonarray value in the form of hash For object, use to_hash. Otherwise, just return the value
def _to_hash(value) if value.is_a?(Array) value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash value.to_hash else value end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def hash\n [value].hash\n end", "def hash\n [value].hash\n end", "def hash\n\t\tvalue.hash\n\tend", "def hash\n value.hash\n end", "def hash\n @value.hash\n end", "def hash\r\n return to_s.hash\r\n end", "def to_hash\n @value\n end", "def to_hash\n @va...
[ "0.6719518", "0.6719518", "0.666832", "0.66565555", "0.6586841", "0.6452931", "0.6414911", "0.6414911", "0.6382046", "0.6346188", "0.6302933", "0.62237245", "0.6151989", "0.6101756", "0.60795677", "0.60795677", "0.60717124", "0.6035991", "0.6021168", "0.5936472", "0.5903488",...
0.0
-1
GET /mission_memberships GET /mission_memberships.json
def index @mission_memberships = MissionMembership.all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def memberships\n @list.client.get(\"#{url}/memberships\")\n end", "def index\n @memberships = @user.memberships\n end", "def GetMemberships params = {}\n\n params = params.merge(path: 'group_memberships.json')\n APICall(params)\n\n end", "def list_memberships(user)\n get(...
[ "0.76106286", "0.7396231", "0.72806555", "0.72588444", "0.70949376", "0.70320547", "0.6945259", "0.69267637", "0.68940276", "0.6810406", "0.67558146", "0.67558146", "0.67558146", "0.6728887", "0.6690107", "0.6661255", "0.6593517", "0.65318435", "0.6506067", "0.64345264", "0.6...
0.78292584
0
GET /mission_memberships/1 GET /mission_memberships/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @mission_memberships = MissionMembership.all\n end", "def GetMembership id\n\n APICall(path: \"group_memberships/#{id}.json\")\n\n end", "def set_mission_membership\n @mission_membership = MissionMembership.find(params[:id])\n end", "def index\n @memberships = @user.mem...
[ "0.7767887", "0.7276003", "0.7273928", "0.7247106", "0.7180575", "0.7057984", "0.6946464", "0.69091326", "0.6858061", "0.6809658", "0.67634076", "0.6693454", "0.6691555", "0.6681637", "0.6681637", "0.6681637", "0.6678518", "0.6674249", "0.6662902", "0.66340756", "0.65968674",...
0.0
-1
POST /mission_memberships POST /mission_memberships.json
def create @mission_membership = MissionMembership.new(mission_membership_params) respond_to do |format| if @mission_membership.save format.html { redirect_to @mission_membership, notice: 'Mission membership was successfully created.' } format.json { render :show, status: :created, location: @mission_membership } else format.html { render :new } format.json { render json: @mission_membership.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def CreateMembership params = {}\n \n APICall(path: 'group_memberships.json',method: 'POST',payload: params.to_json)\n \n end", "def mission_membership_params\n params.require(:mission_membership).permit(:user_id, :mission_id)\n end", "def create\n @membership = Adhocra...
[ "0.74409395", "0.7237003", "0.719769", "0.70858735", "0.701683", "0.68935937", "0.6871786", "0.6861041", "0.67830914", "0.6780647", "0.67684424", "0.6766007", "0.6600742", "0.6540821", "0.65174806", "0.6459168", "0.6427318", "0.6395617", "0.63640666", "0.63258076", "0.6318312...
0.7569
0
PATCH/PUT /mission_memberships/1 PATCH/PUT /mission_memberships/1.json
def update respond_to do |format| if @mission_membership.update(mission_membership_params) format.html { redirect_to @mission_membership, notice: 'Mission membership was successfully updated.' } format.json { render :show, status: :ok, location: @mission_membership } else format.html { render :edit } format.json { render json: @mission_membership.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @membership ||= Membership.find(params[:id])\n\n respond_to do |format|\n if @membership.update_attributes(params[:membership])\n format.html { redirect_to @membership, notice: 'Membership was successfully updated.' }\n format.json { head :no_content }\n else\n for...
[ "0.7122485", "0.70846295", "0.70549154", "0.70328283", "0.70328283", "0.70328283", "0.70328283", "0.70328283", "0.7025758", "0.70087314", "0.6939785", "0.6920675", "0.69048536", "0.68792355", "0.6831834", "0.6770367", "0.66976655", "0.6664359", "0.66423", "0.658141", "0.65712...
0.77228504
0
DELETE /mission_memberships/1 DELETE /mission_memberships/1.json
def destroy @mission_membership.destroy respond_to do |format| format.html { redirect_to mission_memberships_url, notice: 'Mission membership was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @membership.destroy\n respond_to do |format|\n format.html { redirect_to memberships_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @membership.destroy\n respond_to do |format|\n format.html { redirect_to memberships_url }\n format.json { h...
[ "0.77090037", "0.77090037", "0.7646792", "0.7564791", "0.7497444", "0.7477663", "0.7469547", "0.7458328", "0.74232525", "0.7390943", "0.7321565", "0.7270806", "0.72695017", "0.72127837", "0.7205155", "0.71368515", "0.7113252", "0.7090446", "0.7066427", "0.70397353", "0.702391...
0.80314225
0
Use callbacks to share common setup or constraints between actions.
def set_mission_membership @mission_membership = MissionMembership.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.6165094", "0.60450804", "0.5944413", "0.5915806", "0.58885634", "0.5835225", "0.5775847", "0.5700531", "0.5700531", "0.56543404", "0.56209993", "0.54238355", "0.5410386", "0.5410386", "0.5410386", "0.5394892", "0.5377769", "0.53559244", "0.5339896", "0.53388095", "0.533008...
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def mission_membership_params params.require(:mission_membership).permit(:user_id, :mission_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...
[ "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.0
-1
I worked on this challenge with Gabrielle Gustilo. I spent 1 hours on this challenge. Complete each step below according to the challenge directions and include it in this file. Also make sure everything that isn't code is commented. 0. Pseudocode Input: An array of values. Output: An array of the most frequent values. Pseudocode: define method mode, which takes one argument "array" create new Hash iterate through the array if element is not a key in the Hash, create key with value +1 if element is a key in the Hash, increment value +1 get max value of hash check hash for other occurences of max value return as hash pull keys for max value hash 1. Initial Solution
def mode(array) results = {} array.each do |e| if results.has_key?(e) results[e] += 1 else results[e] = 1 end end max = results.max_by{|k,v| v} results.select!{|k,v| v == max[1]} results.keys end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def mode(array)\n frequency = {}\n array.each do |item|\n if frequency.has_key?(item)\n frequency[item] = frequency[item] + 1\n else\n frequency[item] = 1\n end\n end\n\nmax_value = 0\nfrequency.each_value do |value|\n if value > max_value\n max_value = value\n end\nend\nmax = []\nmax_ke...
[ "0.89550817", "0.8930741", "0.88528234", "0.8817719", "0.87976265", "0.87596524", "0.87591493", "0.874088", "0.8733053", "0.8720825", "0.87126374", "0.86996806", "0.8682977", "0.86768436", "0.8663148", "0.866122", "0.86584437", "0.86504096", "0.8647628", "0.864164", "0.862834...
0.83049667
61
Dispatch remaining units in owned territories. Used when the user didn't do it himself during deployment.
def dispatch_remaining_units! Participation.transaction do shuffled_ownerships = ownerships.shuffle 1.upto(units_count) do ownerships.sample.deploy_units!(1) end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def compute_free_places\n max_participants - compute_occupied_places\n end", "def getAllUnits\n deep_copy(@allUnits)\n end", "def completed_units\n return @completed_units\n end", "def user_units\n @user.units\n end", "def available_units\n return 0 if status ==...
[ "0.5652705", "0.55627716", "0.5475168", "0.5465182", "0.54602784", "0.545765", "0.54546475", "0.54125816", "0.53626484", "0.53552467", "0.53325886", "0.53312206", "0.53278375", "0.53141254", "0.52933687", "0.5287663", "0.52581763", "0.52441067", "0.5226708", "0.52012277", "0....
0.68727684
0
Method that adds git repo (if it does not exist)
def add_repo_git(dir) if not Dir.exist?("#{dir}/.git") system_commands("git init #{dir}") end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add(path, param=File.split(path).last)\n unless self.has_repo?(param)\n begin\n list << Repo.new(path)\n rescue Rugged::RepositoryError\n logger.warn \"SKIPPING '#{path}' - not a git repository\"\n end\n end\n list\n end", "def git_add_everything(host,...
[ "0.7786885", "0.7279959", "0.725854", "0.71903586", "0.7140012", "0.70737445", "0.7009269", "0.6834908", "0.67963755", "0.67793787", "0.6749535", "0.6740471", "0.6685378", "0.66643465", "0.6618561", "0.6605729", "0.66043293", "0.65890884", "0.65625286", "0.65524465", "0.65443...
0.83147377
0
Method to pull project request if user wants
def pull_execute(branch, dir) vConfig(CONFIG['configWebsite']) read_json(CONFIG['configWebsite']) pull = @parse_json_config['deploy']['github']['config']['pull'] if pull == "yes" system_commands("cd #{dir}; git pull origin #{branch}") end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def gh_pull_request(data, config)\n action = data['action'] || nil\n pr = data['pull_request'] || nil\n\n Cyclid.logger.debug \"action=#{action}\"\n return true unless action == 'opened' \\\n or action == 'reopened' \\\n ...
[ "0.7001284", "0.68103707", "0.6736298", "0.66228366", "0.6607244", "0.6573737", "0.6538799", "0.653458", "0.64818114", "0.640499", "0.63741964", "0.632654", "0.6323931", "0.62986076", "0.6297217", "0.6293655", "0.62855625", "0.6278223", "0.6267136", "0.6261666", "0.6254019", ...
0.0
-1
Method to check if a given branch exists and enter or create the same.
def git_checkout(setBranch, dir) getBranch = `cd #{dir}; git branch --list | sed -n "/#{setBranch}/p" | cut -d'*' -f2 | awk '{ gsub (" ", "", $0); print}'` if getBranch.nil? || getBranch.empty? system_commands("cd #{dir}; git checkout -b #{setBranch}") else system_commands("cd #{dir}; git checkout #{getBranch}") end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_branch\n check_current_repo\n exists = `git branch --list #{branch}`.squish == branch\n if exists\n `git checkout #{branch}`\n else\n `git checkout master` unless current_branch == 'master'\n `git checkout -b #{branch}`\n end\nend", "def branch_exists?(branch = branch_name)\n git.ca...
[ "0.7477726", "0.7319752", "0.7282876", "0.7063241", "0.69429773", "0.6899303", "0.6818747", "0.67144597", "0.67061746", "0.6641557", "0.66340685", "0.6623382", "0.65888405", "0.6588591", "0.65870833", "0.6571904", "0.65333396", "0.64871174", "0.64258677", "0.64155406", "0.639...
0.0
-1
Method that checks and adds or not the remote github url
def add_remoteurl(dir) vConfig(CONFIG['configWebsite']) read_json(CONFIG['configWebsite']) remoteURL = @parse_json_config['deploy']['github']['config']['remoteURL'] remoteVerify = `sed -n '/url/p' #{dir}/.git/config | cut -d'=' -f2 | cut -d' ' -f2` if remoteVerify.nil? || remoteVerify.empty? system_commands("cd #{dir}; git remote add origin #{remoteURL}") end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def has_github?\n !github_url.blank?\n end", "def github_url\n [homepage, source_code_uri].find do |url|\n GemsBond::Fetchers::Github.valid_url?(url)\n end\n end", "def harmonize_remote_url(expected_url)\n remote_url = Cocaine::CommandLine.new(\"git config --get remote.origin.url...
[ "0.76588166", "0.71272326", "0.7058315", "0.7052431", "0.70423794", "0.69761235", "0.69377404", "0.66902834", "0.6660783", "0.66258305", "0.6621216", "0.6594847", "0.653276", "0.65156406", "0.65015984", "0.64983886", "0.6460231", "0.6424185", "0.64228576", "0.6418765", "0.641...
0.746424
1
Method that starts the deploy of the compiled project
def deploySite verifyOS timeDate = Time.new vConfig(CONFIG['configWebsite']) read_json(CONFIG['configWebsite']) compileP = @parse_json_config['deploy']['compile']['built'] branchBuilt = @parse_json_config['deploy']['branch']['built'] msgCommit = @parse_json_config['deploy']['github']['config']['commit'] if compileP == "yes" system_commands("rake build") end # enter_folder("./_site") # DEPRECATED add_repo_git(SITEDIR) add_remoteurl(SITEDIR) pull_execute(branchBuilt, SITEDIR) system_commands("echo Deploy source files. Wait ...") git_checkout(branchBuilt, SITEDIR) system_commands("cd #{SITEDIR}; git add .") system_commands("cd #{SITEDIR}; git commit -m \"#{msgCommit} - #{timeDate.inspect}\"") system_commands("cd #{SITEDIR}; git push origin -u #{branchBuilt}") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def deploy()\n release = create_release_name()\n\n write_deploy_version_file()\n\n DirectorySync.sync(server, from_dir, cache_dir, server[:deployer])\n copy_cache_dir_to_release(release)\n\n symlink_shared_directories(release)\n\n send_scripts()\n run_script(:before...
[ "0.74498004", "0.73822", "0.72867525", "0.7238021", "0.7143079", "0.7062464", "0.6823013", "0.676205", "0.6716412", "0.6665663", "0.6639183", "0.6626383", "0.6571943", "0.65282935", "0.6491921", "0.64896834", "0.6481388", "0.6453284", "0.6451391", "0.6438518", "0.643701", "...
0.64958453
14
Method that initiates deploy of project source code
def deploySource verifyOS timeDate = Time.new vConfig(CONFIG['configWebsite']) read_json(CONFIG['configWebsite']) branchSource = @parse_json_config['deploy']['branch']['source'] msgCommit = @parse_json_config['deploy']['github']['config']['commit'] add_repo_git(".") add_remoteurl(".") pull_execute(branchSource, ".") git_checkout(branchSource, ".") system_commands("echo Deploy source files. Wait ...") system_commands("git add .") system_commands("git commit -m \"#{msgCommit} - #{timeDate.inspect}\"") system_commands("git push origin -u #{branchSource}") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def deploy()\n release = create_release_name()\n\n write_deploy_version_file()\n\n DirectorySync.sync(server, from_dir, cache_dir, server[:deployer])\n copy_cache_dir_to_release(release)\n\n symlink_shared_directories(release)\n\n send_scripts()\n run_script(:before...
[ "0.69879", "0.69847274", "0.6892983", "0.6831968", "0.68097377", "0.68072814", "0.67954785", "0.6778892", "0.67502743", "0.67266977", "0.6706492", "0.6660971", "0.66427404", "0.65669", "0.6535593", "0.651196", "0.65044767", "0.64739376", "0.64739376", "0.64305824", "0.6387655...
0.6962579
2
:nodoc: A string representation of this Version.
def version @version.dup end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def to_s\n self.version.to_s\n end", "def to_s\n @version\n end", "def to_s\n @version\n end", "def to_s\n \"<Version #{number}>\"\n end", "def to_s\n @version\n end", "def to_s\n version = get_version_string\n version << \"-#{get_pre_string}\" unless @pr...
[ "0.8215513", "0.8058804", "0.8058804", "0.796417", "0.79218316", "0.760062", "0.7438801", "0.74122417", "0.74122417", "0.74122417", "0.74122417", "0.73941314", "0.7385345", "0.7279383", "0.7279383", "0.7279383", "0.7279383", "0.7270175", "0.72545546", "0.7232385", "0.7232385"...
0.0
-1
The full version, with extra zeros prepended for minor and patch if they are missing.
def full_version segments = self.segments segments.push 0 while segments.size < 3 segments.join(".") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def full_version\n return nil unless exact\n\n \"~> \".concat(version)\n end", "def version\n @version ||= version_hex.to_s(16).chars.entries.join('.')\n end", "def minor_version(version = nil)\n version ||= installed_version?\n return \"0.0\" if version.nil?\n\n version.sub(/\\.\\d+$...
[ "0.7619811", "0.7359167", "0.70975435", "0.70632404", "0.7061299", "0.6984565", "0.6977209", "0.6908264", "0.68629193", "0.68619186", "0.683073", "0.68145174", "0.67787987", "0.67596686", "0.6679284", "0.66772634", "0.6652856", "0.6633099", "0.6614034", "0.66041154", "0.65200...
0.7133883
2
Constructs a Version from the +version+ string. A version string is a series of digits or ASCII letters separated by dots.
def initialize(version) unless self.class.correct?(version) raise ArgumentError, "Malformed version number string #{version}" end @version = version.to_s.strip @segments = nil end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def initialize(version)\n unless self.class.correct?(version)\n raise ArgumentError, \"Malformed version number string #{version}\"\n end\n\n # If version is an empty string convert it to 0\n version = 0 if version.is_a?(String) && version =~ /\\A\\s*\\Z/\n\n @version = version.to_s.strip.gsub(...
[ "0.76013184", "0.75010276", "0.73253834", "0.72288823", "0.7208856", "0.71559083", "0.7001371", "0.6874154", "0.6782436", "0.676036", "0.6743286", "0.6697681", "0.6619271", "0.6619271", "0.6534759", "0.648085", "0.6453774", "0.6436464", "0.64097077", "0.63496315", "0.63113314...
0.74028313
2
Return a new version object where the next to the last revision number is one greater (e.g., 5.3.1 => 5.4).
def bump @bump ||= begin segments = self.segments segments.pop if segments.size > 1 segments[-1] = segments[-1].succ self.class.new segments.join(".") end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def bump\n parts = parse_parts_from_version_string\n parts.pop while parts.any? { |part| part.alpha? }\n parts.pop if parts.size > 1\n parts[-1] = parts[-1].succ\n self.class.new(parts.join(\".\"))\n end", "def last_version\n @last_version ||= versions.maximum(:number) || 1\n end"...
[ "0.72846055", "0.71790844", "0.71764606", "0.71290874", "0.69964457", "0.6958", "0.6955923", "0.69128436", "0.6907822", "0.6838771", "0.6789951", "0.6765523", "0.6760832", "0.6689323", "0.6687284", "0.66861886", "0.65922624", "0.6567859", "0.6558683", "0.6518475", "0.6511735"...
0.0
-1
A Version is only eql? to another version if it's specified to the same precision. Version "1.0" is not the same as version "1".
def eql?(other) self.class === other and @version == other._version end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_numeric_comparison\n value1_ = ::Versionomy.create([1, 9, 2], :semver)\n value2_ = ::Versionomy.create([1, 9], :semver)\n assert(value2_ < value1_)\n value1_ = ::Versionomy.create([1, 9, 0], :semver)\n value2_ = ::Versionomy.create([1, 9], :semver)\n assert(value2...
[ "0.7103037", "0.7078211", "0.6941951", "0.6727643", "0.67072713", "0.66723233", "0.65382963", "0.6410356", "0.6392189", "0.6389098", "0.6383337", "0.6361635", "0.63400555", "0.6337259", "0.63070583", "0.62533575", "0.6225545", "0.62221724", "0.6147567", "0.6132779", "0.612836...
0.67370516
4
A recommended version for use with a ~> Requirement.
def approximate_recommendation segments = self.segments segments.pop while segments.size > 2 segments.push 0 while segments.size < 2 recommendation = "~> #{segments.join(".")}" recommendation end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def requirement\n Gem::Requirement.new('~>' + pharos_version.segments.first(2).join('.') + (pharos_version.prerelease? ? '.0-a' : '.0'))\n end", "def requirement\n \"~> #{major}\"\n end", "def version\n @dependency.requirement\n end", "def required_version\n normalize_v...
[ "0.72868747", "0.7146809", "0.7003008", "0.6972227", "0.69709706", "0.6815177", "0.67962575", "0.670734", "0.6695623", "0.66733134", "0.66620564", "0.66620564", "0.6634936", "0.66155094", "0.660427", "0.65951306", "0.654429", "0.64922875", "0.6462626", "0.6437583", "0.6396447...
0.0
-1
Compares this version with +other+ returning 1, 0, or 1 if the other version is larger, the same, or smaller than this one. Attempts to compare to something that's not a Gem::Version return +nil+.
def <=>(other) return unless FoobarMod::Version === other return 0 if @version == other._version || canonical_segments == other.canonical_segments lhsegments = canonical_segments rhsegments = other.canonical_segments lhsize = lhsegments.size rhsize = rhsegments.size limit = (lhsize > rhsize ? lhsize : rhsize) - 1 i = 0 while i <= limit lhs, rhs = lhsegments[i] || 0, rhsegments[i] || 0 i += 1 next if lhs == rhs return -1 if String === lhs && Numeric === rhs return 1 if Numeric === lhs && String === rhs return lhs <=> rhs end return 0 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def <=>(other)\n other_number = other.is_a?(self.class) ? other.number : other\n Gem::Version.new(number) <=> Gem::Version.new(other_number)\n end", "def >= (other)\n Version.compare(self, other) >= 0\n end", "def <=>(other_version)\n self < other_version ? -1 : self == othe...
[ "0.7609623", "0.74609953", "0.7447309", "0.732224", "0.7188725", "0.71836454", "0.71729964", "0.71470916", "0.7091674", "0.6997455", "0.6924706", "0.6866984", "0.68485516", "0.68006617", "0.67671907", "0.6677429", "0.65965027", "0.656231", "0.6554482", "0.65196544", "0.648498...
0.6446981
21
DELETE /social_medias/1 DELETE /social_medias/1.json
def destroy @social_media.destroy respond_to do |format| format.html { redirect_to url_back, notice: 'social media was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @socialmediasite.destroy\n respond_to do |format|\n format.html { redirect_to socialmediasites_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @medio = Medio.find(params[:id])\n @medio.destroy\n\n respond_to do |format|\n format.html { redirec...
[ "0.8106292", "0.7840484", "0.75499827", "0.7509205", "0.744935", "0.74101496", "0.73800826", "0.73797673", "0.7367843", "0.73671913", "0.735851", "0.73511904", "0.73482156", "0.7339288", "0.73315656", "0.73087883", "0.7264992", "0.7242742", "0.7216486", "0.721182", "0.7200243...
0.7487068
4
Use callbacks to share common setup or constraints between actions.
def set_extend_demography @extend_demography = ExtendDemography.find(params[:extend_demography_id]) @url_back = url_back rescue ActiveRecord::RecordNotFound render_404 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
before_action :authenticate_user, only: [:index, :show]
def index @tags = Tag.all @prices = Price.all @favorite = Favorite.all @bars = Bar.last(9) @cities = Bar.pluck(:city) @bars_search_by_my_user = Bar.new @gigs = Gig.last(4) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n redirect_to current_user\n end", "def show\n skip_authorization\n end", "def show\n # authorize Admin\n end", "def index\n redirect_to(:action => 'login') and return unless logged_in?\n \n @user = current_user\n end", "def index\n redirect_to @current_user if current_user...
[ "0.75556827", "0.745496", "0.7448857", "0.7411959", "0.7402401", "0.7381169", "0.7381169", "0.7304431", "0.7266621", "0.7266621", "0.72559065", "0.72340584", "0.7223579", "0.7192612", "0.71893847", "0.7179142", "0.71746325", "0.7158757", "0.7158757", "0.7157501", "0.7148973",...
0.0
-1
Called after the WebSocket handshake completes.
def connected(query) join_key = query['key'] if join_key @nexus.user_by_key join_key do |user| if user && !user.session @user = user @room = user.room @user.set_session self respond hi: 'ok' else @ws.close_websocket end end else @ws.close_websocket end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ssl_handshake_completed\n connected!\n end", "def post_init\n @state = :connecting\n @handshake = ::WebSocket::Handshake::Server.new(:secure => @secure_proxy)\n start_tls(@tls_options) if @secure\n end", "def ssl_handshake_completed\n auth_data = {\n api_ke...
[ "0.7383703", "0.68649566", "0.6817576", "0.6753346", "0.6732809", "0.65693104", "0.65659815", "0.6560655", "0.6473209", "0.646189", "0.6434203", "0.64334786", "0.6341668", "0.63372535", "0.63372535", "0.6307783", "0.6306671", "0.6291704", "0.6239273", "0.61899674", "0.6179674...
0.0
-1
Called when the client closes the WebSocket.
def closed if @user && @room @user.remove_session @room = nil end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def on_close\n websocket_client.on(:close) do |event|\n p [:close, event.code, event.reason]\n end\n end", "def on_close(env)\n @subscription.delete if @subscription\n logger.debug \"WebSocket closing connection\"\n end", "def websocket_connection_close(ws, client)\n ws.on...
[ "0.84952414", "0.79038244", "0.786516", "0.7622504", "0.75200546", "0.744577", "0.7439407", "0.7404754", "0.7263375", "0.7180253", "0.7180253", "0.71518993", "0.70926535", "0.6958211", "0.6952492", "0.68450874", "0.67452216", "0.67247725", "0.67071", "0.67034715", "0.66702634...
0.0
-1
Called when the client sends some data.
def received(message) if message.respond_to?(:encoding) && message.encoding != 'UTF-8' message.force_encoding 'UTF-8' end data = JSON.parse message, :symbolize_names => true case data[:type] when 'text' return if @nonces.include?(data[:nonce]) @nonces << data[:nonce] room.message @user, data[:text], name_color, data[:client_ts] when 'av-invite', 'av-accept', 'av-close' return if @nonces.include?(data[:nonce]) @nonces << data[:nonce] av_message data when 'sync' @last_event_id = data[:last_event_id].to_i sync_events when 'ping' respond pong: { nonce: data[:nonce], client_ts: data[:client_ts] } when 'relay' return if @nonces.include?(data[:nonce]) @nonces << data[:nonce] room.relay @user, data[:to], data[:body], data[:client_ts] end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def send_data(data)\n super(data)\n puts \"#{self} send_data done: #{data.inspect}\"\n end", "def send_data(data)\n super(data)\n puts \"#{self} send_data done: #{data.inspect}\"\n end", "def send_data data\n super \"#{data}\\n\"\n Events.dispatch(:raw_out, Message.new(self, data, true)...
[ "0.7275672", "0.7275672", "0.7193808", "0.6983931", "0.6962535", "0.6962535", "0.6922989", "0.6902052", "0.6883058", "0.6834015", "0.68314976", "0.68106854", "0.6772976", "0.6769789", "0.67508185", "0.6749107", "0.6701254", "0.66909736", "0.6676307", "0.66644526", "0.66466415...
0.0
-1
Called by received to process A/V events.
def av_message(message_data) case message_data['type'] when 'av-invite' @av_nonce = message_data[:av_nonce] when 'av-accept' # NOTE: room#av_event takes care of av-accept when 'av-close' @av_nonce = nil if @av_nonce == message_data[:av_nonce] end room.av_event @user, message_data[:type], message_data[:av_nonce], @name_color, message_data[:client_ts] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def received\n end", "def processEvent(eventName)\n\tend", "def on_bytes(ev)\n\t\tclient = @clients[ev.src_addr]\n\t\t# client can only be 0 if it's a connect packet\n\t\tpost_event bytes_to_event(client,ev.bytes)\n\tend", "def process\n read_events.each {|event| event.callback!}\n end", "def even...
[ "0.6694836", "0.6279749", "0.5963906", "0.5909283", "0.58486754", "0.58486754", "0.58486754", "0.58486754", "0.58486754", "0.58486754", "0.58486754", "0.58486754", "0.58278257", "0.5823451", "0.5823451", "0.5823276", "0.5802523", "0.5732461", "0.57003206", "0.57003206", "0.57...
0.5918022
3
The color of this user's messages.
def name_color # HACK(pwnall): come up with better colors user.key == @room.user1.key ? 'red' : 'blue' end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_user_text_color(user)\n user_color = get_user_color(user).gsub(\"#\", \"\")\n\n # Get the hex color as red, green, blue\n r = user_color[0..1].hex\n g = user_color[2..3].hex\n b = user_color[4..5].hex\n\n if ((r * 0.299) + (g * 0.587) + (b * 0.114)) > 186\n \"#4a4a4a\"\n else\n ...
[ "0.6822189", "0.6671622", "0.6671622", "0.6510276", "0.64185995", "0.64103967", "0.6400676", "0.6391661", "0.6387521", "0.63467145", "0.6305448", "0.62759256", "0.62428457", "0.61948776", "0.6142574", "0.6139737", "0.61388814", "0.6075754", "0.60551226", "0.60551226", "0.6039...
0.6738438
1
Returns a JSON hash describing the session info for this user.
def presence_info { name: @user.name, name_color: @name_color, av_nonce: @av_nonce } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def session_hash(user)\n {\n username: user.username,\n authentication_token: user.authentication_token\n }\n end", "def to_session_hash\n {:id => self.id, :name => self.name, :email => self.email, :language => self.language}\n end", "def session_to_s\n return '' if @session.nil?\n\n ...
[ "0.7872431", "0.73587406", "0.6997041", "0.6704282", "0.6584308", "0.65706366", "0.65043086", "0.64443815", "0.64112914", "0.64012635", "0.6400366", "0.63847876", "0.6377968", "0.6312867", "0.63016415", "0.6296805", "0.62919784", "0.62919784", "0.6266916", "0.6250338", "0.624...
0.0
-1
Transmits any events that the client might not know about.
def sync_events events = @last_event_id ? @room.events_after(@last_event_id) : @room.recent_events(512) return if events.empty? respond_recent_events events end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def send_events; end", "def send_event( data )\n\t\tuntil data.empty?\n\t\t\tbytes = self.socket.sendmsg_nonblock( data, 0, exception: false )\n\n\t\t\tif bytes == :wait_writable\n\t\t\t\tIO.select( nil, [self.socket], nil )\n\t\t\telse\n\t\t\t\tself.log.debug \"Sent: %p\" % [ data[0, bytes] ]\n\t\t\t\tdata[ 0, ...
[ "0.6488268", "0.610779", "0.5970181", "0.585048", "0.5742572", "0.5709255", "0.56956774", "0.5609447", "0.55905026", "0.556543", "0.55187356", "0.54473746", "0.5432325", "0.5431326", "0.54287076", "0.5398758", "0.5393626", "0.5393184", "0.5379811", "0.5358168", "0.5323853", ...
0.5081216
39
Returns the latest events to the client. Args: events:: an array of events; the code assumes these are the most recent events in the session's room
def respond_recent_events(events) return if events.empty? last_id = events.last[:id] respond :last_event_id => last_id, :events => events @last_event_id = last_id end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sync_events\n events = @last_event_id ? @room.events_after(@last_event_id) :\n @room.recent_events(512)\n return if events.empty?\n respond_recent_events events\n end", "def fetch_events\n params = {'calendarId' => CONFIG[:cal_id], \n 'orderBy' => 'start...
[ "0.6532706", "0.65177745", "0.64196754", "0.64079034", "0.63905776", "0.6302563", "0.6290795", "0.6264137", "0.62243485", "0.6203742", "0.61614037", "0.6101372", "0.606116", "0.60109454", "0.6009058", "0.59525794", "0.5936088", "0.5912409", "0.5903249", "0.588616", "0.5871029...
0.64814234
2
Returns data to the client.
def respond(data) @ws.send JSON.unparse(data) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def data\n retrieve_data\n end", "def request_data\n @data.to_json\n end", "def call\n data\n end", "def data\r\n @data\r\n end", "def get_data\n response = proxy.get_data(handle)\n self.update_properties(response)\n self.pa...
[ "0.7244225", "0.69633126", "0.6941225", "0.6868205", "0.6835422", "0.67675036", "0.67142296", "0.67142296", "0.67142296", "0.66895443", "0.666878", "0.666878", "0.666878", "0.6593646", "0.6572515", "0.6437289", "0.64297575", "0.6424078", "0.6397313", "0.6329542", "0.63047373"...
0.0
-1
CREATE TALLY METHOD TO KEEP TRACK TO TOTALS a hand would currently look like this: [["3", "Diamonds"], ["5", "Clubs"], ["3", "Hearts"], ["J", "Spades"], ["2", "Hearts"]]
def tally(hand) arr = hand.map{|e| e[0]} #gets the second element of the nested array (cos arrays are zero indexed) running_total = 0 #initialise this at the beginning & then iterate through each value to get the total from our new hand_total array arr.each do |value| if value == 'A' running_total += 11 elsif value == 'J' || value == 'Q' || value == 'K' #could also say value.to_i ==0 because it would fail and return a 0 running_total += 10 else running_total += value.to_i end end # correct for Aces arr.select{|e| e == "A"}.count.times do running_total -= 10 if running_total > 21 end running_total end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "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...
[ "0.65477335", "0.64149565", "0.63654476", "0.627301", "0.62686116", "0.6237541", "0.62072265", "0.61817276", "0.61564887", "0.61469185", "0.6100209", "0.6097997", "0.609409", "0.6091887", "0.60677624", "0.60031635", "0.59898496", "0.59854573", "0.59734213", "0.59586465", "0.5...
0.65437436
1
A B B C D update of tags is tricky in that it can produce three groups of changes: 1. tags being removed (exist on record, but not in params) 2. tags unchanged (exist both on record and in params) 3. tags being added (do not exiust on record but are passed in params)
def update_tags! return unless @params.key?(:tags) tags_to_remove.each do |tag_title| TaskTag.where(task: task).joins(:tag).merge(Tag.where(title: tag_title)).destroy_all end tags_to_add.each do |tag_title| TaskTag.where(task: task, tag: tag_from_title(tag_title)).first_or_create! end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n\n old_tags = @event.tags.pluck(:tag)\n new_tags = params[:tags].split(',')\n\n #logger.debug old_tags\n #logger.debug new_tags\n #logger.debug (old_tags - new_tags)\n #logger.debug (new_tags - old_tags)\n\n (old_tags - new_tags).each do |stag|\n @event.tags.where(tag: stag).f...
[ "0.70100665", "0.67962426", "0.67500234", "0.67500234", "0.67167956", "0.66967404", "0.66706336", "0.6635702", "0.6629786", "0.66270185", "0.65346444", "0.65046", "0.6500159", "0.6496419", "0.64748824", "0.64666843", "0.6454377", "0.64531195", "0.6418324", "0.6418135", "0.641...
0.75297046
0
POST /messages POST /messages.json
def create MailerWorker.perform_async(message_params) flash[:notice] = "Message sent! Thank you for contacting us." redirect_to root_url end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def post(content)\n post_to(\"/api/v1/messages/\", {:body => content})\n end", "def create\n message = Message.new(message_params)\n message.message = params[:message_text]\n message.display_name = params[:display_name]\n message.save!\n render json: message\n end", "def create\n @messag...
[ "0.7465386", "0.71694404", "0.7112854", "0.7095524", "0.70685273", "0.70200527", "0.69382447", "0.6844289", "0.683413", "0.683015", "0.68281627", "0.68281627", "0.6783851", "0.6763146", "0.67002374", "0.6698929", "0.66701055", "0.66322166", "0.66246116", "0.6623654", "0.66130...
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def message_params params.require(:message).permit(:name, :email, :message) 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.6981537", "0.67835593", "0.6748275", "0.67436063", "0.6736311", "0.65937173", "0.6503359", "0.6498499", "0.6482832", "0.6478776", "0.645703", "0.6439998", "0.63802195", "0.6377008", "0.6366287", "0.632018", "0.63016284", "0.63011277", "0.62932974", "0.62919617", "0.6290564...
0.0
-1
The model's fullyqualified and quoted primary key.
def primary_key "#{quoted_table_name}.#{model_class.send :primary_key}" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def primary_key\n '_id'\n end", "def full_primary_key(klass)\n \"#{klass.quoted_table_name}.#{klass.quoted_primary_key}\"\n end", "def primary_key\n 'id'\n end", "def primary_key\n @primary_key ||= @klass.primary_key.to_s\n end", "def quoted_primary_key\n ...
[ "0.7934944", "0.7922524", "0.7919046", "0.7885284", "0.7765311", "0.7662968", "0.76024866", "0.75943035", "0.75943035", "0.75943035", "0.7562853", "0.75185937", "0.7502828", "0.74844855", "0.744577", "0.74371296", "0.73982894", "0.73734903", "0.73720175", "0.73550135", "0.733...
0.8766146
1
Was the record found using its numeric id?
def found_using_numeric_id? warn("found_using_numeric_id is deprecated and will be removed in 3.0. Please use #friendly_id_status.numeric?") friendly_id_status.numeric? end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def exists?\n return id.to_s =~ /\\d+/\n end", "def identified_by?( id )\n\t\t\tself.rpx_identifiers.find_by_identifier( id )\n\t\tend", "def identified_by?( id )\n\t\t\tself.rpx_identifier == id\n\t\tend", "def id ; @record.id if @record ; end", "def found?\n return false if no_search\n\n id...
[ "0.69426155", "0.6898101", "0.6883071", "0.68743175", "0.6844176", "0.6688446", "0.66270024", "0.66270024", "0.64962536", "0.64956", "0.6492035", "0.6487673", "0.6454233", "0.64452815", "0.6439379", "0.6438676", "0.6409589", "0.6340384", "0.63345164", "0.63328314", "0.6317044...
0.0
-1
Was the record found using an old friendly id, or its numeric id?
def has_better_id? warn("has_better_id? is deprecated and will be removed in 3.0. Please use !#friendly_id_status.best?") ! friendly_id_status.best? end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def found_using_numeric_id?\n !found_using_friendly_id?\n end", "def has_better_id?\n slug and found_using_numeric_id? || found_using_outdated_friendly_id?\n end", "def found_using_outdated_friendly_id?\n finder_slug.id != slug.id\n end", "def acceptable_id?\n id = extracted_id\n ...
[ "0.7403386", "0.7355705", "0.6893606", "0.6605531", "0.6499431", "0.63510394", "0.6240523", "0.61992705", "0.61342454", "0.6091137", "0.6073619", "0.60348225", "0.6003004", "0.5996063", "0.5980389", "0.5980389", "0.5980389", "0.5980389", "0.5980389", "0.5940632", "0.5935978",...
0.6194821
8
Returns the friendly id, or if none is available, the numeric id.
def to_param (friendly_id || id).to_s end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def real_id(model_name, friendly_id)\n if friendly_id.to_s.to_i == 0\n obj = model_name.constantize.find(friendly_id)\n if obj\n return obj.id\n end\n end\n friendly_id\n end", "def actual_id\n args = params[:id].split('-')\n args[0]\n end", "def id\n raise MissingID...
[ "0.7531354", "0.6799069", "0.67762977", "0.67061", "0.6572775", "0.6477305", "0.64661443", "0.64659625", "0.64579844", "0.645301", "0.645075", "0.6433104", "0.642394", "0.6412915", "0.6345919", "0.6344134", "0.6338794", "0.63315356", "0.63122684", "0.6308682", "0.6297837", ...
0.65042126
8
The old and new values for the friendly_id column.
def friendly_id_changes changes[friendly_id_config.column.to_s] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def friendly_id; end", "def oldid(value)\n merge(oldid: value.to_s)\n end", "def oldid(value)\n merge(oldid: value.to_s)\n end", "def history_update\n return if !saved_changes?\n\n # return if it's no update\n return if new_record?\n\n # new record also triggers update, so...
[ "0.574171", "0.5280585", "0.5280585", "0.5245634", "0.5233118", "0.5188976", "0.51878655", "0.51878655", "0.51878655", "0.51878655", "0.51878655", "0.5180392", "0.5126743", "0.51084876", "0.51058644", "0.50968534", "0.5092864", "0.50747055", "0.50657624", "0.50622606", "0.505...
0.7785411
1
Update the slugs for any model that is using this model as its FriendlyId scope.
def update_scopes if changes = friendly_id_changes friendly_id_config.child_scopes.each do |klass| Slug.update_all "scope = '#{changes[1]}'", ["sluggable_type = ? AND scope = ?", klass.to_s, changes[0]] end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_scopes\n if @old_friendly_id != friendly_id\n friendly_id_config.child_scopes.each do |klass|\n Slug.all(:sluggable_type => klass, :scope => @old_friendly_id).update(:scope => friendly_id)\n end\n end\n end", "def update_dependent_scopes\n if slug...
[ "0.7132532", "0.6879803", "0.6831018", "0.67264354", "0.6510821", "0.6416128", "0.6412397", "0.63590467", "0.62244314", "0.61868393", "0.61790764", "0.6104081", "0.6065063", "0.60566974", "0.6016339", "0.60075444", "0.60000193", "0.59657824", "0.59601057", "0.5959993", "0.586...
0.66404086
5
set the choosen number into the board
def set(num) player_id = @players[@turn % 2].id @board[num - 1] = @player_char[player_id] @turn += 1 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_player(input, player_num)\n board[input.to_i] = player_num\n end", "def set_board(board)\n @board = board\n end", "def set\n\t$one = \"1\"\n\t$two = \"2\"\n\t$three = \"3\"\n\t$four = \"4\"\n\t$five = \"5\"\n\t$six = \"6\"\n\t$seven = \"7\"\n\t$eight = \"8\"\n\t$nine = \"9\"\n\t$turn = 0\t\t\ne...
[ "0.72061247", "0.6614173", "0.6608064", "0.65731436", "0.6559795", "0.65297574", "0.64886427", "0.6485483", "0.64492375", "0.6421589", "0.64139074", "0.63991094", "0.63991094", "0.6387553", "0.63794553", "0.6378448", "0.6338022", "0.633373", "0.633373", "0.633373", "0.633373"...
0.7860766
0
String (the op to perform) outputs: Integer (the result of the op) reqs: implement a stack using push and pop methods use a 'register' to rep the current value for a given op, pop most recently pushed value from the stack, perform the op on that and the the register value, and store the result in the register all ops are integer based take a str as an arg (spec'ing the operands and the ops to perform) init the reg to 0 rules: none struct: arr (to hold list of cmds) algo: init a reg (int) to 0 init a stack (array) of ints to [] split the cmd str into an arr of cmds for each cmd perform the spec'd op n Place a value n in the "register". Do not modify the stack. PUSH Push the register value on to the stack. Leave the value in the register. ADD Pops a value from the stack and adds it to the register value, storing the result in the register. SUB Pops a value from the stack and subtracts it from the register value, storing the result in the register. MULT Pops a value from the stack and multiplies it by the register value, storing the result in the register. DIV Pops a value from the stack and divides it into the register value, storing the integer result in the register. MOD Pops a value from the stack and divides it into the register value, storing the integer remainder of the division in the register. POP Remove the topmost item from the stack and place in register PRINT Print the register value
def minilang(str) stack = [] reg = 0 # puts str cmds = str.split cmds.each do |cmd| # puts "cmd == #{cmd}" case cmd when 'PUSH' then stack << reg when 'ADD' then reg += stack.pop when 'SUB' then reg -= stack.pop when 'MULT' then reg *= stack.pop when 'DIV' then reg /= stack.pop when 'MOD' then reg %= stack.pop when 'POP' then reg = stack.pop when 'PRINT' then puts reg else reg = cmd.to_i # integer end end puts end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def arithmeticBinary(op)\n str = getTopTwoFromStack + \"M=M\"+op+\"D\"+\"\\n\"\n return str+\"\\n\"\nend", "def stackEval(cmdStack, resStack, memState)\n # cmdStack => the command stack implemented using a list\n # resStack => the results stack implemented using a list\n # memState => the ...
[ "0.7446514", "0.73305297", "0.7299608", "0.726271", "0.6940428", "0.6920647", "0.6903639", "0.68655574", "0.6813391", "0.678495", "0.67690766", "0.67650366", "0.6762735", "0.6728278", "0.67157835", "0.6658182", "0.6614905", "0.6611889", "0.66066694", "0.6606039", "0.6602687",...
0.7063701
4
reset the raw parameters for each filter received by the form
def reset_filter_params params[:search] = nil params[:status] = nil params[:unassigned] = nil params[:assigned_to_me] = nil params[:needs_attention] = nil params[:year] = nil end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def reset_params\n @params = {}\n end", "def reset\n @params = {}\n @query_filters = []\n @uri = ''\n self\n end", "def reset\n super\n @params.values.uniq.each do |param|\n param.send(:reset) if param.is_a? Parameter\n end\n end", "def rese...
[ "0.7312239", "0.72822034", "0.72426456", "0.7208308", "0.7156524", "0.7128091", "0.7106637", "0.7101697", "0.7072232", "0.69068617", "0.6905468", "0.6870684", "0.67339295", "0.67339295", "0.66478246", "0.66478246", "0.66198885", "0.6570264", "0.6553955", "0.65506566", "0.6509...
0.79791284
0
create date object with the given integer loop 365 times if date is a friday, and date is the 13th of the month add 1 to unlucky_days variable
def friday_13th(year) date = Date.new(year) unlucky_days = 0 365.times do date = date + 1 if date.friday? == true && date.mday == 13 unlucky_days += 1 end end unlucky_days end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def make_days\n month = (1..@day_num).collect do |day|\n Day.new(Date.parse(\"#{@year}-#{@month}-#{day}\"))\n end\n\n month[0].date.wday.times { month.insert(0, Day.new(Date.new))}\n month\n end", "def unlucky_days(year)\r\n (1..12).count { |month| Time.new(year, month, 13).frida...
[ "0.66368306", "0.6629865", "0.6624537", "0.6605464", "0.65711623", "0.6459968", "0.63914263", "0.63739103", "0.6373012", "0.6337704", "0.63307947", "0.61945593", "0.617135", "0.61478686", "0.61069566", "0.61055416", "0.6056321", "0.6031889", "0.60201555", "0.600777", "0.60051...
0.7075502
0
Context Tools Used to call pdb functions which change or retrieve information about context features within gimp Flushes displays so that the images displayed in windows are up to date
def context_update_displays!() $gimp_iface.gimp_displays_flush() end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def features\n features = {}\n sexp_newtype_block.each do |s|\n if s[0] == :command and\n s[1][0..1] == [:@ident, \"feature\"] and\n s[2][0] == :args_add_block\n\n name = s[2][1][0][1][1][1]\n desc = s[2][1][1][1][1][1]\n\n features[name] = desc\n end\n end\n...
[ "0.58085936", "0.5470395", "0.54541117", "0.5428322", "0.5416372", "0.53946114", "0.5382076", "0.53657544", "0.53657544", "0.53657544", "0.53657544", "0.53657544", "0.53657544", "0.53657544", "0.53657544", "0.53657544", "0.53657544", "0.53657544", "0.53657544", "0.53657544", ...
0.64635056
0
context_get_bgcolor: retrieves the current background color. This returns an integer, not an object
def context_get_bgcolor() return $gimp_iface.gimp_context_get_background()[0] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def background_color\n return @background_color\n end", "def bgcolor\n @bgcolor || $def_bg_color\n end", "def bgColor\n return @bg_color\n end", "def background_colour\n @cr[0xf] >> 4\n end", "def background_color\n return @peer.background_color\n end", "...
[ "0.75258", "0.74347776", "0.741705", "0.7208971", "0.7142372", "0.696189", "0.6879816", "0.6850754", "0.6720105", "0.6720105", "0.6632355", "0.6425548", "0.64068097", "0.6327581", "0.6295605", "0.62035584", "0.6187676", "0.6130814", "0.61186284", "0.60704035", "0.5986553", ...
0.78690106
0