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 list | docstring stringlengths 8 16k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 94 266 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
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 `true`, results will include a storage provider'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 | train |
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"... | 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 | train |
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",
",",... | 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 va... | [
"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 | train |
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"... | 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 | train |
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 `1`.
@option opts [Integer] :per_page A number of results per page. Default is `10... | [
"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 | train |
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 | train |
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 `1`.
@option opts [Integer] :per_page A number of results per page. Default is `100`.
@return [PaginatedVideoCollec... | [
"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 | train |
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 `1`.
@option opts [Integer] :per_page A number of results per page. Default is `100`.
@return ... | [
"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 | train |
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",
","... | 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 | train |
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.wr... | 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.wr... | [
"def",
"flush",
"begin",
"valid_existing_file?",
"(",
"@file",
")",
"raise",
"ReadOnlyThresholdsFile",
"if",
"@readonly",
"hash",
"=",
"current_hash",
"file",
"=",
"File",
".",
"open",
"(",
"@file",
",",
"'w+'",
")",
"raise",
"ThresholdAtomicLockFailure",
",",
"... | 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 | train |
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",
"results",
".",
"caps",
".",
"each",
"do",
"|",
"result",
"|",
"build... | 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 | train |
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 InvalidThreshol... | 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 InvalidThreshol... | [
"def",
"valid?",
"begin",
"self",
".",
"each",
"do",
"|",
"threshold",
"|",
"if",
"threshold",
".",
"respond_to?",
"(",
":valid?",
")",
"return",
"false",
"unless",
"threshold",
".",
"valid?",
"else",
"raise",
"InvalidThresholdsObject",
",",
"\"Container object ... | 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 | train |
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",
... | 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 | train |
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_... | 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 | train |
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",
".",
"t... | 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 | train |
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_... | 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 | train |
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",
"."... | Hash -> Integer | [
"Hash",
"-",
">",
"Integer"
] | e11c045a2bb9d578160b6bf4b7cd01745c086d76 | https://github.com/yoppi/backlog-api/blob/e11c045a2bb9d578160b6bf4b7cd01745c086d76/lib/backlog/api.rb#L115-L119 | train |
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... | 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... | [
"def",
"write",
"(",
"file_name",
",",
"options",
"=",
"{",
"}",
")",
"if",
"file_name",
".",
"is_a?",
"(",
"String",
")",
"w",
"=",
"NWrite",
".",
"new",
"(",
"self",
",",
"file_name",
",",
"options",
")",
"w",
".",
"write",
"@write_success",
"=",
... | 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.wr... | [
"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 | train |
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... | 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... | [
"def",
"read",
"(",
"string",
",",
"options",
"=",
"{",
"}",
")",
"if",
"string",
".",
"is_a?",
"(",
"String",
")",
"@string",
"=",
"string",
"r",
"=",
"NRead",
".",
"new",
"(",
"string",
",",
"options",
")",
"if",
"r",
".",
"success",
"@read_succe... | 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 | train |
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 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 | train |
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_derefere... | 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_derefere... | [
"def",
"rubylog_unify",
"other",
"if",
"@bound",
"rubylog_dereference",
".",
"rubylog_unify",
"(",
"other",
")",
"do",
"yield",
"end",
"else",
"other",
"=",
"other",
".",
"rubylog_dereference",
"if",
"other",
".",
"is_a?",
"Rubylog",
"::",
"Variable",
"(",
"yi... | 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 equali... | [
"Unifies",
"the",
"receiver",
"with",
"another",
"value",
"."
] | bd53971b6bc6a9459b79257c925bdc795bf8c04b | https://github.com/cie/rubylog/blob/bd53971b6bc6a9459b79257c925bdc795bf8c04b/lib/rubylog/variable.rb#L63-L98 | train |
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",
{'refer... | ruby | def send_invite
return if self.email.blank?
application = self.applicant_answer_sheet
Notifier.deliver_notification(self.email,
application.email,
"Reference Invite",
{'refer... | [
"def",
"send_invite",
"return",
"if",
"self",
".",
"email",
".",
"blank?",
"application",
"=",
"self",
".",
"applicant_answer_sheet",
"Notifier",
".",
"deliver_notification",
"(",
"self",
".",
"email",
",",
"application",
".",
"email",
",",
"\"Reference Invite\"",... | send email invite | [
"send",
"email",
"invite"
] | 02eb47cbcda8cca28a5db78e18623d0957aa2c9b | https://github.com/thelabtech/questionnaire/blob/02eb47cbcda8cca28a5db78e18623d0957aa2c9b/app/models/qe/reference_sheet.rb#L77-L103 | train |
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",
")",
"+",
"(",
"clo... | 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 | train |
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",
"opts",
"[",
":scope",
"]",
"||=",
"\"basic netdisk super_msg\"",
"oauth_client",
".",
"auth_code",
".",
"authorize_url",
"(",
"scope",
":"... | =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... | [
"=",
"begin",
"rdoc",
"OAuth2",
"+",
"authorize_url",
"+"
] | 5eeecec67e402f9ea890049f5abf42f1ce3866f4 | https://github.com/lanrion/baidu/blob/5eeecec67e402f9ea890049f5abf42f1ce3866f4/lib/baidu/client.rb#L61-L66 | train |
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",
",",
... | =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 | train |
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!",
"e... | =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 | train |
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, vi... | 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, vi... | [
"def",
"stub",
"object",
",",
"stub",
",",
"visibility",
"=",
"nil",
",",
"&",
"proc",
"[",
"Symbol",
",",
"String",
",",
"Hash",
"]",
".",
"include?",
"(",
"stub",
".",
"class",
")",
"||",
"raise",
"(",
"ArgumentError",
",",
"'a Symbol, String or Hash e... | 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... | [
"stubbing",
"given",
"method",
"and",
"keeps",
"original",
"visibility"
] | 6dcdacd041cc031c21f2fe70b6e5b22c6af636c5 | https://github.com/sleewoo/minispec/blob/6dcdacd041cc031c21f2fe70b6e5b22c6af636c5/lib/minispec/api/instance/mocks/stubs.rb#L21-L36 | train |
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 | train |
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.expirat... | 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.expirat... | [
"def",
"to_request",
"card",
"=",
"{",
"number_token",
":",
"self",
".",
"number_token",
",",
"cardholder_name",
":",
"self",
".",
"cardholder_name",
",",
"security_code",
":",
"self",
".",
"security_code",
",",
"brand",
":",
"self",
".",
"brand",
",",
"expi... | 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 | train |
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}... | 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}... | [
"def",
"post_init",
"(",
"*",
"args",
")",
"logger",
".",
"info",
"\"got connection from #{remote_ip}\"",
"@lt2_delimiter",
"=",
"\"\\r\\n\"",
"@ircd",
"=",
"IRCD",
".",
"new",
"(",
"self",
",",
"options",
")",
"if",
"options",
"[",
":ssl",
"]",
"logger",
".... | 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 | train |
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... | 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... | [
"def",
"generate_ULA",
"(",
"mac",
",",
"subnet_id",
"=",
"0",
",",
"locally_assigned",
"=",
"true",
")",
"now",
"=",
"Time",
".",
"now",
".",
"utc",
"ntp_time",
"=",
"(",
"(",
"now",
".",
"to_i",
"+",
"2208988800",
")",
"<<",
"32",
")",
"+",
"now"... | 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",
... | 0426dbad801cf305129370fb991cd9785cdfeb71 | https://github.com/jamesotron/IPAddrExtensions/blob/0426dbad801cf305129370fb991cd9785cdfeb71/lib/ipaddr_extensions.rb#L495-L509 | train |
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... | 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... | [
"def",
"show_panel",
"@tab_name",
"=",
"params",
"[",
":panel_name",
"]",
"@panel_name",
"=",
"params",
"[",
":panel_name",
"]",
"==",
"\"properties\"",
"?",
"\"prop_sheet\"",
":",
"params",
"[",
":panel_name",
"]",
"@all_pages",
"=",
"@question_sheet",
".",
"pa... | 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 | train |
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 | train |
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,
... | 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,
... | [
"def",
"method_visibility",
"object",
",",
"method",
"{",
"public",
":",
":public_methods",
",",
"protected",
":",
":protected_methods",
",",
"private",
":",
":private_methods",
"}",
".",
"each_pair",
"do",
"|",
"v",
",",
"m",
"|",
"if",
"v",
"==",
":public"... | 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 | train |
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",
"... | 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 | train |
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",
... | 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 | train |
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 | train |
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%... | 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 | train |
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, v... | 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, v... | [
"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",
... | 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 | train |
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?('.')
... | 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?('.')
... | [
"def",
"set_response",
"(",
"values",
",",
"app",
")",
"values",
"=",
"Array",
".",
"wrap",
"(",
"values",
")",
"if",
"!",
"object_name",
".",
"blank?",
"and",
"!",
"attribute_name",
".",
"blank?",
"object",
"=",
"object_name",
"==",
"'application'",
"?",
... | 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 | train |
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 answe... | 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 answe... | [
"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!"... | 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 | train |
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?(Answe... | 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?(Answe... | [
"def",
"has_response?",
"(",
"answer_sheet",
"=",
"nil",
")",
"if",
"answer_sheet",
".",
"present?",
"answers",
"=",
"responses",
"(",
"answer_sheet",
")",
"else",
"answers",
"=",
"Answer",
".",
"where",
"(",
":question_id",
"=>",
"self",
".",
"id",
")",
"... | 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 | train |
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")
... | 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")
... | [
"def",
"<<",
"(",
"other",
")",
"case",
"other",
"when",
"String",
"other",
".",
"each_char",
"do",
"|",
"char",
"|",
"byte",
"=",
"char_to_byte",
"(",
"char",
")",
"@chars",
"[",
"byte",
"]",
"=",
"char",
"super",
"(",
"byte",
")",
"end",
"return",
... | 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 | train |
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 | train |
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, ... | [
"Pass",
"random",
"characters",
"to",
"a",
"given",
"block",
"."
] | bc28b59da07c8310abb15cb9d61cacc30e86ffb9 | https://github.com/postmodern/chars/blob/bc28b59da07c8310abb15cb9d61cacc30e86ffb9/lib/chars/char_set.rb#L215-L219 | train |
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",
")",
"{... | 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 | train |
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",
".... | 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 | train |
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... | 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... | [
"def",
"strings_in",
"(",
"data",
",",
"options",
"=",
"{",
"}",
",",
"&",
"block",
")",
"unless",
"block",
"if",
"options",
"[",
":offsets",
"]",
"found",
"=",
"{",
"}",
"block",
"=",
"lambda",
"{",
"|",
"offset",
",",
"substring",
"|",
"found",
"... | 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 opt... | [
"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 | train |
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.suc... | 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.suc... | [
"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"... | 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 | train |
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 | train |
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",
"=... | 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 | train |
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... | 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... | [
"def",
"double",
"*",
"args",
",",
"&",
"proc",
"name",
"=",
"args",
".",
"first",
".",
"is_a?",
"(",
"Hash",
")",
"?",
"nil",
":",
"args",
".",
"shift",
"object",
"=",
"Object",
".",
"new",
"object",
".",
"define_singleton_method",
"(",
":__ms__double... | 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 # => Re... | [
"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",
"treat... | 6dcdacd041cc031c21f2fe70b6e5b22c6af636c5 | https://github.com/sleewoo/minispec/blob/6dcdacd041cc031c21f2fe70b6e5b22c6af636c5/lib/minispec/api/instance/mocks/doubles.rb#L22-L34 | train |
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.p... | 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.p... | [
"def",
"convert",
"(",
"remove_ns",
"=",
"false",
")",
"organization",
"=",
"@gateway",
".",
"fetch_organization",
"[",
"'organization'",
"]",
"builder",
"=",
"Nokogiri",
"::",
"XML",
"::",
"Builder",
".",
"new",
"(",
"encoding",
":",
"'UTF-8'",
")",
"builde... | 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 | train |
netskin/ceph-ruby | lib/ceph-ruby/cluster.rb | CephRuby.Cluster.connect | def connect
log("connect")
ret = Lib::Rados.rados_connect(handle)
raise SystemCallError.new("connect to cluster failed", -ret) if ret < 0
end | ruby | def connect
log("connect")
ret = Lib::Rados.rados_connect(handle)
raise SystemCallError.new("connect to cluster failed", -ret) if ret < 0
end | [
"def",
"connect",
"log",
"(",
"\"connect\"",
")",
"ret",
"=",
"Lib",
"::",
"Rados",
".",
"rados_connect",
"(",
"handle",
")",
"raise",
"SystemCallError",
".",
"new",
"(",
"\"connect to cluster failed\"",
",",
"-",
"ret",
")",
"if",
"ret",
"<",
"0",
"end"
] | helper methods below | [
"helper",
"methods",
"below"
] | bf2023b450ffb8ba7b12e5847e475f0f8796d0c7 | https://github.com/netskin/ceph-ruby/blob/bf2023b450ffb8ba7b12e5847e475f0f8796d0c7/lib/ceph-ruby/cluster.rb#L38-L42 | train |
stereobooster/jshintrb | lib/jshintrb/jshinttask.rb | Jshintrb.JshintTask.define | def define # :nodoc:
actual_name = Hash === name ? name.keys.first : name
unless ::Rake.application.last_comment
desc "Run JShint"
end
task name do
unless js_file_list.empty?
result = Jshintrb::report(js_file_list, @options, @globals, STDERR)
if result.size >... | ruby | def define # :nodoc:
actual_name = Hash === name ? name.keys.first : name
unless ::Rake.application.last_comment
desc "Run JShint"
end
task name do
unless js_file_list.empty?
result = Jshintrb::report(js_file_list, @options, @globals, STDERR)
if result.size >... | [
"def",
"define",
"actual_name",
"=",
"Hash",
"===",
"name",
"?",
"name",
".",
"keys",
".",
"first",
":",
"name",
"unless",
"::",
"Rake",
".",
"application",
".",
"last_comment",
"desc",
"\"Run JShint\"",
"end",
"task",
"name",
"do",
"unless",
"js_file_list",... | Defines a new task, using the name +name+. | [
"Defines",
"a",
"new",
"task",
"using",
"the",
"name",
"+",
"name",
"+",
"."
] | 5ee7051e3c6df584ea7e020bcffd712ffbdb1b31 | https://github.com/stereobooster/jshintrb/blob/5ee7051e3c6df584ea7e020bcffd712ffbdb1b31/lib/jshintrb/jshinttask.rb#L52-L68 | train |
SSSaaS/sssa-ruby | lib/utils.rb | SSSA.Utils.split_ints | def split_ints(secret)
result = []
secret.split('').map { |x|
data = x.unpack("H*")[0]
"0"*(data.size % 2) + data
}.join("").scan(/.{1,64}/) { |segment|
result.push (segment+"0"*(64-segment.size)).hex
}
return ... | ruby | def split_ints(secret)
result = []
secret.split('').map { |x|
data = x.unpack("H*")[0]
"0"*(data.size % 2) + data
}.join("").scan(/.{1,64}/) { |segment|
result.push (segment+"0"*(64-segment.size)).hex
}
return ... | [
"def",
"split_ints",
"(",
"secret",
")",
"result",
"=",
"[",
"]",
"secret",
".",
"split",
"(",
"''",
")",
".",
"map",
"{",
"|",
"x",
"|",
"data",
"=",
"x",
".",
"unpack",
"(",
"\"H*\"",
")",
"[",
"0",
"]",
"\"0\"",
"*",
"(",
"data",
".",
"siz... | split_ints and merge_ints converts between string and integer array,
where the integer is right-padded until it fits a 256 bit integer. | [
"split_ints",
"and",
"merge_ints",
"converts",
"between",
"string",
"and",
"integer",
"array",
"where",
"the",
"integer",
"is",
"right",
"-",
"padded",
"until",
"it",
"fits",
"a",
"256",
"bit",
"integer",
"."
] | df65db5785d591630e4acdff7d2a65b52d2d9581 | https://github.com/SSSaaS/sssa-ruby/blob/df65db5785d591630e4acdff7d2a65b52d2d9581/lib/utils.rb#L19-L30 | train |
appirits/comable | core/app/models/comable/order.rb | Comable.Order.inherit! | def inherit!(order)
self.bill_address ||= order.bill_address
self.ship_address ||= order.ship_address
self.payment ||= order.payment
self.shipments = order.shipments if shipments.empty?
stated?(order.state) ? save! : next_state!
end | ruby | def inherit!(order)
self.bill_address ||= order.bill_address
self.ship_address ||= order.ship_address
self.payment ||= order.payment
self.shipments = order.shipments if shipments.empty?
stated?(order.state) ? save! : next_state!
end | [
"def",
"inherit!",
"(",
"order",
")",
"self",
".",
"bill_address",
"||=",
"order",
".",
"bill_address",
"self",
".",
"ship_address",
"||=",
"order",
".",
"ship_address",
"self",
".",
"payment",
"||=",
"order",
".",
"payment",
"self",
".",
"shipments",
"=",
... | Inherit from other Order | [
"Inherit",
"from",
"other",
"Order"
] | b0cf028da35ea9def1c675680e5e5293a969bebc | https://github.com/appirits/comable/blob/b0cf028da35ea9def1c675680e5e5293a969bebc/core/app/models/comable/order.rb#L98-L105 | train |
thelabtech/questionnaire | app/models/qe/element.rb | Qe.Element.duplicate | def duplicate(page, parent = nil)
new_element = self.class.new(self.attributes)
case parent.class.to_s
when ChoiceField
new_element.conditional_id = parent.id
when QuestionGrid, QuestionGridWithTotal
new_element.question_grid_id = parent.id
end
new_element.save(:valid... | ruby | def duplicate(page, parent = nil)
new_element = self.class.new(self.attributes)
case parent.class.to_s
when ChoiceField
new_element.conditional_id = parent.id
when QuestionGrid, QuestionGridWithTotal
new_element.question_grid_id = parent.id
end
new_element.save(:valid... | [
"def",
"duplicate",
"(",
"page",
",",
"parent",
"=",
"nil",
")",
"new_element",
"=",
"self",
".",
"class",
".",
"new",
"(",
"self",
".",
"attributes",
")",
"case",
"parent",
".",
"class",
".",
"to_s",
"when",
"ChoiceField",
"new_element",
".",
"condition... | copy an item and all it's children | [
"copy",
"an",
"item",
"and",
"all",
"it",
"s",
"children"
] | 02eb47cbcda8cca28a5db78e18623d0957aa2c9b | https://github.com/thelabtech/questionnaire/blob/02eb47cbcda8cca28a5db78e18623d0957aa2c9b/app/models/qe/element.rb#L116-L133 | train |
nazoking/rehtml | lib/rehtml/tokenizer.rb | REHTML.Tokenizer.decode | def decode(html)
html.gsub(ENTITIES::REGEXP){
if $1
if ENTITIES::MAP[$1]
ENTITIES::MAP[$1]
else
$&
end
elsif $2
[$2.to_i(10)].pack('U')
elsif $3
[$3.to_i(16)].pack('U')
else
$&
end
}
... | ruby | def decode(html)
html.gsub(ENTITIES::REGEXP){
if $1
if ENTITIES::MAP[$1]
ENTITIES::MAP[$1]
else
$&
end
elsif $2
[$2.to_i(10)].pack('U')
elsif $3
[$3.to_i(16)].pack('U')
else
$&
end
}
... | [
"def",
"decode",
"(",
"html",
")",
"html",
".",
"gsub",
"(",
"ENTITIES",
"::",
"REGEXP",
")",
"{",
"if",
"$1",
"if",
"ENTITIES",
"::",
"MAP",
"[",
"$1",
"]",
"ENTITIES",
"::",
"MAP",
"[",
"$1",
"]",
"else",
"$&",
"end",
"elsif",
"$2",
"[",
"$2",
... | decode html entity | [
"decode",
"html",
"entity"
] | 4bf9016f5325becd955db777d832a2c90f3407ac | https://github.com/nazoking/rehtml/blob/4bf9016f5325becd955db777d832a2c90f3407ac/lib/rehtml/tokenizer.rb#L42-L58 | train |
thelabtech/questionnaire | app/models/qe/notifier.rb | Qe.Notifier.notification | def notification(p_recipients, p_from, template_name, template_params = {}, options = {})
email_template = EmailTemplate.find_by_name(template_name)
if email_template.nil?
raise "Email Template #{template_name} could not be found"
else
@recipients = p_recipients
@from = p_... | ruby | def notification(p_recipients, p_from, template_name, template_params = {}, options = {})
email_template = EmailTemplate.find_by_name(template_name)
if email_template.nil?
raise "Email Template #{template_name} could not be found"
else
@recipients = p_recipients
@from = p_... | [
"def",
"notification",
"(",
"p_recipients",
",",
"p_from",
",",
"template_name",
",",
"template_params",
"=",
"{",
"}",
",",
"options",
"=",
"{",
"}",
")",
"email_template",
"=",
"EmailTemplate",
".",
"find_by_name",
"(",
"template_name",
")",
"if",
"email_tem... | call Notifier.deliver_notification | [
"call",
"Notifier",
".",
"deliver_notification"
] | 02eb47cbcda8cca28a5db78e18623d0957aa2c9b | https://github.com/thelabtech/questionnaire/blob/02eb47cbcda8cca28a5db78e18623d0957aa2c9b/app/models/qe/notifier.rb#L5-L16 | train |
vchs/ruby_vcloud_sdk | lib/ruby_vcloud_sdk/catalog.rb | VCloudSdk.Catalog.find_item | def find_item(name, item_type = nil)
link = find_item_link(name)
item = VCloudSdk::CatalogItem.new(@session, link)
check_item_type(item, item_type)
item
end | ruby | def find_item(name, item_type = nil)
link = find_item_link(name)
item = VCloudSdk::CatalogItem.new(@session, link)
check_item_type(item, item_type)
item
end | [
"def",
"find_item",
"(",
"name",
",",
"item_type",
"=",
"nil",
")",
"link",
"=",
"find_item_link",
"(",
"name",
")",
"item",
"=",
"VCloudSdk",
"::",
"CatalogItem",
".",
"new",
"(",
"@session",
",",
"link",
")",
"check_item_type",
"(",
"item",
",",
"item_... | Find catalog item from catalog by name and type.
If item_type is set to nil, returns catalog item as long as its name match.
Raises an exception if catalog is not found.
Raises ObjectNotFoundError if an item matching the name and type is not found.
Otherwise, returns the catalog item. | [
"Find",
"catalog",
"item",
"from",
"catalog",
"by",
"name",
"and",
"type",
".",
"If",
"item_type",
"is",
"set",
"to",
"nil",
"returns",
"catalog",
"item",
"as",
"long",
"as",
"its",
"name",
"match",
".",
"Raises",
"an",
"exception",
"if",
"catalog",
"is"... | 92d56db4fea4321068ab300ca60bcc6cec3e459b | https://github.com/vchs/ruby_vcloud_sdk/blob/92d56db4fea4321068ab300ca60bcc6cec3e459b/lib/ruby_vcloud_sdk/catalog.rb#L40-L45 | train |
qw3/getnet_api | lib/getnet_api/configure.rb | GetnetApi.Configure.set_endpoint | def set_endpoint
if ambiente == :producao
return GetnetApi::Configure::URL[:producao]
elsif ambiente == :homologacao
return GetnetApi::Configure::URL[:homologacao]
else
return GetnetApi::Configure::URL[:sandbox]
end
end | ruby | def set_endpoint
if ambiente == :producao
return GetnetApi::Configure::URL[:producao]
elsif ambiente == :homologacao
return GetnetApi::Configure::URL[:homologacao]
else
return GetnetApi::Configure::URL[:sandbox]
end
end | [
"def",
"set_endpoint",
"if",
"ambiente",
"==",
":producao",
"return",
"GetnetApi",
"::",
"Configure",
"::",
"URL",
"[",
":producao",
"]",
"elsif",
"ambiente",
"==",
":homologacao",
"return",
"GetnetApi",
"::",
"Configure",
"::",
"URL",
"[",
":homologacao",
"]",
... | Retornar a url conforme o ambiente | [
"Retornar",
"a",
"url",
"conforme",
"o",
"ambiente"
] | 94cbda66aab03d83ea38bc5325ea2a02a639e922 | https://github.com/qw3/getnet_api/blob/94cbda66aab03d83ea38bc5325ea2a02a639e922/lib/getnet_api/configure.rb#L90-L98 | train |
kissmetrics/uri_signer | lib/uri_signer/request_signature.rb | UriSigner.RequestSignature.signature | def signature
core_signature = [self.http_method, self.encoded_base_uri]
core_signature << self.encoded_query_params if self.query_params?
core_signature.join(self.separator)
end | ruby | def signature
core_signature = [self.http_method, self.encoded_base_uri]
core_signature << self.encoded_query_params if self.query_params?
core_signature.join(self.separator)
end | [
"def",
"signature",
"core_signature",
"=",
"[",
"self",
".",
"http_method",
",",
"self",
".",
"encoded_base_uri",
"]",
"core_signature",
"<<",
"self",
".",
"encoded_query_params",
"if",
"self",
".",
"query_params?",
"core_signature",
".",
"join",
"(",
"self",
".... | Create a new RequestSignature instance
@param http_method [String] The HTTP method from the request (GET, POST, PUT, or DELETE)
@param base_uri [String] The base URI of the request. This is everything except the query string params
@param query_params [Hash] A hash of the provided query string params
It's require... | [
"Create",
"a",
"new",
"RequestSignature",
"instance"
] | 3169df476c7f8ed88c5af6ade2c826ad3e5fa2a3 | https://github.com/kissmetrics/uri_signer/blob/3169df476c7f8ed88c5af6ade2c826ad3e5fa2a3/lib/uri_signer/request_signature.rb#L57-L61 | train |
kissmetrics/uri_signer | lib/uri_signer/query_hash_parser.rb | UriSigner.QueryHashParser.to_s | def to_s
parts = @query_hash.sort.inject([]) do |arr, (key,value)|
if value.kind_of?(Array)
value.each do |nested|
arr << "%s=%s" % [key, nested]
end
else
arr << "%s=%s" % [key, value]
end
arr
end
parts.join('&')
end | ruby | def to_s
parts = @query_hash.sort.inject([]) do |arr, (key,value)|
if value.kind_of?(Array)
value.each do |nested|
arr << "%s=%s" % [key, nested]
end
else
arr << "%s=%s" % [key, value]
end
arr
end
parts.join('&')
end | [
"def",
"to_s",
"parts",
"=",
"@query_hash",
".",
"sort",
".",
"inject",
"(",
"[",
"]",
")",
"do",
"|",
"arr",
",",
"(",
"key",
",",
"value",
")",
"|",
"if",
"value",
".",
"kind_of?",
"(",
"Array",
")",
"value",
".",
"each",
"do",
"|",
"nested",
... | Creates a new QueryHashParser instance
@param query_hash [Hash] A hash of key/values to turn into a query stringo
@return [void]
Returns the hash (key/values) as an ordered query string. This joins the keys and values, and then
joins it all with the ampersand. This is not escaped
@return [String] | [
"Creates",
"a",
"new",
"QueryHashParser",
"instance"
] | 3169df476c7f8ed88c5af6ade2c826ad3e5fa2a3 | https://github.com/kissmetrics/uri_signer/blob/3169df476c7f8ed88c5af6ade2c826ad3e5fa2a3/lib/uri_signer/query_hash_parser.rb#L28-L40 | train |
plexus/macros | lib/macros/sexp.rb | Macros.Sexp.sfind | def sfind(sexp, specs)
specs.inject(sexp) do |node, spec|
return NotFound if node.nil?
if spec.is_a?(Symbol) && node.type == spec
node
elsif spec.is_a?(Integer) && node.children.length > spec
node.children[spec]
elsif spec.is_a?(Array)
node.children.g... | ruby | def sfind(sexp, specs)
specs.inject(sexp) do |node, spec|
return NotFound if node.nil?
if spec.is_a?(Symbol) && node.type == spec
node
elsif spec.is_a?(Integer) && node.children.length > spec
node.children[spec]
elsif spec.is_a?(Array)
node.children.g... | [
"def",
"sfind",
"(",
"sexp",
",",
"specs",
")",
"specs",
".",
"inject",
"(",
"sexp",
")",
"do",
"|",
"node",
",",
"spec",
"|",
"return",
"NotFound",
"if",
"node",
".",
"nil?",
"if",
"spec",
".",
"is_a?",
"(",
"Symbol",
")",
"&&",
"node",
".",
"ty... | Traverse into sexp by type and child position | [
"Traverse",
"into",
"sexp",
"by",
"type",
"and",
"child",
"position"
] | 5a45c8f452695643727383d6e3c0004eb3a1146e | https://github.com/plexus/macros/blob/5a45c8f452695643727383d6e3c0004eb3a1146e/lib/macros/sexp.rb#L11-L27 | train |
sleewoo/minispec | lib/minispec/api/class/helpers.rb | MiniSpec.ClassAPI.helper | def helper helper, opts = {}, &proc
proc || raise(ArgumentError, 'block is missing')
helpers[helper] = [proc, opts]
end | ruby | def helper helper, opts = {}, &proc
proc || raise(ArgumentError, 'block is missing')
helpers[helper] = [proc, opts]
end | [
"def",
"helper",
"helper",
",",
"opts",
"=",
"{",
"}",
",",
"&",
"proc",
"proc",
"||",
"raise",
"(",
"ArgumentError",
",",
"'block is missing'",
")",
"helpers",
"[",
"helper",
"]",
"=",
"[",
"proc",
",",
"opts",
"]",
"end"
] | define custom assertion helpers.
@note helpers can be overridden by name,
that's it, if some spec inherits `:a_duck?` helper
you can use `helper(:a_duck?) { ... }` to override it.
@note tested object are passed to helper via first argument.
any arguments passed to helper are sent after tested object.
@note... | [
"define",
"custom",
"assertion",
"helpers",
"."
] | 6dcdacd041cc031c21f2fe70b6e5b22c6af636c5 | https://github.com/sleewoo/minispec/blob/6dcdacd041cc031c21f2fe70b6e5b22c6af636c5/lib/minispec/api/class/helpers.rb#L92-L95 | train |
sleewoo/minispec | lib/minispec/utils/throw.rb | MiniSpec.Utils.symbol_thrown? | def symbol_thrown? expected_symbol, expected_value, context, &block
thrown_symbol, thrown_value = catch_symbol(expected_symbol, &block)
if context[:right_proc]
expected_symbol && raise(ArgumentError, 'Both arguments and block given. Please use either one.')
return MiniSpec::ThrowInspector.t... | ruby | def symbol_thrown? expected_symbol, expected_value, context, &block
thrown_symbol, thrown_value = catch_symbol(expected_symbol, &block)
if context[:right_proc]
expected_symbol && raise(ArgumentError, 'Both arguments and block given. Please use either one.')
return MiniSpec::ThrowInspector.t... | [
"def",
"symbol_thrown?",
"expected_symbol",
",",
"expected_value",
",",
"context",
",",
"&",
"block",
"thrown_symbol",
",",
"thrown_value",
"=",
"catch_symbol",
"(",
"expected_symbol",
",",
"&",
"block",
")",
"if",
"context",
"[",
":right_proc",
"]",
"expected_sym... | checks whether given block throws a symbol
and if yes compare it with expected one.
if a optional value given it will be compared to thrown one.
@param expected_symbol
@param expected_value
@param [Proc] &proc
@return a failure [ThrowError] if expectation not met.
true if expectations met. | [
"checks",
"whether",
"given",
"block",
"throws",
"a",
"symbol",
"and",
"if",
"yes",
"compare",
"it",
"with",
"expected",
"one",
".",
"if",
"a",
"optional",
"value",
"given",
"it",
"will",
"be",
"compared",
"to",
"thrown",
"one",
"."
] | 6dcdacd041cc031c21f2fe70b6e5b22c6af636c5 | https://github.com/sleewoo/minispec/blob/6dcdacd041cc031c21f2fe70b6e5b22c6af636c5/lib/minispec/utils/throw.rb#L17-L26 | train |
sleewoo/minispec | lib/minispec/utils/throw.rb | MiniSpec.Utils.catch_symbol | def catch_symbol expected_symbol, &block
thrown_symbol, thrown_value = nil
begin
if expected_symbol
thrown_value = catch :__ms__nothing_thrown do
catch expected_symbol do
block.call
throw :__ms__nothing_thrown, :__ms__nothing_thrown
end
... | ruby | def catch_symbol expected_symbol, &block
thrown_symbol, thrown_value = nil
begin
if expected_symbol
thrown_value = catch :__ms__nothing_thrown do
catch expected_symbol do
block.call
throw :__ms__nothing_thrown, :__ms__nothing_thrown
end
... | [
"def",
"catch_symbol",
"expected_symbol",
",",
"&",
"block",
"thrown_symbol",
",",
"thrown_value",
"=",
"nil",
"begin",
"if",
"expected_symbol",
"thrown_value",
"=",
"catch",
":__ms__nothing_thrown",
"do",
"catch",
"expected_symbol",
"do",
"block",
".",
"call",
"thr... | calling given block and catching thrown symbol, if any.
@param expected_symbol
@param [Proc] &block | [
"calling",
"given",
"block",
"and",
"catching",
"thrown",
"symbol",
"if",
"any",
"."
] | 6dcdacd041cc031c21f2fe70b6e5b22c6af636c5 | https://github.com/sleewoo/minispec/blob/6dcdacd041cc031c21f2fe70b6e5b22c6af636c5/lib/minispec/utils/throw.rb#L33-L51 | train |
sleewoo/minispec | lib/minispec/utils/throw.rb | MiniSpec.Utils.extract_thrown_symbol | def extract_thrown_symbol exception
return unless exception.is_a?(Exception)
return unless s = exception.message.scan(/uncaught throw\W+(\w+)/).flatten[0]
s.to_sym
end | ruby | def extract_thrown_symbol exception
return unless exception.is_a?(Exception)
return unless s = exception.message.scan(/uncaught throw\W+(\w+)/).flatten[0]
s.to_sym
end | [
"def",
"extract_thrown_symbol",
"exception",
"return",
"unless",
"exception",
".",
"is_a?",
"(",
"Exception",
")",
"return",
"unless",
"s",
"=",
"exception",
".",
"message",
".",
"scan",
"(",
"/",
"\\W",
"\\w",
"/",
")",
".",
"flatten",
"[",
"0",
"]",
"s... | extract thrown symbol from given exception
@param exception | [
"extract",
"thrown",
"symbol",
"from",
"given",
"exception"
] | 6dcdacd041cc031c21f2fe70b6e5b22c6af636c5 | https://github.com/sleewoo/minispec/blob/6dcdacd041cc031c21f2fe70b6e5b22c6af636c5/lib/minispec/utils/throw.rb#L57-L61 | train |
pjotrp/bioruby-table | lib/bio-table/table.rb | BioTable.Table.find_fields | def find_fields rowname
row = row_by_name(rowname)
fields = (row ? row.fields : [])
# fill fields with nil to match header length
# say header=5 fields=2 fill=2 (skip rowname)
fields.fill(nil,fields.size,header.size-1-fields.size)
end | ruby | def find_fields rowname
row = row_by_name(rowname)
fields = (row ? row.fields : [])
# fill fields with nil to match header length
# say header=5 fields=2 fill=2 (skip rowname)
fields.fill(nil,fields.size,header.size-1-fields.size)
end | [
"def",
"find_fields",
"rowname",
"row",
"=",
"row_by_name",
"(",
"rowname",
")",
"fields",
"=",
"(",
"row",
"?",
"row",
".",
"fields",
":",
"[",
"]",
")",
"fields",
".",
"fill",
"(",
"nil",
",",
"fields",
".",
"size",
",",
"header",
".",
"size",
"-... | Find a record by rowname and return the fields. Empty fields are nils. | [
"Find",
"a",
"record",
"by",
"rowname",
"and",
"return",
"the",
"fields",
".",
"Empty",
"fields",
"are",
"nils",
"."
] | e7cc97bb598743e7d69e63f16f76a2ce0ed9006d | https://github.com/pjotrp/bioruby-table/blob/e7cc97bb598743e7d69e63f16f76a2ce0ed9006d/lib/bio-table/table.rb#L97-L103 | train |
inre/fibre | lib/fibre/fiber_pool.rb | Fibre.FiberPool.checkout | def checkout(&b)
spec = { block: b, parent: ::Fiber.current }
if @pool.empty?
raise "The fiber queue has been overflowed" if @queue.size > @pool_queue_size
@queue.push spec
return
end
@pool.shift.tap do |fiber|
@reserved[fiber.object_id] = spec
fiber.res... | ruby | def checkout(&b)
spec = { block: b, parent: ::Fiber.current }
if @pool.empty?
raise "The fiber queue has been overflowed" if @queue.size > @pool_queue_size
@queue.push spec
return
end
@pool.shift.tap do |fiber|
@reserved[fiber.object_id] = spec
fiber.res... | [
"def",
"checkout",
"(",
"&",
"b",
")",
"spec",
"=",
"{",
"block",
":",
"b",
",",
"parent",
":",
"::",
"Fiber",
".",
"current",
"}",
"if",
"@pool",
".",
"empty?",
"raise",
"\"The fiber queue has been overflowed\"",
"if",
"@queue",
".",
"size",
">",
"@pool... | Initialize fiber's pool
Borrow fiber from the pool and call the block inside | [
"Initialize",
"fiber",
"s",
"pool",
"Borrow",
"fiber",
"from",
"the",
"pool",
"and",
"call",
"the",
"block",
"inside"
] | 6b4155b1b0042345154984c088007b63b3b69f20 | https://github.com/inre/fibre/blob/6b4155b1b0042345154984c088007b63b3b69f20/lib/fibre/fiber_pool.rb#L31-L46 | train |
inre/fibre | lib/fibre/fiber_pool.rb | Fibre.FiberPool.fiber_entry | def fiber_entry(spec)
loop do
raise "wrong spec in fiber block" unless spec.is_a?(Hash)
begin
before!(spec)
spec[:block].call# *Fiber.current.args
after!(spec)
# catch ArgumentError, IOError, EOFError, IndexError, LocalJumpError, NameError, NoMethodError
... | ruby | def fiber_entry(spec)
loop do
raise "wrong spec in fiber block" unless spec.is_a?(Hash)
begin
before!(spec)
spec[:block].call# *Fiber.current.args
after!(spec)
# catch ArgumentError, IOError, EOFError, IndexError, LocalJumpError, NameError, NoMethodError
... | [
"def",
"fiber_entry",
"(",
"spec",
")",
"loop",
"do",
"raise",
"\"wrong spec in fiber block\"",
"unless",
"spec",
".",
"is_a?",
"(",
"Hash",
")",
"begin",
"before!",
"(",
"spec",
")",
"spec",
"[",
":block",
"]",
".",
"call",
"after!",
"(",
"spec",
")",
"... | There is entrypoint running fibers | [
"There",
"is",
"entrypoint",
"running",
"fibers"
] | 6b4155b1b0042345154984c088007b63b3b69f20 | https://github.com/inre/fibre/blob/6b4155b1b0042345154984c088007b63b3b69f20/lib/fibre/fiber_pool.rb#L51-L80 | train |
inre/fibre | lib/fibre/fiber_pool.rb | Fibre.FiberPool.checkin | def checkin(result=nil)
@reserved.delete ::Fiber.current.object_id
@pool.unshift ::Fiber.current
::Fiber.yield
end | ruby | def checkin(result=nil)
@reserved.delete ::Fiber.current.object_id
@pool.unshift ::Fiber.current
::Fiber.yield
end | [
"def",
"checkin",
"(",
"result",
"=",
"nil",
")",
"@reserved",
".",
"delete",
"::",
"Fiber",
".",
"current",
".",
"object_id",
"@pool",
".",
"unshift",
"::",
"Fiber",
".",
"current",
"::",
"Fiber",
".",
"yield",
"end"
] | Return the fiber into the pool | [
"Return",
"the",
"fiber",
"into",
"the",
"pool"
] | 6b4155b1b0042345154984c088007b63b3b69f20 | https://github.com/inre/fibre/blob/6b4155b1b0042345154984c088007b63b3b69f20/lib/fibre/fiber_pool.rb#L83-L87 | train |
lloeki/sprockets-less | lib/sprockets/less/functions.rb | Less.Tree.anonymous_function | def anonymous_function(block)
lambda do |*args|
# args: (this, node) v8 >= 0.10, otherwise (node)
raise ArgumentError, "missing node" if args.empty?
@tree[:Anonymous].new block.call(@tree, args.last)
end
end | ruby | def anonymous_function(block)
lambda do |*args|
# args: (this, node) v8 >= 0.10, otherwise (node)
raise ArgumentError, "missing node" if args.empty?
@tree[:Anonymous].new block.call(@tree, args.last)
end
end | [
"def",
"anonymous_function",
"(",
"block",
")",
"lambda",
"do",
"|",
"*",
"args",
"|",
"raise",
"ArgumentError",
",",
"\"missing node\"",
"if",
"args",
".",
"empty?",
"@tree",
"[",
":Anonymous",
"]",
".",
"new",
"block",
".",
"call",
"(",
"@tree",
",",
"... | Creates a JavaScript anonymous function from a Ruby block | [
"Creates",
"a",
"JavaScript",
"anonymous",
"function",
"from",
"a",
"Ruby",
"block"
] | f8cd973dd4dd5111bbda44e6c3fd8f445ab477f7 | https://github.com/lloeki/sprockets-less/blob/f8cd973dd4dd5111bbda44e6c3fd8f445ab477f7/lib/sprockets/less/functions.rb#L111-L117 | train |
lloeki/sprockets-less | lib/sprockets/less/functions.rb | Less.Tree.extend_js | def extend_js(mod)
extend mod
mod.public_instance_methods.each do |method_name|
add_function(sym_to_css(method_name)) { |tree, cxt|
send method_name.to_sym, unquote(cxt.toCSS())
}
end
end | ruby | def extend_js(mod)
extend mod
mod.public_instance_methods.each do |method_name|
add_function(sym_to_css(method_name)) { |tree, cxt|
send method_name.to_sym, unquote(cxt.toCSS())
}
end
end | [
"def",
"extend_js",
"(",
"mod",
")",
"extend",
"mod",
"mod",
".",
"public_instance_methods",
".",
"each",
"do",
"|",
"method_name",
"|",
"add_function",
"(",
"sym_to_css",
"(",
"method_name",
")",
")",
"{",
"|",
"tree",
",",
"cxt",
"|",
"send",
"method_nam... | Adds all of a module's public instance methods as Less functions | [
"Adds",
"all",
"of",
"a",
"module",
"s",
"public",
"instance",
"methods",
"as",
"Less",
"functions"
] | f8cd973dd4dd5111bbda44e6c3fd8f445ab477f7 | https://github.com/lloeki/sprockets-less/blob/f8cd973dd4dd5111bbda44e6c3fd8f445ab477f7/lib/sprockets/less/functions.rb#L130-L137 | train |
nazoking/rehtml | lib/rehtml/builder.rb | REHTML.REXMLBuilder.append | def append(node)
if node.is_a?(EndTag)
return if empty_tag?(node.name)
po = @pos
while po.parent and po.name != node.name
po = po.parent
end
if po.name == node.name
@pos = po.parent
end
else
rexml = to_rexml(node)
# if node... | ruby | def append(node)
if node.is_a?(EndTag)
return if empty_tag?(node.name)
po = @pos
while po.parent and po.name != node.name
po = po.parent
end
if po.name == node.name
@pos = po.parent
end
else
rexml = to_rexml(node)
# if node... | [
"def",
"append",
"(",
"node",
")",
"if",
"node",
".",
"is_a?",
"(",
"EndTag",
")",
"return",
"if",
"empty_tag?",
"(",
"node",
".",
"name",
")",
"po",
"=",
"@pos",
"while",
"po",
".",
"parent",
"and",
"po",
".",
"name",
"!=",
"node",
".",
"name",
... | append node to document | [
"append",
"node",
"to",
"document"
] | 4bf9016f5325becd955db777d832a2c90f3407ac | https://github.com/nazoking/rehtml/blob/4bf9016f5325becd955db777d832a2c90f3407ac/lib/rehtml/builder.rb#L19-L52 | train |
qw3/getnet_api | lib/getnet_api/payment.rb | GetnetApi.Payment.to_request | def to_request obj, type
payment = {
seller_id: GetnetApi.seller_id.to_s,
amount: self.amount.to_i,
currency: self.currency.to_s,
order: self.order.to_request,
customer: self.customer.to_request(:payment),
}
if type =... | ruby | def to_request obj, type
payment = {
seller_id: GetnetApi.seller_id.to_s,
amount: self.amount.to_i,
currency: self.currency.to_s,
order: self.order.to_request,
customer: self.customer.to_request(:payment),
}
if type =... | [
"def",
"to_request",
"obj",
",",
"type",
"payment",
"=",
"{",
"seller_id",
":",
"GetnetApi",
".",
"seller_id",
".",
"to_s",
",",
"amount",
":",
"self",
".",
"amount",
".",
"to_i",
",",
"currency",
":",
"self",
".",
"currency",
".",
"to_s",
",",
"order"... | Nova instancia da classe Cliente
@param [Hash] campos
Montar o Hash de dados do usuario no padrão utilizado pela Getnet | [
"Nova",
"instancia",
"da",
"classe",
"Cliente"
] | 94cbda66aab03d83ea38bc5325ea2a02a639e922 | https://github.com/qw3/getnet_api/blob/94cbda66aab03d83ea38bc5325ea2a02a639e922/lib/getnet_api/payment.rb#L75-L91 | train |
codefoundry/svn | lib/svn/revisions.rb | Svn.Revision.diff | def diff( path, options={} )
raise Svn::Error, "cannot diff directory #{path}@#{to_s}" if dir? path
other = options[:with] if options[:with].is_a? Root
other = repo.revision(options[:with]) if options[:with].is_a? Numeric
other ||= repo.revision(to_i - 1)
return other.diff( path, :with =... | ruby | def diff( path, options={} )
raise Svn::Error, "cannot diff directory #{path}@#{to_s}" if dir? path
other = options[:with] if options[:with].is_a? Root
other = repo.revision(options[:with]) if options[:with].is_a? Numeric
other ||= repo.revision(to_i - 1)
return other.diff( path, :with =... | [
"def",
"diff",
"(",
"path",
",",
"options",
"=",
"{",
"}",
")",
"raise",
"Svn",
"::",
"Error",
",",
"\"cannot diff directory #{path}@#{to_s}\"",
"if",
"dir?",
"path",
"other",
"=",
"options",
"[",
":with",
"]",
"if",
"options",
"[",
":with",
"]",
".",
"i... | diffs +path+ with another revision. if no revision is specified, the
previous revision is used. | [
"diffs",
"+",
"path",
"+",
"with",
"another",
"revision",
".",
"if",
"no",
"revision",
"is",
"specified",
"the",
"previous",
"revision",
"is",
"used",
"."
] | 930a8da65fbecf3ffed50655e1cb10fcbc484be4 | https://github.com/codefoundry/svn/blob/930a8da65fbecf3ffed50655e1cb10fcbc484be4/lib/svn/revisions.rb#L98-L125 | train |
Nakilon/reddit_bot | lib/reddit_bot.rb | RedditBot.Bot.resp_with_token | def resp_with_token mtd, path, form
fail unless path.start_with? ?/
timeout = 5
begin
reddit_resp mtd, "https://oauth.reddit.com" + path, form, {
"Authorization" => "bearer #{token}",
"User-Agent" => "bot/#{@user_agent || @name}/#{RedditBot::VERSION} by /u/nakilon",
... | ruby | def resp_with_token mtd, path, form
fail unless path.start_with? ?/
timeout = 5
begin
reddit_resp mtd, "https://oauth.reddit.com" + path, form, {
"Authorization" => "bearer #{token}",
"User-Agent" => "bot/#{@user_agent || @name}/#{RedditBot::VERSION} by /u/nakilon",
... | [
"def",
"resp_with_token",
"mtd",
",",
"path",
",",
"form",
"fail",
"unless",
"path",
".",
"start_with?",
"?/",
"timeout",
"=",
"5",
"begin",
"reddit_resp",
"mtd",
",",
"\"https://oauth.reddit.com\"",
"+",
"path",
",",
"form",
",",
"{",
"\"Authorization\"",
"=>... | def update_captcha
return if @ignore_captcha
pp iden_json = json(:post, "/api/new_captcha")
iden = iden_json["json"]["data"]["iden"]
# return @iden_and_captcha = [iden, "\n"] if @ignore_captcha
# pp resp_with_token(:get, "/captcha/#{iden_json["json"]["data"]["iden"]}", {})
puts "CAPTCHA: https://reddi... | [
"def",
"update_captcha",
"return",
"if"
] | e18e498b807b81a49b5ea87b9b294a14b96f9f78 | https://github.com/Nakilon/reddit_bot/blob/e18e498b807b81a49b5ea87b9b294a14b96f9f78/lib/reddit_bot.rb#L228-L244 | train |
kennym/ideone-ruby-api | lib/ideone.rb | Ideone.Client.languages | def languages
unless @languages_cache
response = call_request(:get_languages)
languages = response.to_hash[:get_languages_response][:return][:item][1][:value][:item]
# Create a sorted hash
@languages_cache = Hash[create_dict(languages).sort_by{|k,v| k.to_i}]
end
return... | ruby | def languages
unless @languages_cache
response = call_request(:get_languages)
languages = response.to_hash[:get_languages_response][:return][:item][1][:value][:item]
# Create a sorted hash
@languages_cache = Hash[create_dict(languages).sort_by{|k,v| k.to_i}]
end
return... | [
"def",
"languages",
"unless",
"@languages_cache",
"response",
"=",
"call_request",
"(",
":get_languages",
")",
"languages",
"=",
"response",
".",
"to_hash",
"[",
":get_languages_response",
"]",
"[",
":return",
"]",
"[",
":item",
"]",
"[",
"1",
"]",
"[",
":valu... | Get a list of supported languages and cache it. | [
"Get",
"a",
"list",
"of",
"supported",
"languages",
"and",
"cache",
"it",
"."
] | d682c8a1c673579c399b834bff7dbcbba648fb81 | https://github.com/kennym/ideone-ruby-api/blob/d682c8a1c673579c399b834bff7dbcbba648fb81/lib/ideone.rb#L79-L88 | train |
qw3/getnet_api | lib/getnet_api/boleto.rb | GetnetApi.Boleto.to_request | def to_request
boleto = {
our_number: self.our_number,
document_number: self.document_number,
expiration_date: self.expiration_date,
instructions: self.instructions,
provider: self.provider
}
return boleto
end | ruby | def to_request
boleto = {
our_number: self.our_number,
document_number: self.document_number,
expiration_date: self.expiration_date,
instructions: self.instructions,
provider: self.provider
}
return boleto
end | [
"def",
"to_request",
"boleto",
"=",
"{",
"our_number",
":",
"self",
".",
"our_number",
",",
"document_number",
":",
"self",
".",
"document_number",
",",
"expiration_date",
":",
"self",
".",
"expiration_date",
",",
"instructions",
":",
"self",
".",
"instructions"... | Nova instancia da classe Boleto
@param [Hash] campos
Montar o Hash de dados do pagamento no padrão utilizado pela Getnet | [
"Nova",
"instancia",
"da",
"classe",
"Boleto"
] | 94cbda66aab03d83ea38bc5325ea2a02a639e922 | https://github.com/qw3/getnet_api/blob/94cbda66aab03d83ea38bc5325ea2a02a639e922/lib/getnet_api/boleto.rb#L49-L59 | train |
rkday/ruby-diameter | lib/diameter/message.rb | Diameter.Message.all_avps_by_name | def all_avps_by_name(name)
code, _type, vendor = Internals::AVPNames.get(name)
all_avps_by_code(code, vendor)
end | ruby | def all_avps_by_name(name)
code, _type, vendor = Internals::AVPNames.get(name)
all_avps_by_code(code, vendor)
end | [
"def",
"all_avps_by_name",
"(",
"name",
")",
"code",
",",
"_type",
",",
"vendor",
"=",
"Internals",
"::",
"AVPNames",
".",
"get",
"(",
"name",
")",
"all_avps_by_code",
"(",
"code",
",",
"vendor",
")",
"end"
] | Returns all AVPs with the given name. Only covers "top-level"
AVPs - it won't look inside Grouped AVPs.
@param name [String] The AVP name, either one predefined in
{Constants::AVAILABLE_AVPS} or user-defined with {AVP.define}
@return [Array<AVP>] | [
"Returns",
"all",
"AVPs",
"with",
"the",
"given",
"name",
".",
"Only",
"covers",
"top",
"-",
"level",
"AVPs",
"-",
"it",
"won",
"t",
"look",
"inside",
"Grouped",
"AVPs",
"."
] | 83def68f67cf660aa227eac4c74719dc98aacab2 | https://github.com/rkday/ruby-diameter/blob/83def68f67cf660aa227eac4c74719dc98aacab2/lib/diameter/message.rb#L113-L116 | train |
johnl/web-page-parser | lib/web-page-parser/base_parser.rb | WebPageParser.BaseRegexpParser.encode | def encode(s)
return s if s.nil?
return s if s.valid_encoding?
if s.force_encoding("iso-8859-1").valid_encoding?
return s.encode('utf-8', 'iso-8859-1')
end
s
end | ruby | def encode(s)
return s if s.nil?
return s if s.valid_encoding?
if s.force_encoding("iso-8859-1").valid_encoding?
return s.encode('utf-8', 'iso-8859-1')
end
s
end | [
"def",
"encode",
"(",
"s",
")",
"return",
"s",
"if",
"s",
".",
"nil?",
"return",
"s",
"if",
"s",
".",
"valid_encoding?",
"if",
"s",
".",
"force_encoding",
"(",
"\"iso-8859-1\"",
")",
".",
"valid_encoding?",
"return",
"s",
".",
"encode",
"(",
"'utf-8'",
... | Handle any string encoding | [
"Handle",
"any",
"string",
"encoding"
] | 105cbe6fda569c6c6667ed655ea6c6771c1d9037 | https://github.com/johnl/web-page-parser/blob/105cbe6fda569c6c6667ed655ea6c6771c1d9037/lib/web-page-parser/base_parser.rb#L103-L110 | train |
johnl/web-page-parser | lib/web-page-parser/base_parser.rb | WebPageParser.BaseRegexpParser.retrieve_page | def retrieve_page(rurl = nil)
durl = rurl || url
return nil unless durl
durl = filter_url(durl) if self.respond_to?(:filter_url)
self.class.retrieve_session ||= WebPageParser::HTTP::Session.new
encode(self.class.retrieve_session.get(durl))
end | ruby | def retrieve_page(rurl = nil)
durl = rurl || url
return nil unless durl
durl = filter_url(durl) if self.respond_to?(:filter_url)
self.class.retrieve_session ||= WebPageParser::HTTP::Session.new
encode(self.class.retrieve_session.get(durl))
end | [
"def",
"retrieve_page",
"(",
"rurl",
"=",
"nil",
")",
"durl",
"=",
"rurl",
"||",
"url",
"return",
"nil",
"unless",
"durl",
"durl",
"=",
"filter_url",
"(",
"durl",
")",
"if",
"self",
".",
"respond_to?",
"(",
":filter_url",
")",
"self",
".",
"class",
"."... | request the page from the server and return the raw contents | [
"request",
"the",
"page",
"from",
"the",
"server",
"and",
"return",
"the",
"raw",
"contents"
] | 105cbe6fda569c6c6667ed655ea6c6771c1d9037 | https://github.com/johnl/web-page-parser/blob/105cbe6fda569c6c6667ed655ea6c6771c1d9037/lib/web-page-parser/base_parser.rb#L118-L124 | train |
johnl/web-page-parser | lib/web-page-parser/base_parser.rb | WebPageParser.BaseRegexpParser.title | def title
return @title if @title
if matches = class_const(:TITLE_RE).match(page)
@title = matches[1].to_s.strip
title_processor
@title = decode_entities(@title)
end
end | ruby | def title
return @title if @title
if matches = class_const(:TITLE_RE).match(page)
@title = matches[1].to_s.strip
title_processor
@title = decode_entities(@title)
end
end | [
"def",
"title",
"return",
"@title",
"if",
"@title",
"if",
"matches",
"=",
"class_const",
"(",
":TITLE_RE",
")",
".",
"match",
"(",
"page",
")",
"@title",
"=",
"matches",
"[",
"1",
"]",
".",
"to_s",
".",
"strip",
"title_processor",
"@title",
"=",
"decode_... | The title method returns the title of the web page.
It does the basic extraction using the TITLE_RE regular
expression and handles text encoding. More advanced parsing can
be done by overriding the title_processor method. | [
"The",
"title",
"method",
"returns",
"the",
"title",
"of",
"the",
"web",
"page",
"."
] | 105cbe6fda569c6c6667ed655ea6c6771c1d9037 | https://github.com/johnl/web-page-parser/blob/105cbe6fda569c6c6667ed655ea6c6771c1d9037/lib/web-page-parser/base_parser.rb#L131-L138 | train |
johnl/web-page-parser | lib/web-page-parser/base_parser.rb | WebPageParser.BaseRegexpParser.content | def content
return @content if @content
matches = class_const(:CONTENT_RE).match(page)
if matches
@content = class_const(:KILL_CHARS_RE).gsub(matches[1].to_s, '')
content_processor
@content.collect! { |p| decode_entities(p.strip) }
@content.delete_if { |p| p == '' or p.... | ruby | def content
return @content if @content
matches = class_const(:CONTENT_RE).match(page)
if matches
@content = class_const(:KILL_CHARS_RE).gsub(matches[1].to_s, '')
content_processor
@content.collect! { |p| decode_entities(p.strip) }
@content.delete_if { |p| p == '' or p.... | [
"def",
"content",
"return",
"@content",
"if",
"@content",
"matches",
"=",
"class_const",
"(",
":CONTENT_RE",
")",
".",
"match",
"(",
"page",
")",
"if",
"matches",
"@content",
"=",
"class_const",
"(",
":KILL_CHARS_RE",
")",
".",
"gsub",
"(",
"matches",
"[",
... | The content method returns the important body text of the web page.
It does basic extraction and pre-processing of the page content
and then calls the content_processor method for any other more
custom processing work that needs doing. Lastly, it does some
basic post processing and returns the content as a string... | [
"The",
"content",
"method",
"returns",
"the",
"important",
"body",
"text",
"of",
"the",
"web",
"page",
"."
] | 105cbe6fda569c6c6667ed655ea6c6771c1d9037 | https://github.com/johnl/web-page-parser/blob/105cbe6fda569c6c6667ed655ea6c6771c1d9037/lib/web-page-parser/base_parser.rb#L165-L176 | train |
brainmap/nifti | lib/nifti/n_image.rb | NIFTI.NImage.[] | def [](index)
# Dealing with Ranges is useful when the image represents a tensor
if (index.is_a?(Fixnum) && index >= self.shape[0]) || (index.is_a?(Range) && index.last >= self.shape[0])
raise IndexError.new("Index over bounds")
elsif self.shape.count == 1
if index.is_a?(Range)
... | ruby | def [](index)
# Dealing with Ranges is useful when the image represents a tensor
if (index.is_a?(Fixnum) && index >= self.shape[0]) || (index.is_a?(Range) && index.last >= self.shape[0])
raise IndexError.new("Index over bounds")
elsif self.shape.count == 1
if index.is_a?(Range)
... | [
"def",
"[]",
"(",
"index",
")",
"if",
"(",
"index",
".",
"is_a?",
"(",
"Fixnum",
")",
"&&",
"index",
">=",
"self",
".",
"shape",
"[",
"0",
"]",
")",
"||",
"(",
"index",
".",
"is_a?",
"(",
"Range",
")",
"&&",
"index",
".",
"last",
">=",
"self",
... | Creates an NImage instance.
The NImages instance provides a user friendly interface to the NIFTI Image
A NImage is typically built by NObject instance
=== Parameters
* <tt>array_image</tt> -- The NIFTI image contained on and one dimensional array
* <tt>dim</tt> -- The dimensions array from the NIFTI header.
=... | [
"Creates",
"an",
"NImage",
"instance",
"."
] | a252ee91b4964116a72373aa5008f218fd695e57 | https://github.com/brainmap/nifti/blob/a252ee91b4964116a72373aa5008f218fd695e57/lib/nifti/n_image.rb#L41-L56 | train |
brainmap/nifti | lib/nifti/n_image.rb | NIFTI.NImage.[]= | def []=(index,value)
if self.shape.count != 1 or index >= self.shape[0]
raise IndexError.new("You can only set values for array values")
else
@array_image[get_index_value(index)] = value
end
end | ruby | def []=(index,value)
if self.shape.count != 1 or index >= self.shape[0]
raise IndexError.new("You can only set values for array values")
else
@array_image[get_index_value(index)] = value
end
end | [
"def",
"[]=",
"(",
"index",
",",
"value",
")",
"if",
"self",
".",
"shape",
".",
"count",
"!=",
"1",
"or",
"index",
">=",
"self",
".",
"shape",
"[",
"0",
"]",
"raise",
"IndexError",
".",
"new",
"(",
"\"You can only set values for array values\"",
")",
"el... | Set the value for an element of the dataset
=== Parameters
* <tt>index</tt> -- The desired index on the dataset
* <tt>value</tt> -- The value that the will be set
=== Options
=== Examples
img[0][0] = 1.0 | [
"Set",
"the",
"value",
"for",
"an",
"element",
"of",
"the",
"dataset"
] | a252ee91b4964116a72373aa5008f218fd695e57 | https://github.com/brainmap/nifti/blob/a252ee91b4964116a72373aa5008f218fd695e57/lib/nifti/n_image.rb#L71-L77 | train |
thelabtech/questionnaire | app/models/qe/question_set.rb | Qe.QuestionSet.post | def post(params, answer_sheet)
questions_indexed = @questions.index_by {|q| q.id}
# loop over form values
params ||= {}
params.each do |question_id, response|
next if questions_indexed[question_id.to_i].nil? # the rare case where a question was removed after the app was opened.
... | ruby | def post(params, answer_sheet)
questions_indexed = @questions.index_by {|q| q.id}
# loop over form values
params ||= {}
params.each do |question_id, response|
next if questions_indexed[question_id.to_i].nil? # the rare case where a question was removed after the app was opened.
... | [
"def",
"post",
"(",
"params",
",",
"answer_sheet",
")",
"questions_indexed",
"=",
"@questions",
".",
"index_by",
"{",
"|",
"q",
"|",
"q",
".",
"id",
"}",
"params",
"||=",
"{",
"}",
"params",
".",
"each",
"do",
"|",
"question_id",
",",
"response",
"|",
... | associate answers from database with a set of elements
update with responses from form | [
"associate",
"answers",
"from",
"database",
"with",
"a",
"set",
"of",
"elements",
"update",
"with",
"responses",
"from",
"form"
] | 02eb47cbcda8cca28a5db78e18623d0957aa2c9b | https://github.com/thelabtech/questionnaire/blob/02eb47cbcda8cca28a5db78e18623d0957aa2c9b/app/models/qe/question_set.rb#L24-L34 | train |
thelabtech/questionnaire | app/models/qe/question_set.rb | Qe.QuestionSet.posted_values | def posted_values(param)
if param.kind_of?(Hash) and param.has_key?('year') and param.has_key?('month')
year = param['year']
month = param['month']
if month.blank? or year.blank?
values = ''
else
values = [Date.new(year.to_i, month.to_i, 1).strftime('%m/%d/... | ruby | def posted_values(param)
if param.kind_of?(Hash) and param.has_key?('year') and param.has_key?('month')
year = param['year']
month = param['month']
if month.blank? or year.blank?
values = ''
else
values = [Date.new(year.to_i, month.to_i, 1).strftime('%m/%d/... | [
"def",
"posted_values",
"(",
"param",
")",
"if",
"param",
".",
"kind_of?",
"(",
"Hash",
")",
"and",
"param",
".",
"has_key?",
"(",
"'year'",
")",
"and",
"param",
".",
"has_key?",
"(",
"'month'",
")",
"year",
"=",
"param",
"[",
"'year'",
"]",
"month",
... | convert posted response to a question into Array of values | [
"convert",
"posted",
"response",
"to",
"a",
"question",
"into",
"Array",
"of",
"values"
] | 02eb47cbcda8cca28a5db78e18623d0957aa2c9b | https://github.com/thelabtech/questionnaire/blob/02eb47cbcda8cca28a5db78e18623d0957aa2c9b/app/models/qe/question_set.rb#L60-L79 | train |
sleewoo/minispec | lib/minispec/api/instance/mocks/mocks.rb | MiniSpec.InstanceAPI.mock | def mock object, method, visibility = nil, &proc
if method.is_a?(Hash)
proc && raise(ArgumentError, 'Both Hash and block given. Please use either one.')
method.each_pair {|m,r| mock(object, m, visibility, &proc {r})}
return MiniSpec::Mocks::HashedStub
end
visibility ||= MiniSpe... | ruby | def mock object, method, visibility = nil, &proc
if method.is_a?(Hash)
proc && raise(ArgumentError, 'Both Hash and block given. Please use either one.')
method.each_pair {|m,r| mock(object, m, visibility, &proc {r})}
return MiniSpec::Mocks::HashedStub
end
visibility ||= MiniSpe... | [
"def",
"mock",
"object",
",",
"method",
",",
"visibility",
"=",
"nil",
",",
"&",
"proc",
"if",
"method",
".",
"is_a?",
"(",
"Hash",
")",
"proc",
"&&",
"raise",
"(",
"ArgumentError",
",",
"'Both Hash and block given. Please use either one.'",
")",
"method",
"."... | the mock is basically a stub with difference it will also add a expectation.
that's it, a mock will stub a method on a object and
will expect that stub to be called before test finished.
the `mock` method will return the actual stub
so you can build chained constraints on it.
@note if mocked method exists it's ... | [
"the",
"mock",
"is",
"basically",
"a",
"stub",
"with",
"difference",
"it",
"will",
"also",
"add",
"a",
"expectation",
".",
"that",
"s",
"it",
"a",
"mock",
"will",
"stub",
"a",
"method",
"on",
"a",
"object",
"and",
"will",
"expect",
"that",
"stub",
"to"... | 6dcdacd041cc031c21f2fe70b6e5b22c6af636c5 | https://github.com/sleewoo/minispec/blob/6dcdacd041cc031c21f2fe70b6e5b22c6af636c5/lib/minispec/api/instance/mocks/mocks.rb#L25-L36 | train |
sleewoo/minispec | lib/minispec/api/instance/mocks/mocks.rb | MiniSpec.InstanceAPI.proxy | def proxy object, method_name
# do not proxify doubles
return if object.respond_to?(:__ms__double_instance)
# do not proxify stubs
return if (x = @__ms__stubs__originals) && (x = x[object]) && x[method_name]
proxies = (@__ms__proxies[object] ||= [])
return if proxies.include?(metho... | ruby | def proxy object, method_name
# do not proxify doubles
return if object.respond_to?(:__ms__double_instance)
# do not proxify stubs
return if (x = @__ms__stubs__originals) && (x = x[object]) && x[method_name]
proxies = (@__ms__proxies[object] ||= [])
return if proxies.include?(metho... | [
"def",
"proxy",
"object",
",",
"method_name",
"return",
"if",
"object",
".",
"respond_to?",
"(",
":__ms__double_instance",
")",
"return",
"if",
"(",
"x",
"=",
"@__ms__stubs__originals",
")",
"&&",
"(",
"x",
"=",
"x",
"[",
"object",
"]",
")",
"&&",
"x",
"... | overriding given method of given object with a proxy
so MiniSpec can later check whether given method was called.
if given method does not exists a NoMethodError raised
@note doubles and stubs will be skipped as they are already proxified
@example
proxy(obj, :a)
assert(obj).received(:a) # checking whethe... | [
"overriding",
"given",
"method",
"of",
"given",
"object",
"with",
"a",
"proxy",
"so",
"MiniSpec",
"can",
"later",
"check",
"whether",
"given",
"method",
"was",
"called",
"."
] | 6dcdacd041cc031c21f2fe70b6e5b22c6af636c5 | https://github.com/sleewoo/minispec/blob/6dcdacd041cc031c21f2fe70b6e5b22c6af636c5/lib/minispec/api/instance/mocks/mocks.rb#L87-L112 | train |
thelabtech/questionnaire | app/controllers/qe/answer_sheets_controller.rb | Qe.AnswerSheetsController.index | def index
# TODO dynamically reference this
# @answer_sheets = answer_sheet_type.find(:all, :order => 'created_at')
@answer_sheets = AnswerSheet.find(:all, :order => 'created_at')
# drop down of sheets to capture data for
@question_sheets = QuestionSheet.find(:all, :order => 'label... | ruby | def index
# TODO dynamically reference this
# @answer_sheets = answer_sheet_type.find(:all, :order => 'created_at')
@answer_sheets = AnswerSheet.find(:all, :order => 'created_at')
# drop down of sheets to capture data for
@question_sheets = QuestionSheet.find(:all, :order => 'label... | [
"def",
"index",
"@answer_sheets",
"=",
"AnswerSheet",
".",
"find",
"(",
":all",
",",
":order",
"=>",
"'created_at'",
")",
"@question_sheets",
"=",
"QuestionSheet",
".",
"find",
"(",
":all",
",",
":order",
"=>",
"'label'",
")",
".",
"map",
"{",
"|",
"s",
... | list existing answer sheets | [
"list",
"existing",
"answer",
"sheets"
] | 02eb47cbcda8cca28a5db78e18623d0957aa2c9b | https://github.com/thelabtech/questionnaire/blob/02eb47cbcda8cca28a5db78e18623d0957aa2c9b/app/controllers/qe/answer_sheets_controller.rb#L11-L19 | train |
Telestream/telestream-cloud-ruby-sdk | qc/lib/telestream_cloud_qc/api/qc_api.rb | TelestreamCloud::Qc.QcApi.create_job | def create_job(project_id, data, opts = {})
data, _status_code, _headers = create_job_with_http_info(project_id, data, opts)
return data
end | ruby | def create_job(project_id, data, opts = {})
data, _status_code, _headers = create_job_with_http_info(project_id, data, opts)
return data
end | [
"def",
"create_job",
"(",
"project_id",
",",
"data",
",",
"opts",
"=",
"{",
"}",
")",
"data",
",",
"_status_code",
",",
"_headers",
"=",
"create_job_with_http_info",
"(",
"project_id",
",",
"data",
",",
"opts",
")",
"return",
"data",
"end"
] | Create a new job
@param project_id A unique identifier of a Project.
@param data
@param [Hash] opts the optional parameters
@return [Job] | [
"Create",
"a",
"new",
"job"
] | c232427aa3e84688ba41ec28e5bef1cc72832bf4 | https://github.com/Telestream/telestream-cloud-ruby-sdk/blob/c232427aa3e84688ba41ec28e5bef1cc72832bf4/qc/lib/telestream_cloud_qc/api/qc_api.rb#L89-L92 | train |
Telestream/telestream-cloud-ruby-sdk | qc/lib/telestream_cloud_qc/api/qc_api.rb | TelestreamCloud::Qc.QcApi.get_job | def get_job(project_id, job_id, opts = {})
data, _status_code, _headers = get_job_with_http_info(project_id, job_id, opts)
return data
end | ruby | def get_job(project_id, job_id, opts = {})
data, _status_code, _headers = get_job_with_http_info(project_id, job_id, opts)
return data
end | [
"def",
"get_job",
"(",
"project_id",
",",
"job_id",
",",
"opts",
"=",
"{",
"}",
")",
"data",
",",
"_status_code",
",",
"_headers",
"=",
"get_job_with_http_info",
"(",
"project_id",
",",
"job_id",
",",
"opts",
")",
"return",
"data",
"end"
] | Get QC job
@param project_id A unique identifier of a Project.
@param job_id A unique identifier of a Job.
@param [Hash] opts the optional parameters
@return [Job] | [
"Get",
"QC",
"job"
] | c232427aa3e84688ba41ec28e5bef1cc72832bf4 | https://github.com/Telestream/telestream-cloud-ruby-sdk/blob/c232427aa3e84688ba41ec28e5bef1cc72832bf4/qc/lib/telestream_cloud_qc/api/qc_api.rb#L201-L204 | train |
Telestream/telestream-cloud-ruby-sdk | qc/lib/telestream_cloud_qc/api/qc_api.rb | TelestreamCloud::Qc.QcApi.get_project | def get_project(project_id, opts = {})
data, _status_code, _headers = get_project_with_http_info(project_id, opts)
return data
end | ruby | def get_project(project_id, opts = {})
data, _status_code, _headers = get_project_with_http_info(project_id, opts)
return data
end | [
"def",
"get_project",
"(",
"project_id",
",",
"opts",
"=",
"{",
"}",
")",
"data",
",",
"_status_code",
",",
"_headers",
"=",
"get_project_with_http_info",
"(",
"project_id",
",",
"opts",
")",
"return",
"data",
"end"
] | Get project by Id
@param project_id A unique identifier of a Project.
@param [Hash] opts the optional parameters
@return [Project] | [
"Get",
"project",
"by",
"Id"
] | c232427aa3e84688ba41ec28e5bef1cc72832bf4 | https://github.com/Telestream/telestream-cloud-ruby-sdk/blob/c232427aa3e84688ba41ec28e5bef1cc72832bf4/qc/lib/telestream_cloud_qc/api/qc_api.rb#L261-L264 | train |
Telestream/telestream-cloud-ruby-sdk | qc/lib/telestream_cloud_qc/api/qc_api.rb | TelestreamCloud::Qc.QcApi.list_jobs | def list_jobs(project_id, opts = {})
data, _status_code, _headers = list_jobs_with_http_info(project_id, opts)
return data
end | ruby | def list_jobs(project_id, opts = {})
data, _status_code, _headers = list_jobs_with_http_info(project_id, opts)
return data
end | [
"def",
"list_jobs",
"(",
"project_id",
",",
"opts",
"=",
"{",
"}",
")",
"data",
",",
"_status_code",
",",
"_headers",
"=",
"list_jobs_with_http_info",
"(",
"project_id",
",",
"opts",
")",
"return",
"data",
"end"
] | Get jobs form projects
@param project_id A unique identifier of a Project.
@param [Hash] opts the optional parameters
@option opts [BOOLEAN] :expand Expand details of job
@option opts [String] :status Filter jobs by status
@option opts [Integer] :per_page Limit number of listed jobs (default to 30)
@option opts ... | [
"Get",
"jobs",
"form",
"projects"
] | c232427aa3e84688ba41ec28e5bef1cc72832bf4 | https://github.com/Telestream/telestream-cloud-ruby-sdk/blob/c232427aa3e84688ba41ec28e5bef1cc72832bf4/qc/lib/telestream_cloud_qc/api/qc_api.rb#L320-L323 | train |
mlomnicki/automatic_foreign_key | lib/automatic_foreign_key/active_record/connection_adapters/table_definition.rb | AutomaticForeignKey::ActiveRecord::ConnectionAdapters.TableDefinition.belongs_to | def belongs_to(table, options = {})
options = options.merge(:references => table)
options[:on_delete] = options.delete(:dependent) if options.has_key?(:dependent)
column("#{table.to_s.singularize}_id".to_sym, :integer, options)
end | ruby | def belongs_to(table, options = {})
options = options.merge(:references => table)
options[:on_delete] = options.delete(:dependent) if options.has_key?(:dependent)
column("#{table.to_s.singularize}_id".to_sym, :integer, options)
end | [
"def",
"belongs_to",
"(",
"table",
",",
"options",
"=",
"{",
"}",
")",
"options",
"=",
"options",
".",
"merge",
"(",
":references",
"=>",
"table",
")",
"options",
"[",
":on_delete",
"]",
"=",
"options",
".",
"delete",
"(",
":dependent",
")",
"if",
"opt... | Some people liked this; personally I've decided against using it but I'll keep it nonetheless | [
"Some",
"people",
"liked",
"this",
";",
"personally",
"I",
"ve",
"decided",
"against",
"using",
"it",
"but",
"I",
"ll",
"keep",
"it",
"nonetheless"
] | c87676f8ebca0a1326c5b5c48ae166fdefd3fd2a | https://github.com/mlomnicki/automatic_foreign_key/blob/c87676f8ebca0a1326c5b5c48ae166fdefd3fd2a/lib/automatic_foreign_key/active_record/connection_adapters/table_definition.rb#L40-L44 | train |
codefoundry/svn | lib/svn/streams.rb | Svn.Stream.read_all | def read_all
content = String.new
while bytes = read and !bytes.empty?
content << bytes
end
content
end | ruby | def read_all
content = String.new
while bytes = read and !bytes.empty?
content << bytes
end
content
end | [
"def",
"read_all",
"content",
"=",
"String",
".",
"new",
"while",
"bytes",
"=",
"read",
"and",
"!",
"bytes",
".",
"empty?",
"content",
"<<",
"bytes",
"end",
"content",
"end"
] | reads the stream contents into a String object | [
"reads",
"the",
"stream",
"contents",
"into",
"a",
"String",
"object"
] | 930a8da65fbecf3ffed50655e1cb10fcbc484be4 | https://github.com/codefoundry/svn/blob/930a8da65fbecf3ffed50655e1cb10fcbc484be4/lib/svn/streams.rb#L118-L124 | train |
codefoundry/svn | lib/svn/streams.rb | Svn.Stream.to_string_io | def to_string_io
content = StringIO.new
while bytes = read and !bytes.empty?
content.write( bytes )
end
content.rewind
content
end | ruby | def to_string_io
content = StringIO.new
while bytes = read and !bytes.empty?
content.write( bytes )
end
content.rewind
content
end | [
"def",
"to_string_io",
"content",
"=",
"StringIO",
".",
"new",
"while",
"bytes",
"=",
"read",
"and",
"!",
"bytes",
".",
"empty?",
"content",
".",
"write",
"(",
"bytes",
")",
"end",
"content",
".",
"rewind",
"content",
"end"
] | reads the stream contents into a StringIO object | [
"reads",
"the",
"stream",
"contents",
"into",
"a",
"StringIO",
"object"
] | 930a8da65fbecf3ffed50655e1cb10fcbc484be4 | https://github.com/codefoundry/svn/blob/930a8da65fbecf3ffed50655e1cb10fcbc484be4/lib/svn/streams.rb#L138-L145 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.