query
stringlengths
7
9.55k
document
stringlengths
10
363k
metadata
dict
negatives
listlengths
0
101
negative_scores
listlengths
0
101
document_score
stringlengths
3
10
document_rank
stringclasses
102 values
Sets the MTUs for this VLANs.
def set_mtu(opts) opts = check_params(opts,[:mtus]) super(opts) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def SetMtu(node)\n\t@interfaces.each do |ifn|\n\t self.GetGroupInterface(node, ifn).mtu=\"1528\"\n\tend\n end", "def SetMtu(node)\n @rstack.SetMtu(node)\n end", "def mti=(mti)\n validator = EnumAttributeValidator.new('String', [\"0100\", \"0120\", \"0200\"])\n unless validator.valid?(mti)\n fail ArgumentError, \"invalid value for \\\"mti\\\", must be one of #{validator.allowable_values}.\"\n end\n @mti = mti\n end", "def set_tumor\n @tumor = Tumor.find(params[:id])\n end", "def units=(list)\n @units = makelist(list)\n end", "def add_tlvs(tlvs)\n\t\tif (tlvs != nil)\n\t\t\ttlvs.each { |tlv|\n\t\t\t\tadd_tlv(tlv['type'], tlv['value'])\n\t\t\t}\n\t\tend\n\tend", "def add_tlvs(tlvs)\n\t\tif (tlvs != nil)\n\t\t\ttlvs.each { |tlv|\n\t\t\t\tadd_tlv(tlv['type'], tlv['value'])\n\t\t\t}\n\t\tend\n\tend", "def roles=(t)\n if t.kind_of?(String)\n t = t.downcase.split(\",\").join(\" \").split(\" \").uniq\n end\n self[:roles] = t\n end", "def set(locales = nil, regions = nil, types = nil)\n @Locales = locales unless locales.nil?\n @Regions = regions unless regions.nil?\n @Types = types unless types.nil?\n self\n end", "def set_vhp_ctas\n #ctas =\n\n end", "def monitor_tags=(monitor_tags)\n if monitor_tags.nil?\n fail ArgumentError, 'invalid value for \"monitor_tags\", monitor_tags cannot be nil.'\n end\n if monitor_tags.length < 1\n fail ArgumentError, 'invalid value for \"monitor_tags\", number of items must be greater than or equal to 1.'\n end\n @monitor_tags = monitor_tags\n end", "def units=(value)\n @units = value\n end", "def set(locales = nil, regions = nil)\n @Locales = locales unless locales.nil?\n @Regions = regions unless regions.nil?\n self\n end", "def set(locales = nil, regions = nil)\n @Locales = locales unless locales.nil?\n @Regions = regions unless regions.nil?\n self\n end", "def configure_vlans\n logger.debug(\"Configuring vlans on %s\" % type.puppet_certname)\n desired = desired_port_channels\n desired_vlans = vlans_from_desired(desired)\n current_vlans = switch.vlan_information.keys\n\n desired_vlans.each do |vlan|\n port_channels = vlan_portchannels_from_desired(desired, vlan)\n\n logger.info(\"Adding vlan %d with tagged port channels %s to %s\" % [vlan, port_channels, type.puppet_certname])\n if switch.model =~ /MXL/ || switch.model =~ /PE-FN/\n switch.provider.mxl_vlan_resource(vlan, vlan_name(vlan), vlan_description(vlan), port_channels)\n else\n switch.provider.mxl_vlan_resource(vlan, vlan_name(vlan), vlan_description(vlan), [])\n end\n end\n\n # IOAs cannot set their vlan membership on the mxl_vlan resources\n # so need to get ioa_interfaces made for them instead\n\n unless switch.model =~ /PE-FN/\n desired.keys.each do |port_channel|\n switch.provider.ioa_interface_resource(\"po %s\" % port_channel, desired_vlans, [])\n end\n logger.debug(\"created IOA interface vlans for %s\" % type.puppet_certname)\n end\n\n (current_vlans - desired_vlans).each do |vlan|\n next if vlan == \"1\"\n\n # old code did not support removing vlans from !MXLs,\n # we might support this now in puppet so worth checking\n # if that is still good behaviour\n next unless switch.model =~ /MXL/\n\n logger.info(\"Removing VLAN %s from %s\" % [vlan, type.puppet_certname])\n switch.provider.mxl_vlan_resource(vlan, \"\", \"\", [], true)\n end\n\n nil\n end", "def mtus\n build_system_layout\n @mtus\n end", "def set_vlan(opts)\n opts = check_params(opts,[:vlan_names])\n super(opts)\n end", "def set_agentes_titulares\n self.agente_ids_serial = self.agente_ids\n self.titular_ids_serial = self.titular_ids\n end", "def set_turistum\n @turistum = Turistum.find(params[:id])\n end", "def set_vlan(opts)\n opts = check_params(opts,[:vlans])\n super(opts)\n end", "def set_vlan(opts)\n opts = check_params(opts,[:vlans])\n super(opts)\n end", "def set_tin_tuc\n @tin_tuc = TinTuc.find(params[:id])\n end", "def list_of_tmms\n super\n end", "def set_metum\n @metum = Metum.find(params[:id])\n end", "def set_metum\n @metum = Metum.find(params[:id])\n end", "def set_teeth(as)\n self.set_teeth_numbers(as[:teeth_numbers], false)\n self.set_missing_teeth_numbers(as[:missing_teeth_numbers], false)\n self.put_teeth_in_order\n end", "def tsme=(tsme)\n validator = EnumAttributeValidator.new('String', [\"platform-default\", \"Auto\", \"disabled\", \"enabled\"])\n unless validator.valid?(tsme)\n fail ArgumentError, \"invalid value for \\\"tsme\\\", must be one of #{validator.allowable_values}.\"\n end\n @tsme = tsme\n end", "def application_units=(application_units)\n validator = EnumAttributeValidator.new('String', [\"Amount\", \"Hours\", \"Incidents\"])\n unless validator.valid?(application_units)\n fail ArgumentError, \"invalid value for 'application_units', must be one of #{validator.allowable_values}.\"\n end\n @application_units = application_units\n end", "def set_t_unidad\n @t_unidad = TUnidad.find(params[:id]) \n end", "def set_test_metum\n @test_metum = TestMetum.find(params[:id])\n end", "def set_vlan\n converge_it(\"Set VLAN #{new_resource.vlan} on adapter #{new_resource.device}\") do\n shell_out = Mixlib::ShellOut.new(\"powershell.exe -Command \\\"Set-NetLbfoTeamNIC -Name '#{new_resource.device}' -VlanID #{new_resource.vlan}\\\"\")\n shell_out.run_command\n shell_out.error!\n end\n end", "def units=(args)\n\t@units = (!args or args.is_a?(Units)) ? args : Units.new(args)\n end", "def set_tags(tags)\n @tags.update(tags)\n end", "def memory_thermal_throttling=(memory_thermal_throttling)\n validator = EnumAttributeValidator.new('String', [\"platform-default\", \"CLTT with PECI\", \"Disabled\"])\n unless validator.valid?(memory_thermal_throttling)\n fail ArgumentError, \"invalid value for \\\"memory_thermal_throttling\\\", must be one of #{validator.allowable_values}.\"\n end\n @memory_thermal_throttling = memory_thermal_throttling\n end", "def members=(value)\n self.users = value\n end", "def set_trivium\n @trivium = current_user.triviums.find(params[:id])\n end", "def set_setum\n @setum = Setum.find(params[:id])\n end", "def setTags(tags)\r\n\t\t\t\t\t@tags = tags\r\n\t\t\t\tend", "def targets=( *args )\n update_state_collection( '@targets', *args )\n end", "def set_gtw_smu\n @gtw_smu = GtwSmu.find(params[:id])\n end", "def set_vitabus\n @vitabus = Vitabu.find(params[:id])\n end", "def set_utensil\n @utensil = Utensil.find(params[:id])\n end", "def set_ums_user\n @ums_user = Ums::User.find(params[:id])\n end", "def conf_vlan\n # VLAN port configuration table\n $conf_table =\n [\n {\n # Hybrid, S-custom port\n port_type: \"MESA_VLAN_PORT_TYPE_S_CUSTOM\",\n tpid: $s_etype,\n pvid: $vid_list[1],\n uvid: $vid_list[1],\n frame_type: \"MESA_VLAN_FRAME_ALL\"\n },\n ]\n # Set global Ethernet Type for S-custom ports\n conf = $ts.dut.call(\"mesa_vlan_conf_get\")\n conf[\"s_etype\"] = $s_etype\n $ts.dut.call(\"mesa_vlan_conf_set\", conf)\n\n # Set VLAN port configuration\n $port_list.each_with_index do |port, idx|\n entry = $conf_table[0]\n conf = $ts.dut.call(\"mesa_vlan_port_conf_get\", port)\n conf[\"port_type\"] = entry[:port_type]\n conf[\"pvid\"] = entry[:pvid]\n conf[\"untagged_vid\"] = entry[:uvid]\n conf[\"frame_type\"] = entry[:frame_type]\n $ts.dut.call(\"mesa_vlan_port_conf_set\", port, conf)\n end\n\n # Set VLAN memberships\n $ts.dut.call(\"mesa_vlan_port_members_set\", 1, \"\")\n $vid_list.each_with_index do |vid, idx|\n member_list = $vid_members\n str = \"\"\n member_list.each do |port|\n str += \"#{port}\"\n str += \",\" unless port == member_list.last\n end\n $ts.dut.call(\"mesa_vlan_port_members_set\", vid, str)\n end\nend", "def set_motto\n @motto = Motto.find(params[:id])\n end", "def vms(user)\n vms=@users[user]\n @users[user]=vms=Hash.new if !vms\n vms\n end", "def targets=(value)\n @targets = value\n end", "def targets=(value)\n @targets = value\n end", "def setSystemOfUnits _args\n \"setSystemOfUnits _args;\" \n end", "def virtual_cpus=(value)\n FFI::Libvirt.virDomainSetVcpus(self, value) == 0\n end", "def set_tia_list\n @tia_list = TiaList.find( params[ :my_tia_list_id ])\n # permit access if current user is either owner or deputy of this list\n render_no_permission unless @tia_list.user_is_owner_or_deputy?( current_user.id )\n end", "def target_types=(value)\n @target_types = value\n end", "def set_utenti\n @utenti = Utenti.find(params[:id])\n end", "def vlan=(value)\n if value.is_a(String)\n value = value.to_i\n end\n super(value)\n end", "def set_otum\n @otum = Otum.find(params[:id])\n end", "def available_locales=(locales); end", "def setUnitAbility _obj, _args\n \"_obj setUnitAbility _args;\" \n end", "def set_Units(value)\n set_input(\"Units\", value)\n end", "def set_Units(value)\n set_input(\"Units\", value)\n end", "def roles= *new_roles\n roles.set_roles new_roles\n end", "def set_item_tb(item)\n @tb_item = item\n end", "def set_valor_ust\n @valor_ust = ValorUst.find(params[:id])\n end", "def set_users\n\n end", "def set_mascotum\n @mascotum = Mascotum.find(params[:id])\n end", "def set_mascotum\n @mascotum = Mascotum.find(params[:id])\n end", "def set_mascotum\n @mascotum = Mascotum.find(params[:id])\n end", "def set_vitamina\n @vitamina = Vitamina.find(params[:id])\n end", "def conversation_member_roles=(value)\n @conversation_member_roles = value\n end", "def init_vms\n @vms = []\n\n response = @conn.get do |req|\n req.url \"/api/v1/vms\"\n req.headers = rest_headers\n end\n\n @vms = json(response.body)[:vms]\n end", "def set_tags(tags)\n self.tags = tags.map.each do |tag|\n Tag.find_or_create_by_name tag\n end\n end", "def tags=(list)\n tag(self.class.name)\n tag(*list)\n end", "def setum_params\n params.require(:setum).permit(:name, :time_limit, :description, :is_active, :display_order)\n end", "def set_uang_masuk\n @uang_masuk = UangMasuk.find(params[:id])\n end", "def set_titan_role\n @titan_role = TitanRole.find(params[:id])\n end", "def vms_by_name(name)\n get('VM', :by_name_label, name).collect do |vm|\n UltraVM::VM.new(self, vm)\n end\n end", "def set_tubuyaki\n @tubuyaki = Tubuyaki.find(params[:id])\n end", "def set_tuiter\n @tuiter = Tuiter.find(params[:id])\n end", "def set_mobile_type_list\n @mobile_type_list = MobileTypeList.find(params[:id])\n end", "def set_mat_turma\n @mat_turma = MatTurma.find(params[:id])\n end", "def members=(value)\n @members = value\n end", "def members=(value)\n @members = value\n end", "def members=(value)\n @members = value\n end", "def members=(value)\n @members = value\n end", "def set_tsunami\n @tsunami = Tsunami.find(params[:id])\n end", "def set_toyotum\n @toyotum = Toyotum.find(params[:id])\n end", "def set_mata_matum\n @mata_matum = MataMatum.find(params[:id])\n end", "def set_tribal_membership\n @tribal_membership = TribalMembership.find(params[:id])\n end", "def token_types=(theTokenTypes)\n\t\traise LexerSetupError, \"Token types can be specified only once.\" unless token_types.nil?\n\t\t@token_types = theTokenTypes\n\tend", "def set_mtu(name, opts = {})\n cmds = command_builder('mtu', opts)\n configure_interface(name, cmds)\n end", "def vms\n vms = []\n if current_user.admin?\n vms = object.vms\n elsif current_user.lead?\n vms = object.vms.select { |vm| vm.project.users.include?(current_user) }\n elsif current_user.dev?\n vms = object.vms.select { |vm| vm.user.id == current_user.id || vm.is_jenkins }\n else\n vms = object.vms.select { |vm| vm.user.id == current_user.id }\n end\n vms.map { |v| v.id }\n end", "def vms\n vms = []\n if current_user.admin?\n vms = object.vms\n elsif current_user.lead?\n vms = object.vms.select { |vm| vm.project.users.include?(current_user) }\n elsif current_user.dev?\n vms = object.vms.select { |vm| vm.user.id == current_user.id || vm.is_jenkins }\n else\n vms = object.vms.select { |vm| vm.user.id == current_user.id }\n end\n vms.map { |v| v.id }\n end", "def set_tm\n @tm = Tm.find(params[:id])\n end", "def set_tm_table\n @tm_table = TmTable.find(params[:id])\n end", "def set_mottovote\n @mottovote = Mottovote.find(params[:id])\n end", "def set_usuarios_mobile\n @usuarios_mobile = UsuariosMobile.find(params[:id])\n end", "def amenities=(amenity_list)\n @amenities = amenity_list.map do |amenity|\n amenity.propertyID = propertyID\n amenity.unitID = unitID if defined? unitID\n amenity\n end\n end", "def set_vlan_id(opts)\n opts = check_params(opts,[:vlan_ids])\n super(opts)\n end", "def set_vlan_id(opts)\n opts = check_params(opts,[:vlan_ids])\n super(opts)\n end", "def set_mailboxes(mailboxes_config)\n mailboxes_config.each do |attributes|\n self.mailboxes << Mailbox.new(attributes)\n end\n end" ]
[ "0.57524985", "0.57125205", "0.5089353", "0.49055326", "0.4809779", "0.46781787", "0.46781787", "0.46313825", "0.45997128", "0.45847508", "0.45086566", "0.45039102", "0.44807643", "0.44807643", "0.4465888", "0.4455266", "0.44248164", "0.44182155", "0.44173896", "0.44060814", "0.44060814", "0.440461", "0.43922025", "0.43847576", "0.43847576", "0.43758562", "0.43602327", "0.43480378", "0.42844632", "0.4283042", "0.42828834", "0.4279519", "0.42653325", "0.42623597", "0.4261372", "0.42364147", "0.42212665", "0.42137298", "0.421284", "0.42029753", "0.41836867", "0.41586277", "0.41503417", "0.4144963", "0.41397896", "0.4139686", "0.41381207", "0.41381207", "0.4133311", "0.413137", "0.41277754", "0.40922815", "0.40888447", "0.40862375", "0.40858865", "0.40801856", "0.40667424", "0.40661833", "0.40661833", "0.40616572", "0.40560985", "0.40527818", "0.4050643", "0.40494353", "0.40494353", "0.40494353", "0.40467003", "0.40412405", "0.40336284", "0.4031413", "0.40295634", "0.40276915", "0.40208608", "0.40196696", "0.40170193", "0.40167195", "0.40110663", "0.40068364", "0.4005783", "0.39995798", "0.39995798", "0.39995798", "0.39995798", "0.3992786", "0.39894235", "0.39861912", "0.39835593", "0.39804155", "0.39796472", "0.39788926", "0.39788926", "0.39723313", "0.396961", "0.39692062", "0.3962025", "0.39590025", "0.3956578", "0.3956578", "0.3956511" ]
0.49763003
4
Sets the the source checking states for this VLANs. If enabled and auto lasthop is disabled, check that the source of the first packet of a connection is correct (correct VLAN, router, node). This is equivalent to BSD's net.inet.sourcecheck sysctl variable.
def set_source_check_state(opts) opts = check_params(opts,[:states]) super(opts) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_check_source_state(opts)\n opts = check_params(opts,[:states])\n super(opts)\n end", "def source_check_state\n super\n end", "def check_source_state\n super\n end", "def set_source_interface(name = 'Vxlan1', opts = {})\n commands = command_builder('vxlan source-interface', opts)\n configure_interface(name, commands)\n end", "def aws_instance_network_interface_first_source_dest_check_disable(opts)\n opts[:instance].network_interfaces.first.source_dest_check = false\n end", "def set_nat_source_address(opts)\n opts = check_params(opts,[:nat_states])\n super(opts)\n end", "def set_source_interface(sources)\n existing = config.scan(/ip tacacs.* source-interface.*/)\n desired = []\n sources.each do |vrf, intf|\n vrf_str = vrf == 'default' ? '' : \" vrf #{vrf}\"\n desired << \"ip tacacs#{vrf_str} source-interface #{intf}\"\n end\n remove = existing - desired\n cmds = remove.map { |line| \"no #{line}\" }\n cmds.concat(desired)\n configure cmds\n end", "def check_sources\n case self.source\n when \"rubygems\"\n return false if self.gem_name.empty?\n require 'net/http'\n begin\n r = Net::HTTP.get_response(URI.parse(\"http://rubygems.org/gems/#{self.gem_name}\"))\n Net::HTTPSuccess === r ? (return true) : errors.add(:gem_name, \"#{self.gem_name} is not a valid rubygem\")\n rescue\n errors.add(:gem_name, \"#{self.gem_name} failed.\")\n end\n when \"git\"\n if self.source_url.empty?\n errors.add(:source_url, \"can't be blank\")\n return false\n end\n require 'command_check'\n if command?('git')\n git_ls = system(\"git\", \"ls-remote\", self.source_url)\n if git_ls != true\n errors.add(:source_url, \"#{self.source_url} is not a valid git repository\")\n end\n end\n when \"path\"\n if self.source_url.empty?\n errors.add(:source_url, \"can't be blank\")\n return false\n end\n # Use Dir to see if a gemfile exists in that directory, and protect\n # it with File.directory? to keep out wildcards (resource hog).\n # Make the two cases somewhat indistinguishable to avoid revealing\n # irrelevant system properties.\n if (!File.directory? self.source_url or\n Dir.glob(\"#{self.source_url}/*.gemspec\").empty?)\n errors.add(:source_url, \"Gemspec not found in #{self.source_url}\")\n end\n end\n end", "def source_dest_check\n data[:source_dest_check]\n end", "def _validate_source(s)\n if git = s[:git]\n tag, commit = s.values_at(:tag, :commit)\n version = spec.version.to_s\n\n if git =~ %r{http://EXAMPLE}\n results.add_error('source', 'The Git source still contains the ' \\\n 'example URL.')\n end\n if commit && commit.downcase =~ /head/\n results.add_error('source', 'The commit of a Git source cannot be' \\\n ' `HEAD`.')\n end\n if tag && !tag.to_s.include?(version)\n results.add_warning('source', 'The version should be included in' \\\n ' the Git tag.')\n end\n if tag.nil?\n results.add_warning('source', 'Git sources should specify a tag.', true)\n end\n end\n\n perform_github_source_checks(s)\n check_git_ssh_source(s)\n end", "def check_sources(server)\n return 'Not owned by DLSS' if netdb_but_not_dlss?(server)\n return 'Only in NetDB' if only_netdb?(server)\n return 'Only in VMware' if only_vmware?(server)\n return 'Old configurations need cleaning' if only_configs?(server)\n\n ''\n end", "def set_source_port_behavior(opts)\n opts = check_params(opts,[:source_port_behaviors])\n super(opts)\n end", "def set_source_port_behavior(opts)\n opts = check_params(opts,[:source_port_behaviors])\n super(opts)\n end", "def validate_check_source(check)\n if is_a_string?(check[:source])\n must_match_regex(/\\A[\\w\\.-]*([:]{3}[\\w\\|\\.-]+[:]{3}[\\w\\.-]*|[\\w\\.-]+)\\z/, check[:source]) ||\n invalid(check, \"check source cannot contain spaces, special characters, or invalid tokens\")\n else\n invalid(check, \"check source must be a string\")\n end\n end", "def updateSourceEvent(source)\n # Add custom code here\n\n @ups.fill_parms()\n case source\n when 'UPSLoad'\n updateValue(source, @ups.upsLoad)\n when 'UPSBatteryCharge'\n updateValue(source, @ups.batteryCharge)\n when \"UPSBatteryVoltage\"\n updateValue(source, @ups.batteryVoltage)\n when 'UPSInputVoltage'\n updateValue(source, @ups.inputVoltage)\n when 'UPSOutputVoltage'\n updateValue(source, @ups.outputVoltage)\n end\n\n return true\n end", "def source=(value)\n @source = value\n end", "def source=(value)\n @source = value\n end", "def set_sources\n @yaml[:sources].each do |name, path|\n @sources << Yuyi::Source.new(name, path)\n end\n end", "def check_sources\n if Source.count == 0\n redirect_to :controller=>\"admin/sources\" # unless current controller == sources\n end\n end", "def set_switch_source(source)\n\t\tself.preferences ||= Hash.new\n\t\tself.preferences[:switch] = [source.to_s]\n\tend", "def sources(sources = nil)\n @sources.assign(sources) if sources\n @sources\n end", "def sources=(new_sources) # :nodoc:\n @sources = Set.new\n add_sources(new_sources)\n end", "def source=(source)\n validator = EnumAttributeValidator.new('Integer', [\"1\", \"2\"])\n unless validator.valid?(source)\n fail ArgumentError, \"invalid value for 'source', must be one of #{validator.allowable_values}.\"\n end\n @source = source\n end", "def set_trunk_allowed_vlans(name, opts = {})\n value = opts[:value]\n enable = opts.fetch(:enable, true)\n default = opts[:default] || false\n\n if value\n unless value.is_a?(Array)\n raise ArgumentError, 'value must be an Array'\n end\n value = value.map(&:inspect).join(',').tr('\"', '')\n end\n\n case default\n when true\n cmds = 'default switchport trunk allowed vlan'\n when false\n cmds = if !enable\n 'no switchport trunk allowed vlan'\n else\n [\"switchport trunk allowed vlan #{value}\"]\n end\n end\n configure_interface(name, cmds)\n end", "def check_source(code)\n check_parse_tree(Checker.parse_tree_for(code))\n end", "def target_is_upstream_source\n return if source&.upstream == target\n\n errors.add :source, I18n.t('openwebslides.validations.pull_request.target_is_upstream_source')\n end", "def initSource(source)\n\t\tfor i in 0..(@graph.size - 1) do\n\t\t\tif @graph[i].node == source\n\t\t\t\t@graph[i].distance = 0\n\t\t\t\tbreak\n\t\t\tend \n\t\tend\n\tend", "def set_source_interface(opts = {})\n cmd = command_builder('ntp source', opts)\n configure(cmd)\n end", "def cmd_notify_set_source(*args)\n\t\t\t\tif args.length > 0\n\t\t\t\t\tprint_status(\"Setting the Source to #{args[0]}\")\n\t\t\t\t\t$source = args[0]\n\t\t\t\telse\n\t\t\t\t\tprint_error(\"Please provide a value\")\n\t\t\t\tend\n\t\t\tend", "def protect_sources\n @protected_sources = sources\n end", "def source=(source)\n self.each{|e| e.source=source}\n end", "def set_vlan(opts)\n opts = check_params(opts,[:vlans])\n super(opts)\n end", "def set_vlan(opts)\n opts = check_params(opts,[:vlans])\n super(opts)\n end", "def set_certificate_check_state(opts)\n opts = check_params(opts,[:states])\n super(opts)\n end", "def update_sources\n return if @source_urls.nil?\n @source_urls.each do |source_url|\n source = config.sources_manager.source_with_name_or_url(source_url)\n dir = source.specs_dir\n UI.puts \"Updating a source at #{dir} for #{source}\"\n git!(%W(-C #{dir} pull))\n end\n end", "def set_stp_auto_edge_port_detection_state(opts)\n opts = check_params(opts,[:states])\n super(opts)\n end", "def scan_sources(options={})\n return enum_for(__method__,options) unless block_given?\n\n @lockfile.sources.map do |source|\n case source\n when Source::Git\n case source.uri\n when /^git:/, /^http:/\n unless internal_source?(source.uri)\n yield Results::InsecureSource.new(source.uri)\n end\n end\n when Source::Rubygems\n source.remotes.each do |uri|\n if (uri.scheme == 'http' && !internal_source?(uri))\n yield Results::InsecureSource.new(uri.to_s)\n end\n end\n end\n end\n end", "def included_sources=(value)\n @included_sources = value\n end", "def set_source\n @source = Source.find(params[:id])\n end", "def set_source\n @source = Source.find(params[:id])\n end", "def set_source\n @source = Source.find(params[:id])\n end", "def sources\n @sources ||= []\n end", "def test_source_lists\n config=<<EOF\nsource_list \"test\", %w(test-1.example.com)\n\nsource_list \"has_ipv4\", \"0.0.0.0/0\"\n\nsource_list \"has_ipv6\", \"2000::/3\"\nEOF\n\n Configuration.current = ConfigurationBuilder.parse(config)\n\n a = Alert.new\n a.subject = \"www.example.com\"\n\n assert( a.in_source_list?(\"test\") )\n assert_equal( %w(test has_ipv4).sort, a.source_lists.sort )\n\n a.subject = \"www2.example.com\"\n assert( a.in_source_list?(\"has_ipv6\") )\n assert_equal( %w(has_ipv6 has_ipv4).sort, a.source_lists.sort )\n end", "def set_allow_snmp_state(opts)\n opts = check_params(opts,[:states])\n super(opts)\n end", "def validate_load_shifting_config\n return unless type == :flex && subtype == :load_shifting\n\n source_nodes = Array(demand_source)\n\n if source_nodes.empty?\n errors.add(:demand_source, 'must be set and contain at least one node')\n end\n\n source_nodes.each do |node|\n if !Atlas::EnergyNode.exists?(node)\n errors.add(:demand_source, \"contains node #{node} which does not exist\")\n elsif Atlas::EnergyNode.find(node).merit_order&.type != :consumer\n errors.add(:demand_source, \"contains node #{node} which is not a consumer node\")\n end\n end\n end", "def protect_all_sources\n @protected_all_sources = all_sources\n end", "def sources\n sources = %w(UPSLoad UPSBatteryCharge UPSBatteryVoltage UPSInputVoltage UPSOutputVoltage)\n return sources\n end", "def set_cmp_enabled_state(opts)\n opts = check_params(opts,[:states])\n super(opts)\n end", "def set_credential_source(opts)\n opts = check_params(opts,[:sources])\n super(opts)\n end", "def sources *names\n ## reader\n return @sources if names.size == 0\n ## affectation\n names.each do |sname|\n s = @flow.sources(sname)\n @sources << s if s\n raise \"Unknown source #{sname} in monitor #{name}!\" unless s\n end\n end", "def source=(new_source)\n @source = new_source[0..100]\n end", "def set_check_host_attribute_state(opts)\n opts = check_params(opts,[:states])\n super(opts)\n end", "def is_source?\n @before.nil?\n end", "def configure_vlans\n logger.debug(\"Configuring vlans on %s\" % type.puppet_certname)\n desired = desired_port_channels\n desired_vlans = vlans_from_desired(desired)\n current_vlans = switch.vlan_information.keys\n\n desired_vlans.each do |vlan|\n port_channels = vlan_portchannels_from_desired(desired, vlan)\n\n logger.info(\"Adding vlan %d with tagged port channels %s to %s\" % [vlan, port_channels, type.puppet_certname])\n if switch.model =~ /MXL/ || switch.model =~ /PE-FN/\n switch.provider.mxl_vlan_resource(vlan, vlan_name(vlan), vlan_description(vlan), port_channels)\n else\n switch.provider.mxl_vlan_resource(vlan, vlan_name(vlan), vlan_description(vlan), [])\n end\n end\n\n # IOAs cannot set their vlan membership on the mxl_vlan resources\n # so need to get ioa_interfaces made for them instead\n\n unless switch.model =~ /PE-FN/\n desired.keys.each do |port_channel|\n switch.provider.ioa_interface_resource(\"po %s\" % port_channel, desired_vlans, [])\n end\n logger.debug(\"created IOA interface vlans for %s\" % type.puppet_certname)\n end\n\n (current_vlans - desired_vlans).each do |vlan|\n next if vlan == \"1\"\n\n # old code did not support removing vlans from !MXLs,\n # we might support this now in puppet so worth checking\n # if that is still good behaviour\n next unless switch.model =~ /MXL/\n\n logger.info(\"Removing VLAN %s from %s\" % [vlan, type.puppet_certname])\n switch.provider.mxl_vlan_resource(vlan, \"\", \"\", [], true)\n end\n\n nil\n end", "def set_unicast_redirect_state(opts)\n opts = check_params(opts,[:states])\n super(opts)\n end", "def set_ssl_check_peer_state(opts)\n opts = check_params(opts,[:states])\n super(opts)\n end", "def initSingleSource(graph, source)\n\t\n\tfor i in 0..(graph.size - 1)\n\t\tgraph.changeDistance(i, Float::INFINITY)\n\t\tgraph.changePredecessor(i, nil)\n\tend\n\t\n\tgraph.initSource(source)#initializes the source node\nend", "def set_allow_service_check_state(opts)\n opts = check_params(opts,[:states])\n super(opts)\n end", "def request_source=(value)\n @request_source = value\n end", "def get_sources(workdir)\n @sources.each do |source|\n cur_source = Vanagon::Component::Source.source(source.url, { :ref => source.ref, :sum => source.sum }, workdir)\n cur_source.fetch\n cur_source.verify\n end\n end", "def add_sources(builder)\n builder.add_source(CommandLineSource, :usage, \"Usage: ruby #{$0} [options]\")\n builder.add_source(YamlConfigFileSource, :from_complete_path, \"#{@config_file}\") if @config_file.match(/yml|yaml/i)\n builder.add_source(XmlConfigFileSource, :from_complete_path, \"#{@config_file}\") if @config_file.match(/xml/i)\n builder.add_source(EnvironmentSource, :with_prefix, \"portscan_\")\n end", "def initialize(source, smell_types_to_filter_by = [])\n @sources = Source::SourceRepository.parse(source)\n @description = @sources.description\n @collector = Core::WarningCollector.new\n @smell_types = eligible_smell_types(smell_types_to_filter_by)\n\n run\n end", "def initialize(source, smell_types_to_filter_by = [])\n @sources = Source::SourceRepository.parse(source)\n @description = @sources.description\n @collector = Core::WarningCollector.new\n @smell_types = eligible_smell_types(smell_types_to_filter_by)\n\n run\n end", "def check_git_ssh_source(s)\n if git = s[:git]\n if git =~ %r{\\w+\\@(\\w|\\.)+\\:(/\\w+)*}\n results.add_warning('source', 'Git SSH URLs will NOT work for ' \\\n 'people behind firewalls configured to only allow HTTP, ' \\\n 'therefore HTTPS is preferred.', true)\n end\n end\n end", "def add_sources(marshaller)\n source_dir = (source_type == SOURCE_TYPE_INTERNAL) \\\n ? SystemProperties::getCenterInternalDirectory \\\n : SystemProperties::getCenterExternalDirectory\n\n ha_configured = CommonSql.ha_configured?\n\n ConfigurationSource.get_all_sources_by_type(source_type).each do |source|\n source_xml = marshaller.factory.createConfigurationSourceType\n central_server_address = nil\n if ha_configured\n central_server_address = SystemParameter.where(\n :key => SystemParameter::CENTRAL_SERVER_ADDRESS,\n :ha_node_name => source.ha_node_name).first.value\n else\n central_server_address = SystemParameter.where(\n :key => SystemParameter::CENTRAL_SERVER_ADDRESS).first.value\n end\n source_xml.downloadURL =\n \"http://\" + central_server_address + \"/\" + source_dir\n source.configuration_signing_keys.find_each do |key|\n source_xml.getVerificationCert.add(key.cert.to_java_bytes)\n end\n marshaller.root.source.add(source_xml)\n end\n end", "def __set_source_classes(classes_to_proxy, concurrency_model = :iterative)\n @__concurrency_model = concurrency_model\n sources_data = SourceHelper.set_sources_data(classes_to_proxy)\n @source_obj_methods = sources_data[:source_methods]\n @sources = sources_data[:source_objs]\n @__all_class_methods = @source_obj_methods.keys\n @__class_source_group = SourceGroup.new(@sources, concurrency_model) if @sources.size > 0\n end", "def use_local_sources()\n return ENV.has_key?('USE_LOCAL_SOURCES') || ENV['TRAVIS_PULL_REQUEST'] == 'false'\nend", "def rate_source=(source)\n @rate_source = source\n end", "def sources\n @sources ||= SourcePool.new\n end", "def assert_source_attribute_is_set\n # Ensure the user specified the required source attribute\n if node['visualstudio']['source'].nil?\n fail 'The required attribute node[\\'visualstudio\\'][\\'source\\'] is empty, ' \\\n 'set this and run again!'\n end\n end", "def unsafe_checks=(enable)\n checks = REXML::XPath.first(@xml, 'ScanTemplate/VulnerabilityChecks')\n checks.attributes['unsafe'] = enable ? '1' : '0'\n end", "def source_params\n params.fetch(:source, {}).permit(:disabled, :feed_id, :source_type, :url, :name)\n end", "def set_link_auto_configuration_state(opts)\n opts = check_params(opts,[:states])\n super(opts)\n end", "def set_stp_enabled_state(opts)\n opts = check_params(opts,[:states])\n super(opts)\n end", "def set_source\n @source = Source.find params[:id]\n end", "def set_source\n @source = Source.find(params[:id])\n end", "def add_source(*source)\n unless source.blank?\n what.query.add(:sources) << source.flatten \n changed\n end\n end", "def cmd_twitt_set_source(*args)\n\t\t\t\tif args.length > 0\n\t\t\t\t\tprint_status(\"Setting the source name to #{args[0]}\")\n\t\t\t\t\t@source = args[0]\n\t\t\t\telse\n\t\t\t\t\tprint_error(\"Please provide a value\")\n\t\t\t\tend\n\t\t\tend", "def potential_checks=(enable)\n checks = REXML::XPath.first(@xml, 'ScanTemplate/VulnerabilityChecks')\n checks.attributes['potential'] = enable ? '1' : '0'\n end", "def enabled_checks=(_arg0); end", "def set_source_string(source)\n @source = source\n end", "def source_required?\n true\n end", "def source_required?\n true\n end", "def source_required?\n true\n end", "def check_sources\n if @page.has_content?('No entries found.')\n return true\n else\n sources_type = @page.find(input_elements[:filter_content]).text\n elements = @page.all(input_elements[:entry_sources_list])\n case sources_type\n when 'Tracked'\n return !@page.has_css?(input_elements[:untracked_entry_marker])\n when 'Invalid'\n elements.each do |elem|\n return false unless elem.has_css?(input_elements[:invalid_entry_marker])\n end\n return true\n when 'Untracked'\n elements.each do |elem|\n return false unless elem.has_css?(input_elements[:untracked_entry_marker])\n end\n return true\n when 'Valid'\n return !@page.has_css?(input_elements[:invalid_entry_marker])\n when 'All'\n return elements.size > 0\n end\n return false\n end\n end", "def support_multiple_source?; end", "def source_id=(value)\n @source_id = value\n end", "def update_sourced_attributes source_name=nil\n if source_name\n @sources[source_name].apply\n else\n @sources.values.each(&:apply)\n end\n end", "def check_mode(opts)\n cloud_source_args = %i[source host user password]\n on_premise_source_args = %i[source receptor_controller_scheme receptor_controller_host receptor_controller_port receptor_node]\n if opts[:config].nil?\n to_check = opts[:receptor_node].present? ? on_premise_source_args : cloud_source_args\n to_check.each do |arg|\n Optimist.die arg, \"can't be nil\" if opts[arg].nil?\n Optimist.die arg, \"can't be zero\" if arg.to_s.index('port').present? && opts[arg].zero?\n end\n else\n Optimist.die :config, \"not applicable in single-source mode\" if cloud_source_args.any? { |arg| opts[arg].present? }\n end\nend", "def source_required?\n false\n end", "def ipsource\n lanconfig[\"ip address source\"].downcase!\n end", "def source_type=(source_type)\n validator = EnumAttributeValidator.new('String', [\"container\", \"primary_nas\", \"secondary_nas\", \"primary_cloud\", \"secondary_cloud\", \"secondary_tape\"])\n unless validator.valid?(source_type)\n fail ArgumentError, \"invalid value for \\\"source_type\\\", must be one of #{validator.allowable_values}.\"\n end\n @source_type = source_type\n end", "def sources\n [root_source] + reference_sources\n end", "def sources\n @_configuration.fetch('sources') { DEFAULT_SOURCES }\n end", "def set_security_enabled_request_state(opts)\n opts = check_params(opts,[:states])\n super(opts)\n end", "def source?(v)\n vertex?(v) and pred(v).empty?\n end", "def validate_source_url(spec)\n return if spec.source.nil? || spec.source[:http].nil?\n url = URI(spec.source[:http])\n return if url.scheme == 'https' || url.scheme == 'file'\n warning('http', \"The URL (`#{url}`) doesn't use the encrypted HTTPS protocol. \" \\\n 'It is crucial for Pods to be transferred over a secure protocol to protect your users from man-in-the-middle attacks. '\\\n 'This will be an error in future releases. Please update the URL to use https.')\n end", "def source_required?\n false\n end", "def probe_unconfigured_ldap_identity_source_probe_identity_source_with_http_info(ldap_identity_source, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: SystemAdministrationSettingsUserManagementLDAPIdentitySourcesApi.probe_unconfigured_ldap_identity_source_probe_identity_source ...'\n end\n # verify the required parameter 'ldap_identity_source' is set\n if @api_client.config.client_side_validation && ldap_identity_source.nil?\n fail ArgumentError, \"Missing the required parameter 'ldap_identity_source' when calling SystemAdministrationSettingsUserManagementLDAPIdentitySourcesApi.probe_unconfigured_ldap_identity_source_probe_identity_source\"\n end\n # resource path\n local_var_path = '/aaa/ldap-identity-sources?action=probe_identity_source'\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = @api_client.object_to_http_body(ldap_identity_source)\n auth_names = ['BasicAuth']\n data, status_code, headers = @api_client.call_api(:POST, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'LdapIdentitySourceProbeResults')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: SystemAdministrationSettingsUserManagementLDAPIdentitySourcesApi#probe_unconfigured_ldap_identity_source_probe_identity_source\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def source_required?\n false\n end" ]
[ "0.6762547", "0.60307753", "0.5692701", "0.56040984", "0.54006916", "0.53888077", "0.5177032", "0.512024", "0.5015896", "0.4943069", "0.49320355", "0.49155912", "0.49133372", "0.49016485", "0.4837418", "0.48176342", "0.48176342", "0.47626108", "0.4740771", "0.4729829", "0.47151607", "0.46897686", "0.4680472", "0.46789685", "0.46315408", "0.46249884", "0.4596004", "0.45947894", "0.45741385", "0.4569288", "0.45548603", "0.454931", "0.454931", "0.45395708", "0.45316872", "0.45216975", "0.4519222", "0.45174903", "0.44920233", "0.44920233", "0.44920233", "0.44874302", "0.44763643", "0.447582", "0.44682997", "0.44586894", "0.44547406", "0.44525763", "0.4441746", "0.4427688", "0.44275537", "0.44260883", "0.44170392", "0.4414998", "0.44118658", "0.44057205", "0.4394858", "0.43906945", "0.43835795", "0.4381789", "0.43773362", "0.43475062", "0.43475062", "0.43140206", "0.43122983", "0.43117037", "0.43105426", "0.4298387", "0.4297951", "0.42849892", "0.42831948", "0.42808622", "0.42782596", "0.42718259", "0.42705512", "0.42693058", "0.4253414", "0.42510012", "0.42472354", "0.42402494", "0.42350098", "0.42330834", "0.42330834", "0.42330834", "0.42278343", "0.42164835", "0.42128572", "0.42111236", "0.42088288", "0.42034912", "0.42014685", "0.4185917", "0.41813788", "0.41810212", "0.41793078", "0.41785377", "0.41774243", "0.41683868", "0.41680214", "0.41679406" ]
0.6682239
1
Sets the tag ids for this VLANs. Note: Currently (9.4.0+), this method is not supported; delete and recreate the VLAN instead.
def set_vlan_id(opts) opts = check_params(opts,[:vlan_ids]) super(opts) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def tag_ids=(list)\n tags.clear\n for id in list\n tags << Tag.find(id) if !id.empty?\n end\n end", "def set_tags(tags)\n self.tags = tags.map.each do |tag|\n Tag.find_or_create_by_name tag\n end\n end", "def set_tags(tags)\n @tags.update(tags)\n end", "def set_tag_ids nids\n # Ensure that the user's tags are all and only those in nids\n oids = tagging_tags.pluck :id\n\n # Add new tags as necessary\n (nids - oids).each { |tagid| assert_tagging tagid, @tagging_user_id }\n\n # Remove tags as nec.\n (oids - nids).each { |tagid| refute_tagging tagid, @tagging_user_id }\n end", "def tags=(list)\n tags.clear\n for id in list\n tags << Tag.find(id) if !id.empty?\n end\n end", "def tag_ids=(tag_id_list)\n tag_id_list.each { |tag_id| PostTag.create(post_id: self.id, tag_id: tag_id) if !tag_id.blank? }\n end", "def tags=(list)\n tag(self.class.name)\n tag(*list)\n end", "def product_tags=(values)\n self.tag_list = values\n end", "def my_set_tag_ids(new_tag_ids)\n old_tag_ids = self.tag_ids\n\n to_destroy = old_tag_ids - new_tag_ids\n to_create = new_tag_ids - old_tag_ids\n\n #whenever doing multiple updates, use this ActiveRecord call set-up to make sure that you have an all-or-nothing method call, which won't half-execute the action\n ActiveRecord::Base.transaction do\n Tagging.where(cat_id: self.id, tag_id: to_destroy).destroy_all\n to_create.each do |tag_id|\n Tagging.create!(cat_id: self.id, tag_id: tag_id)\n end\n end\n\n end", "def tags=(tags)\n @tags = tags.map { |name| Tag.new(:name => name) }\n end", "def tags=(tags)\n @tags = tags.map { |name| Tag.new(:name => name) }\n end", "def tags=(tags_names)\n tags_names.each do |tag_name|\n tag = Tag.find_or_create_by_name(tag_name.downcase)\n self.tags << tag if !self.tags.find_by_id(tag)\n end\n self.tags.map(&:name)\n end", "def setTags(tags)\r\n\t\t\t\t\t@tags = tags\r\n\t\t\t\tend", "def tag_names=(tag_names)\n self.tags = tag_names.map do |tag_name|\n tag_name.strip!\n self.tags.find_or_create_by(name: tag_name)\n end\n end", "def tag_list=(my_tags)\n\t\t_new_tags = my_tags.split(',').map { |t| t.strip }.uniq\n\t\t_recent_tags = self.tags.map { |tag| tag.name }\n\n\t\t(_recent_tags - _new_tags).each { |tag| self.tags.where(name: tag).first.destroy } unless _recent_tags.blank?\n\t\tself.tags << (_new_tags - _recent_tags).map { |tag| Tag.find_or_create_by(name: tag) } unless _new_tags.blank?\n\t\t@tag_list = nil\n\tend", "def set_tags(given_tags = {})\n @tags.merge!(given_tags)\n end", "def my_tag_ids=(ids)\n ids = ids.compact.uniq.map {|i| BSON::ObjectId(i)}\n unless ids == self.tag_ids\n self.tag_ids = []\n self.tags = Tag.where(:_id.in => ids).uniq.map {|p| p}\n end\n end", "def tags=(list)\n @tags = makelist(list)\n end", "def tag_names=(tags)\n tag_array = tags.split(\",\").map{|tag| tag.strip}\n tag_array.each do |tag|\n new_tag = Tag.find_or_create_by(name: tag)\n if self.tags.include?(new_tag)\n next\n end\n self.tags << new_tag\n self.owner.tags << new_tag\n end\n end", "def selected_tags=(data)\n self.tags.clear\n data.split('tag').each { |id| self.tags << Tag.find(id) if id.length > 0 }\n end", "def tag_names=(tag_names)\n tag_list = tag_names.split(',')\n cleaned_tag_list = clean(tag_list)\n self.tags = find_or_create_tags(cleaned_tag_list)\n end", "def tag_list=(names)\n tag_names = names.split(\",\").map! {|tag| tag.downcase.strip.gsub(/[^\\w]/,'_') }\n tags_array = []\n tag_names.each do |name|\n tags_array << Tag.where(name: name).first_or_create\n end\n self.tags = tags_array\n end", "def tag_list=(tags_string)\n self.taggings.destroy_all\n\n tag_names = tags_string.split(\",\").collect{|s| s.strip.downcase}.uniq\n\n tag_names.each do |tag_name|\n tag = Tag.find_or_create_by_name(tag_name)\n tagging = self.taggings.new\n tagging.tag_id = tag.id\n end # end of do iteration\n end", "def tag_tokens=(ids)\n current_ids = []\n ids.split(\",\").each do |id|\n current_ids << OfficialTag.find_or_create_by(tag_text: id).id\n end\n self.official_tag_ids = current_ids\n end", "def tags=(tags)\n assert_unloaded\n @tags = names_to_tags(tags)\n end", "def tags=(tags)\n if tags.first.is_a? Hash\n tags = tags.collect { |tag| Tag.new(tag) }\n end\n\n tags.each { |tag|\n if not tag.is_a? Tag\n raise \"Wrong class for attempted tag #{tag.inspect}\"\n end\n }\n\n @tags = tags\n end", "def tag_names=(tags=[])\n self.entity_tags = tags.map do |name|\n tag = Tag.find_or_initialize_by name: name\n self.entity_tags.new(tag: tag)\n end\n end", "def destroy\n tag_ids.clone.each { |tag_id| destroy_tag(tag_id) }\n super\n end", "def tag_list=(tags_string)\n tag_names = tags_string.split(\",\").map{ |s| s.strip.downcase }.uniq\n new_or_found_tags = tag_names.map { |name| Tag.find_or_create_by(name: name) }\n self.tags = new_or_found_tags\n end", "def tag_list=(tags_string)\n tag_names = tags_string.split(\",\").collect{|s| s.strip.downcase}.uniq\n new_or_found_tags = tag_names.collect { |name| Tag.find_or_create_by(name: name) }\n self.tags = new_or_found_tags\n end", "def set_tags\n taggable_uid = unsafe_params[:taggable_uid]\n unless taggable_uid.is_a?(String) && taggable_uid != \"\"\n raise ApiError, \"Taggable uid needs to be a non-empty string\"\n end\n\n tags = unsafe_params[:tags]\n raise ApiError, \"Tags need to be comma-separated strings\" unless tags.is_a?(String)\n\n suggested_tags = unsafe_params[:suggested_tags] # Optional\n tags = (tags.split(\",\") + suggested_tags).join(\",\") if suggested_tags.is_a?(Array)\n\n tag_context = unsafe_params[:tag_context] # Optional\n\n taggable = item_from_uid(taggable_uid)\n\n if taggable.editable_by?(@context) || @context.can_administer_site?\n path = pathify(taggable)\n message = \"redirect to item\"\n @context.user.tag(taggable, with: tags, on: tag_context.presence || :tags)\n else\n path = home_path\n message = \"This item is not accessible by you\"\n end\n\n render json: { path: path, message: message }\n rescue RuntimeError => e\n raise ApiError, e.message\n end", "def tag_list=(tags_string)\n tag_names = tags_string.split(\",\").collect{|s| s.strip.downcase}.uniq\n new_or_found_tags = tag_names.collect { |name| Tag.find_or_create_by(name: name) }\n self.tags = new_or_found_tags\n end", "def tags=(value)\n @tags = value\n end", "def tags=(value)\n @tags = value\n end", "def tags=(value)\n @tags = value\n end", "def set_tags\n @tags = Tag.all\n @time = Tag.all.to_a.slice(0..4)\n @place = Tag.all.to_a.slice(5..8)\n @feeling = Tag.all.to_a.slice(9..13)\n @tag = Tag.find_by(id: params[:id])\n end", "def all_tags=(names)\n self.tags = names.split(\",\").map do |name|\n # If a tag does not already exist, create it.\n Tag.where(name: name.strip).first_or_create!\n end.uniq\n end", "def all_tags=(proverb_tags)\n tag_names = proverb_tags.collect{|tag_name| tag_name.strip.downcase}.uniq\n self.tags = tag_names.map do |proverb_tag|\n Tag.where(name: proverb_tag).first_or_create!\n end\n end", "def all_tags=(proverb_tags)\n tag_names = proverb_tags.collect{|tag_name| tag_name.strip.downcase}.uniq\n self.tags = tag_names.map do |proverb_tag|\n Tag.where(name: proverb_tag).first_or_create!\n end\n end", "def tag_list=(names)\n\t\tself.tags = names.split(\",\").map do |name|\n\t\t\tTag.where(name: name.strip).first_or_create!\n\t\tend\n\tend", "def tag_list=(tags_string)\n tag_names = tags_string.split(/[\\s,\",\"]/).map{ |s| s.strip.downcase }.uniq\n new_or_found_tags = tag_names.map { |name| Tag.find_or_create_by(name: name) }\n self.tags = new_or_found_tags\n end", "def tag_names=(tag_names)\n tag_names.gsub('#', '').split(',').map(&:strip).uniq.each do |tag_name|\n tags << Tag.find_or_create_by(name: tag_name)\n end\n end", "def all_tags=(names)\r\n self.tags = names.split(',').map do |name|\r\n Tag.where(name: name.strip).create!\r\n end\r\n end", "def tags_attributes=(tag_attributes)\n tag_attributes.values.each do |tag_name|\n tag_name.values.each do |tag|\n tag.split(\", \").each do |name|\n tag = Tag.find_or_create_by(name: name)\n tag.slug = tag.to_slug\n tag.save\n self.tags << tag\n end\n end\n end\n end", "def tag_names=(list)\n # Throw away extra space and blank tags\n list = list.map {|x| x.strip}.reject {|x| x.blank?}\n \n # Re-use any tags that already exist\n self.tags = device.account.tags.all(:conditions => {:name => list})\n tag_names = self.tags.map(&:name)\n \n # Create new tags for any names left in the list\n list.reject! {|x| tag_names.find {|name| name.casecmp(x) == 0}}\n self.tags += device.account.tags.create(list.map {|n| {:name => n}}).select(&:valid? )\n end", "def tags=(tags)\n @tags = \n case tags\n when String\n tags\n when Array\n tags.map(&:to_s).join(',')\n end\n @tags\n end", "def sync_tags(attributes)\n return unless attributes.key?(TAG_IDS_ATTR)\n\n recipe.tags = Tag.where(id: attributes[TAG_IDS_ATTR])\n attributes.delete(TAG_IDS_ATTR)\n end", "def tag_list=(names)\n self.tags = names.split(\",\").map do |n|\n Tag.where(name: n.strip).first_or_create!\n end\n end", "def tag_list=(names)\n self.tags = names.split(\",\").map do |n|\n Tag.where(name: n.strip).first_or_create!\n end\n end", "def tag_list=(names)\n self.tags = names.split(\",\").map do |n|\n Tag.where(name: n.strip).first_or_create!\n end\n end", "def tag_list=(names)\n self.tags = names.split(\",\").map do |n|\n Tag.where(name: n.strip).first_or_create!\n end\n end", "def tag_list=(names)\n self.tags = names.split(\",\").map do |n|\n SimpleTags::Tag.where(name: n.strip).first_or_create!\n end\n end", "def update_tags\n @updated = Tag.refresh_counts\n @deleted = []\n Tag.unused.order(:title).all.each do |tag|\n @deleted << tag.destroy\n end\n end", "def all_tags=(names)\n self.tags = names.split(\",\").map do |name|\n Tag.where(name: name.strip).first_or_create!\n end\n end", "def all_tags=(names)\n self.tags = names.split(\",\").map do |name|\n Tag.where(name: name.strip).first_or_create!\n end\n end", "def all_tags=(names)\n self.tags = names.split(\",\").map do |name|\n Tag.where(name: name.strip).first_or_create!\n end\n end", "def tag_list=(names)\n self.tags = names.split(\", \").map do |n|\n Tag.where(name: n.strip.downcase).first_or_create!\n end\n end", "def tag_list=(tags_string)\n tag_names = tags_string.split(\",\").collect{|s| s.strip.downcase}.uniq\n new_or_found_tags = tag_names.collect { |name| Tag.find_or_create_by(name: name) }\n self.tags = new_or_found_tags\nend", "def tag(tags)\n tags.each do |key, value|\n @tags[key.to_s] = value\n end\n end", "def set_tags(path, ctype, arr)\n # FIXME : force lowercase?\n add_metadata(path, ctype, arr.map { |t| t.to_s }, :tags)\n notify(EVENT_TAG, path, ctype)\n end", "def tag_list=(dupa)\n #dupa jest to string z formularza, ktory obrabiamy nizej\n tag_names = dupa.split(\",\") #dzieli string wg znaku \",\" na tablice substringow, np. \"dupa, dupa_blada\".split(\",\") zrobi [\"dupa\", \"dupa_blada\"]\n dupa2 = tag_names.map { |name| Tag.find_or_create_by(name: name) }\n #ponizsze tags z asocjacji, dupa2 to tablica z obrobionymi tagami, self.tags jest prawdopodobnie wykorzystywane w metodzie tag_list wyzej (ta pierwsza)\n self.tags = dupa2\n end", "def tag_list=(tags_string)\r\n \tself.blog_post_taggings.destroy_all\r\n \t\r\n \ttag_names = tags_string.split(\",\").collect{ |s| s.strip }.uniq\r\n \t\r\n \ttag_names.each do |tag_name|\r\n \t blog_post_tag = BlogPostTag.find_or_create_by_name(tag_name)\r\n \t blog_post_tagging = self.blog_post_taggings.new\r\n \t blog_post_tagging.blog_post_tag_id = blog_post_tag.id\r\n \tend\r\n end", "def all_tags=(names)\n self.tags = names.split(\",\").map do |name|\n Tag.where(name: name.strip).first_or_create!\n end\n end", "def _UNDO_setTags(iNewTags)\n # Remove Tags that are not part of the new list\n @Tags.delete_if do |iTag, iNil|\n !iNewTags.has_key?(iTag)\n end\n # Add Tags that are not part of the current list\n iNewTags.each do |iTag, iNil|\n @Tags[iTag] = nil\n end\n end", "def all_tags=(names)\n self.tags = names.split(\",\").map do |name|\n name.gsub!(/[!@%&\"']/,'')\n name.downcase!\n Tag.where(name: name.strip).first_or_create!\n end\n end", "def tags=(value)\n value = value.split(',') if value.is_a?(String)\n\n write_attribute(:tags, Taggable.sanitize_tag_list(Array(value)))\n end", "def change_untagged_vlan( this, xml )\n proc = @@untgv_jmptbl[this.is_trunk?][this.should_trunk?][this.resource[:untagged_vlan].empty?]\n proc.call( this, xml )\n end", "def all_tags=(names)\n self.tags = names.split(\",\").map do |tag|\n Tag.where(name: tag.strip.capitalize).first_or_create!\n end\n end", "def all_tags=(names)\n\t self.tags = names.split(\",\").map do |name|\n\t Tag.where(name: name.strip).first_or_create!\n\t end\n\tend", "def selected_tags=(value)\n @selected_tags = value\n end", "def update_tags!\n return unless @params.key?(:tags)\n\n tags_to_remove.each do |tag_title|\n TaskTag.where(task: task).joins(:tag).merge(Tag.where(title: tag_title)).destroy_all\n end\n\n tags_to_add.each do |tag_title|\n TaskTag.where(task: task, tag: tag_from_title(tag_title)).first_or_create!\n end\n end", "def tag_with(tag_names)\n _tags = []\n Tag.parse(tag_names).each do |tag_name|\n _tags << Tag.find_or_create_by_name(tag_name.downcase)\n end\n self.tags = _tags.uniq\n end", "def tag_list= value\n self.tags = value.split(',').map(&:strip)\n end", "def tag_list= value\n self.tags = value.split(',').map(&:strip)\n end", "def tag(*tags)\n tags.each {|t| @tags << t}\n @tags.uniq!\n end", "def tags=(value)\n @tags = value.is_a?(String) ? value.gsub(', ', ',').split(',') : value\n end", "def tag_list=(tags_string)\n\t\t# splits array, strips non-meaningful whitespace, case insensitive, no duplicates\n\t\ttag_names = tags_string.split(\",\").collect{ |s| s.strip.downcase }.uniq\n\t\t\n\t\t# find or create tag with cleaned up names from array string\n\t\tnew_or_found_tags = tag_names.collect { |name| Tag.find_or_create_by(name: name) }\n\t\t\n\t\t# assign tags to article instance\n\t\tself.tags = new_or_found_tags \t\n\tend", "def tags=(tags)\n if !tags.nil? && tags.length > 5\n fail ArgumentError, 'invalid value for \"tags\", number of items must be less than or equal to 5.'\n end\n @tags = tags\n end", "def tags=(tags)\n if !tags.nil? && tags.length > 5\n fail ArgumentError, 'invalid value for \"tags\", number of items must be less than or equal to 5.'\n end\n @tags = tags\n end", "def update_tags(tags)\n rescue_extra_data\n tags = tags.split(\",\").strip\n post_tags = post_type.post_tags\n post_tags = post_tags.where.not(name: tags) if tags.present?\n term_relationships.where(\"term_taxonomy_id in (?)\", post_tags.pluck(\"#{CamaleonCms::TermTaxonomy.table_name}.id\")).destroy_all\n tags.each do |f|\n post_tag = post_type.post_tags.where({name: f}).first_or_create(slug: f.parameterize)\n term_relationships.where({term_taxonomy_id: post_tag.id}).first_or_create\n end\n update_counters(\"tags\")\n end", "def tags=(new_tags)\n raise 'Tags must be an array!' unless new_tags.is_a?(Array)\n raise 'Tags must be up to 20 items!' unless new_tags.size < 20\n raise 'Tag length must not be over 50 characters!' unless new_tags.select { |v| v.length > 50 }.empty?\n\n @tags = new_tags unless new_tags.empty?\n end", "def set_tags(args)\n\n # Identify method entry\n debug_print \"#{ self } : #{ __method__ }\\n\"\n\n # Need at least one tag in args\n if args.length <= 0\n debug_print \"No args passed, exiting\\n\"\n return false\n end\n\n # Set config flag for CL tag set in config\n @config.cl_tag_set = true\n debug_print \"Updated cl_tag_set flag: #{ @config.cl_tag_set }\\n\"\n\n # If set from CL, we overwrite the RC parameters\n # For each argument passed, add to @config.tag_list\n args.each do | _tag |\n debug_print \"Adding #{ _tag } to config tag_list\\n\"\n @config.tag_list.push(_tag)\n end\n\n debug_print \"Updated tags: #{ @config.tag_list }\\n\"\n return true\n end", "def set_vlan(opts)\n opts = check_params(opts,[:vlan_names])\n super(opts)\n end", "def tag(*tags)\n tags.each { |tag| @tags << tag }\n end", "def tag_set(id, tags)\n wf_event_id?(id)\n tags = Array(tags)\n tags.each { |t| wf_string?(t) }\n api.post([id, 'tag'].uri_concat, tags, 'application/json')\n end", "def pending_tags=(tags)\n @pending_tags = Array(tags)\n end", "def write_tag_list_on(context, tags)\n if (self.is_auto_tag_ownership_enabled?)\n self.tag_owner.tag(self, :with => tags, :on => context, :skip_save => true)\n else\n self.set_tag_list_on(context, tags)\n end\n end", "def tags(*tags)\n @_tags = tags unless tags.empty?\n @_tags\n end", "def assign_tags(tag_titles)\n update_counters_before\n tags = tag_titles.split(\",\").strip\n tags.each do |t|\n post_tag = self.post_type.post_tags.where(name: t).first_or_create!\n self.term_relationships.where({term_taxonomy_id: post_tag.id}).first_or_create!\n end\n update_counters(\"tags\")\n end", "def tags=(tags)\n\t\t\tupdate_metadata(:tags => tags)\n\t\t\t@metadata.attributes.update do |u|\n\t\t\t\tu.set(:tags => tags)\n\t\t\t\tu.add(:idenity => 1)\n\t\t\tend\n\t\t\treturn nil\n\t\tend", "def tags_string=(titles)\n self.tags = titles.split(',').map do |title|\n Tag.find_or_create_by(title: title, user: user)\n end\n end", "def update_tags\n tags=self.tag_ids.clone\n unless tags.nil?\n self.associations.each do |a|\n #destroy an association if its tag wasn't checked in the form\n a.destroy unless tags.include?(a.tag_id.to_s)\n #for each existing association, delete its tag from the parameters(to prevent duplicate associations)\n tags.delete(a.tag_id.to_s)\n end\n devs=Tag.find(:all,:conditions=>'type_id=4',:select=>'id').map{|d| d.id.to_s}\n genres=Tag.find(:all,:conditions=>'type_id=2',:select=>'id').map{|g| g.id.to_s}\n if (tags&devs).length==0\n indie=Tag.find_by_name('Independent')\n # if no developer has been selected, assume \"Independent\"\n self.associations.create(:tag_id=>indie.id)\n end\n if (tags&genres).length==0\n other=Tag.find_by_name('Other')\n # if no genre has been selected, assume \"Other\"\n self.associations.create(:tag_id=>other.id)\n end\n tags.each do |t|\n self.associations.create(:tag_id=>t) unless t.blank?\n end\n reload\n end\n end", "def tag_names=(rhs)\n self.tags = rhs.strip.split(/\\s*,\\s*/).map do |tag_name|\n Tag.find_or_initialize_by(name: tag_name)\n end\n end", "def tags=(value)\n if value == @defaults['tags']\n @values.delete 'tags' if @values.key? 'tags'\n else\n @values['tags'] = value\n end\n end", "def unassign_tags(tag_titles)\n update_counters_before\n tags = tag_titles.split(\",\").strip\n self.term_relationships.where({term_taxonomy_id: self.post_type.post_tags.where(name: tags).pluck(:id)}).destroy_all\n update_counters(\"tags\")\n end", "def create_tags(tags)\n tags.each do |tag_name|\n self.tags.create!(name: tag_name.downcase) unless self.tags.find_by(name: tag_name.downcase)\n end\n end", "def all_tags=(keywords)\n self.tags = keywords.split(',').map do |keyword|\n Tag.where(keyword: keyword.strip).first_or_create!\n end\n end", "def tag_names=(rhs)\n self.tags = rhs.strip.split(/\\s*,\\s*/).map do |tag_name|\n Tag.find_or_initialize_by(name: tag_name)\n end\n end", "def toggle_tags\n puts \"\\n\\n******* toggle_tags *******\"\n\n # == get post_id and tag_id from combined :ids string (e.g. 1_4)\n ids = params[:ids].split(\"_\")\n @post_id = ids[0]\n tag_id = ids[1]\n\n # == check post for selected tag\n @post_tag = PostTag.where(post_id: @post_id, tag_id: tag_id).first\n\n # == remove previously assigned tag\n if @post_tag\n puts \"******* HAS TAG (delete tag) *******\"\n @post_tag.destroy\n @post_tags = PostTag.where(post_id: @post_id)\n @post_tag_ids = @post_tags.map{|pt| pt.tag_id }\n puts \"@post_tag_ids: \", @post_tag_ids\n if @post_tag_ids.length == 0\n @post_no_tags = Tag.all\n else\n @post_no_tags = Tag.where(\"id NOT IN (?)\", @post_tag_ids)\n end\n puts \"@post_no_tags: \", @post_no_tags\n @tags = Tag.where(id: @post_tag_ids)\n render json: { tags: @tags, post_no_tags: @post_no_tags, post_id: @post_id}\n end\n end" ]
[ "0.6666377", "0.65961194", "0.65618086", "0.6528188", "0.64253235", "0.63076854", "0.6159115", "0.61554724", "0.61131644", "0.606299", "0.606299", "0.6050458", "0.6012209", "0.59292305", "0.5891107", "0.58254653", "0.5809939", "0.5797764", "0.579429", "0.5775195", "0.57750696", "0.57311714", "0.5723915", "0.5674069", "0.56338596", "0.5631733", "0.5623573", "0.561021", "0.5599257", "0.5595844", "0.5569755", "0.55496407", "0.55412173", "0.55412173", "0.55412173", "0.55404073", "0.55371606", "0.553107", "0.553107", "0.5524242", "0.5502995", "0.5500404", "0.54975265", "0.5490454", "0.54735076", "0.54629743", "0.5452007", "0.5435413", "0.5434457", "0.5434457", "0.5434457", "0.5427257", "0.53930444", "0.53900915", "0.53900915", "0.53900915", "0.5331042", "0.53284943", "0.53222406", "0.53191966", "0.53173053", "0.5314254", "0.5312604", "0.5296042", "0.52849334", "0.52787423", "0.52540123", "0.5240831", "0.5239653", "0.5232377", "0.5211941", "0.5202726", "0.51820254", "0.51820254", "0.5162384", "0.51621103", "0.5160149", "0.5146296", "0.5146296", "0.5136937", "0.5126618", "0.5094899", "0.50918597", "0.50822586", "0.50683767", "0.50660086", "0.5056977", "0.50506973", "0.5044558", "0.50256747", "0.5024603", "0.5022237", "0.50203145", "0.501047", "0.50051534", "0.5001068", "0.498329", "0.498071", "0.49769363" ]
0.5832389
16
start of add to cart logic
def add # we need the id of the product to be added # lets get it now id = params[:id] # if the cart exists already use it if not make a new one if session[:cart] then cart = session[:cart] else session[:cart] = {} cart = session[:cart] end # If the product is in the cart then increase the existing quantity by 1 if cart[id] then cart[id] = cart[id] + 1 # this is the actual increase quantity part else cart[id] = 1 end redirect_to :action => :index end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def addtocart\n\t\tinsidecart<< createproduct\n\t\taddtocart\n\tend", "def add_to_cart (data)\n added = false\n data.each do |product_data|\n products = product_data[:product]\n if products != nil\n @browser.goto(@custom_base_url + products[:url])\n products[:attributes].each do |attribute|\n @browser.select_list(attribute[:identifier],attribute[:element]).select attribute[:select] if attribute[:select]\n @browser.radio(attribute[:identifier],attribute[:element]).set if attribute[:radio]\n @browser.text_field(attribute[:identifier],attribute[:element]).set attribute[:text] if attribute[:text]\n end\n #add the qty to the json data\n @browser.text_field(:id, \"qty\").set '3'\n @helper.custom_click_button :title, 'Add to Cart'\n # assert_section 'cart'\n #cart tests \n added = true\n end\n end\n exit 1 if !added\n end", "def add_to_cart\n \tif session[\"cart\"].nil?\n \t\tsession[\"cart\"] = []\n \tend\n \t#So luong cua san pham add vao gio hang\n \tquantity_ = 1\n \tsession[\"item\"] = {:id => params[:id].to_i, :name => params[:name], :quantity => quantity_.to_i, :price => params[:price].to_i, :total => quantity_.to_i * params[:price].to_i}\n \tcheck_cart session[\"item\"]\n \tredirect_to :back\n end", "def create_cart\n\tend", "def add_to_cart(product)\n @products << product\n @sub_total += product.base_price\n @total_price += product.total_price\n puts \"Added to cart!\"\n end", "def add\n add_to_cart_common(:add_product, params[:id])\n end", "def add_in_cart \n product_id=params[:id].to_i\n @product=Product.find(product_id)\n total_request=1\n update_through_cart=0 \n if params.has_key?(:quant) \n total_request=params[:quant][:total_request].to_i\n update_through_cart=1 \n end \n if(check_availabilty(product_id,total_request,update_through_cart))\n update_session(product_id,total_request,update_through_cart)\n else\n flash[:notice] = \"#{Product.find(product_id).name} is not available in this quantity\" \n end\n end", "def add_cart_item\n current_cart.cart_items.new\n end", "def add_to_cart\n if current_user.cart\n update\n else\n create\n end\n end", "def add_to_cart\n @cart = current_user.carts.find_or_create_by(completed: false)\n @line_item = @cart.line_items.find_or_create_by(product_id: params[:product_id])\n @line_item.update quantity: @line_item.quantity + 1\n end", "def add_to_cart_from_catalog(prod_id)\n item_num1 = nav_account_menu.app_center_item_number.text.to_i\n item_num2 = nil\n\n # Workaround to make script stable by trying to click on Add to Cart button\n btn_add_to_card = find(:xpath, \"(.//*[@id='#{prod_id}']//button[@class='btn btn-add-to-cart btn-block ng-isolate-scope'])[1]\")\n (1..5).each do\n btn_add_to_card.click\n sleep 1\n item_num2 = nav_account_menu.app_center_item_number.text.to_i\n break if item_num1 < item_num2\n end\n\n item_num1 < item_num2\n end", "def add_to_cart_from_catalog(prod_id)\n item_num1 = nav_account_menu.app_center_item_number.text.to_i\n item_num2 = nil\n\n # Workaround to make script stable by trying to click on Add to Cart button\n btn_add_to_card = find(:xpath, \"(.//*[@id='#{prod_id}']//button[@class='btn btn-add-to-cart btn-block ng-isolate-scope'])[1]\")\n (1..5).each do\n btn_add_to_card.click\n sleep 1\n item_num2 = nav_account_menu.app_center_item_number.text.to_i\n break if item_num1 < item_num2\n end\n\n item_num1 < item_num2\n end", "def add_item_to_cart\n puts \"========= Adding to cart\"\n @b.link(id: \"j-add-cart-btn\").click\n @b.div(class: \"ui-add-shopcart-dialog\").wait_until_present(timeout: 30)\n unless @b.div(class: \"ui-add-shopcart-dialog\").exists?\n @error = \"Falha ao adicionar ao carrinho: #{@b.url}\"\n @log.add_message(@error)\n end\n end", "def create\n # create or increment existing CartLineItem\n @line_item = add_line_item\n # save CartLineItem and create flash message indicating result\n if @line_item.save\n flash[:success] = \"#{params[:desc]} Successfully Added to Cart\"\n else\n flash[:error] = \"#{params[:desc]} not Added to Cart - Please contact Support\"\n end\n # redirect back to Products page to allow user to continue shopping\n if params[:current_page] == 1\n logger.debug \"*** Redirecting to First Products Page...\"\n redirect_to products_path\n else\n logger.debug \"Redirecting to Products Page #{params[:current_page]}\"\n redirect_to products_path(page: params[:current_page])\n end\n end", "def add_item\n prod_id = params[:product_id].to_s\n unless Product.find(prod_id).nil?\n item = cart[prod_id] || {\"Num\" => 0}\n item[\"Num\"] += 1\n cart[prod_id] = item\n update_cart cart\n flash[:success] = t('itm_added')\n redirect_back fallback_location: :root\n end\n end", "def rb_add_to_cart (data) \n # self.add_to_cart(data)\n # go to personalize tabs (href #contentPersonalize-tab)\n # select Message Type id: s7_ea1_message_type, monogram\n # Populate First Name Innital id:s7_ea1_mon_0\n # Populate Last Name Initial id: s7_ea1_mon_1\n # Populate Middle Initial id:s7_ea1_mon_2\n # Choose font selector id:s7_ea1_mon_font\n # Click alternate Add to Cart, id:s7_add_to_cart\n end", "def add\n\t\tadd_to_cart(params[:item_obj], params[:qty])\n flash[:notice] = \"Succesfully added to your cart!\"\n\t\tredirect_to :controller => \"items\", :action => \"show\"\n\tend", "def add_to_cart\n id = params[:id].to_i\n\n is_in_cart = false\n\n session[:cart].delete(1)\n session[:cart].each do |ct|\n if defined?(ct['id'])\n Product.find(ct['id'].to_i)\n if ct['id'].to_i == id\n\n is_in_cart = true\n ct['quantity'] = ct['quantity'].to_i + 1\n end\n end\n end\n\n if !is_in_cart\n cart_item = {\n id: id,\n quantity: 1\n }\n session[:cart] << cart_item\n end\n redirect_to request.referrer\n end", "def add_item_to_cart\n product_id = params[:product_id]\n @item = LineItem.create!(product_id: product_id, cart_id: @current_cart.id)\n redirect_to checkout_carts_path, notice: 'The Item was added to your cart'\n end", "def add_univstub_with_discount() add_to_cart_common(:add_product, params[:id]) end", "def succeed_add_shoppingcart\n\t\t@msg = \"Your product is successfully added to the shopping cart.\"\n\t\t@msg_type = \"success\"\n\tend", "def add_item_to_cart\n puts \"========= Adding to cart\"\n @b.link(id: \"j-add-cart-btn\").click\n\n # wait up to 30 (6*5) seconds for ui-add-shopcart-dialog to show up\n 6.times do\n unless @b.div(class: \"ui-add-shopcart-dialog\").exists?\n sleep(5)\n end\n end\n\n unless @b.div(class: \"ui-add-shopcart-dialog\").exists?\n @error = \"Falha ao adicionar ao carrinho\"\n @log.add_message(@error)\n end\n end", "def cart\n # Calculate price\n # Warn: Need to update cart price every time items changed in cart for the safe side\n update_total_price_and_quantity_in_cart\n @cart = get_current_cart\n \n # prepare coupons\n @available_coupons = get_available_coupons(@cart) \n end", "def added_to_basket\n select_size\n choose_quantity \n click_add_to_basket\n end", "def add_to_cart\n @shopping_cart = ShoppingCart.find_by_user_id(current_user.id)\n if @shopping_cart.nil?\n @shopping_cart = ShoppingCart.new({:user_id => current_user.id, :item_list => Hash.new.to_s})\n end\n if params[:item_id].nil?\n @item = Item.find(params[:item][:item_id])\n if current_user.id == @item.user_id\n redirect_to root_path\n else\n @shopping_cart.item_list = add_to_item_list(@shopping_cart.item_list, params[:item][:item_id], params[:item][:quantity], @item.quantity)\n @shopping_cart.save\n redirect_to @shopping_cart\n end\n else\n @item = Item.find(params[:item_id])\n if current_user.id == @item.user_id\n redirect_to root_path\n else\n @shopping_cart.item_list = add_to_item_list(@shopping_cart.item_list, params[:item_id], params[:quantity], @item.quantity)\n @shopping_cart.save\n redirect_to @shopping_cart\n end\n end\n end", "def add_item\n product_id = params[:product_id].to_s\n modify_cart_delta(product_id, +1)\n redirect_to :back\n end", "def add_item (title, price, quantity = 1)\n # adds purchase price to total\n @total += price * quantity\n # Adds proper quanity of item to cart\n count = 0\n while count < quantity\n @items << title\n count += 1\n end\n # keeps track of last_added item\n @last_transaction[:item] = title\n @last_transaction[:price] = price\n @last_transaction[:quantity] = quantity\n\n end", "def cart_check\n puts \"cart checking\"\n \n sleep(2)\n mini_cart_text.click\n wait_for_spinner\n sleep(2)\n puts @prod2 = cartpage_productname.text.downcase\n if(@prod1 == @prod2)\n puts \"product is added to the cart: PASS\"\n else\n puts \"product is not added to the cart: FAIL\" # cart is invalid ie when items in the cart are sold out \n end\n end", "def sg_add_to_cart_from_quickview\n add_to_cart_btn.click\n sleep TimeOut::WAIT_MID_CONST\n end", "def adding_to_cart\n \n sleep(2)\n puts \"click c1 ethnicwear\"\n ethnic_wear.click\n wait_for_spinner\n sleep(2)\n puts \"movin cursor over c1\"\n $driver.action.move_to(ethnic_wear).perform\n $driver.find_element(:css, \".submenu > li:nth-child(1) > ul > li > ul > li > ul > li > ul > li:nth-child(1) > ul > li:nth-child(1) > a.col-dark-grey\").click\n \n wait_for_spinner\n sleep(3)\n\n @product_flag=0\n i=4 # selection start from 4th product\n j=1 # selecting size from first\n\n \n begin \n\n puts \"clicking on product #{i}\"\n $driver.find_element(:css,\"#product-container > div.ng-isolate-scope > ul > li:nth-child(#{i}) > div > div.product-image > a > img\").click\n wait_for_spinner\n sleep(2)\n if options.displayed?\n puts \"selecting size\"\n begin\n $driver.find_element(:css,\".in-stock:nth-child(#{j}) div\").click\n add_to_cart_button.click\n @product_flag=1\n rescue\n if (j>7) # if size is exhausted\n break\n else\n j=j+1\n end\n retry\n end\n else\n begin \n sleep(3)\n puts \"no size found. add to cart ...\"\n add_to_cart_button.click\n @product_flag=1\n rescue\n puts \"product got soldout (or) product not available\"\n i=i+1 # to select the next product\n #wait_for_spinner\n end \n end\n\n end while @product_flag!=1\n puts @prod1 = productviewpage_productname.text.downcase\n\n end", "def add_product_to_cart(product_id)\n product = look_up_product(reference_number)\n if product != nil\n @shopping_cart << product\n puts \"Yay! Your #{product[:name]} has been added to your cart.\"\n else\n puts \"We don't have that\"\n end\nend", "def add_to_cart\n cart_op do |cart|\n if params[:id].class == Array\n params[:id].collect!(&:to_i)\n params[:id].delete_if {|id| cart.include?(id) }\n cart = cart + params[:id]\n else\n cart << params[:id].to_i if not params[:id].blank? and not get_cart.find {|i| i == params[:id].to_i }\n end\n cart\n end\n render_cart_size\n end", "def add_sku_to_cart(go_to_cart = true)\n add_to_cart_on_search_btn.click\n wait_for_ajax\n\n return unless go_to_cart\n nav_account_menu.appcenter_cart_link.click\n wait_for_ajax\n\n AppCenterCheckOutATG.new\n end", "def add_to_cart(product, amount)\n purchase = \" • #{amount} #{product}\\n\"\n @cart << purchase\n\n cost_per_item = @inventory[product][\"price\"]\n @total_cart_value += (cost_per_item * amount)\n\n @inventory[product][\"quantity\"] -= amount\nend", "def create\n # clear_cart param can be added if restaurant or location changed for initial\n # this means that we need to clear the cart before add anything to it\n if params[:clear_cart] == '1'\n @current_cart.clear!\n @current_cart.force_location session[:current_location]\n end\n # add item to cart\n @current_cart.add_product line_item_params[:product_id], line_item_params[:count], line_item_params[:note], line_item_params[:product_option_ids]\n # add related products if exists\n for i in 0..2\n unless params[\"related_product_#{i}\"].nil?\n @current_cart.add_product params[\"related_product_#{i}\"], params[\"related_product_count_#{i}\"] || 1\n end\n end\n end", "def proceed_to_checkout\n \n order = Order.new\n order.cart_id = @cart.id\n order.responseCode = 100\n order.responseDescription = \"Tests added to your account.\"\n order.save!\n \n cart = Cart.find(order.cart_id)\n \n # Add each cartitem to user's account.\n cart.cart_items.each do | cart_item |\n if cart_item.quiz_id != nil\n # Add Quiz\n quiz_user = QuizUser.new\n quiz_user.quiz_id = cart_item.quiz_id\n quiz_user.user_id = current_user.id\n quiz_user.save!\n end\n end\n \n redirect_to homes_index_path, notice: \"Test added to your account.\"\n end", "def add_to_cart\n session[:item_list] ? session[:item_list] << @product.id : session[:item_list] = [@product.id]\n respond_to do |format|\n format.html { redirect_to products_url, notice: 'Product added to cart!' }\n format.json { head :no_content }\n end\n end", "def add\n id = params[:id] \n cart[id] ? cart[id] = cart[id] + 1 : cart[id] = 1 \n flash[:notice] = \"Added to cart\"\n redirect_to :back\n end", "def add_to_cart\n\t\tcart_hash = session[:cart]\n\t\tproduct = find_key(cart_hash, params[:id])\n\t\tproduct[:quantity] += 1\n\t\tcart_hash[params[:id]] = product\n\n\t\tredirect_to root_url\n\tend", "def add_package_to_customer_cart\n # get params\n @package_id = params[:id]\n @customer_drink_quantity = params[:quantity].to_i\n \n # get drink info\n if user_signed_in?\n @user = current_user\n else\n # first create an account\n @account = Account.create!(account_type: \"consumer\", number_of_users: 1)\n \n # next create fake user profile\n @fake_user_email = Faker::Internet.unique.email\n @generated_password = Devise.friendly_token.first(8)\n \n # create new user\n @user = User.create(account_id: @account.id, \n email: @fake_user_email, \n password: @generated_password,\n password_confirmation: @generated_password,\n role_id: 4,\n getting_started_step: 0,\n unregistered: true)\n \n if @user.save\n # Sign in the new user by passing validation\n bypass_sign_in(@user)\n #Rails.logger.debug(\"Current user: #{current_user.inspect}\")\n end\n end #end of check whether user is already \"signed in\"\n \n @special_package = SpecialPackage.find_by_id(@package_id)\n \n # find if customer currently has an order in process\n @current_order = OrderPrep.where(account_id: @user.account_id, status: \"order in process\").first\n \n if @current_order.blank? # create a new Order Prep entry\n @current_order = OrderPrep.create!(account_id: @user.account_id, status: \"order in process\")\n end\n \n # now check if this inventory item already exists in the Order Drink Prep table\n @current_drink_order = OrderDrinkPrep.where(user_id: @user.id,\n order_prep_id: @current_order.id,\n special_package_id: @package_id)\n \n if !@current_drink_order.blank? #update entry\n if @customer_drink_quantity != 0\n @current_drink_order.update(quantity: @customer_drink_quantity)\n else\n @current_drink_order[0].destroy!\n end\n else # create a new entry\n OrderDrinkPrep.create!(user_id: @user.id,\n account_id: @user.account_id,\n special_package_id: @package_id,\n order_prep_id: @current_order.id,\n quantity: @customer_drink_quantity,\n drink_price: @special_package.actual_cost)\n end\n\n # find total drink number in cart\n @order_prep_info = OrderDrinkPrep.where(order_prep_id: @current_order.id)\n @customer_number_in_cart = @order_prep_info.sum(:quantity)\n # get total amount in cart so far\n @subtotal = @order_prep_info.sum( \"drink_price*quantity\" ) \n @sales_tax = @subtotal * 0.101\n @total_drink_price = @subtotal + @sales_tax\n\n # if all drinks have been removed, delete the order prep\n if @customer_number_in_cart.to_i == 0\n @current_order.destroy!\n else\n if @current_order.delivery_fee.nil?\n @grand_total = @total_drink_price\n else\n @grand_total = @current_order.delivery_fee + @total_drink_price\n end\n # update Order Prep with cost info\n @current_order.update(subtotal: @subtotal, \n sales_tax: @sales_tax, \n total_drink_price: @total_drink_price,\n grand_total: @grand_total)\n end\n \n # update page\n respond_to do |format|\n format.js\n end # end of redirect to jquery\n \n end", "def add_item_to_cart(item_id)\n cart << item_id\n end", "def create\n #This will find or create a cart based on applications controller method\n @cart = current_cart\n #We use params to get the product ID from the request\n #This is stored locally as no need to let view see it\n product = Product.find(params[:product_id])\n \n #Adds an item to the cart using the \"add_product\" \n #function in the \"cart.rb\" file.\n @line_item = @cart.add_product(product.id)\n\n respond_to do |format|\n if @line_item.save\n format.html { redirect_to(store_url) }\n #.js is added to stop the create action from \n #redirecting to the index display if the request is \n #from javascript\n format.js { @current_item = @line_item }\n format.json { render json: @line_item, status: :created, location: @line_item }\n else\n format.html { render action: \"new\" }\n format.json { render json: @line_item.errors, status: :unprocessable_entity }\n end\n end\n end", "def add_to_cart\n \tline_item = LineItem.create(product_id: params[:product_id], quantity: params[:quantity])\n \tline_item.update(line_item_total: (line_item.quantity * line_item.product.price))\n \tredirect_back(fallback_location: root_path)\n end", "def add_to_cart\n order = Cart.create(customer_id: @customer.id, hotel_id: params[:cart][:hotel_id], item_id: params[:cart][:item_id],\n item_quantity: params[:cart][:item_quantity], item_name: params[:cart][:item_name], item_price: params[:cart][:item_price], total_price: params[:cart][:total_price] )\n if order\n render json: {\n messages: \"Successfully added to cart!\",\n is_success: true,\n orders: order\n }, status: :created\n else\n render json: {\n messages: \"Unable to add\",\n is_success: false,\n orders: {}\n }, status: :internal_server_error\n end\n end", "def add_items_to_cart(cart)\n cart.cart_items.each do |item|\n @command.shopping_cart.create_item do |i|\n i.name = item.name\n i.description = \"\"\n i.unit_price = Money.new(item.product_price * 100, \"USD\")\n i.quantity = item.quantity\n end\n end\n end", "def checkout\n @current_cart.adjust_inventory\n @current_cart.mark_submited\n current_user.remove_current_cart\n redirect_to cart_path(@current_cart)\n end", "def set_cart\n if @current_user.nil?\n redirect_to login_path\n elsif @current_user.carts.nil?\n @cart = Cart.create( user_id: @current_user.id )\n elsif @current_user.carts.where( purchase_completed: false ).empty?\n @cart = Cart.create( user_id: @current_user.id )\n else\n @cart = @current_user.carts.find_by( purchase_completed: false )\n end\n # redirect_to cart_path( @cart )\n end", "def create\n #@cart = current_cart\n product = Product.find(params[:product_id])\n #@line_items = @cart.line_items.build(product: product)\n @line_items = @cart.add_item(product.id)\n \n respond_to do |format|\n if @line_items.save\n format.html { redirect_to store_url,\n notice: 'your cart was successfully created.'}\n format.js { @current_item = @line_items }\n format.json {render :show,\n status: :created, location: @line_items }\n else\n format.html {render action: \"new\" }\n format.json { render json: @line_items.errors, status: unprocessable_entity }\n end\n end\n end", "def add_product(name, price)\n new_product = Product.new(name, price)\n @products_in_cart << new_product\n new_product\nend", "def create\r\n @cart_item = CartItem.new(cart_item_params)\r\n @cart_item.user = current_user\r\n\r\n if is_enough && @cart_item.save\r\n @cart_item.buy # pre-emtively \"buys\" the item to save it from other users\r\n flash[:notice] = \"Item was added to cart!\"\r\n else\r\n flash[:danger] = \"Item could not be added to cart!\"\r\n end\r\n redirect_to products_path\r\n end", "def add_items_from_cart(cart)\n cart.line_items.each do |item|\n self.line_items << item if item.sufficient_stock?\n end\n end", "def create\n # Find associated product and current cart\n chosen_cabinet = CabConfig.find(params[:cab_config_id])\n current_cart = @current_cart\n \n # If cart already has this product then find the relevant line_item and iterate quantity otherwise create a new line_item for this product\n if current_cart.cab_configs.include?(chosen_cabinet)\n # Find the line_item with the chosen_product\n @cart_item = current_cart.cart_items.find_by(cab_config_id: chosen_cabinet)\n # Iterate the line_item's quantity by one\n @cart_item.quantity += 1\n else\n @cart_item = CartItem.new\n \n @cart_item.cart = current_cart\n @cart_item.cab_config = chosen_cabinet\n end\n \n\n # Save and redirect to cart show path\n @cart_item.save\n redirect_to cart_path(current_cart)\n end", "def add_to_cart(reference_number)\n product = find_product(reference_number)\n if product != nil\n @shopping_cart << product\n puts \"Congratulations. '#{product[:name]}' has been added to the cart!\"\n else\n puts \"Please select a valid reference number\"\n end\nend", "def create\n # grabbing cart from application controller current_cart method\n @cart = current_cart\n # session[:cart_id] = @cart.id\n # individual product items get added to cart item and added to cart and saved\n @cart_item = @cart.cart_items.build(cart_item_params)\n @cart.save\n end", "def add_product_to_cart(name, base_price)\n product = Products.new_product(name, base_price)\n shopping_cart << product\n end", "def add_stock_to_customer_cart\n # get params\n @customer_projected_rating_id = params[:id]\n @customer_drink_quantity = params[:quantity].to_i\n \n # get drink info\n if user_signed_in?\n @user = current_user\n @user_projected_ratings = ProjectedRating.where(user_id: current_user.id)\n else\n # first create an account\n @account = Account.create!(account_type: \"consumer\", number_of_users: 1)\n \n # next create fake user profile\n @fake_user_email = Faker::Internet.unique.email\n @generated_password = Devise.friendly_token.first(8)\n \n # create new user\n @user = User.create(account_id: @account.id, \n email: @fake_user_email, \n password: @generated_password,\n password_confirmation: @generated_password,\n role_id: 4,\n getting_started_step: 0,\n unregistered: true)\n \n if @user.save\n # Sign in the new user by passing validation\n bypass_sign_in(@user)\n #Rails.logger.debug(\"Current user: #{current_user.inspect}\")\n end\n end #end of check whether user is already \"signed in\"\n \n if !@user_projected_ratings.blank?\n @this_projected_rating = ProjectedRating.find_by_id(@customer_projected_rating_id)\n @inventory = Inventory.find_by_id(@this_projected_rating.inventory_id)\n @inventory_id = @inventory.id\n else\n @inventory = Inventory.find_by_id(@customer_projected_rating_id)\n @inventory_id = @inventory.id\n end\n \n # find if customer currently has an order in process\n @current_order = OrderPrep.where(account_id: @user.account_id, status: \"order in process\").first\n \n if @current_order.blank? # create a new Order Prep entry\n @current_order = OrderPrep.create!(account_id: @user.account_id, status: \"order in process\")\n end\n \n # now check if this inventory item already exists in the Order Drink Prep table\n @current_drink_order = OrderDrinkPrep.where(user_id: @user.id,\n order_prep_id: @current_order.id,\n inventory_id: @inventory_id)\n \n if !@current_drink_order.blank? #update entry\n if @customer_drink_quantity != 0\n @current_drink_order.update(quantity: @customer_drink_quantity)\n else\n @current_drink_order[0].destroy!\n end\n else # create a new entry\n OrderDrinkPrep.create!(user_id: @user.id,\n account_id: @user.account_id,\n inventory_id: @inventory.id,\n order_prep_id: @current_order.id,\n quantity: @customer_drink_quantity,\n drink_price: @inventory.drink_price_four_five)\n end\n\n # find total drink number in cart\n @order_prep_info = OrderDrinkPrep.where(order_prep_id: @current_order.id)\n @customer_number_in_cart = @order_prep_info.sum(:quantity)\n # get total amount in cart so far\n @subtotal = @order_prep_info.sum( \"drink_price*quantity\" ) \n @sales_tax = @subtotal * 0.101\n @total_drink_price = @subtotal + @sales_tax\n\n # if all drinks have been removed, delete the order prep\n if @customer_number_in_cart.to_i == 0\n @current_order.destroy!\n else\n if @current_order.delivery_fee.nil?\n @grand_total = @total_drink_price\n else\n @grand_total = @current_order.delivery_fee + @total_drink_price\n end\n # update Order Prep with cost info\n @current_order.update(subtotal: @subtotal, \n sales_tax: @sales_tax, \n total_drink_price: @total_drink_price,\n grand_total: @grand_total)\n end\n \n # update page\n respond_to do |format|\n format.js\n end # end of redirect to jquery\n \n end", "def add_product_to_cart_from_catalog(prod_id)\r\n if has_xpath?(\"//*[@id='#{prod_id}']//a[contains(text(),'Add to Cart')]\", wait: TimeOut::WAIT_MID_CONST)\r\n btn = find(:xpath, \"//*[@id='#{prod_id}']//a[contains(text(),'Add to Cart')]\")\r\n else\r\n btn = find(:xpath, \"//*[@id='#{prod_id}']//button[contains(@class, 'btn-add-to-cart')]\")\r\n end\r\n\r\n # Click on Add to Cart\r\n btn.click\r\n\r\n # process if item has multi colors\r\n get_product_in_stock('', true)\r\n end", "def check_cart item\n \tcheck = false\n \t#Doc tat ca san pham trong cart session\n \tsession[\"cart\"].each do |x|\n \t\t#So sanh ID product voi ID product trong gio hang\n \t\tif x['id'] == item[:id]\n \t\t\tx['quantity'] = x['quantity'] + 1\n \t\t\tx['total'] = x['price'] * x['quantity']\n \t\t\treturn\n \t\tend\n \tend\n \tsession[\"cart\"].push(item)\n end", "def add_cart(cart)\n @cart = cart\n end", "def cart\n type = params[:type]\n\n if type == \"addcart\"\n #current_user.cart_additions << @item\n current_user.carts.create!(:item =>@item, :iscart? =>true)\n redirect_to cart_index_path, notice: \"#{@item.name} was added to your cart\"\n elsif type == \"removecart\"\n current_user.carts.update(:item =>@item, :iscart? =>false)\n #current_user.cart_additions.delete(@item)\n redirect_to root_path, notice: \"#{@item.name} was removed from your cart\"\n else\n redirect_to item_path(@item), notice: \"Looks like nothing happened. Try again!\"\n\n end\n end", "def add_item\n @item =\n if params[:cart_type].eql? 'product'\n Product.find_by(id: params[:product_id])\n elsif params[:cart_type].eql? 'junkyard'\n JunkyardProduct.find_by(id: params[:product_id])\n end\n\n if @item\n @user.carts.where(product_id: @item, aasm_state: params[:cart_type]).first_or_create\n else\n @object = 'Product or Junkyard'\n render \"api/v1/errors/404\", status: 401\n end\n end", "def add_to_cart_common(add_method, arguments, options = {})\n cart_model_options = options.reject { |key,val| [:suppress_redirect,:create_anon_cart].include?(key)}\n \n redirect = { :action => '' }\n \n if params[:token] || options[:create_anon_cart]\n cart = Cart.create\n session[:anonymous_cart_id] = cart.id\n cart.send(add_method, params[:id], cart_model_options)\n redirect = {:action => 'checkout', :token => params[:token]}\n else\n cart = get_cart()\n cart.send(add_method, arguments, cart_model_options)\n end\n \n \n rescue DuplicateItem => de\n flash[:message] = 'Duplicate item was not added to cart' # + de.inspect\n rescue Exception => e\n flash[:message] = 'Error: Add to cart operation failed' # + e.inspect\n ExceptionNotifier::Notifier.exception_notification(request.env, e, :data => {:message => \"was doing something wrong\"}).deliver\n ensure\n redirect_to(redirect) unless options[:suppress_redirect]\n end", "def add(items)\n\t\t\tcart = Cart.perform_request Cart.api_url(\"carts/#{self.id}\", {}), :patch,\n\t\t\t\t{ op: \"add\",\n\t\t\t\t\titems: items.map { |item| { product_id: item[:product_id], quantity: item[:quantity], variant_id: item[:variant_id] }\n\t\t\t\t}}, true\n\n\t\t\tif cart\n\t\t\t\tCart.new(cart[\"data\"])\n\t\t\telse\n\t\t\t\tfalse\n\t\t\tend\n\t\tend", "def add_item(item, price, quantity = 1)\n self.total += price * quantity\n self.last_item = price\n self.last_quantity = quantity\n\n counter = 0\n while counter < quantity\n self.cart << item\n counter += 1\n end\n self.cart\n end", "def add_to_cart\n @product = Product.find(params[:id])\n Cart.add_to_cart(session[:cart], params[:id], params[:cart][:quantity], params[:cart][:size], params[:cart][:size2])\n redirect_to product_path(@product)\n end", "def add_to_cart\n @product = Product.find(params[:id])\n # alert user if product is out of stock\n if @product.qty_in_stock == 0\n flash[:notice] = \"Sorry, \" + @product.name + \" is currently out of stock. Please check back soon!\"\n else\n # check if a cart already exists in the session\n if cookies[:cart_id]\n @cart = Cart.find_by_id(cookies[:cart_id])\n else # if not, create a new cart\n @cart = Cart.create(:status => 'current')\n cookies[:cart_id] = @cart.id\n # if user is logged in, associate cart with that user\n if logged_in?\n @cart.attach_to_user(@current_user.id)\n end\n end\n \n # check if item already exists in cart \n @item = @cart.items.where(:product_id => @product.id).first\n if @item.blank? #if not, create a new item\n @item = @cart.items.create(:product_id => @product.id, :name => @product.name, \n :price => @product.price, :qty => 0)\n end\n @item.add\n\n # TODO: give the cookie an expiration date so that the product can be restored if not bought?\n flash[:notice] = @product.name + \" has been added to your cart.\"\n end\n # stay in the same view\n redirect_to :controller => 'products', :action => 'show', :id => @product.id\n end", "def create\n product=Product.find(params[:product_id])\n\t # @line_item= @cart.line_items.build(product: product)#from set_cart we'l get @cart cart and build is use for building new lineitems for product\n\t @line_item = @cart.add_product(product.id) # call from Cart.rb\n \trespond_to do |format|\n\t\t if @line_item.save\n\t\t\t format.html { redirect_to store_url,\n\t\t\t\t\tnotice: 'Line item was successfully created.' }\n\n\t\t\t\t\tformat.js { @current_item = @line_item }\n\t\t\t\t\tformat.json { render action: 'show',\n\t\t\t\t\tstatus: :created, location: @line_item }\n\t\t\t else\n\t\t\t\t\tformat.html { render action: 'new' }\n\t\t\t\t\tformat.json { render json: @line_item.errors,\n\t\t\t\t\tstatus: :unprocessable_entity }\n\t\t\t end\n end\n session[:counter] = 0\n end", "def checkout\n\ttotal = shopping_cart.inject {|sum, item| sum + item.price}\n\n\t...\nend\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n#>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>END>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>", "def add_cart\n\t\tcart = Cart.create()\n\t\tCart.find(params[:cart]).items.each do |item|\n\t\t\tcart.items.push(item)\n\t\tend\n\t\tcurrent_user.saved.add_cart(cart)\n\t\tif current_user.saved.errors.empty?\n\t\t\tredirect_to saved_path, :notice => \"Cart saved\"\n\t\telse\n\t\t\tredirect_to :back, :notice => current_user.saved.errors.full_messages().last\n\t\tend\n\tend", "def add\n response.headers['Content-type'] = \"text/plain; charset=utf-8\"\n unless cookies[:cart].nil?\n @cart = Cart.find_by_unique_identifier(cookies[:cart])\n unless @cart.nil?\n @cart.add_product_to_products(params[:catalog_id], params[:product_id])\n if @cart.save\n render :text => {:cart => { 'result' => true, 'cart_unique_id' => @cart.unique_identifier, 'products_count' => @cart.products_count(params[:catalog_id]), 'product_count' => @cart.product_count(params[:catalog_id],params[:product_id])}}.to_json()\n else\n render :text => {'result' => false }.to_json()\n end\n else\n render :text => {'result' => false }.to_json()\n end\n else\n @cart = Cart.new()\n # @cart.catalog_id = params[:catalog_id]\n @cart.unique_identifier = BCrypt::Engine.hash_secret(\"#{@cart.id}\", BCrypt::Engine.generate_salt)\n @cart.add_product_to_products(params[:catalog_id], params[:product_id])\n if @cart.save\n # render :text => {:cart => {'result' => true, 'cart_unique_id' => @cart.unique_identifier }}.to_json()\n render :text => {:cart => { 'result' => true, 'cart_unique_id' => @cart.unique_identifier, 'products_count' => @cart.products_count(params[:catalog_id]), 'product_count' => @cart.product_count(params[:catalog_id],params[:product_id])}}.to_json()\n else\n render :text => {'result' => false }.to_json()\n end\n end\n end", "def prepare_cart\n\n\t\tfind_cart_items\n\t\t\n\t\tset_cart_price\n\t\t\n\t\tset_cart_payments\n\t\t\n\t\tset_cart_paid_amount\n\t\t\n\t\tset_cart_pending_balance\n\n\t\tset_cart_minimum_payable_amount\n\n\t\tset_discount\n\n\tend", "def save_cart\n \tself.status = 'saved'\n \tself.save\n end", "def create\n @order = Order.new(order_params)\n @total = 0\n current_cart.lineitems.each{|line|\n @total = AddService.call(@total.to_i, line.product.price * line.quantity)\n }\n @order.add_lineitem_from_cart(current_cart)\n @order.customer_id = @current_customer.id\n @order.total = @total\n #Use of logger class to log messages into the log file\n Logger.instance.log(Time.now.to_s + \": Order created by user \\n\")\n\n if @order.save\n Cart.destroy(session[:cart_id])\n session[:cart_id] = nil\n flash[:success] = 'Thank You for your order.'\n redirect_to root_path\n else\n @cart = current_cart\n render 'new'\n end\n end", "def add_item_verify\n\t\twait_for_animate\n\t\tvalue1= query(\"* marked:'quantityText'\", :text)[0]\n\t\tguide_price1 = query(\"* marked:'basket_action_bar_up'\", :text)[0]\n\t\tputs \"Quantity Before Add Item : : #{value1}\"\n\t\ttouch(\"* id:'add_btn'\")\n\t\twait_for_animate\n\t\tsleep 4\n\t\t#wait_for_elements_exist( [\"button marked:'Open basket'\"], :timeout => 40)\n\t\tvalue2 = query(\"* marked:'quantityText'\", :text)[0]\n\t\tif (value2 == \"0\")\n\t\t\tvalue2 = query(\"* marked:'quantityText'\", :text)[3]\n\t\tend\n\t\tguide_price2 = query(\"* marked:'basket_action_bar_up'\", :text)[0]\n\t\tputs \"Quantity After Add Item: : #{value2}\"\n\t\t#campare_values(value1,value2)\n\t\t#campare_values(guide_price1,guide_price2)\n\t\t#puts \"Item added successfully\"\n\n\tend", "def add_to_cart(id, quantity = 1)\n product_id_input.set id\n search_product_btn.click\n wait_for_ajax\n view_product_btn.click\n wait_for_ajax\n flag = 0\n sku = nil\n title = nil\n product_view_tbl.each do |tr|\n within tr do\n if has_xpath?(\"td[contains(text(),'In Stock')]\", wait: 1)\n find(:xpath, \"td/input[@type='text']\").set quantity\n flag = 1\n sku = find(:xpath, 'td[2]').text\n title = find(:xpath, 'td[3]').text\n end\n end\n break if flag == 1\n end\n add_to_cart_on_view_btn.click\n wait_for_ajax\n\n return \"Cannot add sku: #{sku} to cart\" if has_error_message_txt?(wait: TimeOut::WAIT_MID_CONST)\n { sku: sku, title: title }\n end", "def create\n # Find the item in the user's cart, if the user does not already\n # have the item in their cart, create a new line_item\n current_item = LineItem.find_or_create_by product_size_id: params[:product_size_id], cart_id: @cart.id\n\n # Increment the item's quantity by one\n requested_qty = current_item.quantity + 1\n\n # Invoke method in line_item.rb that checks the\n # requested qty against current stock levels\n update_qty = current_item.get_update_qty requested_qty\n\n # If the user's requested quantity can not be fulfilled, set a flash error\n unless update_qty == requested_qty\n flash[:item_error] = \"Sorry, not enough stock. Your shopping basket has been adjusted accordingly.\"\n end\n\n # Save the line_item update\n current_item.update quantity: update_qty\n\n # Redirect to My Basket page\n redirect_to cart_path\n end", "def checkout \n system 'clear'\n CoffeeMan.stay_logo\n if @@cart.count == 0 \n puts \"Your cart is empty, please select an item\"\n sleep 1\n main_menu \n else\n system('say \"Already blocked it in my calendar!\"')\n puts \"Your order has been confirmed of #{@@cart.join(\", \")}. It will be ready for pickup in #{rand(20...40)} minutes! Can't wait to hangout!\"\n puts \"Already blocked it in my calendar!\".colorize(:color => :light_blue, :background => :yellow)\n stop_music \n sleep 2\n end\n end", "def success\n if session[:purchased_item] == '0'\n @items = items_from_cart\n session.delete(:cart)\n else\n item = Product.find(session[:purchased_item])\n @items = []\n @items << { name: item.name, price: item.price, image: item.product_images[0].image.url(:thumb), quantity: session[:quantity] }\n end\n @sum = 0\n @count = 0\n @items.each do |item|\n @sum += item[:price] * item[:quantity].to_i\n @count += item[:quantity].to_i\n end\n end", "def add_product(product)\r\n\t\t@shopping_cart << product\r\n\t\t@item_count +=1\t\t# add one to the item counter\r\n\tend", "def require_cart_to_have_items\n if shopping_cart.empty?\n redirect_to(cart_items_path, alert: 'Tu carrito está vacio, deberías agregar items a tu carrito antes.')\n end\n end", "def add_to_cart\n @item = Item.find(params[:id])\n if current_user\n current_user.cart.cart_items.create(item: @item)\n flash[:notice] = \"#{@item.name} was added to the cart\"\n else\n flash[:alert] = \"You have to be signed in to add items to your cart\"\n end\n redirect_to items_path\n end", "def start(cart_name)\n @state.value = OpenShift::State::STARTED\n cart_model.do_control(\"start\", cart_name)\n end", "def add_checkout msg\n #click button\n self.buy\n \n #deal with a pop-up - click checkout\n Watir::Wait.until {browser.text.include?(msg)}\n \n browser.link(:href => 'http://store.demoqa.com/products-page/checkout/').focus \n browser.send_keys :enter\n \n #return shopping cart page\n next_page = Checkout_Cart.new(browser)\n next_page.loaded?\n next_page \n end", "def add_to_cart\n product = Product.find(params[:id])\n @cart.add_product(product)\n redirect_to(:action => 'display_cart')\n rescue\n logger.error(\"Attempt to access invalid product #{params[:id]}\")\n redirect_to_index('Invalid product')\n end", "def add_to_cart\n @item = Item.find(params[:id].to_i)\n\n if current_user\n check_if_item_exists_in_cart(current_cart, @item, params[:redirect_to])\n @items_count = current_cart.items.count\n else\n check_if_item_exists_in_cart(guest_cart, @item, params[:redirect_to])\n @items_count = guest_cart.count\n end\n \n render plain: @items_count\n end", "def add_product_to_order\n prod_id = params[:id].to_i\n qty_to_order = params[:qty].to_i\n\n add_or_update_product_qty(prod_id, qty_to_order)\n\n flash[:notice] = 'Product added to cart'\n redirect_back(fallback_location: root_path)\n end", "def save_order\n @order = Order.new(params[:order]) \n @order.line_items << @cart.items \n if @order.save \n @cart.empty!\n redirect_to_index('Thank you for your order.')\n else\n render(:action => 'checkout') \n end\n end", "def add_cart(cart)\n \tif cart.items.empty?\n\t\t\terrors.add(:cart, 'is empty. Cannot save.')\n \telse\n \t\tself.carts.push(cart)\n \tend\n end", "def add_to_cart_if_temp_cart\n if session[:temp_cart]\n \n product_params = session[:temp_cart]\n product_params[\"user_id\"] = logged_in\n @cart_product = CartProduct.new(product_params)\n @cart_product.save\n session[:temp_cart] = nil\n \n # Then remove from savedlist\n session[:savedlist] ||= []\n session[:savedlist].delete(product_params[\"product_id\"])\n \n # Then update popularity of product\n increase_product_popularity_by_product_id(product_params[\"product_id\"])\n return true\n end\n return false\n end", "def create\n @cart = current_cart\n product = Product.find(params[:product_id])\n\n if product.quantity > 0 \n @line_item = @cart.add_product(product.id)\n product.update_attributes(:quantity => product.quantity - 1)\n end\n\n respond_to do |format|\n if @line_item\n if @line_item.save\n format.html { redirect_to store_url}\n format.js { @current_item = @line_item}\n format.json { render json: @line_item, status: :created, location: @line_item }\n else\n format.html { render action: \"new\" }\n format.json { render json: @line_item.errors, status: :unprocessable_entity }\n end\n else\n format.html {redirect_to store_url, :notice => 'Sorry! Looks like that product is out of stock'}\n end\n end\n end", "def create\n # Invokes action in cart.rb that checks whether the cart is empty\n if @cart.is_cart_empty?\n # If the cart is empty, set flash error and redirect to My Basket page\n flash[:item_error] = \"Your cart is empty.\"\n redirect_to cart_path\n return\n end\n\n # Create order and redirect to orders#confirm_order\n @order = Order.create user_id: @current_user.id\n redirect_to confirm_order_path\n end", "def add\n quantity = params[:quantity].try(:to_i) || 1\n if !add_item?(params[:id], quantity)\n flash[:warning] = 'Invalid input'\n end\n redirect_to cart_index_path\n end", "def add_item_to_cart\n puts \"What would you like to add to your cart?\"\n# Here it grabs a list of everything in store items\n @store_items.each_with_index do |product, index|\n puts \"#{index + 1}: #{product[:item]} - $#{product[:price]}.00\"\n end\n# user chooses the item by number and i minus one so the computer grabs that index\n item_input = gets.strip.to_i - 1\n # this will take the index item the end user selected from the store items and push it to the user cart\n @user_cart << @store_items[item_input]\n\n puts \"Would you like to add more products to your cart?\"\n puts \"1) Yes\"\n puts \"2) No\"\n menu_input = gets.strip.to_i\n\n if menu_input == 1\n add_item_to_cart\n elsif menu_input == 2\n main_menu\n else\n puts \"invalid input.... taking you back to the menu\"\n main_menu\n end\nend", "def call(_obj, args, _ctx)\n product = Product.find_by(id: args[:product_id])\n cart = ShoppingCart.find_by(user_id: args[:user_id])\n if product.nil?\n raise GraphQL::ExecutionError, \"Product with the product id #{args[:product_id]} does not exist.\"\n end\n existing = cart.cart_items.find_by(product_id: product.id)\n if existing.nil?\n cart.cart_items.create(product_id: product.id, quantity: args[:quantity])\n cart.completed = false\n puts cart.cart_items\n else\n existing.quantity += args[:quantity]\n cart.completed = false\n cart.save\n existing.save\n end\n cart.total_cost += product.price * args[:quantity] + product.shipping\n cart.save\n cart\n end", "def add_item_to_cart\n\tputs \"------------------------------------ PRODUCT LISTING ------------------------------------\"\n\n\t# Displays all the items\n\t@array_of_items.each_with_index do |item, index|\n\t\t# Displays the item\n\t\tputs \"(#{index+1}) Name: #{item.name} || Price: $#{item.price} || Shipping Cost: $#{item.shipping_cost}\"\n\tend\n\tputs \"(99) View more products in this category\"\n\tputs \"-----------------------------------------------------------------------------------------\"\n\n\n\t# Allow the user to select an item and add it to the cart\n\tvalid_input = false\n\tputs \"\\n Select a number from the menu for the product that you want to add to the cart:\"\n\twhile !valid_input\n\t\tuser_input = gets.strip.to_i\n\t\t#Check if invalid input\n\t\tif user_input == 0\n\t\t\t# Invalid input\n\t\t\tputs \"You entered an invalid choice, please try again\"\n\t\telsif user_input == 99\n\t\t\t\n\t\telsif\n\t\t\t# Valid input\n\t\t\tvalid_input = true\n\t\t\t#Add the item to the cart\n\t\t\t@shopping_cart.add_item(@array_of_items[user_input-1])\n\t\t\tputs \"You successfully added #{@array_of_items[user_input-1].name} to your shopping cart!\"\n\t\tend\n\tend\nend", "def add_line_items_from_cart(cart)\n cart.line_items.each do |item|\n\t item.cart_id = nil\n \t line_items << item\n end\n end", "def create\n # Add params[:id] to cart\n # logger.debug(\"Adding #{params[:id]} to the cart----------------------------------------\")\n id = params[:id].to_i\n\n existing_item = session[:shopping_cart].map { |item| item[\"id\"] }\n\n unless existing_item.include?(id)\n item = { id: id, quantity: 1 }\n session[:shopping_cart] << item\n\n end\n redirect_to root_path\n end", "def cart_op\n session[:cart] = yield(get_cart)\n end", "def create\n @book_order = BookOrder.new(new_book_order_params)\n @book_order.cart = @cart\n @book_order.user = @current_user\n # @book_order.decrease_q\n @book_order.add_lineitems(@cart)\n if @book_order.save\n session.delete(:cart_id)\n redirect_to root_path, notice: 'Заказ оформлен.'\n else\n render :new\n end\n end", "def create\n session[:cart_id] = @cart.id\n @cart.line_items.create(cart_params[:line_items_attributes])\n end" ]
[ "0.7329773", "0.7258752", "0.72487384", "0.71752805", "0.7087249", "0.70594704", "0.70543087", "0.6980003", "0.6963486", "0.69622844", "0.69042856", "0.69042856", "0.68763524", "0.68760014", "0.6867254", "0.6861381", "0.68447375", "0.6841856", "0.67821884", "0.6746519", "0.6727628", "0.66913444", "0.6682439", "0.6681885", "0.6656959", "0.6650287", "0.66358", "0.6623231", "0.6621349", "0.6617275", "0.6610825", "0.66060126", "0.659624", "0.6588057", "0.65814", "0.6579932", "0.65526825", "0.6550911", "0.65395164", "0.65377647", "0.65358", "0.6535165", "0.6533011", "0.65259594", "0.65174943", "0.6510975", "0.65100044", "0.65033865", "0.6502654", "0.648896", "0.64725125", "0.6465268", "0.6458101", "0.6458019", "0.64540625", "0.6448152", "0.6442383", "0.64405483", "0.6437772", "0.6413682", "0.640749", "0.6401134", "0.64010644", "0.63930625", "0.6389025", "0.6380577", "0.63739586", "0.63732755", "0.6367644", "0.6358175", "0.63553435", "0.6343478", "0.6340103", "0.63320684", "0.63132733", "0.63039404", "0.6299984", "0.62987214", "0.62944", "0.6276627", "0.62718844", "0.62672526", "0.62651", "0.6256971", "0.6253132", "0.6250398", "0.6246166", "0.624369", "0.62385267", "0.6238494", "0.62342453", "0.62238044", "0.62217474", "0.62165624", "0.62130165", "0.62065315", "0.6203072", "0.6202286", "0.6201481", "0.62013876" ]
0.6698859
21
Start of index logic
def index # this method will pass the content of the cart to the page view if session[:cart] then @cart = session[:cart] # if session exists the pass cart contents to the cart view else @cart = {} # if the cart isnt a session the say the cart contents is empty end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def construct_index\n end", "def index ; @index ; end", "def index\r\n build_index unless @index\r\n @index\r\n end", "def index\r\n @index ||= 0\r\n end", "def start_pass(index)\n end", "def index_from_start(index); end", "def index\n @index ||= 1\n end", "def start_index(page)\n (page - 1) * @count + 1\n end", "def index; @index; end", "def index()\n INDEXES.find { |i| (self + i).exist? }&.yield_self { |i| self + i }\n end", "def index\n init(false,false)\n \n end", "def index\n logger.info 'Index of elements'\n end", "def index=(_arg0); end", "def ta_index\n end", "def perform\n index\n true\n end", "def current_start_index\n @current_page * @entries_per_page \n end", "def generate_indexes\n @first_page = first_page\n generate_index('index')\n generate_index('indexes')\n end", "def index(loc, offset=0) end", "def index?; end", "def start\n 0\n end", "def index_finalized\n index\n end", "def index\n set_index\n end", "def cursor_to_decision\n @index = 89\n end", "def index\n \n end", "def index\n set_index_options\n load_index if params[:reload].to_s.to_boolean(true)\n end", "def index\n set_index_options\n load_index if params[:reload].to_s.to_boolean(true)\n end", "def start\n noth\n end", "def start(example_count)\n end", "def start(example_count)\n end", "def index\n @@semaphore.synchronize {\n inner_index()\n }\n end", "def setting_index\n end", "def starting; end", "def set_StartIndex(value)\n set_input(\"StartIndex\", value)\n end", "def construct_index\n @logger.fine('Constructing index...')\n File.open(@index_path, 'wb') do |f|\n write_int(@data_timestamp, f) # The timestamp value - used to determine if an index is valid.\n write_int(0, f) # The first row - always at offset 0.\n @data.each_line { write_int(@data.pos, f) } # The rest of the rows.\n end\n end", "def _lex_index_offsets; end", "def _lex_index_offsets; end", "def _lex_index_offsets; end", "def _lex_index_offsets; end", "def index; end", "def index; end", "def index; end", "def index; end", "def index; end", "def index; end", "def index; end", "def index; end", "def index; end", "def index; end", "def index; end", "def index; end", "def index; end", "def index; end", "def index; end", "def index; end", "def index; end", "def index; end", "def index; end", "def index; end", "def index; end", "def index; end", "def index; end", "def index; end", "def index; end", "def index; end", "def index; end", "def index; end", "def index; end", "def index; end", "def index; end", "def index; end", "def index; end", "def set_StartIndex(value)\n set_input(\"StartIndex\", value)\n end", "def set_StartIndex(value)\n set_input(\"StartIndex\", value)\n end", "def set_StartIndex(value)\n set_input(\"StartIndex\", value)\n end", "def set_StartIndex(value)\n set_input(\"StartIndex\", value)\n end", "def set_StartIndex(value)\n set_input(\"StartIndex\", value)\n end", "def set_StartIndex(value)\n set_input(\"StartIndex\", value)\n end", "def set_StartIndex(value)\n set_input(\"StartIndex\", value)\n end", "def set_StartIndex(value)\n set_input(\"StartIndex\", value)\n end", "def setup_index\n @index_driver.setup_index\n end", "def reindex!\n indexed if generate_solr_index\n end", "def makeIndex()\n\t\tputs \"Indexing TlpDB...\" unless @options[:quiet]\n\n\t\tlineno = 1\n\t\tfor line in @dbFile do\n\t\t\tif line =~ /^name (.*)/ then\n\t\t\t\t@index[$1] = lineno\n\t\t\tend\n\t\t\tlineno = lineno.next\n\t\tend\n\n\t\tputs \"Done. #{@index.size} packages\" unless @options[:quiet]\n\tend", "def lttfindex\n end", "def index\n \t\n end", "def index\n \t\n end", "def start! *_\n self.count = 0\n end", "def index\n \n end", "def index\n \n end", "def index\n \n end", "def start record\n end", "def _lex_index_offsets=(_arg0); end", "def _lex_index_offsets=(_arg0); end", "def _lex_index_offsets=(_arg0); end", "def _lex_index_offsets=(_arg0); end", "def index\n\t\t\n\tend", "def index\n\t\t\n\tend", "def index\n\t\t\n\tend", "def index\n\t\t\n\tend", "def index\n\t\t\n\tend", "def check_index_walk\n if first['index_walk']\n @cost = limit\n add_message(\"index_walk\")\n end\n end", "def start_index\n return 0 if self.total_results == 0\n si = ((self.current_page - 1) * self.results_per_page)\n return (si >= 0 ? si + 1 : 0)\n end" ]
[ "0.7182834", "0.7143137", "0.6997526", "0.67670715", "0.67556", "0.67477393", "0.670621", "0.67032975", "0.6649499", "0.65923375", "0.6587755", "0.65256107", "0.64987653", "0.6378591", "0.6364617", "0.6360411", "0.6356636", "0.6314522", "0.6292073", "0.6280942", "0.6229948", "0.62186235", "0.6217476", "0.621591", "0.6204602", "0.6204602", "0.61778027", "0.61606747", "0.61606747", "0.61516476", "0.61481106", "0.6145942", "0.6138178", "0.6132242", "0.6117068", "0.6117068", "0.6117068", "0.6117068", "0.610494", "0.61043006", "0.61043006", "0.61043006", "0.61043006", "0.61043006", "0.61043006", "0.61043006", "0.61043006", "0.61043006", "0.61043006", "0.61043006", "0.61043006", "0.61043006", "0.61043006", "0.61043006", "0.61043006", "0.61043006", "0.61043006", "0.61043006", "0.61043006", "0.61043006", "0.61043006", "0.61043006", "0.61043006", "0.61043006", "0.61043006", "0.61043006", "0.61043006", "0.61043006", "0.61043006", "0.61043006", "0.61043006", "0.60929495", "0.60929495", "0.60929495", "0.60929495", "0.60929495", "0.60929495", "0.60929495", "0.60929495", "0.608562", "0.60779375", "0.60362023", "0.6028041", "0.6026642", "0.6026642", "0.60227686", "0.60206324", "0.60206324", "0.60206324", "0.60179806", "0.60178286", "0.60178286", "0.60178286", "0.60178286", "0.60131055", "0.60131055", "0.60131055", "0.60131055", "0.60131055", "0.60104984", "0.6009054" ]
0.0
-1
Method to Clear the cart
def clearCart #sets session variable to nil and bring back to index session[:cart] = nil redirect_to :action => :index end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def clear_cart\n update_cart({})\n end", "def cart_clear\n cc = CartClear.new\n cc.params.merge!( { 'CartId' => @cart_id, 'HMAC' => @hmac } )\n cart = search( cc, @rg ).cart_clear_response.cart\n @cart_items = []\n @saved_for_later_items = []\n end", "def clear_cart(cart)\n cart(:CartClear, {:CartId => cart.cart_id, :HMAC => cart.hmac})\n end", "def clear_cart\n items=CartItem.where(:cart_id=>self.id)\n items.each do |item|\n item.destroy\n end\n end", "def clear_cart\r\n session[:cart] = []\r\n flash[:info] = 'Cart has been emptied!'\r\n redirect_to root_url\r\n end", "def clearCart\n \tsession[:cart] = nil\n \tredirect_to :action => :index\n end", "def clear_item_from_cart\n\t\tcart_hash = session[:cart]\n\n\t\tredirect_to root_url\n\tend", "def clear\n session[:cart] = nil\n redirect_to :action => :index\n end", "def destroy\n\t\t@cart_item.destroy\n\n\t\thead :no_content\n\tend", "def clear_carts\n current_user.carts.each_with_index do |cart, i|\n cart.delete if i != current_user.carts.length - 1\n end\n end", "def empty_cart\n self.each do |item|\n item.cart_id = nil\n item.save!\n end\n end", "def empty_cart\n puts \"========= Emptying Cart\"\n @b.goto 'http://shoppingcart.aliexpress.com/shopcart/shopcartDetail.htm'\n\n if @b.link(class: \"remove-all-product\").exists?\n @b.link(class: \"remove-all-product\").click\n @b.div(class: \"ui-window-btn\").button.click\n end\n end", "def empty_cart\n puts \"========= Emptying Cart\"\n @b.goto 'http://shoppingcart.aliexpress.com/shopcart/shopcartDetail.htm'\n\n if @b.link(class: \"remove-all-product\").exists?\n @b.link(class: \"remove-all-product\").click\n @b.div(class: \"ui-window-btn\").button.click\n end\n end", "def delete\n\t\t@cart.delete(:item_id)\n end", "def destroy\n\t\t@cart.destroy\n\t\tsession.delete(:cart)\n\tend", "def my_cart\n @cart = @current_branch.carts.find(current_cart.id)\n @cart.line_items.where(:quantity => 0).destroy_all\n render layout: 'mobile/application'\n end", "def destroy\n @cart_item.destroy\n\n head :no_content\n end", "def destroy\n @in_shopping_cart.destroy\n end", "def show\n @cart.destroy_cart_items\n\n end", "def destroy\n @cart = current_cart\n #need to first destroy each of the line items\n @cart.line_items.each do |i|\n i.destroy\n end\n #now destroy the cart and set the cookie to nil so that it will request a new cookie.\n @cart.destroy if @cart.id == session[:cart_id]\n session[:cart_id] = nil\n respond_to do |format|\n format.html { redirect_to '/', notice: 'Cart was successfully emptied.' }\n format.json { head :no_content }\n end\n end", "def delCart\n session.delete(:cart_id)\n end", "def shopping_cart_cleanup\n\n end", "def empty_cart\n @cart.empty!\n redirect_to_index('Your cart is now empty')\n end", "def destroy\n current_cart.line_items.destroy_all\n current_cart.destroy\n session[:cart_id] = nil\n session[:referer] = nil\n respond_to do |format|\n format.html { redirect_to(root_path) }\n format.xml { head :ok }\n end\n end", "def destroy\n if @cart.cart?\n @cart.destroy\n end\n session[:cart_id] = nil\n redirect_to cart_url\n end", "def destroy\n\t\t@cart = current_cart\n\t\t@cart.delete\n\n\t\tsession.delete(:aregos_cart_id)\n\n\t\tflash[:notice] = \"O carrinho de compras foi eliminado.\"\n\n\t\tredirect_to products_path\n\tend", "def complete_cart\n render json: { status: 'Success', message: 'Checkout Complete! Thank you for shopping with us!', data: products_in_cart(true) }\n Cart.destroy_all\n end", "def remove_from_cart\n if @cart.candle_carts.count == 1\n destroy\n else\n item = CandleCart.find(cart_params[:id])\n item.destroy\n flash[:alert] = \"Succesfully Removed\"\n redirect_back fallback_location: root_path\n end\n end", "def destroy\n @cart = current_cart\n @cart.destroy\n session[:cart_id] = nil\n\n respond_to do |format|\n format.html { redirect_to(root_url,\n :notice => 'Your cart is currently empty' ) }\n format.json { head :no_content }\n end\n end", "def delete_from_cart\n cart_op {|cart| cart.delete(params[:id].to_i); cart }\n render_cart_size\n end", "def checkout_cart\n self.line_items.each do |li|\n li.item.inventory -= li.quantity\n li.item.save\n end\n self.line_items.clear\n self.status = \"submitted\"\n self.user.current_cart_id = nil\n self.user.save\n end", "def clear\n @products.clear\n end", "def remove_items_from_cart\n line_items.each { |i| i.cart = nil }\n end", "def destroy\n @cart = @current_cart\n @cart.destroy\n session[:cart_id] = nil\n redirect_to cart_path(@cart.id)\n end", "def cancel_order\n system 'clear'\n CoffeeMan.stay_logo\n @@cart.clear\n puts \"Your cart has been emptied\"\n sleep(0.09)\n main_menu\n sleep(2)\n end", "def destroy\n @cart = Cart.find(params[:id])\n @cart.destroy\n session[:cart_id] = nil\n\n respond_to do |format|\n format.html { redirect_to(root_path,\n\t:notice => 'Your cart is currently empty') }\n format.json { head :no_content }\n end\n end", "def destroy\n flash.notice = I18n.t(:basket_successfully_cleared)\n @order.line_items.clear\n @order.update_totals!\n after :destroy\n set_flash :destroy\n response_for :destroy\n end", "def destroy\n @cart.destroy if @cart.id == session[:cart_id]\n flash[:success] = \"Cart was successfully empty\"\n #Use of logger class to log messages into the log file\n Logger.instance.log(Time.now.to_s + \": Cart destroyed by user \\n\")\n redirect_to products_path\n end", "def clear_cart\n sleep(1)\n #element = $driver.find_element(:css,\"#mini-cart-wrap > li > div.minicart-inner-div > a:nth-child(3) > span\") \n \n puts \"moving cursor to minicart\"\n $driver.action.move_to(mini_cart_text).perform\n\n sleep(2) \n begin\n empty_my_cart = $driver.find_element(:css,\"#minicart-bottom > p.pull-left > a\")\n sleep(1)\n empty_my_cart.click\n sleep(1)\n rescue \n puts \"cart is already empty\"\n end \n end", "def remove_items\n system 'clear'\n CoffeeMan.stay_logo\n @@cart = @@cart.flatten\n cart_arr = @@cart \n if cart_arr.count == 0 \n puts \"Your cart is empty, please add items\"\n sleep 1\n view_cart\n end\n if cart_arr.count > 0 \n splitted_cart = cart_arr.split(\" \")\n selected_items = prompt.multi_select(\"Which item would you like to remove?\", splitted_cart)\n selected_items.each do |del| \n cart_arr.delete_at(cart_arr.index(del))\n end \n # @@cart = cart_arr\n sleep(0.6)\n view_cart\n end\n end", "def destroy\n @cart = Cart.find(params[:id])\n @cart.destroy\n\n session[:cart_id] = nil\n\n respond_to do |format|\n format.html { redirect_to(store_url, notice => 'Your cart is currently empty') }\n format.xml { head :ok }\n\n end\n end", "def destroy\n if @cart.id == session[:cart_id]\n session[:cart_id] = nil\n end\n\n respond_to do |format|\n format.html { redirect_to store_index_url, notice: \"Your cart is currently empty\" }\n format.json { head :no_content }\n end\n end", "def destroy\r\n @cart_item = CartItem.find(params[:id])\r\n if @cart_item.destroy\r\n \t@cart_item.unbuy # returns unbought items in the cart to products table\r\n \tflash[:notice] = \"Item has been removed from cart!\"\r\n end\r\n redirect_to edit_cart_item_path(@cart_item)\r\n end", "def remove_from_cart\n\t\tcart_hash = session[:cart]\n\n\t\tcart_hash[params[:id]][\"quantity\"] -= 1\n\t\tif cart_hash[params[:id]][\"quantity\"] === 0\n\t\t\tcart_hash.delete(params[:id])\n\t\tend\n\n\t\tredirect_to root_url\n\tend", "def destroy\n if @cart_item.destroy\n # if @cart_item.cart.items.present?\n build do\n message 'Удаление товара из корзины'\n view 'cart_items/delete'\n end\n # else\n # @cart = @cart_item.cart\n # @cart.destroy\n # build do\n # message 'Удаление корзины'\n # view 'carts/delete'\n # end\n # end\n end\n end", "def remove_cart\n\t\tcart = current_user.saved.carts.find(params[:cart])\n #saved.carts.delete(cart)\n cart.destroy\n redirect_to :back\n\tend", "def remove_from_cart\n Cart.remove_from_cart(session[:cart], params[:id])\n redirect_to show_cart_products_path\n end", "def remove\n\t\tremove_from_cart(Item.find(params[:id]))\n\t\tredirect_to :controller => \"cart\", :action => \"index\"\n\tend", "def destroy\n @cart.destroy\n @cart = nil\n session[:cart_id] = nil\n\n respond_to do |format|\n format.html { redirect_to store_index_url, notice: 'Your cart is currently empty' }\n format.json { head :no_content }\n format.js\n end\n end", "def empty_cart\n $tracer.trace(\"GameStopMobileDSL : #{__method__}, Line : #{__LINE__}\")\n view_cart_button.click\n wait_for_landing_page_load\n shopping_cart_label.should_exist\n\n # note: edit_link does NOT have to to be clicked to remove items, but we will perform steps\n unless (empty_cart_label.exists)\n len = timeout(1000).cart_list.length\n while len > 0\n shopping_cart_edit_link.should_exist\n shopping_cart_edit_link.click\n shopping_cart_edit_done_link.should_exist\n\n cart_list.at(0).remove_button.click\n wait_for_landing_page_load\n len-=1\n end\n end\n end", "def clear\n\n end", "def destroy_from_cart\n unless cookies[:cart].nil?\n @cart = Cart.find_by_unique_identifier(cookies[:cart])\n @cart.delete_product(params[:catalog_id],params[:product_id])\n if @cart.save\n if @cart.products.size == 1\n products = @cart.products[0]\n if products[:products_count] == 0\n @cart.destroy\n cookies.delete(:cart)\n redirect_to root_url, :alert => t('cart.msg_cart_destroyed_no_products')\n else\n redirect_to show_mycart_path, :notice => t('cart.msg_del_prod')\n end\n else\n redirect_to show_mycart_path, :notice => t('cart.msg_del_prod')\n end\n else\n redirect_to show_mycart_path, :alert => t('cart.msg_no_del_prod')\n end\n else\n redirect_to root_url, :alert => t('cart.msg_nothing')\n end\n end", "def destroy\n if @cart.class == Hash\n session[:cart] = nil\n else @cart.class == Cart\n @cart.destroy\n end\n respond_to do |format|\n format.html { redirect_to store_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @product_id = params[:product_id].to_s\n\n # remove the item from the session\n session[:shopping_cart].delete(@product_id)\n\n calculate_order_total\n end", "def clear!\n @items.clear\n end", "def remove_product(name)\n @products_in_cart.delete(Product)\nend", "def clear_cart\n sleep(1)\n element = $driver.find_element(:css,\"#mini-cart-wrap > li > div.minicart-inner-div > a:nth-child(3) > span\") \n puts \"moving cursor to minicart\"\n $driver.action.move_to(element).perform\n\n sleep(2) \n begin\n empty_my_cart = $driver.find_element(:css,\"#minicart-bottom > p.pull-left > a\")\n sleep(1)\n empty_my_cart.click\n sleep(1)\n rescue \n\n puts \"cart is already empty\"\n end \n end", "def remove_from_cart\n id = params[:id]\n session[:cart].delete(id)\n redirect_to root_path\n end", "def destroy\n @cart_item.destroy\n Product.update(@cart_item.product.id, :quantity => @cart_item.product.quantity + @cart_item.quantity)\n respond_to do |format|\n format.html { redirect_to :back, notice: 'Cart item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def clear!\n @items.clear\n end", "def clear\n do_clear\n end", "def clear\n end", "def clear\n end", "def destroy\n current_cart=CartItem.find(params[:id]).cart\n # byebug\n if current_cart\n @cart_item.destroy\n new_sub_total_price=Cart.calculate_sub_total_price(current_cart.id)\n respond_to do |format|\n format.html { redirect_to carts_url, notice: 'Cart item was successfully destroyed.' }\n format.json { head :no_content }\n end\n Cart.new_subtotal_price current_cart\n end\n end", "def clear\n\t\tend", "def clear\n end", "def log_out_cart\n session.delete(:cart_id)\n @cart = nil\nend", "def destroy\n #get cart_id in order to delete this cart\n @consider_cart.destroy if @consider_cart.id == session[:con_cart_id] \n session[:con_cart_id] = nil\n respond_to do |format|\n format.html { redirect_to adoption_store_index_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @cart = current_cart\n @cart.destroy\n \n session[:cart_id] = nil\n\n respond_to do |format|\n format.html { \n redirect_to products_url,\n notice: 'Obsah košíku byl vysypán na zem. Zaměstnanci jej nyní uklízí.' \n }\n format.json { \n head :ok \n }\n end \n end", "def remove_from_cart\n render json: CartProduct.find(params[:id]).destroy\n end", "def destroy\n @cart.destroy\n respond_to do |format|\n format.html { redirect_to carts_url }\n format.json { head :no_content }\n end\n end", "def clear\n end", "def clear\n end", "def clear\n end", "def destroy\n @cart = Cart.find(params[:id])\n @cart.destroy\n session[:cart_id] = nil\n\n respond_to do |format|\n format.html { redirect_to(store_url) }\n format.json { head :no_content }\n end\n end", "def destroy\n @cart = Cart.find(params[:id])\n @cart.destroy\n\n respond_to do |format|\n format.html { redirect_to carts_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @cart = Cart.find(params[:id])\n @cart.destroy\n\n respond_to do |format|\n format.html { redirect_to carts_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @cart = Cart.find(params[:id])\n @cart.destroy\n\n respond_to do |format|\n format.html { redirect_to carts_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @cart = Cart.find(params[:id])\n @cart.destroy\n\n respond_to do |format|\n format.html { redirect_to carts_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @cart_item = CartItem.find(params[:id])\n @cart_item.destroy\n\n respond_to do |format|\n format.html { redirect_to current_cart_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @cart = current_cart\n @item = @cart.find_cart_item(params[:id])\n @product = @item.product\n @item.destroy\n flash[:warning] = \"#{@product.name} removed with success!\"\n redirect_to :back\n end", "def destroy\n @cart_item.destroy\n respond_to do |format|\n format.html { redirect_to cart_items_url }\n format.json { head :no_content }\n end\n end", "def remove_product(index)\n @cart.delete_at(index)\n puts \"**Product removed from cart.**\"\n view_cart\nend", "def remove_from_cart\n #see if you can change number of items in cart\n item_id = params[:remove_from_cart][:item_id]\n remove_item_from_cart(item_id)\n\n redirect_to cart_path\n end", "def destroy\n id = params[:id].to_i\n cart_books = session[:cart].map { |c| c[0] }\n \n session[:cart].delete_at(cart_books.index(id))\n \n redirect_back(fallback_location: root_path)\n \n # logger.debug(\"Cart Destroy triggered\")\n end", "def destroy\n # Use callbacks to share common setup or constraints between actions.\n\n @cart_item.destroy\n respond_to do |format|\n format.html { redirect_to basket_url(@cart_item.basket), notice: 'Диск удален из конрзины.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @cart_item = CartItem.find(params[:id])\n @cart_item.destroy\n\n respond_to do |format|\n format.html { redirect_to cart_items_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @cart_item = CartItem.find(params[:id])\n @cart_item.destroy\n\n respond_to do |format|\n format.html { redirect_to cart_items_url }\n format.json { head :no_content }\n end\n end", "def destroy\n cart = Cart.find_by(id: params[:id])\n cart.destroy\n render json: CartSerializer.new(cart)\n end", "def destroy_all\n @order = current_order\n @basket_items = @order.basket_items\n @basket_items.clear\n redirect_to(:back)\n end", "def destroy\n @cart_item = CartItem.find(params[:id])\n @cart_item.destroy\n\n respond_to do |format|\n format.html { redirect_to(carts_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @cart_item = CartItem.find(params[:id])\n @cart_item.destroy\n @cart_id = @cart_item.cart_id\n\n respond_to do |format|\n format.html { redirect_to cart_path(@cart_id) }\n format.json { head :no_content }\n end\n end", "def destroy\n @cart = Cart.find(params[:id])\n @cart.destroy\n\n respond_to do |format|\n format.html { redirect_to(carts_url) }\n format.xml { head :ok }\n end\n end", "def remove_product(index)\n @cart.delete_at(index)\n puts \"Product removed from cart.\"\n view_cart\nend", "def delete\n session[:cart].delete(params[:id])\n flash[:success] = 'Delete done'\n redirect_to cart_index_path\n end", "def remove_item\n prod_id = params[:product_id].to_s\n item = cart[prod_id] || {\"Num\" => 0}\n item[\"Num\"] -=1\n cart[prod_id] = item\n cart.delete(prod_id) if item[\"Num\"] < 1\n update_cart cart\n flash[:success] = t('itm_removed')\n redirect_back fallback_location: :root\n end", "def checkout\n @current_cart.adjust_inventory\n @current_cart.mark_submited\n current_user.remove_current_cart\n redirect_to cart_path(@current_cart)\n end", "def clear!\n end", "def remove\n id = params[:id]\n cart = session[:cart]\n cart.delete id\n \n redirect_to :action => :index\n end", "def clear\n @items.clear\n end" ]
[ "0.8819012", "0.8553298", "0.8390226", "0.82448417", "0.79037595", "0.786143", "0.78293514", "0.77930176", "0.7726829", "0.7568193", "0.7566522", "0.7531423", "0.7531423", "0.7506985", "0.74822944", "0.741013", "0.7387313", "0.7352283", "0.73231196", "0.73229116", "0.729534", "0.7284634", "0.7187701", "0.7103696", "0.7102374", "0.70927525", "0.7054834", "0.70509225", "0.70347935", "0.70192486", "0.6991185", "0.6988984", "0.6979793", "0.69730645", "0.6927497", "0.6925662", "0.69109505", "0.68977886", "0.6881252", "0.6867134", "0.68659085", "0.68258864", "0.68056023", "0.6799541", "0.6758354", "0.67500484", "0.6743052", "0.67375743", "0.6730887", "0.67276824", "0.6712083", "0.6705301", "0.66943014", "0.6686289", "0.6682014", "0.6665687", "0.6638349", "0.6632424", "0.66199195", "0.66132617", "0.6611945", "0.6591726", "0.6591726", "0.657823", "0.65719455", "0.65431124", "0.653583", "0.65325034", "0.6529668", "0.6523365", "0.6519346", "0.6516362", "0.6516362", "0.6516362", "0.65082216", "0.64942235", "0.64942235", "0.64942235", "0.64942235", "0.6492111", "0.6491307", "0.6489823", "0.6481612", "0.6481207", "0.64798826", "0.6479407", "0.64598656", "0.64598656", "0.6454359", "0.6443975", "0.64303124", "0.64276916", "0.6421533", "0.64203686", "0.64161015", "0.64155", "0.63969415", "0.6396484", "0.6386558", "0.6381334" ]
0.7407915
16
GET /fingers/1 GET /fingers/1.xml
def show @finger = Finger.find(params[:id]) respond_to do |format| format.html # show.html.erb format.xml { render :xml => @finger } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def friends(id)\n friends_data(request(\"users/friends/#{id}.xml\", :auth => true))\n end", "def create\n @finger = Finger.new(params[:finger])\n @finger.user = current_user\n \n respond_to do |format|\n if @finger.save\n flash[:notice] = 'Finger was successfully created.'\n format.html { redirect_to(fingers_path) }\n format.xml { render :xml => @finger, :status => :created, :location => @finger }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @finger.errors, :status => :unprocessable_entity }\n end\n end\n end", "def new \n @finger = Finger.new\n @finger.user = current_user\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @finger }\n end\n end", "def destroy\n @finger = Finger.find(params[:id])\n @finger.destroy\n\n respond_to do |format|\n format.html { redirect_to(fingers_url) }\n format.xml { head :ok }\n end\n end", "def show\n @feat = @person.feats.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @feat }\n end\n end", "def show\n @guess = Guess.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @guess }\n end\n end", "def show\n @magnetic_finger_print = MagneticFingerPrint.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @magnetic_finger_print }\n end\n end", "def show\n @probe = Probe.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @probe }\n end\n end", "def show\n #debugger\n @finger_print = FingerPrint.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @finger_print }\n end\n end", "def show\n @threat = Threat.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @threat }\n end\n end", "def show\n @discovery = Discovery.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @discovery }\n end\n end", "def show\n @favourites = Favourite.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @favourites }\n end\n end", "def show\n @face = Face.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @face }\n end\n end", "def getFavorites(userID, ofWhat)\n request('getFavorites', {'userID' => userID, 'ofWhat' => ofWhat})\nend", "def show\n @exposure = Exposure.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @exposure }\n end\n end", "def feats\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @character }\n end\n end", "def api_xml(path,method=:get,options={})\n xml_message(amee,\"/data\"+path,method,options)\n end", "def show\n @favorite = Favorite.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @favorite }\n end\n end", "def show\n respond_to do |format|\n format.html\n format.xml { render xml: @gadget_file.html }\n end\n end", "def show\n @monkey = Monkey.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @monkey }\n end\n end", "def show\n @fan = Fan.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @fan }\n end\n end", "def show\n @favourite = Favourite.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @favourite }\n end\n end", "def update\n @finger = Finger.find(params[:id])\n @finger.user = current_user\n respond_to do |format|\n if @finger.update_attributes(params[:finger])\n flash[:notice] = 'Finger was successfully updated.'\n format.html { redirect_to(fingers_path) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @finger.errors, :status => :unprocessable_entity }\n end\n end\n end", "def show\n @forward = Forward.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @forward }\n end\n end", "def show\n @waypoint = Waypoint.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @waypoint }\n end\n end", "def show\n #@feat = Feat.find(params[:id])\n @feat = @character.feats.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @feat }\n end\n end", "def show\n @fan_request = FanRequest.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @fan_request }\n end\n end", "def show\n @hack_tag_follow = HackTagFollow.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @hack_tag_follow }\n end\n end", "def show\n @friend = Friend.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @friend }\n end\n end", "def show\n @friend = Friend.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @friend }\n end\n end", "def favorite_foods\n get(\"/user/#{@user_id}/foods/log/favorite.json\")\n end", "def show\n @firearm = Firearm.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @firearm }\n end\n end", "def show\n @bottle = Bottle.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @bottle }\n \tformat.json { render :json => @bottle }\n\t\tend\n end", "def show\n @clicker = Clicker.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @clicker }\n end\n end", "def show\n @friendship = Friendship.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @friendship }\n end\n end", "def show\n @fuga = Fuga.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @fuga }\n end\n end", "def show\n @film = @festival.films.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @film }\n end\n end", "def print_each_photo(api_key, tag)\n # Build the URI\n uri = \"http://www.flickr.com/services/rest?method=flickr.photos.search\" +\n \"&api_key=#{api_key}&tags=#{tag}\"\n\n # Make the HTTP request and get the entity-body.\n response = open(uri).read\n\n # Parse the entity-body as an XML document.\n doc = REXML::Document.new(response)\n\n # For each photo found...\n REXML::XPath.each(doc, '//photo') do |photo| \n # ...generate and print its URI\n puts small_photo_uri(photo) if photo\n end\nend", "def show\n @way = Way.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @way }\n end\n end", "def show\n @favoritetweet = Favoritetweet.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @favoritetweet }\n end\n end", "def show\n @shot = Shot.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @shot }\n end\n end", "def show\n @wrestler = Wrestler.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @wrestler }\n end\n end", "def show\n @friendsofuser = Friendsofuser.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @friendsofuser }\n end\n end", "def show\n @funder = Funder.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @funder }\n end\n end", "def show\n @drives = Drives.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @drives }\n end\n end", "def show\n @buddy = Buddy.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @buddy }\n end\n end", "def show\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @food }\n end\n end", "def show\n @fam = Fam.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @fam }\n end\n end", "def index\n\t\t@people = Person.all\n\t\t# respond_to do |format|\n\t\t# \tformat.xml { send_data @entries.to_xml, :type => 'text/xml; charset=UTF-8;', :disposition => 'attachment; filename=entries.xml'}\n\t\t# end\n\tend", "def show\n @favorite_flyer = FavoriteFlyer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @favorite_flyer }\n end\n end", "def show\n @hacker = Hacker.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @hacker }\n end\n end", "def show\n @ingredient = Ingredient.find(params[:id])\n\n respond_to do |format|\n format.xml { render :xml => @ingredient }\n end\n end", "def show\n @tracker = Tracker.find(params[:id])\n\n respond_to do |format|\n format.html # show.erb\n format.xml { render :xml => @tracker.to_xml }\n end\n end", "def GET; end", "def show\n @pneighbour = Pneighbour.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @pneighbour }\n end\n end", "def show\n @fitness_sample = FitnessSample.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @fitness_sample }\n end\n end", "def show\n\t\t@ward = Ward.find(params[:id])\n \trespond_to do |format|\n \t\t format.html # show.html.erb\n \t\t\tformat.xml { render :xml => @wards }\t#Render to XML File\n \tend\n\tend", "def show\n @friend_request = FriendRequest.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @friend_request }\n end\n end", "def show\n @ganho = Ganho.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @ganho }\n end\n end", "def show\n @friend_request = FriendRequest.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @friend_request }\n end\n end", "def show\n @ref = Ref.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @ref }\n end\n end", "def show\n @privacy_friend = PrivacyFriend.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @privacy_friend }\n end\n end", "def get; end", "def show\n @avatar = Avatar.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @avatar }\n end\n end", "def new\n @finger_print = FingerPrint.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @finger_print }\n end\n end", "def show\n @chirp = Chirp.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @chirp }\n end\n end", "def show\n respond_to do |format|\n format.html {}\n format.json {}\n format.rdf { render rdf: @paper }\n end\n end", "def show\n @needle = Needle.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @needle }\n end\n end", "def show\n @question = Question.find(params[:id])\n check_forged_path\n\n respond_to do |format|\n format.html # show.rhtml\n format.json { render :json => @question.to_json }\n format.xml { render :xml => @question.to_xml(:methods => [:purpose]) }\n end\n end", "def show\n @path = Path.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @path }\n format.kml # show.kml.erb\n end\n end", "def friends\n #get friends page\n #get json from friends page\n #parse\n []\n end", "def show\n @haiku = Haiku.find(params[:id])\n\n respond_to { |format|\n format.html # show.rhtml\n format.xml {\n\trender :xml => @haiku.to_xml\n }\n }\n end", "def show\n @referral = Referral.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @referral }\n end\n end", "def show\n @referral = Referral.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @referral }\n end\n end", "def show\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @infraction_type }\n end\n end", "def show\n @scotty_dog_saying = ScottyDogSaying.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @scotty_dog_saying }\n end\n end", "def show\n @allergy = Allergy.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @allergy }\n end\n end", "def show\n @tracker = Tracker.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @tracker }\n end\n end", "def show\n @hr_attendence = Hr::Attendence.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @hr_attendence }\n end\n end", "def show\n @snap = Snap.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @snap }\n end\n end", "def index\n @distributions = @foyer.distributions\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @distributions }\n end\n end", "def show\n @fight = Fight.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @fight }\n end\n end", "def show\n @good = Good.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @good }\n end\n end", "def show\n @picture = Picture.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @picture }\n end\n end", "def show\n @picture = Picture.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @picture }\n end\n end", "def show\n @picture = Picture.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @picture }\n end\n end", "def show\n @post377 = Post377.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post377 }\n end\n end", "def show\n @drive_fixed = DriveFixed.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @drive_fixed }\n end\n end", "def read(id=nil)\r\n request = Net::HTTP.new(@uri.host, @uri.port)\r\n if id.nil?\r\n response = request.get(\"#{@uri.path}.xml\") \r\n else\r\n response = request.get(\"#{@uri.path}/#{id}.xml\") \r\n end\r\n response.body\r\n end", "def show\n @rig = Rig.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @rig }\n end\n end", "def show\n @handbook = Handbook.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @handbook }\n end\n end", "def show\n @chord = Chord.find_by_hash_ref(params[:id]) or raise ActiveRecord::RecordNotFound\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @chord }\n end\n end", "def index\n @funders = Funder.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @funders }\n end\n end", "def show\n @assistance_list = AssistanceList.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @assistance_list }\n end\n end", "def show\n @frequentmag = Frequentmag.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @frequentmag }\n end\n end", "def show\n @avatar_tweet = AvatarTweet.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @avatar_tweet }\n end\n end", "def show\n @attend = Attend.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @attend }\n end\n end", "def show\n @docent = Docent.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @docent }\n end\n end", "def show\n @saved_tape = SavedTape.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @saved_tape }\n end\n end", "def show\n @thing = Thing.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @thing }\n end\n end" ]
[ "0.6058822", "0.57901186", "0.5787219", "0.5698869", "0.5647543", "0.56392294", "0.5624455", "0.5605942", "0.5587766", "0.5496254", "0.54085344", "0.53884786", "0.53834164", "0.5379891", "0.53256345", "0.5324248", "0.5319311", "0.53118926", "0.530363", "0.5297249", "0.52915967", "0.52909684", "0.52864254", "0.52775794", "0.5275499", "0.5264447", "0.52607703", "0.5258866", "0.5258832", "0.5258832", "0.5250698", "0.5239111", "0.52320397", "0.522228", "0.5212731", "0.51936203", "0.5192315", "0.5186683", "0.51713413", "0.51704365", "0.51631284", "0.5158549", "0.51548", "0.51399606", "0.51359147", "0.51223886", "0.5122149", "0.5118677", "0.5117734", "0.5098683", "0.50978416", "0.50940543", "0.5088032", "0.50853765", "0.5077758", "0.50747824", "0.50739264", "0.5070465", "0.5067559", "0.5060056", "0.50568336", "0.50532013", "0.5052626", "0.5045286", "0.504203", "0.5039769", "0.50389713", "0.5037001", "0.5036909", "0.5035622", "0.5033926", "0.5032918", "0.50322694", "0.50322694", "0.50293356", "0.5027512", "0.50212175", "0.5020761", "0.5017724", "0.5010487", "0.5009843", "0.5009806", "0.50077075", "0.5006692", "0.5006692", "0.5006692", "0.5006554", "0.50045097", "0.5002376", "0.5001484", "0.50010717", "0.49990913", "0.499884", "0.49924776", "0.49915668", "0.4991195", "0.49880612", "0.49875894", "0.49863973", "0.49841276" ]
0.70847297
0
GET /fingers/new GET /fingers/new.xml
def new @finger = Finger.new @finger.user = current_user respond_to do |format| format.html # new.html.erb format.xml { render :xml => @finger } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @finger = Finger.new(params[:finger])\n @finger.user = current_user\n \n respond_to do |format|\n if @finger.save\n flash[:notice] = 'Finger was successfully created.'\n format.html { redirect_to(fingers_path) }\n format.xml { render :xml => @finger, :status => :created, :location => @finger }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @finger.errors, :status => :unprocessable_entity }\n end\n end\n end", "def new\n @feat = @person.feats.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @feat }\n end\n end", "def new\n @finger_print = FingerPrint.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @finger_print }\n end\n end", "def new\n @monkey = Monkey.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @monkey }\n end\n end", "def new\n @guess = Guess.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @guess }\n end\n end", "def new\n @threat = Threat.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @threat }\n end\n end", "def new\n @probe = Probe.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @probe }\n end\n end", "def new\n @favorite = Favorite.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @favorite }\n end\n end", "def new\n @foyer = Foyer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @foyer }\n end\n end", "def show\n @finger = Finger.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @finger }\n end\n end", "def new\n @favourite = Favourite.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @favourite }\n end\n end", "def new\n @hack_tag_follow = HackTagFollow.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @hack_tag_follow }\n end\n end", "def new\n @discovery = Discovery.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @discovery }\n end\n end", "def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => new_vurl }\n end\n end", "def new\n @family = Family.new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @family }\n end\n end", "def new\n @fan = Fan.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @fan }\n end\n end", "def new\n @node = Node.scopied.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @node }\n end\n end", "def new\n @favourites = Favourites.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @favourites }\n end\n end", "def new\n @funder = Funder.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @funder }\n end\n end", "def new\n @thing = Thing.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @thing }\n end\n end", "def new\n @waypoint = Waypoint.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @waypoint }\n end\n end", "def new\n @friend = Friend.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @friend }\n end\n end", "def new\n @good = Good.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @good }\n end\n end", "def new\n @way = Way.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @way }\n end\n end", "def new\n @ref = Ref.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @ref }\n end\n end", "def new\n @fam = Fam.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @fam }\n end\n end", "def new\n @buddy = Buddy.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @buddy }\n end\n end", "def new\n @pneighbour = Pneighbour.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @pneighbour }\n end\n end", "def new\n @thred = Thred.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @thred }\n end\n end", "def new\n @post377 = Post377.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post377 }\n end\n end", "def new\n @food = Food.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @food }\n end\n end", "def new\n @hacker = Hacker.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @hacker }\n end\n end", "def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @infraction_type }\n end\n end", "def new\n @friendship = Friendship.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @friendship }\n end\n end", "def new\n @noun = Noun.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @noun }\n end\n end", "def new\n @needle = Needle.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @needle }\n end\n end", "def new\n @friend = current_user_or_guest.friends.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render xml: @friend }\n format.json { render json: @friend }\n end\n end", "def new\n @fuga = Fuga.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @fuga }\n end\n end", "def new\n @bottle = Bottle.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @bottle }\n\t\t\tformat.json { render :json => @bottle }\n end\n end", "def new\n @pdig = Pdig.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @pdig }\n end\n end", "def new\n @fridge_food = FridgeFood.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @fridge_food }\n end\n end", "def new\n @exposure = Exposure.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @exposure }\n end\n end", "def new\n @gift = Gift.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @gift }\n end\n end", "def new\n @thing_list = ThingList.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @thing_list }\n end\n end", "def new\n @tape = Tape.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @tape }\n end\n end", "def new\n @people = People.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @people }\n end\n end", "def new\n @patrimonio = Patrimonio.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @patrimonio }\n end\n end", "def new\n @magnetic_finger_print = MagneticFingerPrint.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @magnetic_finger_print }\n end\n end", "def new\n @tracker = Tracker.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @tracker }\n end\n end", "def new\n @follower = Follower.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @follower }\n end\n end", "def new\n @node = Node.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @node }\n end\n end", "def new\n @node = Node.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @node }\n end\n end", "def new\n @nickname = Nickname.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @nickname }\n end\n end", "def new\n @howto = Howto.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @howto }\n end\n end", "def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @franchise }\n end\n end", "def new\n @force = Force.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @force }\n end\n end", "def new\n @peep = Peep.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @peep }\n end\n end", "def new\n @favoritetweet = Favoritetweet.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @favoritetweet }\n end\n end", "def new\n @flight = Flight.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @flight }\n end\n end", "def new\n head :status => 405\n return\n \n @participant = Participant.new\n\n respond_to do |format|\n format.html # new.html.erb\n #format.xml { render :xml => @participant }\n end\n end", "def new\n @shot = Shot.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @shot }\n end\n end", "def new\n @tweet = Tweet.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @tweet }\n end\n end", "def new\n @click_to_talk = ClickToTalk.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @click_to_talk }\n end\n end", "def new\n @press = Press.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @press }\n end\n end", "def new\n @entry = @resource_finder.new\n initialize_new_resource\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @entry }\n end\n end", "def new\n @saved_food = SavedFood.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @saved_food }\n end\n end", "def new\n @friend_request = FriendRequest.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @friend_request }\n end\n end", "def new\n @friend_request = FriendRequest.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @friend_request }\n end\n end", "def new\n @wildlife = Wildlife.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @wildlife }\n end\n end", "def new\n @diet = Diet.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @diet }\n end\n end", "def new\n# @fossil = Fossil.new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @fossil }\n end\n end", "def new\n @firearm = Firearm.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @firearm }\n end\n end", "def new\n @neighborhood = Neighborhood.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @neighborhood }\n end\n end", "def new\n @brother = Brother.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @brother }\n end\n end", "def new\n @person = Person.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @person }\n end\n end", "def new\n @person = Person.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @person }\n end\n end", "def new\n @person = Person.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @person }\n end\n end", "def new\n @person = Person.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @person }\n end\n end", "def new\n @person = Person.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @person }\n end\n end", "def new\n @person = Person.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @person }\n end\n end", "def new\n @person = Person.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @person }\n end\n end", "def new\n @person = Person.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @person }\n end\n end", "def new\n @person = Person.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @person }\n end\n end", "def new\n @person = Person.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @person }\n end\n end", "def new_rest\n @entry_answer = EntryAnswer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @entry_answer }\n end\n end", "def new\n @twitterfeed = Twitterfeed.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @twitterfeed }\n end\n end", "def new_rest\n @entry_instrument = EntryInstrument.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @entry_instrument }\n end\n end", "def new\n @fight = Fight.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @fight }\n end\n end", "def new\n @rant = Rant.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @rant }\n end\n end", "def new2\n #does not allow attaching a picture\n @listing = Listing.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.fbml # new.fbml.erb\n format.xml { render :xml => @listing }\n end\n end", "def new\n @rawness = Rawness.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @rawness }\n end\n end", "def new\n @rink = Rink.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @rink }\n end\n end", "def new\n @snap = Snap.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @snap }\n end\n end", "def new\n @fav = Fav.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @fav }\n end\n end", "def new\n @uri_type = UriType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @uri_type }\n end\n end", "def new\n @followership = Followership.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @followership }\n end\n end", "def new\n @post78 = Post78.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post78 }\n end\n end", "def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @ontology }\n end\n end", "def new\n @atom = Atom.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @atom }\n end\n end", "def new\n @feature = Feature.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @feature }\n end\n end" ]
[ "0.68037736", "0.6724813", "0.6646627", "0.6530833", "0.64731985", "0.64006215", "0.6397397", "0.63782346", "0.6364024", "0.6330678", "0.63297874", "0.6315338", "0.62802935", "0.6279807", "0.6256123", "0.62546724", "0.6254477", "0.62474364", "0.6228865", "0.6226489", "0.61872226", "0.6184419", "0.61747116", "0.61667615", "0.6160854", "0.61520386", "0.61500984", "0.61472166", "0.61315364", "0.61121726", "0.61119056", "0.61084306", "0.610465", "0.6098367", "0.60964197", "0.60893416", "0.6084175", "0.6075377", "0.60741353", "0.60713845", "0.6069063", "0.60647196", "0.60598046", "0.6028439", "0.6028307", "0.60243136", "0.6019769", "0.6019683", "0.6015223", "0.6012821", "0.60096633", "0.60096633", "0.60073465", "0.6007226", "0.60064214", "0.6002615", "0.59976995", "0.59884775", "0.5988368", "0.5985507", "0.598083", "0.59766614", "0.5976205", "0.5975189", "0.5972107", "0.59719914", "0.59674215", "0.59674215", "0.5963802", "0.59613997", "0.5957824", "0.594906", "0.59487915", "0.5942731", "0.59409684", "0.59409684", "0.59409684", "0.59409684", "0.59409684", "0.59409684", "0.59409684", "0.59409684", "0.59409684", "0.59409684", "0.59388274", "0.5936282", "0.5936064", "0.59351915", "0.5934654", "0.5934645", "0.5930936", "0.5930736", "0.59233063", "0.59214294", "0.59206855", "0.5919624", "0.5917496", "0.5916064", "0.5913937", "0.591245" ]
0.72824943
0
POST /fingers POST /fingers.xml
def create @finger = Finger.new(params[:finger]) @finger.user = current_user respond_to do |format| if @finger.save flash[:notice] = 'Finger was successfully created.' format.html { redirect_to(fingers_path) } format.xml { render :xml => @finger, :status => :created, :location => @finger } else format.html { render :action => "new" } format.xml { render :xml => @finger.errors, :status => :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @finger = Finger.find(params[:id])\n @finger.user = current_user\n respond_to do |format|\n if @finger.update_attributes(params[:finger])\n flash[:notice] = 'Finger was successfully updated.'\n format.html { redirect_to(fingers_path) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @finger.errors, :status => :unprocessable_entity }\n end\n end\n end", "def new \n @finger = Finger.new\n @finger.user = current_user\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @finger }\n end\n end", "def destroy\n @finger = Finger.find(params[:id])\n @finger.destroy\n\n respond_to do |format|\n format.html { redirect_to(fingers_url) }\n format.xml { head :ok }\n end\n end", "def create\n @finger_print = FingerPrint.check_exist(params[:finger_print])\n\n respond_to do |format|\n format.html { redirect_to @finger_print, notice: 'FingerPrint was successfully created.' }\n format.json { render json: @finger_print, status: :created, location: @finger_print }\n end\n end", "def follow\n if request.post?\n fo_ids = params[:follow] \n #fo_str = \"\"\n #fo_cnt = fo_ids.length - 1\n #for i in 0..fo_cnt\n # fo_str +=fo_ids[i].to_s\n # fo_str += \",\" unless fo_cnt == i\n #end\n \n fo_ids.each do |fid|\n hydra = Typhoeus::Hydra.new\n uri = \"http://api.twitter.com/1/friendships/create.json\"\n req = Typhoeus::Request.new(uri,\n :method =>\"post\",\n :params =>{:user_id=>fid, :include_entities=>\"true\"})\n \n sign_request(req,uri)\n hydra.queue(req)\n hydra.run\n #puts req.response.inspect\n end\n end\n redirect_to :action=>\"index\", :page=>\"1\" \n end", "def create\n @magnetic_finger_print = MagneticFingerPrint.new(params[:magnetic_finger_print])\n\n respond_to do |format|\n if @magnetic_finger_print.save\n format.html { redirect_to @magnetic_finger_print, notice: 'Magnetic finger print was successfully created.' }\n format.json { render json: @magnetic_finger_print, status: :created, location: @magnetic_finger_print }\n else\n format.html { render action: \"new\" }\n format.json { render json: @magnetic_finger_print.errors, status: :unprocessable_entity }\n end\n end\n end", "def POST; end", "def create\n @feat = @person.feats.new(params[:feat])\n\n respond_to do |format|\n if @feat.save\n format.html { redirect_to([@person, @feat], :notice => 'Feat was successfully created.') }\n format.xml { render :xml => @feat, :status => :created, :location => @feat }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @feat.errors, :status => :unprocessable_entity }\n end\n end\n end", "def post_to_fancyhands\n post_to_fancyhands_now\n end", "def post(path, **args); end", "def new\n @finger_print = FingerPrint.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @finger_print }\n end\n end", "def show\n @finger = Finger.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @finger }\n end\n end", "def post(path, params={})\n signature_params = params.values.any?{|value| value.respond_to?(:to_io)} ? {} : params\n request(:post, path, params.to_xml, signature_params)\n end", "def create(name=\"Default Name\", age=\"50\")\r\n xml_req =\r\n \"<?xml version='1.0' encoding='UTF-8'?>\r\n <person>\r\n <name>#{name}</name>\r\n <age>#{age}</age>\r\n </person>\"\r\n \r\n request = Net::HTTP::Post.new(@url)\r\n request.add_field \"Content-Type\", \"application/xml\"\r\n request.body = xml_req\r\n \r\n http = Net::HTTP.new(@uri.host, @uri.port)\r\n response = http.request(request)\r\n response.body \r\n end", "def create\n megam_rest.post_node(to_hash)\n end", "def post(uri, xml)\r\n req = Net::HTTP::Post.new(uri)\r\n req[\"content-type\"] = \"application/xml\"\r\n req.body = xml\r\n request(req)\r\n end", "def post\n resource.post(request, response)\n end", "def post\r\n end", "def fingerprint_params\n params.require(:fingerprint).permit(:measurement_id, :location_id)\n end", "def create\n megam_rest.post_appdefn(to_hash)\n end", "def post #:doc:\n end", "def post; end", "def post endpoint, data\n do_request :post, endpoint, data\n end", "def create\n @gesture = Gesture.new(params[:gesture])\n\n respond_to do |format|\n if @gesture.save\n format.html { redirect_to @gesture, notice: 'Gesture was successfully created.' }\n format.json { render json: @gesture, status: :created, location: @gesture }\n else\n format.html { render action: \"new\" }\n format.json { render json: @gesture.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @gesture = Gesture.new(gesture_params)\n\n if @gesture.save\n render json: @gesture, status: :created, location: @gesture\n else\n render json: @gesture.errors, status: :unprocessable_entity\n end\n end", "def post(*args)\n request(:post, *args)\n end", "def post(*args)\n request :post, *args\n end", "def create\n @f5_node = F5Node.new(params[:f5_node])\n\n respond_to do |format|\n if @f5_node.save\n format.html { redirect_to @f5_node, notice: 'F5 node was successfully created.' }\n format.json { render json: @f5_node, status: :created, location: @f5_node }\n else\n format.html { render action: \"new\" }\n format.json { render json: @f5_node.errors, status: :unprocessable_entity }\n end\n end\n end", "def post(path, options={})\n request :post, path, options\n end", "def post(path, options={})\n send_request 'post', path, options\n end", "def post\n end", "def post(path, data={})\n request(:post, path, data)\n end", "def post(path = '/files/', params = {})\n request :post, path, params\n end", "def post(path, opts = {})\n request(:post, path, opts).body\n end", "def create\n # process the request if the proper authorization key was given\n begin\n # parse the given XML document and retrieve the underlying food model\n @food = Food.new(Food.xmlfood_to_hash(request.body))\n respond_to do |format|\n if @food.save\n format.xml { render xml: @food, status: :created, location: @food }\n else # bad request: food could not be added to the database\n # check the entry could not be saved because it is already existing\n unique_error = false\n @food.errors.each do |_, err_mess|\n if err_mess == \"has already been taken\"\n unique_error = true\n break\n end\n end\n # send a 409 Conflict error if it is the case\n if unique_error\n format.xml { head :conflict }\n # else send a 422 Unprocessable entity error\n else\n format.xml { render text: @food.errors.map { |_, e| \"#{e}\" }.join(\"\\n\")+\"\\n\",\n status: :unprocessable_entity }\n end\n end\n end\n rescue ArgumentError => e\n # bad request: improper XML food\n respond_to do |format|\n format.xml { render text: \"#{e}\\n\", status: :unprocessable_entity}\n end\n end\n end", "def post payload, path = \"\" \n make_request(path, \"post\", payload)\n end", "def post(xmldoc)\n headers = {'Content-Type' => 'text/xml'}\n check_response( @httpcli.post(@endpoint, xmldoc, headers) )\n end", "def create\n #@feat = Feat.new(params[:feat])\n @feat = @character.feats.build(params[:feat])\n\n respond_to do |format|\n if @feat.save\n flash[:notice] = 'Feat was successfully created.'\n format.html { redirect_to(edit_character_path(@character)) }\n format.xml { render :xml => @feat, :status => :created, :location => @feat }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @feat.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @post377 = Post377.new(params[:post377])\n\n respond_to do |format|\n if @post377.save\n format.html { redirect_to(@post377, :notice => 'Post377 was successfully created.') }\n format.xml { render :xml => @post377, :status => :created, :location => @post377 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post377.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @threat = Threat.new(params[:threat])\n\n respond_to do |format|\n if @threat.save\n format.html { redirect_to(@threat, :notice => 'Threat was successfully created.') }\n format.xml { render :xml => @threat, :status => :created, :location => @threat }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @threat.errors, :status => :unprocessable_entity }\n end\n end\n end", "def post(attrs = nil)\n attrs ||= attributes\n execute_request do\n faraday_connection.post { |req| req.body = adapter.serialize(attrs) }\n end\n end", "def post(path, params = {})\n Chirpy.request params.merge({:path => path, :method => 'post'}.merge(authentication))\n end", "def post(*args)\n prepare_request(:post, args)\n @@client.add(:post, @path, *args)\n end", "def post(path, options = {})\n request(:post, path, options)\n end", "def post(path, options = {})\n request(:post, path, options)\n end", "def post(path, options = {})\n request(:post, path, options)\n end", "def postEntityFax( entity_id, number, description)\n params = Hash.new\n params['entity_id'] = entity_id\n params['number'] = number\n params['description'] = description\n return doCurl(\"post\",\"/entity/fax\",params)\n end", "def post(path, options = {})\n request(:post, path, options)\n end", "def post(path, options = {})\n request(:post, path, options)\n end", "def post(path, options = {})\n request(:post, path, options)\n end", "def post(path, headers = {})\n process :post, path, headers\n end", "def post(path, payload={})\n request(:post, path, payload)\n end", "def post(path, params={})\n request(:post, path, params)\n end", "def post(path, params={})\n request(:post, path, params)\n end", "def post(path, params={})\n request(:post, path, params)\n end", "def post(path, query_params={}, opts={})\n request(:post, path, query_params, opts)\n end", "def post(path, options={}, &b)\n event(:post, path, options, &b)\n end", "def create\n @featuring = Featuring.new(featuring_params)\n\n respond_to do |format|\n if @featuring.save\n format.html { redirect_to @featuring, notice: 'Featuring was successfully created.' }\n format.json { render :show, status: :created, location: @featuring }\n else\n format.html { render :new }\n format.json { render json: @featuring.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @magnetic_finger_print = MagneticFingerPrint.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @magnetic_finger_print }\n end\n end", "def create\n @wfeat = Wfeat.new(wfeat_params)\n\n respond_to do |format|\n if @wfeat.save\n format.html { redirect_to @wfeat, notice: 'Wfeat was successfully created.' }\n format.json { render :show, status: :created, location: @wfeat }\n else\n format.html { render :new }\n format.json { render json: @wfeat.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @foyer = Foyer.new(params[:foyer])\n\n respond_to do |format|\n if @foyer.save\n flash[:notice] = 'Le foyer a bien été enregistré.'\n format.html { redirect_to(@foyer) }\n format.xml { render :xml => @foyer, :status => :created, :location => @foyer }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @foyer.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @fokey = Fokey.new(fokey_params)\n\n respond_to do |format|\n if @fokey.save\n format.html { redirect_to @fokey, notice: 'Fokey was successfully created.' }\n format.json { render :show, status: :created, location: @fokey }\n else\n format.html { render :new }\n format.json { render json: @fokey.errors, status: :unprocessable_entity }\n end\n end\n end", "def post(path, options = nil)\n add(path, options).post\n end", "def create\n @favorite_flyer = FavoriteFlyer.new(params[:favorite_flyer])\n\n respond_to do |format|\n if @favorite_flyer.save\n format.html { redirect_to @favorite_flyer, notice: 'Favorite flyer was successfully created.' }\n format.json { render json: @favorite_flyer, status: :created, location: @favorite_flyer }\n else\n format.html { render action: \"new\" }\n format.json { render json: @favorite_flyer.errors, status: :unprocessable_entity }\n end\n end\n end", "def post(path, params)\n time(\"POST #{path}\") { Cloudflarer.new.post(path, params) }\n end", "def post(path, params={})\n signature_params = params.values.any?{|value| value.respond_to?(:to_io)} ? {} : params\n request(:post, path, params, signature_params)\n end", "def post(path, params = {})\n request(:post, path, params)\n end", "def post(path, params = {})\n request(:post, path, params)\n end", "def post(path, params = {})\n request(:post, path, params)\n end", "def post(path, params = {})\n request(:post, path, params)\n end", "def post(path, params = {})\n request(:post, path, params)\n end", "def create\n doc = Nokogiri::XML(request.body.read)\n cvNode = doc.xpath('elwak/checklisten_vorlage')\n cv = ChecklistenVorlage.new({\n objekt_id: cvNode.xpath('objekt_id').text.to_s, \n bezeichner: cvNode.xpath('bezeichner').text.to_s, \n version: cvNode.xpath('version').text.to_s.to_i, \n inaktiv: cvNode.xpath('inaktiv').text.to_s.to_bool \n })\n cv.save\n\n cvNode.xpath('checklisten_eintrags/checklisten_eintrag').each do |ceNode|\n ce = ChecklistenEintrag.new({\n checklisten_vorlage_id: cv.id,\n bezeichner: ceNode.xpath('bezeichner').text.to_s,\n was: ceNode.xpath('was').text.to_s,\n wann: ceNode.xpath('wann').text.to_s,\n typ: ceNode.xpath('typ').text.to_s.to_i,\n position: ceNode.xpath('position').text.to_s.to_i\n })\n ce.save\n end\n\n respond_to do |format|\n format.xml {render :xml => '<?xml version=\"1.0\" encoding=\"UTF-8\"?><success />'}\n end\n end", "def post!\n request! :post\n end", "def create\n @sigandanny = Sigandanny.new(sigandanny_params)\n\n respond_to do |format|\n if @sigandanny.save\n format.html { redirect_to @sigandanny, notice: 'Sigandanny was successfully created.' }\n format.json { render :show, status: :created, location: @sigandanny }\n else\n format.html { render :new }\n format.json { render json: @sigandanny.errors, status: :unprocessable_entity }\n end\n end\n end", "def post(path, options={}, format=format)\n request(:post, path, options, format)\n end", "def post(path, data=nil)\n request(:post, path, data)\n end", "def post(path, params = {})\n request(:post, path, params)\n end", "def post\n Rentlinx.client.post(self)\n end", "def create_favorite(id)\n post \"favorites/create/#{id}\", {}\n end", "def create\n @friendship = current_person.friendships.build(:granter_id => params[:granter_id], :accepted => params[:accepted])\n\n respond_to do |format|\n if @friendship.save\n format.html { redirect_to people_url, notice: 'A friend request has been sent to ' + Person.find(params[:granter_id]).name }\n format.json { render :show, status: :created, location: @friendship }\n else\n format.html { render :new }\n format.json { render json: @friendship.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @passife = Passive.new(passife_params)\n \n respond_to do |format|\n if @passife.save\n format.html { redirect_to @passife, notice: 'Passive was successfully created.' }\n format.json { render :show, status: :created, location: @passife }\n else\n format.html { render :new }\n format.json { render json: @passife.errors, status: :unprocessable_entity }\n end\n end\n end", "def post(path, params={})\n signature_params = params.values.any?{|value| value.respond_to?(:to_io)} ? {} : params\n request(:post, path, params, signature_params)\n end", "def post(path, params={})\n signature_params = params.values.any?{|value| value.respond_to?(:to_io)} ? {} : params\n request(:post, path, params, signature_params)\n end", "def post(path, params={})\n signature_params = params.values.any?{|value| value.respond_to?(:to_io)} ? {} : params\n request(:post, path, params, signature_params)\n end", "def post(path, params={})\n signature_params = params.values.any?{|value| value.respond_to?(:to_io)} ? {} : params\n request(:post, path, params, signature_params)\n end", "def create\n @fridge_food = FridgeFood.new(params[:fridge_food])\n\n respond_to do |format|\n if @fridge_food.save\n format.html { redirect_to(@fridge_food, :notice => 'Fridge food was successfully created.') }\n format.xml { render :xml => @fridge_food, :status => :created, :location => @fridge_food }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @fridge_food.errors, :status => :unprocessable_entity }\n end\n end\n end", "def post(request_opts = {})\n store_result(http(request_opts).post(resolved_path, @attrs))\n end", "def create\n Friendship.request(@user, @friend)\n @friend = Friendship.find_by_user_id_and_friend_id(@user, @friend)\n render :json => { :success => true, :new_friend => @friend }\n end", "def create\n @discovery = Discovery.new(params[:discovery])\n\n respond_to do |format|\n if @discovery.save\n flash[:notice] = 'Discovery was successfully created.'\n format.html { redirect_to(@discovery) }\n format.xml { render :xml => @discovery, :status => :created, :location => @discovery }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @discovery.errors, :status => :unprocessable_entity }\n end\n end\n end", "def post (dir, data) #DIR is path to REST, Data is HASH of post data\r\n\tbegin\r\n\t\taddress=$server + dir\r\n\t\turi = URI.parse(address)\r\n\t\tdebugging \"Post URI: #{uri}, data: #{data}\"\r\n\t\trequest=Net::HTTP.post_form(uri,data)\r\n\t\tdebugging \"Response #{request}\"\r\n\t\treturn request\r\n\trescue Exception =>msg\r\n\t\tresponse={'body'=>msg,'code'=>401, 'exception' =>true}\r\n\tend\r\nend", "def create\n @faction_tag = FactionTag.new(faction_tag_params)\n\n respond_to do |format|\n if @faction_tag.save\n format.html { redirect_to @faction_tag, notice: 'Faction tag was successfully created.' }\n format.json { render :show, status: :created, location: @faction_tag }\n else\n format.html { render :new }\n format.json { render json: @faction_tag.errors, status: :unprocessable_entity }\n end\n end\n end", "def post(path, options = {})\n nonce, signature = generate_signature\n options = options.merge(key: @api_key, nonce: nonce, signature: signature)\n result = @connection.post(\"#{path}/\", options).body\n JSON.parse(result)\n end", "def create\n megam_rest.post_promos(to_hash) #WONT BE USED AS OF NOW\n end", "def post(path, data = {})\n request 'POST', path, body: data.to_json\n end", "def http_post(request, response)\n path = request.path\n\n # Only handling xml\n content_type = request.header('Content-Type')\n return nil unless content_type.index('application/xml') || content_type.index('text/xml')\n\n # Making sure the node exists\n begin\n node = @server.tree.node_for_path(path)\n rescue Dav::Exception::NotFound\n return nil\n end\n\n request_body = request.body_as_string\n\n # If this request handler could not deal with this POST request, it\n # will return 'null' and other plugins get a chance to handle the\n # request.\n #\n # However, we already requested the full body. This is a problem,\n # because a body can only be read once. This is why we preemptively\n # re-populated the request body with the existing data.\n request.body = request_body\n\n document_type_box = Box.new('')\n message = @server.xml.parse(request_body, request.url, document_type_box)\n document_type = document_type_box.value\n\n case document_type\n # Dealing with the 'share' document, which modified invitees on a\n # calendar.\n when \"{#{Plugin::NS_CALENDARSERVER}}share\"\n # We can only deal with IShareableCalendar objects\n return true unless node.is_a?(IShareableCalendar)\n\n @server.transaction_type = 'post-calendar-share'\n\n # Getting ACL info\n acl = @server.plugin('acl')\n\n # If there's no ACL support, we allow everything\n acl.check_privileges(path, '{DAV:}write') if acl\n\n node.update_shares(message.set, message.remove)\n\n response.status = 200\n # Adding this because sending a response body may cause issues,\n # and I wanted some type of indicator the response was handled.\n response.update_header('X-Sabre-Status', 'everything-went-well')\n\n # Breaking the event chain\n return false\n # The invite-reply document is sent when the user replies to an\n # invitation of a calendar share.\n when \"{#{Plugin::NS_CALENDARSERVER}}invite-reply\"\n\n # This only works on the calendar-home-root node.\n return true unless node.is_a?(CalendarHome)\n\n @server.transaction_type = 'post-invite-reply'\n\n # Getting ACL info\n acl = @server.plugin('acl')\n\n # If there's no ACL support, we allow everything\n acl.check_privileges(path, '{DAV:}write') if acl\n\n url = node.share_reply(\n message.href,\n message.status,\n message.calendar_uri,\n message.in_reply_to,\n message.summary\n )\n\n response.status = 200\n # Adding this because sending a response body may cause issues,\n # and I wanted some type of indicator the response was handled.\n response.update_header('X-Sabre-Status', 'everything-went-well')\n\n if url\n writer = @server.xml.writer\n writer.open_memory\n writer.start_document\n writer.start_element(\"{#{Plugin::NS_CALENDARSERVER}}shared-as\")\n writer.write(Dav::Xml::Property::Href.new(url))\n writer.end_element\n response.update_header('Content-Type', 'application/xml')\n response.body = writer.output_memory\n end\n\n # Breaking the event chain\n return false\n when \"{#{Plugin::NS_CALENDARSERVER}}publish-calendar\"\n # We can only deal with IShareableCalendar objects\n return true unless node.is_a?(IShareableCalendar)\n\n @server.transaction_type = 'post-publish-calendar'\n\n # Getting ACL info\n acl = @server.plugin('acl')\n\n # If there's no ACL support, we allow everything\n acl.check_privileges(path, '{DAV:}write') if acl\n\n node.publish_status = true\n\n # iCloud sends back the 202, so we will too.\n response.status = 202\n\n # Adding this because sending a response body may cause issues,\n # and I wanted some type of indicator the response was handled.\n response.update_header('X-Sabre-Status', 'everything-went-well')\n\n # Breaking the event chain\n return false\n when \"{#{Plugin::NS_CALENDARSERVER}}unpublish-calendar\"\n # We can only deal with IShareableCalendar objects\n return true unless node.is_a?(IShareableCalendar)\n\n @server.transaction_type = 'post-unpublish-calendar'\n\n # Getting ACL info\n acl = @server.plugin('acl')\n\n # If there's no ACL support, we allow everything\n acl.check_privileges(path, '{DAV:}write') if acl\n\n node.publish_status = false\n\n response.status = 200\n\n # Adding this because sending a response body may cause issues,\n # and I wanted some type of indicator the response was handled.\n response.update_header('X-Sabre-Status', 'everything-went-well')\n\n # Breaking the event chain\n return false\n end\n end", "def create\n @raffle = Raffle.new(raffle_params)\n @raffle.update(user_id: current_user.id)\n respond_to do |format|\n if @raffle.save\n status = 'Participa en la rifa ' + @raffle.name + '. Para visitarla ingresa a https://rifapp-web.herokuapp.com/raffles/' + @raffle.id.to_s\n access_token = prepare_access_token(ENV[\"TWITTER_ACCESS_TOKEN\"], ENV[\"TWITTER_ACCESS_TOKEN_SECRET\"])\n url = '/1.1/statuses/update.json?status=' + URI::escape(status)\n response = access_token.post(url)\n puts response\n #url = 'graph.facebook.com/v2.9/100019068038209/feed?message=' + URI::escape(status) + '&access_token=' + ENV[\"FB_ACCESS_TOKEN\"]\n #RestClient.post url, {}\n format.html { redirect_to created_user_path(current_user.id), notice: 'Raffle was successfully created.' }\n format.json { render :show, status: :created, location: @raffle }\n else\n format.html { render :new }\n format.json { render json: @raffle.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @fan = Fan.new(params[:fan])\n\n respond_to do |format|\n if @fan.save\n format.html { render :action => 'thanks' }\n format.xml { render :xml => @fan, :status => :created, :location => @fan }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @fan.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create_teacher\n @signature = Signature.find(params[:id])\n @signatures_teacher = @signature.signatures_teachers.build(params[:signatures_teacher])\n\n respond_to do |format|\n if @signatures_teacher.save\n format.html { redirect_to(@signature, :notice => 'Profesor añadido con éxito.') }\n format.xml { render :xml => @signature, :status => :created, :location => @signature }\n else\n format.html { render :action => \"show\" }\n format.xml { render :xml => @signature.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @questionfife = Questionfive.new(questionfife_params)\n\n respond_to do |format|\n if @questionfife.save\n format.html { redirect_to @questionfife, notice: 'Questionfive was successfully created.' }\n format.json { render :show, status: :created, location: @questionfife }\n else\n format.html { render :new }\n format.json { render json: @questionfife.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @fat = Fat.new(fat_params)\n\n respond_to do |format|\n if @fat.save\n format.html { redirect_to @fat, notice: 'Fat was successfully created.' }\n format.json { render :show, status: :created, location: @fat }\n else\n format.html { render :new }\n format.json { render json: @fat.errors, status: :unprocessable_entity }\n end\n end\n end" ]
[ "0.55039704", "0.54251176", "0.5343005", "0.53175426", "0.5239797", "0.5229069", "0.52240103", "0.51637775", "0.51343894", "0.5091505", "0.5073883", "0.5017746", "0.49986044", "0.4991063", "0.49683544", "0.49375308", "0.4926145", "0.48768073", "0.4848334", "0.4847382", "0.4843447", "0.48390827", "0.4838092", "0.481875", "0.4800987", "0.47997847", "0.47978944", "0.47877875", "0.4779987", "0.47792298", "0.4758886", "0.47585544", "0.47445214", "0.47445065", "0.47345218", "0.4708702", "0.47068277", "0.47054434", "0.47053137", "0.4698253", "0.4686066", "0.46745357", "0.4672865", "0.46722364", "0.46722364", "0.46722364", "0.4651685", "0.46457902", "0.46457902", "0.46457902", "0.4645517", "0.46443805", "0.4643282", "0.4643282", "0.4643282", "0.46392965", "0.46365657", "0.4634681", "0.46340537", "0.46265903", "0.46229655", "0.46208066", "0.46184695", "0.46088156", "0.46073458", "0.46039048", "0.46004698", "0.46004698", "0.46004698", "0.46004698", "0.46004698", "0.45975065", "0.45953658", "0.45934686", "0.4590988", "0.45891783", "0.45889068", "0.45873606", "0.45844835", "0.45828485", "0.45788622", "0.45744312", "0.45744312", "0.45744312", "0.45744312", "0.45708844", "0.45673218", "0.4565583", "0.45583814", "0.45480835", "0.4545765", "0.45456886", "0.4540817", "0.45392615", "0.45328495", "0.45326555", "0.4532542", "0.45308232", "0.45303348", "0.4528403" ]
0.68211067
0
PUT /fingers/1 PUT /fingers/1.xml
def update @finger = Finger.find(params[:id]) @finger.user = current_user respond_to do |format| if @finger.update_attributes(params[:finger]) flash[:notice] = 'Finger was successfully updated.' format.html { redirect_to(fingers_path) } format.xml { head :ok } else format.html { render :action => "edit" } format.xml { render :xml => @finger.errors, :status => :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @finger = Finger.new(params[:finger])\n @finger.user = current_user\n \n respond_to do |format|\n if @finger.save\n flash[:notice] = 'Finger was successfully created.'\n format.html { redirect_to(fingers_path) }\n format.xml { render :xml => @finger, :status => :created, :location => @finger }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @finger.errors, :status => :unprocessable_entity }\n end\n end\n end", "def put(uri, xml)\r\n req = Net::HTTP::Put.new(uri)\r\n req[\"content-type\"] = \"application/xml\"\r\n req.body = xml\r\n request(req)\r\n end", "def update opts = {}\n opts[:headers] ||= {}\n opts[:headers]['Content-Type'] ||= 'text/xml'\n post 'update', opts\n end", "def put!\n request! :put\n end", "def destroy\n @finger = Finger.find(params[:id])\n @finger.destroy\n\n respond_to do |format|\n format.html { redirect_to(fingers_url) }\n format.xml { head :ok }\n end\n end", "def put(*args)\n request :put, *args\n end", "def update(id, name=\"Updated Name\", age=\"55\")\r\n xml_req =\r\n \"<?xml version='1.0' encoding='UTF-8'?>\r\n <person>\r\n <id type='integer'>#{id}</id>\r\n <name>#{name}</name>\r\n <age>#{age}</age> \r\n </person>\"\r\n request = Net::HTTP::Put.new(\"#{@url}/#{id}.xml\")\r\n request.add_field \"Content-Type\", \"application/xml\"\r\n request.body = xml_req\r\n http = Net::HTTP.new(@uri.host, @uri.port)\r\n response = http.request(request)\r\n # no response body will be returned\r\n case response\r\n when Net::HTTPSuccess\r\n return \"#{response.code} OK\"\r\n else\r\n return \"#{response.code} ERROR\"\r\n end\r\n end", "def put(path = '/files/', params = {})\n request :put, path, params\n end", "def update\n @finger_print = FingerPrint.find(params[:id])\n\n respond_to do |format|\n if @finger_print.update_attributes(params[:finger_print])\n format.html { redirect_to @finger_print, notice: 'Finger print was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @finger_print.errors, status: :unprocessable_entity }\n end\n end\n end", "def put(*args)\n request(:put, *args)\n end", "def rest_update(uri, method: Net::HTTP::Put)\n request = Net::HTTP::Get.new uri\n request.add_field(\"Accept\",\"application/xml\")\n auth_admin(request)\n \n Net::HTTP.start(uri.host, uri.port) do |http|\n response = http.request request\n response.value\n\n doc = REXML::Document.new response.body\n \n doc = strip_class_attributes(yield doc)\n \n request2 = method.new uri\n request2.content_type = 'application/xml'\n auth_admin(request2)\n\n request2.body=doc.to_s\n \n response2 = http.request request2\n response.value\n\n end\n \nend", "def update\n @face = Face.find(params[:id])\n\n respond_to do |format|\n if @face.update_attributes(params[:face])\n flash[:notice] = 'Face was successfully updated.'\n format.html { redirect_to(@face) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @face.errors, :status => :unprocessable_entity }\n end\n end\n end", "def put(path, options={})\n request :put, path, options\n end", "def put(path, opts = {})\n request(:put, path, opts).body\n end", "def update(attrs, path=nil)\n resp = api_client.put(path || url, JSON.dump(attrs))\n refresh(JSON.load(resp.body))\n end", "def put(*args)\n prepare_request(:put, args)\n @@client.add(:put, @path, *args)\n end", "def update options={}\n client.put(\"/#{id}\", options)\n end", "def put(path, params = {})\n request(:put, path, params)\n end", "def put(path, params = {})\n request(:put, path, params)\n end", "def put(path, params = {})\n request(:put, path, params)\n end", "def update\n @eat = Eat.find(params[:id])\n\n respond_to do |format|\n if @eat.update_attributes(params[:eat])\n flash[:notice] = 'Eat was successfully updated.'\n format.html { redirect_to installation_eat_path(@installation, @eat) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @eat.errors, :status => :unprocessable_entity }\n end\n end\n end", "def put(path, options={})\n send_request 'put', path, options\n end", "def put payload, path = \"\"\n make_request(path, \"put\", payload)\n end", "def put(path, params={})\n request(:put, path, params)\n end", "def put(path, params={})\n request(:put, path, params)\n end", "def put(path, params={})\n request(:put, path, params)\n end", "def put(path, params={})\n request(:put, path, params)\n end", "def put(path, params={})\n request(:put, path, params)\n end", "def put(path, params={})\n request(:put, path, params)\n end", "def put(path, params={})\n request(:put, path, params)\n end", "def put(path, params={})\n request(:put, path, params)\n end", "def put(path, options = {})\n request(:put, path, options)\n end", "def put(path, options = {})\n request(:put, path, options)\n end", "def update\n put :update\n end", "def update\n @spoofer = Spoofer.find(params[:id])\n\n respond_to do |format|\n if @spoofer.update_attributes(params[:spoofer])\n format.html { redirect_to @spoofer, notice: 'Spoofer was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @spoofer.errors, status: :unprocessable_entity }\n end\n end\n end", "def put(path, **args); end", "def update(id, name= \"Updated Name\")\n xml_req =\n \"<?xml version='1.0' encoding='UTF-8'?>\n <customer>\n <id type='integer'>#{id}</id>\n <name>#{name}</name>\n </customer>\"\n\n request = Net::HTTP::Put.new(\"#{@url}/#{id}.xml\")\n request.add_field \"Content-Type\", \"application/xml\"\n request.body = xml_req\n\n http = Net::HTTP.new(@uri.host, @uri.port)\n response = http.request(request)\n\n # no response body will be returned\n case response\n when Net::HTTPSuccess\n return \"#{response.code} OK\"\n else\n return \"#{response.code} ERROR\"\n end\n end", "def show\n @finger = Finger.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @finger }\n end\n end", "def put(path, params = {})\n request(:put, path, params)\n end", "def put(path, params = {})\n request(:put, path, params)\n end", "def update\n\n @foaf.interests.clear\n\n if(foaf_params.has_key?(:interests_attributes))\n interest_ids = foaf_params[:interests_attributes].split(\",\").map { |s| s.to_i }\n interest_ids.each do |i|\n @foaf.interests << Interest.find(i)\n #@foaf.update(Interest.find(i))\n end\n \n end\n\n respond_to do |format|\n if @foaf.update(name: foaf_params[:name], work: foaf_params[:work], \n slug: foaf_params[:slug], birthday: foaf_params[:birthday])\n format.html { redirect_to @foaf, notice: 'FOAF was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @foaf.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @shot = Shot.find(params[:id])\n\n respond_to do |format|\n if @shot.update_attributes(params[:shot])\n format.html { redirect_to(@shot, :notice => 'Shot was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @shot.errors, :status => :unprocessable_entity }\n end\n end\n end", "def put(path, data=nil)\n request(:put, path, data)\n end", "def http_put(path, data, content_type = 'application/json')\n http_methods(path, :put, data, content_type)\n end", "def update\n @magnetic_finger_print = MagneticFingerPrint.find(params[:id])\n\n respond_to do |format|\n if @magnetic_finger_print.update_attributes(params[:magnetic_finger_print])\n format.html { redirect_to @magnetic_finger_print, notice: 'Magnetic finger print was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @magnetic_finger_print.errors, status: :unprocessable_entity }\n end\n end\n end", "def put(path, params={})\n request(:put, path, params)\n end", "def put(path, doc = nil, options = {})\n execute('PUT', path, options, doc)\n end", "def put(uri, doc = nil, options = {})\n execute(uri, :put, options, doc)\n end", "def put(path, options = {})\n request(:put, path, options)\n end", "def put(path, options = {})\n request(:put, path, options)\n end", "def put endpoint, data\n do_request :put, endpoint, data\n end", "def update\n\n @foaf.interests.clear\n\n if(foaf_params.has_key?(:interests_attributes))\n interest_ids = foaf_params[:interests_attributes].split(\",\").map { |s| s.to_i }\n interest_ids.each do |i|\n @foaf.interests << Interest.find(i)\n #@foaf.update(Interest.find(i))\n end\n \n end\n\n respond_to do |format|\n if @foaf.update(name: foaf_params[:name], work: foaf_params[:work], \n slug: foaf_params[:slug], birthday: foaf_params[:birthday])\n format.html { redirect_to @foaf, notice: 'Foaf was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @foaf.errors, status: :unprocessable_entity }\n end\n end\n end", "def put(path, data={})\n request(:put, path, data)\n end", "def put(path, parameters = {})\n request(:put, path, parameters)\n end", "def update(*args)\n put(*args)\n end", "def update(*args)\n put(*args)\n end", "def api_put(path, data = {})\n api_request(:put, path, :data => data)\n end", "def update\n resource_path = \"/projects/#{project_id}/people/#{id}\"\n Request.put(resource_path, self.to_xml('person'))\n end", "def update\n @favorite = Favorite.find(params[:id])\n\n respond_to do |format|\n if @favorite.update_attributes(params[:favorite])\n format.html { redirect_to(favorites_url, :notice => 'Favorite was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @favorite.errors, :status => :unprocessable_entity }\n end\n end\n end", "def put(path, options={}, format=format)\n request(:put, path, options, format)\n end", "def test_putpoi_update_valid\n nd = create(:node)\n cs_id = nd.changeset.id\n user = nd.changeset.user\n amf_content \"putpoi\", \"/1\", [\"#{user.email}:test\", cs_id, nd.version, nd.id, nd.lon, nd.lat, nd.tags, nd.visible]\n post :amf_write\n assert_response :success\n amf_parse_response\n result = amf_result(\"/1\")\n\n assert_equal 5, result.size\n assert_equal 0, result[0]\n assert_equal \"\", result[1]\n assert_equal nd.id, result[2]\n assert_equal nd.id, result[3]\n assert_equal nd.version + 1, result[4]\n\n # Now try to update again, with a different lat/lon, using the updated version number\n lat = nd.lat + 0.1\n lon = nd.lon - 0.1\n amf_content \"putpoi\", \"/2\", [\"#{user.email}:test\", cs_id, nd.version + 1, nd.id, lon, lat, nd.tags, nd.visible]\n post :amf_write\n assert_response :success\n amf_parse_response\n result = amf_result(\"/2\")\n\n assert_equal 5, result.size\n assert_equal 0, result[0]\n assert_equal \"\", result[1]\n assert_equal nd.id, result[2]\n assert_equal nd.id, result[3]\n assert_equal nd.version + 2, result[4]\n end", "def update\n @bottle = Bottle.find(params[:id])\n\n respond_to do |format|\n if @bottle.update_attributes(params[:bottle])\n format.html { redirect_to(@bottle, :notice => 'Bottle was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @bottle.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update(url, data)\n RestClient.put url, data, :content_type => :json\nend", "def simple_put(uri, filename, wait = true, opts = {})\n id = @utils.id_generate\n options = { \"URI\" => uri, \"Identifier\" => id, \"UploadFrom\" => 'disk', \"Filename\" => filename, \"FileHash\" => @utils.filehash_maker(id, filename,identifier), \"Verbosity\" => \"111111111\" }.merge(opts)\n options[\"TargetFilename\"] = filename.split(File::SEPARATOR)[-1] if uri =~ /CHK@/\n send_packet @utils.packet_mangler(options,\"ClientPut\")\n #@com.fcpackets.client_put uri, id, options\n if wait\n wait_for id, /PutFailed|PutSuccessful/\n else\n id\n end\n end", "def _http_put resource, path\n uri = ::URI.parse(resource.auth_uri)\n path = _path uri, path\n request = Net::HTTP::Put.new(path)\n _build_request resource, request\nend", "def _http_put resource, path\n uri = ::URI.parse(resource.auth_uri)\n path = _path uri, path\n request = Net::HTTP::Put.new(path)\n _build_request resource, request\nend", "def request_put(path)\n\ttimestamp = Time.now.utc.iso8601\n\tauth = create_hmac_auth(\"PUT\", path, timestamp)\n\t\n\turi = URI($baseUrl + path)\n\n\trequest = Net::HTTP::Put.new(uri)\n\trequest.add_field(\"x-hp-hmac-authentication\", auth)\n\trequest.add_field(\"x-hp-hmac-date\", timestamp)\n\n\tresponse = Net::HTTP.start(uri.host, uri.port,\n\t\t:use_ssl => uri.scheme == 'https',\n\t\t:verify_mode => OpenSSL::SSL::VERIFY_NONE) do |http|\n\t\thttp.request(request)\n\tend\n\n\treturn response\nend", "def update\n @f5_node = F5Node.find(params[:id])\n\n respond_to do |format|\n if @f5_node.update_attributes(params[:f5_node])\n format.html { redirect_to @f5_node, notice: 'F5 node was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @f5_node.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @fan = Fan.find(params[:id])\n\n respond_to do |format|\n if @fan.update_attributes(params[:fan])\n flash[:notice] = 'Fan was successfully updated.'\n format.html { redirect_to(@fan) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @fan.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n\t\t@family ||= Family.find(params[:id])\n respond_to do |format|\n if @family.update_attributes(params[:family])\n flash[:notice] = 'Family was successfully updated.'\n format.html { redirect_to(@family) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @family.errors, :status => :unprocessable_entity }\n end\n end\n end", "def put_update\n response = self.class.put(\"/service/#{$service_id}/version/#{$service_version}/logging/sftp/#{$name}\", \n headers: { \"Fastly-Key\" => $key }, \n body: $put_form_data )\n end", "def put(path, opts = {}, &block)\n request(:put, path, opts, &block)\n end", "def put(path, opts = {}, &block)\n request(:put, path, opts, &block)\n end", "def put(path, data = {})\n request 'PUT', path, body: data.to_json\n end", "def update_xml\n self.xml= dumpRouteAsXml\n self.save\n end", "def update\n @threat = Threat.find(params[:id])\n\n respond_to do |format|\n if @threat.update_attributes(params[:threat])\n format.html { redirect_to(@threat, :notice => 'Threat was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @threat.errors, :status => :unprocessable_entity }\n end\n end\n end", "def put(path, params)\n request(:put, path, params)\n end", "def update\n @gift = Gift.find(params[:id])\n\n respond_to do |format|\n if @gift.update_attributes(params[:gift])\n flash[:notice] = 'Gift was successfully updated.'\n format.html { redirect_to(@gift) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @gift.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @snap = Snap.find(params[:id])\n\n respond_to do |format|\n if @snap.update_attributes(params[:snap])\n format.html { redirect_to(@snap, :notice => 'Snap was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @snap.errors, :status => :unprocessable_entity }\n end\n end\n end", "def put(uri, params = {})\n send_request(uri, :put, params)\n end", "def update\n @gesture = Gesture.find(params[:id])\n\n respond_to do |format|\n if @gesture.update_attributes(params[:gesture])\n format.html { redirect_to @gesture, notice: 'Gesture was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @gesture.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @favorite_flyer = FavoriteFlyer.find(params[:id])\n\n respond_to do |format|\n if @favorite_flyer.update_attributes(params[:favorite_flyer])\n format.html { redirect_to @favorite_flyer, notice: 'Favorite flyer was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @favorite_flyer.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @fucker = Fucker.find(params[:id])\n\n respond_to do |format|\n if @fucker.update_attributes(params[:fucker])\n format.json { head :no_content }\n else\n format.json { render json: @fucker.errors, status: :internal_server_error }\n end\n end\n end", "def put(path, options = {}, raw = false)\n request(:put, path, options, raw)\n end", "def update\n @force = Force.find(params[:id])\n\n respond_to do |format|\n if @force.update_attributes(params[:force])\n format.html { redirect_to(@force, :notice => 'Force was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @force.errors, :status => :unprocessable_entity }\n end\n end\n end", "def new \n @finger = Finger.new\n @finger.user = current_user\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @finger }\n end\n end", "def update\n #@feat = Feat.find(params[:id])\n @feat = @character.feats.find(params[:id])\n\n respond_to do |format|\n if @feat.update_attributes(params[:feat])\n flash[:notice] = 'Feat was successfully updated.'\n format.html { redirect_to(edit_character_path(@character)) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @feat.errors, :status => :unprocessable_entity }\n end\n end\n end", "def put(path, &block)\n route 'PUT', path, &block\n end", "def put(path, options={}, raw=false)\n request(:put, path, options, raw)\n end", "def update\n @fan_request = FanRequest.find(params[:id])\n\n respond_to do |format|\n if @fan_request.update_attributes(params[:fan_request])\n flash[:notice] = 'FanRequest was successfully updated.'\n format.html { redirect_to(@fan_request) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @fan_request.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @favourite = Favourite.find(params[:id])\n\n respond_to do |format|\n if @favourite.update_attributes(params[:favourite])\n flash[:notice] = 'Favourite was successfully updated.'\n format.html { redirect_to(@favourite) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @favourite.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @ref = Ref.find(params[:id])\n\n respond_to do |format|\n if @ref.update_attributes(params[:ref])\n format.html { redirect_to(@ref, :notice => 'Ref was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @ref.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update(args)\n builder.update_rest(type, ref, args, username, password)\n self.elements(true)\n end", "def update\n @monkey = Monkey.find(params[:id])\n\n respond_to do |format|\n if @monkey.update_attributes(params[:monkey])\n format.html { redirect_to(@monkey, :notice => 'Monkey was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @monkey.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @node = Node.scopied.find(params[:id])\n\n respond_to do |format|\n if @node.update_attributes(params[:node])\n format.html { redirect_to(@node, :notice => 'Node was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @node.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @discovery = Discovery.find(params[:id])\n\n respond_to do |format|\n if @discovery.update_attributes(params[:discovery])\n flash[:notice] = 'Discovery was successfully updated.'\n format.html { redirect_to(@discovery) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @discovery.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @post377 = Post377.find(params[:id])\n\n respond_to do |format|\n if @post377.update_attributes(params[:post377])\n format.html { redirect_to(@post377, :notice => 'Post377 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post377.errors, :status => :unprocessable_entity }\n end\n end\n end", "def http_put(request, response)\n body = request.body_as_stream\n path = request.path\n\n # Intercepting Content-Range\n if request.header('Content-Range')\n # An origin server that allows PUT on a given target resource MUST send\n # a 400 (Bad Request) response to a PUT request that contains a\n # Content-Range header field.\n #\n # Reference: http://tools.ietf.org/html/rfc7231#section-4.3.4\n fail Exception::BadRequest, 'Content-Range on PUT requests are forbidden.'\n end\n\n # Intercepting the Finder problem\n expected = request.header('X-Expected-Entity-Length').to_i\n if expected > 0\n # Many webservers will not cooperate well with Finder PUT requests,\n # because it uses 'Chunked' transfer encoding for the request body.\n #\n # The symptom of this problem is that Finder sends files to the\n # server, but they arrive as 0-length files in PHP.\n #\n # If we don't do anything, the user might think they are uploading\n # files successfully, but they end up empty on the server. Instead,\n # we throw back an error if we detect this.\n #\n # The reason Finder uses Chunked, is because it thinks the files\n # might change as it's being uploaded, and therefore the\n # Content-Length can vary.\n #\n # Instead it sends the X-Expected-Entity-Length header with the size\n # of the file at the very start of the request. If this header is set,\n # but we don't get a request body we will fail the request to\n # protect the end-user.\n\n # Only reading first byte\n first_byte = body.read(1)\n unless first_byte\n fail Exception::Forbidden, 'This server is not compatible with OS/X finder. Consider using a different WebDAV client or webserver.'\n end\n\n # The body needs to stay intact, so we copy everything to a\n # temporary stream.\n\n new_body = StringIO.new\n new_body.write(first_byte)\n IO.copy_stream(body, new_body)\n new_body.rewind\n\n body = new_body\n end\n\n if @server.tree.node_exists(path)\n node = @server.tree.node_for_path(path)\n\n # If the node is a collection, we'll deny it\n unless node.is_a?(IFile)\n fail Exception::Conflict, 'PUT is not allowed on non-files.'\n end\n\n etag = Box.new\n return false unless @server.update_file(path, body, etag)\n etag = etag.value\n\n response.update_header('Content-Length', '0')\n response.update_header('ETag', etag) if etag\n response.status = 204\n else\n # If we got here, the resource didn't exist yet.\n etag = Box.new\n unless @server.create_file(path, body, etag)\n # For one reason or another the file was not created.\n return false\n end\n etag = etag.value\n\n response.update_header('Content-Length', '0')\n response.update_header('ETag', etag) if etag\n response.status = 201\n end\n\n # Sending back false will interupt the event chain and tell the server\n # we've handled this method.\n false\n end", "def update\n respond_to do |format|\n if @food.update_attributes(params[:food])\n flash[:notice] = 'Food was successfully updated.'\n format.html { redirect_to(food_url(@food)) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @food.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @gesture = Gesture.find(params[:id])\n\n if @gesture.update(gesture_params)\n head :no_content\n else\n render json: @gesture.errors, status: :unprocessable_entity\n end\n end" ]
[ "0.59614885", "0.58890104", "0.58790255", "0.56750077", "0.5599315", "0.55899286", "0.55658597", "0.5400704", "0.5395109", "0.5373981", "0.5366468", "0.52468497", "0.5245675", "0.5244778", "0.52437353", "0.5215326", "0.51994777", "0.51800364", "0.51800364", "0.51800364", "0.51321965", "0.5130374", "0.5123466", "0.5122954", "0.5122954", "0.5122954", "0.5122954", "0.5122954", "0.5122954", "0.5122954", "0.5122954", "0.51228964", "0.51228964", "0.51157594", "0.5112553", "0.5108014", "0.51075214", "0.5102511", "0.5099105", "0.5099105", "0.50808287", "0.5078467", "0.5077727", "0.5073816", "0.5056418", "0.50543255", "0.5052349", "0.50483763", "0.5046773", "0.5046773", "0.5044079", "0.5042758", "0.5039817", "0.5037957", "0.50315654", "0.50315654", "0.5008051", "0.49989563", "0.49969912", "0.49939275", "0.49933833", "0.49837965", "0.4982164", "0.49786463", "0.49764243", "0.49755248", "0.49744007", "0.4966674", "0.49636555", "0.4963496", "0.49621177", "0.49619702", "0.49619702", "0.49608332", "0.49592614", "0.4952184", "0.4952051", "0.49457222", "0.49449247", "0.49303922", "0.49272114", "0.49244177", "0.4921804", "0.4915279", "0.49080408", "0.49065402", "0.49003714", "0.4899754", "0.4892122", "0.48913908", "0.48834065", "0.48828065", "0.4879039", "0.48788333", "0.48719802", "0.48680046", "0.48651472", "0.48613283", "0.48597383", "0.48595342" ]
0.68502283
0
DELETE /fingers/1 DELETE /fingers/1.xml
def destroy @finger = Finger.find(params[:id]) @finger.destroy respond_to do |format| format.html { redirect_to(fingers_url) } format.xml { head :ok } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete path\n make_request(path, \"delete\", {})\n end", "def destroy\n RestClient.delete \"#{REST_API_URI}/contents/#{id}.xml\" \n self\n end", "def delete!\n Recliner.delete(uri)\n end", "def deletef\n url = prefix + \"deletef\" + id_param\n return response(url)\n end", "def delete()\n response = send_post_request(@xml_api_delete_path)\n response.is_a?(Net::HTTPSuccess) or response.is_a?(Net::HTTPRedirection)\n end", "def delete(path)\n path = relativize_path path\n\n Precog.connect self do |http|\n uri = Addressable::URI.new\n uri.query_values = { :apiKey => api_key }\n\n http.delete \"/ingest/v#{VERSION}/fs/#{path}?#{uri.query}\"\n end\n end", "def delete\n client.delete(\"/#{id}\")\n end", "def delete()\n response = send_post_request(@xml_api_delete_path)\n response.is_a?(Net::HTTPSuccess) or response.is_a?(Net::HTTPRedirection)\n end", "def delete\n request(:delete)\n end", "def delete\n \n end", "def delete\n end", "def delete\n\n end", "def delete(path)\n request(:delete, path)\n end", "def delete\n end", "def delete\n end", "def delete\n end", "def delete\n end", "def delete\n end", "def delete\n end", "def delete\n end", "def delete\n\t\tdb.execute{ \"delete edge #{ref_name} #{rrid}\" }\n\tend", "def destroy; delete end", "def delete(*uris); end", "def delete(options={})\n connection.delete(\"/\", @name)\n end", "def destroy\n @feat = @person.feats.find(params[:id])\n @feat.destroy\n\n respond_to do |format|\n format.html { redirect_to(person_feats_url(@person)) }\n format.xml { head :ok }\n end\n end", "def delete(path)\n request 'DELETE', path\n end", "def destroy\n @finger_print = FingerPrint.find(params[:id])\n @finger_print.destroy\n\n respond_to do |format|\n format.html { redirect_to finger_prints_url }\n format.json { head :no_content }\n end\n end", "def delete\n \n end", "def delete(path)\n request(:delete, path)\n end", "def destroy\n @feefile = Feefile.find(params[:id])\n directory= \"uploads\"\n path =File.join(directory,@feefile.feefilename)\n File.delete(path)\n @feefile.destroy\n \n\n respond_to do |format|\n format.html { redirect_to(feefiles_url) }\n format.xml { head :ok }\n end\n end", "def delete(path)\n RestClient.delete request_base+path\n end", "def delete(name)\n\n end", "def destroy\n @monkey = Monkey.find(params[:id])\n @monkey.destroy\n\n respond_to do |format|\n format.html { redirect_to(monkeys_url) }\n format.xml { head :ok }\n end\n end", "def delete(path)\n\t\trequest(path, :delete)\n\tend", "def delete(name); end", "def delete(name); end", "def delete\n model.delete_attachment(@path)\n end", "def delete(path = '/files/', params = {})\n request :delete, path, params\n end", "def delete!\n request! :delete\n end", "def delete_file_from_database(file_id)\n $db.execute(\"DELETE FROM files WHERE id = ?\", file_id)\n $db.execute(\"DELETE FROM file_share_table WHERE file_id = ?\", file_id)\nend", "def cmd_delete argv\n setup argv\n e = @hash['element']\n response = @api.delete(e)\n msg response\n return response\n end", "def delete\n\n\tend", "def delete(name)\n @ctx.delete(@path + name)\n end", "def destroy\n \tself.class.mongo_client.database.fs.find(:_id => BSON::ObjectId(@id)).delete_one\n end", "def delete(*args)\n request(:delete, *args)\n end", "def destroy\n @snap = Snap.find(params[:id])\n @snap.destroy\n\n respond_to do |format|\n format.html { redirect_to(snaps_url) }\n format.xml { head :ok }\n end\n end", "def delete(filename); end", "def delete(path)\n root.delete(path)\n end", "def del\n delete\n end", "def delete() #DELETE film1.delete (removes 1 film)\n sql = \"DELETE FROM films WHERE id = $1;\"\n values = [@id]\n SqlRunner.run(sql, values)\n end", "def deleteEssence\n \n begin\n \n # Gets @filename and @path\n getPathAndFilename \n name = @filename \n filepath = @path\n puts \"filepath: \" + filepath \n puts \"filename: \" + name\n \n # Find the device \n device = User.find_by_username(params[:username]).devices.find_by_dev_name(params[:devicename])\n \n # Essence can't be deleted from a virtual container\n if device.dev_type == \"virtual_container\"\n render :text => \"Error: Essence can't be deleted from a virtual container'\", :status => 409\n return \n end\n \n file = nil\n if device != nil\n file = device.devfiles.find(:first, :conditions => [\"name = ? and path = ?\", name, filepath])\n if file == nil\n puts \"FILE NOT FOUND: \" + name\n render :text => \"Error. File's metadata can not be found.\", :status => 404\n return\n end\n \n if params[:blob_hash]\n blob = file.blobs.find(:first, :conditions => [\"blob_hash = ?\", params[:blob_hash]])\n else\n blob = file.blobs.find_by_follower_id(nil)\n end\n end\n \n # Checks that the file's and it's version's metadata can be found in database.\n if file == nil or blob == nil\n puts \"Blob not found for file: \" + name\n render :text => \"Error. File's metadata can not be found.\", :status => 404\n return\n end\n \n if blob.uploaded == false\n render :text => \"Error: Essence of the file was not on the server.\", :status => 409\n return\n end\n \n # Remove the fileupload entry\n fup = Fileupload.find_by_blob_id(blob.id)\n if fup != nil\n fup.destroy\n end\n \n # Update blob not to be uploaded and upload_requested to nil\n blob.update_attribute(:uploaded, false)\n blob.update_attribute(:upload_requested, nil)\n \n \n # Remove the actual essence\n deletepath = \"public/devfiles/\" + file.device_id.to_s + \"/\" + blob.blob_hash + \"_\" + file.name\n \n if File.exists?(deletepath)\n FileUtils.rm_f(deletepath)\n puts \"deleted the essence...\"\n else\n puts \"Essence not found and could not be deleted...\"\n end\n \n rescue => exp\n putsE(exp)\n render :text => \"There was an error when trying to delete the essence from the server\", :status => 409\n return\n end\n \n render :text => \"Essence of the file deleted from the server\", :status => 200\n return\n end", "def delete\n end", "def deleteResource(doc, msg_from)\n \n \n begin\n\n puts \"Deleting\"\n\n path = \"\"\n params = {}\n headers = {}\n \n context, path = findContext(doc, path) \n \n # Deleting member from group\n if context == :user_group_member\n params = {}\n else\n raise Exception.new(\"No context given!\")\n end\n \n httpAndNotify(path, params, msg_from, :delete)\n \n rescue Exception => e\n puts \"Problem in parsing data (CREATE) from xml or sending http request to the VR server: \" + e\n puts \" -- line: #{e.backtrace[0].to_s}\"\n end\n \n end", "def delete\n execute_request('DELETE') do |uri, headers|\n HTTP.http_client.delete(uri, header: headers)\n end\n end", "def delete!\n delete( nil, true ) \n end", "def delete(id)\r\n connection.delete(\"/#{@doctype}[@ino:id=#{id}]\")\r\n end", "def delete_file_from_db(file_id)\n $db.execute(\"DELETE FROM files WHERE file_id = ?\", file_id)\nend", "def destroy\n @ref = Ref.find(params[:id])\n @ref.destroy\n\n respond_to do |format|\n format.html { redirect_to(refs_url) }\n format.xml { head :ok }\n end\n end", "def delete(path)\n make_call(mk_conn(path), :delete)\n end", "def ftp_remove path\n return ftp_action(true, path)\n end", "def delete!\n delete(:force => true)\n nil\n end", "def delete\n response = WebPay.client.delete(path)\n response['deleted']\n end", "def delete\n ::File.unlink(@path)\n end", "def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end", "def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end", "def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end", "def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end", "def delete; rest_delete(link('self')); end", "def delete; rest_delete(link('self')); end", "def delete\n delete_from_server single_url\n end", "def delete(uuid, key)\n request(method: 'DELETE', uri: \"/files/#{uuid}/metadata/#{key}/\")\n end", "def delete\n client.delete(url)\n @deleted = true\nend", "def destroy\n @fuga = Fuga.find(params[:id])\n @fuga.destroy\n\n respond_to do |format|\n format.html { redirect_to(fugas_url) }\n format.xml { head :ok }\n end\n end", "def delete(action, **args); end", "def delete(*rest) end", "def delete(id, post)\n File.unlink(post_path(post))\n\n update_digests do |digests|\n digests.delete(id)\n end\n end", "def destroy\n @bottle = Bottle.find(params[:id])\n @bottle.destroy\n\n respond_to do |format|\n format.html { redirect_to(bottles_url) }\n format.xml { head :ok }\n end\n end", "def rm(*path)\n super; on_success{ nil }\n end", "def gp_delete_file(aid)\n data = Asn1Ber.encode [{:class => :application, :primitive => true,\n :number => 0x0F, :value => aid}]\n response = iso_apdu! :cla => 0x80, :ins => 0xE4, :p1 => 0x00, :p2 => 0x80,\n :data => data\n delete_confirmation = response[1, response[0]]\n delete_confirmation\n end", "def delete(*args)\n Request.delete(*args)\n end", "def delete(*args)\n prepare_request(:delete, args)\n @@client.add(:delete, @path, *args)\n end", "def delete\n @client.delete_document(@path)\n end", "def delete\n url = prefix + \"delete\"\n return response(url)\n end", "def delete\n url = prefix + \"delete\"\n return response(url)\n end", "def destroy\n @docent = Docent.find(params[:id])\n @docent.destroy\n\n respond_to do |format|\n format.html { redirect_to(docents_url) }\n format.xml { head :ok }\n end\n end", "def delete (fei)\n\n e = find(fei)\n e.destroy if e\n end", "def delete_data(index_name)\n uri = @client.make_uri(\"/#{index_name}/update/\")\n req = HTTP::Post.new(uri)\n req.content_type = 'text/xml'\n req.body = '<delete><query>*:*</query></delete>'\n response = @client.send_http(req, true, ['200'])\n end", "def destroy\n @fridge_food = FridgeFood.find(params[:id])\n @fridge_food.destroy\n\n respond_to do |format|\n format.html { redirect_to(fridge_foods_url) }\n format.xml { head :ok }\n end\n end", "def delete(name)\n request(uri = uri(name), Net::HTTP::Delete.new(uri.request_uri))\n end", "def delete\n conn.delete(escaped_path)\n true\n rescue StandardError => e\n puts \"carrierwave-upyun delete failed: #{e.inspect}\"\n nil\n end", "def netdev_resxml_delete( xml )\n top = netdev_resxml_top( xml )\n par = top.instance_variable_get(:@parent)\n par['delete'] = 'delete'\n end", "def delete\n end", "def destroy\n @helocagree = Helocagree.find(params[:id])\n @helocagree.destroy\n\n respond_to do |format|\n format.html { redirect_to(helocagrees_url) }\n format.xml { head :ok }\n end\n end", "def delete\n eadid = (params[\"eadid\"] || \"\").strip\n if eadid == \"\"\n log_error(\"Cannot delete EAD. No ID was provided.\")\n flash[:alert] = \"No EAD ID was provided.\"\n redirect_to upload_list_url()\n return\n end\n\n filename = ENV[\"EAD_XML_PENDING_FILES_PATH\"] + \"/\" + eadid + \".xml\"\n if !File.exist?(filename)\n log_error(\"Cannot delete EAD. File was not found: #{filename}\")\n flash[:alert] = \"Source file not found for finding aid: #{eadid}.\"\n redirect_to upload_list_url()\n return\n end\n\n target = ENV[\"EAD_XML_DELETED_FILES_PATH\"] + \"/\" + eadid + \".xml\"\n FileUtils.mv(filename, target)\n\n if !File.exist?(target)\n log_error(\"File delete failed: #{filename}\")\n flash[:alert] = \"Could not delete finding aid #{eadid}.\"\n redirect_to upload_list_url()\n return\n end\n\n Rails.logger.info(\"Findind aid #{eadid} has been deleted\")\n flash[:notice] = \"Findind aid #{eadid} has been deleted\"\n redirect_to upload_list_url()\n rescue => ex\n render_error(\"delete\", ex, current_user)\n end", "def rm path\n end", "def delete\n @uppity_file = PostedFile.get(params[:id])\n @uppity_file.destroy\n redirect_to(posts_index_url)\n end", "def destroy\n @foyer = Foyer.find(params[:id])\n @foyer.destroy\n\n respond_to do |format|\n format.html { redirect_to(foyers_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @fax_document = FaxDocument.find(params[:id])\n @fax_document.destroy\n \n respond_to do |format|\n format.html { redirect_to(fax_documents_url) }\n format.xml { head :ok }\n end\n end", "def delete(path, params={})\n request(:delete, path, params)\n end", "def delete(path, params={})\n request(:delete, path, params)\n end" ]
[ "0.642467", "0.64239526", "0.6389003", "0.63723946", "0.63683456", "0.6359452", "0.6331855", "0.625638", "0.6209855", "0.61830294", "0.6177054", "0.61646986", "0.6144835", "0.6133123", "0.6133123", "0.6133123", "0.6133123", "0.6133123", "0.6133123", "0.6133123", "0.60908574", "0.6076728", "0.60728437", "0.60693854", "0.60680544", "0.606694", "0.6066447", "0.604522", "0.6035965", "0.6025544", "0.60160404", "0.6014087", "0.6013894", "0.6005122", "0.5999759", "0.5999759", "0.59997356", "0.5996086", "0.59955615", "0.59807545", "0.59789574", "0.5971838", "0.5954874", "0.59547275", "0.5933219", "0.5928099", "0.5924094", "0.59204733", "0.59172845", "0.59008414", "0.5897072", "0.589702", "0.5895863", "0.58923095", "0.5891839", "0.58810437", "0.5880642", "0.5880329", "0.5879136", "0.58770627", "0.58749527", "0.58731693", "0.5872745", "0.58698714", "0.58698714", "0.58698714", "0.58698714", "0.5864527", "0.5864527", "0.58633167", "0.58563066", "0.5856041", "0.58476806", "0.58475316", "0.5846886", "0.584349", "0.5839936", "0.5839776", "0.5836403", "0.58311385", "0.5830839", "0.58303654", "0.5829513", "0.5829513", "0.58288825", "0.58249354", "0.58208954", "0.581861", "0.5818357", "0.5814279", "0.5804753", "0.5802318", "0.580228", "0.5800544", "0.58002675", "0.57979405", "0.578969", "0.5787981", "0.57875514", "0.57875514" ]
0.7430854
0
Select options for category. def self.options_for_category categories = Category.find_by_depth 0 options = [] categories.each do |c| options.push [c.name, c.id] end end
def initialize(params = {}) super self.is_valid = true end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_category_select_options(c, level=0)\n retval = []\n retval << [('-' * level) + c.name, c.id]\n c.categories.each do |child_c|\n get_category_select_options(child_c, level + 1).each do |child_c|\n retval << child_c\n end\n end\n \n return retval\n end", "def category_options\n Category.all.map { |c| [c.categoryName,c.id]}\n end", "def options_for_category_select(collection={}, category = Category.new)\n \n html_code = \"<option value=\"\">None</option>\"\n \n if collection.empty?\n html_code\n else\n parents = collection.select{ |kategory| kategory.parent_id.nil? }\n parents.each do |parent|\n options = {:value => parent.id}\n options = options.merge({:selected=>\"selected\"}) if parent == category\n html_code += tag(\"option\", options, true) + parent.name + \"</option>\" + indent_child_options_for_category_select(parent, category)\n end\n html_code\n end\n\n end", "def get_all_category_select_options()\n o = []\n Category.where(:category_id => nil).each do |c|\n get_category_select_options(c).each do |c_option|\n o << c_option\n end\n end\n return o\n end", "def chosen_categories\n return chosen_options.collect &:category\n end", "def select_options\n (first_level_options || []).map { |o| [o.name, o.id] }\n end", "def options_for_select\n choices.map do |choice|\n data = {}\n data[\"choice-category\"] = choice.category_id if choice.category_id\n\n content_tag(\n :option,\n choice.short_name,\n :value => choice.id,\n :selected => selected_choice?(item, choice),\n :data => data\n )\n end.join.html_safe\n end", "def set_categories\n @categories = Category.order(:name).pluck(:name, :id)\n end", "def collect_tier_categories_for_select(klass, select=true)\n result = klass.find_all_categories.map {|c| [c.name, c.id]}\n result.insert(0, [\"Select...\".t, nil])\n result\n end", "def list\r\n\t\t@current_area = 'categories'\r\n\t\t@current_menu = 'products'\r\n\r\n\t\tif params[:select]\r\n\t\t\tif params[:delete]\r\n\t\t\t\t# you MUST manually move child nodes in an acts_as_tree up before calling\r\n\t\t\t\t# the destroy! method. Otherwise Rails will automatically go and delete all\r\n\t\t\t\t# the child nodes even before the selected nodes' 'before_destroy' callback\r\n\t\t\t\t# is triggered!\r\n\t\t\t\tparams[:select].keys.each do |k|\r\n\t\t\t\t\tthe_cat = Category.find(k)\r\n\t\t\t\t\tthe_cat.move_children_up()\r\n\t\t\t\t\tCategory.destroy(the_cat.id)\r\n\t\t\t\tend\r\n\t\t\telsif params[:move_up]\r\n\t\t\t\t# We have to use a Hash as Array iterators do not like sparse indexing.\r\n\t\t\t\tselected_categories = Hash.new\r\n\t\t\t\tcat_index = Hash.new\r\n\t\t\t\tparams[:select].keys.each do |k|\r\n\t\t\t\t\tc = Category.find(k)\r\n\t\t\t\t\tif selected_categories[c.parent_id].nil?\r\n\t\t\t\t\t\tselected_categories[c.parent_id] = Hash.new\r\n\t\t\t\t\tend\r\n\t\t\t\t\tselected_categories[c.parent_id][c.id] = c.sequence\r\n\t\t\t\t\tcat_index[c.id] = c\r\n\t\t\t\tend\r\n\t\t\t\tselected_categories.each do |i, parent|\r\n\t\t\t\t\t# Hash.sort converts the hash into a nested array before sorting; [0] = key, [1] = value.\r\n\t\t\t\t\t# Note that we only want the IDs which are contained in the index 'j'.\r\n\t\t\t\t\tparent.sort{|a,b| (a[1]<=>b[1])}.each do |j, the_sequence|\r\n\t\t\t\t\t\tcat_index[j].move_higher\r\n\t\t\t\t\tend\r\n\t\t\t\tend\r\n\t\t\telsif params[:move_down]\r\n\t\t\t\t# See comments for move_up above\r\n\t\t\t\tselected_categories = Hash.new\r\n\t\t\t\tcat_index = Hash.new\r\n\t\t\t\tparams[:select].keys.each do |k|\r\n\t\t\t\t\tc = Category.find(k)\r\n\t\t\t\t\tif selected_categories[c.parent_id].nil?\r\n\t\t\t\t\t\tselected_categories[c.parent_id] = Hash.new\r\n\t\t\t\t\tend\r\n\t\t\t\t\tselected_categories[c.parent_id][c.id] = c.sequence\r\n\t\t\t\t\tcat_index[c.id] = c\r\n\t\t\t\tend\r\n\t\t\t\tselected_categories.each do |i, parent|\r\n\t\t\t\t\t# Note order of b/a is swapped to move down. This and move_lower instead of move_higher\r\n\t\t\t\t\t# is the only difference between this and the move_up code above.\r\n\t\t\t\t\tparent.sort{|a,b| (b[1]<=>a[1])}.each do |j, the_sequence|\r\n\t\t\t\t\t\tcat_index[j].move_lower\r\n\t\t\t\t\tend\r\n\t\t\t\tend\r\n\t\t\tend\r\n\t\t\texpire_fragment(:controller => :products, :action => :home, :part => 'category_menu')\r\n\t\tend\r\n\r\n\t\t@root_cat = Category.find(1)\r\n\tend", "def index\n @category_options = CategoryOption.all\n end", "def new\n @post = Post.new\n @category_options = Category.all.map{|u| [u.title, u.id]}\n # @category_options = Category.all\n end", "def get_collection_select_options(c, level=0)\n retval = []\n#=begin\n #TODO: will have to pass in user instead of using current_user\n if not collection_is_viewable(c, current_user)\n return retval\n end\n#=end\n retval << [('-' * level) + c.name, c.id]\n c.children.each do |child_c|\n get_collection_select_options(child_c, level + 1).each do |child_c|\n retval << child_c\n end\n end\n \n return retval\n end", "def categories_list\n @categories = Category.all.collect { |p| [p.name, p.id] }\n end", "def select_cat_from_tree(obj, col, root, selected_obj, *args)\n options = args.extract_options!\n select_name = obj + '[' + col.to_s + ']'\n out = \"<select name='#{select_name}' onchange => update_category('#{obj}', facture)>\"\n out << select_cat_from_tree_recurs(root, selected_obj)\n out << \"</select>\"\n end", "def edit\n @categories = Category.pluck(:name, :id)\n super\n end", "def indent_child_options_for_category_select(parent, category, child_indent = \"&nbsp;&nbsp;&nbsp;\")\n html_code = \"\"\n parent.children.each do |child|\n options = {:value => child.id}\n options = options.merge({:selected=>\"selected\"}) if child == category\n html_code += tag(\"option\", options, true) + child_indent + child.name + \"</option>\" + indent_child_options_for_category_select(child, category, child_indent + child_indent)\n end\n html_code\n end", "def categories_list\n self.categories.collect{|c| c.name}\n end", "def categories(options = {})\n fetch_categories.at('categories').children_of_type('category').inject([]){ |r, i| r << parse_single_category_xml(i) }\n\tend", "def categories\n\t\tbegin\n\t\t\t@categories = Category.select(:id, :name)\n\t\t\trender json: @categories\n\t\trescue Exception => e\n\t\t\terror_handling_bad_request(e)\n\t\tend\n\tend", "def edit\n #locates the selected category\n @category = Category.find(params[:id])\n #creates a sorted array using all categories\n @all_categories = Category.all.sort {|x,y| x.name <=> y.name }\n #creates an empty hash\n @child_categories = []\n #call to function to remove children - a parent cannot be moved to be a child of its own child.\n remove_children(@all_categories, @category)\n #re-assigns the array minus the categories children\n @all_categories = @all_categories - @child_categories\n\n if(!@category.parent_id.nil?)\n @items_to_select = [Category.find(@category.parent_id)]\n else\n @items_to_select = nil\n end\n\n end", "def list_categories\n Category.all.each.with_index(1) {|x, i| puts \"#{i}. #{x.name}\"} #Scraper.categories.each.with_index(1) {|category, i| puts \"#{i}. #{category[0]}\"}\n puts \"select the number of the category you would like to browse or type 'exit'\"\n end", "def assign_categories_for_admin\n categories = Category.all\n @categories = []\n categories.each { |category| @categories << [category.name, category.id] }\n end", "def edit\n\t\t@categories = Category.all.map{|c| [c.name, c.id] }\n\tend", "def new\n #creates a sorted array using all category objects\n @all_categories = Category.all.sort {|x,y| x.name <=> y.name }\n #if statement for duplicating a record\n if params[:duplicate_category]\n #Assign category to be duplicated\n category_to_duplicate = Category.find(params[:duplicate_category])\n #set @category to duplicated info minus id\n @category = category_to_duplicate.dup\n if(!@category.parent_id.nil?)\n @items_to_select = [Category.find(@category.parent_id)]\n else\n @item_to_select = nil\n end\n\n else\n #New category\n @category = Category.new\n\n if(!params[:category_id].nil?)\n @items_to_select = [Category.find(params[:category_id])]\n else\n for ac in @all_categories\n if(ac.parent_id.nil?)\n # @items_to_select = [ac]\n end\n end\n end\n end\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @category }\n end\n end", "def contract_category_collection_for_select_options(contract=nil)\n categories = ContractCategory.shared.active\n\n collection = []\n if contract && contract.category && !contract.category.active?\n collection << [ \"--- #{l(:actionview_instancetag_blank_option)} ---\", '' ]\n else\n collection << [ \"--- #{l(:actionview_instancetag_blank_option)} ---\", '' ] unless categories.detect(&:is_default)\n end\n categories.each { |a| collection << [a.name, a.id] }\n collection\n end", "def index\n if @main_category.nil?\n @categories = Category.where(:parent_id => nil).order('title')\n else\n @categories = @main_category.children\n end\n selected_category_id = params[:selected_category_id]\n if !selected_category_id.blank?\n @category = Category.find(selected_category_id)\n @ancestors_for_current = @category.ancestors.collect{|c| c.id.to_i} + [@category.id.to_i]\n end\n respond_to do |format|\n format.html { render :partial => 'select_index', :locals => {:categories => @categories} if request.xhr? }\n format.xml { render :xml => @categories }\n end\n end", "def categories\n category\n end", "def options_for_select_for_cities\n options_for_select(City.all.collect {|c| [c.name, c.id]} << [\"All Locations\", \"0\"])\n end", "def categories options = {}\n perform_get_with_object(\"/categories\", options, Vimeo::Entities::Category)\n end", "def all_selectable_materials\n categories = Category.order(\"depth ASC \")\n \n # MATERIAL = {\n # :steel => {\n # :value => 1, \n # :name => \"Steel\" \n # } ,\n # :copper => {\n # :value => 2, \n # :name => \"Tembaga\"\n # }, \n # :alumunium => {\n # :value => 3, \n # :name => \"Aluminium\"\n # }\n # }\n # \n \n result = []\n MATERIAL.each do |material| \n result << [ \"#{category.name}\" , \n category.id ] \n end\n return result\n end", "def set_category_option\n @category_option = CategoryOption.find(params[:id])\n end", "def index\n @category = Category.new\n \n @categories = Category.find_all_by_parent_id(nil)\n @parent_categories_options = get_category_options_array \n @default_parent_option = \"\"\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @categories }\n end\n end", "def categories\n add_to_query restrict_kind: 'category'\n end", "def get_categories\n cats = []\n params.each do |k,v|\n if k.starts_with? \"category\"\n name = v\n num = cat_number(k) \n cats << [name,num]\n end\n end\n return cats\n end", "def fill_subcategory\n @select_data = Subcategory.ordered_by_category params[:category_id]\n end", "def set_categories\n @categories = Category.all\n end", "def category_enum\n Category.all.collect {|p| [ p.name, p.id ] }\n end", "def search_for_products\r\n @categories = Category.select(:id, :name).all\r\n end", "def initialize(category_options={})\n @id = category_options[\"id\"]\n @name = category_options[\"name\"]\n end", "def set_categories\n\t\t@categories = Category.all\t\n\tend", "def categories(params={})\n return @categories if (@categories && !params[:force])\n @categories = get_categories\n end", "def get_categories\n @categories = Category.all\n end", "def categories\n []\n end", "def multiple_categories\n @categories = Category.all\n end", "def selector_options sort_order = nil\n self.sort_order = sort_order if sort_order\n\n # options_hash - retrieved from YAML file\n list = options_hash.inject([]) do |res, option| \n select_option = calculator(option).select_option\n res << select_option\n res\n end\n end", "def list\n categories = Meal.distinct.pluck(:category)\n meal_list = []\n categories.each { |category|\n obj = {\n groupName: category.capitalize,\n options: Meal.where(category: category).select(:id, :name)\n }\n meal_list.push(obj)\n }\n\n render json: meal_list\n end", "def getCategories\n @categories = []\n @categories << Category.new(name: \"All\", id: -1)\n @categories += Category.all\n end", "def all_categories\n end", "def set_lectures\r\n @category = Category.find(params[:category_id])\r\n end", "def categories=(value)\n @categories = value\n end", "def indent_child_options_for_parent_category_select(category, parent, child_indent = \"&nbsp;&nbsp;&nbsp;\")\n html_code = \"\"\n parent.children.each do |child|\n options = {:value => child.id}\n options = options.merge({:selected=>\"selected\"}) if child == category.parent\n html_code += tag(\"option\", options, true) + child_indent + child.name + \"</option>\" + indent_child_options_for_parent_category_select(category, child, child_indent + child_indent) unless child==category\n end\n html_code\n end", "def categories\n return @categories\n end", "def categories\n return @categories\n end", "def categories\n return @categories\n end", "def edit\n @product = Product.find(params[:id])\n\n # Retrieve the categories to display in the caterogy filter dropdown\n @all_categories = Category.where(parent_id: nil).order(:name)\n end", "def items_for_select_menu(options = {}) \n # clean out the various parts\n html_options = options.slice(:prompt, :divider, :show_root, :root_text)\n sql_options = options.except(:prompt, :divider, :show_root, :root_text)\n \n # defaults\n html_options = {\n :prompt => \"Select #{self.name}\",\n :divider => true,\n :show_root => true,\n :root_text => \"Top Level #{self.name}\",\n }.merge(html_options)\n \n sql_options = {\n :order => [self.select_field.to_sym],\n }.merge(sql_options)\n \n mi = self.select_options[:is_tree] ? all({ :parent_id => nil }.merge(sql_options) ) : all(sql_options)\n \n res = []\n if html_options[:prompt]\n res << [nil, html_options[:prompt]] \n res << ['nil', \" ------ \"] if html_options[:divider]\n if self.select_options[:is_tree]\n if html_options[:show_root]\n res << [0, html_options[:root_text]] \n res << ['nil',\" ------ \"] if html_options[:divider]\n end\n end\n end\n \n if self.select_options[:is_tree]\n mi.each do |x|\n res << [x.send(self.value_field), x.send(self.select_field)]\n unless x.children.blank?\n x.children.each do |child|\n res << [child.send(self.value_field), \"-- #{child.send(self.select_field)}\"]\n child.children.each do |grand_child| \n res << [ grand_child.send(self.value_field), \"-- -- #{grand_child.send(self.select_field)}\"] \n end unless child.children.blank?\n end\n end\n end\n else\n mi.each do |x|\n res << [x.send(self.value_field), x.send(self.select_field)]\n end\n end\n res\n end", "def edit\n # populates the category with the existing category assigned\n @categories = Category.all.map{ |c| [c.name, c.id] }\n end", "def index\n @kinds = Kind.create_select_options\n end", "def category_names\n self.categories.map do |category|\n category.name\n end\n end", "def form_tr_select_cat_from_tree(form, obj, root, name, col, id, display_name, selected_obj, *args)\n options = args.extract_options!\n out = ''\n out += '<tr><td class=\"label\">'\n out += form.label col.to_sym, name\n out += ' : </td>'\n out += '<td class=\"field\">'\n out += select_cat_from_tree(obj, col, root, selected_obj, options)\n out += '</td></tr>'\n return out\n end", "def category_selection(category)\n category = Public_apis.find_by_name(category)\n #goes over list item array . find method to find item\n\n \n end", "def category_list_builder\n categories = API.get_categories\n categories.each do |cat|\n Category.new(cat)\n end\n end", "def categories(options = {})\n options = options.merge(:facets => 'category', :facet_num_results => 100, :num_results => 0)\n search('*:*', options).facets['category'].values\n end", "def creatorship_options\n\t\th.options_for_select(self.creator_categories.pluck(:name, :id))\n\tend", "def set_category\n @categories = Category.find(params[:id])\n end", "def categories\n return @categories\n end", "def selected_categories\n list = []\n @browser.div(:id=>\"assignlocation_jstree_selected_container\").lis.each do |li|\n list << li.text\n end\n return list\n end", "def set_courses_category\n @courses_categories = Course.order(:name).pluck(:name, :id)\n end", "def categories\n Category.position_sorted\n end", "def to_categories(sub_context)\n Array(sub_context).map { |id|\n categories[id] \n }.compact\n end", "def show\n\t\t@category = Category.find(params[:id])\n\t\t@sub_categories = @category.sub_categories\n\tend", "def select_options\n all.map {|e| [e.name, e.to_s] }\n end", "def select_options\n all.map {|e| [e.name, e.to_s] }\n end", "def populate_category\n\t\t\t\tif params[:purpose] == \"category\"\n\t\t\t\t\t\tcategory = Category.find(params[:category_id])\n\t\t\t\t\t\t@sub_categories = category.sub_categories\n\t\t\t\telsif params[:purpose] == \"sub_category\"\n\t\t\t\t\t\tsub_category = SubCategory.find(params[:category_id])\n\t\t\t\t\t\t@inner_categories = sub_category.inner_categories\n\t\t\t\tend\n\t\tend", "def categories\n return [] if @categories.blank?\n @categories.records.map {|c| c.display_name}\n end", "def categories=(value)\n @categories = value\n end", "def categories=(value)\n @categories = value\n end", "def categories=(value)\n @categories = value\n end", "def get_products_colletion_select\n model = self.controller_name.singularize\n collection_select model, :product_ids, Product.find(:all), :id, :name, { }, { :multiple => true, :size => '10', :style => \"width:240px\" }\n end", "def set_categories\r\n @categories = Category.where('courses_count > 0').order(:name)\r\n end", "def getCategories(_, _, _)\n @db.categories\n end", "def language_options_for_select\n LanguageDictionary.instance.options_for_select\n end", "def categories\n category_keys.collect(&:to_s)\n end", "def find_categories(options = {})\n @language_permalink = options[:language_permalink]\n if @language_permalink\n options.delete(:language_permalink)\n Syntaxdb::Request.send_request(options, \"/languages/#{@language_permalink}/categories\")\n end\n end", "def set_all_categories\n @all_categories = Category.all.order_by_name\n end", "def category_menu_items(aRootCategory, aOptions={})\n\t\t\taBaseUrl = (aOptions[:base_url] || '')\n\t\t\taIdPrefix = (aOptions[:id_prefix] || '')\n\t\t\tcategory = aOptions[:category]\n\t\t\tcategory = category.name.urlize('+') if category.is_a?(Category)\n\t\t\ttree_nodes = construct_category_tree(aRootCategory)\n\t\n\t\t\t# now turn tree_nodes into menu items, still as array of levels\n\t\t\ttree_items = []\n\t\t\tlast_lvl = nil\n\t\t\ttree_nodes.each do |lvl|\n\t\t\t\titem_level = []\n\t\t\t\tlvl.each do |node|\n\t\t\t\t\tname = (node.name.index('/') ? File.basename(node.name) : node.name)\n\t\t\t\t\titem = {:id => aIdPrefix+node.id.to_s, :name => name }\t\n\t\t\t\t\titem[:node] = node\n\t\t\t\t\tif last_lvl && parent_item = last_lvl.find {|i| i[:node].id == node.parent_id}\n\t\t\t\t\t\tparent_item[:children] ||= []\n\t\t\t\t\t\tparent_item[:children] << item\n\t\t\t\t\t\titem[:url] = parent_item[:url]\n\t\t\t\t\t\titem[:url] += '+' unless item[:url]=='' || item[:url].ends_with?('/') || item[:url].ends_with?('+')\n\t\t\t\t\t\titem[:url] += name.urlize('-')\n\t\t\t\t\telse\n\t\t\t\t\t\titem[:url] = File.join(aBaseUrl,name.urlize('-'))\n\t\t\t\t\tend\n\t\t\t\t\t\n\t\t\t\t\titem[:selected] = true if category && (category==node.name.urlize('+'))\n\t\t\t\t\titem[:order] = aOptions[:order_proc].call(item) if aOptions.has_key?(:order_proc)\n\t\t\t\t\titem_level << item\n\t\t\t\tend\n\t\t\t\ttree_items << item_level\n\t\t\t\tlast_lvl = item_level\n\t\t\tend\n\t\t\t# clean\n\t\t\ttree_items.each do |lvl|\n\t\t\t\tlvl.each do |i| \n\t\t\t\t\ti.filter_include!([:url,:selected,:id,:name,:children,:order])\n\t\t\t\t\ti[:children].sort! {|a,b| a[:order].to_i <=> b[:order].to_i} if i[:children].is_a?(Array)\n\t\t\t\tend\n\t\t\tend\n\t\t\ttree_items.first.sort! {|a,b| a[:order].to_i <=> b[:order].to_i}\n\t\t\ttree_items.first\n\t\tend", "def show\n @categories = Category.order(\"name ASC\")\n end", "def index\n\n @cat_first = ProductCategory.level_one_cats\n\n @selected_cat_one = \"\"\n @selected_cat_two = \"\"\n @selected_cat_three = \"\"\n @selected_cat_one_name = \"\"\n @selected_cat_two_name = \"\"\n @selected_cat_three_name = \"\"\n @cat_second = nil\n @cat_third = nil\n \n @products = Product.all\n\n cat_params = params[\"category\"]\n\n if cat_params != nil\n if cat_params[\"selected_cat_one\"] != nil && cat_params[\"selected_cat_one\"] != \"\"\n @selected_cat_one = cat_params[\"selected_cat_one\"]\n @products = @products.level_one_products(@selected_cat_one)\n @cat_second = ProductCategory.level_two_cats(@selected_cat_one)\n @select_cat_one_name = ProductCategory.where( \"id = ?\", @selected_cat_one.to_i).first.name\n logger.debug \"selected cat one name: #{@select_cat_one_name} second level categories: #{@cat_second.inspect}\"\n end\n if cat_params[\"selected_cat_two\"] != nil && cat_params[\"selected_cat_two\"] != \"\"\n @selected_cat_two = cat_params[\"selected_cat_two\"]\n @products = @products.level_two_products(@selected_cat_two)\n @cat_third = ProductCategory.level_three_cats(@selected_cat_two)\n @select_cat_two_name = ProductCategory.where( \"id = ?\", @selected_cat_two.to_i).first.name\n logger.debug \"third level categories: #{@cat_third.inspect}\"\n end\n if cat_params[\"selected_cat_three\"] != nil && cat_params[\"selected_cat_three\"] != \"\"\n @selected_cat_three = cat_params[\"selected_cat_three\"]\n @products = @products.level_three_products(@selected_cat_three)\n @select_cat_three_name = ProductCategory.where( \"id = ?\", @selected_cat_three.to_i).first.name\n logger.debug \"third level categories: #{@cat_third.inspect}\"\n end\n end\n end", "def category_names\n @category_names || categories.map(&:name).join(' ')\n end", "def all_categories\n\t\t@categories = Category.all\n\tend", "def edit\n # checking if the user has the ability to modify if not error\n # redirect_to root_path, alert: \"Access denied.\" unless can? :edit, @post\n @category_options = Category.all.map{|u| [u.title, u.id]}\n end", "def categories\n\t\trender :json => {:status => 1, :categories => {\"1\" => \"Apparel & Accessories\", \"2\" => \"Arts and Crafts\", \"3\" => \"Electronics\", \n\t\t\t\"4\" => \"Home Appliances\", \"5\" => \"Kids & Baby\", \"6\" => \"Movies, Music, Books & Games\", \"7\" => \"Motor Vehicles\", \n\t\t\t\"8\" => \"Office & Education\", \"9\" => \"Parties & Events\", \"10\" => \"Spaces & Venues\", \"11\" => \"Sports & Outdoors\", \"12\" => \"Tools & Gardening\", \"13\" => \"Other\"}}, :status => 200\n\t\treturn\n\tend", "def chosen_options\n Option.find_all_by_id session[:chosen_options]\n end", "def set_category\n @categories = Category.friendly.find(params[:id])\n end", "def categories=(categories)\n @categories = categories\n end", "def tag_select_cat_from_tree(obj, root, col, id, display_name, selected_obj, *args)\n options = args.extract_options!\n out = ''\n out += select_cat_from_tree_for_tag(obj, col, root, selected_obj, options)\n return out\n end", "def category_names\n categories.map {|category| CategoryCode[category]}\n end", "def categories=(value)\n\t\t@categories = value\n\tend", "def categories=(value)\n\t\t@categories = value\n\tend", "def categories=(value)\n\t\t@categories = value\n\tend" ]
[ "0.7796857", "0.77922636", "0.7529909", "0.75153494", "0.7115543", "0.6840263", "0.68027747", "0.66743714", "0.6530413", "0.6508157", "0.6504777", "0.6503056", "0.64708847", "0.6403975", "0.6292927", "0.6205291", "0.6193125", "0.6134755", "0.6130949", "0.6122616", "0.60541445", "0.6043054", "0.60231227", "0.6021201", "0.6016845", "0.6013981", "0.6013557", "0.6012731", "0.6010735", "0.59950686", "0.59786737", "0.5969583", "0.59491014", "0.59280264", "0.5919567", "0.5896925", "0.58904225", "0.5876942", "0.5875854", "0.58647424", "0.58436716", "0.5837174", "0.5834481", "0.58256364", "0.5809602", "0.5805534", "0.5803404", "0.579698", "0.57920694", "0.5785456", "0.5773722", "0.5766572", "0.5760487", "0.5760487", "0.5760487", "0.5760253", "0.57534236", "0.5752128", "0.57503814", "0.5746022", "0.57393146", "0.5735332", "0.5726388", "0.57243025", "0.5718303", "0.5717957", "0.56968564", "0.5683879", "0.56780106", "0.56772584", "0.56698626", "0.56691706", "0.5665805", "0.5665805", "0.56564015", "0.5655092", "0.5649362", "0.5649362", "0.5649362", "0.56361544", "0.5631411", "0.56284934", "0.56256384", "0.5623967", "0.56141263", "0.56128305", "0.5609187", "0.5608885", "0.5599781", "0.5597268", "0.5588404", "0.5581887", "0.5573514", "0.55713916", "0.5563163", "0.5554911", "0.5551393", "0.55464494", "0.5543189", "0.5543189", "0.5543189" ]
0.0
-1
Main entry point Requires a Time object and a parameter Hash, currently :format Returns an array of sound files with the requested output Example: sound_files_for_time(Time.now, format: "dMYaHm" format: h: 12h hour H: 24h hour m: minutes s: seconds d: day in number w: weekday name M: month name Y: year as "twenty twelve" p: AM or PM indicator a: the "at" word
def sounds_for_time(time, args={}) format = args.delete(:format) || 'dMYaHm' result = [] format.each_char do |c| result += send("parse_#{FORMAT_TABLE[c]}".to_sym, time) end result end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def run\n file = \"english.srt\"\n times = parse_times file\n build_ffmpeg times, file\nend", "def file_for_day(day)\n sound_path(\"day-#{day}.ul\")\n end", "def collectFileInformation(tracks, flavor, startTimes, real_start_time)\n startTimes.each do |file|\n pathToFile = File.join(file[\"filepath\"], file[\"filename\"])\n\n BigBlueButton.logger.info( \"PathToFile: #{pathToFile}\")\n\n if (File.exists?(pathToFile))\n # File Integrity check\n if (!FFMPEG::Movie.new(pathToFile).valid?)\n BigBlueButton.logger.info( \"The file #{pathToFile} is ffmpeg-invalid and won't be ingested\")\n next\n end\n\n tracks.push( { \"flavor\": flavor,\n \"startTime\": file[\"timestamp\"] - real_start_time,\n \"path\": pathToFile\n } )\n end\n end\n\n return tracks\nend", "def call\n files.each do |file|\n parts = parse_filename(file)\n build_song(parts)\n end \n end", "def parse_at(time)\n [sound_path(\"at.ul\")]\n end", "def speakIntoFiles(spanishText, germanText, englishText)\n @spanishText = spanishText\n @germanText = germanText\n @englishText = englishText\n\n\n readingSpeedES = 140\n readingSpeedDE = 180\n readingSpeedEN = 140\n\n spanishVoice = \"Jorge\"\n germanVoice = \"Markus\"\n englishVoice =\"Susan\"\n\n # we set the character length of the file name\n # languageFileDE = \"#{germanText[0,55]}\"\n languageFileES = \"#{spanishText[0,20].chomp}\"\n languageFileEN = \"#{englishText[0,20].chomp}\"\n languageFileDE = \"#{germanText[0,20].chomp}\"\nputs `say -v #{spanishVoice} -r #{readingSpeedES} \"#{spanishText}\" -o \"#{languageFileES}\".aif`\nputs `say -v #{germanVoice} -r #{readingSpeedDE} \"#{germanText}\" -o \"#{languageFileDE}\".aif`\nputs `say -v #{englishVoice} -r #{readingSpeedEN} \"#{englishText}\" -o \"#{languageFileEN}\".aif`\nend", "def display_time (*args)\n t = Time.now\n format = \"\"\n def add_comma(format, chars)\n if format == \"\"\n return chars\n else\n return format + \", \" + chars\n end\n end\n\n if !args\n puts t.strftime(\"%A, %B, %d, %Y at %I:%M%p\")\n else\n if args.include?(:day_of_week)\n format = add_comma(format, \"%A\")\n end\n if args.include?(:month)\n format = add_comma(format, \"%B\")\n end\n if args.include?(:day)\n format = add_comma(format, \"%d\")\n end\n if args.include?(:year)\n format = add_comma(format, \"%Y\")\n end\n if args.include?(:time)\n format = add_comma(format, \"at %I:%M%p\")\n end\n puts t.strftime(format)\n end\nend", "def list_anat_files(options = {}) \n subs = all_subjects\n filt_subs = looked_for(options[:subjects])\n filt_sess = looked_for(options[:sessions])\n filt_types = looked_for(options[:t_types] || [ \"T1\", \"T2\" ]) \n scans_list = all_scans(subs, filt_subs, filt_sess, filt_types) \n results = []\n scans_list.each do |scan_dir|\n resources_path = \"#{scan_dir}/Resources\"\n scanlist_type = list_files(\"#{resources_path}\", :directory).map { |e| Pathname.new(e.name).basename.to_s }\n scanlist_type.each do |scan_type|\n scanlist = list_files(\"#{resources_path}/#{scan_type}/Files\", :regular).map { |e| Pathname.new(e.name).basename.to_s }\n if (! options[:ext].blank?) && options[:ext].is_a?(Regexp)\n scanlist = scanlist.select { |scan| scan.match(options[:ext]) }\n end\n scanlist.each { |scan| results << \"#{resources_path}/#{scan_type}/Files/#{scan}\" }\n end \n end\n results\n end", "def alejandro1\n # Variable creation.\n # Data structure (way of storing data): List\n notes = [:b4, :b4, :b4, :d4, :e4, :fs4, :fs4, :e4,\n :fs4, :fs4, :fs4, :cs4, :cs4, :cs4, :cs4] # :r is rest.\n \n durations = [0.5, 0.25, 0.25, 0.5, 0.5, 0.5, 1, 0.5,\n 0.5, 0.5, 0.5, 0.5, 0.5, 1, 0.5]\n \n play_pattern_timed notes, durations\nend", "def alarm \n \n#greeting \t\nputs \"Ready Steady Go\"\n\n#user input/converting to an integer \nputs \"Start you clock: Input Hour (from 1-12) and press enter\"\nhour = gets.chomp.to_i\nputs \"Input minutes and press enter\"\nmin = gets.chomp.to_i\n#setting the index to 0 \ni = 0\nhour += 12\n\ncurrent_time = DateTime.now\nsetTime = DateTime.new(2021,10,8, hour, min)\n\ncurrent_time.strftime \"%H:%M\"\nsetTime.strftime \"%H:%M\"\n\n\tif min < 13\n\t\tputs \"Crunch-Time set for #{hour}:0#{min}\"\n\telse\n\t\tputs \"Crunch-Time set for #{hour}:#{min}\"\n\tend\n#loop for the the alarm sound function. Loop will end after 1 rotation of the code\nwhile i < 1\n\t#gem\n\tcurrent_time = DateTime.now\n\tcurrent_time.strftime \"%H:%M\"\n\t#setting paramiters \n if (current_time.strftime \"%H:%M\") == (setTime.strftime \"%H:%M\")\n\t\t#execution for the mp3 audio. \n\t\tpid = fork{ exec 'afplay', \"sound.mp3\"}\n\t\tputs \"Al' here, how did you go? Have a break and lets do it all again. Otherwise, scroll down to Exit\"\n\t\ti+=1\n end \n end \nend", "def create2#timeSpeed is either a start time or a speed.\n `cd C:/Users/Craig/rubys && md file`\n file = params[:file]\n if file\n file +=\".wav\"\n end\n speed = params[:speed]\n time = params[:time]\n time2 = params[:time]\n file2 = params[:file2]\n if file2\n file2 +=\".wav\"\n end\n if speed\n make_file \"#{file}\", nil, \"#{speed}x#{file[0..file.length-4]}1.wav\", \"sox #{file} #{speed}x#{file[0..file.length-4]}1.wav speed #{speed}\"\n elsif time2\n make_file \"#{file}\", nil, \"#{file[0..file.length-4]}1.wav\",\"sox #{file} #{file[0..file.length-4]}1.wav trim #{time} #{time2}\"\n elsif time\n make_file \"#{file}\", \"#{file2}\", \"#{file[0..file.length-4]+ file2[0..file2.length-4]}1.wav\", \"sox #{file} -p pad #{time} 0 | sox - -m #{file2} #{file[0..file.length-4]+ file2[0..file2.length-4]}1.wav\"\n elsif file2\n make_file \"#{file}\", \"#{file2}\", \"#{file[0..file.length-4] +'and'+file2[0..file2.length-4]}1.wav\", \"sox #{file} #{file2} #{file[0..file.length-4] +'and'+file2[0..file2.length-4]}1.wav\"\n else\n make_file \"#{file}\", nil, \"#{file[0..file.length-4].reverse}1.wav\",\"sox #{file} #{file[0..file.length-4].reverse}1.wav reverse\"\n end\n end", "def alejandro1\n # Variable creation.\n # Data structure (way of storing data): List\n notes = [:b4, :b4, :b4, :d4, :e4, :fs4, :fs4, :e4,\n :fs4, :fs4, :fs4, :c4, :c4, :c4, :c4] # :r is rest.\n \n durations = [0.5, 0.25, 0.25, 0.5, 0.5, 0.5, 1, 0.5,\n 0.5, 0.5, 0.5, 0.5, 0.5, 1, 0.5]\n \n play_pattern_timed notes, durations\nend", "def time(*args)\n @contents << \"\\\\time #{args[0..1].join(\"/\")}\"\n end", "def generate_time\n\t\tret = Array.new\n\t\tcount unless @fileinfo[:count]\n\t\ttrigger unless @fileinfo[:trigger]\n\t\tsampling unless @fileinfo[:sampling]\n\n\t\t(0..@fileinfo[:count] - @fileinfo[:trigger] - 1).each {|i| \n\t\t\tret << (i * @fileinfo[:sampling] * 1e-6)\n\t\t}\n\t\treturn ret\n\tend", "def time(subject)\n day = DateTime.now.strftime('%Y%m%d')\n second = now\n file = \"#{@dir}/#{day}-track.yml\"\n if File.exists? file\n yml = YAML.load_file file\n last_entry = nil\n yml.each do |time,info|\n last_entry = time unless last_entry\n if Time.parse(time) > Time.parse(last_entry)\n last_entry = time\n end\n end\n lenght = Time.parse(second) - Time.parse(last_entry)\n yml[last_entry]['lenght'] = lenght\n yml[second] = Hash.new\n yml[second]['subject'] = subject\n yml[second]['lenght'] = nil\n f = File.open(file, 'w')\n f.write yml.to_yaml\n f.close\n else\n puts subject\n yml = Hash.new\n yml[second] = Hash.new\n yml[second]['subject'] = subject\n yml[second]['lenght'] = nil\n f = File.open(file, 'a')\n f.write yml.to_yaml\n f.close\n end\n end", "def runtime\n TagLib::MPEG::File.open(@filename) do |file|\n t = file.audio_properties.length\n mm, ss = t.divmod(60)\n hh, mm = mm.divmod(60)\n dd, hh = hh.divmod(24)\n\n [hh, mm, ss].map{|t| \"%02d\" % t}.join(':')\n end\n end", "def time( time = birth )\n # Check to be sure time is a valid Time object\n raise RuntimeError, 'Invalid Time' unless time.instance_of? Time\n\n show_day = time.strftime( '%a' )\n show_time = '2000' # Defaults to 8PM\n\n # Friday is a 9:00 PM show\n show_time = '2100' if time.wday == 5\n\n # Saturday after 10 PM file creation is 10:30 PM show\n if ( time.wday == 6 && time.hour >= 22 ) || ( time.wday == 0 && time.hour <= 2 )\n show_day = 'Sat'\n show_time = '2230'\n end\n\n # Return the day-time string\n show_day + '-' + show_time\n end", "def parse_am_pm(time)\n time.strftime(\"%P\") == \"am\" ? [sound_path(\"a-m.ul\")] : [sound_path(\"p-m.ul\")]\n end", "def files\n # list_of_filenames = Dir.entries(path)\n @list_of_filenames = Dir.glob(\"#{@path}/*.mp3\").collect! {|x| x.gsub(\"#{@path}/\", \"\") }\n # binding.pry\n end", "def audio_format(infile)\n format = nil\n cmd = [\"ffprobe\", \"-hide_banner\", infile]\n \n IO.popen(cmd, \"rb\", :err=>[:child, :out]) do |io| \n io.each_line do |line|\n # Stream #0:1: Audio: aac (LC), 22050 Hz, stereo, fltp\n # Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 95 kb/s\n # Stream #0:0: Audio: mp3, 22050 Hz, mono, s16p, 67 kb/s\n # Stream #0:1: Audio: mp3 (U[0][0][0] / 0x0055), 44100 Hz, stereo, s16p, 310 kb/s\n if line =~ /Stream.+Audio.+(aac|mp3)/\n format = $1\n break\n end\n end\n end\n\n case format\n when nil\n \"\"\n when \"aac\" \n \"m4a\"\n else\n format\n end\nend", "def parse\n result = []\n files = []\n \n @paths.each { |path|\n begin\n raise FileNotFoundError unless File.exists?(path)\n \n if File.directory?(path) then\n files += Dir.glob(\"#{path}/**/*.mid\")\n else\n files << path if File.extname(path) == \".mid\"\n end\n rescue\n puts \"Not a valid file path : #{path} => #{$!}\"\n end\n }\n \n \n if files.empty? then\n puts \"No files were added.\"\n else\n files.each { |file_path|\n result << read_midi(file_path)\n }\n end\n \n return result\n end", "def list_files\n @synth_files = CreatedFile.find_all_by_content_type(\"synthesis\",\n :include => :researcher, \n :order => \"created_at DESC, created_file DESC\")\n end", "def files\n filename = Dir.entries(@path).find_all {|file| file.include?(\".mp3\")}\n # binding.pry\n # [[\"Thundercat - For Love I Come - dance.mp3\",\n # \"Real Estate - It's Real - hip-hop.mp3\",\n # \"Action Bronson - Larry Csonka - indie.mp3\",\n # \"Real Estate - Green Aisles - country.mp3\"]]\n\n #binding.pry\n end", "def setTime\n if self.exists && File.writable?(\".\")\n nFile = File.new(\"timed_#{@filename}\", \"w+\")\n \n self.play\n \n puts \"Press enter every time the next lyric should show up!\\n\"\n \n @file.each {\n |line|\n charPrint(line)\n getTime(line, nFile)\n }\n\n nFile.close\n @file.rewind\n end\n end", "def time_entries(options = {})\n entries = []\n time_invested(options).groups.each { |g| entries << g[\"time_entries\"] }\n\n process_list_response( entries.flatten , Unfuddled::TimeEntry )\n end", "def parse_weekday(time)\n [file_for_day(time.strftime(\"%w\"))]\n end", "def analise_audio\n ads_file_paths = []\n videos_with_ads_from_files = []\n\n Find.find('.') do |path|\n if path =~ /.*-ads\\.wav$/\n $file_name = ads_file_paths << path[2..-1].to_s\n end\n end\n if !$file_name.nil?\n videos_with_ads_from_files.push(\"'#{$file_name}': 'true'\")\n puts \"List of audio files with ads based on file names #{videos_with_ads_from_files[0]}\"\n end\n\n if $file_name.nil?\n puts 'No audio files with ads found'\n end\n #another way how we can check if ads displayed\n #here we can get a length of audio file in seconds by `sox file_name.wav -n stat 2>&1| grep 'Length'| awk '{print $3}'\n #if ads were displayed length of audio file will be like ads.length + original_video.length in seconds\n #if total audio file length > then RECORD_TIME in seconds it means that audio file contains ads\nend", "def file_choices \r\n puts \"You have the following file choices:\"\r\n list_of_files = Dir[\"*.wav\"]\r\n puts \" #{list_of_files}\"\r\n @file_to_play = user_input \"\\nWhich file would you like to play?\\n\"\r\nend", "def load_raw_sounds(kit_items)\n raw_sounds = {}\n kit_items.values.flatten.each do |sound_file_name|\n begin\n wavefile = WaveFile.open(sound_file_name)\n rescue Errno::ENOENT\n raise SoundFileNotFoundError, \"Sound file #{sound_file_name} not found.\"\n rescue StandardError\n raise InvalidSoundFormatError, \"Sound file #{sound_file_name} is either not a sound file, \" +\n \"or is in an unsupported format. BEATS can handle 8 or 16-bit *.wav files.\"\n end\n @num_channels = [@num_channels, wavefile.num_channels].max\n raw_sounds[sound_file_name] = wavefile\n end\n \n return raw_sounds\n end", "def get_time(infile)\n DateTime.strptime(File.basename(infile).split('.')[1, 2].join('.') + '+0', '%y%j.%H%M%z')\n end", "def format_time\n hours = format_hour @hour\n minutes = format_minute @minutes\n ampm = @hour < 12 ? @@ampm_hash['a'] : @@ampm_hash['p']\n time = ''\n time += hours[0] + minutes[0] + ' ' + ampm[0] + \"\\n\"\n time += hours[1] + minutes[1] + ' ' + ampm[1] + \"\\n\"\n time += hours[2] + minutes[2] + ' ' + ampm[2] + \"\\n\"\n time\n end", "def load_showtimes\n available_times = {\n 10.45 => \"10:45am\", 11.00 => \"11:00am\", 11.15 => \"11:15am\", 11.30 => \"11:30am\",11.45 => \"11:45am\", 12.00 => \"12:00pm\", 12.15 => \"12:15pm\", 12.30 => \"12:30pm\", 12.45 => \"12:45pm\", \n 13.00 => \"1:00pm\", 13.15 => \"1:15pm\", 13.30 => \"1:30pm\",13.45 => \"1:45pm\",14.00 => \"2:00pm\",14.15 => \"2:15pm\",14.30 => \"2:30pm\", 14.45 => \"2:45pm\", 15.00 => \"3:00pm\",15.15 => \"3:15pm\",16.00 => \"4:00pm\", 16.15 => \"4:15pm\", 16.30 => \"4:30pm\", 16.45 => \"4:45pm\", 17.00 => \"5:00pm\",17.15 => \"5:15pm\", 17.30 => \"5:30pm\",17.45 => \"5:45pm\",18.00 => \"6:00pm\", 18.15 => \"6:15pm\", 18.30 => \"6:30pm\", 18.45 => \"6:45pm\", 19.00 => \"7:00pm\", 19.15 => \"7:15pm\", 19.30 => \"7:30pm\", 19.45 => \"7:45pm\", 20.00 => \"8:00pm\", 20.15 => \"8:15pm\", 20.30 => \"8:30pm\", 20.45 => \"8:45pm\", 21.00 => \"9:00pm\", 21.15 => \"9:15pm\", 21.30 => \"9:30pm\", \n 22.00 => \"10:00pm\", 22.15 => \"10:15pm\", 22.30 => \"10:30pm\", 22.45 => \"10:45pm\", 23.00=> \"11:00pm\", 23.15 => \"11:15pm\", \n 23.30 => \"11:30pm\", 23.45 => \"11:45pm\",24.00 => \"12:00am\"}\n\n\n\n showtimes = [10.45]\n\n if self.runtime >= 1.33 && self.runtime <= 1.5\n showtimes << 12.30 << 14.00 << 15.30 << 17.00 << 18.30 << 20.00 << 21.30 << 23.00\n\n elsif self.runtime >= 1.5 && self.runtime <= 2 \n showtimes << 13.00 << 15.00 << 17.00 << 19.00 << 21.00 << 23.00 << 24.00\n\n elsif self.runtime >= 2 && self.runtime <= 3\n showtimes << 14.15 << 17.15 << 21.15 << 24.00\n end \n\n\n\n showtimes.map! do |time|\n time = Showing.create!(military_time: time.to_f, time_string: available_times[time], movie: self)\n end\n\n self.showings = showtimes\n end", "def read_all_dates(src_path) \n hash = {}\n read_pics_filenames(src_path).each { |pic| hash[pic] = read_pic_date(pic).to_f } \n return hash\nend", "def sounds_list(params = {})\n get \"sounds\", params\n end", "def time_all (path1, estimate)\n\tf = File.open('timing_results.txt', 'w')\n\ttotal = 0 #total time \n#loop over the files\n\tDir.glob(path1).each do |docpath|\n#Create a Docx::Document object for our existing docx file\n\t\tif(docpath.to_s.scan(/th/).size > 0)\n\t\t\tdoc = Docx::Document.open(docpath)\n\t\t\tf.puts(docpath)\n\t\t\tb = time_file(doc, estimate)\n\t\t\tb.each {\n\t\t\t\t|key, value| \n\t\t\t\tif(key==\"[Next]\")\n\t\t\t\t\tf.puts \"Total of #{value/6} #{key} taking #{value} seconds\"\n\t\t\t\telse\n\t\t\t\t\tf.puts \"Total of #{value/estimate} #{key} taking #{value} seconds\"\n\t\t\t\tend\n\t\t\t}\n\t\t\tf.puts \"Total Script Time : \" + b.values.inject(:+).to_s + \" (seconds)\" #sum of times [Next], [Submit], etc. in seconds\n\t\t\ttotal += b.values.inject(:+)\n\t\t\tf.puts\n\t\tend\n\tend\n\n\tf.puts \"\\nOverall Lesson Time : \" + total.to_s + \" (seconds)\"\n\tf.close\nend", "def build_filelist(source_file, rule_name)\n basename = source_file.pathmap('%n') # base name without ext\n prefix = \"#{CONF[\"project\"]}-#{rule_name}--#{basename}\"\n src_lines = File.readlines(source_file)\n\n filelist = {\n source: source_file,\n mp3: \"#{DIR[:mp3]}/#{prefix}.mp3\",\n compile: \"#{DIR[:compile]}/#{prefix}.wav\",\n concat: 1.upto(src_lines.size).map { |n| \"#{DIR[:concat]}/#{prefix}--#{'%04d' % n}.wav\" },\n raw: [],\n say_args_by_raw: {},\n movie_concat: \"#{DIR[:movie]}/CONCAT_#{prefix}.txt\",\n movie: \"#{DIR[:movie]}/#{prefix}.mp4\",\n movie_pics: [],\n app_sounds: [],\n }\n\n\n field_voice = CONF['field'].to_a\n src_lines.each_with_index do |line, line_index|\n line.chomp!\n\n raw_by_field = {}\n line.split(/\\t/).each_with_index do |content, index|\n field, voice = field_voice[index]\n next unless voice\n filename_safe_content = get_filename(content)\n # p [filename_safe_content, content]\n\n if (filelist[:movie_pics][line_index].nil?)\n filelist[:movie_pics].push \"#{DIR[:movie_pics]}/#{filename_safe_content}.png\"\n end\n\n app_config = CONF['app'][rule_name]\n if app_config\n app_root = app_config['app_root']\n if app_root\n if (filelist[:app_sounds][line_index].nil?)\n filelist[:app_sounds].push app_config['sounds'].size.times.map { |n|\n File.join(app_root, \"sounds\", \"#{filename_safe_content}-#{n + 1}.wav\")\n }\n end\n end\n end\n\n filter = CONF['filter'][field]\n content = Filter.send(filter, content) if filter\n digest = Digest::SHA256.hexdigest(voice + content)\n raw_file = \"#{DIR[:raw]}/#{digest}.wav\"\n filelist[:say_args_by_raw][raw_file] = [voice, content]\n raw_by_field[field] = raw_file\n end\n filelist[:raw] << raw_by_field\n end\n filelist\nend", "def get_time()\n\tarr_times = [\"Morning\", \"Day\", \"Afternoon\", \"Evening\", \"Night\"]\n\t#binding.pry\n\tif Time.now.strftime(\"%H\").to_i < 12 \n\t\tarr_times[0]\n\telsif Time.now.strftime(\"%H\").to_i < 14\n\t\tarr_times[1]\n\telsif Time.now.strftime(\"%H\").to_i < 18\n\t\tarr_times[2]\n\telsif Time.now.strftime(\"%H\").to_i < 21\n\t\tarr_times[3]\n\telse\n\t\tarr_times[4]\n\tend\nend", "def parse_minutes(time)\n minutes = time.strftime(\"%M\").to_i\n minutes == 0 ? [sound_path(\"oclock.ul\")] : sounds_for_number(minutes)\n end", "def sounds_for_digits(num)\n result = []\n num.to_s.each_char do |c|\n result << sound_path(\"#{c}.ul\")\n end\n result\n end", "def get_files_by_mtime dir='*'\n gfb dir, :mtime\nend", "def create_sound_sound(filename, flags = nil)\n Yuki::ElapsedTime.start(:audio_load_sound)\n if (file_data = @sound_cache[filename])\n @sound_count[filename] += 1\n else\n file_data = File.binread(filename)\n Yuki::ElapsedTime.show(:audio_load_sound, 'Loading sound from disk took')\n end\n gm_filename = filename.include?('.mid') && File.exist?('gm.dls') ? 'gm.dls' : nil\n sound_info = FMOD::SoundExInfo.new(file_data.bytesize, nil, nil, nil, nil, nil, gm_filename)\n sound = FMOD::System.createSound(file_data, create_sound_get_flags(flags), sound_info)\n sound.instance_variable_set(:@extinfo, sound_info)\n Yuki::ElapsedTime.show(:audio_load_sound, 'Creating sound object took')\n return sound\n rescue Errno::ENOENT\n log_error(\"Failed to load sound : #{filename}\")\n return nil\n end", "def time_detail(options = {})\n default_options = {\n :use_words => true,\n :date_format => :date_with_day_of_week,\n :time_format => :time12,\n :use_relative_dates => true,\n :audience => nil\n }\n options = default_options.merge(options)\n audience = options[:audience]\n separator = options[:use_words] ? { :to => \" to\", :from => \" from\", :at => \" at\" } : { :to => \" -\", :from => \"\", :at => \"\" }\n _start_date = date.to_date.to_s(options[:date_format]).strip\n _start_date = \"Today\" if date.to_date == Time.now.to_date && options[:use_relative_dates]\n _start_date = \"Tomorrow\" if date.to_date == 1.day.from_now.to_date && options[:use_relative_dates]\n _start_time = start_time(audience).to_time.to_s(options[:time_format]).strip if start_time(audience)\n _end_date = end_time(audience).to_date.to_s(options[:date_format]).strip if end_time(audience)\n _end_date = \"today\" if end_time(audience) && end_time(audience).to_date == Time.now.to_date && options[:use_relative_dates]\n _end_date = \"tomorrow\" if end_time(audience) && end_time(audience).to_date == 1.day.from_now.to_date && options[:use_relative_dates]\n _end_time = end_time(audience).to_time.to_s(options[:time_format]).strip if end_time(audience)\n return \"Time TBA\" if options[:time_only] && time_tba?\n return \"#{_start_date}\" if (options[:date_only] && (end_time(audience).blank? || start_time(audience).to_date == end_time(audience).to_date)) || start_time(audience).blank? || time_tba?\n return \"#{_start_time}\" if options[:time_only] && !end_time(audience)\n return \"#{_start_time}#{separator[:to]} #{_end_time}\" if options[:time_only] && start_time(audience).to_date == end_time(audience).to_date\n return \"#{_start_date}#{separator[:at]} #{_start_time}\" if start_time(audience) && end_time(audience).nil?\n return \"#{_start_date}#{separator[:from]} #{_start_time}#{separator[:to]} #{_end_time}\" if start_time(audience).to_date == end_time(audience).to_date\n return \"#{_start_date}#{separator[:at]} #{_start_time}#{separator[:to]} #{_end_date}#{separator[:at]} #{_end_time}\"\n end", "def files # loads all the mp3 files in the path directory / normalizes the filename to just the mp3 filename with no path\n @files ||= Dir.glob(\"#{path}/*.mp3\").collect{ |f| f.gsub(\"#{path}/\", \"\") } # then using the .collect method and gsub to just return the filename with out path\n end", "def get_times(hash)\n\ttimes = hash.map { |name, time| time }\nend", "def play_hash_audio(hash)\n HASH_SOUND_MAP.each do |k, v|\n `#{SOUND_APP} #{SOUNDS_DIR}/#{v}` if hash.downcase.match(k.downcase)\n end\nend", "def collect_time_information\n ### Time information\n mark_data_time_information = Array.new\n time_information = @case_details[:case][:system][:time]\n\n mark_data_time_information << 'Answer the following about each time period present in the evidence on the system'\n time_information.each do | key, value | mark_data_time_information << \"-#{key.capitalize}::#{value}\"\n end\n mark_data_time_information << ''\n\n return mark_data_time_information\n end", "def time_class\n puts \"BEGIN: #{__method__}\"\n # There are two time classes:\n # time in the core library\n # time in the standard library\n # require 'time' loads the standard library version which adds useful methods\n # such as parse and strptime\n require 'time'\n\n # Time.new is synonymous with Time.now\n now = Time.now\n\n puts \"Current time=#{now.strftime('%Y-%m-%d %H:%M:%S %Z')}\"\n puts \"year=#{now.year}\"\n puts \"month=#{now.month}\"\n puts \"day=#{now.day}\"\n puts \"wday=#{now.wday}\"\n puts \"day of year=#{now.yday}\"\n puts \"hour=#{now.hour}\"\n puts \"min=#{now.min}\"\n puts \"second=#{now.sec}\"\n puts \"microsecond=#{now.usec}\"\n puts \"timezone=#{now.zone}\"\n puts \"utc offset in seconds=#{now.utc_offset}\"\n\n # Create a time object for 2013-04-07 15:07:35.600\n # Arguments that can be passed:\n # (year, month, day, hour, min, sec, usec_with_frac)\n # Notice how month can be the short name or number\n puts \"Time.utc=#{Time.utc(2013,\"apr\",07,15,07,35,600)}\"\n puts \"Time.local=#{Time.local(2013,04,07,15,07,35,600)}\"\n # Time.new does not support microseconds\n # (year, month, day, hour, min, sec, UTC offset)\n puts \"Time.new=#{Time.new(2013,04,07,15,07,35,'-08:00')}\"\n puts \"Time.at(epoch time)=#{Time.at(1365365255)}\"\n puts \"Time.strptime=#{Time.strptime('2013-04-07 15:07:35.600', '%Y-%m-%d %H:%M:%S.%L')}\"\n puts \"Note how strptime will output to local time by default:\"\n puts \"Time.strptime for 'Apr 7 15:07:35 2013 GMT'=\" \\\n \"#{Time.strptime('Apr 7 15:07:35 2013 GMT', '%b %d %H:%M:%S %Y %Z')}\"\n\n puts \"Current Epoch time=#{now.to_i}\"\n puts \"Current Epoch time with microseconds=#{now.to_f}\"\n\n puts \"10 days from now=#{now + (60 * 60 * 24 * 10)}\"\n puts \"10 days before now=#{now - (60 * 60 * 24 * 10)}\"\n\n puts \"END: #{__method__}\"\nend", "def chord\n note_num = 4\n samples = []\n count = 0\n duration = nil\n\n while duration.nil?\n puts Rainbow(\"For how many seconds should your chord be played?\").blue\n duration = STDIN.gets.chomp.to_i\n if duration < 1 || duration > 40 || !duration.is_a?(Integer)\n puts Rainbow(\"Please enter a number of seconds greater than 1 and less than 150!\").yellow\n duration = nil\n end\n end\n\n while count <= note_num - 1\n frequency *= 2 if count == 3\n amplitude = 0.25\n num_samples = Notes.SAMPLE_RATE * duration\n\n case count\n when 0\n frequency = Notes.get_notes\n voice = generate_sinewave(num_samples, frequency, amplitude)\n voice_1 = voice\n when 1\n frequency = Notes.get_notes\n voice = generate_sinewave(num_samples, frequency, amplitude)\n voice_2 = voice\n when 2\n frequency = Notes.get_notes\n voice = generate_sinewave(num_samples, frequency, amplitude)\n voice_3 = voice\n when 3\n frequency = Notes.get_notes\n frequency *= 2\n voice = generate_sinewave(num_samples, frequency, amplitude)\n voice_4 = voice\n end\n\n if count >= 3\n samples = [voice_1, voice_2, voice_3, voice_4].transpose.map {|x| x.reduce(:+)}\n export_samples(samples.flatten)\n end\n count += 1\n end\n samples\nend", "def sounds_for_number(number)\n number = number.to_i\n result = []\n thousands = (number / 1000).floor\n if thousands > 0\n result << \"#{thousands}.ul\" << \"thousand.ul\"\n end\n rest = number % 1000\n hundreds = (rest / 100).floor\n if hundreds > 0\n result << \"#{hundreds}.ul\" << \"hundred.ul\"\n end\n rest = rest % 100\n if rest <= 19\n result << \"#{rest}.ul\"\n else\n tens = (rest / 10).floor\n units = rest % 10\n result << \"#{tens}0.ul\" \n result << \"#{units}.ul\" if units > 0\n end\n result.map {|r| sound_path(r) }\n end", "def files\n # fetch the appropriate files\n filenames = Dir.glob(@path + \"/*.mp3\")\n filenames.map { |filename| @files << File.basename(filename) }\n @files\n end", "def manual_file\n f = File.open(\"#{Time.new.strftime('%Y-%m-%dT%H:%M:%S')}.txt\", 'w')\n f.write('Hello')\n f.flush\n f.close\nend", "def files\n Dir.entries(\"#{path}\").select {|song_filename| song_filename.include?(\"mp3\")}\n end", "def get_files\n Dir.foreach(@path) do |file|\n if File.extname(file) == \".mp3\"\n thisfile = SongFile.new(\"#{@path}/#{File.path(file)}\")\n @files << thisfile\n end\n end\n end", "def split_movie(file_path)\n OSX.require_framework(\"QTKit\")\n splitted_files = Array.new\n movie, error = OSX::QTMovie.movieWithFile_error(file_path) # Load in the original movie\n if(error != nil || movie == nil) # Check if we can load the movie\n $stderr.puts \"Could not open #{file_path}, #{error.localizedDescription}\"\n exit(-1)\n end\n \n # a QTTime structure has a timeValue and timeScale we need\n # to dived the timeValue by the timeScale to get the time\n # in seconds. If we devide that by 60 we get the time in\n # minutes\n time_scale = movie.duration.timeScale\n total_time = (movie.duration.timeValue / time_scale) / 60\n \n # If the total time is below 10 minutes we don't have to\n # split the movie\n if(total_time < 10)\n splitted_files.push(file_path)\n return splitted_files\n end\n \n # If the totol time is above 10 minutes we have to calculate\n # how many parts we need to make. No part can be over 10 minutes.\n parts = total_time.to_i / 10\n \n if(total_time.modulo(10) != 0)\n parts = parts + 1\n end\n \n # Parts are always 10 minutes long (or shorter)\n part_duration = OSX::QTMakeTime(600 * time_scale, time_scale)\n temp_dir = Dir.tmpdir()\n attributes = OSX::NSDictionary.dictionaryWithObjectsAndKeys(OSX::NSNumber.numberWithBool(true), \"QTMovieFlatten\", nil)\n movies = Array.new\n \n # For every part we extract the time selection out of the original movie\n # and write it out to a new, temporary file. We store the paths to the\n # temporary files\n parts.times do |i|\n begin_time = OSX::QTMakeTime(i * 600 * time_scale, time_scale)\n range = OSX::QTMakeTimeRange(begin_time, part_duration)\n movie_part, error = movie.movieWithTimeRange_error(range)\n \n if(error != nil || movie_part == nil)\n $stderr.puts \"Could not generate subclip, #{error.localizedDescription}\"\n exit(-1)\n end\n \n # Writing out the temporary file and storing the path in the movies array\n temp_file_path = temp_dir + \"/\" + File.basename(file_path, File.extname(file_path)) + \"-\" + i.to_s + \".mov\"\n movie_part.writeToFile_withAttributes(temp_file_path, attributes)\n movies.push(temp_file_path)\n end\n return movies \n end", "def audios\n unless @audios\n @audios = {:es => [], :eu => [], :en => [], :all => []}\n\n return @audios if self.multimedia_path.blank?\n\n # Lista de todos los audios en <dir>/*.mp3\n list_of_audios = Dir.glob(full_multimedia_path + \"*.mp3\")\n list_of_audios = list_of_audios.collect {|a| Pathname.new(a).relative_path_from(Pathname.new(class_multimedia_path)).to_s}\n\n Document::LANGUAGES.each do |l|\n # Meto en cada idioma solo los que acaban en \"_<idioma>.mp3\"\n @audios[l.to_sym] = list_of_audios.select {|a| a.match(\"_#{l}.mp3\")}\n list_of_audios = list_of_audios - @audios[l.to_sym]\n end\n\n Document::LANGUAGES.each do |l|\n @audios[l.to_sym] = @audios[l.to_sym] + list_of_audios\n end\n @audios[:all] = @audios.values.flatten.uniq\n end\n return @audios\n end", "def files\n # Dir.glob(\"*.mp3\") #this grabs mp3s from path\n Dir.chdir(@path) do \n @mp3s = Dir.glob(\"*.mp3\") \n end\n end", "def format\n begin\n fmt_klass = Timetrap::Formatters.const_get(\"#{unused_args.classify}\")\n rescue\n say \"Invalid format specified `#{unused_args}'\"\n return\n end\n ee = Timetrap::Entry.filter(:sheet => Timetrap.current_sheet)\n ee = ee.filter(:start >= Date.parse(args['-s'])) if args['-s']\n ee = ee.filter(:start <= Date.parse(args['-e']) + 1) if args['-e']\n say Timetrap.format(fmt_klass,ee.all)\n end", "def show(time)\n parameter = SCHEDULE.find { |key, val| val if key.include?(time) }\n raise ArgumentError, 'There are no films to watch at this time. Sorry.' unless parameter\n films = filter(parameter[1])\n to_watch = get_rnd_film(films)\n puts \"Now showing: \\\"#{to_watch.title}\\\", #{to_watch.genre * ', '}, \\\nduration: #{to_watch.duration} min.\"\n to_watch\n end", "def file_for_month(month)\n sound_path(\"mon-#{month.to_i - 1}.ul\")\n end", "def process_file(file_name)\n begin\n time=(@time_now-120).strftime(\"%Y:%H:%M\") # 2 min ago\n File.open(file_name,\"rb\") do |file|\n file.each_line do |line|\n if line=~/#{time}/ and info=/^(\\S+)\\s+-\\s+\\[[^\\[\\]]+\\]\\s+\"[^\"]+\"\\s+(\\d+)\\s+\\d+\\s+\"[^\"]+\"\\s+\"[^\"]+\"\\s+\\S+\\s+response_time:(\\S+).*/.match(line)\n uri=info[1].to_s.chomp\n response_code=info[2]\n response_time=(info[3].to_f*1000).to_i\n @pv_response_time[uri]||=response_time\n @pv_response_time[uri]=response_time if response_time>@pv_response_time[uri]\n @pv_response_code[uri]||={}\n @pv_response_code[uri][response_code]||=0\n @pv_response_code[uri][response_code]+=1\n end\n end\n end\n rescue => e\n puts \"Error in process_file: #{e.message}\"\n end\n end", "def parse_hour_24h(time)\n sounds_for_number(time.strftime(\"%k\"))\n end", "def formattime()\n\t\tamOrpm = 0\t# this will decide P or A\n\t\ttopResult = ''\t# save top string from the digital clock\n\t\tmiddleResult = ''\t# save middle string from the digital clock\n\t\tbotResult = ''\t\t# save bot string from the digital clock\n\t\t\n\t\thour = gethour().to_i\t# change to integer for hour\n\t\tmin = getminute().to_i\t# change to integer for minute\n\t\t@amOrpm = @t.strftime(\"%p\")\t# this get PM or AM, I used strftime method which provided from the Time class\n\t\tif @amOrpm == \"PM\"\t# if PM\t\n\t\t\tamOrpm = 1\t# save 1\n\t\telse\t\t\t# if AM\n\t\t\tamOrpm = 0\t# save 0\n\t\tend\n\n\t\ttopResult = top(hour,min)\t# Save top string from the digital clock with top method\n\t\tmiddleResult = middle(hour,min)\t# Save middle string from the digital clock with middle method\n\t\tbotResult = bot(hour,min, amOrpm)\t# Save bot string from the digital clock with bot method\n\t\ttotal = topResult + middleResult + botResult\t# save all the string in the total\n\t\treturn total\t\t\t# return total represent perfect digital time\n\tend", "def determine_file_time(path)\n begin\n date, start_hour, end_hour = date_and_hours_from_path(path)\n rescue ArgumentError\n if params[:debug]\n debug_print(\"Unable to determine file time from path: #{path}\")\n end\n # XXX this is a moderately evil hack to avoid removing files that\n # do not look like they are part of ETL process.\n # Return current time, assuming only files of some age are removed\n # this file should be kept alone\n return Time.now.utc\n end\n # here we assume file timestamps are in UTC\n year, month, day = date[0..3].to_i, date[4..5].to_i, date[6..7].to_i\n # end_hour may be 24, use arithmetic instead of passing end_hour to new\n Time.utc(year, month, day) + end_hour.hours\n end", "def time_to_font(time,font)\n output = []\n for i in 0...time.length()\n converted_font = convert_1_number_to_1_font(time[i],font)\n output.append(converted_font)\n end\n return output\nend", "def scribe\n raise 'bork' unless ARGV.any?\n\n name, type = ARGV.first.split('.')\n name_bits = name.to_s.ljust(64, ' ').to_bits\n type_bits = type.to_s.ljust(5, ' ').to_bits\n data_bits = File.open(ARGV.first) { |file| file.read }.to_bits\n size = data_bits.count / 8\n size_bits = (\"%032b\" % size).split('').map(&:to_i)\n prelude_bits = SYNC.map { |byte| \"%08b\" % byte }.join.split('').map(&:to_i)\n\n sample \"#{ name }.wav\", prelude_bits + name_bits + type_bits + size_bits + data_bits\nend", "def p\n $is_last_recording_playing = !$is_last_recording_playing\n if $is_last_recording_playing\n Thread.new do\n path = File.most_recently_edited(\"./recording/*.mp3\")\n Thread.new do\n unless path.blank?\n while $is_last_recording_playing\n Sounds::Base.play_file_with_mpg123 path \n end\n end\n end\n puts \"playing #{path}\"\n end\n else\n puts \"stopped playback\"\n end\n end", "def format_time(time, opts = {})\n format = opts[:include_timezone] ? \"%H:%M%:z\" : \"%H:%M\"\n if time.is_a? String\n case time\n when 'now'\n return DateTime.now.strftime format\n else\n unless time =~ /^\\d{2}\\:\\d{2}$/\n raise Fitgem::InvalidTimeArgument, \"Invalid time (#{time}), must be in HH:mm format\"\n end\n timezone = DateTime.now.strftime(\"%:z\")\n return opts[:include_timezone] ? [ time, timezone ].join : time\n end\n elsif DateTime === time || Time === time\n return time.strftime format\n else\n raise Fitgem::InvalidTimeArgument, \"Date used must be a valid time object or a string in the format HH:mm; supplied argument is a #{time.class}\"\n end\n end", "def probe(file)\n file = Shellwords.escape(file)\n command = [ \"ffprobe\", \"-print_format json\", \"-show_format\", \"-show_streams\", \"#{file}\" ]\n\n json = JSON.parse execute(command).join\n\n if Options.options[:info]\n pp json\n exit\n end\n\n info = {}\n info[:filename] = json[\"format\"][\"filename\"]\n info[:duration] = json[\"format\"][\"duration\"].to_i\n info[:video] = []\n info[:audio] = []\n info[:subtitle] = []\n\n # Note that the stream index value is not the index of the stream relative\n # to the file, it's the index relative to the number of that type of streams.\n # That is what ffmpeg expects when you specify something like \"-map 0:a:0\"\n # which means the first audio stream in the first input file, even if the\n # stream is the fifth found in the file.\n #\n json[\"streams\"].each do |stream|\n if(\"video\" == stream[\"codec_type\"])\n info[:video] << {\n :index => info[:video].count,\n :codec => stream[\"codec_name\"],\n :width => stream[\"width\"],\n :height => stream[\"height\"]\n }\n elsif(\"audio\" == stream[\"codec_type\"])\n info[:audio] << {\n :index => info[:audio].count,\n :codec => stream[\"codec_name\"],\n :channels => stream[\"channels\"],\n :language => (stream[\"tags\"] && stream[\"tags\"][\"language\"]) ? stream[\"tags\"][\"language\"].downcase : 'und',\n :title => (stream[\"tags\"] && stream[\"tags\"][\"title\"]) ? stream[\"tags\"][\"title\"] : 'Audio Track'\n }\n elsif(\"subtitle\" == stream[\"codec_type\"])\n info[:subtitle] << {\n :index => info[:subtitle].count,\n :codec => stream[\"codec_name\"],\n :language => stream[\"tags\"] ? stream[\"tags\"][\"language\"] ? stream[\"tags\"][\"language\"].downcase : 'eng' : 'eng',\n :title => (stream[\"tags\"] && stream[\"tags\"][\"title\"]) ? stream[\"tags\"][\"title\"] : 'Subtitle Track',\n :forced => stream[\"disposition\"][\"forced\"],\n :impared => stream[\"disposition\"][\"hearing_impaired\"]\n }\n end\n end\n\n return info\nend", "def determine_file_time(path)\n date, hour = date_and_hour_from_path(path)\n # here we assume file timestamps are in UTC\n year, month, day = date[0..3].to_i, date[4..5].to_i, date[6..7].to_i\n Time.utc(year, month, day, hour)\n end", "def test_filetime\n\t\t# for saving, we can use Date, Time, or DateTime.\n\t\tassert_equal \"\\000\\000\\260\\3077-\\307\\001\", FileTime.dump(Time.gm(2007, 1, 1))\n\t\ttime = FileTime.load \"\\000\\000\\260\\3077-\\307\\001\"\n\t\tassert_equal FileTime, time.class\n\t\tassert_equal '2007-01-01T00:00:00+00:00', time.to_s\n\t\t# note that if we'd used Time.local, instead of gm, we'd get a different value. eg\n\t\tassert_equal \"\\000\\370\\331\\336\\r-\\307\\001\", FileTime.dump(DateTime.parse('2007-01-01 00:00 +0500'))\n\t\t# note that it still loads up as GMT, because there's no associated time zone.\n\t\t# essentially, i'm storing and loading times as GMT. maybe i should add in conversion to local time\n\t\t# zone when loading\n\t\tassert_equal '2006-12-31T19:00:00+00:00', FileTime.load(\"\\000\\370\\331\\336\\r-\\307\\001\").to_s\n\t\t# test loading a bogus time\n\t\tassert_equal nil, FileTime.load(0.chr * 8)\n\t\t# this used to be counted as an \"unlikely time\", and discarded. that has been removed\n\t\tassert_equal '1700-01-01T00:00:00+00:00', FileTime.load(FileTime.dump(Date.new(1700, 1, 1))).to_s\n\t\tassert_equal '#<Ole::Types::FileTime 2006-12-31T19:00:00+00:00>', FileTime.load(\"\\000\\370\\331\\336\\r-\\307\\001\").inspect\n\tend", "def files\n # fetch the appropriate files\n file_paths = Dir.glob(@path + \"/*.mp3\")\n file_paths.map { |file_path| @files << File.basename(file_path) }\n @files\n end", "def FormatTimesDates\n\ttime = Time.new\n\tputs time.to_s\n\tputs time.ctime\n\tputs time.localtime\n\tputs time.strftime(\"%Y-%m-%d %H:%M:%S\")\n\tputs time.strftime(\"%d/%m/%Y\")\nend", "def do_add\n file_paths = ARGV.dup\n\n file_paths.map! { |path| File.expand_path(path) }\n \n file_paths.each do |path|\n ensure_exists(path)\n end\n\n audiofiles = file_paths.map do |path|\n af = nil # SCOPE\n TagLib::FileRef.open(path) do |ref|\n if ref.null?\n warnx(\"#{path}: not an audio file?\")\n exit 1\n end\n warnx(\"parsing #{path}\")\n tags = ref.tag\n af = AudioFile.new(path, tags.title, tags.artist, tags.album)\n end\n\n af\n end\n\n File.open(@playlist_path, \"w\") { |fd|\n fd.puts(PlaylistWriter.new(audiofiles).to_s)\n }\nend", "def retrieve_files\r\n\r\n #Determine which platform the game is running on\r\n if RUBY_PLATFORM =~ /win32|win64|\\.NET|windows|cygwin|mingw32/ then\r\n #Retrieve files and assign to global variable\r\n $help_file = File.read('C:\\Ruby22\\Ruby_Apps\\myApp\\BJHelp.txt')\r\n $welcome_file = File.read('C:\\Ruby22\\Ruby_Apps\\myApp\\BJWelcome.txt')\r\n $credits_file = File.read('C:\\Ruby22\\Ruby_Apps\\myApp\\BJCredits.txt')\r\n else\r\n $help_file = File.read('/Ruby22/Ruby_Apps/myApp/BJHelp.txt')\r\n $welcome_file = File.read('/Ruby22/Ruby_Apps/myApp/BJWelcome.txt')\r\n $credits_file = File.read('/Ruby22/Ruby_Apps/myApp/BJCredits.txt')\r\n end\r\n\r\n end", "def time(text)\n scan(text, TIME, :time)\n end", "def time_format(seconds)\nend", "def time_format(seconds)\nend", "def formats(arguments, options)\n puts \"Available formats:\"\n Dir.glob(\"{#{$LOAD_PATH.join(',')}}/baretest/run/*.rb\") { |path|\n puts \"- #{File.basename(path, '.rb')}\"\n }\n end", "def createFile(file,time)\n\t\tFile.open(file, \"w+\") do |f|\n\t\t\tf.print time\n\t\tend\n\tend", "def chatting_time(*args)\n @client.get \"#{@path}/chatting_time\", Hash[*args]\n end", "def with_by_star_options(*args, &block)\n options = args.extract_options!.symbolize_keys!\n time = args.first\n time ||= Time.zone.local(options[:year]) if options[:year]\n time ||= Time.zone.now\n block.call(time, options)\n end", "def files\n array_full_names = Dir.glob(\"#{@path}/*.mp3\")\n array_full_names.collect do |full_name|\n full_name[21..-1]\n end\n end", "def say_datetime(time=Time.now, digits='\"\"', format=\"ABdY\", timezone=nil)\n response = AGIResponse.new\n if timezone.nil?\n command_str = \"SAY DATETIME #{time.to_i} #{digits} #{format}\"\n else\n command_str = \"SAY DATETIME #{time.to_i} #{digits} #{format} #{timezone}\"\n end\n begin\n response.native = execute(command_str)\n rescue AGITimeoutError, AGICommandError, AGIHangupError\n raise\n end\n if response.native == -1 then\n raise AGIChannelError.new(@last_response, \"Channel Failure in (#{command_str})\")\n elsif response.native == 0\n response.success = true\n else\n response.success = true\n response.data = response.native.chr\n end\n return response\n end", "def shiftSub(shift)\n\t\tshift = shift /1000.0\n\t\ttext = @inputFile.read\n\t\tputs \"Please, write the name of the new subtitles...\"\n\t\tnewName = gets.chomp + \".srt\"\n\t\tnewFile = File.new(newName,\"w\")\n\t\ttext.each_line do |line|\n\t\t\tif line[2] == \":\" && line[5] == \":\"\n\t\t\t\tsubSeconds1 = [line[(0..1)].to_f*3600, line[(3..4)].to_f*60, (line[(6..11)].gsub(\",\",\".\")).to_f].reduce(:+)\t+ shift\t\t\n\t\t\t\tsubSeconds2 = [line[(17..18)].to_f*3600, line[(20..21)].to_f*60, (line[(23..28)].gsub(\",\",\".\")).to_f].reduce(:+) + shift\n\n\t\t\t\tsubSeconds1 = [(subSeconds1/3600).to_i, ((subSeconds1/3600 - (subSeconds1/3600).to_i)*60).to_i, ((((subSeconds1/3600 - (subSeconds1/3600).to_i)*60)-((subSeconds1/3600 - (subSeconds1/3600).to_i)*60).to_i)*60).round(3)]\n\t\t\t\tsubSeconds2 = [(subSeconds2/3600).to_i, ((subSeconds2/3600 - (subSeconds2/3600).to_i)*60).to_i, ((((subSeconds2/3600 - (subSeconds2/3600).to_i)*60)-((subSeconds2/3600 - (subSeconds2/3600).to_i)*60).to_i)*60).round(3)]\n\t\t\t\t\n\t\t\t\tline[(0..1)] = toStr(subSeconds1[0],2)\n\t\t\t\tline[(3..4)] = toStr(subSeconds1[1],2)\n\t\t\t\tline[(6..11)] = toStr(subSeconds1[2],6).gsub(\".\",\",\")\n\n\t\t\t\tline[(17..18)] = toStr(subSeconds2[0],2)\n\t\t\t\tline[(20..21)] = toStr(subSeconds2[1],2)\n\t\t\t\tline[(23..28)] = toStr(subSeconds2[2],6).gsub(\".\",\",\")\n\t\t\t\tnewFile.puts(line)\n\t\t\telse\n\t\t\t\tnewFile.puts(line)\n\t\t\tend", "def mtimes\n @files.inject({}) do |hash, g|\n Dir[g].each { |file| hash[file] = File.mtime(file) }\n hash\n end\n end", "def readDirectoryFiles(directory,formats)\n files=[]\n Dir.chdir(directory){\n for i in 0...formats.length\n Dir.glob(formats[i]){|f| files.push(f) }\n end\n }\n return files\nend", "def change_file(time)\n prev_time = time - Rational(1,24)\n prev_time.strftime(\"%Y%m%d%H\") + \"-\" + time.strftime(\"%Y%m%d%H\") + \".osc.gz\"\nend", "def print_to_file(dateTime, mem, cpuu, dsu)\n\t#########TO DO########\n\t#this function will take the variables, dateTime, mem, cpuu, & dsu, and put it into a string variable\n\t#if required, format the string.\n\n\t#then before doing the write to file, check if file exists\n\t#if file exists, go ahead and write to the file\n\t#if file doesn't exist, write to new file.\n\n\t#file names: file name will be determined by the month, day , hour. \"07-13_14\"\"month-day_hour\"\nend", "def format_duration(seconds)\n seconds = seconds.to_f\n answer = Array.new\n if seconds == 0\n return \"now\"\n end\n while seconds >= (60*60*24*365) #years\n answer << (seconds / (60*60*24*365).to_f).to_s.split(\".\").first\n answer.last.to_i > 1 ? answer[-1] += \" years\" : answer[-1] += \" year\"\n seconds = (seconds % (60*60*24*365))\n end\n while seconds >= (60*60*24) #days\n answer << (seconds / (60*60*24).to_f).to_s.split(\".\").first\n answer.last.to_i > 1 ? answer[-1] += \" days\" : answer[-1] += \" day\"\n seconds = (seconds % (60*60*24))\n end\n while seconds >= (60*60) #hours\n answer << (seconds / (60*60).to_f).to_s.split(\".\").first\n answer.last.to_i > 1 ? answer[-1] += \" hours\" : answer[-1] += \" hour\"\n seconds = (seconds % (60*60))\n end\n while seconds >= (60) #minutes\n answer << (seconds / (60).to_f).to_s.split(\".\").first\n answer.last.to_i > 1 ? answer[-1] += \" minutes\" : answer[-1] += \" minute\"\n seconds = (seconds % (60))\n end\n if seconds < 60\n answer << seconds.to_i.to_s\n answer.last.to_i > 1 ? answer[-1] += \" seconds\" : answer[-1] += \" second\"\n end\n while answer[-1].split(\" \").first.to_i == 0\n answer.pop\n end\n while answer.length >= 3\n answer[1] = answer[0] + \", \" + answer[1]\n answer.shift\n end\n if answer.length == 2\n answer.join(\" and \")\n else\n answer.first\n end\nend", "def load_wav filename\n sample_rate = nil\n fmt = nil\n data = ''\n File.open(filename) do |file|\n head = file.read(12)\n until file.eof?\n type = file.read(4)\n size = file.read(4).unpack(\"V\")[0].to_i\n case type\n when 'fmt '\n fmt = file.read(size)\n fmt = {\n :id => fmt.slice(0,2).unpack('c')[0],\n :channel => fmt.slice(2,2).unpack('c')[0],\n :hz => fmt.slice(4,4).unpack('V').join.to_i,\n :byte_sec => fmt.slice(8,4).unpack('V').join.to_i,\n :block_size => fmt.slice(12,2).unpack('c')[0],\n :bit_sample => fmt.slice(14,2).unpack('c')[0]\n }\n when 'data'\n data += file.read size\n else\n raise type\n end\n end\n end\n [fmt, data]\nend", "def set_format *args\n global, format = args.fetch_opts [nil], :type => :console, :time => [\"%H:%M:%S\", \"%03d\"] \n format = if format[:type] == :html; {\n :caller => \"<a class='l'>%f:%l</a> <a class='m'>:%m</a>\", \n :format => \"<div class='line'><a class='t'>%time</a> <a class='%mode'>%mode</m> [%caller]: <p>%text</p>%att</div>\",\n :att =>\"<div class='att'><div class='hide'>+</div><pre>%s</pre></div>\",\n :serializer => RMTools::RMLogger::HTML\n }; else {\n :caller => \"#{@c.gray('%f:%l')} #{@c.red_bold(':%m')}\", \n :format => \"%time %mode [%caller]: %text\"\n } end.merge format\n if global\n _set_format @default_format, format\n else\n _set_format(file_format={}, format)\n @file_formats[File.expand_path(caller[0].till ':')] = file_format\n end\n end", "def audio_info(source)\n # based on how harvester gets file hash.\n generated_file_hash = \"SHA256::#{generate_hash(source).hexdigest}\"\n\n # integrity\n integrity_check = @audio.integrity_check(source)\n\n # get file info using ffmpeg\n info = @audio.info(source)\n\n {\n file: source,\n extension: File.extname(source).delete('.'),\n errors: integrity_check[:errors],\n file_hash: generated_file_hash,\n media_type: info[:media_type],\n sample_rate_hertz: info[:sample_rate].to_i,\n duration_seconds: info[:duration_seconds].to_f.round(3),\n bit_rate_bps: info[:bit_rate_bps],\n data_length_bytes: info[:data_length_bytes],\n channels: info[:channels]\n }\n end", "def time_format\n return :time12 if new_us_user?\n\n clock_type == '12h' ? :time12 : :time24\n end", "def index\n @type_sounds = TypeSound.all\n end", "def audio_files(folder_name)\n Dir.glob(\"./audio/#{folder_name}/**/*\")\n end", "def set_mtimes(times)\n pm = false\n _24hr = true\n\n times_24 = []\n now = Time.now\n \n #convert to '24hr' for consistency\n #start backwards to make sure its am or pm\n times.reverse_each do |t|\n\n hr, min = t[0].to_s.split(':', 2)\n\n #change to pm\n if (min.include?(\"pm\"))\n pm = true\n _24hr = false\n end\n\n #change from pm to am\n if (min.include?(\"am\") && !_24hr)\n pm = false\n end\n\n #only am start - hackish\n if (min.include?(\"am\") && times.length < 3)\n _24hr = false\n end\n\n if (_24hr)\n augment =0\n if (hr.to_i == 12)\n augment = 12\n end\n\n t = Time.new(now.year, now.month, now.day,\n hr.to_i - augment, min[/[0-9]+/]) + 24*60*60 #add a day\n elsif (pm)\n augment = 0\n if hr.to_i != 12\n augment = 12\n end\n t = Time.new(now.year, now.month, now.day,\n hr.to_i + augment, min[/[0-9]+/])\n\n elsif (!pm & !_24hr)\n t = Time.new(now.year, now.month, now.day,\n hr.to_i, min[/[0-9]+/])\n end\n\n=begin\n #midnight seems to be latest\n if ((!pm && min.include?(\"am\") && hr.to_i == 12) ||\n ((!pm && hr.to_i == 12)))\n \n t = Time.new(now.year, now.month, now.day,\n hr.to_i - 12, min[/[0-9]+/]) + 24*60*60 #add a day\n\n elsif (!pm && min.include?(\"am\"))\n pm = false\n\n t = Time.new(now.year, now.month, now.day,\n hr.to_i, min[/[0-9]+/])\n\n elsif (pm || min.include?(\"pm\"))\n pm = true\n augment = 0\n if (hr.to_i != 12)\n augment = 12\n end\n\n t = Time.new(now.year, now.month, now.day,\n hr.to_i + augment, min[/[0-9]+/])\n\n end\n=end\n times_24.push t\n end\n\n self.mtimes = times_24\n\n end", "def say(*fmt)\n print Time.now.localtime.strftime('[%Y%m%d-%H%M%S] ')\n printf *fmt\n puts ''\nend", "def convert(file_info)\n input_name = Shellwords.escape(file_info[:filename])\n input_suffix = File.extname input_name\n output_name = File.basename input_name, input_suffix\n output_suffix = \"mp4\"\n command = [ \"ffmpeg\", \"-y\", \"-i #{input_name}\", \"-max_muxing_queue_size 9999\", \"-map_chapters -1\" ]\n\n if (file_info[:video].empty? && !file_info[:audio].empty?) || input_suffix == '.flac' || input_suffix == '.mp3' || input_suffix == '.aiff'\n #\n # Audio-only files are converted to either ALAC if the source was FLAC, or\n # AAC for all other formats.\n #\n stream = file_info[:audio][0]\n case stream[:codec]\n when \"alac\"\n command << \"-map 0:a:#{stream[:index]}\" << \"-codec:a copy\"\n when \"flac\"\n command << \"-map 0:a:#{stream[:index]}\" << \"-codec:a alac\"\n when \"mp3\"\n command << \"-map 0:a:#{stream[:index]}\" << \"-codec:a alac\"\n else\n command << \"-map 0:a:#{stream[:index]}\" << \"-codec:a aac\" << \"-ar:a:0 48k\" << \"-ab:a 256k\"\n end\n output_suffix = \"m4a\"\n elsif !file_info[:video].empty? && !file_info[:audio].empty?\n # Removes all of the default metadata that junks up the final file.\n command << \"-map_metadata -1\"\n \n # Maps the video track\n command << \"-map 0:v:0\" << \"-metadata:s:v:0 language=und\" << \"-metadata:s:v:0 title='Video Track'\"\n\n #\n # The video track is copied if the codec is h265 (hevc) and a video tag\n # is added so that Apple products understand the format. Otherwise, the\n # video track is copied if it's in h264 format and the frame size is\n # to remain the same, or it's converted to h264 using high-quality\n # settings.\n #\n if \"hevc\" == file_info[:video][:codec]\n command << \"-codec:v copy -vtag hvc1\"\n elsif \"h264\" == file_info[:video][:codec] && !Options.options[:P480] && !Options.options[:P720]\n command << \"-codec:v copy\"\n else\n # This converts the video using settings that provide nearly visual\n # lossless results.\n output_suffix = \"mp4\"\n command << \"-codec:v libx265\" << \"-vtag hvc1\" << \"-preset:v slow\" << \"-profile:v main\" << \"-crf:v 18\" << \"-threads:v 0\"\n\n # Converts HD video to wide-screen 720P if necessary.\n command << \"-vf:v scale=1280:-1\" if Options.options[:P720]\n\n # Converts HD video to wide-screen 480P if necessary.\n command << \"-vf:v scale=854:-1\" if Options.options[:P480]\n end\n\n # Convert all of the audio tracks to AAC (stereo) and AC3 (multi-channel)\n index = 0\n file_info[:audio].each do |stream|\n index, c = convert_audio(stream, index)\n command << c\n end\n\n if file_info.key?(:subtitle) && !file_info[:subtitle].nil? && !file_info[:subtitle].empty?\n command << \"-map 0:s:#{file_info[:subtitle][:index]}\" << \"-metadata:s:s:0 language=eng\" << \"-metadata:s:s:0 title='Subtitle Track'\"\n command << ('dvd_subtitle' == file_info[:subtitle][:codec] ? \"-codec:s:0 copy\" : \"-codec:s:0 mov_text\")\n end\n\n end\n\n command << \"#{output_name}.#{output_suffix}\"\n\n if Options.options[:dump]\n puts command.join(' ')\n exit\n end\n\n #\n # Starts the transcoding process.\n #\n puts file_info[:filename]\n progress = ProgressBar.create(:format => \"%t |%B| %e\",\n :total => file_info[:duration] + 1,\n :title => \"Encoding Progress\")\n execute(command, true) do |line|\n begin\n line.match /time=(\\d\\d):(\\d\\d):(\\d\\d)/ do |match|\n if match.length == 4\n time = match[1].to_i * 3600 + match[2].to_i * 60 + match[3].to_i\n progress.progress = time\n end\n end\n rescue\n # Some UTF-8 characters can cause match to throw, but these characters are not used by this script.\n end\n end\n progress.finish\nend", "def index\n @sound_files = SoundFile.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @sound_files }\n end\n end", "def ingestAudioRecording(audiofilename, dateformat) #dateformat should be optional\n # For ingesting the \"Raw\" audio file. Can be cut in to segments later or separately, then imported and connected to the recording node\n \n # Check if a JSON already exists. If so, use it\n # if not, get the metadata, generate the JSON, and use it\n # IF dateformat nil, set it to \"%Y%m%d_%H%M%S%z\" (Double-check this)\n # Mark the STRFTIME format so that the time can be re-parsed from the filename programically\n # Parse JSON metadata\n # Map the JSON to the properties we care about\n # Set name\n # Set date\n # Set location, if it exists\n # Set ingest date to now\n # set ingestedFile to the file\n # set ingestedMetadataFile to the JSON file\n\nend" ]
[ "0.61816245", "0.5397976", "0.538732", "0.52377385", "0.5225956", "0.51569784", "0.512419", "0.509282", "0.50804037", "0.5053026", "0.5043899", "0.5036145", "0.49884212", "0.4984467", "0.49619898", "0.4961411", "0.49398535", "0.49191245", "0.49179387", "0.49104792", "0.48807785", "0.4866891", "0.48444906", "0.48271003", "0.4823366", "0.48230594", "0.48129287", "0.4794835", "0.4784499", "0.4784419", "0.47737956", "0.47693574", "0.47674808", "0.4747043", "0.47358772", "0.47346023", "0.47240245", "0.47189036", "0.47052795", "0.47036785", "0.47018105", "0.46765634", "0.4659947", "0.465333", "0.46454248", "0.46364757", "0.46283907", "0.46265775", "0.46182573", "0.45964047", "0.45961243", "0.45951602", "0.45810786", "0.4573008", "0.45713437", "0.45659107", "0.4565422", "0.45638335", "0.45619163", "0.45573226", "0.455372", "0.45510438", "0.45434645", "0.4534166", "0.45128012", "0.45097062", "0.45095637", "0.45032364", "0.45030984", "0.45022264", "0.44978535", "0.44925088", "0.44859695", "0.44850117", "0.44749153", "0.44733414", "0.44733414", "0.446042", "0.44534376", "0.4452325", "0.44490534", "0.44449416", "0.44422558", "0.4438807", "0.44357297", "0.44307896", "0.44302484", "0.44210625", "0.4418591", "0.44171885", "0.4405787", "0.43990353", "0.43968132", "0.43892577", "0.43891168", "0.4386028", "0.43791056", "0.43754977", "0.43688372", "0.43686154" ]
0.7513356
0
Returns the sounds for the single digits composing a number
def sounds_for_digits(num) result = [] num.to_s.each_char do |c| result << sound_path("#{c}.ul") end result end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sounds_for_number(number)\n number = number.to_i\n result = []\n thousands = (number / 1000).floor\n if thousands > 0\n result << \"#{thousands}.ul\" << \"thousand.ul\"\n end\n rest = number % 1000\n hundreds = (rest / 100).floor\n if hundreds > 0\n result << \"#{hundreds}.ul\" << \"hundred.ul\"\n end\n rest = rest % 100\n if rest <= 19\n result << \"#{rest}.ul\"\n else\n tens = (rest / 10).floor\n units = rest % 10\n result << \"#{tens}0.ul\" \n result << \"#{units}.ul\" if units > 0\n end\n result.map {|r| sound_path(r) }\n end", "def convert(num)\n track = num\n str = ''\n while track > 0\n if track - 1000 >= 0\n str += 'M'\n track -= 1000\n elsif track - 900 >= 0\n str += 'CM'\n track -= 900\n elsif track - 500 >= 0\n str += 'D'\n track -= 500\n elsif track - 100 >= 0\n str += 'C'\n track -= 100\n elsif track - 90 >= 0\n str += 'XC'\n track -= 90\n elsif track - 50 >= 0\n str += 'L'\n track -= 50\n elsif track - 10 >= 0\n str += 'X'\n track -= 10\n elsif track - 9 >= 0\n str += 'IX'\n track -= 9\n elsif track - 5 >= 0\n str += 'V'\n track -= 5\n elsif track - 4 >= 0\n str += 'IV'\n track -= 4\n elsif track - 1 >= 0\n str += 'I'\n track -= 1\n end\n end\n p str\nend", "def sci_not(number)\n return \"#{number}.00E0\" if number < 10\n answer = number.to_s\n counter = 0\n num_to_check = number\n \n while num_to_check > 10\n num_to_check /= 10.to_f\n counter += 1\n end\n \n get_last_num = ((number.to_f / (10**counter)).round(2).to_s)\n get_last_num[2].nil? ? (mid_num = 0) : (mid_num = get_last_num[2])\n get_last_num[3].nil? ? (last_num = 0) : (last_num = get_last_num[3]) \n \n return \"#{answer[0]}.#{mid_num}#{last_num}E#{counter}\"\n\nend", "def featured(number)\n number += 1\n number += 1 until number.odd? && number % 7 == 0\n\n loop do\n number_chars = number.to_s.split('')\n return number if number_chars.uniq == number_chars\n number += 14\n break if number >= 9_876_543_210\n end\n\n 'There is no possible number that fulfills those requirements.'\nend", "def featured(number)\n loop do\n number +=1\n characters = number.to_s.split('')\n if (number.odd?) && (number % 7 == 0) && (characters.uniq == characters) \n p number\n break\n end \n end \nend", "def featured(number)\n number += 1\n number += 1 until number.odd? && number % 7 == 0\n\n loop do\n number_chars = number.to_s.split('')\n return number if number_chars.uniq == number_chars\n number += 14\n break if number > 9_876_543_210\n end\n\n 'There is no possible number that fulfills those requirements.'\nend", "def to_s()\n result = nil\n \n if @number < 10\n result = WORD_DICT[@number]\n\n elsif number <= 99\n result = two_least_sig\n \n elsif number == 1000\n result = \"one thousand\"\n\n elsif number % 100 == 0\n result = hundreds_component\n\n elsif number <= 999\n result = \"#{hundreds_component} and #{two_least_sig}\"\n end\n\n return result\n end", "def sounds_for_time(time, args={})\n format = args.delete(:format) || 'dMYaHm'\n result = []\n format.each_char do |c|\n result += send(\"parse_#{FORMAT_TABLE[c]}\".to_sym, time)\n end\n result\n end", "def drum_sounds max_amp=0.5, layers =1\n tot = count\n amp = max_amp.to_f / tot #out of total drums\n tot.times do |i| \n this_amp = amp\n wei = (i+1).to_f/(tot+1)\n# this_amp = max_amp if wei < 0.4 # if bass-ish\n range = 0.0\n seqs= 1\n if wei > 0.7 # if hihat-ish\n this_amp /= 3 \n mapee(i).drum(wei, this_amp, 0.04, 1, layers)\n mapee(i)[0].snd.toneseq.tonepart(0).do_all {|tone| tone.saturations.start = 0.5 + rand(3).to_f/10}\n mapee(i)[0].snd.toneseq.do_all{|tp| tp.do_all {|tone|\n tone.detail = 10000\n tone.amp.exp = 0.12\n } }\n else\n if wei > 0.35 && wei < 0.65\n range = 0.5\n seqs= 2+rand(2)\n end\n mapee(i).drum(wei, this_amp, range, seqs, layers)\n end\n end\n end", "def short\n quality + number.to_s \n end", "def speak\n case\n when self <20\n [\"zero\", \"one\", \"two\", \"three\", \"four\", \"five\", \"six\", \"seven\", \"eight\", \"nine\", \"ten\",\n \"eleven\", \"twelve\", \"thirteen\", \"fourteen\", \"fifteen\", \"sixteen\", \"seventeen\", \"eighteen\", \"nineteen\" ][self]\n when self > 19 && self < 100 \n a = [\"twenty\", \"thirty\", \"forty\", \"fifty\", \"sixty\", \"seventy\", \"eighty\", \"ninety\"][self / 10 - 2]\n r = self % 10\n if r == 0\n a\n else\n a + \"-\" + r.speak\n end\n when self > 99 && self < 1000\n a = (self / 100).speak + \" hundred\"\n r = self % 100\n if r == 0\n a\n else\n a + \" and \" + r.speak\n end \n when self > 999 && self < 10000\n a = (self / 1000).speak + \" thousand\"\n r = self % 1000\n if r == 0\n a\n else\n a + ( r <100 ? \" and \" : \" \" ) + r.speak\n end \n else\n self\n end\n end", "def computer_hand\n hands = ['r', 'p', 's']\n ran = hands.sample\n ran.to_s\nend", "def featured2(number)\n number += 1\n number += 1 until number.odd? && number % 7 == 0\n\n loop do\n number_chars = number.to_s.split('')\n return number if number_chars.uniq == number_chars\n number += 14\n break if number >= 9_876_543_210\n end\n\n 'There is no possible number that fulfills those requirements.'\nend", "def pling_plang_plong num\n\n if num % 3 == 0\n print \"Pling \"\n end\n\n if num % 5 == 0\n print \"Plang \"\n end\n\n if num % 7 == 0\n print \"Plong \"\n end\n\n if ((num % 7 != 0 && num % 5 != 0) && num % 3 != 0)\n return num.to_s\n end\nend", "def three_of_a_kind_better_kicker\n [5.♠, 7.♡, J.♠, J.♣, J.♢]\n end", "def long_number_in_words\n magnitude_part_and_remainder.map(&:in_words).join(magnitude_separator)\n end", "def small_word_to_num(number)\n ones = {0=>0, 1=>3, 2=>3, 3=>5, 4=>4, 5=>4, 6=>3, 7=>5, 8=>5, 9=>4, 10=>3, 11=>3, 12=>6, 13=>8, 14=>8, 15=>7, 16=>7, 17=>9, 18=>8, 19=>8}\n tens = {0=>0, 1=>0, 2=>6, 3=>6, 4=>5, 5=>5, 6=>5, 7=>7, 8=>6, 9=>6}\n \n\n count = 0\n\n if number < 20\n return ones[number]\n else number < 99\n return tens[number/10] + ones[number%10]\n end\n\nend", "def the3(number)\n english = ''\n digits = {'0' => '', '1' => 'one', '2' => 'two', '3' => 'three', '4' => 'four', '5' => 'five',\n '6' => 'six', '7' => 'seven', '8' => 'eight', '9' => 'nine'}\n for i in 0..2\n case i\n when 0 then english += digits[number[i]] + (number[i] == '0' ? '' : ' hundred ')\n when 1 then english += number[i] == '0' ? '' : the2(number[1..2])\n when 2 then english += number[i - 1] == '1' ? '' : digits[number[i]]\n end\n end\n return english\nend", "def in_english\n num = self.to_i\n o = ''\n if num < 0\n o += 'negative '\n num = num.abs\n end\n if num.zero?\n o += 'zero'\n else\n sets = []\n i = 0\n f = false\n while !num.zero?\n num, r = num.divmod(1000)\n sets << LOTS[i] + (!sets.empty? ? (f ? ' and' : ',') : '') if !(r.zero? || i.zero?)\n f = true if i.zero? && r < 100\n\n sets << SUB_ONE_THOUSAND[r] if !r.zero?\n i = i.succ\n\n end\n o += sets.reverse.join(' ')\n end\n\n o += ' point ' + self.to_s.split(/\\./, 2).last.scan(/./).map { |n| SUB_ONE_THOUSAND[n.to_i] }.join(' ') if self.class == Float\n o\n end", "def background_digits(digit_string, digits='', path='digits')\n audio = []\n digit_string.to_s.scan(/./m) { |digit| audio << \"#{path}/#{digit}\" }\n begin\n response = background(audio, digits)\n rescue Exception\n raise\n end\n return response\n end", "def get_sounds()\n # Check if sounds have been specified.\n if @metadata[:voices] == nil\n # If not then choose the voices at random.\n voices = Array.new(get_number_of_voices)\n for voice in 0..voices.length - 1\n voices[voice] = [:pretty_bell, :saw, :prophet, :beep].choose\n end\n @metadata[:voices] = voices\n elsif @metadata[:voices].length < get_number_of_voices\n # If yes but not enough, append some more until it there are enough for the number of voices.\n for i in 1..(get_number_of_voices - @metadata[:voices].length)\n @metadata[:voices] << [:pretty_bell, :saw, :prophet, :beep].choose\n end\n end\n return @metadata[:voices]\n end", "def raindrops num\n output = \"\"\n output << \"Pling\" if num % 3 == 0\n output << \"Plang\" if num % 5 == 0\n output << \"Plong\" if num % 7 == 0\n output.empty? ? num.to_s : output\nend", "def codepoints\n Phonology.sounds.codepoints(features)\n end", "def sample_l\n format_num(l,2)\n end", "def rain num\n str = \"\"\n\n # If the number contains 3 as a factor, output 'Pling'.\n str += \"Pling\" if num % 3 == 0\n\n # If the number contains 5 as a factor, output 'Plang'.\n str += \"Plang\" if num % 5 == 0\n\n # If the number contains 7 as a factor, output 'Plong'.\n str += \"Plong\" if num % 7 == 0\n\n # If the number does not contain 3, 5, or 7 as a factor, output the number as a string.\n str = num.to_s if str.empty?\n\n str\nend", "def english_number original_number\r\n current_number = original_number\r\n exploded_number = []\r\n # Convert number into an array of multiples of base units\r\n CONVERSIONS.each do |base_pair|\r\n if current_number >= base_pair[:number] * 2\r\n # Enter the multiple and the base unit as elements if necessary\r\n exploded_number << current_number / base_pair[:number]\r\n exploded_number << base_pair\r\n current_number %= base_pair[:number]\r\n elsif current_number >= base_pair[:number]\r\n # Enter just the base unit if there's no integer multiple\r\n exploded_number << base_pair\r\n current_number %= base_pair[:number]\r\n end\r\n # Otherwise enter nothing\r\n end\r\n # Eg array [{1000000}, 507, {1000}, 5, 100, 30, 7]\r\n # Reduce array to an English translation\r\n english_result = exploded_number.reduce([\"\",:start]) { |text_string, base_pair|\r\n # Add a space unless it's the start of the string\r\n text_string[0] += ' ' unless text_string[1] == :start\r\n # Convert current number to English if it's a multiple\r\n if base_pair.class == Integer\r\n text_string[0] += english_number(base_pair)\r\n text_string[1] = :multiple\r\n elsif base_pair[:number] >= ONE_PREFIX_BOUNDARY\r\n # Otherwise, if it's >= 100 and preceding unit is not a multiple add 'one'\r\n text_string[0] += 'one ' unless text_string[1] == :multiple\r\n text_string[0] += base_pair[:name]\r\n text_string[1] = :above_boundary\r\n else\r\n # Otherwise, if it's <100 and transitioning from >=100, add 'and'\r\n text_string[0] += 'and ' if text_string[1] == :above_boundary\r\n text_string[0] += base_pair[:name]\r\n text_string[1] = :below_boundary\r\n end\r\n text_string\r\n }[0]\r\n return english_result\r\nend", "def featured(num)\n loop do\n num += num % 7 == 0 ? 7 : 1\n num_str = num.to_s.chars\n return num if num.odd? && num % 7 == 0 && num_str.uniq == num_str\n break if num >= 9_876_543_210\n end\n\n 'There is no possible number that fulfills those requirements.'\nend", "def look_and_see(num)\n numbers = num.to_s.split(\"\")\n result = loop_each_number(numbers)\n result.join\nend", "def the2(number)\n english = ''\n pre10 = {'10' => 'ten', '11' => 'eleven', '12' => 'twelve', '13' => 'thirteen', '14' => 'fourteen', '15' => 'fifteen', \n '16' => 'sixteen', '17' => 'seventeen', '18' => 'eighteen', '19' => 'nineteen'}\n pre_other = {'2' => 'twenty', '3' => 'thirty', '4' => 'fourty', '5' => 'fifty', '6' => 'sixty',\n '7' => 'seventy', '8' => 'eighty', '9' => 'ninety'}\n if number[0] == '1'\n english = pre10[number]\n else\n english = pre_other[number[0]] + (number[1] == '0' ? '' : '-')\n end\n return english\nend", "def featured(int)\n loop do \n int += 1\n if int.odd? && int % 7 == 0\n return int if int.to_s.chars.uniq == int.to_s.chars\n end\n break if int == 9_999_999\n end\n \"There is no possible number that fulfils those requirements\"\nend", "def homophonic\n smallest = 1\n return @voices.map { |voice| voice.split_into(smallest) }\n end", "def pling_plang_plong(magic_number)\n magicResult = ''\n # If the number contains 3 as a factor, output 'Pling'.\n if magic_number % 3 == 0\n magicResult += 'Pling '\n puts magicResult\n end\n # If the number contains 5 as a factor, output 'Plang'.\n if magic_number % 5 == 0\n magicResult.to_s += 'Plang'\n puts magicResult\n end\n # If the number contains 7 as a factor, output 'Plong'.\n if magic_number % 7 == 0\n magicResult += 'Plong'\n end\n # If the number does not contain 3, 5, or 7 as a factor, output the number as a string.\n if magicResult == ''\n magicResult = number.to_s\n end\nend", "def musical_score_types\n types = []\n types << 'MS' if %w[c d].include?(record.leader[6])\n return types\n end", "def convert_to_english(num, add_and = false)\n \n numparts = []\n hundreds = (num - (num % 100)) / 100\n \n num -= hundreds * 100\n\n if hundreds > 0\n numparts.push \"#{NAMEMAP[hundreds]} hundred\"\n numparts.push \"and\" if add_and\n end\n\n return numparts.first if num == 0\n\n tens = TENS.find { |i| num - i < 10 }\n ones = num - tens\n\n if tens == 10\n ones = num\n tens = 0\n end\n\n # numparts.push tens > 0 ? \"#{NAMEMAP[tens]}-#{NAMEMAP[ones]}\" : NAMEMAP[ones]\n\n tt = [\n tens > 0 ? NAMEMAP[tens] : nil,\n ones > 0 ? NAMEMAP[ones] : nil\n ].compact.join('-')\n \n numparts.push tt\n\n numparts.join(' ')\n end", "def unit\n [\"teaspoon\", \"cup\", \"pinch\"].sample\nend", "def strong_num(n)\n array = n.to_s.chars.map(&:to_i)\n sumarray = []\n array.each do |number|\n sum = (1..number).inject(:*) || 1\n sumarray << sum\n end\n sumarray.sum == n ? \"STRONG!!!!\" : \"Not Strong !!\"\nend", "def number_joy(n)\na = n.to_s.chars.map(&:to_i).reduce(:+)\nb = a.to_s.reverse.to_i\n(a * b) == n\nend", "def is_happy(number)\n appeared = Array.new\n result = number\n \n while true do\n if result.to_i == 1\n return 1\n end\n \n digits = result.to_s.split(//)\n \n result = digits.inject(0){|sum, d| sum + d.to_i ** 2}\n \n if appeared.include?(result)\n return 0\n end\n \n appeared << result\n end\nend", "def chord\n note_num = 4\n samples = []\n count = 0\n duration = nil\n\n while duration.nil?\n puts Rainbow(\"For how many seconds should your chord be played?\").blue\n duration = STDIN.gets.chomp.to_i\n if duration < 1 || duration > 40 || !duration.is_a?(Integer)\n puts Rainbow(\"Please enter a number of seconds greater than 1 and less than 150!\").yellow\n duration = nil\n end\n end\n\n while count <= note_num - 1\n frequency *= 2 if count == 3\n amplitude = 0.25\n num_samples = Notes.SAMPLE_RATE * duration\n\n case count\n when 0\n frequency = Notes.get_notes\n voice = generate_sinewave(num_samples, frequency, amplitude)\n voice_1 = voice\n when 1\n frequency = Notes.get_notes\n voice = generate_sinewave(num_samples, frequency, amplitude)\n voice_2 = voice\n when 2\n frequency = Notes.get_notes\n voice = generate_sinewave(num_samples, frequency, amplitude)\n voice_3 = voice\n when 3\n frequency = Notes.get_notes\n frequency *= 2\n voice = generate_sinewave(num_samples, frequency, amplitude)\n voice_4 = voice\n end\n\n if count >= 3\n samples = [voice_1, voice_2, voice_3, voice_4].transpose.map {|x| x.reduce(:+)}\n export_samples(samples.flatten)\n end\n count += 1\n end\n samples\nend", "def cpu_get_correct_digits(result)\n to_return = []\n result.each do |guess_digit, result_digit|\n if(result_digit == \"○\")\n to_return.push(guess_digit)\n end\n end\n to_return\n end", "def featured(num)\n num +=1 \n until num % 7 == 0 && num.odd?\n num += 1\n end\n\n loop do\n return num if num.to_s.chars.uniq == num.to_s.chars\n num += 14\n break if num >= 9_876_543_210\n end\n\n \"Your quest is doomed. There is no featured number beyond these walls.\"\nend", "def play_tones(tonestring)\r\n\t\texec(\"PlayTones\", tonestring)\r\n\tend", "def to_string(num)\n\tteens = %w[eleven twelve thirteen fourteen fifteen sixteen seventeen eighteen nineteen]\n\tones = %w[one two three four five six seven eight nine]\n\ttens = %w[ten twenty thirty forty fifty sixty seventy eighty ninety]\n\n\tdigits = num.to_s.split(\"\").map { |e| e.to_i }.reverse\n\twords = []\n\twrite_and = false\n\n\tdigits.each_with_index do |n, i|\n\t\tnext if n == 0\n\n\t\tif ((i == 2) || (i == 3))\n\t\t\tif write_and\n\t\t\t\twords.push(\"and\")\n\t\t\t\twrite_and = false\n\t\t\tend\n\t\tend\n\n\t\tcase i\n\t\twhen 0\n\t\t\tif (digits[i+1] == 1)\n\t\t\t\twords.push(teens[n-1])\n\t\t\t\tdigits[i+1] = 0\n\t\t\telse\n\t\t\t\twords.push(ones[n-1])\n\t\t\tend\n\n\t\t\twrite_and = true\n\t\twhen 1\n\t\t\twords.push(tens[n-1])\n\n\t\t\twrite_and = true\n\t\twhen 2\n\t\t\twords.push(\"hundred\")\n\t\t\twords.push(ones[n-1])\n\t\twhen 3\n\t\t\twords.push(\"thousand\")\n\t\t\twords.push(ones[n-1])\n\t\tend\n\tend\n\n\treturn words.reverse.join(\"\")\nend", "def cards_in_hand_to_string(cards)\n suits = [\"club\", \"diamond\", \"heart\", \"spade\"]\n numbers = [\"A\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\", \"9\", \"10\", \"J\", \"Q\", \"K\"]\n\n card_strings = []\n cards.each do |card|\n card_strings.push(suits[card / 13] + numbers[card % 13])\n end\n return card_strings.join(\", \")\nend", "def roman_numeral num\r\n\r\n\tthous = (num \t\t\t/ 1000)\r\n\thunds = (num \t% 1000 \t/ 100)\r\n\ttens = (num \t% 100 \t/ 10)\r\n\tones = (num \t% \t\t\t10)\r\n\r\n\troman = 'M' * thous\r\n\r\nend", "def get_voice_number\n self.phone_numbers.where([\"type in(2, 3)\"]).first\n end", "def pandigital_multiples\n 932718654\nend", "def dig_number(number)\n arr_dig = number.to_s.chars\n count = arr_dig.size\n arr_dig.map {|dig| dig.to_i ** count} \nend", "def to_hundreds(num)\n\tin_words = \"\"\n\tnum_to_words = Hash.new(0)\n\tnum_to_words = { 1=>\"One\",2=>\"Two\",3=>\"Three\",4=>\"Four\",5=>\"Five\",6=>\"Six\",7=>\"Seven\",8=>\"Eight\",9=>\"Nine\",10=>\"Ten\",11=>\"Eleven\",12=>\"Twelve\",13=>\"Thirteen\",14=>\"Fourteen\",15=>\"Fifteen\",16=>\"Sixteen\",17=>\"Seventeen\",18=>\"Eighteen\",19=>\"Nineteen\",20=>\"Twenty\",30=>\"Thirty\",40=>\"Fourty\",50=>\"Fifty\",60=>\"Sixty\",70=>\"Seventy\",80=>\"Eighty\",90=>\"Ninety\" }\n\n\tif num / 100 > 0\n\t\tin_words = num_to_words[num / 100] + \" Hundred \"\n\n\t\tif num % 10 != 0\n\t\t\tin_words = in_words + \"and \"\n\t\tend\n\t\tnum = num % 100\n\tend\n\n\tif num / 10 > 0\n\t\tif num / 10 == 1\n\t\t\tin_words = in_words + num_to_words[num] + \" \"\n\t\telsif num % 10 == 0\n\t\t\tin_words = in_words + num_to_words[num]\n\t\telse\n\t\t\tin_words = in_words + num_to_words[num / 10*10] + \" \" + num_to_words[num % 10]\n\t\tend\n\telsif num == 0\n\t\tin_words\n\telse \n\t\tin_words = in_words + num_to_words[num]\n\tend\n\n\tin_words\nend", "def conversion(number)\n words_hash = {0=>\"zero\",1=>\"one\",2=>\"two\",3=>\"three\",4=>\"four\",5=>\"five\",6=>\"six\",7=>\"seven\",8=>\"eight\",9=>\"nine\",\n 10=>\"ten\",11=>\"eleven\",12=>\"twelve\",13=>\"thirteen\",14=>\"fourteen\",15=>\"fifteen\",16=>\"sixteen\",\n 17=>\"seventeen\", 18=>\"eighteen\",19=>\"nineteen\",\n 20=>\"twenty\",30=>\"thirty\",40=>\"forty\",50=>\"fifty\",60=>\"sixty\",70=>\"seventy\",80=>\"eighty\",90=>\"ninety\"}\n if words_hash.has_key?number\n return words_hash[number] \n else\n num_string = number.to_s.split(//)\n while num_string.size > 0 \n if num_string.size == 2\n return(\"and\")\n return words_hash[(num_string.join.to_i) - (num_string.join.to_i)%10] \n num_string.shift\n end\n if num_string.size > 4\n return(words_hash[(num_string[0,2].join.to_i) - (num_string[0,2].join.to_i) % 10])\n else\n return(words_hash[num_string[0].to_i]) \n end\n return(scale[num_string.size])\n num_string.shift\n end\n end\n\nend", "def is_apocalyptic(number)\n num_str = (2**number).to_s\n array_of_instances = num_str.scan /666/\n times = array_of_instances.length\n case times\n when 0\n \"Safe\"\n when 1\n \"Single\"\n when 2\n \"Double\"\n when 3\n \"Triple\"\n else\n \"Fucked\"\n end\nend", "def solution(n)\r\n unit = UNITS[n % 10]\r\n dozen = DOZENS[(n % 100) / 10]\r\n hundred = HUNDREDS[(n % 1000) / 100]\r\n thousand = THOUSAND * (n / 1000)\r\n [thousand, hundred, dozen, unit].join\r\nend", "def oldrconv number\n\tset = [1,5,10,50,100,500,1000]\n\tx = 0\n\tlen = set.length\n\twhile x < len\n\t\tresult = number/set[x]\n\t\tbreak if result < 1\n\t\tsres = result\n\t\tx = x + 1\n\tend\n\t\n\tbase = set[x -1]\n\t\n\tif (base !=1)\t\n\tfresult = number%base\n\telse\n\tfresult = number%5\n\tend\n\n\tif (base == 1)\n\t\tform = 'I'* sres\n\telsif (base == 5) \n\t\tform = 'V' * sres\n\telsif (base == 10)\n\t\tform = 'X'* sres\n\telsif (base ==50)\n\t\tform = 'L'* sres\n\telsif (base ==100)\n\t\tform = 'C'* sres\n\telsif (base == 500)\n\t\tform = 'D'* sres\n\telsif (base == 1000)\n\t\tform = 'M'* result\n\tend\n\tif (fresult == 0)\n\t\tputs form\n\telsif (fresult != 0 && base != 1)\n\t\tputs form + 'I'*fresult\n\telse\n\t\tputs 'I' * fresult\n\tend\nend", "def featured(number)\n number += 1\n\n until number % 7 == 0 && number.odd?\n number += 1\n end\n\n loop do\n if number.digits.uniq == number.digits\n return number\n else\n number += 14\n end\n break if number.digits.size > 10\n end\n\n \"Error\"\nend", "def four_of_a_kind\n [6.♠, Q.♡, Q.♠, Q.♣, Q.♢]\n end", "def sheetlisten()\n n=0.5\n i=0\n while i<@songstr.length-1\n case @songstr[i]\n when 'a' \n play :a\n when 'b' \n play :b\n when 'c' \n play :c\n when 'd' \n play :d\n when 'e' \n play :e\n when 'f' \n play :f\n when 'g' \n play :g\n else\n if(!is_numeric?(@songstr[i]))\n puts(\"invalid char\")\n end\n end\n if(!is_numeric?(@songstr[i+1]))\n sleep 0.5\n else\n case @songstr[i+1]\n when '2' \n #for halfnote at regular speed: sleep 1\n n=1\n when '8' \n #for eighth\n n=0.25\n when '6' \n #for sixteenth note\n n=0.125\n end\n sleep n\n i+=1\n end\n i+=1\n end\n end", "def fancy_number(num)\n \"$\" + num.to_s.reverse.scan(/\\d{3}|.+/).join(\",\").reverse\n end", "def featured(i) # found digits method but only works > v2.4 so...\n i = i - i % 7\n loop do\n i += 7\n list = []\n x = i\n while x > 0 do\n list.unshift(x % 10)\n x /= 10\n end\n if list.length > 9; return \"There is no possible number that fulfills those requirements\" end\n if list == list.uniq; break end\n end \n i\nend", "def sound; end", "def oneMore(number)\r\n symbol = number.to_s(2)\r\n kol = symbol.count(\"1\")\r\n puts(kol)\r\n #puts(12344.to_s(2))\r\n #puts (kol) #не_смог_через_return\r\nend", "def eureka(num)\n num_arr = num.to_s.split('').collect{ |x| x.to_i }\n i = 0\n num1 = num_arr.reverse\n result1 = 0\n result2 = 0\n while i < num_arr.length\n result1 += num1[i] * (10 ** i)\n result2 += num_arr[i] ** (i + 1)\n i += 1\n end\n result1 == result2\n end", "def num_to_eng(int)\n ones_place = ['', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine']\n tens_place = ['', 'ten', 'twenty', 'thirty', 'forty', 'fifty', 'sixty', 'seventy', 'eighty', 'ninety']\n teens = ['ten', 'eleven', 'twelve', 'thirteen','fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen']\n \n array = int.to_s.split('').map {|x| x.to_i}\n\n if array.length == 1\n p ones_place[int]\n elsif array.length == 2 && array[0] == 1 && array[1] == 0\n p tens_place[1]\n elsif array.length == 2 && array[0] == 1\n p teens[array[1]]\n elsif array.length == 2 && array[0] > 1\n p tens_place[array[0]] + \" \" + ones_place[array[1]]\n elsif array.length == 3 && array[1] == 1\n p ones_place[array[0]] + \" hundred \" + teens[array[2]]\n elsif array.length == 3 && array[1] == 0\n p ones_place[array[0]] + \" hundred \" + ones_place[array[2]]\n elsif array.length == 3 && array[1] > 1\n p ones_place[array[0]] + \" hundred \" + tens_place[array[1]] + \" \" + ones_place[array[2]]\n end\nend", "def two_digit(number)\n dizaine = (number/10) * 10\n unit = (number % 10)\n if unit == 0\n return specific_word(dizaine)\n else\n return specific_word(dizaine) + \" \" + specific_word(unit)\n end\nend", "def positive_emoji\n %w[100 checkbox star thumbsup rocket].sample\n end", "def featured(number)\n max = 9_876_543_210\n number += 1\n number += 1 until number.odd? && number % 7 == 0\n loop do\n number_chars = number.to_s.chars\n if number_chars.size == number_chars.uniq.size\n return number\n end\n if number > max\n break\n end\n number += 14\n end\n \"ERROR! No next featured number!\"\nend", "def solution(number)\n roman_numeral = { 1 => 'I', 4 => 'IV', 5=> 'V', 6 => 'VI', 10=> 'X', 50=> 'L', 100=> 'C', 500=> 'D', 1000=> 'M' }\n numbers = number.digits.map.with_index{ |int, idx| int * 10**idx }\n numbers.map{ |number| roman_numeral[number] }.reverse.join\nend", "def return_word number\n small = %w(zero one two three four five six seven eight nine ten eleven twelve\n thirteen fourteen fifteen sixteen seventeen eighteen nineteen twenty)\n large = %w(zero ten twenty thirty forty fifty sixty seventy eighty ninety)\n\n if number <= 20\n return small[number]\n elsif number > 20 and number < 100\n q, r = number.divmod(10)\n string = large[q] + (r == 0 ? '' : small[r])\n return string\n elsif number >= 100 and number < 1000\n q, r = number.divmod(100)\n string = small[q] + ' hundred'\n string += ' and ' + return_word(r) if r > 0\n return string\n else\n return 'one thousand'\n end\nend", "def to_arabic num\n arabic = 0\n ROMAN_NUMBERS.each do |key, value|\n while num.start_with? value\n arabic += key\n num = num.slice(value.size, num.size)\n end\n end\n arabic\nend", "def speak_as_digits(element)\n speak_as(element, /[0-9]/, 'digits', method(:operation_speak_as_digits))\n end", "def singles_digits(digit)\n\t\n\tcase digit \n\t\t\n\t\twhen 1, 2, 6\n\t\t\treturn 3\n\t\twhen 3, 7, 8\n\t\t\treturn 5\n\t\twhen 4, 5, 9\n\t\t\treturn 4\n\t\telse\n\t\t\treturn 0\n\tend\nend", "def _digits\n\n _save = self.pos\n while true # choice\n _tmp = match_string(\"0\")\n break if _tmp\n self.pos = _save\n\n _save1 = self.pos\n while true # sequence\n _tmp = scan(/\\A(?-mix:[1-9])/)\n unless _tmp\n self.pos = _save1\n break\n end\n _tmp = scan(/\\A(?-mix:[0-9]*)/)\n unless _tmp\n self.pos = _save1\n end\n break\n end # end sequence\n\n break if _tmp\n self.pos = _save\n break\n end # end choice\n\n set_failed_rule :_digits unless _tmp\n return _tmp\n end", "def numeral(number)\n\tnumerals = {:I => 1, :V => 5, :X => 10, :L => 50, \n\t\t:C => 100, :D => 500, :M => 1000}\n\torder = [:M,:D,:C,:L,:X,:V,:I]\n\toutput = \"\"\n\torder.each do |n|\n\t\tif numerals[n] <= number\n\t\t\ttimes = number / numerals[n]\n\t\t\tremainder = number % numerals[n]\n\t\t\toutput += n.to_s * times\n\t\t\tnumber = remainder\n\t\tend\n\tend\n\toutput\nend", "def melody scales\n oct = rand(4) + 2\n scales.scale.map {|note|\n MidiCalc.new(Pitch.new(note, oct)).pc_to_midi\n }.shuffle\nend", "def interesting_number(number)\n number.each_char.map {|c| c.to_i}\n puts number\nend", "def crackle(number)\n\treturn \"Crackle\" if number % 3 == 0\nend", "def tone_info\n return @tone_info\n end", "def has_sch_sound (str)\n return str + str.slice!(0,3) + 'ay'\nend", "def featured(num)\n num += 1\n num += 1 until num.odd? && (num % 7).zero?\n loop do\n return num if num.to_s.chars.size == num.to_s.chars.uniq.size\n num += 14\n break if num > 9_876_543_210\n end\n 'There is no possible number that fulfills those requirements'\nend", "def featured(integer)\n return \"There is no possible number that fulfills those requirements\" if \n integer >= 9_876_543_210\n integer += 1\n until integer % 7 == 0 && integer.odd? && integer.digits.uniq! == nil\n integer += 1\n end\n integer\nend", "def featured(int)\n for num in (int + 1...9_999_999_999) \n return num if num.odd? && num % 7 == 0 && num.digits == num.digits.uniq\n end\n \"There is no possible number that fulfills those requirements\"\nend", "def roman_numeral num\n\n number1000s = (num / 1000)\n number100s = (num % 1000) / 100\n number10s = (num % 100) / 10\n number1s = (num % 10) / 1\n\n numberDs = (num % 1000) / 500\n numberCs = (num % 500) / 100\n numberLs = (num % 100) / 50\n numberXs = (num % 50) / 10\n numberVs = (num % 10) / 5\n numberIs = (num % 5) / 1\n\n result = \"M\" * number1000s\n\n if number100s == 9\n result = result + \"CM\"\n elsif number100s == 4\n result = result + \"CD\"\n else\n result = result + \"D\" * numberDs\n result = result + \"C\" * numberCs\n end\n\n if number10s == 9\n result = result + \"XC\"\n elsif number10s == 4\n result = result + \"XL\"\n else\n result = result + \"L\" * numberLs\n result = result + \"X\" * numberXs\n end\n\n if number1s == 9\n result = result + \"IX\"\n elsif number1s == 4\n result = result + \"IV\"\n else\n result = result + \"V\" * numberVs\n result = result + \"I\" * numberIs\n end\n\n result\n\nend", "def emma\n for i in 1..105\n\n \"pling\" if i%3 == 0\n \"plang\" if i%5 == 0\n \"plong\" if i%7 == 0\n i.to_s if i%7 != 0 && i%5 != 0 && i%3 != 0\n \" \"\n\n end\nend", "def one_hundred_symbols\n [\"A\", \"AA\", \"AAC\", \"AAN\", \"AAP\", \"AAT\", \"AAV\", \"AB\", \"ABB\", \"ABBV\", \"ABC\", \"ABEV\", \"ABG\",\n \"ABM\", \"ABR\", \"ABR-A\", \"ABR-B\", \"ABR-C\", \"ABRN\", \"ABT\", \"ABX\", \"AC\", \"ACC\", \"ACCO\", \"ACH\",\n \"ACM\", \"ACN\", \"ACP\", \"ACRE\", \"ACV\", \"ADC\", \"ADM\", \"ADNT\", \"ADS\", \"ADSW\", \"ADT\", \"ADX\", \"AEB\",\n \"AED\", \"AEE\", \"AEG\", \"AEH\", \"AEK\", \"AEL\", \"AEM\", \"AEO\", \"AEP\", \"AER\", \"AES\", \"AET\", \"AEUA\",\n \"AFB\", \"AFC\", \"AFG\", \"AFGE\", \"AFGH\", \"AFI\", \"AFL\", \"AFS-A\", \"AFS-B\", \"AFS-C\", \"AFS-D\", \"AFS-E\",\n \"AFS-F\", \"AFSS\", \"AFST\", \"AFT\", \"AG\", \"AGC\", \"AGCO\", \"AGD\", \"AGI\", \"AGM\", \"AGM-A\", \"AGM-B\",\n \"AGM-C\", \"AGM.A\", \"AGN\", \"AGN-A\", \"AGO\", \"AGO-B\", \"AGO-E\", \"AGO-F\", \"AGR\", \"AGRO\", \"AGS\", \"AGX\",\n \"AHC\", \"AHH\", \"AHL\", \"AHL-C\", \"AHL-D\", \"AHP\", \"AHP-B\", \"AHT\", \"AHT-D\", \"BKE\", \"AHT-F\", \"AHT-G\",\n \"AHT-H\"]\n end", "def to_pound(**options) = convert_to('pound', **options)", "def mathphrase(num)\n ops = %w[ plus minus times divide ]\n numbers = %w[ zero one two three four five six seven eight nine ]\n phrase = []\n \n num.times do\n phrase << numbers.sample\n phrase << ops.sample\n end\n \n phrase << numbers.sample\n puts phrase.join(' ')\nend", "def spell_one_nine(num)\n case num\n when 1\n \"one\"\n when 2\n \"two\"\n when 3\n \"three\"\n when 4\n \"four\"\n when 5\n \"five\"\n when 6\n \"six\"\n when 7\n \"seven\"\n when 8\n \"eight\"\n when 9\n \"nine\"\n end\nend", "def audio_formats\n @descriptive_detail.audio_formats\n end", "def fetch_number_strings(number,factor,and_flag)\n first_part = number % factor\n (and_flag) ? and_string = \" and \" : and_string = \" \"\n if factor.eql?(10)\n second_part = number - first_part\n \"#{generate_number_str(second_part,true)}#{and_string}#{int_strings[first_part]}\"\n else\n second_part = (number - first_part)/factor\n \"#{generate_number_str(second_part,true)} #{int_strings[factor]}#{and_string}#{generate_number_str(first_part,true)}\"\n end\n end", "def determine_how_many(number, unit)\n\t(number / unit).in_words\nend", "def MultiplicativePersistence(num)\n count = 0\n\n while num > 9\n num = num.to_s.split(\"\").map{|i| i.to_i}.inject(:*)\n count += 1\n end\n\n count\nend", "def convert_numbers(input_number, result)\n if input_number >= 1000\n input_number -= 1000\n result << \"M\"\n convert_numbers(input_number, result)\n elsif input_number >= 900\n result << \"CM\"\n input_number -= 900\n convert_numbers(input_number, result)\n elsif input_number >= 500\n input_number -= 500\n result << \"D\"\n convert_numbers(input_number, result)\n elsif input_number >= 400\n input_number -= 400\n result << \"CD\"\n convert_numbers(input_number, result) \n elsif input_number >= 100\n input_number -= 100\n result << \"C\"\n convert_numbers(input_number, result)\n elsif input_number >= 90\n input_number -= 90\n result << \"XC\"\n convert_numbers(input_number, result)\n elsif input_number >= 50\n input_number -= 50\n result << \"L\"\n convert_numbers(input_number, result)\n elsif input_number >= 40\n input_number -= 40\n result << \"XL\"\n convert_numbers(input_number, result)\n elsif input_number >= 10\n input_number -= 10\n result << \"X\"\n convert_numbers(input_number, result)\n elsif input_number >= 9\n input_number -= 9\n result << \"IX\"\n convert_numbers(input_number, result)\n elsif input_number >= 5\n input_number -= 5\n result << \"V\"\n convert_numbers(input_number, result)\n elsif input_number >= 4\n input_number -= 4\n result << \"IV\"\n convert_numbers(input_number, result)\n elsif input_number >= 1\n input_number -= 1\n result << \"I\"\n convert_numbers(input_number, result)\n else\n result\n end\nend", "def englishNumber(number)\n\tnumber_as_string = \"\" #this is the string we will return\n\tif number == 0\n\t\tnumber_as_string = \"zero\"\n\telsif number == 100\n\t\tnumber_as_string = \"one hundred\"\n\telsif \n\t\t#take care of 1-10\n\t\t#take care of 11-19\n\t\t#take care of 20,30,40,50,60,70,80,90\n\telse\n\t\tnumber_as_string = \"You didn't give me a number between 0 and 100\"\n\tend\n\t\t\n\n\treturn number_as_string\nend", "def round_1_sig_fig n \n get_first_digit(n) * 10**length(n)\nend", "def pling_plang_or_plong(value)\n plingplangplong = {\n 3 => 'Pling', \n 5 => 'Plang',\n 7 => 'Plong',\n }.map do |factor, noise|\n noise if value % factor == 0\n end\n plingplangplong.any? ? plingplangplong.join : value.to_s\nend", "def audio_types\n ldr6 = record.leader[6]\n\n types = []\n\n # Get the 8524* fields\n f8524 = record.fields('852').select{|f| f.indicator1 == '4'}\n\n # RC\n if %w[i j].include?(ldr6) && (bib_format == 'MU') \n @record.fields('007').map{|f| f.value}.each do |f|\n if f[1] == 'd' && f[12] == 'e'\n types << 'RC'\n break\n end\n end\n end\n\n f8524.each do |f|\n if (f['b'].upcase == 'MUSIC') && (f['j'] =~ /\\ACD/i)\n types << 'RC'\n break\n end\n end\n\n # RL\n\n if (bib_format == 'MU') && %w[i j].include?(ldr6) && self['007[1]'].include?('d')\n record.fields('300').each do |f|\n str = f.subfields.collect {|s| s.value}.join(' ')\n if (str =~ /DISC/i) && str =~ /33 1\\/3 RPM/i\n types << 'RL'\n break\n end\n end\n end\n\n\n f8524.each do |f|\n if (f['j'] =~ /\\ALP/i) &&\n ((f['b'].upcase == 'MUSIC') || (f['c'].upcase == 'MUSI'))\n types << 'RL'\n break\n end\n end\n\n # RM\n types << 'RM' if (ldr6 == 'j') && (bib_format == 'MU')\n\n # RS\n types << 'RS' if (ldr6 == 'i') && (bib_format == 'MU')\n\n # RU\n types << 'RU' if %w[i j].include?(ldr6) && (bib_format == 'MU')\n\n types.uniq!\n return types\n end", "def double_to_single_method\n #single_digit_array = []\n @multiplied_integer_array.each do |value|\n if value > 9\n value = value - 9\n @single_digit_array << value\n else\n value = value\n @single_digit_array << value\n end\n end\n return @single_digit_array\n end", "def handle_hundred (num)\n num2str=''\n if (num%100==0)\n num2str+=NUM_MAP[num/100]+ ' '+ NUM_MAP[100]\n elsif (num%100>=10 && num%100 <= 99)\n num2str+=NUM_MAP[num/100]+ ' '+ NUM_MAP[100]+ ' ' +handle_ten(num%100)\n elsif (num%100>=1 && num%100 <= 9)\n num2str+=NUM_MAP[num/100]+ ' '+ NUM_MAP[100]+ ' ' +handle_bit(num%100)\n end\n return num2str\nend", "def convert(c)\n out = []\n if c == 100\n out << \"C\"\n c -= 100\n end\n if c >= 90\n out << \"XC\"\n c -= 90\n end\n if c >= 50\n out << \"L\"\n c -= 50\n end\n if c >= 40\n out << \"XL\"\n c -= 40\n end\n while c >= 10\n out << \"X\"\n c -= 10\n end\n if c == 9\n out << \"IX\"\n c -= 9\n end\n if c >= 5\n out << \"V\"\n c -= 5\n end\n if c == 4\n out << \"IV\"\n c -= 4\n end\n while c > 0\n out << \"I\"\n c -= 1\n end\n puts \"Your number in Roman Numeral is:\"\n puts out.join\nend", "def soundVolume \n \"soundVolume\" \n end", "def to_words\n if is_a? Integer\n num = self\n else\n num = self.to_i\n end\n\n if (n = num.to_s.size) > 102\n return \"more than a googol! (#{n} digits)\"\n end\n\n whole_thing = []\n\n triplets = num.commatize.split(',')\n num_triplets = triplets.size\n\n triplets.each_with_index do |triplet, i|\n next if triplet.to_i == 0\n\n result = []\n\n tens, hunds = nil, nil\n\n digits = triplet.chars.to_a\n\n raise \"Error: Not a triplet: #{triplet}\" if digits.size > 3 or digits.size < 1\n\n if digits.size == 3\n digit = digits.shift.to_i\n hunds = NAMES_SMALL[digit] + \"-hundred\" if digit > 0\n digits.shift if digits.first == '0'\n end\n\n if digits.size == 2\n n = digits.join('').to_i\n\n if n > 0 and n < 20\n tens = NAMES_SMALL[n]\n elsif n > 0\n tens = NAMES_MEDIUM[digits.shift.to_i - 2]\n if digits.first != '0'\n tens += \"-\" + NAMES_SMALL[digits.shift.to_i]\n else\n digits.shift\n end\n end\n end\n\n if digits.size == 1\n n = digits.join('').to_i\n tens = NAMES_SMALL[n] if n > 0\n end\n\n if hunds\n if tens\n result << \"#{hunds} and #{tens}\"\n else\n result << hunds\n end\n else\n result << tens if tens\n end\n\n magnitude = (num_triplets - i)\n result << NAMES_LARGE[magnitude-2] if magnitude > 1\n\n whole_thing << result.join(' ') if result.any?\n end\n\n whole_thing.join ', '\n end" ]
[ "0.78654265", "0.5743771", "0.5627809", "0.562216", "0.56200093", "0.5618234", "0.5611642", "0.559557", "0.5577491", "0.5554955", "0.5546062", "0.55415964", "0.55395436", "0.5508156", "0.55058163", "0.5505423", "0.5496334", "0.5474896", "0.5428884", "0.542052", "0.54169273", "0.53813535", "0.5380892", "0.5370734", "0.535165", "0.53442836", "0.5340639", "0.533908", "0.5337248", "0.5332898", "0.5321145", "0.53203654", "0.53175193", "0.5316301", "0.53147024", "0.530679", "0.5305386", "0.53004026", "0.5299182", "0.5296991", "0.5288677", "0.52839094", "0.5283735", "0.5283618", "0.52710503", "0.52686083", "0.5266529", "0.5265729", "0.526154", "0.52600557", "0.52563345", "0.5252301", "0.5249345", "0.5248782", "0.5247874", "0.5242806", "0.523512", "0.5214652", "0.52133167", "0.5210592", "0.520895", "0.520671", "0.52031034", "0.5201233", "0.5197111", "0.5192046", "0.5189285", "0.5187905", "0.5184733", "0.5183617", "0.51773196", "0.5169158", "0.51659614", "0.51656777", "0.5162903", "0.51623076", "0.5161029", "0.5160748", "0.5158552", "0.51584524", "0.51566625", "0.51456", "0.5144953", "0.51422805", "0.5142122", "0.51393664", "0.51382476", "0.5134915", "0.5134588", "0.51334226", "0.5127474", "0.5124559", "0.5124466", "0.5124362", "0.5121148", "0.5116619", "0.5115332", "0.5115118", "0.51128674", "0.5108924" ]
0.8130094
0
Parses an "h" character from the main methods Returns the time in AM time.
def parse_hour_12h(time) sounds_for_number(time.strftime("%l")) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def H; cat @time.strftime('%H') end", "def parse_hour_24h(time)\n sounds_for_number(time.strftime(\"%k\"))\n end", "def hour() time[0] end", "def handle_hh_mm\n handle_sign\n @tzhour = @tokens[@index].get_tag(ScalarHour).type\n next_tag\n next_tag\n @tzminute = @tokens[@index].get_tag(ScalarMinute).type\n next_tag\n end", "def hour\n @hour ||= time_parts[0]\n end", "def timeConversion(s)\n if s =~ /[pP]/\n r = s.chomp(\"PM\")\n r = r.split(\":\")\n if r[0] == \"12\"\n r[0] = \"12\"\n else\n r[0] = (r[0].to_i + 12).to_s\n end \n \n r = r[0] + \":\" + r[1] + \":\" + r[2]\n elsif\n if s =~ /[aA]/\n r = s.chomp(\"AM\")\n r = r.split(\":\")\n if r[0] == \"12\"\n r[0] = \"00\"\n end\n r = r[0] + \":\" + r[1] + \":\" + r[2]\n end\n end\n p r\nend", "def hour() end", "def meridiem\n if self.hour > 12 || self.hour == 0\n :pm\n else\n :am\n end\n end", "def ampm\n if @t_hour <= 12\n return \"am\"\n else\n return \"pm\"\n end\n end", "def format_time\n hours = format_hour @hour\n minutes = format_minute @minutes\n ampm = @hour < 12 ? @@ampm_hash['a'] : @@ampm_hash['p']\n time = ''\n time += hours[0] + minutes[0] + ' ' + ampm[0] + \"\\n\"\n time += hours[1] + minutes[1] + ' ' + ampm[1] + \"\\n\"\n time += hours[2] + minutes[2] + ' ' + ampm[2] + \"\\n\"\n time\n end", "def timeConversion(s)\n # Write your code here\n b = s[-2..-1] == 'PM' ? 12 : 0\n p b\n h = s.split(':')[0]\n h = h.to_i%12 + b\n p h\n p h.to_s + s[2..-3]\nend", "def hour_time(unix_time)\n time = Time.at(unix_time)\n hour_string = time.strftime(\"%l %p\")\n hour_string[0] = '' if hour_string[0] == ' '\n hour_string\n end", "def convert_to_usable_time(xanga_time)\n arr = xanga_time.split(\" \")\n ret = arr[0]\n ret.insert(0,\"0\") if arr[0].length == 4 #pad left-most zero\n \n if arr[1] == \"PM\" #add 12 to it\n str = ret.slice(0,2)\n 0.upto(11){ str.succ! } \n ret[0,2] = str\n end\n \n ret.concat(\":00 +0000\")\n end", "def handle_hhmm\n handle_sign\n wide = @tokens[@index].get_tag(ScalarWide).type\n @tzhour = wide[0, 2].to_i\n @tzminute = wide[2, 4].to_i\n next_tag\n end", "def meridiem\n hour_24 / 12\n end", "def initialTimeDecimal(inputStartTime)\n split = inputStartTime.split(':')\n hours = split[0].to_i\n split = split[1].split(' ')\n #mins = split[0].to_i\n if (split[1] == \"PM\")\n hours += 12\n end\n return hours\nend", "def get_formatted_hours(stdTime)\n time = stdTime.split('-')\n hours = time[0].to_i\n if hours > 12\n hours = hours - 12\n hours = hours.to_s + \":\" + time[1].to_s + \"pm\"\n else\n hours = hours.to_s + \":\" + time[1].to_s + \"am\"\n end\n end", "def timeConversion(s)\n timeArr = s.split(\":\");\n hours = timeArr[0];\n minutes = timeArr[1];\n seconds = timeArr[2][0...-2]\n am_or_pm = timeArr[2][-2..-1]\n\n if am_or_pm == \"PM\" && hours != \"12\"\n hours = (hours.to_i + 12).to_s\n elsif am_or_pm == \"AM\" && hours == \"12\"\n hours = \"00\"\n end\n\n hours + \":\" + minutes + \":\" + seconds\nend", "def get_hour\n self.hr.strftime(\"%H\").to_i + self.hr.strftime(\"%M\").to_d/60\n end", "def hour_thc\n hour = @t_hour\n hour -= 12 if hour > 12\n return hour\n end", "def timeConversion(s)\n meridiem = s.scan(/[A-Z]+/).first\n s.gsub!(/[A-Z]+/, '')\n hour_str = s.scan(/\\d\\d/).first\n return s if hour_str == '12' && meridiem == 'PM'\n hour_int = hour_str.to_i\n new_hour =\n if meridiem == 'PM'\n (hour_int + 12) % 24\n else\n (hour_int - 12) % 12\n end\n s.gsub(/^\\d\\d/, new_hour.to_s.rjust(2, '0'))\nend", "def get_formatted_hour\n start_on.strftime(\"%H:%M\")\n end", "def parse_hms\n s0 = @scanner.pos\n s1 = match_digits!\n\n if s1 == :failed\n @scanner.pos = s0\n s0 = :failed\n elsif match_str(':') != :failed\n s3 = match_digits!\n if s3 == :failed\n @scanner.pos = s0\n s0 = :failed\n elsif match_str(':') != :failed\n s5 = match_digits!\n if s5 == :failed\n @scanner.pos = s0\n s0 = :failed\n else\n @reported_pos = s0\n s0 = { 'h' => s1.join.to_i, 'm' => s3.join.to_i, 's' => s5.join.to_i }\n end\n else\n @scanner.pos = s0\n s0 = :failed\n end\n else\n @scanner.pos = s0\n s0 = :failed\n end\n s0\n end", "def h # human\n \"%02d:%02d:%02d\" % [total/3600%24, total/60%60, total%60]\n end", "def parse_times( times )\n case times\n when /^\\s*any\\b/i\n Hour.new(\"12 AM\")..Hour.new(\"11 PM\")\n when /^\\s*before (\\d+ [AP]M)\\b/i\n Hour.new(\"12 AM\")..Hour.new($1)\n when /^\\s*after (\\d+ [AP]M)\\b/i\n Hour.new($1)..Hour.new(\"11 PM\")\n when /^\\s*(\\d+ [AP]M) to (\\d+ [AP]M)\\b/i\n Hour.new($1)..Hour.new($2)\n when /^\\s*not available\\b/i\n nil\n else\n raise \"Unexpected availability format.\"\n end\n end", "def hour_12\n self.strftime(\"%I:%M %p\")\n end", "def hour_12\n self.strftime(\"%I:%M %p\")\n end", "def parseTime(time)\n\t\tstr = time.to_s.rjust(4, \"0\")\n\t\t@hour = str[0..1].to_i\n\t\t@minute = str[2..3].to_i\n\tend", "def hour(system = :twenty_four_hour)\n hour = self.to_duration.to_units(:hour, :minute, :second).fetch(:hour)\n if system == :twelve_hour\n if hour == 0\n 12\n elsif hour > 12\n hour - 12\n else\n hour\n end\n elsif (system == :twenty_four_hour)\n hour\n else\n raise ArgumentError, \"system should be :twelve_hour or :twenty_four_hour\"\n end\n end", "def timeConversion(s)\n am_pm = s[(s.length - 2)..(s.length - 1)]\n s.gsub!(am_pm, '')\n hour = s[0..1]\n if hour == '12'\n if am_pm == 'AM'\n s[0..1] = '00'\n end\n elsif am_pm == 'PM'\n new_hour = (hour.to_i + 12).to_s\n s[0..1] = new_hour\n end\n result = s\nend", "def hour\n return @t_hour\n end", "def formatTime( time )\n hours = 0\n minutes = 0\n time[/(\\d+):(\\d+)/]\n hours = $1.to_i\n minutes = $2.to_i\n if time.include? \"PM\"\n if( hours!=12 )\n hours += 12\n end \n end \n if time.include? \"AM\"\n if (hours == 12)\n hours = 0\n end\n end\n # The year, month and day are irrelevant. \n return Time.local( 1, 1, 1, hours, minutes, 0)\n end", "def time\n @originalTime.gsub(/[ (AM|PM)]/, '').split(':').map(&:to_f)\n end", "def parse_am_pm(time)\n time.strftime(\"%P\") == \"am\" ? [sound_path(\"a-m.ul\")] : [sound_path(\"p-m.ul\")]\n end", "def parse_time(time)\n time = \"0#{time}\" if time.match(/^\\d:\\d\\d/)\n time = time.gsub(/u/, '') if utime?\n time = time.gsub(/s/, '') if stime?\n\n time\n end", "def bot(h, m, amOrpm)\n\t\tlastString = ''\t# this will save last string of digital clock\n\n\t\th = h.to_s\t# convert hour from integer to string\n\t\tif m < 10\t# if minute is less than 10\n\t\t\tm = m.to_s\t\n\t\t\tm = '0' + m.to_s\t# then put the 0 in front of minute (ex 09, 02, 03)\n\t\telse\n\t\t\tm = m.to_s\t\t# if not just convert from integer to string\n\t\tend\n\t\ttotal = h + m\t\t\t# I combined the hour and minute in one string\n\n\t\tfor i in 0..total.length-1 do\t# loop until total length\n\t\t\tif total[i] == '1'\t\t\t\t# if character is 1\n\t\t\t\tlastString = lastString + \" | \"\t\t# save proper bar\n\t\t\telsif total[i] == '4' || total[i] == '7'\t# if character is 4 or 7\n\t\t\t\tlastString = lastString + \" |\"\t\t# save proper bar\n\t\t\telsif total[i] == '2'\t\t\t\t# if character is 2\n\t\t\t\tlastString = lastString + \"|_ \"\t\t# save proper bar\n\t\t\telsif total[i] == '3' || total[i] == '5' || total[i] == '9'\t# if character is 3 or 5 or 9\n\t\t\t\tlastString = lastString + \" _|\"\t\t# save proper bar\n\t\t\telsif total[i] == '6' || total[i] == '8'\t# if character is 6 or 8\n\t\t\t\tlastString = lastString + \"|_|\"\t\t# save proper bar\n\t\t\telsif total[i] == '0'\t\t\t\t# if character is 0\n\t\t\t\tlastString = lastString + \"|_|\"\t\t# save proper bar\n\t\t\tend\n\n\t\t\tif h.length == i+1\t\t\t\t# if hour length is matched with i\n\t\t\t\tlastString = lastString + \".\"\t\t# then save dot which represent colon in the future\n\t\t\tend\n\t\tend\n\t\t\n\t\t# AM and PM is consist of same string in middle and top, except bot. So in the bot method we will decide A or P (AM or PM)\n\t\tif amOrpm == 1\t\t\t\t\t\t# This decide last bar of PM or Am\n\t\t\tlastString = lastString + \" | \"\t\t# it is P\n\t\telse\n\t\t\tlastString = lastString + \" | |\"\t\t# It is A\n\t\tend\n\tend", "def opening_hour\n 11 # 11am\n end", "def timeConversion(s)\n #\n # Write your code here.\n #\n split = s.split(\":\")\n pm = split[2][-2,2]\n split[2] = split[2][0,2]\n if pm == \"AM\" && split[0] == \"12\"\n split[0] = 00\n end\n if pm == \"PM\"\n split[0] = split[0].to_i + 12\n if split[0] == 24\n split[0] = 12\n end\n end\n\n split[0] = split[0].to_s.rjust(2,\"0\")\n split[1] = split[1].to_s.rjust(2,\"0\")\n split[2] = split[2].to_s.rjust(2,\"0\")\n\n p split.join(\":\")\nend", "def tt(time, format=:short); '13:37'; end", "def format_hours\n\n self.breakHours = self.breakHours[1,self.breakHours.length] if !self.breakHours.blank? && self.breakHours =~ /0[0-9]:/\n\t\tself.hours = self.hours[1,hours.length] if !self.hours.blank? && self.hours =~ /0[0-9]:/\n \n\tend", "def hour\n if @time\n @time.hour\n elsif @datetime\n @datetime.hour\n else\n to_time.hour\n end\n end", "def hour\n if @time\n @time.hour\n elsif @datetime\n @datetime.hour\n else\n to_time.hour\n end\n end", "def hour\n if @time\n @time.hour\n elsif @datetime\n @datetime.hour\n else\n to_time.hour\n end\n end", "def formattime()\n\t\tamOrpm = 0\t# this will decide P or A\n\t\ttopResult = ''\t# save top string from the digital clock\n\t\tmiddleResult = ''\t# save middle string from the digital clock\n\t\tbotResult = ''\t\t# save bot string from the digital clock\n\t\t\n\t\thour = gethour().to_i\t# change to integer for hour\n\t\tmin = getminute().to_i\t# change to integer for minute\n\t\t@amOrpm = @t.strftime(\"%p\")\t# this get PM or AM, I used strftime method which provided from the Time class\n\t\tif @amOrpm == \"PM\"\t# if PM\t\n\t\t\tamOrpm = 1\t# save 1\n\t\telse\t\t\t# if AM\n\t\t\tamOrpm = 0\t# save 0\n\t\tend\n\n\t\ttopResult = top(hour,min)\t# Save top string from the digital clock with top method\n\t\tmiddleResult = middle(hour,min)\t# Save middle string from the digital clock with middle method\n\t\tbotResult = bot(hour,min, amOrpm)\t# Save bot string from the digital clock with bot method\n\t\ttotal = topResult + middleResult + botResult\t# save all the string in the total\n\t\treturn total\t\t\t# return total represent perfect digital time\n\tend", "def hour\n @hour\n end", "def timeConversion(s)\n time = s.split(':')\n if time.first == \"12\" && time.last[-2..-1] == 'AM'\n time[0] = time.first.to_i - 12\n elsif time.first != \"12\" && time.last[-2..-1] == 'PM'\n time[0] = time.first.to_i + 12\n end\n time.last.gsub!(/[PM AM pm am]/, '')\n # required to add leading zero to pass all hackerrank tests\n time[0] = '0' + time[0].to_s if time[0].to_s.size <= 1\n time.join(\":\")\nend", "def hours() 60 * minutes end", "def middle(h, m)\n\n\t\tmiddleString = ''\t# return middle string from digital clock\n\t\n\t\th = h.to_s\t# convert hour from integer to string\n\t\tif m < 10\t# if minute is less than 10\n\t\t\tm = m.to_s\t\n\t\t\tm = '0' + m.to_s\t# then put the 0 in front of minute (ex 09, 02, 03)\n\t\telse\n\t\t\tm = m.to_s\t\t# if not just convert from integer to string\n\t\tend\n\t\ttotal = h + m\t\t\t# I combined the hour and minute in one string\n\t\t\n\t\tfor i in 0..total.length-1 do\t\t# loop until toal length\n\t\t\tif total[i] == '1'\t\t# if character is 1\n\t\t\t\tmiddleString = middleString + \" | \"\t# put proper bar\n\t\t\telsif total[i] == '7'\t\t# if character is 7\n\t\t\t\tmiddleString = middleString + \" |\"\t# put proper bar\n\t\t\telsif total[i]=='2' || total[i] == '3'\t\t# if character is 2 or 3\n\t\t\t\tmiddleString = middleString + \" _|\"\t# put proper bar\n\t\t\telsif total[i]=='4' || total[i] == '8' || total[i] == '9' \t#if character is 4 or 8 or 9\n\t\t\t\tmiddleString = middleString + \"|_|\"\t# put proper bar\n\t\t\telsif total[i]=='5' || total[i] == '6'\t\t# if character is 5 or 6\n\t\t\t\tmiddleString = middleString + \"|_ \"\t# put proper bar\n\t\t\telsif total[i]=='0'\t\t\t\t# if character is 0\n\t\t\t\tmiddleString = middleString + \"| |\"\t# put proper bar\n\t\t\tend\n\n\t\t\tif h.length == i+1\t\t\t\t# if hour length is matched with i\n\t\t\t\tmiddleString = middleString + \".\"\t# then put save which represent colon in the future\n\t\t\tend\n\t\tend\n\t\tmiddleString = middleString + \" |_|\"\t\t\t# this is the bar for P or A(PM or AM) at the last\n\t\tmiddleString = middleString + \"\\n\"\t\t\t# put new line\n\t\treturn middleString\t\t\t\t\t# return final middle string\n\tend", "def time_conversion s\n converted_time = \"#{(s[0,2].to_i + 12) % 12}#{s[2,6]}\".rjust(8, \"0\")\n converted_time = \"#{converted_time[0,2].to_i + 12}#{s[2,6]}\" if s[8,9] == \"PM\"\n converted_time\n end", "def parse_time(row)\n raw_time = row[1]\n if raw_time\n time = \"#{raw_time[0..4]}#{raw_time[-2..-1].downcase!}\"\n\n # remove leading 0\n time = time[1..-1] if time[0] === '0'\n time\n else\n nil\n end\nend", "def format_time_from_hour hour\n hrs = hour.to_i\n min = ((hour - hrs) * 60.0 + 0.5).to_i\n \"%2d:%02d\" % [hrs, min]\n end", "def time\n result = veeamconfig('schedule', 'show', '--jobId', get_job_id).lines\n # get the time\n t = result[1].strip.split(': ')[1]\n # split hours and minutes (will use these to pad first)\n bits = t.split(':')\n # pad both the hour and the minute with a zero if needed\n bits[0] = \"%02d\" % bits[0]\n bits[1] = \"%02d\" % bits[1]\n\n # return the joined value (HH:MM)\n bits.join(':')\n end", "def hour\n components.hour\n end", "def time_hour; Time.now.hour; end", "def strptime_to_hour(time)\n Time.strptime(time, '%m/%d/%Y %k').hour\nend", "def absolute_hour(seconds); end", "def first_hour\n\t\tday_begins_at.strftime '%l%P'\n\tend", "def hours_flight\n stamp = @raw_data[:FlightDuration].split(\"PT\")[1]\n stamp.split(\"H\")[0].to_i\n rescue\n nil\n end", "def time\n\tTime.new.strftime(\"%k:%M\")\nend", "def parse_time\n s0 = @scanner.pos\n if match_str('(') == :failed\n @scanner.pos = s0\n s0 = :failed\n else\n match_spaces\n s3 = parse_ms\n if s3 == :failed\n @scanner.pos = s0\n s0 = :failed\n else\n match_spaces\n if match_str('/') == :failed\n @scanner.pos = s0\n s0 = :failed\n else\n match_spaces\n s5 = parse_hms\n s5 = parse_ms(with_hour: true) if s5 == :failed\n if s5 == :failed\n @scanner.pos = s0\n s0 = :failed\n else\n match_spaces\n if match_str(')') == :failed\n @scanner.pos = s0\n s0 = :failed\n else\n @reported_pos = s0\n s0 = { 'now' => s3, 'total' => s5 }\n end\n end\n end\n end\n end\n s0\n end", "def time_string(string)\n\n times=string.split(\":\")\n puts times.inspect\n residual= times[1].to_f/2\n hour_degrees=times[0].to_i*30+residual\n minutes=times[1].to_i*6\n return hour_degrees-minutes\n\nend", "def as_hours hours\n minutes = hours.to_f * 60.0\n sprintf \"%d:%02d\", (minutes / 60).to_i, (minutes % 60).to_i\n end", "def format_hour(hour)\n first, second = hour.divmod(10)\n first_digit_arr = @@number_strs[first]\n second_digit_arr = @@number_strs[second]\n [\n first_digit_arr[0] + second_digit_arr[0] + ' ',\n first_digit_arr[1] + second_digit_arr[1] + '.',\n first_digit_arr[2] + second_digit_arr[2] + '.'\n ]\n end", "def hours\n value_parts[0]\n end", "def hours\n value_parts[0]\n end", "def hour\n # seconds_since_start_of_day / H_SECS\n (seconds_since_start_of_day / H_SECS).to_i\n end", "def handle_sy_sm_sd_h_m_s_hh_mm\n handle_sy_sm_sd_h_m_s\n handle_hh_mm\n end", "def hour\n return self.to_a[IDX_HOUR]\n end", "def hourglass\r\n return 188\r\n end", "def hour(date)\n h = date.minute >= 30 ? date.hour + 1 : date.hour\n time = [pad(h.to_s), '00'].join(':')\n [time, day(date)].join(' ')\n end", "def hour_in\n @hour_in ||= time_in.hour\n end", "def findTime(t, k)\n \n # convert the given time in minutes\n minutes = ((((t[0]).ord() - ('0').ord())* 10 + \n (t[1]).ord() - ('0').ord())* 60 + \n (((t[3]).ord() - ('0').ord()) * 10 + \n (t[4]).ord() - ('0').ord()));\n \n # Add K to current minutes\n minutes += k\n \n # Obtain the new hour\n # and new minutes from minutes\n hour = (minutes / 60).to_i % 24\n \n min = minutes % 60\n \n output = \"\"\n \n # Print the hour in appropriate format\n if (hour < 10)\n output = output + 0 + hour.to_s + \":\") \n else\n output = output + hour.to_s + \":\")\n end \n \n # Print the minute in appropriate format\n if (min < 10)\n puts (0 + min.to_s) \n else\n puts (min.to_s)\n end \n\n\n end", "def fmt_time(dt) _format_dt dt, H12_M_PM end", "def format_time(time)\n first_colon = time.index(':')\n if first_colon.nil? \n #if it's not a time\n return time\n end\n second_colon = time.index(':', first_colon + 1)\n result = time[0, first_colon]\n if result.length < 2\n result = \"0#{result}\"\n end\n if second_colon.nil?\n second_colon = time.length\n end\n result += time[first_colon, second_colon - first_colon]\n return result\nend", "def change_time(hour,min)\n Time.strptime(\"#{hour}:#{min}\", \"%H:%M\")\n end", "def parse_time(time)\n zone = ActiveSupport::TimeZone.new(\"Central Time (US & Canada)\")\n time = time.in_time_zone(zone)\n hour = (time.hour - START_TIME) * HOUR_SHIFT\n minute = time.min / TIME_INTERVAL\n return hour + minute # this is the index used in the schedule\n end", "def prep_time_passed\n return \"7:34\"\n end", "def hour?\n at_match[2].present?\n end", "def end_hour\n hour = DateTime.parse(self.datep.to_s).hour\n hour_s = ''\n if(hour < 10)\n hour_s = '0'+hour.to_s\n else\n hour_s = hour.to_s\n end\n hour_s\n end", "def hour\n hour? ? at_hour : super\n end", "def convert_minutes_into_hours(minutes)\n hour = minutes / 60\n min = minutes % 60\nputs \" #{hour}:#{min}\"\nend", "def hours\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 24 )\n hours_start_index = @input.index\n\n success = false # flag used for memoization\n\n begin\n # rule memoization\n if @state.backtracking > 0 and already_parsed_rule?( __method__ )\n success = true\n return \n end\n # at line 303:8: ( 'H' | 'h' ) ( 'O' | 'o' ) ( 'U' | 'u' ) ( 'R' | 'r' ) ( 'S' | 's' )\n if @input.peek( 1 ).between?( T__36, T__37 )\n @input.consume\n @state.error_recovery = false\n else\n @state.backtracking > 0 and raise( ANTLR3::Error::BacktrackingFailed )\n\n mse = MismatchedSet( nil )\n raise mse\n end\n\n\n if @input.peek( 1 ).between?( T__18, T__19 )\n @input.consume\n @state.error_recovery = false\n else\n @state.backtracking > 0 and raise( ANTLR3::Error::BacktrackingFailed )\n\n mse = MismatchedSet( nil )\n raise mse\n end\n\n\n if @input.peek( 1 ).between?( T__14, T__15 )\n @input.consume\n @state.error_recovery = false\n else\n @state.backtracking > 0 and raise( ANTLR3::Error::BacktrackingFailed )\n\n mse = MismatchedSet( nil )\n raise mse\n end\n\n\n if @input.peek( 1 ).between?( T__20, T__21 )\n @input.consume\n @state.error_recovery = false\n else\n @state.backtracking > 0 and raise( ANTLR3::Error::BacktrackingFailed )\n\n mse = MismatchedSet( nil )\n raise mse\n end\n\n\n if @input.peek( 1 ).between?( T__38, T__39 )\n @input.consume\n @state.error_recovery = false\n else\n @state.backtracking > 0 and raise( ANTLR3::Error::BacktrackingFailed )\n\n mse = MismatchedSet( nil )\n raise mse\n end\n\n\n\n success = true\n\n rescue ANTLR3::Error::RecognitionError => re\n report_error(re)\n recover(re)\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 24 )\n memoize( __method__, hours_start_index, success ) if @state.backtracking > 0\n\n end\n \n return \n end", "def hours\n _nudge[0]\n end", "def handle_sy_sm_sd_h_m_s_ss_hh_mm\n handle_sy_sm_sd_h_m_s_ss\n handle_hh_mm\n end", "def time_format\n return :time12 if new_us_user?\n\n clock_type == '12h' ? :time12 : :time24\n end", "def formatted_hours\n as_hours hours\n end", "def formatted_hours\n as_hours hours\n end", "def parse_time(str)\n return nil if str.nil? || str.empty?\n\n # make sure it looks like a time\n # i've seen arrive time cells just be \"+1\" and nothing else\n return nil unless str =~ /^\\d+:\\d+/\n\n format = str =~ /[ap]m$/ ? '%I:%M %P' : '%H:%M'\n Time.strptime(str, format).to_time\n end", "def time(text)\n scan(text, TIME, :time)\n end", "def in_international_time\n self.strftime(\"%H:%M\")\n end", "def determine_current_hour\n\tcurrent_time = Time.new\n\tcurrent_hour = current_time.hour\nend", "def format_time_h_mm(time_string)\n\t\tresult = ''\n\t\ttime_duration = Time.at(time_string).utc\n\n\t\t#format hours\n\t\tif time_duration.hour > 0\n \t\t\tresult << time_duration.strftime('%k hour')\n \t\t\tif time_duration.hour > 1\n\t\t\t\tresult << 's'\n\t\t\tend\n\t\t\tresult << ', '\n \t\tend\n\n \t\t#format minutes\n \t\tif time_duration.min > 0\n \t\t\tresult << time_duration.strftime('%M minute')\n\t \t\tif time_duration.min > 1\n\t\t\t\tresult << 's'\n\t \t\tend\n \t\tend\n\tend", "def time_date_hm ; time_date && time_date.strftime(\"%H:%M\") ; end", "def select_custom_hearing_time(time)\n click_dropdown(text: /^(#{time} (A|a)(M|m)( E)?)/, name: \"optionalHearingTime0\")\n end", "def after_midnight(str)\n str = str.split(\":\")\n h = str[0].to_i % 24\n m = str[1].to_i\n minutes = (h * 60) + m \nend", "def to_s\n if @am_pm\n display = @current.strftime(\"%I:%M\")\n else\n display = @current.strftime(\"%H:%M\")\n end\n @fuzz.times { display.sub!(/\\d(\\D*)$/, '~\\1') } if @fuzz > 0\n display\n end", "def hours\n fail \"A value is required for #{__method__}\" unless @value\n return \"0/#{@value}:0:0\"\n end", "def calculate_hours_minutes(output)\n return unless output =~ /up\\s+(\\d+):-?(\\d+),/\n\n SECS_IN_AN_HOUR * Regexp.last_match(1).to_i +\n SECS_IN_A_MINUTE * Regexp.last_match(2).to_i\n end", "def opening_hour\n 11\n end", "def timeConversion(s)\n if s[-2..-1] == \"PM\"\n return s[0..-3] if s[0..1] == \"12\"\n converted_time = (s[0..1].to_i + 12).to_s\n converted_time + s[2..-3]\n else\n return \"00\" + s[2..-3] if s[0..1] == \"12\"\n s[0..-3]\n end\nend" ]
[ "0.7094211", "0.7090618", "0.6903488", "0.668905", "0.657391", "0.6550515", "0.64884627", "0.64142066", "0.6390568", "0.6379535", "0.6333664", "0.6332102", "0.63174045", "0.6297677", "0.627675", "0.62738585", "0.6267137", "0.625339", "0.62307733", "0.6205075", "0.61759114", "0.6162899", "0.6149888", "0.6139307", "0.613054", "0.6128621", "0.6128621", "0.6122491", "0.611718", "0.61032283", "0.6063077", "0.6056817", "0.6053459", "0.60531455", "0.60440457", "0.60400796", "0.6037562", "0.6009035", "0.59895116", "0.5981881", "0.5970997", "0.5970997", "0.5970997", "0.59570193", "0.5935234", "0.5931228", "0.5929467", "0.59143937", "0.5912953", "0.5892803", "0.58857346", "0.5860423", "0.5833362", "0.5829059", "0.58209246", "0.58030313", "0.57939595", "0.57902926", "0.5761062", "0.57493645", "0.57344174", "0.57317626", "0.572982", "0.5721615", "0.5721615", "0.5717757", "0.57176423", "0.57142335", "0.56942564", "0.5691903", "0.56915236", "0.56872845", "0.56710935", "0.5668314", "0.5664682", "0.5659581", "0.56560147", "0.56508654", "0.56299585", "0.56270623", "0.56185144", "0.5614348", "0.5611274", "0.5610069", "0.56078523", "0.5606045", "0.5606045", "0.56009865", "0.5594998", "0.5587206", "0.558519", "0.5575073", "0.5574396", "0.5573279", "0.55723083", "0.55707556", "0.5559206", "0.5554548", "0.5550743", "0.55447286" ]
0.7338429
0
Parses an "H" character from the main methods Returns the time in 24 time.
def parse_hour_24h(time) sounds_for_number(time.strftime("%k")) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parse_hour_12h(time)\n sounds_for_number(time.strftime(\"%l\"))\n end", "def H; cat @time.strftime('%H') end", "def hour() time[0] end", "def handle_hh_mm\n handle_sign\n @tzhour = @tokens[@index].get_tag(ScalarHour).type\n next_tag\n next_tag\n @tzminute = @tokens[@index].get_tag(ScalarMinute).type\n next_tag\n end", "def meridiem\n hour_24 / 12\n end", "def hour\n @hour ||= time_parts[0]\n end", "def parse_hms\n s0 = @scanner.pos\n s1 = match_digits!\n\n if s1 == :failed\n @scanner.pos = s0\n s0 = :failed\n elsif match_str(':') != :failed\n s3 = match_digits!\n if s3 == :failed\n @scanner.pos = s0\n s0 = :failed\n elsif match_str(':') != :failed\n s5 = match_digits!\n if s5 == :failed\n @scanner.pos = s0\n s0 = :failed\n else\n @reported_pos = s0\n s0 = { 'h' => s1.join.to_i, 'm' => s3.join.to_i, 's' => s5.join.to_i }\n end\n else\n @scanner.pos = s0\n s0 = :failed\n end\n else\n @scanner.pos = s0\n s0 = :failed\n end\n s0\n end", "def timeConversion(s)\n # Write your code here\n b = s[-2..-1] == 'PM' ? 12 : 0\n p b\n h = s.split(':')[0]\n h = h.to_i%12 + b\n p h\n p h.to_s + s[2..-3]\nend", "def handle_hhmm\n handle_sign\n wide = @tokens[@index].get_tag(ScalarWide).type\n @tzhour = wide[0, 2].to_i\n @tzminute = wide[2, 4].to_i\n next_tag\n end", "def hour() end", "def h # human\n \"%02d:%02d:%02d\" % [total/3600%24, total/60%60, total%60]\n end", "def timeConversion(s)\n if s =~ /[pP]/\n r = s.chomp(\"PM\")\n r = r.split(\":\")\n if r[0] == \"12\"\n r[0] = \"12\"\n else\n r[0] = (r[0].to_i + 12).to_s\n end \n \n r = r[0] + \":\" + r[1] + \":\" + r[2]\n elsif\n if s =~ /[aA]/\n r = s.chomp(\"AM\")\n r = r.split(\":\")\n if r[0] == \"12\"\n r[0] = \"00\"\n end\n r = r[0] + \":\" + r[1] + \":\" + r[2]\n end\n end\n p r\nend", "def hour_thc\n hour = @t_hour\n hour -= 12 if hour > 12\n return hour\n end", "def time_string(string)\n\n times=string.split(\":\")\n puts times.inspect\n residual= times[1].to_f/2\n hour_degrees=times[0].to_i*30+residual\n minutes=times[1].to_i*6\n return hour_degrees-minutes\n\nend", "def initialTimeDecimal(inputStartTime)\n split = inputStartTime.split(':')\n hours = split[0].to_i\n split = split[1].split(' ')\n #mins = split[0].to_i\n if (split[1] == \"PM\")\n hours += 12\n end\n return hours\nend", "def hourglass\r\n return 188\r\n end", "def hours\n value_parts[0]\n end", "def hours\n value_parts[0]\n end", "def clock_hour24(clock)\n to_clock24(clock).hour\nend", "def get_hour\n self.hr.strftime(\"%H\").to_i + self.hr.strftime(\"%M\").to_d/60\n end", "def hours_flight\n stamp = @raw_data[:FlightDuration].split(\"PT\")[1]\n stamp.split(\"H\")[0].to_i\n rescue\n nil\n end", "def hours\n _nudge[0]\n end", "def timeConversion(s)\n meridiem = s.scan(/[A-Z]+/).first\n s.gsub!(/[A-Z]+/, '')\n hour_str = s.scan(/\\d\\d/).first\n return s if hour_str == '12' && meridiem == 'PM'\n hour_int = hour_str.to_i\n new_hour =\n if meridiem == 'PM'\n (hour_int + 12) % 24\n else\n (hour_int - 12) % 12\n end\n s.gsub(/^\\d\\d/, new_hour.to_s.rjust(2, '0'))\nend", "def hour_12\n self.strftime(\"%I:%M %p\")\n end", "def hour_12\n self.strftime(\"%I:%M %p\")\n end", "def middle(h, m)\n\n\t\tmiddleString = ''\t# return middle string from digital clock\n\t\n\t\th = h.to_s\t# convert hour from integer to string\n\t\tif m < 10\t# if minute is less than 10\n\t\t\tm = m.to_s\t\n\t\t\tm = '0' + m.to_s\t# then put the 0 in front of minute (ex 09, 02, 03)\n\t\telse\n\t\t\tm = m.to_s\t\t# if not just convert from integer to string\n\t\tend\n\t\ttotal = h + m\t\t\t# I combined the hour and minute in one string\n\t\t\n\t\tfor i in 0..total.length-1 do\t\t# loop until toal length\n\t\t\tif total[i] == '1'\t\t# if character is 1\n\t\t\t\tmiddleString = middleString + \" | \"\t# put proper bar\n\t\t\telsif total[i] == '7'\t\t# if character is 7\n\t\t\t\tmiddleString = middleString + \" |\"\t# put proper bar\n\t\t\telsif total[i]=='2' || total[i] == '3'\t\t# if character is 2 or 3\n\t\t\t\tmiddleString = middleString + \" _|\"\t# put proper bar\n\t\t\telsif total[i]=='4' || total[i] == '8' || total[i] == '9' \t#if character is 4 or 8 or 9\n\t\t\t\tmiddleString = middleString + \"|_|\"\t# put proper bar\n\t\t\telsif total[i]=='5' || total[i] == '6'\t\t# if character is 5 or 6\n\t\t\t\tmiddleString = middleString + \"|_ \"\t# put proper bar\n\t\t\telsif total[i]=='0'\t\t\t\t# if character is 0\n\t\t\t\tmiddleString = middleString + \"| |\"\t# put proper bar\n\t\t\tend\n\n\t\t\tif h.length == i+1\t\t\t\t# if hour length is matched with i\n\t\t\t\tmiddleString = middleString + \".\"\t# then put save which represent colon in the future\n\t\t\tend\n\t\tend\n\t\tmiddleString = middleString + \" |_|\"\t\t\t# this is the bar for P or A(PM or AM) at the last\n\t\tmiddleString = middleString + \"\\n\"\t\t\t# put new line\n\t\treturn middleString\t\t\t\t\t# return final middle string\n\tend", "def format_hours\n\n self.breakHours = self.breakHours[1,self.breakHours.length] if !self.breakHours.blank? && self.breakHours =~ /0[0-9]:/\n\t\tself.hours = self.hours[1,hours.length] if !self.hours.blank? && self.hours =~ /0[0-9]:/\n \n\tend", "def hours() 60 * minutes end", "def hour(system = :twenty_four_hour)\n hour = self.to_duration.to_units(:hour, :minute, :second).fetch(:hour)\n if system == :twelve_hour\n if hour == 0\n 12\n elsif hour > 12\n hour - 12\n else\n hour\n end\n elsif (system == :twenty_four_hour)\n hour\n else\n raise ArgumentError, \"system should be :twelve_hour or :twenty_four_hour\"\n end\n end", "def hour\n components.hour\n end", "def convert_to_usable_time(xanga_time)\n arr = xanga_time.split(\" \")\n ret = arr[0]\n ret.insert(0,\"0\") if arr[0].length == 4 #pad left-most zero\n \n if arr[1] == \"PM\" #add 12 to it\n str = ret.slice(0,2)\n 0.upto(11){ str.succ! } \n ret[0,2] = str\n end\n \n ret.concat(\":00 +0000\")\n end", "def as_hours hours\n minutes = hours.to_f * 60.0\n sprintf \"%d:%02d\", (minutes / 60).to_i, (minutes % 60).to_i\n end", "def hour_time(unix_time)\n time = Time.at(unix_time)\n hour_string = time.strftime(\"%l %p\")\n hour_string[0] = '' if hour_string[0] == ' '\n hour_string\n end", "def get_formatted_hours(stdTime)\n time = stdTime.split('-')\n hours = time[0].to_i\n if hours > 12\n hours = hours - 12\n hours = hours.to_s + \":\" + time[1].to_s + \"pm\"\n else\n hours = hours.to_s + \":\" + time[1].to_s + \"am\"\n end\n end", "def timeConversion(s)\n #\n # Write your code here.\n #\n split = s.split(\":\")\n pm = split[2][-2,2]\n split[2] = split[2][0,2]\n if pm == \"AM\" && split[0] == \"12\"\n split[0] = 00\n end\n if pm == \"PM\"\n split[0] = split[0].to_i + 12\n if split[0] == 24\n split[0] = 12\n end\n end\n\n split[0] = split[0].to_s.rjust(2,\"0\")\n split[1] = split[1].to_s.rjust(2,\"0\")\n split[2] = split[2].to_s.rjust(2,\"0\")\n\n p split.join(\":\")\nend", "def hour\n return @t_hour\n end", "def format_time\n hours = format_hour @hour\n minutes = format_minute @minutes\n ampm = @hour < 12 ? @@ampm_hash['a'] : @@ampm_hash['p']\n time = ''\n time += hours[0] + minutes[0] + ' ' + ampm[0] + \"\\n\"\n time += hours[1] + minutes[1] + ' ' + ampm[1] + \"\\n\"\n time += hours[2] + minutes[2] + ' ' + ampm[2] + \"\\n\"\n time\n end", "def timeConversion(s)\n timeArr = s.split(\":\");\n hours = timeArr[0];\n minutes = timeArr[1];\n seconds = timeArr[2][0...-2]\n am_or_pm = timeArr[2][-2..-1]\n\n if am_or_pm == \"PM\" && hours != \"12\"\n hours = (hours.to_i + 12).to_s\n elsif am_or_pm == \"AM\" && hours == \"12\"\n hours = \"00\"\n end\n\n hours + \":\" + minutes + \":\" + seconds\nend", "def bot(h, m, amOrpm)\n\t\tlastString = ''\t# this will save last string of digital clock\n\n\t\th = h.to_s\t# convert hour from integer to string\n\t\tif m < 10\t# if minute is less than 10\n\t\t\tm = m.to_s\t\n\t\t\tm = '0' + m.to_s\t# then put the 0 in front of minute (ex 09, 02, 03)\n\t\telse\n\t\t\tm = m.to_s\t\t# if not just convert from integer to string\n\t\tend\n\t\ttotal = h + m\t\t\t# I combined the hour and minute in one string\n\n\t\tfor i in 0..total.length-1 do\t# loop until total length\n\t\t\tif total[i] == '1'\t\t\t\t# if character is 1\n\t\t\t\tlastString = lastString + \" | \"\t\t# save proper bar\n\t\t\telsif total[i] == '4' || total[i] == '7'\t# if character is 4 or 7\n\t\t\t\tlastString = lastString + \" |\"\t\t# save proper bar\n\t\t\telsif total[i] == '2'\t\t\t\t# if character is 2\n\t\t\t\tlastString = lastString + \"|_ \"\t\t# save proper bar\n\t\t\telsif total[i] == '3' || total[i] == '5' || total[i] == '9'\t# if character is 3 or 5 or 9\n\t\t\t\tlastString = lastString + \" _|\"\t\t# save proper bar\n\t\t\telsif total[i] == '6' || total[i] == '8'\t# if character is 6 or 8\n\t\t\t\tlastString = lastString + \"|_|\"\t\t# save proper bar\n\t\t\telsif total[i] == '0'\t\t\t\t# if character is 0\n\t\t\t\tlastString = lastString + \"|_|\"\t\t# save proper bar\n\t\t\tend\n\n\t\t\tif h.length == i+1\t\t\t\t# if hour length is matched with i\n\t\t\t\tlastString = lastString + \".\"\t\t# then save dot which represent colon in the future\n\t\t\tend\n\t\tend\n\t\t\n\t\t# AM and PM is consist of same string in middle and top, except bot. So in the bot method we will decide A or P (AM or PM)\n\t\tif amOrpm == 1\t\t\t\t\t\t# This decide last bar of PM or Am\n\t\t\tlastString = lastString + \" | \"\t\t# it is P\n\t\telse\n\t\t\tlastString = lastString + \" | |\"\t\t# It is A\n\t\tend\n\tend", "def parseTime(time)\n\t\tstr = time.to_s.rjust(4, \"0\")\n\t\t@hour = str[0..1].to_i\n\t\t@minute = str[2..3].to_i\n\tend", "def hour\n @hour\n end", "def hour\n # seconds_since_start_of_day / H_SECS\n (seconds_since_start_of_day / H_SECS).to_i\n end", "def handle_sy_sm_sd_h_m_s_hh_mm\n handle_sy_sm_sd_h_m_s\n handle_hh_mm\n end", "def findTime(t, k)\n \n # convert the given time in minutes\n minutes = ((((t[0]).ord() - ('0').ord())* 10 + \n (t[1]).ord() - ('0').ord())* 60 + \n (((t[3]).ord() - ('0').ord()) * 10 + \n (t[4]).ord() - ('0').ord()));\n \n # Add K to current minutes\n minutes += k\n \n # Obtain the new hour\n # and new minutes from minutes\n hour = (minutes / 60).to_i % 24\n \n min = minutes % 60\n \n output = \"\"\n \n # Print the hour in appropriate format\n if (hour < 10)\n output = output + 0 + hour.to_s + \":\") \n else\n output = output + hour.to_s + \":\")\n end \n \n # Print the minute in appropriate format\n if (min < 10)\n puts (0 + min.to_s) \n else\n puts (min.to_s)\n end \n\n\n end", "def time_conversion s\n converted_time = \"#{(s[0,2].to_i + 12) % 12}#{s[2,6]}\".rjust(8, \"0\")\n converted_time = \"#{converted_time[0,2].to_i + 12}#{s[2,6]}\" if s[8,9] == \"PM\"\n converted_time\n end", "def hours\n fail \"A value is required for #{__method__}\" unless @value\n return \"0/#{@value}:0:0\"\n end", "def after_midnight(str)\n str = str.split(\":\")\n h = str[0].to_i % 24\n m = str[1].to_i\n minutes = (h * 60) + m \nend", "def calculate_hours_minutes(output)\n return unless output =~ /up\\s+(\\d+):-?(\\d+),/\n\n SECS_IN_AN_HOUR * Regexp.last_match(1).to_i +\n SECS_IN_A_MINUTE * Regexp.last_match(2).to_i\n end", "def hour\n return self.to_a[IDX_HOUR]\n end", "def time_format\n return :time12 if new_us_user?\n\n clock_type == '12h' ? :time12 : :time24\n end", "def digital_hour(i)\n rex(:digital_hour, i, /(2[0-4]|[01][0-9]):?[0-5]\\d/)\n end", "def format_time_from_hour hour\n hrs = hour.to_i\n min = ((hour - hrs) * 60.0 + 0.5).to_i\n \"%2d:%02d\" % [hrs, min]\n end", "def handle_sy_sm_sd_h_m_s_ss_hh_mm\n handle_sy_sm_sd_h_m_s_ss\n handle_hh_mm\n end", "def time\n @originalTime.gsub(/[ (AM|PM)]/, '').split(':').map(&:to_f)\n end", "def strptime_to_hour(time)\n Time.strptime(time, '%m/%d/%Y %k').hour\nend", "def formattime()\n\t\tamOrpm = 0\t# this will decide P or A\n\t\ttopResult = ''\t# save top string from the digital clock\n\t\tmiddleResult = ''\t# save middle string from the digital clock\n\t\tbotResult = ''\t\t# save bot string from the digital clock\n\t\t\n\t\thour = gethour().to_i\t# change to integer for hour\n\t\tmin = getminute().to_i\t# change to integer for minute\n\t\t@amOrpm = @t.strftime(\"%p\")\t# this get PM or AM, I used strftime method which provided from the Time class\n\t\tif @amOrpm == \"PM\"\t# if PM\t\n\t\t\tamOrpm = 1\t# save 1\n\t\telse\t\t\t# if AM\n\t\t\tamOrpm = 0\t# save 0\n\t\tend\n\n\t\ttopResult = top(hour,min)\t# Save top string from the digital clock with top method\n\t\tmiddleResult = middle(hour,min)\t# Save middle string from the digital clock with middle method\n\t\tbotResult = bot(hour,min, amOrpm)\t# Save bot string from the digital clock with bot method\n\t\ttotal = topResult + middleResult + botResult\t# save all the string in the total\n\t\treturn total\t\t\t# return total represent perfect digital time\n\tend", "def parse_time\n s0 = @scanner.pos\n if match_str('(') == :failed\n @scanner.pos = s0\n s0 = :failed\n else\n match_spaces\n s3 = parse_ms\n if s3 == :failed\n @scanner.pos = s0\n s0 = :failed\n else\n match_spaces\n if match_str('/') == :failed\n @scanner.pos = s0\n s0 = :failed\n else\n match_spaces\n s5 = parse_hms\n s5 = parse_ms(with_hour: true) if s5 == :failed\n if s5 == :failed\n @scanner.pos = s0\n s0 = :failed\n else\n match_spaces\n if match_str(')') == :failed\n @scanner.pos = s0\n s0 = :failed\n else\n @reported_pos = s0\n s0 = { 'now' => s3, 'total' => s5 }\n end\n end\n end\n end\n end\n s0\n end", "def rational_hour(seconds); end", "def get_formatted_hour\n start_on.strftime(\"%H:%M\")\n end", "def time\n\tTime.new.strftime(\"%k:%M\")\nend", "def prep_time_passed\n return \"7:34\"\n end", "def tt(time, format=:short); '13:37'; end", "def clock_hour12(clock)\n to_clock12(clock).hour\nend", "def parse_time(row)\n raw_time = row[1]\n if raw_time\n time = \"#{raw_time[0..4]}#{raw_time[-2..-1].downcase!}\"\n\n # remove leading 0\n time = time[1..-1] if time[0] === '0'\n time\n else\n nil\n end\nend", "def hour\n if @time\n @time.hour\n elsif @datetime\n @datetime.hour\n else\n to_time.hour\n end\n end", "def hour\n if @time\n @time.hour\n elsif @datetime\n @datetime.hour\n else\n to_time.hour\n end\n end", "def hour\n if @time\n @time.hour\n elsif @datetime\n @datetime.hour\n else\n to_time.hour\n end\n end", "def format_hour(hour)\n first, second = hour.divmod(10)\n first_digit_arr = @@number_strs[first]\n second_digit_arr = @@number_strs[second]\n [\n first_digit_arr[0] + second_digit_arr[0] + ' ',\n first_digit_arr[1] + second_digit_arr[1] + '.',\n first_digit_arr[2] + second_digit_arr[2] + '.'\n ]\n end", "def time_hour; Time.now.hour; end", "def absolute_hour(seconds); end", "def formatted_hours\n as_hours hours\n end", "def formatted_hours\n as_hours hours\n end", "def hours\n fail \"A value is required for #{__method__}\" unless @value\n fail 'A value cannot be > 24' if @value > 24\n fail 'A value cannot be <= 0' if @value <= 0\n return 'daily' if @value == 24\n\n \"0/#{@value}:0:0\"\n end", "def before_midnight(str)\nhours, minutes = str.split(':').map{|char| char.to_i}\ntime = hours * MINUTES_PER_HOUR + minutes\ntime % MINUTES_PER_DAY\nend", "def convert_minutes_into_hours(minutes)\n hour = minutes / 60\n min = minutes % 60\nputs \" #{hour}:#{min}\"\nend", "def parse_time(time)\n time = \"0#{time}\" if time.match(/^\\d:\\d\\d/)\n time = time.gsub(/u/, '') if utime?\n time = time.gsub(/s/, '') if stime?\n\n time\n end", "def hour(date)\n h = date.minute >= 30 ? date.hour + 1 : date.hour\n time = [pad(h.to_s), '00'].join(':')\n [time, day(date)].join(' ')\n end", "def timeConversion(s)\n time = s.split(':')\n if time.first == \"12\" && time.last[-2..-1] == 'AM'\n time[0] = time.first.to_i - 12\n elsif time.first != \"12\" && time.last[-2..-1] == 'PM'\n time[0] = time.first.to_i + 12\n end\n time.last.gsub!(/[PM AM pm am]/, '')\n # required to add leading zero to pass all hackerrank tests\n time[0] = '0' + time[0].to_s if time[0].to_s.size <= 1\n time.join(\":\")\nend", "def from_hms\n nums = split(':')\n\n nums[-1] = nums[-1].to_f if nums[-1] =~ /\\d+\\.\\d+/ # convert fractional seconds to a float\n nums.map! { |n| n.is_a?(String) ? n.to_i : n } # convert the rest to integers\n\n nums_and_units = nums.reverse.zip %w[seconds minutes hours days]\n nums_and_units.map { |num, units| num.send(units) }.sum\n end", "def from_hms\n nums = split(':')\n\n nums[-1] = nums[-1].to_f if nums[-1] =~ /\\d+\\.\\d+/ # convert fractional seconds to a float\n nums.map! { |n| n.is_a?(String) ? n.to_i : n } # convert the rest to integers\n\n nums_and_units = nums.reverse.zip %w[seconds minutes hours days]\n nums_and_units.map { |num, units| num.send(units) }.sum\n end", "def hrs\n self / 24.0\n end", "def end_hour\n hour = DateTime.parse(self.datep.to_s).hour\n hour_s = ''\n if(hour < 10)\n hour_s = '0'+hour.to_s\n else\n hour_s = hour.to_s\n end\n hour_s\n end", "def dec_to_hours(x)\n if x.floor.to_s.length == 1\n return \"0\"+\"#{x.floor}\"\n else return x.floor\n end\n end", "def time_string(h, m, s)\n n = []\n n[0] = h\n n[1] = m \n n[2] = s\n \n # all greater than \n if n[0] >= 10 && n[1] >= 10 && n[2] >= 10\n return \"#{n[0]}:#{n[1]}:#{n[2]}\"\n\n # less, greater, greater\n elsif n[0] < 10 && n[1] >= 10 && n[2] >= 10\n return \"0#{n[0]}:#{n[1]}:#{n[2]}\"\n\n # less, less, greater\n elsif n[0] < 10 && n[1] < 10 && n[2] >= 10\n return \"0#{n[0]}:0#{n[1]}:#{n[2]}\"\n\n # all less than\n elsif n[0] < 10 && n[1] < 10 && n[2] < 10\n return \"0#{n[0]}:0#{n[1]}:0#{n[2]}\"\n\n # greater, less, less \n elsif n[0] >= 10 && n[1] < 10 && n[2] < 10\n return \"#{n[0]}:0#{n[1]}:0#{n[2]}\"\n\n # greater, greater, less \n elsif n[0] >= 10 && n[1] >= 10 && n[2] < 10\n return \"#{n[0]}:#{n[1]}:0#{n[2]}\"\n\n # greater, less, greater \n elsif n[0] >= 10 && n[1] < 10 && n[2] >= 10\n return \"#{n[0]}:0#{n[1]}:#{n[2]}\"\n\n # less, greater, less\n elsif n[0] < 10 && n[1] >= 10 && n[2] < 10\n return \"0#{n[0]}:#{n[1]}:0#{n[2]}\"\n\n else \n return \"Enter a positive integer\" \n end\nend", "def parse_day(time)\n sounds_for_number(time.strftime(\"%-d\"))\n end", "def meridiem\n if self.hour > 12 || self.hour == 0\n :pm\n else\n :am\n end\n end", "def parse_ms(with_hour: false)\n s0 = @scanner.pos\n s1 = match_digits!\n if s1 == :failed\n @scanner.pos = s0\n s0 = :failed\n elsif match_str(':') != :failed\n s3 = match_digits!\n if s3 == :failed\n @scanner.pos = s0\n s0 = :failed\n else\n @reported_pos = s0\n m = s1.join.to_i\n s = s3.join.to_i\n if with_hour\n h = m / 60\n m = m % 60\n s0 = { 'h' => h, 'm' => m, 's' => s }\n else\n s0 = { 'm' => m, 's' => s }\n end\n end\n else\n @scanner.pos = s0\n s0 = :failed\n end\n s0\n end", "def generic_forecast_hour_str(forecast_hour_str)\n # \"11-12\" => \"one hour long\"\n forecast_hour_str.gsub(/^\\d+-\\d+\\s+hour/) do |range_str|\n start, stop = range_str.split(/[\\- ]/)[0..1].map(&:to_i)\n int_to_english(stop - start) + \" hour long\"\n end.gsub(/\\s*\\d+\\s*/, \"\") # \"7 hour fcst\" => \"hour fcst\"\nend", "def after_midnight(str)\n if str[0..1] == '24'\n hour = 0\n else\n hour = str[0..1].to_i\n end\n (hour * 60) + str[3..4].to_i\nend", "def parse_times( times )\n case times\n when /^\\s*any\\b/i\n Hour.new(\"12 AM\")..Hour.new(\"11 PM\")\n when /^\\s*before (\\d+ [AP]M)\\b/i\n Hour.new(\"12 AM\")..Hour.new($1)\n when /^\\s*after (\\d+ [AP]M)\\b/i\n Hour.new($1)..Hour.new(\"11 PM\")\n when /^\\s*(\\d+ [AP]M) to (\\d+ [AP]M)\\b/i\n Hour.new($1)..Hour.new($2)\n when /^\\s*not available\\b/i\n nil\n else\n raise \"Unexpected availability format.\"\n end\n end", "def after_midnight(str)\n hours, minutes = str.split(\":\").map(&:to_i)\n \n hours < 24 ? (hours * 60) + minutes : 0\nend", "def opening_hour\n 11\n end", "def time_emoji\n %w[clockface hourglass alarmclock stopwatch watch].sample\n end", "def gethour()\n\t\treturn @hour\n\tend", "def hour_cell(half_hour)\n if half_hour % 2 == 0\n content_tag :td, :class => \"day_hour_cell\", \n :width => \"1%\", :rowspan => 2 do\n if (half_hour/2 == 0)\n ''\n elsif (half_hour/2 < 12)\n (half_hour/2).to_s + 'am'\n elsif (half_hour/2 == 12)\n 'Noon'\n elsif (half_hour/2 > 12)\n ((half_hour/2) - 12).to_s + 'pm'\n end\n end\n else\n nil\n end\n end", "def opening_hour\n 11 # 11am\n end", "def hours\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 24 )\n hours_start_index = @input.index\n\n success = false # flag used for memoization\n\n begin\n # rule memoization\n if @state.backtracking > 0 and already_parsed_rule?( __method__ )\n success = true\n return \n end\n # at line 303:8: ( 'H' | 'h' ) ( 'O' | 'o' ) ( 'U' | 'u' ) ( 'R' | 'r' ) ( 'S' | 's' )\n if @input.peek( 1 ).between?( T__36, T__37 )\n @input.consume\n @state.error_recovery = false\n else\n @state.backtracking > 0 and raise( ANTLR3::Error::BacktrackingFailed )\n\n mse = MismatchedSet( nil )\n raise mse\n end\n\n\n if @input.peek( 1 ).between?( T__18, T__19 )\n @input.consume\n @state.error_recovery = false\n else\n @state.backtracking > 0 and raise( ANTLR3::Error::BacktrackingFailed )\n\n mse = MismatchedSet( nil )\n raise mse\n end\n\n\n if @input.peek( 1 ).between?( T__14, T__15 )\n @input.consume\n @state.error_recovery = false\n else\n @state.backtracking > 0 and raise( ANTLR3::Error::BacktrackingFailed )\n\n mse = MismatchedSet( nil )\n raise mse\n end\n\n\n if @input.peek( 1 ).between?( T__20, T__21 )\n @input.consume\n @state.error_recovery = false\n else\n @state.backtracking > 0 and raise( ANTLR3::Error::BacktrackingFailed )\n\n mse = MismatchedSet( nil )\n raise mse\n end\n\n\n if @input.peek( 1 ).between?( T__38, T__39 )\n @input.consume\n @state.error_recovery = false\n else\n @state.backtracking > 0 and raise( ANTLR3::Error::BacktrackingFailed )\n\n mse = MismatchedSet( nil )\n raise mse\n end\n\n\n\n success = true\n\n rescue ANTLR3::Error::RecognitionError => re\n report_error(re)\n recover(re)\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 24 )\n memoize( __method__, hours_start_index, success ) if @state.backtracking > 0\n\n end\n \n return \n end", "def first_hour\n\t\tday_begins_at.strftime '%l%P'\n\tend", "def change_time(hour,min)\n Time.strptime(\"#{hour}:#{min}\", \"%H:%M\")\n end", "def hours\n seconds / 3600\n end" ]
[ "0.752976", "0.7320571", "0.68377846", "0.6787406", "0.6606236", "0.6604363", "0.65456736", "0.65254277", "0.64779127", "0.64444906", "0.63874817", "0.6375319", "0.6333604", "0.6297861", "0.62934923", "0.6269661", "0.62559444", "0.62559444", "0.6208015", "0.6201986", "0.61660564", "0.6143796", "0.6135854", "0.6100668", "0.6100668", "0.6095449", "0.6077459", "0.60676134", "0.606723", "0.60596824", "0.6052816", "0.60447925", "0.60421515", "0.60380924", "0.6033495", "0.6026632", "0.6018383", "0.5966868", "0.5964771", "0.59364986", "0.5918191", "0.59147847", "0.58961535", "0.5892763", "0.5890398", "0.5868152", "0.585361", "0.58329576", "0.5825578", "0.5822626", "0.58209574", "0.5810827", "0.581045", "0.57969797", "0.57861507", "0.5778768", "0.5777987", "0.57775396", "0.5776756", "0.5769953", "0.5763138", "0.5758096", "0.57555693", "0.5746104", "0.5744899", "0.5744899", "0.5744899", "0.57333666", "0.5727664", "0.5714127", "0.57119787", "0.57119787", "0.5697511", "0.5682896", "0.5679575", "0.5678523", "0.56755435", "0.5673016", "0.5672309", "0.5672309", "0.5661503", "0.5659221", "0.56529486", "0.564884", "0.5632207", "0.56288624", "0.5622963", "0.5617271", "0.56168926", "0.56132853", "0.56127495", "0.56008667", "0.55906147", "0.55889493", "0.5585972", "0.55793893", "0.5568676", "0.5568446", "0.55676645", "0.55661917" ]
0.7876351
0
Parses a "Y" character from the main methods Returns the numbers for the year in 4 digit format
def parse_year(time) year = time.strftime("%Y").to_i sounds_for_number(year / 100) + sounds_for_number(year % 100) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def year_via_ruby_parsing\n return unless orig_date_str =~ /\\d\\d/ # need at least 2 digits\n # need more in string than only 2 digits\n return if orig_date_str.match(/^\\d\\d$/) || orig_date_str.match(/^\\D*\\d\\d\\D*$/)\n return if orig_date_str =~ /\\d\\s*B.C./ # skip B.C. dates\n\n date_obj = Date.parse(orig_date_str)\n date_obj.year.to_s\n rescue ArgumentError\n nil # explicitly want nil if date won't parse\n end", "def yn(year)\n return year if year.size == 4\n\n y = Date.today.year.to_s[2..4].to_i + 1\n case year.to_i\n when 0...y then \"20#{year}\"\n when y..99 then \"19#{year}\"\n end\n end", "def post_year\n chars = @date.split('')\n chars.pop(4).join('').to_i\n end", "def convert_yy_2_yyyy( birth_year )\n return nil if birth_year.nil?\n # Already a 4-digit year?\n if birth_year.to_i > 1900\n birth_year\n\n # 2-digit year?\n elsif birth_year.to_i < 100\n # We keep track upto M105:\n if DateTime.now.year - 1900 - birth_year.to_i > 105\n 2000 + birth_year.to_i\n else\n 1900 + birth_year.to_i\n end\n\n # 3-digit year?\n elsif birth_year.to_i < 1000\n # We keep track upto M105:\n if DateTime.now.year - 1000 - birth_year.to_i > 105\n 2000 + birth_year.to_i\n else\n 1000 + birth_year.to_i\n end\n end\n end", "def epochyear\n 2000 + @line1[18...20].to_i\n end", "def sortable_year_for_yy\n return unless orig_date_str\n\n slash_matches = orig_date_str.match(/\\d{1,2}\\/\\d{1,2}\\/\\d{2}/)\n if slash_matches\n date_obj = Date.strptime(orig_date_str, '%m/%d/%y')\n else\n hyphen_matches = orig_date_str.match(/\\d{1,2}-\\d{1,2}-\\d{2}/)\n date_obj = Date.strptime(orig_date_str, '%m-%d-%y') if hyphen_matches\n end\n if date_obj && date_obj > Date.today\n date_obj = Date.new(date_obj.year - 100, date_obj.month, date_obj.mday)\n end\n date_obj.year.to_s if date_obj\n rescue ArgumentError\n nil # explicitly want nil if date won't parse\n end", "def parse_year(date)\n date.split(\"-\").first.to_i rescue nil\n end", "def year(input) = new_year(input).year - 621", "def get_plain_four_digit_year(dates)\n dates.each do |f_date|\n matches = f_date.scan(/\\d{4}/)\n if matches.length == 1\n @pub_year = matches.first\n else\n # when there are multiple matches, check for ones with CE after them\n matches.each do |match|\n # look for things like '1865-6 CE'\n pos = f_date.index(Regexp.new(match + '...CE'))\n pos = pos ? pos.to_i : 0\n if f_date.include?(match + ' CE') || pos > 0\n @pub_year = match\n return match\n end\n end\n end\n return matches.first\n end\n nil\n end", "def year() end", "def year(string)\n return if string.blank?\n return string if string.is_a?(Range)\n\n components = string\n .split(\"-\")\n .map(&:to_i)\n .map { |y| y.zero? ? nil : y }\n\n return if components.empty?\n\n # Set end if only one year\n components << components.first if components.count == 1\n\n components[0]..components[1]\n end", "def year_int_from_date_str\n return if orig_date_str == '0000-00-00' # shpc collection has these useless dates\n # B.C. first in case there are 4 digits, e.g. 1600 B.C.\n return sortable_year_int_for_bc if orig_date_str.match(BC_REGEX)\n\n result = sortable_year_for_yyyy_or_yy\n result ||= sortable_year_for_decade # 19xx or 20xx\n result ||= sortable_year_for_century\n result ||= sortable_year_int_for_early_numeric\n unless result\n # try removing brackets between digits in case we have 169[5] or [18]91\n no_brackets = remove_brackets\n return DateParsing.new(no_brackets).year_int_from_date_str if no_brackets\n end\n result.to_i if result && self.class.year_int_valid?(result.to_i)\n end", "def sortable_year_for_century\n return unless orig_date_str\n return if orig_date_str =~ /B\\.C\\./\n\n century_matches = orig_date_str.match(CENTURY_4CHAR_REGEXP)\n if century_matches\n return $1 + '00' if $1.length == 2\n return '0' + $1 + '00' if $1.length == 1\n end\n century_str_matches = orig_date_str.match(CENTURY_WORD_REGEXP)\n if century_str_matches\n yy = ($1.to_i - 1).to_s\n return yy + '00' if yy.length == 2\n return '0' + yy + '00' if yy.length == 1\n end\n end", "def sortable_year_for_yyyy_or_yy\n # most date strings have a four digit year\n result = sortable_year_for_yyyy\n result ||= sortable_year_for_yy # 19xx or 20xx\n result\n end", "def get_year(s)\n begin\n return DateTime.parse(s).year.to_s\n rescue\n if s.match(/^\\d\\d\\d\\d$/)\n return s.to_s\n elsif s.match(/^(\\d\\d\\d\\d)-\\d\\d$/)\n return $1.to_s\n else\n return nil\n end\n end\n end", "def handle_sy\n handle_possible(SeparatorSpace)\n handle_possible(SeparatorApostrophe)\n @year = @tokens[@index].get_tag(ScalarYear).type\n @have_year = true\n @index += 1\n @precision = :year\n end", "def year\n (seconds_since_epoch / Y_SECS).to_i\n end", "def sortable_year_for_yyyy\n matches = orig_date_str.match(/\\d{4}/) if orig_date_str\n matches.to_s if matches\n end", "def roman_year(date)\n date[0]\n end", "def get_u_year(dates)\n dates.each do |f_date|\n # Single digit u notation\n matches = f_date.scan(/\\d{3}u/)\n return matches.first.tr('u', '0') if matches.length == 1\n\n # Double digit u notation\n matches = f_date.scan(/\\d{2}u{2}/)\n return matches.first.tr('u', '-') if matches.length == 1\n end\n nil\n end", "def year\n current_year = Date.today.year\n\n case raw_year\n when current_year; \"this year\"\n when current_year.next; \"next year\"\n when current_year.pred; \"last year\"\n else; raw_year.to_s\n end\n end", "def year_convert(v)\n case v\n when nil, 0 then nil\n when Numeric then v.to_i.to_s\n when IsoYear then v.to_s\n when IsoDay then year_convert(v.to_s)\n when IsoDate then year_convert(v.to_s)\n when START_PATTERN[:complete] then $2\n when START_PATTERN[:day] then $2\n when START_PATTERN[:year] then $1\n else year_convert(date_parse(v))\n end\n end", "def cwyear\n end", "def extract_day_mth_yr(given_date)\n\ttmp_new_date = given_date.split('/')\n\t# Get the current month\n\tset_cur_mth(tmp_new_date[0])\n\t# Get the current day\n\tset_cur_day(tmp_new_date[1])\n\t# Get the current year\n\tset_cur_year(tmp_new_date[2])\n\t# Get the body of the output filename\n\t$op_file_body = \"_\"+ month_num_to_ver(get_cur_mth) +\"_\"+ get_cur_day.to_s + \"_\" + get_cur_year.to_s\n\t# Get the name of the output filename\n\t$op_filename = $op_file_prefix + $op_file_body + $op_file_suffix\nend", "def year(date)\n y = date.year.abs.to_s\n return [y, BCE_SUFFIX].join(' ') if (date.year <= -1)\n y\n end", "def year(string)\n year_matches = /(?!^\"[^\"]+\")\\(([\\d]+)\\)/.match(string)\n year_matches ? year_matches[1].to_s : nil\n end", "def sortable_year_string_from_date_str\n return if orig_date_str == '0000-00-00' # shpc collection has these useless dates\n # B.C. first in case there are 4 digits, e.g. 1600 B.C.\n return sortable_year_str_for_bc if orig_date_str.match(BC_REGEX)\n\n result = sortable_year_for_yyyy_or_yy\n result ||= sortable_year_for_decade # 19xx or 20xx\n result ||= sortable_year_for_century\n result ||= sortable_year_str_for_early_numeric\n unless result\n # try removing brackets between digits in case we have 169[5] or [18]91\n no_brackets = remove_brackets\n return DateParsing.new(no_brackets).sortable_year_string_from_date_str if no_brackets\n end\n result if self.class.year_str_valid?(result)\n end", "def year_name(number); end", "def extract_year(date)\n if date.blank?\n []\n elsif date == \"undated\"\n []\n elsif /^\\d{4}$/ =~ date\n # Date.iso8601 doesn't support YYYY dates\n [date.to_i]\n elsif /^\\d{4}-\\d{4}$/ =~ date\n # date range in YYYY-YYYY format\n earliest, latest = date.split('-').flat_map{ |y| y.to_i }\n (earliest..latest).to_a\n else\n [Date.iso8601(date).year]\n end\n rescue ArgumentError\n raise \"Invalid date: #{date.inspect}\"\n end", "def year; end", "def year; end", "def sortable_year_for_decade\n decade_matches = orig_date_str.match(DECADE_4CHAR_REGEXP) if orig_date_str\n changed_to_zero = decade_matches.to_s.tr('u\\-?x', '0') if decade_matches\n DateParsing.new(changed_to_zero).sortable_year_for_yyyy if changed_to_zero\n end", "def raw_year\n start_on.year\n end", "def w_year; end", "def amy_years\n (Time.now.year - 1977).ordinalize\n end", "def yearCode year\r\n if year =~ /freshman/\r\n 1\r\n elsif year =~ /sophomore/\r\n 2\r\n elsif year =~ /junior/\r\n 3\r\n elsif year =~ /senior/\r\n 4\r\n else \r\n 0\r\n end\r\nend", "def year_to_season(y); \"#{y}-#{sprintf('%02d', (y + 1) % 100)}\"; end", "def bracket_years\n gsub(/(?<!\\()\\b(?:19|20)\\d\\d\\b(?!\\))/, \"(\\\\0)\")\n end", "def get_year_with_number\n date_receipt.strftime(\"%Y\") + \"-\" + sprintf( \"%03i\", receipt_num )\n end", "def test_century_leap_year\n skip\n output = `./cal.rb 02 2000`\n expected = <<EOS\n February 2000\nSu Mo Tu We Th Fr Sa\n 1 2 3 4 5\n 6 7 8 9 10 11 12\n13 14 15 16 17 18 19\n20 21 22 23 24 25 26\n27 28 29\n\nEOS\n assert_equal expected, output\n end", "def year_completed\n \t#binding.pry\n \tresults = super\n \tyear_match = results.match(/(^\\d+) *(\\w*)/)\n \tif year_match[2]==\"\"\n \t\tyear_match[1].to_i\n \telse\n \t\tyear_match\n \tend\n end", "def get_date_month_year\n\t\tif @date_time != nil and @date_time.to_s.strip != \"\"\n\t\t\tdate_time_arr = @date_time.to_s.split\n\t\t\tday_month_year = (date_time_arr[date_time_arr.size - 3] + date_time_arr[date_time_arr.size - 2] + date_time_arr[date_time_arr.size-1]).strip\n\t\t\treturn day_month_year\n\t\telse\n\t\t\treturn \"UNKNOWN\"\n\t\tend\n\tend", "def to_year(**options) = convert_to('year', **options)", "def test_regular_leap_year\n skip\n output = `./cal.rb 02 2016`\n expected = <<EOS\n February 2016\nSu Mo Tu We Th Fr Sa\n 1 2 3 4 5 6\n 7 8 9 10 11 12 13\n14 15 16 17 18 19 20\n21 22 23 24 25 26 27\n28 29\n\nEOS\n assert_equal expected, output\n end", "def century(year)\n century_string = ''\n case year.to_s.length \n when 1..2\n century_string = '1'\n when 3\n century_string = (year.to_s[0].to_i+1).to_s\n when 4\n if year.to_s[-1] == '0'\n century_string = year.to_s[0..1].to_i.to_s\n else \n century_string = (year.to_s[0..1].to_i+1).to_s\n end \n when 5\n century_string = (year.to_s[0..2].to_i+1).to_s\n end \ncentury_string += last_digit(century_string)\n\nend", "def get_double_digit_century(dates)\n dates.each do |f_date|\n matches = f_date.scan(/\\d{2}th/)\n next if matches.empty?\n\n if matches.length == 1\n @pub_year = (matches.first[0, 2].to_i - 1).to_s + '--'\n return @pub_year\n else\n # when there are multiple matches, check for ones with CE after them\n matches.each do |match|\n pos = f_date.index(Regexp.new(match + '...CE'))\n pos = pos ? pos.to_i : f_date.index(Regexp.new(match + ' century CE'))\n pos = pos ? pos.to_i : 0\n if f_date.include?(match + ' CE') || pos > 0\n @pub_year = (match[0, 2].to_i - 1).to_s + '--'\n return @pub_year\n end\n end\n end\n end\n nil\n end", "def year\n end", "def year\n result = self.title.split('-')[0]\n result ? result.to_i : nil\n end", "def test_400_leap_year\n skip\n output = `./cal.rb 02 2400`\n expected = <<EOS\n February 2400\nSu Mo Tu We Th Fr Sa\n 1 2 3 4 5\n 6 7 8 9 10 11 12\n13 14 15 16 17 18 19\n20 21 22 23 24 25 26\n27 28 29\n\nEOS\n assert_equal expected, output\n end", "def year?(v)\n normalize(v).to_s.match?(MATCH_PATTERN[:year])\n end", "def expected_death_year\n Chronic.parse(\"#{@years_to_live} years from\nnow\").year\n end", "def year\n 2020\n end", "def year\n result = title.split('-')[0]\n result ? result.to_i : nil\n end", "def get_bc_year(dates)\n dates.each do |f_date|\n matches = f_date.scan(/\\d{3} B.C./)\n unless matches.empty?\n bc_year = matches.first[0..2]\n return (bc_year.to_i - 1000).to_s\n end\n end\n nil\n end", "def fy(d)\n\t\td = d.to_date\n\t\tif(d.month >= 2)\n\t\t\treturn (d.year+1)\n\t\telse\n\t\t\treturn d.year\n\t\tend\n\tend", "def year\n @year ||= details.at(\"h1[itemprop='name'] span#titleYear a\").text.parse_year rescue nil\n end", "def year_rome_founded\n bce(753)\n end", "def year\n self.class.get_year(@bits)\n end", "def year_int(date_el_array)\n result = date_parsing_result(date_el_array, :year_int_from_date_str)\n return result if result\n\n year_int, _ignore = self.class.earliest_year_int(date_el_array)\n year_int if year_int\n end", "def yearCode(year)\r\n\tif year =~ /freshman/\r\n\t\treturn 1\r\n\telsif year =~ /sophomore/\r\n\t\treturn 2\r\n\telsif year =~ /junior/\r\n\t\treturn 3\r\n\telsif year =~ /senior/\r\n\t\treturn 4\r\n\telse\r\n\t\treturn 0\r\n\tend\r\nend", "def century_to_year(century, offset)\n return century * 100 + offset\n end", "def get_three_digit_year(dates)\n dates.each do |f_date|\n matches = f_date.scan(/\\d{3}/)\n return matches.first unless matches.empty?\n end\n nil\n end", "def datetime_year\n case datetime\n when String\n Date.parse(datetime).year\n when Time\n datetime.year\n end\n end", "def valid_year?(y, min, max)\n return false unless y\n return false if y.length != 4\n\n year = y.to_i\n year >= min && year <= max \n end", "def expected_death_year\n Chronic.parse(\"#{years_to_live} years from now\").year.to_s\n end", "def w_year\n @obj.date.strftime(\"%G\")\n end", "def century(year)\n century = year / 100\n if year % 100 > 0\n century += 1\n end\n century = century.to_s\n if (century[-1] == \"1\") && (century[-2] != \"1\")\n century += 'st'\n elsif (century[-1] == \"2\") && (century[-2] != \"1\")\n century += 'nd'\n elsif (century[-1] == \"3\") && (century[-2] != \"1\")\n century += 'rd'\n else\n century += 'th'\n end\nend", "def sortable_year_int_for_early_numeric\n return orig_date_str.to_i if orig_date_str.match(EARLY_NUMERIC)\n\n orig_date_str.to_i if orig_date_str =~ /^-\\d{4}$/\n end", "def century(year)\n # create century_str--------------\n if year.to_s.end_with?('00')\n century_str = year / 100\n else\n century_str = year / 100 + 1\n end\n century_str = century_str.to_s\n # --------------------------------\n\n # create suffix-------------------\n suffix = nil\n\n if century_str.length == 1\n if century_str == '1'\n suffix = 'st'\n elsif century_str == '2'\n suffix = 'nd'\n elsif century_str == '3'\n suffix = 'rd'\n else\n suffix = 'th'\n end\n\n elsif century_str.length < 4\n if century_str.reverse[1] == '1'\n suffix = 'th'\n elsif century_str.end_with?('1')\n suffix = 'st'\n elsif century_str.end_with?('2')\n suffix = 'nd'\n elsif century_str.end_with?('3')\n suffix = 'rd'\n else\n suffix = 'th'\n end\n\n elsif century_str.length == 3\n # case century_str\n # end\n end\n # --------------------------------\n\n result = \"#{century_str}#{suffix}\"\n\n\n\n p result\nend", "def century(year)\n num = (year - 1) / 100 + 1\n century = num.to_s + suffix(num)\nend", "def get_single_digit_century(dates)\n dates.each do |f_date|\n matches = f_date.scan(/\\d{1}th/)\n next if matches.empty?\n\n if matches.length == 1\n @pub_year = (matches.first[0, 2].to_i - 1).to_s + '--'\n return @pub_year\n else\n # when there are multiple matches, check for ones with CE after them\n matches.each do |match|\n pos = f_date.index(Regexp.new(match + '...CE'))\n pos = pos ? pos.to_i : f_date.index(Regexp.new(match + ' century CE'))\n pos = pos ? pos.to_i : 0\n if f_date.include?(match + ' CE') || pos > 0\n @pub_year = (match[0, 1].to_i - 1).to_s + '--'\n return @pub_year\n end\n end\n end\n end\n nil\n end", "def year\n date&.strftime('%Y')\n end", "def year\n return @year\n end", "def sortable_year_int_for_bc\n bc_matches = orig_date_str.match(BC_REGEX) if orig_date_str\n \"-#{$1}\".to_i if bc_matches\n end", "def year\n ((semester - 1) / 2) + 1\n end", "def date_parse raw_day, raw_month\n str_month = raw_month.scan(@regex_monthes)[0]\n month = @monthes[str_month]\n return if not month\n day = raw_day.to_i\n return if day==0\n today = Date.today\n if day < today.day and month == 12\n year = today.year + 1\n else\n year = today.year\n end\n #puts year, year.class, month, month.class, day, day.class\n return \"#{year}-#{\"%02d\"%month}-#{\"%02d\"%day}\"\nend", "def extract_swimmer_year_and_category( compound_year_or_category )\n parts = compound_year_or_category.to_s.split(/\\s+/)\n if (parts[0] =~ /\\d{4}/) && (parts[1] =~ /\\d{2}/)\n [ parts[0] , \"M#{parts[1]}\" ]\n\n elsif (parts[0] =~ /\\d{4}/) && (parts[1] == '0')\n [ parts[0] , 'U25' ]\n\n elsif parts[0] =~ /M|U/i\n [ nil, parts.join ]\n\n else\n [ nil, nil ]\n end\n end", "def tokenizer_result_row_swimmer_year\n TokenExtractor.new(\n :swimmer_year,\n /\\b\\d{4} +(?=\\D+)/i,\n 4 # (max size)\n )\n end", "def first_year\n 2012\n end", "def end_year\n Time.now.year \n end", "def make_year(year, bias); end", "def century_year(year)\n\n\tcentury_year = year.div(100) + 1\n\tcentury_year -= 1 if year % 100 == 0\n\tcentury_year.to_s + century_suffix(century_year)\n\nend", "def year\n doc.search(\"table.info a[href*='/m_act%5Byear%5D/']\").text.to_i\n end", "def century_validate(year)\n century = (year / 100) + 1\n century.to_s + validate_ordinal(year)\nend", "def year? = unit == 'year'", "def sortable_year_str_for_early_numeric\n return unless orig_date_str.match(EARLY_NUMERIC)\n\n if orig_date_str =~ /^\\-/\n # negative number becomes x - 1000 for sorting; -005 for -995\n num = orig_date_str[1..-1].to_i - 1000\n return '-' + num.to_s[1..-1].rjust(3, '0')\n else\n return orig_date_str.rjust(4, '0')\n end\n end", "def century(year)\n cent = (year / 100) + 1\n year.to_s.end_with?('0') ? cent -= 1 : cent\n chars_array = cent.to_s.chars\n \n if chars_array[-2] == '1'\n chars_array.push('th')\n end\n \n case chars_array[-1]\n when '1'\n chars_array.push('st') unless chars_array[-2] == '1'\n when '2'\n chars_array.push('nd') unless chars_array[-2] == '1'\n when '3'\n chars_array.push('rd') unless chars_array[-2] == '1'\n else chars_array.push('th') unless chars_array.include?('th')\n end\n p chars_array.join\nend", "def year\n @ole.Year\n end", "def century(year)\r\n cent = (year.to_f / 100).ceil.to_s\r\n\r\n if cent.end_with?(\"1\") && !(cent.end_with?(\"11\"))\r\n cent << \"st\"\r\n elsif cent.end_with?(\"2\") && !(cent.end_with?(\"12\"))\r\n cent << \"nd\"\r\n elsif cent.end_with?(\"3\") && !(cent.end_with?(\"13\"))\r\n cent << \"rd\"\r\n else\r\n cent << \"th\"\r\n end\r\nend", "def work_out_year(value)\n case value\n when 0..39\n 2000 + value\n when 40..99\n 1900 + value\n else\n value\n end\n end", "def year\n document.search('a[@href^=\"/year/\"]').innerHTML.to_i\n end", "def get_year_ary\n (Date.today.year-99..Date.today.year).inject([]){|x,y| x << y}.reverse\n end", "def get_next_yr\n\tset_cur_year(get_cur_year+1)\nend", "def dates\n \t\"(#{years})\".sub(\"()\",\"\")\n end", "def get_year\n valid_yr = false\n while !valid_yr\n print \"Please enter the year you would like statistics for: \"\n user_year = gets.chomp\n yr_reg_ex = Regexp.new /^[1-9]\\d\\d\\d$/\n if user_year =~ yr_reg_ex\n valid_yr = true\n else\n puts \"Sorry, that doesn't look like a valid year.\"\n end\n end\n return user_year.to_i\nend", "def fy(datestr)\n d = Date.parse(datestr)\n m = d.month\n y = d.year\n yx = y % 100\n if m > 8\n \"FY#{yx + 1}\"\n else\n \"FY#{yx}\"\n end\n end", "def gas_year\n y = year\n if self< Date.new(y,10,1)\n y\n else\n y+1\n end\n end", "def getyrs(input) \n years = input.gsub(/[^0-9.]+/, '') \n @term_years = years.to_i\n if @term_years.between?(1,99)\n @output.puts 'The term length you entered is: ' + @term_years.to_s + ' years'\n @status = 'valid'\n else\n @output.puts 'Oops, loan length must be between 1 and 99 years!'\n end\n return @term_years \n end", "def get_year\n @year ||= params[:year] ? params[:year].to_i : Time.now.year\n end", "def format_year(year)\n \"#{year}-#{year+1}\"\n end" ]
[ "0.72254795", "0.72176564", "0.69198483", "0.6898048", "0.68305844", "0.6799728", "0.6704873", "0.6701607", "0.66917324", "0.6677889", "0.66488624", "0.65660197", "0.65653646", "0.6564055", "0.6554773", "0.6543124", "0.6520513", "0.64829516", "0.6468795", "0.6465047", "0.64643145", "0.64393425", "0.6409361", "0.6377292", "0.6361173", "0.6338057", "0.6332072", "0.63279915", "0.627243", "0.6269088", "0.6269088", "0.62609124", "0.622457", "0.6219494", "0.61991185", "0.61977243", "0.61935997", "0.61846715", "0.6172823", "0.61516076", "0.612815", "0.6126925", "0.6124806", "0.612201", "0.6118394", "0.61148006", "0.6110145", "0.60961914", "0.60866773", "0.60826164", "0.60746294", "0.6071232", "0.605099", "0.60472053", "0.6046374", "0.60441184", "0.60412943", "0.60392416", "0.60348415", "0.6029905", "0.6029383", "0.6017797", "0.60004973", "0.5986181", "0.5982634", "0.5982372", "0.5980302", "0.5972669", "0.59642184", "0.59436333", "0.59367394", "0.5936388", "0.5911971", "0.5910067", "0.5889525", "0.5884781", "0.5880857", "0.5874762", "0.58733165", "0.58625376", "0.5833047", "0.5831208", "0.58310765", "0.5827703", "0.5823361", "0.5816609", "0.5813919", "0.58139056", "0.5807877", "0.5804807", "0.5796882", "0.579514", "0.57923263", "0.57861996", "0.5780088", "0.5774259", "0.577296", "0.57723564", "0.5757178", "0.5754764" ]
0.6511989
17
Parses an "M" character from the main methods Returns the month in an array.
def parse_month(time) [file_for_month(time.strftime("%-m"))] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def roman_month(date)\n date[1]\n end", "def months_as_array\n (1..12).map {|m| [Date::MONTHNAMES[m]]}\n end", "def month\n @month ||= Date::ABBR_MONTHNAMES.index(@md[1])\n end", "def month_array\r\n\t\t[[\"January\", \"1\"],[\"February\", \"2\"], \r\n\t\t[\"March\", \"3\"],[\"April\",4],\r\n\t\t[\"May\",5],[\"June\",6],\r\n\t\t[\"July\",7],[\"August\",8],\r\n\t\t[\"September\",9],[\"October\",10],\r\n\t\t[\"November\",11],[\"December\",12]]\r\n\tend", "def month\n @month ||= Date::ABBR_MONTHNAMES.index(@md[4])\n end", "def month_str\n ret = Datet.months(:trans => true)[@t_month]\n if args and args[:short]\n ret = ret.slice(0, 3)\n end\n \n return ret\n end", "def month() end", "def month\r\n return @hm\r\n end", "def handle_mn\n handle_possible(SeparatorSpace)\n handle_possible(SeparatorSpace) if handle_possible(KeywordIn)\n @month = Date::MONTHS[@tokens[@index].get_tag(MonthName).type]\n @index += 1\n @precision = :month\n end", "def month; end", "def month; end", "def parse_month(date)\n date.split(\"-\").last.to_i rescue nil\n end", "def month\n self.class.get_month(@bits)\n end", "def month_names; end", "def month\n return self.to_a[IDX_MONTH]\n end", "def getArrMeses\n m = Array.new\n \n m[1] = \"Enero\"\n m[2] = \"Febrero\"\n m[3] = \"Marzo\"\n m[4] = \"Abril\"\n m[5] = \"Mayo\"\n m[6] = \"Junio\"\n m[7] = \"Julio\"\n m[8] = \"Agosto\"\n m[9] = \"Septiembre\"\n m[10] = \"Octubre\"\n m[11] = \"Noviembre\"\n m[12] = \"Diciembre\"\n \n return m\n end", "def month\n end", "def month\n @month ||= date_calc.merch_to_julian(merch_month)\n end", "def January ; Date::MONTHNAMES.index(\"January\"); end", "def get_english_month(idx)\n Date::MONTHNAMES[idx]\n end", "def month\n return @month\n end", "def month=(_arg0); end", "def scan_for_month_names(token, options = T.unsafe(nil)); end", "def mn(month)\n n = Date::ABBR_MONTHNAMES.index(month) || Date::MONTHNAMES.index(month)\n return month unless n\n\n n.to_s.rjust 2, \"0\"\n end", "def month\n months = %w{January February March April May June July August September October November December}\n months[Time.now.month - 1]\n end", "def heb_month_name\r\n if HebrewDate.leap?(@hy) and @hm >= 12 # leap year and from adar\r\n return HEB_MONTH_NAMES[@hm + 1]\r\n else\r\n return HEB_MONTH_NAMES[@hm]\r\n end\r\n end", "def rsmonth(month)\n case month\n when 1\n return 'januar'\n when 2\n return 'februar'\n when 3\n return 'mart'\n when 4\n return 'april'\n when 5\n return 'maj'\n when 6\n return 'jun'\n when 7\n return 'jul'\n when 8\n return 'avgust'\n when 9\n return 'septembar'\n when 10\n return 'oktobar'\n when 11\n return 'novembar'\n when 12\n return 'decembar'\n end\nend", "def adjust_month(m)\n months = [\"january\", \"february\", \"march\", \"april\", \"may\", \"june\", \"july\", \"august\", \"september\", \"october\", \"november\", \"december\"]\n if m.is_a? Integer\n months[m-1]\n else\n m\n end\n end", "def month_name(number); end", "def month(date)\n [MONTHS[date.month - 1], year(date)].join(', ')\n end", "def translated_month_names; end", "def get_month(month)\n month = month.to_s\n month.length == 2 ? month : \"0#{month}\"\n end", "def refine_month(m)\n mon = check_num_str(m)\n adjust_month(mon)\n end", "def month_name\r\n return MONTH_NAMES[@hm]\r\n end", "def month\n @month.to_s.rjust(2, '0')\n end", "def set_month(m)\n @@m_set.index(m.to_s)\n end", "def card_month\n card[:month].to_i\n end", "def month\n Thread.current[:datet_mode] = :months\n return @t_month\n end", "def months\n @years * 12\n end", "def parse_months\n date_from = Date.parse('2004-05-01')\n date_to = Date.parse('2014-04-01')\n date_range = date_from..date_to\n date_months = date_range.map {|d| Date.new(d.year, d.month, 1) }.uniq\n date_months.map {|d| d.strftime \"%B %Y\" }\n end", "def month\n return @month\n end", "def parse_month_in_options(options, default = nil)\n date = options[:date]\n if options[:date]\n begin\n Time.parse_month(options[:date].to_s)\n rescue ArgumentError => e\n raise \"invalid date option: #{e.message}\"\n end\n elsif default\n [default.year, default.month]\n end\n end", "def day_of_month_format(string)\n \tif string =~ /(\\d+)(st|nd|rd|th)?\\sof the month at (.*)/\n \t\tday = $1\n \t\ttimes = parse_times($3)\n \tend\n end", "def number_to_full_month_name(num)\n return Date::MONTHNAMES[num]\nend", "def month\n @date_time_value.month\n end", "def month\n @date_time_value.month\n end", "def monthly_language_activity\n memoized_language_breakdowns = all_languages_monthly_activity\n\n MONTHS.map do |month|\n res = [Date::MONTHNAMES[month]]\n memoized_language_breakdowns.each do |lang, breakdown|\n value = breakdown.detect { |b| b.fetch(\"month\") == month }\n prs = value ? value.fetch(\"prs\") : 0\n res << prs\n end\n res\n end\n end", "def kp_get_modid(data)\n return data.map{|d| d.scan(/(?<m>M\\d{5})/)}.flatten.sort\nend", "def to_month(**options) = convert_to('month', **options)", "def test__individual_month__printing\n\t\tm = Month.new(1, 1, true)\n\t\texpected_output = \n\"Su Mo Tu We Th Fr Sa\n 1 2 3 4 5 6 7\n 8 9 10 11 12 13 14\n15 16 17 18 19 20 21\n22 23 24 25 26 27 28\n29 30 31\n\n\"\n\t\tassert_equal(expected_output, m.construct_month_for_printing)\n\tend", "def monthly\n end", "def build_day_array(year, month)\n day_array = Array.new\n # cycle through number of days in the month and build an array with one entry per day\n for d in (1..self.days_in_month(year, month))\n day_array[d] = Line_Calendar::ABBR_DAYNAMES[self.day_in_month(year, month, d)] # populates array with abbreviated daynames\n end\n # remove the 0 entry and move everything up one\n day_array.shift\n return day_array\n end", "def get_year_month_list()\n arr=[]\n start=\"2008_01\"\n str=\"\"\n var_date = Time.now\n while( start != str)\n str = var_date.year.to_s + \"_\" + \"%02d\" % var_date.month.to_s\n arr << str\n var_date = var_date - 1.month\n end\n return arr\n end", "def roman_date(year, month, event, count, leap)\n [year, month, event, count, leap]\n end", "def month_name\n I18n.t('date.month_names')[month_number].camelize\n end", "def months; self * MONTH; end", "def month\n start_on.strftime(MONTH_NAME)\n end", "def months\n self.to_i * 2_592_000\n end", "def month_result_string(day)\n start = day.beginning_of_month.yday - 1\n finish = day.end_of_month.yday - 1\n result_string(day.year).slice(start..finish)\n end", "def mon() @m_date.mon end", "def print_month\n print \"#{@month.capitalize} #{@year}\".center(20) + \" \"\n puts \"\\n\"\n print \"Su Mo Tu We Th Fr Sa\" + \" \"\n puts \"\\n\"\n format_month_body.each do |line|\n converted_line = line.map do |day|\n day.to_s.rjust(2)\n end\n puts converted_line.join(\" \") + \" \"\n end\n end", "def test_yearly_by_month_loop\n parse(\n 'FREQ=YEARLY;INTERVAL=1;UNTIL=20120203T225959Z;BYMONTH=2;BYSETPOS=1;BYDAY=SU,MO,TU,WE,TH,FR,SA',\n '2012-01-01 15:45:00',\n [\n '2012-02-01 15:45:00'\n ],\n '2012-01-29 23:00:00'\n )\n end", "def month_name\n report_date.strftime(\"%B\")\n end", "def month\n set_function_and_argument(:month, nil)\n end", "def expiration_month\n @months = [\"01\",\"02\",\"03\",\"04\",\"05\",\"06\",\"07\",\"08\",\"09\",\"10\",\"11\",\"12\"]\n end", "def number_to_substring_month(number)\n case number\n when 1\n return \"Jan\"\n when 4\n return \"Apr\"\n when 9\n return \"Sep\"\n when 10\n return \"Oct\"\n end\nend", "def month_from_name(month)\n month = MONTH_NAMES.index(month)\n month ? month / 2 + 1 : nil\n end", "def test_02a_textual_representation_of_a_month\n cal = IndividualMonth.new(2012, 9)\n assert_equal(\"September\", cal.month_name_text)\n end", "def month_names\n @month_names ||= begin\n month_names = @options[:use_month_names] || translated_month_names\n month_names = [nil, *month_names] if month_names.size < 13\n month_names\n end\n end", "def each_march( n=1); each_monthnum(self.Mar,n); end", "def merch_month\n # TODO: This is very inefficient, but less complex than strategic guessing\n # maybe switch to a binary search or something\n @merch_month ||= (1..12).detect do |num|\n date_calc.end_of_month(start_of_year.year, num) >= date && date >= date_calc.start_of_month(start_of_year.year, num)\n end\n end", "def month\n self.range('month')\n end", "def month_name\n return @@month_names[@t_month]\n end", "def number_to_short_month_name(a)\n return number_to_full_month_name(a).slice(0,3)\nend", "def month\n start_date&.strftime('%b %Y')\n end", "def month_arg_to_s(m)\n month_array = [\"January\", \"February\", \"March\", \"April\", \"May\", \"June\", \"July\", \"August\", \"September\", \"October\", \"November\", \"December\"]\n month_array[m - 1]\nend", "def months_list\n\t (Date.today-1.year..Date.today).map{|d| [d.strftime(\"%b-%Y\"), d.strftime(\"%m-%Y\")]}.uniq.reverse\n\tend", "def check_month(num)\n loop do\n if !MONTH.match(num)\n message(MC['num_prompt_month'])\n num = Kernel.gets().chomp()\n else\n break\n end\n end\n num\nend", "def month_labels\n dates.collect { |date| date.to_date.day == 1 ? date.to_date.strftime('%B') : '' }\n end", "def current_month\n Time.now.strftime(\"%^b\")\n end", "def parse_month_day(day, month, year)\n On.parse(day, month, year)\n end", "def month_name(the_date)\n Date::MONTHNAMES[the_date.month]\n end", "def month_name(num)\n\tmonths = {\n\t\t1 => 'January',\n\t\t2 => 'February',\n\t\t3 => 'March',\n\t\t4 => 'April',\n\t\t5 => 'May',\n\t\t6 => 'June',\n\t\t7 => 'July',\n\t\t8 => 'August',\n\t\t9 => 'September',\n\t\t10 => 'October',\n\t\t11 => 'November',\n\t\t12 => 'December',\n\t}\n\treturn months[num]\nend", "def validate_month(spec)\n return true if spec == \"*\"\n\n if spec.respond_to? :to_int\n validate_numeric(spec, 1, 12)\n elsif spec.respond_to? :to_str\n # Named abbreviations are permitted but not as part of a range or with stepping\n return true if %w{jan feb mar apr may jun jul aug sep oct nov dec}.include? spec.downcase\n\n # 1-12 are legal for months\n validate_numeric(spec, 1, 12)\n else\n false\n end\n end", "def all_month\n beginning_of_month..end_of_month\n end", "def the_month\n self.koyomi_month\n end", "def months() 30 * days end", "def month\n @year = params[:year].to_i\n @month = params[:month].to_i\n @first_day = @event.first_day_of_month(@year, @month)\n @last_day_of_month = Date.new(@year, @month, 1).end_of_month\n end", "def get_month(year, month)\n entries = month_entries(@pages, year, month) \n\n budget_month = BudgetMonth.new(entries, year, month)\n\n budget_month\n end", "def number_to_full_month_name(month_number)\n require \"date\"\n return Date::MONTHNAMES[month_number]\nend", "def adjust_set_month(m)\n index = @@m_set.index(m.to_s)\n if index < 13\n index - 1\n else\n index - 13\n end\n end", "def month_number\n date.month\n end", "def extract_futures_contract_month(futures_contact_string)\n match = futures_contact_string.match(/([FGHJKMNQUVXZ])\\s+\\([a-zA-Z]{3}\\s+(\\d{2})\\)/)\n contract_month_letter = match[1].upcase\n year_suffix = match[2]\n month = MonthCodeToMonth[contract_month_letter]\n year = \"20#{year_suffix}\".to_i\n monthstamp(year, month)\nend", "def month_week_pattern\n week_pattern.map.with_index { |val,idx| Array.new(val,idx+1) }.flatten\n end", "def month_entries(pages, year, month)\n #puts \", year = #{year}, month = #{month}\"\n # page.full_name => yyyy/mm/dd\n entries = []\n pages.each do |page|\n if page_is_of_month?(page, year, month)\n entries << page \n end\n end\n entries\n end", "def get_months\n \n @months = RiverEvents::Month.all\n end", "def month_week_result_array(day)\n first_week_length = (7 - (day.wday + 6) % 7)\n data = month_result_string(day)\n [\n data[0..first_week_length - 1],\n data[first_week_length..7 + first_week_length - 1],\n data[first_week_length + 7..14 + first_week_length - 1],\n data[first_week_length + 14..21 + first_week_length - 1],\n data[first_week_length + 21..28 + first_week_length - 1],\n data[first_week_length + 28..35 + first_week_length - 1]\n ].compact\n end", "def parse_date\n\t\tnow = Time.now\n\t\tt = ARGV.shift\n\t\tmonat = now.month\n\t\tmonat = t.to_i unless t.nil?\n\n\t\tt = ARGV.shift\n\t\tjahr = now.year\n\t\tjahr = t.to_i unless t.nil?\n\t\t\t\n\t\treturn jahr, monat\nend", "def month_abbr\n randomize(Date::ABBR_MONTHNAMES[1..-1])\n end", "def month_abbr\n randomize(Date::ABBR_MONTHNAMES[1..-1])\n end" ]
[ "0.7245807", "0.712635", "0.70139784", "0.70082116", "0.6973466", "0.6808378", "0.67515224", "0.6545827", "0.65232563", "0.64642924", "0.64642924", "0.64196014", "0.6395765", "0.6393626", "0.6390436", "0.63685083", "0.63532376", "0.6275884", "0.6272925", "0.6265755", "0.6245625", "0.61969525", "0.6184544", "0.6119871", "0.6106045", "0.60746855", "0.6049797", "0.6041473", "0.6038031", "0.60111773", "0.6003377", "0.5983853", "0.5966579", "0.5936857", "0.59286547", "0.5922667", "0.59034336", "0.5885016", "0.587587", "0.587004", "0.5857554", "0.58527076", "0.58276737", "0.58169705", "0.5798762", "0.5798762", "0.5788165", "0.578292", "0.57680506", "0.57654804", "0.57630146", "0.5745035", "0.5744029", "0.57426745", "0.5739846", "0.5738532", "0.5716858", "0.57054657", "0.57050407", "0.5702301", "0.5699604", "0.56966805", "0.5687425", "0.5687171", "0.5674121", "0.5673503", "0.5671054", "0.56680775", "0.5654098", "0.5636732", "0.5630975", "0.56267345", "0.5611719", "0.56057703", "0.55759174", "0.5574238", "0.55731803", "0.5572837", "0.55660367", "0.5563585", "0.55560887", "0.5552977", "0.55480206", "0.5545495", "0.55304915", "0.55302954", "0.5520387", "0.5518272", "0.54923487", "0.54870945", "0.5479183", "0.5476169", "0.5466738", "0.54636633", "0.54636425", "0.54630154", "0.54577744", "0.54557043", "0.5431026", "0.5431026" ]
0.773772
0
Parses a "d" character from the main methods Returns the numbers for the day.
def parse_day(time) sounds_for_number(time.strftime("%-d")) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parse_day(day)\n '%.2d' % day.to_i\n end", "def handle_dn\n @wday = Date::DAYS[@tokens[@index].get_tag(DayName).type]\n @index += 1\n @precision = :day\n end", "def parse_dob(dob)\n LineParser.dob(dob.split('/').map(&:to_i))\n end", "def ord(day)\n\nend", "def parse_dob(dob)\n LineParser.dob(dob.split('-').map(&:to_i))\n end", "def handle_ds\n @day_special = @tokens[@index].get_tag(DaySpecial).type\n @index += 1\n @precision = :day_special\n end", "def parse_doa(doa)\n if %r{^(\\d{1,2})/(\\d{1,2})/(\\d{1,2})$} =~ doa\n year = $3.to_i\n year += (year < 50 ? 2000 : 1900)\n \"#{year}-#{$1.rjust(2, \"0\")}-#{$2.rjust(2, \"0\")}\"\n else\n nil\n end\n end", "def date_dashes(d)\n d && d.length == 8 ? d.slice(0, 4) + \"-\" + d.slice(4, 2) + \"-\" + d.slice(6, 2) : d\n end", "def parse_ddm(ddm);end", "def test_slash_d_is_a_shortcut_for_a_digit_character_class\n assert_equal '42', \"the number is 42\"[/[0123456789]+/]\n assert_equal '42', \"the number is 42\"[/\\d+/]\n end", "def day_and_date(date_and_times)\n date_and_times.split(';').first\nend", "def daySymbol\n dayNum = 30*(@month - 1) + (@day - 1)\n symbols = [\"Raisin (Grape)\",\n \"Safran (Saffron)\",\n \"Châtaigne (Chestnut)\",\n \"Colchique (Crocus)\",\n \"Cheval (Horse)\",\n \"Balsamine (Impatiens)\",\n \"Carotte (Carrot)\",\n \"Amarante (Amaranth)\",\n \"Panais (Parsnip)\",\n \"Cuve (Vat)\",\n \"Pomme de terre (Potato)\",\n \"Immortelle (Strawflower)\",\n \"Potiron (Calabaza)\",\n \"Réséda (Mignonette)\",\n \"Âne (Donkey)\",\n \"Belle de nuit (The four o’clock flower)\",\n \"Citrouille (Pumpkin)\",\n \"Sarrasin (Buckwheat)\",\n \"Tournesol (Sunflower)\",\n \"Pressoir (Wine-Press)\",\n \"Chanvre (Hemp)\",\n \"Pêche (Peach)\",\n \"Navet (Turnip)\",\n \"Amaryllis (Amaryllis)\",\n \"Bœuf (Cow)\",\n \"Aubergine (Eggplant)\",\n \"Piment (Chili Pepper)\",\n \"Tomate (Tomato)\",\n \"Orge (Barley)\",\n \"Tonneau (Barrel)\",\n \"Pomme (Apple)\",\n \"Céleri (Celery)\",\n \"Poire (Pear)\",\n \"Betterave (Beet root)\",\n \"Oie (Goose)\",\n \"Héliotrope (Heliotrope)\",\n \"Figue (Fig)\",\n \"Scorsonère (Black Salsify)\",\n \"Alisier (Chequer Tree)\",\n \"Charrue (Plough)\",\n \"Salsifis (Salsify)\",\n \"Macre (Water chestnut)\",\n \"Topinambour (Jerusalem Artichoke)\",\n \"Endive (Endive)\",\n \"Dindon (Turkey)\",\n \"Chervis (Skirret)\",\n \"Cresson (Watercress)\",\n \"Dentelaire (Leadworts)\",\n \"Grenade (Pomegranate)\",\n \"Herse (Harrow)\",\n \"Bacchante (Asarum baccharis)\",\n \"Azerole (Acerola)\",\n \"Garance (Madder)\",\n \"Orange (Orange)\",\n \"Faisan (Pheasant)\",\n \"Pistache (Pistachio)\",\n \"Macjonc (Tuberous pea)\",\n \"Coing (Quince)\",\n \"Cormier (Service tree)\",\n \"Rouleau (Roller)\",\n \"Raiponce (Rampion)\",\n \"Turneps (Turnip)\",\n \"Chicorée (Chicory)\",\n \"Nèfle (Medlar)\",\n \"Cochon (Pig)\",\n \"Mâche (Corn Salad)\",\n \"Chou-fleur (Cauliflower)\",\n \"Miel (Honey)\",\n \"Genièvre (Juniper)\",\n \"Pioche (Pickaxe)\",\n \"Cire (Wax)\",\n \"Raifort (Horseradish)\",\n \"Cèdre (Cedar tree)\",\n \"Sapin (Fir tree)\",\n \"Chevreuil (Roe Deer)\",\n \"Ajonc (Gorse)\",\n \"Cyprès (Cypress Tree)\",\n \"Lierre (Ivy)\",\n \"Sabine (Juniper)\",\n \"Hoyau (Grub-hoe)\",\n \"Érable sucré (Maple Tree)\",\n \"Bruyère (Heather)\",\n \"Roseau (Reed plant)\",\n \"Oseille (Sorrel)\",\n \"Grillon (Cricket)\",\n \"Pignon (Pinenut)\",\n \"Liège (cork)\",\n \"Truffe (Truffle)\",\n \"Olive (Olive)\",\n \"Pelle (shovel)\",\n \"Tourbe (Peat)\",\n \"Houille (Coal)\",\n \"Bitume (Bitumen)\",\n \"Soufre (Sulphur)\",\n \"Chien (Dog)\",\n \"Lave (Lava)\",\n \"Terre végétale (Topsoil)\",\n \"Fumier (Manure)\",\n \"Salpêtre (Saltpeter)\",\n \"Fléau (Flail)\",\n \"Granit (Granite stone)\",\n \"Argile (Clay)\",\n \"Ardoise (Slate)\",\n \"Grès (Sandstone)\",\n \"Lapin (Rabbit)\",\n \"Silex (Flint)\",\n \"Marne (Marl)\",\n \"Pierre à chaux (Limestone)\",\n \"Marbre (Marble)\",\n \"Van (Winnowing basket)\",\n \"Pierre à plâtre (Gypsum)\",\n \"Sel (Salt)\",\n \"Fer (Iron)\",\n \"Cuivre (Copper)\",\n \"Chat (Cat)\",\n \"Étain (Tin)\",\n \"Plomb (Lead)\",\n \"Zinc (Zinc)\",\n \"Mercure (Mercury (metal))\",\n \"Crible (Sieve)\",\n \"Lauréole (Spurge-laurel)\",\n \"Mousse (Moss)\",\n \"Fragon (Butcher’s Broom)\",\n \"Perce-neige (Snowdrop)\",\n \"Taureau (Bull)\",\n \"Laurier-thym (Laurustinus)\",\n \"Amadouvier (Tinder polypore)\",\n \"Mézéréon (Daphne mezereum)\",\n \"Peuplier (Poplar Tree)\",\n \"Coignée (Axe)\",\n \"Ellébore (Hellebore)\",\n \"Brocoli (Broccoli)\",\n \"Laurier (Laurel)\",\n \"Avelinier (Cob or filbert)\",\n \"Vache (Cow)\",\n \"Buis (Box Tree)\",\n \"Lichen (Lichen)\",\n \"If (Yew tree)\",\n \"Pulmonaire (Lungwort)\",\n \"Serpette (Billhook)\",\n \"Thlaspi (Pennycress)\",\n \"Thimelé (Rose Daphne)\",\n \"Chiendent (Couch Grass)\",\n \"Trainasse (Knotweed)\",\n \"Lièvre (Hare)\",\n \"Guède (Woad)\",\n \"Noisetier (Hazel)\",\n \"Cyclamen (Cyclamen)\",\n \"Chélidoine (Celandine)\",\n \"Traîneau (Sleigh)\",\n \"Tussilage (Coltsfoot)\",\n \"Cornouiller (Dogwood)\",\n \"Violier (Matthiola)\",\n \"Troène (Privet)\",\n \"Bouc (Billygoat)\",\n \"Asaret (Wild Ginger)\",\n \"Alaterne (Buckthorn)\",\n \"Violette (Violet (plant))\",\n \"Marceau (Goat Willow)\",\n \"Bêche (Spade)\",\n \"Narcisse (Narcissus)\",\n \"Orme (Elm Tree)\",\n \"Fumeterre (Common fumitory)\",\n \"Vélar (Hedge Mustard)\",\n \"Chèvre (Goat)\",\n \"Épinard (Spinach)\",\n \"Doronic (Large-flowered Leopard’s Bane)\",\n \"Mouron (Pimpernel)\",\n \"Cerfeuil (Chervil)\",\n \"Cordeau (Twine)\",\n \"Mandragore (Mandrake)\",\n \"Persil (Parsley)\",\n \"Cochléaria (Scurvy-grass)\",\n \"Pâquerette (Daisy)\",\n \"Thon (Tuna)\",\n \"Pissenlit (Dandelion)\",\n \"Sylve (Forest)\",\n \"Capillaire (Maidenhair fern)\",\n \"Frêne (Ash Tree)\",\n \"Plantoir (Dibber: a hand gardening tool)\",\n \"Primevère (Primrose)\",\n \"Platane (Plane Tree)\",\n \"Asperge (Asparagus)\",\n \"Tulipe (Tulip)\",\n \"Poule (Hen)\",\n \"Bette (Chard Plant)\",\n \"Bouleau (Birch Tree)\",\n \"Jonquille (Daffodil)\",\n \"Aulne (Alder)\",\n \"Couvoir (Hatchery)\",\n \"Pervenche (Periwinkle)\",\n \"Charme (Ironwood)\",\n \"Morille (Morel)\",\n \"Hêtre (Beech Tree)\",\n \"Abeille (Bee)\",\n \"Laitue (Lettuce)\",\n \"Mélèze (Larch)\",\n \"Ciguë (Hemlock)\",\n \"Radis (Radish)\",\n \"Ruche (Hive)\",\n \"Gainier (Judas tree)\",\n \"Romaine (Lettuce)\",\n \"Marronnier (Chestnut Oak)\",\n \"Roquette (Arugula or Rocket)\",\n \"Pigeon (Pigeon)\",\n \"Lilas (Lilac)\",\n \"Anémone (Anemone)\",\n \"Pensée (Pansy)\",\n \"Myrtille (Blueberry)\",\n \"Greffoir (Knife)\",\n \"Rose (Rose)\",\n \"Chêne (Oak Tree)\",\n \"Fougère (Fern)\",\n \"Aubépine (Hawthorn)\",\n \"Rossignol (Nightingale)\",\n \"Ancolie (Columbine)\",\n \"Muguet (Lily of the Valley)\",\n \"Champignon (Button mushroom)\",\n \"Hyacinthe (Hyacinth)\",\n \"Râteau (Rake)\",\n \"Rhubarbe (Rhubarb)\",\n \"Sainfoin (Sainfoin)\",\n \"Bâton-d’or (Wallflower)\",\n \"Chamérops (Palm tree)\",\n \"Ver à soie (Silkworm)\",\n \"Consoude (Comfrey)\",\n \"Pimprenelle (Salad Burnet)\",\n \"Corbeille d’or (Basket of Gold)\",\n \"Arroche (Orache)\",\n \"Sarcloir (Garden hoe)\",\n \"Statice (Sea Lavender)\",\n \"Fritillaire (Fritillary)\",\n \"Bourrache (Borage)\",\n \"Valériane (Valerian)\",\n \"Carpe (Carp)\",\n \"Fusain (Spindle (shrub))\",\n \"Civette (Chive)\",\n \"Buglosse (Bugloss)\",\n \"Sénevé (Wild mustard)\",\n \"Houlette (Shepherd’s crook)\",\n \"Luzerne (Alfalfa)\",\n \"Hémérocalle (Daylily)\",\n \"Trèfle (Clover)\",\n \"Angélique (Angelica)\",\n \"Canard (Duck)\",\n \"Mélisse (Lemon Balm)\",\n \"Fromental (Oat grass)\",\n \"Martagon (Martagon lily)\",\n \"Serpolet (Thyme plant)\",\n \"Faux (Scythe)\",\n \"Fraise (Strawberry)\",\n \"Bétoine (Woundwort)\",\n \"Pois (Pea)\",\n \"Acacia (Acacia)\",\n \"Caille (Quail)\",\n \"Œillet (Carnation)\",\n \"Sureau (Elderberry)\",\n \"Pavot (Poppy plant)\",\n \"Tilleul (Linden or Lime tree)\",\n \"Fourche (Pitchfork)\",\n \"Barbeau (Cornflower)\",\n \"Camomille (Camomile)\",\n \"Chèvrefeuille (Honeysuckle)\",\n \"caille-lait (Bedstraw)\",\n \"Tanche (Tench)\",\n \"Jasmin (Jasmine Plant)\",\n \"Verveine (Verbena)\",\n \"Thym (Thyme Plant)\",\n \"Pivoine (Peony Plant)\",\n \"Chariot (Hand Cart)\",\n \"Seigle (Rye)\",\n \"Avoine (Oats)\",\n \"Oignon (Onion)\",\n \"Véronique (Speedwell)\",\n \"Mulet (Mule)\",\n \"Romarin (Rosemary)\",\n \"Concombre (Cucumber)\",\n \"Échalote (Shallot)\",\n \"Absinthe (Wormwood)\",\n \"Faucille (Sickle)\",\n \"Coriandre (Coriander)\",\n \"Artichaut (Artichoke)\",\n \"Girofle (Clove)\",\n \"Lavande (Lavender)\",\n \"Chamois (Chamois)\",\n \"Tabac (Tobacco)\",\n \"Groseille (Currant)\",\n \"Gesse (Hairy Vetchling)\",\n \"Cerise (Cherry)\",\n \"Parc (Park)\",\n \"Menthe (Mint)\",\n \"Cumin (Cumin)\",\n \"Haricot (Bean)\",\n \"Orcanète (Alkanet)\",\n \"Pintade (Guinea fowl)\",\n \"Sauge (Sage Plant)\",\n \"Ail (Garlic)\",\n \"Vesce (Tare)\",\n \"Blé (Wheat)\",\n \"Chalémie (Shawm)\",\n \"Épeautre (Einkorn Wheat)\",\n \"Bouillon blanc (Common Mullein)\",\n \"Melon (Honeydew Melon)\",\n \"Ivraie (Ryegrass)\",\n \"Bélier (Ram)\",\n \"Prêle (Horsetail)\",\n \"Armoise (Mugwort)\",\n \"Carthame (Safflower)\",\n \"Mûre (Blackberry)\",\n \"Arrosoir (Watering Can)\",\n \"Panis (Panic grass)\",\n \"Salicorne (Common Glasswort)\",\n \"Abricot (Apricot)\",\n \"Basilic (Basil)\",\n \"Brebis (Ewe)\",\n \"Guimauve (Marshmallow root)\",\n \"Lin (Flax)\",\n \"Amande (Almond)\",\n \"Gentiane (Gentian)\",\n \"Écluse (Lock)\",\n \"Carline (Carline thistle)\",\n \"Câprier (Caper)\",\n \"Lentille (Lentil)\",\n \"Aunée (Yellow starwort)\",\n \"Loutre (Otter)\",\n \"Myrte (Myrtle)\",\n \"Colza (Rapeseed)\",\n \"Lupin (Lupin)\",\n \"Coton (Cotton)\",\n \"Moulin (Mill)\",\n \"Prune (Plum)\",\n \"Millet (Millet)\",\n \"Lycoperdon (Puffball)\",\n \"Escourgeon (Six-row Barley)\",\n \"Saumon (Salmon)\",\n \"Tubéreuse (Tuberose)\",\n \"Sucrion (Sugar melon)\",\n \"Apocyn (Apocynum)\",\n \"Réglisse (Liquorice)\",\n \"Échelle (Ladder)\",\n \"Pastèque (Watermelon)\",\n \"Fenouil (Fennel)\",\n \"Épine vinette (Barberry)\",\n \"Noix (Walnut)\",\n \"Truite (Trout)\",\n \"Citron (Lemon)\",\n \"Cardère (Teasel)\",\n \"Nerprun (Buckthorn)\",\n \"Tagette (Mexican Marigold)\",\n \"Hotte (Sack)\",\n \"Églantine (Wild Rose)\",\n \"Noisette (Hazelnut)\",\n \"Houblon (Hops)\",\n \"Sorgho (Sorghum)\",\n \"Écrevisse (Crayfish)\",\n \"Bigarade (Bitter Orange)\",\n \"Verge d’or (Goldenrod)\",\n \"Maïs (Maize or Corn)\",\n \"Marron (Chestnut)\",\n \"Panier (Basket)\",\n \"La Fête de la Vertu (Celebration of Virtue)\",\n \"La Fête du Génie (Celebration of Talent)\",\n \"La Fête du Travail (Celebration of Labour)\",\n \"La Fête de l'Opinion (Celebration of Principles)\",\n \"La Fête des Récompenses (Celebration of Honours)\",\n \"La Fête de la Révolution (Celebration of the Revolution)\"]\n return symbols[dayNum]\n end", "def validate_day day_string\r\n day_int = day_string.to_i\r\n if day_int > 19850501 && day_int < 20850501\r\n return day_string.to_s\r\n else\r\n return current_day\r\n end\r\n end", "def what_day(string)\n if string.include?(\"L\")\n return \"Monday\"\n elsif string.include?(\"M\")\n return \"Tuesday\"\n elsif string.include?(\"I\")\n return \"Wednesday\"\n elsif string.include?(\"J\")\n return \"Thursday\"\n elsif string.include?(\"V\")\n return \"Friday\"\n elsif string.include?(\"S\")\n return \"Saturday\"\n elsif string.include?(\"D\")\n return \"Sunday\"\n end\n return \"NONE\"\n end", "def initialize(d)\n raise ArgumentError, \"Invalid argument '#{d}'\" if d.nil?\n\n if d.is_a? Day\n @day = d.day\n elsif d.is_a? Symbol\n raise ArgumentError, \"Invalid argument '#{d}'\" if not @@days_as_sym.include?(d)\n @day = @@days.find { |da| da.start_with?(d.to_s) }\n elsif d.is_a? String\n d = d.strip\n raise ArgumentError, \"Invalid argument '#{d}'\" if !@@days.include?(d.downcase)\n @day = @@days.find { |da| da.start_with?(d.downcase) }\n else\n raise ArgumentError, \"Invalid argument '#{d}'\"\n end\n end", "def d(date_string)\n Date.parse(date_string)\nend", "def statement_day_ordinal\n return '' if statement_day.nil?\n statement_day.ordinalize\n end", "def date_parse raw_day, raw_month\n str_month = raw_month.scan(@regex_monthes)[0]\n month = @monthes[str_month]\n return if not month\n day = raw_day.to_i\n return if day==0\n today = Date.today\n if day < today.day and month == 12\n year = today.year + 1\n else\n year = today.year\n end\n #puts year, year.class, month, month.class, day, day.class\n return \"#{year}-#{\"%02d\"%month}-#{\"%02d\"%day}\"\nend", "def day_sym_to_day_num(day_sym)\n check_pre((\n (day_sym?(day_sym))\n ))\n\n return index_to_day(DAY_SYM_SEQ.find_index(day_sym))\nend", "def day_convert(v)\n case v\n when nil, 0 then nil\n when Numeric then day_convert(year_convert(v))\n when IsoYear then day_convert(v.to_s)\n when IsoDay then v.to_s\n when IsoDate then day_convert(v.to_s)\n when START_PATTERN[:complete] then \"#{$2}-#{$3}-#{$4}\"\n when START_PATTERN[:day] then $1\n when START_PATTERN[:year] then \"#{$1}-01-01\"\n else day_convert(date_parse(v))\n end\n end", "def day_nums\n self.class.instance_variable_get(\"@day_abbrev_hash\")\n end", "def duns_number\n format('%09d', rand(10**9)).gsub(/(\\d{2})(\\d{3})(\\d{4})/, '\\\\1-\\\\2-\\\\3')\n end", "def parse_druid(druid)\n matches = druid.match(/[a-zA-Z]{2}\\d{3}[a-zA-Z]{2}\\d{4}/)\n matches.nil? ? raise('invalid druid') : matches[0]\n end", "def day\n end", "def day; end", "def dayNum\n ['sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday'].index(self.day.downcase)\n end", "def day_string(value)\n day = month = year = nil\n if value.is_a?(String)\n case (value = value.strip)\n when /^\\d{4}$/ then day = year = \"#{value}-01-01\"\n when /^\\d{4}(\\D?)\\d{2}$/ then day = month = \"#{value}#{$1}01\"\n else day = value\n end\n end\n # noinspection RubyMismatchedReturnType\n return day, !!month, !!year\n end", "def day_string(value)\n day = month = year = nil\n if value.is_a?(String)\n case (value = value.strip)\n when /^\\d{4}$/ then day = year = \"#{value}-01-01\"\n when /^\\d{4}(\\D?)\\d{2}$/ then day = month = \"#{value}#{$1}01\"\n else day = value\n end\n end\n # noinspection RubyMismatchedReturnType\n return day, !!month, !!year\n end", "def run_difs(str)\n return case str\n when /\\A-?\\d+\\Z/\n '0'\n when /\\A-?\\d+\\*\\*+\\d+\\Z/\n '0'\n when /\\A(-?(\\d+[*\\/])*)x(\\*\\*\\d+)?([*\\/]\\d+)*\\Z/\n dif_x($1,$3,$4)\n when /\\AMath::(.+)/\n trigonometry_difs($1)\n else\n '0'\n end\n end", "def check_digit\n dv\n end", "def duration_offset text\n match_data = text.match('CPD\\s[-\\s]*([0-9])*\\s(hours|days)')\n #unit = match_data[2] All are in hours - you can use this if they change to using days.\n if match_data\n return match_data[1].to_i * 3600 #86400 if days\n else\n 0\n end\n\nend", "def day() end", "def day_sym_to_day_num(day_sym)\n check_pre((\n (day_sym_elem?(day_sym))\n ))\n\n return index_to_day_num(DAY_SYM_SEQ.find_index(day_sym))\nend", "def parse_single_char\n if c = @s.scan(/\\\\[ftnr]/)\n (eval \"\\\"#{c}\\\"\").ord\n elsif c = @s.scan(/\\\\[^\\n]/)\n c[1].ord\n elsif c = @s.scan(/[^\\n\\\\\\/\\+\\*\\?\\|\\{\\}\\(\\)\\[\\]\\^\\$]/)\n c.ord\n end\n end", "def parse_date_str (d)\r\n\t\t## Preconditions:\r\n\t\t# check format of date\r\n\t\tdate_arr = d.split(DATE_SPLIT_REGEX)\r\n\t\trtassert(date_arr.size() == 3, ArgumentError,\r\n\t\t\t\"cant recognise format of date '#{d}'\")\r\n\t\t# convert to hyphens as Ruby gets confused with slashes\r\n\t\tdate_str = date_arr.join('-')\r\n\t\t## Main:\r\n\t\t# try each of the supplied date formats\r\n\t\tDATE_FMTS.each { |fmt|\r\n\t\t\tbegin\r\n\t\t\t\tdate_obj = Date.strptime(date_str, fmt)\r\n\t\t\t\treturn date_obj\r\n\t\t\trescue ArgumentError\r\n\t\t\t\t# pass\r\n\t\t\tend\r\n\t\t}\r\n\t\t# try a brute force approach\r\n\t\tbegin\r\n\t\t\tdate_obj = Date.parse(date_str)\r\n\t\t\treturn date_obj \r\n\t\trescue\r\n\t\t\tpp date_arr\r\n\t\t\traise ArgumentError, \"can't recognise format of date '#{d}'\" \r\n\t\tend\r\n\tend", "def inspect\n \"the day of the month is the \" + ordinal_list(@parts)\n end", "def day_of_the_week(day)\n @dias = {1 => \"LUNES\", 2 => \"MARTES\", 3 => \"MIERCOLES\", 4 => \"JUEVES\", 5 => \"VIERNES\", 6 => \"SÁBADO\", 7 => \"DOMINGO\"}\n return @dias[day]\n end", "def day\n return @day\n end", "def day_str(args = nil)\n ret = Datet.days(:trans => true)[self.day_in_week]\n if args and args[:short]\n ret = ret.slice(0, 3)\n end\n \n return ret\n end", "def daytime \n \"daytime\" \n end", "def doi\n doi_regex = %r{10\\.\\d{4,9}\\/[-._;()\\/:A-Z0-9]+}i\n doi = extract_from_identifier(doi_regex)\n doi&.join\n end", "def doi\n doi_regex = %r{10\\.\\d{4,9}\\/[-._;()\\/:A-Z0-9]+}i\n doi = extract_from_identifier(doi_regex)\n doi&.join\n end", "def day_of_month_format(string)\n \tif string =~ /(\\d+)(st|nd|rd|th)?\\sof the month at (.*)/\n \t\tday = $1\n \t\ttimes = parse_times($3)\n \tend\n end", "def word_to_digit(str) # I'm hoping thats not the point\n list = str.split(\" \") # cuz I'm doing it the hard way\n insertions = []\n list.each_index do |i| \n if list[i].include?(\".\") # could also be /[!?.@,]/ etc.\n list[i] = list[i].split(\".\").slice(0,list[i].length-1).join\n insertions.push(i) # collecter\n end\n end\n list.each_index do |i|\n case list[i].downcase\n when \"zero\"; list[i] = \"0\"\n when \"one\"; list[i] = \"1\"\n when \"two\"; list[i] = \"2\"\n when \"three\"; list[i] = \"3\"\n when \"four\"; list[i] = \"4\"\n when \"five\"; list[i] = \"5\"\n when \"six\"; list[i] = \"6\"\n when \"seven\"; list[i] = \"7\"\n when \"eight\"; list[i] = \"8\"\n when \"nine\"; list[i] = \"9\"\n end\n end\n insertions.each{|i| list[i] = list[i]+\".\"}\n list.join(\" \")\nend", "def format_dni\n\t if self.dni\n\t\t\t\tself.dni.upcase!\n\t\t\t\tself.dni = self.dni.rjust(9,\"0\") if self.dni.length < 9\n\t\t\tend\n\tend", "def read_date(date)\r\n case date\r\n when /(\\d{2})\\.\\s{0,}(\\d{2})\\.\\s{0,}(\\d{4})/ # format DD.MM.YYYY nebo DD. MM. YYYY\r\n date.scan(/(\\d{2})\\.\\s{0,}(\\d{2})\\.\\s{0,}(\\d{4})/) do |sep|\r\n new_date = \"#{sep[2]}-#{sep[1]}-#{sep[0]}\"\r\n return new_date\r\n end\r\n when /(\\d{2})\\/(\\d{2})\\/(\\d{4})/\r\n date.scan(/(\\d{2})\\/(\\d{2})\\/(\\d{4})/) do |sep|\r\n new_date = \"#{sep[2]}-#{sep[0]}-#{sep[1]}\"\r\n return new_date\r\n end\r\n when /(\\d{4})\\-(\\d{2})\\-(\\d{2})/ # format YYYY-MM-DD\r\n return date\r\n else\r\n puts \"ERROR! Neplatny format \\\"#{date}\\\" (prijejte format do funkce \\\"read_date\\\")\"\r\n end\r\nend", "def vali_date(str)\n # Define month and day variables\n month, day = str.split('/').map(&:to_i)\n\n # Case month variable and return month and day if they are valid\n case month\n when 2 # February (28 days)\n return month, day if (1..28).include? day\n when 4, 6, 9, 11 # April, June, September, November (30 days)\n return month, day if (1..30).include? day\n when 1, 3, 5, 7, 8, 10, 12 # January, March, May, July, August, October, December (31 days)\n return month, day if (1..31).include? day\n end\n\n # Return nil otherwise\n nil\n end", "def eval_date\n # FIXME: Make pref?\n h = Hash[\"mo\", 1, \"di\", 2, \"mi\", 3, \"do\", 4, \"fr\", 5, \"???\", 6]\n h.merge(Hash[\"mo\", 1, \"tu\", 2, \"we\", 3, \"th\", 4, \"fr\", 5, \"???\", 6])\n a = description.strip.downcase\n a = \"???\" if a.length < 3 || !h.include?(a[0..1])\n day = h[a[0..1]]\n time = a[2..a.length-1].strip.rjust(3, \"0\")\n \"#{day} #{time}\"\n end", "def port_to_i(dandp)\n a = dandp.delete(\"0-9\").to_s.upcase # Remove the numeric portion of the director/port id leaving two alpha chars\n port = a[1,1].to_s.tr('A-B','0-1') # Translate the last alpha into either 0 or 1\n end", "def day_name; Date::DAYNAMES[wday] end", "def reduce_digit(_production, _range, _tokens, _children)\n char_shorthand('d')\n end", "def parse xdydz\n nums = xdydz.split 'd'\n case nums.length\n when 2\n arr = roll nums[1].to_i, nums[0].to_i\n when 3\n temp = roll nums[1].to_i, nums[0].to_i\n arr = temp.sort[nums[2].to_i..-1]\n else\n p \"1 or 2 'd's in roll requests please\" # excellent error handling\n end\n return arr\nend", "def to_day_num(day)\n check_pre((\n (day?(day))\n ))\n\n if day_num?(day)\n return day\n elsif day_sym?(day)\n return day_sym_to_day_num(day)\n end\n\n raise(\"Can't convert day of type '\" + day.type.to_str + \"' to day number\")\nend", "def dec_d\n end", "def day?(v)\n normalize(v).to_s.match?(MATCH_PATTERN[:day])\n end", "def get_day_name(day) \n day_name = \"\"\n\n case day \n when \"Mon\"\n day_name = \"Monday\"\n when \"Tues\"\n day_name = \"Tuesday\"\n when \"Wed\"\n day_name = \"Wednesday\"\n when \"Thur\"\n day_name = \"Thursday\"\n when \"Fri\"\n day_name = \"Friday\"\n when \"Sat\"\n day_name = \"Saturday\"\n when \"Sun\"\n day_name = \"Sunday\"\n else\n day_name = \"Invalid abbreviation\"\n end \n\n return day_name\nend", "def handle_date_parse_input(string)\n string\n end", "def day(date)\n [date.day.ordinalize.to_s, month(date)].join(' ')\n end", "def digit; end", "def convert_day_to_date string\r\n Date.strptime(string.to_s,\"%Y%m%d\")\r\n end", "def to_day_num(day)\n check_pre((\n (day?(day))\n ))\n\n if day.day_num?\n return day.to_num\n elsif day_sym_elem?(day) or day.day_sym?\n return day_sym_to_day_num(day)\n end\n\n return day\n\n raise(\"Can't convert day of type '\" + day.type.to_str + \"' to day number\")\nend", "def parse (str)\n result = []\n i = 0\n\n str.chars.each { |x|\n case x\n when \"i\"\n i += 1\n when \"d\"\n i -= 1\n when \"s\"\n i = i * i\n when \"o\"\n result.push(i)\n end\n }\n return result\nend", "def nice_day string\r\n string = string.to_s\r\n return convert_day_to_date(string).strftime('%A, %B %e, %Y') if string.length == 8\r\n return Date.new(string).strftime('%A, %B %e, %Y')\r\n end", "def day_format(date)\n return nil if date.blank?\n date.strftime('%d')\n end", "def day_format(date)\n return nil if date.blank?\n date.strftime('%d')\n end", "def ordinal(num)\n\tnum = num.to_s\n\tnum2 = num.to_i\n\n if num == \"1\" || num2 % 10 == 1 && num[num.length-2] != \"1\"\n return \"st\"\n elsif num == \"2\" || num2 % 10 == 2 && num[num.length-2] != \"1\"\n return \"nd\"\n elsif num == \"3\" || num2 % 10 == 3 && num[num.length-2] != \"1\"\n return \"rd\"\n else\n return \"th\"\n end\nend", "def lunar_date(year, month, day)\n l = yang_to_nong(year, month, day)\n l[0].to_s + '-' + l[1].to_s + '-' + (/^\\d+/.match(l[2].to_s)).to_s\n end", "def convertDecades(decade=\"\") \n\t decade.gsub!(\"s\",\"\")\n\t decadeInt = decade.to_i + 9\n\t \"#{decade}-#{decadeInt.to_s}\"\n\tend", "def parse_date( day )\n day.is_a?(Date) ? day : Date.parse( day.to_s )\n end", "def hexToDec(hexChar)\n #Between 0 and 9\n if hexChar.match(/\\d/)\n return hexChar.to_i\n else\n case hexChar \n when 'A'\n return 10 \n when 'B'\n return 11 \n when 'C'\n return 12 \n when 'D'\n return 13 \n when 'E'\n return 14 \n when 'F'\n return 15\n end\n end \nend", "def parse_char_group_char\n if c = @s.scan(/\\\\[ftnr]/)\n (eval \"\\\"#{c}\\\"\").ord\n elsif c = @s.scan(/\\\\[^\\n]/)\n c[1].ord\n elsif c = @s.scan(/[^\\n\\\\\\/\\[\\]]/)\n c.ord\n end\n end", "def identify_delimiter\n logger.debug(\"DN.identify_delimeter: #{dn_string}\")\n delimiter_regexp.match(dn_string)[1]\n rescue\n raise DnDelimiterUnparsableError, \"DN delimiter could not be identified\n \\r\\nPlease ensure your string complies with RFC1779 formatting.\"\n end", "def date_from_string(date)\n\n#remove st rd nd and th\n\nfirstParse = Chronic.parse(date)\nr1 = /[a-zA-Z]/\n\nif firstParse #check if chronic managed to find anything\n\n #daY Less than 12, assume chronic wrong, aslong as also no characters such as December, \n #where it would be right\n if firstParse.day <= 12 and !r1.match(date) \n\t\n\t #swap month with day\n\t firstParse = firstParse.change(:day => firstParse.month, :month => firstParse.day)\n\n end #of if <= 12\n\n return firstParse\n \n else\n \n\treturn Date.new\n \n end #of if firstParse\nend", "def day_num_to_day_sym(day_num)\n check_pre((\n (day_num?(day_num))\n ))\n\n return DAY_SYM_SEQ.at(day_to_index(day_num))\nend", "def find_date(output)\n begin\n str = output.split(\" \")\n rescue\n # The split command above, outside this begin/rescue block, fails on\n # FreeBSD for an unknown reason. wrapping the split() command above\n # with begin/rescue on FreeBSD makes it work. It won't need rescue.\n # The command will work as obviously intended inside begin/rescue.\n # So you shouldn't get here.\n str = \"WTF\"\n end\n\n days = %w{Sun Mon Tue Wed Thu Fri Sat}\n if days.include?(str[3])\n day_index = 3\n else\n day_index = 2\n end\n\n if str[1] =~ /Never|fread/\n datestr = \"Never\"\n elsif days.include?(str[day_index])\n datestr = str[day_index..-1].join(\" \")\n else\n datestr = \"Unknown\"\n end\n\n datestr\n end", "def wrong_date(num)\n first_day(num).text\nend", "def day_num_to_day_sym(day_num)\n check_pre((\n (day_num_elem?(day_num)) or\n (day_num.day_num?)\n ))\n\n if day_num_elem?(day_num)\n DayNum.new(day_num).to_sym\n elsif day_num.day_num?\n day_num.to_sym\n end\nend", "def parse(data)\n\n number = 0\n final_array = []\n commands = data.split('')\n\n commands.each do |current_character|\n case current_character\n when \"i\"\n number += 1\n when \"d\"\n number -= 1\n when \"s\"\n number = number ** 2 \n when \"o\"\n final_array.push(number)\n end\n end\n return final_array\n end", "def ajd\n end", "def parse_date(content)\n return content.lstrip.rstrip\n end", "def weekdays\n lines[1]\n end", "def digit \n\t\n\t$cst.add_branch(\"digit\")\n\t\n\tmatch_token(\"T_DIGIT\", $tokens[$index])\n\t\n\t$cst.ascend\n\t\nend", "def extract_date(info)\n \tinfo.split(/; /).each do |str|\n begin\n Date.valid_date? *str.split('-').map(&:to_i)\n rescue \n nil\n else\n return str\n end\n end\n nil\n end", "def get_day_name(day) #convert name into the actual day_name\n day_name = \"\"\n\ncase day\nwhen \"mon\"\n day_name =\"Monday\"\nwhen \"mon\"\n day_name =\"Monday\"\nwhen \"mon\"\n day_name =\"Monday\"\nwhen \"thu\"\n day_name =\"Thursday\"\nwhen \"fri\"\n day_name =\"Friday\"\nwhen \"sat\"\n day_name =\"Saturday\"\nwhen \"sun\"\n day_name =\"Sunday\"\nelse #in case user write an option that doesnt exit we could use else keyword\n day_name = \"Invalid abbreviation\"\nend \n\nreturn day_name\nend", "def day\n return @day\n end", "def cwday\n end", "def letter_to_number(letter)\n case letter\n when \"A\", \"B\", \"C\"\n print \"2\"\n when \"D\", \"E\", \"F\"\n print \"3\"\n when \"G\", \"H\", \"I\"\n print \"4\"\n when \"J\", \"K\", \"L\"\n print \"5\"\n when \"M\", \"N\", \"O\"\n print \"6\"\n when \"P\", \"Q\", \"S\", \"T\"\n print \"7\"\n when \"T\", \"U\", \"V\"\n print \"8\"\n when \"W\", \"X\", \"Y\", \"Z\"\n print \"9\"\n when \" \"\n print \"-\"\n else \n print \"Not a letter\"\n end\nend", "def roman_leap(date)\n date[4]\n end", "def display_str_for_decade\n decade_matches = orig_date_str.match(DECADE_4CHAR_REGEXP) if orig_date_str\n if decade_matches\n changed_to_zero = decade_matches.to_s.tr('u\\-?x', '0') if decade_matches\n zeroth_year = DateParsing.new(changed_to_zero).sortable_year_for_yyyy if changed_to_zero\n return \"#{zeroth_year}s\" if zeroth_year\n else\n decade_matches = orig_date_str.match(DECADE_S_REGEXP) if orig_date_str\n return decade_matches.to_s.tr(\"'\", '') if decade_matches\n end\n end", "def normalize(v)\n v = strip_copyright(v) if v.is_a?(String)\n day_convert(v)\n end", "def day_str(timezone = patient.timezone)\n parsed_time(timezone).strftime(\"%A\")\n end", "def ordinal_indicator(number)\n if number == 0\n return \"zero\"\n elsif number.to_s.chars.map(&:to_i).last == 1 && number != 11\n return \"#{number}st\"\n elsif number.to_s.chars.map(&:to_i).last == 2 && number != 12\n return \"#{number}nd\"\n elsif number.to_s.chars.map(&:to_i).last == 3 && number != 13\n return \"#{number}rd\"\n else\n return \"#{number}th\"\n end\nend", "def get_day(timeslot)\n return timeslot.starttime.strftime(\"%d\").to_i\nend", "def parse_decimal_part(str)\n map = if str.index('割')\n Numeja::JA_割合用小数\n else\n Numeja::JA_小数\n end\n keys = map.keys()\n keys.reduce(0) do |t, ja_digit|\n index = str.index(ja_digit)\n break t if index.nil?\n unit = str.slice!(0, index)\n str.slice!(0, 1)\n t += (unit.to_f * map[ja_digit])\n t\n end\n end", "def day=(_arg0); end", "def convertDigitToNumeral(digit, index)\n returnStr = \"\"\n numerals = [\"I\", \"V\", \"X\", \"L\", \"C\", \"D\", \"M\"]\n case digit.to_i\n when 1..3\n i = 0\n while i < digit.to_i\n returnStr.concat(\"#{numerals[index]}\")\n i += 1\n end\n when 4\n returnStr.concat(\"#{numerals[index]}#{numerals[index + 1]}\")\n when 5\n returnStr.concat(\"#{numerals[index + 1]}\")\n when 6..8\n returnStr.concat(\"#{numerals[index + 1]}\")\n i = 0\n while i < (digit.to_i) - 5\n returnStr.concat(\"#{numerals[index]}\")\n i += 1\n end\n when 9\n returnStr.concat(\"#{numerals[index]}#{numerals[index + 2]}\")\n end\n return returnStr\nend", "def day_identifier\n day_baseline = Date.parse(\"2020-06-01\")\n number_baseline = 91\n\n baseline_shift = date.mjd - day_baseline.mjd\n\n number_baseline + baseline_shift\n end", "def encode_digit(d)\n d + 22 + 75 * (d < 26 ? 1 : 0)\n # 0..25 map to ASCII a..z or A..Z \n # 26..35 map to ASCII 0..9\n end", "def to_day_sym(day)\n check_pre((\n (day?(day))\n ))\n\n if day_sym?(day)\n return day\n elsif day_num?(day)\n return day_num_to_day_sym(day)\n end\n\n raise(\"Can't convert day of type '\" + day.type.to_str + \"' to day symbol\")\nend", "def character\n fetch('dumb_and_dumber.characters')\n end" ]
[ "0.65706754", "0.64472526", "0.59283096", "0.59272754", "0.5918117", "0.5857765", "0.5746278", "0.572903", "0.56919897", "0.56760955", "0.5639098", "0.5585565", "0.55712116", "0.5556135", "0.55493206", "0.5548936", "0.5515986", "0.5499876", "0.54895705", "0.54888123", "0.54875106", "0.5458036", "0.5450607", "0.54387444", "0.5424367", "0.54196006", "0.541483", "0.541483", "0.5407235", "0.53977793", "0.53800666", "0.53635275", "0.53443575", "0.52775764", "0.52663946", "0.5265773", "0.52588356", "0.5251333", "0.52478105", "0.52397746", "0.52359843", "0.52359843", "0.5226504", "0.52047664", "0.51919615", "0.5185709", "0.51843774", "0.51790434", "0.51749206", "0.5165796", "0.51631707", "0.5148898", "0.5147075", "0.5136918", "0.5112574", "0.5103309", "0.50968874", "0.5091181", "0.50869507", "0.50837094", "0.5077328", "0.5070994", "0.50654125", "0.5059647", "0.5059647", "0.5057841", "0.50526863", "0.5052133", "0.5046332", "0.50440043", "0.504304", "0.5040106", "0.5039491", "0.50323516", "0.5024048", "0.50126386", "0.5008202", "0.49972934", "0.4981339", "0.49509898", "0.49465242", "0.4925714", "0.4924245", "0.49217233", "0.49126866", "0.49024522", "0.4902057", "0.4897098", "0.48970616", "0.4893753", "0.48928314", "0.48900014", "0.48894224", "0.48850283", "0.48817852", "0.48812333", "0.48800483", "0.4865057", "0.48616916", "0.4852662" ]
0.70314485
0
Parses a "w" character from the main methods Returns the weekday sound.
def parse_weekday(time) [file_for_day(time.strftime("%w"))] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def hackerSpeak(word)\n\tnew_word=''\n\tword.each_char do |c|\n\t\tif c.downcase=='a'\n\t\t\tnew_word=new_word+'4'\n\t\telsif c.downcase=='e'\n\t\t\tnew_word=new_word+'3'\n\t\telsif c.downcase=='i'\n\t\t\tnew_word=new_word+'1'\n\t\telsif c.downcase=='o'\n\t\t\tnew_word=new_word+'0'\n\t\telsif c.downcase=='s'\n\t\t\tnew_word=new_word+'5'\n\t\telse\n\t\t\tnew_word=new_word+ c\t\t\t\t\t\t\n\t\tend\t\n\tend\n\tnew_word\nend", "def wday() end", "def wednesday\n day(:wednesday)\n end", "def what_day(string)\n if string.include?(\"L\")\n return \"Monday\"\n elsif string.include?(\"M\")\n return \"Tuesday\"\n elsif string.include?(\"I\")\n return \"Wednesday\"\n elsif string.include?(\"J\")\n return \"Thursday\"\n elsif string.include?(\"V\")\n return \"Friday\"\n elsif string.include?(\"S\")\n return \"Saturday\"\n elsif string.include?(\"D\")\n return \"Sunday\"\n end\n return \"NONE\"\n end", "def wday_shortname date\n %w'вс пн вт ср чт пт сб'[date.wday]\n end", "def test_it_can_convert_an_integer_day_of_week_to_the_word\n assert_equal \"Sunday\", FinderClass.day_of_week(0)\n assert_equal \"Monday\", FinderClass.day_of_week(1)\n assert_equal \"Tuesday\", FinderClass.day_of_week(2)\n assert_equal \"Wednesday\", FinderClass.day_of_week(3)\n assert_equal \"Thursday\", FinderClass.day_of_week(4)\n assert_equal \"Friday\", FinderClass.day_of_week(5)\n assert_equal \"Saturday\", FinderClass.day_of_week(6)\n end", "def day_of_the_week(time)\n Date::DAYNAMES[time.wday]\nend", "def mweek; (5 - wday + day) / 7 end", "def weekday(weekday)\n case weekday\n when 'tod'\n @now\n when 'tom'\n @now + 1\n when 'y'\n @now - 1\n end\n end", "def select_wday(day = nil)\n day = Date.today.wday if day.nil?\n\n wday_symbol = if day.kind_of?(Integer)\n wday_symbol = case day\n when 0\n 'Su'\n when 1\n 'M'\n when 2\n 'T'\n when 3\n 'W'\n when 4\n 'R'\n when 5\n 'F'\n when 6\n 'Sa'\n end\n else\n day\n end\n\n @config['comics'].select {|c| c['update_schedule'].include?(wday_symbol)}\n end", "def w_day; end", "def day_week(date)\n day_week = \"--\"\n unless date.blank?\n case date.strftime(\"%A\")\n when \"Monday\"\n day_week = \"月\"\n when \"Tuesday\"\n day_week = \"火\"\n when \"Wednesday\"\n day_week = \"水\"\n when \"Thursday\"\n day_week = \"木\"\n when \"Friday\"\n day_week = \"金\"\n when \"Saturday\"\n day_week = \"土\"\n when \"Sunday\"\n day_week = \"日\"\n end\n else\n end\n return day_week\n end", "def day_to_wdiw( day )\n\t\tk = offset( first_day.cwday )\n\t\td = day + k - 1\n\t\tw = d / DPW\n\t\tdiw = d % DPW\n\n\t\t[ w, diw ]\n end", "def wday\n components.weekday - 1\n end", "def W; cat @time.strftime('%W') end", "def rcwef_short(name)\n char = name.chars.first.downcase\n case char\n when 'r', 'c'\n LOW\n when 'w'\n MEDIUM\n when 'e', 'f'\n HIGH\n else\n LOW\n end\n end", "def day_of_the_week(time)\n\tDate::DAYNAMES[time.wday]\nend", "def weekday\n fail \"A value cannot be provided for #{__method__}\" if @value\n return 'Mon..Fri'\n end", "def w; cat @time.strftime('%w') end", "def weekday\n current_time = Time.new\n current_time.strftime(\"%A\")\nend", "def weekday\n current_time = Time.new\n current_time.strftime(\"%A\")\nend", "def sheetlisten()\n n=0.5\n i=0\n while i<@songstr.length-1\n case @songstr[i]\n when 'a' \n play :a\n when 'b' \n play :b\n when 'c' \n play :c\n when 'd' \n play :d\n when 'e' \n play :e\n when 'f' \n play :f\n when 'g' \n play :g\n else\n if(!is_numeric?(@songstr[i]))\n puts(\"invalid char\")\n end\n end\n if(!is_numeric?(@songstr[i+1]))\n sleep 0.5\n else\n case @songstr[i+1]\n when '2' \n #for halfnote at regular speed: sleep 1\n n=1\n when '8' \n #for eighth\n n=0.25\n when '6' \n #for sixteenth note\n n=0.125\n end\n sleep n\n i+=1\n end\n i+=1\n end\n end", "def has_sch_sound (str)\n return str + str.slice!(0,3) + 'ay'\nend", "def weekdays\n lines[1]\n end", "def week; end", "def weekday\n fail \"A value cannot be provided for #{__method__}\" if @value\n\n 'Mon..Fri'\n end", "def get_day_name(day) #convert name into the actual day_name\n day_name = \"\"\n\ncase day\nwhen \"mon\"\n day_name =\"Monday\"\nwhen \"mon\"\n day_name =\"Monday\"\nwhen \"mon\"\n day_name =\"Monday\"\nwhen \"thu\"\n day_name =\"Thursday\"\nwhen \"fri\"\n day_name =\"Friday\"\nwhen \"sat\"\n day_name =\"Saturday\"\nwhen \"sun\"\n day_name =\"Sunday\"\nelse #in case user write an option that doesnt exit we could use else keyword\n day_name = \"Invalid abbreviation\"\nend \n\nreturn day_name\nend", "def check_win(input)\n input.include?('w')\n end", "def get_day_name(day) \n day_name = \"\"\n\n case day \n when \"Mon\"\n day_name = \"Monday\"\n when \"Tues\"\n day_name = \"Tuesday\"\n when \"Wed\"\n day_name = \"Wednesday\"\n when \"Thur\"\n day_name = \"Thursday\"\n when \"Fri\"\n day_name = \"Friday\"\n when \"Sat\"\n day_name = \"Saturday\"\n when \"Sun\"\n day_name = \"Sunday\"\n else\n day_name = \"Invalid abbreviation\"\n end \n\n return day_name\nend", "def cweek\n end", "def day_of_the_week(day)\n @dias = {1 => \"LUNES\", 2 => \"MARTES\", 3 => \"MIERCOLES\", 4 => \"JUEVES\", 5 => \"VIERNES\", 6 => \"SÁBADO\", 7 => \"DOMINGO\"}\n return @dias[day]\n end", "def pbIsWeekday(wdayVariable,*arg)\n timenow = pbGetTimeNow\n wday = timenow.wday\n ret = false\n for wd in arg\n ret = true if wd==wday\n end\n if wdayVariable>0\n $game_variables[wdayVariable] = [ \n _INTL(\"Sunday\"),\n _INTL(\"Monday\"),\n _INTL(\"Tuesday\"),\n _INTL(\"Wednesday\"),\n _INTL(\"Thursday\"),\n _INTL(\"Friday\"),\n _INTL(\"Saturday\")][wday] \n $game_map.need_refresh = true if $game_map\n end\n return ret\nend", "def wave(str)\n wave_arr = []\n\n str.each_char.with_index do |letter, idx|\n next if letter == ' '\n\n wave_arr << str[0...idx] + letter.upcase + str[idx+1..-1]\n end\n wave_arr\nend", "def strptime_to_day_of_week(time)\n Time.strptime(time, '%m/%d/%Y %k').strftime('%a')\nend", "def monday\n beginning_of_week(:monday)\n end", "def parse_day(time)\n sounds_for_number(time.strftime(\"%-d\"))\n end", "def thursday\n day(:thursday)\n end", "def wday\n return self.to_a[IDX_WDAY]\n end", "def get_letter(word, index)\n if word[index] == 'Q' && index+1 < word.length && word[index+1] == 'U'\n return 'Qu'\n end\n\n return word[index]\n end", "def getDayName(abv)\n day_name = \"\"\n case abv.downcase()\n when \"mon\"\n day_name = \"Monday\"\n when \"tue\"\n day_name = \"Tuesday\"\n when \"wed\"\n day_name=\"Wednseday\"\n when \"thur\"\n day_name=\"Thursday\"\n when \"fri\"\n day_name=\"Friday\"\n when \"sat\"\n day_name=\"Saturday\"\n when \"sun\"\n day_name=\"Sunday\"\n else\n day_name = \"Invalid Abbreviation\"\n end\n \n return day_name\nend", "def parse_week\n @week = @@doc.xpath(\"//fixVersion\")[0].content\n end", "def get_day_name(day)\n# setting a variable with an empty string first\n day_name = \"\"\n\n# instead of writing a LONG if statement for all 7 days\n# we will set up a case expression\n case day\n when \"mon\"\n day_name = \"Monday\"\n when \"tue\"\n day_name = \"Tuesday\"\n when \"wed\"\n day_name = \"Wednesday\"\n when \"thu\"\n day_name = \"Thursday\"\n when \"fri\"\n day_name = \"Friday\"\n when \"sat\"\n day_name = \"Saturday\"\n when \"sun\"\n day_name = \"Sunday\"\n #if user enters invalid abbreviation\n else\n day_name = \"Invalid abbreviation\"\n end #end of case\n return day_name\nend", "def day_of_week\n\tif @current_time.wday == 0 || @current_time.wday == 6\n\t\tweek_period = \"Weekends\"\n\telse\n\t\tweek_period = \"Weekdays\"\n\tend\nend", "def speak\n\t\tputs \"Ho, ho, ho! Haaaappy holidays!\"\n\tend", "def speak\n\t\tputs \"Ho, ho, ho! Haaaappy holidays!\"\n\tend", "def speak\n\t\tputs \"Ho, ho, ho! Haaaappy holidays!\"\n\tend", "def speak\n\t\tputs \"Haaaappy holidays!! Ho, ho, ho!\"\n\tend", "def get_start_of_week(d)\n d -= DAY until d.monday?\n d\n end", "def speak\r\n\t\tputs \"Ho, ho, ho! Haaaappy holidays!\"\r\n\tend", "def song_decoder(song)\n song.gsub(\"WUB\", \" \").gsub(/\\s+/, \" \").strip\nend", "def speak()\n puts \"Ho, ho, ho! Haaaappy holidays!\"\n end", "def song_decoder(song)\n #TODO\n if song.include?(\"WUB\")\n song.gsub(\"WUB\", \" \").gsub(/\\s+/, ' ').strip()\n else\n song\n end\nend", "def day_name; Date::DAYNAMES[wday] end", "def cwday\n end", "def char_description(character)\n\thtml = open(\"https://awoiaf.westeros.org/index.php/#{character}\")\n\tdoc = Nokogiri::HTML(html)\n\tif doc.css(\"div.hatnote:first-child\").empty? #|| doc.css(\".mw-parser-output .hatnote:nth-child(2)\").empty?\n\t\tdescription = doc.css(\".mw-parser-output > p:nth-child(2)\").text.gsub!(/[^A-Za-z ,.]/,'')\n\telse \n\t\tdescription = doc.css(\".mw-parser-output > p:nth-child(3)\").text.gsub!(/[^A-Za-z ,.]/,'')\n\tend\n\n\tif character == \"Walder_Frey\"\n\t\tdescription = doc.css(\".mw-parser-output > p:nth-child(3)\").text.gsub!(/[^A-Za-z ,.]/,'')\n\tend\n\n\tif character == \"Viserys_Targaryen\"\n\t\tdescription = doc.css(\".mw-parser-output > p:nth-child(3)\").text.gsub!(/[^A-Za-z ,.]/,'')\n\tend\n\n\tif character == \"Tywin_Lannister\"\n\t\tdescription = doc.css(\".mw-parser-output > p:nth-child(2)\").text.gsub!(/[^A-Za-z ,.]/,'')\n\tend\n\tdescription\nend", "def tuesday\n day(:tuesday)\n end", "def speak\r\n\t\tputs \"Ho, ho, ho! Merry Christmas and Haaaappy holidays to all!\"\r\n\tend", "def dow(dt = nil)\n ::Date::ABBR_DAYNAMES[ to_datetime(dt).wday ].downcase.to_sym\n end", "def file_for_day(day)\n sound_path(\"day-#{day}.ul\")\n end", "def day_str(args = nil)\n ret = Datet.days(:trans => true)[self.day_in_week]\n if args and args[:short]\n ret = ret.slice(0, 3)\n end\n \n return ret\n end", "def sunday\n end_of_week(:monday)\n end", "def speak\n puts \"Ho, ho, ho! Haaaappy holidays!\"\n end", "def speak\n puts \"Ho, ho, ho! Haaaappy holidays!\"\n end", "def show_sun\r\n\tss = sun_locations @sun_location\t\r\n\t\r\n\t@width.times do |i|\r\n\t if ss.include?(i+1)\r\n print \"\\\"\"\r\n\t elsif (i+1) == @sun_location\r\n\t print \"*\"\r\n\t else\r\n\t print \"_\"\r\n\t end\r\n\tend\r\n\tprint \" --- day #{@day}\"\r\n end", "def mexican_wave_x(str)\n wave = []\n chars = str.chars\n chars.each_with_index do |c, i|\n next if c =~ /\\s/\n wave << str[0...i] + c.upcase + str[i+1..-1]\n end\n wave\nend", "def days_of_week_string\n dow = days_of_week_hash\n\n @days_of_week_string ||=\n (dow[:sunday] ? \"Su\" : \"\") +\n (dow[:monday] ? \"M\" : \"\") +\n (dow[:tuesday] ? \"Tu\" : \"\") +\n (dow[:wednesday] ? \"W\" : \"\") +\n (dow[:thursday] ? \"Th\" : \"\") +\n (dow[:friday] ? \"F\" : \"\") +\n (dow[:saturday] ? \"Sa\" : \"\")\n end", "def speak\r\n puts \"Ho, ho, ho! Haaappy holidays!\"\r\n end", "def roman_event(date)\n date[2]\n end", "def wav\n @wav ||= @info_file.sub(/txt$/, 'wav')\n end", "def speak\r\n\t\t# Prints holiday greeting\r\n\t\tputs \"Ho, ho, ho! Haaaappy holidays!\"\r\n\tend", "def weekday?\n WEEK_DAYS.include? wday\n end", "def speak\n\t\tputs \"Ho, ho, ho! Haaaappy holidays!\"\n\t\tputs \"\"\n\tend", "def speak\n \tputs \"Ho, Ho, Ho! Haaaaaappy holidays!\"\n end", "def speak\n\t\t\tputs \"#{@name} said Ho, ho, ho! Haaaappy holidays!\"\n\t\tend", "def cwday() \n _wday = @m_date.wday\n return 7 if _wday == 0\n \n return _wday\n end", "def meal_plane(time_of_week, time_of_day)\n if time_of_week == \"weekday\"\n if time_of_day == \"breakfast\"\n \"Cereal\"\n elsif time_of_day == \"lunch\"\n \"Sandwinch\"\n elsif time_of_day == \"dinner\"\n \"Chicken nuggets\"\n end\n elsif time_of_week == \"weekend\"\n if time_of_day == \"breakfast\"\n \"French toast\"\n elsif time_of_day == \"lunch\"\n \"Pizza\"\n elsif time_of_day == \"dinner\"\n \"Steak\"\n end\n end\nend", "def validate_dow(spec)\n spec = spec.to_s\n spec == \"*\" ||\n validate_numeric(spec, 0, 7) ||\n %w{sun mon tue wed thu fri sat}.include?(spec.downcase) ||\n %w{sunday monday tuesday wednesday thursday friday saturday}.include?(spec.downcase)\n end", "def first_wa(array)\n output = \"\"\n array.each do |word|\n if word[0..1].to_s == \"wa\"\n output = word\n break\n end\n end\n output\nend", "def song_decoder(song)\n song.gsub!(\"WUB\", \" \")\n return song.gsub(/\\s+/, \" \").strip\nend", "def play_word(word, loc_let, loc_num, direction)\n letters = []\n word = word.upcase.split(\"\")\n i = 0\n loc_down = BOARD_HASH[loc_let]\n if direction == \"across\"\n word.length.times do\n letters << play_letter(word[i], loc_down, loc_num)\n loc_num += 1\n i += 1\n end\n\n elsif direction == \"down\"\n\n word.length.times do\n letters << play_letter(word[i], loc_down, loc_num)\n loc_down += 1\n i += 1\n end\n end\n\n if letters.include?(false)\n return false\n else\n letters.delete(true)\n return letters\n end\n end", "def speak\n p \"Ho, ho, ho! Haaaappy holidays!\"\n end", "def day_of_week\n Date::DAYNAMES.fetch(recurring_event.day).downcase.to_sym\n end", "def week(date = Date.today)\n day = monday(date)\n (day..day + 6)\n end", "def abbr_day_name; Date::ABBR_DAYNAMES[wday] end", "def day_of_week(date)\n date.cwday # cwday returns the day of calendar week (1-7, Monday is 1).\nend", "def single_word(word)\n if word[0] =~ /[aeiou]/i\n word + \"way\"\n else\n # nueva condicionante para palabras de puras consonantes sin vocales. ej: by\n if word.split(/([aeiou].*)/).length > 1\n # Parte palabra en 2 y lo mete en un array. 1er elemento es de consonat(es) iniciales, 2o la parte restante de la palabra a partir de e incluyendo la primera vocal\n word.split(/([aeiou].*)/)[1] + word.split(/([aeiou].*)/)[0] + \"ay\"\n else\n word.split(/([aeiou].*)/)[0]\n end\n end\nend", "def day_of_week\n # Zellers: 0 = Saturday, 1 = Sunday, 2 = Monday, ..., 6 = Friday\n # day_of_week: 1 = Sunday, 7 = Saturday\n (zellers_congruence + 6) % 7\n end", "def day_of_week\n dnum = day\n dnum -= 10 if dnum > 20\n dnum -= 10 if dnum > 10\n dnum -= 1\n dnum\n end", "def test_get_1_day_forecast_text_08\n assert_equal \"Monday:\\nOvercast with rain showers at times. Thunder possible. High near 75F. Winds NE at 5 to 10 mph. Chance of rain 40%.\\n\",\n Forecast.new(zip: 27701).fc_text(0)\n end", "def next_weekday\n if next_day.on_weekend?\n next_week(:monday, same_time: true)\n else\n next_day\n end\n end", "def next_weekday\n if next_day.on_weekend?\n next_week(:monday, same_time: true)\n else\n next_day\n end\n end", "def week_days\n {\n \"1\" => 'mon',\n \"2\" => 'tue',\n \"3\" => 'wed',\n \"4\" => 'thu',\n \"5\" => 'fri',\n \"6\" => 'sat',\n \"7\" => 'sun'\n }\n end", "def get_newspaper_sym\n \"WH\"\n end", "def meal_plan(week_time, week_day) #this is Ruby method\n if week_time == 'weekday'\n if week_day == 'breakfest'\n 'egss and cheese'\n elsif week_day == 'lunch'\n \"soup and potatos\"\n elsif week_day == 'dinner'\n \"Chicken nuggets\"\n end\n elsif week_time == 'weekend'\n if week_day == 'breakfest'\n \"French tost\"\n elsif week_day == 'lunch'\n \"2 pizza\"\n elsif week_day == 'dinner'\n \"meal stack\"\n end\n end\nend", "def song_decoder(song)\n p song.gsub(\"WUB\", \" \").split * \" \"\nend", "def first_wday; (wday - day + 1) % 7 end", "def speak\n print \"Ho, ho, ho! Haaaappy holidays!\"\nend", "def day_of_week(date)\n 7 - date.cwday\n end", "def weekend(day)\n case\n\n when day == 'Saturday'\n return true\n when day == 'Sunday'\n return true\n else\n return false\n\nend\nend", "def Speak\r\n\t\tputs \"Ho, ho, ho! Haaappy holidays!\"\r\n\tend" ]
[ "0.5982429", "0.59736145", "0.5855363", "0.5843768", "0.5716571", "0.5656632", "0.5634727", "0.56127197", "0.5593326", "0.55864394", "0.5586208", "0.55794543", "0.5547098", "0.55291426", "0.5528946", "0.5461002", "0.5454875", "0.54478186", "0.5430737", "0.5403627", "0.5400925", "0.5342573", "0.5327656", "0.53272223", "0.5318734", "0.5314562", "0.53045225", "0.52973413", "0.5290993", "0.5284253", "0.5266535", "0.5259769", "0.52439517", "0.52366", "0.5235281", "0.5221255", "0.5187614", "0.51866364", "0.5175491", "0.5170679", "0.5170559", "0.516826", "0.5167109", "0.5157257", "0.5157257", "0.5157257", "0.51484174", "0.5141296", "0.512297", "0.51157737", "0.5101758", "0.51009595", "0.5100493", "0.51002467", "0.50952864", "0.5089745", "0.5074768", "0.507399", "0.5069183", "0.50647306", "0.50635606", "0.5058908", "0.5058908", "0.5058518", "0.5056428", "0.50536203", "0.5046387", "0.5046385", "0.5040111", "0.50335103", "0.5029712", "0.5029279", "0.5025374", "0.50229883", "0.50207156", "0.501688", "0.5010241", "0.50061053", "0.5003122", "0.500008", "0.499915", "0.49925956", "0.49893203", "0.49658233", "0.4965196", "0.4963974", "0.4963969", "0.49542084", "0.49481732", "0.49451196", "0.49451196", "0.49434808", "0.49413794", "0.49351", "0.49271384", "0.49219298", "0.49213406", "0.49201915", "0.49161726", "0.49151078" ]
0.63193196
0
Parses a "m" character from the main methods Returns the numbers for the minutes
def parse_minutes(time) minutes = time.strftime("%M").to_i minutes == 0 ? [sound_path("oclock.ul")] : sounds_for_number(minutes) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def minutes\n _nudge[1]\n end", "def parse_ms(with_hour: false)\n s0 = @scanner.pos\n s1 = match_digits!\n if s1 == :failed\n @scanner.pos = s0\n s0 = :failed\n elsif match_str(':') != :failed\n s3 = match_digits!\n if s3 == :failed\n @scanner.pos = s0\n s0 = :failed\n else\n @reported_pos = s0\n m = s1.join.to_i\n s = s3.join.to_i\n if with_hour\n h = m / 60\n m = m % 60\n s0 = { 'h' => h, 'm' => m, 's' => s }\n else\n s0 = { 'm' => m, 's' => s }\n end\n end\n else\n @scanner.pos = s0\n s0 = :failed\n end\n s0\n end", "def minutes\n value_parts[1]\n end", "def minutes\n value_parts[1]\n end", "def minutes() 60 * seconds end", "def minutes\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 25 )\n minutes_start_index = @input.index\n\n success = false # flag used for memoization\n\n begin\n # rule memoization\n if @state.backtracking > 0 and already_parsed_rule?( __method__ )\n success = true\n return \n end\n # at line 304:10: ( 'M' | 'm' ) ( 'I' | 'i' ) ( 'N' | 'n' ) ( 'U' | 'u' ) ( 'T' | 't' ) ( 'E' | 'e' ) ( 'S' | 's' )\n if @input.peek( 1 ).between?( T__40, T__41 )\n @input.consume\n @state.error_recovery = false\n else\n @state.backtracking > 0 and raise( ANTLR3::Error::BacktrackingFailed )\n\n mse = MismatchedSet( nil )\n raise mse\n end\n\n\n if @input.peek( 1 ).between?( T__24, T__25 )\n @input.consume\n @state.error_recovery = false\n else\n @state.backtracking > 0 and raise( ANTLR3::Error::BacktrackingFailed )\n\n mse = MismatchedSet( nil )\n raise mse\n end\n\n\n if @input.peek( 1 ).between?( T__34, T__35 )\n @input.consume\n @state.error_recovery = false\n else\n @state.backtracking > 0 and raise( ANTLR3::Error::BacktrackingFailed )\n\n mse = MismatchedSet( nil )\n raise mse\n end\n\n\n if @input.peek( 1 ).between?( T__14, T__15 )\n @input.consume\n @state.error_recovery = false\n else\n @state.backtracking > 0 and raise( ANTLR3::Error::BacktrackingFailed )\n\n mse = MismatchedSet( nil )\n raise mse\n end\n\n\n if @input.peek( 1 ).between?( T__16, T__17 )\n @input.consume\n @state.error_recovery = false\n else\n @state.backtracking > 0 and raise( ANTLR3::Error::BacktrackingFailed )\n\n mse = MismatchedSet( nil )\n raise mse\n end\n\n\n if @input.peek( 1 ).between?( T__28, T__29 )\n @input.consume\n @state.error_recovery = false\n else\n @state.backtracking > 0 and raise( ANTLR3::Error::BacktrackingFailed )\n\n mse = MismatchedSet( nil )\n raise mse\n end\n\n\n if @input.peek( 1 ).between?( T__38, T__39 )\n @input.consume\n @state.error_recovery = false\n else\n @state.backtracking > 0 and raise( ANTLR3::Error::BacktrackingFailed )\n\n mse = MismatchedSet( nil )\n raise mse\n end\n\n\n\n success = true\n\n rescue ANTLR3::Error::RecognitionError => re\n report_error(re)\n recover(re)\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 25 )\n memoize( __method__, minutes_start_index, success ) if @state.backtracking > 0\n\n end\n \n return \n end", "def minutes_flight\n stamp = @raw_data[:FlightDuration].split(\"PT\")[1]\n stamp.split(\"H\")[1].split(\"M\")[0].to_i\n rescue\n nil\n end", "def CountingMinutesI(str)\n parts = str.scan(/(\\d+):(\\d\\d)(..)-(\\d+):(\\d\\d)(..)/).flatten\n\n first_min = (parts[0].to_i * 60) + (parts[1].to_i) + (parts[2] == \"pm\" ? 720 : 0)\n second_min = (parts[3].to_i * 60) + (parts[4].to_i) + (parts[5] == \"pm\" ? 720 : 0)\n\n second_min += 1440 if first_min > second_min\n\n second_min - first_min\nend", "def CountingMinutesI(str)\n\n # code goes here\n return str \n \nend", "def mpm\n mph = self.mph\n return nil unless mph and mph.is_a?(Float)\n div = 60.0 / mph\n min = div.floor\n sec = ( ( div - min ) * 60.0 )\n \"#{ sprintf(\"%.2d\", min ) }:#{ sprintf(\"%.2d\", sec ) }\"\n end", "def CountingMinutesI(str)\n times = str.split('-')\n times.map! do |time|\n hours, minutes = time.split(':').map(&:to_i)\n hours += 12 if time[-2..-1] == 'pm' && hours < 12\n hours -= 12 if time[-2..-1] == 'am' && hours >= 12\n hours * 60 + minutes\n end\n times.reverse.inject(:-) % 1440\nend", "def handle_hh_mm\n handle_sign\n @tzhour = @tokens[@index].get_tag(ScalarHour).type\n next_tag\n next_tag\n @tzminute = @tokens[@index].get_tag(ScalarMinute).type\n next_tag\n end", "def timeConversion(s)\n if s =~ /[pP]/\n r = s.chomp(\"PM\")\n r = r.split(\":\")\n if r[0] == \"12\"\n r[0] = \"12\"\n else\n r[0] = (r[0].to_i + 12).to_s\n end \n \n r = r[0] + \":\" + r[1] + \":\" + r[2]\n elsif\n if s =~ /[aA]/\n r = s.chomp(\"AM\")\n r = r.split(\":\")\n if r[0] == \"12\"\n r[0] = \"00\"\n end\n r = r[0] + \":\" + r[1] + \":\" + r[2]\n end\n end\n p r\nend", "def time_in_minutes(time_str)\n time_in_seconds(time_str) / 60\n end", "def minutes ; self * 60 ; end", "def parse_time_unit(time_unit)\n case time_unit\n when /[0-9]+[smhdy]/\n time = time_unit[/[0-9]+/].to_i\n unit = time_unit[/[smhdy]/]\n time * UNIT_MULTIPLIER.fetch(unit)\n when /[0-9]+/\n Integer(time_unit)\n else\n raise\n end\n rescue IndexError => e\n raise InvalidParameter, \"Invalid time specification specified: '#{time_unit}'\"\n end", "def after_midnight(str)\n str = str.split(\":\")\n h = str[0].to_i % 24\n m = str[1].to_i\n minutes = (h * 60) + m \nend", "def minutes(title)\n \"https://whimsy.apache.org/board/minutes/#{title.gsub(/\\W/, '_')}\"\n end", "def CountingMinutesI(str)\n\n from = str.split(\"-\")[0]\n to = str.split(\"-\")[1]\n fromMinute = from.gsub(\"am\", \"\").gsub(\"pm\", \"\")\n fromMinute = fromMinute.split(\":\")[0].to_i * 60 + fromMinute.split(\":\")[1].to_i\n toMinute = to.gsub(\"am\", \"\").gsub(\"pm\", \"\")\n toMinute = toMinute.split(\":\")[0].to_i * 60 + toMinute.split(\":\")[1].to_i\n \n result = 0\n multiple = 12\n if(fromMinute > toMinute)\n if (from.include?(\"am\") && to.include?(\"am\")) || (from.include?(\"pm\") && to.include?(\"pm\")) \n multiple = 24\n end\n result = multiple * 60 - (fromMinute - toMinute)\n elsif\n if (from.include?(\"am\") && to.include?(\"am\")) || (from.include?(\"pm\") && to.include?(\"pm\")) \n result = toMinute - fromMinute\n elsif\n result = multiple * 60 - (fromMinute - toMinute)\n end\n end\n return result\n \nend", "def minutes; self * MINUTE; end", "def minutes; self * MINUTE; end", "def minutes ; Duration[self * 60] ; end", "def parseTime(time)\n\t\tstr = time.to_s.rjust(4, \"0\")\n\t\t@hour = str[0..1].to_i\n\t\t@minute = str[2..3].to_i\n\tend", "def time_conversion(minutes)\nend", "def englishTimeToMinutes(englishTime)\n\t\tminutes = 0\n\t\tif(englishTime[(englishTime.length - 2)..englishTime.length] == \"pm\")\n\t\t\tminutes = 720\n\t\tend\n\n\t\telements = englishTime[0..(englishTime.length - 3)].split(\":\")\n\n\t\tif(elements[0] != \"12\")\n\t\t\tminutes += 60 * (elements[0].to_i)\n\t\tend\n\n\t\tminutes += elements[1].to_i\n\n\t\treturn minutes\n\tend", "def minutes\n (seconds % 3600) / 60\n end", "def time_string(string)\n\n times=string.split(\":\")\n puts times.inspect\n residual= times[1].to_f/2\n hour_degrees=times[0].to_i*30+residual\n minutes=times[1].to_i*6\n return hour_degrees-minutes\n\nend", "def getminute()\n\t\treturn @min\n\tend", "def grabTime(str)\n if /(\\,\\s)(\\d.+\\.\\m\\.)/.match(str)\n /(\\,\\s)(\\d.+\\.\\m\\.)/.match(str)[2]\n else\n \"Ongoing\"\n end\n end", "def initialTimeDecimal(inputStartTime)\n split = inputStartTime.split(':')\n hours = split[0].to_i\n split = split[1].split(' ')\n #mins = split[0].to_i\n if (split[1] == \"PM\")\n hours += 12\n end\n return hours\nend", "def calculate_hours_minutes(output)\n return unless output =~ /up\\s+(\\d+):-?(\\d+),/\n\n SECS_IN_AN_HOUR * Regexp.last_match(1).to_i +\n SECS_IN_A_MINUTE * Regexp.last_match(2).to_i\n end", "def parse_event_line(s)\n minute, word_1, word_2 = s.scan(/.+ ..:(..)\\] (\\S+) (\\S+)/).flatten\n [minute.to_i, word_1, word_2]\n end", "def parse_time\n s0 = @scanner.pos\n if match_str('(') == :failed\n @scanner.pos = s0\n s0 = :failed\n else\n match_spaces\n s3 = parse_ms\n if s3 == :failed\n @scanner.pos = s0\n s0 = :failed\n else\n match_spaces\n if match_str('/') == :failed\n @scanner.pos = s0\n s0 = :failed\n else\n match_spaces\n s5 = parse_hms\n s5 = parse_ms(with_hour: true) if s5 == :failed\n if s5 == :failed\n @scanner.pos = s0\n s0 = :failed\n else\n match_spaces\n if match_str(')') == :failed\n @scanner.pos = s0\n s0 = :failed\n else\n @reported_pos = s0\n s0 = { 'now' => s3, 'total' => s5 }\n end\n end\n end\n end\n end\n s0\n end", "def minmethod(minutes)\n if minutes > 60\n hours, minutes = minutes.divmod(60)\n \"#{hours.to_s.rjust(2)}hr #{minutes.to_s.rjust(2)}minutes\"\n else\n \"#{minutes.to_s.rjust(2)}minutes\"\n end\n end", "def minute\n @minute\n end", "def CountingMinutesI(str)\n s = str.scan(/\\w+/).to_a\n \n arr = str.scan(/\\d+|\\D+/)\n result = (arr[0].to_i - arr[4].to_i).abs * 60 - arr[2].to_i + arr[6].to_i\n \n if arr[0] == arr[4] && arr[3].delete(\"-\") != arr[7] \n result += 720 \n elsif arr[0] == arr[4] && arr[3].delete(\"-\") == arr[7] \n result += 1440\n elsif arr[0] != arr[4] && arr[3].delete(\"-\") != arr[7]\n result += 720 \n elsif arr[0] != arr[4] && arr[3].delete(\"-\") == arr[7] \n result\n end\n \nend", "def minutes\n self * SECONDS_IN_MINUTES\n end", "def convert_minutes_into_hours(minutes)\n hour = minutes / 60\n min = minutes % 60\nputs \" #{hour}:#{min}\"\nend", "def duration_as_minutes(length)\n t = length.match(/(\\d\\d):(\\d\\d):(\\d\\d)/)\n if t\n (hours,minutes,seconds) = [t[1].to_i, t[2].to_i, t[3].to_i]\n return sprintf(\"%d:%02d\",(hours * 60 + minutes), seconds)\n else\n return 0\n end \n end", "def minutes\n self.to_i * 60\n end", "def time_in_ms(time)\n time_string = time.split(':')\n\n milliseconds = time_string.last.split('.').last\n totalmilliseconds = time_string.last.split('.').first.to_i * 1000 + milliseconds.to_i\n minutes = time_string.first.to_i * 60000\n return totalmilliseconds + minutes\nend", "def get_minutes\n de = self.string_to_datetime(@from)\n a = self.string_to_datetime(@to)\n \n total = ((a.hour - de.hour) * 60) + (a.min - de.min)\n end", "def ReturnSeconds(value)\n result = value.split(/m|s/)\n result = result[0].to_i*60 + result[1].to_i\n return result\nend", "def timeConversion(s)\n # Write your code here\n b = s[-2..-1] == 'PM' ? 12 : 0\n p b\n h = s.split(':')[0]\n h = h.to_i%12 + b\n p h\n p h.to_s + s[2..-3]\nend", "def format_minute(minute)\n first, second = minute.divmod(10)\n first_digit_arr = @@number_strs[first]\n second_digit_arr = @@number_strs[second]\n [\n first_digit_arr[0] + second_digit_arr[0],\n first_digit_arr[1] + second_digit_arr[1],\n first_digit_arr[2] + second_digit_arr[2]\n ]\n end", "def handle_hhmm\n handle_sign\n wide = @tokens[@index].get_tag(ScalarWide).type\n @tzhour = wide[0, 2].to_i\n @tzminute = wide[2, 4].to_i\n next_tag\n end", "def timeConversion(s)\n meridiem = s.scan(/[A-Z]+/).first\n s.gsub!(/[A-Z]+/, '')\n hour_str = s.scan(/\\d\\d/).first\n return s if hour_str == '12' && meridiem == 'PM'\n hour_int = hour_str.to_i\n new_hour =\n if meridiem == 'PM'\n (hour_int + 12) % 24\n else\n (hour_int - 12) % 12\n end\n s.gsub(/^\\d\\d/, new_hour.to_s.rjust(2, '0'))\nend", "def getMinutes\r\n\t\t\t\t\treturn @minutes\r\n\t\t\t\tend", "def mpk\n kmh = self.kmh\n return nil unless kmh and kmh.is_a?(Float)\n div = 60.0 / kmh\n min = div.floor\n sec = ( ( div - min ) * 60.0 ).round \n \"#{ sprintf(\"%.2d\", min ) }:#{ sprintf(\"%.2d\", sec ) }\"\n end", "def minute(padded = false)\n min = (seconds_since_start_of_hour / M_SECS).to_i\n if padded && min < 10\n min = \"0#{min}\"\n end\n min\n end", "def minutes\n (@seconds.abs / 60) % 60 * (@seconds < 0 ? -1 : 1)\n end", "def counting_minutes(str)\n time1, time2 = str.split('-')\n mins1, mins2 = time_to_minutes(time1), time_to_minutes(time2)\n difference = mins2 - mins1\n if difference.negative?\n difference += 1440\n end\n difference\nend", "def minutos(seg)\n return seg.to_f / 60\nend", "def parse_hms\n s0 = @scanner.pos\n s1 = match_digits!\n\n if s1 == :failed\n @scanner.pos = s0\n s0 = :failed\n elsif match_str(':') != :failed\n s3 = match_digits!\n if s3 == :failed\n @scanner.pos = s0\n s0 = :failed\n elsif match_str(':') != :failed\n s5 = match_digits!\n if s5 == :failed\n @scanner.pos = s0\n s0 = :failed\n else\n @reported_pos = s0\n s0 = { 'h' => s1.join.to_i, 'm' => s3.join.to_i, 's' => s5.join.to_i }\n end\n else\n @scanner.pos = s0\n s0 = :failed\n end\n else\n @scanner.pos = s0\n s0 = :failed\n end\n s0\n end", "def seconds_to_minutes(seconds)\n seconds / 60\nend", "def parse_metric_length str\n return nil if (str.nil? or str=='')\n mm = get_f_with_units( str, /(\\s)m(illi)?m(et(er|re)(s)?)?/i ) || 0\n cm = get_f_with_units( str, /(\\s)c(enti)?m(et(er|re)(s)?)?/i ) || 0\n m = get_f_with_units( str, /(\\s)m(et(er|re)(s)?)?/i ) || 0\n \n return [m, cm, mm] unless [m, cm, mm].uniq == [0]\n return nil\n end", "def time_conversion s\n converted_time = \"#{(s[0,2].to_i + 12) % 12}#{s[2,6]}\".rjust(8, \"0\")\n converted_time = \"#{converted_time[0,2].to_i + 12}#{s[2,6]}\" if s[8,9] == \"PM\"\n converted_time\n end", "def time_conversion(mins)\r\n\r\n [mins /60, mins %60].map {|t| t.to_s.rjust(2, '0')}.join(':')\r\nend", "def timeConversion(s)\n timeArr = s.split(\":\");\n hours = timeArr[0];\n minutes = timeArr[1];\n seconds = timeArr[2][0...-2]\n am_or_pm = timeArr[2][-2..-1]\n\n if am_or_pm == \"PM\" && hours != \"12\"\n hours = (hours.to_i + 12).to_s\n elsif am_or_pm == \"AM\" && hours == \"12\"\n hours = \"00\"\n end\n\n hours + \":\" + minutes + \":\" + seconds\nend", "def could_be_minute?(minute); end", "def total_minutes\n hours * 60 + minutes\n end", "def minutes\n\t\treturn self * 60\n\tend", "def minutes\n\t\treturn self * 60\n\tend", "def minute\n self.to_duration.to_units(:hour, :minute, :second).fetch(:minute)\n end", "def parse_am_pm(time)\n time.strftime(\"%P\") == \"am\" ? [sound_path(\"a-m.ul\")] : [sound_path(\"p-m.ul\")]\n end", "def time_conversion(minutes)\n\thours = minutes / 60\n\tmin = minutes % 60\n\t\tif min < 10\n\t\t\tmin_new = \"0\" + min.to_s\n\t\t\treturn \"#{hours}:#{min_new}\"\n\t\tend\n\tp \"#{hours}:#{min}\"\nend", "def timeConversion(s)\n #\n # Write your code here.\n #\n split = s.split(\":\")\n pm = split[2][-2,2]\n split[2] = split[2][0,2]\n if pm == \"AM\" && split[0] == \"12\"\n split[0] = 00\n end\n if pm == \"PM\"\n split[0] = split[0].to_i + 12\n if split[0] == 24\n split[0] = 12\n end\n end\n\n split[0] = split[0].to_s.rjust(2,\"0\")\n split[1] = split[1].to_s.rjust(2,\"0\")\n split[2] = split[2].to_s.rjust(2,\"0\")\n\n p split.join(\":\")\nend", "def chronify_qty(qty)\n minutes = 0\n if qty.strip =~ /^(\\d+):(\\d\\d)$/\n minutes += $1.to_i * 60\n minutes += $2.to_i\n elsif qty.strip =~ /^(\\d+)([hmd])?$/\n amt = $1\n type = $2.nil? ? \"m\" : $2\n\n minutes = case type.downcase\n when 'm'\n amt.to_i\n when 'h'\n (amt.to_f * 60).round\n when 'd'\n (amt.to_f * 60 * 24).round\n else\n minutes\n end\n end\n minutes * 60\n end", "def timeConversion(s)\n if s[-2..-1] == \"PM\"\n return s[0..-3] if s[0..1] == \"12\"\n converted_time = (s[0..1].to_i + 12).to_s\n converted_time + s[2..-3]\n else\n return \"00\" + s[2..-3] if s[0..1] == \"12\"\n s[0..-3]\n end\nend", "def parse_month(time)\n [file_for_month(time.strftime(\"%-m\"))]\n end", "def ampm\n if @t_hour <= 12\n return \"am\"\n else\n return \"pm\"\n end\n end", "def meridiem\n hour_24 / 12\n end", "def time_conversion(minutes)\n\t # hours = 0\n\n # while minutes >= 60 do\n # if minutes >=60\n # hours += 1\n # minutes -=60\n # end\n # end\n\n\n # new_hour = hours.to_s\n # new_minutes = minutes.to_s\n\n \tmin = minutes % 60\n hours = minutes / 60\n\n if min < 10\n \tmin = '0'+min.to_s\n end\n\n \treturn hours.to_s + ':' + min.to_s\n\nend", "def time_conversion( minutes )\n\n# https://ruby-doc.org/stdlib-2.1.1/libdoc/time/rdoc/Time.html\n#\n# must require 'time' to work\n#\n# t = Time.now\n# puts(t.iso8601)\n# puts(t.rfc2822)\n# puts(t.httpdate)\n#\n# output:\n#\n# 2018-01-18T17:36:58-08:00\n# Thu, 18 Jan 2018 17:36:58 -0800\n# Fri, 19 Jan 2018 01:36:58 GMT\n\n if( minutes < 60 )\n time = minutes.to_s()\n time = \"0:\" + time\n #puts(time)\n return time\n else\n\n hours = minutes / 60\n minutes = minutes % 60 # to get remainning minutes\n\n # puts ( hours )\n # puts( minutes )\n\n time = hours.to_s()\n minutes = minutes.to_s()\n\n if( minutes.length() == 1 )\n minutes += \"0\"\n end\n\n time = time + \":\" + minutes\n\n return time\n end\n\nend", "def time_conversion(minutes)\n if minutes / 60 == 0\n if minutes < 10 \n return \"00:0#{minutes}\"\n \n else\n return \"00:#{minutes}\"\n end\n else\n hours = minutes / 60\n minutes2 = minutes % 60\n if minutes2 == 0\n return \"0#{hours}:00\"\n else\n return \"0#{hours}:#{minutes2}\"\n end\n end\nend", "def meridiem\n if self.hour > 12 || self.hour == 0\n :pm\n else\n :am\n end\n end", "def parse_time\n # add a default time for a task.\n length_of_task = Time.now + 15.minutes\n\n # splits the entered text.\n sentence = body.split ' '\n esc_code = sentence.first\n\n # determines if the word is long enough.\n # if it was long enough, split the word into the necessary code.\n if esc_code.length >= 2\n esc_code_prefix = esc_code[0]\n esc_code_suffix = esc_code[1..-1]\n end\n\n # checks for valid escape sequence to parse.\n if esc_code_prefix == \"+\" and esc_code_suffix.match /\\d/\n # set time specified by user.\n length_of_task = Time.now + (esc_code_suffix.to_i * 60)\n # remove the escape code from the string.\n sentences = body.split ' ', 2\n self.body = sentences[1]\n end\n\n # set the completed at time field.\n self.completed_at = length_of_task\n \n end", "def humanized_minute(minutes)\n if minutes == 1\n ' ' << t('plugin_spent_time_in_issue.datetime.minutes.one')\n elsif minutes > 1\n ' ' << t('plugin_spent_time_in_issue.datetime.minutes.other', minutes: minutes)\n else\n ''\n end\n end", "def time_conversion(minutes)\n hr = 0\n min = 0\n \n while minutes >= 0\n if minutes >= 60\n minutes = minutes - 60\n hr = hr + 1\n elsif minutes < 10\n min = 0.to_s + minutes.to_s\n return hr.to_s + ':' + min.to_s\n else\n min = minutes\n return hr.to_s + ':' + min.to_s\n end\n end\nend", "def minute(date)\n time = [pad(date.hour.to_s), pad(date.minute.to_s)].join(':')\n [time, day(date)].join(' ')\n end", "def parse_time(time)\n zone = ActiveSupport::TimeZone.new(\"Central Time (US & Canada)\")\n time = time.in_time_zone(zone)\n hour = (time.hour - START_TIME) * HOUR_SHIFT\n minute = time.min / TIME_INTERVAL\n return hour + minute # this is the index used in the schedule\n end", "def parse_time(time)\n time = \"0#{time}\" if time.match(/^\\d:\\d\\d/)\n time = time.gsub(/u/, '') if utime?\n time = time.gsub(/s/, '') if stime?\n\n time\n end", "def TimeConvert(num)\n\nhour= num.div(60)\n min=num.remainder(60)\n \n return \"#{hour}\" + \":\" + \"#{min}\"\n \nend", "def minutes(num)\n t = current_time + num * SECONDS_IN_MINUTE\n {\n type: :datetime,\n value: t.iso8601\n }\n end", "def handle_mn\n handle_possible(SeparatorSpace)\n handle_possible(SeparatorSpace) if handle_possible(KeywordIn)\n @month = Date::MONTHS[@tokens[@index].get_tag(MonthName).type]\n @index += 1\n @precision = :month\n end", "def human_datetime_minute_mask\n case session[:database][:locale]\n when \"de\" then \"TT.MM.JJJJ HH:MI\"\n when \"en\" then \"YYYY-MM-DD HH:MI\"\n else \"TT.MM.JJJJ HH24:MI\" # Deutsche Variante als default\n end\n end", "def minute\n set_function_and_argument(:minute, nil)\n end", "def validate_minute(spec)\n validate_numeric(spec, 0, 59)\n end", "def time_conversion(minutes)\n hours = 0\n if minutes < 10\n minutes = \"0\" + minutes.to_s\n elsif minutes % 60 == 0 \n hours = minutes / 60\n minutes = \"00\"\n else\n hours = minutes / 60\n minutes = minutes % 60\n end\n return hours.to_s + \":\" + minutes.to_s\nend", "def findTime(t, k)\n \n # convert the given time in minutes\n minutes = ((((t[0]).ord() - ('0').ord())* 10 + \n (t[1]).ord() - ('0').ord())* 60 + \n (((t[3]).ord() - ('0').ord()) * 10 + \n (t[4]).ord() - ('0').ord()));\n \n # Add K to current minutes\n minutes += k\n \n # Obtain the new hour\n # and new minutes from minutes\n hour = (minutes / 60).to_i % 24\n \n min = minutes % 60\n \n output = \"\"\n \n # Print the hour in appropriate format\n if (hour < 10)\n output = output + 0 + hour.to_s + \":\") \n else\n output = output + hour.to_s + \":\")\n end \n \n # Print the minute in appropriate format\n if (min < 10)\n puts (0 + min.to_s) \n else\n puts (min.to_s)\n end \n\n\n end", "def parse_unit\n if @s.scan(/(?=\\()/)\n parse_group\n elsif @s.scan(/(?=\\[|\\\\[dDwWhHsS]|\\.)/)\n parse_char_group\n elsif c = parse_single_char\n Char.new c\n end\n end", "def after_midnight(str)\n hours, minutes = str.split(\":\").map(&:to_i)\n \n hours < 24 ? (hours * 60) + minutes : 0\nend", "def min_to_formatted_time(mnt)\n\t\t(Time.now.midnight + mnt.minutes).to_s(:hr12)\n\tend", "def middle(h, m)\n\n\t\tmiddleString = ''\t# return middle string from digital clock\n\t\n\t\th = h.to_s\t# convert hour from integer to string\n\t\tif m < 10\t# if minute is less than 10\n\t\t\tm = m.to_s\t\n\t\t\tm = '0' + m.to_s\t# then put the 0 in front of minute (ex 09, 02, 03)\n\t\telse\n\t\t\tm = m.to_s\t\t# if not just convert from integer to string\n\t\tend\n\t\ttotal = h + m\t\t\t# I combined the hour and minute in one string\n\t\t\n\t\tfor i in 0..total.length-1 do\t\t# loop until toal length\n\t\t\tif total[i] == '1'\t\t# if character is 1\n\t\t\t\tmiddleString = middleString + \" | \"\t# put proper bar\n\t\t\telsif total[i] == '7'\t\t# if character is 7\n\t\t\t\tmiddleString = middleString + \" |\"\t# put proper bar\n\t\t\telsif total[i]=='2' || total[i] == '3'\t\t# if character is 2 or 3\n\t\t\t\tmiddleString = middleString + \" _|\"\t# put proper bar\n\t\t\telsif total[i]=='4' || total[i] == '8' || total[i] == '9' \t#if character is 4 or 8 or 9\n\t\t\t\tmiddleString = middleString + \"|_|\"\t# put proper bar\n\t\t\telsif total[i]=='5' || total[i] == '6'\t\t# if character is 5 or 6\n\t\t\t\tmiddleString = middleString + \"|_ \"\t# put proper bar\n\t\t\telsif total[i]=='0'\t\t\t\t# if character is 0\n\t\t\t\tmiddleString = middleString + \"| |\"\t# put proper bar\n\t\t\tend\n\n\t\t\tif h.length == i+1\t\t\t\t# if hour length is matched with i\n\t\t\t\tmiddleString = middleString + \".\"\t# then put save which represent colon in the future\n\t\t\tend\n\t\tend\n\t\tmiddleString = middleString + \" |_|\"\t\t\t# this is the bar for P or A(PM or AM) at the last\n\t\tmiddleString = middleString + \"\\n\"\t\t\t# put new line\n\t\treturn middleString\t\t\t\t\t# return final middle string\n\tend", "def end_of_minute\n change(\n sec: 59,\n usec: Rational(999999999, 1000)\n )\n end", "def parse_time(str)\n seconds = 0\n str.scan(/\\d+ *[Dd]/).each { |m| seconds += (m.to_i * 24 * 60 * 60) }\n str.scan(/\\d+ *[Hh]/).each { |m| seconds += (m.to_i * 60 * 60) }\n str.scan(/\\d+ *[Mm]/).each { |m| seconds += (m.to_i * 60) }\n str.scan(/\\d+ *[Ss]/).each { |m| seconds += (m.to_i) }\n seconds\n end", "def parse_units\n # extract the unit suffix\n if self =~ /(\\d[\\d_]*(?:\\.\\d+)?)\\s*([a-zA-Z]+\\b|%(?= \\s|$))/\n units = $2.downcase\n num = $1 #.to_f\n num = num[\".\"] ? num.to_f : num.to_i\n\n case units\n when \"%\"\n # 0.01\n num / 100.0\n when \"k\"\n # 10**3\n num.thousand\n when \"m\", \"mm\"\n # 10**6\n num.million\n when \"b\", \"bn\"\n # 10**9\n num.billion\n when \"gib\", \"gb\", \"g\"\n num * 2**30\n when \"mib\", \"mb\"\n num * 2**20\n when \"kib\", \"kb\"\n num * 2**10\n when \"t\", \"tb\"\n # 10**12\n num.trillion\n when \"q\"\n # 10**15\n num.quadrillion\n when \"Q\"\n # 10**18\n num.quintillion\n when \"min\"\n # 1.minute\n num.minutes\n when \"hours\", \"h\", \"hr\", \"hrs\"\n # 1.hour\n num.hours\n when \"d\", \"days\", \"dy\"\n num.days\n else\n raise \"Invalid units: #{units.inspect}, in: #{self.inspect}\"\n end\n else\n raise \"Couldn't find any units to parse! (expecting: '<a number><some letters>')\"\n end\n end", "def minute\n if self.in_play?\n return self.round.minute\n else\n if self.finished?\n return MINUTES\n else\n return 0\n end\n end\n end", "def time_string(h, m, s)\n n = []\n n[0] = h\n n[1] = m \n n[2] = s\n \n # all greater than \n if n[0] >= 10 && n[1] >= 10 && n[2] >= 10\n return \"#{n[0]}:#{n[1]}:#{n[2]}\"\n\n # less, greater, greater\n elsif n[0] < 10 && n[1] >= 10 && n[2] >= 10\n return \"0#{n[0]}:#{n[1]}:#{n[2]}\"\n\n # less, less, greater\n elsif n[0] < 10 && n[1] < 10 && n[2] >= 10\n return \"0#{n[0]}:0#{n[1]}:#{n[2]}\"\n\n # all less than\n elsif n[0] < 10 && n[1] < 10 && n[2] < 10\n return \"0#{n[0]}:0#{n[1]}:0#{n[2]}\"\n\n # greater, less, less \n elsif n[0] >= 10 && n[1] < 10 && n[2] < 10\n return \"#{n[0]}:0#{n[1]}:0#{n[2]}\"\n\n # greater, greater, less \n elsif n[0] >= 10 && n[1] >= 10 && n[2] < 10\n return \"#{n[0]}:#{n[1]}:0#{n[2]}\"\n\n # greater, less, greater \n elsif n[0] >= 10 && n[1] < 10 && n[2] >= 10\n return \"#{n[0]}:0#{n[1]}:#{n[2]}\"\n\n # less, greater, less\n elsif n[0] < 10 && n[1] >= 10 && n[2] < 10\n return \"0#{n[0]}:#{n[1]}:0#{n[2]}\"\n\n else \n return \"Enter a positive integer\" \n end\nend", "def processing_times\n total = ab_output.match(/Total:\\s+([0-9.]+)\\s+([0-9.]+)\\s+([0-9.]+)\\s+([0-9.]+)\\s+([0-9.]+)/)\n ninety = ab_output.match(/ 90%\\s+([0-9.]+)/)\n ninetyfive = ab_output.match(/ 95%\\s+([0-9.]+)/)\n [total[1], total[2], total[4], ninety[1], ninetyfive[1], total[5]]\n end" ]
[ "0.691876", "0.6805741", "0.6769295", "0.6769295", "0.6556016", "0.6504679", "0.64736044", "0.6459606", "0.64034283", "0.6396048", "0.63351774", "0.62757033", "0.62239575", "0.6200673", "0.6146094", "0.61390084", "0.60862774", "0.6086245", "0.604878", "0.60487", "0.60487", "0.6033584", "0.60177404", "0.6011696", "0.5988984", "0.5950162", "0.5936426", "0.5923263", "0.59023607", "0.58982116", "0.5895474", "0.5891311", "0.58910453", "0.58870476", "0.58773434", "0.58703285", "0.58702016", "0.5867668", "0.58565056", "0.58502436", "0.5837049", "0.5832793", "0.58204085", "0.58197725", "0.5819184", "0.5813109", "0.5802072", "0.5784175", "0.57744867", "0.5773562", "0.5764898", "0.574582", "0.5725541", "0.57156044", "0.57122153", "0.5650431", "0.5636384", "0.56270957", "0.5626093", "0.5616618", "0.5612691", "0.5603062", "0.5603062", "0.5603048", "0.56018525", "0.56017244", "0.5600475", "0.5573796", "0.5573782", "0.5558379", "0.55518705", "0.552341", "0.55223465", "0.55071205", "0.5501985", "0.5495105", "0.5488411", "0.5484991", "0.54742956", "0.54684544", "0.54659283", "0.5459621", "0.5458618", "0.54575497", "0.5443955", "0.5442669", "0.5438717", "0.5427835", "0.54273444", "0.5425607", "0.54133004", "0.5411583", "0.53966165", "0.5390343", "0.53856915", "0.5383804", "0.53766215", "0.5375157", "0.53696203", "0.5365593" ]
0.69660586
0
Parses a "s" character from the main methods Returns the numbers for the seconds
def parse_seconds(time) sounds_for_number(time.strftime("%S")) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ReturnSeconds(value)\n result = value.split(/m|s/)\n result = result[0].to_i*60 + result[1].to_i\n return result\nend", "def parse_time(str)\n seconds = 0\n str.scan(/\\d+ *[Dd]/).each { |m| seconds += (m.to_i * 24 * 60 * 60) }\n str.scan(/\\d+ *[Hh]/).each { |m| seconds += (m.to_i * 60 * 60) }\n str.scan(/\\d+ *[Mm]/).each { |m| seconds += (m.to_i * 60) }\n str.scan(/\\d+ *[Ss]/).each { |m| seconds += (m.to_i) }\n seconds\n end", "def sec() time[2] end", "def seconds ; return aseconds % SPM ; end", "def seconds\n _nudge[2]\n end", "def parse_time\n s0 = @scanner.pos\n if match_str('(') == :failed\n @scanner.pos = s0\n s0 = :failed\n else\n match_spaces\n s3 = parse_ms\n if s3 == :failed\n @scanner.pos = s0\n s0 = :failed\n else\n match_spaces\n if match_str('/') == :failed\n @scanner.pos = s0\n s0 = :failed\n else\n match_spaces\n s5 = parse_hms\n s5 = parse_ms(with_hour: true) if s5 == :failed\n if s5 == :failed\n @scanner.pos = s0\n s0 = :failed\n else\n match_spaces\n if match_str(')') == :failed\n @scanner.pos = s0\n s0 = :failed\n else\n @reported_pos = s0\n s0 = { 'now' => s3, 'total' => s5 }\n end\n end\n end\n end\n end\n s0\n end", "def parse_event_line(s)\n minute, word_1, word_2 = s.scan(/.+ ..:(..)\\] (\\S+) (\\S+)/).flatten\n [minute.to_i, word_1, word_2]\n end", "def tv_sec() end", "def timeConversion(s)\n if s =~ /[pP]/\n r = s.chomp(\"PM\")\n r = r.split(\":\")\n if r[0] == \"12\"\n r[0] = \"12\"\n else\n r[0] = (r[0].to_i + 12).to_s\n end \n \n r = r[0] + \":\" + r[1] + \":\" + r[2]\n elsif\n if s =~ /[aA]/\n r = s.chomp(\"AM\")\n r = r.split(\":\")\n if r[0] == \"12\"\n r[0] = \"00\"\n end\n r = r[0] + \":\" + r[1] + \":\" + r[2]\n end\n end\n p r\nend", "def sec\n @sec ||= time_parts[2]\n end", "def to_seconds(sym)\n seconds = 0\n self.send(sym).split(':').reverse.each_with_index do |i, x|\n seconds += (x == 0 ? 1 : 60 ** x) * i.to_i\n end\n seconds\n end", "def parse_time(string)\n parts = string.split(\":\").map(&:to_f)\n parts = [0] + parts if parts.length == 2\n hours, minutes, seconds = parts\n seconds = hours * 3600 + minutes * 60 + seconds\n seconds.to_i\n end", "def seconds\n value_parts[2]\n end", "def seconds\n value_parts[2]\n end", "def time(text)\n scan(text, TIME, :time)\n end", "def timeConversion(s)\n # Write your code here\n b = s[-2..-1] == 'PM' ? 12 : 0\n p b\n h = s.split(':')[0]\n h = h.to_i%12 + b\n p h\n p h.to_s + s[2..-3]\nend", "def timeConversion(s)\n timeArr = s.split(\":\");\n hours = timeArr[0];\n minutes = timeArr[1];\n seconds = timeArr[2][0...-2]\n am_or_pm = timeArr[2][-2..-1]\n\n if am_or_pm == \"PM\" && hours != \"12\"\n hours = (hours.to_i + 12).to_s\n elsif am_or_pm == \"AM\" && hours == \"12\"\n hours = \"00\"\n end\n\n hours + \":\" + minutes + \":\" + seconds\nend", "def timeConversion(s)\n #\n # Write your code here.\n #\n split = s.split(\":\")\n pm = split[2][-2,2]\n split[2] = split[2][0,2]\n if pm == \"AM\" && split[0] == \"12\"\n split[0] = 00\n end\n if pm == \"PM\"\n split[0] = split[0].to_i + 12\n if split[0] == 24\n split[0] = 12\n end\n end\n\n split[0] = split[0].to_s.rjust(2,\"0\")\n split[1] = split[1].to_s.rjust(2,\"0\")\n split[2] = split[2].to_s.rjust(2,\"0\")\n\n p split.join(\":\")\nend", "def parse_ms(with_hour: false)\n s0 = @scanner.pos\n s1 = match_digits!\n if s1 == :failed\n @scanner.pos = s0\n s0 = :failed\n elsif match_str(':') != :failed\n s3 = match_digits!\n if s3 == :failed\n @scanner.pos = s0\n s0 = :failed\n else\n @reported_pos = s0\n m = s1.join.to_i\n s = s3.join.to_i\n if with_hour\n h = m / 60\n m = m % 60\n s0 = { 'h' => h, 'm' => m, 's' => s }\n else\n s0 = { 'm' => m, 's' => s }\n end\n end\n else\n @scanner.pos = s0\n s0 = :failed\n end\n s0\n end", "def handle_sy_sm_sd_h_m_s_ss_hh_mm\n handle_sy_sm_sd_h_m_s_ss\n handle_hh_mm\n end", "def time_string(string)\n\n times=string.split(\":\")\n puts times.inspect\n residual= times[1].to_f/2\n hour_degrees=times[0].to_i*30+residual\n minutes=times[1].to_i*6\n return hour_degrees-minutes\n\nend", "def to_sec(time) #needs to be a string \"min:sec.hundreths of a sec\"\n\ttime_ary = time.split(\":\").map { |num| num.to_f}#string to array of floats\n\ttime_ary[0] = time_ary[0] * 60.0#convert min to sec\n\ttime_in_sec = 0\n\ttime_ary.each { |num| time_in_sec += num }#sum total number of seconds\n\ttime_in_sec\nend", "def to_seconds(str)\n hours, minutes = str.split(\" \").map(&:to_i)\n (hours * 3600) + (minutes * 60)\n end", "def handle_sy_sm_sd_h_m_s_hh_mm\n handle_sy_sm_sd_h_m_s\n handle_hh_mm\n end", "def stime(*) end", "def parse_seconds(etime)\n time, days = etime.split(\"-\").reverse\n sec, min, hr = time.split(\":\").reverse\n\n total = 0\n total += days.to_i * DAY_SECONDS if days\n total += hr.to_i * HOUR_SECONDS if hr\n total += min.to_i * MINUTE_SECONDS if min\n total += sec.to_i if sec\n total\n end", "def timeConversion(s)\n meridiem = s.scan(/[A-Z]+/).first\n s.gsub!(/[A-Z]+/, '')\n hour_str = s.scan(/\\d\\d/).first\n return s if hour_str == '12' && meridiem == 'PM'\n hour_int = hour_str.to_i\n new_hour =\n if meridiem == 'PM'\n (hour_int + 12) % 24\n else\n (hour_int - 12) % 12\n end\n s.gsub(/^\\d\\d/, new_hour.to_s.rjust(2, '0'))\nend", "def convert_string_to_seconds(str)\n # #\"1 hour & 15 minutes\"\"\n # duration_string = str.gsub(/hours?/,'3600').gsub(/minutes?/,'60')\n # #\"1 3600 & 15 60\"\n # duration_string_array = duration_string.gsub(/[^\\w]/,\" \").split(\" \")\n # #[\"1\", \"3600\", \"15\", \"60\"]\n # duration_int_array = duration_string_array.map{ |x| x.to_i }\n # #[1, 3600, 15, 60]\n # duration_int_pairs = duration_int_array.each_slice(2).to_a\n # #[[1, 3600], [15, 60]]\n # duration_seconds = duration_int_pairs.reduce(0) { |sum,x| sum + (x[0] * x[1]) }\n # #4500\n # return duration_seconds\n return str.gsub(/hours?/,'3600').gsub(/minutes?/,'60').gsub(/[^\\w]/,\" \").split(\" \").map{ |x| x.to_i }.each_slice(2).to_a.reduce(0) { |sum,x| sum + (x[0] * x[1]) }\n end", "def split_time(line)\n str_part=line.split(\" --> \").first\n end_part=line.split(\" --> \").last\n\n str_seconds=get_time_in_seconds(str_part)\n end_seconds=get_time_in_seconds(end_part)\n return str_seconds.to_s,end_seconds.to_s\n end", "def handle_ts\n handle_at\n handle_in\n @time_special = @tokens[@index].get_tag(TimeSpecial).type\n @index += 1\n @precision = :time_special\n end", "def get_seconds_from_time(time)\n times = time.split(':')\n return Integer(times[0]) * 60 * 60 + Integer(times[1]) * 60 + Integer(times[2])\n end", "def s_to_time(string)\n if string.to_s.blank? || !string.to_s[/\\d/]\n nil\n else\n string = string.tr(\",\", \".\")\n parts = string.to_s.split(\":\").reverse\n t = 0.0\n parts.each_with_index do |part, index|\n t += part.to_f * (60.0**index)\n end\n if parts.last&.starts_with?(\"-\")\n -t\n else\n t\n end\n end\n end", "def seconds\n (hour * 60 * 60) + (min * 60)\n end", "def starttime; Time.parse(@starttime_str); end", "def sec\n return @t_sec\n end", "def parse_time(time)\n time = \"0#{time}\" if time.match(/^\\d:\\d\\d/)\n time = time.gsub(/u/, '') if utime?\n time = time.gsub(/s/, '') if stime?\n\n time\n end", "def value_from_s(value)\n a = value.scanf(@format)\n t = 0\n t += a[0] * 3600 if a.size > 0 # hours * seconds-per-hour\n t += a[1] * 60 if a.size > 1 # minutes * seconds-per-minute\n t += a[2] if a.size > 2 # seconds\n t.to_i\n end", "def timer\n seconds = (@panel_input % 100) % 60\n minutes = @panel_input / 100 + (@panel_input % 100) / 60\n \"%02<mm>d:%02<ss>d\" .% mm: minutes, ss: seconds\n end", "def timeConversion(s)\n if s[-2..-1] == \"PM\"\n return s[0..-3] if s[0..1] == \"12\"\n converted_time = (s[0..1].to_i + 12).to_s\n converted_time + s[2..-3]\n else\n return \"00\" + s[2..-3] if s[0..1] == \"12\"\n s[0..-3]\n end\nend", "def parse_dcsubtitle_tc_string( tc_string, fps )\n case tc_string\n when /\\d\\d:\\d\\d:\\d\\d:\\d\\d\\d/ # hh:mm:ss:ttt\n Timecode.parse_with_ticks( tc_string, fps )\n when /\\d\\d:\\d\\d:\\d\\d\\.\\d\\d\\d/ # hh:mm:ss.sss\n Timecode.parse( tc_string, fps )\n else\n nil\n end\nend", "def parse_time_unit(time_unit)\n case time_unit\n when /[0-9]+[smhdy]/\n time = time_unit[/[0-9]+/].to_i\n unit = time_unit[/[smhdy]/]\n time * UNIT_MULTIPLIER.fetch(unit)\n when /[0-9]+/\n Integer(time_unit)\n else\n raise\n end\n rescue IndexError => e\n raise InvalidParameter, \"Invalid time specification specified: '#{time_unit}'\"\n end", "def time_conversion s\n converted_time = \"#{(s[0,2].to_i + 12) % 12}#{s[2,6]}\".rjust(8, \"0\")\n converted_time = \"#{converted_time[0,2].to_i + 12}#{s[2,6]}\" if s[8,9] == \"PM\"\n converted_time\n end", "def sbv_time(t)\r\n i = t.to_i\r\n \"%d:%02d:%02d.%03d\" % [i/3600, i/60%60, i%60, (t*1000).to_i%1000]\r\nend", "def time_string\n time = Time.new(0)\n convert = time + seconds\n convert.asctime.split(\" \")[3]\n end", "def to_seconds(raw_time)\n time_split = raw_time.split(\":\")\n hours = time_split[0]\n minutes = time_split[1]\n seconds = time_split[2]\n return hours.to_i * 3600 + minutes.to_i * 60 + seconds.to_i\n end", "def sec() end", "def time_string(secs)\n dhms = ([secs / 86400] + Time.at(secs).utc.strftime('%H|%M|%S').split(\"|\").map(&:to_i)).zip(['day', 'hour', 'minute', 'second'])\n dhms.shift while dhms[0][0] == 0\n dhms.pop while dhms[-1][0] == 0\n dhms.map! { |(v, s)| \"#{v} #{s}#{v == 1 ? nil : 's'}\" }\n return dhms[0] if dhms.size == 1\n \"#{dhms[0..-2].join(', ')} and #{dhms[-1]}\"\n end", "def tt(time, format=:short); '13:37'; end", "def p(s) puts \"-- #{Time.now.strftime('[%H:%M:%S]')} #{s}\" end", "def p(s) puts \"-- #{Time.now.strftime('[%H:%M:%S]')} #{s}\" end", "def grab_sin(string)\n string.slice(SIN_NUMBER) \nend", "def grab_sin(string)\n match = /\\s(\\d{3}-\\d{3}-\\d{3})(\\D|$)/.match(string)\n unless match == nil\n return match.captures[0].to_s\n end\n end", "def getSec(mod = 60, unit = nil)\n return normalize(@sec, mod, unit) ;\n end", "def grab_sin(string)\n sin = string.scan(/\\b\\d{3}-\\d{3}-\\d{3}\\b/)\n return sin[0]\nend", "def grabTime(str)\n if /(\\,\\s)(\\d.+\\.\\m\\.)/.match(str)\n /(\\,\\s)(\\d.+\\.\\m\\.)/.match(str)[2]\n else\n \"Ongoing\"\n end\n end", "def parse_unit\n if @s.scan(/(?=\\()/)\n parse_group\n elsif @s.scan(/(?=\\[|\\\\[dDwWhHsS]|\\.)/)\n parse_char_group\n elsif c = parse_single_char\n Char.new c\n end\n end", "def get_seconds_after_midnight_from_hms(h, m, s); end", "def get_seconds_after_midnight_from_hms(h, m, s); end", "def symbol_per_sec\n return 1/MCS::SEC_PER_SYMBOL\n end", "def parse_hms\n s0 = @scanner.pos\n s1 = match_digits!\n\n if s1 == :failed\n @scanner.pos = s0\n s0 = :failed\n elsif match_str(':') != :failed\n s3 = match_digits!\n if s3 == :failed\n @scanner.pos = s0\n s0 = :failed\n elsif match_str(':') != :failed\n s5 = match_digits!\n if s5 == :failed\n @scanner.pos = s0\n s0 = :failed\n else\n @reported_pos = s0\n s0 = { 'h' => s1.join.to_i, 'm' => s3.join.to_i, 's' => s5.join.to_i }\n end\n else\n @scanner.pos = s0\n s0 = :failed\n end\n else\n @scanner.pos = s0\n s0 = :failed\n end\n s0\n end", "def timeConversion(s)\n time = s.split(':')\n if time.first == \"12\" && time.last[-2..-1] == 'AM'\n time[0] = time.first.to_i - 12\n elsif time.first != \"12\" && time.last[-2..-1] == 'PM'\n time[0] = time.first.to_i + 12\n end\n time.last.gsub!(/[PM AM pm am]/, '')\n # required to add leading zero to pass all hackerrank tests\n time[0] = '0' + time[0].to_s if time[0].to_s.size <= 1\n time.join(\":\")\nend", "def parse_time\n # add a default time for a task.\n length_of_task = Time.now + 15.minutes\n\n # splits the entered text.\n sentence = body.split ' '\n esc_code = sentence.first\n\n # determines if the word is long enough.\n # if it was long enough, split the word into the necessary code.\n if esc_code.length >= 2\n esc_code_prefix = esc_code[0]\n esc_code_suffix = esc_code[1..-1]\n end\n\n # checks for valid escape sequence to parse.\n if esc_code_prefix == \"+\" and esc_code_suffix.match /\\d/\n # set time specified by user.\n length_of_task = Time.now + (esc_code_suffix.to_i * 60)\n # remove the escape code from the string.\n sentences = body.split ' ', 2\n self.body = sentences[1]\n end\n\n # set the completed at time field.\n self.completed_at = length_of_task\n \n end", "def uptime_in_seconds\n if ! File.readable?(\"/proc/uptime\")\n return File.open(\"/proc/uptime\", mode=\"r\").gets[/^\\d+/].to_i\n else \n info = `uptime`.scan(/^\\s(\\d{2}.\\d{2}.\\d{2})\\sup\\s(\\d+)\\s(\\w+),\\s+(\\d+)(:\\d+|\\w+)/).flatten!\n # => [[\"19:52:49\", \"48\", \"days\", \"1\", \":26\"]]\n\n now = info[0]\n value = info[1].to_i\n unit = info[2].to_s\n precision = info[3].to_s\n surprise = info[4].to_s\n\n seconds = 0\n\n case unit\n when \"days\"\n seconds = value*24*60*60\n when \"hour\"\n seconds = value*60*60\n when \"min\"\n seconds = value*60\n end\n\n if surprise.match(/^:(\\d+)$/)[1]\n hours = precision.to_i\n minutes = $1.to_i\n seconds += hours*60*60 + minutes*60\n elsif surprise.match(/min/)\n minutes = precision.to_i\n seconds += minutes*60\n end\n\n return seconds\n end\nend", "def sounds_for_time(time, args={})\n format = args.delete(:format) || 'dMYaHm'\n result = []\n format.each_char do |c|\n result += send(\"parse_#{FORMAT_TABLE[c]}\".to_sym, time)\n end\n result\n end", "def parse_srt_times(times)\n times =~ /^([0-9:,]+) --> ([0-9:,]+)/ # May have trailing data.\n [$1, $2].map {|t| parse_srt_time(t) }\n end", "def parse_srt_time(time)\n time =~ /^(\\d+):(\\d+):(\\d+),(\\d{3})$/\n hh, mm, ss, ms = [$1, $2, $3, $4].map(&:to_i)\n hh*3600 + mm*60 + ss + ms/1000.0\n end", "def sec\n return self.to_a[IDX_SECOND]\n end", "def calculate_duration_time(string_action)\n string_action.map.with_index do |line, index|\n if index < string_action.size - 1\n start = Time.parse(line[REGEX_TIME])\n next_line = string_action[index + 1]\n finish = Time.parse(next_line[REGEX_TIME])\n (finish - start).to_s\n end\n end\nend", "def seconds() self end", "def from_hms\n nums = split(':')\n\n nums[-1] = nums[-1].to_f if nums[-1] =~ /\\d+\\.\\d+/ # convert fractional seconds to a float\n nums.map! { |n| n.is_a?(String) ? n.to_i : n } # convert the rest to integers\n\n nums_and_units = nums.reverse.zip %w[seconds minutes hours days]\n nums_and_units.map { |num, units| num.send(units) }.sum\n end", "def from_hms\n nums = split(':')\n\n nums[-1] = nums[-1].to_f if nums[-1] =~ /\\d+\\.\\d+/ # convert fractional seconds to a float\n nums.map! { |n| n.is_a?(String) ? n.to_i : n } # convert the rest to integers\n\n nums_and_units = nums.reverse.zip %w[seconds minutes hours days]\n nums_and_units.map { |num, units| num.send(units) }.sum\n end", "def time(text)\n if time?(text)\n Nickel.parse(text).occurrences[0].start_time.to_time\n else\n clean_text = clear_text(text)\n if time?(clean_text)\n Nickel.parse(clean_text).occurrences[0].start_time.to_time\n end\n end\n end", "def parse_time(row)\n raw_time = row[1]\n if raw_time\n time = \"#{raw_time[0..4]}#{raw_time[-2..-1].downcase!}\"\n\n # remove leading 0\n time = time[1..-1] if time[0] === '0'\n time\n else\n nil\n end\nend", "def transform_secs(seconds) \n time = ''\n \n h = (seconds.to_f / 3600.0).floor\n seconds = seconds - (h * 3600)\n time << \"#{h.to_s.rjust(2, '0')}:\" if h > 0\n \n m = (seconds.to_f / 60.0).floor\n seconds = seconds - (m * 60)\n time << \"#{m.to_s.rjust(2, '0')}:\"\n \n time << \"#{seconds.to_s.rjust(2, '0')}\"\n \n time\nend", "def processing_times\n total = ab_output.match(/Total:\\s+([0-9.]+)\\s+([0-9.]+)\\s+([0-9.]+)\\s+([0-9.]+)\\s+([0-9.]+)/)\n ninety = ab_output.match(/ 90%\\s+([0-9.]+)/)\n ninetyfive = ab_output.match(/ 95%\\s+([0-9.]+)/)\n [total[1], total[2], total[4], ninety[1], ninetyfive[1], total[5]]\n end", "def say_time(time, escapeDigits=ALL_SPECIAL_DIGITS) \r\n\t #calc the number of seconds elapsed since epoch (00:00:00 on January 1, 1970) \r\n diff = time.to_i\r\n\t\tmsg = \"SAY TIME #{diff} #{escape_digit_string(escapeDigits)}\"\r\n\t\tsend(msg)\r\n\t\treturn get_int_result()\r\n\tend", "def nicetime_split s\n\t\t\ts.split(/(\\d+)/).reject{|c| c.empty?}\n\t\tend", "def time_string(h, m, s)\n n = []\n n[0] = h\n n[1] = m \n n[2] = s\n \n # all greater than \n if n[0] >= 10 && n[1] >= 10 && n[2] >= 10\n return \"#{n[0]}:#{n[1]}:#{n[2]}\"\n\n # less, greater, greater\n elsif n[0] < 10 && n[1] >= 10 && n[2] >= 10\n return \"0#{n[0]}:#{n[1]}:#{n[2]}\"\n\n # less, less, greater\n elsif n[0] < 10 && n[1] < 10 && n[2] >= 10\n return \"0#{n[0]}:0#{n[1]}:#{n[2]}\"\n\n # all less than\n elsif n[0] < 10 && n[1] < 10 && n[2] < 10\n return \"0#{n[0]}:0#{n[1]}:0#{n[2]}\"\n\n # greater, less, less \n elsif n[0] >= 10 && n[1] < 10 && n[2] < 10\n return \"#{n[0]}:0#{n[1]}:0#{n[2]}\"\n\n # greater, greater, less \n elsif n[0] >= 10 && n[1] >= 10 && n[2] < 10\n return \"#{n[0]}:#{n[1]}:0#{n[2]}\"\n\n # greater, less, greater \n elsif n[0] >= 10 && n[1] < 10 && n[2] >= 10\n return \"#{n[0]}:0#{n[1]}:#{n[2]}\"\n\n # less, greater, less\n elsif n[0] < 10 && n[1] >= 10 && n[2] < 10\n return \"0#{n[0]}:#{n[1]}:0#{n[2]}\"\n\n else \n return \"Enter a positive integer\" \n end\nend", "def get_timing\r\n (time_swam.minutes.to_i > 0 ? \"#{time_swam.minutes.to_i}'\" : '') +\r\n format('%02.0f\"', time_swam.seconds.to_i) +\r\n format('%02.0f', time_swam.hundreds.to_i)\r\n end", "def duration\n search_by_text('время').strip\n end", "def seconds\n @time\n end", "def CountingMinutesI(str)\n\n # code goes here\n return str \n \nend", "def time\n a=[1, 1000, 60000, 3600000]*2\n ms = duration\n \"%02d\" % (ms / a[3]).to_s << \":\" << \n \"%02d\" % (ms % a[3] / a[2]).to_s << \":\" << \n \"%02d\" % (ms % a[2] / a[1]).to_s #<< \".\" << \n #\"%03d\" % (ms % a[1]).to_s\n end", "def epoc_to_sec(epoc)\n\n # Check if sec, usec or msec\n nbr_digit = epoc.to_s.size\n\n if nbr_digit == 10\n return epoc.to_i\n elsif nbr_digit == 13\n return (epoc.to_i/1000).to_i\n elsif nbr_digit == 16\n return (epoc.to_i/1000000).to_i\n end\n\n return epoc\nend", "def prep_time_passed\n return \"7:34\"\n end", "def string_for_seconds(seconds)\n time = seconds_to_time(seconds)\n time_name = ['year','month','week','day','hour','minute','second']\n time_string = \"\"\n time.reverse.each_with_index do |part,index|\n time_string << part.to_s + ' ' + time_name[index] + ' ' if part == 1\n time_string << part.to_s + ' ' + time_name[index] + 's ' if part > 1\n end\n time_string\n end", "def parse_single_char\n if c = @s.scan(/\\\\[ftnr]/)\n (eval \"\\\"#{c}\\\"\").ord\n elsif c = @s.scan(/\\\\[^\\n]/)\n c[1].ord\n elsif c = @s.scan(/[^\\n\\\\\\/\\+\\*\\?\\|\\{\\}\\(\\)\\[\\]\\^\\$]/)\n c.ord\n end\n end", "def timestr(subsec = true)\n if(subsec)\n \"%02d:%02d:%06.3f\" % [ getHour(nil).to_i,\n getMin().to_i,\n getSec().to_f ] ;\n else\n \"%02d:%02d:%02d\" % [ getHour(nil).to_i,\n getMin().to_i,\n getSec().to_i ] ;\n end\n\n end", "def time_format(seconds)\nend", "def time_format(seconds)\nend", "def parseTime(time)\n\t\tstr = time.to_s.rjust(4, \"0\")\n\t\t@hour = str[0..1].to_i\n\t\t@minute = str[2..3].to_i\n\tend", "def duration_to_sec(duration)\n seconds, minutes, hours = duration.split(\":\").reverse\n\n (hours.to_i * 60 * 60) + (minutes.to_i * 60) + seconds.to_i\nend", "def tick_in_seconds\n return unless VALID_TICKS.include?(tick)\n eval(tick.sub(\" \", \".\"))\n end", "def CountingMinutesI(str)\n parts = str.scan(/(\\d+):(\\d\\d)(..)-(\\d+):(\\d\\d)(..)/).flatten\n\n first_min = (parts[0].to_i * 60) + (parts[1].to_i) + (parts[2] == \"pm\" ? 720 : 0)\n second_min = (parts[3].to_i * 60) + (parts[4].to_i) + (parts[5] == \"pm\" ? 720 : 0)\n\n second_min += 1440 if first_min > second_min\n\n second_min - first_min\nend", "def time_delta_string seconds\n return 'less than a minute' if seconds < 60\n return \"#{seconds / 60} minute#{seconds / 60 == 1 ? '' : 's'}\" if\n seconds < 3000 # 50 minutes\n return 'about one hour' if seconds < 5400 # 90 minutes\n return \"#{seconds / 3600} hours\" if seconds < 64800 # 18 hours\n return 'one day' if seconds < 86400 # 1 day\n return 'about one day' if seconds < 172800 # 2 days\n return \"#{seconds / 86400} days\" if seconds < 604800 # 1 week\n return 'about one week' if seconds < 1209600 # 2 week\n return \"#{seconds / 604800} weeks\" if seconds < 7257600 # 3 months\n return \"#{seconds / 2419200} months\" if seconds < 31536000 # 1 year\n return \"#{seconds / 31536000} years\"\n end", "def get_time_in_seconds(time_part)\n time=time_part.split(\",\").first\n ss=time.split(\":\").last\n if dt = DateTime.parse(time) rescue false\n seconds = dt.hour*3600+dt.min*60+ss.to_i\n end\n return seconds.to_s\n end", "def parse_with_fractional_seconds(tc_with_fractions_of_second, fps = DEFAULT_FPS)\n fraction_expr = /\\.(\\d+)$/\n fraction_part = ('.' + tc_with_fractions_of_second.scan(fraction_expr)[0][0]).to_f\n\n seconds_per_frame = 1.0 / fps.to_f\n frame_idx = (fraction_part / seconds_per_frame).floor\n\n tc_with_frameno = tc_with_fractions_of_second.gsub(fraction_expr, \":%02d\" % frame_idx)\n\n parse(tc_with_frameno, fps)\n end", "def parse_with_fractional_seconds(tc_with_fractions_of_second, fps = DEFAULT_FPS)\n fraction_expr = /\\.(\\d+)$/\n fraction_part = ('.' + tc_with_fractions_of_second.scan(fraction_expr)[0][0]).to_f\n\n seconds_per_frame = 1.0 / fps.to_f\n frame_idx = (fraction_part / seconds_per_frame).floor\n\n tc_with_frameno = tc_with_fractions_of_second.gsub(fraction_expr, \":%02d\" % frame_idx)\n\n parse(tc_with_frameno, fps)\n end", "def parse(time_string)\n Time.at(\"#{time_string[0,10]}.#{time_string[10,13]}\".to_f)\n end", "def split_time(line,time_part,delimiter)\n\tif time_part == \"start\"\n\t part=line.split(\" --> \").first\n\telse \n\t part=line.split(\" --> \").last\n\tend\n\ttime=part.split(\",\").first\n\tss=time.split(\":\").last\n\tif dt = DateTime.parse(time) rescue false\n\t seconds = dt.hour*3600+dt.min*60+ss.to_i\n\tend\n\tseconds.to_s\n\tend" ]
[ "0.67289317", "0.6694145", "0.65751565", "0.6459403", "0.6431439", "0.6426587", "0.64001393", "0.6386974", "0.63670474", "0.6365357", "0.63624674", "0.6318847", "0.6223675", "0.6223675", "0.6223207", "0.621081", "0.620728", "0.62024933", "0.6200599", "0.6153995", "0.6150515", "0.6129411", "0.6113916", "0.6111125", "0.60889864", "0.60881674", "0.6070031", "0.5986776", "0.5927214", "0.59231985", "0.58693767", "0.5869266", "0.5867652", "0.5858064", "0.58505803", "0.58436376", "0.58214587", "0.5799976", "0.57803136", "0.57689494", "0.57555914", "0.57473594", "0.5736461", "0.572376", "0.57189196", "0.5709486", "0.57022375", "0.5693315", "0.569209", "0.569209", "0.567922", "0.56680447", "0.5667718", "0.56610286", "0.5650454", "0.5646291", "0.56462055", "0.56462055", "0.5639986", "0.5635792", "0.5634938", "0.5634577", "0.5625467", "0.5622508", "0.56221056", "0.5621875", "0.5616099", "0.55907005", "0.5573129", "0.5570998", "0.5570998", "0.55626047", "0.5545491", "0.5542638", "0.5525448", "0.5519173", "0.55178916", "0.5515619", "0.54942596", "0.54889107", "0.5488677", "0.54875547", "0.5479997", "0.5477774", "0.54750067", "0.54729754", "0.54673636", "0.5464835", "0.5455703", "0.5455703", "0.54537594", "0.54428655", "0.54371196", "0.543211", "0.54309815", "0.5430117", "0.5429041", "0.5429041", "0.5428804", "0.54286283" ]
0.7095934
0
Parses a "p" character Returns AM or PM sound files
def parse_am_pm(time) time.strftime("%P") == "am" ? [sound_path("a-m.ul")] : [sound_path("p-m.ul")] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def pbResolveAudioFile(str,volume=nil,pitch=nil)\n if str.is_a?(String)\n str=pbStringToAudioFile(str)\n str.volume=100\n str.volume=volume if volume\n str.pitch=100\n str.pitch=pitch if pitch\n end\n if str.is_a?(RPG::AudioFile)\n if volume || pitch\n return RPG::AudioFile.new(str.name,\n volume||str.volume||80,\n pitch||str.pitch||100)\n else\n return str\n end\n end\n return str\nend", "def parse_at(time)\n [sound_path(\"at.ul\")]\n end", "def timeConversion(s)\n if s =~ /[pP]/\n r = s.chomp(\"PM\")\n r = r.split(\":\")\n if r[0] == \"12\"\n r[0] = \"12\"\n else\n r[0] = (r[0].to_i + 12).to_s\n end \n \n r = r[0] + \":\" + r[1] + \":\" + r[2]\n elsif\n if s =~ /[aA]/\n r = s.chomp(\"AM\")\n r = r.split(\":\")\n if r[0] == \"12\"\n r[0] = \"00\"\n end\n r = r[0] + \":\" + r[1] + \":\" + r[2]\n end\n end\n p r\nend", "def audio?\n filename =~ /^audio/\n end", "def pfile_digits\n PFILE_REGEX_MATCHING.match(scanned_file)[1]\n end", "def sounds_for_time(time, args={})\n format = args.delete(:format) || 'dMYaHm'\n result = []\n format.each_char do |c|\n result += send(\"parse_#{FORMAT_TABLE[c]}\".to_sym, time)\n end\n result\n end", "def starts_with_p?(word)\n word.start_with?(\"<p>\")\n end", "def pbResolveAudioSE(file)\n return nil if !file\n if RTP.exists?(\"Audio/SE/\"+file,[\"\",\".wav\",\".mp3\",\".ogg\"])\n return RTP.getPath(\"Audio/SE/\"+file,[\"\",\".wav\",\".mp3\",\".ogg\"])\n end\n return nil\nend", "def pbResolveAudioSE(file)\n return nil if !file\n if RTP.exists?(\"Audio/SE/\"+file,[\"\",\".wav\",\".mp3\",\".ogg\"])\n return RTP.getPath(\"Audio/SE/\"+file,[\"\",\".wav\",\".mp3\",\".ogg\"])\n end\n return nil\nend", "def pbResolveAudioSE(file)\n return nil if !file\n if RTP.exists?(\"Audio/SE/\"+file,[\"\",\".wav\",\".mp3\",\".ogg\"])\n return RTP.getPath(\"Audio/SE/\"+file,[\"\",\".wav\",\".mp3\",\".ogg\"])\n end\n return nil\nend", "def codepoints\n Phonology.sounds.codepoints(features)\n end", "def sounds_for_digits(num)\n result = []\n num.to_s.each_char do |c|\n result << sound_path(\"#{c}.ul\")\n end\n result\n end", "def nombres_p(nombres) \n nombres.select{|x| x =~ /P/} # [\"Paula\", \"Pía\"]\nend", "def get_char_info(data, p)\n lines = data[0..p].pack('c*').split(\"\\n\")\n \n char = data[p].chr\n char = '<space>' if char == ' '\n char = '<newline>' if char == \"\\n\"\n char = '<tab>' if char == \"\\t\"\n \n info = {\n :line => lines.length,\n :pos => lines[-1].length,\n :char => char\n }\n return info\n end", "def pbPlayCry(pokemon,volume=90,pitch=nil)\n return if !pokemon\n if pokemon.is_a?(Numeric)\n pbPlayCrySpecies(pokemon,0,volume,pitch)\n elsif !pokemon.egg?\n if pokemon.respond_to?(\"chatter\") && pokemon.chatter\n pokemon.chatter.play\n else\n pkmnwav = pbCryFile(pokemon)\n if pkmnwav\n pbSEPlay(RPG::AudioFile.new(pkmnwav,volume,\n (pitch) ? pitch : (pokemon.hp*25/pokemon.totalhp)+75)) rescue nil\n end\n end\n end\nend", "def pfm_text\n return PFM::Text\n end", "def process_input_during_play(path)\n loop do\n begin\n cmd = String.read(\"cmd> \")\n if /^(h|help|\\?)$/i =~ cmd\n puts \"\"\n puts \"commands:\"\n puts \"help (also h, ?): print this help message\"\n puts \"info (also i): print mp3 info on this song\"\n puts \"remove (also r): remove this file\"\n puts \"mobile (also m): move this file to available android device (via adb command)\"\n puts \"next (also n): play the next file\"\n puts \"exit (also quit): quit the program\"\n elsif /^(info|i)$/i =~ cmd\n Mp3.new(path).inspect\n \n elsif /^(remove|r)$/i =~ cmd\n puts \"removing: #{path}\"\n FileUtils.rm_f(path)\n @settings.rebuild = true\n @broadcast = \"next\"\n elsif /^(mobile|m)$/i =~ cmd\n puts \"copying to phone\"\n puts \"base path is: #{path}\"\n Android.cp(path)\n elsif /^(next|n)$/i =~ cmd\n @broadcast = \"next\"\n elsif /^(exit|quit)$/i =~ cmd\n @broadcast = \"exit\"\n break\n else\n puts \"invalid command: #{cmd}\\nuse 'help' to see available commands...\"\n end\n\n\n rescue RuntimeError => e\n break\n end\n end\n\n end", "def parse_minutes(time)\n minutes = time.strftime(\"%M\").to_i\n minutes == 0 ? [sound_path(\"oclock.ul\")] : sounds_for_number(minutes)\n end", "def packetParse p\n # Check channel value to ensure we are dealing with an IM message\n if p[25..25].unpack(\"C\")[0] == 1\n\n # Find the length of the screenname\n snLength = p[26..26].unpack(\"c\")\n # Find the screenname\n sn = p[27..(27 + snLength[0])]\n\n\n # Check to see if we are receiving a message\n if p[9..9].unpack(\"c\")[0] == 7\n # The receiving message will always be contained 26 bytes after the screenname\n msgStart = 27 + snLength[0] + 26\n\n # We must be sending a message\n elsif p[9..9].unpack(\"c\")[0] == 6\n # The packet contains the recipients screenname, so let's just rename the sender to 'sender'\n sn = \"Sender\"\n msgStart = 27 + snLength[0] + 20\n \n # This isn't an IM packet, so exit\n else\n return nil\n end\n \n # Pull the message out of the packet data\n msg = p[msgStart..(p.length-4)]\n # Strip out any unprintable binary data\n msg = msg.gsub(/[^[:print:]]/, '')\n \n \n return [sn, msg] \n \n end\n \nend", "def ppm(dataType, ppmType, varName, varAlias)\r\n dt = dataType.ljust(12)\r\n pt = ppmType.ljust(12)\r\n vn = varName.ljust(48)\r\n va = varAlias\r\n out = <<EOF\r\nppm #{dt}#{pt}#{vn}\"#{va}\";\r\nEOF\r\n\r\n out # Return generated output\r\n end", "def song_decoder(song)\n p song.gsub(\"WUB\", \" \").split * \" \"\nend", "def paragraph(p,f)\n\t\n\t# Replaces everything that has <b>, </b>, etc.\n\tvalue = p.gsub(/<b>|<\\/b>|<a>|<\\/a>/, \"\")\n \tarr = value.split(/</)\n\n \t# Gets rid of anything else from .* to > \n \t# and fixes spaces between numbers\n\tarr.each {|x| x.gsub!(/.*>\\d*/, \"\"); \n\t\tx.gsub!(/\\&\\#\\d*\\;/, \" \"); }\n \t\n \tarr.each {|x|\n \t\tif x == arr[0] && x != \"\"\n \t\t\tf.write(\"\\t\" + x)\n\t \telsif x != \"\" && x != \"[\" && x != \"]\"\n\t \t\tf.write(x)\n \t\tend\n \t}\n \tf.write(\"\\n\")\nend", "def dd_with_p\n while /\\A(?:\\s|\\z)/ =~ @f.peek or %r!\\A//emlist\\{! =~ @f.peek\n case @f.peek\n when /\\A$/\n @f.gets\n when /\\A[ \\t]/\n @f.while_match(/\\A[ \\t]/) do |line|\n # nop\n end\n when %r!\\A//emlist\\{!\n emlist\n else\n raise 'must not happen'\n end\n end\n end", "def p(pattern)\n Parslet::Pattern.new(pattern)\n end", "def pstring(input)\n p = PascalString.new\n p.input = input\n p.parse\n p.value\nend", "def pirates_say_arrrrrrrrr(string)\n\nend", "def pbMEPlay(param,volume=nil,pitch=nil)\n return if !param\n param=pbResolveAudioFile(param,volume,pitch)\n if param.name && param.name!=\"\"\n if $game_system && $game_system.respond_to?(\"me_play\")\n $game_system.me_play(param)\n return\n elsif (RPG.const_defined?(:ME) rescue false)\n b=RPG::ME.new(param.name,param.volume,param.pitch)\n if b && b.respond_to?(\"play\")\n b.play; return\n end\n end\n Audio.me_play(canonicalize(\"Audio/ME/\"+param.name),param.volume,param.pitch)\n end\nend", "def phs(data)\n ifnt, attrs = data.unpack('vv')\n attrs = Unxls::BitOps.new(attrs)\n\n ph_type = attrs.value_at(0..1)\n ph_type_d = {\n 0x0 => :narrow_katakana,\n 0x1 => :wide_katakana,\n 0x2 => :hiragana,\n 0x3 => :any # Use any type of characters as phonetic string\n }[ph_type]\n\n alc_h = attrs.value_at(2..3)\n alc_h_d = {\n 0x0 => :general, # General alignment\n 0x1 => :left, # Left aligned\n 0x2 => :center, # Center aligned\n 0x3 => :distributed # Distributed alignment\n }[alc_h]\n\n {\n ifnt: ifnt, # ifnt (2 bytes): A FontIndex structure that specifies the font.\n phType: ph_type, # A - phType (2 bits): An unsigned integer that specifies the type of the phonetic information.\n phType_d: ph_type_d,\n alcH: alc_h, # B - alcH (2 bits): An unsigned integer that specifies the alignment of the phonetic string.\n alcH_d: alc_h_d\n # unused (12 bits): Undefined and MUST be ignored.\n }\n end", "def sound; end", "def get_program_midi_data(data)\n valid = data[0] == 0xF0 &&\n data[1] == 0x42 &&\n (data[2] & 0xF0 == 0x30) &&\n data[3] == 0x00 &&\n data[4] == 0x01 &&\n data[5] == 0x44 &&\n (data[6] == 0x4C || data[6] == 0x40) &&\n data[-1] == 0xF7\n if data[6] == 0x40\n # current program\n program = nil\n start = 7\n else\n program = data[7]\n start = 9\n end\n prog = data[start...-1]\n raise \"Invalid program\" unless valid && prog.size == 512\n from_bytes midi_decoder prog\nend", "def play_file(file)\n\t\tsystem(\"afplay #{file}\") #switching ogg123 to afplay\n\tend", "def has_sch_sound (str)\n return str + str.slice!(0,3) + 'ay'\nend", "def parse_point(text)\n m = text.match(/^(\\d)(\\w)(\\w?)/)\n unless [0, 1, 2].include?(m[1].to_i)\n parse_error \"Invalid number of faults: must be 0, 1, or 2.\"\n end\n p = @current_match.player(m[2])\n if p.nil?\n parse_error \"Player not found (abbreviation: #{text.strip}).\"\n end\n unless [\"\", \"A\", \"U\", \"W\"].include?(m[3])\n parse_error \"Invalid point description: must be blank, A, U, or W.\"\n end\n @current_point = Point.new(p, m[1], m[3])\n @current_game.add_point @current_point\n end", "def pirates_say_arrrrrrrrr(string)\n out_string = \"\"\n prev_char = \"\"\n string.each_char do |char|\n if prev_char == \"r\" || prev_char == \"R\"\n out_string << char\n end\n prev_char = char\n end\n out_string\nend", "def checkStringElement(scanner, pattern)\n if scanner.scan(/(\\w\\:\\d+)/) # e.g. \"c:23\"\n soundBank = scanner[0].scan(/\\w+/) # soundBank is an array [letter, number] as string\n pattern << (sample_paths @sounds[soundBank[0].to_sym])[soundBank[1].to_i]\n elsif scanner.scan(/\\w/) # one letter e.g. \"a\"\n pattern << @sounds[scanner[0].to_sym]\n elsif scanner.scan(/\\-\\:\\d+/) # e.g. \"-:23\"\n soundBank = scanner[0].scan(/\\d+/) # soundBank is just a number\n pattern << (sample_paths @sounds[:hyphen])[soundBank[0].to_i]\n elsif scanner.scan(/\\-/)\n pattern << @sounds[:hyphen]\n elsif scanner.scan(/\\ /)\n pattern << @sounds[:whitespace]\n elsif scanner.scan(/\\[/)\n arryResult = createArray(scanner) # call function to create an array\n pattern << arryResult\n elsif scanner.scan(/\\(/) != nil\n arryResult = createArray(scanner) # call function to create an array\n pattern << arryResult.ring # convert result to a ring\n elsif scanner.scan(/\\{/)\n arryResult = createRandomArray(scanner) # call function to create an array\n pattern << arryResult\n else\n scanner.scan(/./)\n end\nend", "def getChar\n $look = ARGF.readchar\nend", "def pirates_say_arrrrrrrrr(string)\n to_return = \"\"\n next_letter = false\n string.size.times do |letter|\n current_letter = string[letter]\n to_return << current_letter if next_letter\n next_letter = (current_letter == \"r\" or current_letter == \"R\")\n end\n to_return\n \nend", "def audio; end", "def ppp?(morpheme)\n morpheme[:pos] == '助詞'\n end", "def test_p2a_not_found\n alpha = \"FOXMART ALFA INDIGO LARGE\"\n assert_raise(RuntimeError) { Phonetic.from_phonetic(alpha) }\n assert_equal \"Invalid phonetic: FOXMART\", Phonetic.translate(\"P2A \" + alpha)\n end", "def is_audio(str)\n str.match(/\\A\\w*.(mp3|flac|alac|aac)\\Z/) != nil\nend", "def pbPlayTrainerIntroME(trainerType)\n data = pbGetTrainerTypeData(trainerType)\n if data && data[6] && data[6]!=\"\"\n bgm = pbStringToAudioFile(data[6])\n pbMEPlay(bgm)\n end\nend", "def audio_format(infile)\n format = nil\n cmd = [\"ffprobe\", \"-hide_banner\", infile]\n \n IO.popen(cmd, \"rb\", :err=>[:child, :out]) do |io| \n io.each_line do |line|\n # Stream #0:1: Audio: aac (LC), 22050 Hz, stereo, fltp\n # Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 95 kb/s\n # Stream #0:0: Audio: mp3, 22050 Hz, mono, s16p, 67 kb/s\n # Stream #0:1: Audio: mp3 (U[0][0][0] / 0x0055), 44100 Hz, stereo, s16p, 310 kb/s\n if line =~ /Stream.+Audio.+(aac|mp3)/\n format = $1\n break\n end\n end\n end\n\n case format\n when nil\n \"\"\n when \"aac\" \n \"m4a\"\n else\n format\n end\nend", "def extract_audio_details\n path = audio.queued_for_write[:original].path\n open_opts = { :encoding => 'utf-8' }\n Mp3Info.open(path, open_opts) do |mp3|\n\t self.title = mp3.tag.title \n\t self.album = mp3.tag.album\n\t self.artist = mp3.tag.artist\n\t self.track = mp3.tag.tracknum\n end\nend", "def create_pls\n pls = \"[playlist]\\n\"\n pls << \"NumberOfEntries=#{songs.size}\\n\\n\"\n\n i = 0\n while i < songs.size do\n num = i+1\n pls << \"File#{num}=#{songs[i].filename}\\n\"\n pls << \"Title#{num}=#{songs[i].title || songs[i].filename}\\n\"\n pls << \"Length#{num}=#{songs[i].duration.round}\\n\\n\"\n i+=1\n end\n\n pls << \"Version=2\"\n end", "def parse_paragraph; end", "def get_pitch\n 12 * (@octave - 1) + @@letters[@letter] + @@accidentals[@accidental]\n end", "def getAudioUri\n return @data.scan(/https:\\/\\/.*?\\.mp3/)[0]\nend", "def p\n $is_last_recording_playing = !$is_last_recording_playing\n if $is_last_recording_playing\n Thread.new do\n path = File.most_recently_edited(\"./recording/*.mp3\")\n Thread.new do\n unless path.blank?\n while $is_last_recording_playing\n Sounds::Base.play_file_with_mpg123 path \n end\n end\n end\n puts \"playing #{path}\"\n end\n else\n puts \"stopped playback\"\n end\n end", "def translate(line)\r\n if line[0,3] == \"A2P\"\r\n return to_phonetic(line[4,line.length])\r\n end\r\n if line[0,3] == \"P2A\"\r\n return from_phonetic(line[4,line.length])\r\n end\r\n \r\n return nil\r\n end", "def song_decoder(song)\n # p song.split('WUB').select { |i| i!= \"\" }.join(',').gsub(/,/, ' ')\n\n p song.gsub(/WUB/, ' ').strip.gsub(/ /, ' ')\n end", "def get_file(line)\n line.match(/-w (.+) -p/)[1]\n end", "def initialize char1\n\t\t@p=char1\n\tend", "def pause_music\n #pause itunes - yanked from https://github.com/sunny/anyplayer/blob/master/lib/anyplayer/players/itunes_mac.rb\n %x(osascript -e 'tell app \"iTunes\" to pause').rstrip\n #pause Spotify\n %x(osascript -e 'tell app \"Spotify\" to pause').rstrip\nend", "def pirates_say_arrrrrrrrr(string)\n text = \"\"\n r_exist = false\n string.split('').each do |chr|\n if r_exist == true\n text << chr\n r_exist = false\n elsif chr.downcase == \"r\"\n r_exist = true\n end\n end\n text\nend", "def out_recog_sounds(str)\n p str\n system('say', str)\n end", "def part_of_speech\n\t\treturn self.class.postype_table[ self.pos.to_sym ]\n\tend", "def pound? = unit == 'pound'", "def speakIntoFiles(spanishText, germanText, englishText)\n @spanishText = spanishText\n @germanText = germanText\n @englishText = englishText\n\n\n readingSpeedES = 140\n readingSpeedDE = 180\n readingSpeedEN = 140\n\n spanishVoice = \"Jorge\"\n germanVoice = \"Markus\"\n englishVoice =\"Susan\"\n\n # we set the character length of the file name\n # languageFileDE = \"#{germanText[0,55]}\"\n languageFileES = \"#{spanishText[0,20].chomp}\"\n languageFileEN = \"#{englishText[0,20].chomp}\"\n languageFileDE = \"#{germanText[0,20].chomp}\"\nputs `say -v #{spanishVoice} -r #{readingSpeedES} \"#{spanishText}\" -o \"#{languageFileES}\".aif`\nputs `say -v #{germanVoice} -r #{readingSpeedDE} \"#{germanText}\" -o \"#{languageFileDE}\".aif`\nputs `say -v #{englishVoice} -r #{readingSpeedEN} \"#{englishText}\" -o \"#{languageFileEN}\".aif`\nend", "def pirates_say_arrrrrrrrr(string)\n characters = \"\"\n add_letter = false\n string.length.times do |index|\n current = string[index]\n characters << current if add_letter\n add_letter = (current == 'r' || current == 'R')\n end\n characters\nend", "def initialize p_notes = 'music/?.wav'\n\n # Set some defaults\n @repeat = true\n @playing = false\n @tune = []\n @tune_index = -1\n @last_note = 0\n\n # And save the note source\n @notes_prefix, @notes_postfix = p_notes.split( '?' )\n\n end", "def p(string);end", "def pirates_say_arrrrrrrrr(string)\n last_letter_r = false\n array = []\n string.size.times { |x|\n string_letter = string[x]\n array << string_letter if last_letter_r\n last_letter_r = (string_letter == \"r\" || string_letter == \"R\") }\n array.join(\"\")\nend", "def pirates_say_arrrrrrrrr(string)\nto_return = \"\"\nr_last = false\n\nstring.downcase.each_char do |c|\n\tto_return << c if r_last\n\tr_last = (c == \"r\")\n\tend\n\nto_return\nend", "def currently_playing_key\n \"pd:c:#{code}\"\n end", "def sheetlisten()\n n=0.5\n i=0\n while i<@songstr.length-1\n case @songstr[i]\n when 'a' \n play :a\n when 'b' \n play :b\n when 'c' \n play :c\n when 'd' \n play :d\n when 'e' \n play :e\n when 'f' \n play :f\n when 'g' \n play :g\n else\n if(!is_numeric?(@songstr[i]))\n puts(\"invalid char\")\n end\n end\n if(!is_numeric?(@songstr[i+1]))\n sleep 0.5\n else\n case @songstr[i+1]\n when '2' \n #for halfnote at regular speed: sleep 1\n n=1\n when '8' \n #for eighth\n n=0.25\n when '6' \n #for sixteenth note\n n=0.125\n end\n sleep n\n i+=1\n end\n i+=1\n end\n end", "def is_match(s, p)\n dp = Array.new(s.length+1) { Array.new(p.length+1, false) }\n m, n = s.length, p.length\n dp[m][n] = true\n m.downto(0) do |i|\n (n-1).downto(0) do |j| \n first = i < m && (s[i] == p[j] || p[j] == '.')\n if p[j+1] == '*'\n dp[i][j] = dp[i][j+2] || (first && dp[i+1][j])\n else\n dp[i][j] = first && dp[i+1][j+1]\n end\n end\n end\n dp[0][0]\nend", "def make_sound()\n\n if @type == \"Guitar\"\n return \"Twing Twang...\"\n elsif @type == \"Piano\"\n return \"Plink Plonk...\"\n end #End of if statement\n\n end", "def parse_file(music_dir_path , path)\n begin\n\n begin\n # Get the relative path of the file\n relative_path = path.relative_path_from( music_dir_path ).to_s\n rescue\n puts \"File cannot be readed. Wrong file name?: #{path.to_s}\"\n return nil\n end\n\n # Do nothing if the song is already stored\n return nil if @songs[relative_path]\n\n absolute_path = path.to_s\n TagLib::MPEG::File.open( absolute_path ) do |file|\n # Create the song\n song = Song.new\n song.fill( relative_path , file , File.size(absolute_path) )\n\n # Get the artist and album\n song.artist = get_artist( file.tag.artist )\n if !song.artist\n puts \"*** #{relative_path}: Artist not found\"\n return nil\n end\n\n song.album = get_album( file.tag )\n if !song.album\n puts \"*** #{relative_path}: Album not found\"\n return nil\n end\n\n @songs[song.path] = song\n return song\n end\n rescue\n Log.log_last_exception(\"Error reading file #{path.to_s}\")\n return nil\n end\n end", "def pirates_say_arrrrrrrrr(string)\n pirate = \"\"\n # Add a blank index at the end of string in case it ends in 'r'\n string << \" \"\n string.each_char.with_index { |chr, ind|\n pirate << string[ind+1] if [\"r\",\"R\"].include?(chr)\n }\n # strip to remove that extra space at the end\n pirate.strip\nend", "def is_match(s, p)\n # . matches a single character\n # * matches any number of the preceding character including 0\n # match to the entire string\n\n # s can be empty, only lowercase\n # p can be empty, only lowercase, plus . and *\n\n return false if p[0] == '*'\n return false if p.length == 0\n\n left_i = 0\n left_j = 0\n\n i = p.length - 1\n j = s.length - 1\n\n while i >= 0\n run = false\n letter = p[i]\n\n if letter == '*'\n i -= 1\n letter = p[i]\n run = true\n end\n\n if run\n while (s[j] == letter || letter == '.') && j >= 0\n j -= 1\n end\n else\n return false if j == -1\n return false unless s[j] == letter || letter == '.'\n j -= 1\n end\n\n i -= 1\n end\n\n j == -1\n\nend", "def read_to(pattern); end", "def audio_regex\n @attributes[:audio_regex]\n end", "def han?(str)\n str =~ /\\p{Han}/\nend", "def pos(part_of_speech)\n case part_of_speech\n when 'noun'\n 'n'\n when 'adjective'\n 'adj'\n when 'verb'\n 'v'\n when 'adverb'\n 'adv'\n when 'interjection'\n 'interj'\n when 'pronoun'\n 'pron'\n when 'preposition'\n 'prep'\n when 'abbreviation'\n 'abbr'\n when 'auxiliary-verb'\n 'aux v'\n when 'conjunction'\n 'conj'\n when 'definite-article'\n 'definite article'\n when 'family-name'\n 'fam'\n when 'idiom'\n 'idiom'\n when 'imperative'\n 'imper'\n when 'noun-plural'\n 'n pl'\n when 'noun-posessive'\n 'n posessive'\n when 'past-participle'\n 'past part'\n when 'phrasal-prefix'\n 'phrasal prefix'\n when 'proper-noun'\n 'proper n'\n when 'proper-noun-plural'\n 'proper n pl'\n when 'proper-noun-posessive'\n 'proper n posessive'\n when 'verb-intransitive'\n 'vi'\n when 'verb-transitive'\n 'vt'\n else\n part_of_speech.nil? ? nil : part_of_speech.gsub('-',' ')\n end\n end", "def string=(p0) end", "def parse_player(text)\n a, n = text.split(/,\\w*/, 2)\n if n.nil?\n parse_error \"Invalid player format: please give a one-letter abbreviation and a full name.\"\n end\n unless a.strip.size == 1\n parse_error \"Invalid player abbreviation: must be one letter.\"\n end\n p = Player.new(n.strip)\n @current_match.add_player(a.strip, p)\n end", "def music_file(file)\n ext_list = $config[\"music_file\"][\"media_extentions\"].gsub(/,/,\"|\")\n \n ext = \".*\\.(#{ext_list})$\" \n name = \"\"\n\n $config['music_file']['regex'].each do |pattern|\n if file =~ /.*#{pattern}#{ext}/i\n name = $1 if $1\n return false if name =~ /^sample/i\n return true\n end\n end\n return false\nend", "def song_decoder(song)\n #TODO\n if song.include?(\"WUB\")\n song.gsub(\"WUB\", \" \").gsub(/\\s+/, ' ').strip()\n else\n song\n end\nend", "def pirates_say_arrrrrrrrr(string)\n\nstring.downcase!\nsplitsplat = string.split(//)\nresult = \"\"\n\nsplitsplat.each_with_index do |l, index|\n if l == \"r\"\n result << splitsplat[index + 1].to_s\n end\nend\nreturn result\nend", "def PLS\n if @pls.nil?\n wasat = @file.pos\n self.current_sample = @no_samples\n @pls = {}\n section = nil\n @file.read.split(/\\r\\n/).each do |line|\n if line =~ /^\\[(.+?)\\]$/\n section = {}\n @pls[$1] = section\n elsif line =~ /^(.+)=(.+)$/\n section[$1] = $2\n else\n # Unknown Data format\n end\n end\n @file.seek(wasat)\n @pls\n else\n @pls\n end\n end", "def is_persian(str)\n str =~ /\\p{Arabic}/\n end", "def speak(title)\n\n a = KjReading.verses title\n\n a.each do |x|\n\n filename = download_ogg(x.title)\n command = @audio_player + ' ' + filename\n system command\n\n end\n\n end", "def fontReport(psdFiles)\n fontData = Array.new\n\n psdFiles.each do |psdFile|\n name = File.basename(psdFile)\n PSD.open(psdFile) do |psd|\n puts \"\\n[ #{name} ] Font used =================================== \\n\\n\"\n psd.layers.each do |layer|\n fontRaw = layer.text\n fontString = fontRaw.to_s()\n fontstring = fontString.gsub!(':font=>{:name=>\"', \"spliter\")\n fontstring = fontString.gsub!('\", :sizes=>[', \"spliter\")\n fontArray = fontString.split(\"spliter\")\n fontName = fontArray[1].to_s()\n if fontName == \"\"\n else\n fontData.push(\"* \" + fontName)\n end\n end\n end\n fontDataClean = fontData.uniq\n fontDataClean.each do |d|\n puts d\n end\n end\nend", "def parse_single_char\n if c = @s.scan(/\\\\[ftnr]/)\n (eval \"\\\"#{c}\\\"\").ord\n elsif c = @s.scan(/\\\\[^\\n]/)\n c[1].ord\n elsif c = @s.scan(/[^\\n\\\\\\/\\+\\*\\?\\|\\{\\}\\(\\)\\[\\]\\^\\$]/)\n c.ord\n end\n end", "def pinyin char_code\n # look up in recent_table\n if char_code < 1000\n char_code = POLYGLOT_TMP[:RECENT][char_code-1][:char_code].to_i\n end\n\n uri = URI(\"http://www.hanviet.org/hv_timchu.php?unichar=#{char_code}\")\n res = Net::HTTP.get uri\n regex = /javascript:mandarin\\('([\\w]+)'\\)/ \n match = regex.match res\n return puts \"Can't find pinyin for char #{char_code}\" if match.nil?\n uchar = [char_code].pack \"U*\"\n puts \"#{uchar} #{match.to_a.last}\"\n end", "def asterisk_converter(input)\n asterisk_switcher = input.split(\"\")\n asterisk_switcher.each do |letter|\n letter.gsub!(/[aeiou]/, '*')\n end\nend", "def beep(type = 'ok')\n process_command :beep, type\n end", "def parse_pushand(file)\n File.open(file).each_line do |line|\n case line\n when /^phd \\$0 (.+)$/\n return $1\n end\n end\n end", "def pirates_say_arrrrrrrrr(string)\n to_return = \"\"\n add_next = false\n string.size.times do |index|\n current_char = string[index,1] # the second param here tells it to get a str of length 1. This is only necessary on 1.8. If you are on 1.9, just go with string[index]\n to_return << current_char if add_next\n add_next = (current_char == \"r\" || current_char == \"R\")\n end\n to_return\nend", "def get_filename_regex\n return AUDIO_FILENAME_REGEX\n end", "def audiotype(audio)\n if audio == \"n\"\n return \"Non-directive Audio\"\n elsif audio == \"d\"\n return \"Directive Audio\"\n else\n return \"invalid type\"\n end \n end", "def bubble_sound\n pid = fork{exec 'afplay', \"lib/Large_bubble_sound.mp3\"}\n end", "def pbReadPBS(filename)\n\tparsedData = {}\n\tpath = \"PBS\" + File::SEPARATOR + filename + \".txt\"\n\tif !File.exists?(path)\n\t\traise _INTL(\"File '{1}' doesn't exist\", file)\n\telse\n\t\tFile.open(path,\"r\") do |f|\n\t\t\tsection = \"\"\n\t\t\tlineno = 0\n\t\t\tf.each_line do |line|\n\t\t\t\tlineno += 1\n\t\t\t\tline = line.chomp\n\t\t\t\tif /^#/ =~ line\n\t\t\t\t\tnext\n\t\t\t\tend\n\t\t\t\techoln(\"Line \" + lineno.to_s)\n\t\t\t\t\n\t\t\t\tif matchSection = /^\\s*\\[\\s*(.+)\\s*\\]\\s*$/.match(line)\n\t\t\t\t\tsection = matchSection[1]\n\t\t\t\t\tparsedData[section] = {}\n\t\t\t\telsif matchAttribute = /^\\s*(\\w+)\\s*=\\s*(.+)\\s*$/.match(line)\n\t\t\t\t\tparsedData[section][matchAttribute[1]] = matchAttribute[2]\n\t\t\t\telse\n\t\t\t\t\traise _INTL(\"Syntax error in line {1}\", lineno.to_s)\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend\n\t\n\treturn parsedData\nend", "def pirates_say_arrrrrrrrr(string)\n\n\tarr = string.split(//)\n\n output = []\n arr.each_cons(2) { |a,b| output << b if a == \"r\" || a == \"R\" }\n output.join\n\nend", "def extract_metadata\n return unless audio?\n logger.debug(maudio_params[:path])\n logger.debug('It\\'s audio')\n path = maudio_params[:path]\n #url = URI.parse(path) # turn the string into a URI\n #http = Net::HTTP.new(url.host, url.port) \n #req = Net::HTTP::Get.new(url.path) # init a request with the url\n #req.range = (0..4096) # limit the load to only 4096 bytes\n #res = http.request(req) # load the mp3 file\n #child = {} # prepare an empty array to store the metadata we grab\n #open_opts = { :encoding => 'utf-8' }\n #Mp3Info.open( StringIO.open(res.body) ) do |m| #do the parsing\n # child['title'] = m.tag.title \n # child['album'] = m.tag.album \n # child['artist'] = m.tag.artist\n # child['length'] = m.length\n # \n # puts m\n #end\n #logger.debug('*********************')\n \n #logger.debug(child['length'])\n #logger.debug('*********************')\n end", "def pbPlayTrainerIntroME(trainer_type)\r\n trainer_type_data = GameData::TrainerType.get(trainer_type)\r\n return if nil_or_empty?(trainer_type_data.intro_ME)\r\n bgm = pbStringToAudioFile(trainer_type_data.intro_ME)\r\n pbMEPlay(bgm)\r\nend", "def pirates_say_arrrrrrrrr(string)\n\tcharacters = string.split('')\n\tchar_index = []\n\toutput = \"\"\n\tcharacters.each_with_index {|char,index| char.downcase == \"r\" ? char_index.push(index += 1) : ''}\n \tcharacters.map.with_index {|char,index| char_index.include?(index) ? output << char : nil }.compact\n return output\nend", "def test_play_song__on_piano\n result = @musician2.play_song(\"Rocket Man\")\n assert_equal(\"Plink Plonk... I'm playing Rocket Man\", result)\n end", "def parse_name(full_name)\n letter = full_name[0].upcase\n octave = full_name[/\\d+/].to_i\n accidental = full_name[/[b#x]+/] || \"\"\n return letter, octave, accidental\n end" ]
[ "0.545785", "0.5429428", "0.5306381", "0.51962537", "0.5174581", "0.5147074", "0.5139501", "0.5045755", "0.5045755", "0.5045755", "0.5045554", "0.49954948", "0.49948603", "0.49886262", "0.49773237", "0.4969655", "0.49572945", "0.49486795", "0.49465916", "0.49029744", "0.49014077", "0.48968896", "0.4895245", "0.48929802", "0.4820115", "0.48176774", "0.48147517", "0.48004323", "0.47901562", "0.47771326", "0.47688717", "0.47670278", "0.4758974", "0.4749788", "0.47379068", "0.4726804", "0.4713158", "0.47076058", "0.4694648", "0.46885854", "0.46878818", "0.4685883", "0.46834564", "0.46758312", "0.4658862", "0.46515492", "0.46499285", "0.4646653", "0.46461082", "0.46417242", "0.46404362", "0.4639008", "0.46314833", "0.46235773", "0.4616778", "0.46005455", "0.4599616", "0.45995972", "0.4599361", "0.45947087", "0.45790052", "0.45764828", "0.45761603", "0.45687303", "0.45653832", "0.45603016", "0.45542392", "0.45515963", "0.45504487", "0.45499015", "0.4547214", "0.45468995", "0.45378593", "0.45366937", "0.45363927", "0.45348495", "0.45313865", "0.4530951", "0.4529476", "0.45293596", "0.451754", "0.4510821", "0.45037454", "0.44991717", "0.44972003", "0.4492021", "0.44915894", "0.4488281", "0.44876936", "0.44838083", "0.44810885", "0.44794193", "0.44788113", "0.44772598", "0.4476935", "0.4476745", "0.44759902", "0.44737568", "0.44697514", "0.44646913" ]
0.69330776
0
Parses a "a" character Returns a "at" connection
def parse_at(time) [sound_path("at.ul")] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def handle_at\n handle_possible(KeywordAt)\n handle_possible(SeparatorSpace)\n end", "def at!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 13 )\n\n type = AT\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at line 145:6: '@'\n match( 0x40 )\n\n \n @state.type = type\n @state.channel = channel\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 13 )\n\n end", "def at!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in(__method__, 9)\n\n type = AT\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at line 15:6: '@'\n match(?@)\n\n \n @state.type = type\n @state.channel = channel\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out(__method__, 9)\n\n end", "def get_char at\n index = range_correct_index(at)\n return internal_object_get(index + 1)\n end", "def ats\n abtAts.unpack 'C*'\n end", "def getChar\n $look = ARGF.readchar\nend", "def NextChar\r\n\t\t@Line.slice!(0, 1)\r\n\tend", "def parse_escaped_chars\n @src.pos += @src.matched_size\n add_text(@src[1])\n end", "def on_characters(chars)\n end", "def char_at(index)\n\tself.to_array[index.to_i]\n end", "def alphabet_position(text)\n \nend", "def next_char\n @current_char_pos += 1\n @current_char = @string[@current_char_pos, 1]\n end", "def char_at(column)\n line[column, 1]\n end", "def line_char_to_offset(text, line, character); end", "def parse_letter(from_where, letter, key)\n # Check if you go from Z to A or z to a\n return (letter.ord + key > from_where)?((letter.ord + key - 26).chr):((letter.ord + key).chr)\n end", "def char_at(index)\n\tself.to_array[index.to_i]\nend", "def scan_for_at(token); end", "def scan_ap\n enter_at_mode\n self.write \"ATAS#{CR}\"\n ap = []\n loop {\n sc = wait_cr 3000 # scan type\n break if !sc || sc.size == 0 || sc == 'ERROR'\n ch = wait_cr # channel number\n st = wait_cr # security type ('00':open, '01':WPA, '02':WPA2, '03':WEP)\n lm = wait_cr # Link margin\n id = wait_cr # SSID\n sec_type = case st\n when '00'; :none\n when '01'; :wpa\n when '02'; :wpa2\n when '03'; :wep\n else; nil\n end\n ap << [id, sec_type] # ssid, sec_type\n }\n cmd \"ATCN\"\n return ap\n end", "def letter!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 56 )\n\n type = LETTER\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at line 355:9: ( 'a' .. 'z' | 'A' .. 'Z' )\n if @input.peek( 1 ).between?( 0x41, 0x5a ) || @input.peek( 1 ).between?( 0x61, 0x7a )\n @input.consume\n else\n mse = MismatchedSet( nil )\n recover mse\n raise mse\n end\n\n\n\n \n @state.type = type\n @state.channel = channel\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 56 )\n\n end", "def set_char at , char\n raise \"char not fixnum #{char}\" unless char.kind_of? Fixnum\n index = range_correct_index(at)\n internal_object_set( index + 1 , char )\n end", "def _get_anotation(row)\n m = row.match(/\\s*@(\\w+)\\s*(\\()?/) or return row\n head, elm = m[1,2]\n elm.nil? and return [m.post_match, head]\n _, bracket, post = _get_bracket(elm + m.post_match, '\\(')\n [post.lstrip, head + bracket]\n end", "def forward characters\n @char += characters\n char || false\n end", "def char!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 30 )\n\n\n\n type = CHAR\n channel = ANTLR3::DEFAULT_CHANNEL\n # - - - - label initialization - - - -\n\n\n # - - - - main rule block - - - -\n # at line 203:5: '\\\\'' . '\\\\''\n match( 0x27 )\n match_any\n match( 0x27 )\n\n\n @state.type = type\n @state.channel = channel\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 30 )\n\n\n end", "def letter!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 40 )\n\n type = LETTER\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at line 139:9: ( 'a' .. 'z' | 'A' .. 'Z' )\n if @input.peek( 1 ).between?( 0x41, 0x5a ) || @input.peek( 1 ).between?( 0x61, 0x7a )\n @input.consume\n else\n mse = MismatchedSet( nil )\n recover mse\n raise mse\n end\n\n\n\n \n @state.type = type\n @state.channel = channel\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 40 )\n\n end", "def action(a)\n if (a==1)\n @sink_io.write @the_a\n end\n if (a==1 || a==2)\n @the_a = @the_b\n if (@the_a == \"\\'\" || @the_a == \"\\\"\")\n while (true)\n @sink_io.write @the_a\n @the_a = get\n break if (@the_a == @the_b)\n raise \"Unterminated string literal\" if (@the_a <= \"\\n\")\n if (@the_a == \"\\\\\")\n @sink_io.write @the_a\n @the_a = get\n end\n end\n end\n end\n if (a==1 || a==2 || a==3)\n @the_b = mynext\n if (@the_b == \"/\" && (@the_a == \"(\" || @the_a == \",\" || @the_a == \"=\" ||\n @the_a == \":\" || @the_a == \"[\" || @the_a == \"!\" ||\n @the_a == \"&\" || @the_a == \"|\" || @the_a == \"?\"))\n @sink_io.write @the_a\n @sink_io.write @the_b\n while (true)\n @the_a = get\n if (@the_a == \"/\")\n break\n elsif (@the_a == \"\\\\\")\n @sink_io.write @the_a\n @the_a = get\n elsif (@the_a <= \"\\n\")\n raise \"Unterminated RegExp Literal\"\n end\n @sink_io.write @the_a\n end\n @the_b = mynext\n end\n end\n end", "def matchChar(c)\r\n\t\tcheckSpace\r\n\t\tcheckLine\r\n\t\traise \"rejects wrong match\" unless c == @Line[0]\r\n\t\t\t@Line.slice!(0, 1)\r\n\t\t\t#@output_file.print c\r\n\t\t\tcheckSpace\r\n\tend", "def read characters\n forward characters\n end", "def char_at(index)\n self.to_array[index.to_i]\n end", "def line_from_char(index = -1)\n send_message(:LINEFROMCHAR, index.to_i)\n end", "def look_ahead(kclass, index, char, buffer, classified_sentence, nivel_parentese)\n if @raw[index + 1] && kclass::REGEX.match( \"#{buffer}#{char}#{@raw[index + 1]}\" )\n buffer.concat char\n else\n classified_sentence.push kclass.new(buffer+char)\n buffer.clear\n end\n end", "def character; end", "def character; end", "def character; end", "def character; end", "def character; end", "def character; end", "def character; end", "def character; end", "def character; end", "def character; end", "def character; end", "def character; end", "def character; end", "def character; end", "def character; end", "def character; end", "def character; end", "def character; end", "def character; end", "def a!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 20 )\n\n type = A\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at line 347:7: 'a'\n match( 0x61 )\n\n \n @state.type = type\n @state.channel = channel\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 20 )\n\n end", "def nextchar\n c = self.more?() ? @source[@index,1] : \"\\0\"\n @index += 1\n return(c)\n end", "def char(char, other_alphabet)\n self[other_alphabet.index(char)]\n end", "def scan_single_char()\n\t\tresult = if metachar?(lexeme)\n\t\t\t# A Meta-character...\n\t\t\tenqueue_token(lexeme.dup)\n\t\telse\n\t\t\tenqueue_token(:T_CHARLIT)\n\t\tend\n\t\t\n\t\treturn result\n\tend", "def peek_char(lookahead = 1)\n @string[@current_char_pos + lookahead, 1]\n end", "def parse(char = \" \")\n consumed = \"\"\n while c = consume\n break if c == char || c == \"\\n\"\n consumed += c\n end\n return consumed\nend", "def next_char\n @pos += 1\n if (c = @source[@pos..@pos]) == BACKSLASH\n @pos += 1\n [true, @source[@pos..@pos]]\n else\n [false, c]\n end\n end", "def letters_before(char)\n (\"a\"...char).to_a\nend", "def address_lookahead\n\tlookahead = []\n\twhile @sym == SYM_ATOM ||\n @sym == SYM_ATOM_NON_ASCII ||\n @sym == SYM_QTEXT ||\n @sym == SYM_PERIOD\n\t lookahead.push([@sym, @lexeme])\n\t get\n\tend\n\tretval = @sym\n\tputback(@sym, @lexeme)\n\tputback_array(lookahead)\n\tget\n\tretval\n end", "def parse_char(char)\n RUBY_VERSION > '1.9' ? char : char.chr\n end", "def char\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 59 )\n\n\n return_value = CharReturnValue.new\n\n # $rule.start = the first token seen before matching\n return_value.start = @input.look\n\n\n root_0 = nil\n\n __COMILLA321__ = nil\n set322 = nil\n __COMILLA323__ = nil\n\n\n tree_for_COMILLA321 = nil\n tree_for_set322 = nil\n tree_for_COMILLA323 = nil\n\n begin\n root_0 = @adaptor.create_flat_list\n\n\n # at line 569:10: COMILLA ( EscapeSequence |~ ( '\\\\'' | '\\\\\\\\' ) ) COMILLA\n __COMILLA321__ = match( COMILLA, TOKENS_FOLLOWING_COMILLA_IN_char_2781 )\n if @state.backtracking == 0\n tree_for_COMILLA321 = @adaptor.create_with_payload( __COMILLA321__ )\n @adaptor.add_child( root_0, tree_for_COMILLA321 )\n\n end\n\n\n set322 = @input.look\n\n if @input.peek( 1 ).between?( ASIGNACION, COMA ) || @input.peek( 1 ).between?( CORDER, WS ) || @input.peek( 1 ).between?( T__81, T__82 )\n @input.consume\n if @state.backtracking == 0\n @adaptor.add_child( root_0, @adaptor.create_with_payload( set322 ) )\n end\n\n @state.error_recovery = false\n\n else\n @state.backtracking > 0 and raise( ANTLR3::Error::BacktrackingFailed )\n\n\n mse = MismatchedSet( nil )\n raise mse\n\n end\n\n\n __COMILLA323__ = match( COMILLA, TOKENS_FOLLOWING_COMILLA_IN_char_2798 )\n if @state.backtracking == 0\n tree_for_COMILLA323 = @adaptor.create_with_payload( __COMILLA323__ )\n @adaptor.add_child( root_0, tree_for_COMILLA323 )\n\n end\n\n\n # - - - - - - - rule clean up - - - - - - - -\n return_value.stop = @input.look( -1 )\n\n\n if @state.backtracking == 0\n return_value.tree = @adaptor.rule_post_processing( root_0 )\n @adaptor.set_token_boundaries( return_value.tree, return_value.start, return_value.stop )\n\n end\n\n rescue ANTLR3::Error::RecognitionError => re\n report_error(re)\n recover(re)\n return_value.tree = @adaptor.create_error_node( @input, return_value.start, @input.look(-1), re )\n\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 59 )\n\n\n end\n\n return return_value\n end", "def nextmatch(char)\n n = self.nextchar\n raise \"Expected '#{char}' and instead saw '#{n}'.\" if (n != char)\n return(n)\n end", "def oraclechar\n foo=[]\n self.asciime.split(',').each {|chr| foo << \"CHR(#{chr})\" }\n foo.join('||')\n end", "def loalpha!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 45 )\n\n type = LOALPHA\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at line 182:12: ( 'a' .. 'z' )+\n # at file 182:12: ( 'a' .. 'z' )+\n match_count_1 = 0\n while true\n alt_1 = 2\n look_1_0 = @input.peek( 1 )\n\n if ( look_1_0.between?( 0x61, 0x7a ) )\n alt_1 = 1\n\n end\n case alt_1\n when 1\n # at line 182:13: 'a' .. 'z'\n match_range( 0x61, 0x7a )\n\n else\n match_count_1 > 0 and break\n eee = EarlyExit(1)\n\n\n raise eee\n end\n match_count_1 += 1\n end\n\n\n \n @state.type = type\n @state.channel = channel\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 45 )\n\n end", "def lookahead(input: $input)\n $lookahead = input.getc\nend", "def lookahead(input: $input)\n $lookahead = input.getc\nend", "def parse_atx_header; end", "def get_swapped_char (letter)\n\tif is_vowel(letter)\n\t\tget_next_vowel(letter)\n\telse\n\t\tget_next_consonant(letter)\n\tend\nend", "def get_swapped_char (letter)\n\tif is_vowel(letter)\n\t\tget_next_vowel(letter)\n\telse\n\t\tget_next_consonant(letter)\n\tend\nend", "def stringNextChar\r\n\t\t@Line.slice!(0, 1)\r\n\t\tcheckLine\r\n\tend", "def readchar() end", "def readchar() end", "def readchar() end", "def parse_letter(input)\n input = input.strip()\n letter = \"\"\n if input != \"\"\n letter = input[0].downcase\n end\n letter\n end", "def char\n self[@char]\n end", "def at(p0) end", "def goto_entry_starting_with fc=nil\n unless fc\n fc = get_single \"Entries starting with: \"\n #fc = get_char\n end\n return if fc.size != 1\n ## this is wrong and duplicates the functionality of /\n # It shoud go to cursor of item starting with fc\n $patt = \"^#{fc}\"\nend", "def character_by_character(string)\nend", "def at(*args)\n @at = args\n end", "def line_at(char)\n return nil unless char\n text[0..char].count(\"\\n\") + 1\n end", "def get_char\n @look = @expression[@number]\n @number +=1\nend", "def goto_entry_starting_with fc=nil\n unless fc\n print \"Entries starting with: \"\n fc = get_char\n end\n return if fc.size != 1\n ## this is wrong and duplicates the functionality of /\n # It shoud go to cursor of item starting with fc\n $patt = \"^#{fc}\"\nend", "def consume_isa\n position = 0\n buffer = \" \"\n\n # @todo: This would probably more optimal if it was written like\n # consume(\"I\") >>= consume_prefix(\"S\") >>= consume_prefix(\"A\")\n while @input.defined_at?(position)\n character = @input.at(position)\n position += 1\n\n unless Reader.is_control_character?(character)\n # Slide the \"window\" forward one character\n buffer = buffer.slice(1..-1)\n buffer = buffer + character.upcase\n if buffer == \"ISA\"\n return success(advance(position))\n end\n end\n end\n\n failure(\"reached end of input before finding ISA segment identifier\")\n end", "def line_at(io, char)\n read(io)[0..char].count(\"\\n\") + 1\n end", "def namechar!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 45 )\n\n \n # - - - - main rule block - - - -\n # at line \n if @input.peek( 1 ).between?( 0x2d, 0x2e ) || @input.peek( 1 ).between?( 0x30, 0x3a ) || @input.peek( 1 ).between?( 0x41, 0x5a ) || @input.peek(1) == 0x5f || @input.peek( 1 ).between?( 0x61, 0x7a )\n @input.consume\n else\n mse = MismatchedSet( nil )\n recover mse\n raise mse\n end\n\n\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 45 )\n\n end", "def process_character( node )\n result = nil\n \n case node.type.name\n when \"general_character\"\n result = node.text.codepoints[0]\n \n when \"escape_sequence\"\n if @@escape_sequences.member?(node.text) then\n result = @@escape_sequences[node.text].codepoints[0]\n else\n result = node.text.codepoints[1]\n end\n \n when \"unicode_sequence\"\n result = node.text.slice(2..-1).to_i(16)\n\n else\n nyi( \"support for node type [#{node.type}]\", node )\n end\n \n return result\n end", "def identificador!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 79 )\n\n\n\n type = Identificador\n channel = ANTLR3::DEFAULT_CHANNEL\n # - - - - label initialization - - - -\n\n\n # - - - - main rule block - - - -\n # at line 616:6: Letter ( Letter | Digito )*\n letter!\n\n # at line 616:13: ( Letter | Digito )*\n while true # decision 27\n alt_27 = 2\n look_27_0 = @input.peek( 1 )\n\n if ( look_27_0 == 0x24 || look_27_0.between?( 0x30, 0x39 ) || look_27_0.between?( 0x41, 0x5a ) || look_27_0 == 0x5f || look_27_0.between?( 0x61, 0x7a ) || look_27_0.between?( 0xc0, 0xd6 ) || look_27_0.between?( 0xd8, 0xf6 ) || look_27_0.between?( 0xf8, 0x1fff ) || look_27_0.between?( 0x3040, 0x318f ) || look_27_0.between?( 0x3300, 0x337f ) || look_27_0.between?( 0x3400, 0x3d2d ) || look_27_0.between?( 0x4e00, 0x9fff ) || look_27_0.between?( 0xf900, 0xfaff ) )\n alt_27 = 1\n\n end\n case alt_27\n when 1\n # at line \n if @input.peek(1) == 0x24 || @input.peek( 1 ).between?( 0x30, 0x39 ) || @input.peek( 1 ).between?( 0x41, 0x5a ) || @input.peek(1) == 0x5f || @input.peek( 1 ).between?( 0x61, 0x7a ) || @input.peek( 1 ).between?( 0xc0, 0xd6 ) || @input.peek( 1 ).between?( 0xd8, 0xf6 ) || @input.peek( 1 ).between?( 0xf8, 0x1fff ) || @input.peek( 1 ).between?( 0x3040, 0x318f ) || @input.peek( 1 ).between?( 0x3300, 0x337f ) || @input.peek( 1 ).between?( 0x3400, 0x3d2d ) || @input.peek( 1 ).between?( 0x4e00, 0x9fff ) || @input.peek( 1 ).between?( 0xf900, 0xfaff )\n @input.consume\n else\n mse = MismatchedSet( nil )\n recover mse\n raise mse\n\n end\n\n\n\n else\n break # out of loop for decision 27\n end\n end # loop for decision 27\n\n\n\n @state.type = type\n @state.channel = channel\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 79 )\n\n\n end", "def space?\n\t\trawString.start_with? 'a'\n\tend", "def space?\n\t\trawString.start_with? 'a'\n\tend", "def letter!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 47 )\n\n \n # - - - - main rule block - - - -\n # at line \n if @input.peek( 1 ).between?( 0x41, 0x5a ) || @input.peek( 1 ).between?( 0x61, 0x7a )\n @input.consume\n else\n mse = MismatchedSet( nil )\n recover mse\n raise mse\n end\n\n\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 47 )\n\n end", "def get_atu()\n if $kx_atu\n atu=get_cmd('AK;',0.1,0.5,3).gsub(/^AK/,'').gsub(/;$/,'')\n puts atu if $verbose\n l=atu[0..1].to_i\n c=atu[2..3].to_i\n r=atu[4..5].to_i\n puts l if $verbose\n puts c if $verbose\n puts r if $verbose\n if r==0\n puts \"atu: antenna\" if $verbose\n relays=\"antenna\"\n elsif r==1\n puts \"atu: transmit\" if $verbose\n relays=\"transmit\"\n else\n puts \"atu: unknown\" if $verbose\n relays=\"Unknown\"\n end\n return(\"L=#{l}, C=#{c}, R=#{relays}\")\n else\n return \"ATU not installed\"\n end\nend", "def bat\n return @character\n end", "def amp_asgn!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 2 )\n\n type = AMP_ASGN\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at line 123:12: '&='\n match( \"&=\" )\n\n \n @state.type = type\n @state.channel = channel\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 2 )\n\n end", "def findAt(ind)\n howMany = 0\n\n ind.each_char do |let|\n if let ==\"@\"\n howMany += 1\n else\n next\n end\n\n end\n\n if howMany == 1\n return true\n else\n return false\n end\n\nend", "def scan_for_colon(token); end", "def lookahead(input: $srcin)\n $lookahead = input.getc\nend", "def parse_single_char\n if c = @s.scan(/\\\\[ftnr]/)\n (eval \"\\\"#{c}\\\"\").ord\n elsif c = @s.scan(/\\\\[^\\n]/)\n c[1].ord\n elsif c = @s.scan(/[^\\n\\\\\\/\\+\\*\\?\\|\\{\\}\\(\\)\\[\\]\\^\\$]/)\n c.ord\n end\n end", "def on_characters(chars)\n STDOUT << \"on_characters\" << \"\\n\" <<\n \" chars \" << chars << \"\\n\" \n STDOUT.flush\n end", "def nextChar\n if getChar == \"\\n\"\n @line += 1\n @column = @lastLineSize\n end\n @index += 1\n @column += 1\n end", "def parse_autolink; end", "def upalpha!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 46 )\n\n type = UPALPHA\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at line 183:12: ( 'A' .. 'Z' )+\n # at file 183:12: ( 'A' .. 'Z' )+\n match_count_2 = 0\n while true\n alt_2 = 2\n look_2_0 = @input.peek( 1 )\n\n if ( look_2_0.between?( 0x41, 0x5a ) )\n alt_2 = 1\n\n end\n case alt_2\n when 1\n # at line 183:13: 'A' .. 'Z'\n match_range( 0x41, 0x5a )\n\n else\n match_count_2 > 0 and break\n eee = EarlyExit(2)\n\n\n raise eee\n end\n match_count_2 += 1\n end\n\n\n \n @state.type = type\n @state.channel = channel\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 46 )\n\n end" ]
[ "0.621177", "0.599837", "0.5931464", "0.5674014", "0.5480492", "0.5431964", "0.53873646", "0.5372693", "0.53620714", "0.53377485", "0.52892685", "0.5274857", "0.52484465", "0.5240651", "0.52216977", "0.5214317", "0.5210502", "0.5205227", "0.5204377", "0.5193749", "0.51816493", "0.51759756", "0.5156511", "0.5150559", "0.5148177", "0.51357895", "0.51318026", "0.51053524", "0.50956964", "0.5084139", "0.5073784", "0.5073784", "0.5073784", "0.5073784", "0.5073784", "0.5073784", "0.5073784", "0.5073784", "0.5073784", "0.5073702", "0.5073702", "0.5073702", "0.5073702", "0.5073702", "0.5073702", "0.5073702", "0.5073702", "0.5073702", "0.5073702", "0.5068535", "0.50680554", "0.50331974", "0.503207", "0.49983388", "0.49894822", "0.49790955", "0.4977488", "0.4971826", "0.4966626", "0.49655932", "0.49574292", "0.49492994", "0.49476957", "0.4933223", "0.4933223", "0.49318513", "0.49314553", "0.49314553", "0.49224174", "0.49217933", "0.49217933", "0.49217933", "0.49188498", "0.4910393", "0.49062577", "0.490579", "0.49054635", "0.49030575", "0.49003845", "0.48915312", "0.48913446", "0.4883139", "0.48761818", "0.48740363", "0.48611167", "0.48598176", "0.48574924", "0.48574924", "0.48526585", "0.48419508", "0.48408812", "0.48372415", "0.48316658", "0.48309162", "0.48297834", "0.48203012", "0.48189023", "0.48124692", "0.48088375", "0.48044693" ]
0.52507824
12
Expects days from 0 to 6 where 0 is Sunday and 6 is Monday
def file_for_day(day) sound_path("day-#{day}.ul") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getSundays(d1,d2)\n d1 += 1 while (d1.wday != 0) # add days till starting on sunday\n sundays = []\n d1.step(d2,7) do |date| # move forward seven days for every sunday\n sundays .push date\n end\n sundays\nend", "def day_of_week\n dnum = day\n dnum -= 10 if dnum > 20\n dnum -= 10 if dnum > 10\n dnum -= 1\n dnum\n end", "def weekdays\n wdays = []\n wdays << 0 if sun\n wdays << 1 if mon\n wdays << 2 if tue\n wdays << 3 if wed\n wdays << 4 if thu\n wdays << 5 if fri\n wdays << 6 if sat\n\n wdays\n end", "def weekday(days)\nt = Date.today\narr = []\n days.times do\n arr << \"ok\" if t.saturday? || t.sunday?; t = t - 1\n end\n arr.count\nend", "def each_sunday( n=1, offset=0, dur=1); each_wdays(self.Sun,n,offset,dur); end", "def day_of_week\n # Zellers: 0 = Saturday, 1 = Sunday, 2 = Monday, ..., 6 = Friday\n # day_of_week: 1 = Sunday, 7 = Saturday\n (zellers_congruence + 6) % 7\n end", "def days_in_week(*days)\n @test_time = @time if @test_time.nil?\n x_in_list_of_y(@test_time.wday, Configuration.parse_range(days,0...7).flatten)\n end", "def set_days_of_week\n @days_of_week = Date::DAYNAMES.each_with_index\n end", "def each_saturday( n=1, offset=0, dur=1); each_wdays(self.Sat,n,offset,dur); end", "def days\n monday..sunday\n end", "def date_end # originally date_start\n\tdate = Date.today\n\t(1..7).each do |n|\n\t\tdate = Date.today - n#.days\n\t\tbreak if date.wday == 6 # 0 = Sun, 1 = Mon ... 6 = Sat\n\tend\n\tdate\nend", "def week_days\n {\n \"1\" => 'mon',\n \"2\" => 'tue',\n \"3\" => 'wed',\n \"4\" => 'thu',\n \"5\" => 'fri',\n \"6\" => 'sat',\n \"7\" => 'sun'\n }\n end", "def dayOfWeek\n days = 0;\n tempYear = MIN_YEAR\n while tempYear < @year\n days += SimpleDate.daysInYear(tempYear).to_i\n tempYear+=1\n end\n\n days = days + ordinalDate\n #puts \"days #{days}\"\n days = days % 7\n\n end", "def day_in_week_int \n\t\tdays = []\n\t\ttoday = Time.now\n\t\tdays.push(today.to_i)\n\t\ttoday_week_day = today.wday\n\t\tanothers = (0..6).select {|e| e != today_week_day}\n\t\tanothers.map do |e|\n\t\t\tdays.push(today.to_i - e*day_second)\n\t\tend\n\n\t\tdays.sort\n\tend", "def to_day_1_7(day_0_6)\n [7,1,2,3,4,5,6,7][day_0_6.to_i] if [0,1,2,3,4,5,6,7].include? day_0_6\n end", "def calendar_wdays(starting_day = 0)\n start_week = Date.today.beginning_of_week + (starting_day - 1).days # In rails week start in monday and monday.wday is 1\n (start_week...start_week+7.days).collect { |day| I18n.l(day, :format => '%A') }\n end", "def week\n first_day_of_week = @date.monday\n \n days_of_week = []\n 7.times do |time|\n days_of_week << day_and_types(first_day_of_week + time.days)\n end \n \n days_of_week\n end", "def weeks() 7 * days end", "def sunday_after days_ago=0\n d = Date.today - days_ago\n until d.sunday?\n d += 1\n end\n d\nend", "def working_days_from_date(date)\r\n date = date + 1.day if date.cwday == 6\r\n day_of_the_week = date.cwday == 7 ? 0 : date.cwday\r\n calendar_days, business_days = self, self\r\n result_date = day_of_the_week + business_days\r\n if (result_date >= 6)\r\n business_days -= (6 - day_of_the_week)\r\n calendar_days += 2\r\n weeks = business_days / 5\r\n calendar_days += (weeks * 2)\r\n end\r\n date + calendar_days.days\r\n end", "def nwday_day(n)\n w = n % 7\n 1 + (w - (wday - day + 1)) % 7 + n - w\n end", "def day_in_week(args = nil)\n if args\n args.each do |key, val|\n case key\n when :mfirst\n else\n raise ArgumentError, \"Invalid key in arguments: '#{key}'.\"\n end\n end\n end\n \n #This is a monday - 0. Use this date to calculate up against.\n def_date = Datet.new(1970, 1, 4)\n \n if self > def_date\n days = Datet.days_between(def_date, self)\n factor = days.to_f / 7.0\n diw = days - (factor.floor * 7)\n else\n days = Datet.days_between(self, def_date)\n factor = days.to_f / 7.0\n diw = days - (factor.floor * 7)\n diw = 7 - diw\n diw = 0 if diw == 7\n end\n \n #Monday should be the first day in the week.\n if args and args[:mfirst]\n if diw == 0\n diw = 6\n else\n diw -= 1\n end\n end\n \n return diw\n end", "def to_weekday_if_weekend(date)\n date += 1 if date.wday == 0\n date -= 1 if date.wday == 6\n date\n end", "def each_wednesday(n=1, offset=0, dur=1); each_wdays(self.Wed,n,offset,dur); end", "def set_day_range(days, start_day, end_day)\n pos = Days.index(start_day)\n while pos != (Days.index(end_day) + 1) % 7\n days[pos] = true\n pos = (pos + 1) % 7\n end\n end", "def days_to_add(desired)\n # c is current day of week, d is desired next day of week\n # f( c, d ) = g( c, d ) mod 7, g( c, d ) > 7\n # = g( c, d ), g( c, d ) <= 7\n # g( c, d ) = [7 - (c - d)] = 7 - c + d\n # where 0 <= c < 7 and 0 <= d < 7\n n = (7 - DateTime.now.wday + desired);\n (n > 7) ? n % 7 : n\nend", "def _week_day_numbers\n week_day_start = self.week_day_start\n week_day_start.capitalize if week_day_start.is_a? String\n [0, 1, 2, 3, 4, 5, 6].partition {|on| on >= day_names.index(week_day_start)%7 }.flatten\n end", "def nth_wday_day(w,d)\n 1 + (d - (wday - day + 1)) % 7 + w * 7\n end", "def get_start_of_week(d)\n d -= DAY until d.monday?\n d\n end", "def count_sundays(first, last)\r\n (first..last).select { |n| n.sunday? && n.mday == 1 }.size\r\nend", "def each_friday( n=1, offset=0, dur=1); each_wdays(self.Fri,n,offset,dur); end", "def each_tuesday( n=1, offset=0, dur=1); each_wdays(self.Tue,n,offset,dur); end", "def check_day(d)\n\tif !$days.include?(d)\n\t\tputs \"================\"\n\t\tputs \"ERROR MESSAGE!!!\"\n\t\tputs \"\"\n\t\tputs \"Days of the week are:\"\n\t\tputs \"Monday\"\n\t\tputs \"Tuesday\"\n\t\tputs \"Wednesday\"\n\t\tputs \"Thursday\"\n\t\tputs \"Friday\"\n\t\tputs \"Saturday\"\n\t\tputs \"Sunday\"\n\t\traise \"Invalid day entered!\"\n\tend\n\t\n\t# Set the day\n\tset_index_for_cur_day($days.index(d))\nend", "def end_of_week; self + (6 - wday).days end", "def test_start_of_week(p_date)\n if p_date.wday == 0 #sundays count as end of week for vehicle app\n return p_date - 6\n else\n (p_date - p_date.wday.days) + 1 #start on monday\n end\n end", "def day_of_week(*weekdays)\n merge(day: weekdays)\n end", "def to_weekday_if_boxing_weekend(date)\n if date.wday == 6 || date.wday == 0\n date += 2\n elsif date.wday == 1\n date += 1\n end\n\n date\n end", "def nth_wday; (day - 1) / 7 end", "def events_seven_days()\n events = []\n today = Date.today\n for i in 0..6 do\n events += events_by_date(today + i)\n end\n return events\nend", "def each_thursday( n=1, offset=0, dur=1); each_wdays(self.Thu,n,offset,dur); end", "def days_to_week_start(start_day = Date.beginning_of_week)\n start_day_number = DAYS_INTO_WEEK.fetch(start_day)\n (wday - start_day_number) % 7\n end", "def day_of_week\n return -1 if self.day_of_year == 308\n result = self.days_since_epoch % 8\n if result > 0\n result\n else\n 8\n end\n\n end", "def day_of_week\n # Date.wday returns 0-6 for Sunday,...Saturday\n return @day.wday\n end", "def day_in_week_str\n\t\tdays = []\n\t\ttoday = Time.now\n\t\tdays.push(formatted(today))\n\t\ttoday_week_day = today.wday\n\t\tanothers = (0..6).select {|e| e != today_week_day}\n\t\tanothers.map do |e|\n\t\t\tdays.push(formatted(Time.at(today.to_i - e*day_second)))\n\t\tend\n\n\t\tdays.sort\n\tend", "def solver(from_date, to_date, weekday)\n result = 0\n days_to_sunday = 7 - weekday\n new_date = from_date.increment_by_days days_to_sunday\n if (new_date.day == 1)\n result = result + 1\n end\n while new_date <= to_date\n if (new_date.day == 1)\n result = result + 1\n end\n new_date = new_date.increment_by_days 7\n end\n return result\nend", "def odd_week?; (to_i / 7.days).odd? end", "def first_wday; (wday - day + 1) % 7 end", "def days_of_week\n\n # create an array for processing\n days_array = [sunday, monday, tuesday, wednesday, thursday, friday, saturday]\n int_array = Array.new\n for day in days_array\n day ? int_array.push(1) : int_array.push(0)\n end\n\n # process with little recursive function\n r(int_array, 0)\n # fix first value, see note below\n int_array[0] == -1 ? int_array[0] = 1 : nil\n\n # final passes, change values into useable string\n int_array[0] == 1 ? int_array[0] = 'Su' : nil\n int_array[1] == 1 ? int_array[1] = 'M' : nil\n int_array[2] == 1 ? int_array[2] = 'Tu' : nil\n int_array[3] == 1 ? int_array[3] = 'W' : nil\n int_array[4] == 1 ? int_array[4] = 'Th' : nil\n int_array[5] == 1 ? int_array[5] = 'F' : nil\n int_array[6] == 1 ? int_array[6] = 'Sa' : nil\n\n int_array.delete(0)\n int_array.map{ |x| x == -1 ? '-' : x}.uniq.join\n\n end", "def week_days(options={}, &block)\n start_date = self\n result = []\n (start_date-wday_offset).step 7 do |a_day|\n a_day.week_day_start = self.week_day_start\n if block_given?\n yield a_day\n else\n result.push(a_day)\n end\n end\n result\n end", "def sundayCounter\n days = [31,28,31,30,31,30,31,31,30,31,30,31]\n date, sundays = 0, 1\n\n (1901...2000).each do\n (0..11).each do |month|\n date = (date + days[month]) % 7\n sundays += 1 if date == 6\n end\n end\n sundays\nend", "def day_of_week(date)\n 7 - date.cwday\n end", "def wday() end", "def weekdays\n value.each_char.map { |c| WEEKDAYS.index(c) }\n end", "def weekdays_until(date)\n return 0 if date <= self\n (self...date).select{|day| day.weekday?}.size\n end", "def saturday\n day(:saturday)\n end", "def each_days_of_week(*wdays)\n if wdays.empty?\n each_days\n else\n each_days.except {|dt| !wdays.include?(dt.wday) }\n end\n end", "def next_weekday(weekday = 2)\n date = Date.today\n unless date.strftime(\"%w\") == weekday.to_s\n date += 1 + ((weekday -1 -date.wday) % 7)\n end\n date\n end", "def days() 24 * hours end", "def getDayOnWeek(weekStart, dayVal)\n\t\tweekDay = ((7 + (dayVal - weekStart.wday)) % 7)\n\t\tdayDateVal = weekStart + weekDay.days\n\t\tdayDateVal\n\tend", "def getSunday(date)\n\t\tunless date.nil?\n\t\t\tday7_diff = 7 - date.cwday%7\n\t\t\tdate += day7_diff == 7 ? 0 : day7_diff\n\t\tend\n\t\tdate\n\tend", "def schedule_days(day_ints = [1,3,5])\n (0..6).each {|day_int|\n is_checked = day_checked?(day_int)\n # puts \"is checked : #{is_checked}\"\n should_be_checked = day_ints.include?(day_int)\n # puts \"should_be_checked : #{should_be_checked}\"\n if (!is_checked && should_be_checked)\n click_day_picker(day_int)\n elsif (is_checked && !should_be_checked)\n click_day_picker(day_int)\n else\n\n end\n } \n current_scheduled_days\n end", "def is_day_number_a_sunday(number)\n # where 1 is '1 Jan 1900'\n # and 2 is '2 Jan 1900'\n return true if (number + 7) % 7 == 0\n return false\nend", "def week(date = Date.today)\n day = monday(date)\n (day..day + 6)\n end", "def days_past_in_week\n to_date.cwday\n end", "def sunday\n day(:sunday)\n end", "def next_weekday(date, weekdays)\n [weekdays].flatten.map{|wd| \n nwd = date - date.cwday + Date::WEEKDAYS.index(wd) + 1\n nwd += 7 if nwd <= date\n nwd\n }.sort[0]\n end", "def unlucky_days(year)\r\n (1..12).count { |month| Time.new(year, month, 13).friday? }\r\n end", "def date_parser(date)\n date = Chronic.parse(\"#{date.downcase}\")\n while date.wday < 6\n date = date += 1 # makes start date the next saturday from the input date\n end\n return date\nend", "def get_days\n return 0b0 if @params[:type] != 'advanced'\n\n return get_weekday_bitmask(['weekday_sun', 'weekday_mon', 'weekday_tue', 'weekday_wed', 'weekday_thu', 'weekday_fri', 'weekday_sat']) if @params[:schedule] == 'weekly'\n\n return get_month_bitmask(@params[:dates_picked]) if @params[:schedule] == 'monthly' && @params[:days] == 'specific'\n\n return get_unspecific_days\n\n end", "def day_of_the_week(day)\n @dias = {1 => \"LUNES\", 2 => \"MARTES\", 3 => \"MIERCOLES\", 4 => \"JUEVES\", 5 => \"VIERNES\", 6 => \"SÁBADO\", 7 => \"DOMINGO\"}\n return @dias[day]\n end", "def each_wdays(wd,n=1,offset=0,dur=1)\n build_subrange do |s|\n s.step = n\n s.adjust_range { |r| day_range(r) }\n s.offset { |dt| dt.to_date + (wd - dt.to_date.wday)%7 + offset*7 }\n s.increment { |dt,i| dt.to_date + i*7 }\n s.span { |dt| dt.to_date + dur }\n end\n end", "def weekdays\n result = veeamconfig('schedule', 'show', '--jobId', get_job_id).lines\n\n if result[0].strip == 'Every day'\n ['daily']\n else\n result[0].strip.split(': ')[1].split(', ')\n end\n end", "def day_of_week(weekdays, *extras)\n merge(day: weekdays.array_concat(extras))\n end", "def days(*args)\n if args.first.is_a?(Range)\n @dow = format_range(args.first)\n else\n list = args.map {|day| day_value(day) unless day.is_a?(Fixnum) }\n @dow = list.join(',')\n end\n self\n end", "def days(*args)\n if args.first.is_a?(Range)\n @dow = format_range(args.first)\n else\n list = args.map {|day| day_value(day) unless day.is_a?(Fixnum) }\n @dow = list.join(',')\n end\n self\n end", "def day_of_week\n\tif @current_time.wday == 0 || @current_time.wday == 6\n\t\tweek_period = \"Weekends\"\n\telse\n\t\tweek_period = \"Weekdays\"\n\tend\nend", "def sunday\n end_of_week(:monday)\n end", "def test_it_can_convert_an_integer_day_of_week_to_the_word\n assert_equal \"Sunday\", FinderClass.day_of_week(0)\n assert_equal \"Monday\", FinderClass.day_of_week(1)\n assert_equal \"Tuesday\", FinderClass.day_of_week(2)\n assert_equal \"Wednesday\", FinderClass.day_of_week(3)\n assert_equal \"Thursday\", FinderClass.day_of_week(4)\n assert_equal \"Friday\", FinderClass.day_of_week(5)\n assert_equal \"Saturday\", FinderClass.day_of_week(6)\n end", "def weekday\n fail \"A value cannot be provided for #{__method__}\" if @value\n return 'Mon..Fri'\n end", "def check_day_of_week\n if (selected_days.size - 1) > 0 && !selected_days.nil?\n d = Date.today\n weekday = Date::DAYNAMES[d.wday]\n selected_days.include?(weekday)\n else\n return true\n end\n end", "def monday(date = Date.today)\n today = date\n day = today.wday\n diff = case day\n when 0\n 6\n when 1..6\n day - 1\n end\n today - diff\n end", "def addDays(date)\n\n #puts 'in addDays'\n #puts date\n if date.saturday? then\n #puts \"sat\"\n date1 = date.next_day(7)\n return date1\n elsif date.sunday? then\n #puts \"sun\"\n date1 = date.next_day(8)\n return date1\n else\n #puts 'other'\n date1 = date.next_day(7)\n end\n return date1\n end", "def weekday\n fail \"A value cannot be provided for #{__method__}\" if @value\n\n 'Mon..Fri'\n end", "def check_day(meet_days_integer,day_to_check)\n\n day_shift = {monday: 0, tuesday: 1, wednesday: 2, thursday: 3, friday: 4, saturday: 5, sunday:6}\n\n# puts \"day_to_check = #{day_to_check}\"\n# puts \"day_shift[:tuesday] = #{day_shift[:tuesday]}\"\n# puts \"day_shift[day_to_check] = #{day_shift[day_to_check]}\"\n day_shift_int = day_shift[day_to_check].to_i\n# puts \"day_shift_int = #{day_shift_int}\"\n shifted_int = ( meet_days_integer >> day_shift_int ).to_s(2)\n# puts \"shifted_int = #{shifted_int}\"\n day_checked = shifted_int.to_i % 2\n# puts \"day_checked = #{day_checked}\"\n return day_checked.to_s\nend", "def non_working_week_days\n @non_working_week_days ||= begin\n days = [] # Setting.non_working_week_days\n if days.is_a?(Array) && days.size < 7\n days.map(&:to_i)\n else\n []\n end\n end\n end", "def cutoff_date\n case date.wday\n when 0\n date + (weeks.to_i * 7)\n when 1\n date + (weeks.to_i * 7) - 1\n when 2\n date + (weeks.to_i * 7) - 2\n when 3\n date + (weeks.to_i * 7) - 3\n when 4\n date + (weeks.to_i * 7) - 4\n when 5\n date + (weeks.to_i * 7) - 5\n when 6\n date + (weeks.to_i * 7) + 1\n end\n end", "def sunday(t)\n dt = to_datetime t\n sun = dt - dt.cwday\n (t.is_a? ::Date) ? sun.to_date : sun\n end", "def next_sunday(due_to_date)\n\t\t\tright_now = Time.zone.now\n\t\t\tright_now += 6.days if right_now <= due_to_date # approximation should be fine, ignore edge cases for now\n return right_now + (7 - right_now.wday).days + (22 - right_now.hour).hours + (0 - right_now.min).minutes + (0 - right_now.sec).second\n\t end", "def days(n)\n n * 3600 * 24\nend", "def start_of_week; self - wday.days end", "def test_day_of_week_end_of_day_week_start_mon\n assert_result :day_of_week, 1, \"2013-01-01 23:59:59\", false, week_start: :mon\n end", "def test_is_a_weekend?(p_date = Date.today)\n p_date.saturday? || p_date.sunday?\n end", "def is_sunday?(days_since_1900)\n # Monday was 1st, so Sunday is when 7 divides evenly into number of days\n # since the known Monday\n (days_since_1900 % 7 == 0)\nend", "def weekdays_until(other)\n return -other.weekdays_until(self) if other < self\n whole_days_to(other).count(&:weekday?)\n end", "def has_sunday_with_date_7(month, year)\n calender = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]\n day_count = 0\n\n calender.each do |num|\n (1..num).each do |i|\n if i == 7 && day_count = 7\n return true\n end\n if day_count <= 7\n day_count += 1\n else\n day_count = 7\n end\n end\n end\nend", "def nth_weekday_before_date(n, desired_weekday, date)\n week_offset_in_days = 7 * (n - 1)\n first_weekday_before_date(desired_weekday, date) - week_offset_in_days\nend", "def mweek; (5 - wday + day) / 7 end", "def weekend\n [saturday, sunday]\n end", "def beginning_of_week; end", "def beginning_of_week; end", "def wday_difference(from, to, direction)\n return direction * ((direction * (to - from)) % 7)\n end" ]
[ "0.7296824", "0.7263616", "0.72486085", "0.72068954", "0.7170879", "0.70695835", "0.70674956", "0.7059349", "0.70462614", "0.70386064", "0.70087373", "0.68912864", "0.68820775", "0.6865934", "0.6821711", "0.67912763", "0.6769885", "0.6732758", "0.67214394", "0.67014956", "0.6657197", "0.66418403", "0.66364926", "0.6628581", "0.66103107", "0.66043985", "0.65997356", "0.6597132", "0.65934616", "0.657951", "0.65707046", "0.6555879", "0.65308326", "0.652878", "0.6479146", "0.64607245", "0.645636", "0.644513", "0.6442421", "0.64279747", "0.64240974", "0.6420293", "0.6410263", "0.64090174", "0.63784474", "0.63586015", "0.6358257", "0.6321293", "0.63143474", "0.6304613", "0.63009393", "0.62925756", "0.62832856", "0.62770545", "0.62737757", "0.6271197", "0.6263133", "0.62501794", "0.6245321", "0.6237589", "0.6233297", "0.62311876", "0.6228424", "0.62241566", "0.6220128", "0.62150383", "0.6204826", "0.62047553", "0.62019175", "0.6198131", "0.6195185", "0.61590165", "0.6157972", "0.6145441", "0.6145441", "0.6142817", "0.61408556", "0.6135963", "0.6124308", "0.6122605", "0.6121876", "0.6116135", "0.6115385", "0.61118823", "0.61049795", "0.61021405", "0.60989815", "0.60968024", "0.6078422", "0.6070867", "0.60688686", "0.606053", "0.60530406", "0.6052392", "0.6048327", "0.603936", "0.6036672", "0.6036647", "0.603379", "0.603379", "0.6032198" ]
0.0
-1
Expects months from 1 to 12 where 1 is January. Files are actually numbered 0 to 11
def file_for_month(month) sound_path("mon-#{month.to_i - 1}.ul") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def month() end", "def parse_month(time)\n [file_for_month(time.strftime(\"%-m\"))]\n end", "def test_yearly_by_month_loop\n parse(\n 'FREQ=YEARLY;INTERVAL=1;UNTIL=20120203T225959Z;BYMONTH=2;BYSETPOS=1;BYDAY=SU,MO,TU,WE,TH,FR,SA',\n '2012-01-01 15:45:00',\n [\n '2012-02-01 15:45:00'\n ],\n '2012-01-29 23:00:00'\n )\n end", "def exportMonthlyFiles()\r\n months = @messages.getMonths()\r\n months.each { |month|\r\n exportMonthlyFile(month)\r\n }\r\n end", "def month; end", "def month; end", "def each_march( n=1); each_monthnum(self.Mar,n); end", "def each_january( n=1); each_monthnum(self.Jan,n); end", "def file_commit_monthly_timeline file_name, events\n file_month_dates = events.select {|e| e.file_name == file_name }.map(&:date).map(&:month_start)\n spread(file_month_dates.freq, month_range(file_month_dates.min, file_month_dates.max))\nend", "def month=(_arg0); end", "def expiration_month\n @months = [\"01\",\"02\",\"03\",\"04\",\"05\",\"06\",\"07\",\"08\",\"09\",\"10\",\"11\",\"12\"]\n end", "def months() 30 * days end", "def months\n self.to_i * 2_592_000\n end", "def each_february( n=1); each_monthnum(self.Feb,n); end", "def each_may( n=1); each_monthnum(self.May,n); end", "def increment_month!\n if month != 12\n # just bump up a number\n self.date = ZDate.format_date(year_str, month + 1)\n else\n self.date = ZDate.format_date(year + 1)\n end\n end", "def months_in_year\n 12\nend", "def each_april( n=1); each_monthnum(self.Apr,n); end", "def month\n set_function_and_argument(:month, nil)\n end", "def normalize_month(month)\n month % 12 + 1\n end", "def monthly\n end", "def setup_months(start_month, end_month)\n @months = []\n while start_month <= end_month\n @months << start_month\n start_month += 1\n end\n end", "def each_october( n=1); each_monthnum(self.Oct,n); end", "def refine_month(m)\n mon = check_num_str(m)\n adjust_month(mon)\n end", "def months\n @years * 12\n end", "def month\n end", "def test_days_in_month()\n first_month=days_in_month(1,2016)\n assert_equal(31,first_month)\n end", "def each_december( n=1); each_monthnum(self.Dec,n); end", "def to_month(**options) = convert_to('month', **options)", "def month\n @month ||= Date::ABBR_MONTHNAMES.index(@md[4])\n end", "def month\n @month ||= Date::ABBR_MONTHNAMES.index(@md[1])\n end", "def get_year_month_list()\n arr=[]\n start=\"2008_01\"\n str=\"\"\n var_date = Time.now\n while( start != str)\n str = var_date.year.to_s + \"_\" + \"%02d\" % var_date.month.to_s\n arr << str\n var_date = var_date - 1.month\n end\n return arr\n end", "def read_files(year, month, path)\n array = [0, '', 100, '', 0, '', 100, 100, 100]\n month_name = Date::MONTHNAMES[month]\n link = \"#{path}_#{year}_#{month_name[0..2]}.txt\"\n file = CSV.read(link)\n loop_var, line_count = case_read_file(path, link)\n until loop_var > line_count\n high_temp_file_loop(loop_var, array, file)\n low_temp_file_loop(loop_var, array, file)\n humid_file_loop(loop_var, array, file)\n loop_var += 1\n end\n array\n end", "def validate_month\n if self.month.length > 2 # assumes month is a name if longer than 2 chars\n @number_month = Date::MONTHNAMES.index(self.month.capitalize)\n if @number_month < Time.now.month\n self.month = @number_month\n else\n @valid = false\n end\n end\n end", "def roman_month(date)\n date[1]\n end", "def years_to_month(years)\n years * 12.0\nend", "def adjust_month(m)\n months = [\"january\", \"february\", \"march\", \"april\", \"may\", \"june\", \"july\", \"august\", \"september\", \"october\", \"november\", \"december\"]\n if m.is_a? Integer\n months[m-1]\n else\n m\n end\n end", "def merch_month\n # TODO: This is very inefficient, but less complex than strategic guessing\n # maybe switch to a binary search or something\n @merch_month ||= (1..12).detect do |num|\n date_calc.end_of_month(start_of_year.year, num) >= date && date >= date_calc.start_of_month(start_of_year.year, num)\n end\n end", "def year_month_int_to_year_and_month(year_month)\n [year_month / 12, (year_month % 12) + 1]\n end", "def each_june( n=1); each_monthnum(self.Jun,n); end", "def month_entries(pages, year, month)\n #puts \", year = #{year}, month = #{month}\"\n # page.full_name => yyyy/mm/dd\n entries = []\n pages.each do |page|\n if page_is_of_month?(page, year, month)\n entries << page \n end\n end\n entries\n end", "def adjust_set_month(m)\n index = @@m_set.index(m.to_s)\n if index < 13\n index - 1\n else\n index - 13\n end\n end", "def get_next_month(number)\n month = number.to_i < @start.day ? (@start.month == 12 ? 1 : @start.month + 1) : @start.month\n end", "def month\n @month ||= date_calc.merch_to_julian(merch_month)\n end", "def month\n @year = params[:year].to_i\n @month = params[:month].to_i\n @first_day = @event.first_day_of_month(@year, @month)\n @last_day_of_month = Date.new(@year, @month, 1).end_of_month\n end", "def months_as_array\n (1..12).map {|m| [Date::MONTHNAMES[m]]}\n end", "def month\n running_days = 0\n DAYS_IN_MONTH.each_with_index do |days, idx|\n running_days += days\n return idx + 1 if self.day_of_year <= running_days\n end\n end", "def after_n_months(year, month)\n\tif year == nil\n\t\t\"year missing\"\n\telsif month == nil\n\t\t\"month missing\"\n\telse\n\t\t(year + month/12).to_i\n\tend\nend", "def changemonth(direction)\n\t\tif direction == :backward\n\t\t\tif @month == 1 #tempting to do \"12/\".next but no corresponding previous\n\t\t\t\t@year -= 1\n\t\t\t\t@month = 12\n\t\t\telse\n\t\t\t\t@month -= 1\n\t\t\tend\n\t\tend\n\t\tif direction == :forward\n\t\t\tif @month == 12\n\t\t\t\t@year += 1\n\t\t\t\t@month = 1\n\t\t\telse\n\t\t\t\t@month += 1\n\t\t\tend\n\t\tend\n\t\tdebug(@year)\n\t\tdebug(@month)\n\t\tdownload(URL+@list+@year.to_s+\"/\"+(0 if @month < 10).to_s+@month.to_s) do |resp|\n\t\t\t@days = eval(resp.response.body)[1]\n\t\t\tdebug(@days)\n\t\t\t#@stack_cal.show\n\t\t\t#@stack_cal_nav.show\n\t\t\t@when.replace(@month.to_s, \" \", @year.to_s)\n\t\t\tdrawcalendar(@list, @year, @month, @days)\n\t\tend\n\tend", "def month\n Thread.current[:datet_mode] = :months\n return @t_month\n end", "def month\n months = %w{January February March April May June July August September October November December}\n months[Time.now.month - 1]\n end", "def each_monthnum(nmonth,n=1)\n build_subrange do |s|\n s.step = n\n s.adjust_range { |r| day_range(r) }\n s.offset { |dt| dt >> (nmonth - dt.month)%12 }\n s.increment { |dt,i| dt.to_date >> i*12 } \n s.span { |dt| dt.to_date >> 1 }\n end\n end", "def month=(value)\n value = 0 if value.nil?\n\n if value.is_a?(String) \n if value.length == 0\n value = 0\n elsif value =~ /\\A\\d{1,2}\\z/ \n value = value.to_i\n else\n raise MonthError, \"Month must be a valid one or two digit string or integer between 0 and 12\"\n end\n end\n\n if (value >= 0 && value <= 12)\n @bits = self.class.set_month(@bits, value)\n @bits = self.class.set_day(@bits, 0) if value == 0\n else\n raise MonthError, \"Month must an be integer between 0 and 12\"\n end\n end", "def each_november( n=1); each_monthnum(self.Nov,n); end", "def all_month\n beginning_of_month..end_of_month\n end", "def month_number\n date.month\n end", "def each_july( n=1); each_monthnum(self.Jul,n); end", "def next_month(month, year)\n if month == 12\n [1, year + 1]\n else\n [month + 1, year]\n end\nend", "def January ; Date::MONTHNAMES.index(\"January\"); end", "def get_number_of_month(m)\n (1..is_leap?[adjust_set_month(m)]).to_a\n end", "def monthly(options = {})\n branch options.merge(every: :month)\n end", "def monthly(options = {})\n branch options.merge(every: :month)\n end", "def months\n Thread.current[:datet_mode] = :months\n return self\n end", "def set_year(m)\n if set_month(m) > 2 and set_month(m) < 13\n @year.to_i\n else\n @year.to_i - 1\n end\n end", "def month=(value)\n @month = value\n end", "def change_month\n from_year = params[:year].to_i\n from_month = params[:month].to_i\n current_action = params[:current_action]\n _page_redirect_to(from_year, from_month, current_action)\n end", "def adjust_set_month\n index = @@m_set.index(@month.to_s)\n if index < 13\n index - 1\n else\n index - 13\n end\n end", "def set_month(m)\n @@m_set.index(m.to_s)\n end", "def month_of_year(*months)\n merge(month: months)\n end", "def parse_months\n date_from = Date.parse('2004-05-01')\n date_to = Date.parse('2014-04-01')\n date_range = date_from..date_to\n date_months = date_range.map {|d| Date.new(d.year, d.month, 1) }.uniq\n date_months.map {|d| d.strftime \"%B %Y\" }\n end", "def each_august( n=1); each_monthnum(self.Aug,n); end", "def >>(months)\n y, m = (@year * 12 + (@month - 1) + months).divmod(12)\n m, = (m + 1) .divmod(1)\n d = @day\n d -= 1 until self.class.valid?(y, m, d)\n self.class.new(y,m,d)\n end", "def each_september(n=1); each_monthnum(self.Sep,n); end", "def validate_month(spec)\n return true if spec == \"*\"\n\n if spec.respond_to? :to_int\n validate_numeric(spec, 1, 12)\n elsif spec.respond_to? :to_str\n # Named abbreviations are permitted but not as part of a range or with stepping\n return true if %w{jan feb mar apr may jun jul aug sep oct nov dec}.include? spec.downcase\n\n # 1-12 are legal for months\n validate_numeric(spec, 1, 12)\n else\n false\n end\n end", "def get_num_months(param)\n if param == '3m'\n 3\n elsif param == '6m'\n 6\n elsif param == '1y'\n 12\n else\n 1\n end\n end", "def month\n self.range('month')\n end", "def could_be_month?(month); end", "def scan_for_month_names(token, options = T.unsafe(nil)); end", "def test_january\n jan = Month.new(1,2000)\n days = jan.num_of_days_in_month\n assert_equal 31, days\n end", "def month_range(month, year)\n next_month = month == 12 ? 1 : month + 1\n next_year = month == 12 ? year + 1 : year\n Date.new(year, month, 1)..Date.new(next_year, next_month, 1)\n end", "def exportMonthlyFile(month)\r\n monthFileName = @outputDir.join(\"#{month}.html\")\r\n monthFile = HtmlOutputFile.new(monthFileName, @options[:title])\r\n @options[:log].begin(\"Exporting messages from #{month} to \\\"#{monthFileName.to_s}\\\"\")\r\n exportMonthlyContent(monthFile, month)\r\n monthFile.close()\r\n @options[:log].end()\r\n end", "def next_month(months = 1)\n advance(months: months)\n end", "def months_list\n unless @months_list\n months = []\n date = start_date\n while date <= end_date\n months << date\n date += 1.month\n end\n @month_list = months\n end\n\n @month_list\n end", "def start_of_month\n Date.new(self.strftime('%Y').to_i, self.strftime('%m').to_i, 1)\n end", "def month? = unit == 'month'", "def months ; self * 30.days ; end", "def jump_to_month(month_number)\n # find difference in months\n if month_number >= month\n ZDate.new(ZDate.format_date(year_str, month_number))\n else\n ZDate.new(ZDate.format_date(year + 1, month_number))\n end\n end", "def check_month(num)\n loop do\n if !MONTH.match(num)\n message(MC['num_prompt_month'])\n num = Kernel.gets().chomp()\n else\n break\n end\n end\n num\nend", "def month_list(date, limit: 1)\n month_list = []\n (0 ... limit).each { |t| month_list.push month(date + t.month) }\n month_list\n end", "def get_months(years, months)\n if years > 0\n (years * 12) + months\n elsif years > 0 && months == 0\n years * 12\n else\n months\n end\nend", "def calculate_month_by_month\n return StandardError, 'Already calculated stats for period' if @calculated.include?(:month_by_month)\n check_for_dates\n\n months_list.each do |date|\n start = date.beginning_of_month\n final = date.end_of_month\n month_key = start.strftime(MONTH_KEY)\n\n calculate_stats_for(month_key, Statistic::VIEW, start, final)\n calculate_stats_for(month_key, Statistic::STREAM, start, final) if include_streaming\n calculate_stats_for(month_key, Statistic::DOWNLOAD, start, final)\n end\n @calculated << :month_by_month\n self\n end", "def get_number_of_month\n (1..is_leap?[adjust_set_month]).to_a\n end", "def by_month(value = Time.now.month, options = {})\n year = options[:year] || Time.now.year\n \n # Work out what actual month is.\n month = if value.class == Fixnum && value >= 1 && value <= 12\n value\n elsif value.class == Time || value.class == Date\n year = value.year\n value.month\n elsif value.class == String && Date::MONTHNAMES.include?(value)\n Date::MONTHNAMES.index(value)\n else\n raise ParseError, \"Value is not an integer (between 1 and 12), time object or string (make sure you typed the name right).\"\n end\n \n start_time = Time.utc(year, month, 1)\n end_time = start_time.end_of_month\n\n by_star(start_time, end_time, options)\n end", "def two_arguments_validation\n if ARGV.empty? || !ARGV[0].to_i.between?(1,12) || !ARGV[1].to_i.between?(1800,3000)\n puts \"Date not acceptable format/range\n./cal.rb [01-12] [1800-3000]\"\n else\n #otherwise, return the calendar month\n month = ARGV[0].to_i\n year = ARGV[1].to_i\n m = Month.new(month,year)\n puts m.to_s\n end\nend", "def valid_date_in_month(d,m)\n d >= 1 and Time.days_in_month(m,start.year) >= d ? d : raise(ArgumentError, \"invalid day #{d} for #{m}\") \n end", "def month_array\r\n\t\t[[\"January\", \"1\"],[\"February\", \"2\"], \r\n\t\t[\"March\", \"3\"],[\"April\",4],\r\n\t\t[\"May\",5],[\"June\",6],\r\n\t\t[\"July\",7],[\"August\",8],\r\n\t\t[\"September\",9],[\"October\",10],\r\n\t\t[\"November\",11],[\"December\",12]]\r\n\tend", "def month\n self.class.get_month(@bits)\n end", "def month_name(number); end", "def month=(value)\n RangeValidator.validate \"DateGroupItem.month\", 0, 12, value\n @month = value\n end", "def test_5_print_months\n year = Year.new(1983)\n assert_equal(\" 1983\\n\\n January February March\\nSu Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa\\n 1 1 2 3 4 5 1 2 3 4 5\\n 2 3 4 5 6 7 8 6 7 8 9 10 11 12 6 7 8 9 10 11 12\\n 9 10 11 12 13 14 15 13 14 15 16 17 18 19 13 14 15 16 17 18 19\\n16 17 18 19 20 21 22 20 21 22 23 24 25 26 20 21 22 23 24 25 26\\n23 24 25 26 27 28 29 27 28 27 28 29 30 31\\n30 31 \\n April May June\\nSu Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa\\n 1 2 1 2 3 4 5 6 7 1 2 3 4\\n 3 4 5 6 7 8 9 8 9 10 11 12 13 14 5 6 7 8 9 10 11\\n10 11 12 13 14 15 16 15 16 17 18 19 20 21 12 13 14 15 16 17 18\\n17 18 19 20 21 22 23 22 23 24 25 26 27 28 19 20 21 22 23 24 25\\n24 25 26 27 28 29 30 29 30 31 26 27 28 29 30\\n \\n July August September\\nSu Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa\\n 1 2 1 2 3 4 5 6 1 2 3\\n 3 4 5 6 7 8 9 7 8 9 10 11 12 13 4 5 6 7 8 9 10\\n10 11 12 13 14 15 16 14 15 16 17 18 19 20 11 12 13 14 15 16 17\\n17 18 19 20 21 22 23 21 22 23 24 25 26 27 18 19 20 21 22 23 24\\n24 25 26 27 28 29 30 28 29 30 31 25 26 27 28 29 30\\n31 \\n October November December\\nSu Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa\\n 1 1 2 3 4 5 1 2 3\\n 2 3 4 5 6 7 8 6 7 8 9 10 11 12 4 5 6 7 8 9 10\\n 9 10 11 12 13 14 15 13 14 15 16 17 18 19 11 12 13 14 15 16 17\\n16 17 18 19 20 21 22 20 21 22 23 24 25 26 18 19 20 21 22 23 24\\n23 24 25 26 27 28 29 27 28 29 30 25 26 27 28 29 30 31\\n30 31 \\n\", year.print_everything)\n end" ]
[ "0.6761202", "0.6733385", "0.6453396", "0.64510095", "0.6442446", "0.6442446", "0.6424039", "0.64170146", "0.6395089", "0.6323511", "0.63121873", "0.6304579", "0.62960637", "0.622856", "0.62112343", "0.6204197", "0.61971813", "0.6192324", "0.6183922", "0.6172286", "0.61657554", "0.61557615", "0.6148409", "0.61276186", "0.6115786", "0.6109869", "0.60949165", "0.6078815", "0.60412866", "0.60398084", "0.6037837", "0.60306317", "0.60125893", "0.6010715", "0.5996262", "0.5989158", "0.59809625", "0.59793717", "0.597505", "0.59528434", "0.59499097", "0.59296644", "0.59266305", "0.5924127", "0.59173244", "0.59144205", "0.5899909", "0.58957785", "0.5881054", "0.587605", "0.5868851", "0.58541846", "0.5853155", "0.58501583", "0.5837294", "0.5819932", "0.58084744", "0.58082306", "0.5805708", "0.580529", "0.58048964", "0.58048964", "0.58032286", "0.579856", "0.57928145", "0.57910615", "0.57837814", "0.5783475", "0.5773563", "0.5771066", "0.57603407", "0.5755771", "0.57331556", "0.57270175", "0.57223666", "0.5716131", "0.5712052", "0.57034963", "0.5700828", "0.56963396", "0.56915003", "0.5685671", "0.5685493", "0.5683562", "0.5680277", "0.56757236", "0.5673203", "0.5672938", "0.5665836", "0.56573224", "0.5652892", "0.56520206", "0.5650149", "0.56460017", "0.56437427", "0.56399626", "0.5632474", "0.5628829", "0.5623445", "0.561776" ]
0.6318267
10
Breaks a number down into components. Supports numbers up to 9999
def sounds_for_number(number) number = number.to_i result = [] thousands = (number / 1000).floor if thousands > 0 result << "#{thousands}.ul" << "thousand.ul" end rest = number % 1000 hundreds = (rest / 100).floor if hundreds > 0 result << "#{hundreds}.ul" << "hundred.ul" end rest = rest % 100 if rest <= 19 result << "#{rest}.ul" else tens = (rest / 10).floor units = rest % 10 result << "#{tens}0.ul" result << "#{units}.ul" if units > 0 end result.map {|r| sound_path(r) } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def splitNumber(val)\n\tresArr = []\n\twhile(val >= 1)\n\t\tresArr.push(val % 10)\n\t\tval = val / 10\n\tend\n\tresArr\nend", "def over_ten_split(number)\n return (number - 10).succ\nend", "def split_number(start)\r\r\n number = []\r\r\n number[0] = start / 1000 / 1000\r\r\n number[1] = start / 1000 % 1000\r\r\n number[2] = start % 1000\r\r\n return number\r\r\n end", "def split_number(start)\n number = []\n number[0] = start / 1000 / 1000\n number[1] = start / 1000 % 1000\n number[2] = start % 1000\n return number\n end", "def break_number(num,short_scale)\n first_slice = (num.to_s.size - short_scale.to_s.size ) if num == short_scale\n first_slice = (num.to_s.size - (short_scale.to_s.size - 3) ) if num < short_scale\n first = num.to_s.slice(0..first_slice)\n second = num.to_s.slice(first.size..num.to_s.size)[0]\n return first,second\n end", "def clean\n @number.gsub!(/\\D/,\"\")\n\n if has_11_digits? and starts_with_1?\n @number = @number[1..-1] \n elsif invalid_length?\n @number = nil\n end\n end", "def digit_list(number)\r\n digits = []\r\n loop do\r\n number, remainder = number.divmod(10)\r\n digits.unshift(remainder)\r\n break if number == 0\r\n end\r\n digits\r\nend", "def handle_hundred (num)\n num2str=''\n if (num%100==0)\n num2str+=NUM_MAP[num/100]+ ' '+ NUM_MAP[100]\n elsif (num%100>=10 && num%100 <= 99)\n num2str+=NUM_MAP[num/100]+ ' '+ NUM_MAP[100]+ ' ' +handle_ten(num%100)\n elsif (num%100>=1 && num%100 <= 9)\n num2str+=NUM_MAP[num/100]+ ' '+ NUM_MAP[100]+ ' ' +handle_bit(num%100)\n end\n return num2str\nend", "def digits(number)\n digits = []\n\n while number != 0\n digits << number % 10\n number = number / 10\n end\n\n digits.reverse.join\nend", "def super_digit(n)\n while n > 9\n n = n % 10 + super_digit(n / 10)\n end\n return n\nend", "def digit_list(number)\n digits = []\n\n loop do\n number, rem = number.divmod(10)\n digits.unshift(rem)\n\n break if number == 0\n end\n\n digits\nend", "def super_digit(n)\n while n >= 10\n n = n % 10 + super_digit(n / 10)\n end\n return n\nend", "def split_into_parts\n number = integer.to_i\n\n @parts = [\n number / 10**8,\n (number / 10**4) % 10**4,\n number % 10**4\n ]\n end", "def digit_list(num)\n digits = []\n\n loop do\n number, remainder = number.divmod(10)\n digits.unshift(remainder)\n break if number == 0\n end\n\n digits\nend", "def digit_list(number)\n digits = []\n\n until number == 0 do\n digits.unshift(number % 10)\n number /= 10\n end\n\n digits\nend", "def split_number(number, length)\n [number[0...length], number[length..-1]]\n end", "def split_problem_number_into_letter_and_number(x)\n if x.to_i>0 then return ['',x.to_i] end # for efficiency\n if x=~/([a-z]*)([0-9]+)/ then\n return [$1,$2.to_i]\n else\n fatal_error(\"illegal problem number, #{x}\")\n end\nend", "def chunkify(number)\n chunks = []\n while number > 0\n number, chunk = number.divmod(1000)\n chunks << chunk\n end\n chunks\n end", "def mod11(number); end", "def digit_list(num)\n result = []\n\n until num.zero?\n num, remainder = num.divmod(10)\n result.unshift(remainder)\n end\n result\nend", "def super_digit(n)\n n < 10 ? n : super_digit(n / 10 + n % 10)\nend", "def split_number(number)\n if number.length > 4\n tokens = []\n\n # reverse & split by doubles\n number.reverse.scan(/.(?:.|$)/) do |token|\n token.reverse!\n if token.length == 1\n tokens.last.prepend token\n else\n tokens << token\n end\n end\n\n # merge back\n tokens.reverse!\n tokens.tap do |tokens|\n tokens.map! { |token| yield token } if block_given?\n end\n else\n yield number if block_given?\n [number]\n end\n end", "def set_last_digits\n if number\n number.to_s.gsub!(/\\s/,'')\n self.digits ||= number.to_s.length <= 4 ? number : number.to_s.slice(-4..-1)\n end\n end", "def splitInteger(num, parts)\n results = []\n remainder = num % parts\n parts.times do\n results << num / parts\n end\n \n results.reverse!.map! do |num|\n break if remainder == 0 \n remainder -= 1\n num += 1\n end\n \n results.reverse!\n \nend", "def digit_list(number)\n digits = []\n\n loop do\n break if number == 0\n\n digit = number % 10\n digits.unshift(digit)\n\n number = number / 10\n end\n\n digits\nend", "def integer_break(n)\nend", "def digits(number)\n return [0] if number.zero?\n\n number = number.abs\n digits = []\n loop do\n digits.unshift(number % 10)\n number = number.div(10)\n return digits if number.zero?\n end\n end", "def separate_comma(integer)\n if integer >= 1000\n number_array = integer.to_s.split(\"\").reverse\n counter = 0\n array_for_reverse = []\n number_array.each do |digit|\n if counter % 3 == 0 && counter != 0\n array_for_reverse << \",\"\n end\n array_for_reverse << digit\n counter += 1\n end\n final = \"\"\n array_for_reverse.reverse.each do |digit|\n final << digit\n end\n else\n final = integer.to_s\n end\n return final\nend", "def map_and_remove_nine(input, digits_to_number, number_to_digits)\n digits = input.find { |digits| digits.size == 6 && number_to_digits[4].subset?(digits) }\n map_and_remove(9, digits, digits_to_number, number_to_digits, input)\nend", "def last_n_digits(num, n)\r\n # your code goes here\r\n num % 10**n\r\nend", "def find_the_digit number\n if number / 1000\n thousands = number / 1000\n number = number - thousands*1000\n puts \"thousands: #{thousands}\"\n end\n if number / 100\n hundreds = number / 100\n number = number - hundreds*100\n puts \"hundreds: #{hundreds}\"\n end\n if number / 10\n tens = number / 10\n number = number - tens*10\n puts \"tens: #{tens}\"\n end\n if number / 1\n ones = number / 1\n puts \"ones: #{ones}\"\n end\nend", "def expanded_form(num)\n array = num.to_s.split(\"\")\n length = num.to_s.size - 1\n numbers_array = []\n\n array.each do |number|\n numbers_array << number.to_i * 10**(length)\n length -= 1\n end\n\n numbers_array.delete_if {|i| i == 0} # cleans up 0s from array. For example: expanded_form(70304)\n numbers_array.join(\" + \")\n\nend", "def digit_list(num)\n arr = []\n divisor = 10**((num.to_s.length) - 1)\n \n while divisor >= 1\n digit = num/divisor\n arr << (num / divisor)\n num -= digit*divisor\n\n divisor = divisor / 10\n end\n \n arr\nend", "def digit_list(number)\n digits = number.to_s.split('')\n digits = digits.map { |digit| digit.to_i }\n digits\nend", "def super_digit(n)\n return n if n < 10\n\n sum_digits = 0\n until n == 0\n sum_digits += n % 10\n n /= 10\n end\n\n super_digit(sum_digits)\nend", "def expanded_form(num)\n num.digits.map.with_index { |num, index| \"#{num}\" + '0' * index }\n .delete_if { |nums| nums.start_with? '0' }\n .reverse.join ' + '\nend", "def clean_numbers(number)\n number.gsub /\\D/, ''\n end", "def digitize(n)\n split_array_numbers = n.to_s.split(//).map { |x| x.to_i}.reverse\nend", "def separate_comma(number)\n\treturn number.to_s if number < 1000\n\tarr_string = number.to_s.split(\"\")\n\tnew_string = \"\"\n\tif number >= 1000 && number <= 9999\n\t\tarr_string.map! do |n|\n\t\t\tif arr_string.index(n) == 0\n\t\t\t\tnew_string << n + \",\"\n\t\t\telse\n\t\t\t\tnew_string << n\n\t\t\tend\n\t\tend\n\telsif number >= 10000 && number <= 99999\n\t\tarr_string.map! do |n|\n\t\t\tif arr_string.index(n) == 1\n\t\t\t\tnew_string << n + \",\"\n\t\t\telse\n\t\t\t\tnew_string << n\n\t\t\tend\n\t\tend\n\telsif number >= 100000 && number <= 999999\n\t\tarr_string.map! do |n|\n\t\t\tif arr_string.index(n) == 2\n\t\t\t\tnew_string << n + \",\"\n\t\t\telse\n\t\t\t\tnew_string << n\n\t\t\tend\n\t\tend\n\telsif number >= 1000000 && number <= 9999999\n\t\tarr_string.map! do |n|\n\t\t\tif arr_string.index(n) == 0 || arr_string.index(n) == 3\n\t\t\t\tnew_string << n + \",\"\n\t\t\telse\n\t\t\t\tnew_string << n\n\t\t\tend\n\t\tend\t\n\telsif number >= 10000000 && number <= 99999999\n\t\tarr_string.map! do |n|\n\t\t\tif arr_string.index(n) == 1 || arr_string.index(n) == 4\n\t\t\t\tnew_string << n + \",\"\n\t\t\telse\n\t\t\t\tnew_string << n\n\t\t\tend\n\t\tend\n\tend\n\tnew_string\t\nend", "def separate_comma(number)\n\tnumber = number.to_i\n\tif number.abs < 1000\n\t\tstring = number.to_s\n\tend\n\tif number.abs >= 1000\n\t\tstring = number.to_s.insert(-4, \",\")\n\tend\n\tif (1000000..999999999).include? number.abs\n\t\tstring.insert(-8, \",\")\n\tend\n\tif (1000000000..999999999999).include? number.abs\n\t\tstring.insert(-12,\",\")\n\tend\nreturn string\nend", "def featured(i) # found digits method but only works > v2.4 so...\n i = i - i % 7\n loop do\n i += 7\n list = []\n x = i\n while x > 0 do\n list.unshift(x % 10)\n x /= 10\n end\n if list.length > 9; return \"There is no possible number that fulfills those requirements\" end\n if list == list.uniq; break end\n end \n i\nend", "def expanded_form(num)\n size = num.to_s.size\n result = []\n i = 1\n while i < size\n rest = num % 10**i\n num -= rest\n result.unshift(rest)\n i += 1\n end\n result.unshift(num).delete(0)\n result.join(\" + \")\nend", "def expanded_form(num)\n number = num.to_s # This will be \"12\"\n num_digits = num.to_s.length\n split_number = number.split(\"\").reverse # This will be [\"2\",\"1\"]\n expanded_array = []\n 0.upto(num_digits-1) do |n| # This will be 0 up to 1\n single_split_number = split_number[n].to_i*(10**n)\n next if single_split_number == 0\n expanded_array << single_split_number.to_s\n end\n expanded_array.reverse! # This will be [\"10\",\"2\"]\n output_array = expanded_array.join(\" + \") # Final statement\nend", "def featured(integer)\n return \"There is no possible number that fulfills those requirements\" if \n integer >= 9_876_543_210\n integer += 1\n until integer % 7 == 0 && integer.odd? && integer.digits.uniq! == nil\n integer += 1\n end\n integer\nend", "def separate_comma(your_number)\nyour_number = your_number.to_s\n if your_number.length < 4\n return your_number\n elsif\n your_number.length >= 4 && your_number.length <= 6\n return your_number[0..-4] + ',' + your_number[-3..-1]\n elsif\n your_number.length >= 7 && your_number.length <= 9\n return your_number[0..-7] + ',' + your_number[-6..-4] + ',' + your_number[-3..-1]\n elsif\n your_number.length >= 10 && your_number.length <= 12\n return your_number[0..-10] + ',' + your_number[-9..-7] + ',' + your_number[-6..-4] + ',' + your_number[-3..-1]\n end\nend", "def separate_comma(num) #takes an integer and converts it to a string with commas in appropriate places\n\tnumber_as_string = num.to_s #converts num to a string\n\tif number_as_string.length < 4 #checks if number isn't long enough to need a comma\n\t\tnumber_as_string #return the number as a string\n\telsif number_as_string.length < 7 #checks if number is bigger than 999, but less than 999,999\n\t\tnumber_as_string.insert -4, ',' #inserts a comma at the 4th from last place in string\n\telse\n\t\tnumber_with_1comma = number_as_string.insert -4, ',' #inserts a comma at the 4th from last place in string and saves that in a variable\n\t\tnumber_with_1comma.insert -8, ',' #inserts second comma in 8th from last place\n\tend\nend", "def delete_digit_x(n)\n n.digits.reverse.combination(n.digits.size-1).max.join.to_i\nend", "def digit_list(number)\n return number.abs.to_s.split('').map(&:to_i)\nend", "def convert_3_digits_number(value)\n word = ''\n division_result = value / 100\n mod_result = value % 100\n\n if division_result > 0\n word = \"#{LESS_THAN_20[division_result]} hundred\"\n word = \"#{word} \" if mod_result > 0\n end\n\n word = \"#{word}#{convert_2_digits_number(mod_result)}\" if mod_result > 0\n word\n end", "def integer_to_string(number)\n result = []\n loop do\n divisor, remainder = number.divmod 10\n result.unshift(remainder) # or use push/<<, then reverse the array after loop ends\n break if divisor == 0\n number = divisor\n end\n \n result.join\nend", "def represent(number, in_base:)\n digits = \"\"\n\n while number > 0\n digits = CHARS[number % in_base] + digits\n number = number / in_base\n end\n\n digits\n end", "def digit_list(num)\n if num < 10\n [num % 10]\n else\n num, digit = num.divmod(10)\n digit_list(num).push(digit)\n end\nend", "def digit_list(num)\n num.to_s.split(//).map(&:to_i)\nend", "def digit_list(num)\n num.to_s.split(//).map(&:to_i)\nend", "def expanded_form(num)\r\n num.digits.each_with_index.map{| val, idx | val * (10 ** idx)}.select{|x| x != 0}.reverse.join(\" + \")\r\nend", "def separate_comma (number)\n a = number.to_s.chars.to_a.reverse\n b = a.count/3\n if a.count < 4\n return number.to_s\n elsif a.count == 6\n a.insert(3, \",\")\n return a.join.reverse\n elsif\n c = 3\n b.times do |n|\n a.insert(c, \",\")\n c = c +4\n end\n return a.join.reverse\n end\nend", "def super_digit(n)\n return n if n/10 == 0\n \n sum = n % 10\n while n/10 != 0\n n = n/10\n sum += n % 10\n end\n return super_digit(sum)\nend", "def formata_numero number, opts={}\n number = number.to_s\n opts = { loop: 10, insert: :\"0\" }.merge opts\n # remove as virgulas e pontos caso seja um valor de dinheiro\n number.gsub! /[,\\.\\ ]/ , ''\n (opts[:loop] - number.length).times { number = \"#{opts[:insert]}#{number}\" }\n number\n end", "def featured2(number)\n number += 1\n number += 1 until number.odd? && number % 7 == 0\n\n loop do\n number_chars = number.to_s.split('')\n return number if number_chars.uniq == number_chars\n number += 14\n break if number >= 9_876_543_210\n end\n\n 'There is no possible number that fulfills those requirements.'\nend", "def number_wang(number)\n if number.to_s.length > 11\n puts 'number is bad. just bad'\n end\n if number.to_s =~ /^\\d{10}$/\n puts 'number is good'\n end\n if number.to_s =~ /^1\\d{10}$/\n puts \"number is 11 digits long but that's ok\"\n new_number = number.to_s\n new_number.slice!(0)\n number = new_number.to_i\n puts number\n end\n if number.to_s =~ /^^1\\d{10}$/\n puts \"number is 11 digits long and it's not ok\"\n end\nend", "def separate_comma(number)\n array = number.to_s.reverse.split(//)\n length = array.length\n\n if length <= 6\n n = 0\n elsif length % 2 == 0\n n = 1\n else\n n = 2\n end\n\n if length < 4\n return array.join.reverse\n elsif length <= 9 \n i = 3 \n while i < length + n do \n array.insert(i, \",\")\n i = i + 4 \n end\n end\n\n return array.join.reverse.to_s\nend", "def split_number(number)\n coefficient, exponent = Kernel.format(\"%e\", number).split(\"e\")\n\n [coefficient.to_f, exponent.to_i]\n end", "def separate_comma(number)\n comma_separated_number = number.to_s.reverse.split('').each_slice(3).map {|obj| obj.push(\",\") }.join.chop.reverse\nend", "def separate_comma(number)\n array = number.to_s.split('') #creates an array from number w/ digits\n number_commas = array.size/3.0 #how many commas\n if array.size < 4 #this is a 3 digit number\n return number.to_s #return number no comma needed\n elsif array.size%3 == 0\n n = -4\n (number_commas.to_i-1).times do |i|\n array.insert(n, ',')\n n -= 4\n end\n return array.join(\"\")\n else\n n = -4\n number_commas.to_i.times do |i|\n array.insert(n, ',')\n n -= 4\n end\n return array.join(\"\")\n end\nend", "def get_first_digit n \n n / 10**length(n) \nend", "def checkdigit(number)\n\t\t\tdigits = number.to_s.reverse.scan(/\\d/).map { |x| x.to_i }\n\t\t\tdigits = digits.each_with_index.map { |d, i|\n\t\t\t d *= 2 if i.even?\n\t\t\t d > 9 ? d - 9 : d\n\t\t\t}\n\t\t\tsum = digits.inject(0) { |m, x| m + x }\n\t\t\tmod = 10 - sum % 10\n\t\t\tmod==10 ? 0 : mod\n \tend", "def super_digit(n)\n return n if n / 10 == 0\n return super_digit(digit_helper(n))\nend", "def to_digits(d)\n digits = []\n while d > 0\n digits << d % 10\n d /= 10\n end\n digits\nend", "def featured(number)\n number += 1\n\n until number % 7 == 0 && number.odd?\n number += 1\n end\n\n loop do\n if number.digits.uniq == number.digits\n return number\n else\n number += 14\n end\n break if number.digits.size > 10\n end\n\n \"Error\"\nend", "def divisible_by_thousand?(number)\n (number % 1000).zero?\n end", "def double_digits\n times_by_2.map do |number|\n if number > 9\n number - 9\n else\n number\n end\n end\nend", "def separate_comma(num)\n\tif num >= 1000\n\t\tarr = num.to_s.reverse.split(//)\n# There's a way to iterate here, ASK AT OFFICE HOURS arr.map!.with_index {|x,y} x + \",\" if y % 3}???\n\t\tnew_arr = []\n\t\tidx = 0\n\t\twhile (idx + 1) < arr.length\n\t\t\tif (idx + 1) % 3 == 0\n\t\t\t\tnew_arr.push(arr[idx] + \",\")\n\t\t\t\tidx += 1\n\t\t\telse\n\t\t\t\tnew_arr.push(arr[idx])\n\t\t\t\tidx += 1\n\t\t\tend\n\t\tend\n\t\tstr = new_arr.push(arr[idx]).join.reverse\n\t\treturn str\n\telse\n\t\treturn num.to_s\n\tend\nend", "def digit_list(number)\n list = number.to_s.split('').map { |i| i.to_i }\nend", "def dasherize_number(num)\n arr = num.to_s.split(\"\")\n idx = 0\n while idx < arr.length\n if arr[idx].to_i % 2 == 0\n idx += 1\n elsif idx == 0 && arr[idx].to_i % 2 != 0\n arr[idx] = \"#{arr[idx]}-\"\n elsif arr[idx].to_i % 2 != 0 && arr[idx - 1].length > 1\n arr[idx] = \"#{arr[idx]}-\"\n else\n arr[idx] = \"-#{arr[idx]}-\"\n end\n idx += 1\n end\n return final = arr.join(\"\").split(\"\")\n if final[-1] == \"-\"\n final.pop\n end\n return final.join(\"\")\nend", "def get_actual_number(number)\n if number >= 31\n return number + 2\n else\n return number + 1\n end\n end", "def featured(int)\n for num in (int + 1...9_999_999_999) \n return num if num.odd? && num % 7 == 0 && num.digits == num.digits.uniq\n end\n \"There is no possible number that fulfills those requirements\"\nend", "def group_by_hundreds(num)\n str = num.to_i.to_s\n a = []\n str.split(//).reverse.each_slice(3) { |slice| a << slice }\n\n t = str.length % 3\n t = 3-t if t>0\n for i in 1..t\n a << 0\n end\n\n new_a = []\n a.each do |item|\n new_a << item\n end\n\n new_a.flatten.join\nend", "def delete_digit(n)\n (s = n.to_s.chars).combination(s.size-1).max.join.to_i\nend", "def last_n_digits(num, n)\n # your code goes here\n if n == 1\n return num % 10\n else\n \treturn num % 100\n end\nend", "def get_digits(num)\n digits = []\n result = num \n first_iter_flag = true\n while(result != 0)\n result = result/10 if(!first_iter_flag)\n first_iter_flag = false if(first_iter_flag)\n digits.unshift result%10 if(result != 0)\n end\n digits\nend", "def format_number(number)\n whole, decimal = number.to_s.split('.')\n if whole.to_i < -999 || whole.to_i > 999\n whole.reverse!.gsub!(/(\\d{3})(?=\\d)/, '\\\\1,').reverse!\n end\n [whole, decimal].compact.join('.')\nend", "def fancy_number(num)\n \"$\" + num.to_s.reverse.scan(/\\d{3}|.+/).join(\",\").reverse\n end", "def last_digit(int)\n # your code goes here\n return int % 10\nend", "def digitize(n)\n nums = n.to_s.split('')\n nums.map { |num| num.to_i }\nend", "def digit_list(int)\n int.digits.reverse\nend", "def digit_list(int)\n int.digits.reverse\nend", "def to_string(number)\n str_array = []\n loop do\n str_array.unshift(number % 10)\n number /= 10\n break if number == 0\n end\n str_array.join\nend", "def digits(num)\n cs = num.to_s.chars\n [].tap do |o|\n while cs.size > 0\n c = cs.shift\n o << (c + Array.new(cs.length) { |_i| 0 }.join).to_i\n end\n end\nend", "def featured(number)\n number += 1\n number += 1 until number.odd? && number % 7 == 0\n\n loop do\n number_chars = number.to_s.split('')\n return number if number_chars.uniq == number_chars\n number += 14\n break if number >= 9_876_543_210\n end\n\n 'There is no possible number that fulfills those requirements.'\nend", "def two_digits_number(x)\n x < 10 ? \"0#{x}\" : x.to_s\n end", "def with_check_digit(number)\n sum = control_sum(number)\n check_digit = to_a(sum * 9).last\n to_a(number).push(check_digit).join.to_i\n end", "def separate_comma(number)\n number_string = number.to_s.split(\"\")\n new_string = \"\"\n if number_string.length < 4\n return number_string.join\n else\n sub_str = \"\"\n number_string.reverse_each do |digit|\n sub_str = digit + sub_str\n if sub_str.length == 3\n new_string = \",\" + sub_str + new_string\n sub_str = \"\"\n end\n end\n new_string = sub_str << new_string\n if new_string[0] == \",\"\n new_string = new_string[1..-1]\n end\n end\n new_string\nend", "def featured(num)\n return 'Error! No featured numbers exist over 10 digits!' if num >= 9876543210\n loop do\n num += 1\n break if num.odd? && (num % 7).zero? && num.digits.uniq! == nil\n end\n num\nend", "def featured(number)\n number += 1\n number += 1 until number.odd? && number % 7 == 0\n\n loop do\n number_chars = number.to_s.split('')\n return number if number_chars.uniq == number_chars\n number += 14\n break if number > 9_876_543_210\n end\n\n 'There is no possible number that fulfills those requirements.'\nend", "def digitize(n)\n n.digits\nend", "def digitize(n)\n number_array =[] #convert n into a string to use split. Map lets us create a new array but we must convert back into int\n number_array = n.to_s.split(\" \").map(&:to_i) # SPLIT divided strings into substrings\n return number_array\n\nend", "def digit_list(integer)\n integer.digits.reverse\nend", "def number_reverser(number)\n result = 0\n while number != 0\n digit = number % 10\n result = (result * 10) + digit\n number = number / 10\n end\n result\nend", "def number_to_digit_array(number, max_size=0)\n array = []\n while number != 0\n array << number % 10\n number /= 10\n end\n (0..((max_size)-(array.length)-1)).each do |x|\n array << 0\n end\n array.reverse\n end", "def handle_ten (num)\n num2str=''\n if (num%10==0)\n num2str+=NUM_MAP[num]\n elsif (num>10 && num<20)\n num2str+=NUM_MAP[num]\n else\n num2str+=NUM_MAP[num/10*10]+'-'+NUM_MAP[num%10]\n end\n return num2str\nend", "def wordify_upto_99(number)\n\t# deal with the numbers 20 and under, straight from array\n\tif number < 21\n\t\tword = @words[number]\n\n\t# numbers 21 to 99, need to split and take from \"@tens\" array first digit\n\telsif number < 100\n\t\tfirst = @tens[number.to_s.slice(0).to_i]\n\t\tif number.to_s.slice(1) == \"0\"\n\t\t\tsecond = \"\"\n\t\telse\n\t\t\tsecond = @words[number.to_s.slice(1).to_i]\n\t\tend\n\t\tword = first + \" \" + second\n\telse\n\t\treturn \"Number greater than 100! Not allowed with this method\"\n\tend\n\treturn word\nend" ]
[ "0.7093631", "0.6990583", "0.6944445", "0.6906978", "0.6652212", "0.65960974", "0.65678585", "0.6559207", "0.654048", "0.6493624", "0.64903283", "0.64801943", "0.6449086", "0.6442826", "0.6417926", "0.6390654", "0.638116", "0.63810146", "0.63440937", "0.6342555", "0.633736", "0.6330098", "0.63202125", "0.6314721", "0.6304108", "0.6298456", "0.62918943", "0.6288545", "0.62643176", "0.6261027", "0.62512535", "0.6245929", "0.622904", "0.6197641", "0.61970925", "0.6191894", "0.6183805", "0.61823374", "0.61707735", "0.6148827", "0.61177796", "0.6109481", "0.61003745", "0.60975087", "0.6091176", "0.6090127", "0.6088772", "0.6087007", "0.60710794", "0.604794", "0.6045213", "0.60444546", "0.6042088", "0.6042088", "0.6035309", "0.6034968", "0.60263014", "0.60202974", "0.6018824", "0.601539", "0.601089", "0.60096115", "0.60029775", "0.60004246", "0.5995814", "0.59930795", "0.5992049", "0.59920156", "0.5989801", "0.59872895", "0.5981396", "0.59792024", "0.5976916", "0.59762454", "0.5973066", "0.5970417", "0.59703153", "0.59685546", "0.5966973", "0.5966043", "0.5964259", "0.5960072", "0.5957391", "0.59519744", "0.5950428", "0.5950428", "0.5947651", "0.594447", "0.5936279", "0.5936137", "0.59316736", "0.5931519", "0.5921625", "0.5920546", "0.59204626", "0.59131086", "0.591019", "0.590995", "0.5907363", "0.5906409", "0.5905131" ]
0.0
-1
Gets the path for a sound file based on configuration and platform
def sound_path(name) multi_path(File.join(Adhearsion.config.ahnsay.sounds_dir, name)) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_sound_source(type)\r\n sound = nil\r\n case type\r\n when :play_fitbell\r\n sound = File.join(get_resource_path, \"sound/fitebell.wav\")\r\n when :play_ba\r\n sound = File.join(get_resource_path, \"sound/ba.wav\")\r\n when :play_click4\r\n sound = File.join(get_resource_path, \"sound/click_4bit.wav\")\r\n when :play_mescola\r\n sound = File.join(get_resource_path, \"sound/dealtwocards.wav\")\r\n else\r\n @log.debug(\"Sound not recognized #{type}\")\r\n end #end case\r\n return sound\r\n end", "def audio_path(source)\n compute_public_path(source, 'audios')\n end", "def audio_path\n #TODO change path after Yura send information\n \"/audio/success.wav\"\n end", "def audio_path(source, options = T.unsafe(nil)); end", "def search_sound(file)\n Dir.glob(File.join(@default_dir_images, file) + '.{mp3,wma,wav}').first\n end", "def audio_path(source, options = {})\n asset_path source, sprockets_helpers_settings.default_path_options[:audio_path].merge(options)\n end", "def full_path\n if path[0] == '/'\n path\n else\n File.join(Play.music_path,path)\n end\n end", "def play what\n case Avalon::Config[:alert_sounds]\n when false, :none, :no\n when Hash\n tunes = [Avalon::Config[:alert_sounds][what] || what].compact.flatten\n\n tunes.each do |tune|\n file = find_file( tune, \"../../../sound/#{tune}\",\n \"~/.avalon/sound/#{tune}\", \"/System/Library/Sounds/#{tune}\")\n case system\n when 'Darwin'\n `afplay #{file}`\n when 'Linux'\n raise 'Please install sox package: sudo apt-get install sox' if `which sox`.empty?\n `play -q #{file}`\n end\n end\n end\n end", "def file_for_day(day)\n sound_path(\"day-#{day}.ul\")\n end", "def media_path\n @media_path ||= Pathname.new(source_dir).join(data['media_path'] || './media').to_s\n end", "def sound_dir=(value)\n value += '/' if value != '' and value[-1] != '/'\n @sound_dir = value\n end", "def pbResolveAudioSE(file)\n return nil if !file\n if RTP.exists?(\"Audio/SE/\"+file,[\"\",\".wav\",\".mp3\",\".ogg\"])\n return RTP.getPath(\"Audio/SE/\"+file,[\"\",\".wav\",\".mp3\",\".ogg\"])\n end\n return nil\nend", "def pbResolveAudioSE(file)\n return nil if !file\n if RTP.exists?(\"Audio/SE/\"+file,[\"\",\".wav\",\".mp3\",\".ogg\"])\n return RTP.getPath(\"Audio/SE/\"+file,[\"\",\".wav\",\".mp3\",\".ogg\"])\n end\n return nil\nend", "def pbResolveAudioSE(file)\n return nil if !file\n if RTP.exists?(\"Audio/SE/\"+file,[\"\",\".wav\",\".mp3\",\".ogg\"])\n return RTP.getPath(\"Audio/SE/\"+file,[\"\",\".wav\",\".mp3\",\".ogg\"])\n end\n return nil\nend", "def path_to_audio(source, options = T.unsafe(nil)); end", "def sound(id, global = false, ext = '.wav')\n a = global ? @global_sounds : @sounds\n return a[id] if a[id]\n s = @prefix + @sound_dir + id.to_s.split(@separator).join('/') + ext\n sound = Gosu::Sample.new s\n a[id] = sound\n end", "def store_dir\n # Change App.Models.Storybook#_parseAssetUrl() if following is changed\n \"sounds/#{model.id}\"\n end", "def path\n File.expand_path File.join(songs.first.path, '..').gsub(' ','\\ ')\n end", "def full_path(settings)\n return File.join( settings.music_dir_path , self.path )\n end", "def filePath()\n return File.join(@@publicDir, @@tracksDir, \"#{self.fileName}#{self.fileType}\").to_s\n end", "def sounds_get(sound_id)\n get \"sounds/#{sound_id}\"\n end", "def fq_bundle_sample_prompt\n \"public/upload/audio/\" + bundle_resouce_file_name + \".mp3\"\n end", "def get_file_source(opts)\n BawWorkers::Validation.check_custom_hash(opts, BawWorkers::Jobs::Analysis::Payload::OPTS_FIELDS)\n\n file_sources = @original_store.existing_paths(opts)\n\n if file_sources.empty?\n possible_sources = @original_store.possible_paths(opts)\n msg = \"No original audio files found in #{possible_sources.join(', ')} using #{opts.to_json}.\"\n @logger.error(@class_name) do msg end\n raise BawAudioTools::Exceptions::AudioFileNotFoundError, msg\n end\n\n File.expand_path(BawWorkers::Validation.normalise_path(file_sources.last, nil))\n end", "def play_sound \n system\"play #{@sound_file}\"\n end", "def wav\n @wav ||= @info_file.sub(/txt$/, 'wav')\n end", "def soundcloud_id\n\t\tif soundcloud?\n\t\t\treturn path[\"stoffi:track:soundcloud:\".length .. -1]\n\t\telse\n\t\t\treturn \"\"\n\t\tend\n\tend", "def sound\n LanguageSound.where(language_id: id)\n end", "def file_path\n File.join device.path, id.to_s(16)\n end", "def sound_exist?(filename)\n return File.exist?(filename)\n end", "def public_path(folder_name, file_name)\n \"./audio/#{folder_name}/#{file_name}\"\n end", "def full_filename\n filename ? File.join( AppConfig.FlashRecordingPath, filename) : \"\"\n end", "def GetPlatformOfFile ( fl )\n platforms = { \"a1\" => \"AQUA-1\", \"t1\" => \"TERRA-1\", \"npp\" => \"NPP\"}\n \n x = File.basename(fl).split(\".\").first\n puts x\n return platforms[x] if ( platforms[x])\n return \"unknown\"\nend", "def IMG_PATH\n SongBugs::IMG_PATH\n end", "def audio_device_name\n return @audio_device_name\n end", "def sound; end", "def sound\n raise NotImplementedError\n end", "def soundcloud_url; \"https://soundcloud.com/#{soundcloud}\" end", "def audio\n @audio ||= URI.parse(\"#{AUDIO_SERVICE_URL}/#{@language.slug}/#{URI::encode(@text)}.mp3\")\n end", "def path\n File.join(@sprites.configuration.sprites_path, @path || sprite_file_name)\n end", "def store_dir\n Rails.root.to_s + \"/audio/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}\"\n # \"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}\"\n end", "def play_sound\n system 'afplay ./app/sounds/test_sound.mp3 &'\n end", "def soundVolume \n \"soundVolume\" \n end", "def john_pot_file\n ::File.join(::Msf::Config.config_directory, \"john.pot\")\n end", "def src\n\n sdk_path = find_sdk\n unless sdk_path == nil\n SDK_SRC_PATHS.each { |sp|\n p = sdk_path+sp\n return p if File.directory? p\n }\n end\n\n nil\n end", "def path\n if location =~ /^\\/dev/\n \"dev:#{location}\"\n elsif location =~ /iso$/\n \"iso:#{location}\"\n elsif location.is_a?(Integer)\n \"disc:#{location}\"\n elsif location =~ /^disc/\n location\n else\n raise RuntimeError\n end\n end", "def path\n if location =~ /^\\/dev/\n \"dev:#{location}\"\n elsif location =~ /iso$/\n \"iso:#{location}\"\n elsif location.is_a?(Integer)\n \"disc:#{location}\"\n elsif location =~ /^disc/\n location\n else\n raise RuntimeError\n end\n end", "def filepath\n File.join(JapaneseNames.root, 'bin/enamdict.min')\n end", "def _SPECSDIR; Config._SPECS; end", "def sap_media_dir\n ::File.join(cache, 'sap_media')\n end", "def asset_path name\n fdpath = @app.asset(name)\n\n if fdpath && fdpath.start_with?(@app.assets_dir)\n if fdpath.start_with?(@app.public_dir)\n fdpath[@app.public_dir.length..-1]\n else\n fdpath[@app.assets_dir.length..-1]\n end\n else\n path = File.join('', name)\n [path, *@app.asset_version(name)].compact.join(\"?\")\n end\n end", "def volume\n `#{@sound}.volume`\n end", "def create_sound_sound(filename, flags = nil)\n Yuki::ElapsedTime.start(:audio_load_sound)\n if (file_data = @sound_cache[filename])\n @sound_count[filename] += 1\n else\n file_data = File.binread(filename)\n Yuki::ElapsedTime.show(:audio_load_sound, 'Loading sound from disk took')\n end\n gm_filename = filename.include?('.mid') && File.exist?('gm.dls') ? 'gm.dls' : nil\n sound_info = FMOD::SoundExInfo.new(file_data.bytesize, nil, nil, nil, nil, nil, gm_filename)\n sound = FMOD::System.createSound(file_data, create_sound_get_flags(flags), sound_info)\n sound.instance_variable_set(:@extinfo, sound_info)\n Yuki::ElapsedTime.show(:audio_load_sound, 'Creating sound object took')\n return sound\n rescue Errno::ENOENT\n log_error(\"Failed to load sound : #{filename}\")\n return nil\n end", "def file_for_month(month)\n sound_path(\"mon-#{month.to_i - 1}.ul\")\n end", "def driver_path\n File.absolute_path File.join(System.install_dir, file_name)\n end", "def random_song\n @mode = :dj\n \n wd = Dir.pwd\n Dir.chdir music_folder\n songs = Dir.glob(\"**/*.{mp3,ogg}\")\n path = songs[rand(songs.size)]\n Dir.chdir wd\n \n if path.blank?\n nil\n else\n [0, path, quick_title(path)]\n end\n end", "def generate_wav_source(source)\n ext = File.extname(source)\n ext_gsubbed = ext.gsub(/\\./, '')\n\n if ext != \".wav\"\n input_options = { type: ext_gsubbed }\n output_options = { type: \"wav\" }\n source_filename_without_extension = File.basename(source, ext)\n output_file_path = File.join File.dirname(source), \"tmp_#{source_filename_without_extension}_#{Time.now.to_i}.wav\"\n converter = Sox::Cmd.new\n converter.add_input source, input_options\n converter.set_output output_file_path, output_options\n converter.run\n output_file_path\n else\n source\n end\n rescue Sox::Error => e\n raise e unless e.message.include?(\"FAIL formats:\")\n raise RuntimeError.new(\"Source file #{source} could not be converted to .wav by Sox (Sox: #{e.message})\")\n end", "def media_path_location\n return @media_path_location\n end", "def play_hash_audio(hash)\n HASH_SOUND_MAP.each do |k, v|\n `#{SOUND_APP} #{SOUNDS_DIR}/#{v}` if hash.downcase.match(k.downcase)\n end\nend", "def read_platform_from_file(path:)\n path.basename.to_s.split('.').first\n end", "def source_path\n Pathname.new(config[:source_path])\n end", "def framework_path\n File.join(config.build_products_dir, name)\n end", "def get_web_sample_path()\n\t\treturn backslashify(File.join(Dir.pwd, WEB_SAMPLE_DIR))\n\tend", "def src\n File.join('/assets', @type, (p? ? @kpath : @path))\n end", "def filename\n Dir[glob].first if exists?\n end", "def track_dir(file_name)\n file = file_name.sub(Cfg.music_dir, '')\n return file.sub(file.split('/')[0], '')\n end", "def play_sound(sound_file)\n begin\n file_or_stream = java.io.File.new(sound_file)\n audio_stream = AudioSystem.get_audio_input_stream(file_or_stream)\n clip = AudioSystem.clip\n clip.open(audio_stream)\n clip.start\n rescue => e\n puts e.full_message\n end\n end", "def filename\n local?? swf_url : tmp_file.path\n end", "def get_audio\n return @audio\n end", "def search_audio_file(file_name)\n # Trace.debug(\"Search audio for track #{@rtrack.to_s.brown}\")\n extensions = Cfg.size_over_quality ? FILE_EXTS_BY_SIZE : FILE_EXTS_BY_QUALITY\n\n extensions.each do |ext|\n if File.exists?(file_name+ext)\n set_audio_state(Status::OK, file_name+ext)\n return audio.status\n end\n end\n\n # Remove the root dir & genre dir to get the appropriate sub dir\n file = track_dir(file_name)\n Dir[Cfg.music_dir+'*'].each do |entry|\n next unless File.directory?(entry)\n extensions.each do |ext|\n if File.exists?(entry+file+ext)\n set_audio_state(Status::MISPLACED, entry+file+ext)\n return audio.status\n end\n end\n end\n\n set_audio_state(Status::NOT_FOUND, nil)\n return audio.status\n end", "def path\n (public_path + sitemaps_path + filename).expand_path.to_s\n end", "def path\n native.path\n end", "def url\n @url ||= File.join(AUDIO_URL_ROOT, self.path) if self.live?\n end", "def call\n PollyService.update if @@polly.nil?\n mp3_file = Rails.root.join(\"#{@@audio_dir}/polly-#{@voice_id}-#{@entry.id}-#{@entry.updated_at}.mp3\")\n # don't request a new file from polly if the same file already exists\n return mp3_file if File.exist?(mp3_file)\n\n params = {\n response_target: mp3_file,\n output_format: 'mp3',\n text: @text,\n text_type: @type,\n voice_id: @voice_id\n }\n Rails.logger.debug \"Polly: #{params}\"\n begin\n @@polly&.synthesize_speech(params)\n rescue\n FileUtils.rm_f(mp3_file)\n return Rails.root.join(\"#{@@audio_dir}/buzzer.wav\")\n end\n mp3_file\n end", "def path\n @path ||= File.join(Rack::Fontserve.fonts_path, name)\n end", "def getFiletype filename\n extension = filename.split(\".\")[1]\n case extension\n when \"wav\" then\t\"audio/wav\"\n when \"amr\" then\t\"audio/amr\"\n when \"amr-wb\" then \"audio/amr-wb\"\n when \"x-speex\" then \"audio/x-speex\"\n when \"spx\" then\t\"audio/x-speex\"\n else \n end\n end", "def getAudioUri\n return @data.scan(/https:\\/\\/.*?\\.mp3/)[0]\nend", "def relativeWebPath()\n return File.join('/', @@tracksDir, \"#{self.fileName}#{self.fileType}\")\n end", "def play_sound\n case @type\n when 1; Sound.play_forge_item\n when 2; Sound.play_forge_weapon\n when 3; Sound.play_forge_armor\n else; Sound.play_use_item\n end\n end", "def root_dir\n self.class.plays_dir.join script_name\n end", "def current_file_path\n clurl = AssetSettings[:local_assets][@file_id].last\n clurl.sub(/\\A#{AssetSettings[:local_assets].assets_url_prefix}/,\n '') if clurl\n end", "def asset_path(kind, source = nil)\n kind, source = source, kind if source.nil?\n source = asset_normalize_extension(kind, escape_link(source.to_s))\n return source if source =~ ABSOLUTE_URL_PATTERN || source =~ /^\\//\n source = File.join(asset_folder_name(kind), source)\n timestamp = asset_timestamp(source)\n result_path = uri_root_path(source)\n \"#{result_path}#{timestamp}\"\n end", "def platform_specific_path(path)\n if RUBY_PLATFORM =~ /mswin|mingw|windows/\n system_drive = ENV['SYSTEMDRIVE'] ? ENV['SYSTEMDRIVE'] : \"\"\n path = win_slashify File.join(system_drive, path.split('/')[2..-1])\n end\n\n path\n end", "def build_audio_file_name\n return track.build_audio_file_name(segment_artist, record, segment, genre)\n end", "def path\n\t\tunless @@rtp_directory\n\t\t\tread_ini = lambda{|val|File.foreach(\"Game.ini\"){|line| break($1) if line =~ /^#{val}=(.*)$/}}\n\t\t\tkey = type = size = [].pack(\"x4\")\n\t\t\tRegOpenKeyExA.(2147483650, 'Software\\Enterbrain\\RGSS3\\RTP', 0, 131097, key)\n\t\t\tkey = key.unpack('l').first\n\t\t\trtp_data = read_ini.(\"RTP\")\n\t\t\tRegQueryValueExA.(key, rtp_data, 0, type, 0, size)\n\t\t\tbuffer = ' '*size.unpack('l').first\n\t\t\tRegQueryValueExA.(key, rtp_data, 0, type, buffer, size)\n\t\t\tRegCloseKey.(key)\n\t\t\t@@rtp_directory = (buffer.gsub(/\\\\/, '/')).delete!(0.chr)\n\t\t\t@@rtp_directory += \"/\" if @@rtp_directory[-1] != \"/\"\n\t\tend\n\t\treturn @@rtp_directory\n\tend", "def sound(soundfile, opts = {}, &blk)\n playable_sound = Shoes::Sound.new(gui_container, soundfile, opts, &blk)\n end", "def play_sound(sound_path, loops = 0)\n if File.exist?(sound_path)\n free_channels\n sample = SDL2::Mixer::Chunk.load(sound_path)\n @sounds << sample\n channel = available_channel\n if channel.is_a?(Integer)\n SDL2::Mixer::Channels.play(channel, sample, loops)\n @channels[channel] = true\n else\n log(\"No channels available for sound playback!\")\n end\n else\n log(\"Sound file not found at '#{sound_path}'\")\n end\n end", "def bubble_sound\n pid = fork{exec 'afplay', \"lib/Large_bubble_sound.mp3\"}\n end", "def path\n @game_info['path']\n end", "def picture_path\n File.expand_path(File.join(PICTURE_DIR, code2filename(code)))\n end", "def source_path\n Pathname.new(self.config[:source_path])\n end", "def file_path\n File.join(AssetMapper.assets_dir, filename)\n end", "def get_media_filepath\n \"Accounts/#{@note.account.identifier}/Previews/#{@filename}\"\n end", "def sound(soundfile, opts = {}, &blk)\n Shoes::Sound.new self.gui, soundfile, opts, &blk\n end", "def path\n @backend.lib_dir + name_on_disk\n end", "def target_file_path\n model.source_location(target_symbol)[:file_path]\n end", "def system_path( type )\n paths = {\n :documents => NSDocumentDirectory,\n :autosaved_information => NSAutosavedInformationDirectory,\n :caches => NSCachesDirectory,\n :application_support => NSApplicationSupportDirectory,\n :downloads => NSDownloadsDirectory,\n :item_replacement => NSItemReplacementDirectory\n }\n return nil unless paths.has_key? type\n\n url = NSFileManager.defaultManager.URLsForDirectory(paths[type],\n inDomains: NSUserDomainMask).first\n return nil if url.nil?\n\n url.fileSystemRepresentation\n end", "def make\n App.out.make_audio_file\nend", "def local_file_path\n afilePath = building.local_path + SAVE_PATH + id.to_s\n\n if file_suffix != \"\" && file_suffix != nil\n afilePath = afilePath + \".\" + file_suffix\n end\n\n afilePath \n end", "def call\n context.sound = Sound[context.sound_id]\n raise SoundNotFoundError unless context.sound\n\n rescue SoundNotFoundError\n context.fail!(error: :sound_not_found)\n\n end", "def vendor_fuseki_path\n Dir[File.join(Rails.root, \"vendor\", \"jena-fuseki-*\")].first\n end" ]
[ "0.7387547", "0.7022132", "0.6817764", "0.6745143", "0.6715965", "0.66164345", "0.6444321", "0.64136654", "0.64128417", "0.63787866", "0.63623923", "0.63603956", "0.63603956", "0.63603956", "0.6144198", "0.6126113", "0.6100045", "0.6086465", "0.6079731", "0.6026207", "0.6010136", "0.5993458", "0.59450096", "0.5905258", "0.5846544", "0.58383316", "0.57679766", "0.5723026", "0.5714541", "0.5708104", "0.5687977", "0.56743073", "0.56689584", "0.5665036", "0.5634704", "0.56290543", "0.5625369", "0.55842644", "0.558039", "0.5576207", "0.5546434", "0.55148256", "0.55111635", "0.5503027", "0.549686", "0.549686", "0.54960287", "0.5493082", "0.547474", "0.5471142", "0.54487056", "0.54238516", "0.5419756", "0.5418968", "0.5410116", "0.54098475", "0.53998655", "0.5389672", "0.53886396", "0.5387913", "0.53861684", "0.5383518", "0.5375697", "0.53710955", "0.5371037", "0.53652364", "0.53541416", "0.53534824", "0.5350125", "0.5323559", "0.5320153", "0.5319853", "0.5319081", "0.53135467", "0.5307285", "0.5291011", "0.5290482", "0.52848905", "0.5278665", "0.5277317", "0.5275362", "0.5273774", "0.52735525", "0.5273466", "0.52525824", "0.5251363", "0.52502", "0.52483165", "0.52483153", "0.5246877", "0.52449185", "0.5230718", "0.5226401", "0.5222928", "0.52201235", "0.5208449", "0.5199893", "0.51997703", "0.51981014", "0.5179672" ]
0.7876083
0
Massages the file path depending on platform
def multi_path(path) path = path.chomp(File.extname(path)) if Adhearsion.config.punchblock.platform == :asterisk path = "file://" + path if Adhearsion.config.punchblock.platform == :xmpp path end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def platform_specific_path(path)\n if RUBY_PLATFORM =~ /mswin|mingw|windows/\n system_drive = ENV['SYSTEMDRIVE'] ? ENV['SYSTEMDRIVE'] : \"\"\n path = win_slashify File.join(system_drive, path.split('/')[2..-1])\n end\n\n path\n end", "def normalized_path(file); end", "def windows_path(path)\n path.gsub(/\\//, '\\\\')\n end", "def win_friendly_path(path)\n path.gsub(::File::SEPARATOR, ::File::ALT_SEPARATOR || '\\\\') if path\n end", "def canonical_path(path)\n if Gem.win_platform?\n raise PDK::CLI::FatalError, format(\"Cannot resolve a full path to '%{path}', as it does not currently exist.\", path: path) unless PDK::Util::Filesystem.exist?(path)\n\n PDK::Util::Windows::File.get_long_pathname(path)\n else\n PDK::Util::Filesystem.expand_path(path)\n end\n end", "def win_friendly_path(path)\n path&.gsub(::File::SEPARATOR, ::File::ALT_SEPARATOR || '\\\\')\n end", "def win_friendly_path(path)\n path&.gsub(::File::SEPARATOR, ::File::ALT_SEPARATOR || '\\\\')\n end", "def canonical_path(path)\n if Gem.win_platform?\n unless File.exist?(path)\n raise PDK::CLI::FatalError, _(\"Cannot resolve a full path to '%{path}' as it does not currently exist\") % { path: path }\n end\n Puppet::Util::Windows::File.get_long_pathname(path)\n else\n File.expand_path(path)\n end\n end", "def uniPath(source)\n source.gsub(/\\\\/, File::SEPARATOR)\nend", "def posixify path\n if path\n @file_separator == BACKSLASH && (path.include? BACKSLASH) ? (path.tr BACKSLASH, SLASH) : path\n else\n ''\n end\n end", "def to_windows_path(path)\n path.gsub('/', \"\\\\\")\n end", "def win_friendly_path(path)\n path.gsub(::File::SEPARATOR, '\\\\\\\\\\\\\\\\') if path\n path.gsub(::File::ALT_SEPARATOR, '\\\\\\\\\\\\\\\\') if path\n # NOTE: regex(\"\\\\\\\\\") is intepreted as regex(\"\\\\\" [escaped backslash] followed by \"\\\\\" [escaped backslash])\n # is intepreted as regex(\\\\)\n # is interpreted as a regex that matches a single literal backslash. --- Ruifeng Ma, May-18-2016\n end", "def win_friendly_path(path)\n if path\n new_path = path.gsub('/', '\\\\')\n new_path = \"c:#{new_path}\" if new_path =~ /^\\\\/\n end\n new_path\n end", "def windows_safe_path!(path)\n path.gsub!(File::SEPARATOR, File::ALT_SEPARATOR) if File::ALT_SEPARATOR\n end", "def proper_file_uri(file)\n p(\"-- setting up proper file uri for file: [ #{file} ]\")\n case RUBY_PLATFORM\n when /cygwin/, /mswin32/, /i386-mingw32/\n new_path = file.gsub(/C:/,'')\n p(\"-- new_path (windows only) = #{new_path}\")\n return \"file://\" + new_path\n else\n return \"file://\" + file\n end\n end", "def clean_path(path)\n\t\t\tif @posix_support\n\t\t\t\treturn path\n\t\t\telse\n\t\t\t\treturn path.gsub(/\\//,'\\\\')\n\t\t\tend\n\t\tend", "def canonicalize\n FilePath.new(File.expand_path(to_s))\n end", "def win_slashify(path)\n path.gsub(File::SEPARATOR, (File::ALT_SEPARATOR || '\\\\'))\n end", "def GetWindowsPath(path)\n return path.gsub(\"/\", \"\\\\\")\n end", "def windows_safe_path(*pieces)\n path = File.join(*pieces)\n\n if File::ALT_SEPARATOR\n path.gsub(File::SEPARATOR, File::ALT_SEPARATOR)\n else\n path\n end\n end", "def win_friendly_path(path)\n path.gsub(::File::SEPARATOR, '\\\\\\\\\\\\\\\\') if path\n # NOTE: regex(\"\\\\\\\\\") is intepreted as regex(\"\\\\\" [escaped backslash] followed by \"\\\\\" [escaped backslash])\n # is intepreted as regex(\\\\)\n # is interpreted as a regex that matches a single literal backslash. --- Ruifeng Ma, May-18-2016\nend", "def sanitize_file_path(entry)\n parts = entry.name.split(File::SEPARATOR)\n parts.shift\n parts.join(File::SEPARATOR)\n end", "def unify_path(s)\r\n p = s.frozen? ? s.dup : s\r\n p.gsub!( /\\\\/, '/' )\r\n p = \"#{$1.upcase}/#{$POSTMATCH}\" if p =~ REGEX_DISK\r\n if RUBY_PLATFORM =~ REGEX_CYGWIN\r\n\tif p =~ REGEX_CYGDRIVE\r\n\t p = \"/cygdrive/#{$1.upcase}/#{$POSTMATCH}\" \r\n\telse\r\n\t p.sub!( REGEX_DISK2, '/cygdrive/\\1/' ) if @name == 'PATH'\r\n\tend\r\n end\r\n return p\r\n end", "def FormatPath(path)\n if(!path || path == \"\" || path == \".\")\n return nil\n end\n #puts \"Formatting path #{path}\"\n return path.gsub(/\\\\/, \"/\") # replace accidential double backslashes\n .gsub(/\\/\\//, \"/\") # replace accidential double slashes\n .gsub(/\\/\\.\\//, \"/\") # replace local folder overhead, e.g. my/path/./to/my/file\n .gsub(/^\\.\\//, \"\"); # replace local folder at start of path\n end", "def normalize_path(path); end", "def normalize_path(path); end", "def unescape_path(path); end", "def path_to_safe_filename(path)\n path = '/' if path == ''\n normalize_path(path).gsub('/', '?').gsub(/[ :]/, '_')\n end", "def pathname(path)\n path = path.tr(\"/\", \"\\\\\") if windows?\n Pathname.new(path)\n end", "def remove_extra_slashes\n self.home = StringConstructor.sanitized_filepath self.home\n end", "def normalize_path(p) # NOTE BOOTSTRAP: was action::base::escape_windows_path\n p.tr(\"\\\\\", \"/\")\n end", "def preprocess_path(path, internal_pwd)\n path = '' unless path\n path.strip!\n\n path = unless File.exists? path\n begin\n instance_eval(path)\n rescue NameError, SyntaxError\n end\n end || path\n\n File.expand_path(path)\n end", "def escape_path(path)\n\t\t# EXPERIMENTAL Help me to test this on windows\n\t\tif RUBY_PLATFORM =~ /(win|w)32$/\n\t\t\treturn path.gsub(\"\\\\\", \"!\")\n\t\telse\n\t\t\treturn path.gsub(\"/\", \"!\")\n\t\tend\n\tend", "def file_uri_from_path(path)\n path = path.to_s if path.is_a?(Pathname)\n path = path.tr('\\\\', '/') if windows?\n path = URI::DEFAULT_PARSER.escape(path)\n return path.start_with?('/') ? \"file://\" + path : path unless windows?\n return \"file:///\" + path.tr(\"\\\\\", \"/\") if path =~ %r{^[a-zA-Z]:[/\\\\]}\n return \"file:\" + path.tr(\"\\\\\", \"/\") if path =~ %r{\\\\\\\\[^\\\\]+\\\\[^\\\\/]+}\n path.tr(\"\\\\\", \"/\")\n end", "def fix_path(path)\n\t\t\tpath ||= \"\"\n\t\t\tpath = \"/#{path}\" unless path.start_with?(\"/\")\n\t\t\tpath = \"#{path}gitcommits.atom\" if path.end_with?(\"/\")\n\t\t\treturn path\n\t\tend", "def fix_path(path)\n path_parts = path.split('/')\n return path_parts.join(File::SEPARATOR)\n end", "def fix_path(path)\n path_parts = path.split('/')\n return path_parts.join(File::SEPARATOR)\n end", "def makeWindowsPathIntoMinGWPath(path)\n modifiedPath = path.gsub(/\\\\/, '/')\n modifiedPath.gsub(/^(\\w+):[\\\\\\/]/) { \"/#{$1.downcase}/\" }\nend", "def sanitizeFilePath(path)\n path = path.gsub(/[^-a-z A-Z0-9_.\\/]/, '_').split(\"/\").map { |part|\n part.sub(/^\\.+/, '_').sub(/\\.+$/, '_')\n }.join('/')\nend", "def normalize_path(path)\n normalized = Rex::Text.to_ascii(path).downcase\n normalized.gsub!(/[\\x00]*/, '') #delete padding\n normalized.gsub!(/\\\\x([0-9a-f]{2})/i, '') # delete hex chars\n\n normalized\n end", "def join_path(*path)\n windows? ? win_friendly_path(::File.join(path)) : ::File.join(path)\n end", "def remap_filepath(path) \n parent_dir, path_basename = path.split('/')[-2..-1]\n\n # Handle file paths at 0 level of depth 'style.css'\n path_basename = path if path_basename.nil?\n \n parent_dir = get_confManager().target_dir if parent_dir.gsub(/\\/$/,'') == get_confManager().source_dir.gsub(/\\/$/,'') \n \n\n\n is_absolute = URI.parse(path).absolute? \n unless is_absolute\n \n find_file_in_targetdir([parent_dir, path_basename].join('/'))\n else \n path\n end\n end", "def ruby_path_escape( path )\n if (@os == :mac)\n '\"' + path + '\"'\n else\n # Adapt to other OSs if necessary\n '\"' + path + '\"'\n end\n end", "def pretty_path(path, native_fs_flag = false)\n return native_fs_flag ? path.gsub(\"/\", \"\\\\\") : path.gsub(\"\\\\\", \"/\")\n end", "def filepath_to_id\n @filepath = @filepath[@filepath.index(FILE_REGEX[:dir])..-1]\n FILE_REGEX.each do |attr,regex|\n if match = @filepath.scan(regex).try(:flatten).try(:compact)\n if attr == :ext\n @format = match.shift\n @handler = match.join(\".\")\n else\n self.instance_variable_set \"@#{attr}\", match=match[0]\n unless match.nil?\n attr == :locale ? @filepath.gsub!(/\\.#{match}/,\"\") : @filepath.gsub!(/\\/#{match}/,\"\")\n end\n end\n end\n end\n end", "def fix_drive_letter(path); end", "def sanitized_path(base_directory, questionable_path); end", "def sanitized_path(base_directory, questionable_path); end", "def sanitized_path(base_directory, questionable_path); end", "def sanitized_path(base_directory, questionable_path); end", "def sanitized_path(base_directory, questionable_path); end", "def sanitized_path(base_directory, questionable_path); end", "def makeWindowsPathIntoMinGWPath(path)\n modified_path = path.tr('\\\\', '/')\n modified_path.gsub(%r{^(\\w+):[\\\\/]}) { \"/#{Regexp.last_match(1).downcase}/\" }\nend", "def adjust_rsync_path(path)\n path.gsub(/^(\\w):/) { \"/cygdrive/#{$1}\" }\n end", "def psub(path)\n if include_win?\n path.gsub(\"/\", \"\\\\\")\n else\n path.gsub(\"\\\\\", \"/\")\n end\nend", "def read_platform_from_file(path:)\n path.basename.to_s.split('.').first\n end", "def convert_path(path)\n return path\n end", "def canonical_file_path(file_path)\n # This could be a little dangerous. The paths that come from the editor are URIs, and may or may not always\n # represent their actual filename on disk e.g. case-insensitive file systems. So a quick and dirty way to\n # reconcile this is just to always use lowercase file paths. While this works ok on Windows (NTFS or FAT)\n # other operating systems, could, in theory have two manifests being debugged that only differ by case. This\n # is not recommend as it breaks cross platform editing, but it's still possible\n file_path.downcase\n end", "def stdlib_path?(file); end", "def fix_path!\n @path = path.sub(/^\\~\\//, \"#{ENV['HOME']}/\")\n end", "def escape_path(path)\n # Strip anchors incase input is in a url form (as per guide)\n path = strip_anchors(path)\n filename = File.basename(path)\n folder = File.dirname(path)\n # avoid turning style.css into ./style.css\n if folder == \".\"\n URI.escape(unescape_path(filename))\n else\n File.join folder, URI.escape(unescape_path(filename))\n end\n end", "def path\n return @path.sub(/^\\//,'').sub(/^%2F/,'/')\n end", "def windows_safe_path_join(*args)\n ::File.join(args).gsub(::File::SEPARATOR, ::File::ALT_SEPARATOR || File::SEPARATOR)\nend", "def jar_path(p)\n path = p.sub(/^file:/, \"\").sub(/!.*/, \"\")\n path = path.sub(/^\\//, \"\") if win_platform? && path =~ /^\\/[A-Za-z]:/\n path\n end", "def path\n if location =~ /^\\/dev/\n \"dev:#{location}\"\n elsif location =~ /iso$/\n \"iso:#{location}\"\n elsif location.is_a?(Integer)\n \"disc:#{location}\"\n elsif location =~ /^disc/\n location\n else\n raise RuntimeError\n end\n end", "def path\n if location =~ /^\\/dev/\n \"dev:#{location}\"\n elsif location =~ /iso$/\n \"iso:#{location}\"\n elsif location.is_a?(Integer)\n \"disc:#{location}\"\n elsif location =~ /^disc/\n location\n else\n raise RuntimeError\n end\n end", "def rsync_path_escape( path )\n if (@os == :mac)\n # '\"' + path + '\"'\n path\n else\n # Adapt to other OSs if necessary\n # '\"' + path + '\"'\n path\n end\n end", "def getRealPath(path) Pathname.new(path).realpath.to_s; end", "def getRealPath(path) Pathname.new(path).realpath.to_s; end", "def to_rubyPath\r\n gsub(File::ALT_SEPARATOR || File::SEPARATOR, File::SEPARATOR)\r\n end", "def file_to_path(file)\n file = File.expand_path(file, @app.root)\n \n prefix = @app.source_dir.sub(/\\/$/, \"\") + \"/\"\n return false unless file.include?(prefix)\n \n path = file.sub(prefix, \"\")\n extensionless_path(path)\n end", "def windows_path(path)\n path = path.to_path if path.respond_to? :to_path\n fs_object.GetAbsolutePathName(path.to_str)\n end", "def toUnix(path)\n PathWrapper.new(path)\n end", "def path(style_name = default_style)\n path = original_filename.nil? ? nil : interpolate(path_option, style_name)\n path.respond_to?(:unescape) ? path.unescape : path\n end", "def format_path(entry)\n server_path = entry.path\n if base_path && server_path[0,base_path.length] == base_path\n if server_path == base_path\n return \".\"\n elsif server_path[base_path.length,1] == \"/\"\n return server_path[base_path.length + 1, server_path.length - base_path.length - 1]\n elsif base_path == \"/\" && server_path[0,1] == \"/\"\n return server_path[1, server_path.length - 1]\n end\n end\n server_path\n end", "def file_path\n dir_name + file_name\n end", "def mangle(path)\n path.gsub(%r{^file://}, '')\n end", "def normalize_path(path)\n path.sub(/^\\//, \"\").gsub(\"%20\", \" \")\n end", "def normalize_path(path)\n path.sub(%r{^/}, '').tr('', '')\n end", "def safe_filepath\n filename.gsub!(/[\\?<>\\\\:\\*\\|\":]/, '_')\n full_path = File.join(root_path, filename)\n if(File.exists? full_path) && file_inside_root?(full_path)\n return full_path\n else\n raise 'Disallowed file requested'\n end\n end", "def localize_path(path)\n cpath_size = @component_path.size\n return @component_name + path[cpath_size..-1]\n end", "def user_file_path(file)\n path = \"#{Settings.source_dir}/#{file}\"\n ext = \".#{Settings.partials_extension}\"\n return path if path.end_with? ext\n\n \"#{path}#{ext}\"\n end", "def normalize_path(path)\n return '' if path.eql? '<>'\n path =~ PATH\n $~[1].to_s.downcase + normalize_local_part($~[9]) + \"@\" + $~[12].downcase\n end", "def format_from_path\n\n return \"\" if path_info.nil? or path_info !~ /[.]/\n \n format = path_info.split(\".\").last\n \n if format =~ /[\\w+\\/]/\n format = format.split(\"/\")[0]\n end\n \n format\n end", "def path\n \"%s/%s\" % [dirname, filename]\n end", "def make_fat32_compliant(filepath)\n extname = File.extname(filepath)\n basename = File.basename(filepath, extname)\n dirname = File.dirname(filepath)\n path_without_ext = File.join(dirname, basename)\n\n split = path_without_ext.split(\"/\")\n new_split = []\n split.map do |part|\n new_split << part.gsub(/([\\?\\*\\|:;\"“”<>])/, \"\").strip.gsub(/ {2,}/,\" \").gsub('’', \"'\")\n end\n return new_split.join(\"/\")+extname\n end", "def normalize(path)\n path.gsub(/\\\\/, \"/\")\n end", "def join_path(*path)\n win_friendly_path(::File.join(path))\n end", "def join_path(*path)\n win_friendly_path(::File.join(path))\n end", "def real_path(aPath)\n\t\t\t\t(path = Pathname.new(::File.expand_path(aPath))) && path.realpath.to_s\n\t\t\tend", "def partialize_path(path)\n if path.basename.to_s !~ /\\A_/\n Pathname.new path.to_s.sub(/([^\\/]+)\\Z/, '_\\1')\n end\n end", "def partialize_path(path)\n if path.basename.to_s !~ /\\A_/\n Pathname.new path.to_s.sub(/([^\\/]+)\\Z/, '_\\1')\n end\n end", "def ensure_leading_slash(path); end", "def cleanup_pathname(path)\n return CGI.unescape(path).gsub(@music_root, '').gsub(%r{file:/+}, '').gsub(%r{^/+}, '')\n end", "def user_path?(file); end", "def file_path; end", "def file_with_source_path(source_path)\n source_path = source_path.unicode_normalize\n @source_path_to_file[source_path] || @abs_source_path_to_file[source_path]\n end", "def file_path path\n File.join(output_path, manifest.lookup(path).split('/')[2..-1])\n end", "def dos_path(source_path, drive_letter = \"C\")\n path = \"\"\n return source_path if source_path.include?(\":\\\\\")\n path_array = source_path.split(\"/\")\n if path_array[1].length == 1 # drive letter\n path = \"#{path_array[1]}:\\\\\"\n path += path_array[2..-1].join(\"\\\\\")\n else\n path = \"#{drive_letter}:\\\\\"\n path += path_array[1..-1].join(\"\\\\\")\n end\n path\n end", "def filename\n path.split(File::Separator).join(\"_\")\n end", "def full_path(path)\n if path.nil?\n '<unknown>'\n else\n begin\n File.expand_path(path)\n rescue\n '<unknown>'\n end\n end\n end" ]
[ "0.7331798", "0.72073436", "0.6935914", "0.6927264", "0.691679", "0.6883882", "0.6883882", "0.68559873", "0.677458", "0.67641944", "0.67495286", "0.661395", "0.65997154", "0.6599325", "0.6585143", "0.65736735", "0.65606916", "0.65409684", "0.6539794", "0.651637", "0.6430668", "0.63883036", "0.63875324", "0.63714266", "0.6359771", "0.6359771", "0.6320567", "0.63205236", "0.6291522", "0.6275858", "0.6272706", "0.6255981", "0.6246697", "0.6236259", "0.62255573", "0.6224581", "0.6224581", "0.62223047", "0.622113", "0.6204735", "0.61921495", "0.61648923", "0.61625385", "0.61413366", "0.6133795", "0.60862195", "0.607809", "0.607809", "0.607809", "0.607809", "0.607809", "0.607809", "0.60717154", "0.6065927", "0.606244", "0.60597545", "0.60336876", "0.6032997", "0.60091007", "0.60053676", "0.59825325", "0.5949177", "0.5946738", "0.5940326", "0.59395593", "0.59395593", "0.59310293", "0.59208316", "0.59208316", "0.59144783", "0.59050286", "0.5861484", "0.5859641", "0.5848032", "0.5847595", "0.5845137", "0.5844843", "0.58318025", "0.5824197", "0.5822115", "0.5821608", "0.5812301", "0.5811857", "0.58074844", "0.5804947", "0.5801043", "0.5797903", "0.57972354", "0.57972354", "0.5785798", "0.5779227", "0.5779227", "0.57788616", "0.5772758", "0.57581687", "0.575303", "0.5742036", "0.573904", "0.5733173", "0.5729724", "0.572631" ]
0.0
-1
By default, you don't need this. Use it only if you have runtime initialization for your backend.
def initialize( options = {} ) super end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def backend; end", "def backends; end", "def initialize\n super(true)\n end", "def backend=(backend); end", "def at_init\n\n\t\tend", "def init\n\n end", "def init\n end", "def init\n end", "def init\n end", "def configured?; false; end", "def post_init\n end", "def auto_initialize!\n # noop by default\n end", "def user_init; end", "def init; end", "def init; end", "def init; end", "def init; end", "def post_init\n end", "def standalone; end", "def backends=(_arg0); end", "def initialize\n super()\n end", "def initialize\n super()\n end", "def initialize\n super()\n end", "def initialize\n super()\n end", "def initialize\n super()\n end", "def initialize\n super()\n end", "def initialize\n super()\n end", "def initialize\n initialize!\n end", "def initialize\n initialize!\n end", "def backend_klass; end", "def post_init\n\tend", "def backend\n @backend ||= self.class.backend\n end", "def global\n raise NotImplementedError\n end", "def initialized?; end", "def initialized?; end", "def initialized?; end", "def initialized?; end", "def initialize()\n\t\tend", "def initialize\n\t \t# loading or not loading should be the key here.\n end", "def initialize\n # nothing here for now\n end", "def set_backend(val)\n end", "def initialize\n init\n end", "def post_initialize\n # raise NotImplementedError\n end", "def initialize\n super\n end", "def initialize\n super\n end", "def initialize\n super\n end", "def stand_alone?; end", "def stand_alone?; end", "def init\n raise NotImplementedError\n end", "def initialize\n super()\n end", "def pre_initialize; end", "def initialize()\n end", "def configure\n # do nothing\n end", "def init; end", "def initialize\n set_config\n end", "def on_init; end", "def on_init; end", "def init_ext()\n \n end", "def initialize\n super\n self.scripts = []\n self.template_paths = []\n self.libraries = {}\n self.options = SymbolHash.new(false).update(\n :single_library => true,\n :caching => false\n )\n self.server_options = {:Port => 8808}\n end", "def configure; end", "def internal; end", "def initialize()\n\tend", "def initialize()\n\tend", "def before_setup; end", "def backend\n @backend ||= Configurator.new(self, :backend)\n end", "def initialize()\n end", "def initialize()\n end", "def initialize()\n end", "def initialize()\n end", "def initialize()\n end", "def initialize()\n end", "def initialize()\n end", "def initialize()\n end", "def post_configure\n # noop\n end", "def global?; true end", "def hashback_backend\n self.class.__send__(:class_variable_get, :@@_backend) \n end", "def initialize\n\n end", "def initialize\n\n end", "def init\n self\n end", "def used?; end", "def initialize\n\n\tend", "def initialize\n\n\tend", "def internal?; end", "def initialize()\r\n\r\n end", "def initialize\n super\n end", "def initialize\n super\n end", "def initialize\n super\n end", "def initialize\n @application = \"precidix\"\n super\n end", "def post_setup\n end", "def adapter_initialize\n end", "def after_initialize\n # noop\n end", "def initialize\n\tinit\n\tsuper\nend", "def initialize()\n\n end", "def setup\n # noop\n end", "def private; end", "def initialize(backend=nil)\n @backend = backend || Soup::Backends::FileBackend.new\n check_backend_for_compatibility\n @backend.prepare\n end", "def before_setup\n # do nothing by default\n end", "def initialize()\n end", "def initialize()\n end", "def initialize() end", "def configuration; end" ]
[ "0.6971646", "0.6675645", "0.64763564", "0.64736176", "0.64511555", "0.6395973", "0.63322014", "0.63322014", "0.63322014", "0.6324129", "0.6271202", "0.6258255", "0.6210659", "0.6200997", "0.6200997", "0.6200997", "0.6200997", "0.61937296", "0.6186925", "0.6179913", "0.61729753", "0.61729753", "0.61729753", "0.61729753", "0.61729753", "0.61729753", "0.61729753", "0.61682385", "0.61682385", "0.6141902", "0.61147624", "0.6110413", "0.6081888", "0.6079215", "0.6079215", "0.6079215", "0.6079215", "0.60789585", "0.60774255", "0.6071504", "0.60708696", "0.60576826", "0.6051293", "0.60357684", "0.60357684", "0.60357684", "0.60267496", "0.60267496", "0.6008576", "0.60067266", "0.6006396", "0.5996167", "0.59883744", "0.598446", "0.5982377", "0.5978485", "0.5978485", "0.5976098", "0.59656113", "0.596295", "0.59345835", "0.592266", "0.592266", "0.59156597", "0.59143376", "0.5900767", "0.5900767", "0.5900767", "0.5900767", "0.5900767", "0.5900767", "0.5900767", "0.5900767", "0.5889748", "0.5886942", "0.5876866", "0.58702695", "0.58702695", "0.58663756", "0.586308", "0.58571136", "0.58571136", "0.58557117", "0.5851338", "0.5849109", "0.5849109", "0.5849109", "0.58435726", "0.5841757", "0.5841309", "0.58342606", "0.5833735", "0.58318406", "0.58287853", "0.58271325", "0.58252215", "0.5823595", "0.5820539", "0.5820539", "0.58199036", "0.5807716" ]
0.0
-1
Accepts the standard Resumator hash and outputs as plain text
def process( resume, options = {} ) text = "" text += process_personal( resume["personal"] ) text += process_experience( resume["experience"] ) text += process_skills( resume["skills"] ) text += process_education( resume["education"] ) text += process_hobbies( resume["hobbies"] ) text += process_footer( resume["footer"] ) return text end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def rehash\n raw \"REHASH\\r\\n\"\n end", "def get_hash(input)\n return $hasher.reset.update(input).to_s\nend", "def block_hash\n\t\tdigest = Digest::SHA2.new\n\n\t\tdigest << '%d' % [ self.index ]\n\t\tdigest << self.timestamp.strftime( '%s%N' )\n\t\tdigest << self.payload\n\t\tdigest << self.payload_hash\n\t\tdigest << self.proof.to_s\n\t\tdigest << self.previous_hash\n\t\t\n\t\treturn digest.hexdigest\n\tend", "def sha\n result_hash['sha']\n end", "def digest\n ''\n end", "def digest\n ''\n end", "def hash\n Digest::SHA256.hexdigest( \"#{nonce}#{time}#{difficulty}#{prev}#{data}\" )\n end", "def hash\n shasum.hash\n end", "def hash\n shasum.hash\n end", "def hash\n shasum.hash\n end", "def hash(tx)\n Digest::SHA256.hexdigest(Digest::SHA256.hexdigest(tx))\nend", "def hash_passwd(pw)\n return pw if pw.match?(/^\\$\\d*\\$/)\n hash = shell_out(\"#{splunk_cmd} hash-passwd #{pw}\")\n hash.stdout.strip\nend", "def rehash\n send_data(\"REHASH\")\n end", "def hash(block)\n Digest::SHA256.hexdigest(block.to_s.encode)\n end", "def computed_sha(string)\n provider.computed_sha(string)\n end", "def default_hash_function(plain_token)\n ::Digest::SHA256.hexdigest plain_token\n end", "def sha1; end", "def sha1; end", "def evalsha(*args); end", "def evalsha(*args); end", "def hash() end", "def hash() end", "def hash() end", "def hash() end", "def hash() end", "def hash() end", "def hash() end", "def sha256; end", "def show_hash\n hash = Push::Rhn.make_hash_for_push(@errata, current_user.login_name)\n respond_to do |format|\n format.json do\n render :layout => false,\n :json => hash.to_json\n end\n format.text do\n render :text => hash_to_string(hash)\n end\n format.html do\n @text = hash_to_string(hash)\n render :layout => false\n end\n end\n end", "def hexhash\n hash.to_s(16)\n end", "def generate_hash(id, raffle_number)\n Digest::SHA256.base64digest(id+ raffle_number)\nend", "def hash_passphrase_text passphrase\n passphrase_text_hash = Digest::SHA256.base64digest passphrase\n end", "def hash_from_payload(payload)\n Digest::SHA256.digest(Digest::SHA256.digest( payload )).reverse.unpack(\"H*\")[0]\n end", "def call( *args )\n text = args.shift.to_s\n bitlength = (args.shift || 256).to_i\n Digest::SHA2.new( bitlength ).hexdigest( text )\n end", "def hexdigest!()\n #This is a stub, used for indexing\n end", "def hash\n Digest::SHA2.hexdigest(self.id.to_s + self.password_hash.to_s + self.email.to_s).slice(0,10)\n end", "def sha_to_b62 sha\n sint = sha.to_i(16)\n res = \"\"\n digits = (\"0\"..\"9\").to_a + (\"a\"..\"z\").to_a + (\"A\"..\"Z\").to_a\n while sint > 0\n rest,units = sint.divmod(62)\n res = digits[units] + res\n sint = rest\n end\n return res\nend", "def to_str\n digest.to_str\n end", "def verification_code\n raise ArgumentError, 'Hash is not set' if @hash.nil?\n\n binary = @hash.unpack1('B*').split //\n [*binary.first(6), *binary.last(7)].join.to_i(2)\n end", "def digest(data); end", "def to_sha(hash)\n # converts a hash to a SHA256\n return Digest::SHA256.hexdigest(JSON.dump(hash))\nend", "def compute_checksum(h)\n begin\n signed_h = h.dup.with_indifferent_access\n CLEAR_OPTIONS.map{|o| signed_h.delete(o) }\n marshaled = ActionController::Routing::Route.new.build_query_string(signed_h)\n marshaled = marshaled.gsub(/^\\?/, '').split(/&/).sort.join('&')\n digest.call(self, Base64.encode64(marshaled.to_s.reverse)).to_s\n ensure\n end\n end", "def calc_digest input\n Digest::SHA1.hexdigest(input.to_s).\n\n # XXX: surround all digits with alphabets so\n # Maruku doesn't change them into HTML\n gsub(/\\d/, 'z\\&z')\n end", "def fedora_shasum\n \"urn:sha1:#{Digest::SHA1.file(file_path)}\"\n end", "def dave(new_str)\r\n new_hash = Digest::SHA256.hexdigest new_str\r\n return new_hash\r\nend", "def to_s\n digest.to_s\n end", "def hashed_rooster\r\nend", "def to_s\n \"#{user}:#{digest}\"\n end", "def sha\n id.sha\n end", "def unhash(h)\n begin\n h = Integer(h)\n rescue ArgumentError\n return ArgumentError.new(\"Invalid input argument\")\n end\n return nil if h == 7\n return \"Invalid hash\" if h > 7 && h < 259\n string = []\n letters = \"acdegilmnoprstuw\"\n while h >= 259\n quotient, modulus = h.divmod(37)\n string.unshift(letters[modulus])\n h = quotient\n end\n return string.join\nend", "def md5 hash\n\t\treturn Digest::MD5.hexdigest(hash.to_s).to_s\n\tend", "def hash\n guid.hash\n end", "def hash(message)\n return Digest::SHA1.hexdigest(message)\n end", "def evalsha(*arguments)\n\t\t\t\t\tcall(\"EVALSHA\", *arguments)\n\t\t\t\tend", "def proof_of_work(client)\n value = SecureRandom.hex(16)\n work = Digest::SHA2.hexdigest value\n client.puts \"Please provide proof of work for: SHA2(????#{value[4..-1]}) == #{work}\"\n client.print '? '\n pow = Digest::SHA2.hexdigest client.gets.chomp\n return true if pow == work\n\n # Show source as implementation reference if PoW fails\n client.puts File.read __FILE__\n client&.close\nend", "def hexdigest\n DigestUtils.pack_hexdigest(digest)\n end", "def hashed_input\n\t\tmd5_hex = Digest::MD5.hexdigest(@term)\n\t\tmd5_hex.scan(/../).map { |s| s.to_i(16) }\n\tend", "def evalsha(*args)\n _eval(:evalsha, args)\n end", "def merchanthash\n if version.to_i == 1 \n return HashGenerator::generate(merchant_hash_key, merchant_id, order_id);\n else\n return Digest::SHA512.hexdigest(\"#{merchant_hash_key},#{merchant_id},01,#{order_id},#{gross_amount}\")\n end\n end", "def create_reset_digest\n new_token = SecureRandom.urlsafe_base64\n update_attributes(reset_digest: User.hash_token(new_token), reset_sent_at: Time.zone.now)\n new_token\n end", "def deploy_checksum(deploy)\n bin = Base64.decode64(deploy['content'].first['hash']['BYTES_VALUE'])\n bin.each_byte.map { |b| b.to_s(16) }.join\n end", "def sha1=(_); end", "def checksum\n source[digest_type]\n end", "def hash\n bytes.hash\n end", "def to_sha256\n Tapyrus.sha256(to_payload).bth\n end", "def hexdigest\n @digest.unpack('H*'.freeze).first\n end", "def digest\n Digest::SHA1.hexdigest(self)\n end", "def checksum!\n # Get a deep copy of hash to compare with\n @_original_hash = Marshal.load(Marshal.dump(to_hash))\n # create a copy of basic elements\n base = self.reject { |k,_| ['_id', '_rev', 'couchrest-hash'].include? k.to_s }\n\n result = nil\n\n flatten =\n lambda {|r|\n (recurse = lambda {|v|\n if v.is_a?(Hash) || v.is_a?(CouchRest::Document)\n v.to_a.map{|v| recurse.call(v)}.flatten\n elsif v.is_a?(Array)\n v.flatten.map{|v| recurse.call(v)}\n else\n v.to_s\n end\n }).call(r)\n }\n self['couchrest-hash'] = Digest::MD5.hexdigest(flatten.call(base).sort.join(''))\n end", "def sha_hash (arg)\r\n Digest::SHA2.hexdigest(arg)\r\n end", "def hash(block, stored_hash, hash_calc, block_check, line)\r\n return 'Block empty' if block.nil?\r\n\r\n # calculate hash value for line\r\n error = \"Line #{line}: Invalid hash set to #{stored_hash.strip}\"\r\n\r\n # if hash stored as with capital letters, return error\r\n stored_hash = stored_hash.strip # get rid of trailing white space\r\n int_hash = stored_hash.to_i(16) # get stored hash and convert to decimal\r\n # check lenght of stored hash(max4)...may be optiaml to place elsewhere\r\n return error + \"\\nHash length is too big\" if stored_hash.size >= 5\r\n\r\n # check hash for leading 0's\r\n return error + \"\\nHash contains leading zeros\" if stored_hash[0] == '0' && stored_hash.size > 1\r\n\r\n # check to make sure value is valid hex values\r\n return error + \"\\nInvalid hex value, must be lowercase and from 0-f\" unless block_check.check_hex(stored_hash)\r\n\r\n # see if calculated hash and stored has match\r\n hash = block_check.get_hash(block, hash_calc) # get hash value\r\n # removes last hash from string\r\n output_string = block_check.parse(block, '|' + stored_hash)\r\n error_two = \"Line #{line}: String '#{output_string[0]}' hash set to #{stored_hash.strip},\"\\\r\n \"should be #{hash.to_s(16)}\"\r\n return error_two unless block_check.check_hash(hash, int_hash)\r\n\r\n nil\r\n end", "def hash_generator(pass)\n require 'openssl'\n\n # Get hash parameters\n params = hash_decoder\n\n algo = params['algo']\n salt = params['salt']\n\n iter = if params['iter']\n params['iter'].to_i\n else\n 1\n end\n\n new_hash = (salt + pass).each_byte.to_a\n digest = OpenSSL::Digest.new(algo.delete('-'))\n\n 1.upto(iter) do\n digest.reset\n digest << new_hash.pack('c*')\n new_hash = digest.to_s.scan(/../).map(&:hex)\n end\n\n digest.to_s\n end", "def calculate_payload_hash\n\t\treturn Digest::SHA2.hexdigest( self.payload )\n\tend", "def sha commit_message\n cmd = \"git reflog --grep-reflog='commit\"\n cmd += ' (initial)' if commit_message == 'Initial commit'\n cmd += \": #{commit_message.strip}' --format='%H'\"\n result = ''\n %w[developer developer_secondary].each do |user|\n next unless result.empty?\n in_repository(user) { result = output_of cmd }\n end\n result\nend", "def checksum(hex)\n hash = hash256(hex) # Hash the data through SHA256 twice\n return hash[0...8] # Return the first 4 bytes (8 characters)\nend", "def hash\n digest = Digest::MD5.new\n digest << title.to_s\n digest << content.join('').to_s\n digest.to_s\n end", "def render_hash(hsh)\n str = \"\"\n indiff_hsh = hsh.with_indifferent_access\n indiff_hsh.keys.sort.each do |key|\n str << \"#{key}: \"\n value = indiff_hsh[key]\n PP::pp(value, str)\n end\n str\n end", "def shortsha(n = 7)\n @sha.slice(0,n)\n end", "def test_previous_hash_non_hex\r\n block_checker = Minitest::Mock.new('test_block_checker')\r\n def block_checker.check_hex(string); false; end\r\n output = \"Line 0: Previous hash was 112g, should be 2710\\nInvalid hex value, must be lowercase and from 0-f\"\r\n assert_equal output, @g.previous_hash( '112g', 10000, block_checker, 0)\r\n end", "def digest( str )\n Digest::SHA1.hexdigest( str )\n end", "def digest_hash_function\n decode[:hash_function]\n end", "def sha\n Digest::SHA2.new.update(self.source).to_s\n end", "def report_hashes(hash_loot,service)\n filename= \"#{rhost}-#{rport}_mysqlhashes.txt\"\n path = store_loot(\"mysql.hashes\", \"text/plain\", rhost, hash_loot, filename, \"MySQL Hashes\", service)\n print_good(\"#{rhost}:#{rport} Hash Table has been saved: #{path}\")\n\n end", "def hex_sha1(s)\n binb2hex(core_sha1(str2binb(s), s.length * $chrsz))\n end", "def hexlify\n offset = 0\n while (str = $stdin.read(16))\n out = \"#{'%08x' % offset} \"\n out << hex_digits(str)\n out << ' '\n out << ascii(str)\n puts out\n offset += 16\n end\nend", "def shasum\n @shasum ||= begin\n digest = Digest::SHA256.new\n\n update_with_string(digest, project.shasum)\n update_with_string(digest, builder.shasum)\n update_with_string(digest, name)\n update_with_string(digest, version_for_cache)\n update_with_string(digest, FFI_Yajl::Encoder.encode(overrides))\n\n if filepath && File.exist?(filepath)\n update_with_file_contents(digest, filepath)\n else\n update_with_string(digest, \"<DYNAMIC>\")\n end\n\n digest.hexdigest\n end\n end", "def hex() end", "def mining_hash\n Utils.keccak(rlp_encode skip_keys: [:mix_hash, :nonce])\n end", "def hash\n return Digest::MD5.hexdigest(self.describe(' '))\n end", "def rsh_ruby\n r = \"\"\n s = TCPSocket.new(@host, 514)\n s.write \"0\\0\"\n s.write \"#{@luser}\\0\"\n s.write \"#{@ruser}\\0\"\n s.write \"#{@command}\\0\"\n s.getc # cutting off the first byte, signalling?\n while line = s.gets\n if block_given?\n yield line\n else\n r << line\n end\n end\n s.close\n r == \"\" ? nil : r\n end", "def digest\n digest = ''\n @entries.each { |entry| digest << entry.digest << ' ' }\n digest\n end", "def hashed_content\n @hashed_content ||= valid? ? Digest::SHA1.hexdigest(content) : nil \n end", "def checksum\n Digest::SHA256.hexdigest(self.to_smash(:sorted).to_s)\n end", "def rubocop_checksum; end", "def sha256_fingerprint\n Base64.encode64(Digest::SHA256.digest(ssh_public_key_conversion)).gsub(\"\\n\", \"\")\n end", "def hard_hash(password)\n opslimit = 2**20\n memlimit = 2**24\n digest_size = 64\n\n salt = RbNaCl::Random.random_bytes(RbNaCl::PasswordHash::SCrypt::SALTBYTES)\n digest = RbNaCl::PasswordHash.scrypt(password, salt,\n opslimit, memlimit, digest_size)\n [Base64.strict_encode64(digest), Base64.strict_encode64(salt)].join(\"\\n\")\nend", "def hash_secure\n # TODO: Use sha256 from openssl to create a cryptographically secure hash.\n # Credit cards with identical information should produce the same hash.\n\n sha256 = OpenSSL::Digest::SHA256.new\n sha256.digest(self.to_s).unpack('h*')\nend", "def hash_password(password)\n puts \"Password: #{password}\"\n stdout, result = Open3.capture2('openssl', 'passwd', '-apr1', password)\n puts stdout\n puts result\n if result.success?\n return stdout\n else\n raise ShellError\n end\n end", "def hex_sha1(s)\n return binb2hex(core_sha1(str2binb(s), s.length * $chrsz))\n end", "def lm_hash(password)\n keys = gen_keys password.upcase.ljust(14, \"\\0\")\n apply_des(LM_MAGIC, keys).join\n end", "def checksum(hex)\n hash = hash256(hex) # Hash the data through SHA256 twice\n return hash[0...8] # Return the first 4 bytes (8 characters)\n end", "def digest\n Digest::MD5.hexdigest(id.to_s+Interactiff::Application.config.secret_token).to_i(16).to_s[3,8]\n end" ]
[ "0.6588555", "0.6174179", "0.6158154", "0.60514134", "0.59609103", "0.59609103", "0.59427434", "0.58217037", "0.58217037", "0.58217037", "0.58171684", "0.57874036", "0.57632124", "0.5688378", "0.5659628", "0.56579304", "0.5650635", "0.5650635", "0.55849665", "0.55849665", "0.55807316", "0.55807316", "0.55807316", "0.55807316", "0.55807316", "0.55807316", "0.55807316", "0.5567822", "0.5566139", "0.55585", "0.5533809", "0.55228454", "0.55207014", "0.55145794", "0.55124086", "0.5444885", "0.5441357", "0.5414188", "0.5395759", "0.53938943", "0.53929085", "0.53924036", "0.5389984", "0.5376307", "0.5369921", "0.5363527", "0.53599465", "0.5322532", "0.53036916", "0.5291624", "0.5290904", "0.528886", "0.5286488", "0.5283087", "0.5266741", "0.52618897", "0.52617913", "0.52529323", "0.5237877", "0.52375716", "0.52367914", "0.52334875", "0.52282506", "0.52271795", "0.5210499", "0.5209851", "0.5208236", "0.5198064", "0.5190408", "0.5184929", "0.5175275", "0.51736623", "0.517276", "0.51685584", "0.5167025", "0.51638234", "0.51632243", "0.51586133", "0.5156961", "0.51452327", "0.514384", "0.51323843", "0.5130779", "0.51265544", "0.5119193", "0.51166934", "0.5112392", "0.51089543", "0.510889", "0.5107078", "0.51026106", "0.5099834", "0.50966287", "0.5092449", "0.50919473", "0.50881606", "0.5084734", "0.50833315", "0.5083117", "0.5082361", "0.5081568" ]
0.0
-1
for distance_attempt logic, there are certain 'states' that a competitor can get into
def triple_fault? Rails.cache.fetch("#{distance_attempt_cache_key_base}/triple_fault") do df = false if distance_attempts.count > 2 if distance_attempts[0].fault? && distance_attempts[1].fault? && distance_attempts[2].fault? if distance_attempts[0].distance == distance_attempts[1].distance && distance_attempts[1].distance == distance_attempts[2].distance df = true end end end df end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def compute_state # {{{\n\n player_moves = []\n ki_moves = []\n\n player_moves = self.get_moves_as_hash true\n ki_moves = self.get_moves_as_hash false\n\n return WON if has_winning_combination player_moves\n return LOST if has_winning_combination ki_moves\n\n return DRAWN if player_moves.count + ki_moves.count == 3*3\n\n RUNNING\n end", "def times_walked_to(state); end", "def any_mines_detonated?(state = false)\n state\n end", "def known_states; end", "def known_states; end", "def known_states; end", "def generate_possible_moves(state)\n end", "def match_states(query); end", "def getFinalState()\r\n dealer_score = @dealer.hand.score\r\n case @dealer.state\r\n when \"bust\"\r\n #every player that didnt bust wins\r\n @players.each do |player|\r\n if(player.state != \"bust\")\r\n player.state = \"won\"\r\n else\r\n player.state = \"lose\"\r\n end\r\n end\r\n when \"fine\"\r\n #everyone with a lower score than the dealer loses, everyone with a higher score that didnt bust wins\r\n @players.each do |player|\r\n if(player.state == \"bust\")\r\n player.state = \"lose\"\r\n elsif(player.hand.score < dealer_score)\r\n player.state = \"lose\"\r\n elsif(player.hand.score > dealer_score)\r\n player.state = \"won\"\r\n else\r\n player.state = \"push\"\r\n end\r\n end\r\n when \"blackjack\"\r\n #everyone lower score loses, everyone equal score pushes\r\n @players.each do |player|\r\n if(player.hand.score == dealer_score)\r\n player.state = \"push\"\r\n else\r\n player.state = \"lose\"\r\n end\r\n end\r\n end\r\n end", "def moves\n state.moves_taken\n end", "def competitor_has_result?(competitor)\n competitor.distance_attempts.any?\n end", "def move(game_state)\n directions = [\"up\", \"down\", \"left\", \"right\"]\n\n move_groups = directions.group_by do |move|\n pos = game_state.me.move(move)\n\n case\n when !game_state.board.valid?(pos)\n :invalid\n when game_state.board.occupied?(pos)\n :occupied\n when game_state.board.hazard?(pos)\n :hazard\n when game_state.board.food?(pos)\n :food\n else\n :safe\n end\n end\n\n possible_moves = move_groups[:food] || move_groups[:safe] || move_groups[:hazard] || move_groups[:occupied] || [\"up\"]\n\n move = possible_moves.sample\n puts \"MOVE: \" + move\n { \"move\": move }\nend", "def parties(location, state)\n if location == :north\n soldiers_at(:north, state).map { |soldier| [soldier] } # one guy\n else\n soldiers_at(:south, state).combination(2).to_a # two guys\n end\nend", "def fix_state!(row)\n return unless row['STATE']\n possible_state = final_state = row['STATE'].strip.upcase\n map = {\n /ANDHRAPRADESH/ => 'ANDHRA PRADESH',\n /ANDAMAN/ => 'ANDAMAN AND NICOBAR ISLANDS',\n /BANGALORE/ => 'KARNATAKA',\n /BARDEZ/ => 'GOA',\n /BHUSAWAL/ => 'MAHARASHTRA',\n /BTM/ => 'KARNATAKA',\n /BULDHANA/ => 'MAHARASHTRA',\n /BUNDI/ => 'RAJASTHAN',\n /RAJAS/ => 'RAJASTHAN',\n /KARANATAKA/ => 'KARNATAKA',\n /CARMELARAM/ => 'KARNATAKA',\n # Chandigarh is not a state, but the branches there are ambigous b/w Haryana and Punjab\n # /CHANDIGARH/ => 'PUNJAB',\n /CHEMBUR/ => 'PUNJAB',\n /CHENNAI/ => 'TAMIL NADU',\n /CHHATIS/ => 'CHHATTISGARH',\n # Double H, Single T\n /CHHATISHGARH/ => 'CHHATTISGARH',\n # Single H, Double T\n /CHATTISGARH/ => 'CHHATTISGARH',\n /DADRA/ => 'DADRA AND NAGAR HAVELI AND DAMAN AND DIU',\n /DAHEGAM/ => 'GUJARAT',\n /DAHEJ/ => 'GUJARAT',\n /DELHI/ => 'DELHI',\n /DINDORI/ => 'MADHYA PRADESH',\n /MADHYAPRADESH/ => 'MADHYA PRADESH',\n # Do not use DAMAN as that clashes with ANDAMAN\n /DIU/ => 'DADRA AND NAGAR HAVELI AND DAMAN AND DIU',\n # Do an exact match for Daman instead\n 'DAMAN' => 'DADRA AND NAGAR HAVELI AND DAMAN AND DIU',\n /GOA/ => 'GOA',\n /HIMANCHAL/ => 'HIMACHAL PRADESH',\n /HIMACHAL/ => 'HIMACHAL PRADESH',\n /HYDERABAD/ => 'ANDHRA PRADESH',\n /IDAR/ => 'ANDHRA PRADESH',\n /INDORE/ => 'MADHYA PRADESH',\n /JAMMU/ => 'JAMMU AND KASHMIR',\n /MADURAI/ => 'TAMIL NADU',\n /MALEGAON/ => 'MAHARASHTRA',\n /MUMBAI/ => 'MAHARASHTRA',\n /NASHIK/ => 'MAHARASHTRA',\n /NASIK/ => 'MAHARASHTRA',\n /PONDICHERRY/ => 'PUDUCHERRY',\n /SAMBRA/ => 'KARNATAKA',\n /SANTACRUZ/ => 'MAHARASHTRA',\n /TAMIL/ => 'TAMIL NADU',\n /UTTARA/ => 'UTTARAKHAND',\n /UTTARPRADESH/ => 'UTTAR PRADESH',\n /UTTRAKHAND/ => 'UTTARAKHAND',\n /WEST/ => 'WEST BENGAL',\n /CHURU/ => 'RAJASTHAN',\n /AHMEDABAD/ => 'GUJARAT',\n /GUJRAT/ => 'GUJARAT',\n /HARKHAND/ => 'JHARKHAND',\n /JHAGRAKHAND/ => 'JHARKHAND',\n /ORISSA/ => 'ODISHA',\n /PUNE/ => 'MAHARASHTRA',\n /TELENGANA/ => 'TELANGANA',\n /PANJAB/ => 'PUNJAB',\n /MEGHALAY/ => 'MEGHALAYA',\n # Only if the branch is specifically marked as a UT branch\n # Otherwise, it could be Haryana or Punjab\n /CHANDIGARH UT/ => 'CHANDIGARH'\n }\n\n if possible_state.size == 2\n final_state = {\n \"AP\" => \"ANDHRA PRADESH\",\n \"KA\" => \"KARNATAKA\",\n \"TN\" => \"TELANGANA\",\n \"MH\" => \"MAHARASHTRA\",\n \"CG\" => \"CHHATTISGARH\",\n \"ML\" => \"MEGHALAYA\",\n \"MP\" => \"MADHYA PRADESH\"\n }[possible_state]\n else\n map.each_pair do |r, state|\n if r.is_a? Regexp and r.match? possible_state\n final_state = state\n elsif r == possible_state\n final_state = state\n end\n end\n end\n\n if final_state != row['STATE']\n log \"#{row['IFSC']}: Setting State=(#{final_state}) instead of (#{row['STATE']})\"\n row['STATE'] = final_state\n end\nend", "def calculate_state\n set_room\n\n # params[:round].to_i >= @room.number_of_rounds checks if you have reached the final round.\n # params[:round].to_i < @room.round checks if you are NOT the first person to finish, \n # because the first person needs to calculate the state.\n if (params[:round].to_i >= @room.number_of_rounds && params[:round].to_i < @room.round)\n respond_to do |format|\n format.js { render json: {game_over: \"true\"} }\n end\n return\n elsif (params[:round].to_i < @room.round)\n respond_to do |format|\n format.js { render json: {} }\n end\n return\n end\n\n # If neither of the last two statements were true, then you are the first person\n # whose round has ended and you can calculate the state.\n players = @room.players\n players_array = []\n players.each do |player|\n players_array << player.attributes\n end\n\n players_array.each do |player|\n player[\"last_round_notice\"] = \" \"\n end\n\n # Farmers first. If they farmed, +1 crop. Easy.\n players_array.select { |p| p[\"activity\"] == \"farming\" }.each do |farmer|\n score = farmer[\"score\"]\n farmer[\"score\"] = score + 1\n end\n\n # Donators next - also easy. Give +1 to whoever they visit.\n players_array.select { |p| p[\"activity\"] == \"donating\" }.each do |donator|\n player_affected = players_array.select{ |v| v[\"name\"] == donator[\"visiting\"] }[0]\n score = player_affected[\"score\"]\n player_affected[\"score\"] = score + 1\n end\n\n # Investigators are a little trickier. Loop through and see if anyone else visited\n # the same room as an investigator, set their status accordingly.\n players_array.select { |p| p[\"activity\"] == \"investigating\" }.each do |investigator|\n investigated = []\n player_affected = players_array.select{ |v| v[\"name\"] == investigator[\"visiting\"] }[0]\n players_array.select {|p| p[\"id\"] != investigator[\"id\"] }.each do |player|\n if player[\"visiting\"] == player_affected[\"name\"]\n investigated.append(player[\"name\"])\n end\n end\n if investigated.empty?\n investigated << \"nobody\"\n end\n notice = \"While at #{investigator['visiting']}, you saw \" + investigated.join(\", \")\n investigator[\"last_round_notice\"] = notice\n end\n\n # Robbing / gaurding is last. For each robber, do the following:\n players_array.select { |p| p[\"activity\"] == \"robbing\" }.each do |robber|\n shot = false\n player_affected = players_array.select{ |v| v[\"name\"] == robber[\"visiting\"] }[0]\n\n # First, loop and see if the robbed player was gaurded, and update\n # the gaurds status.\n players_array.select do |p| \n p[\"activity\"] == \"guarding\" && p[\"visiting\"] == player_affected[\"name\"] \n end.each do |guard|\n guard[\"last_round_notice\"] = \"You shot someone!\"\n shot = true\n end\n\n # Was the robber shot by a gaurd? If so, change lives. Else, update \n # the farmer and robbers crop totals.\n if shot == true\n lives_remaining = robber[\"lives\"] - 1\n robber[\"last_round_notice\"] = \"You were shot!\"\n robber[\"lives\"] = lives_remaining\n else\n max_payoff = players_array.size - @room.robber_count\n robber_new_score = (player_affected[\"score\"] > max_payoff - 1) ? robber[\"score\"] + max_payoff : robber[\"score\"] + player_affected[\"score\"]\n player_affected_new_score = (player_affected[\"score\"] > max_payoff - 1) ? player_affected[\"score\"] - max_payoff : 0\n player_affected[\"last_round_notice\"] = \"You were robbed!\"\n player_affected[\"score\"] = player_affected_new_score\n robber[\"last_round_notice\"] = \"Success!\"\n robber[\"score\"] = robber_new_score\n end\n end\n\n # Reset each player's activity and visiting, and re-save players\n players.each do |player|\n updated_attribs = players_array.select{ |p| p[\"id\"] == player.id }[0]\n updated_attribs[\"activity\"] = nil\n updated_attribs[\"visiting\"] = nil\n player.update(updated_attribs)\n end\n\n @room.round = @room.round + 1\n @room.round_end = Time.now.to_i + @room.time_per_round\n @room.save\n\n # If last round, game is now over\n if (@room.round > @room.number_of_rounds)\n respond_to do |format|\n format.js { render json: {game_over: \"true\"} }\n end\n else\n respond_to do |format|\n format.js { render json: {} }\n end\n end\n end", "def get_possible_states\n raise \"This is an abstract function!\"\n end", "def states\n\t[:shelf,:in_use,:borrowed,:misplaced,:lost]\nend", "def is_move_valid(current_state, proposed_change)\n proposed_floor = current_state[:elevator] + proposed_change[:elevator]\n return false if proposed_change.length < 2 || proposed_change.length > 3\n return false if proposed_floor < 0 || proposed_floor > 3\n\n proposed_state = get_new_state(current_state, proposed_change)\n generators = []\n chips = []\n proposed_state[:floors][proposed_floor].each do |item|\n binding.pry if item == nil\n if item[0] == :gen\n generators << item[1]\n else\n chips << item[1]\n end\n end\n if generators.length > 0\n chips.each do |chip_type|\n return false if !generators.include?(chip_type)\n end\n end\n\n return false if @visited_states.include? proposed_state.to_s\n @visited_states << proposed_state.to_s\n # binding.pry\n proposed_state\nend", "def decide_direction()\n floors = @building.floors\n requests_below = 0\n #see how many people below, wanting to go up or down\n (1..@current_floor).each do |floor_num|\n f = floors[floor_num]\n if f.button_pairs[\"elevator#{@number}\"][\"up\"] == true || f.button_pairs[\"elevator#{@number}\"][\"down\"] == true\n requests_below += f.up_person_queue.size() + f.down_person_queue.size()\n end\n end\n requests_above = 0\n #see how many above wanting to go down or up\n (@current_floor..@building.number_of_floors).each do |floor_num|\n f = floors[floor_num]\n if f.button_pairs[\"elevator#{@number}\"][\"down\"] == true || f.button_pairs[\"elevator#{@number}\"][\"up\"] == true\n requests_above += f.up_person_queue.size() + f.down_person_queue.size()\n end\n end\n if requests_above == 0 && requests_below == 0\n @direction = \"stationary\"\n elsif requests_above > requests_below\n @direction = \"up\"\n move_up()\n else #requests_above <= requests_below\n @direction = \"down\"\n move_down()\n end \n end", "def calc_in_game\n return unless state.mode == :creating\n calc_world_lookup\n calc_player\n end", "def next_states\n possible = []\n # possible states going up\n possible += next_states_in_dir(1) if @elevator != 3\n # possible states going down only make sense if there are actually some items available at lower floors\n items_lower = @floors[0...@elevator].map { |floor| floor.length }.sum\n possible += next_states_in_dir(-1) if (@elevator != 0) && (items_lower > 0)\n\n return possible\n end", "def random_status!\n \n choice = [:new, :needs_review, :needs_interview, :needs_interview, :needs_code_interview, :needs_decision, :needs_payment, :committed, :rejected, :rejected, :rejected, :rejected, :wont_attend, :wont_attend].sample\n return if choice == :new\n\n #convention: after setting the state, return if the choice equals that.\n self.mark_as_needs_review\n return if choice == :needs_review\n\n self.mark_as_needs_interview\n\n if choice == :needs_interview\n return\n elsif choice == :needs_code_interview\n self.mark_as_needs_code_interview\n return\n end\n\n self.mark_as_needs_decision\n return if choice == :needs_decision\n\n self.mark_as_accepted\n\n return if choice == :needs_payment\n \n self.mark_as_committed\n\n return if choice == :committed\n\n \n\n if choice == :rejected\n self.mark_as_rejected\n return\n elsif choice == :rejected\n self.mark_as_wont_attend\n return\n end\n\n #add rejected and wont_attend later.\n # if choice == :needs_decision_from_interview\n # self.mark_as_needs_decision_from_interview\n # return\n # elsif choice == :needs_decision_from_code_interview\n # self.mark_as_needs_code_interview\n # self.mark_as_needs_decision_from_code_interview\n # return\n # end\n \n end", "def check_state_ext(actor)\n for state in actor.states.sort {|a,b| $data_states[b].rating <=> $data_states[a].rating}\n return State_Battler[state] if State_Battler[state] != nil\n end\n return ''\n end", "def valid_moves\n\n end", "def find_start_states_without_canonicalization\n states = []\n lose_state.random_successors.each do |one_tile_state|\n one_tile_state.random_successors.each do |two_tile_state|\n states << two_tile_state\n end\n end\n states\n end", "def states; end", "def onroad_state(statistics)\n distance_from_last_start = distance_from [statistics.last_start.latitude, statistics.last_start.longitude]\n duration_since_last_start = (time - statistics.last_start.time).to_i\n\n if ignition_is_off? && (distance_from_last_start >= 0.01 or duration_since_last_start > 300)\n on_stop(statistics, duration_since_last_start)\n else\n on_road(statistics)\n end \n end", "def state\n\t\t@flrs.each do |f|\n\t\t\tputs \"Floor #{@flrs.index(f)} has #{f.passengers.length} passengers waiting.\"\n\t\tend\n\t\t@elevators.each do |e|\n\t\t\tputs \"Elevator #{@elevators.index(e)} is in floor #{@flrs.index(e.current_floor)}, #{e.direction} with #{e.passengers.length} passengers\"\n\t\tend\n\tend", "def determine_moves(loc)\n\n piece = @spaces[loc]\n\n moveset = []\n attackset = []\n new_moves = []\n\n x = loc[0]\n y = loc[1]\n\n enemy_king_checked = false\n\n\n case piece.type\n\n when \"pawn\"\n\n if piece.color == \"white\"\n\n new_moves << [x, y+1]\n new_moves << [x,y+2] if y == 1\n\n if @spaces[new_moves[0]].nil?\n\n moveset << new_moves[0]\n moveset << new_moves[1] if y == 1\n\n end\n\n atk_moves = [[x+1, y+1], [x-1, y+1]]\n atk_moves.each do |move|\n attackset << move if @spaces[move].nil?.! and @spaces[move].color == \"black\"\n if @spaces[move].nil?.!\n enemy_king_checked = true if @spaces[move].color == \"black\" and @spaces[move].type == \"king\"\n end\n end\n \n\n elsif piece.color == \"black\"\n\n new_moves = [[x, y-1]]\n new_moves << [x,y-2] if y == 6\n\n if @spaces[new_moves[0]].nil?\n\n moveset << new_moves[0]\n moveset << new_moves[1] if loc[1] == 6\n\n end\n\n atk_moves = [[x+1, y-1], [x-1, y-1]]\n atk_moves.each do |move|\n attackset << move if @spaces[move].nil?.! and @spaces[move].color == \"white\"\n if @spaces[move].nil?.!\n enemy_king_checked = true if @spaces[move].color == \"white\" and @spaces[move].type == \"king\"\n end\n end\n end\n\n @spaces[loc].moveset = moveset\n @spaces[loc].attackset = attackset\n \n\n when \"rook\"\n\n runner(loc, :north)\n runner(loc, :east)\n runner(loc, :south)\n runner(loc, :west)\n\n when \"knight\"\n\n possible_directions =\n [ [x+1, y+2],\n [x+1, y-2],\n [x-1, y+2],\n [x-1, y-2],\n [x+2, y+1],\n [x+2, y-1],\n [x-2, y+1],\n [x-2, y-1] ]\n\n moveset = possible_directions.select do |d|\n (d[0].between?(0,7) & d[1].between?(0,7)) and @spaces[d].nil?\n end\n\n attackset = possible_directions.select do |d|\n (d[0].between?(0,7) & d[1].between?(0,7)) and (@spaces[d].nil?.! and @spaces[d].color != @spaces[loc].color)\n end\n\n @spaces[loc].moveset = moveset\n @spaces[loc].attackset = attackset\n\n\n when \"bishop\"\n\n runner(loc, :northeast)\n runner(loc, :southeast)\n runner(loc, :northwest)\n runner(loc, :southwest)\n\n\n when \"queen\"\n\n runner(loc, :north)\n runner(loc, :northeast)\n runner(loc, :east)\n runner(loc, :southeast)\n runner(loc, :south)\n runner(loc, :southwest)\n runner(loc, :west)\n runner(loc, :northwest)\n\n\n when \"king\"\n\n runner(loc, :north, 1)\n runner(loc, :northeast, 1)\n runner(loc, :east, 1)\n runner(loc, :southeast, 1)\n runner(loc, :south, 1)\n runner(loc, :southwest, 1)\n runner(loc, :west, 1)\n runner(loc, :northwest, 1)\n\n end\n\n\n end", "def state\n [\n [\"AC\",\"Acre\"],\n [\"AL\",\"Alagoas\"],\n [\"AP\",\"Amapa\"],\n [\"AM\",\"Amazonas\"],\n [\"BA\",\"Bahia\"],\n [\"CE\",\"Ceara\"],\n [\"DF\",\"Distrito Federal\"],\n [\"ES\",\"Espirito Santo\"],\n [\"GO\",\"Goias\"],\n [\"MA\",\"Maranhao\"],\n [\"MT\",\"Mato Grosso\"],\n [\"MS\",\"Mato Grosso do Sul\"],\n [\"MG\",\"Minas Gerais\"],\n [\"PA\",\"Para\"],\n [\"PB\",\"Paraiba\"],\n [\"PR\",\"Parana\"],\n [\"PE\",\"Pernambuco\"],\n [\"PI\",\"Piaui\"],\n [\"RJ\",\"Rio de Janeiro\"],\n [\"RN\",\"Rio Grande do Norte\"],\n [\"RS\",\"Rio Grande do Sul\"],\n [\"RO\",\"Rondonia\"],\n [\"RR\",\"Roraima\"],\n [\"SC\",\"Santa Catarina\"],\n [\"SP\",\"Sao Paulo\"],\n [\"SE\",\"Sergipe\"],\n [\"TO\",\"Tocantins\"],\n ]\n end", "def setup_add_state\n return TSBS.error(@acts[0], 1, @used_sequence) if @acts.size < 2\n c = @acts[2] || 100\n c = c/100.0 if c.integer?\n if area_flag\n target_array.each do |t|\n cx = c # Chance extra\n if !@acts[3]\n cx *= target.state_rate(@acts[1]) if opposite?(self)\n cx *= target.luk_effect_rate(self) if opposite?(self)\n end\n if chance(cx)\n t.add_state(@acts[1]) \n get_scene.tsbs_redraw_status(t)\n end\n end\n return\n end\n return unless target\n if !@acts[3]\n c *= target.state_rate(@acts[1]) if opposite?(self)\n c *= target.luk_effect_rate(self) if opposite?(self)\n end\n if chance(c)\n target.add_state(@acts[1]) \n get_scene.tsbs_redraw_status(target)\n end\n end", "def chara_by_state\n return STATE_APPEARANCE_SUFFIX[@state || enter_in_walking_state]\n end", "def utility(state)\n return 0 if rules.draw?(state)\n\n (state.turn == team) ? -1 : 1 \n end", "def occupy_grid(from_x, from_y, the_direction, the_distance, wire_index, the_base_steps, in_grid_hash)\n if the_direction.upcase == \"U\"\n the_step_x, the_step_y = 0, 1\n elsif the_direction.upcase == \"D\"\n the_step_x, the_step_y = 0, -1\n elsif the_direction.upcase == \"L\"\n the_step_x, the_step_y = -1, 0\n elsif the_direction.upcase == \"R\"\n the_step_x, the_step_y = 1, 0\n end\n the_walk_x, the_walk_y = from_x, from_y\n\n 0.upto(the_distance - 1) do |the_step_num|\n the_key = \"#{the_walk_x}_#{the_walk_y}\"\n in_grid_hash[the_key] ||= [-1,-1]\n\n in_grid_hash[the_key][wire_index] = the_base_steps + the_step_num if in_grid_hash[the_key][wire_index] < 1\n\n the_walk_y += the_step_y\n the_walk_x += the_step_x\n end\n return the_walk_x, the_walk_y\nend", "def pre_check_legal_moves(state)\n player = state[:player]\n piece_list = state[:pieces][player]\n move_list = []\n # Loop over pieces\n piece_list.each do |piece|\n move_list += piece.legal_moves(state)\n end\n move_list\n end", "def reachable?; @state[\"reachable\"]; end", "def state\n [\n [\"AC\", \"Acre\"],\n [\"AL\", \"Alagoas\"],\n [\"AP\", \"Amapa\"],\n [\"AM\", \"Amazonas\"],\n [\"BA\", \"Bahia\"],\n [\"CE\", \"Ceara\"],\n [\"DF\", \"Distrito Federal\"],\n [\"ES\", \"Espirito Santo\"],\n [\"GO\", \"Goias\"],\n [\"MA\", \"Maranhao\"],\n [\"MT\", \"Mato Grosso\"],\n [\"MS\", \"Mato Grosso do Sul\"],\n [\"MG\", \"Minas Gerais\"],\n [\"PA\", \"Para\"],\n [\"PB\", \"Paraiba\"],\n [\"PR\", \"Parana\"],\n [\"PE\", \"Pernambuco\"],\n [\"PI\", \"Piaui\"],\n [\"RJ\", \"Rio de Janeiro\"],\n [\"RN\", \"Rio Grande do Norte\"],\n [\"RS\", \"Rio Grande do Sul\"],\n [\"RO\", \"Rondonia\"],\n [\"RR\", \"Roraima\"],\n [\"SC\", \"Santa Catarina\"],\n [\"SP\", \"Sao Paulo\"],\n [\"SE\", \"Sergipe\"],\n [\"TO\", \"Tocantins\"],\n ]\n end", "def done?\n # legal_moves(state).empty?\n # Try to speed up by disregarding possibility of draw\n false\n end", "def next_state(state, move)\n position = state[:position]\n player = state[:player]\n result = position.each_with_index.map do |row, x|\n row.each_with_index.map do |value, y|\n ( x >= move[0] && y >= move[1] ) ? 0 : value\n end\n end\n next_player = opponent(player)\n { :position => result, :player => next_player }\n end", "def get_available_positions\n @state.each.with_index(1).select { |mark, index| mark.nil? }.map { |mark, index| index }\n end", "def expects\n self.class.moves[@state].keys\n end", "def possible_moves\n possibles = []\n @state.each_with_index do |column, i|\n possibles << i if column[5] == :e\n end\n possibles\n end", "def move(state)\n @iteration_count = 0\n #make an array of all possible moves\n choices = []\n state.legal_moves.each do |move| \n hash = tabulate_outcomes(move)\n hash[:move] = move\n choices << hash\n end\n puts \"Finished tabulation in #{@iteration_count} calls.\"\n \n #pick best worst case scenario\n best = choices.sort_by { |c| [-c[:worst], -c[@playing_mark]] }.first\n return best[:move]\n end", "def exits\n ways_out = []\n ways_out << :north if simperson.simplace.to_simnorth\n ways_out << :south if simperson.simplace.to_simsouth\n ways_out << :east if simperson.simplace.to_simeast\n ways_out << :west if simperson.simplace.to_simwest\n ways_out << :up if simperson.simplace.to_simup\n ways_out << :down if simperson.simplace.to_simdown\n ways_out\n end", "def state(restrictions={state: [], zip_code: []}, abbreviated=true)\n state = nil\n state = restrictions[:state].is_a?(Array) and !restrictions[:state].blank? ? restrictions[:state] : []\n zip_codes = restrictions[:zip_code].is_a?(Array) and !restrictions[:zip_code].blank? ? restrictions[:zip_code] : []\n\n unless @config[:location_db][:adapter].eql?(:none)\n if abbreviated\n state = find_location(state, zip_codes)[\"#{@config[:location_db][:column_mapping][:state]}\"]\n else\n state = find_location(state, zip_codes)[\"#{@config[:location_db][:column_mapping][:state_abbr]}\"]\n end\n end\n\n if state.blank?\n state = abbrivated ? Faker::Address.state_abbr : Faker::Address.state\n end\n\n state\n end", "def setup_iterative_division_algorithm_state(grid_length, state)\n state[:todo_chamber] = []\n state[:finished_init] = false\n state[:current_chamber] = ChamberInfo.new(0, 0, grid_length, grid_length)\n state[:generation_complete] = false\nend", "def if_goal_reachable(num_gas_stand, course_distance, init_gas_amount, gas_stand_spot, gas_amounts)\n track = Track.new(init_gas_amount)\n gas_stand_spot.each_with_index do |dist, index|\n print \"index: #{index}, dist: #{dist}\\n\"\n track.run(dist - track.location)\n while track.check_gasoline_necessary\n if_successful = track.consume_gasoline\n print \"gasoline_necessary. consume gasoline_successful? #{if_successful}\\n\"\n return -1 unless if_successful\n end\n track.gasoline_right_provided(gas_amounts[index])\n end\n\n # From last gas stop to the goal\n track.run(course_distance - track.location)\n if track.check_gasoline_necessary\n if_successful = track.consume_gasoline\n return -1 unless if_successful\n end\n print \"gas_station_used: #{track.show_gas_station_used}\\n\"\n return track.count_gas_stand_used\nend", "def isValidWalk(walk)\n #your code here\n directions = {'n'=>0, 's'=>0, 'e'=>0, 'w'=>0}\n\n walk.each do |step|\n directions[step] += 1\n end\n\n if directions['n'] == directions['s'] && directions['e'] == directions['w']\n walk\n else\n false\n end\nend", "def eval_res_distances\n self.greater_than_twenty_away = (self.position_one - self.position_two).abs > 20\n self.greater_than_50_away = (self.position_one - self.position_two).abs > 50\n self.greater_than_100_away = (self.position_one - self.position_two).abs > 100\n self.greater_than_200_away = (self.position_one - self.position_two).abs > 200\n self.greater_than_300_away = (self.position_one - self.position_two).abs > 300\n self.greater_than_400_away = (self.position_one - self.position_two).abs > 400\n self.greater_than_500_away = (self.position_one - self.position_two).abs > 500\n self.greater_than_600_away = (self.position_one - self.position_two).abs > 600\n self.greater_than_700_away = (self.position_one - self.position_two).abs > 700\n self.greater_than_800_away = (self.position_one - self.position_two).abs > 800\n self.greater_than_900_away = (self.position_one - self.position_two).abs > 900\n self.greater_than_1000_away = (self.position_one - self.position_two).abs > 1000\n self.greater_than_1100_away = (self.position_one - self.position_two).abs > 1100\n self.greater_than_1200_away = (self.position_one - self.position_two).abs > 1200\n self.greater_than_1300_away = (self.position_one - self.position_two).abs > 1300\n self.greater_than_1400_away = (self.position_one - self.position_two).abs > 1400\n self.greater_than_1500_away = (self.position_one - self.position_two).abs > 1500\n self.greater_than_1600_away = (self.position_one - self.position_two).abs > 1600\n self.greater_than_1700_away = (self.position_one - self.position_two).abs > 1700\n self.greater_than_1800_away = (self.position_one - self.position_two).abs > 1800\n self.greater_than_1900_away = (self.position_one - self.position_two).abs > 1900\n self.greater_than_2000_away = (self.position_one - self.position_two).abs > 2000\n self.greater_than_2100_away = (self.position_one - self.position_two).abs > 2100\n self.greater_than_2200_away = (self.position_one - self.position_two).abs > 2200\n self.greater_than_2300_away = (self.position_one - self.position_two).abs > 2300\n self.greater_than_2400_away = (self.position_one - self.position_two).abs > 2400\n self.greater_than_2500_away = (self.position_one - self.position_two).abs > 2500\n self.save\n end", "def query_num_of_legislators_by_states\n\thash1 = Representative.group(:state).count\n\tarr = hash1.to_a\n\thash2 = Senator.group(:state).count \n\tarr.sort_by! { |arr_within_arr| arr_within_arr[1] + hash2[arr_within_arr[0]] } # looks at the num of sen & rep to sort\n\tarr.reverse!\n\tarr.each do |a| \n\t\tstate = a[0]\n\t\tputs \"#{state}: #{hash2[state]} Senators, #{a[1]} Representative(s)\"\n\tend\nend", "def extended_state\n\t if self.state == 'complete'\n \t if !self.accepted_at\n \t 'submitted'\n elsif self.accepted_at && (self.packed_at == nil) && self.shipment_state != 'shipped'\n 'accepted'\n elsif self.packed_at && (self.shipment_state != 'shipped' && self.shipment_state != 'delivered')\n 'ready_for_pick_up'\n elsif self.shipment_state == 'shipped'\n 'shipped'\n elsif self.shipment.state == 'delivered'\n 'delivered'\n end\n else\n self.state\n end\n end", "def advance(state)\n newState = Hash.new(false)\n for x in 1..$size\n for y in 1..$size\n neighbours = get_neighbours(x, y, state)\n if state[[x, y]]\n newState[[x, y]] = true if neighbours == 2 or neighbours == 3\n else\n newState[[x, y]] = true if neighbours == 3\n end\n end\n end\n return newState\nend", "def validate_place(x,y,direction,placed,place_position)\n params=place_position.split(',')\n if is_integer(params[0]) && is_integer(params[1]) # Checking invalid inputs\n temp_x=params[0].to_i\n temp_y=params[1].to_i\n else\n return x,y,direction,placed # Place invalid, return\n end \n if validate(temp_x) && validate(temp_y) # Checking board boundaries\n if ['NORTH','EAST','WEST','SOUTH'].include?(params[2]) # Checking valid Directions\n x=temp_x\n y=temp_y\n direction=params[2]\n return x,y,direction,true #place is valid return updated coordinates and placed_state\n end\n end\n return x,y,direction,placed # Place invalid, return\n end", "def moves_available\n # return what moves are available to this piec\n end", "def mock_leaderboard\n overtake = (rand * 10).round == 7\n swap_at((rand * 9).floor) if overtake\n $state.each.with_index do |car, i|\n $state[i][:interval] = $state[i-1][:interval] - (rand * 4) if i != 0\n $state[i][:last_lap] = 39 + (rand * 3)\n end\n return $state\nend", "def state\n ret = self[:state] || {}\n if game.facts[:contraband] && game.facts[:contraband].include?(card_type)\n ret[:contraband] = true\n end\n return ret\n end", "def internship_passed; end", "def test_neighbour_count\n # Empty\n @game.state=[[0,0,0],[0,0,0],[0,0,0]]\n assert_equal 0,@game.neighbour_count(0,0)\n assert_equal 0,@game.neighbour_count(1,1)\n\n # One cell, check all neighbours, check proper edge wrapping\n @game.state=[[0,0,0],[0,1,0],[0,0,0]]\n assert_equal 1,@game.neighbour_count(0,2),'0,2'\n assert_equal 1,@game.neighbour_count(0,0),'0,0'\n assert_equal 1,@game.neighbour_count(0,1),'0,1'\n assert_equal 1,@game.neighbour_count(1,0),'1,0'\n assert_equal 0,@game.neighbour_count(1,1),'1,1' # Don't count self\n assert_equal 1,@game.neighbour_count(1,2),'1,2'\n assert_equal 1,@game.neighbour_count(2,0),'2,0'\n assert_equal 1,@game.neighbour_count(2,1),'2,1'\n assert_equal 1,@game.neighbour_count(2,2),'2,2'\n\n # Eight cells, check all neighbours, check proper edge wrapping\n @game.state=[[1,1,1],[1,0,1],[1,1,1]]\n assert_equal 7,@game.neighbour_count(0,2),'0,2'\n assert_equal 7,@game.neighbour_count(0,0),'0,0'\n assert_equal 7,@game.neighbour_count(0,1),'0,1'\n assert_equal 7,@game.neighbour_count(1,0),'1,0'\n assert_equal 8,@game.neighbour_count(1,1),'1,1' # Only cell with 8\n assert_equal 7,@game.neighbour_count(1,2),'1,2'\n assert_equal 7,@game.neighbour_count(2,0),'2,0'\n assert_equal 7,@game.neighbour_count(2,1),'2,1'\n assert_equal 7,@game.neighbour_count(2,2),'2,2'\n end", "def get_target(map, loc)\n owned = nil\n owned_min = 1000\n GameMap::CARDINALS.each do |l|\n new_loc = map.find_location(loc, l)\n site = map.site(new_loc)\n if site.owner != $tag && site.strength < owned_min\n owned_min = site.strength\n owned = l\n end\n end\n owned\nend", "def steps_before_repeat_state_naive\n\t\t# state = {}\n\t\tsteps = 0\n\t\torig = @moons_pos.to_s\n\t\tzero_vel = [0, 0, 0]\n\t\tstarting_time = Time.now\n\t\tp @moons_pos\n\t\twhile (42)\n\t\t\tsleep(1)\n\t\t\t# state.has_key?(@moons_pos.to_s) ? break : state[@moons_pos.to_s] = true\n\n\t\t\tapply_gravity_to_velocity\n\t\t\tapply_velocity_to_position\n\t\t\tsteps += 1\n\t\t\tp @moons_pos\n\t\t\tbreak if velocity(:io) == zero_vel && @moons_pos.to_s == orig\n\t\tend\n\t\tsteps\n\tend", "def game_state\n\n if @A1.content == \"o\" && @A2.content == \"o\" && @A3.content == \"o\" || @A1.content == \"x\" && @A2.content == \"x\" && @A3.content == \"x\"\n @game_state_variable = true\n end\n\n # On test la 2ème ligne\n if @B1.content == \"o\" && @B2.content == \"o\" && @B3.content == \"o\" || @B1.content == \"x\" && @B2.content == \"x\" && @B3.content == \"x\"\n @game_state_variable = true\n end\n\n # On test la 3eme ligne\n if @C1.content == \"o\" && @C2.content == \"o\" && @C3.content == \"o\" || @C1.content == \"x\" && @C2.content == \"x\" && @C3.content == \"x\"\n @game_state_variable = true\n end\n\n # On test la première colone\n if @A1.content == \"o\" && @B1.content == \"o\" && @C1.content == \"o\" || @A1.content == \"x\" && @B1.content == \"x\" && @C1.content == \"x\"\n @game_state_variable = true\n end\n\n # On test le deuxième colone\n if @A2.content == \"o\" && @B2.content == \"o\" && @C2.content == \"o\" || @A2.content == \"x\" && @B2.content == \"x\" && @C2.content == \"x\"\n @game_state_variable = true\n end\n\n # On test la 3eme colone\n if @A3.content == \"o\" && @B3.content == \"o\" && @C3.content == \"o\" || @A3.content == \"x\" && @B3.content == \"x\" && @C3.content == \"x\"\n @game_state_variable = true\n end\n\n # On test la dagonale gauche\n if @A1.content == \"o\" && @B2.content == \"o\" && @C3.content == \"o\" || @A1.content == \"x\" && @B2.content == \"x\" && @C3.content == \"x\"\n @game_state_variable = true\n end\n\n # On test la diagonle droite\n if @A3.content == \"o\" && @B2.content == \"o\" && @C1.content == \"o\" || @A3.content == \"x\" && @B2.content == \"x\" && @C1.content == \"x\"\n @game_state_variable = true\n end\n\n end", "def check_swing_states(spread)\n @polls.each do |state, row|\n row[4] = row[1] - row[2]\n if row[4].abs < spread.to_f\n @swing_states << [state, row[4]]\n elsif row[4] > 0\n @clinton_states << [state, row[1]]\n else\n @trump_states << [state, row[2]]\n end\n end\n @swing_states.sort! {|a,b| a[1].abs <=> b[1].abs}\n @clinton_states.sort! {|a,b| a[1].abs <=> b[1].abs}\n @trump_states.sort! {|a,b| a[1].abs <=> b[1].abs}\n end", "def update_user_state\n # puts \"GameSession.update_user_state\"\n game_session_user_statuses.each do |gsus|\n area_elements_owned_by_user = self.area_elements.find :all, :conditions => [\"user_id = ?\",gsus.user.id]\n \n num_of_cities = 0\n area_elements_owned_by_user.each do |ae|\n # TODO: Needs update to support more AreaElements\n if((ae.area_element_type.name == \"city\") || (ae.area_element_type.name == \"harbor\"))\n num_of_cities += 1\n end \n end\n \n if (num_of_cities == 0) || (gsus.is_chief_killed?)\n if (gsus.state == \"active\") \n gsus.state = \"killed\"\n gsus.save\n NextworldMailer.deliver_battle_ended_mail(@the_user, gs.name)\n end \n end\n # puts \"GameSession.update_user_state, gsus.user.name: #{gsus.user.name}, gsus.state: #{gsus.state}, gsus.last_turn_order_recived: #{gsus.last_turn_order_recived}, self.current_turn_number: #{self.current_turn_number} \"\n if ((gsus.state == \"active\") && (gsus.last_turn_order_recived <= self.current_turn_number - 3))\n gsus.state = \"inactive\"\n gsus.save\n end\n end\n end", "def check_50_states\n STATE_DATA.each do |state, state_data_hash|\n VirusPredictor.new(state, state_data_hash[:population_density], state_data_hash[:population]).virus_effects\n end\nend", "def handle_geocode_status(geomatch_result)\n case geomatch_result[:status]\n when VaDotGovAddressValidator::STATUSES[:matched_available_hearing_locations],\n VaDotGovAddressValidator::STATUSES[:philippines_exception]\n cancel_admin_actions_for_matched_appeal\n when VaDotGovAddressValidator::STATUSES[:created_verify_address_admin_action],\n VaDotGovAddressValidator::STATUSES[:created_foreign_veteran_admin_action]\n create_available_hearing_location_for_errored_appeal\n end\n end", "def todo_state\n return :normal if !self.wip_total\n return :urgent if self.wip_total > WIP_TOTAL_URGENT\n return :warn if self.wip_total > WIP_TOTAL_WARN\n\n return :normal if !self.lane\n return :urgent if self.lane.urgent_limit and self.wip_current > self.lane.urgent_limit\n return :warn if self.lane.warn_limit and self.wip_current > self.lane.warn_limit\n return :normal\n end", "def gps(initial_states, goal_states, operators)\n\n # To keep track of which operators have been applied, we add additional\n # 'executing ...' states to each operator's add-list. These will never be\n # deleted by another operator, so when the problem is solved we can find\n # them in the list of current states.\n prefix = 'Executing '\n\n operators.each do |operator|\n operator['add'].append(prefix + operator['action'])\n end\n\n final_states = achieve_all(initial_states, operatos, goal_states, [])\n\n if !final_states\n nil\n else\n final_states.select do |state|\n state.start_with?(prefix)\n end\n end\nend", "def travel_and_places; end", "def process_validity_geocoords\n unless self.status == OrderStatusEnum::COMPLETED\n if self.lat && self.long\n if self.get_assigned_tour\n self.status = OrderStatusEnum::ASSIGNED\n else\n self.status = OrderStatusEnum::ACTIVE\n end\n else\n self.status = OrderStatusEnum::INVALID\n end\n end\n end", "def state_at(t)\n\n if @time_span.include?(t)\n \n leg_percent = (t - @launch_time) / @flight_time\n dist = leg_percent * @distance\n dist_rad = leg_percent * @distance_rad\n\n alt_track = @alt1 + @v_init * (t - @launch_time) * Math.sin(@theta_init) - 0.5 * @g * (t - @launch_time)**2\n\n lat_track = @lat1 + dist_rad * Math.cos(@tc)\n\n d_phi = Math.log(Math.tan(lat_track/ 2.0 + QUARTER_PI)/ Math.tan(@lat1 / 2.0 + QUARTER_PI))\n\n if (lat_track - @lat1).abs < 1e-8\n q = Math.cos(@lat1)\n else\n q = (lat_track - @lat1) / d_phi\n end\n\n lng_track = @lng1 + dist_rad * Math.sin(@tc) / q\n\n lat_track = lat_track * DEG_PER_RAD\n lng_track = lng_track * DEG_PER_RAD\n\n lla_track = LlaCoordinate.new( lat_track, lng_track, alt_track)\n\n ## Attitude Calculations\n theta_track = Math.atan( Math.tan(@theta_init) - @g * (t - @launch_time) / (@v_init * Math.cos(@theta_init)) )\n bearing_track = @tc * DEG_PER_RAD\n velocity_track = @v_init / Math.cos(@theta_init) * Math.cos(theta_track)\n\n theta_track *= DEG_PER_RAD\n\n velocity_vector = ecef_rotation( lla_track, bearing_track, theta_track, velocity_track)\n attitude_vector = ecef_rotation( lla_track, bearing_track, theta_track, 1)\n\n return [lla_track, velocity_vector, attitude_vector]\n \n else\n return [nil, nil, nil]\n end\n\n end", "def next_state\n STATES.find do |_, state|\n state[:probability] && state[:probability] > rand\n end\n end", "def checkmate(k,a)\n # Checkmate test where king may be: k_attacks - used - king_attaks - cells_behind_the_king\n all = all_position\n p used = [k,a]\n k_attacks = king_position(k).uniq \n a_attacks = (amazon_postion(a) - free_cells(k,a)).uniq\n stand_positions = a_attacks - k_attacks - used\n safe_squares = (all - k_attacks - a_attacks - used).uniq\n ans = stand_positions.reduce([]){ |acc,x| \n if (safe_squares & king_position(x)).empty?\n p x\n acc.push(x) \n end\n acc\n }\n p ans\n ans.size\n \nend", "def initialize_strategy\n main_position = player.command_centers.first.position\n _, *unscouted_bases = BWTA.start_locations.to_a.map(&:position).sort do |a, b|\n main_position.getDistance(b) <=> main_position.getDistance(a)\n end.reverse\n overlord_target = nil\n\n #Basic Strategy:\n strategy_step \"Every idle worker should mine\" do\n precondition { player.workers.any? &:idle? }\n\n postcondition { false } #this step should be repeated\n\n order do\n center = player.command_centers.first\n\n minerals = state.units.values.select{|u| u.type.mineral_field? }.sort do |a, b|\n b.distance(center) <=> a.distance(center)\n end\n\n player.workers.select(&:idle?).each do |worker|\n worker.mine(minerals.pop)\n end\n end\n end\n\n #When there is less than 5 supply and a spawning pool does not exist, a drone should be spawned\n strategy_step \"Spawn a drone\" do\n precondition { player.minerals >= 50 && player.supply_used < 10 }\n\n postcondition { false } #this step should be repeated\n\n order { spawn UnitType.Zerg_Drone }\n end\n\n #When there is not enough supply an overlord should be spawned\n strategy_step \"Spawn an overlord\" do\n precondition { player.minerals >= 100 && player.supply_total <= player.supply_used && player.larva_available? } #not smart\n\n progresscondition { player.units.values.any? {|unit| unit.has_order? \"Spawn Overlord\" } }\n\n postcondition { false }#this step should be repeated\n\n order { spawn UnitType.Zerg_Overlord }\n end\n\n strategy_step \"Early overlord scout\" do\n overlord = nil\n target = nil\n\n precondition do\n overlords = player.get_all_by_unit_type(UnitType.Zerg_Overlord)\n if overlords.count == 1\n overlord = overlords.first\n target = unscouted_bases.shift\n overlord_target = target\n true\n end\n end\n\n progresscondition { overlord && target }\n\n postcondition { overlord.position == target if overlord }\n\n order { overlord.move(target) if overlord }\n end\n\n strategy_step \"Drone scout\" do\n drone_scout = nil\n target = nil\n\n precondition do\n if player.get_all_by_unit_type(UnitType.Zerg_Spawning_Pool).count > 0 && target = unscouted_bases.shift\n drone_scout = player.workers.first\n true\n end\n end\n\n order do\n # TODO why is if drone_scout necessary?\n drone_scout.move(target) if drone_scout\n end\n end\n\n #At 5 supply, 200 minerals a spawning pool should be made\n strategy_step \"Make a spawning pool at 5 supply\" do\n precondition { player.minerals > 200 && player.supply_total >= 10 }\n\n postcondition { player.units.values.any? {|u| u.type == UnitType.Zerg_Spawning_Pool} }\n\n progresscondition { player.units.values.any? {|u| u.has_order? \"Build SpawningPool\" } }\n\n order do\n player.workers.first.build(UnitType.Zerg_Spawning_Pool, build_location(UnitType.Zerg_Spawning_Pool))\n end\n end\n\n #When there is a spawning pool and enough minerals and supply, a zergling should be made\n strategy_step \"Make zerglings\" do\n precondition { player.minerals > 50 && player.supply_left >= 2 && player.larva_available? }\n\n precondition { player.get_all_by_unit_type(UnitType.Zerg_Spawning_Pool).count > 0 }\n\n postcondition { false } #this step should be repeated\n\n order do\n while (player.minerals > 50 && player.supply_left >= 2 && player.larva_available?) do\n spawn UnitType.Zerg_Zergling #spawn many zerglings in one frame\n end\n end\n end\n\n strategy_step \"Move in!\" do\n precondition { zerglings.count >= 1 && enemy.units.count == 0 }\n\n postcondition { false }\n\n order do\n target = unscouted_bases.shift || overlord_target\n\n zerglings.each do |z|\n puts \"Ordering zerglings to move\"\n z.move(target)\n end\n end\n end\n\n #When there are 5 zerglings, they should attack\n strategy_step \"Attack!\" do\n precondition { zerglings.count >= 5 && enemy.units.count > 0 }\n\n postcondition { false } #just keep on doin' it\n\n order do \n puts \"Ordering zerglings to attack\"\n zerglings.each { |z| attack_nearest_enemy(z) }\n end\n end\n end", "def moving\n\t\tget_rand(2)\n\t\tcase @location\n\t\twhen \"Cathedral\"\n\t\t\tfrom_cathy()\n\t\twhen \"Hospital\"\n\t\t\tfrom_hospital()\n\t\twhen \"Hillman\"\n\t\t\tfrom_hillman()\n\t\twhen \"Museum\"\n\t\t\tfrom_museum()\n\t\tend\n\tend", "def initial_state(soldiers)\n {\n soldiers: soldiers,\n positions: initial_positions(soldiers),\n clock: 0\n }\nend", "def winner\n (@cases['A'][1].state == @cases['A'][2].state && @cases['A'][2].state == @cases['A'][3].state) ||\n (@cases['B'][1].state == @cases['B'][2].state && @cases['B'][2].state == @cases['B'][3].state) ||\n (@cases['C'][1].state == @cases['C'][2].state && @cases['C'][2].state == @cases['C'][3].state) ||\n (@cases['A'][1].state == @cases['B'][1].state && @cases['B'][1].state == @cases['C'][1].state) ||\n (@cases['A'][2].state == @cases['B'][2].state && @cases['B'][2].state == @cases['C'][2].state) ||\n (@cases['A'][3].state == @cases['B'][3].state && @cases['B'][3].state == @cases['C'][3].state) ||\n (@cases['A'][1].state == @cases['B'][2].state && @cases['B'][2].state == @cases['C'][3].state) ||\n (@cases['A'][3].state == @cases['B'][2].state && @cases['B'][2].state == @cases['C'][1].state)\n end", "def steps\n infect the cell at a\n while we have more? new_infections do\n spread a new_infection\n more cowbell!\n end\n if the maze is infected? at b then return the generation at b else return 0 end\n end", "def game_state\n end", "def take_ride\n\n # This happens if the user is both too short & ticketless to take the ride:\n if self.user.tickets < self.attraction.tickets && self.user.height < self.attraction.min_height\n # The rspec tests expect this output to be the return value:\n \"Sorry. You do not have enough tickets to ride the #{attraction.name}. You are not tall enough to ride the #{attraction.name}.\"\n\n # This happens if the user is too short for the ride\n elsif self.user.tickets < self.attraction.tickets\n # The rspec tests expect this output to be the return value:\n \"Sorry. You do not have enough tickets to ride the #{attraction.name}.\"\n\n # This happens of the user is too ticketless for the ride\n elsif self.user.height < self.attraction.min_height\n # The rspec tests expect this output to be the return value:\n \"Sorry. You are not tall enough to ride the #{attraction.name}.\"\n\n # This closes the door on situations where the user can't take the ride.\n # The loop doesn't end here because if it did, the rest of the code below\n # would be ignored. Now that this whole thing is in one giant loop, the\n # \"return\" values above can be removed.\n\n else\n # Assuming the user has the height & resources, The user will pay for the ride in tickets\n self.user.tickets = self.user.tickets - self.attraction.tickets\n self.user.nausea = self.attraction.nausea_rating + self.user.nausea\n self.user.happiness = self.attraction.happiness_rating + self.user.happiness\n self.user.save\n # The rspec tests expect this output to be the return value:\n \"Thanks for riding the #{attraction.name}!\"\n end\n end", "def state_wins\n WINS.map { |win| [ $state[win[0]], $state[win[1]], $state[win[2]] ] }\nend", "def legal_moves\n # Fill this in\n end", "def load_state(state)\n state.symbolize_keys!\n\n @mine = state[:mine].present?\n @revealed = state[:revealed].present?\n @flagged = state[:flagged].present?\n @neighbors_count = state[:neighbors_count]\n end", "def determine_status(cell, neighbor_live_count)\n nc = neighbor_live_count\n (nc < 2 || nc > 3) && @dead_generation << cell\n (nc == 3) && @live_generation << cell\n end", "def next_life_state current_state,neighbours\n case current_state\n when 1 then \n (2..3) === neighbours ? 1 : 0\n when 0 then \n 3 === neighbours ? 1 : 0\n else\n 0\n end\n end", "def validate_fake_pos_with_previous_turn_data( turn )\n if @data[ turn-1 ]\n @data[ turn ][ :fake_pos ] = @data[ turn ][ :fake_pos ] & cities_around_last_spotted_cities( turn )\n end\n end", "def available_moves\n adjacent_tiles(*@hole)\n end", "def _available_moves(location, distance, moves)\n\t\t\treturn if (distance < 0)\n\t\t\t\n\t\t\t#calc\n\t\t\treturn if (@map[location.to_s].nil?)\n\t\t\t#return if (@map[location.to_s].get_name() == \"empty\")\n\t\t\t\n\t\t\tsector = @map[location.to_s];\n\t\t\tdifficulty = sector.get_infantry_moves()\n\t\t\tnew_distance = distance-difficulty;\n\t\t\t\n\t\t\t#Special unmovable case\n\t\t\treturn if (difficulty == -1)\n\t\t\t\n\t\t\tmoves[location.to_s] = distance;\n\t\t\t\n\t\t\tcircle = get_circle(location, 1)\n\t\t\tcircle.each do |l|\n\t\t\t\tif !moves.has_key?(l.to_s)\n\t\t\t\t\t_available_moves(l, new_distance, moves);\n\t\t\t\telsif (moves.has_key?(l.to_s) && moves[l.to_s] < new_distance)\n\t\t\t\t\tmoves.delete(l.to_s);\n\t\t\t\t\t_available_moves(l, new_distance, moves)\n\t\t\t\tend\n\t\t\tend\n\t\tend", "def on_player_walk\n @result.clear\n check_floor_effect\n if $game_player.normal_walk?\n turn_end_on_map\n states.each {|state| update_state_steps(state) }\n show_added_states\n show_removed_states\n end\n end", "def move\n # Choose a random cell\n # JAVI: Extend this part of the method to choose cell with lower number of surveys (on average)\n cell = cells_around(@loc).rand\n \n # possibly a good location\n # first look ahead \n if !touches_path? cell, @path, @loc \n \n # do 1 more look ahead for each further possible step to avoid this:\n #\n # . . . . .\n # v < < . .\n # v . ^ . .\n # v . ^ < .\n # v . x o .\n # v x ? x .\n # > > ^ . .\n # . . . . . \n #\n # ^v<> = path\n # o = start\n # ? = possible good looking next move\n # x = shows that this is a dead end. All further steps are not allowed.\n #\n # Therefore, if any further step from cell is possible, then we're good to go\n \n # Configure future\n future_path = @path.dup\n future_path << cell\n second_steps = cells_around(cell)\n \n # If at least one of the future steps is valid, go for it\n second_steps.each do |ss|\n if !touches_path? ss, future_path, cell\n @path << cell\n @loc = cell\n @distance -= 1 \n return true\n end\n end \n end \n \n Rails.logger.debug \"*****************\"\n Rails.logger.debug \"Location: #{@loc.to_s}, New move: #{cell.to_s}.\"\n Rails.logger.debug \"Path: #{@path.to_s}\" \n \n false \n #cells = Cell.all :conditions => \"(x = #{@x-1} AND y = #{@y}) OR (x = #{@x+1} AND y = #{@y}) OR (x = #{@x} AND y = #{@y-1}) OR (x = #{@x} AND y = #{@y+1})\",\n # :order => \"positive_count + negative_count ASC\"\n \n # if all the cells have already been surveyed, weight index to those with few surveys \n #if cells.size == 4\n # i = rand(3)\n # i = (i - (i * 0.1)).floor \n # @x = cells[i].x\n # @y = cells[i].y\n # return\n #end\n \n # if there are empty cells, make a new cell where there's a gap and use that \n #[@x, @y-1] *<-- ALWAYS GOING DOWN\n #existing_cells = cells.map {|c| [c.x, c.y]}\n #survey_cell = (possible_cells - existing_cells).rand\n end", "def calculate_changes(grid, empty_if_greater, occupied_counter)\n grid.points.keys.each_with_object({}) do |coordinate, changes|\n seat_state = grid.at(coordinate)[:state]\n if seat_state != State::FLOOR\n occupied_count = occupied_counter.call(grid, coordinate)\n changes[coordinate] = State::OCCUPIED if occupied_count == 0 && seat_state == State::EMPTY\n changes[coordinate] = State::EMPTY if occupied_count >= empty_if_greater && seat_state == State::OCCUPIED\n end\n end\nend", "def get_incompletely_covered_alts(d)\n return @state_to_incompletely_covered_alts_map.get(d)\n end", "def done?(state)\n legal_moves(state).empty?\n end", "def each_clap_reachable_state\n if @clap_reachable.nil?\n # Set to avoid duplicates.\n @clap_reachable = Set[]\n player = @players[@turn]\n opponent_num = (@turn + 1) % 2\n opponent = @players[opponent_num]\n\n # Clap rules.\n for source_hand in [Left, Right] do\n target_hand = (source_hand == Left ? Right : Left)\n # The first line is the number that can be removed from the source.\n # The second is the number that can be added to the target without\n # killing it.\n max_transfer = [player[source_hand],\n (FingersPerHand - player[target_hand] - 1)].min\n (1..max_transfer).each do |i|\n # skip transfers that just flip the hands\n next if (player[source_hand] - i) == player[target_hand]\n\n p = player.clone\n p[source_hand] -= i\n p[target_hand] += i\n if @turn == Player1\n @clap_reachable << State.new(p, opponent.clone, opponent_num, self)\n else\n @clap_reachable << State.new(opponent.clone, p, opponent_num, self)\n end\n end\n end\n end\n\n @clap_reachable.each { |r| yield r }\n end", "def state_dist\n senator = Legislator.select(\"state\").where(\"title = 'Sen'\").where(\"in_office = '1'\").group(\"state\").count\n rep = Legislator.select(\"state\").where(\"title = 'Rep'\").where(\"in_office = '1'\").group(\"state\").count\n\n rep = rep.sort_by {|key,value| value}.reverse!\n\n\n rep.each do |key, value|\n \"#{key}: \" \"#{senator[key]} Senators, #{value} Representative(s)\"\n end\n\nend", "def state_options\n \n \n [\n ['Alabama', 'AL'],\n ['Alaska', 'AK'],\n ['Arizona', 'AZ'],\n ['Arkansas', 'AR'],\n ['California', 'CA'],\n ['Colorado', 'CO'],\n ['Connecticut', 'CT'],\n ['Delaware', 'DE'],\n ['District of Columbia', 'DC'],\n ['Florida', 'FL'],\n ['Georgia', 'GA'],\n ['Hawaii', 'HI'],\n ['Idaho', 'ID'],\n ['Illinois', 'IL'],\n ['Indiana', 'IN'],\n ['Iowa', 'IA'],\n ['Kansas', 'KS'],\n ['Kentucky', 'KY'],\n ['Louisiana', 'LA'],\n ['Maine', 'ME'],\n ['Maryland', 'MD'],\n ['Massachusetts', 'MA'],\n ['Michigan', 'MI'],\n ['Minnesota', 'MN'],\n ['Mississippi', 'MS'],\n ['Missouri', 'MO'],\n ['Montana', 'MT'],\n ['Nebraska', 'NE'],\n ['Nevada', 'NV'],\n ['New Hampshire', 'NH'],\n ['New Jersey', 'NJ'],\n ['New Mexico', 'NM'],\n ['New York', 'NY'],\n ['North Carolina', 'NC'],\n ['North Dakota', 'ND'],\n ['Ohio', 'OH'],\n ['Oklahoma', 'OK'],\n ['Oregon', 'OR'],\n ['Pennsylvania', 'PA'],\n ['Puerto Rico', 'PR'],\n ['Rhode Island', 'RI'],\n ['South Carolina', 'SC'],\n ['South Dakota', 'SD'],\n ['Tennessee', 'TN'],\n ['Texas', 'TX'],\n ['Utah', 'UT'],\n ['Vermont', 'VT'],\n ['Virginia', 'VA'],\n ['Washington', 'WA'],\n ['West Virginia', 'WV'],\n ['Wisconsin', 'WI'],\n ['Wyoming', 'WY']\n ]\n \n \n end", "def get_state(division)\n challenge_states.find_by(division: division).state\n end", "def get_captives_info\n @captives = 0\n @captives_direction = Array.new\n warrior.listen.each do |unit|\n if Captives.include? unit.to_s.to_sym\n @captives += 1\n @captives_direction.push warrior.direction_of(unit)\n end \n end\n return false\n end", "def getGuess\n \n # choose a random card from the lists of potential right cards.\n personOfGuess = rand(@listOfAllSuspects.length)\n placeOfGuess = rand(@listOfAllLocations.length)\n weaponOfGuess = rand(@listOfAllWeapons.length)\n \n # if the there are only 3 cards in the 3 lists, then there is only one possibility of the right answer, so it is an accusation.\n if( @listOfAllSuspects.length == 1 && @listOfAllLocations.length == 1 && @listOfAllWeapons.length == 1 ) \n isAccusation = true\n else\n isAccusation = false\n end\n \n return Guess.new(@listOfAllSuspects[personOfGuess], @listOfAllLocations[placeOfGuess], @listOfAllWeapons[weaponOfGuess], isAccusation)\n \n end", "def winning_state_for_next_move?\n # for each possible move that could be made:\n # return true if the move leaves a losing_state_for_next_move for the opponent\n # else\n # false\n # end\n\n\n # a player can win with one move\n # / there is a move that makes true losing_state_for_next_move\n\n # if you can set up 1,1,1 by making your move, it's a winning move\n end", "def active_sen \n\tstates = Legislator.uniq.pluck(:state) #print out the state if pluck only will print out multiple same state like \"CA\"\n\t#ordering of state begin \n\tarray_of_count = []\n states.each do |state|\n array_of_count << [state, Legislator.where(state: state).count]\n states.each do |state|\n puts \"#{state}: #{ Legislator.where(title: \"Sen\", state: state).count}\"+ \" Sen\" + \" #{ Legislator.where(title: \"Rep\", state: state).count }\" + \" Rep\"\n end \n end\nend", "def game_state\n\t\t\"YOURTURN #{self.current_round} #{@hunter.to_state}, #{@prey.to_state}, W[#{@walls.map{|w| w.to_state}.join(\", \")}]\"\n\tend" ]
[ "0.64507663", "0.5898442", "0.5871546", "0.586736", "0.586736", "0.586736", "0.58284676", "0.5805894", "0.578024", "0.5776026", "0.564541", "0.5641445", "0.5616097", "0.56159776", "0.560865", "0.55902314", "0.55793357", "0.5564589", "0.5541524", "0.5535891", "0.55353767", "0.5516044", "0.55065155", "0.54981816", "0.54976195", "0.54931337", "0.5489854", "0.5480358", "0.54467106", "0.5445686", "0.54396826", "0.5433292", "0.5401847", "0.53823644", "0.53822476", "0.5359409", "0.53565204", "0.5354324", "0.53369766", "0.53238714", "0.53214717", "0.5320291", "0.53146684", "0.5311042", "0.5309033", "0.5301925", "0.53018206", "0.5283042", "0.5262686", "0.52581084", "0.524889", "0.52423525", "0.52387947", "0.52381283", "0.52379787", "0.5236671", "0.52356243", "0.52353936", "0.5227086", "0.5221581", "0.52193075", "0.5217634", "0.5208227", "0.5202106", "0.51989627", "0.51960737", "0.5193723", "0.51935124", "0.518942", "0.51829416", "0.51745087", "0.5165822", "0.51651293", "0.51650363", "0.5154653", "0.5146488", "0.51449937", "0.5143699", "0.51403874", "0.5137101", "0.512456", "0.51189685", "0.51110435", "0.5109771", "0.5109215", "0.51080656", "0.5104631", "0.5097731", "0.5093597", "0.5078778", "0.5075202", "0.5073489", "0.50707936", "0.506753", "0.50647646", "0.5063245", "0.5061535", "0.5053484", "0.5050439", "0.5048802", "0.5044138" ]
0.0
-1
1. For each cohort, display the cohort name and the amount of students like so. It's probably best that you create a method.
def display_list(students) students.each { |key, value| puts "#{key}: #{value} students" } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cohort_list(list)\n\tlist.each do |cohort, num_of_students|\n\t\tputs \"#{cohort}: has #{num_of_students} students\"\n\tend\nend", "def display(students)\n students.each {|cohort, number_of_students| puts \"#{cohort}: #{number_of_students} students\"}\n end", "def print_by_cohort\n cohorts = []\n @students.each do |student|\n unless cohorts.include? student[:cohort]\n cohorts << student[:cohort]\n end\n end\n cohorts.each do |month|\n puts \"#{month} cohort:\"\n students.each_with_index do |student, index|\n if student[:cohort] == month\n puts \"#{index + 1}. #{student[:name]}\"\n # print_student_data(student)\n end\n end\n end\nend", "def print_info_each_student\n list_cohorts\n @cohorts.each do |cohort|\n puts \"\\nStudents in the #{cohort} cohort\\n\".center(50)\n @students.each_with_index do |student_info, index|\n if cohort == student_info[:cohort]\n puts \"#{index+1}. #{student_info[:name]}\".center(50)\n plural = \"s\" if student_info[:pronoun] != \"they\"\n puts \"#{student_info[:name]} is #{student_info[:height]} tall, was born in #{student_info[:country]} and #{student_info[:pronoun]} like#{plural} #{student_info[:hobbies]}.\"\n end\n end\n end\nend", "def print_student_list\n @students.each do |student|\n puts \"#{student[:name]} (#{student[:cohort]} cohort)\".center(100)\n end\nend", "def display (students)\n students.each do |cohort, num|\n puts \"#{cohort}: #{num}\"\n end\nend", "def print_students_list\n @students.each_with_index do |student, index|\n puts \"#{index+1}. #{student[:name]} (#{student[:cohort]} cohort)\".center(@center_by)\n end\nend", "def print_student_list\n existing_cohorts = get_cohort_list\n existing_cohorts.each do |cohort|\n puts \"The students in the #{cohort.to_s} cohort are:\"\n @students.each do |student|\n if student[:cohort] == cohort\n puts student[:name]\n end\n end\n end\nend", "def cohorts_print #students #, existing_cohorts\n puts \"Students grouped by cohort:\"\n puts #spacer line\n #existing_cohorts = [] I DON'T NEED TO DECALRE IT FIRST\n existing_cohorts = @students.map {|student| student[:cohort]}.sort.uniq\n for i in (0..existing_cohorts.length-1)\n @students.map do |student|\n if student[:cohort] == existing_cohorts[i]\n cohortstr = student[:cohort].to_s.capitalize + \" Cohort\"\n puts \"#{cohortstr.ljust(20)} #{student[:name]} \"\n end #end if\n end #end do\n end #end for\n success\n #cohorts\nend", "def print_students_list\n\t@students.each do |student|\n\t\tputs \"#{student[:name]} (#{student[:cohort]} cohort)\"\n\tend\nend", "def print_student_list\n @students.each do |student|\n puts \"#{student[:name]} (#{student[:cohort]} cohort)\"\n end\nend", "def display_name(hash)\n\thash.each do |cohort,num|\n \t\tputs \"#{cohort}: #{num} students\"\n\tend \nend", "def print_students_list\n @students.each_with_index { |student, index| puts \"#{index + 1}. #{student[:name]} (#{student[:cohort]} cohort)\" }\nend", "def print_by_cohorts(students, cohort)\n students = students.select { |student| student[:cohort] == cohort}\n print(students)\nend", "def list_cohorts(students)\n students.each do |key, value|\n puts \"#{key} : #{value} students\"\n end\nend", "def print_student_list\n @students.sort_by! { |hash| hash[:cohort] }\n @students.each.with_index(1) do |student, index|\n puts \"#{index}. #{student[:name]} (#{student[:cohort]} cohort)\".center(100)\n end\nend", "def print_students(students)\n\tstudents.each_with_index do |student, index|\n\t\tputs \"#{index + 1}: \" + \"#{student[:name]}\".center(20) + \" (#{student[:cohort]} cohort)\"\n\tend\nend", "def print_by_cohort\n\n # for each month in the year (in order)\n Date::MONTHNAMES.each do |month|\n\n # find students in this months cohort\n list = @students.select {|name| name[:cohort] == month}\n\n # if the cohort is empty and skip_empty is true, skip\n if list.length == 0 then next\n\n # otherwise print cohort list\n else\n # print list\n print_header\n print_list(list)\n print_footer(list)\n end\n\n end\n\nend", "def print_student_list(students)\n puts \"Students:\"\n puts \"----------------\"\n students.each do |student|\n puts \"#{student[:name]}, Cohort: #{student[:cohort]}\"\n end\n puts \"Overall, we have #{students.count} students\"\nend", "def print_students_list\n\n if @students.empty?\n puts \"Villains Academy is empty. :(\".center(@width)\n puts\n return\n end\n\n @cohorts_list.each do |month|\n @students.each_with_index do |student, index|\n if student[:cohort] == month\n puts \" #{student[:name]} (##{index + 1}) \".center(@width,\"-\")\n puts \"Cohort: #{student[:cohort].capitalize}\".center(@width)\n puts \"Hero: #{student[:hero]}\".center(@width)\n puts\n end\n end\n end\n\nend", "def display_cohort_info\n puts '=========================================='\n puts @name\n puts \"Start Phase 0: #{@p0_start_date}\"\n puts \"Start Immersive: #{immersive_start_date}\"\n puts \"Graduate: #{graduation_date}\"\n puts \"Enrollment: #{self.num_of_students}\"\n puts \"Current Phase: #{currently_in_phase}\"\n end", "def print(students)\n students.each_with_index do |student, index|\n puts \" #{index + 1}. #{student[:name]} (#{student [:cohort]} cohort)\"\n end\nend", "def print(students, center_by)\n students.each_with_index do |student, index|\n puts \"#{index+1}. #{student[:name]} (#{student[:cohort]} cohort)\".center(center_by)\n end\nend", "def print(students)\n students.each { |student| puts \"#{student[:name].center(20)} (#{student[:cohort]} cohort)\"}\nend", "def print_students\n @students.each do |student|\n puts \" Name:\".ljust(11) + \"-\".center(8) + \"#{student[:name]}\"\n puts \" Cohort:\".ljust(11) + \"-\".center(8) + \"#{student[:cohort]}\"\n puts \"\"\n end\nend", "def print(students)\n\tstudents.each_with_index do |student,index|\n\t\tputs \"#{index+1}. #{student[:name]} (#{student[:cohort]} cohort)\"\n\tend\nend", "def print(students)\n students.each_with_index do |student, index|\n puts \"#{index+1}. #{student[:name]} (#{student[:cohort]} cohort)\"\n end\nend", "def print_student_list(students)\n\tstudents_by_cohort = students.sort_by {|a| a[:cohort]}\n\tstudents_by_cohort.each do |student|\n\t\tputs \"#{student[:name]} (#{student[:cohort]}) cohort\".center(@width)\n\tend\nend", "def display_students_in_diff_cohorts(list)\n\tlist.each {|key,value| puts \"#{key}: #{value} students.\"}\nend", "def print_by_cohort\n sorted_by_cohort = {}\n @students.each do |student|\n cohort = student[:cohort]\n students_name = student[:name]\n if sorted_by_cohort[cohort] == nil\n sorted_by_cohort[cohort] = []\n end\n sorted_by_cohort[cohort].push(student[:name])\n end\n puts \"Students sorted by cohort:\"\n sorted_by_cohort.each do |cohort, name_array|\n puts \"#{cohort} students:\"\n puts name_array\n end\nend", "def print_students_list\n @students.each.with_index do |student, index|\n puts \"#{(index + 1)}. #{student[:name]} (#{student[:cohort]} cohort)\"\n #@students.each do |student|\n #puts \"#{student[:name]} (#{student[:cohort]} cohort)\"\n end\nend", "def total_students(students)\n\ttotal = 0\n\tstudents.each do |cohort, number| \n\t\ttotal += number.to_i\n\tend\n\tputs total\nend", "def students_index\n @students.each.with_index(1) do |value, index|\n puts \"#{index}. #{value[:name]} (#{value[:cohort]} cohort)\".center(70)\n end\nend", "def list_cohorts\n @students.each do |student_info|\n if (@cohorts.include? (student_info[:cohort])) == false\n @cohorts << student_info[:cohort]\n end\n end\nend", "def print_cohort\n puts \"These are the current active cohorts:\".center(70)\n active_cohorts = @students.uniq { |student| student[:cohort] }\n active_cohorts.each do |entry|\n puts \"#{entry[:cohort]}\".center(70)\n end\n puts \"Enter a cohort start month to print students in that cohort\".center(70)\n cohort_to_print = STDIN.gets.strip.downcase.to_sym\n single_cohort = @students.select { |student| student[:cohort] == cohort_to_print }\n single_cohort.each do |student| \n puts \"#{student[:name]} (#{student[:cohort]} cohort)\".center(70)\n end\nend", "def print_students_list\n count = @students.count\n if count ==0\n puts \"There are no students to print.\".center(40)\n exit\n else\n\n n = 1\n while n <= count\n @students.map do |student|\n name = student[:name]\n cohortstr = student[:cohort].to_s.capitalize\n puts \"#{n.to_s.center(4)} #{name.ljust(30)} #{cohortstr}\"\n n +=1\n end #end of map do\n end #end of while\n puts #spacer line\n success\n end #end if\nend", "def print(students)\n\tstudents.each_with_index do |student, index|\n\t\tindex = 0\n\t\twhile index <= 4\n\t\tputs \"#{index +1} #{student[:name]} (#{student[:cohort]} cohort)\"\n\t\tend\n\tend\nend", "def print_students student_arr\n\tstudent_arr.each do |student|\n\t\tputs \"#{student[:name]} (#{student[:cohort]} cohort)\"\n\tend\nend", "def total(list)\n\ttotal_students = 0\n\tlist.map do |cohorts, size|\n\t\ttotal_students += size\n\tend\n\treturn total_students\nend", "def display_cohort(s)\n s.each do |k, v|\n puts \"#{k}: #{v}\"\n end\nend", "def display_cohort(s)\n s.each do |k, v|\n puts \"#{k}: #{v}\"\n end\nend", "def print(students)\n cohort_groups = {\n january: [],\n february: [],\n march: [],\n april: [],\n may: [],\n june: [],\n july: [],\n august: [],\n september: [],\n october: [],\n november: [],\n december: []\n }\n students.each do |student|\n cohort_groups[student[:cohort]].push(student[:name])\n end\n # Printing the results only if the array contains at least one element\n cohort_groups.each do |cohort, name|\n if name.length > 0\n puts \"The list of students for #{cohort} is:\"\n puts name\n else\n puts \"There are no students in #{cohort}.\"\n end\n end\nend", "def index\n @cohorts_students = CohortsStudent.all\n end", "def cohort()\n return @cohort\nend", "def co_hort(a)\n\n\n\ta.each {|b, c| puts \"#{b}\" + \" \" +\"#{c} students\"}\nend", "def index\n @cohort_students = CohortStudent.all\n end", "def print(students)\n sorted_students = {}\n students.each do |student|\n cohort = student[:cohort].to_s\n name = student[:name].to_s\n if !sorted_students[cohort]\n sorted_students[cohort] = [name]\n else\n sorted_students[cohort].push(name)\n end\n end\n sorted_students.each do |cohort, students|\n puts cohort.to_s.center(50)\n students.each do |student|\n puts student.to_s.center(50)\n end\n end \nend", "def print(students)\n cohort_array = []\n# Ex 8 - Print out students grouped by cohort.\n students.each do |s|\n cohort_array.push(s[:cohort])\n end\n cohort_array.uniq.each do |x|\n puts x\n students.each do |s|\n if s[:cohort] == x\n puts s\n end\n end\n end\n\n# Ex 4 - Replace each for while.\n# count = 0\n# while count < students.length\n # puts \"#{count + 1}. #{students[count][:name]} (#{students[count][:cohort]} cohort) #{students[count][:hobbies]}\".center(100) \n # count += 1\n# end\n\n# Ex 1 - Use each loop to print students\n# students.each_with_index do |student, index|\n # if student[:name].upcase[0] == 'D' && student[:name].length > 12 # Ex 2 & 3 - Print if begin 'D' & > 12 charachters.\n # puts \"#{index+1}. #{student[:name]} (#{student[:cohort]} cohort)\" # Ex 1 - Add number using each_with_index.\n # end\n# end\nend", "def print_cohort(month)\n\n puts \"All students on %s cohort\" % month\n print_list(@students.select {|name| name[:cohort] == month})\n\nend", "def print_students\n count = 0\n until count == @students.length\n counter = \"#{count + 1}.\"\n name = \"#{@students[count][:name]}\"\n cohort = \"#{@students[count][:cohort]} cohort\"\n hobby = \"#{@students[count][:hobbies]}\"\n country = \"#{@students[count][:country_of_birth]}\"\n puts counter.center(5) + name.center(15) + cohort.center(15) + hobby.center(15) + country.center(15)\n count += 1\n end\nend", "def cohort\n return @cohort\n end", "def print(students)\n students.select { |student_info| student_info[:name][0] == \"C\" }.each_with_index { |student_info, index| puts \"#{index+1}. #{student_info[:name]}, (#{student_info[:cohort]} cohort)\" }\nend", "def print_with_index(students)\n\tstudents.each_with_index do |student, index| \n\t\tputs \"#{index}. #{student[:name]} (#{student[:cohort]} cohort)\"\n\tend\nend", "def print_with_index\n @students.each_with_index do |student, index|\n puts \"#{index+1} #{student[:name]} (#{student[:cohort]} cohort)\"\n end\nend", "def print(students)\n i = 0\n until i == students.length\n puts \"#{i+1}. #{students[i][:name]}, (#{students[i][:cohort]} cohort)\"\n i += 1\n end\nend", "def index \n @cohorts = Cohort.all\n \n end", "def names_by_cohort\n @students.sort_by { |student| student[:cohort] }\nend", "def index\n @cohorts = Cohort.all\n end", "def teach(cohort) #check what happens with an arrage\n cohort.each {|student| student.learn } #this will put learn into each\n end", "def print_footer\n puts \"\\nOverall, we have #{@students.length} #{pluralize(\"student\")} in all cohorts\"\nend", "def inclu (list, cohort, students)\n list[cohort] = students\n display(list)\nend", "def print_students_list\n counter = 0\n until counter == @students.length\n puts \"#{counter + 1}. #{@students[counter][:name]} (#{@students[counter][:cohort]} cohort, hobby: #{@students[counter][:hobby]}, country of birth: #{@students[counter][:birth_country]})\".center(100)\n counter += 1\n end\nend", "def loop_print(students, center_by)\n #commenting\n i = 0\n while i<students.length\n student = students[i]\n puts \"#{i+1}. #{student[:name]} (#{student[:cohort]} cohort)\".center(center_by)\n i+=1\n end\nend", "def print1(student)\n\ti=1\n\t\tstudent.each do |element|\n\t\tputs \"#{i}. #{element[:name]}, #{element[:age]}, (of the #{element[:cohort]} cohort)\" \n\t\ti+=1\t\nend\nend", "def initialize(student_name, cohort)\n @student_name = student_name\n @cohort = cohort\n end", "def cohorts (a)\n a.each do |k, v|\n puts \"#{k}: #{v}\"\n end\nend", "def create_cohort(n)\n $cohort = Array.new\n i = 1\n (n).times do\n\t\t$cohort.push(\"Person \"+ i.to_s)\n\t\ti += 1\n\tend\n return $cohort\nend", "def print(students)\n students.each do |student|\n puts \"#{student[:name]}, (#{student [:cohort]} cohort), Place of birth: #{student[:country]}, Favourite hobby: #{student[:hobby]}\"\n end\nend", "def index\n\t\t@students = Student.all.order(:created_at)\n\t\t@cohorts = Cohort.all\n\t\t\n\tend", "def create_cohort(n)\n $cohort = Array.new\n i = 1\n (n).times do\n $cohort.push(\"Person \"+ i.to_s)\n i += 1\n end\n puts $cohort\nend", "def print(students)\n # creating an if statement to tell the program to print only if there is at least one student\n if students.count > 0 \n puts students.group_by {|student| student[:cohort]}\n .each {|cohort, students| students.map!{|single_student| single_student = (single_student[:name])}}\n .flatten\n end\nend", "def print_student_list\n #print the list if there is at least one student in there\n if @students.count > 0\n @students.each do |student|\n puts \"Name = #{student[:name]} (#{student[:cohort]} cohort), hobby = #{student[:hobby]}, Country = #{student[:country]}\".center(80)\n end\n end\nend", "def print_cohort(input_hash)\n input_hash.each do |k, v|\n puts \"#{k}: #{v} students\"\n end\nend", "def print(students)\n\n months = [\"January\", \"Febuary\", \"March\", \"April\", \"May\", \"June\", \"July\", \"August\", \"September\", \"October\", \"November\", \"December\"]\n\n if @students.count > 0\n #prints list of students\n months.each do |month|\n puts month + \" Cohort:\"\n\n\n @students.each do |student|\n if student[:cohort] == month.to_sym\n\n puts \"Name: #{student[:name]}\\n\n COB: #{student[:cOb]}\\n\n Height: #{student[:height]}\\n\n Hobbies: #{student[:hobbies]}\\n\n Cohort: #{student[:cohort]}\"\n end\n end\n end\n end\nend", "def test_student_cohort\n student = CodeclanStudent.new(\"Harjit\",\"g6\")\n assert_equal(\"g6\", student.cohort)\n end", "def print_while(students)\n index = 0\n while index < students.size\n puts \"#{students[index][:name]} (#{students[index][:cohort]} cohort)\"\n index += 1\n end\nend", "def print_students_centered student_arr\n\tstudent_arr.each do |student|\n\t\tputs \"#{student[:name]} (#{student[:cohort]} cohort)\".center(100)\n\tend\nend", "def cohort_student_assignments\n StudentAssignment.joins(:student).where(student: self.students)\n end", "def all_cohorts (hash_value)\n total_students = hash_value.each_value.reduce(:+)\n puts total_students\nend", "def index\n render json: serializer_class.new(paginate(ecf_schools), params: { cohort: }).serializable_hash.to_json\n end", "def test_student_cohort()\n student = Student.new(\"Raphael\", \"E23\")\n assert_equal(\"E23\", student.cohort())\n end", "def print_while(students)\n i = 0\n while i < students.length do\n puts \"#{i + 1}. #{students[i][:name]} (#{students[i][:cohort]} cohort)\"\n i += 1\n end\nend", "def print(students)\n months = ['january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december']\n\n months.map do |month|\n students.map do |student|\n if (student[:cohort].downcase == month)\n puts \"#{student[:name]}\".center(20) + \"#{student[:age]}\".center(20) + \"#{student[:nationality]}\".center(20) + \"(#{student[:cohort]} cohort)\"\n end\n end\n end\nend", "def cohortfilter\n puts \"Please find students by cohort below:\"\n cohort_months = @students.map { |month| month[:cohort]}\n cohort_months.uniq!\n cohort_months.each do |month|\n puts \"Here are the #{month} students\"\n selected_students = @students.select { |student| student[:cohort] == month}\n list(selected_students)\n end\nend", "def test_student_cohort_fetch\n assert_equal(\"G17\", @student.get_cohort)\n end", "def set_student_cohort(cohort)\n @cohort = cohort\n end", "def print_line(student, index)\n cohort_merge = \"(\" + student[:cohort].to_s + \" cohort)\"\n index_string = (index+1).to_s + \".\"\n puts \"#{index_string.to_s.center(3)} #{student[:name].center(30)} #{cohort_merge.center(20)}, Hobbies:#{student[:hobbies].to_s.center(30)}, COB:#{student[:cob].to_s.center(10)}, Height:#{student[:height].to_s.center(6)}\"\nend", "def index\n @cohort_fellows = CohortFellow.all\n end", "def cohorts\n # participants.find(:all, :select => [:grad_year]).collect(&:grad_year).uniq.compact.sort.reverse\n @cohorts ||= participants.find(:all, :select => \"DISTINCT grad_year\").collect(&:grad_year).compact.sort.reverse\n end", "def show\n render json: serializer_class.new(ecf_school, params: { cohort: }).serializable_hash.to_json\n end", "def show \n @cohort = Cohort.find(params[:id])\n end", "def index\n @cohort_instructors = CohortInstructor.all\n end", "def index\n @cohort_users = CohortUser.all\n end", "def print_students_list\n # sorting the students by their cohort (exercise 8)\n # students = students.sort_by {|name, cohort| cohort}\n number = 0\n # sorts the students by cohort (exercise 8)\n @students = @students.sort_by {|student| student[:cohort]}\n #Replacement for the each() method using a while loop (exercise 4)\n while number < @students.length\n #students.each do |student|\n # tracks the number of times the do loop has been run (exercise 1 & 4)\n student = @students[number]\n number = number + 1\n # sets the variable to the letter being look for at the start of the names (exercise 2)\n #letter = \"D\"\n # checks to see if the current name being checked in the students array starts with the letter from the line before this one (exercise 2)\n #if student[:name][0] == letter\n # only prints the students info if their name is shorter than 12 characters (exercise 3)\n #if student[:name].length <= 12\n # Some changes from exercise 5 printing out the extra information (exercise 5)\n puts \"#{number}. #{student[:name]} (#{student[:cohort]} cohort).\"# Hobbies: #{student[:hobbies]}, Place of Birth: #{student[:country]}, Height: #{student[:height]}\"\n #end\n #end\n end\nend", "def sum_cohorts(users)\n sums = []\n # initialize the expected number of cohorts\n (1..current_cohort).each do |cohort|\n sums[cohort] = 0\n end\n\n users.each do |user|\n user_id = user[0]\n cohort = user[1]\n sums[cohort] = 0 if sums[cohort].nil?\n if match_user_id?(user_id)\n sums[cohort] += 1\n end\n end\n\n return sums\n end", "def print_students_idx student_arr\n\tstudent_arr.each_with_index do |student, index|\n\t\tputs \"#{index}: #{student[:name]} (#{student[:cohort]} cohort)\"\n\tend\nend", "def list\n @course = find_course_by_slug(params[:id])\n cohort = Cohort.find_by(title: cohort_params[:title])\n unless cohort\n render json: {\n message: \"Sorry, #{cohort_params[:title]} is not a valid cohort.\"\n }, status: 404\n return\n end\n ListCourseManager.new(@course, cohort, request).manage\n end", "def print_header(cohort_sym)\n\tputs \"The students of #{cohort_sym.to_s} cohort at Makers Academy\".center(get_winsize)\n\tputs \"-----------\".center(get_winsize)\nend", "def print(students)\n students.each do |student|\n if student[:name].capitalize.match(/^P/)\n puts \"#{student[:name]} (#{student[:cohort]} cohort)\"\n end\n end\nend", "def index\n\t\tauth_producer\n\t\t@cohorts = @current_user.cohorts\n\tend", "def list(selection)\n\tselection.each_with_index do |student, x|\n\t\tprint x + 1\n\t\tputs \" #{student[:name].center(30)} \" + \" #{student[:cohort].center(25)}\" + \" #{student[:birth].center(20)}\" + \" #{student[:hobby].center(25)}\"\n\tend\nend" ]
[ "0.81365526", "0.79392177", "0.7832763", "0.77592695", "0.77164316", "0.76646787", "0.7601162", "0.75691086", "0.7547328", "0.74216574", "0.7371336", "0.73452514", "0.7343272", "0.7287619", "0.72631973", "0.7256217", "0.72309494", "0.72196174", "0.7211941", "0.7198243", "0.7192045", "0.7161163", "0.7152807", "0.71507794", "0.71492875", "0.71373534", "0.7134461", "0.71211195", "0.71129644", "0.7077289", "0.70610094", "0.69863105", "0.6981346", "0.697774", "0.69593924", "0.69591236", "0.6930308", "0.6929888", "0.6917384", "0.68998444", "0.68998444", "0.6889022", "0.6880823", "0.6864281", "0.6854392", "0.68412757", "0.6839189", "0.6834526", "0.6826401", "0.6810602", "0.6786331", "0.67314553", "0.6681259", "0.66504014", "0.6650272", "0.6639686", "0.66360515", "0.66325694", "0.6631502", "0.6627503", "0.66094863", "0.6607148", "0.65929615", "0.6576282", "0.6571563", "0.6571366", "0.65667135", "0.6566129", "0.65600824", "0.6559554", "0.65509206", "0.65377194", "0.65236527", "0.65196204", "0.6491208", "0.64894205", "0.64816993", "0.6481308", "0.6469459", "0.64554805", "0.6453646", "0.64533496", "0.6430623", "0.6413703", "0.6413109", "0.64114255", "0.640512", "0.6400512", "0.63915443", "0.6348378", "0.633687", "0.6334734", "0.63346916", "0.6298366", "0.6293772", "0.62936556", "0.6291912", "0.62743104", "0.62487334", "0.6189", "0.6187678" ]
0.0
-1
If optional block is given, it will be passed to the child class implementation of 'send'. The implementation can execute the block on a response to the published message
def publish(message, destination, code = nil, &blk) payload, sender = Gilmour::Protocol.create_request(message, code) send(sender, destination, payload, &blk) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def send_action &block\n @actions[:send] = block\n end", "def send msg\n @sending_socket.send(msg)\n\n if block_given? || @handler\n messages = response\n if !messages.nil?\n messages.each do |message|\n if block_given?\n yield message\n else\n @handler.handle message\n end\n end\n end\n end\n end", "def send selector, *arguments, &block\n message = Message.new(@receiver, selector, arguments, block, self)\n message = @before_send_message.call(message) if @before_send_message\n @__configure.call(message, self) if @__configure\n transport.send_message(message) # => result\n end", "def method_missing(*args, &block)\n if block_given?\n @message.send(*args, &block)\n else\n @message.send(*args)\n end\n end", "def send\n @sent_at = Time.now\n sender.publish(data, meta)\n self\n end", "def send_rpc &block\n @connection.send do |out|\n xml = Builder::XmlMarkup.new(:target => out, :indent => 1)\n xml.rpc 'message-id' => \"#{(@message_id += 1)}\" do\n block.call(xml)\n end\n end\n end", "def _send_message(msg, opts = {}, block = nil)\n if (block)\n # register callback for responses to 'mid'\n debug \"(#{id}) register callback for responses to 'mid: #{msg.mid}'\"\n @lock.synchronize do\n @context2cbk[msg.mid.to_s] = { block: block, created_at: Time.now }\n end\n end\n end", "def send_response\r\n if self.response.class.name == \"Proc\"\r\n return self.response.call\r\n end\r\n self.response\r\n end", "def method_missing(*args, &block)\n if block_given?\n message.send(*args, &block)\n else\n message.send(*args)\n end\n end", "def send\n puts \"a fake implementation of `send`\"\n end", "def response_block\n create_response_block\n end", "def response_block\n create_response_block\n end", "def send(args, &block)\n args = {\"obj\" => args} if !args.is_a?(Hash)\n \n my_id = nil\n raise \"No 'obj' was given.\" if !args[\"obj\"]\n str = Marshal.dump(args[\"obj\"])\n \n if args.key?(\"type\")\n type = args[\"type\"]\n else\n type = \"send\"\n end\n \n raise \"Invalid type: '#{type}'.\" if type.to_s.strip.length <= 0\n args[\"wait_for_answer\"] = true if !args.key?(\"wait_for_answer\")\n \n @out_mutex.synchronize do\n my_id = @out_count\n @out_count += 1\n \n if block\n if type == \"send\"\n if args[\"buffer_use\"]\n type = \"send_block_buffer\"\n @blocks[my_id] = {:block => block, :results => [], :finished => false, :buffer => args[\"buffer_use\"], :mutex => Mutex.new}\n else\n type = \"send_block\"\n end\n end\n end\n \n $stderr.print \"Writing #{type}:#{my_id}:#{args[\"obj\"]} to socket.\\n\" if @debug\n @out.write(\"#{type}:#{my_id}:#{str.length}\\n#{str}\")\n end\n \n #If block is broken it might never give us control to return anything - thats why we use ensure.\n begin\n if type == \"send_block\"\n loop do\n res = self.send(\"obj\" => my_id, \"type\" => \"send_block_res\")\n \n if res == \"StopIteration\"\n break\n elsif res.is_a?(Hash) and res.key?(\"result\")\n #do nothing.\n else\n raise \"Unknown result: '#{res}'.\"\n end\n \n block.call(res[\"result\"])\n end\n end\n ensure\n #Tell the subprocess we are done with the block (if break, exceptions or anything else like that was used).\n if type == \"send_block\"\n res = self.send(\"obj\" => my_id, \"type\" => \"send_block_end\")\n raise \"Unknown result: '#{res}'.\" if res != \"ok\"\n end\n \n if args[\"wait_for_answer\"]\n #Make very, very short sleep, if the result is almost instant this will heavily optimize the speed, because :sleep_answer-argument wont be used.\n sleep 0.00001\n return self.read_answer(my_id)\n end\n \n return {:id => my_id}\n end\n end", "def process! non_block=false\n @running = true\n while @running && (message = shift(non_block))\n @transport.send_message(message)\n end\n message\n end", "def message\n lambda do |data|\n return if public_conversation?(data.channel)\n response = resp(data)\n send_response(response, data)\n end\n end", "def publish(message, *arguments)\n block_given? and raise ArgumentError, _(\"blocks cannot be published\")\n\n count = arguments.count\n command = arguments.shift if arguments.first.is_a?(Razor::Data::Command)\n message.is_a? String or message.is_a? Symbol or\n raise TypeError, _(\"message is a %{class} where String or Symbol was expected\") % {class: message.class}\n\n # This will raise NameError if the message is not accepted locally,\n # which completes our contract of raising on error.\n arity = method(message).arity\n if arity < 0\n raise ArgumentError, _(\"variable number of arguments sending %{class}.%{message}\") % {class: self.class, message: message}\n elsif arity != count\n raise ArgumentError, _(\"wrong number of arguments sending %{class}.%{message} (%{count} for %{arity}\") % {class: self.class, message: message, count: count, arity: arity}\n end\n\n queue_name = '/queues/razor/sequel-instance-messages'\n if !arguments.empty? and arguments.first.is_a?(Hash) and arguments.first.has_key?('queue')\n queue_name = arguments.first.delete('queue')\n end\n # Looks good, publish it; EDN encoding has reasonably good fidelity\n # for transmitting Ruby values over the wire, and this allows us to\n # enforce that during sending.\n msg = {\n 'class' => self.class.name,\n 'instance' => self.pk_hash,\n 'message' => message,\n 'arguments' => arguments\n }\n if command\n command.store('pending') if command.id.nil?\n msg['command'] = command.pk_hash\n end\n fetch(queue_name).\n publish(msg, :encoding => :edn)\n\n return self\n end", "def run_respond(aCommand)\n run(aCommand) do |ch,stream,text|\n \tch[:state] ||= { :channel => ch }\n \toutput = yield(text,stream,ch[:state])\n \tch.send_data(output) if output\n end\nend", "def send\n response = @message.send\n @message = new_message\n unless response.success?\n raise ServiceError, response.raw\n end\n return response\n end", "def process( nonblock=false )\n process_data_requests\n\n if !nonblock || reader_ready?\n type, response = @session.wait_for_message\n\n unless ( dispatcher = MESSAGES[ type ] )\n raise Net::SSH::Exception,\n \"Unexpected response type '#{type}', (#{response.inspect})\"\n end\n\n dispatcher[:method].bind( self ).call( response )\n end\n\n self\n end", "def send_message(friend_object, bitch_object, &block)\n Message.new(self, friend_object, bitch_object).send(&block)\n end", "def send\n curate_text\n if @no_send\n self.print\n return\n end\n\n raise NotImplementedError.new(\"#{self.class.name}#send is an abstract method and must be implemented by a subclass.\")\n end", "def _send_request request, &block\n @response_waited[request.id] = block if block_given?\n send_data request.to_s + \"\\n\"\n request\n end", "def send(obj, &block)\n alive_check!\n\n #Sync ID stuff so they dont get mixed up.\n id = nil\n @send_mutex.synchronize do\n id = @send_count\n @send_count += 1\n end\n\n #Parse block.\n if block\n block_proxy_res = self.send(cmd: :spawn_proxy_block, id: block.__id__, answer_id: id)\n block_proxy_res_id = block_proxy_res[:id]\n raise \"No block ID was returned?\" unless block_proxy_res_id\n raise \"Invalid block-ID: '#{block_proxy_res_id}'.\" if block_proxy_res_id.to_i <= 0\n @proxy_objs[block_proxy_res_id] = block\n @proxy_objs_ids[block.__id__] = block_proxy_res_id\n ObjectSpace.define_finalizer(block, method(:proxyobj_finalizer))\n obj[:block] = {\n id: block_proxy_res_id,\n arity: block.arity\n }\n end\n\n flush_finalized unless obj.fetch(:cmd) == :flush_finalized\n\n debug \"Sending(#{id}): #{obj}\\n\" if @debug\n line = Base64.strict_encode64(Marshal.dump(\n id: id,\n type: :send,\n obj: obj\n ))\n\n begin\n @answers[id] = Queue.new\n @io_out.puts(line)\n return answer_read(id)\n ensure\n #Be sure that the answer is actually deleted to avoid memory-leaking.\n @answers.delete(id)\n end\n end", "def send_body\n\t\t\tif @content\n\t\t\t\tsend_content\n\t\t\telsif @chunks\n\t\t\t\tsend_chunks\n\t\t\telsif @multiparts\n\t\t\t\tsend_multiparts\n\t\t\telse\n\t\t\t\t@content = \"\"\n\t\t\t\tsend_content\n\t\t\tend\n\t\tend", "def recv_action &block\n @actions[:recv] = block\n end", "def method_missing selector, *arguments\n raise ArgumentError, \"block given\" if block_given?\n _log { \"method_missing #{selector.inspect} #{arguments.inspect}\" }\n request = Request.new(receiver, selector, arguments)\n result = transport.send_request(request)\n result\n end", "def execute\n previous_time = Time.now\n\n publish_message(message(@channel, @data))\n\n @response_time = (Time.now - previous_time) * 1000 # Miliseconds\n @response_code = 1\n rescue Exception => e\n @response_code = @response_time = nil\n @response_body = e.message\n end", "def send_message(&block)\n timestamp = Time.now.to_f\n # Throttled messages are disregarded\n if @messages.empty? || !throttle?(timestamp, @messages.last[:timestamp])\n thread = ::MMPlayer::Thread.new(&block)\n record_message(thread, timestamp)\n end\n end", "def forge\n message.set_response(::Item.forge(command_string.subject, message.sender))\n end", "def _send_message data\n response << data\n end", "def response(&_)\n if block_given?\n @response ||= Response.new\n yield @response\n end\n @response\n end", "def call(&block)\n # RODA4: Remove\n catch(:halt) do\n r = @_request\n r.block_result(instance_exec(r, &block)) # Fallback\n @_response.finish\n end\n end", "def deliver(message)\n raise NotImplementedError\n end", "def send(*rest) end", "def send(*rest) end", "def send(*rest) end", "def send_raw(message)\n @handler.send_raw message\n end", "def on(name, &block)\n define_sending_method(name)\n define_receiving_method(name, &block)\n end", "def execute\n yield self if block_given?\n end", "def send_pending; end", "def run_respond(aCommand)\n\t\trun(aCommand) do |ch,stream,text|\n\t\t\tch[:state] ||= { :channel => ch }\n\t\t\toutput = yield(text,stream,ch[:state])\n\t\t\tch.send_data(output) if output\n\t\tend\n\tend", "def send_method\n <<-CODE\n next_literal_into(msg.send_site);\n msg.recv = stack_pop();\n msg.block = Qnil;\n msg.args = 0;\n goto perform_send;\n CODE\n end", "def send(body=nil, &block)\n\t\t\traise RuntimeError, 'Need to set request' if @request.nil?\n\t\t\t@body = condition.transform @xml if body.nil?\n\t\t\t@request.post(@body, &block) if block_given?\n\t\tend", "def modify_delivery\n return unless block_given?\n yield self.delivery_options\n end", "def send_class_message(method_name, return_type, *args, &b)\n @messenger.deliver_to_class(method_name, return_type, *args, &b)\n end", "def method_missing(method, *params, &block)\n @response.send(method, *params, &block)\n end", "def xsend (name, *args, &block)\n @messages << [name, args, block]\n end", "def raw_send(message)\n TalkerBase.instance.output << \"#{id} send #{message}\"\n end", "def execute(request, response, &_block)\n if block_given?\n yield request, response\n else\n execute_default(request, response)\n end\n end", "def send(message)\n ## empty\n end", "def set_message_handler(&block); end", "def raw\n raise \"ll-009: No block given to method\" unless block_given?\n yield client\n end", "def send_message(method_name, return_type, *args, &b)\n @messenger.deliver(method_name, return_type, *args, &b)\n end", "def deliver(*)\n true\n end", "def send(cmd, &block)\n cmd = cmd.to_h\n logger.debug(self.class) { \"CMD: #{cmd}\" }\n\n str = cmd.bencode\n logger.debug(self.class) { \"Encoded CMD: #{str}\" }\n\n @io.write(cmd.bencode)\n\n collect_responses(&block)\n end", "def publish!(payload, &block)\n add_transaction_headers(payload)\n return unless ensure_publish(payload)\n\n current_transaction ? current_transaction.add_payload(payload) : connector_publish(payload)\n block&.call\n payload\n rescue => e\n print_error(e, payload)\n raise\n end", "def on_delivery(&block)\n self.append_callback(:delivery, &block)\n end", "def call_block\n @_block.call(self) if @_block\n end", "def publish(node, message, host, &block)\n pubsub.publish(node, message, host, &callback_logging(__method__, node, message.operation, &block))\n end", "def request(message, response_size = 0, &the_block)\n @q.push([message, response_size, the_block])\n end", "def on_response request, response, block\n block.call(response.name, response.params)\n end", "def method_missing(name, *args, &block)\n self.receiver.send name, *args, &block\n end", "def send!\n @_sended = true\n self\n end", "def execute(&block)\n\tblock\nend", "def execute(&block)\n\tblock\nend", "def send_message(message); end", "def send_message(message); end", "def listen(&block)\n AMQP.start(:host => @host) do\n exchange = MQ.direct(@x_request)\n reply = MQ.direct(@x_response)\n queue = MQ.queue(@server_q)\n notify = MQ.fanout(@x_notify)\n \n puts \"request xchange =#{@x_request}\"\n puts \"reply xchange =#{@x_response}\"\n puts \"server queue =#{@server_q}\"\n \n @do_notify = proc do |msg|\n notify.publish(Blix.to_binary_data(msg))\n puts \"[AmqpServer] notify: message=#{msg}\" if $DEBUG\n end\n \n queue.bind( exchange).subscribe do |header,body|\n \n # extract the headers and create a transport for this\n # client. the reply_to field may be in the application\n # headers field so check for it there also.\n \n reply_to = header.reply_to || ( header.headers && header.headers[:reply_to])\n message_id = header.message_id || ( header.headers && header.headers[:message_id])\n \n if reply_to && message_id\n # process the call\n response = block && block.call(body)\n \n # publish the reply only if there is a response\n \n if response\n options = {}\n options[:key] = reply_to\n options[:message_id] = message_id\n data = Blix.to_binary_data(response)\n \n puts \"[AmqpServer] response: data=#{data}, options=#{options}\" if $DEBUG\n \n reply.publish(data, options )\n end\n else\n puts \"missing reply-to /message_id field .....#{header.inspect}\"\n end\n end\n \n# # send any notifications that are waiting.\n# while !@notify_queue.empty?\n# message = @notify_queue.pop\n# channel.fanout(@x_notify).publish(Blix.to_binary_data(message))\n# puts \"[AmqpServer] notify: message=#{msg}\" if $DEBUG\n# end\n end\n \n end", "def dispatch(&block)\n @dispatch_block = block\n end", "def listen(&block)\n while @_run do\n request = @responder.recv #(ZMQ::NOBLOCK)\n if request\n response = block && block.call(request)\n @responder.send( response )\n end\n end\n end", "def by(message)\n if block_given?\n yield\n else\n pending message\n end\nend", "def run\n if @block.arity >= 1\n @block.call self\n else\n @block.call\n end\n end", "def send_message(message)\n raise NotImplementedError, 'Raw connections do not support send_message. Please subclass and define a send_message method.'\n end", "def deliver\r\n raise NotImplementedError.new(\"#{self.class.name}#deliver is not implemented.\")\r\n end", "def execute_action(tubesock, block)\n begin\n # Execute block\n block.call\n rescue Exception => e\n # Log the error\n Rails.logger.error e.message\n\n # Print stack strace\n puts e.backtrace\n\n # Send error message to client\n tubesock.send_data({\n error: e.message\n }.to_json)\n end\n end", "def send(*args); __send__(*args); end", "def reply(*args, &block)\n self.rooms.each do |room|\n room.reply(*args, &block)\n end\n end", "def method_missing(message, *args, &block)\n subject.send(message, *args, &block)\n end", "def send(options={})\n end", "def send_pipeline_command(command, &block)\n with_command_shell(command) do |shell, cmd|\n response_reader.read_message(command_output_message(shell, cmd), true, &block)\n end\n end", "def on_each_response( &block )\n fail 'Block is mandatory!' if !block_given?\n @on_each_response_blocks << block\n self\n end", "def block_message_printer\n message = \"Welcome to Block Message Printer\"\n if block_given?\n proc.call\n end\n puts \"But in this function/method message is :: #{message}\"\n end", "def define_receiving_method(name, &block)\n self.class.send(:define_method, \"_#{name}\") do |*args|\n block.call(*args)\n end\n end", "def expect(&block)\n @block = block\n self\n end", "def stream_send(data)\n self[STREAM_SEND].call(data)\n end", "def send_data(&block)\n create_data do |data|\n tessen_api_request(data, &block)\n end\n end", "def execute_block(block)\n case\n when block.is_a?(Symbol)\n send(block)\n when block.respond_to?(:call) && (block.arity == 1 || block.arity == -1)\n block.call(self)\n else\n block\n end \n end", "def request(&block)\n self.with(&block)\n end", "def render\n if @block\n instance_eval(&@block)\n end\n end", "def send_request(method, params, &block); end", "def respond(response)\n @publisher.publish(response)\n end", "def set_message_handler &block\n @message_handler = block\n end", "def block\n\t\t\tif custom_block = super\n\t\t\t\treturn custom_block\n\t\t\telse\n\t\t\t\tpost_processor = \"post_process_%s\" % [ @pattern_name ]\n\t\t\t\treturn nil unless self.respond_to?( post_processor, true )\n\t\t\t\treturn self.method( post_processor )\n\t\t\tend\n\t\tend", "def publish message, &block\n if @channel == \"*\"\n raise ShoveException.new(\"Cannot publish to *\")\n elsif message.size > 2048\n raise ShoveException.new(\"Max message size is 2 KiB\")\n end\n @app.request(\"publish?channel=#{@channel}\").post(message, &block)\n end", "def write(&block)\n @write_block = block\n end", "def method_missing(message, *params, &block)\n # We only want to relay to public client methods.\n if self.respond_to?(message)\n return self.client.send(message, *params, &block)\n else\n raise NoMethodError,\n \"Undefined method '#{message}' for #{self.inspect}.\"\n end\n end", "def execute(&block)\n\tblock.call\nend", "def execute(&block)\n\tblock.call\nend", "def execute(&block)\n\tblock.call\nend", "def execute(&block)\n\tblock.call\nend", "def method_missing(name, *args, &block)\n response.body.send(name, *args, &block)\n end" ]
[ "0.6838609", "0.6531437", "0.651162", "0.64760154", "0.6300031", "0.62360877", "0.6232462", "0.6215255", "0.61379206", "0.61042744", "0.60513896", "0.60513896", "0.59684205", "0.5950558", "0.5918244", "0.5917582", "0.58880275", "0.58837336", "0.58770597", "0.5855661", "0.58431363", "0.5841145", "0.58037835", "0.5800125", "0.5799436", "0.57793593", "0.57562953", "0.57393336", "0.5722654", "0.5711714", "0.57009083", "0.57002467", "0.5699045", "0.56887484", "0.56887484", "0.56887484", "0.56880385", "0.5676066", "0.5666424", "0.56640995", "0.56497157", "0.5644752", "0.5644254", "0.56351274", "0.5616079", "0.5612314", "0.5609366", "0.5606575", "0.56055325", "0.5600267", "0.5598211", "0.5592235", "0.5584957", "0.55799484", "0.5573998", "0.5573488", "0.55674386", "0.5564822", "0.55626744", "0.5561844", "0.5536278", "0.55223924", "0.5520574", "0.5493443", "0.5493443", "0.5488324", "0.5488324", "0.54809743", "0.54777545", "0.54758024", "0.5475049", "0.54744434", "0.54693186", "0.5453925", "0.5452732", "0.5446131", "0.5437442", "0.54339236", "0.54323083", "0.54195833", "0.54177654", "0.54107136", "0.54073715", "0.5405101", "0.54037195", "0.54030555", "0.5402241", "0.5396327", "0.53920174", "0.5391211", "0.53886604", "0.5388457", "0.53687084", "0.5361475", "0.53602886", "0.53590995", "0.5358949", "0.5358949", "0.5358949", "0.53578216", "0.5356862" ]
0.0
-1
Para imagenes almacenadas en la dase de datos
def blob_to_base64 (photo) #Convierte de formato '/xFF' a Base64 para poder mostrar la foto en la vista return "data:image/jpeg;base64," + [photo].pack('m0') end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_img\n\n end", "def images; end", "def add_image \n image = CARMD.image(self.vin)\n if image == \"\"\n image = \"http://clipart-library.com/img/2050778.png\"\n end\n self.auto_image = image \n self.save \n end", "def set_imagen\n @objeto = Imagen.find(params[:id])\n end", "def comer\r\n # @image = Image[\"pez2.png\"]\r\n # Al comer, un pez tendrá x segundos mas de vida, y queda libre para buscar mas comida\r\n @vida_inicio += 2\r\n @libre = true\r\n end", "def update_imagem(foto_64)\n foto_64 = \"data:image/jpeg;base64,#{foto_64}\"\n if foto_64 != \"\" && foto_64 != nil\n base_64_encoded_data = foto_64\n string_img = Base64.decode64(base_64_encoded_data['data:image/png;base64,'.length .. -1])\n File.open(\"#{Rails.root}/tmp/motorista2.jpg\", \"wb\") do |file| \n file.write(string_img)\n file.size\n self.imagem = file\n end\n end\n end", "def images\n @images = super || []\n end", "def sepia\n @photo = Photo.find(params[:id])\n img = Magick::Image.read('public' + @photo.attachment_url).first\n img = img.sepiatone()\n img.write('public' + @photo.attachment_url)\n end", "def update_bitmap\n @effectus_old_name = @picture.name\n if @effectus_old_name.empty?\n self.bitmap = nil\n else\n self.bitmap = Cache.picture(@effectus_old_name)\n @effectus_center_x = bitmap.width / 2\n @effectus_center_y = bitmap.height / 2\n end\n end", "def set_image\n @image = Image.find(params[:id]).decorate\n end", "def images\n end", "def save_image(data)\n\t\timages = []\n\n\t\tdata[\"photos\"].each do |image|\n\t\t\tset = {\n\t\t\t\t:sol => image['sol'],\n\t\t\t\t:img_src => image['img_src'],\n\t\t\t\t:rover => image['rover']['name'].downcase,\n\t\t\t\t:camera_name => image['camera']['name'],\n\t\t\t\t:camera_full_name => image['camera']['full_name'],\n\t\t\t\t:earth_date => image['earth_date'],\n\t\t\t}\n\n\t \t\t#save to database\n\t \t\timg = Image.create(set)\n\t \t\timg.save\n\n\t \t\timages.push(set)\n\t\tend\n\n\t\treturn images\n \tend", "def picdata\n object.imgdata\n end", "def image; end", "def all_images(albid)\n kept_images(albid) + deleted_images(albid)\n end", "def images\n @images ||= {}\n end", "def set_img\n @img = Img.find(params[:id])\n end", "def adjuntar_imagen(klass, img)\n begin\n archivo = File.new(img)\n Adjunto.create( :archivo => archivo, :adjuntable_id => klass.id, :adjuntable_type => klass.class.to_s )\n rescue\n end\n end", "def images\n []\n end", "def guarda_fotos_todas\n dame_fotos_todas\n\n if x_foto_principal.present?\n a = adicional ? adicional.reload : Adicional.new(especie_id: id)\n a.foto_principal = x_foto_principal\n\n if a.changed?\n a.save\n reload\n end\n end\n end", "def imgs obj\n Image.find(obj.image_ids)\n end", "def image\n 0\n end", "def afficher\n @image.display\n end", "def image_hash; end", "def image\n\n end", "def getImaginario\n\t\treturn @i\n\tend", "def image\n end", "def image\n end", "def index\n @guardarios_img = GuardarioImage.last(9).reverse\n end", "def se\r\n db = ITestUtils.newdb\r\n db.store(test_image1,:name => 'orig-1.jpg' )\r\n db.fetch('orig-1.jpg',:width => 102)\r\n db.store(test_image1,:name => 'notfound-1.jpg' )\r\n db.store(test_image1,:name => 'notfound-2.jpg' )\r\n db\r\n end", "def sequence_images\n \n end", "def show\n @imgs = @guardario.guardario_images\n end", "def image=(img)\n @image__ = img\n end", "def set_adm_galerias_imagem\n @adm_galerias_imagem = Adm::GaleriasImagem.find(params[:id])\n end", "def update_bitmap\n if @picture.name.empty?\n self.bitmap = nil\n else\n self.bitmap = swap_cache(@picture.name)\n end\n end", "def image\n end", "def image\n end", "def charcoal\n @photo = Photo.find(params[:id])\n img = Magick::Image.read('public' + @photo.attachment_url).first\n img = img.charcoal(0.0, 1.0)\n img.write('public' + @photo.attachment_url)\n end", "def makeImage\n for i in 0...@width\n ti = 2.0*Math::PI*i/ImageWidth.to_f\n for j in 0...@height\n tj = 2.0*Math::PI*j/ImageHeight.to_f\n\n $image[3 * (@height * i + j)] = 127*(1.0 + Math::sin(ti))\n $image[3 * (@height * i + j) +1] = 127*(1.0 + Math::cos(2*tj))\n $image[3 * (@height * i + j) +2] = 127*(1.0 + Math::cos(ti+tj))\n end\n end\n end", "def update_bitmap\n if @picture.name.empty?\n self.bitmap = nil\n else\n self.bitmap = swap_cache\n self.mirror = false\n end\n end", "def image(key)\n return @data[key].clone\n end", "def image_data\n return @image_data unless @image_data.empty?\n\n validate_spreadsheet_file_list\n\n spreadsheet_data.map do |row_hash|\n sequence = Integer row_hash[PAGE_SEQUENCE].to_s.strip\n filename = row_hash[FILENAME]\n image = File.basename filename, File.extname(filename)\n toc = (row_hash[TOC_ENTRY] || '').split(%r{\\s*\\|\\s*}).map(&:strip)\n ill = (row_hash[ILL_ENTRY] || '').split(%r{\\s*\\|\\s*}).map(&:strip)\n data = {\n number: sequence,\n seq: sequence,\n image_defaultscale: 3,\n display: true,\n side: (sequence.odd? ? RECTO : VERSO),\n image_id: image,\n image: image,\n visiblepage: row_hash[VISIBLE_PAGE],\n toc: toc,\n ill: ill\n }\n @image_data << OpenStruct.new(data)\n end\n\n files_on_disk.reject {|f| spreadsheet_files.include? f }.each do |extra|\n sequence = @image_data.last.seq + 1\n image = File.basename extra, File.extname(extra)\n data = {\n number: sequence,\n seq: sequence,\n id: image,\n image_defaultscale: 3,\n side: (sequence.odd? ? RECTO : VERSO),\n image_id: image,\n image: image,\n visiblepage: nil,\n display: false,\n toc: [],\n ill: []\n }\n @image_data << OpenStruct.new(data)\n end\n\n @image_data\n end", "def math_images\n return metadata.math_images = MathImages.new([], id) unless metadata.math_images\n metadata.math_images.model_id = id if id && !metadata.math_images.model_id\n metadata.math_images\n end", "def set_producto_imagen\n @producto_imagen = ProductoImagen.find(params[:id])\n end", "def to_jpg\n load_image\n end", "def imaginary\r\n self.data.map(&:imaginary)\r\n end", "def set_image\n @escape_game = EscapeGame.find_by_id!(params[:escape_game_id])\n @image = @escape_game.images.find(params[:id])\n end", "def set_im\n @im = Im.find(params[:id])\n end", "def images\n if !@images\n @images = {}\n @images[:thumb] = self.thumb_image if self.thumb_image\n @images[:tiny_image] = self.tiny_image if self.tiny_image\n @images[:small] = self.small_image if self.small_image \n @images[:medium] = self.medium_image if self.medium_image\n @images[:large] = self.large_image if self.large_image\n end\n end", "def put_image(_x, _y, _image)\n @reacs[:images] << [_x, _y, _image]\n end", "def set_image_cashiero\n @image_cashiero = ImageCashiero.find(params[:id])\n end", "def set_imagen_articulo\n @imagen_articulo = ImagenArticulo.find(params[:id])\n end", "def set_dicomimage\n @dicomimage = Dicomimage.order('SSDICOMImageID asc').find(params[:id])\n end", "def add_image( id, image_name, x_position, speed, width, height )\n OSX::NSLog(\"Received image ##{id} (#{image_name})\")\n# image_name = OSX::NSBundle.mainBundle.pathForImageResource( image_name )\n image_name = \"/Users/alpha/src/cyberart/images/#{image_name}.jpg\"\n image = CAImage.new( id, image_name, x_position, speed, width, height )\n @semaphore.synchronize { temp_images = @images.dup }\n temp_images << image\n @semaphore.synchronize { @images = temp_images }\n end", "def blue_shift\n @photo = Photo.find(params[:id])\n img = Magick::Image.read('public' + @photo.attachment_url).first\n img = img.blue_shift(2)\n img.write('public' + @photo.attachment_url)\n end", "def set_image\n @image = Image.find(params[:id])\n end", "def rotate_image(image)\n\nend", "def view\n if belongs_to_user?(@good)\n @good_images = [@good.main_image] + Image.ad_images_of_good(@good)\n @good_images.flatten!\n else\n redirect_to root_path, alert: 'Это не ваша сохраненная вещь'\n end\n end", "def store_images\n self.images.each_key do |k|\n if self.send(\"store_#{k}\") == \"1\"\n if self.send(\"#{k}?\")\n image = Image.new\n image.image = self.send(k).to_file\n image.save\n end\n end\n end\n end", "def images\n @images ||= Hash.new\n end", "def profile_photo\n @profile = Profile.find(:all)\n \n for profile in @profile\n if !profile.profile_image.blank?\n original_image = RAILS_ROOT + \"/public/profile/profile_image/#{profile.id}/#{File.basename(profile.profile_image)}\"\n # main = RAILS_ROOT + \"/public/profile/profile_image/#{profile.id}/main/#{File.basename(profile.profile_image)}\"\n submain = RAILS_ROOT + \"/public/profile/profile_image/#{profile.id}/submain/#{File.basename(profile.profile_image)}\"\n image = Magick::ImageList.new(original_image) \n image = image.change_geometry!('171x171!') { |c, r, i| i.resize!(c, r) } \n image.write(submain) \n end \n end\n \n \n end", "def images\n @picturesandmeta = Pictureandmeta.all\n @kind = Kind.find(params[:kind_id])\n Rails.logger.info(\"Kind: #{@kind.inspect}\")\n end", "def change_image(&block)\n yield image\n @tempfile = nil\n @uri = nil # Once transformed, all external sources are invalid.\n @blob = nil # Once transformed, we need to reset the data. Now the getter can lazily load the blob.\n @persistent = false\n self\n end", "def rotate\n @photo = Photo.find(params[:id])\n img = Magick::Image.read('public' + @photo.attachment_url).first\n img = img.rotate(90)\n img.write('public' + @photo.attachment_url)\n end", "def imagen_params\n params.require(:imagen).permit(:orden, :imagen, :nota, :linea_id, :directorio_id)\n end", "def set_image\r\n @image = Image.find(params[:id])\r\n end", "def create_images\n problem_image = self.images.build\n File.open('./public/projects/problem_default.jpg') do |f|\n problem_image.image = f\n end\n\n solution_image = self.images.build\n File.open('./public/projects/solution_default.jpg') do |f|\n solution_image.image = f\n end\n\n team_image = self.images.build\n File.open('./public/projects/team_default.png') do |f|\n team_image.image = f\n end\n end", "def refresh\n # get arrow bitmap (picture folder)\n self.bitmap = RPG::Cache.picture(@type)\n # define width and height (32 x 32)\n @cw = self.bitmap.width\n @ch = self.bitmap.height\n update\n end", "def images=(image_path_hash)\n @normal_image = image_path_hash[:normal]\n @pressed_image = image_path_hash[:pressed]\n end", "def image( name )\n @images[name]\n end", "def subir_imagen=(file_data)\n\t\t#Se ejecuta solo si no esta vacio\n\t\tunless file_data.blank?\n\t\t\tputs \"FILEDATA: #{file_data}\"\n\t\t\t@file_data = file_data\n\t\t\t#Parte el archivo en 2 por el caracter '.' y coge la ultima parte\n\t\t\t# para luego convertirlo a minuscula\n\t\t\tself.imagen = file_data.original_filename.split('.').last.downcase\n\t\t\tputs \"IMAGEN: #{self.imagen}\"\n\t\t\t# self.imagen = \"#{id}.#{imagen}\"\n\t\tend\n\tend", "def show\n Dir.chdir \"#{Rails.root.join('public/')}\"\n\n #iteración de todos los usuarios en el arreglo @usuarios\n # creamos una variable que va a crear en string el nombre de la foto que se va a guardar\n # ej. user_image_23.png para el usuario con id 23\n saveName = \"business_image_#{@negocio.id}.png\"\n\n # abrimos el filestream para escritura con el nombre de la variable saveName\n fotoUsuario = File.open(saveName, 'wb') do |f|\n\n # el begin y rescue es el clásico try/catch\n begin\n # intentamos convertir los bytes que se reciben de la base de datos en encoding BASE64\n # y lo escribimos en el filestream usando decode64. Se guardaría en /public/user_image_23.png\n f.write(Base64.urlsafe_decode64(@negocio.imagen))\n\n # cambiamos el contenido de la propiedad foto para que no sea el arreglo de bytes sino el\n # nombre con el que quedó guardado en /public/\n @negocio.imagen=saveName\n\n # cerramos el stream\n f.close\n # si escribir la foto falla por algún motivo...\n rescue => ex\n # ignoramos lo que se haya jalado de la base de datos y ponemos de nombre una imagen genérica\n # esta imagen debe estar guardada eb /public/\n @negocio.imagen=\"default_user_image.png\"\n end\n end\n end", "def create\n @pic = params[:image][:image_url]\n puts \"---------------------------------datos-imagen------------------------------------------------------\"\n puts @pic.inspect\n puts \"---------------------------------------------------------------------------------------------------\"\n\n @gallery = Gallery.find(params[:image][:galery_id])\n @project2 = Project.find(@gallery.project_id)\n @gallery2 = Gallery.find(@gallery)\n\n unless @pic.blank?\n @pics = DataFile.save(@pic,@project2.name,@gallery2.title)\n end\n @image = Image.new(\"image_url\" => @pics, \"galery_id\" => params[:image][:galery_id])\n\n respond_to do |format|\n if secure_save(@image)\n format.html { redirect_to '/galleries/' + params[:image][:galery_id].to_s, notice: 'Image was successfully created.' }\n format.json { render :show, status: :created, location: @image }\n else\n format.html { render :new }\n format.json { render json: @image.errors, status: :unprocessable_entity }\n end\n end\n end", "def edit_real_picture\n end", "def set_main_image\n if self.is_main_image\n self.class.update_all(\"is_main_image = 0\", \"is_main_image <> 0 AND location_id = #{self.location_id} AND id <> #{self.id}\")\n end\n end", "def image idx=0\n @images[idx]\n end", "def add_image(pic, img_loc_text, stock_images=nil)\n pic.photo = File.open(Rails.root.join('db', 'images', get_stock_image(img_loc_text, stock_images)))\n pic\n end", "def update\n delImageId = Array.new(0)\n updateIds = Hash.new\n\n # :delete sends hash of delete requested ids\n # ids are of ImageData(not DesignData)\n updateIds = params[:delete]\n updateImage = ImageDatum.find(updateIds.keys)\n\n # for later use\n # file name should be same in all updateImages\n # so it should be ok just to get from the 1st one\n file_name = updateImage[0].file_name\n\n # if the updateIds value of image.id == 1,\n # set the delflag(user wants to delete it)\n updateImage.each {|image|\n if updateIds[image.id.to_s] == \"1\"\n image.delflag = true\n else\n image.delflag = false\n end\n image.save!\n }\n\n # image_data上、最新のseq_idの画像を削除する場合、\n # design_dataのcurSeq_idは、削除されてないimage_dataのseq_idの\n # 一番大きいデータと同期してないといけないので、\n # その処理をする\n updateDesignData = DesignDatum.find_by_file_name(file_name)\n curSeq_id = updateDesignData.curSeq_id\n\n # updateIds に0がある場合(userが削除したくない画像がある場合)\n if updateIds.has_value?(\"0\")\n\n # 削除されなくて、seq_id が一番大きいimage_data をselect\n recoverImage = ImageDatum.find_all_by_id_and_delflag(updateIds.keys, \"0\", :order => \"seq_id DESC\", :limit => \"1\")\n\n if curSeq_id != recoverImage[0].seq_id\n # image_dataの画像と、design_dataの画像は、thumbnailなら一緒!\n updateDesignData.thumbnail = recoverImage[0].thumbnail\n updateDesignData.curSeq_id = recoverImage[0].seq_id\n end\n updateDesignData.delflag = false\n updateDesignData.save!\n else\n updateDesignData.delflag = true\n updateDesignData.save!\n end\n\n respond_to do |format|\n format.html { redirect_to :controller => 'design_data', :action => 'index' }\n format.json { head :no_content }\n end\n end", "def process_image_enhenced\n file_name = \"#{Rails.root}/tmp/temp-#{self.id}.jpg\"\n\n open(file_name, 'wb') do |file|\n file << open(self.image_uncompressed.url).read\n end\n\n image = OpenCV::Cv::Mat.new\n image = OpenCV::Cv::imread file_name\n\n image.convertTo(image, -1, 1.4, 30)\n\n photo = OpenCV::Cv::imwrite \"#{Rails.root}/tmp/black_and_white-#{self.id}.png\", image\n\n file = File.open \"#{Rails.root}/tmp/black_and_white-#{self.id}.png\"\n\n self.image_enhenced = file\n\n begin\n self.save!\n rescue CarrierWave::ProcessingError => error\n raise error.cause\n end\n\n self.exam.check_for_enhenced\n end", "def add_image(img)\n unless images.include?(img)\n images << img\n self.thumb_image = img unless thumb_image\n self.updated_at = Time.zone.now\n save\n notify_users(:added_image)\n reload\n end\n img\n end", "def show\n\n Dir.chdir \"#{Rails.root.join('public/')}\"\n\n #iteración de todos los usuarios en el arreglo @usuarios\n # creamos una variable que va a crear en string el nombre de la foto que se va a guardar\n # ej. user_image_23.png para el usuario con id 23\n saveName = \"user_image_#{@usuario.id}.png\"\n\n # abrimos el filestream para escritura con el nombre de la variable saveName\n fotoUsuario = File.open(saveName, 'wb') do |f|\n\n # el begin y rescue es el clásico try/catch\n begin\n # intentamos convertir los bytes que se reciben de la base de datos en encoding BASE64\n # y lo escribimos en el filestream usando decode64. Se guardaría en /public/user_image_23.png\n f.write(Base64.urlsafe_decode64(@usuario.foto))\n\n # cambiamos el contenido de la propiedad foto para que no sea el arreglo de bytes sino el\n # nombre con el que quedó guardado en /public/\n\n if @usuario.foto != \"\"\n\n # cambiamos el contenido de la propiedad foto para que no sea el arreglo de bytes sino el\n # nombre con el que quedó guardado en /public/\n @usuario.foto=saveName\n\n else\n @usuario.foto=\"default_user_image.png\"\n end\n\n # cerramos el stream\n f.close\n # si escribir la foto falla por algún motivo...\n rescue => ex\n # ignoramos lo que se haya jalado de la base de datos y ponemos de nombre una imagen genérica\n # esta imagen debe estar guardada eb /public/\n @usuario.foto=\"default_user_image.png\"\n end\n end\n end", "def gallery_images\n imgs = images\n 1.upto(3 - imgs.size) do |i|\n imgs << \"/images/placeholder.png\"\n end\n imgs\n end", "def get_images\n {}\n end", "def update_img\n @post = Post.find(self.id)\n image = @post.image.url(:gallery)\n image = '/public' + image.gsub(/\\?.*/, '')\n\n if !@post.meme_text.nil?\n if File.exists? Rails.root.to_s + image\n PostsHelper.image_writer(image, @post.meme_text, @post.meme_position)\n end\n end\n end", "def images\n [\n 'crow',\n 'cow',\n 'deer',\n 'monkey',\n 'fish',\n 'frog',\n 'horse',\n 'spider',\n ]\n end", "def images\n self.class.images\n end", "def save_picture(data)\n File.open('public/images/'+ self.picture,'w') do |f|\n f.write data\n end\n end", "def set_image\n @image = Image.find(params[:id])\n end", "def set_image\n @image = Image.find(params[:id])\n end", "def set_image\n @image = Image.find(params[:id])\n end", "def set_image\n @image = Image.find(params[:id])\n end", "def set_image\n @image = Image.find(params[:id])\n end", "def set_image\n @image = Image.find(params[:id])\n end", "def set_image\n @image = Image.find(params[:id])\n end", "def set_image\n @image = Image.find(params[:id])\n end", "def set_image\n @image = Image.find(params[:id])\n end", "def set_image\n @image = Image.find(params[:id])\n end", "def set_image\n @image = Image.find(params[:id])\n end", "def set_image\n @image = Image.find(params[:id])\n end", "def set_image\n @image = Image.find(params[:id])\n end", "def set_image\n @image = Image.find(params[:id])\n end" ]
[ "0.66399646", "0.6350283", "0.62796783", "0.62576264", "0.6131364", "0.6124412", "0.6090842", "0.60895085", "0.6042777", "0.60396785", "0.6012288", "0.59984326", "0.5988628", "0.5968303", "0.59598863", "0.5958608", "0.59576374", "0.5951554", "0.5935682", "0.5888274", "0.5862293", "0.5838866", "0.583478", "0.5815749", "0.5805861", "0.580287", "0.57952225", "0.57952225", "0.5771674", "0.577078", "0.57692224", "0.57613134", "0.5744355", "0.57282794", "0.5720128", "0.57160676", "0.57160676", "0.57144856", "0.57118183", "0.57019067", "0.57001853", "0.5696634", "0.56901276", "0.56853396", "0.56751156", "0.567116", "0.56709665", "0.56459564", "0.564396", "0.56412876", "0.5634697", "0.562363", "0.5613382", "0.5597301", "0.5592485", "0.5583828", "0.5576246", "0.5574273", "0.5571212", "0.55661434", "0.55622625", "0.5561172", "0.5545505", "0.55413264", "0.5538745", "0.55365855", "0.5526283", "0.55248505", "0.5519598", "0.5516619", "0.5516078", "0.55143845", "0.5513155", "0.5504149", "0.5498901", "0.5491761", "0.54895127", "0.54872084", "0.54823774", "0.548072", "0.54765135", "0.5474941", "0.54704964", "0.54695094", "0.54689527", "0.5467608", "0.5466273", "0.54653513", "0.54653513", "0.54653513", "0.54653513", "0.54653513", "0.54653513", "0.54653513", "0.54653513", "0.54653513", "0.54653513", "0.54653513", "0.54653513", "0.5462647", "0.5462647" ]
0.0
-1
Para imagenes almacenadas en disco
def file_to_base64 (photo) puts [photo].pack('m0') #Convierte de formato '/xFF' a Base64 para poder mostrar la foto en la vista return [photo].pack('m0') end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_img\n\n end", "def sepia\n @photo = Photo.find(params[:id])\n img = Magick::Image.read('public' + @photo.attachment_url).first\n img = img.sepiatone()\n img.write('public' + @photo.attachment_url)\n end", "def images; end", "def charcoal\n @photo = Photo.find(params[:id])\n img = Magick::Image.read('public' + @photo.attachment_url).first\n img = img.charcoal(0.0, 1.0)\n img.write('public' + @photo.attachment_url)\n end", "def comer\r\n # @image = Image[\"pez2.png\"]\r\n # Al comer, un pez tendrá x segundos mas de vida, y queda libre para buscar mas comida\r\n @vida_inicio += 2\r\n @libre = true\r\n end", "def images\n end", "def set_imagen\n @objeto = Imagen.find(params[:id])\n end", "def afficher\n @image.display\n end", "def image; end", "def add_image \n image = CARMD.image(self.vin)\n if image == \"\"\n image = \"http://clipart-library.com/img/2050778.png\"\n end\n self.auto_image = image \n self.save \n end", "def show\n @imgs = @guardario.guardario_images\n end", "def blue_shift\n @photo = Photo.find(params[:id])\n img = Magick::Image.read('public' + @photo.attachment_url).first\n img = img.blue_shift(2)\n img.write('public' + @photo.attachment_url)\n end", "def image\n\n end", "def imgs obj\n Image.find(obj.image_ids)\n end", "def images\n []\n end", "def images\n @images = super || []\n end", "def image\n end", "def image\n end", "def sequence_images\n \n end", "def all_images(albid)\n kept_images(albid) + deleted_images(albid)\n end", "def getImaginario\n\t\treturn @i\n\tend", "def cloudinary_imgs_cara(key,instance)\n cl_image_tag(key, :quality=>\"auto\", :fetch_format=>:auto, :crop=>\"fit\", :class=>\"d-block mx-auto img-fluid rounded\", :alt=>\"#{instance.name}\")\n end", "def images\n [\n 'crow',\n 'cow',\n 'deer',\n 'monkey',\n 'fish',\n 'frog',\n 'horse',\n 'spider',\n ]\n end", "def makeImage\n for i in 0...@width\n ti = 2.0*Math::PI*i/ImageWidth.to_f\n for j in 0...@height\n tj = 2.0*Math::PI*j/ImageHeight.to_f\n\n $image[3 * (@height * i + j)] = 127*(1.0 + Math::sin(ti))\n $image[3 * (@height * i + j) +1] = 127*(1.0 + Math::cos(2*tj))\n $image[3 * (@height * i + j) +2] = 127*(1.0 + Math::cos(ti+tj))\n end\n end\n end", "def edit_real_picture\n end", "def image\n end", "def image\n end", "def update_imagem(foto_64)\n foto_64 = \"data:image/jpeg;base64,#{foto_64}\"\n if foto_64 != \"\" && foto_64 != nil\n base_64_encoded_data = foto_64\n string_img = Base64.decode64(base_64_encoded_data['data:image/png;base64,'.length .. -1])\n File.open(\"#{Rails.root}/tmp/motorista2.jpg\", \"wb\") do |file| \n file.write(string_img)\n file.size\n self.imagem = file\n end\n end\n end", "def adjuntar_imagen(klass, img)\n begin\n archivo = File.new(img)\n Adjunto.create( :archivo => archivo, :adjuntable_id => klass.id, :adjuntable_type => klass.class.to_s )\n rescue\n end\n end", "def black_and_white\n @photo = Photo.find(params[:id])\n img = Magick::Image.read('public' + @photo.attachment_url).first\n img = img.quantize(256, Magick::GRAYColorspace)\n img.write('public' + @photo.attachment_url)\n end", "def set_img\n @img = Img.find(params[:id])\n end", "def image\n 0\n end", "def images\n @picturesandmeta = Pictureandmeta.all\n @kind = Kind.find(params[:kind_id])\n Rails.logger.info(\"Kind: #{@kind.inspect}\")\n end", "def setup\n size 200, 200\n @a = load_image 'construct.jpg'\n @b = load_image 'wash.jpg'\n @offset = 0.0\nend", "def images\n images = @anchors.select { |a| a.object.is_a?(Pic) }\n images.map { |a| a.object }\n end", "def main\n ImageManip::inspect_image(@image_path)\n dimensions = ImageManip::get_dimensions(@image_path)\n sharp_pixels = get_accidental_pixels(@sharp_path)\n flat_pixels = get_accidental_pixels(@flat_path)\n edits = Hash.new\n edits[:lower_left] = [dimensions[0] / 2, dimensions[1] / 2]\n edits[:rgb_array] = sharp_pixels\n ImageManip::draw_2D_object(@image_path, './new_staff.gif', edits)\n edits[:lower_left] = [dimensions[0] / 3, dimensions[1] / 3]\n edits[:rgb_array] = flat_pixels\n ImageManip::draw_2D_object('./new_staff.gif', './new_staff.gif', edits)\n end", "def rotate_image(image)\n\nend", "def set_producto_imagen\n @producto_imagen = ProductoImagen.find(params[:id])\n end", "def picdata\n object.imgdata\n end", "def add_image( id, image_name, x_position, speed, width, height )\n OSX::NSLog(\"Received image ##{id} (#{image_name})\")\n# image_name = OSX::NSBundle.mainBundle.pathForImageResource( image_name )\n image_name = \"/Users/alpha/src/cyberart/images/#{image_name}.jpg\"\n image = CAImage.new( id, image_name, x_position, speed, width, height )\n @semaphore.synchronize { temp_images = @images.dup }\n temp_images << image\n @semaphore.synchronize { @images = temp_images }\n end", "def img(*) # :nodoc:\n raise \"no!\"\n end", "def to_jpg\n load_image\n end", "def put_image(_x, _y, _image)\n @reacs[:images] << [_x, _y, _image]\n end", "def update_bitmap\n @effectus_old_name = @picture.name\n if @effectus_old_name.empty?\n self.bitmap = nil\n else\n self.bitmap = Cache.picture(@effectus_old_name)\n @effectus_center_x = bitmap.width / 2\n @effectus_center_y = bitmap.height / 2\n end\n end", "def deleted_images(albid)\n Dir[_(albid, \"trash\", \"*.jpg\")].collect do |f|\n image(albid, File.basename(f))\n end\n end", "def flip\n @photo = Photo.find(params[:id])\n img = Magick::Image.read('public' + @photo.attachment_url).first\n img = img.flip!\n img.write('public' + @photo.attachment_url)\n end", "def rotate\n @photo = Photo.find(params[:id])\n img = Magick::Image.read('public' + @photo.attachment_url).first\n img = img.rotate(90)\n img.write('public' + @photo.attachment_url)\n end", "def show_image\n temp_floor_tile = Image.new('tiles\\tile_floor_1.png')\n hex_width = temp_floor_tile.width - 6\n hex_height = temp_floor_tile.width - 4\n temp_floor_tile.remove\n @hexArray.each_with_index do | line, x |\n bottom_y = hex_height * 11\n y_start = bottom_y - (11 - line.size) * (hex_height / 2)\n line.each_with_index do | hex, y |\n cur_x = x * hex_width\n cur_y = y_start - y * hex_height\n\n case hex.type\n when Hex::FLOOR_TYPE\n Image.new('tiles\\tile_floor_1.png', x:cur_x, y:cur_y)\n when Hex::LAVA_TYPE\n Image.new('tiles\\tile_liquid_1.png', x:cur_x, y:cur_y)\n when Hex::EXIT_TYPE\n Image.new('tiles\\tile_base.png', x:cur_x, y:cur_y)\n Image.new('tiles\\dung_ladderdown.png', x:cur_x, y:cur_y)\n else\n Image.new('tiles\\tile_base.png', x:cur_x, y:cur_y)\n end\n if hex.contained_object != nil && hex.contained_object.type == MovingObject::PLAYER_TYPE\n Image.new('tiles\\player.png', x:cur_x, y:cur_y)\n end\n end\n end\n end", "def main()\n \n for i in 0...$enemy_info.length do\n \n EditImage(\n $enemy_info[i][0],\n $enemy_info[i][2][0],\n $enemy_info[i][2][1],\n $enemy_info[i][2][2],\n $enemy_info[i][2][3],\n $enemy_info[i][3]\n )\n \n end \n\n\nend", "def set_imagen_articulo\n @imagen_articulo = ImagenArticulo.find(params[:id])\n end", "def despeckle image\n m_begin \"despeckle\"\n set_variable(image, get_image(image).despeckle)\n m_end \"despeckle\"\n end", "def images\n [assets.find_all { |asset| asset.is_a? MDL::BorealisImage }].flatten\n end", "def set_im\n @im = Im.find(params[:id])\n end", "def kept_images(albid)\n Dir[_(albid, \"*.jpg\")].collect do |f|\n image(albid, File.basename(f))\n end\n end", "def setup\n size 640, 360\n @image = load_image \"test.jpg\"\n @image_mask = load_image \"mask.jpg\"\n @image.mask @image_mask\nend", "def imagen_params\n params.require(:imagen).permit(:orden, :imagen, :nota, :linea_id, :directorio_id)\n end", "def cover_image\n end", "def set_image\n @image = Image.find(params[:id]).decorate\n end", "def index\n @guardarios_img = GuardarioImage.last(9).reverse\n end", "def cur_image\n self\n end", "def set_image_cashiero\n @image_cashiero = ImageCashiero.find(params[:id])\n end", "def move_picture picture\n end", "def process_small_image\n small_image.encode!(:png).convert!('-resize 50x50 -gravity center -background none -extent 50x50')\n end", "def sharpen\n @photo = Photo.find(params[:id])\n img = Magick::Image.read('public' + @photo.attachment_url).first\n img = img.sharpen(0.0, 1.0)\n img.write('public' + @photo.attachment_url)\n end", "def set_adm_galerias_imagem\n @adm_galerias_imagem = Adm::GaleriasImagem.find(params[:id])\n end", "def img(uuid, delete = true)\n log(\"image #{uuid}\")\n lock(:img) do\n delete ? @cache[:img].delete(uuid) : @cache[:img].fetch(uuid, nil)\n end\n end", "def gallery_images\n imgs = images\n 1.upto(3 - imgs.size) do |i|\n imgs << \"/images/placeholder.png\"\n end\n imgs\n end", "def lnbPicture _obj, _args\n \"_obj lnbPicture _args;\" \n end", "def fetch_image(host,old_file,new_file)\n\t`rm #{old_file}` \n\t`mv #{new_file} #{old_file}`\t\n\topen('assets/images/radar/new.png', 'wb') do |file|\n\t\tfile << open('host').read\n\tend\n\tnew_file\nend", "def picture_show(id, n, x=0, y=0, ori=0, z_x=100, z_y=100, op=255, bl=0)\n pictures[id].show(n, ori, x, y, z_x, z_y, op, bl)\n end", "def set_image\n @escape_game = EscapeGame.find_by_id!(params[:escape_game_id])\n @image = @escape_game.images.find(params[:id])\n end", "def imagen_path\n\t\t\"../perfumes/#{id}.#{imagen}\"\n\t\t# \"../perfumes/#{imagen}\"\n\tend", "def view\n if belongs_to_user?(@good)\n @good_images = [@good.main_image] + Image.ad_images_of_good(@good)\n @good_images.flatten!\n else\n redirect_to root_path, alert: 'Это не ваша сохраненная вещь'\n end\n end", "def images\n @images ||= {}\n end", "def show\n # require \"mini_magick\"\n #\n # @codeimage = @code.image\n # croppedcode = @codeimage.cropped\n # compositecode = @codeimage.composite\n # base = Base.last.image\n #\n # newimage = MiniMagick::Image.open(croppedcode.url)\n # baseimage = MiniMagick::Image.open(base.url)\n # newimage.rotate(\"-10\")\n #\n # newimage = baseimage.composite(newimage) do |c|\n # c.compose(\"Darken\")\n # c.geometry(\"200x200+215+70\")\n # c.gravity(\"southeast\")\n # end\n\n\n # newimage.write(@codeimage.composite.url)\n\n if Code.count > 1\n if Code.first.created_at < 7.days.ago\n Code.first.delete\n end\n end\n\n redirect_to root_url\n\n end", "def picture_list\n end", "def profile_photo\n @profile = Profile.find(:all)\n \n for profile in @profile\n if !profile.profile_image.blank?\n original_image = RAILS_ROOT + \"/public/profile/profile_image/#{profile.id}/#{File.basename(profile.profile_image)}\"\n # main = RAILS_ROOT + \"/public/profile/profile_image/#{profile.id}/main/#{File.basename(profile.profile_image)}\"\n submain = RAILS_ROOT + \"/public/profile/profile_image/#{profile.id}/submain/#{File.basename(profile.profile_image)}\"\n image = Magick::ImageList.new(original_image) \n image = image.change_geometry!('171x171!') { |c, r, i| i.resize!(c, r) } \n image.write(submain) \n end \n end\n \n \n end", "def images\n self.class.images\n end", "def images_from_img_tag\n img_array = []\n # пробегаю по тегам img (meta og:images...), хватаю урл и закидываю в img_array\n @doc.xpath('//img').each do |img|\n if img['src'] != nil\n array = [img['src'].to_s]\n src = @handler_link.remove_unless_symbols(array)\n got_link = @handler_link.handler_prefix_link(@link_host_name, src.to_s.delete!(\"[\\\"]\"))\n\n img_array << got_link\n end\n end\n\n img_array.uniq!\n @handler_link.remove_unless_link(img_array)\n img_array\n end", "def thumbnail_image\n end", "def show\n Dir.chdir \"#{Rails.root.join('public/')}\"\n\n #iteración de todos los usuarios en el arreglo @usuarios\n # creamos una variable que va a crear en string el nombre de la foto que se va a guardar\n # ej. user_image_23.png para el usuario con id 23\n saveName = \"business_image_#{@negocio.id}.png\"\n\n # abrimos el filestream para escritura con el nombre de la variable saveName\n fotoUsuario = File.open(saveName, 'wb') do |f|\n\n # el begin y rescue es el clásico try/catch\n begin\n # intentamos convertir los bytes que se reciben de la base de datos en encoding BASE64\n # y lo escribimos en el filestream usando decode64. Se guardaría en /public/user_image_23.png\n f.write(Base64.urlsafe_decode64(@negocio.imagen))\n\n # cambiamos el contenido de la propiedad foto para que no sea el arreglo de bytes sino el\n # nombre con el que quedó guardado en /public/\n @negocio.imagen=saveName\n\n # cerramos el stream\n f.close\n # si escribir la foto falla por algún motivo...\n rescue => ex\n # ignoramos lo que se haya jalado de la base de datos y ponemos de nombre una imagen genérica\n # esta imagen debe estar guardada eb /public/\n @negocio.imagen=\"default_user_image.png\"\n end\n end\n end", "def add_picture(picture)\n end", "def update_img\n @post = Post.find(self.id)\n image = @post.image.url(:gallery)\n image = '/public' + image.gsub(/\\?.*/, '')\n\n if !@post.meme_text.nil?\n if File.exists? Rails.root.to_s + image\n PostsHelper.image_writer(image, @post.meme_text, @post.meme_position)\n end\n end\n end", "def set_element pic\n controller_name == 'temp_listings' ? get_pixi_image(pic) : get_pixi_image(pic, 'large')\n end", "def set_proyectos_imagen\n @proyecto_imagen = ProyectoImagen.find(params[:id])\n end", "def imgurl\n picref.imgurl if picref\n end", "def recreate\n #photo = Photo.find(params[:id])\n #degrees = if params[:direction] == 'left' then -90 else 90 end\n\n #~ #main photo\n #~ image = Magick::ImageList.new(photo.file)\n #~ image = image.rotate(degrees)\n #~ image.write(photo.file)\n\n # thumb\n @photoset = Photoset.find(params[:id])\n #@photos = Photo.find(:all)\n for photo in @photoset.photos \n # render :text => photo.id and return\n photo = Photo.find(photo.id)\n if !photo.image.blank?\n original_image = RAILS_ROOT + \"/public/photo/image/#{photo.id}/#{File.basename(photo.image)}\"\n \n main = RAILS_ROOT + \"/public/photo/image/#{photo.id}/main/#{File.basename(photo.image)}\"\n \n #~ thumbnail = RAILS_ROOT + \"/public/photo/image/#{photo.id}/thumbnail/#{File.basename(photo.image)}\"\n \n #~ submain = RAILS_ROOT + \"/public/photo/image/#{photo.id}/submain/#{File.basename(photo.image)}\"\n \n\n \n \n image = Magick::ImageList.new(original_image) \n image = image.change_geometry!('600x450>') { |c, r, i| i.resize!(c, r) } \n image.write(main)\n \n #~ image = Magick::ImageList.new(original_image) \n #~ image = image.change_geometry!('51x51!') { |c, r, i| i.resize!(c, r) } \n #~ image.write(thumbnail)\n \n #~ image = Magick::ImageList.new(original_image) \n #~ image = image.change_geometry!('97x97!') { |c, r, i| i.resize!(c, r) } \n #~ image.write(submain) \n \n end\n \n end\n render :text => \"image croped\"\n #redirect_to :action => 'index'\n end", "def home\n @images = [\"random_people.jpg\", \"using_phones.jpg\", \"naeem.jpg\"]\n end", "def find_normal_image\n return \"Pictures/pcn%04d.png\" % (80 + id)\n end", "def image\n @path\n end", "def imagemagick?; end", "def set_coleccion_imagene\n @coleccion_imagene = ColeccionImagene.find(params[:id])\n end", "def load_images\n @@images[\"background\"] = Gosu::Image.new(self, \"media/ground.jpeg\", true)\n @@images[\"circle\"] = Gosu::Image.new(self, \"media/ground.jpeg\", true)\n @@images[\"creeps\"] = Gosu::Image.load_tiles(\"./media/pokemons.png\", 32, 32)\n end", "def image( name )\n @images[name]\n end", "def lbSetPicture _obj, _args\n \"_obj lbSetPicture _args;\" \n end", "def lbSetPicture _obj, _args\n \"_obj lbSetPicture _args;\" \n end", "def index\n @producto_imagenes = ProductoImagen.all\n end", "def set_main_image\n if self.is_main_image\n self.class.update_all(\"is_main_image = 0\", \"is_main_image <> 0 AND location_id = #{self.location_id} AND id <> #{self.id}\")\n end\n end", "def stream_image(headers, index, is_retina)\n image_option = selected_image_at_index index.to_i\n return nil if image_option.nil?\n\n image_file_name = \"#{image_option['path']}\"\n image_file_name.gsub! /\\.png/i, '@2x.png' if (is_retina.to_i >= 1)\n image_file_path = \"#{@assets_path}/images/#{image_file_name}\"\n\n read_file headers, image_file_path, 'image/png'\n end", "def add_image(path, point, width, height = 0.0)\n end", "def putImage(theWidth, theHeight, theImage)\n\n\tputs \"Raw Image:\";\n\tputs theImage.join();\n\t\n\t\n\tputs \"\"\n\tputs \"Bitmap Image:\"\n\tn = 0;\n\n\t0.upto(theHeight - 1) do |y|\n\t\t0.upto(theWidth - 1) do |x|\n\t\t\tprint (theImage[n] == 1) ? '#' : ' ';\n\t\t\tn += 1;\n\t\tend\n\t\tputs \"\";\n\tend\n\nend" ]
[ "0.66818684", "0.667384", "0.65921867", "0.64820796", "0.64053124", "0.63101983", "0.6294972", "0.61342466", "0.6120463", "0.61008704", "0.6095081", "0.6049432", "0.6048877", "0.60488236", "0.60479033", "0.60139465", "0.5942776", "0.5942776", "0.5932586", "0.5929353", "0.58827263", "0.58693665", "0.5858633", "0.58297986", "0.58284456", "0.58197504", "0.58197504", "0.58186364", "0.58155096", "0.5812943", "0.5806372", "0.580253", "0.5782497", "0.5769088", "0.57500696", "0.5740911", "0.57280797", "0.571354", "0.570978", "0.5705671", "0.569936", "0.5690253", "0.56814253", "0.56728435", "0.56698847", "0.5642357", "0.5614964", "0.5609161", "0.5593588", "0.5588688", "0.5585343", "0.55820704", "0.55758935", "0.55756176", "0.5575355", "0.5574782", "0.55736846", "0.55693984", "0.5565086", "0.55595773", "0.5559546", "0.5555565", "0.55456007", "0.5533947", "0.5533451", "0.5532", "0.5530202", "0.5524806", "0.55231404", "0.5520001", "0.55153364", "0.55148846", "0.55147743", "0.55130404", "0.5511866", "0.550766", "0.5504136", "0.54876065", "0.5478499", "0.54747397", "0.5461903", "0.54617745", "0.54579836", "0.5453122", "0.5450906", "0.5450499", "0.5449764", "0.5433919", "0.54320776", "0.54277164", "0.5427451", "0.54236186", "0.5417212", "0.54103583", "0.5409051", "0.5409051", "0.54081345", "0.5396378", "0.53935134", "0.53925997", "0.53822064" ]
0.0
-1
Fuerza formato de fecha a "dd/mm/yyyy"
def format_date (date) return date.strftime("%d/%m/%Y") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def date_format t\n t.strftime \"%Y/%m/%d\"\n end", "def formatted_date(dt, format=\"%m/%d/%Y\")\n\t\tDate.strptime(dt, '%Y-%m-%d').strftime(format)\n\tend", "def date_format(date)\n\t if date\n\t date.strftime(\"%d/%m/%Y\")\n\t end\n\tend", "def format_date date\n date.strftime('%m/%d/%y')\n end", "def format_date_to_s(val)\n Date.parse(val.to_s).strftime('%m/%d/%Y')\n end", "def formatted_date\n Date.strptime(date, \"%m/%d/%Y\")\n end", "def format_date(date)\n date = DateTime.parse(date)\n date.strftime('%m/%d/%y')\n end", "def date_format t\n t.strftime \"%Y/%m/%d\"\nend", "def date_format t\n t.strftime \"%Y/%m/%d\"\nend", "def returnDateFormated date, format\n return Date.strptime(date, format).strftime(\"%d/%m/%Y\")\nend", "def format_date(date, format = \"%m/%d/%Y\")\n date.respond_to?(:strftime) ? date.strftime(format) : date.to_s\n end", "def format_date_nicely(date)\n date.strftime(\"%d/%m/%Y\")\nend", "def format_date_nicely(date)\n date.strftime(\"%d/%m/%Y\")\nend", "def format_date_nicely(date)\n date.strftime '%d/%m/%Y'\nend", "def formatted_date(date)\n DateTime.parse(date).strftime('%-m/%-d/%y')\n rescue\n ''\n end", "def format_date( date = Date.today )\n date.strftime('%a %d/%m/%Y')\n end", "def format_date\n chars = @date.split('')\n chars.pop(6)\n chars.join('')\n end", "def format_date(date) \r\n (date == \"mm/dd/yy\" || date == \"MM/DD/YY\" || date.blank?)? nil : Date.strptime(date, '%m/%d/%y')\r\n end", "def format_date(date)\n date.strftime '%d-%m-%Y'\n end", "def change_date_format(date)\n if date.include? '/'\n\t date_array = date.split(\"/\")\n\t new_date = date_array[1]+\"/\"+date_array[2]+\"/\"+date_array[0]\n \t\tputs new_date\n \t return new_date\n else\n \t return date\n end\n end", "def format_date(date)\n date.strftime(\"%Y-%m-%d\")\n end", "def format_s_to_date(val)\n Date.strptime(val, '%m/%d/%Y').strftime(\"%Y%m%d\")\n end", "def format_date(date)\n date.strftime '%Y-%m-%d'\n end", "def DateFormat(date)\n @newDate = date[:month] + \"/\" + date[:day] + \"/\" + date[:year]\n return @newDate\n end", "def fmt_date(date)\n if (date)\n date.strftime(\"%m-%d-%Y\")\n end\n end", "def fix_date(date=nil)\n if date == nil\n # no full date, use current\n yy, mm, dd = Time.now.strftime(\"%Y/%m/%d\").split('/')\n elsif date.size == 3\n # we got full date\n if date[0].size == 4\n # yyyy/mm/dd\n yy = date[0].strip\n mm = date[1].strip\n dd = date[2].strip.rjust(2,'0')\n else\n # dd/mm/yyyy\n dd = date[0].strip.rjust(2,'0')\n mm = date[1].strip\n yy = date[2].strip\n end\n case mm.downcase\n when 'enero' :\n mm = '01'\n when 'febrero' :\n mm = '02'\n when 'marzo' :\n mm = '03'\n when 'abril' :\n mm = '04'\n when 'mayo' :\n mm = '05'\n when 'junio' :\n mm = '06'\n when 'julio' :\n mm = '07'\n when 'agosto' :\n mm = '08'\n when 'setiembre' :\n mm = '09'\n when 'septiembre' :\n mm = '09'\n when 'octubre' :\n mm = '10'\n when 'noviembre' :\n mm = '11'\n when 'diciembre' :\n mm = '12'\n else\n mm.rjust(2,'0')\n end\n end\n return yy, mm, dd\n end", "def date_formate(date)\n return nil if date.blank?\n date.strftime('%m/%d/%Y %I:%M %p')\n end", "def format_date(date)\n return date if date.nil?\n Date.strptime(date.to_s, '%Y-%m-%d').strftime('%b %d, %Y')\n end", "def fecha_r\r\n @fecha_r.try(:fecha_recepcion).strftime(\"%d/%m/%Y\")\r\n end", "def convert_date(datetime)\n date = Time.parse(datetime)\n date.strftime('%m/%d/%Y').strip\n end", "def shortDate(obj)\n obj.strftime(\"%m/%d/%Y\")\n end", "def format_date(date)\n date.strftime(\"%d %B %Y\")\n end", "def strf_date(date_time)\n begin\n date_time.strftime('%Y-%m-%d')\n rescue\n date_time\n end\n end", "def nice_date_form(the_date)\n \treturn the_date ? the_date.strftime('%b %d, %Y') : ''\n\tend", "def format_date(date)\n if date.nil?\n return \"\"\n end\n if date.year == Date.today.year\n return date.strftime(\"%A, %B %-d\") unless date.nil?\n else\n return date.strftime(\"%A, %B %-d %Y\") unless date.nil?\n end\n end", "def date_formats\n [\n '%m/%d/%Y', #'mm/dd/yyyy',\n '%m-%d-%Y', #'mm-dd-yyyy',\n '%m-%d-%y', #'mm-dd-yy',\n '%d/%m/%Y', #'dd/mm/yyyy',\n '%d-%m-%Y', #'dd-mm-yyyy',\n '%d-%m-%y', #'dd-mm-yy',\n '%a, %d %b %Y' #strftime, e.g. 'Sat, 10 Nov 2007'\n ]\n end", "def get_date(date)\n\t\tif date != nil\n\t\t\ttemp = Date.parse date.to_s\n\t\t\treturn temp.strftime(\"%a, %b %d %Y\")\n\t\telse\n\t\t\treturn \"Not specifed\"\n\t\tend\n\tend", "def date_reformatting(date)\n #date.split('/')..join(',')\n Date.parse.(date).strftime'[%m, %d, %Y]'\nend", "def convert_date(date)\n d = date.split('/')\n \"#{d[2]}-#{d[0]}-#{d[1]}\".to_date\n end", "def date_format_readable(date)\n #date.strftime '%Y-%b-%d'\n date.strftime '%b %d %Y' if date.present?\n end", "def www_date(date)\r\n if date.nil?\r\n Time.now.strftime('%d/%m/%Y')\r\n else\r\n date.strftime('%d/%m/%Y')\r\n end\r\n end", "def start_date_us_format\n start_date.nil? ? nil : start_date.strftime(\"%m/%d/%Y\") \n end", "def format_date_nicely(date)\n\tn = Time.new(2013, 10, 31)\n\tn.strftime(\"%d/%m/%Y\")\nend", "def fmt_date(dt)\n if dt.present?\n dt.strftime(ApplicationHelper.date_fmt)\n end\n end", "def format_date(date, format)\n date = datetime(date)\n if format.nil? || format.empty? || format == \"ordinal\"\n date_formatted = ordinalize(date)\n else\n format.gsub!(/%a/, ABBR_DAYNAMES_DE[date.wday])\n format.gsub!(/%A/, DAYNAMES_DE[date.wday])\n format.gsub!(/%b/, ABBR_MONTHNAMES_DE[date.mon])\n format.gsub!(/%B/, MONTHNAMES_DE[date.mon])\n date_formatted = date.strftime(format)\n end\n date_formatted\n end", "def format_date(date)\n return prefs.format_date(date)\n end", "def format_date(date)\n return prefs.format_date(date)\n end", "def dateify_dob\n self.dob ||= \"\"\n parts = self.dob.split(\"/\").map{|i| i.to_i}\n self.dob = \"#{parts[0].to_s.rjust(2, \"0\")}/#{parts[1].to_s.rjust(2, \"0\")}/#{parts[2]}\"\n end", "def formatted_timestamp(date)\n Date.parse(date).strftime('%d/%m/%Y')\n end", "def dateize(date)\n if not date.nil?\n date.strftime(\"%Y-%m-%d\")\n end\nend", "def ver_fecha_df(fecha)\n if fecha\n fecha.strftime(FECHA_FORMATO2)\n else\n '-'\n end\n end", "def date_format\n return @date_format\n end", "def formatted_date( date )\n date.strftime( \"%Y-%b-%d\" ) + \" \" + date.strftime( \"%A\" ).slice( 0..2 ) unless date == nil\n end", "def geek_date(date)\n date.strftime(\"%Y-%m-%d\") \n end", "def formatted_date(date = nil)\n return '' unless date\n date.last_modified_date.strftime(\"%m/%d/%y\")\n end", "def format_date_nicely(date)\nend", "def date_view value, meta=nil\n return value.strftime \"%Y-%m-%d\" unless value.nil?\n ''\n end", "def convert_date(date)\n DateTime.parse(date.to_s).strftime('%d.%m.%Y')\n end", "def date_formatted\n date.strftime(\"%A %B %d, %Y\")\n end", "def date\n dreport.date_format\n end", "def date\n object.date.strftime(\"%m/%d/%Y\")\n end", "def format_date(date)\n date.strftime(\"%b #{date.day.ordinalize}, %Y\")\n end", "def format_start_date()\n\t\tif Date.valid_date?(self.year, self.month, self.day)\n\t\t\treturn self.month.to_s + '/' + self.day.to_s\n\t\telse\n\t\t\traise \"Invalid start date specified.\"\n\t\tend\n\tend", "def get_app_date()\n date_object = Date.strptime(@app_date, '%Y-%m-%d')\n format = date_object.strftime('%d/%m/%Y')\n return format.to_s\n end", "def change_date_format(date)\n date_array = date.split(\"/\")\n if date_array[1].to_i > 12\n new_date = date_array[1]+\"/\"+date_array[2]+\"/\"+date_array[0]\n else\n new_date = date_array[0]+\"/\"+date_array[2]+\"/\"+date_array[1]\n end\n puts \"anusha\"\n puts new_date.inspect\n return new_date\n end", "def format_date(year, month = 1, day = 1)\n format_year(year) + format_month(month) + format_day(day)\n end", "def formato_fecha(d,m,a)\r\n if (d<=9)\r\n dia=\"0\"+d.to_s\r\n else\r\n dia=d.to_s\r\n end\r\n if (m<=9)\r\n mes=\"0\"+m.to_s\r\n else\r\n mes=m.to_s\r\n end\r\n \r\n \r\n return dia+\"/\"+mes+\"/\"+a.to_s\r\nend", "def to_date(value)\n # return(date($this->DateFormat,value))\n end", "def formatted_date(date)\n date.present? ? date.strftime(\"%A, %B %d, %Y\") : \"\"\n end", "def date_url_format\n '%Y-%m-%d'\n end", "def formatted_date(date)\n return '' if date.nil?\n sprintf('%d/%d/%d alle %d:%d', date.day, date.month, date.year,\n date.hour, date.min)\n end", "def fmt_date(obj)\r\n if obj.class == Array \r\n return obj.collect {|e| fmt_date(e)}\r\n elsif obj.respond_to?('strftime')\r\n return obj.strftime(\"%m/%d/%Y\") \r\n else\r\n return obj\r\n end\r\n end", "def date(input, format); end", "def as_date\n strftime \"%Y-%m-%d\"\n end", "def change_date_form(date)\n\n \n date_array = date.to_s.split(\"-\")\n puts date_array\n new_date = date_array[2]+ \"/\" + date_array[0] + \"/\" + date_array[1]\n puts new_date.inspect\n return new_date\n\n end", "def date_str d\n Util::date(d)\n end", "def input_date_format(date)\n if date.split(\"-\").count > 2\n new_date = date.split(\"-\")\n return new_date[1] + \"-\" + new_date[0]\n else\n return date\n end\n end", "def date_str\n date.strftime(\"%Y%m%d\")\n end", "def to_date string\n \n end", "def format_date(date)\n date.sub(/(\\d\\d\\d\\d)([\\-\\/])(\\d\\d)\\2(\\d\\d)/, '\\4.\\3.\\1')\nend", "def format_date\n begin\n self.eob_date = Date.strptime(self.unformatted_eob_date, \"%m/%d/%Y\").to_time(:utc) if !self.unformatted_eob_date.blank?\n self.dos = Date.strptime(self.unformatted_dos, \"%m/%d/%Y\").to_time(:utc) if !self.unformatted_dos.blank?\n self.check_date = Date.strptime(self.unformatted_check_date, \"%m/%d/%Y\").to_time(:utc) if !self.unformatted_check_date.blank?\n rescue\n errors.add :base, \"Invalid Date(s)\"\n end\n end", "def pretty_date(input_date)\n return input_date.strftime(\"%d %B %Y\")\n end", "def format_date(date)\n return date unless !!date.match(/[\\-]+/)\n date.split(/\\-/).reverse.join(\".\")\nend", "def as_date format = :dd_mm_yyyy\n format_str =\n case format\n when :dd_mm_yyyy then \"%d %m %Y\"\n when :dd_mm_yy then \"%d %m %y\"\n when :mm_yyyy then \"%m %Y\"\n when :mm_yy then \"%m %y\"\n when :d_mois_yyyy then return as_human_date\n when :d_mois_court_yyyy then return as_human_date false\n else\n nil\n end\n unless format_str.nil?\n Time.at(self).strftime(format_str)\n end\n end", "def format_date(datetime)\n return datetime if !datetime.respond_to?(:strftime)\n datetime.strftime(\"%m-%d-%Y\")\n end", "def format_table_date(date)\n date.strftime('%Y%m%d')\n end", "def getDateString(d)\n return d.strftime('%Y-%-m-%-d')\nend", "def to_form_date(datetime)\n datetime.strftime(\"%Y-%m-%d\")\n end", "def formatFullDate(date)\n date.strftime(\"%A | %B #{date.day.ordinalize}, %Y\")\n end", "def get_formatted_date(date)\n date = date.gsub(\",\",\"\")\n date = date.gsub(\" \",\"-\")\n arr = date.split(\"-\")\n new_date = arr[1] + \"-\" + arr[2] + \"-\" + arr[3]\n end", "def date_humanized(date_as_integer)\n begin\n Time.at(date_as_integer).to_date.strftime(\"%m/%d/%y\")\n rescue\n nil\n end\n end", "def formatFullDate(date)\n date.strftime(\"%A, %B %d, %Y\")\n end", "def showdate(my_date)\n if my_date\n str_date=my_date.to_date.strftime(\"%d-%m-%Y\")\n else\n str_date=\"\"\n end\n return str_date\n end", "def human_date(datetime)\n datetime.strftime('%d/%m/%Y').gsub(/ 0(\\d{1})/, ' \\1')\n end", "def short_date( date )\n date.strftime( '%b %d, %Y')\n end", "def date_to_day date\r\n date = Date.parse(date) unless date.respond_to? :strftime\r\n return date.strftime('%Y%m%d')\r\n end", "def day_format(date)\n return nil if date.blank?\n date.strftime('%d')\n end", "def day_format(date)\n return nil if date.blank?\n date.strftime('%d')\n end", "def date\n \"#{day} #{month.capitalize} #{year}\"\n end", "def fancy_date(date)\n h date.strftime(\"%A, %B %d, %Y\")\n end" ]
[ "0.80554336", "0.80394876", "0.8025067", "0.7958487", "0.7909312", "0.786111", "0.78589314", "0.7852065", "0.7852065", "0.78196454", "0.7747431", "0.76876646", "0.76876646", "0.76657945", "0.7649918", "0.75773305", "0.75295556", "0.75099784", "0.742877", "0.7363715", "0.73434436", "0.7329472", "0.7320435", "0.7263666", "0.7183232", "0.7148842", "0.71465844", "0.7127669", "0.7107403", "0.7081519", "0.7058416", "0.70507103", "0.70499694", "0.70388836", "0.7027236", "0.6997067", "0.69898474", "0.69530386", "0.6941522", "0.693163", "0.6929949", "0.69169974", "0.69149655", "0.6907994", "0.6891157", "0.68869287", "0.68869287", "0.6886375", "0.68671584", "0.68532425", "0.6851107", "0.68482476", "0.6839476", "0.6821036", "0.68150723", "0.6810765", "0.68100727", "0.68061495", "0.6781702", "0.67683256", "0.6757702", "0.6744648", "0.67153496", "0.67111444", "0.6707101", "0.67016494", "0.66798633", "0.66667485", "0.6645333", "0.66377145", "0.6631027", "0.6627336", "0.66202086", "0.66171783", "0.6606885", "0.6599838", "0.65980744", "0.6586335", "0.65822035", "0.657888", "0.6571689", "0.6565898", "0.65497404", "0.6548574", "0.65485334", "0.65465516", "0.65371585", "0.6535049", "0.65216255", "0.6521535", "0.65176994", "0.6516676", "0.65112895", "0.6502506", "0.6488954", "0.64866674", "0.64799666", "0.64799666", "0.64762807", "0.64700454" ]
0.80143774
3
will always be a positive integer and return its additive persistence which is the number of times you must add the digits in num until you reach a single digit. For example: if num is 2718 then your program should return 2 because 2 + 7 + 1 + 8 = 18 and 1 + 8 = 9 and you stop at 9.
def AdditivePersistence(num) # code goes here sum = 0 count = 0 until num < 10 num1 = num.to_s sum = 0 for i in 0..num1.length-1 sum += num1[i].to_i end num = sum count += 1 end return count end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def AdditivePersistence(num)\n addv_pers = 0\n until num < 10\n num = num.digits.sum\n addv_pers += 1\n end\n addv_pers\nend", "def AdditivePersistence(num)\n count = 0\n\n while num > 9\n num = num.to_s.split(\"\").map{|i| i.to_i}.inject(:+)\n count += 1\n end\n\n count\nend", "def additive_persistence(num, count = 0)\n if num <= 9\n return count\n else\n num = num.to_s.split(\"\").inject(0) { |sum,n| sum += n.to_i }\n count += 1\n end\n additive_persistence(num, count)\nend", "def additivePersistence(number, times)\n # your magic\n numString = number.to_s\n sum = 0\n numString.each_char {|digit| sum += digit.to_i}\n\n if sum > 9 \n\t times += 1\n puts additivePersistence(sum, times)\n else\n puts times\n end\nend", "def AdditivePersistence(num)\n\n new = num.to_s.split('').map {|x| x.to_i}\n \n pers = new.size == 1 ? 0 : 1\n sum = new.reduce(:+)\n new = sum.to_s.split('').map { |x| x.to_i }\n \n until sum < 10 \n p sum = new.reduce(:+)\n p pers += 1\n new = sum.to_s.split('').map { |x| x.to_i }\n end\n \n # code goes here\n return pers \n \nend", "def add_digits(num)\n return 0 if num == 0\n (num - 1) % 9 + 1\nend", "def persistence(num)\n counter = 0\n product = num\n while product >= 10\n digits = product.to_s.chars.map(&:to_i)\n product = digits.inject(:*)\n counter += 1\n end\n counter\nend", "def persistence(n)\n count = 0\n while n > 9 do\n n = n.digits.inject(:*)\n count += 1\n end\n count\nend", "def persistence(num)\n return 0 if num.digits.length == 1\n multiplicative_persistence = 0\n until num.digits.length == 1\n num = num.digits.inject(:*)\n multiplicative_persistence += 1\n end\n multiplicative_persistence\nend", "def add_digits(num)\n return num if num.to_s.length == 1\n add_digits(num.to_s[0].to_i + add_digits(num.to_s[1..-1]).to_i)\nend", "def sum_nums(num)\n\t\n\tnumbers = []\n\tnum_sum = num\n\t\nuntil numbers.length == num_sum\n\tnumbers.push(num)\n\tnum = num - 1\nend\n return\tnumbers.inject(:+)\nend", "def persistence(int)\n return 0 if int.digits.length == 1\n\n num = int\n repeats = 0\n loop do\n num = num.digits\n\n num = num.inject { |mem, num| mem * num }\n repeats += 1\n break if num.digits.length < 2\n end\n repeats\nend", "def add_digits(num)\n num = num.to_s\n \n while num.length > 1\n new_num = num.split('').map(&:to_i).sum\n \n num = new_num.to_s\n end\n \n num.to_i\nend", "def recurring_decimal_length(num)\n\tdecimalArray, numerator = Array.new, 1\n\twhile true\n\t\tremainder = numerator%num\n\t\tif decimalArray.count(remainder) == 0\n\t\t\tdecimalArray.push(remainder)\n\t\telse\n\t\t\treturn decimalArray.count\n\t\tend\n\t\tnumerator = remainder*10\n\tend\nend", "def add_digits(num)\n return num if num.to_s.length == 1\n int_array = split_digits(num)\n sum = add_array_ints(int_array)\n return add_digits(sum)\n end", "def additivePersistenceRecursive(number,step)\n sum = 0\n number.to_s.each_char do |digit|\n sum += digit.to_i\n end\n (sum < 10) ? step : additivePersistenceRecursive(sum, step+1)\nend", "def sum_nums(num)\n\ncount = num\n\nif( num == 0 )\n return num\nend\n\n while count > 0\n num += count - 1\n #puts \"Num: #{num}\"\n count -= 1\n #puts \"Count: #{count}\"\n end\n\n return num\nend", "def digit_sum(num, digits)\n if digits == 1\n num\n else\n num % 10 + digit_sum(num / 10, digits - 1)\n end\nend", "def add_digits(num)\n return num if num < 10\n sum = 0\n num.to_s.split(\"\").each do |num|\n sum += num.to_i\n end\n add_digits(sum)\nend", "def adding(num)\n\tsum = 0\n\t(1..num).each do |x|\n\t\tsum += x\n\tend\n\treturn sum\nend", "def sum_nums(num)\n\n value = 0\n i = 0\n while i < num\n value = value + (num - i) \n i += 1\n end\n\n return value\nend", "def sum_num\n\t#ask for number\n\tputs \"gimme dat number: make sure its more than 1?\"\n\tnum = gets.chomp.to_i\n\t\n\n\tif num < 1\n\t\tputs \"I told you to put a number greater than 1\"\n\t\tsum_num\n\telse\n\t\t# prints number 1 to num\n\t\tcounter = (1..num)\n\t\tnew_num = 0\n\t\tcounter.each do |num|\n\t\t\tnew_num = new_num + num\n\n\n\t\tend\n\n\tend\n\tputs new_num \nend", "def digital_helper(num)\n result = 0\n while num >= 10\n result += num % 10\n num = num/10\n end\n result + num\nend", "def numsum(n)\n result = 0\n while n >= 1\n digit = (n % 10).floor\n result += digit\n (n /= 10).floor\n end\n puts result\nend", "def sum_to(num)\n i = 0\n sum = 0\n while i < num\n i += 1\n sum += i\n end\n return sum\nend", "def sum_nums(num)\r\n sum = 0\r\n while num >= 0\r\n sum = num + sum\r\n num = num-1\r\n end\r\n return sum\r\nend", "def persistence(num)\n count = 0\n while num.to_s.length > 1 do\n count+=1\n num = num.to_s.split('').map{|el| el.to_i}.reduce{|a,b| a*b}\n end\n return count\nend", "def SimpleAdding(num)\n\ti = 0\n\ttotal = 0\n\twhile i <= num\n\t\ttotal += i\n\t\ti += 1\n\tend\n\tprint total\nend", "def sum_digits(n)\n remaining = n\n sum = 0\n while remaining > 0\n sum += remaining % 10\n remaining = remaining / 10\n end\n sum\nend", "def sum_to(num)\n sum = 0\n i = 0\n while i <= num\n sum += i\n i += 1\n end\n return sum\nend", "def find_digit_amount(num)\n\treturn num.to_s.length()\nend", "def sum_to(num)\n i = num\n output = 0\n while i > 0\n output += i\n i -= 1\n end\n return output\nend", "def sum(num)\n digits = []\n sum = 0\n digits = num.digits\n sum = digits.sum\n return sum\nend", "def compute_number(digits)\n digits.length == 1 ? (digits.to_i) : (digits[-1].to_i + 10*compute_number(digits[0..-2]))\nend", "def sum_nums2(num)\n\ncount = 0\nresult = 0\n\n while num >= count\n result += count\n count += 1\n end\n #puts( result )\n return result\nend", "def sumdig_r(num, result = 0)\n if num < 10\n result += num\n else\n result += num % 10\n result = sumdig_r(num / 10, result)\n end\n result\nend", "def sumto(num)\n i = 0\n output = 0\n while i < num + 1\n output += i\n i += 1\n end\n return output\nend", "def persistence(n)\n n < 10 ? 0 : 1 + persistence(n.digits.reduce(&:*))\nend", "def super_digit(n)\n return n if n <= 9\n \n until n < 10\n sum = 0\n sum += (n % 10)\n sum += (n / 10)\n n = sum\n end\n\n return sum\nend", "def add_digits(number)\r\n total = 0\r\n number.to_s.split(\"\").each do |n|\r\n total += n.to_i\r\n end\r\n if total.to_s.length > 1\r\n div_by_3(@total)\r\n end\r\n total\r\nend", "def sumdigit_r(num)\n if num < 10\n num\n else\n sumdigit_r(num/10) + num % 10\n end\nend", "def sum(num)\n digits = num.to_s.chars.map(&:to_i) # Get an array of ints\n digits.reduce(:+) # Return sum of digits\nend", "def num_of_num(number)\n\tnumber_of_num=1\n\tnumber_size=number.to_s.size\n while number_size > 1 do\n number_of_num = number_of_num * \tnumber_size\n number_size = number_size - 1 \n end\n return number_of_num\nend", "def sum(num)\n p num.to_s.chars.tally.keys.map(&:to_i).reduce(:+)\nend", "def add_up(num)\n\tsum = 0;\n\t(1..num).each { |x| sum += x }\n\tsum\nend", "def numSum number\nsum = 0\ncount = 0\nwhile (count < number.to_i)\nputs \"enter num:\"\nnum = gets.chomp\nsum += num.to_i\ncount += 1\nend\nreturn sum\nend", "def MultiplicativePersistence(num)\n count = 0\n\n while num > 9\n num = num.to_s.split(\"\").map{|i| i.to_i}.inject(:*)\n count += 1\n end\n\n count\nend", "def digit_sum (number)\n sum = 0\n base = 10\n while number > 0 do\n sum += number % base\n number /= base\n end\n return sum\nend", "def digits_of_answer(digits)\n n = 0\n previous = 0\n i = 1\n\n\n\n while i.to_s.length < digits\n n += 1\n i, previous = previous, previous + i\n end\n\n (n-1)\nend", "def sum_of_digits(number)\n\treturn (number/100)+((number/10)%10)+(number%10)\nend", "def sum_digits(n)\n return n if n <= 9\n n % 10 + sum_digits(n / 10)\nend", "def sum_func(num)\n return num if num <= 1\n\n divided = num / 10\n moded = num % 10\n\n moded + sum_func(divided)\nend", "def digitcount(num)\n # Convert the number into an array, 1131 -> [1,1,3,1] so we can iterate through\n digits = num.to_s.chars.map(&:to_i)\n # Track the count of seen numbers\n count = 0\n # Track the n-1 array value\n prev = nil\n # The resulting string\n result = ''\n \n # For each digit\n digits.each do |d|\n if prev == d\n # If it's the same number as we've seen before we should inc the counter\n count += 1\n else\n # This isn't a match, so output the previous count and number, reset the counter and carry on\n result += count.to_s + prev.to_s if count > 0\n count = 1\n end\n # In the next loop iteration the previous is the current digit\n prev = d\n end\n \n # Return the result, don't forget the last digit we inspected\n return result += count.to_s + prev.to_s\nend", "def sum_of_factorial_digits(factorial)\r\n\tthe_factorial = (1..factorial).inject(1){ |milti, i| milti * i }\r\n\r\n\treturn the_factorial.to_s.split('').inject(0){ |sum, i| sum + i.to_i }\r\nend", "def sum(num)\na_num = []\nnum_split_string = num.to_s.split('')\n \n while a_num.count < num do\n a_num.push(num_split_string)\n a_num.count\n break\n end\n a_num.flatten!.map! do |e|\n e.to_i\n end\n a_num.sum\nend", "def super_digit(n)\n while n >= 10\n n = n % 10 + super_digit(n / 10)\n end\n return n\nend", "def super_digit(n)\n sum = 0;\n\n while n > 0 || sum > 9\n if n == 0\n n = sum\n sum = 0\n end\n sum += n % 10\n n /= 10\n end\n return sum\nend", "def simple_adding (num)\n the_sum = 0\n i = 0\n while i <= num do\n puts the_sum += i\n i += 1\n end\n return the_sum\nend", "def super_digit(n)\n while n > 9\n n = n % 10 + super_digit(n / 10)\n end\n return n\nend", "def NumberAddition(str)\n num_hold = []\n num_arr = []\n\n str = str.split(\"\")\n\n str << \"end\"\n\n str.each do |char|\n if %w(0 1 2 3 4 5 6 7 8 9).include? char\n num_hold << char\n else\n num_arr << num_hold.join.to_i\n num_hold = []\n end\n end\n\n num_arr.inject(0) {|sum, n| sum + n}\nend", "def sum_of_digits(num)\n\tsum = 0\n\tnum.to_s.each_char { |x| sum = sum + x.to_i}\n\tputs sum\nend", "def SimpleAdding(num)\nsum=0\n 1.upto(num) do |x|\n\tsum+=x\n\tend\n\t\nreturn sum\nend", "def add_up(num)\n return (1..num).inject(:+)\nend", "def check_num(input)\n input = input.to_s\n num_of_checks = input.length\n\n # stick the first number on the end, so we don't need to worry about\n # looping back\n input = input + input[0]\n\n memo = 0\n num_of_checks.times do |i|\n memo = memo + input[i].to_i if input[i] == input[i+1]\n end\n\n memo\nend", "def suma(num)\n\t\ttotal =0\n\t\t((num*2).to_s.chars.map(&:to_i)).each{|x| total+=x}\n\t\treturn total\n\tend", "def multiplicative_persistence(num, count = 0)\n if num < 10\n return count\n else\n num = num.to_s.split(\"\").inject(1){|total,n| total *= n.to_i }\n count += 1\n end\n multiplicative_persistence(num, count)\nend", "def reverse(num)\n reverse = 0\n while num > 0\n last_num = num % 10\n reverse = (reverse * 10) + last_num\n num = num / 10\n end\n return reverse\nend", "def super_digit(n)\n sum = 0\n\n if n < 10\n return sum + n\n else\n until n < 10\n sum += (n % 10)\n n /= 10\n end\n\n sum += n\n end\n\n return super_digit(n = sum)\nend", "def sum_digits(num)\n\nend", "def super_digit(n)\n return n if n < 10\n\n sum = 0 \n\n while n > 0\n digit = n % 10\n n /= 10\n sum += digit\n end\n\n super_digit(sum)\n\nend", "def sum(number)\n count = 0\n split = number.to_s.split('')\n split.each do |num|\n # num = num.to_i\n # count = count + num\n count += num.to_i\n end\n count\nend", "def sum_num(first_num, last_num)\n # Your code goes here\n sum = 0\n first_num = first_num - 1\n num_count = (last_num - first_num)\n num_count.times do\n first_num += 1\n sum += first_num \n end\n return sum\nend", "def add_nums number\n i = number.digits.count - 1\n j = 0\n sum = 0\n array = number.digits\n p i\n loop do\n p array[i]\n sum += array[i]\n i -= 1\n j += 1\n break if i < 0 || j == 2\n end\n sum\nend", "def plus_one(digits)\n carry = 0\n if (digits[-1] + 1) >= 10\n digits[-1] = (digits[-1] + 1) % 10\n carry = 1\n ((digits.size- 2).downto 0).each do |i|\n if (digits[i] + carry) < 10\n digits[i] = digits[i] + carry\n carry = 0\n break\n else\n digits[i] = (digits[i] + carry) % 10\n carry = 1\n end\n end\n else\n digits[-1] = digits[-1] + 1\n end\n digits.insert(0,carry) if carry == 1\n digits\nend", "def occurrances(int, digit)\n\tif int.div(10) == 0 && int == digit\n\t\treturn 1\n\telsif int.div(10) == 0 \n\t\treturn 0\n\telsif int.modulo(10) == digit\n\t\treturn 1 + occurrances(int.div(10), digit)\n\telse\n\t\treturn occurrances(int.div(10), digit)\t\n\tend\t\nend", "def next_num(num, max=9, min=0)\r\n arr = num\r\n done = false\r\n for i in 0...arr.length\r\n index = arr.length - i - 1\r\n \tif arr[index] == max\r\n \t arr[index] = min\r\n \t next\r\n \tend\r\n\t arr[index] += 1\r\n done = true\r\n\t break\r\n end\r\n arr = [min] + arr if not done\r\n arr.join_to_i\r\nend", "def super_digit(n)\n return n if n/10 == 0\n \n sum = n % 10\n while n/10 != 0\n n = n/10\n sum += n % 10\n end\n return super_digit(sum)\nend", "def last_n_digits(num, n)\r\n # your code goes here\r\n num % 10**n\r\nend", "def persistence(n, count = 0)\n return count if n < 10\n i = 0\n arr = n.to_s.split('')\n if arr.length > 1\n tot = arr.map(&:to_i).inject(:*)\n i += 1\n count += 1\n tot.to_i >= 10 ? persistence(tot.to_i, count) : count\n end\nend", "def sum_of_digits(number)\n split_to_array(number).inject(:+)\n end", "def plus_one(digits)\n num = 0\n digits.each_with_index do |digit, index|\n num = num * 10 + digit\n end\n num += 1\n ans = []\n while num > 0 do \n ans.unshift(num % 10)\n num = num / 10\n end\n ans\nend", "def plus_one(digits)\n arr = digits.join.to_i + 1\n arr.to_s.split(\"\").map(&:to_i)\nend", "def summation(num)\n sum = (0..num).inject(:+)\n return sum\nend", "def sum_digits\n self.to_s.split('').inject(0) { |memo, c| memo + c.to_i }\n end", "def product_digits(num)\n return 2 if num.to_s.size == 1\n count = 1\n while num.to_s.size > 1\n divisor = 9\n while num % divisor != 0\n divisor -= 1\n end\n num /= divisor\n count += 1\n end\n count\nend", "def get_digits(num)\n digits = []\n result = num \n first_iter_flag = true\n while(result != 0)\n result = result/10 if(!first_iter_flag)\n first_iter_flag = false if(first_iter_flag)\n digits.unshift result%10 if(result != 0)\n end\n digits\nend", "def fibonacci_digit_counter\n num1, num2, i = -1, 0, 1\n\n #Create a while loop and iterate over the digit value of i, convert i to a string then call the length method\n #on it to get the total number of digits there.\n while i.to_s.length < 1000\n num1 += 1\n #i is equal to num2 and num2 is equal to num2\n i, num2 = num2, num2 + i\n end\n #return num1\n num1\nend", "def sum_digits(integer)\n arr = integer.to_s.chars.map { |num| num.to_i }\n arr.reduce(:+)\nend", "def count_digits(n)\n return 1 if (-9..9).cover? n #n >= -9 and n <= 9\n 1 + count_digits(n / 10)\nend", "def rec_sum(num)\n return num if num <= 1\n num + rec_sum(num - 1)\nend", "def digits_sum(n)\n n.to_s.split('').inject(0){|a,b|a+=b.to_i}\nend", "def SimpleAdding(num)\n answer = (1..num).to_a.inject(:+)\nend", "def sum_to_one_digit(num)\n if num < 1 or not num.is_a? Integer\n puts \"Num must be positive integer\"\n return false;\n end\n\n get_sum = ->(intgr) {\n digit_sum = 0\n intgr = intgr.to_s.split('')\n intgr.each do |i|\n digit_sum += i.to_i\n end\n return digit_sum\n }\n\n sum = get_sum.call(num)\n while sum.to_s.length > 1 do\n sum = get_sum.call(sum)\n end\n\n puts sum\n return sum\nend", "def sum(num)\n num.digits.sum\nend", "def sum(num)\n num.digits.sum\nend", "def sum(num)\n num.digits.sum\nend", "def sum(num)\n num.digits.sum\nend", "def super_digit(n)\n return n if n < 10\n\n sum_digits = 0\n until n == 0\n sum_digits += n % 10\n n /= 10\n end\n\n super_digit(sum_digits)\nend", "def sum_all_digits(num)\n split_string = num.to_s.split('')\n split_string.map!(&:to_i)\n sum_digits = split_string.inject(0) { |res,el| res + el }\n return sum_digits\nend", "def super_digit(n)\n sum = 0\n while n >= 10 do\n sum += n % 10\n n /= 10\n end\n sum += n\n return sum < 10 ? sum : super_digit(sum)\nend" ]
[ "0.84167403", "0.80365", "0.77320504", "0.7713103", "0.7605349", "0.74756783", "0.7138025", "0.7126007", "0.70803404", "0.7049356", "0.70313007", "0.7028427", "0.7020832", "0.69682056", "0.69554216", "0.69242376", "0.6908651", "0.69063514", "0.6901997", "0.6889966", "0.6857473", "0.6841833", "0.68355256", "0.6832448", "0.68011886", "0.6779099", "0.6771885", "0.6765986", "0.67578095", "0.6748684", "0.6744979", "0.6735768", "0.67321694", "0.67298496", "0.6725219", "0.67181593", "0.67112017", "0.6695115", "0.669", "0.66867", "0.6672773", "0.66669947", "0.6665876", "0.66579574", "0.6657645", "0.6647279", "0.6639766", "0.6637417", "0.6633053", "0.6625335", "0.66222316", "0.6577791", "0.6566931", "0.6564333", "0.6558416", "0.6550267", "0.65373766", "0.6535567", "0.6519312", "0.64960015", "0.6495126", "0.64914745", "0.6482641", "0.64812654", "0.64722425", "0.6465097", "0.6461354", "0.645156", "0.6449098", "0.6445187", "0.6442008", "0.64409184", "0.64293486", "0.64140964", "0.6410716", "0.6404365", "0.64028203", "0.64008254", "0.63992614", "0.63983065", "0.6380529", "0.6377815", "0.63704145", "0.63634884", "0.6362898", "0.6356735", "0.63501567", "0.63401407", "0.63351065", "0.63347965", "0.6330785", "0.6330617", "0.63298994", "0.6329343", "0.6329343", "0.6329343", "0.6329343", "0.6322095", "0.6321126", "0.6314383" ]
0.8045087
1
GET /projects GET /projects.json
def index @completed_projects = Project.where(status: "completed").order("id ASC") @development_projects = Project.where(status: "in_development").order("id ASC") @tools = Tool.all.order("id ASC") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def listprojects\n get('listprojects.json')['projects']\n end", "def list\n get 'projects'\n end", "def projects\n request(method: 'getAllProjects')\n end", "def projects\n resource 'projects'\n end", "def projects(params = {})\n make_get_request('/account/projects', params)\n end", "def projects\n Sifter.\n get(\"/api/projects\").\n parsed_response[\"projects\"].\n map { |p| Sifter::Project.new(p) }\n end", "def index\n @projects = Project.all\n render json: @projects\n end", "def index\n # @projects = @current_user.projects\n @projects = Project.all\n json_response(@projects)\n end", "def index\n @projects = Project.all\n render json: @projects, status: :ok\n end", "def get_projects\n me = request('/services/v5/me')\n me['projects']\n end", "def index\n @projects = current_user.projects\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @projects }\n end\n end", "def get\n CircleCi.request(conf, '/projects').get\n end", "def projects\n return forbidden unless current_account # already returns a 401 if credentials aren't supplied\n opts = { :include_document_ids => params[:include_document_ids] != 'false' }\n @response = {'projects' => Project.accessible(current_account).map {|p| p.canonical(opts) } }\n render_cross_origin_json\n end", "def projects\n records \"project\", \"/project/list\"\n end", "def index\n @projects = current_user.projects.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @projects }\n end\n end", "def index\n @projects = Project.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @projects }\n end\n end", "def index\n @projects = Project.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @projects }\n end\n end", "def index\n @projects = Project.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @projects }\n end\n end", "def index\n @projects = Project.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @projects }\n end\n end", "def index\n @projects = Project.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @projects }\n end\n end", "def index\n @projects = Project.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @projects }\n end\n end", "def index\n @projects = Project.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @projects }\n end\n end", "def index\n @projects = Project.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @projects }\n end\n end", "def index\n @projects = Project.all\n render json: @projects, layout: false\n end", "def projects(params = {})\n fetch_all('projects', 'projects', params)\n end", "def index\n @projects = Project.all_for_user(current_user.id)\n render json: @projects.to_json(include: :project_detail), status: 200\n end", "def index\n @projects = Project.visible\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @projects }\n end\n end", "def index\n @user = User.find_by(id: params[:user_id])\n @project = @user.projects\n if @project \n render :json => @project\n else\n render :json => 422\n end\n end", "def index\n @projects = Project.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @projects }\n end\n end", "def all_projects()\n @endpoint = \"/projects.json?limit=100\"\n setup_get\n res = @http.request(@req)\n return JSON.load(res.body)[\"projects\"].sort_by { |proj| proj[\"name\"] }\n end", "def index\n \n @workspaces = current_user.workspaces\n # debugger\n @projects = Project.where(:workspace_id => @workspace)\n\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @projects }\n end\n end", "def projects(options = {})\n get(\"projects\", options).projects\n end", "def list_projects\n handle_action_exceptions(__method__) do\n cmd_line = ['listprojects']\n cmd_line << 'json' if @json\n\n handle_return(@toolshck_ether.cmd(cmd_line.join(' ')))\n end\n end", "def index\n @projects = Project.includes(:user).all\n respond_with(@projects) do |format|\n format.json { render :json => {:list => @projects.as_json, :current_user => current_user.as_json} }\n format.html\n end\n end", "def projects(req_params = {})\n name = 'Projects'\n params = { req: req_params }\n\n data = endpoint(name: name, params: params).do_get\n\n collection name, data\n end", "def index \n\n @projects = Project.all\n respond_to do |format|\n format.html {render :template => \"projects/index\"}\n format.json { render json: @projects }\n end\n end", "def index\n @projects = Project.with_permissions_to(:read)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @projects }\n end\n end", "def projects\n @projects ||= Harvest::API::Projects.new(credentials)\n end", "def show\n @project = @client.projects.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @project }\n end\n end", "def index\n @projects = Project.where user: current_user\n render json: @projects, each_serializer: Projects::IndexSerializer\n end", "def index\n @projects = Project.order_by_company_and_project.paginate(page: params[:page] || 1, per_page: helpers.pager_per_page)\n respond_to do |format|\n message = @projects.present? ? \"\" : \"There are no projects available at this time\"\n format.json do\n status = @projects.present? ? :ok : :not_found\n render json: { response: @projects, status: status, message: message }\n end\n format.html do\n # Only authorize html format, json is okay because we use it as\n # an api.\n authorize(:project)\n flash[:alert] = message unless message.blank?\n @projects\n end\n end\n end", "def index\n if signed_in?\n @projects = current_user.projects\n respond_to do |format|\n format.html { render 'projects/index' }\n format.json { render template: 'projects/index.json.jbuilder' }\n end\n else\n redirect_to :projects\n end\n end", "def get_projects_of_user\n respond_to do |format|\n format.json {\n #param = params[:payload]\n #@user = User.find_by_id(param[:id])\n @projects = Project.where(:user_id => @current_user.id)\n if @projects\n render :json => @projects\n else\n render :nothing => true, :status => 200, :content_type => 'text/html'\n end\n }\n end\n end", "def get_projects_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: ProjectsApi.get_projects ...'\n end\n # resource path\n local_var_path = '/projects'\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['Token']\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'Projects')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ProjectsApi#get_projects\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def show_all_projects\r\n json = GoodData.get GoodData.profile.projects\r\n puts \"You have this project available:\"\r\n json[\"projects\"].map do |project|\r\n pid = project[\"project\"][\"links\"][\"roles\"].to_s\r\n puts \"Project name: #{project[\"project\"][\"meta\"][\"title\"].bright} Project PID: #{pid.match(\"[^\\/]{32}\").to_s.bright}\"\r\n end\r\n end", "def init_projects\n @projects = []\n\n response = @conn.get do |req|\n req.url \"/api/v1/projects\"\n req.headers = rest_headers\n end\n\n @projects = json(response.body)[:projects]\n end", "def projects\n @projects ||= begin\n http = Net::HTTP.new(API_HOST, API_PORT)\n http.use_ssl = true\n http.ca_file = (Twigg.root + 'files' + 'github.pem').to_s\n http.verify_mode = OpenSSL::SSL::VERIFY_PEER\n uri = ORG_REPOS_ENDPOINT % Config.github.organization\n headers = { 'Authorization' => \"token #{Config.github.token}\" }\n\n [].tap do |names|\n begin # loop: page through project list\n request = Net::HTTP::Get.new(uri, headers)\n response = http.request(request)\n raise \"Bad response #{response.inspect}\" unless response.is_a?(Net::HTTPOK)\n names.concat JSON[response.body].map { |repo| repo['name'] }\n uri = parse_link(response['Link'])\n end until uri.nil?\n end\n end\n end", "def projects\n @projects = Project.order(created_at: :desc).page(@page).per(10)\n respond_to do |format|\n format.html\n format.js { render :projects}\n end\n end", "def list_project(optional={})\n\t\targs = self.class.new_params\n\t\targs[:method] = 'GET'\n\t\targs[:pattern] = '/projects'\n\t\targs[:query]['Action'] = 'ListProject'\n\t\targs[:region] = optional[:_region] if (optional.key? :_region)\n\t\targs[:scheme] = 'http'\n\t\tif optional.key? :page\n\t\t\targs[:query]['Page'] = optional[:page]\n\t\tend\n\t\tif optional.key? :page_size\n\t\t\targs[:query]['PageSize'] = optional[:page_size]\n\t\tend\n\t\tif optional.key? :project_owner\n\t\t\targs[:query]['ProjectOwner'] = optional[:project_owner]\n\t\tend\n\t\tself.run(args)\n\tend", "def project(project_id, options={})\n response_body = nil\n begin\n response = connection.get do |req|\n req.url \"/api/v1/projects/#{project_id}\", options\n end\n response_body = response.body\n rescue MultiJson::DecodeError => e\n #p 'Unable to parse JSON.'\n end\n \n response_body\n end", "def index\n\t\tif present_user.role? 'admin'\n\t\t\t@projects = Project.all\n\t\telse\n\t\t\t@projects = present_user.projects\n\t\tend\n\t\tmake_breadcrumbs\n\n\t\trespond_to do |format|\n\t\t\tformat.html # index.html.erb\n\t\t\tformat.json { render json: @projects }\n\t\tend\n\tend", "def show\n @projects = find_projects\n end", "def index\n projects = current_user.admin_projects.paginate(:page => params[:page])\n render json: projects\n end", "def list\r\n @projects = Project.where(user:current_user).order(created_at: :desc).page(params[:page])\r\n respond_with(@projects)\r\n end", "def index\n @user = User.find_by_id(session[:userid])\n @projects = current_user_projects\n respond_to do |format|\n format.html # index.html.erb\n format.json\n end\n end", "def index\n @user = get_user\n @projects = Project.all\n # render :inline => @projects.to_json\n end", "def project\n request :project\n end", "def show\n\n render json: Project.all\n\n end", "def listProjects \n uri = URI(RUNDECKSERVER + ':' + RUNDECKPORT + '/api/1/projects')\n http = Net::HTTP.new(uri.host, uri.port)\n headers = {\n 'Content-Type'=> 'application/json',\n 'X-RunDeck-Auth-Token'=> API_KEY \n}\n r = http.get(uri.path, headers)\n return r.body.force_encoding(\"UTF-8\")\n\nend", "def available_projects_list\n uri = \"#{@api_url}?access_token=#{@access_token}\"\n get uri\n end", "def index\n @projects = current_user.active_projects.includes(:project_errors)\n @project_invitations = current_user.user_projects.pending\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @projects }\n end\n end", "def project(project_id, params = {})\n make_get_request(\"/projects/#{project_id}\", params)\n end", "def list_projects # :nologin:\n query = create_query(:Project, :all, :by => :title)\n show_selected_projects(query)\n end", "def index\n @projects = Project.includes(:participants).all\n\n render json: @projects, include: :participants, status: 200\n end", "def show\n render json: @project\n end", "def projects\n @projects\n end", "def index\n @projects = @projects.includes(:latest_iteration).where(:tenant_id => current_user.tenant).order(\"name\").page(params[:page]).per(DEFAULT_ROWS_PER_PAGE)\n\n respond_with @projects\n end", "def index\n @projects = Service::JIRA.projects\n respond_with(@projects) do |format|\n format.json { render json: @projects.to_a.sort_by(&:name).map(&:attrs).to_json }\n end\n end", "def projects\n Harvest::Resources::Project\n end", "def project(project_id, query_params = nil)\n get(\"/projects/#{project_id}\", query_params)\n end", "def get_projects_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: ProjectsApi#get_projects ...\"\n end\n \n # resource path\n path = \"/Projects\".sub('{format}','json')\n\n # query parameters\n query_params = {}\n query_params[:'brief'] = opts[:'brief'] if opts[:'brief']\n query_params[:'skip'] = opts[:'skip'] if opts[:'skip']\n query_params[:'top'] = opts[:'top'] if opts[:'top']\n query_params[:'count_total'] = opts[:'count_total'] if opts[:'count_total']\n\n # header parameters\n header_params = {}\n\n # HTTP header 'Accept' (if needed)\n _header_accept = ['application/json']\n _header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result\n\n # HTTP header 'Content-Type'\n _header_content_type = ['application/json']\n header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type)\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n \n\n auth_names = []\n data, status_code, headers = @api_client.call_api(:GET, path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'Array<APIProject>')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ProjectsApi#get_projects\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def index\n @projects = @namespace.projects.all\n end", "def projects\n tmp = client.get @json['user']['links']['projects']\n tmp['projects'].map do |project_meta|\n project_uri = project_meta['project']['links']['self']\n project = client.get project_uri\n client.factory.create(GoodData::Project, project)\n end\n end", "def get_projects_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: ProjectApi.get_projects ...'\n end\n # resource path\n local_var_path = '/v1/project'\n\n # query parameters\n query_params = opts[:query_params] || {}\n query_params[:'name'] = opts[:'name'] if !opts[:'name'].nil?\n query_params[:'excludeInactive'] = opts[:'exclude_inactive'] if !opts[:'exclude_inactive'].nil?\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:body] \n\n # return_type\n return_type = opts[:return_type] || 'Array<Project>' \n\n # auth_names\n auth_names = opts[:auth_names] || ['X-Api-Key']\n\n new_options = opts.merge(\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ProjectApi#get_projects\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def index\n\t\t@projects = Project.all\n\tend", "def index\n #@projects = []\n if current_user\n #@projects = current_user.projects.where(\"memberships.status >= ?\", 1)\n end\n\n if params[:id]\n @project = Project.find(params[:id])\n authorize! :read, @project\n else\n @project = @projects.first\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.js { render :action => 'show'}\n format.json { render json: @projects }\n end\n end", "def index_participating\n projects = current_user.projects.paginate(:page => params[:page])\n render json: projects\n end", "def list_project(optional={})\n\t\targs = self.class.new_params\n\t\targs[:method] = 'GET'\n\t\targs[:query]['Action'] = 'ListProject'\n\t\targs[:region] = optional[:_region] if (optional.key? :_region)\n\t\targs[:scheme] = 'http'\n\t\tif optional.key? :page\n\t\t\targs[:query]['Page'] = optional[:page]\n\t\tend\n\t\tif optional.key? :page_size\n\t\t\targs[:query]['PageSize'] = optional[:page_size]\n\t\tend\n\t\tif optional.key? :project_owner\n\t\t\targs[:query]['ProjectOwner'] = optional[:project_owner]\n\t\tend\n\t\tself.run(args)\n\tend", "def project\n return forbidden unless current_account and params[:id] and (request.format.json? || request.format.js? || request.format.text?)\n project = Project.accessible(current_account).find(params[:id].to_i)\n return not_found unless project\n opts = { :include_document_ids => params[:include_document_ids] != 'false' }\n @response = {'project' => project.canonical(opts)}\n render_cross_origin_json\n end", "def show \n project= Project.find(params[:id])\n\n render json: project\n end", "def list_projects(company_id: )\n url = \"#{@base_url}/vapid/projects?company_id=#{company_id}\"\n HTTParty.get(url, headers: procore_headers(token: @customer_info[:token], company_id: @customer_info[:company_id] )).parsed_response\n end", "def index\n @projects = current_user.projects\n end", "def index\n @projects = current_user.projects\n end", "def index\n @projects = current_user.projects\n end", "def index\n @projects = current_user.projects\n end", "def index\n @projects = current_user.projects\n end", "def index\n @projects = current_user.projects\n end", "def index\n @projects = current_user.projects\n end", "def index\n @projects = current_user.projects\n end", "def index\n @projects_people = ProjectsPerson.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @projects_people }\n end\n end", "def index\r\n @projects = current_user.projects\r\n end", "def projects\n PivotalTracker::Project.all\n end", "def show\n render json: Project.where(id: params.fetch(:id))\n end", "def get_projects\n @params=task_params\n @client=current_user.clients.find(@params[:client_id])\n counter=0\n @res=[]\n @client.projects.each do |c|\n if c.users.include? current_user\n @res[counter]={\n project_id: c.id, \n name: c.name\n }\n counter+=1\n end\n end\n respond_to do |format|\n format.json {render json: @res.uniq}\n end\n end", "def show\n @projects = Project.all\n end", "def projects\n @projects ||= begin\n user = api('user')\n api(\"users/#{user['id']}/projects\").sort_by { |p| p['id'] }\n end\nend", "def list_projects_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: QcApi.list_projects ...\"\n end\n # resource path\n local_var_path = \"/projects.json\"\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['api_key']\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'Array<Project>')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: QcApi#list_projects\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def getProjectID()\n result = RestClient.get GITHUB_API + PROJECTS_PATH, :accept => 'application/vnd.github.inertia-preview+json', :'Authorization' => 'token ' + CONFIG['OAUTH']\n result = JSON.parse(result) \n end", "def index\n @projects = Project.all\n end", "def index\n @projects = Project.all\n end", "def index\n @projects = Project.all\n end" ]
[ "0.8574897", "0.8386689", "0.8355737", "0.8062607", "0.80368364", "0.8002139", "0.78593457", "0.7834634", "0.78324", "0.7799698", "0.77792805", "0.7748103", "0.77139485", "0.7700251", "0.7696023", "0.7695487", "0.7695487", "0.7695487", "0.7695487", "0.7695487", "0.7695487", "0.7695487", "0.7695384", "0.7677249", "0.7659848", "0.76413786", "0.7627596", "0.76157665", "0.76007134", "0.75998086", "0.7599048", "0.755127", "0.75476474", "0.7504184", "0.7464399", "0.7463047", "0.74520797", "0.7440121", "0.74273944", "0.74115896", "0.74086154", "0.7406792", "0.73953074", "0.73152006", "0.72899425", "0.7288984", "0.727693", "0.72592014", "0.725888", "0.72443324", "0.72430474", "0.7232267", "0.7224122", "0.7218089", "0.7194763", "0.7187098", "0.71705997", "0.7170378", "0.7167435", "0.7164896", "0.71607876", "0.7140332", "0.7130536", "0.7128779", "0.7127035", "0.7124004", "0.7118136", "0.711526", "0.7114364", "0.71083033", "0.71005213", "0.7098299", "0.70919305", "0.70723647", "0.70523155", "0.70496404", "0.70492387", "0.7042553", "0.70393467", "0.7036608", "0.7033363", "0.7031996", "0.7031996", "0.7031996", "0.7031996", "0.7031996", "0.7031996", "0.7031996", "0.7031996", "0.70277584", "0.7026879", "0.7022911", "0.70143616", "0.70081574", "0.70047146", "0.70036596", "0.7003546", "0.7002825", "0.69961166", "0.69961166", "0.69961166" ]
0.0
-1
GET /projects/1 GET /projects/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def list\n get 'projects'\n end", "def listprojects\n get('listprojects.json')['projects']\n end", "def show\n @project = @client.projects.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @project }\n end\n end", "def projects\n resource 'projects'\n end", "def index\n @projects = Project.all\n render json: @projects, status: :ok\n end", "def index\n @projects = Project.all\n render json: @projects\n end", "def index\n @projects = Project.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @projects }\n end\n end", "def index\n @projects = Project.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @projects }\n end\n end", "def index\n @projects = Project.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @projects }\n end\n end", "def index\n @projects = Project.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @projects }\n end\n end", "def index\n @projects = Project.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @projects }\n end\n end", "def index\n @projects = Project.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @projects }\n end\n end", "def index\n @projects = Project.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @projects }\n end\n end", "def index\n @projects = Project.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @projects }\n end\n end", "def index\n @user = User.find_by(id: params[:user_id])\n @project = @user.projects\n if @project \n render :json => @project\n else\n render :json => 422\n end\n end", "def projects\n request(method: 'getAllProjects')\n end", "def project(project_id, params = {})\n make_get_request(\"/projects/#{project_id}\", params)\n end", "def index\n @projects = Project.visible\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @projects }\n end\n end", "def index\n @projects = Project.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @projects }\n end\n end", "def show\n render json: Project.where(id: params.fetch(:id))\n end", "def show \n project= Project.find(params[:id])\n\n render json: project\n end", "def index\n @projects = Project.all_for_user(current_user.id)\n render json: @projects.to_json(include: :project_detail), status: 200\n end", "def project(project_id, options={})\n response_body = nil\n begin\n response = connection.get do |req|\n req.url \"/api/v1/projects/#{project_id}\", options\n end\n response_body = response.body\n rescue MultiJson::DecodeError => e\n #p 'Unable to parse JSON.'\n end\n \n response_body\n end", "def index\n @projects = current_user.projects\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @projects }\n end\n end", "def show\n @project = Project.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @project }\n end\n end", "def show\n @project = Project.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @project }\n end\n end", "def show\n @project = Project.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @project }\n end\n end", "def show\n @project = Project.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @project }\n end\n end", "def show\n @project = Project.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @project }\n end\n end", "def show\n @project = Project.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @project }\n end\n end", "def show\n @project = Project.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @project }\n end\n end", "def show\n @project = Project.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @project }\n end\n end", "def show\n @project = Project.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @project }\n end\n end", "def show\n @project = Project.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @project }\n end\n end", "def show\n @project = Project.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @project }\n end\n end", "def show\n @project = Project.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @project }\n end\n end", "def show\n @project = Project.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @project }\n end\n end", "def show\n @project = Project.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @project }\n end\n end", "def show\n @project = Project.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @project }\n end\n end", "def project(project_id, query_params = nil)\n get(\"/projects/#{project_id}\", query_params)\n end", "def project(project_id)\n resource \"projects/#{project_id}\"\n end", "def index\n @projects = Project.all\n render json: @projects, layout: false\n end", "def getProjectID()\n result = RestClient.get GITHUB_API + PROJECTS_PATH, :accept => 'application/vnd.github.inertia-preview+json', :'Authorization' => 'token ' + CONFIG['OAUTH']\n result = JSON.parse(result) \n end", "def show\n @project = Project.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @project }\n end\n end", "def get\n CircleCi.request(conf, '/projects').get\n end", "def index\n # @projects = @current_user.projects\n @projects = Project.all\n json_response(@projects)\n end", "def projects\n records \"project\", \"/project/list\"\n end", "def projects\n Sifter.\n get(\"/api/projects\").\n parsed_response[\"projects\"].\n map { |p| Sifter::Project.new(p) }\n end", "def index \n\n @projects = Project.all\n respond_to do |format|\n format.html {render :template => \"projects/index\"}\n format.json { render json: @projects }\n end\n end", "def index\n @projects = current_user.projects.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @projects }\n end\n end", "def index\n \n @workspaces = current_user.workspaces\n # debugger\n @projects = Project.where(:workspace_id => @workspace)\n\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @projects }\n end\n end", "def show\n @project = Project.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @project }\n end\n end", "def show\n render json: @project\n end", "def show\n repo = ProjectRepo.new current_user\n @v_project = repo.get(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @v_project }\n end\n end", "def find_project(name)\n get(\"/projects/#{name}\")\n end", "def find_project(name)\n get(\"/projects/#{name}\")\n end", "def show\n @project = Project.find_by(id: params[:id])\n if @project\n render :json => @project\n else\n render :json => 422\n end\n end", "def projects(params = {})\n make_get_request('/account/projects', params)\n end", "def project\n request :project\n end", "def project\n return forbidden unless current_account and params[:id] and (request.format.json? || request.format.js? || request.format.text?)\n project = Project.accessible(current_account).find(params[:id].to_i)\n return not_found unless project\n opts = { :include_document_ids => params[:include_document_ids] != 'false' }\n @response = {'project' => project.canonical(opts)}\n render_cross_origin_json\n end", "def show \n render :json => Project.find_by_id(params[:id])\n end", "def show\n @ourproject = Ourproject.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @ourproject }\n end\n end", "def get_project(project_id)\n http = Net::HTTP.new(@city_db_url, @port)\n http.read_timeout = 1000\n if @city_db_is_https\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n end\n\n request = Net::HTTP::Get.new(\"/projects/#{project_id}.json\")\n request.add_field('Content-Type', 'application/json')\n request.add_field('Accept', 'application/json')\n request.basic_auth(ENV['URBANOPT_USERNAME'], ENV['URBANOPT_PASSWORD'])\n\n response = http.request(request)\n if response.code != '200' # success\n @runner.registerError(\"Bad response #{response.code}\")\n @runner.registerError(response.body)\n @result = false\n return {}\n end\n\n result = JSON.parse(response.body, symbolize_names: true)\n return result\n end", "def index\n @projects = Project.with_permissions_to(:read)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @projects }\n end\n end", "def show\n @projectresource = Projectresource.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @projectresource }\n end\n end", "def index\n @projects = Project.where user: current_user\n render json: @projects, each_serializer: Projects::IndexSerializer\n end", "def show \n respond_to do |format|\n format.json {\n\n @project = Project.find_by_id(params[:id])\n\n if @project\n render :json => @project\n else\n render :nothing => true, :status => 200, :content_type => 'text/html'\n end\n }\n end\n end", "def show\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @project }\n end\n end", "def show\n @current_project = CurrentProject.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @current_project }\n end\n end", "def show\n respond_with(@project) do |format|\n format.json { render json: @project.as_json }\n format.html\n end\n end", "def show\n @show_project = Project.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @show_project }\n end\n end", "def show\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @project }\n end\n end", "def show\n respond_with @project do |format|\n format.json do\n render json: @project.as_json.merge(\n commits_url: project_commits_url(@project, format: 'json'),\n commits: @project.commits.order('committed_at DESC').limit(10).map { |commit|\n commit.as_json.merge(\n percent_done: commit.fraction_done.nan? ? 0.0 : commit.fraction_done*100,\n translations_done: commit.translations_done,\n translations_total: commit.translations_total,\n strings_total: commit.strings_total,\n import_url: import_project_commit_url(@project, commit, format: 'json'),\n sync_url: sync_project_commit_url(@project, commit, format: 'json'),\n url: project_commit_url(@project, commit),\n status_url: project_commit_url(@project, commit),\n )\n }\n )\n end\n end\n end", "def show\n # turn ruby database into json\n # route to the project 3 page with this json\n # id = 1\n end", "def projects(params = {})\n fetch_all('projects', 'projects', params)\n end", "def show\n\n render json: Project.all\n\n end", "def show\n set_surrogate_key_header \"api/platforms/#{@platform.id}/projects\"\n set_cache_control_headers 3600\n end", "def index\n @about_projects = AboutProject.last(1)\n\n respond_to do |format|\n format.json {render json: @about_projects[0], :only => [:description]}\n end\n end", "def show\n @projects = find_projects\n end", "def get_project(optional={})\n\t\targs = self.class.new_params\n\t\targs[:method] = 'GET'\n\t\targs[:pattern] = '/projects/[ProjectName]'\n\t\targs[:query]['Action'] = 'GetProject'\n\t\targs[:region] = optional[:_region] if (optional.key? :_region)\n\t\targs[:scheme] = 'http'\n\t\tif optional.key? :project_name\n\t\t\targs[:path]['ProjectName'] = optional[:project_name]\n\t\tend\n\t\tself.run(args)\n\tend", "def show_by_gitpath\n @project = Project.includes(:users).includes(:technos).find_by_gitpath(params[:gitpath])\n\n respond_to do |format|\n format.json { render json: @project, status: 200 }\n end\n end", "def project\n @client.project(:id => project_id)\n end", "def list_projects\n handle_action_exceptions(__method__) do\n cmd_line = ['listprojects']\n cmd_line << 'json' if @json\n\n handle_return(@toolshck_ether.cmd(cmd_line.join(' ')))\n end\n end", "def index\n #@projects = []\n if current_user\n #@projects = current_user.projects.where(\"memberships.status >= ?\", 1)\n end\n\n if params[:id]\n @project = Project.find(params[:id])\n authorize! :read, @project\n else\n @project = @projects.first\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.js { render :action => 'show'}\n format.json { render json: @projects }\n end\n end", "def projects\n return forbidden unless current_account # already returns a 401 if credentials aren't supplied\n opts = { :include_document_ids => params[:include_document_ids] != 'false' }\n @response = {'projects' => Project.accessible(current_account).map {|p| p.canonical(opts) } }\n render_cross_origin_json\n end", "def get_projects_of_user\n respond_to do |format|\n format.json {\n #param = params[:payload]\n #@user = User.find_by_id(param[:id])\n @projects = Project.where(:user_id => @current_user.id)\n if @projects\n render :json => @projects\n else\n render :nothing => true, :status => 200, :content_type => 'text/html'\n end\n }\n end\n end", "def get\n render json: Project.select(:id, \"name as label\")\n end", "def index\n @projects = Project.includes(:user).all\n respond_with(@projects) do |format|\n format.json { render :json => {:list => @projects.as_json, :current_user => current_user.as_json} }\n format.html\n end\n end", "def details\n get(\"project/details\")[\"project\"]\n end", "def show\n @workspaces = current_user.workspaces\n @project = Project.find(params[:id])\n @workspace = Workspace.find(params[:workspace_id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @project }\n end\n end", "def get(project_name)\n response = get_request(\"/projects/#{project_name}/\")\n TheShiningSource::Project.new(response)\n end", "def show\n @unfinished_project = UnfinishedProject.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @unfinished_project }\n end\n end", "def index\n @user = User.find_by_id(session[:userid])\n @projects = current_user_projects\n respond_to do |format|\n format.html # index.html.erb\n format.json\n end\n end", "def show_project\r\n @project = Project.find(params[:id])\r\n @id = @project.id\r\n respond_to do |format|\r\n format.html { render 'project_control/view' }\r\n format.json { render json: @project }\r\n end\r\n end", "def getProject(project)\r\n\t\t\t\tproject_json = JSON.parse project\r\n\t\t\t\tproject_array = project_json[\"projects\"]\r\n\t\t\t\treturn jsonToProject(project_array[0])\r\n\t\t\tend", "def show\n @project = Project.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @projects }\n #format.json { render json: @project.as_json(:include => [:client, :project_participants] ) }\n end\n end", "def index\n if signed_in?\n @projects = current_user.projects\n respond_to do |format|\n format.html { render 'projects/index' }\n format.json { render template: 'projects/index.json.jbuilder' }\n end\n else\n redirect_to :projects\n end\n end", "def index\n @projects = @projects.includes(:latest_iteration).where(:tenant_id => current_user.tenant).order(\"name\").page(params[:page]).per(DEFAULT_ROWS_PER_PAGE)\n\n respond_with @projects\n end", "def show\n respond_to do |format|\n format.html {render :show}\n format.json {render json: @project}\n end\n end", "def show\n @project = Project.find(params[:id])\n\t@user = User.find(@project.user_id)\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @project }\n end\n end", "def find(project_id)\n raw_response = get_request(\"projects/#{project_id}\")\n parse_response(raw_response, :project)\n end" ]
[ "0.78697544", "0.7698408", "0.7680339", "0.7613705", "0.75337136", "0.7525879", "0.7493363", "0.7493363", "0.7493363", "0.7493363", "0.7493363", "0.7493363", "0.7493363", "0.74931365", "0.7483965", "0.74803555", "0.7446126", "0.7429718", "0.74231553", "0.7414986", "0.7385634", "0.7380362", "0.73794556", "0.7375584", "0.73619705", "0.73619705", "0.73619705", "0.73619705", "0.73619705", "0.73619705", "0.73619705", "0.73619705", "0.73619705", "0.73619705", "0.73619705", "0.73619705", "0.73619705", "0.73619705", "0.73619705", "0.73588735", "0.7354991", "0.7352316", "0.7343573", "0.73419714", "0.7326049", "0.7303268", "0.72901344", "0.727417", "0.7273762", "0.72540456", "0.7252145", "0.7251143", "0.7242956", "0.724223", "0.72293097", "0.72293097", "0.7213873", "0.72112584", "0.7204831", "0.7196271", "0.7184846", "0.71561235", "0.71503824", "0.71490365", "0.7121025", "0.7112306", "0.7106593", "0.7086883", "0.7084719", "0.70793617", "0.70527", "0.7050857", "0.70440745", "0.70436114", "0.70263803", "0.7026122", "0.7004827", "0.7004275", "0.70039594", "0.7001873", "0.69874394", "0.6986131", "0.6980996", "0.69805783", "0.6978405", "0.6976709", "0.69693714", "0.6965785", "0.6965646", "0.6962675", "0.6962555", "0.69625133", "0.69619524", "0.69581634", "0.6943415", "0.6935823", "0.6934703", "0.69173646", "0.69126534", "0.6910493", "0.6905561" ]
0.0
-1
POST /projects POST /projects.json
def create @project = Project.new(project_params) respond_to do |format| if @project.save format.html { redirect_to projects_url, notice: 'Project was successfully created.' } format.json { render :show, status: :created, location: @project } else format.html { render :new } format.json { render json: @project.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @project = Project.new(params[:project])\n\n respond_to do |format|\n if @project.save\n format.json { render :json => @project, :status => :created, :location => @project }\n format.html { redirect_to(projects_path) }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @project.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create_project(name)\n post('projects', {:name => name})[\"project\"]\n end", "def create\n @project = Project.new(project_params)\n\n if @project.save\n render json: @project, status: 200\n else\n render json: { errors: @project.errors.messages }, status: 200\n end\n end", "def create\n @project = Project.new(project_params)\n\n if @project.save\n render json: @project, status: :created\n else\n render json: @project.errors, status: :unprocessable_entity\n end\n end", "def create\n @urlroot = Designax::Application.config.urlroot\n if params[:pk] == \"new\" and params[:name] == \"project_name\"\n project_name = params[:value]\n @project = Project.new()\n @project.project_name = project_name\n else\n @project = Project.new(params[:project])\n end\n\n respond_to do |format|\n if @project.save\n redirect_url = @urlroot + \"/projects\"\n response_url = { \"url\" => redirect_url }\n format.json { render json: response_url, status: 200 }\n else\n format.html { render action: \"new\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(params[:project] || JSON.parse(request.body.read))\n\n if (params[:id])\n @project.id = params[:id]\n end\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to(@project, :notice => 'Project was successfully created.') }\n format.xml { render :xml => @project, :status => :created, :location => @project }\n format.json { render :json => @project }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @project.errors, :status => :unprocessable_entity }\n format.json { render :text => \"error creating project via http/json\" }\n end\n end\n end", "def test_should_create_project_via_API_JSON\r\n get \"/logout\"\r\n post \"/projects.json\", :api_key => 'testapikey',\r\n :project => {:user_id => 1,\r\n :url => 'http://www.apiproject.com',\r\n :name => 'API Project',\r\n :description => 'API Project Desc' }\r\n assert_response :created\r\n project = JSON.parse(response.body)\r\n check_new_project(project) \r\n end", "def create\n\t\t@project = current_user.projects.new(project_params)\n\n\t\trespond_to do |format|\n\t\t\tif @project.save\n\t\t\t\tformat.json { render :show, status: :created }\n\t\t\telse\n\t\t\t\tformat.json { render json: @project.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend", "def create\n @projects = current_user.projects\n @project = current_user.projects.new(project_params)\n\n respond_to do |format|\n if @projects << @project\n format.html { redirect_to user_projects_path(current_user), notice: 'Project was successfully created.' }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(params[:project])\n\n respond_to do |format|\n if @project.save\n format.json { render json: @project, status: :created, location: @project }\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n else\n format.json { render json: @project.errors, status: :unprocessable_entity }\n format.html { render action: \"new\" }\n end\n end\n end", "def create\n @project = current_user.projects.new(params[:project])\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render json: @project, status: :created, location: @project }\n else\n format.html { render action: \"new\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create(attributes={})\n raw_response = post_request('projects', project: attributes)\n parse_response(raw_response, :project)\n end", "def create\n #byebug\n @project = Project.new(create_params)\n @project.user_id = @current_user.id\n @project.save\n #@project = Project.create(name_project: \"prueba\", subsidy: true, parking: true, user_id: @current_user.id)\n #byebug\n render json: @project, status: :created\n end", "def create\n @project = Project.new(params[:project])\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to(@project, :notice => 'Project was successfully created.') }\n format.json { render :json => @project, :status => :created, :location => @project }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @project.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(params[:project])\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to projects_path, notice: 'Project was successfully created.' }\n format.json { render json: @project, status: :created, location: @project }\n else\n format.html { render action: \"new\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(project_params)\n if @project.save\n render json: @project, status: :ok\n else\n render json: {error: @project.errors.full_messages.to_sentence } , status: :unprocessable_entity\n end\n end", "def create\n @user = current_user\n @project = @user.projects.build(params[:project])\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render json: @project, status: :created, location: @project }\n else\n format.html { render action: \"new\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = current_user.projects.new(project_params)\n\n respond_to do |format|\n if @project.save\n format.html {redirect_to \"/projects\", notice: \"Project was successfully created.\"}\n format.json {render :show, status: :created, location: @project}\n else\n format.html {render :new, status: :unprocessable_entity}\n format.json {render json: @project.errors, status: :unprocessable_entity}\n end\n end\n end", "def create\n @project = current_user.projects.build(project_params)\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: \"Project was successfully created.\" }\n User.find(current_user.id).projects << Project.find(@project.id)\n @projects_user = ProjectsUser.find_by(user_id: current_user.id, project_id: @project.id)\n format.json { render :show, status: :created, location: @project }\n\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(project_params)\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: t('models.project.create') }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(params[:project])\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render json: @project, status: :created, location: @project }\n else\n format.html { render action: \"new\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(params[:project])\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render json: @project, status: :created, location: @project }\n else\n format.html { render action: \"new\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(params[:project])\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render json: @project, status: :created, location: @project }\n else\n format.html { render action: \"new\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(params[:project])\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render json: @project, status: :created, location: @project }\n else\n format.html { render action: \"new\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(params[:project])\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render json: @project, status: :created, location: @project }\n else\n format.html { render action: \"new\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(params[:project])\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render json: @project, status: :created, location: @project }\n else\n format.html { render action: \"new\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(params[:project])\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render json: @project, status: :created, location: @project }\n else\n format.html { render action: \"new\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(params[:project])\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render json: @project, status: :created, location: @project }\n else\n format.html { render action: \"new\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(params[:project])\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render json: @project, status: :created, location: @project }\n else\n format.html { render action: \"new\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @api_project = Project.new(api_project_params)\n\n respond_to do |format|\n if @api_project.save\n format.html { redirect_to @api_project, notice: 'Project was successfully created.' }\n format.json { render :show, status: :created, location: @api_project }\n else\n format.html { render :new }\n format.json { render json: @api_project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(project_params)\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to projects_path, notice: \"Project was successfully created.\" }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(project_params)\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to projects_path, notice: 'Project was successfully created.' }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = @client.projects.new(params[:project])\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @client, notice: 'Project was successfully created.' }\n else\n format.html { render action: \"new\" }\n end\n end\n end", "def create\n @project = Project.new(project_params)\n\n respond_to do |format|\n if @project.save\n format.json { render json: @project, status: 200 }\n else\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = current_user.projects.build(project_params)\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to projects_path, notice: 'Project was successfully created.' }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(project_params)\n @project.user_id = @user.id\n if @project.save\n render json: {status: :success, project: @project}\n else\n render json: {status: :failed, project: @project}\n end\n end", "def create\n @project = Project.new(project_params)\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to projects_path, notice: 'Project was successfully created.' }\n format.json { render action: 'show', status: :created, location: @project }\n else\n format.html { render action: 'new' }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n respond_to do |format|\n if project.save\n format.html { redirect_to project, notice: 'Project was successfully created.' }\n format.json { render json: project, status: ':created', location: project }\n else\n format.html { render action: 'new' }\n format.json { render json: project.errors, status: ':unprocessable_entity' }\n end\n end\n end", "def create\n @project = Project.new(project_params)\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render json: @project, status: :created, location: @project }\n else\n format.html { render action: 'new' }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = current_user.projects.new(project_params)\n if @project.save\n render :show\n else\n render json: { errors: @project.errors }\n end\n end", "def create\n @project = Project.new(params[:project])\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to admin_projects_url, notice: 'Project was successfully created.' }\n format.json { render json: @project, status: :created, location: @project }\n else\n format.html { render action: \"new\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(project_params)\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render json: @project, status: :created, location: @project }\n else\n format.html { render action: \"new\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(project_params)\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, flash: {success: 'Project was successfully created.'} }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n # authenticate_user!\n @project = Project.new\n @project[:category] = params[:category]\n @project[:title] = params[:title]\n @project[:body] = params[:body]\n @project[:location] = params[:location]\n @project[:image_link] = params[:image_link]\n @project[:project_url] = params[:project_url]\n @project[:year] = params[:year]\n @project[:likes] = params[:likes]\n @project.save\n\n render json: @project\n end", "def create\n @project = Project.new(project_params.merge(user_id: current_user.id))\n\n respond_to do |format|\n if @project.save\n format.json { render :show, status: :created, location: @project }\n else\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(project_params)\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render json: @project, status: :created, location: @project }\n else\n format.html { render action: \"new\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(project_params)\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(project_params)\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(project_params)\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(project_params)\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(project_params)\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(project_params)\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(project_params)\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(project_params)\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(project_params)\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(project_params)\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(project_params)\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(project_params)\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(project_params)\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(project_params)\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(project_params)\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(project_params)\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(project_params)\n \n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @client = Client.find(params[:client_id])\n @project = @client.projects.build(project_params)\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to client_projects_path(@client), notice: 'Project was successfully created.' }\n format.json { render json: client_projects_path(@client), status: :created, location: @project }\n else\n format.html { render action: \"new\" }\n format.json { render json: client_projects_path(@client).errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = current_user.projects.build(project_params)\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to root_path, notice: 'Enhorabuena! Tienes un nuevo proyecto. A trabajar!' }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.create project_params\n current_user.memberships.create(\n project_id: @project.id,\n owner_at: Time.now\n )\n\n if @project.save\n render 'projects/create', status: 201\n else\n render 'projects/error', status: 422\n end\n end", "def create\n @project = @client.projects.build(project_params)\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to(client_projects_url(@client), notice: 'Project was successfully created.') }\n format.xml { render xml: @project, status: :created, location: @project }\n else\n format.html { render action: \"new\" }\n format.xml { render xml: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @create_project = current_user.projects.build(params[:project])\n flash[:notice] = \"Project #{@create_project.description} successfully created\" if @create_project.save\n respond_with(@create_project, layout: !request.xhr?)\n end", "def new_project\n @request = Request.new(data_type: :project)\n @request.build_contact\n @request.build_project\n @request.build_general_information\n\n render 'new'\n end", "def create\t\t\t\t\t\t\t\t\t# Creates record in db and redirects (porbably to index)\n\t\t@project = Project.new(projects_params)\t# Passes only title and desc.\n\n \trespond_to do |format|\t\t\t\t\t# All this is doing is rendering stuff in case of json\n \t\tif @project.save\n \t\tformat.html { redirect_to @project, notice: 'Created a new project!' }\n \t\tformat.json { render :show, status: :created, location: @project }\n \t\telse\n \t\tformat.html { render :new }\n \t\t\tformat.json { render json: @project.errors, status: :unprocessable_entity }\n \t\tend\n \tend\n\tend", "def create\n if params[:project_id]\n cloned_from = Project.find(params[:project_id])\n @project = cloned_from.clone(params, @cur_user.id)\n else\n @cloned_project = nil\n @project = Project.new project_params\n @project.user_id = @cur_user.id\n end\n\n respond_to do |format|\n if @project.save\n format.html do\n redirect_to @project, notice: 'Project was successfully created.'\n end\n format.json do\n render json: @project.to_hash(false),\n status: :created, location: @project\n end\n else\n flash[:error] = @project.errors.full_messages\n format.html { redirect_to projects_path }\n format.json do\n render json: @project.errors, status: :unprocessable_entity\n end\n end\n end\n end", "def create_project(key, name, params = {})\n params[:key] = key\n params[:name] = name\n post('projects', params)\n end", "def create\n @project = Project.new(project_params)\n @project.owner = current_user unless @project.owner\n if @project.save\n render :show, status: :created, location: @project\n else\n render json: @project.errors, status: :unprocessable_entity\n end\n end", "def create_project(optional={})\n\t\targs = self.class.new_params\n\t\targs[:method] = 'POST'\n\t\targs[:pattern] = '/projects'\n\t\targs[:query]['Action'] = 'CreateProject'\n\t\targs[:region] = optional[:_region] if (optional.key? :_region)\n\t\targs[:scheme] = 'http'\n\t\tif optional.key? :project\n\t\t\targs[:body]['Project'] = optional[:project]\n\t\tend\n\t\tself.run(args)\n\tend", "def projects\n resource 'projects'\n end", "def create\n @project = Project.new(project_params)\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render :show, status: :created, location: @project }\n else\n build_projects_user\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n project_attrs = params[:project].merge(validate_repo_connectivity: true)\n @project = current_user.owned_projects.create(project_attrs, as: :owner)\n respond_with @project do |format|\n format.json do\n if @project.valid?\n render json: decorate(@project).to_json, status: :created\n else\n render json: {project: @project.errors.as_json}.to_json, status: :unprocessable_entity\n end\n end\n end\n end", "def create\n @project = Project.new(params[:project])\n\t\t@project.user_id =current_user.id\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render json: @project, status: :created, location: @project }\n else\n format.html { render action: \"new\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(params[:project])\n @project.skills = params[:skills]\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render json: @project, status: :created, location: @project }\n else\n format.html { render action: \"new\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.create(project_params)\n if @project.errors.blank?\n flash[:success] = t('controllers.projects.create.success', project: @project.name)\n else\n flash.now[:alert] = @project.errors.full_messages.unshift(t('controllers.projects.create.failure'))\n end\n respond_with @project, location: projects_url\n end", "def create\n @new_nav = true;\n @project = Project.new(project_params)\n\n respond_to do |format|\n if @project.save\n if params[:project_attachments]\n create_attachments\n end\n\n if params[:project_fields]\n create_fields\n end\n\n if params[:slider_objects]\n create_slider_objects\n end\n\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render json: @project, status: :created, location: @project }\n else\n format.html { render action: \"new\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(project_params)\n @project.user = current_user\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(project_params)\n\n begin\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new }\n format.json { render json: @project.errors.full_messages, status: :unprocessable_entity }\n end\n end\n rescue Exception => e\n @project.destroy\n respond_to do |format|\n format.html { render :new }\n format.json { render json: e.as_json, status: :service_unavailable }\n end\n end\n end", "def project_create(global_options, options)\n result = Excon.post(\n \"#{global_options[:fenton_server_url]}/projects.json\",\n body: project_json(options),\n headers: { 'Content-Type' => 'application/json' }\n )\n\n [result.status, JSON.parse(result.body)]\n end", "def create\n @project = Project.new(params[:project])\n\n respond_to do |format|\n if @project.save\n @project.user_projects.create(:user_id => current_user.id, :status => true, :role => 1)\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render json: @project, status: :created, location: @project }\n else\n format.html { render action: \"new\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(project_params)\n respond_to do |format|\n if @project.save\n flash[:alert] = \"Project created successfully.\"\n format.html { redirect_back(fallback_location: root_path) }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(project_params)\n\n if is_organization_admin? and @project.save\n @project.team_members.create(user_id: @project.organization.owner_id)\n render json: {\n name: @project.name,\n organization: @project.organization.name,\n url: project_dashboard_path(@project.id)\n }\n else\n render json: @project.errors, status: :unprocessable_entity\n end\n end", "def create\n @project = Project.new(project_params)\n\n if params[\"project\"][\"client_id\"] != \"\"\n @project.client = Client.find params[\"project\"][\"client_id\"]\n end\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Novo projeto cadastrado com sucesso.' }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = current_user.projects.create(params[:project])\n \n if @project.save\n record_activity(\"created new project: \" + @project.id.to_s)\n redirect_to root_path, :notice => \"Project created successfully\"\n else\n render 'new'\n end\n end", "def create\n find_projects(params[:api_key])\n end", "def create\n\n @project = Project.new(project_params)\n @project.user_id = current_user.id\n\n respond_to do |format|\n if @project.save\n\n format.html { redirect_to @project, success: 'Project was successfully created.' }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(:project_title => params[:project_title], :start_date => params[:startDate], :end_date => params[:endDate],\n :status => params[:project_status])\n\n @project.user_id = current_user.id\n\n\n respond_to do |format|\n if @project.save\n p \"pass on projects controller\"\n format.html { redirect_to @project}\n format.json { render json: \"ok\" }\n else\n p \"fail on projects controller\"\n end\n end\n\n\n end", "def create_project_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: ProjectApi.create_project ...'\n end\n # resource path\n local_var_path = '/projects'\n\n # query parameters\n query_params = opts[:query_params] || {}\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n content_type = @api_client.select_header_content_type(['application/json'])\n if !content_type.nil?\n header_params['Content-Type'] = content_type\n end\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:debug_body] || @api_client.object_to_http_body(opts[:'create_project_body'])\n\n # return_type\n return_type = opts[:debug_return_type] || 'Project'\n\n # auth_names\n auth_names = opts[:debug_auth_names] || ['oryAccessToken']\n\n new_options = opts.merge(\n :operation => :\"ProjectApi.create_project\",\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ProjectApi#create_project\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def create\n @project = Project.new(project_params)\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to :projects, notice: \"Project was successfully created.\" }\n format.json { render :show, status: :created, location: @project }\n else\n format.html do\n @teams = Team.order(:name)\n render :new\n end\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(project_params)\n\n respond_to do |format|\n if @project.save\n @project.team.touch\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render :show, status: :created, location: @project }\n else\n render_errors(format, @project.errors, :new)\n end\n end\n end", "def create\n @project = Project.new(project_params)\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to [:user, @project], notice: 'Project temp was successfully created.' }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(project_params)\n\n render text: params[:project].inspect\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to projects_path, notice: 'Proyecto creado sastifactoriamente' }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(params[:project])\n @project.status = \"Etat zero\"\n creator = current_user\n ProjectUser.create(:project => @project, :user => creator, :admin => true)\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render json: @project, status: :created, location: @project }\n else\n format.html { render action: \"new\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(project_params)\n @project.user_id = current_user.id\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = @projectable.projects.new(params[:project])\n\n respond_to do |format|\n if @project.save\n track_activity @project\n format.html { redirect_to [@projectable, @project], notice: 'Project was successfully created.' }\n format.json { render json: @project, status: :created, location: @project }\n else\n format.html { render layout: 'form', action: \"new\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n\n #Acá se retorna de la vista New (o de cualquier lugar que llame a create con POST). Le llega el hash project_params con \n # los datos que retornó la vista.\n\n #Crea el nuevo usuario.\n @project = Project.new(project_params)\n\n respond_to do |format| #Esta linea es curiosa. Si el request le llegó por HTML, entonces fue un navegador. Si le llego\n #por JSON, entonces probablemente fue otra cosa, un app movil por ejemplo.\n if @project.save #Esto guarda el proyecto nuevo en la base de datos y retorna True si no hubo problema, y False si hubo un error.\n # Es importante notar que al llamar .save, primero pasa por el modelo, el cual revisa que no falte ningún dato.\n # Por ejemplo, si el modelo necesita que se incluya el nombre del proyecto, si o si, y no se le pasó el nombre,\n # Entonces el modelo va a guardar ese error en un hash llamado errors, dentro de el mismo (@projects.errors)\n # y va a hacer que .save retorne False.\n\n\n format.html { redirect_to :controller => \"misc\", :action =>\"about\", notice: 'Project was successfully created.' }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end" ]
[ "0.7338948", "0.73139244", "0.7308003", "0.7299582", "0.7227503", "0.7225945", "0.71982473", "0.71170384", "0.7104803", "0.7095263", "0.7070636", "0.70408624", "0.70358187", "0.7024969", "0.70191896", "0.7009597", "0.698481", "0.697517", "0.6963753", "0.6963096", "0.6948756", "0.6948756", "0.6948756", "0.6948756", "0.6948756", "0.6948756", "0.6948756", "0.6948756", "0.6948756", "0.6944626", "0.69397265", "0.6938008", "0.69204897", "0.6911497", "0.6908809", "0.6907813", "0.6894293", "0.689054", "0.68847734", "0.6879909", "0.68794346", "0.6879012", "0.68784195", "0.6868972", "0.68664163", "0.68660194", "0.68657774", "0.68657774", "0.68657774", "0.68657774", "0.68657774", "0.68657774", "0.68657774", "0.68657774", "0.68657774", "0.68657774", "0.68657774", "0.68657774", "0.68657774", "0.68657774", "0.68657774", "0.6865554", "0.68598175", "0.6858278", "0.6846567", "0.6828604", "0.68193066", "0.6806436", "0.678643", "0.6784763", "0.6773288", "0.675545", "0.6750235", "0.67379624", "0.6718913", "0.6716745", "0.67009157", "0.66877806", "0.6686259", "0.668621", "0.66856426", "0.66838706", "0.6680505", "0.66770595", "0.6670888", "0.6668133", "0.66572726", "0.66528344", "0.66518456", "0.66511416", "0.6649628", "0.6649045", "0.6642436", "0.6638429", "0.6634081", "0.66324985", "0.6629944", "0.6628171", "0.66263485", "0.66259176", "0.66255814" ]
0.0
-1
PATCH/PUT /projects/1 PATCH/PUT /projects/1.json
def update respond_to do |format| if @project.update(project_params) format.html { redirect_to projects_url, notice: 'Project was successfully updated.' } format.json { render :show, status: :ok, location: @project } else format.html { render :edit } format.json { render json: @project.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n if @project.update(project_params)\n render json: @project, status: 200\n else\n render json: { errors: @project.errors.messages }, status: 200\n end\n end", "def update\n authorize! :update, @project\n\n if @project.update(project_params)\n head :no_content\n else\n render 'projects/error', status: 422\n end\n end", "def update\n @project = Project.find(params[:id])\n\n if params[:name] == \"project_name\"\n project_name = params[:value]\n @project.project_name = project_name\n end\n\n respond_to do |format|\n if @project.update_attributes(params[:project])\n\n @projects = Project.all\n format.html {\n render :action => \"index\"\n }\n format.json { render json: @project }\n else\n logMessage = self.class.to_s + \"#\" + __method__.to_s + \" \" + current_user.username + \" errors:\" + @project.errors.full_messages.to_s\n logger.info logMessage\n\n format.html {\n flash[:error] = 'Project was not successfully updated.'\n redirect_to action: \"index\"\n }\n errorMsg = @project.errors.full_messages.to_s.split(\"\\\"\")\n format.json { render json: errorMsg[1], status: 500 }\n end\n end\n end", "def update\n @project = Project.find(params[:id])\n\n respond_to do |format|\n if @project.update_attributes(params[:project])\n format.html { redirect_to @project, :notice => 'Project was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @project.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @project = Project.find(params[:id])\n\n respond_to do |format|\n if @project.update_attributes(params[:project])\n format.html { redirect_to projects_path, notice: 'Project was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @project = Project.find(params[:id])\n\n respond_to do |format|\n if @project.update_attributes(params[:project])\n format.html { redirect_to(@project, :notice => 'Project was successfully updated.') }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @project.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update_project\n\t\t@project = Project.find(params[:id])\n\n\t \trespond_to do |format|\n\t\t if @project.update_attributes(project_update_params)\n\t\t format.html { redirect_to(@project, :notice => 'Entry was successfully updated.') }\n\t\t format.json { respond_with_bip(@project) }\n\t\t else\n\t\t format.html { render :action => \"edit\" }\n\t\t format.json { respond_with_bip(@project) }\n\t\t end\n\n \t end\n\tend", "def update\t\t\t\t\t\t\t\t\t# Actually modifies the data and redirects (probably to index or show? depends)\n\t\t#@project = Project.find(params[:id])\t# Taken out because of the before action GENIUS!\n\n\t\trespond_to do |format|\n \t\t if @project.update(projects_params)\n \t\tformat.html { redirect_to @project, notice: 'Project was successfully updated.' }\n \t\tformat.json { render :show, status: :ok, location: @project }\n \t\telse\n \t\tformat.html { render :edit }\n \t\tformat.json { render json: @project.errors, status: :unprocessable_entity }\n \t\tend\n \tend\n\tend", "def update\n @project = Project.find(params[:id])\n\n respond_to do |format|\n if @project.update_attributes(params[:project])\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @project = Project.find(params[:id])\n\n respond_to do |format|\n if @project.update_attributes(params[:project])\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @project = Project.find(params[:id])\n\n respond_to do |format|\n if @project.update_attributes(params[:project])\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @project = Project.find(params[:id])\n\n respond_to do |format|\n if @project.update_attributes(params[:project])\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @project = Project.find(params[:id])\n\n respond_to do |format|\n if @project.update_attributes(params[:project])\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @project = Project.find(params[:id])\n\n respond_to do |format|\n if @project.update_attributes(params[:project])\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @project = Project.find(params[:id])\n\n respond_to do |format|\n if @project.update_attributes(params[:project])\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @project = Project.find(params[:id])\n\n respond_to do |format|\n if @project.update_attributes(params[:project])\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @project = Project.find(params[:id])\n\n respond_to do |format|\n if @project.update_attributes(params[:project])\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @project = Project.find(params[:id])\n\n respond_to do |format|\n if @project.update_attributes(params[:project])\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @project = Project.find(params[:id])\n\n respond_to do |format|\n if @project.update_attributes(params[:project])\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @project = Project.find(params[:id])\n\n respond_to do |format|\n if @project.update_attributes(params[:project])\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @project = Project.find(params[:id])\n\n respond_to do |format|\n if @project.update_attributes(params[:project])\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @project = Project.find(params[:id])\n\n respond_to do |format|\n if @project.update_attributes(params[:project])\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @project = Project.find(params[:id])\n\n respond_to do |format|\n if @project.update_attributes(params[:project])\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @project = Project.find(params[:id])\n\n respond_to do |format|\n if @project.update_attributes(params[:project])\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @project = current_user.projects.find(params[:id])\n\n respond_to do |format|\n if @project.update_attributes(params[:project])\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @project = @client.projects.find(params[:id])\n\n respond_to do |format|\n if @project.update_attributes(project_params)\n format.html { redirect_to([@client, @project], notice: 'Project was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render action: \"edit\" }\n format.xml { render xml: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @project = Project.find(params[:id])\n\n respond_to do |format|\n if @project.update_attributes(params[:project])\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @project = Project.find(params[:id])\n\n respond_to do |format|\n if @project.update_attributes(params[:project])\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @project = Project.find(params[:id])\n\n respond_to do |format|\n if @project.update_attributes(params[:project])\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @project = Project.find(params[:id])\n\n respond_to do |format|\n if @project.update_attributes(params[:project])\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.json { render :show, status: :ok, location: @project }\n else\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.json { render json: @project, status: 200 }\n else\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n\t\trespond_to do |format|\n\t\t\tif @project.update(project_params)\n\t\t\t\tformat.json { render :show, status: :ok }\n\t\t\telse\n\t\t\t\tformat.json { render json: @project.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend", "def update\n @client = Client.find(params[:client_id])\n @project = Project.find(params[:id])\n \n respond_to do |format|\n if @project.update_attributes(project_params)\n format.html { redirect_to client_projects_path(@client), notice: 'Project was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: client_projects_path(@client).errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @project = Project.find(params[:id])\n\n respond_to do |format|\n if @project.update_attributes(params[:project])\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { render json: @project.as_json(:include => [:client, :project_participants ] ) }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if project.update(project_params)\n format.html { redirect_to project, notice: 'Project was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: project.errors, status: ':unprocessable_entity' }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to projects_path, notice: 'project was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update_attributes(params[:project])\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { head :ok }\n else\n @main_projects = Project.roots.where(creator_id: @project.creator_id)\n format.html { render action: \"edit\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @project = Project.find(params[:id])\n\n respond_to do |format|\n if @project.update_attributes(project_params)\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @project = Project.find(params[:id])\n\n respond_to do |format|\n if @project.update_attributes(project_params)\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if @project.update(project_params)\n render json: {status: :success, project: @project}\n else\n render json: {status: :failed, project: @project}\n end\n end", "def update\n @edit_project = Project.find(params[:id])\n\n respond_to do |format|\n if @edit_project.update_attributes(params[:project])\n format.html { redirect_to @edit_project, notice: 'Project was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @edit_project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @api_project.update(api_project_params)\n format.html { redirect_to @api_project, notice: 'Project was successfully updated.' }\n format.json { render :show, status: :ok, location: @api_project }\n else\n format.html { render :edit }\n format.json { render json: @api_project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def project_update(project)\n raise Client::FileboundClientException.new('Id is required', 0) unless project[:projectId].greater_than_zero?\n put('/projects', nil, project)\n end", "def update\n\t\t@project = Project.find(params[:id])\n\t\tmake_breadcrumbs\n\t\t\n\t\trespond_to do |format|\n\t\t\tif @project.update_attributes(params[:project])\n\t\t\t\tformat.html { redirect_to @project, notice: t('app.projects.updated') }\n\t\t\t\tformat.json { head :ok }\n\t\t\telse\n\t\t\t\tformat.html { render action: \"edit\" }\n\t\t\t\tformat.json { render json: @project.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend", "def update\n if @project.update(project_params)\n render :show, status: :ok, location: api_v1_project_url(@project)\n else\n render json: @project.errors, status: :unprocessable_entity\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n \t\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { render :show, status: :ok, location: @project }\n else\n format.html { render :edit }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to add_path(@project), notice: 'Project was successfully updated.' }\n format.json { render :add, status: :ok, location: @project }\n else\n format.html { render :edit }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @project = Project.find(params[:id])\n params[:project][:problem_ids] ||= []\n params[:project][:target_ids] ||= []\n params[:project][:factor_ids] ||= []\n respond_to do |format|\n if @project.update_attributes(params[:project])\n format.html { redirect_to(projects_path, :notice => 'Project was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @project.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to projects_path, notice: 'Project was successfully updated.' }\n format.json { render :show, status: :ok, location: projects_path }\n else\n format.html { render :edit }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\r\n respond_to do |format|\r\n if @project.update(project_params)\r\n format.html { redirect_to @project }\r\n format.json { respond_with_bip(@project) }\r\n else\r\n format.html { render action: 'edit' }\r\n format.json { respond_with_bip(@project) }\r\n end\r\n end\r\n end", "def update\n authenticate_user!\n @project = Project.find(params[:id])\n\n respond_to do |format|\n if @project.update_attributes(params[:project])\n format.html { redirect_to(@project, :notice => 'Project was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @project.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update_project(optional={})\n\t\targs = self.class.new_params\n\t\targs[:method] = 'PUT'\n\t\targs[:pattern] = '/projects/[ProjectName]'\n\t\targs[:query]['Action'] = 'UpdateProject'\n\t\targs[:region] = optional[:_region] if (optional.key? :_region)\n\t\targs[:scheme] = 'http'\n\t\tif optional.key? :project\n\t\t\targs[:body]['Project'] = optional[:project]\n\t\tend\n\t\tif optional.key? :project_name\n\t\t\targs[:path]['ProjectName'] = optional[:project_name]\n\t\tend\n\t\tself.run(args)\n\tend", "def update\n @project = Project.find(params[:id])\n\n respond_to do |format|\n if @project.update_attributes(params[:project])\n format.html { redirect_to projects_path() }\n format.xml { head :ok }\n else\n @edit_mode = true\n @tasks = Task.find_all_by_project_id(@project.id)\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @project.errors, :status => :unprocessable_entity }\n end\n end\n end", "def project_updates\n @project = Project.find(params[:id])\n end", "def update\n if @project.update(project_params)\n render :show, status: :ok\n else\n render json: @project.errors, status: :unprocessable_entity\n end\n end", "def update\n if @project.update(project_params)\n render :show, status: :ok\n else\n render json: @project.errors, status: :unprocessable_entity\n end\n end", "def update\n @project = Project.find(params[:id])\n<<<<<<< HEAD:app/controllers/projects_controller.rb\n handle_disciplines_projects\n \n=======\n\n>>>>>>> 336471e6be257cf55c9afa2a65f928fde34e41fe:app/controllers/projects_controller.rb\n respond_to do |format|\n if @project.update_attributes(params[:project])\n flash[:notice] = 'Project was successfully updated.'\n format.html { redirect_to(@project) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @project.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to projects_path, notice: 'Project was successfully updated.' }\n format.json { render :show, status: :ok, location: @project }\n else\n format.html { render :edit }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to projects_path, notice: 'Project was successfully updated.' }\n format.json { render :show, status: :ok, location: @project }\n else\n format.html { render :edit }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def patch_project_with_http_info(project_id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: ProjectApi.patch_project ...'\n end\n # verify the required parameter 'project_id' is set\n if @api_client.config.client_side_validation && project_id.nil?\n fail ArgumentError, \"Missing the required parameter 'project_id' when calling ProjectApi.patch_project\"\n end\n # resource path\n local_var_path = '/projects/{project_id}'.sub('{' + 'project_id' + '}', CGI.escape(project_id.to_s))\n\n # query parameters\n query_params = opts[:query_params] || {}\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n content_type = @api_client.select_header_content_type(['application/json'])\n if !content_type.nil?\n header_params['Content-Type'] = content_type\n end\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:debug_body] || @api_client.object_to_http_body(opts[:'json_patch'])\n\n # return_type\n return_type = opts[:debug_return_type] || 'SuccessfulProjectUpdate'\n\n # auth_names\n auth_names = opts[:debug_auth_names] || ['oryAccessToken']\n\n new_options = opts.merge(\n :operation => :\"ProjectApi.patch_project\",\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:PATCH, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ProjectApi#patch_project\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to projects_path, notice: \"Project was successfully updated.\" }\n format.json { render :show, status: :ok, location: @project }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { render :show, status: :ok, location: @project }\n else\n format.html { render :edit }\n format.json { render json: @project.errors.full_messages, status: :unprocessable_entity }\n end\n end\n end", "def update\n if @project\n if @project.update(project_params)\n render json: @project, status: :ok\n else\n render json: {error: @project.errors.full_messages.to_sentence } , status: :unprocessable_entity\n end\n else\n render json: {error: \"Project does not exist\"} , status: :unprocessable_entity\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { render :show, status: :ok, location: @project }\n else\n format.html { render :edit }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { render :show, status: :ok, location: @project }\n else\n format.html { render :edit }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { render :show, status: :ok, location: @project }\n else\n format.html { render :edit }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { render :show, status: :ok, location: @project }\n else\n format.html { render :edit }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { render :show, status: :ok, location: @project }\n else\n format.html { render :edit }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { render :show, status: :ok, location: @project }\n else\n format.html { render :edit }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { render :show, status: :ok, location: @project }\n else\n format.html { render :edit }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { render :show, status: :ok, location: @project }\n else\n format.html { render :edit }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { render :show, status: :ok, location: @project }\n else\n format.html { render :edit }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { render :show, status: :ok, location: @project }\n else\n format.html { render :edit }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { render :show, status: :ok, location: @project }\n else\n format.html { render :edit }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { render :show, status: :ok, location: @project }\n else\n format.html { render :edit }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { render :show, status: :ok, location: @project }\n else\n format.html { render :edit }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { render :show, status: :ok, location: @project }\n else\n format.html { render :edit }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { render :show, status: :ok, location: @project }\n else\n format.html { render :edit }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { render :show, status: :ok, location: @project }\n else\n format.html { render :edit }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { render :show, status: :ok, location: @project }\n else\n format.html { render :edit }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { render :show, status: :ok, location: @project }\n else\n format.html { render :edit }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { render :show, status: :ok, location: @project }\n else\n format.html { render :edit }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { render :show, status: :ok, location: @project }\n else\n format.html { render :edit }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { render :show, status: :ok, location: @project }\n else\n format.html { render :edit }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { render :show, status: :ok, location: @project }\n else\n format.html { render :edit }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { render :show, status: :ok, location: @project }\n else\n format.html { render :edit }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { render :show, status: :ok, location: @project }\n else\n format.html { render :edit }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { render :show, status: :ok, location: @project }\n else\n format.html { render :edit }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { render :show, status: :ok, location: @project }\n else\n format.html { render :edit }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { render :show, status: :ok, location: @project }\n else\n format.html { render :edit }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { render :show, status: :ok, location: @project }\n else\n format.html { render :edit }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { render :show, status: :ok, location: @project }\n else\n format.html { render :edit }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { render :show, status: :ok, location: @project }\n else\n format.html { render :edit }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { render :show, status: :ok, location: @project }\n else\n format.html { render :edit }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { render :show, status: :ok, location: @project }\n else\n format.html { render :edit }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { render :show, status: :ok, location: @project }\n else\n format.html { render :edit }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { render :show, status: :ok, location: @project }\n else\n format.html { render :edit }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { render :show, status: :ok, location: @project }\n else\n format.html { render :edit }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end" ]
[ "0.70004326", "0.69119745", "0.6911138", "0.6889052", "0.6888448", "0.6878091", "0.68675476", "0.6857582", "0.685334", "0.685334", "0.68503886", "0.68503886", "0.68503886", "0.68503886", "0.68503886", "0.68503886", "0.68503886", "0.68503886", "0.68503886", "0.68503886", "0.68503886", "0.68503886", "0.68503886", "0.68503886", "0.6850255", "0.6842495", "0.684057", "0.684057", "0.684057", "0.684057", "0.68398464", "0.68397754", "0.6839175", "0.6829714", "0.6829413", "0.68209535", "0.68173355", "0.6808719", "0.68025875", "0.68025875", "0.6780633", "0.6771888", "0.67589355", "0.67586994", "0.67586994", "0.67561215", "0.6746647", "0.6735708", "0.67201793", "0.6706241", "0.6702684", "0.66779363", "0.66752994", "0.66677266", "0.6659675", "0.66557306", "0.66467226", "0.6633223", "0.6633223", "0.66229934", "0.66225135", "0.66225135", "0.6615703", "0.661438", "0.66133374", "0.66015583", "0.6600113", "0.6600113", "0.6600113", "0.6600113", "0.6600113", "0.6600113", "0.6600113", "0.6600113", "0.6600113", "0.6600113", "0.6600113", "0.6600113", "0.6600113", "0.6600113", "0.6600113", "0.6600113", "0.6600113", "0.6600113", "0.6600113", "0.6600113", "0.6600113", "0.6600113", "0.6600113", "0.6600113", "0.6600113", "0.6600113", "0.6600113", "0.6600113", "0.6600113", "0.6600113", "0.6600113", "0.6600113", "0.6600113", "0.6600113", "0.6600113" ]
0.0
-1
DELETE /projects/1 DELETE /projects/1.json
def destroy @project.destroy respond_to do |format| format.html { redirect_to projects_url, notice: 'Project was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @project.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def destroy\n project.destroy\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @project = Project.find(params[:id])\n \n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :no_content }\n end\n end", "def destroy\n # @project = Project.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :ok }\n end\n end", "def destroy\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :ok }\n end\n end", "def destroy\n @project.destroy\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @project.destroy\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @project.destroy\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @project.destroy\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @project.destroy\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @project.destroy\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @project = Project.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to(projects_url) }\n format.json { head :ok }\n end\n end", "def destroy\n @project = Project.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :ok }\n end\n end", "def destroy\n @project = Project.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :ok }\n end\n end", "def destroy\n @project = Project.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :ok }\n end\n end", "def destroy\n @project = Project.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :ok }\n end\n end", "def destroy\n @project = Project.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @project = Project.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @project = Project.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @project = Project.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @project = Project.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @project = Project.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @project = Project.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @project = Project.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @project = Project.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @project = Project.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @project = Project.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @project = Project.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @project = Project.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @project = Project.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @project = Project.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @project = Project.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @project = Project.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @project = Project.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @project = Project.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @project = Project.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @project = Project.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @project = Project.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @project = Project.find(params[:id])\n @project.delete\n\n respond_to do |format|\n format.html { redirect_to request.referer }\n format.json { head :no_content }\n end\n end", "def destroy\n @project = Project.find(params[:id])\n @project.status = 'deleted'\n @project.save!\n\n respond_to do |format|\n format.json { render :json => \"success\" }\n end\n end", "def delete\n @project = Project.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_path }\n format.json { head :no_content }\n end\n end", "def destroy\n project = Project.find(params[:id])\n project.destroy\n\n respond_to do |format|\n format.html { redirect_to root_path }\n format.json { head :no_content }\n end\n end", "def destroy\n name = @project.name\n @project.destroy\n render json: [\"You have successfullly deleted '#{name}''\"], status: 200\n end", "def destroy\n @project.destroy\n respond_to do |format|\n format.html { redirect_to admin_projects_url }\n format.json { head :no_content }\n end\n end", "def destroy\r\n @project.destroy\r\n respond_to do |format|\r\n format.html { redirect_to projects_url }\r\n format.json { head :no_content }\r\n end\r\n end", "def delete(projects)\n project_ids = projects.collect { |project| project.id } \n args = {ids: project_ids.to_json}\n return @client.api_helper.command(args, \"project_delete\")\n end", "def delete\r\n\t\t\trender json: Project.delete_by_id(params[:id])\r\n\t\tend", "def destroy\n\t\t@project.destroy\n\t\trespond_to do |format|\n\t\t\tformat.json { head :no_content }\n\t\tend\n\tend", "def destroy\n @project = Project.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to administration_projects_path }\n format.json { head :no_content }\n end\n end", "def destroy\n @project = current_user.projects.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { render :json => {:message=>\"OK\",:id=>@project.id}, :staus=>:ok}\n end\n end", "def destroy\n @project = Project.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_projects_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @project.destroy\n head :no_content\n end", "def destroy\t\t\n @project.destroy\n respond_to do |format|\n format.html { redirect_to projects_url, notice: 'Successfully deleted project.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @project.destroy\n respond_to do |format|\n format.html { redirect_to projects_url, notice: t('models.project.destroy') }\n format.json { head :no_content }\n end\n end", "def destroy\n @project = @client.projects.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to @client }\n end\n end", "def destroy\n @project.destroy\n\n head :no_content\n end", "def destroy\n @ourproject = Ourproject.find(params[:id])\n @ourproject.destroy\n\n respond_to do |format|\n format.html { redirect_to ourprojects_url }\n format.json { head :ok }\n end\n end", "def destroy\n authorize @project\n @project.destroy\n render json: [\"Deleted successfully.\"], status: :ok\n end", "def destroy\n @project.destroy_all\n respond_to do |format|\n format.html { redirect_to projects_url, notice: 'The project was successfully removed.' }\n format.json { head :no_content }\n end\n end", "def delete_project(project)\n handle_action_exceptions(__method__) do\n cmd_line = [\"deleteproject '#{project}'\"]\n cmd_line << 'json' if @json\n\n handle_return(@toolshck_ether.cmd(cmd_line.join(' ')))\n end\n end", "def destroy\n @project = Project.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { render :json => {:valid => true} }\n end\n end", "def destroy\n @api_project.destroy\n respond_to do |format|\n format.html { redirect_to api_projects_url, notice: 'Project was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @project.destroy\n respond_to do |format|\n format.html { redirect_to projects_path, notice: 'Project was successfully deleted.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @project.destroy\n respond_to do |format|\n format.html { redirect_to projects_url, notice: 'Project was successfully deleted.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @project.destroy\n respond_to do |format|\n format.html { redirect_to projects_url, notice: 'Project was successfully deleted.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @project = Project.find_by_permalink(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :no_content }\n end\n end", "def delproject(project)\n post('delproject.json', project: project)\n end", "def destroy\n authorize! :destroy, @project\n @project.destroy\n\n head :no_content\n end", "def destroy\n @project = Project.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_back(fallback_location: root_path) }\n format.json { head :no_content }\n end\n end", "def destroy\n Rails.logger.info \"We are deleting project\"\n @todo_project.destroy\n respond_to do |format|\n format.html { redirect_to todo_projects_url, notice: 'Project was successfully deleted.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @project = @projectable.projects.find(params[:id])\n @project.destroy\n track_activity @project\n\n respond_to do |format|\n format.html { redirect_to [@projectable, :projects] }\n format.json { head :no_content }\n end\n end", "def destroy\n @project = Project.find(params[:id])\n @project.destroy\n @project.users.delete_all\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :no_content }\n end\n end", "def destroy\n \t@project = Project.find(params[:id])\n \t#ap @project\n \t#abort\n \n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to :back }\n format.json { head :no_content }\n end\n end", "def destroy\n authenticate_user!\n @project = Project.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to(projects_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @project.destroy\n render json: {message: 'Projeto Excluido'}, status: :ok\n end", "def destroy\n @project.destroy\n respond_to do |format|\n format.html { redirect_to root_url, notice: 'Project was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @project.destroy\n respond_to do |format|\n format.html { redirect_to root_url, notice: 'Project was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @project = Project.find_by_slug(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :ok }\n end\n end", "def destroy\n\n @project.destroy\n respond_to do |format|\n format.html { redirect_to projects_url, notice: \"Project was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @project.destroy\n respond_to do |format|\n format.html { redirect_to projects_url, notice: \"#{I18n.t 'project.project_destoy'}\"}\n format.json { head :no_content }\n end\n end", "def destroy\n @project = Admin::Project.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_projects_url) }\n format.xml { head :ok }\n end\n end", "def delete_project(optional={})\n\t\targs = self.class.new_params\n\t\targs[:method] = 'DELETE'\n\t\targs[:pattern] = '/projects/[ProjectName]'\n\t\targs[:query]['Action'] = 'DeleteProject'\n\t\targs[:region] = optional[:_region] if (optional.key? :_region)\n\t\targs[:scheme] = 'http'\n\t\tif optional.key? :project_name\n\t\t\targs[:path]['ProjectName'] = optional[:project_name]\n\t\tend\n\t\tself.run(args)\n\tend", "def destroy\n @project = current_user.active_projects.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :no_content }\n end\n end", "def destroy\n standard_destroy(Project, params[:id])\n end", "def destroy\n authorize! :delete, @project\n @project.destroy\n respond_to do |format|\n format.html { redirect_to projects_url, notice: 'Project was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @project.destroy\n respond_to do |format|\n format.html { redirect_to projects_url, notice: \"Project was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @project.destroy\n respond_to do |format|\n format.html { redirect_to projects_url, notice: \"Project was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @project.destroy\n respond_to do |format|\n format.html { redirect_to projects_url, notice: \"Project was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @project.destroy\n respond_to do |format|\n format.html { redirect_to projects_url, notice: 'Project was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @project.destroy\n respond_to do |format|\n format.html { redirect_to projects_url, notice: 'Project was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @project.destroy\n respond_to do |format|\n format.html { redirect_to projects_url, notice: 'Project was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @project.destroy\n respond_to do |format|\n format.html { redirect_to projects_url, notice: 'Project was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @project.destroy\n respond_to do |format|\n format.html { redirect_to projects_url, notice: 'Project was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @project.destroy\n respond_to do |format|\n format.html { redirect_to projects_url, notice: 'Project was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @project.destroy\n respond_to do |format|\n format.html { redirect_to projects_url, notice: 'Project was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @project.destroy\n respond_to do |format|\n format.html { redirect_to projects_url, notice: 'Project was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @project.destroy\n respond_to do |format|\n format.html { redirect_to projects_url, notice: 'Project was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @project.destroy\n respond_to do |format|\n format.html { redirect_to projects_url, notice: 'Project was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @project.destroy\n respond_to do |format|\n format.html { redirect_to projects_url, notice: 'Project was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @project.destroy\n respond_to do |format|\n format.html { redirect_to projects_url, notice: 'Project was successfully destroyed.' }\n format.json { head :no_content }\n end\n end" ]
[ "0.78951", "0.78593713", "0.7778056", "0.7771693", "0.77585995", "0.7730887", "0.77305084", "0.77305084", "0.77305084", "0.77305084", "0.77305084", "0.77244985", "0.7718401", "0.7718401", "0.7718401", "0.7718401", "0.7704753", "0.7704753", "0.7704753", "0.7704753", "0.7704753", "0.7704753", "0.7704753", "0.7704753", "0.7704753", "0.7704753", "0.7704753", "0.7704753", "0.7704753", "0.7704753", "0.7704753", "0.7704753", "0.7704753", "0.7704753", "0.7704753", "0.7704753", "0.7704753", "0.7704753", "0.7700103", "0.76993084", "0.7682566", "0.7669082", "0.7659675", "0.764973", "0.76495475", "0.7641442", "0.763269", "0.761519", "0.76147044", "0.7611191", "0.76066136", "0.7605034", "0.7598783", "0.75986093", "0.7593673", "0.7591231", "0.75896156", "0.7571706", "0.7571697", "0.7561333", "0.7543007", "0.7537952", "0.75324875", "0.75302756", "0.75237787", "0.75237787", "0.75189", "0.75063527", "0.7504202", "0.7499374", "0.7494583", "0.7487019", "0.74810386", "0.74776345", "0.7469382", "0.74652857", "0.7460907", "0.7460907", "0.74520767", "0.7448516", "0.744649", "0.74448746", "0.74421936", "0.7441719", "0.74374086", "0.7437005", "0.74365294", "0.74365294", "0.74365294", "0.7436244", "0.7436244", "0.7436244", "0.7436244", "0.7436244", "0.7436244", "0.7436244", "0.7436244", "0.7436244", "0.7436244", "0.7436244", "0.7436244" ]
0.0
-1
Use callbacks to share common setup or constraints between actions.
def set_project @project = Project.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_eval do\n define_method(:valid?) do |*args|\n self.class.state_machines.fire_event_attributes(self, :save, false) { super(*args) }\n end\n end\n end\n end", "def add_actions; end", "def callbacks; end", "def callbacks; end", "def setup *actions, &proc\n (@setup_procs ||= []) << [proc, actions.size > 0 ? actions : [:*]]\n end", "def define_action_helpers; end", "def post_setup\n end", "def action_methods; end", "def action_methods; end", "def action_methods; end", "def before_setup; end", "def action_run\n end", "def execute(setup)\n @action.call(setup)\n end", "def define_action_helpers?; end", "def set_actions\n actions :all\n end", "def action_done(action)\n dispatch = { :migrate => :done_migrating, :map => :done_mapping, :reduce =>\n :done_reducing, :finalize => :done_finalizing } \n self.send dispatch[action[:action]], action\n end", "def dependencies action, &block\n @actions.each do |other|\n if action[:requires].include? other[:provide]\n block.call other\n end\n end\n end", "def setup!\n return unless @setup_procs\n http_actions = actions\n @setup_procs.each do |setup_proc|\n proc, actions = setup_proc\n @setup__actions = actions.map do |action|\n\n action.is_a?(Regexp) ?\n http_actions.select { |a| a.to_s =~ action } :\n action.is_a?(String) && action =~ /\\A\\./ ?\n http_actions.map { |a| a.to_s << action if format?(a).include?(action) }.compact :\n action\n\n end.flatten\n self.class_exec &proc\n @setup__actions = nil\n end\n @setup_procs = nil\n end", "def setup_handler\n end", "def before_actions(*logic)\n self.before_actions = logic\n end", "def set_action(opts)\n opts = check_params(opts,[:actions])\n super(opts)\n end", "def setup(action)\n @targets.clear\n unless action.item.target_filters.empty?\n @targets = SES::TargetManager.make_targets(action)\n else\n item = action.item\n if item.for_opponent?\n @targets = $game_troop.alive_members\n elsif item.for_dead_friend?\n @targets = $game_party.battle_members.select { |actor| actor.dead? }\n else\n $game_party.battle_members.select { |actor| actor.alive? }\n end\n end\n @item_max = @targets.size\n create_contents\n refresh\n show\n activate\n end", "def action; end", "def action; end", "def action; end", "def action; end", "def action; end", "def revisable_shared_setup(args, block)\n class << self\n attr_accessor :revisable_options\n end\n options = args.extract_options!\n self.revisable_options = Options.new(options, &block)\n \n self.send(:include, Common)\n self.send(:extend, Validations) unless self.revisable_options.no_validation_scoping?\n self.send(:include, WithoutScope::QuotedColumnConditions)\n end", "def workflow\n end", "def setup\n @action = SampleActionAndroid.new(os_name: 'android',\n app_name: APP_PATH)\n end", "def before(action)\n invoke_callbacks *self.class.send(action).before\n end", "def process_action(...)\n send_action(...)\n end", "def before_dispatch(env); end", "def setup\n # override and do something appropriate\n end", "def after_actions(*logic)\n self.after_actions = logic\n end", "def setup(client)\n return unless @setup\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n actions.each do |action|\n action.execute(client)\n end\n self\n end", "def setup(_context)\n end", "def setup(resources) ; end", "def validate_actions\n errors.add(:base, :should_give_at_least_one_action) if !manage? && !forecasting? && !read? && !api?\n end", "def setup\n @resource_config = {\n :callbacks => {\n :before_create => nil,\n :after_create => nil,\n :before_update => nil,\n :after_update => nil,\n :before_destroy => nil,\n :after_destroy => nil,\n },\n :child_assoc => nil,\n :model => nil,\n :parent => nil,\n :path => nil,\n :permission => {},\n :properties => {},\n :relation => {\n :create => nil,\n :delete => nil,\n },\n :roles => nil,\n }\n end", "def determine_valid_action\n\n end", "def process_shared\n handle_taxes\n handle_shippings\n create_adjustments_from_params\n handle_status\n handle_inventory_refunds\n handle_payment_transactions\n order.updater.update\n end", "def init_actions\n am = action_manager()\n am.add_action(Action.new(\"&Disable selection\") { @selection_mode = :none; unbind_key(32); bind_key(32, :scroll_forward); } )\n am.add_action(Action.new(\"&Edit Toggle\") { @edit_toggle = !@edit_toggle; $status_message.value = \"Edit toggle is #{@edit_toggle}\" })\n end", "def startcompany(action)\n @done = true\n action.setup\n end", "def event_callbacks(event, metadata={})\n case event\n when :reset, :review\n if confirmed\n update_attributes(confirmed: false)\n end\n when :confirm\n confirm\n # trigger :order for all applicable items\n # NOTE: :order event is common to both physical and digital items\n items.each do |i|\n if i.event_permitted(:order)\n user_id = last_transition.user_id\n i.trigger!(:order, { order_id: id, user_id: user_id })\n end\n end\n when :complete_work\n request = metadata[:request]\n work_complete_notification(request)\n when :close\n close\n end\n if event != :close && !open\n reopen\n end\n end", "def setup_action\n return unless PONY::ERRNO::check_sequence(current_act)\n new_sequence = @action_sequence[@sequence_index+1...@action_sequence.size]\n @sequence_index = 0\n new_sequence = DND::SkillSequence::ACTS[@acts[1]] + new_sequence\n execute_sequence\n end", "def define_tasks\n define_weave_task\n connect_common_tasks\n end", "def setup(&block)\n define_method(:setup, &block)\n end", "def setup\n transition_to(:setup)\n end", "def setup\n transition_to(:setup)\n end", "def action\n end", "def setup( *args )\n\t\t\tself.class.setupBlocks.each {|sblock|\n\t\t\t\tdebugMsg \"Calling setup block method #{sblock}\"\n\t\t\t\tself.send( sblock )\n\t\t\t}\n\t\t\tsuper( *args )\n\t\tend", "def config(action, *args); end", "def setup\n @setup_proc.call(self) if @setup_proc\n end", "def before_action \n end", "def setup_callbacks\n defined_callbacks.each do |meth|\n unless respond_to?(\"call_#{meth}_callbacks\".to_sym)\n self.class.module_eval <<-EOE\n def call_#{meth}_callbacks(*args)\n plugin_store.each {|a| a.call_#{meth}_callbacks(*args) } if respond_to?(:plugin_store) && plugin_store\n self.send :#{meth}, *args if respond_to?(:#{meth})\n end\n EOE\n end\n end\n end", "def action\n end", "def matt_custom_action_begin(label); end", "def setup\n # override this if needed\n end", "def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend", "def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend", "def action(options,&callback)\n new_action = Action===options ? options : Action.new(options,&callback)\n # replace any with (shared name/alias or both default) + same arity\n @actions.delete_if do |existing_action|\n ((existing_action.names & new_action.names).size > 0 ||\n existing_action.default? && new_action.default?) &&\n existing_action.required.size == new_action.required.size &&\n existing_action.optional.size <= new_action.optional.size\n end\n @actions = (@actions + [new_action]).sort\n new_action\n end", "def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action\n end", "def after(action)\n invoke_callbacks *options_for(action).after\n end", "def pre_task\n end", "def setup(server)\n server.on('beforeMethod', method(:before_method), 10)\n end", "def add_actions\n attribute = machine.attribute\n name = self.name\n \n owner_class.class_eval do\n define_method(name) {self.class.state_machines[attribute].events[name].fire(self)}\n define_method(\"#{name}!\") {self.class.state_machines[attribute].events[name].fire!(self)}\n define_method(\"can_#{name}?\") {self.class.state_machines[attribute].events[name].can_fire?(self)}\n end\n end", "def init_actions\n @select_action = SelectAction.new\n @endpoint_mouse_action = EndpointMouseAction.new\n @move_action = MoveAction.new\n end", "def setup_signals; end", "def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend", "def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend", "def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action.respond_to?('weak!') ? action.weak! : action\n end", "def initialize(*args)\n super\n @action = :set\nend", "def setup\n #implement in subclass;\n end", "def after_set_callback; end", "def lookup_action; end", "def setup &block\n if block_given?\n @setup = block\n else\n @setup.call\n end\n end", "def setup_action\n return TSBS.error(@acts[0], 1, @used_sequence) if @acts.size < 2\n actions = TSBS::AnimLoop[@acts[1]]\n if actions.nil?\n show_action_error(@acts[1])\n end\n @sequence_stack.push(@acts[1])\n @used_sequence = @acts[1]\n actions.each do |acts|\n @acts = acts\n execute_sequence\n break if @break_action\n end\n @sequence_stack.pop\n @used_sequence = @sequence_stack[-1]\n end", "def release_actions; end", "def setup(easy)\n super\n easy.customrequest = @verb\n end", "def around_hooks; end", "def save_action; end", "def action_target()\n \n end", "def setup\n callback(:setup) do\n notify(:setup)\n migration_check.last_deployed_commit\n end\n end", "def setup\n return unless @setup\n\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n run_actions_and_retry(actions)\n self\n end", "def before_setup\n # do nothing by default\n end", "def my_actions(options)\n @setup = false\n get_template_part(\"custom_used\",\"action_users\",true)\n end", "def default_action; end", "def setup(&blk)\n @setup_block = blk\n end", "def callback_phase\n super\n end", "def advice\n end", "def _handle_action_missing(*args); end", "def shared_action(name, &block)\n @controller.shared_actions[name] = block\n end", "def setup_initial_state\n\n state_a = State.new(\"a\", 0)\n state_b = State.new(\"b\", 0)\n state_c = State.new(\"c\", 10)\n\n move_to_b = Action.new(\"move_to_b\", 1, state_b)\n\n move_to_c = Action.new(\"move_to_c\", 1, state_c)\n\n state_a.actions = [move_to_b, move_to_c]\n\n return state_a\n \nend", "def before_action action, &block\n @audience[:before][action] ||= Set.new\n @audience[:before][action] << block\n end", "def duas1(action)\n action.call\n action.call\nend" ]
[ "0.6165152", "0.60463154", "0.59467196", "0.5917112", "0.5890387", "0.58345735", "0.57773316", "0.56991524", "0.56991524", "0.565454", "0.5622282", "0.54232633", "0.54119074", "0.54119074", "0.54119074", "0.53937256", "0.53801376", "0.5358599", "0.53412294", "0.5340814", "0.53314966", "0.53114754", "0.52984965", "0.52977055", "0.5296272", "0.5260649", "0.5245076", "0.52388334", "0.52388334", "0.52388334", "0.52388334", "0.52388334", "0.5235081", "0.52321917", "0.5228592", "0.5220735", "0.52198535", "0.52139324", "0.5208539", "0.5206585", "0.5178542", "0.5175199", "0.5173538", "0.5167041", "0.51614195", "0.51577675", "0.5153909", "0.51528823", "0.5152225", "0.51429904", "0.5141399", "0.51345575", "0.51145", "0.5114052", "0.5114052", "0.5110216", "0.5108656", "0.50935394", "0.5089196", "0.5081936", "0.5079627", "0.50675833", "0.5056105", "0.5053687", "0.5050475", "0.5050475", "0.503471", "0.5028311", "0.501982", "0.50157547", "0.5013552", "0.50014806", "0.50011593", "0.49976763", "0.4990292", "0.4990292", "0.49882022", "0.4981269", "0.49792367", "0.49766538", "0.4967978", "0.49667212", "0.4958987", "0.49572337", "0.49550423", "0.4954479", "0.4952353", "0.494726", "0.4944055", "0.4935437", "0.4931248", "0.49283475", "0.49281213", "0.49268973", "0.4921738", "0.49204507", "0.4918924", "0.49182287", "0.4916538", "0.49158585", "0.49156788" ]
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def project_params params.require(:project).permit(:name, :link, :status, :description) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strong_params\n params.require(:user).permit(param_whitelist)\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def allow_params_authentication!; end", "def allowed_params\n ALLOWED_PARAMS\n end", "def default_param_whitelist\n [\"mode\"]\n end", "def param_whitelist\n [:role, :title]\n end", "def expected_permitted_parameter_names; end", "def safe_params\n params.except(:host, :port, :protocol).permit!\n end", "def strong_params\n params.require(:team_member).permit(param_whitelist)\n end", "def permitir_parametros\n \t\tparams.permit!\n \tend", "def strong_params\n params.require(:community).permit(param_whitelist)\n end", "def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end", "def strong_params\n params.require(:education).permit(param_whitelist)\n end", "def restricted_params\n #params.require(self.controller_name.classify.underscore.to_sym).permit([])\n raise(\"No strong params set, override restricted_params method in your controller. E.g. params.require(:model).permit(:attribute1, :attribute2)\")\n end", "def allowed_params\n params.require(:user).permit(:username, :email, :password, :password_confirmation)\n end", "def param_whitelist\n [:rating, :review]\n end", "def param_whitelist\n whitelist = [\n :username, :name,\n :parent_id,\n :headline, :description, :video,\n :policy, :signup_mode, :category,\n :website, :facebook, :twitter, :linkedin,\n :founded_at,\n privacy: [\n :events,\n :resources\n ],\n permission: [\n :profile,\n :members,\n :children,\n :statistics,\n :posts,\n :listings,\n :resources,\n :events\n ],\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:parent_id)\n unless current_user.role_in(@community) === 'owner'\n whitelist.delete(:privacy)\n whitelist.delete(:permission)\n end\n end\n \n whitelist\n end", "def param_whitelist\n if @user.present? && current_user != @user\n return [:followed]\n end\n \n whitelist = [\n :username, :email, :password,\n :first_name, :last_name,\n :birthday, :gender,\n :headline, :biography, :ask_about, :focus,\n :website, :facebook, :linkedin, :twitter, :github,\n roles: [],\n skills: [],\n interests: [],\n privacy: { contact: [] },\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:email)\n whitelist.delete(:password)\n end\n \n whitelist\n end", "def user_params \n \tparams.require(:user).permit(:name, :email, :password, :password_confirmation)# preventing CSTR\n end", "def user_params\n params.permit(:name, :phoneNumber, :address, :postalCode, :local, :link, :counter, :latitude, :longitude) \n end", "def valid_params_request?; end", "def strong_params\n params.require(:experience).permit(param_whitelist)\n end", "def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end", "def whitelist_url_params\n params.require(:whitelist_url).permit(:domain)\n end", "def allowed_params\n params.require(:allowed).permit(:email)\n end", "def permitted_params\n []\n end", "def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end", "def safe_params\n params.permit(:id, :name, :origin, :emails => []); #emails is an array\n end", "def query_param\n\t\tparams.permit(:first_name, :last_name, :phone)\n\tend", "def strong_params\n params.require(:success_metric).permit(param_whitelist)\n end", "def devise_filter\r\n logger.debug(\"In devise_filter =>PARAMS: #{params.inspect}\")\r\n\r\n # White list for sign_up\r\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(user_whitelist) }\r\n\r\n # White list for account update\r\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(user_whitelist, :current_password) }\r\n\r\n # White list for Invitation creation\r\n devise_parameter_sanitizer.for(:invite) { |u| u.permit(:account_type, :email, :invitation_token)}\r\n\r\n # White list for accept invitation\r\n devise_parameter_sanitizer.for(:accept_invitation) { |u| u.permit(user_whitelist, :invitation_token)}\r\n\r\n end", "def whitelisted_user_params\n params.require(:user).\n permit( :first_name, :last_name, :email,:password,:password_confirmation,:birthday,:gender)\n end", "def user_params\n ActionController::Parameters.permit_all_parameters = true\n params.require(:user) #.permit(:name, :surname, :phone, :password, :email, :time_zone)\n end", "def strong_params\n params.require(:metric_change).permit(param_whitelist)\n end", "def safe_params\n params.require(:user).permit(:name)\n end", "def get_params\n\t\treturn ActionController::Parameters.new(self.attributes).permit(\"account_id\", \"title\", \"category\", \"introduction\", \"tags\", \"segment_type\", \"visible\", \"status\", \"main_image\")\n\tend", "def grant_params\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\n end", "def check_params; true; end", "def param_whitelist\n whitelist = [\n :description,\n :progress,\n :kpi_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:kpi_id)\n end\n \n whitelist\n end", "def quote_params\n params.permit!\n end", "def valid_params?; end", "def paramunold_params\n params.require(:paramunold).permit!\n end", "def user_params\n\t\tparams.permit(:nickname, :avatar, :description, :password, :gender, :birthday, :email, :phone, :qq_id, :wechat_id)\n\tend", "def filtered_parameters; end", "def user_params\n params.permit(\n \t:id,\n \t:email, \n \t:first_name, \n \t:last_name, \n \t:password, \n \t:confirm_token, \n \t:phone_number,\n \t:facebook_link,\n \t:car_model,\n \t:license_plate)\n end", "def filtering_params\n params.permit(:email, :name)\n end", "def check_params\n true\n end", "def wx_public_params\n params.require(:wx_public).permit(:nickname, :manager, :alias)\n end", "def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end", "def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end", "def listing_params\n\t\tparams.permit(:address, :transit_info, :rules, :other_info, :lat, :lng)\n\tend", "def social_account_params\n\t\t\tparams.require(:social_account).permit!\n\t\tend", "def safe_params\n resurce_name = self.class.resource_name\n params_method_name = \"#{resurce_name}_params\".to_sym\n if params[resurce_name]\n if respond_to?(params_method_name) || private_methods.include?(params_method_name)\n send(params_method_name)\n else\n raise ActiveModel::ForbiddenAttributesError, \"Please, define the '#{params_method_name}' method in #{self.class.name}\"\n end\n end\n end", "def url_params\n params.require(:url).permit(:short_url, :original_url, :clicks, :ip_addresses)\n end", "def user_params\n params.require(:user).permit(:uri, :username, :password, :realname, :email, :publicvisible)\n end", "def model_params\n\t\tparams.require(:manager).permit(\n\t :user_name,\n :password,\n :email,\n \t\t\t)\n\tend", "def article_params_whitelist\n params.require(:article).permit(:title, :description, category_ids: [])\n end", "def college_whitelist_params\n params.require(:college_whitelist).permit(:status)\n end", "def active_code_params\n params[:active_code].permit\n end", "def filtering_params\n params.permit(:email)\n end", "def valid_params(params)\n params.permit(:user_id, :photo_id, :originX, :originY, :width, :height)\n end", "def ip_address_params\n\t\t\tparams.require(:ip_address).permit!\n end", "def pull_request_params\n whitelist = [\n :url,\n :id,\n :html_url,\n :diff_url,\n :patch_url,\n :issue_url,\n :number,\n :state,\n :locked,\n :title\n ]\n params.require(:pull_request).permit(whitelist)\n end", "def reserved_params\n params.require(:reserved).permit(:name, :email, :pax, :address, :KTP, :title)\n end", "def post_params\n if current_user.admin? \n params.permit(:title, :body, :city, :country, :gps_location, :privacy, :visible, :latitude, :longitude, images: [], files: [])\n else \n params.permit(:title, :body, :city, :country, :gps_location, :privacy,:latitude, :longitude, images: [], files: [])\n end \n end", "def list_params\n params.permit(:name)\n end", "def filter_parameters; end", "def filter_parameters; end", "def vineyard_params\n params.permit(:vineyard_name, :email, :website_url, :phone, :address, :city, :region, :postcode, :country, :specialty, :description, :pet_friendly, :holiday, :tours, :events, :family_friendly, :cover_image, :image_one, :image_two, :image_three, :image_four, :user_id, :base64)\n end", "def available_activity_params\n # params.require(:available_activity).permit(:type,:geometry,:properties)\n whitelisted = ActionController::Parameters.new({\n type: params.require(:available_activity)[:type],\n geometry: params.require(:available_activity)[:geometry].try(:permit!).to_h,\n properties: params.require(:available_activity)[:properties].try(:permit!).to_h\n }).try(:permit!)\n end", "def user_params\n params.permit(:name, :username, :email, :password, :img_url, :bg_url, :coinbank)\n end", "def user_params_pub\n\t \tparams[:user].permit(:hruid)\n\t end", "def user_params\n params.permit(:id, :email, :password, :nickname, :status, :avatar, :flat_picture, :flatsharing_id, :member,\n :user, :color, :solde)\n end", "def validate_search_inputs\n @whitelisted = params.fetch(:user, nil)\n if @whitelisted.blank?\n render_error(400, \"#{I18n.t('general_error.params_missing_key')}\": [I18n.t('general_error.params_missing_value', model: \"review\")])\n return\n else\n @whitelisted = @whitelisted.permit(:name, :uen, :description)\n end\n end", "def param_whitelist\n [\n :title,\n :description,\n :organization,\n :team_id,\n :started_at,\n :finished_at,\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n end", "def url_whitelist; end", "def admin_social_network_params\n params.require(:social_network).permit!\n end", "def filter_params\n params.require(:filters).permit(:letters)\n end", "def origin_params\n params.permit(:country, :state, :city, :postal_code, :address, :description)\n end", "def valid_params(params)\n params.permit(:login, :first_name, :last_name, \n :password, :password_confirmation)\n end", "def sensitive_params=(params)\n @sensitive_params = params\n end", "def permit_request_params\n params.permit(:address)\n end", "def user_params\n # Ensure a user can't give themselves admin priveleges\n params.delete(:admin) if current_user.admin?\n params.require(:user).permit(:name, :email, :admin, :image)\n end", "def secure_params\n params.require(:location).permit(:name)\n end", "def strong_params\n params.require( :setting ).\n permit( :global_scan_limit, :per_user_scan_limit,\n :target_whitelist_patterns, :target_blacklist_patterns )\n end", "def question_params\n params.require(:survey_question).permit(question_whitelist)\n end", "def case_insensitive_params\n params.require(:case_insensitive).permit(:name)\n end", "def empire_master_no_match_params\n params.require(:empire_master_no_match).permit(:uid, :last_name, :list, :search_date, :double, :source)\n end", "def maintenance_request_params\n params[:maintenance_request].permit! #allow all parameters for now\n end", "def unwanted_params\n params.require(:unwanted).permit(:title, :description, :image)\n end", "def url_params\n params[:url].permit(:full)\n end", "def backend_user_params\n params.permit!\n end", "def filter_params\n\t\treturn params[:candidate].permit(:name_for_filter)\n\tend", "def speed_measurement_params\n\n #fuckit, to lazy to deal with permit crap right now\n ActionController::Parameters.permit_all_parameters = true\n\n params[:speed_measurement]\n end", "def user_params\n params.permit(:name, :age, :username, :display_photo, :password)\n end", "def get_params\r\n #params.require(:article).permit(:title, :permalink, :content, :source_site, :introtext, :type_id, :order_by, :searchable, :created_by, :edited_by, :published_by, :published_on, :user_id)\r\n params.require(:article).permit!\r\n\r\n end", "def pub_params\n params.require(:pub).permit(:name, :description, :phone, :email, :hidden, :city_id, :address)\n end", "def pass_params\n params[:pass].permit(:name, :price, :description, :colour, :events)\n end", "def droptraining_params\n params.permit(:training_id,:user_id, :utf8, :authenticity_token, :commit)\n end", "def person_params\n # params whitelist does *not* include admin, sub, remember_token\n # TBD: share this whitelist with the list used by configuration_permitted_parameters\n # TBD: should current_password be on this list? -- for now, leaving off, since it seems to work without\n # NOTE: do not include 'admin' in this list!\n params.require(:person).permit(\n :name, \n :email, \n :description,\n :password, \n :password_confirmation\n )\n end", "def parameter_params\n params.require(:parameter).permit(:name, :description, :param_code, :param_value, :active_from, :active_to)\n end" ]
[ "0.69792545", "0.6781151", "0.67419964", "0.674013", "0.6734356", "0.6591046", "0.6502396", "0.6496313", "0.6480641", "0.6477825", "0.64565", "0.6438387", "0.63791263", "0.63740575", "0.6364131", "0.63192815", "0.62991166", "0.62978333", "0.6292148", "0.6290449", "0.6290076", "0.62894756", "0.6283177", "0.6242471", "0.62382483", "0.6217549", "0.6214457", "0.6209053", "0.6193042", "0.6177802", "0.6174604", "0.61714715", "0.6161512", "0.6151757", "0.6150663", "0.61461", "0.61213595", "0.611406", "0.6106206", "0.6105114", "0.6089039", "0.6081015", "0.6071004", "0.60620916", "0.6019971", "0.601788", "0.6011056", "0.6010898", "0.6005122", "0.6005122", "0.6001556", "0.6001049", "0.59943926", "0.5992201", "0.59909594", "0.5990628", "0.5980841", "0.59669393", "0.59589154", "0.5958826", "0.5957911", "0.5957385", "0.5953072", "0.59526145", "0.5943361", "0.59386164", "0.59375334", "0.59375334", "0.5933856", "0.59292704", "0.59254247", "0.5924164", "0.59167904", "0.59088355", "0.5907542", "0.59064597", "0.5906243", "0.5898226", "0.589687", "0.5896091", "0.5894501", "0.5894289", "0.5891739", "0.58860534", "0.5882406", "0.587974", "0.58738774", "0.5869024", "0.58679986", "0.5867561", "0.5865932", "0.5864461", "0.58639693", "0.58617616", "0.5861436", "0.5860451", "0.58602303", "0.5854586", "0.58537364", "0.5850427", "0.5850199" ]
0.0
-1
GET /transactions GET /transactions.json
def index @transactions = Transaction.all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def transactions\n JSON.parse(response.body).fetch('transactions')\n end", "def transactions\n JSON.parse(call_blockchain_api(\"transactions\"))\n end", "def index\n @transactions = Transaction.all\n render json: @transactions\n end", "def all_transactions\n json_response(Transaction.all)\n end", "def fetch_wallets_transactions(filters = {})\n MangoPay.request(:get, url() + \"/transactions\", {}, filters)\n end", "def my_transactions\n @transactions = Transaction.find_all_by_user_id(current_user.id)\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @transactions }\n end\n end", "def transactionById\n results = HTTParty.get(\"http://192.168.99.101:4050/transactions/\" + (params[:id]).to_s)\n render json: results.parsed_response, status: results.code\n end", "def index\n account = Account.find(params[:account_id].to_i)\n @transactions = account.transactions\n\n transactions_json = TransactionSerializer.new(@transactions).serialized_json\n render json: transactions_json\n end", "def index\n user_coin_transactions = get_user_coin_transactions\n if user_coin_transactions\n json_response(user_coin_transactions)\n else \n json_response({:status => false, :message => 'no transaction'})\n end\n end", "def index\n @transactions = @account.transactions\n paginate @transactions.count, 20 do |limit, offset|\n render json: @transactions.limit(limit).offset(offset)\n end\n\n # render json: @transactions\n end", "def index\n if @account\n @transactions = @account.transactions\n else\n @transactions = Transaction.all\n end\n render json: @transactions\n end", "def user_transactions\n user_deposits = get_user_deposits\n user_withdrawals = get_user_withdrawals\n json_response({:user_transactions => @user_transactions, :user_deposits => user_deposits, :user_withdrawals => user_withdrawals})\n end", "def show\n @transactions = Transaction.where(user_id: params[:id])\n render json: @transactions\n end", "def index\n @transactions = Transaction.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @transactions }\n end\n end", "def index\n @transactions = Transaction.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @transactions }\n end\n end", "def index\n @transactions = Transaction.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @transactions }\n end\n end", "def index\n\t@transactions = current_user.transactions.all.order(created_at: :desc)\n\trender json: { transactions: @transactions }\nend", "def get_transactions\n @transactions\n end", "def transactions\n @transactions ||= ArkEcosystem::Client::API::Transactions.new(@client) # rubocop:disable Metrics/LineLength\n end", "def transactions(options = {})\n response = JSON.parse(@client.get(\"items/#{send(:id)}/transactions\", options).body)\n transactions = response.key?('transactions') ? response['transactions'] : []\n transactions.map { |attributes| Promisepay::Transaction.new(@client, attributes) }\n end", "def transactions(options = {})\n response = JSON.parse(@client.get(\"items/#{send(:id)}/transactions\", options).body)\n transactions = response.key?('transactions') ? response['transactions'] : []\n transactions.map { |attributes| Promisepay::Transaction.new(@client, attributes) }\n end", "def transactions(options = {})\n response = JSON.parse(@client.get(\"items/#{send(:id)}/transactions\", options).body)\n transactions = response.key?('transactions') ? response['transactions'] : []\n transactions.map { |attributes| Promisepay::Transaction.new(@client, attributes) }\n end", "def transactions account_id\n data = perform_get(\"#{ACCOUNTS_PATH}/#{account_id}/transactions\")\n data[:accountTransactions] || []\n end", "def index\n @transactions = current_user.wallet.transactions\n\n end", "def get_transactions(service)\n\t\treturn @transport.get_path(\"transactions\",service)\n\tend", "def getTransactions\n\t\t\n\tend", "def index\n @transactions = current_user.transactions\n end", "def transactions\n res = filter\n .apply( account.all_transactions.reverse_order(:created_at) )\n\n res\n .paginate(page, per_page)\n end", "def index\n\t\ttransaction = Transaction.where(user_id: params[:user_id])\n\n\t\tif transaction\n\t\t\trender json: transaction,status: 200\n\t\telse\n\t\t\trender json: transaction.errors.messages,status: 422\n\t\tend\t\n\tend", "def transactions_get(opts = {})\n data, _status_code, _headers = transactions_get_with_http_info(opts)\n data\n end", "def get_transactions_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: PaymentsTransactionsApi.get_transactions ...\"\n end\n # resource path\n local_var_path = \"/transactions\"\n\n # query parameters\n query_params = {}\n query_params[:'filter_invoice'] = opts[:'filter_invoice'] if !opts[:'filter_invoice'].nil?\n query_params[:'size'] = opts[:'size'] if !opts[:'size'].nil?\n query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?\n query_params[:'order'] = opts[:'order'] if !opts[:'order'].nil?\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['oauth2_client_credentials_grant', 'oauth2_password_grant']\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'PageResourceTransactionResource')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: PaymentsTransactionsApi#get_transactions\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def index\n @transactions = Transaction.all \n end", "def get_transactions(opts = {})\n data, _status_code, _headers = get_transactions_with_http_info(opts)\n data\n end", "def get_transactions(type = 'all', limit = 10)\n post_data = initial_post_data\n post_data['method'] = 'getTransactions'\n post_data['params'] = [type, limit]\n post_request(post_data)\n end", "def index\n @transactions = Transaction.all \n end", "def index\n @transactions = Transaction.all\n render_success_response({\n transaction: array_serializer.new(@transactions, serializer: TransactionSerializer)\n })\n end", "def transactions\n case params[:name]\n when 'missing'\n @transactions = @set.missing_transactions\n when 'overlapping'\n @transactions = @set.overlapping_transactions\n else\n @transactions = []\n end\n\n respond_to do |format|\n format.js\n format.html\n end\n end", "def index\n if admin_signed_in?\n @transactions = Transaction.all\n else\n @transactions = Transaction.tri(@current_user.id).all\n end\n respond_to do |format|\n format.html\n format.json { render json: @transactions}\n end\n end", "def index\n @transactions = User.find(params[:id])\n end", "def wallet_transactions_listing(wallet_id, type)\n add_timestamp\n add_salt\n headers = { 'content-type' => 'application/json',\n 'signature' => signature('', 'get', \"/v1/user/#{wallet_id}/transactions?type=#{type}\"), 'salt' => salt, 'timestamp' => timestamp, 'access_key' => access_key }\n response, msg = rest_client.getCall(\"/v1/user/#{wallet_id}/transactions?type=#{type}\", headers)\n JSON.parse(response)['data'] if response.present?\n rescue StandardError => e\n Rails.logger.error e\n nil\n end", "def get_transactions(opts = {})\n data, _status_code, _headers = get_transactions_with_http_info(opts)\n return data\n end", "def get_transactions_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: TransactionsApi.get_transactions ...'\n end\n if @api_client.config.client_side_validation && opts[:'transactions_type'] && !['automated', 'manual'].include?(opts[:'transactions_type'])\n fail ArgumentError, 'invalid value for \"transactions_type\", must be one of automated, manual'\n end\n # resource path\n local_var_path = '/transactions'\n\n # query parameters\n query_params = {}\n query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?\n query_params[:'per'] = opts[:'per'] if !opts[:'per'].nil?\n query_params[:'external_id'] = opts[:'external_id'] if !opts[:'external_id'].nil?\n query_params[:'sender_id'] = opts[:'sender_id'] if !opts[:'sender_id'].nil?\n query_params[:'transactions_type'] = opts[:'transactions_type'] if !opts[:'transactions_type'].nil?\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['AuthorizationKey', 'AuthorizationNonce', 'AuthorizationSecret', 'AuthorizationSignature']\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'TransactionListResponse')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: TransactionsApi#get_transactions\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def index\n @transactions = Transaction.filter(params.slice(:contact, :transaction_type)).ordered_created_at\n _, transaction_list = pagy(@transactions)\n json_response({\n data: {\n transactions: transaction_list,\n count: @transactions.count\n }\n })\n end", "def index\n @transactions = @transactions.paginate(:page => params[:page], :per_page => 10)\n end", "def transactionByUser\n results = HTTParty.get(\"http://192.168.99.101:4050/by_user_id?userid=\" + (@current_user[\"id\"]).to_s)\n render json: results.parsed_response, status: results.code\n end", "def index\n @admin_transactions = AdminTransaction.page(params[:page]).per(params[:per])\n render json: @admin_transactions\n end", "def transaction\n add_breadcrumb \"Merchants\", epsadmin_merchants_path\n add_breadcrumb \"#{@transc_merchant.first_name}\", epsadmin_merchant_path(@transc_merchant.merchant_uniq_id)\n @epsadmin_transaction_list = @transc_merchant.transactions.order(\"created_at DESC\")\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @epsadmin_transaction_list }\n end\n end", "def fetch_wallet_transactions(funds_type, currency_iso_code, filters = {})\n MangoPay.request(:get, url() + \"/wallets/#{funds_type}/#{currency_iso_code}/transactions\", {}, filters)\n end", "def transactions\n txs = @client.listtransactions.reverse\n txs.map do |tx|\n tx = symbolize tx\n Transaction.new(\n account: tx.f(:account),\n address: tx.f(:address),\n category: tx.f(:category),\n amount: tx.f(:amount),\n vout: tx.f(:vout),\n confirmations: tx.f(:confirmations),\n blockhash: tx[:blockhash],\n blockindex: tx[:blockindex],\n blocktime: tx[:blocktime],\n txid: tx.f(:txid),\n keychainconflicts: tx.f(:keychainconflicts),\n time: tx.f(:time),\n timereceived: tx.f(:timereceived),\n )\n end\n end", "def index\n @transactions = Transaction.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @transactions }\n end\n end", "def transactions(options = {})\n @gateway.customer.transactions(id, options)\n end", "def gettransaction(txid)\n request :gettransaction, txid\n end", "def get_transaction(account_id, transaction_id)\n query_api_object Transaction, \"/rest/accounts/#{account_id}/transactions/#{transaction_id}\"\n end", "def find_all(options = {})\n response = JSON.parse(@client.get('transactions', options).body)\n transactions = response.key?('transactions') ? response['transactions'] : []\n transactions.map { |attributes| Promisepay::Transaction.new(@client, attributes) }\n end", "def index\n @wallet_transactions = WalletTransaction.all\n end", "def transactions(account_id, opts = {})\n query = {}\n query['cursor'] = opts[:cursor] if opts[:cursor]\n query['start'] = opts[:start] if opts[:start]\n query['end'] = opts[:end] if opts[:end]\n query['time_field'] = opts[:time_field] if opts[:time_field]\n\n api_get(path(account_id), query)\n end", "def index\n limit = params[:limit] || MonzoTransaction.count\n @page = { page: params[:page], per_page: limit.to_i }\n @order = params[:order] || \"created_at\"\n\n @transactions = MonzoTransaction.order(@order).paginate(@page)\n @balance = MonzoTransaction.balance\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @transactions, callback: params[:callback] }\n format.xml { render xml: @transactions }\n format.rss { render 'feed' }\n end\n end", "def getTransaction( transaction_id)\n params = Hash.new\n params['transaction_id'] = transaction_id\n return doCurl(\"get\",\"/transaction\",params)\n end", "def get_transaction(tx_id:)\n client.make_request('/get-transaction', 'post', params: {tx_id: tx_id})\n end", "def index\n @transaction_requests = TransactionRequest.all\n end", "def gettransaction(txid)\n @api.request 'gettransaction', txid\n end", "def gettransaction(txid)\n @api.request 'gettransaction', txid\n end", "def index\n @bitcoin_transactions = BitcoinTransaction.all\n end", "def index\n @transaction = find_parent.transactions.includes(:user, :deal)\n respond_with(paginate(@transactions), :include => [:user])\n end", "def index\n @journal = Journal.find(params[:journal]) if params[:journal]\n @transactions = Transaction.rev_chrono\n @transactions = @transactions.for_journal(params[:journal]) if params[:journal]\n \n if params[:filter] == 'tagged' && params[:tags]\n @transactions = @transactions.with_tag(params[:tags])\n end\n \n @transactions = @transactions.page params[:page]\n respond_with(@transactions)\n end", "def get_bank_transactions(options = {})\n request_params = {}\n request_params[:BankTransactionID] = options[:bank_transaction_id] if options[:bank_transaction_id]\n request_params[:ModifiedAfter] = options[:modified_since] if options[:modified_since]\n request_params[:order] = options[:order] if options[:order]\n request_params[:where] = options[:where] if options[:where]\n request_params[:page] = options[:page] if options[:page]\n\n response_xml = http_get(@client, \"#{@xero_url}/BankTransactions\", request_params)\n\n parse_response(response_xml, {:request_params => request_params}, {:request_signature => 'GET/BankTransactions'})\n end", "def index\n @transactions = Transaction.find_all_by_user_id(current_user.id)\n if not @transactions\n flash.now[:error] = \"No transactions found for this user!\"\n end\n end", "def index\n @m_transactions = MTransaction.all\n end", "def transactions_by_ref(merchant_ref)\n client.get \"transactions/#{inst_id}/byRef?merchantRef=#{merchant_ref}\"\n end", "def transactions\n @transactions ||= []\n end", "def transactions(customer_id, status=\"NotSettled\")\n unless Transaction::STATUSES.include?(status)\n raise ArgumentError, \"Invalid status: #{status}\"\n end\n\n resp = get(\"/customer/#{customer_id}/Transactions/#{status}\")\n resp[\"Transactions\"].map { |t| Transaction.new(t) }\n end", "def transactions(since = nil, start_id = nil, count = 1000, include_pending = false)\n data = {}\n data[\"since\"] = (since.is_a?(Date) ? since.to_s : since) unless since.nil?\n data[\"start_id\"] = start_id unless start_id.nil?\n data[\"count\"] = count.to_s\n data[\"include_pending\"] = include_pending ? \"1\" : \"0\"\n response = query_api(\"/rest/transactions?\" + URI.encode_www_form(data)) \n return response[\"transactions\"].map {|transaction| Transaction.new(self, transaction)}\n end", "def index\n @account_transactions = AccountTransaction.paginate(page: params[:page], per_page: 30)\n end", "def index\n #valid_account_ids = current_user.accounts.map{|a|a.id}\n if params[:account_id]\n @account = current_user.accounts.find(params[:account_id])\n elsif params[:category_id]\n @category = Category.find(params[:category_id])\n else\n @account = current_user.accounts.current_accounts.first\n end\n\n if @account\n @transactions = Transaction.where(:account_id => @account.id).order(\"date desc, created_at desc\").limit(100)\n @transaction = Transaction.new(:date => Date.today, :account_id => @account.id)\n else\n @transactions = Transaction.where(:category_id => @category.id).order(\"date desc, created_at desc\").limit(100)\n end\n\n @current_date = Date.today\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @transactions }\n end\n end", "def transactionGet(options={})\n assert_valid_keys(options, :transactionId)\n assert_keys_exists(options, :transactionId)\n execute(:transactionGet, options)\n end", "def transactionGet(options={})\n assert_valid_keys(options, :transactionId)\n assert_keys_exists(options, :transactionId)\n execute(:transactionGet, options)\n end", "def transactions(options = {})\n []\n end", "def transactions\n raw_transactions = @agent.get(\"https://wwws.mint.com/transactionDownload.event?\").body\n\n transos = []\n\n raw_transactions.split(\"\\n\").each_with_index do |line,index|\n\n if index > 1\n line_array = line.split(\",\")\n transaction = {\n :date => Date.strptime(remove_quotes(line_array[0]), '%m/%d/%Y'),\n :description=>remove_quotes(line_array[1]),\n :original_description=>remove_quotes(line_array[2]),\n :amount=>remove_quotes(line_array[3]).to_f,\n :type=>remove_quotes(line_array[4]),\n :category=>remove_quotes(line_array[5]),\n :account=>remove_quotes(line_array[6]),\n :labels=>remove_quotes(line_array[7]),\n :notes=>remove_quotes(line_array[8])\n }\n transos << transaction\n\n if block_given?\n yield transaction\n end\n\n end\n\n end\n transos\n \n end", "def transactions(count = 10)\n @client.transactions(name, count)\n end", "def get_transactions(*params); raise('Stub or mock required.') end", "def listtransactions(account, count = 10)\n request :listtransactions, account, count\n end", "def show\n @transaction = Transaction.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @transaction }\n end\n end", "def show\n @transaction = Transaction.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @transaction }\n end\n end", "def show\n @transaction = Transaction.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @transaction }\n end\n end", "def show\n @transaction = Transaction.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @transaction }\n end\n end", "def show\n @transaction = Transaction.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @transaction }\n end\n end", "def list_wallet_transactions(wallet_id: default_wallet_id, params: {})\n call :get, \"/wallet/#{wallet_id}/tx\", params\n end", "def find(id)\n response = JSON.parse(@client.get(\"transactions/#{id}\").body)\n Promisepay::Transaction.new(@client, response['transactions'])\n end" ]
[ "0.8164624", "0.796332", "0.77854896", "0.7751081", "0.7728147", "0.7706774", "0.7691088", "0.7651612", "0.7590682", "0.7567767", "0.7548055", "0.751779", "0.75108814", "0.745996", "0.745996", "0.745996", "0.73983127", "0.7326831", "0.7299761", "0.7288485", "0.7288485", "0.7288485", "0.72474736", "0.72383595", "0.7231423", "0.72071624", "0.7179262", "0.71488446", "0.71474665", "0.71427435", "0.7127549", "0.70809424", "0.7064867", "0.70319676", "0.70271236", "0.70238006", "0.70092994", "0.6988081", "0.69849145", "0.69822633", "0.6953893", "0.69320273", "0.69259596", "0.6901523", "0.68897676", "0.68881494", "0.68585545", "0.6815605", "0.68143004", "0.67863137", "0.67798996", "0.6772969", "0.6748839", "0.6747516", "0.6690085", "0.6645738", "0.6644841", "0.66400176", "0.662081", "0.6599684", "0.65941316", "0.65941316", "0.6593449", "0.6585045", "0.6584231", "0.65836346", "0.6574847", "0.6573473", "0.6565683", "0.6556276", "0.6555494", "0.65528744", "0.65444696", "0.65371364", "0.65352124", "0.65352124", "0.6535035", "0.65336585", "0.6517354", "0.6510736", "0.6506427", "0.65009487", "0.65009487", "0.65009487", "0.65009487", "0.65009487", "0.64896727", "0.64705116" ]
0.71780056
38
Use callbacks to share common setup or constraints between actions.
def set_transaction @transaction = Transaction.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_eval do\n define_method(:valid?) do |*args|\n self.class.state_machines.fire_event_attributes(self, :save, false) { super(*args) }\n end\n end\n end\n end", "def add_actions; end", "def callbacks; end", "def callbacks; end", "def setup *actions, &proc\n (@setup_procs ||= []) << [proc, actions.size > 0 ? actions : [:*]]\n end", "def define_action_helpers; end", "def post_setup\n end", "def action_methods; end", "def action_methods; end", "def action_methods; end", "def before_setup; end", "def action_run\n end", "def execute(setup)\n @action.call(setup)\n end", "def define_action_helpers?; end", "def set_actions\n actions :all\n end", "def action_done(action)\n dispatch = { :migrate => :done_migrating, :map => :done_mapping, :reduce =>\n :done_reducing, :finalize => :done_finalizing } \n self.send dispatch[action[:action]], action\n end", "def dependencies action, &block\n @actions.each do |other|\n if action[:requires].include? other[:provide]\n block.call other\n end\n end\n end", "def setup!\n return unless @setup_procs\n http_actions = actions\n @setup_procs.each do |setup_proc|\n proc, actions = setup_proc\n @setup__actions = actions.map do |action|\n\n action.is_a?(Regexp) ?\n http_actions.select { |a| a.to_s =~ action } :\n action.is_a?(String) && action =~ /\\A\\./ ?\n http_actions.map { |a| a.to_s << action if format?(a).include?(action) }.compact :\n action\n\n end.flatten\n self.class_exec &proc\n @setup__actions = nil\n end\n @setup_procs = nil\n end", "def before_actions(*logic)\n self.before_actions = logic\n end", "def setup_handler\n end", "def set_action(opts)\n opts = check_params(opts,[:actions])\n super(opts)\n end", "def setup(action)\n @targets.clear\n unless action.item.target_filters.empty?\n @targets = SES::TargetManager.make_targets(action)\n else\n item = action.item\n if item.for_opponent?\n @targets = $game_troop.alive_members\n elsif item.for_dead_friend?\n @targets = $game_party.battle_members.select { |actor| actor.dead? }\n else\n $game_party.battle_members.select { |actor| actor.alive? }\n end\n end\n @item_max = @targets.size\n create_contents\n refresh\n show\n activate\n end", "def action; end", "def action; end", "def action; end", "def action; end", "def action; end", "def workflow\n end", "def revisable_shared_setup(args, block)\n class << self\n attr_accessor :revisable_options\n end\n options = args.extract_options!\n self.revisable_options = Options.new(options, &block)\n \n self.send(:include, Common)\n self.send(:extend, Validations) unless self.revisable_options.no_validation_scoping?\n self.send(:include, WithoutScope::QuotedColumnConditions)\n end", "def setup\n @action = SampleActionAndroid.new(os_name: 'android',\n app_name: APP_PATH)\n end", "def before(action)\n invoke_callbacks *self.class.send(action).before\n end", "def process_action(...)\n send_action(...)\n end", "def before_dispatch(env); end", "def after_actions(*logic)\n self.after_actions = logic\n end", "def setup\n # override and do something appropriate\n end", "def setup(client)\n return unless @setup\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n actions.each do |action|\n action.execute(client)\n end\n self\n end", "def setup(_context)\n end", "def setup(resources) ; end", "def validate_actions\n errors.add(:base, :should_give_at_least_one_action) if !manage? && !forecasting? && !read? && !api?\n end", "def setup\n @resource_config = {\n :callbacks => {\n :before_create => nil,\n :after_create => nil,\n :before_update => nil,\n :after_update => nil,\n :before_destroy => nil,\n :after_destroy => nil,\n },\n :child_assoc => nil,\n :model => nil,\n :parent => nil,\n :path => nil,\n :permission => {},\n :properties => {},\n :relation => {\n :create => nil,\n :delete => nil,\n },\n :roles => nil,\n }\n end", "def determine_valid_action\n\n end", "def process_shared\n handle_taxes\n handle_shippings\n create_adjustments_from_params\n handle_status\n handle_inventory_refunds\n handle_payment_transactions\n order.updater.update\n end", "def startcompany(action)\n @done = true\n action.setup\n end", "def init_actions\n am = action_manager()\n am.add_action(Action.new(\"&Disable selection\") { @selection_mode = :none; unbind_key(32); bind_key(32, :scroll_forward); } )\n am.add_action(Action.new(\"&Edit Toggle\") { @edit_toggle = !@edit_toggle; $status_message.value = \"Edit toggle is #{@edit_toggle}\" })\n end", "def event_callbacks(event, metadata={})\n case event\n when :reset, :review\n if confirmed\n update_attributes(confirmed: false)\n end\n when :confirm\n confirm\n # trigger :order for all applicable items\n # NOTE: :order event is common to both physical and digital items\n items.each do |i|\n if i.event_permitted(:order)\n user_id = last_transition.user_id\n i.trigger!(:order, { order_id: id, user_id: user_id })\n end\n end\n when :complete_work\n request = metadata[:request]\n work_complete_notification(request)\n when :close\n close\n end\n if event != :close && !open\n reopen\n end\n end", "def setup_action\n return unless PONY::ERRNO::check_sequence(current_act)\n new_sequence = @action_sequence[@sequence_index+1...@action_sequence.size]\n @sequence_index = 0\n new_sequence = DND::SkillSequence::ACTS[@acts[1]] + new_sequence\n execute_sequence\n end", "def define_tasks\n define_weave_task\n connect_common_tasks\n end", "def setup(&block)\n define_method(:setup, &block)\n end", "def setup\n transition_to(:setup)\n end", "def setup\n transition_to(:setup)\n end", "def action\n end", "def setup( *args )\n\t\t\tself.class.setupBlocks.each {|sblock|\n\t\t\t\tdebugMsg \"Calling setup block method #{sblock}\"\n\t\t\t\tself.send( sblock )\n\t\t\t}\n\t\t\tsuper( *args )\n\t\tend", "def config(action, *args); end", "def setup\n @setup_proc.call(self) if @setup_proc\n end", "def before_action \n end", "def setup_callbacks\n defined_callbacks.each do |meth|\n unless respond_to?(\"call_#{meth}_callbacks\".to_sym)\n self.class.module_eval <<-EOE\n def call_#{meth}_callbacks(*args)\n plugin_store.each {|a| a.call_#{meth}_callbacks(*args) } if respond_to?(:plugin_store) && plugin_store\n self.send :#{meth}, *args if respond_to?(:#{meth})\n end\n EOE\n end\n end\n end", "def action\n end", "def matt_custom_action_begin(label); end", "def setup\n # override this if needed\n end", "def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend", "def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend", "def action(options,&callback)\n new_action = Action===options ? options : Action.new(options,&callback)\n # replace any with (shared name/alias or both default) + same arity\n @actions.delete_if do |existing_action|\n ((existing_action.names & new_action.names).size > 0 ||\n existing_action.default? && new_action.default?) &&\n existing_action.required.size == new_action.required.size &&\n existing_action.optional.size <= new_action.optional.size\n end\n @actions = (@actions + [new_action]).sort\n new_action\n end", "def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action\n end", "def after(action)\n invoke_callbacks *options_for(action).after\n end", "def pre_task\n end", "def setup(server)\n server.on('beforeMethod', method(:before_method), 10)\n end", "def add_actions\n attribute = machine.attribute\n name = self.name\n \n owner_class.class_eval do\n define_method(name) {self.class.state_machines[attribute].events[name].fire(self)}\n define_method(\"#{name}!\") {self.class.state_machines[attribute].events[name].fire!(self)}\n define_method(\"can_#{name}?\") {self.class.state_machines[attribute].events[name].can_fire?(self)}\n end\n end", "def init_actions\n @select_action = SelectAction.new\n @endpoint_mouse_action = EndpointMouseAction.new\n @move_action = MoveAction.new\n end", "def setup_signals; end", "def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend", "def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend", "def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action.respond_to?('weak!') ? action.weak! : action\n end", "def initialize(*args)\n super\n @action = :set\nend", "def after_set_callback; end", "def setup\n #implement in subclass;\n end", "def lookup_action; end", "def setup &block\n if block_given?\n @setup = block\n else\n @setup.call\n end\n end", "def setup_action\n return TSBS.error(@acts[0], 1, @used_sequence) if @acts.size < 2\n actions = TSBS::AnimLoop[@acts[1]]\n if actions.nil?\n show_action_error(@acts[1])\n end\n @sequence_stack.push(@acts[1])\n @used_sequence = @acts[1]\n actions.each do |acts|\n @acts = acts\n execute_sequence\n break if @break_action\n end\n @sequence_stack.pop\n @used_sequence = @sequence_stack[-1]\n end", "def release_actions; end", "def around_hooks; end", "def save_action; end", "def setup(easy)\n super\n easy.customrequest = @verb\n end", "def action_target()\n \n end", "def setup\n callback(:setup) do\n notify(:setup)\n migration_check.last_deployed_commit\n end\n end", "def setup\n return unless @setup\n\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n run_actions_and_retry(actions)\n self\n end", "def before_setup\n # do nothing by default\n end", "def my_actions(options)\n @setup = false\n get_template_part(\"custom_used\",\"action_users\",true)\n end", "def default_action; end", "def setup(&blk)\n @setup_block = blk\n end", "def callback_phase\n super\n end", "def advice\n end", "def _handle_action_missing(*args); end", "def duas1(action)\n action.call\n action.call\nend", "def shared_action(name, &block)\n @controller.shared_actions[name] = block\n end", "def before_action action, &block\n @audience[:before][action] ||= Set.new\n @audience[:before][action] << block\n end", "def setup_initial_state\n\n state_a = State.new(\"a\", 0)\n state_b = State.new(\"b\", 0)\n state_c = State.new(\"c\", 10)\n\n move_to_b = Action.new(\"move_to_b\", 1, state_b)\n\n move_to_c = Action.new(\"move_to_c\", 1, state_c)\n\n state_a.actions = [move_to_b, move_to_c]\n\n return state_a\n \nend" ]
[ "0.6163163", "0.6045976", "0.5946146", "0.591683", "0.5890051", "0.58349305", "0.5776858", "0.5703237", "0.5703237", "0.5652805", "0.5621621", "0.54210985", "0.5411113", "0.5411113", "0.5411113", "0.5391541", "0.53794575", "0.5357573", "0.53402257", "0.53394014", "0.53321576", "0.53124547", "0.529654", "0.5296262", "0.52952296", "0.52600986", "0.52442724", "0.52385926", "0.52385926", "0.52385926", "0.52385926", "0.52385926", "0.5232394", "0.523231", "0.5227454", "0.52226824", "0.52201617", "0.5212327", "0.52079266", "0.52050185", "0.51754695", "0.51726824", "0.51710224", "0.5166172", "0.5159343", "0.51578903", "0.51522785", "0.5152022", "0.51518047", "0.51456624", "0.51398855", "0.5133759", "0.5112076", "0.5111866", "0.5111866", "0.5110294", "0.5106169", "0.509231", "0.50873137", "0.5081088", "0.508059", "0.50677156", "0.50562143", "0.5050554", "0.50474834", "0.50474834", "0.5036181", "0.5026331", "0.5022976", "0.5015441", "0.50121695", "0.5000944", "0.5000019", "0.4996878", "0.4989888", "0.4989888", "0.49864885", "0.49797225", "0.49785787", "0.4976161", "0.49683493", "0.4965126", "0.4958034", "0.49559742", "0.4954353", "0.49535993", "0.4952725", "0.49467874", "0.49423352", "0.49325448", "0.49282882", "0.49269363", "0.49269104", "0.49252945", "0.4923091", "0.49194667", "0.49174926", "0.49173003", "0.49171105", "0.4915879", "0.49155936" ]
0.0
-1
Scopes Events are active in system
def event_is_active_in_system all_active_events = Event.active.all.map{|e| e.id} unless all_active_events.include?(self.event_id) errors.add(:event_id, "is not an event in the system") end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def relevant_events_scope\n events\n end", "def relevant_events_scope\n raise NotImplementedError\n end", "def security_events\r\n SecurityEventsController.instance\r\n end", "def owned_events\n events\n end", "def update_global_common_events\n end", "def scopes; end", "def events\n event_lookup()\n end", "def events\n event_lookup()\n end", "def get_events\n # events created by this user\n @my_events = User.find(current_user.id).event_attendants.where('owner = 1')\n\n # events this user has joined\n @joined_events = User.find(current_user.id).event_attendants.where('attendee_status = 3 and owner IS NULL')\n \n # events this user is invited to\n @invited_to_events = User.find(current_user.id).event_attendants.where('attendee_status = 0')\n\n @maybe_events = User.find(current_user.id).event_attendants.where('attendee_status = 2')\n end", "def events\n end", "def load_events\r\n @events = Event.find(:all, \r\n :conditions => [\"user_id = \"\\\r\n \"#{session[:user_id]} and (begins >= CURRENT_DATE()\"\\\r\n \"or ends >= CURRENT_DATE())\"] ,\r\n :order => 'begins ASC')\r\n end", "def events\r\n load_private_events\r\n load_completed_private_events\r\n end", "def qualified_event; end", "def qualified_event; end", "def events\n @@events\n end", "def events\n # FIXME this logic belongs in the Event model. stop leaking AR outside of the model\n @events ||= Event.includes(:upcoming_observances).where(\"observances.start_on >= ?\", Date.current).references(:observances)\n end", "def events; end", "def events; end", "def events; end", "def events; end", "def events; end", "def events; end", "def events; end", "def events; end", "def send_events; end", "def event_requirement; end", "def scope; end", "def scope; end", "def scope; end", "def scope; end", "def scope; end", "def scope; end", "def scope; end", "def scope; end", "def scope; end", "def scope; end", "def do_event_action\n if self.casetype == 'order' || self.casetype == 'abandoned_cart' || self.casetype == 'preorder'\n puts \"Case do_event_action start\"\n events = Event.where(casetype: self.casetype)\n if events.present?\n puts \"case do_event_action\"\n user = User.find_by_subdomain(Apartment::Tenant.current)\n events.each do |event|\n Services::EventAction.do_action(user, event, self)\n end\n end\n puts \"Case do_event_action finish\"\n end\n end", "def events\n self.class.events\n end", "def events\n @execution.events if @execution\n end", "def applicationWillBecomeActive event\n @windowController.markCurrentRoomAsRead unless @windowController.nil?\n end", "def fires_in; end", "def permitted_events\n events = self.states_events_config.map { |se| se[:event] }\n events.delete_if { |e| !event_permitted(e) }\n end", "def evented\n @evented = true\n end", "def events\n self.class.state_machine.events_for(current_state)\n end", "def events\n Vedeu::Events.registered\n end", "def edit_start_time\n authorize @event\n end", "def get_events()\n @client.make_request(:get, @client.concat_user_path(\"#{CALL_PATH}/#{id}/events\"))[0]\n end", "def open?\n event_status_id == 1\n end", "def events_happening_at\n find_related_frbr_objects( :happens_at, :which_events?) \n end", "def all_adverse_events\n AdverseEvent\n .current\n .with_site(all_editable_sites.select(:id))\n .blinding_scope(self)\n end", "def events\n event_enum\n end", "def events\n event_enum\n end", "def index\n @events = current_user.super_user ? Event.all : current_user.events\n end", "def events\n @events = registered_application.events.group_by(&:name)\n end", "def my_events\n @events = []\n Event.all.each do |event|\n if (event.creator == current_user.id)\n @events << event\n end\n end\n end", "def events\n @events ||= user_events.concat(org_events).uniq\n end", "def get_events\n if @user.uuid.present?\n @events = @user.events.active_events.page(params[:page])\n paginate json: @events, per_page: params[:per_page]\n elsif @user.uuid == \"guest\"\n @events = Com::Nbos::Events::Event.active_events.where(tenant_id: @user.tenant_id)\n render json: @events\n else\n render :json => {messageCode: \"bad.request\", message: \"Bad Request\"}, status: 400\n end\n end", "def events\n @events ||= event_finder\n end", "def scopes\n @scopes ||= config[:scopes] || []\n end", "def org_events\n @org_events ||= orgs.map { |o| o.events }.flatten\n end", "def event_change\n\t\n\tend", "def events\n requires :label, :application_name\n service.events.all({\n 'ApplicationName' => application_name,\n 'VersionLabel' => label\n })\n end", "def scope_level; end", "def global_state \n @event_collector.global_state\n end", "def events\n @events ||= {}\n end", "def available_events\n\t\treturn current_room.events || []\n\tend", "def ineligible_current_spouses\n raise_unless_current_spouse_enabled\n self.gclass.send(ssex.to_s.pluralize, { scoped_at_val: self.send(\"#{gclass.scoped_at}\")} )\n end", "def find_event\n coffee_shop = find_coffee_shop\n return find_event_for_coffee_owner(coffee_shop) if current_user&.coffee_owner?\n return find_event_for_sys_expert(coffee_shop) if current_user&.sys_expert?\n find_event_for_other(coffee_shop)\n end", "def events\n @events ||= []\n @events\n end", "def check_for_current_event\n @event = Event.current_event\n\n if @event.blank?\n if current_user && current_user.role?(:track_manager)\n flash[:alert] = \"There is NO active Event. Please correct this immediately!\"\n else\n redirect_to page_event_not_set_path and return\n end\n end\n end", "def event_types; end", "def events_worked_and_managed\n Distribution.get_events_worked(self.id) + Distribution.get_events_managed(self.id)\n end", "def events\n @events ||= Array(context[:events]).reverse.map { |event| Concierge::SafeAccessHash.new(event) }\n end", "def events\n collection(\"events\")\n end", "def terminal_events\n bound_events.each_value.find_all(&:terminal?)\n end", "def events_hosting\n Event.where(:creator_uid => self.uid)\nend", "def show\n authorize @event\n end", "def index\n if current_user && current_user.is_admin? && params_user_id\n @events = User.find(params_user_id).events.where(is_validated:true)\n elsif params_user_id && params_user_id.to_i == current_user.id\n @events = current_user.events.where(is_validated:true)\n elsif params_user_id && params_user_id.to_i != current_user.id \n redirect_to root_path\n else\n @events= Event.where(is_validated:true)\n end\n end", "def scopes\n self.class.scopes\n end", "def events_for_authenticated_user page\n events = api_client.received_events(authenticated_user, page: page)\n filter_events events\n end", "def all_viewable_adverse_events\n AdverseEvent\n .current\n .with_site(all_viewable_sites.select(:id))\n .blinding_scope(self)\n end", "def get_events\n response = request(:get, \"/devmgr/v2/events\")\n #status(response, 200, 'Failed to get current events from server')\n #JSON.parse(response.body)\n response\n end", "def event_eligible?(events, uri)\n event = events.find { |evt|\n event = evt['_resolved'];\n ext_doc = event['external_documents'][0];\n event['event_type'] == 'ingestion' and ext_doc and ext_doc['location'] == uri\n }\n debug \"Islandora event eligible: #{event}\" if event\n event\n end", "def upcaming_events\n self.attended_events.upcaming\n end", "def scope\n super&.inquiry\n end", "def scope_condition() {} end", "def event_list\n @_events\n end", "def index\n case params[:scope]\n when \"past\" then @events = Event.past\n when \"free\" then @events = Event.free\n else @events = Event.upcoming \n end #case \n end", "def events\n @events ||= RubyEvents::Events.new(self)\n end", "def possible_events\n\t\t\t@events = []\n\t\t\topts = self.class.class_variable_get :@@options\n\t\t\tif self.has_attribute?(opts[:column_name].to_sym)\n\n\t\t\t\t@current = send(opts[:column_name].to_sym).to_sym #self.state.to_sym\n\t\t\t\tevent_states_table = self.class.class_variable_get :@@event_states_table\n\t\t\t\tevent_states_table.keys.each do |k|\n\t\t\t\t\tevent_states_table[k].each do |s|\n\t\t\t\t\t\tif s[:transition].keys[0] == @current and !@events.include?(k)\n\t\t\t\t\t\t\tif s[:guard] != nil\n\t\t\t\t\t\t\t\tputs \"guard result #{s[:guard].call(self)} for #{k}\"\n\t\t\t\t\t\t\t\tif s[:guard].call(self)\n\t\t\t\t\t\t\t\t\t@events << k\n\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\t@events << k\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\tend\n\n\t\t\tend\n\t\t\t@events\n\t\tend", "def scopes\n @scopes ||= {}\n end", "def events=(_); end", "def set_resource\n #apply policy scope\n @event = EventPolicy::Scope.new(current_user, Event).resolve.find(params[:id])\n end", "def scope\n GlobalScope.instance\n end", "def active_events_count\n self.events.where(\"end_day >= ?\", Date.today).where(:deleted => false).count\nend", "def common_event_reserved?\r\n @common_event_id > 0\r\n end", "def events(all = true)\n self.singleton_class.instance_events(all)\n end", "def authorize_admin\n authorize! :update, convention.events.new\n end", "def my_asists\n @events = []\n Attend.all.each do |attend|\n if (attend.userID == current_user.id)\n @events << Event.find(attend.eventID)\n end\n end\n end", "def index\n #@event_users = EventUser.where(event: @event)\n #@event_users = EventUserPolicy::Scope.new(current_user, [:admin, EventUser]).resolve\n @event_users = policy_scope(EventUser.where(event: @event))\n authorize @event_users\n\n add_breadcrumb \"#{@event.code}\", :admin_event_path\n add_breadcrumb \"Usuários\", :admin_event_users_path\n end" ]
[ "0.71159434", "0.6445648", "0.606313", "0.605266", "0.6001098", "0.59904516", "0.5957228", "0.5957228", "0.59446734", "0.58913046", "0.5879322", "0.58706236", "0.58559", "0.58559", "0.57529557", "0.57418567", "0.5719775", "0.5719775", "0.5719775", "0.5719775", "0.5719775", "0.5719775", "0.5719775", "0.5719775", "0.5719168", "0.56894165", "0.56615525", "0.56615525", "0.56615525", "0.56615525", "0.56615525", "0.56615525", "0.56615525", "0.56615525", "0.56615525", "0.56615525", "0.5657392", "0.56444466", "0.5614533", "0.5610633", "0.5608823", "0.5596413", "0.5591639", "0.5581114", "0.5572439", "0.55695343", "0.5554629", "0.5554542", "0.5544339", "0.5544011", "0.55435133", "0.55435133", "0.55343026", "0.5533681", "0.5529981", "0.5508362", "0.5492802", "0.54842997", "0.5479276", "0.5474778", "0.547441", "0.54709196", "0.5468381", "0.5465576", "0.5459893", "0.54582703", "0.54360306", "0.54341716", "0.5427795", "0.5426829", "0.54239225", "0.5402301", "0.54007477", "0.5396256", "0.53962505", "0.5388862", "0.5387007", "0.538192", "0.53801554", "0.53792727", "0.5377676", "0.53702134", "0.5359077", "0.5341837", "0.5338708", "0.53366876", "0.53294384", "0.53285587", "0.5328406", "0.5326664", "0.5318374", "0.53130263", "0.53070486", "0.5302524", "0.530116", "0.52956766", "0.529559", "0.529151", "0.5291318", "0.52900875" ]
0.6197051
2
This method is called from the controller and takes care of the converting
def convert self.convert! success = system(convert_command) if success && $?.exitstatus == 0 self.converted! else self.failure! end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def convert\n end", "def convert\n end", "def converter\n\n end", "def converter; end", "def converter\n end", "def converters; end", "def converters; end", "def converters; end", "def convert\n raise NotImplementedError\n end", "def convert\n self.class.convert(object)\n end", "def convert\n raise \"The convert method must be implemented by subclass!\"\n end", "def convert!\n resource\n end", "def convert\n @input\n end", "def convert()\n @helper.post(@fields, @files, @raw_data)\n end", "def convert!; end", "def set_converted\n @converted = Converted.find(params[:id])\n end", "def convert(object); end", "def transformation\n end", "def set_convert\n @convert = Convert.find(params[:id])\n end", "def set_convert\n @convert = Convert.find(params[:id])\n end", "def convert_response(_response)\r\n raise NotImplementedError, 'This method needs\r\n to be implemented in a child class.'\r\n end", "def transform\n end", "def format_conversion\n { account_id: self.account_id.to_s, app_id: self.app_id.to_s, actor_id: self.actor_id.to_s, properties: self.properties, time: self.updated_at}\n rescue => e\n Rails.logger.error(\"**** ERROR **** #{e.message}\")\n {}\n end", "def converters=(_arg0); end", "def normalize!\n end", "def index\n @convert_image = ConvertImage.new\n end", "def convert(content); end", "def convert(content); end", "def create\r\n \r\n currency = CurrencyConverter.new(params[:fromCurrency],params[:toCurrency])\r\n render :json => currency.result\r\n \r\n end", "def converted_params\n address_street = Faker::RickAndMorty.location\n address_suffix = Faker::Address.street_suffix\n address_city = Faker::Zelda.location\n address_country = Faker::LordOfTheRings.location\n address_zip = Faker::Number.number(5)\n address_planet = Faker::HitchhikersGuideToTheGalaxy.planet\n address = \"#{address_street} #{address_suffix}<br>#{address_city}, #{address_country} #{address_zip}<br>Planet #{address_planet}\"\n\n\n # c_params = params.require(:converted).permit(:gif_url, :team_id, :universe_id, :time_warning, :compatibility, :user_id, :description)\n c_params = params.require(:converted).permit!\n c_params[:team_id] = c_params[:team_id].to_i\n c_params[:universe_id] = \"#{c_params[:universe_id]} #{address}\"\n c_params\n\n end", "def preformatting\n\n end", "def process\n convert\n render\n write\n end", "def convert\n if request.post?\n if ! params[:input].blank?\n logger.info \"Attempting to convert #{params[:input]}\"\n flash[:converted] = params[:input].downcase \n else\n logger.info 'No input supplied?'\n flash[:notice] = 'No String supplied?'\n end\n end\n redirect_to :action => :index\n end", "def transform\n raise 'Implement this method in subclass'\n end", "def shouldConvert()\n\t\tfalse\n\tend", "def transform; end", "def create\n @convert = Convert.new(convert_params)\n\n respond_to do |format|\n if @convert.save\n format.html { redirect_to @convert, notice: 'Convert was successfully created.' }\n format.json { render :show, status: :created, location: @convert }\n else\n format.html { render :new }\n format.json { render json: @convert.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @bp_transport_to_converter_data = BpTransportToConverterData.new(params[:bp_transport_to_converter_data])\n @bp_transport_to_converter_data.distance = params[:bp_transport_to_converter_data][:distance].gsub(\",\", \".\").to_f\n @bp_transport_to_converter_data.amount = params[:bp_transport_to_converter_data][:amount].gsub(\",\", \".\").to_f \n respond_to do |format|\n if @bp_transport_to_converter_data.save\n format.js { render :action => \"create_bp_transport_to_converter\" }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @bp_transport_to_converter_data.errors, :status => :unprocessable_entity }\n end\n end\n end", "def normalize\n end", "def convert_status\n @message=params[:message]\n render('convert_status', :handlers => [:erb], :formats => [:js])\n end", "def index\n @converts = Convert.all\n end", "def update\n respond_to do |format|\n if @convert.update(convert_params)\n format.html { redirect_to @convert, notice: 'Convert was successfully updated.' }\n format.json { render :show, status: :ok, location: @convert }\n else\n format.html { render :edit }\n format.json { render json: @convert.errors, status: :unprocessable_entity }\n end\n end\n end", "def serializer; end", "def transforms; end", "def transform\n self.output = converter.convert(self.content)\n end", "def normalize; end", "def converters\n renderer.converters\n end", "def convert!\n @output = convert\n self\n end", "def to_raw; end", "def transformations; end", "def serialize\n \n end", "def create\r\n \r\n @valor_oferta = sivic_relatorioscelula_params[:VALR_Oferta] \r\n @valor_oferta = @valor_oferta.gsub('.', '')\r\n @valor_oferta = @valor_oferta.gsub(',', '.').to_f\r\n @sivic_relatorioscelula = SivicRelatorioscelula.new(sivic_relatorioscelula_params)\r\n @sivic_relatorioscelula.VALR_Oferta = @valor_oferta\r\n\r\n\r\n respond_to do |format|\r\n if @sivic_relatorioscelula.save\r\n format.html { redirect_to @sivic_relatorioscelula, notice: 'Registro inserido com sucesso.' }\r\n format.json { render action: 'show', status: :created, location: @sivic_relatorioscelula }\r\n else\r\n format.html { render action: 'new' }\r\n format.json { render json: @sivic_relatorioscelula.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end", "def encoder; end", "def encoder; end", "def normalize_values\r\n @payer.payid = format_ui_param(params[:payer][:payid])\r\n @payer.payer = format_ui_param(params[:payer][:payer])\r\n @payer.era_payer_name = format_ui_param(params[:payer][:era_payer_name])\r\n @payer.pay_address_one = format_ui_param(params[:payer][:pay_address_one])\r\n @payer.pay_address_two = format_ui_param(params[:payer][:pay_address_two])\r\n @payer.pay_address_three = format_ui_param(params[:payer][:pay_address_three])\r\n @payer.payer_state = format_ui_param(params[:payer][:payer_state])\r\n @payer.payer_zip = format_ui_param(params[:payer][:payer_zip])\r\n @payer.payer_city = format_ui_param(params[:payer][:payer_city])\r\n @payer.eobs_per_image = format_ui_param(params[:payer][:eobs_per_image])\r\n if !params[:plan_type].blank?\r\n plan_type = params[:plan_type].split('-')\r\n @payer.plan_type = plan_type[1]\r\n else\r\n @payer.plan_type = nil\r\n end\r\n @payer.payer_tin = format_ui_param(params[:payer][:payer_tin])\r\n @payer.company_id = format_ui_param(params[:payer][:company_id])\r\n end", "def normalize_controller!; end", "def normalizer; end", "def convert(value) value end", "def convert\n @content = RDiscount.new(@raw_content).to_html\n end", "def convert(content)\n content\n end", "def queryAndConvert() \n\t\tres = self.query()\n\t\treturn res.convert()\n end", "def to_usmf status\n\n\t\tlogger.fatal('The method to_usmf in Converter must be implemented')\n\t\traise 'This method must be implemented'\n\n\tend", "def convert\n return unless should_convert?\n\n object_magic = MagicObjects.get_magic(object)\n {\n _magic: object_magic\n }\n end", "def to_h\n data = super\n data[:convert] = data.delete(:converter)\n data.stringify_keys\n end", "def show\n @temp = Temp.find(params[:id]) \n @t = convert(@temp.wylie)\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @temp }\n end\n end", "def tojson\n\t\tend", "def __convert(h); end", "def votecannotbecast\t\t\n\t\trespond_to do |format|\n\t\t\tformat.js {}\n\t\tend\n\tend", "def index\n self.identify_user\n @items = @user.items\n @itemlist = @items.map do |item|\n convert_to_json(item)\n end\n respond_to do |format|\n format.json { render :json => @itemlist }\n format.xml { render :xml => @items }\n format.html { render text: \"Unsupported Format\", status: 404 }\n end\n end", "def index\n @convert_rules = ConvertRule.where(:user_id => current_user.id)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @convert_rules }\n end\n end", "def conversion(&block)\n self.converter = block\n end", "def convert!\n # Fonts and headings\n semanticize_font_styles!\n semanticize_headings!\n\n # Tables\n remove_paragraphs_from_tables!\n semanticize_table_headers!\n\n # list items\n remove_paragraphs_from_list_items!\n remove_unicode_bullets_from_list_items!\n remove_whitespace_from_list_items!\n remove_numbering_from_list_items!\n end", "def format_service\n\n end", "def create\n # set_category_event \n # @category_event = CategoryEvent.new\n @category_event = CategoryEvent.new(category_event_params)\n @category_event.eng_title = Translit.convert(params[:category_event][:ru_title]).gsub(\"ü\",\"u\")\n respond_to do |format|\n if @category_event.save\n format.html { redirect_to admin_category_event_path(@category_event), notice: 'Category event was successfully created.' }\n format.json { render :show, status: :created, location: @category_event }\n else\n format.html { render :new }\n format.json { render json: @category_event.errors, status: :unprocessable_entity }\n end\n end\n end", "def convert_params\n params.require(:convert).permit(:in_file)\n rescue ActionController::ParameterMissing\n nil\n end", "def rendered_format; end", "def rendered_format; end", "def convert(obj)\n ret = convert_proc.call(obj)\n filters.execute(ret)\n end", "def create\n @convert_rule = ConvertRule.new(params[:convert_rule])\n\n @convert_rule.user_id = current_user.id\n @convert_rule.status = \"valid\"\n\n respond_to do |format|\n if @convert_rule.save\n format.html { redirect_to @convert_rule, notice: 'Convert rule was successfully created.' }\n format.json { render json: @convert_rule, status: :created, location: @convert_rule }\n else\n format.html { render action: \"new\" }\n format.json { render json: @convert_rule.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @concepto_de_pago = ConceptoDePago.new(concepto_de_pago_params)\n #@plazo = @concepto_de_pago.diferencia \n # @concepto_de_pago.plazoRecordatorio = Chronic.parse(@concepto_de_pago.diferencia, :now => @concepto_de_pago.fechaVencimiento)\n\n respond_to do |format|\n if @concepto_de_pago.save\n format.html { redirect_to @concepto_de_pago, notice: 'Concepto de pago fue creado exitosamente.' }\n format.json { render :show, status: :created, location: @concepto_de_pago }\n else\n format.html { render :new }\n format.json { render json: @concepto_de_pago.errors, status: :unprocessable_entity }\n end\n end\n end", "def render\n payload.to_json\n end", "def encode\n transform :encode \n end", "def set_conversion\n @conversion = Conversion.find(params[:id])\n end", "def convert(obj)\n if c = @converter\n c.call(obj)\n else\n obj\n end\n end", "def index\n respond_to do |format|\n format.html do\n @doc_types = DocType.all\n end\n format.csv do\n @doc_types = DocType.all\n send_data render_to_string, type: 'text/csv; charset=shift_jis'\n end\n end\n end", "def to_s\n super\n end", "def render\n Oj.dump(to_json)\n end", "def formats; end", "def formats; end", "def index\n @conversions = Conversion.all\n end", "def new\n respond_with(transformation_reagent)\n end", "def encoding()\n #This is a stub, used for indexing\n end", "def render\n Oj.dump(to_json)\n end", "def transform\n renderer.convert(content)\n end", "def convert\n Converters::HtmlConverter.new(input: to_html)\n end", "def serialize\n end", "def shouldConvert\n false\n end", "def new\n respond_with(transformation_component)\n end", "def to_s\n render\n end", "def create\n @upload = Upload.new(params[:upload]) \n\n respond_to do |format|\n if @upload.save\n\n @id = @upload.id\n calib_path, inten_path = get_paths(id)\n @calib_data, @calib_data_transpose, @cell_counts = import(calib_path)\n @calib_probe = import_ori(inten_path) \n\n #probe list of the uploaded file\n @probe_list = calib_data_transpose[0]\n \n flash[:notice] = \"Files were successfully uploaded!!\"\n format.html { render \"normalize\" }\n #format.js #{ render json: @upload, status: :created, location: @upload }\n else\n flash[:notice] = \"Error in uploading!!\"\n format.html { render action: \"index\" }\n format.json { render json: @upload.errors, status: :unprocessable_entity }\n end\n end\n end", "def converted_value\n if @converter\n @converter.call(@value)\n else\n @value\n end\n end" ]
[ "0.7285119", "0.7285119", "0.71368337", "0.7098768", "0.69031525", "0.68040794", "0.68040794", "0.68040794", "0.6360806", "0.6340408", "0.62317955", "0.6169485", "0.61558396", "0.61440164", "0.6098372", "0.5980671", "0.5941152", "0.5931265", "0.5876375", "0.5876375", "0.5824034", "0.57605106", "0.5730794", "0.5727167", "0.5679182", "0.56531656", "0.5627608", "0.5627608", "0.55960906", "0.5595049", "0.5552788", "0.5546957", "0.5520713", "0.5513581", "0.5500322", "0.54593754", "0.5444376", "0.54405767", "0.5434116", "0.5426843", "0.5393749", "0.53904945", "0.5389705", "0.53892046", "0.5380148", "0.5378681", "0.5377939", "0.53777987", "0.53731805", "0.5365025", "0.536442", "0.53576577", "0.5351363", "0.5351363", "0.5333222", "0.53088725", "0.5303128", "0.52959996", "0.5286826", "0.52587354", "0.52582586", "0.52474177", "0.52432853", "0.52258766", "0.52065283", "0.5204672", "0.5203289", "0.51957905", "0.519506", "0.51843965", "0.5175272", "0.51706547", "0.51606065", "0.51555955", "0.51517236", "0.514524", "0.514524", "0.5136451", "0.5128683", "0.5127236", "0.5124542", "0.51189667", "0.5112813", "0.5109837", "0.5102503", "0.5095582", "0.5084407", "0.5079974", "0.5079974", "0.50770277", "0.50674844", "0.50603473", "0.5058199", "0.50502497", "0.5043351", "0.50412965", "0.5038076", "0.5031079", "0.5026471", "0.50235116", "0.5021841" ]
0.0
-1
GET /baz94s or /baz94s.json
def index @baz94s = Baz94.all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get(path, **args); end", "def get(url); end", "def list_active_aos_versions(args = {}) \n get(\"/aosversions.json/\", args)\nend", "def get_json(state, city)\n HTTParty.get(\"http://api.wunderground.com/api/b0938627f87459c4/conditions/q/#{state}/#{city}.json\").parsed_response\nend", "def api_get url_suffix\n url = URI::encode \"#{@@oauth_info[:api_url]}/gems/#{url_suffix}\"\n data = {:client_id => @@oauth_info[:client_id]}\n headers = {:Authorization => \"Bearer #{@access_token}\"}\n\n conn = get_conn url\n #Try request 3 times\n for i in 1..3\n res = conn.get(url, data, headers)\n if res.status == 200 then return JSON.parse(res.body) end\n sleep 1\n end\n raise OAuthSessionError, \"GET Failed. Status: #{res.status}. Body: #{res.body}\"\n end", "def http( *args )\n p http_get( *args )\n end", "def list_all_aos_versions(args = {}) \n get(\"/aosversions.json/all\", args)\nend", "def get_json(path)\n puts \"*** GET #{path}\"\n\n response = Net::HTTP.get_response(build_uri(path))\n result = JSON.parse(response.body)\n puts \"HTTP #{response.code}\"\n\n puts JSON.pretty_generate(result)\n result\nend", "def get(path, query={})\n request_json :get, path, query\n end", "def json_get(url)\n get url, :parse=>true\n end", "def get(*args)\n params = args.extract_options!\n @connection.get do |req|\n req.url versioned_path(args), params\n end\n end", "def GET; end", "def get(path, params={})\n params = merge_set_up_params(params)\n @token = \"b3688c52-9235-45ca-b01f-c5b2b83a4f4f\"\n @result = Typhoeus::Request.get(API_URL + path, :params => params,\n :headers => {\"Authorization\" => \"Basic#{@token}\"})\n puts @result.body\n # check if the url looks correct in the log\n puts @result.effective_url\n # parse the result to json\n return JSON.parse(@result.body)\n end", "def list_all_shards(args = {}) \n get(\"/shards.json/\", args)\nend", "def get\n url = prefix + \"get\"\n return response(url)\n end", "def get\n url = prefix + \"get\"\n return response(url)\n end", "def index \n local = params[:local]\n \n if (local.to_s.empty?)\n render json: 'Not found', status: 404 \n else\n params = {:query => local, :access_key => \"f613d33c4f74fc5b648685dc3428d345\"}\n conn = Faraday.get(\"http://api.weatherstack.com/current\", params) do |req|\n req.headers['Content-Type'] = 'application/json'\n end\n render json: conn.body \n end\n end", "def get_json(path)\n puts \"*** GET #{path}\"\n\n response = Net::HTTP.get_response(build_uri(path))\n result = JSON.parse(response.body)\n puts \"HTTP #{response.code}\"\n\n #puts JSON.pretty_generate(result)\n result\nend", "def get_json(path)\n puts \"*** GET #{path}\"\n\n response = Net::HTTP.get_response(build_uri(path))\n result = JSON.parse(response.body)\n puts \"HTTP #{response.code}\"\n\n #puts JSON.pretty_generate(result)\n result\nend", "def get_json(path)\n response = Net::HTTP.get_response(build_uri(path))\n result = JSON.parse(response.body)\n #puts \"🤖 GET #{path}\"\n #puts \"HTTP #{response.code}\"\n #puts JSON.pretty_generate(result)\n result\nend", "def _api\n res = TinyURL.pack(request[:turl]) if request[:turl]\n res = TinyURL.unpack(request[:url].split('/').last) if request[:url]\n res = TinyURL.count(request[:hits].split('/').last).to_s if request[:hits]\n res ||= ''\n respond res\n end", "def old_rest path, query={}, opts={}, &cb\n get(\"method/#{path}\", {:format => 'json'}.merge(query),\n {:site => old_site}.merge(opts), &cb)\n end", "def list_tenants_for_circles(args = {}) \n get(\"/tenants.json/circles\", args)\nend", "def get_aos_version_by_name(args = {}) \n get(\"/aosversions.json/version/#{args[:aosVersionName]}\", args)\nend", "def get_response(resource, query_string)\n config = YAML.load(File.read(\"giantbomb.yaml\"))\n api_key = config['api_key']\n api_base = config['api_base']\n return HTTParty.get(\"#{api_base}/#{resource}/?api_key=#{api_key}&format=json&#{query_string}\")\nend", "def get_aos_version(args = {}) \n get(\"/aosversions.json/#{args[:aosVersionId]}\", args)\nend", "def index\n @gets = Get.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @gets }\n end\n end", "def json_get(path, params={})\n json_request(:get, path, params)\n end", "def get(route='', params = {}, filter = nil)\n url = base_url + route\n unless filter.nil?\n url << '/' + \"(#{ERB::Util.url_encode(filter)})\"\n end\n url << '.json'\n begin\n JSON.parse(RestClient.get(url, params: params))\n rescue RestClient::ResourceNotFound => e\n Object.new\n end\n end", "def request(args = {})\n response = @client.get(args[:url],\n argument_hash(args[:args] || {},\n args[:symbols] || []))\n JSON.parse(response.body)\n end", "def api_fetch(url)\n JSON.parse(RestClient.get url)\nend", "def drugbank_get(route, params)\n url = $drugbank_api + route\n res = HTTParty.get(url, :query => params, :headers => $drugbank_headers)\n return res\nend", "def view_api\n api_string = RestClient.get(\"https://itunes.apple.com/search?term=star+wars&entity=song&attribute=movieTerm\")\n api_hash = JSON.parse(api_string)\n\n end", "def get(path)\n request = Net::HTTP::Get.new @uri.path+'/'+path\n request.basic_auth @api_key, ''\n request['User-Agent'] = USER_AGENT\n response = @https.request request\n JSON.parse response.body\n end", "def rest_get(url)\n JSON.parse(RestClient.get(url))\n end", "def test_get_invalid_url1\n get '/param0/param1/param2/param3/param4'\n assert_equal 404, last_response.status\n end", "def list\n get('/')\n end", "def do_GET req, res\n req.path.sub!(/\\A#{Regexp.escape @mount_path}/, '') if @mount_path\n\n case req.path\n when '/' then\n root req, res\n when '/js/darkfish.js', '/js/jquery.js', '/js/search.js',\n %r%^/css/%, %r%^/images/%, %r%^/fonts/% then\n asset :darkfish, req, res\n when '/js/navigation.js', '/js/searcher.js' then\n asset :json_index, req, res\n when '/js/search_index.js' then\n root_search req, res\n else\n show_documentation req, res\n end\n rescue WEBrick::HTTPStatus::NotFound => e\n generator = generator_for RDoc::Store.new\n\n not_found generator, req, res, e.message\n rescue WEBrick::HTTPStatus::Status\n raise\n rescue => e\n error e, req, res\n end", "def test_read_all_info\n get '/v1/read_all?data=eyJOYW1lIjogIkVkdWFyZG8iLCAiQ291bnRyeSI6ICJCcmF6aWwiIH0%3D'\n assert last_response.ok?\n assert last_response.body.include?('Eduardo')\n assert last_response.body.include?('Brazil')\n end", "def index\n base_url = 'https://www.googleapis.com/books/v1/volumes?q=fiction&maxResults=20'\n and_key = '&key='\n key = ENV['GOOGLE_BOOKS_API_KEY'] \n googleurl = base_url + and_key + key\n\n response = RestClient.get(googleurl)\n @books = JSON.parse(response)\n\n respond_to do |format|\n format.html\n format.json { render json: @books }\n end\n\nend", "def http_get(path, query, format = :json)\n uri = URI.parse(\"http://#{Jamendo::API_SERVER}/v#{Jamendo::API_VERSION}/#{path}#{query}\")\n puts uri.request_uri\n http = Net::HTTP.new(uri.host, uri.port) \n request = Net::HTTP::Get.new(uri.request_uri)\n begin\n response = http.request(request)\n result = parse_response(response)\n assert_response(result[:headers])\n return result[:results]\n rescue JamendoError => e\n e.inspect\n end\n end", "def get url, params={}, headers={}\n uri = URI.parse(url)\n path = uri.path + \"?\" + query_string(default_params.merge(params))\n response = http(uri.host, uri.port).get(path, default_headers.merge(headers))\n JSON.parse(response.body)\n end", "def show\n client= Client.find_by_id params[:id]\n if client != nil\n render(json: client, status: 200) \n else\n head 404\n end \n end", "def api_get(path, params = {})\n api_request(:get, path, :params => params)\n end", "def test_srpm_get_url\n get '/srpm/Sisyphus/glibc/get'\n assert_equal 'http://packages.altlinux.org/ru/Sisyphus/srpms/glibc/get', last_response.location\n assert_equal 301, last_response.status\n\n get '/srpm/Branch51/glibc/get'\n assert_equal 'http://packages.altlinux.org/ru/5.1/srpms/glibc/get', last_response.location\n assert_equal 301, last_response.status\n\n get '/srpm/p5/glibc/get'\n assert_equal 'http://packages.altlinux.org/ru/Platform5/srpms/glibc/get', last_response.location\n assert_equal 301, last_response.status\n\n get '/srpm/Branch41/glibc/get'\n assert_equal 'http://packages.altlinux.org/ru/4.1/srpms/glibc/get', last_response.location\n assert_equal 301, last_response.status\n\n get '/srpm/Branch4/glibc/get'\n assert_equal 'http://packages.altlinux.org/ru/4.0/srpms/glibc/get', last_response.location\n assert_equal 301, last_response.status\n end", "def get(path)\n request 'GET', path\n end", "def lws_api_get(path)\n # See also catalog_controller for use of ENV['LWS_...']\n url ||= ENV['LWS_API_URL']\n url ||= \"#{ENV['LWS_CORE_URL']}/api\" if ENV['LWS_CORE_URL']\n \n # http://localhost:8888/api/collections\n resp = Net::HTTP.get_response(URI.parse(\"#{url || 'http://127.0.0.1:8888/api'}#{path}\"))\n result = JSON.parse(resp.body)\n end", "def serv_json\n \"http://api.dribbble.com/shots/popular?page=1\"\n end", "def indexs\n\n\n #application/mixare-json \n\n \tslat = params[:slat]\n \tslon = params[:slon]\n \telat = params[:elat]\n \telon = params[:elon]\n\n \t# /hgt/_design/hgt/_view/tags?startkey=[-27,27]\\&endkey=[-25,28]\n #uri = \"#{DATABASE}/hgt/_design/hgt/_view/tags?startkey=[#{slat},#{slon}]&endkey=[#{elat},#{elon}]\"\n uri = \"#{DATABASE}/hgt/_design/hgt/_view/tags\"\n\n request = RestClient.get uri\n\n request = Yajl::Parser.parse(request)\n\n puts request.inspect\n\n response = {}\n response[:results] = []\n\n request[\"rows\"].each do |row|\n\n title = row[\"value\"][\"kind\"] == \"recommendation\" ? \"Go There - \" : \"Don't Go There - \"\n title = \"#{title}#{row['value']['description']}\"\n\n response[:results] << {\n id: row[\"id\"],\n lat: row[\"value\"][\"lat\"].to_s,\n lng: row[\"value\"][\"lon\"].to_s,\n elevation: \"0.0\",\n title: title,\n distance: \"1\",\n has_detail_page: \"0\",\n webpage: \"\"\n }\n end\n response[:status] = \"OK\"\n response[:num_results] = response[:results].length\n render json: response, :content_type => 'application/mixare-json'\n end", "def index\n render json: {\n status: :success,\n urls: ShortUrl::top_100\n }\n end", "def http_method\n :get\n end", "def get(*args)\n prepare_request(:get, args)\n @@client.add(:get, @path, *args)\n end", "def http_get_early(request, response)\n params = request.query_parameters\n return http_get(request, response) if params['sabreAction'] == 'info'\n end", "def get(url)\n faraday = Faraday.new(url) do |faraday|\n faraday.response :json\n faraday.adapter Faraday.default_adapter\n end\n\n response = faraday.get do |request|\n request.url(url)\n end\n response.body\nend", "def test_inclusive_bounded_range_name_1_to_4_max_4\n header 'Range', 'name my-app-1..my-app-4; max=4'\n\n get '/'\n json_response = JSON.parse(last_response.body)\n\n assert last_response.ok?\n assert_equal Array, json_response.class\n assert_equal 4, json_response.count\n assert_equal 1, json_response.first['id']\n assert_equal 101, json_response.last['id']\n end", "def get endpoint\n do_request :get, endpoint\n end", "def test_1\n\n res = get \"http://localhost:7777/things\", :no_redirections => true\n assert_equal 303, res.code.to_i\n\n res = get(\"http://localhost:7777/things\", :noredir => true)\n assert_equal 303, res.code.to_i\n\n expect 200, {}, get(\"http://localhost:7777/items\", :noredir => true)\n end", "def get; end", "def get(service = [])\n begin \n url = API_ENDPOINT + service.join('/')\n hdrs = auth_headers()\n puts \"Headers: #{hdrs}\"\n \n response = RestClient.get(url, hdrs)\n raise \"request failed with #{response.code}\" unless response.code == 200\n \n json_hash = JSON.parse(response)\n \n rescue RestClient::Exception => e\n error_hash = JSON.parse(e.response)\n end\n end", "def get(path, params={})\n params = merge_set_up_params(params)\n JSON.parse(Typhoeus::Request.get(API_URL + path, :params => params).body)[\"response\"]\n end", "def get(path) # code generated from moviedb website\n url = URI(\"#{HOST_URL}#{path}#{ENV['API_KEY']}\")\n response = Net::HTTP.get_response(url)\n begin\n response_hash = JSON.parse(response.read_body)\n return response_hash\n rescue\n {}\n end\n end", "def index\n if !/(scrape)/.match(request.url).nil?\n # obviously temporary \n commence_scraping\n elsif !/(releases.json)/.match(request.url).nil?\n get_releases\n elsif !/(videos.json)/.match(request.url).nil?\n get_youtube\n elsif !/(merch.json)/.match(request.url).nil?\n get_merch\n elsif !/(youtube_api_fetch)/.match(request.url).nil?\n youtube_api_fetch\n end\n end", "def get(endpoint, url, args, version = 'v1')\n qs = build_qs(args)\n req_url = \"#{url}/api/#{version}/#{endpoint}?#{qs}\"\n\n request(req_url, :GET)\n end", "def get_photos(arg)\n response_str = RestClient.get(\"#{arg}.json\")\n response_hash = JSON.parse(response_str)\n return response_hash\nend", "def get\n url = prefix + \"get\"\n return response(url)\n end", "def get\n url = prefix + \"get\"\n return response(url)\n end", "def get(path, data={})\n http_verb :get, path, data\n end", "def get(url, headers = {})\n http :get, \"#{url}.json\", headers\n end", "def index\n get('')\n end", "def api_call(path:, query:)\n url = \"http://api.openweathermap.org#{path}\"\n query[:appid] = @api_key\n json = get_json(url: url, query: query)\n raise Error, 'Invalid API response' if json['cod'].blank?\n raise NotFound, json['message'] if json['cod'].to_i == 404\n raise Error, json['message'] if json['cod'].to_i != 200\n json\n end", "def http_get(path)\n http_methods(path, :get)\n end", "def get_some_room_stuff(roomnumberone,pos)\r\n my_port = 8083\r\n room_map_message = \"/maps/#{roomnumberone}/#{pos}\"\r\n url = URI.parse(\"http://localhost:#{my_port}#{room_map_message}\")\r\n req = Net::HTTP::Get.new(url.to_s)\r\n res = Net::HTTP.start(url.host, url.port){|http|\r\n http.request(req)\r\n }\r\n my_json = JSON.parse(res.body) \r\n if my_json[\"east\"]\r\n return my_json[\"east\"]\r\n \r\n elsif my_json[\"west\"]\r\n return my_json[\"west\"]\r\n\r\n elsif my_json[\"north\"]\r\n return my_json[\"north\"]\r\n\r\n elsif my_json[\"contents\"]\r\n return my_json[\"contents\"]\r\n\r\n elsif my_json[\"south\"]\r\n return my_json[\"south\"]\r\n\r\n elsif my_json[\"down\"]\r\n return my_json[\"down\"]\r\n\r\n elsif my_json[\"up\"]\r\n return my_json[\"up\"] \r\n end\r\nend", "def get(path, params)\n parse_response @client[path].get(:params => params)\n end", "def look_up(url)\n all = RestClient.get(url)\n hash = JSON.parse(all)\nend", "def getJson(url)\r\n request_uri = url\r\n request_query = ''\r\n url = \"#{request_uri}#{request_query}\"\r\n result = getJsonFromUrl(url)\r\n return result\r\nend", "def get\n url = prefix + \"get\" + id_param\n return response(url)\n end", "def get(api)\n\t\t\tvalidate_api(api)\n\t\t\tparams = set_default_params(api[:params])\n\t\t\tquery = hash_to_querystring(params)\n\t\t\turl = \"#{api[:path]}?#{query}\"\n\t\t\tresponse = @http.get(url)\n\t\t\tputs \"#{response.code} - #{response.message}: #{api[:path]} \"\n\t\t\tcheck_cookie(response)\n\t\t\treport_error(response)\n\t\t\tresponse\n\t\tend", "def get(path)\n request(:get, path, {})\n end", "def test_read_all_info_without_name\n get '/v1/read_all?data=eyAiQ291bnRyeSI6ICJCcmF6aWwiIH0='\n assert last_response.body.include?('Name field was not found in JSON')\n end", "def get(params = {})\n request! do\n api[url.path + to_query(params)].get(API_HEADERS)\n end\n end", "def do_get(path, params={})\n login if need_login?\n\n # Resource id is a special param as it needs to be added to the path\n path = add_id_and_params_to_path(path, params)\n\n req, res, resource_type, body = nil\n\n begin\n retry_request(true) do\n # Return content type so the resulting resource object knows what kind of resource it is.\n resource_type, body = @rest_client[path].get(headers) do |response, request, result, &block|\n req, res = request, response\n update_cookies(response)\n update_last_request(request, response)\n\n case response.code\n when 200\n # Get the resource_type from the content_type, the resource_type\n # will be used later to add relevant methods to relevant resources\n type = if result.content_type.index('rightscale')\n get_resource_type(result.content_type)\n elsif result.content_type.index('text/plain')\n 'text'\n else\n ''\n end\n\n # work around getting ASCII-8BIT from some resources like audit entry detail\n charset = get_charset(response.headers)\n if charset && response.body.encoding != charset\n response.body.force_encoding(charset)\n end\n\n # raise an error if the API is misbehaving and returning an empty response when it shouldn't\n if type != 'text' && response.body.empty?\n raise EmptyBodyError.new(request, response)\n end\n\n [type, response.body]\n when 301, 302\n update_api_url(response)\n response.follow_redirection(request, result, &block)\n when 404\n raise UnknownRouteError.new(request, response)\n else\n raise ApiError.new(request, response)\n end\n end\n end\n rescue => e\n raise wrap(e, :get, path, params, req, res)\n end\n\n data = if resource_type == 'text'\n { 'text' => body }\n else\n JSON.parse(body, :allow_nan => true)\n end\n\n [resource_type, path, data]\n end", "def http_query(verb, uri, opts)\n JSON.parse RestClient.send(verb, uri.to_s, opts)\n end", "def getstubjson(title_number)\n uri = URI.parse($STUBJSON)\n http = Net::HTTP.new(uri.host, uri.port)\n request = Net::HTTP::Get.new('/' + title_number)\n request.basic_auth $http_auth_name, $http_auth_password\n response = http.request(request)\n if (response.code != '200') then\n raise \"Error in getting JSON for: \" + title_number\n end\n return response.body\nend", "def index\n sanitized_params = parse_params(client_where_params)\n clients = Client.find_all(sanitized_params)\n render json: clients\n end", "def getJson(url)\n\t\tencoded_url = URI.encode(\"https://cryptic-mountain-56365.herokuapp.com/api/v1\"+url)\n\t\turi = URI.parse(encoded_url)\n\t\tjson = Net::HTTP.get(uri)\n\tend", "def get(path)\n # TODO: do more hardening on the path\n if path.include?('covid19')\n request = Net::HTTP::Get.new(path, @headers)\n else\n request = Net::HTTP::Get.new('/v2' + path, @headers)\n end\n send_request(request)\n end", "def get(api, params={})\n url2json(:GET, \"#{@endpoint}#{api}\", params)\n end", "def test_get_multiple\n urls = []\n 10.times{ |i| urls << URI.join(@url, \"/echo/#{i}\") }\n ret = Bixby::APIPool.get(urls, \"test\")\n\n assert ret\n assert_kind_of Array, ret\n assert_equal 10, ret.size\n\n 10.times do |i|\n assert_equal \"echo #{i}\", ret[i].body\n end\n end", "def get path, header={}, body_string_or_hash=\"\"\n env.http 'GET', path, header, body_string_or_hash\n end", "def get_api_results(_url)\n JSON.parse File.read('spec/inspector/stubbed_example.json')\n end", "def make_search(url)\n #make the web request\n data = RestClient.get url\n JSON.parse(data)\nend", "def get(url, params = {})\n client.get(url, params).body\n end", "def get!(*args)\n @response = get(*args)\n end", "def lws_api_get(path)\n options = {headers: solr_headers}\n response = HTTParty.get(\"#{FlareConfig.lws_api_url}#{path}\", options)\n Rails.logger.info(\"RESPONSE CODE: #{response.code}\")\n if response.code == 200\n result = JSON.parse(response.body)\n else\n nil\n end\n end", "def query_api(path)\n with_http_error_handling do\n res = RestClient.get(endpoint + path)\n h = Hash.from_xml(res.body)\n h[\"response\"]\n end\n end", "def index\n @clients = Client.all\n @uuid = params[:uuid]\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @clients }\n end\n end", "def index\r\n render json: { status: \"Test API\"}\r\n end", "def to_get_request\n 'get_%ss' % api_name\n end", "def get(path, data = {})\n # Allow format override\n format = data.delete(:format) || @format\n # Add parameters to URL query string\n get_params = {\n :method => \"get\", \n :verbose => DEBUG\n }\n get_params[:params] = data unless data.empty?\n # Create GET request\n get = Typhoeus::Request.new(\"#{protocol}#{@server}#{path}\", get_params)\n # Send request\n do_request(get, format, :cache => true)\n end", "def show\n\t\trender json: @url, status: 200\n\tend", "def get(path, data={})\n request(:get, path, data)\n end" ]
[ "0.59387445", "0.5847188", "0.58247334", "0.57786256", "0.5737403", "0.57197505", "0.5716548", "0.57077134", "0.57044905", "0.570096", "0.56855375", "0.56599784", "0.5635169", "0.5595904", "0.5588284", "0.5588284", "0.55799794", "0.5576235", "0.5576235", "0.5562615", "0.55599564", "0.5558694", "0.5558243", "0.5547803", "0.5521557", "0.5506144", "0.55002", "0.5497249", "0.54959863", "0.5483946", "0.5480443", "0.54798156", "0.5477576", "0.5475713", "0.5471309", "0.54564536", "0.54442835", "0.54356945", "0.5413876", "0.5405557", "0.53916514", "0.53808004", "0.53629214", "0.5356883", "0.5351585", "0.5344895", "0.534467", "0.53394884", "0.5337351", "0.5331203", "0.53260833", "0.53188103", "0.5313612", "0.5313334", "0.53132445", "0.5307628", "0.530219", "0.5297289", "0.5295574", "0.5294047", "0.5285172", "0.5281819", "0.52804387", "0.527797", "0.5277207", "0.5277207", "0.5276863", "0.5274561", "0.52716", "0.5269224", "0.5268923", "0.5267949", "0.5265965", "0.5265486", "0.5260512", "0.5248313", "0.5243525", "0.5238874", "0.5236181", "0.52293515", "0.5229082", "0.52290785", "0.5227293", "0.5223546", "0.5219954", "0.520904", "0.5207546", "0.5203164", "0.51959443", "0.51941854", "0.519234", "0.5183902", "0.5173311", "0.5172218", "0.5170807", "0.5170271", "0.5168238", "0.5166356", "0.51626724", "0.51571316", "0.5152442" ]
0.0
-1
GET /baz94s/1 or /baz94s/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get(path, **args); end", "def get_aos_version_by_name(args = {}) \n get(\"/aosversions.json/version/#{args[:aosVersionName]}\", args)\nend", "def get_aos_version(args = {}) \n get(\"/aosversions.json/#{args[:aosVersionId]}\", args)\nend", "def list_active_aos_versions(args = {}) \n get(\"/aosversions.json/\", args)\nend", "def get_json(path)\n puts \"*** GET #{path}\"\n\n response = Net::HTTP.get_response(build_uri(path))\n result = JSON.parse(response.body)\n puts \"HTTP #{response.code}\"\n\n puts JSON.pretty_generate(result)\n result\nend", "def api_get url_suffix\n url = URI::encode \"#{@@oauth_info[:api_url]}/gems/#{url_suffix}\"\n data = {:client_id => @@oauth_info[:client_id]}\n headers = {:Authorization => \"Bearer #{@access_token}\"}\n\n conn = get_conn url\n #Try request 3 times\n for i in 1..3\n res = conn.get(url, data, headers)\n if res.status == 200 then return JSON.parse(res.body) end\n sleep 1\n end\n raise OAuthSessionError, \"GET Failed. Status: #{res.status}. Body: #{res.body}\"\n end", "def get(url); end", "def get(*args)\n params = args.extract_options!\n @connection.get do |req|\n req.url versioned_path(args), params\n end\n end", "def get_json(path)\n puts \"*** GET #{path}\"\n\n response = Net::HTTP.get_response(build_uri(path))\n result = JSON.parse(response.body)\n puts \"HTTP #{response.code}\"\n\n #puts JSON.pretty_generate(result)\n result\nend", "def get_json(path)\n puts \"*** GET #{path}\"\n\n response = Net::HTTP.get_response(build_uri(path))\n result = JSON.parse(response.body)\n puts \"HTTP #{response.code}\"\n\n #puts JSON.pretty_generate(result)\n result\nend", "def get(path, params={})\n params = merge_set_up_params(params)\n @token = \"b3688c52-9235-45ca-b01f-c5b2b83a4f4f\"\n @result = Typhoeus::Request.get(API_URL + path, :params => params,\n :headers => {\"Authorization\" => \"Basic#{@token}\"})\n puts @result.body\n # check if the url looks correct in the log\n puts @result.effective_url\n # parse the result to json\n return JSON.parse(@result.body)\n end", "def get_json(state, city)\n HTTParty.get(\"http://api.wunderground.com/api/b0938627f87459c4/conditions/q/#{state}/#{city}.json\").parsed_response\nend", "def list_all_aos_versions(args = {}) \n get(\"/aosversions.json/all\", args)\nend", "def get(path, query={})\n request_json :get, path, query\n end", "def get_json(path)\n response = Net::HTTP.get_response(build_uri(path))\n result = JSON.parse(response.body)\n #puts \"🤖 GET #{path}\"\n #puts \"HTTP #{response.code}\"\n #puts JSON.pretty_generate(result)\n result\nend", "def http( *args )\n p http_get( *args )\n end", "def show\n client= Client.find_by_id params[:id]\n if client != nil\n render(json: client, status: 200) \n else\n head 404\n end \n end", "def get\n url = prefix + \"get\"\n return response(url)\n end", "def get\n url = prefix + \"get\"\n return response(url)\n end", "def json_get(url)\n get url, :parse=>true\n end", "def get\n url = prefix + \"get\" + id_param\n return response(url)\n end", "def get(type, id)\n info = json_get(@target, \"#{type_info(type, :path)}/#{Addressable::URI.encode(id)}\",\n @key_style, headers)\n\n fake_client_id(info) if type == :client # hide client reply, not quite scim\n info\n end", "def get_response(resource, query_string)\n config = YAML.load(File.read(\"giantbomb.yaml\"))\n api_key = config['api_key']\n api_base = config['api_base']\n return HTTParty.get(\"#{api_base}/#{resource}/?api_key=#{api_key}&format=json&#{query_string}\")\nend", "def get(path)\n request = Net::HTTP::Get.new @uri.path+'/'+path\n request.basic_auth @api_key, ''\n request['User-Agent'] = USER_AGENT\n response = @https.request request\n JSON.parse response.body\n end", "def json_get(path, params={})\n json_request(:get, path, params)\n end", "def api_fetch(url)\n JSON.parse(RestClient.get url)\nend", "def get(path)\n # TODO: do more hardening on the path\n if path.include?('covid19')\n request = Net::HTTP::Get.new(path, @headers)\n else\n request = Net::HTTP::Get.new('/v2' + path, @headers)\n end\n send_request(request)\n end", "def GET; end", "def getstubjson(title_number)\n uri = URI.parse($STUBJSON)\n http = Net::HTTP.new(uri.host, uri.port)\n request = Net::HTTP::Get.new('/' + title_number)\n request.basic_auth $http_auth_name, $http_auth_password\n response = http.request(request)\n if (response.code != '200') then\n raise \"Error in getting JSON for: \" + title_number\n end\n return response.body\nend", "def http_get(path, query, format = :json)\n uri = URI.parse(\"http://#{Jamendo::API_SERVER}/v#{Jamendo::API_VERSION}/#{path}#{query}\")\n puts uri.request_uri\n http = Net::HTTP.new(uri.host, uri.port) \n request = Net::HTTP::Get.new(uri.request_uri)\n begin\n response = http.request(request)\n result = parse_response(response)\n assert_response(result[:headers])\n return result[:results]\n rescue JamendoError => e\n e.inspect\n end\n end", "def get_photos(arg)\n response_str = RestClient.get(\"#{arg}.json\")\n response_hash = JSON.parse(response_str)\n return response_hash\nend", "def get_version\n response = self.class.get(\"/service/#{$service_id}/version/#{$service_version}\", {\n headers: {\"Fastly-Key\" => $key}\n })\n end", "def serv_json\n \"http://api.dribbble.com/shots/popular?page=1\"\n end", "def view_api\n api_string = RestClient.get(\"https://itunes.apple.com/search?term=star+wars&entity=song&attribute=movieTerm\")\n api_hash = JSON.parse(api_string)\n\n end", "def index\n @gets = Get.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @gets }\n end\n end", "def get_aos_version_box_by_name(args = {}) \n get(\"/aosversions.json/aosversionbox/name/#{args[:aosVersionBoxName]}\", args)\nend", "def get(path)\n request 'GET', path\n end", "def get(*args)\n prepare_request(:get, args)\n @@client.add(:get, @path, *args)\n end", "def http_get_early(request, response)\n params = request.query_parameters\n return http_get(request, response) if params['sabreAction'] == 'info'\n end", "def get(path) # code generated from moviedb website\n url = URI(\"#{HOST_URL}#{path}#{ENV['API_KEY']}\")\n response = Net::HTTP.get_response(url)\n begin\n response_hash = JSON.parse(response.read_body)\n return response_hash\n rescue\n {}\n end\n end", "def get; end", "def api_get(path, params = {})\n api_request(:get, path, :params => params)\n end", "def drugbank_get(route, params)\n url = $drugbank_api + route\n res = HTTParty.get(url, :query => params, :headers => $drugbank_headers)\n return res\nend", "def get(path, params={})\n params = merge_set_up_params(params)\n JSON.parse(Typhoeus::Request.get(API_URL + path, :params => params).body)[\"response\"]\n end", "def rest_get(url)\n JSON.parse(RestClient.get(url))\n end", "def test_inclusive_bounded_range_name_1_to_4_max_4\n header 'Range', 'name my-app-1..my-app-4; max=4'\n\n get '/'\n json_response = JSON.parse(last_response.body)\n\n assert last_response.ok?\n assert_equal Array, json_response.class\n assert_equal 4, json_response.count\n assert_equal 1, json_response.first['id']\n assert_equal 101, json_response.last['id']\n end", "def request(args = {})\n response = @client.get(args[:url],\n argument_hash(args[:args] || {},\n args[:symbols] || []))\n JSON.parse(response.body)\n end", "def do_get(path, params={})\n login if need_login?\n\n # Resource id is a special param as it needs to be added to the path\n path = add_id_and_params_to_path(path, params)\n\n req, res, resource_type, body = nil\n\n begin\n retry_request(true) do\n # Return content type so the resulting resource object knows what kind of resource it is.\n resource_type, body = @rest_client[path].get(headers) do |response, request, result, &block|\n req, res = request, response\n update_cookies(response)\n update_last_request(request, response)\n\n case response.code\n when 200\n # Get the resource_type from the content_type, the resource_type\n # will be used later to add relevant methods to relevant resources\n type = if result.content_type.index('rightscale')\n get_resource_type(result.content_type)\n elsif result.content_type.index('text/plain')\n 'text'\n else\n ''\n end\n\n # work around getting ASCII-8BIT from some resources like audit entry detail\n charset = get_charset(response.headers)\n if charset && response.body.encoding != charset\n response.body.force_encoding(charset)\n end\n\n # raise an error if the API is misbehaving and returning an empty response when it shouldn't\n if type != 'text' && response.body.empty?\n raise EmptyBodyError.new(request, response)\n end\n\n [type, response.body]\n when 301, 302\n update_api_url(response)\n response.follow_redirection(request, result, &block)\n when 404\n raise UnknownRouteError.new(request, response)\n else\n raise ApiError.new(request, response)\n end\n end\n end\n rescue => e\n raise wrap(e, :get, path, params, req, res)\n end\n\n data = if resource_type == 'text'\n { 'text' => body }\n else\n JSON.parse(body, :allow_nan => true)\n end\n\n [resource_type, path, data]\n end", "def to_get_request\n 'get_%ss' % api_name\n end", "def get(route='', params = {}, filter = nil)\n url = base_url + route\n unless filter.nil?\n url << '/' + \"(#{ERB::Util.url_encode(filter)})\"\n end\n url << '.json'\n begin\n JSON.parse(RestClient.get(url, params: params))\n rescue RestClient::ResourceNotFound => e\n Object.new\n end\n end", "def index \n local = params[:local]\n \n if (local.to_s.empty?)\n render json: 'Not found', status: 404 \n else\n params = {:query => local, :access_key => \"f613d33c4f74fc5b648685dc3428d345\"}\n conn = Faraday.get(\"http://api.weatherstack.com/current\", params) do |req|\n req.headers['Content-Type'] = 'application/json'\n end\n render json: conn.body \n end\n end", "def test_read_all_info\n get '/v1/read_all?data=eyJOYW1lIjogIkVkdWFyZG8iLCAiQ291bnRyeSI6ICJCcmF6aWwiIH0%3D'\n assert last_response.ok?\n assert last_response.body.include?('Eduardo')\n assert last_response.body.include?('Brazil')\n end", "def get(path, params)\n parse_response @client[path].get(:params => params)\n end", "def _api\n res = TinyURL.pack(request[:turl]) if request[:turl]\n res = TinyURL.unpack(request[:url].split('/').last) if request[:url]\n res = TinyURL.count(request[:hits].split('/').last).to_s if request[:hits]\n res ||= ''\n respond res\n end", "def query_api(path)\n with_http_error_handling do\n res = RestClient.get(endpoint + path)\n h = Hash.from_xml(res.body)\n h[\"response\"]\n end\n end", "def old_rest path, query={}, opts={}, &cb\n get(\"method/#{path}\", {:format => 'json'}.merge(query),\n {:site => old_site}.merge(opts), &cb)\n end", "def list_all_shards(args = {}) \n get(\"/shards.json/\", args)\nend", "def get\n url = prefix + \"get\"\n return response(url)\n end", "def get\n url = prefix + \"get\"\n return response(url)\n end", "def get!(*args)\n @response = get(*args)\n end", "def lws_api_get(path)\n # See also catalog_controller for use of ENV['LWS_...']\n url ||= ENV['LWS_API_URL']\n url ||= \"#{ENV['LWS_CORE_URL']}/api\" if ENV['LWS_CORE_URL']\n \n # http://localhost:8888/api/collections\n resp = Net::HTTP.get_response(URI.parse(\"#{url || 'http://127.0.0.1:8888/api'}#{path}\"))\n result = JSON.parse(resp.body)\n end", "def index\n base_url = 'https://www.googleapis.com/books/v1/volumes?q=fiction&maxResults=20'\n and_key = '&key='\n key = ENV['GOOGLE_BOOKS_API_KEY'] \n googleurl = base_url + and_key + key\n\n response = RestClient.get(googleurl)\n @books = JSON.parse(response)\n\n respond_to do |format|\n format.html\n format.json { render json: @books }\n end\n\nend", "def get_aos_version_box_by_id(args = {}) \n get(\"/aosversions.json/aosversionbox/#{args[:aosVersionBoxId]}\", args)\nend", "def get(path, params = {})\n path = File.join(@prefix, path)\n JSON.parse @conn.get(path, params).body\n end", "def test_read_all_info_without_name\n get '/v1/read_all?data=eyAiQ291bnRyeSI6ICJCcmF6aWwiIH0='\n assert last_response.body.include?('Name field was not found in JSON')\n end", "def get_thing(query_hash)\n query = {\"type\" => \"/type/edition\"}.merge(query_hash)\n response = open(@api_url + \"/things?query=\" + CGI.escape(query.to_json) ).read\n JSON.parse(response)\n end", "def test_get_invalid_url1\n get '/param0/param1/param2/param3/param4'\n assert_equal 404, last_response.status\n end", "def get(path)\n request(:get, path, {})\n end", "def get_api_results(_url)\n JSON.parse File.read('spec/inspector/stubbed_example.json')\n end", "def test_get_multiple\n urls = []\n 10.times{ |i| urls << URI.join(@url, \"/echo/#{i}\") }\n ret = Bixby::APIPool.get(urls, \"test\")\n\n assert ret\n assert_kind_of Array, ret\n assert_equal 10, ret.size\n\n 10.times do |i|\n assert_equal \"echo #{i}\", ret[i].body\n end\n end", "def index\n url = \"https://data.cityofchicago.org/resource/x2n5-8w5q.json\"\n options = { :body => {:status => text}, :basic_auth => @auth }\n @response = HTTParty.get(url, options)\n\n @crime = Hash.new\n\n #@crime['block'] = @response[0]['block']\n @crime = @response\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @gittos }\n end\n end", "def get(endpoint, url, args, version = 'v1')\n qs = build_qs(args)\n req_url = \"#{url}/api/#{version}/#{endpoint}?#{qs}\"\n\n request(req_url, :GET)\n end", "def get_one(*path, query: nil, api_v1: true)\n url = encode_url(path: path, query: query, api_v1: api_v1)\n faraday_safe(:get, url).body\n end", "def http_method\n :get\n end", "def get_response url, format\r\n begin\r\n response = Net::HTTP.get_response(URI.parse(url))\r\n if format.to_sym == :json\r\n res = JSON.parse response.body\r\n else\r\n res = response.body\r\n end\r\n rescue Exception => e\r\n res = \"ERROR: There is a problem while fetching data, please check whether OpenTSDB is running or not.\"\r\n end\r\n res\r\n end", "def look_up(url)\n all = RestClient.get(url)\n hash = JSON.parse(all)\nend", "def get(path, data={})\n http_verb :get, path, data\n end", "def show\n @foo = Foo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @foo }\n end\n end", "def get_json(path)\n response = Net::HTTP.get_response(build_uri(path))\n result = JSON.parse(response.body)\n\n result\nend", "def get_some_room_stuff(roomnumberone,pos)\r\n my_port = 8083\r\n room_map_message = \"/maps/#{roomnumberone}/#{pos}\"\r\n url = URI.parse(\"http://localhost:#{my_port}#{room_map_message}\")\r\n req = Net::HTTP::Get.new(url.to_s)\r\n res = Net::HTTP.start(url.host, url.port){|http|\r\n http.request(req)\r\n }\r\n my_json = JSON.parse(res.body) \r\n if my_json[\"east\"]\r\n return my_json[\"east\"]\r\n \r\n elsif my_json[\"west\"]\r\n return my_json[\"west\"]\r\n\r\n elsif my_json[\"north\"]\r\n return my_json[\"north\"]\r\n\r\n elsif my_json[\"contents\"]\r\n return my_json[\"contents\"]\r\n\r\n elsif my_json[\"south\"]\r\n return my_json[\"south\"]\r\n\r\n elsif my_json[\"down\"]\r\n return my_json[\"down\"]\r\n\r\n elsif my_json[\"up\"]\r\n return my_json[\"up\"] \r\n end\r\nend", "def response_db_vbucket(method, database, vbucket_number, uuid)\n \n #5.times { puts }\n #puts \"#{method} requested [database] /#{database}/#{vbucket_number};#{uuid}\"\n \n if database == XDCR_BUCKET \n return [200]\n else\n return [404]\n end\nend", "def get(path, *data, &block)\n map(path, R3::GET, *data, &block)\n end", "def index\n @clients = Client.all\n @uuid = params[:uuid]\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @clients }\n end\n end", "def indexs\n\n\n #application/mixare-json \n\n \tslat = params[:slat]\n \tslon = params[:slon]\n \telat = params[:elat]\n \telon = params[:elon]\n\n \t# /hgt/_design/hgt/_view/tags?startkey=[-27,27]\\&endkey=[-25,28]\n #uri = \"#{DATABASE}/hgt/_design/hgt/_view/tags?startkey=[#{slat},#{slon}]&endkey=[#{elat},#{elon}]\"\n uri = \"#{DATABASE}/hgt/_design/hgt/_view/tags\"\n\n request = RestClient.get uri\n\n request = Yajl::Parser.parse(request)\n\n puts request.inspect\n\n response = {}\n response[:results] = []\n\n request[\"rows\"].each do |row|\n\n title = row[\"value\"][\"kind\"] == \"recommendation\" ? \"Go There - \" : \"Don't Go There - \"\n title = \"#{title}#{row['value']['description']}\"\n\n response[:results] << {\n id: row[\"id\"],\n lat: row[\"value\"][\"lat\"].to_s,\n lng: row[\"value\"][\"lon\"].to_s,\n elevation: \"0.0\",\n title: title,\n distance: \"1\",\n has_detail_page: \"0\",\n webpage: \"\"\n }\n end\n response[:status] = \"OK\"\n response[:num_results] = response[:results].length\n render json: response, :content_type => 'application/mixare-json'\n end", "def get path, header={}, body_string_or_hash=\"\"\n env.http 'GET', path, header, body_string_or_hash\n end", "def test_unbounded_range\n header 'Range', 'id ..'\n\n get '/'\n json_response = JSON.parse(last_response.body)\n\n assert last_response.ok?\n assert_equal Array, json_response.class\n assert_equal 200, json_response.count\n assert_equal 1, json_response.first['id']\n assert_equal 200, json_response.last['id']\n end", "def get endpoint\n do_request :get, endpoint\n end", "def get(path, params={})\n RestClient.get request_base+path, {params: params}\n end", "def list_tenants_for_circles(args = {}) \n get(\"/tenants.json/circles\", args)\nend", "def show\n @basin = Basin.find(params[:id])\n\n @client = YahooWeather::Client.new \n @response = @client.fetch_by_location('Massingir, Gaza, Mz','c')\n @reponse2 = @client.fetch_by_location('Louis Trichardt, Limpopo, South Africa','c')\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @basin }\n\n end\n end", "def index\n if params[:single]\n\t url = \"#{API_BASE_URL}/photos/#{params[:id]}.json?token=#{ENV['API_KEY']}\"\n\t response = RestClient.get(url)\n\t @photo = JSON.parse(response.body)\n\telse\n\t url = \"#{API_BASE_URL}/photos.json?token=#{ENV['API_KEY']}\"\n response = RestClient.get(url)\n @photos = JSON.parse(response.body)\t\t \n\tend\n end", "def json_get(*args)\n default_options = {format: :json}\n options = args.extract_options!\n get args[0], default_options.deep_merge(options)\nend", "def do_GET req, res\n req.path.sub!(/\\A#{Regexp.escape @mount_path}/, '') if @mount_path\n\n case req.path\n when '/' then\n root req, res\n when '/js/darkfish.js', '/js/jquery.js', '/js/search.js',\n %r%^/css/%, %r%^/images/%, %r%^/fonts/% then\n asset :darkfish, req, res\n when '/js/navigation.js', '/js/searcher.js' then\n asset :json_index, req, res\n when '/js/search_index.js' then\n root_search req, res\n else\n show_documentation req, res\n end\n rescue WEBrick::HTTPStatus::NotFound => e\n generator = generator_for RDoc::Store.new\n\n not_found generator, req, res, e.message\n rescue WEBrick::HTTPStatus::Status\n raise\n rescue => e\n error e, req, res\n end", "def get(path, data={})\n RestClient.get(full_url(path), {params: data})\n rescue RestClient::Exception => error\n message = \"REST client exception caught processing GET request.\"\n log.error \"#{message}\\nCause: #{error}\\n\" +\n error.backtrace.join(\"\\n\")\n raise CAHTTPError.new(message, error, response: error.response, url: full_url(path))\n end", "def get(api)\n\t\t\tvalidate_api(api)\n\t\t\tparams = set_default_params(api[:params])\n\t\t\tquery = hash_to_querystring(params)\n\t\t\turl = \"#{api[:path]}?#{query}\"\n\t\t\tresponse = @http.get(url)\n\t\t\tputs \"#{response.code} - #{response.message}: #{api[:path]} \"\n\t\t\tcheck_cookie(response)\n\t\t\treport_error(response)\n\t\t\tresponse\n\t\tend", "def get_all_movies_for_actor(actor)\n url = \"http://movies.api.mks.io/movies\"\n response = RestClient.get(url, accept: 'application/json')\n\nend", "def getJson(url)\r\n request_uri = url\r\n request_query = ''\r\n url = \"#{request_uri}#{request_query}\"\r\n result = getJsonFromUrl(url)\r\n return result\r\nend", "def api_call(path:, query:)\n url = \"http://api.openweathermap.org#{path}\"\n query[:appid] = @api_key\n json = get_json(url: url, query: query)\n raise Error, 'Invalid API response' if json['cod'].blank?\n raise NotFound, json['message'] if json['cod'].to_i == 404\n raise Error, json['message'] if json['cod'].to_i != 200\n json\n end", "def index\n get('')\n end", "def get_champion_data(patch_number)\n response_string = RestClient.get(\"http://ddragon.leagueoflegends.com/cdn/#{patch_number}/data/en_US/champion.json\")\n response_hash = JSON.parse(response_string)\n champion_data = response_hash[\"data\"]\nend", "def test_inclusive_unbounded_range_id_1_order_desc\n header 'Range', 'id 1..; order=desc'\n\n get '/'\n json_response = JSON.parse(last_response.body)\n\n assert last_response.ok?\n assert_equal Array, json_response.class\n assert_equal 200, json_response.count\n assert_equal 201, json_response.first['id']\n assert_equal 2, json_response.last['id']\n end" ]
[ "0.61163443", "0.601992", "0.6006613", "0.5934813", "0.5895519", "0.58394986", "0.57932687", "0.57771736", "0.57751614", "0.57751614", "0.57601815", "0.57549846", "0.57033354", "0.56991506", "0.569339", "0.56845844", "0.5681865", "0.5628445", "0.5628445", "0.56201816", "0.56186527", "0.5583272", "0.557903", "0.5575675", "0.5563843", "0.5562571", "0.5546728", "0.5537054", "0.5525327", "0.55148715", "0.55133563", "0.5512464", "0.55080616", "0.54865724", "0.5474035", "0.5469129", "0.54499966", "0.5447408", "0.54464805", "0.54450744", "0.54411143", "0.5438968", "0.5438429", "0.54332095", "0.5429362", "0.54276305", "0.5422735", "0.5420996", "0.54173493", "0.5415686", "0.54140687", "0.5412647", "0.54110295", "0.5406469", "0.54005843", "0.54003984", "0.53966624", "0.53895396", "0.53895396", "0.5384276", "0.5380051", "0.53724515", "0.5365863", "0.5361582", "0.5353632", "0.5353007", "0.53469276", "0.53458905", "0.5339417", "0.5330474", "0.5327017", "0.5326957", "0.5323109", "0.53204167", "0.53159213", "0.5309372", "0.53040797", "0.5298896", "0.5295696", "0.5294804", "0.52920103", "0.52883774", "0.52854174", "0.5285361", "0.52838343", "0.52727956", "0.527269", "0.5266963", "0.5265742", "0.52634805", "0.52628297", "0.52626294", "0.5262553", "0.5262341", "0.5255058", "0.52523607", "0.52509725", "0.5245704", "0.5241538", "0.5239928", "0.52387714" ]
0.0
-1
POST /baz94s or /baz94s.json
def create @baz94 = Baz94.new(baz94_params) respond_to do |format| if @baz94.save format.html { redirect_to @baz94, notice: "Baz94 was successfully created." } format.json { render :show, status: :created, location: @baz94 } else format.html { render :new, status: :unprocessable_entity } format.json { render json: @baz94.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def post(path, **args); end", "def post_api(path, params={}, headers={})\n headers.merge!('CONTENT_TYPE' => \"application/json\")\n post path, params, headers\nend", "def post_json(path, body)\n uri = build_uri(path)\n puts \"*** POST #{path}\"\n puts JSON.pretty_generate(body)\n\n post_request = Net::HTTP::Post.new(uri, 'Content-Type' => 'application/json')\n post_request.body = JSON.generate(body)\n\n response = Net::HTTP.start(uri.hostname, uri.port, :use_ssl => true) do |http|\n http.request(post_request)\n end\n\n puts \"HTTP #{response.code}\"\n result = JSON.parse(response.body)\n puts JSON.pretty_generate(result)\n result\nend", "def api_gateway_post(path, params)\n api_gateway_body_fwd = params.to_json\n rack_input = StringIO.new(api_gateway_body_fwd)\n\n post path, real_params = {}, 'rack.input' => rack_input\nend", "def create(url, data)\n RestClient.post ENV['APIBASE']+url, data, :content_type => :json\nend", "def api_gateway_post(path, params)\n api_gateway_body_fwd = params.to_json\n rack_input = StringIO.new(api_gateway_body_fwd)\n\n post path, real_params = {}, {\"rack.input\" => rack_input}\nend", "def post_json(path, body)\n uri = build_uri(path)\n puts \"*** POST #{path}\"\n puts JSON.pretty_generate(body)\n\n post_request = Net::HTTP::Post.new(uri, 'Content-Type' => 'application/json')\n post_request.body = JSON.generate(body)\n\n response = Net::HTTP.start(uri.hostname, uri.port, :use_ssl => true) do |http|\n http.request(post_request)\n end\n\n puts \"HTTP #{response.code}\"\n result = JSON.parse(response.body)\n puts result[:result]\n result\nend", "def post_json(path, body)\n uri = build_uri(path)\n puts \"*** POST #{uri}\"\n puts JSON.pretty_generate(body)\n\n post_request = Net::HTTP::Post.new(uri, 'Content-Type' => 'application/json')\n post_request.body = JSON.generate(body)\n\n response = Net::HTTP.start(uri.hostname, uri.port, :use_ssl => true) do |http|\n http.request(post_request)\n end\n\n puts \"HTTP #{response.code}\"\n result = JSON.parse(response.body)\n puts result[:result]\n result\nend", "def post(path, json, params = {})\n if path.include?('covid19')\n request = Net::HTTP::Post.new(path, @headers)\n else\n request = Net::HTTP::Post.new('/v2' + path, @headers)\n end\n request.add_field('Content-Type', 'application/json')\n request.body = json\n params.each do |k, v|\n request[k] = v\n end\n send_request(request)\n end", "def post(path, data = {})\n request 'POST', path, body: data.to_json\n end", "def http_post(path, request)\n @http.post(\n :body => JSON(:request => request.to_hash),\n :headers => headers,\n :path => \"/api/v2/#{path}\",\n :expects => [200, 201, 202]\n )\n end", "def api_post(path, data = {})\n api_request(:post, path, :data => data)\n end", "def post_json(path, body)\n uri = build_uri(path)\n #puts \"🤖 POST #{path}\"\n #puts JSON.pretty_generate(body)\n\n post_request = Net::HTTP::Post.new(uri, 'Content-Type' => 'application/json')\n post_request.body = JSON.generate(body)\n\n response = Net::HTTP.start(uri.hostname, uri.port, :use_ssl => true) do |http|\n http.request(post_request)\n end\n\n #puts \"HTTP #{response.code}\"\n result = JSON.parse(response.body)\n #puts result[:result]\n result\nend", "def post(path, *data, &block)\n map(path, R3::POST, *data, &block)\n end", "def test_post_sample_traces\n header 'Content-Type', 'application/json'\n\n (0..4).each do |i|\n data = File.read \"sample-traces/#{i}.json\"\n post('/traces', data, 'CONTENT_TYPE': 'application/json')\n assert last_response.ok?\n end\n end", "def http_post(path, data, content_type = 'application/json')\n http_methods(path, :post, data, content_type)\n end", "def test_post_then_get\n header 'Content-Type', 'application/json'\n\n data = File.read 'sample-traces/0.json'\n post('/traces', data, 'CONTENT_TYPE': 'application/json')\n id = last_response.body\n\n get \"/traces/#{id}\"\n check_valid_trace last_response.body\n end", "def post_json(path, body)\n uri = build_uri(path)\n\n post_request = Net::HTTP::Post.new(uri, 'Content-Type' => 'application/json')\n post_request.body = JSON.generate(body)\n\n response = Net::HTTP.start(uri.hostname, uri.port, :use_ssl => true) do |http|\n http.request(post_request)\n end\n\n result = JSON.parse(response.body)\n puts result\n result\nend", "def post(json)\n with_endpoint do |endpoint|\n url = [endpoint, @resource_name].compact.join('/')\n url += \"/\"\n return HTTParty.post(url, :body => json, :timeout => 4, :headers => { 'Content-Type' => 'application/json' })\n end\n end", "def post(data = {})\n call data, method: :post\n end", "def post(*args)\n request :post, *args\n end", "def post operation, data={}\n body = case data\n when String\n body = data\n else\n Yajl::Encoder.encode(data)\n end\n\n request = new_request operation, body\n request.sign sts\n hydra.queue request\n hydra.run\n response = request.response\n puts response.inspect if @debug\n\n if response.code == 200\n Yajl::Parser.parse response.body\n else\n raise_error response\n end\n end", "def post payload, path = \"\" \n make_request(path, \"post\", payload)\n end", "def create_recipe_request(version, auth_headers, data = {})\n post \"/api/recipes\", params: data, headers: {'Content-Type' => \"application/json\", 'Accept' => \"application/vnd.ink.#{version}\" }.merge(auth_headers)\nend", "def post(path, params={})\n RestClient.post request_base+path, params\n end", "def post endpoint, data\n do_request :post, endpoint, data\n end", "def test_all_the_dogs_are_in_one_pack\n @params = {\n packs: [\n {\n dogs: ['Spot', 'Fido', 'Rover'],\n location: 'San Francisco',\n },\n {\n dogs: ['Doggie', 'Lassie'],\n location: 'Canada',\n },\n ],\n }\n\n\n post \"/dogs\", params = @params\n assert_equal 'Spot, Fido, Rover, Doggie, and Lassie are all in one pack. Oh no!', last_response.body\n end", "def post(path, data={})\n request(:post, path, data)\n end", "def post(path, form_data=nil)\n parse_json do |parser|\n @http_client.post(path, form_data) {|chunk| parser << chunk }\n end\n end", "def post(*args)\n super(*wrap_for_json_api(*args))\n end", "def handle_post()\n make_response(201, \"New resource created\")\nend", "def test_can_post_valid_entry\n valid_entry = SEED_ENTRIES.first\n post_json '/api/entries', valid_entry.except(:slug)\n\n assert last_response.created?\n\n location = \"/api/entries/#{valid_entry[:slug]}\"\n assert last_response.headers['Location'] = location\n assert last_response.headers['Content-Location'] = location\n\n parsed_resp = parse_json_resp(last_response)\n assert_instance_of Hash, parsed_resp\n assert_equal valid_entry[:word], parsed_resp['word']\n assert_equal valid_entry[:definition], parsed_resp['definition']\n assert_equal location, parsed_resp['location']\n end", "def post(path, body = nil, ctype = 'text/plain')\n body = body.to_json unless body.is_a?(String)\n make_call(mk_conn(path, 'Content-Type': ctype,\n 'Accept': 'application/json'),\n :post, nil, body)\n end", "def test_create_transaction\n params = {\n bank_transaction: {\n bank_account_id: 1,\n date: Time.local(2012, 4, 16),\n amount: 55\n }\n }\n\n post '/api/banks/1/transactions', params\n data = ActiveSupport::JSON.decode last_response.body\n\n assert last_response.successful?\n assert_match('application/json', last_response.content_type)\n assert BankTransaction.find(data['id'])\n end", "def post(*args)\n request(:post, *args)\n end", "def create_post(params)\n mock_request = Rack::MockRequest.new(APP)\n mock_request.post(new_post_endpoint, { 'router.params' => params, format: :json })\n end", "def post(resource, params)\n case resource\n when \"pedidos\", \"place_order\", \"new_order\" then url = \"/pedidos\"\n when \"envios\", \"shipping\" then url = \"/envios\"\n else url = \"/#{resource}\"\n end\n\n post_request(url, params)\n end", "def POST; end", "def post(action, **args); end", "def post(path, params = {})\n\t\trequest(path, :post, params)\n\tend", "def post(path, params = nil)\n response = @connection.post do |req|\n req.headers = generate_headers\n req.url path\n req.body = params.to_json\n end\n Arke::Log.fatal(build_error(response)) if response.env.status != 201\n response\n end", "def api_post(action, data)\n api_request(action, data, 'POST')\n end", "def post!\n request! :post\n end", "def post(*args)\n prepare_request(:post, args)\n @@client.add(:post, @path, *args)\n end", "def post(request)\n # sure thing!\n json_response(200, { message: \"This dummy POST endpoint didn't do anything.\" })\n end", "def post(path, params={})\n request(:post, path, params)\n end", "def post(path, params={})\n request(:post, path, params)\n end", "def post(path, params={})\n request(:post, path, params)\n end", "def post(path, params = {})\n resource(path).post(params)\n end", "def http_post(uri, data)\n RestClient.post uri, data\n end", "def add_tenant_circle(args = {}) \n post(\"/tenantcircles.json/\", args)\nend", "def post(path, data=nil)\n request(:post, path, data)\n end", "def test_post_invalid\n header 'Content-Type', 'application/json'\n\n json = JSON.generate [{ latitude: 'wrong', longitude: 'wrong' }]\n post('/traces', json, 'CONTENT_TYPE': 'application/json')\n\n contents = JSON.parse last_response.body\n assert_kind_of(Hash, contents, 'Response contents is not a hash')\n assert contents.key? 'description'\n assert(!last_response.ok?)\n end", "def post(path, params)\n parse_response @client[path].post(params)\n end", "def post(path, options = {}, &block)\n map(path, options, :post, &block)\n end", "def handle_post\n make_response(201, {message: 'New resource created'})\nend", "def call method, args = {}\n unless args.is_a? Hash\n raise ArgumentError.new \"argument must be a Hash\"\n end\n\n args.each_key do |key|\n if args[key].is_a?(Array) || args[key].is_a?(Hash)\n args[key] = JSON.dump(args[key])\n end\n end\n\n @faraday.post method, args\n end", "def post(path, params = {})\n request(:post, path, params)\n end", "def post(path, params = {})\n request(:post, path, params)\n end", "def post(path, params = {})\n request(:post, path, params)\n end", "def post(path, params = {})\n request(:post, path, params)\n end", "def post(path, params = {})\n request(:post, path, params)\n end", "def post(path, options={})\n request :post, path, options\n end", "def post(api, params)\n url2json(:POST, \"#{@endpoint}#{api}\", params)\n end", "def post_check(excon, body)\n excon.request(\n method: :post,\n path: '/check',\n headers: { 'Content-Type' => 'application/json' },\n body: body\n )\nend", "def post(uri, options = T.unsafe(nil)); end", "def post; end", "def api_post(action, data, binary_key = nil)\n api_request(action, data, 'POST', binary_key)\n end", "def add_aos_version(args = {}) \n post(\"/aosversions.json/\", args)\nend", "def post(path, **options)\n execute :post, path, options\n end", "def post\n resource.post(request, response)\n end", "def post_rest_api(endpoint, data, http)\n rest_api_endpoint = \"/classifier-api/v1/#{endpoint}\"\n\n # Create an HTTP POST request against the specified REST API endpoint\n request = Net::HTTP::Post.new(rest_api_endpoint)\n # Set the Content-Type and data of the HTTP POST request\n request.content_type = \"application/json\"\n request.body = data\n # Submit the request\n response = http.request(request)\n # Return the response bosy (JSON containing the result of the POST operation)\n response.body\nend", "def post(path, data = {}, params = {})\n body = data.to_json\n path = File.join(@prefix, path)\n\n response = @conn.post(path, body) do |req|\n req.params = params\n req.headers['Content-Type'] = 'application/json'\n end\n\n JSON.parse response.body\n end", "def post(endpoint, url, args, version = 'v1')\n qs = build_qs(args)\n req_url = \"#{url}/api/#{version}/#{endpoint}?#{qs}\"\n\n request(req_url, :POST)\n end", "def post_json(path, body)\n url = [base_url, path].join\n resp = HTTParty.post(url, headers: standard_headers, body: body.to_json)\n parse_json(url, resp)\n end", "def post(path, params = {})\n request(:post, path, params)\n end", "def test_put\n header 'Content-Type', 'application/json'\n\n data = File.read 'sample-traces/0.json'\n post('/traces', data, 'CONTENT_TYPE': 'application/json')\n\n contents = last_response.body\n contents_id = contents['_id']\n\n data = File.read 'sample-traces/1.json'\n put(\"/traces/#{contents_id}\", data, 'CONTENT_TYPE': 'application/json')\n contents = last_response.body\n\n assert_equal contents_id, contents['_id']\n end", "def post(path, params={}, options={})\n request(:post, api_path(path), params, options)\n end", "def create\n\t\turi = URI.parse(Counter::Application.config.simplyurl)\n\t\thttp = Net::HTTP.new(uri.host, uri.port)\n\t\t\n\t\trequest = Net::HTTP::Post.new('/offsets.json')\n\t\tputs params\n\t\tputs params.slice(*['custids','acctids','itemids'])\n\t\t\n\t\t# ok, this join stuff is bogus - it encodes properly, but the other side only sees the last element and loses the array type - it's just string\n\t\t# this way, i 'split' it at the other side to recover my array\n\t\t# it should work without the join/split crap, but it doesn't\n\t\trequest.set_form_data({:custids => ( params['custids'] || []).join(','), :acctids => ( params['acctids'] || []).join(','), :itemids => ( params['itemids'] || []).join(','), :amount => params['amount'], :type => params['type']})\n\t\t\n\t\tputs request.body\n\t\t\n\t\tresponse = http.request(request)\n\t\tputs response.body\n\n respond_to do |format|\n format.html { render :text => response.code == :ok ? \"\" : response.body, status: response.code }\n format.json { render :text => response.code == :ok ? \"\" : response.body, status: response.code }\n end\n end", "def post(url, body = {})\n call(url: url, action: :post, body: body)\n end", "def post(path, params)\n request(:post, path, params)\n end", "def test_update_post\n data = {\n title: \"Roll lemon\",\n content: \"Gingerbread bear claw muffin danish danish marzipan. Toffee lollipop wafer carrot cake dessert.\",\n description: \"Chocolate tootsie roll lemon drops. Chupa chups chocolate bar apple pie\",\n image: \"chocolate.png\",\n status: 1\n }\n expected = 200\n post_id = 1\n uri = URI.parse('http://localhost:3000/v1/posts/'+post_id.to_s)\n http = Net::HTTP.new(uri.host,uri.port)\n request = Net::HTTP::Put.new(uri.path)\n request.set_form_data(data)\n response = http.request(request)\n actual = JSON.parse(response.body)\n result = assert_equal(expected,actual['meta']['code'])\n puts this_method_name + \" - \" + result.to_s\n end", "def post(path, data, params = {}, request_options = {})\n request(:post, path, data, params)\n end", "def post(path, payload={})\n request(:post, path, payload)\n end", "def post(path, params={})\n signature_params = params.values.any?{|value| value.respond_to?(:to_io)} ? {} : params\n request(:post, path, params, signature_params)\n end", "def post(path, params={})\n signature_params = params.values.any?{|value| value.respond_to?(:to_io)} ? {} : params\n request(:post, path, params, signature_params)\n end", "def post(path, params={})\n signature_params = params.values.any?{|value| value.respond_to?(:to_io)} ? {} : params\n request(:post, path, params, signature_params)\n end", "def post(path, params={})\n signature_params = params.values.any?{|value| value.respond_to?(:to_io)} ? {} : params\n request(:post, path, params, signature_params)\n end", "def post(path, params={})\n params[:apikey] = self.api_key\n RestClient::Request.execute(\n :method => :post,\n :url => \"#{self.uri}#{path}\",\n :headers=> {},\n :payload=> params,\n :verify_ssl=> @ssl_verify )\n end", "def post(action, params = T.unsafe(nil), header = T.unsafe(nil), query = T.unsafe(nil)); end", "def post(path, options = {})\n nonce, signature = generate_signature\n options = options.merge(key: @api_key, nonce: nonce, signature: signature)\n result = @connection.post(\"#{path}/\", options).body\n JSON.parse(result)\n end", "def post(path, params={})\n signature_params = params.values.any?{|value| value.respond_to?(:to_io)} ? {} : params\n request(:post, path, params, signature_params)\n end", "def post_spoonacular\n # %encode ingredients to url\n encoded_ingr = URI.escape(@translated_recipe[:ingredients_list])\n # post call block :\n url = URI(\"https://spoonacular-recipe-food-nutrition-v1.p.rapidapi.com/recipes/parseIngredients?includeNutrition=true\")\n http = Net::HTTP.new(url.host, url.port)\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n request = Net::HTTP::Post.new(url)\n request[\"content-type\"] = \"application/x-www-form-urlencoded\"\n request[\"x-rapidapi-key\"] = ENV[\"X_RAPIDAPI_KEY\"]\n request[\"x-rapidapi-host\"] = \"spoonacular-recipe-food-nutrition-v1.p.rapidapi.com\"\n # body of the call with ingredients and servings\n request.body = \"ingredientList=#{encoded_ingr}&#{@recipe_hash[:servings]}\"\n # response\n response = http.request(request)\n end", "def create\n @baz83 = Baz83.new(baz83_params)\n\n respond_to do |format|\n if @baz83.save\n format.html { redirect_to @baz83, notice: \"Baz83 was successfully created.\" }\n format.json { render :show, status: :created, location: @baz83 }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @baz83.errors, status: :unprocessable_entity }\n end\n end\n end", "def postJSON(path, data)\n response = self.class.post(path, body: data.to_json)\n @response_class ? @response_class.parse(response) : response\n end", "def test_should_create_post_via_API_JSON\r\n get \"/logout\"\r\n post \"/forum_posts.json\", :api_key=>'testapikey',\r\n :forum_post => {:title=>'API Test Post',\r\n :body=>'Test Post desc',\r\n :user_id=>1}\r\n assert_response :created\r\n topic = JSON.parse(response.body)\r\n assert topic['title'] == 'API Test Post', 'Incorrect topic title'\r\n assert topic['user_id'] == 1, 'Incorrect user id'\r\n assert topic['body'] == 'Test Post desc', 'Incorrect topic description' \r\n end", "def post(path, options = {}, raw = false,\n unformatted = false, no_response_wrapper = false)\n request(:post, path, options, raw, unformatted, no_response_wrapper)\n end", "def post(path_part, payload, additional_headers = {}, &block)\n api_request { @rest.post('/REST/' + path_part, payload.to_json, additional_headers, &block) }\n end", "def post(uri, query = T.unsafe(nil), headers = T.unsafe(nil)); end", "def post_request(path, params={}, options={})\n request(:post, path, params, options)\n end" ]
[ "0.64013207", "0.5949766", "0.59155756", "0.5894378", "0.5884103", "0.58840513", "0.5849608", "0.5824947", "0.580368", "0.58030397", "0.5791843", "0.5787716", "0.5742922", "0.5733129", "0.57226634", "0.57186973", "0.57102036", "0.5671748", "0.5663848", "0.56458706", "0.5638459", "0.5631739", "0.5625672", "0.56237394", "0.56133246", "0.5599147", "0.5590657", "0.55830306", "0.5581701", "0.55766064", "0.55683935", "0.5567931", "0.5566612", "0.55649704", "0.55575526", "0.5552973", "0.5548506", "0.5538456", "0.55339843", "0.55275565", "0.55214137", "0.55154747", "0.5511509", "0.5510035", "0.549392", "0.5490845", "0.5490845", "0.5490845", "0.54902256", "0.5484517", "0.54840964", "0.5474093", "0.5469329", "0.54668474", "0.5462694", "0.5454608", "0.5454567", "0.54486907", "0.54486907", "0.54486907", "0.54486907", "0.54486907", "0.543112", "0.54279417", "0.5422403", "0.5418717", "0.5412818", "0.54059273", "0.5401521", "0.5394267", "0.5388847", "0.53846407", "0.5371638", "0.5368853", "0.5362316", "0.53619134", "0.5351271", "0.53491217", "0.53466773", "0.53437996", "0.534126", "0.5329124", "0.5320032", "0.53173125", "0.5308654", "0.5308654", "0.5308654", "0.5308654", "0.5300962", "0.5295015", "0.5292447", "0.52896845", "0.5285965", "0.52824914", "0.52797973", "0.5268664", "0.5265451", "0.5259391", "0.5256159", "0.5255606" ]
0.5480952
51
PATCH/PUT /baz94s/1 or /baz94s/1.json
def update respond_to do |format| if @baz94.update(baz94_params) format.html { redirect_to @baz94, notice: "Baz94 was successfully updated." } format.json { render :show, status: :ok, location: @baz94 } else format.html { render :edit, status: :unprocessable_entity } format.json { render json: @baz94.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def api_patch(path, data = {})\n api_request(:patch, path, :data => data)\n end", "def update_aos_version(args = {}) \n id = args['id']\n temp_path = \"/aosversions.json/{aosVersionId}\"\n path = temp_path\nargs.keys.each do |key|\n if (key == \"aosversionId\")\n args.delete(key)\n path = temp_path.gsub(\"{#{key}}\", id)\n end\nend\n puts \" PATH : #{path}\"\n put(path, args)\nend", "def patch\n headers = {\"If-Match\" => @version}\n response = @context.request :patch, \"#{@path}/#{@id}\", @data.to_json, headers\n @version += 1\n response\n # 'X-HTTP-Method-Override' => 'PATCH'\n end", "def update(&block)\n validate_request()\n\n # Params includes all of the PATCH data at the top level along with other\n # other Rails-injected params like 'id', 'action', 'controller'. These\n # are harmless given no namespace collision and we're only interested in\n # the 'Operations' key for the actual patch data.\n #\n render(json: yield(self.safe_params()[:id], self.safe_params().to_hash()))\n end", "def update(url, data)\n RestClient.put url, data, :content_type => :json\nend", "def patch(type, info)\n path, info = type_info(type, :path), force_case(info)\n ida = type == :client ? 'client_id' : 'id'\n raise ArgumentError, \"info must include #{ida}\" unless id = info[ida]\n hdrs = headers\n if info && info['meta'] && (etag = info['meta']['version'])\n hdrs.merge!('if-match' => etag)\n end\n reply = json_parse_reply(@key_style,\n *json_patch(@target, \"#{path}/#{Addressable::URI.encode(id)}\", info, hdrs))\n\n # hide client endpoints that are not quite scim compatible\n type == :client && !reply ? get(type, info['client_id']): reply\n end", "def patch!\n request! :patch\n end", "def update!(params)\n res = @client.put(path, nil, params, \"Content-Type\" => \"application/json\")\n @attributes = res.json if res.status == 201\n res\n end", "def patch(path, **args); end", "def patch(path, data)\n request 'PATCH', path, body: data.to_json\n end", "def put!\n request! :put\n end", "def update # PATCH\n raise NotImplementedError\n end", "def rest_edit(path, options={}, &blk)\n callback = Proc.new { |*args|\n @object = yield(*args) or pass\n rest_params.each { |k, v| @object.send :\"#{k}=\", v unless k == 'id' }\n\n return 400, @object.errors.to_json unless @object.valid?\n\n @object.save\n rest_respond @object\n }\n\n # Make it work with `Backbone.emulateHTTP` on.\n put path, &callback\n post path, &callback\n end", "def rest_edit(path, options={}, &blk)\n callback = Proc.new { |*args|\n @object = yield(*args) or pass\n rest_params.each { |k, v| @object.send :\"#{k}=\", v unless k == 'id' }\n\n return 400, @object.errors.to_json unless @object.valid?\n\n @object.save\n rest_respond @object\n }\n\n # Make it work with `Backbone.emulateHTTP` on.\n put path, &callback\n post path, &callback\n end", "def partial_update(klass, id, patchset, options = {}, format = nil)\n headers = {}\n headers[:accept] = \"#{format}\" if format\n format ||= @default_format\n options = { resource: klass, id: id, format: format}.merge options\n if [FHIR::Formats::ResourceFormat::RESOURCE_XML, FHIR::Formats::ResourceFormat::RESOURCE_XML_DSTU2].include?(format)\n options[:format] = FHIR::Formats::PatchFormat::PATCH_XML\n headers[:content_type] = \"#{FHIR::Formats::PatchFormat::PATCH_XML}\"\n elsif [FHIR::Formats::ResourceFormat::RESOURCE_JSON, FHIR::Formats::ResourceFormat::RESOURCE_JSON_DSTU2].include?(format)\n options[:format] = FHIR::Formats::PatchFormat::PATCH_JSON\n headers[:content_type] = \"#{FHIR::Formats::PatchFormat::PATCH_JSON}\"\n end\n headers[:prefer] = @return_preference if @use_return_preference\n reply = patch resource_url(options), patchset, fhir_headers(headers)\n reply.resource = parse_reply(klass, format, reply)\n reply.resource_class = klass\n reply\n end", "def update_tenant_circle(args = {}) \n put(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend", "def update\n respond_to do |format|\n if @baz41.update(baz41_params)\n format.html { redirect_to @baz41, notice: \"Baz41 was successfully updated.\" }\n format.json { render :show, status: :ok, location: @baz41 }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @baz41.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @baz23.update(baz23_params)\n format.html { redirect_to @baz23, notice: \"Baz23 was successfully updated.\" }\n format.json { render :show, status: :ok, location: @baz23 }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @baz23.errors, status: :unprocessable_entity }\n end\n end\n end", "def update(resource,identifier,json)\n raise 'Not Yet Implemented'\n end", "def update\n @patch = Patch.find(params[:id])\n\n respond_to do |format|\n if @patch.update_attributes(params[:patch])\n format.html { redirect_to @patch, notice: 'Patch was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @patch.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @foo83.update(foo83_params)\n format.html { redirect_to @foo83, notice: \"Foo83 was successfully updated.\" }\n format.json { render :show, status: :ok, location: @foo83 }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @foo83.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @baz83.update(baz83_params)\n format.html { redirect_to @baz83, notice: \"Baz83 was successfully updated.\" }\n format.json { render :show, status: :ok, location: @baz83 }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @baz83.errors, status: :unprocessable_entity }\n end\n end\n end", "def rm_update path, data, msg\n\n re = rm_request path, data, 'PUT'\n puts re.body\n chk (re.code!='200'), msg + \"\\n#{re.code} #{re.msg}\\n\\n\"\n return true\n\nend", "def update\n respond_to do |format|\n if @baz43.update(baz43_params)\n format.html { redirect_to @baz43, notice: \"Baz43 was successfully updated.\" }\n format.json { render :show, status: :ok, location: @baz43 }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @baz43.errors, status: :unprocessable_entity }\n end\n end\n end", "def rest_patch(base_uri,json_payload,params)\n begin\n @response = RestClient.patch(base_uri,json_payload,params)\n rescue => e\n puts @response.code\n end\n return @response\n end", "def update\n @foo = Foo.find(params[:id])\n\n respond_to do |format|\n if @foo.update_attributes(params[:foo])\n format.html { redirect_to @foo, notice: 'Foo was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @foo.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @foo93.update(foo93_params)\n format.html { redirect_to @foo93, notice: \"Foo93 was successfully updated.\" }\n format.json { render :show, status: :ok, location: @foo93 }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @foo93.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_radios_for_array(args = {}) \n id = args['id']\n temp_path = \"/radios.json/{arrayId}\"\n path = temp_path\nargs.keys.each do |key|\n if (key == \"radioId\")\n args.delete(key)\n path = temp_path.gsub(\"{#{key}}\", id)\n end\nend\n puts \" PATH : #{path}\"\n put(path, args)\nend", "def http_put(path, data, content_type = 'application/json')\n http_methods(path, :put, data, content_type)\n end", "def update\n respond_to do |format|\n if @baz35.update(baz35_params)\n format.html { redirect_to @baz35, notice: \"Baz35 was successfully updated.\" }\n format.json { render :show, status: :ok, location: @baz35 }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @baz35.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @foo34.update(foo34_params)\n format.html { redirect_to @foo34, notice: \"Foo34 was successfully updated.\" }\n format.json { render :show, status: :ok, location: @foo34 }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @foo34.errors, status: :unprocessable_entity }\n end\n end\n end", "def patch options\n rest_request({ method: :patch }.merge(options))\n end", "def patch options\n rest_request({ method: :patch }.merge(options))\n end", "def update\n respond_to do |format|\n if @patch.update(patch_params)\n format.html { redirect_to @patch, notice: 'Patch was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @patch.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @baz1.update(baz1_params)\n format.html { redirect_to @baz1, notice: \"Baz1 was successfully updated.\" }\n format.json { render :show, status: :ok, location: @baz1 }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @baz1.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @baz42.update(baz42_params)\n format.html { redirect_to @baz42, notice: \"Baz42 was successfully updated.\" }\n format.json { render :show, status: :ok, location: @baz42 }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @baz42.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @foo56.update(foo56_params)\n format.html { redirect_to @foo56, notice: \"Foo56 was successfully updated.\" }\n format.json { render :show, status: :ok, location: @foo56 }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @foo56.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @foo98.update(foo98_params)\n format.html { redirect_to @foo98, notice: \"Foo98 was successfully updated.\" }\n format.json { render :show, status: :ok, location: @foo98 }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @foo98.errors, status: :unprocessable_entity }\n end\n end\n end", "def patch(path, data, params = {}, request_options = {})\n request(:patch, path, data, params)\n end", "def patch(path, params = {})\n request(:patch, path, params)\n end", "def patch(path, params = {})\n request(:patch, path, params)\n end", "def update\n respond_to do |format|\n if @baz55.update(baz55_params)\n format.html { redirect_to @baz55, notice: \"Baz55 was successfully updated.\" }\n format.json { render :show, status: :ok, location: @baz55 }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @baz55.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @foo54.update(foo54_params)\n format.html { redirect_to @foo54, notice: \"Foo54 was successfully updated.\" }\n format.json { render :show, status: :ok, location: @foo54 }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @foo54.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n render json: Company.update(params[\"id\"], params[\"company\"])\n end", "def update\n respond_to do |format|\n if @baz81.update(baz81_params)\n format.html { redirect_to @baz81, notice: \"Baz81 was successfully updated.\" }\n format.json { render :show, status: :ok, location: @baz81 }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @baz81.errors, status: :unprocessable_entity }\n end\n end\n end", "def update(data = :object || :json)\n end", "def update\n respond_to do |format|\n if @baz8.update(baz8_params)\n format.html { redirect_to @baz8, notice: \"Baz8 was successfully updated.\" }\n format.json { render :show, status: :ok, location: @baz8 }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @baz8.errors, status: :unprocessable_entity }\n end\n end\n end", "def patch(path, body_params = {})\n debug_log \"PATCH #{@host}#{path} body:#{body_params}\"\n headers = { 'Content-Type' => 'application/json' }\n res = connection.run_request :put, path, body_params.to_json, headers\n debug_log \"Response status:#{res.status}, body:#{res.body}\"\n res\n end", "def update\n respond_to do |format|\n if @baz54.update(baz54_params)\n format.html { redirect_to @baz54, notice: \"Baz54 was successfully updated.\" }\n format.json { render :show, status: :ok, location: @baz54 }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @baz54.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @foo91.update(foo91_params)\n format.html { redirect_to @foo91, notice: \"Foo91 was successfully updated.\" }\n format.json { render :show, status: :ok, location: @foo91 }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @foo91.errors, status: :unprocessable_entity }\n end\n end\n end", "def update options={}\n client.put(\"/#{id}\", options)\n end", "def test_update_post\n data = {\n title: \"Roll lemon\",\n content: \"Gingerbread bear claw muffin danish danish marzipan. Toffee lollipop wafer carrot cake dessert.\",\n description: \"Chocolate tootsie roll lemon drops. Chupa chups chocolate bar apple pie\",\n image: \"chocolate.png\",\n status: 1\n }\n expected = 200\n post_id = 1\n uri = URI.parse('http://localhost:3000/v1/posts/'+post_id.to_s)\n http = Net::HTTP.new(uri.host,uri.port)\n request = Net::HTTP::Put.new(uri.path)\n request.set_form_data(data)\n response = http.request(request)\n actual = JSON.parse(response.body)\n result = assert_equal(expected,actual['meta']['code'])\n puts this_method_name + \" - \" + result.to_s\n end", "def from_merge_patch_json\n if request.patch?\n from_json\n else\n 415\n end\n end", "def update_request?(http_method = nil)\n http_method = http_method.downcase.to_sym if http_method.is_a?(String)\n %i[put post patch].include?(http_method || @verb)\n end", "def patch(operation, path, value = nil)\n ensure_client && ensure_uri\n body = {\n 'op' => operation,\n 'path' => path,\n 'value' => value\n }\n response = @client.rest_patch(@data['uri'], { 'Content-Type' => 'application/json-patch+json', 'body' => [body] }, @api_version)\n @client.response_handler(response)\n end", "def update\n respond_to do |format|\n if @foo.update(foo_params)\n format.html { redirect_to @foo, notice: 'Foo was successfully updated.' }\n format.json { render :show, status: :ok, location: @foo }\n else\n format.html { render :edit }\n format.json { render json: @foo.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @foo8.update(foo8_params)\n format.html { redirect_to @foo8, notice: \"Foo8 was successfully updated.\" }\n format.json { render :show, status: :ok, location: @foo8 }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @foo8.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @foo88.update(foo88_params)\n format.html { redirect_to @foo88, notice: \"Foo88 was successfully updated.\" }\n format.json { render :show, status: :ok, location: @foo88 }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @foo88.errors, status: :unprocessable_entity }\n end\n end\n end", "def patch(path, opts = {})\n request(:patch, path, opts).body\n end", "def update\n @stuff = Stuff.find(params[:id])\n\n respond_to do |format|\n if @stuff.update_attributes(params[:stuff])\n format.html { redirect_to @stuff, :notice => 'Stuff was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @stuff.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @foobar = Foobar.find(params[:id])\n\n respond_to do |format|\n if @foobar.update_attributes(params[:foobar])\n format.html { redirect_to @foobar, notice: 'Foobar was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @foobar.errors, status: :unprocessable_entity }\n end\n end\n end", "def patch(uri, options = T.unsafe(nil)); end", "def put(id, json)\n with_endpoint do |endpoint|\n url = [endpoint, @resource_name, id].compact.join('/')\n url += \"/\" \n return HTTParty.put(url, :body => json, :timeout => 4, :headers => { 'Content-Type' => 'application/json' })\n end\n end", "def update\n respond_to do |format|\n if @anything.update(anything_params)\n format.html { redirect_to @anything, notice: 'Anything was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @anything.errors, status: :unprocessable_entity }\n end\n end\n end", "def http_method_modifies_resource?\n ['PUT','POST','PATCH'].include?(method.to_s.upcase)\n end", "def update\n respond_to do |format|\n if @foo81.update(foo81_params)\n format.html { redirect_to @foo81, notice: \"Foo81 was successfully updated.\" }\n format.json { render :show, status: :ok, location: @foo81 }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @foo81.errors, status: :unprocessable_entity }\n end\n end\n end", "def put(*args)\n request :put, *args\n end", "def update\n respond_to do |format|\n if @baz33.update(baz33_params)\n format.html { redirect_to @baz33, notice: \"Baz33 was successfully updated.\" }\n format.json { render :show, status: :ok, location: @baz33 }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @baz33.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @baz80.update(baz80_params)\n format.html { redirect_to @baz80, notice: \"Baz80 was successfully updated.\" }\n format.json { render :show, status: :ok, location: @baz80 }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @baz80.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @foo1.update(foo1_params)\n format.html { redirect_to @foo1, notice: \"Foo1 was successfully updated.\" }\n format.json { render :show, status: :ok, location: @foo1 }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @foo1.errors, status: :unprocessable_entity }\n end\n end\n end", "def put(path, body = nil, ctype = 'application/json')\n make_call(mk_conn(path, 'Content-Type': ctype,\n 'Accept': 'application/json'),\n :put, nil, body.to_json)\n end", "def update(attrs, path=nil)\n resp = api_client.put(path || url, JSON.dump(attrs))\n refresh(JSON.load(resp.body))\n end", "def test_update_unsuccessful\n data = {\n firstname: \"\",\n lastname: \"Hoang\",\n avatar: \"avatar.png\",\n address: \"111D Ly Chinh Thang\",\n city: \"Ho Chi Minh\",\n email: \"anh@gmallds.sl\",\n mobile: \"0309433343545\",\n gender: 1,\n birthday: \"1991/10/10\"\n }\n\n user_id = 28\n expected = 1002\n uri = URI.parse('http://localhost:3000/v1/users/'+user_id.to_s)\n\n http = Net::HTTP.new(uri.host,uri.port)\n request = Net::HTTP::Put.new(uri.path)\n request.set_form_data(data)\n response = http.request(request)\n actual = JSON.parse(response.body)\n result = assert_equal(expected,actual['meta']['code'])\n puts this_method_name + \" - \" + result.to_s\n end", "def update\n respond_to do |format|\n if @baz27.update(baz27_params)\n format.html { redirect_to @baz27, notice: \"Baz27 was successfully updated.\" }\n format.json { render :show, status: :ok, location: @baz27 }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @baz27.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_tenant_maintenance_window(args = {}) \n id = args['id']\n temp_path = \"/tenants.json/maintenance/{tenantId}\"\n path = temp_path\nargs.keys.each do |key|\n if (key == \"tenantId\")\n args.delete(key)\n path = temp_path.gsub(\"{#{key}}\", id)\n end\nend\n puts \" PATH : #{path}\"\n put(path, args)\nend", "def update\n respond_to do |format|\n if @rest_api.update(rest_api_params)\n format.html { redirect_to @rest_api, notice: 'Rest api was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @rest_api.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n format.xml { head :method_not_allowed }\n format.json { head :method_not_allowed }\n end\n end", "def patch(url, payload, headers={})\n RestClient.patch url, payload, headers\n end", "def update\n respond_to do |format|\n if @baz44.update(baz44_params)\n format.html { redirect_to @baz44, notice: \"Baz44 was successfully updated.\" }\n format.json { render :show, status: :ok, location: @baz44 }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @baz44.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @baz3.update(baz3_params)\n format.html { redirect_to @baz3, notice: \"Baz3 was successfully updated.\" }\n format.json { render :show, status: :ok, location: @baz3 }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @baz3.errors, status: :unprocessable_entity }\n end\n end\n end", "def update!(**args)\n @errors = args[:errors] if args.key?(:errors)\n @etag = args[:etag] if args.key?(:etag)\n @group_id = args[:group_id] if args.key?(:group_id)\n @id = args[:id] if args.key?(:id)\n @kind = args[:kind] if args.key?(:kind)\n @resource = args[:resource] if args.key?(:resource)\n end", "def update\n respond_to do |format|\n if @foo78.update(foo78_params)\n format.html { redirect_to @foo78, notice: \"Foo78 was successfully updated.\" }\n format.json { render :show, status: :ok, location: @foo78 }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @foo78.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @baz31.update(baz31_params)\n format.html { redirect_to @baz31, notice: \"Baz31 was successfully updated.\" }\n format.json { render :show, status: :ok, location: @baz31 }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @baz31.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @my_foo.update(my_foo_params)\n format.html { redirect_to @my_foo, notice: 'My foo was successfully updated.' }\n format.json { render :show, status: :ok, location: @my_foo }\n else\n format.html { render :edit }\n format.json { render json: @my_foo.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @foo77.update(foo77_params)\n format.html { redirect_to @foo77, notice: \"Foo77 was successfully updated.\" }\n format.json { render :show, status: :ok, location: @foo77 }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @foo77.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_with []\n end", "def update\n# respond_to do |format|\n# if @req.update(req_params)\n format.json { render :json => {:status => 'success'}}\n# format.html { redirect_to @req, notice: 'Req was successfully updated.' }\n# format.json { render :show, status: :ok, location: @req }\n# else\n format.json { render :json => {:status => 'failed'}}\n# format.html { render :edit }\n# format.json { render json: @req.errors, status: :unprocessable_entity }\n# end\n# end\n end", "def test_update_successful\n data = {\n firstname: \"Anh\",\n lastname: \"Hoang\",\n avatar: \"avatar.png\",\n address: \"111D Ly Chinh Thang\",\n city: \"Ho Chi Minh\",\n email: \"anh@gmallds.sl\",\n mobile: \"0309433343545\",\n gender: 1,\n birthday: \"1991/10/10\"\n }\n\n user_id = 28\n expected = 200\n uri = URI.parse('http://localhost:3000/v1/users/'+user_id.to_s)\n\n http = Net::HTTP.new(uri.host,uri.port)\n request = Net::HTTP::Put.new(uri.path)\n request.set_form_data(data)\n response = http.request(request)\n actual = JSON.parse(response.body)\n result = assert_equal(expected,actual['meta']['code'])\n puts this_method_name + \" - \" + result.to_s\n end", "def update_by_body\n @person = Person.find(person_update_params[:id])\n\n if @person.update_attributes(person_update_params)\n render json: { status: 'PUT Success' }, status: :ok\n else\n render json: { status: 'Error', message:'Error updating person', person: @person.errors }, status: :unprocessable_entity\n end\n end", "def update\n respond_to do |format|\n if @baz66.update(baz66_params)\n format.html { redirect_to @baz66, notice: \"Baz66 was successfully updated.\" }\n format.json { render :show, status: :ok, location: @baz66 }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @baz66.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n request_body_Data= '{ \"widget\":\n {\n \"name\" : \"'+params[:name]+'\",\n \"description\" : \"'+params[:description]+'\"\n }}'\n response = RestClient::Request.new({\n method: :put,\n url: ENV['API_URL'] + '/widgets/' + params[:id],\n payload: request_body_Data,\n headers: { Authorization: session[:access_token], content_type: 'application/json'}\n }).execute do |response, request, result|\n case response.code\n when 400\n [ :error, JSON.parse(response) ]\n when 200\n [ :success, JSON.parse(response) ]\n json=JSON.parse(response)\n @widget= Widget.new do |widget|\n widget.id=json[\"data\"][\"widget\"][\"id\"]\n widget.name=json[\"data\"][\"widget\"][\"name\"]\n widget.description=json[\"data\"][\"widget\"][\"description\"]\n widget.kind=json[\"data\"][\"widget\"][\"kind\"]\n widget.userid=json[\"data\"][\"widget\"][\"user\"][\"id\"]\n widget.username=json[\"data\"][\"widget\"][\"user\"][\"name\"]\n widget.owner=json[\"data\"][\"widget\"][\"owner\"]\n end\n else\n fail \"Invalid response #{response.to_str} received.\"\n end\n end\n respond_to do |format|\n if @widget\n format.html { redirect_to @widget, notice: 'Widget was successfully updated.' }\n format.json { render :show, status: :ok, location: @widget }\n else\n format.html { render :edit }\n format.json { render json: @widget.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @json.update(json_params)\n format.html { redirect_to @json, notice: 'Json was successfully updated.' }\n format.json { render :show, status: :ok, location: @json }\n else\n format.html { render :edit }\n format.json { render json: @json.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @json.update(json_params)\n format.html { redirect_to @json, notice: 'Json was successfully updated.' }\n format.json { render :show, status: :ok, location: @json }\n else\n format.html { render :edit }\n format.json { render json: @json.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_user_for_tenant(args = {}) \n id = args['id']\n temp_path = \"/tenants.json/{tenantId}/users/{userId}\"\n path = temp_path\nargs.keys.each do |key|\n if (key == \"tenantId\")\n args.delete(key)\n path = temp_path.gsub(\"{#{key}}\", id)\n end\nend\n puts \" PATH : #{path}\"\n put(path, args)\nend", "def update\n respond_to do |format|\n if @api_v1_resource.update(api_v1_resource_params)\n format.html { redirect_to @api_v1_resource, notice: 'Resource was successfully updated.' }\n format.json { render :show, status: :ok, location: @api_v1_resource }\n else\n format.html { render :edit }\n format.json { render json: @api_v1_resource.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @baz32.update(baz32_params)\n format.html { redirect_to @baz32, notice: \"Baz32 was successfully updated.\" }\n format.json { render :show, status: :ok, location: @baz32 }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @baz32.errors, status: :unprocessable_entity }\n end\n end\n end", "def update!(**args)\n @api_version = args[:api_version] if args.key?(:api_version)\n @cancel_requested = args[:cancel_requested] if args.key?(:cancel_requested)\n @create_time = args[:create_time] if args.key?(:create_time)\n @end_time = args[:end_time] if args.key?(:end_time)\n @status_detail = args[:status_detail] if args.key?(:status_detail)\n @target = args[:target] if args.key?(:target)\n @verb = args[:verb] if args.key?(:verb)\n end", "def update!(**args)\n @api_version = args[:api_version] if args.key?(:api_version)\n @cancel_requested = args[:cancel_requested] if args.key?(:cancel_requested)\n @create_time = args[:create_time] if args.key?(:create_time)\n @end_time = args[:end_time] if args.key?(:end_time)\n @status_detail = args[:status_detail] if args.key?(:status_detail)\n @target = args[:target] if args.key?(:target)\n @verb = args[:verb] if args.key?(:verb)\n end", "def update!(**args)\n @api_version = args[:api_version] if args.key?(:api_version)\n @cancel_requested = args[:cancel_requested] if args.key?(:cancel_requested)\n @create_time = args[:create_time] if args.key?(:create_time)\n @end_time = args[:end_time] if args.key?(:end_time)\n @status_detail = args[:status_detail] if args.key?(:status_detail)\n @target = args[:target] if args.key?(:target)\n @verb = args[:verb] if args.key?(:verb)\n end", "def update!(**args)\n @api_version = args[:api_version] if args.key?(:api_version)\n @cancel_requested = args[:cancel_requested] if args.key?(:cancel_requested)\n @create_time = args[:create_time] if args.key?(:create_time)\n @end_time = args[:end_time] if args.key?(:end_time)\n @status_detail = args[:status_detail] if args.key?(:status_detail)\n @target = args[:target] if args.key?(:target)\n @verb = args[:verb] if args.key?(:verb)\n end" ]
[ "0.6465599", "0.6313394", "0.63052225", "0.6287115", "0.62198776", "0.61856407", "0.61634755", "0.6151888", "0.6110573", "0.6004204", "0.60037816", "0.60013103", "0.5904396", "0.5904396", "0.5883331", "0.58516693", "0.5843176", "0.58250463", "0.5802294", "0.57998407", "0.5798113", "0.5784603", "0.578228", "0.5782158", "0.5781329", "0.57612216", "0.5756797", "0.5749168", "0.5749054", "0.57476395", "0.574433", "0.57378596", "0.57378596", "0.57340384", "0.5724828", "0.57238835", "0.57223964", "0.5719891", "0.5701473", "0.57010263", "0.57010263", "0.5698004", "0.5692249", "0.56920385", "0.56809914", "0.5676765", "0.56756854", "0.5675654", "0.56749785", "0.5672072", "0.5662605", "0.5651543", "0.56460303", "0.5627923", "0.56263375", "0.56215066", "0.5619381", "0.5616422", "0.56109744", "0.5609479", "0.5609004", "0.5603407", "0.56004155", "0.5600072", "0.558692", "0.55854416", "0.55765754", "0.55719244", "0.55671996", "0.55665916", "0.556274", "0.5552143", "0.5551774", "0.55515194", "0.5550251", "0.5547894", "0.5547091", "0.55404633", "0.5538733", "0.5536891", "0.55277795", "0.5525732", "0.5523849", "0.55208325", "0.5520327", "0.55165136", "0.5516112", "0.55160743", "0.55155617", "0.55143917", "0.5504897", "0.5504876", "0.5504876", "0.54959255", "0.5491558", "0.54885983", "0.5488141", "0.5488141", "0.5488141", "0.5488141" ]
0.58031523
18
DELETE /baz94s/1 or /baz94s/1.json
def destroy @baz94.destroy respond_to do |format| format.html { redirect_to baz94s_url, notice: "Baz94 was successfully destroyed." } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete_aos_version(args = {}) \n delete(\"/aosversions.json/#{args[:aosVersionId]}\", args)\nend", "def delete(*rest) end", "def test_delete_preconditions_failed\n request = Http::Request.new(\n 'DELETE',\n '/file1',\n 'If-Match' => \"\\\"#{Digest::MD5.hexdigest('bar')}\\\"\"\n )\n\n response = self.request(request)\n\n assert_equal(\n 412,\n response.status,\n \"Incorrect status code. Response body: #{response.body_as_string}\"\n )\n end", "def cmd_delete argv\n setup argv\n uuid = @hash['uuid']\n response = @api.delete(uuid)\n msg response\n return response\n end", "def http_delete(path, data = nil, content_type = 'application/json')\n http_methods(path, :delete, data, content_type)\n end", "def delete path\n make_request(path, \"delete\", {})\n end", "def delete!(*rest) end", "def api_delete(path, data = {})\n api_request(:delete, path, :data => data)\n end", "def delete\n url = prefix + \"delete\"\n return response(url)\n end", "def delete\n url = prefix + \"delete\"\n return response(url)\n end", "def delete!( opts = {} )\n http_action :delete, nil, opts\n end", "def delete_json(path)\n url = [base_url, path].join\n resp = HTTParty.delete(url, headers: standard_headers)\n parse_json(url, resp)\n end", "def delete(path)\n RestClient.delete request_base+path\n end", "def delete\n client.delete(\"/#{id}\")\n end", "def delete\n url = prefix + \"delete\" + id_param\n return response(url)\n end", "def delete\n client.delete(url)\n @deleted = true\nend", "def delete(splat)\n bad_request if splat.empty?\n _delete resolve_uri(splat[0])\n end", "def delete(*args)\n request(:delete, *args)\n end", "def delete(path)\n repository = path.split(/\\//)[2]\n objectid = path.split(/\\//)[3]\n if storage_fetch(repository, objectid) && storage_delete(repository, objectid)\n ['200', {}, []]\n else\n ['404', {}, [\"Repository #{repository} or ObjectID #{objectid} not found: #{path}\"]]\n end\n end", "def delete(url, headers = {})\n http :delete, \"#{url}.json\", headers\n end", "def delete(name); end", "def delete(name); end", "def delete\n url = prefix + \"delete\"\n return response(url)\n end", "def delete\n url = prefix + \"delete\"\n return response(url)\n end", "def do_delete(uri = \"\")\n @connection.delete do |req|\n req.url uri\n req.headers['Content-Type'] = 'application/json'\n end\n end", "def orchio_delete\n response = client.send_request :delete, inst_args\n orchio_status response, 204\n end", "def delete\n res = HTTParty.get URL, headers: HEADERS\n message = JSON.parse res.body, symbolize_names: true\n if res.code == 200\n numSubs = message[:data].count\n if numSubs > 0\n message[:data].each do |sub|\n id = sub[:id]\n delRes = HTTParty.delete \"#{URL}/#{id}\", headers: HEADERS\n #TODO handle status codes\n end\n end\n end\n end", "def delete(type, id)\n http_delete @target, \"#{type_info(type, :path)}/#{Addressable::URI.encode(id)}\", @auth_header, @zone\n end", "def test_delete_not_found\n request = Http::Request.new('DELETE', '/file2')\n response = self.request(request)\n\n assert_equal(\n 404,\n response.status,\n \"Incorrect status code. Response body: #{response.body_as_string}\"\n )\n end", "def delete(path)\n request(:delete, path)\n end", "def test_del\n header 'Content-Type', 'application/json'\n\n data = File.read 'sample-traces/0.json'\n post('/traces', data, 'CONTENT_TYPE': 'application/json')\n\n id = last_response.body\n\n delete \"/traces/#{id}\"\n assert last_response.ok?\n\n get \"/traces/#{id}\"\n\n contents = JSON.parse last_response.body\n assert_kind_of(Hash, contents, 'Response contents is not a hash')\n assert contents.key? 'description'\n assert(!last_response.ok?)\n end", "def delete(*args)\n prepare_request(:delete, args)\n @@client.add(:delete, @path, *args)\n end", "def delete!\n request! :delete\n end", "def delete(path)\n\t\trequest(path, :delete)\n\tend", "def delete(path, params)\n headers = {:Authorization => \"token #{token}\", :content_type => :json, :accept => :json}\n res = RestClient.delete(\"#{github_api_uri}/#{path}\", params.to_json, headers)\n Yajl.load(res)\n end", "def destroy\n client=Client.find_by_id(params[:id])\n if client != nil\n if client.destroy\n head 204\n end\n else\n head 404\n end\n end", "def delete(*uris); end", "def delete(path, params = {})\n Chirpy.request params.merge({:path => path, :method => 'delete'}.merge(authentication))\n end", "def delete(path, *data, &block)\n map(path, R3::DELETE, *data, &block)\n end", "def delete(path)\n request 'DELETE', path\n end", "def delete\n response = WebPay.client.delete(path)\n response['deleted']\n end", "def delete *args, &block\n res = @conn.delete *args, &block\n handle res, parse: false\n end", "def delete(args)\n args = {:path => args} unless args.is_a?(Hash)\n assert_supported_keys(args, [:path, :version, :callback, :context])\n assert_required_keys(args, [:path])\n args[:version] ||= -1\n\n if args[:callback] ## asynchronous\n raise KeeperException::BadArguments unless args[:callback].kind_of?(VoidCallback)\n return zoo_adelete(@zk_handle, args[:path], args[:version], args[:callback].proc, YAML.dump(args[:context]))\n end\n\n ## synchronous\n rc = zoo_delete(@zk_handle, args[:path], args[:version])\n raise KeeperException.by_code(rc), ZooKeeperFFI::zerror(rc) unless rc == ZOK\n return rc\n end", "def delete(path, params)\n parse_response @client[path].delete(:params => params)\n end", "def delete\n execute_request('DELETE') do |uri, headers|\n HTTP.http_client.delete(uri, header: headers)\n end\n end", "def test_delete_post\n expected = 200\n post_id = 1\n uri = URI.parse('http://localhost:3000/v1/posts/'+post_id.to_s)\n http = Net::HTTP.new(uri.host,uri.port)\n request = Net::HTTP::Delete.new(uri.path)\n request.set_form_data(data)\n response = http.request(request)\n actual = JSON.parse(response.body)\n result = assert_equal(expected,actual['meta']['code'])\n puts this_method_name + \" - \" + result.to_s\n end", "def delete(resource)\n headers = base_headers.merge('Content-Type' => 'application/json')\n url = \"#{@base_url}/#{resource}\"\n\n @logger.debug(\"DELETE request Url: #{url}\")\n @logger.debug(\"-- Headers: #{headers}\")\n\n x = HTTParty.delete(url, headers: headers)\n puts x.inspect\n x\n end", "def delete(name)\n\n end", "def deletef\n url = prefix + \"deletef\" + id_param\n return response(url)\n end", "def destroy\n if @short_url.destroy\n render json: { status: \"Deleted\" }\n else\n render json: { head: \"no content\" }\n end \n end", "def delete(path_part, additional_headers = {}, &block)\n api_request { @rest.delete('/REST/' + path_part, \"\", additional_headers, &block) }\n end", "def delete_tenant_circle(args = {}) \n delete(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend", "def destroy\n @baz41.destroy\n respond_to do |format|\n format.html { redirect_to baz41s_url, notice: \"Baz41 was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @baz54.destroy\n respond_to do |format|\n format.html { redirect_to baz54s_url, notice: \"Baz54 was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def delete(name)\n request(uri = uri(name), Net::HTTP::Delete.new(uri.request_uri))\n end", "def delete(path, data = {})\n self.class.delete path, :body => data.merge(:u => access_token)\n end", "def delete(path, options={})\n url = build_url path, options\n headers = options[:headers] || {}\n # nothing returned in response body for DELETE\n Response.new(@client[url].delete headers)\n rescue RestClient::Exception => e\n Response.new e.response\n end", "def delete(path, headers = {})\n process :delete, path, headers\n end", "def delete(major,minor)\n major = major.to_sym\n if minor\n delete_hash = minor\n else\n if storage.hash_exists?(major)\n delete_hash = storage.find(major)\n else\n puts 'Delete hash not found in storage.'\n puts 'Use: imgurr delete <id> <delete_hash>'\n return\n end\n end\n if ImgurAPI.delete(delete_hash)\n puts 'Successfully deleted image from Imgur'\n storage.delete(major)\n storage.save\n else\n puts 'Unauthorized Access. Wrong delete hash?'\n end\n end", "def delete\n if body.empty? && params[:id]\n client.delete(params)\n elsif body.empty?\n client.delete_by_query(params.merge(body: body.merge(ALL)))\n else\n client.delete_by_query(params.merge(body: body))\n end\n end", "def delete(*args)\n execute(:delete, *args)\n end", "def delete(path, data={})\n request(:delete, path, data)\n end", "def delete(action, **args); end", "def delete\n request(:delete)\n end", "def test_valid_delete_returns_204\n db = DB.get\n\n valid_entry = SEED_ENTRIES.first\n insert_entry(db, valid_entry)\n\n assert_equal 1, db.execute('select * from entries').count\n\n delete \"/api/entries/#{valid_entry[:slug]}\"\n assert last_response.no_content?\n\n assert_equal 0, db.execute('select * from entries').count\n end", "def http_delete(opts={})\n ret=http_delete_low(opts)\n if ret.is_a?(Hash) and ret.has_key?('error') and ret['error']=='Invalid Credentials' then\n\tauthdefault\n\tret=http_delete_low(opts)\n\treturn ret\n else\n\treturn ret\n end\n end", "def destroy\n @foo54.destroy\n respond_to do |format|\n format.html { redirect_to foo54s_url, notice: \"Foo54 was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @baz43.destroy\n respond_to do |format|\n format.html { redirect_to baz43s_url, notice: \"Baz43 was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def delete(command)\n pp @client.files.delete(clean_up(command[1]))\n end", "def delete(path)\n request(:delete, path)\n end", "def destroy\n @baz1.destroy\n respond_to do |format|\n format.html { redirect_to baz1s_url, notice: \"Baz1 was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def delete(path, **options)\n execute :delete, path, options\n end", "def destroy\n @baz35.destroy\n respond_to do |format|\n format.html { redirect_to baz35s_url, notice: \"Baz35 was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def deleteExecution(execution_id)\n uri = URI(RUNDECKSERVER + ':' + RUNDECKPORT + '/api/12/execution/' + execution_id)\n http = Net::HTTP.new(uri.host, uri.port)\n headers = {'Content-Type'=> 'application/jsonr','X-RunDeck-Auth-Token'=> API_KEY }\n r = http.delete(uri.path, headers) \n return r\nend", "def delete_data(path, &block)\n url = \"#{host}/api/v#{version}/#{path}\"\n params = Jbuilder.encode(&block) if block_given?\n params ||= {}\n resource = RestClient::Resource.new(\n url, \n headers: {\n \"uid\" => @uid,\n \"client\" => @client,\n \"access-token\" => @access_token\n }\n )\n resource.delete(params) do |response, request, result, &blk|\n case response.code\n when 200\n if response.blank?\n true\n else\n auth_data = {\n uid: response.headers[:uid],\n client: response.headers[:client],\n access_token: response.headers[:access_token]\n }\n JSON.parse(response).merge(auth_data)\n end\n when 404\n nil\n else\n JSON.parse(response)\n end\n end\n end", "def destroy\n @baz55.destroy\n respond_to do |format|\n format.html { redirect_to baz55s_url, notice: \"Baz55 was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @baz83.destroy\n respond_to do |format|\n format.html { redirect_to baz83s_url, notice: \"Baz83 was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @baz72.destroy\n respond_to do |format|\n format.html { redirect_to baz72s_url, notice: \"Baz72 was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def delete(resource_type,identifier)\n path = '/api/' + resource_type.to_s + '/' + slugify(identifier)\n http_delete(path)\n end", "def delete\n RestClient.delete(url, @header) do |rso, req, res|\n setup(rso, req, res)\n end\n end", "def delete\n supprimer = SondageService.instance.supprimerSondage(params[:id])\n (supprimer) ? (render json: true, status: :ok) : (render json: false, status: :not_found)\nend", "def fire_delete(url_or_path, options = {}, &block)\n params = options.fetch(:params, {})\n params.merge!(mapped_params(options))\n\n url = absolute_url(url_or_path, params: params)\n headers = {:Accept => MEDIA_TYPE_JSON}.merge(options.fetch(:headers, {}))\n headers = merge_log_weasel_header(headers)\n timeout = options.fetch(:timeout, Ladon.default_request_timeout)\n response = Typhoeus::Request.delete(url, headers: headers, timeout: timeout)\n handle_response(response, method: :delete, default_data: options[:default_data], url: url,\n raise_on_error: options[:raise_on_error], &block)\n end", "def delete(path, options = {}, signature = false, raw = false, unformatted = false, no_response_wrapper = self.no_response_wrapper, signed = sign_requests)\n request(:delete, path, options, signature, raw, unformatted, no_response_wrapper, signed)\n end", "def delete(path, params = {})\n debug_log \"DELETE #{@host}#{path} params:#{params}\"\n res = connection.delete path, params\n debug_log \"Response status:#{res.status}, body:#{res.body}\"\n res\n end", "def delete_from_entzumena\n headline = Headline.where({:source_item_type => params[:source_item_type], :source_item_id => params[:source_item_id]}).first\n if headline.destroy\n render :json => true, :status => 200\n else\n render :json => false, :status => :error\n end\n end", "def delete_json(url)\n JSON.parse(delete(url, :json, :json))\n end", "def delete endpoint\n do_request :delete, endpoint\n end", "def destroy\n @foo56.destroy\n respond_to do |format|\n format.html { redirect_to foo56s_url, notice: \"Foo56 was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @foo = Foo.find(params[:id])\n @foo.destroy\n\n respond_to do |format|\n format.html { redirect_to foos_url }\n format.json { head :ok }\n end\n end", "def delete(path, params={})\n request(:delete, path, params)\n end", "def delete(path, params={})\n request(:delete, path, params)\n end", "def delete(path, params={})\n request(:delete, path, params)\n end", "def delete(path, params={})\n request(:delete, path, params)\n end", "def delete(path, params={})\n request(:delete, path, params)\n end", "def delete(path, params={})\n request(:delete, path, params)\n end", "def delete(path, params={})\n request(:delete, path, params)\n end", "def delete(*args)\n url, subdomain, path, = parse_args(*args)\n rewrap_errors do\n RestClient.delete(build_url(url || subdomain, path), headers)\n end\n end", "def delete(path = '/files/', params = {})\n request :delete, path, params\n end", "def destroy\n @baz44.destroy\n respond_to do |format|\n format.html { redirect_to baz44s_url, notice: \"Baz44 was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def delete(options={})\n connection.delete(\"/\", @name)\n end" ]
[ "0.6852052", "0.68285906", "0.66160333", "0.6586017", "0.6498215", "0.64959764", "0.64631444", "0.6461559", "0.6442501", "0.6442501", "0.64055824", "0.6384943", "0.63474727", "0.6335707", "0.6322956", "0.629167", "0.62751585", "0.6246913", "0.62424093", "0.6237382", "0.62248766", "0.62248766", "0.6224211", "0.6224211", "0.62238485", "0.6218054", "0.6214848", "0.6204506", "0.6201167", "0.61919564", "0.61873645", "0.6185583", "0.61748326", "0.6163481", "0.61567116", "0.6145385", "0.61443365", "0.6144271", "0.6133785", "0.6133099", "0.6122452", "0.61224127", "0.61186856", "0.61181784", "0.6107062", "0.61046845", "0.61005324", "0.6098749", "0.60974234", "0.6085383", "0.6073476", "0.6058", "0.6057295", "0.6057068", "0.6054792", "0.6049021", "0.60487723", "0.6046881", "0.604665", "0.6041585", "0.60405505", "0.6038009", "0.603419", "0.6030811", "0.6021646", "0.6018439", "0.6006619", "0.6003795", "0.60037404", "0.60005724", "0.6000019", "0.59923553", "0.5985054", "0.5974581", "0.5974445", "0.5969614", "0.59661144", "0.5960594", "0.5960275", "0.59559256", "0.59558994", "0.5952905", "0.59515864", "0.5949438", "0.594762", "0.59428406", "0.59411585", "0.5940674", "0.5938925", "0.593708", "0.593708", "0.593708", "0.593708", "0.593708", "0.593708", "0.593708", "0.59357154", "0.59352845", "0.5934815", "0.5934721" ]
0.6089383
49
Use callbacks to share common setup or constraints between actions.
def set_baz94 @baz94 = Baz94.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_eval do\n define_method(:valid?) do |*args|\n self.class.state_machines.fire_event_attributes(self, :save, false) { super(*args) }\n end\n end\n end\n end", "def add_actions; end", "def callbacks; end", "def callbacks; end", "def setup *actions, &proc\n (@setup_procs ||= []) << [proc, actions.size > 0 ? actions : [:*]]\n end", "def define_action_helpers; end", "def post_setup\n end", "def action_methods; end", "def action_methods; end", "def action_methods; end", "def before_setup; end", "def action_run\n end", "def execute(setup)\n @action.call(setup)\n end", "def define_action_helpers?; end", "def set_actions\n actions :all\n end", "def action_done(action)\n dispatch = { :migrate => :done_migrating, :map => :done_mapping, :reduce =>\n :done_reducing, :finalize => :done_finalizing } \n self.send dispatch[action[:action]], action\n end", "def dependencies action, &block\n @actions.each do |other|\n if action[:requires].include? other[:provide]\n block.call other\n end\n end\n end", "def setup!\n return unless @setup_procs\n http_actions = actions\n @setup_procs.each do |setup_proc|\n proc, actions = setup_proc\n @setup__actions = actions.map do |action|\n\n action.is_a?(Regexp) ?\n http_actions.select { |a| a.to_s =~ action } :\n action.is_a?(String) && action =~ /\\A\\./ ?\n http_actions.map { |a| a.to_s << action if format?(a).include?(action) }.compact :\n action\n\n end.flatten\n self.class_exec &proc\n @setup__actions = nil\n end\n @setup_procs = nil\n end", "def before_actions(*logic)\n self.before_actions = logic\n end", "def setup_handler\n end", "def set_action(opts)\n opts = check_params(opts,[:actions])\n super(opts)\n end", "def setup(action)\n @targets.clear\n unless action.item.target_filters.empty?\n @targets = SES::TargetManager.make_targets(action)\n else\n item = action.item\n if item.for_opponent?\n @targets = $game_troop.alive_members\n elsif item.for_dead_friend?\n @targets = $game_party.battle_members.select { |actor| actor.dead? }\n else\n $game_party.battle_members.select { |actor| actor.alive? }\n end\n end\n @item_max = @targets.size\n create_contents\n refresh\n show\n activate\n end", "def action; end", "def action; end", "def action; end", "def action; end", "def action; end", "def workflow\n end", "def revisable_shared_setup(args, block)\n class << self\n attr_accessor :revisable_options\n end\n options = args.extract_options!\n self.revisable_options = Options.new(options, &block)\n \n self.send(:include, Common)\n self.send(:extend, Validations) unless self.revisable_options.no_validation_scoping?\n self.send(:include, WithoutScope::QuotedColumnConditions)\n end", "def setup\n @action = SampleActionAndroid.new(os_name: 'android',\n app_name: APP_PATH)\n end", "def before(action)\n invoke_callbacks *self.class.send(action).before\n end", "def process_action(...)\n send_action(...)\n end", "def before_dispatch(env); end", "def after_actions(*logic)\n self.after_actions = logic\n end", "def setup\n # override and do something appropriate\n end", "def setup(client)\n return unless @setup\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n actions.each do |action|\n action.execute(client)\n end\n self\n end", "def setup(_context)\n end", "def setup(resources) ; end", "def validate_actions\n errors.add(:base, :should_give_at_least_one_action) if !manage? && !forecasting? && !read? && !api?\n end", "def setup\n @resource_config = {\n :callbacks => {\n :before_create => nil,\n :after_create => nil,\n :before_update => nil,\n :after_update => nil,\n :before_destroy => nil,\n :after_destroy => nil,\n },\n :child_assoc => nil,\n :model => nil,\n :parent => nil,\n :path => nil,\n :permission => {},\n :properties => {},\n :relation => {\n :create => nil,\n :delete => nil,\n },\n :roles => nil,\n }\n end", "def determine_valid_action\n\n end", "def process_shared\n handle_taxes\n handle_shippings\n create_adjustments_from_params\n handle_status\n handle_inventory_refunds\n handle_payment_transactions\n order.updater.update\n end", "def startcompany(action)\n @done = true\n action.setup\n end", "def init_actions\n am = action_manager()\n am.add_action(Action.new(\"&Disable selection\") { @selection_mode = :none; unbind_key(32); bind_key(32, :scroll_forward); } )\n am.add_action(Action.new(\"&Edit Toggle\") { @edit_toggle = !@edit_toggle; $status_message.value = \"Edit toggle is #{@edit_toggle}\" })\n end", "def event_callbacks(event, metadata={})\n case event\n when :reset, :review\n if confirmed\n update_attributes(confirmed: false)\n end\n when :confirm\n confirm\n # trigger :order for all applicable items\n # NOTE: :order event is common to both physical and digital items\n items.each do |i|\n if i.event_permitted(:order)\n user_id = last_transition.user_id\n i.trigger!(:order, { order_id: id, user_id: user_id })\n end\n end\n when :complete_work\n request = metadata[:request]\n work_complete_notification(request)\n when :close\n close\n end\n if event != :close && !open\n reopen\n end\n end", "def setup_action\n return unless PONY::ERRNO::check_sequence(current_act)\n new_sequence = @action_sequence[@sequence_index+1...@action_sequence.size]\n @sequence_index = 0\n new_sequence = DND::SkillSequence::ACTS[@acts[1]] + new_sequence\n execute_sequence\n end", "def define_tasks\n define_weave_task\n connect_common_tasks\n end", "def setup(&block)\n define_method(:setup, &block)\n end", "def setup\n transition_to(:setup)\n end", "def setup\n transition_to(:setup)\n end", "def action\n end", "def setup( *args )\n\t\t\tself.class.setupBlocks.each {|sblock|\n\t\t\t\tdebugMsg \"Calling setup block method #{sblock}\"\n\t\t\t\tself.send( sblock )\n\t\t\t}\n\t\t\tsuper( *args )\n\t\tend", "def config(action, *args); end", "def setup\n @setup_proc.call(self) if @setup_proc\n end", "def before_action \n end", "def setup_callbacks\n defined_callbacks.each do |meth|\n unless respond_to?(\"call_#{meth}_callbacks\".to_sym)\n self.class.module_eval <<-EOE\n def call_#{meth}_callbacks(*args)\n plugin_store.each {|a| a.call_#{meth}_callbacks(*args) } if respond_to?(:plugin_store) && plugin_store\n self.send :#{meth}, *args if respond_to?(:#{meth})\n end\n EOE\n end\n end\n end", "def action\n end", "def matt_custom_action_begin(label); end", "def setup\n # override this if needed\n end", "def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend", "def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend", "def action(options,&callback)\n new_action = Action===options ? options : Action.new(options,&callback)\n # replace any with (shared name/alias or both default) + same arity\n @actions.delete_if do |existing_action|\n ((existing_action.names & new_action.names).size > 0 ||\n existing_action.default? && new_action.default?) &&\n existing_action.required.size == new_action.required.size &&\n existing_action.optional.size <= new_action.optional.size\n end\n @actions = (@actions + [new_action]).sort\n new_action\n end", "def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action\n end", "def after(action)\n invoke_callbacks *options_for(action).after\n end", "def pre_task\n end", "def setup(server)\n server.on('beforeMethod', method(:before_method), 10)\n end", "def add_actions\n attribute = machine.attribute\n name = self.name\n \n owner_class.class_eval do\n define_method(name) {self.class.state_machines[attribute].events[name].fire(self)}\n define_method(\"#{name}!\") {self.class.state_machines[attribute].events[name].fire!(self)}\n define_method(\"can_#{name}?\") {self.class.state_machines[attribute].events[name].can_fire?(self)}\n end\n end", "def init_actions\n @select_action = SelectAction.new\n @endpoint_mouse_action = EndpointMouseAction.new\n @move_action = MoveAction.new\n end", "def setup_signals; end", "def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend", "def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend", "def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action.respond_to?('weak!') ? action.weak! : action\n end", "def initialize(*args)\n super\n @action = :set\nend", "def after_set_callback; end", "def setup\n #implement in subclass;\n end", "def lookup_action; end", "def setup &block\n if block_given?\n @setup = block\n else\n @setup.call\n end\n end", "def setup_action\n return TSBS.error(@acts[0], 1, @used_sequence) if @acts.size < 2\n actions = TSBS::AnimLoop[@acts[1]]\n if actions.nil?\n show_action_error(@acts[1])\n end\n @sequence_stack.push(@acts[1])\n @used_sequence = @acts[1]\n actions.each do |acts|\n @acts = acts\n execute_sequence\n break if @break_action\n end\n @sequence_stack.pop\n @used_sequence = @sequence_stack[-1]\n end", "def release_actions; end", "def around_hooks; end", "def save_action; end", "def setup(easy)\n super\n easy.customrequest = @verb\n end", "def action_target()\n \n end", "def setup\n callback(:setup) do\n notify(:setup)\n migration_check.last_deployed_commit\n end\n end", "def setup\n return unless @setup\n\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n run_actions_and_retry(actions)\n self\n end", "def before_setup\n # do nothing by default\n end", "def my_actions(options)\n @setup = false\n get_template_part(\"custom_used\",\"action_users\",true)\n end", "def default_action; end", "def setup(&blk)\n @setup_block = blk\n end", "def callback_phase\n super\n end", "def advice\n end", "def _handle_action_missing(*args); end", "def duas1(action)\n action.call\n action.call\nend", "def shared_action(name, &block)\n @controller.shared_actions[name] = block\n end", "def before_action action, &block\n @audience[:before][action] ||= Set.new\n @audience[:before][action] << block\n end", "def setup_initial_state\n\n state_a = State.new(\"a\", 0)\n state_b = State.new(\"b\", 0)\n state_c = State.new(\"c\", 10)\n\n move_to_b = Action.new(\"move_to_b\", 1, state_b)\n\n move_to_c = Action.new(\"move_to_c\", 1, state_c)\n\n state_a.actions = [move_to_b, move_to_c]\n\n return state_a\n \nend" ]
[ "0.6163163", "0.6045976", "0.5946146", "0.591683", "0.5890051", "0.58349305", "0.5776858", "0.5703237", "0.5703237", "0.5652805", "0.5621621", "0.54210985", "0.5411113", "0.5411113", "0.5411113", "0.5391541", "0.53794575", "0.5357573", "0.53402257", "0.53394014", "0.53321576", "0.53124547", "0.529654", "0.5296262", "0.52952296", "0.52600986", "0.52442724", "0.52385926", "0.52385926", "0.52385926", "0.52385926", "0.52385926", "0.5232394", "0.523231", "0.5227454", "0.52226824", "0.52201617", "0.5212327", "0.52079266", "0.52050185", "0.51754695", "0.51726824", "0.51710224", "0.5166172", "0.5159343", "0.51578903", "0.51522785", "0.5152022", "0.51518047", "0.51456624", "0.51398855", "0.5133759", "0.5112076", "0.5111866", "0.5111866", "0.5110294", "0.5106169", "0.509231", "0.50873137", "0.5081088", "0.508059", "0.50677156", "0.50562143", "0.5050554", "0.50474834", "0.50474834", "0.5036181", "0.5026331", "0.5022976", "0.5015441", "0.50121695", "0.5000944", "0.5000019", "0.4996878", "0.4989888", "0.4989888", "0.49864885", "0.49797225", "0.49785787", "0.4976161", "0.49683493", "0.4965126", "0.4958034", "0.49559742", "0.4954353", "0.49535993", "0.4952725", "0.49467874", "0.49423352", "0.49325448", "0.49282882", "0.49269363", "0.49269104", "0.49252945", "0.4923091", "0.49194667", "0.49174926", "0.49173003", "0.49171105", "0.4915879", "0.49155936" ]
0.0
-1
Only allow a list of trusted parameters through.
def baz94_params params.require(:baz94).permit(:foo1, :foo2, :foo3, :foo4, :foo5) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def allowed_params\n ALLOWED_PARAMS\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def parameters_list_params\n params.require(:parameters_list).permit(:name, :description, :is_user_specific)\n end", "def param_whitelist\n [:role, :title]\n end", "def param_whitelist\n whitelist = [\n :username, :name,\n :parent_id,\n :headline, :description, :video,\n :policy, :signup_mode, :category,\n :website, :facebook, :twitter, :linkedin,\n :founded_at,\n privacy: [\n :events,\n :resources\n ],\n permission: [\n :profile,\n :members,\n :children,\n :statistics,\n :posts,\n :listings,\n :resources,\n :events\n ],\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:parent_id)\n unless current_user.role_in(@community) === 'owner'\n whitelist.delete(:privacy)\n whitelist.delete(:permission)\n end\n end\n \n whitelist\n end", "def strong_params\n params.require(:user).permit(param_whitelist)\n end", "def param_whitelist\n if @user.present? && current_user != @user\n return [:followed]\n end\n \n whitelist = [\n :username, :email, :password,\n :first_name, :last_name,\n :birthday, :gender,\n :headline, :biography, :ask_about, :focus,\n :website, :facebook, :linkedin, :twitter, :github,\n roles: [],\n skills: [],\n interests: [],\n privacy: { contact: [] },\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:email)\n whitelist.delete(:password)\n end\n \n whitelist\n end", "def allow_params_authentication!; end", "def whitelisted_args\n args.select &:allowed\n end", "def safe_list_sanitizer; end", "def safe_list_sanitizer; end", "def safe_list_sanitizer; end", "def filtered_parameters; end", "def sanitize_params_for user, params, allowed_params\n params.each do |key, val|\n #if allowed_params.include?(key)\n #sanitize!(user, params, key) if key =~ /_attributes|_ids$/\n #else\n #params.delete(key)\n #end\n params.delete(key) unless allowed_params.include?(key.to_sym)\n end\n end", "def strong_params\n params.require(:team_member).permit(param_whitelist)\n end", "def expected_permitted_parameter_names; end", "def sanitize_parameters!(sanitizer, params)\n # replace :readwrite with :onlyif\n if params.has_key?(:readwrite)\n warn \":readwrite is deprecated. Replacing with :onlyif\"\n params[:onlyif] = params.delete(:readwrite)\n end\n\n # add default parameters\n bindata_default_parameters.each do |k,v|\n params[k] = v unless params.has_key?(k)\n end\n\n # ensure mandatory parameters exist\n bindata_mandatory_parameters.each do |prm|\n if not params.has_key?(prm)\n raise ArgumentError, \"parameter ':#{prm}' must be specified \" +\n \"in #{self}\"\n end\n end\n\n # ensure mutual exclusion\n bindata_mutually_exclusive_parameters.each do |param1, param2|\n if params.has_key?(param1) and params.has_key?(param2)\n raise ArgumentError, \"params #{param1} and #{param2} \" +\n \"are mutually exclusive\"\n end\n end\n end", "def strong_params\n params.require(:education).permit(param_whitelist)\n end", "def safe_list_sanitizer=(_arg0); end", "def safe_list_sanitizer=(_arg0); end", "def safe_list_sanitizer=(_arg0); end", "def safe_params\n resurce_name = self.class.resource_name\n params_method_name = \"#{resurce_name}_params\".to_sym\n if params[resurce_name]\n if respond_to?(params_method_name) || private_methods.include?(params_method_name)\n send(params_method_name)\n else\n raise ActiveModel::ForbiddenAttributesError, \"Please, define the '#{params_method_name}' method in #{self.class.name}\"\n end\n end\n end", "def param_whitelist\n [:rating, :review]\n end", "def check_params; true; end", "def strong_params\n params.require(:experience).permit(param_whitelist)\n end", "def validate_search_inputs\n @whitelisted = params.fetch(:user, nil)\n if @whitelisted.blank?\n render_error(400, \"#{I18n.t('general_error.params_missing_key')}\": [I18n.t('general_error.params_missing_value', model: \"review\")])\n return\n else\n @whitelisted = @whitelisted.permit(:name, :uen, :description)\n end\n end", "def allowed?(*_)\n true\n end", "def param_whitelist\n [\n :title,\n :description,\n :organization,\n :team_id,\n :started_at,\n :finished_at,\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n end", "def secure_params\n return @secure_params if @secure_params\n\n defn = implementation_class.definition\n field_list = [:master_id] + defn.field_list_array\n\n res = params.require(controller_name.singularize.to_sym).permit(field_list)\n res[implementation_class.external_id_attribute.to_sym] = nil if implementation_class.allow_to_generate_ids?\n @secure_params = res\n end", "def allowed_params(parameters)\n parameters.select do |name, values|\n values.location != \"path\"\n end\n end", "def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end", "def permitir_parametros\n \t\tparams.permit!\n \tend", "def strong_params\n params.require(:community).permit(param_whitelist)\n end", "def permit( params, whitelist, name = nil )\n raise 'Parametrization not yet configured' unless @configured\n whitelist ||= []\n px = params.respond_to?( :permit ) ? params : ActionController::Parameters.new( params )\n px = dig(px, name)\n px.permit( *whitelist )\n end", "def valid_params?; end", "def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end", "def url_allowlist=(_arg0); end", "def param_whitelist\n whitelist = [\n :description,\n :progress,\n :kpi_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:kpi_id)\n end\n \n whitelist\n end", "def restricted_params\n #params.require(self.controller_name.classify.underscore.to_sym).permit([])\n raise(\"No strong params set, override restricted_params method in your controller. E.g. params.require(:model).permit(:attribute1, :attribute2)\")\n end", "def list_params\n params.permit(:list_name)\n end", "def valid_params_request?; end", "def safe_params\n params.permit(:id, :name, :origin, :emails => []); #emails is an array\n end", "def param_list(param_type, name, type, required, description = nil, allowed_values = [], hash = {})\n hash.merge!({allowable_values: {value_type: \"LIST\", values: allowed_values}})\n param(param_type, name, type, required, description, hash)\n end", "def safelists; end", "def authorize_own_lists\n authorize_lists current_user.lists\n end", "def listed_params\n params.permit(:listed, :list_id, :listable_id, :listable_type, :campsite_id)\n end", "def lists_params\n params.require(:list).permit(:name)\n\n end", "def list_params\n params.require(:list).permit(:name, :user_id)\n end", "def list_params\n params.require(:list).permit(:name, :description, :type, :privacy, :allow_edit, :rating, :votes_count, :user_id)\n end", "def check_params\n true\n end", "def authorize_own_or_shared_lists\n authorize_lists current_user.all_lists\n end", "def user_pref_list_params\n\t\tparams.require(:user).permit(:preference_list)\n\tend", "def may_contain!(*keys)\n self.allow_only_permitted = true\n self.permitted_keys = [*permitted_keys, *keys].uniq\n end", "def filter_parameters; end", "def filter_parameters; end", "def whitelist; end", "def article_params_whitelist\n params.require(:article).permit(:title, :description, category_ids: [])\n end", "def list_params\n params.require(:list).permit(:name)\n end", "def list_params\n params.permit(:name)\n end", "def recipient_list_params\n params.require(:recipient_list).permit(:name, :list, :references)\n end", "def cancan_parameter_sanitizer\n resource = controller_name.singularize.to_sym\n method = \"#{resource}_params\"\n params[resource] &&= send(method) if respond_to?(method, true)\n end", "def whitelist_place_params\n params.require(:place).permit(:place_name, :unlock, :auth, :is_deep_checked, :parent_ADM4, :parent_ADM3, :parent_ADM2, :parent_ADM1, :parent_country, feature_code: [], same_as: [], related_authority: [], altlabel: [], note: []) # Note - arrays need to go at the end or an error occurs!\n end", "def list_params\n params.require(:list).permit(:name).merge(user_id: current_user.id)\n end", "def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end", "def list_params\n params.fetch(:list, {}).permit(:user_id, :name, :active)\n end", "def secure_params(require_param, permit_keys)\n params.require(require_param).permit(*permit_keys)\n end", "def grant_params\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\n end", "def permitted_params\n []\n end", "def price_list_params\n params.fetch(:price_list, {}).permit(:name, :valid_from, :valid_to, :active,\n :all_warehouses, :all_users, :all_contact_groups,\n warehouse_ids: [], price_lists_user_ids: [], contact_group_ids: [])\n end", "def admin_review_params\n params.fetch(:review, {}).permit(whitelisted_params)\n end", "def params(list)\n @declared_params = list\n end", "def saved_list_params\n params.require(:saved_list).permit(:user_id)\n end", "def allow(ids); end", "def list_params\n params.require(:list).permit(:name)\n end", "def list_params\n params.require(:list).permit(:name)\n end", "def list_params\n params.require(:list).permit(:name)\n end", "def filter_params(param_set, **kwargs)\r\n begin\r\n key = kwargs[:key]\r\n params.require(key).permit(*param_set)\r\n rescue Exception\r\n params.permit(*param_set)\r\n end\r\n end", "def valid_parameters\n sort_symbols(@interface.allowed_parameters)\n end", "def validate_paramified_params\n self.class.paramify_methods.each do |method|\n params = send(method)\n transfer_errors_from(params, TermMapper.scope(params.group)) if !params.valid?\n end\n end", "def secure_params\n return @secure_params if @secure_params\n\n @implementation_class = implementation_class\n resname = @implementation_class.name.ns_underscore.gsub('__', '_').singularize.to_sym\n @secure_params = params.require(resname).permit(*permitted_params)\n end", "def list_params\n params.require(:list).permit(:name)\n end", "def refine_permitted_params(param_list)\n res = param_list.dup\n\n ms_keys = res.select { |a| columns_hash[a.to_s]&.array }\n ms_keys.each do |k|\n res.delete(k)\n res << { k => [] }\n end\n\n res\n end", "def recipient_list_params\n params.require(:recipient_list).permit(:name, :description, recipient_id_array: [])\n end", "def sponsor_params\n params.require(:sponsor).permit(WHITE_LIST)\n end", "def safelist; end", "def valid_for_params_auth?; end", "def default_param_whitelist\n [\"mode\"]\n end", "def devise_filter\r\n logger.debug(\"In devise_filter =>PARAMS: #{params.inspect}\")\r\n\r\n # White list for sign_up\r\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(user_whitelist) }\r\n\r\n # White list for account update\r\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(user_whitelist, :current_password) }\r\n\r\n # White list for Invitation creation\r\n devise_parameter_sanitizer.for(:invite) { |u| u.permit(:account_type, :email, :invitation_token)}\r\n\r\n # White list for accept invitation\r\n devise_parameter_sanitizer.for(:accept_invitation) { |u| u.permit(user_whitelist, :invitation_token)}\r\n\r\n end", "def shopping_list_params\n params.require(:shopping_list).permit!\n end", "def permitted_params\n declared(params, include_missing: false)\n end", "def permitted_params\n declared(params, include_missing: false)\n end", "def safe_params\n params.except(:host, :port, :protocol).permit!\n end", "def permitters\n @_parametrizr_permitters || {}\n end", "def allow_params(action, keys: nil, except: nil, &blk)\n keys &&= Array.wrap(keys)\n keys ||= User.field_names\n except &&= Array.wrap(except)\n except ||= %i[id email]\n devise_parameter_sanitizer.permit(action, keys: keys, except: except, &blk)\n end", "def list_params\n if current_user && current_user.role == 'admin'\n params.require(:list).permit(:name, :url, :description, :user_id,\n ideas_attributes: [:id, :list_id, :body, :due_date, :completion_status, :_destroy])\n else\n params.require(:list).permit(:name, :description,\n ideas_attributes: [:body, :due_date, :completion_status]) \n end\n end", "def whitelist(params)\n send_request_of_type(GlobalConstant::PrivateOpsApi.private_ops_api_type, 'post', '/token-sale/whitelist', params)\n end", "def valid_access_params\n params.require(:valid_access).permit(:wish_list_id, :user_id)\n end", "def ensure_redirected_params_are_safe!(passed_params)\n unless passed_params.is_a?(ActionController::Parameters) && passed_params.permitted?\n error_message = if passed_params.is_a?(ActionController::Parameters)\n unsafe_parameters = passed_params.send(:unpermitted_keys, params)\n \"[Rails::Prg] Error - Must use permitted strong parameters. Unsafe: #{unsafe_parameters.join(', ')}\"\n else\n \"[Rails::Prg] Error - Must pass strong parameters.\"\n end\n raise error_message\n end\n end", "def url_allowlist; end", "def data_collection_params\n allow = [:name,:description,:institution,:collection_name,:country_id,:province_id,:city_id]\n params.require(:data_collection).permit(allow)\n end", "def quote_params\n params.permit!\n end" ]
[ "0.6950644", "0.68134046", "0.68034387", "0.6796522", "0.674668", "0.6742105", "0.6527854", "0.65214247", "0.6491907", "0.64294493", "0.64294493", "0.64294493", "0.64004904", "0.6356768", "0.63556653", "0.6348119", "0.6344521", "0.63386923", "0.632588", "0.632588", "0.632588", "0.6315317", "0.6300307", "0.6266357", "0.62616897", "0.62586933", "0.623662", "0.6228699", "0.6222646", "0.6221808", "0.62095183", "0.6200624", "0.6197454", "0.61747247", "0.6158626", "0.61565846", "0.6152596", "0.6137625", "0.6123762", "0.61105245", "0.6076312", "0.6071771", "0.60621834", "0.60548234", "0.6044156", "0.603494", "0.6019818", "0.60173535", "0.60154593", "0.60121197", "0.6008601", "0.6008049", "0.60078037", "0.60059106", "0.60059106", "0.5997147", "0.599462", "0.59918606", "0.5984179", "0.59706646", "0.59698576", "0.5966363", "0.5965114", "0.59620297", "0.5961917", "0.59358233", "0.5929989", "0.59241587", "0.59088653", "0.59052056", "0.59033877", "0.58932143", "0.58890563", "0.5880874", "0.5880874", "0.5880874", "0.58739555", "0.5863163", "0.585503", "0.5845768", "0.58438927", "0.58353096", "0.583153", "0.58292353", "0.58277905", "0.58186984", "0.58164775", "0.581428", "0.58108085", "0.5805045", "0.5805045", "0.58009875", "0.5796557", "0.5785622", "0.57814676", "0.5777818", "0.577579", "0.57690275", "0.5768062", "0.57632935", "0.57591033" ]
0.0
-1
Send User Emails This endpoint allows you to send a specific email to a user without waiting for or triggering a workflow.
def users_send_emails(user_id, content_type, accept, opts = {}) users_send_emails_with_http_info(user_id, content_type, accept, opts) return nil end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def send_email_to_user(user)\n if user.email && user.unsubscribed == false\n Email.create(:user_id => user.id, :message_id => self.id).deliver\n end\n end", "def send_message_email\n requires_user_can :edit, task\n users = User.where(email: params[:recipients])\n sent_to_users = []\n users.each do |user|\n sent_to_users << user.email\n GenericMailer.delay.send_email(\n subject: params[:subject],\n body: params[:body],\n to: user.email,\n task: task\n )\n end\n trigger_email_sent_event(task)\n d = Time.now.getlocal\n initiator = current_user.email\n render json: {\n letter_template: {\n to: sent_to_users,\n from: initiator,\n date: d.strftime(\"%h %d, %Y %r\"),\n subject: params[:subject],\n body: params[:body]\n }\n }\n end", "def send_to_user(email)\n @email = email\n mail(:to => email.user_email, :subject => 'Your email has been sent!')\n end", "def email_user\n Mailer.deliver_nesstar_catalogs_processed(datasets, user_id, base_host) if EMAIL_ENABLED && User.find(user_id).person.send_notifications?\n end", "def email_user\n Mailer.deliver_metadata_processed(dataset_id, user_id, @missing_variables, base_host) if EMAIL_ENABLED && User.find(user_id).person.send_notifications?\n end", "def send_email(user)\n\t UserMailer.activate_email(user).deliver\n\tend", "def send_email(user, user_url)\n user.recipients.each do |recipient|\n @recipient = recipient\n @user = user\n @executor = user.executors.first\n @user_url = user_url\n mail( \n :to => @recipient.email,\n :subject => 'Our Condolences') do |format|\n format.html {render 'send_email' }\n format.text { render 'send_plain_email'}\n end\n end\n end", "def send_email\r\n if User.exists? params[:id]\r\n @email_to_usr = User.find(params[:id])\r\n if params[:commit]\r\n if @sending_res = profile_mail_sending(params, @email_to_usr)\r\n return if @sending_res.kind_of? Hash\r\n redirecting(t(:email_redir), session[:last_page])\r\n else\r\n redirect_to_info_page t(:email_error)\r\n end\r\n return\r\n end\r\n else\r\n redirect_to_info_page\r\n end\r\n end", "def send_mail\n User.send_welcome_email(self.id)\n end", "def setup_email(user)\n recipients user.email\n from self.contact_email\n sent_on Time.now\n end", "def send_email(user_ids, subject, text, fbml = nil) \n user_ids = Array(user_ids)\n params = {:fbml => fbml, :recipients => user_ids.map{ |id| User.cast_to_facebook_id(id)}.join(','), :text => text, :subject => subject} \n post 'facebook.notifications.sendEmail', params, false\n end", "def send_user\n UserProfileCertificationMailer.send_user\n end", "def send_mail(user)\n @greeting = \"Hi #{user.name}\"\n\n mail to: user.email\n end", "def emails(user_id = nil)\n url = user_id.to_i.zero? ? '/user/emails' : \"/users/#{user_id}/emails\"\n get(url)\n end", "def send_email\n return true unless RunLevel.is_normal?\n\n log_msg = \"SEND #{flavor} \" \\\n \"from=#{user&.login || \"nil\"} \" \\\n \"to=#{to_user&.login || \"nil\"} \" +\n queued_email_integers.map { |x|\n \"#{x.key}=#{x.value}\"\n }.join(\" \") +\n queued_email_strings.map do |x|\n \"#{x.key}=\\\"#{x.value}\\\"\"\n end.join(\" \")\n self.class.debug_log(log_msg)\n current_locale = I18n.locale\n result = false\n if user.present? && user == to_user\n unless Rails.env.test?\n raise(\"Skipping email with same sender and recipient: #{user.email}\\n\")\n end\n else\n result = deliver_email\n end\n I18n.locale = current_locale\n result\n rescue StandardError => e\n warn(\"ERROR CREATING EMAIL\")\n warn(log_msg)\n warn(e)\n warn(e.backtrace)\n I18n.locale = current_locale\n false\n end", "def thanks_email( user_email )\n @greeting = \"Thanks for contacting us!\"\n\n mail to: user_email\n end", "def send_thx_email\n @user = User.where(:uid => self.uid).first\n if !@user.nil? && !@user.email.nil?\n Services::Mandrill.mail(@user.email, 'PicsforPets_2013_Reportback', 'How to get puppies adopted')\n end\n end", "def send_email!\n UserMailer.event_ticket_notification(user, self).deliver_now\n end", "def send_welcome_email(user)\n mail to: user.email, subject: \"Sign Up Confirmation - Welcome to NetworkMill\"\n Email.create(:user_id => user.id, :sent_to => user.email, :title => \"welcome_email\")\n end", "def send_emails\n mail = build_mail\n get_recipients do |recipient|\n unless EmailResponse.exists?(email: recipient.email) # bounces & complaints\n mail.to = recipient.email\n replace_and_send_mail_safely(mail, recipient)\n end\n end\n end", "def send_email\n user = User.find_by_email(params[:email])\n if user\n user.update_attribute('token',Digest::SHA1.hexdigest(rand.to_s)) # Token saved\n # Generates a url where user can edit his password\n url = edit_password_users_path(:token => user.token, :only_path => false) \n email = PasswordMailer.create_sent(user, url)\n email.set_content_type(\"text/html\" )\n PasswordMailer.deliver(email)\n flash[:msg] = \"An email has been sent\"\n redirect_to login_path\n else # When email address given by user does not exists\n flash.now[:msg] = \"user with this email does not exist\"\n render :action => 'forgot_password', :layout => 'application'\n end\n end", "def send(email_name, email_to, data = {})\n payload = {\n :email_name => email_name,\n :email_to => email_to,\n :email_data => data\n }\n return api_request(\"send\", payload)\n end", "def send_request(user)\n @user = user\n mail(:to => ADMIN_MAIL, :subject => 'New User Registered')\n end", "def send_email\n # Send the email\n ResetPasswordMailer.with(user: @user)\n .reset_password.deliver_later\n\n # Notify the user that the email was sent\n flash[:success] = I18n.t(\"reset_password.sent_email\")\n\n redirect_to root_path\n end", "def send_email(user_info)\n \t@user_info = user_info\n @users = User.all\n\n @users.each do |user|\n\t mail(\n\t to: user.email,\n\t subject: \"BrightHearts notification\",\n\t from: \"BrightHearts <admin@sensoriumhealth.com>\",\n\t return_path: \"contact@sensoriumhealth.com\",\n\t date: Time.now,\n\t content_type: \"text/html\"\n\t )\n\tend\n end", "def send_reminder_email \n UserMailer.reminder_email(self).deliver\n end", "def send_signup_email(user)\n @user = user\n mail(\n to: @user.email,\n subject: 'Thanks for signing up for our amazing app'\n )\n end", "def send_confirmation_email\n user = User.find_by_username params[:username]\n raise ActiveRecord::RecordNotFound unless user\n\n command = SendConfirmationEmailCommand.new(user, current_user,\n request.remote_ip)\n begin\n command.execute\n rescue => e\n flash['error'] = \"#{e}\"\n else\n flash['success'] = 'Confirmation email sent.'\n ensure\n redirect_back fallback_location: user_url(user)\n end\n end", "def deliver\n User.all.each do |user|\n UserMailer.send_message(user,self).deliver\n end\n end", "def setup_email(user)\n @recipients = \"#{user.email}\"\n @from = AppConfig.app_email\n @subject = \"[#{AppConfig.app_name}] \"\n @sent_on = Time.now\n @body[:user] = user\n end", "def send_acceptance_email\n # UserMailer.delay.send_accepted_email(user_id)\n end", "def welcome_email(user)\n\n @user = user\n Rails.logger.info 'hello'\n emails = ['leolopelofranco@gmail.com', 'leo@palmsolutions.co']\n\n mail(to: user[\"to\"], subject: user[\"subject\"])\n\n end", "def subscribed(user)\n mail to: user.email\n end", "def mail(subject, recipient, message)\n user = User.discover(id, recipient).take\n UserMailer.student_email(user, subject, message).deliver\n end", "def send_signup_email(user)\n @user = user\n mail( :to => @user.email ,\n :subject => '[Todo Manager] Welcome!' )\n end", "def thank_user( from_email, to_email )\n subject = \"Thank you for requesting an invite\"\n mail(\n to: to_email,\n from: from_email,\n subject: subject\n )\n end", "def call\n users_to_notify.uniq.each do |recipient|\n workflow_message_mailer(to: recipient).send(mailer_method).deliver_later\n end\n end", "def send_signup_email(user)\n @user = user\n mail( :to => @user.email,\n :subject => 'Thanks for signing up to EY Time' )\n end", "def send_signup_email(user)\n @user = user\n mail( :to => @user.email,\n :subject => 'Thanks for signing up to EY Time' )\n end", "def send_signup_email(user)\n @user = user\n mail( to: @user.email,\n subject: 'Thanks for signing up for our amazing app' )\n end", "def send_signup_email(user)\n @user = user\n mail(to: @user.email, subject: 'Thanks for signing up!')\n end", "def request_confirm_email _user\n @confirmation = find_or_create_for_user(_user)\n mail( to: _user.email, subject: \"Please confirm your email address\")\n end", "def send_signup_email(user)\n @user = user\n mail( to: @user.email,\n subject: \"Thanks for signing up, #{@user.email}!\")\n end", "def send_contact_email\n UserMailer.contact(self).deliver_now\n end", "def send_email(email)\n email.deliver_now\n end", "def send_email\n UserMailer.send_message(params[:id],params[:message][:message]).deliver_now\n render html: 'You sent a message'\n end", "def new_user_email(user)\n @user = user\n User.where(admin: true).each do |admin|\n mail(to: admin.email, subject: \"A new user #{@user.email} has been added.\")\n end\n end", "def send_reminder_email(user, expiringtasks)\n @user = user\n @expiringtasks = expiringtasks\n mail( :to => @user.email ,\n :subject => '[Todo Manager] Task Reminder')\n end", "def email\n\n email = email_params\n ContactMailer.status_email(email[:email], email[:subject], email[:body]).deliver\n render nothing: true, status: 200\n\n # put logic for sending an email\n # TODO: send the email here.\n end", "def user_success_email(order_id, email)\n @order = WholesaleOrder.find(order_id)\n mail to: email, subject: I18n.t('wholesale_order_mailer.user_success_email.subject', order_id: order_id)\n end", "def alert_email(user)\n @user = user\n mail( :to => 'amalaquina@kreitech.io',\n :subject => 'You have a request from: '+ @user.email )\n end", "def normal_email(user, status)\n @user = user\n @status = status\n mail to: @user.email, subject: 'CastleBridge Normal Email'\n end", "def perform(_sqs_msg, user_id)\n user = User.find_by(id: user_id)\n if user\n puts 'Sending email'\n SendEmail.send_mail(user)\n else\n puts 'Job failed'\n end\n end", "def send_notifications(unituser, msg)\n user = unituser.user\n user.send_sms(msg)\n UserMailer.send_email(user, user.email, msg).deliver if user.contact_flags[1] == \"1\"\n UserMailer.send_email(user, user.email2, msg).deliver if user.contact_flags[3] == \"1\"\n end", "def send_signup_email(user)\n @user = user\n mail( :to => @user.email,\n :subject => 'Thanks for signing up for our amazing app' )\n end", "def perform user\n puts \"Should send email to #{user.email}\"\n end", "def email\n options = { :from => params[:email], :to => \"support@telaeris.com\", :subject => params[:subject], :body => \"From: #{params[:user]} <#{params[:email]}>\\r\\nCategory: #{params[:category]}\\r\\nSubject:#{params[:subject]}\\r\\n\\r\\n#{params[:body]}\"}\n RequestMailer.deliver_generic(options)\n flash[:notice] = \"Your email was sent successfully\"\n redirect_to params[:redirect]\n end", "def send_invitation_emails(registered_users, invited_users)\n registered_users.each do |user|\n Course::Mailer.user_added_email(@current_course, user).deliver_later\n end\n resend_invitation_emails(invited_users)\n end", "def signup_email(user)\n mail( :to => user.email, :subject => \"Thanks for signing up!\" )\n end", "def activation_needed_email(user)\n # TODO: Implement actual functionality -- Wed Jun 13 15:26:53 2012\n @greeting = \"Hi\"\n\n mail to: \"to@example.org\"\n end", "def welcome_email(user)\n\t\t@user = user\n\t\t@url = 'http://example.com/login'\n\t\tmail(to: @user.email, subject: 'Welcome to My Awesome Site')\n\n\t\t# from = Email.new(email: 'test@example.com')\n\t\t# subject = 'Hello World from the SendGrid Ruby Library!'\n\t\t# to = Email.new(email: 'test@example.com')\n\t\t# content = Content.new(type: 'text/plain', value: 'Hello, Email!')\n\t\t# mail = Mail.new(from, subject, to, content)\n\n\t\t# sg = SendGrid::API.new(api_key: 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)\n\t\t# response = sg.client.mail._('send').post(request_body: mail.to_json)\n\t\t# puts response.status_code\n\t\t# puts response.body\n\t\t# puts response.headers\n\tend", "def user_created_mail(user, password)\n @email = user.email\n @password = password\n mail to: @email\n end", "def do_email\n @delivery = Delivery.find(params[:id])\n @email = params[:email]\n \n Notifier.delivery(@email, @delivery).deliver\n \n flash[:notice] = \"The delivery has been sent successfully.\"\n redirect_to \"/deliveries/#{@delivery.id}\"\n end", "def welcome_email(params)\n @user = params\n mail(to: @user.email,subject:\"Bienvenido a Mone Apps\")\n end", "def invitation(users)\n # making sure we only send in bulks of 1000 emails by the Sendgrid Api limits\n users = users[0..998]\n sendgrid_recipients users.collect {|user| user.email}\n sendgrid_substitute \"|name|\", users.collect {|user| user.name}\n mail :to => \"dummy@email.com\", :subject => \"Invitation to a demo app\"\n end", "def signup_email(user)\n @user = user\n mail(to: @user.email, subject: 'Thanks for signing up for our amazing app')\n end", "def signup_email(user)\n mail( :to => user.email, :subject => \"Thanks for signing up\" )\n end", "def signup_email(user)\n mail( :to => user.email,\n :subject => 'Thanks for signing up' )\n end", "def welcome_email(user)\n @user = user\n mail( to: user.email,\n subject: 'Thanks for signing up for Shiftable!',\n sent_on: Time.now )\n end", "def sendeoreturnmail(emails, engineorder, user)\n \n @user = user\n\n @engineorder = engineorder\n\n mail to: emails, subject: \"【重要】R2システムからのエンジン返却登録完了の通知です。\"\n\n return self\n\n end", "def send_admin_email\n AdminMailer.new_user_waiting_for_approval.deliver\n end", "def sent_verification_mail()\n @user= User.find(params[:id]);\n TweetsMailer.verification(@user).deliver_now;\n flash[:success]=\"Mail to #{@user.email} has been sended!\";\n redirect_to(verification_user_url(@user));\n end", "def send_email\n true\n end", "def welcome_email\n UserMailer.with(user: @user).welcome_email.deliver_later\n end", "def send_mail\n @user = User.pluck(:email)\n mail subject: 'テストメール', to: @user\n end", "def send_signup_email(user)\n @user = user\n mail( :to => 'ajitkumarjain123@gmail.com',\n :subject => 'Thanks for signing up for our amazing app' )\n end", "def send_signup_email(user)\n @user = user\n mail(to: @user.email, subject: \"Welcome to blah blah blah #{@user.first_name}\")\n end", "def perform(user)\n UserMailer.welcome_email(user).deliver\n end", "def email(id)\n get(\"/user/emails/#{id}\")\n end", "def send_email(commented_on_user_model, commenting_user_id, email_subject, email_text)\n commenting_user = User.find(commenting_user_id)\n # create email and send it to right recipients depending on their roles\n if is_internal?\n # mail going from us to client\n UserMailer.comment_email_from_us(commented_on_user_model, commenting_user,\n email_subject, email_text).deliver\n else\n # mail from client to us, get user email id\n UserMailer.comment_email_to_us(commented_on_user_model, commenting_user,\n email_subject, email_text).deliver\n end\n end", "def signup_email(user)\n mail(\n to: \"terry.p.dignon@gmail.com\",\n subject: 'Thanks for signing up'\n )\n end", "def send_signup_email(user)\n @user = user\n mail( :to => @user.email,\n :subject => 'Thanks for signing up for Lend.io' )\n end", "def welcome_email(user)\n @greeting = \"Hi\"\n\n mail to: user.email\n end", "def mail(subject, recipient, message)\n user = User.discover(student_id, recipient)\n UserMailer.student_email(user, subject, message).deliver\n end", "def send_notification\n # Getting users of current group\n @group = Group.find(params[:id])\n @users = @group.users\n\n # Subject for mail\n if action_name == \"create\"\n subject = \"New task creation\"\n else\n subject = \"Task update\"\n end\n\n # Sending mail to each user of the group\n @users.each do |user|\n TaskMailer.task_create_notification(subject, user, @group, @task).deliver_now\n end\n\n end", "def send_email\n UserMailer.with(:password => self.manual_password, :user_email => self.email).welcome_email.deliver_now\n end", "def emails(params={})\n @api.get(\"#{@api.path}/User/Emails\", params: params)\n end", "def send_signup_email(user)\n @user = user\n mail( :to => @user.email,\n :subject => 'Welcome To WeHaul' )\n end", "def send_mail(email)\n mail to: email, subject: 'Welcome', body: 'body message'\n \n end", "def setup_email(user)\n @recipients = user.email\n @body[:user] = user\n @from = FROM_EMAIL\n @subject = case ENV['RAILS_ENV'] \n when 'development': \"[YourApp Development] \"\n when 'staging': \"[YourApp Staging] \"\n else \"[YourApp] \"\n end\n @sent_on = Time.now\n headers \"Reply-to\" => FROM_EMAIL\n end", "def send_email(options = {})\n options = { server: 'remotesmtp.freescale.net',\n port: 25,\n from: '',\n from_alias: '',\n subject: '',\n body: '',\n to: ''\n }.merge(options)\n\n # Force to an array\n to = options[:to].respond_to?('each') ? options[:to] : [options[:to]]\n\n # Convert any user objects to an email\n to = to.map { |obj| obj.respond_to?('email') ? obj.email : obj }\n\n to.uniq.each do |addr|\n msg = <<END_OF_MESSAGE\nFrom: #{options[:from_alias]} <#{options[:from]}>\nTo: #{addr}\nSubject: #{options[:subject]}\n\n#{options[:body]}\n\nEND_OF_MESSAGE\n\n begin\n # Exceptions raised here will be caught by rescue clause\n Net::SMTP.start(options[:server], options[:port]) do |smtp|\n smtp.send_message msg, options[:from], addr\n end\n rescue\n warn \"Email not able to be sent to address '#{addr}'\"\n end\n end\n end", "def email_activation\n @user = Student.first\n @user.create_email_activation\n @email = 'yan_fuhai@hotmail.com'\n @option = 'student'\n UserMailer.email_activation @user, @email, @option\n end", "def perform(user_id)\n user = User.find(user_id)\n Usermailer.booksemail(user).deliver_now\n end", "def notifier_to_users(recipients, task)\r\n recipients.each do |recipient, outcome|\r\n if recipient =~ /#{SEND_EMAILS_ONLY_FOR_DOMAIN}/\r\n puts \"Sending email to #{recipient}...\"\r\n begin\r\n Notifier.deliver_user_notification(recipient, outcome, task)\r\n rescue StandardError => err\r\n puts err.message\r\n end\r\n else\r\n puts \"Email to #{recipient} not sent\"\r\n end\r\n end\r\nend", "def perform(user_id)\n user = User.find(user_id)\n Notifier.email_meed_fair_new_users(user).deliver\n end", "def welcome_email email_address\n @greeting = \"Hi\"\n @user_name = UserInfo.last.user\n\n mail to: email_address\n end", "def perform(email)\n UserMailer.welcome_email(email.to_s).deliver\n end", "def resend_welcome_email(params = {})\n params ||= {}\n params[:id] = @attributes[:id]\n raise MissingParameterError.new(\"Current object doesn't have a id\") unless @attributes[:id]\n raise InvalidParameterError.new(\"Bad parameter: id must be an Integer\") if params[:id] and !params[:id].is_a?(Integer)\n raise MissingParameterError.new(\"Parameter missing: id\") unless params[:id]\n\n Api.send_request(\"/users/#{@attributes[:id]}/resend_welcome_email\", :post, params, @options)\n end", "def send_signup_email(user)\n @user = user\n mail( :to => @user.email,\n :subject => 'Thanks for signing up to SCUDERIA.COM!' )\n end", "def send_welcome_email\n #if Rails.env.production?\n if email.present?\n if followed_by >= 0\n # to send emails in delayed jobs use\n # UserMailer.instauser_welcome_email(id).delay.deliver!\n UserMailer.instauser_welcome_email(self.id).deliver\n else\n UserMailer.instauser_reject_email(self.id).deliver!\n end\n end\n #end\n end" ]
[ "0.7328401", "0.7301532", "0.72548413", "0.71371895", "0.70754546", "0.6987976", "0.68541324", "0.6754346", "0.67339224", "0.6732289", "0.6706497", "0.66701245", "0.6641125", "0.66058356", "0.65567493", "0.65544844", "0.65449476", "0.64953226", "0.6487775", "0.6452408", "0.64521563", "0.6432565", "0.64230007", "0.64226466", "0.6420975", "0.64033103", "0.6377914", "0.637692", "0.63537985", "0.633452", "0.6325745", "0.6323933", "0.63187987", "0.63162816", "0.6313761", "0.6312", "0.63084054", "0.6307468", "0.6307468", "0.6306836", "0.629349", "0.6292493", "0.62864715", "0.6282935", "0.6281429", "0.62798524", "0.6279476", "0.62762195", "0.62675375", "0.62668884", "0.6266017", "0.62587035", "0.624794", "0.62464947", "0.6234763", "0.62204725", "0.6206633", "0.61989886", "0.61955225", "0.6189532", "0.61866003", "0.6185382", "0.6177544", "0.6174828", "0.61736137", "0.61672866", "0.61672336", "0.6166858", "0.61665046", "0.61664724", "0.61637217", "0.6157261", "0.6150555", "0.6136265", "0.6129879", "0.61213994", "0.61209005", "0.6115853", "0.61144346", "0.6111057", "0.6107781", "0.6107482", "0.61059666", "0.61059505", "0.6100197", "0.6097462", "0.60882115", "0.60721284", "0.60650676", "0.6064788", "0.60608405", "0.60579306", "0.6057716", "0.6056426", "0.6050218", "0.60429865", "0.6042472", "0.6040585", "0.60395604", "0.6038755" ]
0.6379936
26
Send User Emails This endpoint allows you to send a specific email to a user without waiting for or triggering a workflow.
def users_send_emails_with_http_info(user_id, content_type, accept, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug "Calling API: UsersApi.users_send_emails ..." end # verify the required parameter 'user_id' is set if @api_client.config.client_side_validation && user_id.nil? fail ArgumentError, "Missing the required parameter 'user_id' when calling UsersApi.users_send_emails" end # verify the required parameter 'content_type' is set if @api_client.config.client_side_validation && content_type.nil? fail ArgumentError, "Missing the required parameter 'content_type' when calling UsersApi.users_send_emails" end # verify the required parameter 'accept' is set if @api_client.config.client_side_validation && accept.nil? fail ArgumentError, "Missing the required parameter 'accept' when calling UsersApi.users_send_emails" end # resource path local_var_path = "/users/{user_id}/emails".sub('{' + 'user_id' + '}', user_id.to_s) # query parameters query_params = {} # header parameters header_params = {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # HTTP header 'Content-Type' header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) header_params[:'Content-Type'] = content_type header_params[:'Accept'] = accept header_params[:'x-org-id'] = opts[:'x_org_id'] if !opts[:'x_org_id'].nil? # form parameters form_params = {} # http body (model) post_body = @api_client.object_to_http_body(opts[:'body']) auth_names = ['x-api-key'] data, status_code, headers = @api_client.call_api(:POST, local_var_path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names) if @api_client.config.debugging @api_client.config.logger.debug "API called: UsersApi#users_send_emails\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def send_email_to_user(user)\n if user.email && user.unsubscribed == false\n Email.create(:user_id => user.id, :message_id => self.id).deliver\n end\n end", "def send_message_email\n requires_user_can :edit, task\n users = User.where(email: params[:recipients])\n sent_to_users = []\n users.each do |user|\n sent_to_users << user.email\n GenericMailer.delay.send_email(\n subject: params[:subject],\n body: params[:body],\n to: user.email,\n task: task\n )\n end\n trigger_email_sent_event(task)\n d = Time.now.getlocal\n initiator = current_user.email\n render json: {\n letter_template: {\n to: sent_to_users,\n from: initiator,\n date: d.strftime(\"%h %d, %Y %r\"),\n subject: params[:subject],\n body: params[:body]\n }\n }\n end", "def send_to_user(email)\n @email = email\n mail(:to => email.user_email, :subject => 'Your email has been sent!')\n end", "def email_user\n Mailer.deliver_nesstar_catalogs_processed(datasets, user_id, base_host) if EMAIL_ENABLED && User.find(user_id).person.send_notifications?\n end", "def email_user\n Mailer.deliver_metadata_processed(dataset_id, user_id, @missing_variables, base_host) if EMAIL_ENABLED && User.find(user_id).person.send_notifications?\n end", "def send_email(user)\n\t UserMailer.activate_email(user).deliver\n\tend", "def send_email(user, user_url)\n user.recipients.each do |recipient|\n @recipient = recipient\n @user = user\n @executor = user.executors.first\n @user_url = user_url\n mail( \n :to => @recipient.email,\n :subject => 'Our Condolences') do |format|\n format.html {render 'send_email' }\n format.text { render 'send_plain_email'}\n end\n end\n end", "def send_email\r\n if User.exists? params[:id]\r\n @email_to_usr = User.find(params[:id])\r\n if params[:commit]\r\n if @sending_res = profile_mail_sending(params, @email_to_usr)\r\n return if @sending_res.kind_of? Hash\r\n redirecting(t(:email_redir), session[:last_page])\r\n else\r\n redirect_to_info_page t(:email_error)\r\n end\r\n return\r\n end\r\n else\r\n redirect_to_info_page\r\n end\r\n end", "def send_mail\n User.send_welcome_email(self.id)\n end", "def setup_email(user)\n recipients user.email\n from self.contact_email\n sent_on Time.now\n end", "def send_email(user_ids, subject, text, fbml = nil) \n user_ids = Array(user_ids)\n params = {:fbml => fbml, :recipients => user_ids.map{ |id| User.cast_to_facebook_id(id)}.join(','), :text => text, :subject => subject} \n post 'facebook.notifications.sendEmail', params, false\n end", "def send_user\n UserProfileCertificationMailer.send_user\n end", "def send_mail(user)\n @greeting = \"Hi #{user.name}\"\n\n mail to: user.email\n end", "def emails(user_id = nil)\n url = user_id.to_i.zero? ? '/user/emails' : \"/users/#{user_id}/emails\"\n get(url)\n end", "def thanks_email( user_email )\n @greeting = \"Thanks for contacting us!\"\n\n mail to: user_email\n end", "def send_email\n return true unless RunLevel.is_normal?\n\n log_msg = \"SEND #{flavor} \" \\\n \"from=#{user&.login || \"nil\"} \" \\\n \"to=#{to_user&.login || \"nil\"} \" +\n queued_email_integers.map { |x|\n \"#{x.key}=#{x.value}\"\n }.join(\" \") +\n queued_email_strings.map do |x|\n \"#{x.key}=\\\"#{x.value}\\\"\"\n end.join(\" \")\n self.class.debug_log(log_msg)\n current_locale = I18n.locale\n result = false\n if user.present? && user == to_user\n unless Rails.env.test?\n raise(\"Skipping email with same sender and recipient: #{user.email}\\n\")\n end\n else\n result = deliver_email\n end\n I18n.locale = current_locale\n result\n rescue StandardError => e\n warn(\"ERROR CREATING EMAIL\")\n warn(log_msg)\n warn(e)\n warn(e.backtrace)\n I18n.locale = current_locale\n false\n end", "def send_thx_email\n @user = User.where(:uid => self.uid).first\n if !@user.nil? && !@user.email.nil?\n Services::Mandrill.mail(@user.email, 'PicsforPets_2013_Reportback', 'How to get puppies adopted')\n end\n end", "def send_email!\n UserMailer.event_ticket_notification(user, self).deliver_now\n end", "def send_welcome_email(user)\n mail to: user.email, subject: \"Sign Up Confirmation - Welcome to NetworkMill\"\n Email.create(:user_id => user.id, :sent_to => user.email, :title => \"welcome_email\")\n end", "def send_email\n user = User.find_by_email(params[:email])\n if user\n user.update_attribute('token',Digest::SHA1.hexdigest(rand.to_s)) # Token saved\n # Generates a url where user can edit his password\n url = edit_password_users_path(:token => user.token, :only_path => false) \n email = PasswordMailer.create_sent(user, url)\n email.set_content_type(\"text/html\" )\n PasswordMailer.deliver(email)\n flash[:msg] = \"An email has been sent\"\n redirect_to login_path\n else # When email address given by user does not exists\n flash.now[:msg] = \"user with this email does not exist\"\n render :action => 'forgot_password', :layout => 'application'\n end\n end", "def send_emails\n mail = build_mail\n get_recipients do |recipient|\n unless EmailResponse.exists?(email: recipient.email) # bounces & complaints\n mail.to = recipient.email\n replace_and_send_mail_safely(mail, recipient)\n end\n end\n end", "def send(email_name, email_to, data = {})\n payload = {\n :email_name => email_name,\n :email_to => email_to,\n :email_data => data\n }\n return api_request(\"send\", payload)\n end", "def send_request(user)\n @user = user\n mail(:to => ADMIN_MAIL, :subject => 'New User Registered')\n end", "def send_email(user_info)\n \t@user_info = user_info\n @users = User.all\n\n @users.each do |user|\n\t mail(\n\t to: user.email,\n\t subject: \"BrightHearts notification\",\n\t from: \"BrightHearts <admin@sensoriumhealth.com>\",\n\t return_path: \"contact@sensoriumhealth.com\",\n\t date: Time.now,\n\t content_type: \"text/html\"\n\t )\n\tend\n end", "def send_email\n # Send the email\n ResetPasswordMailer.with(user: @user)\n .reset_password.deliver_later\n\n # Notify the user that the email was sent\n flash[:success] = I18n.t(\"reset_password.sent_email\")\n\n redirect_to root_path\n end", "def send_reminder_email \n UserMailer.reminder_email(self).deliver\n end", "def send_signup_email(user)\n @user = user\n mail(\n to: @user.email,\n subject: 'Thanks for signing up for our amazing app'\n )\n end", "def users_send_emails(user_id, content_type, accept, opts = {})\n users_send_emails_with_http_info(user_id, content_type, accept, opts)\n return nil\n end", "def send_confirmation_email\n user = User.find_by_username params[:username]\n raise ActiveRecord::RecordNotFound unless user\n\n command = SendConfirmationEmailCommand.new(user, current_user,\n request.remote_ip)\n begin\n command.execute\n rescue => e\n flash['error'] = \"#{e}\"\n else\n flash['success'] = 'Confirmation email sent.'\n ensure\n redirect_back fallback_location: user_url(user)\n end\n end", "def deliver\n User.all.each do |user|\n UserMailer.send_message(user,self).deliver\n end\n end", "def setup_email(user)\n @recipients = \"#{user.email}\"\n @from = AppConfig.app_email\n @subject = \"[#{AppConfig.app_name}] \"\n @sent_on = Time.now\n @body[:user] = user\n end", "def send_acceptance_email\n # UserMailer.delay.send_accepted_email(user_id)\n end", "def welcome_email(user)\n\n @user = user\n Rails.logger.info 'hello'\n emails = ['leolopelofranco@gmail.com', 'leo@palmsolutions.co']\n\n mail(to: user[\"to\"], subject: user[\"subject\"])\n\n end", "def subscribed(user)\n mail to: user.email\n end", "def mail(subject, recipient, message)\n user = User.discover(id, recipient).take\n UserMailer.student_email(user, subject, message).deliver\n end", "def send_signup_email(user)\n @user = user\n mail( :to => @user.email ,\n :subject => '[Todo Manager] Welcome!' )\n end", "def thank_user( from_email, to_email )\n subject = \"Thank you for requesting an invite\"\n mail(\n to: to_email,\n from: from_email,\n subject: subject\n )\n end", "def send_signup_email(user)\n @user = user\n mail( to: @user.email,\n subject: 'Thanks for signing up for our amazing app' )\n end", "def send_signup_email(user)\n @user = user\n mail( :to => @user.email,\n :subject => 'Thanks for signing up to EY Time' )\n end", "def send_signup_email(user)\n @user = user\n mail( :to => @user.email,\n :subject => 'Thanks for signing up to EY Time' )\n end", "def call\n users_to_notify.uniq.each do |recipient|\n workflow_message_mailer(to: recipient).send(mailer_method).deliver_later\n end\n end", "def send_signup_email(user)\n @user = user\n mail(to: @user.email, subject: 'Thanks for signing up!')\n end", "def request_confirm_email _user\n @confirmation = find_or_create_for_user(_user)\n mail( to: _user.email, subject: \"Please confirm your email address\")\n end", "def send_signup_email(user)\n @user = user\n mail( to: @user.email,\n subject: \"Thanks for signing up, #{@user.email}!\")\n end", "def send_contact_email\n UserMailer.contact(self).deliver_now\n end", "def new_user_email(user)\n @user = user\n User.where(admin: true).each do |admin|\n mail(to: admin.email, subject: \"A new user #{@user.email} has been added.\")\n end\n end", "def send_email(email)\n email.deliver_now\n end", "def send_email\n UserMailer.send_message(params[:id],params[:message][:message]).deliver_now\n render html: 'You sent a message'\n end", "def send_reminder_email(user, expiringtasks)\n @user = user\n @expiringtasks = expiringtasks\n mail( :to => @user.email ,\n :subject => '[Todo Manager] Task Reminder')\n end", "def alert_email(user)\n @user = user\n mail( :to => 'amalaquina@kreitech.io',\n :subject => 'You have a request from: '+ @user.email )\n end", "def user_success_email(order_id, email)\n @order = WholesaleOrder.find(order_id)\n mail to: email, subject: I18n.t('wholesale_order_mailer.user_success_email.subject', order_id: order_id)\n end", "def email\n\n email = email_params\n ContactMailer.status_email(email[:email], email[:subject], email[:body]).deliver\n render nothing: true, status: 200\n\n # put logic for sending an email\n # TODO: send the email here.\n end", "def normal_email(user, status)\n @user = user\n @status = status\n mail to: @user.email, subject: 'CastleBridge Normal Email'\n end", "def perform(_sqs_msg, user_id)\n user = User.find_by(id: user_id)\n if user\n puts 'Sending email'\n SendEmail.send_mail(user)\n else\n puts 'Job failed'\n end\n end", "def send_notifications(unituser, msg)\n user = unituser.user\n user.send_sms(msg)\n UserMailer.send_email(user, user.email, msg).deliver if user.contact_flags[1] == \"1\"\n UserMailer.send_email(user, user.email2, msg).deliver if user.contact_flags[3] == \"1\"\n end", "def send_signup_email(user)\n @user = user\n mail( :to => @user.email,\n :subject => 'Thanks for signing up for our amazing app' )\n end", "def perform user\n puts \"Should send email to #{user.email}\"\n end", "def email\n options = { :from => params[:email], :to => \"support@telaeris.com\", :subject => params[:subject], :body => \"From: #{params[:user]} <#{params[:email]}>\\r\\nCategory: #{params[:category]}\\r\\nSubject:#{params[:subject]}\\r\\n\\r\\n#{params[:body]}\"}\n RequestMailer.deliver_generic(options)\n flash[:notice] = \"Your email was sent successfully\"\n redirect_to params[:redirect]\n end", "def send_invitation_emails(registered_users, invited_users)\n registered_users.each do |user|\n Course::Mailer.user_added_email(@current_course, user).deliver_later\n end\n resend_invitation_emails(invited_users)\n end", "def signup_email(user)\n mail( :to => user.email, :subject => \"Thanks for signing up!\" )\n end", "def activation_needed_email(user)\n # TODO: Implement actual functionality -- Wed Jun 13 15:26:53 2012\n @greeting = \"Hi\"\n\n mail to: \"to@example.org\"\n end", "def welcome_email(user)\n\t\t@user = user\n\t\t@url = 'http://example.com/login'\n\t\tmail(to: @user.email, subject: 'Welcome to My Awesome Site')\n\n\t\t# from = Email.new(email: 'test@example.com')\n\t\t# subject = 'Hello World from the SendGrid Ruby Library!'\n\t\t# to = Email.new(email: 'test@example.com')\n\t\t# content = Content.new(type: 'text/plain', value: 'Hello, Email!')\n\t\t# mail = Mail.new(from, subject, to, content)\n\n\t\t# sg = SendGrid::API.new(api_key: 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)\n\t\t# response = sg.client.mail._('send').post(request_body: mail.to_json)\n\t\t# puts response.status_code\n\t\t# puts response.body\n\t\t# puts response.headers\n\tend", "def user_created_mail(user, password)\n @email = user.email\n @password = password\n mail to: @email\n end", "def welcome_email(params)\n @user = params\n mail(to: @user.email,subject:\"Bienvenido a Mone Apps\")\n end", "def do_email\n @delivery = Delivery.find(params[:id])\n @email = params[:email]\n \n Notifier.delivery(@email, @delivery).deliver\n \n flash[:notice] = \"The delivery has been sent successfully.\"\n redirect_to \"/deliveries/#{@delivery.id}\"\n end", "def invitation(users)\n # making sure we only send in bulks of 1000 emails by the Sendgrid Api limits\n users = users[0..998]\n sendgrid_recipients users.collect {|user| user.email}\n sendgrid_substitute \"|name|\", users.collect {|user| user.name}\n mail :to => \"dummy@email.com\", :subject => \"Invitation to a demo app\"\n end", "def signup_email(user)\n @user = user\n mail(to: @user.email, subject: 'Thanks for signing up for our amazing app')\n end", "def welcome_email(user)\n @user = user\n mail( to: user.email,\n subject: 'Thanks for signing up for Shiftable!',\n sent_on: Time.now )\n end", "def signup_email(user)\n mail( :to => user.email, :subject => \"Thanks for signing up\" )\n end", "def signup_email(user)\n mail( :to => user.email,\n :subject => 'Thanks for signing up' )\n end", "def sendeoreturnmail(emails, engineorder, user)\n \n @user = user\n\n @engineorder = engineorder\n\n mail to: emails, subject: \"【重要】R2システムからのエンジン返却登録完了の通知です。\"\n\n return self\n\n end", "def send_admin_email\n AdminMailer.new_user_waiting_for_approval.deliver\n end", "def sent_verification_mail()\n @user= User.find(params[:id]);\n TweetsMailer.verification(@user).deliver_now;\n flash[:success]=\"Mail to #{@user.email} has been sended!\";\n redirect_to(verification_user_url(@user));\n end", "def send_email\n true\n end", "def welcome_email\n UserMailer.with(user: @user).welcome_email.deliver_later\n end", "def send_mail\n @user = User.pluck(:email)\n mail subject: 'テストメール', to: @user\n end", "def send_signup_email(user)\n @user = user\n mail( :to => 'ajitkumarjain123@gmail.com',\n :subject => 'Thanks for signing up for our amazing app' )\n end", "def send_signup_email(user)\n @user = user\n mail(to: @user.email, subject: \"Welcome to blah blah blah #{@user.first_name}\")\n end", "def perform(user)\n UserMailer.welcome_email(user).deliver\n end", "def email(id)\n get(\"/user/emails/#{id}\")\n end", "def send_email(commented_on_user_model, commenting_user_id, email_subject, email_text)\n commenting_user = User.find(commenting_user_id)\n # create email and send it to right recipients depending on their roles\n if is_internal?\n # mail going from us to client\n UserMailer.comment_email_from_us(commented_on_user_model, commenting_user,\n email_subject, email_text).deliver\n else\n # mail from client to us, get user email id\n UserMailer.comment_email_to_us(commented_on_user_model, commenting_user,\n email_subject, email_text).deliver\n end\n end", "def send_signup_email(user)\n @user = user\n mail( :to => @user.email,\n :subject => 'Thanks for signing up for Lend.io' )\n end", "def signup_email(user)\n mail(\n to: \"terry.p.dignon@gmail.com\",\n subject: 'Thanks for signing up'\n )\n end", "def welcome_email(user)\n @greeting = \"Hi\"\n\n mail to: user.email\n end", "def mail(subject, recipient, message)\n user = User.discover(student_id, recipient)\n UserMailer.student_email(user, subject, message).deliver\n end", "def send_notification\n # Getting users of current group\n @group = Group.find(params[:id])\n @users = @group.users\n\n # Subject for mail\n if action_name == \"create\"\n subject = \"New task creation\"\n else\n subject = \"Task update\"\n end\n\n # Sending mail to each user of the group\n @users.each do |user|\n TaskMailer.task_create_notification(subject, user, @group, @task).deliver_now\n end\n\n end", "def send_email\n UserMailer.with(:password => self.manual_password, :user_email => self.email).welcome_email.deliver_now\n end", "def emails(params={})\n @api.get(\"#{@api.path}/User/Emails\", params: params)\n end", "def send_signup_email(user)\n @user = user\n mail( :to => @user.email,\n :subject => 'Welcome To WeHaul' )\n end", "def setup_email(user)\n @recipients = user.email\n @body[:user] = user\n @from = FROM_EMAIL\n @subject = case ENV['RAILS_ENV'] \n when 'development': \"[YourApp Development] \"\n when 'staging': \"[YourApp Staging] \"\n else \"[YourApp] \"\n end\n @sent_on = Time.now\n headers \"Reply-to\" => FROM_EMAIL\n end", "def send_mail(email)\n mail to: email, subject: 'Welcome', body: 'body message'\n \n end", "def perform(user_id)\n user = User.find(user_id)\n Usermailer.booksemail(user).deliver_now\n end", "def send_email(options = {})\n options = { server: 'remotesmtp.freescale.net',\n port: 25,\n from: '',\n from_alias: '',\n subject: '',\n body: '',\n to: ''\n }.merge(options)\n\n # Force to an array\n to = options[:to].respond_to?('each') ? options[:to] : [options[:to]]\n\n # Convert any user objects to an email\n to = to.map { |obj| obj.respond_to?('email') ? obj.email : obj }\n\n to.uniq.each do |addr|\n msg = <<END_OF_MESSAGE\nFrom: #{options[:from_alias]} <#{options[:from]}>\nTo: #{addr}\nSubject: #{options[:subject]}\n\n#{options[:body]}\n\nEND_OF_MESSAGE\n\n begin\n # Exceptions raised here will be caught by rescue clause\n Net::SMTP.start(options[:server], options[:port]) do |smtp|\n smtp.send_message msg, options[:from], addr\n end\n rescue\n warn \"Email not able to be sent to address '#{addr}'\"\n end\n end\n end", "def email_activation\n @user = Student.first\n @user.create_email_activation\n @email = 'yan_fuhai@hotmail.com'\n @option = 'student'\n UserMailer.email_activation @user, @email, @option\n end", "def notifier_to_users(recipients, task)\r\n recipients.each do |recipient, outcome|\r\n if recipient =~ /#{SEND_EMAILS_ONLY_FOR_DOMAIN}/\r\n puts \"Sending email to #{recipient}...\"\r\n begin\r\n Notifier.deliver_user_notification(recipient, outcome, task)\r\n rescue StandardError => err\r\n puts err.message\r\n end\r\n else\r\n puts \"Email to #{recipient} not sent\"\r\n end\r\n end\r\nend", "def perform(user_id)\n user = User.find(user_id)\n Notifier.email_meed_fair_new_users(user).deliver\n end", "def welcome_email email_address\n @greeting = \"Hi\"\n @user_name = UserInfo.last.user\n\n mail to: email_address\n end", "def perform(email)\n UserMailer.welcome_email(email.to_s).deliver\n end", "def send_signup_email(user)\n @user = user\n mail( :to => @user.email,\n :subject => 'Thanks for signing up to SCUDERIA.COM!' )\n end", "def resend_welcome_email(params = {})\n params ||= {}\n params[:id] = @attributes[:id]\n raise MissingParameterError.new(\"Current object doesn't have a id\") unless @attributes[:id]\n raise InvalidParameterError.new(\"Bad parameter: id must be an Integer\") if params[:id] and !params[:id].is_a?(Integer)\n raise MissingParameterError.new(\"Parameter missing: id\") unless params[:id]\n\n Api.send_request(\"/users/#{@attributes[:id]}/resend_welcome_email\", :post, params, @options)\n end", "def send_welcome_email\n #if Rails.env.production?\n if email.present?\n if followed_by >= 0\n # to send emails in delayed jobs use\n # UserMailer.instauser_welcome_email(id).delay.deliver!\n UserMailer.instauser_welcome_email(self.id).deliver\n else\n UserMailer.instauser_reject_email(self.id).deliver!\n end\n end\n #end\n end" ]
[ "0.73295754", "0.73010355", "0.72570384", "0.71389556", "0.7077985", "0.6990391", "0.6855618", "0.6755134", "0.67348456", "0.67340934", "0.6705783", "0.66735274", "0.6644495", "0.66064894", "0.6556347", "0.65561265", "0.6546647", "0.64954424", "0.648944", "0.6453129", "0.6450413", "0.64317846", "0.6426319", "0.64229745", "0.6422943", "0.64032286", "0.63814217", "0.6381163", "0.63773763", "0.63558245", "0.6337419", "0.63275933", "0.6326386", "0.6321232", "0.6318496", "0.6316864", "0.6312661", "0.63102853", "0.6310269", "0.6310269", "0.63078254", "0.629659", "0.6294228", "0.6289789", "0.62839097", "0.628186", "0.62808067", "0.62794995", "0.62768686", "0.6268606", "0.6267548", "0.62656736", "0.6260125", "0.62486595", "0.624662", "0.62378657", "0.6222811", "0.62057215", "0.6198921", "0.6197251", "0.6192219", "0.6189156", "0.6187387", "0.6177233", "0.6176554", "0.617365", "0.6170215", "0.6169892", "0.616897", "0.61686754", "0.6166658", "0.6163865", "0.61586064", "0.6150215", "0.6138508", "0.61321807", "0.61243176", "0.6124278", "0.61187154", "0.6115087", "0.611269", "0.6110666", "0.6110147", "0.6108771", "0.61075914", "0.6099937", "0.6098164", "0.6086934", "0.60753125", "0.60664964", "0.606508", "0.606045", "0.60588074", "0.6058316", "0.6055832", "0.6053481", "0.60458905", "0.6043408", "0.6042782", "0.60408837", "0.603999" ]
0.0
-1
Use callbacks to share common setup or constraints between actions.
def set_user @user = @current_user end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_eval do\n define_method(:valid?) do |*args|\n self.class.state_machines.fire_event_attributes(self, :save, false) { super(*args) }\n end\n end\n end\n end", "def add_actions; end", "def callbacks; end", "def callbacks; end", "def setup *actions, &proc\n (@setup_procs ||= []) << [proc, actions.size > 0 ? actions : [:*]]\n end", "def define_action_helpers; end", "def post_setup\n end", "def action_methods; end", "def action_methods; end", "def action_methods; end", "def before_setup; end", "def action_run\n end", "def execute(setup)\n @action.call(setup)\n end", "def define_action_helpers?; end", "def set_actions\n actions :all\n end", "def action_done(action)\n dispatch = { :migrate => :done_migrating, :map => :done_mapping, :reduce =>\n :done_reducing, :finalize => :done_finalizing } \n self.send dispatch[action[:action]], action\n end", "def dependencies action, &block\n @actions.each do |other|\n if action[:requires].include? other[:provide]\n block.call other\n end\n end\n end", "def setup!\n return unless @setup_procs\n http_actions = actions\n @setup_procs.each do |setup_proc|\n proc, actions = setup_proc\n @setup__actions = actions.map do |action|\n\n action.is_a?(Regexp) ?\n http_actions.select { |a| a.to_s =~ action } :\n action.is_a?(String) && action =~ /\\A\\./ ?\n http_actions.map { |a| a.to_s << action if format?(a).include?(action) }.compact :\n action\n\n end.flatten\n self.class_exec &proc\n @setup__actions = nil\n end\n @setup_procs = nil\n end", "def before_actions(*logic)\n self.before_actions = logic\n end", "def setup_handler\n end", "def set_action(opts)\n opts = check_params(opts,[:actions])\n super(opts)\n end", "def setup(action)\n @targets.clear\n unless action.item.target_filters.empty?\n @targets = SES::TargetManager.make_targets(action)\n else\n item = action.item\n if item.for_opponent?\n @targets = $game_troop.alive_members\n elsif item.for_dead_friend?\n @targets = $game_party.battle_members.select { |actor| actor.dead? }\n else\n $game_party.battle_members.select { |actor| actor.alive? }\n end\n end\n @item_max = @targets.size\n create_contents\n refresh\n show\n activate\n end", "def action; end", "def action; end", "def action; end", "def action; end", "def action; end", "def workflow\n end", "def revisable_shared_setup(args, block)\n class << self\n attr_accessor :revisable_options\n end\n options = args.extract_options!\n self.revisable_options = Options.new(options, &block)\n \n self.send(:include, Common)\n self.send(:extend, Validations) unless self.revisable_options.no_validation_scoping?\n self.send(:include, WithoutScope::QuotedColumnConditions)\n end", "def setup\n @action = SampleActionAndroid.new(os_name: 'android',\n app_name: APP_PATH)\n end", "def before(action)\n invoke_callbacks *self.class.send(action).before\n end", "def process_action(...)\n send_action(...)\n end", "def before_dispatch(env); end", "def after_actions(*logic)\n self.after_actions = logic\n end", "def setup\n # override and do something appropriate\n end", "def setup(client)\n return unless @setup\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n actions.each do |action|\n action.execute(client)\n end\n self\n end", "def setup(_context)\n end", "def setup(resources) ; end", "def validate_actions\n errors.add(:base, :should_give_at_least_one_action) if !manage? && !forecasting? && !read? && !api?\n end", "def setup\n @resource_config = {\n :callbacks => {\n :before_create => nil,\n :after_create => nil,\n :before_update => nil,\n :after_update => nil,\n :before_destroy => nil,\n :after_destroy => nil,\n },\n :child_assoc => nil,\n :model => nil,\n :parent => nil,\n :path => nil,\n :permission => {},\n :properties => {},\n :relation => {\n :create => nil,\n :delete => nil,\n },\n :roles => nil,\n }\n end", "def determine_valid_action\n\n end", "def process_shared\n handle_taxes\n handle_shippings\n create_adjustments_from_params\n handle_status\n handle_inventory_refunds\n handle_payment_transactions\n order.updater.update\n end", "def startcompany(action)\n @done = true\n action.setup\n end", "def init_actions\n am = action_manager()\n am.add_action(Action.new(\"&Disable selection\") { @selection_mode = :none; unbind_key(32); bind_key(32, :scroll_forward); } )\n am.add_action(Action.new(\"&Edit Toggle\") { @edit_toggle = !@edit_toggle; $status_message.value = \"Edit toggle is #{@edit_toggle}\" })\n end", "def event_callbacks(event, metadata={})\n case event\n when :reset, :review\n if confirmed\n update_attributes(confirmed: false)\n end\n when :confirm\n confirm\n # trigger :order for all applicable items\n # NOTE: :order event is common to both physical and digital items\n items.each do |i|\n if i.event_permitted(:order)\n user_id = last_transition.user_id\n i.trigger!(:order, { order_id: id, user_id: user_id })\n end\n end\n when :complete_work\n request = metadata[:request]\n work_complete_notification(request)\n when :close\n close\n end\n if event != :close && !open\n reopen\n end\n end", "def setup_action\n return unless PONY::ERRNO::check_sequence(current_act)\n new_sequence = @action_sequence[@sequence_index+1...@action_sequence.size]\n @sequence_index = 0\n new_sequence = DND::SkillSequence::ACTS[@acts[1]] + new_sequence\n execute_sequence\n end", "def define_tasks\n define_weave_task\n connect_common_tasks\n end", "def setup(&block)\n define_method(:setup, &block)\n end", "def setup\n transition_to(:setup)\n end", "def setup\n transition_to(:setup)\n end", "def action\n end", "def setup( *args )\n\t\t\tself.class.setupBlocks.each {|sblock|\n\t\t\t\tdebugMsg \"Calling setup block method #{sblock}\"\n\t\t\t\tself.send( sblock )\n\t\t\t}\n\t\t\tsuper( *args )\n\t\tend", "def config(action, *args); end", "def setup\n @setup_proc.call(self) if @setup_proc\n end", "def before_action \n end", "def setup_callbacks\n defined_callbacks.each do |meth|\n unless respond_to?(\"call_#{meth}_callbacks\".to_sym)\n self.class.module_eval <<-EOE\n def call_#{meth}_callbacks(*args)\n plugin_store.each {|a| a.call_#{meth}_callbacks(*args) } if respond_to?(:plugin_store) && plugin_store\n self.send :#{meth}, *args if respond_to?(:#{meth})\n end\n EOE\n end\n end\n end", "def action\n end", "def matt_custom_action_begin(label); end", "def setup\n # override this if needed\n end", "def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend", "def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend", "def action(options,&callback)\n new_action = Action===options ? options : Action.new(options,&callback)\n # replace any with (shared name/alias or both default) + same arity\n @actions.delete_if do |existing_action|\n ((existing_action.names & new_action.names).size > 0 ||\n existing_action.default? && new_action.default?) &&\n existing_action.required.size == new_action.required.size &&\n existing_action.optional.size <= new_action.optional.size\n end\n @actions = (@actions + [new_action]).sort\n new_action\n end", "def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action\n end", "def after(action)\n invoke_callbacks *options_for(action).after\n end", "def pre_task\n end", "def setup(server)\n server.on('beforeMethod', method(:before_method), 10)\n end", "def add_actions\n attribute = machine.attribute\n name = self.name\n \n owner_class.class_eval do\n define_method(name) {self.class.state_machines[attribute].events[name].fire(self)}\n define_method(\"#{name}!\") {self.class.state_machines[attribute].events[name].fire!(self)}\n define_method(\"can_#{name}?\") {self.class.state_machines[attribute].events[name].can_fire?(self)}\n end\n end", "def init_actions\n @select_action = SelectAction.new\n @endpoint_mouse_action = EndpointMouseAction.new\n @move_action = MoveAction.new\n end", "def setup_signals; end", "def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend", "def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend", "def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action.respond_to?('weak!') ? action.weak! : action\n end", "def initialize(*args)\n super\n @action = :set\nend", "def after_set_callback; end", "def setup\n #implement in subclass;\n end", "def lookup_action; end", "def setup &block\n if block_given?\n @setup = block\n else\n @setup.call\n end\n end", "def setup_action\n return TSBS.error(@acts[0], 1, @used_sequence) if @acts.size < 2\n actions = TSBS::AnimLoop[@acts[1]]\n if actions.nil?\n show_action_error(@acts[1])\n end\n @sequence_stack.push(@acts[1])\n @used_sequence = @acts[1]\n actions.each do |acts|\n @acts = acts\n execute_sequence\n break if @break_action\n end\n @sequence_stack.pop\n @used_sequence = @sequence_stack[-1]\n end", "def release_actions; end", "def around_hooks; end", "def save_action; end", "def setup(easy)\n super\n easy.customrequest = @verb\n end", "def action_target()\n \n end", "def setup\n callback(:setup) do\n notify(:setup)\n migration_check.last_deployed_commit\n end\n end", "def setup\n return unless @setup\n\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n run_actions_and_retry(actions)\n self\n end", "def before_setup\n # do nothing by default\n end", "def my_actions(options)\n @setup = false\n get_template_part(\"custom_used\",\"action_users\",true)\n end", "def default_action; end", "def setup(&blk)\n @setup_block = blk\n end", "def callback_phase\n super\n end", "def advice\n end", "def _handle_action_missing(*args); end", "def duas1(action)\n action.call\n action.call\nend", "def shared_action(name, &block)\n @controller.shared_actions[name] = block\n end", "def before_action action, &block\n @audience[:before][action] ||= Set.new\n @audience[:before][action] << block\n end", "def setup_initial_state\n\n state_a = State.new(\"a\", 0)\n state_b = State.new(\"b\", 0)\n state_c = State.new(\"c\", 10)\n\n move_to_b = Action.new(\"move_to_b\", 1, state_b)\n\n move_to_c = Action.new(\"move_to_c\", 1, state_c)\n\n state_a.actions = [move_to_b, move_to_c]\n\n return state_a\n \nend" ]
[ "0.6163163", "0.6045976", "0.5946146", "0.591683", "0.5890051", "0.58349305", "0.5776858", "0.5703237", "0.5703237", "0.5652805", "0.5621621", "0.54210985", "0.5411113", "0.5411113", "0.5411113", "0.5391541", "0.53794575", "0.5357573", "0.53402257", "0.53394014", "0.53321576", "0.53124547", "0.529654", "0.5296262", "0.52952296", "0.52600986", "0.52442724", "0.52385926", "0.52385926", "0.52385926", "0.52385926", "0.52385926", "0.5232394", "0.523231", "0.5227454", "0.52226824", "0.52201617", "0.5212327", "0.52079266", "0.52050185", "0.51754695", "0.51726824", "0.51710224", "0.5166172", "0.5159343", "0.51578903", "0.51522785", "0.5152022", "0.51518047", "0.51456624", "0.51398855", "0.5133759", "0.5112076", "0.5111866", "0.5111866", "0.5110294", "0.5106169", "0.509231", "0.50873137", "0.5081088", "0.508059", "0.50677156", "0.50562143", "0.5050554", "0.50474834", "0.50474834", "0.5036181", "0.5026331", "0.5022976", "0.5015441", "0.50121695", "0.5000944", "0.5000019", "0.4996878", "0.4989888", "0.4989888", "0.49864885", "0.49797225", "0.49785787", "0.4976161", "0.49683493", "0.4965126", "0.4958034", "0.49559742", "0.4954353", "0.49535993", "0.4952725", "0.49467874", "0.49423352", "0.49325448", "0.49282882", "0.49269363", "0.49269104", "0.49252945", "0.4923091", "0.49194667", "0.49174926", "0.49173003", "0.49171105", "0.4915879", "0.49155936" ]
0.0
-1
filter the counts based on the user id set produces a new array of just the matched items if the user id filter is nil we match all the form of the input data is expected to be: [[user_id, cohort], ...] we sum up the count of matching user_ids into their cohort bucket
def sum_cohorts(users) sums = [] # initialize the expected number of cohorts (1..current_cohort).each do |cohort| sums[cohort] = 0 end users.each do |user| user_id = user[0] cohort = user[1] sums[cohort] = 0 if sums[cohort].nil? if match_user_id?(user_id) sums[cohort] += 1 end end return sums end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cohorts_query_in(db, proc)\n sums = []\n # initialize the expected number of cohorts\n (1..current_cohort).each do |cohort|\n sums[cohort] = 0\n end\n\n if !@user_ids.nil?\n # build our user ids\n total_ids = @user_ids.length\n count = 0\n stmt = \"\"\n @user_ids.each do |user_id|\n if count % IN_CLAUSE_MAX == 0\n stmt << \"(#{user_id}\"\n else\n stmt << \",#{user_id}\"\n end\n count += 1\n if (count % IN_CLAUSE_MAX == 0) || (count == total_ids)\n # hit max batch size or last batch, submit the query\n stmt << \")\"\n sql = proc.call(date_first, date_last, stmt)\n stmt = \"\"\n results = db.execute(sql)\n results.each do |r|\n cohort = r[0]\n sum = r[1]\n sums[cohort] = 0 if sums[cohort].nil?\n sums[cohort] += sum\n end\n end\n end\n end\n\n save_sums(sums)\n return sums\n end", "def users_who_completed_all_studies\n @downloaded_studies = Study.find(self.study_ids)\n\n user_arr = []\n @downloaded_studies.each do |study|\n user_arr.push(study.study_completions.pluck(:user_id).uniq)\n end\n\n ## SELECT THE COMMON VALUES OF ALL INTERIOR ARRAYS\n user_ids_and_nil = user_arr.reduce { |a, b| a & b }\n\n\n ## THIS COMMAND GETS RID OF ALL LOGGED OUT USER SURVEY DATA -- could be interesting to see if its use can dry up code\n user_ids_who_completed_all_studies = user_ids_and_nil.grep(Integer)\n\n user_ids_who_completed_all_studies\n end", "def getTechnicianStatsActivities\n #Getting all the tech leads and understudies for each activity\n actTechs = ActivityTech.all.pluck(:tech_lead_id)\n actTechsU = ActivityTech.all.pluck(:tech_ustudy_id)\n \n #putting them in the same set\n actTechs = actTechs + actTechsU \n\n userIDs = User.all.pluck(:id)\n \n userCount = []\n userIDs.each do |id|\n\n #Only add it to the final result if the number of activities > 0\n if actTechs.count(id) != 0 then\n username = User.find(id).display_name\n #get the number of activities by counting the number of occurences of the id\n userCount.push([username, actTechs.count(id)])\n end\n\n end\n \n return userCount\n end", "def cohortfilter\n puts \"Please find students by cohort below:\"\n cohort_months = @students.map { |month| month[:cohort]}\n cohort_months.uniq!\n cohort_months.each do |month|\n puts \"Here are the #{month} students\"\n selected_students = @students.select { |student| student[:cohort] == month}\n list(selected_students)\n end\nend", "def match\n users_that_match = []\n User.collect_users_and_interests.each do |user, interests_array|\n total_match = count_common_interests(interests_array, self)\n if (is_a_match(total_match) == true) && (user.id != self.id) && (user.location_id == self.location_id)\n users_that_match << user\n end\n end\n users_that_match\n end", "def userfilter\n @tweets = Tweet.where(\"user_vote < 0 or user_vote > 0\").includes(:company).page params[:page]\n @count = Tweet.where(\"user_vote < 0 or user_vote > 0\").count\n end", "def count\n filtered = apply_criteria(@data)\n filtered.count\n end", "def user_id_company_users(start, stop, users)\n removed_users = UserCompany.\n where(user_id: users).\n not_deleted.\n removed.\n where.not(user_id: @test).\n where('started_at < ?', stop).\n where('removed_at > ?', start)\n not_removed_users = UserCompany.\n where(user_id: users).\n not_deleted.\n not_removed.\n where.not(user_id: @test).\n where('started_at < ?', stop)\n (removed_users + not_removed_users).pluck(:user_id).uniq\nend", "def find_users_id_from_query\n if query_is_mifare_number?\n find_users_from :card\n else\n found_user_ids = Set.new\n\n USER_SOURCES_PRIORITY.each do |source|\n if found_user_ids.size < USER_COUNT_SEARCH_LIMIT\n found_user_ids.merge(find_users_from source)\n end\n end\n\n found_user_ids.take(USER_COUNT_SEARCH_LIMIT)\n end\n end", "def q_with_dupes_count(current_user)\n count = 0\n sections.each do |s|\n count += s.q_with_dupes_count(current_user)\n end\n count\n end", "def unique_users(days=30)\n latest_executions(days).select(:user_id).distinct.count\n end", "def contributors_with_counts\n # Get contributing users' IDs\n swf_asset_ids = swf_assets.select(SwfAsset.arel_table[:id]).map(&:id)\n swf_asset_contributions = Contribution.select('user_id').\n where(:contributed_type => 'SwfAsset', :contributed_id => swf_asset_ids)\n contributor_ids = swf_asset_contributions.map(&:user_id)\n \n # Get the users, mapped by ID\n contributors_by_id = {}\n User.find(contributor_ids).each { |u| contributors_by_id[u.id] = u }\n \n # Count each user's contributions\n contributor_counts_by_id = Hash.new(0)\n contributor_ids.each { |id| contributor_counts_by_id[id] += 1 }\n \n # Build an OrderedHash mapping users to counts in descending order\n contributors_with_counts = ActiveSupport::OrderedHash.new\n contributor_counts_by_id.sort_by { |k, v| v }.reverse.each do |id, count|\n contributor = contributors_by_id[id]\n contributors_with_counts[contributor] = count\n end\n contributors_with_counts\n end", "def user_species_count(user_id, year = Time.zone.now.year)\n return 0 unless (user = User.find(user_id)) && user.subscribed?(year)\n Bird.published.known.approved\n .where(user_id: user_id)\n .where(\"EXTRACT(year FROM timestamp) = ?\", year)\n .where(\"EXTRACT(year FROM created_at) = ?\", year)\n .select(:species_id).distinct(:species_id)\n .count\n end", "def has_users_not_in?(cohort)\n\t\tself.users.size - cohort.users.size > 0\n\tend", "def available_cohorts(user)\n\t\tuser.nil? ? self.cohorts : self.cohorts - user.cohorts\n\tend", "def get_set_of_user_ids(arr_of_user_names)\n set_of_user_ids = Set.new\n\n arr_of_user_names.each { |name|\n @url = \"http://#{$canvas_host}/api/v1/courses/#{$canvas_course_id}/users\"\n puts \"@url is #{@url}\"\n \n @payload={'search_term': name}\n puts(\"@payload is #{@payload}\")\n \n @getResponse = HTTParty.get(@url, :body => @payload.to_json, :headers => $header)\n puts(\" GET to get user has Response.code #{@getResponse.code} and getResponse is #{@getResponse}\")\n \n user_data = @getResponse.parsed_response\n \n user_data.each do |user_data_info|\n set_of_user_ids.add user_data_info[\"id\"]\n end\n }\n \n return set_of_user_ids\nend", "def count_common_interests(interests, current_user)\n total_interests_in_common = 0\n interests.each do |interest|\n if current_user.user_interests.any?(interest)\n total_interests_in_common += 1\n end\n end\n # return total interest count\n total_interests_in_common\n end", "def followed_by_profiles_count\n return Favorite.where(favable_type: 'Stream', favable_id: stream_ids).pluck(:profile_id).uniq.count\n end", "def rule_member_ids\n results = []\n\n # Step One: Build groups out of each 'is' rule,\n # grouping rules of similar type together via OR\n # Note: we ignore the 'loginid' column as it is calculated separately\n # Produce an array of arrays: outer array items represent each column type used, inner arrays are all group rule IDs for that specific column type\n # e.g. id: 1 \"organization is\", id: 2 \"organization is\", id: 3 \"department is\" produces: [ [1,2] , [3] ]\n GroupRule.select(:group_rule_result_set_id, :column)\n .where(group_id: id)\n .where(condition: 'is')\n .where.not(column: 'loginid')\n .group_by(&:column)\n .map { |set| set[1].map(&:group_rule_result_set_id) }.each do |rule_set_ids|\n rule_set_results = GroupRuleResult.select(:entity_id)\n .joins(:group_rule_result_set)\n .where(group_rule_result_set_id: rule_set_ids)\n .map(&:entity_id)\n results << rule_set_results\n end\n\n # Step Two: AND all groups from step one together\n results = results.inject(results.first) { |sum, n| sum &= n }\n results ||= [] # reduce/inject may return nil\n\n # Step Three: Pass over the result from step two and\n # remove anybody who violates an 'is not' rule\n negative_results = []\n GroupRule.select(:group_rule_result_set_id, :column)\n .where(group_id: id)\n .where(condition: 'is not')\n .group_by(&:column)\n .map { |set| set[1].map(&:group_rule_result_set_id) }.each do |rule_set_ids|\n negative_results << GroupRuleResult.select(:entity_id)\n .joins(:group_rule_result_set)\n .where(group_rule_result_set_id: rule_set_ids)\n .map(&:entity_id)\n end\n\n results -= negative_results.flatten.uniq\n\n # Step Four: Process any 'loginid is' rules\n rules.select { |r| r.condition == 'is' && r.column == 'loginid' }.each do |rule|\n # Rails.logger.debug \"Processing loginid is rule #{rule.value}...\"\n results << rule.result_set.results.map(&:entity_id)\n end\n\n results.flatten!\n\n return results # rubocop:disable Style/RedundantReturn\n end", "def message_count\n id = session[:userid]\n # sent_by_user = Status.filter(:owner_id => id).exclude(:recipient_id => nil).count # 1)\n # sent_to_user = Status.filter(:recipient_id => id).count\n # sent_by_user + sent_to_user\n \n # Using a single database query \n # http://sequel.rubyforge.org/rdoc/files/doc/dataset_filtering_rdoc.html => \"Using OR instead of AND\"\n Status.filter(:owner_id => id).exclude(:recipient_id => nil). # 2)\n or(:recipient_id => id).\n count\n end", "def getMEELeadActivitiesCount\n users = User.all.pluck(:id)\n\n activities = []\n users.each do |id|\n #get the activities where the user is the mee lead\n acts = Activity.where(user_id: id)\n\n #only add the result if number of activites > 0\n if acts.length != 0\n username = User.find(id).display_name\n \n #get number by doing.length on the list\n activities.push([username, acts.length])\n end\n end\n return activities\n end", "def get_unviewed_ids(user); end", "def cumulative_company_users(stop, company)\n users = UserCompany.\n where(company: company).\n where.not(user_id: @test).\n where('started_at < ?', stop).\n pluck(:user_id).\n uniq\nend", "def get_user_ids(deal_id, multiple_redeem = false)\n date = DateTime.now.in_time_zone(\"Singapore\").end_of_day\n if multiple_redeem\n user_ids = Array.new\n all_users = Redemption.where(deal_id: deal_id).where(\"created_at <= ?\", date).select(:user_id).distinct.pluck(:user_id)\n all_users.each do |au|\n if Redemption.where(deal_id: deal_id, user_id: au).count > 1\n user_ids << au\n end\n end\n user_ids\n else\n Redemption.where(deal_id: deal_id).where(\"created_at <= ?\", date).select(:user_id).distinct.pluck(:user_id)\n end\n end", "def count_active_profs\n active_users = read_csv(\"CSV/Pessoas_Ativas.csv\")\n\n prof_ativos = Hash.new\n\n active_users.each do |row|\n namespace = row['namespace']\n prof_ativos[namespace] ||= Set.new\n prof = row['user_id']\n if row['teacher'] == '1' and not $ignored_users.include?(prof)\n prof_ativos[namespace].add(prof) \n $all_profs.add(prof)\n end\n end\n\n n_prof_ativos = Hash.new\n\n prof_ativos.each do |ns, profs|\n n_prof_ativos[ns] = profs.size\n end\n n_prof_ativos\nend", "def select_tweeters(followers)\n result = []\n start_time = Time.now\n result_quality = 0\n\n # do grouping\n # should end up with an array of arrays (or nil), where each n-th position in\n # main array represents the array of userids that have n followers.\n grouped_users = [];\n followers.each_with_index do |follower_list, userid|\n list = grouped_users[follower_list.length];\n\n if list.nil?\n list = []\n grouped_users[follower_list.length] = list\n end\n\n list << userid\n end\n top_users = grouped_users.flatten.compact.reverse\n\n # determine top-n users to inspect\n top_n = sqrt(top_users.length)\n top_n = top_users.length / 5 if top_n < 7 # 20%\n top_n = top_users.length / 2 if top_n < 7 # 50%\n top_n = top_users.length if top_n < 7 # 100%\n # top_n = 34\n\n top_users[0..top_n].combination(5) do |combi|\n # array style\n # obtain a list of ALL followers of the chosen users\n follower_list = []\n\n # use concat to avoid creating new arrays\n # or having to flatten the array later\n combi.each { |num| follower_list.concat(followers[num]) }\n\n # remove dupes\n follower_list.uniq!\n\n # remove the candidate users\n combi.each { |num| follower_list.delete(num) }\n\n # update tracker variables if necessary\n if follower_list.size > result_quality\n result = combi\n result_quality = follower_list.size\n end\n\n # if (Time.now - start_time) > 5.985 # 0.25 is the floor\n # break\n # end\n end\n\n return result\nend", "def perform_analytics(data)\n # input -> data: a hash of the form { users -> list of strings of commands }\n # output -> results: a nested array of two-element arrays\n results = [] # [[ string, count ]] or {string => count}, chartkick can deal with either.\n frequencies = Hash.new(0)\n data.keys.each do | user |\n data[user].each do | cmd |\n if !frequencies.include?(cmd)\n frequencies[cmd] = 1\n else\n frequencies[cmd] += 1\n end\n end\n end\n return frequencies \t\n end", "def count_user\n count = 0\n @f_net.each do |followees|\n count += 1 unless !followees or followees.empty?\n end\n count\n end", "def fellow_group_member_ids\n user_ids = GroupUser\n .where(group_id: group_ids + owned_group_ids)\n .uniq\n .pluck(:user_id)\n\n # don't include self\n user_ids.delete(id)\n\n user_ids\n end", "def mutual_songs (user_id)\n User.exists?(user_id) ? (self.my_songs & User.find(user_id).my_songs).size : 0\n end", "def household_user_ids\n @household_user_ids || household.users.where.not(id: id).pluck(:id)\n end", "def household_user_ids\n @household_user_ids || household.users.where.not(id: id).pluck(:id)\n end", "def available_users(cohort)\n\t\tcohort.nil? ? self.users : self.users - cohort.users\n\tend", "def possible_users\n ids = []\n ids = condition.scan(/\\d+/) if condition.present?\n User.where(:id => ids)\n end", "def survey_count\n @pub_surveys = Survey.select('id').where(status: 'published')\n @pub_survey_ids = Array.new\n\n @pub_surveys.each do |u|\n @pub_survey_ids.push (u.id)\n end\n \n @user_taken_surveys = UserSurvey.where(user_id: current_login)\n @user_taken_survey_ids = Array.new\n\n @user_taken_surveys.each do |u|\n @user_taken_survey_ids.push (u.survey_id)\n end\n\n @untaken_pub_surveys_ids = Array.new\n\n @pub_survey_ids.each do |u|\n if @user_taken_survey_ids.index(u)\n puts \"it exists\"\n else\n @untaken_pub_surveys_ids.push (u)\n end\n end\n\n if @untaken_pub_surveys_ids.empty?\n count = 0\n else\n count = @untaken_pub_surveys_ids.count\n end\n return count\n end", "def cohorts_query(db, proc)\n sums = []\n # initialize the expected number of cohorts\n (1..current_cohort).each do |cohort|\n sums[cohort] = 0\n end\n\n sql = proc.call(date_first, date_last)\n results = db.execute(sql)\n results.each do |r|\n cohort = r[0]\n sum = r[1]\n sums[cohort] = 0 if sums[cohort].nil?\n sums[cohort] += sum\n end\n\n save_sums(sums)\n return sums\n end", "def userids(*values)\n values.inject(self) { |res, val| res._userids(val) }\n end", "def following_profiles_count\n stream_ids = favorites.streams.pluck(:favable_id).uniq\n return Stream.where(:id => stream_ids).pluck(:profile_id).uniq.count\n end", "def unique_users_with_failures(days=30)\n latest_executions(days).where(success: false).select(:user_id).distinct.count\n end", "def patients_in_measure_population_observation\n Patient.find(gather_patient_ids).keep_if do |p|\n p.patient_relevant?(measures.pluck(:_id), ['OBSERV'])\n end.pluck(:_id)\n end", "def users_by_amount_visited\n user_visits = self.visited_museums.count\n other_user_visits = User.where.not(id: self.id).map { |user| user.visited_museums.count }\n other_user_visits.unshift(user_visits)\n end", "def count_geographic_occurrences_of_users(users)\n users\n .filter_map { |u| ISO3166::Country[u.try(:organisation).try(:country)] }\n .reduce(Hash.new(0)) { |result, c| result[c] += 1; result }\n .map { |c, z| { name: c.iso_short_name, lat: c.geo[\"latitude\"], lon: c.geo[\"longitude\"], z: z } }\n end", "def list_cohorts\n @students.each do |student_info|\n if (@cohorts.include? (student_info[:cohort])) == false\n @cohorts << student_info[:cohort]\n end\n end\nend", "def partition_users_into_subgraphs\n already_partitioned = Set.new\n partition = []\n # The values are the partitions, the keys are the counts of each partition\n counts_of_partitions_hash = {}\n num_users_partitioned = 0\n\n until num_users_partitioned == User.count\n users_to_partition = User.all.pluck(:id) - already_partitioned.to_a\n # We have to go through all of them eventually, so it doesn't matter\n # which one we start from\n user_id = users_to_partition.sample\n user_graph = graph_for_user(user_id)\n partition << user_graph\n already_partitioned.merge(user_graph)\n num_users_partitioned = partition.flatten.count\n end\n\n partition.each { |sg| counts_of_partitions_hash[sg.length] = sg }\n\n counts_of_partitions_hash\n end", "def phase1_reduce\n removed_all = []\n\n # 1.3i - remove any that match 1.3i\n @best_proposals.each_with_index do |p,i|\n slice_point = @people_prefs[i].index(p) + 1\n removed_from_i = @people_prefs[i].slice!(slice_point, @people_prefs[i].count)\n removed_all << removed_from_i\n end\n\n # 1.3ii - remove user i from the list of those he had removed above\n removed_all.each_with_index do |list,i|\n list.each do |ignored_user|\n @people_prefs[ignored_user].delete(i)\n end\n end\n\n @people_prefs\n end", "def countries_of_members_data(country_name = false)\n data = [['Country', 'Users']]\n members.group(:country).where.not(country: [nil, '']).select('country, COUNT(*) AS number_of_users').each{|i| data << [country_name ? ISO3166::Country.new(i.country).try(:name) : i.country, i.number_of_users] }\n data\n end", "def has_cohorts_not_in?(user)\n\t\tself.cohorts.size - user.cohorts.size > 0\n\tend", "def filter_by_user\n users = TaskFilter.filter_user_ids(session)\n return \"\" if users.empty? or users.include?(ALL_USERS)\n\n task_ids = []\n users.each do |id|\n if id > 0\n u = User.find(id)\n task_ids += u.tasks.map { |t| t.id }\n elsif id == UNASSIGNED_TASKS\n join = \"LEFT OUTER JOIN task_owners t_o ON tasks.id = t_o.task_id\"\n conditions = [\"tasks.company_id = ? AND t_o.id IS NULL\", @company.id ]\n unassigned = Task.find(:all, :select => \"tasks.*\", \n :joins => join,\n :readonly => false, \n :conditions => conditions)\n task_ids += unassigned.map { |t| t.id }\n end\n end\n\n task_ids = [ \"0\" ] if task_ids.empty?\n return \"tasks.id IN (#{ task_ids.join(\", \") }) AND \"\n end", "def users\n response.present? ? response.totals_for_all_results['ga:users'] : 0\n end", "def user_labels\n @users = User.where(id: params[:user_ids].split(\",\").map(&:to_i).uniq).all\n end", "def count_filter_email\n email_filter.reduce(0) do |sum, element| ##???\n sum += 1\n end\nend", "def record_counts(model_query, filtered_query)\n counts = Hash.new\n total = model_query.distinct.count(:id)\n\n # Handle results of joined queries. This feels a little bit hacky.\n total = total.keys.length if total.is_a?(Hash)\n\n counts[:total_rows] = total\n\n if tablesorter_params[:filter]\n # Count again if additional filters were applied (fires a query)\n cnt = filtered_query.count(\"#{model_query.table_name}.id\")\n\n # Handle results of having-queries. This feels a little bit hacky.\n cnt = cnt.keys.length if cnt.is_a?(Hash)\n\n counts[:filtered_rows] = cnt\n else\n counts[:filtered_rows] = total # There wasn't any reduction.\n end\n\n counts\n end", "def all_users\n @date = (params[:date])? Date.parse(params[:date]) : Date.today\n users_ungroup = User.all(:conditions => {:status => User::STATUS_ACTIVE}, :order => 'login').sort\n @user_counts = users_ungroup.size\n @reported = false\n @daily_todo_users_group = Array.new\n @daily_todo_groups = Group.all().sort\n @daily_todo_groups.each do |group|\n users_of_group = group.users.sort_by { |u| u.name }\n no_todo_users, todo_users = users_of_group.partition do |user|\n DailyTodo.first(:conditions => {:user_id => user.id, :date => @date}).nil?\n end\n\n hash_users_of_group = {:todo => todo_users, :no_todo => no_todo_users}\n @daily_todo_users_group.push(hash_users_of_group)\n # Check if the current user has written todo for this date\n @reported = @reported || todo_users.any? { |user|\n user.id == User.current.id\n }\n\n users_of_group.each do |user_of_group|\n users_ungroup.delete_if do |user_ungroup|\n user_ungroup.id == user_of_group.id\n end\n end\n end\n\n no_todo_ungroup_users, todo_ungroup_users = users_ungroup.partition do |user|\n DailyTodo.first(:conditions => {:user_id => user.id, :date => @date}).nil?\n end\n @daily_todo_users_ungroup = {:todo => todo_ungroup_users, :no_todo => no_todo_ungroup_users}\n @reported = @reported || todo_ungroup_users.any? do |user|\n user.id == User.current.id\n end\n end", "def user_baptised_data(period_data = 'last_month')\n res = user_baptised_relationships\n range, daily_report = period_data.to_s.report_period_to_range\n data = [[period_data.to_s.report_period_to_title, 'Members']]\n range.each{|d| data << [d.strftime(daily_report ? '%d' : '%Y-%m'), res.where(baptised_at: d.beginning_of_day..(daily_report ? d.end_of_day : d.end_of_month.end_of_day)).count(:id)] }\n data\n end", "def accountability_group(dbcCohort_array)\n array_output = dbcCohort_array.shuffle.each_slice(4).to_a\n if array_output.length % 4 == 0 \n return array_output \n else \n remainder_people = array_output.pop \n for i in 0...array_output.length \n array_output[i].push(remainder_people[i])\n end\n return array_output\n end \nend", "def find_user_split_amt(all_users, equal_share , current_user)\n\t\tresult_array = [];\n\t\ttmp_array = all_users.map{|user| [user.email, equal_share - user.user_expense(self.id)]}\n\t\tp_array = tmp_array.select{|email, v| v > 0 }\n\t\tn_array = tmp_array - p_array\n\t\t#n_array = tmp_array.select{|email, v| v < 0 }\n\n\t\tp_array.each_with_index do |p_record, p_index|\n\t\t\tn_array.each_with_index do |n_record, n_index|\n\t\t\t\tif n_record[1].abs > p_record[1]\n\t\t\t\t\tputs \"#{p_record[0]} will pay to #{n_record[0]} value = #{p_record[1]}\"\n\t\t\t\t\tresult_array = create_result_set(p_record, n_record, current_user, result_array, p_record[1])\n\t\t\t\t\tn_value = n_record[1].abs - p_record[1]\n\t\t\t\t\tn_array[n_index] = [n_record[0], n_value]\n\t\t\t\t\tn_record = [n_record[0], n_value]\n\t\t\t\t\tp_array[p_index] = [p_record[0], 0]\n\t\t\t\t\tp_record = [p_record[0], 0]\n\t\t\t\telse\n\t\t\t\t\tputs \"#{p_record[0]} will pay to #{n_record[0]} value = #{n_record[1].abs}\"\n\t\t\t\t\tresult_array = create_result_set(p_record, n_record, current_user, result_array, n_record[1].abs)\n\t\t\t\t\tvalue = p_record[1] - n_record[1].abs\n\t\t\t\t\tp_array[p_index] = [p_record[0], value]\n\t\t\t\t\tp_record = [p_record[0], value]\n\t\t\t\t\tn_record = [n_record[0], 0]\n\t\t\t\t\tn_array[n_index] = [n_record[0], 0]\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\treturn result_array\n\tend", "def count_contestants_by_hometown(data, hometown)\n all_seasons(data).reduce(0) do |sum, contestant|\n if contestant[\"hometown\"] == hometown \n sum + 1 \n else \n sum \n end\n end\nend", "def count(filter = {})\n collection = all\n if filter[:days]\n now = Time.now.to_i\n old = now - filter[:days].to_i.days\n\n collection = collection.where(\"date between ? and ?\", old, now)\n end\n\n if filter.has_key?(:revoked)\n collection = collection.revoked\n end\n\n collection = collection.where(client_id: filter[:client_id]) if filter[:client_id]\n\n collection.count\n end", "def count_confirmed_users\n count = 0\n self.users.each do |user|\n if ProjectRoleUser.where(:user_id => user.id, :project_id => self.id).first.invitation_token == nil\n count = count + 1\n elsif ProjectRoleUser.where(:user_id => user.id, :project_id => self.id).first.invitation_confirmed == true\n count = count + 1\n end\n end\n\n return count\n end", "def permitted_users_id\n\treturn_user_ids = Array.new\n\tif !self.venue_id.nil?\n\t return_user_ids = ActiveInVenue.where(venue_id: self.venue_id).where.not(user_id: self.user_id).map(&:user_id)\n end\n\tif self.allow_nearby\n\t\treturn_user_ids = return_user_ids | User.where.not(id: self.user_id).near([self.latitude, self.longitude], 25, units: :km).map(&:id)\n\tend\n\tblack_list = BlockUser.blocked_user_ids(self.user_id)\n \tcontent_black_list = ShoutReportHistory.where(reportable_id: self.id).where(reportable_type: 'Shout').map(&:reporter_id)\n \treturn_user_ids = return_user_ids - black_list - content_black_list\n\n \t# only user pusher for online users\n \tonline_users_ids = User.where(id: return_user_ids).where(pusher_private_online: true).map(&:id)\n \treturn online_users_ids\n end", "def total(list)\n\ttotal_students = 0\n\tlist.map do |cohorts, size|\n\t\ttotal_students += size\n\tend\n\treturn total_students\nend", "def count_contestants_by_hometown(data, hometown)\n counter = 0\n data.each do |season, person| \n person.each do |person_data|\n if person_data[\"hometown\"] == hometown\n counter += 1\n end \n end\n end\n counter\nend", "def test_filter_creation\n md_report = @twitter_reporter.reports.create(:body => 'here in #21108')\n assert_equal 5, (md_report.filters & %w(annapolis baltimore maryland northamerica unitedstates).map { |c| Filter.find_by_name(c) }).size\n ca_report = @twitter_reporter.reports.create(:body => 'all is well in 94107')\n assert_equal 4, (ca_report.filters & %w(sanfrancisco california northamerica unitedstates).map { |c| Filter.find_by_name(c) }).size\n end", "def match\n not_gifted_array = self.users.map{|user| user.id}\n self.users.each do |user|\n while !user.match\n match = not_gifted_array.sample\n if (user.id != match)\n not_gifted_array.delete(match)\n user.update({match: match})\n end\n end\n end\n end", "def cohorts\n # participants.find(:all, :select => [:grad_year]).collect(&:grad_year).uniq.compact.sort.reverse\n @cohorts ||= participants.find(:all, :select => \"DISTINCT grad_year\").collect(&:grad_year).compact.sort.reverse\n end", "def country_count\n varietal_array = []\n # wine_array = [\"Malbec\", \"Merlot\", \"Syrah\", 'Cabernet Sauvignon', 'Pinot Noir', 'Grenache', 'Sangiovese', 'Tempranillo', 'Montepulcia', 'Petite Syrah', 'Chardonnay', 'Sauvignon blanc', 'Pinot Gris', 'Riesling', 'Semillon', 'Gewurztraminer', 'Chenin Blanc', 'Gruner Veltliner', 'Torrontes']\n variety = Wine.where(variety: params[:variety])\n # , \"Pinot Noir\", \"Merlot\", \"Malbec\", \"Syrah\",\"Chardonnay\",\"Sauvignon blanc\",\"Pinot Gris\",\"Riesling\",\"Pinot Noir\"]\n \n countries = []\n count_array = []\n new_hash = {}\n\n countries = variety.map do |wine| \n wine.country\n end \n\n \n count_array = countries.each_with_object(Hash.new(0)) {|k, v| v[k] += 1}\n new_array = []\n\n count_array.keys.each do |country| \n if country\n hash = {:country => country, :value => count_array[country]}\n new_array.push(hash)\n end\n end\n\n new_hash = {:countries => new_array}\n render json: new_hash\n end", "def dataset_count\n Dataset.count_by_user(self.id)\n end", "def matchable_users(&block)\n users = @users.values.select { |u| u.sessions.length > 0 && !u.matched }\n block.call users\n end", "def count_records_in_measure_groups\n patient_cache = get_db.collection('patient_cache')\n base_query = {'value.measure_id' => @measure_id, 'value.sub_id' => @sub_id,\n 'value.effective_date' => @parameter_values['effective_date'],\n 'value.test_id' => @parameter_values['test_id']}\n\n base_query.merge!(filter_parameters)\n \n query = base_query.clone\n\n query.merge!({'value.manual_exclusion' => {'$in' => [nil, false]}})\n \n result = {:measure_id => @measure_id, :sub_id => @sub_id, \n :effective_date => @parameter_values['effective_date'],\n :test_id => @parameter_values['test_id'], :filters => @parameter_values['filters']}\n \n # need to time the old way agains the single query to verify that the single query is more performant\n aggregate = {\"population\"=>0, \"denominator\"=>0, \"numerator\"=>0, \"antinumerator\"=>0, \"exclusions\"=>0}\n %w(population denominator numerator antinumerator exclusions).each do |measure_group|\n patient_cache.find(query.merge(\"value.#{measure_group}\" => true)) do |cursor|\n aggregate[measure_group] = cursor.count\n end\n end\n aggregate[\"considered\"] = patient_cache.find(query).count\n aggregate[\"exclusions\"] += patient_cache.find(base_query.merge({'value.manual_exclusion'=>true})).count\n result.merge!(aggregate)\n\n result.merge!(execution_time: (Time.now.to_i - @parameter_values['start_time'].to_i)) if @parameter_values['start_time']\n\n get_db.collection(\"query_cache\").save(result, safe: true)\n result\n end", "def account_group(cohort)\n group_of_3 = cohort.sample(3)\n cohort -= group_of_3\n puts \"Accountability Group(3 people): \"\n group_of_3.each do |index|\n puts index\n end\n group_of_4 = cohort.sample(4)\n cohort -= group_of_4\n puts \"Accountability Group(4 people): \"\n group_of_4.each do |index|\n puts index\n end\nuntil cohort.empty?\n group_of_5 = cohort.sample(5)\n cohort -= group_of_5\n puts \"Accountability Group: \"\n group_of_5.each do |index|\n puts index\n end\nend\nend", "def count(filter = {})\n select = {}\n if filter[:days]\n if filter[:revoked]\n select[:revoked] = (Date.today - filter[:days])..(Date.today)\n else\n select[:created_at] = (Date.today - filter[:days])..(Date.today)\n end\n elsif filter.has_key?(:revoked)\n select[:revoked] = filter[:revoked] ? { :$ne=>nil } : { :$eq=>nil }\n end\n select[:client_id] = filter[:client_id] if filter[:client_id]\n self.find(select)\n \n end", "def index\n @cohort_users = CohortUser.all\n end", "def list_filter(counts: nil, **opt)\n # TODO: ???\n end", "def choose\n other_users = User.all.where.not id: current_user.id\n clubs = Hash.new 0\n other_users.each do |other_user|\n other_user_clubs = Club.left_joins(:club_matches,:users).where(:users=> {id:other_user.id},:club_matches=>{matched:1})\n current_user_clubs = Club.left_joins(:club_matches,:users).where(:users=> {id:current_user.id},:club_matches=>{matched:1})\n\n common_clubs = other_user_clubs & current_user_clubs\n weight = (common_clubs.length.to_f * 100/ other_user_clubs.length)\n other_user_clubs.each do |club|\n if !common_clubs.include?(club)&& !current_user_clubs.include?(club)\n clubs[club] += weight\n end\n end\n end\n\n clubs.each do |club, v|\n common_interest_count = (current_user.interests & club.interests).length\n if clubs[club] >= 1\n clubs[club] = clubs[club] + ((5 * common_interest_count)/clubs[club]) + (rand(-14..14)/7)\n else\n clubs[club] = clubs[club] + (10 * common_interest_count) + (rand(-14..14).to_f/7)\n end\n clubs[club] = clubs[club].round(2)\n end\n @clubs = clubs.sort_by{ |k, v| v }.reverse\n end", "def limit_to_tenant! # rubocop:disable Metrics/AbcSize\n @stats[:user_count] = @stats[:user_count].where(tenant_id: current_user.tenant_id)\n @stats[:dataset_count] = @stats[:dataset_count].joins(resources: :user)\n .where(['stash_engine_users.tenant_id = ?', current_user.tenant_id]).distinct\n @stats[:user_7days] = @stats[:user_7days].where(tenant_id: current_user.tenant_id)\n @stats[:dataset_started_7days] = @stats[:dataset_started_7days].joins(:user)\n .where(['stash_engine_users.tenant_id = ?', current_user.tenant_id])\n @stats[:dataset_submitted_7days] = @stats[:dataset_submitted_7days].joins(resources: :user)\n .where(['stash_engine_users.tenant_id = ?', current_user.tenant_id]).distinct\n end", "def subscribers_count\n subscribers_as_people.uniq.count\n end", "def users_retention\n month_users = {}\n\t\n uret = {}\n\t\n @visits.each do |v| # all in right order\n time = Time.at(v.time_in)\n next if time < @from_day\n if time > @to_day then break end\n month = time.strftime \"%Y-%m\"\n if month_users[month].nil? then month_users[month] = {:uids => {}, :month => month} end\n if month_users[month][:uids][v.user_id].nil? then month_users[month][:uids][v.user_id] = 0 end\n month_users[month][:uids][v.user_id] += 1\n end\n \n month_users_ar = month_users.values.sort {|x,y| x[:month] <=> y[:month]} # sort by month\n\n for index in 1 ... month_users_ar.size # skip first month\n info = month_users_ar[index]\n month = info[:month]\n # how much (in %) from last month users came again in this month\n last_month_users = month_users_ar[index-1]\n uret[month] = {:count => 0, :total => last_month_users[:uids].count }\n last_month_users[:uids].each do |uid, count|\n if !(info[:uids][uid].nil?) then uret[month][:count] += 1 end\n end\n end\n \n render json: uret\n end", "def get_no_of_users\n\t\tusers.select(:id).count\n\tend", "def gather_user_profiles_from_ids(ids)\n ids = ids.map{|i| Integer(i) }\n profiles = []\n count = 0\n ids.each_slice(100) do |arr|\n count += 1\n puts \"On count: #{count}\"\n begin\n data = Twit.fetch_users_by_ids(arr)\n rescue Twitter::Error::TooManyRequests => err\n puts err\n puts \"Sleeping for 30\"\n sleep 30\n retry\n rescue Twitter::Error::NotFound => err\n puts err\n puts \"moving on...\"\n else\n profiles.concat(data)\n sleep 5\n end\n end\n\n return profiles\n end", "def viewers(m, set=@trainingSet)\n (set.data.select {|item| item[@MOVIE_ID].to_i == m}).collect {|item| item[@USER_ID].to_i}\n end", "def kata_user_categories\n kataUserCategories = []\n survived_reviews.each do |review|\n review.category_ids.each {|category_id| kataUserCategories << category_id}\n end\n kataUserCategories.uniq\n end", "def picasa_albums(user, picasa_user_id=nil)\n return [] unless user.picasa_identity\n picasa = user.picasa_client\n user_data = picasa.user(picasa_user_id) \n albums = []\n unless user_data.nil?\n user_data.albums.select{|a| a.numphotos.to_i > 0}.each do |a|\n albums << {\n 'aid' => a.id,\n 'name' => a.title,\n 'cover_photo_src' => a.thumbnails.first.url\n }\n end\n end\n return albums\n end", "def check_user_paging(users, context)\n options = {}\n if params[:group_category_id] && params[:unassigned]\n @options[:unassigned] = params[:unassigned]\n end\n unless users.empty?\n @page += 1\n @options[:page] = @page\n @options[:per_page] = @per_page\n \n users = context.get(:users, @options)\n @user_array << users\n self.check_user_paging(users, context)\n else\n @user_array.flatten!\n end\n end", "def usage_per_interval\n #end_date = AnalyticsUsage.last.created_at\n #start_date = AnalyticsUsage.first.created_at\n start_date = params[:report_start_date].to_time.to_i\n end_date = params[:report_end_date].to_time.to_i\n interval = params[:interval].to_i\n type= params[:submit]\n institution_ids = params[:institution]\n institution_names = []\n results = []\n institution_ids.each do |id|\n institution = Institution.find_by_id(id)\n name = institution.name.gsub(\" \",\"\").to_s\n institution_names << name\n users = Institution.find_by_id(id).students.map(&:id)\n s = start_date\n e = Time.at(start_date).to_date.plus_with_duration(interval).to_time.to_i\n i = true\n while i\n if s < end_date\n if e > end_date\n e = end_date\n end\n if type==\"Get Report\"\n duration = AnalyticsUsage.where(:user_id=>users,:created_at=>s..e).sum(:today_usage)\n user_count = AnalyticsUsage.select(:user_id).where(:user_id=>users,:created_at=>s..e).map(&:user_id).uniq.count\n results << [Time.at(s).to_date,Time.at(e).to_date,user_count,duration/60,name]\n elsif type == \"User Report\"\n AnalyticsUsage.where(:user_id=>users,:created_at=>s..e).each do |u|\n user = User.includes(:institution=>(:profile),:center=>(:profile),:academic_class=>(:profile),:section=>(:profile)).find_by_id_and_institution_id(u.id,id)\n if user\n results << [Time.at(s).to_date,Time.at(e).to_date,user.try(:name),(user.edutorid rescue \"\"),(user.institution.try(:name) if user.institution rescue \"\"),(user.center.try(:name) if user.center rescue \"\"),(user.academic_class.try(:name) if user.academic_class rescue \"\"),(user.section.try(:name) if user.section rescue \"\"),(u.today_usage/60 rescue 0),Time.at(u.created_at).to_date]\n end\n end\n end\n s = e\n e = Time.at(s).to_date.plus_with_duration(interval).to_time.to_i\n else\n i = false\n end\n end\n end\n if type == \"Get Report\"\n header = \"Start date,End date,Users,Total Duration,Institution\".split(\",\")\n elsif type == \"User Report\"\n header = \"Start date,End Date,Name,EdutorID,Institution,Center,Class,Section,Duration,Date\".split(\",\")\n end\n\n\n csv_data = FasterCSV.generate do |csv|\n csv << header\n results.each do |c|\n csv << c\n end\n end\n filename = \"Usage-Report\"\n institution_names.collect{|i| filename = filename+\"-\"+i}\n logger.info\"======#{filename}\"\n send_data csv_data, :type => 'text/csv; charset=iso-8859-1; header=present', :disposition => \"attachment; filename=#{filename}.csv\"\n end", "def user_rating(user_id, year = Time.zone.now.year)\n return 0 unless (user = User.find(user_id)) && user.subscribed?(year)\n index = users_species_count(year).find_index { |user| user.id == user_id }\n index ? index + 1 : 0\n end", "def grouped_user_fitness\n grouped_activities.select {|activity| activity.category == \"Health & Fitness\"}\n end", "def compare_response_to_user_budget(user_id)\n fares_under_budget = []\n convert_strings_to_floats(user_id).each do |fare|\n if fare <= User.find_by_id(user_id).budget\n fares_under_budget << fare\n end\n end\n fares_under_budget\nend", "def count_contestants_by_hometown(data, hometown)\n answer_counter = 0\n data.each do |season_key, season_data|\n season_data.each_with_index do |contestant|\n contestant.each do |key, value|\n if value == hometown\n answer_counter += 1\n end\n end\n end\n end\n answer_counter\nend", "def filter_ids\n (tags.map { |tag| tag[:id] } + filters.map(&:id)).uniq\n end", "def engaged_users\n self.users.select { |u| u.ideas.count > 0 || u.comments.count > 0 || u.votes.count > 0 || u.support_messages.count > 0 }\n end", "def count_contestants_by_hometown(data, hometown)\n count_of_contestants_from_hometown = 0\n data.each do |season_in_hash, contestant_array|\n contestant_array.each do |contestant|\n if contestant[\"hometown\"] == hometown\n count_of_contestants_from_hometown += 1\n end\n end\n end\n count_of_contestants_from_hometown\nend", "def combine_filtered_ids(u_filtered_ids, b_filtered_ids, m_filtered_ids, d_filtered_ids, tenant_filter_ids)\n intersection = ->(operand1, operand2) { [operand1, operand2].compact.reduce(&:&) }\n union = ->(operand1, operand2, operand3 = nil) { [operand1, operand2, operand3].compact.reduce(&:|) }\n\n b_intersection_m = intersection.call(b_filtered_ids, m_filtered_ids)\n u_union_d_union_b_intersection_m = union.call(u_filtered_ids, d_filtered_ids, b_intersection_m)\n\n intersection.call(u_union_d_union_b_intersection_m, tenant_filter_ids)\n end", "def watch_comment_by_user_ids\n user_ids = watch_comment_by_user_actions.where(\"action_option is null or action_option != ?\", \"ignore\").pluck(:user_id)\n user_ids += repository.watch_by_user_ids\n user_ids.uniq!\n\n user_ids - unwatch_comment_by_user_ids\n end", "def get_plays_count_for(user, maps)\n scoped = Game.where user_id: user.id, :map_id.in => maps.collect(&:id)\n\n map = \"function() { emit(this.map_id, 1); }\"\n reduce = \"function(key, result) { return result.length; }\"\n vals = scoped.map_reduce(map, reduce).out(inline: 1)\n\n plays = {}\n vals.each do |rd|\n plays[rd['_id']] = rd['value'].to_i\n end\n plays\n end", "def remove_countries_with_missing_data(data)\n filtered_countries = []\n data[:countries].each do |country|\n if country[:fertility_rate].count(0) == 0 and country[:life_expectancy].count(0) == 0 and country[:population].count(0) == 0\n filtered_countries << country\n end\n end\n\n p \"original num countries: #{data[:countries].length}\"\n p \"filtered num countries: #{filtered_countries.length}\"\n\n data[:countries] = filtered_countries\n return data\n end", "def twitter_user_data\n\t\t# IT WOULD BE NICE TO RE-FACTOR THIS SO IT IS THE SAME current_user as for other stats display...\n\t\t@twitter_graph = Authorization.where(\"user_id = ?\", current_user).where(\"provider = ?\", \"twitter\")\n\t\t@twitter_graph_user = TwitterUser.where(\"uid = ?\", @twitter_graph.first['uid'])\n\t\tdata_by_day = @twitter_graph_user.total_grouped_by_date(2.weeks.ago)\n\t\t#twitter_index_by_day = IvolveIndex.twitter_grouped_by_day(2.weeks.ago)\n\t\t(2.weeks.ago.to_date..Time.zone.today).map do |date|\n\t\t\tif !data_by_day[date].nil?\n\t\t\t\tcreated_at = date\n\t\t\t\tfriends_count = data_by_day[date].first.try(:friends_int_count)\n\t\t\t\tfollowers_count = data_by_day[date].first.try(:followers_int_count)\n\t\t\t\ttweets_count = data_by_day[date].first.try(:tweet_int_count)\n\t\t\t\tfavd_count = data_by_day[date].first.try(:favorite_int_count)\n\t\t\t\tlist_count = data_by_day[date].first.try(:listed_int_count)\n\t\t\telse\n\t\t\t\tcreated_at = date\n\t\t\t\tfriends_count = 0\n\t\t\t\tfollowers_count = 0\n\t\t\t\ttweets_count = 0\n\t\t\t\tfavd_count = 0\n\t\t\t\tlist_count = 0\n\t\t\tend\n\n\t\t\t{\n\t\t\t\tcreated_at: date,\n\t\t\t\tnum_friends: friends_count,\n\t\t\t\t#index_friends: twitter_index_friends,\n\t\t\t\tnum_followers: followers_count,\n\t\t\t\t#index_followers: twitter_index_followers,\n\t\t\t\ttweets_sent: tweets_count,\n\t\t\t\t#index_sent: twitter_index_sent,\n\t\t\t\ttweets_favd: favd_count,\n\t\t\t\t#index_favd: twitter_index_favd,\n\t\t\t\tnum_lists: list_count,\n\t\t\t\t#index_lists: twitter_index_lists,\n\t\t\t}\n\t\tend\n\tend", "def shared_with_following_tips\n follower_ids = user.user_followers.pluck(:id)\n\n @filtered_tips.where(share_following: true, user_id: (follower_ids).uniq).pluck(:id)\n end", "def all_cohorts (hash_value)\n total_students = hash_value.each_value.reduce(:+)\n puts total_students\nend", "def show\n @user = User.find(params[:id])\n @matches = @user.club_matches\n @matched_clubs = @matches.where(matched: \"1\").length\n @rejected_clubs = @matches.where(matched: \"0\").length\n @interests = Interest.joins(:user_interests).where(:user_interests => {user_id: current_user.id}).uniq\n\n end", "def state_user_counts\r\n #Reset state counts\r\n State.update_all(:user_count => 0)\r\n\r\n stats = User.find(:all, :select => \"states.id, count(states.id) as count\", :joins => ['join zips ON zips.zip = users.zip_code', 'join states ON states.id = zips.state_id'], :group => \"states.id\")\r\n stats.each do |s|\r\n state = State.find(s.id)\r\n state.user_count = s.count\r\n state.save\r\n end\r\n redirect_to :action => :index, :notice => \"updated state records\"\r\n end" ]
[ "0.6179814", "0.5751907", "0.55744034", "0.5488608", "0.5350726", "0.5249186", "0.52092034", "0.52043134", "0.5147224", "0.5118692", "0.51013154", "0.5058948", "0.50578564", "0.50486875", "0.5045273", "0.5021556", "0.5004701", "0.49844268", "0.4980961", "0.49513242", "0.4937445", "0.49246648", "0.49167424", "0.49135306", "0.48979294", "0.48884568", "0.48575717", "0.48524544", "0.4848239", "0.48318395", "0.48271614", "0.48271614", "0.48260376", "0.48232728", "0.48215586", "0.4815332", "0.48055035", "0.4804391", "0.4799283", "0.47829527", "0.47786987", "0.47412926", "0.4740889", "0.47372183", "0.47319102", "0.47199804", "0.4719599", "0.4719585", "0.47177914", "0.47074223", "0.46839285", "0.46706372", "0.46485135", "0.46464345", "0.46418378", "0.46229452", "0.46224412", "0.4611399", "0.4610986", "0.46078452", "0.4601536", "0.4597296", "0.45931154", "0.45928895", "0.45928174", "0.45888", "0.4588625", "0.45842", "0.4580571", "0.45788196", "0.4570794", "0.4561271", "0.4560254", "0.45590258", "0.4558564", "0.45511034", "0.4547378", "0.4542255", "0.4542212", "0.45404276", "0.45401347", "0.45376146", "0.45354545", "0.45345703", "0.45279035", "0.45266977", "0.45250908", "0.45242256", "0.4506687", "0.450581", "0.450196", "0.45004448", "0.44957817", "0.44930103", "0.44906345", "0.4486381", "0.4486137", "0.44795865", "0.44793847", "0.44751182" ]
0.7025142
0
run the query and add the users found as filters expects you to select and return only the user_ids
def add_users_query(db, proc) # since we are running a query, no longer match all even if it returns nothing ensure_user_ids sql = proc.call(date_first, date_last) results = db.execute(sql) # this form expects to see multiple result rows results.each do |r| user_id = r[0].to_i add_user_id(user_id) unless user_id == 0 end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def find_users_id_from_query\n if query_is_mifare_number?\n find_users_from :card\n else\n found_user_ids = Set.new\n\n USER_SOURCES_PRIORITY.each do |source|\n if found_user_ids.size < USER_COUNT_SEARCH_LIMIT\n found_user_ids.merge(find_users_from source)\n end\n end\n\n found_user_ids.take(USER_COUNT_SEARCH_LIMIT)\n end\n end", "def possible_users\n ids = []\n ids = condition.scan(/\\d+/) if condition.present?\n User.where(:id => ids)\n end", "def fetch_users\n user_relational_query = get_model_query\n @total_filtered_users = user_relational_query.count\n\n return if @total_filtered_users < 1\n offset = 0\n offset = @page_size * (@page_number - 1) if @page_number > 1\n @users = user_relational_query.limit(@page_size).offset(offset).all\n # No need to query kyc detail if filter applied is kyc_submitted_no\n if @allowed_filters[GlobalConstant::User.is_kyc_submitted_filter].to_s != GlobalConstant::User.kyc_submitted_false\n @user_kyc_details = UserKycDetail.using_client_shard(client: @client).\n where(user_id: @users.collect(&:id)).all.index_by(&:user_id)\n end\n end", "def user_ids\n page = 1\n per_page = 100\n user_ids = []\n puts 'collecting all user ids'\n loop do\n response = @conn.get api_url('/users'),\n { page: page, per_page: per_page }.merge(token)\n raise 'Error Retrieving user_ids' if response.status != 200\n ids = JSON.parse(response.body).collect { |u| u['id'] }\n user_ids.concat(ids)\n break if ids.size < per_page\n page += 1\n end\n puts 'returning now the user ids'\n user_ids.sort\n end", "def users\n Ecore::User.find(@user_id, :group_ids.like(\"%#{@id}%\")).receive(:all)\n end", "def users\n Ecore::User.where(\"group_ids LIKE '%#{id}%'\").all\n end", "def user_ids_sql\n \"#{member_user_ids_sql} UNION SELECT user_id FROM project_medias WHERE team_id = #{team_id}\"\n end", "def users_invited_by_query_v2(start_day, end_day, user_ids_in=nil)\n\n return \"SELECT * FROM users WHERE 0\" if !user_ids_in.nil? && user_ids_in.size == 0\n\n and_user_ids_in = \"AND u.invited_by_source_user_id IN (#{user_ids_in.join(\",\")})\" unless user_ids_in.nil?\n\n return \"SELECT u.id\n FROM users u\n WHERE u.created_at BETWEEN '#{start_day} 00:00:00' AND '#{end_day} 23:59:59'\n AND u.invited_by_source_user_id IS NOT NULL\n #{and_user_ids_in}\"\n end", "def permitted_users_id\n\treturn_user_ids = Array.new\n\tif !self.venue_id.nil?\n\t return_user_ids = ActiveInVenue.where(venue_id: self.venue_id).where.not(user_id: self.user_id).map(&:user_id)\n end\n\tif self.allow_nearby\n\t\treturn_user_ids = return_user_ids | User.where.not(id: self.user_id).near([self.latitude, self.longitude], 25, units: :km).map(&:id)\n\tend\n\tblack_list = BlockUser.blocked_user_ids(self.user_id)\n \tcontent_black_list = ShoutReportHistory.where(reportable_id: self.id).where(reportable_type: 'Shout').map(&:reporter_id)\n \treturn_user_ids = return_user_ids - black_list - content_black_list\n\n \t# only user pusher for online users\n \tonline_users_ids = User.where(id: return_user_ids).where(pusher_private_online: true).map(&:id)\n \treturn online_users_ids\n end", "def users\n company_ids = [self.id]\n company_ids += advisor_company_ids if advised?\n\n user_ids = UserAffiliation.where(:company_id.in => company_ids).with_access.only(:user_id).map(&:user_id)\n User.where(:id.in => user_ids).order_by(created_at: :asc)\n end", "def user_ids\n self.class.where(id: id).user_ids\n end", "def searchUsers\n # if current_user.rolable.class.name == \"Charity\"\n # return User.where.not(rolable_type: 'Business')\n # # list_a = User.where(rolable_type: 'Business').order(:rolable_id).pluck(:id, :rolable_id)\n # # search_list = Business.order(:id).pluck(:id, :name)\n\n # # search_list.each_with_index do |x, index|\n # # x[0] = list_a[index][0]\n # # end\n # # sea\n # # search_list = Business.where(active: true).pluck(:name)\n # # search_list.each do |b|\n # # list << b.name\n # # current_user\n # elsif current_user.rolable.class.name == \"Business\"\n # return User.where(rolable_type: 'Charity')\n # # list_a = User.where(rolable_type: 'Charity').order(:rolable_id).pluck(:id, :rolable_id)\n # # search_list = Charity.order(:id).pluck(:id, :name)\n # # search_list.each_with_index do |x, index|\n # # x[0] = list_a[index][0]\n # # end\n # # # search_list.each do |c|\n # # # list << c.name\n # # # end\n # end\n return User.where.not(rolable_type: 'Donor')\n end", "def user_ids\n post\n .organization\n .users\n .select(:id)\n .where('members.active = true')\n .where('users.push_notifications = true')\n end", "def all_ids(opts={}, &block)\n user_id = options.delete(:user_id) || User.me.id\n\n opts = options.merge opts\n\n from = \"/users/#{user_id}#{collection_path}/search\"\n\n has_results = true\n ids = []\n\n while has_results && opts[:pages] != opts[:page] do\n params = { limit: opts[:limit],\n offset: opts[:offset] }\n\n path = \"#{from}#{query_string(params)}\"\n data = format.decode(connection.get(path, headers).body) || []\n\n\n results = data[\"results\"]\n has_results = (results.any? and results.count == opts[:limit])\n\n opts[:page ] += 1\n opts[:offset ] += opts[:limit]\n\n yield(results, data, options) if block_given?\n\n ids.concat results\n end\n\n ids\n end", "def users\n User.in(id: user_promotions.pluck(:user_id))\n end", "def index\n @filter = params[:filter] if params.has_key? :filter and %w{unapproved invited}.include? params[:filter]\n\n if params[:search]\n @search = User.search { fulltext params[:search] }\n @users = user_query.where(id: @search.results.map(&:id))\n else\n @users = user_query.order(updated_at: :desc)\n end\n end", "def search_users(term, value)\n results = @users_indice.search(term: term, value: value)\n if perform_search_by_id?(term)\n results.each do |user|\n # Get related organizations\n user['organizations'] =\n @organizations_indice.search_by_primary_key(value: user['organization_id'])\n\n # Get submitted tickets related to user\n user['submitted_tickets'] =\n @tickets_indice.search(term: 'submitter_id', value: user['_id'])\n\n # Get assigned tickets related to user\n user['assigned_tickets'] =\n @tickets_indice.search(term: 'assignee_id', value: user['_id'])\n end\n end\n results\n end", "def user_ids\n users.pluck(:id)\n end", "def index\n @user_ids = UserId.all\n end", "def users_invited_by_query(start_day, end_day, user_ids_in=nil)\n\n return \"SELECT * FROM users WHERE 0\" if !user_ids_in.nil? && user_ids_in.size == 0\n\n and_user_ids_in = \"AND u.invited_by_source_user_id IN (#{user_ids_in.join(\",\")})\" unless user_ids_in.nil?\n\n return \"SELECT COUNT(*)\n FROM users u\n WHERE u.created_at BETWEEN '#{start_day} 00:00:00' AND '#{end_day} 23:59:59'\n AND u.invited_by_source_user_id IS NOT NULL\n #{and_user_ids_in}\"\n end", "def household_users\n User.where(id: household_user_ids)\n end", "def userids(*values)\n values.inject(self) { |res, val| res._userids(val) }\n end", "def get_related_users(query='', results=10, start=0)\r\n get_related('Users',query, results, start)\r\n end", "def get_user_ids(deal_id, multiple_redeem = false)\n date = DateTime.now.in_time_zone(\"Singapore\").end_of_day\n if multiple_redeem\n user_ids = Array.new\n all_users = Redemption.where(deal_id: deal_id).where(\"created_at <= ?\", date).select(:user_id).distinct.pluck(:user_id)\n all_users.each do |au|\n if Redemption.where(deal_id: deal_id, user_id: au).count > 1\n user_ids << au\n end\n end\n user_ids\n else\n Redemption.where(deal_id: deal_id).where(\"created_at <= ?\", date).select(:user_id).distinct.pluck(:user_id)\n end\n end", "def user_ids=(values)\n values ||= []\n values = [ values ] unless values.is_a?(::Array)\n values = values.reject{|v| v.blank?}.map{|v| v.to_i}\n self.users = Incline::User.where(id: values).to_a\n end", "def filter_by_user_id\n @query = @query.where(user_id: @user_id)\n end", "def matched_users\n @matched_users ||= @provider_user.find_records\n end", "def user_collaboration_search(q, limit=10)\n if q.present? and q.length > 1\n already_exists_ids = []\n already_exists_emails = []\n # add owner\n # already_exists_ids << self.user_id\n # add colaborators\n if self.users.present?\n already_exists_ids << self.users.map{|x| x.id}\n end\n # add invitations\n pending = Invitation.pending_by_story(self.id)\n if pending.present?\n already_exists_emails << pending.map{|x| x.to_email}\n end\n\n already_exists_ids.flatten!\n already_exists_emails.flatten!\n\n sql = \"\"\n if already_exists_ids.present? && already_exists_emails.present?\n sql = \"!(id in (:ids) or email in (:emails)) and \"\n elsif already_exists_ids.present?\n sql = \"!(id in (:ids)) and \"\n elsif already_exists_emails.present?\n sql = \"!(email in (:emails)) and \"\n end\n sql << \"(nickname like :search or email_no_domain like :search)\"\n users = User.where([sql,\n :ids => already_exists_ids.uniq,\n :emails => already_exists_emails.uniq,\n :search => \"%#{q}%\"])\n .limit(limit)\n return users\n end\n end", "def filter_by_user\n users = TaskFilter.filter_user_ids(session)\n return \"\" if users.empty? or users.include?(ALL_USERS)\n\n task_ids = []\n users.each do |id|\n if id > 0\n u = User.find(id)\n task_ids += u.tasks.map { |t| t.id }\n elsif id == UNASSIGNED_TASKS\n join = \"LEFT OUTER JOIN task_owners t_o ON tasks.id = t_o.task_id\"\n conditions = [\"tasks.company_id = ? AND t_o.id IS NULL\", @company.id ]\n unassigned = Task.find(:all, :select => \"tasks.*\", \n :joins => join,\n :readonly => false, \n :conditions => conditions)\n task_ids += unassigned.map { |t| t.id }\n end\n end\n\n task_ids = [ \"0\" ] if task_ids.empty?\n return \"tasks.id IN (#{ task_ids.join(\", \") }) AND \"\n end", "def index\n @userids = Userid.all\n end", "def index\n @regdetails = Regdetail.select(:user_id).distinct\n @user_ids = @regdetails.collect { |r| r.user_id }\n @registered_users = User.find(@user_ids).paginate(:page => params[:page], :per_page => 5)\n # @registered_users = @registered_users.paginate(:page => params[:page], :per_page => 4)\n\n end", "def index\n StatsManager::StatsD.time(Settings::StatsConstants.api['user']['index']) do\n if params[:ids]\n ids = params[:ids].split(\",\")\n if ids.length <= 10\n @users = User.find(ids)\n @status = 200\n else\n render_error(400, \"too many ids included (max 10)\")\n end\n elsif user_signed_in?\n @status = 200\n @user = current_user\n @user_personal_roll_subdomain = (@user.public_roll and @user.public_roll.subdomain)\n render 'v1/user/show'\n else\n render_error(401, \"current user not authenticated\")\n end\n end\n end", "def user_ids\n self.users.collect{|ud| ud.id}\n end", "def consuming_users(day, user_ids_in=nil)\n\n and_user_ids_in = \"AND user_id IN (#{user_ids_in.join(\",\")})\" unless user_ids_in.nil?\n\n return \"SELECT DISTINCT user_id\n FROM ns2_notification_items\n WHERE created_at BETWEEN '#{day} 00:00:00' AND '#{day} 23:59:59'\n #{and_user_ids_in}\"\n end", "def user_ids\n users.collect(&:id)\n end", "def user_search\n @users = User.admin_search(params[:query])\n end", "def users\n Webmail::User.in(group_ids: id)\n end", "def index\n if(current_user.entidade_id.nil?)\n @users = []\n @users.push User.find_by(email: current_user.email)\n else\n @users = User.where(entidade_id: current_user.entidade_id.to_int)\n end\n\n if(current_user.tipo.eql? 1)\n @users = User.where('tipo = 1 or tipo = 2 or tipo = 4')\n elsif(current_user.tipo.eql? 2)\n @users = User.distinct()\n .joins('left join reservas r on users.id = r.user_id')\n .where('(tipo in(2,3) and users.entidade_id=?) or (tipo = 4 and r.entidade_id=?)', current_user.entidade_id, current_user.entidade_id)\n elsif(current_user.tipo.eql? 3)\n @users = User.distinct()\n .joins('left join reservas r on users.id = r.user_id')\n .where('tipo = 4 and r.entidade_id=?', current_user.entidade_id)\n else \n end\n end", "def get_users\n\t\t\t@users = User.all.where(:on_beverage_list => true).order('firstname, lastname')\n\t\tend", "def all_users\n query = users.to_sql + \"\\nUNION\\n\" + User.where(id: super_admin_id).to_sql\n User.find_by_sql(query)\n end", "def users\n users = []\n if current_user.lead?\n users = object.users.select { |u| u.id != current_user.id }\n users = users.unshift(current_user)\n elsif current_user.dev?\n vms_v = object.vms.select { |vm| vm.is_jenkins }\n users = vms_v.flat_map(&:user).uniq.select { |u| u.id != current_user.id }\n users = users.unshift(current_user)\n else\n users <<= current_user\n end\n users.map { |u| u.id }\n end", "def getUsers\r\n if params[:userTerm].blank? \r\n params[:userTerm] = nil\r\n end\r\n if params[:page].nil?\r\n params[:page] = 1\r\n end\r\n if params[:type].blank?\r\n params[:type] = 0 # 0 - ue part. ,1 - exp followers, 2 user following, 3 user followers\r\n end\r\n if params[:id].blank? && !UsersExprience.isExists(params[:id].to_i) && params[:typeview] == 0\r\n params[:id] = 0 # 0 - ue part. , user exp follow , 1 - reported, 2- global\r\n end\r\n users = nil\r\n case params[:type].to_i\r\n when 0\r\n user_existed = ''\r\n if params[:id].to_i != 0\r\n user_existed = UsersExprienceFollowers.following(params[:id].to_i).map(&:users_id).join(\",\") \r\n else \r\n user_existed = UsersExprienceFollowers.following(params[:id].to_i).map(&:user_id).join(\",\") \r\n end\r\n unless UsersExprienceFollowers.following(params[:id].to_i).size != 0\r\n users = UsersFollows.followers(params[:user].id).uniq\r\n else\r\n users = UsersFollows.followers(params[:user].id).where(\"users_follows.user_id not in (\" + user_existed +\")\").uniq\r\n end \r\n when 1 \r\n users = UsersExprienceFollowers.following(params[:id].to_i).uniq\r\n when 2\r\n users = UsersFollows.following(params[:user].id).uniq\r\n else \r\n users = UsersFollows.followers(params[:user].id).uniq\r\n end\r\n unless params[:userTerm].blank? \r\n searchTerms = \"%\" + params[:userTerm].downcase + \"%\"\r\n users = users.where(\"lower(users_profiles.lname) like ? or lower(users_profiles.fname) like ?\",searchTerms,searchTerms)\r\n end \r\n users = users.page(params[:page].to_i).per(APP_CONFIG[\"Max_Page\"])\r\n usersProfile = Array.new\r\n users.each do |item|\r\n userObj = nil\r\n case params[:type].to_i\r\n when 2\r\n userObj = UsersProfile.byUser(item.ref_user_id).first\r\n when 3\r\n userObj = UsersProfile.byUser(item.user_id).first\r\n else\r\n userObj = UsersProfile.byUser(item.id).first\r\n end\r\n\r\n unless userObj.nil?\r\n asset = {\r\n :id => -1,\r\n :uri=> ''\r\n }\r\n unless userObj.image_id.nil?\r\n if userObj.image_id != 0 \r\n assetObj = Assets.where({id:userObj.image_id}).first.asset.url(:small)\r\n asset[:id] = userObj.image_id\r\n asset[:uri] = assetObj\r\n end\r\n end\r\n is_ue = false\r\n is_follow = false\r\n if params[:type].to_i == 1&& !UsersExprience.isExists(params[:id].to_i)\r\n is_uep = !UsersExprienceParticipants.isExists(item.id,params[:id].to_i)\r\n end\r\n if params[:type].to_i == 2 \r\n is_follow = !UsersFollows.isExists(item.user_id,params[:user].id)\r\n end\r\n if params[:type].to_i == 3\r\n is_follow = UsersFollows.isExists(item.user_id,params[:user].id)\r\n end\r\n \tdataHash ={\r\n \t\tfname: userObj.fname,\r\n \t\tlname: userObj.lname,\r\n \t\tid: userObj.user_id,\r\n \t\timage: asset,\r\n status: {\r\n is_follow: is_follow\r\n }\r\n \t}\r\n \tusersProfile.push(dataHash)\r\n end\r\n end\r\n @responseObject = OpenStruct.new({\r\n status: true,\r\n errors: [],\r\n code: API_CODE_ERRORS['Services']['Global']['success'],\r\n objectData: OpenStruct.new({ items: usersProfile, total: users.num_pages }),\r\n timestamp: (Date.new).to_time.to_i.abs\r\n })\r\n \trender :template => 'api/v1/users/members/getUsers' ,:handlers => [:rabl], :formats => [:json]\r\n\tend", "def index\n @search = User.search(params[:q])\n @users = @search.result #.includes(:user)\n end", "def find_user\n self.user_lookup_failed = false\n unless self.user_ids.blank?\n my_users = User.scoped.extending(QueryHelper::WhereIn).where_in('id', self.user_ids)\n unless my_users.blank?\n self.users = my_users\n else\n self.user_lookup_failed = true\n end\n end\n # be sure the call back returns true or else the call will fail with no error message\n # from the validation loop\n return true\n end", "def all_users\n @user = User.where(created_by: @current_user.id).select(:id,:email,:username,:mobile,:address)\n if @user.present?\n render json: {success:true,data:@user}\n else\n render json: {success:false,message:\"No Records Found\"}\n end\n end", "def get_users(count=42, offset=0)\n # Build a Filter String with a corresponding array of\n # prepared filters for the sql execution\n # (prepared statements prevent sql injection)\n prepared_filters = []\n filter_string = \"\"\n\n ALLOWED_FILTERS.each do |filter_name|\n if params.has_key?(filter_name) && \"All\" != params[filter_name]\n filter_string += \" AND #{filter_name} LIKE ?\"\n prepared_filters << params[filter_name]\n end\n end\n\n # If no user filters provided we will defalt to California\n filter_string = \"AND location LIKE '%CALIFORNIA%'\" if filter_string.empty?\n\n prepared_filters << count.to_i\n prepared_filters << offset.to_i\n\n # Connect to the database\n Database.new.execute(\n \"SELECT pictures.username,\n pictures.url,\n profiles.created_at,\n profiles.location\n FROM pictures\n JOIN profiles ON profiles.username = pictures.username\n WHERE size = 'small' #{filter_string}\n ORDER BY profiles.created_at DESC\n LIMIT ? OFFSET ?\",\n prepared_filters\n )\n end", "def users\n User.where(network_id: context[:current_network]&.id)\n end", "def enabled_user_ids\n User\n .non_admins\n .find_each(batch_size: 100).each_with_object([]) do |user, ids|\n ids.push(user.id) if user.feature_enabled?(:block_level_sync)\n end\n end", "def get_user_ids\n @assigned_lawfirm_users.map(&:id)\n end", "def memberships_users\n group_ids_select = memberships.select(:user_id).where(user_type: 'Group')\n\n User.where('id IN (:user_ids) OR id IN (:group_owner_ids)',\n user_ids: memberships.select(:user_id).where(user_type: 'User'),\n group_owner_ids: Group.where(id: group_ids_select).select(:owner_id))\n end", "def liked_users \n users = object.liked_users.collect do |liked_user|\n # user = User.find_by(id: liked_user.liked_user_id)\n # user.attributes.except!(\"created_at\", :updated_at, :email)\n user = User.select(:id, :name, :gender, :age, :bio).find_by(id: liked_user.liked_user_id)\n end\n end", "def users(*args)\n params = arguments(args, required: [:q]).params\n params['q'] ||= arguments.q\n\n get_request('/search/users', arguments.params)\n end", "def uids\n return [] unless valid?\n\n queries.search(name_query).merged_uids\n end", "def searchUsers\n \n \n query_processing_time_begin = Time.now\n # In web-ui query processing time is only shown if asked. In atom-feed, it is always shown.\n if params[\"query_processing_time\"] && params[\"query_processing_time\"].downcase == \"true\"\n @query_processing = true\n end\n if params[:qoption] && params[:qoption][\"query_processing_time\"] == \"true\"\n @query_processing = true\n end\n \n @json_callback = nil\n if params[:qoption] && params[:qoption][\"json_callback\"]\n @json_callback = params[:qoption][\"json_callback\"]\n end\n \n @queryparams = params\n\n if params[:qoption] && params[:qoption][\"format\"]\n @queryparams[:format] = params[:qoption][\"format\"]\n end\n \n if params[:q] && params[:q][\"user\"]\n @queryparams[:user] = params[:q][\"user\"]\n end\n \n \n # host parameter, needed when creating atom-feed\n if request.ssl?\n @request_url = \"https://#{request.host}\"\n else\n @request_url = \"http://#{request.host}\"\n end\n\n if request.port != nil and request.port != 80\n @request_url += \":#{request.port}\"\n end\n \n @request_url += request.request_uri\n\n @query_search = \"\"\n if @queryparams[:user] and @queryparams[:user] !~ /[^\\w\\.\\s\\-\\_\\+]/\n @query_search = @queryparams[:user]\n usersstring = searchtermForSql(@queryparams[:user], \"username\") + \" OR \" + searchtermForSql(@queryparams[:user], \"real_name\")\n @users = User.find(:all, :conditions => usersstring)\n end \n \n if @queryparams[:format] == \"yaml\" or @queryparams[:format] == \"json\"\n @yaml_results = {}\n @users.each do |user|\n begin\n\n userObject = UserObject.new(user)\n @yaml_results.merge!({userObject.get_uri => userObject.to_yaml})\n \n rescue Exception => e\n putsE(e)\n end\n end\n #puts @yaml_results.to_s\n end\n \n if query_processing_time_begin != nil\n query_processing_time_end = Time.now\n @query_processing_time = query_processing_time_end - query_processing_time_begin\n puts \"Time used for processing query: #{@query_processing_time}\"\n end\n \n # Renderöinti\n @host = @@http_host\n respond_to do |format|\n if @queryparams[:format] == nil\n format.html {render :searchUsers, :layout=>true }\n else\n format.html {render :searchUsers, :layout=>true }\n format.atom {render :searchUsers, :layout=>false }\n format.yaml { render :text => YAML.dump(@yaml_results), :layout=>false }\n if @json_callback == nil\n format.json { render :text => JSON.dump(@yaml_results), :layout=>false }\n else\n format.json { render :text => @json_callback + '(' + JSON.dump(@yaml_results) + ')', :layout=>false }\n end\n end\n end\n \n end", "def users(filter = {})\n handler[:people].filter(filter)\n end", "def users\n \n @users = User.where(:enabled => true)\n @users = @users.where(:role => params[:role].upcase) if params[:role]\n @users = @users.where(:id => params[:id]) if params[:id]\n respond_to do |format|\n format.xml { render :xml => @users.to_xml }\n end\n \n end", "def index \n \t@items = Item.paginate(page: params[:page])\n\n @user_items = current_user.user_items.pluck(:id).uniq\n @all_user_items = UserItem.where(id: @user_items)\n end", "def update_find\n @user = User.new\n @users_array = User.select(\"id, email\")\n \n render \"update_find\"\n end", "def index_users\n load_alert\n return if (@alert.blank?)\n\n # Preload the users\n @users = User.where(:_id.in => @alert.user_ids)\n\n respond_to do |format|\n format.html\n end\n end", "def index\n authorize User\n\n @users = !!params[:search] ? User.search_includes(params[:search]) : User.all_includes\n\n @users = User.filter_with(@users, params[:filter]) if !!params[:filter]\n\n @users = User.sort_num_desc(@users, params[:sort_by]) if !!params[:sort_by]\n end", "def user_ids\n UsersRole\n .joins(:role)\n .where(Role.arel_table[:resource_identifier].in(identifiers))\n .pluck(:user_id)\n .uniq\n end", "def get_users(id)\r\n db = connect() \r\n return result2 = db.execute(\"SELECT * FROM users WHERE userid=(?)\", id)\r\n end", "def index\n params[:q] = {} if params[:q].blank?\n params[:q][:company_id_eq] = current_user.company_id\n @q = User.search(params[:q])\n @users = @q.result(:distinct => true).paginate(:page => params[:page])\n end", "def users\n records do |instance|\n instance['users'] = user.where('organization_id': instance['_id'])\n end\n end", "def users\n signups.map do |signup|\n user_id = signup.user_id\n User.all.find {|user| user.id == user_id}\n end\n end", "def projects_users\n all_users_ids = projects.map { |project| project.user_ids }\n all_users_ids.flatten!\n all_users_ids.uniq!\n User.all(conditions: {:_id.in => all_users_ids})\n end", "def projects_users\n all_users_ids = projects.map { |project| project.user_ids }\n all_users_ids.flatten!\n all_users_ids.uniq!\n User.all(conditions: {:_id.in => all_users_ids})\n end", "def users\n user_arr = []\n accounts.each do |s|\n user_arr << User.find(s.user.id)\n end\n user_arr\n end", "def index_user # :nologin: :norobots:\n if is_in_admin_mode? || find_query(:User)\n query = find_or_create_query(:User, by: params[:by])\n show_selected_users(query, id: params[:id].to_s, always_index: true)\n else\n flash_error(:runtime_search_has_expired.t)\n redirect_to(action: \"list_rss_logs\")\n end\n end", "def users(query)\n get_endpoint('users', nil, {'q' => query})[\"users\"].map{|u| \n Bibliovore::User.new(u, self)\n }\n end", "def related_users_query(list_id)\n <<-SQL\n SELECT DISTINCT \"users\".*\n FROM \"users\"\n INNER JOIN \"users_lists\"\n ON \"users\".\"id\" = \"users_lists\".\"user_id\"\n WHERE \"users_lists\".\"list_id\" IN (\n SELECT \"lists\".\"id\"\n FROM \"lists\"\n INNER JOIN \"users_lists\"\n ON \"lists\".\"id\" = \"users_lists\".\"list_id\"\n WHERE \"users_lists\".\"user_id\" = #{id}\n )\n AND NOT \"users\".\"id\" IN (\n SELECT \"users_lists\".\"user_id\"\n FROM \"users_lists\"\n WHERE \"users_lists\".\"list_id\" = #{list_id}\n );\n SQL\n end", "def get_users\n @get_users = Rails.cache.fetch(\"get_aside_users\", :expires_in => 1.hours) do\n if @current_user.present?\n Core::User.active.where(\"verified = 1 AND id != #{@current_user.id}\").order(position: :desc, created_at: :desc).limit(10).sample(3)\n else\n Core::User.active.where(\"verified = 1\").order(position: :desc, created_at: :desc).limit(10).sample(3)\n end\n end\n end", "def select_all_user_info_id(user_id)\n p \"uder id #{user_id}s\"\n p \"look here#{get_db_as_hash().execute(\"SELECT * FROM user WHERE user_id = ?\", user_id).first}\"\n return get_db_as_hash().execute(\"SELECT * FROM user WHERE user_id = ?\", user_id).first\n end", "def get_set_of_user_ids(arr_of_user_names)\n set_of_user_ids = Set.new\n\n arr_of_user_names.each { |name|\n @url = \"http://#{$canvas_host}/api/v1/courses/#{$canvas_course_id}/users\"\n puts \"@url is #{@url}\"\n \n @payload={'search_term': name}\n puts(\"@payload is #{@payload}\")\n \n @getResponse = HTTParty.get(@url, :body => @payload.to_json, :headers => $header)\n puts(\" GET to get user has Response.code #{@getResponse.code} and getResponse is #{@getResponse}\")\n \n user_data = @getResponse.parsed_response\n \n user_data.each do |user_data_info|\n set_of_user_ids.add user_data_info[\"id\"]\n end\n }\n \n return set_of_user_ids\nend", "def targeted_users\r\n if groups.any?\r\n target = []\r\n groups.each do |group|\r\n target << group.active_members\r\n end\r\n\r\n target.flatten!\r\n target_ids = target.map{|u| u.id}\r\n\r\n target = User.where(id: target_ids)\r\n else\r\n target = enterprise.users.active\r\n end\r\n\r\n target = target.for_segments(segments) unless segments.empty?\r\n\r\n target.uniq{|u| u.id}\r\n end", "def index\n\n @organization_id = params[:organization_id].to_i\n @search_text = params[:search_text]\n @role = params[:role].split(\",\") if params[:role]\n @id_filter_list = params[:ids]\n\n # Start to set up the query\n conditions = []\n values = []\n\n if @organization_id.to_i > 0\n conditions << 'users_organizations.organization_id = ?'\n values << @organization_id\n else\n conditions << 'users_organizations.organization_id IN (?)'\n values << @organization_list\n end\n\n\n unless @search_text.blank?\n # get the list of searchable fields from the asset class\n searchable_fields = User.new.searchable_fields\n # create an OR query for each field\n query_str = []\n first = true\n # parameterize the search based on the selected search parameter\n search_value = get_search_value(@search_text, @search_param)\n # Construct the query based on the searchable fields for the model\n searchable_fields.each do |field|\n if first\n first = false\n query_str << '('\n else\n query_str << ' OR '\n end\n\n query_str << \"UPPER(users.#{field})\"\n query_str << ' LIKE ? '\n # add the value in for this sub clause\n values << search_value.upcase\n end\n query_str << ')' unless searchable_fields.empty?\n\n conditions << [query_str.join]\n end\n\n unless @id_filter_list.blank?\n conditions << 'object_key in (?)'\n values << @id_filter_list\n end\n\n if params[:show_active_only].nil?\n @show_active_only = 'active'\n else\n @show_active_only = params[:show_active_only]\n end\n\n if @show_active_only == 'active'\n conditions << 'users.active = ?'\n values << true\n elsif @show_active_only == 'inactive'\n conditions << 'users.active = ?'\n values << false\n end\n\n # Get the Users but check to see if a role was selected\n @users = User.unscoped.distinct.joins(:organization).order('organizations.organization_type_id', 'organizations.short_name', :last_name).joins(:organizations).includes(:organization,:roles).where(conditions.join(' AND '), *values)\n\n unless @role.blank?\n all_users = @users\n @users = @users.with_role(@role[0])\n @role[1..-1].each do |r|\n @users = @users.or(all_users.with_role(r))\n end\n end\n\n if params[:sort] && params[:order]\n case params[:sort]\n when 'organization'\n @users = @users.reorder(\"organizations.short_name #{params[:order]}\")\n # figure out sorting by role + privilege some other way\n # when 'role_name'\n # @users = @users.joins(:roles).merge(Role.unscoped.order(name: params[:order]))\n # when 'privilege_names'\n # @users = @users.joins(:roles).merge(Role.order(privilege: params[:order]))\n else\n @users = @users.reorder(params[:sort] => params[:order])\n end\n end\n\n # Set the breadcrumbs\n if @organization_list.count == 1\n org = Organization.find(@organization_list.first)\n add_breadcrumb org.short_name, users_path(:organization_id => org.id)\n end\n if @role.present?\n role_string = @role.kind_of?(Array) ? Role.find_by(name: @role).try(:label).try(:parameterize).try(:underscore) : @role\n add_breadcrumb role_string.titleize, users_path(:role => role_string) if role_string\n end\n\n # remember the view type\n @view_type = get_view_type(SESSION_VIEW_TYPE_VAR)\n\n respond_to do |format|\n format.html # index.html.erb\n # format.json {\n # render :json => {\n # :total => @users.count,\n # :rows => @users.limit(params[:limit]).offset(params[:offset]).collect{ |u|\n # u.as_json.merge!({\n # organization_short_name: u.organization.short_name,\n # organization_name: u.organization.name,\n # role_name: !@role.blank? && (@role.kind_of?(Array) ? !Role.find_by(name:@role.first).privilege : !Role.find_by(name: @role).privilege) ? (@role.kind_of?(Array) ? u.roles.roles.where(name: @role).last.label : u.roles.roles.find_by(name: @role).label) : u.roles.roles.last.label,\n # privilege_names: u.roles.privileges.collect{|x| x.label}.join(', '),\n # all_orgs: u.organizations.map{ |o| o.to_s }.join(', ')\n # })\n # }\n # }\n # }\n\n end\n end", "def fetch_user_data\n @username = params[:username]\n @configured_sources = params[:source_ids] || []\n @result_set = Hash.new\n @configured_sources.each do |source|\n feed_result = fetch_feed(source,@username)\n @result_set[source] = feed_result\n end\n \n end", "def user_labels\n @users = User.where(id: params[:user_ids].split(\",\").map(&:to_i).uniq).all\n end", "def created_by_user(user_id, source_id, number_to_return = :all, starting_index = 0)\n # ids = PublicEarth::Db::Place.many.created_by_user(user_id, source_id, number_to_return == :all && 250 || number_to_return, starting_index).map { |result| result['created_by_user'] }\n ids = PublicEarth::Db::Place.many.created_by_user(user_id, source_id).map { |result| result['created_by_user'] }\n PublicEarth::Db::Place.find_from_search(*ids)\n end", "def get_target_users\n\n users = []\n\n self.get_orders.each do |user_hash|\n\n user_ids = user_hash.keys\n\n users = users + user_ids unless user_ids.nil?\n end\n\n users.compact!\n\n return users\n end", "def users_who_created_activity_query(start_day, end_day, user_ids_in=nil)\n\n return \"SELECT * FROM users WHERE 0\" if !user_ids_in.nil? && user_ids_in.size == 0\n\n and_user_ids_in = \"AND subj_id IN (#{user_ids_in.join(\",\")})\" unless user_ids_in.nil?\n\n return \"SELECT subj_id\n FROM activity_items\n WHERE created_at BETWEEN '#{start_day} 00:00:00' AND '#{end_day} 23:59:59'\n AND subj_type = \\\"User\\\"\n AND obj_type IN (\\\"Event\\\", \\\"EventMessage\\\", \\\"InviteResponse\\\")\n #{and_user_ids_in}\n GROUP BY subj_id\"\n end", "def household_user_ids\n @household_user_ids || household.users.where.not(id: id).pluck(:id)\n end", "def household_user_ids\n @household_user_ids || household.users.where.not(id: id).pluck(:id)\n end", "def user_ids \n @user_ids ||= input[\"users\"].map{|user| user[\"id\"]}\nend", "def location_users_filter\n @location = Location.where(\"id = #{params[:location_id]}\").first\n @sub_locations = @location.locations\n full_tree_location_ids = @location.parent_location_full_child_tree\n logger.debug(\"**************** #{full_tree_location_ids}\")\n\n @users = User.where(\"location_id IN (#{full_tree_location_ids})\")\n \n respond_to do |format|\n format.js\n end\n end", "def set_users\n \n columns=params[:columns]\n order=params[:order][\"0\"]\n search_list=User.attribute_names.select do |item|\n !@model_config[item].nil? && @model_config[item][\"searchable\"]\n end\n @filteredUsers=User.all\n @filteredUsers=@filteredUsers.order(\"#{columns[order[\"column\"]][\"data\"]} #{order[\"dir\"]}\") #单项排序\n @users=@filteredUsers.offset(params[:start]).limit(params[:length])\n end", "def fetch_users(limit)\n system_users = %w[AFL APL LSC MSEL SAIS WELCH reserve Nanjing ILS1]\n ds = @db[@illiad_table].where(\n userinfo1: nil,\n userinfo3: nil,\n emailaddress: nil,\n nvtgc: @nvtgc\n ).exclude(\n username: system_users,\n cleared: %w[DIS]\n ).order_by(\n :userinfo3\n ).limit(limit)\n rescue Sequel::Error => e\n p 'ERROR: ' + e.message + ds\n end", "def index\n @user_types_map = User.user_types.map{|k, v| [k, v.humanize.pluralize]}.to_h\n @filter = params[:filter] || 'Current'\n if @filter == 'All'\n @users = User.order(:email)\n elsif @user_types_map.values.include? @filter\n @users = User.where(locked_out: false, user_type: @user_types_map.key(@filter)).order(:email)\n else\n @users = User.where(locked_out: false).order(:email)\n end\n end", "def get_users(request); end", "def research_individual\n @users = Array.new()\n User.all.each do |u|\n if !u.admin?\n @users.push(u)\n end\n end\n end", "def identities\n User.where(:provider => provider, :uid => uid)\n end", "def search_for(term, phone, email, type)\n\t\trelation = [-1, 1, 2, 3].include?(type) ? type : nil\n\t\tsql = \"select id from search_user_ids(?, ?, ?, ?, ?, #{self.class.per_page})\"\n\t\tids = User.find_by_sql([sql, self.id, term, phone, email, relation ]).map(&:id)\n\t\t# if ids.size && ids.size>0\n\t\t# \tUser.where(\"id in (?)\", ids);\n\t\t# else\n\t\t# \tUser.none\n\t\t# end\n\tend", "def user_search(query)\n get(\"/user/search/#{query}\")['users'].map { |u| User.new(self, u) }\n end", "def core_user_get_users(criteria)\n params = {}\n\n counter = 0\n criteria.each do |key,value|\n params['criteria[' + counter.to_s + '][key]'] = key.to_s\n params['criteria[' + counter.to_s + '][value]'] = value\n counter = counter + 1\n end\n\n response = request(params)\n\n if response['users']\n users = response['users'].map { |user| Hashie::Mash.new(user) }\n end\n end", "def extra_users_data_look_up\n return if @results.empty?\n\n tickets = DataStore.instance.tickets\n @results.each do |user|\n ticket_names = tickets.select { |t| t['assignee_id'] == user['_id'] }.map { |t| t['subject'] }\n user['tickets'] = ticket_names\n end\n end", "def core_user_get_users(criteria)\n params = {}\n\n counter = 0\n criteria.each do |key,value|\n params['criteria[' + counter.to_s + '][key]'] = key.to_s\n params['criteria[' + counter.to_s + '][value]'] = value\n counter += 1\n end\n\n response = request(params: params)\n\n if response['users']\n response['users'].map { |user| Hashie::Mash.new(user) }\n end\n end", "def list_users(page, filter = nil)\n return unless filter.nil? || filter.valid?\n\n user_values = User.all(self).values\n users = user_values.select { |u| filter.include?(u) } unless filter.nil?\n users_filtered, pagination_collection = Pagination.paginate_record(users, page, 10)\n [users_filtered, pagination_collection]\n end", "def addUsersToSearchContext(value)\n begin\n values = value.split(' ')\n values.each do |x|\n \n # Find each user and add its information to the search context\n user = User.find_by_username(x)\n if user != nil\n @context.merge!({:user=> user})\n puts \"Added user: #{user.username} to the search context\"\n user.devices.each do |d|\n @device_ids.push(d.id)\n end\n end\n end\n rescue => e\n puts \"Problem adding user to search context. E: #{e}\"\n end\n end", "def get_users_from_select(select)\n select = select.reject { |id| id.blank? }\n unless select.blank?\n group_ids = select.select {|group_id| group_id.start_with?(\"g\")}\n users = User.find(select - group_ids)\n group_users = group_ids.map {|group_id| group_id.sub! \"g\",\"\"}\n .map {|group_id| Group.find(group_id).users}\n .flatten\n group_users.concat(users).uniq\n end\n end", "def find_people\n @users=[]\n session[:search_opt] = params[:user]\n if request.post?\n @users = @login_user.search_query(params[:user],1)\n flash[:notice] = \"No results found.\" if @users.empty?\n end\n end" ]
[ "0.6915241", "0.6782004", "0.672524", "0.6550564", "0.649576", "0.6495702", "0.64841604", "0.6448145", "0.6443397", "0.6428057", "0.6426304", "0.63817537", "0.6351607", "0.63441473", "0.6334755", "0.63304937", "0.62921053", "0.62809527", "0.6263903", "0.6253346", "0.62506497", "0.6187387", "0.6159778", "0.61519724", "0.6131349", "0.6126356", "0.6125523", "0.6061962", "0.6060078", "0.6048187", "0.6031096", "0.6005384", "0.6002737", "0.59970134", "0.5993673", "0.5973608", "0.59557784", "0.5954556", "0.5953363", "0.59523046", "0.5952133", "0.59457695", "0.5931185", "0.5925924", "0.5924426", "0.5923861", "0.5921702", "0.5916931", "0.5912224", "0.5911183", "0.59083265", "0.5906275", "0.5905957", "0.5881793", "0.58775294", "0.58768517", "0.5876136", "0.58756864", "0.5874985", "0.5863099", "0.58569777", "0.5856565", "0.5851025", "0.58495885", "0.5846488", "0.58460623", "0.58460623", "0.58448786", "0.58390385", "0.5836842", "0.583266", "0.583238", "0.58259195", "0.582057", "0.5810382", "0.5807081", "0.58061236", "0.5801839", "0.579672", "0.5796467", "0.57933426", "0.5791719", "0.5791719", "0.5782783", "0.57817006", "0.5781607", "0.57766646", "0.5769799", "0.57683635", "0.5767127", "0.57639927", "0.5759453", "0.5757303", "0.575266", "0.57509863", "0.57421845", "0.57407403", "0.57385814", "0.57366604", "0.57324886" ]
0.6664304
3
run the cohorts query, this expects you to return: [[user_id, cohort],...] user_id, cohort from the select and will be filtered against any previous add_users_query calls to effectively limit the results by filtering various conditions together once complete, we return with a single array that contains the cohort counts in the given cohort array position you should iterate assuming a start index of 1 up to the length
def cohorts_query_local_merge(db, proc) sql = proc.call(date_first, date_last) results = db.execute(sql) sums = sum_cohorts(results) save_sums(sums) return sums end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cohorts_query_in(db, proc)\n sums = []\n # initialize the expected number of cohorts\n (1..current_cohort).each do |cohort|\n sums[cohort] = 0\n end\n\n if !@user_ids.nil?\n # build our user ids\n total_ids = @user_ids.length\n count = 0\n stmt = \"\"\n @user_ids.each do |user_id|\n if count % IN_CLAUSE_MAX == 0\n stmt << \"(#{user_id}\"\n else\n stmt << \",#{user_id}\"\n end\n count += 1\n if (count % IN_CLAUSE_MAX == 0) || (count == total_ids)\n # hit max batch size or last batch, submit the query\n stmt << \")\"\n sql = proc.call(date_first, date_last, stmt)\n stmt = \"\"\n results = db.execute(sql)\n results.each do |r|\n cohort = r[0]\n sum = r[1]\n sums[cohort] = 0 if sums[cohort].nil?\n sums[cohort] += sum\n end\n end\n end\n end\n\n save_sums(sums)\n return sums\n end", "def cohorts_query(db, proc)\n sums = []\n # initialize the expected number of cohorts\n (1..current_cohort).each do |cohort|\n sums[cohort] = 0\n end\n\n sql = proc.call(date_first, date_last)\n results = db.execute(sql)\n results.each do |r|\n cohort = r[0]\n sum = r[1]\n sums[cohort] = 0 if sums[cohort].nil?\n sums[cohort] += sum\n end\n\n save_sums(sums)\n return sums\n end", "def sum_cohorts(users)\n sums = []\n # initialize the expected number of cohorts\n (1..current_cohort).each do |cohort|\n sums[cohort] = 0\n end\n\n users.each do |user|\n user_id = user[0]\n cohort = user[1]\n sums[cohort] = 0 if sums[cohort].nil?\n if match_user_id?(user_id)\n sums[cohort] += 1\n end\n end\n\n return sums\n end", "def index\n @cohort_users = CohortUser.all\n end", "def cohorts\n # participants.find(:all, :select => [:grad_year]).collect(&:grad_year).uniq.compact.sort.reverse\n @cohorts ||= participants.find(:all, :select => \"DISTINCT grad_year\").collect(&:grad_year).compact.sort.reverse\n end", "def available_cohorts(user)\n\t\tuser.nil? ? self.cohorts : self.cohorts - user.cohorts\n\tend", "def index\n @cohorts = Cohort.all\n end", "def index \n @cohorts = Cohort.all\n \n end", "def cohort\n return @cohort\n end", "def index\n\t\tauth_producer\n\t\t@cohorts = @current_user.cohorts\n\tend", "def cohort_list(list)\n\tlist.each do |cohort, num_of_students|\n\t\tputs \"#{cohort}: has #{num_of_students} students\"\n\tend\nend", "def cohort()\n return @cohort\nend", "def index\n @cohorts = current_user.accessible_cohorts\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @cohorts }\n end\n end", "def index\n render json: serializer_class.new(paginate(ecf_schools), params: { cohort: }).serializable_hash.to_json\n end", "def list\n @course = find_course_by_slug(params[:id])\n cohort = Cohort.find_by(title: cohort_params[:title])\n unless cohort\n render json: {\n message: \"Sorry, #{cohort_params[:title]} is not a valid cohort.\"\n }, status: 404\n return\n end\n ListCourseManager.new(@course, cohort, request).manage\n end", "def available_users(cohort)\n\t\tcohort.nil? ? self.users : self.users - cohort.users\n\tend", "def index\n @cohort_fellows = CohortFellow.all\n end", "def index\n redirect_to cohort_path(@cohort) if @current_user.is_student? @cohort\n\n @tasks = @cohort.tasks\n\n if params[:unit]\n @submissions = Unit.find(params[:unit]).submissions.where(task: @tasks)\n else\n @submissions = Submission.where(task: @tasks)\n end\n\n # Users corresponding to these submissions.\n # TODO: refactor to get users in this cohort, which should be the same as users with submissions\n @users = User.from_submissions(@submissions)\n\n # most recent unaccepted Submission for each user\n # TODO: refactor - this is slow\n @most_recent_submissions = @cohort.unaccepted_submissions\n\n by_status = @most_recent_submissions.group_by{ |s| s['status'] }\n\n @submission_by_status = {\n 'Pending Review' => by_status['Pending Review'],\n 'Not Accepted' => by_status['Not Accepted']\n }\n end", "def index\n @cohort = Cohort.find(params[:cohort_id])\n respond_to do |format|\n format.html\n format.js\n end\n end", "def account_group(cohort)\n group_of_3 = cohort.sample(3)\n cohort -= group_of_3\n puts \"Accountability Group(3 people): \"\n group_of_3.each do |index|\n puts index\n end\n group_of_4 = cohort.sample(4)\n cohort -= group_of_4\n puts \"Accountability Group(4 people): \"\n group_of_4.each do |index|\n puts index\n end\nuntil cohort.empty?\n group_of_5 = cohort.sample(5)\n cohort -= group_of_5\n puts \"Accountability Group: \"\n group_of_5.each do |index|\n puts index\n end\nend\nend", "def cohort_student_assignments\n StudentAssignment.joins(:student).where(student: self.students)\n end", "def list_cohorts\n @students.each do |student_info|\n if (@cohorts.include? (student_info[:cohort])) == false\n @cohorts << student_info[:cohort]\n end\n end\nend", "def index\n @cohorts_students = CohortsStudent.all\n end", "def cohort_assignments\n StudentAssignment.joins(:assignment).where(assignment: self.assignments)\n end", "def create_cohort(n)\n $cohort = Array.new\n i = 1\n (n).times do\n\t\t$cohort.push(\"Person \"+ i.to_s)\n\t\ti += 1\n\tend\n return $cohort\nend", "def index\n @cohort_students = CohortStudent.all\n end", "def print_by_cohort\n cohorts = []\n @students.each do |student|\n unless cohorts.include? student[:cohort]\n cohorts << student[:cohort]\n end\n end\n cohorts.each do |month|\n puts \"#{month} cohort:\"\n students.each_with_index do |student, index|\n if student[:cohort] == month\n puts \"#{index + 1}. #{student[:name]}\"\n # print_student_data(student)\n end\n end\n end\nend", "def cohorts_print #students #, existing_cohorts\n puts \"Students grouped by cohort:\"\n puts #spacer line\n #existing_cohorts = [] I DON'T NEED TO DECALRE IT FIRST\n existing_cohorts = @students.map {|student| student[:cohort]}.sort.uniq\n for i in (0..existing_cohorts.length-1)\n @students.map do |student|\n if student[:cohort] == existing_cohorts[i]\n cohortstr = student[:cohort].to_s.capitalize + \" Cohort\"\n puts \"#{cohortstr.ljust(20)} #{student[:name]} \"\n end #end if\n end #end do\n end #end for\n success\n #cohorts\nend", "def index\n if !current_user.nil? && current_user.has_role?(:teacher)\n @cohorts = Cohort.all.order(:name).reverse\n @students_without_cohorts = User.with_role(:student).where(cohort: nil)\n else\n flash[:alert] = 'You are not authorized to view this page'\n redirect_to '/user/index'\n end\n end", "def cohortfilter\n puts \"Please find students by cohort below:\"\n cohort_months = @students.map { |month| month[:cohort]}\n cohort_months.uniq!\n cohort_months.each do |month|\n puts \"Here are the #{month} students\"\n selected_students = @students.select { |student| student[:cohort] == month}\n list(selected_students)\n end\nend", "def index\n @schedule_cohort_periods = ScheduleCohortPeriod.all\n end", "def assign_cohort(user_id, cohort_category, cohort)\n # ap(assign_cohort: {user_id: user_id, cohort_category: cohort_category, cohort: cohort})\n @user_data.update({\"_id\" => BSON::ObjectId(user_id)}, \"$set\" => {\"cohorts.#{cohort_category}\" => cohort})\n end", "def index\n # TODO: Gotta be able to replace all this imperative scoping with `Ransack` or summit...\n\n @answer_sets = current_user.accessible_answer_sets\n\n # set default values into params\n params[:granularity] ||= current_user.default_cohort_granularity\n params[:group] ||= :day\n\n\n if params[:from_date].present?\n @answer_sets = @answer_sets.where(\"answer_sets.created_at >= ?\", params[:from_date])\n end\n if params[:to_date].present?\n @answer_sets = @answer_sets.where(\"answer_sets.created_at <= ?\", params[:to_date])\n end\n\n\n # setup the core query of the answer_set data\n @chart_data = @answer_sets.select('avg(answers.value) as value').joins(:answers, :cohort)\n\n\n # set the granularity of the data as required\n @chart_data = case params[:granularity].to_s.downcase\n when 'person'\n # remove the granularity of seeing the individual metric - instead, show each user's average for the set\n @chart_data.select('answer_sets.cohort_id as cohort_id, answer_sets.user_id as metric_id, answer_sets.user_id as user_id, users.email as label').group('answer_sets.cohort_id, answer_sets.user_id, users.email').joins(:user)\n\n when 'cohort'\n authorize! :granularity_by_cohort, AnswerSet\n @chart_data.select(\"answer_sets.cohort_id as cohort_id, 'cohort' as metric_id, 'cohort' as user_id, cohorts.name as label\").group('answer_sets.cohort_id, cohorts.name')\n\n else\n # default to grouping as finely-grained as possible - right down to the individual metric\n @chart_data.select(\"answer_sets.cohort_id as cohort_id, answers.metric_id as metric_id, answer_sets.user_id as user_id, users.email || ': ' || metrics.measure as label\").group(\"answer_sets.cohort_id, answers.metric_id, answer_sets.user_id, users.email || ': ' || metrics.measure\").joins(:user, answers: :metric)\n end\n\n\n # group the data into days/weeks if required\n @chart_data = case params[:group].to_s.downcase\n when 'hour'\n @x_labels = 'hour'\n @chart_data.select(\"date_trunc('hour', answer_sets.created_at) as created_at\").group(\"date_trunc('hour', answer_sets.created_at)\")\n\n when 'day'\n @x_labels = 'day'\n @chart_data.select('DATE(answer_sets.created_at) as created_at').group('DATE(answer_sets.created_at)')\n\n when 'week'\n # TODO: the week-grouping chart labels get fubard... try to sort them\n @x_labels = 'month'\n @chart_data.select(\"EXTRACT(YEAR FROM answer_sets.created_at)::text as created_at_year, EXTRACT(WEEK FROM answer_sets.created_at)::text as created_at_week\").group(\"EXTRACT(YEAR FROM answer_sets.created_at)::text, EXTRACT(WEEK FROM answer_sets.created_at)::text\")\n\n else\n @chart_data.select('answer_sets.created_at as created_at').group('answer_sets.created_at')\n end\n\n\n @data = chart_data(@chart_data)\n @keys = chart_data_keys(@chart_data)\n @labels = chart_data_labels(@chart_data)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @chart_data }\n end\n end", "def set_cohort_user\n @cohort_user = CohortUser.find(params[:id])\n end", "def index\n @cohort_programs = CohortProgram.all\n end", "def index\n @teacher_cohorts = TeacherCohort.all\n end", "def index\n @teacher_cohorts = TeacherCohort.all\n end", "def index\n @cohort_instructors = CohortInstructor.all\n end", "def cohort_user_params\n params.require(:cohort_user).permit(:cohort_id, :user_id)\n end", "def set_cohort\n @cohort = Cohort.find(params[:id])\n end", "def get_and_check_cohort\n cohorts = [\"January\", \"February\", \"March\", \"April\", \"May\", \"June\", \"July\", \"August\", \"September\", \"October\", \"November\", \"December\"]\n puts \"And the cohort?\"\n cohort = get_cohort\n input_ok = check_input(cohort, cohorts)\n while !input_ok\n puts \"That isn't a month....the cohort?\"\n cohort = get_cohort\n input_ok = check_input(cohort, cohorts)\n end\n return cohort\nend", "def has_users_not_in?(cohort)\n\t\tself.users.size - cohort.users.size > 0\n\tend", "def induction_records\n @induction_records ||= dashboard_school_cohorts.flat_map do |school_cohort|\n InductionRecordPolicy::Scope\n .new(user,\n school_cohort\n .induction_records\n .current_or_transferring_in_or_transferred\n .eager_load(induction_programme: %i[school core_induction_programme lead_provider delivery_partner],\n participant_profile: %i[user ecf_participant_eligibility ecf_participant_validation_data])\n .order(\"users.full_name\"))\n .resolve\n .order(start_date: :desc, created_at: :desc)\n .uniq(&:participant_profile_id)\n end\n end", "def index\n\t\t@students = Student.all.order(:created_at)\n\t\t@cohorts = Cohort.all\n\t\t\n\tend", "def index\n @cohort = Cohort.find(params[:cohort_id])\n @announcements = @cohort.announcements\n end", "def getActivitiesCohortSemester\n degreeProgs = Programme.all.pluck(:id)\n \n acts = []\n degreeProgs.each do |prgm|\n \n #Get the durations of activities that belong to the current programme\n actProgs = ActivityProgramme.where(programme_id: prgm).pluck(:activity_id)\n actstt = ActivityTimetable.where(activity_id: actProgs).pluck(:duration)\n \n #Add all durations to the sum\n sum = 0\n actstt.each do |time|\n unless time.nil?\n sum = sum + (time/60.0)\n end\n end\n \n #push the result\n progName = Programme.find(prgm).code\n acts.push([progName, sum]) \n\n end\n return acts\n end", "def cohorts (a)\n a.each do |k, v|\n puts \"#{k}: #{v}\"\n end\nend", "def district_teachers(cohort = nil)\n return nil unless district_contact?\n teachers = district.users\n (cohort ? teachers.joins(:cohorts).where(cohorts: {id: cohort}) : teachers).to_a\n end", "def destroy\n @cohort_user.destroy\n respond_to do |format|\n format.html { redirect_to cohort_users_url }\n format.json { head :no_content }\n end\n end", "def create_cohort(n)\n $cohort = Array.new\n i = 1\n (n).times do\n $cohort.push(\"Person \"+ i.to_s)\n i += 1\n end\n puts $cohort\nend", "def print_by_cohorts(students, cohort)\n students = students.select { |student| student[:cohort] == cohort}\n print(students)\nend", "def cohort_params\n params.require(:cohort).permit(:name,\n :start_date,\n :end_date,\n :coach_id,\n :clinic_id,\n player_ids:[])\n end", "def getTechnicianStatsActivities\n #Getting all the tech leads and understudies for each activity\n actTechs = ActivityTech.all.pluck(:tech_lead_id)\n actTechsU = ActivityTech.all.pluck(:tech_ustudy_id)\n \n #putting them in the same set\n actTechs = actTechs + actTechsU \n\n userIDs = User.all.pluck(:id)\n \n userCount = []\n userIDs.each do |id|\n\n #Only add it to the final result if the number of activities > 0\n if actTechs.count(id) != 0 then\n username = User.find(id).display_name\n #get the number of activities by counting the number of occurences of the id\n userCount.push([username, actTechs.count(id)])\n end\n\n end\n \n return userCount\n end", "def has_cohorts_not_in?(user)\n\t\tself.cohorts.size - user.cohorts.size > 0\n\tend", "def init_cohort(cohort)\n @data[cohort] ||= {}\n @data[cohort][:success] ||= 0\n @data[cohort][:failure] ||= 0\n end", "def set_student_cohort(cohort)\n @cohort = cohort\n end", "def cohort_params\n params.require(:cohort).permit(:name, :start_date, :end_date, :instructor_id, :course_id)\n end", "def cohort_params\n params.require(:cohort).permit(:name, :start, :end, :course_id)\n end", "def print_by_cohort\n\n # for each month in the year (in order)\n Date::MONTHNAMES.each do |month|\n\n # find students in this months cohort\n list = @students.select {|name| name[:cohort] == month}\n\n # if the cohort is empty and skip_empty is true, skip\n if list.length == 0 then next\n\n # otherwise print cohort list\n else\n # print list\n print_header\n print_list(list)\n print_footer(list)\n end\n\n end\n\nend", "def acct_groups(cohort)\n\tgroups_array = []\n\tcohort_array = cohort.split(\", \").shuffle!\n\theadcount = cohort_array.size\n\t\tif headcount < 6\n\t\t\tputs \"Too few students to sort!\"\n\t\telsif headcount == 6 || headcount == 9\n\t\t\tcohort_array.each_slice(3) { |three_person|\tgroups_array.push(three_person) }\n\t\telsif headcount <= 8 || headcount % 4 == 0\n \t\t\tcohort_array.each_slice(4) { |four_person| groups_array.push(four_person) }\n\t\telsif headcount % 5 == 0 || headcount >= 11\n \t\t\tcohort_array.each_slice(5) { |five_person| groups_array.push(five_person) }\t\t\n\t\twhile groups_array.last.size < 3\n\t\t\tgroups_array.last.push(groups_array[0][0]); groups_array[0].shift\n\t\t\tgroups_array.last.push(groups_array[1][0]); groups_array[1].shift\n\t\tend\n\t\tend\n\tgroups_hash = Hash.new\n\tnum = 0\n\tgroups_array.each { |team| groups_hash[num += 1] = team }\n\treturn groups_hash\nend", "def cohort_params\n params.require(:cohort).permit(:name, :start_date, :end_date, :description, :active)\n end", "def destroy\n @cohort = current_user.accessible_cohorts.find(params[:id])\n @cohort.destroy\n\n respond_to do |format|\n format.html { redirect_to cohorts_url }\n format.json { head :no_content }\n end\n end", "def acct_groups(array)\n if array.length % 5 != 0\n num_groups = array.length/5 + 1\n end\n \n cohort = array.shuffle\n groups = Array.new(num_groups) {[]}\n \n groups.each do |group|\n 5.times do \n group << cohort.pop\n end\n end\n \n return groups\nend", "def index\n @coupons_users = CouponsUser.find_by_sql [\"SELECT cu.id, cu.user_id, cu.coupon_status_id, cu.created_at, cu.updated_at, cu.coupon_coupontype_id, cu.couponrule_id, cct.coupon_id, cct.coupon_type_id, u.username, cs.coupon_status_name, c.price, c.coupon_name, cr.start_on, cr.end_on, ct.coupon_type_name FROM coupons_users cu, users u, coupon_statuses cs, coupons c, couponrule_cities cr, coupon_types ct, coupon_coupontypes cct WHERE cu.user_id = u.id AND cu.coupon_status_id = cs.id AND cu.coupon_coupontype_id = cct.id AND cct.coupon_id = c.id AND cct.coupon_type_id = ct.id AND cu.couponrule_id = cr.id\"]\n end", "def show\n if params[:cohort_id]\n set_cohort\n end\n end", "def create\n @cohort_user = CohortUser.new(cohort_user_params)\n\n respond_to do |format|\n if @cohort_user.save\n format.html { redirect_to @cohort_user }\n format.json { render :show, status: :created, location: @cohort_user }\n else\n format.html { render :new }\n format.json { render json: @cohort_user.errors, status: :unprocessable_entity }\n end\n end\n end", "def click_view_everyone_cohorts\n sleep 2\n wait_for_load_and_click view_everyone_cohorts_link_element\n wait_for_title 'All Cohorts'\n end", "def all_contestants(data)\n\tarray_of_people = []\n\tdata.each do |season, people|\n\t\tarray_of_people << people\n\tend\n\tarray_of_people.flatten\nend", "def cohort_field\n @@start_date = params[\"start_date\"]\n @@end_date = params[\"end_date\"]\n\n if params[\"field\"]\n\n if params[\"start_date\"]\n start_date = params[\"start_date\"]\n else\n start_date = Time.now.strftime(\"%Y-%m-%d\")\n end\n if params[\"end_date\"]\n end_date = params[\"end_date\"]\n else\n end_date = Time.now.strftime(\"%Y-%m-%d\")\n end\n\n case params[\"field\"]\n when \"regimens\"\n regimens(start_date, end_date, params[\"field\"])\n when \"defaulters\"\n art_defaulters(start_date, end_date, params[\"field\"])\n when \"total_alive_and_on_art\"\n total_alive_and_on_art(start_date, end_date, params[\"field\"])\n when \"defaulted\"\n defaulted(start_date, end_date, params[\"field\"])\n when \"total_on_art\"\n total_on_art(start_date, end_date, params[\"field\"])\n when \"new_total_reg\"\n new_total_reg(start_date, end_date, params[\"field\"])\n when \"cum_total_reg\"\n cum_total_reg(start_date, end_date, params[\"field\"])\n when \"new_ft\"\n new_ft(start_date, end_date, params[\"field\"])\n when \"cum_ft\"\n cum_ft(start_date, end_date, params[\"field\"])\n when \"new_re\"\n new_re(start_date, end_date, params[\"field\"])\n when \"cum_re\"\n cum_re(start_date, end_date, params[\"field\"])\n when \"new_ti\"\n new_ti(start_date, end_date, params[\"field\"])\n when \"cum_ti\"\n cum_ti(start_date, end_date, params[\"field\"])\n when \"new_males\"\n new_males(start_date, end_date, params[\"field\"])\n when \"cum_males\"\n cum_males(start_date, end_date, params[\"field\"])\n when \"new_non_preg\"\n new_non_preg(start_date, end_date, params[\"field\"])\n when \"cum_non_preg\"\n cum_non_preg(start_date, end_date, params[\"field\"])\n when \"new_preg_all_age\"\n new_preg_all_age(start_date, end_date, params[\"field\"])\n when \"cum_preg_all_age\"\n cum_preg_all_age(start_date, end_date, params[\"field\"])\n when \"new_a\"\n new_a(start_date, end_date, params[\"field\"])\n when \"cum_a\"\n cum_a(start_date, end_date, params[\"field\"])\n when \"new_b\"\n new_b(start_date, end_date, params[\"field\"])\n when \"cum_b\"\n cum_b(start_date, end_date, params[\"field\"])\n when \"new_c\"\n new_c(start_date, end_date, params[\"field\"])\n when \"cum_c\"\n cum_c(start_date, end_date, params[\"field\"])\n when \"new_unk_age\"\n new_unk_age(start_date, end_date, params[\"field\"])\n when \"cum_unk_age\"\n cum_unk_age(start_date, end_date, params[\"field\"])\n when \"new_pres_hiv\"\n new_pres_hiv(start_date, end_date, params[\"field\"])\n when \"cum_pres_hiv\"\n cum_pres_hiv(start_date, end_date, params[\"field\"])\n when \"new_conf_hiv\"\n new_conf_hiv(start_date, end_date, params[\"field\"])\n when \"cum_conf_hiv\"\n cum_conf_hiv(start_date, end_date, params[\"field\"])\n when \"new_who_1_2\"\n new_who_1_2(start_date, end_date, params[\"field\"])\n when \"cum_who_1_2\"\n cum_who_1_2(start_date, end_date, params[\"field\"])\n when \"new_who_2\"\n new_who_2(start_date, end_date, params[\"field\"])\n when \"cum_who_2\"\n cum_who_2(start_date, end_date, params[\"field\"])\n when \"new_children\"\n new_children(start_date, end_date, params[\"field\"])\n when \"cum_children\"\n cum_children(start_date, end_date, params[\"field\"])\n when \"new_breastfeed\"\n new_breastfeed(start_date, end_date, params[\"field\"])\n when \"cum_breastfeed\"\n cum_breastfeed(start_date, end_date, params[\"field\"])\n when \"new_preg\"\n new_preg(start_date, end_date, params[\"field\"])\n when \"cum_preg\"\n cum_preg(start_date, end_date, params[\"field\"])\n when \"new_who_3\"\n new_who_3(start_date, end_date, params[\"field\"])\n when \"cum_who_3\"\n cum_who_3(start_date, end_date, params[\"field\"])\n when \"new_who_4\"\n new_who_4(start_date, end_date, params[\"field\"])\n when \"cum_who_4\"\n cum_who_4(start_date, end_date, params[\"field\"])\n when \"new_other_reason\"\n new_other_reason(start_date, end_date, params[\"field\"])\n when \"cum_other_reason\"\n cum_other_reason(start_date, end_date, params[\"field\"])\n when \"new_no_tb\"\n new_no_tb(start_date, end_date, params[\"field\"])\n when \"cum_no_tb\"\n cum_no_tb(start_date, end_date, params[\"field\"])\n when \"new_tb_w2yrs\"\n new_tb_w2yrs(start_date, end_date, params[\"field\"])\n when \"cum_tb_w2yrs\"\n cum_tb_w2yrs(start_date, end_date, params[\"field\"])\n when \"new_current_tb\"\n new_current_tb(start_date, end_date, params[\"field\"])\n when \"cum_current_tb\"\n cum_current_tb(start_date, end_date, params[\"field\"])\n when \"new_ks\"\n new_ks(start_date, end_date, params[\"field\"])\n when \"cum_ks\"\n cum_ks(start_date, end_date, params[\"field\"])\n when \"died_1st_month\"\n died_1st_month(start_date, end_date, params[\"field\"])\n when \"died_2nd_month\"\n died_2nd_month(start_date, end_date, params[\"field\"])\n when \"died_3rd_month\"\n died_3rd_month(start_date, end_date, params[\"field\"])\n when \"died_after_3rd_month\"\n died_after_3rd_month(start_date, end_date, params[\"field\"])\n when \"died_total\"\n died_total(start_date, end_date, params[\"field\"])\n when \"stopped\"\n stopped(start_date, end_date, params[\"field\"])\n when \"transfered\"\n transfered(start_date, end_date, params[\"field\"])\n when \"unknown_outcome\"\n unknown_outcome(start_date, end_date, params[\"field\"])\n when \"n0a\"\n n1a(start_date, end_date, params[\"field\"])\n when \"n0p\"\n n1p(start_date, end_date, params[\"field\"])\n when \"n1a\"\n n1a(start_date, end_date, params[\"field\"])\n when \"n1p\"\n n1p(start_date, end_date, params[\"field\"])\n when \"n2a\"\n n2a(start_date, end_date, params[\"field\"])\n when \"n2p\"\n n2p(start_date, end_date, params[\"field\"])\n when \"n3a\"\n n3a(start_date, end_date, params[\"field\"])\n when \"n3p\"\n n3p(start_date, end_date, params[\"field\"])\n when \"n4a\"\n n4a(start_date, end_date, params[\"field\"])\n when \"n4p\"\n n4p(start_date, end_date, params[\"field\"])\n when \"n5a\"\n n5a(start_date, end_date, params[\"field\"])\n when \"n6a\"\n n6a(start_date, end_date, params[\"field\"])\n when \"n7a\"\n n7a(start_date, end_date, params[\"field\"])\n when \"n8a\"\n n8a(start_date, end_date, params[\"field\"])\n when \"n9p\"\n n9p(start_date, end_date, params[\"field\"])\n when \"non_std\"\n non_std(start_date, end_date, params[\"field\"])\n when \"tb_no_suspect\"\n tb_no_suspect(start_date, end_date, params[\"field\"])\n when \"tb_suspected\"\n tb_suspected(start_date, end_date, params[\"field\"])\n when \"tb_confirm_not_treat\"\n tb_confirm_not_treat(start_date, end_date, params[\"field\"])\n when \"tb_confirmed\"\n tb_confirmed(start_date, end_date, params[\"field\"])\n when \"unknown_tb\"\n unknown_tb(start_date, end_date, params[\"field\"])\n when \"current_site\"\n current_site\n when \"quarter\"\n quarter(start_date, end_date, params[\"field\"])\n when \"side_effects\"\n side_effects(start_date, end_date, params[\"field\"])\n when \"no_effects\"\n no_effects(start_date, end_date, params[\"field\"])\n when \"unk_effects\"\n unk_effects(start_date, end_date, params[\"field\"])\n when \"missed_0_6\"\n missed_0_6(start_date, end_date, params[\"field\"])\n when \"missed_7plus\"\n missed_7plus(start_date, end_date, params[\"field\"])\n when \"missed_7plus_one\"\n missed_7plus_one(start_date, end_date, params[\"field\"])\n when \"missed_7plus_two\"\n missed_7plus_two(start_date, end_date, params[\"field\"])\n when \"missed_7plus_three\"\n missed_7plus_three(start_date, end_date, params[\"field\"])\n when \"missed_7plus_four\"\n missed_7plus_four(start_date, end_date, params[\"field\"])\n when \"missed_7plus_five\"\n missed_7plus_five(start_date, end_date, params[\"field\"])\n when \"unknown_adherence\"\n unknown_adherence(start_date, end_date, params[\"field\"])\n when \"drug_induced_p_neu\"\n drug_induced_p_neu(start_date, end_date, params[\"field\"])\n when \"drug_induced_leg_pain\"\n drug_induced_leg_pain(start_date, end_date, params[\"field\"])\n when \"drug_induced_hepatitis\"\n drug_induced_hepatitis(start_date, end_date, params[\"field\"])\n when \"drug_induced_skin_rash\"\n drug_induced_skin_rash(start_date, end_date, params[\"field\"])\n when \"drug_induced_jaundice\"\n drug_induced_jaundice(start_date, end_date, params[\"field\"])\n when \"new_patient_pregnant\"\n new_patient_pregnant(start_date, end_date, params[\"field\"])\n when \"cum_patient_pregnant\"\n cum_patient_pregnant(start_date, end_date, params[\"field\"])\n else\n reply(params[\"field\"])\n end\n end\n end", "def show\n @cohort = current_user.accessible_cohorts.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @cohort }\n end\n end", "def total(list)\n\ttotal_students = 0\n\tlist.map do |cohorts, size|\n\t\ttotal_students += size\n\tend\n\treturn total_students\nend", "def index\n @lookup_cohorts = LookupCohort.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @lookup_cohorts }\n end\n end", "def show\n render json: serializer_class.new(ecf_school, params: { cohort: }).serializable_hash.to_json\n end", "def print_student_list\n existing_cohorts = get_cohort_list\n existing_cohorts.each do |cohort|\n puts \"The students in the #{cohort.to_s} cohort are:\"\n @students.each do |student|\n if student[:cohort] == cohort\n puts student[:name]\n end\n end\n end\nend", "def print(students)\n cohort_array = []\n# Ex 8 - Print out students grouped by cohort.\n students.each do |s|\n cohort_array.push(s[:cohort])\n end\n cohort_array.uniq.each do |x|\n puts x\n students.each do |s|\n if s[:cohort] == x\n puts s\n end\n end\n end\n\n# Ex 4 - Replace each for while.\n# count = 0\n# while count < students.length\n # puts \"#{count + 1}. #{students[count][:name]} (#{students[count][:cohort]} cohort) #{students[count][:hobbies]}\".center(100) \n # count += 1\n# end\n\n# Ex 1 - Use each loop to print students\n# students.each_with_index do |student, index|\n # if student[:name].upcase[0] == 'D' && student[:name].length > 12 # Ex 2 & 3 - Print if begin 'D' & > 12 charachters.\n # puts \"#{index+1}. #{student[:name]} (#{student[:cohort]} cohort)\" # Ex 1 - Add number using each_with_index.\n # end\n# end\nend", "def usage_per_interval\n #end_date = AnalyticsUsage.last.created_at\n #start_date = AnalyticsUsage.first.created_at\n start_date = params[:report_start_date].to_time.to_i\n end_date = params[:report_end_date].to_time.to_i\n interval = params[:interval].to_i\n type= params[:submit]\n institution_ids = params[:institution]\n institution_names = []\n results = []\n institution_ids.each do |id|\n institution = Institution.find_by_id(id)\n name = institution.name.gsub(\" \",\"\").to_s\n institution_names << name\n users = Institution.find_by_id(id).students.map(&:id)\n s = start_date\n e = Time.at(start_date).to_date.plus_with_duration(interval).to_time.to_i\n i = true\n while i\n if s < end_date\n if e > end_date\n e = end_date\n end\n if type==\"Get Report\"\n duration = AnalyticsUsage.where(:user_id=>users,:created_at=>s..e).sum(:today_usage)\n user_count = AnalyticsUsage.select(:user_id).where(:user_id=>users,:created_at=>s..e).map(&:user_id).uniq.count\n results << [Time.at(s).to_date,Time.at(e).to_date,user_count,duration/60,name]\n elsif type == \"User Report\"\n AnalyticsUsage.where(:user_id=>users,:created_at=>s..e).each do |u|\n user = User.includes(:institution=>(:profile),:center=>(:profile),:academic_class=>(:profile),:section=>(:profile)).find_by_id_and_institution_id(u.id,id)\n if user\n results << [Time.at(s).to_date,Time.at(e).to_date,user.try(:name),(user.edutorid rescue \"\"),(user.institution.try(:name) if user.institution rescue \"\"),(user.center.try(:name) if user.center rescue \"\"),(user.academic_class.try(:name) if user.academic_class rescue \"\"),(user.section.try(:name) if user.section rescue \"\"),(u.today_usage/60 rescue 0),Time.at(u.created_at).to_date]\n end\n end\n end\n s = e\n e = Time.at(s).to_date.plus_with_duration(interval).to_time.to_i\n else\n i = false\n end\n end\n end\n if type == \"Get Report\"\n header = \"Start date,End date,Users,Total Duration,Institution\".split(\",\")\n elsif type == \"User Report\"\n header = \"Start date,End Date,Name,EdutorID,Institution,Center,Class,Section,Duration,Date\".split(\",\")\n end\n\n\n csv_data = FasterCSV.generate do |csv|\n csv << header\n results.each do |c|\n csv << c\n end\n end\n filename = \"Usage-Report\"\n institution_names.collect{|i| filename = filename+\"-\"+i}\n logger.info\"======#{filename}\"\n send_data csv_data, :type => 'text/csv; charset=iso-8859-1; header=present', :disposition => \"attachment; filename=#{filename}.csv\"\n end", "def refresh_outcomes_table\n logger.debug('Initialising cohort temporary tables...')\n CohortBuilder.new(outcomes_definition: @outcomes_definition)\n .init_temporary_tables(@start_date, @end_date)\n end", "def print_cohort\n puts \"These are the current active cohorts:\".center(70)\n active_cohorts = @students.uniq { |student| student[:cohort] }\n active_cohorts.each do |entry|\n puts \"#{entry[:cohort]}\".center(70)\n end\n puts \"Enter a cohort start month to print students in that cohort\".center(70)\n cohort_to_print = STDIN.gets.strip.downcase.to_sym\n single_cohort = @students.select { |student| student[:cohort] == cohort_to_print }\n single_cohort.each do |student| \n puts \"#{student[:name]} (#{student[:cohort]} cohort)\".center(70)\n end\nend", "def teach(cohort) #check what happens with an arrage\n cohort.each {|student| student.learn } #this will put learn into each\n end", "def adminned_memberships_by_tag(cohort)\n membership = memberships.find_by(cohort: cohort, is_admin: true)\n return [] unless membership && membership.tag_ids.any?\n\n tag_ids = membership.tag_ids\n tagged_memberships = Membership.joins(:taggings).where(cohort: cohort).where(taggings: {tag_id: tag_ids})\n tagged_memberships.uniq\n end", "def list_cohorts(students)\n students.each do |key, value|\n puts \"#{key} : #{value} students\"\n end\nend", "def set_cohorts_student\n @cohorts_student = CohortsStudent.find(params[:id])\n end", "def exercise1\n @content = ActiveRecord::Base.connection.execute(\"\n SELECT\n u.name as user_name,\n COUNT(gr.name) as groups_count,\n CONCAT('[', COALESCE(STRING_AGG(gr.name, ', ' ), ''),']') as groups\n FROM ((users as u\n LEFT JOIN groups_users as gu ON u.id=gu.user_id)\n LEFT JOIN groups as gr ON gr.id = gu.group_id)\n GROUP BY user_name\n ORDER BY groups_count;\");\n\n @results1 = []\n\n index = 0\n @content.each do |r|\n @results1[index] = Result1.new r\n index = index + 1;\n end\n\n return @results1\n end", "def get_all_contestants data \n people = []\n data.each { | season | contestants = season[1]; \n contestants.each { | person | people << person } }\n people \nend", "def fetch_statistics\n user = AdminUser.find(get_logged_in_user_id)\n if user.designation == \"supervisor\"\n new_complaints = ComplaintStatus.where(admin_user_id: user.id, status: \"pending\").count\n pending_complaints = 0\n completed_complaints = ComplaintStatus.where(admin_user_id: user.id, status: \"completed\").count\n elsif user.designation == \"ward officer\"\n ward = WardOffice.find(user.municipal_id)\n new_complaints = ComplaintStatus.where(admin_user_id: user.id).count\n pending_complaints = ComplaintStatus.where(district_office_id: ward.district_office_id, ward_office_id: user.municipal_id,\n category: user.designation, status: \"pending\").count\n completed_complaints = ComplaintStatus.where(district_office_id: ward.district_office_id, ward_office_id: user.municipal_id,\n category: user.designation, status: \"completed\").count\n elsif user.designation == \"district officer\"\n new_complaints = ComplaintStatus.where(admin_user_id: user.id, status: \"new\").count\n pending_complaints = ComplaintStatus.where(district_office_id: user.municipal_id, status: \"pending\").count\n completed_complaints = ComplaintStatus.where(district_office_id: user.municipal_id, status: \"completed\").count\n end\n render json: {new_complaint: new_complaints, pending_complaint: pending_complaints, completed_complaint: completed_complaints}\n end", "def extract_from(students, cohort_sym)\n\tif !cohort_sym == :Nofilter\n\t\tresults = students.select do |student|\n\t\t\tstudent[:cohort] == cohort_sym\n\t\t\tend\n\telse \n\t\tresults = students\n\tend\n\tresults\nend", "def dashboard_actions\n @actions = Action.where('closed_flag = ?', false)\n @users = User.all\n \n @over = @actions.where('date_target < ?', Time.now).count\n @due = @actions.where('date_target >= ?', Time.now).count\n @year_count = Action.where('date_time_created >= ?', Time.now - 1.year).count\n \n @typeA_num = @actions.where('type_ABC = ?', \"A\").count\n @typeB_num = @actions.where('type_ABC = ?', \"B\").count\n @typeC_num = @actions.where('type_ABC = ?', \"C\").count\n \n # data series for the pie-chart\n\n @series1 = @actions.where('date_target >= ?', Time.now).group(:type_ABC).count\n @series2 = @actions.where('date_target < ?', Time.now).group(:type_ABC).count\n\n # data series for the stacked column\n # If statement allows for filtering by team, available to line managers and above...\n\n\n @series3 = @actions.where('date_target >= ?', Time.now).group(:owner).count\n @series4 = @actions.where('date_target < ?', Time.now).group(:owner).count\n\n action_ids = []\n k = 0\n team_count = User.where('team = ?', \"SHEQ\").count\n team_hash = User.where('team = ?', \"SHEQ\")\n (0..team_count-1).each do |i|\n team_member_actions_arr = @actions.where('user_id = ?', team_hash[i].id).index_by(&:id).to_a\n (0..team_member_actions_arr.length-1).each do |j|\n action_ids[k] = team_member_actions_arr[j][0]\n k += 1\n end\n \n end\n \n gon.SHEQ_team_actions = @actions.where('id IN(?)', action_ids)\n \n end", "def show \n @cohort = Cohort.find(params[:id])\n end", "def initialize(name, cohort)\n\t\t@name = name\n\t\t@cohort = cohort\n\tend", "def accountability_group(dbcCohort_array)\n array_output = dbcCohort_array.shuffle.each_slice(4).to_a\n if array_output.length % 4 == 0 \n return array_output \n else \n remainder_people = array_output.pop \n for i in 0...array_output.length \n array_output[i].push(remainder_people[i])\n end\n return array_output\n end \nend", "def has_cohorts?\n\t\tself.cohorts.size > 0\n\tend", "def display_stats\n \n if current_user && current_user.role == \"admin\"\n @valuesArray = params.values[0,(params.values).length-2]\n @keysArray = params.keys[0,(params.keys).length-2]\n @match_data = ClubMatch.joins(:club).where(:matched=>1).order('COUNT(club_matches.club_id)DESC').limit(5)\n @user_interest_data = UserInterest.joins(:interest).order('COUNT(user_interests.interest_id)DESC').limit(7)\n @club_interest_data = ClubInterest.joins(:interest).order('COUNT(club_interests.interest_id)DESC').limit(7)\n \n if @valuesArray[0] != \"All\" \n @users = User.where(\"#{@keysArray[0]}\": params[\"#{@keysArray[0]}\".to_sym])\n else\n @users = User.all\n end\n \n\n @title = ' users'\n @keysArray.each_index{|x|\n if x > 0 && @valuesArray[x] != \"\" \n @users = @users.where(\"#{@keysArray[x]}\": params[\"#{@keysArray[x]}\".to_sym])\n end\n\n if @keysArray[x] == \"gender\"\n @title = @valuesArray[x] + @title\n end\n\n if @keysArray[x] == \"grad_year\" && @valuesArray[x] != \"\"\n @title = @title + ' graduating in ' + @valuesArray[x]\n end\n } \n\n @total = @users.length\n else\n redirect_to new_user_session_path\n end \n \n end", "def create_groups(cohort)\n if cohort.length % 5 == 0\n hash = {} \t\n \tcounter = 1\n group_count = cohort.length / 5\n remainder = cohort.length % 5 \t\n # Set to groups(keys) to members(values)\n group_count.times do\n hash[counter] = cohort.slice!(0..4)\n counter += 1\n end\n else\n \thash = {}\n counter = 1 \n group_count = cohort.length / 4\n remainder = cohort.length % 4\n # Set to groups(keys) to members(values)\n group_count.times do\n hash[counter] = cohort.slice!(0..3)\n counter += 1\n end\n end\n # Add remainders\n counter = 1\n cohort.each do |string|\n hash[counter] << string\n counter += 1\n end\nreturn hash\nend", "def reading_debug(cohort_options = {})\n grade_now = cohort_options.fetch(:grade_now, nil)\n school_id_now = cohort_options.fetch(:school_id_now, nil)\n students = authorized do\n cohort_students = Student.active\n cohort_students = cohort_students.where(grade: grade_now) if grade_now.present?\n cohort_students = cohort_students.where(school_id: school_id_now) if school_id_now.present?\n cohort_students.to_a\n end\n groups = ReadingQueries.new.groups_for_grid(students)\n [students, groups]\n end", "def ranged_user_data(interval = 'year', from = DateTime.new(0), to = DateTime.now)\n [\n {\n key: 'active',\n name: t('statistics.entries.users.active'),\n data: ExternalUser.joins(:submissions)\n .where(submissions: {created_at: from..to})\n .select(ExternalUser.sanitize_sql(['date_trunc(?, submissions.created_at) AS \"key\", count(distinct external_users.id) AS \"value\"', interval]))\n .group('key').order('key'),\n },\n {\n key: 'submissions',\n name: t('statistics.entries.exercises.submissions'),\n data: Submission.where(created_at: from..to)\n .select(Submission.sanitize_sql(['date_trunc(?, created_at) AS \"key\", count(id) AS \"value\"', interval]))\n .group('key').order('key'),\n axis: 'right',\n },\n ]\n end", "def exercise3\n @content = ActiveRecord::Base.connection.execute(\"\n SELECT\n gr.name as group,\n u.name as name,\n SUM(m.mapviews) as views,\n CONCAT(CAST(ROUND((SUM(m.mapviews)*100)/SUM(SUM(m.mapviews)) OVER (PARTITION BY gr.name),2) as text), '%') as percent_of_group_views\n FROM (((users as u\n INNER JOIN groups_users as gu ON u.id=gu.user_id)\n INNER JOIN groups as gr ON gr.id = gu.group_id)\n INNER JOIN maps as m ON m.user_id = u.id)\n GROUP BY (gr.name, u.name)\n ORDER BY gr.name ASC, percent_of_group_views DESC;\");\n\n @results3 = []\n\n index = 0\n @content.each do |r|\n @results3[index] = Result3.new r\n index = index + 1;\n end\n\n return @results3\n end", "def show\n @active_team_users = @team.users.where.not(last_sign_in_at: nil)\n\n @prospects = 0\n @active_team_users.each do |user|\n @prospects += user.prospects.count\n end\n @statements = 0\n @active_team_users.each do |user|\n user.prospects.each do |prospect|\n @statements += prospect.statements.count\n end\n end\n @today_tasks = 0\n @active_team_users.each do |user|\n user.prospects.each do |prospect|\n prospect.tasks.each do |task|\n if task.finish_date.strftime(\"%m/%d/%Y\") == Time.now.strftime(\"%m/%d/%Y\")\n @today_tasks += 1\n end\n end\n end\n end\n @active_users = 0\n @inactive_users = 0\n @active_team_users.each do |user|\n if user.last_sign_in_at.strftime(\"%m/%d/%Y\") >= 7.days.ago.strftime(\"%m/%d/%Y\")\n @active_users += 1\n else\n @inactive_users += 1\n end\n end\n\n @six_days_ago_prospects = 0\n @five_days_ago_prospects = 0\n @four_days_ago_prospects = 0\n @three_days_ago_prospects = 0\n @two_days_ago_prospects = 0\n @one_day_ago_prospects = 0\n @todays_prospects = 0\n\n @active_team_users.each do |user|\n user.prospects.each do |prospect|\n if prospect.created_at.localtime.strftime(\"%m/%d/%Y\") == 6.days.ago.localtime.strftime(\"%m/%d/%Y\")\n @six_days_ago_prospects += 1\n elsif prospect.created_at.localtime.strftime(\"%m/%d/%Y\") == 5.days.ago.localtime.strftime(\"%m/%d/%Y\")\n @five_days_ago_prospects += 1\n elsif prospect.created_at.localtime.strftime(\"%m/%d/%Y\") == 4.days.ago.localtime.strftime(\"%m/%d/%Y\")\n @four_days_ago_prospects += 1\n elsif prospect.created_at.localtime.strftime(\"%m/%d/%Y\") == 3.days.ago.localtime.strftime(\"%m/%d/%Y\")\n @three_days_ago_prospects += 1\n elsif prospect.created_at.localtime.strftime(\"%m/%d/%Y\") == 2.days.ago.localtime.strftime(\"%m/%d/%Y\")\n @two_days_ago_prospects += 1\n elsif prospect.created_at.localtime.strftime(\"%m/%d/%Y\") == 1.day.ago.localtime.strftime(\"%m/%d/%Y\")\n @one_day_ago_prospects += 1\n elsif prospect.created_at.localtime.strftime(\"%m/%d/%Y\") == Time.now.localtime.strftime(\"%m/%d/%Y\")\n @todays_prospects += 1\n end\n end\n end\n\n @six_days_ago = (Time.now.localtime - 6.days).localtime.strftime(\"%d\")\n @five_days_ago = (Time.now.localtime - 5.days).localtime.strftime(\"%d\")\n @four_days_ago = (Time.now.localtime - 4.days).localtime.strftime(\"%d\")\n @three_days_ago = (Time.now.localtime - 3.days).localtime.strftime(\"%d\")\n @two_days_ago = (Time.now.localtime - 2.days).localtime.strftime(\"%d\")\n @one_day_ago = (Time.now.localtime - 1.day).localtime.strftime(\"%d\")\n @today = Time.now.localtime.strftime(\"%d\")\n\n end", "def countries_of_members_data(country_name = false)\n data = [['Country', 'Users']]\n members.group(:country).where.not(country: [nil, '']).select('country, COUNT(*) AS number_of_users').each{|i| data << [country_name ? ISO3166::Country.new(i.country).try(:name) : i.country, i.number_of_users] }\n data\n end", "def fetch_player_activity\n unique_ids_two_weeks_ago = Card.for_quizzes.between_days('quizzes', 14, 8).select(:user_id).distinct.pluck(:user_id)\n unique_ids_one_week_ago = Card.for_quizzes.between_days('quizzes', 7, 1).select(:user_id).distinct.pluck(:user_id)\n returned_user_ids = unique_ids_two_weeks_ago.select { |id| unique_ids_one_week_ago.include?(id) }\n left_user_ids = unique_ids_two_weeks_ago.reject { |id| unique_ids_one_week_ago.include?(id) }\n returned_users = User.where(id: returned_user_ids).sample(25)\n left_users = User.where(id: left_user_ids).sample(25)\n message_count = Notification.where('notifications.created_at BETWEEN ? AND ?', DateTime.current.beginning_of_day - 7, DateTime.current.end_of_day - 1).size\n new_users = User.where('users.created_at BETWEEN ? AND ?', DateTime.current.beginning_of_day - 7, DateTime.current.end_of_day - 1).sample(25)\n confirmed_can_users = Hash.new(0)\n can_users = Hash.new(0)\n User.confirmed.where(source: \"mlb_scan_lp\").each do |user|\n role = user.roles.first\n role ? confirmed_can_users[user.roles.first.name] += 1 : confirmed_can_users['global'] += 1\n end\n User.where(confirmed: false).where(source: \"mlb_scan_lp\").each do |user|\n role = user.roles.first\n role ? can_users[user.roles.first.name] += 1 : can_users['global'] += 1\n end\n registered_count = confirmed_can_users.size\n unregistered_count = can_users.size\n phone_number_count = PhoneNumber.all.size\n WeeklyUserActivityMailer.stats_email(\n new_users: new_users, \n returned_users: returned_users, \n left_users: left_users,\n message_count: message_count,\n can_users: can_users,\n confirmed_can_users: confirmed_can_users,\n registered_count: registered_count,\n unregistered_count: unregistered_count,\n phone_number_count: phone_number_count\n ).deliver_now\n end", "def print_info_each_student\n list_cohorts\n @cohorts.each do |cohort|\n puts \"\\nStudents in the #{cohort} cohort\\n\".center(50)\n @students.each_with_index do |student_info, index|\n if cohort == student_info[:cohort]\n puts \"#{index+1}. #{student_info[:name]}\".center(50)\n plural = \"s\" if student_info[:pronoun] != \"they\"\n puts \"#{student_info[:name]} is #{student_info[:height]} tall, was born in #{student_info[:country]} and #{student_info[:pronoun]} like#{plural} #{student_info[:hobbies]}.\"\n end\n end\n end\nend" ]
[ "0.7172977", "0.69906735", "0.69260067", "0.6465127", "0.6220563", "0.59685946", "0.59039056", "0.5900638", "0.5892886", "0.58772135", "0.5847169", "0.5719657", "0.56540424", "0.5615155", "0.5587426", "0.55198336", "0.54967433", "0.54714143", "0.54251933", "0.54024667", "0.5400136", "0.5360984", "0.5328391", "0.5321271", "0.5271741", "0.5268418", "0.52661663", "0.52593005", "0.5254641", "0.5244302", "0.52012765", "0.5184042", "0.5178547", "0.5158868", "0.51294106", "0.5122538", "0.5122538", "0.509746", "0.5052431", "0.5017808", "0.49974167", "0.49965835", "0.4986276", "0.49808058", "0.49589512", "0.4956027", "0.49534813", "0.4907667", "0.48617172", "0.48605368", "0.4840015", "0.48384452", "0.48246", "0.4823758", "0.48147047", "0.47996625", "0.47705913", "0.47646454", "0.47631553", "0.47527573", "0.4750275", "0.4731777", "0.47311828", "0.46697387", "0.46617708", "0.46321455", "0.4619571", "0.46045765", "0.46037874", "0.46008864", "0.4587636", "0.4566547", "0.4563325", "0.4556059", "0.45461643", "0.45366657", "0.45321113", "0.45213434", "0.45194593", "0.45152906", "0.4508527", "0.44777465", "0.44704604", "0.44620606", "0.4437592", "0.44251823", "0.44014922", "0.43990013", "0.43862167", "0.43782756", "0.43610358", "0.43545976", "0.4352166", "0.43386015", "0.43360934", "0.43301424", "0.43298432", "0.4326858", "0.4324516", "0.43161795" ]
0.49077365
47
This form of query expects you to provide summarized results When we run the query we expect to get back results of: [[cohort, count], ...] we then record the sums in the rollup result table
def cohorts_query(db, proc) sums = [] # initialize the expected number of cohorts (1..current_cohort).each do |cohort| sums[cohort] = 0 end sql = proc.call(date_first, date_last) results = db.execute(sql) results.each do |r| cohort = r[0] sum = r[1] sums[cohort] = 0 if sums[cohort].nil? sums[cohort] += sum end save_sums(sums) return sums end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sum_cohorts(users)\n sums = []\n # initialize the expected number of cohorts\n (1..current_cohort).each do |cohort|\n sums[cohort] = 0\n end\n\n users.each do |user|\n user_id = user[0]\n cohort = user[1]\n sums[cohort] = 0 if sums[cohort].nil?\n if match_user_id?(user_id)\n sums[cohort] += 1\n end\n end\n\n return sums\n end", "def cohorts_query_local_merge(db, proc)\n sql = proc.call(date_first, date_last)\n results = db.execute(sql)\n sums = sum_cohorts(results)\n save_sums(sums)\n return sums\n end", "def all_cohorts (hash_value)\n total_students = hash_value.each_value.reduce(:+)\n puts total_students\nend", "def cohorts_query_in(db, proc)\n sums = []\n # initialize the expected number of cohorts\n (1..current_cohort).each do |cohort|\n sums[cohort] = 0\n end\n\n if !@user_ids.nil?\n # build our user ids\n total_ids = @user_ids.length\n count = 0\n stmt = \"\"\n @user_ids.each do |user_id|\n if count % IN_CLAUSE_MAX == 0\n stmt << \"(#{user_id}\"\n else\n stmt << \",#{user_id}\"\n end\n count += 1\n if (count % IN_CLAUSE_MAX == 0) || (count == total_ids)\n # hit max batch size or last batch, submit the query\n stmt << \")\"\n sql = proc.call(date_first, date_last, stmt)\n stmt = \"\"\n results = db.execute(sql)\n results.each do |r|\n cohort = r[0]\n sum = r[1]\n sums[cohort] = 0 if sums[cohort].nil?\n sums[cohort] += sum\n end\n end\n end\n end\n\n save_sums(sums)\n return sums\n end", "def aggregate(query)\n #query.model.last_query = query\n #y query\n _layout = layout(query.model)\n opts = query.fmp_options\n #opts[:template] = self.class.fmresultset_template_path\n prms = query.to_fmp_query\n #[prms.empty? ? _layout.all(:max_records=>0).foundset_count : _layout.count(prms)]\n [prms.empty? ? _layout.view.total_count : _layout.count(prms)]\n end", "def exercise3\n @content = ActiveRecord::Base.connection.execute(\"\n SELECT\n gr.name as group,\n u.name as name,\n SUM(m.mapviews) as views,\n CONCAT(CAST(ROUND((SUM(m.mapviews)*100)/SUM(SUM(m.mapviews)) OVER (PARTITION BY gr.name),2) as text), '%') as percent_of_group_views\n FROM (((users as u\n INNER JOIN groups_users as gu ON u.id=gu.user_id)\n INNER JOIN groups as gr ON gr.id = gu.group_id)\n INNER JOIN maps as m ON m.user_id = u.id)\n GROUP BY (gr.name, u.name)\n ORDER BY gr.name ASC, percent_of_group_views DESC;\");\n\n @results3 = []\n\n index = 0\n @content.each do |r|\n @results3[index] = Result3.new r\n index = index + 1;\n end\n\n return @results3\n end", "def summarize_per_table_dum\n @having = NO_ROWS\n end", "def summaries\n header = summarize_per.header\n summaries = default_summaries\n operand.each { |tuple| summaries.summarize_by(header, tuple) }\n summaries\n end", "def summarize\n # count of ads in language in the past day (via grouped by day for the past week)\n # count of ads in language in the past week\n ads_by_day_this_week = Ad.where(lang: @lang).unscope(:order).where(\"date(created_at) > now() - interval '1 week' \").group(\"date(created_at)\").count\n ads_today = ads_by_day_this_week[ads_by_day_this_week.keys.last]\n ads_this_week = ads_by_day_this_week.values.reduce(&:+)\n\n # count of ads in language total\n political_ads_count = Ad.where(lang: @lang).count\n\n # last week's ratio of ads to political ads\n daily_political_ratio = Ad.unscoped.where(lang: @lang).where(\"date(created_at) > now() - interval '1 week' \").group(\"date(created_at)\").select(\"count(*) as total, sum(CASE political_probability > 0.7 AND NOT suppressed WHEN true THEN 1 ELSE 0 END) as political, date(created_at) as date\").map{|ad| [ad.date, ad.political.to_f / ad.total, ad.total]}.sort_by{|date, ratio, total| date}\n\n # rolling weekly ratio of ads to political ads\n weekly_political_ratio = Ad.unscoped.where(lang: @lang).where(\"date(created_at) > now() - interval '2 months' \").group(\"extract(week from created_at), extract(year from created_at)\").select(\"count(*) as total, sum(CASE political_probability > 0.7 AND NOT suppressed WHEN true THEN 1 ELSE 0 END) as political, extract(week from created_at) as week, extract(year from created_at) as year\").sort_by{|ad| ad.year.to_s + ad.week.to_s }.sort_by{|ad| ad.year.to_s + ad.week.to_i.to_s.rjust(2, '0') }.map{|ad| [ad.week, ad.political.to_f / ad.total, ad.total]}\n\n # datetime of last received ad\n last_received_at = Ad.unscoped.where(lang: @lang).order(:created_at).last.created_at\n\n render json: {\n ads_this_week: ads_this_week,\n ads_today: ads_today,\n total_political_ads: political_ads_count,\n daily_political_ratio: daily_political_ratio,\n weekly_political_ratio: weekly_political_ratio,\n last_received_at: last_received_at\n }\n end", "def aggregate\n #response = Result.collection.map_reduce(self.map_fn(), _reduce(), :raw => true, :out => {:inline => true}, :query => {:execution_id => id})\n response = Result.where(execution_id: id).map_reduce(self.map_fn(), self.query.reduce).out(inline: true).raw()\n results = response['results']\n if results\n self.aggregate_result = {}\n results.each do |result|\n result = prettify_generated_result(result) if self.query.generated? && result['value']['rereduced']\n self.aggregate_result[result['_id']] = result['value']\n end\n save!\n end\n end", "def cohort()\n return @cohort\nend", "def total(list)\n\ttotal_students = 0\n\tlist.map do |cohorts, size|\n\t\ttotal_students += size\n\tend\n\treturn total_students\nend", "def summarize_per_subset\n @having = ANY_ROWS\n end", "def index\n # TODO: Gotta be able to replace all this imperative scoping with `Ransack` or summit...\n\n @answer_sets = current_user.accessible_answer_sets\n\n # set default values into params\n params[:granularity] ||= current_user.default_cohort_granularity\n params[:group] ||= :day\n\n\n if params[:from_date].present?\n @answer_sets = @answer_sets.where(\"answer_sets.created_at >= ?\", params[:from_date])\n end\n if params[:to_date].present?\n @answer_sets = @answer_sets.where(\"answer_sets.created_at <= ?\", params[:to_date])\n end\n\n\n # setup the core query of the answer_set data\n @chart_data = @answer_sets.select('avg(answers.value) as value').joins(:answers, :cohort)\n\n\n # set the granularity of the data as required\n @chart_data = case params[:granularity].to_s.downcase\n when 'person'\n # remove the granularity of seeing the individual metric - instead, show each user's average for the set\n @chart_data.select('answer_sets.cohort_id as cohort_id, answer_sets.user_id as metric_id, answer_sets.user_id as user_id, users.email as label').group('answer_sets.cohort_id, answer_sets.user_id, users.email').joins(:user)\n\n when 'cohort'\n authorize! :granularity_by_cohort, AnswerSet\n @chart_data.select(\"answer_sets.cohort_id as cohort_id, 'cohort' as metric_id, 'cohort' as user_id, cohorts.name as label\").group('answer_sets.cohort_id, cohorts.name')\n\n else\n # default to grouping as finely-grained as possible - right down to the individual metric\n @chart_data.select(\"answer_sets.cohort_id as cohort_id, answers.metric_id as metric_id, answer_sets.user_id as user_id, users.email || ': ' || metrics.measure as label\").group(\"answer_sets.cohort_id, answers.metric_id, answer_sets.user_id, users.email || ': ' || metrics.measure\").joins(:user, answers: :metric)\n end\n\n\n # group the data into days/weeks if required\n @chart_data = case params[:group].to_s.downcase\n when 'hour'\n @x_labels = 'hour'\n @chart_data.select(\"date_trunc('hour', answer_sets.created_at) as created_at\").group(\"date_trunc('hour', answer_sets.created_at)\")\n\n when 'day'\n @x_labels = 'day'\n @chart_data.select('DATE(answer_sets.created_at) as created_at').group('DATE(answer_sets.created_at)')\n\n when 'week'\n # TODO: the week-grouping chart labels get fubard... try to sort them\n @x_labels = 'month'\n @chart_data.select(\"EXTRACT(YEAR FROM answer_sets.created_at)::text as created_at_year, EXTRACT(WEEK FROM answer_sets.created_at)::text as created_at_week\").group(\"EXTRACT(YEAR FROM answer_sets.created_at)::text, EXTRACT(WEEK FROM answer_sets.created_at)::text\")\n\n else\n @chart_data.select('answer_sets.created_at as created_at').group('answer_sets.created_at')\n end\n\n\n @data = chart_data(@chart_data)\n @keys = chart_data_keys(@chart_data)\n @labels = chart_data_labels(@chart_data)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @chart_data }\n end\n end", "def summarize_results(results)\n sort_order = ['scenario', 'step', 'failed', 'flaky', 'undefined', 'skipped', 'pending', 'passed']\n\n ['scenario', 'step'].map do |group|\n group_results = results.grep(/^\\d+ #{group}/)\n next if group_results.empty?\n\n sums = sum_up_results(group_results)\n sums = sums.sort_by { |word, _| sort_order.index(word) || 999 }\n sums.map! do |word, number|\n plural = \"s\" if (word == group) && (number != 1)\n \"#{number} #{word}#{plural}\"\n end\n \"#{sums[0]} (#{sums[1..-1].join(\", \")})\"\n end.compact.join(\"\\n\")\n end", "def cohort\n return @cohort\n end", "def aggregated_over_time_query\n quantity_field = @country_ids.present? ? \"#{entity_quantity}_reported_quantity\" : \"#{@reported_by}_reported_quantity\"\n\n <<-SQL\n SELECT ROW_TO_JSON(row)\n FROM (\n SELECT JSON_AGG(JSON_BUILD_OBJECT('x', year, 'y', value) ORDER BY year) AS datapoints\n FROM (\n SELECT year, ROUND(SUM(#{quantity_field}::FLOAT)) AS value\n FROM #{shipments_table}\n #{child_taxa_join}\n WHERE #{@condition} AND #{quantity_field} IS NOT NULL AND #{country_condition}\n AND #{child_taxa_condition}\n GROUP BY year\n #{quantity_condition(quantity_field)}\n ORDER BY value DESC\n #{limit}\n ) t\n ) row\n SQL\n end", "def summarize(group_by, properties=[], query=nil, options={})\n rv = []\n\n fields = ([group_by]+[*properties]).compact.collect{|field|\n self.resolve_field(field)\n }.reverse\n\n # pop current field off the stack\n current_field = fields.pop()\n\n # perform query, only return facets (no documents)\n results = self.search({\n :facets => {\n :counts => {\n :facet_filter => (query.nil? ? nil : self.to_elasticsearch_query(query)),\n :terms => {\n :field => current_field,\n :size => (options[:limit].nil? ? DEFAULT_MAX_FACETS : options[:limit])\n },\n :global => true\n }.compact\n }\n }, {\n :limit => 0,\n :raw => true\n })\n\n # if we got anything...\n unless results.get('facets.counts.terms').nil?\n results.get('facets.counts.terms', []).each do |facet|\n rv << {\n :id => facet['term'],\n :field => self.unresolve_field(current_field),\n :count => facet['count'],\n :children => (fields.empty? ? nil :\n # we need to go deeper...\n self.summarize(fields[0], fields[1..-1], [query, \"#{self.unresolve_field(current_field)}/#{facet['term']}\"].compact.join('/'))\n )\n }.compact\n end\n\n # add in empty results as nulls\n if results.get('facets.counts.missing', 0) > 0\n rv << {\n :id => nil,\n :field => self.unresolve_field(current_field),\n :count => results.get('facets.counts.missing'),\n :children => (fields.empty? ? nil :\n # we need to go deeper...\n self.summarize(fields[0], fields[1..-1], [query, \"#{self.unresolve_field(current_field)}/null\"].compact.join('/'))\n )\n }\n end\n end\n\n return rv\n end", "def summarise!( header )\n load( summarise( header ).to_a.unshift [ header, 'Count' ] )\n end", "def statement\n case @metric.aggregate\n when :sum\n parts = {\n select: select_statement,\n joins: dimension_joins,\n having: having_statement,\n order: order_by_statement\n }\n\n statement = ([model] + parts.keys).inject do |chain, method|\n chain.public_send(method, parts[method])\n end\n\n statement = process_scope_dimension_filter(statement)\n statement = process_lambda_dimension_filter(statement)\n statement = process_ransack_dimension_filter(statement)\n\n # The original gem did not handle has_many relationships. In order to support\n # has_many, we need to first do an inner query to select out distinct rows _before_\n # attempting the sum. Therefore we build up the query piece\n # by piece rather than using the basic statement.\n\n sum_definition = parts[:select].first\n original_columns = parts[:select].drop(1)\n\n # Collect a list of all renamed columns from the original query so that we can include\n # these in the outer query.\n renamed_columns = []\n original_columns.each do |sel|\n renamed_columns << sel.split(' AS ').last\n end\n\n # In some situations the column we're summing over is not included as a part of the aggregation\n # in the inner query. In such cases we must explicitly select the desired column in the inner\n # query, so that we can sum over it in the outer query.\n summation_metric = if select_aggregate.include?(\"CASE\")\n select_aggregate.split('CASE WHEN ').last.split(' ').first\n else\n ''\n end\n\n outer_columns = ([sum_definition] << renamed_columns).flatten.uniq.join(', ')\n inner_columns = (original_columns << [summation_metric, fact_model.measure.to_s]).flatten.uniq.reject(&:blank?).join(', ').remove(\"\\n\").squeeze(' ')\n inner_from = statement.to_sql.split('FROM').last\n group_by = outer_group_by_statement.join(', ')\n\n # Finally, construct the query we want and return it as a string\n full_statement = \"SELECT #{outer_columns} FROM(SELECT #{distinct}, #{inner_columns} FROM #{inner_from}) AS T\"\n\n # Add the GROUP BY clause only if it's non nil and non empty\n full_statement = \"#{full_statement} GROUP BY #{group_by}\" if group_by.present?\n\n full_statement\n\n else\n parts = {\n select: select_statement,\n joins: dimension_joins,\n group: group_by_statement,\n having: having_statement,\n order: order_by_statement\n }\n\n statement = ([model] + parts.keys).inject do |chain, method|\n chain.public_send(method, parts[method])\n end\n\n statement = process_scope_dimension_filter(statement)\n statement = process_lambda_dimension_filter(statement)\n statement = process_ransack_dimension_filter(statement)\n\n statement.to_sql\n end\n end", "def call()\n Population.left_joins(:logz).group(:year).count(\"the_logz.year\").sort_by{|k, v| v}.reverse\n end", "def count_records_in_measure_groups\n patient_cache = get_db.collection('patient_cache')\n base_query = {'value.measure_id' => @measure_id, 'value.sub_id' => @sub_id,\n 'value.effective_date' => @parameter_values['effective_date'],\n 'value.test_id' => @parameter_values['test_id']}\n\n base_query.merge!(filter_parameters)\n \n query = base_query.clone\n\n query.merge!({'value.manual_exclusion' => {'$in' => [nil, false]}})\n \n result = {:measure_id => @measure_id, :sub_id => @sub_id, \n :effective_date => @parameter_values['effective_date'],\n :test_id => @parameter_values['test_id'], :filters => @parameter_values['filters']}\n \n # need to time the old way agains the single query to verify that the single query is more performant\n aggregate = {\"population\"=>0, \"denominator\"=>0, \"numerator\"=>0, \"antinumerator\"=>0, \"exclusions\"=>0}\n %w(population denominator numerator antinumerator exclusions).each do |measure_group|\n patient_cache.find(query.merge(\"value.#{measure_group}\" => true)) do |cursor|\n aggregate[measure_group] = cursor.count\n end\n end\n aggregate[\"considered\"] = patient_cache.find(query).count\n aggregate[\"exclusions\"] += patient_cache.find(base_query.merge({'value.manual_exclusion'=>true})).count\n result.merge!(aggregate)\n\n result.merge!(execution_time: (Time.now.to_i - @parameter_values['start_time'].to_i)) if @parameter_values['start_time']\n\n get_db.collection(\"query_cache\").save(result, safe: true)\n result\n end", "def get_outcome_result_rollups(course_id,opts={})\n query_param_keys = [\n :aggregate,\n :user_ids,\n :outcome_ids,\n :include\n ]\n\n form_param_keys = [\n \n ]\n\n # verify existence of params\n raise \"course_id is required\" if course_id.nil?\n # set default values and merge with input\n options = underscored_merge_opts(opts,\n :course_id => course_id\n )\n\n # resource path\n path = path_replace(\"/v1/courses/{course_id}/outcome_rollups\",\n :course_id => course_id)\n headers = nil\n form_params = select_params(options, form_param_keys)\n query_params = select_params(options, query_param_keys)\n if opts[:next_page]\n pagination_params = page_params_load(:get, path)\n query_params.merge! pagination_params if pagination_params\n end\n response = mixed_request(:get, path, query_params, form_params, headers)\n page_params_store(:get, path)\n response\n \n end", "def aggregate\n klass.collection.group(\n :key => field_list,\n :cond => selector,\n :initial => { :count => 0 },\n :reduce => Javascript.aggregate\n )\n end", "def exercise2\n @content = ActiveRecord::Base.connection.execute(\"\n SELECT\n gr.name as group_name,\n u.name as user_name,\n sum(m.mapviews) as groups_count\n FROM (((users as u\n INNER JOIN groups_users as gu ON u.id=gu.user_id)\n INNER JOIN groups as gr ON gr.id = gu.group_id)\n INNER JOIN maps as m ON m.user_id = u.id)\n GROUP BY (gr.name, u.name)\n ORDER BY gr.name, groups_count DESC;\");\n\n @results2 = []\n\n index = 0\n @content.each do |r|\n @results2[index] = Result2.new r\n index = index + 1;\n end\n\n return @results2\n end", "def populate_rollup_cube(options={})\n create_rollup_cube_table(options)\n puts \"Populating rollup cube #{cube_class.name}\" if options[:verbose]\n\n num_columns = dimensions_to_columns.size\n num_combos = (2**num_columns)-1\n puts \"There are #{num_combos} combinations\" if options[:verbose]\n (0..num_combos).each do |i|\n puts \"Populating agg #{i} of #{num_combos}\" if i % 100 == 0 if options[:verbose]\n mask = sprintf(\"%0#{num_columns}b\", i).split(//).collect{|x| x == '1' ? true : false}\n\n sql = ''\n sql += \"INSERT INTO #{rollup_table_name} \"\n sql += build_aggregate_sql(mask)\n\n connection.transaction { connection.execute(sql) }\n end\n\n if options[:verbose]\n row_count = connection.select_value(\"SELECT count(*) FROM #{rollup_table_name}\")\n puts \"Rollup cube populated with #{row_count} rows\"\n end\n end", "def cohorts\n # participants.find(:all, :select => [:grad_year]).collect(&:grad_year).uniq.compact.sort.reverse\n @cohorts ||= participants.find(:all, :select => \"DISTINCT grad_year\").collect(&:grad_year).compact.sort.reverse\n end", "def summarize_suite(suite, tests); end", "def summarize_suite(suite, tests); end", "def aggregated_over_time_query\n # TODO Remember to implement permitted parameters here\n query = @grouping_class.new(sanitized_attributes, params)\n @aggregated_over_time_data = Rails.cache.fetch(['aggregated_over_time_data', params], expires_in: 1.week) do\n query.aggregated_over_time_data\n end\n\n render json: @aggregated_over_time_data\n end", "def count_contestants_by_hometown(data, hometown)\n all_seasons(data).reduce(0) do |sum, contestant|\n if contestant[\"hometown\"] == hometown \n sum + 1 \n else \n sum \n end\n end\nend", "def cohort_list(list)\n\tlist.each do |cohort, num_of_students|\n\t\tputs \"#{cohort}: has #{num_of_students} students\"\n\tend\nend", "def index\n @q = Record.ransack(params[:q])\n @records = @q.result(distinct: true)\n @total_sales = @records.sum(:sales)\n end", "def index \n @cohorts = Cohort.all\n \n end", "def queries_summary(project_id)\n get \"projects/#{project_id}/queries/summary\"\n end", "def create_summary_average_report\n setup_summary_report\n @data = PppamsCategoryBaseRef.indicator_summary_between(@show_from, @show_to, summary_query_options)\n render_report('summary_average')\n end", "def summary\n \n end", "def count\n raise \"View#count cannot be used with group options\" if query[:group]\n if can_reduce?\n row = reduce.skip(0).limit(1).rows.first\n row.nil? ? 0 : row.value\n else\n limit(0).total_rows\n end\n end", "def exercise1\n @content = ActiveRecord::Base.connection.execute(\"\n SELECT\n u.name as user_name,\n COUNT(gr.name) as groups_count,\n CONCAT('[', COALESCE(STRING_AGG(gr.name, ', ' ), ''),']') as groups\n FROM ((users as u\n LEFT JOIN groups_users as gu ON u.id=gu.user_id)\n LEFT JOIN groups as gr ON gr.id = gu.group_id)\n GROUP BY user_name\n ORDER BY groups_count;\");\n\n @results1 = []\n\n index = 0\n @content.each do |r|\n @results1[index] = Result1.new r\n index = index + 1;\n end\n\n return @results1\n end", "def index\n @exam_results = ExamResult.order(:week_s => :desc).first(200)\n @exam_results_all = ExamResult.all\n\n @exam_results_weeks = ExamResult.count(:week_s)\n @exams_results_exams = ExamResult.sum(:taken)\n end", "def index\n @cohorts = Cohort.all\n end", "def get_population_set_summaries(current_measure, archived_measure)\n patients = Record.where(user_id: current_measure.user_id, measure_ids: current_measure.hqmf_set_id)\n\n # if there is no archived_measure, set this to 0\n pre_upload_population_set_count = archived_measure ? archived_measure.measure_content['populations'].count : 0\n # there should always be a current_measure\n post_upload_population_set_count = current_measure.populations.count\n\n # store patient calculation information based on the archived_measure\n (0..pre_upload_population_set_count-1).each do |population_set_index|\n population_set_summary = PopulationSetSummary.new\n self.population_set_summaries << population_set_summary\n\n # collect pre upload information if a previous version of the measure existed (there is an archived_measure)\n if archived_measure\n population_set_summary.store_patient_information(current_measure, patients, population_set_index, :pre_upload)\n end\n end\n \n # clear out any existing calc_results so that all of the calc_results will be based on the new version of the measure\n # rework the expected value structure for the newly uploaded measure.\n patients.each do |patient|\n patient.clear_existing_calc_results!(current_measure)\n patient.update_expected_value_structure!(current_measure)\n end\n\n # recalculate the patient information for the newly uploaded measure and\n # note that the patient has measure history\n calculator = BonnieBackendCalculator.new\n current_measure.populations.each_with_index do |population, population_set_index|\n calculator.set_measure_and_population(current_measure, population_set_index, clear_db_cache: true, rationale: true)\n patients.each do |patient|\n patient.has_measure_history = true # update_calc_results does the patient save to persist this change\n begin\n patient.update_calc_results!(current_measure, population_set_index, calculator)\n rescue => e\n logger.error \"\\n\\nThere has been an error calculating the patient in measure_upload_summary:get_population_set_summaries\"\n logger.error \"Error for #{current_measure.user.email} measure #{current_measure.cms_id} population set #{population_set_index} patient '#{patient.first} #{patient.last}' (_id: ObjectId('#{patient.id}'))\"\n logger.error e.message\n logger.error e.backtrace.inspect\n logger.error \"\\n\\n\"\n raise e # want to re-raise the error so any internal handling continues\n end\n end\n end\n\n # store patient calculation information based on the newly uploaded measure\n (0..post_upload_population_set_count-1).each do |population_set_index|\n if population_set_index >= self.population_set_summaries.length\n population_set_summary = PopulationSetSummary.new\n self.population_set_summaries << population_set_summary\n else\n population_set_summary = self.population_set_summaries[population_set_index]\n end\n\n population_set_summary.store_patient_information(current_measure, patients, population_set_index, :post_upload)\n end\n end", "def getAssessmentResults(sheet, year_row, start_row)\n stats = Hash.new { |h,k| h[k] = Hash.new { |h,k| h[k] = {} } }\n (0..100).step(3) do |sg_offset| # go down the rows\n blank = sheet.row(start_row + sg_offset)[TEST_TYPE_BLANK_COL]\n return start_row + sg_offset, stats if blank.nil? or (blank.is_a? String and blank.empty?)\n subgroup = sheet.row(start_row + sg_offset)[TEST_GROUP_COL]\n (START_SCORE_COL..START_SCORE_COL+8).step(4) do |offset| # and across\n year = sheet.row(year_row)[offset]\n stats[subgroup][year]['Advanced'] = sheet.row(start_row + sg_offset)[offset]\n stats[subgroup][year]['Proficient'] = sheet.row(start_row + sg_offset)[offset+1]\n stats[subgroup][year]['Fail'] = sheet.row(start_row + sg_offset)[offset+3]\n end\n end\n # maybe need a fall-through?\nend", "def result\n query_group.with_context do\n if primary.summarise?\n summary_result\n else\n simple_result\n end\n end\n end", "def organization_analysis\n \n @organization = Organization.find(params[:id])\n \n # make sure user is sys admin, or orgleader of the organization that they want to look at.\n if (!current_user.is_admin? && !@organization.organization_leaders.map{|x| x.id}.include?(current_user.id))\n redirect_to organizations_path\n flash[:error] = \"Sorry, you cannot access this portion of the site.\"\n end\n\n # build hash of all user scores for each measurement.\n @measurements_scores = Hash.new(Array.new)\n checkpt_users = Set.new\n responses = Set.new\n \n @organization.checkpoints.map{|ou| checkpt_users.merge(ou.checkpoint_users)}\n checkpt_users.map{|cu| responses.merge(cu.responses.reject{|resp| !resp.is_complete?})}\n\n responses.each do |resp|\n measureStr = resp.question.measurement.name\n @measurements_scores[measureStr] = [] if (@measurements_scores[measureStr] == nil) \n @measurements_scores[measureStr] = @measurements_scores[measureStr] << resp.percent_score\n end\n \n end", "def hitter_totals\n totals = {\"h\" => 0, \"ab\" => 1}\n Hitter.team_view(self).reduce.group_level(2).rows.each do |obj|\n totals[obj[\"key\"][1]] = obj[\"value\"]\n end\n # now correct for the averages\n totals[\"avg\"] = (totals[\"h\"]/totals[\"ab\"].to_f).round(3)\n totals\n end", "def summary_json(user)\n return {} unless user.admin? || user.ta?\n\n if user.admin?\n groupings = self.groupings\n graders = groupings.joins(:tas)\n .pluck_to_hash(:id, 'users.user_name', 'users.first_name', 'users.last_name')\n .group_by { |x| x[:id] }\n assigned_criteria = nil\n else\n groupings = self.groupings\n .joins(:memberships)\n .where('memberships.user_id': user.id)\n graders = {}\n if self.assign_graders_to_criteria\n assigned_criteria = user.criterion_ta_associations\n .where(assessment_id: self.id)\n .pluck(:criterion_id)\n else\n assigned_criteria = nil\n end\n end\n\n grouping_data = groupings.joins(:group)\n .left_outer_joins(inviter: :section)\n .pluck_to_hash(:id, 'groups.group_name', 'sections.name')\n .group_by { |x| x[:id] }\n members = groupings.joins(:accepted_students)\n .pluck_to_hash(:id, 'users.user_name', 'users.first_name', 'users.last_name')\n .group_by { |x| x[:id] }\n tag_data = groupings\n .joins(:tags)\n .pluck_to_hash(:id, 'tags.name')\n .group_by { |h| h[:id] }\n groupings_with_results = groupings.includes(current_result: :marks).includes(:submitted_remark, :extension)\n result_ids = groupings_with_results.pluck('results.id').uniq.compact\n extra_marks_hash = Result.get_total_extra_marks(result_ids, max_mark: max_mark)\n\n hide_unassigned = user.ta? && hide_unassigned_criteria\n\n criteria_shown = Set.new\n max_mark = 0\n\n selected_criteria = user.admin? ? self.criteria : self.ta_criteria\n criteria_columns = selected_criteria.map do |crit|\n unassigned = !assigned_criteria.nil? && !assigned_criteria.include?(crit.id)\n next if hide_unassigned && unassigned\n\n max_mark += crit.max_mark unless crit.bonus?\n accessor = crit.id\n criteria_shown << accessor\n {\n Header: crit.bonus? ? \"#{crit.name} (#{Criterion.human_attribute_name(:bonus)})\" : crit.name,\n accessor: \"criteria.#{accessor}\",\n className: 'number ' + (unassigned ? 'unassigned' : ''),\n headerClassName: unassigned ? 'unassigned' : ''\n }\n end.compact\n\n final_data = groupings_with_results.map do |g|\n result = g.current_result\n has_remark = g.current_submission_used&.submitted_remark.present?\n if user.ta? && anonymize_groups\n group_name = \"#{Group.model_name.human} #{g.id}\"\n section = ''\n group_members = []\n else\n group_name = grouping_data[g.id][0]['groups.group_name']\n section = grouping_data[g.id][0]['sections.name']\n group_members = members.fetch(g.id, [])\n .map { |s| [s['users.user_name'], s['users.first_name'], s['users.last_name']] }\n end\n\n tag_info = tag_data.fetch(g.id, [])\n .map { |a| a['tags.name'] }\n criteria = result.nil? ? {} : result.mark_hash.select { |key, _| criteria_shown.include?(key) }\n extra_mark = extra_marks_hash[result&.id]\n {\n group_name: group_name,\n section: section,\n members: group_members,\n tags: tag_info,\n graders: graders.fetch(g.id, [])\n .map { |s| [s['users.user_name'], s['users.first_name'], s['users.last_name']] },\n marking_state: marking_state(has_remark,\n result&.marking_state,\n result&.released_to_students,\n g.collection_date),\n final_grade: [criteria.values.compact.sum + (extra_mark || 0), 0].max,\n criteria: criteria,\n max_mark: max_mark,\n result_id: result&.id,\n submission_id: result&.submission_id,\n total_extra_marks: extra_mark\n }\n end\n\n { data: final_data,\n criteriaColumns: criteria_columns,\n numAssigned: self.get_num_assigned(user.admin? ? nil : user.id),\n numMarked: self.get_num_marked(user.admin? ? nil : user.id) }\n end", "def new_total_tb_w2yrs(start_date=Time.now, end_date=Time.now, section=nil)\n value = []\n\n start_date = @@start_date.to_date.strftime('%Y-%m-%d 00:00:00')\n end_date = @@end_date.to_date.strftime('%Y-%m-%d 23:59:59')\n\n patients = FlatCohortTable.find_by_sql(\"SELECT ftc.patient_id FROM flat_cohort_table ftc\n LEFT OUTER JOIN flat_table1 ft1 ON ft1.patient_id = ftc.patient_id\n WHERE ftc.date_enrolled >= '#{start_date}'\n AND ftc.date_enrolled <= '#{end_date}'\n AND (ft1.pulmonary_tuberculosis_last_2_years = 'Yes' OR\n ft1.who_stages_criteria_present = 'Tuberculosis (PTB or EPTB) within the last 2 years')\n GROUP BY ftc.patient_id\").collect{|p| p.patient_id}\n\n\n value = patients unless patients.blank?\n end", "def index\n render json: serializer_class.new(paginate(ecf_schools), params: { cohort: }).serializable_hash.to_json\n end", "def index\n\t\tauth_producer\n\t\t@cohorts = @current_user.cohorts\n\tend", "def total_students(students)\n\ttotal = 0\n\tstudents.each do |cohort, number| \n\t\ttotal += number.to_i\n\tend\n\tputs total\nend", "def index\r\n @profile_projects = Profile::Project.select('profile_projects.*, COUNT(profile_evaluations.id) AS num_eval').joins('LEFT OUTER JOIN profile_evaluations ON profile_evaluations.project_id = profile_projects.id').group('profile_projects.id').where(user_id: current_user.id).paginate(page: params[:page], per_page: 10).order(\"created_at DESC\")\r\n end", "def index\n @rankings = Prediction.select(\"user_id, name, sum(score) as score\")\n .joins(:user) \n .group(\"user_id, name\")\n .order(\"score DESC, name ASC\")\n .paginate(page: params[:page])\n end", "def aggregate(property, resolution)\n # Look up the date/time dimensions for the resolution.\n date_time_dimensions = date_time_dimensions_for_resolution(resolution)\n\n # Build the timestamp from the date/time dimensions.\n timestamp = Sequel::SQL::NumericExpression.new(:+, *date_time_dimensions).cast(:timestamp).as(:timestamp)\n\n # Build a window function to sum the counts.\n count_window_function = Sequel::SQL::Function.new(:sum, :count).over(partition: date_time_dimensions).as(:count)\n\n # Build the aggregation window functions.\n aggregation_window_functions = AGGREGATIONS.map do |aggregation|\n Sequel::SQL::Function.new(aggregation, :\"#{property}\").over(partition: date_time_dimensions).as(:\"#{aggregation}_#{property}\")\n end\n\n facts_dataset\n .join(:dimension_dates, date: Sequel.cast(:timestamp, :date))\n .join(:dimension_times, time: Sequel.cast(:timestamp, :time))\n .distinct(*date_time_dimensions)\n .select(timestamp, count_window_function, *aggregation_window_functions)\n end", "def cohorts_print #students #, existing_cohorts\n puts \"Students grouped by cohort:\"\n puts #spacer line\n #existing_cohorts = [] I DON'T NEED TO DECALRE IT FIRST\n existing_cohorts = @students.map {|student| student[:cohort]}.sort.uniq\n for i in (0..existing_cohorts.length-1)\n @students.map do |student|\n if student[:cohort] == existing_cohorts[i]\n cohortstr = student[:cohort].to_s.capitalize + \" Cohort\"\n puts \"#{cohortstr.ljust(20)} #{student[:name]} \"\n end #end if\n end #end do\n end #end for\n success\n #cohorts\nend", "def bowlingStats\n BowlingInnings.joins(:Player).select(\"name, SUM(wickets), SUM(runs)\").group(:name)\n end", "def sum(project_id, event_collection, target_property, options = {})\n options[:event_collection] = event_collection\n options[:target_property] = target_property\n\n resource \"projects/#{project_id}/queries/sum\", options\n end", "def induction_records\n @induction_records ||= dashboard_school_cohorts.flat_map do |school_cohort|\n InductionRecordPolicy::Scope\n .new(user,\n school_cohort\n .induction_records\n .current_or_transferring_in_or_transferred\n .eager_load(induction_programme: %i[school core_induction_programme lead_provider delivery_partner],\n participant_profile: %i[user ecf_participant_eligibility ecf_participant_validation_data])\n .order(\"users.full_name\"))\n .resolve\n .order(start_date: :desc, created_at: :desc)\n .uniq(&:participant_profile_id)\n end\n end", "def sum_overall\n @categories.inject(0.0) { |sum, (name, cat)| sum + cat[:sum] }\n end", "def cohort_assignments\n StudentAssignment.joins(:assignment).where(assignment: self.assignments)\n end", "def aggregate profile_name, interface=nil\n extend TCD::Common\n count=0\n Dir.glob(File.expand_path(\"~/.tcd/stats/#{profile_name}/#{interface || '*'}/*\")).each {|path|\n next unless TCD::Profiles.needsAggregating(path)\n day= getDateFromPath(path)\n interface= File.basename(File.dirname(path))\n stats= TCD::Storage.readStats(profile_name, interface) {|p| TCD::Profiles.isDay(day,p) }\n in_sum= out_sum= 0\n stats[:in].each {|size, date| in_sum+=size }\n stats[:out].each {|size, date| out_sum+=size }\n stats[:in]= [[in_sum, :sum]] + stats[:in]\n stats[:out]=[[out_sum,:sum]] + stats[:out]\n writeFile YAML.dump(stats), '00-00-00_aggr.txt', path+'/'\n TCD::Storage.postAggDeletion( path )\n count+=1\n }\n count\n end", "def summarize_suite(suite, tests)\n summary = Hash.new(0)\n summary[:name] = suite.to_s\n tests.each do |test|\n summary[:\"#{result(test)}_count\"] += 1\n summary[:assertion_count] += test.assertions\n summary[:test_count] += 1\n summary[:time] += test.time\n end\n summary[:has_errors_or_failures] = (summary[:fail_count] + summary[:error_count]) > 0\n summary[:has_skipps] = summary[:skip_count] > 0\n summary\n end", "def aggregate_sum(aggr)\n sum = {}\n aggr.each do |ts, counterVals|\n sum[ts] = {} unless sum.has_key?ts\n counterVals.each do |obj, count|\n if obj.respond_to?(:enterprise_id)\n eid = obj.public_send(:enterprise_id).to_s\n sum[ts][eid] = sum[ts].fetch(eid, 0) + count\n end\n end\n end\n sum\n end", "def count_per_period_all\n \tcount = Center.all.inject({}) do |col,center|\n \t\tcol[center.id] = count_sum_per_period(center.id)\n \t\tcol\n \tend\n end", "def getAssessmentResults(sheet, year_row, start_row)\n stats = Hash.new { |h,k| h[k] = Hash.new { |h,k| h[k] = {} } }\n (0..100).step(3) do |sg_offset| # go down the rows\n subgroup = sheet.row(start_row + sg_offset)[TEST_GROUP_COL]\n break if subgroup.nil? or subgroup.empty? or subgroup.include? 'English: Reading' or subgroup.include? 'Mathematics'\n (START_SCORE_COL..START_SCORE_COL+8).step(4) do |offset| # and across\n year = sheet.row(year_row)[offset]\n stats[subgroup][year][:adv] = sheet.row(start_row + sg_offset)[offset]\n stats[subgroup][year][:pro] = sheet.row(start_row + sg_offset)[offset+1]\n stats[subgroup][year][:fai] = sheet.row(start_row + sg_offset)[offset+3]\n end\n end\n stats\nend", "def print_by_cohort\n cohorts = []\n @students.each do |student|\n unless cohorts.include? student[:cohort]\n cohorts << student[:cohort]\n end\n end\n cohorts.each do |month|\n puts \"#{month} cohort:\"\n students.each_with_index do |student, index|\n if student[:cohort] == month\n puts \"#{index + 1}. #{student[:name]}\"\n # print_student_data(student)\n end\n end\n end\nend", "def total_workout_calories\n set_sport_by_user.sum(:burned_calories) || 0\n end", "def category_totals(db, user_name, number)\r\n\tretrieve_totals = '\r\n\tSELECT categories.name, SUM(amount) FROM expenses\r\n\tJOIN users ON expenses.user_id = users.id\r\n\tJOIN categories ON expenses.category_id = categories.id\r\n\tWHERE categories.id = ?\r\n\tAND users.name = ?'\r\n\ttotals = db.execute(retrieve_totals, [number, user_name])[0]\r\nend", "def index\n @goals = current_user.goals\n occs = current_user.occurrences.includes(habit: :goal)\n .where('scheduled_at >= ?', DateTime.now.beginning_of_week(start_day=:monday))\n .where('scheduled_at <= ?', DateTime.now.end_of_week).order(:scheduled_at)\n\n # group by weekday\n @schedule = occs.group_by { |occ| occ.scheduled_at.strftime('%A').downcase.to_sym }\n\n # calculate streaks\n occs = current_user.occurrences.includes(:habit).where('scheduled_at <= ?', DateTime.now).order(:scheduled_at).limit(100)\n @streaks = occs.group_by{ |occ| occ.habit.goal_id }\n\n # get all metrics\n configs = current_user.experience_sample_configs\n\n # get this weeks metrics\n current_week_metrics = current_user.samplings.includes(:experience_sample_config)\n .where('scheduled_at >= ?', DateTime.now.beginning_of_week(start_day=:monday))\n .where('scheduled_at <= ?', DateTime.now.end_of_week)\n .group(:experience_sample_config_id).average(:value)\n\n # get last weeks metrics\n last_week_metrics = current_user.samplings.includes(:experience_sample_config)\n .where('scheduled_at >= ?', DateTime.now.beginning_of_week(start_day=:monday) - 7.days)\n .where('scheduled_at <= ?', DateTime.now.end_of_week - 7.days)\n .group(:experience_sample_config_id).average(:value)\n\n @metrics = configs.map { |config| {\n config: config,\n current_week: current_week_metrics[config.id]&.round(2),\n last_week: last_week_metrics[config.id]&.round(2),\n difference: percentage_difference(current_week_metrics[config.id], last_week_metrics[config.id])\n }}\n end", "def execute(input_set = nil)\n resp = super(input_set)\n results = AdGroupStatsResultSet.new(resp)\n return results\n end", "def summarize(data, summarization_method, variable=nil)\n case summarization_method\n when 'sum'\n data = data.sum(variable)\n when 'max'\n data = data.maximum(variable)\n when 'count'\n data = data.count(variable)\n end\n end", "def results\n responses\n .includes(answer_choices)\n .group(:answer)\n .count\n end", "def cohort_student_assignments\n StudentAssignment.joins(:student).where(student: self.students)\n end", "def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_name\n<<-SQL\n SELECT DISTINCT title ,SUM(amount) FROM projects INNER JOIN pledges ON projects.id = pledges.project_id\n GROUP BY projects.title\n SQL\nend", "def reshare_lending_summary(model, institution, fiscal_year)\n\n # Get the prefix of the table for the reshare model\n prefix = table_name_prefix(model::Reshare)\n\n # Get the rollup of lending attempts\n model::Reshare::Transaction.connection.select_all(\n \"SELECT\n COALESCE(\n #{prefix}transactions.borrower, 'All Institutions'\n ) AS borrower,\n COUNT(DISTINCT #{prefix}transactions.request_id) AS total_requests,\n COUNT(DISTINCT #{prefix}transactions.request_id) FILTER (\n WHERE #{prefix}transactions.lender_status = 'RES_COMPLETE'\n ) AS complete,\n COUNT(DISTINCT #{prefix}transactions.request_id) FILTER (\n WHERE #{prefix}transactions.lender_status = 'RES_UNFILLED'\n ) as unfilled,\n COUNT(DISTINCT #{prefix}transactions.request_id) FILTER (\n WHERE #{prefix}transactions.lender_status = 'RES_CANCELLED'\n ) AS cancelled,\n COUNT(DISTINCT #{prefix}transactions.request_id) FILTER (\n WHERE #{prefix}transactions.lender_status NOT IN (\n 'RES_UNFILLED', 'RES_COMPLETE', 'RES_CANCELLED'\n )\n ) AS pending,\n ROUND(\n CAST(\n COUNT(DISTINCT #{prefix}transactions.request_id) FILTER (\n WHERE #{prefix}transactions.lender_status = 'RES_COMPLETE'\n ) AS DECIMAL\n ) / NULLIF(\n CAST(\n COUNT(DISTINCT #{prefix}transactions.request_id) FILTER (\n WHERE #{prefix}transactions.lender_status IN (\n 'RES_COMPLETE', 'RES_UNFILLED', 'RES_CANCELLED'\n )\n ) AS DECIMAL\n ), 0\n ), 2\n ) AS fill_rate,\n ROUND(AVG(#{prefix}lending_turnarounds.time_to_fill) FILTER (\n WHERE #{prefix}transactions.lender_status != 'RES_UNFILLED'\n ), 2) AS average_time_to_fill,\n ROUND(AVG(#{prefix}lending_turnarounds.time_to_ship) FILTER (\n WHERE #{prefix}transactions.lender_status != 'RES_UNFILLED'\n ), 2) AS average_time_to_ship,\n ROUND(AVG(#{prefix}lending_turnarounds.time_to_receipt) FILTER (\n WHERE #{prefix}transactions.lender_status != 'RES_UNFILLED'\n ), 2) AS average_time_to_receipt,\n ROUND(AVG(#{prefix}lending_turnarounds.total_time) FILTER (\n WHERE #{prefix}transactions.lender_status != 'RES_UNFILLED'\n ), 2) AS average_turnaround\n FROM #{prefix}transactions\n LEFT JOIN #{prefix}lending_turnarounds\n ON #{prefix}lending_turnarounds.request_id = #{prefix}transactions.lender_id\n WHERE #{prefix}transactions.lender = '#{institution}'\n AND #{prefix}transactions.date_created\n BETWEEN '#{fiscal_year-1}-07-01' AND '#{fiscal_year}-06-30'\n GROUP BY ROLLUP (borrower)\n ORDER BY borrower NULLS FIRST;\"\n ).rows\n end", "def visit_axiom_aggregate_sum(sum)\n aggregate_function_sql(SUM, sum)\n end", "def summarize_results!(all_results)\n \t summaries = {}\n \t all_results.each do |paramset, results|\n \t File.open(@dir + \"/results-#{param_string(paramset)}.yaml\", 'w' ) do |out|\n \t\t\tYAML.dump(results, out)\n \t\tend\n \t\tsummaries[paramset] = {}\n \t\t# create an array of arrays\n \t\tres = results.keys.map do |key| \n \t\t # calculate stats\n \t\t a = results[key]\n \t\t if a.all? {|el| el.is_a? Numeric }\n \t\t summaries[paramset][\"#{key} mean\"] = Stats::mean(a)\n \t\t summaries[paramset][\"#{key} SD\"] = Stats::standard_deviation(a)\n \t\t [key] + a + [Stats::mean(a), Stats::standard_deviation(a)]\n \t\t else\n \t\t [key] + a + [\"--\", \"--\"]\n \t end\n \t\t end\n\t\t \n \t\t ls = results.keys.map{|v| [7, v.to_s.length].max }\n \t\t\n \t\tls = [\"Std Deviation\".length] + ls\n \t\tres = header_column + res\n \t\tres = res.transpose\n \t\tout = build_table res, ls\n \t\tFile.open(@dir + \"/#{paramset}-summary.mmd\", 'w') do |f|\n \t\t f << \"## Results for #{@experiment} with parametres #{param_string(paramset, \", \")} ##\\n\\n\"\n \t\t f << out\n \t\t end\n\t\t end\n\t\t \n\t\t # Build CSV file with all of the results\n\t\t #puts summaries.inspect\n\t\t \n\t\t summaries = summaries.to_a\n #puts summaries.inspect\n\t\t keys1 = summaries.first.first.keys\n\t\t keys2 = summaries.first.last.keys\n\t\t #puts keys1.inspect, keys2.inspect, \"=====\"\n CSV.open(@dir + \"/results.csv\", \"w\") do |csv|\n \t csv << keys1 + keys2\n \t summaries.each do |summary|\n \t #puts summary.first.inspect\n \t #puts summary.first.values_at(*keys1).inspect + summary.last.values_at(*keys2).inspect\n \t csv << summary.first.values_at(*keys1) + summary.last.values_at(*keys2)\n \t \n \t end\n \t end\n\t\t \n\t end", "def summarize!\n %i[critical warning unknown].each do |status|\n send(status, summary) unless results[status].empty?\n end\n ok(summary)\n end", "def cohort_field\n @@start_date = params[\"start_date\"]\n @@end_date = params[\"end_date\"]\n\n if params[\"field\"]\n\n if params[\"start_date\"]\n start_date = params[\"start_date\"]\n else\n start_date = Time.now.strftime(\"%Y-%m-%d\")\n end\n if params[\"end_date\"]\n end_date = params[\"end_date\"]\n else\n end_date = Time.now.strftime(\"%Y-%m-%d\")\n end\n\n case params[\"field\"]\n when \"regimens\"\n regimens(start_date, end_date, params[\"field\"])\n when \"defaulters\"\n art_defaulters(start_date, end_date, params[\"field\"])\n when \"total_alive_and_on_art\"\n total_alive_and_on_art(start_date, end_date, params[\"field\"])\n when \"defaulted\"\n defaulted(start_date, end_date, params[\"field\"])\n when \"total_on_art\"\n total_on_art(start_date, end_date, params[\"field\"])\n when \"new_total_reg\"\n new_total_reg(start_date, end_date, params[\"field\"])\n when \"cum_total_reg\"\n cum_total_reg(start_date, end_date, params[\"field\"])\n when \"new_ft\"\n new_ft(start_date, end_date, params[\"field\"])\n when \"cum_ft\"\n cum_ft(start_date, end_date, params[\"field\"])\n when \"new_re\"\n new_re(start_date, end_date, params[\"field\"])\n when \"cum_re\"\n cum_re(start_date, end_date, params[\"field\"])\n when \"new_ti\"\n new_ti(start_date, end_date, params[\"field\"])\n when \"cum_ti\"\n cum_ti(start_date, end_date, params[\"field\"])\n when \"new_males\"\n new_males(start_date, end_date, params[\"field\"])\n when \"cum_males\"\n cum_males(start_date, end_date, params[\"field\"])\n when \"new_non_preg\"\n new_non_preg(start_date, end_date, params[\"field\"])\n when \"cum_non_preg\"\n cum_non_preg(start_date, end_date, params[\"field\"])\n when \"new_preg_all_age\"\n new_preg_all_age(start_date, end_date, params[\"field\"])\n when \"cum_preg_all_age\"\n cum_preg_all_age(start_date, end_date, params[\"field\"])\n when \"new_a\"\n new_a(start_date, end_date, params[\"field\"])\n when \"cum_a\"\n cum_a(start_date, end_date, params[\"field\"])\n when \"new_b\"\n new_b(start_date, end_date, params[\"field\"])\n when \"cum_b\"\n cum_b(start_date, end_date, params[\"field\"])\n when \"new_c\"\n new_c(start_date, end_date, params[\"field\"])\n when \"cum_c\"\n cum_c(start_date, end_date, params[\"field\"])\n when \"new_unk_age\"\n new_unk_age(start_date, end_date, params[\"field\"])\n when \"cum_unk_age\"\n cum_unk_age(start_date, end_date, params[\"field\"])\n when \"new_pres_hiv\"\n new_pres_hiv(start_date, end_date, params[\"field\"])\n when \"cum_pres_hiv\"\n cum_pres_hiv(start_date, end_date, params[\"field\"])\n when \"new_conf_hiv\"\n new_conf_hiv(start_date, end_date, params[\"field\"])\n when \"cum_conf_hiv\"\n cum_conf_hiv(start_date, end_date, params[\"field\"])\n when \"new_who_1_2\"\n new_who_1_2(start_date, end_date, params[\"field\"])\n when \"cum_who_1_2\"\n cum_who_1_2(start_date, end_date, params[\"field\"])\n when \"new_who_2\"\n new_who_2(start_date, end_date, params[\"field\"])\n when \"cum_who_2\"\n cum_who_2(start_date, end_date, params[\"field\"])\n when \"new_children\"\n new_children(start_date, end_date, params[\"field\"])\n when \"cum_children\"\n cum_children(start_date, end_date, params[\"field\"])\n when \"new_breastfeed\"\n new_breastfeed(start_date, end_date, params[\"field\"])\n when \"cum_breastfeed\"\n cum_breastfeed(start_date, end_date, params[\"field\"])\n when \"new_preg\"\n new_preg(start_date, end_date, params[\"field\"])\n when \"cum_preg\"\n cum_preg(start_date, end_date, params[\"field\"])\n when \"new_who_3\"\n new_who_3(start_date, end_date, params[\"field\"])\n when \"cum_who_3\"\n cum_who_3(start_date, end_date, params[\"field\"])\n when \"new_who_4\"\n new_who_4(start_date, end_date, params[\"field\"])\n when \"cum_who_4\"\n cum_who_4(start_date, end_date, params[\"field\"])\n when \"new_other_reason\"\n new_other_reason(start_date, end_date, params[\"field\"])\n when \"cum_other_reason\"\n cum_other_reason(start_date, end_date, params[\"field\"])\n when \"new_no_tb\"\n new_no_tb(start_date, end_date, params[\"field\"])\n when \"cum_no_tb\"\n cum_no_tb(start_date, end_date, params[\"field\"])\n when \"new_tb_w2yrs\"\n new_tb_w2yrs(start_date, end_date, params[\"field\"])\n when \"cum_tb_w2yrs\"\n cum_tb_w2yrs(start_date, end_date, params[\"field\"])\n when \"new_current_tb\"\n new_current_tb(start_date, end_date, params[\"field\"])\n when \"cum_current_tb\"\n cum_current_tb(start_date, end_date, params[\"field\"])\n when \"new_ks\"\n new_ks(start_date, end_date, params[\"field\"])\n when \"cum_ks\"\n cum_ks(start_date, end_date, params[\"field\"])\n when \"died_1st_month\"\n died_1st_month(start_date, end_date, params[\"field\"])\n when \"died_2nd_month\"\n died_2nd_month(start_date, end_date, params[\"field\"])\n when \"died_3rd_month\"\n died_3rd_month(start_date, end_date, params[\"field\"])\n when \"died_after_3rd_month\"\n died_after_3rd_month(start_date, end_date, params[\"field\"])\n when \"died_total\"\n died_total(start_date, end_date, params[\"field\"])\n when \"stopped\"\n stopped(start_date, end_date, params[\"field\"])\n when \"transfered\"\n transfered(start_date, end_date, params[\"field\"])\n when \"unknown_outcome\"\n unknown_outcome(start_date, end_date, params[\"field\"])\n when \"n0a\"\n n1a(start_date, end_date, params[\"field\"])\n when \"n0p\"\n n1p(start_date, end_date, params[\"field\"])\n when \"n1a\"\n n1a(start_date, end_date, params[\"field\"])\n when \"n1p\"\n n1p(start_date, end_date, params[\"field\"])\n when \"n2a\"\n n2a(start_date, end_date, params[\"field\"])\n when \"n2p\"\n n2p(start_date, end_date, params[\"field\"])\n when \"n3a\"\n n3a(start_date, end_date, params[\"field\"])\n when \"n3p\"\n n3p(start_date, end_date, params[\"field\"])\n when \"n4a\"\n n4a(start_date, end_date, params[\"field\"])\n when \"n4p\"\n n4p(start_date, end_date, params[\"field\"])\n when \"n5a\"\n n5a(start_date, end_date, params[\"field\"])\n when \"n6a\"\n n6a(start_date, end_date, params[\"field\"])\n when \"n7a\"\n n7a(start_date, end_date, params[\"field\"])\n when \"n8a\"\n n8a(start_date, end_date, params[\"field\"])\n when \"n9p\"\n n9p(start_date, end_date, params[\"field\"])\n when \"non_std\"\n non_std(start_date, end_date, params[\"field\"])\n when \"tb_no_suspect\"\n tb_no_suspect(start_date, end_date, params[\"field\"])\n when \"tb_suspected\"\n tb_suspected(start_date, end_date, params[\"field\"])\n when \"tb_confirm_not_treat\"\n tb_confirm_not_treat(start_date, end_date, params[\"field\"])\n when \"tb_confirmed\"\n tb_confirmed(start_date, end_date, params[\"field\"])\n when \"unknown_tb\"\n unknown_tb(start_date, end_date, params[\"field\"])\n when \"current_site\"\n current_site\n when \"quarter\"\n quarter(start_date, end_date, params[\"field\"])\n when \"side_effects\"\n side_effects(start_date, end_date, params[\"field\"])\n when \"no_effects\"\n no_effects(start_date, end_date, params[\"field\"])\n when \"unk_effects\"\n unk_effects(start_date, end_date, params[\"field\"])\n when \"missed_0_6\"\n missed_0_6(start_date, end_date, params[\"field\"])\n when \"missed_7plus\"\n missed_7plus(start_date, end_date, params[\"field\"])\n when \"missed_7plus_one\"\n missed_7plus_one(start_date, end_date, params[\"field\"])\n when \"missed_7plus_two\"\n missed_7plus_two(start_date, end_date, params[\"field\"])\n when \"missed_7plus_three\"\n missed_7plus_three(start_date, end_date, params[\"field\"])\n when \"missed_7plus_four\"\n missed_7plus_four(start_date, end_date, params[\"field\"])\n when \"missed_7plus_five\"\n missed_7plus_five(start_date, end_date, params[\"field\"])\n when \"unknown_adherence\"\n unknown_adherence(start_date, end_date, params[\"field\"])\n when \"drug_induced_p_neu\"\n drug_induced_p_neu(start_date, end_date, params[\"field\"])\n when \"drug_induced_leg_pain\"\n drug_induced_leg_pain(start_date, end_date, params[\"field\"])\n when \"drug_induced_hepatitis\"\n drug_induced_hepatitis(start_date, end_date, params[\"field\"])\n when \"drug_induced_skin_rash\"\n drug_induced_skin_rash(start_date, end_date, params[\"field\"])\n when \"drug_induced_jaundice\"\n drug_induced_jaundice(start_date, end_date, params[\"field\"])\n when \"new_patient_pregnant\"\n new_patient_pregnant(start_date, end_date, params[\"field\"])\n when \"cum_patient_pregnant\"\n cum_patient_pregnant(start_date, end_date, params[\"field\"])\n else\n reply(params[\"field\"])\n end\n end\n end", "def group_rollup\n raise Error, \"GROUP BY ROLLUP not supported on #{db.database_type}\" unless supports_group_rollup?\n clone(:group_options=>:rollup)\n end", "def fetch_analytics(collection)\n ga4 = ga4_analytics(collection)\n ua = ua_analytics(collection)\n \n analytics = (ga4+ua).map{|a| a.to_h }.group_by{|h| h[:object] }.map{|k,v| v.reduce({}, :merge)}\n \n analytics.each do |entry|\n entry[:users] = entry[:users].to_i + entry[:ga4_users].to_i if entry[:ga4_users].present?\n entry[:totalEvents] = entry[:totalEvents].to_i + entry[:ga4_totalEvents].to_i if entry[:ga4_totalEvents].present?\n entry[:totalHits] = entry[:totalHits].to_i + entry[:ga4_totalHits].to_i if entry[:ga4_totalHits].present? \n end\n\n object_hash = object_titles(collection)\n analytics.each{ |r| r[:title] = object_hash[r[:object]] }\n\n if sort_column == 'title'\n analytics.sort_by! { |hsh| hsh[sort_column.to_sym] }\n else\n analytics.sort_by! { |hsh| hsh[sort_column.to_sym].to_i }\n end\n analytics.reverse! if sort_direction == 'desc'\n\n analytics\n end", "def summary(profile_report, num_compliant, num_non_compliant)\n report = {\n 'compliant' => num_compliant,\n 'non_compliant' => num_non_compliant\n }\n\n if profile_report['documented_missing_parameters']\n report['documented_missing_parameters'] = profile_report['documented_missing_parameters'].count\n end\n\n if profile_report['documented_missing_resources']\n report['documented_missing_resources'] = profile_report['documented_missing_resources'].count\n end\n\n total_checks = num_non_compliant + num_compliant\n report['percent_compliant'] = total_checks == 0 ? 0 : ((num_compliant.to_f/total_checks) * 100).round(0)\n\n return report\nend", "def query(*args)\n options = parse_query_args(*args)\n\n column_dimension_name = options[:column_dimension_name]\n column_hierarchy_name = options[:column_hierarchy_name]\n row_dimension_name = options[:row_dimension_name]\n row_hierarchy_name = options[:row_hierarchy_name]\n conditions = options[:conditions]\n cstage = options[:cstage]\n rstage = options[:rstage]\n filters = options[:filters]\n\n column_dimension = fact_class.dimension_class(column_dimension_name)\n column_hierarchy = column_dimension.hierarchy(column_hierarchy_name)\n row_dimension = fact_class.dimension_class(row_dimension_name)\n row_hierarchy = row_dimension.hierarchy(row_hierarchy_name)\n\n current_column_name = column_hierarchy[cstage]\n current_row_name = row_hierarchy[rstage]\n full_column_name = \"#{column_dimension_name}_#{current_column_name}\"\n full_row_name = \"#{row_dimension_name}_#{current_row_name}\"\n\n # build the SQL query\n sql = ''\n sql += 'SELECT '\n sql += \"#{full_column_name} AS #{current_column_name},\"\n sql += \"#{full_row_name} AS #{current_row_name},\"\n sql += aggregate_fields.collect{|c| \"#{c.label_for_table} as '#{c.label}'\"}.join(\",\")\n sql += \" FROM #{rollup_table_name} \"\n\n # build the where clause\n where_clause = []\n 0.upto(column_hierarchy.length - 1) do |stage|\n column_name = column_hierarchy[stage]\n name = \"#{column_dimension_name}_#{column_name}\"\n filter_value = filters.delete(column_name)\n if filter_value\n where_clause << \"#{name} = '#{filter_value}'\" # TODO: protect from\n else\n where_clause << \"#{name} is null\" if stage > cstage\n end\n end\n\n 0.upto(row_hierarchy.length - 1) do |stage|\n row_name = row_hierarchy[stage]\n name = \"#{row_dimension_name}_#{row_name}\"\n filter_value = filters.delete(row_name)\n if filter_value\n where_clause << \"#{name} = '#{filter_value}'\" # TODO: protect from\n else\n where_clause << \"#{name} is null\" if stage > rstage\n end\n end\n\n where_clause << \"#{full_column_name} is not null\"\n where_clause << \"#{full_row_name} is not null\"\n\n filters.each do |key, value|\n dimension_name, column = key.split('.')\n where_clause << \"#{dimension_name}_#{column} = '#{value}'\" # TODO: protect from SQL injection\n end\n\n sql += %Q( WHERE #{where_clause.join(\" AND \")} ) if where_clause.length > 0\n\n if conditions\n sql += \"\\n WHERE\\n\" unless sql =~ /WHERE/i\n sql += conditions\n end\n\n # execute the query and return the results as a CubeQueryResult object\n result = ActiveWarehouse::CubeQueryResult.new(aggregate_fields)\n\n rows = connection.select_all(sql)\n # fact_column_names = fact_class.aggregate_fields.collect{|f| f.to_s}\n rows.each do |row|\n result.add_data(row.delete(current_row_name.to_s),\n row.delete(current_column_name.to_s),\n row) # the rest of the members of row are the fact columns\n end\n result\n\n end", "def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_name\n #\"SELECT DISTINCT SUM(pledges.amount) FROM pledges INNER JOIN projects WHERE pledges.project_id = projects.id ORDER BY title ASC;\"\n #\"SELECT projects.title, SUM(pledges.amount) FROM pledges GROUP BY aisle ORDER BY SUM(quantity);\"\n #\"SELECT projects.title, SUM(pledges.amount), count(projects.title) FROM pledges INNER JOIN projects ON pledges.project_id = projects.id GROUP BY projects.title ORDER BY projects.title ASC;\"\n \"SELECT projects.title, SUM(pledges.amount) FROM pledges INNER JOIN projects ON pledges.project_id = projects.id GROUP BY projects.title ORDER BY projects.title ASC;\"\nend", "def record_totals\n workout_hash = Hash.new\n current_user.workouts.each do |w|\n # Today, This Week, This Month, This Year, Total [x2 for time & distance]\n inner_array = [\n w.sum_field_by_time_range(:duration, method(:this_day)),\n w.sum_field_by_time_range(:duration, method(:this_week)),\n w.sum_field_by_time_range(:duration, method(:this_month)),\n w.sum_field_by_time_range(:duration, method(:this_year)),\n w.sum_field_by_time_range(:duration, method(:total)),\n w.sum_field_by_time_range(:distance, method(:this_day)),\n w.sum_field_by_time_range(:distance, method(:this_week)),\n w.sum_field_by_time_range(:distance, method(:this_month)),\n w.sum_field_by_time_range(:distance, method(:this_year)),\n w.sum_field_by_time_range(:distance, method(:total))\n ]\n workout_hash[w] = inner_array\n end\n return workout_hash\n end", "def index\n @invens = Inven.all\n @collections = Collection.all\n \n @locations = Location.all\n @families = Family.all\n @collection_without_donations = @collections.where(\"collection_type !=?\", '2')\n @total = @collection_without_donations.group(:name).sum(:amount).to_a\n # @total = @collections.group(:name).sum(:amount).to_a\n \n @total_collections = @collection_without_donations.sum(:amount)\n @total_by_location = @collection_without_donations.group(:location).sum(:amount).to_a\n # @total_by_location = @collections.group(:location).sum(:amount).to_a\n \n @donations = @collections.group(:collection_type, :name).sum(:amount).to_a\n @total_donations = @collections.where(\"collection_type=?\", '2').sum(:amount)\n \n @location_count = Location.count\n @family_count = Family.count\n @expenses = Expense.all.group(:expense_type).sum(:amount).to_a\n @total_expenses = Expense.all.sum(:amount)\n @const_expenses = ConstructionExpense.all.group(:owner).sum(:amount).to_a\n @total_const_expenses = ConstructionExpense.all.sum(:amount)\n end", "def total(options = {})\n extra = {}\n response = total_by_time_period(options)\n extra = { error: response[:error] } if response[:error].present?\n { query: options[:query], total: response[:results].map { |item| item[:count] }.reduce(:+), calls: response[:calls] }.merge!(extra)\n end", "def print_by_cohort\n\n # for each month in the year (in order)\n Date::MONTHNAMES.each do |month|\n\n # find students in this months cohort\n list = @students.select {|name| name[:cohort] == month}\n\n # if the cohort is empty and skip_empty is true, skip\n if list.length == 0 then next\n\n # otherwise print cohort list\n else\n # print list\n print_header\n print_list(list)\n print_footer(list)\n end\n\n end\n\nend", "def instructors_sum_select\n\t\tselect = \"\"\n\t\ttotal = \"\"\n\t\tdistribution.each do |user|\n\t\t\tselect << \"SUM(#{user[:sql_username]}) as sum_#{user[:sql_username]}, \"\n\t\t\ttotal << \"#{user[:sql_username]}\"\n\t\t\ttotal << \" + \" unless user[:username] == distribution_names.last\n\t\tend\n\t\tselect << \"SUM(#{total}) as attendance_total\"\n\t\tselect\n\tend", "def aggregates\n @aggregates\n end", "def query_standard(query)\n ResultSet.create [\n [scenario.start_year, query_present(query)],\n [scenario.end_year, query_future(query)]\n ]\n end", "def index\n @cohort_users = CohortUser.all\n end", "def init_cohort(cohort)\n @data[cohort] ||= {}\n @data[cohort][:success] ||= 0\n @data[cohort][:failure] ||= 0\n end", "def totals\n Array.new(dimensions.size) + report[\"data\"][\"totals\"][0][\"values\"]\n end", "def cohorts (a)\n a.each do |k, v|\n puts \"#{k}: #{v}\"\n end\nend", "def totalWickets\n if (self.bowlingStats.sum(\"wickets\")[self.name.to_s] != nil) then\n self.bowlingStats.sum(\"wickets\")[self.name.to_s]\n else\n \"\"\n end\n end", "def aggregate(query)\n client.search(\n index: name,\n body: query\n )\n end", "def summate_activity_counts\n activity_count = 0\n all_user_projects_subscriptions.find_each do |subscription|\n next if subscription.empty_summary?\n if count = subscription.summary.values.first[:count].to_i\n activity_count += count\n end\n end\n activity_count\n end", "def index\n @expenses = Expense.all\n @expenses_sum = Expense.sum(:amount)\n @insurances_sum = Insurance.includes(:expense).pluck(:amount).sum\n @breaks_sum = Break.includes(:expense).pluck(:amount).sum\n @damages_sum = Damage.includes(:expense).pluck(:amount).sum\n @owner_takes_sum = OwnerTake.includes(:expense).pluck(:amount).sum\n end", "def new_total_current_tb(start_date=Time.now, end_date=Time.now, section=nil)\n value = []\n\n start_date = @@start_date.to_date.strftime('%Y-%m-%d 00:00:00')\n end_date = @@end_date.to_date.strftime('%Y-%m-%d 23:59:59')\n\n patients = FlatCohortTable.find_by_sql(\"SELECT ftc.patient_id FROM flat_cohort_table ftc\n LEFT OUTER JOIN flat_table1 ft1 ON ft1.patient_id = ftc.patient_id\n WHERE ftc.date_enrolled >= '#{start_date}'\n AND ftc.date_enrolled <= '#{end_date}'\n AND (ft1.pulmonary_tuberculosis = 'Yes' OR\n ft1.extrapulmonary_tuberculosis = 'Yes' OR\n ft1.who_stages_criteria_present IN ('Extrapulmonary tuberculosis (EPTB)', 'Pulmonary tuberculosis', 'Pulmonary tuberculosis (current)'))\n GROUP BY ftc.patient_id\").collect{|p| p.patient_id}\n\n value = patients unless patients.blank?\n end" ]
[ "0.6110699", "0.60947895", "0.5991278", "0.5985832", "0.5840837", "0.57941365", "0.57623947", "0.5734036", "0.56640846", "0.55760056", "0.55481046", "0.55356014", "0.5510348", "0.5414227", "0.5407771", "0.540386", "0.5400838", "0.5367653", "0.5350469", "0.5318325", "0.5241472", "0.52154386", "0.5214431", "0.5180125", "0.5175542", "0.5168235", "0.5149472", "0.5120524", "0.5120524", "0.51171213", "0.51135397", "0.51087046", "0.5107468", "0.5107091", "0.510438", "0.50979406", "0.509625", "0.50634193", "0.50624436", "0.50570744", "0.5055915", "0.50537956", "0.505257", "0.5044111", "0.5032871", "0.50314575", "0.50311327", "0.5030889", "0.50287974", "0.50192624", "0.50168085", "0.5015746", "0.50102895", "0.49962384", "0.49920633", "0.4990864", "0.49860328", "0.49851987", "0.49840856", "0.49772224", "0.49765515", "0.49635234", "0.49411246", "0.4940171", "0.49401018", "0.49378756", "0.49297312", "0.492797", "0.49270085", "0.49264124", "0.49219427", "0.49123457", "0.4900884", "0.4897777", "0.48977748", "0.48948008", "0.48921883", "0.48859262", "0.4885806", "0.48850316", "0.48849595", "0.48788306", "0.48715606", "0.48693472", "0.48652866", "0.48561376", "0.48541376", "0.4851811", "0.48507896", "0.48476702", "0.4842078", "0.4837985", "0.48371628", "0.4830557", "0.4830523", "0.48231894", "0.48194268", "0.48067552", "0.47967795", "0.4795656" ]
0.70358753
0
Run a cohorts_query derived from the current user_ids that have been added formed into a set that can be used in an IN clause. We actually break the set up into multiple parts in case we have a very large number of ids. We then sum the cohorts from the multiple calls, and report them the query must return results as [[cohort, sum],...] This call is similar the to plain cohorts_query except it filters against the user ids that have been added to the manager
def cohorts_query_in(db, proc) sums = [] # initialize the expected number of cohorts (1..current_cohort).each do |cohort| sums[cohort] = 0 end if !@user_ids.nil? # build our user ids total_ids = @user_ids.length count = 0 stmt = "" @user_ids.each do |user_id| if count % IN_CLAUSE_MAX == 0 stmt << "(#{user_id}" else stmt << ",#{user_id}" end count += 1 if (count % IN_CLAUSE_MAX == 0) || (count == total_ids) # hit max batch size or last batch, submit the query stmt << ")" sql = proc.call(date_first, date_last, stmt) stmt = "" results = db.execute(sql) results.each do |r| cohort = r[0] sum = r[1] sums[cohort] = 0 if sums[cohort].nil? sums[cohort] += sum end end end end save_sums(sums) return sums end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sum_cohorts(users)\n sums = []\n # initialize the expected number of cohorts\n (1..current_cohort).each do |cohort|\n sums[cohort] = 0\n end\n\n users.each do |user|\n user_id = user[0]\n cohort = user[1]\n sums[cohort] = 0 if sums[cohort].nil?\n if match_user_id?(user_id)\n sums[cohort] += 1\n end\n end\n\n return sums\n end", "def cohorts_query(db, proc)\n sums = []\n # initialize the expected number of cohorts\n (1..current_cohort).each do |cohort|\n sums[cohort] = 0\n end\n\n sql = proc.call(date_first, date_last)\n results = db.execute(sql)\n results.each do |r|\n cohort = r[0]\n sum = r[1]\n sums[cohort] = 0 if sums[cohort].nil?\n sums[cohort] += sum\n end\n\n save_sums(sums)\n return sums\n end", "def cohorts_query_local_merge(db, proc)\n sql = proc.call(date_first, date_last)\n results = db.execute(sql)\n sums = sum_cohorts(results)\n save_sums(sums)\n return sums\n end", "def all_ids(opts={}, &block)\n user_id = options.delete(:user_id) || User.me.id\n\n opts = options.merge opts\n\n from = \"/users/#{user_id}#{collection_path}/search\"\n\n has_results = true\n ids = []\n\n while has_results && opts[:pages] != opts[:page] do\n params = { limit: opts[:limit],\n offset: opts[:offset] }\n\n path = \"#{from}#{query_string(params)}\"\n data = format.decode(connection.get(path, headers).body) || []\n\n\n results = data[\"results\"]\n has_results = (results.any? and results.count == opts[:limit])\n\n opts[:page ] += 1\n opts[:offset ] += opts[:limit]\n\n yield(results, data, options) if block_given?\n\n ids.concat results\n end\n\n ids\n end", "def user_ids_sql\n \"#{member_user_ids_sql} UNION SELECT user_id FROM project_medias WHERE team_id = #{team_id}\"\n end", "def cohort_student_assignments\n StudentAssignment.joins(:student).where(student: self.students)\n end", "def userids(*values)\n values.inject(self) { |res, val| res._userids(val) }\n end", "def users_who_completed_all_studies\n @downloaded_studies = Study.find(self.study_ids)\n\n user_arr = []\n @downloaded_studies.each do |study|\n user_arr.push(study.study_completions.pluck(:user_id).uniq)\n end\n\n ## SELECT THE COMMON VALUES OF ALL INTERIOR ARRAYS\n user_ids_and_nil = user_arr.reduce { |a, b| a & b }\n\n\n ## THIS COMMAND GETS RID OF ALL LOGGED OUT USER SURVEY DATA -- could be interesting to see if its use can dry up code\n user_ids_who_completed_all_studies = user_ids_and_nil.grep(Integer)\n\n user_ids_who_completed_all_studies\n end", "def find_users_id_from_query\n if query_is_mifare_number?\n find_users_from :card\n else\n found_user_ids = Set.new\n\n USER_SOURCES_PRIORITY.each do |source|\n if found_user_ids.size < USER_COUNT_SEARCH_LIMIT\n found_user_ids.merge(find_users_from source)\n end\n end\n\n found_user_ids.take(USER_COUNT_SEARCH_LIMIT)\n end\n end", "def cohortfilter\n puts \"Please find students by cohort below:\"\n cohort_months = @students.map { |month| month[:cohort]}\n cohort_months.uniq!\n cohort_months.each do |month|\n puts \"Here are the #{month} students\"\n selected_students = @students.select { |student| student[:cohort] == month}\n list(selected_students)\n end\nend", "def adminned_memberships_by_tag(cohort)\n membership = memberships.find_by(cohort: cohort, is_admin: true)\n return [] unless membership && membership.tag_ids.any?\n\n tag_ids = membership.tag_ids\n tagged_memberships = Membership.joins(:taggings).where(cohort: cohort).where(taggings: {tag_id: tag_ids})\n tagged_memberships.uniq\n end", "def promotions\n # Promotion.in(id: user_promotions.pluck(:promotion_id))\n Promotion.where({'id'=> {'$in'=> UserPromotion.pluck(:promotion_id)}, 'end_date'=> {'$gt'=> DateTime.now}, 'start_date'=> {'$lt'=> DateTime.now}})\n end", "def get_set_of_user_ids(arr_of_user_names)\n set_of_user_ids = Set.new\n\n arr_of_user_names.each { |name|\n @url = \"http://#{$canvas_host}/api/v1/courses/#{$canvas_course_id}/users\"\n puts \"@url is #{@url}\"\n \n @payload={'search_term': name}\n puts(\"@payload is #{@payload}\")\n \n @getResponse = HTTParty.get(@url, :body => @payload.to_json, :headers => $header)\n puts(\" GET to get user has Response.code #{@getResponse.code} and getResponse is #{@getResponse}\")\n \n user_data = @getResponse.parsed_response\n \n user_data.each do |user_data_info|\n set_of_user_ids.add user_data_info[\"id\"]\n end\n }\n \n return set_of_user_ids\nend", "def available_cohorts(user)\n\t\tuser.nil? ? self.cohorts : self.cohorts - user.cohorts\n\tend", "def ids_in\n \"p.id IN :ids\" if options[:id].present?\n end", "def cohort_assignments\n StudentAssignment.joins(:assignment).where(assignment: self.assignments)\n end", "def list_cohorts\n @students.each do |student_info|\n if (@cohorts.include? (student_info[:cohort])) == false\n @cohorts << student_info[:cohort]\n end\n end\nend", "def batch_role_params\n params.require(:users).permit(:cohort, user_ids: [])\n end", "def add_users_query(db, proc)\n # since we are running a query, no longer match all even if it returns nothing\n ensure_user_ids\n\n sql = proc.call(date_first, date_last)\n results = db.execute(sql)\n\n # this form expects to see multiple result rows\n results.each do |r|\n user_id = r[0].to_i\n add_user_id(user_id) unless user_id == 0\n end\n end", "def managed_users_sent_approvable_recognitions_set(query_scope)\n query_scope\n .where(::Recognition.arel_table[:sender_id].in(managed_users.pluck(:id)))\n .where(::Badge.arel_table[:requires_approval].eq(true))\n .where(::Badge.arel_table[:approver].eq(Role.manager.id))\n .where(::Badge.arel_table[:approval_strategy].eq(::Badge.approval_strategies[:any_manager]))\n end", "def cohorts\n # participants.find(:all, :select => [:grad_year]).collect(&:grad_year).uniq.compact.sort.reverse\n @cohorts ||= participants.find(:all, :select => \"DISTINCT grad_year\").collect(&:grad_year).compact.sort.reverse\n end", "def users_invited_by_query(start_day, end_day, user_ids_in=nil)\n\n return \"SELECT * FROM users WHERE 0\" if !user_ids_in.nil? && user_ids_in.size == 0\n\n and_user_ids_in = \"AND u.invited_by_source_user_id IN (#{user_ids_in.join(\",\")})\" unless user_ids_in.nil?\n\n return \"SELECT COUNT(*)\n FROM users u\n WHERE u.created_at BETWEEN '#{start_day} 00:00:00' AND '#{end_day} 23:59:59'\n AND u.invited_by_source_user_id IS NOT NULL\n #{and_user_ids_in}\"\n end", "def consuming_users(day, user_ids_in=nil)\n\n and_user_ids_in = \"AND user_id IN (#{user_ids_in.join(\",\")})\" unless user_ids_in.nil?\n\n return \"SELECT DISTINCT user_id\n FROM ns2_notification_items\n WHERE created_at BETWEEN '#{day} 00:00:00' AND '#{day} 23:59:59'\n #{and_user_ids_in}\"\n end", "def batch_query\n render nothing: true\n\n # logger.info \"params: \" + params.inspect\n #\n # endpoints_all = Endpoint.all\n # logger.info \"List of all endpoints:\"\n # endpoints_all.each do |endpoint|\n # logger.info ' name: ' + endpoint[:name] + ', url: ' + endpoint[:base_url]\n # end\n\n # Select endpoints using array of endpoint names;\n # Unfortunately, they are not necessarily unique\n endpoint_names = params[:endpoint_names]\n logger.info 'param endpoint_names:' + endpoint_names.inspect\n selected_endpoints = []\n if endpoint_names\n parse_array(endpoint_names).each do |endpoint_name|\n match_ep = Endpoint.find_by_name(endpoint_name)\n if match_ep\n logger.info endpoint_name.to_s + ' matches: ' + match_ep[:name].inspect\n selected_endpoints.push(match_ep)\n else\n logger.info 'WARNING: ' + endpoint_name.to_s + ' has no match!'\n end\n end\n end\n # logger.info 'selected endpoings: ' + selected_endpoints.inspect\n\n\n # users = User.all\n # users.each do |user|\n # logger.info 'username: ' + user[:username]\n # end\n\n # queries_all = Query.all\n # logger.info \"List of all queries:\"\n # queries_all.each do |query|\n # logger.info ' title: ' + query[:title] + ', desc: ' + query[:description]\n # end\n\n # Select query using array of query descriptions;\n # Unfortunately, they are not necessarily unique\n #query_titles = params[:query_titles]\n username = params[:username]\n current_user = User.find_by_username(username)\n if current_user\n query_descriptions = params[:query_descriptions]\n # logger.info 'param query_descriptions:' + query_descriptions.inspect\n selected_queries = []\n if query_descriptions\n parse_array(query_descriptions).each do |query_desc|\n match_query = current_user.queries.find_by_description(query_desc)\n if match_query\n logger.info query_desc + ' matches: ' + match_query[:description].inspect\n selected_queries.push(match_query)\n else\n logger.info 'WARNING: ' + query_desc + ' has no match!'\n end\n end\n end\n end\n # logger.info 'selected queries: ' + selected_queries.inspect\n\n if selected_endpoints && !selected_endpoints.empty? &&\n selected_queries && !selected_queries.empty?\n notify = params[:notification]\n selected_queries.each do |eachQuery|\n #Parallel.each(selected_queries, :in_threads=>15) do |eachQuery|\n # execute the query, and pass in the endpoints and if the user should be notified by email when execution completes\n # logger.info 'title: ' + eachQuery[:title].inspect\n # logger.info 'desc: ' + eachQuery[:description].inspect\n # logger.info 'user_id: ' + eachQuery[:user_id].inspect\n eachQuery.execute(selected_endpoints, notify)\n end\n else\n flash[:alert] = 'Cannot execute a query if no endpoints are provided.'\n end\n end", "def involved_people\n involved_people_ids.collect{|user_id| User.find(user_id)}\n end", "def users_include?(*user_ids)\n user_ids.map { |user_id| @users.include?(user_id) }.all?\n end", "def liked_in_common_with(klass, user)\n klass.where(:ids => liked_ids_in_common_with(klass, user))\n end", "def memberships_users\n group_ids_select = memberships.select(:user_id).where(user_type: 'Group')\n\n User.where('id IN (:user_ids) OR id IN (:group_owner_ids)',\n user_ids: memberships.select(:user_id).where(user_type: 'User'),\n group_owner_ids: Group.where(id: group_ids_select).select(:owner_id))\n end", "def user_id_company_users(start, stop, users)\n removed_users = UserCompany.\n where(user_id: users).\n not_deleted.\n removed.\n where.not(user_id: @test).\n where('started_at < ?', stop).\n where('removed_at > ?', start)\n not_removed_users = UserCompany.\n where(user_id: users).\n not_deleted.\n not_removed.\n where.not(user_id: @test).\n where('started_at < ?', stop)\n (removed_users + not_removed_users).pluck(:user_id).uniq\nend", "def get_user_ids(deal_id, multiple_redeem = false)\n date = DateTime.now.in_time_zone(\"Singapore\").end_of_day\n if multiple_redeem\n user_ids = Array.new\n all_users = Redemption.where(deal_id: deal_id).where(\"created_at <= ?\", date).select(:user_id).distinct.pluck(:user_id)\n all_users.each do |au|\n if Redemption.where(deal_id: deal_id, user_id: au).count > 1\n user_ids << au\n end\n end\n user_ids\n else\n Redemption.where(deal_id: deal_id).where(\"created_at <= ?\", date).select(:user_id).distinct.pluck(:user_id)\n end\n end", "def filter_by_user\n users = TaskFilter.filter_user_ids(session)\n return \"\" if users.empty? or users.include?(ALL_USERS)\n\n task_ids = []\n users.each do |id|\n if id > 0\n u = User.find(id)\n task_ids += u.tasks.map { |t| t.id }\n elsif id == UNASSIGNED_TASKS\n join = \"LEFT OUTER JOIN task_owners t_o ON tasks.id = t_o.task_id\"\n conditions = [\"tasks.company_id = ? AND t_o.id IS NULL\", @company.id ]\n unassigned = Task.find(:all, :select => \"tasks.*\", \n :joins => join,\n :readonly => false, \n :conditions => conditions)\n task_ids += unassigned.map { |t| t.id }\n end\n end\n\n task_ids = [ \"0\" ] if task_ids.empty?\n return \"tasks.id IN (#{ task_ids.join(\", \") }) AND \"\n end", "def user_query(list)\n\t\treturn nil if !list\n\n\t\tif !list.kind_of?(Array)\n\t\t\ttmp = list\n\t\t\tlist = Array.new\n\t\t\tlist << tmp\n\t\tend\n\n\t\treturn nil if list.empty?\n\n\t\tActiveRecord::Base.silence_auto_explain do\n\t \t# no automatic EXPLAIN is triggered here\n\t\t\treturn SitrackTracking.find_by_sql(\n\t\t\t\t'SELECT p.accountNo, p.firstName, p.lastName, p.preferredName, s.email, s.mobilePhone, s.homePhone, s.otherPhone ' +\n\t\t\t\t'FROM ministry_person AS p ' +\n\t\t\t\t'LEFT JOIN ministry_staff AS s ON p.personID = s.person_id ' +\n\t\t\t\t\"WHERE p.accountNo IN (#{list.map{|u| \"'#{u}'\"}.join(',')})\"\n\t\t\t\t)\n\t\tend\n\tend", "def possible_users\n ids = []\n ids = condition.scan(/\\d+/) if condition.present?\n User.where(:id => ids)\n end", "def friendlist(user)\n User.find_by_sql(\n \"SELECT\n friend_interests_users.user_id as id,\n count(common_interests.id) as num_common_interests\n FROM\n users as me\n left join interests_users as my_interests_users on my_interests_users.user_id = me.id\n left join interests as common_interests on my_interests_users.interest_id = common_interests.id\n left join interests_users as friend_interests_users on common_interests.id = friend_interests_users.interest_id\n WHERE\n friend_interests_users.user_id <> #{user.id} and\n me.id = #{user.id}\n GROUP BY\n friend_interests_users.user_id\n ORDER BY\n num_common_interests desc;\"\n )\n end", "def query\n @klass.where(:_id.in => only_saved_ids)\n end", "def set_cohort_user\n @cohort_user = CohortUser.find(params[:id])\n end", "def get_ids_for_query\n if param.field.options[:definition]\n definition = param.field.options[:definition]\n else\n # Set up a definition\n definition = Definition.new\n definition.base = param.field.options[:base].is_a?(Proc) ? param.field.options[:base].call : param.field.options[:base]\n\n # Get the fields which we should search for\n fields = @field.is_a?(Array) ? @field : [@field]\n fields.each do |field|\n definition.fields << DefinitionField.new(field, :condition => Local, :value_transmogrification => param.field.options[:value_transmogrification])\n end\n end\n\n # Set up a query\n query = Query.new(definition)\n\n # Add all the fields\n query.group(:any) do |params|\n fields.each do |field|\n params << query.param(field, @operator, @value)\n end\n end\n\n ids = query.results.pluck(param.field.options[:foreign_key])\n\n if @operator == :blank\n all_ids = param.query.definition.base.pluck(:id)\n present_ids = definition.base.pluck(param.field.options[:foreign_key])\n ids = (all_ids - present_ids) + ids\n end\n\n ids\n\n end", "def cohort_list(list)\n\tlist.each do |cohort, num_of_students|\n\t\tputs \"#{cohort}: has #{num_of_students} students\"\n\tend\nend", "def calculate_ids amount, offset\n return [] if @combinations.empty? # Checked here to avoid checking in each backend.\n\n # TODO Redesign such that ids is only created (and cached) if requested.\n #\n backend.ids @combinations, amount, offset\n end", "def related_users_query(list_id)\n <<-SQL\n SELECT DISTINCT \"users\".*\n FROM \"users\"\n INNER JOIN \"users_lists\"\n ON \"users\".\"id\" = \"users_lists\".\"user_id\"\n WHERE \"users_lists\".\"list_id\" IN (\n SELECT \"lists\".\"id\"\n FROM \"lists\"\n INNER JOIN \"users_lists\"\n ON \"lists\".\"id\" = \"users_lists\".\"list_id\"\n WHERE \"users_lists\".\"user_id\" = #{id}\n )\n AND NOT \"users\".\"id\" IN (\n SELECT \"users_lists\".\"user_id\"\n FROM \"users_lists\"\n WHERE \"users_lists\".\"list_id\" = #{list_id}\n );\n SQL\n end", "def users_invited_by_query_v2(start_day, end_day, user_ids_in=nil)\n\n return \"SELECT * FROM users WHERE 0\" if !user_ids_in.nil? && user_ids_in.size == 0\n\n and_user_ids_in = \"AND u.invited_by_source_user_id IN (#{user_ids_in.join(\",\")})\" unless user_ids_in.nil?\n\n return \"SELECT u.id\n FROM users u\n WHERE u.created_at BETWEEN '#{start_day} 00:00:00' AND '#{end_day} 23:59:59'\n AND u.invited_by_source_user_id IS NOT NULL\n #{and_user_ids_in}\"\n end", "def usage_per_interval\n #end_date = AnalyticsUsage.last.created_at\n #start_date = AnalyticsUsage.first.created_at\n start_date = params[:report_start_date].to_time.to_i\n end_date = params[:report_end_date].to_time.to_i\n interval = params[:interval].to_i\n type= params[:submit]\n institution_ids = params[:institution]\n institution_names = []\n results = []\n institution_ids.each do |id|\n institution = Institution.find_by_id(id)\n name = institution.name.gsub(\" \",\"\").to_s\n institution_names << name\n users = Institution.find_by_id(id).students.map(&:id)\n s = start_date\n e = Time.at(start_date).to_date.plus_with_duration(interval).to_time.to_i\n i = true\n while i\n if s < end_date\n if e > end_date\n e = end_date\n end\n if type==\"Get Report\"\n duration = AnalyticsUsage.where(:user_id=>users,:created_at=>s..e).sum(:today_usage)\n user_count = AnalyticsUsage.select(:user_id).where(:user_id=>users,:created_at=>s..e).map(&:user_id).uniq.count\n results << [Time.at(s).to_date,Time.at(e).to_date,user_count,duration/60,name]\n elsif type == \"User Report\"\n AnalyticsUsage.where(:user_id=>users,:created_at=>s..e).each do |u|\n user = User.includes(:institution=>(:profile),:center=>(:profile),:academic_class=>(:profile),:section=>(:profile)).find_by_id_and_institution_id(u.id,id)\n if user\n results << [Time.at(s).to_date,Time.at(e).to_date,user.try(:name),(user.edutorid rescue \"\"),(user.institution.try(:name) if user.institution rescue \"\"),(user.center.try(:name) if user.center rescue \"\"),(user.academic_class.try(:name) if user.academic_class rescue \"\"),(user.section.try(:name) if user.section rescue \"\"),(u.today_usage/60 rescue 0),Time.at(u.created_at).to_date]\n end\n end\n end\n s = e\n e = Time.at(s).to_date.plus_with_duration(interval).to_time.to_i\n else\n i = false\n end\n end\n end\n if type == \"Get Report\"\n header = \"Start date,End date,Users,Total Duration,Institution\".split(\",\")\n elsif type == \"User Report\"\n header = \"Start date,End Date,Name,EdutorID,Institution,Center,Class,Section,Duration,Date\".split(\",\")\n end\n\n\n csv_data = FasterCSV.generate do |csv|\n csv << header\n results.each do |c|\n csv << c\n end\n end\n filename = \"Usage-Report\"\n institution_names.collect{|i| filename = filename+\"-\"+i}\n logger.info\"======#{filename}\"\n send_data csv_data, :type => 'text/csv; charset=iso-8859-1; header=present', :disposition => \"attachment; filename=#{filename}.csv\"\n end", "def has_cohorts_not_in?(user)\n\t\tself.cohorts.size - user.cohorts.size > 0\n\tend", "def users\n User.in(id: user_promotions.pluck(:user_id))\n end", "def find_in_batches(batch_size: 1000, &block)\n if iterator\n iterator.call(&block)\n elsif query\n manager_uuids_set.each_slice(batch_size) do |batch|\n yield(query.where(inventory_collection.targeted_selection_for(batch)))\n end\n else\n manager_uuids_set.each_slice(batch_size) do |batch|\n yield(inventory_collection.db_collection_for_comparison_for(batch))\n end\n end\n end", "def induction_records\n @induction_records ||= dashboard_school_cohorts.flat_map do |school_cohort|\n InductionRecordPolicy::Scope\n .new(user,\n school_cohort\n .induction_records\n .current_or_transferring_in_or_transferred\n .eager_load(induction_programme: %i[school core_induction_programme lead_provider delivery_partner],\n participant_profile: %i[user ecf_participant_eligibility ecf_participant_validation_data])\n .order(\"users.full_name\"))\n .resolve\n .order(start_date: :desc, created_at: :desc)\n .uniq(&:participant_profile_id)\n end\n end", "def gather_user_profiles_from_ids(ids)\n ids = ids.map{|i| Integer(i) }\n profiles = []\n count = 0\n ids.each_slice(100) do |arr|\n count += 1\n puts \"On count: #{count}\"\n begin\n data = Twit.fetch_users_by_ids(arr)\n rescue Twitter::Error::TooManyRequests => err\n puts err\n puts \"Sleeping for 30\"\n sleep 30\n retry\n rescue Twitter::Error::NotFound => err\n puts err\n puts \"moving on...\"\n else\n profiles.concat(data)\n sleep 5\n end\n end\n\n return profiles\n end", "def user_ids=(values)\n values ||= []\n values = [ values ] unless values.is_a?(::Array)\n values = values.reject{|v| v.blank?}.map{|v| v.to_i}\n self.users = Incline::User.where(id: values).to_a\n end", "def userSpecificProjects\n #@specific_user = User.find(6) #TEMPORARY: REMOVE LATER\n @specific_user = current_user\n @specific_user_groups = @specific_user.groups\n @specific_user_projects = []\n\n @specific_user_groups.find_each(:batch_size => 5000) do |group|\n group.projects.find_each(:batch_size => 5000) do |project|\n @specific_user_projects << project\n end\n end\n end", "def involved_people_ids\n (\n [self.scrum_master_id.to_s, self.product_owner_id.to_s] + self.team_member_ids + self.stakeholder_ids\n ).select {|u_id| !u_id.blank?}\n end", "def index\n @collaborators = User.includes(:github_account).\n where.not(id: params[:ineligible_user_ids]).\n limit(20)\n\n if params[:q]\n @collaborators = @collaborators.search(params[:q])\n end\n\n respond_to do |format|\n format.json\n end\n end", "def user_ids\n self.class.where(id: id).user_ids\n end", "def suggest_groups_from_membership(user)\n Set.new(Notebook.where(owner: user.groups).map(&:owner_id))\n end", "def query_show_ids(&block)\n @source.query_with_pagination(@queries[:shows], @queries[:count_shows], &block)\n end", "def work_id_list\n query = { params: { q: \"member_of_collection_ids_ssim:#{id} AND has_model_ssim:Work\", fl: \"id\", rows: \"100000\" } }\n results = solr.select(query)\n results['response']['docs'].flat_map(&:values)\n end", "def has_users_not_in?(cohort)\n\t\tself.users.size - cohort.users.size > 0\n\tend", "def fellow_group_member_ids\n user_ids = GroupUser\n .where(group_id: group_ids + owned_group_ids)\n .uniq\n .pluck(:user_id)\n\n # don't include self\n user_ids.delete(id)\n\n user_ids\n end", "def users\n company_ids = [self.id]\n company_ids += advisor_company_ids if advised?\n\n user_ids = UserAffiliation.where(:company_id.in => company_ids).with_access.only(:user_id).map(&:user_id)\n User.where(:id.in => user_ids).order_by(created_at: :asc)\n end", "def my_students\n CourseUser.joins(group_users: :group).merge(Course::GroupUser.normal).\n where(Course::Group.arel_table[:id].in(group_users.manager.pluck(:group_id))).distinct\n end", "def index\n @cohort_users = CohortUser.all\n end", "def find_approved_by_ids(items)\n items.approved_by_users_with_ids(*ids)\n end", "def index\n # TODO: Gotta be able to replace all this imperative scoping with `Ransack` or summit...\n\n @answer_sets = current_user.accessible_answer_sets\n\n # set default values into params\n params[:granularity] ||= current_user.default_cohort_granularity\n params[:group] ||= :day\n\n\n if params[:from_date].present?\n @answer_sets = @answer_sets.where(\"answer_sets.created_at >= ?\", params[:from_date])\n end\n if params[:to_date].present?\n @answer_sets = @answer_sets.where(\"answer_sets.created_at <= ?\", params[:to_date])\n end\n\n\n # setup the core query of the answer_set data\n @chart_data = @answer_sets.select('avg(answers.value) as value').joins(:answers, :cohort)\n\n\n # set the granularity of the data as required\n @chart_data = case params[:granularity].to_s.downcase\n when 'person'\n # remove the granularity of seeing the individual metric - instead, show each user's average for the set\n @chart_data.select('answer_sets.cohort_id as cohort_id, answer_sets.user_id as metric_id, answer_sets.user_id as user_id, users.email as label').group('answer_sets.cohort_id, answer_sets.user_id, users.email').joins(:user)\n\n when 'cohort'\n authorize! :granularity_by_cohort, AnswerSet\n @chart_data.select(\"answer_sets.cohort_id as cohort_id, 'cohort' as metric_id, 'cohort' as user_id, cohorts.name as label\").group('answer_sets.cohort_id, cohorts.name')\n\n else\n # default to grouping as finely-grained as possible - right down to the individual metric\n @chart_data.select(\"answer_sets.cohort_id as cohort_id, answers.metric_id as metric_id, answer_sets.user_id as user_id, users.email || ': ' || metrics.measure as label\").group(\"answer_sets.cohort_id, answers.metric_id, answer_sets.user_id, users.email || ': ' || metrics.measure\").joins(:user, answers: :metric)\n end\n\n\n # group the data into days/weeks if required\n @chart_data = case params[:group].to_s.downcase\n when 'hour'\n @x_labels = 'hour'\n @chart_data.select(\"date_trunc('hour', answer_sets.created_at) as created_at\").group(\"date_trunc('hour', answer_sets.created_at)\")\n\n when 'day'\n @x_labels = 'day'\n @chart_data.select('DATE(answer_sets.created_at) as created_at').group('DATE(answer_sets.created_at)')\n\n when 'week'\n # TODO: the week-grouping chart labels get fubard... try to sort them\n @x_labels = 'month'\n @chart_data.select(\"EXTRACT(YEAR FROM answer_sets.created_at)::text as created_at_year, EXTRACT(WEEK FROM answer_sets.created_at)::text as created_at_week\").group(\"EXTRACT(YEAR FROM answer_sets.created_at)::text, EXTRACT(WEEK FROM answer_sets.created_at)::text\")\n\n else\n @chart_data.select('answer_sets.created_at as created_at').group('answer_sets.created_at')\n end\n\n\n @data = chart_data(@chart_data)\n @keys = chart_data_keys(@chart_data)\n @labels = chart_data_labels(@chart_data)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @chart_data }\n end\n end", "def instructor_queries\n\t\tquery = \"\"\n\n\t\tdistribution.each do |user|\n\t\t\tquery << %(\n\t\t\t\tUNION\n\t\t\t\t-- select contact attributes and count attendances on a time slot\n\t\t\t\tSELECT DISTINCT contacts.*, MAX(accounts_contacts.padma_status) status, #{instructors_count_select user[:sql_username]}\n\t\t\t\tFROM contacts\n\t\t\t\tINNER JOIN accounts_contacts ON contacts.id = accounts_contacts.contact_id\n\t\t\t\tINNER JOIN attendance_contacts ON contacts.id = attendance_contacts.contact_id\n\t\t\t\tINNER JOIN attendances ON attendance_contacts.attendance_id = attendances.id\n\t\t\t\tINNER JOIN time_slots ON attendances.time_slot_id = time_slots.id\n\t\t\t\tWHERE attendances.username = '#{user[:username]}'\n\t\t\t\tAND #{account_condition}\n\t\t\t\tAND #{attendance_between_dates_condition}\n\t\t\t\tAND #{status_condition}\n\t\t\t\t#{cultural_activity_condition}\n\t\t\t\tGROUP BY contacts.id\n\t\t\t)\n\t\tend\n\n\t\tquery\n\tend", "def users\n Ecore::User.find(@user_id, :group_ids.like(\"%#{@id}%\")).receive(:all)\n end", "def get_ids(params)\n if params[:ids]\n type = [\"doi\", \"pmid\", \"pmcid\", \"arxiv\", \"wos\", \"scp\", \"ark\", \"url\"].find { |t| t == params[:type] } || \"pid\"\n type = \"canonical_url\" if type == \"url\"\n ids = params[:ids].nil? ? nil : params[:ids].split(\",\").map { |id| get_clean_id(id) }\n collection = Work.where(works: { type => ids })\n elsif params[:q]\n collection = Work.query(params[:q])\n elsif params[:publisher_id] && publisher = cached_publisher(params[:publisher_id])\n collection = Work.where(publisher_id: publisher.id)\n elsif params[:contributor_id] && contributor = Contributor.where(pid: params[:contributor_id]).first\n collection = Work.joins(:contributions).where(\"contributions.contributor_id = ?\", contributor.id)\n elsif params[:id]\n id_hash = get_id_hash(params[:id])\n if id_hash.present?\n key, value = id_hash.first\n collection = Work.where(key => value)\n else\n collection = Work.none\n end\n else\n collection = Work.tracked\n end\n\n if params[:source_id] && source = cached_source(params[:source_id])\n collection = collection.joins(:results)\n .where(\"results.source_id = ?\", source.id)\n .where(\"results.total > 0\")\n end\n\n if params[:relation_type_id] && relation_type = cached_relation_type(params[:relation_type_id])\n collection = collection.joins(:relations)\n .where(\"relations.relation_type_id = ?\", relation_type.id)\n end\n\n if params[:registration_agency_id] && registration_agency = cached_registration_agency(params[:registration_agency_id])\n collection = collection.where(registration_agency_id: registration_agency.id)\n end\n\n collection\n end", "def queries(with_orgs=true)\n condition_parts(with_orgs).reduce(:merge)\n end", "def enabled_user_ids\n User\n .non_admins\n .find_each(batch_size: 100).each_with_object([]) do |user, ids|\n ids.push(user.id) if user.feature_enabled?(:block_level_sync)\n end\n end", "def user_ids\n page = 1\n per_page = 100\n user_ids = []\n puts 'collecting all user ids'\n loop do\n response = @conn.get api_url('/users'),\n { page: page, per_page: per_page }.merge(token)\n raise 'Error Retrieving user_ids' if response.status != 200\n ids = JSON.parse(response.body).collect { |u| u['id'] }\n user_ids.concat(ids)\n break if ids.size < per_page\n page += 1\n end\n puts 'returning now the user ids'\n user_ids.sort\n end", "def household_user_ids\n @household_user_ids || household.users.where.not(id: id).pluck(:id)\n end", "def household_user_ids\n @household_user_ids || household.users.where.not(id: id).pluck(:id)\n end", "def fetch_for_grouped_by_report_id(criteria, ids_to_be_excluded)\n fetch_for(criteria, ids_to_be_excluded).group_by(&:expense_rpt_id)\n end", "def liked_ids_in_common_with(klass, user_id)\n user_id = user_id.id if user_id.is_a?(Recommendable.config.user_class)\n Recommendable.redis.sinter(Recommendable::Helpers::RedisKeyMapper.liked_set_for(klass, id), Recommendable::Helpers::RedisKeyMapper.liked_set_for(klass, user_id))\n end", "def get_unviewed_ids(user); end", "def scope_langs\n if params[:language_id].present?\n langs_scope = []\n langs_scope << \"langs.language_id = #{params[:language_id]}\"\n langs_condition = \"SELECT user_id FROM langs WHERE #{langs_scope.join('AND')}\"\n @users = @users.where(\"users.id IN (#{langs_condition})\")\n end\n end", "def household_users\n User.where(id: household_user_ids)\n end", "def execute(input_set = nil)\n resp = super(input_set)\n results = ListPlaylistsByIDResultSet.new(resp)\n return results\n end", "def execute(input_set = nil)\n resp = super(input_set)\n results = ListChannelsByIDResultSet.new(resp)\n return results\n end", "def liked_ids_in_common_with(klass, user)\n user_id = user.id if user.is_a?(Recommendations.config.user_class)\n Recommendations.redis.sinter(Recommendations::Helpers::RedisKeyMapper.liked_set_for(klass, id), Recommendations::Helpers::RedisKeyMapper.liked_set_for(klass, user_id))\n end", "def subqueries\n [\n select_distinct_on,\n # default filters -- all scopes have them\n filter_by_subscription_or_topics,\n filter_by_start_date,\n filter_by_end_date,\n # grouping\n group_distinct_on,\n # ordering for GROUP BY\n order_distinct_on,\n ]\n end", "def user_ids\n post\n .organization\n .users\n .select(:id)\n .where('members.active = true')\n .where('users.push_notifications = true')\n end", "def combine_filtered_ids(u_filtered_ids, b_filtered_ids, m_filtered_ids, d_filtered_ids, tenant_filter_ids)\n intersection = ->(operand1, operand2) { [operand1, operand2].compact.reduce(&:&) }\n union = ->(operand1, operand2, operand3 = nil) { [operand1, operand2, operand3].compact.reduce(&:|) }\n\n b_intersection_m = intersection.call(b_filtered_ids, m_filtered_ids)\n u_union_d_union_b_intersection_m = union.call(u_filtered_ids, d_filtered_ids, b_intersection_m)\n\n intersection.call(u_union_d_union_b_intersection_m, tenant_filter_ids)\n end", "def users\n Ecore::User.where(\"group_ids LIKE '%#{id}%'\").all\n end", "def recognition_query\n recognitions_set = super.where(user_id: managed_users)\n\n if status_filter == :pending_approval\n unless @manager.company.allow_manager_to_resolve_recognition_she_sent?\n recognitions_set = exclude_pending_recognitions_sent_by_manager_herself(recognitions_set)\n end\n\n if company_has_company_admin_approvable_badges?\n recognitions_set = exclude_pending_recognitions_approvable_by_company_admin(recognitions_set)\n end\n end\n\n if company_has_any_manager_approvable_badges?\n recognitions_set = recognitions_set.or(managed_users_sent_approvable_recognitions_set(super))\n end\n\n recognitions_set\n end", "def gemd_ids_in_common_with(klass, user_id)\n user_id = user_id.id if user_id.is_a?(Recommendable.config.user_class)\n Recommendable.redis.sinter(Recommendable::Helpers::RedisKeyMapper.gemd_set_for(klass, id), Recommendable::Helpers::RedisKeyMapper.gemd_set_for(klass, user_id))\n end", "def permitted_users_id\n\treturn_user_ids = Array.new\n\tif !self.venue_id.nil?\n\t return_user_ids = ActiveInVenue.where(venue_id: self.venue_id).where.not(user_id: self.user_id).map(&:user_id)\n end\n\tif self.allow_nearby\n\t\treturn_user_ids = return_user_ids | User.where.not(id: self.user_id).near([self.latitude, self.longitude], 25, units: :km).map(&:id)\n\tend\n\tblack_list = BlockUser.blocked_user_ids(self.user_id)\n \tcontent_black_list = ShoutReportHistory.where(reportable_id: self.id).where(reportable_type: 'Shout').map(&:reporter_id)\n \treturn_user_ids = return_user_ids - black_list - content_black_list\n\n \t# only user pusher for online users\n \tonline_users_ids = User.where(id: return_user_ids).where(pusher_private_online: true).map(&:id)\n \treturn online_users_ids\n end", "def users_who_created_activity_query(start_day, end_day, user_ids_in=nil)\n\n return \"SELECT * FROM users WHERE 0\" if !user_ids_in.nil? && user_ids_in.size == 0\n\n and_user_ids_in = \"AND subj_id IN (#{user_ids_in.join(\",\")})\" unless user_ids_in.nil?\n\n return \"SELECT subj_id\n FROM activity_items\n WHERE created_at BETWEEN '#{start_day} 00:00:00' AND '#{end_day} 23:59:59'\n AND subj_type = \\\"User\\\"\n AND obj_type IN (\\\"Event\\\", \\\"EventMessage\\\", \\\"InviteResponse\\\")\n #{and_user_ids_in}\n GROUP BY subj_id\"\n end", "def active_copoolers\n sql = \"SELECT DISTINCT ON (u.id) u.* FROM users u JOIN pools p ON p.user_id = u.id\n WHERE p.is_active = true\n AND p.user_id != :uid\n AND p.trip_id in (:tids)\"\n vars = {uid: id, tids: trips.ids}\n @active_copoolers = User.find_by_sql [sql,vars]\n end", "def rule_member_ids\n results = []\n\n # Step One: Build groups out of each 'is' rule,\n # grouping rules of similar type together via OR\n # Note: we ignore the 'loginid' column as it is calculated separately\n # Produce an array of arrays: outer array items represent each column type used, inner arrays are all group rule IDs for that specific column type\n # e.g. id: 1 \"organization is\", id: 2 \"organization is\", id: 3 \"department is\" produces: [ [1,2] , [3] ]\n GroupRule.select(:group_rule_result_set_id, :column)\n .where(group_id: id)\n .where(condition: 'is')\n .where.not(column: 'loginid')\n .group_by(&:column)\n .map { |set| set[1].map(&:group_rule_result_set_id) }.each do |rule_set_ids|\n rule_set_results = GroupRuleResult.select(:entity_id)\n .joins(:group_rule_result_set)\n .where(group_rule_result_set_id: rule_set_ids)\n .map(&:entity_id)\n results << rule_set_results\n end\n\n # Step Two: AND all groups from step one together\n results = results.inject(results.first) { |sum, n| sum &= n }\n results ||= [] # reduce/inject may return nil\n\n # Step Three: Pass over the result from step two and\n # remove anybody who violates an 'is not' rule\n negative_results = []\n GroupRule.select(:group_rule_result_set_id, :column)\n .where(group_id: id)\n .where(condition: 'is not')\n .group_by(&:column)\n .map { |set| set[1].map(&:group_rule_result_set_id) }.each do |rule_set_ids|\n negative_results << GroupRuleResult.select(:entity_id)\n .joins(:group_rule_result_set)\n .where(group_rule_result_set_id: rule_set_ids)\n .map(&:entity_id)\n end\n\n results -= negative_results.flatten.uniq\n\n # Step Four: Process any 'loginid is' rules\n rules.select { |r| r.condition == 'is' && r.column == 'loginid' }.each do |rule|\n # Rails.logger.debug \"Processing loginid is rule #{rule.value}...\"\n results << rule.result_set.results.map(&:entity_id)\n end\n\n results.flatten!\n\n return results # rubocop:disable Style/RedundantReturn\n end", "def user_ids\n users.pluck(:id)\n end", "def timeline_user_ids(myself = true)\n myself ? leader_ids + [id] : leader_ids\n end", "def find_manageable_seasons( check_date = Date.today() )\n @seasons_found = true\n @seasons_ids = @user.\n team_managers.\n joins( team_affiliation: :season ).\n where( ['seasons.end_date >= ? and seasons.begin_date <= ?', check_date, check_date]).\n select( \"team_affiliations.season_id\" ).\n map{ |tm| tm.season_id }\n end", "def cohort_user_params\n params.require(:cohort_user).permit(:cohort_id, :user_id)\n end", "def queries\n parse_ga_response(authenticated_service.batch_get_reports(reports_request))\n end", "def available_users(cohort)\n\t\tcohort.nil? ? self.users : self.users - cohort.users\n\tend", "def club_owner_ids\n find.\n lifes.\n clubs.\n map(:_id).\n go!\n end", "def track_interviewee_ids\n param_role_extractor(:track_contributors, :interviewees)\n end", "def getActivitiesCohortSemester\n degreeProgs = Programme.all.pluck(:id)\n \n acts = []\n degreeProgs.each do |prgm|\n \n #Get the durations of activities that belong to the current programme\n actProgs = ActivityProgramme.where(programme_id: prgm).pluck(:activity_id)\n actstt = ActivityTimetable.where(activity_id: actProgs).pluck(:duration)\n \n #Add all durations to the sum\n sum = 0\n actstt.each do |time|\n unless time.nil?\n sum = sum + (time/60.0)\n end\n end\n \n #push the result\n progName = Programme.find(prgm).code\n acts.push([progName, sum]) \n\n end\n return acts\n end", "def execute(input_set = nil)\n resp = super(input_set)\n results = GetMembershipsResultSet.new(resp)\n return results\n end", "def apply_filters(query, options)\n if @model_ids && options[:mview]\n query = query.where(model_id: @model_ids)\n elsif @model_ids\n query = query.where('scenarios.model_id' => @model_ids)\n end\n query = query.where(scenario_id: @scenario_ids) if @scenario_ids\n query = query.where(indicator_id: @indicator_ids) if @indicator_ids\n query = query.where(location_id: @location_ids) if @location_ids\n query = query.joins(:indicator).where(indicators: {subcategory_id: apply_category_filter}) if @category_ids\n puts query.to_sql.inspect\n query\n end", "def set_cohorts_student\n @cohorts_student = CohortsStudent.find(params[:id])\n end" ]
[ "0.6177951", "0.6114492", "0.52603155", "0.5226534", "0.5221034", "0.5028796", "0.50081253", "0.49946836", "0.4981251", "0.49521142", "0.49093488", "0.48550412", "0.48397872", "0.48375145", "0.48262027", "0.48130345", "0.47871277", "0.47742367", "0.47499028", "0.4749216", "0.4743208", "0.47213256", "0.47034326", "0.46678296", "0.46226948", "0.46175987", "0.4615938", "0.45951572", "0.45932284", "0.45906422", "0.4583784", "0.45828503", "0.45760527", "0.45500553", "0.4542779", "0.4530936", "0.45257357", "0.45205405", "0.45190725", "0.44923025", "0.44817778", "0.4478189", "0.4476077", "0.44752482", "0.4460007", "0.44503474", "0.44451502", "0.4436161", "0.44361347", "0.44341555", "0.4429802", "0.4423693", "0.4419874", "0.44175386", "0.44126546", "0.440713", "0.44051057", "0.43786892", "0.4377865", "0.4375174", "0.43740046", "0.43600413", "0.43555006", "0.43482018", "0.43474743", "0.43437123", "0.43433848", "0.43383855", "0.433433", "0.433433", "0.43247524", "0.4320217", "0.4317514", "0.4316878", "0.4315444", "0.43120715", "0.43114957", "0.43095365", "0.43086955", "0.4307829", "0.4307729", "0.430386", "0.43012238", "0.42975515", "0.42937106", "0.42887235", "0.4288028", "0.42840087", "0.42834723", "0.42757538", "0.42739835", "0.42692208", "0.4264666", "0.42630646", "0.42623678", "0.4259773", "0.42567196", "0.42500186", "0.42360926", "0.42330685" ]
0.7764512
0
GET /black_fridays GET /black_fridays.json
def index @black_fridays = BlackFriday.paginate(:page => params[:page], :per_page => 10) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @fridays = Friday.all\n end", "def show\n @closing_day = ClosingDay.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @closing_day }\n end\n end", "def index\n @holidays = Holiday.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @holidays }\n end\n end", "def index\r\n @classdays = Classday.all\r\n\r\n render json: @classdays\r\n end", "def create\n @black_friday = BlackFriday.new(black_friday_params)\n\n respond_to do |format|\n if @black_friday.save\n format.html { redirect_to @black_friday, notice: 'Black friday was successfully created.' }\n format.json { render :show, status: :created, location: @black_friday }\n else\n format.html { render :new }\n format.json { render json: @black_friday.errors, status: :unprocessable_entity }\n end\n end\n end", "def get_remaining_days(view_id, sprint_id)\n\thttp = create_http\n\trequest = create_request(\"/rest/greenhopper/1.0/gadgets/sprints/remainingdays?rapidViewId=#{view_id}&sprintId=#{sprint_id}\")\n\tresponse = http.request(request)\n\tJSON.parse(response.body)\nend", "def calendar\n get '/gtfs/calendar'\n end", "def index\n @best_of_days = BestOfDay.all\n end", "def get_days_with_fare(outbound=true)\n page = get_page(outbound)\n\n parse_page(page, find_cheap=true).merge(parse_page(page, find_cheap=false))\n end", "def set_black_friday\n @black_friday = BlackFriday.find(params[:id])\n end", "def show\n @dayoff = Dayoff.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @dayoff }\n end\n end", "def show\n @holiday = Holiday.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @holiday }\n end\n end", "def dates\n render json: @standings\n end", "def scheduled_fights_scraper\n BoxingSchedules::Scraper.scrape_scheduled_fights\n end", "def show\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @holiday }\n end\n end", "def update\n respond_to do |format|\n if @black_friday.update(black_friday_params)\n format.html { redirect_to @black_friday, notice: 'Black friday was successfully updated.' }\n format.json { render :show, status: :ok, location: @black_friday }\n else\n format.html { render :edit }\n format.json { render json: @black_friday.errors, status: :unprocessable_entity }\n end\n end\n end", "def show\n respond_to do |format|\n format.html \n # format.json { render json: @day_availability }\n end\n end", "def show\n @daylight = Daylight.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @daylight }\n end\n end", "def calendar_exceptions\n get '/gtfs/calendarDate'\n end", "def index\n @workout_days = WorkoutDay.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @workout_days }\n end\n end", "def index\n @day_availabilities = DayAvailability.all\n\n respond_to do |format|\n format.html {redirect_to @day_availabilities.week_availability}\n # format.json { render json: @day_availability }\n end\n end", "def index\n @monthly_finances = MonthlyFinance.all\n # respond_to do |format|\n # format.html # index.html.erb\n # format.json { render json: @monthly_finances }\n # end\n end", "def day_booking\n @zones_books = RestaurantManage.get_day_books(@restaurant.id, params[:special_day])\n @select_date = params[:special_day]\n\n render 'restaurant_manage/_day_booking', :layout => false\n #render json: {:success => true, :attachmentPartial => render_to_string('restaurant_manage/_day_booking', :layout => false) }\n end", "def show\n @weekday = Weekday.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @weekday }\n end\n end", "def index\n @holidays = Holiday.all.where(\"day > ?\", Time.now).order(:day)\n end", "def new\n @closing_day = ClosingDay.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @closing_day }\n end\n end", "def pebble\n provider = Account.find(params[:provider_id])\n\n dates = EventDate.where(\"datetime>:now AND stage_id IN (:stage_id)\", {\n :now => (Time.now + 2.hours),\n :stage_id => provider.user.stages.map(&:id)\n }).order(:datetime).limit(2)\n \n output = {}\n dates.each do |date| \n output[output.count] = ActiveSupport::Inflector.transliterate(date.event.title.slice(0,20))\n output[output.count] = date.datetime.strftime(\"%H:%M\") + \" \" + ActiveSupport::Inflector.transliterate(date.event.stage.name.gsub(/[a-z]|\\s/,''))\n end\n \n render json: output\n \n rescue ActiveRecord::RecordNotFound\n render json: {}\n end", "def show\n #@calendar_guess = CalendarGuess.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @calendar_guess }\n end\n end", "def weather\n # empty array dates is still fine, not a reason for 400 (happens for venues without courts)\n render json: {} and return if params.dig(:dates).blank?\n\n forecast = WeatherForecaster.call(venue, [*params.require(:dates)])\n json = forecast.transform_values do |value|\n value ? value.slice(*%w(icon temperature)) : nil\n end\n render json: json\n end", "def index\n @sundays = Sunday.all\n end", "def get(days,start_cep,end_cep)\n self.class.get(\"/api/v1/quote/available_scheduling_dates/#{days}/#{start_cep}/#{end_cep}\")\n end", "def dayIndex\n render json: Restaurant.restaurantsDay\n end", "def new\n @holiday = Holiday.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @holiday }\n end\n end", "def index\n @day_weeks = DayWeek.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @day_weeks }\n end\n end", "def index\n @special_holidays = SpecialHoliday.all\n end", "def new\n @dayoff = Dayoff.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @dayoff }\n end\n end", "def index\n @sightings = Sighting.where(date: params[:start_date]..params[:end_date])\n render json: @sightings\n end", "def show\n @plan = Plan.find(params[:id])\n @plan_days = @plan.plan_days\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @plan }\n end\n end", "def fishing_ground_businesses\n @current_resource.body.resources[:\"fishing-ground-businesses\"].map(&:symbolize_keys)\n end", "def index\n # @weekdays = Weekday.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: Oj.dump(@weekdays, mode: :compat) }\n end\n end", "def index\n @days = @trip.days.order(trip_day: :asc)\n render json: @days, include: [:activities]\n end", "def index\n @snowfalls = Snowfall.all\n end", "def index\n @flights = Flight.all\n render json: @flights\n end", "def new\n @daylight = Daylight.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @daylight }\n end\n end", "def index\n if params[:date]\n redirect_date(params[:date])\n else\n @school_days = SchoolDay.all\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @school_days }\n end\n end\n end", "def index\n session[:admin] = true\n @badges = Badge.order('approved_at desc,id')\n @fri_count = Badge.select { |b| b.friday? }.size\n @sat_count = Badge.select { |b| b.saturday? }.size\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @badges }\n end\n end", "def index\n @gamedays = Gameday.all\n end", "def index\n @current_user = current_user\n if @current_user.nil? || !@current_user.is_admin\n redirect_to root_url\n return\n end\n\n # TODO show dates in user's time zone\n @nfl_games = NflSchedule.includes(:home_nfl_team)\n .includes(:away_nfl_team)\n .order(:week)\n .order(:start_time)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @nfl_games }\n end\n end", "def index\n\t\t@holidays = Holiday.all.order(\"created_at DESC\")\n\tend", "def index\n if params[:all]\n @today = Time.now.strftime(\"%A\")\n @yoga_sessions = YogaSession.all\n elsif params[:day]\n @today = params[:day].capitalize\n @yoga_sessions = YogaSession.on_day params[:day]\n else\n @today = \"Today\"\n @yoga_sessions = YogaSession.today.remaining\n end \n respond_with @yoga_sessions\n end", "def show\n # render json: @birthday_party\n end", "def show\n @bday = Bday.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @bday }\n end\n end", "def show\n @holidaytype = Holidaytype.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @holidaytype }\n end\n end", "def flights\n result = Search.search_flights(params)\n if result\n # The search gave us something so we can return it\n render json: result\n else\n # Something went wrong, return a 500 error with no body\n render status: 500, json: nil\n end\n end", "def index\n @flaws = Flaw.order(\"date DESC, created_at DESC\").page( params[:page] ).per(10)\n \n @flaw = Flaw.new\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @flaws }\n end\n end", "def index\n meals = json_decode(RestClient::Resource.new(BASE_URL).get({:accept => :json}).body)\n\n styled_array(meals.map do |meal|\n [(meal['today'] ? '*' : ''), day_of_week(meal['date']), meal['summary']]\n end, :sort => false)\n end", "def retrieve_rates(date)\n path = \"http://openexchangerates.org/api/historical/#{date.to_s}.json?app_id=#{$app_id}\"\n response = Net::HTTP.get_response(URI.parse path)\n # TODO: error handling\n response.body\nend", "def show\n @time_sheet = TimeSheet.find(params[:id])\n @holidays = Holiday.where(:month => Date.today.strftime(\"%m\"),:year =>Date.today.strftime(\"%Y\"))\n\n respond_to do |format|\n format.html # show.html.erb\n format.js {}\n end\n end", "def new\n @weekday = Weekday.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @weekday }\n end\n end", "def flights(params={})\n perform_get('/flights.xml', params)\n end", "def show\n @day_list = DayList.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @day_list }\n end\n end", "def index\n if params[:company]\n @holiday = Holiday.new(:project_id => nil)\n set_content_title([t(\"screens.labels.company_calendar\")])\n @days_enable = can? :update_company_calendar, @holiday\n @dates_creation = can? :create_company_calendar, @holiday\n @holidays = Holiday.company_holidays\n @days_off = DayOff.company_days_off\n @holiday.company = true\n @days_off_for_fullcalendar = DayOff.calendar_wday_classes()\n else\n @holiday = Holiday.new(:project_id => actual_project.id)\n set_content_title([t(\"screens.labels.project_calendar\")])\n @days_enable = can? :update_project_calendar, @holiday\n @dates_creation = can? :create_project_calendar, @holiday\n @holidays = actual_project.holidays.order(\"day\")\n @days_off = actual_project.get_days_off\n @days_off_for_fullcalendar = DayOff.calendar_wday_classes(actual_project)\n end\n\n\n @holidays_for_fullcalendar = @holidays.map(&:milis_from_1970).join(', ')\n #@holidays_for_fullcalendar = \"1335852000000, 1337148000000, 1337234400000\"\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @holidays }\n end\n end", "def late_arrival_fees\n path = \"CheckInOut.LateArrivalFees.LateArrivalFee\"\n get_fees_by_path(path)\n end", "def index\n @day_crew_blocks = DayCrewBlock.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @day_crew_blocks }\n end\n end", "def index\n @wednesdays = Wednesday.all\n end", "def show\n respond_to do |format|\n format.html { }\n format.json {\n render :json => @week, :methods => [:monday, :tuesday, :wednesday, :friday, :thursday, :saturday, :sunday, :image ] }\n end\n end", "def state_events(state)\n api_return = RestClient.get('https://app.ticketmaster.com/discovery/v2/events.json?stateCode=' + state + '&apikey=' + $ticket_master_api_key)\n JSON.parse(api_return)\nend", "def new\n @week_availability = WeekAvailability.find(params[:week_availability_id])\n @day_availability = DayAvailability.new\n\n respond_to do |format|\n format.html # new.html.erb\n # format.json { render json: @day_availability }\n end\n end", "def index\n @fines = Fine.all\n end", "def friday\n day(:friday)\n end", "def index\n @thursdays = Thursday.all\n end", "def index\n @gifdays = Gifday.all\n \n end", "def get_surf_data\n url = \"http://magicseaweed.com/api/#{ENV['MAGIC_SEAWEED_API_KEY']}/forecast/?spot_id=6128&units=UK\"\n uri = URI(url)\n\n response = Net::HTTP.get(uri)\n ActiveSupport::JSON.decode(response) if response != ''\n end", "def create\n @friday = Friday.new(friday_params)\n\n respond_to do |format|\n if @friday.save\n format.html { redirect_to @friday, notice: \"Friday was successfully created.\" }\n format.json { render :show, status: :created, location: @friday }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @friday.errors, status: :unprocessable_entity }\n end\n end\n end", "def show\n @flight_schedule = FlightSchedule.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @flight_schedule }\n end\n end", "def index \n db_date_format = \"%Y-%m-%d\"\n\n if params[:from_date_picker].nil?\n session[:from_date_picker] ||= (Date.today - 7).strftime(db_date_format)\n session[:to_date_picker] ||= Date.today.strftime(db_date_format)\n\n params[:from_date_picker] = session[:from_date_picker]\n params[:to_date_picker] = session[:to_date_picker]\n end \n \n session[:from_date_picker] = params[:from_date_picker]\n session[:to_date_picker] = params[:to_date_picker]\n\n @stay_nights = StayNight.where([\"today >= ? and today <= ?\", params[:from_date_picker], params[:to_date_picker]]).order(today: :asc)\n @stay_night = StayNight.new\n\n end", "def show\n @dailyStanding = DailyStanding.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @dailyStanding }\n end\n end", "def index\n @activity_holidays = ActivityHoliday.all\n end", "def days\n @trainings = Training.all\n @activities = Activity.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @trainings }\n end\n end", "def index\n @essays = Essay.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @essays }\n end\n end", "def find\n days = Day.where(fulldate: Date.parse(params[:startdate])..Date.parse(params[:enddate]))\n sorted_days = days.sort_by{ |day| day.fulldate }\n render json: sorted_days\n end", "def index\n @time_of_days = TimeOfDay.all\n end", "def business_days\n @business_days ||= days.select(&:business_day?)\n end", "def show\n @flat_happening = FlatHappening.find(params[:id])\n\n render json: @flat_happening\n end", "def show\n @restaurant = Restaurant.find(params[:id])\n @show_cat = @restaurant.categories.collect {|cat| cat.category}\n @rest_days_open = @restaurant.restaurant_hours.map {|h| Date::ABBR_DAYNAMES[h.day - 6]}\n @rest_time_open = @restaurant.restaurant_hours.map {|h| h.open}\n @rest_time_closed = @restaurant.restaurant_hours.map {|h| h.close}\n end", "def index\n @federal_states = FederalState.all\n end", "def index\n @everydays = Everyday.all\n end", "def showListPendingPays\n puts @current_user\n results = HTTParty.get(\"http://192.168.99.101:4055/lists/by_user?user_id=\"+(@current_user[\"id\"]).to_s)\n if results.code == 200\n render json: results.parsed_response, status: 200\n else\n render json: results.parsed_response, status: results.code\n end\n end", "def index\n @lates = Late.where(date: Date.today)\n @leaves = Leave.where(\"(start_date <= :date AND end_date >= :date) or start_date = :date\", date: Date.today)\n @schedules = Schedule.over_dates(Date.today, Date.today)\n @schedules = @schedules.where(\"user_id NOT IN (?)\", @leaves.select(\"user_id\").where(\"hours IS NULL OR hours >=8\").group(:user_id).map(&:user_id)) unless @leaves.blank?\n @holidays = Holiday.where(\"(start_date <= :date AND end_date >= :date) OR start_date = :date\", date: Date.today)\n\n respond_with(@schedules, @lates, @leaves, @holidays)\n end", "def flights\n trip = Trip.where('id = ?', params[:id]).take\n if !trip.nil\n respond_with( trip.flights )\n else\n render :json => { error: 404 }, :status => 404\n end\n end", "def index\n @beefs = Beef.all\n end", "def emergencias_en_curso\n @emergencies = Emergency.where(:estado => 'f')\n render json: @emergencies\n end", "def index\n @fights = Fight.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @fights.to_json( :include => { :field_initial => { :only => [:name] }, :field_actual => { :only => [:name] }, :category => { :only => [:name] }, :competitor_blue => { :only => [:last_name, :lot_number] }, :competitor_red => { :only => [:last_name, :lot_number] }, :competitor_winner => { :only => [:last_name, :lot_number] }, :previous_fight_blue => { :only => [:id, :number], :include => { :field_initial => { :only => [:name] } } }, :previous_fight_red => { :only => [:id, :number], :include => { :field_initial => { :only => [:name] } } } } ) }\n end\n end", "def index\n @forecast_72s = Forecast72.all\n end", "def index\n @reserved_dates = ReservedDate.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @reserved_dates }\n end\n end", "def weekIndex\n render json: Restaurant.restaurantsWeek\n end", "def index\n @sightings = Sighting.all\n render json: @sightings\n end", "def upcoming_bills(options = {})\n get('/upcoming_bills', options)\n end", "def show\n @work_day = WorkDay.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @work_day }\n end\n end", "def show\n @daytime = Daytime.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @daytime }\n end\n end" ]
[ "0.63019675", "0.57668734", "0.57145727", "0.57114524", "0.5696606", "0.5683033", "0.56441444", "0.564085", "0.5618594", "0.56143415", "0.5519595", "0.550131", "0.54865074", "0.54823333", "0.54411155", "0.5439421", "0.54295236", "0.5393427", "0.5368539", "0.53629714", "0.5327023", "0.5323404", "0.5321669", "0.5314841", "0.53052354", "0.5290491", "0.52813923", "0.52733505", "0.5254283", "0.52323633", "0.5223423", "0.5190671", "0.5190607", "0.51858664", "0.5174", "0.51739204", "0.5172956", "0.51691705", "0.516898", "0.5165887", "0.5156028", "0.5153436", "0.5152667", "0.5146136", "0.5146058", "0.51446843", "0.51326245", "0.51290596", "0.51241285", "0.51228213", "0.51226836", "0.5118607", "0.51144135", "0.5104818", "0.51028985", "0.5097304", "0.5089194", "0.50856596", "0.5083056", "0.50827557", "0.50762254", "0.507583", "0.5065277", "0.50616926", "0.50613564", "0.5056018", "0.50510675", "0.50366414", "0.5030789", "0.50192374", "0.5018366", "0.5007506", "0.499663", "0.49923396", "0.4988886", "0.49874544", "0.4979056", "0.497899", "0.49759966", "0.4974623", "0.49723926", "0.49708676", "0.49706683", "0.49656364", "0.49524158", "0.49507394", "0.49497107", "0.49486798", "0.4946897", "0.49422678", "0.49375474", "0.4937403", "0.49345332", "0.4933222", "0.49301085", "0.49290535", "0.49287245", "0.49243608", "0.4923368", "0.492179" ]
0.64573187
0
GET /black_fridays/1 GET /black_fridays/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @fridays = Friday.all\n end", "def index\n @black_fridays = BlackFriday.paginate(:page => params[:page], :per_page => 10)\n end", "def show\n @closing_day = ClosingDay.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @closing_day }\n end\n end", "def index\r\n @classdays = Classday.all\r\n\r\n render json: @classdays\r\n end", "def show\n @dayoff = Dayoff.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @dayoff }\n end\n end", "def index\n @holidays = Holiday.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @holidays }\n end\n end", "def show\n @holiday = Holiday.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @holiday }\n end\n end", "def create\n @black_friday = BlackFriday.new(black_friday_params)\n\n respond_to do |format|\n if @black_friday.save\n format.html { redirect_to @black_friday, notice: 'Black friday was successfully created.' }\n format.json { render :show, status: :created, location: @black_friday }\n else\n format.html { render :new }\n format.json { render json: @black_friday.errors, status: :unprocessable_entity }\n end\n end\n end", "def show\n @weekday = Weekday.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @weekday }\n end\n end", "def show\n @daylight = Daylight.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @daylight }\n end\n end", "def show\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @holiday }\n end\n end", "def set_black_friday\n @black_friday = BlackFriday.find(params[:id])\n end", "def show\n respond_to do |format|\n format.html \n # format.json { render json: @day_availability }\n end\n end", "def dayIndex\n render json: Restaurant.restaurantsDay\n end", "def index\n @best_of_days = BestOfDay.all\n end", "def new\n @closing_day = ClosingDay.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @closing_day }\n end\n end", "def show\n @holidaytype = Holidaytype.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @holidaytype }\n end\n end", "def new\n @holiday = Holiday.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @holiday }\n end\n end", "def show\n #@calendar_guess = CalendarGuess.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @calendar_guess }\n end\n end", "def new\n @dayoff = Dayoff.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @dayoff }\n end\n end", "def get_remaining_days(view_id, sprint_id)\n\thttp = create_http\n\trequest = create_request(\"/rest/greenhopper/1.0/gadgets/sprints/remainingdays?rapidViewId=#{view_id}&sprintId=#{sprint_id}\")\n\tresponse = http.request(request)\n\tJSON.parse(response.body)\nend", "def index\n @monthly_finances = MonthlyFinance.all\n # respond_to do |format|\n # format.html # index.html.erb\n # format.json { render json: @monthly_finances }\n # end\n end", "def show\n @plan = Plan.find(params[:id])\n @plan_days = @plan.plan_days\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @plan }\n end\n end", "def new\n @weekday = Weekday.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @weekday }\n end\n end", "def index\n @flights = Flight.all\n render json: @flights\n end", "def index\n @workout_days = WorkoutDay.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @workout_days }\n end\n end", "def update\n respond_to do |format|\n if @black_friday.update(black_friday_params)\n format.html { redirect_to @black_friday, notice: 'Black friday was successfully updated.' }\n format.json { render :show, status: :ok, location: @black_friday }\n else\n format.html { render :edit }\n format.json { render json: @black_friday.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @flaws = Flaw.order(\"date DESC, created_at DESC\").page( params[:page] ).per(10)\n \n @flaw = Flaw.new\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @flaws }\n end\n end", "def index\n # @weekdays = Weekday.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: Oj.dump(@weekdays, mode: :compat) }\n end\n end", "def calendar\n get '/gtfs/calendar'\n end", "def dates\n render json: @standings\n end", "def new\n @daylight = Daylight.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @daylight }\n end\n end", "def show\n @flat_happening = FlatHappening.find(params[:id])\n\n render json: @flat_happening\n end", "def pebble\n provider = Account.find(params[:provider_id])\n\n dates = EventDate.where(\"datetime>:now AND stage_id IN (:stage_id)\", {\n :now => (Time.now + 2.hours),\n :stage_id => provider.user.stages.map(&:id)\n }).order(:datetime).limit(2)\n \n output = {}\n dates.each do |date| \n output[output.count] = ActiveSupport::Inflector.transliterate(date.event.title.slice(0,20))\n output[output.count] = date.datetime.strftime(\"%H:%M\") + \" \" + ActiveSupport::Inflector.transliterate(date.event.stage.name.gsub(/[a-z]|\\s/,''))\n end\n \n render json: output\n \n rescue ActiveRecord::RecordNotFound\n render json: {}\n end", "def show\n @day_list = DayList.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @day_list }\n end\n end", "def index\n @days = @trip.days.order(trip_day: :asc)\n render json: @days, include: [:activities]\n end", "def index\n @day_availabilities = DayAvailability.all\n\n respond_to do |format|\n format.html {redirect_to @day_availabilities.week_availability}\n # format.json { render json: @day_availability }\n end\n end", "def show\n @flight_schedule = FlightSchedule.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @flight_schedule }\n end\n end", "def index\n @day_weeks = DayWeek.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @day_weeks }\n end\n end", "def show\n @forecast = Forecast.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @forecast }\n end\n end", "def index\n session[:admin] = true\n @badges = Badge.order('approved_at desc,id')\n @fri_count = Badge.select { |b| b.friday? }.size\n @sat_count = Badge.select { |b| b.saturday? }.size\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @badges }\n end\n end", "def show\n @daytime = Daytime.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @daytime }\n end\n end", "def show\n @bday = Bday.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @bday }\n end\n end", "def show\n @dailyStanding = DailyStanding.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @dailyStanding }\n end\n end", "def show\n # render json: @birthday_party\n end", "def retrieve_rates(date)\n path = \"http://openexchangerates.org/api/historical/#{date.to_s}.json?app_id=#{$app_id}\"\n response = Net::HTTP.get_response(URI.parse path)\n # TODO: error handling\n response.body\nend", "def index\n @essays = Essay.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @essays }\n end\n end", "def show\n respond_to do |format|\n format.html { }\n format.json {\n render :json => @week, :methods => [:monday, :tuesday, :wednesday, :friday, :thursday, :saturday, :sunday, :image ] }\n end\n end", "def show\n @work_day = WorkDay.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @work_day }\n end\n end", "def flights\n trip = Trip.where('id = ?', params[:id]).take\n if !trip.nil\n respond_with( trip.flights )\n else\n render :json => { error: 404 }, :status => 404\n end\n end", "def weekIndex\n render json: Restaurant.restaurantsWeek\n end", "def index\n if params[:date]\n redirect_date(params[:date])\n else\n @school_days = SchoolDay.all\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @school_days }\n end\n end\n end", "def show\n @day_week = DayWeek.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @day_week }\n end\n end", "def new\n @week_availability = WeekAvailability.find(params[:week_availability_id])\n @day_availability = DayAvailability.new\n\n respond_to do |format|\n format.html # new.html.erb\n # format.json { render json: @day_availability }\n end\n end", "def create\n @friday = Friday.new(friday_params)\n\n respond_to do |format|\n if @friday.save\n format.html { redirect_to @friday, notice: \"Friday was successfully created.\" }\n format.json { render :show, status: :created, location: @friday }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @friday.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n meals = json_decode(RestClient::Resource.new(BASE_URL).get({:accept => :json}).body)\n\n styled_array(meals.map do |meal|\n [(meal['today'] ? '*' : ''), day_of_week(meal['date']), meal['summary']]\n end, :sort => false)\n end", "def scheduled_fights_scraper\n BoxingSchedules::Scraper.scrape_scheduled_fights\n end", "def show\n @monthly_finance = MonthlyFinance.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @monthly_finance }\n end\n end", "def show\n @belief = Belief.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @belief }\n end\n end", "def days\n @trainings = Training.all\n @activities = Activity.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @trainings }\n end\n end", "def index\n @snowfalls = Snowfall.all\n end", "def new\n @flight_schedule = FlightSchedule.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @flight_schedule }\n end\n end", "def index\n @sundays = Sunday.all\n end", "def show\n @flight = Flight.find(params[:id])\n render json: @flight\n end", "def index\n @fights = Fight.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @fights.to_json( :include => { :field_initial => { :only => [:name] }, :field_actual => { :only => [:name] }, :category => { :only => [:name] }, :competitor_blue => { :only => [:last_name, :lot_number] }, :competitor_red => { :only => [:last_name, :lot_number] }, :competitor_winner => { :only => [:last_name, :lot_number] }, :previous_fight_blue => { :only => [:id, :number], :include => { :field_initial => { :only => [:name] } } }, :previous_fight_red => { :only => [:id, :number], :include => { :field_initial => { :only => [:name] } } } } ) }\n end\n end", "def show\n @sale_day_total = SaleDayTotal.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @sale_day_total }\n end\n end", "def show\n @days_since_visit = DaysSinceVisit.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @days_since_visit }\n end\n end", "def index\r\n @clocks = ClockResult.all\r\n\r\n respond_to do |format|\r\n format.html # index.html.erb\r\n format.json { render json: @clocks }\r\n end\r\n end", "def weather\n # empty array dates is still fine, not a reason for 400 (happens for venues without courts)\n render json: {} and return if params.dig(:dates).blank?\n\n forecast = WeatherForecaster.call(venue, [*params.require(:dates)])\n json = forecast.transform_values do |value|\n value ? value.slice(*%w(icon temperature)) : nil\n end\n render json: json\n end", "def get_days_with_fare(outbound=true)\n page = get_page(outbound)\n\n parse_page(page, find_cheap=true).merge(parse_page(page, find_cheap=false))\n end", "def show\n @nightclub = Nightclub.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @nightclub }\n end\n end", "def index\n @fines = Fine.all\n end", "def day_booking\n @zones_books = RestaurantManage.get_day_books(@restaurant.id, params[:special_day])\n @select_date = params[:special_day]\n\n render 'restaurant_manage/_day_booking', :layout => false\n #render json: {:success => true, :attachmentPartial => render_to_string('restaurant_manage/_day_booking', :layout => false) }\n end", "def state_events(state)\n api_return = RestClient.get('https://app.ticketmaster.com/discovery/v2/events.json?stateCode=' + state + '&apikey=' + $ticket_master_api_key)\n JSON.parse(api_return)\nend", "def new\n @holidaytype = Holidaytype.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @holidaytype }\n end\n end", "def show\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @schedule, methods: :bookings }\n end\n end", "def show\n @daytype = Daytype.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @daytype }\n end\n end", "def show\n @fishing_method = FishingMethod.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @fishing_method }\n end\n end", "def index\n @gamedays = Gameday.all\n end", "def index\n @sightings = Sighting.all\n render json: @sightings\n end", "def show\n @basin = Basin.find(params[:id])\n\n @client = YahooWeather::Client.new \n @response = @client.fetch_by_location('Massingir, Gaza, Mz','c')\n @reponse2 = @client.fetch_by_location('Louis Trichardt, Limpopo, South Africa','c')\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @basin }\n\n end\n end", "def index\n @funds = Fund.all\n\n render json: @funds\n end", "def index\n @sightings = Sighting.where(date: params[:start_date]..params[:end_date])\n render json: @sightings\n end", "def show\n #@day = Day.find_by_user_id(current_user)\n @day = Day.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @day }\n end\n end", "def flights(params={})\n perform_get('/flights.xml', params)\n end", "def index\n @day_crew_blocks = DayCrewBlock.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @day_crew_blocks }\n end\n end", "def index\n @fretes = Frete.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @fretes }\n end\n end", "def show\n @financial = Financial.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @financial }\n end\n end", "def index\n @forecast_wsizes = ForecastWsize.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @forecast_wsizes }\n end\n end", "def index\n @gifdays = Gifday.all\n \n end", "def show\n render json: @day, include: [:activities]\n end", "def show\n @federal1870_census_entry = Federal1870CensusEntry.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @federal1870_census_entry }\n end\n end", "def index\n @holidays = Holiday.all.where(\"day > ?\", Time.now).order(:day)\n end", "def index\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @financials }\n end\n end", "def index\n @weddings = Wedding.all\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @weddings }\n end\n end", "def index\n @lunchplans = Lunchplan.all\n\t@lunchplans_by_date = @lunchplans.group_by(&:day)\n\t@date = params[:date] ? Date.parse(params[:date]) : Date.today\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @lunchplans }\n end\n end", "def new\n @butterfly = Butterfly.new\n @butterflies = Butterfly.all\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @butterfly }\n end\n end", "def index\n @forecast_72s = Forecast72.all\n end", "def flights\n result = Search.search_flights(params)\n if result\n # The search gave us something so we can return it\n render json: result\n else\n # Something went wrong, return a 500 error with no body\n render status: 500, json: nil\n end\n end", "def index\n @beefs = Beef.all\n end", "def index\n\t\t@flights = Flight.all\n\n\t\trespond_to do |format|\n\t\t\tformat.html # index.html.erb\n\t\t\tformat.json { render json: @flights }\n\t\tend\n\tend" ]
[ "0.63799", "0.6347761", "0.6135369", "0.6039325", "0.59884185", "0.59607416", "0.59281063", "0.58689964", "0.5863545", "0.5834585", "0.5786008", "0.5695188", "0.56912804", "0.56861067", "0.56544393", "0.56332445", "0.56255835", "0.5618451", "0.5614231", "0.5608541", "0.5607243", "0.56018734", "0.5587301", "0.5584572", "0.5582177", "0.5569897", "0.555466", "0.55538267", "0.5549511", "0.55493945", "0.5537456", "0.55316734", "0.55140615", "0.5506905", "0.5502359", "0.5497463", "0.54859763", "0.54819536", "0.5474443", "0.5466811", "0.5454455", "0.54537594", "0.544692", "0.54410356", "0.5438081", "0.54364246", "0.5425015", "0.5402069", "0.5400439", "0.5395315", "0.5388812", "0.5384781", "0.53808814", "0.5376624", "0.53665984", "0.5364638", "0.53582114", "0.53501195", "0.53355646", "0.5323905", "0.53176636", "0.5316675", "0.5308207", "0.53080225", "0.5303992", "0.53031445", "0.5300327", "0.52878916", "0.528583", "0.52858", "0.5276714", "0.52745926", "0.52716434", "0.52677923", "0.52585614", "0.5257586", "0.5249134", "0.5244924", "0.5243592", "0.52393436", "0.52366805", "0.52363235", "0.5235625", "0.5232888", "0.5232881", "0.52321", "0.5227324", "0.5220967", "0.52178466", "0.52172583", "0.52171576", "0.5216418", "0.52149576", "0.5214749", "0.52109", "0.52024007", "0.51996577", "0.5199221", "0.5198504", "0.5196472", "0.5194936" ]
0.0
-1
POST /black_fridays POST /black_fridays.json
def create @black_friday = BlackFriday.new(black_friday_params) respond_to do |format| if @black_friday.save format.html { redirect_to @black_friday, notice: 'Black friday was successfully created.' } format.json { render :show, status: :created, location: @black_friday } else format.html { render :new } format.json { render json: @black_friday.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @friday = Friday.new(friday_params)\n\n respond_to do |format|\n if @friday.save\n format.html { redirect_to @friday, notice: \"Friday was successfully created.\" }\n format.json { render :show, status: :created, location: @friday }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @friday.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @closing_day = ClosingDay.new(params[:closing_day])\n\n respond_to do |format|\n if @closing_day.save\n format.html { redirect_to @closing_day, notice: 'Closing day was successfully created.' }\n format.json { render json: @closing_day, status: :created, location: @closing_day }\n else\n format.html { render action: \"new\" }\n format.json { render json: @closing_day.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @dayoff = Dayoff.new(params[:dayoff])\n\n respond_to do |format|\n if @dayoff.save\n format.html { redirect_to @dayoff, notice: 'Dayoff was successfully created.' }\n format.json { render json: @dayoff, status: :created, location: @dayoff }\n else\n format.html { render action: \"new\" }\n format.json { render json: @dayoff.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @weekday = Weekday.new(params[:weekday])\n\n respond_to do |format|\n if @weekday.save\n format.html { redirect_to @weekday, notice: 'Weekday was successfully created.' }\n format.json { render json: @weekday, status: :created, location: @weekday }\n else\n format.html { render action: \"new\" }\n format.json { render json: @weekday.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @sunday = Sunday.new(sunday_params)\n\n respond_to do |format|\n if @sunday.save\n format.html { redirect_to @sunday, notice: 'Sunday was successfully created.' }\n format.json { render :show, status: :created, location: @sunday }\n else\n format.html { render :new }\n format.json { render json: @sunday.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @black_friday.update(black_friday_params)\n format.html { redirect_to @black_friday, notice: 'Black friday was successfully updated.' }\n format.json { render :show, status: :ok, location: @black_friday }\n else\n format.html { render :edit }\n format.json { render json: @black_friday.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @off_day = OffDay.new(off_day_params)\n\n respond_to do |format|\n if @off_day.save\n format.html { redirect_to @off_day, notice: 'Off day was successfully created.' }\n format.json { render :show, status: :created, location: @off_day }\n else\n format.html { render :new }\n format.json { render json: @off_day.errors, status: :unprocessable_entity }\n end\n end\n end", "def black_friday_params\n params.require(:black_friday).permit(:user_id, :product_id, :gender, :age, :occupation, :city_category, :stay_in_current_city_years, :marital_status, :product_category_1, :product_category_2, :product_category_3, :purchase)\n end", "def create\n busy_shifts = params[:busy_shift]\n if busy_shifts\n busy_shifts[:day].length.times do |index|\n day = busy_shifts[:day][index]\n start_time = busy_shifts[:start_time][index]\n end_time = busy_shifts[:end_time][index]\n @busy_shifts = current_user.busy_shifts.create(:day => day, :start_time => start_time, :end_time => end_time)\n end\n render json: current_user.busy_shifts\n else\n render json: {errors: \"Could not create busy shifts there was a error\"}\n end\n end", "def create\n @snowfall = Snowfall.new(snowfall_params)\n\n respond_to do |format|\n if @snowfall.save\n format.html { redirect_to @snowfall, notice: 'Snowfall was successfully created.' }\n format.json { render :show, status: :created, location: @snowfall }\n else\n format.html { render :new }\n format.json { render json: @snowfall.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @bday = Bday.new(params[:bday])\n\n respond_to do |format|\n if @bday.save\n format.html { redirect_to(@bday, :notice => 'Bday was successfully created.') }\n format.xml { render :xml => @bday, :status => :created, :location => @bday }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @bday.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @everyday = Everyday.new(everyday_params)\n\n respond_to do |format|\n if @everyday.save\n format.html { redirect_to :back, notice: 'Everyday was successfully created.' }\n format.json { render :show, status: :created, location: :back }\n else\n format.html { render :new }\n format.json { render json: @everyday.errors, status: :unprocessable_entity }\n end\n end\n end", "def postEntityOpening_times( entity_id, monday, tuesday, wednesday, thursday, friday, saturday, sunday, closed, closed_public_holidays)\n params = Hash.new\n params['entity_id'] = entity_id\n params['monday'] = monday\n params['tuesday'] = tuesday\n params['wednesday'] = wednesday\n params['thursday'] = thursday\n params['friday'] = friday\n params['saturday'] = saturday\n params['sunday'] = sunday\n params['closed'] = closed\n params['closed_public_holidays'] = closed_public_holidays\n return doCurl(\"post\",\"/entity/opening_times\",params)\n end", "def create\n @user_day = UserDay.new(params[:user_day])\n\n today = Date.today\n #TODO this should be a selected year\n holiday_year = HolidayYear.where('date_start<=? and date_end>=?', today, today).first\n @user_day.holiday_year = holiday_year\n\n @allowance = @user_day.user.get_holiday_allowance\n @allowance.days_remaining += @user_day.no_days\n\n respond_to do |format|\n if @user_day.save and @allowance.save\n format.js\n else\n format.js\n end\n end\n end", "def create\n @week_day = WeekDay.new(week_day_params)\n\n respond_to do |format|\n if @week_day.save\n format.html { redirect_to @week_day, notice: 'Week day was successfully created.' }\n format.json { render :show, status: :created, location: @week_day }\n else\n format.html { render :new }\n format.json { render json: @week_day.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @day_of_week = DayOfWeek.new(day_of_week_params)\n\n respond_to do |format|\n if @day_of_week.save\n format.html { redirect_to @day_of_week, notice: 'Day of week was successfully created.' }\n format.json { render :show, status: :created, location: @day_of_week }\n else\n format.html { render :new }\n format.json { render json: @day_of_week.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @wednesday = Wednesday.new(wednesday_params)\n\n respond_to do |format|\n if @wednesday.save\n format.html { redirect_to @wednesday, notice: \"Wednesday was successfully created.\" }\n format.json { render :show, status: :created, location: @wednesday }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @wednesday.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @special_holiday = SpecialHoliday.new(special_holiday_params)\n\n respond_to do |format|\n if @special_holiday.save\n format.html { redirect_to @special_holiday, notice: 'Special holiday was successfully created.' }\n format.json { render :show, status: :created, location: @special_holiday }\n else\n format.html { render :new }\n format.json { render json: @special_holiday.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @day ||= Weekday.day\n @days ||= Weekday.days\n @batch = Weekday.set_day(params[:weekday][:batch_id], params[:weekdays])\n flash[:notice] = t('weekday_create')\n end", "def create\n @fine = Fine.new(fine_params.merge(:amount => 5, :date => Time.now, :status => \"Pending\"))\n # raise fine_params.to_yaml\n\n if @fine.save\n redirect_to fines_url\n else\n render action: 'new'\n end\n end", "def create\n @gameday = Gameday.new(gameday_params)\n\n respond_to do |format|\n if @gameday.save\n format.html { redirect_to gamedays_path, notice: 'Gameday was successfully created.' }\n format.json { render :show, status: :created, location: @gameday }\n else\n format.html { render :new }\n format.json { render json: @gameday.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @day_week = DayWeek.new(params[:day_week])\n\n respond_to do |format|\n if @day_week.save\n format.html { redirect_to @day_week, :notice => 'Dia da semana criado com sucesso.' }\n format.json { render :json => @day_week, :status => :created, :location => @day_week }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @day_week.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @daylight = Daylight.new(daylight_params)\n\n respond_to do |format|\n if @daylight.save\n format.html { redirect_to @daylight, notice: 'Daylight was successfully created.' }\n format.json { render json: @daylight, status: :created, location: @daylight }\n else\n format.html { render action: \"new\" }\n format.json { render json: @daylight.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @fridays = Friday.all\n end", "def create\n user = current_user\n @work_day = user.work_days.create(params[:work_day]) \n\n respond_to do |format|\n if @work_day.save\n flash[:notice] = 'Giornata di lavoro salvata con successo.'\n format.html { redirect_to action: 'index' }\n format.json { render json: @work_day, status: :created, location: @work_day }\n else\n format.html { render action: \"new\" }\n format.json { render json: @work_day.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @weekday_constraint = WeekdayConstraint.new(weekday_constraint_params)\n\n respond_to do |format|\n if @weekday_constraint.save\n format.html { redirect_to @weekday_constraint, notice: 'Weekday constraint was successfully created.' }\n format.json { render :show, status: :created, location: @weekday_constraint }\n else\n format.html { render :new }\n format.json { render json: @weekday_constraint.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @friday.update(friday_params)\n format.html { redirect_to @friday, notice: \"Friday was successfully updated.\" }\n format.json { render :show, status: :ok, location: @friday }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @friday.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_black_friday\n @black_friday = BlackFriday.find(params[:id])\n end", "def create\n @holiday_date = HolidayDate.new(holiday_date_params)\n\n respond_to do |format|\n if @holiday_date.save\n format.html { redirect_to @holiday_date, notice: 'Holiday date was successfully created.' }\n format.json { render :show, status: :created, location: @holiday_date }\n else\n format.html { render :new }\n format.json { render json: @holiday_date.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @holiday = current_user.holidays.build(params[:holiday])\n\n respond_to do |format|\n if @holiday.save\n format.html { redirect_to @holiday, notice: 'El Feriado fue creado en forma satisfactoria.' }\n format.json { render json: @holiday, status: :created, location: @holiday }\n else\n format.html { render action: \"new\" }\n format.json { render json: @holiday.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @birthday = current_user.birthdays.new(birthday_params)\n\n respond_to do |format|\n if @birthday.save\n format.html { redirect_to pages_home_url, notice: \"Birthday was successfully created.\" }\n format.json { render :show, status: :created, location: @birthday }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @birthday.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @closing_day = ClosingDay.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @closing_day }\n end\n end", "def create\n \n\tdays = params[:day]\n\tsaved = true\n \n\tdays.each do |d|\n\t\t@shift = Shift.new(params[:shift])\n\t\t@shift.business_id = current_user.id\n\t\t@shift.day = d[0]\n\n\t if !@shift.save\n\t\tsaved = false\n\t end\n\tend\n\t\n\trespond_to do |format|\n\t\tif saved\n\t\t\tformat.html { redirect_to shifts_path, notice: 'Shift was successfully created.' }\n\t\t\tformat.json { render json: shifts_path, status: :created, location: @shift }\n\t\telse\n\t\t\tformat.html { render action: \"new\" }\n\t\t\tformat.json { render json: @shift.errors, status: :unprocessable_entity }\n\t\tend\n\tend\n\t\n end", "def create\n days = [\"Monday\", \"Tuesday\", \"Wednesday\", \"Thursday\", \"Friday\", \"Saturday\", \"Sunday\"]\n\n @user = current_user\n @user_location = @user.user_locations.find(params[:user_location_id])\n\n UserSchedule.transaction do\n \n days.each do |day|\n if params[day]\n @user_schedule = @user_location.user_schedules.build\n\n @user_schedule.to_standard = params[:to_standard] \n @user_schedule.from_standard = params[:from_standard] \n @user_schedule.day = day\n @user_schedule.save\n\n end\n end\n end\n\n respond_to :js\n\n end", "def create\n @day = Day.new(params[:day])\n\n respond_to do |format|\n if @day.save\n format.html { redirect_to @day, notice: 'Day was successfully created.' }\n format.json { render json: @day, status: :created, location: @day }\n else\n format.html { render action: \"new\" }\n format.json { render json: @day.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n attendance_params[:checkin] = attendance_params[:checkin].to_time\n attendance_params[:checkout] = attendance_params[:checkout].to_time\n attendance_params[:attendance_date] = attendance_params[:attendance_date].to_date\n\n r = @api.create_attendance(attendance_params)\n respond_to do |format|\n if r.code == 201\n format.html { redirect_to attendances_url, notice: 'Attendance was successfully created.' }\n else\n response = JSON.parse(r.body)\n format.html { redirect_to attendances_url, alert: response['message']}\n end\n end\n end", "def create\n @extra_holiday = ExtraHoliday.new(extra_holiday_params)\n\n respond_to do |format|\n if @extra_holiday.save\n format.html { redirect_to @extra_holiday, notice: 'Extra holiday was successfully created.' }\n format.json { render :show, status: :created, location: @extra_holiday }\n else\n format.html { render :new }\n format.json { render json: @extra_holiday.errors, status: :unprocessable_entity }\n end\n end\n end", "def holiday_params\n params.require(:holiday).permit(\n :base64,\n :location,\n :attractions,\n :when_to_go,\n :departureDate,\n :returnDate,\n :departureAirport,\n :arrivalAirport,\n :user_id,\n :group_id\n )\n end", "def create\n @hospitalization_day = @adverse_event.hospitalization_days.create(hospitalization_day_params)\n\n respond_to do |format|\n if @hospitalization_day.save\n format.html { redirect_to adverse_event_path(@adverse_event), notice: 'Día de estancia ingresado satisfactoriamente.' }\n format.json { render :show, status: :created, location: @hospitalization_day }\n else\n format.html { render :new }\n format.json { render json: @hospitalization_day.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @calendar_day = CalendarDay.new(calendar_day_params)\n\n respond_to do |format|\n if @calendar_day.save\n format.html { redirect_to @calendar_day, notice: 'Calendar day was successfully created.' }\n format.json { render :show, status: :created, location: @calendar_day }\n else\n format.html { render :new }\n format.json { render json: @calendar_day.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @dayoff = Dayoff.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @dayoff }\n end\n end", "def create\n @availability_day = AvailabilityDay.new(params[:availability_day])\n\n respond_to do |format|\n if @availability_day.save\n format.html { redirect_to(@availability_day, :notice => 'Availability day was successfully created.') }\n format.xml { render :xml => @availability_day, :status => :created, :location => @availability_day }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @availability_day.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @workday = Workday.new(workday_params)\n\n respond_to do |format|\n if @workday.save\n format.html { redirect_to dashboard_path, notice: 'Workday was successfully created.' }\n format.json { render :show, status: :created, location: @workday }\n else\n format.html { render :new }\n format.json { render json: @workday.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @fahrt = Fahrt.new(fahrt_params)\n\n respond_to do |format|\n if @fahrt.save\n format.html { redirect_to @fahrt, notice: 'Fahrt was successfully created.' }\n format.json { render :show, status: :created, location: @fahrt }\n else\n format.html { render :new }\n format.json { render json: @fahrt.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @event_day = EventDay.new(event_day_params)\n @event = Event.find(params[:event_id])\n\n respond_to do |format|\n if @event_day.save\n format.html { redirect_to @event, notice: 'Event day was successfully created.' }\n format.json { render :show, status: :created, location: @event_day }\n else\n format.html { render :new }\n format.json { render json: @event_day.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @holiday = Holiday.new(holiday_params)\n\n if @holiday.save\n flash[:success] = \"Feiertag angelegt.\"\n redirect_to @holiday\n else\n render :new \n end\n end", "def create\n @daily_happiness = DailyHappiness.new(daily_happiness_params)\n\n respond_to do |format|\n if @daily_happiness.save\n format.html { redirect_to @daily_happiness, notice: 'Daily happiness was successfully created.' }\n format.json { render :show, status: :created, location: @daily_happiness }\n else\n format.html { render :new }\n format.json { render json: @daily_happiness.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @weekday = Weekday.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @weekday }\n end\n end", "def create\n @fg_booking = FgBooking.new(fg_booking_params)\n\n respond_to do |format|\n if @fg_booking.save\n UserMailer.focus_group_time(current_user, @fg_booking).deliver_now\n format.html { redirect_to getting_started_welcome_path, notice: 'Booking was successfully created.' }\n format.json { render :show, status: :created, location: @fg_booking }\n else\n format.html { render :new }\n format.json { render json: @fg_booking.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @federal_state = FederalState.new(federal_state_params)\n\n respond_to do |format|\n if @federal_state.save\n format.html { redirect_to @federal_state, notice: 'Federal state was successfully created.' }\n format.json { render action: 'show', status: :created, location: @federal_state }\n else\n format.html { render action: 'new' }\n format.json { render json: @federal_state.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @dis_nfi_schedule = DisNfiSchedule.new(dis_nfi_schedule_params)\n\n respond_to do |format|\n if @dis_nfi_schedule.save\n format.html { redirect_to @dis_nfi_schedule, notice: 'Dis nfi schedule was successfully created.' }\n format.json { render :show, status: :created, location: @dis_nfi_schedule }\n else\n format.html { render :new }\n format.json { render json: @dis_nfi_schedule.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\r\n @group = Group.find(params[:group_id])\r\n\r\n if @group.update_attributes(classdays_params)\r\n @group.generate_calendar!\r\n render json: @group.classdays, status: :created\r\n else\r\n render json: @group.errors, status: :unprocessable_entity\r\n end\r\n end", "def create\n @workout_day = WorkoutDay.new(params[:workout_day])\n @workout_day.user_id = current_user.id\n\n respond_to do |format|\n if @workout_day.save\n format.html { redirect_to @workout_day, notice: 'Workout day was successfully created.' }\n format.json { render json: @workout_day, status: :created, location: @workout_day }\n else\n format.html { render action: \"new\" }\n format.json { render json: @workout_day.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @holiday = current_user.holidays.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @holiday }\n end\n end", "def create_day\n trip = Trip.find(params[:id])\n offset = 0\n trip.days.all.each do |day|\n offset += 1\n end\n @day = Day.new({\"date\" => trip.beginning + offset , \"trip\" => trip})\n trip.update_attribute(:duration, trip.attributes['duration'] + 1)\n trip.save\n respond_to do |format|\n if @day.save\n format.html { redirect_to trip, notice: 'Day was successfully created.' }\n format.json { render :show, status: :created, location: @day }\n else\n format.html { render home_path }\n format.json { render json: @day.errors, status: :unprocessable_entity }\n end\n end\n end", "def save_days_off\n if params[:company]\n days_off = DayOff.where(\"company = ?\", true)\n redirect = holidays_path(:company => true)\n day_hours = DayHour.first\n day_hours.hours = params[:day_hours]\n day_hours.save!\n else\n days_off = DayOff.where(\"project_id = ?\", session[:actual_project])\n redirect = holidays_path\n ap = actual_project\n ap.hours_day = params[:day_hours]\n ap.save!(:validate => false) #por las dudas le pongo que skip validations, no vaya a ser que de un error\n end\n days_off.each do |day|\n day.off = true\n case day.wday\n when 0: day.off = false unless params[:wday_domingo]\n when 1: day.off = false unless params[:wday_lunes]\n when 2: day.off = false unless params[:wday_martes]\n when 3: day.off = false unless params[:wday_miercoles]\n when 4: day.off = false unless params[:wday_jueves]\n when 5: day.off = false unless params[:wday_viernes]\n when 6: day.off = false unless params[:wday_sabado]\n end\n day.save!\n end\n redirect_to(redirect, :notice => t(\"screens.notice.successfully_created\"))\n end\n\nend", "def holiday_params\n params.require(:holiday).permit(:day, :name)\n end", "def create\n @user = current_user\n @baby = Baby.find(params[:baby_id])\n @day = Day.new(day_params)\n @day.baby_id = @baby.id\n @day.user_id = @user.id\n respond_to do |format|\n if @day.save\n @baby.days << @day\n @user.days << @day\n format.html { redirect_to baby_path(@baby), notice: 'Day was successfully created.' }\n # format.json { render :show, status: :created, location: @day }\n else\n format.html { render :new }\n # format.json { render json: @day.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @sgda_seller_goal_day = SgdaSellerGoalDay.new(sgda_seller_goal_day_params)\n\n respond_to do |format|\n if @sgda_seller_goal_day.save\n format.html { redirect_to @sgda_seller_goal_day, notice: 'Sgda seller goal day was successfully created.' }\n format.json { render :show, status: :created, location: @sgda_seller_goal_day }\n else\n format.html { render :new }\n format.json { render json: @sgda_seller_goal_day.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n s=false\n TurnScheme.transaction do\n @turn_scheme = TurnScheme.new(turn_scheme_params)\n s=@turn_scheme.save\n if s\n unless params[:day].nil?\n params[:day].each_with_index do |i, index|\n dates=i.split(',')\n\n dates.each do |d|\n dt=d.to_date\n ExclusionDay.find_or_create_by(day: dt, turn_type_id: params[:turn_type_id][index], turn_scheme_id: @turn_scheme.id)\n end\n end\n end\n\n end\n end\n respond_to do |format|\n if s\n format.html { redirect_to turn_schemes_path, notice: 'Схема смен была создана.' }\n format.json { render :show, status: :created, location: @turn_scheme }\n else\n format.html { render :new }\n format.json { render json: @turn_scheme.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @availability = Availability.new(params[:availability])\n @availability.user= current_user\n \n\n @availability.begin = @availability.begin.change(:day => params[:availability][:begin], :month => 4, :year => 2012)\n @availability.end = @availability.end.change(:day => params[:availability][:end], :month => 4, :year => 2012)\n\n respond_to do |format|\n if @availability.save\n format.html { redirect_to @availability.user, notice: 'Availability was successfully created.' }\n format.json { render json: @availability, status: :created, location: @availability }\n else\n format.html { render action: \"new\" }\n format.json { render json: @availability.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @holiday = Holiday.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @holiday }\n end\n end", "def create\n @schedule = Schedule.new(params[:schedule])\n @schedule.days = params[:days]\n\n if @schedule.save\n redirect_to edit_profiles_path\n else\n respond_with(@schedule) do\n format.html {render 'new'}\n end\n end\n end", "def create\n \t@conference = Conference.find(params[:conference_id])\n @day = @conference.days.new(params[:day])\n\n respond_to do |format|\n if @day.save\n format.html { redirect_to(conference_days_url, :notice => 'Day was successfully created.') }\n format.xml { render :xml => @day, :status => :created, :location => @day }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @day.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @user_day = UserDay.new(user_day_params)\n\n if params[:user_day][:holiday_year_id]\n @user_day.holiday_year = HolidayYear.find(params[:user_day][:holiday_year_id])\n else\n @user_day.holiday_year = HolidayYear.current_year\n end\n\n holiday_year_id = @user_day.holiday_year.id\n\n @user = @user_day.user\n @allowance = @user.get_holiday_allowance_for_selected_year(@user_day.holiday_year)\n @allowance.days_remaining += @user_day.no_days\n\n if @user_day.save and @allowance.save\n redirect_to user_days_url, flash: { success: I18n.t('user_day.update_success'), holiday_year_id: holiday_year_id }\n else\n redirect_to user_days_url, flash: { error: I18n.t('user_day.update_failure'), holiday_year_id: holiday_year_id }\n end\n end", "def create\n @day_week = DayWeek.new(day_week_params)\n\n respond_to do |format|\n if @day_week.save\n format.html { redirect_to '/maestricos/prueba?titulo=Dias+de+la+Semana&tabla=DayWeek' }\n format.json { render :show, status: :created, location: @day_week }\n else\n flash[:success] = \"Welcome to the Sample App!\"\n format.html { redirect_to '/maestricos/prueba?titulo=Dias+de+la+Semana&tabla=DayWeek' }\n format.json { render json: @day_week.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @daytime = Daytime.new(params[:daytime])\n\n respond_to do |format|\n if @daytime.save\n format.html { redirect_to @daytime, notice: 'Daytime was successfully created.' }\n format.json { render json: @daytime, status: :created, location: @daytime }\n else\n format.html { render action: \"new\" }\n format.json { render json: @daytime.errors, status: :unprocessable_entity }\n end\n end\n end", "def day_booking\n @zones_books = RestaurantManage.get_day_books(@restaurant.id, params[:special_day])\n @select_date = params[:special_day]\n\n render 'restaurant_manage/_day_booking', :layout => false\n #render json: {:success => true, :attachmentPartial => render_to_string('restaurant_manage/_day_booking', :layout => false) }\n end", "def get_days_with_fare(outbound=true)\n page = get_page(outbound)\n\n parse_page(page, find_cheap=true).merge(parse_page(page, find_cheap=false))\n end", "def sunday_params\n params.require(:sunday).permit(:issue_id, :date, :entry, :mantra, :moon_sign, :theme, :number_1, :number_2, :number_3)\n end", "def index\n @black_fridays = BlackFriday.paginate(:page => params[:page], :per_page => 10)\n end", "def create\n @shipping_fee = ShippingFee.new(shipping_fee_params)\n\n respond_to do |format|\n if @shipping_fee.save\n format.html { redirect_to action: :index, notice: 'Create Success.' }\n format.json { render action: :index, status: :created }\n else\n format.html { render action: :new }\n format.json { render json: @shipping_fee.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @day = Day.new(day_params)\n\n respond_to do |format|\n if @day.save\n format.html { redirect_to @day, notice: 'Day was successfully created.' }\n format.json { render :show, status: :created, location: @day }\n else\n format.html { render :new }\n format.json { render json: @day.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @holiday = Holiday.new_holiday(params, @company.id, @current_user)\n @holidays = @company.holidays\n respond_to do |format|\n if @holiday.save\n Workstream.register_user_action(@company.id, @current_user.id, request.remote_ip,\n \" new holiday for #{@holiday.holiday} on date #{@holiday.holiday_date}\", \"created\", @current_user.branch_id)\n end\n format.js { render \"create_holiday\" }\n end\n end", "def create\n @breakdown = Breakdown.new(params[:breakdown])\n if params[:breakdown][:is_fixed].to_i == 0 \n @breakdown.is_fixed = false\n @breakdown.fixed_date = nil\n else\n @breakdown.is_fixed = true\n end\n \n\n respond_to do |format|\n if @breakdown.save\n format.html { redirect_to(@breakdown, :notice => 'Breakdown was successfully created.') }\n format.xml { render :xml => @breakdown, :status => :created, :location => @breakdown }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @breakdown.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @days_since_visit = DaysSinceVisit.new(params[:days_since_visit])\n\n respond_to do |format|\n if @days_since_visit.save\n format.html { redirect_to @days_since_visit, :notice => 'Days since visit was successfully created.' }\n format.json { render :json => @days_since_visit, :status => :created, :location => @days_since_visit }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @days_since_visit.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @funding_event = FundingEvent.new(funding_event_params)\n\n respond_to do |format|\n if @funding_event.save\n format.html { redirect_to @funding_event, notice: 'Funding event was successfully created.' }\n format.json { render :show, status: :created, location: @funding_event }\n else\n format.html { render :new }\n format.json { render json: @funding_event.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @thursday = Thursday.new(thursday_params)\n\n respond_to do |format|\n if @thursday.save\n format.html { redirect_to @thursday, notice: \"Thursday was successfully created.\" }\n format.json { render :show, status: :created, location: @thursday }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @thursday.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @time_of_day = TimeOfDay.new(time_of_day_params)\n\n respond_to do |format|\n if @time_of_day.save\n format.html { redirect_to @time_of_day, notice: 'Time of day was successfully created.' }\n format.json { render :show, status: :created, location: @time_of_day }\n else\n format.html { render :new }\n format.json { render json: @time_of_day.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @financial_event = FinancialEvent.new(financial_event_params)\n\n respond_to do |format|\n if @financial_event.save\n format.html { redirect_to @financial_event, notice: 'Financial event was successfully created.' }\n format.json { render :show, status: :created, location: @financial_event }\n else\n format.html { render :new }\n format.json { render json: @financial_event.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @fbooking = Fbooking.new(fbooking_params)\n\n respond_to do |format|\n if @fbooking.save\n format.html { redirect_to @fbooking, notice: \"Fbooking was successfully created.\" }\n format.json { render :show, status: :created, location: @fbooking }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @fbooking.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @best_of_day = BestOfDay.new(best_of_day_params)\n\n @best_of_day.pedago_id = @user.id\n respond_to do |format|\n if @best_of_day.save\n format.html { redirect_to best_of_days_path, notice: 'Best of day was successfully created.' }\n format.json { render :show, status: :created, location: @best_of_day }\n else\n format.html { render :new }\n format.json { render json: @best_of_day.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @gifday = Gifday.new(gifday_params)\n\n respond_to do |format|\n if @gifday.save\n format.html { redirect_to @gifday, notice: 'Gifday was successfully created.' }\n format.json { render :show, status: :created, location: @gifday }\n else\n format.html { render :new }\n format.json { render json: @gifday.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @theory_day = TheoryDay.new(theory_day_params)\n\n respond_to do |format|\n if @theory_day.save\n format.html { redirect_to @theory_day, notice: 'Theory day was successfully created.' }\n format.json { render action: 'show', status: :created, location: @theory_day }\n else\n format.html { render action: 'new' }\n format.json { render json: @theory_day.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @week_availability = WeekAvailability.find(params[:week_availability_id])\n @day_availability = DayAvailability.new\n\n respond_to do |format|\n format.html # new.html.erb\n # format.json { render json: @day_availability }\n end\n end", "def update\n if correct_ts_user\n @tire_store = TireStore.find(params[:id]) unless @tire_store\n\n respond_to do |format|\n if @tire_store.update_attributes(params[:tire_store])\n ##puts \"---->>>>> here <<<<<<------#{params[:closed_sunday]}\"\n if !params[:open_24_hrs_monday].blank?\n @tire_store.monday_open = \"00:00\"\n @tire_store.monday_close = \"23:59\"\n elsif !params[:closed_monday].blank?\n @tire_store.monday_open = \"\"\n @tire_store.monday_close = \"\"\n elsif params[:tire_store][:monday_open].blank? && params[:tire_store][:monday_closed].blank?\n @tire_store.google_properties[\"monday_open\"] = \" \"\n @tire_store.google_properties[\"monday_close\"] = \" \"\n end\n\n if !params[:open_24_hrs_tuesday].blank?\n @tire_store.tuesday_open = \"00:00\"\n @tire_store.tuesday_close = \"23:59\"\n elsif !params[:closed_tuesday].blank?\n @tire_store.tuesday_open = \"\"\n @tire_store.tuesday_close = \"\"\n elsif params[:tire_store][:tuesday_open].blank? && params[:tire_store][:tuesday_closed].blank?\n @tire_store.google_properties[\"tuesday_open\"] = \" \"\n @tire_store.google_properties[\"tuesday_close\"] = \" \"\n end\n\n if !params[:open_24_hrs_wednesday].blank?\n @tire_store.wednesday_open = \"00:00\"\n @tire_store.wednesday_close = \"23:59\"\n elsif !params[:closed_wednesday].blank?\n @tire_store.wednesday_open = \"\"\n @tire_store.wednesday_close = \"\"\n elsif params[:tire_store][:wednesday_open].blank? && params[:tire_store][:wednesday_close].blank?\n @tire_store.google_properties[\"wednesday_open\"] = \" \"\n @tire_store.google_properties[\"wednesday_close\"] = \" \"\n end\n\n if !params[:open_24_hrs_thursday].blank?\n @tire_store.thursday_open = \"00:00\"\n @tire_store.thursday_close = \"23:59\"\n elsif !params[:closed_thursday].blank?\n @tire_store.thursday_open = \"\"\n @tire_store.thursday_close = \"\"\n elsif params[:tire_store][:thursday_open].blank? && params[:tire_store][:thursday_close].blank?\n @tire_store.google_properties[\"thursday_open\"] = \" \"\n @tire_store.google_properties[\"thursday_close\"] = \" \"\n end\n\n if !params[:open_24_hrs_friday].blank?\n @tire_store.friday_open = \"00:00\"\n @tire_store.friday_close = \"23:59\"\n elsif !params[:closed_friday].blank?\n @tire_store.friday_open = \"\"\n @tire_store.friday_close = \"\"\n elsif params[:tire_store][:friday_open].blank? && params[:tire_store][:friday_close].blank?\n @tire_store.google_properties[\"friday_open\"] = \" \"\n @tire_store.google_properties[\"friday_close\"] = \" \"\n end\n\n if !params[:open_24_hrs_saturday].blank?\n @tire_store.saturday_open = \"00:00\"\n @tire_store.saturday_close = \"23:59\"\n elsif !params[:closed_saturday].blank?\n @tire_store.saturday_open = \"\"\n @tire_store.saturday_close = \"\"\n elsif params[:tire_store][:saturday_open].blank? && params[:tire_store][:saturday_close].blank?\n @tire_store.google_properties[\"saturday_open\"] = \" \"\n @tire_store.google_properties[\"saturday_close\"] = \" \"\n end\n\n if !params[:open_24_hrs_sunday].blank?\n @tire_store.sunday_open = \"00:00\"\n @tire_store.sunday_close = \"23:59\"\n elsif !params[:closed_sunday].blank?\n @tire_store.sunday_open = \"\"\n @tire_store.sunday_close = \"\"\n elsif params[:tire_store][:sunday_open].blank? && params[:tire_store][:sunday_close].blank?\n @tire_store.google_properties[\"sunday_open\"] = \" \"\n @tire_store.google_properties[\"sunday_close\"] = \" \"\n end\n\n if !params[:online_payments].blank? && params[:online_payments] == \"0\"\n if !@tire_store.stripe_account_record.nil?\n # need to update to no stripe record....\n @tire_store.stripe_account_id = \"\"\n end\n elsif !params[:stripeAccountToken].blank?\n if @tire_store.stripe_account_record.nil?\n begin\n @tire_store.update_stripe_recipient_data_bank_account(params[:stripeBusinessName],\n params[:stripeBusinessType], params[:stripeTaxID], params[:stripeAccountToken])\n rescue Exception => e\n puts \"got an error in update_stripe_recipient_data_bank_account\"\n flash[:alert] = e.to_s \n end\n else\n # just need to update\n @tire_store.update_stripe_recipient_data_bank_account(params[:stripeBusinessName],\n params[:stripeBusinessType], params[:stripeTaxID], params[:stripeAccountToken])\n end\n end\n\n @tire_store.save\n\n # now do promotions\n @promotions = Promotion.store_only_promotions(@tire_store, 'all').order('id')\n if @promotions.nil?\n @promotions = []\n end\n\n @deals = params[:deals]\n if @deals.nil?\n @deals = []\n end\n\n @promo_ids_to_delete = []\n\n if @promotions.length != @deals.length\n # if there are zero promotions, the @deals will have a blank deal first\n if (@promotions.length == 0 && @deals.length == 1 && @deals.first.blank?)\n # do nothing...there are no 'real' promotions\n else\n # there is a difference in size...so we need to update.\n\n # process the ones that match up\n (0..@promotions.length - 1).each do |i|\n if @deals[i].blank?\n # delete the promotion\n @promo_ids_to_delete << @promotions[i].id\n elsif @deals[i] != @promotions[i].promo_name\n @promotions[i].update_attribute(:promo_name, @deals[i])\n end\n end\n\n # process the ones that are existing promotions but no longer \n # in deals (they were deleted)\n (@deals.length..@promotions.length - 1).each do |i|\n @promo_ids_to_delete << @promotions[i].id\n end\n\n\n # process the ones that are in deals but not in \n # existing promotions (they were added)\n (@promotions.length..@deals.length - 1).each do |i|\n p = Promotion.new \n p.promo_name = @deals[i]\n p.promotion_type = \"O\"\n p.promo_level = \"A\"\n p.account_id = @tire_store.account_id\n p.add_tire_store_id_to_promotion(@tire_store.id)\n p.description = p.promo_name\n p.start_date = Date.today\n p.end_date = p.start_date + 1.year\n p.new_or_used = \"N\"\n p.save\n end\n end\n else\n # they are the same...update or delete as needed\n (0..@promotions.length - 1).each do |i|\n if @deals[i].blank?\n # delete the promotion\n @promo_ids_to_delete << @promotions[i].id\n elsif @deals[i] != @promotions[i].promo_name\n @promotions[i].update_attribute(:promo_name, @deals[i])\n end\n end\n end\n\n # delete the ones that need to go\n @promo_ids_to_delete.each do |id|\n Promotion.find(id).destroy\n end \n\n if @tire_store.private_seller?\n store_type = 'Listing info'\n else\n store_type = 'Tire store'\n end\n \n begin\n @tire_store.branding.update_attributes(params[:branding])\n rescue\n end\n\n if params[:return_to_storefront].blank?\n format.html { redirect_to @tire_store, \n notice: \"#{store_type} was successfully updated.\" }\n else \n format.html { redirect_to \"/storefront/#{@tire_store.id}/edit\", \n notice: \"Hours were successfully updated.\" }\n end\n\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @tire_store.errors, status: :unprocessable_entity }\n end\n end\n else\n redirect_to root_path, :alert => \"You do not have access to that page.\"\n end\n end", "def create\n @flight_schedule = FlightSchedule.new(params[:flight_schedule])\n\n respond_to do |format|\n if @flight_schedule.save\n format.html { redirect_to @flight_schedule, notice: 'Flight schedule was successfully created.' }\n format.json { render json: @flight_schedule, status: :created, location: @flight_schedule }\n else\n format.html { render action: \"new\" }\n format.json { render json: @flight_schedule.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n bikes = Bike.all\n bikes.each do |bike|\n if bike.next_date_inspected == Time.now.in_time_zone\n bike.passed_inspection = false\n end\n end\n create_checkout_values\n respond_to do |format|\n if @checked_out.save\n create_bike_values\n UserMailer.check_out_email(@checked_out.user).deliver\n format.html { redirect_to home_check_out_path, notice: \"The bike was successfully checked out by #{@checked_out.user.email}.\" }\n format.json { render action: 'show', status: :created, location: @checked_out }\n else\n format.html { redirect_to home_check_out_path, :flash => @checked_out.errors }\n format.json { render json: @checked_out.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @spec_day = SpecDay.new(spec_day_params)\n\n drop_page_title(\"新增假日\")\n drop_breadcrumb\n respond_to do |format|\n if @spec_day.save\n format.html { redirect_to spec_days_path, notice: '添加成功.' }\n format.json { render :show, status: :created, location: @spec_day }\n else\n flash.now[:alert] = @spec_day.errors.full_messages\n format.html { render :new }\n format.json { render json: @spec_day.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @holidaytype = Holidaytype.new(params[:holidaytype])\n\n respond_to do |format|\n if @holidaytype.save\n format.html { redirect_to @holidaytype, notice: 'Holidaytype was successfully created.' }\n format.json { render json: @holidaytype, status: :created, location: @holidaytype }\n else\n format.html { render action: \"new\" }\n format.json { render json: @holidaytype.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @user_day = UserDay.new(user_day_params)\n\n respond_to do |format|\n if @user_day.save\n format.html { redirect_to @user_day, notice: 'User day was successfully created.' }\n format.json { render :show, status: :created, location: @user_day }\n else\n format.html { render :new }\n format.json { render json: @user_day.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @forecast_72 = Forecast72.new(forecast_72_params)\n\n respond_to do |format|\n if @forecast_72.save\n format.html { redirect_to @forecast_72, notice: 'Forecast 72 was successfully created.' }\n format.json { render :show, status: :created, location: @forecast_72 }\n else\n format.html { render :new }\n format.json { render json: @forecast_72.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @activity_holiday = ActivityHoliday.new(activity_holiday_params)\n\n respond_to do |format|\n if @activity_holiday.save\n format.html { redirect_to @activity_holiday, notice: 'Activity holiday was successfully created.' }\n format.json { render :show, status: :created, location: @activity_holiday }\n else\n format.html { render :new }\n format.json { render json: @activity_holiday.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @special_holiday_ctgr = SpecialHolidayCtgr.new(special_holiday_ctgr_params)\n\n respond_to do |format|\n if @special_holiday_ctgr.save\n format.html { redirect_to @special_holiday_ctgr, notice: 'Special holiday ctgr was successfully created.' }\n format.json { render :show, status: :created, location: @special_holiday_ctgr }\n else\n format.html { render :new }\n format.json { render json: @special_holiday_ctgr.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @fishing_method = FishingMethod.new(params[:fishing_method])\n\n respond_to do |format|\n if @fishing_method.save\n format.html { redirect_to @fishing_method, notice: 'Fishing method was successfully created.' }\n format.json { render json: @fishing_method, status: :created, location: @fishing_method }\n else\n format.html { render action: \"new\" }\n format.json { render json: @fishing_method.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @elective_day = ElectiveDay.new(elective_day_params)\n\n respond_to do |format|\n if @elective_day.save\n format.html { redirect_to elective_days_url }\n #format.html { redirect_to 'index', notice: 'Elective day was successfully created.' }\n format.json { render action: 'index', status: :created, location: @elective_day }\n else\n format.html { render action: 'new' }\n format.json { render json: @elective_day.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @datebodydatum = Datebodydatum.new(datebodydatum_params)\n @datebodydatum.weight = @datebodydatum.weight.round(1)\n respond_to do |format|\n if @datebodydatum.save\n format.html { redirect_to datebodydatum_url(@datebodydatum, :date_search => params[:date_search]), notice: 'Datebodydatum was successfully created.' }\n format.json { render action: 'show', status: :created, location: @datebodydatum }\n else\n format.html { render action: 'new' }\n format.json { render json: @datebodydatum.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @sale_day_total = SaleDayTotal.new(params[:sale_day_total])\n\n respond_to do |format|\n if @sale_day_total.save\n format.html { redirect_to @sale_day_total, notice: 'Sale day total was successfully created.' }\n format.json { render json: @sale_day_total, status: :created, location: @sale_day_total }\n else\n format.html { render action: \"new\" }\n format.json { render json: @sale_day_total.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @calf = Calf.new(calf_params)\n\n respond_to do |format|\n if @calf.save\n format.html { redirect_to @calf, notice: 'Calf was successfully created.' }\n format.json { render :show, status: :created, location: @calf }\n else\n format.html { render :new }\n format.json { render json: @calf.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n begin\n @new_holiday = @@data_util.strip_hash_data(params[:holiday])\n @new_holiday[:mypclient_id] = session[:client_id].strip\n @new_holiday[:createdby] = session[:username].strip\n @new_holiday[:holidaydate] = Date.strptime(@new_holiday[:holidaydate], \"%m/%d/%Y\")\n @locals = JSON.parse params[:locals] unless params[:locals].empty? \n\n Holiday.transaction do\n @holiday = Holiday.new(@new_holiday)\n if @holiday.save\n self.add_holiday_local(@locals, @holiday.id)\n @@request_result[:success] = true\n @@request_result[:notice] = \"Holiday was successfully created.\"\n else\n @@request_result[:errormsg] = @holiday.errors.full_messages[0]\n ActiveRecord::Rollback\n end\n end\n rescue Exception => e\n ActiveRecord::Rollback\n @@request_result[:errormsg] = e.message\n end\n render json: @@request_result\n end" ]
[ "0.64180404", "0.586408", "0.5675287", "0.566221", "0.5656307", "0.5606775", "0.5582695", "0.5578594", "0.5558162", "0.5536122", "0.55284905", "0.5519413", "0.54999155", "0.548241", "0.54597807", "0.5457774", "0.5438455", "0.54267293", "0.5408235", "0.54040164", "0.53981847", "0.5373032", "0.53631604", "0.5343041", "0.53429216", "0.5323712", "0.5320463", "0.5314825", "0.5314699", "0.53140694", "0.5307288", "0.5298723", "0.5287724", "0.5283929", "0.52825856", "0.5280328", "0.52501297", "0.5247109", "0.5242439", "0.52357644", "0.52291816", "0.5217061", "0.5215981", "0.52098835", "0.5206616", "0.520103", "0.51996225", "0.51941884", "0.5191691", "0.5190995", "0.5177688", "0.5174914", "0.5173518", "0.51676697", "0.5165284", "0.51634604", "0.516208", "0.5159781", "0.5138412", "0.5138029", "0.5135544", "0.51336956", "0.51336956", "0.51315665", "0.5129275", "0.51274246", "0.5124003", "0.5113967", "0.510009", "0.50915444", "0.50898725", "0.508863", "0.5087154", "0.5086602", "0.5086176", "0.50858307", "0.5085025", "0.50753224", "0.5075196", "0.50720775", "0.5070498", "0.5069795", "0.5065715", "0.50650144", "0.50583196", "0.50559074", "0.505556", "0.5046772", "0.50447565", "0.50385445", "0.50363624", "0.5034964", "0.50331837", "0.50328267", "0.503072", "0.50299525", "0.50280356", "0.50236833", "0.5021751", "0.50207615" ]
0.6805994
0
PATCH/PUT /black_fridays/1 PATCH/PUT /black_fridays/1.json
def update respond_to do |format| if @black_friday.update(black_friday_params) format.html { redirect_to @black_friday, notice: 'Black friday was successfully updated.' } format.json { render :show, status: :ok, location: @black_friday } else format.html { render :edit } format.json { render json: @black_friday.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n respond_to do |format|\n if @friday.update(friday_params)\n format.html { redirect_to @friday, notice: \"Friday was successfully updated.\" }\n format.json { render :show, status: :ok, location: @friday }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @friday.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @everyday.update(everyday_params)\n format.html { redirect_to :back, notice: 'Everyday was successfully updated.' }\n format.json { render :show, status: :ok, location: :back }\n else\n format.html { render :edit }\n format.json { render json: @everyday.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @snowfall.update(snowfall_params)\n format.html { redirect_to @snowfall, notice: 'Snowfall was successfully updated.' }\n format.json { render :show, status: :ok, location: @snowfall }\n else\n format.html { render :edit }\n format.json { render json: @snowfall.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @dayoff = Dayoff.find(params[:id])\n\n respond_to do |format|\n if @dayoff.update_attributes(params[:dayoff])\n format.html { redirect_to @dayoff, notice: 'Dayoff was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @dayoff.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @off_day.update(off_day_params)\n format.html { redirect_to @off_day, notice: 'Off day was successfully updated.' }\n format.json { render :show, status: :ok, location: @off_day }\n else\n format.html { render :edit }\n format.json { render json: @off_day.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @appraisal_fee.update(appraisal_fee_params)\n format.html { redirect_to appraisal_fees_path, notice: 'Appraisal fee was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @appraisal_fee.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n\n @foaf.interests.clear\n\n if(foaf_params.has_key?(:interests_attributes))\n interest_ids = foaf_params[:interests_attributes].split(\",\").map { |s| s.to_i }\n interest_ids.each do |i|\n @foaf.interests << Interest.find(i)\n #@foaf.update(Interest.find(i))\n end\n \n end\n\n respond_to do |format|\n if @foaf.update(name: foaf_params[:name], work: foaf_params[:work], \n slug: foaf_params[:slug], birthday: foaf_params[:birthday])\n format.html { redirect_to @foaf, notice: 'FOAF was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @foaf.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @sunday.update(sunday_params)\n format.html { redirect_to @sunday, notice: 'Sunday was successfully updated.' }\n format.json { render :show, status: :ok, location: @sunday }\n else\n format.html { render :edit }\n format.json { render json: @sunday.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @special_holiday.update(special_holiday_params)\n format.html { redirect_to @special_holiday, notice: 'Special holiday was successfully updated.' }\n format.json { render :show, status: :ok, location: @special_holiday }\n else\n format.html { render :edit }\n format.json { render json: @special_holiday.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @calf.update(calf_params)\n format.html { redirect_to @calf, notice: 'Calf was successfully updated.' }\n format.json { render :show, status: :ok, location: @calf }\n else\n format.html { render :edit }\n format.json { render json: @calf.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @beef.update(beef_params)\n format.html { redirect_to @beef, notice: 'Beef was successfully updated.' }\n format.json { render :show, status: :ok, location: @beef }\n else\n format.html { render :edit }\n format.json { render json: @beef.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n\n @foaf.interests.clear\n\n if(foaf_params.has_key?(:interests_attributes))\n interest_ids = foaf_params[:interests_attributes].split(\",\").map { |s| s.to_i }\n interest_ids.each do |i|\n @foaf.interests << Interest.find(i)\n #@foaf.update(Interest.find(i))\n end\n \n end\n\n respond_to do |format|\n if @foaf.update(name: foaf_params[:name], work: foaf_params[:work], \n slug: foaf_params[:slug], birthday: foaf_params[:birthday])\n format.html { redirect_to @foaf, notice: 'Foaf was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @foaf.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @closing_day = ClosingDay.find(params[:id])\n\n respond_to do |format|\n if @closing_day.update_attributes(params[:closing_day])\n format.html { redirect_to @closing_day, notice: 'Closing day was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @closing_day.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @flat_happening = FlatHappening.find(params[:id])\n\n if @flat_happening.update_attributes(params[:flat_happening])\n head :no_content\n else\n render json: @flat_happening.errors, status: :unprocessable_entity\n end\n end", "def update\n @daylight = Daylight.find(params[:id])\n\n respond_to do |format|\n if @daylight.update_attributes(daylight_params)\n format.html { redirect_to @daylight, notice: 'Daylight was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @daylight.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @belief = Belief.find(params[:id])\n\n respond_to do |format|\n if @belief.update_attributes(params[:belief])\n format.html { redirect_to @belief, :notice => 'Belief was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @belief.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @weekday = Weekday.find(params[:id])\n\n respond_to do |format|\n if @weekday.update_attributes(params[:weekday])\n format.html { redirect_to @weekday, notice: 'Weekday was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @weekday.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @extra_holiday.update(extra_holiday_params)\n format.html { redirect_to @extra_holiday, notice: 'Extra holiday was successfully updated.' }\n format.json { render :show, status: :ok, location: @extra_holiday }\n else\n format.html { render :edit }\n format.json { render json: @extra_holiday.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @holiday.update_attributes(params[:holiday])\n format.html { redirect_to @holiday, notice: 'El Feriado fue Actualizado.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @holiday.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @flight_schedule = FlightSchedule.find(params[:id])\n\n respond_to do |format|\n if @flight_schedule.update_attributes(params[:flight_schedule])\n format.html { redirect_to @flight_schedule, notice: 'Flight schedule was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @flight_schedule.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @daily_happiness.update(daily_happiness_params)\n format.html { redirect_to @daily_happiness, notice: 'Daily happiness was successfully updated.' }\n format.json { render :show, status: :ok, location: @daily_happiness }\n else\n format.html { render :edit }\n format.json { render json: @daily_happiness.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @theory_day.update(theory_day_params)\n format.html { redirect_to @theory_day, notice: 'Theory day was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @theory_day.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @flight = Flight.find(params[:id])\n\n if @flight.update(params[:flight])\n head :no_content\n else\n render json: @flight.errors, status: :unprocessable_entity\n end\n end", "def update\n respond_to do |format|\n if @weekday_constraint.update(weekday_constraint_params)\n format.html { redirect_to @weekday_constraint, notice: 'Weekday constraint was successfully updated.' }\n format.json { render :show, status: :ok, location: @weekday_constraint }\n else\n format.html { render :edit }\n format.json { render json: @weekday_constraint.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @bday = Bday.find(params[:id])\n\n respond_to do |format|\n if @bday.update_attributes(params[:bday])\n format.html { redirect_to(@bday, :notice => 'Bday was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @bday.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @special_holiday_ctgr.update(special_holiday_ctgr_params)\n format.html { redirect_to @special_holiday_ctgr, notice: 'Special holiday ctgr was successfully updated.' }\n format.json { render :show, status: :ok, location: @special_holiday_ctgr }\n else\n format.html { render :edit }\n format.json { render json: @special_holiday_ctgr.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n\n price_schedule_params[:basis] = price_schedule_params[:basis].to_i\n price_schedule_params[:break_type] = price_schedule_params[:break_type].to_i\n price_schedule_params[:qualifier] = price_schedule_params[:qualifier].to_i\n price_schedule_params[:fee_calculation_type] = price_schedule_params[:fee_calculation_type].to_i\n price_schedule_params[:usual_customary_calculation] = price_schedule_params[:usual_customary_calculation].to_i\n price_schedule_params[:customer_assigned_schedule] = price_schedule_params[:customer_assigned_schedule].to_i\n price_schedule_params[:percentage_fee_type] = price_schedule_params[:percentage_fee_type].to_i\n price_schedule_params[:amount_fee_type] = price_schedule_params[:amount_fee_type].to_i\n\n respond_to do |format|\n if @price_schedule.update(price_schedule_params)\n format.html { redirect_to @price_schedule, notice: 'Price Schedule was successfully updated.' }\n format.json { render :show, status: :ok, location: @price_schedule }\n else\n format.html { render :edit }\n format.json { render json: @price_schedule.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @wing.update(wing_params)\n @wing.floors.each { |f| f.touch }\n format.html { redirect_to @wing, notice: t('.update_ok', item: @wing.name) }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @wing.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @day.update(day_params)\n format.html { redirect_to days_path, notice: 'Day was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @day.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @fahrt.update(fahrt_params)\n format.html { redirect_to @fahrt, notice: 'Fahrt was successfully updated.' }\n format.json { render :show, status: :ok, location: @fahrt }\n else\n format.html { render :edit }\n format.json { render json: @fahrt.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @fishing_method = FishingMethod.find(params[:id])\n\n respond_to do |format|\n if @fishing_method.update_attributes(params[:fishing_method])\n format.html { redirect_to @fishing_method, notice: 'Fishing method was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @fishing_method.errors, status: :unprocessable_entity }\n end\n end\n end", "def api_patch(path, data = {})\n api_request(:patch, path, :data => data)\n end", "def update\n puts \"update #{@feeling.as_json} #{updated_params.as_json}\"\n respond_to do |format|\n if @feeling.update(updated_params)\n puts \"brucep update success\"\n #format.html { redirect_to @feeling, notice: 'Feeling was successfully updated.' }\n format.html { redirect_to new_feeling_path }\n format.json { render :show, status: :ok, location: @feeling }\n #format.js\n else\n format.html { render :edit }\n format.json { render json: @feeling.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @workday.update(workday_params)\n format.html { redirect_to dashboard_path, notice: 'Workday was successfully updated.' }\n format.json { render :show, status: :ok, location: @workday }\n else\n format.html { render :edit }\n format.json { render json: @workday.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n budgets = update_budgets(params[:budgets])\n\n render json: budgets, status: :ok\n end", "def update\n respond_to do |format|\n if @fee.update(fee_params)\n format.html { redirect_to @fee, notice: 'Fee was successfully updated.' }\n format.json { render :show, status: :ok, location: @fee }\n else\n format.html { render :edit }\n format.json { render json: @fee.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @fee.update(fee_params)\n format.html { redirect_to @fee, notice: 'Fee was successfully updated.' }\n format.json { render :show, status: :ok, location: @fee }\n else\n format.html { render :edit }\n format.json { render json: @fee.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @holidaytype = Holidaytype.find(params[:id])\n\n respond_to do |format|\n if @holidaytype.update_attributes(params[:holidaytype])\n format.html { redirect_to @holidaytype, notice: 'Holidaytype was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @holidaytype.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @day = Day.find(params[:id])\n\n respond_to do |format|\n if @day.update_attributes(params[:day])\n format.html { redirect_to @day, notice: 'Day was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @day.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @gifday.update(gifday_params)\n format.html { redirect_to @gifday, notice: 'Gifday was successfully updated.' }\n format.json { render :show, status: :ok, location: @gifday }\n else\n format.html { render :edit }\n format.json { render json: @gifday.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @freerange.update(freerange_params)\n format.html { redirect_to current_user }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @freerange.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_tenant_circle(args = {}) \n put(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend", "def update\n respond_to do |format|\n if @spec_day.update(spec_day_params)\n format.html { redirect_to spec_days_path, notice: '更新成功!' }\n format.json { render :show, status: :ok, location: @spec_day }\n else\n flash.now[:alert] = @spec_day.errors.full_messages\n format.html { render :edit }\n format.json { render json: @spec_day.errors, status: :unprocessable_entity }\n end\n end\n end", "def patch!\n request! :patch\n end", "def update\n respond_to do |format|\n if @b_twelf.update(b_twelf_params)\n format.html { redirect_to year_action_plan_path(@year,@action_plan), notice: 'B twelf was successfully updated.' }\n format.json { render :show, status: :ok, location: @b_twelf }\n else\n format.html { render :edit }\n format.json { render json: @b_twelf.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @tenant_fee.update(tenant_fee_params)\n format.html { redirect_to @tenant_fee, notice: 'Tenant fee was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :edit }\n format.json { render json: @tenant_fee.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @fee = Fee.find(params[:id])\n\n respond_to do |format|\n if @fee.update_attributes(params[:fee])\n format.html { redirect_to fees_path, notice: 'Fee was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @fee.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @batch_day.update(batch_day_params)\n format.html { redirect_to @batch_day, notice: 'Batch day was successfully updated.' }\n format.json { render :show, status: :ok, location: @batch_day }\n else\n format.html { render :edit }\n format.json { render json: @batch_day.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @scribble = Scribble.find(params[:id])\n\n respond_to do |format|\n if @scribble.update_attributes(params[:scribble])\n format.html { redirect_to @scribble, :notice => 'Scribble was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @scribble.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @scribble = Scribble.find(params[:id])\n\n respond_to do |format|\n if @scribble.update_attributes(params[:scribble])\n format.html { redirect_to @scribble, :notice => 'Scribble was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @scribble.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @scribble = Scribble.find(params[:id])\n\n respond_to do |format|\n if @scribble.update_attributes(params[:scribble])\n format.html { redirect_to @scribble, :notice => 'Scribble was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @scribble.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @frosting_flavor.update(frosting_flavor_params)\n format.html { redirect_to @frosting_flavor, notice: 'Frosting flavor was successfully updated.' }\n format.json { render :show, status: :ok, location: @frosting_flavor }\n else\n format.html { render :edit }\n format.json { render json: @frosting_flavor.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @fridge = Fridge.find(params[:id])\n\n respond_to do |format|\n if @fridge.update_attributes(params[:fridge])\n format.html { redirect_to @fridge, notice: 'Fridge was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @fridge.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @schedule = Schedule.find(params[:id])\n @client_branches = ClientBranch.where(:client_id => params[:schedule][:client_id])\n respond_to do |format|\n if @schedule.update_attributes(params[:schedule])\n format.html { redirect_to @schedule, notice: 'Schedule was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @schedule.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if @day.update(update_params)\n render json: @day, include: [:activities]\n else \n render json: @day.errors\n end\n end", "def update\n respond_to do |format|\n if @event_day.update(event_day_params)\n format.html { redirect_to events_path, notice: 'Event day was successfully updated.' }\n format.json { render :show, status: :ok, location: @event_day }\n else\n format.html { render :edit }\n format.json { render json: @event_day.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @attendance.flake!({reason: params[:attendance][:reason]})\n format.html { redirect_to profile_path, notice: 'Your spot is now open for someone else!' }\n format.json { render :show, status: :created, location: @tea_time }\n else\n format.html { redirect_to profile_path }\n format.json { render json: @attendance.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @agenda_checkin = AgendaCheckin.find(params[:id])\n\n respond_to do |format|\n if @agenda_checkin.update_attributes(params[:agenda_checkin])\n format.html { redirect_to @agenda_checkin, :notice => 'Agenda checkin was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @agenda_checkin.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @day.update(day_params)\n format.html { redirect_to @day, notice: 'Day was successfully updated.' }\n format.json { render :show, status: :ok, location: @day }\n else\n format.html { render :edit }\n format.json { render json: @day.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @nightclub.update(nightclub_params)\n format.html { redirect_to @nightclub, notice: 'Nightclub was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @nightclub.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @holiday.update(holiday_params)\n format.html { redirect_to holidays_url, notice: '成功更新.' }\n format.json { render :show, status: :ok, location: @holiday }\n else\n format.html { render :edit }\n format.json { render json: @holiday.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @red_flag = RedFlag.find(params[:id])\n\n respond_to do |format|\n if @red_flag.update_attributes(params[:red_flag])\n format.html { redirect_to @red_flag, notice: 'Red flag was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @red_flag.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @holiday_date.update(holiday_date_params)\n format.html { redirect_to @holiday_date, notice: 'Holiday date was successfully updated.' }\n format.json { render :show, status: :ok, location: @holiday_date }\n else\n format.html { render :edit }\n format.json { render json: @holiday_date.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @shipping_fee.update_attributes(shipping_fee_params)\n format.html { redirect_to action: :index, notice: 'Update Success.' }\n format.json { render action: :index, status: :accepted }\n else\n format.html { render action: :edit }\n format.json { render json: @shipping_fee.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @dow.update(dow_params)\n format.html { redirect_to @dow, notice: 'Dow was successfully updated.' }\n format.json { render :show, status: :ok, location: @dow }\n else\n format.html { render :edit }\n format.json { render json: @dow.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @cal_time.update(cal_time_params)\n format.html { redirect_to @cal_time, notice: 'Cal time was successfully updated.' }\n format.json { render :show, status: :ok, location: @cal_time }\n else\n format.html { render :edit }\n format.json { render json: @cal_time.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @activity_holiday.update(activity_holiday_params)\n format.html { redirect_to @activity_holiday, notice: 'Activity holiday was successfully updated.' }\n format.json { render :show, status: :ok, location: @activity_holiday }\n else\n format.html { render :edit }\n format.json { render json: @activity_holiday.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @calendar_day.update(calendar_day_params)\n format.html { redirect_to @calendar_day, notice: 'Calendar day was successfully updated.' }\n format.json { render :show, status: :ok, location: @calendar_day }\n else\n format.html { render :edit }\n format.json { render json: @calendar_day.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n #@calendar_guess = CalendarGuess.find(params[:id])\n\n respond_to do |format|\n if @@calendar_guess.update_attributes(params[:calendar_guess])\n format.html { redirect_to @calendar_guess, notice: 'Calendar guess was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @calendar_guess.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @work_day = WorkDay.find(params[:id])\n\n respond_to do |format|\n if @work_day.update_attributes(params[:work_day])\n flash[:notice] = 'Giornata di lavoro salvata con successo.'\n format.html { redirect_to action: 'index' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @work_day.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @day = DayAvailability.find(params[:id])\n @week = WeekAvailability.find(params[:week_availability_id])\n\n respond_to do |format|\n if @day.update_attributes(params[:day_availability])\n format.html {redirect_to @week, notice: 'Successfully updated schedule.'}\n # format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n end\n end\n end", "def update\n respond_to do |format|\n if @work_day.update(work_day_params)\n format.html { redirect_to @work_day, notice: 'Work day was successfully updated.' }\n format.json { render :show, status: :ok, location: @work_day }\n else\n format.html { render :edit }\n format.json { render json: @work_day.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @time_of_day.update(time_of_day_params)\n format.html { redirect_to @time_of_day, notice: 'Time of day was successfully updated.' }\n format.json { render :show, status: :ok, location: @time_of_day }\n else\n format.html { render :edit }\n format.json { render json: @time_of_day.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @holidaytask.update(holidaytask_params)\n format.html { redirect_to @holidaytask, notice: 'Holidaytask was successfully updated.' }\n format.json { render :show, status: :ok, location: @holidaytask }\n else\n format.html { render :edit }\n format.json { render json: @holidaytask.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @food.update(food_params)\n respond_with @food, location: -> { kitchen_board_path }\n end", "def update\n respond_to do |format|\n if @luxury_coffee.update(luxury_coffee_params)\n format.html { redirect_to @luxury_coffee, notice: 'Luxury coffee was successfully updated.' }\n format.json { render :show, status: :ok, location: @luxury_coffee }\n else\n format.html { render :edit }\n format.json { render json: @luxury_coffee.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @feeling = Feeling.find(params[:id])\n\n respond_to do |format|\n if @feeling.update_attributes(params[:feeling])\n format.html { redirect_to @feeling, notice: 'Feeling was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @feeling.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @porkbeef.update(porkbeef_params)\n format.html { redirect_to @porkbeef, notice: 'Porkbeef was successfully updated.' }\n format.json { render :show, status: :ok, location: @porkbeef }\n else\n format.html { render :edit }\n format.json { render json: @porkbeef.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @rainbow = Rainbow.find(params[:id])\n\n respond_to do |format|\n if @rainbow.update_attributes(params[:rainbow])\n format.html { redirect_to @rainbow, notice: 'Rainbow was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @rainbow.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @blueprint.update(blueprint_params)\n format.html { redirect_to @blueprint, notice: 'Blueprint was successfully updated.' }\n format.json { render :show, status: :ok, location: @blueprint }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @blueprint.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @downtime.update(downtime_params)\n format.html { redirect_to @downtime, notice: 'Downtime was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @downtime.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @riesgo.update(riesgo_params)\n format.html { redirect_to @riesgo, notice: 'Riesgo was successfully updated.' }\n format.json { render :show, status: :ok, location: @riesgo }\n else\n format.html { render :edit }\n format.json { render json: @riesgo.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @meal_schedule.update(meal_schedule_params)\n format.html { redirect_to meal_schedules_path, notice: 'MealSchedule was updated successfully' }\n format.json { render :show, status: :ok, location: meal_schedules_path }\n else\n format.html { render :edit }\n format.json { render json: @meal_schedule.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @daytime = Daytime.find(params[:id])\n\n respond_to do |format|\n if @daytime.update_attributes(params[:daytime])\n format.html { redirect_to @daytime, notice: 'Daytime was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @daytime.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @spoofer = Spoofer.find(params[:id])\n\n respond_to do |format|\n if @spoofer.update_attributes(params[:spoofer])\n format.html { redirect_to @spoofer, notice: 'Spoofer was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @spoofer.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @trip.update(trip_params)\n format.html { redirect_to @trip, notice: 'Trip was successfully updated.' }\n format.json { render :show, status: :ok, location: @trip }\n offset = -1\n @trip.days.all.each do |day|\n offset += 1\n day.update_attribute(:date, @trip.beginning + offset)\n end\n else\n format.html { render :edit }\n format.json { render json: @trip.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @snowboard.update(snowboard_params)\n format.html { redirect_to @snowboard, notice: \"Snowboard was successfully updated.\" }\n format.json { render :show, status: :ok, location: @snowboard }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @snowboard.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @wednesday.update(wednesday_params)\n format.html { redirect_to @wednesday, notice: \"Wednesday was successfully updated.\" }\n format.json { render :show, status: :ok, location: @wednesday }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @wednesday.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @calorie_consumption.update(calorie_consumption_params)\n format.html { redirect_to @calorie_consumption, notice: 'Calorie consumption was successfully updated.' }\n format.json { render :show, status: :ok, location: @calorie_consumption }\n else\n format.html { render :edit }\n format.json { render json: @calorie_consumption.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @backoffice_compliance.update(backoffice_compliance_params)\n format.html { redirect_to @backoffice_compliance, notice: 'Compliance was successfully updated.' }\n format.json { render :show, status: :ok, location: @backoffice_compliance }\n else\n format.html { render :edit }\n format.json { render json: @backoffice_compliance.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @fbt.update(fbt_params)\n format.html { redirect_to @fbt, notice: \"Client was successfully updated.\" }\n format.json { render :show, status: :ok, location: @fbt }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @fbt.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @sick_hours_event.update(sick_hours_event_params)\n format.html { redirect_to sick_hours_events_path, notice: 'Sick hours event was successfully updated.' }\n format.json { render :show, status: :ok, location: @sick_hours_event }\n else\n format.html { render :edit }\n format.json { render json: @sick_hours_event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @forecast_72.update(forecast_72_params)\n format.html { redirect_to @forecast_72, notice: 'Forecast 72 was successfully updated.' }\n format.json { render :show, status: :ok, location: @forecast_72 }\n else\n format.html { render :edit }\n format.json { render json: @forecast_72.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @elective_day.update(elective_day_params)\n format.html { redirect_to 'index', notice: 'Elective day was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @elective_day.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @getoff_info = GetoffInfo.find(params[:id])\n\n respond_to do |format|\n if @getoff_info.update_attributes(params[:getoff_info])\n format.html { redirect_to @getoff_info, :notice => 'Getoff info was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @getoff_info.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @butterfly = Butterfly.find(params[:id])\n\n respond_to do |format|\n if @butterfly.update_attributes(params[:butterfly])\n format.html { redirect_to @butterfly, notice: 'Butterfly was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @butterfly.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @default_line_calendar.update(default_line_calendar_params)\n format.html { redirect_to @default_line_calendar, notice: 'Default line calendar was successfully updated.' }\n format.json { render :show, status: :ok, location: @default_line_calendar }\n else\n format.html { render :edit }\n format.json { render json: @default_line_calendar.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @holiday = Holiday.find(params[:id])\n \n respond_to do |format|\n if @holiday.update_attributes(params[:holiday])\n Workstream.register_user_action(@company.id, @current_user.id, request.remote_ip,\n \" holiday for #{@holiday.holiday} on date #{@holiday.holiday_date}\", \"updated\", @current_user.branch_id)\n format.html { redirect_to(@holiday, :notice => 'Holiday was successfully updated.') }\n # format.xml { head :ok }\n format.json { head :ok }\n else\n @menu = \"Organisation Settings\"\n @page_name = \"Manage Holiday\"\n format.html { render :action => \"edit\" }\n # format.xml { render :xml => @holiday.errors, :status => :unprocessable_entity }\n format.json { respond_with_bip(@holiday) }\n end\n end\n end", "def update\n respond_to do |format|\n if @sun_glass.update(sun_glass_params)\n format.html { redirect_to @sun_glass, notice: 'Sun glass was successfully updated.' }\n format.json { render :show, status: :ok, location: @sun_glass }\n else\n format.html { render :edit }\n format.json { render json: @sun_glass.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @freight_bill.update(freight_bill_params)\n format.html { redirect_to @freight_bill, notice: 'Freight bill was successfully updated.' }\n format.json { render :show, status: :ok, location: @freight_bill }\n else\n format.html { render :edit }\n format.json { render json: @freight_bill.errors, status: :unprocessable_entity }\n end\n end\n end" ]
[ "0.6534209", "0.6212672", "0.6169254", "0.61150664", "0.6111235", "0.61073947", "0.60652864", "0.60615295", "0.6045077", "0.60324526", "0.6021983", "0.6021285", "0.6003562", "0.59936595", "0.59888697", "0.592375", "0.5914209", "0.59090865", "0.5907867", "0.5885865", "0.5882263", "0.5880745", "0.58560914", "0.5850846", "0.58459574", "0.58366996", "0.5827263", "0.5813735", "0.58113545", "0.58081067", "0.5805317", "0.5803259", "0.580133", "0.5797278", "0.57915705", "0.5791429", "0.5791429", "0.5789559", "0.57828707", "0.57820135", "0.57814854", "0.57801604", "0.5777794", "0.5776726", "0.57741207", "0.577389", "0.5771803", "0.57672197", "0.57596606", "0.57596606", "0.57596606", "0.5757349", "0.57509565", "0.5748633", "0.5743883", "0.5741138", "0.57398146", "0.57389593", "0.5734314", "0.5731192", "0.5730997", "0.5724419", "0.5723568", "0.5719918", "0.57191914", "0.57163805", "0.5712739", "0.57111126", "0.57104516", "0.5708464", "0.5704613", "0.56998986", "0.5698492", "0.56923866", "0.5691755", "0.56904215", "0.5690104", "0.5684041", "0.56782573", "0.5677402", "0.5676384", "0.56761533", "0.5672967", "0.5671179", "0.5670611", "0.5669419", "0.566266", "0.5657773", "0.56563514", "0.56529737", "0.5650277", "0.56502724", "0.5648074", "0.5646262", "0.5645868", "0.5643927", "0.5643173", "0.56397116", "0.56383246", "0.56372213" ]
0.6813972
0
DELETE /black_fridays/1 DELETE /black_fridays/1.json
def destroy @black_friday.destroy respond_to do |format| format.html { redirect_to black_fridays_url, notice: 'Black friday was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @friday.destroy\n respond_to do |format|\n format.html { redirect_to fridays_url, notice: \"Friday was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @weekday = Weekday.find(params[:id])\n @weekday.destroy\n\n respond_to do |format|\n format.html { redirect_to weekdays_url }\n format.json { head :ok }\n end\n end", "def destroy\n @theory_day.destroy\n respond_to do |format|\n format.html { redirect_to theory_days_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @dayoff = Dayoff.find(params[:id])\n @dayoff.destroy\n\n respond_to do |format|\n format.html { redirect_to dayoffs_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @closing_day = ClosingDay.find(params[:id])\n @closing_day.destroy\n\n respond_to do |format|\n format.html { redirect_to closing_days_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @sunday.destroy\n respond_to do |format|\n format.html { redirect_to sundays_url, notice: 'Sunday was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @bday = Bday.find(params[:id])\n @bday.destroy\n\n respond_to do |format|\n format.html { redirect_to(bdays_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @day.destroy\n respond_to do |format|\n format.html { redirect_to days_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @daylight = Daylight.find(params[:id])\n @daylight.destroy\n\n respond_to do |format|\n format.html { redirect_to daylights_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @matchday.destroy\n respond_to do |format|\n format.html { redirect_to matchdays_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @everyday.destroy\n respond_to do |format|\n format.html { redirect_to everydays_url, notice: 'Everyday was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @daytime = Daytime.find(params[:id])\n @daytime.destroy\n\n respond_to do |format|\n format.html { redirect_to daytimes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @elective_day.destroy\n respond_to do |format|\n format.html { redirect_to elective_days_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @day = Day.find(params[:id])\n @day.destroy\n\n respond_to do |format|\n format.html { redirect_to days_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @daily_happiness.destroy\n respond_to do |format|\n format.html { redirect_to daily_happinesses_url, notice: 'Daily happiness was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete\n render :json => @fiestas.delete_at(params[:id].to_i)\n end", "def destroy\n @off_day.destroy\n respond_to do |format|\n format.html { redirect_to off_days_url, notice: 'Off day was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @downtime.destroy\n respond_to do |format|\n format.html { redirect_to downtimes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @best_of_day.destroy\n respond_to do |format|\n format.html { redirect_to best_of_days_path, notice: 'Best of day was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @beacon.destroy\n DateUpdate.new().save\n respond_to do |format|\n format.html { redirect_to local_beacons_path, notice: 'Beacon was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @nightclub.destroy\n respond_to do |format|\n format.html { redirect_to nightclubs_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @dailyStanding = DailyStanding.find(params[:id])\n @dailyStanding.destroy\n\n respond_to do |format|\n format.html { redirect_to dailyStanding_url }\n format.json { head :ok }\n end\n end", "def destroy\n @time_of_day.destroy\n respond_to do |format|\n format.html { redirect_to time_of_days_url, notice: 'Time of day was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @new_day.destroy\n respond_to do |format|\n format.html { redirect_to new_days_url, notice: 'New day was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @day_week.destroy\n respond_to do |format|\n format.html { redirect_to day_weeks_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @day = Day.find(params[:id])\n @baby = @day.baby\n @day.destroy\n respond_to do |format|\n format.html { redirect_to baby_path(@baby), notice: 'Day was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @holiday.destroy\n respond_to do |format|\n format.html { redirect_to holidays_url }\n format.json { head :no_content }\n end\n end", "def delete\n client.delete(\"/#{id}\")\n end", "def destroy\n @daily_intake.destroy\n respond_to do |format|\n format.html { redirect_to daily_intakes_url }\n format.json { head :no_content }\n end\n end", "def delete_tenant_circle(args = {}) \n delete(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend", "def destroy\n @wednesday.destroy\n respond_to do |format|\n format.html { redirect_to wednesdays_url, notice: \"Wednesday was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @flight_schedule = FlightSchedule.find(params[:id])\n @flight_schedule.destroy\n\n respond_to do |format|\n format.html { redirect_to flight_schedules_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @daytype = Daytype.find(params[:id])\n @daytype.destroy\n\n respond_to do |format|\n format.html { redirect_to daytypes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @nightclub = Nightclub.find(params[:id])\n @nightclub.destroy\n\n respond_to do |format|\n format.html { redirect_to nightclubs_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @holidaytype = Holidaytype.find(params[:id])\n @holidaytype.destroy\n\n respond_to do |format|\n format.html { redirect_to holidaytypes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @batch_day.destroy\n respond_to do |format|\n format.html { redirect_to batch_days_url, notice: 'Batch day was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @daily_step.destroy\n respond_to do |format|\n format.html { redirect_to daily_steps_url, notice: 'Daily step was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @stay_night.destroy\n respond_to do |format|\n format.html { redirect_to stay_nights_url }\n format.json { head :no_content }\n format.js\n end\n end", "def destroy\n @thursday.destroy\n respond_to do |format|\n format.html { redirect_to thursdays_url, notice: \"Thursday was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def delete_aos_version(args = {}) \n delete(\"/aosversions.json/#{args[:aosVersionId]}\", args)\nend", "def destroy\n @daily_grr = DailyGrr.find(params[:id])\n @daily_grr.destroy\n\n respond_to do |format|\n format.html { redirect_to(scaffold_daily_grrs_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @climb_datum = ClimbDatum.find(params[:id])\n @climb_datum.destroy\n\n respond_to do |format|\n format.html { redirect_to climb_data_url }\n format.json { head :no_content }\n end\n end", "def test_del\n header 'Content-Type', 'application/json'\n\n data = File.read 'sample-traces/0.json'\n post('/traces', data, 'CONTENT_TYPE': 'application/json')\n\n id = last_response.body\n\n delete \"/traces/#{id}\"\n assert last_response.ok?\n\n get \"/traces/#{id}\"\n\n contents = JSON.parse last_response.body\n assert_kind_of(Hash, contents, 'Response contents is not a hash')\n assert contents.key? 'description'\n assert(!last_response.ok?)\n end", "def destroy\n @gifday.destroy\n respond_to do |format|\n format.html { redirect_to gifdays_url, notice: 'Gifday was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @snowfall.destroy\n respond_to do |format|\n format.html { redirect_to snowfalls_url, notice: 'Snowfall was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @day.destroy\n respond_to do |format|\n format.html { redirect_to days_url, notice: 'Day was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @appraisal_fee.destroy\n respond_to do |format|\n format.html { redirect_to appraisal_fees_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @gameday.destroy\n respond_to do |format|\n format.html { redirect_to gamedays_url, notice: 'Gameday was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @the_day = TheDay.find(params[:id])\n @the_day.destroy\n\n respond_to do |format|\n format.html { redirect_to(the_days_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @daily_total.destroy\n respond_to do |format|\n format.html { redirect_to daily_totals_url, notice: 'Daily total was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @day = Day.find(params[:id])\n @day.destroy\n\n respond_to do |format|\n format.html { redirect_to(conference_days_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @sale_day_total = SaleDayTotal.find(params[:id])\n @sale_day_total.destroy\n\n respond_to do |format|\n format.html { redirect_to sale_day_totals_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @essay = Essay.find(params[:id])\n @essay.destroy\n\n respond_to do |format|\n format.html { redirect_to essays_url }\n format.json { head :ok }\n end\n end", "def destroy\n @day_of_week.destroy\n respond_to do |format|\n format.html { redirect_to day_of_weeks_url, notice: 'Day of week was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @hospitalization_day.destroy\n respond_to do |format|\n format.html { redirect_to hospitalization_days_url, notice: 'Día de estancia eliminado satisfactoriamente.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @special_holiday_ctgr.destroy\n respond_to do |format|\n format.html { redirect_to special_holiday_ctgrs_url, notice: 'Special holiday ctgr was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @special_holiday.destroy\n respond_to do |format|\n format.html { redirect_to special_holidays_url, notice: 'Special holiday was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @station_daily.destroy\n respond_to do |format|\n format.html { redirect_to station_dailies_url, notice: 'Station daily was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @monday.destroy\n respond_to do |format|\n format.html { redirect_to mondays_url, notice: 'Monday was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @calf.destroy\n respond_to do |format|\n format.html { redirect_to calves_url, notice: 'Calf was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @cashflow = Cashflow.find(params[:id])\n @cashflow.destroy\n\n respond_to do |format|\n format.html { redirect_to cashflows_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @work_day = WorkDay.find(params[:id])\n @work_day.destroy\n\n respond_to do |format|\n flash[:notice] = 'Giornata di lavoro rimossa con successo.'\n format.html { redirect_to work_days_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @dailyfeatured.destroy\n respond_to do |format|\n format.html { redirect_to dailyfeatureds_url, notice: 'Dailyfeatured was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @thirtyeight.destroy\n respond_to do |format|\n format.html { redirect_to thirtyeights_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @important_date.destroy\n respond_to do |format|\n format.html { redirect_to important_dates_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @skydatum = Skydatum.find(params[:id])\n @skydatum.destroy\n\n respond_to do |format|\n format.html { redirect_to skydata_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @six.destroy\n respond_to do |format|\n format.html { redirect_to sixes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @workday.destroy\n respond_to do |format|\n format.html { redirect_to dashboard_path, notice: 'Workday was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @spec_day.destroy\n respond_to do |format|\n format.html { redirect_to spec_days_url, notice: 'Spec day was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @default_line_calendar.destroy\n respond_to do |format|\n format.html { redirect_to default_line_calendars_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @holiday.destroy\n\n respond_to do |format|\n format.html { redirect_to holidays_url, notice: 'El Feriado fue Eliminado.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @hotel_stay = HotelStay.find(params[:id])\n @hotel_stay.destroy\n\n respond_to do |format|\n format.html { redirect_to hotel_stays_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @availability_day = AvailabilityDay.find(params[:id])\n @availability_day.destroy\n\n respond_to do |format|\n format.html { redirect_to(availability_days_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @extra_holiday.destroy\n respond_to do |format|\n format.html { redirect_to extra_holidays_url, notice: 'Extra holiday was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @daily_data_payment.destroy\n respond_to do |format|\n format.html { redirect_to daily_data_payments_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @battery_weekly_test = BatteryWeeklyTest.find(params[:id])\n @battery_weekly_test.destroy\n\n respond_to do |format|\n format.html { redirect_to battery_battery_weekly_tests_url(@battery_weekly_test.battery) }\n format.json { head :no_content }\n end\n end", "def destroy\n @dailybank.destroy\n respond_to do |format|\n format.html { redirect_to dailybanks_url, notice: 'Dailybank was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def deletef\n url = prefix + \"deletef\" + id_param\n return response(url)\n end", "def destroy\n @week_day.destroy\n respond_to do |format|\n format.html { redirect_to week_days_url, notice: 'Week day was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @consensu = Consensu.find(params[:id])\n @consensu.destroy\n\n respond_to do |format|\n format.html { redirect_to consensus_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @gaz_assay = GazAssay.find(params[:id])\n @gaz_assay.destroy\n\n respond_to do |format|\n format.html { redirect_to gaz_assays_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @calificacione = Calificacione.find(params[:id])\n @calificacione.destroy\n\n respond_to do |format|\n format.html { redirect_to calificaciones_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @federal1870_census_entry = Federal1870CensusEntry.find(params[:id])\n @federal1870_census_entry.destroy\n\n respond_to do |format|\n format.html { redirect_to federal1870_census_entries_url }\n format.json { head :no_content }\n end\n end", "def delete(path)\n RestClient.delete request_base+path\n end", "def destroy\n @weekday_constraint.destroy\n respond_to do |format|\n format.html { redirect_to weekday_constraints_url, notice: 'Weekday constraint was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @fee = Fee.find(params[:id])\n @fee.destroy\n\n respond_to do |format|\n format.html { redirect_to fees_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @workout_day = WorkoutDay.find(params[:id])\n @workout_day.destroy\n\n respond_to do |format|\n format.html { redirect_to workout_days_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @rebate = Rebate.find(params[:id])\n @rebate.destroy\n\n respond_to do |format|\n format.html { redirect_to rebates_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @workday = Workday.find(params[:id])\n @workday.destroy\n\n respond_to do |format|\n format.html { redirect_to(workdays_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @heartbeat = Heartbeat.find(params[:id])\n @heartbeat.destroy\n\n respond_to do |format|\n format.html { redirect_to heartbeats_url }\n format.json { head :no_content }\n end\n end", "def delete path\n make_request(path, \"delete\", {})\n end", "def destroy\n\n @paid_offdays = PaidOffday.all\n @paid_offday = PaidOffday.find(params[:id])\n @paid_offday.destroy\n\n\n=begin\n @paid_offday.destroy\n respond_to do |format|\n format.html { redirect_to paid_offdays_url, notice: 'Paid offday was successfully destroyed.' }\n format.json { head :no_content }\n end\n=end\n end", "def destroy\n @sgda_seller_goal_day.destroy\n respond_to do |format|\n format.html { redirect_to sgda_seller_goal_days_url, notice: 'Sgda seller goal day was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @day_week = DayWeek.find(params[:id])\n @day_week.destroy\n\n respond_to do |format|\n format.html { redirect_to day_weeks_url, :notice => 'Dia da semana excluído com sucesso.' }\n format.json { head :no_content }\n end\n end", "def destroy\n event = @event_day.destroy\n @event_day.destroy\n respond_to do |format|\n format.html { redirect_to :back, notice: 'Event day was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @backlog_entry = BacklogEntry.find(params[:id])\n @backlog_entry.destroy\n\n respond_to do |format|\n format.html { redirect_to backlog_entries_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @forecast_72.destroy\n respond_to do |format|\n format.html { redirect_to forecast_72s_url, notice: 'Forecast 72 was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n\n @unpaid_offdays = UnpaidOffday.all\n @unpaid_offday = UnpaidOffday.find(params[:id])\n @unpaid_offday.destroy\n\n=begin\n @unpaid_offday.destroy\n respond_to do |format|\n format.html { redirect_to unpaid_offdays_url, notice: 'Unpaid offday was successfully destroyed.' }\n format.json { head :no_content }\n end\n=end\n end", "def destroy\n @night.destroy\n respond_to do |format|\n format.html { redirect_to nights_url, notice: 'Night was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @food = Food.find(params[:id])\n @food.destroy\n\n respond_to do |format|\n format.html { redirect_to foods_url }\n format.json { head :ok }\n end\n end" ]
[ "0.67711014", "0.6717281", "0.6709792", "0.66702175", "0.66188335", "0.66172785", "0.66040945", "0.66011256", "0.65438354", "0.6541761", "0.65403503", "0.65228885", "0.6511923", "0.6509053", "0.6505492", "0.64925", "0.6491775", "0.64911705", "0.6463169", "0.6442766", "0.6441526", "0.64396346", "0.64380205", "0.6416396", "0.6410902", "0.6401807", "0.63934106", "0.6382861", "0.6374583", "0.63743156", "0.6361166", "0.63504046", "0.6341844", "0.6331424", "0.6326797", "0.63241154", "0.6321837", "0.6313606", "0.63114244", "0.63103396", "0.631003", "0.63046235", "0.63022876", "0.6301001", "0.63004315", "0.6299039", "0.62969756", "0.6287865", "0.628386", "0.627829", "0.6277375", "0.62765664", "0.6273407", "0.62725216", "0.625971", "0.62540615", "0.6253451", "0.6245058", "0.6244863", "0.62422067", "0.6239134", "0.6232046", "0.6230283", "0.62286997", "0.622857", "0.62222683", "0.6221286", "0.6214195", "0.6212606", "0.6211735", "0.62113786", "0.62078303", "0.6205688", "0.6204895", "0.6199406", "0.6186632", "0.6186481", "0.6185303", "0.61820364", "0.61797875", "0.61781937", "0.61756337", "0.6175029", "0.61738896", "0.6171383", "0.61709195", "0.6170254", "0.61690485", "0.61676323", "0.6164906", "0.61646646", "0.61641794", "0.61603093", "0.61588544", "0.6157575", "0.6152498", "0.6152251", "0.61512214", "0.61506504", "0.6149916" ]
0.69452596
0
Use callbacks to share common setup or constraints between actions.
def set_black_friday @black_friday = BlackFriday.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_eval do\n define_method(:valid?) do |*args|\n self.class.state_machines.fire_event_attributes(self, :save, false) { super(*args) }\n end\n end\n end\n end", "def add_actions; end", "def callbacks; end", "def callbacks; end", "def setup *actions, &proc\n (@setup_procs ||= []) << [proc, actions.size > 0 ? actions : [:*]]\n end", "def define_action_helpers; end", "def post_setup\n end", "def action_methods; end", "def action_methods; end", "def action_methods; end", "def before_setup; end", "def action_run\n end", "def execute(setup)\n @action.call(setup)\n end", "def define_action_helpers?; end", "def set_actions\n actions :all\n end", "def action_done(action)\n dispatch = { :migrate => :done_migrating, :map => :done_mapping, :reduce =>\n :done_reducing, :finalize => :done_finalizing } \n self.send dispatch[action[:action]], action\n end", "def dependencies action, &block\n @actions.each do |other|\n if action[:requires].include? other[:provide]\n block.call other\n end\n end\n end", "def setup!\n return unless @setup_procs\n http_actions = actions\n @setup_procs.each do |setup_proc|\n proc, actions = setup_proc\n @setup__actions = actions.map do |action|\n\n action.is_a?(Regexp) ?\n http_actions.select { |a| a.to_s =~ action } :\n action.is_a?(String) && action =~ /\\A\\./ ?\n http_actions.map { |a| a.to_s << action if format?(a).include?(action) }.compact :\n action\n\n end.flatten\n self.class_exec &proc\n @setup__actions = nil\n end\n @setup_procs = nil\n end", "def before_actions(*logic)\n self.before_actions = logic\n end", "def setup_handler\n end", "def set_action(opts)\n opts = check_params(opts,[:actions])\n super(opts)\n end", "def setup(action)\n @targets.clear\n unless action.item.target_filters.empty?\n @targets = SES::TargetManager.make_targets(action)\n else\n item = action.item\n if item.for_opponent?\n @targets = $game_troop.alive_members\n elsif item.for_dead_friend?\n @targets = $game_party.battle_members.select { |actor| actor.dead? }\n else\n $game_party.battle_members.select { |actor| actor.alive? }\n end\n end\n @item_max = @targets.size\n create_contents\n refresh\n show\n activate\n end", "def action; end", "def action; end", "def action; end", "def action; end", "def action; end", "def workflow\n end", "def revisable_shared_setup(args, block)\n class << self\n attr_accessor :revisable_options\n end\n options = args.extract_options!\n self.revisable_options = Options.new(options, &block)\n \n self.send(:include, Common)\n self.send(:extend, Validations) unless self.revisable_options.no_validation_scoping?\n self.send(:include, WithoutScope::QuotedColumnConditions)\n end", "def setup\n @action = SampleActionAndroid.new(os_name: 'android',\n app_name: APP_PATH)\n end", "def before(action)\n invoke_callbacks *self.class.send(action).before\n end", "def process_action(...)\n send_action(...)\n end", "def before_dispatch(env); end", "def after_actions(*logic)\n self.after_actions = logic\n end", "def setup\n # override and do something appropriate\n end", "def setup(client)\n return unless @setup\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n actions.each do |action|\n action.execute(client)\n end\n self\n end", "def setup(_context)\n end", "def setup(resources) ; end", "def validate_actions\n errors.add(:base, :should_give_at_least_one_action) if !manage? && !forecasting? && !read? && !api?\n end", "def setup\n @resource_config = {\n :callbacks => {\n :before_create => nil,\n :after_create => nil,\n :before_update => nil,\n :after_update => nil,\n :before_destroy => nil,\n :after_destroy => nil,\n },\n :child_assoc => nil,\n :model => nil,\n :parent => nil,\n :path => nil,\n :permission => {},\n :properties => {},\n :relation => {\n :create => nil,\n :delete => nil,\n },\n :roles => nil,\n }\n end", "def determine_valid_action\n\n end", "def process_shared\n handle_taxes\n handle_shippings\n create_adjustments_from_params\n handle_status\n handle_inventory_refunds\n handle_payment_transactions\n order.updater.update\n end", "def startcompany(action)\n @done = true\n action.setup\n end", "def init_actions\n am = action_manager()\n am.add_action(Action.new(\"&Disable selection\") { @selection_mode = :none; unbind_key(32); bind_key(32, :scroll_forward); } )\n am.add_action(Action.new(\"&Edit Toggle\") { @edit_toggle = !@edit_toggle; $status_message.value = \"Edit toggle is #{@edit_toggle}\" })\n end", "def event_callbacks(event, metadata={})\n case event\n when :reset, :review\n if confirmed\n update_attributes(confirmed: false)\n end\n when :confirm\n confirm\n # trigger :order for all applicable items\n # NOTE: :order event is common to both physical and digital items\n items.each do |i|\n if i.event_permitted(:order)\n user_id = last_transition.user_id\n i.trigger!(:order, { order_id: id, user_id: user_id })\n end\n end\n when :complete_work\n request = metadata[:request]\n work_complete_notification(request)\n when :close\n close\n end\n if event != :close && !open\n reopen\n end\n end", "def setup_action\n return unless PONY::ERRNO::check_sequence(current_act)\n new_sequence = @action_sequence[@sequence_index+1...@action_sequence.size]\n @sequence_index = 0\n new_sequence = DND::SkillSequence::ACTS[@acts[1]] + new_sequence\n execute_sequence\n end", "def define_tasks\n define_weave_task\n connect_common_tasks\n end", "def setup(&block)\n define_method(:setup, &block)\n end", "def setup\n transition_to(:setup)\n end", "def setup\n transition_to(:setup)\n end", "def action\n end", "def setup( *args )\n\t\t\tself.class.setupBlocks.each {|sblock|\n\t\t\t\tdebugMsg \"Calling setup block method #{sblock}\"\n\t\t\t\tself.send( sblock )\n\t\t\t}\n\t\t\tsuper( *args )\n\t\tend", "def config(action, *args); end", "def setup\n @setup_proc.call(self) if @setup_proc\n end", "def before_action \n end", "def setup_callbacks\n defined_callbacks.each do |meth|\n unless respond_to?(\"call_#{meth}_callbacks\".to_sym)\n self.class.module_eval <<-EOE\n def call_#{meth}_callbacks(*args)\n plugin_store.each {|a| a.call_#{meth}_callbacks(*args) } if respond_to?(:plugin_store) && plugin_store\n self.send :#{meth}, *args if respond_to?(:#{meth})\n end\n EOE\n end\n end\n end", "def action\n end", "def matt_custom_action_begin(label); end", "def setup\n # override this if needed\n end", "def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend", "def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend", "def action(options,&callback)\n new_action = Action===options ? options : Action.new(options,&callback)\n # replace any with (shared name/alias or both default) + same arity\n @actions.delete_if do |existing_action|\n ((existing_action.names & new_action.names).size > 0 ||\n existing_action.default? && new_action.default?) &&\n existing_action.required.size == new_action.required.size &&\n existing_action.optional.size <= new_action.optional.size\n end\n @actions = (@actions + [new_action]).sort\n new_action\n end", "def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action\n end", "def after(action)\n invoke_callbacks *options_for(action).after\n end", "def pre_task\n end", "def setup(server)\n server.on('beforeMethod', method(:before_method), 10)\n end", "def add_actions\n attribute = machine.attribute\n name = self.name\n \n owner_class.class_eval do\n define_method(name) {self.class.state_machines[attribute].events[name].fire(self)}\n define_method(\"#{name}!\") {self.class.state_machines[attribute].events[name].fire!(self)}\n define_method(\"can_#{name}?\") {self.class.state_machines[attribute].events[name].can_fire?(self)}\n end\n end", "def init_actions\n @select_action = SelectAction.new\n @endpoint_mouse_action = EndpointMouseAction.new\n @move_action = MoveAction.new\n end", "def setup_signals; end", "def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend", "def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend", "def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action.respond_to?('weak!') ? action.weak! : action\n end", "def initialize(*args)\n super\n @action = :set\nend", "def after_set_callback; end", "def setup\n #implement in subclass;\n end", "def lookup_action; end", "def setup &block\n if block_given?\n @setup = block\n else\n @setup.call\n end\n end", "def setup_action\n return TSBS.error(@acts[0], 1, @used_sequence) if @acts.size < 2\n actions = TSBS::AnimLoop[@acts[1]]\n if actions.nil?\n show_action_error(@acts[1])\n end\n @sequence_stack.push(@acts[1])\n @used_sequence = @acts[1]\n actions.each do |acts|\n @acts = acts\n execute_sequence\n break if @break_action\n end\n @sequence_stack.pop\n @used_sequence = @sequence_stack[-1]\n end", "def release_actions; end", "def around_hooks; end", "def save_action; end", "def setup(easy)\n super\n easy.customrequest = @verb\n end", "def action_target()\n \n end", "def setup\n callback(:setup) do\n notify(:setup)\n migration_check.last_deployed_commit\n end\n end", "def setup\n return unless @setup\n\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n run_actions_and_retry(actions)\n self\n end", "def before_setup\n # do nothing by default\n end", "def my_actions(options)\n @setup = false\n get_template_part(\"custom_used\",\"action_users\",true)\n end", "def default_action; end", "def setup(&blk)\n @setup_block = blk\n end", "def callback_phase\n super\n end", "def advice\n end", "def _handle_action_missing(*args); end", "def duas1(action)\n action.call\n action.call\nend", "def shared_action(name, &block)\n @controller.shared_actions[name] = block\n end", "def before_action action, &block\n @audience[:before][action] ||= Set.new\n @audience[:before][action] << block\n end", "def setup_initial_state\n\n state_a = State.new(\"a\", 0)\n state_b = State.new(\"b\", 0)\n state_c = State.new(\"c\", 10)\n\n move_to_b = Action.new(\"move_to_b\", 1, state_b)\n\n move_to_c = Action.new(\"move_to_c\", 1, state_c)\n\n state_a.actions = [move_to_b, move_to_c]\n\n return state_a\n \nend" ]
[ "0.6163163", "0.6045976", "0.5946146", "0.591683", "0.5890051", "0.58349305", "0.5776858", "0.5703237", "0.5703237", "0.5652805", "0.5621621", "0.54210985", "0.5411113", "0.5411113", "0.5411113", "0.5391541", "0.53794575", "0.5357573", "0.53402257", "0.53394014", "0.53321576", "0.53124547", "0.529654", "0.5296262", "0.52952296", "0.52600986", "0.52442724", "0.52385926", "0.52385926", "0.52385926", "0.52385926", "0.52385926", "0.5232394", "0.523231", "0.5227454", "0.52226824", "0.52201617", "0.5212327", "0.52079266", "0.52050185", "0.51754695", "0.51726824", "0.51710224", "0.5166172", "0.5159343", "0.51578903", "0.51522785", "0.5152022", "0.51518047", "0.51456624", "0.51398855", "0.5133759", "0.5112076", "0.5111866", "0.5111866", "0.5110294", "0.5106169", "0.509231", "0.50873137", "0.5081088", "0.508059", "0.50677156", "0.50562143", "0.5050554", "0.50474834", "0.50474834", "0.5036181", "0.5026331", "0.5022976", "0.5015441", "0.50121695", "0.5000944", "0.5000019", "0.4996878", "0.4989888", "0.4989888", "0.49864885", "0.49797225", "0.49785787", "0.4976161", "0.49683493", "0.4965126", "0.4958034", "0.49559742", "0.4954353", "0.49535993", "0.4952725", "0.49467874", "0.49423352", "0.49325448", "0.49282882", "0.49269363", "0.49269104", "0.49252945", "0.4923091", "0.49194667", "0.49174926", "0.49173003", "0.49171105", "0.4915879", "0.49155936" ]
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def black_friday_params params.require(:black_friday).permit(:user_id, :product_id, :gender, :age, :occupation, :city_category, :stay_in_current_city_years, :marital_status, :product_category_1, :product_category_2, :product_category_3, :purchase) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strong_params\n params.require(:user).permit(param_whitelist)\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def allow_params_authentication!; end", "def allowed_params\n ALLOWED_PARAMS\n end", "def default_param_whitelist\n [\"mode\"]\n end", "def param_whitelist\n [:role, :title]\n end", "def expected_permitted_parameter_names; end", "def safe_params\n params.except(:host, :port, :protocol).permit!\n end", "def strong_params\n params.require(:team_member).permit(param_whitelist)\n end", "def permitir_parametros\n \t\tparams.permit!\n \tend", "def strong_params\n params.require(:community).permit(param_whitelist)\n end", "def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end", "def strong_params\n params.require(:education).permit(param_whitelist)\n end", "def restricted_params\n #params.require(self.controller_name.classify.underscore.to_sym).permit([])\n raise(\"No strong params set, override restricted_params method in your controller. E.g. params.require(:model).permit(:attribute1, :attribute2)\")\n end", "def allowed_params\n params.require(:user).permit(:username, :email, :password, :password_confirmation)\n end", "def param_whitelist\n [:rating, :review]\n end", "def param_whitelist\n whitelist = [\n :username, :name,\n :parent_id,\n :headline, :description, :video,\n :policy, :signup_mode, :category,\n :website, :facebook, :twitter, :linkedin,\n :founded_at,\n privacy: [\n :events,\n :resources\n ],\n permission: [\n :profile,\n :members,\n :children,\n :statistics,\n :posts,\n :listings,\n :resources,\n :events\n ],\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:parent_id)\n unless current_user.role_in(@community) === 'owner'\n whitelist.delete(:privacy)\n whitelist.delete(:permission)\n end\n end\n \n whitelist\n end", "def param_whitelist\n if @user.present? && current_user != @user\n return [:followed]\n end\n \n whitelist = [\n :username, :email, :password,\n :first_name, :last_name,\n :birthday, :gender,\n :headline, :biography, :ask_about, :focus,\n :website, :facebook, :linkedin, :twitter, :github,\n roles: [],\n skills: [],\n interests: [],\n privacy: { contact: [] },\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:email)\n whitelist.delete(:password)\n end\n \n whitelist\n end", "def user_params \n \tparams.require(:user).permit(:name, :email, :password, :password_confirmation)# preventing CSTR\n end", "def user_params\n params.permit(:name, :phoneNumber, :address, :postalCode, :local, :link, :counter, :latitude, :longitude) \n end", "def valid_params_request?; end", "def strong_params\n params.require(:experience).permit(param_whitelist)\n end", "def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end", "def whitelist_url_params\n params.require(:whitelist_url).permit(:domain)\n end", "def allowed_params\n params.require(:allowed).permit(:email)\n end", "def permitted_params\n []\n end", "def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end", "def safe_params\n params.permit(:id, :name, :origin, :emails => []); #emails is an array\n end", "def query_param\n\t\tparams.permit(:first_name, :last_name, :phone)\n\tend", "def strong_params\n params.require(:success_metric).permit(param_whitelist)\n end", "def devise_filter\r\n logger.debug(\"In devise_filter =>PARAMS: #{params.inspect}\")\r\n\r\n # White list for sign_up\r\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(user_whitelist) }\r\n\r\n # White list for account update\r\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(user_whitelist, :current_password) }\r\n\r\n # White list for Invitation creation\r\n devise_parameter_sanitizer.for(:invite) { |u| u.permit(:account_type, :email, :invitation_token)}\r\n\r\n # White list for accept invitation\r\n devise_parameter_sanitizer.for(:accept_invitation) { |u| u.permit(user_whitelist, :invitation_token)}\r\n\r\n end", "def whitelisted_user_params\n params.require(:user).\n permit( :first_name, :last_name, :email,:password,:password_confirmation,:birthday,:gender)\n end", "def user_params\n ActionController::Parameters.permit_all_parameters = true\n params.require(:user) #.permit(:name, :surname, :phone, :password, :email, :time_zone)\n end", "def strong_params\n params.require(:metric_change).permit(param_whitelist)\n end", "def safe_params\n params.require(:user).permit(:name)\n end", "def get_params\n\t\treturn ActionController::Parameters.new(self.attributes).permit(\"account_id\", \"title\", \"category\", \"introduction\", \"tags\", \"segment_type\", \"visible\", \"status\", \"main_image\")\n\tend", "def grant_params\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\n end", "def check_params; true; end", "def param_whitelist\n whitelist = [\n :description,\n :progress,\n :kpi_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:kpi_id)\n end\n \n whitelist\n end", "def quote_params\n params.permit!\n end", "def valid_params?; end", "def paramunold_params\n params.require(:paramunold).permit!\n end", "def user_params\n\t\tparams.permit(:nickname, :avatar, :description, :password, :gender, :birthday, :email, :phone, :qq_id, :wechat_id)\n\tend", "def filtered_parameters; end", "def user_params\n params.permit(\n \t:id,\n \t:email, \n \t:first_name, \n \t:last_name, \n \t:password, \n \t:confirm_token, \n \t:phone_number,\n \t:facebook_link,\n \t:car_model,\n \t:license_plate)\n end", "def filtering_params\n params.permit(:email, :name)\n end", "def check_params\n true\n end", "def wx_public_params\n params.require(:wx_public).permit(:nickname, :manager, :alias)\n end", "def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end", "def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end", "def listing_params\n\t\tparams.permit(:address, :transit_info, :rules, :other_info, :lat, :lng)\n\tend", "def social_account_params\n\t\t\tparams.require(:social_account).permit!\n\t\tend", "def safe_params\n resurce_name = self.class.resource_name\n params_method_name = \"#{resurce_name}_params\".to_sym\n if params[resurce_name]\n if respond_to?(params_method_name) || private_methods.include?(params_method_name)\n send(params_method_name)\n else\n raise ActiveModel::ForbiddenAttributesError, \"Please, define the '#{params_method_name}' method in #{self.class.name}\"\n end\n end\n end", "def url_params\n params.require(:url).permit(:short_url, :original_url, :clicks, :ip_addresses)\n end", "def user_params\n params.require(:user).permit(:uri, :username, :password, :realname, :email, :publicvisible)\n end", "def model_params\n\t\tparams.require(:manager).permit(\n\t :user_name,\n :password,\n :email,\n \t\t\t)\n\tend", "def article_params_whitelist\n params.require(:article).permit(:title, :description, category_ids: [])\n end", "def college_whitelist_params\n params.require(:college_whitelist).permit(:status)\n end", "def active_code_params\n params[:active_code].permit\n end", "def filtering_params\n params.permit(:email)\n end", "def valid_params(params)\n params.permit(:user_id, :photo_id, :originX, :originY, :width, :height)\n end", "def ip_address_params\n\t\t\tparams.require(:ip_address).permit!\n end", "def pull_request_params\n whitelist = [\n :url,\n :id,\n :html_url,\n :diff_url,\n :patch_url,\n :issue_url,\n :number,\n :state,\n :locked,\n :title\n ]\n params.require(:pull_request).permit(whitelist)\n end", "def reserved_params\n params.require(:reserved).permit(:name, :email, :pax, :address, :KTP, :title)\n end", "def post_params\n if current_user.admin? \n params.permit(:title, :body, :city, :country, :gps_location, :privacy, :visible, :latitude, :longitude, images: [], files: [])\n else \n params.permit(:title, :body, :city, :country, :gps_location, :privacy,:latitude, :longitude, images: [], files: [])\n end \n end", "def list_params\n params.permit(:name)\n end", "def filter_parameters; end", "def filter_parameters; end", "def vineyard_params\n params.permit(:vineyard_name, :email, :website_url, :phone, :address, :city, :region, :postcode, :country, :specialty, :description, :pet_friendly, :holiday, :tours, :events, :family_friendly, :cover_image, :image_one, :image_two, :image_three, :image_four, :user_id, :base64)\n end", "def available_activity_params\n # params.require(:available_activity).permit(:type,:geometry,:properties)\n whitelisted = ActionController::Parameters.new({\n type: params.require(:available_activity)[:type],\n geometry: params.require(:available_activity)[:geometry].try(:permit!).to_h,\n properties: params.require(:available_activity)[:properties].try(:permit!).to_h\n }).try(:permit!)\n end", "def user_params\n params.permit(:name, :username, :email, :password, :img_url, :bg_url, :coinbank)\n end", "def user_params_pub\n\t \tparams[:user].permit(:hruid)\n\t end", "def user_params\n params.permit(:id, :email, :password, :nickname, :status, :avatar, :flat_picture, :flatsharing_id, :member,\n :user, :color, :solde)\n end", "def validate_search_inputs\n @whitelisted = params.fetch(:user, nil)\n if @whitelisted.blank?\n render_error(400, \"#{I18n.t('general_error.params_missing_key')}\": [I18n.t('general_error.params_missing_value', model: \"review\")])\n return\n else\n @whitelisted = @whitelisted.permit(:name, :uen, :description)\n end\n end", "def param_whitelist\n [\n :title,\n :description,\n :organization,\n :team_id,\n :started_at,\n :finished_at,\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n end", "def url_whitelist; end", "def admin_social_network_params\n params.require(:social_network).permit!\n end", "def filter_params\n params.require(:filters).permit(:letters)\n end", "def origin_params\n params.permit(:country, :state, :city, :postal_code, :address, :description)\n end", "def valid_params(params)\n params.permit(:login, :first_name, :last_name, \n :password, :password_confirmation)\n end", "def sensitive_params=(params)\n @sensitive_params = params\n end", "def permit_request_params\n params.permit(:address)\n end", "def user_params\n # Ensure a user can't give themselves admin priveleges\n params.delete(:admin) if current_user.admin?\n params.require(:user).permit(:name, :email, :admin, :image)\n end", "def secure_params\n params.require(:location).permit(:name)\n end", "def strong_params\n params.require( :setting ).\n permit( :global_scan_limit, :per_user_scan_limit,\n :target_whitelist_patterns, :target_blacklist_patterns )\n end", "def question_params\n params.require(:survey_question).permit(question_whitelist)\n end", "def case_insensitive_params\n params.require(:case_insensitive).permit(:name)\n end", "def empire_master_no_match_params\n params.require(:empire_master_no_match).permit(:uid, :last_name, :list, :search_date, :double, :source)\n end", "def maintenance_request_params\n params[:maintenance_request].permit! #allow all parameters for now\n end", "def unwanted_params\n params.require(:unwanted).permit(:title, :description, :image)\n end", "def url_params\n params[:url].permit(:full)\n end", "def backend_user_params\n params.permit!\n end", "def filter_params\n\t\treturn params[:candidate].permit(:name_for_filter)\n\tend", "def speed_measurement_params\n\n #fuckit, to lazy to deal with permit crap right now\n ActionController::Parameters.permit_all_parameters = true\n\n params[:speed_measurement]\n end", "def user_params\n params.permit(:name, :age, :username, :display_photo, :password)\n end", "def get_params\r\n #params.require(:article).permit(:title, :permalink, :content, :source_site, :introtext, :type_id, :order_by, :searchable, :created_by, :edited_by, :published_by, :published_on, :user_id)\r\n params.require(:article).permit!\r\n\r\n end", "def pub_params\n params.require(:pub).permit(:name, :description, :phone, :email, :hidden, :city_id, :address)\n end", "def pass_params\n params[:pass].permit(:name, :price, :description, :colour, :events)\n end", "def droptraining_params\n params.permit(:training_id,:user_id, :utf8, :authenticity_token, :commit)\n end", "def person_params\n # params whitelist does *not* include admin, sub, remember_token\n # TBD: share this whitelist with the list used by configuration_permitted_parameters\n # TBD: should current_password be on this list? -- for now, leaving off, since it seems to work without\n # NOTE: do not include 'admin' in this list!\n params.require(:person).permit(\n :name, \n :email, \n :description,\n :password, \n :password_confirmation\n )\n end", "def parameter_params\n params.require(:parameter).permit(:name, :description, :param_code, :param_value, :active_from, :active_to)\n end" ]
[ "0.69792545", "0.6781151", "0.67419964", "0.674013", "0.6734356", "0.6591046", "0.6502396", "0.6496313", "0.6480641", "0.6477825", "0.64565", "0.6438387", "0.63791263", "0.63740575", "0.6364131", "0.63192815", "0.62991166", "0.62978333", "0.6292148", "0.6290449", "0.6290076", "0.62894756", "0.6283177", "0.6242471", "0.62382483", "0.6217549", "0.6214457", "0.6209053", "0.6193042", "0.6177802", "0.6174604", "0.61714715", "0.6161512", "0.6151757", "0.6150663", "0.61461", "0.61213595", "0.611406", "0.6106206", "0.6105114", "0.6089039", "0.6081015", "0.6071004", "0.60620916", "0.6019971", "0.601788", "0.6011056", "0.6010898", "0.6005122", "0.6005122", "0.6001556", "0.6001049", "0.59943926", "0.5992201", "0.59909594", "0.5990628", "0.5980841", "0.59669393", "0.59589154", "0.5958826", "0.5957911", "0.5957385", "0.5953072", "0.59526145", "0.5943361", "0.59386164", "0.59375334", "0.59375334", "0.5933856", "0.59292704", "0.59254247", "0.5924164", "0.59167904", "0.59088355", "0.5907542", "0.59064597", "0.5906243", "0.5898226", "0.589687", "0.5896091", "0.5894501", "0.5894289", "0.5891739", "0.58860534", "0.5882406", "0.587974", "0.58738774", "0.5869024", "0.58679986", "0.5867561", "0.5865932", "0.5864461", "0.58639693", "0.58617616", "0.5861436", "0.5860451", "0.58602303", "0.5854586", "0.58537364", "0.5850427", "0.5850199" ]
0.0
-1
METHOD: initialise word game INPUT: secret word as string OUTPUT: WordGame instance
def initialize(secret) @secret = secret @guess_count = secret.length @word_state = ["_"] * secret.length @guesses = [] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def initialize(secret_word)\n puts \"Initializing game for new secret word...\"\n @secret_word = secret_word\n @current_state = \"\"\n secret_word.length.times { @current_state << \"_\" }\n @prev_guesses = []\n @available_guesses = secret_word.length\n @is_over_won = false\n end", "def initialize(word)\n start_new_game(word)\n end", "def initialize(word)\r\n\t\t\r\n# \ti. Put a initializing game statement on the screen\r\n\tputs \"Initializing game...\"\r\n# \tii. Instance variables for:\r\n# \t \ta. The word (entered by first user - the word to be guessed)\r\n\t\t@word = word\r\n# \t \tb. Split the word into letters that can be guessed and assign to a new instance variable\r\n\t\t@word_split = word.split(\"\")\r\n# \t \tc. Default a guess count instance variable to start at 0\r\n\t\t@guess_count = 0 \r\n# \t \td. The chances of winning the game based on the amount of guesses you have. \r\n\t\t@chance = word.length\r\n# \t \te. Amt of guesses should be assigned to a variable using the length of the word to be guessed.\r\n\t\t@guessed = Array.new(word.length, \"_\")\r\n# \t \tf. Set variable to false for end of game\r\n\t\t@end_game = false\r\n# \t \tg. Letter guessed assigned to a variable.\r\n\t\t@letter_guessed = letter_guessed\r\n\tend", "def initialize(word)\n\t\t@word = word\n\t\t@guesses = word.length\n\t\t# Initialize a instance variable with empty hash.\n\t\t@guessed_words = {}\n\t\t# Initialize the game_end to boolean false \n\t\t@game_end = false\n\t\t# Index is used to replace the dashes with the correct guess.\n\t\t@index = 0\n\t\t# Initialize the hidden word with dashes instead of alphabets.\n\t\t@hidden_word = word.tr(word,\"-\")\n\tend", "def initialize(word)\n\t\t@word = word\n\t\t@guesses = word.length\n\t\t@game_over = false\n\t\t@letters = []\n\tend", "def initialize(player1, player2, secret_word)\n @player1 = player1\n @player2 = player2\n @secret_word = secret_word\n\t\t# Code: Split the string into characters\n\t\t# Output: array of characters (secret_word_arr) \n @secret_word_arr = secret_word.chars\n \t@word_length = @secret_word_arr.length\n \t@guess_count = 0\n @is_over = false\n # @guess = nil\n @guesses = []\n\tend", "def init_word_board\r\n\t\t if @resulta.size == 0\r\n\t\t\t\t\t\t\treadwordfile(@filename)\r\n\t\t\t\t\t\t\t@descr = @phrases\r\n\t\t\t\t\t\t\tsetsecretword(gensecretword)\r\n\t\t\t\t\t\tend\r\n\t\t end", "def initialize(word = nil, hidden_word = nil)\r\n @word = word.gsub(\"\\n\", \"\").split('') unless word == nil\r\n @hidden_word = hidden_word.split(' ') unless word == nil\r\n @word ||= Hangman::Dictionary.generate_word.gsub(\"\\n\", \"\").split('')\r\n @hidden_word ||= @word.map {|letter| letter = \" _ \"}\r\n end", "def initialize(word)\r\n\r\n\t\t@word_array = word.split('')\r\n\t\t@board_array = []\r\n\t\t@guesses = []\r\n\r\n\t\t#Set board\r\n\t\t@word_array.length.times do\r\n\t\t\t@board_array << \"_\"\r\n\t\tend\r\n\r\n\t\t@num_of_guesses = 0\r\n\t\t@is_over = false\r\n\r\n\tend", "def initialize(word=WordGuesserGame.get_random_word, guesses = '',wrong_guesses='')\n @word = word\n @guesses = guesses\n @wrong_guesses = wrong_guesses\n end", "def initialize(word)\r\n\t\tputs \"game initializing\"\r\n\t\t@guessed_letters = []\r\n\t\t@word = word\r\n\t\ttemp = word.downcase.delete(' ')\r\n \t@secret_word = temp.split('')\r\n \t\r\n \t@guess_count = word.length.to_i + 4\r\n \tif(guess_count > 26)\r\n \t\tguess_count = 24\r\n \tend\r\n \r\n \t@gameover = false\r\n\r\n\t\tshow_progress(secret_word,guessed_letters)\r\n\r\n \twhile @gameover == false \r\n \t\r\n begin\r\n\t\t\t puts \"guess a letter or the word: \"\r\n\t\t\t letter = gets.chomp\r\n letter = letter.downcase\r\n \r\n \r\n end until @guessed_letters.include?(letter) == false\r\n if (letter == temp)\r\n puts \"Letters guessed #{guessed_letters}\"\r\n puts \"YOU WIN by means of guessing the word\"\r\n break\r\n end\r\n\r\n\t\t\t@guessed_letters.push(letter)\r\n\t\t\tguess(letter,secret_word)\r\n\t\t\tputs \"Letters guessed #{guessed_letters}\"\r\n\t\t\tshow_progress(secret_word,guessed_letters)\r\n\t\t\t\r\n\r\n\r\n\t\t end\r\n\r\n \tend", "def initialize()\n @word = get_random_word\n @guesses = ''\n @wrong_guesses = ''\n end", "def initialize()\n @word = ''\n @guesses = ''\n @wrong_guesses = ''\n @word_with_guesses = '-'*word.length\n @check_win_or_lose = :play\n end", "def initialize(word)\n @word = word\n @guesses = \"\"\n @wrong_guesses = \"\"\n @word_with_guesses = word.gsub(/./, \"-\") \n @check_win_or_lose = :play\n @wrong_count = 0\n end", "def initialize(win_word)\r\n\t# Set winning word\r\n\t\t@win_word = win_word\r\n\t# Initialize remaining guesses to win_word length plus 5\r\n\t\t@remaining_guesses = win_word.length + 5\r\n\t# Initialize array to store past guesses to check for repeats\r\n\t\t@past_guesses = []\r\n\t# Initialize string to represent current state of word, or, hint\r\n\t\thint = \"\"\r\n\t\thint_length = win_word.length\r\n\t\thint_length.times { hint = hint + \"_ \" }\r\n\t\t@hint = hint\r\n\t\tputs \"Ok! User 2 please take over.\"\r\n\t\tputs \"Guess the word!\"\r\n\t\tputs \"Here's a hint: #{@hint}\"\r\n\tend", "def initialize(word, image)\n @word = word\n @correct_guesses = Array.new(word.game_word.length)\n @dashes = Array.new(word.game_word.length, \"-\")\n @guesses = []\n @counter = 0\n @image = image\n end", "def initialize(word)\n @word = word #instanciates a new instance of `word`\n end", "def initialize(word)\n @word = word.downcase\n @guesses = ''\n @wrong_guesses = ''\n @word_with_guesses = \" \"\n for i in 0...@word.length\n @word_with_guesses[i] = \"-\"\n end\n @check_win_or_lose = :play\n\n end", "def initialize(secret_word)\n @secret_word = secret_word\n @guess_count = secret_word.length\n @encrypted_word = []\n @arrayed_word = []\n\n end", "def initialize\r\n\t\t# another way of making an array\r\n\t\t@words = %w\"learning lollipop education image computer mobile january february friday flower beauty light earth machine book\r\n\t\tnews yahoo google internet bangladesh india america cricket football friday sunday sunny\"\r\n\t\t@chances_left = 5\r\n\r\n\t\t@game_over = false\r\n\r\n\t\t\r\n\tend", "def initialize(word)\n @word = word\n @guesses = ''\n @wrong_guesses = ''\n self\n end", "def initialize(word)\n @word = word\n @guesses = ''\n @wrong_guesses = ''\n end", "def initialize(word)\n @word = word\n @guesses = ''\n @wrong_guesses = ''\n end", "def initialize(word)\n @word = word\n @guesses = ''\n @wrong_guesses = ''\n end", "def initialize(word)\n @word = word\n @guesses = ''\n @wrong_guesses = ''\n end", "def initialize(chosen_word,word_guess,dead_man,time)\n @chosen_word = chosen_word\n @word_guess = word_guess\n @dead_man = dead_man\n @time = time\n end", "def initialize(word)\n @word = word\n @guesses = \"\"\n @wrong_guesses = \"\"\n end", "def initialize(word)\n @word = word\n @guesses = \"\"\n @wrong_guesses = \"\"\n end", "def initialize word \n @word = word\n @guesses = ''\n @wrong_guesses = ''\n end", "def initialize(word)\n @word = word\n end", "def initialize(word)\n # This is just some a printout of the game at initialization\n puts \"\n POORMAN's\n ___ ___ ____ ____ __ ____ ___ ___ _____ ____ __\n / / / / / _ | | \\\\ | | / ___\\\\ | \\\\ / | | _ \\\\ \\\\ \\\\_ \\\\ \\ \n / /__/ / / /_| | | |\\\\ \\\\| | | | ___ | |\\\\ \\\\ / /| | | |_\\\\ \\\\ \\\\ \\\\ \\\\ \\\\\n / ___ / / ___ | | | \\\\ | | |__| | | | \\\\ \\\\/ / | | | ___ \\\\ \\\\ \\\\\\\\ \\\\_\\\\ \\\\ \n /__/ /__/ /__/ |_| |_| \\\\__| \\\\____/ |_| \\\\__/ |_| |_| \\\\__\\\\ |_| \\_____|\n \n \"\n\n # instance variables for HangMan Class\n @word = word\n\n ## LOGIC: This is to set the number of guesses based on the length of the word\n if @word.length >= 12\n @guess_count = 9\n elsif @word.length >= 10 && @word.length < 12\n @guess_count = 8\n elsif @word.length >= 8 && @word.length < 10\n @guess_count = 7\n elsif @word.length >= 6 && @word.length < 8\n @guess_count = 6\n else\n @guess_count = 5\n end\n ## End of Logic\n\n @is_correct = false # Flag to see if the guess is correct\n # Nifty code to set a prompt variable with a bunch if underscores\n # Note the length of the underscores matches the length of the word\n @prompt = String.new(str=\"_\") * word.length\n @guess_history = Array.new # A guess history array to store guesses\n end", "def initialize(word)\n @word = word\n end", "def initialize(word)\n @word = word\n end", "def initialize(word)\n @word = word\n end", "def initialize(word)\n @word = word\n end", "def initialize(word)\n @word = word\n end", "def initialize(word)\n @word = word\n end", "def initialize(word)\n @word = word\n end", "def initialize(word)\n @word = word\n end", "def initialize(word)\n @word = word\n end", "def initialize(word)\n @word = word\n end", "def init_load\n init_dict()\n @grid = Array.new(self.size) { Array.new(self.size, nil) }\n insert_word(self.firstWord, self.fwX, self.fwY)\n\n if (self.playedWords == nil)\n return\n end\n\n for pw in self.playedWords\n @grid[pw.x][pw.y] = pw.letter\n end\n end", "def initialize(word)\n\t\t@word = word\n\tend", "def initialize(word)\n @word=word\n end", "def initialize(player, difficulty = nil, passed_word = nil)\n url = \"http://app.linkedin-reach.io/words?\"\n \n #Set the difficulty. Get dictionary filtered on difficulty. Initialize secret word.\n if difficulty\n url += \"difficulty=#{difficulty}\"\n end\n response = HTTParty.get(url)\n @dictionary = response.parsed_response.split(\"\\n\")\n passed_word ||= dictionary.sample.downcase\n @secret_word = passed_word.downcase\n\n\n # Initialize the list of players. This can support two players. \n # Set player index to 0, which will support keeping track of two players. \n @players = [player]\n @curr_player_index = 0\n @curr_player = @players[@curr_player_index]\n\n #Give the user the option for two players. \n #If two players are not specified, default to the single player passed to the intialization.\n print \"Enter 1 for one player, or 2 for two player: \"\n player_mode = gets.chomp\n if player_mode == \"2\"\n player_2 = Player.new(\"Player_2\")\n @players += [player_2]\n end\n\n @game_word = \"\"\n @secret_word.each_char do |char|\n add_char = \"_\"\n if char == \" \"\n add_char = \" \"\n end\n @game_word += add_char + \" \"\n end\n \n end", "def initialize(word)\n @word = word\n @guesses = ''\n @wrong_guesses = ''\n @word_with_guesses = ''\n @wrong_word_with_guesses = ''\n @check_win_or_lose\n i = 0\n while i < @word.length do\n @word_with_guesses << '-'\n i=i+1\n end\n end", "def initialize()\n @word = ''\n @guesses = ''\n @wrong_guesses = ''\n end", "def initialize\n @difficulty = 0\n @word_to_guess\n @theme = \"\"\n puts \"Welcome to Word Guess!\".blink\n prompt\n end", "def initialize(file)\n @@word = Word.new # @@ is a class variable\n\t\tself.read_word_file(file) # Read in word list file\n\t\t@guess_count = 0 # @ is an instance variable, is only available for current instance of GameEngine object\n\tend", "def start_game()\n $game_over = false # set flag to false when starting a new game\n $game_won = false # set flag to false when starting a new game\n $bucket = [] # empty array when starting a new game\n $build_word = [] # empty array when starting a new game\n $wrong_count = [] # empty array when starting a new game\n #$word = $words.sample # select a random word from the words array\n $word.length.times { $build_word.push(\"_\") } # push placeholder underscores to $build_word array\nend", "def initialize(player_1_word)\n @word_to_guess = player_1_word.split('')\n @number_guesses_left = @word_to_guess.length\n @letters_tried=[]\n end", "def initialize(word)\n @word = word \nend", "def initialize(target_word)\n\t\t@target_word = target_word\n\t\t@guess_limit = target_word.length*2\n\t\t@guess_count = 0\n\t\t@is_over = false\n\t\t@win = false\n\t\t@guess_history = []\n\t\t@feedback = []\n\t\ttarget_word.split('').each {|x| @feedback << [x, false]}\n\tend", "def initialize(invalid_word, possible_word)\n self.invalid_word = invalid_word\n self.possible_word = possible_word\n self.common_chars = build_common_word\n end", "def initialize\n\t\t@word = [\"buffalo\", \"llama\", \"kangaroo\", \"elephant\", \"aardvark\", \"orangutan\", \"hyena\"]\n\t\t@current_state = []\n\t\t@guess_array = []\n\tend", "def initialize(word)\n @word = word\n @word_array = @word.chars\n @length = @word.length\n @blanks = []\n @guess_num = 0\n @word_array.each do |word|\n @blanks << \"_ \"\n end\n end", "def initialize(word)\r\n\t\t@word = word.split(\"\")\r\n\t\t@guesses = @word.length * 2\r\n\t\t@underscore_array = @word.map {|x| \"_\" }\r\n\t\t@underscore = @underscore_array.join(\" \")\r\n\t\t@guessed_array = []\r\n\tend", "def init_first_word()\n #\"if (self.playedWords != nil)\n# return\n# end\"\n\n self.firstWord = \"\"\n if (self.firstWord == nil)\n throw Exception.new \"wtf ??!\"\n end\n\n begin\n if (self.firstWord == nil)\n throw Exception.new \"@words isn't responsible\"\n end\n self.firstWord = @words.keys[Random.rand(@words.size)]\n if (self.firstWord == nil)\n throw Exception.new \"self.firstWord is equal to nil\"\n end\n end while self.firstWord.length > self.size\n\n self.fwX = Random.rand(self.size)\n self.fwY = Random.rand(self.size - self.firstWord.length + 1)\n \n insert_word(self.firstWord, self.fwX, self.fwY)\n end", "def initialize(word)\n @word = word.downcase\n @guesses = ''\n @wrong_guesses = ''\n end", "def new_game\n\t\t# Get the full list of words\n\t\twords = File.readlines('wordlist.txt')\n\t\tvalid_words = []\n\t\twords.each do |w| \n\t\t\t# Take all new lines and returns out\n\t\t\tw.gsub!(/\\r\\n/, \"\")\n\t\t\t# Word is valid if it's between 5 and 12 characters and isn't a proper noun. (no fair using names and such!) \n\t\t\tvalid_words << w if w.length.between?(5,12) && w[0] != w[0].upcase\n\t\tend\n\t\t# Split secret word into an array of letters\n\t\t@word = valid_words.sample.split(\"\").to_a\n\t\t# This holds user's guess. Originally populated with \"_\" for each letter\n\t\t@guess = \"\"\n\t\t@word.length.times { @guess += \"_\"}\n\t\t# Holds user's wrong letters. Originally populated with 9 x \"_\"\n\t\t@wrong_letters = \"\"\n\t\t9.times { @wrong_letters += \"_\"}\n\t\t@turn = 0\n\t\tputs \"Your task is to guess the secret word, letter by letter.\"\n\t\tputs \"You have only 9 wrong letters before you lose, so guess carefully!\"\n\t\tputs\n\t\tputs \"Here is your word. Each _ is a letter.\"\n\t\tputs\n\t\tget_guess\n\tend", "def initialize(secretWord, maxWrongGuesses)\n @correctlyGuessedLetters = Set.new\n @incorrectlyGuessedLetters = Set.new\n @incorrectlyGuessedWords = Set.new\n\t\t@secretWord = secretWord.upcase\n\t\t@guessedSoFar = MYSTERY_LETTER*@secretWord.length\n\t\t@maxWrongGuesses = maxWrongGuesses\n end", "def initialize(word)\n @word = word\n @guesses=''\n @wrong_guesses=''\n @word_with_guesses=''\n @check_win_or_lose=''\n for i in 0..word.length-1\n @word_with_guesses[i]='-'\n end\n end", "def initialize(word)\n # Make the word lowercase\n @word = word.downcase\n @guesses = ''\n @wrong_guesses = ''\n @word_with_guesses = ''\n end", "def load_game(chosen_word,word_guess,dead_man)\n @chosen_word = chosen_word\n @word_guess = word_guess\n @dead_man = dead_man\n\n @word_guess.display(@dead_man)\n round\n end", "def initialize(word)\n @guesses = ''\n @wrong_guesses = ''\n @word = word.downcase\n end", "def initialize(word)\n @correct_word_array = word.upcase.split(//)\n @letters_guessed_array = Array.new(word.length,\"__\")\n end", "def initialize(word)\n @url = \"https://www.google.com/search?q=define%3A+#{word}\"\n @noko = correct_site()\n @word_info = get_definition()\n end", "def make_word\n @secret_word = File.readlines('dictionary.txt').sample.chomp.downcase.split('')\n @working_word = Array.new(@secret_word.length) { \"_\" }\n end", "def init_word(kanji, options={})\n word = Word.find_by_kanji(kanji)\n word.update_attributes!(options)\n word\n end", "def setsecretword word\r\n\t\t @secretword = word\r\n\t\t templ = createtemplate\r\n\t\t\t\t\tword_templ = templ.gsub(\"[\",\"\").gsub(\"]\",\"\")\r\n\t\t\t\t\ti=0\r\n\t\t\t\t\tsec_word_array=@secretword.chars\r\n\t\t\t\t\twhile i < sec_word_array.length do\r\n\t\t\t\t\t\tif sec_word_array[i] == \" \"\r\n\t\t\t\t\t @resulta[i] = \" \"\r\n\t\t\t\t\t else\r\n\t\t\t\t\t \t@resulta[i] = \"_\"\r\n\t\t\t\t end\r\n\t\t\t\t i+=1\r\n\t\t\t\t end\r\n\t\t end", "def create\n word = Word.new(params['term'], false)\n\n # check to see if the word exists on the board\n board = Boggle.new\n exists = board.search(word.term, params['tiles'])\n\n # now, see if the word is an actual English word\n if exists\n\n # check the cache first - only go to the oxford dictionary if\n # it doesn't exist in our simple word cache\n word_cache_store = MiniCache::Store.new\n if !word_cache_store.get(word.term).nil?\n word.exists = true\n else\n # allowing exceptions from underlying api to throw 500 status code\n # and generate a log entry - to protect system from downstream\n # latency and failures, use circuit breaker\n word.exists = @dictionary_gateway.exists(word.term)\n word_cache_store.set(word.term, '') if word.exists\n\n end\n end\n\n render json: word\n end", "def initialize(word)\n @letters = get_letters(word)\n # error counter\n @errors = 0\n # good and bad letters arrays\n @good_letters = []\n @bad_letters = []\n # status counter\n @status = 0\n end", "def start_game\n dictionary = File.readlines(\"dictionary.txt\")\n secret_word = get_word(dictionary).split(\"\")\n word = secret_word.map { |x| x = \"_\" }\n game_status = {\n secret_word: secret_word,\n word: word,\n incorrect_guesses: [],\n images: ['\n +---+\n | |\n | \n | \n | \n | \n ==========', '\n +---+\n | |\n | O \n | \n | \n | \n ==========', '\n +---+\n | |\n | O \n | | \n | \n | \n ==========', '\n +---+\n | |\n | O \n | /| \n | \n | \n ==========', '\n +---+ \n | | \n | O \n | /|\\ \n | \n | \n ==========', '\n +---+ \n | | \n | O \n | /|\\ \n | / \n | \n ==========', '\n +---+ \n | | \n | O \n | /|\\ \n | / \\ \n | \n ==========']\n }\n end", "def initialize(word) # initialize with the arguement word\n @name = word # set the name = to the word that is paaed\n end", "def setup_game\n\t\t@word = get_word.upcase\n\t\t@misses = []\n\t\t@hits = []\n\t\t@guesses_left = 10\n\tend", "def play\r\n @secret_word = get_random_word\r\n @secret_word_letters = @secret_word.chars.to_a\r\n print_instructions\r\n play_loop\r\n end", "def new_game(dictionary)\n\t\t@dictionary = dictionary\n\t\t@frequency_hash = frequency_hash\n\t\t@vowels = vowels\n\t\t@letters = letters\n end", "def new_game(dictionary)\n\t\t@dictionary = dictionary.map { |w| w.chomp }\n\t\t@played_letters = []\n\t\t@letters = ('a'..'z').to_a\n\tend", "def set_gameword\n\t @gameword = Gameword.find(params[:id])\n\tend", "def initialize(name = 'Kasih', file_name='./dictionary.txt')\n @name = name\n @full_dictionary = import_dictionary(file_name)\n @dictionary = @full_dictionary.dup\n @guessed_letters = [] #must reset at the end!\n @new_game = true\n end", "def set_word\n @word = Word.find_by_text(params[:text])\n end", "def new_game\n dictionary = File.readlines(\"assets/5desk.txt\").map {|word| word.chomp}\n dictionary.select! {|word| word.length >= 5 && word.length <= 12}\n @chosen_word = dictionary[(dictionary.size * rand).floor]\n\n puts \"A word has been chosen that is #{@chosen_word.length} letters long.\"\n puts \"You may guess the letters in that word one letter at a time,\"\n puts \"or you may guess the whole word, but a man's life \\\"hangs\\\" in\"\n puts \"the balance. So be careful not to make too many wrong guesses,\"\n puts \"because once his whole body and both of his eyes have been\"\n puts \"drawn, he's dead and you lose!\"\n puts \"\\n\"\n\n @word_guess = WordGuess.new(@chosen_word)\n @dead_man = DeadMan.new\n\n round\n end", "def make_guess(word)\n raise_if_complete\n\n correct = word.downcase == password.word\n guesses.create!(word: word, correct: correct)\n self.game_state = 'lost' if lives_left.zero?\n self.game_state = 'won' if correct\n save!\n correct\n end", "def initialize word1, word2\n \t@word1 = word1\n \t@word2 = word2\n end", "def initialize(word)\n @word = word\n @letters = unique_letters_in(word)\n end", "def initialize(input, output)\r\n\t\t\t\t\t@input = input\r\n\t\t\t\t\t@output = output\r\n\t\t\t\t\t@played = 0\r\n\t\t\t\t\t@score = 0\r\n\t\t\t\t\t@wordtable = []\r\n\t\t\t\t\t@wheel = [\"500\",\"900\",\"700\",\"300\",\"800\",\"550\",\"400\",\"500\",\"600\",\"350\",\"500\",\"900\",\"Bankrupt\",\"650\",\"Free spin\",\"700\",\"Lose a turn\",\"800\",\"500\",\"450\",\"500\",\"300\",\"Bankrupt\",\"5000\"]\r\n\t\t\t\t\t@template = \"\"\r\n\t\t\t\t\t@secretword = \"\"\r\n\t\t\t\t\t@turn = 0\r\n\t\t\t\t\t@turnsleft = GOES\r\n\t\t\t\t\t@reward = \"\"\r\n\t\t\t\t\t@num_guessed = 0\r\n\t\t\t\t\t@resulta = []\r\n\t\t\t\t\t@resultb = []\r\n\t\t\t\t\t@descr= []\r\n\t\t\t\t\t@secret_clue = \"\"\r\n\t\t\t\t\t@num_words = 0\r\n\t\t\t\t\t@console = true\r\n\t\t\t\t\t@break_flag = false\r\n\t\t\t\t\t@spin_flag = false\r\n\t\t\t\t\t@spin_counter=0\r\n\t\t\t\t\t@guess_counter=0\r\n\t\t\t\t\t@filename = \"wordfile.txt\"\r\n\t\t\t\t\t@phrases = [\"Kind of animal that lives by water.\",\"Heavy seabird.\",\"Common wild bird.\",\"Mohawk bird.\"]\r\n\t\t\t\t\t@game_analysis = Hash.new { |h, k| h[k] = Hash.new { |hh, kk| hh[kk] = {} } }\r\n\t\t\t\t\t@statistic = Hash.new { |h, k| h[k] = Hash.new { |hh, kk| hh[kk] = {} } }\r\n\t\t\t\t @message=\"Guess a letter from the word/phrase.\"\r\n\t\t\t\t @web_initial = true\r\n\t\t\t\t @win = false\r\n\t\t\t\t @game_over = false\r\n\t\t\t\tend", "def new(options= {})\n password = \"\"\n total_length = (options[:length] || 12).to_i\n word_count = (options[:words] || 2).to_i\n digit_length = (options[:digits] || 2).to_i\n word_options = options.slice(:language, :dictionary)\n length_variance = 3\n \n validate_word_count(word_count)\n \n total_digits = digit_length * (word_count - 1)\n avg_word_length = (total_length - total_digits) / word_count\n \n validate_avg_word_length(avg_word_length)\n\n word_count.downto(1) do |n|\n length_needed = total_length - password.length\n break if length_needed <= 0\n\n if n == 1 # this is the last word\n word_options[:exact] = length_needed\n else # not the last word\n word_options[:min] = [1, avg_word_length - length_variance].max\n # max_length = total remaining length - remaining digits and words\n word_options[:max] = length_needed - ((n-1) * (digit_length + avg_word_length))\n end\n password << pick_dictionary_word(word_options)\n password << pick_random_number(digit_length).to_s if digit_length > 0 && n > 1\n end\n\n return password\n end", "def random_word\n wordpair = nil\n File.foreach(\"wordlist\").each_with_index do |line, number|\n wordpair = line if rand < 1.0/(number+1)\n end\n word = Word.new(wordpair.split(':')[0], wordpair.split(':')[1])\n return word\n end", "def pick_secret_word\n @word = dictionary.sample\n word\n end", "def set_word\n @word = Word.find(params[:id])\n end", "def set_word\n @word = Word.find(params[:id])\n end", "def set_word\n @word = Word.find(params[:id])\n end", "def set_word\n @word = Word.find(params[:id])\n end", "def set_word\n @word = Word.find(params[:id])\n end", "def set_word\n @word = Word.find(params[:id])\n end", "def set_word\n @word = Word.find(params[:id])\n end", "def set_word\n @word = Word.find(params[:id])\n end", "def set_word\n @word = Word.find(params[:id])\n end", "def set_word\n @word = Word.find(params[:id])\n end", "def set_word\n @word = Word.find(params[:id])\n end" ]
[ "0.79163533", "0.78474665", "0.7480395", "0.7479263", "0.7434373", "0.73875904", "0.72949153", "0.71076715", "0.71025366", "0.70366204", "0.70168674", "0.7016486", "0.70108616", "0.7005909", "0.69748276", "0.6970804", "0.6965631", "0.69593126", "0.69578195", "0.69392616", "0.693893", "0.6935918", "0.6935918", "0.6935918", "0.6935918", "0.6924617", "0.69242084", "0.69242084", "0.691346", "0.689291", "0.6852197", "0.6837274", "0.6837274", "0.6837274", "0.6837274", "0.6837274", "0.6837274", "0.6837274", "0.6837274", "0.6837274", "0.6837274", "0.6783098", "0.67759466", "0.6775252", "0.67539734", "0.67519826", "0.6751692", "0.67059696", "0.6697891", "0.66807353", "0.6665046", "0.6646743", "0.6644248", "0.6643968", "0.66392756", "0.6633147", "0.6596699", "0.6589065", "0.6573611", "0.656049", "0.65482366", "0.65425384", "0.6516219", "0.65086013", "0.64763075", "0.647493", "0.64701474", "0.64407146", "0.6435534", "0.6433736", "0.64045197", "0.6370263", "0.6368985", "0.63630056", "0.6360431", "0.63167095", "0.63141876", "0.6300589", "0.62975293", "0.62876046", "0.6277595", "0.62620616", "0.6245196", "0.62158084", "0.62122303", "0.6207075", "0.6193105", "0.61647934", "0.61380976", "0.6128121", "0.6128121", "0.6128121", "0.6128121", "0.6128121", "0.6128121", "0.6128121", "0.6128121", "0.6128121", "0.6128121", "0.6128121" ]
0.69524336
19
METHOD: check if guess correct INPUT: guessed letter as string OUTPUT: true or false
def guess_correct?(guess) @secret.include? guess end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def guess(letter)\n is_letter = /^[a-zA-Z]$/\n if letter.nil? or letter.empty? or not letter.match(is_letter)\n throw ArgumentError \n end\n letter.downcase!\n if self.guesses.include? letter or self.wrong_guesses.include? letter\n return false\n end\n if self.word.include? letter\n self.guesses = self.guesses + letter\n else\n self.wrong_guesses = self.wrong_guesses + letter\n end\n return true\n end", "def guess? (letter)\n \t\tif word.include?(letter)==true\n \t\tvalid_guess(letter)\n \telse\n \t\tinvalid_guess(letter)\n \tend\n end", "def valid_guess?(letter)\n letter.length==1 && (\"a\"..\"z\").include?(letter)\n end", "def check_letter(user_guess)\n @letter = user_guess.length == 1\n end", "def valid_guess?(letter_guess)\n (letter_guess.length == 1 && !letter_guess.match(/[^A-Za-z]/) && !@guesses.include?(letter_guess)) ? true : false\n end", "def guess_correct(letter)\n\t\tif @secret_word.include?(letter)\n\t\t\t@secret_word.each_with_index do |correct, index|\n\t\t\tif letter == correct\n\t\t\t\t@display[2*index+1] = letter\n\t\t\t\tputs @display\n\t\t\t\t@attempted_letters << letter\n\t\t\t\tend\n\t\t\tend\n\t\t\t@number_of_guesses -= 1\n\t\t\treturn true\n\t\telse \n\t\t\treturn false\n\t\tend \n\tend", "def guess?(letter)\n correct = false\n @@secret.length.times do |i|\n if (@@secret[i] == letter && @@progress[i] == '_')\n @@progress[i] = letter\n correct = true\n end\n end\n @@incorrect << letter if !correct\n @@guesses += 1\n puts(\"secret: #{@@secret}\")\n correct\n end", "def valid_letter_guess?(guess)\n if !guess.match?(/\\A([a-z]|[-]|\\d)\\z/)\n puts \"Not a letter! Guess again.\"\n return false\n elsif @incorrect_guesses.include?(guess) || @correct_guesses.include?(guess)\n puts \"You already guessed that letter. Guess again.\\n\\n\"\n return false\n else\n return true\n end\n end", "def correct_guess?(letter)\n if @word_selected.include?(letter)\n if @correct_guesses.empty?\n @correct_guesses << letter\n elsif @correct_guesses.include?(letter)\n puts 'Letter already guessed! try another one!'\n else\n @correct_guesses << letter\n end\n return true\n end\n false\n end", "def is_a_letter?(guess)\n return true if @word.include?(guess)\n return false\n end", "def guess_letter(letter)\n won = false\n failed_guess = feedback(letter)\n if failed_guess\n @tries_left -= 1\n else\n won = won?(@display_word.split(\" \").join(\"\"))\n end\n won\n end", "def guess char\n #get 1st char\n \n if char.nil?\n raise ArgumentError, 'Argument is not string' \n return false\n end\n if char.length != 1\n raise ArgumentError, 'Argument is not string'\n return false\n end \n if char.match(/[a-zA-Z]/) == nil\n raise ArgumentError, 'Argument is not string' \n return false\n end\n \n pick = char.chr.downcase\n\n #catch replicant entries\n if @guesses.match(\"#{pick}\") != nil\n # @word_with_guesses << \"You have already used that letter\"\n return false\n end \n \n if @wrong_guesses.match(\"#{pick}\") != nil\n# @word_with_guesses << \"You have already used that letter\"\n return false\n end \n \n #actual match\n if @word.match(\"#{pick}\") != nil\n guesses << pick # 1st char\n else\n wrong_guesses << pick # \n @attempt += 1\n end\n \n # build up guess string i.e. \"----a-e\"\n @word_with_guesses = '';\n @check_win_or_lose = :win\n word.each_char { |a|\n if @guesses.match(\"#{a}\") != nil \n @word_with_guesses << a\n else\n @word_with_guesses << '-'\n @check_win_or_lose = :play\n end\n }\n \n #check game status\n if @attempt > 6\n @check_win_or_lose = :lose\n end\n \n return true\n end", "def check_guess(player_guess, display)\n letter_found = false\n @secret_word.chars.each_with_index do |char, index|\n if char.downcase == player_guess\n display[index] = char\n letter_found = true\n end\n end\n letter_found\n end", "def guess?(letter)\n if !self_is_letter?(letter)\n puts \"Not a letter!\"\n return false\n end\n if @word.include? letter\n if(@word.count(letter) > 1)\n while(@word.include? letter)\n puts \"Hit this while loop\"\n index = @word.index(letter)\n @word.slice!(index,0)\n @word[index] = '_'\n\n puts \"Word\" + @word\n @guessedWord.slice!(index,0)\n @guessedWord[index] = letter\n\n end\n else\n index = @word.index(letter)\n\n @guessedWord.slice!(index,0)\n @guessedWord[index] = letter\n\n\n\n end\n\n\n output_word()\n return true\n end\n p \"Word does not contain #{letter}\"\n @health -= 1\n p \"you have #{@health} tries left\"\n return false\n end", "def guess(letter)\n # STEP 1: check to make sure the letter is not any non-letter character and\n # raises an error if it is\n if /^[a-zA-Z]+$/.match(letter)\n letter.downcase!\n else raise_error(\"Invalid letter\")\n end\n\n # STEP 2: check to make sure the user does not guess the same letter more\n # than once\n if @guesses.include? letter; return false; end\n if @wrong_guesses.include? letter; return false; end\n\n # STEP 3: check to see if the guessed letter matches any letters in the \n # word\n if @word.include? letter\n @guesses += letter\n # if there is a match, update the word_with_guesses to show where\n # in the string the letter was matched\n @word.each_char.with_index do |c, i|\n if c == letter\n @word_with_guesses[i] = c\n end\n end \n else \n @wrong_guesses += letter\n @attempts += 1\n end\n # update the number of attempts and call the function to check if\n # the user won, lost, or continues playing\n check_win_or_lose\n end", "def check_letter_in_random_word(guess_letter)\n position_letter = 0\n @correct_guess = false\n @random_word.each_char do |letter_random_word|\n if letter_random_word == guess_letter\n change_guess_word_status(position_letter)\n @correct_guess = true\n end\n position_letter += 1\n end\n if @correct_guess == true\n line_of_30_stars\n puts \"WhoopWhoop: Letter '#{guess_letter}' is in the word!\\n\"\n else\n line_of_30_stars\n puts \"No, sorry, '#{guess_letter}' isn't in the word.\"\n end\n end", "def already_guessed? (letter)\r\n letter = letter.downcase\r\n @guessed_letters.include? letter\r\n end", "def has_been_guessed_correctly?(in_letter)\n @letters_tried.any? {|letter_combo|letter_combo[:letter] == in_letter && letter_combo[:correct] == true}\n end", "def valid_guess?(player_guess)\n ('a'..'z').include?(player_guess) && !@guessed_letters.include?(player_guess)\n end", "def check_guess(guess)\n # checks human guess, displays discovered, and return if letter found\n letter_found = false\n self.secret_word.split('').each_with_index do |chr, ind|\n if chr == guess\n self.currently_discovered[ind] = chr\n letter_found = true\n end\n end\n p self.currently_discovered\n letter_found\n end", "def test_guess_passes_letter\n\t\tword = \"hello\"\n\t\tchar = \"e\"\n\t\th= Hangman.new(word)\n\t\tassert_equal true, h.guess?(char)\n\tend", "def check_letter(guess)\n if @word.include? guess\n puts \"You chose wisely!\"\n #find which position(s) the guess is in the word array\n correct_index_arr = @word.each_index.select { |i| @word[i] == guess }\n # rebuild @game_status with the correct letter guessed into that position of the word\n correct_index_arr.each do |index|\n @game_status[index] = guess\n end\n # if they don't make guess and put an empty response\n elsif guess.empty?\n puts \"You didn't make a guess. Try again.\"\n # if the user guesses the same wrong letter again\n elsif @wrong_guesses.include? guess\n puts \"You guessed that before! Try again.\"\n else\n @guesses_remaining -= 1\n puts \"wrong guess, the guesses remaining: #{@guesses_remaining}\"\n @wrong_guesses.push(guess)\n end\n end", "def guess(char)\n if char==''||!(char=~/[A-Za-z]/)\n raise ArgumentError\n else\n char = char.downcase\n if @guesses.include?(char)||@wrong_guesses.include?(char)\n return false\n else\n if @word.include?(char)\n @guesses+=char\n for i in 0..@word.length-1\n if @word[i]==char\n @word_with_guesses[i]=char\n end\n end\n if !@word_with_guesses.include?('-')\n @check_win_or_lose=:win\n end\n else\n @wrong_guesses+=char\n if @wrong_guesses.length>=7\n @check_win_or_lose=:lose\n end\n end\n return true\n end\n end\n end", "def check_letter(input_letter)\n # Each time we check, the number of guesses is increased \n @guess_count += 1\n \n # Transform the words into arrays for convenience\n arr_word_to_guess = @word_to_guess.split('') \n arr_guessed_word = @guessed_word.split('') \n \n # Search for the input_letter in arr_word_to_guess\n index_found = arr_word_to_guess.each_index.select{|i| arr_word_to_guess[i] == input_letter}\n \n if (index_found == []) then\n return false \n else \n # if the letter is found, update the guessed word\n n_found = index_found.size\n i = 0 \n n_found.times do \n arr_guessed_word[index_found[i]] = input_letter\n i += 1\n end\n @guessed_word = arr_guessed_word.join('')\n return true\n end \n end", "def guess?(letter)\n if @guessed_letter.include?(letter)\n puts \"You already guessed that letter!\"\n return\n end\n @guessed_letter << letter\n ​\n found = false\n if @characters.include?(letter)\n found = true \n puts \"Yes that letter is in the word!\"\n else\n puts \"Wrong answer!\"\n end \n ​\n @characters.each_with_index do |char, index|\n if char == letter\n @displayed_character[index] = letter\n end\n end\n found\n end", "def guess(char)\n \n #Check if letter guessed is nil or empty or not a letter and throw error\n if char == nil \n raise ArgumentError\n elsif char == \"\"\n raise ArgumentError\n elsif !char.match(/[A-Za-z]/)\n raise ArgumentError\n end\n \n #Convert character to downcase to make it case insensitive.\n #Check if letter has already been guessed in correct or wrong guess buckets\n char = char.downcase\n if @guesses.include? char \n return false\n elsif @wrong_guesses.include? char\n return false\n end\n \n #Check if word contains letter. If yes, increment guesses by 1. If not, increment wrong guesses by 1.\n if @word.include? char\n @guesses += char\n return true\n else\n @wrong_guesses += char\n return true\n end\n\n end", "def guess_letter\n\t\tprint \"Your guess: \"\n\t\tguess = gets.chomp.downcase\n\t\treturn guess if guess == \"save\"\n\t\tif (guess.between?('a','z') && !(@guessed_letters.include? guess)\\\n\t\t\t&& guess.length == 1)\n\t\t\tprocess_guess(guess)\n\t\t\t@guessed_letters << guess\n\t\t\t@turns += 1\n\t\telse\n\t\t\tif guess.between?('a','z')\n\t\t\t\tputs \"\\nYour guess must be ONE letter\" unless guess.length == 1\n\t\t\t\tputs \"\\nYou've already guessed that!\" if @guessed_letters.include? guess\n\t\t\telse\n\t\t\t\tputs \"\\nYour guess must be a letter!\" unless guess.between?('a','z')\n\t\t\tend\n\t\t\tputs \"Try again!\\n\\n\"\n\t\t\tguess = guess_letter\n\t\tend\n\t\tguess\n\tend", "def check_letter(in_letter)\n # find out if this is a correct guess\n correct_status = false\n if word_to_guess.include? in_letter\n correct_status=true\n else\n # bad guess; decrement number_guesses_left\n @number_guesses_left -= 1\n end\n # put letter in letters_tried with correct/wrong status\n new_letter_combo = {\n letter: in_letter,\n correct: correct_status\n }\n letters_tried.push(new_letter_combo)\n return correct_status\n end", "def check_guess(letter)\n\t\t# If the guessed letter is in the word, replace \"_\" in the guess variable with the letter in the right spot\n\t\t@word.each_with_index do |l, i|\n\t\t\tif l == letter\n\t\t\t\t@guess[i] = letter\n\t\t\tend\n\t\tend\n\t\t# If the guessed word and the answer are the same, the user won!\n\t\t# Show message and if the game was previously saved, delete it\n\t\tif @word.join == @guess\n\t\t\tputs \n\t\t\tshow_board\n\t\t\tputs \"You won!!\"\n\t\t\tif @running_saved_game != nil\n\t\t\t\tover_write_data\n\t\t\tend\n\t\t\tgo_again\n\t\t# Got a letter but didn't win. Get another guess\n\t\telsif @word.include?(letter)\n\t\t\tputs\n\t\t\tputs \"You got a letter!\"\n\t\t\tget_guess\n\t\t# Letter wasn't in word, put letter in missed letter variable and guess again\n\t\telse\n\t\t\tputs \n\t\t\tputs \"No #{letter}'s.\"\n\t\t\t@wrong_letters.sub!(\"_\", letter)\n\t\t\t@turn += 1\n\t\t\tget_guess\n\t\tend\n\tend", "def guess_check(letter_guessed)\r\n# \ti. Run a loop to be sure that the letter guessed is a string and if it isn't a string or a single letter put up a warning message and the method\r\n\tif letter_guessed.class.to_s != \"String\" or letter_guessed.length !=1\r\n\t\tputs \"Guesses must be a single letter. Enter another guess.\"\r\n\t\t@guess_check = false\r\n# \tii. If it is a string and a single character continue and run to see if the letter has been guessed already or not. \r\n\telsif @guessed.include? letter_guessed\r\n\t\tputs \"Letter #{letter_guessed} guessed already. Enter another guess\"\r\n\t\t@guess_check = false\r\n\telse\r\n\t\t@guess_check = true\r\n\tend #if\r\nend", "def letter_guess\n letter = get_letter_player()\n check_letter_in_random_word(@guess_letter)\n if @correct_guess == false\n @failed_attempts += 1\n if @failed_attempts == 10\n @lose = true\n end\n end\n guess_word_status_string = @guess_word_status.join()\n if guess_word_status_string == @random_word\n @win = true\n end\n end", "def valid_guess?(guess)\n\t\tguess == 'SAVE' || (('A'..'Z').include?(guess) && (!(@wrong_letters.include?(guess))))\n\tend", "def check_guess(guess)\n @current_guess = guess.downcase\n if @current_guess == @secret_word\n player_won?\n elsif @current_guess.length > 1 || @current_guess.nil?\n @feedback = \"Invalid Guess!\"\n else\n @feedback = \"\"\n if @secret_word.include? @current_guess\n show_letter\n else\n @turns -= 1\n end\n @guesses << @current_guess\n end\n end", "def valid_guess?(guess)\n if guess =~ /^[a-z]$/ && !@try.include?(guess)\n true\n else\n false\n end\n end", "def all_letters_guessed?\n @word_to_guess.each do |letter_in_word_to_guess|\n if !has_been_guessed_correctly?(letter_in_word_to_guess)\n return false\n end\n end\n return true\n end", "def guess(letter)\n \n raise ArgumentError if letter.nil? ## Raise an error if the letter is null.\n raise ArgumentError if letter == '' ## Raise an error if the user entered an empty string. \n raise ArgumentError if !letter.match(/[a-zA-Z]/) ## Raise an error is the user entered a letter that is not in the alphabet.\n\n \n letter.downcase!\n \n # If word includes letter\n if(word.include? letter)\n # And the letter isnt already in guess\n unless (guesses.include? letter)\n # Add guessed word to guesses\n guesses.concat(letter)\n \n # For test case 14\n for i in 0..word.length do\n # If the guessedLetter is in the string, replace it with the guessed letter\n if(letter == word[i])\n word_with_guesses[i] = letter\n end\n \n end\n \n # If guessed letters match word set to win\n if(word_with_guesses == word)\n @check_win_or_lose = :win\n end\n \n return true # return true valid guess\n end #end unless\n return false # invalid guess false\n else\n unless (wrong_guesses.include? letter)\n # Add the guessed letter to the list of incorrected guesses\n wrong_guesses.concat(letter)\n \n # Wrong guesses greater than 7 set win or loose to loose\n if(@wrong_guesses.length>=7)\n @check_win_or_lose = :lose\n end\n \n return true\n end # end unless\n return false # invalid guess\n end # end for \n end", "def setguessedletter(letter)\n\t\t@letter_exists = false\n\t\t\n\t\t@guessed_letters.each do |char|\n\t\t\tif char == letter\n\t\t\t\t@letter_exists = true\n\t\t\tend\n\t\tend\n\t\treturn @letter_exists\n\tend", "def guess_letter?(letter)\r\n\r\n\t\t#Add 1 to the total number of guesses in game IF not already guessed (in the guesses array)\r\n\t\tif @guesses.index(letter) == nil\r\n\t\t\t@guesses << letter\r\n\t\t\t@num_of_guesses += 1\r\n\t\tend\r\n\r\n\t\t#If the letter exists (aka returns valid index)\r\n\t\t# 1. Loop through letters in word and compare to the guessed letter\r\n\t\t# 2. If guessed letter = original letter in word, set board = to letter in that index\r\n\t\t# 3. Return True\r\n\t\t#Else if the letter does not exist in word array\r\n\t\t# 1. Return False\r\n\t\tif @word_array.index(letter)\r\n\t\t\tindex = 0\r\n\t\t\t@word_array.each do|i|\r\n\t\t\t\tif letter == i\r\n\t\t\t\t\t@board_array[index] = letter\r\n\t\t\t\tend\r\n\t\t\t\tindex+=1\r\n\t\t\tend\r\n\t\t\ttrue\r\n\t\telse\r\n\t\t\tfalse\r\n\t\tend\r\n\tend", "def wrong_guess(letter)\n\t\tif !@attempted_letters.include?(letter)\n\t\t\tputs \"WRONG....\"\n\t\t\t@attempted_letters << letter\n\t\t\t@number_of_guesses -= 1 \n\t\t\tp @number_of_guesses\n\t\t\tp @display\n\t\t\tp \"you have #{@number_of_guesses} guesses left...\"\n\t\t\treturn true\n\t\tend\n\tend", "def try_guess(char)\n if self.already_attempted?(char)\n p \"that has already been attempted\"\n return false\n else\n matching_indices = self.get_matching_indices(char)\n self.fill_indices(char, matching_indices)\n\n @remaining_incorrect_guesses -= 1 if matching_indices.empty?\n \n @attempted_chars << char\n return true\n end\n end", "def guess!(letter)\n end", "def repeated_guess?\r\n if @guessed_letters.include? @letter\r\n puts \"You have already guessed the letter #{@letter}, try again.\"\r\n return true\r\n end\r\n end", "def check_winner\n @word.downcase.chars == @guess\n end", "def guess(letter)\r\n if word_has?(letter)\r\n \tput_letter_on_board(letter)\r\n else\r\n wrong_letter(letter) if !@guesses.include? letter\r\n end\r\n end", "def already_guessed?(letter, previous_attempts)\r\n if previous_attempts.include?(letter)\r\n puts \"You already guessed that\"\r\n return true\r\n else\r\n return false\r\n end\r\nend", "def respond_to_guess(letter)\n letter = letter.clone.downcase\n\n if @incorrect_letters.include?(letter) || @progress.include?(letter) || @progress.include?(letter.upcase)\n puts \"You already guessed that letter!\"\n puts \"\"\n elsif @word.include?(letter) || @word.include?(letter.upcase)\n update_progress(letter)\n unless @progress.include?(\"_\")\n @round_finished = true\n @guessed = true\n end\n else\n @incorrect_letters << letter\n @round_finished = true if @incorrect_letters.size == 6\n end\n print_hangman\n end", "def check_phrase guess\r\n\t\t\t\t\t\t\t\tif guess == @secretword\r\n\t\t\t\t\t\t\t\t\tincement_score\r\n\t\t\t\t\t\t\t\t\t@win = true\r\n\t\t\t\t\t\t\t\t\treturn true\r\n\t\t\t\t\t\t\t\telse\r\n\t\t\t\t\t\t\t\t\treturn false\r\n\t\t\t\t\t\t\t\tend\r\n\t\t\t\t\t\tend", "def process_guess(letter)\n\n\t\tletter = letter.downcase\n\n\t\tif @prev_guesses.include? letter\n\t\t\tputs \"\\\"#{letter}\\\" has already been guessed\"\n\t\t\tprint_status\n\t\t\treturn false \n\t\telse\n\t\t\t@prev_guesses << letter\n\t\t\tdecrement_guesses\n\t\tend\n\n\t\tif @original_word.include? letter\n\t\t\tupdate_gameboard(letter)\n\t\t\tprint_status\n\t\t\ttrue\n\t\telse\n\t\t\tprint_status\n\t\t\tfalse\n\t\tend\n\tend", "def guess_letters_check\n @user_guess.length != 4 || !check_letters(@user_guess)\n end", "def guessed?\n \t(word.split('') - selected_letters).empty?\n\tend", "def guesses_include_in?(letter)\n #puts @word\n word = @word.split(\"\")\n guessChar = @guesses.split(\"\")\n #puts \"***guesses_include_in? #{word} #{guessChar}\"\n word.each do |w|\n guessChar.each do |g|\n #puts \"w == g && g == letter\"\n #puts \"#{w} == #{g} && #{g} == #{letter} ==> #{w == g && g == letter}\"\n if w == g && g == letter\n return true\n else\n #return false\n end\n end\n\n end\n return false\nend", "def check_guess(input)\n @guessed_letters.push(input)\n if @secret_word.match?(input)\n @secret_word.split(//).each_with_index { |char, index| @guessed_word[index] = char if char == input }\n else\n puts 'Incorrect'\n @guesses_left -= 1\n @wrong_letters.push(input)\n end\n end", "def guessing_for_the_win(letter)\n\t\tif repeat_guess(letter)\n\t\telsif guess_correct(letter)\n\t\telse wrong_guess(letter)\n\t\tend \n\n\t\tif @secret_word == @display\n\t\t\tcongrats\n\t\telsif @number_of_guesses > 0 \n\n\t\t\tp \"Keep guessing\"\n\t\telse\n\t\t\tfailure\n\t\tend\n\tend", "def has_been_guessed?(in_letter)\n @letters_tried.any? {|letter_combo|letter_combo[:letter] == in_letter}\n end", "def good_guess?\n current_guess == \"save\" || current_guess == secret_word || current_guess.length == 1\n end", "def guess letter\n raise InvalidGuessError if letter.strip.empty? || letter.length > 1\n letter = letter[0].upcase\n if @guesses.include?(letter)\n return {advance: false, message: \"#{letter} has already been played, silly!\"}\n else\n @guesses << letter\n end\n @guessed.each_with_index do |guessed_pos, index|\n if guessed_pos\n if letter == secret[index]\n return {advance: false, message: \"#{letter} has already been played, silly!\"}\n end\n else\n if letter == secret[index]\n reveal_all(letter)\n return {advance: true, message: \"We found #{letter}!\"}\n end\n end\n end\n {advance: true, message: \"Sorry, we did not find #{letter}!\"}\n end", "def guess(letters)\n raise ArgumentError if letters == \"\"\n raise ArgumentError if letters !~ %r{\\w}\n letters.downcase!\n if @word.include?(letters) \n !@guesses.include?(letters) ? @guesses << letters : false\n\n else\n @wrong_guesses.include?(letters) ? false : wrong_guesses << letters \n end\n end", "def guess(letter)\n # raise an execption\n # raise will 'break' the method if valid_guess? == false\n raise InvalidGuessException.new(\"Invalid guess!\") unless valid_guess?(letter)\n if word_has?(letter)\n \tput_letter_on_board(letter)\n else\n wrong_letter(letter) if !@guesses.include? letter\n end\n end", "def invalid?(guess)\n\t\t@guessed_letters.include?(guess)\n\tend", "def is_good?(letter)\n @letters.include?(letter)\n end", "def check_guess\n @guess_count += 1 # Increment guess count\n @guess_feedback = \"\"\n return true if @input == @current_word # Return true value if input is same as chosen word - correctly guessed word\n i = 0\n @input.split('').each do |letter| # Split user input and check if each letter is in exact position as chosen word, or if it is somewhere or not in the word at all\n # Use << to append to string as this is faster and doesn't create new string objects, as opposed to concatenation using a +\n # Below line uses nested ternary operators, where the condition is first evaluated and then if true, the first statement is executed, if false, the second statement is executed\n # This allows the code to be more readable and shorter\n @current_word.index(letter) == i ? (@guess_feedback << \"exact \") : (@current_word.index(letter).nil? ? (@guess_feedback << \"miss \") : (@guess_feedback << \"near \"))\n i += 1\n end\n puts @guess_feedback\n end", "def input_validation(guess, password)\n if (@masked_password.include? guess) || (@wrong_letters.include? guess)\n puts 'You already tried that one!', ''\n else\n guess_letter(guess, password) ? right_letter(guess) : wrong_letter(guess)\n end\n end", "def guess(letter, secret_word)\r\n \t\t\r\n \t\t\r\n \t\tright = false\r\n \t\r\n \t\tsecret_word.each do|char| \r\n\r\n \t\t\tif char == letter\r\n \t\t\t\tright = true\r\n \t\t\tend\r\n \t\tend\r\n \t\t\r\n \t\tif right == true\r\n \t\t\tputs \"correct!\"\r\n \t\t\t\r\n \t\telse\r\n \t\t\tputs \"wrong!\"\r\n \t\tend\r\n \t\t@guess_count -= 1\r\n\r\n \t\tputs \"Guesses remaining #{guess_count}\"\r\n \t\t\r\n\r\n\r\n \tend", "def valid_chars?(guess)\n if !guess.upcase.each_char.all? { |char| @colors.has_value? char }\n puts \"That is not a valid guess. Please guess from these colors: #{@colors.values.join}\"\n false\n else\n true\n end \n end", "def check_guess\n if current_guess == secret_word\n player_won?\n else\n if secret_word.include? current_guess\n show_letter\n puts \"This word includes the guessed letter\\n\\n\"\n elsif current_guess == \"save\"\n create_save\n puts \"Game saved! Exiting game!\"\n exit\n else\n show_letter\n puts \"This word does not include the guessed letter\\n\\n\"\n end\n end\n end", "def win?\n @correct_letters.join == @secret_word\n end", "def check_guess(user_guess)\n\t\t@guess_count += 1\n\t\tletter_guessed(user_guess)\n\t\tif @answer_word.include?(user_guess)\n\t\t\tupdate_word(user_guess)\n\t\t\tputs \"-- RIGHT ON! #{user_guess} is in the word! Keep going! --\"\n\t\telse \n\t\t\tputs \"-- WRONG! That letter is not in the word! Try again: --\"\n\t\tend\n\t\t@guess_count\n\tend", "def check(guess)\n correct = 0\n\n if @guessed.include?(guess)\n @message = \"Choose another letter!\"\n else\n @message = \"\"\n @guessed << guess\n @to_guess.each_with_index do |char, index|\n if guess == char\n @guessing[index] = guess\n correct += 1\n end\n end\n @lives -= 1 if correct == 0\n end\n\n if @guessing.join == @to_guess.join\n @message = \"#{@guessing.join} was the word. You won!!\"\n @status = \"disabled\"\n end\n if @lives == 0\n @message = \"No lives left! You lost! The word was: \\\"#{@to_guess.join}\\\"\"\n @status = \"disabled\"\n end\n\n end", "def check_if_correct(word, letter)\n if word.include?(letter)\n index = word.index(letter)\n word[index] = '' # Clear the letter from word so it can check for other instances of letter\n @hints[index] = letter\n check_if_correct(word, letter) # It will loop through every instace of letter on word\n elsif !@hints.include?(letter)\n @incorrect.push(letter) unless @incorrect.include?(letter)\n @lives += 1\n end\n end", "def correct?(word)\n if @word == word\n @guessed_correctly = true\n return true\n end\n false\n end", "def guessed_all_correct?\n if self.output == self.word \n puts \"You have guessed the word\"\n end\n end", "def check_guess\n\t\t@word.include?(@guess)\n\n\tend", "def check_guess(word, guess)\n if word.include? guess\n @correct_guess = true\n\n elsif !word.include? guess\n @correct_guess = false\n end\nend", "def good_guess?\n @code_word.include?(@word_guesser.guess)\n end", "def repeat_guess(letter)\n\t\tif @attempted_letters.include?(letter)\n\t\t\tputs \"you already guessed that...\"\n\t\t\treturn true\n\t\tend\n\t\t\treturn false\n\tend", "def getguess guess\r\n\t\t\t\t\t@spin_flag = false\r\n\t\t\t\t if guess.length == 1\r\n\t\t\t\t if check_repeated_choice guess\r\n\t\t\t\t @message = \"Already guessed this letter!\"\r\n\t\t\t\t if @console\r\n\t\t\t\t\t\t\t\t@output.puts \"#{@message}\"\r\n\t\t\t\t\t\t\t\tword_input = take_user_word_input\r\n\t\t\t\t\t\t\t\tvalid = false\r\n\t\t\t\t\t\t\t while !valid do\r\n\t\t if validate_input word_input\r\n\t\t valid = true\r\n\t\t else\r\n\t\t @output.puts \"Invalid input\"\r\n\t\t word_input = take_user_word_input\r\n\t\t end\r\n\t\t\t\t\t\t\t end\r\n\t\t\t\t\t\t\t\tif check_enter word_input\r\n\t\t\t\t\t\t\t\t\t\t@break_flag = true\r\n\t\t\t\t\t\t\t\telse\r\n\t\t\t\t\t\t\t\t getguess word_input\r\n\t\t\t\t\t\t\t\tend\r\n\t\t\t\t\t\telse\r\n\t\t\t\t\t\t\t@spin_flag = true\r\n\t\t\t\t end\r\n\t\t\t\t else\r\n\t\t\t\t \t@message=\"Guess a letter from the word/phrase.\"\r\n\t\t\t\t @guess_counter+=1\r\n\t\t\t\t check_guess guess\r\n\t\t\t\t set_guess_analysis guess\r\n\t\t\t\t end\r\n\t\t\t\t success = check_phrase @resulta.join(',').gsub(\",\",\"\")\r\n\t\t\t\t return success ? true : false\r\n\t\t\t\telse\r\n\t\t\t\t\t if check_phrase guess\r\n\t\t\t\t\t\t phrase = @secretword.chars\r\n\t\t\t\t\t\t i = 0\r\n\t\t\t\t\t\t while i < phrase.length do\r\n\t\t\t\t\t\t\t\t\t\t@resulta[i] = phrase[i]\r\n\t\t\t\t\t\t\t\t\t\ti += 1\r\n\t\t\t\t\t\t end\r\n\t\t\t\t\t\t return true\r\n\t\t\t\t\t else\r\n\t\t\t\t\t\t @num_guessed = 0\r\n\t\t\t\t\t\t incrementturn\r\n\t\t\t\t\t\t @guess_counter+=1\r\n\t\t\t\t\t\t set_guess_analysis guess\r\n\t\t\t\t\t\t return false\r\n\t\t\t\t\t end\r\n\t\t\t\tend\r\n\t\t\t\tend", "def char_valid?(char, guesses, target)\n\n if target == '_'\n return !guesses.include?(char)\n end\n\n char == target\n end", "def guess(letter)\n raise InvalidGuessException.new(\"Invalid Guess!\") unless valid_guess?(letter)\n \n if word_has?(letter)\n \tput_letter_on_board(letter)\n else\n wrong_letter(letter) if !@guesses.include? letter\n end\n end", "def get_guess\n @guess = \"\"\n until @guess.match(/^[a-z]$/) && !@already_guessed.include?(@guess)\n print \"Please enter a letter. \"\n @guess = gets.chomp.downcase\n if @guess == 'save'\n save_game\n elsif @already_guessed.include?(@guess)\n puts \"You have already guessed that letter. Please try again.\"\n elsif !@guess.match(/^[a-z]$/)\n puts \"That is not a valid guess. Please enter a single letter.\"\n end\n end\n @guess\n end", "def guess_letter\n guess = \"\"\n if @letters_guessed.size > 0\n puts \"\\nSo far, you have already guessed the following letters:\"\n puts \"(\" + @letters_guessed.join(\", \") + \")\"\n end\n begin\n puts \"\\n\\nPlease enter a letter for your guess: \"\n puts \"(or type the entire keyword: 'SAVE' or 'EXIT')\"\n guess = gets.chomp.strip.upcase\n if guess == \"SAVE\"\n save_game\n elsif guess == \"EXIT\"\n puts \"\\nExiting the current round...\"\n puts \"\\n=================================================\"\n else\n error_msg1 = \"Selected letter was not of the correct format.\"\n raise ArgumentError.new(error_msg1) unless guess =~ /^[A-Z]$/\n error_msg2 = \"Selected letter has already been guessed.\"\n raise ArgumentError.new(error_msg2) if @letters_guessed.include?(guess)\n end\n rescue ArgumentError=>e\n puts \"Error: #{e.message}\"\n retry\n end\n return guess\n end", "def check_letters(letter_guessed)\n if @secret_word.include?(letter_guessed)\n @characters_guessed_correctly << letter_guessed\n puts 'you guessed correctly'\n puts replace_correct_letters\n else\n puts 'you guessed wrong'\n @guess_count -= 1\n end\n end", "def evaluate_players_letter()\n letter= @player1.give_letter()\n if @hiddenword1.determine_if_correct_letter_given(letter)\n p @hiddenword1.obscured_word\n @guessed_letters.push(letter)\n else\n @player1.lives-=1\n p \"Please try again\"\n p @guessed_letters\n p @hiddenword1.obscured_word\n end\n end", "def guess!(letter)\n self.word.include? letter\n self.letter = letter\n end", "def letter_match?(letter)\n if @secret.include?(letter)\n return true; end\n return false\n end", "def check_guess(word, char)\n if word.downcase.include?(char.downcase) && AVAILABLE_LETTERS.include?(char.downcase)\n AVAILABLE_LETTERS.delete(char.downcase)\n else\n AVAILABLE_LETTERS.delete(char.downcase)\n $incorrect_guesses += 1\n end\n puts display_word(word)\nend", "def guess\n loop do\n input = gets.chomp\n (\"a\"..\"z\").include?(input) ? (return input) : (puts \"Invalid input - single English-alphabet characters only\")\n end\n end", "def validate_letter(letter)\n\t\t# If user wants to save, save game\n\t\tif letter.downcase == \"save\"\n\t\t\tsave_game\n\t\t# If letter has already been guessed (either in word or in missed letters) make another guess\n\t\telsif @guess.include?(letter) || @wrong_letters.include?(letter)\n\t\t\tputs\n\t\t\tputs \"Oops, you guessed that letter already. Try again!\"\n\t\t\tputs\n\t\t\tget_guess\n\t\t# If letter is not in the alphabet\n\t\telsif (letter =~ /[[:alpha:]]/) != 0\n\t\t\tputs\n\t\t\tputs \"Oops, you must enter a letter. Try again!\"\n\t\t\tputs\n\t\t\tget_guess\n\t\t# If too many letters were chosen\n\t\telsif letter.length != 1\n\t\t\tputs\n\t\t\tputs \"Oops, you must enter only ONE letter. Try again!\"\n\t\t\tputs\n\t\t\tget_guess\n\t\t# All good! Check if the letter won the game\n\t\telse\n\t\t\tcheck_guess(letter)\n\t\tend\n\tend", "def check_guess(letter)\n @indices = gameboard[0].each_index.select { |i| gameboard[0][i].downcase == letter }\n if @indices.empty?\n incorrect_guesses << letter\n puts 'Sorry, the secret word does not contain that letter'\n else\n @indices.each do |index|\n gameboard[1][index] = gameboard[0][index] # letter\n end\n puts 'Good guess!'\n end\n end", "def guess(letter)\r\n\t\t\r\n\t\tif(@word.include?(letter))\r\n\t\t @good_guesses.add(letter)\r\n\t end\r\n\t\r\n\tend", "def guess_letter(a_letter)\n p a_letter.downcase\n @word.split(\"\").each_with_index do |another_letter, index|\n if a_letter == another_letter\n @input_word[index] = a_letter\n puts \"Correct! Here are your guesses so far\"\n p @input_word\n end\n if !@word.include? (a_letter)\n end\n end\n end", "def validate_guess(guess)\n valid_chars?(guess) && valid_length?(guess) \n end", "def guess(letter)\r\n letter = letter.downcase\r\n #find the guess\r\n returnValue = @word.count(letter) \r\n case returnValue\r\n when 0\r\n #Meaning this was an invalid guess\r\n @count-=1\r\n #maybe for debugging purposes\r\n @guessedFalse << letter\r\n else\r\n #maybe for debugging purposes\r\n @guessedTrue << letter\r\n #get all index of a matching letter\r\n arryOfMatchesIndexs = (0 ... @word.length).find_all { |i| @word[i,1] == letter }\r\n #iterate through the matches and replace the shadow word\r\n arryOfMatchesIndexs.each { |x| \r\n @shadowWord[x] = letter \r\n }\r\n \r\n #if the shadowWord array does not have any underscroes then we win \r\n if (@shadowWord.index(\"_\")).nil? \r\n @win = true\r\n end\r\n end\r\n #return the value of found\r\n returnValue\r\n end", "def guess_letter\n \tloop do \n \t puts \"Guess a letter or type 'save' to save the game and continue later.\"\n \t letter = gets.chomp.downcase.strip\n \t if letter == \"save\"\n \t \tsave\n \t else\n if letter.match(/[a-z]/) && letter.length == 1\n \t\t return letter\n else\n \t puts \"Invalid Character - Try Again\"\n \t end\n end\n end\n end", "def guess_compare(guess)\n # Defining correct_guess as a guess where the letter is properly included\n correct_guess = @secret_word.include? guess\n if correct_guess == true\n puts \"The letter #{guess} is correct! Good job!\"\n print_teaser guess\n else\n @lives -= 1\n puts \"The letter #{guess} is incorrect!\"\n puts \"The hangman has #{@lives} lives left!\"\n end\n player_guess\n end", "def check_for_correct_letters(user_guess)\n @correct_letters << user_guess.count do |guess_char|\n @solution.include?(guess_char)\n end\n end", "def include?(letter)\n @guess_spaces +=1\n guessed_letter << letter\n if @real_word.include?(letter)\n letter_index = 0\n @real_word.each_char do |l|\n @guess_word[letter_index] = l if \n l == letter\n letter_index += 1\n end\n return true\n else\n return false\n end\n end", "def valid_word_guess?(guess)\n if !guess.match?(/\\A([a-z]|[-]|\\d){2,}\\z/) \n puts \"Not a legal word guess! Guess again.\"\n return false\n elsif @incorrect_guesses.include?(guess) || @correct_guesses.include?(guess)\n puts \"You already guessed that word. Guess again.\\n\\n\"\n return false\n else\n return true\n end\n end", "def correct?(guess)\n guess == @back\n end", "def good_letter(letter)\n if $bucket.include? letter # check to see if letter has already been guessed and reprompt if so\n $prompt = \"You already guessed that one - TRY AGAIN!\"\n elsif letter[/[a-zA-Z]+/] and letter.length == 1 # check is a single -letter- has been entered\n $bucket.push(letter) # if so, add it to the bucket array\n letter_test(letter) # then pass it to letter_test()\n else # if multiple letters, non-alpha characters or nothing has been entered\n $prompt = \"Enter a single letter - TRY AGAIN!\" # reprompt user to try again\n end\nend", "def letter_check(letter)\n @word.chars.each_with_index do |letter_in_word, index|\n if letter == letter_in_word\n @result_str[index] = letter\n end\n end\n if !@word.include?(letter)\n puts \"Sorry try again\"\n end\n @result_str\n end", "def letter_guess(input,dead_man)\n if @letters_guessed_array.include?(input) || dead_man.wrong_letters.include?(input)\n puts \"You have already guessed this letter!\"\n display(dead_man)\n elsif @correct_word_array.include?(input)\n @letters_guessed_array.each_with_index do |letter, index|\n @letters_guessed_array[index] = input if @correct_word_array[index] == input\n end\n puts \"The letter #{input} is in the word.\"\n if @letters_guessed_array.include?(\"__\")\n display(dead_man)\n else\n win\n end\n else\n puts \"The letter #{input} is not in the word.\"\n dead_man.wrong_letters.push(input)\n dead_man.wrong_guesses += 1\n display(dead_man)\n end\n end" ]
[ "0.83395875", "0.8311119", "0.8305276", "0.8293208", "0.8265234", "0.82490057", "0.82372975", "0.81611437", "0.8147528", "0.8065921", "0.80438083", "0.80395985", "0.8036576", "0.7993273", "0.7969394", "0.79674435", "0.79671854", "0.79646635", "0.7919829", "0.7909802", "0.79068714", "0.7897927", "0.788983", "0.787984", "0.7875416", "0.78573996", "0.7854088", "0.7846234", "0.7841219", "0.783886", "0.78380823", "0.78245", "0.7816471", "0.7812562", "0.78094083", "0.7792847", "0.77901334", "0.77899724", "0.77615297", "0.77528995", "0.7747689", "0.7746304", "0.7736395", "0.7729123", "0.77254945", "0.77036494", "0.76843435", "0.76751333", "0.76689523", "0.76542354", "0.7654189", "0.76537746", "0.7631569", "0.76247025", "0.7624145", "0.7610112", "0.7596138", "0.759022", "0.75720334", "0.7550261", "0.7543881", "0.7537449", "0.7534433", "0.7528931", "0.75223315", "0.751607", "0.75152916", "0.7510816", "0.7498065", "0.7491878", "0.74879646", "0.74862397", "0.747487", "0.7468401", "0.7459655", "0.74484557", "0.7446089", "0.7419169", "0.7417922", "0.7410896", "0.7409541", "0.74046594", "0.7401892", "0.73944503", "0.73871726", "0.7382239", "0.73789847", "0.7378806", "0.73723835", "0.73668945", "0.7362175", "0.7354544", "0.73501253", "0.73425305", "0.7336482", "0.7330623", "0.73060805", "0.7278334", "0.7277442", "0.7265585", "0.7226851" ]
0.0
-1
METHOD: check if guess duplicated INPUT: guessed letter as string OUTPUT: true or false
def duplicate?(guess) @guesses.include? guess end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def repeated_guess?\r\n if @guessed_letters.include? @letter\r\n puts \"You have already guessed the letter #{@letter}, try again.\"\r\n return true\r\n end\r\n end", "def already_guessed? (letter)\r\n letter = letter.downcase\r\n @guessed_letters.include? letter\r\n end", "def repeat_guess(letter)\n\t\tif @attempted_letters.include?(letter)\n\t\t\tputs \"you already guessed that...\"\n\t\t\treturn true\n\t\tend\n\t\t\treturn false\n\tend", "def already_guessed?(letter, previous_attempts)\r\n if previous_attempts.include?(letter)\r\n puts \"You already guessed that\"\r\n return true\r\n else\r\n return false\r\n end\r\nend", "def guess?(letter)\n correct = false\n @@secret.length.times do |i|\n if (@@secret[i] == letter && @@progress[i] == '_')\n @@progress[i] = letter\n correct = true\n end\n end\n @@incorrect << letter if !correct\n @@guesses += 1\n puts(\"secret: #{@@secret}\")\n correct\n end", "def setguessedletter(letter)\n\t\t@letter_exists = false\n\t\t\n\t\t@guessed_letters.each do |char|\n\t\t\tif char == letter\n\t\t\t\t@letter_exists = true\n\t\t\tend\n\t\tend\n\t\treturn @letter_exists\n\tend", "def correct_guess?(letter)\n if @word_selected.include?(letter)\n if @correct_guesses.empty?\n @correct_guesses << letter\n elsif @correct_guesses.include?(letter)\n puts 'Letter already guessed! try another one!'\n else\n @correct_guesses << letter\n end\n return true\n end\n false\n end", "def check_letter(input_letter)\n # Each time we check, the number of guesses is increased \n @guess_count += 1\n \n # Transform the words into arrays for convenience\n arr_word_to_guess = @word_to_guess.split('') \n arr_guessed_word = @guessed_word.split('') \n \n # Search for the input_letter in arr_word_to_guess\n index_found = arr_word_to_guess.each_index.select{|i| arr_word_to_guess[i] == input_letter}\n \n if (index_found == []) then\n return false \n else \n # if the letter is found, update the guessed word\n n_found = index_found.size\n i = 0 \n n_found.times do \n arr_guessed_word[index_found[i]] = input_letter\n i += 1\n end\n @guessed_word = arr_guessed_word.join('')\n return true\n end \n end", "def repeated?(guessed_char, running_guess, misses)\n guess_downcase = guessed_char.downcase\n running_guess.include?(guess_downcase) || misses.include?(guess_downcase)\n end", "def valid_guess?(letter_guess)\n (letter_guess.length == 1 && !letter_guess.match(/[^A-Za-z]/) && !@guesses.include?(letter_guess)) ? true : false\n end", "def try_guess(char)\n if self.already_attempted?(char)\n p \"that has already been attempted\"\n return false\n else\n matching_indices = self.get_matching_indices(char)\n self.fill_indices(char, matching_indices)\n\n @remaining_incorrect_guesses -= 1 if matching_indices.empty?\n \n @attempted_chars << char\n return true\n end\n end", "def guess?(letter)\n if !self_is_letter?(letter)\n puts \"Not a letter!\"\n return false\n end\n if @word.include? letter\n if(@word.count(letter) > 1)\n while(@word.include? letter)\n puts \"Hit this while loop\"\n index = @word.index(letter)\n @word.slice!(index,0)\n @word[index] = '_'\n\n puts \"Word\" + @word\n @guessedWord.slice!(index,0)\n @guessedWord[index] = letter\n\n end\n else\n index = @word.index(letter)\n\n @guessedWord.slice!(index,0)\n @guessedWord[index] = letter\n\n\n\n end\n\n\n output_word()\n return true\n end\n p \"Word does not contain #{letter}\"\n @health -= 1\n p \"you have #{@health} tries left\"\n return false\n end", "def guess?(letter)\n if @guessed_letter.include?(letter)\n puts \"You already guessed that letter!\"\n return\n end\n @guessed_letter << letter\n ​\n found = false\n if @characters.include?(letter)\n found = true \n puts \"Yes that letter is in the word!\"\n else\n puts \"Wrong answer!\"\n end \n ​\n @characters.each_with_index do |char, index|\n if char == letter\n @displayed_character[index] = letter\n end\n end\n found\n end", "def valid_guess?(letter)\n letter.length==1 && (\"a\"..\"z\").include?(letter)\n end", "def guess_check(letter_guessed)\r\n# \ti. Run a loop to be sure that the letter guessed is a string and if it isn't a string or a single letter put up a warning message and the method\r\n\tif letter_guessed.class.to_s != \"String\" or letter_guessed.length !=1\r\n\t\tputs \"Guesses must be a single letter. Enter another guess.\"\r\n\t\t@guess_check = false\r\n# \tii. If it is a string and a single character continue and run to see if the letter has been guessed already or not. \r\n\telsif @guessed.include? letter_guessed\r\n\t\tputs \"Letter #{letter_guessed} guessed already. Enter another guess\"\r\n\t\t@guess_check = false\r\n\telse\r\n\t\t@guess_check = true\r\n\tend #if\r\nend", "def guess(letter)\n is_letter = /^[a-zA-Z]$/\n if letter.nil? or letter.empty? or not letter.match(is_letter)\n throw ArgumentError \n end\n letter.downcase!\n if self.guesses.include? letter or self.wrong_guesses.include? letter\n return false\n end\n if self.word.include? letter\n self.guesses = self.guesses + letter\n else\n self.wrong_guesses = self.wrong_guesses + letter\n end\n return true\n end", "def check_guess(letter)\n\t\t# If the guessed letter is in the word, replace \"_\" in the guess variable with the letter in the right spot\n\t\t@word.each_with_index do |l, i|\n\t\t\tif l == letter\n\t\t\t\t@guess[i] = letter\n\t\t\tend\n\t\tend\n\t\t# If the guessed word and the answer are the same, the user won!\n\t\t# Show message and if the game was previously saved, delete it\n\t\tif @word.join == @guess\n\t\t\tputs \n\t\t\tshow_board\n\t\t\tputs \"You won!!\"\n\t\t\tif @running_saved_game != nil\n\t\t\t\tover_write_data\n\t\t\tend\n\t\t\tgo_again\n\t\t# Got a letter but didn't win. Get another guess\n\t\telsif @word.include?(letter)\n\t\t\tputs\n\t\t\tputs \"You got a letter!\"\n\t\t\tget_guess\n\t\t# Letter wasn't in word, put letter in missed letter variable and guess again\n\t\telse\n\t\t\tputs \n\t\t\tputs \"No #{letter}'s.\"\n\t\t\t@wrong_letters.sub!(\"_\", letter)\n\t\t\t@turn += 1\n\t\t\tget_guess\n\t\tend\n\tend", "def guess_correct(letter)\n\t\tif @secret_word.include?(letter)\n\t\t\t@secret_word.each_with_index do |correct, index|\n\t\t\tif letter == correct\n\t\t\t\t@display[2*index+1] = letter\n\t\t\t\tputs @display\n\t\t\t\t@attempted_letters << letter\n\t\t\t\tend\n\t\t\tend\n\t\t\t@number_of_guesses -= 1\n\t\t\treturn true\n\t\telse \n\t\t\treturn false\n\t\tend \n\tend", "def history_checker(guess)\n if @used_letter.include?(guess)\n puts \"You already used that letter\"\n else\n \t#increments @guess_count if letter was unique \n @guess_count += 1 \n @used_letter << guess\n end\n end", "def check_guess(player_guess, display)\n letter_found = false\n @secret_word.chars.each_with_index do |char, index|\n if char.downcase == player_guess\n display[index] = char\n letter_found = true\n end\n end\n letter_found\n end", "def guess char\n #get 1st char\n \n if char.nil?\n raise ArgumentError, 'Argument is not string' \n return false\n end\n if char.length != 1\n raise ArgumentError, 'Argument is not string'\n return false\n end \n if char.match(/[a-zA-Z]/) == nil\n raise ArgumentError, 'Argument is not string' \n return false\n end\n \n pick = char.chr.downcase\n\n #catch replicant entries\n if @guesses.match(\"#{pick}\") != nil\n # @word_with_guesses << \"You have already used that letter\"\n return false\n end \n \n if @wrong_guesses.match(\"#{pick}\") != nil\n# @word_with_guesses << \"You have already used that letter\"\n return false\n end \n \n #actual match\n if @word.match(\"#{pick}\") != nil\n guesses << pick # 1st char\n else\n wrong_guesses << pick # \n @attempt += 1\n end\n \n # build up guess string i.e. \"----a-e\"\n @word_with_guesses = '';\n @check_win_or_lose = :win\n word.each_char { |a|\n if @guesses.match(\"#{a}\") != nil \n @word_with_guesses << a\n else\n @word_with_guesses << '-'\n @check_win_or_lose = :play\n end\n }\n \n #check game status\n if @attempt > 6\n @check_win_or_lose = :lose\n end\n \n return true\n end", "def process_guess(letter)\n\n\t\tletter = letter.downcase\n\n\t\tif @prev_guesses.include? letter\n\t\t\tputs \"\\\"#{letter}\\\" has already been guessed\"\n\t\t\tprint_status\n\t\t\treturn false \n\t\telse\n\t\t\t@prev_guesses << letter\n\t\t\tdecrement_guesses\n\t\tend\n\n\t\tif @original_word.include? letter\n\t\t\tupdate_gameboard(letter)\n\t\t\tprint_status\n\t\t\ttrue\n\t\telse\n\t\t\tprint_status\n\t\t\tfalse\n\t\tend\n\tend", "def all_letters_guessed?\n @word_to_guess.each do |letter_in_word_to_guess|\n if !has_been_guessed_correctly?(letter_in_word_to_guess)\n return false\n end\n end\n return true\n end", "def is_repeated?(test)\n flag = false\n @guesses == test || @wrong_guesses == test ? flag = true : flag = false\n #puts \"@guesses == test || @wrong_guesses == test #{@guesses == test || @wrong_guesses == test}\"\n\n if flag\n return flag\n else\n #puts @word\n word = @word.split(\"\")\n #puts word\n guessChar = @guesses.split(\"\")\n word.each { |x|\n if word.include?(guessChar)\n flag = true\n return flag\n end\n }\n\n end\n return flag\n end", "def guess? (letter)\n \t\tif word.include?(letter)==true\n \t\tvalid_guess(letter)\n \telse\n \t\tinvalid_guess(letter)\n \tend\n end", "def check_letter(user_guess)\n @letter = user_guess.length == 1\n end", "def wrong_guess(letter)\n\t\tif !@attempted_letters.include?(letter)\n\t\t\tputs \"WRONG....\"\n\t\t\t@attempted_letters << letter\n\t\t\t@number_of_guesses -= 1 \n\t\t\tp @number_of_guesses\n\t\t\tp @display\n\t\t\tp \"you have #{@number_of_guesses} guesses left...\"\n\t\t\treturn true\n\t\tend\n\tend", "def guess_letter?(letter)\r\n\r\n\t\t#Add 1 to the total number of guesses in game IF not already guessed (in the guesses array)\r\n\t\tif @guesses.index(letter) == nil\r\n\t\t\t@guesses << letter\r\n\t\t\t@num_of_guesses += 1\r\n\t\tend\r\n\r\n\t\t#If the letter exists (aka returns valid index)\r\n\t\t# 1. Loop through letters in word and compare to the guessed letter\r\n\t\t# 2. If guessed letter = original letter in word, set board = to letter in that index\r\n\t\t# 3. Return True\r\n\t\t#Else if the letter does not exist in word array\r\n\t\t# 1. Return False\r\n\t\tif @word_array.index(letter)\r\n\t\t\tindex = 0\r\n\t\t\t@word_array.each do|i|\r\n\t\t\t\tif letter == i\r\n\t\t\t\t\t@board_array[index] = letter\r\n\t\t\t\tend\r\n\t\t\t\tindex+=1\r\n\t\t\tend\r\n\t\t\ttrue\r\n\t\telse\r\n\t\t\tfalse\r\n\t\tend\r\n\tend", "def has_been_guessed?(in_letter)\n @letters_tried.any? {|letter_combo|letter_combo[:letter] == in_letter}\n end", "def guesses_include_in?(letter)\n #puts @word\n word = @word.split(\"\")\n guessChar = @guesses.split(\"\")\n #puts \"***guesses_include_in? #{word} #{guessChar}\"\n word.each do |w|\n guessChar.each do |g|\n #puts \"w == g && g == letter\"\n #puts \"#{w} == #{g} && #{g} == #{letter} ==> #{w == g && g == letter}\"\n if w == g && g == letter\n return true\n else\n #return false\n end\n end\n\n end\n return false\nend", "def check_guess(input)\n @guessed_letters.push(input)\n if @secret_word.match?(input)\n @secret_word.split(//).each_with_index { |char, index| @guessed_word[index] = char if char == input }\n else\n puts 'Incorrect'\n @guesses_left -= 1\n @wrong_letters.push(input)\n end\n end", "def repeat_guess(guess, str)\n if @guess != @str[-1]\n print \"Repeat. Please guess different letter.\"\n return\n end\nend", "def check_guess(guess)\n # checks human guess, displays discovered, and return if letter found\n letter_found = false\n self.secret_word.split('').each_with_index do |chr, ind|\n if chr == guess\n self.currently_discovered[ind] = chr\n letter_found = true\n end\n end\n p self.currently_discovered\n letter_found\n end", "def is_a_letter?(guess)\n return true if @word.include?(guess)\n return false\n end", "def guess_letter\n\t\tprint \"Your guess: \"\n\t\tguess = gets.chomp.downcase\n\t\treturn guess if guess == \"save\"\n\t\tif (guess.between?('a','z') && !(@guessed_letters.include? guess)\\\n\t\t\t&& guess.length == 1)\n\t\t\tprocess_guess(guess)\n\t\t\t@guessed_letters << guess\n\t\t\t@turns += 1\n\t\telse\n\t\t\tif guess.between?('a','z')\n\t\t\t\tputs \"\\nYour guess must be ONE letter\" unless guess.length == 1\n\t\t\t\tputs \"\\nYou've already guessed that!\" if @guessed_letters.include? guess\n\t\t\telse\n\t\t\t\tputs \"\\nYour guess must be a letter!\" unless guess.between?('a','z')\n\t\t\tend\n\t\t\tputs \"Try again!\\n\\n\"\n\t\t\tguess = guess_letter\n\t\tend\n\t\tguess\n\tend", "def include?(letter)\n @guess_spaces +=1\n guessed_letter << letter\n if @real_word.include?(letter)\n letter_index = 0\n @real_word.each_char do |l|\n @guess_word[letter_index] = l if \n l == letter\n letter_index += 1\n end\n return true\n else\n return false\n end\n end", "def check_guess(guess)\n\t\tif @guesses.include?(guess)\n\t\t\tputs 'This is a repeated guess. Try another letter!'\t\n\t\telse\n\t\t\t@guesses << guess\n\t\t\tif @secret_word_arr.include?(guess)\n\t\t\t\t# logic to show the guess inside the @dashes_arr\n\t\t\t\t@word_length.times do |i|\n\t\t\t\t\tif @secret_word_arr[i] == guess\n\t\t\t\t\t\t@dashes_arr.delete_at(i)\n\t\t\t\t\t\t@dashes_arr.insert(i, guess)\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\telse\n\t\t\t\t@guess_count += 1\n\t\t\t\tattempts = @word_length - @guess_count\n\t\t\t\tputs \"Incorrect guess. You have #{attempts.to_s} attempts left. Try again!\"\n\t\t\tend\n\t\tend\n\t\t@display_chars\n\tend", "def check_letter_in_random_word(guess_letter)\n position_letter = 0\n @correct_guess = false\n @random_word.each_char do |letter_random_word|\n if letter_random_word == guess_letter\n change_guess_word_status(position_letter)\n @correct_guess = true\n end\n position_letter += 1\n end\n if @correct_guess == true\n line_of_30_stars\n puts \"WhoopWhoop: Letter '#{guess_letter}' is in the word!\\n\"\n else\n line_of_30_stars\n puts \"No, sorry, '#{guess_letter}' isn't in the word.\"\n end\n end", "def same_guess\n @guesses[0...-1].each do |letter|\n if @guesses[-1] == letter\n return true\n # else\n # return false\n # I couldn't figure out why this method would not return false if the last letter did not match.\n end\n end\nend", "def valid_letter_guess?(guess)\n if !guess.match?(/\\A([a-z]|[-]|\\d)\\z/)\n puts \"Not a letter! Guess again.\"\n return false\n elsif @incorrect_guesses.include?(guess) || @correct_guesses.include?(guess)\n puts \"You already guessed that letter. Guess again.\\n\\n\"\n return false\n else\n return true\n end\n end", "def guess letter\n raise InvalidGuessError if letter.strip.empty? || letter.length > 1\n letter = letter[0].upcase\n if @guesses.include?(letter)\n return {advance: false, message: \"#{letter} has already been played, silly!\"}\n else\n @guesses << letter\n end\n @guessed.each_with_index do |guessed_pos, index|\n if guessed_pos\n if letter == secret[index]\n return {advance: false, message: \"#{letter} has already been played, silly!\"}\n end\n else\n if letter == secret[index]\n reveal_all(letter)\n return {advance: true, message: \"We found #{letter}!\"}\n end\n end\n end\n {advance: true, message: \"Sorry, we did not find #{letter}!\"}\n end", "def good_letter(letter)\n if $bucket.include? letter # check to see if letter has already been guessed and reprompt if so\n $prompt = \"You already guessed that one - TRY AGAIN!\"\n elsif letter[/[a-zA-Z]+/] and letter.length == 1 # check is a single -letter- has been entered\n $bucket.push(letter) # if so, add it to the bucket array\n letter_test(letter) # then pass it to letter_test()\n else # if multiple letters, non-alpha characters or nothing has been entered\n $prompt = \"Enter a single letter - TRY AGAIN!\" # reprompt user to try again\n end\nend", "def check_guess(word, guess)\n if word.include? guess\n @correct_guess = true\n\n elsif !word.include? guess\n @correct_guess = false\n end\nend", "def check_letter(guess)\n if @word.include? guess\n puts \"You chose wisely!\"\n #find which position(s) the guess is in the word array\n correct_index_arr = @word.each_index.select { |i| @word[i] == guess }\n # rebuild @game_status with the correct letter guessed into that position of the word\n correct_index_arr.each do |index|\n @game_status[index] = guess\n end\n # if they don't make guess and put an empty response\n elsif guess.empty?\n puts \"You didn't make a guess. Try again.\"\n # if the user guesses the same wrong letter again\n elsif @wrong_guesses.include? guess\n puts \"You guessed that before! Try again.\"\n else\n @guesses_remaining -= 1\n puts \"wrong guess, the guesses remaining: #{@guesses_remaining}\"\n @wrong_guesses.push(guess)\n end\n end", "def has_been_guessed_correctly?(in_letter)\n @letters_tried.any? {|letter_combo|letter_combo[:letter] == in_letter && letter_combo[:correct] == true}\n end", "def guess(letter)\n # STEP 1: check to make sure the letter is not any non-letter character and\n # raises an error if it is\n if /^[a-zA-Z]+$/.match(letter)\n letter.downcase!\n else raise_error(\"Invalid letter\")\n end\n\n # STEP 2: check to make sure the user does not guess the same letter more\n # than once\n if @guesses.include? letter; return false; end\n if @wrong_guesses.include? letter; return false; end\n\n # STEP 3: check to see if the guessed letter matches any letters in the \n # word\n if @word.include? letter\n @guesses += letter\n # if there is a match, update the word_with_guesses to show where\n # in the string the letter was matched\n @word.each_char.with_index do |c, i|\n if c == letter\n @word_with_guesses[i] = c\n end\n end \n else \n @wrong_guesses += letter\n @attempts += 1\n end\n # update the number of attempts and call the function to check if\n # the user won, lost, or continues playing\n check_win_or_lose\n end", "def check_guess(guess)\n @current_guess = guess.downcase\n if @current_guess == @secret_word\n player_won?\n elsif @current_guess.length > 1 || @current_guess.nil?\n @feedback = \"Invalid Guess!\"\n else\n @feedback = \"\"\n if @secret_word.include? @current_guess\n show_letter\n else\n @turns -= 1\n end\n @guesses << @current_guess\n end\n end", "def check_letters(letter_guessed)\n if @secret_word.include?(letter_guessed)\n @characters_guessed_correctly << letter_guessed\n puts 'you guessed correctly'\n puts replace_correct_letters\n else\n puts 'you guessed wrong'\n @guess_count -= 1\n end\n end", "def respond_to_guess(letter)\n letter = letter.clone.downcase\n\n if @incorrect_letters.include?(letter) || @progress.include?(letter) || @progress.include?(letter.upcase)\n puts \"You already guessed that letter!\"\n puts \"\"\n elsif @word.include?(letter) || @word.include?(letter.upcase)\n update_progress(letter)\n unless @progress.include?(\"_\")\n @round_finished = true\n @guessed = true\n end\n else\n @incorrect_letters << letter\n @round_finished = true if @incorrect_letters.size == 6\n end\n print_hangman\n end", "def good_guess?\n current_guess == \"save\" || current_guess == secret_word || current_guess.length == 1\n end", "def letter_guessed(user_guess)\n\t\tif @guessed_letters.length == 0\n\t\t\t@guessed_letters << user_guess\n\t\telse \n\t\t\tif @guessed_letters.include?(user_guess)\n\t\t\t\tputs \"--You already guessed that letter! Try again!--\"\n\t\t\t\t@guess_count -= 1\n\t\t\telse\n\t\t\t\t@guessed_letters << user_guess\n\t\t\tend\n\t\tend\n\tend", "def guess(char)\n if char==''||!(char=~/[A-Za-z]/)\n raise ArgumentError\n else\n char = char.downcase\n if @guesses.include?(char)||@wrong_guesses.include?(char)\n return false\n else\n if @word.include?(char)\n @guesses+=char\n for i in 0..@word.length-1\n if @word[i]==char\n @word_with_guesses[i]=char\n end\n end\n if !@word_with_guesses.include?('-')\n @check_win_or_lose=:win\n end\n else\n @wrong_guesses+=char\n if @wrong_guesses.length>=7\n @check_win_or_lose=:lose\n end\n end\n return true\n end\n end\n end", "def guessed?\n \t(word.split('') - selected_letters).empty?\n\tend", "def check_guess(word, char)\n if word.downcase.include?(char.downcase) && AVAILABLE_LETTERS.include?(char.downcase)\n AVAILABLE_LETTERS.delete(char.downcase)\n else\n AVAILABLE_LETTERS.delete(char.downcase)\n $incorrect_guesses += 1\n end\n puts display_word(word)\nend", "def guess(letter)\r\n\t\t\r\n\t\tif(@word.include?(letter))\r\n\t\t @good_guesses.add(letter)\r\n\t end\r\n\t\r\n\tend", "def check_guess\n if current_guess == secret_word\n player_won?\n else\n if secret_word.include? current_guess\n show_letter\n puts \"This word includes the guessed letter\\n\\n\"\n elsif current_guess == \"save\"\n create_save\n puts \"Game saved! Exiting game!\"\n exit\n else\n show_letter\n puts \"This word does not include the guessed letter\\n\\n\"\n end\n end\n end", "def check_guess(guess)\n\t\tif @secret_word.include?(guess)\n\n\t\t\ttemp_secret_word = @secret_word.clone\n\t\t\ttemp_secret_word = temp_secret_word.split('')\n\n\t\t\ttemp_secret_word.each_with_index {|letter, index| @guess_line[index] = guess if temp_secret_word[index] == guess}\n\t\telse\n\t\t\t@misses << guess\n\t\t\t@incorrect_guesses_count += 1\n\t\tend\n\tend", "def check_letter(in_letter)\n # find out if this is a correct guess\n correct_status = false\n if word_to_guess.include? in_letter\n correct_status=true\n else\n # bad guess; decrement number_guesses_left\n @number_guesses_left -= 1\n end\n # put letter in letters_tried with correct/wrong status\n new_letter_combo = {\n letter: in_letter,\n correct: correct_status\n }\n letters_tried.push(new_letter_combo)\n return correct_status\n end", "def check_guess(letter)\n @indices = gameboard[0].each_index.select { |i| gameboard[0][i].downcase == letter }\n if @indices.empty?\n incorrect_guesses << letter\n puts 'Sorry, the secret word does not contain that letter'\n else\n @indices.each do |index|\n gameboard[1][index] = gameboard[0][index] # letter\n end\n puts 'Good guess!'\n end\n end", "def valid_guess?(player_guess)\n ('a'..'z').include?(player_guess) && !@guessed_letters.include?(player_guess)\n end", "def guess(letter)\n \n raise ArgumentError if letter.nil? ## Raise an error if the letter is null.\n raise ArgumentError if letter == '' ## Raise an error if the user entered an empty string. \n raise ArgumentError if !letter.match(/[a-zA-Z]/) ## Raise an error is the user entered a letter that is not in the alphabet.\n\n \n letter.downcase!\n \n # If word includes letter\n if(word.include? letter)\n # And the letter isnt already in guess\n unless (guesses.include? letter)\n # Add guessed word to guesses\n guesses.concat(letter)\n \n # For test case 14\n for i in 0..word.length do\n # If the guessedLetter is in the string, replace it with the guessed letter\n if(letter == word[i])\n word_with_guesses[i] = letter\n end\n \n end\n \n # If guessed letters match word set to win\n if(word_with_guesses == word)\n @check_win_or_lose = :win\n end\n \n return true # return true valid guess\n end #end unless\n return false # invalid guess false\n else\n unless (wrong_guesses.include? letter)\n # Add the guessed letter to the list of incorrected guesses\n wrong_guesses.concat(letter)\n \n # Wrong guesses greater than 7 set win or loose to loose\n if(@wrong_guesses.length>=7)\n @check_win_or_lose = :lose\n end\n \n return true\n end # end unless\n return false # invalid guess\n end # end for \n end", "def guess(letter)\r\n if word_has?(letter)\r\n \tput_letter_on_board(letter)\r\n else\r\n wrong_letter(letter) if !@guesses.include? letter\r\n end\r\n end", "def valid_guess?(guess)\n if guess =~ /^[a-z]$/ && !@try.include?(guess)\n true\n else\n false\n end\n end", "def is_repeated_guess(guess)\n @prev_guesses.include? guess\n end", "def check_guess(user_guess)\n\t\t@guess_count += 1\n\t\tletter_guessed(user_guess)\n\t\tif @answer_word.include?(user_guess)\n\t\t\tupdate_word(user_guess)\n\t\t\tputs \"-- RIGHT ON! #{user_guess} is in the word! Keep going! --\"\n\t\telse \n\t\t\tputs \"-- WRONG! That letter is not in the word! Try again: --\"\n\t\tend\n\t\t@guess_count\n\tend", "def guessing_for_the_win(letter)\n\t\tif repeat_guess(letter)\n\t\telsif guess_correct(letter)\n\t\telse wrong_guess(letter)\n\t\tend \n\n\t\tif @secret_word == @display\n\t\t\tcongrats\n\t\telsif @number_of_guesses > 0 \n\n\t\t\tp \"Keep guessing\"\n\t\telse\n\t\t\tfailure\n\t\tend\n\tend", "def already_guessed?(guessed_character)\n @guesses_made.include?(guessed_character)\n end", "def check_guess\n @already_guessed.push(@guess)\n if @secret_word.include?(@guess)\n @secret_word.split(\"\").each_with_index do |letter, index|\n if letter == @guess\n @blanks[index] = letter\n end\n end\n else\n @guesses_left -= 1\n @missed_letters.push(@guess)\n end\n @blanks\n end", "def g_happy(str)\n i = 0\n count = 0\n str.size.times do |letter|\n if str[letter] == \"g\"\n if str[letter] != str[i + 1]\n if str[letter] != str[i - 1]\n return false\n end\n end\n else\n count += 1\n end\n i += 1\n end\n if count == str.size\n return false\n else\n return true\n end\nend", "def g_happy(str)\n i = 0\n count = 0\n str.size.times do |letter|\n if str[letter] == \"g\"\n if str[letter] != str[i + 1]\n if str[letter] != str[i - 1]\n return false\n end\n end\n else\n count += 1\n end\n i += 1\n end\n if count == str.size\n return false\n else\n return true\n end\nend", "def is_good?(letter)\n @letters.include?(letter)\n end", "def guess(char)\n \n #Check if letter guessed is nil or empty or not a letter and throw error\n if char == nil \n raise ArgumentError\n elsif char == \"\"\n raise ArgumentError\n elsif !char.match(/[A-Za-z]/)\n raise ArgumentError\n end\n \n #Convert character to downcase to make it case insensitive.\n #Check if letter has already been guessed in correct or wrong guess buckets\n char = char.downcase\n if @guesses.include? char \n return false\n elsif @wrong_guesses.include? char\n return false\n end\n \n #Check if word contains letter. If yes, increment guesses by 1. If not, increment wrong guesses by 1.\n if @word.include? char\n @guesses += char\n return true\n else\n @wrong_guesses += char\n return true\n end\n\n end", "def check_guess\n\t\t@word.include?(@guess)\n\n\tend", "def guess(letter_guessed)\r\n# \ti. Run loop to see if the letter has been guessed yet.\r\n\tif word_split.include? (letter_guessed)\r\n\t\t# a. Iterate through the word characters to see if it includes the letter guessed\r\n\t\t@word_split.each_with_index do |char, index|\r\n\t\t\tif word_split[index] == letter_guessed\r\n\t\t\t\t@guessed[index] = letter_guessed\r\n\t\t\tend #if\r\n\t\tend #do\r\n\t\t# b. If it is right then put you have guessed a letter and then ask for another guess repeat method\r\n\t\tputs \"You guessed correctly. Enter another guess\"\r\n# \t\tc. If it is wrong then put you have guessed wrong and ask for another guess. Maybe return how many guesses you have left?\r\n\telse\r\n\t\t@guess_count +=1\r\n\t\tputs \"You guessed incorrectly. Enter another guess\"\r\n\tend#if\r\nend", "def guess_letter(letter)\n won = false\n failed_guess = feedback(letter)\n if failed_guess\n @tries_left -= 1\n else\n won = won?(@display_word.split(\" \").join(\"\"))\n end\n won\n end", "def check_guess\n @guess_count += 1 # Increment guess count\n @guess_feedback = \"\"\n return true if @input == @current_word # Return true value if input is same as chosen word - correctly guessed word\n i = 0\n @input.split('').each do |letter| # Split user input and check if each letter is in exact position as chosen word, or if it is somewhere or not in the word at all\n # Use << to append to string as this is faster and doesn't create new string objects, as opposed to concatenation using a +\n # Below line uses nested ternary operators, where the condition is first evaluated and then if true, the first statement is executed, if false, the second statement is executed\n # This allows the code to be more readable and shorter\n @current_word.index(letter) == i ? (@guess_feedback << \"exact \") : (@current_word.index(letter).nil? ? (@guess_feedback << \"miss \") : (@guess_feedback << \"near \"))\n i += 1\n end\n puts @guess_feedback\n end", "def guess(letters)\n raise ArgumentError if letters == \"\"\n raise ArgumentError if letters !~ %r{\\w}\n letters.downcase!\n if @word.include?(letters) \n !@guesses.include?(letters) ? @guesses << letters : false\n\n else\n @wrong_guesses.include?(letters) ? false : wrong_guesses << letters \n end\n end", "def guess!(letter)\n end", "def get_guess\n @guess = \"\"\n until @guess.match(/^[a-z]$/) && !@already_guessed.include?(@guess)\n print \"Please enter a letter. \"\n @guess = gets.chomp.downcase\n if @guess == 'save'\n save_game\n elsif @already_guessed.include?(@guess)\n puts \"You have already guessed that letter. Please try again.\"\n elsif !@guess.match(/^[a-z]$/)\n puts \"That is not a valid guess. Please enter a single letter.\"\n end\n end\n @guess\n end", "def check_word(guess)\n\t\tguess_used = false\n\t\t@guess_history.each do |x|\n\t\t\t\tif x == guess\n\t\t\t\t\tguess_used = true\n\t\t\t\tend\n\t\t\tend\n\t\tif !guess_used\n\t\t\t@guess_count += 1\n\t\t\t@guess_history << guess\n\t\tend\n\t\tif guess == @target_word\n\t\t\t@win = true\n\t\t\t@is_over = true\n\t\telse\n\t\t\tfalse\n\t\tend\n\tend", "def check_if_correct(word, letter)\n if word.include?(letter)\n index = word.index(letter)\n word[index] = '' # Clear the letter from word so it can check for other instances of letter\n @hints[index] = letter\n check_if_correct(word, letter) # It will loop through every instace of letter on word\n elsif !@hints.include?(letter)\n @incorrect.push(letter) unless @incorrect.include?(letter)\n @lives += 1\n end\n end", "def invalid?(guess)\n\t\t@guessed_letters.include?(guess)\n\tend", "def try_guess(guess)\n if !is_repeated_guess(guess)\n deduct_available_guesses\n add_to_previous_guesses(guess)\n end\n\n if guess.length > 1\n @secret_word == guess ? @is_over_won = true : false\n elsif guess.length > 0\n if @secret_word.include? guess\n update_current_state(guess)\n !is_word_complete() ? true : @is_over_won = true\n else\n false\n end\n else\n false\n end\n end", "def guess_letter(a_letter)\n p a_letter.downcase\n @word.split(\"\").each_with_index do |another_letter, index|\n if a_letter == another_letter\n @input_word[index] = a_letter\n puts \"Correct! Here are your guesses so far\"\n p @input_word\n end\n if !@word.include? (a_letter)\n end\n end\n end", "def guess!(letter)\n self.word.include? letter\n self.letter = letter\n end", "def guess(letter)\r\n letter = letter.downcase\r\n #find the guess\r\n returnValue = @word.count(letter) \r\n case returnValue\r\n when 0\r\n #Meaning this was an invalid guess\r\n @count-=1\r\n #maybe for debugging purposes\r\n @guessedFalse << letter\r\n else\r\n #maybe for debugging purposes\r\n @guessedTrue << letter\r\n #get all index of a matching letter\r\n arryOfMatchesIndexs = (0 ... @word.length).find_all { |i| @word[i,1] == letter }\r\n #iterate through the matches and replace the shadow word\r\n arryOfMatchesIndexs.each { |x| \r\n @shadowWord[x] = letter \r\n }\r\n \r\n #if the shadowWord array does not have any underscroes then we win \r\n if (@shadowWord.index(\"_\")).nil? \r\n @win = true\r\n end\r\n end\r\n #return the value of found\r\n returnValue\r\n end", "def good_guess?\n @code_word.include?(@word_guesser.guess)\n end", "def guess_letters_check\n @user_guess.length != 4 || !check_letters(@user_guess)\n end", "def check(guess)\n correct = 0\n\n if @guessed.include?(guess)\n @message = \"Choose another letter!\"\n else\n @message = \"\"\n @guessed << guess\n @to_guess.each_with_index do |char, index|\n if guess == char\n @guessing[index] = guess\n correct += 1\n end\n end\n @lives -= 1 if correct == 0\n end\n\n if @guessing.join == @to_guess.join\n @message = \"#{@guessing.join} was the word. You won!!\"\n @status = \"disabled\"\n end\n if @lives == 0\n @message = \"No lives left! You lost! The word was: \\\"#{@to_guess.join}\\\"\"\n @status = \"disabled\"\n end\n\n end", "def valid_guess?(guess)\n\t\tguess == 'SAVE' || (('A'..'Z').include?(guess) && (!(@wrong_letters.include?(guess))))\n\tend", "def letter_match?(letter)\n if @secret.include?(letter)\n return true; end\n return false\n end", "def win?\n @correct_letters.join == @secret_word\n end", "def check_letters(letter)\n progress(letter)\n count = 0\n @word_to_guess.each do |char|\n if char == letter\n @hidden_word[count] = letter\n else\n @hidden_word \n end\n count +=1 \n end\n puts @hidden_word\n @hidden_word\n end", "def check_phrase guess\r\n\t\t\t\t\t\t\t\tif guess == @secretword\r\n\t\t\t\t\t\t\t\t\tincement_score\r\n\t\t\t\t\t\t\t\t\t@win = true\r\n\t\t\t\t\t\t\t\t\treturn true\r\n\t\t\t\t\t\t\t\telse\r\n\t\t\t\t\t\t\t\t\treturn false\r\n\t\t\t\t\t\t\t\tend\r\n\t\t\t\t\t\tend", "def letter_guess\n letter = get_letter_player()\n check_letter_in_random_word(@guess_letter)\n if @correct_guess == false\n @failed_attempts += 1\n if @failed_attempts == 10\n @lose = true\n end\n end\n guess_word_status_string = @guess_word_status.join()\n if guess_word_status_string == @random_word\n @win = true\n end\n end", "def letter_guess(input,dead_man)\n if @letters_guessed_array.include?(input) || dead_man.wrong_letters.include?(input)\n puts \"You have already guessed this letter!\"\n display(dead_man)\n elsif @correct_word_array.include?(input)\n @letters_guessed_array.each_with_index do |letter, index|\n @letters_guessed_array[index] = input if @correct_word_array[index] == input\n end\n puts \"The letter #{input} is in the word.\"\n if @letters_guessed_array.include?(\"__\")\n display(dead_man)\n else\n win\n end\n else\n puts \"The letter #{input} is not in the word.\"\n dead_man.wrong_letters.push(input)\n dead_man.wrong_guesses += 1\n display(dead_man)\n end\n end", "def getguess guess\r\n\t\t\t\t\t@spin_flag = false\r\n\t\t\t\t if guess.length == 1\r\n\t\t\t\t if check_repeated_choice guess\r\n\t\t\t\t @message = \"Already guessed this letter!\"\r\n\t\t\t\t if @console\r\n\t\t\t\t\t\t\t\t@output.puts \"#{@message}\"\r\n\t\t\t\t\t\t\t\tword_input = take_user_word_input\r\n\t\t\t\t\t\t\t\tvalid = false\r\n\t\t\t\t\t\t\t while !valid do\r\n\t\t if validate_input word_input\r\n\t\t valid = true\r\n\t\t else\r\n\t\t @output.puts \"Invalid input\"\r\n\t\t word_input = take_user_word_input\r\n\t\t end\r\n\t\t\t\t\t\t\t end\r\n\t\t\t\t\t\t\t\tif check_enter word_input\r\n\t\t\t\t\t\t\t\t\t\t@break_flag = true\r\n\t\t\t\t\t\t\t\telse\r\n\t\t\t\t\t\t\t\t getguess word_input\r\n\t\t\t\t\t\t\t\tend\r\n\t\t\t\t\t\telse\r\n\t\t\t\t\t\t\t@spin_flag = true\r\n\t\t\t\t end\r\n\t\t\t\t else\r\n\t\t\t\t \t@message=\"Guess a letter from the word/phrase.\"\r\n\t\t\t\t @guess_counter+=1\r\n\t\t\t\t check_guess guess\r\n\t\t\t\t set_guess_analysis guess\r\n\t\t\t\t end\r\n\t\t\t\t success = check_phrase @resulta.join(',').gsub(\",\",\"\")\r\n\t\t\t\t return success ? true : false\r\n\t\t\t\telse\r\n\t\t\t\t\t if check_phrase guess\r\n\t\t\t\t\t\t phrase = @secretword.chars\r\n\t\t\t\t\t\t i = 0\r\n\t\t\t\t\t\t while i < phrase.length do\r\n\t\t\t\t\t\t\t\t\t\t@resulta[i] = phrase[i]\r\n\t\t\t\t\t\t\t\t\t\ti += 1\r\n\t\t\t\t\t\t end\r\n\t\t\t\t\t\t return true\r\n\t\t\t\t\t else\r\n\t\t\t\t\t\t @num_guessed = 0\r\n\t\t\t\t\t\t incrementturn\r\n\t\t\t\t\t\t @guess_counter+=1\r\n\t\t\t\t\t\t set_guess_analysis guess\r\n\t\t\t\t\t\t return false\r\n\t\t\t\t\t end\r\n\t\t\t\tend\r\n\t\t\t\tend", "def valid_chars?(guess)\n if !guess.upcase.each_char.all? { |char| @colors.has_value? char }\n puts \"That is not a valid guess. Please guess from these colors: #{@colors.values.join}\"\n false\n else\n true\n end \n end", "def check_winner\n @word.downcase.chars == @guess\n end", "def letter_check(letter)\n @word.chars.each_with_index do |letter_in_word, index|\n if letter == letter_in_word\n @result_str[index] = letter\n end\n end\n if !@word.include?(letter)\n puts \"Sorry try again\"\n end\n @result_str\n end" ]
[ "0.860954", "0.8222383", "0.8098351", "0.8065002", "0.8008855", "0.79772484", "0.7969457", "0.7907627", "0.7902701", "0.7871664", "0.7828328", "0.7823834", "0.7818478", "0.7795849", "0.77946335", "0.7787985", "0.7772331", "0.7746675", "0.77443296", "0.77425915", "0.7737831", "0.7736969", "0.7726948", "0.77099943", "0.7694791", "0.76926154", "0.7686743", "0.76828784", "0.76759946", "0.76709306", "0.766195", "0.76434577", "0.763824", "0.76364195", "0.7632186", "0.7605656", "0.76045424", "0.7587992", "0.757601", "0.75426894", "0.75357026", "0.7530318", "0.7501597", "0.74859977", "0.74846935", "0.74786997", "0.74687845", "0.744632", "0.7436435", "0.74297535", "0.74192506", "0.74101084", "0.7401555", "0.7398424", "0.73894286", "0.73799723", "0.73746157", "0.7361887", "0.7361594", "0.7361064", "0.7353112", "0.734487", "0.7332019", "0.73302263", "0.73297846", "0.73297584", "0.7327576", "0.73250383", "0.7324524", "0.7324524", "0.7319389", "0.7314094", "0.731347", "0.73088366", "0.7308769", "0.7298517", "0.72951585", "0.72783136", "0.72725165", "0.72655755", "0.72629195", "0.7259719", "0.7251906", "0.724164", "0.7237817", "0.723639", "0.72267336", "0.7222523", "0.72161216", "0.7183828", "0.71780944", "0.7176645", "0.7175373", "0.7162713", "0.7161924", "0.7148899", "0.71375644", "0.71316004", "0.71314687", "0.7130057" ]
0.7403021
52
METHOD: add guess to tracked guesses if not duplicated INPUT: guessed letter as string OUTPUT: array of tracked guesses
def add_guess(guess) duplicate?(guess) ? @guesses : @guesses << guess end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_to_guess\n @guess = @guess.map!.with_index do |character, index|\n @word.downcase[index] == @letter ? @word[index] : character\n end\n end", "def guess_letters(letter)\n @guesses << letter\n @guesses\nend", "def letter_guessed(user_guess)\n\t\tif @guessed_letters.length == 0\n\t\t\t@guessed_letters << user_guess\n\t\telse \n\t\t\tif @guessed_letters.include?(user_guess)\n\t\t\t\tputs \"--You already guessed that letter! Try again!--\"\n\t\t\t\t@guess_count -= 1\n\t\t\telse\n\t\t\t\t@guessed_letters << user_guess\n\t\t\tend\n\t\tend\n\tend", "def letters_to_guess\n @letters.map do |letter|\n if @user_guesses.include?(normalize_letter(letter))\n letter\n else\n nil\n end\n end\n end", "def guess(letter)\r\n\t\t\r\n\t\tif(@word.include?(letter))\r\n\t\t @good_guesses.add(letter)\r\n\t end\r\n\t\r\n\tend", "def guess\n\t\tcollect_words_of_length\n\t\tputs \"Already guessed letters by computer: #{@guessed_letters}\"\n\t\t@guessing_letter = nil\n\t\twhile @guessing_letter == nil || invalid?(@guessing_letter)\n\t\t\t@guessing_letter = guessing_letter\n\t\tend\n\t\t@guessed_letters << @guessing_letter\n\t\t@guessing_letter\n\tend", "def collection_of_guesses(letter_guess)\n\t\tif @guess_array.include? (letter_guess)\n\t\t\tputs \"You already guessed that!\"\n\t\t\t@total_guesses += 1\n\t\telse\n\t\t\t@guess_array << letter_guess\n\t\tend\n\tend", "def process_guess(letter)\n\n\t\tletter = letter.downcase\n\n\t\tif @prev_guesses.include? letter\n\t\t\tputs \"\\\"#{letter}\\\" has already been guessed\"\n\t\t\tprint_status\n\t\t\treturn false \n\t\telse\n\t\t\t@prev_guesses << letter\n\t\t\tdecrement_guesses\n\t\tend\n\n\t\tif @original_word.include? letter\n\t\t\tupdate_gameboard(letter)\n\t\t\tprint_status\n\t\t\ttrue\n\t\telse\n\t\t\tprint_status\n\t\t\tfalse\n\t\tend\n\tend", "def guess(letter)\r\n\t\t@guessed << letter.downcase\r\n\t\t@word[0].each_index do |i| #Iterate through indexes instead of values\r\n\t\t\tif @word.dig(0,i) == letter #since @word is an array inside an array, dig helps us look in word ([0]) each index for the letter.\r\n\t\t\t\t@hidden_word[i] = letter #if found, substitute \"_\" for the letter guessed in the same index for @hidden_word\r\n\t\t\tend\r\n\t\tend\r\n\t\tp @hidden_word #give feedback of results\r\n\tend", "def history_checker(guess)\n if @used_letter.include?(guess)\n puts \"You already used that letter\"\n else\n \t#increments @guess_count if letter was unique \n @guess_count += 1 \n @used_letter << guess\n end\n end", "def save_guess\n if good_guess?\n matching_indexes(@code_word, @word_guesser.guess).each do |i|\n @good_guesses[i] = @word_guesser.guess\n end\n else\n @bad_guesses.push(@word_guesser.guess)\n end\n end", "def failed_guess(letter)\r\n @failed_guesses << letter\r\n @attempts_left -= 1\r\n end", "def guessed_letters()\n guessed = $bucket.join(\" \") # return a string of guessed letters\nend", "def make_guess(guess)\n @previous_guesses << guess \n display_string = show_progress()\n if !goal_word.include?(guess) \n guess_counter()\n end \n if display_string == @goal_word\n @player_won = true \n end\n end", "def check_guess(input)\n @guessed_letters.push(input)\n if @secret_word.match?(input)\n @secret_word.split(//).each_with_index { |char, index| @guessed_word[index] = char if char == input }\n else\n puts 'Incorrect'\n @guesses_left -= 1\n @wrong_letters.push(input)\n end\n end", "def guess(letter)\r\n letter = letter.downcase\r\n num = 0\r\n #iterate through word comparing guessed letter to letter's in the word\r\n @word_arr.each_index do |i| \r\n if @word_arr[i] == letter\r\n #if the letter matches update the game board in the equivalent spot\r\n @gameboard[i] = letter\r\n num += 1\r\n end\r\n end\r\n #add letter to guessed database, and lower amount of guesses by one\r\n @guessed_letters << letter\r\n @guesses -= 1\r\n return num\r\n end", "def update_round(guess)\n if @word_array.include?(guess)\n @word_array.each_with_index do |letter, index|\n @word_array_player[index] = letter if guess == letter\n end\n else\n @errors_left -= 1\n end\n @letters_guessed.push(guess)\n end", "def setguessmatch(letter)\n\t\t@guess_count +=1\t\n\t\t@guessed_letters << letter\n\n\t\t@starting_word.each_with_index do |char,index|\n\t\t\tif char == letter\n\t\t\t\t@guessing_word[index] = char\n\t\t\t\tif starting_word == guessing_word\n\t\t\t\t\t@game_status = true\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend", "def wrong_letter(letter)\r\n \t@chances -= 1\r\n @guesses << letter\r\n end", "def check_guess\n @already_guessed.push(@guess)\n if @secret_word.include?(@guess)\n @secret_word.split(\"\").each_with_index do |letter, index|\n if letter == @guess\n @blanks[index] = letter\n end\n end\n else\n @guesses_left -= 1\n @missed_letters.push(@guess)\n end\n @blanks\n end", "def wrong_letter(letter)\n @chances -= 1\n @guesses << letter\n end", "def check_letters(letter_guessed)\n if @secret_word.include?(letter_guessed)\n @characters_guessed_correctly << letter_guessed\n puts 'you guessed correctly'\n puts replace_correct_letters\n else\n puts 'you guessed wrong'\n @guess_count -= 1\n end\n end", "def guessed_wrong_letter()\n if $hidden_word_arr.exclude?($input)\n $guessed.append($input)\n end\n end", "def good_letter(letter)\n if $bucket.include? letter # check to see if letter has already been guessed and reprompt if so\n $prompt = \"You already guessed that one - TRY AGAIN!\"\n elsif letter[/[a-zA-Z]+/] and letter.length == 1 # check is a single -letter- has been entered\n $bucket.push(letter) # if so, add it to the bucket array\n letter_test(letter) # then pass it to letter_test()\n else # if multiple letters, non-alpha characters or nothing has been entered\n $prompt = \"Enter a single letter - TRY AGAIN!\" # reprompt user to try again\n end\nend", "def guess_letters\n guess_array = []\n @current_word.each do\n guess_array << \"_\"\n end\n return guess_array\n end", "def guesses_history(alphabet,position)\n\t\tguessed_words[position] = alphabet\n\t\tguessed_words\n\tend", "def respond_to_guess(letter)\n letter = letter.clone.downcase\n\n if @incorrect_letters.include?(letter) || @progress.include?(letter) || @progress.include?(letter.upcase)\n puts \"You already guessed that letter!\"\n puts \"\"\n elsif @word.include?(letter) || @word.include?(letter.upcase)\n update_progress(letter)\n unless @progress.include?(\"_\")\n @round_finished = true\n @guessed = true\n end\n else\n @incorrect_letters << letter\n @round_finished = true if @incorrect_letters.size == 6\n end\n print_hangman\n end", "def check_guess(guess)\n\t\tif @secret_word.include?(guess)\n\n\t\t\ttemp_secret_word = @secret_word.clone\n\t\t\ttemp_secret_word = temp_secret_word.split('')\n\n\t\t\ttemp_secret_word.each_with_index {|letter, index| @guess_line[index] = guess if temp_secret_word[index] == guess}\n\t\telse\n\t\t\t@misses << guess\n\t\t\t@incorrect_guesses_count += 1\n\t\tend\n\tend", "def guess?(letter)\n if @guessed_letter.include?(letter)\n puts \"You already guessed that letter!\"\n return\n end\n @guessed_letter << letter\n ​\n found = false\n if @characters.include?(letter)\n found = true \n puts \"Yes that letter is in the word!\"\n else\n puts \"Wrong answer!\"\n end \n ​\n @characters.each_with_index do |char, index|\n if char == letter\n @displayed_character[index] = letter\n end\n end\n found\n end", "def guess(letter_guessed)\r\n# \ti. Run loop to see if the letter has been guessed yet.\r\n\tif word_split.include? (letter_guessed)\r\n\t\t# a. Iterate through the word characters to see if it includes the letter guessed\r\n\t\t@word_split.each_with_index do |char, index|\r\n\t\t\tif word_split[index] == letter_guessed\r\n\t\t\t\t@guessed[index] = letter_guessed\r\n\t\t\tend #if\r\n\t\tend #do\r\n\t\t# b. If it is right then put you have guessed a letter and then ask for another guess repeat method\r\n\t\tputs \"You guessed correctly. Enter another guess\"\r\n# \t\tc. If it is wrong then put you have guessed wrong and ask for another guess. Maybe return how many guesses you have left?\r\n\telse\r\n\t\t@guess_count +=1\r\n\t\tputs \"You guessed incorrectly. Enter another guess\"\r\n\tend#if\r\nend", "def check_guess guess\r\n\t\t\t\t @resultb.push(guess)\r\n\t\t\t\t phrase = @secretword.chars\r\n\t\t\t\t i = 0\r\n\t\t\t\t @num_guessed = 0\r\n\t\t\t\t while i < phrase.length do\r\n\t\t\t\t\t\t\t\tif phrase[i] == guess\r\n\t\t\t\t\t\t\t\t @resulta[i] = guess\r\n\t\t\t\t\t\t\t\t @num_guessed += 1\r\n\t\t\t\t\t\t\t\tend\r\n\t\t\t\t\t\t\t\ti += 1\r\n\t\t\t\t end\r\n\t\t\t\t\t\t\t\tif @num_guessed > 0\r\n\t\t\t\t\t\t\t\t@score += (@reward.to_i * @num_guessed)\r\n\t\t\t\t\t\t\t else\r\n\t\t\t\t\t\t\t incrementturn\r\n\t\t\t\t\t\t\t\tend\r\n\t\t end", "def add_to_previous_guesses(guess)\n prev_guesses << guess\n end", "def match_letters #handle_guess\n\t\tindexes_matched = @word_array.each_index.select { |i| @word_array[i] == @guess}\n\n\t\tfor x in indexes_matched do\n\t\t\t@result_array[x] = guess\n\t\tend\n\n\t\tputs @result_array\n\tend", "def match_letters #handle_guess\n\t\tindexes_matched = @word_array.each_index.select { |i| @word_array[i] == @guess}\n\n\t\tfor x in indexes_matched do\n\t\t\t@result_array[x] = guess\n\t\tend\n\n\t\tputs @result_array\n\tend", "def guess letter\n raise InvalidGuessError if letter.strip.empty? || letter.length > 1\n letter = letter[0].upcase\n if @guesses.include?(letter)\n return {advance: false, message: \"#{letter} has already been played, silly!\"}\n else\n @guesses << letter\n end\n @guessed.each_with_index do |guessed_pos, index|\n if guessed_pos\n if letter == secret[index]\n return {advance: false, message: \"#{letter} has already been played, silly!\"}\n end\n else\n if letter == secret[index]\n reveal_all(letter)\n return {advance: true, message: \"We found #{letter}!\"}\n end\n end\n end\n {advance: true, message: \"Sorry, we did not find #{letter}!\"}\n end", "def respond_to_guess(guess)\n\t\t@guessed_letters << guess\n\t\t@secret_word.split(\"\").include?(guess)\t\n\tend", "def guess(letter)\n # STEP 1: check to make sure the letter is not any non-letter character and\n # raises an error if it is\n if /^[a-zA-Z]+$/.match(letter)\n letter.downcase!\n else raise_error(\"Invalid letter\")\n end\n\n # STEP 2: check to make sure the user does not guess the same letter more\n # than once\n if @guesses.include? letter; return false; end\n if @wrong_guesses.include? letter; return false; end\n\n # STEP 3: check to see if the guessed letter matches any letters in the \n # word\n if @word.include? letter\n @guesses += letter\n # if there is a match, update the word_with_guesses to show where\n # in the string the letter was matched\n @word.each_char.with_index do |c, i|\n if c == letter\n @word_with_guesses[i] = c\n end\n end \n else \n @wrong_guesses += letter\n @attempts += 1\n end\n # update the number of attempts and call the function to check if\n # the user won, lost, or continues playing\n check_win_or_lose\n end", "def include_letter(word, letter)\n index = 0 \n if @letter_bank.include?(letter) \n puts \"You already tried this letter\"\n else \n word.each_char do |l|\n if l == letter\n @blanks[index] = letter\n end \n index += 1\n end \n @guess_count -= 1 \n @letter_bank << letter\n end \n puts \"You have #{guess_count} guesses left\"\n p @blanks\n end", "def check_letter(guess)\n if @word.include? guess\n puts \"You chose wisely!\"\n #find which position(s) the guess is in the word array\n correct_index_arr = @word.each_index.select { |i| @word[i] == guess }\n # rebuild @game_status with the correct letter guessed into that position of the word\n correct_index_arr.each do |index|\n @game_status[index] = guess\n end\n # if they don't make guess and put an empty response\n elsif guess.empty?\n puts \"You didn't make a guess. Try again.\"\n # if the user guesses the same wrong letter again\n elsif @wrong_guesses.include? guess\n puts \"You guessed that before! Try again.\"\n else\n @guesses_remaining -= 1\n puts \"wrong guess, the guesses remaining: #{@guesses_remaining}\"\n @wrong_guesses.push(guess)\n end\n end", "def update_game_state guess\n\t\tif @word.include?(guess)\n\t\t\t@hits << guess\n\t\telse\n\t\t\t@misses << guess\n\t\t\t@guesses_left -= 1\n\t\tend\n\tend", "def check_guess(guess)\n\t\tif @guesses.include?(guess)\n\t\t\tputs 'This is a repeated guess. Try another letter!'\t\n\t\telse\n\t\t\t@guesses << guess\n\t\t\tif @secret_word_arr.include?(guess)\n\t\t\t\t# logic to show the guess inside the @dashes_arr\n\t\t\t\t@word_length.times do |i|\n\t\t\t\t\tif @secret_word_arr[i] == guess\n\t\t\t\t\t\t@dashes_arr.delete_at(i)\n\t\t\t\t\t\t@dashes_arr.insert(i, guess)\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\telse\n\t\t\t\t@guess_count += 1\n\t\t\t\tattempts = @word_length - @guess_count\n\t\t\t\tputs \"Incorrect guess. You have #{attempts.to_s} attempts left. Try again!\"\n\t\t\tend\n\t\tend\n\t\t@display_chars\n\tend", "def letter_guess(input,dead_man)\n if @letters_guessed_array.include?(input) || dead_man.wrong_letters.include?(input)\n puts \"You have already guessed this letter!\"\n display(dead_man)\n elsif @correct_word_array.include?(input)\n @letters_guessed_array.each_with_index do |letter, index|\n @letters_guessed_array[index] = input if @correct_word_array[index] == input\n end\n puts \"The letter #{input} is in the word.\"\n if @letters_guessed_array.include?(\"__\")\n display(dead_man)\n else\n win\n end\n else\n puts \"The letter #{input} is not in the word.\"\n dead_man.wrong_letters.push(input)\n dead_man.wrong_guesses += 1\n display(dead_man)\n end\n end", "def guess(letters)\n raise ArgumentError if letters == \"\"\n raise ArgumentError if letters !~ %r{\\w}\n letters.downcase!\n if @word.include?(letters) \n !@guesses.include?(letters) ? @guesses << letters : false\n\n else\n @wrong_guesses.include?(letters) ? false : wrong_guesses << letters \n end\n end", "def guess_letter(a_letter)\n p a_letter.downcase\n @word.split(\"\").each_with_index do |another_letter, index|\n if a_letter == another_letter\n @input_word[index] = a_letter\n puts \"Correct! Here are your guesses so far\"\n p @input_word\n end\n if !@word.include? (a_letter)\n end\n end\n end", "def check_letters(letter)\n progress(letter)\n count = 0\n @word_to_guess.each do |char|\n if char == letter\n @hidden_word[count] = letter\n else\n @hidden_word \n end\n count +=1 \n end\n puts @hidden_word\n @hidden_word\n end", "def guess\n puts \"Enter a letter\"\n puts\n letter = gets.chomp\n if @word_array.include?(letter)\n @word_array.each_with_index do |char, index|\n if char == letter\n @puzzle_array[index] = letter\n end\n end\n puts \"Correct!\"\n else\n puts \"Try again!\"\n end\n @counter -= 1\n end", "def guess(guess)\r\n\t\t# Make sure the guess is either a letter or the whole word\r\n\t\tif guess.length != 1 && guess.length != @win_word.length\r\n\t\t\tp @remaining_guesses.to_s + \" guesses left\"\r\n\t\t\tp \"Guess a letter, or the complete word!\"\r\n\t\t# check for repeated guesses\r\n\t\telsif @past_guesses.include? guess\r\n\t\t\tp @remaining_guesses.to_s + \" guesses left\"\r\n\t\t\tp @hint\r\n\t\t\tp \"You guessed that already!\"\r\n\t\t# check if they guessed the entire word correctly\r\n\t\telsif guess == @win_word\r\n\t\t\twin\r\n\t\t# if the letter is not in the word\r\n\t\telsif !@win_word.include? guess\r\n\t\t\t# Add guess to arrayof past guesses\r\n\t\t\t@past_guesses << guess\r\n\t\t\tif @remaining_guesses == 1\r\n\t\t\t\tlose\r\n\t\t\telse\r\n\t\t\tguesses_remaining\r\n\t\t\tp @remaining_guesses.to_s + \" guesses left\"\r\n\t\t\tp @hint\r\n\t\t\tp \"Sorry, try again!\"\r\n\t\t\tend\r\n\t\t# if the letter is in the word\r\n\t\telsif @win_word.include? guess\r\n\t\t\t# Add guess to arrayof past guesses\r\n\t\t\t@past_guesses << guess\r\n\t\t\tguesses_remaining\r\n\t\t\tp @remaining_guesses.to_s + \" guesses left\"\r\n\t\t\tupdate_hint(guess)\r\n\t\t\tif @hint_str == @win_word\r\n\t\t\t\twin\r\n\t\t\telse\r\n\t\t\t\tp \"Nice guess!\"\r\n\t\t\tend\r\n\t\telse\r\n\t\t\tp \"Error\"\r\n\t\tend\r\n\r\n\tend", "def check_letter(input_letter)\n # Each time we check, the number of guesses is increased \n @guess_count += 1\n \n # Transform the words into arrays for convenience\n arr_word_to_guess = @word_to_guess.split('') \n arr_guessed_word = @guessed_word.split('') \n \n # Search for the input_letter in arr_word_to_guess\n index_found = arr_word_to_guess.each_index.select{|i| arr_word_to_guess[i] == input_letter}\n \n if (index_found == []) then\n return false \n else \n # if the letter is found, update the guessed word\n n_found = index_found.size\n i = 0 \n n_found.times do \n arr_guessed_word[index_found[i]] = input_letter\n i += 1\n end\n @guessed_word = arr_guessed_word.join('')\n return true\n end \n end", "def set_guess\n @guess = Array.new(@word.length, '*')\n end", "def match_letters(player_guess) \n indexes_matched = @word_array.each_index.select { |i| @word_array[i] == player_guess}\n for x in indexes_matched do\n @results[x] = player_guess\n end\n end", "def guess_letter\n\t\tprint \"Your guess: \"\n\t\tguess = gets.chomp.downcase\n\t\treturn guess if guess == \"save\"\n\t\tif (guess.between?('a','z') && !(@guessed_letters.include? guess)\\\n\t\t\t&& guess.length == 1)\n\t\t\tprocess_guess(guess)\n\t\t\t@guessed_letters << guess\n\t\t\t@turns += 1\n\t\telse\n\t\t\tif guess.between?('a','z')\n\t\t\t\tputs \"\\nYour guess must be ONE letter\" unless guess.length == 1\n\t\t\t\tputs \"\\nYou've already guessed that!\" if @guessed_letters.include? guess\n\t\t\telse\n\t\t\t\tputs \"\\nYour guess must be a letter!\" unless guess.between?('a','z')\n\t\t\tend\n\t\t\tputs \"Try again!\\n\\n\"\n\t\t\tguess = guess_letter\n\t\tend\n\t\tguess\n\tend", "def check_guess(guess)\n # checks human guess, displays discovered, and return if letter found\n letter_found = false\n self.secret_word.split('').each_with_index do |chr, ind|\n if chr == guess\n self.currently_discovered[ind] = chr\n letter_found = true\n end\n end\n p self.currently_discovered\n letter_found\n end", "def correct_guess?(letter)\n if @word_selected.include?(letter)\n if @correct_guesses.empty?\n @correct_guesses << letter\n elsif @correct_guesses.include?(letter)\n puts 'Letter already guessed! try another one!'\n else\n @correct_guesses << letter\n end\n return true\n end\n false\n end", "def respond_to_letter_guess(letter)\n indices_matching_letter = []\n i = 0\n while i < @secret_word.length\n if @secret_word[i] == letter\n indices_matching_letter << i\n end\n\n i += 1\n end\n\n indices_matching_letter\n end", "def getguess guess\r\n\t\t\t\t\t@spin_flag = false\r\n\t\t\t\t if guess.length == 1\r\n\t\t\t\t if check_repeated_choice guess\r\n\t\t\t\t @message = \"Already guessed this letter!\"\r\n\t\t\t\t if @console\r\n\t\t\t\t\t\t\t\t@output.puts \"#{@message}\"\r\n\t\t\t\t\t\t\t\tword_input = take_user_word_input\r\n\t\t\t\t\t\t\t\tvalid = false\r\n\t\t\t\t\t\t\t while !valid do\r\n\t\t if validate_input word_input\r\n\t\t valid = true\r\n\t\t else\r\n\t\t @output.puts \"Invalid input\"\r\n\t\t word_input = take_user_word_input\r\n\t\t end\r\n\t\t\t\t\t\t\t end\r\n\t\t\t\t\t\t\t\tif check_enter word_input\r\n\t\t\t\t\t\t\t\t\t\t@break_flag = true\r\n\t\t\t\t\t\t\t\telse\r\n\t\t\t\t\t\t\t\t getguess word_input\r\n\t\t\t\t\t\t\t\tend\r\n\t\t\t\t\t\telse\r\n\t\t\t\t\t\t\t@spin_flag = true\r\n\t\t\t\t end\r\n\t\t\t\t else\r\n\t\t\t\t \t@message=\"Guess a letter from the word/phrase.\"\r\n\t\t\t\t @guess_counter+=1\r\n\t\t\t\t check_guess guess\r\n\t\t\t\t set_guess_analysis guess\r\n\t\t\t\t end\r\n\t\t\t\t success = check_phrase @resulta.join(',').gsub(\",\",\"\")\r\n\t\t\t\t return success ? true : false\r\n\t\t\t\telse\r\n\t\t\t\t\t if check_phrase guess\r\n\t\t\t\t\t\t phrase = @secretword.chars\r\n\t\t\t\t\t\t i = 0\r\n\t\t\t\t\t\t while i < phrase.length do\r\n\t\t\t\t\t\t\t\t\t\t@resulta[i] = phrase[i]\r\n\t\t\t\t\t\t\t\t\t\ti += 1\r\n\t\t\t\t\t\t end\r\n\t\t\t\t\t\t return true\r\n\t\t\t\t\t else\r\n\t\t\t\t\t\t @num_guessed = 0\r\n\t\t\t\t\t\t incrementturn\r\n\t\t\t\t\t\t @guess_counter+=1\r\n\t\t\t\t\t\t set_guess_analysis guess\r\n\t\t\t\t\t\t return false\r\n\t\t\t\t\t end\r\n\t\t\t\tend\r\n\t\t\t\tend", "def make_guess\n\t\tbegin\n\t\t\thighest_letter_left = freq_hash\n\t\t\t\t.sort_by{|k, v| v}\n\t\t\t\t.reverse\n\t\t\t\t.map{|char, freq| char}\n\t\t\t\t.detect{|char| !@guessed_letters.include?(char)}\n\n\t\t\traise \"Aw, damn! Got nothin' left. Let's start a new game.\" unless highest_letter_left\n\t\trescue Exception => e\n\t\t\tputs e.message\n\t\t\texit\n\t\telse\n\t\t\t@guessed_letters << highest_letter_left\n\t\t\thighest_letter_left\n\t\tend\n\tend", "def check_guess(letter)\n @indices = gameboard[0].each_index.select { |i| gameboard[0][i].downcase == letter }\n if @indices.empty?\n incorrect_guesses << letter\n puts 'Sorry, the secret word does not contain that letter'\n else\n @indices.each do |index|\n gameboard[1][index] = gameboard[0][index] # letter\n end\n puts 'Good guess!'\n end\n end", "def checkLetter(letter)\n @word.split(\"\").each_with_index do |item, index|\n if item == letter\n @guess[index] = letter\n end\n end\n puts @guess\nend", "def guess_letter(letter)\n\t\tif @ans_word.include?(letter)\n\t\t\ti = @ans_word.index(letter)\n\t\t\t@guess.insert(i, letter)\n\t\t\t@guess.pop\n\t\t\tputs \"Good! You are getting closer: #{@guess*\"\"}\"\n\t\telse\n\t\t\tputs \"sorry, guess again\"\n\t\tend\n\tend", "def turn_taken(guess, phrase)\n if guess.nil?\n @incorrect_guesses << \"[nil]\"\n elsif !guess.respond_to?(:downcase)\n @incorrect_guesses << \"[invalid]\"\n elsif guess.empty?\n @incorrect_guesses << \"[empty]\"\n else\n guess = guess.downcase.strip.gsub(/ /, \"/\")\n\n if guess.size > 1 && guess.size < phrase.size\n # This is a word guess, do not allow part of a word guesses\n words = phrase.split(\"/\")\n matching_words = words.select {|w| w == guess}\n if matching_words.size == 0\n @incorrect_guesses << guess\n return\n end\n end\n \n matches = phrase.all_indices(guess)\n \n if matches.empty? || @correct_guesses.index(guess) != nil # No matches or a repeated correct guess\n @incorrect_guesses << guess\n else\n @correct_guesses << guess\n \n matches.each do |i|\n x = 0\n guess.each_char do |c|\n @current_pattern[i + x] = c\n x = x + 1\n end\n end\n \n @found_phrase = @current_pattern.index(\"_\") == nil\n end\n end\n end", "def check_for_correct_letters(user_guess)\n @correct_letters << user_guess.count do |guess_char|\n @solution.include?(guess_char)\n end\n end", "def guess(letter)\r\n if word_has?(letter)\r\n \tput_letter_on_board(letter)\r\n else\r\n wrong_letter(letter) if !@guesses.include? letter\r\n end\r\n end", "def get_guess\n @guess = \"\"\n until @guess.match(/^[a-z]$/) && !@already_guessed.include?(@guess)\n print \"Please enter a letter. \"\n @guess = gets.chomp.downcase\n if @guess == 'save'\n save_game\n elsif @already_guessed.include?(@guess)\n puts \"You have already guessed that letter. Please try again.\"\n elsif !@guess.match(/^[a-z]$/)\n puts \"That is not a valid guess. Please enter a single letter.\"\n end\n end\n @guess\n end", "def check_guess(letter)\n\t\t# If the guessed letter is in the word, replace \"_\" in the guess variable with the letter in the right spot\n\t\t@word.each_with_index do |l, i|\n\t\t\tif l == letter\n\t\t\t\t@guess[i] = letter\n\t\t\tend\n\t\tend\n\t\t# If the guessed word and the answer are the same, the user won!\n\t\t# Show message and if the game was previously saved, delete it\n\t\tif @word.join == @guess\n\t\t\tputs \n\t\t\tshow_board\n\t\t\tputs \"You won!!\"\n\t\t\tif @running_saved_game != nil\n\t\t\t\tover_write_data\n\t\t\tend\n\t\t\tgo_again\n\t\t# Got a letter but didn't win. Get another guess\n\t\telsif @word.include?(letter)\n\t\t\tputs\n\t\t\tputs \"You got a letter!\"\n\t\t\tget_guess\n\t\t# Letter wasn't in word, put letter in missed letter variable and guess again\n\t\telse\n\t\t\tputs \n\t\t\tputs \"No #{letter}'s.\"\n\t\t\t@wrong_letters.sub!(\"_\", letter)\n\t\t\t@turn += 1\n\t\t\tget_guess\n\t\tend\n\tend", "def wrong_guess(letter)\n\t\tif !@attempted_letters.include?(letter)\n\t\t\tputs \"WRONG....\"\n\t\t\t@attempted_letters << letter\n\t\t\t@number_of_guesses -= 1 \n\t\t\tp @number_of_guesses\n\t\t\tp @display\n\t\t\tp \"you have #{@number_of_guesses} guesses left...\"\n\t\t\treturn true\n\t\tend\n\tend", "def check_guess(guess)\n\t\thits_arr = []\n\t\t@secret.chars.each_index do |idx|\n\t\t\thits_arr << idx if guess == @secret[idx]\n\t\tend\n\t\t\n\t\thits_arr\n\tend", "def already_guessed? (letter)\r\n letter = letter.downcase\r\n @guessed_letters.include? letter\r\n end", "def play!(letter)\n if !over? && !@user_guesses.include?(letter)\n @user_guesses << normalize_letter(letter)\n end\n end", "def fill_correct_guess(guess)\n indexes = find_guess_position(guess)\n indexes.map do |index|\n @incomplete_word[index] = guess\n end\n end", "def guess?(letter)\n if !self_is_letter?(letter)\n puts \"Not a letter!\"\n return false\n end\n if @word.include? letter\n if(@word.count(letter) > 1)\n while(@word.include? letter)\n puts \"Hit this while loop\"\n index = @word.index(letter)\n @word.slice!(index,0)\n @word[index] = '_'\n\n puts \"Word\" + @word\n @guessedWord.slice!(index,0)\n @guessedWord[index] = letter\n\n end\n else\n index = @word.index(letter)\n\n @guessedWord.slice!(index,0)\n @guessedWord[index] = letter\n\n\n\n end\n\n\n output_word()\n return true\n end\n p \"Word does not contain #{letter}\"\n @health -= 1\n p \"you have #{@health} tries left\"\n return false\n end", "def guess_letter?(letter)\r\n\r\n\t\t#Add 1 to the total number of guesses in game IF not already guessed (in the guesses array)\r\n\t\tif @guesses.index(letter) == nil\r\n\t\t\t@guesses << letter\r\n\t\t\t@num_of_guesses += 1\r\n\t\tend\r\n\r\n\t\t#If the letter exists (aka returns valid index)\r\n\t\t# 1. Loop through letters in word and compare to the guessed letter\r\n\t\t# 2. If guessed letter = original letter in word, set board = to letter in that index\r\n\t\t# 3. Return True\r\n\t\t#Else if the letter does not exist in word array\r\n\t\t# 1. Return False\r\n\t\tif @word_array.index(letter)\r\n\t\t\tindex = 0\r\n\t\t\t@word_array.each do|i|\r\n\t\t\t\tif letter == i\r\n\t\t\t\t\t@board_array[index] = letter\r\n\t\t\t\tend\r\n\t\t\t\tindex+=1\r\n\t\t\tend\r\n\t\t\ttrue\r\n\t\telse\r\n\t\t\tfalse\r\n\t\tend\r\n\tend", "def guess=(guess)\n @guess=guess\n @guess_array<<@guess\n end", "def process_guess(guess)\n\t\t\tunless @secret.include? guess\n\t\t\t\tputs \"Bad guess...\"\n\t\t\t\t@bad_guesses << guess\n\t\t\t\t@guesses -= 1\n\t\t\t\t@drawing[@bad_guess_count+1] = @drawing_animation[@bad_guess_count]\n\t\t\t\t@bad_guess_count += 1\n\t\t\tend\n\n\t\t\twhile @secret.include? guess\n\t\t\t\t@fill_in_word[@secret.index(guess) * 2] = guess\n\t\t\t\t@secret[@secret.index guess] = \" \"\n\t\t\tend\n\t\tend", "def check_guess(letter)\n\t\tret = []\n\t\tif(@secret_word.include?(letter))\n\t\t\t@secret_word.split(\"\").each_with_index do |let, i|\n\t\t\t\tif(let == letter)\n\t\t\t\t\tret << i\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\tret\n\tend", "def check_guess(game, guess)\n @guess_num = 0\n guess_list = []\n\n puts @blanks.join\n puts \"Look at the blanks above that represent a word.\"\n puts \"Guess a letter a-z:\"\n p guess\n\n index_word = @word_array.index(guess)\n index_guess = guess_list.index(guess)\n\n #If the letter is in the word, let them know! And store the letter in the correct index in the blanks hash so they can see this info before their next guess.\n if index_word != nil\n puts \"YAY! Correct! #{guess} will be placed in its corresponding place in the word.\"\n @blanks[index_word] = guess\n if index_guess != nil\n puts \"You already guessed that!\"\n @guess_num -= 1\n end\n return true\n\n #If the guessed letter is not in the word, store in a new array so we can discount their guess if they guess that letter again.\n elsif index_word == nil\n if index_guess != nil\n puts \"You already guessed that!\"\n @guess_num -= 1\n elsif index_guess == nil\n puts \"Sorry! #{guess} is not in the word. Good Try!\"\n end\n return false\n end\n guess_list.push(guess)\n @guess_num += 1\n end", "def letter_guess\n letter = get_letter_player()\n check_letter_in_random_word(@guess_letter)\n if @correct_guess == false\n @failed_attempts += 1\n if @failed_attempts == 10\n @lose = true\n end\n end\n guess_word_status_string = @guess_word_status.join()\n if guess_word_status_string == @random_word\n @win = true\n end\n end", "def analyze\n @hits.times do\n @guesses << @last_guess unless @guesses.length == 4\n end\n end", "def analyze\n @hits.times do\n @guesses << @last_guess unless @guesses.length == 4\n end\n end", "def guess_badly(guess)\n @remaining_guesses -= 1\n @current_index += 1\n @bad_guesses << guess\n end", "def game_board(guess_letter)\r\n\t puts \"\"\t \r\n\t result_index_array = (0 ... @secret_word.length).find_all { |i| @secret_word[i,1] == guess_letter }\r\n\t \r\n\t # Change the output to show a successful guess\r\n\t if result_index_array.size == 0\r\n\t @incorrect_letters += guess_letter\r\n\t\t@incorrect_letters += \", \"\r\n\t else \r\n\t result_index_array.each { |index| @correct_letters[2*index] = guess_letter }\r\n end\r\n\t \r\n\t # Update variables and check if the game has been won\r\n\t @turn_count -= 1\r\n\t puts @correct_letters\r\n\t #@incorrect_letters.each {|letter| print \"#{letter}, \"}\r\n\t puts \"\\nIncorrect Guesses: #{@incorrect_letters}\"\r\n\t win_game if @correct_letters.count('_') == 0\r\n\t end_turn\r\n\tend", "def guess(letter)\r\n letter = letter.downcase\r\n #find the guess\r\n returnValue = @word.count(letter) \r\n case returnValue\r\n when 0\r\n #Meaning this was an invalid guess\r\n @count-=1\r\n #maybe for debugging purposes\r\n @guessedFalse << letter\r\n else\r\n #maybe for debugging purposes\r\n @guessedTrue << letter\r\n #get all index of a matching letter\r\n arryOfMatchesIndexs = (0 ... @word.length).find_all { |i| @word[i,1] == letter }\r\n #iterate through the matches and replace the shadow word\r\n arryOfMatchesIndexs.each { |x| \r\n @shadowWord[x] = letter \r\n }\r\n \r\n #if the shadowWord array does not have any underscroes then we win \r\n if (@shadowWord.index(\"_\")).nil? \r\n @win = true\r\n end\r\n end\r\n #return the value of found\r\n returnValue\r\n end", "def try_guess(char)\n if self.already_attempted?(char)\n p \"that has already been attempted\"\n return false\n else\n matching_indices = self.get_matching_indices(char)\n self.fill_indices(char, matching_indices)\n\n @remaining_incorrect_guesses -= 1 if matching_indices.empty?\n \n @attempted_chars << char\n return true\n end\n end", "def already_guessed?(letter, previous_attempts)\r\n if previous_attempts.include?(letter)\r\n puts \"You already guessed that\"\r\n return true\r\n else\r\n return false\r\n end\r\nend", "def match_letters \n\t\tindexes_matched = @word_array.each_index.select { |i| @word_array[i] == @guess}\n\n\t\tfor x in indexes_matched do\n\t\t\t@result_array[x] = @guess\n\t\tend\n\tend", "def repeated_guess?\r\n if @guessed_letters.include? @letter\r\n puts \"You have already guessed the letter #{@letter}, try again.\"\r\n return true\r\n end\r\n end", "def input_evaluation(guess, correct_word)\n if correct_word.word.include?(guess)\n # We learned that .each_with_index can be used to locate each letter corresponding with each spacific index\n # Then if the letter matches it will subsitue the \"_\", at the correct index, with the corresponding letter\n correct_word.word.each_with_index do |letter, index|\n if letter == guess\n correct_word.progress[index] = guess\n end\n end\n else\n # Storing wrong letters into an array and updating max_guesses\n correct_word.wrong_guesses << guess\n correct_word.max_guesses -= 3\n end\nend", "def guess?(letter)\n correct = false\n @@secret.length.times do |i|\n if (@@secret[i] == letter && @@progress[i] == '_')\n @@progress[i] = letter\n correct = true\n end\n end\n @@incorrect << letter if !correct\n @@guesses += 1\n puts(\"secret: #{@@secret}\")\n correct\n end", "def guess!(letter)\n self.word.include? letter\n self.letter = letter\n end", "def check_guess(guess, secret_word)\n matches = []\n secret_characters = secret_word.split(//)\n\n # loop to find matches & wrong letters\n if secret_characters.include? guess\n secret_characters.each_with_index do |char, index|\n if char.include? guess\n @secret_display[index] = char\n end\n end\n else\n @wrong_guesses << guess\n @guess_count -= 1\n end\n end", "def guess_letter\n @unused_letters.pop\n end", "def guess_correct(letter)\n\t\tif @secret_word.include?(letter)\n\t\t\t@secret_word.each_with_index do |correct, index|\n\t\t\tif letter == correct\n\t\t\t\t@display[2*index+1] = letter\n\t\t\t\tputs @display\n\t\t\t\t@attempted_letters << letter\n\t\t\t\tend\n\t\t\tend\n\t\t\t@number_of_guesses -= 1\n\t\t\treturn true\n\t\telse \n\t\t\treturn false\n\t\tend \n\tend", "def check_letter(guess_letter)\n @word_array.each_with_index { |letter, index|\n if letter == guess_letter\n @correct_index_list.append(index)\n end\n }\n if @word_array.include? guess_letter\n puts \"Congratulations you guess a letter correctly!\"\n else\n puts \"Sorry! You did not guess a correct letter.\"\n @number_incorrect += 1\n end\n return @correct_index_list\n end", "def track_user_guesses(user_input)\n track_user_input = Array.new\n track_user_input << user_input\n\n #return track_user_input\n end", "def incorrect_guess(game)\n for letter in game.guessed_letters\n unless game.hiddenword.word.split(\"\").include?(letter)\n game.player.lives -= 1\n end\n end\n return game.player.lives\nend", "def check(guess)\n correct = 0\n\n if @guessed.include?(guess)\n @message = \"Choose another letter!\"\n else\n @message = \"\"\n @guessed << guess\n @to_guess.each_with_index do |char, index|\n if guess == char\n @guessing[index] = guess\n correct += 1\n end\n end\n @lives -= 1 if correct == 0\n end\n\n if @guessing.join == @to_guess.join\n @message = \"#{@guessing.join} was the word. You won!!\"\n @status = \"disabled\"\n end\n if @lives == 0\n @message = \"No lives left! You lost! The word was: \\\"#{@to_guess.join}\\\"\"\n @status = \"disabled\"\n end\n\n end", "def make_guess\n puts \"Make a guess:\"\n @current_guess = gets.chomp\n unless good_guess?\n puts \"That is an invalid guess, please try again!\"\n @current_guess = gets.chomp\n end\n puts\n guesses << current_guess unless current_guess == \"save\" || current_guess == secret_word\n end", "def guesses\r\n \t@guesses.join(' ')\r\n end", "def get_guess\n\t\t# There are turns left...\n\t\tif @turn < 9\n\t\t\tshow_board\n\t\t\tputs \"Enter your letter guess...\"\n\t\t\tletter = gets.chomp.downcase\n\t\t\tvalidate_letter(letter)\n\t\t# No turns left, show losing message and delete game if it was previously saved\n\t\telse\n\t\t\tputs\n\t\t\tshow_board\n\t\t\tputs \"Dangit, you ran out of turns!\"\n\t\t\tputs \"The word was #{@word.join}...\"\n\t\t\tif @running_saved_game != nil\n\t\t\t\tover_write_data\n\t\t\tend\n\t\t\tgo_again\n\t\tend\n\tend", "def feedback(guess_word)\n guessword_array=guess_word.split(\"\")\n word_array=@word.split(\"\")\n guessword_array.each do |letter|\n if word_array.include?(letter)\n @result[word.index(letter)]=letter\n end\n end\n puts \"here is your feedback: #{@result}\"\n end", "def guess(letter)\n \n raise ArgumentError if letter.nil? ## Raise an error if the letter is null.\n raise ArgumentError if letter == '' ## Raise an error if the user entered an empty string. \n raise ArgumentError if !letter.match(/[a-zA-Z]/) ## Raise an error is the user entered a letter that is not in the alphabet.\n\n \n letter.downcase!\n \n # If word includes letter\n if(word.include? letter)\n # And the letter isnt already in guess\n unless (guesses.include? letter)\n # Add guessed word to guesses\n guesses.concat(letter)\n \n # For test case 14\n for i in 0..word.length do\n # If the guessedLetter is in the string, replace it with the guessed letter\n if(letter == word[i])\n word_with_guesses[i] = letter\n end\n \n end\n \n # If guessed letters match word set to win\n if(word_with_guesses == word)\n @check_win_or_lose = :win\n end\n \n return true # return true valid guess\n end #end unless\n return false # invalid guess false\n else\n unless (wrong_guesses.include? letter)\n # Add the guessed letter to the list of incorrected guesses\n wrong_guesses.concat(letter)\n \n # Wrong guesses greater than 7 set win or loose to loose\n if(@wrong_guesses.length>=7)\n @check_win_or_lose = :lose\n end\n \n return true\n end # end unless\n return false # invalid guess\n end # end for \n end" ]
[ "0.792962", "0.78505254", "0.7769422", "0.74021506", "0.7317234", "0.72854877", "0.7260846", "0.7251099", "0.7188374", "0.7187443", "0.7175978", "0.71673495", "0.71298856", "0.71237457", "0.71142584", "0.71006775", "0.7081098", "0.70733905", "0.70709395", "0.70657134", "0.7021785", "0.70094925", "0.69958264", "0.69932896", "0.6988483", "0.69813704", "0.69445723", "0.694065", "0.6918901", "0.69173086", "0.6895963", "0.6892807", "0.6888419", "0.6888419", "0.68829435", "0.68801045", "0.68631846", "0.6860871", "0.68218523", "0.6803898", "0.67723", "0.6770492", "0.67611516", "0.67464316", "0.67395276", "0.669801", "0.66826427", "0.6673998", "0.666362", "0.6660876", "0.6657051", "0.6653016", "0.6633701", "0.66276187", "0.66274744", "0.66269565", "0.661627", "0.6580524", "0.6570937", "0.65640956", "0.6563139", "0.65569216", "0.65439624", "0.6530758", "0.6522162", "0.64971507", "0.6477458", "0.6475983", "0.6473956", "0.6460166", "0.6454552", "0.64455104", "0.6445044", "0.6432964", "0.64314365", "0.6425126", "0.6419778", "0.6419778", "0.6405786", "0.64051586", "0.63863295", "0.63836706", "0.63775575", "0.63754404", "0.6374248", "0.63710713", "0.6365631", "0.6359169", "0.63346696", "0.6318977", "0.6314186", "0.63116515", "0.63003045", "0.6298021", "0.62942344", "0.62893426", "0.6283013", "0.62787294", "0.6278013", "0.62651426" ]
0.6910815
30
METHOD: update remaining guess count INPUT: N/A OUTPUT: integer of remaining guesses
def update_guess_count @guess_count > 0 ? @guess_count -= 1 : @guess_count end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def guess_count\n\t\t @number_of_guesses -= 1\n\tend", "def increment_guess_count(current_guess_count)\n\tcurrent_guess_count += 1\nend", "def total_guess_count()\r\n\t\t# TODO: fill in method body\r\n\t\treturn -1\r\n\tend", "def increment_guess_count(guesses_made)\n guesses_made = guesses_made + 1\nend", "def increment_guess_count\n @current_guess_count += 1\n end", "def increment_guess_count\n @current_guess_count += 1\n end", "def increment_guess_count\n @current_guess_count += 1\n end", "def bad_guess_count()\r\n\t\t# TODO: fill in method body\r\n\t\treturn -1\r\n\tend", "def increment_guess_count(count)\n\treturn count += 1\nend", "def increment_guess_count (guess_count)\n\treturn guess_count += 1\nend", "def increment_guess_count(guess)\n\tincremented = guess.to_i + 1\nend", "def use_guess\n @guesses -= 1\n end", "def guesses_left\n\t\t@guesses -= 1\n\t\tguesses \n\tend", "def guesses_left(current_guess_count)\n\t3 - current_guess_count\nend", "def guesses_left\n @guesses_allowed - @current_guess_count\n end", "def guesses_left()\n \treturn ((@guesses_allowed - @current_guess_count)) \n end", "def new_guess(tries)\n\tputs \"You have #{3-tries} more tries:\"\n\tgets\nend", "def init_guess_count\n @guess_count = 12\n end", "def guess_badly(guess)\n @remaining_guesses -= 1\n @current_index += 1\n @bad_guesses << guess\n end", "def remaining_guesses()\n if $turns > 1\n puts \"You have #{$turns} incorrect guesses left!\"\n elsif $turns == 1\n puts \"You have 1 incorrect guess left!\"\n else\n puts \"GAME OVER\"\n end\n end", "def guesses_left\n @guesses_left = @guesses_allowed - @current_guess_count\n end", "def check_lost\n if @guess_count == MAX_GUESS\n puts \"\\tYou lost! You've used up all your guesses!\"\n self.new_round\n end\n end", "def number_correct\n number_correct = 0\n if current_card.answer == turns[turns.length - 1].guess\n number_correct + 1\n end\n end", "def get_num_of_guesses\r\n return @numOfGuessesLeft\r\n end", "def increment(resp)\n return if game_data.randomly_picked_word.include?(resp)\n\n game_data.guesses_remaining -= 1\n end", "def updateGamesLost\n @gamesLost += 1\n end", "def turns_left\n turns_left = @total_guesses - @guess_count\nend", "def incorrect_guess(game)\n for letter in game.guessed_letters\n unless game.hiddenword.word.split(\"\").include?(letter)\n game.player.lives -= 1\n end\n end\n return game.player.lives\nend", "def deduct_available_guesses\n @available_guesses -= 1\n end", "def guess_limit\n\t\tguesses \n\tend", "def check_if_lost\n\t\tif @guess_count == @number_guess + 1\n\t\t\t@game_over = 2\n\t\tend\n\t\t@game_over\n\tend", "def wrong\n @count += 1\n [:wrong, @count]\n end", "def keep_guessing(guess)\n count = 0\n until guess == @number || count == 4\n if guess < @number\n puts 'Your guess was too low. Try Again.'\n else\n puts 'Your guess was too high. Try Again'\n end\n\n guess = gets.to_i\n count += 1\n end\n\n results guess\n end", "def update_total_matches\n self.correct_matches = (maker.code.select.with_index { |v, i| v == breaker.guess[i] }).length\n self.matches = 4 - (maker.code - breaker.guess).length - correct_matches\n end", "def guesses_left(int, max_guesses)\n max_guesses - int\nend", "def guessing_game(guess_count)\n puts 'Guess a number between 1 and 100.'\n guess = gets.chomp.to_i\n number = 48\n if guess < number\n puts \"The number is higher than #{guess}. Guess again\"\n guess_count += 1\n guessing_game(guess_count)\n elsif guess > number\n puts \"The number is lower than #{guess}. Guess again\"\n guess_count += 1\n guessing_game(guess_count)\n else\n guess_count += 1\n puts \"You got it in #{guess_count} tries!\"\n end\nend", "def update_game_state guess\n\t\tif @word.include?(guess)\n\t\t\t@hits << guess\n\t\telse\n\t\t\t@misses << guess\n\t\t\t@guesses_left -= 1\n\t\tend\n\tend", "def guesses_left(incremented)\n\tif incremented < 3\n\t\tputs 3 - incremented\n\telse\n\t\tputs \"You have guessed at least 3 times\"\n\tend\nend", "def guessnumber\r\n\t\t@tries = @wordlength * 3 / 2\r\n\t\tputs \"player 2: you have #{@tries} guesses to get the word\"\r\n\tend", "def missed_guesses\n guesses - secret\n end", "def number_of_items()\n print \"Please enter a number of items you're interested in seeing: \"\n number_of_items = gets.chomp\n number_of_items = confirm_a_number(number_of_items)\n count = 0\n while number_of_items > @fav_food.length\n count+=1\n print \"Please enter a value less than the size of the menu: \"\n puts \"You have #{@NUMBER_OF_ATTEMPTS-count+1} left\"\n number_of_items = gets.chomp\n number_of_items = confirm_a_number(number_of_items)\n if count >= @NUMBER_OF_ATTEMPTS\n puts \"You have exceeded the required amounts of guesses, default amount of values will be (5).\\n\"\n break\n end\n end\n return number_of_items\nend", "def update_possible!()\r\n\r\n #falls es keine Hits gibt, werden ale Tipps geloescht, die eine der Ziffern enthalten\r\n if (@last_hits == [0,0])\r\n @digits.times do |i|\r\n\r\n @left.delete_if{ |x|\r\n x.include?(@last_guess[i])\r\n }\r\n\r\n end\r\n\r\n end\r\n\r\n #falls es keine Black Hits gibt, werden alle Tipps mit einer identischen Stelle geloescht\r\n if @last_hits[0]==0\r\n\r\n @digits.times do |i|\r\n\r\n @left.delete_if { |x|\r\n x[i]==@last_guess[i]\r\n }\r\n end\r\n\r\n end\r\n\r\n #loescht alle, deren Uebereinstimmung mit dem letzten Tipp nicht den Black Hits entspricht\r\n @left.delete_if { |x|\r\n @last_hits[0] != @mastermind.hits(@last_guess,x)[0]\r\n }\r\n\r\n #loescht alle, deren Uebereinstimmung mit dem letzten Tipp nicht den Total Hits entspricht\r\n @left.delete_if { |x|\r\n (@last_hits[0] + @last_hits[1]) != (@mastermind.hits(@last_guess,x)[0]+@mastermind.hits(@last_guess,x)[1])\r\n }\r\n\r\n end", "def guess(input)\n @last_guess = input\n compare(input)\n @turns += 1\n end", "def guess(input)\n @last_guess = input\n compare(input)\n @turns += 1\n end", "def try_again(secret_num, tries)\n\tguess = new_guess(tries).to_i\n\ttries = tries + 1 \t\t\t\t\t\n\teval_num(secret_num, guess, tries)\nend", "def increment_loss\n self.games_lost += 1\n increment_games_played\n end", "def guessing_game\n\tputs \"Guess a number between 1 and 100\"\n\tcorrect = Random.new.rand(1..100)\n\tnum_guesses = 1\n\tcurrent_guess = gets.chomp.to_i\n\n\twhile current_guess != correct\n\t\tif current_guess > correct \n\t\t\tputs \"The number is lower than #{current_guess}. Guess again\"\n\t\telsif current_guess < correct\n\t\t\tputs \"The number is higher than #{current_guess}. Guess again\"\n\t\tend\n\t\tcurrent_guess = gets.chomp.to_i\n\t\tnum_guesses = num_guesses + 1\n\tend\n\tputs \"You guessed #{correct} in #{num_guesses} tries!\"\nend", "def wrong_answer\n @score -= 1\n end", "def number_correct\n turns.count do |each_turn|\n each_turn.correct?\n end\n end", "def remaining_count\n raw_history['results_remaining']\n end", "def increment_tries\n @tries += 1\n end", "def guess()\n num = rand(1..100)\n count = 0\n puts \"Guess between 1 and 100\"\n\n while ((response = gets.chomp.to_i) != num)\n if (num > response)\n puts \"The number is higher than %s\" % response\n count += 1\n else\n puts \"The number is lower than %s\" % response\n count += 1\n end\n end\n puts \"Congratulations! The number was %s\" % num\n puts \"You got it in %s tries\" % count\nend", "def num_known\n @num_known ||= worth_counting { count_known }\nend", "def test_13_games_lost_count_incremented_upon_lost\r\n letter = \"p\"\r\n $games_lost = 0\r\n $wrong_count = [\"z\", \"x\", \"w\", \"q\", \"d\", \"f\", \"k\", \"m\", \"u\"]\r\n results = wrong_letter(letter)\r\n assert_equal(1, $games_lost)\r\n end", "def try_again(count)\n what_to_do(count)\nend", "def ask_user_guess (total_games = 3)\n puts \"Please guess a nunmber between 1 and 10!\"\n user_guess = gets\n user_guess = user_guess.chomp.to_i\n if user_guess == secret_number\n puts \"That's correct! Congratulations!!! Game over!\"\n elsif\n user_guess > secret_number\n total_games = total_games -1\n \tif total_games > 0\n \t puts \"Too high! Guess again! You have #{total_games} games left\"\n \t ask_user_guess(total_games)\n \telse\n \t puts \"Sorry, no more guesses. The correct answer was 3. Game over!\"\n \tend\n else\n total_games = total_games -1\n \tif total_games > 0\n puts \"Too low! Guess again You have #{total_games} games left\"\n \t ask_user_guess(total_games)\n \telse\n \t puts \"Sorry, no more guesses. The correct answer was 3. Game over!\"\n \tend\n end\nend", "def game(mode, count, rangeL, rangeH, number)\n puts `clear`\n puts \"---------------------\"\n puts \"Welcome to #{mode} mode!\"\n puts \"---------------------\"\n puts \"Please enter a number to guess between #{rangeL} and #{rangeH}.\"\n guess = gets.chomp.to_i\n count += 1 \n while guess != number \n if guess > number \n puts \"You guessed to high\"\n count += 1\n puts \"Please enter a number to guess between #{rangeL} and #{rangeH}.\"\n guess = gets.chomp.to_i\n elsif guess < number \n puts \"You guessed to low\"\n count += 1 \n puts \"Please enter a number to guess between #{rangeL} and #{rangeH}.\"\n guess = gets.chomp.to_i\n end\n end \n puts \"You guessed the number in #{count} attempts!\"\nend", "def increment_correct_slot(guess, code, clues)\n guess.each_with_index do |color, index|\n if color == code[index]\n clues[:correct_slot] += 1\n code[index] = nil # Won't be included for next testing\n guess[index] = nil # Same\n end\n end \n\n clues\n end", "def update_status(guesses) \n \t_count = 0\n \tguesses.each do |guess|\n \t\tif (guess.status == \"hit\") && (self.is_at(guess.x, guess.y))\n \t\t\t_count += 1\n \t\tend\n \tend\n\n \tself.status = _count === self.size ? \"sunk\" : \"safe\"\n\n \tself.status\n end", "def guess_number_3\n tries = 1\n random_number = rand(10) # rand gives a random number between 0 and x-1\n puts \"Guess a number, any number!\"\n answer = gets.chomp.to_i\n while answer != random_number\n puts \"Please guess again. You have had #{tries} tries so far.\"\n tries += 1\n answer = gets.chomp.to_i\n end\n puts \"You guessed correctly! The random number is #{random_number}.\"\n puts \"It took you #{tries} tries to guess the number correctly.\"\nend", "def return_guess\n 5\n end", "def number_correct\n @turns.count do |turn|\n turn.correct?\n end\n end", "def num_of_correct(crct)\n if self.total.nil?\n self.total = 1\n else\n self.total += 1\n end\n \n if crct == 1\n if self.correct.nil?\n self.correct = 1\n else\n self.correct += 1\n end \n else\n self.correct = 0\n end\n end", "def guessing_game\n guesses = 0\n answer = rand(1..100)\n guess = nil\n\n until guess == answer\n puts \"guess a number\"\n guess = gets.chomp.to_i\n\n puts \"#{guess} is too high\" if guess > answer\n puts \"#{guess} is too low\" if guess < answer\n\n guesses += 1\n end\n\n puts \"#{answer} was the correct answer! It took you #{guesses} guesses to come up with that!\"\nend", "def guessgame\n prev_guess = 0\n comp_guess = ((rand * 100) + 1).floor\n attempts = 10\n while attempts >= 1\n print \"Guess the number : \"\n user_guess = gets.chomp.to_i\n if user_guess != prev_guess\n if user_guess > comp_guess\n puts 'Guess was higher'\n elsif user_guess < comp_guess\n puts \"Guess was lower\"\n else\n puts \"You are correct, the answer is #{comp_guess} indeed!\"\n break\n end\n attempts -= 1\n prev_guess = user_guess\n else\n puts \"Guess was same as last attempt, try a different number\"\n end\n puts \"You have #{attempts} attempts left\"\n end\nend", "def wrong_ans\n puts \"What do you think it is ?\"\n @guess_no = gets.chomp.to_i\n\n if @guess_no > @rand_no\n puts \"go a little lower\"\n elsif @guess_no < @rand_no\n puts \"go a little higher\"\n end\n\n @chances += 1\nend", "def wrong_count()\n $game_won == true ? 11 : $wrong_count.length # if the user won use 11, otherwise use the number of wrong letters\nend", "def recalculate_incorrect_num_participants(rounds_to_ignore)\n rd = select{|d| d.num_participants != d.results.select{|t| t.round_complete}.count} - rounds_to_ignore\n \n unless rd.empty?\n puts 'Updating ' + rd.length.to_s + ' Round records where num_participants != # of round_complete Results'\n rd.each{|d| d.update(num_participants: d.results.select{|t| t.round_complete}.count)}\n end\n return rd\n end", "def challenge5 \n\tcounter = 1\n\tnumber = rand(1..100)\n\tputs \"Guess a number between 1 and 100\"\n\tguess = gets.chomp.to_i\n\n\twhile guess != number do\n\t\tif guess > 100 || guess < 0\n\t\t\tputs \"Please guess a number between 1 and 100. Guess again\"\n\t\t\tguess = gets.chomp.to_i\n\t\t\tcounter +=1\n\t\telsif guess < number\n\t\t\tputs \"the number is greater than #{guess}. Guess again.\"\n\t\t\tguess = gets.chomp.to_i\n\t\t\tcounter +=1\n\t\telsif guess > number\n\t\t\tputs \"the number is less than #{guess}. Guess again.\"\n\t\t\tguess = gets.chomp.to_i\n\t\t\tcounter +=1\n\t\tend\n\tend\n\tputs \"You got it in #{counter} attempt(s)!\"\nend", "def num_unknown\n @num_unknown ||= num_researched - num_known\nend", "def decrement_remaining_shots(missed_target)\n self.remaining_shots -= 1 if missed_target\n if remaining_shots == 0 || all_ships_sunk\n self.ended_at = Time.zone.now\n self.points = ((500 * shots_on_target) - (50 * shots_missed)) / time_played\n end\n save\n end", "def if_correct(ok_guess, number_guesses, secret_number) \n\tnumber_guesses = number_guesses - 1\t# STEP 6 - Subtracts one of the player's guesses\n\t\tif ok_guess == secret_number\n\t\t\tputs \"Congratulations! You got it right! You win!!!\"\n\t\telsif ok_guess < secret_number \n\t\t\tputs \"Good try, but guess a little higher.\"\n\t\t\tputs guesses_left(number_guesses) # STEP 7 - Tells the player how many guesses s/he has left\n\t\telse ok_guess > secret_number\n\t\t\tputs \"Good try, but guess a little lower.\"\n\t\t\tputs guesses_left(number_guesses) # STEP 7 - Tells the player how many guesses s/he has left\n\t\tend\nend", "def guesses_left(number_guesses)\n\tif number_guesses == 0\n\t\tputs \"Sorry, you're out of guesses. Game over!\"\n\telsif number_guesses == 1\n\t\tputs \"You have 1 more guess left. No pressure.\"\n\t\tputs \"What's your last guess?\"\n\t\tguess = gets.to_i\n\t\tok_guess = valid_guess(guess)\n\t\tsecret_number = 7\n\t\tputs game_over(ok_guess, secret_number)\n\telsif number_guesses == 2\n\t\tputs \"You have 2 more guesses left.\"\n\t\tputs \"What is your second guess?\"\n\t\tguess = gets.to_i\n\t\tok_guess = valid_guess(guess)\n\t\tsecret_number = 7 # I shouldn't have to add in secret_number. (Instance variable? Hash as argument?)\n\t\tputs if_correct(ok_guess, number_guesses, secret_number) # Goes back to STEP 5(b) to see if correct\n\tend\nend", "def updateGamesPlayed\n @gamesPlayed += 1\n end", "def update_rate_counts(allowed)\n now = Utils::Time.get_time\n\n # No tokens have been seen yet, start a new window\n if @current_window.nil?\n @current_window = now\n # If more than 1 second has past since last window, reset\n elsif now - @current_window >= 1\n @prev_conforming_messages = @conforming_messages\n @prev_total_messages = @total_messages\n @conforming_messages = 0\n @total_messages = 0\n @current_window = now\n end\n\n increment_conforming_count if allowed\n\n increment_total_count\n end", "def check_guess_count()\n if $guessed.count == 0\n puts \"\"\n elsif $guessed.count == 1\n puts \"So far you have incorrectly guessed the letter #{$guessed}\"\n else\n puts \"So far you have incorrectly guessed the letters #{$guessed}\"\n end\n end", "def number_correct\n count_of_correct_turns = 0\n\n @turns.each do |turn|\n if turn.correct? == true\n count_of_correct_turns += 1\n end\n end\n count_of_correct_turns\n end", "def number_correct\n @correct_answers = []\n\n @turns.each do |turn|\n @correct_answers << turn.correct?\n end\n @correct_answers.count(true)\n end", "def retried\n tryouts.size\n end", "def num_players_missing\n num_players - game_players.count\n end", "def calculate\n new_guess\n while @guess != @random_num\n if (@guess <= 100) && (@guess > @random_num)\n guesslower\n elsif (@guess >= 1) && (@guess < @random_num)\n guesshigher\n end\n end\n guesscongrats\n end", "def guess(max_number)\n number_of_guesses = 0\n correct_number = rand(max_number) + 1\n guess = 0\n puts \"I've picked a random number between 1 and #{max_number}.\\n\\n\"\n while (guess != correct_number)\n print \"What is your guess? \"\n guess = gets.chomp.to_i\n number_of_guesses += 1\n if (guess > correct_number)\n puts \"Too High!\"\n elsif (guess < correct_number)\n puts \"Too Low!\"\n else\n puts \"You got it in #{number_of_guesses} guesses. Good job!\"\n end\n end\nend", "def check_for_loss\n if @number_incorrect.to_i == 6\n puts \"Unfortuntately you are out of guesses. Please play again!\"\n exit\n end\n end", "def game_Count\r\n\r\n #increments the gameCount global variable by 1\r\n $gameCount += 1\r\n\r\n end", "def guess\n puts 'Guess a number between 1-100, You only have 5 tries to get it right.'\n\n guess = gets.to_i\n\n if guess == @number\n puts 'WOW!! You guessed it on the first try!'\n else\n keep_guessing guess\n end\n end", "def bad_guess(i,guess,secret_number,name,bad_counter,tries)\n\tleft = tries-i\n \tcase \n \twhen bad_counter==0\n \t\tputs \"Come on. WAKE UP #{name}. Type in a number. Now you have #{left} tries left. You are making it easy for me!\"\n \twhen bad_counter==1\n \t\tputs \"Really? Try again #{name}. Type in a NUMBER not a word! You have #{left} tries left.\"\n \twhen bad_counter==2\n \t\tputs \"How many times do I need to tell you to type in a number. You might as well stop playing. You have #{left} tries left.\"\n \twhen left == 0\n \t\tputs \"Game Over #{name}. The number is #{secret_number}. You lost.\"\n \t\tabort(\"Thank you for playing!\")\n #break\n \telse\n \t\tputs \"I am ignoring your input. You have #{left} tries left.\"\n \tend\n\n\nend", "def checker\n @correct_pos = 0\n @correct_num = 0\n x = 0\n @guess.each do |i|\n if (i == @solution[x])\n @correct_pos += 1\n elsif @solution.include?(i)\n @correct_num += 1\n end\n x += 1\n end\n end", "def parse_and_set_attempt_count(attempts)\n if @handle.ptr == nil\n raise \"this is disposed\"\n end\n result = Native.RunEditor_parse_and_set_attempt_count(@handle.ptr, attempts)\n result\n end", "def num_attempts\n @num_attempts\n end", "def roundcount\n @roundcount = @roundcount + 1\n puts \"You are on round #{@roundcount}\"\nend", "def update_peer_check_count(count = 1)\n begin\n completed_checks = self.auditor_completed_checks + count\n self.auditor_completed_checks = completed_checks\n self.auditor_complete = (completed_checks == self.peer_check_count)\n self.save\n rescue ActiveRecord::StaleObjectError\n self.reload\n retry\n end\n end", "def analyze\n @hits.times do\n @guesses << @last_guess unless @guesses.length == 4\n end\n end", "def analyze\n @hits.times do\n @guesses << @last_guess unless @guesses.length == 4\n end\n end", "def guessing_game\n chosen_num = Random.new.rand(100) + 1\n guesses = 0\n\n if chosen_num == 0 then raise NoMoreInput end\n\n begin\n puts \"Guess a number between 1 and 100:\"\n guess = gets.chomp.to_i\n puts \"#{guess}\"\n\n if guess > chosen_num\n puts \"too high\"\n elsif guess < chosen_num\n puts \"too low\"\n end\n guesses += 1\n end until guess == chosen_num\n\n puts \"You guessed right in #{guesses}! It was #{guess}\"\nend", "def check_guess\n reset_guess\n check_number_and_position\n check_number_only\n fill_result\n @result\n end", "def count_guess \r\n\t\t@num_guess = @secret_word.length \r\n\t\t@num_guess.times do \r\n\t\t\t@word_length_array << \"_\"\r\n\t\tend \r\n\t\tp @word_length_array\r\n\tend", "def player_game(player)\n until player.guess_count >= @@MAX_GUESS || player.guess == @secret_code\n puts \"You have #{@@MAX_GUESS-player.guess_count} guesses left.\"\n player.ask_for_guess\n guess_result = check_code(player.guess, @secret_code)\n unless guess_result[0] == 4 && guess_result[1] == 4\n display_guess_results(guess_result)\n end\n end\n display_end_game(player)\n end", "def update_vote_count(card)\n card.increment!(:votes)\n self.used_cards.push(self.unused_cards.shift, self.unused_cards.shift)\n end", "def lives_lost\n @lives -= 1\n pp \"INCORRECT -- YOU HAVE #{@lives} LIVES LEFT\"\n end", "def calc_new_num_available\n # old_num_available = self.num_available\n # when num_offered changes, num_available cannot go below 0\n # new_num_available = self.num_available + self.num_offered\n # if new_num_available < 0\n # self.errors[:base] << \"ERROR: You cannot set 'Num Offered' to #{self.num_offered} because the new 'Num Available' would be negative (#{new_num_available}).\\n\"\n # # { :result => false, \n # # :message => \"ERROR: You cannot set 'Num Offered' to #{self.num_offered} because the new 'Num Available' would be negative (#{new_num_available}).\\n\" }\n # else\n # can proceed with the update\n if self.num_offered == 0\n self.num_available = 0\n else\n self.num_available = self.num_available + self.num_offered \n end\n # { :result => true, \n # :message => \"There are now #{new_num_available} deals available\"}\n # end \n # total_redeemed = Redemption.where(:deal_id => self.id).sum('num_redeemed')\n end" ]
[ "0.7759731", "0.73455924", "0.7324958", "0.73007137", "0.7288633", "0.7288633", "0.7223735", "0.7216042", "0.7200896", "0.71794975", "0.69632095", "0.6962135", "0.6941786", "0.6849557", "0.6814378", "0.66789806", "0.6602662", "0.65936023", "0.65774333", "0.6550532", "0.6518269", "0.64389133", "0.64377874", "0.6415255", "0.63411874", "0.6333863", "0.6328674", "0.63191736", "0.62902886", "0.6250858", "0.6242191", "0.62368625", "0.62194926", "0.6218927", "0.6167184", "0.6112281", "0.6064985", "0.60637814", "0.60495675", "0.6043818", "0.6043743", "0.59570473", "0.5934432", "0.5934432", "0.59257424", "0.59159356", "0.59132826", "0.59050184", "0.59013987", "0.5898125", "0.5896907", "0.5889772", "0.58891743", "0.58571076", "0.5838835", "0.5830201", "0.5827765", "0.58218944", "0.5808269", "0.5804742", "0.5785016", "0.57755035", "0.57488275", "0.5742451", "0.57361776", "0.57343185", "0.57297164", "0.5722226", "0.57166827", "0.5712777", "0.57061213", "0.5701511", "0.57004136", "0.569049", "0.5678722", "0.567088", "0.5668332", "0.5645178", "0.5642785", "0.56412095", "0.56378525", "0.56285954", "0.562773", "0.5627242", "0.562374", "0.56160855", "0.56146413", "0.5614027", "0.56108403", "0.561001", "0.56005347", "0.55975634", "0.55975634", "0.5571738", "0.5571151", "0.55691385", "0.5569138", "0.5565703", "0.5557217", "0.55499697" ]
0.79700905
0
METHOD: display word state INPUT: N/A OUTPUT: word state as string
def display_word_state @word_state.join(" ") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_current_state_of_word()\r\n\r\n wordString = \"\"\r\n\r\n for i in 0..@secretWordLength-1 do\r\n\r\n key = @secretWord[i]\r\n\r\n if @lettersGuessed[key] == true \r\n wordString += key\r\n elsif @lettersGuessed[key] == false\r\n wordString += \"_ \" \r\n end\r\n\r\n end\r\n\r\n return wordString\r\n end", "def display_word\n puts \"Current word: #{@hidden_word}\"\n end", "def current_state_setter\n\t\tputs \"Here is your mystery word: \"\n\t\tlength = @game_word.length.to_i\n\t\t@current_state = Array.new(length, \" _ \")\n\t\t@current_state.join\n\tend", "def show_word()\n puts $hidden_word_arr.join(\" \")\n end", "def state_text\n EasyLoan::LoanBill::STATE_TEXT.fetch(bill_state.to_sym, \"无状态\")\n end", "def echo_state(state)\n if String.disable_colorization\n case state\n when 'running' then '+ ' \n when 'stopped' then '- '\n when 'terminated' then 'X '\n when 'pending' then 'O '\n when 'shutting-down' then '\\\\_'\n when 'stopping' then '~-'\n else '??'\n end\n else\n case state\n when 'running' then '✅ ' \n when 'stopped' then '❙❙'\n when 'terminated' then '⚫ '\n when 'pending' then '⚪ '\n when 'shutting-down' then '♺ '\n when 'stopping' then '⌛ '\n else '??'\n end\n end\nend", "def word_status\n\t\t@ans_word.length.times do\n\t\t\t@guess << \"_\"\n\t\tend\n\t\tputs \"Guesser, your secret word has #{@ans_word.length} characters: #{@guess*\"\"}\"\n\tend", "def show_state\n puts \"#{name} à #{life_points} points de vie\"\n end", "def output_word\n end", "def describe_state(state)\n $states[state.to_sym].last.join(' ,')\nend", "def status_text\n case @state\n when 0\n H87Enchant::ST1\n when 1\n H87Enchant::ST2\n when 2\n H87Enchant::STQ\n when 3\n H87Enchant::ST3\n when 4\n H87Enchant::ST4\n when 5\n H87Enchant::ST5\n else\n ; 'ERRORE 01'\n end\n end", "def show_state\n puts \"#{names} a #{life_points} points de vie\"\n end", "def show_state\n \tputs \"#{@name} a #{life_points} points de vie\"\n end", "def show_state\n\t\tputs \"#{@name} a #{life_points} de points de vie et une arme de niveau #{weapon_level}\"\n\tend", "def show_state\n return \"#{@name} a #{life_points} points de vie et une amre de niveau #{weapon_level}\"\n end", "def state_string\n state.flatten.each_with_object([]) do |square, result|\n result << square_character(square)\n end\n end", "def most_important_state_text\r\n states.each {|state| return state.message3 unless state.message3.empty? }\r\n return \"\"\r\n end", "def state_str\n VN_STATES[state]\n end", "def show_state\n puts \"#{name} a #{life_points} points de vie !!\"\n end", "def show_state\r\n puts \"#{@name} à #{@life_points} points de vie et une arme de niveau #{@weapon_level}\"\r\n end", "def show_state\n return \"#{@name} a #{@life_points} points de vie\"\n end", "def show_state\n puts \"#{@names} a #{@life_points} points de vie et une arme de niveau #{@weapon_level}\"\n end", "def show_state\r\n puts \"#{@name} à #{@life_points} points de vie\"\r\n end", "def show_state\n puts \"#{@name} a #{@life_points} de PV\"\n end", "def show_state\n puts \"#{@name} a #{@life_points} de vie\"\n end", "def show_state\n\t\tputs \"#{@name} a #{@life_points} points de vie.\"\n\tend", "def show_state\n puts \"#{@name} à #{@life_points} points de vie\"\n end", "def show_state\n puts \"#{name} a #{life_points} points de vie!\"\n end", "def show_state \n puts \"#{@name} a #{@life_points} points de vie et une arme au niveau #{@weapon_level}.\"\n end", "def display_name_word\n if @sym == SYM_ATOM || @sym == SYM_ATOM_NON_ASCII || @sym == SYM_QTEXT\n save_text\n get\n else\n\t error \"expected word, got #{@sym.inspect}\"\n\tend\n end", "def show_word\n print \"The word was: #{@word} \\n\"\n puts \"\\n\"\n end", "def show_state \n puts \"#{@name} à #{@life_points} points de vie\"\n end", "def show_state\n puts \"#{@name} a #{@life_points} points de vie et une arme de niveau #{@weapon_level}\"\n end", "def current_state_string\n string = \"\"\n\n (@size * @size).times{ |i|\n if i % @size == 0\n string << \"\\n\\t\"\n end\n if @state[i]\n string << \"1 \"\n else\n string << \"0 \"\n end\n }\n string << \"\\n\"\n\n return string\n end", "def show_state\n puts \"#{@name} a #{@life_points} points de vie\"\n end", "def show_state\n puts \"#{@name} a #{@life_points} points de vie.\"\n end", "def show_state \n puts \"#{@name} a #{@life_points} points de vie.\"\n end", "def description\n @state.description\n end", "def display ( )\n puts 'Parser states: ' + @states.size.to_s\n\n @states.each do |st|\n\tputs\n\tputs '*' * 80\n\tputs 'state: ' + st.statename\n\tputs 'branches: '\n\tst.branches.each do |br|\n\t puts ' ' + @states[br].statename\n\tend\n end\n end", "def short_state_str\n SHORT_VN_STATES[state_str]\n end", "def current_state_s\n self.current_state.to_s.humanize.downcase\n end", "def current_state_s\n self.current_state.to_s.humanize.downcase\n end", "def output_word\n p @guessedWord\n end", "def game_state\n\t\t\"YOURTURN #{self.current_round} #{@hunter.to_state}, #{@prey.to_state}, W[#{@walls.map{|w| w.to_state}.join(\", \")}]\"\n\tend", "def show_state\n\t\tputs \"#{self.name} a #{self.life_points} points de vie et une arme de niveau #{self.weapon_level}.\"\n\tend", "def boolean_to_word_no(bol)\n if bol \n return \"\"\n else\n return \"No\"\n end\n end", "def is_word_complete()\n !@current_state.include? \"_\"\n end", "def display_status\n exam_state = (all_questions_answered? ? FINISHED_STATE : UNFINISHED_STATE).titleize\n \"#{exam_state} Subject\"\n end", "def show_state\n puts \"#{self.name} a #{self.life_points} points de vie et son arme est de niveau #{self.weapon_level}.\"\n end", "def output_word\n puts @displayed_character.join('')\n end", "def show_state\n\t\treturn \"#{self.name} a #{self.life_points} points de vie.\"\n\tend", "def log_state(state, byte)\n return nil unless @debug\n token = if byte == TOKEN_QUOTE\n 'TOKEN_QUOTE'\n elsif byte == TOKEN_EQUAL\n 'TOKEN_EQUAL'\n elsif byte == TOKEN_END\n 'TOKEN_END'\n elsif byte == TOKEN_COMMENT_START\n 'TOKEN_COMMENT_START'\n elsif byte == TOKEN_COMMENT_MULTI\n 'TOKEN_COMMENT_MULTI'\n elsif byte == TOKEN_COMMENT_SINGLE\n 'TOKEN_COMMENT_SINGLE'\n elsif byte.chr =~ TOKEN_WHITESPACE\n 'TOKEN_WHITESPACE'\n elsif byte.chr =~ TOKEN_EOL\n 'TOKEN_EOL'\n else\n 'TOKEN_NEUTRAL'\n end\n puts \"#{state_to_string(state)}\\n #{token} (#{byte})\"\n nil\n end", "def state_text state = self.State\n P2::DS_MESSAGES[state]\n end", "def state_str\n MARKETPLACEAPP_STATES[state]\n end", "def state_abbr; end", "def state_string()\n ss = 'UNKNOWN'\n case @state\n when STARTING\n ss = 'STARTING'\n when STOPPED\n ss = 'STOPPED'\n when RUNNING\n ss = 'RUNNING'\n when CLOSING\n ss = 'CLOSING'\n when BLOCKED\n ss = 'BLOCKED'\n when STEP\n ss = 'STEP'\n end\n ss\n end", "def show\n \"$#{total} #{@state[0]} #{@state[1]} #{@state[2]} #{@state[3]} #{@state[4]}\"\n end", "def status_in_words\n return \"Champion's Bracket\" if status == 1\n return \"Second Chance Bracket\" if status == 2\n return \"Knocked Out for the season!\"\n end", "def to_pretty_s\n \"#{type}:#{name} is #{state}\"\n end", "def getDescriptionOfState ( state )\n case state \n when CHECKBOX_CHECKED\n s = \" Checked \"\n when CHECKBOX_UNCHECKED\n s = \" Unchecked \"\n when CHECKBOX_TOGGLE\n s = \" Toggle \"\n else\n s = \" Unknown Checkbox State!! \"\n end\n return s \n end", "def state_description(item)\n s = state_value(item) or return\n state_table.dig(s, :note) || s.to_s.humanize(capitalize: false)\n end", "def state_label(x)\n labels = { 'state_abb' => \"State Abbreviation\"}\n !labels[x].nil? ? labels[x] : nil\n end", "def state_to_string(state)\n {\n STATE_SEARCH => 'STATE_SEARCH',\n STATE_IN_KEY => 'STATE_IN_KEY',\n STATE_EXPECT_EQUAL => 'STATE_EXPECT_EQUAL',\n STATE_EXPECT_VALUE => 'STATE_EXPECT_VALUE',\n STATE_IN_VALUE => 'STATE_IN_VALUE',\n STATE_EXPECT_END => 'STATE_EXPECT_END',\n STATE_EXPECT_COMMENT => 'STATE_EXPECT_COMMENT',\n STATE_IN_COMMENT_MULTI => 'STATE_IN_COMMENT_MULTI',\n STATE_EXPECT_COMMENT_END => 'STATE_EXPECT_COMMENT_END',\n STATE_IN_COMMENT_SINGLE => 'STATE_IN_COMMENT_SINGLE',\n STATE_EXPECT_UTF8_BOM => 'STATE_EXPECT_UTF8_BOM'\n }[state]\n end", "def word\n if @sym == SYM_ATOM || @sym == SYM_QTEXT\n save_text\n get\n else\n\t error \"expected word, got #{@sym.inspect}\"\n\tend\n end", "def state_label\n self.state == 3 ? \"Confirmado\" : \"Borrador\"\n end", "def print_current_status\n print_guess_word_status = \"\"\n @guess_word_status.each do |letter|\n print_guess_word_status += \"#{letter} \"\n end\n puts \"\\nYou guessed #{@failed_attempts} times wrong so far. Remember, when reaching 10 you lose!\"\n puts \"Guess word status = #{print_guess_word_status}\"\n end", "def get_word\r\n return_word\r\n end", "def display_state(object, attr)\n I18n.t(\"activerecord.attributes.#{object.class.to_s.underscore}.states.#{attr.to_s}.#{object.send(attr)}\")\n end", "def state_str\n VM_STATE[state]\n end", "def state_str\n VM_STATE[state]\n end", "def show\n set_word\n end", "def print_info\n if get_definitions[0] == nil\n puts \"Invalid word\"\n else\n # output for terminal, uses dashes for cleaner screen\n puts \"-\" * 20\n puts \"You entered #{word}.\"\n `say #{word}`\n puts \"-\" * 20\n puts \"We found the following definitions:\"\n print_definitions\n puts \"-\" * 20\n puts \"The best example usage is:\"\n print_top_example\n puts \"-\" * 20\n puts \"We found the following pronunciations:\"\n print_pronunciations\n puts \"-\" * 20\n end\n end", "def show_state\n puts \"#{@name} has #{@life_points} life points\"\n end", "def state\n object.human_state_name\n end", "def state_prompt_label\n # unit_test_no_generate: state_prompt_label, span.className(create_ats_regex_string(\"ats-statelbl\"))\n $tracer.trace(__method__)\n return ToolTag.new(span.className(create_ats_regex_string(\"ats-statelbl\")), __method__)\n end", "def display_text word\n raise \"word should be string\" unless word.is_a? String\n w = @form.by_name[\"tv\"]; \n lines = get_data word\n #file = `ri -f bs #{word}`\n #lines = convert_man_to_ansi file\n return if lines.nil? || lines.size == 0\n # ansi can have overflow\n w.add_content(lines, :content_type => :ansi, :title => word)\n\n # Since i am trying without border, so need to put class on top right\n header = @form.by_name[\"header\"]; \n header.text_right(word)\n\n $visited << word unless $visited.index(word)\n #w.add_content(lines, :title => word)\n w.buffer_last\nend", "def state_str\n ZONE_STATES[state]\n end", "def show_state\n puts \"#{self.name} a #{self.life_points} points de vie.\"\n end", "def get_state\n \"Treasury state: #{@resources}\"\n end", "def to_s\n @word\n end", "def current_state\n Display.hangman(@lives)\n puts @hints.join('.')\n Display.errors(@incorrect)\n end", "def to_s\n\t\tputs(\"States: #{@states}\")\n\t\tputs(\"Input Symbols: #{@input_symbols}\")\n\t\tputs(\"Output_symbols: #{@output_symbols}\")\n\t\tputs(\"Left Marker: #{@left_marker}\")\n\t\tputs(\"Blank Symbol: #{@blank_symbol}\")\n\t\tputs(\"Start State: #{@start_state}\")\n\t\tputs(\"Accept State: #{@accept_state}\")\n\t\tputs(\"Reject State: #{@reject_state}\")\n\t\tputs(\"Function Map: #{@function_map}\")\n\t\treturn \"\"\n\tend", "def render_State s\n return if @rendered[s]\n @rendered[s] = true\n\n stream.puts \"\\n// #{s.inspect}\"\n \n sequence = [ ]\n \n if options[:history]\n options[:history].each_with_index do | hist, i |\n if hist[:new_state] && s.is_a_superstate_of?(hist[:new_state])\n sequence << i + 1\n end\n end\n end\n\n dot_opts = {\n :label => dot_label(s),\n :shape => :box,\n :style => \"filled\",\n }\n\n case\n when s.end_state?\n dot_opts[:label] = \"\" # DONT BOTH LABELING END STATES.\n dot_opts[:shape] = :doublecircle\n end\n\n dot_opts = dot_opts_for s, dot_opts\n\n hide_decomposition = dot_opts.delete(:hide_decomposition)\n stream.puts \" // hide_decomposition = #{hide_decomposition.inspect}\"\n\n if (hs = options[:highlight_states]) && hs.include?(s)\n dot_opts[:style] += ',bold'\n end\n\n unless sequence.empty?\n if options[:highlight_state_history] && (s.submachine ? hide_decomposition : true)\n dot_opts[:fillcolor] = :grey\n end\n if options[:show_state_sequence] \n dot_opts[:label] += \"\\\\n(#{sequence_to_s(sequence)})\\\\r\"\n end\n else\n if options[:highlight_state_label_history]\n dot_opts[:fontcolor] = :grey\n end\n if options[:highlight_state_border_history]\n dot_opts[:color] = :grey\n end\n end\n\n dot_opts[:color] ||= :black\n dot_opts[:fontcolor] ||= :black\n dot_opts[:fillcolor] ||= :white\n\n # Dont label FinalStates, it causes too much clutter.\n # Invert the colors to be more like UML.\n case\n when s.end_state?\n dot_opts[:label] = \"\" \n dot_opts[:fillcolor], dot_opts[:fontcolor] =\n dot_opts[:fontcolor], dot_opts[:fillcolor]\n end\n\n if ssm = s.submachine\n # Composite States are rendered as\n # a subgraph cluster with a target and source \"connection point\" for external connections.\n # This is where the dot_name(s, :source || :target) is defined.\n # Subsequence Transitions edges will used these connnection points.\n implicit_dot_opts = dot_opts.dup\n dot_opts[:hide_decomposition] = hide_decomposition\n render_StateMachine(ssm, dot_opts) do\n dot_opts = implicit_dot_opts\n dot_opts[:shape] = :point\n dot_opts[:label] = \"[]\"\n\n stream.puts %Q'\\n subgraph cluster_#{dot_name(s, :source)} {'\n stream.puts %Q{ color=none;}\n stream.puts %Q{ fillcolor=none;}\n stream.puts %Q{ fontcolor=none;}\n stream.puts %Q{ label=\"\";}\n stream.puts %Q{ shape=\"plaintext\";}\n stream.puts %Q{ style=\"none\";}\n\n dot_opts[:color] = :black\n dot_opts[:fillcolor] = :black\n stream.puts \"\\n// Implicit target point for State #{s.to_s}\"\n stream.puts %Q{ node [ #{render_opts(dot_opts)} ] #{dot_name(s, :target)};}\n\n dot_opts[:color] = :black\n dot_opts[:fillcolor] = :white\n stream.puts \"\\n// Implicit source point for State #{s.to_s}\"\n stream.puts %Q{ node [ #{render_opts(dot_opts)} ] #{dot_name(s, :source)};}\n stream.puts \"\\n }\\n\"\n end\n return self\n end\n\n # Non-composite States are rendered as simple nodes.\n # In this case dot_name(s, :source || :target) == dot_name(s).\n dot_opts[:style] += ',rounded'\n stream.puts %Q{ node [ #{render_opts(dot_opts)} ] #{dot_name(s, [:source, :target])};}\n\n return self\n end", "def show # shows the selected word of the day (redundant)\n end", "def print_status(game)\n cls\n\n puts game.version\n\n # Print the word with underscores instead of not guessed letters\n puts \"\\nWord: #{get_word_for_print(game.letters, game.good_letters)}\"\n # Print wrong letters separated with commas\n puts \"Mistakes: #{game.bad_letters.join(\", \")}\"\n\n # Print the image for the current number of made mistakes\n print_hangman(game.mistakes)\n\n if game.status == :lost\n # If player lost - print a message about it and show the word\n puts \"\\nGame over :(\"\n puts \"The word was: \" + game.letters.join(\"\")\n elsif game.status == :won\n # If player won - congratulate\n puts \"\\nYou won! Congratulations! :)\"\n else\n # If the game is not over, print the number of mistakes that are available to make\n if game.mistakes != 6\n puts \"You have left: #{game.mistakes_left} mistakes\"\n else\n puts \"You have left: 1 mistake. Be careful! \"\n end\n end\n end", "def show_state\n if @life_points <= 0\n puts \">>> #{@name} a 0 points de vie\"\n else\n puts \">>> #{@name} a #{@life_points} points de vie et une arme de niveau #{@weapon_level}\"\n end\n end", "def current_status\n result = \"\"\n\n @guessing_word.split(\"\").each { |letter|\n if @guess_array.include?(letter)\n result << letter\n else\n result << \"_ \"\n end\n }\n \n return result\n end", "def state_s\n # return \"审核中\" if approving?\n return \"等待激活中\" if unapproved?\n return \"审核被拒绝\" if rejected?\n return \"展示中\" if opened? and available?\n return \"高亮展示中\" if highlighted? and opened? and available?\n return \"已过期\" if !available?\n return \"未展示\" if closed?\n end", "def printState(count,md,mq,ac)\n\tputs(count.to_s(2))\n\tputs(\"MD:\" + md.join)\n\tputs(\"AC:\" + ac.join)\n\tputs(\"MQ:\" + mq.join)\nend", "def word\n end", "def show_word(secretword)\n\t\tanswers = []\n\t\tsecretword.length.times do\n\t\t\tanswers.push(\"\")\n\t\tend\n\t\tanswers\n\tend", "def feedback\n puts \"Spelling errors\"\n #Default errors is 0\n errors = 0\n #For each word in the word hash\n $words.each do |word|\n #If the word is spelled wrong prints the word and increments errors\n if word[1] == false\n puts \"#{word[0]}\"\n errors += 1\n end\n end\n #If there are no errors states as much\n if errors == 0\n puts \"No errors found\"\n end\nend", "def lex_state; end", "def word; end", "def word; end", "def word; end", "def word; end", "def word; end", "def complete_state_name()\n return engine.complete_state_name()\n end", "def to_s\n\n\t \"Words running in pure mode using wordnet files found at #{wordnet_path}\"\n\n\tend" ]
[ "0.662951", "0.6614449", "0.65313107", "0.6524054", "0.6500809", "0.6387393", "0.6297495", "0.62627405", "0.62448466", "0.6211618", "0.61427057", "0.6130881", "0.6130296", "0.61248255", "0.6119928", "0.61089206", "0.61068046", "0.61050934", "0.6091142", "0.6081492", "0.60782295", "0.6076068", "0.60753244", "0.6062975", "0.60521907", "0.6040428", "0.60393536", "0.60222155", "0.60200965", "0.60047925", "0.6003757", "0.5994125", "0.59852284", "0.5975653", "0.5967125", "0.59636027", "0.59316224", "0.5921475", "0.59144336", "0.5907702", "0.5902266", "0.5902266", "0.5880507", "0.5850774", "0.5827625", "0.5810066", "0.5810019", "0.58067715", "0.58000094", "0.57842606", "0.5775981", "0.57726455", "0.57690126", "0.5757092", "0.5753959", "0.5738006", "0.5736876", "0.57303494", "0.57275516", "0.5717803", "0.57093126", "0.5707139", "0.57031924", "0.5683395", "0.56800634", "0.56758904", "0.56546974", "0.56249636", "0.5615856", "0.5615856", "0.561533", "0.5609595", "0.5605318", "0.56051135", "0.55938774", "0.55920094", "0.55800855", "0.5575064", "0.5571755", "0.55713665", "0.5567673", "0.55657405", "0.55600524", "0.5550474", "0.55490655", "0.5547306", "0.554709", "0.55328697", "0.5521638", "0.551326", "0.5496284", "0.5493573", "0.5467584", "0.54664993", "0.54664993", "0.54664993", "0.54664993", "0.54664993", "0.54630023", "0.5444091" ]
0.79703206
0
METHOD: update word state with most recently added guess INPUT: N/A OUTPUT: updated word state
def update_word_state @secret.chars.each_with_index do |letter, idx| @word_state[idx] = letter if @guesses[-1] == letter end @word_state end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_game_state guess\n\t\tif @word.include?(guess)\n\t\t\t@hits << guess\n\t\telse\n\t\t\t@misses << guess\n\t\t\t@guesses_left -= 1\n\t\tend\n\tend", "def update_current_state(guess)\n start = 0\n while (i = @secret_word.index(guess, start)) != nil\n @current_state[i] = guess\n start = i + 1\n end\n @current_state\n end", "def answer_update \r\n\t\t@guess_word.each_index do |i|\r\n\t\t\t@guess_word[i] ||= \"_\"\r\n\t\tend \r\n\t\tp @guess_word\r\n\tend", "def update_word(user_guess)\n\t\ti = 0\n\t\twhile i < @number_guess\n\t\t\tif @answer_word[i] == user_guess\n\t\t\t\t@word_hidden[i] = user_guess\n\t\t\tend\n\t\ti += 1\n\t\tend\n\t\t@word_hidden\n\tend", "def guess_word=(guess)\n \n # First is the case that the user guesses correctly\n if @word == guess\n @is_correct = true # flag to see if the user guessed correctly is set true\n @guess_count = 0 # Automatically set the guess count to zero\n \n # Now want to know if the guess word guess is included in the guess history\n elsif @guess_history.include?(guess)\n @is_correct = false # flag set to false but no loss in attempt\n\n # Finally if the guess is not correct\n else\n @guess_history << guess # Store the guess in the guess history\n @is_correct = false # flag is still showing the guess incorrect\n @guess_count -= 1 # loose an attept at guessing\n end\n end", "def update_round(guess)\n if @word_array.include?(guess)\n @word_array.each_with_index do |letter, index|\n @word_array_player[index] = letter if guess == letter\n end\n else\n @errors_left -= 1\n end\n @letters_guessed.push(guess)\n end", "def change_guess_word_status(position_letter)\n @guess_word_status[position_letter] = @guess_letter\n end", "def update_teaser last_guess\n new_teaser = @word_teaser.split\n new_teaser.each_with_index do |letter, index|\n if letter == \"_\" && @words.first[index] == last_guess\n new_teaser[index] = last_guess\n end\n end\n @word_teaser = new_teaser.join(' ')\n end", "def update_display_word\n length = @word.length\n length.times do |i|\n if @word[i] == @current_guess\n @display_word[i] = @word[i]\n end\n end\n end", "def guessed_word(alphabet,position)\n\t\tindex = position-1\n\n\t\t# Check for repeating guess by comparing already existing guesses from the hash.\n\t\tif guessed_words.keys.index(position) != nil && guessed_words[position].upcase == alphabet.upcase\n\t\t\tputs \"Don't repeat the same guess\"\n\t\t\tputs \"You have #{guesses} guesses left.\"\n\n\t\t# If the guess is same as that of the original word's letter, its a correct guess\n\t\telsif original_word[index] == alphabet.upcase\n\t\t\thidden_word[index] = alphabet.upcase\n\t\t\tguesses_history(alphabet,position)\n\t\t\tputs \"Congrats!!! Your guess is correct.\"\n\t\t\tputs \"You have #{guesses_left} guesses left.\"\n\t\t# Additional condition for downcase correct guesses.\n\t\telsif original_word[index] == alphabet.downcase\n\t\t\thidden_word[index] = alphabet.downcase\n\t\t\tguesses_history(alphabet,position)\n\t\t\tputs \"Congrats!!! Your guess is correct.\"\n\t\t\tputs \"You have #{guesses_left} guesses left.\"\n\n\t\t# Other than repeat and correct guess, all other guesses are worng and just add the guesses to the hash to show repeat case in future.\n\t\telse\n\t\t\tputs \"Sorry! That's a wrong guess.\"\n\t\t\tputs \"You have #{guesses_left} guesses left.\"\n\t\t\tguesses_history(alphabet,position)\n\t\tend\n\t\tputs \"The status of the word is: #{hidden_word}\" \n\tend", "def guess(guess)\r\n\t\t# Make sure the guess is either a letter or the whole word\r\n\t\tif guess.length != 1 && guess.length != @win_word.length\r\n\t\t\tp @remaining_guesses.to_s + \" guesses left\"\r\n\t\t\tp \"Guess a letter, or the complete word!\"\r\n\t\t# check for repeated guesses\r\n\t\telsif @past_guesses.include? guess\r\n\t\t\tp @remaining_guesses.to_s + \" guesses left\"\r\n\t\t\tp @hint\r\n\t\t\tp \"You guessed that already!\"\r\n\t\t# check if they guessed the entire word correctly\r\n\t\telsif guess == @win_word\r\n\t\t\twin\r\n\t\t# if the letter is not in the word\r\n\t\telsif !@win_word.include? guess\r\n\t\t\t# Add guess to arrayof past guesses\r\n\t\t\t@past_guesses << guess\r\n\t\t\tif @remaining_guesses == 1\r\n\t\t\t\tlose\r\n\t\t\telse\r\n\t\t\tguesses_remaining\r\n\t\t\tp @remaining_guesses.to_s + \" guesses left\"\r\n\t\t\tp @hint\r\n\t\t\tp \"Sorry, try again!\"\r\n\t\t\tend\r\n\t\t# if the letter is in the word\r\n\t\telsif @win_word.include? guess\r\n\t\t\t# Add guess to arrayof past guesses\r\n\t\t\t@past_guesses << guess\r\n\t\t\tguesses_remaining\r\n\t\t\tp @remaining_guesses.to_s + \" guesses left\"\r\n\t\t\tupdate_hint(guess)\r\n\t\t\tif @hint_str == @win_word\r\n\t\t\t\twin\r\n\t\t\telse\r\n\t\t\t\tp \"Nice guess!\"\r\n\t\t\tend\r\n\t\telse\r\n\t\t\tp \"Error\"\r\n\t\tend\r\n\r\n\tend", "def new_round\n @guess_feedback = \"\" # Set guess feedback to be empty\n puts \"\\t\\tNext Round!\\n?????\"\n\t\t@guess_count = 0 # Reset amount of guesses\n\t\t@current_word = self.random_word # Set a new random chosen/current word\n\tend", "def make_guess(guess)\n @previous_guesses << guess \n display_string = show_progress()\n if !goal_word.include?(guess) \n guess_counter()\n end \n if display_string == @goal_word\n @player_won = true \n end\n end", "def reset_game\n\t\t\t@word = @@dictionary.sample.downcase[0..-3] #strips away \\r and \\n characters\n\t\t\t@guesses = 5\n\t\t\t@guess_map = Array.new(@guesses) {false}\n\t\t\t# puts @guess_map\n\t\tend", "def save_guess\n if good_guess?\n matching_indexes(@code_word, @word_guesser.guess).each do |i|\n @good_guesses[i] = @word_guesser.guess\n end\n else\n @bad_guesses.push(@word_guesser.guess)\n end\n end", "def guess_word(word)\n won = won?(word)\n @tries_left -= 1 unless won\n won\n end", "def guessed_word(word)\n\t\tif @ans_word == word\n\t\t\tputs \"You are a genious\"\n\t\telse\n\t\t\tputs \"guess again\"\n\t\t\t@guess_word.pop\n\t\tend\n\tend", "def update_display \r\n \tletters = @secret_word.chars\r\n \tletters.each_with_index {|letter, index| @word_display[index] = letter if letter == @guess}\r\n \t@word_display\r\n end", "def make_guess(word)\n raise_if_complete\n\n correct = word.downcase == password.word\n guesses.create!(word: word, correct: correct)\n self.game_state = 'lost' if lives_left.zero?\n self.game_state = 'won' if correct\n save!\n correct\n end", "def check_word(guess)\n\t\tguess_used = false\n\t\t@guess_history.each do |x|\n\t\t\t\tif x == guess\n\t\t\t\t\tguess_used = true\n\t\t\t\tend\n\t\t\tend\n\t\tif !guess_used\n\t\t\t@guess_count += 1\n\t\t\t@guess_history << guess\n\t\tend\n\t\tif guess == @target_word\n\t\t\t@win = true\n\t\t\t@is_over = true\n\t\telse\n\t\t\tfalse\n\t\tend\n\tend", "def try_guess(guess)\n if !is_repeated_guess(guess)\n deduct_available_guesses\n add_to_previous_guesses(guess)\n end\n\n if guess.length > 1\n @secret_word == guess ? @is_over_won = true : false\n elsif guess.length > 0\n if @secret_word.include? guess\n update_current_state(guess)\n !is_word_complete() ? true : @is_over_won = true\n else\n false\n end\n else\n false\n end\n end", "def input_evaluation(guess, correct_word)\n if correct_word.word.include?(guess)\n # We learned that .each_with_index can be used to locate each letter corresponding with each spacific index\n # Then if the letter matches it will subsitue the \"_\", at the correct index, with the corresponding letter\n correct_word.word.each_with_index do |letter, index|\n if letter == guess\n correct_word.progress[index] = guess\n end\n end\n else\n # Storing wrong letters into an array and updating max_guesses\n correct_word.wrong_guesses << guess\n correct_word.max_guesses -= 3\n end\nend", "def current_word\n #for each char in the word, either fill it in if its guessed or replace with '_'\n my_word = \"\"\n word.each_char do |c|\n if guesses.include? c\n my_word << c\n else\n my_word << \"_\"\n end\n end\n my_word\n\n end", "def fill_correct_guess(guess)\n indexes = find_guess_position(guess)\n indexes.map do |index|\n @incomplete_word[index] = guess\n end\n end", "def check_word(guess)\r\n\r\n\t\tif @secret_word.include? (guess)\r\n\t\t\t@word_include = true \r\n\t\t\tif @word_include == true \r\n\t\t\t @secret_word.each_index do |idx|\r\n\t\t\t\t if @secret_word[idx] == guess \r\n\t\t\t\t\t @guess_word[idx] = guess \r\n\t\t\t\t\tend \r\n\t\t\t\tend\r\n\t\t\t\tanswer_update\r\n\t\t\t\tcheck_win \r\n \tend \t\t\r\n\t\telse \r\n\t\t\tfalse \r\n\t\t\t@num_guess -= 1 \r\n\t\t\tputs \"Wrong guess. Try again!\"\r\n\t\tend \r\n\tend", "def word_status\n\t\t@ans_word.length.times do\n\t\t\t@guess << \"_\"\n\t\tend\n\t\tputs \"Guesser, your secret word has #{@ans_word.length} characters: #{@guess*\"\"}\"\n\tend", "def make_guess(word)\n guess = word.upcase\n \n # If the game is over, let the player know.\n if @guesses_left == 0\n p \"This game is over!\"\n\n # Congratulatory message if they got it.\n elsif guess == @secret_word\n @number_of_guesses += 1\n p \"Congratulations! You got the word in #{@number_of_guesses} guesses!\"\n \n # If they already guessed the word:\n elsif @guessed_words.index(guess) != nil\n p \"You already guessed that word!\"\n p \"The secret word is: \" + feedback(guess)\n return \"You already guessed that word!\"\n\n # Count the guess and provide feedback on it.\n else\n\n @guessed_words.push(guess)\n @number_of_guesses += 1\n @guesses_left -= 1\n \n p \"Correct letters:\"\n p feedback(guess)\n\n # If that was the last guess, let the player know.\n if @guesses_left == 0\n p \"That was your last guess! Game over.\"\n\n else\n get_guesses_left\n \n end # control flow/guessed_word\n end # end control flow/make_guess\n end", "def add_to_guess\n @guess = @guess.map!.with_index do |character, index|\n @word.downcase[index] == @letter ? @word[index] : character\n end\n end", "def update_teaser(last_guess)\n new_teaser = @word_teaser.split\n\n new_teaser.each_with_index do |letter, index|\n if letter == '_' && @secret_word[index] == last_guess\n new_teaser[index] = last_guess\n end\n end\n\n @word_teaser = new_teaser.join(' ')\n end", "def reset\n @guessed = []\n @to_guess = get_word\n @guessing = Array.new(@to_guess.length, \"_\")\n @lives = 10\n end", "def check_guess(user_guess)\n\t\t@guess_count += 1\n\t\tletter_guessed(user_guess)\n\t\tif @answer_word.include?(user_guess)\n\t\t\tupdate_word(user_guess)\n\t\t\tputs \"-- RIGHT ON! #{user_guess} is in the word! Keep going! --\"\n\t\telse \n\t\t\tputs \"-- WRONG! That letter is not in the word! Try again: --\"\n\t\tend\n\t\t@guess_count\n\tend", "def guess(letter)\r\n letter = letter.downcase\r\n num = 0\r\n #iterate through word comparing guessed letter to letter's in the word\r\n @word_arr.each_index do |i| \r\n if @word_arr[i] == letter\r\n #if the letter matches update the game board in the equivalent spot\r\n @gameboard[i] = letter\r\n num += 1\r\n end\r\n end\r\n #add letter to guessed database, and lower amount of guesses by one\r\n @guessed_letters << letter\r\n @guesses -= 1\r\n return num\r\n end", "def guesses_history(alphabet,position)\n\t\tguessed_words[position] = alphabet\n\t\tguessed_words\n\tend", "def check_guess\n @guess_count += 1 # Increment guess count\n @guess_feedback = \"\"\n return true if @input == @current_word # Return true value if input is same as chosen word - correctly guessed word\n i = 0\n @input.split('').each do |letter| # Split user input and check if each letter is in exact position as chosen word, or if it is somewhere or not in the word at all\n # Use << to append to string as this is faster and doesn't create new string objects, as opposed to concatenation using a +\n # Below line uses nested ternary operators, where the condition is first evaluated and then if true, the first statement is executed, if false, the second statement is executed\n # This allows the code to be more readable and shorter\n @current_word.index(letter) == i ? (@guess_feedback << \"exact \") : (@current_word.index(letter).nil? ? (@guess_feedback << \"miss \") : (@guess_feedback << \"near \"))\n i += 1\n end\n puts @guess_feedback\n end", "def process_guess(letter)\n\n\t\tletter = letter.downcase\n\n\t\tif @prev_guesses.include? letter\n\t\t\tputs \"\\\"#{letter}\\\" has already been guessed\"\n\t\t\tprint_status\n\t\t\treturn false \n\t\telse\n\t\t\t@prev_guesses << letter\n\t\t\tdecrement_guesses\n\t\tend\n\n\t\tif @original_word.include? letter\n\t\t\tupdate_gameboard(letter)\n\t\t\tprint_status\n\t\t\ttrue\n\t\telse\n\t\t\tprint_status\n\t\t\tfalse\n\t\tend\n\tend", "def guess(word, guesses_left)\n @left.shift\n end", "def guess\n\t\tcollect_words_of_length\n\t\tputs \"Already guessed letters by computer: #{@guessed_letters}\"\n\t\t@guessing_letter = nil\n\t\twhile @guessing_letter == nil || invalid?(@guessing_letter)\n\t\t\t@guessing_letter = guessing_letter\n\t\tend\n\t\t@guessed_letters << @guessing_letter\n\t\t@guessing_letter\n\tend", "def update_feedback(guess)\n\t\tguess.split('').each do |guess_letter|\n\t\t\t@feedback.each do |target|\n\t\t\t\tif target[0] == guess_letter\n\t\t\t\t\ttarget[1] = true\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\tall_true_check = true\n\t\t@feedback.each do |x|\n\t\t\tif !x[1]\n\t\t\t\tall_true_check = false\n\t\t\tend\n\t\tend\n\t\tif all_true_check\n\t\t\t@win = true\n\t\t\t@is_over = true\n\t\tend\n\tend", "def game_play\n find_word\n board\n load_game?\n if @confirm != 'y'\n game_intro\n end \n until game_end? || @incorrect_guess == 8 \n #p @the_word\n guess\n incorrect_guess?\n hang_man_figure\n update_board\n save?\n end\n if game_end? != true\n puts \"\\n\" * 100\n hang_man_figure\n update_board\n puts \"SORRY, YOU LOST!!\" \n puts \"\\n\"\n puts \"The word was....#{@the_word.upcase}!!\"\n exit\n elsif game_end? == true\n puts \"\\n\" * 100\n hang_man_figure\n update_board\n puts \"OMG!\"\n puts \"#{@the_word.upcase} is the word!\"\n puts \"YOU WIN!!! =)\"\n puts \"******!*******!*****!*******!*****!*****!\"\n exit\n end\nend", "def guess\n puts \"Enter a letter\"\n puts\n letter = gets.chomp\n if @word_array.include?(letter)\n @word_array.each_with_index do |char, index|\n if char == letter\n @puzzle_array[index] = letter\n end\n end\n puts \"Correct!\"\n else\n puts \"Try again!\"\n end\n @counter -= 1\n end", "def guess(letter)\r\n\t\t\r\n\t\tif(@word.include?(letter))\r\n\t\t @good_guesses.add(letter)\r\n\t end\r\n\t\r\n\tend", "def new_game\n\t\t# Get the full list of words\n\t\twords = File.readlines('wordlist.txt')\n\t\tvalid_words = []\n\t\twords.each do |w| \n\t\t\t# Take all new lines and returns out\n\t\t\tw.gsub!(/\\r\\n/, \"\")\n\t\t\t# Word is valid if it's between 5 and 12 characters and isn't a proper noun. (no fair using names and such!) \n\t\t\tvalid_words << w if w.length.between?(5,12) && w[0] != w[0].upcase\n\t\tend\n\t\t# Split secret word into an array of letters\n\t\t@word = valid_words.sample.split(\"\").to_a\n\t\t# This holds user's guess. Originally populated with \"_\" for each letter\n\t\t@guess = \"\"\n\t\t@word.length.times { @guess += \"_\"}\n\t\t# Holds user's wrong letters. Originally populated with 9 x \"_\"\n\t\t@wrong_letters = \"\"\n\t\t9.times { @wrong_letters += \"_\"}\n\t\t@turn = 0\n\t\tputs \"Your task is to guess the secret word, letter by letter.\"\n\t\tputs \"You have only 9 wrong letters before you lose, so guess carefully!\"\n\t\tputs\n\t\tputs \"Here is your word. Each _ is a letter.\"\n\t\tputs\n\t\tget_guess\n\tend", "def setguessmatch(letter)\n\t\t@guess_count +=1\t\n\t\t@guessed_letters << letter\n\n\t\t@starting_word.each_with_index do |char,index|\n\t\t\tif char == letter\n\t\t\t\t@guessing_word[index] = char\n\t\t\t\tif starting_word == guessing_word\n\t\t\t\t\t@game_status = true\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend", "def set_guess\n @guess = Array.new(@word.length, '*')\n end", "def word_guess\n puts \"\\nYou want to guess the whole word.\"\n print \"Please enter what you think the word is: \"\n word_guess = gets.chomp.upcase\n\n if word_guess == @random_word\n line_of_30_stars\n @win = true\n else\n line_of_30_stars\n puts \"No sorry, #{word_guess} is not right...\"\n @failed_attempts += 1\n if @failed_attempts == 10\n @lose = true\n end\n end\n end", "def word_checker(user_guess)\n i = -1\n instances = []\n# Checks for the index of the first instance of user_guess AFTER index number i\n# Stops when @word.index(user_guess,i+1) returns nil\n while i = @word.index(user_guess,i+1)\n instances << i\n end\n\n# replace dashes in word display with the correctly guessed letters\n instances.each do |i| @word_display[i] = user_guess end\nend", "def current_word()\n current = $build_word.join(\" \") # return a string of placeholder underscores + correctly guessed letters\nend", "def guess_entire_word\n \n Welcoming.guess_hidden_word # shows a message asking if they would like to guess the entire word\n \n # Gets the players input and formats it (local varariable)\n\n \n # If the player slelected y than they are then prompted to enter the entire word. Their guess is then formatted\n\n # Gets the players input and formats it (local varariable)\n player_answer = STDIN.gets\n player_answer.chop!\n player_answer = player_answer.upcase\n @master_word.chop!\t\t# removes extra character on the master word\n # After the player inputs their guess, the guess is run through the next if statement. \n # This if tests if the players answer is equal to the master_word\n # if the player is correct than they win the game. if not they get an incorrect message\n if player_answer == @master_word\n puts(\"#{@master_word} is correct! Press Enter to continue.\\n\")\n \n $player_won_lost = 1 # This variable will be used in the main program to determine what the player will do\n else\n puts(\"Sorry thats incorrect. Press Enter to continue.\\n\") \n $player_won_lost = 2 # this variable is used in the main program and will let the player know they lost\n end\n\t \n\tConsole_Screen.pause_program\n\tConsole_Screen.cls\n\t \n \n end", "def setguessword\n\t\t@starting_word.each_index do |index|\n\t\t\t@guessing_word[index]=\"_ \"\n\t\tend\n\t\treturn @guessing_word\n\tend", "def current_state_setter\n\t\tputs \"Here is your mystery word: \"\n\t\tlength = @game_word.length.to_i\n\t\t@current_state = Array.new(length, \" _ \")\n\t\t@current_state.join\n\tend", "def guess!(letter)\n self.word.include? letter\n self.letter = letter\n end", "def guess(letter)\r\n\t\t@guessed << letter.downcase\r\n\t\t@word[0].each_index do |i| #Iterate through indexes instead of values\r\n\t\t\tif @word.dig(0,i) == letter #since @word is an array inside an array, dig helps us look in word ([0]) each index for the letter.\r\n\t\t\t\t@hidden_word[i] = letter #if found, substitute \"_\" for the letter guessed in the same index for @hidden_word\r\n\t\t\tend\r\n\t\tend\r\n\t\tp @hidden_word #give feedback of results\r\n\tend", "def guessed_wrong_letter()\n if $hidden_word_arr.exclude?($input)\n $guessed.append($input)\n end\n end", "def track_progress(word, guess, correct_guess, progress_message)\n \n if @correct_guess == true\n\n @index_of_correct_letter = word.index(guess)\n\n @inserted_prog_msg = @progress_message.insert(@index_of_correct_letter, guess)\n\n @inserted_prog_msg.slice!(@index_of_correct_letter + 1)\n\n @new_progress_message = @inserted_prog_msg\n\n puts \"Correct! The secret word is #{@new_progress_message}\"\n @new_progress_message\n\n else puts \"Incorrect! Guess again, the secret word is #{@new_progress_message}\"\n @new_progress_message\n end\nend", "def process_guess(guess)\n\t\t\tunless @secret.include? guess\n\t\t\t\tputs \"Bad guess...\"\n\t\t\t\t@bad_guesses << guess\n\t\t\t\t@guesses -= 1\n\t\t\t\t@drawing[@bad_guess_count+1] = @drawing_animation[@bad_guess_count]\n\t\t\t\t@bad_guess_count += 1\n\t\t\tend\n\n\t\t\twhile @secret.include? guess\n\t\t\t\t@fill_in_word[@secret.index(guess) * 2] = guess\n\t\t\t\t@secret[@secret.index guess] = \" \"\n\t\t\tend\n\t\tend", "def game_play\n self.new_round # Start new round\n loop do\n puts \"Your Guess:\"\n @input = gets.chomp # Gets user input by making a prompt and capturing the input, chomp method removes the new line which would otherwise be stored in the input string\n if @input != \"/\"\n if @@word.legal?(@input)\n if self.check_guess\n puts \"Correct! You got the answer in #{@guess_count} guesses!\" # Use string interpolation instead of concatenating to include guess count\n\n self.new_round\n puts @current_word\n end\n puts \"You have #{MAX_GUESS - @guess_count} guesses remaining.\\n?????\" # Calculations can be made in string interpolation too\n else\n puts \"That guess doesn't count! Your guess can only be 5 characters in length, contain no duplicate letters and only contain letters.\" # Guess isn't a legal word\n end\n self.check_lost # Check if player has exhausted amount of guesses\n else\n exit\n end\n\t\tend\n\tend", "def round\n response = nil\n black_list = []\n pat = next_word.downcase\n\n words_dict = words_of_length pat.length\n while true\n g, words_dict = freq_of_pat words_dict, black_list, pat\n if g == nil\n puts \"Word Not KNOWN\"\n WORDS << \"#\"\n break\n\n elsif g == \"GIVEUP1\"\n puts \"GIVE UP\"\n WORDS << \"&1\"\n break\n\n elsif g == \"GIVEUP2\"\n puts \"GIVE UP\"\n WORDS << \"&2\"\n break\n end\n\n black_list << g\n\n puts \"The #{black_list.length}th guess letter is #{g.upcase}\"\n puts \"black_list is #{black_list.to_s}, length: #{black_list.length}\"if V\n\n response = guess_word g\n pat = response[\"word\"].downcase\n puts \"#{pat}\"\n\n unless pat.include? '*'\n WORDS << pat\n puts \"GOT IT\"\n break\n end\n ## the numberOfGuessAllowedForThisWord received from server is not correct!!\n if response[\"data\"][\"numberOfGuessAllowedForThisWord\"] == 0\n WORDS << pat\n break\n end\n\n if black_list.length == NUM_GUESSES\n WORDS << pat\n puts \"WRONG, NEXT ROUND\"\n break\n end\n end\n\n num_of_round = response[\"data\"][\"numberOfWordsTried\"]\n num_of_round\nend", "def guess_letter(letter)\n\t\tif @ans_word.include?(letter)\n\t\t\ti = @ans_word.index(letter)\n\t\t\t@guess.insert(i, letter)\n\t\t\t@guess.pop\n\t\t\tputs \"Good! You are getting closer: #{@guess*\"\"}\"\n\t\telse\n\t\t\tputs \"sorry, guess again\"\n\t\tend\n\tend", "def guess?(letter)\n if !self_is_letter?(letter)\n puts \"Not a letter!\"\n return false\n end\n if @word.include? letter\n if(@word.count(letter) > 1)\n while(@word.include? letter)\n puts \"Hit this while loop\"\n index = @word.index(letter)\n @word.slice!(index,0)\n @word[index] = '_'\n\n puts \"Word\" + @word\n @guessedWord.slice!(index,0)\n @guessedWord[index] = letter\n\n end\n else\n index = @word.index(letter)\n\n @guessedWord.slice!(index,0)\n @guessedWord[index] = letter\n\n\n\n end\n\n\n output_word()\n return true\n end\n p \"Word does not contain #{letter}\"\n @health -= 1\n p \"you have #{@health} tries left\"\n return false\n end", "def guessed_word()\r\n\t\tresult = ''\r\n\r\n\t\t# TODO: fill in method body\r\n\t\t\r\n\t\treturn result\r\n\tend", "def updateWord(word)\n\n\t\tword = remove_punctuation(word)\n\n\t\t# If we have an entry then increment its count\n\t\tif @a.has_key?(word)\n\t\t\t@a[word] += 1\n\t\telse \n\t\t\t@a[word] = 1\n\t\tend\n\n\n\t\tcount = @a[word]\n\t\tdeleteWord(word, count)\n\t\taddWord(word, count)\n\tend", "def guess(letter)\n # STEP 1: check to make sure the letter is not any non-letter character and\n # raises an error if it is\n if /^[a-zA-Z]+$/.match(letter)\n letter.downcase!\n else raise_error(\"Invalid letter\")\n end\n\n # STEP 2: check to make sure the user does not guess the same letter more\n # than once\n if @guesses.include? letter; return false; end\n if @wrong_guesses.include? letter; return false; end\n\n # STEP 3: check to see if the guessed letter matches any letters in the \n # word\n if @word.include? letter\n @guesses += letter\n # if there is a match, update the word_with_guesses to show where\n # in the string the letter was matched\n @word.each_char.with_index do |c, i|\n if c == letter\n @word_with_guesses[i] = c\n end\n end \n else \n @wrong_guesses += letter\n @attempts += 1\n end\n # update the number of attempts and call the function to check if\n # the user won, lost, or continues playing\n check_win_or_lose\n end", "def guess_char=(char)\n # First want to check if a character is in the word and has not been guessed\n # beforhand\n if @word.include?(char) && !@guess_history.include?(char)\n # defining an array of indices of the word string that tells us the\n # position of where the character matches the character of the word\n char_index = (0 ... @word.length).find_all { |i| @word[i,1] == char}\n # loop through the character index array to redefine the prompt with the \n # correctly guessed character\n char_index.each{|elment| @prompt[elment] = char}\n @guess_history << char # Store the guess in the guess history\n @is_correct = false # the guess is not correct because the user hasn't\n # guessed the whole word\n @guess_count -= 1 # loose an attempt to guess the word\n\n # next we want to check if the guess has been guessed before\n elsif @guess_history.include?(char)\n @is_correct = false # guess is not correct because the user hasn't guessed\n # the whole word\n # note the counter will not be increased if it matches guess history\n # For all other incorrect guesses do the following:\n else\n @guess_history << char # store char in the guess history\n @is_correct = false # the guess is incorrect\n @guess_count -= 1 # loose an attempt to guess the word\n end\n end", "def initialize\n\t\t@word = [\"buffalo\", \"llama\", \"kangaroo\", \"elephant\", \"aardvark\", \"orangutan\", \"hyena\"]\n\t\t@current_state = []\n\t\t@guess_array = []\n\tend", "def make_guess(guess)\n @guesses_made << guess\n @guesses_made.sort!\n guess_list = Hash.new\t\t\n\n @active_list.each do |word|\n format = @pattern.dup\n @word_size.times{ |index| format[index] = guess if word[index] == guess }\n\n guess_list[format] = String.new if guess_list[format] == nil\n guess_list[format] << word\n guess_list[format] << ','\n end\n\n guess_list = guess_list.sort\n\n biggest = String.new\n second_biggest = String.new\n biggest_size = -1\n second_biggest_size = -1\n hold_list = Hash.new\n guess_list.each do |key, value|\n hold_list[key] = value.split(',')\t\n if biggest_size < hold_list.fetch(key).size\n biggest = key\n biggest_size = hold_list.fetch(key).size\n elsif biggest_size == hold_list.fetch(key).size\n first_reveal = 0\n second_reveal = 0\n @word_size.times do |index|\n first_reveal += 1 if biggest[index] == guess\t\t\t\t\t\n second_reveal += 1 if key[index] == guess\n end\n biggest = key if first_reveal > second_reveal\n end\n\n\n if second_biggest_size < hold_list.fetch(key).size && key != biggest \n second_biggest = key\n second_biggest_size = hold_list.fetch(key).size\n elsif biggest_size == hold_list.fetch(key).size && key != biggest\n first_reveal = 0\n second_reveal = 0\n @word_size.times do |index|\n first_reveal += 1 if second_biggest[index]== guess\t\t\t\t\t\n second_reveal += 1 if key[index] == guess\n end\n second_biggest = key if first_reveal > second_reveal\t\n end\n end\n\n output = Hash.new\n hold_list.each{ |key, value| output[key] = value.size }\n\n\n biggest = second_biggest if @diff_timer == 0 && second_biggest != String.new\n\t\t\t\n @active_list = hold_list.fetch(biggest)\n\n biggest == @pattern ? @guesses_left -= 1 : @pattern = biggest\n \n\n @diff_timer = @timer_max if @diff_timer == 0\n\t\t\t\n @diff_timer -= 1\n\t\t\n output\n end", "def initialize(win_word)\r\n\t# Set winning word\r\n\t\t@win_word = win_word\r\n\t# Initialize remaining guesses to win_word length plus 5\r\n\t\t@remaining_guesses = win_word.length + 5\r\n\t# Initialize array to store past guesses to check for repeats\r\n\t\t@past_guesses = []\r\n\t# Initialize string to represent current state of word, or, hint\r\n\t\thint = \"\"\r\n\t\thint_length = win_word.length\r\n\t\thint_length.times { hint = hint + \"_ \" }\r\n\t\t@hint = hint\r\n\t\tputs \"Ok! User 2 please take over.\"\r\n\t\tputs \"Guess the word!\"\r\n\t\tputs \"Here's a hint: #{@hint}\"\r\n\tend", "def whole_word_guess(input,dead_man)\n guessed_word_array = input.split(//)\n if guessed_word_array == @correct_word_array\n win\n else\n puts \"The word you have guessed is incorrect!\"\n dead_man.wrong_guesses += 1\n display(dead_man) \n end\n end", "def print_current_status\n print_guess_word_status = \"\"\n @guess_word_status.each do |letter|\n print_guess_word_status += \"#{letter} \"\n end\n puts \"\\nYou guessed #{@failed_attempts} times wrong so far. Remember, when reaching 10 you lose!\"\n puts \"Guess word status = #{print_guess_word_status}\"\n end", "def initialize()\n @word = get_random_word\n @guesses = ''\n @wrong_guesses = ''\n end", "def make_guess\n puts \"Make a guess:\"\n @current_guess = gets.chomp\n unless good_guess?\n puts \"That is an invalid guess, please try again!\"\n @current_guess = gets.chomp\n end\n puts\n guesses << current_guess unless current_guess == \"save\" || current_guess == secret_word\n end", "def guess(letter)\r\n letter = letter.downcase\r\n #find the guess\r\n returnValue = @word.count(letter) \r\n case returnValue\r\n when 0\r\n #Meaning this was an invalid guess\r\n @count-=1\r\n #maybe for debugging purposes\r\n @guessedFalse << letter\r\n else\r\n #maybe for debugging purposes\r\n @guessedTrue << letter\r\n #get all index of a matching letter\r\n arryOfMatchesIndexs = (0 ... @word.length).find_all { |i| @word[i,1] == letter }\r\n #iterate through the matches and replace the shadow word\r\n arryOfMatchesIndexs.each { |x| \r\n @shadowWord[x] = letter \r\n }\r\n \r\n #if the shadowWord array does not have any underscroes then we win \r\n if (@shadowWord.index(\"_\")).nil? \r\n @win = true\r\n end\r\n end\r\n #return the value of found\r\n returnValue\r\n end", "def guess_hidden_word\n puts (\"Enter your guess: \")\n end", "def initialize word \n @word = word\n @guesses = ''\n @wrong_guesses = ''\n end", "def guess(letter_guessed)\r\n# \ti. Run loop to see if the letter has been guessed yet.\r\n\tif word_split.include? (letter_guessed)\r\n\t\t# a. Iterate through the word characters to see if it includes the letter guessed\r\n\t\t@word_split.each_with_index do |char, index|\r\n\t\t\tif word_split[index] == letter_guessed\r\n\t\t\t\t@guessed[index] = letter_guessed\r\n\t\t\tend #if\r\n\t\tend #do\r\n\t\t# b. If it is right then put you have guessed a letter and then ask for another guess repeat method\r\n\t\tputs \"You guessed correctly. Enter another guess\"\r\n# \t\tc. If it is wrong then put you have guessed wrong and ask for another guess. Maybe return how many guesses you have left?\r\n\telse\r\n\t\t@guess_count +=1\r\n\t\tputs \"You guessed incorrectly. Enter another guess\"\r\n\tend#if\r\nend", "def presence_of_letter(user_guess)\n\t\tif @game_word.include? user_guess \n\t\t\tputs \"Nice! Your letter appears #{@presence_counter} times. Here is an update on your progress: \"\n\t\t\tp @current_state.join\n\t\t\t# return @current_state.join\n\t\telse\n\t\t\tputs \"Too bad! \\\"#{user_guess}\\\" is not in the mystery word! Here is your progress so far: \"\n\t\t\tp @current_state.join\n\t\t\t# return \"Too bad!\"\n\t\tend\n\n\t\tif @current_state.include?(\" _ \" )\n\t\t\tputs \"You have #{@total_guesses} guesses remaining.\"\n\t\tend\n\tend", "def check_guess guess\r\n\t\t\t\t @resultb.push(guess)\r\n\t\t\t\t phrase = @secretword.chars\r\n\t\t\t\t i = 0\r\n\t\t\t\t @num_guessed = 0\r\n\t\t\t\t while i < phrase.length do\r\n\t\t\t\t\t\t\t\tif phrase[i] == guess\r\n\t\t\t\t\t\t\t\t @resulta[i] = guess\r\n\t\t\t\t\t\t\t\t @num_guessed += 1\r\n\t\t\t\t\t\t\t\tend\r\n\t\t\t\t\t\t\t\ti += 1\r\n\t\t\t\t end\r\n\t\t\t\t\t\t\t\tif @num_guessed > 0\r\n\t\t\t\t\t\t\t\t@score += (@reward.to_i * @num_guessed)\r\n\t\t\t\t\t\t\t else\r\n\t\t\t\t\t\t\t incrementturn\r\n\t\t\t\t\t\t\t\tend\r\n\t\t end", "def reset\n @lives = 7\n @letter = ''\n @bank = []\n @guess = []\n @word = ''\n set_word\n set_guess\n end", "def begin_guessing\r\n\t while @turn_count > 0 do\r\n\t puts \"\\nPlease enter 'guess' if you would like to guess the word. Otherwise, please enter a single letter guess.\"\r\n\t guess_input = gets.chomp\r\n\t\t\r\n\t\t# Handles the case if the user wants to guess the word\r\n\t\tif guess_input.downcase == \"guess\"\r\n\t\t puts \"\\nPlease enter your guess.\"\r\n\t\t full_guess = gets.chomp\r\n\t\t full_guess.downcase!\r\n\t\t if full_guess == @secret_word \r\n\t\t win_game \r\n\t\t else \r\n\t\t @turn_count -= 1\r\n\t\t puts \"\\nIncorrect guess.\"\r\n\t\t\tend_turn\r\n\t\t end\r\n\t\t \r\n\t\t# Handles the case if the user wants to guess a letter\r\n\t\telse\r\n\t guess_letter = guess_input[0].downcase\r\n\t game_board(guess_letter)\r\n\t\tend\r\n\t end\r\n\t lose_game if @turn_count == 0\r\n\tend", "def turn_taken(guess, phrase)\n if guess.nil?\n @incorrect_guesses << \"[nil]\"\n elsif !guess.respond_to?(:downcase)\n @incorrect_guesses << \"[invalid]\"\n elsif guess.empty?\n @incorrect_guesses << \"[empty]\"\n else\n guess = guess.downcase.strip.gsub(/ /, \"/\")\n\n if guess.size > 1 && guess.size < phrase.size\n # This is a word guess, do not allow part of a word guesses\n words = phrase.split(\"/\")\n matching_words = words.select {|w| w == guess}\n if matching_words.size == 0\n @incorrect_guesses << guess\n return\n end\n end\n \n matches = phrase.all_indices(guess)\n \n if matches.empty? || @correct_guesses.index(guess) != nil # No matches or a repeated correct guess\n @incorrect_guesses << guess\n else\n @correct_guesses << guess\n \n matches.each do |i|\n x = 0\n guess.each_char do |c|\n @current_pattern[i + x] = c\n x = x + 1\n end\n end\n \n @found_phrase = @current_pattern.index(\"_\") == nil\n end\n end\n end", "def draw_board #Draws the blanks and correctly guessed letters\n\t$winning_word.each_with_index do |letter, index|\n\t\tif $current[index] == nil\n\t\t\t$current[index] = \"_\"\n\t\telse\n\t\t\t$current[index]\n\t\tend\n\tend\n\tputs $current.join(\" \")\n\tputs \"Previously incorrect guesses: #{$already_guessed}\"\nend", "def initialize(secret_word)\n puts \"Initializing game for new secret word...\"\n @secret_word = secret_word\n @current_state = \"\"\n secret_word.length.times { @current_state << \"_\" }\n @prev_guesses = []\n @available_guesses = secret_word.length\n @is_over_won = false\n end", "def play_new_game\n #get new code word\n @word_master.choose_code_word\n @code_word = @word_master.code_word\n @good_guesses = Array.new(@code_word.length, '_ ')\n #tells you rules\n puts \"Try to figure out the word. If you guess 6 wrong letters, you lose!\"\n #starts playing\n game_loop\n end", "def check_guess(letter)\n\t\t# If the guessed letter is in the word, replace \"_\" in the guess variable with the letter in the right spot\n\t\t@word.each_with_index do |l, i|\n\t\t\tif l == letter\n\t\t\t\t@guess[i] = letter\n\t\t\tend\n\t\tend\n\t\t# If the guessed word and the answer are the same, the user won!\n\t\t# Show message and if the game was previously saved, delete it\n\t\tif @word.join == @guess\n\t\t\tputs \n\t\t\tshow_board\n\t\t\tputs \"You won!!\"\n\t\t\tif @running_saved_game != nil\n\t\t\t\tover_write_data\n\t\t\tend\n\t\t\tgo_again\n\t\t# Got a letter but didn't win. Get another guess\n\t\telsif @word.include?(letter)\n\t\t\tputs\n\t\t\tputs \"You got a letter!\"\n\t\t\tget_guess\n\t\t# Letter wasn't in word, put letter in missed letter variable and guess again\n\t\telse\n\t\t\tputs \n\t\t\tputs \"No #{letter}'s.\"\n\t\t\t@wrong_letters.sub!(\"_\", letter)\n\t\t\t@turn += 1\n\t\t\tget_guess\n\t\tend\n\tend", "def restart_loop\n new_last_word_index = @words.keys.sort.last\n if new_last_word_index.nil?\n @i_last_real_word = 0 \n @i = 0\n else\n @i_last_real_word = new_last_word_index\n @i = @i_last_real_word\n end\n end", "def restart_loop\n new_last_word_index = @words.keys.sort.last\n if new_last_word_index.nil?\n @i_last_real_word = 0 \n @i = 0\n else\n @i_last_real_word = new_last_word_index\n @i = @i_last_real_word\n end\n end", "def guess(letter)\r\n if word_has?(letter)\r\n \tput_letter_on_board(letter)\r\n else\r\n wrong_letter(letter) if !@guesses.include? letter\r\n end\r\n end", "def word_test()\n if $build_word.join == $word # if $build_word equals $word, the user won\n $game_over = true # set the flag to indicate that the game is over\n $game_won = true # set the flag to indicate that the player won the game\n $games_won += 1 # so increase the games_won score by 1\n else # if they don't match, run user_input() for another letter\n $prompt = \"Good job - that letter was in the word. Please guess again!\"\n end\nend", "def guess_badly(guess)\n @remaining_guesses -= 1\n @current_index += 1\n @bad_guesses << guess\n end", "def update_guess_count\n @guess_count > 0 ? @guess_count -= 1 : @guess_count\n end", "def initialize()\n @word = ''\n @guesses = ''\n @wrong_guesses = ''\n end", "def letter_guess\n letter = get_letter_player()\n check_letter_in_random_word(@guess_letter)\n if @correct_guess == false\n @failed_attempts += 1\n if @failed_attempts == 10\n @lose = true\n end\n end\n guess_word_status_string = @guess_word_status.join()\n if guess_word_status_string == @random_word\n @win = true\n end\n end", "def use_guess\n @guesses -= 1\n end", "def initialize(word)\n # This is just some a printout of the game at initialization\n puts \"\n POORMAN's\n ___ ___ ____ ____ __ ____ ___ ___ _____ ____ __\n / / / / / _ | | \\\\ | | / ___\\\\ | \\\\ / | | _ \\\\ \\\\ \\\\_ \\\\ \\ \n / /__/ / / /_| | | |\\\\ \\\\| | | | ___ | |\\\\ \\\\ / /| | | |_\\\\ \\\\ \\\\ \\\\ \\\\ \\\\\n / ___ / / ___ | | | \\\\ | | |__| | | | \\\\ \\\\/ / | | | ___ \\\\ \\\\ \\\\\\\\ \\\\_\\\\ \\\\ \n /__/ /__/ /__/ |_| |_| \\\\__| \\\\____/ |_| \\\\__/ |_| |_| \\\\__\\\\ |_| \\_____|\n \n \"\n\n # instance variables for HangMan Class\n @word = word\n\n ## LOGIC: This is to set the number of guesses based on the length of the word\n if @word.length >= 12\n @guess_count = 9\n elsif @word.length >= 10 && @word.length < 12\n @guess_count = 8\n elsif @word.length >= 8 && @word.length < 10\n @guess_count = 7\n elsif @word.length >= 6 && @word.length < 8\n @guess_count = 6\n else\n @guess_count = 5\n end\n ## End of Logic\n\n @is_correct = false # Flag to see if the guess is correct\n # Nifty code to set a prompt variable with a bunch if underscores\n # Note the length of the underscores matches the length of the word\n @prompt = String.new(str=\"_\") * word.length\n @guess_history = Array.new # A guess history array to store guesses\n end", "def running(turn, time_to_guess, last_guess, last_word, last_feedback)\n system('cls')\n puts '***************************************************************'\n puts '* Word Mastermind *'\n puts '***************************************************************'\n puts '* Turn Number: ' + turn.to_s + ' Turns To Guess: '+time_to_guess.to_s+' *'\n puts '***************************************************************'\n puts ''\n puts ' REMEMBER: Your Word can only have 5 letters, and can only'\n puts ' contain one of each character!'\n puts ''\n puts '|X| = Not in word |O| = In the word and the correct place'\n puts '|-| = In the word but in the incorrect place '\n puts ''\n puts ' Your Last Guess Was: ' + last_word\n puts ''\n puts ' ' + \"#{last_guess}\"\n puts ' ' + \"#{last_feedback}\"\n puts ''\n puts ''\n puts 'What will you guess this turn?'\n puts ''\n print 'Guess: '\n end", "def get_guess\n\t\t# There are turns left...\n\t\tif @turn < 9\n\t\t\tshow_board\n\t\t\tputs \"Enter your letter guess...\"\n\t\t\tletter = gets.chomp.downcase\n\t\t\tvalidate_letter(letter)\n\t\t# No turns left, show losing message and delete game if it was previously saved\n\t\telse\n\t\t\tputs\n\t\t\tshow_board\n\t\t\tputs \"Dangit, you ran out of turns!\"\n\t\t\tputs \"The word was #{@word.join}...\"\n\t\t\tif @running_saved_game != nil\n\t\t\t\tover_write_data\n\t\t\tend\n\t\t\tgo_again\n\t\tend\n\tend", "def win\n puts \"\\n\"\n @letters_guessed_array = @correct_word_array\n puts @letters_guessed_array.join(\" \")\n puts \"\\n\"\n puts \"You have guess the whole word correctly! You have saved\"\n puts \"this man from a hanging!\"\n end", "def check_letter(guess)\n if @word.include? guess\n puts \"You chose wisely!\"\n #find which position(s) the guess is in the word array\n correct_index_arr = @word.each_index.select { |i| @word[i] == guess }\n # rebuild @game_status with the correct letter guessed into that position of the word\n correct_index_arr.each do |index|\n @game_status[index] = guess\n end\n # if they don't make guess and put an empty response\n elsif guess.empty?\n puts \"You didn't make a guess. Try again.\"\n # if the user guesses the same wrong letter again\n elsif @wrong_guesses.include? guess\n puts \"You guessed that before! Try again.\"\n else\n @guesses_remaining -= 1\n puts \"wrong guess, the guesses remaining: #{@guesses_remaining}\"\n @wrong_guesses.push(guess)\n end\n end", "def hack(words)\n candidates = words.clone\n word_to_guess = candidates.pop\n\n while !candidates.empty?\n puts \"Try the word: #{word_to_guess}\"\n puts \"What was the likeness?\"\n\n key_likeness = gets.to_i\n if key_likeness == word_to_guess.length\n puts \"Nicee hackeeer!!\"\n break\n end\n\n words.each do |word|\n next if !candidates.include?(word)\n\n likeness = get_likeness(word_to_guess, word)\n\n if key_likeness == 0\n candidates -= [word] if likeness > 0\n else\n candidates -= [word] if likeness < key_likeness\n end\n end\n\n puts \"Candidates left: #{candidates.join(', ')}\"\n word_to_guess = candidates.pop\n end\nend", "def check_guess\n\t\t@word.include?(@guess)\n\n\tend", "def get_current_state_of_word()\r\n\r\n wordString = \"\"\r\n\r\n for i in 0..@secretWordLength-1 do\r\n\r\n key = @secretWord[i]\r\n\r\n if @lettersGuessed[key] == true \r\n wordString += key\r\n elsif @lettersGuessed[key] == false\r\n wordString += \"_ \" \r\n end\r\n\r\n end\r\n\r\n return wordString\r\n end" ]
[ "0.7802108", "0.77900094", "0.74261653", "0.7343291", "0.7308614", "0.6945857", "0.6909196", "0.69077325", "0.6874585", "0.68211114", "0.6700159", "0.6661162", "0.657755", "0.6571838", "0.6571573", "0.64858186", "0.64727396", "0.64715916", "0.646832", "0.64497477", "0.6428058", "0.6417236", "0.6409747", "0.6404387", "0.63946164", "0.63867974", "0.63774616", "0.6366766", "0.63330805", "0.6322178", "0.6291101", "0.6272948", "0.6250382", "0.62429404", "0.6232973", "0.620904", "0.62018067", "0.6198445", "0.616863", "0.6168524", "0.6157525", "0.614804", "0.6119489", "0.61186886", "0.61152667", "0.61027515", "0.6098847", "0.6094905", "0.6092133", "0.60915375", "0.60874194", "0.60808104", "0.60518646", "0.6048186", "0.6042794", "0.6030507", "0.60217303", "0.60054785", "0.6004353", "0.6003146", "0.59941876", "0.5992492", "0.59914976", "0.5990141", "0.59799", "0.59776324", "0.5977297", "0.5974172", "0.59653044", "0.5961056", "0.59538966", "0.5950491", "0.59478056", "0.59475785", "0.5928812", "0.5924776", "0.5924293", "0.5924083", "0.5917165", "0.5916418", "0.59157944", "0.5909631", "0.5907914", "0.5907773", "0.5907773", "0.5899559", "0.58985406", "0.5891547", "0.5887798", "0.587929", "0.5875985", "0.587149", "0.58705896", "0.58678967", "0.5862096", "0.586173", "0.58536845", "0.58511835", "0.5846568", "0.5836956" ]
0.77347606
2
a simple filter to keep web crawlers from triggering this needlessly
def check_magic_token params[:magic_token] == Rails.application.secrets.salesforce_magic_token end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def global_filter; end", "def filter_redirect; end", "def filter_redirect; end", "def unfiltered_content; end", "def unfiltered_content; end", "def unfiltered_content; end", "def filter_cache; end", "def _filters_halted() \"<html><body><h1>Filter Chain Halted!</h1></body></html>\" end", "def before_filter; end", "def strict_filters; end", "def filter_response(response, request)\n # nothing to do\n end", "def filter_redirect=(_arg0); end", "def filter_redirect=(_arg0); end", "def after_filter; end", "def consider_all_requests_local; end", "def consider_all_requests_local; end", "def filter\n super\n end", "def exclude_from_xss_checks; %w{ body html } end", "def url_whitelist; end", "def quick_and_dirty_url_filter(url)\n url && (url !~ /\\.(css|js|htm(l?)|jpg|gif|zip|jnlp)$/) && (url !~ /^#/)\n end", "def filter\n\tfilter_disabled\n\tfilter_repeated\n\tfilter_silenced\n\tfilter_dependencies\n end", "def filter; end", "def filter; end", "def filter; end", "def apply_filter\n end", "def skip_html_injection=(_arg0); end", "def filter!; end", "def consider_all_requests_local=(_arg0); end", "def consider_all_requests_local=(_arg0); end", "def autofilter\n true\n end", "def on_ignored_request\n end", "def test_default_filterchain\n chain = UrlFilters::FilterChain.new(RDig.filter_chain[:http])\n assert_nil chain.apply(Document.create(\"http://www.example.com/affe.htm\"))\n assert_not_nil chain.apply(Document.create(\"http://localhost:3000/affe.html\"))\n assert_nil chain.apply(Document.create(\"http://localhost.com/affe.html\"))\n end", "def consume_bad_url; end", "def filter\n end", "def url_whitelist=(_arg0); end", "def noreferrer?; end", "def conditional_requests; end", "def conditional_requests; end", "def halted_callback_hook(filter, _); end", "def filter_argument; end", "def crawl\n while NG_URL.where(:a_hrefs_unprocessed => { :$not => { :$size => 0}}).count > 0 do\n next_unprocessed_url\n end\n end", "def site_cleaner; end", "def weber; end", "def test_filterchain\n cfg = [\n { UrlFilters::UrlInclusionFilter => /.+html$/ },\n { :hostname_filter => 'test.host' }\n ]\n chain = UrlFilters::FilterChain.new(cfg)\n\n assert_nil chain.apply(Document.create(\"http://test.host/affe.htm\"))\n assert_not_nil chain.apply(Document.create(\"http://test.host/affe.html\"))\n assert_nil chain.apply(Document.create(\"http://test.host.com/affe.html\"))\n end", "def autofilter\r\n\t\tfalse\r\n\tend", "def autofilter\r\n\t\tfalse\r\n\tend", "def autofilter\r\n\t\tfalse\r\n\tend", "def autofilter\r\n\t\tfalse\r\n\tend", "def add_filter\n @filter = true \n end", "def entry_filter; end", "def on_pre_request( request ); end", "def initialize_url_filters\n # We use a hash which tells the domains to filter.\n # The hash value tells that if company name contains that string then don't filter\n @url_filter = Hash.new\n @url_filter[\"facebook.com\"] = \"facebook\"\n @url_filter[\"linkedin.com\"] = \"linkedin\"\n @url_filter[\"wikipedia.org\"] = \"wikipedia\"\n @url_filter[\"yahoo.com\"] = \"yahoo\"\n @url_filter[\"zdnet.com\"] = \"zdnet\"\n @url_filter[\"yelp.com\"] = \"yelp\"\n @url_filter[\"yellowpages.com\"] = \"yellowpages\"\n @url_filter[\"thefreelibrary.com\"] = \"thefreelibrary\"\n @url_filter[\"thefreedictionary.com\"] = \"thefreedictionary\"\n @url_filter[\"superpages.com\"] = \"superpages\"\n @url_filter[\"businessweek.com\"] = \"week\"\n @url_filter[\"indiamart.com\"] = \"mart\"\n @url_filter[\"naukri.com\"] = \"naukri\"\n @url_filter[\"monsterindia.com\"] = \"monster\"\n @url_filter[\"answers.com\"] = \"answers\"\n @url_filter[\"sulekha.com\"] = \"sulekha\"\n @url_filter[\"asklaila.com\"] = \"asklaila\"\n @url_filter[\"blogspot.com\"] = \"blogspot\"\n @url_filter[\"manta.com\"] = \"manta\"\n @url_filter[\"zoominfo.com\"] = \"zoom\"\n @url_filter[\"twitter.com\"] = \"twitter\"\n @url_filter[\"hotfrog.com\"] = \"hotfrog\"\n @url_filter[\"amazon.com\"] = \"amazon\"\n end", "def filter_rspamd\n end", "def register_filter(mod); end", "def filters; end", "def filters; end", "def filter\n doc = @mode == :xml ? Hpricot.XML(@str) : Hpricot(@str)\n attr_rgxp = %r/\\[@(\\w+)\\]$/o\n path_to_root = \"\"\n path_parts = @page.destination.split('/') - SITE.output_dir.split('/')\n (path_parts.length - 1).times { path_to_root += \"../\" }\n Webby.site.xpaths.each do |xpath|\n @attr_name = nil\n doc.search(xpath).each do |element|\n @attr_name ||= attr_rgxp.match(xpath)[1]\n a = element.get_attribute(@attr_name)\n if a[0..0] == '/' # Only 'fix' absolute URIs\n new_uri = path_to_root + a[1..-1]\n # puts \"Updating URI: #{a}\"\n # puts \" to: #{new_uri}\"\n element.set_attribute(@attr_name, new_uri)\n end\n end\n end\n \n doc.to_html\n end", "def filtered_url\n @@ported_url.sub(/:[^:@@]+@@/, ':FILTERED@@')\n end", "def named_filter; end", "def content_security_policy_report_only; end", "def content_security_policy_report_only; end", "def strict_filters=(_arg0); end", "def process_site(site); end", "def global_filter=(_arg0); end", "def protect_html html\n raise \"Must override Filter#protect_html\"\n end", "def crawl_delay(url); end", "def ignore_urls\n @url_rules.reject\n end", "def content_security_policy_report_only=(_arg0); end", "def content_security_policy_report_only=(_arg0); end", "def whitelist; end", "def filter\n doc = @mode == :xml ? Hpricot.XML(@str) : Hpricot(@str)\n base_path = ::Webby.site.base\n attr_rgxp = %r/\\[@(\\w+)\\]$/o\n sub_rgxp = %r/\\A(?=\\/)/o\n\n ::Webby.site.xpaths.each do |xpath|\n @attr_name = nil\n\n doc.search(xpath).each do |element|\n @attr_name ||= attr_rgxp.match(xpath)[1]\n a = element.get_attribute(@attr_name)\n element.set_attribute(@attr_name, a) if a.sub!(sub_rgxp, base_path)\n end\n end\n\n doc.to_html\n end", "def filters_halted\n end", "def test_filterchain_config\n RDig.configuration do |conf|\n conf.crawler.include_patterns = /.+html$/\n conf.crawler.include_hosts = 'test.host'\n end\n cfg = [\n { UrlFilters::UrlInclusionFilter => :include_patterns },\n { :hostname_filter => :include_hosts }\n ]\n chain = UrlFilters::FilterChain.new(cfg)\n\n assert_nil chain.apply(Document.create(\"http://test.host/affe.htm\"))\n assert_not_nil chain.apply(Document.create(\"http://test.host/affe.html\"))\n assert_nil chain.apply(Document.create(\"http://test.host.com/affe.html\"))\n end", "def conditional_requests=(_arg0); end", "def filter_content \n\t\tself.title = ActionView::Base.full_sanitizer.sanitize(self.title)\n\t\tself.slug = ActionView::Base.full_sanitizer.sanitize(self.slug)\n\t\tself.meta_title = ActionView::Base.full_sanitizer.sanitize(self.meta_title)\n\t\tself.meta_keyword = ActionView::Base.full_sanitizer.sanitize(self.meta_keyword)\n\t\tself.meta_description = ActionView::Base.full_sanitizer.sanitize(self.meta_description)\n\t\tself.page_class = ActionView::Base.full_sanitizer.sanitize(self.page_class)\n\tend", "def spamcheck(url, max_score=5.0)\n filters(spamcheck: {settings: {enable: 1, maxscore: max_score, url: url}})\n end", "def link_sanitizer; end", "def link_sanitizer; end", "def link_sanitizer; end", "def default_filters!\n before do\n request.path_info =~ /\\.([^\\.\\/]+)$/\n @_content_type = ($1 || :html).to_sym\n content_type(@_content_type, :charset => 'utf-8') rescue content_type('application/octet-stream')\n end\n end", "def filter\n setup_instance_variables\n render 'index'\n end", "def default_text_filter\n # blog.text_filter.to_text_filter\n end", "def filter_url_before_save\n return true unless url_changed? && !self['url'].blank?\n raw = self['url'].to_s.strip\n raw = raw.sub(/tag=.+?(?:&|$)/, '') if raw =~ /amazon.com/i # Remove amazon associate tag\n raw = raw.gsub(/&&+/, '&').sub(/[\\?&]$/, '') # Trailing ? or &\n self.url = raw\n end", "def filter_generator; end", "def sanitization_whitelist\n whitelist = HTML::Pipeline::SanitizationFilter::WHITELIST\n whitelist[:attributes][:all].push('class', 'id')\n whitelist[:elements].push('span')\n\n fix_anchors = lambda do |env|\n name, node = env[:node_name], env[:node]\n if name == 'a'\n node.remove_attribute('rel')\n if node['href'] && node['href'].match('javascript:')\n node.remove_attribute('href')\n end\n end\n end\n\n whitelist[:transformers].push(fix_anchors)\n\n whitelist\n end", "def before_request\n end", "def history_sanitization\n self.class.new do |sanitize|\n sanitize.add_attributes['a'] = {'rel' => 'nofollow'}\n end\n end", "def filtered_path; end", "def filter_parameters; end", "def filter_parameters; end", "def before_processing\n end", "def set_random_filters\n change_endpoint(:search)\n\n dd_author = browser.select_list(id: 'author')\n dd_tag = browser.select_list(id: 'tag')\n update_action_log(\n :select_list,\n [\n !dd_author.nil? && dd_author.present? && dd_author.respond_to?(:options),\n !dd_tag.nil? && dd_tag.present? && dd_tag.respond_to?(:options)\n ].all?\n )\n\n dd_author_options = dd_author.options\n update_action_log(:options, dd_author_options.size == 50)\n\n author = dd_author_options[(0..dd_author_options.size).to_a.sample].text\n dd_author.select_value(author)\n update_action_log(:select_value, dd_author.value == author)\n update_action_log(:value, !dd_author.value.empty?)\n\n tag = dd_tag.option(index: (1..dd_tag.options.size - 1).to_a.sample)\n tag.select\n update_action_log(:select, dd_tag.value == tag.text)\n\n browser.button(name: 'submit_button').click\n sleep 2\n update_action_log(:button_click, !page_quotes.to_a.empty?)\n dd_author.value == author && dd_tag.value == tag\n end", "def run\n super\n\n # Base checklist\n to_check = [\n { :path => \"crossdomain.xml\", :signature => \"<?xml\" },\n { :path => \"elmah.axd\", :signature => \"Error Log for\" },\n { :path => \"phpinfo.php\", :signature => \"phpinfo()\" },\n { :path => \"robots.txt\", :signature => \"user-agent:\" },\n { :path => \"sitemap.xml\", :signature => \"<?xml\" },\n { :path => \"sitemap.xml.gz\", :signature => \"<?xml\" },\n ]\n\n # Add in un-sig'd checks \n unsig_checks = IO.readlines(\"#{Rails.root}/data/web.list\")\n unsig_check_list = unsig_checks.map { |x| { :path => x.chomp, :signature => \"\" } } \n to_check += unsig_check_list\n\n test_url = \"#{@entity.name}/there-is-no-way-this-exists-#{rand(10000)}\"\n missing_page_content = open_uri_and_return_content(test_url, @task_logger)\n\n # Run through the checks\n to_check.each do |check|\n\n # Concat the uri to create the check\n url = \"#{@entity.name}/#{check[:path]}\"\n @task_logger.log \"Connecting to #{url} for #{@entity}\" \n\n # Do the request\n content = open_uri_and_return_content(url,@task_logger)\n\n # Return if we didn't get anyting\n next unless content\n\n # Check to make sure this is a legit page, and create an entity if so\n # \n # Note that the signature is blank for unsig_checks\n #\n # TODO - improve the checking for wildcard page returns and 404-200's\n\n if content.include? check[:signature] and content != missing_page_content\n # create an entity if we match\n create_entity Entities::WebPage, { :name => \"#{url}\", :uri => \"#{url}\", :content => \"#{content}\" }\n end\n\n end\nend", "def no_spamming\n created_urls = submitter.submitted_urls\n num_of_recent_urls = created_urls\n .where('created_at > ?', 1.minute.ago)\n .count\n\n raise \"Cannot create more than 5 shortened links in a minute!\" if num_of_recent_urls >= 5 \n end", "def bench_filters\n skip 'TODO'\n end", "def html_clean_filters( src_key, tree_key = nil )\n\n tree_key = \"#{src_key}_tree\".to_sym unless tree_key\n src_key, tree_key = src_key.to_k, tree_key.to_k\n\n filters = []\n filters << html_parse_filter( src_key, tree_key )\n\n #FIXME: PAGE: filters << TitleExtractor.new, or after?\n\n # FIXME: if src is text, last filter\n # filters << TextCtrlWSFilter.new( ContentKeys::TITLE )\n\n tfc = TreeFilterChain.new( html_tree_filters )\n\n filters << HTMLTreeFilter.new( tree_key, tfc,\n HTMLTreeFilter::Order::DEPTH_FIRST )\n\n #FIXME: First block extractor back to text key?\n\n filters\n end", "def check_site_read_only\r\n if OperatingParamCache.instance.read_only_site_enabled?\r\n if request.xhr?\r\n render :update do |page|\r\n page.redirect_to '/site_slow.html#hide_find_reviews'\r\n end\r\n else\r\n render :template => 'common/site_slow', :layout => 'application'\r\n end\r\n false\r\n else\r\n true\r\n end\r\n end", "def on_pre_request( request )\n end", "def process(request); end", "def crawls\n\t\t\t\t@url_collection.select{|k,v| v.crawled?}\n\t\t\tend", "def pre_match\n end" ]
[ "0.65347165", "0.6523866", "0.6523866", "0.6503984", "0.6503984", "0.6503984", "0.6278043", "0.62743187", "0.621413", "0.6175442", "0.6121482", "0.6115001", "0.6115001", "0.60824484", "0.59973884", "0.59973884", "0.59602416", "0.595875", "0.59543383", "0.5939358", "0.58930075", "0.58306843", "0.58306843", "0.58306843", "0.5813035", "0.5799885", "0.5797319", "0.57815653", "0.57815653", "0.57528764", "0.5737351", "0.5712595", "0.57124436", "0.5705776", "0.57032675", "0.5668805", "0.566777", "0.566777", "0.56512856", "0.56498265", "0.5649031", "0.5550364", "0.55383307", "0.5536584", "0.5535706", "0.5535706", "0.5535706", "0.5535706", "0.55354524", "0.55334246", "0.55188453", "0.5497769", "0.5490452", "0.5483821", "0.5470059", "0.5470059", "0.54542816", "0.5447404", "0.5442718", "0.54114515", "0.54114515", "0.53994644", "0.5376993", "0.5374448", "0.53699934", "0.53442335", "0.53403443", "0.53311574", "0.53311574", "0.531693", "0.530944", "0.52937216", "0.529101", "0.527006", "0.5263968", "0.5259782", "0.5240781", "0.5240781", "0.5240781", "0.52367145", "0.52179724", "0.52170396", "0.5207087", "0.52032137", "0.5200856", "0.5194737", "0.5191541", "0.5183097", "0.5176345", "0.5176345", "0.51760644", "0.5171001", "0.5165413", "0.51637936", "0.5161096", "0.5156867", "0.51562893", "0.5149781", "0.51493645", "0.51467025", "0.5138621" ]
0.0
-1
GET /friendships GET /friendships.json
def index @friendships = Friendship.all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @friendships = @user.friendships\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @friendships }\n end\n end", "def friendships_show(options = {})\n @req.get(\"/1.1/friendships/show.json\", options)\n end", "def show\n @friendship = @user.friendships.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @friendship }\n end\n end", "def index\n @friendships = Friendship.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @friendships }\n end\n end", "def index\n @friendships = Friendship.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @friendships }\n end\n end", "def show_list_by_user_id\n @id = current_user.id\n @userfriendships = User.find(@id).friends\n if @userfriendships.empty?\n render json: {Error: \"No friends found\"}, status: 404\n else\n render json: @userfriendships.to_json(:only => [:id, :username])\n end\n end", "def show\n user = User.find(params[:id])\n friendships = user.followers + user.followees\n render json: {user: user, friendships: friendships}\n end", "def index\n @friendships = @user.friendships\n\n respond_to do |format|\n format.html # index.rhtml\n end\n end", "def friendships_incoming(options = {})\n @req.get(\"/1.1/friendships/incoming.json\", options)\n end", "def all_followships\n followships = User.find(params[:user_id]).followships\n render :json => followships\n end", "def index\n retrieve_and_develop_all_friendships\n end", "def get_friends_list\n friends = self.friendships\n friends = friends.map do |friendship|\n User.find(friendship.friend_id)\n end\n end", "def index\n @followships = Follower.all\n render json: @followships\n end", "def index\n logger.info(\"-------------->index Friendship session #{session[:login]}\");\n if request.format.json?\n friendships_instance =Friendship.new\n @friendships = friendships_instance.getMyfriends(session[:login]); \n else \n @friendships=Friendship.where(user_id: session[:login])\n end\n\n end", "def show\n @friendship = Friendship.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @friendship }\n end\n end", "def show\n @friendship = Friendship.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @friendship }\n end\n end", "def index\n @request_friendships = RequestFriendship.all\n end", "def index\n @clientships = current_user.clientships.all \n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @clientships }\n end\n end", "def friendships\n @_friendships ||= Friendable.resource_class.find(raw_friend_hashes.keys).map do |resource|\n Friendship.deserialize!(self, resource, raw_friend_hashes[resource.id.to_s])\n end\n end", "def list\n user = User.find_by_email params[:email]\n if user\n friendship = Friendship.where user: user\n render json: {success: true, friends: friendship.map {|f| f.friend.email}, count: friendship.count}\n else\n render json: {message: \"email not found\"}\n end\n end", "def get_friends\n results = []\n user = User.find_by_username(params[:username])\n friends = Friend.where(user_id: user.id, accepted: true)\n friends.each do |friend_rel|\n friend = User.find(friend_rel.friend_id)\n results << {id:friend.id, username: friend.username}\n end\n friends = Friend.where(friend_id: user.id, accepted: true)\n friends.each do |friend_rel|\n friend = User.find(friend_rel.user_id)\n results << {id:friend.id, username: friend.username}\n end\n render json:results\n end", "def friends\n all_friends = [];\n self.friendships.each do |ship|\n if ship.status == 'approved'\n friend_id = get_friend_id_from_friendship(ship)\n friend = User.find(friend_id)\n all_friends << friend\n end\n end\n all_friends\n end", "def friendships_outgoing(options = {})\n @req.get(\"/1.1/friendships/outgoing.json\", options)\n end", "def friend_requests\n friends = current_user.friends.where accepted: false\n profiles = friends.map{ |friend| Profile.find(friend.profile_id)}\n render json: profiles\n end", "def show\n @clientship = current_user.clientships.find(params[:id]) \n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @clientship }\n end\n end", "def friends\n # Requires authorization\n raise PutioError::AuthorizationRequired if authentication_required!\n\n make_get_call('/friends/list').friends\n end", "def index\n @friends = Friend.all\n render json: @friends\n end", "def friends\n output = []\n friendships.each do |f|\n output << f.friend\n end\n output\n end", "def friends(options={})\n get('/friends', options)\n end", "def index\n @user = current_user\n render json: @user.friends\n end", "def find_friendship\n @friendship = current_user.friendships.find_by_user_id_and_friend_id(current_user.id, @friend_id)\n end", "def index\n @fellowships = Fellowship.all\n end", "def index\n @current_user = current_user\n @friendships = current_user.friendships\n\n @potentialFriends = User.all()\n end", "def friends(fships = friendships_confirmed)\n users = Array.new\n fships.each{ |f| users += f.users.select { |u| u.id != self.id } }\n users\n end", "def all_friends\n friends friendships\n end", "def friend_requests\n Friendship.where(friend_id: id, status: false)\n end", "def index\n @followships = Followship.all\n end", "def index\r\n @followships = Followship.all\r\n end", "def index\n @girlfriends = Girlfriend.all\n render json: @girlfriends, status: 200 \n end", "def friends\n #get friends page\n #get json from friends page\n #parse\n []\n end", "def get_friends\n friends = get(\"friends\")\n\n # [id, name, phone_number, klass]\n if @starred_contacts.length == 0\n Logger.d(\"Starred contacts length was found to be 0, initiating a fetch\")\n t = Thread.start do\n @starred_contacts = ContactsSync.find_all_starred_contacts(@context)\n Logger.d(\"#{@starred_contacts.length} starred contacts are available. Requesting a UI refresh\")\n request_ui_refresh\n end # Thread ends\n end\n\n return friends + @starred_contacts\n end", "def friends_list\n @user = User.find_by(email: params[:email])\n if @user.present?\n @friends = @user.friends.page(params[:page]).per(params[:per_page]).distinct\n render json: @friends, each_serializer: Api::V1::UsersSerializer, meta: pagination_dict(@friends)\n else\n render json: {message: 'User Not Found'}, status: 404\n end\n end", "def friends\n @friends_arr = []\n current_user = User.where(id: self.id)\n friends = current_user[0].friendships\n friends.each do |f|\n @friends_arr.push(f.friendee)\n end\n \n @friends_arr\n end", "def friend_requests\n # Requires authorization\n raise PutioError::AuthorizationRequired if authentication_required!\n\n make_get_call('/friends/waiting-requests').friends\n end", "def friends\n friendships.where(accepted: true).map(&:friend)\n end", "def leaderboard\n get(\"/user/#{@user_id}/friends/leaderboard.json\")\n end", "def follows\n @follows = @user.follows\n\n respond_to do |format|\n format.html\n format.json { render :json => { :follows => @follows.map{|x| x.as_json(:json => 'friendship')}, :user => @user.as_json(:json => 'wall') }}\n end\n end", "def get_friends\n @person = Person.find_by_guid(params['user_id'])\n if ! @person\n render_json :status => :not_found and return\n end\n\n if params['sortBy'] == \"status_changed\"\n params['sortOrder'] ||= \"ascending\"\n @friends = @person.contacts.all\n @friends.sort!{|a,b| sort_by_status_message_changed(a, b, params['sortOrder']) }\n else\n @friends = @person.contacts\n end\n @friends.filter_paginate!(params[:per_page], params[:page]){true}\n @friends.collect! { |p| p.to_hash(@user, @client)}\n render_json :entry => @friends, :size => @friends.count_available and return\n end", "def my_friends\n @current_user = User.find(params[:user_id])\n render json: {\n friends: @current_user.friend.where(status: 'accept').map do |friend|\n {\n id: friend.id,\n name: User.find(friend.friend).name.upcase,\n avatar: \"#{request.base_url}#{Rails.application.routes.url_helpers.rails_blob_path(User.find(friend.friend).avatar, only_path: true)}\",\n date: friend.created_at\n }\n end\n }\n end", "def followers\n @followers = @user.followers\n\n respond_to do |format|\n format.html\n format.json { render :json => { :followers => @followers.map{|x| x.as_json(:json => 'friendship')}, :user => @user.as_json(:json => 'wall') }}\n end\n end", "def friends\n friendships = Friendship.where('(user_id = ? OR friend_id = ?) AND confirmed = ?', self.id, self.id, true)\n users = []\n friendships.each do |friendship|\n if friendship.user_id == self.id\n users.push User.find friendship.friend_id\n else\n users.push User.find friendship.user_id\n end\n end\n\n users\n end", "def sent_friend_requests\n friendships = Friendship.where(:user_id => self.id, :confirmed => false)\n users = []\n friendships.each do |friendship|\n users.push User.find friendship.friend_id\n end\n\n users\n end", "def list_pending_friend_request\n @current_user = User.find(params[:user_id])\n render json: {\n pending_friend: @current_user.friend.where(status: :pending).map do |friend|\n {\n id: friend.friend,\n name: User.find(friend.friend).name,\n avatar: \"#{request.base_url}#{Rails.application.routes.url_helpers.rails_blob_path(User.find(friend.friend).avatar, only_path: true)}\",\n status: friend.status\n }\n end\n }, status: :ok\n end", "def friends\n\t\t@user = User.includes(:owned_friendships => :friend, :sent_requests => :requestee,\n\t\t\t\t\t\t\t :received_requests => :requestor).find(params[:id])\n\tend", "def friendships_pending\n friendships_pending = []\n friendships.where(confirmed: false).each { |fs| friendships_pending << User.find(fs.friend_id) }\n friendships_pending\n end", "def show\n @user=current_user\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @user.friends}\n end\n end", "def index\n session[:last_friendship_page] = request.env['REQUEST_URI']\n @friendship = Friendship.new\n set_index_friendships\n end", "def friendships\n\t\tt = Friendship.arel_table\n\t\tFriendship.where(t[:requester_id].eq(id).or(t[:accepter_id].eq(id)))\n\tend", "def friends(user_id=self.username)\n connection.get(\"/users/#{user_id}/friends\").body.users\n end", "def friendship_exists?(user_a, user_b)\n response = get \"friendships/exists\", {:user_a => user_a, :user_b => user_b}\n if response.ok?\n response.data.%('friends').inner_html == 'true'\n else\n response\n end\n end", "def friendships_create(options = {})\n @req.post(\"/1.1/friendships/create.json\", options)\n end", "def set_friendship\n @friendship = current_api_user.friendships.find(params[:id])\n end", "def friends(id, options = {})\n get(\"users/#{id}/friends\").friends\n end", "def friends \n friends = []\n friendships = Relationship.where(\"follower_id = :user_id and friend_status = 'FRIENDS' or followed_id = :user_id and friend_status = 'FRIENDS'\", {user_id: self.id})\n\n friendships.each do |friendship|\n if friendship.followed_id == self.id\n friends.append(friendship.follower)\n else\n friends.append(friendship.followed)\n end\n end\n\n\tfriends << self\n\t\n return friends \n end", "def friend_requests\n get(\"users/requests\").requests\n end", "def show\n @friendship = Friendship.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @friendship }\n end\n end", "def friends(options={})\n perform_get(\"statuses/friends.#{Twitter.format}\", options)\n end", "def friends(user = nil, params = {})\n args = [user, params]\n get path_from_args('statuses/friends', args), params_from_args(args)\n end", "def received_friend_requests\n friendships = Friendship.where(:friend_id => self.id, :confirmed => false)\n users = []\n friendships.each do |friendship|\n users.push User.find_by_id friendship.user_id\n end\n\n users\n end", "def index\n @player_ships = PlayerShip.all\n end", "def friendships_update(options = {})\n @req.post(\"/1.1/friendships/update.json\", options)\n end", "def friends\n friend_ids = active_friendships.where(confirmed: true).pluck(:recipient_id) + passive_friendships.where(confirmed: true).pluck(:initiator_id)\n User.where(id: friend_ids)\n end", "def friend_ids(query={})\n perform_get(\"/friends/ids.json\", :query => query)\nend", "def get_friends\n graph = Koala::Facebook::API.new(@access_token)\n\n # Get friends from Facebook and convert them into a Friend object\n friends = graph.get_connections(\"me\", \"friends\").collect do |friend|\n Friend.new(:id => friend[\"id\"], :name => friend[\"name\"])\n end\n\n # Batch request friend pictures with respect to BATCH_API_LIMIT\n pictures = Array.new\n friends.each_slice(BATCH_API_LIMIT) do |friends_slice|\n batch_pictures = graph.batch do |batch|\n friends_slice.each { |friend| batch.get_picture(friend.id, :type => \"large\") }\n end\n pictures.concat(batch_pictures)\n end\n\n # Zip through the friends and pictures to produce updated Friend\n # objects.\n friends.zip(pictures).collect do |pair|\n friend = pair.first\n picture = pair.last\n\n friend.picture = pair.last\n\n friend\n end\n end", "def destroy\n @friendship = @user.friendships.find(params[:id])\n @friendship.destroy\n\n respond_to do |format|\n format.html { redirect_to game_user_friendships_url }\n format.json { head :no_content }\n end\n end", "def index\n @friend_requests = FriendRequest.all\n end", "def pending_friends\n friendships.map{|friendship| friendship.friend if !friendship.confirmed}.compact\n end", "def list\n @emails = Friend.friends(params[:email])\n\n unless @emails.empty?\n render json:{\n success: true,\n friends: @emails,\n count: @emails.count\n }\n else\n render json: {\n success: false,\n friends: [],\n count: 0\n }\n end\n end", "def index\n @relationships = current_user.friends\n end", "def friendship(friend)\n \t ::Friendship.find(:first, :conditions => [ '(user_id = ? AND friend_id = ?) OR (friend_id = ? AND user_id = ?)', id, friend.id, id, friend.id ])\n \t end", "def index\n @friends = @member.friends\n end", "def index\n @ships = Ship.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @ships }\n end\n end", "def index\n current_user = get_current_user\n @users = current_user.friends_list\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @users }\n end\n end", "def friendship_show?(user_a, user_b)\n\t\treturn true if user_a == user_b\n\t\tresponse = access_token.get(\"/friendships/show.json?user_a=#{user_a}&user_b=#{user_b}\")\n\t\tcase response\n\t\twhen Net::HTTPSuccess\n\t\t\tfriendship=JSON.parse(response.body)\n\t\telse\n\t\t\traise TwitterOauth::APIError\n\t\tend\n\trescue => err\n\t\tputs \"Exception in friendship_show?: #{err}\"\n\t\traise err\n\tend", "def show\n @friendrequest = Friendrequest.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @friendrequest }\n end\n end", "def index\n @ships = Ship.all\n end", "def index\n @ships = Ship.all\n end", "def pending_friend_requests_to\n self.friendships.where(state: \"pending\")\n end", "def requests_received\n friends = Friend.where(friend_id: params[:user_id], accepted: false)\n\t render json:friends\n end", "def show\n @friend = Friend.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @friend }\n end\n end", "def friends\n @friends = response[\"friends\"]\n @friends[\"groups\"].each do |group|\n group[\"items\"].map!{|item| Foursquared::Response::User.new(client, item)}\n end\n @friends\n end", "def friends_timeline(params = {})\n get \"statuses/friends_timeline\", params\n end", "def create\n # prevent user from adding friends who are already on friends list.\n if @friendship\n render json: { Message: \"You're already friends!\" }, status: :unprocessable_entity\n else\n @friend = current_user.friendships.create(:friend_id => @friend_id)\n render json: @friend, status: 201\n end\n end", "def friends\n @start = Time.now\n @users = current_user.friends.order(:name).page params[:page]\n\n respond_to do |format|\n format.html # friends.html.erb\n format.json { render :json => @users }\n format.xml { render :xml => @users }\n end\n end", "def following\n @users = User.find(params[:id]).all_following\n render json: @users\n end", "def get_friends_list(user_id, *friend_ids)\n user_id = user_id.to_s\n validate_identifier(:user_id, user_id)\n friend_ids.each do |friend_id|\n friend_id = friend_id.to_s\n validate_identifier(:friend_ids, friend_id)\n end\n call_myspace_api(:friends_list, :user_id => user_id, :friend_ids => friend_ids.join(';'), :v1_json => true)\n end" ]
[ "0.7930787", "0.7711196", "0.75130063", "0.7359897", "0.7359897", "0.73134756", "0.7235248", "0.7098102", "0.70333683", "0.6989055", "0.69784063", "0.6882203", "0.6827199", "0.6778252", "0.67537236", "0.67537236", "0.6712055", "0.6704092", "0.66797566", "0.6663811", "0.66312593", "0.6533817", "0.6494705", "0.6470066", "0.6431654", "0.6414504", "0.6404134", "0.63626814", "0.6355115", "0.6298863", "0.62945247", "0.6290208", "0.6275614", "0.6266672", "0.62662697", "0.6245852", "0.62452644", "0.6228648", "0.6210684", "0.61575377", "0.60760087", "0.6068064", "0.606598", "0.60557574", "0.6047681", "0.6042492", "0.60389537", "0.60362047", "0.6023715", "0.6012719", "0.60087705", "0.6001921", "0.59933585", "0.59864926", "0.5978286", "0.596211", "0.5958834", "0.5947772", "0.5947681", "0.59423363", "0.5938832", "0.59347886", "0.5922285", "0.58999366", "0.5897851", "0.5894406", "0.58834434", "0.5879562", "0.58714694", "0.58511525", "0.5850838", "0.58502257", "0.5830908", "0.582908", "0.58289295", "0.5827972", "0.5824969", "0.581339", "0.58098394", "0.58073324", "0.58060145", "0.57997227", "0.5797287", "0.579624", "0.5791534", "0.5788804", "0.5788804", "0.57764095", "0.57742", "0.57706267", "0.5766052", "0.57511055", "0.5750904", "0.57507914", "0.5746743", "0.5743457" ]
0.6882189
16
GET /friendships/1 GET /friendships/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n @friendship = @user.friendships.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @friendship }\n end\n end", "def index\n @friendships = @user.friendships\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @friendships }\n end\n end", "def friendships_show(options = {})\n @req.get(\"/1.1/friendships/show.json\", options)\n end", "def index\n @friendships = Friendship.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @friendships }\n end\n end", "def index\n @friendships = Friendship.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @friendships }\n end\n end", "def show\n @friendship = Friendship.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @friendship }\n end\n end", "def show\n @friendship = Friendship.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @friendship }\n end\n end", "def show_list_by_user_id\n @id = current_user.id\n @userfriendships = User.find(@id).friends\n if @userfriendships.empty?\n render json: {Error: \"No friends found\"}, status: 404\n else\n render json: @userfriendships.to_json(:only => [:id, :username])\n end\n end", "def index\n @friendships = @user.friendships\n\n respond_to do |format|\n format.html # index.rhtml\n end\n end", "def show\n user = User.find(params[:id])\n friendships = user.followers + user.followees\n render json: {user: user, friendships: friendships}\n end", "def index\n @friendships = Friendship.all\n end", "def index\n @friendships = Friendship.all\n end", "def index\n @friendships = Friendship.all\n end", "def index\n @friendships = Friendship.all\n end", "def index\n @friendships = Friendship.all\n end", "def index\n retrieve_and_develop_all_friendships\n end", "def show\n @clientship = current_user.clientships.find(params[:id]) \n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @clientship }\n end\n end", "def index\n logger.info(\"-------------->index Friendship session #{session[:login]}\");\n if request.format.json?\n friendships_instance =Friendship.new\n @friendships = friendships_instance.getMyfriends(session[:login]); \n else \n @friendships=Friendship.where(user_id: session[:login])\n end\n\n end", "def index\n @followships = Follower.all\n render json: @followships\n end", "def index\n @request_friendships = RequestFriendship.all\n end", "def all_followships\n followships = User.find(params[:user_id]).followships\n render :json => followships\n end", "def friendships_incoming(options = {})\n @req.get(\"/1.1/friendships/incoming.json\", options)\n end", "def find_friendship\n @friendship = current_user.friendships.find_by_user_id_and_friend_id(current_user.id, @friend_id)\n end", "def index\n @clientships = current_user.clientships.all \n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @clientships }\n end\n end", "def get_friends\n results = []\n user = User.find_by_username(params[:username])\n friends = Friend.where(user_id: user.id, accepted: true)\n friends.each do |friend_rel|\n friend = User.find(friend_rel.friend_id)\n results << {id:friend.id, username: friend.username}\n end\n friends = Friend.where(friend_id: user.id, accepted: true)\n friends.each do |friend_rel|\n friend = User.find(friend_rel.user_id)\n results << {id:friend.id, username: friend.username}\n end\n render json:results\n end", "def show\n @friendrequest = Friendrequest.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @friendrequest }\n end\n end", "def index\n @friends = Friend.all\n render json: @friends\n end", "def show\n @friend = Friend.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @friend }\n end\n end", "def show\n @friendship = Friendship.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @friendship }\n end\n end", "def get_friends_list\n friends = self.friendships\n friends = friends.map do |friendship|\n User.find(friendship.friend_id)\n end\n end", "def set_friendship\n @friendship = current_api_user.friendships.find(params[:id])\n end", "def friendship(friend)\n \t ::Friendship.find(:first, :conditions => [ '(user_id = ? AND friend_id = ?) OR (friend_id = ? AND user_id = ?)', id, friend.id, id, friend.id ])\n \t end", "def index\n @girlfriends = Girlfriend.all\n render json: @girlfriends, status: 200 \n end", "def index\n @user = current_user\n render json: @user.friends\n end", "def index\n @fellowships = Fellowship.all\n end", "def list\n user = User.find_by_email params[:email]\n if user\n friendship = Friendship.where user: user\n render json: {success: true, friends: friendship.map {|f| f.friend.email}, count: friendship.count}\n else\n render json: {message: \"email not found\"}\n end\n end", "def friend_requests\n friends = current_user.friends.where accepted: false\n profiles = friends.map{ |friend| Profile.find(friend.profile_id)}\n render json: profiles\n end", "def index\n session[:last_friendship_page] = request.env['REQUEST_URI']\n @friendship = Friendship.new\n set_index_friendships\n end", "def destroy\n @friendship = @user.friendships.find(params[:id])\n @friendship.destroy\n\n respond_to do |format|\n format.html { redirect_to game_user_friendships_url }\n format.json { head :no_content }\n end\n end", "def friendship_finder(user_2)\n Friendship.where(user_id: [self.id, user_2.id], friend_id: [self.id, user_2.id]).first\n end", "def show\n @user=current_user\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @user.friends}\n end\n end", "def leaderboard\n get(\"/user/#{@user_id}/friends/leaderboard.json\")\n end", "def show\n @internships_user = InternshipsUser.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @internships_user }\n end\n end", "def friends\n\t\t@user = User.includes(:owned_friendships => :friend, :sent_requests => :requestee,\n\t\t\t\t\t\t\t :received_requests => :requestor).find(params[:id])\n\tend", "def friends\n #get friends page\n #get json from friends page\n #parse\n []\n end", "def friendships\n @_friendships ||= Friendable.resource_class.find(raw_friend_hashes.keys).map do |resource|\n Friendship.deserialize!(self, resource, raw_friend_hashes[resource.id.to_s])\n end\n end", "def friend_requests\n Friendship.where(friend_id: id, status: false)\n end", "def index\n @followships = Followship.all\n end", "def my_friends\n @current_user = User.find(params[:user_id])\n render json: {\n friends: @current_user.friend.where(status: 'accept').map do |friend|\n {\n id: friend.id,\n name: User.find(friend.friend).name.upcase,\n avatar: \"#{request.base_url}#{Rails.application.routes.url_helpers.rails_blob_path(User.find(friend.friend).avatar, only_path: true)}\",\n date: friend.created_at\n }\n end\n }\n end", "def index\n @current_user = current_user\n @friendships = current_user.friendships\n\n @potentialFriends = User.all()\n end", "def show\n @ship = Ship.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @ship }\n end\n end", "def index\r\n @followships = Followship.all\r\n end", "def request_friendship(user_2)\n self.friendships.create(friend: user_2)\n end", "def friends(options={})\n get('/friends', options)\n end", "def show\n @intern = Intern.find(params[:id])\n @internships = Internship.where(intern_id: @intern.id)\n respond_to do |format|\n format.html #show.html.erb\n format.json { render json: @intern }\n end\n end", "def friends\n # Requires authorization\n raise PutioError::AuthorizationRequired if authentication_required!\n\n make_get_call('/friends/list').friends\n end", "def index\n @friends = @member.friends\n end", "def friends\n output = []\n friendships.each do |f|\n output << f.friend\n end\n output\n end", "def new\n @friendship = Friendship.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @friendship }\n end\n end", "def new\n @friendship = Friendship.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @friendship }\n end\n end", "def friends\n all_friends = [];\n self.friendships.each do |ship|\n if ship.status == 'approved'\n friend_id = get_friend_id_from_friendship(ship)\n friend = User.find(friend_id)\n all_friends << friend\n end\n end\n all_friends\n end", "def friendships_outgoing(options = {})\n @req.get(\"/1.1/friendships/outgoing.json\", options)\n end", "def request_friendship(user_2)\n \tself.friendships.create(friend: user_2)\n end", "def show\n @internship = Internship.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @internship }\n end\n end", "def friendship(friend)\n Friendship.find(:first, :conditions => ['(user_id = ? AND friend_id = ?) OR (friend_id = ? AND user_id = ?)', self.id, friend.id, self.id, friend.id])\n end", "def list_pending_friend_request\n @current_user = User.find(params[:user_id])\n render json: {\n pending_friend: @current_user.friend.where(status: :pending).map do |friend|\n {\n id: friend.friend,\n name: User.find(friend.friend).name,\n avatar: \"#{request.base_url}#{Rails.application.routes.url_helpers.rails_blob_path(User.find(friend.friend).avatar, only_path: true)}\",\n status: friend.status\n }\n end\n }, status: :ok\n end", "def show\n @friend = Friend.find(params[:id])\n respond_with(@friend)\n end", "def create\n # prevent user from adding friends who are already on friends list.\n if @friendship\n render json: { Message: \"You're already friends!\" }, status: :unprocessable_entity\n else\n @friend = current_user.friendships.create(:friend_id => @friend_id)\n render json: @friend, status: 201\n end\n end", "def show\n @spaceship = Spaceship.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @spaceship }\n end\n end", "def get_friends\n @person = Person.find_by_guid(params['user_id'])\n if ! @person\n render_json :status => :not_found and return\n end\n\n if params['sortBy'] == \"status_changed\"\n params['sortOrder'] ||= \"ascending\"\n @friends = @person.contacts.all\n @friends.sort!{|a,b| sort_by_status_message_changed(a, b, params['sortOrder']) }\n else\n @friends = @person.contacts\n end\n @friends.filter_paginate!(params[:per_page], params[:page]){true}\n @friends.collect! { |p| p.to_hash(@user, @client)}\n render_json :entry => @friends, :size => @friends.count_available and return\n end", "def set_friendship\n @friendship = Friendship.find(params[:id])\n end", "def find_any_friendship_with(user)\n friendship = Amistad.friendship_class.where(:friendable_id => self.id, :friend_id => user.id).first\n if friendship.nil?\n friendship = Amistad.friendship_class.where(:friendable_id => user.id, :friend_id => self.id).first\n end\n friendship\n end", "def create\n Friendship.request(@user, @friend)\n @friend = Friendship.find_by_user_id_and_friend_id(@user, @friend)\n render :json => { :success => true, :new_friend => @friend }\n end", "def show\n @internship = Internship.find(params[:id])\n\n respond_to do |format|\n format.html \n format.json { render :json => @internship }\n end\n end", "def new\n @primary = current_user\n @friendship = Friendship.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @friendship }\n end\n end", "def show\n #@friendship = Friendship.where(fitpartner_user: params[:id])\n @friendship = Friendship.where(:fitpartner_id => params[:id], :user_id => current_user.id).count\n end", "def friends(id)\n friends_data(request(\"users/friends/#{id}.xml\", :auth => true))\n end", "def destroy\n @friendship = Friendship.find(params[:id])\n @friendship.destroy\n\n respond_to do |format|\n format.html { redirect_to friendships_url }\n format.json { head :no_content }\n end\n end", "def friendship_relation(user_2)\n Friendship.where(user_id: [self.id,user_2.id], friend_id: [self.id,user_2.id]).first\n end", "def show\n @relationship = Relationship.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @relationship }\n end\n end", "def index\n @friend_requests = FriendRequest.all\n end", "def follows\n @follows = @user.follows\n\n respond_to do |format|\n format.html\n format.json { render :json => { :follows => @follows.map{|x| x.as_json(:json => 'friendship')}, :user => @user.as_json(:json => 'wall') }}\n end\n end", "def show\n @friendsofuser = Friendsofuser.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @friendsofuser }\n end\n end", "def friends(user = nil, params = {})\n args = [user, params]\n get path_from_args('statuses/friends', args), params_from_args(args)\n end", "def friendship_exists?(user_a, user_b)\n response = get \"friendships/exists\", {:user_a => user_a, :user_b => user_b}\n if response.ok?\n response.data.%('friends').inner_html == 'true'\n else\n response\n end\n end", "def index\n @friends1s = Friends1.all\n end", "def friends(id, options = {})\n get(\"users/#{id}/friends\").friends\n end", "def new\n #Find the current user and the requested friend\n @user=current_user\n friend=User.find_by_email(params[:email])\n #make sure the friend exists\n if(friend)\n #Check to see if the friendship already exists\n friendCheck=Friendship.find_by_user_id_and_friend_id(@user.id, friend.id)\n if(!friendCheck)\n #If there is no friendship between the two users, continue as normal\n @friendship = @user.friendships.build(:friend_id => friend.id)\n\n respond_to do |format|\n #Do it again for the reverse relationship (a friends with b and b friends with a are two separate relationships)\n if @friendship.save\n @friendship=friend.friendships.build(:friend_id => @user.id)\n if @friendship.save\n #Send an email to the friend so they can confirm that they want to be friends\n UserMailer.confirmation_email(@user,friend).deliver\n format.html { redirect_to @friendship, notice: 'Friendship was successfully created.' }\n format.json { render json: {:created => 'true', :exists => 'true', :friends => 'false'}}\n else\n format.html { render action: \"new\" }\n format.json { render json: {:created => 'false', :friends => 'false', :exists => 'true'}}\n end\n else\n render json: {:created => 'false', :friends => 'false', :exists => 'true'}\n end\n end\n else\n #If the friendship exist, return this fact to the app. It will notify the user.\n render json: {:friends => 'true', :exists => 'true', :created => 'false'}\n end\n else\n #If the user does not exist, let the app know.\n render json: {:friends => 'false', :exists => 'false', :created => 'false'}\n end\n end", "def friend_ids(query={})\n perform_get(\"/friends/ids.json\", :query => query)\nend", "def followers\n @followers = @user.followers\n\n respond_to do |format|\n format.html\n format.json { render :json => { :followers => @followers.map{|x| x.as_json(:json => 'friendship')}, :user => @user.as_json(:json => 'wall') }}\n end\n end", "def show\n @championship = Championship.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @championship }\n end\n end", "def friends\n @start = Time.now\n @users = current_user.friends.order(:name).page params[:page]\n\n respond_to do |format|\n format.html # friends.html.erb\n format.json { render :json => @users }\n format.xml { render :xml => @users }\n end\n end", "def get_friends\n friends = get(\"friends\")\n\n # [id, name, phone_number, klass]\n if @starred_contacts.length == 0\n Logger.d(\"Starred contacts length was found to be 0, initiating a fetch\")\n t = Thread.start do\n @starred_contacts = ContactsSync.find_all_starred_contacts(@context)\n Logger.d(\"#{@starred_contacts.length} starred contacts are available. Requesting a UI refresh\")\n request_ui_refresh\n end # Thread ends\n end\n\n return friends + @starred_contacts\n end", "def request_friendship (user_2)\n #self will be current user (user_1)\n self.friendships.create(friend: user_2)\n end", "def set_friendship\n @friendship = Friendship.find(params[:id])\n end", "def friends\n @friends_arr = []\n current_user = User.where(id: self.id)\n friends = current_user[0].friendships\n friends.each do |f|\n @friends_arr.push(f.friendee)\n end\n \n @friends_arr\n end", "def befriend\n \t#friend = User.find(params[:friend_id])\n respond_to do |format|\n \t\tif Friendship.befriend(@user, @friend)\n \t\t\tmessage = \"Friend request succeed\"\n format.json{render :json => {:message => message, :status => \"200\"}}\n \t\telse\n \t\t\terror = \"No friendship request from #{@friend.nick_name}.\"\n format.json{render :json => {:error => error, :status => \"400\"}}\n \t\tend\n end\n end", "def find_friend_by_username\n begin\n @friend_id = User.find_by(username: params[:username]).id\n rescue\n render json: {error: \"Friend not found\"}, status: 404\n end\n end", "def update\n @friendship = @user.friendships.find(params[:id])\n\n respond_to do |format|\n if @friendship.update_attributes(params[:friendship])\n format.html { redirect_to [@game, @user, @friendship], notice: 'Friendship was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @friendship.errors, status: :unprocessable_entity }\n end\n end\n end", "def show\n @neighborhood = Neighborhood.find(params[:id])\n\n render json: @neighborhood\n end", "def friendship_show?(user_a, user_b)\n\t\treturn true if user_a == user_b\n\t\tresponse = access_token.get(\"/friendships/show.json?user_a=#{user_a}&user_b=#{user_b}\")\n\t\tcase response\n\t\twhen Net::HTTPSuccess\n\t\t\tfriendship=JSON.parse(response.body)\n\t\telse\n\t\t\traise TwitterOauth::APIError\n\t\tend\n\trescue => err\n\t\tputs \"Exception in friendship_show?: #{err}\"\n\t\traise err\n\tend" ]
[ "0.7787635", "0.7707509", "0.7389193", "0.719965", "0.719965", "0.71584564", "0.71584564", "0.7076224", "0.6984562", "0.69049644", "0.6683278", "0.6682108", "0.6682108", "0.6682108", "0.6682108", "0.6678331", "0.6654447", "0.6641869", "0.65554625", "0.65029025", "0.64925325", "0.64863414", "0.6476347", "0.64542747", "0.64022344", "0.6369766", "0.63504016", "0.6322476", "0.6292335", "0.62798584", "0.6256232", "0.6229185", "0.6227377", "0.62030613", "0.61703086", "0.6107525", "0.61016685", "0.60995615", "0.6071636", "0.60476357", "0.6045297", "0.60437906", "0.60256964", "0.6021207", "0.60180503", "0.6013734", "0.60017383", "0.59801793", "0.5971213", "0.59498614", "0.5947361", "0.5944694", "0.5931374", "0.5900667", "0.5898786", "0.5890579", "0.5882773", "0.5870668", "0.58705664", "0.58705664", "0.5864136", "0.58550113", "0.5854649", "0.5842754", "0.58416134", "0.5835466", "0.58182526", "0.5818033", "0.580978", "0.5802562", "0.5800754", "0.57969815", "0.579282", "0.5792051", "0.5789725", "0.57826513", "0.5780576", "0.5769971", "0.57677287", "0.57658327", "0.57627946", "0.57539433", "0.57486653", "0.5740065", "0.57315564", "0.57156986", "0.571469", "0.57142794", "0.5709515", "0.57076526", "0.57013977", "0.5692011", "0.56861794", "0.5680393", "0.5676771", "0.5676572", "0.5676428", "0.5673532", "0.567346", "0.567119", "0.5663483" ]
0.0
-1
POST /friendships POST /friendships.json
def create if params[:status] == "pending" arefriends = Friendship.where(:user_id => params[:user_id], :friend_id => params[:friend_id]) if arefriends.empty? @friendship = current_user.friendships.build(:friend_id => params[:friend_id], :status => params[:status]) friend = User.find(params[:friend_id]) @friendship2 = friend.friendships.build(:friend_id => params[:user_id], :status => 'requested') respond_to do |format| if @friendship.save format.html { redirect_to connections_user_path(current_user), notice: 'Your Connection Request has been sent' } format.json { render action: 'show', status: :created, location: @friendship } else format.html { render action: 'new' } format.json { render json: @friendship.errors, status: :unprocessable_entity } end if @friendship2.save format.html { redirect_to @friendship2, notice: 'You received a Connection invitation' } format.json { render action: 'show', status: :created, location: @friendship2 } else format.html { render action: 'new' } format.json { render json: @friendship2.errors, status: :unprocessable_entity } end end else status = arefriends[0].status if status == "accepted" response = "Already friends" else if status == "pending" response = "Connection already requested by you" else response = "You'be been asked for that Connection" end end respond_to do |format| format.html { redirect_to connections_user_path(current_user), notice: response } format.json { render json: arefriends[0].errors, status: :unprocessable_entity } end end else if params[:status] == "accepted" @friendship = Friendship.where(:user_id => params[:user_id], :friend_id => params[:friend_id]) @friendship[0].status = "accepted" @friendship2 = Friendship.where(:user_id => params[:friend_id], :friend_id => params[:user_id]) @friendship2[0].status = "accepted" respond_to do |format| if @friendship[0].save format.html { redirect_to connections_user_path(current_user), notice: 'Connection accepted' } format.json { render action: 'show', status: :created, location: @friendship[0] } else format.html { render action: 'new' } format.json { render json: @friendship[0].errors, status: :unprocessable_entity } end if @friendship2[0].save format.html { redirect_to @friendship2[0], notice: 'The friendship was accepted' } format.json { render action: 'show', status: :created, location: @friendship2[0] } else format.html { render action: 'new' } format.json { render json: @friendship2[0].errors, status: :unprocessable_entity } end end else if params[:status] == "remove" @friendship = Friendship.where(:user_id => params[:user_id], :friend_id => params[:friend_id]) @friendship[0].destroy @friendship2 = Friendship.where(:user_id => params[:friend_id], :friend_id => params[:user_id]) @friendship2[0].destroy respond_to do |format| if @friendship[0].save format.html { redirect_to connections_user_path(current_user), notice: 'Connection Removed' } format.json { render action: 'show', status: :created, location: @friendship[0] } else format.html { render action: 'new' } format.json { render json: @friendship[0].errors, status: :unprocessable_entity } end if @friendship2[0].save format.html { redirect_to @friendship2[0], notice: 'A Connection has been removed' } format.json { render action: 'show', status: :created, location: @friendship2[0] } else format.html { render action: 'new' } format.json { render json: @friendship2[0].errors, status: :unprocessable_entity } end end end end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def friendships_create(options = {})\n @req.post(\"/1.1/friendships/create.json\", options)\n end", "def create\n # prevent user from adding friends who are already on friends list.\n if @friendship\n render json: { Message: \"You're already friends!\" }, status: :unprocessable_entity\n else\n @friend = current_user.friendships.create(:friend_id => @friend_id)\n render json: @friend, status: 201\n end\n end", "def create\n @friendship = @user.friendships.new(params[:friendship])\n\n respond_to do |format|\n if @friendship.save\n format.html { redirect_to [@game, @user, @friendship], notice: 'Friendship was successfully created.' }\n format.json { render json: [@game, @user, @friendship], status: :created, location: [@game, @user, @friendship] }\n else\n format.html { render action: \"new\" }\n format.json { render json: @friendship.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n Friendship.request(@user, @friend)\n @friend = Friendship.find_by_user_id_and_friend_id(@user, @friend)\n render :json => { :success => true, :new_friend => @friend }\n end", "def create_friendship(user = nil, params = {})\n args = [user, params]\n post path_from_args('friendships/create', args), {:follow => true}.merge(params_from_args(args))\n end", "def friend\n @user.friendships.build(friend_id: @friend.id)\n if @user.save\n render json: { success: true }\n else\n render json: {message: @user.errors&.messages || 'Unable add as friend, please try again'}, status: 202\n end\n end", "def create\n user = User.find(params[:user_id])\n friendship = current_user.friendships.build(friend: user)\n if friendship.save\n reciprocal_friendship = user.friendships.build(friend: current_user)\n if reciprocal_friendship.save\n request_1 = FriendshipRequest.find_by(sender: current_user, recipient: user)\n request_2 = FriendshipRequest.find_by(sender: user, recipient: current_user)\n request_1.destroy if request_1\n request_2.destroy if request_2\n respond_to do |format|\n format.html { redirect_back(fallback_location: root_path, notice: \"You and #{user.name} are now friends!\") }\n format.json do\n render json: {\n friendship: {\n name: current_user.name,\n id: current_user.id\n },\n message: \"You and #{user.name} are now friends!\"\n }\n end\n end\n else\n friendship.destroy\n redirect_back(fallback_location: root_path, notice: \"There was an error creating the friendship\")\n end\n else\n redirect_back(fallback_location: root_path, notice: \"There was an error creating the friendship\")\n end\n end", "def create\n @friendship = current_user.friendships.build(:friend_id => params[:friend_id])\n @friendship.status = \"SENT\"\n if @friendship.save\n flash[:notice] = \"Added friend.\"\n redirect_to root_url\n else\n flash[:error] = \"Unable to add friend.\"\n redirect_to root_url\n end\n end", "def create\n @friendship = current_user.friendships.build(:friend_id => params[:id])\n \n if @friendship.save\n flash[:notice] = \"Added friend.\"\n redirect_to root_path\n else\n flash[:error] = \"Unable to add friend.\"\n redirect_to root_path\n end\n end", "def create\n @friendship = current_user.friendships.build(:friend_id => params[:friend_id])\n if @friendship.save\n flash[:notice] = t('friendship.create')\n else\n flash[:notice] = t('friendship.create_error')\n end\n redirect_to friendships_path\n end", "def create\n @friendship = Friendship.new(friendship_params)\n\n respond_to do |format|\n if @friendship.save\n format.html { redirect_to @friendship, notice: 'Friendship was successfully created.' }\n format.json { render :show, status: :created, location: @friendship }\n else\n format.html { render :new }\n format.json { render json: @friendship.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @user = User.find_by(:email => friendship_params[:email])\n if @user.nil?\n render json: { error: \"Cannot find user with specified email\"}, status: 400\n else\n id = @user.firstName\n if Friendship.exists?(:user_id => @current_user.id, :friend_id => @user.id)\n render json: { error: 'Already Friends'}, status: 400\n else\n @friendship = @current_user.friendships.build(:friend_id => @user.id)\n if @friendship.save\n @friend_user = @friendship.friend\n @inverse_friendship = @friend_user.friendships.build(:friend_id => @current_user.id)\n if @inverse_friendship.save\n render json: @friendship, status: :created\n else\n render json: @inverse_friendship.errors, status: :unprocessable_entity\n end\n else\n render json: @friendship.errors, status: :unprocessable_entity\n end\n end\n end\n end", "def create\n @friendship = current_user.friendships.build(friend_id: params[:friend_id])\n if @friendship.save\n flash[:notice] = \"Added friend.\"\n redirect_to root_url\n else\n flash[:alert] = \"Unable to add friend.\"\n redirect_to root_url\n end\n end", "def create\n @friendship = current_person.friendships.build(:granter_id => params[:granter_id], :accepted => params[:accepted])\n\n respond_to do |format|\n if @friendship.save\n format.html { redirect_to people_url, notice: 'A friend request has been sent to ' + Person.find(params[:granter_id]).name }\n format.json { render :show, status: :created, location: @friendship }\n else\n format.html { render :new }\n format.json { render json: @friendship.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n logger.debug('In the create method afterall')\n logger.debug( friend_params )\n current_user.friendships.create!(:friend_id => params[:friend_id]) \n\n redirect_to friendship_index_path\n end", "def create\n #@user = User.find(:first, \n # :conditions => [ \"username = ?\", params[:friendship][:user_id] ])\n\n @friend = User.find(:first,\n :conditions => [ \"username = ?\", params[:friendship][:friend_id] ])\n\n @friendship = Friendship.new({ \n user_id: current_user.id, \n friend_id: @friend.id,\n ignore: false\n })\n\n respond_to do |format|\n if @friendship.save\n format.html { redirect_to friendships_url, notice: 'Friendship was successfully created.' }\n format.json { render json: @friendship, status: :created, location: @friendship }\n else\n format.html { render action: \"new\" }\n format.json { render json: @friendship.errors, status: :unprocessable_entity }\n end\n end\n end", "def friendship_params\n params.require(:friendship).permit(:user_id, :friend_id, :create, :destroy)\n end", "def friendship_params\n params.require(:friendship).permit(:user_id, :friend_id, :create, :destroy)\n end", "def friendship_params\n params.require(:friendship).permit(:user_id, :friend_id, :create, :destroy)\n end", "def friendship_params\n params.require(:friendship).permit(:user_id, :friend_id, :create, :destroy)\n end", "def create\n @friendship = Friendship.new\n @friendship.user1_id = current_user.id\n @friendship.user2_id = @owner.id\n @friendship.approved = false\n respond_to do |format|\n if @friendship.save\n format.html { redirect_to friendships_main_path, flash: { :success => 'Request of friendship was successfully sent.' } }\n format.json { render :index, status: :created, location: @friendship }\n else\n set_index_friendships\n format.html { render :index }\n format.json { render json: @friendship.errors, status: :unprocessable_entity }\n end\n end\n end", "def friendships_params\n params.require(:friendships).permit(:user_id, :friend_id, :confirmed)\n end", "def create\n user = User.find(params[:friend_id])\n if current_user == user\n redirect_to root_path, notice: \"You can't send request to yourself\"\n return\n elsif Friendship.where(friend_id: user.id, user_id: current_user, confirm: false).exists?\n redirect_to root_path, notice: \"Friend request already sent\"\n return\n elsif Friendship.where(friend_id: current_user, user_id: user.id, confirm: false).exists?\n redirect_to root_path, notice: \"This user already sent friend request to you. Respond to it!\"\n return\n end\n @friendship = current_user.friendships.build(friend_id: user.id)\n\n respond_to do |format|\n if @friendship.save\n format.html { redirect_to root_path, notice: \"Friends request sent\" }\n format.json { render :show, status: :created, location: @friendship }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @friendship.errors, status: :unprocessable_entity }\n end\n end\n end", "def friendship_params\n params.require(:friendship).permit(:user_id, :user_name, :friend_id, :friend_name)\n end", "def create\n @friendship = current_user.friendships.build(:friend_id => params[:friend_id], approved: \"false\")\n if @friendship.save\n flash[:notice] = \"Friend requested.\"\n redirect_to :back\n else\n flash[:error] = \"Unable to request friendship.\"\n redirect_to :back\n end\n end", "def create\n @request_friendship = RequestFriendship.new(request_friendship_params)\n\n respond_to do |format|\n if @request_friendship.save\n format.html { redirect_to @request_friendship, notice: 'La solicitud de amistad se ha creado correctamente' }\n format.json { render :show, status: :created, location: @request_friendship }\n else\n format.html { render :new }\n format.json { render json: @request_friendship.errors, status: :unprocessable_entity }\n end\n end\n end", "def friendships_update(options = {})\n @req.post(\"/1.1/friendships/update.json\", options)\n end", "def request_friendship(user_2)\n \tself.friendships.create(friend: user_2)\n end", "def request_friendship(user_2)\n self.friendships.create(friend: user_2)\n end", "def add\n params[:friends].each do |email|\n friend = User.find_by_email(email)\n next unless friend.present?\n\n # Check the inverse friendship and add if necessary\n friendship = Friendship.find_by_user_id_and_friend_id(friend.id, current_user.id)\n unless friendship.present?\n inverse_friendship = friend.friendships.build(friend_id: current_user.id)\n if inverse_friendship.save\n puts \"Added friendship for #{friend.name} (#{friend.id}) and #{current_user.name} (#{current_user.id})\"\n end\n end\n end\n\n render json: { success: true }\n end", "def friendship_params\n params.require(:friendship).permit(:user_id, :friend_id)\n end", "def create\n if request.format.json?\n @friendship = Friendship.new(friend_id: params[:friend_id])\n @friendship.user_id = session[:login]\n @friendship.save\n render :text => \"#{@friendship.id}\"\n else\n @friendship = Friendship.new\n friendship = params[:friendship]\n @friendship.friend_id = friendship[:friend_id]\n @friendship.user_id = session[:login]\n if @friendship.save\n redirect_to friendships_url \n else\n render action: 'new' \n end\n end\n end", "def friendship_params\n params.require(:friendship).permit(:user_id, :friend_id, :approved, :create, :destroy)\n end", "def friendship_params\n params.require(:friendship).permit(:user_id, :friend_id)\n end", "def friendship_params\n params.require(:friendship).permit(:user_id, :friend_id, :status)\n end", "def create\n\n if current_user.friends.include?(params[:friend_id])\n flash[:notice] = \"It's polite to ask once.\"\n else\n\n\n @friendship = current_user.friendships.build(:friend_id => params[:friend_id], approved: \"false\")\n\n if @friendship.save\n\n\n\n log_activity\n\n flash[:notice] = \"Friend requested.\"\n\n\n\n redirect_to :back\n else\n flash[:error] = \"Unable to request friendship.\"\n redirect_to :back\n end\n end\n end", "def friendship_params\n params.fetch(:friendship).permit(:user_id, :friend_id)\n end", "def create\n @user=User.find(params[:uid])\n friend=User.find(params[:fid])\n #make sure the friend and user exist\n if(friend && @user)\n #Check to see if the friendship already exists\n friendShip=Friendship.find_by_user_id_and_friend_id(@user.id, friend.id)\n if(friendShip)\n #If there is a friendship between the two users, continue as normal\n #Change the type of friendship to Confirmed.\n #The users will then show up on each others maps.\n #The logic for this is in the users model\n friendShip.type='ConfirmedFriendship'\n respond_to do |format|\n if friendShip.save\n #Then do it again for the inverse relationship (see the new method for an explanation of why this is necessary)\n friendShip=Friendship.find_by_user_id_and_friend_id(friend.id, @user.id)\n #Change the type of friendship to Confirmed.\n #The users will then show up on each others maps.\n #The logic for this is in the users model\n friendShip.type='ConfirmedFriendship'\n session[:user_id]=@user.id\n if friendShip.save\n format.html { redirect_to \"http://54.235.20.117:3000/users/#{@user.id}.html\", notice: 'Friendship was successfully created.' }\n format.json { render json: {:created => 'true', :exists => 'true', :friends => 'false'}}\n else\n format.html { redirect_to @user, notice: 'Something went wrong!'}\n format.json { render json: {:created => 'false', :friends => 'false', :exists => 'true'}}\n end\n else\n format.html { redirect_to @user, notice: 'Something went wrong!'}\n format.json {render json: {:friends => 'false', :exists => 'false', :created => 'false'}}\n end\n end\n else\n #If the friendship doesn't exist, don't create the friendship. This will never be sent to the app\n #So the important part is the html response.\n respond_to do |format|\n format.html { redirect_to @user, notice: 'Something went wrong! According to our records, this friendship was never requested!'}\n format.json {render json: {:friends => 'false', :exists => 'false', :created => 'false'}}\n end\n end\n else\n #If the user does not exist, inform the user that their link was incorrect.\n respond_to do |format|\n format.html { redirect_to @user, notice: 'Something went wrong! According to our records, you do not exist!'}\n format.json {render json: {:friends => 'false', :exists => 'false', :created => 'false'}}\n end\n end\n end", "def create\n \n @friendship1 = current_user.friendships.build(:friend_id => params[:friend_id], approved: \"false\")\n @friendship1.original = true\n @user_being_friended = User.find(params[:friend_id])\n @friendship2 = @user_being_friended.friendships.build(:friend_id => current_user.id, approved: \"false\")\n @friendship2.original = false\n if !(Friendship.where(friend_id: params[:friend_id], user_id: current_user.id).count >= 1)\n if @friendship1.save && @friendship2.save\n flash[:notice] = \"Friend requested.\"\n redirect_to :back\n else\n flash[:error] = \"Unable to request friendship.\"\n redirect_to :back\n end\n else\n flash[:notice] = \"Friend requested again.\"\n redirect_to :back\n end\n end", "def friendship_params\n params.require(:friendship).permit(:user_id, :friend_id, :approved)\n end", "def friendship_params\n params.require(:friendship).permit(:user_id, :friend_id, :approved)\n end", "def create\n @friendship = current_user.friendships.build(friend_id: params[:friend_id])\n @valid = @friendship.save\n respond_to do |format|\n format.html do\n if @valid\n flash[:success] = \"Friended.\"#{@friendship.friend.username} \n else\n flash[:error] = \"Unable to add friend.\"\n end\n redirect_to :back\n end\n format.js do\n if current_user.mutual_friends.include? @friendship.friend\n @new_friend = @friendship.friend\n inverse_friendship = current_user.inverse_friendships.where(user: @friendship.friend).first\n end\n end\n end\n end", "def add\n id = params.require(:friend_id)\n current_user.friendships.create friend_id: id\n\n respond_to do |format|\n format.html { redirect_to friends_path, alert: \"#{User.find(id).name} is now your friend\" }\n format.json { render :json => {success: 'OK'} }\n end\n end", "def create\n params[:friendship][:user_id] = current_user.id\n\n friendship_already_exists =\n Friendship.find_by_user_id_and_friend_id(params[:friendship][:user_id], params[:friendship][:friend_id]) ||\n Friendship.find_by_user_id_and_friend_id(params[:friendship][:friend_id], params[:friendship][:user_id])\n if friendship_already_exists\n respond_to do |format|\n flash[:error] = \"Friendship not created (already exists).\"\n format.html { redirect_to new_user_friendship_path(current_user.id) }\n end\n elsif params[:friendship][:friend_id] == params[:friendship][:user_id]\n respond_to do |format|\n flash[:error] = \"You cannot add yourself as a friend.\"\n format.html { redirect_to new_user_friendship_path(current_user.id) }\n end\n else\n @friendship = Friendship.new(params[:friendship])\n # set initial datetime\n @friendship.accepted_at = nil\n if @friendship.message.blank?\n @friendship.message = nil\n end\n\n respond_to do |format|\n if @friendship.save\n \n begin\n friend = @friendship.friend\n Notifier.deliver_friendship_request(friend, @friendship.user.name, @friendship, base_host) if friend.send_notifications?\n rescue Exception => e\n logger.error(\"ERROR: failed to send Friendship Request email notification. Friendship ID: #{@friendship.id}\")\n logger.error(\"EXCEPTION:\" + e)\n end\n \n flash[:notice] = 'Friendship was successfully requested.'\n format.html { redirect_to user_friendship_path(current_user.id, @friendship) }\n else\n format.html { render :action => \"new\" }\n end\n end\n end\n end", "def request_friendship (user_2)\n #self will be current user (user_1)\n self.friendships.create(friend: user_2)\n end", "def friendship_params\n params.require(:friendship).permit(:user_id, :friend_id, :mutual_friend_id)\n end", "def index\n @friendships = @user.friendships\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @friendships }\n end\n end", "def friendship_params\n params.require(:friendship).permit(:user_id,:friend_id)\n end", "def friendship_params\n params.require(:friendship).permit(:requester_id, :granter_id, :accepted)\n end", "def friendship_params\n params.require(:friendship).permit(:friend_id)\n end", "def create\n @followship = Followship.create(:follower_id => current_user.id, :following_id => followship_params[:following_id])\n\n respond_to do |format|\n if @followship.save\n format.html { redirect_to @followship, notice: 'Followship was successfully created.' }\n format.json { render :show, status: :created, location: @followship }\n else\n format.html { render :new }\n format.json { render json: @followship.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n #Find the current user and the requested friend\n @user=current_user\n friend=User.find_by_email(params[:email])\n #make sure the friend exists\n if(friend)\n #Check to see if the friendship already exists\n friendCheck=Friendship.find_by_user_id_and_friend_id(@user.id, friend.id)\n if(!friendCheck)\n #If there is no friendship between the two users, continue as normal\n @friendship = @user.friendships.build(:friend_id => friend.id)\n\n respond_to do |format|\n #Do it again for the reverse relationship (a friends with b and b friends with a are two separate relationships)\n if @friendship.save\n @friendship=friend.friendships.build(:friend_id => @user.id)\n if @friendship.save\n #Send an email to the friend so they can confirm that they want to be friends\n UserMailer.confirmation_email(@user,friend).deliver\n format.html { redirect_to @friendship, notice: 'Friendship was successfully created.' }\n format.json { render json: {:created => 'true', :exists => 'true', :friends => 'false'}}\n else\n format.html { render action: \"new\" }\n format.json { render json: {:created => 'false', :friends => 'false', :exists => 'true'}}\n end\n else\n render json: {:created => 'false', :friends => 'false', :exists => 'true'}\n end\n end\n else\n #If the friendship exist, return this fact to the app. It will notify the user.\n render json: {:friends => 'true', :exists => 'true', :created => 'false'}\n end\n else\n #If the user does not exist, let the app know.\n render json: {:friends => 'false', :exists => 'false', :created => 'false'}\n end\n end", "def create\n #user = User.find(params[:friend_id])\n #User.invite!(:email => user.email, :first_name => user.first_name)\n @friendship = current_user.friendships.build(:friend_id => params[:friend_id])\n \n respond_to do |format|\n if @friendship.save\n Notification.create(recepient: @friendship.friend, user: current_user, body: \"#{current_user.screen_name } has request to connect \", notificable: @friendship, :accept => false)\n # NotificationMailer.friend_request(@friendship).deliver_later\n \n @suggested_connections, @suggest = suggested_connections\n format.html { redirect_to '/', notice: 'Invitation has been sent successfully' }\n # format.json { render :show, status: :created, location: @friendship }\n format.js\n else\n format.html { render :new }\n format.json { render json: @friendship.errors, status: :unprocessable_entity }\n end\n end \n end", "def create\n @friendship = Friendship.new(params[:friendship])\n current_user.un_black_ball(@friendship.proposee)\n @user = @friendship.proposee\n respond_to do |format|\n if @friendship.save\n format.html { redirect_to @friendship, notice: \"Your Friend Request was sent\" }\n format.json { render json: @friendship, status: :created, location: @friendship }\n format.js {}\n else\n format.html { render action: \"new\" }\n format.js {}\n format.json { render json: @friendship.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @fellowship = Fellowship.new(fellowship_params)\n @fellowship.users << current_user\n\n # Capitalize fellowship name\n @fellowship.fellowship_name = @fellowship.fellowship_name.titleize\n\n respond_to do |format|\n if @fellowship.save\n format.html { redirect_to @fellowship, notice: 'Fellowship was successfully created.' }\n format.json { render :show, status: :created, location: @fellowship }\n else\n format.html { render :new }\n format.json { render json: @fellowship.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_request\n friendship = Friend.new(:user_id => params[:user_id], \n\t\t\t\t\t\t\t :friend_id => params[:friend_id])\n\t if friendship.save\n\t render text: friendship.id \n\t else\n\t render text:'-1'\n\t end\n end", "def save_friendships\n array = friendlist(current_user)\n puts \"array: \\n #{array}\"\n array.each do |user|\n puts \"user id is #{user.id}\"\n puts \"current user is #{current_user.id}\"\n if Friendship.where(\"user_id = ? AND friend_id = ?\", current_user.id, user.id).exists?\n puts \"Friendship already exists: #{Friendship.where(\"user_id = ? AND friend_id = ?\", current_user.id, user.id).inspect}\"\n next\n elsif Friendship.where(\"user_id = ? AND friend_id = ?\", user.id, current_user.id).exists?\n puts \"Friendship already exists: #{Friendship.where(\"user_id = ? AND friend_id = ?\", user.id, current_user.id).inspect}\"\n next\n elsif (user.id == current_user.id)\n puts \"Can't be friends with yourself!\"\n next\n else\n puts \"#{user.id} isn't a friend of #{current_user.id} yet!\"\n Friendship.create(user_id: current_user.id, friend_id: user.id, friendship_status: \"suggested\")\n end\n end\n end", "def create\n @plant = Plant.find(params[:plant])\n @friendship = @plant.friendships.build(:friend_id => params[:friend])\n if @friendship.save\n flash[:notice] = \"added friend\"\n redirect_to request.referrer\n else\n flash[:error] = \"Unable to add friend.\"\n redirect_to request.referer\n end\n end", "def create\n #@friendrequest = Friendrequest.new(params[:friendrequest])\n \n @user = User.find(params[:user_id])\n #@friend = Friend.new(params[:friend])\n @friendreq = @user.friendrequests.create(params[:friendrequest].permit(:futurefriend))\n\n respond_to do |format|\n if @friendrequest.save\n format.html { redirect_to @friendrequest, notice: 'Friendrequest was successfully created.' }\n format.json { render json: @friendrequest, status: :created, location: @friendrequest }\n else\n format.html { render action: \"new\" }\n format.json { render json: @friendrequest.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if params[:status] == \"accepted\"\n @friendship = current_user.friendships.build(:friend_id => params[:friend_id], :status => 'accepted')\n friend = User.find(params[:friend_id])\n @friendship2 = friend.friendships.build(:friend_id => params[:user_id], :status => 'accepted')\n\n respond_to do |format|\n if @friendship.save\n format.html { redirect_to @friendship, notice: 'Your Connection Request has been sent' }\n format.json { render action: 'show', status: :created, location: @friendship }\n else\n format.html { render action: 'new' }\n format.json { render json: @friendship.errors, status: :unprocessable_entity }\n end\n if @friendship2.save\n format.html { redirect_to @friendship2, notice: 'You received a friendship invitation' }\n format.json { render action: 'show', status: :created, location: @friendship2 }\n else\n format.html { render action: 'new' }\n format.json { render json: @friendship2.errors, status: :unprocessable_entity }\n end\n end\n end\n\n end", "def friendship_params\n params.require(:friendship).permit(:friend_id, :state)\n end", "def request_friend(friend)\n self.friendships.create!(friend_id: friend.id, status: 'requested')\n friend.friendships.create!(friend_id: self.id, status: 'pending')\n end", "def friendship_params\n params.require(:friendship).permit(:id, :sender_id, :receiver_id, :active)\n end", "def create\n @clientship = current_user.clientships.build(:client_id => params[:client_id], :fee => params[:fee])\n\n respond_to do |format|\n if @clientship.save\n format.html { redirect_to @clientship, notice: 'Clientship was successfully created.' }\n format.json { render json: @clientship, status: :created, location: @clientship }\n else\n format.html { render action: \"new\" }\n format.json { render json: @clientship.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @followship = Followship.new(followship_params)\n\n respond_to do |format|\n if @followship.save\n format.html { redirect_to @followship, notice: 'Followship was successfully created.' }\n format.json { render :show, status: :created, location: @followship }\n else\n format.html { render :new }\n format.json { render json: @followship.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n\t\t@profile_friend = Friendship.new(profile_friend_params)\n\t\t@profile_friend.friend_a = current_user\n\n\t\trespond_to do |format|\n\t\t\tif @profile_friend.save\n\t\t\t\tback_page = profile_friends_path\n\t\t\t\tback_page = URI(request.referer).path if params[:back]\n\t\t\t\tformat.html { redirect_to back_page, notice: 'Friend was successfully created.' }\n\t\t\t\tformat.json { render :show, status: :created, location: back_page }\n\t\t\telse\n\t\t\t\tformat.html { broadcast_errors @profile_friend, profile_friend_params }\n\t\t\t\tformat.json { render json: @profile_friend.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend", "def friend(other_user)\n friendships.create!(friend_id: other_user.id)\n end", "def user_friendship_params\n params.require(:user_friendship).permit(:friend, :user, :user_id, :friend_id) if params[:user_friendship]\n end", "def follow!(amigo_id)\n self.friendships.create!(friend_id: amigo_id)\n \n end", "def create\n @friendship = Friendship.request(@user, @friend)\n respond_to do |format|\n if !@friendship.nil?\n @is_friendship_requested = true\n format.js\n else\n format.js {render \"an error occured\"}\n end\n end\n end", "def create\n @friends = params[:friends] || []\n @hack = Hack.new(params[:hack])\n @hack.sort_rand = Random.rand\n @hack.event_id = @event.id\n\n if !@hack.save\n respond_to do |format|\n format.html { render :action => \"new\" }\n format.json { render :json => @hack.errors, :status => :unprocessable_entity }\n end\n return\n end\n\n assoc = HackMembersAssoc.new\n assoc.hack = @hack\n assoc.user = @current_user\n assoc.confirmed = true\n assoc.save!\n @friends.each do |friend_id|\n friend = User.get_or_create_by_fbid(friend_id, @api);\n assoc = HackMembersAssoc.new\n assoc.hack = @hack\n assoc.user = friend\n assoc.confirmed = true\n assoc.save!\n end\n\n respond_to do |format|\n format.html { redirect_to @event, :notices => ['Hack was successfully created.'] }\n format.json { render :json => @hack, :status => :created, :location => [@event, @hack] }\n end\n end", "def create\n\t\tFriendship::request(@user, @friend)\n\t\tUserMailer::friend_request(\n\t\t\t:user => @user,\n\t\t\t:friend => @friend,\n\t\t\t:user_url => profile_for(@user),\n\t\t\t:accept_url => url_for(:action => \"accept\", :id => @user.screen_name),\n\t\t\t:decline_url => url_for(:action => \"decline\", :id => @user.screen_name)\n\t\t).deliver_now\n\t\tflash[:notice] = \"Friend request sent.\"\n\t\tredirect_to profile_for(@friend)\n\tend", "def create\r\n @followship = Followship.new(followship_params)\r\n\r\n respond_to do |format|\r\n if @followship.save\r\n format.html { redirect_to @followship, notice: 'Followship was successfully created.' }\r\n format.json { render :show, status: :created, location: @followship }\r\n else\r\n format.html { render :new }\r\n format.json { render json: @followship.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end", "def add_friend\n\n current_user.friends_list.push(define_friend)\n # binding.pry\n if current_user.save\n render json: current_user \n else\n render json: @user.errors, status: 422\n end\n\n end", "def add_friend\n # If there is no pending connection between persons,\n # add pendind/requested connections between them.\n # If there is already a pending connection requested from the other direction,\n # change friendship status to accepted.\n\n if (params['user_id'] == params['friend_id'])\n render_json :messages => \"Cannot add yourself to your friend.\", :status => :bad_request and return\n end\n\n if ! ensure_same_as_logged_person(params['user_id'])\n render_json :status => :forbidden and return\n end\n\n @person = Person.find_by_guid(params['user_id'])\n if ! @person\n render_json :status => :not_found and return\n end\n @friend = Person.find_by_guid(params['friend_id'])\n if ! @friend\n render_json :status => :not_found and return\n end\n\n if @person.association? or @friend.association?\n render_json :messages => \"Association users cannot have friends.\", :status => :bad_request and return\n end\n\n if @person.pending_contacts.include?(@friend) #accept if pending\n Connection.accept(@person, @friend)\n else\n unless @person.requested_contacts.include?(@friend) || @person.contacts.include?(@friend)\n Connection.request(@person, @friend) #request if didn't exist\n end\n end\n\n render_json :status => :ok\n end", "def add_first_friend\n if User.count > 0\n f = self.friendships.create!(:friend_id => User.find_by_username(DEFAULT_FRIEND_NAME).id)\n f.status=true;\n f.save\n end\n end", "def add_friend\n # byebug\n #we get user_id from jwt!\n user = User.find(decode_jwt(cookies.signed[:jwt])[\"user_id\"])\n #we get friend_id from frontend\n if !Block.where(blocker_id: user.id, blockee_id:follow_params[:user2]).empty?\n return render json: {error: \"There was a problem! (Ya been blocked!)\"}\n end\n\n followee = User.find(follow_params[:user2])\n #insert the one way relation in db!\n friend_request = Follow.new(follower_id: user.id, followee_id: followee.id)\n if friend_request.save\n render json: {friend_request: followee} \n else\n render json: {error: \"There was a problem!\"}\n end\n end", "def build_friendships\n graph = Koala::Facebook::API.new(self.f_token)\n friends = graph.get_connections('me', 'friends')\n\n # update users and user_user_link relation\n friends.each do |friend|\n user = User.where(:f_id => friend['id']).first_or_create\n user.update!({ :name => friend['name'] })\n user.update_friends_count\n self.user_user_links.where(:user_id => self.f_id, :friend_id => user.f_id).first_or_create\n end\n\n # delete user_user_link is not facebook friend anymore\n friend_ids = friends.collect{ |friend| friend['id'] }\n self.user_user_links.where('user_user_links.friend_id not in (?)', friend_ids).destroy_all\n\n self.update!({ :friends_updated_at => Time.now })\n end", "def create\n @friend = Friend.new(user_id: params[:user_id], friend_id: params[:friend_id])\n\n respond_to do |format|\n if @friend.save\n format.html { redirect_to @friend, notice: \"Friend was successfully created.\" }\n format.json { render :show, status: :created, location: @friend }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @friend.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_friend\n user = current_user\n @user = User.find_by_id(params[:id])\n @friendship = Friendship.find_by_friend_id_and_user_id(user.id,@user.id)\n if @friendship.nil? then\n @friendship = Friendship.new\n @friendship.user_id = user.id\n @friendship.friend_id = @user.id\n @friendship.accepted = false\n @friendship.save\n\n @typed = @friendship.class.to_s\n @az = @friendship\n activation_activity\n end\n\n respond_to do |format|\n format.js\n format.json\n end\n\n begin\n permissioning = Permissioning.find_by_user_id_and_network_id(user.id, current_network.id)\n mixpanel_properties = { \n 'Network' => current_network.name.capitalize,\n 'Subdomain' => current_network.subdomain,\n 'Role' => permissioning.role.title.capitalize\n }\n MixpanelTrackerWorker.perform_async user.id, 'Friend Requests', mixpanel_properties\n rescue\n puts \"\\e[1;31m[ERROR]\\e[0m error sending data to mixpanel\"\n end\n\n end", "def create\n @township = Township.new(township_params)\n\n respond_to do |format|\n if @township.save\n format.html { redirect_to @township, notice: 'Township was successfully created.' }\n format.json { render :show, status: :created, location: @township }\n else\n format.html { render :new }\n format.json { render json: @township.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n\n respond_to do |format|\n if @friendship.update(params.permit(:id, :accepted))\n # now build a friendship in the opposite direction\n @other_friendship = current_person.friendships.build(:granter_id => @friendship.requester_id, :accepted => true)\n @other_friendship.save\n\n format.html { redirect_to people_url, notice: 'You and ' + Person.find(@friendship.requester_id).name + ' are now friends!' }\n format.json { render :show, status: :ok, location: @friendship }\n else\n format.html { render :edit }\n format.json { render json: @friendship.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n # @friend = Friend.new(friend_params)\n @friend = current_user.friends.build(friend_params)\n respond_to do |format|\n if @friend.save\n format.html { redirect_to @friend, notice: I18n.t('friend.create') }\n format.json { render :show, status: :created, location: @friend }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @friend.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @friendships = Friendship.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @friendships }\n end\n end", "def index\n @friendships = Friendship.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @friendships }\n end\n end", "def create\n @friend = Friend.new(friend_params)\n\n if @friend.save\n render :show, status: :created, location: @friend\n else\n render json: @friend.errors, status: :unprocessable_entity\n end\n end", "def request_friendship_params\n params.require(:request_friendship).permit(:message, :status, :sender_id, :recipient_id)\n end", "def create\n @friendship = Friendship.create(:user_id => current_user.id, :friend_id => params[:friend_id], :accepted => false)\n if @friendship.save\n @az = @friendship\n @typed = @friendship.class.to_s\n activation_activity\n redirect_to :new_friends\n else\n redirect_to :new_friends\n end\n end", "def create\n @game = Game.find(params[:game_id])\n @game.authorships.create_from_names(params[:authorship])\n respond_to do |format|\n flash[:notice] = 'Les autheurs sont enregistres'\n format.html { redirect_to game_path(@game) }\n format.xml { head :created, :location => authorship_url(@authorship) }\n end\n end", "def set_friendship\n @friendship = current_api_user.friendships.find(params[:id])\n end", "def create\n respond_to do |format|\n if safe_create_friend\n format.html { redirect_to member_friends_path(@member), notice: 'Friend was successfully created.' }\n format.json { render :show, status: :created, location: @member }\n else\n format.html { render :new }\n format.json { render json: @friend.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n \n @ship = current_user.create_ship(ship_params)\n \n\n respond_to do |format|\n if @ship!=nil\n current_user.activeShip = @ship.id\n if @ship.save\n format.html { redirect_to @ship, notice: 'Ship was successfully created.' }\n format.json { render :show, status: :created, location: @ship }\n else\n format.html { render :new }\n format.json { render json: @ship.errors, status: :unprocessable_entity }\n end\n else\n format.html { redirect_to ships_path, notice: 'Kauf nicht erfolgreich!' }\n \n end\n end\n end", "def create_request\n Friendship.request(@user, @friend)\n flash[:notice] = \"Friend request sent.\"\n redirect_to :back\n end", "def create\n @ship = Ship.new(params[:ship])\n respond_to do |format|\n if @ship.save\n format.html { redirect_to @ship, notice: 'Ship was successfully created.' }\n format.json { render json: @ship, status: :created, location: @ship }\n else\n format.html { render action: \"new\" }\n format.json { render json: @ship.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n user = User.find(params[:user_id])\n friend_request = user.incoming_requests.build(sender_id: current_user.id)\n if friend_request.save\n if friend_request.sender == current_user\n respond_to do |format|\n format.html { redirect_back(fallback_location: root_path, notice: \"Friend request sent to #{user.name}.\") }\n format.json do\n render json: {\n request: {\n id: friend_request.id,\n name: friend_request.sender.name\n },\n message: \"Friend request sent to #{user.name}.\"\n }\n end\n end\n else\n redirect_back(fallback_location: root_path, notice: \"Friend request sent to #{user.name}.\")\n end\n else\n redirect_back(fallback_location: root_path, alert: 'Friend request could not be sent.')\n end\n end", "def create\n @friend = Friend.new(params[:friend])\n\n respond_to do |format|\n if @friend.save\n format.html { redirect_to @friend, notice: 'Friend was successfully created.' }\n format.json { render json: @friend, status: :created, location: @friend }\n else\n format.html { render action: \"new\" }\n format.json { render json: @friend.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @pending_friend_request = PendingFriendRequest.new(pending_friend_request_params)\n\n respond_to do |format|\n if @pending_friend_request.save\n format.html { redirect_to '/profile', notice: 'Friend request sent!' }\n format.json { render action: 'show', status: :created, location: @pending_friend_request }\n else\n format.html { render action: 'new' }\n format.json { render json: @pending_friend_request.errors, status: :unprocessable_entity }\n end\n end\n end", "def follow!(new_friend)\n\t\tresponse = access_token.post(\"/friendships/create/#{new_friend}.json\")\n\t\tcase response\n\t\twhen Net::HTTPSuccess\n\t\t\tfriend=JSON.parse(response.body)\n\t\t\traise TwitterOauth::UnexpectedResponse unless friend.is_a? Hash\n\t\t\tfriend\n\t\telse\n\t\t\traise TwitterOauth::APIError\n\t\tend\n\trescue => err\n\t\tputs \"Exception in follow!: #{err}\"\n\t\traise err\n\tend", "def create\n relationship = Relationship.between(current_user.id, params[:user_two_id]).first\n unless relationship\n current_user.add_friend(User.find(params[:user_two_id]))\n relationship = Relationship.between(current_user.id, params[:user_two_id]).first\n relationship.status = 1\n relationship.save\n end\n friend = User.find_friend(current_user, relationship)\n redirect_to friendlist_path\n end", "def add_friends\n @params[:friend_ids].each do |id|\n @plan.users_plans.new(user_id: id)\n end\n end" ]
[ "0.7818167", "0.7393506", "0.73249245", "0.729346", "0.7141652", "0.7051172", "0.69890857", "0.69552326", "0.69517946", "0.68621576", "0.6860564", "0.6857097", "0.6840203", "0.6809342", "0.6780816", "0.67396927", "0.67190844", "0.67190844", "0.67190844", "0.67190844", "0.67090535", "0.6707801", "0.66576856", "0.6595578", "0.65750253", "0.65553105", "0.6537647", "0.6534639", "0.6515193", "0.65124923", "0.65051997", "0.6499865", "0.64921844", "0.64514136", "0.64498305", "0.6429372", "0.64039606", "0.6391231", "0.63310975", "0.63065004", "0.63065004", "0.6301889", "0.6287357", "0.62769127", "0.62306273", "0.6217391", "0.62141573", "0.6150652", "0.61426616", "0.6140622", "0.61271524", "0.6125033", "0.6106018", "0.61023504", "0.6100411", "0.609226", "0.60849553", "0.6084908", "0.6045633", "0.60424966", "0.6035095", "0.60343415", "0.60296136", "0.60212713", "0.5999717", "0.5988667", "0.5983934", "0.59824514", "0.59486413", "0.5942778", "0.59363216", "0.5931928", "0.59130675", "0.5893198", "0.58804464", "0.5874952", "0.5871618", "0.58660513", "0.5852322", "0.5851729", "0.5842673", "0.58334595", "0.58147526", "0.5810568", "0.5810568", "0.58018136", "0.57904893", "0.5775523", "0.57582366", "0.57576144", "0.5751708", "0.5738752", "0.5734017", "0.57310385", "0.5727707", "0.5718665", "0.57050216", "0.56886697", "0.5686057", "0.5679933" ]
0.60648686
58
PATCH/PUT /friendships/1 PATCH/PUT /friendships/1.json
def update if params[:status] == "accepted" @friendship = current_user.friendships.build(:friend_id => params[:friend_id], :status => 'accepted') friend = User.find(params[:friend_id]) @friendship2 = friend.friendships.build(:friend_id => params[:user_id], :status => 'accepted') respond_to do |format| if @friendship.save format.html { redirect_to @friendship, notice: 'Your Connection Request has been sent' } format.json { render action: 'show', status: :created, location: @friendship } else format.html { render action: 'new' } format.json { render json: @friendship.errors, status: :unprocessable_entity } end if @friendship2.save format.html { redirect_to @friendship2, notice: 'You received a friendship invitation' } format.json { render action: 'show', status: :created, location: @friendship2 } else format.html { render action: 'new' } format.json { render json: @friendship2.errors, status: :unprocessable_entity } end end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def friendships_update(options = {})\n @req.post(\"/1.1/friendships/update.json\", options)\n end", "def update\n @friendship = @user.friendships.find(params[:id])\n\n respond_to do |format|\n if @friendship.update_attributes(params[:friendship])\n format.html { redirect_to [@game, @user, @friendship], notice: 'Friendship was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @friendship.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @friendship = Friendship.find(params[:id])\n\n respond_to do |format|\n if @friendship.update_attributes(params[:friendship])\n format.html { redirect_to @friendship, notice: 'Friendship was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @friendship.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @friendship = Friendship.find(params[:id])\n\n respond_to do |format|\n if @friendship.update_attributes(params[:friendship])\n format.html { redirect_to @friendship, notice: 'Friendship was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @friendship.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @friendship.update(friendship_params)\n format.html { redirect_to @friendship, notice: 'friendship was successfully updated.' }\n format.json { render :show, status: :ok, location: @friendship }\n else\n format.html { render :edit }\n format.json { render json: @friendship.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @friendship.update(friendship_params)\n format.html { redirect_to @friendship, notice: 'Friendship was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @friendship.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @friendship.update(friendship_params)\n format.html { redirect_to @friendship, notice: 'Friendship was successfully updated.' }\n format.json { render :show, status: :ok, location: @friendship }\n else\n format.html { render :edit }\n format.json { render json: @friendship.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @friendship.update(friendship_params)\n format.html { redirect_to @friendship, notice: 'Friendship was successfully updated.' }\n format.json { render :show, status: :ok, location: @friendship }\n else\n format.html { render :edit }\n format.json { render json: @friendship.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n\n respond_to do |format|\n if @friendship.update(params.permit(:id, :accepted))\n # now build a friendship in the opposite direction\n @other_friendship = current_person.friendships.build(:granter_id => @friendship.requester_id, :accepted => true)\n @other_friendship.save\n\n format.html { redirect_to people_url, notice: 'You and ' + Person.find(@friendship.requester_id).name + ' are now friends!' }\n format.json { render :show, status: :ok, location: @friendship }\n else\n format.html { render :edit }\n format.json { render json: @friendship.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @friendship.update(friendship_params)\n format.html { redirect_to @friendship, notice: \"Friend request accepted!\" }\n format.json { render :show, status: :ok, location: @friendship }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @friendship.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @friendship = Friendship.find(params[:id])\n (@friendship.is_confirmed? || @friendship.proposer == current_user) ? (friend_notice = \"Friendship was successfully updated\") : (friend_notice = \"You accepted the friend request\")\n @friendship.confirmed = true unless @friendship.proposer == current_user\n @incoming_friend_requests = Friendship.where({\n proposee_id: current_user.id,\n confirmed: nil\n })\n respond_to do |format|\n if @friendship.update_attributes(params[:friendship])\n @grouped_friends = current_user.grouped_friends\n format.html { redirect_to @friendship, notice: friend_notice}\n format.json { head :no_content }\n format.js {}\n else\n @grouped_friends = current_user.grouped_friends\n format.html { render action: \"edit\" }\n format.json { render json: @friendship.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @request_friendship.update(request_friendship_params)\n format.html { redirect_to @request_friendship, notice: 'La solicitud de amistad se ha actualizado correctamente.' }\n format.json { render :show, status: :ok, location: @request_friendship }\n else\n format.html { render :edit }\n format.json { render json: @request_friendship.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @friendship = Friendship.find(params[:id])\n\n respond_to do |format|\n if @friendship.update_attributes(params[:friendship])\n format.html { redirect_to(@friendship, :notice => 'Friendship was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @friendship.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n friendship_new = Friendship.new\n friendship_new.user1_id = @friendship.user2_id\n friendship_new.user2_id = @friendship.user1_id\n friendship_new.approved = true\n friendship_new.save!\n @friendship.approved = true\n respond_to do |format|\n if @friendship.save\n format.html { redirect_to back_page, flash: { :success => 'Friendship was approved.' } }\n format.json { render :index, status: :ok, location: @friendship }\n else\n set_index_friendships\n format.html { render :index }\n format.json { render json: @friendship.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @friendship = Friendship.find(params[:id])\n\n if (params[:ignore])\n @friendship.ignore = params[:ignore] == \"true\"\n end\n\n respond_to do |format|\n if @friendship.update_attributes(params[:friendship])\n format.html { render @friendship }\n format.json { render json: { success: true } }\n else\n format.html { render action: \"index\" }\n format.json { render json: @friendship.errors, \n status: :unprocessable_entity }\n end\n end\n end", "def update\n @friend = Friend.find(params[:id])\n @friend.update_attributes(params[:friend])\n respond_with(@friend)\n end", "def update_friends\n @user = User.find(params[:id])\n\n respond_to do |format|\n if @user.update_attributes(params[:user])\n flash[:notice] = 'Your friends were updated successfully.'\n format.html { redirect_to(user_friendships_path(@user)) }\n else\n format.html { render :action => \"edit\" }\n end\n end\n \n end", "def update\n respond_to do |format|\n if @pending_friend_request.update(pending_friend_request_params)\n format.html { redirect_to @pending_friend_request, notice: 'Pending friend request was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @pending_friend_request.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_friendship\n @friendship = current_api_user.friendships.find(params[:id])\n end", "def update\n respond_to do |format|\n if @fellowship.update(fellowship_params)\n format.html { redirect_to @fellowship, notice: 'Fellowship was successfully updated.' }\n format.json { render :show, status: :ok, location: @fellowship }\n else\n format.html { render :edit }\n format.json { render json: @fellowship.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @friend_request = FriendRequest.find(params[:id])\n\n respond_to do |format|\n if @friend_request.update_attributes(params[:friend_request])\n format.html { redirect_to @friend_request, notice: 'Friend request was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @friend_request.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @friendrequest = Friendrequest.find(params[:id])\n\n respond_to do |format|\n if @friendrequest.update_attributes(params[:friendrequest])\n format.html { redirect_to @friendrequest, notice: 'Friendrequest was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @friendrequest.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @friend_request.update(update_friend_request_params)\n format.html { redirect_to friends_path, notice: 'Friend request was successfully updated.' }\n format.json { render :show, status: :ok, location: @friend_request }\n else\n format.html { render :edit }\n format.json { render json: @friend_request.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @friend.update(friend_params)\n format.html { redirect_to @friend, notice: I18n.t('friend.update') }\n format.json { render :show, status: :ok, location: @friend }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @friend.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @friendship.update_attributes(:accept => params[:accept])\n format.html { redirect_to @friendship, notice: 'Friendship is successfully updated.' }\n format.json { render :show, status: :ok, location: @friendship }\n else\n format.html { render :edit }\n format.json { render json: @friendship.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if @friend.update(friend_params)\n render :show, status: :ok, location: @friend\n else\n render json: @friend.errors, status: :unprocessable_entity\n end\n end", "def update\n # no spoofing of acceptance\n params[:friendship].delete('accepted_at') if params[:friendship][:accepted_at]\n \n respond_to do |format|\n if @friendship.update_attributes(params[:friendship])\n flash[:notice] = 'Friendship was successfully updated.'\n format.html { redirect_to user_friendship_path(@friendship.user_id, @friendship) }\n else\n format.html { render :action => \"edit\" }\n end\n end\n end", "def update\n @friend = Friend.find(params[:id])\n\n respond_to do |format|\n if @friend.update_attributes(params[:friend])\n format.html { redirect_to @friend, notice: 'Friend was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @friend.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @friends1.update(friends1_params)\n format.html { redirect_to @friends1, notice: \"Friend was successfully updated.\" }\n format.json { render :show, status: :ok, location: @friends1 }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @friends1.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @friendship = Friendship.find_by_user_id_and_friend_id(current_user.id,params[:friend_id])\n if @friendship.nil? then\n @friendship = Friendship.find_by_user_id_and_friend_id(params[:friend_id],current_user.id)\n end\n @friendship.update_attributes(:accepted => true)\n redirect_to :show_friends\n end", "def update\n @clientship = current_user.clientships.find(params[:id])\n\n respond_to do |format|\n if @clientship.update_attributes(params[:clientship])\n format.html { redirect_to @clientship, notice: 'Clientship was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @clientship.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @friendrequest.update(friendrequest_params)\n format.html { redirect_to @friendrequest, notice: 'Friendrequest was successfully updated.' }\n format.json { render :show, status: :ok, location: @friendrequest }\n else\n format.html { render :edit }\n format.json { render json: @friendrequest.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @friend.update(friend_params)\n format.html { redirect_to @friend, notice: \"Friend was successfully updated.\" }\n format.json { render :show, status: :ok, location: @friend }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @friend.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @friend.update(friend_params)\n format.html { redirect_to @friend, notice: \"Friend was successfully updated.\" }\n format.json { render :show, status: :ok, location: @friend }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @friend.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @friend.update(friend_params)\n format.html { redirect_to @friend, notice: 'Friend was successfully updated.' }\n format.json { render :show, status: :ok, location: @friend }\n else\n format.html { render :edit }\n format.json { render json: @friend.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @friend.update(friend_params)\n format.html { redirect_to @friend, notice: 'Friend was successfully updated.' }\n format.json { render :show, status: :ok, location: @friend }\n else\n format.html { render :edit }\n format.json { render json: @friend.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @friend.update(friend_params)\n format.html { redirect_to @friend, notice: 'Friend was successfully updated.' }\n format.json { render :show, status: :ok, location: @friend }\n else\n format.html { render :edit }\n format.json { render json: @friend.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @friend.update(friend_params)\n format.html { redirect_to @friend, notice: 'Friend was successfully updated.' }\n format.json { render :show, status: :ok, location: @friend }\n else\n format.html { render :edit }\n format.json { render json: @friend.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @friend.update(friend_params)\n format.html { redirect_to @friend, notice: 'Friend was successfully updated.' }\n format.json { render :show, status: :ok, location: @friend }\n else\n format.html { render :edit }\n format.json { render json: @friend.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @followship.update(followship_params)\n format.html { redirect_to @followship, notice: 'Followship was successfully updated.' }\n format.json { render :show, status: :ok, location: @followship }\n else\n format.html { render :edit }\n format.json { render json: @followship.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @friendslist = Friendslist.find(params[:id])\n\n respond_to do |format|\n if @friendslist.update_attributes(params[:friendslist])\n format.html { redirect_to @friendslist, notice: 'Friendslist was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @friendslist.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_friendships\n if has_to_update_friendships?\n graph = Koala::Facebook::API.new(self.f_token)\n friends = graph.get_connections('me', 'friends')\n\n # update users and user_user_link relation\n friends.each do |friend|\n Rails.logger.info(friend.inspect)\n\n user = User.find_or_create_by_f_id(friend['id'])\n user.update_attributes!({ :name => friend['name'] })\n self.user_user_links.find_or_create_by_user_id_and_friend_id(self.f_id, user.f_id)\n end\n\n # delete user_user_link is not facebook friend anymore\n friend_ids = friends.collect{ |friend| friend['id'] }\n self.user_user_links.where('user_user_links.friend_id not in (?)', friend_ids).destroy_all\n\n self.update_attributes!({ :friends_updated_at => Time.now })\n end\n end", "def update\r\n respond_to do |format|\r\n if @followship.update(followship_params)\r\n format.html { redirect_to @followship, notice: 'Followship was successfully updated.' }\r\n format.json { render :show, status: :ok, location: @followship }\r\n else\r\n format.html { render :edit }\r\n format.json { render json: @followship.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end", "def update\n @friend_request = FriendRequest.find(params[:id])\n respond_to do |format|\n if @friend_request.update_attributes(params[:friend_request])\n format.html { redirect_to(@friend_request, :notice => 'Friend request was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @friend_request.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @user = User.find(params[:id])\n @user.friend_ids = params[:friend_ids]\n @user.save\n end", "def update\n respond_to do |format|\n if @friends_list.update(friends_list_params)\n format.html { redirect_to @friends_list, notice: \"Friend's info successfully updated.\" }\n format.json { render :show, status: :ok, location: @friends_list }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @friends_list.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_friendship\n @friendship = Friendship.find(params[:id])\n end", "def update\n respond_to do |format|\n if @call_your_friend.update(call_your_friend_params)\n format.html { redirect_to @call_your_friend, notice: 'Call your friend was successfully updated.' }\n format.json { render :show, status: :ok, location: @call_your_friend }\n else\n format.html { render :edit }\n format.json { render json: @call_your_friend.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_friendship\n @friendship = Friendship.find(params[:id])\n end", "def set_friendship\n @friendship = Friendship.find(params[:id])\n end", "def set_friendship\n @friendship = Friendship.find(params[:id])\n end", "def set_friendship\n @friendship = Friendship.find(params[:id])\n end", "def set_friendship\n @friendship = Friendship.find(params[:id])\n end", "def set_friendship\n @friendship = Friendship.find(params[:id])\n end", "def set_friendship\n @friendship = Friendship.find(params[:id])\n end", "def set_friendship\n @friendship = Friendship.find(params[:id])\n end", "def set_friendship\n @friendship = Friendship.find(params[:id])\n end", "def set_friendship\n @friendship = Friendship.find(params[:id])\n end", "def set_friendship\n @friendship = Friendship.find(params[:id])\n end", "def update\n relationship = Relationships.find(params[:id])\n if relationship.update(relationship_params)\n render json: relationship, status: 200\n else\n render json: { errors: relationship.errors }, status: 422\n end\n end", "def update\n @friendship = Friendship.find_by(sender_id: params[:user_id], receiver_id: current_user.id, status: false)\n return unless @friendship\n\n @friendship.status = true\n if @friendship.save\n flash[:success] = \"Request accepted\"\n @friendship_mutual = current_user.friend_sent.build(receiver_id: params[:user_id], status: true)\n @friendship_mutual.save\n else\n flash[:warning] = \"Request failed\"\n end\n\n redirect_back fallback_location: root_url\n end", "def friendships_params\n params.require(:friendships).permit(:user_id, :friend_id, :confirmed)\n end", "def update\n respond_to do |format|\n if @friends_list.update(friends_list_params)\n format.html { redirect_to @friends_list, notice: 'Friends list was successfully updated.' }\n format.json { render :show, status: :ok, location: @friends_list }\n else\n format.html { render :edit }\n format.json { render json: @friends_list.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_friendship\n @friendship = Friendship.find(params[:id])\n end", "def update\n respond_to do |format|\n if @friendlist.update(friendlist_params)\n format.html { redirect_to @friendlist, notice: 'Friendlist was successfully updated.' }\n format.json { render :show, status: :ok, location: @friendlist }\n else\n format.html { render :edit }\n format.json { render json: @friendlist.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @friend = Friend.find(params[:id])\n\n respond_to do |format|\n if @friend.update_attributes(params[:friend])\n format.html { redirect_to(@friend, :notice => 'Friend was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @friend.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n if params[:status] == 'accept'\n @friendship.accepted! \n flash[:notice] = t('friendship.accept')\n elsif params[:status] == 'ignore'\n @friendship.rejected!\n flash[:notice] = t('friendship.ignore')\n end\n redirect_to friendships_path\n end", "def update\n @friend_request = FriendRequest.find(params[:id])\n\n respond_to do |format|\n if @friend_request.update_attributes(params[:friend_request])\n flash[:notice] = 'FriendRequest was successfully updated.'\n format.html { redirect_to(@friend_request) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @friend_request.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @group_friend.update(group_friend_params)\n format.html { redirect_to @group_friend, notice: 'Group friend was successfully updated.' }\n format.json { render :show, status: :ok, location: @group_friend }\n else\n format.html { render :edit }\n format.json { render json: @group_friend.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_request_friendship\n @request_friendship = RequestFriendship.find(params[:id])\n end", "def update\n @friendship_sent_request = FriendshipSentRequest.find(params[:id])\n\n respond_to do |format|\n if @friendship_sent_request.update_attributes(params[:friendship_sent_request])\n format.html { redirect_to(profile_url, :notice => 'Friendship sent request was successfully updated.') }\n\n else\n format.html { render :action => \"edit\" }\n\n end\n end\n end", "def update\n @admin_customer_friend = Admin::Customer::Friend.find_by_id(params[:id])\n success = @admin_customer_friend.on_update(params[:admin_customer_friend])\n respond_to do |format|\n if success\n @storyline.describe \"Updating friend #{@admin_customer_friend.name}\"\n format.json { head :ok }\n format.js\n else\n @storyline.describe \"Updating friend errors: #{@admin_customer_friend.errors.full_messages}\"\n format.json { render json: @admin_customer_friend.errors, status: :unprocessable_entity }\n format.js\n end\n end\n end", "def friend\n @user.friendships.build(friend_id: @friend.id)\n if @user.save\n render json: { success: true }\n else\n render json: {message: @user.errors&.messages || 'Unable add as friend, please try again'}, status: 202\n end\n end", "def friendship_params\n params.require(:friendship).permit(:user_id, :friend_id, :status)\n end", "def update\n @ship = Ship.find(params[:id])\n\n respond_to do |format|\n if @ship.update_attributes(params[:ship])\n format.html { redirect_to @ship, notice: 'Ship was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @ship.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @my_girlfriend.update(my_girlfriend_params)\n format.html { redirect_to @my_girlfriend, notice: 'My girlfriend was successfully updated.' }\n format.json { render :show, status: :ok, location: @my_girlfriend }\n else\n format.html { render :edit }\n format.json { render json: @my_girlfriend.errors, status: :unprocessable_entity }\n end\n end\n end", "def friendship_params\n params.fetch(:friendship).permit(:user_id, :friend_id)\n end", "def update\n @friend = Friend.find(params[:id])\n\n respond_to do |format|\n if @friend.update_attributes(params[:friend])\n flash[:notice] = 'Friend was successfully updated.'\n format.html { redirect_to(@friend) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @friend.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @ship = Ship.find(params[:id])\n\n respond_to do |format|\n if @ship.update_attributes(params[:ship])\n format.html { redirect_to @ship, notice: 'Ship was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @ship.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @friendsofuser = Friendsofuser.find(params[:id])\n\n respond_to do |format|\n if @friendsofuser.update_attributes(params[:friendsofuser])\n flash[:notice] = 'Friendsofuser was successfully updated.'\n format.html { redirect_to(@friendsofuser) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @friendsofuser.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n\t\t@friend = Friend.find(params[:user_id])\n\t\t@invite = Friend.find(params[:friend_id]) \n\n\t\tif @friend.update_attributes(params['friend']) \n\t\t\tredirect_to :back\n\t\tend\t\n\tend", "def set_friendship\n @friendship = User.find_by(id: params[:id])\n end", "def friendship_params\n params.require(:friendship).permit(:user_id, :friend_id, :mutual_friend_id)\n end", "def update\n respond_to do |format|\n if @manifestship.update(manifestship_params)\n format.html { redirect_to @manifestship, notice: 'Manifestship was successfully updated.' }\n format.json { render :show, status: :ok, location: @manifestship }\n else\n format.html { render :edit }\n format.json { render json: @manifestship.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @friendship1 = Friendship.where(friend_id: current_user.id, user_id: params[:id]).first\n @friendship2 = Friendship.where(friend_id: params[:id], user_id: current_user.id).first\n @friendship1.update(approved: true)\n @friendship2.update(approved: true)\n if @friendship1.save && @friendship2.save\n redirect_to :back, :notice => \"Successfully confirmed friend!\"\n else\n redirect_to :back, :notice => \"Sorry! Could not confirm friend!\"\n end\n end", "def set_friendship\n end", "def friendship_params\n params.require(:friendship).permit(:user_id, :friend_id)\n end", "def update\n @friendship = Friendship.where(friend_id: current_user, user_id: params[:id]).first\n @friendship.update(approved: true)\n if @friendship.save\n redirect_to :back, :notice => \"Successfully confirmed friend!\"\n else\n redirect_to :back, :notice => \"Sorry! Could not confirm friend!\"\n end\n end", "def friendship_params\n params.require(:friendship).permit(:user_id, :friend_id)\n end", "def update\n respond_to do |format|\n if @fleet_ship.update(fleet_ship_params)\n format.html { redirect_to @fleet_ship, notice: 'Fleet ship was successfully updated.' }\n format.json { render :show, status: :ok, location: @fleet_ship }\n else\n format.html { render :edit }\n format.json { render json: @fleet_ship.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @friendship = Friendship.where(friend_id: current_user, user_id: params[:id]).first\n @friendship.update(approved: true)\n if @friendship.save\n redirect_to root_url, :notice => \"Successfully confirmed friend!\"\n else\n redirect_to root_url, :notice => \"Sorry! Could not confirm friend!\"\n end\n end", "def update\n @friend = Friend.find(params[:id],:conditions=>{:created_by=>current_user.id})\n\n respond_to do |format|\n if @friend.update_attributes(params[:friend])\n format.html { redirect_to(groups_path, :notice => \"Group #{@friend.group.name} was updated.\") }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @friend.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n # go to params hash and get the id\n the_id = params['id']\n\n # grab a single family based on the id\n family = Family.find_by(id: the_id)\n\n # update it\n if family.update!(\n first_name: params[:first_name],\n last_name: params[:last_name],\n email: params[:email],\n password: params[:password],\n phone_number: params[:phone_number],\n street_address: params[:street_address],\n secondary_address: params[:secondary_address],\n city: params[:city],\n state: params[:state],\n zip_code: params[:zip_code],\n photo: params[:photo])\n render json: family.as_json\n else\n render json: {errors: family.errors.full_messages}\n end\n end", "def create_or_update_friendship(friend)\n if Friendship.find_by(user_id: friend.id, friend_id: id) ||\n Friendship.find_by(user_id: id, friend_id: friend.id)\n friendship = Friendship.find_by(user_id: friend.id, friend_id: id) ||\n Friendship.find_by(user_id: id, friend_id: friend.id)\n friendship.update(status: \"pending\")\n else\n Friendship.create(user_id: id, friend_id: friend.id, status: \"pending\")\n send_friend_request_email(friend.email, self.username)\n end\n end", "def update\n respond_to do |format|\n if @girlfriend.update(girlfriend_params)\n format.html { redirect_to @girlfriend, notice: 'Girlfriend was successfully updated.' }\n format.json { render :show, status: :ok, location: @girlfriend }\n else\n format.html { render :edit }\n format.json { render json: @girlfriend.errors, status: :unprocessable_entity }\n end\n end\n end", "def show\n @friendship = @user.friendships.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @friendship }\n end\n end", "def friendship_params\n params.require(:friendship).permit(:user_id, :user_name, :friend_id, :friend_name)\n end", "def update\n respond_to do |format|\n if @ship.update(ship_params)\n format.html { redirect_to @ship, notice: 'Ship was successfully updated.' }\n format.json { render :show, status: :ok, location: @ship }\n else\n format.html { render :edit }\n format.json { render json: @ship.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @friend_one = Friend.where(user_id: current_user.id, friend_id: @friend.friend_id)\n @friend_one.update(status: true)\n Friend.create!(user_id: @friend.friend_id, friend_id: current_user.id, status: true)\n redirect_to user_path(current_user)\n flash[:notice] =\n \"You and #{@friend.friend.name} are now Friends ! \"\n end", "def update\n respond_to do |format|\n if @shipfleet.update(shipfleet_params)\n format.html { redirect_to @shipfleet, notice: 'Shipfleet was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @shipfleet.errors, status: :unprocessable_entity }\n end\n end\n end" ]
[ "0.75791544", "0.7365749", "0.7171268", "0.7171268", "0.7102057", "0.7068277", "0.7033859", "0.7033859", "0.694694", "0.69351727", "0.68741876", "0.68689406", "0.68521154", "0.6838455", "0.6747497", "0.66983867", "0.66889864", "0.66092294", "0.65870005", "0.6572818", "0.6539613", "0.6536217", "0.65150774", "0.64819", "0.6461069", "0.64469725", "0.6441032", "0.6440248", "0.6404639", "0.6403931", "0.6402485", "0.6400827", "0.63932496", "0.63932496", "0.63789123", "0.63789123", "0.63789123", "0.63789123", "0.63789123", "0.6265496", "0.6203911", "0.6195033", "0.61946446", "0.61885494", "0.6186366", "0.6183025", "0.61762893", "0.61489767", "0.6146556", "0.6146556", "0.6146556", "0.6146556", "0.6146556", "0.6146556", "0.6146556", "0.6146556", "0.6146556", "0.6146556", "0.6146556", "0.61350524", "0.61337376", "0.61143386", "0.6112332", "0.6111616", "0.61065924", "0.6100594", "0.6078579", "0.6075509", "0.6073283", "0.60574526", "0.60404414", "0.6034786", "0.6021702", "0.60132587", "0.5998651", "0.5995152", "0.5994414", "0.5990865", "0.5990242", "0.59844095", "0.5982667", "0.5961448", "0.59606445", "0.59540635", "0.59525317", "0.5940642", "0.5938617", "0.5930922", "0.5927913", "0.59154844", "0.5912657", "0.5907227", "0.5895601", "0.5877045", "0.5876314", "0.587451", "0.5873674", "0.5870824", "0.58699524", "0.5868412" ]
0.6769694
14
DELETE /friendships/1 DELETE /friendships/1.json
def destroy @friendship.destroy respond_to do |format| format.html { redirect_to friendships_url } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @friendship = @user.friendships.find(params[:id])\n @friendship.destroy\n\n respond_to do |format|\n format.html { redirect_to game_user_friendships_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @friendship = Friendship.find(params[:id])\n @friendship.destroy\n\n respond_to do |format|\n format.html { redirect_to friendships_url }\n format.json { head :no_content }\n end\n end", "def destroy\n logger.info(\"Delete friend_id 33333\")\n logger.info(\"Delete friend_id #{params[:user_id]}\")\n @friendship.destroy\n if request.format.json?\n render text: \"Delete\"\n else\n @friendship.destroy\n redirect_to friendships_url \n end \n end", "def destroy\n @friendship.destroy\n respond_to do |format|\n format.html { redirect_to friendships_url, notice: \"Friens request denied\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @friendship = Friendship.find(params[:id])\n @friendship.destroy\n\n respond_to do |format|\n format.html { redirect_to(friendships_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @request_friendship.destroy\n respond_to do |format|\n format.html { redirect_to request_friendships_url, notice: 'La solicitud de amistad fue eliminada con éxito.' }\n format.json { head :no_content }\n end\n end", "def destroy\n puts 'callin'\n friendship = Friendship.find(params[:id])\n user = friendship.user\n friend = friendship.friend\n reciprocal_friendship = Friendship.find_by(user: friend, friend: user)\n friendship.destroy\n reciprocal_friendship.destroy\n respond_to do |format|\n # format.html do\n # { redirect_back(fallback_location: root_path, notice: \"Friendship with #{friend.name} ended.\") }\n format.json do\n render json: {\n status: 'deleted',\n notice: \"Friendship with #{friend.name} ended.\"\n }\n end\n end\n end", "def destroy\n # prevent user from deleting a friendship which cannot be found.\n if !(@friendship)\n render json: {error: \"Friendship not found\"}, status: 404\n else\n @friendship.destroy\n render status: 204\n end\n end", "def destroy\n @friendship = current_user.friendships.find_by_id(params[:id])\n @friendship = current_user.inverse_friendships.find_by_id(params[:id]) unless @friendship.present? \n @friendship.destroy\n respond_to do |format|\n format.html { redirect_to user_friend_url(current_user), notice: 'Friendship was successfully Removed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @friendship = current_user.friendships.find(params[:id])\n @friendship.destroy\n flash[:notice] = \"Removed friendship.\"\n redirect_to current_user\n end", "def delete_friendship\n user = User.find(params[:user_id])\n @friendship = user.friendships.where(friend_id: params[:friend_id]).first ||\n user.inverse_friendships.where(friend_id: params[:user_id]).first\n if @friendship.present? # Can't call exists on a single record\n @friendship.delete\n render status: :ok, json: {\n message: 'Successfully deleted friendship'\n }.to_json\n else\n render status: :bad_request, json: {\n message: 'No friendship to delete'\n }\n end\n end", "def destroy\n if @friend\n @friend.destroy\n else\n @friendship.destroy\n end\n respond_to do |format|\n format.html { redirect_to friendships_url, notice: 'Friendship was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @friendship = Friendship.find(params[:id])\n @friendship_mutual = Friendship.where(:user_id => @friendship.friend_id).first\n @friendship.destroy \n @friendship_mutual.destroy\n respond_to do |format|\n format.html { redirect_to root_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @friendship = @current_user.friendships.find_by(friendship_params)\n @inverse_friendship = @current_user.inverse_friendships.find_by(@friendship.friend_id)\n @friendship.destroy\n @inverse_friendship.destroy\n\n head :no_content\n end", "def destroy\n other = Friendship.find_by(user: @friendship.friend, friend: @friendship.user)\n other.destroy unless other.nil?\n @friendship.destroy\n respond_to do |format|\n format.html { redirect_to current_user, notice: 'Friendship was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @friend = current_user.friendships.find(params[:id])\n @friend.destroy\n flash[:notice] = \"Removed friend.\"\n redirect_to current_user\n end", "def destroy\n @friendship = Friendship.find(params[:id]).destroy\n redirect_to users_url\n end", "def destroy\n #Deletes the friendship (both ways)\n @user=current_user\n friend=User.find_by_email(params[:email])\n if(friend)\n friendCheck=Friendship.find_by_user_id_and_friend_id(@user.id, friend.id)\n if(friendCheck)\n @friendship = @user.friendships.find_by_friend_id(friend.id)\n @friendship.destroy\n @friendship = friend.friendships.find_by_friend_id(@user.id)\n @friendship.destroy\n\n respond_to do |format|\n format.html { redirect_to root_url }\n format.json { render json: {:deleted => 'true'}}\n end\n else\n respond_to do |format|\n format.html { redirect_to root_url }\n format.json { render json: {:deleted => 'false'}}\n end\n end\n else\n respond_to do |format|\n format.html { redirect_to root_url }\n format.json { render json: {:deleted => 'false'}}\n end\n end\n end", "def destroy\n second_friendship = Friendship.find_by(:user1_id => @friendship.user2_id)\n @friendship.destroy\n second_friendship.destroy if second_friendship\n \n respond_to do |format|\n format.html { redirect_to back_page, flash: { :success => 'Friendship was deleted.' } }\n format.json { head :no_content }\n end\n end", "def delete_friend\n \t#friend = User.find(params[:friend_id])\n respond_to do |format|\n \tif @user.friends.include?(@friend)\n Friendship.breakup(@user, @friend)\n message = \"Friendship with #{@friend.nick_name} deleted!\"\n format.json{render :json => {:message => message, :status => \"200\"}}\n else\n error = \"You aren't friends with #{@friend.nick_name}\"\n format.json { render :json => {:error => error, :status => \"400\"} }\n end\n end\n end", "def destroy_friendship(user, params = {})\n args = [user, params]\n delete path_from_args('friendships/destroy', args), params_from_args(args)\n end", "def destroy\n @friendship = current_user.friendships.find(params[:id])\n @friendship.destroy\n flash[:notice] = \"Removed friendship.\"\n redirect_to posts_path\n end", "def destroy\n @friendship = @current_user.friendships.find_by_id(params[:id])\n if @friendship.destroy\n flash[:success] = \"This relationship has been deleted\"\n else\n flash[:error] = \"Delete failed, if you really want, please try again\"\n end\n redirect_to(individual_path(@current_user))\n end", "def destroy\n @friendship.destroy\n respond_to do |format|\n format.html { redirect_to :back, notice: 'Friendship was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def friendships_destroy(options = {})\n @req.post(\"/1.1/friendships/destroy.json\", options)\n end", "def destroy\n @friend_request = FriendRequest.find(params[:id])\n @friend_request.destroy\n\n respond_to do |format|\n format.html { redirect_to friend_requests_url }\n format.json { head :ok }\n end\n end", "def destroy\n @friendrequest = Friendrequest.find(params[:id])\n @friendrequest.destroy\n\n respond_to do |format|\n format.html { redirect_to friendrequests_url }\n format.json { head :no_content }\n end\n end", "def unfriend\n if relation = @user.friendships.find_by(friend_id: @friend.id)\n relation.destroy\n render json: { success: true }\n else\n render json: {message: relation.errors&.full_messages&.first}, status: 202\n end\n end", "def destroy\n @friend.destroy\n render json: {}\n end", "def destroy\n raise\n @friendship = Friendship.all.sample\n @friendship.destroy\n respond_to do |format|\n format.html { redirect_to friendships_path, notice: 'Project was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @friendship = Friendship.find(params[:id])\n @friendship.destroy\n \n flash[:notice] = \"Removed friendship.\"\n redirect_to root_path\n end", "def destroy\n @friendship = Friendship.where(friend_id: [current_user, params[:id]]).where(user_id: [current_user, params[:id]]).last\n @friendship.destroy\n flash[:notice] = \"Removed friendship.\"\n redirect_to :back\n end", "def destroy\n @clientship = current_user.clientships.find(params[:id])\n @clientship.destroy\n\n respond_to do |format|\n format.html { redirect_to clientships_url }\n format.json { head :ok }\n end\n end", "def destroy\n @fellowship.destroy\n respond_to do |format|\n format.html { redirect_to fellowships_url, notice: 'Fellowship was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @friend = Friend.find(params[:id])\n @friend.destroy\n\n respond_to do |format|\n format.html { redirect_to friends_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @friend.destroy\n respond_to do |format|\n format.html { redirect_to friends_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @friends1.destroy\n respond_to do |format|\n format.html { redirect_to friends1s_url, notice: \"Friend was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @friend_request.destroy\n respond_to do |format|\n format.html { redirect_to friend_requests_url, notice: 'Friend request was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @friend_request.destroy\n respond_to do |format|\n format.html { redirect_to friend_requests_url, notice: 'Friend request was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @friendrequest.destroy\n respond_to do |format|\n format.html { redirect_to friendrequests_url, notice: 'Friendrequest was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @friendslist = Friendslist.find(params[:id])\n @friendslist.destroy\n\n respond_to do |format|\n format.html { redirect_to friendslists_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @pending_friend_request.destroy\n respond_to do |format|\n format.html { redirect_to '/profile?id=%s' % [session[:user_id]] }\n format.json { head :no_content }\n end\n end", "def destroy\n @friendship = Friendship.where(friend_id: [current_user, params[:id]]).where(user_id: [current_user, params[:id]]).last\n @friendship.destroy\n flash[:notice] = \"No longer friends.\"\n redirect_to :back\n end", "def destroy\n @friendship1 = Friendship.where(friend_id: current_user.id, user_id: params[:id]).first\n @friendship2 = Friendship.where(friend_id: params[:id], user_id: current_user.id).first\n @friendship1.destroy\n @friendship2.destroy\n flash[:notice] = \"Removed friendship.\"\n redirect_to :back\n end", "def destroy\n @friend.destroy\n respond_to do |format|\n format.html { redirect_to friends_url, notice: I18n.t('friend.destroy') }\n format.json { head :no_content }\n end\n end", "def destroy\n\n @plant = Plant.find(params[:id])\n @friendship = @plant.friendships.find_by_friend_id(params[:friend_id])\n\n if @friendship.destroy\n flash[:notice] = \"Removed friendship.\"\n redirect_to request.referrer\n else\n flash[:error] = \"Unable to remove friend\"\n redirect_to request.referrer\n end\n end", "def destroy\n\n @friendship = Friendship.find(params[:id])\n\n if params[:black_ball]\n current_user.black_ball(@friendship.proposer)\n end\n\n @friendship.destroy\n @incoming_friend_requests = Friendship.where({\n proposee_id: current_user.id,\n confirmed: nil\n })\n respond_to do |format|\n format.html { redirect_to friendships_url }\n format.js{}\n format.json { head :no_content }\n end\n end", "def remove\n\t\tif request.post?\n\t\t\tfriendship = Friendship.where(user_id: params[:user_id], friend_id: params[:friend_id]).first\n\t\t\tunless friendship\n\t\t\t\trender json: {error: \"You are not friends\"} and return\n\t\t\tend\n\t\t\tfriendship.destroy\n\t\t\trender json: {msg: \"Friend deleted\"}\n\t\tend\n\tend", "def destroy\n current_user.end_friendship!(@relationship.friend)\n respond_to do |format|\n format.html { redirect_to relationships_url }\n end\n end", "def destroy\n @followship.destroy\n respond_to do |format|\n format.html { redirect_to followships_url, notice: 'Followship was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @friends_list.destroy\n respond_to do |format|\n format.html { redirect_to friends_lists_url, notice: \"Friend was successfully removed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n relationship = Relationships.find(params[:id])\n relationship.destroy\n head 204\n end", "def destroy\n @followship.destroy\n respond_to do |format|\n format.html { redirect_to followships_url, notice: 'Followship was successfully unfollowed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @friend.destroy\n respond_to do |format|\n format.html { redirect_to member_friends_path(@member), notice: 'Friend was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @friendlist.destroy\n respond_to do |format|\n format.html { redirect_to friendlists_url, notice: 'Friendlist was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @friend_request = FriendRequest.find(params[:id])\n @friend_request.destroy\n\n respond_to do |format|\n format.html { redirect_to(friend_requests_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @friend.destroy\n respond_to do |format|\n format.html { redirect_to friends_url, notice: 'Friend was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @friend.destroy\n respond_to do |format|\n format.html { redirect_to friends_url, notice: 'Friend was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @friendsofuser = Friendsofuser.find(params[:id])\n @friendsofuser.destroy\n\n respond_to do |format|\n format.html { redirect_to(friendsofusers_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @friend = Friend.find(params[:id])\n @friend.destroy\n respond_with(@friend)\n end", "def destroy\n @friend.destroy\n respond_to do |format|\n format.html { redirect_to friends_url, notice: \"Friend was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @friend.destroy\n respond_to do |format|\n format.html { redirect_to friends_url, notice: \"Friend was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @friend_request = FriendRequest.find(params[:id])\n @friend_request.destroy\n respond_to do |format|\n format.html { redirect_to(friend_requests_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @manifestship.destroy\n respond_to do |format|\n format.html { redirect_to manifestships_url, notice: 'Manifestship was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @friendship = Friendship.find_by_user_id_and_friend_id(params[:id],current_user.id)\n @friendship ||= Friendship.find_by_user_id_and_friend_id(current_user.id,params[:id])\n unless @friendship.nil?\n @friendship.destroy\n redirect_to :back, flash: { success: t('.friendships_controller.delete_usr') }\n else\n redirect_to :back, flash: { error: t('.friendships_controller.error_usr') }\n end\n end", "def destroy\n @memeber_ship = MemeberShip.find(params[:id])\n @memeber_ship.destroy\n\n respond_to do |format|\n format.html { redirect_to(memeber_ships_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @discipleship.destroy\n respond_to do |format|\n format.html { redirect_to discipleships_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @internship = Internship.find(params[:id])\n @internship.destroy\n\n respond_to do |format|\n format.html { redirect_to internships_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @internship = Internship.find(params[:id])\n @internship.destroy\n\n respond_to do |format|\n format.html { redirect_to internships_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @internship = Internship.find(params[:id])\n @internship.destroy\n\n respond_to do |format|\n format.html { redirect_to internships_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @ab_reltionship.destroy\n respond_to do |format|\n format.html { redirect_to ab_reltionships_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @friends_list.destroy\n respond_to do |format|\n format.html { redirect_to friends_lists_url, notice: 'Friends list was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n\n # Your friend will first remove you as friend\n your_friend = Friend.where(\"account_id = ? AND friend_account_id = ?\", @friend.friend_account_id, current_account.id).first\n your_friend.destroy\n\n # Now, Remove your friend\n @friend.destroy\n\n respond_to do |format|\n format.html { redirect_to friends_url, notice: 'Friend was successfully removed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @replyship = Replyship.find(params[:id])\n @replyship.destroy\n\n respond_to do |format|\n format.html { redirect_to(replyships_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @friend = Friend.find(params[:id])\n @friend.destroy\n\n respond_to do |format|\n format.html { redirect_to(friends_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @friend = Friend.find(params[:id])\n @friend.destroy\n\n respond_to do |format|\n format.html { redirect_to(friends_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @invite_friend = InviteFriend.find(params[:id])\n @invite_friend.destroy\n\n respond_to do |format|\n format.html { redirect_to invite_friends_url }\n format.xml { head :ok }\n end\n end", "def destroy\n\t @friendable = Friendable.where(from_id: [current_user, params[:id]]).where(to_id: [current_user, params[:id]]).last\n\t @friendable.destroy\n\t flash[:notice] = \"Removed friendship.\"\n\t redirect_to :back\n\t end", "def destroy\n @my_girlfriend.destroy\n respond_to do |format|\n format.html { redirect_to my_girlfriends_url, notice: 'My girlfriend was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @ship = Ship.find(params[:id])\n @ship.destroy\n\n respond_to do |format|\n format.html { redirect_to ships_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @internship = Internship.find(params[:id])\n @internship.destroy\n\n respond_to do |format|\n format.html { redirect_to(internships_url) }\n format.json { head :ok }\n end\n end", "def destroy\n @friend.destroy\n respond_to do |format|\n format.html { redirect_to request.referrer, notice: \"Friend was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @ship = Ship.find(params[:id])\n @ship.destroy\n\n respond_to do |format|\n format.html { redirect_to ships_url }\n format.json { head :ok }\n end\n end", "def destroy\n @internships_user = InternshipsUser.find(params[:id])\n @internships_user.destroy\n\n respond_to do |format|\n format.html { redirect_to internships_users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @ship = Ship.find(params[:id])\n @ship.destroy\n\n respond_to do |format|\n format.html { redirect_to(ships_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @ship = Ship.find(params[:id])\n @ship.destroy\n\n respond_to do |format|\n format.html { redirect_to(ships_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n if @friendship.accepted\n @other_friendship = Friendship.find_by :requester_id => @friendship.granter_id, :granter_id => @friendship.requester_id\n @other_friendship.destroy\n notice = 'You and ' + Person.find(@friendship.granter_id).name + ' are no longer friends!'\n else\n notice = 'You have cancelled your friend request to ' + Person.find(@friendship.granter_id).name\n end\n @friendship.destroy\n respond_to do |format|\n format.html { redirect_to people_url, notice: notice }\n format.json { head :no_content }\n end\n end", "def destroy\n @authorship = Authorship.find(params[:id])\n @authorship.destroy\n\n respond_to do |format|\n format.html { redirect_to(authorships_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @call_your_friend.destroy\n respond_to do |format|\n format.html { redirect_to call_your_friends_url, notice: 'Call your friend was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @spaceship = Spaceship.find(params[:id])\n @spaceship.destroy\n\n respond_to do |format|\n format.html { redirect_to spaceships_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @friendship = Friendship.where(friend_id: [current_user, params[:id]]).where(user_id: [current_user, params[:id]]).last\n @friendship.destroy\n flash[:notice] = \"Removed friendship.\"\n\n #log_activity #doesnt work with call backs\n\n redirect_to :back\n end", "def unfriendship\n if params[:id]\n current_user.follow_ids.delete(params[:id])\n @user = User.find(params[:id]).del_follower(current_user)\n @user.save\n current_user.save\n end\n\n respond_to do |format|\n format.html { redirect_to :back }\n format.js\n end\n end", "def destroy\n user = User.find(params[:id])\n begin\n current_user.friends.delete(user)\n user.friends.delete(current_user)\n rescue\n end\n\n respond_to do |format|\n format.html { redirect_to '/manage/friends' }\n end\n end", "def destroy\n @authorship = Authorship.find(params[:id])\n @authorship.destroy\n\n respond_to do |format|\n format.html { redirect_to authorships_url }\n format.xml { head :ok }\n end\n end", "def destroy\n @mentorship = Mentorship.find(params[:id])\n @mentorship.destroy\n\n respond_to do |format|\n format.html { redirect_to mentorships_url }\n format.json { head :no_content }\n end\n end", "def destroy\n\t\t@profile.friends.destroy(params[:id])\n\t\trespond_to do |format|\n\t\t\tback_page = profile_friends_path\n\t\t\tback_page = URI(request.referer).path if params[:back]\n\t\t\tformat.html { redirect_to back_page, notice: 'Friend was successfully destroyed.' }\n\t\t\tformat.json { head :no_content }\n\t\tend\n\tend", "def destroy\n @user = User.find(params[:user_id])\n\n #this is okay because only one of these EVER exists at a time\n current_user.friends_requested.delete(@user)\n current_user.friend_requesters.delete(@user)\n\n if current_user.save\n flash[:success] = \"Request deleted!\"\n else\n flash[:error] = \"You can't let that person go just yet.\"\n end\n\n redirect_to session.delete(:return_to)\n end", "def destroy\n @championship = Championship.find(params[:id])\n @championship.destroy\n\n respond_to do |format|\n format.html { redirect_to championships_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @township.destroy\n respond_to do |format|\n format.html { redirect_to townships_url, notice: 'Township was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n destroy_friendship_sent_request()\n respond_to do |format|\n format.html { redirect_to(:back, :notice => \"Friendship request from #{params[:id]} was rejected\") }\n format.xml { head :ok }\n end\n end" ]
[ "0.82214355", "0.8085715", "0.7877334", "0.77677894", "0.7734391", "0.7715833", "0.76893854", "0.76850754", "0.76729405", "0.7641806", "0.7634508", "0.76028705", "0.7581459", "0.7570719", "0.7564472", "0.7549868", "0.74964285", "0.749085", "0.7483406", "0.7478135", "0.74379253", "0.7420924", "0.74020785", "0.73807263", "0.7343347", "0.7297022", "0.72946626", "0.72896564", "0.7270171", "0.72618407", "0.72389275", "0.7232045", "0.72104913", "0.7195814", "0.7171731", "0.71546626", "0.7144732", "0.7126795", "0.7126795", "0.71168256", "0.7102246", "0.7100058", "0.70935005", "0.70891607", "0.7052683", "0.70405746", "0.7039317", "0.7013781", "0.69821787", "0.6975245", "0.6960244", "0.69492674", "0.6939929", "0.6911875", "0.6907476", "0.6901239", "0.6888912", "0.6888912", "0.6885862", "0.6883476", "0.6882286", "0.6882286", "0.6881855", "0.68789303", "0.68711585", "0.6866246", "0.6858576", "0.6851908", "0.6851908", "0.6851908", "0.6850915", "0.6839732", "0.683919", "0.6827171", "0.6798718", "0.6798718", "0.6769988", "0.6763017", "0.675757", "0.675016", "0.6748364", "0.67468905", "0.6744864", "0.6733603", "0.67242175", "0.67242175", "0.670285", "0.6691405", "0.6691031", "0.6681343", "0.667799", "0.6672426", "0.6671655", "0.6670487", "0.6668888", "0.6666876", "0.6666105", "0.6647687", "0.663345", "0.6610458" ]
0.7987953
2
Use callbacks to share common setup or constraints between actions.
def set_friendship @friendship = Friendship.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_eval do\n define_method(:valid?) do |*args|\n self.class.state_machines.fire_event_attributes(self, :save, false) { super(*args) }\n end\n end\n end\n end", "def add_actions; end", "def callbacks; end", "def callbacks; end", "def setup *actions, &proc\n (@setup_procs ||= []) << [proc, actions.size > 0 ? actions : [:*]]\n end", "def define_action_helpers; end", "def post_setup\n end", "def action_methods; end", "def action_methods; end", "def action_methods; end", "def before_setup; end", "def action_run\n end", "def execute(setup)\n @action.call(setup)\n end", "def define_action_helpers?; end", "def set_actions\n actions :all\n end", "def action_done(action)\n dispatch = { :migrate => :done_migrating, :map => :done_mapping, :reduce =>\n :done_reducing, :finalize => :done_finalizing } \n self.send dispatch[action[:action]], action\n end", "def dependencies action, &block\n @actions.each do |other|\n if action[:requires].include? other[:provide]\n block.call other\n end\n end\n end", "def setup!\n return unless @setup_procs\n http_actions = actions\n @setup_procs.each do |setup_proc|\n proc, actions = setup_proc\n @setup__actions = actions.map do |action|\n\n action.is_a?(Regexp) ?\n http_actions.select { |a| a.to_s =~ action } :\n action.is_a?(String) && action =~ /\\A\\./ ?\n http_actions.map { |a| a.to_s << action if format?(a).include?(action) }.compact :\n action\n\n end.flatten\n self.class_exec &proc\n @setup__actions = nil\n end\n @setup_procs = nil\n end", "def before_actions(*logic)\n self.before_actions = logic\n end", "def setup_handler\n end", "def set_action(opts)\n opts = check_params(opts,[:actions])\n super(opts)\n end", "def setup(action)\n @targets.clear\n unless action.item.target_filters.empty?\n @targets = SES::TargetManager.make_targets(action)\n else\n item = action.item\n if item.for_opponent?\n @targets = $game_troop.alive_members\n elsif item.for_dead_friend?\n @targets = $game_party.battle_members.select { |actor| actor.dead? }\n else\n $game_party.battle_members.select { |actor| actor.alive? }\n end\n end\n @item_max = @targets.size\n create_contents\n refresh\n show\n activate\n end", "def action; end", "def action; end", "def action; end", "def action; end", "def action; end", "def workflow\n end", "def revisable_shared_setup(args, block)\n class << self\n attr_accessor :revisable_options\n end\n options = args.extract_options!\n self.revisable_options = Options.new(options, &block)\n \n self.send(:include, Common)\n self.send(:extend, Validations) unless self.revisable_options.no_validation_scoping?\n self.send(:include, WithoutScope::QuotedColumnConditions)\n end", "def setup\n @action = SampleActionAndroid.new(os_name: 'android',\n app_name: APP_PATH)\n end", "def before(action)\n invoke_callbacks *self.class.send(action).before\n end", "def process_action(...)\n send_action(...)\n end", "def before_dispatch(env); end", "def after_actions(*logic)\n self.after_actions = logic\n end", "def setup\n # override and do something appropriate\n end", "def setup(client)\n return unless @setup\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n actions.each do |action|\n action.execute(client)\n end\n self\n end", "def setup(_context)\n end", "def setup(resources) ; end", "def validate_actions\n errors.add(:base, :should_give_at_least_one_action) if !manage? && !forecasting? && !read? && !api?\n end", "def setup\n @resource_config = {\n :callbacks => {\n :before_create => nil,\n :after_create => nil,\n :before_update => nil,\n :after_update => nil,\n :before_destroy => nil,\n :after_destroy => nil,\n },\n :child_assoc => nil,\n :model => nil,\n :parent => nil,\n :path => nil,\n :permission => {},\n :properties => {},\n :relation => {\n :create => nil,\n :delete => nil,\n },\n :roles => nil,\n }\n end", "def determine_valid_action\n\n end", "def process_shared\n handle_taxes\n handle_shippings\n create_adjustments_from_params\n handle_status\n handle_inventory_refunds\n handle_payment_transactions\n order.updater.update\n end", "def startcompany(action)\n @done = true\n action.setup\n end", "def init_actions\n am = action_manager()\n am.add_action(Action.new(\"&Disable selection\") { @selection_mode = :none; unbind_key(32); bind_key(32, :scroll_forward); } )\n am.add_action(Action.new(\"&Edit Toggle\") { @edit_toggle = !@edit_toggle; $status_message.value = \"Edit toggle is #{@edit_toggle}\" })\n end", "def event_callbacks(event, metadata={})\n case event\n when :reset, :review\n if confirmed\n update_attributes(confirmed: false)\n end\n when :confirm\n confirm\n # trigger :order for all applicable items\n # NOTE: :order event is common to both physical and digital items\n items.each do |i|\n if i.event_permitted(:order)\n user_id = last_transition.user_id\n i.trigger!(:order, { order_id: id, user_id: user_id })\n end\n end\n when :complete_work\n request = metadata[:request]\n work_complete_notification(request)\n when :close\n close\n end\n if event != :close && !open\n reopen\n end\n end", "def setup_action\n return unless PONY::ERRNO::check_sequence(current_act)\n new_sequence = @action_sequence[@sequence_index+1...@action_sequence.size]\n @sequence_index = 0\n new_sequence = DND::SkillSequence::ACTS[@acts[1]] + new_sequence\n execute_sequence\n end", "def define_tasks\n define_weave_task\n connect_common_tasks\n end", "def setup(&block)\n define_method(:setup, &block)\n end", "def setup\n transition_to(:setup)\n end", "def setup\n transition_to(:setup)\n end", "def action\n end", "def setup( *args )\n\t\t\tself.class.setupBlocks.each {|sblock|\n\t\t\t\tdebugMsg \"Calling setup block method #{sblock}\"\n\t\t\t\tself.send( sblock )\n\t\t\t}\n\t\t\tsuper( *args )\n\t\tend", "def config(action, *args); end", "def setup\n @setup_proc.call(self) if @setup_proc\n end", "def before_action \n end", "def setup_callbacks\n defined_callbacks.each do |meth|\n unless respond_to?(\"call_#{meth}_callbacks\".to_sym)\n self.class.module_eval <<-EOE\n def call_#{meth}_callbacks(*args)\n plugin_store.each {|a| a.call_#{meth}_callbacks(*args) } if respond_to?(:plugin_store) && plugin_store\n self.send :#{meth}, *args if respond_to?(:#{meth})\n end\n EOE\n end\n end\n end", "def action\n end", "def matt_custom_action_begin(label); end", "def setup\n # override this if needed\n end", "def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend", "def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend", "def action(options,&callback)\n new_action = Action===options ? options : Action.new(options,&callback)\n # replace any with (shared name/alias or both default) + same arity\n @actions.delete_if do |existing_action|\n ((existing_action.names & new_action.names).size > 0 ||\n existing_action.default? && new_action.default?) &&\n existing_action.required.size == new_action.required.size &&\n existing_action.optional.size <= new_action.optional.size\n end\n @actions = (@actions + [new_action]).sort\n new_action\n end", "def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action\n end", "def after(action)\n invoke_callbacks *options_for(action).after\n end", "def pre_task\n end", "def setup(server)\n server.on('beforeMethod', method(:before_method), 10)\n end", "def add_actions\n attribute = machine.attribute\n name = self.name\n \n owner_class.class_eval do\n define_method(name) {self.class.state_machines[attribute].events[name].fire(self)}\n define_method(\"#{name}!\") {self.class.state_machines[attribute].events[name].fire!(self)}\n define_method(\"can_#{name}?\") {self.class.state_machines[attribute].events[name].can_fire?(self)}\n end\n end", "def init_actions\n @select_action = SelectAction.new\n @endpoint_mouse_action = EndpointMouseAction.new\n @move_action = MoveAction.new\n end", "def setup_signals; end", "def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend", "def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend", "def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action.respond_to?('weak!') ? action.weak! : action\n end", "def initialize(*args)\n super\n @action = :set\nend", "def after_set_callback; end", "def setup\n #implement in subclass;\n end", "def lookup_action; end", "def setup &block\n if block_given?\n @setup = block\n else\n @setup.call\n end\n end", "def setup_action\n return TSBS.error(@acts[0], 1, @used_sequence) if @acts.size < 2\n actions = TSBS::AnimLoop[@acts[1]]\n if actions.nil?\n show_action_error(@acts[1])\n end\n @sequence_stack.push(@acts[1])\n @used_sequence = @acts[1]\n actions.each do |acts|\n @acts = acts\n execute_sequence\n break if @break_action\n end\n @sequence_stack.pop\n @used_sequence = @sequence_stack[-1]\n end", "def release_actions; end", "def around_hooks; end", "def save_action; end", "def setup(easy)\n super\n easy.customrequest = @verb\n end", "def action_target()\n \n end", "def setup\n callback(:setup) do\n notify(:setup)\n migration_check.last_deployed_commit\n end\n end", "def setup\n return unless @setup\n\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n run_actions_and_retry(actions)\n self\n end", "def before_setup\n # do nothing by default\n end", "def my_actions(options)\n @setup = false\n get_template_part(\"custom_used\",\"action_users\",true)\n end", "def default_action; end", "def setup(&blk)\n @setup_block = blk\n end", "def callback_phase\n super\n end", "def advice\n end", "def _handle_action_missing(*args); end", "def duas1(action)\n action.call\n action.call\nend", "def shared_action(name, &block)\n @controller.shared_actions[name] = block\n end", "def before_action action, &block\n @audience[:before][action] ||= Set.new\n @audience[:before][action] << block\n end", "def setup_initial_state\n\n state_a = State.new(\"a\", 0)\n state_b = State.new(\"b\", 0)\n state_c = State.new(\"c\", 10)\n\n move_to_b = Action.new(\"move_to_b\", 1, state_b)\n\n move_to_c = Action.new(\"move_to_c\", 1, state_c)\n\n state_a.actions = [move_to_b, move_to_c]\n\n return state_a\n \nend" ]
[ "0.6163163", "0.6045976", "0.5946146", "0.591683", "0.5890051", "0.58349305", "0.5776858", "0.5703237", "0.5703237", "0.5652805", "0.5621621", "0.54210985", "0.5411113", "0.5411113", "0.5411113", "0.5391541", "0.53794575", "0.5357573", "0.53402257", "0.53394014", "0.53321576", "0.53124547", "0.529654", "0.5296262", "0.52952296", "0.52600986", "0.52442724", "0.52385926", "0.52385926", "0.52385926", "0.52385926", "0.52385926", "0.5232394", "0.523231", "0.5227454", "0.52226824", "0.52201617", "0.5212327", "0.52079266", "0.52050185", "0.51754695", "0.51726824", "0.51710224", "0.5166172", "0.5159343", "0.51578903", "0.51522785", "0.5152022", "0.51518047", "0.51456624", "0.51398855", "0.5133759", "0.5112076", "0.5111866", "0.5111866", "0.5110294", "0.5106169", "0.509231", "0.50873137", "0.5081088", "0.508059", "0.50677156", "0.50562143", "0.5050554", "0.50474834", "0.50474834", "0.5036181", "0.5026331", "0.5022976", "0.5015441", "0.50121695", "0.5000944", "0.5000019", "0.4996878", "0.4989888", "0.4989888", "0.49864885", "0.49797225", "0.49785787", "0.4976161", "0.49683493", "0.4965126", "0.4958034", "0.49559742", "0.4954353", "0.49535993", "0.4952725", "0.49467874", "0.49423352", "0.49325448", "0.49282882", "0.49269363", "0.49269104", "0.49252945", "0.4923091", "0.49194667", "0.49174926", "0.49173003", "0.49171105", "0.4915879", "0.49155936" ]
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def friendship_params params.require(:friendship).permit(:user_id, :friend_id, :status) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strong_params\n params.require(:user).permit(param_whitelist)\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def allow_params_authentication!; end", "def allowed_params\n ALLOWED_PARAMS\n end", "def default_param_whitelist\n [\"mode\"]\n end", "def param_whitelist\n [:role, :title]\n end", "def expected_permitted_parameter_names; end", "def safe_params\n params.except(:host, :port, :protocol).permit!\n end", "def strong_params\n params.require(:team_member).permit(param_whitelist)\n end", "def permitir_parametros\n \t\tparams.permit!\n \tend", "def strong_params\n params.require(:community).permit(param_whitelist)\n end", "def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end", "def strong_params\n params.require(:education).permit(param_whitelist)\n end", "def restricted_params\n #params.require(self.controller_name.classify.underscore.to_sym).permit([])\n raise(\"No strong params set, override restricted_params method in your controller. E.g. params.require(:model).permit(:attribute1, :attribute2)\")\n end", "def allowed_params\n params.require(:user).permit(:username, :email, :password, :password_confirmation)\n end", "def param_whitelist\n [:rating, :review]\n end", "def param_whitelist\n whitelist = [\n :username, :name,\n :parent_id,\n :headline, :description, :video,\n :policy, :signup_mode, :category,\n :website, :facebook, :twitter, :linkedin,\n :founded_at,\n privacy: [\n :events,\n :resources\n ],\n permission: [\n :profile,\n :members,\n :children,\n :statistics,\n :posts,\n :listings,\n :resources,\n :events\n ],\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:parent_id)\n unless current_user.role_in(@community) === 'owner'\n whitelist.delete(:privacy)\n whitelist.delete(:permission)\n end\n end\n \n whitelist\n end", "def param_whitelist\n if @user.present? && current_user != @user\n return [:followed]\n end\n \n whitelist = [\n :username, :email, :password,\n :first_name, :last_name,\n :birthday, :gender,\n :headline, :biography, :ask_about, :focus,\n :website, :facebook, :linkedin, :twitter, :github,\n roles: [],\n skills: [],\n interests: [],\n privacy: { contact: [] },\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:email)\n whitelist.delete(:password)\n end\n \n whitelist\n end", "def user_params \n \tparams.require(:user).permit(:name, :email, :password, :password_confirmation)# preventing CSTR\n end", "def user_params\n params.permit(:name, :phoneNumber, :address, :postalCode, :local, :link, :counter, :latitude, :longitude) \n end", "def valid_params_request?; end", "def strong_params\n params.require(:experience).permit(param_whitelist)\n end", "def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end", "def whitelist_url_params\n params.require(:whitelist_url).permit(:domain)\n end", "def allowed_params\n params.require(:allowed).permit(:email)\n end", "def permitted_params\n []\n end", "def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end", "def safe_params\n params.permit(:id, :name, :origin, :emails => []); #emails is an array\n end", "def query_param\n\t\tparams.permit(:first_name, :last_name, :phone)\n\tend", "def strong_params\n params.require(:success_metric).permit(param_whitelist)\n end", "def devise_filter\r\n logger.debug(\"In devise_filter =>PARAMS: #{params.inspect}\")\r\n\r\n # White list for sign_up\r\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(user_whitelist) }\r\n\r\n # White list for account update\r\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(user_whitelist, :current_password) }\r\n\r\n # White list for Invitation creation\r\n devise_parameter_sanitizer.for(:invite) { |u| u.permit(:account_type, :email, :invitation_token)}\r\n\r\n # White list for accept invitation\r\n devise_parameter_sanitizer.for(:accept_invitation) { |u| u.permit(user_whitelist, :invitation_token)}\r\n\r\n end", "def whitelisted_user_params\n params.require(:user).\n permit( :first_name, :last_name, :email,:password,:password_confirmation,:birthday,:gender)\n end", "def user_params\n ActionController::Parameters.permit_all_parameters = true\n params.require(:user) #.permit(:name, :surname, :phone, :password, :email, :time_zone)\n end", "def strong_params\n params.require(:metric_change).permit(param_whitelist)\n end", "def safe_params\n params.require(:user).permit(:name)\n end", "def get_params\n\t\treturn ActionController::Parameters.new(self.attributes).permit(\"account_id\", \"title\", \"category\", \"introduction\", \"tags\", \"segment_type\", \"visible\", \"status\", \"main_image\")\n\tend", "def grant_params\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\n end", "def check_params; true; end", "def param_whitelist\n whitelist = [\n :description,\n :progress,\n :kpi_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:kpi_id)\n end\n \n whitelist\n end", "def quote_params\n params.permit!\n end", "def valid_params?; end", "def paramunold_params\n params.require(:paramunold).permit!\n end", "def user_params\n\t\tparams.permit(:nickname, :avatar, :description, :password, :gender, :birthday, :email, :phone, :qq_id, :wechat_id)\n\tend", "def filtered_parameters; end", "def user_params\n params.permit(\n \t:id,\n \t:email, \n \t:first_name, \n \t:last_name, \n \t:password, \n \t:confirm_token, \n \t:phone_number,\n \t:facebook_link,\n \t:car_model,\n \t:license_plate)\n end", "def filtering_params\n params.permit(:email, :name)\n end", "def check_params\n true\n end", "def wx_public_params\n params.require(:wx_public).permit(:nickname, :manager, :alias)\n end", "def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end", "def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end", "def listing_params\n\t\tparams.permit(:address, :transit_info, :rules, :other_info, :lat, :lng)\n\tend", "def social_account_params\n\t\t\tparams.require(:social_account).permit!\n\t\tend", "def safe_params\n resurce_name = self.class.resource_name\n params_method_name = \"#{resurce_name}_params\".to_sym\n if params[resurce_name]\n if respond_to?(params_method_name) || private_methods.include?(params_method_name)\n send(params_method_name)\n else\n raise ActiveModel::ForbiddenAttributesError, \"Please, define the '#{params_method_name}' method in #{self.class.name}\"\n end\n end\n end", "def url_params\n params.require(:url).permit(:short_url, :original_url, :clicks, :ip_addresses)\n end", "def user_params\n params.require(:user).permit(:uri, :username, :password, :realname, :email, :publicvisible)\n end", "def model_params\n\t\tparams.require(:manager).permit(\n\t :user_name,\n :password,\n :email,\n \t\t\t)\n\tend", "def article_params_whitelist\n params.require(:article).permit(:title, :description, category_ids: [])\n end", "def college_whitelist_params\n params.require(:college_whitelist).permit(:status)\n end", "def active_code_params\n params[:active_code].permit\n end", "def filtering_params\n params.permit(:email)\n end", "def valid_params(params)\n params.permit(:user_id, :photo_id, :originX, :originY, :width, :height)\n end", "def ip_address_params\n\t\t\tparams.require(:ip_address).permit!\n end", "def pull_request_params\n whitelist = [\n :url,\n :id,\n :html_url,\n :diff_url,\n :patch_url,\n :issue_url,\n :number,\n :state,\n :locked,\n :title\n ]\n params.require(:pull_request).permit(whitelist)\n end", "def reserved_params\n params.require(:reserved).permit(:name, :email, :pax, :address, :KTP, :title)\n end", "def post_params\n if current_user.admin? \n params.permit(:title, :body, :city, :country, :gps_location, :privacy, :visible, :latitude, :longitude, images: [], files: [])\n else \n params.permit(:title, :body, :city, :country, :gps_location, :privacy,:latitude, :longitude, images: [], files: [])\n end \n end", "def list_params\n params.permit(:name)\n end", "def filter_parameters; end", "def filter_parameters; end", "def vineyard_params\n params.permit(:vineyard_name, :email, :website_url, :phone, :address, :city, :region, :postcode, :country, :specialty, :description, :pet_friendly, :holiday, :tours, :events, :family_friendly, :cover_image, :image_one, :image_two, :image_three, :image_four, :user_id, :base64)\n end", "def available_activity_params\n # params.require(:available_activity).permit(:type,:geometry,:properties)\n whitelisted = ActionController::Parameters.new({\n type: params.require(:available_activity)[:type],\n geometry: params.require(:available_activity)[:geometry].try(:permit!).to_h,\n properties: params.require(:available_activity)[:properties].try(:permit!).to_h\n }).try(:permit!)\n end", "def user_params\n params.permit(:name, :username, :email, :password, :img_url, :bg_url, :coinbank)\n end", "def user_params_pub\n\t \tparams[:user].permit(:hruid)\n\t end", "def user_params\n params.permit(:id, :email, :password, :nickname, :status, :avatar, :flat_picture, :flatsharing_id, :member,\n :user, :color, :solde)\n end", "def validate_search_inputs\n @whitelisted = params.fetch(:user, nil)\n if @whitelisted.blank?\n render_error(400, \"#{I18n.t('general_error.params_missing_key')}\": [I18n.t('general_error.params_missing_value', model: \"review\")])\n return\n else\n @whitelisted = @whitelisted.permit(:name, :uen, :description)\n end\n end", "def param_whitelist\n [\n :title,\n :description,\n :organization,\n :team_id,\n :started_at,\n :finished_at,\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n end", "def url_whitelist; end", "def admin_social_network_params\n params.require(:social_network).permit!\n end", "def filter_params\n params.require(:filters).permit(:letters)\n end", "def origin_params\n params.permit(:country, :state, :city, :postal_code, :address, :description)\n end", "def valid_params(params)\n params.permit(:login, :first_name, :last_name, \n :password, :password_confirmation)\n end", "def sensitive_params=(params)\n @sensitive_params = params\n end", "def permit_request_params\n params.permit(:address)\n end", "def user_params\n # Ensure a user can't give themselves admin priveleges\n params.delete(:admin) if current_user.admin?\n params.require(:user).permit(:name, :email, :admin, :image)\n end", "def secure_params\n params.require(:location).permit(:name)\n end", "def strong_params\n params.require( :setting ).\n permit( :global_scan_limit, :per_user_scan_limit,\n :target_whitelist_patterns, :target_blacklist_patterns )\n end", "def question_params\n params.require(:survey_question).permit(question_whitelist)\n end", "def case_insensitive_params\n params.require(:case_insensitive).permit(:name)\n end", "def empire_master_no_match_params\n params.require(:empire_master_no_match).permit(:uid, :last_name, :list, :search_date, :double, :source)\n end", "def maintenance_request_params\n params[:maintenance_request].permit! #allow all parameters for now\n end", "def unwanted_params\n params.require(:unwanted).permit(:title, :description, :image)\n end", "def url_params\n params[:url].permit(:full)\n end", "def backend_user_params\n params.permit!\n end", "def filter_params\n\t\treturn params[:candidate].permit(:name_for_filter)\n\tend", "def speed_measurement_params\n\n #fuckit, to lazy to deal with permit crap right now\n ActionController::Parameters.permit_all_parameters = true\n\n params[:speed_measurement]\n end", "def user_params\n params.permit(:name, :age, :username, :display_photo, :password)\n end", "def get_params\r\n #params.require(:article).permit(:title, :permalink, :content, :source_site, :introtext, :type_id, :order_by, :searchable, :created_by, :edited_by, :published_by, :published_on, :user_id)\r\n params.require(:article).permit!\r\n\r\n end", "def pub_params\n params.require(:pub).permit(:name, :description, :phone, :email, :hidden, :city_id, :address)\n end", "def pass_params\n params[:pass].permit(:name, :price, :description, :colour, :events)\n end", "def droptraining_params\n params.permit(:training_id,:user_id, :utf8, :authenticity_token, :commit)\n end", "def person_params\n # params whitelist does *not* include admin, sub, remember_token\n # TBD: share this whitelist with the list used by configuration_permitted_parameters\n # TBD: should current_password be on this list? -- for now, leaving off, since it seems to work without\n # NOTE: do not include 'admin' in this list!\n params.require(:person).permit(\n :name, \n :email, \n :description,\n :password, \n :password_confirmation\n )\n end", "def parameter_params\n params.require(:parameter).permit(:name, :description, :param_code, :param_value, :active_from, :active_to)\n end" ]
[ "0.69792545", "0.6781151", "0.67419964", "0.674013", "0.6734356", "0.6591046", "0.6502396", "0.6496313", "0.6480641", "0.6477825", "0.64565", "0.6438387", "0.63791263", "0.63740575", "0.6364131", "0.63192815", "0.62991166", "0.62978333", "0.6292148", "0.6290449", "0.6290076", "0.62894756", "0.6283177", "0.6242471", "0.62382483", "0.6217549", "0.6214457", "0.6209053", "0.6193042", "0.6177802", "0.6174604", "0.61714715", "0.6161512", "0.6151757", "0.6150663", "0.61461", "0.61213595", "0.611406", "0.6106206", "0.6105114", "0.6089039", "0.6081015", "0.6071004", "0.60620916", "0.6019971", "0.601788", "0.6011056", "0.6010898", "0.6005122", "0.6005122", "0.6001556", "0.6001049", "0.59943926", "0.5992201", "0.59909594", "0.5990628", "0.5980841", "0.59669393", "0.59589154", "0.5958826", "0.5957911", "0.5957385", "0.5953072", "0.59526145", "0.5943361", "0.59386164", "0.59375334", "0.59375334", "0.5933856", "0.59292704", "0.59254247", "0.5924164", "0.59167904", "0.59088355", "0.5907542", "0.59064597", "0.5906243", "0.5898226", "0.589687", "0.5896091", "0.5894501", "0.5894289", "0.5891739", "0.58860534", "0.5882406", "0.587974", "0.58738774", "0.5869024", "0.58679986", "0.5867561", "0.5865932", "0.5864461", "0.58639693", "0.58617616", "0.5861436", "0.5860451", "0.58602303", "0.5854586", "0.58537364", "0.5850427", "0.5850199" ]
0.0
-1
Customisation point, expect individual cards to set their own length
def expected_length? formatted_number.length == 16 || formatted_number.length == 17 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cards_needed\n [@size, 5].min\n end", "def size\n cards.size\n end", "def length\n cards.length\n end", "def size\n return @cards.length\n end", "def size\n @cards.size\n end", "def size\n @cards.size\n end", "def size\n @cards.size\n end", "def card_ncolumns\n 0\n end", "def length\n @fulldeck.length # => 52\n end", "def length\n\t\treturn @cards.length\n\tend", "def size\n return @cardsShown.length\n end", "def populate_deck\n # self.initial_size.times do\n # new_card_class = Card.library.values.sample\n # new_card = new_card_class.new\n # self.cards << new_card\n # end\n 40.times do\n new_card_type = Card.library.values.sample\n new_card = new_card_type.create\n self.cards << new_card\n end\n end", "def no_of_cards\n @cards.length\n end", "def hand_length\n return @cards_in_hand.length\n end", "def size\n deck.size\n end", "def count\n return cards.length \n end", "def test_card_length_equals_card_count \n assert_equal(@deck.cards.length, @deck.count)\n end", "def length\n super\n end", "def size= length\n #This is a stub, used for indexing\n end", "def calc_length\n Base.calculate_and_set_length self\n self.ihl = 5 + self[:options].sz / 4\n end", "def determine_length\n determine_length_support\n end", "def count\n @cards.length\n end", "def no_of_cards\n @card_list.no_of_cards\n end", "def no_of_cards\n @card_list.no_of_cards\n end", "def no_of_cards\n @card_list.no_of_cards\n end", "def no_of_cards\r\n @card_list.no_of_cards\r\n end", "def no_of_cards\r\n @card_list.no_of_cards\r\n end", "def cards_left\n @deck.length\n end", "def deal_hand no_of_cards\n @card_list.deal_hand no_of_cards\n end", "def deal_hand no_of_cards\r\n @card_list.deal_hand no_of_cards\r\n end", "def count\n @cards.length\n end", "def initialize(desired_length)\n @length = desired_length\n end", "def count\n @cards.size\n end", "def count\n @cards.size\n end", "def length_calculator; end", "def cards_left\n @deck.length\n end", "def size=(dimension); end", "def size\n super\n end", "def size\n super\n end", "def size\n sku.size * amount\n end", "def resize(player)\r\n #@log.debug \"gxc: resize deck_main\"\r\n img_opponent_deck = @image_gfx_resource[:card_opp_img]\r\n \r\n # deck\r\n model_canvas_gfx = @gfx_res.model_canvas_gfx\r\n x_deck_start = 50\r\n y_deck_start = 50\r\n \r\n if model_canvas_gfx.info[:deck_info][:position] == nil\r\n x_deck_start = model_canvas_gfx.info[:canvas][:width] - (img_opponent_deck.width + 30)\r\n y_deck_start = (model_canvas_gfx.info[:canvas][:height] - (img_opponent_deck.height + 30))/ 2\r\n else\r\n x_deck_start = model_canvas_gfx.info[:deck_info][:position][:x_deck_start]\r\n y_deck_start = model_canvas_gfx.info[:deck_info][:position][:y_deck_start]\r\n end\r\n \r\n rest_x = 0\r\n rest_y = 0\r\n @deck_todisp.each do |card_deck|\r\n card_deck.pos_x = x_deck_start + rest_x\r\n card_deck.pos_y = y_deck_start + rest_y\r\n rest_y += 1\r\n rest_x += 1 \r\n end\r\n model_canvas_gfx.info[:deck_info][:x_deck_start] = x_deck_start\r\n model_canvas_gfx.info[:deck_info][:y_deck_start] = y_deck_start\r\n model_canvas_gfx.info[:deck_info][:rest_x] = rest_x\r\n model_canvas_gfx.info[:deck_info][:rest_y] = rest_y\r\n \r\n if @briscola and @card_briscola_todisp\r\n # briscola\r\n # it is a rotated card\r\n y_brisc = y_deck_start + (img_opponent_deck.height / 2 - img_opponent_deck.width / 2 - 12)\r\n x_brisc = x_deck_start - (img_opponent_deck.height - img_opponent_deck.height / 3 + 20) \r\n @card_briscola_todisp.pos_x = x_brisc\r\n @card_briscola_todisp.pos_y = y_brisc\r\n end\r\n \r\n end", "def initialize\n\t\t@cards = (1..52).to_a\n\tend", "def more_decks deck\n if deck.length == 0\n\n create_deck deck\n shuffle deck\n\n else \n deal_cards deck\n end\n # p deck.length\nend", "def length=(length)\n end", "def size\n return 3\n end", "def count\n @deck.size\n end", "def total_cards\n cards.count\n end", "def create_52_card_deck\n\n end", "def test_deck_display_size_fullDeck\n print \"Expected size of 81: Found \"\n Deck.new.display_size\n end", "def length_override; end", "def cards_played_size \n a = @played\n a.delete_if { |key, value| value == nil }\n a.length\n end", "def current_length; end", "def initialize_cards\n cards = []\n 4.times { cards += (2..14).to_a }\n cards.sample(52)\n end", "def length\n length = width\n end", "def magic_weight\n binding.pry\n \n @result.arrayofcards.each do |bundle|\n \n end\n end", "def test_initial_card_count \n assert_equal(52, @deck.count)\n assert_equal(52, @deck.cards.length)\n end", "def initialize(side_length)\n #instance variable\n @side_length = side_length\n end", "def size\n 4\n end", "def set_hands(hand_size = 2)\n puts \"Dealing cards\"\n @player.new_hand\n @dealer.new_hand\n\n @dealer.update_deck if @deck.cards_left < ((hand_size * 2) + 1) # Rebuilds deck if empty\n hand_size.times do\n @player.hand.hit\n @dealer.hand.hit\n end\n end", "def player_capacity\n 2\n end", "def initialize length\n self.length = length\n end", "def width(val); @width = val; self; end", "def set_scaled_info(lbl, width, height)\r\n @cards_scaled_info[lbl] = {:w => width, :h => height}\r\n end", "def render_length; end", "def slot_size (size)\r\n @slot_size = size\r\n end", "def size=(size)\n end", "def generate_card (player)\n new_card = Card.new face, suit, value\n player.hand << new_card\n #update total for player\n player.total = player.total + new_card.value\n end", "def initialize(card_number, limit)\n @card_number = card_number\n @limit = limit\n end", "def initialize(card)\n @card = card #TODO: change this to @rank\n end", "def initialize(size)\n @size = size\n @cards = Array.new\n for i in 1..@size\n deck = Deck.new\n @cards.concat(deck.get_cards)\n end\n \n # Shuffle all the cards in the deck\n @cards = @cards.shuffle\n end", "def data_length\n super\n end", "def size=(_); end", "def size=(_); end", "def get_size(card_name)\n if @sizes\n begin\n size_key = /[<{\\[](.+)[>}\\]]/.match(card_name)[1].to_sym\n if @sizes.has_key? size_key\n size = @sizes[size_key] \n else\n if size_key.to_s.to_i != 0\n size = size_key.to_s.to_i\n else\n size = @sizes[:default]\n end\n end\n rescue Exception => e\n size = @sizes[:default]\n end\n else\n size = (/[<{\\[](\\d+)[>}\\]]/.match(card_name) || DEFAULT_SIZE )[1].to_i\n end\n size\n end", "def canonic_size( size )\n if canonic_type == :decimal && size.is_a?( Integer )\n [ size, 0 ]\n else\n size\n end\n end", "def count\n cards.count\n end", "def coat_length; end", "def initialize(length)\n @length = length\n end", "def size\n Stal.solve(redis, [\"SCARD\", key])\n end", "def interpret_size(size); end", "def initialize \n\t\tsuper(SIZE)\n\t\t@lives = 10\n\tend", "def restock_hand!\n return if Bot::CONFIG.hand_size == unplayed_cards.count\n (Bot::CONFIG.hand_size - unplayed_cards.count).times do\n add_player_card PlayerCard.create(answer: game.available_answers.sample)\n end\n end", "def mutate_length\n original = self.to_s\n length_change = rand_between_plus_and_minus(@options[:length_mutations])\n if length_change > 0\n length_change.times{ self << random_char}\n elsif length_change < 0\n range = size + length_change\n range = 0 if range < 0 # not letting strings become empty\n slice!(0,range)\n end\n self\n end", "def deal5cards (n)", "def calc_length\n Base.calculate_and_set_length self\n end", "def initialize(deck)\n @cards_showing = Array.new\n base#just like the deck I want this to be adaptable if we can\n @table_max.times {@cards_showing.push(deck.draw_card)}\n @table_size = @cards_showing.length\n set_warnings\n end", "def available_cards\n (@deck.size + board.size)\n end", "def length\n @config[:length]\n end", "def initialize\n super CardNine::Cards::PlayingCard.deck, [:community], STAGES\n end", "def calc_length\n self.length = Base.calculate_and_set_length(self)\n end", "def length=(_); end", "def size_bonus\n @character.race.size.modifier\n end", "def initialize(cards)\n raise \"Invalid hand size - #{cards.length}\" unless cards.length == 5\n @cards = cards.map {|c| Card.new(c)}.sort\n @by_value = {}\n @by_suit = {}\n @cards.each do |c|\n @by_value[c.value] ||= []\n @by_suit[c.suit] ||= []\n @by_value[c.value] << c\n @by_suit[c.suit] << c\n end\n\n if @cards[4].value+1 == @cards[3].value &&\n @cards[3].value+1 == @cards[2].value &&\n @cards[2].value+1 == @cards[1].value &&\n @cards[1].value+1 == @cards[0].value\n end\n # Is it a straight\n @straight = true\n @cards.reduce do |p,c|\n if p.value != c.value + 1\n @straight = false\n break\n end\n c\n end\n value = [0]\n if @straight # Is it a straight\n value = [500, @cards.first.value]\n end\n # Is it a flush\n if @flush = @by_suit.find {|k,v| v.length == 5}\n if @straight\n value = [900, @cards.first.value]\n else\n value = [600, @cards.first.value]\n end\n end\n if value[0] < 700\n if (a = @by_value.find {|k,v| v.length == 3 }) &&\n (b = @by_value.find {|k,v| v.length == 2 })\n value = [700, a[0], b[0]]\n elsif a = @by_value.find {|k,v| v.length == 4 }\n value = [800, a[0]] # Is it 4 of a kind\n end\n end\n if value[0] < 500 && (a = @by_value.find {|k,v| v.length == 3 })\n value = [400, a[0]] # Is it 3 of a kind\n end\n if value[0] < 400 \n if (a = @by_value.select {|k,v| v.length == 2}).length > 0\n if a.length == 2\n hi,low = a[a.keys.max], a[a.keys.min]\n high = @cards - hi - low\n value = [300,hi.first.value, low.first.value, high.first.value]\n else\n pair = a[a.keys.first]\n high = (@cards - pair).first\n value = [200,pair.first.value, high.value]\n end\n else\n value = [100, @cards.first.value]\n end\n end\n @value = value\n end", "def test_deck_size_fullDeck\n deck = Deck.new\n assert_equal(81, deck.size, \"Expected size of 81.\")\n end", "def size\n\t\t7500\n\tend", "def size(size)\n @value[:size] = size\n self\n end", "def card_stats\n stats = {\n colors: {\n W: 0,\n U: 0,\n B: 0,\n R: 0,\n G: 0,\n C: 0,\n M: 0,\n total: 0\n },\n types: {\n creature: { count: 0, subtypes: {} },\n enchantment: { count: 0, subtypes: {} },\n instant: { count: 0, subtypes: {} },\n land: { count: 0, subtypes: {} },\n sorcery: { count: 0, subtypes: {} },\n planeswalker: { count: 0, subtypes: {} },\n artifact: { count: 0, subtypes: {} },\n },\n cmc: {\n 1 => 0,\n 2 => 0,\n 3 => 0,\n 4 => 0,\n 5 => 0,\n 6 => 0,\n },\n counts: {\n creature: 0,\n nonCreature: 0,\n land: 0,\n nonLand: 0,\n },\n rarity: {\n common: 0,\n uncommon: 0,\n rare: 0,\n mythic: 0,\n special: 0,\n bonus: 0\n },\n cards: 0,\n }\n\n cards = self.cards\n # Iterates over every card and updates stats object\n cards.each do |card|\n multiplier = card.deck_quantity(id).quantity\n\n # Increment total cards\n stats[:cards] += multiplier\n\n\n # Card types, they have been stringified so we must parse them\n card_types = card.card_types\n types = stats[:types]\n\n\n # Counts the card types\n card_types.each do |type|\n lower_type = type.downcase().to_sym\n \n if types[lower_type]\n types[lower_type][:count] += multiplier\n end\n \n \n # Counts the card subTypes\n card.subtypes&.each do |subtype|\n lower_subtype = subtype.downcase().to_sym\n\n if types[lower_type] && types[lower_type][:subtypes] && types[lower_type][:subtypes][lower_subtype]\n types[lower_type][:subtypes][lower_subtype] += multiplier\n elsif types[lower_type] && types[lower_type][:subtypes]\n types[lower_type][:subtypes][lower_subtype] = multiplier\n end\n end\n end\n\n\n # Counts multicolored cards and individual colors\n if card.color_identity.length > 1\n stats[:colors][:M] += multiplier\n end\n\n \n\n # Artifacts do not have colors, so we increment colorless\n if (card.color_identity.length === 0) \n stats[:colors][:C] += multiplier\n stats[:colors][:total] += multiplier\n end\n \n \n \n # Otherwise we update the color identity\n card.color_identity.each { |color|\n stats[:colors][color.to_sym] += multiplier\n stats[:colors][:total] += multiplier\n }\n\n\n # if the card is a land we just need to up the land count. Otherwise we set a few more counts\n if (card.card_type.include?('Basic Land')) \n stats[:counts][:land] += multiplier\n else\n stats[:counts][:nonLand] += multiplier\n\n \n # Updates counts for creatures and nonCreatures\n if card_types.include?('Creature')\n stats[:counts][:creature] += multiplier\n else\n stats[:counts][:nonCreature] += multiplier\n end\n\n # Gets converted mana cost counts\n card_cmc = card.converted_mana_cost\n \n # Increments 1 mana for 1 or 0 cmc\n if (card_cmc <= 1) \n stats[:cmc][1] += multiplier\n \n # Increments 6 mana for 6 or more cmc\n elsif (card_cmc >= 6) \n stats[:cmc][6] += multiplier\n \n # Otherwise we increment what's in-between as long as it's not a land\n else\n stats[:cmc][card_cmc.to_i] += multiplier\n end\n \n # counts card rarity, doesn't include basic lands\n stats[:rarity][card.rarity.to_sym] += multiplier\n end\n\n\n end\n\n stats\n end", "def build_card\n @items = game.reset_items\n @card = BingoBuilder::Card.new(@game.title, @game.size)\n add_mandatory_items\n add_discretionary_items\n @card\n end", "def full_contract_length\n full_length = self.contract_length\n if self.is_extended\n full_length += 1\n end\n\n if self.is_franchised\n full_length += 1\n end \n full_length\n end", "def size\nend", "def quantity(card)\n external_deck_instances.find_by(card_id: card.id).quantity\n end" ]
[ "0.6967645", "0.69532734", "0.6944996", "0.67095095", "0.6670523", "0.6670523", "0.65640694", "0.65004814", "0.64327115", "0.6409271", "0.6327344", "0.62774354", "0.62380415", "0.61485076", "0.6099927", "0.60522753", "0.6046741", "0.6040553", "0.6014089", "0.6009662", "0.59384614", "0.588877", "0.58847904", "0.58847904", "0.58847904", "0.5883377", "0.5883377", "0.58775246", "0.5875801", "0.5846524", "0.58452135", "0.58246547", "0.5808997", "0.5808997", "0.5792766", "0.5791059", "0.5789515", "0.57830167", "0.57830167", "0.57741094", "0.5766873", "0.5748633", "0.573904", "0.57324773", "0.5726704", "0.5698587", "0.5697736", "0.5686787", "0.5663109", "0.5661913", "0.5659546", "0.5653326", "0.56480765", "0.5641659", "0.5629261", "0.56291384", "0.5622891", "0.56066865", "0.56021804", "0.5599287", "0.55974996", "0.55845046", "0.5581763", "0.55793995", "0.557896", "0.5552843", "0.55415416", "0.5535988", "0.5534253", "0.5532225", "0.5508258", "0.5505861", "0.5505861", "0.55042833", "0.55030257", "0.5502101", "0.5500933", "0.5500795", "0.54934275", "0.54847455", "0.54800373", "0.54746807", "0.54745966", "0.5471122", "0.5469147", "0.54572946", "0.54561913", "0.54523873", "0.54519284", "0.5450665", "0.54457855", "0.54366195", "0.54363257", "0.54335594", "0.5425429", "0.5419167", "0.5406269", "0.54024667", "0.5396041", "0.53716516", "0.5366327" ]
0.0
-1
def get_list_id list_name sql = %q[SELECT id FROM lists WHERE name = $1] result = db.exec(sql, [list_name]) result.first['id'] empty array could be returned here, check if something was found end def share_list other_user_id, list_id sql = %q[INSERT INTO shared_lists (user_id, list_id) VALUES ($1, $2) RETURNING ] result = db.exec(sql, [other_user_id, list_id]) result.first end Make sure there is some verification of contents, array could be empty result.first is a good example
def get_user_lists user_id sql = %q[SELECT * FROM lists WHERE user_id = $1 ] result = db.exec(sql, [user_id]) result.entries.map{ |entry| build_list entry } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def user_info(user_id, list_id)\n return [db.execute(\"SELECT * FROM users WHERE user_id=?\", user_id), db.execute(\"SELECT * FROM listings WHERE list_id=?\", list_id)]\nend", "def already_shared(user_id, file_id)\n if $db.execute(\"SELECT * FROM shared_files WHERE file_id = ? AND user_id = ?\", file_id, user_id) != []\n return true\n end\n return false\nend", "def create_new_list(list_name) \n sql = \"INSERT INTO lists (name) VALUES ($1)\"\n result = query(sql, list_name)\n end", "def find_list_id(list_name)\n begin\n mailing_lists = @api.call(\"lists\", @api_key)\n @list = mailing_lists.find {|list| list[\"name\"] == list_name} unless mailing_lists.nil?\n @list_id = @list['id']\n rescue\n return nil\n end\n end", "def create\n puts params[\"user_ids\"]\n puts \"in create\"\n if params[:new_list_name].nil? || params[:new_list_name].blank? && params[:list_name] != \"\" && !params[\"user_ids\"].nil?\n puts \"in creating from existing\"\n @list_name = params[:list_name]\n @saved_list = SavedList.find(params[:list_name])\n @user_ids = params[\"user_ids\"]\n @int_user_ids = @user_ids.map(&:to_i) #Changing string ids to integer\n\n # Removes duplicates from Saved Lists\n # Authored by Ryan Hilsabeck(previous version did not remove duplicates)\n @saved_list_user_ids = Array.new\n @saved_list.users.each do |u|\n @saved_list_user_ids.push (u.id)\n end\n\n @new_ids_for_list = Array.new\n\n @int_user_ids.each do |u|\n if @saved_list_user_ids.index(u)\n puts \"it exists\"\n else\n @new_ids_for_list.push (u)\n end\n end\n # End remove duplicates code\n\n @new_ids_for_list.each do |user_id|\n SavedListUser.create(saved_list_id: @saved_list.id, user_id: user_id)\n end\n @saved_list.save\n redirect_to @saved_list\n elsif !params[\"user_ids\"].nil? && (params[:new_list_name] != \"\" && !params[:new_list_name].nil? || !params[:new_list_name].blank?)\n puts \"in trying to create new list\"\n # Create new saved list table entry\n @saved_list = SavedList.new\n # Store attributes\n @saved_list.list_name = params[:new_list_name]\n @saved_list.login_id = params[:login_id]\n @saved_list.date_saved = params[:date_saved]\n @saved_list.saved_user_list = true\n # Save the saved list\n respond_to do |format|\n if @saved_list.save\n\n # Create new user saved list entries for all users in list\n @user_ids = params[\"user_ids\"]\n @int_user_ids = @user_ids.map(&:to_i) #Changing string ids to integer\n\n # Removes duplicates from Saved Lists\n # Authored by Ryan Hilsabeck(previous version did not remove duplicates)\n @saved_list_user_ids = Array.new\n @saved_list.users.each do |u|\n @saved_list_user_ids.push (u.id)\n end\n\n @new_ids_for_list = Array.new\n\n @int_user_ids.each do |u|\n if @saved_list_user_ids.index(u)\n puts \"it exists\"\n else\n @new_ids_for_list.push (u)\n end\n end\n # End remove duplicates code\n\n @new_ids_for_list.each do |user_id|\n SavedListUser.create(saved_list_id: @saved_list.id, user_id: user_id)\n end\n\n format.html { redirect_to @saved_list, notice: 'Saved list was successfully created.' }\n format.json { render :show, status: :created, location: @saved_list }\n else\n format.html { render :new }\n format.json { render json: @saved_list.errors, status: :unprocessable_entity }\n end\n end\n else\n redirect_to saved_lists_path\n end\n end", "def get_shared_files(user_id)\n shared_file_ids = $db.execute(\"SELECT file_id FROM file_share_table WHERE user_id = ?\", user_id)\n \n files = []\n shared_file_ids.each do |id|\n files << $db.execute(\"SELECT * FROM files WHERE id = ?\", id[\"file_id\"])[0]\n end\n return files\nend", "def set_list\n @lists = List.where(user_id: params[:id])\n end", "def create_or_get_list(name)\n list = find_lists(name)&.first || handle_response(client.create_dashboard_list(name))\n get_list(list['id'])\n end", "def get_list_id(client,list_name)\n puts \"Getting the listName\" if @enable_debug_logging\n # Send the request to get the list info\n begin\n response = client.request(:get_list) do\n soap.body = {:listName => list_name}\n end\n rescue Savon::SOAP::Fault\n raise StandardError, \"The list '#{@parameters['list_name']}' cannot be found on the Sharepoint site\"\n rescue Exception => ex\n raise\n end\n\n # Retrieving the from the response\n return response.body[:get_list_response][:get_list_result][:list][:@name]\n end", "def find_list\n @list = current_user.lists.find params[:id]\n end", "def insert( list_name, owner, author, text, full_message, submitted )\n # TODO Checking friendship existance requires oauth\n # if owner != author and not base.friendship_exists?(owner, author)\n # puts(owner + \" does not follow \" + author + \". Not adding list.\")\n # else\n # puts (owner + \" \" + author + \" are friends, adding to list.\")\n # end\n \n @list = List.find( :first, \n :conditions => { :name => list_name,\n :owner => owner } )\n \n if not @list\n \n #Don't allow creating a list for someone else.\n if owner != author\n puts (owner + \" \" + author + \" \" + list_name + \" doesn't exist, not creating.\")\n return false\n end\n \n @list = List.new({ \"owner\" => owner,\n \"name\" => list_name,\n \"permission\" => \"public\" } )\n @list.save #TODO error handling here like in list create method\n end\n \n #Created a list but no more items\n if text == \"\"\n return false\n end\n \n #Check if the item exists, since we assume the messages\n #come in chronological order, we can just break when\n #we find something.\n @item = Item.find( :first,\n :conditions => { :author => author,\n :text => text,\n :submitted => submitted } ) \n #Clean up this search by using the submit time and the list name or ID TODO\n #TODO really need to check submit time to make sure it's the same message\n if @item\n puts(\"Already saw this element before\")\n return true\n end\n \n @item = @list.items.build( { :author => author,\n :text => text,\n :fullMessage => full_message,\n :submitted => submitted } )\n @item.save #TODO error handling\n print \"item saved\"\n \n return false\n end", "def share_file(file_id, email)\n user_data = $db.execute(\"SELECT id FROM users WHERE email = ?\", [email])[0]\n if user_data == nil\n return false\n end\n user_id = user_data[\"id\"]\n $db.execute(\"INSERT INTO file_share_table (file_id, user_id) VALUES (?, ?)\", [file_id, user_id])\n return true\nend", "def set_list\n @list = current_user.lists.find(params[:list_id])\n end", "def set_list\n @list = current_user.lists.find(params[:list_id])\n end", "def set_list\n @list = current_user.lists.find(params[:id])\n end", "def user_query(list)\n\t\treturn nil if !list\n\n\t\tif !list.kind_of?(Array)\n\t\t\ttmp = list\n\t\t\tlist = Array.new\n\t\t\tlist << tmp\n\t\tend\n\n\t\treturn nil if list.empty?\n\n\t\tActiveRecord::Base.silence_auto_explain do\n\t \t# no automatic EXPLAIN is triggered here\n\t\t\treturn SitrackTracking.find_by_sql(\n\t\t\t\t'SELECT p.accountNo, p.firstName, p.lastName, p.preferredName, s.email, s.mobilePhone, s.homePhone, s.otherPhone ' +\n\t\t\t\t'FROM ministry_person AS p ' +\n\t\t\t\t'LEFT JOIN ministry_staff AS s ON p.personID = s.person_id ' +\n\t\t\t\t\"WHERE p.accountNo IN (#{list.map{|u| \"'#{u}'\"}.join(',')})\"\n\t\t\t\t)\n\t\tend\n\tend", "def set_list\n @list = @lists.find(params[:id])\n end", "def load_list(id)\n # look thru the session to find a list w/ the spec'd id\n # list = session[:lists].find { |list| list[:id] == id } # moved to SessionPersistence\n\n # the storage obj holds all data for our ap;\n # it is an instance of the SessionPersistence class\n list = @storage.find_list(id)\n\n return list if list\n session[:error] = \"The specified list was not found\"\n redirect \"/lists\"\nend", "def list\n session[:list_type_id] = ListType.find(:first).id if session[:list_type_id] == nil\n @list_items = ListItem.find_all_by_user_id_and_list_type_id(\n session[:user_id], \n session[:list_type_id],\n :order => \"position\") \n if @list_items.size > 0\n @list_item = @list_items.first\n session[:list_item_id] = @list_items.first.id\n else\n session[:list_item_id] = nil\n end\n end", "def load_list(id)\n list = @storage.find_list(id)\n return list if list\n\n session[:error] = 'The specified list was not found.' # session[:lists] is an array of lists, each list being a hash. if an index is attempted to be accessed that doesn't exist, like /lists/10234, then we want a redirect to home page: https://launchschool.com/lessons/31df6daa/assignments/cb2ef1d2\n redirect '/lists' # \"/\" redirects to \"/lists\" of course, the home\nend", "def find_friend_id(db, friend_name)\n friend_id = db.execute(\"SELECT friends.id FROM friends WHERE friend_name='#{friend_name}'\")\n friend_id[0][0]\nend", "def create_list(name)\n path = \"lists\"\n params = { list: { name: name }}\n list = request(path, params, :post)\n list_id = list[:id]\n # output full list again\n show_list(list_id)\n end", "def load_list(id)\n list = session[:lists].find { |list| list[:id] == id }\n return list if list\n\n session[:error] = \"The specified list was not found.\"\n redirect \"/lists\"\nend", "def share_file_with_user(user_id, file_id)\n $db.execute(\"INSERT INTO shared_files (user_id, file_id) VALUES (?, ?)\", user_id, file_id)\nend", "def getList(userName,listName)\n\t\tbegin\n\t \tlist = TwitterClient.owned_lists(userName)\n\t \t@selectedList=\"\"\n\t \tlist.each do |listTMP|\n\t \t\tif(listTMP.name==listName)\n\t \t\t\t@selectedList = listTMP\n \t\t\tend\n\t \tend\n\t \t@selectedList\n\t\trescue\n\t\t\t-1\n\t\tend\n\tend", "def set_list\n @list = current_user.lists.find(params[:list_id])\n end", "def set_list\n @list = current_user.lists.find(params[:id])\n end", "def insert_article_list(res, id, title, link)\n if res['exists(select 1 from article_lists where article_url=?)'] == 0\n stmt = @sql.prepare \"insert into article_lists (site_list_id, title, article_url) values(?,?,?)\"\n stmt.execute(id, title, link)\n id_res = @sql.query 'select last_insert_id() from article_lists'\n roles = @sql.query \"select role from site_roles where deleted_at is null and site_list_id=#{id} order by priority desc\"\n r = @http.get(link, :follow_redirect => true)\n id_res.each_with_index {|nowid, i| extract_html(r.body, roles, nowid['last_insert_id()']) if r.status == 200 && i == 0}\n end\n end", "def set_current_list_id!\n # session[:list_id] = nil\n if session[:list_id].nil? \n if user_signed_in?\n lists = current_user.lists\n session[:list_id] = lists.first.id if lists.any?\n end\n else\n if user_signed_in?\n list = current_list\n session[:list_id] = nil unless list.user == current_user\n end\n end\n end", "def media_promotion_list_id\n @media_promotion_list_id ||= client.lists({:filters=>{:list_name=>@group_name}})['data'].first['id'] \n end", "def current_search_list\n SearchList.find(session[:search_list_id])\n rescue ActiveRecord::RecordNotFound\n list = SearchList.create\n session[:search_list_id] = list.id\n list\n end", "def return_id(db, user_name)\r\n\tretrieve_id = '\r\n\tSELECT id FROM users\r\n\tWHERE name = ?'\r\n\tid = db.execute(retrieve_id, [user_name])\r\nend", "def related_users_query(list_id)\n <<-SQL\n SELECT DISTINCT \"users\".*\n FROM \"users\"\n INNER JOIN \"users_lists\"\n ON \"users\".\"id\" = \"users_lists\".\"user_id\"\n WHERE \"users_lists\".\"list_id\" IN (\n SELECT \"lists\".\"id\"\n FROM \"lists\"\n INNER JOIN \"users_lists\"\n ON \"lists\".\"id\" = \"users_lists\".\"list_id\"\n WHERE \"users_lists\".\"user_id\" = #{id}\n )\n AND NOT \"users\".\"id\" IN (\n SELECT \"users_lists\".\"user_id\"\n FROM \"users_lists\"\n WHERE \"users_lists\".\"list_id\" = #{list_id}\n );\n SQL\n end", "def admin(user_id)\n return [db.execute(\"SELECT * FROM users WHERE user_id=?\", user_id), db.execute(\"SELECT * FROM users\")]\nend", "def create\n\n # Create new saved list table entry\n @saved_list = SavedList.new\n\n # Store attributes\n @saved_list.login_id = params[:login_id]\n @saved_list.list_name = params[:list_name]\n @saved_list.saved_user_list = true\n @saved_list.date_saved = params[:date_saved]\n\n # Save the saved list\n respond_to do |format|\n if @saved_list.save\n\n # Create new user saved list entries for all users in list\n @user_ids = params[\"user_ids\"]\n @user_ids.each do |user_id|\n SavedListUser.create(saved_list_id: @saved_list.id, user_id: user_id)\n end\n\n format.html { redirect_to @saved_list, notice: 'Saved list was successfully created.' }\n format.json { render :show, status: :created, location: @saved_list }\n else\n format.html { render :new }\n format.json { render json: @saved_list.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n #@list = List.new(list_params)\n @list = current_user.lists.create(list_params)\n if params[:campsite_id] && @list.listeds.find_by_campsite_id(params[:campsite_id]).blank?\n campsite = Campsite.find(params[:campsite_id])\n @listed = campsite.listeds.create(list:@list.id, user_id:current_user.id)\n #@listed = Listed.new()\n #@listed.list_id = @list.id\n #@listed.user_id = current_user.id\n #@listed.save\n end\n\n respond_to do |format|\n if @list.save\n format.html { redirect_to management_lists_path, notice: 'List was successfully created.' }\n format.json { render action: 'show', status: :created, location: @list }\n else\n format.html { render action: 'new' }\n format.json { render json: @list.errors, status: :unprocessable_entity }\n end\n end\n end", "def load_list(id)\n list_to_load = @lists.find { |list| list[:id] == id }\n if !list_to_load\n session[:error] = \"The specified list was not found.\"\n redirect \"/lists\"\n else\n list_to_load\n end\nend", "def filter_by_list(list, other_list)\n other_list.select{|lt| \n lt['list_id'].to_s == list.id.to_s\n }\n end", "def list_id\n raise 'answer a unique, never changing value'\n end", "def set_list\n @list = @organization.lists.find_by_permalink(params[:id])\n raise ActiveRecord::RecordNotFound unless @list\n end", "def get_users_with_access(file_id)\n return $db.execute(\"SELECT user_id FROM shared_files WHERE file_id = ?\", file_id)\nend", "def load_list(index)\n list = session[:lists][index] if index && session[:lists][index]\n return list if list\n\n session[:error] = \"The specified list was not found.\"\n redirect \"/lists\"\nend", "def find_list\n @list = @topic.lists.find(params[:list_id])\n end", "def find_list\n @list = List.find(params[:id])\n end", "def check_and_assign_shared_ids_to_shared_folders \n #First checking if the new user's email exists in any of ShareFolder records \n shared_folders_with_same_email = SharedFolder.find_all_by_shared_email(self.email) \n \n if shared_folders_with_same_email \n #loop and update the shared user id with this new user id \n shared_folders_with_same_email.each do |shared_folder| \n shared_folder.shared_user_id = self.id \n shared_folder.save \n end \n end \n end", "def check_and_assign_shared_ids_to_shared_folders \n #First checking if the new user's email exists in any of ShareFolder records \n shared_folders_with_same_email = SharedFolder.find_all_by_shared_email(self.email) \n \n if shared_folders_with_same_email \n #loop and update the shared user id with this new user id \n shared_folders_with_same_email.each do |shared_folder| \n shared_folder.shared_user_id = self.id \n shared_folder.save \n end \n end \n end", "def get_entry(first_name, last_name)\n begin\n conn = open_db()\n query = \"select * from listings where fname = $1 and lname = $2\"\n conn.prepare('q_statement', query)\n user_hash = conn.exec_prepared('q_statement', [first_name, last_name])\n conn.exec(\"deallocate q_statement\")\n user_hash.to_a.size > 0 ? (return user_hash[0]) : (return {})\n rescue PG::Error => e\n puts 'Exception occurred'\n puts e.message\n ensure\n conn.close if conn\n end\nend", "def use_saved_list\n logger.debug \"**** USE SAVED LIST ****\"\n \n show_params(params) #debug params and put them in logs\n saved_contact_list_id = params[:search][:list_id]\n if saved_contact_list_id != ''\n @saved_contact_list = SavedContactList.find(saved_contact_list_id)\n @contacts = @saved_contact_list.contributors\n \n session[:contacts_from_search] = @contacts\n \n @already_selected = session[SELECTED_CONTACTS]\n logger.debug \"Contributors from saved list @ #{@contacts}\"\n \n # processing for existent contacts from mailout or saved contact lists\n saved_list_contacts = session[:list_contacts]\n mailout_list_contacts = session[:mailout_contacts]\n if saved_list_contacts != nil\n @already_selected = @already_selected + saved_list_contacts\n end\n if mailout_list_contacts != nil\n @already_selected = @already_selected + mailout_list_contacts\n end \n \n #Given we have got this far, store the search details in the session\n session[:last_search_details ] = {:list => @saved_contact_list.id}\n end\n render :layout => false\n end", "def find_user_id (db, user)\n user_values = db.execute(\"SELECT id FROM user WHERE name = ?\", [user])\n user_values[0][0]\nend", "def set_list\n @list = List.find(params[:id])\n end", "def set_list\n @list = List.find(params[:id])\n end", "def set_list\n @list = List.find(params[:id])\n end", "def set_list\n @list = List.find(params[:id])\n end", "def sync_list(list_type)\n \n #Update account_info \n #TODO make sure this isn't called four times if all lists are syncghronized together\n @account_info = @authenticator.get_account\n\n \n #lists_array is the array that stores the user's lists of the given type\n #For example, @locations\n \n lists_array = self.send(\"#{list_type}s\")\n \n\n #Add any new locations\n new_lists = lists_array.keys.select{|list| list.brand_new}\n \n #TODO rewrite this to use only one API query, if API supports it\n unless new_lists.empty? #Won't be redundant if/when the loop is eliminated\n new_lists.each do |list| \n @authenticator.send(\"add_#{list_type}\", list.json_parsed)\n list.no_longer_new!\n end\n end\n \n #Delete any deleted locations \n\n #Get all the lists that have been deleted locally \n del_lists = lists_array.values.select{|list| list.deleted}\n\n unless del_lists.empty?\n del_lists.each do |list|\n @authenticator.send(\"delete_#{list_type}\", list.json_parsed)}\n lists_array.delete(list.id)\n list.delete!\n list.edit_saved\n end\n end\n \n #TODO delete the lists locally if they have been deleted on the server\n\n #Only fetch from server and do conflict resolution if the last edit on the server was later than the last sync for the list\n \n if self.send(\"lastedit_#{list_type}\") > self.send(\"last_#{list_type}_sync\") \n\n #Get the lists\n lists = @authenticator.send(\"get_#{list}s\")\n\n locally_edited = []\n \n lists.each do |list|\n if not lists_array[list.id]\n #If for some reason we don't have the list locally, store the list locally and move on.\n lists_array[list.id]\n else\n #Otherwise, compare modification times, update local copy when necessary, and resolve editing conflicts\n \n if self.send(\"lastedit_#{list}\") > lists_array[task.id].last_mod\n #The server-stored list was modified more recently than the local task\n #TODO make sure the list object is unique by ID\n \n lists_array[list.id].json_parsed = list.json_parsed\n lists_array[list.id].edit_saved\n else\n #The local list was modified more recently than the server-stored task\n #Assume the local copy is more accurate if the two timestamps are somehow the same\n locally_edited.push(lists_array[task.id])\n @authenticator.send(\"edit_#{list}\", list.json_parsed) unless list.deleted?\n list.edit_saved\n end\n end\n end\n end\n\n\n #TODO will this work if it is not public?\n self.send(\"last#{list_type}_sync=\", Time.now)\n \n #Remove all locally deleted lists of this type\n self.send(\"#{list_type}s=\", lists_array.values.select{|list| not list.deleted})\n\n #All of the lists have now been synchronized since they were last created\n self.send(\"#{list_type}s\").each{|list| list.no_longer_new!}\n end", "def list_exists?(name)\n @lists.detect { |list| list.name == name }\n end", "def set_list\n @list = List.find(params[:list_id])\n end", "def set_list\n @list = List.find(params[:list_id])\n end", "def set_list\n @list = List.find(params[:list_id])\n end", "def get_list(user, list)\n get(\"/#{user}/lists/#{list}.json\")\n end", "def create_song(db,song_name,artist_name,playlist_id)\n\tdb.execute(\"INSERT INTO songlist (song_name,artist_name,playlist_id) VALUES ('#{song_name}', '#{artist_name}', #{playlist_id});\")\nend", "def set_list_by_id\n @list = List.find(params[:id])\n end", "def load_list(index)\n list = @storage.find_list(index)\n return list if list\n\n session[:error] = 'The specified list was not found.'\n redirect '/lists'\nend", "def sync_list(options, force = false)\n (get_list(options, force)['ID'] rescue nil) || create_list(options)\n end", "def print_list(db, current_user)\r\n results = db.execute(\"SELECT * FROM items WHERE user_id = ?\", [current_user])\r\n results.each do |item|\r\n puts \"#{item[1]} x#{item[2]}\"\r\n end\r\nend", "def find_lists(x)\n lists.select do |l|\n (l['name'] == x) || (l['id'] == x)\n end\n end", "def getUserListInchannel(idChan)\n begin\n userlList = []\n query = \"SELECT id_user,last_name,first_name,profile_img FROM `#{USER_TABLE}` \n INNER JOIN #{USER_LIST_IN_CHAN_TABBLE} \n ON #{USER_TABLE}.id_user = #{USER_LIST_IN_CHAN_TABBLE}.user_id_user \n WHERE #{USER_LIST_IN_CHAN_TABBLE}.channel_id_channel = #{idChan}\"\n \n self.connect unless self.connected? # => connect to the DB server if not connected\n \n sth = @dbh.prepare(query)\n \n sth.execute()\n \n sth.fetch { |row| \n userlList << Hash[\"id\" => row[0],\n \"last_name\" => to_utf8(row[1]),\n \"first_name\" => to_utf8(row[2]),\n \"img_url\" => row[3]\n ]\n } \n \n \n sth.finish\n \n rescue DBI::DatabaseError => e\n puts \"An error occurred\"\n puts \"Error code: #{e.err}\"\n puts \"Error message: #{e.errstr}\"\n @dbh.rollback\n rescue Exception => e \n puts \"error!!! -> : #{e.to_s}\"\n \n ensure\n # disconnect from server\n @dbh.disconnect if @connected\n @connected=false\n end\n return userlList\n end", "def merge_list!(list_id_or_screen_name)\n case list_id_or_screen_name\n when Integer\n self[:list_id] = list_id_or_screen_name\n when String\n self[:slug] = list_id_or_screen_name\n end\n self\n end", "def merge_list!(list_id_or_screen_name)\n case list_id_or_screen_name\n when Integer\n self[:list_id] = list_id_or_screen_name\n when String\n self[:slug] = list_id_or_screen_name\n end\n self\n end", "def get_list(list_id)\n rest(\"get\", \"lists/#{list_id}\")\n end", "def create\n campsite = Campsite.find(params[:campsite_id])\n if user_signed_in? && current_user.lists.find(params[:list_id]).present? #verify ownership\n unless campsite.listeds.present? && campsite.listeds.where(list_id:params[:list_id]).present?\n #Listed.find_by(list_id:params[:list_id], listable_id:campsite.id, listable_type:'Campsite').blank?\n # if it passes these hurdles, create the list\n #if campsite.listeds.find_by(list_id:params[:list_id]).blank? && !current_user.lists.find_by(list_id:params[:list_id]).blank?\n @listed = campsite.listeds.create(list_id:params[:list_id])\n else\n @listed = campsite.listeds.find_by(list_id:params[:list_id])\n end\n end\n\n respond_to do |format|\n if @listed.save\n puts \"Campsite was added to list\"\n format.html { redirect_to session[:previous_url], notice: 'List item was successfully created.' }\n format.json { render json: {message:\"Created successfully\"} }\n else\n puts \"Campsite was not added to list\"\n format.html { render action: 'new' }\n format.json { render json: @listed.errors, status: :unprocessable_entity }\n end\n end\n end", "def show_list(db)\n\tcurrent_list = db.execute(\"Select * FROM list\")\n\tcurrent_list.each do |row|\n\tputs \"ID: #{row['id']} | #{row['name']} | #{row['gift']} | #{row['price']}\"\n\tend\n\tputs \"---------------------------\"\nend", "def get_all_shared_files_for_user(user_id)\n return $db.execute(\"SELECT * \n FROM files \n INNER JOIN shared_files ON files.file_id = shared_files.file_id\n INNER JOIN users ON files.owner_id = users.user_id\n WHERE shared_files.user_id = ?\", user_id)\nend", "def get_student_id(database, name)\r\n\tstudent = database.execute(\"SELECT * FROM students WHERE name=?\",[name])\r\n\tstudent_id = student[0][0].to_i\r\nend", "def current_list\n List.find(session[:list_id])\n end", "def print_individual_contact(list)\n puts \"Please enter name to search:\"\n input_name = gets.chomp.downcase\n\n print_list = list.execute(\"SELECT * FROM contacts WHERE name = '#{input_name}' \")\n puts print_list\nend", "def check_valid_list_id!\n assoc_class = ModelReference.to_record_class_for_type assoc_name.singularize\n assoc_item = assoc_class.where(list_on_attr => list_id).first\n return if assoc_item\n\n raise FphsGeneralError, \"list id does not represent an associated list: #{list_id} for #{assoc_class}\"\n end", "def check_duplicate_item(db, tbl,field_name,value)\r\n check_command = \"Select * from ? where ? = ?\",[tbl, field_name,value]\r\n if db.execute(check_command).length > 0\r\n return true\r\n else \r\n return false \r\n end \r\nend", "def create_wish_list(db)\r\n create_wish_list_cmd = <<-SQL\r\n CREATE TABLE IF NOT EXISTS wish_list(\r\n wish_id INTEGER PRIMARY KEY,\r\n title VARCHAR(255),\r\n author VARCHAR(255),\r\n reader_id INTEGER,\r\n FOREIGN KEY (reader_id) REFERENCES book_readers(reader_id)\r\n )\r\n SQL\r\n #create wish list table\r\n db.execute(create_wish_list_cmd)\r\nend", "def set_listname\n @listname = Listname.find(params[:id])\n end", "def all_playlists_songs\n sql = \"SELECT * FROM playlists_songs;\"\n # implicit return\n run_sql(sql)\nend", "def instantiate_current_list_cookie\n\t\tif session[:current_list].blank?\n\t \tsession[:current_list]=current_user.lists.first.id\n\t end\n\tend", "def list_params\n params.require(:list).permit(:name).merge(user_id: current_user.id)\n end", "def set_list\n @list = List.friendly.find(params[:id])\n end", "def add_users(ids)\n\t\t self.shared_users = ids.split(\",\").map do |id|\n \t\tUser.where(id: id.strip).first_or_create!\n \tend\n\tend", "def add_asin(asin)\r\n match = $db.execute(\"SELECT asin FROM asins WHERE asin = ?\", [asin])\r\n if match == []\r\n $db.execute(\"INSERT INTO asins (asin) VALUES (?)\", [asin])\r\n end\r\nend", "def check_and_assign_shared_ids_to_shared_folders\n #First checking if the new user's email exists in any of SharedFolder records\n shared_folders_with_same_email = SharedFolder.find_all_by_shared_email(self.email)\n\n if shared_folders_with_same_email\n # Loop and update the shared user id with this new user id\n shared_folders_with_same_email.each do |shared_folder|\n shared_folder.shared_user_id = self.id\n shared_folder.save\n end\n end\n end", "def set_list\n @list = List.find(params[:list_id])\n end", "def set_list\n @list = List.find(params[:id])\n end", "def set_list\n @list = List.find(params[:id])\n end", "def set_list\n @list = List.find(params[:id])\n end", "def set_list\n @list = List.find(params[:id])\n end", "def set_list\n @list = List.find(params[:id])\n end", "def set_list\n @list = List.find(params[:id])\n end", "def set_list\n @list = List.find(params[:id])\n end", "def set_list\n @list = List.find(params[:id])\n end", "def set_list\n @list = List.find(params[:id])\n end", "def set_list\n @list = List.find(params[:id])\n end", "def set_list\n @list = List.find(params[:id])\n end", "def set_list\n @list = List.find(params[:id])\n end", "def set_list\n @list = List.find(params[:id])\n end" ]
[ "0.6547393", "0.642324", "0.6395162", "0.6298203", "0.61114174", "0.60435504", "0.5993598", "0.5991419", "0.59888035", "0.59840375", "0.59094507", "0.5810523", "0.58045214", "0.58045214", "0.5753239", "0.574084", "0.5718982", "0.5712895", "0.57052", "0.5633266", "0.56257546", "0.56232864", "0.561979", "0.56166", "0.56152266", "0.5612947", "0.5570178", "0.5546145", "0.55288094", "0.55216324", "0.55178857", "0.55011183", "0.5500806", "0.5476646", "0.54567426", "0.5451621", "0.5444482", "0.54433614", "0.5419563", "0.53997606", "0.5399195", "0.53919625", "0.53913754", "0.53778744", "0.5360647", "0.535919", "0.53477544", "0.53443366", "0.533489", "0.5311575", "0.5311575", "0.5311575", "0.5311575", "0.5305121", "0.5295348", "0.52936584", "0.52936584", "0.52936584", "0.5291806", "0.5283004", "0.52780205", "0.5275472", "0.5264517", "0.525747", "0.52536666", "0.5241009", "0.52306443", "0.52306443", "0.52236444", "0.522133", "0.5217914", "0.52070904", "0.5205699", "0.5199828", "0.517939", "0.5174418", "0.51730055", "0.5167621", "0.51661074", "0.51582545", "0.51540834", "0.5150059", "0.51499707", "0.5149229", "0.5145455", "0.5142409", "0.5141781", "0.5141658", "0.5141658", "0.5141658", "0.5141658", "0.5141658", "0.5141658", "0.5141658", "0.5141658", "0.5141658", "0.5141658", "0.5141658", "0.5141658", "0.5141658" ]
0.54742646
34
x is either the recommended value (Integer) or the query result (String) prior to conversion to Integer
def validate( x ) (x.to_s =~ /\A[1-5]\Z/) ? true : false end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def post_process_integer( val )\n\t\t\treturn Integer( val.to_s )\n\t\tend", "def pres(x)\n\tif x<10\n\t\treturn x = \"0\" + x.to_s\n\telse\n\t\treturn x = x.to_s\n\tend\nend", "def return_value(x)\n\tif x > 1\n\t\treturn x\n\telse\n\tend\nend", "def result\n value.sub(/^integer-/, '').to_i\n end", "def get_integer_value(field_name)\n\t\tend", "def get_integer_value\n\t\tend", "def column_value_integer\n column_value.to_i.to_s\n end", "def handle_integer_conversion(id) \n (Integer(id) rescue nil).nil? || id.to_i.to_s != id.to_s ? id : id.to_i\n end", "def integer(x)\n # return integer?(x) ? x.round : nil\n r = x.round\n ((x-r).abs <= relative_to(x)) ? r : nil\n end", "def result\n map_value(converted_value: RDF::Literal.new(\n value.value,\n datatype: PermissiveSchema.valkyrie_int\n ))\n end", "def int_value\n return @int_value unless @int_value.nil?\n if is_string == 0\n @int_value = value_or_ofs_value\n end\n @int_value\n end", "def return_num(res)\n if res then res.to_i else res end\n end", "def to_i_with_method\n to_x_with_method.to_i\n end", "def integer_or_float(x)\n if x.include?(\".\")\n return x.to_f\n else\n return x.to_i\n end\nend", "def value_loader\n @data_type == 'integer' ? :to_i : :to_s\n end", "def int_value(param)\n return \"$#{param.to_s}\"\nend", "def value(x=nil)\n if x\n relative_to(x)\n else\n @value\n end\n end", "def x=(new_x)\n @x = new_x.to_f if new_x\n end", "def coerce(x)\n return x.coerce(self.value)\n end", "def format_int_or_float(final_value)\n final_value == final_value.to_i ? final_value.to_i : final_value\n end", "def result_string\n case\n when result > 0 then \"+#{result}\"\n when result == 0 then \"=\"\n when result < 0 then result.to_s\n end\n end", "def convert(integer:)\n integer == 0 ? \"#{integer}\" : calculate(integer: integer)\n end", "def get_value\n @value.to_i\n end", "def cmd_numeric(obj)\n return handle_return_object(obj[:val].to_i)\n end", "def transform_value(value)\n if value.to_i.to_s == value\n value = value.to_i\n else\n value = nil\n end\nend", "def integer\n lambda do |x, convert = false|\n return x.to_i if convert\n\n x.is_a? Integer\n end\n end", "def searchby(criteria, value, lib)\r\n\t#clear unnecessary apostrophes, and return to int if that was the intention\r\n\tvalue = value.to_s.gsub(\"'\"){\"''\"}\r\n\t#run a sligtly different search if value.class = int...\r\n\tif value.to_i == 0\t\r\n\t\t#if value is a string, then we add '' around the value\r\n\t\treturn lib.execute(\"Select * from books join authors on books.author_id = authors.id WHERE #{criteria} = '#{value}'\")\r\n\telse#if value is a string, we pass it in without ''.\r\n\t\treturn lib.execute(\"Select * from books join authors on books.author_id = authors.id WHERE #{criteria} = #{value}\")\r\n\tend\r\n\r\nend", "def match_integer( val )\n\t\treturn Integer( val ) rescue nil\n\tend", "def bool_to_int(x)\n if x==true;1;elsif x==false;0;else; x;end\n end", "def fetch_value(value); end", "def query_return_first_value(sql, *binds)\n mysql.fetch(sql, *binds).single_value\n end", "def cast_numeric(arg, sql_type = nil)\n cast(arg, sql_type || Integer).sql_number\n end", "def fetch_value(sql)\n # Get the row\n row = fetch_row(sql)\n\n # Check field count\n if row.count > 1\n check.critical(\"Expected to receive a single value, but result has more than one field\", \"SQL: #{sql}\\nResult: #{row.inspect}\")\n end\n\n return row.values.first\n end", "def value; super.to_i; end", "def convert_to_test_value value, data_type\n if data_type == \"float\"\n test_value = (value.to_f * 1000).to_i\n else\n test_value = value.to_i\n end\n test_value\nend", "def cast_data_for_column(data, col)\n if !@columns\n raise \"need to fetch columns but in a query\"\n end\n\n case @columns[col][:type]\n when /boolean/i\n return data == true ? 1 : 0\n when /datetime/i\n return (data == nil ? nil : data.to_i)\n when /integer/i\n return (data == nil ? nil : data.to_i)\n else\n return data\n end\n end", "def interpret\r\n return @number.to_i\r\n end", "def res_ok?(x)\n x.to_i == x\nend", "def asin(x)\n asin_base(num_class[x])\n end", "def x\n @x ||= SpatialStats::Queries::Variables.query_field(@scope, @x_field)\n .standardize\n end", "def current_db_value\n return @current_db_value if @current_db_value\n debug \"Loading current value from DB\"\n table = @current_question[\"table\"]\n x = RT.custom_query(\"SELECT #{current_db_column} FROM #{table} WHERE path = ?\", [current_path], true)\n @current_db_value = x[current_db_column].to_i\n end", "def get_value_number\n value ? value : 0\n end", "def normalize_sqlite_result(result)\n data = result.select { |hash| hash.select!{|key, val| !key.is_a? Numeric }}\n data = data.first\n end", "def value_with_typecast\n if values == \"boolean\"\n value == \"true\" ? true : false\n elsif values.is_a?(Hash) && values[\"ids\"] == \"id\"\n value.to_i\n else\n value\n end\n end", "def get_x; \t\t@x \t\t\tend", "def lookup(val)\n rounded_value = val.respond_to?(:round) ? val.round : val\n transformed_value = (rounded_value < 1) ? 1 : rounded_value\n super(transformed_value.to_s)\n end", "def integer?(x)\n # Computing the tolerance at x seems the best option here\n (x-x.round).abs <= relative_to(x)\n end", "def to_int() end", "def to_int() end", "def return_int(number)\n if number == number.to_i\n number = number.to_i\n else\n number = number\n end\n end", "def x\n @x ||= SpatialStats::Queries::Variables.query_field(@scope, @field)\n .standardize\n end", "def to_i()\n #This is a stub, used for indexing\n end", "def getFirst_i( query, args=[] )\n res = self.exec( query, args ).values.first\n\n if res.is_a? Array\n res = res[0]\n end\n \n #self.bot.debug query + \" args: \" + args.inspect + \"\\n\"\n\n res.to_i\n end", "def values(x)\n thous = x / 1000\n hunds = (x % 1000) / 100\n tens = (x % 100) / 10\n ones = x % 10\n\n puts \"#{thous}\"\n puts \"#{hunds}\"\n puts \"#{tens}\"\n puts \"#{ones}\"\nend", "def explicit_integer(integer)\n integer.positive? ? \"+#{integer}\" : integer.to_s\n end", "def x=(x)\n if x.nil?\n fail ArgumentError, 'invalid value for \"x\", x cannot be nil.'\n end\n if x < 0\n fail ArgumentError, 'invalid value for \"x\", must be greater than or equal to 0.'\n end\n @x = x\n end", "def is_int\r\n\t\tself.to_i.to_s != self.to_s\r\n\tend", "def get_integer\n # Prepare query url.\n _query_builder = config.get_base_uri\n _query_builder << '/response/integer'\n _query_url = APIHelper.clean_url _query_builder\n\n # Prepare and execute HttpRequest.\n _request = config.http_client.get(\n _query_url\n )\n _response = execute_request(_request)\n\n # Validate response against endpoint and global error codes.\n return nil if _response.status_code == 404\n validate_response(_response)\n\n # Return appropriate response type.\n _response.raw_body.to_i\n end", "def expect_integer name, value\n expect_type name,\n value,\n \"integer\",\n Integer\n end", "def result(answer)\n @answer == answer.to_i \n end", "def isint\n int? ? Q::ONE : Q::ZERO\n end", "def convert(number)\n drops = drops(number)\n#Here the check and return if no drop is get. As the test request \n drops.empty? ? number.to_s : drops\n end", "def to_i\n @val\n end", "def int(value, context = nil)\n Integer(value)\n rescue => error\n log_failure(value, Integer, context, error)\n 0\n end", "def typecast_value_integer(value)\n value.to_i\n end", "def handle(x, low, mid, high)\n case x\n when 0 then ''\n when 1 then low\n when 2 then low * 2\n when 3 then low * 3\n when 4 then low + mid\n when 5 then mid\n when 6 then mid + low\n when 7 then mid + low * 2\n when 8 then mid + low * 3\n when 9 then low + high\n else raise ArgumentError.new(\"passed #{x}\")\n end\n end", "def get_i(key)\n val = get(key)\n val.nil? ? nil : val.to_i\n end", "def x=(value)\n super\n update_cursor\n end", "def to_i; end", "def to_i; end", "def to_i; end", "def to_i; end", "def to_i; end", "def to_i; end", "def get_val(xpath, type)\n case type\n when 'int'\n @page.xpath(xpath).text.to_s.gsub(/[[:space:]]/, '').to_i\n when 'bool'\n @page.xpath(xpath).text.strip.downcase == YES\n else\n @page.xpath(xpath).text.strip\n end\n end", "def literal_integer(v)\n if v > 9223372036854775807 || v < -9223372036854775808\n literal_integer_outside_bigint_range(v)\n else\n v.to_s\n end\n end", "def nodetype2num(x)\n @nodetypes.find_index(x)\nend", "def get_int(key)\n get(key, \"i\")\n end", "def to_s\n unknown? ? 'x' : @value.to_s\n end", "def expected_income(db, user_name)\r\n\tretrieve_expected_income = '\r\n\r\n\tSELECT expected_income FROM users\r\n\r\n\tWHERE name = ?'\r\n\texpected_income = db.execute(retrieve_expected_income, [user_name])[0][0]\r\nend", "def _reduce_34(val, _values, result)\n result = IntegerLiteral.new(val[0].to_i) \n result\nend", "def integer_amount\n times_x_amount = amount.integer? ? 1 : 100\n (amount * times_x_amount).to_i\n end", "def x #getter method\n\t\t@x\n\tend", "def x\n @x\n end", "def inputed_value\n Inventory.in_check(self.id).remote_s.sum(\"result_value\").to_f\n end", "def to_i\n val.to_i\n end", "def verify(x)\n\ty = 1\n\twhile y == 1\n\t\tif x.is_a?(Integer) && x > 0 && x < 10 #need to fix this. Still able to take non integers like 1.5\n\t\t\treturn x\n\t\t\ty-=1\n\t\telse\n\t\t\tputs \"Try again - number must be 1 through 10 and an integer\"\n\t\t\tx = gets.chomp.to_i\n\t\tend\n\tend\nend", "def tobeint(obj)\n\t\tif obj \n\t\t\treturn obj.to_s.gsub(/\\D/,'').to_i\n\t\tend\n\t\treturn obj\n\tend", "def to_i() end", "def to_i() end", "def to_i() end", "def to_i() end", "def to_i() end", "def convert_value(value, column_options)\n if column_options\n case column_options[:type]\n when 'Number'\n return value.to_i\n end\n end\n\n value\n end", "def normalize_value value\n return value if value.is_a? String\n return \"0\" if value < 0\n return \"10\" if value > 10\n value.to_s\nend", "def to_i()\n #This is a stub, used for indexing\n end", "def correct_format_for_values\n self.value.to_i\n end", "def hit_value= int\n #This is a stub, used for indexing\n end", "def explicit_value\n return if value.nil?\n value < 0 ? value : \"+#{value.to_s}\"\n end", "def result_to_s(result)\n case result\n when true\n '2'\n when false\n '1'\n else\n '0'\n end\n end", "def to_number(exception = nil)\n res = super(context,self,exception)\n return res\n end" ]
[ "0.58335", "0.58176595", "0.5804167", "0.56590647", "0.56511843", "0.54943186", "0.5493593", "0.5479256", "0.54732704", "0.5391227", "0.5378253", "0.53576326", "0.5340153", "0.5319091", "0.5314443", "0.5269511", "0.5239462", "0.5179016", "0.51472306", "0.5129534", "0.51194245", "0.51095444", "0.5094834", "0.5094232", "0.5093715", "0.5093337", "0.5088761", "0.5082691", "0.50755185", "0.50749207", "0.5072045", "0.5071764", "0.5070635", "0.5069384", "0.5068476", "0.50407815", "0.5028241", "0.5019569", "0.5018441", "0.5003913", "0.49873614", "0.49700361", "0.49675578", "0.4967534", "0.4966221", "0.4965608", "0.49646324", "0.49645323", "0.49645323", "0.49490246", "0.4940032", "0.49371853", "0.49197528", "0.49179894", "0.49115616", "0.49074227", "0.490479", "0.48954105", "0.48927522", "0.4882329", "0.48797917", "0.48769483", "0.48680177", "0.48441887", "0.48428708", "0.4841921", "0.48342183", "0.48330528", "0.48306227", "0.48306227", "0.48306227", "0.48306227", "0.48306227", "0.48306227", "0.4827136", "0.48231462", "0.48209244", "0.48170215", "0.48097128", "0.47876263", "0.47839633", "0.47785038", "0.47758725", "0.47747657", "0.4769263", "0.4768419", "0.476807", "0.47641033", "0.47584727", "0.47584727", "0.47584727", "0.47584727", "0.47584727", "0.4754878", "0.47466233", "0.4731546", "0.4722083", "0.47207177", "0.47160533", "0.47132948", "0.47109646" ]
0.0
-1
GET /corps GET /corps.json
def index @corps = Corp.all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @corges = Corge.all\n end", "def index\n @copons = Copon.all\n end", "def index\n @popcorns = Popcorn.all\n end", "def index\n @corridas = Corrida.all\n end", "def list_tenants_for_circles(args = {}) \n get(\"/tenants.json/circles\", args)\nend", "def index\n @cps = Cp.all\n end", "def index\n @circuses = Circus.all\n end", "def index\n @cn_curves = CnCurve.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @cn_curves }\n end\n end", "def index\n require 'rest-client'\n response = RestClient::Request.execute(method: :get, url: 'localhost:3001/colores',\n headers: {page: params[:page], items: 9})\n if response.code == 200\n body = JSON.parse(response.body)\n @colors = body[\"data\"]\n @page = body[\"page\"]\n end\n end", "def index\n @pcs = Pc.all\n end", "def index\n @clues = Clue.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @clues }\n end\n end", "def index\n @colegios = Colegio.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @colegios }\n end\n end", "def index\n @cp_changes = CpChange.all\n\n render json: @cp_changes\n end", "def index\n @concursos = Concurso.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @concursos }\n end\n end", "def index\n @recipies = Recipy.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @recipies }\n end\n end", "def index\n @proccs = Procc.all\n end", "def index\n @correlations = Correlation.all\n end", "def index\n @disciplines = Discipline.all\n\n render json: @disciplines\n end", "def index\n @company_authorities = CompanyAuthority.all\n\n render json: @company_authorities\n end", "def index\n #@csosns = Csosn.all\n @csosns = Csosn.paginate(:page => params[:page], :per_page => 10)\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @csosns }\n end\n end", "def all_cops?; end", "def index\n @socio_cpfs = SocioCpf.all\n end", "def index\n @pricings = Pricing.all\n\n render json: @pricings\n end", "def index\n @socio_doc_fiscais_corings = SocioDocFiscaisCoring.all\n end", "def search(string)\n\n # Convert to a get-paramenter\n string = CGI.escapeHTML string.strip\n string.gsub!(\" \", \"%20\")\n\n begin\n resp = JSON.parse(http_get_body(get_service_endpoint(@api_key, string)))\n rescue JSON::ParserError => e\n return nil\n end\n\n # Check for successful result\n return nil unless resp[\"meta\"][\"status\"] == 200\n\n # initialize an array of corps to return\n corps = []\n\n # For each result, create a corp\n resp[\"result\"][\"companies\"].each do |key, value|\n corps << Corpwatch::Corporation.new(value)\n end\n\n corps\n end", "def index\n @congties = Congty.all\n end", "def set_corpu\n @corpu = Corpu.find(params[:id])\n end", "def index\n @clins = Clin.all\n end", "def show\n @circulation = Circulation.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @circulation }\n end\n end", "def get\n @cine = Cine.find(params[:cine_id], :select => [\"nombre\",\"id\",\"direccion\",\"localidad\"])\n render :json => [ @cine, :peliculas => @cine.peliculas.select('titulo,horas,pelicula_id') ]\n end", "def index\n @competencies = Competency.all\n respond_to do |format|\n format.json { render json: @competencies }\n end\n end", "def index\n @cursos = Curso.all_active\n @curso = Curso.new\n @programas = Programa.all_active\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @cursos }\n end\n end", "def list_tenants_for_circle(args = {}) \n get(\"/tenantcircles.json/tenants\", args)\nend", "def index\n @chores = Chore.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @chores }\n end\n end", "def index\n @chores = Chore.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @chores }\n end\n end", "def index\n @cocktails = Cocktail.where(\"oficial = ?\", false)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @cocktails }\n end\n end", "def index\n @csrelations = Csrelation.all\n end", "def index\n @simple_chores = SimpleChore.all\n respond_to do |format|\n format.html\n format.json { render :json => @simple_chores }\n end\n end", "def index\n @coasters = Coaster.all\n\n render json: @coasters\n end", "def index\n @commemts = Commemt.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @commemts }\n end\n end", "def index\n @consents = Consent.all\n render json: @consents\n end", "def get_csrs(opts = {})\n data, _status_code, _headers = get_csrs_with_http_info(opts)\n return data\n end", "def show\n @correlation = Correlation.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @correlation }\n end\n end", "def index\n @circle = current_user.circle\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @circle }\n end\n end", "def index\n @coocos = Cooco.all\n end", "def index\n @consorciots = Consorciot.all\n end", "def corona_virus\n # endpoint = \"https://corona.lmao.ninja/all\"\n endpoint = 'https://corona.lmao.ninja/v2/all'\n response = HTTParty.get(endpoint)\n data = JSON.parse response.body\n res = data\n result = []\n result<<{\n country: \"world\",\n cases: res[\"cases\"],\n todayCases: res[\"todayCases\"],\n deaths: res[\"deaths\"],\n todayDeaths: res[\"todayDeaths\"],\n recovered: res[\"recovered\"],\n active: res[\"active\"],\n critical: res[\"critical\"],\n casesPerOneMillion: res[\"casesPerOneMillion\"],\n deathsPerOneMillion: res[\"deathsPerOneMillion\"],\n tests: res[\"tests\"],\n testsPerOneMillion: res[\"testsPerOneMillion\"],\n affectedCountries: res[\"affectedCountries\"]\n }\n render json: result\n end", "def index\n @crates = Crate.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @crates }\n end\n end", "def index\n @cousins = Cousin.all\n end", "def index\n @proyects = Proyect.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @proyects }\n end\n end", "def show\n @cerc = Cerc.find(params[:id])\n\n render json: @cerc\n end", "def index\n url = \"https://data.cityofchicago.org/resource/x2n5-8w5q.json\"\n options = { :body => {:status => text}, :basic_auth => @auth }\n @response = HTTParty.get(url, options)\n\n @crime = Hash.new\n\n #@crime['block'] = @response[0]['block']\n @crime = @response\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @gittos }\n end\n end", "def index\n @care_plans = CarePlan.all\n render json: @care_plans\n end", "def index\n @citations = Citation.all\n\n render json: @citations\n end", "def index\n @careers = Career.all\n json_response(@careers)\n end", "def index\n @copenometros = Copenometro.all\n end", "def index\n @cages = current_user.cages\n\n respond_to do |format|\n format.json { render json: @cages }\n end\n end", "def index\n @prod_cotis = ProdCoti.all\n end", "def show\n @curso = Curso.find(params[:curso_id])\n end", "def index\n @cartridges = Cartridge.all\n\n respond_to do |format|\n format.html\n format.json { render json: @cartridges }\n end\n end", "def index\n @clinic_doctors = ClinicDoctor.includes(:clinic, :doctor).all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @clinic_doctors }\n end\n end", "def index\n @reqcargos = Reqcargo.all\n end", "def index\n @cofs = Cof.all\n end", "def show\n @crust = Crust.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @crust }\n end\n end", "def corals\n @corals ||= [@first_coral, @second_coral].sort\n end", "def index\n @corruptions = Corruption.all\n end", "def index\n @carros = @patio.carros.all\n end", "def listCon\n @opportunities = Opportunity.where(\"status = ?\", \"Publish\")\n render json: @opportunities\n end", "def index\n @crpyto_infos = CrpytoInfo.all\n end", "def index\n @csps = Csp.all\n end", "def index\n @prefectures = Prefecture.all\n end", "def show\n @cso = Cso.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @cso }\n end\n end", "def set_corge\n @corge = Corge.find(params[:id])\n end", "def index\n colorizers = Colorizer.all\n\n render json: colorizers\n end", "def index\n @conns = current_user.conns\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @conns }\n end\n end", "def show\n @cec_complaint = CecComplaint.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @cec_complaint }\n end\n end", "def index\n @references = Reference.all\n\n render json: @references\n end", "def show\n @clasp = Clasp.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @clasp }\n end\n end", "def index\n @clients = current_user.clients\n render json: @clients\n end", "def index\n @mycometer_cocs = MycometerCoc.all\n end", "def index\n @cfos = Cfo.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @cfos }\n end\n end", "def index\n @occasions = current_user.occasions.sorteddesc.all.paginate(page: params[:page], :per_page => 10)\n @products = Product.all\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @occasions }\n end\n end", "def index\n @proximities = Proximity.all\n end", "def cities\n CS.get :us, :ca\n end", "def index\n @cordinates = Cordinate.all\n end", "def index\n @correos = Correo.all\n end", "def index\n @casos = Caso.all\n end", "def index\n @c_povolanis = CPovolani.all\n end", "def index\n @cofis = Cofi.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @cofis }\n end\n end", "def index\n @congressos = Congresso.all\n end", "def index\n @crate_priorities = CratePriority.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @crate_priorities }\n end\n end", "def make_api_call(args)\n uri = URI(\"https://classes.cornell.edu/api/2.0/search/classes.json?roster=#{args[0]}&subject=#{args[1]}&acadCareer[]=#{args[2]}&classLevels[]=#{args[3]}\")\n begin\n Net::HTTP.start(uri.host, uri.port,\n :use_ssl => uri.scheme == 'https') do |http|\n request = Net::HTTP::Get.new uri\n\n response = http.request request # Net::HTTPResponse object\n hash_response = JSON.parse(response.body)\n hash_response\n end\n rescue JSON::ParserError\n {\"status\": \"Error\"} # Returning an empty hash\n end\nend", "def index\n @clips = Clip.all\n respond_to do |format|\n format.json { render json: @clips.to_json(:include => [:sound_board_clip_sources, :image_playing, :image_default ]) }\n format.xml { render xml: @clips }\n end\n end", "def index\n @cartella_clinicas = CartellaClinica.all\n end", "def index\n @competitions = Competition.paginate(:page => params[:page], :per_page => 3)\n\n\t\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @competitions }\n end\n end", "def index\n lat = request.headers['lat'].to_f\n long = request.headers['long'].to_f\n\n @user = User.find(current_user)\n @concerts = @user.artists.map do |a|\n a.concerts.select{|c| Date.parse(c.date) > Date.today && Date.parse(c.date) < (Date.today + 7)}\n end\n @concerts = @concerts.flatten.sort do |concert1, concert2|\n order = Date.parse(concert1.date) <=> Date.parse(concert2.date)\n if order != 0\n order\n else\n concert1.distance(lat, long) <=> concert2.distance(lat, long)\n end\n end\n render json: {concerts: @concerts}\n end", "def index\n @coconut1s = Coconut1.all\n end", "def index\n @pacientes = Pacientes.all\n render json: @pacientes\n end", "def index\n @crops = Crop.all\n end" ]
[ "0.6263931", "0.5835342", "0.58079046", "0.5802921", "0.57680696", "0.5691794", "0.56731963", "0.56525725", "0.55293006", "0.55221397", "0.5511802", "0.5472816", "0.54695475", "0.5452315", "0.54469156", "0.54377645", "0.5437015", "0.54313797", "0.5425353", "0.54224765", "0.54059386", "0.539839", "0.53820926", "0.5370636", "0.5355652", "0.53478295", "0.53438264", "0.53429335", "0.5340822", "0.5340417", "0.53330153", "0.5322442", "0.53222966", "0.5316528", "0.5316528", "0.53123224", "0.5302861", "0.530265", "0.5286019", "0.5283107", "0.52722836", "0.52653354", "0.5264792", "0.5264561", "0.5260391", "0.52602375", "0.5242652", "0.5241826", "0.5236674", "0.5214773", "0.52111316", "0.5209238", "0.5207992", "0.51900166", "0.51897866", "0.51894563", "0.51838154", "0.5181938", "0.5174913", "0.51747286", "0.5174086", "0.51713103", "0.5162046", "0.51583374", "0.5154096", "0.5141205", "0.5134768", "0.5134204", "0.51291597", "0.5122191", "0.5121799", "0.51114476", "0.5110766", "0.5103879", "0.5103475", "0.5101232", "0.51006615", "0.5099845", "0.5099693", "0.5099604", "0.5097599", "0.5096542", "0.50931233", "0.5092023", "0.50917834", "0.5089478", "0.5089323", "0.5088807", "0.50863254", "0.50854063", "0.5083521", "0.5078689", "0.50761986", "0.507266", "0.5072446", "0.5066816", "0.5063728", "0.5060504", "0.50572467" ]
0.6692728
0
GET /corps/1 GET /corps/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @corps = Corp.all\n end", "def index\n @corps = Corp.all\n end", "def index\n @corges = Corge.all\n end", "def set_corpu\n @corpu = Corpu.find(params[:id])\n end", "def show\n @circulation = Circulation.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @circulation }\n end\n end", "def show\n @correlation = Correlation.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @correlation }\n end\n end", "def index\n @corridas = Corrida.all\n end", "def index\n @copons = Copon.all\n end", "def show\n @crust = Crust.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @crust }\n end\n end", "def index\n @recipies = Recipy.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @recipies }\n end\n end", "def index\n @coconut1s = Coconut1.all\n end", "def show\n @cec_complaint = CecComplaint.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @cec_complaint }\n end\n end", "def show\n @cerc = Cerc.find(params[:id])\n\n render json: @cerc\n end", "def show\n @curso = Curso.find(params[:curso_id])\n end", "def index\n @circuses = Circus.all\n end", "def index\n @colegios = Colegio.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @colegios }\n end\n end", "def index\n @cn_curves = CnCurve.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @cn_curves }\n end\n end", "def index\n @concursos = Concurso.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @concursos }\n end\n end", "def show\n @commtent1 = Commtent1.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @commtent1 }\n end\n end", "def get\n @cine = Cine.find(params[:cine_id], :select => [\"nombre\",\"id\",\"direccion\",\"localidad\"])\n render :json => [ @cine, :peliculas => @cine.peliculas.select('titulo,horas,pelicula_id') ]\n end", "def index\n @cp_changes = CpChange.all\n\n render json: @cp_changes\n end", "def index\n @cps = Cp.all\n end", "def show\n @cso = Cso.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @cso }\n end\n end", "def show\n @central_correio = CentralCorreio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @central_correio }\n end\n end", "def show\n @clonet = Clonet.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @clonet }\n end\n end", "def index\n @simple_chores = SimpleChore.all\n respond_to do |format|\n format.html\n format.json { render :json => @simple_chores }\n end\n end", "def show\n @colegio = Colegio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @colegio }\n end\n end", "def set_corge\n @corge = Corge.find(params[:id])\n end", "def show\n @colaboration = Colaboration.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @colaboration }\n end\n end", "def index\n url = \"https://data.cityofchicago.org/resource/x2n5-8w5q.json\"\n options = { :body => {:status => text}, :basic_auth => @auth }\n @response = HTTParty.get(url, options)\n\n @crime = Hash.new\n\n #@crime['block'] = @response[0]['block']\n @crime = @response\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @gittos }\n end\n end", "def show\n @cppic = Cppic.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @cppic }\n end\n end", "def show\n @correo = Correo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @correo }\n end\n end", "def show\n @complaint = Complaint.find(params[:id])\n\n render json: @complaint\n end", "def show\n @correo = Correo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @correo }\n end\n end", "def index\n @correlations = Correlation.all\n end", "def show\n @concurso = Concurso.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @concurso }\n end\n end", "def index\n @clues = Clue.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @clues }\n end\n end", "def set_corrida\n @corrida = Corrida.find(params[:id])\n end", "def index\n @disciplines = Discipline.all\n\n render json: @disciplines\n end", "def index\n require 'rest-client'\n response = RestClient::Request.execute(method: :get, url: 'localhost:3001/colores',\n headers: {page: params[:page], items: 9})\n if response.code == 200\n body = JSON.parse(response.body)\n @colors = body[\"data\"]\n @page = body[\"page\"]\n end\n end", "def index\n @cursos = Curso.all_active\n @curso = Curso.new\n @programas = Programa.all_active\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @cursos }\n end\n end", "def index\n @chores = Chore.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @chores }\n end\n end", "def index\n @chores = Chore.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @chores }\n end\n end", "def index\n @pcs = Pc.all\n end", "def index\n @popcorns = Popcorn.all\n end", "def list_tenants_for_circles(args = {}) \n get(\"/tenants.json/circles\", args)\nend", "def index\n @commemts = Commemt.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @commemts }\n end\n end", "def show\n @csosn = Csosn.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @csosn }\n end\n end", "def index\n @coasters = Coaster.all\n\n render json: @coasters\n end", "def show\n @clasp = Clasp.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @clasp }\n end\n end", "def index\n @proccs = Procc.all\n end", "def index\n @company_authorities = CompanyAuthority.all\n\n render json: @company_authorities\n end", "def show\n @critic = Critic.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @critic }\n end\n end", "def show\n @compra = Compra.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @compra }\n end\n end", "def show\n @comic = Comic.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @comic }\n end\n end", "def show\n @comic = Comic.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @comic }\n end\n end", "def index\n #@csosns = Csosn.all\n @csosns = Csosn.paginate(:page => params[:page], :per_page => 10)\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @csosns }\n end\n end", "def show\n @recipy = Recipy.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @recipy }\n end\n end", "def getbyId\n begin\n @company = Company.find(params[:id])\n render :json => @company.to_json(:include =>[:confidenceLevel,:nda,:country,:region,:state,:city,:company_type,:companyInvestors,:classifications,:companyGeos,:companyRevenues,:companyGrowths]), :status=>:ok\n rescue\n render :json=>\"No company found\"\n end\n end", "def show\n @condolence = Condolence.find(params[:id])\n @orbituarysite = current_user.orbituarysites.new\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @condolence }\n end\n end", "def show\n @corgi = Corgi.find(params[:id])\n respond_to do |format|\n format.html \n format.json { render json: @corgi }\n end \n end", "def index\n @companies = Company.all\n @com_info = Company.last\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @companies }\n end\n end", "def show\n @crunch_company = CrunchCompany.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @crunch_company }\n end\n end", "def index\n @crates = Crate.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @crates }\n end\n end", "def index\n @cocktails = Cocktail.where(\"oficial = ?\", false)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @cocktails }\n end\n end", "def show\n @cocktail = Cocktail.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @cocktail }\n end\n end", "def index\n @proyects = Proyect.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @proyects }\n end\n end", "def show\n @cuerpo = Cuerpo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @cuerpo }\n end\n end", "def show\n @compromise = Compromise.find(params[:id])\n\n render json: @compromise\n end", "def getOrden \n \t@orden = Orden.where(:rest => params[:id_res])\n \trender json: @orden\n end", "def show\n @conductor = Conductor.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @conductor }\n end\n end", "def show\n @conductor = Conductor.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @conductor }\n end\n end", "def index\n @consorciots = Consorciot.all\n end", "def show\n @climate = Climate.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @climate }\n end\n end", "def index\n @corruptions = Corruption.all\n end", "def show\n @cocktail = Cocktail.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @cocktail }\n end\n end", "def index\n @pricings = Pricing.all\n\n render json: @pricings\n end", "def index\n @competencies = Competency.all\n respond_to do |format|\n format.json { render json: @competencies }\n end\n end", "def get(path, params={})\n params = merge_set_up_params(params)\n @token = \"b3688c52-9235-45ca-b01f-c5b2b83a4f4f\"\n @result = Typhoeus::Request.get(API_URL + path, :params => params,\n :headers => {\"Authorization\" => \"Basic#{@token}\"})\n puts @result.body\n # check if the url looks correct in the log\n puts @result.effective_url\n # parse the result to json\n return JSON.parse(@result.body)\n end", "def index\n @consents = Consent.all\n render json: @consents\n end", "def index\n @cartridges = Cartridge.all\n\n respond_to do |format|\n format.html\n format.json { render json: @cartridges }\n end\n end", "def set_coconut1\n @coconut1 = Coconut1.find(params[:id])\n end", "def index\n @chronics = Chronic.where(\"patient_id = ?\", params[:p_id])\n end", "def index\n @circle = current_user.circle\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @circle }\n end\n end", "def show\n @cofi = Cofi.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @cofi }\n end\n end", "def index\n @reqcargos = Reqcargo.all\n end", "def index\n @courts = Court.by_name\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @courts }\n end\n end", "def index\n @copenometros = Copenometro.all\n end", "def index\n @cofis = Cofi.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @cofis }\n end\n end", "def show\n @research_c = ResearchC.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @research_c }\n end\n end", "def first\n @comic = Comic.order(\"created_at ASC\").first\n respond_to do |format|\n format.html { render 'show' }\n format.json { render json: @comic }\n end\n end", "def first\n @comic = Comic.order(\"created_at ASC\").first\n respond_to do |format|\n format.html { render 'show' }\n format.json { render json: @comic }\n end\n end", "def index\n @crpyto_infos = CrpytoInfo.all\n end", "def index\n @care_plans = CarePlan.all\n render json: @care_plans\n end", "def index\n @conns = current_user.conns\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @conns }\n end\n end", "def corona_virus\n # endpoint = \"https://corona.lmao.ninja/all\"\n endpoint = 'https://corona.lmao.ninja/v2/all'\n response = HTTParty.get(endpoint)\n data = JSON.parse response.body\n res = data\n result = []\n result<<{\n country: \"world\",\n cases: res[\"cases\"],\n todayCases: res[\"todayCases\"],\n deaths: res[\"deaths\"],\n todayDeaths: res[\"todayDeaths\"],\n recovered: res[\"recovered\"],\n active: res[\"active\"],\n critical: res[\"critical\"],\n casesPerOneMillion: res[\"casesPerOneMillion\"],\n deathsPerOneMillion: res[\"deathsPerOneMillion\"],\n tests: res[\"tests\"],\n testsPerOneMillion: res[\"testsPerOneMillion\"],\n affectedCountries: res[\"affectedCountries\"]\n }\n render json: result\n end", "def index\n @clins = Clin.all\n end", "def index\n @repas = Repa.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @repas }\n end\n end", "def index\n @cousins = Cousin.all\n end", "def show\n render json: Company.find(params[\"id\"])\n end", "def show\n @cp_press = CpPress.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @cp_press }\n end\n end" ]
[ "0.6537758", "0.6537758", "0.6211128", "0.5856104", "0.5821062", "0.58143884", "0.5800207", "0.5743693", "0.5714927", "0.56905675", "0.56778306", "0.56736755", "0.5650279", "0.5639502", "0.5614502", "0.56134313", "0.56128067", "0.56124675", "0.5610981", "0.5610778", "0.56041986", "0.55973816", "0.5583508", "0.5582092", "0.5576611", "0.5573862", "0.5565771", "0.55575025", "0.5548962", "0.5537812", "0.55315685", "0.5530332", "0.55303204", "0.5529545", "0.5527318", "0.55023366", "0.54945993", "0.54921657", "0.54879373", "0.5485433", "0.5482746", "0.547792", "0.547792", "0.5470496", "0.54496217", "0.54489607", "0.5432705", "0.5430429", "0.5424091", "0.54236114", "0.541434", "0.54054016", "0.5404919", "0.5403486", "0.5399556", "0.5399556", "0.5397751", "0.53944814", "0.53899014", "0.53853124", "0.5382374", "0.5381003", "0.5379032", "0.53785527", "0.5376817", "0.5364657", "0.53583795", "0.5352805", "0.53402233", "0.5326851", "0.5323236", "0.5323236", "0.53179693", "0.53097314", "0.5300139", "0.5298953", "0.5294935", "0.5293376", "0.52854836", "0.528069", "0.52743953", "0.5269415", "0.526471", "0.52646965", "0.525869", "0.52546734", "0.52530116", "0.52500325", "0.52491", "0.5242702", "0.5240752", "0.5240752", "0.5237939", "0.5235275", "0.5234795", "0.5234228", "0.5231101", "0.52307606", "0.5227541", "0.522659", "0.52262104" ]
0.0
-1
POST /corps POST /corps.json
def create @corp = Corp.new(corp_params) respond_to do |format| if @corp.save format.html { redirect_to @corp, notice: 'Corp was successfully created.' } format.json { render :show, status: :created, location: @corp } else format.html { render :new } format.json { render json: @corp.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @corpu = Corpu.new(corpu_params)\n respond_to do |format|\n if @corpu.save\n format.json { head :no_content }\n format.js\n else\n format.json { render json: @corpu.errors.full_messages, status: :unprocessable_entity }\n end\n end\n end", "def create\n @corge = Corge.new(corge_params)\n\n respond_to do |format|\n if @corge.save\n format.html { redirect_to @corge, notice: 'Corge was successfully created.' }\n format.json { render :show, status: :created, location: @corge }\n else\n format.html { render :new }\n format.json { render json: @corge.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @corrida = Corrida.new(corrida_params)\n\n respond_to do |format|\n if @corrida.save\n format.html { redirect_to @corrida, notice: 'Corrida creada satisfactoriamente.' }\n format.json { render :show, status: :created, location: @corrida }\n else\n format.html { render :new }\n format.json { render json: @corrida.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @correlation = Correlation.new(params[:correlation])\n\n respond_to do |format|\n if @correlation.save\n format.html { redirect_to @correlation, notice: 'Correlation was successfully created.' }\n format.json { render json: @correlation, status: :created, location: @correlation }\n else\n format.html { render action: \"new\" }\n format.json { render json: @correlation.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @correlation = Correlation.new(correlation_params)\n\n respond_to do |format|\n if @correlation.save\n format.html { redirect_to @correlation, notice: 'Correlation was successfully created.' }\n format.json { render :show, status: :created, location: @correlation }\n else\n format.html { render :new }\n format.json { render json: @correlation.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @cargo = Cargo.new(cargo_params)\n if @cargo.save\n render json: @cargo\n else\n render json: @cargo.errors, status: :unprocessable_entity\n end\n end", "def create\n @reqcargo = Reqcargo.new(reqcargo_params)\n\n respond_to do |format|\n if @reqcargo.save\n format.html { redirect_to @reqcargo, notice: 'Reqcargo was successfully created.' }\n format.json { render :show, status: :created, location: @reqcargo }\n else\n format.html { render :new }\n format.json { render json: @reqcargo.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @curso = Curso.new(curso_params)\n\n respond_to do |format|\n if @curso.save\n format.html { redirect_to @curso, notice: 'Curso was successfully created.' }\n format.json { render :show, status: :created, location: @curso }\n else\n format.html { render :new }\n format.json { render json: @curso.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @poc = Poc.new(poc_params)\n\n respond_to do |format|\n if @poc.save\n format.html { redirect_to @poc, notice: 'Poc was successfully created.' }\n format.json { render :show, status: :created, location: @poc }\n else\n format.html { render :new }\n format.json { render json: @poc.errors, status: :unprocessable_entity }\n end\n end\n end", "def corpu_params\n params.require(:corpu).permit(:name, :description, :end_date_build, :building_id)\n end", "def create\n @cp = Cp.new(cp_params)\n\n respond_to do |format|\n if @cp.save\n format.html { redirect_to @cp, notice: 'Cp was successfully created.' }\n format.json { render :show, status: :created, location: @cp }\n else\n format.html { render :new }\n format.json { render json: @cp.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @curso = Curso.new(curso_params)\n\n respond_to do |format|\n if @curso.save\n format.json { render json: \"Curso Creado\", status: :created }\n else\n format.json { render json: @curso.errors}\n end\n end\n end", "def create\n @circulation = Circulation.new(params[:circulation])\n\n respond_to do |format|\n if @circulation.save\n format.html { redirect_to @circulation, notice: 'Circulation was successfully created.' }\n format.json { render json: @circulation, status: :created, location: @circulation }\n else\n format.html { render action: \"new\" }\n format.json { render json: @circulation.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @curso = Curso.new(params[:curso])\n\n respond_to do |format|\n if @curso.save\n format.html { redirect_to(:back) }\n format.json { render json: @curso, status: :created, location: @curso }\n else\n format.html { render action: \"new\" }\n format.json { render json: @curso.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @cooco = Cooco.new(cooco_params)\n\n respond_to do |format|\n if @cooco.save\n format.html { redirect_to @cooco, notice: 'Cooco was successfully created.' }\n format.json { render :show, status: :created, location: @cooco }\n else\n format.html { render :new }\n format.json { render json: @cooco.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @cerc = Cerc.new(params[:cerc])\n\n if @cerc.save\n render json: @cerc, status: :created, location: @cerc\n else\n render json: @cerc.errors, status: :unprocessable_entity\n end\n end", "def add_tenant_circle(args = {}) \n post(\"/tenantcircles.json/\", args)\nend", "def create\n\n @company = Company.find(1)\n\n @cout = Cout.new(cout_params)\n\n\n @cout[:code] = @cout.generate_cout_number\n @puntos = @company.get_puntos()\n @employees = @company.get_employees2() \n @trucks = @company.get_trucks\n\n respond_to do |format|\n if @cout.save\n format.html { redirect_to @cout, notice: 'Cout was successfully created.' }\n format.json { render :show, status: :created, location: @cout }\n else\n format.html { render :new }\n format.json { render json: @cout.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @cso = Cso.new(params[:cso])\n\n respond_to do |format|\n if @cso.save\n format.html { redirect_to @cso, notice: 'Cso was successfully created.' }\n format.json { render json: @cso, status: :created, location: @cso }\n else\n format.html { render action: \"new\" }\n format.json { render json: @cso.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @cropland = Cropland.new(cropland_params)\n\n respond_to do |format|\n if @cropland.save\n format.html { redirect_to @cropland, notice: 'Cropland was successfully created.' }\n format.json { render :show, status: :created, location: @cropland }\n else\n format.html { render :new }\n format.json { render json: @cropland.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @procc = Procc.new(procc_params)\n\n respond_to do |format|\n if @procc.save\n format.html { redirect_to @procc, notice: 'Procc was successfully created.' }\n format.json { render :show, status: :created, location: @procc }\n else\n format.html { render :new }\n format.json { render json: @procc.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @cp_change = CpChange.new(cp_change_params)\n\n if @cp_change.save\n render json: @cp_change, status: :created, location: @cp_change\n else\n render json: @cp_change.errors, status: :unprocessable_entity\n end\n end", "def create\n @cec_complaint = CecComplaint.new(params[:cec_complaint])\n\n respond_to do |format|\n if @cec_complaint.save\n format.html { redirect_to @cec_complaint, notice: 'Cec complaint was successfully created.' }\n format.json { render json: @cec_complaint, status: :created, location: @cec_complaint }\n else\n format.html { render action: \"new\" }\n format.json { render json: @cec_complaint.errors, status: :unprocessable_entity }\n end\n end\n end", "def do_coaps_posted_03\n # get the Base64 of the incoming signed request\n body = IO.read(\"spec/files/vr_00-D0-E5-F2-00-03.vrq\")\n\n env = Hash.new\n env[\"SSL_CLIENT_CERT\"] = cbor_clientcert_03\n env[\"HTTP_ACCEPT\"] = \"application/voucher-cose+cbor\"\n env[\"CONTENT_TYPE\"] = \"application/voucher-cose+cbor\"\n\n $FAKED_TEMPORARY_KEY = temporary_key\n post '/e/rv', :params => body, :headers => env\n end", "def create\n @projecct = Projecct.new(params[:projecct])\n\n respond_to do |format|\n if @projecct.save\n format.html { redirect_to @projecct, notice: 'Projecct was successfully created.' }\n format.json { render json: @projecct, status: :created, location: @projecct }\n else\n format.html { render action: \"new\" }\n format.json { render json: @projecct.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @socio_cpf = SocioCpf.new(socio_cpf_params)\n\n respond_to do |format|\n if @socio_cpf.save\n format.html { redirect_to @socio_cpf, notice: 'Socio cpf was successfully created.' }\n format.json { render action: 'show', status: :created, location: @socio_cpf }\n else\n format.html { render action: 'new' }\n format.json { render json: @socio_cpf.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @otg_crypst = OtgCrypst.new(otg_crypst_params)\n\n respond_to do |format|\n if @otg_crypst.save\n format.html { redirect_to @otg_crypst, notice: 'Otg crypst was successfully created.' }\n format.json { render :show, status: :created, location: @otg_crypst }\n else\n format.html { render :new }\n format.json { render json: @otg_crypst.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @criterio = Pmc::Criterio.new(criterio_params)\n\n respond_to do |format|\n if @criterio.save\n format.html { redirect_to @criterio, notice: 'Criterio was successfully created.' }\n format.json { render :show, status: :created, location: @criterio }\n else\n format.html { render :new }\n format.json { render json: @criterio.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @consorciot = Consorciot.new(consorciot_params)\n\n respond_to do |format|\n if @consorciot.save\n format.html { redirect_to @consorciot, notice: 'Consorciot was successfully created.' }\n format.json { render :show, status: :created, location: @consorciot }\n else\n format.html { render :new }\n format.json { render json: @consorciot.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @caso = Caso.new(caso_params)\n\n respond_to do |format|\n if @caso.save\n format.html { redirect_to @caso, notice: 'Caso was successfully created.' }\n format.json { render :show, status: :created, location: @caso }\n else\n format.html { render :new }\n format.json { render json: @caso.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_corpu\n @corpu = Corpu.find(params[:id])\n end", "def create\n @popcorn = Popcorn.new(popcorn_params)\n\n respond_to do |format|\n if @popcorn.save\n format.html { redirect_to @popcorn, notice: 'Popcorn was successfully created.' }\n format.json { render :show, status: :created, location: @popcorn }\n else\n format.html { render :new }\n format.json { render json: @popcorn.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n # @cord = Cord.new(cord_params)\n @cord = @racquet.cords.new(cord_params)\n @cord.user = current_user\n respond_to do |format|\n if @cord.save\n format.html { redirect_to @cord, notice: t('cords.create.success') }\n format.json { render :show, status: :created, location: @cord }\n else\n format.html { render :new }\n format.json { render json: @cord.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @corps = Corp.all\n end", "def index\n @corps = Corp.all\n end", "def create\n @copon = Copon.new(copon_params)\n get_product(@copon, params.require(:copon)[:product])\n set_associative_criteria @copon, params.require(:copon)\n\n respond_to do |format|\n if @copon.save\n format.html { redirect_to @copon, notice: 'Copon was successfully created.' }\n format.json { render :show, status: :created, location: @copon }\n else\n format.html { render :new }\n format.json { render json: @copon.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @crust = Crust.new(params[:crust])\n\n respond_to do |format|\n if @crust.save\n format.html { redirect_to @crust, notice: 'Crust was successfully created.' }\n format.json { render json: @crust, status: :created, location: @crust }\n else\n format.html { render action: \"new\" }\n format.json { render json: @crust.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @clasp = Clasp.new(params[:clasp])\n\n respond_to do |format|\n if @clasp.save\n format.html { redirect_to @clasp, notice: 'Clasp was successfully created.' }\n format.json { render json: @clasp, status: :created, location: @clasp }\n else\n format.html { render action: \"new\" }\n format.json { render json: @clasp.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @corruption = current_citoyen.corruptions.build(corruption_params)\n\n respond_to do |format|\n if @corruption.save\n format.html { redirect_to @corruption, notice: 'Corruption was successfully created.' }\n format.json { render :show, status: :created, location: @corruption }\n else\n format.html { render :new }\n format.json { render json: @corruption.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n \n \n @cocktail = Cocktail.new(params[:cocktail])\n @cocktail.prise = 20000\n @cocktail.grade = 0\n @cocktail.oficial = false\n respond_to do |format|\n if @cocktail.save\n format.html { redirect_to @cocktail, :notice => 'Cocktail was successfully created.' }\n format.json { render :json => @cocktail, :status => :created, :location => @cocktail }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @cocktail.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @cuota_curso = CuotaCurso.new(cuota_curso_params)\n\n respond_to do |format|\n if @cuota_curso.save\n format.html { redirect_to @cuota_curso, notice: 'La cuota del curso se creó correctamente.' }\n format.json { render :show, status: :created, location: @cuota_curso }\n else\n format.html { render :new }\n format.json { render json: @cuota_curso.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @profesor = Profesor.new(profesor_params)\n\n if @profesor.save\n render json: @profesor, status: :created, location: @profesor\n else\n render json: @profesor.errors, status: :unprocessable_entity\n end\n end", "def create\n @corp = Corp.new(corp_params)\n\n respond_to do |format|\n if @corp.save\n format.html { redirect_to @corp, notice: 'Corp was successfully created.' }\n format.json { render action: 'show', status: :created, location: @corp }\n else\n format.html { render action: 'new' }\n format.json { render json: @corp.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @prod_coti = ProdCoti.new(prod_coti_params)\n\n respond_to do |format|\n if @prod_coti.save\n format.html { redirect_to @prod_coti, notice: 'Prod coti was successfully created.' }\n format.json { render :show, status: :created, location: @prod_coti }\n else\n format.html { render :new }\n format.json { render json: @prod_coti.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @complaint = Complaint.new(params[:complaint])\n\n if @complaint.save\n render json: @complaint, status: :created, location: @complaint\n else\n render json: @complaint.errors, status: :unprocessable_entity\n end\n end", "def create\n @copropietario = Copropietario.new(copropietario_params)\n\n respond_to do |format|\n if @copropietario.save\n format.html { redirect_to @copropietario, notice: 'Copropietario was successfully created.' }\n format.json { render :show, status: :created, location: @copropietario }\n else\n format.html { render :new }\n format.json { render json: @copropietario.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @corpu.update(corpu_params)\n format.json { head :no_content }\n format.js\n else\n format.json { render json: @corpu.errors.full_messages, status: :unprocessable_entity }\n end\n end\n end", "def asignar_curso\n render :json => Profesor.asignar_curso(params)\n end", "def create\n @concert = Concert.new(concert_params)\n\n respond_to do |format|\n if @concert.save\n format.html { redirect_to @concert, notice: 'Concert was successfully created.' }\n format.json { render :show, status: :created, location: @concert }\n else\n format.html { render :new }\n format.json { render json: @concert.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @concert = Concert.new(concert_params)\n\n respond_to do |format|\n if @concert.save\n format.html { redirect_to @concert, notice: 'Concert was successfully created.' }\n format.json { render :show, status: :created, location: @concert }\n else\n format.html { render :new }\n format.json { render json: @concert.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @central_correio = CentralCorreio.new(params[:central_correio])\n\n respond_to do |format|\n if @central_correio.save\n format.html { redirect_to @central_correio, notice: 'Central correio was successfully created.' }\n format.json { render json: @central_correio, status: :created, location: @central_correio }\n else\n format.html { render action: \"new\" }\n format.json { render json: @central_correio.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @coconut1 = Coconut1.new(coconut1_params)\n\n respond_to do |format|\n if @coconut1.save\n format.html { redirect_to @coconut1, notice: 'Coconut1 was successfully created.' }\n format.json { render :show, status: :created, location: @coconut1 }\n else\n format.html { render :new }\n format.json { render json: @coconut1.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @curiosidades_japon = CuriosidadesJapon.new(curiosidades_japon_params)\n\n respond_to do |format|\n if @curiosidades_japon.save\n format.html { redirect_to @curiosidades_japon, notice: 'Curiosidades japon was successfully created.' }\n format.json { render :show, status: :created, location: @curiosidades_japon }\n else\n format.html { render :new }\n format.json { render json: @curiosidades_japon.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @cp_press = CpPress.new(params[:cp_press])\n\n respond_to do |format|\n if @cp_press.save\n format.html { redirect_to @cp_press, notice: 'Cp press was successfully created.' }\n format.json { render json: @cp_press, status: :created, location: @cp_press }\n else\n format.html { render action: \"new\" }\n format.json { render json: @cp_press.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n # @observation = Observation.new(params[:observation])\n\n @coral = Coral.find(params[:coral_id])\n @observation = @coral.observations.create(observation_params)\n\n respond_to do |format|\n if @observation.save\n format.html { redirect_to coral_path(@coral), flash: {success: 'The observation was successfully created.' } }\n format.json { render json: @observation, status: :created, location: @observation }\n else\n format.html { redirect_to coral_path(@coral), flash: {danger: \"The observation was NOT created. Please make sure the fieldtrip ID is a number and unique.\" } }\n format.json { render json: @observation.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @circulo = Circulo.new(circulo_params)\n\n respond_to do |format|\n if @circulo.save\n format.html { redirect_to @circulo, notice: 'Circulo was successfully created.' }\n format.json { render :show, status: :created, location: @circulo }\n else\n format.html { render :new }\n format.json { render json: @circulo.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n from_interface = Interface.find(patchcord_params['from_node'])\n to_interface = Interface.find(patchcord_params['to_node'])\n @patchcord = Patchcord.new(from_node: from_interface,\n to_node: to_interface,\n length: patchcord_params['length'])\n\n respond_to do |format|\n if @patchcord.save\n format.html { redirect_to @patchcord, notice: 'Patchcord was successfully created.' }\n format.json { render :show, status: :created, location: @patchcord }\n else\n format.html { redirect_to new_patchcord_url, alert: @patchcord.errors }\n format.json { render json: @patchcord.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @chocolate = Chocolate.new(chocolate_params)\n\n respond_to do |format|\n if @chocolate.save\n format.html { redirect_to @chocolate, notice: \"Chocolate was successfully created.\" }\n format.json { render :show, status: :created, location: @chocolate }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @chocolate.errors, status: :unprocessable_entity }\n end\n end\n end", "def corge_params\n params.require(:corge).permit(:name)\n end", "def create\n @curso = Curso.new(curso_params)\n\n respond_to do |format|\n if @curso.save\n format.html { redirect_to @curso, notice: 'Curso foi criado(a) com sucesso.' }\n format.json { render action: 'show', status: :created, location: @curso }\n else\n format.html { render action: 'new' }\n format.json { render json: @curso.errors, status: :unprocessable_entity }\n end\n end\n end", "def post_evaluate(excon, body)\n excon.request(\n method: :post,\n path: '/evaluate',\n headers: { 'Content-Type' => 'application/json' },\n body: body\n )\nend", "def test_client_post\n client = CoAP::Client.new\n answer = client.post('coap.me', 5683, '/test', 'TD_COAP_CORE_04')\n assert_equal(2, answer.mcode[0])\n assert_equal(1, answer.mcode[1])\n assert_equal('POST OK', answer.payload)\n end", "def create\n @cppic = Cppic.new(params[:cppic])\n\n respond_to do |format|\n if @cppic.save\n format.html { redirect_to @cppic, notice: 'Cppic was successfully created.' }\n format.json { render json: @cppic, status: :created, location: @cppic }\n else\n format.html { render action: \"new\" }\n format.json { render json: @cppic.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @cn_curve = CnCurve.new(cn_curve_params)\n\n respond_to do |format|\n if @cn_curve.save\n format.html { redirect_to @cn_curve, notice: 'Cn curve was successfully created.' }\n format.json { render json: @cn_curve, status: :created }\n else\n format.html { render action: 'new' }\n format.json { render json: @cn_curve.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @correction = Correction.new(correction_params)\n\n respond_to do |format|\n if @correction.save\n format.html { redirect_to @correction, notice: 'Correction was successfully created.' }\n format.json { render :show, status: :created, location: @correction }\n else\n format.html { render :new }\n format.json { render json: @correction.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @congresso = Congresso.new(congresso_params)\n\n respond_to do |format|\n if @congresso.save\n format.html { redirect_to @congresso, notice: 'Congresso was successfully created.' }\n format.json { render :show, status: :created, location: @congresso }\n else\n format.html { render :new }\n format.json { render json: @congresso.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @crpyto_info = CrpytoInfo.new(crpyto_info_params)\n\n respond_to do |format|\n if @crpyto_info.save\n format.html { redirect_to @crpyto_info, notice: 'Crpyto info was successfully created.' }\n format.json { render :show, status: :created, location: @crpyto_info }\n else\n format.html { render :new }\n format.json { render json: @crpyto_info.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @concurso = Concurso.new(concurso_params)\n\n respond_to do |format|\n if @concurso.save\n format.html { redirect_to @concurso, notice: 'Concurso ha sido creado correctamente.' }\n format.json { render :show, status: :created, location: @concurso }\n else\n format.html { render :new }\n format.json { render json: @concurso.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @correction = Correction.new(params[:correction])\n\n respond_to do |format|\n if @correction.save\n format.html { redirect_to @correction, notice: 'Correction was successfully created.' }\n format.json { render json: @correction, status: :created, location: @correction }\n else\n format.html { render action: \"new\" }\n format.json { render json: @correction.errors, status: :unprocessable_entity }\n end\n end\n end", "def do_coaps_posted_02\n # get the Base64 of the incoming signed request\n body = IO.read(\"spec/files/vr_00-D0-E5-F2-00-02.vrq\")\n\n env = Hash.new\n env[\"SSL_CLIENT_CERT\"] = cbor_clientcert_02\n env[\"HTTP_ACCEPT\"] = \"application/voucher-cose+cbor\"\n env[\"CONTENT_TYPE\"] = \"application/voucher-cose+cbor\"\n\n $FAKED_TEMPORARY_KEY = temporary_key\n post '/e/rv', :params => body, :headers => env\n end", "def create\n @company_authority = CompanyAuthority.new(company_authority_params)\n\n if @company_authority.save\n render json: @company_authority, status: :created, location: @company_authority\n else\n render json: @company_authority.errors, status: :unprocessable_entity\n end\n end", "def create\n @secco = @curso.seccos.build(secco_params)\n\n respond_to do |format|\n if @secco.save\n format.html { redirect_to curso_secco_path(@curso, @secco), notice: 'Seccao was successfully created.' }\n format.json { render :show, status: :created, location: @secco }\n else\n format.html { render :new }\n format.json { render json: @secco.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @trein_consul_comercial = TreinConsulComercial.new(trein_consul_comercial_params)\n\n respond_to do |format|\n if @trein_consul_comercial.save\n format.html { redirect_to @trein_consul_comercial, notice: 'Trein consul comercial was successfully created.' }\n format.json { render action: 'show', status: :created, location: @trein_consul_comercial }\n else\n format.html { render action: 'new' }\n format.json { render json: @trein_consul_comercial.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @csosn = Csosn.new(params[:csosn])\n\n respond_to do |format|\n if @csosn.save\n format.html { redirect_to @csosn, notice: 'Csosn was successfully created.' }\n format.json { render json: @csosn, status: :created, location: @csosn }\n else\n format.html { render action: \"new\" }\n format.json { render json: @csosn.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @cocktail = Cocktail.new(params[:cocktail])\n\n respond_to do |format|\n if @cocktail.save\n format.html { redirect_to @cocktail, notice: 'Cocktail was successfully created.' }\n format.json { render json: @cocktail, status: :created, location: @cocktail }\n else\n format.html { render action: \"new\" }\n format.json { render json: @cocktail.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @clonet = Clonet.new(params[:clonet])\n\n respond_to do |format|\n if @clonet.save\n format.html { redirect_to @clonet, notice: 'Clonet was successfully created.' }\n format.json { render json: @clonet, status: :created, location: @clonet }\n else\n format.html { render action: \"new\" }\n format.json { render json: @clonet.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @csrelation = Csrelation.new(csrelation_params)\n\n respond_to do |format|\n if @csrelation.save\n format.html { redirect_to @csrelation, notice: 'Csrelation was successfully created.' }\n format.json { render :show, status: :created, location: @csrelation }\n else\n format.html { render :new }\n format.json { render json: @csrelation.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @circle = Circle.new(post_params)\n\n if @circle.save\n render :show, status: :created, location: @circle \n else\n render json: @circle.errors, status: :unprocessable_entity \n end\n end", "def create\n @care_plan = CarePlan.new(care_plan_params)\n\n if @care_plan.save\n render json: @care_plan, status: :created, location: @care_plan\n else\n render json: @care_plan.errors, status: :unprocessable_entity\n end\n end", "def create\n @socio_doc_fiscais_coring = SocioDocFiscaisCoring.new(socio_doc_fiscais_coring_params)\n\n respond_to do |format|\n if @socio_doc_fiscais_coring.save\n format.html { redirect_to @socio_doc_fiscais_coring, notice: 'Socio doc fiscais coring was successfully created.' }\n format.json { render action: 'show', status: :created, location: @socio_doc_fiscais_coring }\n else\n format.html { render action: 'new' }\n format.json { render json: @socio_doc_fiscais_coring.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @cocoon_example = CocoonExample.new(cocoon_example_params)\n\n respond_to do |format|\n if @cocoon_example.save\n format.html { redirect_to @cocoon_example, notice: 'Cocoon example was successfully created.' }\n format.json { render :show, status: :created, location: @cocoon_example }\n else\n format.html { render :new }\n format.json { render json: @cocoon_example.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @cof = Cof.new(cof_params)\n\n respond_to do |format|\n if @cof.save\n format.html { redirect_to @cof, notice: 'Cof was successfully created.' }\n format.json { render action: 'show', status: :created, location: @cof }\n else\n format.html { render action: 'new' }\n format.json { render json: @cof.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @recipy = Recipy.new(params[:recipy])\n\n respond_to do |format|\n if @recipy.save\n format.html { redirect_to @recipy, notice: 'Recipy was successfully created.' }\n format.json { render json: @recipy, status: :created, location: @recipy }\n else\n format.html { render action: \"new\" }\n format.json { render json: @recipy.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @consequence = Consequence.new(consequence_params)\n\n respond_to do |format|\n if @consequence.save\n format.html { redirect_to @consequence, notice: 'Consequence was successfully created.' }\n format.json { render :show, status: :created, location: @consequence }\n else\n format.html { render :new }\n format.json { render json: @consequence.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @caso = Caso.new(caso_params)\n\n respond_to do |format|\n if @caso.save\n format.html { redirect_to @caso, notice: 'Caso creado con éxito.' }\n format.json { render action: 'show', status: :created, location: @caso }\n else\n format.html { render action: 'new' }\n format.json { render json: @caso.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @proximity = Proximity.new(proximity_params)\n\n respond_to do |format|\n if @proximity.save\n format.html { redirect_to @proximity, notice: 'Proximity was successfully created.' }\n format.json { render action: 'show', status: :created, location: @proximity }\n else\n format.html { render action: 'new' }\n format.json { render json: @proximity.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @prospecto_correo = ProspectoCorreo.new(prospecto_correo_params)\n\n respond_to do |format|\n if @prospecto_correo.save\n format.html { redirect_to @prospecto_correo, notice: 'Prospecto correo was successfully created.' }\n format.json { render :show, status: :created, location: @prospecto_correo }\n else\n format.html { render :new }\n format.json { render json: @prospecto_correo.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @condolence = Condolence.new(params[:condolence])\n @orbituarysite = @condolence.orbituarysite\n respond_to do |format|\n if @condolence.save\n format.html { redirect_to @orbituarysite, notice: 'Condolence was successfully created.' }\n format.json { render json: @condolence, status: :created, location: @condolence }\n else\n format.html { render action: \"new\" }\n format.json { render json: @condolence.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @cfct = Cfct.new(cfct_params)\n\n respond_to do |format|\n if @cfct.save\n format.html { redirect_to @cfct, notice: 'Cfct was successfully created.' }\n format.json { render :show, status: :created, location: @cfct }\n else\n format.html { render :new }\n format.json { render json: @cfct.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @sponsercf = Sponsercf.new(sponsercf_params)\n\n respond_to do |format|\n if @sponsercf.save\n \n format.html { redirect_to @sponsercf, notice: 'Sponsercf was successfully created.' }\n format.json { render :show, status: :created, location: @sponsercf }\n else\n format.html { render :new }\n format.json { render json: @sponsercf.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @cpf = Cpf.new(cpf_params)\n\n respond_to do |format|\n if @cpf.save\n format.html { redirect_to @cpf, notice: 'Cpf was successfully created.' }\n format.json { render action: 'show', status: :created, location: @cpf }\n else\n format.html { render action: 'new' }\n format.json { render json: @cpf.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @correo = Correo.new(params[:correo])\n\n respond_to do |format|\n if @correo.save\n format.html { redirect_to edit_correo_path(@correo), notice: 'correo was successfully created.' }\n format.json { render json: @correo, status: :created, location: @correo }\n else\n format.html { render action: \"new\" }\n format.json { render json: @correo.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @state_copd = StateCopd.new(state_copd_params)\n\n respond_to do |format|\n if @state_copd.save\n format.html { redirect_to @state_copd, notice: 'State copd was successfully created.' }\n format.json { render :show, status: :created, location: @state_copd }\n else\n format.html { render :new }\n format.json { render json: @state_copd.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @circ_policy_matrix = CircPolicyMatrix.new(circ_policy_matrix_params)\n\n respond_to do |format|\n if @circ_policy_matrix.save\n format.html { redirect_to @circ_policy_matrix, notice: 'Circ policy matrix was successfully created.' }\n format.json { render :show, status: :created, location: @circ_policy_matrix }\n else\n format.html { render :new }\n format.json { render json: @circ_policy_matrix.errors, status: :unprocessable_entity }\n end\n end\n end", "def post\n Typhoeus.post(@url,\n body: @results_hash.to_json,\n headers: { 'Content-Type' => 'application/json' })\n end", "def create\n @subject_of_speech = SubjectOfSpeech.new(subject_of_speech_params)\n # binding.pry\n @subject_of_speech.costar = params[\"costar\"].to_s\n\n respond_to do |format|\n if @subject_of_speech.save\n format.html { redirect_to @subject_of_speech, notice: 'Subject of speech was successfully created.' }\n format.json { render :show, status: :created, location: @subject_of_speech }\n else\n format.html { render :new }\n format.json { render json: @subject_of_speech.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @concurso = Concurso.new(params[:concurso])\n\n respond_to do |format|\n if @concurso.save\n format.html { redirect_to @concurso, notice: 'Concurso criado com sucesso.' }\n format.json { render json: @concurso, status: :created, location: @concurso }\n else\n format.html { render action: \"new\" }\n format.json { render json: @concurso.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @scoop = Scoop.new(scoop_params)\n @scoop.kid = current_kid\n respond_to do |format|\n if @scoop.save\n format.html { redirect_to scoops_path, notice: 'Scoop was successfully created!' }\n format.json { render :show, status: :created, location: @scoop }\n else\n format.html { render :new }\n format.json { render json: @scoop.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @coff = Coff.new(params[:coff])\n\n respond_to do |format|\n if @coff.save\n format.html { redirect_to @coff, notice: 'Coff was successfully created.' }\n format.json { render json: @coff, status: :created, location: @coff }\n else\n format.html { render action: \"new\" }\n format.json { render json: @coff.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @con_proc = ConProc.new(con_proc_params)\n\n respond_to do |format|\n if @con_proc.save\n format.html { redirect_to @con_proc, notice: 'Con proc was successfully created.' }\n format.json { render :show, status: :created, location: @con_proc }\n else\n format.html { render :new }\n format.json { render json: @con_proc.errors, status: :unprocessable_entity }\n end\n end\n end" ]
[ "0.61426973", "0.5903807", "0.55852276", "0.5559872", "0.5545504", "0.5443921", "0.5400938", "0.53967345", "0.53742874", "0.5358108", "0.53553253", "0.53443646", "0.5334253", "0.5329681", "0.53193533", "0.53118676", "0.52779937", "0.5244831", "0.52070224", "0.5189835", "0.5174418", "0.5169705", "0.51696485", "0.51607734", "0.5152674", "0.5150663", "0.5147223", "0.51389843", "0.5135766", "0.51340455", "0.5132083", "0.51319426", "0.51306015", "0.5116909", "0.5116909", "0.51079583", "0.5096891", "0.50939906", "0.5088942", "0.50849575", "0.5078058", "0.50778115", "0.5075717", "0.5069466", "0.50549495", "0.5048065", "0.50452137", "0.5043068", "0.50264454", "0.50264454", "0.5020474", "0.50174326", "0.5017272", "0.5017185", "0.5016506", "0.5013952", "0.5008751", "0.50065154", "0.5002862", "0.5001535", "0.4993764", "0.49845126", "0.4978732", "0.4976953", "0.49766347", "0.4966073", "0.49570534", "0.49490497", "0.49482107", "0.4946668", "0.49460784", "0.49436328", "0.49375287", "0.49356085", "0.49344623", "0.49323657", "0.49269566", "0.49268758", "0.49219188", "0.49217576", "0.492021", "0.49200886", "0.49107265", "0.490513", "0.4900361", "0.48987347", "0.48980078", "0.48974872", "0.489238", "0.4891398", "0.48907128", "0.48865914", "0.4876719", "0.48756823", "0.48755318", "0.48713645", "0.4869703", "0.4865133", "0.48648852", "0.48604771" ]
0.5137135
28
PATCH/PUT /corps/1 PATCH/PUT /corps/1.json
def update respond_to do |format| if @corp.update(corp_params) format.html { redirect_to @corp, notice: 'Corp was successfully updated.' } format.json { render :show, status: :ok, location: @corp } else format.html { render :edit } format.json { render json: @corp.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_tenant_circle(args = {}) \n put(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend", "def update\n respond_to do |format|\n if @corpu.update(corpu_params)\n format.json { head :no_content }\n format.js\n else\n format.json { render json: @corpu.errors.full_messages, status: :unprocessable_entity }\n end\n end\n end", "def patch\n headers = {\"If-Match\" => @version}\n response = @context.request :patch, \"#{@path}/#{@id}\", @data.to_json, headers\n @version += 1\n response\n # 'X-HTTP-Method-Override' => 'PATCH'\n end", "def api_patch(path, data = {})\n api_request(:patch, path, :data => data)\n end", "def update\n respond_to do |format|\n if @corge.update(corge_params)\n format.html { redirect_to @corge, notice: 'Corge was successfully updated.' }\n format.json { render :show, status: :ok, location: @corge }\n else\n format.html { render :edit }\n format.json { render json: @corge.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n # { clinic: {id: references, \"license_id\"=>nil, \"name\"=>string } }\n \n if @clinic.update_attributes(params[:clinic].except(:api_license_id))\n head :no_content\n else\n render json: clinic.errors.full_messages, status: :unprocessable_entity\n end\n end", "def patch!\n request! :patch\n end", "def patch(path, data)\n request 'PATCH', path, body: data.to_json\n end", "def patch options\n rest_request({ method: :patch }.merge(options))\n end", "def patch options\n rest_request({ method: :patch }.merge(options))\n end", "def update\n #Finding the specific chore where the id matches the one we pass in with the body\n @v1_chore = Chore.where(id: params[:id]).first\n #Here we're checking if we have user_id in our body, and if we do, we'll change the selected chore's properties\n #with the parameters of the body, we go through the specific group to our specific chore with the path\n if v1_chore_params[:user_id]\n @v1_chore.user_id = params[:user_id]\n @v1_chore.assigned = true\n if @v1_chore.save\n render :show, status: :ok\n end\n else\n render json: @v1_chore.errors, status: :unprocessable_entity\n end\n end", "def patch(path, params)\n time(\"PATCH #{path}\") { Cloudflarer.new.patch(path, params) }\n end", "def update\n render json: Company.update(params[\"id\"], params[\"company\"])\n end", "def patch(path, body_params = {})\n debug_log \"PATCH #{@host}#{path} body:#{body_params}\"\n headers = { 'Content-Type' => 'application/json' }\n res = connection.run_request :put, path, body_params.to_json, headers\n debug_log \"Response status:#{res.status}, body:#{res.body}\"\n res\n end", "def update\n @correlation = Correlation.find(params[:id])\n\n respond_to do |format|\n if @correlation.update_attributes(params[:correlation])\n format.html { redirect_to @correlation, notice: 'Correlation was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @correlation.errors, status: :unprocessable_entity }\n end\n end\n end", "def patch(path, data, options = {})\n uri = build_uri(path, options)\n\n request = Net::HTTP::Patch.new(uri.request_uri)\n set_authorisation_header(request)\n request.set_form_data(data)\n\n response = https_client(uri).request(request)\n end", "def update\n respond_to do |format|\n if @reqcargo.update(reqcargo_params)\n format.html { redirect_to @reqcargo, notice: 'Reqcargo was successfully updated.' }\n format.json { render :show, status: :ok, location: @reqcargo }\n else\n format.html { render :edit }\n format.json { render json: @reqcargo.errors, status: :unprocessable_entity }\n end\n end\n end", "def patch(operation, path, value = nil)\n ensure_client && ensure_uri\n body = {\n 'op' => operation,\n 'path' => path,\n 'value' => value\n }\n response = @client.rest_patch(@data['uri'], { 'Content-Type' => 'application/json-patch+json', 'body' => [body] }, @api_version)\n @client.response_handler(response)\n end", "def update\n @curso = Curso.find(params[:id])\n\n respond_to do |format|\n if @curso.update_attributes(params[:curso])\n format.html { redirect_to(:back) }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @curso.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @complaint = Complaint.find(params[:id])\n\n if @complaint.update_attributes(params[:complaint])\n head :no_content\n else\n render json: @complaint.errors, status: :unprocessable_entity\n end\n end", "def patch(path, params = {})\n request(:patch, path, params)\n end", "def patch(path, params = {})\n request(:patch, path, params)\n end", "def update # PATCH\n raise NotImplementedError\n end", "def patch(path, **args); end", "def update\n respond_to do |format|\n if @trip.update(trip_params)\n last_clip(@trip, trip_params[:clips_attributes].present?)\n format.html { redirect_to @trip.parent || @trip, notice: 'Trip was successfully updated.', change: \"list\" }\n format.json { head :no_content }\n else\n format.html { redirect_to @trip.parent || @trip }\n format.json { render json: @trip.errors, status: :unprocessable_entity }\n end\n end\n end", "def patch(type, info)\n path, info = type_info(type, :path), force_case(info)\n ida = type == :client ? 'client_id' : 'id'\n raise ArgumentError, \"info must include #{ida}\" unless id = info[ida]\n hdrs = headers\n if info && info['meta'] && (etag = info['meta']['version'])\n hdrs.merge!('if-match' => etag)\n end\n reply = json_parse_reply(@key_style,\n *json_patch(@target, \"#{path}/#{Addressable::URI.encode(id)}\", info, hdrs))\n\n # hide client endpoints that are not quite scim compatible\n type == :client && !reply ? get(type, info['client_id']): reply\n end", "def update!(params)\n res = @client.put(path, nil, params, \"Content-Type\" => \"application/json\")\n @attributes = res.json if res.status == 201\n res\n end", "def update\n respond_to do |format|\n if @corrida.update(corrida_params)\n format.html { redirect_to @corrida, notice: 'Corrida actualizada correctamente.' }\n format.json { render :show, status: :ok, location: @corrida }\n else\n format.html { render :edit }\n format.json { render json: @corrida.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @cof.update(cof_params)\n format.html { redirect_to :back }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @cof.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @coconut1.update(coconut1_params)\n format.html { redirect_to @coconut1, notice: 'Coconut1 was successfully updated.' }\n format.json { render :show, status: :ok, location: @coconut1 }\n else\n format.html { render :edit }\n format.json { render json: @coconut1.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @cocoon_example.update(cocoon_example_params)\n format.html { redirect_to @cocoon_example, notice: 'Cocoon example was successfully updated.' }\n format.json { render :show, status: :ok, location: @cocoon_example }\n else\n format.html { render :edit }\n format.json { render json: @cocoon_example.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @clonet = Clonet.find(params[:id])\n\n respond_to do |format|\n if @clonet.update_attributes(params[:clonet])\n format.html { redirect_to @clonet, notice: 'Clonet was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @clonet.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @cooco.update(cooco_params)\n format.html { redirect_to @cooco, notice: 'Cooco was successfully updated.' }\n format.json { render :show, status: :ok, location: @cooco }\n else\n format.html { render :edit }\n format.json { render json: @cooco.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @patch = Patch.find(params[:id])\n\n respond_to do |format|\n if @patch.update_attributes(params[:patch])\n format.html { redirect_to @patch, notice: 'Patch was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @patch.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @coff = Coff.find(params[:id])\n\n respond_to do |format|\n if @coff.update_attributes(params[:coff])\n format.html { redirect_to @coff, notice: 'Coff was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @coff.errors, status: :unprocessable_entity }\n end\n end\n end", "def update(path)\n output { patch(path, params) }\n end", "def update\n @crust = Crust.find(params[:id])\n\n respond_to do |format|\n if @crust.update_attributes(params[:crust])\n format.html { redirect_to @crust, notice: 'Crust was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @crust.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @couch.update(couch_params)\n format.html { redirect_to @couch, notice: 'Couche was successfully updated.' }\n format.json { render :show, status: :ok, location: @couch }\n else\n format.html { render :edit }\n format.json { render json: @couch.errors, status: :unprocessable_entity }\n end\n end\n end", "def rest_patch(base_uri,json_payload,params)\n begin\n @response = RestClient.patch(base_uri,json_payload,params)\n rescue => e\n puts @response.code\n end\n return @response\n end", "def update\n respond_to do |format|\n if @patch.update(patch_params)\n format.html { redirect_to @patch, notice: 'Patch was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @patch.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @camp.update(camp_params)\n format.html { redirect_to @camp, notice: \"#{@camp.name} was revised in the system.\" }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.jdson { render json: @camp.errors, status: :unprocessable_entity }\n end\n end\n end", "def patch(path, data, params = {}, request_options = {})\n request(:patch, path, data, params)\n end", "def update(&block)\n validate_request()\n\n # Params includes all of the PATCH data at the top level along with other\n # other Rails-injected params like 'id', 'action', 'controller'. These\n # are harmless given no namespace collision and we're only interested in\n # the 'Operations' key for the actual patch data.\n #\n render(json: yield(self.safe_params()[:id], self.safe_params().to_hash()))\n end", "def update\n respond_to do |format|\n if @caso.update_attributes(caso_params)\n format.html { redirect_to @caso, notice: 'Caso was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @caso.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @correlation.update(correlation_params)\n format.html { redirect_to @correlation, notice: 'Correlation was successfully updated.' }\n format.json { render :show, status: :ok, location: @correlation }\n else\n format.html { render :edit }\n format.json { render json: @correlation.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @observation = Observation.find(params[:id])\n\n respond_to do |format|\n if @observation.update_attributes(observation_params)\n format.html { redirect_to coral_path(@observation.coral), flash: {success: 'Observation was successfully updated.' } }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @observation.errors, status: :unprocessable_entity }\n end\n end\n end", "def update(url, data)\n RestClient.put url, data, :content_type => :json\nend", "def update\n respond_to do |format|\n if @api_v1_concern.update(api_v1_concern_params)\n format.html { redirect_to @api_v1_concern, notice: 'Concern was successfully updated.' }\n format.json { render :show, status: :ok, location: @api_v1_concern }\n else\n format.html { render :edit }\n format.json { render json: @api_v1_concern.errors, status: :unprocessable_entity }\n end\n end\n end", "def patch\n end", "def update\n respond_to do |format|\n if @poc.update(poc_params)\n format.html { redirect_to @poc, notice: 'Poc was successfully updated.' }\n format.json { render :show, status: :ok, location: @poc }\n else\n format.html { render :edit }\n format.json { render json: @poc.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @copenometro.update(copenometro_params)\n format.html { redirect_to @copenometro, notice: 'Copenometro was successfully updated.' }\n format.json { render :show, status: :ok, location: @copenometro }\n else\n format.html { render :edit }\n format.json { render json: @copenometro.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @capitol.update(capitol_params)\n format.html { redirect_to root_path, notice: 'Capitol was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @capitol.errors, status: :unprocessable_entity }\n end\n end\n end", "def patch(operation, path, value)\n response = @client.rest_patch(@data['uri'], 'body' => [{ op: operation, path: path, value: value }])\n @client.response_handler(response)\n end", "def update\n respond_to do |format|\n if @couch.update(couch_params)\n format.html { redirect_to @couch, notice: 'Couch was successfully updated.' }\n format.json { render :show, status: :ok, location: @couch }\n else\n format.html { render :edit }\n format.json { render json: @couch.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @cerc = Cerc.find(params[:id])\n\n if @cerc.update_attributes(params[:cerc])\n head :no_content\n else\n render json: @cerc.errors, status: :unprocessable_entity\n end\n end", "def update\n @cso = Cso.find(params[:id])\n\n respond_to do |format|\n if @cso.update_attributes(params[:cso])\n format.html { redirect_to @cso, notice: 'Cso was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @cso.errors, status: :unprocessable_entity }\n end\n end\n end", "def patch(path, opts = {})\n request(:patch, path, opts).body\n end", "def update\n @clasp = Clasp.find(params[:id])\n\n respond_to do |format|\n if @clasp.update_attributes(params[:clasp])\n format.html { redirect_to @clasp, notice: 'Clasp was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @clasp.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n\n @company = Company.find(1)\n @puntos = @company.get_puntos()\n @employees = @company.get_employees2() \n@trucks = @company.get_trucks\n\n respond_to do |format|\n if @cout.update(cout_params)\n format.html { redirect_to @cout, notice: 'Cout was successfully updated.' }\n format.json { render :show, status: :ok, location: @cout }\n else\n format.html { render :edit }\n format.json { render json: @cout.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @trein_consul_comercial.update(trein_consul_comercial_params)\n format.html { redirect_to @trein_consul_comercial, notice: 'Trein consul comercial was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @trein_consul_comercial.errors, status: :unprocessable_entity }\n end\n end\n end", "def update options={}\n client.put(\"/#{id}\", options)\n end", "def update\n @contact = Contact.find(params[:id])\n if params[:contact][:clientId] == \"\"\n params[:contact][:clientId] = nil\n end \n\n respond_to do |format|\n if @contact.update_attributes(params[:contact])\n format.html { redirect_to @contact, notice: 'Contato atualizado com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @socio_doc_fiscais_coring.update(socio_doc_fiscais_coring_params)\n format.html { redirect_to @socio_doc_fiscais_coring, notice: 'Socio doc fiscais coring was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @socio_doc_fiscais_coring.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @cto.update(cto_params)\n format.html { redirect_to @cto, notice: 'Cto was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @cto.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @care_circle.update(care_circle_params)\n format.html { redirect_to @care_circle, notice: 'Care circle was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @care_circle.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @crpyto_info.update(crpyto_info_params)\n format.html { redirect_to @crpyto_info, notice: 'Crpyto info was successfully updated.' }\n format.json { render :show, status: :ok, location: @crpyto_info }\n else\n format.html { render :edit }\n format.json { render json: @crpyto_info.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @commtent1 = Commtent1.find(params[:id])\n\n respond_to do |format|\n if @commtent1.update_attributes(params[:commtent1])\n format.html { redirect_to @commtent1, notice: 'Commtent1 was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @commtent1.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @chronicle = Chronicle.find(params[:id])\n\n respond_to do |format|\n if @chronicle.update_attributes(params[:chronicle])\n format.html { redirect_to @chronicle, notice: 'Chronicle was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @chronicle.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @projecct = Projecct.find(params[:id])\n\n respond_to do |format|\n if @projecct.update_attributes(params[:projecct])\n format.html { redirect_to @projecct, notice: 'Projecct was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @projecct.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @cephalopod.update(cephalopod_params)\n format.html { redirect_to @cephalopod, notice: 'Cephalopod was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @cephalopod.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @consorciot.update(consorciot_params)\n format.html { redirect_to @consorciot, notice: 'Consorciot was successfully updated.' }\n format.json { render :show, status: :ok, location: @consorciot }\n else\n format.html { render :edit }\n format.json { render json: @consorciot.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @cocktail = Cocktail.find(params[:id])\n respond_to do |format|\n if @cocktail.update_attributes(params[:cocktail])\n format.html { redirect_to @cocktail, :notice => 'Cocktail was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @cocktail.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n client=Client.find_by_id params[:id]\n if client!= nil\n client.cedula=params[:cedula] ? params[:cedula]: client.cedula\n client.sector=params[:sector] ? params[:sector]: client.sector\n client.nombre=params[:nombre] ? params[:nombre]: client.nombre\n client.telefono=params[:telefono] ? params[:telefono]: client.telefono\n client.pagina=params[:pagina] ? params[:pagina]: client.pagina\n client.direccion=params[:direccion] ? params[:direccion]: client.direccion\n if client.save\n render(json: client, status: 201)\n end \n else\n render(json: client.errors, status: 404)\n end \n end", "def update\n @cp_change = CpChange.find(params[:id])\n\n if @cp_change.update(cp_change_params)\n head :no_content\n else\n render json: @cp_change.errors, status: :unprocessable_entity\n end\n end", "def update\n respond_to do |format|\n if @capex.update(capex_params)\n format.html { redirect_to @capex, notice: 'Capex was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @capex.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @squishee_cup = SquisheeCup.find(params[:id])\n puts params.to_json\n respond_to do |format|\n if @squishee_cup.update_attributes(params[:squishee_cup])\n format.html { redirect_to @squishee_cup, notice: 'Squishee cup was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @squishee_cup.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @curso.update(curso_params)\n format.html { redirect_to @curso, notice: 'Curso was successfully updated.' }\n format.json { render :show, status: :ok, location: @curso }\n else\n format.html { render :edit }\n format.json { render json: @curso.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @corp.update(corp_params)\n format.html { redirect_to @corp, notice: 'Corp was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @corp.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @cocktail = Cocktail.find(params[:id])\n\n respond_to do |format|\n if @cocktail.update_attributes(params[:cocktail])\n format.html { redirect_to @cocktail, notice: 'Cocktail was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @cocktail.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @conpany.update(conpany_params)\n format.html { redirect_to conpanies_path , notice: 'Conpany was successfully updated.' }\n format.json { render :show, status: :ok, location: @conpany }\n \n else\n format.html { render :edit }\n format.json { render json: @conpany.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @court_complex.update(court_complex_params)\n format.html { redirect_to @court_complex, notice: 'Court complex was successfully updated.' }\n format.json { render :show, status: :ok, location: @court_complex }\n else\n format.html { render :edit }\n format.json { render json: @court_complex.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @scoop.update(scoop_params)\n format.html { redirect_to scoops_path, notice: 'Scoop was successfully updated!' }\n format.json { render :show, status: :ok, location: @scoop }\n else\n format.html { render :edit }\n format.json { render json: @scoop.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @curso.update(curso_params)\n format.html { redirect_to @curso, notice: 'Curso foi atualizado(a) com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @curso.errors, status: :unprocessable_entity }\n end\n end\n end", "def update!(**args)\n @client_id = args[:client_id] if args.key?(:client_id)\n @recurrence = args[:recurrence] if args.key?(:recurrence)\n @recurrence_id = args[:recurrence_id] if args.key?(:recurrence_id)\n @server_id = args[:server_id] if args.key?(:server_id)\n end", "def update\n respond_to do |format|\n if @socio_cpf.update(socio_cpf_params)\n format.html { redirect_to @socio_cpf, notice: 'Socio cpf was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @socio_cpf.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @central_correio = CentralCorreio.find(params[:id])\n\n respond_to do |format|\n if @central_correio.update_attributes(params[:central_correio])\n format.html { redirect_to @central_correio, notice: 'Central correio was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @central_correio.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @circle = Circle.find(params[:id])\n\n respond_to do |format|\n if @circle.update_attributes(params[:circle])\n format.html { redirect_to @circle, :notice => 'Circle was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @circle.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @colaborattor.update(colaborattor_params)\n format.html { redirect_to colaborattors_path, notice: I18n.t('messages.updated_with', item: @colaborattor.colaborattorname) }\n format.json { render :show, status: :ok, location: @colaborattor }\n else\n format.html { render :edit }\n format.json { render json: @colaborattor.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @curso.update(curso_params)\n format.html { redirect_to cursos_path, notice: 'Curso atualizado com sucesso!' }\n format.json { render :show, status: :ok, location: @curso }\n else\n format.html { render :edit }\n format.json { render json: @curso.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n # TODO: Add cron_str updating\n respond_to do |format|\n if @chore.update_attributes(params[:chore])\n format.html { redirect_to @chore, notice: 'Chore was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :edit }\n format.json { render json: @chore.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @docs_ponto.update(docs_ponto_params)\n format.html { redirect_to :back }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @docs_ponto.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @circulation = Circulation.find(params[:id])\n\n respond_to do |format|\n if @circulation.update_attributes(params[:circulation])\n format.html { redirect_to @circulation, notice: 'Circulation was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @circulation.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @chest_triceps1.update(chest_triceps1_params)\n format.html { redirect_to \"/chest_triceps1s\" } \n format.json { render :show, status: :ok, location: @chest_triceps1 }\n else\n format.html { render :edit }\n format.json { render json: @chest_triceps1.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @cec_complaint = CecComplaint.find(params[:id])\n\n respond_to do |format|\n if @cec_complaint.update_attributes(params[:cec_complaint])\n format.html { redirect_to @cec_complaint, notice: 'Cec complaint was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @cec_complaint.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @articulocomp = Articulocomp.find(params[:id])\n\n respond_to do |format|\n if @articulocomp.update_attributes(params[:articulocomp])\n format.html { redirect_to @articulocomp, :notice => 'Articulocomp was successfully updated.' }\n #format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n #format.json { render json: @articulocomp.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n require 'rest-client'\n response = RestClient.put('localhost:3001/colores/'+@color.id.to_s, color_params.as_json, {:Authorization => 'admin irizREhyoG6Ejwr4AcjsQME9'})\n if response.code == 200\n @color = JSON.parse(response.body)\n\n format.html { redirect_to @color, notice: \"Color was successfully updated.\" }\n format.json { render :show, status: :ok, location: @color }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @color.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @prod_coti.update(prod_coti_params)\n format.html { redirect_to @prod_coti, notice: 'Prod coti was successfully updated.' }\n format.json { render :show, status: :ok, location: @prod_coti }\n else\n format.html { render :edit }\n format.json { render json: @prod_coti.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @circle = Circle.find(params[:id])\n\n respond_to do |format|\n if @circle.update_attributes(params[:circle])\n format.html { redirect_to @circle, notice: 'Circle was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @circle.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @circle = Circle.find(params[:id])\n\n respond_to do |format|\n if @circle.update_attributes(params[:circle])\n format.html { redirect_to @circle, notice: 'Circle was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @circle.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @consumo = Consumo.find(params[:id])\n\n respond_to do |format|\n if @consumo.update_attributes(params[:consumo])\n format.html { redirect_to @consumo.cliente, :notice => 'Consumo alterado com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @consumo.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @coche.update(coche_params)\n format.html { redirect_to @coche, notice: 'Coche was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @coche.errors, status: :unprocessable_entity }\n end\n end\n end" ]
[ "0.63657326", "0.6250912", "0.61621356", "0.60965997", "0.60865307", "0.6085833", "0.60691607", "0.60228765", "0.5982152", "0.5982152", "0.59476143", "0.59448385", "0.5915759", "0.58931226", "0.5886872", "0.5853425", "0.58501947", "0.5846086", "0.5844588", "0.5832674", "0.58270824", "0.58270824", "0.58125025", "0.5807818", "0.5782992", "0.5782661", "0.57800716", "0.5774697", "0.57619095", "0.5742898", "0.57396775", "0.57384473", "0.5730308", "0.5722982", "0.5707546", "0.57051986", "0.5692591", "0.5688038", "0.567672", "0.5671181", "0.56690496", "0.56643534", "0.5663952", "0.5649968", "0.56462544", "0.5642602", "0.56417376", "0.564018", "0.5635576", "0.5631634", "0.5630695", "0.5628332", "0.5619787", "0.5614715", "0.5613767", "0.5608281", "0.5606369", "0.5604401", "0.55973214", "0.55899024", "0.5587421", "0.55807966", "0.55775183", "0.55773467", "0.55735123", "0.5573318", "0.5561674", "0.5558948", "0.5552583", "0.55522", "0.5547769", "0.5547185", "0.554569", "0.5541439", "0.5538419", "0.5534847", "0.55346835", "0.5530035", "0.55187666", "0.5515825", "0.5510083", "0.5505409", "0.55037165", "0.5503668", "0.5486248", "0.5482858", "0.54824567", "0.5476927", "0.5474955", "0.54748225", "0.5472639", "0.54676497", "0.5462103", "0.5461686", "0.5459636", "0.5458147", "0.54548985", "0.54546165", "0.54546165", "0.5448448", "0.5447701" ]
0.0
-1
DELETE /corps/1 DELETE /corps/1.json
def destroy @corp.destroy respond_to do |format| format.html { redirect_to corps_url, notice: 'Corp was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete_tenant_circle(args = {}) \n delete(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend", "def destroy\n @corp.destroy\n respond_to do |format|\n format.html { redirect_to corps_url }\n format.json { head :no_content }\n end\n end", "def delete\n client.delete(\"/#{id}\")\n end", "def destroy\n @v1_chore = Chore.where(id: params[:id])\n if @v1_chore.destroy\n head(:ok)\n else\n head(:unprocessable_entity)\n end\n end", "def destroy\n @correlation = Correlation.find(params[:id])\n @correlation.destroy\n\n respond_to do |format|\n format.html { redirect_to correlations_url }\n format.json { head :no_content }\n end\n end", "def delete\n res = HTTParty.get URL, headers: HEADERS\n message = JSON.parse res.body, symbolize_names: true\n if res.code == 200\n numSubs = message[:data].count\n if numSubs > 0\n message[:data].each do |sub|\n id = sub[:id]\n delRes = HTTParty.delete \"#{URL}/#{id}\", headers: HEADERS\n #TODO handle status codes\n end\n end\n end\n end", "def delete_json(path)\n url = [base_url, path].join\n resp = HTTParty.delete(url, headers: standard_headers)\n parse_json(url, resp)\n end", "def destroy\n @corge.destroy\n respond_to do |format|\n format.html { redirect_to corges_url, notice: 'Corge was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete(path)\n RestClient.delete request_base+path\n end", "def destroy\n @curso.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def destroy\n @trein_consul_comercial.destroy\n respond_to do |format|\n format.html { redirect_to trein_consul_comercials_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @cord.destroy\n respond_to do |format|\n format.html { redirect_to cords_url, notice: t('cords.destroy.success') }\n format.json { head :no_content }\n end\n end", "def destroy\n @crust = Crust.find(params[:id])\n @crust.destroy\n\n respond_to do |format|\n format.html { redirect_to crusts_url }\n format.json { head :no_content }\n end\n end", "def delete path\n make_request(path, \"delete\", {})\n end", "def destroy\n @couch.destroy\n respond_to do |format|\n format.html { redirect_to couches_url, notice: 'Couche was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @patchcord.destroy\n respond_to do |format|\n format.html { redirect_to patchcords_url, notice: 'Patchcord was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @central_correio = CentralCorreio.find(params[:id])\n @central_correio.destroy\n\n respond_to do |format|\n format.html { redirect_to central_correios_url }\n format.json { head :no_content }\n end\n end", "def delete(path, params = {})\n debug_log \"DELETE #{@host}#{path} params:#{params}\"\n res = connection.delete path, params\n debug_log \"Response status:#{res.status}, body:#{res.body}\"\n res\n end", "def do_delete(uri = \"\")\n @connection.delete do |req|\n req.url uri\n req.headers['Content-Type'] = 'application/json'\n end\n end", "def destroy\n @correo = Correo.find(params[:id])\n @correo.destroy\n\n respond_to do |format|\n format.html { redirect_to correos_url }\n format.json { head :no_content }\n end\n end", "def delete(options={})\n connection.delete(\"/\", @name)\n end", "def destroy\n @couch.destroy\n respond_to do |format|\n format.html { redirect_to couches_url, notice: 'Couch was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @clip.destroy\n respond_to do |format|\n format.html { redirect_to trip_path(@clip.trip.parent), change: 'list' }\n format.json { head :no_content }\n end\n end", "def delete_aos_version(args = {}) \n delete(\"/aosversions.json/#{args[:aosVersionId]}\", args)\nend", "def destroy\n # @observation = Observation.find(params[:id])\n # @observation.destroy\n\n @coral = Coral.find(params[:coral_id])\n @observation = @coral.observations.find(params[:id])\n @observation.destroy\n # redirect_to coral_path(@coral)\n \n respond_to do |format|\n format.html { redirect_to coral_path(@coral) }\n format.json { head :no_content }\n end\n end", "def destroy\n @cephalopod.destroy\n respond_to do |format|\n format.html { redirect_to cephalopods_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @aucrecord.destroy\n respond_to do |format|\n format.html { redirect_to aucrecords_url }\n format.json { head :no_content }\n end\n end", "def destroy\n client=Client.find_by_id(params[:id])\n if client != nil\n if client.destroy\n head 204\n end\n else\n head 404\n end\n end", "def delete\n render json: Company.delete(params[\"id\"])\n end", "def delete(path, params = {})\n Chirpy.request params.merge({:path => path, :method => 'delete'}.merge(authentication))\n end", "def destroy\n @coconut1.destroy\n respond_to do |format|\n format.html { redirect_to coconut1s_url, notice: 'Coconut1 was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @cso = Cso.find(params[:id])\n @cso.destroy\n\n respond_to do |format|\n format.html { redirect_to csos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @reqcargo.destroy\n respond_to do |format|\n format.html { redirect_to reqcargos_url, notice: 'Reqcargo was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @commtent1 = Commtent1.find(params[:id])\n @commtent1.destroy\n\n respond_to do |format|\n format.html { redirect_to commtent1s_url }\n format.json { head :no_content }\n end\n end", "def delete\n start { |connection| connection.request http :Delete }\n end", "def destroy\n @colegio = Colegio.find(params[:id])\n @colegio.destroy\n\n respond_to do |format|\n format.html { redirect_to colegios_url }\n format.json { head :no_content }\n end\n end", "def delete(*rest) end", "def delete(path, params)\n parse_response @client[path].delete(:params => params)\n end", "def delete(*args)\n prepare_request(:delete, args)\n @@client.add(:delete, @path, *args)\n end", "def delete(path, params)\n headers = {:Authorization => \"token #{token}\", :content_type => :json, :accept => :json}\n res = RestClient.delete(\"#{github_api_uri}/#{path}\", params.to_json, headers)\n Yajl.load(res)\n end", "def destroy\n @curso.destroy\n respond_to do |format|\n format.html { redirect_to cursos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @club_path = ClubPath.find(params[:id])\n @club_path.destroy\n\n respond_to do |format|\n format.html { redirect_to club_paths_url }\n format.json { head :no_content }\n end\n end", "def api_delete(path, data = {})\n api_request(:delete, path, :data => data)\n end", "def destroy\n @corrida.destroy\n respond_to do |format|\n format.html { redirect_to corridas_url, notice: 'Corrida eliminada correctamente.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @clonet = Clonet.find(params[:id])\n @clonet.destroy\n\n respond_to do |format|\n format.html { redirect_to clonets_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @ruby.destroy\n respond_to do |format|\n format.html { redirect_to rubies_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @correlation.destroy\n respond_to do |format|\n format.html { redirect_to correlations_url, notice: 'Correlation was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @consorciot.destroy\n respond_to do |format|\n format.html { redirect_to consorciots_url, notice: 'Consorciot was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @coche.destroy\n respond_to do |format|\n format.html { redirect_to coches_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @socio_doc_fiscais_coring.destroy\n respond_to do |format|\n format.html { redirect_to socio_doc_fiscais_corings_url }\n format.json { head :no_content }\n end\n end", "def destroy\n \n respond_to do |format|\n RestClient.delete 'localhost:3001/colores/'+@color.id.to_s, {:Authorization => 'admin irizREhyoG6Ejwr4AcjsQME9'}\n format.html { redirect_to colors_url, notice: \"Color was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @repa = Repa.find(params[:id])\n @repa.destroy\n\n respond_to do |format|\n format.html { redirect_to repas_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @repa = Repa.find(params[:id])\n @repa.destroy\n\n respond_to do |format|\n format.html { redirect_to repas_url }\n format.json { head :no_content }\n end\n end", "def delete\n url = prefix + \"delete\"\n return response(url)\n end", "def delete\n url = prefix + \"delete\"\n return response(url)\n end", "def destroy\n @orc = Orc.find(params[:id])\n @orc.destroy\n\n respond_to do |format|\n format.html { redirect_to orcs_url }\n format.json { head :ok }\n end\n end", "def destroy\n @octopus.destroy\n respond_to do |format|\n format.html { redirect_to octopi_url, notice: 'Octopus was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end", "def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end", "def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end", "def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end", "def destroy\n @retroaspecto = Retroaspecto.find(params[:id])\n @retroaspecto.destroy\n\n respond_to do |format|\n format.html { redirect_to retroaspectos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @chronicle.destroy\n respond_to do |format|\n format.html { redirect_to chronicles_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @relogio = Relogio.find(params[:id])\n @relogio.destroy\n\n respond_to do |format|\n format.html { redirect_to relogios_url }\n format.json { head :ok }\n end\n end", "def destroy\n @caso.destroy\n respond_to do |format|\n format.html { redirect_to casos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @concurso = Concurso.find(params[:id])\n @concurso.destroy\n\n respond_to do |format|\n format.html { redirect_to concursos_url }\n format.json { head :no_content }\n end\n end", "def http_delete(path, data = nil, content_type = 'application/json')\n http_methods(path, :delete, data, content_type)\n end", "def test_del\n header 'Content-Type', 'application/json'\n\n data = File.read 'sample-traces/0.json'\n post('/traces', data, 'CONTENT_TYPE': 'application/json')\n\n id = last_response.body\n\n delete \"/traces/#{id}\"\n assert last_response.ok?\n\n get \"/traces/#{id}\"\n\n contents = JSON.parse last_response.body\n assert_kind_of(Hash, contents, 'Response contents is not a hash')\n assert contents.key? 'description'\n assert(!last_response.ok?)\n end", "def destroy\n @conductor = Conductor.find(params[:id])\n @conductor.destroy\n\n respond_to do |format|\n format.html { redirect_to conductors_url }\n format.json { head :no_content }\n end\n end", "def delete\n execute_request('DELETE') do |uri, headers|\n HTTP.http_client.delete(uri, header: headers)\n end\n end", "def delete\n if body.empty? && params[:id]\n client.delete(params)\n elsif body.empty?\n client.delete_by_query(params.merge(body: body.merge(ALL)))\n else\n client.delete_by_query(params.merge(body: body))\n end\n end", "def delete(path, params = {})\n post(path, params.merge(\"_method\" => \"delete\"))\n end", "def destroy\n @coff = Coff.find(params[:id])\n @coff.destroy\n\n respond_to do |format|\n format.html { redirect_to coffs_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @circulation = Circulation.find(params[:id])\n @circulation.destroy\n\n respond_to do |format|\n format.html { redirect_to circulations_url }\n format.json { head :no_content }\n end\n end", "def orchio_delete\n response = client.send_request :delete, inst_args\n orchio_status response, 204\n end", "def cmd_delete argv\n setup argv\n uuid = @hash['uuid']\n response = @api.delete(uuid)\n msg response\n return response\n end", "def delete(splat)\n bad_request if splat.empty?\n _delete resolve_uri(splat[0])\n end", "def delete!\n Recliner.delete(uri)\n end", "def destroy\n @repuestum = Repuestum.find(params[:id])\n @repuestum.destroy\n\n respond_to do |format|\n format.html { redirect_to repuesta_url }\n format.json { head :no_content }\n end\n end", "def delete(path)\n make_call(mk_conn(path), :delete)\n end", "def destroy\n @consumo = Consumo.find(params[:id])\n @consumo.destroy\n\n respond_to do |format|\n format.html { redirect_to consumos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @copon.destroy\n respond_to do |format|\n format.html { redirect_to copons_url, notice: 'Copon was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @otg_crypst.destroy\n respond_to do |format|\n format.html { redirect_to otg_crypsts_url, notice: 'Otg crypst was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @cage.destroy\n\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def delete\n response = WebPay.client.delete(path)\n response['deleted']\n end", "def destroy\n @areco = Areco.find(params[:id])\n @areco.destroy\n\n respond_to do |format|\n format.html { redirect_to arecos_url }\n format.json { head :no_content }\n end\n end", "def delete(path)\n uri = build_uri(path)\n\n request = Net::HTTP::Delete.new(uri.request_uri)\n set_authorisation_header(request)\n\n response = https_client(uri).request(request)\n end", "def delete\n client.delete(url)\n @deleted = true\nend", "def destroy\n @convo = Convo.find(params[:id])\n @convo.destroy\n\n respond_to do |format|\n format.html { redirect_to convos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @cla.destroy\n respond_to do |format|\n format.html { redirect_to clas_path, notice: 'Test was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete(*args)\n request(:delete, *args)\n end", "def destroy\n @cont = Cont.find(params[:id])\n @cont.destroy\n\n respond_to do |format|\n format.html { redirect_to conts_url }\n format.json { head :ok }\n end\n end", "def destroy\n @reconocimiento = Reconocimiento.find(params[:id])\n @reconocimiento.destroy\n\n respond_to do |format|\n format.html { redirect_to reconocimientos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @cof.destroy\n respond_to do |format|\n format.html { redirect_to cofs_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @clasp = Clasp.find(params[:id])\n @clasp.destroy\n\n respond_to do |format|\n format.html { redirect_to clasps_url }\n format.json { head :ok }\n end\n end", "def destroy\n @respuesta = Respuesta.find(params[:id])\n @respuesta.destroy\n\n respond_to do |format|\n format.html { redirect_to respuestas_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @cuerpo = Cuerpo.find(params[:id])\n @cuerpo.destroy\n\n respond_to do |format|\n format.html { redirect_to cuerpos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @ca = Ca.find(params[:id])\n @ca.destroy\n\n respond_to do |format|\n format.html { redirect_to cas_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @projecct = Projecct.find(params[:id])\n @projecct.destroy\n\n respond_to do |format|\n format.html { redirect_to projeccts_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @doc_ponto_comer.destroy\n respond_to do |format|\n format.html { redirect_to doc_ponto_comers_url }\n format.json { head :no_content }\n end\n end" ]
[ "0.7157394", "0.6801786", "0.6619608", "0.65247077", "0.6523261", "0.6517229", "0.65159374", "0.65108764", "0.6501687", "0.6498776", "0.6487857", "0.64595914", "0.64335674", "0.64149374", "0.64125526", "0.64073616", "0.63975513", "0.6395592", "0.6394126", "0.6392911", "0.63899916", "0.6382009", "0.63794655", "0.6367198", "0.63655174", "0.63647026", "0.6360812", "0.6354232", "0.6350307", "0.6340588", "0.6340357", "0.6335602", "0.63355106", "0.63333714", "0.6318232", "0.6314552", "0.6314445", "0.6313769", "0.6302126", "0.62776136", "0.62746876", "0.6266137", "0.6262417", "0.6261527", "0.625503", "0.6250396", "0.6239149", "0.6233541", "0.6232972", "0.622672", "0.6225994", "0.6225724", "0.6225724", "0.62248755", "0.62248755", "0.6223267", "0.62221014", "0.62192833", "0.62192833", "0.62192833", "0.62192833", "0.6218106", "0.6217553", "0.62150544", "0.62128377", "0.6211758", "0.6211015", "0.62068653", "0.6206549", "0.6203821", "0.62037843", "0.6203635", "0.6202359", "0.62009764", "0.6199341", "0.61970824", "0.6191427", "0.619068", "0.6187831", "0.61867297", "0.6186532", "0.6186071", "0.6185624", "0.6184895", "0.6183916", "0.6183005", "0.61788154", "0.6176301", "0.61721206", "0.61711174", "0.6168511", "0.61668205", "0.61660635", "0.6165335", "0.6164093", "0.61620003", "0.6153091", "0.61528975", "0.61509305", "0.6149616" ]
0.6500696
9
Use callbacks to share common setup or constraints between actions.
def set_corp @corp = Corp.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_eval do\n define_method(:valid?) do |*args|\n self.class.state_machines.fire_event_attributes(self, :save, false) { super(*args) }\n end\n end\n end\n end", "def add_actions; end", "def callbacks; end", "def callbacks; end", "def setup *actions, &proc\n (@setup_procs ||= []) << [proc, actions.size > 0 ? actions : [:*]]\n end", "def define_action_helpers; end", "def post_setup\n end", "def action_methods; end", "def action_methods; end", "def action_methods; end", "def before_setup; end", "def action_run\n end", "def execute(setup)\n @action.call(setup)\n end", "def define_action_helpers?; end", "def set_actions\n actions :all\n end", "def action_done(action)\n dispatch = { :migrate => :done_migrating, :map => :done_mapping, :reduce =>\n :done_reducing, :finalize => :done_finalizing } \n self.send dispatch[action[:action]], action\n end", "def dependencies action, &block\n @actions.each do |other|\n if action[:requires].include? other[:provide]\n block.call other\n end\n end\n end", "def setup!\n return unless @setup_procs\n http_actions = actions\n @setup_procs.each do |setup_proc|\n proc, actions = setup_proc\n @setup__actions = actions.map do |action|\n\n action.is_a?(Regexp) ?\n http_actions.select { |a| a.to_s =~ action } :\n action.is_a?(String) && action =~ /\\A\\./ ?\n http_actions.map { |a| a.to_s << action if format?(a).include?(action) }.compact :\n action\n\n end.flatten\n self.class_exec &proc\n @setup__actions = nil\n end\n @setup_procs = nil\n end", "def before_actions(*logic)\n self.before_actions = logic\n end", "def setup_handler\n end", "def set_action(opts)\n opts = check_params(opts,[:actions])\n super(opts)\n end", "def setup(action)\n @targets.clear\n unless action.item.target_filters.empty?\n @targets = SES::TargetManager.make_targets(action)\n else\n item = action.item\n if item.for_opponent?\n @targets = $game_troop.alive_members\n elsif item.for_dead_friend?\n @targets = $game_party.battle_members.select { |actor| actor.dead? }\n else\n $game_party.battle_members.select { |actor| actor.alive? }\n end\n end\n @item_max = @targets.size\n create_contents\n refresh\n show\n activate\n end", "def action; end", "def action; end", "def action; end", "def action; end", "def action; end", "def workflow\n end", "def revisable_shared_setup(args, block)\n class << self\n attr_accessor :revisable_options\n end\n options = args.extract_options!\n self.revisable_options = Options.new(options, &block)\n \n self.send(:include, Common)\n self.send(:extend, Validations) unless self.revisable_options.no_validation_scoping?\n self.send(:include, WithoutScope::QuotedColumnConditions)\n end", "def setup\n @action = SampleActionAndroid.new(os_name: 'android',\n app_name: APP_PATH)\n end", "def before(action)\n invoke_callbacks *self.class.send(action).before\n end", "def process_action(...)\n send_action(...)\n end", "def before_dispatch(env); end", "def after_actions(*logic)\n self.after_actions = logic\n end", "def setup\n # override and do something appropriate\n end", "def setup(client)\n return unless @setup\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n actions.each do |action|\n action.execute(client)\n end\n self\n end", "def setup(_context)\n end", "def setup(resources) ; end", "def validate_actions\n errors.add(:base, :should_give_at_least_one_action) if !manage? && !forecasting? && !read? && !api?\n end", "def setup\n @resource_config = {\n :callbacks => {\n :before_create => nil,\n :after_create => nil,\n :before_update => nil,\n :after_update => nil,\n :before_destroy => nil,\n :after_destroy => nil,\n },\n :child_assoc => nil,\n :model => nil,\n :parent => nil,\n :path => nil,\n :permission => {},\n :properties => {},\n :relation => {\n :create => nil,\n :delete => nil,\n },\n :roles => nil,\n }\n end", "def determine_valid_action\n\n end", "def process_shared\n handle_taxes\n handle_shippings\n create_adjustments_from_params\n handle_status\n handle_inventory_refunds\n handle_payment_transactions\n order.updater.update\n end", "def startcompany(action)\n @done = true\n action.setup\n end", "def init_actions\n am = action_manager()\n am.add_action(Action.new(\"&Disable selection\") { @selection_mode = :none; unbind_key(32); bind_key(32, :scroll_forward); } )\n am.add_action(Action.new(\"&Edit Toggle\") { @edit_toggle = !@edit_toggle; $status_message.value = \"Edit toggle is #{@edit_toggle}\" })\n end", "def event_callbacks(event, metadata={})\n case event\n when :reset, :review\n if confirmed\n update_attributes(confirmed: false)\n end\n when :confirm\n confirm\n # trigger :order for all applicable items\n # NOTE: :order event is common to both physical and digital items\n items.each do |i|\n if i.event_permitted(:order)\n user_id = last_transition.user_id\n i.trigger!(:order, { order_id: id, user_id: user_id })\n end\n end\n when :complete_work\n request = metadata[:request]\n work_complete_notification(request)\n when :close\n close\n end\n if event != :close && !open\n reopen\n end\n end", "def setup_action\n return unless PONY::ERRNO::check_sequence(current_act)\n new_sequence = @action_sequence[@sequence_index+1...@action_sequence.size]\n @sequence_index = 0\n new_sequence = DND::SkillSequence::ACTS[@acts[1]] + new_sequence\n execute_sequence\n end", "def define_tasks\n define_weave_task\n connect_common_tasks\n end", "def setup(&block)\n define_method(:setup, &block)\n end", "def setup\n transition_to(:setup)\n end", "def setup\n transition_to(:setup)\n end", "def action\n end", "def setup( *args )\n\t\t\tself.class.setupBlocks.each {|sblock|\n\t\t\t\tdebugMsg \"Calling setup block method #{sblock}\"\n\t\t\t\tself.send( sblock )\n\t\t\t}\n\t\t\tsuper( *args )\n\t\tend", "def config(action, *args); end", "def setup\n @setup_proc.call(self) if @setup_proc\n end", "def before_action \n end", "def setup_callbacks\n defined_callbacks.each do |meth|\n unless respond_to?(\"call_#{meth}_callbacks\".to_sym)\n self.class.module_eval <<-EOE\n def call_#{meth}_callbacks(*args)\n plugin_store.each {|a| a.call_#{meth}_callbacks(*args) } if respond_to?(:plugin_store) && plugin_store\n self.send :#{meth}, *args if respond_to?(:#{meth})\n end\n EOE\n end\n end\n end", "def action\n end", "def matt_custom_action_begin(label); end", "def setup\n # override this if needed\n end", "def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend", "def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend", "def action(options,&callback)\n new_action = Action===options ? options : Action.new(options,&callback)\n # replace any with (shared name/alias or both default) + same arity\n @actions.delete_if do |existing_action|\n ((existing_action.names & new_action.names).size > 0 ||\n existing_action.default? && new_action.default?) &&\n existing_action.required.size == new_action.required.size &&\n existing_action.optional.size <= new_action.optional.size\n end\n @actions = (@actions + [new_action]).sort\n new_action\n end", "def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action\n end", "def after(action)\n invoke_callbacks *options_for(action).after\n end", "def pre_task\n end", "def setup(server)\n server.on('beforeMethod', method(:before_method), 10)\n end", "def add_actions\n attribute = machine.attribute\n name = self.name\n \n owner_class.class_eval do\n define_method(name) {self.class.state_machines[attribute].events[name].fire(self)}\n define_method(\"#{name}!\") {self.class.state_machines[attribute].events[name].fire!(self)}\n define_method(\"can_#{name}?\") {self.class.state_machines[attribute].events[name].can_fire?(self)}\n end\n end", "def init_actions\n @select_action = SelectAction.new\n @endpoint_mouse_action = EndpointMouseAction.new\n @move_action = MoveAction.new\n end", "def setup_signals; end", "def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend", "def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend", "def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action.respond_to?('weak!') ? action.weak! : action\n end", "def initialize(*args)\n super\n @action = :set\nend", "def after_set_callback; end", "def setup\n #implement in subclass;\n end", "def lookup_action; end", "def setup &block\n if block_given?\n @setup = block\n else\n @setup.call\n end\n end", "def setup_action\n return TSBS.error(@acts[0], 1, @used_sequence) if @acts.size < 2\n actions = TSBS::AnimLoop[@acts[1]]\n if actions.nil?\n show_action_error(@acts[1])\n end\n @sequence_stack.push(@acts[1])\n @used_sequence = @acts[1]\n actions.each do |acts|\n @acts = acts\n execute_sequence\n break if @break_action\n end\n @sequence_stack.pop\n @used_sequence = @sequence_stack[-1]\n end", "def release_actions; end", "def around_hooks; end", "def save_action; end", "def setup(easy)\n super\n easy.customrequest = @verb\n end", "def action_target()\n \n end", "def setup\n callback(:setup) do\n notify(:setup)\n migration_check.last_deployed_commit\n end\n end", "def setup\n return unless @setup\n\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n run_actions_and_retry(actions)\n self\n end", "def before_setup\n # do nothing by default\n end", "def my_actions(options)\n @setup = false\n get_template_part(\"custom_used\",\"action_users\",true)\n end", "def default_action; end", "def setup(&blk)\n @setup_block = blk\n end", "def callback_phase\n super\n end", "def advice\n end", "def _handle_action_missing(*args); end", "def duas1(action)\n action.call\n action.call\nend", "def shared_action(name, &block)\n @controller.shared_actions[name] = block\n end", "def before_action action, &block\n @audience[:before][action] ||= Set.new\n @audience[:before][action] << block\n end", "def setup_initial_state\n\n state_a = State.new(\"a\", 0)\n state_b = State.new(\"b\", 0)\n state_c = State.new(\"c\", 10)\n\n move_to_b = Action.new(\"move_to_b\", 1, state_b)\n\n move_to_c = Action.new(\"move_to_c\", 1, state_c)\n\n state_a.actions = [move_to_b, move_to_c]\n\n return state_a\n \nend" ]
[ "0.6163163", "0.6045976", "0.5946146", "0.591683", "0.5890051", "0.58349305", "0.5776858", "0.5703237", "0.5703237", "0.5652805", "0.5621621", "0.54210985", "0.5411113", "0.5411113", "0.5411113", "0.5391541", "0.53794575", "0.5357573", "0.53402257", "0.53394014", "0.53321576", "0.53124547", "0.529654", "0.5296262", "0.52952296", "0.52600986", "0.52442724", "0.52385926", "0.52385926", "0.52385926", "0.52385926", "0.52385926", "0.5232394", "0.523231", "0.5227454", "0.52226824", "0.52201617", "0.5212327", "0.52079266", "0.52050185", "0.51754695", "0.51726824", "0.51710224", "0.5166172", "0.5159343", "0.51578903", "0.51522785", "0.5152022", "0.51518047", "0.51456624", "0.51398855", "0.5133759", "0.5112076", "0.5111866", "0.5111866", "0.5110294", "0.5106169", "0.509231", "0.50873137", "0.5081088", "0.508059", "0.50677156", "0.50562143", "0.5050554", "0.50474834", "0.50474834", "0.5036181", "0.5026331", "0.5022976", "0.5015441", "0.50121695", "0.5000944", "0.5000019", "0.4996878", "0.4989888", "0.4989888", "0.49864885", "0.49797225", "0.49785787", "0.4976161", "0.49683493", "0.4965126", "0.4958034", "0.49559742", "0.4954353", "0.49535993", "0.4952725", "0.49467874", "0.49423352", "0.49325448", "0.49282882", "0.49269363", "0.49269104", "0.49252945", "0.4923091", "0.49194667", "0.49174926", "0.49173003", "0.49171105", "0.4915879", "0.49155936" ]
0.0
-1
Only allow a list of trusted parameters through.
def corp_params params.require(:corp).permit(:corp) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def allowed_params\n ALLOWED_PARAMS\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def parameters_list_params\n params.require(:parameters_list).permit(:name, :description, :is_user_specific)\n end", "def param_whitelist\n [:role, :title]\n end", "def param_whitelist\n whitelist = [\n :username, :name,\n :parent_id,\n :headline, :description, :video,\n :policy, :signup_mode, :category,\n :website, :facebook, :twitter, :linkedin,\n :founded_at,\n privacy: [\n :events,\n :resources\n ],\n permission: [\n :profile,\n :members,\n :children,\n :statistics,\n :posts,\n :listings,\n :resources,\n :events\n ],\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:parent_id)\n unless current_user.role_in(@community) === 'owner'\n whitelist.delete(:privacy)\n whitelist.delete(:permission)\n end\n end\n \n whitelist\n end", "def strong_params\n params.require(:user).permit(param_whitelist)\n end", "def param_whitelist\n if @user.present? && current_user != @user\n return [:followed]\n end\n \n whitelist = [\n :username, :email, :password,\n :first_name, :last_name,\n :birthday, :gender,\n :headline, :biography, :ask_about, :focus,\n :website, :facebook, :linkedin, :twitter, :github,\n roles: [],\n skills: [],\n interests: [],\n privacy: { contact: [] },\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:email)\n whitelist.delete(:password)\n end\n \n whitelist\n end", "def allow_params_authentication!; end", "def whitelisted_args\n args.select &:allowed\n end", "def safe_list_sanitizer; end", "def safe_list_sanitizer; end", "def safe_list_sanitizer; end", "def filtered_parameters; end", "def sanitize_params_for user, params, allowed_params\n params.each do |key, val|\n #if allowed_params.include?(key)\n #sanitize!(user, params, key) if key =~ /_attributes|_ids$/\n #else\n #params.delete(key)\n #end\n params.delete(key) unless allowed_params.include?(key.to_sym)\n end\n end", "def strong_params\n params.require(:team_member).permit(param_whitelist)\n end", "def expected_permitted_parameter_names; end", "def sanitize_parameters!(sanitizer, params)\n # replace :readwrite with :onlyif\n if params.has_key?(:readwrite)\n warn \":readwrite is deprecated. Replacing with :onlyif\"\n params[:onlyif] = params.delete(:readwrite)\n end\n\n # add default parameters\n bindata_default_parameters.each do |k,v|\n params[k] = v unless params.has_key?(k)\n end\n\n # ensure mandatory parameters exist\n bindata_mandatory_parameters.each do |prm|\n if not params.has_key?(prm)\n raise ArgumentError, \"parameter ':#{prm}' must be specified \" +\n \"in #{self}\"\n end\n end\n\n # ensure mutual exclusion\n bindata_mutually_exclusive_parameters.each do |param1, param2|\n if params.has_key?(param1) and params.has_key?(param2)\n raise ArgumentError, \"params #{param1} and #{param2} \" +\n \"are mutually exclusive\"\n end\n end\n end", "def strong_params\n params.require(:education).permit(param_whitelist)\n end", "def safe_list_sanitizer=(_arg0); end", "def safe_list_sanitizer=(_arg0); end", "def safe_list_sanitizer=(_arg0); end", "def safe_params\n resurce_name = self.class.resource_name\n params_method_name = \"#{resurce_name}_params\".to_sym\n if params[resurce_name]\n if respond_to?(params_method_name) || private_methods.include?(params_method_name)\n send(params_method_name)\n else\n raise ActiveModel::ForbiddenAttributesError, \"Please, define the '#{params_method_name}' method in #{self.class.name}\"\n end\n end\n end", "def param_whitelist\n [:rating, :review]\n end", "def check_params; true; end", "def strong_params\n params.require(:experience).permit(param_whitelist)\n end", "def validate_search_inputs\n @whitelisted = params.fetch(:user, nil)\n if @whitelisted.blank?\n render_error(400, \"#{I18n.t('general_error.params_missing_key')}\": [I18n.t('general_error.params_missing_value', model: \"review\")])\n return\n else\n @whitelisted = @whitelisted.permit(:name, :uen, :description)\n end\n end", "def allowed?(*_)\n true\n end", "def param_whitelist\n [\n :title,\n :description,\n :organization,\n :team_id,\n :started_at,\n :finished_at,\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n end", "def secure_params\n return @secure_params if @secure_params\n\n defn = implementation_class.definition\n field_list = [:master_id] + defn.field_list_array\n\n res = params.require(controller_name.singularize.to_sym).permit(field_list)\n res[implementation_class.external_id_attribute.to_sym] = nil if implementation_class.allow_to_generate_ids?\n @secure_params = res\n end", "def allowed_params(parameters)\n parameters.select do |name, values|\n values.location != \"path\"\n end\n end", "def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end", "def permitir_parametros\n \t\tparams.permit!\n \tend", "def strong_params\n params.require(:community).permit(param_whitelist)\n end", "def permit( params, whitelist, name = nil )\n raise 'Parametrization not yet configured' unless @configured\n whitelist ||= []\n px = params.respond_to?( :permit ) ? params : ActionController::Parameters.new( params )\n px = dig(px, name)\n px.permit( *whitelist )\n end", "def valid_params?; end", "def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end", "def url_allowlist=(_arg0); end", "def param_whitelist\n whitelist = [\n :description,\n :progress,\n :kpi_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:kpi_id)\n end\n \n whitelist\n end", "def restricted_params\n #params.require(self.controller_name.classify.underscore.to_sym).permit([])\n raise(\"No strong params set, override restricted_params method in your controller. E.g. params.require(:model).permit(:attribute1, :attribute2)\")\n end", "def list_params\n params.permit(:list_name)\n end", "def valid_params_request?; end", "def safe_params\n params.permit(:id, :name, :origin, :emails => []); #emails is an array\n end", "def param_list(param_type, name, type, required, description = nil, allowed_values = [], hash = {})\n hash.merge!({allowable_values: {value_type: \"LIST\", values: allowed_values}})\n param(param_type, name, type, required, description, hash)\n end", "def safelists; end", "def authorize_own_lists\n authorize_lists current_user.lists\n end", "def listed_params\n params.permit(:listed, :list_id, :listable_id, :listable_type, :campsite_id)\n end", "def lists_params\n params.require(:list).permit(:name)\n\n end", "def list_params\n params.require(:list).permit(:name, :user_id)\n end", "def list_params\n params.require(:list).permit(:name, :description, :type, :privacy, :allow_edit, :rating, :votes_count, :user_id)\n end", "def check_params\n true\n end", "def authorize_own_or_shared_lists\n authorize_lists current_user.all_lists\n end", "def user_pref_list_params\n\t\tparams.require(:user).permit(:preference_list)\n\tend", "def may_contain!(*keys)\n self.allow_only_permitted = true\n self.permitted_keys = [*permitted_keys, *keys].uniq\n end", "def filter_parameters; end", "def filter_parameters; end", "def whitelist; end", "def article_params_whitelist\n params.require(:article).permit(:title, :description, category_ids: [])\n end", "def list_params\n params.require(:list).permit(:name)\n end", "def list_params\n params.permit(:name)\n end", "def recipient_list_params\n params.require(:recipient_list).permit(:name, :list, :references)\n end", "def cancan_parameter_sanitizer\n resource = controller_name.singularize.to_sym\n method = \"#{resource}_params\"\n params[resource] &&= send(method) if respond_to?(method, true)\n end", "def whitelist_place_params\n params.require(:place).permit(:place_name, :unlock, :auth, :is_deep_checked, :parent_ADM4, :parent_ADM3, :parent_ADM2, :parent_ADM1, :parent_country, feature_code: [], same_as: [], related_authority: [], altlabel: [], note: []) # Note - arrays need to go at the end or an error occurs!\n end", "def list_params\n params.require(:list).permit(:name).merge(user_id: current_user.id)\n end", "def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end", "def list_params\n params.fetch(:list, {}).permit(:user_id, :name, :active)\n end", "def secure_params(require_param, permit_keys)\n params.require(require_param).permit(*permit_keys)\n end", "def grant_params\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\n end", "def permitted_params\n []\n end", "def price_list_params\n params.fetch(:price_list, {}).permit(:name, :valid_from, :valid_to, :active,\n :all_warehouses, :all_users, :all_contact_groups,\n warehouse_ids: [], price_lists_user_ids: [], contact_group_ids: [])\n end", "def admin_review_params\n params.fetch(:review, {}).permit(whitelisted_params)\n end", "def params(list)\n @declared_params = list\n end", "def saved_list_params\n params.require(:saved_list).permit(:user_id)\n end", "def allow(ids); end", "def list_params\n params.require(:list).permit(:name)\n end", "def list_params\n params.require(:list).permit(:name)\n end", "def list_params\n params.require(:list).permit(:name)\n end", "def filter_params(param_set, **kwargs)\r\n begin\r\n key = kwargs[:key]\r\n params.require(key).permit(*param_set)\r\n rescue Exception\r\n params.permit(*param_set)\r\n end\r\n end", "def valid_parameters\n sort_symbols(@interface.allowed_parameters)\n end", "def validate_paramified_params\n self.class.paramify_methods.each do |method|\n params = send(method)\n transfer_errors_from(params, TermMapper.scope(params.group)) if !params.valid?\n end\n end", "def secure_params\n return @secure_params if @secure_params\n\n @implementation_class = implementation_class\n resname = @implementation_class.name.ns_underscore.gsub('__', '_').singularize.to_sym\n @secure_params = params.require(resname).permit(*permitted_params)\n end", "def list_params\n params.require(:list).permit(:name)\n end", "def refine_permitted_params(param_list)\n res = param_list.dup\n\n ms_keys = res.select { |a| columns_hash[a.to_s]&.array }\n ms_keys.each do |k|\n res.delete(k)\n res << { k => [] }\n end\n\n res\n end", "def recipient_list_params\n params.require(:recipient_list).permit(:name, :description, recipient_id_array: [])\n end", "def sponsor_params\n params.require(:sponsor).permit(WHITE_LIST)\n end", "def safelist; end", "def valid_for_params_auth?; end", "def default_param_whitelist\n [\"mode\"]\n end", "def devise_filter\r\n logger.debug(\"In devise_filter =>PARAMS: #{params.inspect}\")\r\n\r\n # White list for sign_up\r\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(user_whitelist) }\r\n\r\n # White list for account update\r\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(user_whitelist, :current_password) }\r\n\r\n # White list for Invitation creation\r\n devise_parameter_sanitizer.for(:invite) { |u| u.permit(:account_type, :email, :invitation_token)}\r\n\r\n # White list for accept invitation\r\n devise_parameter_sanitizer.for(:accept_invitation) { |u| u.permit(user_whitelist, :invitation_token)}\r\n\r\n end", "def shopping_list_params\n params.require(:shopping_list).permit!\n end", "def permitted_params\n declared(params, include_missing: false)\n end", "def permitted_params\n declared(params, include_missing: false)\n end", "def safe_params\n params.except(:host, :port, :protocol).permit!\n end", "def permitters\n @_parametrizr_permitters || {}\n end", "def allow_params(action, keys: nil, except: nil, &blk)\n keys &&= Array.wrap(keys)\n keys ||= User.field_names\n except &&= Array.wrap(except)\n except ||= %i[id email]\n devise_parameter_sanitizer.permit(action, keys: keys, except: except, &blk)\n end", "def list_params\n if current_user && current_user.role == 'admin'\n params.require(:list).permit(:name, :url, :description, :user_id,\n ideas_attributes: [:id, :list_id, :body, :due_date, :completion_status, :_destroy])\n else\n params.require(:list).permit(:name, :description,\n ideas_attributes: [:body, :due_date, :completion_status]) \n end\n end", "def whitelist(params)\n send_request_of_type(GlobalConstant::PrivateOpsApi.private_ops_api_type, 'post', '/token-sale/whitelist', params)\n end", "def valid_access_params\n params.require(:valid_access).permit(:wish_list_id, :user_id)\n end", "def ensure_redirected_params_are_safe!(passed_params)\n unless passed_params.is_a?(ActionController::Parameters) && passed_params.permitted?\n error_message = if passed_params.is_a?(ActionController::Parameters)\n unsafe_parameters = passed_params.send(:unpermitted_keys, params)\n \"[Rails::Prg] Error - Must use permitted strong parameters. Unsafe: #{unsafe_parameters.join(', ')}\"\n else\n \"[Rails::Prg] Error - Must pass strong parameters.\"\n end\n raise error_message\n end\n end", "def url_allowlist; end", "def data_collection_params\n allow = [:name,:description,:institution,:collection_name,:country_id,:province_id,:city_id]\n params.require(:data_collection).permit(allow)\n end", "def quote_params\n params.permit!\n end" ]
[ "0.6950644", "0.68134046", "0.68034387", "0.6796522", "0.674668", "0.6742105", "0.6527854", "0.65214247", "0.6491907", "0.64294493", "0.64294493", "0.64294493", "0.64004904", "0.6356768", "0.63556653", "0.6348119", "0.6344521", "0.63386923", "0.632588", "0.632588", "0.632588", "0.6315317", "0.6300307", "0.6266357", "0.62616897", "0.62586933", "0.623662", "0.6228699", "0.6222646", "0.6221808", "0.62095183", "0.6200624", "0.6197454", "0.61747247", "0.6158626", "0.61565846", "0.6152596", "0.6137625", "0.6123762", "0.61105245", "0.6076312", "0.6071771", "0.60621834", "0.60548234", "0.6044156", "0.603494", "0.6019818", "0.60173535", "0.60154593", "0.60121197", "0.6008601", "0.6008049", "0.60078037", "0.60059106", "0.60059106", "0.5997147", "0.599462", "0.59918606", "0.5984179", "0.59706646", "0.59698576", "0.5966363", "0.5965114", "0.59620297", "0.5961917", "0.59358233", "0.5929989", "0.59241587", "0.59088653", "0.59052056", "0.59033877", "0.58932143", "0.58890563", "0.5880874", "0.5880874", "0.5880874", "0.58739555", "0.5863163", "0.585503", "0.5845768", "0.58438927", "0.58353096", "0.583153", "0.58292353", "0.58277905", "0.58186984", "0.58164775", "0.581428", "0.58108085", "0.5805045", "0.5805045", "0.58009875", "0.5796557", "0.5785622", "0.57814676", "0.5777818", "0.577579", "0.57690275", "0.5768062", "0.57632935", "0.57591033" ]
0.0
-1
access the type of the medal type is a sring and wight an integer
def initialize(type, weight) @type = type @weight = weight end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def type\n munson.type\n end", "def sti_type\n self.type\n end", "def mediatype; end", "def presentation_unit_type_measure\n packing_material.presentation_unit_type_measure\n end", "def type\n return :basic if @is_basic\n return :platinum if @is_platinum\n return :centurion if @is_centurion\n return :premium if @is_premium\n :unknown\n end", "def type_code \n 4\n end", "def presentation_unit_type_measurement\n packing_material.presentation_unit_type_measurement\n end", "def type\n if rank_test(0) && rank_test(2)\n :mutually_assured_destruction\n elsif rank_test(0)\n :war\n else\n :basic\n end\n end", "def weams_type\n { \n 'ojt' => ojt?, 'correspondence' => correspondence?, 'flight' => flight?,\n 'foreign' => foreign?, 'public' => public?, 'for profit' => for_profit?,\n 'private' => private?\n }.find { |key, value| value }[0]\n end", "def claim_type_weight\n is_industry_code_configured = facility.industry_code_configured?\n remark_codes = []\n rcc = ReasonCodeCrosswalk.new(payer, nil, client, facility)\n if claim_level_eob?\n crosswalked_codes = rcc.get_all_codes_for_entity(eob, true)\n remark_codes << crosswalked_codes[:remark_codes]\n else\n service_lines = eob.service_payment_eobs\n if !service_lines.blank?\n service_lines.each do |svc_line|\n crosswalked_codes = rcc.get_all_codes_for_entity(svc_line, true)\n remark_codes << crosswalked_codes[:remark_codes]\n remark_codes << svc_line.get_remark_codes\n end\n end \n end\n remark_codes = remark_codes.flatten.compact.uniq\n condition_to_print_claim_type_19 = is_industry_code_configured && !remark_codes.blank? &&\n eob.check_validity_of_ansi_code(remark_codes)\n if condition_to_print_claim_type_19\n Output835.log.info \"claim type is 19\"\n 19\n else\n eob.claim_type_weight\n end\n end", "def type\n\t\t@type\n\tend", "def type() end", "def get_shower_type\n self.shower_type ? self.shower_type.i18n_description : '?'\n end", "def get_type\n\n end", "def type\n read_attribute(:type) || Figaro.env.meal_types.split.first\n end", "def subtype\n self.numeric_type\n end", "def subtype\n self.numeric_type\n end", "def type\n self['TYPE'].to_i\n end", "def get_movie_type( the_type_num )\n @typeInfos = TypeInfo.all\n @typeInfos.each{ |type_info|\n if type_info.type_id === the_type_num\n type_info.type_name\n end\n }\n end", "def determine_kind(int)\n if int == 3\n return :equilateral\n elsif int == 2\n return :isosceles\n else\n return :scalene\n end\n end", "def describe_type\n puts \"I am a #{type} of Bees Wax\"\n end", "def fuel_type; end", "def getType(t)\n\n #type 0 = {1}\n #type 1 = {2-4}\n #type 2 = {5-20}\n \n if (t>10) \n t = t%100\n end\n \n if ((t>10) && (t<20)) \n return 2\n else\n t = t%10\n if (t == 1)\n return 0\n elsif ((t >= 2) && (t <=4))\n return 1\n else\n return 2\n end\n end\nend", "def nonregular_type; end", "def get_typePont\n return @typePont\n end", "def math_type\n self\n end", "def type\n return @type if @type != \"unknown\"\n info\n @type\n end", "def human_type\n SHIPPING_TYPES[self[:type].to_i]\n end", "def type\n @type\n end", "def type\n return @type\n end", "def type\n\t\t\t@data[\"type\"]\n\t\tend", "def type\n @type\n end", "def bike_type(type)\n if type == 1\n @discipline = \"mountain\"\n @frame = \"mountain\"\n elsif type == 2\n @discipline = \"road\"\n @frame = \"road\"\n else\n @discipline = \"cyclo-cross\"\n @frame = \"cyclo-cross\"\n end\n @discipline\n @frame\n end", "def get_style(type, id)\n if Weapon_style_by_attribute == true\n # BY ATTRIBUTE\n if type == 0\n item = $data_weapons[id]\n if item.element_set.include?(17)\n #this element means it requires the ability to wield swords\n return 'Sword'\n end\n if item.element_set.include?(18)\n #this element means it requires the ability to wield staffs\n return 'Staff'\n end\n \n end\n if type == 1\n item = $data_armors[id]\n if item.element_set.include?(17)\n #you can re-use elements for armour for example this can mean shield when tagged on armour\n return 'Shield'\n end\n if item.element_set.include?(19)\n #or to avoid confusion you can use differant ones\n return 'Armour'\n end\n end\n return nil\n else\n # BY ID\n if type == 0\n case id\n when 1\n return 'Sword'\n when 29\n return 'Staff' \n end\n end\n if type == 1\n case id\n when 1\n return 'Shield'\n end\n end\n return nil\n end\n end", "def yale?; return stype == :yale; end", "def type\n self['type']['type']\n end", "def material_type\n attributes['material_type']\n end", "def material_type\n attributes['material_type']\n end", "def get_type\n case self[:type]\n when /pe/\n :pe\n else\n :foss\n end\n end", "def types; end", "def types; end", "def types; end", "def types; end", "def types; end", "def o_type\n 2 #type for Answers\n end", "def get_metal_value(metal)\t\n\ts, g, i = get_single_value \n\tif (metal == \"Silver\")\n\t\treturn s\n\telsif (metal == \"Gold\")\n\t\treturn g\n\telsif (metal == \"Iron\")\n\t\treturn i\n\telse\n\t\tretun nil\n\tend\nend", "def type\n rank.first\n end", "def type\n @data['type']\n end", "def determine_word_of_god(god_data)\n\tcase god_data\n\twhen 1\n\t\t:yes\n\twhen 2\n\t\t:no\n\telse\n\t\t:unknown\n\tend\nend", "def snap_type=(i); typecast i; end", "def o_type\n 8 \n end", "def type(type); end", "def get_hair_dryer_type\n self.hair_dryer_type ? self.hair_dryer_type.i18n_description : '?'\n end", "def type_code\n type.try(:code)\n end", "def rdmg\n wpn = Speacial_Status['Weapon']\n return wpn[@id] != nil && wpn[@id]['rdmg'] != nil ? wpn[@id]['rdmg'] : 0\n end", "def nature; end", "def medical_use; end", "def get_type(value) #method\n if value == 'verdadero'\n true\n elsif value == 'falso'\n false\n elsif value.include? '.'\n value.to_f\n elsif value.scan(/\\D/).empty?\n value.to_i\n else\n value\n end\n end", "def my_type(type)\n case type\n when /bond/i\n \"Bonds\"\n when /stock/i\n \"Stocks\"\n when /alternative/i\n \"Alternatives\"\n else\n \"Unclassified\"\n end\n end", "def type; end", "def type; end", "def type; end", "def type; end", "def type; end", "def type; end", "def type; end", "def type; end", "def type; end", "def type; end", "def type; end", "def type; end", "def type; end", "def type; end", "def type; end", "def type; end", "def type; end", "def type; end", "def type; end", "def type; end", "def type; end", "def type; end", "def type; end", "def type; end", "def type; end", "def type; end", "def type; end", "def type; end", "def type; end", "def type; end", "def type; end", "def type; end", "def type; end", "def type; end", "def type; end", "def type; end", "def type; end", "def type; end", "def type; end", "def type; end", "def type; end", "def type; end" ]
[ "0.6272783", "0.6235713", "0.6224735", "0.62182754", "0.60074526", "0.5930462", "0.5904124", "0.58993685", "0.58853763", "0.577737", "0.57766974", "0.57642645", "0.57618296", "0.57510227", "0.57187635", "0.57038856", "0.57038856", "0.5679324", "0.5636631", "0.56254756", "0.5623497", "0.56204575", "0.5615394", "0.5607777", "0.5603788", "0.5586953", "0.5585643", "0.5583652", "0.5566786", "0.5553791", "0.5545734", "0.554534", "0.55358857", "0.5534523", "0.55288774", "0.55237305", "0.55219114", "0.55219114", "0.5515763", "0.5510737", "0.5510737", "0.5510737", "0.5510737", "0.5510737", "0.5510376", "0.5505197", "0.5491266", "0.54854745", "0.5472428", "0.5464664", "0.54627013", "0.5461063", "0.5458013", "0.5451814", "0.54481035", "0.54470074", "0.5438233", "0.5432847", "0.54310566", "0.54305536", "0.54305536", "0.54305536", "0.54305536", "0.54305536", "0.54305536", "0.54305536", "0.54305536", "0.54305536", "0.54305536", "0.54305536", "0.54305536", "0.54305536", "0.54305536", "0.54305536", "0.54305536", "0.54305536", "0.54305536", "0.54305536", "0.54305536", "0.54305536", "0.54305536", "0.54305536", "0.54305536", "0.54305536", "0.54305536", "0.54305536", "0.54305536", "0.54305536", "0.54305536", "0.54305536", "0.54305536", "0.54305536", "0.54305536", "0.54305536", "0.54305536", "0.54305536", "0.54305536", "0.54305536", "0.54305536", "0.54305536", "0.54305536" ]
0.0
-1
GET /urls/1 GET /urls/1.json
def show if params[:short_url] @url = Url.find_by short_url: params[:short_url] if redirect_to "#{@url.original_url}" @url.clicks += 1 ip = request.env['HTTP_X_FORWARDED_FOR'] || request.remote_ip if !@url.ip_addresses.include? ip @url.ip_addresses.push(ip) end @url.save end else @base_url = "#{request.protocol}#{request.host_with_port}/" @url = Url.find(params[:id]) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @urls = Url.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @urls }\n end\n end", "def index\n @urls = ShortenedUrl.order(\"updated_at ASC\").all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @urls }\n end\n end", "def show\n @url = Url.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @url }\n end\n end", "def get(url); end", "def index\n @urls = Url.get_top(25)\n # render json: @urls\n end", "def show\n\t\trender json: @url, status: 200\n\tend", "def show\n render json: @url\n end", "def json_get(url)\n get url, :parse=>true\n end", "def url_list\n urls = current_user.mini_urls\n if urls.count > 0\n render json: {urls: urls}, status: 200\n else\n raise Exceptions::EmptyObjectError.new('No URL found.')\n end\n rescue Exceptions::EmptyObjectError => e\n render json: {error: e}, status: 404\n end", "def show\n\t\t@url = UrlGenerator.find_by(encoded_url:params[:id])\n\t\tif @url.nil?\n\t\t\trender json:{error:\"not found\"}\n\t\telse\n\t\t\trender json:{orginal_url:@url.url}\n\t\tend\n\tend", "def index\n @urls = @site.urls.paginate(:page => params[:page])\n render json: @urls\n end", "def json_at(url)\n JSON.parse(open(url).read, symbolize_names: true)[:objects]\nend", "def getUrl(url)\n puts url if @options[\"show-url\"]\n RestClient.get(url)\n end", "def index\n render json: {\n status: :success,\n urls: ShortUrl::top_100\n }\n end", "def rest_get(url)\n JSON.parse(RestClient.get(url))\n end", "def all\n render json: Url.all\n end", "def fetch_json_from_url(url_of_search)\n Net::HTTP.get(URI.parse(url_of_search))\n end", "def get(url)\n call(url: url)\n end", "def get_json( url )\n JSON.parse( get_url( url ){ |f| f.read } )\nend", "def api_fetch(url)\n JSON.parse(RestClient.get url)\nend", "def showJSON\n\n\t\trender json: UrlDataModel.find(params[:id])\n\n\tend", "def index\n @urls = Url.all\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render xml: @urls}\n format.json { render json: @urls }\n end\n end", "def show\n @url = ShortenedUrl.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @url }\n end\n end", "def show\n @sampled_url = SampledUrl.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @sampled_url }\n end\n end", "def getJson(url)\r\n request_uri = url\r\n request_query = ''\r\n url = \"#{request_uri}#{request_query}\"\r\n result = getJsonFromUrl(url)\r\n return result\r\nend", "def api_fetch(url)\n JSON.parse(URI.open(url).read)\nend", "def readJSONFromUrl(url)\n # use GET request to retrieve the json\n uri = URI(url)\n response = Net::HTTP.get(uri)\n json = JSON.parse(response)\n return json\nend", "def get_json(url)\n @response = RestClient.get url\n while @response.nil? do\n if @response.code == 200\n @response = RestClient.get url\n end\n end\n @json_file = JSON.parse(@response)\n end", "def get_json_url(url) \n useragent = \"NotubeMiniCrawler/0.1\"\n u = URI.parse url\n\n req = Net::HTTP::Get.new(u.request_uri,{'User-Agent' => useragent})\n\n begin\n\n res = Net::HTTP.new(u.host, u.port).start {|http|http.request(req) }\n\n end\n j = nil\n begin\n j = JSON.parse(res.body)\n rescue OpenURI::HTTPError=>e\n case e.to_s\n when /^404/\n raise 'Not Found'\n when /^304/\n raise 'No Info'\n end\n end\n return j\n end", "def url_hash(url)\n response_string = RestClient.get(url)\n JSON.parse(response_string)\nend", "def get_json(path)\n puts \"*** GET #{path}\"\n\n response = Net::HTTP.get_response(build_uri(path))\n result = JSON.parse(response.body)\n puts \"HTTP #{response.code}\"\n\n puts JSON.pretty_generate(result)\n result\nend", "def get_urls( search_url )\n urls = []\n result_json = parse_json( search_url )\n result_json['items'].each do |item|\n urls << item['url']\n end\n\n return urls\nend", "def index\n render json: @links\n end", "def getJson(url)\n\t\tencoded_url = URI.encode(\"https://cryptic-mountain-56365.herokuapp.com/api/v1\"+url)\n\t\turi = URI.parse(encoded_url)\n\t\tjson = Net::HTTP.get(uri)\n\tend", "def show\n @crawl_request = CrawlRequest.includes(:urls).find(params[:id])\n\n render json: @crawl_request, :include => :urls\n end", "def get_json(path)\n puts \"*** GET #{path}\"\n\n response = Net::HTTP.get_response(build_uri(path))\n result = JSON.parse(response.body)\n puts \"HTTP #{response.code}\"\n\n #puts JSON.pretty_generate(result)\n result\nend", "def get_json(path)\n puts \"*** GET #{path}\"\n\n response = Net::HTTP.get_response(build_uri(path))\n result = JSON.parse(response.body)\n puts \"HTTP #{response.code}\"\n\n #puts JSON.pretty_generate(result)\n result\nend", "def index\n @urls = Url.all\n end", "def index\n @urls = Url.all\n end", "def get_json(path)\n response = Net::HTTP.get_response(build_uri(path))\n result = JSON.parse(response.body)\n #puts \"🤖 GET #{path}\"\n #puts \"HTTP #{response.code}\"\n #puts JSON.pretty_generate(result)\n result\nend", "def get(url, headers = {})\n http :get, \"#{url}.json\", headers\n end", "def get_json(url, args = {})\n response = adapter.get(url, args) do |req|\n req.headers['Content-Type'] = 'application/json'\n req.headers['Accept'] = 'application/json'\n end\n body = response.body\n JSON.parse(body)\n end", "def get_tags_by_url\n url = Url.find_by(id: params[:id])\n tags = url.tags\n render json: {code: 200, tags: tags}\n end", "def index\n respond_to do |format|\n format.html { redirect_to root_path }\n format.json { @url_shorts = UrlShort.all }\n end\n end", "def serv_json\n \"http://api.dribbble.com/shots/popular?page=1\"\n end", "def get_inf(url)\n\turi = URI.parse(url)\n\tresponse = Net::HTTP.get_response(uri)\n\tJSON.parse(response.body)\nend", "def show\n @url_connector = UrlConnector.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @url_connector }\n end\n end", "def get(url)\n self.class.get(url)\n end", "def url\n response[\"url\"]\n end", "def get(url)\n request(:get, url, {}, nil)\n end", "def index\n @url_connectors = UrlConnector.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @url_connectors }\n end\n end", "def index\n @crawl_requests = CrawlRequest.includes(:urls)\n\n render json: @crawl_requests, :include => :urls\n end", "def get_url(url)\n myurl = URI.parse(url)\n req = Net::HTTP::Get.new(url)\n res = Net::HTTP.start(myurl.host, myurl.port) { |http|\n http.request(req)\n }\n \n res.body # return\n end", "def json_url\n \"#{REDDIT_URL_PREFIX}#{permalink}.json\"\n end", "def realtime\n render :json=>WebUrl.all.map(&:url).to_json\n end", "def get(url)\n raise \"Needs to be implemented\"\n end", "def get_json(url)\n r = RestClient.get url, request_options\n JSON.parse(r)\n end", "def index\n @content_urls = ContentUrl.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @content_urls }\n end\n end", "def handle_links(json) end", "def api_get url_suffix\n url = URI::encode \"#{@@oauth_info[:api_url]}/gems/#{url_suffix}\"\n data = {:client_id => @@oauth_info[:client_id]}\n headers = {:Authorization => \"Bearer #{@access_token}\"}\n\n conn = get_conn url\n #Try request 3 times\n for i in 1..3\n res = conn.get(url, data, headers)\n if res.status == 200 then return JSON.parse(res.body) end\n sleep 1\n end\n raise OAuthSessionError, \"GET Failed. Status: #{res.status}. Body: #{res.body}\"\n end", "def get url\n url = URI url\n request = HTTP::Get.new url.path\n\n dispatch request, to: url\n end", "def show url\n function = ''\n \n params = {}\n params[:url] = url\n\n request(@resource, function, params)\n end", "def look_up(url)\n all = RestClient.get(url)\n hash = JSON.parse(all)\nend", "def get_json(url)\n JSON.parse(get(url, :json, :json))\n end", "def show\n @base_url = BaseUrl.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @base_url }\n end\n end", "def get(url)\n faraday = Faraday.new(url) do |faraday|\n faraday.response :json\n faraday.adapter Faraday.default_adapter\n end\n\n response = faraday.get do |request|\n request.url(url)\n end\n response.body\nend", "def call\n fail(WordpRSS::InvalidURLError.new(\"#{url} is not a valid URL\")) unless url =~ URI::regexp\n\n RestClient.get(url)\n end", "def get(url)\n uri = URI.parse(url)\n http = Net::HTTP.new(uri.host, uri.port)\n\n response = http.get(\"#{uri.path}?auto\")\n\n unless response.code == \"200\"\n puts \"Failed to retrieve #{url}: #{response.code}\"\n exit 3\n end\n\n response.body\nend", "def index\n @url = Url.all\n end", "def json_url\n # \"#{REDDIT_URL_PREFIX}#{permalink}#{@self_id}.json\"\n end", "def get url, params={}, headers={}\n uri = URI.parse(url)\n path = uri.path + \"?\" + query_string(default_params.merge(params))\n response = http(uri.host, uri.port).get(path, default_headers.merge(headers))\n JSON.parse(response.body)\n end", "def get(url)\n begin\n # Start by creating a new `RestCLient::Resource` authenticated with\n # the `@project` name and `@password`.\n resource = RestClient::Resource.new(url) \n # `GET` the resource\n resource.get {|response, request, result, &block|\n case response.code\n when 200\n JSON.parse(response.body)\n else\n response.return!(request, result, &block)\n end\n }\n rescue => e\n # Rescue and reraise with the current `@url` for debugging purposes \n raise \"Problem fetching #{@url} because #{e.message}\"\n end\n end", "def swapi_fetch(url)\n JSON.parse(open(url).read)\nend", "def get(url, args = {})\r\n make_request(:get, url, args)\r\n end", "def index\n @urls = Url.all\n\n \n\n end", "def get(url)\n uri = URI(url)\n Net::HTTP.get(uri)\nend", "def url\n data['url']\n end", "def call_poke_url(url)\n JSON.parse(\n HTTP\n .get(URI(url))\n )\nend", "def show\n @url = Url.find(params[:id])\n \n respond_to do |format|\n format.html\n end\n end", "def get(url, options={})\n resp = RestClient.get url, rest_client_options(options)\n Representation.new self, MultiJson.load(resp)\n end", "def do_get url\n\t\turi = URI.parse(url)\n\t\tNet::HTTP.get_response(uri)\n\tend", "def json(url)\n Rails.logger.info \"Retrieving json for url: #{url}\"\n r = response(url).body\n JSON.parse(r)\n end", "def index\n links = all_links\n render json: { success: true, links: links }\n end", "def show\n @content_url = ContentUrl.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @content_url }\n end\n end", "def get_url\n heroku_app = options[:heroku_app]\n uriString = \"https://api.heroku.com/apps/#{heroku_app}/releases\"\n accept = '\"Accept: application/vnd.heroku+json; version=3\"'\n order = '\"Range: version ..; order=desc, max=10;\"'\n uri = URI(uriString)\n puts \"URI: #{uri}\"\n\n res = `curl -n --silent #{uriString} -H #{accept} -H #{order}`\n\n result = JSON.parse(res)\n\n id = nil\n ver = nil\n hash = nil\n result.each { |i|\n puts i\n if !id && i[\"slug\"] && i[\"slug\"][\"id\"] && i[\"slug\"][\"id\"] != \"\"\n id = i[\"slug\"][\"id\"]\n ver = i[\"version\"]\n hash = i[\"description\"]\n end\n }\n\n #puts id if id\n if id != nil\n\n uriStringSlug = \"https://api.heroku.com/apps/#{heroku_app}/slugs/#{id}\"\n uriSlug = URI(uriStringSlug)\n\n resSlug = `curl -n --silent #{uriStringSlug} -H #{accept}`\n resultSlug = JSON.parse(resSlug)\n p \"--------------------------------\"\n p \"Version: #{ver}\"\n p \"Hash: #{hash}\"\n p resultSlug[\"blob\"][\"url\"]\n p \"--------------------------------\"\n end\n end", "def show\n respond_to do |format|\n format.json { render json: @uri, status: 200 }\n end\n end", "def new\n @url = Url.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @url }\n end\n end", "def get(url, opts = {})\n response = RestClient::Request.new(\n method: :get,\n url: \"#{ENDPOINT_URL}/#{url}\",\n verify_ssl: false,\n headers: {\n 'Content-Type' => 'application/json',\n 'Authorization' => \"Basic #{authorization_hash}\",\n 'client-id' => client_id,\n 'access-token' => access_token\n },\n payload: opts\n ).execute\n\n JSON.parse(response)\n end", "def [](url)\n rget key_for url\n end", "def [](url)\n rget key_for url\n end", "def url\n \"/#{self.class.rest_name}s/#{id}\"\n end", "def new\n @page_title = 'New URL'\n @url = ShortenUrl.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @url }\n end\n end", "def http( *args )\n p http_get( *args )\n end", "def shorten_link(url)\n uri = URI.parse(\"http://localhost:3000/shorten\")\n params = {\"url\": url}\n uri.query = URI.encode_www_form(params)\n JSON.parse(Net::HTTP.get(uri))\nend", "def get(path, redirect_limit=5)\n parse_json do |parser|\n @http_client.get(path, redirect_limit) {|chunk| parser << chunk }\n end\n end", "def new\n @url = ShortenedUrl.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @url }\n end\n end", "def request(args = {})\n response = @client.get(args[:url],\n argument_hash(args[:args] || {},\n args[:symbols] || []))\n JSON.parse(response.body)\n end", "def load_from_url!(url)\n uri = URI(url)\n req = Net::HTTP::Get.new(uri)\n req['Accept'] = 'application/json'\n\n res = Net::HTTP.start(uri.hostname, uri.port) do |http|\n http.request(req)\n end\n\n # TODO: handle redirects\n raise IOError, \"Unable to load URL #{url}\" unless res.is_a?(Net::HTTPOK)\n\n load_from_json!(res.body)\n end", "def get_json(uri)\n start = Time.now\n attempt = 0\n begin\n res = @http.get(\n uri,\n 'Accept' => 'text/plain',\n 'User-Agent' => user_agent,\n 'Accept-Encoding' => ''\n )\n raise Error, \"Failed to retrieve #{uri} (#{res.code}): #{res.body}\" unless res.code == '200'\n info(\"GET #{uri}: #{res.code}/#{res.body.length}b in #{age(start)}\")\n JSON.parse(res.body)\n rescue StandardError => e\n attempt += 1\n raise e if attempt >= @attempts\n retry\n end\n end", "def show\n json = self.as_json(only: [:created_at, :version])\n json['url'] = doi_url\n json\n end", "def index\n @url = Url.new\n end" ]
[ "0.6885968", "0.66887754", "0.66787374", "0.66593164", "0.6529249", "0.6509962", "0.64914274", "0.6448754", "0.64453053", "0.6409037", "0.64083", "0.6267918", "0.6236266", "0.6223829", "0.6216287", "0.62162524", "0.620276", "0.6169882", "0.6138518", "0.6119957", "0.61180186", "0.6108202", "0.61003846", "0.60605735", "0.60550773", "0.60468984", "0.6046129", "0.60417986", "0.60299844", "0.60294175", "0.6014244", "0.60016876", "0.5995629", "0.5992139", "0.5985687", "0.5968342", "0.5968342", "0.5954984", "0.5954984", "0.59509933", "0.59451306", "0.5941038", "0.59368545", "0.593176", "0.59266025", "0.5914046", "0.5906366", "0.5902448", "0.59023285", "0.5901168", "0.58992666", "0.5893455", "0.58678144", "0.5833601", "0.5820917", "0.58192194", "0.58189905", "0.5810175", "0.58061785", "0.5801068", "0.57873946", "0.578485", "0.5782201", "0.5777008", "0.5762652", "0.5752454", "0.57425886", "0.57424617", "0.573629", "0.5732209", "0.5729212", "0.57290244", "0.57191604", "0.57189447", "0.571705", "0.5697322", "0.56949914", "0.5687519", "0.56830966", "0.5678516", "0.5667808", "0.5666167", "0.5661877", "0.5658962", "0.5647116", "0.56451553", "0.56437135", "0.56405675", "0.56367886", "0.56367886", "0.5606693", "0.5605289", "0.56031066", "0.56021976", "0.5592379", "0.5589913", "0.55875146", "0.5580259", "0.55762273", "0.5562687", "0.5551767" ]
0.0
-1
POST /urls POST /urls.json
def create @url = Url.new(url_params) if @url.save redirect_to @url else render 'new' end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n params[:url_list].each do |url|\n WebUrl.new(:url => url).save\n end\n render :json=>params[:url_list].to_json\n end", "def create_api\n\n @url = Url.new(:url => params[:url])\n\n if @url.save\n url_hash = Hash.new\n\n url_hash[:short_url] = root_url.to_s() + \"urls_api/\" + (@url.id).to_s(36)\n url_hash[:url] = @url.url\n\n render :json => url_hash.to_json\n end\n\n end", "def create\n @url = current_user.urls.new(params[:url])\n\n respond_to do |format|\n if @url.save\n format.html { redirect_to urls_path, notice: 'Url was successfully created.' }\n format.json { render json: @url, status: :created, location: @url }\n else\n format.html { render action: \"new\" }\n format.json { render json: @url.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @url = Url.new(url_params.merge({user: current_user}))\n\n if @url.save\n render_jsonapi_response(@url)\n else\n render json: {errors: @url.errors}, status: :unprocessable_entity\n end\n end", "def create url\n function = ''\n \n post_data = {}\n post_data[:url] = url\n\n request(@resource, function, nil, 'post', post_data)\n end", "def create\n\n @url = Url.new(url_params)\n @url.user = current_user\n @url.unique_key = @url.generate_unique_key\n\n #save data\n if @url.save\n response = {:status => 'success',\n :mgs => short_url(@url.unique_key)}\n else\n response = {:status => 'fail',\n :mgs => 'Not a valid URL.'}\n end\n\n #send response\n respond_to do |format|\n format.json { render json: response }\n end\n end", "def create_batch urls\n function = 'batch/'\n\n post_data = {}\n post_data[:urls] = urls.join(',')\n\n request(@resource, function, nil, 'post', post_data)\n end", "def create\n \t@url = Url.build(params[:link],request.base_url) \t\n \trender json: @url.to_json\n end", "def create\n @url = Url.new(url_params)\n respond_to do |format|\n if @url.save\n #format.html { redirect_to @url, notice: 'Url was successfully created.' }\n FetchUrlWorker.perform_async(@url.id)\n format.json { render json: {\n short_url: \"#{request.protocol}#{request.host_with_port}/#{@url.short_url}\",\n status: :created,\n location: @url }\n }\n else\n # format.html { render :new }\n format.json { render json: @url.errors, status: :unprocessable_entity }\n end\n end\n end", "def post(url, args = {})\r\n make_request(:post, url, args)\r\n end", "def create\n \turl = Url.create(params[:url])\n \t\n \tredirect_to urls_path\n end", "def create\n @url = Url.new(url_params)\n\n\n respond_to do |format|\n if @url.save\n format.html { redirect_to @url, notice: 'Url was successfully created.' }\n format.json { render :show, status: :created, location: @url }\n else\n format.html { render :new }\n format.json { render json: @url.errors, status: :unprocessable_entity }\n end\n end\n end", "def create(url, data)\n RestClient.post ENV['APIBASE']+url, data, :content_type => :json\nend", "def create\n @url = Url.new(url_params)\n\n respond_to do |format|\n if @url.save\n format.html { redirect_to @url, notice: 'Url was successfully created.' }\n format.json { render action: 'show', status: :created, location: @url }\n wordcount\n else\n format.html { render action: 'new' }\n format.json { render json: @url.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @crawl_request = CrawlRequest.new(crawl_request_params)\n\n if @crawl_request.save\n render json: @crawl_request, status: :created, location: @crawl_request, :include => :urls\n else\n render json: @crawl_request.errors, status: :unprocessable_entity\n end\n end", "def create\n puts '---------------'\n puts params\n puts '---------------'\n # We made users, and urls need a user_id\n # so for demo we are going to generature the URL for\n # our First user in our database....\n url = User.first.urls.new(url_params)\n url.save\n redirect_to '/urls'\n end", "def post_json(url, data)\n JSON.parse(post(url, data, :json, :json))\n end", "def create\n @url = Url.new(url_params)\n\n Url.transaction do\n @url.save\n #write base 62 method\n @url.short_url = generate_base62_short_url(@url.id)\n if @url.save\n render json: @url, status: :created, root: :url\n else\n render json: @url.errors, status: :unprocessable_entity\n end\n end\n end", "def post(path, **args); end", "def create\n @url = request.format.json? ? Url.new(original_link: params[:original_link]) : Url.new(url_params)\n\n respond_to do |format|\n if @url.save\n format.html { redirect_to @url, notice: 'URL was successfully created.' }\n format.json { render :show, status: :created, location: @url }\n else\n format.html { render :new }\n format.json { render json: @url.errors, status: :unprocessable_entity }\n end\n end\n end", "def post(url, payload = {}, headers = {})\n http :post, \"#{url}.json\", payload.to_json, headers\n end", "def create\n url = ShortenedUrl.find_by_long_url(shortened_urls_params[:long_url])\n \n if url\n render json: {shortUrl: url[:short_url]}\n else\n shortened_url = ShortenedUrl.new(shortened_urls_params)\n \n if shortened_url.save\n short_url = shortened_url.generate_short_url\n shortened_url.update_attribute(\"short_url\", short_url)\n \n render json: { shortUrl: shortened_url[:short_url], success: true }\n else\n render json: { error: true }\n end\n end\n end", "def create\n response = @page.parse_url\n render json: response\n end", "def create\n @url = ShortenedUrl.new(surl_params)\n\n respond_to do |format|\n if @url.save\n format.html { redirect_to @url, :notice => 'Shortened url was successfully created.' }\n format.json { render :json => @url, :status => :created, :location => @url }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @url.errors, :status => :unprocessable_entity }\n end\n end\n end", "def http_post(url, data)\n\turi = URI(url)\n\treq = Net::HTTP::Post.new(uri.path, initheader = {'Content-Type' =>'application/json'})\n req.body = data.to_json\n response = Net::HTTP.new(uri.host, uri.port).start {|http| http.request(req) }\n return response\nend", "def post(url, post_vars={})\n send_request url, post_vars, 'POST'\n end", "def post_request(url,args)\n uri = URI.parse(url)\n req = Net::HTTP::Post.new(uri.path)\n req.set_form_data(args)\n request(uri,req)\n end", "def create\n @url = Url.new(url_params)\n @url = Url.get_from_long(@url.long) if @url.duplicate?\n\n respond_to do |format|\n if not @url.new_record?\n format.html { redirect_to root_path, notice: 'URL already existed.' }\n format.json { render action: 'show', status: :ok, location: @url }\n elsif @url.save\n format.html { redirect_to root_path, notice: 'Url was successfully created.' }\n format.json { render action: 'show', status: :created, location: @url }\n else\n format.html do\n @urls = Url.recent.page(params[:page]).per(25)\n render action: 'index'\n end\n format.json { render json: @url.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @url = Url.new(url_params)\n \n set_url_host_model\n \n respond_to do |format|\n if @url.save\n format.html { redirect_to @url, notice: 'Url was successfully created.' }\n format.json { render :show, status: :created, location: @url }\n else\n format.html { render :new }\n format.json { render json: @url.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @urls = params[:domain].split(\"\\r\\n\")\n\n @urls.each do |url|\n @whitelist_url = WhitelistUrl.new(:domain => url)\n @whitelist_url.save\n end\n\n redirect_to whitelist_urls_url\n\n # respond_to do |format|\n # if @whitelist_url.save\n # format.html { redirect_to @whitelist_url, notice: 'Whitelist url was successfully created.' }\n # format.json { render action: 'show', status: :created, location: @whitelist_url }\n # else\n # format.html { render action: 'new' }\n # format.json { render json: @whitelist_url.errors, status: :unprocessable_entity }\n # end\n # end\n end", "def post url\n Timeout.timeout(60) do\n puts \"POST: #{url}\" if config[:debug]\n \n tags = (Hpricot(open(\"http://del.icio.us/url/check?url=#{CGI.escape(url)}\"))/\n '#top-tags'/'li')[0..10].map do |li| \n (li/'span').innerHTML[/(.*?)<em/, 1]\n end.join(\" \")\n puts \"POST-TAGS: #{tags}\" if config[:debug]\n \n description = begin\n Timeout.timeout(5) do \n (((Hpricot(open(url))/:title).first.innerHTML or url) rescue url)\n end\n rescue Timeout::Error\n puts \"POST: URL timeout\" if config[:debug]\n url\n end\n \n query = { :url => url, :description => description, :tags => tags, :replace => 'yes' }\n\n http = Net::HTTP.new('api.del.icio.us', 443) \n http.use_ssl = true \n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n response = http.start do |http|\n post_url = '/v1/posts/add?' + query.map {|k,v| \"#{k}=#{CGI.escape(v)}\"}.join('&')\n puts \"POST: post url #{post_url}\" if config[:debug]\n req = Net::HTTP::Get.new(post_url, {\"User-Agent\" => \"Kirby\"})\n req.basic_auth config[:delicious_user], config[:delicious_pass]\n http.request(req)\n end.body\n\n puts \"POST: #{response.inspect}\" if config[:debug]\n end\n rescue Exception => e\n puts \"POST: #{e.inspect}\" if config[:debug]\n end", "def test_should_create_link_via_API_JSON\r\n get \"/logout\"\r\n post \"/links.json\", :api_key => 'testapikey',\r\n :link => {:user_id => 1,\r\n :title => 'API Link 1',\r\n :url => 'http://www.api.com'}\r\n assert_response :created\r\n link = JSON.parse(response.body)\r\n check_new_link(link) \r\n end", "def create\n @shortened_url = Url.new(:url => params[:url])\n \n \n respond_to do |format|\n if @shortened_url.save\n @num=\"\"\n flash[:shortened_id] = @shortened_url.id\n ( @shortened_url.id..(@shortened_url.id)).each do |i|\n @num=hashing(i)+@num\n end\n @shortened_url.shorturl=url_url(@num) \n @shortened_url.save \n \n format.html {redirect_to new_url_url}\n format.xml { render xml: @urls}\n format.json { render json: @shortened_url, status: :created }\n else\n format.json { render json: @shortened_url.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @listing = Listing.new(params[:listing])\n @listing.urls.append params[:url]\n\n respond_to do |format|\n if @listing.save\n format.html { redirect_to @listing, notice: 'Listing was successfully created.' }\n format.json { render json: @listing, status: :created, location: @listing }\n else\n format.html { render action: \"new\" }\n format.json { render json: @listing.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n \n url_match = params[:url][:url] =~ /\\Ahttp(s?):\\/\\//i\n params[:url][:url] = \"http://\" << params[:url][:url] if url_match.nil?\n \n # find existing url\n @existing_url = Url.find_by_url(params[:url][:url])\n \n if @existing_url.nil?\n @url = Url.new(params[:url])\n id = Url.last.id unless Url.last.nil?\n @url.short_url = Shorten::Base62.to_s(id.nil? ? 1 : id+1)\n p @url\n else\n @url = @existing_url\n end\n\n respond_to do |format|\n if !@existing_url.nil? or @url.save\n format.html { redirect_to @url, notice: 'Url was successfully shortened.' }\n format.json { render json: @url, status: :created, location: @url }\n format.js\n else\n format.html { render action: \"new\" }\n format.json { render json: @url.errors, status: :unprocessable_entity }\n format.js\n end\n end\n end", "def handle_links(json) end", "def add_new_urls(urls)\n return if urls.length == 0\n @db[LINKS_COLLECTION_NAME].insert(urls.map {|u| {'_id' => hash_url(u)}})\n end", "def url_params\n params.require(:url).permit(:url, :unique_key, :hits)\n end", "def post(url, payload, headers={})\n payload = MultiJson.encode(payload)\n headers = headers.merge({:content_type => 'application/json'})\n request(:post, url, payload, headers)\n end", "def create\n @url_list = UrlList.new(url_list_params)\n\n respond_to do |format|\n if @url_list.save\n format.html { redirect_to @url_list, notice: 'Url list was successfully created.' }\n format.json { render :show, status: :created, location: @url_list }\n else\n format.html { render :new }\n format.json { render json: @url_list.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @urls = Url.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @urls }\n end\n end", "def create\n @url = Url.new(url_params)\n @page = Page.find(params[:page_id])\n respond_to do |format|\n if @url.save\n @url.capture # 新規作成したとき、ここで、キャプチャ\n format.html { redirect_to edit_page_url_url(@page,@url), notice: 'URLを追加しました。' }\n format.json { render :show, status: :created, location: @url }\n else\n format.html { render :new }\n format.json { render json: @url.errors, status: :unprocessable_entity }\n end\n end\n end", "def post url, object = nil\n request url, HTTP::Post, object\n end", "def post(endpoint, url, args, version = 'v1')\n qs = build_qs(args)\n req_url = \"#{url}/api/#{version}/#{endpoint}?#{qs}\"\n\n request(req_url, :POST)\n end", "def entries_to_http entries, url, http = Atom::HTTP.new\n coll = Atom::Collection.new url, http\n\n entries.each { |entry| coll.post! entry }\n end", "def index\n @urls = ShortenedUrl.order(\"updated_at ASC\").all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @urls }\n end\n end", "def post_json(url, ls_data)\n uri = URI.parse(url)\n request = Net::HTTP::Post.new(uri.request_uri, HEADER_JSON)\n request.body = ls_data\n request.basic_auth(@nsx_user, @nsx_password)\n response = Net::HTTP.start(uri.host, uri.port, :use_ssl => true,\n :verify_mode => OpenSSL::SSL::VERIFY_NONE) do |https|\n https.request(request)\n end\n return JSON.parse(response.body)['id'] \\\n if check_response(response, 201)\n end", "def post(url, key)\n _request(url, :POST, key)\n end", "def post_json(url, body = nil, headers = nil)\n body = body.to_json\n headers = (headers || {}).merge('Content-Type' => 'application/json')\n post(url, body, headers)\n end", "def create\n referrer = Rails.application.routes.recognize_path(request.referrer)\n \n @url = Url.new(url_params)\n @error = nil\n result_url = Url.find_by(:long_url => @url[:long_url])\n\n respond_to do |format|\n if result_url.nil?\n max_id = Url.maximum(:id) || 0\n num = START_OFFSET + max_id + 1\n short_key = encode(num) \n @url[:short_url] = short_key\n\n if @url.save\n @new_url = @url\n @url = Url.new(:long_url => @new_url[:long_url], :short_url => @new_url[:short_url])\n if referrer[:action] == 'index'\n format.html { render :index }\n else\n format.html { redirect_to @new_url, notice: \"URL was successfully created.\"}\n end\n else\n @error = @url.errors.full_messages\n if referrer[:action] == 'index'\n format.html { render :index }\n else\n format.html { render :new }\n format.json { render json: @url.errors, status: :unprocessable_entity }\n end\n end\n else\n if referrer[:action] == 'index'\n @url[:short_url] = result_url[:short_url]\n format.html { render :index }\n else\n format.html { redirect_to result_url, notice: \"Existing URL. No URL is created.\" }\n end\n end\n end\n end", "def create\n @urlitem = Urlitem.new(urlitem_params)\n\n respond_to do |format|\n if @urlitem.save\n format.html { redirect_to @urlitem, notice: 'Urlitem was successfully created.' }\n format.json { render :show, status: :created, location: @urlitem }\n else\n format.html { render :new }\n format.json { render json: @urlitem.errors, status: :unprocessable_entity }\n end\n end\n end", "def http_post(*args)\n url = args.shift\n c = Curl::Easy.new url\n yield c if block_given?\n c.http_post *args\n c\n end", "def post(*args)\n request :post, *args\n end", "def create\n @visited_url = VisitedUrl.new(visited_url_params)\n\n respond_to do |format|\n if @visited_url.save\n format.html { redirect_to @visited_url, notice: 'Visited url was successfully created.' }\n format.json { render :show, status: :created, location: @visited_url }\n else\n format.html { render :new }\n format.json { render json: @visited_url.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @sampled_url = SampledUrl.new(params[:sampled_url])\n\n respond_to do |format|\n if @sampled_url.save\n format.html { redirect_to @sampled_url, notice: 'Sampled url was successfully created.' }\n format.json { render json: @sampled_url, status: :created, location: @sampled_url }\n else\n format.html { render action: \"new\" }\n format.json { render json: @sampled_url.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @url_identifier = params[:new_identifier]\n @url = Url.new(url_params)\n @url.group = current_user.context_group\n @empty_url = Url.new\n\n respond_to do |format|\n if @url.save\n format.html do\n redirect_to urls_path, notice: 'URL was successfully created.'\n end\n format.js { render :create }\n else\n format.js { render :new }\n end\n end\n end", "def create\n\t@doi = Doi.find params[:doi_id]\n @url = @doi.urls.new(url_params)\n\n\tif @url.save\n\tredirect_to doi_urls_url(@doi) , notice: 'URL was successfuly created'\n\telse\n\trender :new\n\tend\n end", "def index\n @urls = @site.urls.paginate(:page => params[:page])\n render json: @urls\n end", "def create\n\t\turi = URI.parse(Counter::Application.config.simplyurl)\n\t\thttp = Net::HTTP.new(uri.host, uri.port)\n\t\t\n\t\trequest = Net::HTTP::Post.new('/offsets.json')\n\t\tputs params\n\t\tputs params.slice(*['custids','acctids','itemids'])\n\t\t\n\t\t# ok, this join stuff is bogus - it encodes properly, but the other side only sees the last element and loses the array type - it's just string\n\t\t# this way, i 'split' it at the other side to recover my array\n\t\t# it should work without the join/split crap, but it doesn't\n\t\trequest.set_form_data({:custids => ( params['custids'] || []).join(','), :acctids => ( params['acctids'] || []).join(','), :itemids => ( params['itemids'] || []).join(','), :amount => params['amount'], :type => params['type']})\n\t\t\n\t\tputs request.body\n\t\t\n\t\tresponse = http.request(request)\n\t\tputs response.body\n\n respond_to do |format|\n format.html { render :text => response.code == :ok ? \"\" : response.body, status: response.code }\n format.json { render :text => response.code == :ok ? \"\" : response.body, status: response.code }\n end\n end", "def urls_params\n params.permit(urls: []).dig(:urls) || ParallelFetcher::DEFAULT_URLS\n end", "def post(*args)\n prepare_request(:post, args)\n @@client.add(:post, @path, *args)\n end", "def post(url, body = {})\n call(url: url, action: :post, body: body)\n end", "def create\n submitted_url = url_params[:original_url]\n\n @url = Url.where(original_url: [submitted_url, \"http://#{submitted_url}\",\"http://www.#{submitted_url}\"]).first_or_initialize\n @url.assign_attributes(url_params)\n\n respond_to do |format|\n if @url.persisted?\n format.html {redirect_to @url, notice: \"We've already redirected this url. Check out the shortened url below.\"}\n format.json { render action: 'show', status: 200, location: @url }\n elsif @url.save\n format.html { redirect_to @url, notice: 'Url was successfully created.' }\n format.json { render action: 'show', status: :created, location: @url }\n else\n format.html { render action: 'new' }\n format.json { render json: @url.errors, status: :unprocessable_entity }\n end\n end\n end", "def post(url, payload)\n url = URI.parse(url)\n http = Net::HTTP.new(url.host, url.port)\n http.use_ssl = true\n request = Net::HTTP::Post.new(url.path+'?access_token=verysecret')\n request.content_type = 'application/json'\n request.body = JSON.generate(payload)\n response = http.start {|http| http.request(request) }\n begin\n return JSON.parse(response.body)\n rescue\n # Log as a problematic case with rule number and line\n $problems.write \"#{$index}, #{payload}, #{response.body}\\n\"\n return nil\n end\nend", "def post(url, data, headers = {})\n request(:post, url, headers, :data => data)\n end", "def create\n @known_url = KnownUrl.new(known_url_params)\n\n respond_to do |format|\n if @known_url.save\n format.html { redirect_to @known_url, notice: 'Known url was successfully created.' }\n format.json { render action: 'show', status: :created, location: @known_url }\n else\n format.html { render action: 'new' }\n format.json { render json: @known_url.errors, status: :unprocessable_entity }\n end\n end\n end", "def post_json(path, body)\n uri = build_uri(path)\n puts \"*** POST #{path}\"\n puts JSON.pretty_generate(body)\n\n post_request = Net::HTTP::Post.new(uri, 'Content-Type' => 'application/json')\n post_request.body = JSON.generate(body)\n\n response = Net::HTTP.start(uri.hostname, uri.port, :use_ssl => true) do |http|\n http.request(post_request)\n end\n\n puts \"HTTP #{response.code}\"\n result = JSON.parse(response.body)\n puts JSON.pretty_generate(result)\n result\nend", "def url_params\n params.permit(:url)\n end", "def url_params\n params.permit(:url)\n end", "def post(url)\n response = RestClient::Request.new(\n method: :post,\n url: \"#{ENDPOINT_URL}/#{url}\",\n verify_ssl: false,\n headers: {\n 'Content-Type' => 'application/json',\n 'Authorization' => \"Basic #{authorization_hash}\"\n },\n payload: {user: user, pwd: password}.to_json\n ).execute\n\n # Parse the response to Ruby objects\n JSON.parse(response)\n end", "def post(url_variables:, body:)\n ensure_service_document\n\n end", "def create\n # decode url to remove duplicacy in case of same url encoded and decoded\n url = URI.decode(params[:url])\n # check if url already exists in db\n mini_url = MiniUrlHelper.check_existing_url(url, current_user)\n unless mini_url\n mini_url = MiniUrl.new\n mini_url.url = url\n # a check to handle invalid expiry time\n begin\n mini_url.expiry = DateTime.parse(params[:expiry])\n rescue ArgumentError => e\n logger.error \"Invalid expiry time.\"\n end\n mini_url.user = current_user if current_user\n # call method to generate unique code and save into db\n # raise exception in case of some error\n unless mini_url.generate_unique_code\n raise Exceptions::SavingError.new(mini_url.errors)\n end\n end\n short_url = \"#{BASE_URL}/#{mini_url.url_code}\"\n render json: {short_url: short_url}, status: 201\n rescue Exceptions::SavingError => e\n render json: {error: e}, status: 400\n end", "def post(*args)\n request(:post, *args)\n end", "def create\n @url_mapper = UrlMapper.new(url_mapper_params)\n\n respond_to do |format|\n if @url_mapper.save\n format.html { redirect_to @url_mapper, notice: 'Url mapper was successfully created.' }\n format.json { render :show, status: :created, location: @url_mapper }\n else\n format.html { render :new }\n format.json { render json: @url_mapper.errors, status: :unprocessable_entity }\n end\n end\n end", "def post(url, params = {})\n client.post(url, params).body\n end", "def create\n @url = Url.new(url_params)\n\n respond_to do |format|\n @url.user = current_user\n if @url.save\n format.html { redirect_to polymorphic_url([:short], short: \"#{@url.short}+\"), notice: 'Url was successfully shortened.' }\n format.json { render action: 'show', status: :created, location: @url }\n else\n format.html { render action: 'new' }\n format.json { render json: @url.errors, status: :unprocessable_entity }\n end\n end\n end", "def save_data(url_list)\n urls = []\n url_list.each do |url|\n begin\n parsed_url = URI.parse(url)\n main_url = parsed_url.scheme + '://' + parsed_url.host + parsed_url.path\n query = URI::decode_www_form(parsed_url.query).to_h rescue nil\n insert_in_table({url: main_url, query: query})\n rescue Exception => e\n puts \"BAD URL = #{e.message}, url = #{url}\"\n end\n end\n puts urls\n end", "def create\n @url = Url.create_update_with(url_params)\n @short_url = \"#{request.host_with_port}/#{@url.short_url}\"\n redirect_to root_path(short_url: @short_url)\n end", "def post endpoint, data\n do_request :post, endpoint, data\n end", "def url_params\n params.require(:url).permit(:url)\n end", "def create\n @feed_url = current_account.feed_urls.new(feed_url_params)\n\n respond_to do |format|\n if @feed_url.save\n format.html { redirect_to feed_urls_path, notice: 'Feed url was successfully created.' }\n format.json { render :show, status: :created, location: @feed_url }\n else\n format.html { render :new }\n format.json { render json: @feed_url.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @urlshortner = Urlshortner.new(urlshortner_params)\n\n respond_to do |format|\n if @urlshortner.save\n format.html { redirect_to @urlshortner, notice: 'Urlshortner was successfully created.' }\n format.json { render action: 'show', status: :created, location: @urlshortner }\n else\n format.html { render action: 'new' }\n format.json { render json: @urlshortner.errors, status: :unprocessable_entity }\n end\n end\n end", "def http_post(uri, data)\n RestClient.post uri, data\n end", "def create\n @link = Link.new(params[:link])\n\n respond_to do |format|\n if @link.save\n @response = { url: \"#{request.protocol}#{request.host_with_port}/#{Link.encode(@link.id)}\" }\n format.json { render json: @response, status: :created, location: @link }\n else\n format.json { render json: @link.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @url_connector = UrlConnector.new(params[:url_connector])\n\n respond_to do |format|\n if @url_connector.save\n format.html { redirect_to @url_connector, notice: 'Url connector was successfully created.' }\n format.json { render json: @url_connector, status: :created, location: @url_connector }\n else\n format.html { render action: \"new\" }\n format.json { render json: @url_connector.errors, status: :unprocessable_entity }\n end\n end\n end", "def post_json(path, body)\n uri = build_uri(path)\n puts \"*** POST #{uri}\"\n puts JSON.pretty_generate(body)\n\n post_request = Net::HTTP::Post.new(uri, 'Content-Type' => 'application/json')\n post_request.body = JSON.generate(body)\n\n response = Net::HTTP.start(uri.hostname, uri.port, :use_ssl => true) do |http|\n http.request(post_request)\n end\n\n puts \"HTTP #{response.code}\"\n result = JSON.parse(response.body)\n puts result[:result]\n result\nend", "def post_json(path, body)\n uri = build_uri(path)\n #puts \"🤖 POST #{path}\"\n #puts JSON.pretty_generate(body)\n\n post_request = Net::HTTP::Post.new(uri, 'Content-Type' => 'application/json')\n post_request.body = JSON.generate(body)\n\n response = Net::HTTP.start(uri.hostname, uri.port, :use_ssl => true) do |http|\n http.request(post_request)\n end\n\n #puts \"HTTP #{response.code}\"\n result = JSON.parse(response.body)\n #puts result[:result]\n result\nend", "def add_url(teamsiteId:, name:, url:, **args)\n request.post(\n \"#{teamsites_url}/#{teamsiteId}/urls\",\n body: { url: url, name: name, **args }\n )\n end", "def create\n @url = params[:url]\n token = SecureRandom.hex(4)\n @tiny_token = Url.create(\n url: @url,\n token: token,\n domain: \"#{ENV['HOSTNAME']}/#{token}\" \n )\n redirect_to url_path(token)\n \n end", "def post(url, resource_name, options = {})\n build_response(resource_name) do\n connection.post do |req|\n req.url url\n req.body = options.to_json\n end\n end\n end", "def submit\n\t\tset_post_data\n get_response @url\n parse_response\n\tend", "def post_json(path, body)\n uri = build_uri(path)\n\n post_request = Net::HTTP::Post.new(uri, 'Content-Type' => 'application/json')\n post_request.body = JSON.generate(body)\n\n response = Net::HTTP.start(uri.hostname, uri.port, :use_ssl => true) do |http|\n http.request(post_request)\n end\n\n result = JSON.parse(response.body)\n puts result\n result\nend", "def create\n if @link.save\n render json: @link, status: :created, location: @link\n else\n render json: @link.errors, status: :unprocessable_entity\n end\n end", "def create\n @url_link = UrlLink.new(url_link_params)\n\n respond_to do |format|\n if @url_link.save\n format.html { redirect_to @url_link, notice: 'Url link was successfully created.' }\n format.json { render :show, status: :created, location: @url_link }\n else\n format.html { render :new }\n format.json { render json: @url_link.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @url = Url.new(url_params)\n @url.sanitize\n @url.current_ip = request.remote_ip\n if @url.new_url?\n respond_to do |format|\n if @url.save\n format.html { redirect_to shortened_path(@url.short_url), notice: 'Url was successfully created.' }\n format.json { render :show, status: :created, location: @url }\n else\n format.html { render :new }\n format.json { render json: @url.errors, status: :unprocessable_entity }\n end\n end\n else\n flash[:notice] = \"A short link for this URL is already in our database\"\n redirect_to shortened_path(@url.find_duplicate.short_url)\n end\n \n end", "def autoname_url(url)\n request('POST', @uri.request_uri, url)\n end", "def create\n @short_url = @user.short_urls.new(short_url_params)\n\n if @short_url.save\n short_url = @short_url\n short_url.shorty = \"http://www.my-domain.com/#{@short_url.shorty}\"\n render json: short_url, status: :created\n else\n render json: {errors: @short_url.errors}, status: :unprocessable_entity\n end\n end", "def urls_params\n params.require(:url).permit(:long_url)\n end", "def post(object, url, headers={})\n do_request(\"post\", url, object, headers)\n end", "def create\n normalized_url = Link.normalize_url(params[:url])\n if normalized_url.nil?\n render json: LinkResponse.new(ERROR_INVALID_URL, params[:code]), status: 422\n else\n begin\n link = Link.find_or_create(normalized_url, params[:type])\n render json: LinkResponse.new(SUCCESS, link.code), status: 200\n rescue => error\n render json: LinkResponse.new(ERROR_INVALID_URL, params[:code]), status: 500\n end\n end\n end", "def post_json(path, body)\n uri = build_uri(path)\n puts \"*** POST #{path}\"\n puts JSON.pretty_generate(body)\n\n post_request = Net::HTTP::Post.new(uri, 'Content-Type' => 'application/json')\n post_request.body = JSON.generate(body)\n\n response = Net::HTTP.start(uri.hostname, uri.port, :use_ssl => true) do |http|\n http.request(post_request)\n end\n\n puts \"HTTP #{response.code}\"\n result = JSON.parse(response.body)\n puts result[:result]\n result\nend" ]
[ "0.66614103", "0.6225674", "0.62237", "0.6133381", "0.6110082", "0.60986954", "0.60519725", "0.60070646", "0.5954528", "0.59431005", "0.5926763", "0.58907574", "0.5872233", "0.58478326", "0.58240664", "0.58098954", "0.57900316", "0.57866234", "0.5748828", "0.57442534", "0.571095", "0.5702256", "0.5697739", "0.56848264", "0.56669545", "0.5665943", "0.5658442", "0.56583846", "0.5633092", "0.5632965", "0.5608323", "0.5604932", "0.56031066", "0.5576357", "0.5569383", "0.5564657", "0.5558423", "0.55470204", "0.5534048", "0.5531006", "0.5498041", "0.5487107", "0.54843044", "0.5453987", "0.54337716", "0.54286295", "0.5413775", "0.5413754", "0.5412093", "0.5392093", "0.53916115", "0.5389826", "0.5387794", "0.53822106", "0.5369843", "0.5353218", "0.535303", "0.5348782", "0.53303796", "0.5322968", "0.5322768", "0.532178", "0.53170955", "0.53169143", "0.53091943", "0.52959967", "0.5293572", "0.52903783", "0.52903783", "0.52888346", "0.52807444", "0.5280107", "0.5279515", "0.5269916", "0.5269777", "0.5268436", "0.5266615", "0.52525795", "0.52402246", "0.52348644", "0.52343255", "0.5234164", "0.5230838", "0.5230364", "0.52200544", "0.5214429", "0.52129567", "0.5211464", "0.5194285", "0.5193844", "0.5193401", "0.51877755", "0.51843965", "0.51804554", "0.51742077", "0.51726294", "0.51524436", "0.5146588", "0.5140739", "0.5138498", "0.51369053" ]
0.0
-1
Use callbacks to share common setup or constraints between actions.
def set_url @url = Url.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_eval do\n define_method(:valid?) do |*args|\n self.class.state_machines.fire_event_attributes(self, :save, false) { super(*args) }\n end\n end\n end\n end", "def add_actions; end", "def callbacks; end", "def callbacks; end", "def setup *actions, &proc\n (@setup_procs ||= []) << [proc, actions.size > 0 ? actions : [:*]]\n end", "def define_action_helpers; end", "def post_setup\n end", "def action_methods; end", "def action_methods; end", "def action_methods; end", "def before_setup; end", "def action_run\n end", "def execute(setup)\n @action.call(setup)\n end", "def define_action_helpers?; end", "def set_actions\n actions :all\n end", "def action_done(action)\n dispatch = { :migrate => :done_migrating, :map => :done_mapping, :reduce =>\n :done_reducing, :finalize => :done_finalizing } \n self.send dispatch[action[:action]], action\n end", "def dependencies action, &block\n @actions.each do |other|\n if action[:requires].include? other[:provide]\n block.call other\n end\n end\n end", "def setup!\n return unless @setup_procs\n http_actions = actions\n @setup_procs.each do |setup_proc|\n proc, actions = setup_proc\n @setup__actions = actions.map do |action|\n\n action.is_a?(Regexp) ?\n http_actions.select { |a| a.to_s =~ action } :\n action.is_a?(String) && action =~ /\\A\\./ ?\n http_actions.map { |a| a.to_s << action if format?(a).include?(action) }.compact :\n action\n\n end.flatten\n self.class_exec &proc\n @setup__actions = nil\n end\n @setup_procs = nil\n end", "def setup_handler\n end", "def before_actions(*logic)\n self.before_actions = logic\n end", "def set_action(opts)\n opts = check_params(opts,[:actions])\n super(opts)\n end", "def setup(action)\n @targets.clear\n unless action.item.target_filters.empty?\n @targets = SES::TargetManager.make_targets(action)\n else\n item = action.item\n if item.for_opponent?\n @targets = $game_troop.alive_members\n elsif item.for_dead_friend?\n @targets = $game_party.battle_members.select { |actor| actor.dead? }\n else\n $game_party.battle_members.select { |actor| actor.alive? }\n end\n end\n @item_max = @targets.size\n create_contents\n refresh\n show\n activate\n end", "def action; end", "def action; end", "def action; end", "def action; end", "def action; end", "def revisable_shared_setup(args, block)\n class << self\n attr_accessor :revisable_options\n end\n options = args.extract_options!\n self.revisable_options = Options.new(options, &block)\n \n self.send(:include, Common)\n self.send(:extend, Validations) unless self.revisable_options.no_validation_scoping?\n self.send(:include, WithoutScope::QuotedColumnConditions)\n end", "def workflow\n end", "def setup\n @action = SampleActionAndroid.new(os_name: 'android',\n app_name: APP_PATH)\n end", "def before(action)\n invoke_callbacks *self.class.send(action).before\n end", "def process_action(...)\n send_action(...)\n end", "def before_dispatch(env); end", "def setup\n # override and do something appropriate\n end", "def after_actions(*logic)\n self.after_actions = logic\n end", "def setup(client)\n return unless @setup\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n actions.each do |action|\n action.execute(client)\n end\n self\n end", "def setup(_context)\n end", "def setup(resources) ; end", "def validate_actions\n errors.add(:base, :should_give_at_least_one_action) if !manage? && !forecasting? && !read? && !api?\n end", "def setup\n @resource_config = {\n :callbacks => {\n :before_create => nil,\n :after_create => nil,\n :before_update => nil,\n :after_update => nil,\n :before_destroy => nil,\n :after_destroy => nil,\n },\n :child_assoc => nil,\n :model => nil,\n :parent => nil,\n :path => nil,\n :permission => {},\n :properties => {},\n :relation => {\n :create => nil,\n :delete => nil,\n },\n :roles => nil,\n }\n end", "def determine_valid_action\n\n end", "def process_shared\n handle_taxes\n handle_shippings\n create_adjustments_from_params\n handle_status\n handle_inventory_refunds\n handle_payment_transactions\n order.updater.update\n end", "def init_actions\n am = action_manager()\n am.add_action(Action.new(\"&Disable selection\") { @selection_mode = :none; unbind_key(32); bind_key(32, :scroll_forward); } )\n am.add_action(Action.new(\"&Edit Toggle\") { @edit_toggle = !@edit_toggle; $status_message.value = \"Edit toggle is #{@edit_toggle}\" })\n end", "def startcompany(action)\n @done = true\n action.setup\n end", "def event_callbacks(event, metadata={})\n case event\n when :reset, :review\n if confirmed\n update_attributes(confirmed: false)\n end\n when :confirm\n confirm\n # trigger :order for all applicable items\n # NOTE: :order event is common to both physical and digital items\n items.each do |i|\n if i.event_permitted(:order)\n user_id = last_transition.user_id\n i.trigger!(:order, { order_id: id, user_id: user_id })\n end\n end\n when :complete_work\n request = metadata[:request]\n work_complete_notification(request)\n when :close\n close\n end\n if event != :close && !open\n reopen\n end\n end", "def setup_action\n return unless PONY::ERRNO::check_sequence(current_act)\n new_sequence = @action_sequence[@sequence_index+1...@action_sequence.size]\n @sequence_index = 0\n new_sequence = DND::SkillSequence::ACTS[@acts[1]] + new_sequence\n execute_sequence\n end", "def define_tasks\n define_weave_task\n connect_common_tasks\n end", "def setup(&block)\n define_method(:setup, &block)\n end", "def setup\n transition_to(:setup)\n end", "def setup\n transition_to(:setup)\n end", "def action\n end", "def setup( *args )\n\t\t\tself.class.setupBlocks.each {|sblock|\n\t\t\t\tdebugMsg \"Calling setup block method #{sblock}\"\n\t\t\t\tself.send( sblock )\n\t\t\t}\n\t\t\tsuper( *args )\n\t\tend", "def config(action, *args); end", "def setup\n @setup_proc.call(self) if @setup_proc\n end", "def before_action \n end", "def setup_callbacks\n defined_callbacks.each do |meth|\n unless respond_to?(\"call_#{meth}_callbacks\".to_sym)\n self.class.module_eval <<-EOE\n def call_#{meth}_callbacks(*args)\n plugin_store.each {|a| a.call_#{meth}_callbacks(*args) } if respond_to?(:plugin_store) && plugin_store\n self.send :#{meth}, *args if respond_to?(:#{meth})\n end\n EOE\n end\n end\n end", "def action\n end", "def matt_custom_action_begin(label); end", "def setup\n # override this if needed\n end", "def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend", "def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend", "def action(options,&callback)\n new_action = Action===options ? options : Action.new(options,&callback)\n # replace any with (shared name/alias or both default) + same arity\n @actions.delete_if do |existing_action|\n ((existing_action.names & new_action.names).size > 0 ||\n existing_action.default? && new_action.default?) &&\n existing_action.required.size == new_action.required.size &&\n existing_action.optional.size <= new_action.optional.size\n end\n @actions = (@actions + [new_action]).sort\n new_action\n end", "def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action\n end", "def after(action)\n invoke_callbacks *options_for(action).after\n end", "def pre_task\n end", "def setup(server)\n server.on('beforeMethod', method(:before_method), 10)\n end", "def add_actions\n attribute = machine.attribute\n name = self.name\n \n owner_class.class_eval do\n define_method(name) {self.class.state_machines[attribute].events[name].fire(self)}\n define_method(\"#{name}!\") {self.class.state_machines[attribute].events[name].fire!(self)}\n define_method(\"can_#{name}?\") {self.class.state_machines[attribute].events[name].can_fire?(self)}\n end\n end", "def init_actions\n @select_action = SelectAction.new\n @endpoint_mouse_action = EndpointMouseAction.new\n @move_action = MoveAction.new\n end", "def setup_signals; end", "def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend", "def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend", "def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action.respond_to?('weak!') ? action.weak! : action\n end", "def initialize(*args)\n super\n @action = :set\nend", "def setup\n #implement in subclass;\n end", "def after_set_callback; end", "def lookup_action; end", "def setup &block\n if block_given?\n @setup = block\n else\n @setup.call\n end\n end", "def setup_action\n return TSBS.error(@acts[0], 1, @used_sequence) if @acts.size < 2\n actions = TSBS::AnimLoop[@acts[1]]\n if actions.nil?\n show_action_error(@acts[1])\n end\n @sequence_stack.push(@acts[1])\n @used_sequence = @acts[1]\n actions.each do |acts|\n @acts = acts\n execute_sequence\n break if @break_action\n end\n @sequence_stack.pop\n @used_sequence = @sequence_stack[-1]\n end", "def release_actions; end", "def setup(easy)\n super\n easy.customrequest = @verb\n end", "def around_hooks; end", "def save_action; end", "def action_target()\n \n end", "def setup\n callback(:setup) do\n notify(:setup)\n migration_check.last_deployed_commit\n end\n end", "def setup\n return unless @setup\n\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n run_actions_and_retry(actions)\n self\n end", "def before_setup\n # do nothing by default\n end", "def my_actions(options)\n @setup = false\n get_template_part(\"custom_used\",\"action_users\",true)\n end", "def default_action; end", "def setup(&blk)\n @setup_block = blk\n end", "def callback_phase\n super\n end", "def advice\n end", "def _handle_action_missing(*args); end", "def shared_action(name, &block)\n @controller.shared_actions[name] = block\n end", "def setup_initial_state\n\n state_a = State.new(\"a\", 0)\n state_b = State.new(\"b\", 0)\n state_c = State.new(\"c\", 10)\n\n move_to_b = Action.new(\"move_to_b\", 1, state_b)\n\n move_to_c = Action.new(\"move_to_c\", 1, state_c)\n\n state_a.actions = [move_to_b, move_to_c]\n\n return state_a\n \nend", "def before_action action, &block\n @audience[:before][action] ||= Set.new\n @audience[:before][action] << block\n end", "def duas1(action)\n action.call\n action.call\nend" ]
[ "0.6165152", "0.60463154", "0.59467196", "0.5917112", "0.5890387", "0.58345735", "0.57773316", "0.56991524", "0.56991524", "0.565454", "0.5622282", "0.54232633", "0.54119074", "0.54119074", "0.54119074", "0.53937256", "0.53801376", "0.5358599", "0.53412294", "0.5340814", "0.53314966", "0.53114754", "0.52984965", "0.52977055", "0.5296272", "0.5260649", "0.5245076", "0.52388334", "0.52388334", "0.52388334", "0.52388334", "0.52388334", "0.5235081", "0.52321917", "0.5228592", "0.5220735", "0.52198535", "0.52139324", "0.5208539", "0.5206585", "0.5178542", "0.5175199", "0.5173538", "0.5167041", "0.51614195", "0.51577675", "0.5153909", "0.51528823", "0.5152225", "0.51429904", "0.5141399", "0.51345575", "0.51145", "0.5114052", "0.5114052", "0.5110216", "0.5108656", "0.50935394", "0.5089196", "0.5081936", "0.5079627", "0.50675833", "0.5056105", "0.5053687", "0.5050475", "0.5050475", "0.503471", "0.5028311", "0.501982", "0.50157547", "0.5013552", "0.50014806", "0.50011593", "0.49976763", "0.4990292", "0.4990292", "0.49882022", "0.4981269", "0.49792367", "0.49766538", "0.4967978", "0.49667212", "0.4958987", "0.49572337", "0.49550423", "0.4954479", "0.4952353", "0.494726", "0.4944055", "0.4935437", "0.4931248", "0.49283475", "0.49281213", "0.49268973", "0.4921738", "0.49204507", "0.4918924", "0.49182287", "0.4916538", "0.49158585", "0.49156788" ]
0.0
-1