_id
stringlengths
2
6
title
stringlengths
9
130
partition
stringclasses
3 values
text
stringlengths
66
10.5k
language
stringclasses
1 value
meta_information
dict
q21900
BTC.Transaction.add_input
train
def add_input(txin) raise ArgumentError, "Input is missing" if !txin if !(txin.transaction == nil || txin.transaction == self) raise ArgumentError, "Can't add an input to a transaction when it references another transaction" # sanity check end txin.transaction = self txin.index = @inputs.size @inputs << txin self end
ruby
{ "resource": "" }
q21901
BTC.Data.data_from_hex
train
def data_from_hex(hex_string) raise ArgumentError, "Hex string is missing" if !hex_string hex_string = hex_string.strip data = [hex_string].pack(HEX_PACK_CODE) if hex_from_data(data) != hex_string.downcase # invalid hex string was detected raise FormatError, "Hex string is invalid: #{hex_string.inspect}" end return data end
ruby
{ "resource": "" }
q21902
BTC.OpenSSL.regenerate_keypair
train
def regenerate_keypair(private_key, public_key_compressed: false) autorelease do |pool| eckey = pool.new_ec_key priv_bn = pool.new_bn(private_key) pub_key = pool.new_ec_point EC_POINT_mul(self.group, pub_key, priv_bn, nil, nil, pool.bn_ctx) EC_KEY_set_private_key(eckey, priv_bn) EC_KEY_set_public_key(eckey, pub_key) length = i2d_ECPrivateKey(eckey, nil) buf = FFI::MemoryPointer.new(:uint8, length) if i2d_ECPrivateKey(eckey, pointer_to_pointer(buf)) == length # We have a full DER representation of private key, it contains a length # of a private key at offset 8 and private key at offset 9. size = buf.get_array_of_uint8(8, 1)[0] private_key2 = buf.get_array_of_uint8(9, size).pack("C*").rjust(32, "\x00") else raise BTCError, "OpenSSL failed to convert private key to DER format" end if private_key2 != private_key raise BTCError, "OpenSSL somehow regenerated a wrong private key." end EC_KEY_set_conv_form(eckey, public_key_compressed ? POINT_CONVERSION_COMPRESSED : POINT_CONVERSION_UNCOMPRESSED); length = i2o_ECPublicKey(eckey, nil) buf = FFI::MemoryPointer.new(:uint8, length) if i2o_ECPublicKey(eckey, pointer_to_pointer(buf)) == length public_key = buf.read_string(length) else raise BTCError, "OpenSSL failed to regenerate a public key." end [ private_key2, public_key ] end end
ruby
{ "resource": "" }
q21903
BTC.OpenSSL.private_key_from_der_format
train
def private_key_from_der_format(der_key) raise ArgumentError, "Missing DER private key" if !der_key prepare_if_needed buf = FFI::MemoryPointer.from_string(der_key) ec_key = d2i_ECPrivateKey(nil, pointer_to_pointer(buf), buf.size-1) if ec_key.null? raise BTCError, "OpenSSL failed to create EC_KEY with DER private key" end bn = EC_KEY_get0_private_key(ec_key) BN_bn2bin(bn, buf) buf.read_string(32) end
ruby
{ "resource": "" }
q21904
BTC.OpenSSL.data_from_bn
train
def data_from_bn(bn, min_length: nil, required_length: nil) raise ArgumentError, "Missing big number" if !bn length = BN_num_bytes(bn) buf = FFI::MemoryPointer.from_string("\x00"*length) BN_bn2bin(bn, buf) s = buf.read_string(length) s = s.rjust(min_length, "\x00") if min_length if required_length && s.bytesize != required_length raise BTCError, "Non-matching length of the number: #{s.bytesize} bytes vs required #{required_length}" end s end
ruby
{ "resource": "" }
q21905
BTC.WireFormat.encode_varint
train
def encode_varint(i) raise ArgumentError, "int must be present" if !i raise ArgumentError, "int must be non-negative" if i < 0 buf = if i < 0xfd [i].pack("C") elsif i <= 0xffff [0xfd, i].pack("Cv") elsif i <= 0xffffffff [0xfe, i].pack("CV") elsif i <= 0xffffffffffffffff [0xff, i].pack("CQ<") else raise ArgumentError, "Does not support integers larger 0xffffffffffffffff (i = 0x#{i.to_s(16)})" end buf end
ruby
{ "resource": "" }
q21906
BTC.WireFormat.write_varint
train
def write_varint(i, data: nil, stream: nil) buf = encode_varint(i) data << buf if data stream.write(buf) if stream buf end
ruby
{ "resource": "" }
q21907
BTC.WireFormat.encode_string
train
def encode_string(string) raise ArgumentError, "String must be present" if !string encode_varint(string.bytesize) + BTC::Data.ensure_binary_encoding(string) end
ruby
{ "resource": "" }
q21908
BTC.WireFormat.write_string
train
def write_string(string, data: nil, stream: nil) raise ArgumentError, "String must be present" if !string intbuf = write_varint(string.bytesize, data: data, stream: stream) stringbuf = BTC::Data.ensure_binary_encoding(string) data << stringbuf if data stream.write(stringbuf) if stream intbuf + stringbuf end
ruby
{ "resource": "" }
q21909
BTC.WireFormat.read_array
train
def read_array(data: nil, stream: nil, offset: 0) count, len = read_varint(data: data, stream: stream, offset: offset) return [nil, len] if !count (0...count).map do |i| yield end end
ruby
{ "resource": "" }
q21910
BTC.WireFormat.encode_uleb128
train
def encode_uleb128(value) raise ArgumentError, "Signed integers are not supported" if value < 0 return "\x00" if value == 0 bytes = [] while value != 0 byte = value & 0b01111111 # 0x7f value >>= 7 if value != 0 byte |= 0b10000000 # 0x80 end bytes << byte end return BTC::Data.data_from_bytes(bytes) end
ruby
{ "resource": "" }
q21911
BTC.WireFormat.write_uleb128
train
def write_uleb128(value, data: nil, stream: nil) raise ArgumentError, "Integer must be present" if !value buf = encode_uleb128(value) data << buf if data stream.write(buf) if stream buf end
ruby
{ "resource": "" }
q21912
Preferences.InstanceMethods.preferences
train
def preferences(group = nil) preferences = preferences_group(group) unless preferences_group_loaded?(group) group_id, group_type = Preference.split_group(group) find_preferences(:group_id => group_id, :group_type => group_type).each do |preference| preferences[preference.name] = preference.value unless preferences.include?(preference.name) end # Add defaults preference_definitions.each do |name, definition| preferences[name] = definition.default_value(group_type) unless preferences.include?(name) end end preferences.inject({}) do |typed_preferences, (name, value)| typed_preferences[name] = value.nil? ? value : preference_definitions[name].type_cast(value) typed_preferences end end
ruby
{ "resource": "" }
q21913
Preferences.InstanceMethods.preferred?
train
def preferred?(name, group = nil) name = name.to_s assert_valid_preference(name) value = preferred(name, group) preference_definitions[name].query(value) end
ruby
{ "resource": "" }
q21914
Preferences.InstanceMethods.preferred
train
def preferred(name, group = nil) name = name.to_s assert_valid_preference(name) if preferences_group(group).include?(name) # Value for this group/name has been written, but not saved yet: # grab from the pending values value = preferences_group(group)[name] else # Grab the first preference; if it doesn't exist, use the default value group_id, group_type = Preference.split_group(group) preference = find_preferences(:name => name, :group_id => group_id, :group_type => group_type).first unless preferences_group_loaded?(group) value = preference ? preference.value : preference_definitions[name].default_value(group_type) preferences_group(group)[name] = value end definition = preference_definitions[name] value = definition.type_cast(value) unless value.nil? value end
ruby
{ "resource": "" }
q21915
Preferences.InstanceMethods.preference_changes
train
def preference_changes(group = nil) preferences_changed(group).inject({}) do |changes, preference| changes[preference] = preference_change(preference, group) changes end end
ruby
{ "resource": "" }
q21916
Preferences.InstanceMethods.preference_was
train
def preference_was(name, group) preference_changed?(name, group) ? preferences_changed_group(group)[name] : preferred(name, group) end
ruby
{ "resource": "" }
q21917
Preferences.InstanceMethods.reset_preference!
train
def reset_preference!(name, group) write_preference(name, preferences_changed_group(group)[name], group) if preference_changed?(name, group) end
ruby
{ "resource": "" }
q21918
Preferences.InstanceMethods.preference_value_changed?
train
def preference_value_changed?(name, old, value) definition = preference_definitions[name] if definition.type == :integer && (old.nil? || old == 0) # For nullable numeric columns, NULL gets stored in database for blank (i.e. '') values. # Hence we don't record it as a change if the value changes from nil to ''. # If an old value of 0 is set to '' we want this to get changed to nil as otherwise it'll # be typecast back to 0 (''.to_i => 0) value = nil if value.blank? else value = definition.type_cast(value) end old != value end
ruby
{ "resource": "" }
q21919
Preferences.InstanceMethods.find_preferences
train
def find_preferences(attributes) if stored_preferences.loaded? stored_preferences.select do |preference| attributes.all? {|attribute, value| preference[attribute] == value} end else stored_preferences.find(:all, :conditions => attributes) end end
ruby
{ "resource": "" }
q21920
DBus.ProxyObject.[]
train
def [](intfname) introspect unless introspected ifc = @interfaces[intfname] raise DBus::Error, "no such interface `#{intfname}' on object `#{@path}'" unless ifc ifc end
ruby
{ "resource": "" }
q21921
DBus.ProxyObjectInterface.define_method_from_descriptor
train
def define_method_from_descriptor(m) m.params.each do |fpar| par = fpar.type # This is the signature validity check Type::Parser.new(par).parse end singleton_class.class_eval do define_method m.name do |*args, &reply_handler| if m.params.size != args.size raise ArgumentError, "wrong number of arguments (#{args.size} for #{m.params.size})" end msg = Message.new(Message::METHOD_CALL) msg.path = @object.path msg.interface = @name msg.destination = @object.destination msg.member = m.name msg.sender = @object.bus.unique_name m.params.each do |fpar| par = fpar.type msg.add_param(par, args.shift) end ret = @object.bus.send_sync_or_async(msg, &reply_handler) if ret.nil? || @object.api.proxy_method_returns_array ret else m.rets.size == 1 ? ret.first : ret end end end @methods[m.name] = m end
ruby
{ "resource": "" }
q21922
DBus.ProxyObjectInterface.define
train
def define(m) if m.is_a?(Method) define_method_from_descriptor(m) elsif m.is_a?(Signal) define_signal_from_descriptor(m) end end
ruby
{ "resource": "" }
q21923
DBus.ProxyObjectInterface.define_method
train
def define_method(methodname, prototype) m = Method.new(methodname) m.from_prototype(prototype) define(m) end
ruby
{ "resource": "" }
q21924
DBus.ProxyObjectInterface.[]
train
def [](propname) ret = object[PROPERTY_INTERFACE].Get(name, propname) # this method always returns the single property if @object.api.proxy_method_returns_array ret[0] else ret end end
ruby
{ "resource": "" }
q21925
DBus.ProxyObjectInterface.all_properties
train
def all_properties ret = object[PROPERTY_INTERFACE].GetAll(name) # this method always returns the single property if @object.api.proxy_method_returns_array ret[0] else ret end end
ruby
{ "resource": "" }
q21926
DBus.MessageQueue.connect
train
def connect addresses = @address.split ";" # connect to first one that succeeds worked = addresses.find do |a| transport, keyvaluestring = a.split ":" kv_list = keyvaluestring.split "," kv_hash = {} kv_list.each do |kv| key, escaped_value = kv.split "=" value = escaped_value.gsub(/%(..)/) { |_m| [Regexp.last_match(1)].pack "H2" } kv_hash[key] = value end case transport when "unix" connect_to_unix kv_hash when "tcp" connect_to_tcp kv_hash when "launchd" connect_to_launchd kv_hash else # ignore, report? end end worked # returns the address that worked or nil. # how to report failure? end
ruby
{ "resource": "" }
q21927
DBus.MessageQueue.connect_to_tcp
train
def connect_to_tcp(params) # check if the path is sufficient if params.key?("host") && params.key?("port") begin # initialize the tcp socket @socket = TCPSocket.new(params["host"], params["port"].to_i) @socket.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC) init_connection @is_tcp = true rescue Exception => e puts "Oops:", e puts "Error: Could not establish connection to: #{@path}, will now exit." exit(1) # a little harsh end else # Danger, Will Robinson: the specified "path" is not usable puts "Error: supplied path: #{@path}, unusable! sorry." end end
ruby
{ "resource": "" }
q21928
DBus.MessageQueue.connect_to_unix
train
def connect_to_unix(params) @socket = Socket.new(Socket::Constants::PF_UNIX, Socket::Constants::SOCK_STREAM, 0) @socket.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC) if !params["abstract"].nil? sockaddr = if HOST_END == LIL_END "\1\0\0#{params["abstract"]}" else "\0\1\0#{params["abstract"]}" end elsif !params["path"].nil? sockaddr = Socket.pack_sockaddr_un(params["path"]) end @socket.connect(sockaddr) init_connection end
ruby
{ "resource": "" }
q21929
DBus.Message.add_param
train
def add_param(type, val) type = type.chr if type.is_a?(Integer) @signature += type.to_s @params << [type, val] end
ruby
{ "resource": "" }
q21930
DBus.Message.marshall
train
def marshall if @path == "/org/freedesktop/DBus/Local" raise InvalidDestinationName end params = PacketMarshaller.new @params.each do |param| params.append(param[0], param[1]) end @body_length = params.packet.bytesize marshaller = PacketMarshaller.new marshaller.append(Type::BYTE, HOST_END) marshaller.append(Type::BYTE, @message_type) marshaller.append(Type::BYTE, @flags) marshaller.append(Type::BYTE, @protocol) marshaller.append(Type::UINT32, @body_length) marshaller.append(Type::UINT32, @serial) headers = [] headers << [PATH, ["o", @path]] if @path headers << [INTERFACE, ["s", @interface]] if @interface headers << [MEMBER, ["s", @member]] if @member headers << [ERROR_NAME, ["s", @error_name]] if @error_name headers << [REPLY_SERIAL, ["u", @reply_serial]] if @reply_serial headers << [DESTINATION, ["s", @destination]] if @destination # SENDER is not sent, the message bus fills it in instead headers << [SIGNATURE, ["g", @signature]] if @signature != "" marshaller.append("a(yv)", headers) marshaller.align(8) @params.each do |param| marshaller.append(param[0], param[1]) end marshaller.packet end
ruby
{ "resource": "" }
q21931
DBus.Message.unmarshall_buffer
train
def unmarshall_buffer(buf) buf = buf.dup endianness = if buf[0] == "l" LIL_END else BIG_END end pu = PacketUnmarshaller.new(buf, endianness) mdata = pu.unmarshall(MESSAGE_SIGNATURE) _, @message_type, @flags, @protocol, @body_length, @serial, headers = mdata headers.each do |struct| case struct[0] when PATH @path = struct[1] when INTERFACE @interface = struct[1] when MEMBER @member = struct[1] when ERROR_NAME @error_name = struct[1] when REPLY_SERIAL @reply_serial = struct[1] when DESTINATION @destination = struct[1] when SENDER @sender = struct[1] when SIGNATURE @signature = struct[1] end end pu.align(8) if @body_length > 0 && @signature @params = pu.unmarshall(@signature, @body_length) end [self, pu.idx] end
ruby
{ "resource": "" }
q21932
DBus.Message.annotate_exception
train
def annotate_exception(ex) new_ex = ex.exception("#{ex}; caused by #{self}") new_ex.set_backtrace(ex.backtrace) new_ex end
ruby
{ "resource": "" }
q21933
DBus.PacketUnmarshaller.unmarshall
train
def unmarshall(signature, len = nil) if !len.nil? if @buffy.bytesize < @idx + len raise IncompleteBufferException end end sigtree = Type::Parser.new(signature).parse ret = [] sigtree.each do |elem| ret << do_parse(elem) end ret end
ruby
{ "resource": "" }
q21934
DBus.PacketUnmarshaller.align
train
def align(a) case a when 1 nil when 2, 4, 8 bits = a - 1 @idx = @idx + bits & ~bits raise IncompleteBufferException if @idx > @buffy.bytesize else raise "Unsupported alignment #{a}" end end
ruby
{ "resource": "" }
q21935
DBus.PacketUnmarshaller.read
train
def read(nbytes) raise IncompleteBufferException if @idx + nbytes > @buffy.bytesize ret = @buffy.slice(@idx, nbytes) @idx += nbytes ret end
ruby
{ "resource": "" }
q21936
DBus.PacketUnmarshaller.read_string
train
def read_string align(4) str_sz = read(4).unpack(@uint32)[0] ret = @buffy.slice(@idx, str_sz) raise IncompleteBufferException if @idx + str_sz + 1 > @buffy.bytesize @idx += str_sz if @buffy[@idx].ord != 0 raise InvalidPacketException, "String is not nul-terminated" end @idx += 1 # no exception, see check above ret end
ruby
{ "resource": "" }
q21937
DBus.PacketUnmarshaller.read_signature
train
def read_signature str_sz = read(1).unpack("C")[0] ret = @buffy.slice(@idx, str_sz) raise IncompleteBufferException if @idx + str_sz + 1 >= @buffy.bytesize @idx += str_sz if @buffy[@idx].ord != 0 raise InvalidPacketException, "Type is not nul-terminated" end @idx += 1 # no exception, see check above ret end
ruby
{ "resource": "" }
q21938
DBus.PacketMarshaller.num_align
train
def num_align(n, a) case a when 1, 2, 4, 8 bits = a - 1 n + bits & ~bits else raise "Unsupported alignment" end end
ruby
{ "resource": "" }
q21939
DBus.PacketMarshaller.array
train
def array(type) # Thanks to Peter Rullmann for this line align(4) sizeidx = @packet.bytesize @packet += "ABCD" align(type.alignment) contentidx = @packet.bytesize yield sz = @packet.bytesize - contentidx raise InvalidPacketException if sz > 67_108_864 @packet[sizeidx...sizeidx + 4] = [sz].pack("L") end
ruby
{ "resource": "" }
q21940
DBus.Service.object
train
def object(path, api: ApiOptions::A0) node = get_node(path, _create = true) if node.object.nil? || node.object.api != api node.object = ProxyObject.new( @bus, @name, path, api: api ) end node.object end
ruby
{ "resource": "" }
q21941
DBus.Service.get_node
train
def get_node(path, create = false) n = @root path.sub(%r{^/}, "").split("/").each do |elem| if !(n[elem]) return nil if !create n[elem] = Node.new(elem) end n = n[elem] end if n.nil? DBus.logger.debug "Warning, unknown object #{path}" end n end
ruby
{ "resource": "" }
q21942
DBus.Service.rec_introspect
train
def rec_introspect(node, path) xml = bus.introspect_data(@name, path) intfs, subnodes = IntrospectXMLParser.new(xml).parse subnodes.each do |nodename| subnode = node[nodename] = Node.new(nodename) subpath = if path == "/" "/" + nodename else path + "/" + nodename end rec_introspect(subnode, subpath) end return if intfs.empty? node.object = ProxyObjectFactory.new(xml, @bus, @name, path).build end
ruby
{ "resource": "" }
q21943
DBus.Node.to_xml
train
def to_xml xml = '<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd"> <node> ' each_pair do |k, _v| xml += "<node name=\"#{k}\" />" end if @object @object.intfs.each_pair do |_k, v| xml += %(<interface name="#{v.name}">\n) v.methods.each_value { |m| xml += m.to_xml } v.signals.each_value { |m| xml += m.to_xml } xml += "</interface>\n" end end xml += "</node>" xml end
ruby
{ "resource": "" }
q21944
DBus.Connection.glibize
train
def glibize require "glib2" # Circumvent a ruby-glib bug @channels ||= [] gio = GLib::IOChannel.new(@message_queue.socket.fileno) @channels << gio gio.add_watch(GLib::IOChannel::IN) do |_c, _ch| dispatch_message_queue true end end
ruby
{ "resource": "" }
q21945
DBus.Connection.request_service
train
def request_service(name) # Use RequestName, but asynchronously! # A synchronous call would not work with service activation, where # method calls to be serviced arrive before the reply for RequestName # (Ticket#29). proxy.RequestName(name, NAME_FLAG_REPLACE_EXISTING) do |rmsg, r| # check and report errors first raise rmsg if rmsg.is_a?(Error) raise NameRequestError unless r == REQUEST_NAME_REPLY_PRIMARY_OWNER end @service = Service.new(name, self) @service end
ruby
{ "resource": "" }
q21946
DBus.Connection.proxy
train
def proxy if @proxy.nil? path = "/org/freedesktop/DBus" dest = "org.freedesktop.DBus" pof = DBus::ProxyObjectFactory.new( DBUSXMLINTRO, self, dest, path, api: ApiOptions::A0 ) @proxy = pof.build["org.freedesktop.DBus"] end @proxy end
ruby
{ "resource": "" }
q21947
DBus.Connection.add_match
train
def add_match(mr, &slot) # check this is a signal. mrs = mr.to_s DBus.logger.debug "#{@signal_matchrules.size} rules, adding #{mrs.inspect}" # don't ask for the same match if we override it unless @signal_matchrules.key?(mrs) DBus.logger.debug "Asked for a new match" proxy.AddMatch(mrs) end @signal_matchrules[mrs] = slot end
ruby
{ "resource": "" }
q21948
DBus.Connection.send_hello
train
def send_hello m = Message.new(DBus::Message::METHOD_CALL) m.path = "/org/freedesktop/DBus" m.destination = "org.freedesktop.DBus" m.interface = "org.freedesktop.DBus" m.member = "Hello" send_sync(m) do |rmsg| @unique_name = rmsg.destination DBus.logger.debug "Got hello reply. Our unique_name is #{@unique_name}" end @service = Service.new(@unique_name, self) end
ruby
{ "resource": "" }
q21949
DBus.Main.run
train
def run # before blocking, empty the buffers # https://bugzilla.novell.com/show_bug.cgi?id=537401 @buses.each_value do |b| while (m = b.message_queue.message_from_buffer_nonblock) b.process(m) end end while !@quitting && !@buses.empty? ready = IO.select(@buses.keys, [], [], 5) # timeout 5 seconds next unless ready # timeout exceeds so continue unless quitting ready.first.each do |socket| b = @buses[socket] begin b.message_queue.buffer_from_socket_nonblock rescue EOFError, SystemCallError @buses.delete socket # this bus died next end while (m = b.message_queue.message_from_buffer_nonblock) b.process(m) end end end end
ruby
{ "resource": "" }
q21950
DBus.External.authenticate
train
def authenticate # Take the user id (eg integer 1000) make a string out of it "1000", take # each character and determin hex value "1" => 0x31, "0" => 0x30. You # obtain for "1000" => 31303030 This is what the server is expecting. # Why? I dunno. How did I come to that conclusion? by looking at rbus # code. I have no idea how he found that out. Process.uid.to_s.split(//).map { |d| d.ord.to_s(16) }.join end
ruby
{ "resource": "" }
q21951
DBus.DBusCookieSHA1.hex_decode
train
def hex_decode(encoded) encoded.scan(/[[:xdigit:]]{2}/).map { |h| h.hex.chr }.join end
ruby
{ "resource": "" }
q21952
DBus.Client.authenticate
train
def authenticate if RbConfig::CONFIG["target_os"] =~ /freebsd/ @socket.sendmsg(0.chr, 0, nil, [:SOCKET, :SCM_CREDS, ""]) else @socket.write(0.chr) end next_authenticator @state = :Starting while @state != :Authenticated r = next_state return r if !r end true end
ruby
{ "resource": "" }
q21953
DBus.Client.next_authenticator
train
def next_authenticator raise AuthenticationFailed if @auth_list.empty? @authenticator = @auth_list.shift.new auth_msg = ["AUTH", @authenticator.name, @authenticator.authenticate] DBus.logger.debug "auth_msg: #{auth_msg.inspect}" send(auth_msg) rescue AuthenticationFailed @socket.close raise end
ruby
{ "resource": "" }
q21954
DBus.Interface.validate_name
train
def validate_name(name) raise InvalidIntrospectionData if name.bytesize > 255 raise InvalidIntrospectionData if name =~ /^\./ || name =~ /\.$/ raise InvalidIntrospectionData if name =~ /\.\./ raise InvalidIntrospectionData if name !~ /\./ name.split(".").each do |element| raise InvalidIntrospectionData if element !~ INTERFACE_ELEMENT_RE end end
ruby
{ "resource": "" }
q21955
DBus.Interface.define
train
def define(m) if m.is_a?(Method) @methods[m.name.to_sym] = m elsif m.is_a?(Signal) @signals[m.name.to_sym] = m end end
ruby
{ "resource": "" }
q21956
DBus.Interface.define_method
train
def define_method(id, prototype) m = Method.new(id) m.from_prototype(prototype) define(m) end
ruby
{ "resource": "" }
q21957
DBus.Method.from_prototype
train
def from_prototype(prototype) prototype.split(/, */).each do |arg| arg = arg.split(" ") raise InvalidClassDefinition if arg.size != 2 dir, arg = arg if arg =~ /:/ arg = arg.split(":") name, sig = arg else sig = arg end case dir when "in" add_fparam(name, sig) when "out" add_return(name, sig) end end self end
ruby
{ "resource": "" }
q21958
DBus.Method.to_xml
train
def to_xml xml = %(<method name="#{@name}">\n) @params.each do |param| name = param.name ? %(name="#{param.name}" ) : "" xml += %(<arg #{name}direction="in" type="#{param.type}"/>\n) end @rets.each do |param| name = param.name ? %(name="#{param.name}" ) : "" xml += %(<arg #{name}direction="out" type="#{param.type}"/>\n) end xml += %(</method>\n) xml end
ruby
{ "resource": "" }
q21959
DBus.Signal.from_prototype
train
def from_prototype(prototype) prototype.split(/, */).each do |arg| if arg =~ /:/ arg = arg.split(":") name, sig = arg else sig = arg end add_fparam(name, sig) end self end
ruby
{ "resource": "" }
q21960
DBus.Signal.to_xml
train
def to_xml xml = %(<signal name="#{@name}">\n) @params.each do |param| name = param.name ? %(name="#{param.name}" ) : "" xml += %(<arg #{name}type="#{param.type}"/>\n) end xml += %(</signal>\n) xml end
ruby
{ "resource": "" }
q21961
DBus.MatchRule.from_s
train
def from_s(str) str.split(",").each do |eq| next unless eq =~ /^(.*)='([^']*)'$/ # " name = Regexp.last_match(1) val = Regexp.last_match(2) raise MatchRuleException, name unless FILTERS.member?(name.to_sym) method(name + "=").call(val) end self end
ruby
{ "resource": "" }
q21962
DBus.MatchRule.from_signal
train
def from_signal(intf, signal) signal = signal.name unless signal.is_a?(String) self.type = "signal" self.interface = intf.name self.member = signal self.path = intf.object.path self end
ruby
{ "resource": "" }
q21963
DBus.MatchRule.match
train
def match(msg) if @type if { Message::SIGNAL => "signal", Message::METHOD_CALL => "method_call", Message::METHOD_RETURN => "method_return", Message::ERROR => "error" }[msg.message_type] != @type return false end end return false if @interface && @interface != msg.interface return false if @member && @member != msg.member return false if @path && @path != msg.path # FIXME: sender and destination are ignored true end
ruby
{ "resource": "" }
q21964
ScreenObject.Accessors.button
train
def button(name, locator) # generates method for clicking button. # this method will not return any value. # @example click on 'Submit' button. # button(:login_button,"xpath~//UIButtonField") # def click_login_button # login_button # This will click on the button. # end define_method(name) do ScreenObject::AppElements::Button.new(locator).tap end # generates method for checking the existence of the button. # this method will return true or false based on object displayed or not. # @example check if 'Submit' button exists on the screen. # button(:login_button,"xpath~//UIButtonField") # DSL to check existence of login button # def check_login_button # login_button? # This will return true or false based on existence of button. # end define_method("#{name}?") do ScreenObject::AppElements::Button.new(locator).exists? end # generates method for checking if button is enabled. # this method will return true if button is enabled otherwise false. # @example check if 'Submit' button enabled on the screen. # button(:login_button,"xpath~//UIButtonField") # DSL to check if button is enabled or not # def enable_login_button # login_button_enabled? # This will return true or false if button is enabled or disabled. # end define_method("#{name}_enabled?") do ScreenObject::AppElements::Button.new(locator).enabled? end # generates method for getting text for value attribute. # this method will return the text containing into value attribute. # @example To retrieve text from value attribute of the defined object i.e. 'Submit' button. # button(:login_button,"xpath~//UIButtonField") # DSL to retrieve text for value attribute. # def value_login_button # login_button_value # This will return the text of the value attribute of the 'Submit' button object. # end define_method("#{name}_value") do ScreenObject::AppElements::Button.new(locator).value end # generates method for scrolling on the screen and click on the button. # this should be used for iOS platform. # scroll to the first element with exact target static text or name. # this method will not return any value. # button(:login_button,"xpath~//UIButtonField") # def scroll_button # login_button_scroll # This will not return any value. It will scroll on the screen until object found and click # on the object i.e. button. This is iOS specific method and should not be used for android application # end define_method("#{name}_scroll") do # direction = options[:direction] || 'down' ScreenObject::AppElements::Button.new(locator).scroll_for_element_click end # generates method for scrolling on iOS application screen and click on button. This method should be used when button text is dynamic.. # this should be used for iOS platform. # scroll to the first element with exact target dynamic text or name. # this method will not return any value. # @param [text] is the actual text of the button containing. # DSL to scroll on iOS application screen and click on button. This method should be used when button text is dynamic.. # button(:login_button,"UIButtonField") # button API should have class name as shown in this example. # OR # button(:login_button,"UIButtonField/UIButtonFieldtext") # button API should have class name as shown in this example. # def scroll_button # login_button_scroll_dynamic(text) # This will not return any value. we need to pass button text or name as parameter. # It will scroll on the screen until object with same name found and click on # the object i.e. button. This is iOS specific method and should not be used # for android application. # end define_method("#{name}_scroll_dynamic") do |text| # direction = options[:direction] || 'down' ScreenObject::AppElements::Button.new(locator).scroll_for_dynamic_element_click(text) end # generates method for scrolling on Android application screen and click on button. This method should be used when button text is static... # this should be used for Android platform. # scroll to the first element containing target static text or name. # this method will not return any value. # DSL to scroll on Android application screen and click on button. This method should be used when button text is static... # @param [text] is the actual text of the button containing. # button(:login_button,"xpath~//UIButtonField") # def scroll_button # login_button_scroll_(text) # This will not return any value. we need to pass button text or # name[containing targeted text or name] as parameter.It will scroll on the # screen until object with same name found and click on the # object i.e. button. This is Android specific method and should not be used # for iOS application. This method matches with containing text for the # button on the screen and click on it. # end define_method("#{name}_scroll_") do |text| ScreenObject::AppElements::Button.new(locator).click_text(text) end # generates method for scrolling on Android application screen and click on button. This method should be used when button text is dynamic...... # this should be used for Android platform. # scroll to the first element containing target dynamic text or name. # this method will not return any value. # DSL to scroll on Android application screen and click on button. This method should be used when button text is dynamic...... # @param [text] is the actual text of the button containing. # button(:login_button,"UIButtonField") # button API should have class name as shown in this example. # OR # button(:login_button,"UIButtonField/UIButtonFieldtext") # button API should have class name as shown in this example. # # def scroll_button # login_button_scroll_dynamic_(text) # This will not return any value. we need to pass button text or name # [containing targeted text or name] as parameter.It will scroll on the screen # until object with same name found and click on the object i.e. button. # This is Android specific method and should not be used for iOS application. # This method matches with containing text for the button on the screen and click on it. # # end define_method("#{name}_scroll_dynamic_") do |text| ScreenObject::AppElements::Button.new(locator).click_dynamic_text(text) end # generates method for scrolling on the screen and click on the button. # this should be used for Android platform. # scroll to the first element with exact target static text or name. # this method will not return any value. # DSL to scroll on Android application screen and click on button. This method should be used when button text is static. it matches with exact text. # @param [text] is the actual text of the button containing. # button(:login_button,"xpath~//UIButtonField") # def scroll_button # login_button_scroll_exact_(text) # This will not return any value. we need to pass button text or name # [EXACT text or name] as parameter. It will scroll on the screen until # object with same name found and click on the object i.e. button. # This is Android specific method and should not be used for iOS application. # This method matches with exact text for the button on the screen and click on it. # # end define_method("#{name}_scroll_exact_") do |text| ScreenObject::AppElements::Button.new(locator).click_exact_text(text) end #generates method for scrolling on the screen and click on the button. #This should be used for Android platform. # Scroll to the first element with exact target dynamic text or name. # this method will not return any value. # DSL to scroll on Android application screen and click on button. This method should be used when button text is dynamic. it matches with exact text. # @param [text] is the actual text of the button containing. # button(:login_button,"UIButtonField") # button API should have class name as shown in this example. # OR # button(:login_button,"UIButtonField/UIButtonFieldtext") # button API should have class name as shown in this example. # def scroll_button # login_button_scroll_dynamic_exact_(text) # This will not return any value. we need to pass button text or name # [EXACT text or name] as parameter. It will scroll on the screen until object # with same name found and click on the object i.e. button. This is Android specific # method and should not be used for iOS application. This method matches with exact # text for the button on the screen and click on it. # # end define_method("#{name}_scroll_dynamic_exact_") do |text| ScreenObject::AppElements::Button.new(locator).click_dynamic_exact_text(text) end end
ruby
{ "resource": "" }
q21965
ScreenObject.Accessors.checkbox
train
def checkbox(name, locator) # generates method for checking the checkbox object. # this will not return any value # @example check if 'remember me' checkbox is not checked. # checkbox(:remember_me,"xpath~//UICheckBox") # DSL to check the 'remember me' check box. # def check_remember_me_checkbox # check_remember_me # This method will check the check box. # end define_method("check_#{name}") do ScreenObject::AppElements::CheckBox.new(locator).check end # generates method for un-checking the checkbox. # this will not return any value # @example uncheck if 'remember me' check box is checked. # DSL to uncheck remember me check box # def uncheck_remember_me_check_box # uncheck_remember_me # This method will uncheck the check box if it's checked. # end define_method("uncheck_#{name}") do ScreenObject::AppElements::CheckBox.new(locator).uncheck end # generates method for checking the existence of object. # this will return true or false based on object is displayed or not. # @example check if 'remember me' check box exists on the screen. # def exist_remember_me_check_box # remember_me? # This method is used to return true or false based on 'remember me' check box exist. # end define_method("#{name}?") do ScreenObject::AppElements::CheckBox.new(locator).exists? end # generates method for checking if checkbox is already checked. # this will return true if checkbox is checked. # @example check if 'remember me' check box is not checked. # def exist_remember_me_check_box # remember_me? # This method is used to return true or false based on 'remember me' check box exist. # end define_method("#{name}_checked?") do ScreenObject::AppElements::CheckBox.new(locator).checked? end end
ruby
{ "resource": "" }
q21966
ScreenObject.Accessors.text
train
def text(name,locator) # generates method for clicking button. # this method will not return any value. # @example click on 'Submit' button. # button(:login_button,"xpath~//UIButtonField") # def click_login_button # login_button # This will click on the button. # end define_method(name) do ScreenObject::AppElements::Text.new(locator).tap end # generates method for checking if text exists on the screen. # this will return true or false based on if text is available or not # @example check if 'Welcome' text is displayed on the page # text(:welcome_text,"xpath~//UITextField") # # DSL for clicking the Welcome text. # def verify_welcome_text # welcome_text? # This will check if object exists and return true.. # end define_method("#{name}?") do ScreenObject::AppElements::Text.new(locator).exists? end # generates method for clicking on text object. # this will NOT return any value. # @example check if 'Welcome' text is displayed on the page # text(:welcome_text,"xpath~//UITextField") # DSL for clicking the Welcome text. # def click_welcome_text # welcome_text # This will click on the Welcome text on the screen. # end define_method("#{name}") do ScreenObject::AppElements::Text.new(locator).click end # generates method for retrieving text of the object. # this will return value of text attribute of the object. # @example retrieve text of 'Welcome' object on the page. # text(:welcome_text,"xpath~//UITextField") # DSL to retrieve text of the attribute text. # def get_welcome_text # welcome_text_text # This will return text of value of attribute 'text'. # end define_method("#{name}_text") do ScreenObject::AppElements::Text.new(locator).text end # generates method for checking dynamic text object. # this will return true or false based on object is displayed or not. # @example check if 'Welcome' text is displayed on the page # @param [text] is the actual text of the button containing. # suppose 'Welcome guest' text appears on the screen for non logged in user and it changes when user logged in on the screen and appears as 'Welcome <guest_name>'. this would be treated as dynamic text since it would be changing based on guest name. # DSL to check if the text that is sent as argument exists on the screen. Returns true or false # text(:welcome_guest,"xpath~//UITextField") # def dynamic_welcome_guest(Welcome_<guest_name>) # welcome_text_dynamic?(welcome_<guest_name>) # This will return true or false based welcome text exists on the screen. # end define_method("#{name}_dynamic?") do |text| ScreenObject::AppElements::Text.new(locator).dynamic_text_exists?(text) end # generates method for retrieving text of the value attribute of the object. # this will return text of value attribute of the object. # @example retrieve text of the 'Welcome' text. # text(:welcome_text,"xpath~//UITextField") # DSL to retrieve text of the attribute text. # def get_welcome_text # welcome_text_value # This will return text of value of attribute 'text'. # end define_method("#{name}_value") do ScreenObject::AppElements::Text.new(locator).value end # generates method for checking dynamic text object. # this will return actual test for an object. # @example check if 'Welcome' text is displayed on the page # @param [text] is the actual text of the button containing. # suppose 'Welcome guest' text appears on the screen for non logged in user and it changes when user logged in on the screen and appears as 'Welcome <guest_name>'. this would be treated as dynamic text since it would be changing based on guest name. # DSL to check if the text that is sent as argument exists on the screen. Returns true or false # text(:welcome_guest,"xpath~//UITextField") # def dynamic_welcome_guest(Welcome_<guest_name>) # welcome_text_dynamic?(welcome_<guest_name>) # This will return true or false based welcome text exists on the screen. # end define_method("#{name}_dynamic_text") do |text| ScreenObject::AppElements::Text.new(locator).dynamic_text(text) end end
ruby
{ "resource": "" }
q21967
ScreenObject.Accessors.text_field
train
def text_field(name,locator) # generates method for setting text into text field. # There is no return value for this method. # @example setting username field. # DSL for entering text in username text field. # def set_username_text_field(username) # self.username=username # This method will enter text into username text field. # end define_method("#{name}=") do |text| ScreenObject::AppElements::TextField.new(locator).text=(text) end # generates method for comparing expected and actual text. # this will return text of text attribute of the object. # @example retrieve text of the 'username' text field. # text_field(:username,"xpath~//UITextField") # DSL to retrieve text of the attribute text. # def get_welcome_text # username_text # This will return text containing in text field attribute. # end define_method("#{name}") do ScreenObject::AppElements::TextField.new(locator).text end # generates method for clear pre populated text from the text field. # this will not return any value. # @example clear text of the username text field. # text_field(:username,"xpath~//UITextField") # DSL to clear the text of the text field. # def clear_text # clear_username # This will clear the pre populated user name text field. # end define_method("clear_#{name}") do ScreenObject::AppElements::TextField.new(locator).clear end # generates method for checking if text_field exists on the screen. # this will return true or false based on if text field is available or not # @example check if 'username' text field is displayed on the page # text_field(:username,"xpath~//UITextField") # # DSL for clicking the username text. # def exists_username # username? # This will return if object exists on the screen. # end define_method("#{name}?") do ScreenObject::AppElements::TextField.new(locator).exists? end # generates method for retrieving text of the value attribute of the object. # this will return text of value attribute of the object. # @example retrieve text of the 'username' text_field. # text_field(:username,"xpath~//UITextField") # DSL to retrieve text of the attribute text. # def get_username_text # username_value # This will return text of value of attribute 'text'. # end define_method("#{name}_value") do ScreenObject::AppElements::TextField.new(locator).value end # generates method for checking if button is enabled. # this method will return true if button is enabled otherwise false. # @example check if 'Submit' button enabled on the screen. # button(:login_button,"xpath~//UIButtonField") # DSL to check if button is enabled or not # def enable_login_button # login_button_enabled? # This will return true or false if button is enabled or disabled. # end define_method("#{name}_enabled?") do ScreenObject::AppElements::TextField.new(locator).enabled? end end
ruby
{ "resource": "" }
q21968
ScreenObject.Accessors.image
train
def image(name,locator) # generates method for checking the existence of the image. # this will return true or false based on if image is available or not # @example check if 'logo' image is displayed on the page # text(:logo,"xpath~//UITextField") # DSL for clicking the logo image. # def click_logo # logo # This will click on the logo text on the screen. # end define_method("#{name}?") do ScreenObject::AppElements::Image.new(locator).exists? end #generates method for clicking image # this will not return any value. # @example clicking on logo image. # text(:logo,"xpath~//UITextField") # DSL for clicking the logo image. # def click_logo # logo # This will click on the logo text on the screen. # end define_method("#{name}") do ScreenObject::AppElements::Image.new(locator).click end end
ruby
{ "resource": "" }
q21969
ScreenObject.Accessors.table
train
def table(name, locator) #generates method for counting total no of cells in table define_method("#{name}_cell_count") do ScreenObject::AppElements::Table.new(locator).cell_count end end
ruby
{ "resource": "" }
q21970
Nugrant.Bag.__convert_value
train
def __convert_value(value) case # Converts Hash to Bag instance when value.kind_of?(Hash) Bag.new(value, @__config) # Converts Array elements to Bag instances if needed when value.kind_of?(Array) value.map(&self.method(:__convert_value)) # Keeps as-is other elements else value end end
ruby
{ "resource": "" }
q21971
Furik.PullRequests.pull_requests
train
def pull_requests(repo_name) org_name = org_name_from(repo_name) unless @block if @org_name == org_name print '-' else puts '' print "#{org_name} -" @org_name = org_name end end issues = @client.issues(repo_name, creator: @login, state: 'open'). select { |issue| issue.pull_request } issues.concat @client.issues(repo_name, creator: @login, state: 'closed'). select { |issue| issue.pull_request } @block.call(repo_name, issues) if @block issues rescue Octokit::ClientError rescue => e puts e end
ruby
{ "resource": "" }
q21972
Darksky.API.precipitation
train
def precipitation(latitudes_longitudes_times, options = {}) return if latitudes_longitudes_times.size % 3 != 0 params = [] latitudes_longitudes_times.each_slice(3) do |data| params << data.join(',') end response = Typhoeus::Request.get("#{DARKSKY_API_URL}/precipitation/#{@api_key}/#{params.join(';')}", DEFAULT_OPTIONS.dup.merge(options)) JSON.parse(response.body) if response.code == 200 end
ruby
{ "resource": "" }
q21973
Darksky.API.interesting
train
def interesting(options = {}) response = Typhoeus::Request.get("#{DARKSKY_API_URL}/interesting/#{@api_key}", DEFAULT_OPTIONS.dup.merge(options)) JSON.parse(response.body) if response.code == 200 end
ruby
{ "resource": "" }
q21974
Rib.Shell.loop
train
def loop before_loop set_trap start in_loop stop self rescue Exception => e Rib.warn("Error while running loop:\n #{format_error(e)}") raise ensure release_trap after_loop end
ruby
{ "resource": "" }
q21975
Rib.Paging.one_screen?
train
def one_screen? str cols, lines = `tput cols`.to_i, `tput lines`.to_i (str.count("\n") + 2) <= lines && # count last line and prompt str.gsub(/\e\[[^m]*m/, '').size <= cols * lines end
ruby
{ "resource": "" }
q21976
Vegas.Runner.daemonize!
train
def daemonize! if JRUBY # It's not a true daemon but when executed with & works like one thread = Thread.new {daemon_execute} thread.join elsif RUBY_VERSION < "1.9" logger.debug "Parent Process: #{Process.pid}" exit!(0) if fork logger.debug "Child Process: #{Process.pid}" daemon_execute else Process.daemon(true, true) daemon_execute end end
ruby
{ "resource": "" }
q21977
Vegas.Runner.load_config_file
train
def load_config_file(config_path) abort "Can not find config file at #{config_path}" if !File.readable?(config_path) config = File.read(config_path) # trim off anything after __END__ config.sub!(/^__END__\n.*/, '') @app.module_eval(config) end
ruby
{ "resource": "" }
q21978
KPeg.CodeGenerator.output_grammar
train
def output_grammar(code) code << " # :stopdoc:\n" handle_ast(code) fg = @grammar.foreign_grammars if fg.empty? if @standalone code << " def setup_foreign_grammar; end\n" end else code << " def setup_foreign_grammar\n" @grammar.foreign_grammars.each do |name, gram| code << " @_grammar_#{name} = #{gram}.new(nil)\n" end code << " end\n" end render = GrammarRenderer.new(@grammar) renderings = {} @grammar.rule_order.each do |name| reset_saves rule = @grammar.rules[name] io = StringIO.new render.render_op io, rule.op rend = io.string rend.gsub! "\n", " " renderings[name] = rend code << "\n" code << " # #{name} = #{rend}\n" if rule.arguments code << " def #{method_name name}(#{rule.arguments.join(',')})\n" else code << " def #{method_name name}\n" end if @debug code << " puts \"START #{name} @ \#{show_pos}\\n\"\n" end output_op code, rule.op if @debug code << " if _tmp\n" code << " puts \" OK #{name} @ \#{show_pos}\\n\"\n" code << " else\n" code << " puts \" FAIL #{name} @ \#{show_pos}\\n\"\n" code << " end\n" end code << " set_failed_rule :#{method_name name} unless _tmp\n" code << " return _tmp\n" code << " end\n" end code << "\n Rules = {}\n" @grammar.rule_order.each do |name| rend = GrammarRenderer.escape renderings[name], true code << " Rules[:#{method_name name}] = rule_info(\"#{name}\", \"#{rend}\")\n" end code << " # :startdoc:\n" end
ruby
{ "resource": "" }
q21979
KPeg.CodeGenerator.output_header
train
def output_header(code) if header = @grammar.directives['header'] code << header.action.strip code << "\n" end pre_class = @grammar.directives['pre-class'] if @standalone if pre_class code << pre_class.action.strip code << "\n" end code << "class #{@name}\n" cp = standalone_region("compiled_parser.rb") cpi = standalone_region("compiled_parser.rb", "INITIALIZE") pp = standalone_region("position.rb") cp.gsub!(/^\s*include Position/, pp) code << " # :stopdoc:\n" code << cpi << "\n" unless @grammar.variables['custom_initialize'] code << cp << "\n" code << " # :startdoc:\n" else code << "require 'kpeg/compiled_parser'\n\n" if pre_class code << pre_class.action.strip code << "\n" end code << "class #{@name} < KPeg::CompiledParser\n" end @grammar.setup_actions.each do |act| code << "\n#{act.action}\n\n" end end
ruby
{ "resource": "" }
q21980
YNAB.TransactionsApi.create_transaction
train
def create_transaction(budget_id, data, opts = {}) data, _status_code, _headers = create_transaction_with_http_info(budget_id, data, opts) data end
ruby
{ "resource": "" }
q21981
YNAB.TransactionsApi.get_transaction_by_id
train
def get_transaction_by_id(budget_id, transaction_id, opts = {}) data, _status_code, _headers = get_transaction_by_id_with_http_info(budget_id, transaction_id, opts) data end
ruby
{ "resource": "" }
q21982
YNAB.TransactionsApi.get_transactions
train
def get_transactions(budget_id, opts = {}) data, _status_code, _headers = get_transactions_with_http_info(budget_id, opts) data end
ruby
{ "resource": "" }
q21983
YNAB.TransactionsApi.get_transactions_by_account
train
def get_transactions_by_account(budget_id, account_id, opts = {}) data, _status_code, _headers = get_transactions_by_account_with_http_info(budget_id, account_id, opts) data end
ruby
{ "resource": "" }
q21984
YNAB.TransactionsApi.get_transactions_by_category
train
def get_transactions_by_category(budget_id, category_id, opts = {}) data, _status_code, _headers = get_transactions_by_category_with_http_info(budget_id, category_id, opts) data end
ruby
{ "resource": "" }
q21985
YNAB.TransactionsApi.get_transactions_by_payee
train
def get_transactions_by_payee(budget_id, payee_id, opts = {}) data, _status_code, _headers = get_transactions_by_payee_with_http_info(budget_id, payee_id, opts) data end
ruby
{ "resource": "" }
q21986
YNAB.TransactionsApi.update_transaction
train
def update_transaction(budget_id, transaction_id, data, opts = {}) data, _status_code, _headers = update_transaction_with_http_info(budget_id, transaction_id, data, opts) data end
ruby
{ "resource": "" }
q21987
YNAB.TransactionsApi.update_transactions
train
def update_transactions(budget_id, data, opts = {}) data, _status_code, _headers = update_transactions_with_http_info(budget_id, data, opts) data end
ruby
{ "resource": "" }
q21988
YNAB.AccountsApi.get_account_by_id
train
def get_account_by_id(budget_id, account_id, opts = {}) data, _status_code, _headers = get_account_by_id_with_http_info(budget_id, account_id, opts) data end
ruby
{ "resource": "" }
q21989
YNAB.AccountsApi.get_accounts
train
def get_accounts(budget_id, opts = {}) data, _status_code, _headers = get_accounts_with_http_info(budget_id, opts) data end
ruby
{ "resource": "" }
q21990
YNAB.MonthsApi.get_budget_month
train
def get_budget_month(budget_id, month, opts = {}) data, _status_code, _headers = get_budget_month_with_http_info(budget_id, month, opts) data end
ruby
{ "resource": "" }
q21991
YNAB.MonthsApi.get_budget_months
train
def get_budget_months(budget_id, opts = {}) data, _status_code, _headers = get_budget_months_with_http_info(budget_id, opts) data end
ruby
{ "resource": "" }
q21992
Chess.Pgn.to_s
train
def to_s s = '' TAGS.each do |t| tag = instance_variable_get("@#{t}") s << "[#{t.capitalize} \"#{tag}\"]\n" end s << "\n" m = '' @moves.each_with_index do |move, i| m << "#{i/2+1}. " if i % 2 == 0 m << "#{move} " end m << @result unless @result.nil? s << m.gsub(/(.{1,78})(?: +|$)\n?|(.{78})/, "\\1\\2\n") end
ruby
{ "resource": "" }
q21993
Chess.Game.pgn
train
def pgn pgn = Chess::Pgn.new pgn.moves = self.moves pgn.result = self.result return pgn end
ruby
{ "resource": "" }
q21994
YNAB.PayeeLocationsApi.get_payee_location_by_id
train
def get_payee_location_by_id(budget_id, payee_location_id, opts = {}) data, _status_code, _headers = get_payee_location_by_id_with_http_info(budget_id, payee_location_id, opts) data end
ruby
{ "resource": "" }
q21995
YNAB.PayeeLocationsApi.get_payee_locations
train
def get_payee_locations(budget_id, opts = {}) data, _status_code, _headers = get_payee_locations_with_http_info(budget_id, opts) data end
ruby
{ "resource": "" }
q21996
YNAB.PayeeLocationsApi.get_payee_locations_by_payee
train
def get_payee_locations_by_payee(budget_id, payee_id, opts = {}) data, _status_code, _headers = get_payee_locations_by_payee_with_http_info(budget_id, payee_id, opts) data end
ruby
{ "resource": "" }
q21997
YNAB.CategoriesApi.update_month_category
train
def update_month_category(budget_id, month, category_id, data, opts = {}) data, _status_code, _headers = update_month_category_with_http_info(budget_id, month, category_id, data, opts) data end
ruby
{ "resource": "" }
q21998
YNAB.BudgetsApi.get_budget_by_id
train
def get_budget_by_id(budget_id, opts = {}) data, _status_code, _headers = get_budget_by_id_with_http_info(budget_id, opts) data end
ruby
{ "resource": "" }
q21999
YNAB.BudgetsApi.get_budget_settings_by_id
train
def get_budget_settings_by_id(budget_id, opts = {}) data, _status_code, _headers = get_budget_settings_by_id_with_http_info(budget_id, opts) data end
ruby
{ "resource": "" }