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
Clever/clever-ruby
lib/clever-ruby/api/data_api.rb
Clever.DataApi.get_term_for_section
def get_term_for_section(id, opts = {}) data, _status_code, _headers = get_term_for_section_with_http_info(id, opts) return data end
ruby
def get_term_for_section(id, opts = {}) data, _status_code, _headers = get_term_for_section_with_http_info(id, opts) return data end
[ "def", "get_term_for_section", "(", "id", ",", "opts", "=", "{", "}", ")", "data", ",", "_status_code", ",", "_headers", "=", "get_term_for_section_with_http_info", "(", "id", ",", "opts", ")", "return", "data", "end" ]
Returns the term for a section @param id @param [Hash] opts the optional parameters @return [TermResponse]
[ "Returns", "the", "term", "for", "a", "section" ]
f9f19496c33699c4adfdebfbc7f118e75007b9e2
https://github.com/Clever/clever-ruby/blob/f9f19496c33699c4adfdebfbc7f118e75007b9e2/lib/clever-ruby/api/data_api.rb#L2787-L2790
train
Clever/clever-ruby
lib/clever-ruby/api/events_api.rb
Clever.EventsApi.get_event
def get_event(id, opts = {}) data, _status_code, _headers = get_event_with_http_info(id, opts) return data end
ruby
def get_event(id, opts = {}) data, _status_code, _headers = get_event_with_http_info(id, opts) return data end
[ "def", "get_event", "(", "id", ",", "opts", "=", "{", "}", ")", "data", ",", "_status_code", ",", "_headers", "=", "get_event_with_http_info", "(", "id", ",", "opts", ")", "return", "data", "end" ]
Returns the specific event @param id @param [Hash] opts the optional parameters @return [EventResponse]
[ "Returns", "the", "specific", "event" ]
f9f19496c33699c4adfdebfbc7f118e75007b9e2
https://github.com/Clever/clever-ruby/blob/f9f19496c33699c4adfdebfbc7f118e75007b9e2/lib/clever-ruby/api/events_api.rb#L28-L31
train
arthurnn/apn_sender
lib/apn/client.rb
APN.Client.setup_socket
def setup_socket ctx = setup_certificate APN.log(:debug, "Connecting to #{@host}:#{@port}...") socket_tcp = TCPSocket.new(@host, @port) OpenSSL::SSL::SSLSocket.new(socket_tcp, ctx).tap do |s| s.sync = true s.connect end end
ruby
def setup_socket ctx = setup_certificate APN.log(:debug, "Connecting to #{@host}:#{@port}...") socket_tcp = TCPSocket.new(@host, @port) OpenSSL::SSL::SSLSocket.new(socket_tcp, ctx).tap do |s| s.sync = true s.connect end end
[ "def", "setup_socket", "ctx", "=", "setup_certificate", "APN", ".", "log", "(", ":debug", ",", "\"Connecting to #{@host}:#{@port}...\"", ")", "socket_tcp", "=", "TCPSocket", ".", "new", "(", "@host", ",", "@port", ")", "OpenSSL", "::", "SSL", "::", "SSLSocket", ...
Open socket to Apple's servers
[ "Open", "socket", "to", "Apple", "s", "servers" ]
ecb1539b61fc4022dadb91fc09c1786f476d1c36
https://github.com/arthurnn/apn_sender/blob/ecb1539b61fc4022dadb91fc09c1786f476d1c36/lib/apn/client.rb#L46-L56
train
ruby-numo/numo-linalg
lib/numo/linalg/function.rb
Numo.Linalg.dot
def dot(a, b) a = NArray.asarray(a) b = NArray.asarray(b) case a.ndim when 1 case b.ndim when 1 func = blas_char(a, b) =~ /c|z/ ? :dotu : :dot Blas.call(func, a, b) else if b.contiguous? trans = 't' else if b.fortran_contiguous? ...
ruby
def dot(a, b) a = NArray.asarray(a) b = NArray.asarray(b) case a.ndim when 1 case b.ndim when 1 func = blas_char(a, b) =~ /c|z/ ? :dotu : :dot Blas.call(func, a, b) else if b.contiguous? trans = 't' else if b.fortran_contiguous? ...
[ "def", "dot", "(", "a", ",", "b", ")", "a", "=", "NArray", ".", "asarray", "(", "a", ")", "b", "=", "NArray", ".", "asarray", "(", "b", ")", "case", "a", ".", "ndim", "when", "1", "case", "b", ".", "ndim", "when", "1", "func", "=", "blas_char...
module methods Matrix and vector products Dot product. @param a [Numo::NArray] matrix or vector (>= 1-dimensinal NArray) @param b [Numo::NArray] matrix or vector (>= 1-dimensinal NArray) @return [Numo::NArray] result of dot product
[ "module", "methods", "Matrix", "and", "vector", "products", "Dot", "product", "." ]
bb0929aae0f3285a41d404040eda651833ffccef
https://github.com/ruby-numo/numo-linalg/blob/bb0929aae0f3285a41d404040eda651833ffccef/lib/numo/linalg/function.rb#L82-L146
train
ruby-numo/numo-linalg
lib/numo/linalg/function.rb
Numo.Linalg.matrix_power
def matrix_power(a, n) a = NArray.asarray(a) m,k = a.shape[-2..-1] unless m==k raise NArray::ShapeError, "input must be a square array" end unless Integer===n raise ArgumentError, "exponent must be an integer" end if n == 0 return a.class.eye(m) elsif n < 0 a = in...
ruby
def matrix_power(a, n) a = NArray.asarray(a) m,k = a.shape[-2..-1] unless m==k raise NArray::ShapeError, "input must be a square array" end unless Integer===n raise ArgumentError, "exponent must be an integer" end if n == 0 return a.class.eye(m) elsif n < 0 a = in...
[ "def", "matrix_power", "(", "a", ",", "n", ")", "a", "=", "NArray", ".", "asarray", "(", "a", ")", "m", ",", "k", "=", "a", ".", "shape", "[", "-", "2", "..", "-", "1", "]", "unless", "m", "==", "k", "raise", "NArray", "::", "ShapeError", ","...
Compute a square matrix `a` to the power `n`. * If n > 0: return `a**n`. * If n == 0: return identity matrix. * If n < 0: return `(a*\*-1)*\*n.abs`. @param a [Numo::NArray] square matrix (>= 2-dimensinal NArray). @param n [Integer] the exponent. @example i = Numo::DFloat[[0, 1], [-1, 0]] => Numo::D...
[ "Compute", "a", "square", "matrix", "a", "to", "the", "power", "n", "." ]
bb0929aae0f3285a41d404040eda651833ffccef
https://github.com/ruby-numo/numo-linalg/blob/bb0929aae0f3285a41d404040eda651833ffccef/lib/numo/linalg/function.rb#L198-L233
train
ruby-numo/numo-linalg
lib/numo/linalg/function.rb
Numo.Linalg.svdvals
def svdvals(a, driver:'svd') case driver.to_s when /^(ge)?sdd$/i, "turbo" Lapack.call(:gesdd, a, jobz:'N')[0] when /^(ge)?svd$/i Lapack.call(:gesvd, a, jobu:'N', jobvt:'N')[0] else raise ArgumentError, "invalid driver: #{driver}" end end
ruby
def svdvals(a, driver:'svd') case driver.to_s when /^(ge)?sdd$/i, "turbo" Lapack.call(:gesdd, a, jobz:'N')[0] when /^(ge)?svd$/i Lapack.call(:gesvd, a, jobu:'N', jobvt:'N')[0] else raise ArgumentError, "invalid driver: #{driver}" end end
[ "def", "svdvals", "(", "a", ",", "driver", ":", "'svd'", ")", "case", "driver", ".", "to_s", "when", "/", "/i", ",", "\"turbo\"", "Lapack", ".", "call", "(", ":gesdd", ",", "a", ",", "jobz", ":", "'N'", ")", "[", "0", "]", "when", "/", "/i", "L...
Computes the Singular Values of a M-by-N matrix A. The SVD is written A = U * SIGMA * transpose(V) where SIGMA is an M-by-N matrix which is zero except for its min(m,n) diagonal elements. The diagonal elements of SIGMA are the singular values of A; they are real and non-negative, and are returned in descend...
[ "Computes", "the", "Singular", "Values", "of", "a", "M", "-", "by", "-", "N", "matrix", "A", ".", "The", "SVD", "is", "written" ]
bb0929aae0f3285a41d404040eda651833ffccef
https://github.com/ruby-numo/numo-linalg/blob/bb0929aae0f3285a41d404040eda651833ffccef/lib/numo/linalg/function.rb#L332-L341
train
ruby-numo/numo-linalg
lib/numo/linalg/function.rb
Numo.Linalg.orth
def orth(a, rcond: -1) raise NArray::ShapeError, '2-d array is required' if a.ndim < 2 s, u, = svd(a) tol = s.max * (rcond.nil? || rcond < 0 ? a.class::EPSILON * a.shape.max : rcond) k = (s > tol).count u[true, 0...k] end
ruby
def orth(a, rcond: -1) raise NArray::ShapeError, '2-d array is required' if a.ndim < 2 s, u, = svd(a) tol = s.max * (rcond.nil? || rcond < 0 ? a.class::EPSILON * a.shape.max : rcond) k = (s > tol).count u[true, 0...k] end
[ "def", "orth", "(", "a", ",", "rcond", ":", "-", "1", ")", "raise", "NArray", "::", "ShapeError", ",", "'2-d array is required'", "if", "a", ".", "ndim", "<", "2", "s", ",", "u", ",", "=", "svd", "(", "a", ")", "tol", "=", "s", ".", "max", "*",...
Computes an orthonormal basis for the range of matrix A. @param a [Numo::NArray] m-by-n matrix A (>= 2-dimensional NArray). @param rcond [Float] (optional) rcond is used to determine the effective rank of A. Singular values `s[i] <= rcond * s.max` are treated as zero. If rcond < 0, machine precision is used...
[ "Computes", "an", "orthonormal", "basis", "for", "the", "range", "of", "matrix", "A", "." ]
bb0929aae0f3285a41d404040eda651833ffccef
https://github.com/ruby-numo/numo-linalg/blob/bb0929aae0f3285a41d404040eda651833ffccef/lib/numo/linalg/function.rb#L352-L358
train
ruby-numo/numo-linalg
lib/numo/linalg/function.rb
Numo.Linalg.null_space
def null_space(a, rcond: -1) raise NArray::ShapeError, '2-d array is required' if a.ndim < 2 s, _u, vh = svd(a) tol = s.max * (rcond.nil? || rcond < 0 ? a.class::EPSILON * a.shape.max : rcond) k = (s > tol).count return a.class.new if k == vh.shape[0] r = vh[k..-1, true].transpose.dup blas_c...
ruby
def null_space(a, rcond: -1) raise NArray::ShapeError, '2-d array is required' if a.ndim < 2 s, _u, vh = svd(a) tol = s.max * (rcond.nil? || rcond < 0 ? a.class::EPSILON * a.shape.max : rcond) k = (s > tol).count return a.class.new if k == vh.shape[0] r = vh[k..-1, true].transpose.dup blas_c...
[ "def", "null_space", "(", "a", ",", "rcond", ":", "-", "1", ")", "raise", "NArray", "::", "ShapeError", ",", "'2-d array is required'", "if", "a", ".", "ndim", "<", "2", "s", ",", "_u", ",", "vh", "=", "svd", "(", "a", ")", "tol", "=", "s", ".", ...
Computes an orthonormal basis for the null space of matrix A. @param a [Numo::NArray] m-by-n matrix A (>= 2-dimensional NArray). @param rcond [Float] (optional) rcond is used to determine the effective rank of A. Singular values `s[i] <= rcond * s.max` are treated as zero. If rcond < 0, machine precision is...
[ "Computes", "an", "orthonormal", "basis", "for", "the", "null", "space", "of", "matrix", "A", "." ]
bb0929aae0f3285a41d404040eda651833ffccef
https://github.com/ruby-numo/numo-linalg/blob/bb0929aae0f3285a41d404040eda651833ffccef/lib/numo/linalg/function.rb#L369-L377
train
ruby-numo/numo-linalg
lib/numo/linalg/function.rb
Numo.Linalg.lu
def lu(a, permute_l: false) raise NArray::ShapeError, '2-d array is required' if a.ndim < 2 m, n = a.shape k = [m, n].min lu, ip = lu_fact(a) l = lu.tril.tap { |mat| mat[mat.diag_indices(0)] = 1.0 }[true, 0...k] u = lu.triu[0...k, 0...n] p = Numo::DFloat.eye(m).tap do |mat| ip.to_a...
ruby
def lu(a, permute_l: false) raise NArray::ShapeError, '2-d array is required' if a.ndim < 2 m, n = a.shape k = [m, n].min lu, ip = lu_fact(a) l = lu.tril.tap { |mat| mat[mat.diag_indices(0)] = 1.0 }[true, 0...k] u = lu.triu[0...k, 0...n] p = Numo::DFloat.eye(m).tap do |mat| ip.to_a...
[ "def", "lu", "(", "a", ",", "permute_l", ":", "false", ")", "raise", "NArray", "::", "ShapeError", ",", "'2-d array is required'", "if", "a", ".", "ndim", "<", "2", "m", ",", "n", "=", "a", ".", "shape", "k", "=", "[", "m", ",", "n", "]", ".", ...
Computes an LU factorization of a M-by-N matrix A using partial pivoting with row interchanges. The factorization has the form A = P * L * U where P is a permutation matrix, L is lower triangular with unit diagonal elements (lower trapezoidal if m > n), and U is upper triangular (upper trapezoidal if m < n...
[ "Computes", "an", "LU", "factorization", "of", "a", "M", "-", "by", "-", "N", "matrix", "A", "using", "partial", "pivoting", "with", "row", "interchanges", "." ]
bb0929aae0f3285a41d404040eda651833ffccef
https://github.com/ruby-numo/numo-linalg/blob/bb0929aae0f3285a41d404040eda651833ffccef/lib/numo/linalg/function.rb#L399-L410
train
ruby-numo/numo-linalg
lib/numo/linalg/function.rb
Numo.Linalg.lu_solve
def lu_solve(lu, ipiv, b, trans:"N") Lapack.call(:getrs, lu, ipiv, b, trans:trans)[0] end
ruby
def lu_solve(lu, ipiv, b, trans:"N") Lapack.call(:getrs, lu, ipiv, b, trans:trans)[0] end
[ "def", "lu_solve", "(", "lu", ",", "ipiv", ",", "b", ",", "trans", ":", "\"N\"", ")", "Lapack", ".", "call", "(", ":getrs", ",", "lu", ",", "ipiv", ",", "b", ",", "trans", ":", "trans", ")", "[", "0", "]", "end" ]
Solves a system of linear equations A * X = B or A**T * X = B with a N-by-N matrix A using the LU factorization computed by Numo::Linalg.lu_fact @param lu [Numo::NArray] matrix containing the factors L and U from the factorization `A = P*L*U` as computed by Numo::Linalg.lu_fact. @param ipiv [Numo::N...
[ "Solves", "a", "system", "of", "linear", "equations" ]
bb0929aae0f3285a41d404040eda651833ffccef
https://github.com/ruby-numo/numo-linalg/blob/bb0929aae0f3285a41d404040eda651833ffccef/lib/numo/linalg/function.rb#L476-L478
train
ruby-numo/numo-linalg
lib/numo/linalg/function.rb
Numo.Linalg.eigvals
def eigvals(a) jobvl, jobvr = 'N','N' case blas_char(a) when /c|z/ w, = Lapack.call(:geev, a, jobvl:jobvl, jobvr:jobvr) else wr, wi, = Lapack.call(:geev, a, jobvl:jobvl, jobvr:jobvr) w = wr + wi * Complex::I end w end
ruby
def eigvals(a) jobvl, jobvr = 'N','N' case blas_char(a) when /c|z/ w, = Lapack.call(:geev, a, jobvl:jobvl, jobvr:jobvr) else wr, wi, = Lapack.call(:geev, a, jobvl:jobvl, jobvr:jobvr) w = wr + wi * Complex::I end w end
[ "def", "eigvals", "(", "a", ")", "jobvl", ",", "jobvr", "=", "'N'", ",", "'N'", "case", "blas_char", "(", "a", ")", "when", "/", "/", "w", ",", "=", "Lapack", ".", "call", "(", ":geev", ",", "a", ",", "jobvl", ":", "jobvl", ",", "jobvr", ":", ...
Computes the eigenvalues only for a square nonsymmetric matrix A. @param a [Numo::NArray] square nonsymmetric matrix (>= 2-dimensinal NArray) @return [Numo::NArray] eigenvalues
[ "Computes", "the", "eigenvalues", "only", "for", "a", "square", "nonsymmetric", "matrix", "A", "." ]
bb0929aae0f3285a41d404040eda651833ffccef
https://github.com/ruby-numo/numo-linalg/blob/bb0929aae0f3285a41d404040eda651833ffccef/lib/numo/linalg/function.rb#L682-L692
train
ruby-numo/numo-linalg
lib/numo/linalg/function.rb
Numo.Linalg.cond
def cond(a,ord=nil) if ord.nil? s = svdvals(a) s[false, 0]/s[false, -1] else norm(a, ord, axis:[-2,-1]) * norm(inv(a), ord, axis:[-2,-1]) end end
ruby
def cond(a,ord=nil) if ord.nil? s = svdvals(a) s[false, 0]/s[false, -1] else norm(a, ord, axis:[-2,-1]) * norm(inv(a), ord, axis:[-2,-1]) end end
[ "def", "cond", "(", "a", ",", "ord", "=", "nil", ")", "if", "ord", ".", "nil?", "s", "=", "svdvals", "(", "a", ")", "s", "[", "false", ",", "0", "]", "/", "s", "[", "false", ",", "-", "1", "]", "else", "norm", "(", "a", ",", "ord", ",", ...
Compute the condition number of a matrix using the norm with one of the following order. | ord | matrix norm | | ----- | ---------------------- | | nil | 2-norm using SVD | | 'fro' | Frobenius norm | | 'inf' | x.abs.sum(axis:-1).max | | 1 | x.abs.sum(axis...
[ "Compute", "the", "condition", "number", "of", "a", "matrix", "using", "the", "norm", "with", "one", "of", "the", "following", "order", "." ]
bb0929aae0f3285a41d404040eda651833ffccef
https://github.com/ruby-numo/numo-linalg/blob/bb0929aae0f3285a41d404040eda651833ffccef/lib/numo/linalg/function.rb#L882-L889
train
ruby-numo/numo-linalg
lib/numo/linalg/function.rb
Numo.Linalg.det
def det(a) lu, piv, = Lapack.call(:getrf, a) idx = piv.new_narray.store(piv.class.new(piv.shape[-1]).seq(1)) m = piv.eq(idx).count_false(axis:-1) % 2 sign = m * -2 + 1 lu.diagonal.prod(axis:-1) * sign end
ruby
def det(a) lu, piv, = Lapack.call(:getrf, a) idx = piv.new_narray.store(piv.class.new(piv.shape[-1]).seq(1)) m = piv.eq(idx).count_false(axis:-1) % 2 sign = m * -2 + 1 lu.diagonal.prod(axis:-1) * sign end
[ "def", "det", "(", "a", ")", "lu", ",", "piv", ",", "=", "Lapack", ".", "call", "(", ":getrf", ",", "a", ")", "idx", "=", "piv", ".", "new_narray", ".", "store", "(", "piv", ".", "class", ".", "new", "(", "piv", ".", "shape", "[", "-", "1", ...
Determinant of a matrix @param a [Numo::NArray] matrix (>= 2-dimensional NArray) @return [Float or Complex or Numo::NArray]
[ "Determinant", "of", "a", "matrix" ]
bb0929aae0f3285a41d404040eda651833ffccef
https://github.com/ruby-numo/numo-linalg/blob/bb0929aae0f3285a41d404040eda651833ffccef/lib/numo/linalg/function.rb#L896-L902
train
ruby-numo/numo-linalg
lib/numo/linalg/function.rb
Numo.Linalg.slogdet
def slogdet(a) lu, piv, = Lapack.call(:getrf, a) idx = piv.new_narray.store(piv.class.new(piv.shape[-1]).seq(1)) m = piv.eq(idx).count_false(axis:-1) % 2 sign = m * -2 + 1 lud = lu.diagonal if (lud.eq 0).any? return 0, (-Float::INFINITY) end lud_abs = lud.abs sign *= (lud/lud_...
ruby
def slogdet(a) lu, piv, = Lapack.call(:getrf, a) idx = piv.new_narray.store(piv.class.new(piv.shape[-1]).seq(1)) m = piv.eq(idx).count_false(axis:-1) % 2 sign = m * -2 + 1 lud = lu.diagonal if (lud.eq 0).any? return 0, (-Float::INFINITY) end lud_abs = lud.abs sign *= (lud/lud_...
[ "def", "slogdet", "(", "a", ")", "lu", ",", "piv", ",", "=", "Lapack", ".", "call", "(", ":getrf", ",", "a", ")", "idx", "=", "piv", ".", "new_narray", ".", "store", "(", "piv", ".", "class", ".", "new", "(", "piv", ".", "shape", "[", "-", "1...
Natural logarithm of the determinant of a matrix @param a [Numo::NArray] matrix (>= 2-dimensional NArray) @return [[sign,logdet]] - **sign** -- A number representing the sign of the determinant. - **logdet** -- The natural log of the absolute value of the determinant.
[ "Natural", "logarithm", "of", "the", "determinant", "of", "a", "matrix" ]
bb0929aae0f3285a41d404040eda651833ffccef
https://github.com/ruby-numo/numo-linalg/blob/bb0929aae0f3285a41d404040eda651833ffccef/lib/numo/linalg/function.rb#L911-L924
train
ruby-numo/numo-linalg
lib/numo/linalg/function.rb
Numo.Linalg.inv
def inv(a, driver:"getrf", uplo:'U') case driver when /(ge|sy|he|po)sv$/ d = $1 b = a.new_zeros.eye solve(a, b, driver:d, uplo:uplo) when /(ge|sy|he)tr[fi]$/ d = $1 lu, piv = lu_fact(a) lu_inv(lu, piv) when /potr[fi]$/ lu = cho_fact(a, uplo:uplo) cho_inv(l...
ruby
def inv(a, driver:"getrf", uplo:'U') case driver when /(ge|sy|he|po)sv$/ d = $1 b = a.new_zeros.eye solve(a, b, driver:d, uplo:uplo) when /(ge|sy|he)tr[fi]$/ d = $1 lu, piv = lu_fact(a) lu_inv(lu, piv) when /potr[fi]$/ lu = cho_fact(a, uplo:uplo) cho_inv(l...
[ "def", "inv", "(", "a", ",", "driver", ":", "\"getrf\"", ",", "uplo", ":", "'U'", ")", "case", "driver", "when", "/", "/", "d", "=", "$1", "b", "=", "a", ".", "new_zeros", ".", "eye", "solve", "(", "a", ",", "b", ",", "driver", ":", "d", ",",...
Inverse matrix from square matrix `a` @param a [Numo::NArray] n-by-n square matrix (>= 2-dimensinal NArray) @param driver [String or Symbol] choose LAPACK diriver ('ge'|'sy'|'he'|'po') + ("sv"|"trf") (optional, default='getrf') @param uplo [String or Symbol] optional, default='U'. Access upper or ('U') low...
[ "Inverse", "matrix", "from", "square", "matrix", "a" ]
bb0929aae0f3285a41d404040eda651833ffccef
https://github.com/ruby-numo/numo-linalg/blob/bb0929aae0f3285a41d404040eda651833ffccef/lib/numo/linalg/function.rb#L1000-L1016
train
google/autoparse
lib/autoparse/instance.rb
AutoParse.Instance.valid?
def valid? unvalidated_fields = @data.keys.dup for property_key, schema_class in self.class.properties property_value = @data[property_key] if !self.class.validate_property_value( property_value, schema_class.data) return false end if property_value == n...
ruby
def valid? unvalidated_fields = @data.keys.dup for property_key, schema_class in self.class.properties property_value = @data[property_key] if !self.class.validate_property_value( property_value, schema_class.data) return false end if property_value == n...
[ "def", "valid?", "unvalidated_fields", "=", "@data", ".", "keys", ".", "dup", "for", "property_key", ",", "schema_class", "in", "self", ".", "class", ".", "properties", "property_value", "=", "@data", "[", "property_key", "]", "if", "!", "self", ".", "class"...
Validates the parsed data against the schema.
[ "Validates", "the", "parsed", "data", "against", "the", "schema", "." ]
c710936d68b30840c9feea01f9d89038944b4ec9
https://github.com/google/autoparse/blob/c710936d68b30840c9feea01f9d89038944b4ec9/lib/autoparse/instance.rb#L394-L447
train
zachinglis/crummy
lib/crummy/action_view.rb
Crummy.ViewMethods.render_crumbs
def render_crumbs(options = {}) raise ArgumentError, "Renderer and block given" if options.has_key?(:renderer) && block_given? return yield(crumbs, options) if block_given? @_renderer ||= if options.has_key?(:renderer) options.delete(:renderer) else require 'crummy/standar...
ruby
def render_crumbs(options = {}) raise ArgumentError, "Renderer and block given" if options.has_key?(:renderer) && block_given? return yield(crumbs, options) if block_given? @_renderer ||= if options.has_key?(:renderer) options.delete(:renderer) else require 'crummy/standar...
[ "def", "render_crumbs", "(", "options", "=", "{", "}", ")", "raise", "ArgumentError", ",", "\"Renderer and block given\"", "if", "options", ".", "has_key?", "(", ":renderer", ")", "&&", "block_given?", "return", "yield", "(", "crumbs", ",", "options", ")", "if...
Render the list of crumbs using renderer
[ "Render", "the", "list", "of", "crumbs", "using", "renderer" ]
915b93a3e98f9162170ccbcaa9fba714f60ca870
https://github.com/zachinglis/crummy/blob/915b93a3e98f9162170ccbcaa9fba714f60ca870/lib/crummy/action_view.rb#L15-L27
train
erector/erector
lib/erector/convenience.rb
Erector.Convenience.javascript
def javascript(value = nil, attributes = {}) if value.is_a?(Hash) attributes = value value = nil elsif block_given? && value raise ArgumentError, "You can't pass both a block and a value to javascript -- please choose one." end script(attributes.merge(:type => "text...
ruby
def javascript(value = nil, attributes = {}) if value.is_a?(Hash) attributes = value value = nil elsif block_given? && value raise ArgumentError, "You can't pass both a block and a value to javascript -- please choose one." end script(attributes.merge(:type => "text...
[ "def", "javascript", "(", "value", "=", "nil", ",", "attributes", "=", "{", "}", ")", "if", "value", ".", "is_a?", "(", "Hash", ")", "attributes", "=", "value", "value", "=", "nil", "elsif", "block_given?", "&&", "value", "raise", "ArgumentError", ",", ...
Emits a javascript block inside a +script+ tag, wrapped in CDATA doohickeys like all the cool JS kids do.
[ "Emits", "a", "javascript", "block", "inside", "a", "+", "script", "+", "tag", "wrapped", "in", "CDATA", "doohickeys", "like", "all", "the", "cool", "JS", "kids", "do", "." ]
59754211101b2c50a4c9daa8e64a64e6edc9e976
https://github.com/erector/erector/blob/59754211101b2c50a4c9daa8e64a64e6edc9e976/lib/erector/convenience.rb#L62-L89
train
kolosek/finance_math
lib/finance_math/loan.rb
FinanceMath.Loan.pmt
def pmt(options = {}) future_value = options.fetch(:future_value, 0) type = options.fetch(:type, 0) ((@amount * interest(@monthly_rate, @duration) - future_value ) / ((1.0 + @monthly_rate * type) * fvifa(@monthly_rate, duration))) end
ruby
def pmt(options = {}) future_value = options.fetch(:future_value, 0) type = options.fetch(:type, 0) ((@amount * interest(@monthly_rate, @duration) - future_value ) / ((1.0 + @monthly_rate * type) * fvifa(@monthly_rate, duration))) end
[ "def", "pmt", "(", "options", "=", "{", "}", ")", "future_value", "=", "options", ".", "fetch", "(", ":future_value", ",", "0", ")", "type", "=", "options", ".", "fetch", "(", ":type", ",", "0", ")", "(", "(", "@amount", "*", "interest", "(", "@mon...
create a new Loan instance @return [Loan] @param [Numeric] decimal value of the interest rate @param [Integer] Duration of the loan period @param [Float] Loan amount @param [Float] structure fee - fee for the market in percentages @param [Float] currency protection - Protection for currency changes - usually 3%, ...
[ "create", "a", "new", "Loan", "instance" ]
850f774bb7ac80ceb0d6a17c2f2fb8066ef02dfd
https://github.com/kolosek/finance_math/blob/850f774bb7ac80ceb0d6a17c2f2fb8066ef02dfd/lib/finance_math/loan.rb#L54-L58
train
erector/erector
lib/erector/jquery.rb
Erector.JQuery.jquery
def jquery(*args) event = if args.first.is_a? Symbol args.shift else :ready end txt = args.shift attributes = args.shift || {} javascript attributes do rawtext "\n" rawtext "jQuery(document).#{event}(function($){\n" rawtext txt rawtext...
ruby
def jquery(*args) event = if args.first.is_a? Symbol args.shift else :ready end txt = args.shift attributes = args.shift || {} javascript attributes do rawtext "\n" rawtext "jQuery(document).#{event}(function($){\n" rawtext txt rawtext...
[ "def", "jquery", "(", "*", "args", ")", "event", "=", "if", "args", ".", "first", ".", "is_a?", "Symbol", "args", ".", "shift", "else", ":ready", "end", "txt", "=", "args", ".", "shift", "attributes", "=", "args", ".", "shift", "||", "{", "}", "jav...
Emits a jQuery script, inside its own script tag, that is to be run on document ready or load. Usage (from inside a widget method): jquery "alert('hi')" :: a jquery ready handler jquery "alert('hi')", :id => 'foo' :: a jquery ready handler, with attributes in the script tag jquery :load, "alert('hi')" :: a jquery ...
[ "Emits", "a", "jQuery", "script", "inside", "its", "own", "script", "tag", "that", "is", "to", "be", "run", "on", "document", "ready", "or", "load", "." ]
59754211101b2c50a4c9daa8e64a64e6edc9e976
https://github.com/erector/erector/blob/59754211101b2c50a4c9daa8e64a64e6edc9e976/lib/erector/jquery.rb#L10-L25
train
erector/erector
lib/erector/abstract_widget.rb
Erector.AbstractWidget.capture_content
def capture_content original, @_output = output, Output.new yield original.widgets.concat(output.widgets) # todo: test!!! output.to_s ensure @_output = original end
ruby
def capture_content original, @_output = output, Output.new yield original.widgets.concat(output.widgets) # todo: test!!! output.to_s ensure @_output = original end
[ "def", "capture_content", "original", ",", "@_output", "=", "output", ",", "Output", ".", "new", "yield", "original", ".", "widgets", ".", "concat", "(", "output", ".", "widgets", ")", "output", ".", "to_s", "ensure", "@_output", "=", "original", "end" ]
Creates a whole new output string, executes the block, then converts the output string to a string and returns it as raw text. If at all possible you should avoid this method since it hurts performance, and use +widget+ instead.
[ "Creates", "a", "whole", "new", "output", "string", "executes", "the", "block", "then", "converts", "the", "output", "string", "to", "a", "string", "and", "returns", "it", "as", "raw", "text", ".", "If", "at", "all", "possible", "you", "should", "avoid", ...
59754211101b2c50a4c9daa8e64a64e6edc9e976
https://github.com/erector/erector/blob/59754211101b2c50a4c9daa8e64a64e6edc9e976/lib/erector/abstract_widget.rb#L176-L183
train
erector/erector
lib/erector/abstract_widget.rb
Erector.AbstractWidget._emit_via
def _emit_via(parent, options = {}, &block) _emit(options.merge(:parent => parent, :output => parent.output, :helpers => parent.helpers), &block) end
ruby
def _emit_via(parent, options = {}, &block) _emit(options.merge(:parent => parent, :output => parent.output, :helpers => parent.helpers), &block) end
[ "def", "_emit_via", "(", "parent", ",", "options", "=", "{", "}", ",", "&", "block", ")", "_emit", "(", "options", ".", "merge", "(", ":parent", "=>", "parent", ",", ":output", "=>", "parent", ".", "output", ",", ":helpers", "=>", "parent", ".", "hel...
same as _emit, but using a parent widget's output stream and helpers
[ "same", "as", "_emit", "but", "using", "a", "parent", "widget", "s", "output", "stream", "and", "helpers" ]
59754211101b2c50a4c9daa8e64a64e6edc9e976
https://github.com/erector/erector/blob/59754211101b2c50a4c9daa8e64a64e6edc9e976/lib/erector/abstract_widget.rb#L210-L214
train
erector/erector
lib/erector/rails3.rb
Erector.Rails.render
def render(*args, &block) captured = helpers.capture do helpers.concat(helpers.render(*args, &block)) helpers.output_buffer.to_s end rawtext(captured) end
ruby
def render(*args, &block) captured = helpers.capture do helpers.concat(helpers.render(*args, &block)) helpers.output_buffer.to_s end rawtext(captured) end
[ "def", "render", "(", "*", "args", ",", "&", "block", ")", "captured", "=", "helpers", ".", "capture", "do", "helpers", ".", "concat", "(", "helpers", ".", "render", "(", "*", "args", ",", "&", "block", ")", ")", "helpers", ".", "output_buffer", ".",...
Wrap Rails' render method, to capture output from partials etc.
[ "Wrap", "Rails", "render", "method", "to", "capture", "output", "from", "partials", "etc", "." ]
59754211101b2c50a4c9daa8e64a64e6edc9e976
https://github.com/erector/erector/blob/59754211101b2c50a4c9daa8e64a64e6edc9e976/lib/erector/rails3.rb#L115-L121
train
erector/erector
lib/erector/rails3.rb
Erector.Rails.content_for
def content_for(*args,&block) if block helpers.content_for(*args,&block) else rawtext(helpers.content_for(*args)) '' end end
ruby
def content_for(*args,&block) if block helpers.content_for(*args,&block) else rawtext(helpers.content_for(*args)) '' end end
[ "def", "content_for", "(", "*", "args", ",", "&", "block", ")", "if", "block", "helpers", ".", "content_for", "(", "*", "args", ",", "&", "block", ")", "else", "rawtext", "(", "helpers", ".", "content_for", "(", "*", "args", ")", ")", "''", "end", ...
Rails content_for is output if and only if no block given
[ "Rails", "content_for", "is", "output", "if", "and", "only", "if", "no", "block", "given" ]
59754211101b2c50a4c9daa8e64a64e6edc9e976
https://github.com/erector/erector/blob/59754211101b2c50a4c9daa8e64a64e6edc9e976/lib/erector/rails3.rb#L124-L131
train
erector/erector
lib/erector/text.rb
Erector.Text.character
def character(code_point_or_name) if code_point_or_name.is_a?(Symbol) require "erector/unicode" found = Erector::CHARACTERS[code_point_or_name] if found.nil? raise "Unrecognized character #{code_point_or_name}" end raw("&#x#{sprintf '%x', found};") elsif cod...
ruby
def character(code_point_or_name) if code_point_or_name.is_a?(Symbol) require "erector/unicode" found = Erector::CHARACTERS[code_point_or_name] if found.nil? raise "Unrecognized character #{code_point_or_name}" end raw("&#x#{sprintf '%x', found};") elsif cod...
[ "def", "character", "(", "code_point_or_name", ")", "if", "code_point_or_name", ".", "is_a?", "(", "Symbol", ")", "require", "\"erector/unicode\"", "found", "=", "Erector", "::", "CHARACTERS", "[", "code_point_or_name", "]", "if", "found", ".", "nil?", "raise", ...
Return a character given its unicode code point or unicode name.
[ "Return", "a", "character", "given", "its", "unicode", "code", "point", "or", "unicode", "name", "." ]
59754211101b2c50a4c9daa8e64a64e6edc9e976
https://github.com/erector/erector/blob/59754211101b2c50a4c9daa8e64a64e6edc9e976/lib/erector/text.rb#L107-L120
train
hcatlin/make_resourceful
lib/resourceful/response.rb
Resourceful.Response.method_missing
def method_missing(name, &block) @formats.push([name, block || proc {}]) unless @formats.any? {|n,b| n == name} end
ruby
def method_missing(name, &block) @formats.push([name, block || proc {}]) unless @formats.any? {|n,b| n == name} end
[ "def", "method_missing", "(", "name", ",", "&", "block", ")", "@formats", ".", "push", "(", "[", "name", ",", "block", "||", "proc", "{", "}", "]", ")", "unless", "@formats", ".", "any?", "{", "|", "n", ",", "b", "|", "n", "==", "name", "}", "e...
Returns a new Response with no format data. Used to dispatch the individual format methods.
[ "Returns", "a", "new", "Response", "with", "no", "format", "data", ".", "Used", "to", "dispatch", "the", "individual", "format", "methods", "." ]
138455b3650917ffdf31dfee4ef9d4aff3f47b06
https://github.com/hcatlin/make_resourceful/blob/138455b3650917ffdf31dfee4ef9d4aff3f47b06/lib/resourceful/response.rb#L29-L31
train
raw1z/amistad
lib/amistad/active_record_friendship_model.rb
Amistad.ActiveRecordFriendshipModel.can_block?
def can_block?(friendable) active? && (approved? || (pending? && self.friend_id == friendable.id && friendable.class.to_s == Amistad.friend_model)) end
ruby
def can_block?(friendable) active? && (approved? || (pending? && self.friend_id == friendable.id && friendable.class.to_s == Amistad.friend_model)) end
[ "def", "can_block?", "(", "friendable", ")", "active?", "&&", "(", "approved?", "||", "(", "pending?", "&&", "self", ".", "friend_id", "==", "friendable", ".", "id", "&&", "friendable", ".", "class", ".", "to_s", "==", "Amistad", ".", "friend_model", ")", ...
returns true if a friendship can be blocked by given friendable
[ "returns", "true", "if", "a", "friendship", "can", "be", "blocked", "by", "given", "friendable" ]
3da822509611450e4777f6571ea0967fd5bf6602
https://github.com/raw1z/amistad/blob/3da822509611450e4777f6571ea0967fd5bf6602/lib/amistad/active_record_friendship_model.rb#L43-L45
train
raw1z/amistad
lib/amistad/active_record_friendship_model.rb
Amistad.ActiveRecordFriendshipModel.can_unblock?
def can_unblock?(friendable) blocked? && self.blocker_id == friendable.id && friendable.class.to_s == Amistad.friend_model end
ruby
def can_unblock?(friendable) blocked? && self.blocker_id == friendable.id && friendable.class.to_s == Amistad.friend_model end
[ "def", "can_unblock?", "(", "friendable", ")", "blocked?", "&&", "self", ".", "blocker_id", "==", "friendable", ".", "id", "&&", "friendable", ".", "class", ".", "to_s", "==", "Amistad", ".", "friend_model", "end" ]
returns true if a friendship can be unblocked by given friendable
[ "returns", "true", "if", "a", "friendship", "can", "be", "unblocked", "by", "given", "friendable" ]
3da822509611450e4777f6571ea0967fd5bf6602
https://github.com/raw1z/amistad/blob/3da822509611450e4777f6571ea0967fd5bf6602/lib/amistad/active_record_friendship_model.rb#L48-L50
train
rktjmp/tileup
lib/tileup/logger.rb
TileUp.TileUpLogger.add
def add(severity, message) severity = TileUpLogger.sym_to_severity(severity) logger.add(severity, message) end
ruby
def add(severity, message) severity = TileUpLogger.sym_to_severity(severity) logger.add(severity, message) end
[ "def", "add", "(", "severity", ",", "message", ")", "severity", "=", "TileUpLogger", ".", "sym_to_severity", "(", "severity", ")", "logger", ".", "add", "(", "severity", ",", "message", ")", "end" ]
add message to log
[ "add", "message", "to", "log" ]
5002151f8603ea5d4af76892081af85d9deff9fb
https://github.com/rktjmp/tileup/blob/5002151f8603ea5d4af76892081af85d9deff9fb/lib/tileup/logger.rb#L62-L65
train
cloudfoundry-community/bosh-gen
lib/bosh/gen/bosh-config.rb
Bosh::Cli.Config.deployment
def deployment return nil if target.nil? if @config_file.has_key?("deployment") if is_old_deployment_config? set_deployment(@config_file["deployment"]) save end if @config_file["deployment"].is_a?(Hash) return @config_file["deployment"][target] e...
ruby
def deployment return nil if target.nil? if @config_file.has_key?("deployment") if is_old_deployment_config? set_deployment(@config_file["deployment"]) save end if @config_file["deployment"].is_a?(Hash) return @config_file["deployment"][target] e...
[ "def", "deployment", "return", "nil", "if", "target", ".", "nil?", "if", "@config_file", ".", "has_key?", "(", "\"deployment\"", ")", "if", "is_old_deployment_config?", "set_deployment", "(", "@config_file", "[", "\"deployment\"", "]", ")", "save", "end", "if", ...
Read the deployment configuration. Return the deployment for the current target. @return [String?] The deployment path for the current target.
[ "Read", "the", "deployment", "configuration", ".", "Return", "the", "deployment", "for", "the", "current", "target", "." ]
73022585f762fa75f021bfd35b2e3f9096c99c74
https://github.com/cloudfoundry-community/bosh-gen/blob/73022585f762fa75f021bfd35b2e3f9096c99c74/lib/bosh/gen/bosh-config.rb#L151-L162
train
hcatlin/make_resourceful
lib/resourceful/builder.rb
Resourceful.Builder.apply
def apply apply_publish kontroller = @controller Resourceful::ACTIONS.each do |action_named| # See if this is a method listed by #actions unless @ok_actions.include? action_named # If its not listed, then remove the method # No one can hit it... if its DEAD!...
ruby
def apply apply_publish kontroller = @controller Resourceful::ACTIONS.each do |action_named| # See if this is a method listed by #actions unless @ok_actions.include? action_named # If its not listed, then remove the method # No one can hit it... if its DEAD!...
[ "def", "apply", "apply_publish", "kontroller", "=", "@controller", "Resourceful", "::", "ACTIONS", ".", "each", "do", "|", "action_named", "|", "unless", "@ok_actions", ".", "include?", "action_named", "@action_module", ".", "send", ":remove_method", ",", "action_na...
The constructor is only meant to be called internally. This takes the klass (class object) of a controller and constructs a Builder ready to apply the make_resourceful additions to the controller. This method is only meant to be called internally. Applies all the changes that have been declared via the instance...
[ "The", "constructor", "is", "only", "meant", "to", "be", "called", "internally", "." ]
138455b3650917ffdf31dfee4ef9d4aff3f47b06
https://github.com/hcatlin/make_resourceful/blob/138455b3650917ffdf31dfee4ef9d4aff3f47b06/lib/resourceful/builder.rb#L40-L70
train
hcatlin/make_resourceful
lib/resourceful/builder.rb
Resourceful.Builder.belongs_to
def belongs_to(*parents) options = parents.extract_options! @parents = parents.map(&:to_s) if options[:shallow] options[:shallow] = options[:shallow].to_s raise ArgumentError, ":shallow needs the name of a parent resource" unless @parents.include? options[:shallow] @shallow_par...
ruby
def belongs_to(*parents) options = parents.extract_options! @parents = parents.map(&:to_s) if options[:shallow] options[:shallow] = options[:shallow].to_s raise ArgumentError, ":shallow needs the name of a parent resource" unless @parents.include? options[:shallow] @shallow_par...
[ "def", "belongs_to", "(", "*", "parents", ")", "options", "=", "parents", ".", "extract_options!", "@parents", "=", "parents", ".", "map", "(", "&", ":to_s", ")", "if", "options", "[", ":shallow", "]", "options", "[", ":shallow", "]", "=", "options", "["...
Specifies parent resources for the current resource. Each of these parents will be loaded automatically if the proper id parameter is given. For example, # cake_controller.rb belongs_to :baker, :customer Then on GET /bakers/12/cakes, params[:baker_id] #=> 12 parent? #=> true parent_name ...
[ "Specifies", "parent", "resources", "for", "the", "current", "resource", ".", "Each", "of", "these", "parents", "will", "be", "loaded", "automatically", "if", "the", "proper", "id", "parameter", "is", "given", ".", "For", "example" ]
138455b3650917ffdf31dfee4ef9d4aff3f47b06
https://github.com/hcatlin/make_resourceful/blob/138455b3650917ffdf31dfee4ef9d4aff3f47b06/lib/resourceful/builder.rb#L364-L372
train
raw1z/amistad
lib/amistad/mongo_friend_model.rb
Amistad.MongoFriendModel.blocked?
def blocked?(user) (blocked_friend_ids + blocked_inverse_friend_ids + blocked_pending_inverse_friend_ids).include?(user.id) or user.blocked_pending_inverse_friend_ids.include?(self.id) end
ruby
def blocked?(user) (blocked_friend_ids + blocked_inverse_friend_ids + blocked_pending_inverse_friend_ids).include?(user.id) or user.blocked_pending_inverse_friend_ids.include?(self.id) end
[ "def", "blocked?", "(", "user", ")", "(", "blocked_friend_ids", "+", "blocked_inverse_friend_ids", "+", "blocked_pending_inverse_friend_ids", ")", ".", "include?", "(", "user", ".", "id", ")", "or", "user", ".", "blocked_pending_inverse_friend_ids", ".", "include?", ...
checks if a user is blocked
[ "checks", "if", "a", "user", "is", "blocked" ]
3da822509611450e4777f6571ea0967fd5bf6602
https://github.com/raw1z/amistad/blob/3da822509611450e4777f6571ea0967fd5bf6602/lib/amistad/mongo_friend_model.rb#L146-L148
train
raw1z/amistad
lib/amistad/mongo_friend_model.rb
Amistad.MongoFriendModel.friendshiped_with?
def friendshiped_with?(user) (friend_ids + inverse_friend_ids + pending_friend_ids + pending_inverse_friend_ids + blocked_friend_ids).include?(user.id) end
ruby
def friendshiped_with?(user) (friend_ids + inverse_friend_ids + pending_friend_ids + pending_inverse_friend_ids + blocked_friend_ids).include?(user.id) end
[ "def", "friendshiped_with?", "(", "user", ")", "(", "friend_ids", "+", "inverse_friend_ids", "+", "pending_friend_ids", "+", "pending_inverse_friend_ids", "+", "blocked_friend_ids", ")", ".", "include?", "(", "user", ".", "id", ")", "end" ]
check if any friendship exists with another user
[ "check", "if", "any", "friendship", "exists", "with", "another", "user" ]
3da822509611450e4777f6571ea0967fd5bf6602
https://github.com/raw1z/amistad/blob/3da822509611450e4777f6571ea0967fd5bf6602/lib/amistad/mongo_friend_model.rb#L151-L153
train
raw1z/amistad
lib/amistad/mongo_friend_model.rb
Amistad.MongoFriendModel.delete_all_friendships
def delete_all_friendships friend_ids.clear inverse_friend_ids.clear pending_friend_ids.clear pending_inverse_friend_ids.clear blocked_friend_ids.clear blocked_inverse_friend_ids.clear blocked_pending_friend_ids.clear blocked_pending_inverse_friend_ids.clear self.sa...
ruby
def delete_all_friendships friend_ids.clear inverse_friend_ids.clear pending_friend_ids.clear pending_inverse_friend_ids.clear blocked_friend_ids.clear blocked_inverse_friend_ids.clear blocked_pending_friend_ids.clear blocked_pending_inverse_friend_ids.clear self.sa...
[ "def", "delete_all_friendships", "friend_ids", ".", "clear", "inverse_friend_ids", ".", "clear", "pending_friend_ids", ".", "clear", "pending_inverse_friend_ids", ".", "clear", "blocked_friend_ids", ".", "clear", "blocked_inverse_friend_ids", ".", "clear", "blocked_pending_fr...
deletes all the friendships
[ "deletes", "all", "the", "friendships" ]
3da822509611450e4777f6571ea0967fd5bf6602
https://github.com/raw1z/amistad/blob/3da822509611450e4777f6571ea0967fd5bf6602/lib/amistad/mongo_friend_model.rb#L156-L166
train
hcatlin/make_resourceful
spec/spec_helper.rb
RailsMocks.ControllerMethods.render
def render(options=nil, deprecated_status_or_extra_options=nil, &block) if ::Rails::VERSION::STRING >= '2.0.0' && deprecated_status_or_extra_options.nil? deprecated_status_or_extra_options = {} end unless block_given? if @template.respond_to?(:finder) (class << @template.fin...
ruby
def render(options=nil, deprecated_status_or_extra_options=nil, &block) if ::Rails::VERSION::STRING >= '2.0.0' && deprecated_status_or_extra_options.nil? deprecated_status_or_extra_options = {} end unless block_given? if @template.respond_to?(:finder) (class << @template.fin...
[ "def", "render", "(", "options", "=", "nil", ",", "deprecated_status_or_extra_options", "=", "nil", ",", "&", "block", ")", "if", "::", "Rails", "::", "VERSION", "::", "STRING", ">=", "'2.0.0'", "&&", "deprecated_status_or_extra_options", ".", "nil?", "deprecate...
From rspec-rails ControllerExampleGroup
[ "From", "rspec", "-", "rails", "ControllerExampleGroup" ]
138455b3650917ffdf31dfee4ef9d4aff3f47b06
https://github.com/hcatlin/make_resourceful/blob/138455b3650917ffdf31dfee4ef9d4aff3f47b06/spec/spec_helper.rb#L227-L256
train
raw1z/amistad
lib/amistad/active_record_friend_model.rb
Amistad.ActiveRecordFriendModel.unblock
def unblock(user) friendship = find_any_friendship_with(user) return false if friendship.nil? || !friendship.can_unblock?(self) friendship.update_attribute(:blocker, nil) end
ruby
def unblock(user) friendship = find_any_friendship_with(user) return false if friendship.nil? || !friendship.can_unblock?(self) friendship.update_attribute(:blocker, nil) end
[ "def", "unblock", "(", "user", ")", "friendship", "=", "find_any_friendship_with", "(", "user", ")", "return", "false", "if", "friendship", ".", "nil?", "||", "!", "friendship", ".", "can_unblock?", "(", "self", ")", "friendship", ".", "update_attribute", "(",...
unblocks a friendship
[ "unblocks", "a", "friendship" ]
3da822509611450e4777f6571ea0967fd5bf6602
https://github.com/raw1z/amistad/blob/3da822509611450e4777f6571ea0967fd5bf6602/lib/amistad/active_record_friend_model.rb#L84-L88
train
raw1z/amistad
lib/amistad/active_record_friend_model.rb
Amistad.ActiveRecordFriendModel.find_any_friendship_with
def find_any_friendship_with(user) friendship = Amistad.friendship_class.where(:friendable_id => self.id, :friend_id => user.id).first if friendship.nil? friendship = Amistad.friendship_class.where(:friendable_id => user.id, :friend_id => self.id).first end friendship end
ruby
def find_any_friendship_with(user) friendship = Amistad.friendship_class.where(:friendable_id => self.id, :friend_id => user.id).first if friendship.nil? friendship = Amistad.friendship_class.where(:friendable_id => user.id, :friend_id => self.id).first end friendship end
[ "def", "find_any_friendship_with", "(", "user", ")", "friendship", "=", "Amistad", ".", "friendship_class", ".", "where", "(", ":friendable_id", "=>", "self", ".", "id", ",", ":friend_id", "=>", "user", ".", "id", ")", ".", "first", "if", "friendship", ".", ...
returns friendship with given user or nil
[ "returns", "friendship", "with", "given", "user", "or", "nil" ]
3da822509611450e4777f6571ea0967fd5bf6602
https://github.com/raw1z/amistad/blob/3da822509611450e4777f6571ea0967fd5bf6602/lib/amistad/active_record_friend_model.rb#L136-L142
train
Swirrl/tripod
lib/tripod/extensions/module.rb
Tripod::Extensions.Module.re_define_method
def re_define_method(name, &block) undef_method(name) if method_defined?(name) define_method(name, &block) end
ruby
def re_define_method(name, &block) undef_method(name) if method_defined?(name) define_method(name, &block) end
[ "def", "re_define_method", "(", "name", ",", "&", "block", ")", "undef_method", "(", "name", ")", "if", "method_defined?", "(", "name", ")", "define_method", "(", "name", ",", "&", "block", ")", "end" ]
Redefine the method. Will undef the method if it exists or simply just define it. @example Redefine the method. Object.re_define_method("exists?") do self end @param [ String, Symbol ] name The name of the method. @param [ Proc ] block The method body. @return [ Method ] The new method.
[ "Redefine", "the", "method", ".", "Will", "undef", "the", "method", "if", "it", "exists", "or", "simply", "just", "define", "it", "." ]
00bb42c67b68e5c6843b9883cd5c69a318f3b72b
https://github.com/Swirrl/tripod/blob/00bb42c67b68e5c6843b9883cd5c69a318f3b72b/lib/tripod/extensions/module.rb#L17-L20
train
Swirrl/tripod
lib/tripod/rdf_type.rb
Tripod::RdfType.ClassMethods.rdf_type
def rdf_type(new_rdf_type) self._RDF_TYPE = RDF::URI.new(new_rdf_type.to_s) field :rdf_type, RDF.type, :multivalued => true, :is_uri => true # things can have more than 1 type and often do end
ruby
def rdf_type(new_rdf_type) self._RDF_TYPE = RDF::URI.new(new_rdf_type.to_s) field :rdf_type, RDF.type, :multivalued => true, :is_uri => true # things can have more than 1 type and often do end
[ "def", "rdf_type", "(", "new_rdf_type", ")", "self", ".", "_RDF_TYPE", "=", "RDF", "::", "URI", ".", "new", "(", "new_rdf_type", ".", "to_s", ")", "field", ":rdf_type", ",", "RDF", ".", "type", ",", ":multivalued", "=>", "true", ",", ":is_uri", "=>", "...
makes a "field" on this model called rdf_type and sets a class level _RDF_TYPE variable with the rdf_type passed in.
[ "makes", "a", "field", "on", "this", "model", "called", "rdf_type", "and", "sets", "a", "class", "level", "_RDF_TYPE", "variable", "with", "the", "rdf_type", "passed", "in", "." ]
00bb42c67b68e5c6843b9883cd5c69a318f3b72b
https://github.com/Swirrl/tripod/blob/00bb42c67b68e5c6843b9883cd5c69a318f3b72b/lib/tripod/rdf_type.rb#L16-L19
train
xi-livecode/xi
lib/xi/pattern.rb
Xi.Pattern.p
def p(*delta, **metadata) delta = delta.compact.empty? ? @delta : delta Pattern.new(@source, delta: delta, size: @size, **@metadata.merge(metadata)) end
ruby
def p(*delta, **metadata) delta = delta.compact.empty? ? @delta : delta Pattern.new(@source, delta: delta, size: @size, **@metadata.merge(metadata)) end
[ "def", "p", "(", "*", "delta", ",", "**", "metadata", ")", "delta", "=", "delta", ".", "compact", ".", "empty?", "?", "@delta", ":", "delta", "Pattern", ".", "new", "(", "@source", ",", "delta", ":", "delta", ",", "size", ":", "@size", ",", "**", ...
Returns a new Pattern with the same +source+, but with +delta+ overriden and +metadata+ merged. @param delta [Array<Numeric>, Pattern<Numeric>, Numeric] @param metadata [Hash] @return [Pattern]
[ "Returns", "a", "new", "Pattern", "with", "the", "same", "+", "source", "+", "but", "with", "+", "delta", "+", "overriden", "and", "+", "metadata", "+", "merged", "." ]
215dfb84899b3dd00f11089ae3eab0febf498e95
https://github.com/xi-livecode/xi/blob/215dfb84899b3dd00f11089ae3eab0febf498e95/lib/xi/pattern.rb#L131-L134
train
xi-livecode/xi
lib/xi/pattern.rb
Xi.Pattern.each_event
def each_event(cycle=0) return enum_for(__method__, cycle) unless block_given? EventEnumerator.new(self, cycle).each { |v, s, d, i| yield v, s, d, i } end
ruby
def each_event(cycle=0) return enum_for(__method__, cycle) unless block_given? EventEnumerator.new(self, cycle).each { |v, s, d, i| yield v, s, d, i } end
[ "def", "each_event", "(", "cycle", "=", "0", ")", "return", "enum_for", "(", "__method__", ",", "cycle", ")", "unless", "block_given?", "EventEnumerator", ".", "new", "(", "self", ",", "cycle", ")", ".", "each", "{", "|", "v", ",", "s", ",", "d", ","...
Calls the given block once for each event, passing its value, start position, duration and iteration as parameters. +cycle+ can be any number, even if there is no event that starts exactly at that moment. It will start from the next event. If no block is given, an enumerator is returned instead. Enumeration lo...
[ "Calls", "the", "given", "block", "once", "for", "each", "event", "passing", "its", "value", "start", "position", "duration", "and", "iteration", "as", "parameters", "." ]
215dfb84899b3dd00f11089ae3eab0febf498e95
https://github.com/xi-livecode/xi/blob/215dfb84899b3dd00f11089ae3eab0febf498e95/lib/xi/pattern.rb#L194-L197
train
xi-livecode/xi
lib/xi/pattern.rb
Xi.Pattern.each_delta
def each_delta(index=0) return enum_for(__method__, index) unless block_given? delta = @delta if delta.is_a?(Array) size = delta.size return if size == 0 start = index.floor i = start % size loop do yield delta[i] i = (i + 1) % size ...
ruby
def each_delta(index=0) return enum_for(__method__, index) unless block_given? delta = @delta if delta.is_a?(Array) size = delta.size return if size == 0 start = index.floor i = start % size loop do yield delta[i] i = (i + 1) % size ...
[ "def", "each_delta", "(", "index", "=", "0", ")", "return", "enum_for", "(", "__method__", ",", "index", ")", "unless", "block_given?", "delta", "=", "@delta", "if", "delta", ".", "is_a?", "(", "Array", ")", "size", "=", "delta", ".", "size", "return", ...
Calls the given block passing the delta of each value in pattern This method is used internally by {#each_event} to calculate when each event in pattern occurs in time. If no block is given, an Enumerator is returned instead. @param index [Numeric] @yield [d] duration @return [Enumerator]
[ "Calls", "the", "given", "block", "passing", "the", "delta", "of", "each", "value", "in", "pattern" ]
215dfb84899b3dd00f11089ae3eab0febf498e95
https://github.com/xi-livecode/xi/blob/215dfb84899b3dd00f11089ae3eab0febf498e95/lib/xi/pattern.rb#L209-L230
train
xi-livecode/xi
lib/xi/pattern.rb
Xi.Pattern.each
def each return enum_for(__method__) unless block_given? each_event { |v, _, _, i| break if i > 0 yield v } end
ruby
def each return enum_for(__method__) unless block_given? each_event { |v, _, _, i| break if i > 0 yield v } end
[ "def", "each", "return", "enum_for", "(", "__method__", ")", "unless", "block_given?", "each_event", "{", "|", "v", ",", "_", ",", "_", ",", "i", "|", "break", "if", "i", ">", "0", "yield", "v", "}", "end" ]
Calls the given block once for each value in source @example Pattern.new([1, 2, 3]).each.to_a # => [1, 2, 3] @return [Enumerator] @yield [Object] value
[ "Calls", "the", "given", "block", "once", "for", "each", "value", "in", "source" ]
215dfb84899b3dd00f11089ae3eab0febf498e95
https://github.com/xi-livecode/xi/blob/215dfb84899b3dd00f11089ae3eab0febf498e95/lib/xi/pattern.rb#L241-L248
train
xi-livecode/xi
lib/xi/pattern.rb
Xi.Pattern.select
def select return enum_for(__method__) unless block_given? Pattern.new(self) do |y, d| each_event do |v, s, ed, i| y << v if yield(v, s, ed, i) end end end
ruby
def select return enum_for(__method__) unless block_given? Pattern.new(self) do |y, d| each_event do |v, s, ed, i| y << v if yield(v, s, ed, i) end end end
[ "def", "select", "return", "enum_for", "(", "__method__", ")", "unless", "block_given?", "Pattern", ".", "new", "(", "self", ")", "do", "|", "y", ",", "d", "|", "each_event", "do", "|", "v", ",", "s", ",", "ed", ",", "i", "|", "y", "<<", "v", "if...
Returns a Pattern containing all events of +self+ for which +block+ is true. If no block is given, an Enumerator is returned. @see Pattern#reject @yield [v, s, d, i] value, start, duration and iteration @yieldreturn [Boolean] whether value is selected @return [Pattern]
[ "Returns", "a", "Pattern", "containing", "all", "events", "of", "+", "self", "+", "for", "which", "+", "block", "+", "is", "true", "." ]
215dfb84899b3dd00f11089ae3eab0febf498e95
https://github.com/xi-livecode/xi/blob/215dfb84899b3dd00f11089ae3eab0febf498e95/lib/xi/pattern.rb#L318-L326
train
xi-livecode/xi
lib/xi/pattern.rb
Xi.Pattern.reject
def reject return enum_for(__method__) unless block_given? select { |v, s, d, i| !yield(v, s, d, i) } end
ruby
def reject return enum_for(__method__) unless block_given? select { |v, s, d, i| !yield(v, s, d, i) } end
[ "def", "reject", "return", "enum_for", "(", "__method__", ")", "unless", "block_given?", "select", "{", "|", "v", ",", "s", ",", "d", ",", "i", "|", "!", "yield", "(", "v", ",", "s", ",", "d", ",", "i", ")", "}", "end" ]
Returns a Pattern containing all events of +self+ for which +block+ is false. If no block is given, an Enumerator is returned. @see Pattern#select @yield [v, s, d, i] value, start, duration and iteration @yieldreturn [Boolean] whether event is rejected @return [Pattern]
[ "Returns", "a", "Pattern", "containing", "all", "events", "of", "+", "self", "+", "for", "which", "+", "block", "+", "is", "false", "." ]
215dfb84899b3dd00f11089ae3eab0febf498e95
https://github.com/xi-livecode/xi/blob/215dfb84899b3dd00f11089ae3eab0febf498e95/lib/xi/pattern.rb#L340-L344
train
xi-livecode/xi
lib/xi/pattern.rb
Xi.Pattern.first
def first(n=nil, *args) res = take(n || 1, *args) n.nil? ? res.first : res end
ruby
def first(n=nil, *args) res = take(n || 1, *args) n.nil? ? res.first : res end
[ "def", "first", "(", "n", "=", "nil", ",", "*", "args", ")", "res", "=", "take", "(", "n", "||", "1", ",", "*", "args", ")", "n", ".", "nil?", "?", "res", ".", "first", ":", "res", "end" ]
Returns the first element, or the first +n+ elements, of the pattern. If the pattern is empty, the first form returns nil, and the second form returns an empty array. @see #take @param n [Integer] @param args same arguments as {#take} @return [Object, Array]
[ "Returns", "the", "first", "element", "or", "the", "first", "+", "n", "+", "elements", "of", "the", "pattern", "." ]
215dfb84899b3dd00f11089ae3eab0febf498e95
https://github.com/xi-livecode/xi/blob/215dfb84899b3dd00f11089ae3eab0febf498e95/lib/xi/pattern.rb#L387-L390
train
xi-livecode/xi
lib/xi/pattern.rb
Xi.Pattern.inspect
def inspect ss = if @source.respond_to?(:join) @source.map(&:inspect).join(', ') elsif @source.is_a?(Proc) "?proc" else @source.inspect end ms = @metadata.reject { |_, v| v.nil? } ms.merge!(delta: delta) if delta != 1 ms = ...
ruby
def inspect ss = if @source.respond_to?(:join) @source.map(&:inspect).join(', ') elsif @source.is_a?(Proc) "?proc" else @source.inspect end ms = @metadata.reject { |_, v| v.nil? } ms.merge!(delta: delta) if delta != 1 ms = ...
[ "def", "inspect", "ss", "=", "if", "@source", ".", "respond_to?", "(", ":join", ")", "@source", ".", "map", "(", "&", ":inspect", ")", ".", "join", "(", "', '", ")", "elsif", "@source", ".", "is_a?", "(", "Proc", ")", "\"?proc\"", "else", "@source", ...
Returns a string containing a human-readable representation When source is not a Proc, this string can be evaluated to construct the same instance. @return [String]
[ "Returns", "a", "string", "containing", "a", "human", "-", "readable", "representation" ]
215dfb84899b3dd00f11089ae3eab0febf498e95
https://github.com/xi-livecode/xi/blob/215dfb84899b3dd00f11089ae3eab0febf498e95/lib/xi/pattern.rb#L399-L413
train
Swirrl/tripod
lib/tripod/fields.rb
Tripod::Fields.ClassMethods.get_field
def get_field(name) @fields ||= {} field = fields[name] raise Tripod::Errors::FieldNotPresent.new unless field field end
ruby
def get_field(name) @fields ||= {} field = fields[name] raise Tripod::Errors::FieldNotPresent.new unless field field end
[ "def", "get_field", "(", "name", ")", "@fields", "||=", "{", "}", "field", "=", "fields", "[", "name", "]", "raise", "Tripod", "::", "Errors", "::", "FieldNotPresent", ".", "new", "unless", "field", "field", "end" ]
Return the field object on a +Resource+ associated with the given name. @example Get the field. Person.get_field(:name) @param [ Symbol ] name The name of the field.
[ "Return", "the", "field", "object", "on", "a", "+", "Resource", "+", "associated", "with", "the", "given", "name", "." ]
00bb42c67b68e5c6843b9883cd5c69a318f3b72b
https://github.com/Swirrl/tripod/blob/00bb42c67b68e5c6843b9883cd5c69a318f3b72b/lib/tripod/fields.rb#L56-L61
train
Swirrl/tripod
lib/tripod/fields.rb
Tripod::Fields.ClassMethods.fields
def fields tripod_superclasses.map { |c| c.instance_variable_get(:@fields) }.reduce do |acc,class_fields| class_fields.merge(acc) end end
ruby
def fields tripod_superclasses.map { |c| c.instance_variable_get(:@fields) }.reduce do |acc,class_fields| class_fields.merge(acc) end end
[ "def", "fields", "tripod_superclasses", ".", "map", "{", "|", "c", "|", "c", ".", "instance_variable_get", "(", ":@fields", ")", "}", ".", "reduce", "do", "|", "acc", ",", "class_fields", "|", "class_fields", ".", "merge", "(", "acc", ")", "end", "end" ]
Return all of the fields on a +Resource+ in a manner that respects Ruby's inheritance rules. i.e. subclass fields should override superclass fields with the same
[ "Return", "all", "of", "the", "fields", "on", "a", "+", "Resource", "+", "in", "a", "manner", "that", "respects", "Ruby", "s", "inheritance", "rules", ".", "i", ".", "e", ".", "subclass", "fields", "should", "override", "superclass", "fields", "with", "t...
00bb42c67b68e5c6843b9883cd5c69a318f3b72b
https://github.com/Swirrl/tripod/blob/00bb42c67b68e5c6843b9883cd5c69a318f3b72b/lib/tripod/fields.rb#L66-L70
train
Swirrl/tripod
lib/tripod/fields.rb
Tripod::Fields.ClassMethods.add_field
def add_field(name, predicate, options = {}) # create a field object and store it in our hash field = field_for(name, predicate, options) @fields ||= {} @fields[name] = field # set up the accessors for the fields create_accessors(name, name, options) # create a URL validation...
ruby
def add_field(name, predicate, options = {}) # create a field object and store it in our hash field = field_for(name, predicate, options) @fields ||= {} @fields[name] = field # set up the accessors for the fields create_accessors(name, name, options) # create a URL validation...
[ "def", "add_field", "(", "name", ",", "predicate", ",", "options", "=", "{", "}", ")", "field", "=", "field_for", "(", "name", ",", "predicate", ",", "options", ")", "@fields", "||=", "{", "}", "@fields", "[", "name", "]", "=", "field", "create_accesso...
Define a field attribute for the +Resource+. @example Set the field. Person.add_field(:name, 'http://myfield') @param [ Symbol ] name The name of the field. @param [ String, RDF::URI ] predicate The predicate for the field. @param [ Hash ] options The hash of options.
[ "Define", "a", "field", "attribute", "for", "the", "+", "Resource", "+", "." ]
00bb42c67b68e5c6843b9883cd5c69a318f3b72b
https://github.com/Swirrl/tripod/blob/00bb42c67b68e5c6843b9883cd5c69a318f3b72b/lib/tripod/fields.rb#L86-L100
train
Swirrl/tripod
lib/tripod/fields.rb
Tripod::Fields.ClassMethods.create_accessors
def create_accessors(name, meth, options = {}) field = @fields[name] create_field_getter(name, meth, field) create_field_setter(name, meth, field) create_field_check(name, meth, field) # from dirty.rb create_dirty_methods(name, meth) end
ruby
def create_accessors(name, meth, options = {}) field = @fields[name] create_field_getter(name, meth, field) create_field_setter(name, meth, field) create_field_check(name, meth, field) # from dirty.rb create_dirty_methods(name, meth) end
[ "def", "create_accessors", "(", "name", ",", "meth", ",", "options", "=", "{", "}", ")", "field", "=", "@fields", "[", "name", "]", "create_field_getter", "(", "name", ",", "meth", ",", "field", ")", "create_field_setter", "(", "name", ",", "meth", ",", ...
Create the field accessors. @example Generate the accessors. Person.create_accessors(:name, "name") person.name #=> returns the field person.name = "" #=> sets the field person.name? #=> Is the field present? @param [ Symbol ] name The name of the field. @param [ Symbol ] meth The name of the accessor....
[ "Create", "the", "field", "accessors", "." ]
00bb42c67b68e5c6843b9883cd5c69a318f3b72b
https://github.com/Swirrl/tripod/blob/00bb42c67b68e5c6843b9883cd5c69a318f3b72b/lib/tripod/fields.rb#L113-L122
train
Swirrl/tripod
lib/tripod/fields.rb
Tripod::Fields.ClassMethods.create_field_getter
def create_field_getter(name, meth, field) generated_methods.module_eval do re_define_method(meth) do read_attribute(name, field) end end end
ruby
def create_field_getter(name, meth, field) generated_methods.module_eval do re_define_method(meth) do read_attribute(name, field) end end end
[ "def", "create_field_getter", "(", "name", ",", "meth", ",", "field", ")", "generated_methods", ".", "module_eval", "do", "re_define_method", "(", "meth", ")", "do", "read_attribute", "(", "name", ",", "field", ")", "end", "end", "end" ]
Create the getter method for the provided field. @example Create the getter. Model.create_field_getter("name", "name", field) @param [ String ] name The name of the attribute. @param [ String ] meth The name of the method. @param [ Field ] field The field.
[ "Create", "the", "getter", "method", "for", "the", "provided", "field", "." ]
00bb42c67b68e5c6843b9883cd5c69a318f3b72b
https://github.com/Swirrl/tripod/blob/00bb42c67b68e5c6843b9883cd5c69a318f3b72b/lib/tripod/fields.rb#L132-L138
train
Swirrl/tripod
lib/tripod/fields.rb
Tripod::Fields.ClassMethods.create_field_setter
def create_field_setter(name, meth, field) generated_methods.module_eval do re_define_method("#{meth}=") do |value| write_attribute(name, value, field) end end end
ruby
def create_field_setter(name, meth, field) generated_methods.module_eval do re_define_method("#{meth}=") do |value| write_attribute(name, value, field) end end end
[ "def", "create_field_setter", "(", "name", ",", "meth", ",", "field", ")", "generated_methods", ".", "module_eval", "do", "re_define_method", "(", "\"#{meth}=\"", ")", "do", "|", "value", "|", "write_attribute", "(", "name", ",", "value", ",", "field", ")", ...
Create the setter method for the provided field. @example Create the setter. Model.create_field_setter("name", "name") @param [ String ] name The name of the attribute. @param [ String ] meth The name of the method. @param [ Field ] field The field.
[ "Create", "the", "setter", "method", "for", "the", "provided", "field", "." ]
00bb42c67b68e5c6843b9883cd5c69a318f3b72b
https://github.com/Swirrl/tripod/blob/00bb42c67b68e5c6843b9883cd5c69a318f3b72b/lib/tripod/fields.rb#L148-L154
train
Swirrl/tripod
lib/tripod/fields.rb
Tripod::Fields.ClassMethods.create_field_check
def create_field_check(name, meth, field) generated_methods.module_eval do re_define_method("#{meth}?") do attr = read_attribute(name, field) attr == true || attr.present? end end end
ruby
def create_field_check(name, meth, field) generated_methods.module_eval do re_define_method("#{meth}?") do attr = read_attribute(name, field) attr == true || attr.present? end end end
[ "def", "create_field_check", "(", "name", ",", "meth", ",", "field", ")", "generated_methods", ".", "module_eval", "do", "re_define_method", "(", "\"#{meth}?\"", ")", "do", "attr", "=", "read_attribute", "(", "name", ",", "field", ")", "attr", "==", "true", ...
Create the check method for the provided field. @example Create the check. Model.create_field_check("name", "name") @param [ String ] name The name of the attribute. @param [ String ] meth The name of the method.
[ "Create", "the", "check", "method", "for", "the", "provided", "field", "." ]
00bb42c67b68e5c6843b9883cd5c69a318f3b72b
https://github.com/Swirrl/tripod/blob/00bb42c67b68e5c6843b9883cd5c69a318f3b72b/lib/tripod/fields.rb#L163-L170
train
Swirrl/tripod
lib/tripod/fields.rb
Tripod::Fields.ClassMethods.field_for
def field_for(name, predicate, options) Tripod::Fields::Standard.new(name, predicate, options) end
ruby
def field_for(name, predicate, options) Tripod::Fields::Standard.new(name, predicate, options) end
[ "def", "field_for", "(", "name", ",", "predicate", ",", "options", ")", "Tripod", "::", "Fields", "::", "Standard", ".", "new", "(", "name", ",", "predicate", ",", "options", ")", "end" ]
instantiates and returns a new standard field
[ "instantiates", "and", "returns", "a", "new", "standard", "field" ]
00bb42c67b68e5c6843b9883cd5c69a318f3b72b
https://github.com/Swirrl/tripod/blob/00bb42c67b68e5c6843b9883cd5c69a318f3b72b/lib/tripod/fields.rb#L188-L190
train
Swirrl/tripod
lib/tripod/finders.rb
Tripod::Finders.ClassMethods.describe_uris
def describe_uris(uris) graph = RDF::Graph.new if uris.length > 0 uris_sparql_str = uris.map{ |u| "<#{u.to_s}>" }.join(" ") # Do a big describe statement, and read the results into an in-memory repo ntriples_string = Tripod::SparqlClient::Query.query("CONSTRUCT { ?s ?p ?o } WHERE {...
ruby
def describe_uris(uris) graph = RDF::Graph.new if uris.length > 0 uris_sparql_str = uris.map{ |u| "<#{u.to_s}>" }.join(" ") # Do a big describe statement, and read the results into an in-memory repo ntriples_string = Tripod::SparqlClient::Query.query("CONSTRUCT { ?s ?p ?o } WHERE {...
[ "def", "describe_uris", "(", "uris", ")", "graph", "=", "RDF", "::", "Graph", ".", "new", "if", "uris", ".", "length", ">", "0", "uris_sparql_str", "=", "uris", ".", "map", "{", "|", "u", "|", "\"<#{u.to_s}>\"", "}", ".", "join", "(", "\" \"", ")", ...
returns a graph of triples which describe the uris passed in.
[ "returns", "a", "graph", "of", "triples", "which", "describe", "the", "uris", "passed", "in", "." ]
00bb42c67b68e5c6843b9883cd5c69a318f3b72b
https://github.com/Swirrl/tripod/blob/00bb42c67b68e5c6843b9883cd5c69a318f3b72b/lib/tripod/finders.rb#L105-L117
train
Swirrl/tripod
lib/tripod/finders.rb
Tripod::Finders.ClassMethods._rdf_graph_from_ntriples_string
def _rdf_graph_from_ntriples_string(ntriples_string, graph=nil) graph ||= RDF::Graph.new RDF::Reader.for(:ntriples).new(ntriples_string) do |reader| reader.each_statement do |statement| graph << statement end end graph end
ruby
def _rdf_graph_from_ntriples_string(ntriples_string, graph=nil) graph ||= RDF::Graph.new RDF::Reader.for(:ntriples).new(ntriples_string) do |reader| reader.each_statement do |statement| graph << statement end end graph end
[ "def", "_rdf_graph_from_ntriples_string", "(", "ntriples_string", ",", "graph", "=", "nil", ")", "graph", "||=", "RDF", "::", "Graph", ".", "new", "RDF", "::", "Reader", ".", "for", "(", ":ntriples", ")", ".", "new", "(", "ntriples_string", ")", "do", "|",...
given a string of ntriples data, populate an RDF graph. If you pass a graph in, it will add to that one.
[ "given", "a", "string", "of", "ntriples", "data", "populate", "an", "RDF", "graph", ".", "If", "you", "pass", "a", "graph", "in", "it", "will", "add", "to", "that", "one", "." ]
00bb42c67b68e5c6843b9883cd5c69a318f3b72b
https://github.com/Swirrl/tripod/blob/00bb42c67b68e5c6843b9883cd5c69a318f3b72b/lib/tripod/finders.rb#L140-L148
train
Swirrl/tripod
lib/tripod/finders.rb
Tripod::Finders.ClassMethods._graph_of_triples_from_construct_or_describe
def _graph_of_triples_from_construct_or_describe(construct_query) ntriples_str = Tripod::SparqlClient::Query.query(construct_query, Tripod.ntriples_header_str) _rdf_graph_from_ntriples_string(ntriples_str, graph=nil) end
ruby
def _graph_of_triples_from_construct_or_describe(construct_query) ntriples_str = Tripod::SparqlClient::Query.query(construct_query, Tripod.ntriples_header_str) _rdf_graph_from_ntriples_string(ntriples_str, graph=nil) end
[ "def", "_graph_of_triples_from_construct_or_describe", "(", "construct_query", ")", "ntriples_str", "=", "Tripod", "::", "SparqlClient", "::", "Query", ".", "query", "(", "construct_query", ",", "Tripod", ".", "ntriples_header_str", ")", "_rdf_graph_from_ntriples_string", ...
given a construct or describe query, return a graph of triples.
[ "given", "a", "construct", "or", "describe", "query", "return", "a", "graph", "of", "triples", "." ]
00bb42c67b68e5c6843b9883cd5c69a318f3b72b
https://github.com/Swirrl/tripod/blob/00bb42c67b68e5c6843b9883cd5c69a318f3b72b/lib/tripod/finders.rb#L151-L154
train
Swirrl/tripod
lib/tripod/finders.rb
Tripod::Finders.ClassMethods._create_and_hydrate_resources_from_sparql
def _create_and_hydrate_resources_from_sparql(select_sparql, opts={}) # TODO: Optimization?: if return_graph option is false, then don't do this next line? uris_and_graphs = _select_uris_and_graphs(select_sparql, :uri_variable => opts[:uri_variable], :graph_variable => opts[:graph_variable]) #there a...
ruby
def _create_and_hydrate_resources_from_sparql(select_sparql, opts={}) # TODO: Optimization?: if return_graph option is false, then don't do this next line? uris_and_graphs = _select_uris_and_graphs(select_sparql, :uri_variable => opts[:uri_variable], :graph_variable => opts[:graph_variable]) #there a...
[ "def", "_create_and_hydrate_resources_from_sparql", "(", "select_sparql", ",", "opts", "=", "{", "}", ")", "uris_and_graphs", "=", "_select_uris_and_graphs", "(", "select_sparql", ",", ":uri_variable", "=>", "opts", "[", ":uri_variable", "]", ",", ":graph_variable", "...
Given a select query, perform a DESCRIBE query to get a graph of data from which we create and hydrate a collection of resources. @option options [ String ] uri_variable The name of the uri variable in the query, if not 'uri' @option options [ String ] graph_variable The name of the uri variable in the query, if no...
[ "Given", "a", "select", "query", "perform", "a", "DESCRIBE", "query", "to", "get", "a", "graph", "of", "data", "from", "which", "we", "create", "and", "hydrate", "a", "collection", "of", "resources", "." ]
00bb42c67b68e5c6843b9883cd5c69a318f3b72b
https://github.com/Swirrl/tripod/blob/00bb42c67b68e5c6843b9883cd5c69a318f3b72b/lib/tripod/finders.rb#L161-L173
train
Swirrl/tripod
lib/tripod/finders.rb
Tripod::Finders.ClassMethods._construct_query_for_uris_and_graphs
def _construct_query_for_uris_and_graphs(uris_and_graphs) value_pairs = uris_and_graphs.map do |(uri, graph)| u = RDF::URI.new(uri).to_base g = graph ? RDF::URI.new(graph).to_base : 'UNDEF' "(#{u} #{g})" end query = "CONSTRUCT { ?uri ?p ?o . #{ self.all_triples_construct("?uri"...
ruby
def _construct_query_for_uris_and_graphs(uris_and_graphs) value_pairs = uris_and_graphs.map do |(uri, graph)| u = RDF::URI.new(uri).to_base g = graph ? RDF::URI.new(graph).to_base : 'UNDEF' "(#{u} #{g})" end query = "CONSTRUCT { ?uri ?p ?o . #{ self.all_triples_construct("?uri"...
[ "def", "_construct_query_for_uris_and_graphs", "(", "uris_and_graphs", ")", "value_pairs", "=", "uris_and_graphs", ".", "map", "do", "|", "(", "uri", ",", "graph", ")", "|", "u", "=", "RDF", "::", "URI", ".", "new", "(", "uri", ")", ".", "to_base", "g", ...
Generate a CONSTRUCT query for the given uri and graph pairs.
[ "Generate", "a", "CONSTRUCT", "query", "for", "the", "given", "uri", "and", "graph", "pairs", "." ]
00bb42c67b68e5c6843b9883cd5c69a318f3b72b
https://github.com/Swirrl/tripod/blob/00bb42c67b68e5c6843b9883cd5c69a318f3b72b/lib/tripod/finders.rb#L196-L203
train
Swirrl/tripod
lib/tripod/finders.rb
Tripod::Finders.ClassMethods._raw_describe_select_results
def _raw_describe_select_results(select_sparql, opts={}) accept_header = opts[:accept_header] || Tripod.ntriples_header_str query = _describe_query_for_select(select_sparql, :uri_variable => opts[:uri_variable]) Tripod::SparqlClient::Query.query(query, accept_header) end
ruby
def _raw_describe_select_results(select_sparql, opts={}) accept_header = opts[:accept_header] || Tripod.ntriples_header_str query = _describe_query_for_select(select_sparql, :uri_variable => opts[:uri_variable]) Tripod::SparqlClient::Query.query(query, accept_header) end
[ "def", "_raw_describe_select_results", "(", "select_sparql", ",", "opts", "=", "{", "}", ")", "accept_header", "=", "opts", "[", ":accept_header", "]", "||", "Tripod", ".", "ntriples_header_str", "query", "=", "_describe_query_for_select", "(", "select_sparql", ",",...
For a select query, get a raw serialisation of the DESCRIPTION of the resources from the database. @option options [ String ] uri_variable The name of the uri variable in the query, if not 'uri' @option options [ String ] accept_header The http accept header (default application/n-triples)
[ "For", "a", "select", "query", "get", "a", "raw", "serialisation", "of", "the", "DESCRIPTION", "of", "the", "resources", "from", "the", "database", "." ]
00bb42c67b68e5c6843b9883cd5c69a318f3b72b
https://github.com/Swirrl/tripod/blob/00bb42c67b68e5c6843b9883cd5c69a318f3b72b/lib/tripod/finders.rb#L209-L213
train
Swirrl/tripod
lib/tripod/resource_collection.rb
Tripod.ResourceCollection.to_nt
def to_nt time_serialization('nt') do if @criteria @criteria.serialize(:return_graph => @return_graph, :accept_header => Tripod.ntriples_header_str) elsif @sparql_query_str && @resource_class # run the query as a describe. @resource_class._raw_describe_select_results(...
ruby
def to_nt time_serialization('nt') do if @criteria @criteria.serialize(:return_graph => @return_graph, :accept_header => Tripod.ntriples_header_str) elsif @sparql_query_str && @resource_class # run the query as a describe. @resource_class._raw_describe_select_results(...
[ "def", "to_nt", "time_serialization", "(", "'nt'", ")", "do", "if", "@criteria", "@criteria", ".", "serialize", "(", ":return_graph", "=>", "@return_graph", ",", ":accept_header", "=>", "Tripod", ".", "ntriples_header_str", ")", "elsif", "@sparql_query_str", "&&", ...
for n-triples we can just concatenate them
[ "for", "n", "-", "triples", "we", "can", "just", "concatenate", "them" ]
00bb42c67b68e5c6843b9883cd5c69a318f3b72b
https://github.com/Swirrl/tripod/blob/00bb42c67b68e5c6843b9883cd5c69a318f3b72b/lib/tripod/resource_collection.rb#L53-L69
train
Swirrl/tripod
lib/tripod/criteria/execution.rb
Tripod.CriteriaExecution.resources
def resources(opts={}) Tripod::ResourceCollection.new( self.resource_class._resources_from_sparql(self.as_query(opts)), # pass in the criteria that was used to generate this collection, as well as whether the user specified return graph :return_graph => (opts.has_key?(:return_graph) ? opt...
ruby
def resources(opts={}) Tripod::ResourceCollection.new( self.resource_class._resources_from_sparql(self.as_query(opts)), # pass in the criteria that was used to generate this collection, as well as whether the user specified return graph :return_graph => (opts.has_key?(:return_graph) ? opt...
[ "def", "resources", "(", "opts", "=", "{", "}", ")", "Tripod", "::", "ResourceCollection", ".", "new", "(", "self", ".", "resource_class", ".", "_resources_from_sparql", "(", "self", ".", "as_query", "(", "opts", ")", ")", ",", ":return_graph", "=>", "(", ...
Execute the query and return a +ResourceCollection+ of all hydrated resources +ResourceCollection+ is an +Enumerable+, Array-like object. @option options [ String ] return_graph Indicates whether to return the graph as one of the variables.
[ "Execute", "the", "query", "and", "return", "a", "+", "ResourceCollection", "+", "of", "all", "hydrated", "resources", "+", "ResourceCollection", "+", "is", "an", "+", "Enumerable", "+", "Array", "-", "like", "object", "." ]
00bb42c67b68e5c6843b9883cd5c69a318f3b72b
https://github.com/Swirrl/tripod/blob/00bb42c67b68e5c6843b9883cd5c69a318f3b72b/lib/tripod/criteria/execution.rb#L13-L20
train
Swirrl/tripod
lib/tripod/criteria/execution.rb
Tripod.CriteriaExecution.first
def first(opts={}) sq = Tripod::SparqlQuery.new(self.as_query(opts)) first_sparql = sq.as_first_query_str self.resource_class._resources_from_sparql(first_sparql).first end
ruby
def first(opts={}) sq = Tripod::SparqlQuery.new(self.as_query(opts)) first_sparql = sq.as_first_query_str self.resource_class._resources_from_sparql(first_sparql).first end
[ "def", "first", "(", "opts", "=", "{", "}", ")", "sq", "=", "Tripod", "::", "SparqlQuery", ".", "new", "(", "self", ".", "as_query", "(", "opts", ")", ")", "first_sparql", "=", "sq", ".", "as_first_query_str", "self", ".", "resource_class", ".", "_reso...
Execute the query and return the first result as a hydrated resource @option options [ String ] return_graph Indicates whether to return the graph as one of the variables.
[ "Execute", "the", "query", "and", "return", "the", "first", "result", "as", "a", "hydrated", "resource" ]
00bb42c67b68e5c6843b9883cd5c69a318f3b72b
https://github.com/Swirrl/tripod/blob/00bb42c67b68e5c6843b9883cd5c69a318f3b72b/lib/tripod/criteria/execution.rb#L34-L38
train
Swirrl/tripod
lib/tripod/criteria/execution.rb
Tripod.CriteriaExecution.count
def count(opts={}) sq = Tripod::SparqlQuery.new(self.as_query(opts)) count_sparql = sq.as_count_query_str result = Tripod::SparqlClient::Query.select(count_sparql) if result.length > 0 result[0]["tripod_count_var"]["value"].to_i else return 0 end end
ruby
def count(opts={}) sq = Tripod::SparqlQuery.new(self.as_query(opts)) count_sparql = sq.as_count_query_str result = Tripod::SparqlClient::Query.select(count_sparql) if result.length > 0 result[0]["tripod_count_var"]["value"].to_i else return 0 end end
[ "def", "count", "(", "opts", "=", "{", "}", ")", "sq", "=", "Tripod", "::", "SparqlQuery", ".", "new", "(", "self", ".", "as_query", "(", "opts", ")", ")", "count_sparql", "=", "sq", ".", "as_count_query_str", "result", "=", "Tripod", "::", "SparqlClie...
Return how many records the current criteria would return @option options [ String ] return_graph Indicates whether to return the graph as one of the variables.
[ "Return", "how", "many", "records", "the", "current", "criteria", "would", "return" ]
00bb42c67b68e5c6843b9883cd5c69a318f3b72b
https://github.com/Swirrl/tripod/blob/00bb42c67b68e5c6843b9883cd5c69a318f3b72b/lib/tripod/criteria/execution.rb#L43-L53
train
Swirrl/tripod
lib/tripod/criteria/execution.rb
Tripod.CriteriaExecution.as_query
def as_query(opts={}) Tripod.logger.debug("TRIPOD: building select query for criteria...") return_graph = opts.has_key?(:return_graph) ? opts[:return_graph] : true Tripod.logger.debug("TRIPOD: with return_graph: #{return_graph.inspect}") select_query = "SELECT DISTINCT ?uri " if graph_...
ruby
def as_query(opts={}) Tripod.logger.debug("TRIPOD: building select query for criteria...") return_graph = opts.has_key?(:return_graph) ? opts[:return_graph] : true Tripod.logger.debug("TRIPOD: with return_graph: #{return_graph.inspect}") select_query = "SELECT DISTINCT ?uri " if graph_...
[ "def", "as_query", "(", "opts", "=", "{", "}", ")", "Tripod", ".", "logger", ".", "debug", "(", "\"TRIPOD: building select query for criteria...\"", ")", "return_graph", "=", "opts", ".", "has_key?", "(", ":return_graph", ")", "?", "opts", "[", ":return_graph", ...
turn this criteria into a query
[ "turn", "this", "criteria", "into", "a", "query" ]
00bb42c67b68e5c6843b9883cd5c69a318f3b72b
https://github.com/Swirrl/tripod/blob/00bb42c67b68e5c6843b9883cd5c69a318f3b72b/lib/tripod/criteria/execution.rb#L56-L104
train
Swirrl/tripod
lib/tripod/repository.rb
Tripod::Repository.ClassMethods.add_data_to_repository
def add_data_to_repository(graph, repo=nil) repo ||= RDF::Repository.new() graph.each_statement do |statement| repo << statement end repo end
ruby
def add_data_to_repository(graph, repo=nil) repo ||= RDF::Repository.new() graph.each_statement do |statement| repo << statement end repo end
[ "def", "add_data_to_repository", "(", "graph", ",", "repo", "=", "nil", ")", "repo", "||=", "RDF", "::", "Repository", ".", "new", "(", ")", "graph", ".", "each_statement", "do", "|", "statement", "|", "repo", "<<", "statement", "end", "repo", "end" ]
for triples in the graph passed in, add them to the passed in repository obj, and return the repository objects  if no repository passed, make a new one.
[ "for", "triples", "in", "the", "graph", "passed", "in", "add", "them", "to", "the", "passed", "in", "repository", "obj", "and", "return", "the", "repository", "objects", "if", "no", "repository", "passed", "make", "a", "new", "one", "." ]
00bb42c67b68e5c6843b9883cd5c69a318f3b72b
https://github.com/Swirrl/tripod/blob/00bb42c67b68e5c6843b9883cd5c69a318f3b72b/lib/tripod/repository.rb#L75-L84
train
Swirrl/tripod
lib/tripod/criteria.rb
Tripod.Criteria.graph
def graph(graph_uri, &block) if block_given? self.graph_lambdas ||= [] self.graph_lambdas << block self else self.graph_uri = graph_uri.to_s self end end
ruby
def graph(graph_uri, &block) if block_given? self.graph_lambdas ||= [] self.graph_lambdas << block self else self.graph_uri = graph_uri.to_s self end end
[ "def", "graph", "(", "graph_uri", ",", "&", "block", ")", "if", "block_given?", "self", ".", "graph_lambdas", "||=", "[", "]", "self", ".", "graph_lambdas", "<<", "block", "self", "else", "self", ".", "graph_uri", "=", "graph_uri", ".", "to_s", "self", "...
Restrict this query to the graph uri passed in You may also pass a block to an unbound graph, ?g then chain a where clause to the criteria returned to bind ?g @example .graph(RDF::URI.new('http://graphoid') @example .graph('http://graphoid') @example .graph(nil) { "?s ?p ?o" }.where("?uri ?p ?g") @param [ Strin...
[ "Restrict", "this", "query", "to", "the", "graph", "uri", "passed", "in", "You", "may", "also", "pass", "a", "block", "to", "an", "unbound", "graph", "?g", "then", "chain", "a", "where", "clause", "to", "the", "criteria", "returned", "to", "bind", "?g" ]
00bb42c67b68e5c6843b9883cd5c69a318f3b72b
https://github.com/Swirrl/tripod/blob/00bb42c67b68e5c6843b9883cd5c69a318f3b72b/lib/tripod/criteria.rb#L101-L111
train
Swirrl/tripod
lib/tripod/links.rb
Tripod::Links.ClassMethods.linked_from_for
def linked_from_for(name, incoming_field_name, options) Tripod::Links::LinkedFrom.new(name, incoming_field_name, options) end
ruby
def linked_from_for(name, incoming_field_name, options) Tripod::Links::LinkedFrom.new(name, incoming_field_name, options) end
[ "def", "linked_from_for", "(", "name", ",", "incoming_field_name", ",", "options", ")", "Tripod", "::", "Links", "::", "LinkedFrom", ".", "new", "(", "name", ",", "incoming_field_name", ",", "options", ")", "end" ]
instantiates and returns a new LinkedFrom
[ "instantiates", "and", "returns", "a", "new", "LinkedFrom" ]
00bb42c67b68e5c6843b9883cd5c69a318f3b72b
https://github.com/Swirrl/tripod/blob/00bb42c67b68e5c6843b9883cd5c69a318f3b72b/lib/tripod/links.rb#L164-L166
train
Swirrl/tripod
lib/tripod/links.rb
Tripod::Links.ClassMethods.linked_to_for
def linked_to_for(name, predicate, options) Tripod::Links::LinkedTo.new(name, predicate, options) end
ruby
def linked_to_for(name, predicate, options) Tripod::Links::LinkedTo.new(name, predicate, options) end
[ "def", "linked_to_for", "(", "name", ",", "predicate", ",", "options", ")", "Tripod", "::", "Links", "::", "LinkedTo", ".", "new", "(", "name", ",", "predicate", ",", "options", ")", "end" ]
instantiates and returns a new LinkTo
[ "instantiates", "and", "returns", "a", "new", "LinkTo" ]
00bb42c67b68e5c6843b9883cd5c69a318f3b72b
https://github.com/Swirrl/tripod/blob/00bb42c67b68e5c6843b9883cd5c69a318f3b72b/lib/tripod/links.rb#L169-L171
train
story-branch/story_branch
lib/story_branch/main.rb
StoryBranch.Main.validate_branch_name
def validate_branch_name(name, id) if GitUtils.branch_for_story_exists? id prompt.error("An existing branch has the same story id: #{id}") return false end if GitUtils.existing_branch? name prompt.error('This name is very similar to an existing branch. Avoid confusion and use a...
ruby
def validate_branch_name(name, id) if GitUtils.branch_for_story_exists? id prompt.error("An existing branch has the same story id: #{id}") return false end if GitUtils.existing_branch? name prompt.error('This name is very similar to an existing branch. Avoid confusion and use a...
[ "def", "validate_branch_name", "(", "name", ",", "id", ")", "if", "GitUtils", ".", "branch_for_story_exists?", "id", "prompt", ".", "error", "(", "\"An existing branch has the same story id: #{id}\"", ")", "return", "false", "end", "if", "GitUtils", ".", "existing_bra...
Branch name validation
[ "Branch", "name", "validation" ]
2ad2aa94f89b5a278c4f4ea32db7bccfb1ab05d7
https://github.com/story-branch/story_branch/blob/2ad2aa94f89b5a278c4f4ea32db7bccfb1ab05d7/lib/story_branch/main.rb#L178-L188
train
bernerdschaefer/akephalos
lib/akephalos/node.rb
Akephalos.Node.value
def value case tag_name when "select" if self[:multiple] selected_options.map { |option| option.value } else selected_option = @_node.selected_options.first selected_option ? Node.new(selected_option).value : nil end when "option" self[:val...
ruby
def value case tag_name when "select" if self[:multiple] selected_options.map { |option| option.value } else selected_option = @_node.selected_options.first selected_option ? Node.new(selected_option).value : nil end when "option" self[:val...
[ "def", "value", "case", "tag_name", "when", "\"select\"", "if", "self", "[", ":multiple", "]", "selected_options", ".", "map", "{", "|", "option", "|", "option", ".", "value", "}", "else", "selected_option", "=", "@_node", ".", "selected_options", ".", "firs...
Return the value of a form element. If the element is a select box and has "multiple" declared as an attribute, then all selected options will be returned as an array. @return [String, Array<String>] the node's value
[ "Return", "the", "value", "of", "a", "form", "element", ".", "If", "the", "element", "is", "a", "select", "box", "and", "has", "multiple", "declared", "as", "an", "attribute", "then", "all", "selected", "options", "will", "be", "returned", "as", "an", "a...
80103301ebe1609b90de04a8e4f6092def818585
https://github.com/bernerdschaefer/akephalos/blob/80103301ebe1609b90de04a8e4f6092def818585/lib/akephalos/node.rb#L40-L56
train
bernerdschaefer/akephalos
lib/akephalos/node.rb
Akephalos.Node.value=
def value=(value) case tag_name when "textarea" @_node.setText("") type(value) when "input" if file_input? @_node.setValueAttribute(value) else @_node.setValueAttribute("") type(value) end end end
ruby
def value=(value) case tag_name when "textarea" @_node.setText("") type(value) when "input" if file_input? @_node.setValueAttribute(value) else @_node.setValueAttribute("") type(value) end end end
[ "def", "value", "=", "(", "value", ")", "case", "tag_name", "when", "\"textarea\"", "@_node", ".", "setText", "(", "\"\"", ")", "type", "(", "value", ")", "when", "\"input\"", "if", "file_input?", "@_node", ".", "setValueAttribute", "(", "value", ")", "els...
Set the value of the form input. @param [String] value
[ "Set", "the", "value", "of", "the", "form", "input", "." ]
80103301ebe1609b90de04a8e4f6092def818585
https://github.com/bernerdschaefer/akephalos/blob/80103301ebe1609b90de04a8e4f6092def818585/lib/akephalos/node.rb#L61-L74
train
bernerdschaefer/akephalos
lib/akephalos/node.rb
Akephalos.Node.click
def click @_node.click @_node.getPage.getEnclosingWindow.getJobManager.waitForJobs(1000) @_node.getPage.getEnclosingWindow.getJobManager.waitForJobsStartingBefore(1000) end
ruby
def click @_node.click @_node.getPage.getEnclosingWindow.getJobManager.waitForJobs(1000) @_node.getPage.getEnclosingWindow.getJobManager.waitForJobsStartingBefore(1000) end
[ "def", "click", "@_node", ".", "click", "@_node", ".", "getPage", ".", "getEnclosingWindow", ".", "getJobManager", ".", "waitForJobs", "(", "1000", ")", "@_node", ".", "getPage", ".", "getEnclosingWindow", ".", "getJobManager", ".", "waitForJobsStartingBefore", "(...
Click the node and then wait for any triggered JavaScript callbacks to fire.
[ "Click", "the", "node", "and", "then", "wait", "for", "any", "triggered", "JavaScript", "callbacks", "to", "fire", "." ]
80103301ebe1609b90de04a8e4f6092def818585
https://github.com/bernerdschaefer/akephalos/blob/80103301ebe1609b90de04a8e4f6092def818585/lib/akephalos/node.rb#L150-L154
train
phcdevworks/multi-tenancy-devise
app/controllers/mtdevise/accounts_controller.rb
Mtdevise.AccountsController.create
def create account = if user_signed_in? Mtdevise::Account.create(account_params) else Mtdevise::Account.create_with_owner(account_params) end @account = account if account.valid? flash[:success] = "Your account has been successfully created." if user_signed_in? account.owner = curre...
ruby
def create account = if user_signed_in? Mtdevise::Account.create(account_params) else Mtdevise::Account.create_with_owner(account_params) end @account = account if account.valid? flash[:success] = "Your account has been successfully created." if user_signed_in? account.owner = curre...
[ "def", "create", "account", "=", "if", "user_signed_in?", "Mtdevise", "::", "Account", ".", "create", "(", "account_params", ")", "else", "Mtdevise", "::", "Account", ".", "create_with_owner", "(", "account_params", ")", "end", "@account", "=", "account", "if", ...
Accounts Create action
[ "Accounts", "Create", "action" ]
e0a6e4582a8f415539ab598863c5e4cde2cde2cd
https://github.com/phcdevworks/multi-tenancy-devise/blob/e0a6e4582a8f415539ab598863c5e4cde2cde2cd/app/controllers/mtdevise/accounts_controller.rb#L23-L50
train
HewlettPackard/hpe3par_ruby_sdk
lib/Hpe3parSdk/client.rb
Hpe3parSdk.Client.get_ws_api_version
def get_ws_api_version # remove everything down to host:port host_url = @api_url.split('/api') @http.set_url(host_url[0]) begin # get the api version response = @http.get('/api') response[1] rescue => ex Util.log_exception(ex, caller_locations(1, 1)[0].label...
ruby
def get_ws_api_version # remove everything down to host:port host_url = @api_url.split('/api') @http.set_url(host_url[0]) begin # get the api version response = @http.get('/api') response[1] rescue => ex Util.log_exception(ex, caller_locations(1, 1)[0].label...
[ "def", "get_ws_api_version", "host_url", "=", "@api_url", ".", "split", "(", "'/api'", ")", "@http", ".", "set_url", "(", "host_url", "[", "0", "]", ")", "begin", "response", "=", "@http", ".", "get", "(", "'/api'", ")", "response", "[", "1", "]", "res...
Get the 3PAR WS API version. ==== Returns WSAPI version hash
[ "Get", "the", "3PAR", "WS", "API", "version", "." ]
f8cfc6e597741be593cf7fe013accadf982ee68b
https://github.com/HewlettPackard/hpe3par_ruby_sdk/blob/f8cfc6e597741be593cf7fe013accadf982ee68b/lib/Hpe3parSdk/client.rb#L133-L148
train
HewlettPackard/hpe3par_ruby_sdk
lib/Hpe3parSdk/client.rb
Hpe3parSdk.Client.create_flash_cache
def create_flash_cache(size_in_gib, mode = nil) begin @flash_cache.create_flash_cache(size_in_gib, mode) rescue => ex Util.log_exception(ex, caller_locations(1, 1)[0].label) raise ex end end
ruby
def create_flash_cache(size_in_gib, mode = nil) begin @flash_cache.create_flash_cache(size_in_gib, mode) rescue => ex Util.log_exception(ex, caller_locations(1, 1)[0].label) raise ex end end
[ "def", "create_flash_cache", "(", "size_in_gib", ",", "mode", "=", "nil", ")", "begin", "@flash_cache", ".", "create_flash_cache", "(", "size_in_gib", ",", "mode", ")", "rescue", "=>", "ex", "Util", ".", "log_exception", "(", "ex", ",", "caller_locations", "("...
Creates a new FlashCache ==== Attributes * size_in_gib - Specifies the node pair size of the Flash Cache on the system type size_in_gib: Integer * mode - Values supported Simulator: 1, Real: 2 (default) type mode: Integer ==== Raises * Hpe3parSdk::HTTPBadRequest - NO_SPACE - Not enough space...
[ "Creates", "a", "new", "FlashCache" ]
f8cfc6e597741be593cf7fe013accadf982ee68b
https://github.com/HewlettPackard/hpe3par_ruby_sdk/blob/f8cfc6e597741be593cf7fe013accadf982ee68b/lib/Hpe3parSdk/client.rb#L186-L194
train
HewlettPackard/hpe3par_ruby_sdk
lib/Hpe3parSdk/client.rb
Hpe3parSdk.Client.get_flash_cache
def get_flash_cache begin @flash_cache.get_flash_cache rescue => ex Util.log_exception(ex, caller_locations(1, 1)[0].label) raise ex end end
ruby
def get_flash_cache begin @flash_cache.get_flash_cache rescue => ex Util.log_exception(ex, caller_locations(1, 1)[0].label) raise ex end end
[ "def", "get_flash_cache", "begin", "@flash_cache", ".", "get_flash_cache", "rescue", "=>", "ex", "Util", ".", "log_exception", "(", "ex", ",", "caller_locations", "(", "1", ",", "1", ")", "[", "0", "]", ".", "label", ")", "raise", "ex", "end", "end" ]
Get Flash Cache information ==== Returns FlashCache - Details of the specified flash cache
[ "Get", "Flash", "Cache", "information" ]
f8cfc6e597741be593cf7fe013accadf982ee68b
https://github.com/HewlettPackard/hpe3par_ruby_sdk/blob/f8cfc6e597741be593cf7fe013accadf982ee68b/lib/Hpe3parSdk/client.rb#L201-L208
train
HewlettPackard/hpe3par_ruby_sdk
lib/Hpe3parSdk/client.rb
Hpe3parSdk.Client.delete_flash_cache
def delete_flash_cache begin @flash_cache.delete_flash_cache rescue => ex Util.log_exception(ex, caller_locations(1, 1)[0].label) raise ex end end
ruby
def delete_flash_cache begin @flash_cache.delete_flash_cache rescue => ex Util.log_exception(ex, caller_locations(1, 1)[0].label) raise ex end end
[ "def", "delete_flash_cache", "begin", "@flash_cache", ".", "delete_flash_cache", "rescue", "=>", "ex", "Util", ".", "log_exception", "(", "ex", ",", "caller_locations", "(", "1", ",", "1", ")", "[", "0", "]", ".", "label", ")", "raise", "ex", "end", "end" ...
Deletes an existing Flash Cache ==== Raises * Hpe3parSdk::HTTPForbidden - FLASH_CACHE_IS_BEING_REMOVED - Unable to delete the Flash Cache, the Flash Cache is being removed. * Hpe3parSdk::HTTPForbidden - FLASH_CACHE_NOT_SUPPORTED - Flash Cache is not supported on this system. * Hpe3parSdk::HTTPNotFou...
[ "Deletes", "an", "existing", "Flash", "Cache" ]
f8cfc6e597741be593cf7fe013accadf982ee68b
https://github.com/HewlettPackard/hpe3par_ruby_sdk/blob/f8cfc6e597741be593cf7fe013accadf982ee68b/lib/Hpe3parSdk/client.rb#L220-L227
train
HewlettPackard/hpe3par_ruby_sdk
lib/Hpe3parSdk/client.rb
Hpe3parSdk.Client.get_overall_system_capacity
def get_overall_system_capacity begin response = @http.get('/capacity') response[1] rescue => ex Util.log_exception(ex, caller_locations(1, 1)[0].label) raise ex end end
ruby
def get_overall_system_capacity begin response = @http.get('/capacity') response[1] rescue => ex Util.log_exception(ex, caller_locations(1, 1)[0].label) raise ex end end
[ "def", "get_overall_system_capacity", "begin", "response", "=", "@http", ".", "get", "(", "'/capacity'", ")", "response", "[", "1", "]", "rescue", "=>", "ex", "Util", ".", "log_exception", "(", "ex", ",", "caller_locations", "(", "1", ",", "1", ")", "[", ...
Gets the overall system capacity for the 3PAR server. ==== Returns Hash of system capacity information capacity = { "allCapacity"=> { # Overall system capacity # includes FC, NL, SSD # d...
[ "Gets", "the", "overall", "system", "capacity", "for", "the", "3PAR", "server", "." ]
f8cfc6e597741be593cf7fe013accadf982ee68b
https://github.com/HewlettPackard/hpe3par_ruby_sdk/blob/f8cfc6e597741be593cf7fe013accadf982ee68b/lib/Hpe3parSdk/client.rb#L328-L336
train
HewlettPackard/hpe3par_ruby_sdk
lib/Hpe3parSdk/client.rb
Hpe3parSdk.Client.get_all_tasks
def get_all_tasks begin @task.get_all_tasks rescue => ex Util.log_exception(ex, caller_locations(1, 1)[0].label) raise ex end end
ruby
def get_all_tasks begin @task.get_all_tasks rescue => ex Util.log_exception(ex, caller_locations(1, 1)[0].label) raise ex end end
[ "def", "get_all_tasks", "begin", "@task", ".", "get_all_tasks", "rescue", "=>", "ex", "Util", ".", "log_exception", "(", "ex", ",", "caller_locations", "(", "1", ",", "1", ")", "[", "0", "]", ".", "label", ")", "raise", "ex", "end", "end" ]
Get the list of all 3PAR Tasks ==== Returns Array of Task
[ "Get", "the", "list", "of", "all", "3PAR", "Tasks" ]
f8cfc6e597741be593cf7fe013accadf982ee68b
https://github.com/HewlettPackard/hpe3par_ruby_sdk/blob/f8cfc6e597741be593cf7fe013accadf982ee68b/lib/Hpe3parSdk/client.rb#L357-L364
train
HewlettPackard/hpe3par_ruby_sdk
lib/Hpe3parSdk/client.rb
Hpe3parSdk.Client.get_task
def get_task(task_id) begin @task.get_task(task_id) rescue => ex Util.log_exception(ex, caller_locations(1, 1)[0].label) raise ex end end
ruby
def get_task(task_id) begin @task.get_task(task_id) rescue => ex Util.log_exception(ex, caller_locations(1, 1)[0].label) raise ex end end
[ "def", "get_task", "(", "task_id", ")", "begin", "@task", ".", "get_task", "(", "task_id", ")", "rescue", "=>", "ex", "Util", ".", "log_exception", "(", "ex", ",", "caller_locations", "(", "1", ",", "1", ")", "[", "0", "]", ".", "label", ")", "raise"...
Get the status of a 3PAR Task ==== Attributes * task_id - the task id type task_id: Integer ==== Returns Task ==== Raises * Hpe3parSdk::HTTPBadRequest - INV_INPUT_BELOW_RANGE - Bad Request Task ID must be a positive value. * Hpe3parSdk::HTTPBadRequest - INV_INPUT_EXCEEDS_RANGE - Bad R...
[ "Get", "the", "status", "of", "a", "3PAR", "Task" ]
f8cfc6e597741be593cf7fe013accadf982ee68b
https://github.com/HewlettPackard/hpe3par_ruby_sdk/blob/f8cfc6e597741be593cf7fe013accadf982ee68b/lib/Hpe3parSdk/client.rb#L387-L394
train
HewlettPackard/hpe3par_ruby_sdk
lib/Hpe3parSdk/client.rb
Hpe3parSdk.Client.create_vlun
def create_vlun(volume_name, lun = nil, host_name = nil, port_pos = nil, no_vcn = false, override_lower_priority = false, auto = false) begin @vlun.create_vlun(volume_name, host_name, lun, port_pos, no_vcn, override_lower_priority, auto) rescue => ex Util.log_exception(ex, caller_locations(1...
ruby
def create_vlun(volume_name, lun = nil, host_name = nil, port_pos = nil, no_vcn = false, override_lower_priority = false, auto = false) begin @vlun.create_vlun(volume_name, host_name, lun, port_pos, no_vcn, override_lower_priority, auto) rescue => ex Util.log_exception(ex, caller_locations(1...
[ "def", "create_vlun", "(", "volume_name", ",", "lun", "=", "nil", ",", "host_name", "=", "nil", ",", "port_pos", "=", "nil", ",", "no_vcn", "=", "false", ",", "override_lower_priority", "=", "false", ",", "auto", "=", "false", ")", "begin", "@vlun", ".",...
Creates a new VLUN. When creating a VLUN, the volumeName is required. The lun member is not required if auto is set to True. Either hostname or portPos (or both in the case of matched sets) is also required. The noVcn and overrideLowerPriority members are optional. * volume_name: Name of the volume to be export...
[ "Creates", "a", "new", "VLUN", "." ]
f8cfc6e597741be593cf7fe013accadf982ee68b
https://github.com/HewlettPackard/hpe3par_ruby_sdk/blob/f8cfc6e597741be593cf7fe013accadf982ee68b/lib/Hpe3parSdk/client.rb#L442-L449
train
HewlettPackard/hpe3par_ruby_sdk
lib/Hpe3parSdk/client.rb
Hpe3parSdk.Client.get_vluns
def get_vluns begin @vlun.get_vluns rescue => ex Util.log_exception(ex, caller_locations(1, 1)[0].label) raise ex end end
ruby
def get_vluns begin @vlun.get_vluns rescue => ex Util.log_exception(ex, caller_locations(1, 1)[0].label) raise ex end end
[ "def", "get_vluns", "begin", "@vlun", ".", "get_vluns", "rescue", "=>", "ex", "Util", ".", "log_exception", "(", "ex", ",", "caller_locations", "(", "1", ",", "1", ")", "[", "0", "]", ".", "label", ")", "raise", "ex", "end", "end" ]
Gets VLUNs. ==== Returns Array of VLUN objects
[ "Gets", "VLUNs", "." ]
f8cfc6e597741be593cf7fe013accadf982ee68b
https://github.com/HewlettPackard/hpe3par_ruby_sdk/blob/f8cfc6e597741be593cf7fe013accadf982ee68b/lib/Hpe3parSdk/client.rb#L456-L463
train
HewlettPackard/hpe3par_ruby_sdk
lib/Hpe3parSdk/client.rb
Hpe3parSdk.Client.get_vlun
def get_vlun(volume_name) begin @vlun.get_vlun(volume_name) rescue => ex Util.log_exception(ex, caller_locations(1, 1)[0].label) raise ex end end
ruby
def get_vlun(volume_name) begin @vlun.get_vlun(volume_name) rescue => ex Util.log_exception(ex, caller_locations(1, 1)[0].label) raise ex end end
[ "def", "get_vlun", "(", "volume_name", ")", "begin", "@vlun", ".", "get_vlun", "(", "volume_name", ")", "rescue", "=>", "ex", "Util", ".", "log_exception", "(", "ex", ",", "caller_locations", "(", "1", ",", "1", ")", "[", "0", "]", ".", "label", ")", ...
Gets information about a VLUN. ==== Attributes * volume_name: The volume name of the VLUN to find type volume_name: String ==== Returns VLUN object ==== Raises * Hpe3parSdk::HTTPNotFound - NON_EXISTENT_VLUN - VLUN doesn't exist
[ "Gets", "information", "about", "a", "VLUN", "." ]
f8cfc6e597741be593cf7fe013accadf982ee68b
https://github.com/HewlettPackard/hpe3par_ruby_sdk/blob/f8cfc6e597741be593cf7fe013accadf982ee68b/lib/Hpe3parSdk/client.rb#L480-L487
train
HewlettPackard/hpe3par_ruby_sdk
lib/Hpe3parSdk/client.rb
Hpe3parSdk.Client.delete_vlun
def delete_vlun(volume_name, lun_id, host_name = nil, port = nil) begin @vlun.delete_vlun(volume_name, lun_id, host_name, port) rescue => ex Util.log_exception(ex, caller_locations(1, 1)[0].label) raise ex end end
ruby
def delete_vlun(volume_name, lun_id, host_name = nil, port = nil) begin @vlun.delete_vlun(volume_name, lun_id, host_name, port) rescue => ex Util.log_exception(ex, caller_locations(1, 1)[0].label) raise ex end end
[ "def", "delete_vlun", "(", "volume_name", ",", "lun_id", ",", "host_name", "=", "nil", ",", "port", "=", "nil", ")", "begin", "@vlun", ".", "delete_vlun", "(", "volume_name", ",", "lun_id", ",", "host_name", ",", "port", ")", "rescue", "=>", "ex", "Util"...
Deletes a VLUN. ==== Attributes * volume_name: Volume name of the VLUN type volume_name: String * lun_id: LUN ID type lun_id: Integer * host_name: Name of the host which the volume is exported. For VLUN of port type,the value is empty type host_name: String * port: Specifies the system port of the...
[ "Deletes", "a", "VLUN", "." ]
f8cfc6e597741be593cf7fe013accadf982ee68b
https://github.com/HewlettPackard/hpe3par_ruby_sdk/blob/f8cfc6e597741be593cf7fe013accadf982ee68b/lib/Hpe3parSdk/client.rb#L523-L530
train
HewlettPackard/hpe3par_ruby_sdk
lib/Hpe3parSdk/client.rb
Hpe3parSdk.Client.query_qos_rules
def query_qos_rules begin @qos.query_qos_rules rescue => ex Util.log_exception(ex, caller_locations(1, 1)[0].label) raise ex end end
ruby
def query_qos_rules begin @qos.query_qos_rules rescue => ex Util.log_exception(ex, caller_locations(1, 1)[0].label) raise ex end end
[ "def", "query_qos_rules", "begin", "@qos", ".", "query_qos_rules", "rescue", "=>", "ex", "Util", ".", "log_exception", "(", "ex", ",", "caller_locations", "(", "1", ",", "1", ")", "[", "0", "]", ".", "label", ")", "raise", "ex", "end", "end" ]
Gets QoS Rules. ==== Returns Array of QoSRule objects
[ "Gets", "QoS", "Rules", "." ]
f8cfc6e597741be593cf7fe013accadf982ee68b
https://github.com/HewlettPackard/hpe3par_ruby_sdk/blob/f8cfc6e597741be593cf7fe013accadf982ee68b/lib/Hpe3parSdk/client.rb#L538-L545
train
HewlettPackard/hpe3par_ruby_sdk
lib/Hpe3parSdk/client.rb
Hpe3parSdk.Client.query_qos_rule
def query_qos_rule(target_name, target_type = 'vvset') begin @qos.query_qos_rule(target_name, target_type) rescue => ex Util.log_exception(ex, caller_locations(1, 1)[0].label) raise ex end end
ruby
def query_qos_rule(target_name, target_type = 'vvset') begin @qos.query_qos_rule(target_name, target_type) rescue => ex Util.log_exception(ex, caller_locations(1, 1)[0].label) raise ex end end
[ "def", "query_qos_rule", "(", "target_name", ",", "target_type", "=", "'vvset'", ")", "begin", "@qos", ".", "query_qos_rule", "(", "target_name", ",", "target_type", ")", "rescue", "=>", "ex", "Util", ".", "log_exception", "(", "ex", ",", "caller_locations", "...
Queries a QoS rule ==== Attributes * target_name : Name of the target. When targetType is sys, target name must be sys:all_others. type target_name: String * target_type : Target type is vvset or sys type target_type: String ==== Returns QoSRule object ==== Raises * Hpe3parSdk::HTTPNotFound ...
[ "Queries", "a", "QoS", "rule" ]
f8cfc6e597741be593cf7fe013accadf982ee68b
https://github.com/HewlettPackard/hpe3par_ruby_sdk/blob/f8cfc6e597741be593cf7fe013accadf982ee68b/lib/Hpe3parSdk/client.rb#L565-L572
train
HewlettPackard/hpe3par_ruby_sdk
lib/Hpe3parSdk/client.rb
Hpe3parSdk.Client.modify_qos_rules
def modify_qos_rules(target_name, qos_rules, target_type = QoStargetTypeConstants::VVSET) if @current_version < @min_version && !qos_rules.nil? qos_rules.delete_if { |key, _value| key == :latencyGoaluSecs } end begin @qos.modify_qos_rules(target_name, qos_rules, target_type) resc...
ruby
def modify_qos_rules(target_name, qos_rules, target_type = QoStargetTypeConstants::VVSET) if @current_version < @min_version && !qos_rules.nil? qos_rules.delete_if { |key, _value| key == :latencyGoaluSecs } end begin @qos.modify_qos_rules(target_name, qos_rules, target_type) resc...
[ "def", "modify_qos_rules", "(", "target_name", ",", "qos_rules", ",", "target_type", "=", "QoStargetTypeConstants", "::", "VVSET", ")", "if", "@current_version", "<", "@min_version", "&&", "!", "qos_rules", ".", "nil?", "qos_rules", ".", "delete_if", "{", "|", "...
Modifies an existing QOS rules The QoS rule can be applied to VV sets. By using sys:all_others, you can apply the rule to all volumes in the system for which no QoS rule has been defined. ioMinGoal and ioMaxLimit must be used together to set I/O limits. Similarly, bwMinGoalKB and bwMaxLimitKB must be used togethe...
[ "Modifies", "an", "existing", "QOS", "rules" ]
f8cfc6e597741be593cf7fe013accadf982ee68b
https://github.com/HewlettPackard/hpe3par_ruby_sdk/blob/f8cfc6e597741be593cf7fe013accadf982ee68b/lib/Hpe3parSdk/client.rb#L747-L757
train
HewlettPackard/hpe3par_ruby_sdk
lib/Hpe3parSdk/client.rb
Hpe3parSdk.Client.delete_qos_rules
def delete_qos_rules(target_name, target_type = QoStargetTypeConstants::VVSET) begin @qos.delete_qos_rules(target_name, target_type) rescue => ex Util.log_exception(ex, caller_locations(1, 1)[0].label) raise ex end end
ruby
def delete_qos_rules(target_name, target_type = QoStargetTypeConstants::VVSET) begin @qos.delete_qos_rules(target_name, target_type) rescue => ex Util.log_exception(ex, caller_locations(1, 1)[0].label) raise ex end end
[ "def", "delete_qos_rules", "(", "target_name", ",", "target_type", "=", "QoStargetTypeConstants", "::", "VVSET", ")", "begin", "@qos", ".", "delete_qos_rules", "(", "target_name", ",", "target_type", ")", "rescue", "=>", "ex", "Util", ".", "log_exception", "(", ...
Deletes QoS rules. ==== Attributes * target_name: Name of the target. When target_type is sys, target_name must be sys:all_others. type target_name: String * target_type: target type is vvset or sys type target_type: String ==== Raises * Hpe3parSdk::HTTPNotFound NON_EXISTENT_QOS_...
[ "Deletes", "QoS", "rules", "." ]
f8cfc6e597741be593cf7fe013accadf982ee68b
https://github.com/HewlettPackard/hpe3par_ruby_sdk/blob/f8cfc6e597741be593cf7fe013accadf982ee68b/lib/Hpe3parSdk/client.rb#L774-L781
train
HewlettPackard/hpe3par_ruby_sdk
lib/Hpe3parSdk/client.rb
Hpe3parSdk.Client.get_hosts
def get_hosts begin @host.get_hosts rescue => ex Util.log_exception(ex, caller_locations(1, 1)[0].label) raise ex end end
ruby
def get_hosts begin @host.get_hosts rescue => ex Util.log_exception(ex, caller_locations(1, 1)[0].label) raise ex end end
[ "def", "get_hosts", "begin", "@host", ".", "get_hosts", "rescue", "=>", "ex", "Util", ".", "log_exception", "(", "ex", ",", "caller_locations", "(", "1", ",", "1", ")", "[", "0", "]", ".", "label", ")", "raise", "ex", "end", "end" ]
Gets all hosts. ==== Returns Array of Host.
[ "Gets", "all", "hosts", "." ]
f8cfc6e597741be593cf7fe013accadf982ee68b
https://github.com/HewlettPackard/hpe3par_ruby_sdk/blob/f8cfc6e597741be593cf7fe013accadf982ee68b/lib/Hpe3parSdk/client.rb#L788-L795
train
HewlettPackard/hpe3par_ruby_sdk
lib/Hpe3parSdk/client.rb
Hpe3parSdk.Client.get_host
def get_host(name) begin @host.get_host(name) rescue => ex Util.log_exception(ex, caller_locations(1, 1)[0].label) raise ex end end
ruby
def get_host(name) begin @host.get_host(name) rescue => ex Util.log_exception(ex, caller_locations(1, 1)[0].label) raise ex end end
[ "def", "get_host", "(", "name", ")", "begin", "@host", ".", "get_host", "(", "name", ")", "rescue", "=>", "ex", "Util", ".", "log_exception", "(", "ex", ",", "caller_locations", "(", "1", ",", "1", ")", "[", "0", "]", ".", "label", ")", "raise", "e...
Gets host information by name. ==== Attributes * name - The name of the host to find. type name: String ==== Returns Host. ==== Raises * Hpe3parSdk::HTTPBadRequest - INV_INPUT - Invalid URI syntax. * Hpe3parSdk::HTTPNotFound - NON_EXISTENT_HOST - Host not found. * Hpe3parSdk::HTTPInter...
[ "Gets", "host", "information", "by", "name", "." ]
f8cfc6e597741be593cf7fe013accadf982ee68b
https://github.com/HewlettPackard/hpe3par_ruby_sdk/blob/f8cfc6e597741be593cf7fe013accadf982ee68b/lib/Hpe3parSdk/client.rb#L818-L825
train
HewlettPackard/hpe3par_ruby_sdk
lib/Hpe3parSdk/client.rb
Hpe3parSdk.Client.create_host
def create_host(name, iscsi_names = nil, fcwwns = nil, optional = nil) begin @host.create_host(name, iscsi_names, fcwwns, optional) rescue => ex Util.log_exception(ex, caller_locations(1, 1)[0].label) raise ex end end
ruby
def create_host(name, iscsi_names = nil, fcwwns = nil, optional = nil) begin @host.create_host(name, iscsi_names, fcwwns, optional) rescue => ex Util.log_exception(ex, caller_locations(1, 1)[0].label) raise ex end end
[ "def", "create_host", "(", "name", ",", "iscsi_names", "=", "nil", ",", "fcwwns", "=", "nil", ",", "optional", "=", "nil", ")", "begin", "@host", ".", "create_host", "(", "name", ",", "iscsi_names", ",", "fcwwns", ",", "optional", ")", "rescue", "=>", ...
Creates a new Host. ==== Attributes * name - The name of the host. type name: String * iscsi_names - Array of iSCSI iqns. type iscsi_names: Array * fcwwns - Array of Fibre Channel World Wide Names. type fcwwns: Array * optional - The optional stuff. type optional: Hash optional = ...
[ "Creates", "a", "new", "Host", "." ]
f8cfc6e597741be593cf7fe013accadf982ee68b
https://github.com/HewlettPackard/hpe3par_ruby_sdk/blob/f8cfc6e597741be593cf7fe013accadf982ee68b/lib/Hpe3parSdk/client.rb#L881-L888
train
HewlettPackard/hpe3par_ruby_sdk
lib/Hpe3parSdk/client.rb
Hpe3parSdk.Client.modify_host
def modify_host(name, mod_request) begin @host.modify_host(name, mod_request) rescue => ex Util.log_exception(ex, caller_locations(1, 1)[0].label) raise ex end end
ruby
def modify_host(name, mod_request) begin @host.modify_host(name, mod_request) rescue => ex Util.log_exception(ex, caller_locations(1, 1)[0].label) raise ex end end
[ "def", "modify_host", "(", "name", ",", "mod_request", ")", "begin", "@host", ".", "modify_host", "(", "name", ",", "mod_request", ")", "rescue", "=>", "ex", "Util", ".", "log_exception", "(", "ex", ",", "caller_locations", "(", "1", ",", "1", ")", "[", ...
Modifies an existing Host. ==== Attributes * name - Name of the host. type name: String * mod_request - Objects for host modification request. type mod_request: Hash mod_request = { 'newName'=> 'myNewName', # New name of the host 'pathOperation'=> 1, ...
[ "Modifies", "an", "existing", "Host", "." ]
f8cfc6e597741be593cf7fe013accadf982ee68b
https://github.com/HewlettPackard/hpe3par_ruby_sdk/blob/f8cfc6e597741be593cf7fe013accadf982ee68b/lib/Hpe3parSdk/client.rb#L966-L973
train
HewlettPackard/hpe3par_ruby_sdk
lib/Hpe3parSdk/client.rb
Hpe3parSdk.Client.delete_host
def delete_host(name) begin @host.delete_host(name) rescue => ex Util.log_exception(ex, caller_locations(1, 1)[0].label) raise ex end end
ruby
def delete_host(name) begin @host.delete_host(name) rescue => ex Util.log_exception(ex, caller_locations(1, 1)[0].label) raise ex end end
[ "def", "delete_host", "(", "name", ")", "begin", "@host", ".", "delete_host", "(", "name", ")", "rescue", "=>", "ex", "Util", ".", "log_exception", "(", "ex", ",", "caller_locations", "(", "1", ",", "1", ")", "[", "0", "]", ".", "label", ")", "raise"...
Deletes a host. ==== Attributes * name - The name of host to be deleted. type name: String ==== Raises * Hpe3parSdk::HTTPNotFound - NON_EXISTENT_HOST - Host not found * Hpe3parSdk::HTTPConflict - HOST_IN_SET - Host is a member of a set
[ "Deletes", "a", "host", "." ]
f8cfc6e597741be593cf7fe013accadf982ee68b
https://github.com/HewlettPackard/hpe3par_ruby_sdk/blob/f8cfc6e597741be593cf7fe013accadf982ee68b/lib/Hpe3parSdk/client.rb#L988-L995
train
HewlettPackard/hpe3par_ruby_sdk
lib/Hpe3parSdk/client.rb
Hpe3parSdk.Client.query_host_by_fc_path
def query_host_by_fc_path(wwn = nil) begin @host.query_host_by_fc_path(wwn) rescue => ex Util.log_exception(ex, caller_locations(1, 1)[0].label) raise ex end end
ruby
def query_host_by_fc_path(wwn = nil) begin @host.query_host_by_fc_path(wwn) rescue => ex Util.log_exception(ex, caller_locations(1, 1)[0].label) raise ex end end
[ "def", "query_host_by_fc_path", "(", "wwn", "=", "nil", ")", "begin", "@host", ".", "query_host_by_fc_path", "(", "wwn", ")", "rescue", "=>", "ex", "Util", ".", "log_exception", "(", "ex", ",", "caller_locations", "(", "1", ",", "1", ")", "[", "0", "]", ...
Finds the host with the specified FC WWN path. ==== Attributes * wwn - Lookup based on WWN. type wwn: String ==== Returns Host with specified FC WWN. ==== Raises * Hpe3parSdk::HTTPBadRequest - INV_INPUT - Invalid URI syntax. * Hpe3parSdk::HTTPNotFound - NON_EXISTENT_HOST - HOST Not Fo...
[ "Finds", "the", "host", "with", "the", "specified", "FC", "WWN", "path", "." ]
f8cfc6e597741be593cf7fe013accadf982ee68b
https://github.com/HewlettPackard/hpe3par_ruby_sdk/blob/f8cfc6e597741be593cf7fe013accadf982ee68b/lib/Hpe3parSdk/client.rb#L1018-L1025
train
HewlettPackard/hpe3par_ruby_sdk
lib/Hpe3parSdk/client.rb
Hpe3parSdk.Client.query_host_by_iscsi_path
def query_host_by_iscsi_path(iqn = nil) begin @host.query_host_by_iscsi_path(iqn) rescue => ex Util.log_exception(ex, caller_locations(1, 1)[0].label) raise ex end end
ruby
def query_host_by_iscsi_path(iqn = nil) begin @host.query_host_by_iscsi_path(iqn) rescue => ex Util.log_exception(ex, caller_locations(1, 1)[0].label) raise ex end end
[ "def", "query_host_by_iscsi_path", "(", "iqn", "=", "nil", ")", "begin", "@host", ".", "query_host_by_iscsi_path", "(", "iqn", ")", "rescue", "=>", "ex", "Util", ".", "log_exception", "(", "ex", ",", "caller_locations", "(", "1", ",", "1", ")", "[", "0", ...
Finds the host with the specified iSCSI initiator. ==== Attributes * iqn - Lookup based on iSCSI initiator. type iqn: String ==== Returns Host with specified IQN. ==== Raises * Hpe3parSdk::HTTPBadRequest - INV_INPUT - Invalid URI syntax. * Hpe3parSdk::HTTPNotFound - NON_EXISTENT_HOST ...
[ "Finds", "the", "host", "with", "the", "specified", "iSCSI", "initiator", "." ]
f8cfc6e597741be593cf7fe013accadf982ee68b
https://github.com/HewlettPackard/hpe3par_ruby_sdk/blob/f8cfc6e597741be593cf7fe013accadf982ee68b/lib/Hpe3parSdk/client.rb#L1048-L1055
train
HewlettPackard/hpe3par_ruby_sdk
lib/Hpe3parSdk/client.rb
Hpe3parSdk.Client.get_host_sets
def get_host_sets begin @host_set.get_host_sets rescue => ex Util.log_exception(ex, caller_locations(1, 1)[0].label) raise ex end end
ruby
def get_host_sets begin @host_set.get_host_sets rescue => ex Util.log_exception(ex, caller_locations(1, 1)[0].label) raise ex end end
[ "def", "get_host_sets", "begin", "@host_set", ".", "get_host_sets", "rescue", "=>", "ex", "Util", ".", "log_exception", "(", "ex", ",", "caller_locations", "(", "1", ",", "1", ")", "[", "0", "]", ".", "label", ")", "raise", "ex", "end", "end" ]
Gets all host sets. ==== Returns Array of HostSet.
[ "Gets", "all", "host", "sets", "." ]
f8cfc6e597741be593cf7fe013accadf982ee68b
https://github.com/HewlettPackard/hpe3par_ruby_sdk/blob/f8cfc6e597741be593cf7fe013accadf982ee68b/lib/Hpe3parSdk/client.rb#L1062-L1069
train
HewlettPackard/hpe3par_ruby_sdk
lib/Hpe3parSdk/client.rb
Hpe3parSdk.Client.delete_host_set
def delete_host_set(name) begin @host_set.delete_host_set(name) rescue => ex Util.log_exception(ex, caller_locations(1, 1)[0].label) raise ex end end
ruby
def delete_host_set(name) begin @host_set.delete_host_set(name) rescue => ex Util.log_exception(ex, caller_locations(1, 1)[0].label) raise ex end end
[ "def", "delete_host_set", "(", "name", ")", "begin", "@host_set", ".", "delete_host_set", "(", "name", ")", "rescue", "=>", "ex", "Util", ".", "log_exception", "(", "ex", ",", "caller_locations", "(", "1", ",", "1", ")", "[", "0", "]", ".", "label", ")...
Deletes a HostSet. ==== Attributes * name - The hostset to delete. type name: String ==== Raises * Hpe3parSdk::HTTPNotFound - NON_EXISTENT_SET - The set does not exists. * Hpe3parSdk::HTTPConflict - EXPORTED_VLUN - The host set has exported VLUNs.
[ "Deletes", "a", "HostSet", "." ]
f8cfc6e597741be593cf7fe013accadf982ee68b
https://github.com/HewlettPackard/hpe3par_ruby_sdk/blob/f8cfc6e597741be593cf7fe013accadf982ee68b/lib/Hpe3parSdk/client.rb#L1122-L1129
train