id
int32
0
24.9k
repo
stringlengths
5
58
path
stringlengths
9
168
func_name
stringlengths
9
130
original_string
stringlengths
66
10.5k
language
stringclasses
1 value
code
stringlengths
66
10.5k
code_tokens
sequence
docstring
stringlengths
8
16k
docstring_tokens
sequence
sha
stringlengths
40
40
url
stringlengths
94
266
4,400
Telestream/telestream-cloud-ruby-sdk
tts/lib/telestream_cloud_tts/api/tts_api.rb
TelestreamCloud::Tts.TtsApi.corpus
def corpus(project_id, name, opts = {}) data, _status_code, _headers = corpus_with_http_info(project_id, name, opts) return data end
ruby
def corpus(project_id, name, opts = {}) data, _status_code, _headers = corpus_with_http_info(project_id, name, opts) return data end
[ "def", "corpus", "(", "project_id", ",", "name", ",", "opts", "=", "{", "}", ")", "data", ",", "_status_code", ",", "_headers", "=", "corpus_with_http_info", "(", "project_id", ",", "name", ",", "opts", ")", "return", "data", "end" ]
Returns the Corpus Returns the Corpus @param project_id ID of the Project @param name Corpus name @param [Hash] opts the optional parameters @return [Corpus]
[ "Returns", "the", "Corpus", "Returns", "the", "Corpus" ]
c232427aa3e84688ba41ec28e5bef1cc72832bf4
https://github.com/Telestream/telestream-cloud-ruby-sdk/blob/c232427aa3e84688ba41ec28e5bef1cc72832bf4/tts/lib/telestream_cloud_tts/api/tts_api.rb#L84-L87
4,401
Telestream/telestream-cloud-ruby-sdk
tts/lib/telestream_cloud_tts/api/tts_api.rb
TelestreamCloud::Tts.TtsApi.create_corpus
def create_corpus(project_id, name, body, opts = {}) create_corpus_with_http_info(project_id, name, body, opts) return nil end
ruby
def create_corpus(project_id, name, body, opts = {}) create_corpus_with_http_info(project_id, name, body, opts) return nil end
[ "def", "create_corpus", "(", "project_id", ",", "name", ",", "body", ",", "opts", "=", "{", "}", ")", "create_corpus_with_http_info", "(", "project_id", ",", "name", ",", "body", ",", "opts", ")", "return", "nil", "end" ]
Creates a new Corpus Creates a new Corpus @param project_id ID of the Project @param name Corpus name @param body @param [Hash] opts the optional parameters @return [nil]
[ "Creates", "a", "new", "Corpus", "Creates", "a", "new", "Corpus" ]
c232427aa3e84688ba41ec28e5bef1cc72832bf4
https://github.com/Telestream/telestream-cloud-ruby-sdk/blob/c232427aa3e84688ba41ec28e5bef1cc72832bf4/tts/lib/telestream_cloud_tts/api/tts_api.rb#L146-L149
4,402
Telestream/telestream-cloud-ruby-sdk
tts/lib/telestream_cloud_tts/api/tts_api.rb
TelestreamCloud::Tts.TtsApi.create_project
def create_project(project, opts = {}) data, _status_code, _headers = create_project_with_http_info(project, opts) return data end
ruby
def create_project(project, opts = {}) data, _status_code, _headers = create_project_with_http_info(project, opts) return data end
[ "def", "create_project", "(", "project", ",", "opts", "=", "{", "}", ")", "data", ",", "_status_code", ",", "_headers", "=", "create_project_with_http_info", "(", "project", ",", "opts", ")", "return", "data", "end" ]
Creates a new Project Creates a new Project @param project @param [Hash] opts the optional parameters @return [Project]
[ "Creates", "a", "new", "Project", "Creates", "a", "new", "Project" ]
c232427aa3e84688ba41ec28e5bef1cc72832bf4
https://github.com/Telestream/telestream-cloud-ruby-sdk/blob/c232427aa3e84688ba41ec28e5bef1cc72832bf4/tts/lib/telestream_cloud_tts/api/tts_api.rb#L271-L274
4,403
Telestream/telestream-cloud-ruby-sdk
tts/lib/telestream_cloud_tts/api/tts_api.rb
TelestreamCloud::Tts.TtsApi.job
def job(project_id, job_id, opts = {}) data, _status_code, _headers = job_with_http_info(project_id, job_id, opts) return data end
ruby
def job(project_id, job_id, opts = {}) data, _status_code, _headers = job_with_http_info(project_id, job_id, opts) return data end
[ "def", "job", "(", "project_id", ",", "job_id", ",", "opts", "=", "{", "}", ")", "data", ",", "_status_code", ",", "_headers", "=", "job_with_http_info", "(", "project_id", ",", "job_id", ",", "opts", ")", "return", "data", "end" ]
Returns the Job Returns the Job @param project_id ID of the Project @param job_id @param [Hash] opts the optional parameters @return [Job]
[ "Returns", "the", "Job", "Returns", "the", "Job" ]
c232427aa3e84688ba41ec28e5bef1cc72832bf4
https://github.com/Telestream/telestream-cloud-ruby-sdk/blob/c232427aa3e84688ba41ec28e5bef1cc72832bf4/tts/lib/telestream_cloud_tts/api/tts_api.rb#L495-L498
4,404
Telestream/telestream-cloud-ruby-sdk
tts/lib/telestream_cloud_tts/api/tts_api.rb
TelestreamCloud::Tts.TtsApi.job_result
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
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
[ "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" ]
Returns the Job Result Returns the Job Result @param project_id ID of the Project @param job_id @param [Hash] opts the optional parameters @return [JobResult]
[ "Returns", "the", "Job", "Result", "Returns", "the", "Job", "Result" ]
c232427aa3e84688ba41ec28e5bef1cc72832bf4
https://github.com/Telestream/telestream-cloud-ruby-sdk/blob/c232427aa3e84688ba41ec28e5bef1cc72832bf4/tts/lib/telestream_cloud_tts/api/tts_api.rb#L556-L559
4,405
Telestream/telestream-cloud-ruby-sdk
tts/lib/telestream_cloud_tts/api/tts_api.rb
TelestreamCloud::Tts.TtsApi.jobs
def jobs(project_id, opts = {}) data, _status_code, _headers = jobs_with_http_info(project_id, opts) return data end
ruby
def jobs(project_id, opts = {}) data, _status_code, _headers = jobs_with_http_info(project_id, opts) return data end
[ "def", "jobs", "(", "project_id", ",", "opts", "=", "{", "}", ")", "data", ",", "_status_code", ",", "_headers", "=", "jobs_with_http_info", "(", "project_id", ",", "opts", ")", "return", "data", "end" ]
Returns a collection of Jobs Returns a collection of Jobs @param project_id ID of the Project @param [Hash] opts the optional parameters @option opts [Integer] :page page number @option opts [Integer] :per_page number of records per page @return [JobsCollection]
[ "Returns", "a", "collection", "of", "Jobs", "Returns", "a", "collection", "of", "Jobs" ]
c232427aa3e84688ba41ec28e5bef1cc72832bf4
https://github.com/Telestream/telestream-cloud-ruby-sdk/blob/c232427aa3e84688ba41ec28e5bef1cc72832bf4/tts/lib/telestream_cloud_tts/api/tts_api.rb#L618-L621
4,406
Telestream/telestream-cloud-ruby-sdk
tts/lib/telestream_cloud_tts/api/tts_api.rb
TelestreamCloud::Tts.TtsApi.project
def project(project_id, opts = {}) data, _status_code, _headers = project_with_http_info(project_id, opts) return data end
ruby
def project(project_id, opts = {}) data, _status_code, _headers = project_with_http_info(project_id, opts) return data end
[ "def", "project", "(", "project_id", ",", "opts", "=", "{", "}", ")", "data", ",", "_status_code", ",", "_headers", "=", "project_with_http_info", "(", "project_id", ",", "opts", ")", "return", "data", "end" ]
Returns the Project Returns the Project @param project_id ID of the Project @param [Hash] opts the optional parameters @return [Project]
[ "Returns", "the", "Project", "Returns", "the", "Project" ]
c232427aa3e84688ba41ec28e5bef1cc72832bf4
https://github.com/Telestream/telestream-cloud-ruby-sdk/blob/c232427aa3e84688ba41ec28e5bef1cc72832bf4/tts/lib/telestream_cloud_tts/api/tts_api.rb#L677-L680
4,407
Telestream/telestream-cloud-ruby-sdk
tts/lib/telestream_cloud_tts/api/tts_api.rb
TelestreamCloud::Tts.TtsApi.update_project
def update_project(project, opts = {}) data, _status_code, _headers = update_project_with_http_info(project, opts) return data end
ruby
def update_project(project, opts = {}) data, _status_code, _headers = update_project_with_http_info(project, opts) return data end
[ "def", "update_project", "(", "project", ",", "opts", "=", "{", "}", ")", "data", ",", "_status_code", ",", "_headers", "=", "update_project_with_http_info", "(", "project", ",", "opts", ")", "return", "data", "end" ]
Updates an existing Project Updates an existing Project @param project @param [Hash] opts the optional parameters @return [Project]
[ "Updates", "an", "existing", "Project", "Updates", "an", "existing", "Project" ]
c232427aa3e84688ba41ec28e5bef1cc72832bf4
https://github.com/Telestream/telestream-cloud-ruby-sdk/blob/c232427aa3e84688ba41ec28e5bef1cc72832bf4/tts/lib/telestream_cloud_tts/api/tts_api.rb#L835-L838
4,408
Telestream/telestream-cloud-ruby-sdk
tts/lib/telestream_cloud_tts/api/tts_api.rb
TelestreamCloud::Tts.TtsApi.upload_video
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
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
[ "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" ]
Creates an upload session @param project_id ID of the Project @param video_upload_body @param [Hash] opts the optional parameters @return [UploadSession]
[ "Creates", "an", "upload", "session" ]
c232427aa3e84688ba41ec28e5bef1cc72832bf4
https://github.com/Telestream/telestream-cloud-ruby-sdk/blob/c232427aa3e84688ba41ec28e5bef1cc72832bf4/tts/lib/telestream_cloud_tts/api/tts_api.rb#L891-L894
4,409
christhekeele/rails-tables
lib/rails-tables/datatable/searching.rb
RailsTables::Searching.ClassMethods.search_on
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
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
[ "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" ]
Allow user defined fields to sort on in addition to introspected fields
[ "Allow", "user", "defined", "fields", "to", "sort", "on", "in", "addition", "to", "introspected", "fields" ]
77adc0f9392f58819adce112b7964e4d353fab04
https://github.com/christhekeele/rails-tables/blob/77adc0f9392f58819adce112b7964e4d353fab04/lib/rails-tables/datatable/searching.rb#L12-L17
4,410
brainmap/nifti
lib/nifti/n_read.rb
NIFTI.NRead.read_image
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
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
[ "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" ]
Create a NRead object to parse a nifti file or binary string and set header and image info instance variables. The nifti header will be checked for validity (header size and magic number) and will raise an IOError if invalid. NIFTI header extensions are not yet supported and are not included in the header. The header and image are accessible via the hdr and image instance variables. An optional narray matrix may also be available in image_narray if desired by passing in :narray => true as an option. === Parameters * <tt>source</tt> -- A string which specifies either the path of a NIFTI file to be loaded, or a binary NIFTI string to be parsed. * <tt>options</tt> -- A hash of parameters. === Options * <tt>:bin</tt> -- Boolean. If set to true, string parameter will be interpreted as a binary NIFTI string, and not a path string, which is the default behaviour. * <tt>:image</tt> -- Boolean. If set to true, automatically load the image into @image, otherwise only a header is collected and you can get an image * <tt>:narray</tt> -- Boolean. If set to true, a properly shaped narray matrix will be set in the instance variable @image_narray. Automatically sets :image => true Unpack an image array from vox_offset to the end of a nifti file. === Parameters There are no parameters - this reads from the binary string in the @string instance variable. This sets @image_rubyarray to the image data vector and also returns it.
[ "Create", "a", "NRead", "object", "to", "parse", "a", "nifti", "file", "or", "binary", "string", "and", "set", "header", "and", "image", "info", "instance", "variables", "." ]
a252ee91b4964116a72373aa5008f218fd695e57
https://github.com/brainmap/nifti/blob/a252ee91b4964116a72373aa5008f218fd695e57/lib/nifti/n_read.rb#L60-L66
4,411
brainmap/nifti
lib/nifti/n_read.rb
NIFTI.NRead.get_image_narray
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
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
[ "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" ]
Create an narray if the NArray is available Tests if a file is readable, and if so, opens it. === Parameters * <tt>image_array</tt> -- Array. A vector of image data. * <tt>dim</tt> -- Array. The dim array from the nifti header, specifing number of dimensions (dim[0]) and dimension length of other dimensions to reshape narray into.
[ "Create", "an", "narray", "if", "the", "NArray", "is", "available", "Tests", "if", "a", "file", "is", "readable", "and", "if", "so", "opens", "it", "." ]
a252ee91b4964116a72373aa5008f218fd695e57
https://github.com/brainmap/nifti/blob/a252ee91b4964116a72373aa5008f218fd695e57/lib/nifti/n_read.rb#L76-L82
4,412
brainmap/nifti
lib/nifti/n_read.rb
NIFTI.NRead.parse_header
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
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
[ "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" ]
Parse the NIFTI Header.
[ "Parse", "the", "NIFTI", "Header", "." ]
a252ee91b4964116a72373aa5008f218fd695e57
https://github.com/brainmap/nifti/blob/a252ee91b4964116a72373aa5008f218fd695e57/lib/nifti/n_read.rb#L113-L123
4,413
brainmap/nifti
lib/nifti/n_read.rb
NIFTI.NRead.parse_basic_header
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 & Slice Dimensions from diminfo if header['dim_info'] header['freq_dim'] = dim_info_to_freq_dim(header['dim_info']) header['phase_dim'] = dim_info_to_phase_dim(header['dim_info']) header['slice_dim'] = dim_info_to_slice_dim(header['dim_info']) end header['sform_code_descr'] = XFORM_CODES[header['sform_code']] header['qform_code_descr'] = XFORM_CODES[header['qform_code']] return header end
ruby
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 & Slice Dimensions from diminfo if header['dim_info'] header['freq_dim'] = dim_info_to_freq_dim(header['dim_info']) header['phase_dim'] = dim_info_to_phase_dim(header['dim_info']) header['slice_dim'] = dim_info_to_slice_dim(header['dim_info']) end header['sform_code_descr'] = XFORM_CODES[header['sform_code']] header['qform_code_descr'] = XFORM_CODES[header['qform_code']] return header end
[ "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 & Slice Dimensions from diminfo", "if", "header", "[", "'dim_info'", "]", "header", "[", "'freq_dim'", "]", "=", "dim_info_to_freq_dim", "(", "header", "[", "'dim_info'", "]", ")", "header", "[", "'phase_dim'", "]", "=", "dim_info_to_phase_dim", "(", "header", "[", "'dim_info'", "]", ")", "header", "[", "'slice_dim'", "]", "=", "dim_info_to_slice_dim", "(", "header", "[", "'dim_info'", "]", ")", "end", "header", "[", "'sform_code_descr'", "]", "=", "XFORM_CODES", "[", "header", "[", "'sform_code'", "]", "]", "header", "[", "'qform_code_descr'", "]", "=", "XFORM_CODES", "[", "header", "[", "'qform_code'", "]", "]", "return", "header", "end" ]
Read the nifti header according to its byte signature. The file stream will be left open and should be positioned at the end of the 348 byte header.
[ "Read", "the", "nifti", "header", "according", "to", "its", "byte", "signature", ".", "The", "file", "stream", "will", "be", "left", "open", "and", "should", "be", "positioned", "at", "the", "end", "of", "the", "348", "byte", "header", "." ]
a252ee91b4964116a72373aa5008f218fd695e57
https://github.com/brainmap/nifti/blob/a252ee91b4964116a72373aa5008f218fd695e57/lib/nifti/n_read.rb#L157-L175
4,414
brainmap/nifti
lib/nifti/n_read.rb
NIFTI.NRead.parse_extended_header
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, these 4 # bytes will always be present, since the earliest start point for the # image data is byte #352. In a separate .hdr file, these bytes may or may # not be present (i.e., a .hdr file may only be 348 bytes long). If not # present, then a NIfTI-1.1 compliant program should use the default value # of extension={0,0,0,0}. The first byte (extension[0]) is the only value # of this array that is specified at present. The other 3 bytes are # reserved for future use." if extension[0] != 0 while @stream.index < @hdr['vox_offset'] esize, ecode = *@stream.decode(8, "UL") data = @stream.decode(esize - 8, "STR") extended << {:esize => esize, :ecode => ecode, :data => data} end # stream.decode(header['vox_offset'] - stream.index, "STR") # stream.skip header['vox_offset'] - stream.index end return extended end
ruby
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, these 4 # bytes will always be present, since the earliest start point for the # image data is byte #352. In a separate .hdr file, these bytes may or may # not be present (i.e., a .hdr file may only be 348 bytes long). If not # present, then a NIfTI-1.1 compliant program should use the default value # of extension={0,0,0,0}. The first byte (extension[0]) is the only value # of this array that is specified at present. The other 3 bytes are # reserved for future use." if extension[0] != 0 while @stream.index < @hdr['vox_offset'] esize, ecode = *@stream.decode(8, "UL") data = @stream.decode(esize - 8, "STR") extended << {:esize => esize, :ecode => ecode, :data => data} end # stream.decode(header['vox_offset'] - stream.index, "STR") # stream.skip header['vox_offset'] - stream.index end return extended end
[ "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, these 4", "# bytes will always be present, since the earliest start point for the", "# image data is byte #352. In a separate .hdr file, these bytes may or may", "# not be present (i.e., a .hdr file may only be 348 bytes long). If not", "# present, then a NIfTI-1.1 compliant program should use the default value", "# of extension={0,0,0,0}. The first byte (extension[0]) is the only value", "# of this array that is specified at present. The other 3 bytes are", "# reserved for future use.\"", "if", "extension", "[", "0", "]", "!=", "0", "while", "@stream", ".", "index", "<", "@hdr", "[", "'vox_offset'", "]", "esize", ",", "ecode", "=", "@stream", ".", "decode", "(", "8", ",", "\"UL\"", ")", "data", "=", "@stream", ".", "decode", "(", "esize", "-", "8", ",", "\"STR\"", ")", "extended", "<<", "{", ":esize", "=>", "esize", ",", ":ecode", "=>", "ecode", ",", ":data", "=>", "data", "}", "end", "# stream.decode(header['vox_offset'] - stream.index, \"STR\")", "# stream.skip header['vox_offset'] - stream.index", "end", "return", "extended", "end" ]
Read any extended header information. The file stream will be left at imaging data itself, taking vox_offset into account for NIFTI Header Extended Attributes. Pass in the voxel offset so the extended header knows when to stop reading.
[ "Read", "any", "extended", "header", "information", ".", "The", "file", "stream", "will", "be", "left", "at", "imaging", "data", "itself", "taking", "vox_offset", "into", "account", "for", "NIFTI", "Header", "Extended", "Attributes", ".", "Pass", "in", "the", "voxel", "offset", "so", "the", "extended", "header", "knows", "when", "to", "stop", "reading", "." ]
a252ee91b4964116a72373aa5008f218fd695e57
https://github.com/brainmap/nifti/blob/a252ee91b4964116a72373aa5008f218fd695e57/lib/nifti/n_read.rb#L181-L205
4,415
brainmap/nifti
lib/nifti/n_read.rb
NIFTI.NRead.open_file
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, "rb") end else @msg << "Error! File is too small to contain DICOM information (#{file})." end else @msg << "Error! File is a directory (#{file})." end else @msg << "Error! File exists but I don't have permission to read it (#{file})." end else @msg << "Error! The file you have supplied does not exist (#{file})." end end
ruby
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, "rb") end else @msg << "Error! File is too small to contain DICOM information (#{file})." end else @msg << "Error! File is a directory (#{file})." end else @msg << "Error! File exists but I don't have permission to read it (#{file})." end else @msg << "Error! The file you have supplied does not exist (#{file})." end end
[ "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", ",", "\"rb\"", ")", "end", "else", "@msg", "<<", "\"Error! File is too small to contain DICOM information (#{file}).\"", "end", "else", "@msg", "<<", "\"Error! File is a directory (#{file}).\"", "end", "else", "@msg", "<<", "\"Error! File exists but I don't have permission to read it (#{file}).\"", "end", "else", "@msg", "<<", "\"Error! The file you have supplied does not exist (#{file}).\"", "end", "end" ]
Tests if a file is readable, and if so, opens it. === Parameters * <tt>file</tt> -- A path/file string.
[ "Tests", "if", "a", "file", "is", "readable", "and", "if", "so", "opens", "it", "." ]
a252ee91b4964116a72373aa5008f218fd695e57
https://github.com/brainmap/nifti/blob/a252ee91b4964116a72373aa5008f218fd695e57/lib/nifti/n_read.rb#L213-L235
4,416
thelabtech/questionnaire
app/models/qe/text_field.rb
Qe.TextField.validation_class
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-' + validate_style end validation end
ruby
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-' + validate_style end validation end
[ "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-'", "+", "validate_style", "end", "validation", "end" ]
css class names for javascript-based validation
[ "css", "class", "names", "for", "javascript", "-", "based", "validation" ]
02eb47cbcda8cca28a5db78e18623d0957aa2c9b
https://github.com/thelabtech/questionnaire/blob/02eb47cbcda8cca28a5db78e18623d0957aa2c9b/app/models/qe/text_field.rb#L17-L26
4,417
brainmap/nifti
lib/nifti/n_write.rb
NIFTI.NWrite.write
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 content to a binary string: @stream = Stream.new(nil, @file_endian) # Tell the Stream instance which file to write to: @stream.set_file(@file) # Write Header and Image write_basic_header write_extended_header write_image # As file has been written successfully, it can be closed. @file.close # Mark this write session as successful: @success = true end end
ruby
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 content to a binary string: @stream = Stream.new(nil, @file_endian) # Tell the Stream instance which file to write to: @stream.set_file(@file) # Write Header and Image write_basic_header write_extended_header write_image # As file has been written successfully, it can be closed. @file.close # Mark this write session as successful: @success = true end end
[ "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 content to a binary string:", "@stream", "=", "Stream", ".", "new", "(", "nil", ",", "@file_endian", ")", "# Tell the Stream instance which file to write to:", "@stream", ".", "set_file", "(", "@file", ")", "# Write Header and Image", "write_basic_header", "write_extended_header", "write_image", "# As file has been written successfully, it can be closed.", "@file", ".", "close", "# Mark this write session as successful:", "@success", "=", "true", "end", "end" ]
Creates an NWrite instance. === Parameters * <tt>obj</tt> -- A NObject instance which will be used to encode a NIfTI string. * <tt>file_name</tt> -- A string, either specifying the path of a DICOM file to be loaded, or a binary DICOM string to be parsed. * <tt>options</tt> -- A hash of parameters. === Options Handles the encoding of NIfTI information to string as well as writing it to file.
[ "Creates", "an", "NWrite", "instance", "." ]
a252ee91b4964116a72373aa5008f218fd695e57
https://github.com/brainmap/nifti/blob/a252ee91b4964116a72373aa5008f218fd695e57/lib/nifti/n_write.rb#L33-L57
4,418
brainmap/nifti
lib/nifti/n_write.rb
NIFTI.NWrite.write_basic_header
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(type)) # pp padded_str.unpack(@stream.vr_to_str(type)) @stream.write padded_str @stream.skip length rescue StandardError => e puts name, length, type, e raise e end end end
ruby
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(type)) # pp padded_str.unpack(@stream.vr_to_str(type)) @stream.write padded_str @stream.skip length rescue StandardError => e puts name, length, type, e raise e end end end
[ "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(type))", "# pp padded_str.unpack(@stream.vr_to_str(type))", "@stream", ".", "write", "padded_str", "@stream", ".", "skip", "length", "rescue", "StandardError", "=>", "e", "puts", "name", ",", "length", ",", "type", ",", "e", "raise", "e", "end", "end", "end" ]
Write Basic Header
[ "Write", "Basic", "Header" ]
a252ee91b4964116a72373aa5008f218fd695e57
https://github.com/brainmap/nifti/blob/a252ee91b4964116a72373aa5008f218fd695e57/lib/nifti/n_write.rb#L60-L76
4,419
brainmap/nifti
lib/nifti/n_write.rb
NIFTI.NWrite.write_extended_header
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 @stream.encode_string_to_length(@stream.encode(extension[:data], "STR"), extension[:esize] - 8) end else @stream.write @stream.encode([0,0,0,0], "BY") end end
ruby
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 @stream.encode_string_to_length(@stream.encode(extension[:data], "STR"), extension[:esize] - 8) end else @stream.write @stream.encode([0,0,0,0], "BY") end end
[ "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", "@stream", ".", "encode_string_to_length", "(", "@stream", ".", "encode", "(", "extension", "[", ":data", "]", ",", "\"STR\"", ")", ",", "extension", "[", ":esize", "]", "-", "8", ")", "end", "else", "@stream", ".", "write", "@stream", ".", "encode", "(", "[", "0", ",", "0", ",", "0", ",", "0", "]", ",", "\"BY\"", ")", "end", "end" ]
Write Extended Header
[ "Write", "Extended", "Header" ]
a252ee91b4964116a72373aa5008f218fd695e57
https://github.com/brainmap/nifti/blob/a252ee91b4964116a72373aa5008f218fd695e57/lib/nifti/n_write.rb#L79-L90
4,420
vchs/ruby_vcloud_sdk
lib/ruby_vcloud_sdk/powerable.rb
VCloudSdk.Powerable.power_on
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_on_link = target.power_on_link unless power_on_link fail CloudError, "#{class_name} #{target.name} not in a state able to power on." end Config.logger.info "Powering on #{class_name} #{target.name}." task = connection.post(power_on_link.href, nil) task = monitor_task task, @session.time_limit[:power_on] Config.logger.info "#{class_name} #{target.name} is powered on." self end
ruby
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_on_link = target.power_on_link unless power_on_link fail CloudError, "#{class_name} #{target.name} not in a state able to power on." end Config.logger.info "Powering on #{class_name} #{target.name}." task = connection.post(power_on_link.href, nil) task = monitor_task task, @session.time_limit[:power_on] Config.logger.info "#{class_name} #{target.name} is powered on." self end
[ "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_on_link", "=", "target", ".", "power_on_link", "unless", "power_on_link", "fail", "CloudError", ",", "\"#{class_name} #{target.name} not in a state able to power on.\"", "end", "Config", ".", "logger", ".", "info", "\"Powering on #{class_name} #{target.name}.\"", "task", "=", "connection", ".", "post", "(", "power_on_link", ".", "href", ",", "nil", ")", "task", "=", "monitor_task", "task", ",", "@session", ".", "time_limit", "[", ":power_on", "]", "Config", ".", "logger", ".", "info", "\"#{class_name} #{target.name} is powered on.\"", "self", "end" ]
Power on VApp or VM
[ "Power", "on", "VApp", "or", "VM" ]
92d56db4fea4321068ab300ca60bcc6cec3e459b
https://github.com/vchs/ruby_vcloud_sdk/blob/92d56db4fea4321068ab300ca60bcc6cec3e459b/lib/ruby_vcloud_sdk/powerable.rb#L15-L35
4,421
vchs/ruby_vcloud_sdk
lib/ruby_vcloud_sdk/powerable.rb
VCloudSdk.Powerable.power_off
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_name == "VApp" ? VappSuspendedError : VmSuspendedError, error_msg end if is_status?(target, :POWERED_OFF) Config.logger.info "#{class_name} #{target.name} is already powered off." return end power_off_link = target.power_off_link unless power_off_link fail CloudError, "#{class_name} #{target.name} is not in a state that could be powered off." end task = connection.post(power_off_link.href, nil) monitor_task task, @session.time_limit[:power_off] Config.logger.info "#{class_name} #{target.name} is powered off." undeploy(target, class_name) self end
ruby
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_name == "VApp" ? VappSuspendedError : VmSuspendedError, error_msg end if is_status?(target, :POWERED_OFF) Config.logger.info "#{class_name} #{target.name} is already powered off." return end power_off_link = target.power_off_link unless power_off_link fail CloudError, "#{class_name} #{target.name} is not in a state that could be powered off." end task = connection.post(power_off_link.href, nil) monitor_task task, @session.time_limit[:power_off] Config.logger.info "#{class_name} #{target.name} is powered off." undeploy(target, class_name) self end
[ "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_name", "==", "\"VApp\"", "?", "VappSuspendedError", ":", "VmSuspendedError", ",", "error_msg", "end", "if", "is_status?", "(", "target", ",", ":POWERED_OFF", ")", "Config", ".", "logger", ".", "info", "\"#{class_name} #{target.name} is already powered off.\"", "return", "end", "power_off_link", "=", "target", ".", "power_off_link", "unless", "power_off_link", "fail", "CloudError", ",", "\"#{class_name} #{target.name} is not in a state that could be powered off.\"", "end", "task", "=", "connection", ".", "post", "(", "power_off_link", ".", "href", ",", "nil", ")", "monitor_task", "task", ",", "@session", ".", "time_limit", "[", ":power_off", "]", "Config", ".", "logger", ".", "info", "\"#{class_name} #{target.name} is powered off.\"", "undeploy", "(", "target", ",", "class_name", ")", "self", "end" ]
Power off VApp or VM
[ "Power", "off", "VApp", "or", "VM" ]
92d56db4fea4321068ab300ca60bcc6cec3e459b
https://github.com/vchs/ruby_vcloud_sdk/blob/92d56db4fea4321068ab300ca60bcc6cec3e459b/lib/ruby_vcloud_sdk/powerable.rb#L38-L63
4,422
Telestream/telestream-cloud-ruby-sdk
flip/lib/telestream_cloud_flip/api/flip_api.rb
TelestreamCloud::Flip.FlipApi.cancel_encoding
def cancel_encoding(id, factory_id, opts = {}) data, _status_code, _headers = cancel_encoding_with_http_info(id, factory_id, opts) return data end
ruby
def cancel_encoding(id, factory_id, opts = {}) data, _status_code, _headers = cancel_encoding_with_http_info(id, factory_id, opts) return data end
[ "def", "cancel_encoding", "(", "id", ",", "factory_id", ",", "opts", "=", "{", "}", ")", "data", ",", "_status_code", ",", "_headers", "=", "cancel_encoding_with_http_info", "(", "id", ",", "factory_id", ",", "opts", ")", "return", "data", "end" ]
Cancels an Encoding. @param id Id of an Encoding. @param factory_id Id of a Factory. @param [Hash] opts the optional parameters @return [CanceledResponse]
[ "Cancels", "an", "Encoding", "." ]
c232427aa3e84688ba41ec28e5bef1cc72832bf4
https://github.com/Telestream/telestream-cloud-ruby-sdk/blob/c232427aa3e84688ba41ec28e5bef1cc72832bf4/flip/lib/telestream_cloud_flip/api/flip_api.rb#L29-L32
4,423
Telestream/telestream-cloud-ruby-sdk
flip/lib/telestream_cloud_flip/api/flip_api.rb
TelestreamCloud::Flip.FlipApi.copy_profile
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
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
[ "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" ]
Copies a given Profile @param id Id of a Profile. @param factory_id Id of a Factory. @param copy_profile_body @param [Hash] opts the optional parameters @option opts [BOOLEAN] :expand If expand option is set Profile objects will contain all command parameters, even if their value is default. By default this is not set. @return [Profile]
[ "Copies", "a", "given", "Profile" ]
c232427aa3e84688ba41ec28e5bef1cc72832bf4
https://github.com/Telestream/telestream-cloud-ruby-sdk/blob/c232427aa3e84688ba41ec28e5bef1cc72832bf4/flip/lib/telestream_cloud_flip/api/flip_api.rb#L93-L96
4,424
Telestream/telestream-cloud-ruby-sdk
flip/lib/telestream_cloud_flip/api/flip_api.rb
TelestreamCloud::Flip.FlipApi.create_encoding
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
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
[ "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" ]
Creates an Encoding @param factory_id Id of a Factory. @param create_encoding_body @param [Hash] opts the optional parameters @option opts [BOOLEAN] :screenshots Determines whether the response will include screenshots. By default this is not set. @option opts [BOOLEAN] :precise_status Determines whether the response will include a precise status. By default this is not set. @return [Encoding]
[ "Creates", "an", "Encoding" ]
c232427aa3e84688ba41ec28e5bef1cc72832bf4
https://github.com/Telestream/telestream-cloud-ruby-sdk/blob/c232427aa3e84688ba41ec28e5bef1cc72832bf4/flip/lib/telestream_cloud_flip/api/flip_api.rb#L164-L167
4,425
Telestream/telestream-cloud-ruby-sdk
flip/lib/telestream_cloud_flip/api/flip_api.rb
TelestreamCloud::Flip.FlipApi.create_factory
def create_factory(create_factory_body, opts = {}) data, _status_code, _headers = create_factory_with_http_info(create_factory_body, opts) return data end
ruby
def create_factory(create_factory_body, opts = {}) data, _status_code, _headers = create_factory_with_http_info(create_factory_body, opts) return data end
[ "def", "create_factory", "(", "create_factory_body", ",", "opts", "=", "{", "}", ")", "data", ",", "_status_code", ",", "_headers", "=", "create_factory_with_http_info", "(", "create_factory_body", ",", "opts", ")", "return", "data", "end" ]
Creates a new factory @param create_factory_body @param [Hash] opts the optional parameters @option opts [BOOLEAN] :with_storage_provider if set to &#x60;true&#x60;, results will include a storage provider&#39;s id @return [Factory]
[ "Creates", "a", "new", "factory" ]
c232427aa3e84688ba41ec28e5bef1cc72832bf4
https://github.com/Telestream/telestream-cloud-ruby-sdk/blob/c232427aa3e84688ba41ec28e5bef1cc72832bf4/flip/lib/telestream_cloud_flip/api/flip_api.rb#L230-L233
4,426
Telestream/telestream-cloud-ruby-sdk
flip/lib/telestream_cloud_flip/api/flip_api.rb
TelestreamCloud::Flip.FlipApi.create_profile
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
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
[ "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" ]
Creates a Profile @param factory_id Id of a Factory. @param create_profile_body @param [Hash] opts the optional parameters @option opts [BOOLEAN] :exclude_advanced_services @option opts [BOOLEAN] :expand If expand option is set Profile objects will contain all command parameters, even if their value is default. By default it is not set. @return [Profile]
[ "Creates", "a", "Profile" ]
c232427aa3e84688ba41ec28e5bef1cc72832bf4
https://github.com/Telestream/telestream-cloud-ruby-sdk/blob/c232427aa3e84688ba41ec28e5bef1cc72832bf4/flip/lib/telestream_cloud_flip/api/flip_api.rb#L290-L293
4,427
Telestream/telestream-cloud-ruby-sdk
flip/lib/telestream_cloud_flip/api/flip_api.rb
TelestreamCloud::Flip.FlipApi.create_video
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
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
[ "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" ]
Creates a Video from a provided source_url. @param factory_id Id of a Factory. @param create_video_body @param [Hash] opts the optional parameters @return [Video]
[ "Creates", "a", "Video", "from", "a", "provided", "source_url", "." ]
c232427aa3e84688ba41ec28e5bef1cc72832bf4
https://github.com/Telestream/telestream-cloud-ruby-sdk/blob/c232427aa3e84688ba41ec28e5bef1cc72832bf4/flip/lib/telestream_cloud_flip/api/flip_api.rb#L356-L359
4,428
Telestream/telestream-cloud-ruby-sdk
flip/lib/telestream_cloud_flip/api/flip_api.rb
TelestreamCloud::Flip.FlipApi.delete_encoding
def delete_encoding(id, factory_id, opts = {}) data, _status_code, _headers = delete_encoding_with_http_info(id, factory_id, opts) return data end
ruby
def delete_encoding(id, factory_id, opts = {}) data, _status_code, _headers = delete_encoding_with_http_info(id, factory_id, opts) return data end
[ "def", "delete_encoding", "(", "id", ",", "factory_id", ",", "opts", "=", "{", "}", ")", "data", ",", "_status_code", ",", "_headers", "=", "delete_encoding_with_http_info", "(", "id", ",", "factory_id", ",", "opts", ")", "return", "data", "end" ]
Deletes an Encoding from both Telestream Cloud and your storage. Returns an information whether the operation was successful. @param id Id of an Encoding. @param factory_id Id of a Factory. @param [Hash] opts the optional parameters @return [DeletedResponse]
[ "Deletes", "an", "Encoding", "from", "both", "Telestream", "Cloud", "and", "your", "storage", ".", "Returns", "an", "information", "whether", "the", "operation", "was", "successful", "." ]
c232427aa3e84688ba41ec28e5bef1cc72832bf4
https://github.com/Telestream/telestream-cloud-ruby-sdk/blob/c232427aa3e84688ba41ec28e5bef1cc72832bf4/flip/lib/telestream_cloud_flip/api/flip_api.rb#L482-L485
4,429
Telestream/telestream-cloud-ruby-sdk
flip/lib/telestream_cloud_flip/api/flip_api.rb
TelestreamCloud::Flip.FlipApi.delete_profile
def delete_profile(id, factory_id, opts = {}) data, _status_code, _headers = delete_profile_with_http_info(id, factory_id, opts) return data end
ruby
def delete_profile(id, factory_id, opts = {}) data, _status_code, _headers = delete_profile_with_http_info(id, factory_id, opts) return data end
[ "def", "delete_profile", "(", "id", ",", "factory_id", ",", "opts", "=", "{", "}", ")", "data", ",", "_status_code", ",", "_headers", "=", "delete_profile_with_http_info", "(", "id", ",", "factory_id", ",", "opts", ")", "return", "data", "end" ]
Deletes a given Profile @param id Id of a Profile @param factory_id Id of a Factory. @param [Hash] opts the optional parameters @return [DeletedResponse]
[ "Deletes", "a", "given", "Profile" ]
c232427aa3e84688ba41ec28e5bef1cc72832bf4
https://github.com/Telestream/telestream-cloud-ruby-sdk/blob/c232427aa3e84688ba41ec28e5bef1cc72832bf4/flip/lib/telestream_cloud_flip/api/flip_api.rb#L544-L547
4,430
Telestream/telestream-cloud-ruby-sdk
flip/lib/telestream_cloud_flip/api/flip_api.rb
TelestreamCloud::Flip.FlipApi.delete_video
def delete_video(id, factory_id, opts = {}) data, _status_code, _headers = delete_video_with_http_info(id, factory_id, opts) return data end
ruby
def delete_video(id, factory_id, opts = {}) data, _status_code, _headers = delete_video_with_http_info(id, factory_id, opts) return data end
[ "def", "delete_video", "(", "id", ",", "factory_id", ",", "opts", "=", "{", "}", ")", "data", ",", "_status_code", ",", "_headers", "=", "delete_video_with_http_info", "(", "id", ",", "factory_id", ",", "opts", ")", "return", "data", "end" ]
Deletes a Video object. @param id Id of a Video. @param factory_id Id of a Factory. @param [Hash] opts the optional parameters @return [DeletedResponse]
[ "Deletes", "a", "Video", "object", "." ]
c232427aa3e84688ba41ec28e5bef1cc72832bf4
https://github.com/Telestream/telestream-cloud-ruby-sdk/blob/c232427aa3e84688ba41ec28e5bef1cc72832bf4/flip/lib/telestream_cloud_flip/api/flip_api.rb#L606-L609
4,431
Telestream/telestream-cloud-ruby-sdk
flip/lib/telestream_cloud_flip/api/flip_api.rb
TelestreamCloud::Flip.FlipApi.delete_video_source
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
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
[ "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" ]
Delete a video's source file. @param id Id of a Video. @param factory_id Id of a Factory. @param [Hash] opts the optional parameters @return [DeletedResponse]
[ "Delete", "a", "video", "s", "source", "file", "." ]
c232427aa3e84688ba41ec28e5bef1cc72832bf4
https://github.com/Telestream/telestream-cloud-ruby-sdk/blob/c232427aa3e84688ba41ec28e5bef1cc72832bf4/flip/lib/telestream_cloud_flip/api/flip_api.rb#L668-L671
4,432
Telestream/telestream-cloud-ruby-sdk
flip/lib/telestream_cloud_flip/api/flip_api.rb
TelestreamCloud::Flip.FlipApi.encoding
def encoding(id, factory_id, opts = {}) data, _status_code, _headers = encoding_with_http_info(id, factory_id, opts) return data end
ruby
def encoding(id, factory_id, opts = {}) data, _status_code, _headers = encoding_with_http_info(id, factory_id, opts) return data end
[ "def", "encoding", "(", "id", ",", "factory_id", ",", "opts", "=", "{", "}", ")", "data", ",", "_status_code", ",", "_headers", "=", "encoding_with_http_info", "(", "id", ",", "factory_id", ",", "opts", ")", "return", "data", "end" ]
Returns an Encoding object. @param id Id of an Encoding. @param factory_id Id of a Factory. @param [Hash] opts the optional parameters @option opts [BOOLEAN] :screenshots Determines whether the response will include screenshots. By default this is not set. @option opts [BOOLEAN] :precise_status Determines whether the response will include a precise status. By default this is not set. @return [Encoding]
[ "Returns", "an", "Encoding", "object", "." ]
c232427aa3e84688ba41ec28e5bef1cc72832bf4
https://github.com/Telestream/telestream-cloud-ruby-sdk/blob/c232427aa3e84688ba41ec28e5bef1cc72832bf4/flip/lib/telestream_cloud_flip/api/flip_api.rb#L732-L735
4,433
Telestream/telestream-cloud-ruby-sdk
flip/lib/telestream_cloud_flip/api/flip_api.rb
TelestreamCloud::Flip.FlipApi.encodings
def encodings(factory_id, opts = {}) data, _status_code, _headers = encodings_with_http_info(factory_id, opts) return data end
ruby
def encodings(factory_id, opts = {}) data, _status_code, _headers = encodings_with_http_info(factory_id, opts) return data end
[ "def", "encodings", "(", "factory_id", ",", "opts", "=", "{", "}", ")", "data", ",", "_status_code", ",", "_headers", "=", "encodings_with_http_info", "(", "factory_id", ",", "opts", ")", "return", "data", "end" ]
Returns a list of Encoding objects @param factory_id Id of a Factory. @param [Hash] opts the optional parameters @option opts [String] :video_id Id of a Video. When specified, the resulting list will contain videos that belong to the Video. @option opts [String] :status One of &#x60;success&#x60;, &#x60;fail&#x60;, &#x60;processing&#x60;. When specified, the resulting list will contain ecodings filtered by status. @option opts [String] :profile_id Filter by profile_id. @option opts [String] :profile_name Filter by profile_name. @option opts [Integer] :page A page to be fetched. Default is &#x60;1&#x60;. @option opts [Integer] :per_page A number of results per page. Default is &#x60;100&#x60;. @option opts [BOOLEAN] :screenshots Determines whether the response will include screenshots. By default this is not set. @option opts [BOOLEAN] :precise_status Determines whether the response will include a precise status. By default this is not set. @return [PaginatedEncodingsCollection]
[ "Returns", "a", "list", "of", "Encoding", "objects" ]
c232427aa3e84688ba41ec28e5bef1cc72832bf4
https://github.com/Telestream/telestream-cloud-ruby-sdk/blob/c232427aa3e84688ba41ec28e5bef1cc72832bf4/flip/lib/telestream_cloud_flip/api/flip_api.rb#L805-L808
4,434
Telestream/telestream-cloud-ruby-sdk
flip/lib/telestream_cloud_flip/api/flip_api.rb
TelestreamCloud::Flip.FlipApi.encodings_count
def encodings_count(factory_id, opts = {}) data, _status_code, _headers = encodings_count_with_http_info(factory_id, opts) return data end
ruby
def encodings_count(factory_id, opts = {}) data, _status_code, _headers = encodings_count_with_http_info(factory_id, opts) return data end
[ "def", "encodings_count", "(", "factory_id", ",", "opts", "=", "{", "}", ")", "data", ",", "_status_code", ",", "_headers", "=", "encodings_count_with_http_info", "(", "factory_id", ",", "opts", ")", "return", "data", "end" ]
Returns a number of Encoding objects created using a given factory. @param factory_id Id of a Factory. @param [Hash] opts the optional parameters @return [CountResponse]
[ "Returns", "a", "number", "of", "Encoding", "objects", "created", "using", "a", "given", "factory", "." ]
c232427aa3e84688ba41ec28e5bef1cc72832bf4
https://github.com/Telestream/telestream-cloud-ruby-sdk/blob/c232427aa3e84688ba41ec28e5bef1cc72832bf4/flip/lib/telestream_cloud_flip/api/flip_api.rb#L877-L880
4,435
Telestream/telestream-cloud-ruby-sdk
flip/lib/telestream_cloud_flip/api/flip_api.rb
TelestreamCloud::Flip.FlipApi.factory
def factory(id, opts = {}) data, _status_code, _headers = factory_with_http_info(id, opts) return data end
ruby
def factory(id, opts = {}) data, _status_code, _headers = factory_with_http_info(id, opts) return data end
[ "def", "factory", "(", "id", ",", "opts", "=", "{", "}", ")", "data", ",", "_status_code", ",", "_headers", "=", "factory_with_http_info", "(", "id", ",", "opts", ")", "return", "data", "end" ]
Returns a Factory object. Returns a Factory object. @param id id of a factory @param [Hash] opts the optional parameters @option opts [BOOLEAN] :with_storage_provider if set to &#x60;true&#x60;, results will include a storage provider&#39;s id @return [Factory]
[ "Returns", "a", "Factory", "object", ".", "Returns", "a", "Factory", "object", "." ]
c232427aa3e84688ba41ec28e5bef1cc72832bf4
https://github.com/Telestream/telestream-cloud-ruby-sdk/blob/c232427aa3e84688ba41ec28e5bef1cc72832bf4/flip/lib/telestream_cloud_flip/api/flip_api.rb#L992-L995
4,436
Telestream/telestream-cloud-ruby-sdk
flip/lib/telestream_cloud_flip/api/flip_api.rb
TelestreamCloud::Flip.FlipApi.notifications
def notifications(factory_id, opts = {}) data, _status_code, _headers = notifications_with_http_info(factory_id, opts) return data end
ruby
def notifications(factory_id, opts = {}) data, _status_code, _headers = notifications_with_http_info(factory_id, opts) return data end
[ "def", "notifications", "(", "factory_id", ",", "opts", "=", "{", "}", ")", "data", ",", "_status_code", ",", "_headers", "=", "notifications_with_http_info", "(", "factory_id", ",", "opts", ")", "return", "data", "end" ]
Returns a Factory's notification settings. @param factory_id Id of a Factory. @param [Hash] opts the optional parameters @return [CloudNotificationSettings]
[ "Returns", "a", "Factory", "s", "notification", "settings", "." ]
c232427aa3e84688ba41ec28e5bef1cc72832bf4
https://github.com/Telestream/telestream-cloud-ruby-sdk/blob/c232427aa3e84688ba41ec28e5bef1cc72832bf4/flip/lib/telestream_cloud_flip/api/flip_api.rb#L1049-L1052
4,437
Telestream/telestream-cloud-ruby-sdk
flip/lib/telestream_cloud_flip/api/flip_api.rb
TelestreamCloud::Flip.FlipApi.profile
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
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
[ "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" ]
Returns a Profile object. @param id_or_name A name or an id of a Profile. @param factory_id Id of a Factory. @param [Hash] opts the optional parameters @option opts [BOOLEAN] :expand If expand option is set Profile objects will contain all command parameters, even if their value is default. By default this is not set. @return [Profile]
[ "Returns", "a", "Profile", "object", "." ]
c232427aa3e84688ba41ec28e5bef1cc72832bf4
https://github.com/Telestream/telestream-cloud-ruby-sdk/blob/c232427aa3e84688ba41ec28e5bef1cc72832bf4/flip/lib/telestream_cloud_flip/api/flip_api.rb#L1107-L1110
4,438
Telestream/telestream-cloud-ruby-sdk
flip/lib/telestream_cloud_flip/api/flip_api.rb
TelestreamCloud::Flip.FlipApi.profile_encodings
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
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
[ "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" ]
Returns a list of Encodings that belong to a Profile. @param id_or_name Id or name of a Profile. @param factory_id Id of a Factory. @param [Hash] opts the optional parameters @return [PaginatedEncodingsCollection]
[ "Returns", "a", "list", "of", "Encodings", "that", "belong", "to", "a", "Profile", "." ]
c232427aa3e84688ba41ec28e5bef1cc72832bf4
https://github.com/Telestream/telestream-cloud-ruby-sdk/blob/c232427aa3e84688ba41ec28e5bef1cc72832bf4/flip/lib/telestream_cloud_flip/api/flip_api.rb#L1171-L1174
4,439
Telestream/telestream-cloud-ruby-sdk
flip/lib/telestream_cloud_flip/api/flip_api.rb
TelestreamCloud::Flip.FlipApi.profiles
def profiles(factory_id, opts = {}) data, _status_code, _headers = profiles_with_http_info(factory_id, opts) return data end
ruby
def profiles(factory_id, opts = {}) data, _status_code, _headers = profiles_with_http_info(factory_id, opts) return data end
[ "def", "profiles", "(", "factory_id", ",", "opts", "=", "{", "}", ")", "data", ",", "_status_code", ",", "_headers", "=", "profiles_with_http_info", "(", "factory_id", ",", "opts", ")", "return", "data", "end" ]
Returns a collection of Profile objects. @param factory_id Id of a Factory. @param [Hash] opts the optional parameters @option opts [BOOLEAN] :exclude_advanced_services Determine whether exclude Advanced Services profiles from the results. By default this is not set. @option opts [BOOLEAN] :expand If expand option is set Profile objects will contain all command parameters, even if their value is default. By default this is not set. @option opts [Integer] :page A page to be fetched. Default is &#x60;1&#x60;. @option opts [Integer] :per_page A number of results per page. Default is &#x60;100&#x60;. @return [PaginatedProfilesCollection]
[ "Returns", "a", "collection", "of", "Profile", "objects", "." ]
c232427aa3e84688ba41ec28e5bef1cc72832bf4
https://github.com/Telestream/telestream-cloud-ruby-sdk/blob/c232427aa3e84688ba41ec28e5bef1cc72832bf4/flip/lib/telestream_cloud_flip/api/flip_api.rb#L1236-L1239
4,440
Telestream/telestream-cloud-ruby-sdk
flip/lib/telestream_cloud_flip/api/flip_api.rb
TelestreamCloud::Flip.FlipApi.queued_videos
def queued_videos(factory_id, opts = {}) data, _status_code, _headers = queued_videos_with_http_info(factory_id, opts) return data end
ruby
def queued_videos(factory_id, opts = {}) data, _status_code, _headers = queued_videos_with_http_info(factory_id, opts) return data end
[ "def", "queued_videos", "(", "factory_id", ",", "opts", "=", "{", "}", ")", "data", ",", "_status_code", ",", "_headers", "=", "queued_videos_with_http_info", "(", "factory_id", ",", "opts", ")", "return", "data", "end" ]
Returns a collection of Video objects queued for encoding. @param factory_id Id of a Factory. @param [Hash] opts the optional parameters @option opts [Integer] :page A page to be fetched. Default is &#x60;1&#x60;. @option opts [Integer] :per_page A number of results per page. Default is &#x60;100&#x60;. @return [PaginatedVideoCollection]
[ "Returns", "a", "collection", "of", "Video", "objects", "queued", "for", "encoding", "." ]
c232427aa3e84688ba41ec28e5bef1cc72832bf4
https://github.com/Telestream/telestream-cloud-ruby-sdk/blob/c232427aa3e84688ba41ec28e5bef1cc72832bf4/flip/lib/telestream_cloud_flip/api/flip_api.rb#L1302-L1305
4,441
Telestream/telestream-cloud-ruby-sdk
flip/lib/telestream_cloud_flip/api/flip_api.rb
TelestreamCloud::Flip.FlipApi.retry_encoding
def retry_encoding(id, factory_id, opts = {}) data, _status_code, _headers = retry_encoding_with_http_info(id, factory_id, opts) return data end
ruby
def retry_encoding(id, factory_id, opts = {}) data, _status_code, _headers = retry_encoding_with_http_info(id, factory_id, opts) return data end
[ "def", "retry_encoding", "(", "id", ",", "factory_id", ",", "opts", "=", "{", "}", ")", "data", ",", "_status_code", ",", "_headers", "=", "retry_encoding_with_http_info", "(", "id", ",", "factory_id", ",", "opts", ")", "return", "data", "end" ]
Retries a failed encoding. @param id Id of an Encoding. @param factory_id Id of a Factory. @param [Hash] opts the optional parameters @return [RetriedResponse]
[ "Retries", "a", "failed", "encoding", "." ]
c232427aa3e84688ba41ec28e5bef1cc72832bf4
https://github.com/Telestream/telestream-cloud-ruby-sdk/blob/c232427aa3e84688ba41ec28e5bef1cc72832bf4/flip/lib/telestream_cloud_flip/api/flip_api.rb#L1424-L1427
4,442
Telestream/telestream-cloud-ruby-sdk
flip/lib/telestream_cloud_flip/api/flip_api.rb
TelestreamCloud::Flip.FlipApi.signed_encoding_url
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
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
[ "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" ]
Returns a signed url pointing to an Encoding. @param id Id of an Encoding. @param factory_id Id of a Factory. @param [Hash] opts the optional parameters @return [EncodingSignedUrl]
[ "Returns", "a", "signed", "url", "pointing", "to", "an", "Encoding", "." ]
c232427aa3e84688ba41ec28e5bef1cc72832bf4
https://github.com/Telestream/telestream-cloud-ruby-sdk/blob/c232427aa3e84688ba41ec28e5bef1cc72832bf4/flip/lib/telestream_cloud_flip/api/flip_api.rb#L1486-L1489
4,443
Telestream/telestream-cloud-ruby-sdk
flip/lib/telestream_cloud_flip/api/flip_api.rb
TelestreamCloud::Flip.FlipApi.signed_encoding_urls
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
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
[ "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" ]
Returns a list of signed urls pointing to an Encoding's outputs. @param id Id of an Encoding. @param factory_id Id of a Factory. @param [Hash] opts the optional parameters @return [EncodingSignedUrls]
[ "Returns", "a", "list", "of", "signed", "urls", "pointing", "to", "an", "Encoding", "s", "outputs", "." ]
c232427aa3e84688ba41ec28e5bef1cc72832bf4
https://github.com/Telestream/telestream-cloud-ruby-sdk/blob/c232427aa3e84688ba41ec28e5bef1cc72832bf4/flip/lib/telestream_cloud_flip/api/flip_api.rb#L1548-L1551
4,444
Telestream/telestream-cloud-ruby-sdk
flip/lib/telestream_cloud_flip/api/flip_api.rb
TelestreamCloud::Flip.FlipApi.signed_video_url
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
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
[ "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" ]
Returns a signed url pointing to a Video. @param id Id of a Video. @param factory_id Id of a Factory. @param [Hash] opts the optional parameters @return [SignedVideoUrl]
[ "Returns", "a", "signed", "url", "pointing", "to", "a", "Video", "." ]
c232427aa3e84688ba41ec28e5bef1cc72832bf4
https://github.com/Telestream/telestream-cloud-ruby-sdk/blob/c232427aa3e84688ba41ec28e5bef1cc72832bf4/flip/lib/telestream_cloud_flip/api/flip_api.rb#L1610-L1613
4,445
Telestream/telestream-cloud-ruby-sdk
flip/lib/telestream_cloud_flip/api/flip_api.rb
TelestreamCloud::Flip.FlipApi.toggle_factory_sync
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
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
[ "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" ]
Toggles synchronisation settings. @param id id of the factory @param factory_sync_body @param [Hash] opts the optional parameters @return [FactorySync]
[ "Toggles", "synchronisation", "settings", "." ]
c232427aa3e84688ba41ec28e5bef1cc72832bf4
https://github.com/Telestream/telestream-cloud-ruby-sdk/blob/c232427aa3e84688ba41ec28e5bef1cc72832bf4/flip/lib/telestream_cloud_flip/api/flip_api.rb#L1672-L1675
4,446
Telestream/telestream-cloud-ruby-sdk
flip/lib/telestream_cloud_flip/api/flip_api.rb
TelestreamCloud::Flip.FlipApi.update_encoding
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
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
[ "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" ]
Updates an Encoding @param id Id of an Encoding. @param factory_id Id of a Factory. @param update_encoding_body @param [Hash] opts the optional parameters @option opts [BOOLEAN] :screenshots Determines whether the response will include screenshots. By default this is not set. @option opts [BOOLEAN] :precise_status Determines whether the response will include a precise status. By default this is not set. @return [Encoding]
[ "Updates", "an", "Encoding" ]
c232427aa3e84688ba41ec28e5bef1cc72832bf4
https://github.com/Telestream/telestream-cloud-ruby-sdk/blob/c232427aa3e84688ba41ec28e5bef1cc72832bf4/flip/lib/telestream_cloud_flip/api/flip_api.rb#L1736-L1739
4,447
Telestream/telestream-cloud-ruby-sdk
flip/lib/telestream_cloud_flip/api/flip_api.rb
TelestreamCloud::Flip.FlipApi.update_factory
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
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
[ "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" ]
Updates a Factory's settings. Returns a Factory object. @param id id of the factory @param update_factory_body @param [Hash] opts the optional parameters @option opts [BOOLEAN] :with_storage_provider if set to &#x60;true&#x60;, results will include a storage provider&#39;s id @return [Factory]
[ "Updates", "a", "Factory", "s", "settings", ".", "Returns", "a", "Factory", "object", "." ]
c232427aa3e84688ba41ec28e5bef1cc72832bf4
https://github.com/Telestream/telestream-cloud-ruby-sdk/blob/c232427aa3e84688ba41ec28e5bef1cc72832bf4/flip/lib/telestream_cloud_flip/api/flip_api.rb#L1808-L1811
4,448
Telestream/telestream-cloud-ruby-sdk
flip/lib/telestream_cloud_flip/api/flip_api.rb
TelestreamCloud::Flip.FlipApi.update_notifications
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
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
[ "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" ]
Updates a Factory's notification settings. @param factory_id Id of a Factory. @param cloud_notification_settings_body @param [Hash] opts the optional parameters @return [CloudNotificationSettings]
[ "Updates", "a", "Factory", "s", "notification", "settings", "." ]
c232427aa3e84688ba41ec28e5bef1cc72832bf4
https://github.com/Telestream/telestream-cloud-ruby-sdk/blob/c232427aa3e84688ba41ec28e5bef1cc72832bf4/flip/lib/telestream_cloud_flip/api/flip_api.rb#L1871-L1874
4,449
Telestream/telestream-cloud-ruby-sdk
flip/lib/telestream_cloud_flip/api/flip_api.rb
TelestreamCloud::Flip.FlipApi.update_profile
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
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
[ "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" ]
Updates a given Profile @param id @param factory_id Id of a Factory. @param update_profile_body @param [Hash] opts the optional parameters @option opts [BOOLEAN] :exclude_advanced_services @option opts [BOOLEAN] :expand If expand option is set Profile objects will contain all command parameters, even if their value is default. By default this is not set. @return [Profile]
[ "Updates", "a", "given", "Profile" ]
c232427aa3e84688ba41ec28e5bef1cc72832bf4
https://github.com/Telestream/telestream-cloud-ruby-sdk/blob/c232427aa3e84688ba41ec28e5bef1cc72832bf4/flip/lib/telestream_cloud_flip/api/flip_api.rb#L1936-L1939
4,450
Telestream/telestream-cloud-ruby-sdk
flip/lib/telestream_cloud_flip/api/flip_api.rb
TelestreamCloud::Flip.FlipApi.upload_video
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
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
[ "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" ]
Creates an upload session. @param factory_id Id of a Factory. @param video_upload_body @param [Hash] opts the optional parameters @return [UploadSession]
[ "Creates", "an", "upload", "session", "." ]
c232427aa3e84688ba41ec28e5bef1cc72832bf4
https://github.com/Telestream/telestream-cloud-ruby-sdk/blob/c232427aa3e84688ba41ec28e5bef1cc72832bf4/flip/lib/telestream_cloud_flip/api/flip_api.rb#L2007-L2010
4,451
Telestream/telestream-cloud-ruby-sdk
flip/lib/telestream_cloud_flip/api/flip_api.rb
TelestreamCloud::Flip.FlipApi.video_encodings
def video_encodings(id, factory_id, opts = {}) data, _status_code, _headers = video_encodings_with_http_info(id, factory_id, opts) return data end
ruby
def video_encodings(id, factory_id, opts = {}) data, _status_code, _headers = video_encodings_with_http_info(id, factory_id, opts) return data end
[ "def", "video_encodings", "(", "id", ",", "factory_id", ",", "opts", "=", "{", "}", ")", "data", ",", "_status_code", ",", "_headers", "=", "video_encodings_with_http_info", "(", "id", ",", "factory_id", ",", "opts", ")", "return", "data", "end" ]
Returns a list of Encodings that belong to a Video. @param id Id of a Video. @param factory_id Id of a Factory. @param [Hash] opts the optional parameters @option opts [Integer] :page A page to be fetched. Default is &#x60;1&#x60;. @option opts [Integer] :per_page A number of results per page. Default is &#x60;100&#x60;. @option opts [BOOLEAN] :screenshots Determines whether the response will include screenshots. By default this is not set. @option opts [BOOLEAN] :precise_status Determines whether the response will include a precise status. By default this is not set. @return [PaginatedEncodingsCollection]
[ "Returns", "a", "list", "of", "Encodings", "that", "belong", "to", "a", "Video", "." ]
c232427aa3e84688ba41ec28e5bef1cc72832bf4
https://github.com/Telestream/telestream-cloud-ruby-sdk/blob/c232427aa3e84688ba41ec28e5bef1cc72832bf4/flip/lib/telestream_cloud_flip/api/flip_api.rb#L2135-L2138
4,452
Telestream/telestream-cloud-ruby-sdk
flip/lib/telestream_cloud_flip/api/flip_api.rb
TelestreamCloud::Flip.FlipApi.video_metadata
def video_metadata(id, factory_id, opts = {}) data, _status_code, _headers = video_metadata_with_http_info(id, factory_id, opts) return data end
ruby
def video_metadata(id, factory_id, opts = {}) data, _status_code, _headers = video_metadata_with_http_info(id, factory_id, opts) return data end
[ "def", "video_metadata", "(", "id", ",", "factory_id", ",", "opts", "=", "{", "}", ")", "data", ",", "_status_code", ",", "_headers", "=", "video_metadata_with_http_info", "(", "id", ",", "factory_id", ",", "opts", ")", "return", "data", "end" ]
Returns a Video's metadata @param id Id of a Video. @param factory_id Id of a Factory. @param [Hash] opts the optional parameters @return [VideoMetadata]
[ "Returns", "a", "Video", "s", "metadata" ]
c232427aa3e84688ba41ec28e5bef1cc72832bf4
https://github.com/Telestream/telestream-cloud-ruby-sdk/blob/c232427aa3e84688ba41ec28e5bef1cc72832bf4/flip/lib/telestream_cloud_flip/api/flip_api.rb#L2205-L2208
4,453
Telestream/telestream-cloud-ruby-sdk
flip/lib/telestream_cloud_flip/api/flip_api.rb
TelestreamCloud::Flip.FlipApi.videos
def videos(factory_id, opts = {}) data, _status_code, _headers = videos_with_http_info(factory_id, opts) return data end
ruby
def videos(factory_id, opts = {}) data, _status_code, _headers = videos_with_http_info(factory_id, opts) return data end
[ "def", "videos", "(", "factory_id", ",", "opts", "=", "{", "}", ")", "data", ",", "_status_code", ",", "_headers", "=", "videos_with_http_info", "(", "factory_id", ",", "opts", ")", "return", "data", "end" ]
Returns a collection of Video objects. @param factory_id Id of a Factory. @param [Hash] opts the optional parameters @option opts [Integer] :page A page to be fetched. Default is &#x60;1&#x60;. @option opts [Integer] :per_page A number of results per page. Default is &#x60;100&#x60;. @return [PaginatedVideoCollection]
[ "Returns", "a", "collection", "of", "Video", "objects", "." ]
c232427aa3e84688ba41ec28e5bef1cc72832bf4
https://github.com/Telestream/telestream-cloud-ruby-sdk/blob/c232427aa3e84688ba41ec28e5bef1cc72832bf4/flip/lib/telestream_cloud_flip/api/flip_api.rb#L2268-L2271
4,454
Telestream/telestream-cloud-ruby-sdk
flip/lib/telestream_cloud_flip/api/flip_api.rb
TelestreamCloud::Flip.FlipApi.workflows
def workflows(factory_id, opts = {}) data, _status_code, _headers = workflows_with_http_info(factory_id, opts) return data end
ruby
def workflows(factory_id, opts = {}) data, _status_code, _headers = workflows_with_http_info(factory_id, opts) return data end
[ "def", "workflows", "(", "factory_id", ",", "opts", "=", "{", "}", ")", "data", ",", "_status_code", ",", "_headers", "=", "workflows_with_http_info", "(", "factory_id", ",", "opts", ")", "return", "data", "end" ]
Returns a collection of Workflows that belong to a Factory. @param factory_id Id of a Factory. @param [Hash] opts the optional parameters @option opts [Integer] :page A page to be fetched. Default is &#x60;1&#x60;. @option opts [Integer] :per_page A number of results per page. Default is &#x60;100&#x60;. @return [PaginatedWorkflowsCollection]
[ "Returns", "a", "collection", "of", "Workflows", "that", "belong", "to", "a", "Factory", "." ]
c232427aa3e84688ba41ec28e5bef1cc72832bf4
https://github.com/Telestream/telestream-cloud-ruby-sdk/blob/c232427aa3e84688ba41ec28e5bef1cc72832bf4/flip/lib/telestream_cloud_flip/api/flip_api.rb#L2330-L2333
4,455
appirits/comable
core/app/helpers/comable/application_helper.rb
Comable.ApplicationHelper.liquid_assigns
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
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
[ "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" ]
To use the functionality of liquid-rails
[ "To", "use", "the", "functionality", "of", "liquid", "-", "rails" ]
b0cf028da35ea9def1c675680e5e5293a969bebc
https://github.com/appirits/comable/blob/b0cf028da35ea9def1c675680e5e5293a969bebc/core/app/helpers/comable/application_helper.rb#L58-L66
4,456
shadowbq/snort-thresholds
lib/threshold/thresholds.rb
Threshold.Thresholds.flush
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.write self.sort.to_s file.close rescue NonExistantThresholdFile raise ReadOnlyThresholdsFile if @readonly file = File.open(@file, 'w') file.write self.sort.to_s file.close end stored_hash=current_hash return true end
ruby
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.write self.sort.to_s file.close rescue NonExistantThresholdFile raise ReadOnlyThresholdsFile if @readonly file = File.open(@file, 'w') file.write self.sort.to_s file.close end stored_hash=current_hash return true end
[ "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", ".", "write", "self", ".", "sort", ".", "to_s", "file", ".", "close", "rescue", "NonExistantThresholdFile", "raise", "ReadOnlyThresholdsFile", "if", "@readonly", "file", "=", "File", ".", "open", "(", "@file", ",", "'w'", ")", "file", ".", "write", "self", ".", "sort", ".", "to_s", "file", ".", "close", "end", "stored_hash", "=", "current_hash", "return", "true", "end" ]
Write changes to the file
[ "Write", "changes", "to", "the", "file" ]
e3e9d1b10c2460846e1779fda67e8bec0422f53e
https://github.com/shadowbq/snort-thresholds/blob/e3e9d1b10c2460846e1779fda67e8bec0422f53e/lib/threshold/thresholds.rb#L22-L41
4,457
shadowbq/snort-thresholds
lib/threshold/thresholds.rb
Threshold.Thresholds.loadfile
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
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
[ "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" ]
Append in the thresholds.conf file to current collection
[ "Append", "in", "the", "thresholds", ".", "conf", "file", "to", "current", "collection" ]
e3e9d1b10c2460846e1779fda67e8bec0422f53e
https://github.com/shadowbq/snort-thresholds/blob/e3e9d1b10c2460846e1779fda67e8bec0422f53e/lib/threshold/thresholds.rb#L50-L61
4,458
shadowbq/snort-thresholds
lib/threshold/thresholds.rb
Threshold.Thresholds.valid?
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 InvalidThresholdsObject return false end end
ruby
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 InvalidThresholdsObject return false end end
[ "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", "InvalidThresholdsObject", "return", "false", "end", "end" ]
Check if all objects in the Threshold Instance report .valid?
[ "Check", "if", "all", "objects", "in", "the", "Threshold", "Instance", "report", ".", "valid?" ]
e3e9d1b10c2460846e1779fda67e8bec0422f53e
https://github.com/shadowbq/snort-thresholds/blob/e3e9d1b10c2460846e1779fda67e8bec0422f53e/lib/threshold/thresholds.rb#L64-L77
4,459
shadowbq/snort-thresholds
lib/threshold/thresholds.rb
Threshold.Thresholds.uniq
def uniq(&blk) if block_given? Thresholds.new(@thresholds.uniq(&blk)) else Thresholds.new(@thresholds.uniq{ |lineitem| lineitem.to_s(true) }) end end
ruby
def uniq(&blk) if block_given? Thresholds.new(@thresholds.uniq(&blk)) else Thresholds.new(@thresholds.uniq{ |lineitem| lineitem.to_s(true) }) end end
[ "def", "uniq", "(", "&", "blk", ")", "if", "block_given?", "Thresholds", ".", "new", "(", "@thresholds", ".", "uniq", "(", "blk", ")", ")", "else", "Thresholds", ".", "new", "(", "@thresholds", ".", "uniq", "{", "|", "lineitem", "|", "lineitem", ".", "to_s", "(", "true", ")", "}", ")", "end", "end" ]
Uniques by default to printable output Returns a new Threshold Object
[ "Uniques", "by", "default", "to", "printable", "output", "Returns", "a", "new", "Threshold", "Object" ]
e3e9d1b10c2460846e1779fda67e8bec0422f53e
https://github.com/shadowbq/snort-thresholds/blob/e3e9d1b10c2460846e1779fda67e8bec0422f53e/lib/threshold/thresholds.rb#L138-L144
4,460
shadowbq/snort-thresholds
lib/threshold/thresholds.rb
Threshold.Thresholds.suppressions
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
def suppressions(&blk) if block_given? self.suppressions.select(&blk) else Thresholds.new(@thresholds.select{|t| t.class.to_s == "Threshold::Suppression"}) end end
[ "def", "suppressions", "(", "&", "blk", ")", "if", "block_given?", "self", ".", "suppressions", ".", "select", "(", "blk", ")", "else", "Thresholds", ".", "new", "(", "@thresholds", ".", "select", "{", "|", "t", "|", "t", ".", "class", ".", "to_s", "==", "\"Threshold::Suppression\"", "}", ")", "end", "end" ]
Returns a new Threshold Object with just suppressions
[ "Returns", "a", "new", "Threshold", "Object", "with", "just", "suppressions" ]
e3e9d1b10c2460846e1779fda67e8bec0422f53e
https://github.com/shadowbq/snort-thresholds/blob/e3e9d1b10c2460846e1779fda67e8bec0422f53e/lib/threshold/thresholds.rb#L173-L179
4,461
shadowbq/snort-thresholds
lib/threshold/thresholds.rb
Threshold.Thresholds.event_filters
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
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
[ "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" ]
Returns a new Threshold Object with just event_filters
[ "Returns", "a", "new", "Threshold", "Object", "with", "just", "event_filters" ]
e3e9d1b10c2460846e1779fda67e8bec0422f53e
https://github.com/shadowbq/snort-thresholds/blob/e3e9d1b10c2460846e1779fda67e8bec0422f53e/lib/threshold/thresholds.rb#L182-L188
4,462
shadowbq/snort-thresholds
lib/threshold/thresholds.rb
Threshold.Thresholds.rate_filters
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
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
[ "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" ]
Returns a new Threshold Object with just rate_filters
[ "Returns", "a", "new", "Threshold", "Object", "with", "just", "rate_filters" ]
e3e9d1b10c2460846e1779fda67e8bec0422f53e
https://github.com/shadowbq/snort-thresholds/blob/e3e9d1b10c2460846e1779fda67e8bec0422f53e/lib/threshold/thresholds.rb#L191-L197
4,463
yoppi/backlog-api
lib/backlog/api.rb
Backlog.API.count_issue
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
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
[ "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" ]
Hash -> Integer
[ "Hash", "-", ">", "Integer" ]
e11c045a2bb9d578160b6bf4b7cd01745c086d76
https://github.com/yoppi/backlog-api/blob/e11c045a2bb9d578160b6bf4b7cd01745c086d76/lib/backlog/api.rb#L115-L119
4,464
brainmap/nifti
lib/nifti/n_object.rb
NIFTI.NObject.write
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.length > 0 else raise ArgumentError, "Invalid file_name. Expected String, got #{file_name.class}." end end
ruby
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.length > 0 else raise ArgumentError, "Invalid file_name. Expected String, got #{file_name.class}." end end
[ "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", ".", "length", ">", "0", "else", "raise", "ArgumentError", ",", "\"Invalid file_name. Expected String, got #{file_name.class}.\"", "end", "end" ]
Passes the NObject to the DWrite class, which writes out the header and image to the specified file. === Parameters * <tt>file_name</tt> -- A string which identifies the path & name of the NIfTI file which is to be written to disk. * <tt>options</tt> -- A hash of parameters. === Options === Examples obj.write(path + "test.dcm")
[ "Passes", "the", "NObject", "to", "the", "DWrite", "class", "which", "writes", "out", "the", "header", "and", "image", "to", "the", "specified", "file", "." ]
a252ee91b4964116a72373aa5008f218fd695e57
https://github.com/brainmap/nifti/blob/a252ee91b4964116a72373aa5008f218fd695e57/lib/nifti/n_object.rb#L99-L110
4,465
brainmap/nifti
lib/nifti/n_object.rb
NIFTI.NObject.read
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 the NRead object: @header = r.hdr @extended_header = r.extended_header if r.image_narray @image = r.image_narray elsif r.image_rubyarray @image = r.image_rubyarray end else @read_success = false end # If any messages have been recorded, send these to the message handling method: add_msg(r.msg) if r.msg.length > 0 else raise ArgumentError, "Invalid argument. Expected String, got #{string.class}." end end
ruby
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 the NRead object: @header = r.hdr @extended_header = r.extended_header if r.image_narray @image = r.image_narray elsif r.image_rubyarray @image = r.image_rubyarray end else @read_success = false end # If any messages have been recorded, send these to the message handling method: add_msg(r.msg) if r.msg.length > 0 else raise ArgumentError, "Invalid argument. Expected String, got #{string.class}." end end
[ "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 the NRead object:", "@header", "=", "r", ".", "hdr", "@extended_header", "=", "r", ".", "extended_header", "if", "r", ".", "image_narray", "@image", "=", "r", ".", "image_narray", "elsif", "r", ".", "image_rubyarray", "@image", "=", "r", ".", "image_rubyarray", "end", "else", "@read_success", "=", "false", "end", "# If any messages have been recorded, send these to the message handling method:", "add_msg", "(", "r", ".", "msg", ")", "if", "r", ".", "msg", ".", "length", ">", "0", "else", "raise", "ArgumentError", ",", "\"Invalid argument. Expected String, got #{string.class}.\"", "end", "end" ]
Returns a NIFTI object by reading and parsing the specified file. This is accomplished by initializing the NRead class, which loads NIFTI information. === Notes This method is called automatically when initializing the NObject class with a file parameter, and in practice should not be called by users.
[ "Returns", "a", "NIFTI", "object", "by", "reading", "and", "parsing", "the", "specified", "file", ".", "This", "is", "accomplished", "by", "initializing", "the", "NRead", "class", "which", "loads", "NIFTI", "information", "." ]
a252ee91b4964116a72373aa5008f218fd695e57
https://github.com/brainmap/nifti/blob/a252ee91b4964116a72373aa5008f218fd695e57/lib/nifti/n_object.rb#L123-L146
4,466
thelabtech/questionnaire
app/models/qe/question_sheet.rb
Qe.QuestionSheet.duplicate
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
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
[ "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" ]
Pages get duplicated Question elements get associated non-question elements get cloned
[ "Pages", "get", "duplicated", "Question", "elements", "get", "associated", "non", "-", "question", "elements", "get", "cloned" ]
02eb47cbcda8cca28a5db78e18623d0957aa2c9b
https://github.com/thelabtech/questionnaire/blob/02eb47cbcda8cca28a5db78e18623d0957aa2c9b/app/models/qe/question_sheet.rb#L50-L58
4,467
cie/rubylog
lib/rubylog/variable.rb
Rubylog.Variable.rubylog_unify
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_dereference # if the other is a variable if other.is_a? Rubylog::Variable # succeed if same object (yield; return) if self.equal? other # we union our guards with the other's other.append_guards guards do # and bind to the other bind_to other do yield end end else # if the other is a value # bind to it and bind_to other do # check our guards if guards.all? {|g|g.rubylog_matches_as_guard? other} yield end end end end end
ruby
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_dereference # if the other is a variable if other.is_a? Rubylog::Variable # succeed if same object (yield; return) if self.equal? other # we union our guards with the other's other.append_guards guards do # and bind to the other bind_to other do yield end end else # if the other is a value # bind to it and bind_to other do # check our guards if guards.all? {|g|g.rubylog_matches_as_guard? other} yield end end end end end
[ "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_dereference", "# if the other is a variable", "if", "other", ".", "is_a?", "Rubylog", "::", "Variable", "# succeed if same object", "(", "yield", ";", "return", ")", "if", "self", ".", "equal?", "other", "# we union our guards with the other's", "other", ".", "append_guards", "guards", "do", "# and bind to the other", "bind_to", "other", "do", "yield", "end", "end", "else", "# if the other is a value", "# bind to it and ", "bind_to", "other", "do", "# check our guards", "if", "guards", ".", "all?", "{", "|", "g", "|", "g", ".", "rubylog_matches_as_guard?", "other", "}", "yield", "end", "end", "end", "end", "end" ]
Unifies the receiver with another value. First dereferences both the receiver and the other. If both dereferenced values are variables, unifies them with the other being bound to the receiver. If one of them is a variable, it gets bound to the other value. If none of them is a variable, they are checked for equality with eql?. Succeeds if other is the same object as the receiver.
[ "Unifies", "the", "receiver", "with", "another", "value", "." ]
bd53971b6bc6a9459b79257c925bdc795bf8c04b
https://github.com/cie/rubylog/blob/bd53971b6bc6a9459b79257c925bdc795bf8c04b/lib/rubylog/variable.rb#L63-L98
4,468
thelabtech/questionnaire
app/models/qe/reference_sheet.rb
Qe.ReferenceSheet.send_invite
def send_invite return if self.email.blank? application = self.applicant_answer_sheet Notifier.deliver_notification(self.email, application.email, "Reference Invite", {'reference_full_name' => self.name, 'applicant_full_name' => application.name, 'applicant_email' => application.email, 'applicant_home_phone' => application.phone, 'reference_url' => edit_reference_sheet_url(self, :a => self.access_key, :host => ActionMailer::Base.default_url_options[:host])}) # Send notification to applicant Notifier.deliver_notification(applicant_answer_sheet.email, # RECIPIENTS Questionnaire.from_email, # FROM "Reference Notification to Applicant", # LIQUID TEMPLATE NAME {'applicant_full_name' => applicant_answer_sheet.name, 'reference_full_name' => self.name, 'reference_email' => self.email, 'application_url' => edit_answer_sheet_url(applicant_answer_sheet, :host => ActionMailer::Base.default_url_options[:host])}) self.email_sent_at = Time.now self.save(:validate => false) true end
ruby
def send_invite return if self.email.blank? application = self.applicant_answer_sheet Notifier.deliver_notification(self.email, application.email, "Reference Invite", {'reference_full_name' => self.name, 'applicant_full_name' => application.name, 'applicant_email' => application.email, 'applicant_home_phone' => application.phone, 'reference_url' => edit_reference_sheet_url(self, :a => self.access_key, :host => ActionMailer::Base.default_url_options[:host])}) # Send notification to applicant Notifier.deliver_notification(applicant_answer_sheet.email, # RECIPIENTS Questionnaire.from_email, # FROM "Reference Notification to Applicant", # LIQUID TEMPLATE NAME {'applicant_full_name' => applicant_answer_sheet.name, 'reference_full_name' => self.name, 'reference_email' => self.email, 'application_url' => edit_answer_sheet_url(applicant_answer_sheet, :host => ActionMailer::Base.default_url_options[:host])}) self.email_sent_at = Time.now self.save(:validate => false) true end
[ "def", "send_invite", "return", "if", "self", ".", "email", ".", "blank?", "application", "=", "self", ".", "applicant_answer_sheet", "Notifier", ".", "deliver_notification", "(", "self", ".", "email", ",", "application", ".", "email", ",", "\"Reference Invite\"", ",", "{", "'reference_full_name'", "=>", "self", ".", "name", ",", "'applicant_full_name'", "=>", "application", ".", "name", ",", "'applicant_email'", "=>", "application", ".", "email", ",", "'applicant_home_phone'", "=>", "application", ".", "phone", ",", "'reference_url'", "=>", "edit_reference_sheet_url", "(", "self", ",", ":a", "=>", "self", ".", "access_key", ",", ":host", "=>", "ActionMailer", "::", "Base", ".", "default_url_options", "[", ":host", "]", ")", "}", ")", "# Send notification to applicant", "Notifier", ".", "deliver_notification", "(", "applicant_answer_sheet", ".", "email", ",", "# RECIPIENTS", "Questionnaire", ".", "from_email", ",", "# FROM", "\"Reference Notification to Applicant\"", ",", "# LIQUID TEMPLATE NAME", "{", "'applicant_full_name'", "=>", "applicant_answer_sheet", ".", "name", ",", "'reference_full_name'", "=>", "self", ".", "name", ",", "'reference_email'", "=>", "self", ".", "email", ",", "'application_url'", "=>", "edit_answer_sheet_url", "(", "applicant_answer_sheet", ",", ":host", "=>", "ActionMailer", "::", "Base", ".", "default_url_options", "[", ":host", "]", ")", "}", ")", "self", ".", "email_sent_at", "=", "Time", ".", "now", "self", ".", "save", "(", ":validate", "=>", "false", ")", "true", "end" ]
send email invite
[ "send", "email", "invite" ]
02eb47cbcda8cca28a5db78e18623d0957aa2c9b
https://github.com/thelabtech/questionnaire/blob/02eb47cbcda8cca28a5db78e18623d0957aa2c9b/app/models/qe/reference_sheet.rb#L77-L103
4,469
flydata/elastic-mapreduce
lib/uuidtools.rb
UUIDTools.UUID.generate_i
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
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
[ "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" ]
Generates an integer representation for this UUID.
[ "Generates", "an", "integer", "representation", "for", "this", "UUID", "." ]
fc96593d27c7e4797aef67ff4f8c76ee35609d57
https://github.com/flydata/elastic-mapreduce/blob/fc96593d27c7e4797aef67ff4f8c76ee35609d57/lib/uuidtools.rb#L447-L457
4,470
lanrion/baidu
lib/baidu/client.rb
Baidu.Client.authorize_url
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
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
[ "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" ]
=begin rdoc OAuth2 +authorize_url+ redirect or open this URL for login in Baidu website === Params: * +opts+ Hash * +redirect_uri+ String - default Baidu::DEFAULT_REDIRECT_URI,URL with logined redirect back === Rails example: class SessionController def oauth redirect_to $baidu.authorize_url(redirect_uri: callback_session_url) end def callback auth_code = params[:code] $baidu.token!(auth_code) end end =end
[ "=", "begin", "rdoc", "OAuth2", "+", "authorize_url", "+" ]
5eeecec67e402f9ea890049f5abf42f1ce3866f4
https://github.com/lanrion/baidu/blob/5eeecec67e402f9ea890049f5abf42f1ce3866f4/lib/baidu/client.rb#L61-L66
4,471
lanrion/baidu
lib/baidu/client.rb
Baidu.Client.token!
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
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
[ "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" ]
=begin rdoc OAuth get_token method This method will get #access_token (OAuth2::AccessToken) ... and save in Baidu instance == Params: * authorization_code - Authorization Code in callback URL * opts * +redirect_uri+ String - default Baidu::DEFAULT_REDIRECT_URI,URL with logined redirect back =end
[ "=", "begin", "rdoc", "OAuth", "get_token", "method" ]
5eeecec67e402f9ea890049f5abf42f1ce3866f4
https://github.com/lanrion/baidu/blob/5eeecec67e402f9ea890049f5abf42f1ce3866f4/lib/baidu/client.rb#L80-L83
4,472
lanrion/baidu
lib/baidu/client.rb
Baidu.Client.refresh_token!
def refresh_token!(refresh_token) old_token = OAuth2::AccessToken.new(oauth_client,'', refresh_token: refresh_token) self.access_token = old_token.refresh! end
ruby
def refresh_token!(refresh_token) old_token = OAuth2::AccessToken.new(oauth_client,'', refresh_token: refresh_token) self.access_token = old_token.refresh! end
[ "def", "refresh_token!", "(", "refresh_token", ")", "old_token", "=", "OAuth2", "::", "AccessToken", ".", "new", "(", "oauth_client", ",", "''", ",", "refresh_token", ":", "refresh_token", ")", "self", ".", "access_token", "=", "old_token", ".", "refresh!", "end" ]
=begin rdoc OAuth refresh_token method Refresh tokens when token was expired == Params: * refresh_token - refresh_token in last got #access_token =end
[ "=", "begin", "rdoc", "OAuth", "refresh_token", "method" ]
5eeecec67e402f9ea890049f5abf42f1ce3866f4
https://github.com/lanrion/baidu/blob/5eeecec67e402f9ea890049f5abf42f1ce3866f4/lib/baidu/client.rb#L98-L101
4,473
sleewoo/minispec
lib/minispec/api/instance/mocks/stubs.rb
MiniSpec.InstanceAPI.stub
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, visibility, &proc) end visibility ||= MiniSpec::Utils.method_visibility(object, stub) || :public stubs = (@__ms__stubs[object.__id__] ||= {}) stubs[stub] ||= MiniSpec::Mocks::Stub.new(object, @__ms__messages, @__ms__stubs__originals) stubs[stub].stubify(stub, visibility, &proc) stubs[stub] end
ruby
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, visibility, &proc) end visibility ||= MiniSpec::Utils.method_visibility(object, stub) || :public stubs = (@__ms__stubs[object.__id__] ||= {}) stubs[stub] ||= MiniSpec::Mocks::Stub.new(object, @__ms__messages, @__ms__stubs__originals) stubs[stub].stubify(stub, visibility, &proc) stubs[stub] end
[ "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", ",", "visibility", ",", "proc", ")", "end", "visibility", "||=", "MiniSpec", "::", "Utils", ".", "method_visibility", "(", "object", ",", "stub", ")", "||", ":public", "stubs", "=", "(", "@__ms__stubs", "[", "object", ".", "__id__", "]", "||=", "{", "}", ")", "stubs", "[", "stub", "]", "||=", "MiniSpec", "::", "Mocks", "::", "Stub", ".", "new", "(", "object", ",", "@__ms__messages", ",", "@__ms__stubs__originals", ")", "stubs", "[", "stub", "]", ".", "stubify", "(", "stub", ",", "visibility", ",", "proc", ")", "stubs", "[", "stub", "]", "end" ]
stubbing given method and keeps original visibility if a block given, it will receive original method as first argument and any passed parameters as rest arguments. @example make Some::Remote::API.call to return success stub(Some::Remote::API, :call) { :success } @example call original stub(obj, :a) {|orig| orig.call} @param object object to define stub on @param stub method to be stubbed. if a Hash given, keys will be stubbed methods and values return values @param [Proc] &proc block to be yielded when stub called @return MiniSpec::Mocks::Stub instance
[ "stubbing", "given", "method", "and", "keeps", "original", "visibility" ]
6dcdacd041cc031c21f2fe70b6e5b22c6af636c5
https://github.com/sleewoo/minispec/blob/6dcdacd041cc031c21f2fe70b6e5b22c6af636c5/lib/minispec/api/instance/mocks/stubs.rb#L21-L36
4,474
sleewoo/minispec
lib/minispec/api/instance/mocks/stubs.rb
MiniSpec.InstanceAPI.stubs
def stubs object, *stubs, &proc MiniSpec::Mocks::MultipleStubsProxy.new(stubs.map {|s| stub(object, s, &proc)}) end
ruby
def stubs object, *stubs, &proc MiniSpec::Mocks::MultipleStubsProxy.new(stubs.map {|s| stub(object, s, &proc)}) end
[ "def", "stubs", "object", ",", "*", "stubs", ",", "&", "proc", "MiniSpec", "::", "Mocks", "::", "MultipleStubsProxy", ".", "new", "(", "stubs", ".", "map", "{", "|", "s", "|", "stub", "(", "object", ",", "s", ",", "proc", ")", "}", ")", "end" ]
same as `stub` except it defines multiple stubs at once @param object @param *stubs @param &proc @return MiniSpec::Mocks::MultipleStubsProxy instance
[ "same", "as", "stub", "except", "it", "defines", "multiple", "stubs", "at", "once" ]
6dcdacd041cc031c21f2fe70b6e5b22c6af636c5
https://github.com/sleewoo/minispec/blob/6dcdacd041cc031c21f2fe70b6e5b22c6af636c5/lib/minispec/api/instance/mocks/stubs.rb#L70-L72
4,475
qw3/getnet_api
lib/getnet_api/card.rb
GetnetApi.Card.to_request
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.expiration_year } return card end
ruby
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.expiration_year } return card end
[ "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", ".", "expiration_year", "}", "return", "card", "end" ]
Nova instancia da classe Card @param [Hash] campos Montar o Hash de dados do pagamento no padrão utilizado pela Getnet
[ "Nova", "instancia", "da", "classe", "Card" ]
94cbda66aab03d83ea38bc5325ea2a02a639e922
https://github.com/qw3/getnet_api/blob/94cbda66aab03d83ea38bc5325ea2a02a639e922/lib/getnet_api/card.rb#L55-L66
4,476
zerowidth/camper_van
lib/camper_van/server.rb
CamperVan.Server.post_init
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}" start_tls(:cert_chain_file => options[:ssl_cert], :private_key_file => options[:ssl_private_key], :verify_peer => options[:ssl_verify_peer]) end end
ruby
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}" start_tls(:cert_chain_file => options[:ssl_cert], :private_key_file => options[:ssl_private_key], :verify_peer => options[:ssl_verify_peer]) end end
[ "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}\"", "start_tls", "(", ":cert_chain_file", "=>", "options", "[", ":ssl_cert", "]", ",", ":private_key_file", "=>", "options", "[", ":ssl_private_key", "]", ",", ":verify_peer", "=>", "options", "[", ":ssl_verify_peer", "]", ")", "end", "end" ]
Public callback once a server connection is established. Initializes an IRCD instance for this connection.
[ "Public", "callback", "once", "a", "server", "connection", "is", "established", "." ]
984351a3b472e936a451f1d1cd987ca27d981d23
https://github.com/zerowidth/camper_van/blob/984351a3b472e936a451f1d1cd987ca27d981d23/lib/camper_van/server.rb#L105-L118
4,477
jamesotron/IPAddrExtensions
lib/ipaddr_extensions.rb
IPAddrExtensions.ClassMethods.generate_ULA
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('QQ') # Pack the ntp timestamp and the system_id into a binary string global_id = Digest::SHA1.digest( key ).unpack('QQ').last & 0xffffffffff # Use only the last 40 bytes of the SHA1 digest. prefix = (126 << 121) + # 0xfc (bytes 0..6) ((locally_assigned ? 1 : 0) << 120) + # locally assigned? (byte 7) (global_id << 80) + # 40 bit global idenfitier (bytes 8..48) ((subnet_id & 0xffff) << 64) # 16 bit subnet_id (bytes 48..64) prefix.to_ip(Socket::AF_INET6).tap { |p| p.length = 64 } end
ruby
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('QQ') # Pack the ntp timestamp and the system_id into a binary string global_id = Digest::SHA1.digest( key ).unpack('QQ').last & 0xffffffffff # Use only the last 40 bytes of the SHA1 digest. prefix = (126 << 121) + # 0xfc (bytes 0..6) ((locally_assigned ? 1 : 0) << 120) + # locally assigned? (byte 7) (global_id << 80) + # 40 bit global idenfitier (bytes 8..48) ((subnet_id & 0xffff) << 64) # 16 bit subnet_id (bytes 48..64) prefix.to_ip(Socket::AF_INET6).tap { |p| p.length = 64 } end
[ "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", "(", "'QQ'", ")", "# Pack the ntp timestamp and the system_id into a binary string", "global_id", "=", "Digest", "::", "SHA1", ".", "digest", "(", "key", ")", ".", "unpack", "(", "'QQ'", ")", ".", "last", "&", "0xffffffffff", "# Use only the last 40 bytes of the SHA1 digest.", "prefix", "=", "(", "126", "<<", "121", ")", "+", "# 0xfc (bytes 0..6)", "(", "(", "locally_assigned", "?", "1", ":", "0", ")", "<<", "120", ")", "+", "# locally assigned? (byte 7)", "(", "global_id", "<<", "80", ")", "+", "# 40 bit global idenfitier (bytes 8..48)", "(", "(", "subnet_id", "&", "0xffff", ")", "<<", "64", ")", "# 16 bit subnet_id (bytes 48..64)", "prefix", ".", "to_ip", "(", "Socket", "::", "AF_INET6", ")", ".", "tap", "{", "|", "p", "|", "p", ".", "length", "=", "64", "}", "end" ]
Generate an IPv6 Unique Local Address using the supplied system MAC address. Note that the MAC address is just used as a source of randomness, so where you get it from is not important and doesn't restrict this ULA to just that system. See RFC4193
[ "Generate", "an", "IPv6", "Unique", "Local", "Address", "using", "the", "supplied", "system", "MAC", "address", ".", "Note", "that", "the", "MAC", "address", "is", "just", "used", "as", "a", "source", "of", "randomness", "so", "where", "you", "get", "it", "from", "is", "not", "important", "and", "doesn", "t", "restrict", "this", "ULA", "to", "just", "that", "system", ".", "See", "RFC4193" ]
0426dbad801cf305129370fb991cd9785cdfeb71
https://github.com/jamesotron/IPAddrExtensions/blob/0426dbad801cf305129370fb991cd9785cdfeb71/lib/ipaddr_extensions.rb#L495-L509
4,478
thelabtech/questionnaire
app/controllers/qe/admin/question_pages_controller.rb
Qe.Admin::QuestionPagesController.show_panel
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.js # load panel end end
ruby
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.js # load panel end end
[ "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", ".", "js", "# load panel", "end", "end" ]
load panel all AJAX-like GET
[ "load", "panel", "all", "AJAX", "-", "like", "GET" ]
02eb47cbcda8cca28a5db78e18623d0957aa2c9b
https://github.com/thelabtech/questionnaire/blob/02eb47cbcda8cca28a5db78e18623d0957aa2c9b/app/controllers/qe/admin/question_pages_controller.rb#L74-L83
4,479
codefoundry/svn
lib/svn/utils.rb
Svn.Utils.wrap
def wrap( obj ) ptr = FFI::MemoryPointer.new( :uint64 ) ptr.write_uint64( obj.object_id ) ptr end
ruby
def wrap( obj ) ptr = FFI::MemoryPointer.new( :uint64 ) ptr.write_uint64( obj.object_id ) ptr end
[ "def", "wrap", "(", "obj", ")", "ptr", "=", "FFI", "::", "MemoryPointer", ".", "new", "(", ":uint64", ")", "ptr", ".", "write_uint64", "(", "obj", ".", "object_id", ")", "ptr", "end" ]
Returns a pointer to the object_id of +obj+
[ "Returns", "a", "pointer", "to", "the", "object_id", "of", "+", "obj", "+" ]
930a8da65fbecf3ffed50655e1cb10fcbc484be4
https://github.com/codefoundry/svn/blob/930a8da65fbecf3ffed50655e1cb10fcbc484be4/lib/svn/utils.rb#L12-L16
4,480
sleewoo/minispec
lib/minispec/utils.rb
MiniSpec.Utils.method_visibility
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, # most notable ActiveRecord::Base#find which rely on method_missing return v if object.respond_to?(method) else return v if object.send(m).include?(method) end end nil end
ruby
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, # most notable ActiveRecord::Base#find which rely on method_missing return v if object.respond_to?(method) else return v if object.send(m).include?(method) end end nil end
[ "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,", "# most notable ActiveRecord::Base#find which rely on method_missing", "return", "v", "if", "object", ".", "respond_to?", "(", "method", ")", "else", "return", "v", "if", "object", ".", "send", "(", "m", ")", ".", "include?", "(", "method", ")", "end", "end", "nil", "end" ]
determines method's visibility @param object @param method @return [Symbol] or nil
[ "determines", "method", "s", "visibility" ]
6dcdacd041cc031c21f2fe70b6e5b22c6af636c5
https://github.com/sleewoo/minispec/blob/6dcdacd041cc031c21f2fe70b6e5b22c6af636c5/lib/minispec/utils.rb#L59-L75
4,481
sleewoo/minispec
lib/minispec/utils.rb
MiniSpec.Utils.any_match?
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
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
[ "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" ]
checks whether given label matches any matcher. even if label matched, it will return `false` if label matches some rejector. @param label @param matchers an `Array` of matchers and rejectors. matchers contained as hashes, rejectors as arrays. @return `true` or `false`
[ "checks", "whether", "given", "label", "matches", "any", "matcher", ".", "even", "if", "label", "matched", "it", "will", "return", "false", "if", "label", "matches", "some", "rejector", "." ]
6dcdacd041cc031c21f2fe70b6e5b22c6af636c5
https://github.com/sleewoo/minispec/blob/6dcdacd041cc031c21f2fe70b6e5b22c6af636c5/lib/minispec/utils.rb#L100-L108
4,482
sleewoo/minispec
lib/minispec/utils.rb
MiniSpec.Utils.rejected?
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
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
[ "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" ]
checks whether given label matches any rejector. @param label @param reject an `Array` of rejectors, each being a `Hash` containing `:except` key @return `true` or `false`
[ "checks", "whether", "given", "label", "matches", "any", "rejector", "." ]
6dcdacd041cc031c21f2fe70b6e5b22c6af636c5
https://github.com/sleewoo/minispec/blob/6dcdacd041cc031c21f2fe70b6e5b22c6af636c5/lib/minispec/utils.rb#L116-L125
4,483
sleewoo/minispec
lib/minispec/utils.rb
MiniSpec.Utils.match?
def match? label, x x.is_a?(Regexp) ? label.to_s =~ x : label == x end
ruby
def match? label, x x.is_a?(Regexp) ? label.to_s =~ x : label == x end
[ "def", "match?", "label", ",", "x", "x", ".", "is_a?", "(", "Regexp", ")", "?", "label", ".", "to_s", "=~", "x", ":", "label", "==", "x", "end" ]
compare given label to given expression. if expression is a `Regexp` comparing using `=~`. otherwise `==` are used @param label @param x @return `true` or `false`
[ "compare", "given", "label", "to", "given", "expression", ".", "if", "expression", "is", "a", "Regexp", "comparing", "using", "=", "~", ".", "otherwise", "==", "are", "used" ]
6dcdacd041cc031c21f2fe70b6e5b22c6af636c5
https://github.com/sleewoo/minispec/blob/6dcdacd041cc031c21f2fe70b6e5b22c6af636c5/lib/minispec/utils.rb#L135-L137
4,484
kissmetrics/uri_signer
lib/uri_signer/signer.rb
UriSigner.Signer.uri_with_signature
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
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
[ "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" ]
Returns the URI with the signature appended to the query string return [String]
[ "Returns", "the", "URI", "with", "the", "signature", "appended", "to", "the", "query", "string" ]
3169df476c7f8ed88c5af6ade2c826ad3e5fa2a3
https://github.com/kissmetrics/uri_signer/blob/3169df476c7f8ed88c5af6ade2c826ad3e5fa2a3/lib/uri_signer/signer.rb#L57-L61
4,485
grk/polish
lib/polish/proxies.rb
Polish.Proxies.pluralize
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, variants_hash, n) end
ruby
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, variants_hash, n) end
[ "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", ",", "variants_hash", ",", "n", ")", "end" ]
Simple pluralization proxy Usage: Polish.pluralize(1, "dom", "domy", "domów")
[ "Simple", "pluralization", "proxy" ]
d1488048e53f93eabe7219eb7d5760eef55a362b
https://github.com/grk/polish/blob/d1488048e53f93eabe7219eb7d5760eef55a362b/lib/polish/proxies.rb#L24-L29
4,486
thelabtech/questionnaire
app/models/qe/question.rb
Qe.Question.set_response
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?('.') objects = object_name.split('.') object = eval("app." + objects[0..-2].join('.') + ".create_" + objects.last) eval("app." + objects[0..-2].join('.')).reload end end unless responses(app) == values value = ActiveRecord::Base.connection.quote_string(values.first) if self.is_a?(DateField) && value.present? begin value = Date.strptime(value, (I18n.t 'date.formats.default')) rescue raise "invalid date - " + value.inspect end end object.update_attribute(attribute_name, value) end # else # raise object_name.inspect + ' == ' + attribute_name.inspect # end else @answers ||= [] @mark_for_destroy ||= [] # go through existing answers (in reverse order, as we delete) (@answers.length - 1).downto(0) do |index| # reject: skip over responses that are unchanged unless values.reject! {|value| value == @answers[index]} # remove any answers that don't match the posted values @mark_for_destroy << @answers[index] # destroy from database later @answers.delete_at(index) end end # insert any new answers for value in values if @mark_for_destroy.empty? answer = Answer.new(:question_id => self.id) else # re-use marked answers (an update vs. a delete+insert) answer = @mark_for_destroy.pop end answer.set(value) @answers << answer end end end
ruby
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?('.') objects = object_name.split('.') object = eval("app." + objects[0..-2].join('.') + ".create_" + objects.last) eval("app." + objects[0..-2].join('.')).reload end end unless responses(app) == values value = ActiveRecord::Base.connection.quote_string(values.first) if self.is_a?(DateField) && value.present? begin value = Date.strptime(value, (I18n.t 'date.formats.default')) rescue raise "invalid date - " + value.inspect end end object.update_attribute(attribute_name, value) end # else # raise object_name.inspect + ' == ' + attribute_name.inspect # end else @answers ||= [] @mark_for_destroy ||= [] # go through existing answers (in reverse order, as we delete) (@answers.length - 1).downto(0) do |index| # reject: skip over responses that are unchanged unless values.reject! {|value| value == @answers[index]} # remove any answers that don't match the posted values @mark_for_destroy << @answers[index] # destroy from database later @answers.delete_at(index) end end # insert any new answers for value in values if @mark_for_destroy.empty? answer = Answer.new(:question_id => self.id) else # re-use marked answers (an update vs. a delete+insert) answer = @mark_for_destroy.pop end answer.set(value) @answers << answer end end end
[ "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?", "(", "'.'", ")", "objects", "=", "object_name", ".", "split", "(", "'.'", ")", "object", "=", "eval", "(", "\"app.\"", "+", "objects", "[", "0", "..", "-", "2", "]", ".", "join", "(", "'.'", ")", "+", "\".create_\"", "+", "objects", ".", "last", ")", "eval", "(", "\"app.\"", "+", "objects", "[", "0", "..", "-", "2", "]", ".", "join", "(", "'.'", ")", ")", ".", "reload", "end", "end", "unless", "responses", "(", "app", ")", "==", "values", "value", "=", "ActiveRecord", "::", "Base", ".", "connection", ".", "quote_string", "(", "values", ".", "first", ")", "if", "self", ".", "is_a?", "(", "DateField", ")", "&&", "value", ".", "present?", "begin", "value", "=", "Date", ".", "strptime", "(", "value", ",", "(", "I18n", ".", "t", "'date.formats.default'", ")", ")", "rescue", "raise", "\"invalid date - \"", "+", "value", ".", "inspect", "end", "end", "object", ".", "update_attribute", "(", "attribute_name", ",", "value", ")", "end", "# else", "# raise object_name.inspect + ' == ' + attribute_name.inspect", "# end", "else", "@answers", "||=", "[", "]", "@mark_for_destroy", "||=", "[", "]", "# go through existing answers (in reverse order, as we delete)", "(", "@answers", ".", "length", "-", "1", ")", ".", "downto", "(", "0", ")", "do", "|", "index", "|", "# reject: skip over responses that are unchanged", "unless", "values", ".", "reject!", "{", "|", "value", "|", "value", "==", "@answers", "[", "index", "]", "}", "# remove any answers that don't match the posted values", "@mark_for_destroy", "<<", "@answers", "[", "index", "]", "# destroy from database later ", "@answers", ".", "delete_at", "(", "index", ")", "end", "end", "# insert any new answers", "for", "value", "in", "values", "if", "@mark_for_destroy", ".", "empty?", "answer", "=", "Answer", ".", "new", "(", ":question_id", "=>", "self", ".", "id", ")", "else", "# re-use marked answers (an update vs. a delete+insert)", "answer", "=", "@mark_for_destroy", ".", "pop", "end", "answer", ".", "set", "(", "value", ")", "@answers", "<<", "answer", "end", "end", "end" ]
set answers from posted response
[ "set", "answers", "from", "posted", "response" ]
02eb47cbcda8cca28a5db78e18623d0957aa2c9b
https://github.com/thelabtech/questionnaire/blob/02eb47cbcda8cca28a5db78e18623d0957aa2c9b/app/models/qe/question.rb#L126-L177
4,487
thelabtech/questionnaire
app/models/qe/question.rb
Qe.Question.save_response
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 answer in @mark_for_destroy answer.destroy end @mark_for_destroy.clear end rescue TypeError raise answer.inspect end
ruby
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 answer in @mark_for_destroy answer.destroy end @mark_for_destroy.clear end rescue TypeError raise answer.inspect end
[ "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", "answer", "in", "@mark_for_destroy", "answer", ".", "destroy", "end", "@mark_for_destroy", ".", "clear", "end", "rescue", "TypeError", "raise", "answer", ".", "inspect", "end" ]
save this question's @answers to database
[ "save", "this", "question", "s" ]
02eb47cbcda8cca28a5db78e18623d0957aa2c9b
https://github.com/thelabtech/questionnaire/blob/02eb47cbcda8cca28a5db78e18623d0957aa2c9b/app/models/qe/question.rb#L185-L204
4,488
thelabtech/questionnaire
app/models/qe/question.rb
Qe.Question.has_response?
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?(Answer) ? answer.value : answer return true if (value.is_a?(FalseClass) && value === false) || value.present? end return false end
ruby
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?(Answer) ? answer.value : answer return true if (value.is_a?(FalseClass) && value === false) || value.present? end return false end
[ "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?", "(", "Answer", ")", "?", "answer", ".", "value", ":", "answer", "return", "true", "if", "(", "value", ".", "is_a?", "(", "FalseClass", ")", "&&", "value", "===", "false", ")", "||", "value", ".", "present?", "end", "return", "false", "end" ]
has any sort of non-empty response?
[ "has", "any", "sort", "of", "non", "-", "empty", "response?" ]
02eb47cbcda8cca28a5db78e18623d0957aa2c9b
https://github.com/thelabtech/questionnaire/blob/02eb47cbcda8cca28a5db78e18623d0957aa2c9b/app/models/qe/question.rb#L207-L219
4,489
postmodern/chars
lib/chars/char_set.rb
Chars.CharSet.<<
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") end end
ruby
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") end end
[ "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\"", ")", "end", "end" ]
Adds a character to the set. @param [String, Integer] other The character(s) or byte to add. @return [CharSet] The modified character set. @raise [TypeError] The argument was not a {String} or {Integer}. @since 0.2.1
[ "Adds", "a", "character", "to", "the", "set", "." ]
bc28b59da07c8310abb15cb9d61cacc30e86ffb9
https://github.com/postmodern/chars/blob/bc28b59da07c8310abb15cb9d61cacc30e86ffb9/lib/chars/char_set.rb#L57-L73
4,490
postmodern/chars
lib/chars/char_set.rb
Chars.CharSet.include_char?
def include_char?(char) unless char.empty? @chars.has_value?(char) || include_byte?(char_to_byte(char)) else false end end
ruby
def include_char?(char) unless char.empty? @chars.has_value?(char) || include_byte?(char_to_byte(char)) else false end end
[ "def", "include_char?", "(", "char", ")", "unless", "char", ".", "empty?", "@chars", ".", "has_value?", "(", "char", ")", "||", "include_byte?", "(", "char_to_byte", "(", "char", ")", ")", "else", "false", "end", "end" ]
Determines if a character is contained within the character set. @param [String] char The character to search for. @return [Boolean] Specifies whether the character is contained within the character set.
[ "Determines", "if", "a", "character", "is", "contained", "within", "the", "character", "set", "." ]
bc28b59da07c8310abb15cb9d61cacc30e86ffb9
https://github.com/postmodern/chars/blob/bc28b59da07c8310abb15cb9d61cacc30e86ffb9/lib/chars/char_set.rb#L91-L97
4,491
postmodern/chars
lib/chars/char_set.rb
Chars.CharSet.each_random_char
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
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
[ "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" ]
Pass random characters to a given block. @param [Integer] n Specifies how many times to pass a random character to the block. @yield [char] The block will receive the random characters. @yieldparam [String] char The random character from the character set. @return [Enumerator] If no block is given, an enumerator object will be returned.
[ "Pass", "random", "characters", "to", "a", "given", "block", "." ]
bc28b59da07c8310abb15cb9d61cacc30e86ffb9
https://github.com/postmodern/chars/blob/bc28b59da07c8310abb15cb9d61cacc30e86ffb9/lib/chars/char_set.rb#L215-L219
4,492
postmodern/chars
lib/chars/char_set.rb
Chars.CharSet.random_bytes
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
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
[ "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" ]
Creates an Array of random bytes from the character set. @param [Integer, Array, Range] length The length of the Array of random bytes. @return [Array<Integer>] The randomly selected bytes.
[ "Creates", "an", "Array", "of", "random", "bytes", "from", "the", "character", "set", "." ]
bc28b59da07c8310abb15cb9d61cacc30e86ffb9
https://github.com/postmodern/chars/blob/bc28b59da07c8310abb15cb9d61cacc30e86ffb9/lib/chars/char_set.rb#L230-L236
4,493
postmodern/chars
lib/chars/char_set.rb
Chars.CharSet.random_distinct_bytes
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
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
[ "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" ]
Creates an Array of random non-repeating bytes from the character set. @param [Integer, Array, Range] length The length of the Array of random non-repeating bytes. @return [Array<Integer>] The randomly selected non-repeating bytes.
[ "Creates", "an", "Array", "of", "random", "non", "-", "repeating", "bytes", "from", "the", "character", "set", "." ]
bc28b59da07c8310abb15cb9d61cacc30e86ffb9
https://github.com/postmodern/chars/blob/bc28b59da07c8310abb15cb9d61cacc30e86ffb9/lib/chars/char_set.rb#L247-L253
4,494
postmodern/chars
lib/chars/char_set.rb
Chars.CharSet.strings_in
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,&block) return found end min_length = options.fetch(:length,4) return if data.length < min_length index = 0 while index <= (data.length - min_length) if self === data[index,min_length] sub_index = (index + min_length) while self.include_char?(data[sub_index,1]) sub_index += 1 end match = data[index...sub_index] case block.arity when 2 yield match, index else yield match end index = sub_index else index += 1 end end end
ruby
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,&block) return found end min_length = options.fetch(:length,4) return if data.length < min_length index = 0 while index <= (data.length - min_length) if self === data[index,min_length] sub_index = (index + min_length) while self.include_char?(data[sub_index,1]) sub_index += 1 end match = data[index...sub_index] case block.arity when 2 yield match, index else yield match end index = sub_index else index += 1 end end end
[ "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", ",", "block", ")", "return", "found", "end", "min_length", "=", "options", ".", "fetch", "(", ":length", ",", "4", ")", "return", "if", "data", ".", "length", "<", "min_length", "index", "=", "0", "while", "index", "<=", "(", "data", ".", "length", "-", "min_length", ")", "if", "self", "===", "data", "[", "index", ",", "min_length", "]", "sub_index", "=", "(", "index", "+", "min_length", ")", "while", "self", ".", "include_char?", "(", "data", "[", "sub_index", ",", "1", "]", ")", "sub_index", "+=", "1", "end", "match", "=", "data", "[", "index", "...", "sub_index", "]", "case", "block", ".", "arity", "when", "2", "yield", "match", ",", "index", "else", "yield", "match", "end", "index", "=", "sub_index", "else", "index", "+=", "1", "end", "end", "end" ]
Finds sub-strings within given data that are made of characters within the character set. @param [String] data The data to find sub-strings within. @param [Hash] options Additional options. @option options [Integer] :length (4) The minimum length of sub-strings found within the given data. @option options [Boolean] :offsets (false) Specifies whether to return a Hash of offsets and matched sub-strings within the data, or to just return the matched sub-strings themselves. @yield [match,(index)] The given block will be passed every matched sub-string, and the optional index. @yield [String] match A sub-string containing the characters from the character set. @yield [Integer] index The index the sub-string was found at. @return [Array, Hash] If no block is given, an Array or Hash of sub-strings is returned.
[ "Finds", "sub", "-", "strings", "within", "given", "data", "that", "are", "made", "of", "characters", "within", "the", "character", "set", "." ]
bc28b59da07c8310abb15cb9d61cacc30e86ffb9
https://github.com/postmodern/chars/blob/bc28b59da07c8310abb15cb9d61cacc30e86ffb9/lib/chars/char_set.rb#L345-L386
4,495
sportngin/hasoffers
lib/has_offers_model.rb
HasOffersModel.ClassMethods.has_offers_model
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.success? if response.data.is_a? Hash # return_object is true self.has_offer_id = response.data[has_offers_class_name]["id"].to_i else # return_object is false self.has_offer_id = response.data.to_i end end check_for_errors(response) end end define_method("has_offers_update") do if respond_to?(:has_offer_id) and has_offer_id response = has_offers_class.update(has_offer_id, has_offers_params) check_for_errors(response) end end define_method("check_for_errors") do |response| unless response.success? response.error_messages.each do |error_message| new_error_message = "HasOffers API Error: #{error_message}" if self.errors.respond_to?(:add_to_base) self.errors.add_to_base new_error_message else self.errors.add :base, new_error_message end end end response.success? end end end
ruby
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.success? if response.data.is_a? Hash # return_object is true self.has_offer_id = response.data[has_offers_class_name]["id"].to_i else # return_object is false self.has_offer_id = response.data.to_i end end check_for_errors(response) end end define_method("has_offers_update") do if respond_to?(:has_offer_id) and has_offer_id response = has_offers_class.update(has_offer_id, has_offers_params) check_for_errors(response) end end define_method("check_for_errors") do |response| unless response.success? response.error_messages.each do |error_message| new_error_message = "HasOffers API Error: #{error_message}" if self.errors.respond_to?(:add_to_base) self.errors.add_to_base new_error_message else self.errors.add :base, new_error_message end end end response.success? end end end
[ "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", ".", "success?", "if", "response", ".", "data", ".", "is_a?", "Hash", "# return_object is true", "self", ".", "has_offer_id", "=", "response", ".", "data", "[", "has_offers_class_name", "]", "[", "\"id\"", "]", ".", "to_i", "else", "# return_object is false", "self", ".", "has_offer_id", "=", "response", ".", "data", ".", "to_i", "end", "end", "check_for_errors", "(", "response", ")", "end", "end", "define_method", "(", "\"has_offers_update\"", ")", "do", "if", "respond_to?", "(", ":has_offer_id", ")", "and", "has_offer_id", "response", "=", "has_offers_class", ".", "update", "(", "has_offer_id", ",", "has_offers_params", ")", "check_for_errors", "(", "response", ")", "end", "end", "define_method", "(", "\"check_for_errors\"", ")", "do", "|", "response", "|", "unless", "response", ".", "success?", "response", ".", "error_messages", ".", "each", "do", "|", "error_message", "|", "new_error_message", "=", "\"HasOffers API Error: #{error_message}\"", "if", "self", ".", "errors", ".", "respond_to?", "(", ":add_to_base", ")", "self", ".", "errors", ".", "add_to_base", "new_error_message", "else", "self", ".", "errors", ".", "add", ":base", ",", "new_error_message", "end", "end", "end", "response", ".", "success?", "end", "end", "end" ]
requires that your model has the column has_offer_id requires that you implement the method has_offers_params within your model
[ "requires", "that", "your", "model", "has", "the", "column", "has_offer_id", "requires", "that", "you", "implement", "the", "method", "has_offers_params", "within", "your", "model" ]
4127fc0c9a5362eb6a4e4945f8e8762fa3e18756
https://github.com/sportngin/hasoffers/blob/4127fc0c9a5362eb6a4e4945f8e8762fa3e18756/lib/has_offers_model.rb#L11-L56
4,496
rkday/ruby-diameter
lib/diameter/avp.rb
Diameter.AVP.inner_avps
def inner_avps(name) code, _type, _vendor = AVPNames.get(name) grouped_value.select { |a| a.code == code } end
ruby
def inner_avps(name) code, _type, _vendor = AVPNames.get(name) grouped_value.select { |a| a.code == code } end
[ "def", "inner_avps", "(", "name", ")", "code", ",", "_type", ",", "_vendor", "=", "AVPNames", ".", "get", "(", "name", ")", "grouped_value", ".", "select", "{", "|", "a", "|", "a", ".", "code", "==", "code", "}", "end" ]
For a grouped AVP, returns all AVPs it contains with this name. @param [String] name The AVP name @return [Array<AVP>]
[ "For", "a", "grouped", "AVP", "returns", "all", "AVPs", "it", "contains", "with", "this", "name", "." ]
83def68f67cf660aa227eac4c74719dc98aacab2
https://github.com/rkday/ruby-diameter/blob/83def68f67cf660aa227eac4c74719dc98aacab2/lib/diameter/avp.rb#L205-L209
4,497
rkday/ruby-diameter
lib/diameter/avp.rb
Diameter.AVP.ip_address=
def ip_address=(value) bytes = if value.ipv4? [1].pack('n') else [2].pack('n') end bytes += value.hton @content = bytes end
ruby
def ip_address=(value) bytes = if value.ipv4? [1].pack('n') else [2].pack('n') end bytes += value.hton @content = bytes end
[ "def", "ip_address", "=", "(", "value", ")", "bytes", "=", "if", "value", ".", "ipv4?", "[", "1", "]", ".", "pack", "(", "'n'", ")", "else", "[", "2", "]", ".", "pack", "(", "'n'", ")", "end", "bytes", "+=", "value", ".", "hton", "@content", "=", "bytes", "end" ]
Sets this AVP's byte data to an Address. @param [IPAddr] value @return [void]
[ "Sets", "this", "AVP", "s", "byte", "data", "to", "an", "Address", "." ]
83def68f67cf660aa227eac4c74719dc98aacab2
https://github.com/rkday/ruby-diameter/blob/83def68f67cf660aa227eac4c74719dc98aacab2/lib/diameter/avp.rb#L340-L349
4,498
sleewoo/minispec
lib/minispec/api/instance/mocks/doubles.rb
MiniSpec.InstanceAPI.double
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(object, h)} rest.each {|s| stub(object, s, &proc)} object end
ruby
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(object, h)} rest.each {|s| stub(object, s, &proc)} object end
[ "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", "(", "object", ",", "h", ")", "}", "rest", ".", "each", "{", "|", "s", "|", "stub", "(", "object", ",", "s", ",", "proc", ")", "}", "object", "end" ]
creates a double object. if one or more arguments given, first argument will be used as name, unless it is a Hash. arguments that goes after first one are treated as stubs. @example create a double that will respond to `color` and reported as :apple apple = double(:apple, :color) { 'Red' } apple.color # => Red @example injecting a double into a real battle and expecting it to receive some messages user = double(:user, :name, :address) expect(user).to_receive(:name, :address) Shipping.new.get_address_for(user) @example spy on a double user = double(:user, :name, :address) Shipping.new.get_address_for(user) assert(user).received(:name, :address)
[ "creates", "a", "double", "object", ".", "if", "one", "or", "more", "arguments", "given", "first", "argument", "will", "be", "used", "as", "name", "unless", "it", "is", "a", "Hash", ".", "arguments", "that", "goes", "after", "first", "one", "are", "treated", "as", "stubs", "." ]
6dcdacd041cc031c21f2fe70b6e5b22c6af636c5
https://github.com/sleewoo/minispec/blob/6dcdacd041cc031c21f2fe70b6e5b22c6af636c5/lib/minispec/api/instance/mocks/doubles.rb#L22-L34
4,499
simon-watiau/qonto_ofx
lib/converter.rb
QontoOfx.Converter.convert
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.parent.namespace = nil organization['bank_accounts'].each do |bank_account| xml.STMTTRNRS do xml.TRNUID 1 add_status_block xml xml.STMTRS do xml.CURDEF 'EUR' add_bankacctfrom_block xml, bank_account xml.BANKTRANLIST do process_transactions xml, bank_account end xml.LEDGERBAL do xml.BALAMT bank_account['balance'] xml.DTASOF Time.now.strftime('%Y%m%d%H%M%S') end end end end end end move_to_first_position(builder, '//DTEND') move_to_first_position(builder, '//DTSTART') result = builder.to_xml raise 'generation failed (invalid OFX)' unless @ofx_validator.valid? result result = result.gsub( 'ofx:OFX', 'OFX' ).gsub(' xmlns:ofx="http://ofx.net/types/2003/04"', '') if remove_ns result end
ruby
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.parent.namespace = nil organization['bank_accounts'].each do |bank_account| xml.STMTTRNRS do xml.TRNUID 1 add_status_block xml xml.STMTRS do xml.CURDEF 'EUR' add_bankacctfrom_block xml, bank_account xml.BANKTRANLIST do process_transactions xml, bank_account end xml.LEDGERBAL do xml.BALAMT bank_account['balance'] xml.DTASOF Time.now.strftime('%Y%m%d%H%M%S') end end end end end end move_to_first_position(builder, '//DTEND') move_to_first_position(builder, '//DTSTART') result = builder.to_xml raise 'generation failed (invalid OFX)' unless @ofx_validator.valid? result result = result.gsub( 'ofx:OFX', 'OFX' ).gsub(' xmlns:ofx="http://ofx.net/types/2003/04"', '') if remove_ns result end
[ "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", ".", "parent", ".", "namespace", "=", "nil", "organization", "[", "'bank_accounts'", "]", ".", "each", "do", "|", "bank_account", "|", "xml", ".", "STMTTRNRS", "do", "xml", ".", "TRNUID", "1", "add_status_block", "xml", "xml", ".", "STMTRS", "do", "xml", ".", "CURDEF", "'EUR'", "add_bankacctfrom_block", "xml", ",", "bank_account", "xml", ".", "BANKTRANLIST", "do", "process_transactions", "xml", ",", "bank_account", "end", "xml", ".", "LEDGERBAL", "do", "xml", ".", "BALAMT", "bank_account", "[", "'balance'", "]", "xml", ".", "DTASOF", "Time", ".", "now", ".", "strftime", "(", "'%Y%m%d%H%M%S'", ")", "end", "end", "end", "end", "end", "end", "move_to_first_position", "(", "builder", ",", "'//DTEND'", ")", "move_to_first_position", "(", "builder", ",", "'//DTSTART'", ")", "result", "=", "builder", ".", "to_xml", "raise", "'generation failed (invalid OFX)'", "unless", "@ofx_validator", ".", "valid?", "result", "result", "=", "result", ".", "gsub", "(", "'ofx:OFX'", ",", "'OFX'", ")", ".", "gsub", "(", "' xmlns:ofx=\"http://ofx.net/types/2003/04\"'", ",", "''", ")", "if", "remove_ns", "result", "end" ]
valid_ofx = false removes the namespaces
[ "valid_ofx", "=", "false", "removes", "the", "namespaces" ]
16b849ab4df1522801a3d262a79270998b5ec6d3
https://github.com/simon-watiau/qonto_ofx/blob/16b849ab4df1522801a3d262a79270998b5ec6d3/lib/converter.rb#L17-L60