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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
kreynolds/phidgets-ffi | lib/phidgets-ffi/common.rb | Phidgets.Common.on_error | def on_error(obj=nil, &block)
@on_error_obj = obj
@on_error = Proc.new { |handle, obj_ptr, code, description|
yield self, object_for(obj_ptr), code, description
}
Phidgets::FFI::Common.set_OnError_Handler(@handle, @on_error, pointer_for(obj))
true
end | ruby | def on_error(obj=nil, &block)
@on_error_obj = obj
@on_error = Proc.new { |handle, obj_ptr, code, description|
yield self, object_for(obj_ptr), code, description
}
Phidgets::FFI::Common.set_OnError_Handler(@handle, @on_error, pointer_for(obj))
true
end | [
"def",
"on_error",
"(",
"obj",
"=",
"nil",
",",
"&",
"block",
")",
"@on_error_obj",
"=",
"obj",
"@on_error",
"=",
"Proc",
".",
"new",
"{",
"|",
"handle",
",",
"obj_ptr",
",",
"code",
",",
"description",
"|",
"yield",
"self",
",",
"object_for",
"(",
"... | Sets an error handler callback function. This is called when an asynchronous error occurs. This is generally used for network errors, and device hardware error messages.
@param [String] obj Object to pass to the callback function. This is optional.
@param [Proc] Block When the callback is executed, the device and ob... | [
"Sets",
"an",
"error",
"handler",
"callback",
"function",
".",
"This",
"is",
"called",
"when",
"an",
"asynchronous",
"error",
"occurs",
".",
"This",
"is",
"generally",
"used",
"for",
"network",
"errors",
"and",
"device",
"hardware",
"error",
"messages",
"."
] | 5c22e206804dc47e8ad37173baf952c874845973 | https://github.com/kreynolds/phidgets-ffi/blob/5c22e206804dc47e8ad37173baf952c874845973/lib/phidgets-ffi/common.rb#L403-L410 | train |
kreynolds/phidgets-ffi | lib/phidgets-ffi/common.rb | Phidgets.Common.on_server_connect | def on_server_connect(obj=nil, &block)
@on_server_connect_obj = obj
@on_server_connect = Proc.new { |handle, obj_ptr|
yield self, object_for(obj_ptr)
}
Phidgets::FFI::Common.set_OnServerConnect_Handler(@handle, @on_server_connect, pointer_for(obj))
true
end | ruby | def on_server_connect(obj=nil, &block)
@on_server_connect_obj = obj
@on_server_connect = Proc.new { |handle, obj_ptr|
yield self, object_for(obj_ptr)
}
Phidgets::FFI::Common.set_OnServerConnect_Handler(@handle, @on_server_connect, pointer_for(obj))
true
end | [
"def",
"on_server_connect",
"(",
"obj",
"=",
"nil",
",",
"&",
"block",
")",
"@on_server_connect_obj",
"=",
"obj",
"@on_server_connect",
"=",
"Proc",
".",
"new",
"{",
"|",
"handle",
",",
"obj_ptr",
"|",
"yield",
"self",
",",
"object_for",
"(",
"obj_ptr",
")... | Sets a server connect handler callback function. This is called for network opened Phidgets when a connection to the PhidgetWebService has been established.
@param [String] obj Object to pass to the callback function. This is optional.
@param [Proc] Block When the callback is executed, the device and object are yiel... | [
"Sets",
"a",
"server",
"connect",
"handler",
"callback",
"function",
".",
"This",
"is",
"called",
"for",
"network",
"opened",
"Phidgets",
"when",
"a",
"connection",
"to",
"the",
"PhidgetWebService",
"has",
"been",
"established",
"."
] | 5c22e206804dc47e8ad37173baf952c874845973 | https://github.com/kreynolds/phidgets-ffi/blob/5c22e206804dc47e8ad37173baf952c874845973/lib/phidgets-ffi/common.rb#L422-L429 | train |
kreynolds/phidgets-ffi | lib/phidgets-ffi/common.rb | Phidgets.Common.on_sleep | def on_sleep(obj=nil, &block)
@on_sleep_obj = obj
@on_sleep = Proc.new { |obj_ptr|
yield object_for(obj_ptr)
}
Phidgets::FFI::Common.set_OnWillSleep_Handler(@on_sleep, pointer_for(obj))
true
end | ruby | def on_sleep(obj=nil, &block)
@on_sleep_obj = obj
@on_sleep = Proc.new { |obj_ptr|
yield object_for(obj_ptr)
}
Phidgets::FFI::Common.set_OnWillSleep_Handler(@on_sleep, pointer_for(obj))
true
end | [
"def",
"on_sleep",
"(",
"obj",
"=",
"nil",
",",
"&",
"block",
")",
"@on_sleep_obj",
"=",
"obj",
"@on_sleep",
"=",
"Proc",
".",
"new",
"{",
"|",
"obj_ptr",
"|",
"yield",
"object_for",
"(",
"obj_ptr",
")",
"}",
"Phidgets",
"::",
"FFI",
"::",
"Common",
... | Sets a sleep handler callback function. This is called when the MacOS X is entering sleep mode.
@param [String] obj Object to pass to the callback function. This is optional.
@param [Proc] Block When the callback is executed, the device and object are yielded to this block.
@example
ifkit.on_sleep do |obj|
... | [
"Sets",
"a",
"sleep",
"handler",
"callback",
"function",
".",
"This",
"is",
"called",
"when",
"the",
"MacOS",
"X",
"is",
"entering",
"sleep",
"mode",
"."
] | 5c22e206804dc47e8ad37173baf952c874845973 | https://github.com/kreynolds/phidgets-ffi/blob/5c22e206804dc47e8ad37173baf952c874845973/lib/phidgets-ffi/common.rb#L461-L469 | train |
kreynolds/phidgets-ffi | lib/phidgets-ffi/common.rb | Phidgets.Common.on_wake | def on_wake(obj=nil, &block)
@on_wake_obj = obj
@on_wake = Proc.new { |obj_ptr|
yield object_for(obj_ptr)
}
Phidgets::FFI::Common.set_OnWakeup_Handler(@on_wake, pointer_for(obj))
true
end | ruby | def on_wake(obj=nil, &block)
@on_wake_obj = obj
@on_wake = Proc.new { |obj_ptr|
yield object_for(obj_ptr)
}
Phidgets::FFI::Common.set_OnWakeup_Handler(@on_wake, pointer_for(obj))
true
end | [
"def",
"on_wake",
"(",
"obj",
"=",
"nil",
",",
"&",
"block",
")",
"@on_wake_obj",
"=",
"obj",
"@on_wake",
"=",
"Proc",
".",
"new",
"{",
"|",
"obj_ptr",
"|",
"yield",
"object_for",
"(",
"obj_ptr",
")",
"}",
"Phidgets",
"::",
"FFI",
"::",
"Common",
"."... | Sets a wake callback function. This is called when the MacOS X is waking up from sleep mode.
@param [String] obj Object to pass to the callback function. This is optional.
@param [Proc] Block When the callback is executed, the device and object are yielded to this block.
@example
ifkit.on_wake do |obj|
... | [
"Sets",
"a",
"wake",
"callback",
"function",
".",
"This",
"is",
"called",
"when",
"the",
"MacOS",
"X",
"is",
"waking",
"up",
"from",
"sleep",
"mode",
"."
] | 5c22e206804dc47e8ad37173baf952c874845973 | https://github.com/kreynolds/phidgets-ffi/blob/5c22e206804dc47e8ad37173baf952c874845973/lib/phidgets-ffi/common.rb#L482-L489 | train |
elektronaut/dynamic_image | lib/dynamic_image/routing.rb | DynamicImage.Routing.image_resources | def image_resources(resource_name, options = {})
options = {
path: "#{resource_name}/:digest(/:size)",
constraints: { size: /\d+x\d+/ },
only: [:show]
}.merge(options)
resources resource_name, options do
get :uncropped, on: :member
get :original, o... | ruby | def image_resources(resource_name, options = {})
options = {
path: "#{resource_name}/:digest(/:size)",
constraints: { size: /\d+x\d+/ },
only: [:show]
}.merge(options)
resources resource_name, options do
get :uncropped, on: :member
get :original, o... | [
"def",
"image_resources",
"(",
"resource_name",
",",
"options",
"=",
"{",
"}",
")",
"options",
"=",
"{",
"path",
":",
"\"#{resource_name}/:digest(/:size)\"",
",",
"constraints",
":",
"{",
"size",
":",
"/",
"\\d",
"\\d",
"/",
"}",
",",
"only",
":",
"[",
"... | Declares an image resource.
image_resources :avatars | [
"Declares",
"an",
"image",
"resource",
"."
] | d711f8f5d8385fb36d7ff9a6012f3fd123005c18 | https://github.com/elektronaut/dynamic_image/blob/d711f8f5d8385fb36d7ff9a6012f3fd123005c18/lib/dynamic_image/routing.rb#L12-L23 | train |
kreynolds/phidgets-ffi | lib/phidgets-ffi/manager.rb | Phidgets.Manager.on_attach | def on_attach(obj=nil, &block)
@on_attach_obj = obj
@on_attach = Proc.new { |handle, obj_ptr|
yield handle, object_for(obj_ptr)
}
Klass.set_OnAttach_Handler(@handle, @on_attach, pointer_for(obj))
end | ruby | def on_attach(obj=nil, &block)
@on_attach_obj = obj
@on_attach = Proc.new { |handle, obj_ptr|
yield handle, object_for(obj_ptr)
}
Klass.set_OnAttach_Handler(@handle, @on_attach, pointer_for(obj))
end | [
"def",
"on_attach",
"(",
"obj",
"=",
"nil",
",",
"&",
"block",
")",
"@on_attach_obj",
"=",
"obj",
"@on_attach",
"=",
"Proc",
".",
"new",
"{",
"|",
"handle",
",",
"obj_ptr",
"|",
"yield",
"handle",
",",
"object_for",
"(",
"obj_ptr",
")",
"}",
"Klass",
... | Sets an attach handler callback function. This is called when a Phidget is plugged into the system.
@param [String] obj Object to pass to the callback function. This is optional.
@param [Proc] Block When the callback is executed, the device and object are yielded to this block.
@example
manager.on_attach do |d... | [
"Sets",
"an",
"attach",
"handler",
"callback",
"function",
".",
"This",
"is",
"called",
"when",
"a",
"Phidget",
"is",
"plugged",
"into",
"the",
"system",
"."
] | 5c22e206804dc47e8ad37173baf952c874845973 | https://github.com/kreynolds/phidgets-ffi/blob/5c22e206804dc47e8ad37173baf952c874845973/lib/phidgets-ffi/manager.rb#L137-L143 | train |
kreynolds/phidgets-ffi | lib/phidgets-ffi/manager.rb | Phidgets.Manager.on_detach | def on_detach(obj=nil, &block)
@on_detach_obj = obj
@on_detach = Proc.new { |handle, obj_ptr|
yield handle, object_for(obj_ptr)
}
Klass.set_OnDetach_Handler(@handle, @on_detach, pointer_for(obj))
end | ruby | def on_detach(obj=nil, &block)
@on_detach_obj = obj
@on_detach = Proc.new { |handle, obj_ptr|
yield handle, object_for(obj_ptr)
}
Klass.set_OnDetach_Handler(@handle, @on_detach, pointer_for(obj))
end | [
"def",
"on_detach",
"(",
"obj",
"=",
"nil",
",",
"&",
"block",
")",
"@on_detach_obj",
"=",
"obj",
"@on_detach",
"=",
"Proc",
".",
"new",
"{",
"|",
"handle",
",",
"obj_ptr",
"|",
"yield",
"handle",
",",
"object_for",
"(",
"obj_ptr",
")",
"}",
"Klass",
... | Sets a detach handler callback function. This is called when a Phidget is unplugged from the system.
@param [String] obj Object to pass to the callback function. This is optional.
@param [Proc] Block When the callback is executed, the device and object are yielded to this block.
@example
manager.on_detach do |... | [
"Sets",
"a",
"detach",
"handler",
"callback",
"function",
".",
"This",
"is",
"called",
"when",
"a",
"Phidget",
"is",
"unplugged",
"from",
"the",
"system",
"."
] | 5c22e206804dc47e8ad37173baf952c874845973 | https://github.com/kreynolds/phidgets-ffi/blob/5c22e206804dc47e8ad37173baf952c874845973/lib/phidgets-ffi/manager.rb#L155-L161 | train |
kreynolds/phidgets-ffi | lib/phidgets-ffi/manager.rb | Phidgets.Manager.on_server_connect | def on_server_connect(obj=nil, &block)
@on_server_connect_obj = obj
@on_server_connect = Proc.new { |handle, obj_ptr|
yield self, object_for(obj_pointer)
}
Klass.set_OnServerConnect_Handler(@handle, @on_server_connect, pointer_for(obj))
end | ruby | def on_server_connect(obj=nil, &block)
@on_server_connect_obj = obj
@on_server_connect = Proc.new { |handle, obj_ptr|
yield self, object_for(obj_pointer)
}
Klass.set_OnServerConnect_Handler(@handle, @on_server_connect, pointer_for(obj))
end | [
"def",
"on_server_connect",
"(",
"obj",
"=",
"nil",
",",
"&",
"block",
")",
"@on_server_connect_obj",
"=",
"obj",
"@on_server_connect",
"=",
"Proc",
".",
"new",
"{",
"|",
"handle",
",",
"obj_ptr",
"|",
"yield",
"self",
",",
"object_for",
"(",
"obj_pointer",
... | Sets a server connect handler callback function. This is used for opening the PhidgetManager remotely, and is called when a connection to the server has been made.
@param [String] obj Object to pass to the callback function. This is optional.
@param [Proc] Block When the callback is executed, the device and object a... | [
"Sets",
"a",
"server",
"connect",
"handler",
"callback",
"function",
".",
"This",
"is",
"used",
"for",
"opening",
"the",
"PhidgetManager",
"remotely",
"and",
"is",
"called",
"when",
"a",
"connection",
"to",
"the",
"server",
"has",
"been",
"made",
"."
] | 5c22e206804dc47e8ad37173baf952c874845973 | https://github.com/kreynolds/phidgets-ffi/blob/5c22e206804dc47e8ad37173baf952c874845973/lib/phidgets-ffi/manager.rb#L173-L179 | train |
kreynolds/phidgets-ffi | lib/phidgets-ffi/manager.rb | Phidgets.Manager.on_server_disconnect | def on_server_disconnect(obj=nil, &block)
@on_server_disconnect_obj = obj
@on_server_disconnect = Proc.new { |handle, obj_ptr|
yield self, object_for(obj_ptr)
}
Klass.set_OnServerDisconnect_Handler(@handle, @on_server_disconnect, pointer_for(obj))
end | ruby | def on_server_disconnect(obj=nil, &block)
@on_server_disconnect_obj = obj
@on_server_disconnect = Proc.new { |handle, obj_ptr|
yield self, object_for(obj_ptr)
}
Klass.set_OnServerDisconnect_Handler(@handle, @on_server_disconnect, pointer_for(obj))
end | [
"def",
"on_server_disconnect",
"(",
"obj",
"=",
"nil",
",",
"&",
"block",
")",
"@on_server_disconnect_obj",
"=",
"obj",
"@on_server_disconnect",
"=",
"Proc",
".",
"new",
"{",
"|",
"handle",
",",
"obj_ptr",
"|",
"yield",
"self",
",",
"object_for",
"(",
"obj_p... | Sets a server disconnect handler callback function. This is used for opening the PhidgetManager remotely, and is called when a connection to the server has been lost
@param [String] obj Object to pass to the callback function. This is optional.
@param [Proc] Block When the callback is executed, the device and object... | [
"Sets",
"a",
"server",
"disconnect",
"handler",
"callback",
"function",
".",
"This",
"is",
"used",
"for",
"opening",
"the",
"PhidgetManager",
"remotely",
"and",
"is",
"called",
"when",
"a",
"connection",
"to",
"the",
"server",
"has",
"been",
"lost"
] | 5c22e206804dc47e8ad37173baf952c874845973 | https://github.com/kreynolds/phidgets-ffi/blob/5c22e206804dc47e8ad37173baf952c874845973/lib/phidgets-ffi/manager.rb#L191-L197 | train |
kreynolds/phidgets-ffi | lib/phidgets-ffi/manager.rb | Phidgets.Manager.on_error | def on_error(obj=nil, &block)
@on_error_obj = obj
@on_error = Proc.new { |handle, obj_ptr, code, description|
yield self, object_for(obj_ptr), code, description
}
Klass.set_OnError_Handler(@handle, @on_error, pointer_for(obj))
end | ruby | def on_error(obj=nil, &block)
@on_error_obj = obj
@on_error = Proc.new { |handle, obj_ptr, code, description|
yield self, object_for(obj_ptr), code, description
}
Klass.set_OnError_Handler(@handle, @on_error, pointer_for(obj))
end | [
"def",
"on_error",
"(",
"obj",
"=",
"nil",
",",
"&",
"block",
")",
"@on_error_obj",
"=",
"obj",
"@on_error",
"=",
"Proc",
".",
"new",
"{",
"|",
"handle",
",",
"obj_ptr",
",",
"code",
",",
"description",
"|",
"yield",
"self",
",",
"object_for",
"(",
"... | Sets a error handler callback function. This is called when an asynchronous error occurs.
@param [String] obj Object to pass to the callback function. This is optional.
@param [Proc] Block When the callback is executed, the device and object are yielded to this block.
@example
manager.on_error do |obj|
... | [
"Sets",
"a",
"error",
"handler",
"callback",
"function",
".",
"This",
"is",
"called",
"when",
"an",
"asynchronous",
"error",
"occurs",
"."
] | 5c22e206804dc47e8ad37173baf952c874845973 | https://github.com/kreynolds/phidgets-ffi/blob/5c22e206804dc47e8ad37173baf952c874845973/lib/phidgets-ffi/manager.rb#L209-L215 | train |
activenetwork-automation/vcoworkflows | lib/vcoworkflows/runner.rb | VcoWorkflows.Runner.execute! | def execute!
exit_code = begin
# Thor accesses these streams directly rather than letting them be
# injected, so we replace them...
$stderr = @stderr
$stdin = @stdin
$stdout = @stdout
VcoWorkflows::CLI.start(@argv)
# Thor::Base#start does not have a return... | ruby | def execute!
exit_code = begin
# Thor accesses these streams directly rather than letting them be
# injected, so we replace them...
$stderr = @stderr
$stdin = @stdin
$stdout = @stdout
VcoWorkflows::CLI.start(@argv)
# Thor::Base#start does not have a return... | [
"def",
"execute!",
"exit_code",
"=",
"begin",
"$stderr",
"=",
"@stderr",
"$stdin",
"=",
"@stdin",
"$stdout",
"=",
"@stdout",
"VcoWorkflows",
"::",
"CLI",
".",
"start",
"(",
"@argv",
")",
"0",
"rescue",
"StandardError",
"=>",
"e",
"b",
"=",
"e",
".",
"bac... | Allow everything fun to be injected from the outside while defaulting to normal implementations.
Do the things! | [
"Allow",
"everything",
"fun",
"to",
"be",
"injected",
"from",
"the",
"outside",
"while",
"defaulting",
"to",
"normal",
"implementations",
".",
"Do",
"the",
"things!"
] | 01db57318c14e572dc47261f55c8d08341306642 | https://github.com/activenetwork-automation/vcoworkflows/blob/01db57318c14e572dc47261f55c8d08341306642/lib/vcoworkflows/runner.rb#L13-L41 | train |
activenetwork-automation/vcoworkflows | lib/vcoworkflows/workflowservice.rb | VcoWorkflows.WorkflowService.get_workflow_for_name | def get_workflow_for_name(name)
path = "/workflows?conditions=name=#{url_encode(name)}"
response = JSON.parse(@session.get(path).body)
# barf if we got anything other than a single workflow
fail(IOError, ERR[:too_many_workflows]) if response['total'] > 1
fail(IOError, ERR[:no_workflow_fou... | ruby | def get_workflow_for_name(name)
path = "/workflows?conditions=name=#{url_encode(name)}"
response = JSON.parse(@session.get(path).body)
# barf if we got anything other than a single workflow
fail(IOError, ERR[:too_many_workflows]) if response['total'] > 1
fail(IOError, ERR[:no_workflow_fou... | [
"def",
"get_workflow_for_name",
"(",
"name",
")",
"path",
"=",
"\"/workflows?conditions=name=#{url_encode(name)}\"",
"response",
"=",
"JSON",
".",
"parse",
"(",
"@session",
".",
"get",
"(",
"path",
")",
".",
"body",
")",
"fail",
"(",
"IOError",
",",
"ERR",
"["... | Get one workflow with a specified name.
@param [String] name Name of the workflow
@return [String] the JSON document of the requested workflow | [
"Get",
"one",
"workflow",
"with",
"a",
"specified",
"name",
"."
] | 01db57318c14e572dc47261f55c8d08341306642 | https://github.com/activenetwork-automation/vcoworkflows/blob/01db57318c14e572dc47261f55c8d08341306642/lib/vcoworkflows/workflowservice.rb#L43-L59 | train |
activenetwork-automation/vcoworkflows | lib/vcoworkflows/workflowservice.rb | VcoWorkflows.WorkflowService.get_execution_list | def get_execution_list(workflow_id)
path = "/workflows/#{workflow_id}/executions/"
relations = JSON.parse(@session.get(path).body)['relations']
# The first two elements of the relations['link'] array are URLS,
# so scrap them. Everything else is an execution.
executions = {}
relation... | ruby | def get_execution_list(workflow_id)
path = "/workflows/#{workflow_id}/executions/"
relations = JSON.parse(@session.get(path).body)['relations']
# The first two elements of the relations['link'] array are URLS,
# so scrap them. Everything else is an execution.
executions = {}
relation... | [
"def",
"get_execution_list",
"(",
"workflow_id",
")",
"path",
"=",
"\"/workflows/#{workflow_id}/executions/\"",
"relations",
"=",
"JSON",
".",
"parse",
"(",
"@session",
".",
"get",
"(",
"path",
")",
".",
"body",
")",
"[",
"'relations'",
"]",
"executions",
"=",
... | Get a list of executions for the given workflow GUID
@param [String] workflow_id Workflow GUID
@return [Hash] workflow executions, keyed by execution ID | [
"Get",
"a",
"list",
"of",
"executions",
"for",
"the",
"given",
"workflow",
"GUID"
] | 01db57318c14e572dc47261f55c8d08341306642 | https://github.com/activenetwork-automation/vcoworkflows/blob/01db57318c14e572dc47261f55c8d08341306642/lib/vcoworkflows/workflowservice.rb#L73-L86 | train |
activenetwork-automation/vcoworkflows | lib/vcoworkflows/workflowservice.rb | VcoWorkflows.WorkflowService.execute_workflow | def execute_workflow(id, parameter_json)
path = "/workflows/#{id}/executions/"
response = @session.post(path, parameter_json)
# Execution ID is the final component in the Location header URL, so
# chop off the front, then pull off any trailing /
response.headers[:location].gsub(%r{^.*/exec... | ruby | def execute_workflow(id, parameter_json)
path = "/workflows/#{id}/executions/"
response = @session.post(path, parameter_json)
# Execution ID is the final component in the Location header URL, so
# chop off the front, then pull off any trailing /
response.headers[:location].gsub(%r{^.*/exec... | [
"def",
"execute_workflow",
"(",
"id",
",",
"parameter_json",
")",
"path",
"=",
"\"/workflows/#{id}/executions/\"",
"response",
"=",
"@session",
".",
"post",
"(",
"path",
",",
"parameter_json",
")",
"response",
".",
"headers",
"[",
":location",
"]",
".",
"gsub",
... | Submit the given workflow for execution
@param [String] id Workflow GUID for the workflow we want to execute
@param [String] parameter_json JSON document of input parameters
@return [String] Execution ID | [
"Submit",
"the",
"given",
"workflow",
"for",
"execution"
] | 01db57318c14e572dc47261f55c8d08341306642 | https://github.com/activenetwork-automation/vcoworkflows/blob/01db57318c14e572dc47261f55c8d08341306642/lib/vcoworkflows/workflowservice.rb#L101-L107 | train |
nwjsmith/thumbtack | lib/thumbtack/specification.rb | Thumbtack.Specification.parameters | def parameters(arguments)
Hash[
arguments.map do |name, value|
type_handler = @type_handlers.fetch(name)
type_handler.validate(value)
[name, type_handler.serialize(value)]
end
]
end | ruby | def parameters(arguments)
Hash[
arguments.map do |name, value|
type_handler = @type_handlers.fetch(name)
type_handler.validate(value)
[name, type_handler.serialize(value)]
end
]
end | [
"def",
"parameters",
"(",
"arguments",
")",
"Hash",
"[",
"arguments",
".",
"map",
"do",
"|",
"name",
",",
"value",
"|",
"type_handler",
"=",
"@type_handlers",
".",
"fetch",
"(",
"name",
")",
"type_handler",
".",
"validate",
"(",
"value",
")",
"[",
"name"... | Initialize a Specification
@param [Hash{Symbol => Type}] type_handlers
a map of parameter names to their type handlers
Validate and translate client parameters to their Pinboard values
@param [Hash{Symbol => Object}] arguments
parameter names associated with their values
@return [Hash{Symbol => Object}]
... | [
"Initialize",
"a",
"Specification"
] | f7d5323b91b901c7d61daadb9ef9c1ed08a3a7cb | https://github.com/nwjsmith/thumbtack/blob/f7d5323b91b901c7d61daadb9ef9c1ed08a3a7cb/lib/thumbtack/specification.rb#L24-L32 | train |
activenetwork-automation/vcoworkflows | lib/vcoworkflows/workflowexecutionlog.rb | VcoWorkflows.WorkflowExecutionLog.to_s | def to_s
message = ''
@messages.keys.sort.each do |timestamp|
message << "#{Time.at(timestamp / 1000)}"
message << " #{@messages[timestamp]['severity']}: #{@messages[timestamp]['user']}:"
message << " #{@messages[timestamp]['short-description']}"
unless @messages[timestamp]['... | ruby | def to_s
message = ''
@messages.keys.sort.each do |timestamp|
message << "#{Time.at(timestamp / 1000)}"
message << " #{@messages[timestamp]['severity']}: #{@messages[timestamp]['user']}:"
message << " #{@messages[timestamp]['short-description']}"
unless @messages[timestamp]['... | [
"def",
"to_s",
"message",
"=",
"''",
"@messages",
".",
"keys",
".",
"sort",
".",
"each",
"do",
"|",
"timestamp",
"|",
"message",
"<<",
"\"#{Time.at(timestamp / 1000)}\"",
"message",
"<<",
"\" #{@messages[timestamp]['severity']}: #{@messages[timestamp]['user']}:\"",
"messa... | Create an execution log object
@param [String] log_json JSON document as string
@return [VcoWorkflows::WorkflowExecutionLog]
rubocop:disable MethodLength, LineLength
Stringify the log
@return [String] | [
"Create",
"an",
"execution",
"log",
"object"
] | 01db57318c14e572dc47261f55c8d08341306642 | https://github.com/activenetwork-automation/vcoworkflows/blob/01db57318c14e572dc47261f55c8d08341306642/lib/vcoworkflows/workflowexecutionlog.rb#L27-L39 | train |
kreynolds/phidgets-ffi | lib/phidgets-ffi/led.rb | Phidgets.LED.current_limit= | def current_limit=(new_current_limit)
ptr = ::FFI::MemoryPointer.new(:int)
Klass.setCurrentLimit(@handle, Phidgets::FFI::LEDCurrentLimit[new_current_limit])
new_current_limit
end | ruby | def current_limit=(new_current_limit)
ptr = ::FFI::MemoryPointer.new(:int)
Klass.setCurrentLimit(@handle, Phidgets::FFI::LEDCurrentLimit[new_current_limit])
new_current_limit
end | [
"def",
"current_limit",
"=",
"(",
"new_current_limit",
")",
"ptr",
"=",
"::",
"FFI",
"::",
"MemoryPointer",
".",
"new",
"(",
":int",
")",
"Klass",
".",
"setCurrentLimit",
"(",
"@handle",
",",
"Phidgets",
"::",
"FFI",
"::",
"LEDCurrentLimit",
"[",
"new_curren... | Sets the board current limit for all LEDs, or raises an error. Not supported on all PhidgetLEDs.
@param [Phidgets::FFI::LEDCurrentLimit] new_current_limit new current limit
@return [Phidgets::FFI::LEDCurrentLimit] returns the board current limit, or raises an error. | [
"Sets",
"the",
"board",
"current",
"limit",
"for",
"all",
"LEDs",
"or",
"raises",
"an",
"error",
".",
"Not",
"supported",
"on",
"all",
"PhidgetLEDs",
"."
] | 5c22e206804dc47e8ad37173baf952c874845973 | https://github.com/kreynolds/phidgets-ffi/blob/5c22e206804dc47e8ad37173baf952c874845973/lib/phidgets-ffi/led.rb#L32-L36 | train |
kreynolds/phidgets-ffi | lib/phidgets-ffi/led.rb | Phidgets.LED.voltage= | def voltage=(new_voltage)
ptr = ::FFI::MemoryPointer.new(:int)
Klass.setVoltage(@handle, Phidgets::FFI::LEDVoltage[new_voltage])
new_voltage
end | ruby | def voltage=(new_voltage)
ptr = ::FFI::MemoryPointer.new(:int)
Klass.setVoltage(@handle, Phidgets::FFI::LEDVoltage[new_voltage])
new_voltage
end | [
"def",
"voltage",
"=",
"(",
"new_voltage",
")",
"ptr",
"=",
"::",
"FFI",
"::",
"MemoryPointer",
".",
"new",
"(",
":int",
")",
"Klass",
".",
"setVoltage",
"(",
"@handle",
",",
"Phidgets",
"::",
"FFI",
"::",
"LEDVoltage",
"[",
"new_voltage",
"]",
")",
"n... | Sets the voltage level for all LEDs, or raises an error. Not supported on all PhidgetLEDs.
@param [Phidgets::FFI::LEDVoltage] new_voltage new voltage
@return [Phidgets::FFI::LEDVoltage] returns the voltage level, or raises an error. | [
"Sets",
"the",
"voltage",
"level",
"for",
"all",
"LEDs",
"or",
"raises",
"an",
"error",
".",
"Not",
"supported",
"on",
"all",
"PhidgetLEDs",
"."
] | 5c22e206804dc47e8ad37173baf952c874845973 | https://github.com/kreynolds/phidgets-ffi/blob/5c22e206804dc47e8ad37173baf952c874845973/lib/phidgets-ffi/led.rb#L48-L52 | train |
kreynolds/phidgets-ffi | lib/phidgets-ffi/stepper.rb | Phidgets.Stepper.on_velocity_change | def on_velocity_change(obj=nil, &block)
@on_velocity_change_obj = obj
@on_velocity_change = Proc.new { |device, obj_ptr, index, velocity|
yield self, @steppers[index], velocity, object_for(obj_ptr)
}
Klass.set_OnVelocityChange_Handler(@handle, @on_velocity_change, pointer_for(obj))
e... | ruby | def on_velocity_change(obj=nil, &block)
@on_velocity_change_obj = obj
@on_velocity_change = Proc.new { |device, obj_ptr, index, velocity|
yield self, @steppers[index], velocity, object_for(obj_ptr)
}
Klass.set_OnVelocityChange_Handler(@handle, @on_velocity_change, pointer_for(obj))
e... | [
"def",
"on_velocity_change",
"(",
"obj",
"=",
"nil",
",",
"&",
"block",
")",
"@on_velocity_change_obj",
"=",
"obj",
"@on_velocity_change",
"=",
"Proc",
".",
"new",
"{",
"|",
"device",
",",
"obj_ptr",
",",
"index",
",",
"velocity",
"|",
"yield",
"self",
","... | Sets a velocity change handler callback function. This is called when a stepper velocity changes.
@param [String] obj Object to pass to the callback function. This is optional.
@param [Proc] Block When the callback is executed, the device and object are yielded to this block.
@example
st.on_velocity_change do ... | [
"Sets",
"a",
"velocity",
"change",
"handler",
"callback",
"function",
".",
"This",
"is",
"called",
"when",
"a",
"stepper",
"velocity",
"changes",
"."
] | 5c22e206804dc47e8ad37173baf952c874845973 | https://github.com/kreynolds/phidgets-ffi/blob/5c22e206804dc47e8ad37173baf952c874845973/lib/phidgets-ffi/stepper.rb#L55-L61 | train |
kreynolds/phidgets-ffi | lib/phidgets-ffi/accelerometer.rb | Phidgets.Accelerometer.on_acceleration_change | def on_acceleration_change(obj=nil, &block)
@on_acceleration_change_obj = obj
@on_acceleration_change = Proc.new { |device, obj_ptr, ind, acc|
yield self, axes[ind], acc, object_for(obj_ptr)
}
Klass.set_OnAccelerationChange_Handler(@handle, @on_acceleration_change, pointer_for(obj))
end | ruby | def on_acceleration_change(obj=nil, &block)
@on_acceleration_change_obj = obj
@on_acceleration_change = Proc.new { |device, obj_ptr, ind, acc|
yield self, axes[ind], acc, object_for(obj_ptr)
}
Klass.set_OnAccelerationChange_Handler(@handle, @on_acceleration_change, pointer_for(obj))
end | [
"def",
"on_acceleration_change",
"(",
"obj",
"=",
"nil",
",",
"&",
"block",
")",
"@on_acceleration_change_obj",
"=",
"obj",
"@on_acceleration_change",
"=",
"Proc",
".",
"new",
"{",
"|",
"device",
",",
"obj_ptr",
",",
"ind",
",",
"acc",
"|",
"yield",
"self",
... | Sets an acceleration change handler callback function. This is called when the acceleration of an axis changes by more than the set sensitivity.
@param [String] obj Object to pass to the callback function. This is optional.
@param [Proc] Block When the callback is executed, the device and object are yielded to this ... | [
"Sets",
"an",
"acceleration",
"change",
"handler",
"callback",
"function",
".",
"This",
"is",
"called",
"when",
"the",
"acceleration",
"of",
"an",
"axis",
"changes",
"by",
"more",
"than",
"the",
"set",
"sensitivity",
"."
] | 5c22e206804dc47e8ad37173baf952c874845973 | https://github.com/kreynolds/phidgets-ffi/blob/5c22e206804dc47e8ad37173baf952c874845973/lib/phidgets-ffi/accelerometer.rb#L32-L38 | train |
elektronaut/dynamic_image | lib/dynamic_image/processed_image.rb | DynamicImage.ProcessedImage.cropped_and_resized | def cropped_and_resized(size)
normalized do |image|
if record.cropped? || size != record.size
image.crop(image_sizing.crop_geometry_string(size))
image.resize(size)
end
end
end | ruby | def cropped_and_resized(size)
normalized do |image|
if record.cropped? || size != record.size
image.crop(image_sizing.crop_geometry_string(size))
image.resize(size)
end
end
end | [
"def",
"cropped_and_resized",
"(",
"size",
")",
"normalized",
"do",
"|",
"image",
"|",
"if",
"record",
".",
"cropped?",
"||",
"size",
"!=",
"record",
".",
"size",
"image",
".",
"crop",
"(",
"image_sizing",
".",
"crop_geometry_string",
"(",
"size",
")",
")"... | Crops and resizes the image. Normalization is performed as well.
==== Example
processed = DynamicImage::ProcessedImage.new(image)
image_data = processed.cropped_and_resized(Vector2d.new(200, 200))
Returns a binary string. | [
"Crops",
"and",
"resizes",
"the",
"image",
".",
"Normalization",
"is",
"performed",
"as",
"well",
"."
] | d711f8f5d8385fb36d7ff9a6012f3fd123005c18 | https://github.com/elektronaut/dynamic_image/blob/d711f8f5d8385fb36d7ff9a6012f3fd123005c18/lib/dynamic_image/processed_image.rb#L37-L44 | train |
elektronaut/dynamic_image | lib/dynamic_image/processed_image.rb | DynamicImage.ProcessedImage.normalized | def normalized
require_valid_image!
process_data do |image|
image.combine_options do |combined|
combined.auto_orient
combined.colorspace("sRGB") if needs_colorspace_conversion?
yield(combined) if block_given?
optimize(combined)
end
image.format... | ruby | def normalized
require_valid_image!
process_data do |image|
image.combine_options do |combined|
combined.auto_orient
combined.colorspace("sRGB") if needs_colorspace_conversion?
yield(combined) if block_given?
optimize(combined)
end
image.format... | [
"def",
"normalized",
"require_valid_image!",
"process_data",
"do",
"|",
"image",
"|",
"image",
".",
"combine_options",
"do",
"|",
"combined",
"|",
"combined",
".",
"auto_orient",
"combined",
".",
"colorspace",
"(",
"\"sRGB\"",
")",
"if",
"needs_colorspace_conversion... | Normalizes the image.
* Applies EXIF rotation
* CMYK images are converted to sRGB
* Strips metadata
* Optimizes GIFs
* Performs format conversion if the requested format is different
==== Example
processed = DynamicImage::ProcessedImage.new(image, :jpeg)
jpg_data = processed.normalized
Returns a binary... | [
"Normalizes",
"the",
"image",
"."
] | d711f8f5d8385fb36d7ff9a6012f3fd123005c18 | https://github.com/elektronaut/dynamic_image/blob/d711f8f5d8385fb36d7ff9a6012f3fd123005c18/lib/dynamic_image/processed_image.rb#L60-L71 | train |
axsh/isono | lib/isono/manifest.rb | Isono.Manifest.load_config | def load_config(path)
return unless File.exist?(path)
buf = File.read(path)
eval("#{buf}", binding, path)
end | ruby | def load_config(path)
return unless File.exist?(path)
buf = File.read(path)
eval("#{buf}", binding, path)
end | [
"def",
"load_config",
"(",
"path",
")",
"return",
"unless",
"File",
".",
"exist?",
"(",
"path",
")",
"buf",
"=",
"File",
".",
"read",
"(",
"path",
")",
"eval",
"(",
"\"#{buf}\"",
",",
"binding",
",",
"path",
")",
"end"
] | load config file and merge up with the config tree.
it will not work when the config_path is nil or the file is missed | [
"load",
"config",
"file",
"and",
"merge",
"up",
"with",
"the",
"config",
"tree",
".",
"it",
"will",
"not",
"work",
"when",
"the",
"config_path",
"is",
"nil",
"or",
"the",
"file",
"is",
"missed"
] | 0325eb1a46538b8eea63e80745a9161e2532b7cf | https://github.com/axsh/isono/blob/0325eb1a46538b8eea63e80745a9161e2532b7cf/lib/isono/manifest.rb#L86-L90 | train |
manojmj92/fulfil-ruby | lib/fulfil/base.rb | Fulfil.Base.method_missing | def method_missing(method)
method = method.to_s
raise NoMethodError, "No such method: #{method}" unless @args.keys.include? method
@args[method]
end | ruby | def method_missing(method)
method = method.to_s
raise NoMethodError, "No such method: #{method}" unless @args.keys.include? method
@args[method]
end | [
"def",
"method_missing",
"(",
"method",
")",
"method",
"=",
"method",
".",
"to_s",
"raise",
"NoMethodError",
",",
"\"No such method: #{method}\"",
"unless",
"@args",
".",
"keys",
".",
"include?",
"method",
"@args",
"[",
"method",
"]",
"end"
] | This will return arguments as object methods. | [
"This",
"will",
"return",
"arguments",
"as",
"object",
"methods",
"."
] | f47832eeb4137c8cc531fab4c1f9a181e6be5652 | https://github.com/manojmj92/fulfil-ruby/blob/f47832eeb4137c8cc531fab4c1f9a181e6be5652/lib/fulfil/base.rb#L38-L42 | train |
kreynolds/phidgets-ffi | lib/phidgets-ffi/motor_control.rb | Phidgets.MotorControl.attributes | def attributes
super.merge({
:motors => motors.size,
:encoders => encoders.size,
:inputs => inputs.size,
:sensors => sensors.size,
:ratiometric => ratiometric
})
end | ruby | def attributes
super.merge({
:motors => motors.size,
:encoders => encoders.size,
:inputs => inputs.size,
:sensors => sensors.size,
:ratiometric => ratiometric
})
end | [
"def",
"attributes",
"super",
".",
"merge",
"(",
"{",
":motors",
"=>",
"motors",
".",
"size",
",",
":encoders",
"=>",
"encoders",
".",
"size",
",",
":inputs",
"=>",
"inputs",
".",
"size",
",",
":sensors",
"=>",
"sensors",
".",
"size",
",",
":ratiometric"... | The attributes of a PhidgetMotorControl | [
"The",
"attributes",
"of",
"a",
"PhidgetMotorControl"
] | 5c22e206804dc47e8ad37173baf952c874845973 | https://github.com/kreynolds/phidgets-ffi/blob/5c22e206804dc47e8ad37173baf952c874845973/lib/phidgets-ffi/motor_control.rb#L28-L36 | train |
kreynolds/phidgets-ffi | lib/phidgets-ffi/motor_control.rb | Phidgets.MotorControl.on_current_change | def on_current_change(obj=nil, &block)
@on_current_change_obj = obj
@on_current_change = Proc.new { |device, obj_ptr, motor, current|
yield self, @motors[motor], current, object_for(obj_ptr)
}
Klass.set_OnCurrentChange_Handler(@handle, @on_current_change, pointer_for(obj))
end | ruby | def on_current_change(obj=nil, &block)
@on_current_change_obj = obj
@on_current_change = Proc.new { |device, obj_ptr, motor, current|
yield self, @motors[motor], current, object_for(obj_ptr)
}
Klass.set_OnCurrentChange_Handler(@handle, @on_current_change, pointer_for(obj))
end | [
"def",
"on_current_change",
"(",
"obj",
"=",
"nil",
",",
"&",
"block",
")",
"@on_current_change_obj",
"=",
"obj",
"@on_current_change",
"=",
"Proc",
".",
"new",
"{",
"|",
"device",
",",
"obj_ptr",
",",
"motor",
",",
"current",
"|",
"yield",
"self",
",",
... | Sets a current change handler callback function. This is called when the current consumed by a motor changes.
@param [String] obj Object to pass to the callback function. This is optional.
@param [Proc] Block When the callback is executed, the device and object are yielded to this block.
@example
mc.on_current... | [
"Sets",
"a",
"current",
"change",
"handler",
"callback",
"function",
".",
"This",
"is",
"called",
"when",
"the",
"current",
"consumed",
"by",
"a",
"motor",
"changes",
"."
] | 5c22e206804dc47e8ad37173baf952c874845973 | https://github.com/kreynolds/phidgets-ffi/blob/5c22e206804dc47e8ad37173baf952c874845973/lib/phidgets-ffi/motor_control.rb#L68-L76 | train |
kreynolds/phidgets-ffi | lib/phidgets-ffi/motor_control.rb | Phidgets.MotorControl.on_back_emf_update | def on_back_emf_update(obj=nil, &block)
@on_back_emf_update_obj = obj
@on_back_emf_update = Proc.new { |device, obj_ptr, motor, voltage|
yield self, @motors[motor], voltage, object_for(obj_ptr)
}
Klass.set_OnBackEMFUpdate_Handler(@handle, @on_back_emf_update, pointer_for(obj))
end | ruby | def on_back_emf_update(obj=nil, &block)
@on_back_emf_update_obj = obj
@on_back_emf_update = Proc.new { |device, obj_ptr, motor, voltage|
yield self, @motors[motor], voltage, object_for(obj_ptr)
}
Klass.set_OnBackEMFUpdate_Handler(@handle, @on_back_emf_update, pointer_for(obj))
end | [
"def",
"on_back_emf_update",
"(",
"obj",
"=",
"nil",
",",
"&",
"block",
")",
"@on_back_emf_update_obj",
"=",
"obj",
"@on_back_emf_update",
"=",
"Proc",
".",
"new",
"{",
"|",
"device",
",",
"obj_ptr",
",",
"motor",
",",
"voltage",
"|",
"yield",
"self",
",",... | Sets a Back EMF update handler callback function. This is called at a steady rate of 16ms, when BackEMF sensing is enabled.
@param [String] obj Object to pass to the callback function. This is optional.
@param [Proc] Block When the callback is executed, the device and object are yielded to this block.
@example
... | [
"Sets",
"a",
"Back",
"EMF",
"update",
"handler",
"callback",
"function",
".",
"This",
"is",
"called",
"at",
"a",
"steady",
"rate",
"of",
"16ms",
"when",
"BackEMF",
"sensing",
"is",
"enabled",
"."
] | 5c22e206804dc47e8ad37173baf952c874845973 | https://github.com/kreynolds/phidgets-ffi/blob/5c22e206804dc47e8ad37173baf952c874845973/lib/phidgets-ffi/motor_control.rb#L126-L132 | train |
kreynolds/phidgets-ffi | lib/phidgets-ffi/motor_control.rb | Phidgets.MotorControl.on_position_update | def on_position_update(obj=nil, &block)
@on_position_update_obj = obj
@on_position_update = Proc.new { |device, obj_ptr, encoder, position|
yield self, @encoders[encoder], position, object_for(obj_ptr)
}
Klass.set_OnEncoderPositionUpdate_Handler(@handle, @on_position_update, pointer_for(obj))... | ruby | def on_position_update(obj=nil, &block)
@on_position_update_obj = obj
@on_position_update = Proc.new { |device, obj_ptr, encoder, position|
yield self, @encoders[encoder], position, object_for(obj_ptr)
}
Klass.set_OnEncoderPositionUpdate_Handler(@handle, @on_position_update, pointer_for(obj))... | [
"def",
"on_position_update",
"(",
"obj",
"=",
"nil",
",",
"&",
"block",
")",
"@on_position_update_obj",
"=",
"obj",
"@on_position_update",
"=",
"Proc",
".",
"new",
"{",
"|",
"device",
",",
"obj_ptr",
",",
"encoder",
",",
"position",
"|",
"yield",
"self",
"... | Sets a position update handler callback function. This event provides data about how many ticks have occured since the last update event. It is called at a steady rate of 8ms.
@param [String] obj Object to pass to the callback function. This is optional.
@param [Proc] Block When the callback is executed, the device ... | [
"Sets",
"a",
"position",
"update",
"handler",
"callback",
"function",
".",
"This",
"event",
"provides",
"data",
"about",
"how",
"many",
"ticks",
"have",
"occured",
"since",
"the",
"last",
"update",
"event",
".",
"It",
"is",
"called",
"at",
"a",
"steady",
"... | 5c22e206804dc47e8ad37173baf952c874845973 | https://github.com/kreynolds/phidgets-ffi/blob/5c22e206804dc47e8ad37173baf952c874845973/lib/phidgets-ffi/motor_control.rb#L164-L172 | train |
kreynolds/phidgets-ffi | lib/phidgets-ffi/motor_control.rb | Phidgets.MotorControl.on_sensor_update | def on_sensor_update(obj=nil, &block)
@on_sensor_update_obj = obj
@on_sensor_update = Proc.new { |device, obj_ptr, index, value|
yield self, @sensors[index], value, object_for(obj_ptr)
}
Klass.set_OnSensorUpdate_Handler(@handle, @on_sensor_update, pointer_for(obj))
end | ruby | def on_sensor_update(obj=nil, &block)
@on_sensor_update_obj = obj
@on_sensor_update = Proc.new { |device, obj_ptr, index, value|
yield self, @sensors[index], value, object_for(obj_ptr)
}
Klass.set_OnSensorUpdate_Handler(@handle, @on_sensor_update, pointer_for(obj))
end | [
"def",
"on_sensor_update",
"(",
"obj",
"=",
"nil",
",",
"&",
"block",
")",
"@on_sensor_update_obj",
"=",
"obj",
"@on_sensor_update",
"=",
"Proc",
".",
"new",
"{",
"|",
"device",
",",
"obj_ptr",
",",
"index",
",",
"value",
"|",
"yield",
"self",
",",
"@sen... | Sets a sensor update handler callback function. This is called at a steady rate of 8ms.
@param [String] obj Object to pass to the callback function. This is optional.
@param [Proc] Block When the callback is executed, the device and object are yielded to this block.
@example
mc.on_sensor_update do |device, sen... | [
"Sets",
"a",
"sensor",
"update",
"handler",
"callback",
"function",
".",
"This",
"is",
"called",
"at",
"a",
"steady",
"rate",
"of",
"8ms",
"."
] | 5c22e206804dc47e8ad37173baf952c874845973 | https://github.com/kreynolds/phidgets-ffi/blob/5c22e206804dc47e8ad37173baf952c874845973/lib/phidgets-ffi/motor_control.rb#L184-L190 | train |
kreynolds/phidgets-ffi | lib/phidgets-ffi/motor_control.rb | Phidgets.MotorControl.ratiometric | def ratiometric
ptr = ::FFI::MemoryPointer.new(:int)
Klass.getRatiometric(@handle, ptr)
(ptr.get_int(0) == 0) ? false : true
end | ruby | def ratiometric
ptr = ::FFI::MemoryPointer.new(:int)
Klass.getRatiometric(@handle, ptr)
(ptr.get_int(0) == 0) ? false : true
end | [
"def",
"ratiometric",
"ptr",
"=",
"::",
"FFI",
"::",
"MemoryPointer",
".",
"new",
"(",
":int",
")",
"Klass",
".",
"getRatiometric",
"(",
"@handle",
",",
"ptr",
")",
"(",
"ptr",
".",
"get_int",
"(",
"0",
")",
"==",
"0",
")",
"?",
"false",
":",
"true... | Returns the ratiometric state of the board
@return [Boolean] returns the ratiometric state or raises an error | [
"Returns",
"the",
"ratiometric",
"state",
"of",
"the",
"board"
] | 5c22e206804dc47e8ad37173baf952c874845973 | https://github.com/kreynolds/phidgets-ffi/blob/5c22e206804dc47e8ad37173baf952c874845973/lib/phidgets-ffi/motor_control.rb#L195-L199 | train |
notEthan/jsi | lib/jsi/base.rb | JSI.Base.pretty_print | def pretty_print(q)
q.instance_exec(self) do |obj|
text "\#<#{obj.class.to_s}"
group_sub {
nest(2) {
breakable ' '
pp obj.instance
}
}
breakable ''
text '>'
end
end | ruby | def pretty_print(q)
q.instance_exec(self) do |obj|
text "\#<#{obj.class.to_s}"
group_sub {
nest(2) {
breakable ' '
pp obj.instance
}
}
breakable ''
text '>'
end
end | [
"def",
"pretty_print",
"(",
"q",
")",
"q",
".",
"instance_exec",
"(",
"self",
")",
"do",
"|",
"obj",
"|",
"text",
"\"\\#<#{obj.class.to_s}\"",
"group_sub",
"{",
"nest",
"(",
"2",
")",
"{",
"breakable",
"' '",
"pp",
"obj",
".",
"instance",
"}",
"}",
"br... | pretty-prints a representation this JSI to the given printer
@return [void] | [
"pretty",
"-",
"prints",
"a",
"representation",
"this",
"JSI",
"to",
"the",
"given",
"printer"
] | 57483606e9d1996ce589e1797bd9948fa0684b88 | https://github.com/notEthan/jsi/blob/57483606e9d1996ce589e1797bd9948fa0684b88/lib/jsi/base.rb#L175-L187 | train |
notEthan/jsi | lib/jsi/base.rb | JSI.Base.subscript_assign | def subscript_assign(subscript, value)
clear_memo(:[], subscript)
if value.is_a?(Base)
instance[subscript] = value.instance
else
instance[subscript] = value
end
end | ruby | def subscript_assign(subscript, value)
clear_memo(:[], subscript)
if value.is_a?(Base)
instance[subscript] = value.instance
else
instance[subscript] = value
end
end | [
"def",
"subscript_assign",
"(",
"subscript",
",",
"value",
")",
"clear_memo",
"(",
":[]",
",",
"subscript",
")",
"if",
"value",
".",
"is_a?",
"(",
"Base",
")",
"instance",
"[",
"subscript",
"]",
"=",
"value",
".",
"instance",
"else",
"instance",
"[",
"su... | assigns a subscript, taking care of memoization and unwrapping a JSI if given.
@param subscript [Object] the bit between the [ and ]
@param value [JSI::Base, Object] the value to be assigned | [
"assigns",
"a",
"subscript",
"taking",
"care",
"of",
"memoization",
"and",
"unwrapping",
"a",
"JSI",
"if",
"given",
"."
] | 57483606e9d1996ce589e1797bd9948fa0684b88 | https://github.com/notEthan/jsi/blob/57483606e9d1996ce589e1797bd9948fa0684b88/lib/jsi/base.rb#L226-L233 | train |
kreynolds/phidgets-ffi | lib/phidgets-ffi/rfid.rb | Phidgets.RFID.on_output_change | def on_output_change(obj=nil, &block)
@on_output_change_obj = obj
@on_output_change = Proc.new { |device, obj_ptr, index, state|
yield self, @outputs[index], (state == 0 ? false : true), object_for(obj_ptr)
}
Klass.set_OnOutputChange_Handler(@handle, @on_output_change, pointer_for(obj))
... | ruby | def on_output_change(obj=nil, &block)
@on_output_change_obj = obj
@on_output_change = Proc.new { |device, obj_ptr, index, state|
yield self, @outputs[index], (state == 0 ? false : true), object_for(obj_ptr)
}
Klass.set_OnOutputChange_Handler(@handle, @on_output_change, pointer_for(obj))
... | [
"def",
"on_output_change",
"(",
"obj",
"=",
"nil",
",",
"&",
"block",
")",
"@on_output_change_obj",
"=",
"obj",
"@on_output_change",
"=",
"Proc",
".",
"new",
"{",
"|",
"device",
",",
"obj_ptr",
",",
"index",
",",
"state",
"|",
"yield",
"self",
",",
"@out... | Sets an output change handler callback function. This is called when a digital output on the PhidgetRFID board has changed.
@param [String] obj Object to pass to the callback function. This is optional.
@param [Proc] Block When the callback is executed, the device and object are yielded to this block.
@example
... | [
"Sets",
"an",
"output",
"change",
"handler",
"callback",
"function",
".",
"This",
"is",
"called",
"when",
"a",
"digital",
"output",
"on",
"the",
"PhidgetRFID",
"board",
"has",
"changed",
"."
] | 5c22e206804dc47e8ad37173baf952c874845973 | https://github.com/kreynolds/phidgets-ffi/blob/5c22e206804dc47e8ad37173baf952c874845973/lib/phidgets-ffi/rfid.rb#L34-L40 | train |
kreynolds/phidgets-ffi | lib/phidgets-ffi/rfid.rb | Phidgets.RFID.on_tag | def on_tag(obj=nil, &block)
@on_tag_obj = obj
@on_tag = Proc.new { |device, obj_ptr, tag, proto|
yield self, tag.read_string, object_for(obj_ptr)
}
Klass.set_OnTag2_Handler(@handle, @on_tag, pointer_for(obj))
end | ruby | def on_tag(obj=nil, &block)
@on_tag_obj = obj
@on_tag = Proc.new { |device, obj_ptr, tag, proto|
yield self, tag.read_string, object_for(obj_ptr)
}
Klass.set_OnTag2_Handler(@handle, @on_tag, pointer_for(obj))
end | [
"def",
"on_tag",
"(",
"obj",
"=",
"nil",
",",
"&",
"block",
")",
"@on_tag_obj",
"=",
"obj",
"@on_tag",
"=",
"Proc",
".",
"new",
"{",
"|",
"device",
",",
"obj_ptr",
",",
"tag",
",",
"proto",
"|",
"yield",
"self",
",",
"tag",
".",
"read_string",
",",... | Sets a tag handler callback function. This is called when a new tag is seen by the reader. The event is only fired one time for a new tag, so the tag has to be removed and then replaced before another tag gained event will fire.
@param [String] obj Object to pass to the callback function. This is optional.
@param [P... | [
"Sets",
"a",
"tag",
"handler",
"callback",
"function",
".",
"This",
"is",
"called",
"when",
"a",
"new",
"tag",
"is",
"seen",
"by",
"the",
"reader",
".",
"The",
"event",
"is",
"only",
"fired",
"one",
"time",
"for",
"a",
"new",
"tag",
"so",
"the",
"tag... | 5c22e206804dc47e8ad37173baf952c874845973 | https://github.com/kreynolds/phidgets-ffi/blob/5c22e206804dc47e8ad37173baf952c874845973/lib/phidgets-ffi/rfid.rb#L52-L58 | train |
kreynolds/phidgets-ffi | lib/phidgets-ffi/rfid.rb | Phidgets.RFID.on_tag_lost | def on_tag_lost(obj=nil, &block)
@on_tag_lost_obj = obj
@on_tag_lost = Proc.new { |device, obj_ptr, tag, proto|
yield self, tag.read_string, object_for(obj_ptr)
}
Klass.set_OnTagLost2_Handler(@handle, @on_tag_lost, pointer_for(obj))
end | ruby | def on_tag_lost(obj=nil, &block)
@on_tag_lost_obj = obj
@on_tag_lost = Proc.new { |device, obj_ptr, tag, proto|
yield self, tag.read_string, object_for(obj_ptr)
}
Klass.set_OnTagLost2_Handler(@handle, @on_tag_lost, pointer_for(obj))
end | [
"def",
"on_tag_lost",
"(",
"obj",
"=",
"nil",
",",
"&",
"block",
")",
"@on_tag_lost_obj",
"=",
"obj",
"@on_tag_lost",
"=",
"Proc",
".",
"new",
"{",
"|",
"device",
",",
"obj_ptr",
",",
"tag",
",",
"proto",
"|",
"yield",
"self",
",",
"tag",
".",
"read_... | Sets a tag lost handler callback function. This is called when a tag is removed from the reader
@param [String] obj Object to pass to the callback function. This is optional.
@param [Proc] Block When the callback is executed, the device and object are yielded to this block.
@example
rfid.on_tag_lost do |device... | [
"Sets",
"a",
"tag",
"lost",
"handler",
"callback",
"function",
".",
"This",
"is",
"called",
"when",
"a",
"tag",
"is",
"removed",
"from",
"the",
"reader"
] | 5c22e206804dc47e8ad37173baf952c874845973 | https://github.com/kreynolds/phidgets-ffi/blob/5c22e206804dc47e8ad37173baf952c874845973/lib/phidgets-ffi/rfid.rb#L70-L76 | train |
kreynolds/phidgets-ffi | lib/phidgets-ffi/rfid.rb | Phidgets.RFID.antenna | def antenna
ptr = ::FFI::MemoryPointer.new(:int)
Klass.getAntennaOn(@handle, ptr)
(ptr.get_int(0) == 0) ? false : true
end | ruby | def antenna
ptr = ::FFI::MemoryPointer.new(:int)
Klass.getAntennaOn(@handle, ptr)
(ptr.get_int(0) == 0) ? false : true
end | [
"def",
"antenna",
"ptr",
"=",
"::",
"FFI",
"::",
"MemoryPointer",
".",
"new",
"(",
":int",
")",
"Klass",
".",
"getAntennaOn",
"(",
"@handle",
",",
"ptr",
")",
"(",
"ptr",
".",
"get_int",
"(",
"0",
")",
"==",
"0",
")",
"?",
"false",
":",
"true",
"... | Returns the antenna state of the Phidget.
@return [Boolean] returns the ratiometric state or raises an error | [
"Returns",
"the",
"antenna",
"state",
"of",
"the",
"Phidget",
"."
] | 5c22e206804dc47e8ad37173baf952c874845973 | https://github.com/kreynolds/phidgets-ffi/blob/5c22e206804dc47e8ad37173baf952c874845973/lib/phidgets-ffi/rfid.rb#L81-L85 | train |
kreynolds/phidgets-ffi | lib/phidgets-ffi/rfid.rb | Phidgets.RFID.led | def led
ptr = ::FFI::MemoryPointer.new(:int)
Klass.getLEDOn(@handle, ptr)
(ptr.get_int(0) == 0) ? false : true
end | ruby | def led
ptr = ::FFI::MemoryPointer.new(:int)
Klass.getLEDOn(@handle, ptr)
(ptr.get_int(0) == 0) ? false : true
end | [
"def",
"led",
"ptr",
"=",
"::",
"FFI",
"::",
"MemoryPointer",
".",
"new",
"(",
":int",
")",
"Klass",
".",
"getLEDOn",
"(",
"@handle",
",",
"ptr",
")",
"(",
"ptr",
".",
"get_int",
"(",
"0",
")",
"==",
"0",
")",
"?",
"false",
":",
"true",
"end"
] | Returns the LED state.
@return [Boolean] returns the LED state or raises an error | [
"Returns",
"the",
"LED",
"state",
"."
] | 5c22e206804dc47e8ad37173baf952c874845973 | https://github.com/kreynolds/phidgets-ffi/blob/5c22e206804dc47e8ad37173baf952c874845973/lib/phidgets-ffi/rfid.rb#L99-L103 | train |
kreynolds/phidgets-ffi | lib/phidgets-ffi/rfid.rb | Phidgets.RFID.tag_present | def tag_present
ptr = ::FFI::MemoryPointer.new(:int)
Klass.getTagStatus(@handle, ptr)
(ptr.get_int(0) == 0) ? false : true
end | ruby | def tag_present
ptr = ::FFI::MemoryPointer.new(:int)
Klass.getTagStatus(@handle, ptr)
(ptr.get_int(0) == 0) ? false : true
end | [
"def",
"tag_present",
"ptr",
"=",
"::",
"FFI",
"::",
"MemoryPointer",
".",
"new",
"(",
":int",
")",
"Klass",
".",
"getTagStatus",
"(",
"@handle",
",",
"ptr",
")",
"(",
"ptr",
".",
"get_int",
"(",
"0",
")",
"==",
"0",
")",
"?",
"false",
":",
"true",... | Returns the value indicating whether or not a tag is on the reader.
@return [Boolean] returns a value indicating whether or not a tag is on the reader, or raises an error | [
"Returns",
"the",
"value",
"indicating",
"whether",
"or",
"not",
"a",
"tag",
"is",
"on",
"the",
"reader",
"."
] | 5c22e206804dc47e8ad37173baf952c874845973 | https://github.com/kreynolds/phidgets-ffi/blob/5c22e206804dc47e8ad37173baf952c874845973/lib/phidgets-ffi/rfid.rb#L138-L142 | train |
kreynolds/phidgets-ffi | lib/phidgets-ffi/rfid.rb | Phidgets.RFID.write | def write(tag, protocol, lock=false)
tmp = lock ? 1 : 0
Klass.write(@handle, tag, Phidgets::FFI::RFIDTagProtocol[protocol], tmp)
true
end | ruby | def write(tag, protocol, lock=false)
tmp = lock ? 1 : 0
Klass.write(@handle, tag, Phidgets::FFI::RFIDTagProtocol[protocol], tmp)
true
end | [
"def",
"write",
"(",
"tag",
",",
"protocol",
",",
"lock",
"=",
"false",
")",
"tmp",
"=",
"lock",
"?",
"1",
":",
"0",
"Klass",
".",
"write",
"(",
"@handle",
",",
"tag",
",",
"Phidgets",
"::",
"FFI",
"::",
"RFIDTagProtocol",
"[",
"protocol",
"]",
","... | Writes to a tag.
@param [String] tag Tag data to write. See product manual for formatting.
@param [Phidgets::FFI::RFIDTagProtocol] protocol Tag Protocol to use.
@param [Boolean] lock Lock the tag from further writes
@return [Boolean] returns true or raises an error | [
"Writes",
"to",
"a",
"tag",
"."
] | 5c22e206804dc47e8ad37173baf952c874845973 | https://github.com/kreynolds/phidgets-ffi/blob/5c22e206804dc47e8ad37173baf952c874845973/lib/phidgets-ffi/rfid.rb#L150-L154 | train |
kreynolds/phidgets-ffi | lib/phidgets-ffi/spatial.rb | Phidgets.Spatial.set_compass_correction_parameters | def set_compass_correction_parameters(new_mag_field, new_offset0, new_offset1, new_offset2, new_gain0, new_gain1, new_gain2, new_t0, new_t1, new_t2, new_t3, new_t4, new_t5)
Klass.setCompassCorrectionParameters(@handle, new_mag_field, new_offset0, new_offset1, new_offset2, new_gain0, new_gain1, new_gain2, new_t0, ... | ruby | def set_compass_correction_parameters(new_mag_field, new_offset0, new_offset1, new_offset2, new_gain0, new_gain1, new_gain2, new_t0, new_t1, new_t2, new_t3, new_t4, new_t5)
Klass.setCompassCorrectionParameters(@handle, new_mag_field, new_offset0, new_offset1, new_offset2, new_gain0, new_gain1, new_gain2, new_t0, ... | [
"def",
"set_compass_correction_parameters",
"(",
"new_mag_field",
",",
"new_offset0",
",",
"new_offset1",
",",
"new_offset2",
",",
"new_gain0",
",",
"new_gain1",
",",
"new_gain2",
",",
"new_t0",
",",
"new_t1",
",",
"new_t2",
",",
"new_t3",
",",
"new_t4",
",",
"n... | Sets correction paramaters for the magnetometer triad. This is for filtering out hard and soft iron offsets, and scaling the output to match the local field strength. These parameters can be obtained from the compass calibration program provided by Phidgets Inc.
@param [Integer] new_mag_field local magnetic field stre... | [
"Sets",
"correction",
"paramaters",
"for",
"the",
"magnetometer",
"triad",
".",
"This",
"is",
"for",
"filtering",
"out",
"hard",
"and",
"soft",
"iron",
"offsets",
"and",
"scaling",
"the",
"output",
"to",
"match",
"the",
"local",
"field",
"strength",
".",
"Th... | 5c22e206804dc47e8ad37173baf952c874845973 | https://github.com/kreynolds/phidgets-ffi/blob/5c22e206804dc47e8ad37173baf952c874845973/lib/phidgets-ffi/spatial.rb#L99-L102 | train |
kreynolds/phidgets-ffi | lib/phidgets-ffi/dictionary.rb | Phidgets.Dictionary.open | def open(options)
password = (options[:password].nil? ? nil : options[:password].to_s)
if !options[:server_id].nil?
Klass.openRemote(@handle, options[:server_id].to_s, password)
else
Klass.openRemoteIP(@handle, options[:address].to_s, options[:port].to_i, password)
end
slee... | ruby | def open(options)
password = (options[:password].nil? ? nil : options[:password].to_s)
if !options[:server_id].nil?
Klass.openRemote(@handle, options[:server_id].to_s, password)
else
Klass.openRemoteIP(@handle, options[:address].to_s, options[:port].to_i, password)
end
slee... | [
"def",
"open",
"(",
"options",
")",
"password",
"=",
"(",
"options",
"[",
":password",
"]",
".",
"nil?",
"?",
"nil",
":",
"options",
"[",
":password",
"]",
".",
"to_s",
")",
"if",
"!",
"options",
"[",
":server_id",
"]",
".",
"nil?",
"Klass",
".",
"... | Opens a PhidgetDictionary over the WebService.
If you are not programming with the block method, you will have to call this explicitly.
This is called automatically if you are programming with the block method.
<b>Usage:</b>
Open a PhidgetDictionary using an address, port, and an optional password.
options = {:... | [
"Opens",
"a",
"PhidgetDictionary",
"over",
"the",
"WebService",
".",
"If",
"you",
"are",
"not",
"programming",
"with",
"the",
"block",
"method",
"you",
"will",
"have",
"to",
"call",
"this",
"explicitly",
".",
"This",
"is",
"called",
"automatically",
"if",
"y... | 5c22e206804dc47e8ad37173baf952c874845973 | https://github.com/kreynolds/phidgets-ffi/blob/5c22e206804dc47e8ad37173baf952c874845973/lib/phidgets-ffi/dictionary.rb#L68-L77 | train |
kreynolds/phidgets-ffi | lib/phidgets-ffi/dictionary.rb | Phidgets.Dictionary.delete | def delete(pattern)
Klass.removeKey(@handle, (pattern.kind_of?(Regexp) ? pattern.source : pattern.to_s))
true
end | ruby | def delete(pattern)
Klass.removeKey(@handle, (pattern.kind_of?(Regexp) ? pattern.source : pattern.to_s))
true
end | [
"def",
"delete",
"(",
"pattern",
")",
"Klass",
".",
"removeKey",
"(",
"@handle",
",",
"(",
"pattern",
".",
"kind_of?",
"(",
"Regexp",
")",
"?",
"pattern",
".",
"source",
":",
"pattern",
".",
"to_s",
")",
")",
"true",
"end"
] | Removes a set of keys from the dictionary
@return [Boolean] returns true or raises an error | [
"Removes",
"a",
"set",
"of",
"keys",
"from",
"the",
"dictionary"
] | 5c22e206804dc47e8ad37173baf952c874845973 | https://github.com/kreynolds/phidgets-ffi/blob/5c22e206804dc47e8ad37173baf952c874845973/lib/phidgets-ffi/dictionary.rb#L130-L133 | train |
kreynolds/phidgets-ffi | lib/phidgets-ffi/dictionary.rb | Phidgets.Dictionary.on_connect | def on_connect(obj=nil, &block)
@on_connect_obj = obj
@on_connect = Proc.new { |handle, obj_ptr|
# On connect, we'll need to re-add all of our change handlers
@listeners.each_pair do |pattern, (listener, proc)|
begin
next if status != :connected
Klass.set_On... | ruby | def on_connect(obj=nil, &block)
@on_connect_obj = obj
@on_connect = Proc.new { |handle, obj_ptr|
# On connect, we'll need to re-add all of our change handlers
@listeners.each_pair do |pattern, (listener, proc)|
begin
next if status != :connected
Klass.set_On... | [
"def",
"on_connect",
"(",
"obj",
"=",
"nil",
",",
"&",
"block",
")",
"@on_connect_obj",
"=",
"obj",
"@on_connect",
"=",
"Proc",
".",
"new",
"{",
"|",
"handle",
",",
"obj_ptr",
"|",
"@listeners",
".",
"each_pair",
"do",
"|",
"pattern",
",",
"(",
"listen... | Sets a server connect handler callback function. This is called when a connection to the server has been made.
@param [String] obj Object to pass to the callback function. This is optional.
@param [Proc] Block When the callback is executed, the device and object are yielded to this block.
@example
dict.on_conn... | [
"Sets",
"a",
"server",
"connect",
"handler",
"callback",
"function",
".",
"This",
"is",
"called",
"when",
"a",
"connection",
"to",
"the",
"server",
"has",
"been",
"made",
"."
] | 5c22e206804dc47e8ad37173baf952c874845973 | https://github.com/kreynolds/phidgets-ffi/blob/5c22e206804dc47e8ad37173baf952c874845973/lib/phidgets-ffi/dictionary.rb#L145-L162 | train |
kreynolds/phidgets-ffi | lib/phidgets-ffi/dictionary.rb | Phidgets.Dictionary.on_disconnect | def on_disconnect(obj=nil, &block)
@on_disconnect_obj = obj
@on_disconnect = Proc.new { |handle, obj_ptr|
# On disconnect, we'll need to remove all of our change handlers
@listeners.each_pair do |pattern, (listener, proc)|
Klass.remove_OnKeyChange_Handler(listener.get_pointer(0))
... | ruby | def on_disconnect(obj=nil, &block)
@on_disconnect_obj = obj
@on_disconnect = Proc.new { |handle, obj_ptr|
# On disconnect, we'll need to remove all of our change handlers
@listeners.each_pair do |pattern, (listener, proc)|
Klass.remove_OnKeyChange_Handler(listener.get_pointer(0))
... | [
"def",
"on_disconnect",
"(",
"obj",
"=",
"nil",
",",
"&",
"block",
")",
"@on_disconnect_obj",
"=",
"obj",
"@on_disconnect",
"=",
"Proc",
".",
"new",
"{",
"|",
"handle",
",",
"obj_ptr",
"|",
"@listeners",
".",
"each_pair",
"do",
"|",
"pattern",
",",
"(",
... | Sets a server disconnect handler callback function. This is called when a connection to the server has been lost.
@param [String] obj Object to pass to the callback function. This is optional.
@param [Proc] Block When the callback is executed, the device and object are yielded to this block.
@example
dict.on_d... | [
"Sets",
"a",
"server",
"disconnect",
"handler",
"callback",
"function",
".",
"This",
"is",
"called",
"when",
"a",
"connection",
"to",
"the",
"server",
"has",
"been",
"lost",
"."
] | 5c22e206804dc47e8ad37173baf952c874845973 | https://github.com/kreynolds/phidgets-ffi/blob/5c22e206804dc47e8ad37173baf952c874845973/lib/phidgets-ffi/dictionary.rb#L174-L186 | train |
kreynolds/phidgets-ffi | lib/phidgets-ffi/dictionary.rb | Phidgets.Dictionary.on_change | def on_change(pattern=".*", obj=nil, &block)
pattern = (pattern.kind_of?(Regexp) ? pattern.source : pattern.to_s)
@listeners[pattern] = [
::FFI::MemoryPointer.new(:pointer),
Proc.new { |handle, obj_ptr, key, value, reason|
yield object_for(obj_ptr), key, value, reason
}
... | ruby | def on_change(pattern=".*", obj=nil, &block)
pattern = (pattern.kind_of?(Regexp) ? pattern.source : pattern.to_s)
@listeners[pattern] = [
::FFI::MemoryPointer.new(:pointer),
Proc.new { |handle, obj_ptr, key, value, reason|
yield object_for(obj_ptr), key, value, reason
}
... | [
"def",
"on_change",
"(",
"pattern",
"=",
"\".*\"",
",",
"obj",
"=",
"nil",
",",
"&",
"block",
")",
"pattern",
"=",
"(",
"pattern",
".",
"kind_of?",
"(",
"Regexp",
")",
"?",
"pattern",
".",
"source",
":",
"pattern",
".",
"to_s",
")",
"@listeners",
"["... | Adds a key listener to an opened dictionary. Note that this should only be called after the connection has been made - unlike all other events.
@param [String] obj Object to pass to the callback function. This is optional.
@param [Proc] Block When the callback is executed, the device and object are yielded to this b... | [
"Adds",
"a",
"key",
"listener",
"to",
"an",
"opened",
"dictionary",
".",
"Note",
"that",
"this",
"should",
"only",
"be",
"called",
"after",
"the",
"connection",
"has",
"been",
"made",
"-",
"unlike",
"all",
"other",
"events",
"."
] | 5c22e206804dc47e8ad37173baf952c874845973 | https://github.com/kreynolds/phidgets-ffi/blob/5c22e206804dc47e8ad37173baf952c874845973/lib/phidgets-ffi/dictionary.rb#L217-L228 | train |
kreynolds/phidgets-ffi | lib/phidgets-ffi/dictionary.rb | Phidgets.Dictionary.remove_on_change | def remove_on_change(pattern=".*")
pattern = (pattern.kind_of?(Regexp) ? pattern.source : pattern.to_s)
if @listeners.has_key?(pattern)
listener, proc = @listeners.delete(pattern)
Klass.remove_OnKeyChange_Handler(listener.get_pointer(0))
sleep @handler_sleep
true
else
... | ruby | def remove_on_change(pattern=".*")
pattern = (pattern.kind_of?(Regexp) ? pattern.source : pattern.to_s)
if @listeners.has_key?(pattern)
listener, proc = @listeners.delete(pattern)
Klass.remove_OnKeyChange_Handler(listener.get_pointer(0))
sleep @handler_sleep
true
else
... | [
"def",
"remove_on_change",
"(",
"pattern",
"=",
"\".*\"",
")",
"pattern",
"=",
"(",
"pattern",
".",
"kind_of?",
"(",
"Regexp",
")",
"?",
"pattern",
".",
"source",
":",
"pattern",
".",
"to_s",
")",
"if",
"@listeners",
".",
"has_key?",
"(",
"pattern",
")",... | Removes a key listener
@param [String] pattern pattern
@return [Boolean] returns true or raises an error | [
"Removes",
"a",
"key",
"listener"
] | 5c22e206804dc47e8ad37173baf952c874845973 | https://github.com/kreynolds/phidgets-ffi/blob/5c22e206804dc47e8ad37173baf952c874845973/lib/phidgets-ffi/dictionary.rb#L233-L243 | train |
metanorma/iev | lib/iev/db_cache.rb | Iev.DbCache.fetched | def fetched(key)
value = self[key]
return unless value
# if value =~ /^not_found/
# value.match(/\d{4}-\d{2}-\d{2}/).to_s
# else
doc = Nokogiri::XML value
doc.at("/bibitem/fetched")&.text
# end
end | ruby | def fetched(key)
value = self[key]
return unless value
# if value =~ /^not_found/
# value.match(/\d{4}-\d{2}-\d{2}/).to_s
# else
doc = Nokogiri::XML value
doc.at("/bibitem/fetched")&.text
# end
end | [
"def",
"fetched",
"(",
"key",
")",
"value",
"=",
"self",
"[",
"key",
"]",
"return",
"unless",
"value",
"doc",
"=",
"Nokogiri",
"::",
"XML",
"value",
"doc",
".",
"at",
"(",
"\"/bibitem/fetched\"",
")",
"&.",
"text",
"end"
] | Return fetched date
@param key [String]
@return [String] | [
"Return",
"fetched",
"date"
] | bdda9f125421752d305986334fae3a7daa422854 | https://github.com/metanorma/iev/blob/bdda9f125421752d305986334fae3a7daa422854/lib/iev/db_cache.rb#L40-L50 | train |
nwjsmith/thumbtack | lib/thumbtack/client.rb | Thumbtack.Client.action | def action(path, params)
response = @adapter.get(path, params)
unless response['result_code'] == 'done'
raise ResultError, response['result_code']
end
self
end | ruby | def action(path, params)
response = @adapter.get(path, params)
unless response['result_code'] == 'done'
raise ResultError, response['result_code']
end
self
end | [
"def",
"action",
"(",
"path",
",",
"params",
")",
"response",
"=",
"@adapter",
".",
"get",
"(",
"path",
",",
"params",
")",
"unless",
"response",
"[",
"'result_code'",
"]",
"==",
"'done'",
"raise",
"ResultError",
",",
"response",
"[",
"'result_code'",
"]",... | Perform an action request against the Pinboard API
@param [String] path
the path to fetch from, relative to from the base Pinboard API URL
@param [Hash] params
query parameters to append to the URL
@return [Hash] the response parsed from the JSON
@raise [RateLimitError] if the response is rate-limited
@r... | [
"Perform",
"an",
"action",
"request",
"against",
"the",
"Pinboard",
"API"
] | f7d5323b91b901c7d61daadb9ef9c1ed08a3a7cb | https://github.com/nwjsmith/thumbtack/blob/f7d5323b91b901c7d61daadb9ef9c1ed08a3a7cb/lib/thumbtack/client.rb#L91-L98 | train |
activenetwork-automation/vcoworkflows | lib/vcoworkflows/vcosession.rb | VcoWorkflows.VcoSession.post | def post(endpoint, body, headers = {})
headers = { accept: :json, content_type: :json }.merge(headers)
@rest_resource[endpoint].post body, headers
end | ruby | def post(endpoint, body, headers = {})
headers = { accept: :json, content_type: :json }.merge(headers)
@rest_resource[endpoint].post body, headers
end | [
"def",
"post",
"(",
"endpoint",
",",
"body",
",",
"headers",
"=",
"{",
"}",
")",
"headers",
"=",
"{",
"accept",
":",
":json",
",",
"content_type",
":",
":json",
"}",
".",
"merge",
"(",
"headers",
")",
"@rest_resource",
"[",
"endpoint",
"]",
".",
"pos... | Perform a REST POST operation against the specified endpoint with the
given data body
@param [String] endpoint REST endpoint to use
@param [String] body JSON data body to post
@param [Hash] headers Optional headers to use in request
@return [String] JSON response body | [
"Perform",
"a",
"REST",
"POST",
"operation",
"against",
"the",
"specified",
"endpoint",
"with",
"the",
"given",
"data",
"body"
] | 01db57318c14e572dc47261f55c8d08341306642 | https://github.com/activenetwork-automation/vcoworkflows/blob/01db57318c14e572dc47261f55c8d08341306642/lib/vcoworkflows/vcosession.rb#L66-L69 | train |
kreynolds/phidgets-ffi | lib/phidgets-ffi/ir.rb | Phidgets.IR.on_raw_data | def on_raw_data(obj=nil, &block)
@on_raw_data_obj = obj
@on_raw_data = Proc.new { |device, obj_ptr, raw_data, data_length|
data = []
data_length.times { |i|
data << raw_data[i].get_int(0)
}
yield self, data, data_length, object_for(obj_ptr)
}
Klass.set_OnRawData_Handler(@handle, @on_r... | ruby | def on_raw_data(obj=nil, &block)
@on_raw_data_obj = obj
@on_raw_data = Proc.new { |device, obj_ptr, raw_data, data_length|
data = []
data_length.times { |i|
data << raw_data[i].get_int(0)
}
yield self, data, data_length, object_for(obj_ptr)
}
Klass.set_OnRawData_Handler(@handle, @on_r... | [
"def",
"on_raw_data",
"(",
"obj",
"=",
"nil",
",",
"&",
"block",
")",
"@on_raw_data_obj",
"=",
"obj",
"@on_raw_data",
"=",
"Proc",
".",
"new",
"{",
"|",
"device",
",",
"obj_ptr",
",",
"raw_data",
",",
"data_length",
"|",
"data",
"=",
"[",
"]",
"data_le... | Sets a raw data handler callback function. This is called whenever a new IR data is available. Data is in the form of an array of microsecond pulse values. This can be used if the user wishes to do their own data decoding, or for codes that the PhidgetIR cannot automatically recognize.
@param [String] obj Object to ... | [
"Sets",
"a",
"raw",
"data",
"handler",
"callback",
"function",
".",
"This",
"is",
"called",
"whenever",
"a",
"new",
"IR",
"data",
"is",
"available",
".",
"Data",
"is",
"in",
"the",
"form",
"of",
"an",
"array",
"of",
"microsecond",
"pulse",
"values",
".",... | 5c22e206804dc47e8ad37173baf952c874845973 | https://github.com/kreynolds/phidgets-ffi/blob/5c22e206804dc47e8ad37173baf952c874845973/lib/phidgets-ffi/ir.rb#L106-L117 | train |
kreynolds/phidgets-ffi | lib/phidgets-ffi/ir.rb | Phidgets.IR.on_code | def on_code(obj=nil, &block)
@on_code_obj = obj
@on_code = Proc.new { |device, obj_ptr, data, data_length, bit_count, repeat|
data_string = []
data_length.times { |i|
data_string[i] = data[i].get_uchar(0).to_s(16)
}
yield self, data_string, data_length, bit_count, repeat, object_for(obj_ptr)
... | ruby | def on_code(obj=nil, &block)
@on_code_obj = obj
@on_code = Proc.new { |device, obj_ptr, data, data_length, bit_count, repeat|
data_string = []
data_length.times { |i|
data_string[i] = data[i].get_uchar(0).to_s(16)
}
yield self, data_string, data_length, bit_count, repeat, object_for(obj_ptr)
... | [
"def",
"on_code",
"(",
"obj",
"=",
"nil",
",",
"&",
"block",
")",
"@on_code_obj",
"=",
"obj",
"@on_code",
"=",
"Proc",
".",
"new",
"{",
"|",
"device",
",",
"obj_ptr",
",",
"data",
",",
"data_length",
",",
"bit_count",
",",
"repeat",
"|",
"data_string",... | Sets a code handler callback function. This is called whenever a new code is recognized.
@param [String] obj Object to pass to the callback function. This is optional.
@param [Proc] Block When the callback is executed, the device and object are yielded to this block.
@example
ir.on_code do |device, data, data_le... | [
"Sets",
"a",
"code",
"handler",
"callback",
"function",
".",
"This",
"is",
"called",
"whenever",
"a",
"new",
"code",
"is",
"recognized",
"."
] | 5c22e206804dc47e8ad37173baf952c874845973 | https://github.com/kreynolds/phidgets-ffi/blob/5c22e206804dc47e8ad37173baf952c874845973/lib/phidgets-ffi/ir.rb#L129-L140 | train |
kreynolds/phidgets-ffi | lib/phidgets-ffi/ir.rb | Phidgets.IR.on_learn | def on_learn(obj=nil, &block)
@on_learn_obj = obj
@on_learn = Proc.new { |device, obj_ptr, int_data, data_length, code_info|
data = []
data_length.times { |i|
data[i] = int_data[i].get_uchar(0).to_s(16)
}
code_info_struct = IR_code_info.new(code_info)
yield self, data, data_length, ... | ruby | def on_learn(obj=nil, &block)
@on_learn_obj = obj
@on_learn = Proc.new { |device, obj_ptr, int_data, data_length, code_info|
data = []
data_length.times { |i|
data[i] = int_data[i].get_uchar(0).to_s(16)
}
code_info_struct = IR_code_info.new(code_info)
yield self, data, data_length, ... | [
"def",
"on_learn",
"(",
"obj",
"=",
"nil",
",",
"&",
"block",
")",
"@on_learn_obj",
"=",
"obj",
"@on_learn",
"=",
"Proc",
".",
"new",
"{",
"|",
"device",
",",
"obj_ptr",
",",
"int_data",
",",
"data_length",
",",
"code_info",
"|",
"data",
"=",
"[",
"]... | Sets a learn handler callback function. This is called when a new code has been learned. This generally requires the button to be held down for a second or two.
@param [String] obj Object to pass to the callback function. This is optional.
@param [Proc] Block When the callback is executed, the device and object are ... | [
"Sets",
"a",
"learn",
"handler",
"callback",
"function",
".",
"This",
"is",
"called",
"when",
"a",
"new",
"code",
"has",
"been",
"learned",
".",
"This",
"generally",
"requires",
"the",
"button",
"to",
"be",
"held",
"down",
"for",
"a",
"second",
"or",
"tw... | 5c22e206804dc47e8ad37173baf952c874845973 | https://github.com/kreynolds/phidgets-ffi/blob/5c22e206804dc47e8ad37173baf952c874845973/lib/phidgets-ffi/ir.rb#L152-L165 | train |
kreynolds/phidgets-ffi | lib/phidgets-ffi/ir.rb | Phidgets.IR.transmit | def transmit(data, code_info)
pdata = ::FFI::MemoryPointer.new(:uchar, 16)
data_ffi = []
data.size.times { |i|
data_ffi[i] = data[i].to_i(16)
}
data_ffi = ::FFI::MemoryPointer.new(:uchar, 16).write_array_of_uchar(data_ffi)
Klass.Transmit(@handle, data_ffi, code_info)
true
end | ruby | def transmit(data, code_info)
pdata = ::FFI::MemoryPointer.new(:uchar, 16)
data_ffi = []
data.size.times { |i|
data_ffi[i] = data[i].to_i(16)
}
data_ffi = ::FFI::MemoryPointer.new(:uchar, 16).write_array_of_uchar(data_ffi)
Klass.Transmit(@handle, data_ffi, code_info)
true
end | [
"def",
"transmit",
"(",
"data",
",",
"code_info",
")",
"pdata",
"=",
"::",
"FFI",
"::",
"MemoryPointer",
".",
"new",
"(",
":uchar",
",",
"16",
")",
"data_ffi",
"=",
"[",
"]",
"data",
".",
"size",
".",
"times",
"{",
"|",
"i",
"|",
"data_ffi",
"[",
... | Transmits a code
@param [Array<String>] data data to send
@param [IR_code_info] code_info code info structure specifying the attributes of the code to send. Anything that is not set is set to default.
@return [Boolean] returns true if the code was successfully transmitted, or raises an error. | [
"Transmits",
"a",
"code"
] | 5c22e206804dc47e8ad37173baf952c874845973 | https://github.com/kreynolds/phidgets-ffi/blob/5c22e206804dc47e8ad37173baf952c874845973/lib/phidgets-ffi/ir.rb#L171-L184 | train |
kreynolds/phidgets-ffi | lib/phidgets-ffi/ir.rb | Phidgets.IR.transmit_raw | def transmit_raw(data, length, carrier_frequency, duty_cycle, gap)
c_data = ::FFI::MemoryPointer.new(:int, data.size).write_array_of_int(data)
Klass.TransmitRaw(@handle, c_data, length.to_i, carrier_frequency.to_i, duty_cycle.to_i, gap.to_i)
true
end | ruby | def transmit_raw(data, length, carrier_frequency, duty_cycle, gap)
c_data = ::FFI::MemoryPointer.new(:int, data.size).write_array_of_int(data)
Klass.TransmitRaw(@handle, c_data, length.to_i, carrier_frequency.to_i, duty_cycle.to_i, gap.to_i)
true
end | [
"def",
"transmit_raw",
"(",
"data",
",",
"length",
",",
"carrier_frequency",
",",
"duty_cycle",
",",
"gap",
")",
"c_data",
"=",
"::",
"FFI",
"::",
"MemoryPointer",
".",
"new",
"(",
":int",
",",
"data",
".",
"size",
")",
".",
"write_array_of_int",
"(",
"d... | Transmits raw data as a series of pulses and spaces.
@param [Array] data data to send
@param [Integer] length length of the data array
@param [Integer] carrier_frequency carrier frequency in Hz. Leave as 0 for default
@param [Integer] duty_cycle duty cycle(10-50). Leave as 0 for default
@param [Integer] gap_time g... | [
"Transmits",
"raw",
"data",
"as",
"a",
"series",
"of",
"pulses",
"and",
"spaces",
"."
] | 5c22e206804dc47e8ad37173baf952c874845973 | https://github.com/kreynolds/phidgets-ffi/blob/5c22e206804dc47e8ad37173baf952c874845973/lib/phidgets-ffi/ir.rb#L200-L204 | train |
kreynolds/phidgets-ffi | lib/phidgets-ffi/ir.rb | Phidgets.IR.last_code | def last_code
data_ffi = ::FFI::MemoryPointer.new(:uchar, 16)
data_length = ::FFI::MemoryPointer.new(:int)
data_length.write_int(16)
bit_count = ::FFI::MemoryPointer.new(:int)
Klass.getLastCode(@handle, data_ffi, data_length, bit_count)
data = []
data_length.get_int(0).times { |i|
data << d... | ruby | def last_code
data_ffi = ::FFI::MemoryPointer.new(:uchar, 16)
data_length = ::FFI::MemoryPointer.new(:int)
data_length.write_int(16)
bit_count = ::FFI::MemoryPointer.new(:int)
Klass.getLastCode(@handle, data_ffi, data_length, bit_count)
data = []
data_length.get_int(0).times { |i|
data << d... | [
"def",
"last_code",
"data_ffi",
"=",
"::",
"FFI",
"::",
"MemoryPointer",
".",
"new",
"(",
":uchar",
",",
"16",
")",
"data_length",
"=",
"::",
"FFI",
"::",
"MemoryPointer",
".",
"new",
"(",
":int",
")",
"data_length",
".",
"write_int",
"(",
"16",
")",
"... | Gets the last code that was received.
@return [Array<String>] returns the last code, or raises an error.
@return [Integer] returns the data length, or raises an error.
@return [Object] returns the bit count, or raises an error. | [
"Gets",
"the",
"last",
"code",
"that",
"was",
"received",
"."
] | 5c22e206804dc47e8ad37173baf952c874845973 | https://github.com/kreynolds/phidgets-ffi/blob/5c22e206804dc47e8ad37173baf952c874845973/lib/phidgets-ffi/ir.rb#L230-L248 | train |
kreynolds/phidgets-ffi | lib/phidgets-ffi/ir.rb | Phidgets.IR.last_learned_code | def last_learned_code
data_ffi = ::FFI::MemoryPointer.new(:uchar, 16)
data_length = ::FFI::MemoryPointer.new(:int)
data_length.write_int(16)
code_info = ::FFI::MemoryPointer.new(IR_code_info)
Klass.getLastLearnedCode(@handle, data_ffi, data_length, code_info)
data = []
data_length.get_int(0... | ruby | def last_learned_code
data_ffi = ::FFI::MemoryPointer.new(:uchar, 16)
data_length = ::FFI::MemoryPointer.new(:int)
data_length.write_int(16)
code_info = ::FFI::MemoryPointer.new(IR_code_info)
Klass.getLastLearnedCode(@handle, data_ffi, data_length, code_info)
data = []
data_length.get_int(0... | [
"def",
"last_learned_code",
"data_ffi",
"=",
"::",
"FFI",
"::",
"MemoryPointer",
".",
"new",
"(",
":uchar",
",",
"16",
")",
"data_length",
"=",
"::",
"FFI",
"::",
"MemoryPointer",
".",
"new",
"(",
":int",
")",
"data_length",
".",
"write_int",
"(",
"16",
... | Gets the last code that was learned.
@return [Array<String>] returns the last learned code, or raises an error.
@return [Integer] returns the data length, or raises an error.
@return [IR_code_info] returns the code info structure for the learned code, or raises an error. | [
"Gets",
"the",
"last",
"code",
"that",
"was",
"learned",
"."
] | 5c22e206804dc47e8ad37173baf952c874845973 | https://github.com/kreynolds/phidgets-ffi/blob/5c22e206804dc47e8ad37173baf952c874845973/lib/phidgets-ffi/ir.rb#L254-L275 | train |
axsh/isono | lib/isono/amqp_client.rb | Isono.AmqpClient.publish_to | def publish_to(exname, message, opts={})
EventMachine.schedule {
ex = amq.exchanges[exname] || raise("Undefined exchange name : #{exname}")
case ex.type
when :topic
unless opts.has_key? :key
opts[:key] = '*'
end
end
ex.publish(Serializer.inst... | ruby | def publish_to(exname, message, opts={})
EventMachine.schedule {
ex = amq.exchanges[exname] || raise("Undefined exchange name : #{exname}")
case ex.type
when :topic
unless opts.has_key? :key
opts[:key] = '*'
end
end
ex.publish(Serializer.inst... | [
"def",
"publish_to",
"(",
"exname",
",",
"message",
",",
"opts",
"=",
"{",
"}",
")",
"EventMachine",
".",
"schedule",
"{",
"ex",
"=",
"amq",
".",
"exchanges",
"[",
"exname",
"]",
"||",
"raise",
"(",
"\"Undefined exchange name : #{exname}\"",
")",
"case",
"... | Publish a message to the designated exchange.
@param [String] exname The exchange name
@param [String] message Message body to be sent
@param [Hash] opts Options with the message.
:key => 'keyname'
@return [void]
@example Want to broadcast the data to all bound queues:
publish_to('topic exchange', 'data', ... | [
"Publish",
"a",
"message",
"to",
"the",
"designated",
"exchange",
"."
] | 0325eb1a46538b8eea63e80745a9161e2532b7cf | https://github.com/axsh/isono/blob/0325eb1a46538b8eea63e80745a9161e2532b7cf/lib/isono/amqp_client.rb#L180-L191 | train |
activenetwork-automation/vcoworkflows | lib/vcoworkflows/workflow.rb | VcoWorkflows.Workflow.required_parameters | def required_parameters
required = {}
@input_parameters.each_value { |v| required[v.name] = v if v.required? }
required
end | ruby | def required_parameters
required = {}
@input_parameters.each_value { |v| required[v.name] = v if v.required? }
required
end | [
"def",
"required_parameters",
"required",
"=",
"{",
"}",
"@input_parameters",
".",
"each_value",
"{",
"|",
"v",
"|",
"required",
"[",
"v",
".",
"name",
"]",
"=",
"v",
"if",
"v",
".",
"required?",
"}",
"required",
"end"
] | Get an array of the names of all the required input parameters
@return [Hash] Hash of WorkflowParameter input parameters which
are required for this workflow | [
"Get",
"an",
"array",
"of",
"the",
"names",
"of",
"all",
"the",
"required",
"input",
"parameters"
] | 01db57318c14e572dc47261f55c8d08341306642 | https://github.com/activenetwork-automation/vcoworkflows/blob/01db57318c14e572dc47261f55c8d08341306642/lib/vcoworkflows/workflow.rb#L236-L240 | train |
activenetwork-automation/vcoworkflows | lib/vcoworkflows/workflow.rb | VcoWorkflows.Workflow.parameter | def parameter(parameter_name, parameter_value = nil)
if @input_parameters.key?(parameter_name)
@input_parameters[parameter_name].set parameter_value
else
$stderr.puts "\nAttempted to set a value for a non-existent WorkflowParameter!"
$stderr.puts "It appears that there is no paramete... | ruby | def parameter(parameter_name, parameter_value = nil)
if @input_parameters.key?(parameter_name)
@input_parameters[parameter_name].set parameter_value
else
$stderr.puts "\nAttempted to set a value for a non-existent WorkflowParameter!"
$stderr.puts "It appears that there is no paramete... | [
"def",
"parameter",
"(",
"parameter_name",
",",
"parameter_value",
"=",
"nil",
")",
"if",
"@input_parameters",
".",
"key?",
"(",
"parameter_name",
")",
"@input_parameters",
"[",
"parameter_name",
"]",
".",
"set",
"parameter_value",
"else",
"$stderr",
".",
"puts",
... | Get the parameter object named. If a value is provided, set the value
and return the parameter object.
To get a parameter value, use parameter(parameter_name).value
@param [String] parameter_name Name of the parameter to get
@param [Object, nil] parameter_value Optional value for parameter.
@return [VcoWorkflows... | [
"Get",
"the",
"parameter",
"object",
"named",
".",
"If",
"a",
"value",
"is",
"provided",
"set",
"the",
"value",
"and",
"return",
"the",
"parameter",
"object",
"."
] | 01db57318c14e572dc47261f55c8d08341306642 | https://github.com/activenetwork-automation/vcoworkflows/blob/01db57318c14e572dc47261f55c8d08341306642/lib/vcoworkflows/workflow.rb#L250-L261 | train |
activenetwork-automation/vcoworkflows | lib/vcoworkflows/workflow.rb | VcoWorkflows.Workflow.execute | def execute(workflow_service = nil)
# If we're not given an explicit workflow service for this execution
# request, use the one defined when we were created.
workflow_service = @service if workflow_service.nil?
# If we still have a nil workflow_service, go home.
fail(IOError, ERR[:no_workf... | ruby | def execute(workflow_service = nil)
# If we're not given an explicit workflow service for this execution
# request, use the one defined when we were created.
workflow_service = @service if workflow_service.nil?
# If we still have a nil workflow_service, go home.
fail(IOError, ERR[:no_workf... | [
"def",
"execute",
"(",
"workflow_service",
"=",
"nil",
")",
"workflow_service",
"=",
"@service",
"if",
"workflow_service",
".",
"nil?",
"fail",
"(",
"IOError",
",",
"ERR",
"[",
":no_workflow_service_defined",
"]",
")",
"if",
"workflow_service",
".",
"nil?",
"ver... | Execute this workflow
@param [VcoWorkflows::WorkflowService] workflow_service
@return [String] Workflow Execution ID | [
"Execute",
"this",
"workflow"
] | 01db57318c14e572dc47261f55c8d08341306642 | https://github.com/activenetwork-automation/vcoworkflows/blob/01db57318c14e572dc47261f55c8d08341306642/lib/vcoworkflows/workflow.rb#L306-L316 | train |
activenetwork-automation/vcoworkflows | lib/vcoworkflows/workflow.rb | VcoWorkflows.Workflow.log | def log(execution_id = nil)
execution_id = @execution_id if execution_id.nil?
log_json = @service.get_log(@id, execution_id)
VcoWorkflows::WorkflowExecutionLog.new(log_json)
end | ruby | def log(execution_id = nil)
execution_id = @execution_id if execution_id.nil?
log_json = @service.get_log(@id, execution_id)
VcoWorkflows::WorkflowExecutionLog.new(log_json)
end | [
"def",
"log",
"(",
"execution_id",
"=",
"nil",
")",
"execution_id",
"=",
"@execution_id",
"if",
"execution_id",
".",
"nil?",
"log_json",
"=",
"@service",
".",
"get_log",
"(",
"@id",
",",
"execution_id",
")",
"VcoWorkflows",
"::",
"WorkflowExecutionLog",
".",
"... | Return logs for the given execution
@param [String] execution_id optional execution id to get logs for
@return [VcoWorkflows::WorkflowExecutionLog] | [
"Return",
"logs",
"for",
"the",
"given",
"execution"
] | 01db57318c14e572dc47261f55c8d08341306642 | https://github.com/activenetwork-automation/vcoworkflows/blob/01db57318c14e572dc47261f55c8d08341306642/lib/vcoworkflows/workflow.rb#L336-L340 | train |
activenetwork-automation/vcoworkflows | lib/vcoworkflows/workflow.rb | VcoWorkflows.Workflow.input_parameter_json | def input_parameter_json
tmp_params = []
@input_parameters.each_value { |v| tmp_params << v.as_struct if v.set? }
param_struct = { parameters: tmp_params }
param_struct.to_json
end | ruby | def input_parameter_json
tmp_params = []
@input_parameters.each_value { |v| tmp_params << v.as_struct if v.set? }
param_struct = { parameters: tmp_params }
param_struct.to_json
end | [
"def",
"input_parameter_json",
"tmp_params",
"=",
"[",
"]",
"@input_parameters",
".",
"each_value",
"{",
"|",
"v",
"|",
"tmp_params",
"<<",
"v",
".",
"as_struct",
"if",
"v",
".",
"set?",
"}",
"param_struct",
"=",
"{",
"parameters",
":",
"tmp_params",
"}",
... | Convert the input parameters to a JSON document
@return [String] | [
"Convert",
"the",
"input",
"parameters",
"to",
"a",
"JSON",
"document"
] | 01db57318c14e572dc47261f55c8d08341306642 | https://github.com/activenetwork-automation/vcoworkflows/blob/01db57318c14e572dc47261f55c8d08341306642/lib/vcoworkflows/workflow.rb#L371-L376 | train |
activenetwork-automation/vcoworkflows | lib/vcoworkflows/workflow.rb | VcoWorkflows.Workflow.verify_parameters | def verify_parameters
required_parameters.each do |name, wfparam|
if wfparam.required? && (wfparam.value.nil? || wfparam.value.size == 0)
fail(IOError, ERR[:param_verify_failed] << "#{name} required but not present.") # rubocop:disable Metrics/LineLength
end
end
end | ruby | def verify_parameters
required_parameters.each do |name, wfparam|
if wfparam.required? && (wfparam.value.nil? || wfparam.value.size == 0)
fail(IOError, ERR[:param_verify_failed] << "#{name} required but not present.") # rubocop:disable Metrics/LineLength
end
end
end | [
"def",
"verify_parameters",
"required_parameters",
".",
"each",
"do",
"|",
"name",
",",
"wfparam",
"|",
"if",
"wfparam",
".",
"required?",
"&&",
"(",
"wfparam",
".",
"value",
".",
"nil?",
"||",
"wfparam",
".",
"value",
".",
"size",
"==",
"0",
")",
"fail"... | Verify that all mandatory input parameters have values | [
"Verify",
"that",
"all",
"mandatory",
"input",
"parameters",
"have",
"values"
] | 01db57318c14e572dc47261f55c8d08341306642 | https://github.com/activenetwork-automation/vcoworkflows/blob/01db57318c14e572dc47261f55c8d08341306642/lib/vcoworkflows/workflow.rb#L379-L385 | train |
axsh/isono | lib/isono/util.rb | Isono.Util.default_gw_ipaddr | def default_gw_ipaddr
ip = case `/bin/uname -s`.rstrip
when 'Linux'
`/sbin/ip route get 8.8.8.8`.split("\n")[0].split.last
when 'SunOS'
`/sbin/ifconfig $(/usr/sbin/route -n get 1.1.1.1 | awk '$1 == "interface:" {print $2}') | awk '$1 == "inet" { print $2 }'`
... | ruby | def default_gw_ipaddr
ip = case `/bin/uname -s`.rstrip
when 'Linux'
`/sbin/ip route get 8.8.8.8`.split("\n")[0].split.last
when 'SunOS'
`/sbin/ifconfig $(/usr/sbin/route -n get 1.1.1.1 | awk '$1 == "interface:" {print $2}') | awk '$1 == "inet" { print $2 }'`
... | [
"def",
"default_gw_ipaddr",
"ip",
"=",
"case",
"`",
"`",
".",
"rstrip",
"when",
"'Linux'",
"`",
"`",
".",
"split",
"(",
"\"\\n\"",
")",
"[",
"0",
"]",
".",
"split",
".",
"last",
"when",
"'SunOS'",
"`",
"`",
"else",
"raise",
"\"Unsupported platform to det... | Return the IP address assigned to default gw interface | [
"Return",
"the",
"IP",
"address",
"assigned",
"to",
"default",
"gw",
"interface"
] | 0325eb1a46538b8eea63e80745a9161e2532b7cf | https://github.com/axsh/isono/blob/0325eb1a46538b8eea63e80745a9161e2532b7cf/lib/isono/util.rb#L41-L53 | train |
nwjsmith/thumbtack | lib/thumbtack/notes.rb | Thumbtack.Notes.list | def list
response = @client.get('/notes/list')
response.fetch('notes', EMPTY_ARRAY).map do |note_hash|
NoteSummary.from_hash(note_hash)
end
end | ruby | def list
response = @client.get('/notes/list')
response.fetch('notes', EMPTY_ARRAY).map do |note_hash|
NoteSummary.from_hash(note_hash)
end
end | [
"def",
"list",
"response",
"=",
"@client",
".",
"get",
"(",
"'/notes/list'",
")",
"response",
".",
"fetch",
"(",
"'notes'",
",",
"EMPTY_ARRAY",
")",
".",
"map",
"do",
"|",
"note_hash",
"|",
"NoteSummary",
".",
"from_hash",
"(",
"note_hash",
")",
"end",
"... | Initialize a Notes
@param [Client] client
client to communicate with the Pinboard API
@api private
List of summaries of the user's notes
@example
summaries = notes.list
@return [Array<NoteSummary>]
@api public
@see https://pinboard.in/api/#notes_list | [
"Initialize",
"a",
"Notes"
] | f7d5323b91b901c7d61daadb9ef9c1ed08a3a7cb | https://github.com/nwjsmith/thumbtack/blob/f7d5323b91b901c7d61daadb9ef9c1ed08a3a7cb/lib/thumbtack/notes.rb#L26-L31 | train |
nwjsmith/thumbtack | lib/thumbtack/posts.rb | Thumbtack.Posts.get | def get(options = EMPTY_HASH)
parameters = Specification.new(
tag: Types::Tags,
dt: Types::Time,
url: Types::URL,
meta: Types::Boolean
).parameters(options)
posts_from @client.get('/posts/get', parameters)
end | ruby | def get(options = EMPTY_HASH)
parameters = Specification.new(
tag: Types::Tags,
dt: Types::Time,
url: Types::URL,
meta: Types::Boolean
).parameters(options)
posts_from @client.get('/posts/get', parameters)
end | [
"def",
"get",
"(",
"options",
"=",
"EMPTY_HASH",
")",
"parameters",
"=",
"Specification",
".",
"new",
"(",
"tag",
":",
"Types",
"::",
"Tags",
",",
"dt",
":",
"Types",
"::",
"Time",
",",
"url",
":",
"Types",
"::",
"URL",
",",
"meta",
":",
"Types",
"... | Fetch one or more bookmarks
@example
bookmarks = posts.get(tag: ['one', 'two', 'three'])
@param [Hash] options
options to filter the results by
@option options [Array<String>] :tag
up to three tags to filter by
@option options [Time] :dt
which day the results were bookmarked
@option options [String] ... | [
"Fetch",
"one",
"or",
"more",
"bookmarks"
] | f7d5323b91b901c7d61daadb9ef9c1ed08a3a7cb | https://github.com/nwjsmith/thumbtack/blob/f7d5323b91b901c7d61daadb9ef9c1ed08a3a7cb/lib/thumbtack/posts.rb#L115-L123 | train |
nwjsmith/thumbtack | lib/thumbtack/posts.rb | Thumbtack.Posts.recent | def recent(options = EMPTY_HASH)
parameters = Specification.new(
tag: Types::Tags,
count: Types::Integer
).parameters(options)
posts_from @client.get('/posts/recent', parameters)
end | ruby | def recent(options = EMPTY_HASH)
parameters = Specification.new(
tag: Types::Tags,
count: Types::Integer
).parameters(options)
posts_from @client.get('/posts/recent', parameters)
end | [
"def",
"recent",
"(",
"options",
"=",
"EMPTY_HASH",
")",
"parameters",
"=",
"Specification",
".",
"new",
"(",
"tag",
":",
"Types",
"::",
"Tags",
",",
"count",
":",
"Types",
"::",
"Integer",
")",
".",
"parameters",
"(",
"options",
")",
"posts_from",
"@cli... | List the most recent bookmarks
@example
bookmarks = posts.recent(tag: ['one', 'two', 'three'], count: 25)
@param [Hash] options
options to filter the results by
@option options [Array<String>] :tag
up to three tags to filter by
@option options [Integer] :count
the number of results to return
@return... | [
"List",
"the",
"most",
"recent",
"bookmarks"
] | f7d5323b91b901c7d61daadb9ef9c1ed08a3a7cb | https://github.com/nwjsmith/thumbtack/blob/f7d5323b91b901c7d61daadb9ef9c1ed08a3a7cb/lib/thumbtack/posts.rb#L142-L148 | train |
nwjsmith/thumbtack | lib/thumbtack/posts.rb | Thumbtack.Posts.all | def all(options = EMPTY_HASH)
parameters = Specification.new(
tag: Types::Tags,
start: Types::Integer,
results: Types::Integer,
fromdt: Types::Time,
todt: Types::Time,
meta: Types::Boolean
).parameters(options)
results = @client.get('/posts/all', paramet... | ruby | def all(options = EMPTY_HASH)
parameters = Specification.new(
tag: Types::Tags,
start: Types::Integer,
results: Types::Integer,
fromdt: Types::Time,
todt: Types::Time,
meta: Types::Boolean
).parameters(options)
results = @client.get('/posts/all', paramet... | [
"def",
"all",
"(",
"options",
"=",
"EMPTY_HASH",
")",
"parameters",
"=",
"Specification",
".",
"new",
"(",
"tag",
":",
"Types",
"::",
"Tags",
",",
"start",
":",
"Types",
"::",
"Integer",
",",
"results",
":",
"Types",
"::",
"Integer",
",",
"fromdt",
":"... | List all bookmarks
@example
posts.all(todt: yesterday, meta: true, tag: ['one', 'two', 'three'])
@param [Hash] options
options to filter the results by
@option options [Array<String>] :tag
up to three tags to filter by
@option options [Array<String>] :start
an offset value
@option options [Array<Stri... | [
"List",
"all",
"bookmarks"
] | f7d5323b91b901c7d61daadb9ef9c1ed08a3a7cb | https://github.com/nwjsmith/thumbtack/blob/f7d5323b91b901c7d61daadb9ef9c1ed08a3a7cb/lib/thumbtack/posts.rb#L175-L186 | train |
nwjsmith/thumbtack | lib/thumbtack/posts.rb | Thumbtack.Posts.suggest | def suggest(url)
parameters = Specification.new(url: Types::URL).parameters(url: url)
Suggestion.from_array(@client.get('/posts/suggest', parameters))
end | ruby | def suggest(url)
parameters = Specification.new(url: Types::URL).parameters(url: url)
Suggestion.from_array(@client.get('/posts/suggest', parameters))
end | [
"def",
"suggest",
"(",
"url",
")",
"parameters",
"=",
"Specification",
".",
"new",
"(",
"url",
":",
"Types",
"::",
"URL",
")",
".",
"parameters",
"(",
"url",
":",
"url",
")",
"Suggestion",
".",
"from_array",
"(",
"@client",
".",
"get",
"(",
"'/posts/su... | List popular and recommended tags for a URL
@example
suggestion = posts.suggest(url)
@param [String] url
URL to fetch suggested tags for
Returns a Hash with two entries, :popular is a list of popular tags,
:recommended is a list of recommended tags.
@return [Array<Suggestion>]
@api public
@see https:... | [
"List",
"popular",
"and",
"recommended",
"tags",
"for",
"a",
"URL"
] | f7d5323b91b901c7d61daadb9ef9c1ed08a3a7cb | https://github.com/nwjsmith/thumbtack/blob/f7d5323b91b901c7d61daadb9ef9c1ed08a3a7cb/lib/thumbtack/posts.rb#L204-L207 | train |
nwjsmith/thumbtack | lib/thumbtack/posts.rb | Thumbtack.Posts.dates | def dates(options = EMPTY_HASH)
parameters = Specification.new(tag: Types::Tags).parameters(options)
response = @client.get('/posts/dates', parameters)
dates_with_counts_from(response)
end | ruby | def dates(options = EMPTY_HASH)
parameters = Specification.new(tag: Types::Tags).parameters(options)
response = @client.get('/posts/dates', parameters)
dates_with_counts_from(response)
end | [
"def",
"dates",
"(",
"options",
"=",
"EMPTY_HASH",
")",
"parameters",
"=",
"Specification",
".",
"new",
"(",
"tag",
":",
"Types",
"::",
"Tags",
")",
".",
"parameters",
"(",
"options",
")",
"response",
"=",
"@client",
".",
"get",
"(",
"'/posts/dates'",
",... | List dates with the number of bookmarks created on each
@example
dates = posts.dates(tag: ['one', 'two', 'three'])
@param [Hash] options
options to filter the results by
@option options [Array<String>] :tag
up to three tags to filter by
@return [Hash{Date => Integer}]
dates on which bookmarks were cr... | [
"List",
"dates",
"with",
"the",
"number",
"of",
"bookmarks",
"created",
"on",
"each"
] | f7d5323b91b901c7d61daadb9ef9c1ed08a3a7cb | https://github.com/nwjsmith/thumbtack/blob/f7d5323b91b901c7d61daadb9ef9c1ed08a3a7cb/lib/thumbtack/posts.rb#L226-L230 | train |
nwjsmith/thumbtack | lib/thumbtack/posts.rb | Thumbtack.Posts.posts_from | def posts_from(response)
response.fetch('posts', EMPTY_ARRAY).map do |post_hash|
Post.from_hash(post_hash)
end
end | ruby | def posts_from(response)
response.fetch('posts', EMPTY_ARRAY).map do |post_hash|
Post.from_hash(post_hash)
end
end | [
"def",
"posts_from",
"(",
"response",
")",
"response",
".",
"fetch",
"(",
"'posts'",
",",
"EMPTY_ARRAY",
")",
".",
"map",
"do",
"|",
"post_hash",
"|",
"Post",
".",
"from_hash",
"(",
"post_hash",
")",
"end",
"end"
] | Create Post objects from posts response
@return [Array<Post>]
@api private | [
"Create",
"Post",
"objects",
"from",
"posts",
"response"
] | f7d5323b91b901c7d61daadb9ef9c1ed08a3a7cb | https://github.com/nwjsmith/thumbtack/blob/f7d5323b91b901c7d61daadb9ef9c1ed08a3a7cb/lib/thumbtack/posts.rb#L239-L243 | train |
nwjsmith/thumbtack | lib/thumbtack/posts.rb | Thumbtack.Posts.dates_with_counts_from | def dates_with_counts_from(response)
entries = response.fetch('dates', EMPTY_HASH).map do |date, count|
[Types::Date.deserialize(date), count.to_i]
end
Hash[entries]
end | ruby | def dates_with_counts_from(response)
entries = response.fetch('dates', EMPTY_HASH).map do |date, count|
[Types::Date.deserialize(date), count.to_i]
end
Hash[entries]
end | [
"def",
"dates_with_counts_from",
"(",
"response",
")",
"entries",
"=",
"response",
".",
"fetch",
"(",
"'dates'",
",",
"EMPTY_HASH",
")",
".",
"map",
"do",
"|",
"date",
",",
"count",
"|",
"[",
"Types",
"::",
"Date",
".",
"deserialize",
"(",
"date",
")",
... | Create Hash of dates to counts from dates response
@return [Hash{Date => Integer}]
@api private | [
"Create",
"Hash",
"of",
"dates",
"to",
"counts",
"from",
"dates",
"response"
] | f7d5323b91b901c7d61daadb9ef9c1ed08a3a7cb | https://github.com/nwjsmith/thumbtack/blob/f7d5323b91b901c7d61daadb9ef9c1ed08a3a7cb/lib/thumbtack/posts.rb#L250-L255 | train |
kreynolds/phidgets-ffi | lib/phidgets-ffi/servo.rb | Phidgets.Servo.on_position_change | def on_position_change(obj=nil, &block)
@on_position_change_obj = obj
@on_position_change = Proc.new { |device, obj_ptr, index, position|
yield self, @servos[index], position, object_for(obj_ptr)
}
Klass.set_OnPositionChange_Handler(@handle, @on_position_change, pointer_for(obj))
end | ruby | def on_position_change(obj=nil, &block)
@on_position_change_obj = obj
@on_position_change = Proc.new { |device, obj_ptr, index, position|
yield self, @servos[index], position, object_for(obj_ptr)
}
Klass.set_OnPositionChange_Handler(@handle, @on_position_change, pointer_for(obj))
end | [
"def",
"on_position_change",
"(",
"obj",
"=",
"nil",
",",
"&",
"block",
")",
"@on_position_change_obj",
"=",
"obj",
"@on_position_change",
"=",
"Proc",
".",
"new",
"{",
"|",
"device",
",",
"obj_ptr",
",",
"index",
",",
"position",
"|",
"yield",
"self",
","... | Sets a position change handler callback function. This is called when a the servo position has changed.
@param [String] obj Object to pass to the callback function. This is optional.
@param [Proc] Block When the callback is executed, the device and object are yielded to this block.
@example
servo.on_position_c... | [
"Sets",
"a",
"position",
"change",
"handler",
"callback",
"function",
".",
"This",
"is",
"called",
"when",
"a",
"the",
"servo",
"position",
"has",
"changed",
"."
] | 5c22e206804dc47e8ad37173baf952c874845973 | https://github.com/kreynolds/phidgets-ffi/blob/5c22e206804dc47e8ad37173baf952c874845973/lib/phidgets-ffi/servo.rb#L32-L38 | train |
kreynolds/phidgets-ffi | lib/phidgets-ffi/gps.rb | Phidgets.GPS.on_position_fix_status_change | def on_position_fix_status_change(obj=nil, &block)
@on_position_fix_status_change_obj = obj
@on_position_fix_status_change = Proc.new { |device, obj_ptr, fix_status|
yield self, (fix_status == 0 ? false : true), object_for(obj_ptr)
}
Klass.set_OnPositionFixStatusChange_Handler(@handle, @o... | ruby | def on_position_fix_status_change(obj=nil, &block)
@on_position_fix_status_change_obj = obj
@on_position_fix_status_change = Proc.new { |device, obj_ptr, fix_status|
yield self, (fix_status == 0 ? false : true), object_for(obj_ptr)
}
Klass.set_OnPositionFixStatusChange_Handler(@handle, @o... | [
"def",
"on_position_fix_status_change",
"(",
"obj",
"=",
"nil",
",",
"&",
"block",
")",
"@on_position_fix_status_change_obj",
"=",
"obj",
"@on_position_fix_status_change",
"=",
"Proc",
".",
"new",
"{",
"|",
"device",
",",
"obj_ptr",
",",
"fix_status",
"|",
"yield"... | Sets an position fix status change handler callback function. This is called when the position fix status changes.
@param [String] obj Object to pass to the callback function. This is optional.
@param [Proc] Block When the callback is executed, the device and object are yielded to this block.
@example
gps.on_p... | [
"Sets",
"an",
"position",
"fix",
"status",
"change",
"handler",
"callback",
"function",
".",
"This",
"is",
"called",
"when",
"the",
"position",
"fix",
"status",
"changes",
"."
] | 5c22e206804dc47e8ad37173baf952c874845973 | https://github.com/kreynolds/phidgets-ffi/blob/5c22e206804dc47e8ad37173baf952c874845973/lib/phidgets-ffi/gps.rb#L87-L93 | train |
kreynolds/phidgets-ffi | lib/phidgets-ffi/gps.rb | Phidgets.GPS.on_position_change | def on_position_change(obj=nil, &block)
@on_position_change_obj = obj
@on_position_change = Proc.new { |device, obj_ptr, lat, long, alt|
yield self, lat, long, alt, object_for(obj_ptr)
}
Klass.set_OnPositionChange_Handler(@handle, @on_position_change, pointer_for(obj))
end | ruby | def on_position_change(obj=nil, &block)
@on_position_change_obj = obj
@on_position_change = Proc.new { |device, obj_ptr, lat, long, alt|
yield self, lat, long, alt, object_for(obj_ptr)
}
Klass.set_OnPositionChange_Handler(@handle, @on_position_change, pointer_for(obj))
end | [
"def",
"on_position_change",
"(",
"obj",
"=",
"nil",
",",
"&",
"block",
")",
"@on_position_change_obj",
"=",
"obj",
"@on_position_change",
"=",
"Proc",
".",
"new",
"{",
"|",
"device",
",",
"obj_ptr",
",",
"lat",
",",
"long",
",",
"alt",
"|",
"yield",
"se... | Sets position change handler callback function. This is called when the latitude, longitude, or altitude changes.
@param [String] obj Object to pass to the callback function. This is optional.
@param [Proc] Block When the callback is executed, the device and object are yielded to this block.
@example
gps.on_po... | [
"Sets",
"position",
"change",
"handler",
"callback",
"function",
".",
"This",
"is",
"called",
"when",
"the",
"latitude",
"longitude",
"or",
"altitude",
"changes",
"."
] | 5c22e206804dc47e8ad37173baf952c874845973 | https://github.com/kreynolds/phidgets-ffi/blob/5c22e206804dc47e8ad37173baf952c874845973/lib/phidgets-ffi/gps.rb#L105-L111 | train |
kreynolds/phidgets-ffi | lib/phidgets-ffi/temperature_sensor.rb | Phidgets.TemperatureSensor.on_temperature_change | def on_temperature_change(obj=nil, &block)
@on_temperature_change_obj = obj
@on_temperature_change = Proc.new { |device, obj_ptr, index, temperature|
yield self, @thermocouples[index], temperature, object_for(obj_ptr)
}
Klass.set_OnTemperatureChange_Handler(@handle, @on_temperature_change, point... | ruby | def on_temperature_change(obj=nil, &block)
@on_temperature_change_obj = obj
@on_temperature_change = Proc.new { |device, obj_ptr, index, temperature|
yield self, @thermocouples[index], temperature, object_for(obj_ptr)
}
Klass.set_OnTemperatureChange_Handler(@handle, @on_temperature_change, point... | [
"def",
"on_temperature_change",
"(",
"obj",
"=",
"nil",
",",
"&",
"block",
")",
"@on_temperature_change_obj",
"=",
"obj",
"@on_temperature_change",
"=",
"Proc",
".",
"new",
"{",
"|",
"device",
",",
"obj_ptr",
",",
"index",
",",
"temperature",
"|",
"yield",
"... | Sets a temperature change handler callback function. This is called when when the temperature has changed atleast by the sensitivity value that has been set.
@param [String] obj Object to pass to the callback function. This is optional.
@param [Proc] Block When the callback is executed, the device and object are yie... | [
"Sets",
"a",
"temperature",
"change",
"handler",
"callback",
"function",
".",
"This",
"is",
"called",
"when",
"when",
"the",
"temperature",
"has",
"changed",
"atleast",
"by",
"the",
"sensitivity",
"value",
"that",
"has",
"been",
"set",
"."
] | 5c22e206804dc47e8ad37173baf952c874845973 | https://github.com/kreynolds/phidgets-ffi/blob/5c22e206804dc47e8ad37173baf952c874845973/lib/phidgets-ffi/temperature_sensor.rb#L32-L38 | train |
manojmj92/fulfil-ruby | lib/fulfil/request.rb | Fulfil.Request.check_auth_params | def check_auth_params
if (Fulfil.authentication.nil? || Fulfil.authentication[:subdomain].empty? || Fulfil.authentication[:api_key].empty?)
raise Fulfil::AuthenticationError, "Please set your subdomain and api key"
end
end | ruby | def check_auth_params
if (Fulfil.authentication.nil? || Fulfil.authentication[:subdomain].empty? || Fulfil.authentication[:api_key].empty?)
raise Fulfil::AuthenticationError, "Please set your subdomain and api key"
end
end | [
"def",
"check_auth_params",
"if",
"(",
"Fulfil",
".",
"authentication",
".",
"nil?",
"||",
"Fulfil",
".",
"authentication",
"[",
":subdomain",
"]",
".",
"empty?",
"||",
"Fulfil",
".",
"authentication",
"[",
":api_key",
"]",
".",
"empty?",
")",
"raise",
"Fulf... | USed to check if auth is done properly before making calls | [
"USed",
"to",
"check",
"if",
"auth",
"is",
"done",
"properly",
"before",
"making",
"calls"
] | f47832eeb4137c8cc531fab4c1f9a181e6be5652 | https://github.com/manojmj92/fulfil-ruby/blob/f47832eeb4137c8cc531fab4c1f9a181e6be5652/lib/fulfil/request.rb#L37-L41 | train |
manojmj92/fulfil-ruby | lib/fulfil/request.rb | Fulfil.Request.request | def request(http_method, data={}, url="")
final_url = @options[:base_url] << url
begin
case http_method
when :get
response = Curl.get(final_url, data) do |http|
http.headers['x-api-key'] = @options[:api_key]
http.headers['Accept']... | ruby | def request(http_method, data={}, url="")
final_url = @options[:base_url] << url
begin
case http_method
when :get
response = Curl.get(final_url, data) do |http|
http.headers['x-api-key'] = @options[:api_key]
http.headers['Accept']... | [
"def",
"request",
"(",
"http_method",
",",
"data",
"=",
"{",
"}",
",",
"url",
"=",
"\"\"",
")",
"final_url",
"=",
"@options",
"[",
":base_url",
"]",
"<<",
"url",
"begin",
"case",
"http_method",
"when",
":get",
"response",
"=",
"Curl",
".",
"get",
"(",
... | Issue request and get response | [
"Issue",
"request",
"and",
"get",
"response"
] | f47832eeb4137c8cc531fab4c1f9a181e6be5652 | https://github.com/manojmj92/fulfil-ruby/blob/f47832eeb4137c8cc531fab4c1f9a181e6be5652/lib/fulfil/request.rb#L44-L58 | train |
nwjsmith/thumbtack | lib/thumbtack/tags.rb | Thumbtack.Tags.get | def get
response = @client.get('/tags/get')
Hash[response.map { |tag, count| [tag, count.to_i] }]
end | ruby | def get
response = @client.get('/tags/get')
Hash[response.map { |tag, count| [tag, count.to_i] }]
end | [
"def",
"get",
"response",
"=",
"@client",
".",
"get",
"(",
"'/tags/get'",
")",
"Hash",
"[",
"response",
".",
"map",
"{",
"|",
"tag",
",",
"count",
"|",
"[",
"tag",
",",
"count",
".",
"to_i",
"]",
"}",
"]",
"end"
] | Initialize a Tags
@param [Client] client
client to communicate with the Pinboard API
@api private
List tags with their counts
@example
tag_counts = tags.get
@return [Hash{String => Integer}]
tags associated with the number of times they have been used
@api public
@see https://pinboard.in/api/#tags... | [
"Initialize",
"a",
"Tags"
] | f7d5323b91b901c7d61daadb9ef9c1ed08a3a7cb | https://github.com/nwjsmith/thumbtack/blob/f7d5323b91b901c7d61daadb9ef9c1ed08a3a7cb/lib/thumbtack/tags.rb#L27-L30 | train |
nwjsmith/thumbtack | lib/thumbtack/tags.rb | Thumbtack.Tags.delete | def delete(tag)
parameters = Specification.new(tag: Types::Tags).parameters(tag: tag)
@client.action('/tags/delete', parameters)
self
end | ruby | def delete(tag)
parameters = Specification.new(tag: Types::Tags).parameters(tag: tag)
@client.action('/tags/delete', parameters)
self
end | [
"def",
"delete",
"(",
"tag",
")",
"parameters",
"=",
"Specification",
".",
"new",
"(",
"tag",
":",
"Types",
"::",
"Tags",
")",
".",
"parameters",
"(",
"tag",
":",
"tag",
")",
"@client",
".",
"action",
"(",
"'/tags/delete'",
",",
"parameters",
")",
"sel... | Delete a tag
@example
tags.delete(tag)
@param [String] tag
the tag to delete
@return [self]
@api public
@see https://pinboard.in/api/#tags_delete | [
"Delete",
"a",
"tag"
] | f7d5323b91b901c7d61daadb9ef9c1ed08a3a7cb | https://github.com/nwjsmith/thumbtack/blob/f7d5323b91b901c7d61daadb9ef9c1ed08a3a7cb/lib/thumbtack/tags.rb#L45-L49 | train |
nwjsmith/thumbtack | lib/thumbtack/tags.rb | Thumbtack.Tags.rename | def rename(old, new)
parameters = Specification.new(
old: Types::Tags,
new: Types::Tags
).parameters(old: old, new: new)
@client.action('/tags/rename', parameters)
self
end | ruby | def rename(old, new)
parameters = Specification.new(
old: Types::Tags,
new: Types::Tags
).parameters(old: old, new: new)
@client.action('/tags/rename', parameters)
self
end | [
"def",
"rename",
"(",
"old",
",",
"new",
")",
"parameters",
"=",
"Specification",
".",
"new",
"(",
"old",
":",
"Types",
"::",
"Tags",
",",
"new",
":",
"Types",
"::",
"Tags",
")",
".",
"parameters",
"(",
"old",
":",
"old",
",",
"new",
":",
"new",
... | Rename a tag
@example
tags.rename(old, new)
@param [String] old
the tag to be renamed
@param [String] new
the new name for the tag
@return [self]
@api public
@see https://pinboard.in/api/#tags_rename | [
"Rename",
"a",
"tag"
] | f7d5323b91b901c7d61daadb9ef9c1ed08a3a7cb | https://github.com/nwjsmith/thumbtack/blob/f7d5323b91b901c7d61daadb9ef9c1ed08a3a7cb/lib/thumbtack/tags.rb#L66-L73 | train |
axsh/isono | lib/isono/daemonize.rb | Wakame.Daemonize.change_privilege | def change_privilege(user, group=user)
Wakame.log.info("Changing process privilege to #{user}:#{group}")
uid, gid = Process.euid, Process.egid
target_uid = Etc.getpwnam(user).uid
target_gid = Etc.getgrnam(group).gid
if uid != target_uid || gid != target_gid
if pid_file && File.ex... | ruby | def change_privilege(user, group=user)
Wakame.log.info("Changing process privilege to #{user}:#{group}")
uid, gid = Process.euid, Process.egid
target_uid = Etc.getpwnam(user).uid
target_gid = Etc.getgrnam(group).gid
if uid != target_uid || gid != target_gid
if pid_file && File.ex... | [
"def",
"change_privilege",
"(",
"user",
",",
"group",
"=",
"user",
")",
"Wakame",
".",
"log",
".",
"info",
"(",
"\"Changing process privilege to #{user}:#{group}\"",
")",
"uid",
",",
"gid",
"=",
"Process",
".",
"euid",
",",
"Process",
".",
"egid",
"target_uid"... | Change privileges of the process
to the specified user and group. | [
"Change",
"privileges",
"of",
"the",
"process",
"to",
"the",
"specified",
"user",
"and",
"group",
"."
] | 0325eb1a46538b8eea63e80745a9161e2532b7cf | https://github.com/axsh/isono/blob/0325eb1a46538b8eea63e80745a9161e2532b7cf/lib/isono/daemonize.rb#L21-L40 | train |
activenetwork-automation/vcoworkflows | lib/vcoworkflows/config.rb | VcoWorkflows.Config.to_json | def to_json
config = {}
config['url'] = @url
config['username'] = @username
config['password'] = @password
config['verify_ssl'] = @verify_ssl
puts JSON.pretty_generate(config)
end | ruby | def to_json
config = {}
config['url'] = @url
config['username'] = @username
config['password'] = @password
config['verify_ssl'] = @verify_ssl
puts JSON.pretty_generate(config)
end | [
"def",
"to_json",
"config",
"=",
"{",
"}",
"config",
"[",
"'url'",
"]",
"=",
"@url",
"config",
"[",
"'username'",
"]",
"=",
"@username",
"config",
"[",
"'password'",
"]",
"=",
"@password",
"config",
"[",
"'verify_ssl'",
"]",
"=",
"@verify_ssl",
"puts",
"... | Return a JSON document for this object | [
"Return",
"a",
"JSON",
"document",
"for",
"this",
"object"
] | 01db57318c14e572dc47261f55c8d08341306642 | https://github.com/activenetwork-automation/vcoworkflows/blob/01db57318c14e572dc47261f55c8d08341306642/lib/vcoworkflows/config.rb#L82-L89 | train |
kreynolds/phidgets-ffi | lib/phidgets-ffi/interface_kit.rb | Phidgets.InterfaceKit.on_sensor_change | def on_sensor_change(obj=nil, &block)
@on_sensor_change_obj = obj
@on_sensor_change = Proc.new { |device, obj_ptr, index, value|
yield self, @sensors[index], value, object_for(obj_ptr)
}
Klass.set_OnSensorChange_Handler(@handle, @on_sensor_change, pointer_for(obj))
end | ruby | def on_sensor_change(obj=nil, &block)
@on_sensor_change_obj = obj
@on_sensor_change = Proc.new { |device, obj_ptr, index, value|
yield self, @sensors[index], value, object_for(obj_ptr)
}
Klass.set_OnSensorChange_Handler(@handle, @on_sensor_change, pointer_for(obj))
end | [
"def",
"on_sensor_change",
"(",
"obj",
"=",
"nil",
",",
"&",
"block",
")",
"@on_sensor_change_obj",
"=",
"obj",
"@on_sensor_change",
"=",
"Proc",
".",
"new",
"{",
"|",
"device",
",",
"obj_ptr",
",",
"index",
",",
"value",
"|",
"yield",
"self",
",",
"@sen... | Sets a sensor change handler callback function. This is called when a sensor on the PhidgetInterfaceKit has changed by at least the sensitivity value that has been set for this input.
@param [String] obj Object to pass to the callback function. This is optional.
@param [Proc] Block When the callback is executed, the... | [
"Sets",
"a",
"sensor",
"change",
"handler",
"callback",
"function",
".",
"This",
"is",
"called",
"when",
"a",
"sensor",
"on",
"the",
"PhidgetInterfaceKit",
"has",
"changed",
"by",
"at",
"least",
"the",
"sensitivity",
"value",
"that",
"has",
"been",
"set",
"f... | 5c22e206804dc47e8ad37173baf952c874845973 | https://github.com/kreynolds/phidgets-ffi/blob/5c22e206804dc47e8ad37173baf952c874845973/lib/phidgets-ffi/interface_kit.rb#L79-L85 | train |
GlobalNamesArchitecture/dwca_hunter | lib/dwca_hunter/downloader.rb | DwcaHunter.Downloader.download | def download
raise "#{@source_url} is not accessible" unless @url.valid?
f = open(@file_path,'wb')
count = 0
@url.net_http.request_get(@url.path) do |r|
r.read_body do |s|
@download_length += s.length
f.write s
if block_given?
count += 1
... | ruby | def download
raise "#{@source_url} is not accessible" unless @url.valid?
f = open(@file_path,'wb')
count = 0
@url.net_http.request_get(@url.path) do |r|
r.read_body do |s|
@download_length += s.length
f.write s
if block_given?
count += 1
... | [
"def",
"download",
"raise",
"\"#{@source_url} is not accessible\"",
"unless",
"@url",
".",
"valid?",
"f",
"=",
"open",
"(",
"@file_path",
",",
"'wb'",
")",
"count",
"=",
"0",
"@url",
".",
"net_http",
".",
"request_get",
"(",
"@url",
".",
"path",
")",
"do",
... | downloads a given file into a specified filename.
If block is given returns download progress | [
"downloads",
"a",
"given",
"file",
"into",
"a",
"specified",
"filename",
".",
"If",
"block",
"is",
"given",
"returns",
"download",
"progress"
] | fa7665c2bf6a1033ac20097fa1ef372830ff5e2c | https://github.com/GlobalNamesArchitecture/dwca_hunter/blob/fa7665c2bf6a1033ac20097fa1ef372830ff5e2c/lib/dwca_hunter/downloader.rb#L17-L37 | train |
elektronaut/dynamic_image | lib/dynamic_image/helper.rb | DynamicImage.Helper.dynamic_image_tag | def dynamic_image_tag(record_or_array, options = {})
record = extract_dynamic_image_record(record_or_array)
options = { alt: filename_to_alt(record.filename) }.merge(options)
size = fit_size!(record_or_array, options)
url_options = options.extract!(*allowed_dynamic_image_url_options)
html... | ruby | def dynamic_image_tag(record_or_array, options = {})
record = extract_dynamic_image_record(record_or_array)
options = { alt: filename_to_alt(record.filename) }.merge(options)
size = fit_size!(record_or_array, options)
url_options = options.extract!(*allowed_dynamic_image_url_options)
html... | [
"def",
"dynamic_image_tag",
"(",
"record_or_array",
",",
"options",
"=",
"{",
"}",
")",
"record",
"=",
"extract_dynamic_image_record",
"(",
"record_or_array",
")",
"options",
"=",
"{",
"alt",
":",
"filename_to_alt",
"(",
"record",
".",
"filename",
")",
"}",
".... | Returns an HTML image tag for the record. If no size is given, it will
render at the original size.
==== Options
* <tt>:alt</tt>: If no alt text is given, it will default to the
filename of the uploaded image.
See +dynamic_image_url+ for info on how to size and cropping. Options
supported by +polymorphic_url+... | [
"Returns",
"an",
"HTML",
"image",
"tag",
"for",
"the",
"record",
".",
"If",
"no",
"size",
"is",
"given",
"it",
"will",
"render",
"at",
"the",
"original",
"size",
"."
] | d711f8f5d8385fb36d7ff9a6012f3fd123005c18 | https://github.com/elektronaut/dynamic_image/blob/d711f8f5d8385fb36d7ff9a6012f3fd123005c18/lib/dynamic_image/helper.rb#L32-L44 | train |
adamcooke/authie | lib/authie/session.rb | Authie.Session.touch! | def touch!
self.check_security!
self.last_activity_at = Time.now
self.last_activity_ip = controller.request.ip
self.last_activity_path = controller.request.path
self.requests += 1
self.save!
Authie.config.events.dispatch(:session_touched, self)
true
end | ruby | def touch!
self.check_security!
self.last_activity_at = Time.now
self.last_activity_ip = controller.request.ip
self.last_activity_path = controller.request.path
self.requests += 1
self.save!
Authie.config.events.dispatch(:session_touched, self)
true
end | [
"def",
"touch!",
"self",
".",
"check_security!",
"self",
".",
"last_activity_at",
"=",
"Time",
".",
"now",
"self",
".",
"last_activity_ip",
"=",
"controller",
".",
"request",
".",
"ip",
"self",
".",
"last_activity_path",
"=",
"controller",
".",
"request",
".",... | This method should be called each time a user performs an
action while authenticated with this session. | [
"This",
"method",
"should",
"be",
"called",
"each",
"time",
"a",
"user",
"performs",
"an",
"action",
"while",
"authenticated",
"with",
"this",
"session",
"."
] | d88eb2096b584d6fa20da69b155da97c6f042d05 | https://github.com/adamcooke/authie/blob/d88eb2096b584d6fa20da69b155da97c6f042d05/lib/authie/session.rb#L56-L65 | train |
adamcooke/authie | lib/authie/session.rb | Authie.Session.set_cookie! | def set_cookie!
cookies[:user_session] = {
:value => self.temporary_token,
:secure => controller.request.ssl?,
:httponly => true,
:expires => self.expires_at
}
Authie.config.events.dispatch(:session_cookie_updated, self)
true
end | ruby | def set_cookie!
cookies[:user_session] = {
:value => self.temporary_token,
:secure => controller.request.ssl?,
:httponly => true,
:expires => self.expires_at
}
Authie.config.events.dispatch(:session_cookie_updated, self)
true
end | [
"def",
"set_cookie!",
"cookies",
"[",
":user_session",
"]",
"=",
"{",
":value",
"=>",
"self",
".",
"temporary_token",
",",
":secure",
"=>",
"controller",
".",
"request",
".",
"ssl?",
",",
":httponly",
"=>",
"true",
",",
":expires",
"=>",
"self",
".",
"expi... | Sets the cookie on the associated controller. | [
"Sets",
"the",
"cookie",
"on",
"the",
"associated",
"controller",
"."
] | d88eb2096b584d6fa20da69b155da97c6f042d05 | https://github.com/adamcooke/authie/blob/d88eb2096b584d6fa20da69b155da97c6f042d05/lib/authie/session.rb#L68-L77 | train |
adamcooke/authie | lib/authie/session.rb | Authie.Session.check_security! | def check_security!
if controller
if cookies[:browser_id] != self.browser_id
invalidate!
Authie.config.events.dispatch(:browser_id_mismatch_error, self)
raise BrowserMismatch, "Browser ID mismatch"
end
unless self.active?
invalidate!
Authi... | ruby | def check_security!
if controller
if cookies[:browser_id] != self.browser_id
invalidate!
Authie.config.events.dispatch(:browser_id_mismatch_error, self)
raise BrowserMismatch, "Browser ID mismatch"
end
unless self.active?
invalidate!
Authi... | [
"def",
"check_security!",
"if",
"controller",
"if",
"cookies",
"[",
":browser_id",
"]",
"!=",
"self",
".",
"browser_id",
"invalidate!",
"Authie",
".",
"config",
".",
"events",
".",
"dispatch",
"(",
":browser_id_mismatch_error",
",",
"self",
")",
"raise",
"Browse... | Check the security of the session to ensure it can be used. | [
"Check",
"the",
"security",
"of",
"the",
"session",
"to",
"ensure",
"it",
"can",
"be",
"used",
"."
] | d88eb2096b584d6fa20da69b155da97c6f042d05 | https://github.com/adamcooke/authie/blob/d88eb2096b584d6fa20da69b155da97c6f042d05/lib/authie/session.rb#L80-L112 | train |
adamcooke/authie | lib/authie/session.rb | Authie.Session.invalidate! | def invalidate!
self.active = false
self.save!
if controller
cookies.delete(:user_session)
end
Authie.config.events.dispatch(:session_invalidated, self)
true
end | ruby | def invalidate!
self.active = false
self.save!
if controller
cookies.delete(:user_session)
end
Authie.config.events.dispatch(:session_invalidated, self)
true
end | [
"def",
"invalidate!",
"self",
".",
"active",
"=",
"false",
"self",
".",
"save!",
"if",
"controller",
"cookies",
".",
"delete",
"(",
":user_session",
")",
"end",
"Authie",
".",
"config",
".",
"events",
".",
"dispatch",
"(",
":session_invalidated",
",",
"self"... | Mark this session as invalid | [
"Mark",
"this",
"session",
"as",
"invalid"
] | d88eb2096b584d6fa20da69b155da97c6f042d05 | https://github.com/adamcooke/authie/blob/d88eb2096b584d6fa20da69b155da97c6f042d05/lib/authie/session.rb#L147-L155 | train |
adamcooke/authie | lib/authie/session.rb | Authie.Session.see_password! | def see_password!
self.password_seen_at = Time.now
self.save!
Authie.config.events.dispatch(:seen_password, self)
true
end | ruby | def see_password!
self.password_seen_at = Time.now
self.save!
Authie.config.events.dispatch(:seen_password, self)
true
end | [
"def",
"see_password!",
"self",
".",
"password_seen_at",
"=",
"Time",
".",
"now",
"self",
".",
"save!",
"Authie",
".",
"config",
".",
"events",
".",
"dispatch",
"(",
":seen_password",
",",
"self",
")",
"true",
"end"
] | Note that we have just seen the user enter their password. | [
"Note",
"that",
"we",
"have",
"just",
"seen",
"the",
"user",
"enter",
"their",
"password",
"."
] | d88eb2096b584d6fa20da69b155da97c6f042d05 | https://github.com/adamcooke/authie/blob/d88eb2096b584d6fa20da69b155da97c6f042d05/lib/authie/session.rb#L177-L182 | train |
adamcooke/authie | lib/authie/session.rb | Authie.Session.mark_as_two_factored! | def mark_as_two_factored!
self.two_factored_at = Time.now
self.two_factored_ip = controller.request.ip
self.save!
Authie.config.events.dispatch(:marked_as_two_factored, self)
true
end | ruby | def mark_as_two_factored!
self.two_factored_at = Time.now
self.two_factored_ip = controller.request.ip
self.save!
Authie.config.events.dispatch(:marked_as_two_factored, self)
true
end | [
"def",
"mark_as_two_factored!",
"self",
".",
"two_factored_at",
"=",
"Time",
".",
"now",
"self",
".",
"two_factored_ip",
"=",
"controller",
".",
"request",
".",
"ip",
"self",
".",
"save!",
"Authie",
".",
"config",
".",
"events",
".",
"dispatch",
"(",
":marke... | Mark this request as two factor authoritsed | [
"Mark",
"this",
"request",
"as",
"two",
"factor",
"authoritsed"
] | d88eb2096b584d6fa20da69b155da97c6f042d05 | https://github.com/adamcooke/authie/blob/d88eb2096b584d6fa20da69b155da97c6f042d05/lib/authie/session.rb#L195-L201 | train |
adamcooke/authie | lib/authie/session.rb | Authie.Session.revert_to_parent! | def revert_to_parent!
if self.parent
self.invalidate!
self.parent.activate!
self.parent.controller = self.controller
self.parent.set_cookie!
self.parent
else
raise NoParentSessionForRevert, "Session does not have a parent therefore cannot be reverted."
e... | ruby | def revert_to_parent!
if self.parent
self.invalidate!
self.parent.activate!
self.parent.controller = self.controller
self.parent.set_cookie!
self.parent
else
raise NoParentSessionForRevert, "Session does not have a parent therefore cannot be reverted."
e... | [
"def",
"revert_to_parent!",
"if",
"self",
".",
"parent",
"self",
".",
"invalidate!",
"self",
".",
"parent",
".",
"activate!",
"self",
".",
"parent",
".",
"controller",
"=",
"self",
".",
"controller",
"self",
".",
"parent",
".",
"set_cookie!",
"self",
".",
... | Revert back to the parent session | [
"Revert",
"back",
"to",
"the",
"parent",
"session"
] | d88eb2096b584d6fa20da69b155da97c6f042d05 | https://github.com/adamcooke/authie/blob/d88eb2096b584d6fa20da69b155da97c6f042d05/lib/authie/session.rb#L209-L219 | train |
dbgrandi/danger-prose | lib/danger_plugin.rb | Danger.DangerProse.lint_files | def lint_files(files = nil)
# Installs a prose checker if needed
system 'pip install --user proselint' unless proselint_installed?
# Check that this is in the user's PATH after installing
raise "proselint is not in the user's PATH, or it failed to install" unless proselint_installed?
# E... | ruby | def lint_files(files = nil)
# Installs a prose checker if needed
system 'pip install --user proselint' unless proselint_installed?
# Check that this is in the user's PATH after installing
raise "proselint is not in the user's PATH, or it failed to install" unless proselint_installed?
# E... | [
"def",
"lint_files",
"(",
"files",
"=",
"nil",
")",
"system",
"'pip install --user proselint'",
"unless",
"proselint_installed?",
"raise",
"\"proselint is not in the user's PATH, or it failed to install\"",
"unless",
"proselint_installed?",
"markdown_files",
"=",
"get_files",
"fi... | Lints the globbed markdown files. Will fail if `proselint` cannot be installed correctly.
Generates a `markdown` list of warnings for the prose in a corpus of .markdown and .md files.
@param [String] files
A globbed string which should return the files that you want to lint, defaults to nil.
if... | [
"Lints",
"the",
"globbed",
"markdown",
"files",
".",
"Will",
"fail",
"if",
"proselint",
"cannot",
"be",
"installed",
"correctly",
".",
"Generates",
"a",
"markdown",
"list",
"of",
"warnings",
"for",
"the",
"prose",
"in",
"a",
"corpus",
"of",
".",
"markdown",
... | b32ddfe58194dfe16be327f3d1e4a0d85af714a9 | https://github.com/dbgrandi/danger-prose/blob/b32ddfe58194dfe16be327f3d1e4a0d85af714a9/lib/danger_plugin.rb#L48-L86 | train |
dbgrandi/danger-prose | lib/danger_plugin.rb | Danger.DangerProse.with_proselint_disabled | def with_proselint_disabled(disable_linters)
# Create the disabled linters JSON in ~/.proselintrc
proselint_template = File.join(File.dirname(__FILE__), 'proselintrc')
proselintJSON = JSON.parse(File.read(proselint_template))
# Disable individual linters
disable_linters.each do |linter|
... | ruby | def with_proselint_disabled(disable_linters)
# Create the disabled linters JSON in ~/.proselintrc
proselint_template = File.join(File.dirname(__FILE__), 'proselintrc')
proselintJSON = JSON.parse(File.read(proselint_template))
# Disable individual linters
disable_linters.each do |linter|
... | [
"def",
"with_proselint_disabled",
"(",
"disable_linters",
")",
"proselint_template",
"=",
"File",
".",
"join",
"(",
"File",
".",
"dirname",
"(",
"__FILE__",
")",
",",
"'proselintrc'",
")",
"proselintJSON",
"=",
"JSON",
".",
"parse",
"(",
"File",
".",
"read",
... | Creates a temporary proselint settings file
@return void | [
"Creates",
"a",
"temporary",
"proselint",
"settings",
"file"
] | b32ddfe58194dfe16be327f3d1e4a0d85af714a9 | https://github.com/dbgrandi/danger-prose/blob/b32ddfe58194dfe16be327f3d1e4a0d85af714a9/lib/danger_plugin.rb#L191-L210 | train |
jonmagic/grim | lib/grim/page.rb | Grim.Page.save | def save(path, options={})
raise PathMissing if path.nil? || path !~ /\S/
Grim.processor.save(@pdf, @index, path, options)
end | ruby | def save(path, options={})
raise PathMissing if path.nil? || path !~ /\S/
Grim.processor.save(@pdf, @index, path, options)
end | [
"def",
"save",
"(",
"path",
",",
"options",
"=",
"{",
"}",
")",
"raise",
"PathMissing",
"if",
"path",
".",
"nil?",
"||",
"path",
"!~",
"/",
"\\S",
"/",
"Grim",
".",
"processor",
".",
"save",
"(",
"@pdf",
",",
"@index",
",",
"path",
",",
"options",
... | Sets up some instance variables on new instance.
pdf - the pdf this page belongs to
index - the index of the page in the array of pages
options - A Hash of options.
:pdftotext_path - The String path of where to find the pdftotext
binary to use when extracting text
... | [
"Sets",
"up",
"some",
"instance",
"variables",
"on",
"new",
"instance",
"."
] | 45ffef3f762345ca1cbe8901f95898ac1de5e37c | https://github.com/jonmagic/grim/blob/45ffef3f762345ca1cbe8901f95898ac1de5e37c/lib/grim/page.rb#L37-L41 | train |
bitrise-io/ipa_analyzer | lib/ipa_analyzer/analyzer.rb | IpaAnalyzer.Analyzer.find_app_folder_in_ipa | def find_app_folder_in_ipa
raise 'IPA is not open' unless self.open?
# Check the most common location
app_folder_in_ipa = "Payload/#{File.basename(@ipa_path, File.extname(@ipa_path))}.app"
#
mobileprovision_entry = @ipa_zipfile.find_entry("#{app_folder_in_ipa}/embedded.mobileprovision")
... | ruby | def find_app_folder_in_ipa
raise 'IPA is not open' unless self.open?
# Check the most common location
app_folder_in_ipa = "Payload/#{File.basename(@ipa_path, File.extname(@ipa_path))}.app"
#
mobileprovision_entry = @ipa_zipfile.find_entry("#{app_folder_in_ipa}/embedded.mobileprovision")
... | [
"def",
"find_app_folder_in_ipa",
"raise",
"'IPA is not open'",
"unless",
"self",
".",
"open?",
"app_folder_in_ipa",
"=",
"\"Payload/#{File.basename(@ipa_path, File.extname(@ipa_path))}.app\"",
"mobileprovision_entry",
"=",
"@ipa_zipfile",
".",
"find_entry",
"(",
"\"#{app_folder_in_... | Find the .app folder which contains both the "embedded.mobileprovision"
and "Info.plist" files. | [
"Find",
"the",
".",
"app",
"folder",
"which",
"contains",
"both",
"the",
"embedded",
".",
"mobileprovision",
"and",
"Info",
".",
"plist",
"files",
"."
] | 70dbcbdbb2371b60c327931aa8fea587505e41bd | https://github.com/bitrise-io/ipa_analyzer/blob/70dbcbdbb2371b60c327931aa8fea587505e41bd/lib/ipa_analyzer/analyzer.rb#L105-L133 | train |
infosimples/deathbycaptcha | lib/deathbycaptcha/client.rb | DeathByCaptcha.Client.load_captcha | def load_captcha(options)
if options[:raw64]
options[:raw64]
elsif options[:raw]
Base64.encode64(options[:raw])
elsif options[:file]
Base64.encode64(options[:file].read())
elsif options[:path]
Base64.encode64(File.open(options[:path], 'rb').read)
elsif optio... | ruby | def load_captcha(options)
if options[:raw64]
options[:raw64]
elsif options[:raw]
Base64.encode64(options[:raw])
elsif options[:file]
Base64.encode64(options[:file].read())
elsif options[:path]
Base64.encode64(File.open(options[:path], 'rb').read)
elsif optio... | [
"def",
"load_captcha",
"(",
"options",
")",
"if",
"options",
"[",
":raw64",
"]",
"options",
"[",
":raw64",
"]",
"elsif",
"options",
"[",
":raw",
"]",
"Base64",
".",
"encode64",
"(",
"options",
"[",
":raw",
"]",
")",
"elsif",
"options",
"[",
":file",
"]... | Load a captcha raw content encoded in base64 from options.
@param [Hash] options Options hash.
@option options [String] :url URL of the image to be decoded.
@option options [String] :path File path of the image to be decoded.
@option options [File] :file File instance with image to be decoded.
@option... | [
"Load",
"a",
"captcha",
"raw",
"content",
"encoded",
"in",
"base64",
"from",
"options",
"."
] | b6fc9503025b24adaffb8c28843995a7f1715cb7 | https://github.com/infosimples/deathbycaptcha/blob/b6fc9503025b24adaffb8c28843995a7f1715cb7/lib/deathbycaptcha/client.rb#L169-L185 | train |
infosimples/deathbycaptcha | lib/deathbycaptcha/client/socket.rb | DeathByCaptcha.Client::Socket.captcha | def captcha(captcha_id)
response = perform('captcha', captcha: captcha_id)
DeathByCaptcha::Captcha.new(response)
end | ruby | def captcha(captcha_id)
response = perform('captcha', captcha: captcha_id)
DeathByCaptcha::Captcha.new(response)
end | [
"def",
"captcha",
"(",
"captcha_id",
")",
"response",
"=",
"perform",
"(",
"'captcha'",
",",
"captcha",
":",
"captcha_id",
")",
"DeathByCaptcha",
"::",
"Captcha",
".",
"new",
"(",
"response",
")",
"end"
] | Retrieve information from an uploaded captcha.
@param [Integer] captcha_id Numeric ID of the captcha.
@return [DeathByCaptcha::Captcha] The captcha object. | [
"Retrieve",
"information",
"from",
"an",
"uploaded",
"captcha",
"."
] | b6fc9503025b24adaffb8c28843995a7f1715cb7 | https://github.com/infosimples/deathbycaptcha/blob/b6fc9503025b24adaffb8c28843995a7f1715cb7/lib/deathbycaptcha/client/socket.rb#L15-L18 | train |
infosimples/deathbycaptcha | lib/deathbycaptcha/client/socket.rb | DeathByCaptcha.Client::Socket.perform | def perform(action, payload = {})
payload.merge!(
cmd: action,
version: DeathByCaptcha::API_VERSION,
username: self.username,
password: self.password
)
socket = create_socket()
socket.puts(payload.to_json)
response = socket.read()
socket.close()
... | ruby | def perform(action, payload = {})
payload.merge!(
cmd: action,
version: DeathByCaptcha::API_VERSION,
username: self.username,
password: self.password
)
socket = create_socket()
socket.puts(payload.to_json)
response = socket.read()
socket.close()
... | [
"def",
"perform",
"(",
"action",
",",
"payload",
"=",
"{",
"}",
")",
"payload",
".",
"merge!",
"(",
"cmd",
":",
"action",
",",
"version",
":",
"DeathByCaptcha",
"::",
"API_VERSION",
",",
"username",
":",
"self",
".",
"username",
",",
"password",
":",
"... | Perform a Socket communication with the DeathByCaptcha API.
@param [String] action API method name.
@param [Hash] payload Data to be exchanged in the communication.
@return [Hash] Response from the DeathByCaptcha API. | [
"Perform",
"a",
"Socket",
"communication",
"with",
"the",
"DeathByCaptcha",
"API",
"."
] | b6fc9503025b24adaffb8c28843995a7f1715cb7 | https://github.com/infosimples/deathbycaptcha/blob/b6fc9503025b24adaffb8c28843995a7f1715cb7/lib/deathbycaptcha/client/socket.rb#L74-L107 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.