_id stringlengths 2 6 | title stringlengths 9 130 | partition stringclasses 3
values | text stringlengths 30 4.3k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q16200 | Azure::ARM.VnetConfig.divide_network | train | def divide_network(address_prefix)
network_address = IPAddress(address_prefix)
prefix = nil
case network_address.count
when 4097..65536
prefix = "20"
when 256..4096
prefix = "24"
end
## if the given | ruby | {
"resource": ""
} |
q16201 | Azure::ARM.VnetConfig.new_subnet_address_prefix | train | def new_subnet_address_prefix(vnet_address_prefix, subnets)
if subnets.empty? ## no subnets exist in the given address space of the virtual network, so divide the network into smaller subnets (based on the network size) and allocate space for the new subnet to be added ##
divide_network(vnet_address_prefi... | ruby | {
"resource": ""
} |
q16202 | Azure::ARM.VnetConfig.add_subnet | train | def add_subnet(subnet_name, vnet_config, subnets)
new_subnet_prefix = nil
vnet_address_prefix_count = 0
vnet_address_space = vnet_config[:addressPrefixes]
## search for space in all the address prefixes of the virtual network ##
while new_subnet_prefix.nil? && vnet_address_space.length > ... | ruby | {
"resource": ""
} |
q16203 | Azure::ARM.VnetConfig.create_vnet_config | train | def create_vnet_config(resource_group_name, vnet_name, vnet_subnet_name)
raise ArgumentError, "GatewaySubnet cannot be used as the name for --azure-vnet-subnet-name option. GatewaySubnet can only be used for virtual network gateways." if vnet_subnet_name == "GatewaySubnet"
vnet_config = {}
subnets = ... | ruby | {
"resource": ""
} |
q16204 | Azure.Hosts.fetch_from_cloud | train | def fetch_from_cloud(name)
ret_val = @connection.query_azure("hostedservices/#{name}")
error_code, error_message = error_from_response_xml(ret_val) if ret_val
if ret_val.nil? || error_code.length > 0
| ruby | {
"resource": ""
} |
q16205 | PublicSuffix.List.each | train | def each(&block)
Enumerator.new do |y|
@rules.each do | ruby | {
"resource": ""
} |
q16206 | PublicSuffix.List.find | train | def find(name, default: default_rule, **options)
rule = select(name, **options).inject do |l, r|
return r if r.class == Rule::Exception
| ruby | {
"resource": ""
} |
q16207 | PublicSuffix.List.select | train | def select(name, ignore_private: false)
name = name.to_s
parts = name.split(DOT).reverse!
index = 0
query = parts[index]
rules = []
loop do
match = @rules[query]
rules << entry_to_rule(match, | ruby | {
"resource": ""
} |
q16208 | Minicron.Monitor.start! | train | def start!
# Activate the monitor
@active = true
# Connect to the database
Minicron.establish_db_connection(
Minicron.config['server']['database'],
Minicron.config['verbose']
)
# Set the start time of the monitir
@start_time = Time.now.utc
# Start a thr... | ruby | {
"resource": ""
} |
q16209 | Minicron.Monitor.monitor | train | def monitor(schedule)
# Parse the cron expression
cron = CronParser.new(schedule.formatted)
# Find the time the cron was last expected to run with a 30 second pre buffer
# and a 30 second post buffer (in addition to the 60 already in place) incase
# jobs run early/late to allow for clock ... | ruby | {
"resource": ""
} |
q16210 | Minicron.Cron.build_crontab | train | def build_crontab(host)
# You have been warned..
crontab = "#\n"
crontab += "# This file was automatically generated by minicron at #{Time.now.utc}, DO NOT EDIT manually!\n"
crontab += "#\n\n"
# Set the path to something sensible by default, eventually this should be configurable
cr... | ruby | {
"resource": ""
} |
q16211 | MetaInspector.URL.with_default_scheme | train | def with_default_scheme(url)
parsed(url) && parsed(url).scheme.nil? | ruby | {
"resource": ""
} |
q16212 | MetaInspector.URL.normalized | train | def normalized(url)
Addressable::URI.parse(url).normalize.to_s
rescue Addressable::URI::InvalidURIError => e
| ruby | {
"resource": ""
} |
q16213 | MetaInspector.Document.to_hash | train | def to_hash
{
'url' => url,
'scheme' => scheme,
'host' => host,
'root_url' => root_url,
'title' => title,
'best_title' => best_title,
'author' => author,
'best_author' => best... | ruby | {
"resource": ""
} |
q16214 | GLI.Command.has_option? | train | def has_option?(option) #:nodoc:
option = option.gsub(/^\-+/,'')
((flags.values.map { | ruby | {
"resource": ""
} |
q16215 | GLI.Command.name_for_help | train | def name_for_help
name_array = [name.to_s]
command_parent = parent
while(command_parent.is_a?(GLI::Command)) do
| ruby | {
"resource": ""
} |
q16216 | GLI.App.commands_from | train | def commands_from(path)
if Pathname.new(path).absolute? and File.exist?(path)
load_commands(path)
else
$LOAD_PATH.each do |load_path|
| ruby | {
"resource": ""
} |
q16217 | GLI.App.config_file | train | def config_file(filename)
if filename =~ /^\//
@config_file = filename
else
@config_file = File.join(File.expand_path(ENV['HOME']),filename)
| ruby | {
"resource": ""
} |
q16218 | GLI.AppSupport.reset | train | def reset # :nodoc:
switches.clear
flags.clear
@commands = nil
@commands_declaration_order = []
@flags_declaration_order = []
@switches_declaration_order = []
@version = nil
@config_file = nil
@use_openstruct = false
@prog_desc = nil
@error_block = false... | ruby | {
"resource": ""
} |
q16219 | GLI.AppSupport.run | train | def run(args) #:nodoc:
args = args.dup if @preserve_argv
the_command = nil
begin
override_defaults_based_on_config(parse_config)
add_help_switch_if_needed(self)
gli_option_parser = GLIOptionParser.new(commands,
flags,
... | ruby | {
"resource": ""
} |
q16220 | GLI.AppSupport.override_defaults_based_on_config | train | def override_defaults_based_on_config(config)
override_default(flags,config)
override_default(switches,config)
| ruby | {
"resource": ""
} |
q16221 | GLI.AppSupport.proceed? | train | def proceed?(parsing_result) #:nodoc:
if parsing_result.command && parsing_result.command.skips_pre
| ruby | {
"resource": ""
} |
q16222 | GLI.AppSupport.regular_error_handling? | train | def regular_error_handling?(ex) #:nodoc:
if @error_block
return true if (ex.respond_to?(:exit_code) && ex.exit_code == 0)
| ruby | {
"resource": ""
} |
q16223 | GLI.DSL.flag | train | def flag(*names)
options = extract_options(names)
names = [names].flatten
verify_unused(names)
| ruby | {
"resource": ""
} |
q16224 | GLI.DSL.verify_unused | train | def verify_unused(names) # :nodoc:
names.each do |name|
verify_unused_in_option(name,flags,"flag") | ruby | {
"resource": ""
} |
q16225 | GLI.GLIOptionParser.parse_options | train | def parse_options(args) # :nodoc:
option_parser_class = self.class.const_get("#{options[:subcommand_option_handling_strategy].to_s.capitalize}CommandOptionParser")
OptionParsingResult.new.tap { |parsing_result|
parsing_result.arguments = args
| ruby | {
"resource": ""
} |
q16226 | GLI.GLIOptionBlockParser.parse! | train | def parse!(args)
do_parse(args)
rescue OptionParser::InvalidOption => ex
@exception_handler.call("Unknown option #{ex.args.join(' ')}",@extra_error_context)
rescue OptionParser::InvalidArgument => | ruby | {
"resource": ""
} |
q16227 | GLI.CommandLineToken.parse_names | train | def parse_names(names)
# Allow strings; convert to symbols
names = [names].flatten.map { |name| name.to_sym }
names_hash = {}
names.each do |name|
raise ArgumentError.new("#{name} has spaces; they are not allowed") if name.to_s =~ /\s/
| ruby | {
"resource": ""
} |
q16228 | GLI.Flag.all_forms | train | def all_forms(joiner=', ')
forms = all_forms_a
string = forms.join(joiner)
if forms[-1] =~ /^\-\-/
string += '='
| ruby | {
"resource": ""
} |
q16229 | Hamlbars.Template.evaluate | train | def evaluate(scope, locals, &block)
if @engine.respond_to?(:precompiled_method_return_value, true)
super(scope, locals, &block)
| ruby | {
"resource": ""
} |
q16230 | Webshot.Screenshot.capture | train | def capture(url, path, opts = {})
begin
# Default settings
width = opts.fetch(:width, 120)
height = opts.fetch(:height, 90)
gravity = opts.fetch(:gravity, "north")
quality = opts.fetch(:quality, 85)
full = opts.fetch(:full, true)
selector = opts.fetch(:se... | ruby | {
"resource": ""
} |
q16231 | ActiveStorageDragAndDrop.FormBuilder.drag_and_drop_file_field | train | def drag_and_drop_file_field(method, content_or_options = nil, options = {}, &block)
if block_given?
options = content_or_options if content_or_options.is_a? Hash
| ruby | {
"resource": ""
} |
q16232 | ActiveStorageDragAndDrop.FormBuilder.unpersisted_attachment_fields | train | def unpersisted_attachment_fields(method, multiple)
unpersisted_attachments(method).map.with_index do |attachment, idx|
hidden_field method,
mutiple: multiple ? :multiple : false, value: attachment.signed_id,
name: "#{object_name}[#{method}]#{'[]' if multiple}",
... | ruby | {
"resource": ""
} |
q16233 | ActiveStorageDragAndDrop.FormBuilder.default_file_field_options | train | def default_file_field_options(method)
{
multiple: @object.send(method).is_a?(ActiveStorage::Attached::Many),
direct_upload: true,
style: 'display:none;',
data: {
dnd: true,
| ruby | {
"resource": ""
} |
q16234 | ActiveStorageDragAndDrop.FormBuilder.file_field_options | train | def file_field_options(method, custom_options)
default_file_field_options(method).merge(custom_options) do |_key, default, custom|
| ruby | {
"resource": ""
} |
q16235 | StateMachines.State.value | train | def value(eval = true)
if @value.is_a?(Proc) && eval
if cache_value?
@value = @value.call
| ruby | {
"resource": ""
} |
q16236 | StateMachines.State.context_methods | train | def context_methods
@context.instance_methods.inject({}) do |methods, name|
| ruby | {
"resource": ""
} |
q16237 | StateMachines.State.call | train | def call(object, method, *args, &block)
options = args.last.is_a?(Hash) ? args.pop : {}
options = {:method_name => method}.merge(options)
state = machine.states.match!(object)
if state == self && object.respond_to?(method)
object.send(method, *args, &block)
elsif method_missing = ... | ruby | {
"resource": ""
} |
q16238 | StateMachines.State.add_predicate | train | def add_predicate
# Checks whether the current value matches this state
machine.define_helper(:instance, | ruby | {
"resource": ""
} |
q16239 | StateMachines.Machine.initial_state= | train | def initial_state=(new_initial_state)
@initial_state = new_initial_state
add_states([@initial_state]) unless dynamic_initial_state?
# Update all states to reflect the new initial state
states.each { |state| state.initial = (state.name == @initial_state) }
# Output a warning if there are ... | ruby | {
"resource": ""
} |
q16240 | StateMachines.Machine.initialize_state | train | def initialize_state(object, options = {})
state = initial_state(object)
if state && (options[:force] || initialize_state?(object))
| ruby | {
"resource": ""
} |
q16241 | StateMachines.Machine.define_helper | train | def define_helper(scope, method, *args, &block)
helper_module = @helper_modules.fetch(scope)
if block_given?
if !self.class.ignore_method_conflicts && conflicting_ancestor = owner_class_ancestor_has_method?(scope, method)
ancestor_name = conflicting_ancestor.name && !conflicting_ancestor.... | ruby | {
"resource": ""
} |
q16242 | StateMachines.Machine.state | train | def state(*names, &block)
options = names.last.is_a?(Hash) ? names.pop : {}
options.assert_valid_keys(:value, :cache, :if, :human_name)
# Store the context so that it can be used for / matched against any state
# that gets added
@states.context(names, &block) if block_given?
if nam... | ruby | {
"resource": ""
} |
q16243 | StateMachines.Machine.read | train | def read(object, attribute, ivar = false)
attribute = self.attribute(attribute)
if ivar
object.instance_variable_defined?("@#{attribute}") | ruby | {
"resource": ""
} |
q16244 | StateMachines.Machine.write | train | def write(object, attribute, value, ivar = false)
attribute = self.attribute(attribute) | ruby | {
"resource": ""
} |
q16245 | StateMachines.Machine.event | train | def event(*names, &block)
options = names.last.is_a?(Hash) ? names.pop : {}
options.assert_valid_keys(:human_name)
# Store the context so that it can be used for / matched against any event
# that gets added
@events.context(names, &block) if block_given?
if names.first.is_a?(Matche... | ruby | {
"resource": ""
} |
q16246 | StateMachines.Machine.transition | train | def transition(options)
raise ArgumentError, 'Must specify :on event' unless options[:on]
branches = []
options = options.dup
event(*Array(options.delete(:on))) { branches | ruby | {
"resource": ""
} |
q16247 | StateMachines.Machine.generate_message | train | def generate_message(name, values = [])
message = (@messages[name] || self.class.default_messages[name])
# Check whether there are actually any values to interpolate to avoid
# any warnings
| ruby | {
"resource": ""
} |
q16248 | StateMachines.Machine.action_hook? | train | def action_hook?(self_only = false)
@action_hook_defined || !self_only && owner_class.state_machines.any? { |name, machine| machine.action | ruby | {
"resource": ""
} |
q16249 | StateMachines.Machine.sibling_machines | train | def sibling_machines
owner_class.state_machines.inject([]) do |machines, (name, machine)|
if machine.attribute == attribute && machine != self
machines | ruby | {
"resource": ""
} |
q16250 | StateMachines.Machine.initialize_state? | train | def initialize_state?(object)
value = read(object, :state)
| ruby | {
"resource": ""
} |
q16251 | StateMachines.Machine.define_path_helpers | train | def define_path_helpers
# Gets the paths of transitions available to the current object
define_helper(:instance, attribute(:paths)) do | ruby | {
"resource": ""
} |
q16252 | StateMachines.Machine.define_action_helpers? | train | def define_action_helpers?
action && !owner_class.state_machines.any? | ruby | {
"resource": ""
} |
q16253 | StateMachines.Machine.owner_class_ancestor_has_method? | train | def owner_class_ancestor_has_method?(scope, method)
return false unless owner_class_has_method?(scope, method)
superclasses = owner_class.ancestors.select { |ancestor| ancestor.is_a?(Class) }[1..-1]
if scope == :class
current = owner_class.singleton_class
superclass = superclasses.fi... | ruby | {
"resource": ""
} |
q16254 | StateMachines.Machine.define_name_helpers | train | def define_name_helpers
# Gets the humanized version of a state
define_helper(:class, "human_#{attribute(:name)}") do |machine, klass, state|
machine.states.fetch(state).human_name(klass)
end
# Gets the humanized version of an event
define_helper(:class, "human_#{attribute(:event_... | ruby | {
"resource": ""
} |
q16255 | StateMachines.Machine.run_scope | train | def run_scope(scope, machine, klass, states)
values = states.flatten.map { |state| | ruby | {
"resource": ""
} |
q16256 | StateMachines.Machine.add_sibling_machine_configs | train | def add_sibling_machine_configs
# Add existing states
sibling_machines.each do |machine|
| ruby | {
"resource": ""
} |
q16257 | StateMachines.Machine.add_callback | train | def add_callback(type, options, &block)
callbacks[type == :around ? :before : type] << callback = Callback.new(type, options, &block)
| ruby | {
"resource": ""
} |
q16258 | StateMachines.Machine.add_states | train | def add_states(new_states)
new_states.map do |new_state|
# Check for other states that use a different class type for their name.
# This typically prevents string / symbol misuse.
if new_state && conflict = states.detect { |state| state.name && state.name.class != new_state.class }
... | ruby | {
"resource": ""
} |
q16259 | StateMachines.Machine.add_events | train | def add_events(new_events)
new_events.map do |new_event|
# Check for other states that use a different class type for their name.
# This typically prevents string / symbol misuse.
if conflict = events.detect { |event| event.name.class != new_event.class }
raise ArgumentError, "#{... | ruby | {
"resource": ""
} |
q16260 | StateMachines.StateCollection.match | train | def match(object)
value = machine.read(object, :state)
self[value, :value] || | ruby | {
"resource": ""
} |
q16261 | StateMachines.Branch.build_matcher | train | def build_matcher(options, whitelist_option, blacklist_option)
options.assert_exclusive_keys(whitelist_option, blacklist_option)
if options.include?(whitelist_option)
value = options[whitelist_option]
value.is_a?(Matcher) ? value : WhitelistMatcher.new(options[whitelist_opti... | ruby | {
"resource": ""
} |
q16262 | StateMachines.Branch.match_states | train | def match_states(query)
state_requirements.detect do |state_requirement|
| ruby | {
"resource": ""
} |
q16263 | StateMachines.Branch.matches_requirement? | train | def matches_requirement?(query, option, requirement)
| ruby | {
"resource": ""
} |
q16264 | StateMachines.Branch.matches_conditions? | train | def matches_conditions?(object, query)
query[:guard] == false ||
Array(if_condition).all? {|condition| evaluate_method(object, condition)} &&
| ruby | {
"resource": ""
} |
q16265 | StateMachines.PathCollection.initial_paths | train | def initial_paths
machine.events.transitions_for(object, :from => from_name, :guard => @guard).map do |transition|
path = Path.new(object, machine, :target => to_name, | ruby | {
"resource": ""
} |
q16266 | StateMachines.PathCollection.walk | train | def walk(path)
self << path if path.complete?
| ruby | {
"resource": ""
} |
q16267 | StateMachines.Path.recently_walked? | train | def recently_walked?(transition)
transitions = self
if @target && @target != to_name && target_transition = detect {|t| t.to_name == @target}
transitions = | ruby | {
"resource": ""
} |
q16268 | StateMachines.Path.transitions | train | def transitions
@transitions ||= empty? ? [] : machine.events.transitions_for(object, :from => to_name, :guard | ruby | {
"resource": ""
} |
q16269 | StateMachines.StateContext.method_missing | train | def method_missing(*args, &block)
# Get the configuration
if args.last.is_a?(Hash)
options = args.last
else
args << options = {}
end
# Get any existing condition that may need to be merged
if_condition = options.delete(:if)
unless_condition = options.dele... | ruby | {
"resource": ""
} |
q16270 | StateMachines.EventCollection.valid_for | train | def valid_for(object, requirements = {})
match(requirements).select { |event| | ruby | {
"resource": ""
} |
q16271 | StateMachines.EventCollection.transitions_for | train | def transitions_for(object, requirements = {})
match(requirements).map { |event| | ruby | {
"resource": ""
} |
q16272 | StateMachines.EventCollection.attribute_transition_for | train | def attribute_transition_for(object, invalidate = false)
return unless machine.action
# TODO, simplify
machine.read(object, :event_transition) || if event_name = machine.read(object, :event)
if event = self[event_name.to_sym, :name]
... | ruby | {
"resource": ""
} |
q16273 | StateMachines.Event.transition_for | train | def transition_for(object, requirements = {})
requirements.assert_valid_keys(:from, :to, :guard)
requirements[:from] = machine.states.match!(object).name unless custom_from_state = requirements.include?(:from)
branches.each do |branch|
if match = branch.match(object, requirements)
#... | ruby | {
"resource": ""
} |
q16274 | StateMachines.Event.fire | train | def fire(object, *args)
machine.reset(object)
if transition = transition_for(object)
transition.perform(*args)
else
| ruby | {
"resource": ""
} |
q16275 | StateMachines.Event.on_failure | train | def on_failure(object, *args)
state = machine.states.match!(object)
machine.invalidate(object, :state, :invalid_transition, [[:event, human_name(object.class)], [:state, state.human_name(object.class)]])
| ruby | {
"resource": ""
} |
q16276 | StateMachines.Event.add_actions | train | def add_actions
# Checks whether the event can be fired on the current object
machine.define_helper(:instance, "can_#{qualified_name}?") do |machine, object, *args|
machine.event(name).can_fire?(object, *args)
end
# Gets the next transition that would be performed if the event were
... | ruby | {
"resource": ""
} |
q16277 | StateMachines.MachineCollection.transitions | train | def transitions(object, action, options = {})
transitions = map do |name, machine|
machine.events.attribute_transition_for(object, true) if machine.action == action
end
| ruby | {
"resource": ""
} |
q16278 | StateMachines.NodeCollection.<< | train | def <<(node)
@nodes << node
@index_names.each { |name| add_to_index(name, value(node, name), node) }
| ruby | {
"resource": ""
} |
q16279 | StateMachines.NodeCollection.update_index | train | def update_index(name, node)
index = self.index(name)
old_key = index.key(node)
new_key = value(node, name)
| ruby | {
"resource": ""
} |
q16280 | StateMachines.NodeCollection.eval_context | train | def eval_context(context, node)
node.context(&context[:block]) | ruby | {
"resource": ""
} |
q16281 | StateMachines.Transition.pause | train | def pause
raise ArgumentError, 'around_transition callbacks cannot be called in multiple execution contexts in java implementations of Ruby. Use before/after_transitions instead.' unless self.class.pause_supported? | ruby | {
"resource": ""
} |
q16282 | StateMachines.Transition.resume | train | def resume
if @paused_block
halted, error = callcc do |block|
@resume_block = block
@paused_block.call
end
@resume_block = @paused_block = | ruby | {
"resource": ""
} |
q16283 | StateMachines.Transition.before | train | def before(complete = true, index = 0, &block)
unless @before_run
while callback = machine.callbacks[:before][index]
index += 1
if callback.type == :around
# Around callback: need to handle recursively. Execution only gets
# paused if:
... | ruby | {
"resource": ""
} |
q16284 | StateMachines.Transition.after | train | def after
unless @after_run
# First resume previously paused callbacks
if resume
catch(:halt) do
type = @success ? :after : :failure
| ruby | {
"resource": ""
} |
q16285 | StateMachines.TransitionCollection.run_callbacks | train | def run_callbacks(index = 0, &block)
if transition = self[index]
throw :halt unless transition.run_callbacks(:after => !skip_after) do
| ruby | {
"resource": ""
} |
q16286 | StateMachines.TransitionCollection.run_actions | train | def run_actions
catch_exceptions do
@success = if block_given?
result = yield
actions.each {|action| results[action] = result}
!!result
else
| ruby | {
"resource": ""
} |
q16287 | StateMachines.AttributeTransitionCollection.rollback | train | def rollback
super
each {|transition| transition.machine.write(object, | ruby | {
"resource": ""
} |
q16288 | StateMachines.Callback.call | train | def call(object, context = {}, *args, &block)
if @branch.matches?(object, context)
| ruby | {
"resource": ""
} |
q16289 | Yajl.HttpStream.get | train | def get(uri, opts = {}, &block)
initialize_socket(uri, opts)
HttpStream::get(uri, opts, &block)
rescue IOError => | ruby | {
"resource": ""
} |
q16290 | Yajl.HttpStream.post | train | def post(uri, body, opts = {}, &block)
initialize_socket(uri, opts)
HttpStream::post(uri, body, opts, &block)
rescue | ruby | {
"resource": ""
} |
q16291 | Yajl.HttpStream.initialize_socket | train | def initialize_socket(uri, opts = {})
return if opts[:socket]
@socket = TCPSocket.new(uri.host, uri.port)
| ruby | {
"resource": ""
} |
q16292 | Xray.Middleware.append_js! | train | def append_js!(html, after_script_name, script_name)
html.sub!(script_matcher(after_script_name)) do
| ruby | {
"resource": ""
} |
q16293 | HasScope.ClassMethods.has_scope | train | def has_scope(*scopes, &block)
options = scopes.extract_options!
options.symbolize_keys!
options.assert_valid_keys(:type, :only, :except, :if, :unless, :default, :as, :using, :allow_blank, :in)
if options.key?(:in)
options[:as] = options[:in]
options[:using] = scopes
end
... | ruby | {
"resource": ""
} |
q16294 | Ox.Element.attr_match | train | def attr_match(cond)
cond.each_pair { |k,v| return false unless v == @attributes[k.to_sym] | ruby | {
"resource": ""
} |
q16295 | Ox.Element.each | train | def each(cond=nil)
if cond.nil?
nodes.each { |n| yield(n) }
else
cond = cond.to_s if cond.is_a?(Symbol)
if cond.is_a?(String)
nodes.each { |n| yield(n) if n.is_a?(Element) && cond | ruby | {
"resource": ""
} |
q16296 | Ox.Element.remove_children | train | def remove_children(*children)
return self if children.compact.empty?
| ruby | {
"resource": ""
} |
q16297 | Ox.Element.recursive_children_removal | train | def recursive_children_removal(found)
return if found.empty?
nodes.tap do |ns|
# found.delete(n.object_id) stops looking for an already found object_id
ns.delete_if { |n| found.include?(n.object_id) ? found.delete(n.object_id) : false } | ruby | {
"resource": ""
} |
q16298 | Xcake.Visitor.visit | train | def visit(item)
item_name = item_name(item)
method = "visit_#{item_name}"
| ruby | {
"resource": ""
} |
q16299 | Xcake.Visitor.leave | train | def leave(item)
item_name = item_name(item)
method = "leave_#{item_name}"
| ruby | {
"resource": ""
} |
Subsets and Splits
SQL Console for CoIR-Retrieval/CodeSearchNet-ccr-ruby-queries-corpus
Retrieves a large number of entries in the 'ruby' language, providing basic information but limited analytical value.