_id
stringlengths
2
6
title
stringlengths
9
130
partition
stringclasses
3 values
text
stringlengths
66
10.5k
language
stringclasses
1 value
meta_information
dict
q4400
TelestreamCloud::Tts.TtsApi.corpus
train
def corpus(project_id, name, opts = {}) data, _status_code, _headers = corpus_with_http_info(project_id, name, opts) return data end
ruby
{ "resource": "" }
q4401
TelestreamCloud::Tts.TtsApi.create_corpus
train
def create_corpus(project_id, name, body, opts = {}) create_corpus_with_http_info(project_id, name, body, opts) return nil end
ruby
{ "resource": "" }
q4402
TelestreamCloud::Tts.TtsApi.create_project
train
def create_project(project, opts = {}) data, _status_code, _headers = create_project_with_http_info(project, opts) return data end
ruby
{ "resource": "" }
q4403
TelestreamCloud::Tts.TtsApi.job
train
def job(project_id, job_id, opts = {}) data, _status_code, _headers = job_with_http_info(project_id, job_id, opts) return data end
ruby
{ "resource": "" }
q4404
TelestreamCloud::Tts.TtsApi.job_result
train
def job_result(project_id, job_id, opts = {}) data, _status_code, _headers = job_result_with_http_info(project_id, job_id, opts) return data end
ruby
{ "resource": "" }
q4405
TelestreamCloud::Tts.TtsApi.jobs
train
def jobs(project_id, opts = {}) data, _status_code, _headers = jobs_with_http_info(project_id, opts) return data end
ruby
{ "resource": "" }
q4406
TelestreamCloud::Tts.TtsApi.project
train
def project(project_id, opts = {}) data, _status_code, _headers = project_with_http_info(project_id, opts) return data end
ruby
{ "resource": "" }
q4407
TelestreamCloud::Tts.TtsApi.update_project
train
def update_project(project, opts = {}) data, _status_code, _headers = update_project_with_http_info(project, opts) return data end
ruby
{ "resource": "" }
q4408
TelestreamCloud::Tts.TtsApi.upload_video
train
def upload_video(project_id, video_upload_body, opts = {}) data, _status_code, _headers = upload_video_with_http_info(project_id, video_upload_body, opts) return data end
ruby
{ "resource": "" }
q4409
RailsTables::Searching.ClassMethods.search_on
train
def search_on(column_source, methods) Array(methods).each do |method_name| join column_source self.searches += [{column_source: column_source.to_s, method_name: method_name.to_s}] end end
ruby
{ "resource": "" }
q4410
NIFTI.NRead.read_image
train
def read_image raw_image = [] @stream.index = @hdr['vox_offset'] type = NIFTI_DATATYPES[@hdr['datatype']] format = @stream.format[type] @image_rubyarray = @stream.decode(@stream.rest_length, type) end
ruby
{ "resource": "" }
q4411
NIFTI.NRead.get_image_narray
train
def get_image_narray(image_array, dim) if Object.const_defined?('NArray') @image_narray = pixel_data = NArray.to_na(image_array).reshape!(*dim[1..dim[0]]) else add_msg "Can't find NArray, no image_narray created. Please `gem install narray`" end end
ruby
{ "resource": "" }
q4412
NIFTI.NRead.parse_header
train
def parse_header(options = {}) check_header @hdr = parse_basic_header @extended_header = parse_extended_header # Optional image gathering read_image if options[:image] get_image_narray(@image_rubyarray, @hdr['dim']) if options[:narray] @success = true end
ruby
{ "resource": "" }
q4413
NIFTI.NRead.parse_basic_header
train
def parse_basic_header # The HEADER_SIGNATURE is defined in NIFTI::Constants and used for both reading and writing. header = {} HEADER_SIGNATURE.each do |header_item| name, length, type = *header_item header[name] = @stream.decode(length, type) end # Extract Freq, Phase & ...
ruby
{ "resource": "" }
q4414
NIFTI.NRead.parse_extended_header
train
def parse_extended_header extended = [] extension = @stream.decode(4, "BY") # "After the end of the 348 byte header (e.g., after the magic field), # the next 4 bytes are an byte array field named extension. By default, # all 4 bytes of this array should be set to zero. In a .nii file, the...
ruby
{ "resource": "" }
q4415
NIFTI.NRead.open_file
train
def open_file(file) if File.exist?(file) if File.readable?(file) if not File.directory?(file) if File.size(file) > 8 begin @file = Zlib::GzipReader.new(File.new(file, "rb")) rescue Zlib::GzipFile::Error @file = File.new(file...
ruby
{ "resource": "" }
q4416
Qe.TextField.validation_class
train
def validation_class(answer_sheet) validation = '' validation += ' required' if self.required?(answer_sheet) # validate-number, etc. validate_style = ['number', 'currency-dollar', 'email', 'url', 'phone'].find {|v| v == self.style } if validate_style validation += ' validate-' + va...
ruby
{ "resource": "" }
q4417
NIFTI.NWrite.write
train
def write # Check if we are able to create given file: open_file(@file_name) # Go ahead and write if the file was opened successfully: if @file # Initiate necessary variables: init_variables @file_endian = false # Create a Stream instance to handle the encoding of...
ruby
{ "resource": "" }
q4418
NIFTI.NWrite.write_basic_header
train
def write_basic_header HEADER_SIGNATURE.each do |header_item| begin name, length, type = *header_item str = @stream.encode(@obj.header[name], type) padded_str = @stream.encode_string_to_length(str, length) # puts @stream.index, name, str.unpack(@stream.vr_to_str(typ...
ruby
{ "resource": "" }
q4419
NIFTI.NWrite.write_extended_header
train
def write_extended_header unless @obj.extended_header.empty? @stream.write @stream.encode([1,0,0,0], "BY") @obj.extended_header.each do |extension| @stream.write @stream.encode extension[:esize], "UL" @stream.write @stream.encode extension[:ecode], "UL" @stream.write @strea...
ruby
{ "resource": "" }
q4420
VCloudSdk.Powerable.power_on
train
def power_on target = entity_xml class_name = self.class.name.split("::").last Config.logger.debug "#{class_name} status: #{target[:status]}" if is_status?(target, :POWERED_ON) Config.logger.info "#{class_name} #{target.name} is already powered-on." return end power_...
ruby
{ "resource": "" }
q4421
VCloudSdk.Powerable.power_off
train
def power_off target = entity_xml class_name = self.class.name.split("::").last Config.logger.debug "#{class_name} status: #{target[:status]}" if is_status?(target, :SUSPENDED) error_msg = "#{class_name} #{target.name} suspended, discard state before powering off." fail class_nam...
ruby
{ "resource": "" }
q4422
TelestreamCloud::Flip.FlipApi.cancel_encoding
train
def cancel_encoding(id, factory_id, opts = {}) data, _status_code, _headers = cancel_encoding_with_http_info(id, factory_id, opts) return data end
ruby
{ "resource": "" }
q4423
TelestreamCloud::Flip.FlipApi.copy_profile
train
def copy_profile(id, factory_id, copy_profile_body, opts = {}) data, _status_code, _headers = copy_profile_with_http_info(id, factory_id, copy_profile_body, opts) return data end
ruby
{ "resource": "" }
q4424
TelestreamCloud::Flip.FlipApi.create_encoding
train
def create_encoding(factory_id, create_encoding_body, opts = {}) data, _status_code, _headers = create_encoding_with_http_info(factory_id, create_encoding_body, opts) return data end
ruby
{ "resource": "" }
q4425
TelestreamCloud::Flip.FlipApi.create_factory
train
def create_factory(create_factory_body, opts = {}) data, _status_code, _headers = create_factory_with_http_info(create_factory_body, opts) return data end
ruby
{ "resource": "" }
q4426
TelestreamCloud::Flip.FlipApi.create_profile
train
def create_profile(factory_id, create_profile_body, opts = {}) data, _status_code, _headers = create_profile_with_http_info(factory_id, create_profile_body, opts) return data end
ruby
{ "resource": "" }
q4427
TelestreamCloud::Flip.FlipApi.create_video
train
def create_video(factory_id, create_video_body, opts = {}) data, _status_code, _headers = create_video_with_http_info(factory_id, create_video_body, opts) return data end
ruby
{ "resource": "" }
q4428
TelestreamCloud::Flip.FlipApi.delete_encoding
train
def delete_encoding(id, factory_id, opts = {}) data, _status_code, _headers = delete_encoding_with_http_info(id, factory_id, opts) return data end
ruby
{ "resource": "" }
q4429
TelestreamCloud::Flip.FlipApi.delete_profile
train
def delete_profile(id, factory_id, opts = {}) data, _status_code, _headers = delete_profile_with_http_info(id, factory_id, opts) return data end
ruby
{ "resource": "" }
q4430
TelestreamCloud::Flip.FlipApi.delete_video
train
def delete_video(id, factory_id, opts = {}) data, _status_code, _headers = delete_video_with_http_info(id, factory_id, opts) return data end
ruby
{ "resource": "" }
q4431
TelestreamCloud::Flip.FlipApi.delete_video_source
train
def delete_video_source(id, factory_id, opts = {}) data, _status_code, _headers = delete_video_source_with_http_info(id, factory_id, opts) return data end
ruby
{ "resource": "" }
q4432
TelestreamCloud::Flip.FlipApi.encoding
train
def encoding(id, factory_id, opts = {}) data, _status_code, _headers = encoding_with_http_info(id, factory_id, opts) return data end
ruby
{ "resource": "" }
q4433
TelestreamCloud::Flip.FlipApi.encodings
train
def encodings(factory_id, opts = {}) data, _status_code, _headers = encodings_with_http_info(factory_id, opts) return data end
ruby
{ "resource": "" }
q4434
TelestreamCloud::Flip.FlipApi.encodings_count
train
def encodings_count(factory_id, opts = {}) data, _status_code, _headers = encodings_count_with_http_info(factory_id, opts) return data end
ruby
{ "resource": "" }
q4435
TelestreamCloud::Flip.FlipApi.factory
train
def factory(id, opts = {}) data, _status_code, _headers = factory_with_http_info(id, opts) return data end
ruby
{ "resource": "" }
q4436
TelestreamCloud::Flip.FlipApi.notifications
train
def notifications(factory_id, opts = {}) data, _status_code, _headers = notifications_with_http_info(factory_id, opts) return data end
ruby
{ "resource": "" }
q4437
TelestreamCloud::Flip.FlipApi.profile
train
def profile(id_or_name, factory_id, opts = {}) data, _status_code, _headers = profile_with_http_info(id_or_name, factory_id, opts) return data end
ruby
{ "resource": "" }
q4438
TelestreamCloud::Flip.FlipApi.profile_encodings
train
def profile_encodings(id_or_name, factory_id, opts = {}) data, _status_code, _headers = profile_encodings_with_http_info(id_or_name, factory_id, opts) return data end
ruby
{ "resource": "" }
q4439
TelestreamCloud::Flip.FlipApi.profiles
train
def profiles(factory_id, opts = {}) data, _status_code, _headers = profiles_with_http_info(factory_id, opts) return data end
ruby
{ "resource": "" }
q4440
TelestreamCloud::Flip.FlipApi.queued_videos
train
def queued_videos(factory_id, opts = {}) data, _status_code, _headers = queued_videos_with_http_info(factory_id, opts) return data end
ruby
{ "resource": "" }
q4441
TelestreamCloud::Flip.FlipApi.retry_encoding
train
def retry_encoding(id, factory_id, opts = {}) data, _status_code, _headers = retry_encoding_with_http_info(id, factory_id, opts) return data end
ruby
{ "resource": "" }
q4442
TelestreamCloud::Flip.FlipApi.signed_encoding_url
train
def signed_encoding_url(id, factory_id, opts = {}) data, _status_code, _headers = signed_encoding_url_with_http_info(id, factory_id, opts) return data end
ruby
{ "resource": "" }
q4443
TelestreamCloud::Flip.FlipApi.signed_encoding_urls
train
def signed_encoding_urls(id, factory_id, opts = {}) data, _status_code, _headers = signed_encoding_urls_with_http_info(id, factory_id, opts) return data end
ruby
{ "resource": "" }
q4444
TelestreamCloud::Flip.FlipApi.signed_video_url
train
def signed_video_url(id, factory_id, opts = {}) data, _status_code, _headers = signed_video_url_with_http_info(id, factory_id, opts) return data end
ruby
{ "resource": "" }
q4445
TelestreamCloud::Flip.FlipApi.toggle_factory_sync
train
def toggle_factory_sync(id, factory_sync_body, opts = {}) data, _status_code, _headers = toggle_factory_sync_with_http_info(id, factory_sync_body, opts) return data end
ruby
{ "resource": "" }
q4446
TelestreamCloud::Flip.FlipApi.update_encoding
train
def update_encoding(id, factory_id, update_encoding_body, opts = {}) data, _status_code, _headers = update_encoding_with_http_info(id, factory_id, update_encoding_body, opts) return data end
ruby
{ "resource": "" }
q4447
TelestreamCloud::Flip.FlipApi.update_factory
train
def update_factory(id, update_factory_body, opts = {}) data, _status_code, _headers = update_factory_with_http_info(id, update_factory_body, opts) return data end
ruby
{ "resource": "" }
q4448
TelestreamCloud::Flip.FlipApi.update_notifications
train
def update_notifications(factory_id, cloud_notification_settings_body, opts = {}) data, _status_code, _headers = update_notifications_with_http_info(factory_id, cloud_notification_settings_body, opts) return data end
ruby
{ "resource": "" }
q4449
TelestreamCloud::Flip.FlipApi.update_profile
train
def update_profile(id, factory_id, update_profile_body, opts = {}) data, _status_code, _headers = update_profile_with_http_info(id, factory_id, update_profile_body, opts) return data end
ruby
{ "resource": "" }
q4450
TelestreamCloud::Flip.FlipApi.upload_video
train
def upload_video(factory_id, video_upload_body, opts = {}) data, _status_code, _headers = upload_video_with_http_info(factory_id, video_upload_body, opts) return data end
ruby
{ "resource": "" }
q4451
TelestreamCloud::Flip.FlipApi.video_encodings
train
def video_encodings(id, factory_id, opts = {}) data, _status_code, _headers = video_encodings_with_http_info(id, factory_id, opts) return data end
ruby
{ "resource": "" }
q4452
TelestreamCloud::Flip.FlipApi.video_metadata
train
def video_metadata(id, factory_id, opts = {}) data, _status_code, _headers = video_metadata_with_http_info(id, factory_id, opts) return data end
ruby
{ "resource": "" }
q4453
TelestreamCloud::Flip.FlipApi.videos
train
def videos(factory_id, opts = {}) data, _status_code, _headers = videos_with_http_info(factory_id, opts) return data end
ruby
{ "resource": "" }
q4454
TelestreamCloud::Flip.FlipApi.workflows
train
def workflows(factory_id, opts = {}) data, _status_code, _headers = workflows_with_http_info(factory_id, opts) return data end
ruby
{ "resource": "" }
q4455
Comable.ApplicationHelper.liquid_assigns
train
def liquid_assigns view_context.assigns.merge( current_store: current_store, current_comable_user: current_comable_user, current_order: current_order, current_trackers: current_trackers, form_authenticity_token: form_authenticity_token ).stringify_keys end
ruby
{ "resource": "" }
q4456
Threshold.Thresholds.flush
train
def flush begin valid_existing_file?(@file) raise ReadOnlyThresholdsFile if @readonly hash = current_hash file = File.open(@file, 'w+') raise ThresholdAtomicLockFailure, 'The @file state/hash changed before we could flush the file' unless stored_hash == hash file.wr...
ruby
{ "resource": "" }
q4457
Threshold.Thresholds.loadfile
train
def loadfile valid_existing_file?(@file) results = Threshold::Parser.new(@file) @stored_hash= results.filehash #puts stored_hash results.caps.each do |result| builder = Threshold::Builder.new(result) self << builder.build end end
ruby
{ "resource": "" }
q4458
Threshold.Thresholds.valid?
train
def valid? begin self.each do |threshold| if threshold.respond_to?(:valid?) return false unless threshold.valid? else raise InvalidThresholdsObject, "Container object has unknown objects" end end return true rescue InvalidThreshol...
ruby
{ "resource": "" }
q4459
Threshold.Thresholds.uniq
train
def uniq(&blk) if block_given? Thresholds.new(@thresholds.uniq(&blk)) else Thresholds.new(@thresholds.uniq{ |lineitem| lineitem.to_s(true) }) end end
ruby
{ "resource": "" }
q4460
Threshold.Thresholds.suppressions
train
def suppressions(&blk) if block_given? self.suppressions.select(&blk) else Thresholds.new(@thresholds.select{|t| t.class.to_s == "Threshold::Suppression"}) end end
ruby
{ "resource": "" }
q4461
Threshold.Thresholds.event_filters
train
def event_filters(&blk) if block_given? self.event_filters.select(&blk) else Thresholds.new(@thresholds.select{|t| t.class.to_s == "Threshold::EventFilter"}) end end
ruby
{ "resource": "" }
q4462
Threshold.Thresholds.rate_filters
train
def rate_filters(&blk) if block_given? self.rate_filters.select(&blk) else Thresholds.new(@thresholds.select{|t| t.class.to_s == "Threshold::RateFilter"}) end end
ruby
{ "resource": "" }
q4463
Backlog.API.count_issue
train
def count_issue(condition) raise Backlog::API::ArgumentError, "must specify 'projectId'" unless condition.has_key? "projectId" condition = Backlog::Object::FindCondition.new(condition) self.call("backlog.countIssue", condition.to_h) end
ruby
{ "resource": "" }
q4464
NIFTI.NObject.write
train
def write(file_name, options={}) if file_name.is_a?(String) w = NWrite.new(self, file_name, options) w.write # Write process succesful? @write_success = w.success # If any messages has been recorded, send these to the message handling method: add_msg(w.msg) if w.msg...
ruby
{ "resource": "" }
q4465
NIFTI.NObject.read
train
def read(string, options={}) if string.is_a?(String) @string = string r = NRead.new(string, options) # Store the data to the instance variables if the readout was a success: if r.success @read_success = true # Update instance variables based on the properties of...
ruby
{ "resource": "" }
q4466
Qe.QuestionSheet.duplicate
train
def duplicate new_sheet = QuestionSheet.new(self.attributes) new_sheet.label = self.label + ' - COPY' new_sheet.save(:validate => false) self.pages.each do |page| page.copy_to(new_sheet) end new_sheet end
ruby
{ "resource": "" }
q4467
Rubylog.Variable.rubylog_unify
train
def rubylog_unify other # check if we are bound if @bound # if we are bound # proceed to our dereferenced value rubylog_dereference.rubylog_unify(other) do yield end else # if we are unbound # dereference the other other = other.rubylog_derefere...
ruby
{ "resource": "" }
q4468
Qe.ReferenceSheet.send_invite
train
def send_invite return if self.email.blank? application = self.applicant_answer_sheet Notifier.deliver_notification(self.email, application.email, "Reference Invite", {'refer...
ruby
{ "resource": "" }
q4469
UUIDTools.UUID.generate_i
train
def generate_i return (begin bytes = (time_low << 96) + (time_mid << 80) + (time_hi_and_version << 64) + (clock_seq_hi_and_reserved << 56) + (clock_seq_low << 48) for i in 0..5 bytes += (nodes[i] << (40 - (i * 8))) end bytes end) end
ruby
{ "resource": "" }
q4470
Baidu.Client.authorize_url
train
def authorize_url(opts = {}) opts[:redirect_uri] ||= DEFAULT_REDIRECT_URI # scope:非必须参数,以空格分隔的权限列表,若不传递此参数,代表请求用户的默认权限。关于权限的具体信息请参考“权限列表”。 opts[:scope] ||= "basic netdisk super_msg" oauth_client.auth_code.authorize_url(scope: opts[:scope], redirect_uri: opts[:redirect_uri]) end
ruby
{ "resource": "" }
q4471
Baidu.Client.token!
train
def token!(authorization_code,opts = {}) opts[:redirect_uri] ||= DEFAULT_REDIRECT_URI self.access_token = oauth_client.auth_code.get_token(authorization_code, redirect_uri: opts[:redirect_uri]) end
ruby
{ "resource": "" }
q4472
Baidu.Client.refresh_token!
train
def refresh_token!(refresh_token) old_token = OAuth2::AccessToken.new(oauth_client,'', refresh_token: refresh_token) self.access_token = old_token.refresh! end
ruby
{ "resource": "" }
q4473
MiniSpec.InstanceAPI.stub
train
def stub object, stub, visibility = nil, &proc [Symbol, String, Hash].include?(stub.class) || raise(ArgumentError, 'a Symbol, String or Hash expected') if stub.is_a?(Hash) return hash_stub(object, stub, visibility, &proc) elsif stub =~ /\./ return chained_stub(object, stub, vi...
ruby
{ "resource": "" }
q4474
MiniSpec.InstanceAPI.stubs
train
def stubs object, *stubs, &proc MiniSpec::Mocks::MultipleStubsProxy.new(stubs.map {|s| stub(object, s, &proc)}) end
ruby
{ "resource": "" }
q4475
GetnetApi.Card.to_request
train
def to_request card = { number_token: self.number_token, cardholder_name: self.cardholder_name, security_code: self.security_code, brand: self.brand, expiration_month: self.expiration_month, expiration_year: self.expirat...
ruby
{ "resource": "" }
q4476
CamperVan.Server.post_init
train
def post_init(*args) logger.info "got connection from #{remote_ip}" # initialize the line-based protocol: IRC is \r\n @lt2_delimiter = "\r\n" # start up the IRCD for this connection @ircd = IRCD.new(self, options) if options[:ssl] logger.info "starting TLS for #{remote_ip}...
ruby
{ "resource": "" }
q4477
IPAddrExtensions.ClassMethods.generate_ULA
train
def generate_ULA(mac, subnet_id = 0, locally_assigned=true) now = Time.now.utc ntp_time = ((now.to_i + 2208988800) << 32) + now.nsec # Convert time to an NTP timstamp. system_id = '::/64'.to_ip.eui_64(mac).to_i # Generate an EUI64 from the provided MAC address. key = [ ntp_time, system_id ].pack...
ruby
{ "resource": "" }
q4478
Qe.Admin::QuestionPagesController.show_panel
train
def show_panel @tab_name = params[:panel_name] @panel_name = params[:panel_name] == "properties" ? "prop_sheet" : params[:panel_name] @all_pages = @question_sheet.pages.find(:all) # for pages_list @page = @question_sheet.pages.find(params[:id]) respond_to do |format| format...
ruby
{ "resource": "" }
q4479
Svn.Utils.wrap
train
def wrap( obj ) ptr = FFI::MemoryPointer.new( :uint64 ) ptr.write_uint64( obj.object_id ) ptr end
ruby
{ "resource": "" }
q4480
MiniSpec.Utils.method_visibility
train
def method_visibility object, method { public: :public_methods, protected: :protected_methods, private: :private_methods }.each_pair do |v,m| if v == :public # in case public_methods overridden to include method # but method in fact does not exists, ...
ruby
{ "resource": "" }
q4481
MiniSpec.Utils.any_match?
train
def any_match? label, matchers reject, select = matchers.partition {|m| m.is_a?(Hash)} rejected = rejected?(label, reject) if select.any? return select.find {|x| (x == :*) || match?(label, x)} && !rejected end !rejected end
ruby
{ "resource": "" }
q4482
MiniSpec.Utils.rejected?
train
def rejected? label, reject if reject.any? && (x = reject.first[:except]) if x.is_a?(Array) return true if x.find {|m| match?(label, m)} else return true if match?(label, x) end end false end
ruby
{ "resource": "" }
q4483
MiniSpec.Utils.match?
train
def match? label, x x.is_a?(Regexp) ? label.to_s =~ x : label == x end
ruby
{ "resource": "" }
q4484
UriSigner.Signer.uri_with_signature
train
def uri_with_signature separator = if request_parser.query_params? then '&' else '?' end encoded_signature = signature.extend(UriSigner::Helpers::String).escaped "%s%s_signature=%s" % [self.uri, separator, encoded_signature] end
ruby
{ "resource": "" }
q4485
Polish.Proxies.pluralize
train
def pluralize(n, *variants) raise ArgumentError, "Must have a Numeric as a first parameter" unless n.is_a?(Numeric) raise ArgumentError, "Must have 3 variants for pluralization" if variants.size < 3 variants_hash = pluralization_variants_to_hash(*variants) I18n.backend.send(:pluralize, LOCALE, v...
ruby
{ "resource": "" }
q4486
Qe.Question.set_response
train
def set_response(values, app) values = Array.wrap(values) if !object_name.blank? and !attribute_name.blank? # if eval("app." + object_name).present? object = object_name == 'application' ? app : eval("app." + object_name) unless object.present? if object_name.include?('.') ...
ruby
{ "resource": "" }
q4487
Qe.Question.save_response
train
def save_response(answer_sheet) unless @answers.nil? for answer in @answers if answer.is_a?(Answer) answer.answer_sheet_id = answer_sheet.id answer.save! end end end # remove others unless @mark_for_destroy.nil? for answe...
ruby
{ "resource": "" }
q4488
Qe.Question.has_response?
train
def has_response?(answer_sheet = nil) if answer_sheet.present? answers = responses(answer_sheet) else answers = Answer.where(:question_id => self.id) end return false if answers.length == 0 answers.each do |answer| # loop through Answers value = answer.is_a?(Answe...
ruby
{ "resource": "" }
q4489
Chars.CharSet.<<
train
def <<(other) case other when String other.each_char do |char| byte = char_to_byte(char) @chars[byte] = char super(byte) end return self when Integer super(other) else raise(TypeError,"can only append Strings and Integers") ...
ruby
{ "resource": "" }
q4490
Chars.CharSet.include_char?
train
def include_char?(char) unless char.empty? @chars.has_value?(char) || include_byte?(char_to_byte(char)) else false end end
ruby
{ "resource": "" }
q4491
Chars.CharSet.each_random_char
train
def each_random_char(n,&block) return enum_for(:each_random_char,n) unless block_given? each_random_byte(n) { |byte| yield @chars[byte] } end
ruby
{ "resource": "" }
q4492
Chars.CharSet.random_bytes
train
def random_bytes(length) if (length.kind_of?(Array) || length.kind_of?(Range)) Array.new(length.sort_by { rand }.first) { random_byte } else Array.new(length) { random_byte } end end
ruby
{ "resource": "" }
q4493
Chars.CharSet.random_distinct_bytes
train
def random_distinct_bytes(length) if (length.kind_of?(Array) || length.kind_of?(Range)) self.entries.sort_by { rand }.slice(0...(length.sort_by { rand }.first)) else self.entries.sort_by { rand }.slice(0...length) end end
ruby
{ "resource": "" }
q4494
Chars.CharSet.strings_in
train
def strings_in(data,options={},&block) unless block if options[:offsets] found = {} block = lambda { |offset,substring| found[offset] = substring } else found = [] block = lambda { |substring| found << substring } end strings_in(data,options...
ruby
{ "resource": "" }
q4495
HasOffersModel.ClassMethods.has_offers_model
train
def has_offers_model(has_offers_class_name) has_offers_class = "HasOffers::#{has_offers_class_name}".constantize class_eval do define_method("has_offers_create") do if respond_to? :has_offer_id response = has_offers_class.create(has_offers_params) if response.suc...
ruby
{ "resource": "" }
q4496
Diameter.AVP.inner_avps
train
def inner_avps(name) code, _type, _vendor = AVPNames.get(name) grouped_value.select { |a| a.code == code } end
ruby
{ "resource": "" }
q4497
Diameter.AVP.ip_address=
train
def ip_address=(value) bytes = if value.ipv4? [1].pack('n') else [2].pack('n') end bytes += value.hton @content = bytes end
ruby
{ "resource": "" }
q4498
MiniSpec.InstanceAPI.double
train
def double *args, &proc name = args.first.is_a?(Hash) ? nil : args.shift object = Object.new object.define_singleton_method(:__ms__double_instance) {true} object.define_singleton_method(:inspect) {name} if name hashes, rest = args.partition {|s| s.is_a?(Hash)} hashes.each {|h| stub...
ruby
{ "resource": "" }
q4499
QontoOfx.Converter.convert
train
def convert(remove_ns = false) organization = @gateway.fetch_organization['organization'] builder = Nokogiri::XML::Builder.new(encoding: 'UTF-8') builder[:ofx].OFX('xmlns:ofx' => 'http://ofx.net/types/2003/04') do |xml| add_signonmsgsrsv1_block xml xml.BANKMSGSRSV1 do xml.p...
ruby
{ "resource": "" }