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
require 'rubygems' require 'oauth' require 'json'
def constantize(string) return string.downcase.gsub(/[^a-z]/i, '') end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def do_requires()\n require 'rack'\n require './lib/my_thin.rb'\n require './android_translation_helper.rb'\nend", "def require_gems; end", "def initialize\n require 'open-uri'\n require 'json'\n optional_gem 'jsonpath'\n end", "def conscientious_require; end", "def initialize\n super\n\t \n require 'base64'\n require 'digest'\n require 'json'\n require 'net/http'\n require 'net/https'\n require 'openssl'\n require 'rexml/document'\n require 'securerandom'\n require 'socket'\n require 'uri'\n require_relative 'omslog'\n require_relative 'oms_configuration'\n require_relative 'oms_common'\n end", "def initialize\n require 'rubygems'\n require 'net-ldap'\n require 'cicphash'\n end", "def require_lib(*libs); end", "def require(*args)\n super\n case args\n when [\"stripe\"]\n # so we don't have to shell out to uname\n ::Stripe.class_variable_set(:@@uname, 'Linux Codecademy codex-adapter x86_64 GNU/Linux')\n\n # gem hard-codes their own bundled ca file, which we need to override\n ::Stripe.class_variable_set(:@@ssl_bundle_path, '/etc/ssl/certs/ca-certificates.crt')\n when [\"twilio-ruby\"]\n Twilio::REST::Client::DEFAULTS[:ssl_ca_file] = '/etc/ssl/certs/ca-certificates.crt'\n end\n end", "def initialize\n super\n require 'ipaddr'\n require 'socket'\n require 'openssl'\n require 'digest'\n require 'securerandom'\n end", "def require(name)\n Kernel.require name\nend", "def r(*gems)\n gems.map {|g| require g.to_s}\nend", "def require_libs(*libs); end", "def load_minimal_gems\r\n end", "def require_with_grace(r) require r; rescue LoadError; block_given? ? yield : abort(\"#{$!.message}\\n\\n try executing: gem install '#{r}'\") end", "def gems; end", "def gems; end", "def gems; end", "def require_bossman\n begin\n require 'bossman'\n require 'open-uri'\n true\n rescue LoadError\n nil\n end\n end", "def require path\n JsObj.get(\"Ruby.require\").call path\n nil\nrescue\n super\nend", "def require path\n JsObj.get(\"Ruby.require\").call path\n nil\nrescue\n super\nend", "def local_requires\n require \"talia_cl\"\nend", "def initialize\n require 'json'\n optional_gem 'redis'\n end", "def require_gtk2\n require \"gtk2\"\n \n #For msgbox and translation of windows.\n require \"knj/gtk2\"\n \n #For easy initialization, getting and settings of values on comboboxes.\n require \"knj/gtk2_cb\"\n \n #For easy initialization, getting and settings of values on treeviews.\n require \"knj/gtk2_tv\"\n \n #For easy making status-windows with progressbar.\n require \"knj/gtk2_statuswindow\"\n end", "def require_library(name)\n require File.expand_path(File.join(\n File.dirname(__FILE__), '../../../../libraries', \"#{name}.rb\"\n ))\nend", "def gemspec; end", "def gemspec; end", "def gemspec; end", "def gemspec; end", "def gemspec; end", "def gemspec; end", "def gemspec; end", "def gemspec; end", "def require_without_bundler(*gems)\n unless defined?(::Bundler)\n gems.each { |g| require g }\n return\n end\n Dir.glob(\"#{Gem.path.first}/gems/*\").map { |gem_path| \n gem_name=File.basename(gem_path).gsub(/-(\\d\\.?)+$/,'')\n if gems.include?(gem_name)\n $LOAD_PATH << \"#{gem_path}/lib\"\n require gem_name\n end\n }\nend", "def library; end", "def library; end", "def require!\n super do\n gem @gem_name, @version if @version\n end\n end", "def require(p0) end", "def local_require(lib)\n load_local_gem(lib)\n require(lib)\n end", "def test_requires\n assert_nothing_raised do\n require 'msfrpc-client'\n end\n end", "def ruby_can_load(*files)\n # Always include rubygems first\n files = files.unshift('rubygems').collect { |x| \"require '#{x}'\" }\n \n @commands << \"ruby -e \\\"#{files.join(';')}\\\"\"\n end", "def load_gems(an_array_of_strings)\n\n print \"Installing gems as necessary ... \" if $debug\n gemfile do\n source 'https://rubygems.org'\n Array(an_array_of_strings).each do |gem_name|\n print gem_name + ' ' if $debug\n gem gem_name\n end\n end\n\n puts 'done' if $debug\n\nend", "def require_paths; end", "def require_paths; end", "def require(path)\n require__ path\n rescue LoadError => load_error\n begin\n @gempath_searcher ||= Gem::GemPathSearcher.new\n if spec = @gempath_searcher.find(path)\n Gem.activate(spec.name, true, \"= #{spec.version}\")\n require__ path\n else\n\traise load_error\n end\n end\n end", "def use_oauth\n\t\t\t\n\t\tend", "def ruby_can_load(*files)\n # Always include rubygems first\n files = files.unshift('rubygems').collect { |x| \"require '#{x}'\" }\n \n @commands << \"ruby -e \\\"#{files.join(';')}\\\"\"\n end", "def require(options={})\n options[:require] = true\n load(options)\n end", "def libs; end", "def check_gem # --- CHECK FOR MISSING GEMS\n begin\n\t gem 'em-websocket'\n rescue Gem::LoadError\n\t puts \"IT APPEARS YOU ARE MISSING THE SOCKET GEM\"\n puts \"TO INSTALL IT TYPE 'gem install em-websocket'\"\n\telse\n\t\t#donothing\n\tend\n\n\tbegin\n\t\tgem 'net-ping', '>=1.7.8'\n\trescue Gem::LoadError\n\t\tputs \"IT APPEARS THAT YOU ARE MISSING THE NET-PING GEM\"\n puts \"TO INSTALL IT TYPE 'gem install net-ping'\"\n\telse\n\t\t#donothing\n\tend\nend", "def rq(lib)\n require lib.to_s\n end", "def configure(conf)\n super\n require 'msgpack'\n require 'net/http'\n end", "def require( library_name )\n\tbegin\n\t\tMockFS.mock = false\n\t\tsuper\n\t\tMockFS.mock = true\n\trescue LoadError => err\n\t\tMockFS.mock = true\n\t\tfile = library_name\n\t\tfile += '.rb' unless library_name =~ /\\.rb$/\n\t\tif File.exist? file\n\t\t\tcontents = File.open( file ) do |f| f.gets( nil ); end\n\t\t\teval contents\n\t\telse\n\t\t\traise\n\t\tend\n\tend\nend", "def load_gem_plugins; end", "def require(file)\n begin\n rsc_original_require file\n rescue LoadError\n rsc_require file\n end\nend", "def safe_require(file)\n require file\nrescue LoadError\n # ignore\nend", "def safe_require(file)\n require file\nrescue LoadError\n # ignore\nend", "def load_dependencies\n begin\n require 'cairo'\n rescue LoadError\n require 'rubygems'\n begin\n require 'cairo'\n rescue LoadError\n puts \"Compass::Canvas\\n_______________\\n\\n\"\n puts \"Unable to load Cairo backend. Please install it with the following command:\\n\\n\"\n puts \" gem install cairo\\n\\n\"\n puts \"For more information, please visit https://github.com/rcairo/rcairo\"\n raise\n end\n end\n end", "def create_app()\n file=File.open(\"app.rb\", \"w\")\n file.puts(\"require 'bundler'\")\n file.puts(\"Bundler.require\")\n file.puts(\"\")\n file.puts(\"require_relative 'lib/...'\")\n file.close\n create_readme()\nend", "def initialize\n require 'open-uri'\n optional_gem 'nokogiri'\n end", "def generate_require_paths; end", "def opal_require name\n require_symbol{:name}\n (config.opal_dir + \"#{name}.rb\").read\n end", "def require(file, *extras) #:nodoc:\n super(file, *extras)\n end", "def common_pods\n pod 'AppAuth', '0.9.1'\n pod 'Alamofire', '4.5'\n pod 'ObjectMapper', '3.0.0'\n pod 'SwiftKeychainWrapper', '3.0.1'\n pod 'ReachabilitySwift', '3'\nend", "def app_require(file)\n require File.expand_path(file)\nend", "def oauth_authentication; end", "def load_libs; end", "def load_gem(name, version=nil)\n # needed if your ruby version is less than 1.9\n require 'rubygems'\n\n begin\n gem name, version\n rescue LoadError\n version = \"--version '#{version}'\" unless version.nil?\n system(\"gem install #{name} #{version}\")\n Gem.clear_paths\n retry\n end\n\n require name\nend", "def load_gem(name, version=nil)\n # needed if your ruby version is less than 1.9\n require 'rubygems'\n\n begin\n gem name, version\n rescue LoadError\n version = \"--version '#{version}'\" unless version.nil?\n system(\"gem install #{name} #{version}\")\n Gem.clear_paths\n retry\n end\n\n require name\nend", "def load_gem(name, version=nil)\n # needed if your ruby version is less than 1.9\n require 'rubygems'\n\n begin\n gem name, version\n rescue LoadError\n version = \"--version '#{version}'\" unless version.nil?\n system(\"gem install #{name} #{version}\")\n Gem.clear_paths\n retry\n end\n\n require name\nend", "def initialize\n load_site\n load_creds\n end", "def gemspecs; end", "def configured_require_paths; end", "def require_faux_gem\n rel_main = \"./#{real_main_file_name}\"\n Dir.chdir( folder_lib ){\n require \"./#{real_main_file_name}\"\n }\n end", "def require_external(library)\n\n # Get the current debug level so we can set it back again afterwards.\n debug_level = $DEBUG\n $DEBUG = false\n require(library)\n $DEBUG = debug_level\nend", "def main\n last_good_root = from_file($cache_dir + '/root.txt') ||\n from_file('config/root.txt') ||\n raise(\"Can't find root.txt\")\n\n repository = Gem::TUF::Repository.new(\n root: JSON.parse(last_good_root),\n bucket: FileCachingBucket.new(HttpBucket.new($host))\n )\n\n gem_name = ARGV.shift\n\n specs = repository.target('latest_specs.4.8.gz')\n raise \"could not find latest_specs.4.8.gz\" unless specs\n specs = unmarshal_gz specs\n gem = specs.detect {|x| x[0] == gem_name } || raise(\"Can't find gem #{gem}\")\n\n gem_with_version = \"#{gem[0]}-#{gem[1]}\"\n gem_path = \"gems/#{gem_with_version}.gem\"\n gemspec_path = \"quick/Marshal.4.8/#{gem_with_version}.gemspec.rz\"\n\n repository.target(gemspec_path)\n repository.target(gem_path)\n\n puts \"Downloaded #{gem_path} and #{gemspec_path}\"\nend", "def require path \n if File.exist?(path) and !File.directory?(path)\n elsif File.exist?(tmp = path+\".rb\")\n path = tmp\n elsif File.exist?(tmp = path+\".mrb\") \n path = tmp\n elsif $:.is_a?(Array)\n $:.each do |dir|\n if File.exist?(tmp = \"#{dir}/#{path}\") and !File.directory?(tmp)\n path = tmp\n next\n elsif File.exist?(tmp = \"#{dir}/#{path}.rb\")\n path = tmp\n next\n elsif File.exist?(tmp = \"#{dir}/#{path}.mrb\")\n path = tmp\n next\n end \n end\n end \n\n if [\"rb\", \"mrb\"].index(q = path.split(\".\").last) \n \n path = File.expand_path(path)\n \n if REQUIRED_LIBS[path]\n return false\n end\n\n REQUIRED_LIBS[path = File.expand_path(path)] = true\n end\n \n if q == \"rb\"\n __eval__ \"JAM_MAIN_HANDLE.loadScriptFull __mrb_context__, '#{path}'\"\n return true\n elsif q == \"mrb\"\n __eval__ \"JAM_MAIN_HANDLE.loadCompiledFull __mrb_context__, '#{path}'\"\n return true\n else\n __jam_require__ path\n end\n rescue => e\n p e\n raise e\n end", "def initialize\n optional_gem 'dbd-sqlite3', requires: 'dbd/SQLite3'\n optional_gem 'activerecord', '~> 4.0', requires: 'active_record'\n optional_gem 'dbi'\n optional_gem 'sqlite3'\n end", "def private_gem(name)\n gem name, '0.3.0', git: \"https://#{ENV['GITHUB_TOKEN']}:x-oauth-basic@github.com/mharris717/#{name}.git\", branch: :master\nend", "def load_lab_app_lib_files\n libFiles = File.dirname(__FILE__) + \"/../lib/*.rb\"\n Dir[libFiles].each do |file|\n fullpath = File.expand_path(file)\n puts \"Loading your file #{fullpath}\"\n require fullpath\n end\n end", "def require!(_file_)\n raise 'must implement'\n end", "def gemspec?; end", "def vendor_dependencies\n fetch_bundler\n bundle_install\n end", "def requires\n require_items.collect(&:package)\n end", "def standard_dependencies\n gem 'yard'\n gem 'ffi'\n\n group :development, :testing do\n gem 'jruby-openssl', platforms: :jruby\n gem 'json', platforms: :jruby\n gem 'rspec', '~> 3.12'\n gem 'activesupport', '<7.1'\n gem 'rake'\n gem 'webrick'\n\n gem 'byebug', platforms: :mri\n gem 'ruby-debug', platforms: :jruby\n\n gem 'aws-sdk-core', '~> 3'\n gem 'aws-sdk-cloudwatchlogs'\n gem 'aws-sdk-ec2'\n gem 'aws-sdk-ecs'\n gem 'aws-sdk-iam'\n gem 'aws-sdk-sts'\n gem 'paint'\n\n # for benchmark tests\n gem 'yajl-ruby', platforms: :mri, require: false\n gem 'celluloid', platforms: :mri, require: false\n\n # for static analysis -- ignore ruby < 2.6 because of rubocop\n # version incompatibilities\n if RUBY_VERSION > '2.5.99'\n gem 'rubocop', '~> 1.45.1'\n gem 'rubocop-performance', '~> 1.16.0'\n gem 'rubocop-rake', '~> 0.6.0'\n gem 'rubocop-rspec', '~> 2.18.1'\n end\n\n platform :mri do\n # Debugger for VSCode.\n if !ENV['CI'] && !ENV['DOCKER'] && RUBY_VERSION < '3.0'\n gem 'debase'\n gem 'ruby-debug-ide'\n end\n end\n end\n\n group :testing do\n gem 'timecop'\n gem 'ice_nine'\n gem 'rubydns', platforms: :mri\n gem 'rspec-retry'\n gem 'rfc', '~> 0.2.0'\n gem 'fuubar'\n gem 'timeout-interrupt', platforms: :mri\n gem 'concurrent-ruby', platforms: :jruby\n gem 'dotenv'\n gem 'childprocess'\n end\n\n group :development do\n gem 'ruby-prof', platforms: :mri\n gem 'erubi'\n gem 'tilt'\n # solargraph depends on rbs, which won't build on jruby for some reason\n gem 'solargraph', platforms: :mri\n end\n\n gem 'libmongocrypt-helper', '~> 1.8.0' if ENV['FLE'] == 'helper'\nend", "def require_all(path)\n glob = File.join(File.dirname(__FILE__), path, '*.rb')\n Dir[glob].each do |f|\n require f\n end\nend", "def require_all(path)\n glob = File.join(File.dirname(__FILE__), path, '*.rb')\n Dir[glob].each do |f|\n require f\n end\nend", "def require_all(path)\n glob = File.join(File.dirname(__FILE__), path, '*.rb')\n Dir[glob].each do |f|\n require f\n end\nend", "def require_all(path)\n glob = File.join(File.dirname(__FILE__), path, '*.rb')\n Dir[glob].each do |f|\n require f\n end\nend", "def require_all(path)\n glob = File.join(File.dirname(__FILE__), path, '*.rb')\n Dir[glob].each do |f|\n require f\n end\nend", "def require_all(path)\n glob = File.join(File.dirname(__FILE__), path, '*.rb')\n Dir[glob].each do |f|\n require f\n end\nend", "def require_all(path)\n glob = File.join(File.dirname(__FILE__), path, '*.rb')\n Dir[glob].each do |f|\n require f\n end\nend", "def require_all(path)\n glob = File.join(File.dirname(__FILE__), path, '*.rb')\n Dir[glob].each do |f|\n require f\n end\nend", "def require_all(path)\n glob = File.join(File.dirname(__FILE__), path, '*.rb')\n Dir[glob].each do |f|\n require f\n end\nend", "def require_all(path)\n glob = File.join(File.dirname(__FILE__), path, '*.rb')\n Dir[glob].each do |f|\n require f\n end\nend", "def require_all(path)\n glob = File.join(File.dirname(__FILE__), path, '*.rb')\n Dir[glob].each do |f|\n require f\n end\nend", "def require_all(path)\n glob = File.join(File.dirname(__FILE__), path, '*.rb')\n Dir[glob].each do |f|\n require f\n end\nend", "def install_gem; end", "def generate_require_files_for_individual_gems\n puts 'Generating require files for individual gems'\n generate_require_files_for_gem(@mgmt_sdks_location)\n generate_require_files_for_gem(@data_sdks_location)\n end", "def require(*files)\n files.each do |file|\n evaluate(\"Johnson.require('#{file}');\")\n end\n end", "def require(*files)\n files.each do |file|\n evaluate(\"Johnson.require('#{file}');\")\n end\n end", "def require_plugin_files; end" ]
[ "0.68832314", "0.68214726", "0.6669958", "0.6621294", "0.6595564", "0.6489403", "0.61675406", "0.59948546", "0.5968073", "0.59416384", "0.5909711", "0.584697", "0.58180296", "0.5717908", "0.56910926", "0.56910926", "0.56910926", "0.56513876", "0.5647925", "0.5647925", "0.564075", "0.56116253", "0.55904245", "0.555633", "0.5546599", "0.5546599", "0.5546599", "0.5546599", "0.5546599", "0.5546599", "0.5546599", "0.5546599", "0.55324787", "0.5512553", "0.5512553", "0.5503619", "0.54797655", "0.54790044", "0.5459702", "0.54559374", "0.545586", "0.5437775", "0.5437775", "0.5435255", "0.5429617", "0.5418612", "0.5412935", "0.54107946", "0.53764665", "0.5369112", "0.53455526", "0.5323194", "0.5321918", "0.5304227", "0.5297415", "0.5297415", "0.52888346", "0.528806", "0.5285906", "0.52829134", "0.5281168", "0.5278168", "0.5256716", "0.5253919", "0.52240664", "0.52179027", "0.52084404", "0.52084404", "0.52084404", "0.520676", "0.5191091", "0.5189671", "0.5158575", "0.51480734", "0.5147313", "0.51447695", "0.5142155", "0.51342577", "0.51195395", "0.5106169", "0.51007545", "0.50980175", "0.50889367", "0.5085521", "0.50820804", "0.50820804", "0.50820804", "0.50820804", "0.50820804", "0.50820804", "0.50820804", "0.50820804", "0.50820804", "0.50820804", "0.50820804", "0.50820804", "0.50667214", "0.50666165", "0.5060761", "0.5060761", "0.5053014" ]
0.0
-1
GET /pagina_principals GET /pagina_principals.json
def index @pagina_principals = PaginaPrincipal.all def index if( !(session[:cafe] != nil && session[:cafe] != '') ) redirect_to '/' end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @slider_principals = SliderPrincipal.all\n end", "def index\n @usuarios = Usuario.paginate(page: params[:page])\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @usuarios }\n end\n end", "def index\n @unidades = current_user.empresa.unidades.page params[:page]\n end", "def index\n #@usuarios = User.all.order_by([:email, :asc]).paginate(:page => params[:page], :per_page => @@page)\n @usuarios = User.accessible_by(current_ability).order_by([:email, :asc]).paginate(:page => params[:page], :per_page => @@page)\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @usuarios }\n end\n end", "def set_pagina_principal\n @pagina_principal = PaginaPrincipal.find(params[:id])\n end", "def index\n @ventas_presupuestos = Ventas::Presupuesto.paginate(:page => params[:page], :per_page => 5)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ventas_presupuestos }\n end\n end", "def index\n @roles = Role.page params[:page]\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @roles}\n end\n end", "def search_principals(prefix_path, search_properties, test = 'allof')\n end", "def index\n @pizarras = current_user.pizarras.paginate :page => params[:page],:per_page => 5 \n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @pizarras }\n end\n end", "def index\n authorize! :index, Notificacao\n @notificacoes = Notificacao.where(usuario_curso: @perfil.id).order('id desc').page(params[:page])\n end", "def index\n @pt_accounts = current_user.pt_accounts.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @pt_accounts }\n end\n end", "def index\n @relatorio_pedagogicos = RelatorioPedagogico.all.page(params[:page]).per(15)\n authorize @relatorio_pedagogicos\n end", "def grab_professors\n professor_size = User.where(:professor => true).length\n current_offset = (params[:payload][:pagenumber] - 1)*10\n direction = params[:payload][:direction]\n\n respond_to do |format|\n format.json {\n\n if current_offset + direction < professor_size && current_offset + direction >= 0\n offset = current_offset + direction\n @professors = User.where(:professor => true).offset(offset).take(10)\n render :json => @professors\n else\n render :nothing => true, :status => 200, :content_type => 'text/html'\n end\n\n }\n end\n end", "def index\n \n @listadeprecios = current_user.empresa.listadeprecios.page params[:page]\n cookies[:current_page] = params[:page]\n \n end", "def get_principal(filter = nil, sort = nil)\n puts \"ACS: get_principal\"\n res = query(\"principal-list\", \n \"filter\" => filter, \n \"sort\" => sort)\n\n return res.body\n end", "def service_principals()\n return MicrosoftGraph::ServicePrincipals::ServicePrincipalsRequestBuilder.new(@path_parameters, @request_adapter)\n end", "def index\n if current_user.nil?\n redirect_to(log_in_path) and return\n end\n\n @personas_vinculadas = PersonaVinculada.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @personas_vinculadas }\n end\n end", "def index\n if isAdmin?\n @title= \"Listing All Professors\"\n @users = User.where('role' => 2).paginate(page: params[:page])\n if(!@users.any?)\n flash[:notice]= \"No professor on CMS. To create a new professor click on Create New Professor\"\n end\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @users }\n end\n else\n flash[:notice]= \"You don't have permission to browse all users\"\n redirect_to courses_path\n end\n end", "def index\n @people = User.order(:nickname).page(params[:page])\n\n respond_to do |format|\n format.html # index.html.haml\n format.json { render :json => @people }\n end\n end", "def valid_principals; end", "def index\n @ideas = current_user.ideas.page(params[\"page\"])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ideas }\n end\n end", "def index\n render json: AuthIpAddressGroup.paginate(page: params[:page], per_page: 25)\n end", "def index\n @accounts = current_user.person.linked_in_accounts\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @accounts }\n end\n end", "def index\n @pagamentos = Pagamento.page(params[:page]).per(NUMERO_POR_PAGINA)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @pagamentos }\n end\n end", "def mostrar_pag_apresentacao\n if @permissao === \"admin\" or @permissao === \"autenticado\" or @permissao === \"convidado\"\n puts \"esta é a pág de apresentação do usuario #{@email}\"\n else\n puts \"vc nao tem permissao para acessar esta página!\"\n end\n end", "def index\n\tperfilId = session[:perfilLogado]\n\n\tif(perfilId)\n\t\tperfil = Perfil.find(perfilId)\n\n\t\trender :json => perfil.grupos.to_json(), :callback => params['callback']\n\tend\n end", "def index\n @roles = Role.paginate(:page => params[:page], per_page: 30)\n @number = Role.count\n\n respond_to do |format|\n format.html\n format.json { render :json => Role.all }\n end\n end", "def index\n @accounts = Account.paginate(page: params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @accounts }\n end\n end", "def index\n @users = User.paginate(page: params[:page], per_page:50)\n render json: @users, status: :ok\n end", "def index\n @os_groups_principals = OsGroupsPrincipal.all\n end", "def show_patrons\r\n @patrons_pages, @patrons = paginate(:users, \r\n :conditions => ['level = 0'],\r\n :order => 'username') \r\n end", "def index\n if logged_in?\n @pannes = Panne.paginate(page: params[:page], :per_page => 10)\n else\n redirect_to home_url\n end\n end", "def pages\n get(\"v1/account/#{@email}/pages\")\n end", "def index\n @usuario_perfils = UsuarioPerfil.all\n end", "def list_farm_puc_accounts\n\treturn if authorise_for_web(program_name?,'read') == false \n\n \tif params[:page]!= nil \n\n \t\tsession[:farm_puc_accounts_page] = params['page']\n\n\t\t render_list_farm_puc_accounts\n\n\t\t return \n\telse\n\t\tsession[:farm_puc_accounts_page] = nil\n\tend\n\n\tlist_query = \"@farm_puc_account_pages = Paginator.new self, FarmPucAccount.count, @@page_size,@current_page\n\t @farm_puc_accounts = FarmPucAccount.find(:all,\n\t\t\t\t :limit => @farm_puc_account_pages.items_per_page,\n\t\t\t\t :offset => @farm_puc_account_pages.current.offset)\"\n\tsession[:query] = list_query\n\trender_list_farm_puc_accounts\nend", "def index\n @account = Account.find(params[:account_id])\n @users = @account.users\n respond_to do |format|\n format.json { render json: @account.users.paginate(page: @page, per_page: @per_page) }\n end\n end", "def index\n \n @users = User.page(params[:page]).per_page(14)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @users }\n end\n \n end", "def pages()\n get('subAccountPages')\n end", "def index\n @anuncios = Anuncio.all.paginate(page: params[:page], per_page: 4 )\n\n respond_to do |format|\n format.html\n format.json { render json: @jobs }\n end\n end", "def index\n @iniciadores = Iniciador.paginate(page: params[:page], per_page:10).all.order(:razon_social)\n end", "def index\n @users = User.order(\"login ASC\")\n @users = @users.paginate :page => params[:page], :per_page => users_per_page\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @users }\n end\n end", "def index\n @accounts = Account.alumni.paginate(:page => params[:page], :per_page => 50)\n end", "def index\n page_num=params[:page]\n @users= User.page(page_num)\n render json: @users\n end", "def index_participating\n projects = current_user.projects.paginate(:page => params[:page])\n render json: projects\n end", "def show\n @coleccion = {}\n @coleccion['publicaciones'] = @objeto.publicaciones.page(params[:page])\n end", "def index\n @paniers = current_user.paniers.all\n end", "def show\n @servidor = Servidor.find(params[:id])\n @q = @servidor.pontos.ransack(params[:q])\n @q.sorts = 'nome'\n @pontos = @q.result.page params[:page]\n @autenticacoes = @servidor.autenticacoes.order(authdate: :desc).page params[:page]\n end", "def index\n @users = User.page params[:page]\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @users }\n end\n end", "def index\n @users = User.all\n authorize @users\n\n render json: @users\n end", "def index\n authorize! :ver, UsuarioPrestamo.new\n @usuarios_prestamos = UsuarioPrestamo.all\n @alumnos = UsuarioPrestamo.where(:categoria => UsuarioPrestamo.categorias[:alumno])\n @profesores = UsuarioPrestamo.where(:categoria => UsuarioPrestamo.categorias[:profesor])\n @personal = UsuarioPrestamo.where(:categoria => UsuarioPrestamo.categorias[:personal])\n end", "def index\n @accounts = policy_scope(Account)\n\n render json: @accounts, include: [:user]\n end", "def index\n auth_response = plaid_client.auth.get(access_token)\n render json: auth_response.to_json\n end", "def index\n @employee_associations = EmployeeAssociation.paginate(:page => params[:page], :per_page => 5)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @employee_associations }\n end\n end", "def index\n\t\t#params[:page]|| = 1\n\t\t@users = User.all.paginate(page: params[:page], per_page: 3)\n\t\tjson_success_response(@users)\n\tend", "def index\n authorize! :index, Por, :message => 'Acceso denegado.'\n @pors = @campus.pors.paginate(:per_page => 3, :page => params[:page])\n\t\t@points = @pors\n\t\t@point_name = \"por\"\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render \"points/index.json.erb\" } # index.json.erb\n end\n end", "def index\n if params[:propietario]\n @usuario = Usuario.find(params[:usuario_id])\n authorize! :show, @usuario\n @negocios_propios = Usuario.find(params[:usuario_id]).negocios_propios\n render json: @negocios_propios,\n root: 'negocios_propios',\n each_serializer: NegocioPropioSerializer\n else\n @negocios = Negocio.all\n render json: @negocios\n end\n end", "def index\n @accounts = current_user.person.phone_accounts\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @accounts }\n end\n end", "def api_v11_cm_kerberos_principals_get_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: DefaultApi#api_v11_cm_kerberos_principals_get ...\"\n end\n \n # resource path\n path = \"/api/v11/cm/kerberosPrincipals\".sub('{format}','json')\n\n # query parameters\n query_params = {}\n query_params[:'missingOnly'] = opts[:'missing_only'] if opts[:'missing_only']\n\n # header parameters\n header_params = {}\n\n # HTTP header 'Accept' (if needed)\n _header_accept = []\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 = []\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 if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: DefaultApi#api_v11_cm_kerberos_principals_get\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def index\n projects = current_user.admin_projects.paginate(:page => params[:page])\n render json: projects\n end", "def api_v11_cm_kerberos_principals_get(opts = {})\n api_v11_cm_kerberos_principals_get_with_http_info(opts)\n return nil\n end", "def index\n\t\tauthorize! :index, Presupuesto\n @presupuestos = Presupuesto.all\n end", "def all_principals\n (User.all + UserGroup.where_unit(unit).not(self)).sort { |a, b| a.name.downcase <=> b.name.downcase }\n end", "def index\n @accounts = current_user.person.gmail_accounts\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @accounts }\n end\n end", "def index\n page = params[:page] || 1\n\n @users = User.all.page(page)\n respond_to do |format|\n format.json\n format.html\n end\n end", "def index\n if not ( paziente_signed_in? or administrator_signed_in?)\n redirect_to root_path and return\n end\n @profilopazientis = Profilopazienti.all\n end", "def index\n\t\tauthorize! :index, EstadoPresupuesto\n @estado_presupuestos = EstadoPresupuesto.all\n end", "def index\n @people = Person.all\n respond_to do |format|\n format.json { \n render json: @people, :include => [:roles => { include: [:privileges] } ]\n }\n end\n end", "def index\n @relatorio_gerals = RelatorioGeral.all.page(params[:page]).per(15)\n authorize @relatorio_gerals\n end", "def index\n @formasdepagos = current_user.empresa.formasdepagos.page params[:page]\n end", "def index\n @usuarios = Usuario.por_colegio(colegio.id).order(\"nombre\")\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @usuarios }\n end\n end", "def index\n @users = User.all.page params[:page]\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @users }\n end\n end", "def physicians\n physicians = User.physicians\n render json: { status: 200, data: physicians }\n end", "def index\n @puntajes = Puntaje.paginate(:page => params[:page], :per_page => 10)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @puntajes }\n end\n end", "def index\n # @usuarios = @topico.perguntas.usuarios\n end", "def index\n @families = Family.all.paginate(page: params[:page])\n render json: @families\n end", "def all_accounts\n puts params[:id]\n accounts = []\n user = User.find params[:id]\n user.accounts.each do |f|\n accounts << {id:f.id, title: f.title}\n end\n render json: accounts\n end", "def index\n page = valid_page_or_one params[:page]\n @users = User.paginate(:page => page, :per_page => per_page).order('created_at DESC')\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @users }\n end\n end", "def index\n @instances = Instance.page params[:page]\n authorize! :read, @instances\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @instances }\n end\n end", "def index\n authorize! :read, Registro\n\n p = params[:page]\n @registros = Registro.order(\"created_at DESC\").paginate(page: p)\n end", "def extraer_lista_principio\n ref = @principio\n @principio = ref.siguiente\n if @principio != nil\n @principio.anterior = nil\n else\n @final = @principio\n end\n ref\n end", "def show\n authorize @accounts\n render json: @account\n end", "def show\n @principal_establec = PrincipalEstablec.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @principal_establec }\n end\n end", "def get_ponto\n render json: Usuario.ultimo_ponto(params[:user_id], params[:evento_id]).to_json\n end", "def index\n @users = User.paginate(page: params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @users }\n end\n end", "def owned\n @relations = @user.owned.paginate(page: params[:page], per_page: 10)\n respond_to do |format|\n format.html\n format.amp\n format.json\n format.js\n end\n end", "def index\n @publicaciones_para_mostrar = Array.new\n publicaciones = Announcement.aproved.reverse\n if current_user.is_oficial\n @publicaciones_para_mostrar = publicaciones\n else\n publicaciones.each do |publicacion|\n if publicacion.aprobada(current_user)\n @publicaciones_para_mostrar.push(publicacion)\n end\n end\n end\n @publicaciones_para_mostrar = @publicaciones_para_mostrar.paginate(page: params[:page], per_page: 1)\n\n respond_to do |format|\n format.html\n format.js\n end\n end", "def index\n @granted_scopes = GrantedScope.paginate(:page => params[:page], :per_page => 100)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @granted_scopes }\n end\n end", "def index\n @principalgroupes = Principalgroupe.all\n end", "def index\n @profiles = Profile.all.paginate :page => params[:page], :per_page => 3\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @profiles }\n end\n end", "def index\n @users = User.paginate(:page => params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @users }\n end\n end", "def index\n users = policy_scope(User)\n render json: { users: users }\n end", "def index\n @permitions = Permition.all.page(params[:page]).per(10)\n @page = params[:page]\n @page = 1 if @page.blank?\n end", "def show\n @persona = Persona.find(params[:id])\n @users = User.all\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @persona }\n end\n end", "def index\n @personas = Persona.all\n @users = User.all\n\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @personas }\n end\n end", "def index\n @prayers = Prayer.where(\"user_id = ?\", getUser())\n\n @prayer_requests = PrayerRequest.all \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @prayers }\n end\n end", "def index\n @pagos_publicidads = PagosPublicidad.all\n end", "def index\n @tutorados = Tutorado.all\n\n render json: @tutorados, status: :ok\n end", "def index\n @usuario_projetos = UsuarioProjeto.all\n end", "def index\n @users = User.paginate(:page => params[:page], :per_page => 30)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @users }\n end\n end", "def verifica_usuarios\n# @user_pages, @usuarios = paginate :users, :per_page => 10\n @usuarios = User.find(:all, :order => 'nombre')\n @rol = Rol.find(params[:id])\n @usuarios = @rol.users\n end" ]
[ "0.6125944", "0.6043836", "0.6034562", "0.598759", "0.5979556", "0.5865911", "0.5830862", "0.582593", "0.5821607", "0.58168006", "0.58145386", "0.580052", "0.5795285", "0.5793987", "0.577988", "0.5763626", "0.57336086", "0.5721906", "0.57187206", "0.57185656", "0.57099414", "0.569423", "0.56806564", "0.5675506", "0.5674621", "0.56617874", "0.5657232", "0.5654964", "0.5641304", "0.563364", "0.5632109", "0.5624552", "0.5612812", "0.560734", "0.5598203", "0.5591764", "0.5583304", "0.557056", "0.5559615", "0.55423254", "0.5542071", "0.55402493", "0.55261177", "0.552169", "0.5501069", "0.5498092", "0.54957", "0.54926974", "0.5491313", "0.5486499", "0.54820853", "0.54612446", "0.54594344", "0.5453958", "0.54508233", "0.54481024", "0.5447486", "0.54452443", "0.5440609", "0.5440442", "0.5440379", "0.5440116", "0.5439426", "0.5437512", "0.5437298", "0.54355395", "0.54345095", "0.5426454", "0.54245526", "0.5418767", "0.5414624", "0.54113173", "0.54111916", "0.5409035", "0.54045826", "0.54023767", "0.53952396", "0.5392195", "0.53918934", "0.5385593", "0.5384351", "0.53830916", "0.5368484", "0.53663975", "0.5365284", "0.53646827", "0.53638434", "0.53632724", "0.5359743", "0.535839", "0.5356671", "0.5350084", "0.5348647", "0.5346904", "0.5340565", "0.5338931", "0.5335713", "0.5334431", "0.53336567", "0.5332694" ]
0.5646031
28
GET /pagina_principals/1 GET /pagina_principals/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_pagina_principal\n @pagina_principal = PaginaPrincipal.find(params[:id])\n end", "def index\n @usuarios = Usuario.paginate(page: params[:page])\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @usuarios }\n end\n end", "def index\n @unidades = current_user.empresa.unidades.page params[:page]\n end", "def index\n @ventas_presupuestos = Ventas::Presupuesto.paginate(:page => params[:page], :per_page => 5)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ventas_presupuestos }\n end\n end", "def index\n #@usuarios = User.all.order_by([:email, :asc]).paginate(:page => params[:page], :per_page => @@page)\n @usuarios = User.accessible_by(current_ability).order_by([:email, :asc]).paginate(:page => params[:page], :per_page => @@page)\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @usuarios }\n end\n end", "def grab_professors\n professor_size = User.where(:professor => true).length\n current_offset = (params[:payload][:pagenumber] - 1)*10\n direction = params[:payload][:direction]\n\n respond_to do |format|\n format.json {\n\n if current_offset + direction < professor_size && current_offset + direction >= 0\n offset = current_offset + direction\n @professors = User.where(:professor => true).offset(offset).take(10)\n render :json => @professors\n else\n render :nothing => true, :status => 200, :content_type => 'text/html'\n end\n\n }\n end\n end", "def index\n @slider_principals = SliderPrincipal.all\n end", "def index\n authorize! :index, Notificacao\n @notificacoes = Notificacao.where(usuario_curso: @perfil.id).order('id desc').page(params[:page])\n end", "def index\n @pagamentos = Pagamento.page(params[:page]).per(NUMERO_POR_PAGINA)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @pagamentos }\n end\n end", "def index\n if current_user.nil?\n redirect_to(log_in_path) and return\n end\n\n @personas_vinculadas = PersonaVinculada.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @personas_vinculadas }\n end\n end", "def show\n @perfilnegocio = Perfilnegocio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @perfilnegocio }\n end\n end", "def index\n \n @listadeprecios = current_user.empresa.listadeprecios.page params[:page]\n cookies[:current_page] = params[:page]\n \n end", "def index\n @people = User.order(:nickname).page(params[:page])\n\n respond_to do |format|\n format.html # index.html.haml\n format.json { render :json => @people }\n end\n end", "def index\n @roles = Role.page params[:page]\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @roles}\n end\n end", "def get_ponto\n render json: Usuario.ultimo_ponto(params[:user_id], params[:evento_id]).to_json\n end", "def index\n if params[:propietario]\n @usuario = Usuario.find(params[:usuario_id])\n authorize! :show, @usuario\n @negocios_propios = Usuario.find(params[:usuario_id]).negocios_propios\n render json: @negocios_propios,\n root: 'negocios_propios',\n each_serializer: NegocioPropioSerializer\n else\n @negocios = Negocio.all\n render json: @negocios\n end\n end", "def show\n @principal_establec = PrincipalEstablec.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @principal_establec }\n end\n end", "def index\n @pizarras = current_user.pizarras.paginate :page => params[:page],:per_page => 5 \n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @pizarras }\n end\n end", "def index\n @pt_accounts = current_user.pt_accounts.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @pt_accounts }\n end\n end", "def index\n render json: AuthIpAddressGroup.paginate(page: params[:page], per_page: 25)\n end", "def show\n @cliente = Cliente.find(params[:cliente_id])\n @pago = @cliente.pagos.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @pago }\n end\n end", "def index\n @relatorio_pedagogicos = RelatorioPedagogico.all.page(params[:page]).per(15)\n authorize @relatorio_pedagogicos\n end", "def index\n @ideas = current_user.ideas.page(params[\"page\"])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ideas }\n end\n end", "def index\n\tperfilId = session[:perfilLogado]\n\n\tif(perfilId)\n\t\tperfil = Perfil.find(perfilId)\n\n\t\trender :json => perfil.grupos.to_json(), :callback => params['callback']\n\tend\n end", "def show\n @servidor = Servidor.find(params[:id])\n @q = @servidor.pontos.ransack(params[:q])\n @q.sorts = 'nome'\n @pontos = @q.result.page params[:page]\n @autenticacoes = @servidor.autenticacoes.order(authdate: :desc).page params[:page]\n end", "def show\n if current_user.nil?\n redirect_to(log_in_path) and return\n end\n\n @persona_vinculada = PersonaVinculada.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @persona_vinculada }\n end\n end", "def index\n if isAdmin?\n @title= \"Listing All Professors\"\n @users = User.where('role' => 2).paginate(page: params[:page])\n if(!@users.any?)\n flash[:notice]= \"No professor on CMS. To create a new professor click on Create New Professor\"\n end\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @users }\n end\n else\n flash[:notice]= \"You don't have permission to browse all users\"\n redirect_to courses_path\n end\n end", "def get_principal(filter = nil, sort = nil)\n puts \"ACS: get_principal\"\n res = query(\"principal-list\", \n \"filter\" => filter, \n \"sort\" => sort)\n\n return res.body\n end", "def mostrar_pag_apresentacao\n if @permissao === \"admin\" or @permissao === \"autenticado\" or @permissao === \"convidado\"\n puts \"esta é a pág de apresentação do usuario #{@email}\"\n else\n puts \"vc nao tem permissao para acessar esta página!\"\n end\n end", "def index\n @roles = Role.paginate(:page => params[:page], per_page: 30)\n @number = Role.count\n\n respond_to do |format|\n format.html\n format.json { render :json => Role.all }\n end\n end", "def show\n @persona = Persona.find(params[:id])\n @users = User.all\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @persona }\n end\n end", "def index\n authorize! :read, Registro\n\n p = params[:page]\n @registros = Registro.order(\"created_at DESC\").paginate(page: p)\n end", "def show\n @coleccion = {}\n @coleccion['publicaciones'] = @objeto.publicaciones.page(params[:page])\n end", "def index\n @accounts = Account.paginate(page: params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @accounts }\n end\n end", "def index\n @pagina_principals = PaginaPrincipal.all\n def index\n if( !(session[:cafe] != nil && session[:cafe] != '') )\n redirect_to '/'\n end\n end\n end", "def index\n authorize! :index, Por, :message => 'Acceso denegado.'\n @pors = @campus.pors.paginate(:per_page => 3, :page => params[:page])\n\t\t@points = @pors\n\t\t@point_name = \"por\"\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render \"points/index.json.erb\" } # index.json.erb\n end\n end", "def index_participating\n projects = current_user.projects.paginate(:page => params[:page])\n render json: projects\n end", "def index\n @puntajes = Puntaje.paginate(:page => params[:page], :per_page => 10)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @puntajes }\n end\n end", "def index\n @usuarios = Usuario.por_colegio(colegio.id).order(\"nombre\")\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @usuarios }\n end\n end", "def index\n @usuario_perfils = UsuarioPerfil.all\n end", "def show\n @por = @campus.pors.find(params[:id])\n authorize! :show, @por, :message => 'Acceso denegado.'\n \n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @por }\n end\n end", "def show\n @publicaciones = Publicacione.find(params[:id])\n render json: @publicaciones, status: :ok\n end", "def index\n @accounts = current_user.person.linked_in_accounts\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @accounts }\n end\n end", "def index\n @account = Account.find(params[:account_id])\n @users = @account.users\n respond_to do |format|\n format.json { render json: @account.users.paginate(page: @page, per_page: @per_page) }\n end\n end", "def show\n @paciente = Paciente.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @paciente }\n end\n end", "def show\n @paciente = Paciente.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @paciente }\n end\n end", "def index\n @anuncios = Anuncio.all.paginate(page: params[:page], per_page: 4 )\n\n respond_to do |format|\n format.html\n format.json { render json: @jobs }\n end\n end", "def index\n @users = User.paginate(page: params[:page], per_page:50)\n render json: @users, status: :ok\n end", "def create\n @pagina_principal = PaginaPrincipal.new(pagina_principal_params)\n\n respond_to do |format|\n if @pagina_principal.save\n format.html { redirect_to @pagina_principal, notice: 'Pagina principal was successfully created.' }\n format.json { render :show, status: :created, location: @pagina_principal }\n else\n format.html { render :new }\n format.json { render json: @pagina_principal.errors, status: :unprocessable_entity }\n end\n end\n end", "def show\n @usuario = Usuario.find(params[:id])\n\n render json: @usuario\n end", "def index\n if logged_in?\n @pannes = Panne.paginate(page: params[:page], :per_page => 10)\n else\n redirect_to home_url\n end\n end", "def privacy\n @api_v1_pages = Api::V1::Page.where('title = \"privacy\"').first\n\n render json: @api_v1_pages\n end", "def index\n authorize! :ver, UsuarioPrestamo.new\n @usuarios_prestamos = UsuarioPrestamo.all\n @alumnos = UsuarioPrestamo.where(:categoria => UsuarioPrestamo.categorias[:alumno])\n @profesores = UsuarioPrestamo.where(:categoria => UsuarioPrestamo.categorias[:profesor])\n @personal = UsuarioPrestamo.where(:categoria => UsuarioPrestamo.categorias[:personal])\n end", "def show_permiso_diario\n @permiso_diario = PermisoDiario.get_user_permiso_diario(current_user.id).page(params[:page]).per(7)\n @solicita = current_user.nombre\n end", "def show\n @periodo_academico = PeriodoAcademico.find(params[:id])\n\n render json: @periodo_academico\n end", "def index\n page_num=params[:page]\n @users= User.page(page_num)\n render json: @users\n end", "def index\n @usuarios = Usuario.all\n #@habilidades = Usuario.first.curso_dictado.first.curso.profile_image\n end", "def index\n @instances = Instance.page params[:page]\n authorize! :read, @instances\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @instances }\n end\n end", "def index\n @pagamentos = Pagamento.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @pagamentos }\n end\n end", "def index\n # @usuarios = @topico.perguntas.usuarios\n end", "def show_patrons\r\n @patrons_pages, @patrons = paginate(:users, \r\n :conditions => ['level = 0'],\r\n :order => 'username') \r\n end", "def index\n @formasdepagos = current_user.empresa.formasdepagos.page params[:page]\n end", "def index\n \n @users = User.page(params[:page]).per_page(14)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @users }\n end\n \n end", "def show\n @premio = Premio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @premio }\n end\n end", "def index\n if not ( paziente_signed_in? or administrator_signed_in?)\n redirect_to root_path and return\n end\n @profilopazientis = Profilopazienti.all\n end", "def index\n @premios = Premio.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @premios }\n end\n end", "def index\n @profiles = Profile.all.paginate :page => params[:page], :per_page => 3\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @profiles }\n end\n end", "def index\n @iniciadores = Iniciador.paginate(page: params[:page], per_page:10).all.order(:razon_social)\n end", "def index\n @produtos = Produto.where(empresa_id: current_user.empresa_id).page(params[:page]).per(7)\n end", "def index\n @users = User.page params[:page]\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @users }\n end\n end", "def show\n @usuario = Usuario.find(params[:id])\n render json: @usuario\n end", "def show\n @usuario = Usuario.find(params[:id])\n render json: @usuario\n end", "def index\n @personas = Persona.all\n @users = User.all\n\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @personas }\n end\n end", "def show\n @palestrante = Palestrante.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @palestrante }\n end\n end", "def index\n @users = User.order(\"login ASC\")\n @users = @users.paginate :page => params[:page], :per_page => users_per_page\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @users }\n end\n end", "def index\n projects = current_user.admin_projects.paginate(:page => params[:page])\n render json: projects\n end", "def show\n @coleccion = {}\n @coleccion['publicaciones'] = @objeto.publicaciones.page(params[:page]) #.where(estado: @estado)\n end", "def show\n @coleccion = {}\n @coleccion['publicaciones'] = @objeto.publicaciones.page(params[:page]) #.where(estado: @estado)\n end", "def show\n @pagamento = Pagamento.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @pagamento }\n end\n end", "def show\n @pagamento = Pagamento.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @pagamento }\n end\n end", "def show\n @pagamento = Pagamento.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @pagamento }\n end\n end", "def show\n @person_belong = @group.people.paginate(:per_page => 4, :page => params[:page])\n respond_to do |format|\n format.html\n format.js\n end\n end", "def index\n @accounts = current_user.person.phone_accounts\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @accounts }\n end\n end", "def index\n\t\tauthorize! :index, Presupuesto\n @presupuestos = Presupuesto.all\n end", "def show\n @grupo = Grupo.find(params[:id])\n authorize! :show, @grupo\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @grupo }\n end\n end", "def index\n @permitions = Permition.all.page(params[:page]).per(10)\n @page = params[:page]\n @page = 1 if @page.blank?\n end", "def index\n @usuario_projetos = UsuarioProjeto.all\n end", "def index\n @accounts = Account.alumni.paginate(:page => params[:page], :per_page => 50)\n end", "def index\n @seguridad_usuarios = Seguridad::Usuario.order('usuario')\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @seguridad_usuarios }\n end\n end", "def show\n @partecipanti_gruppo = PartecipantiGruppo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @partecipanti_gruppo }\n end\n end", "def index\n page = valid_page_or_one params[:page]\n @users = User.paginate(:page => page, :per_page => per_page).order('created_at DESC')\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @users }\n end\n end", "def index\n @palestrantes = Palestrante.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @palestrantes }\n end\n end", "def index\n authorize Profile\n @profiles = ProfilePolicy::Scope.new(current_user, @user.profiles).resolve\n render json: @profiles\n end", "def index\n @os_groups_principals = OsGroupsPrincipal.all\n end", "def index\n @prayers = Prayer.where(\"user_id = ?\", getUser())\n\n @prayer_requests = PrayerRequest.all \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @prayers }\n end\n end", "def show\n @clasificacion_pegi = ClasificacionPegi.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @clasificacion_pegi }\n end\n end", "def index\n @accounts = current_user.person.gmail_accounts\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @accounts }\n end\n end", "def show\n user= params[:user]\n repo= params[:repo]\n puts user\n puts repo\n url = BASE_URL + \"repos/\" + user + \"/\" + repo + \"/collaborators\"+ \"?client_id=e24305f14f7f9a67c465&client_secret=604015f905f6207ec29f3661b952397663d58347\"\n # url = BASE_URL + \"repos/rails/rails/collaborators\"\n # url = BASE_URL + \"repositories\"\n @repo = JSON.parse(open(url).read)\n @results = []\n\n\n @repo.each do |doc|\n ids = doc['login']\n url_people = BASE_URL + \"users/\" + ids + \"?client_id=e24305f14f7f9a67c465&client_secret=604015f905f6207ec29f3661b952397663d58347\"\n @results << JSON.parse(open(url_people).read)\n end\n\n end", "def show\n @pagenate = Pagenate.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @pagenate }\n end\n end", "def index\n page = params[:page] || 1\n\n @users = User.all.page(page)\n respond_to do |format|\n format.json\n format.html\n end\n end", "def index\n @people = Person.all\n respond_to do |format|\n format.json { \n render json: @people, :include => [:roles => { include: [:privileges] } ]\n }\n end\n end" ]
[ "0.63806653", "0.6141997", "0.60513455", "0.60486054", "0.599158", "0.5983846", "0.5983029", "0.59639883", "0.59469026", "0.58980966", "0.5894253", "0.5880484", "0.58435124", "0.5840942", "0.583935", "0.58309525", "0.58257216", "0.5815181", "0.58118707", "0.5810231", "0.579957", "0.57968307", "0.57960355", "0.5781923", "0.5778955", "0.5776993", "0.57746124", "0.5752713", "0.5712678", "0.57018954", "0.569575", "0.5694074", "0.5688518", "0.5677355", "0.5675996", "0.56629205", "0.5662047", "0.56578726", "0.56529933", "0.56479406", "0.5646699", "0.5639247", "0.56318814", "0.56230897", "0.5621791", "0.5621791", "0.5621675", "0.56211764", "0.56151783", "0.5599869", "0.55973446", "0.558996", "0.5589675", "0.5589153", "0.55865335", "0.55773103", "0.55747694", "0.5574508", "0.55713004", "0.55712974", "0.55695415", "0.5568639", "0.55666417", "0.5559539", "0.5553204", "0.5543931", "0.5542558", "0.5541788", "0.5538299", "0.5538141", "0.5537981", "0.5537981", "0.5534136", "0.5532868", "0.55324614", "0.5528331", "0.5528025", "0.5528025", "0.552677", "0.552677", "0.552677", "0.55253977", "0.55236524", "0.5511795", "0.55109453", "0.5505201", "0.5502669", "0.5502539", "0.54920155", "0.549098", "0.54905033", "0.5489685", "0.548621", "0.5484041", "0.54826945", "0.5482073", "0.54796803", "0.5476163", "0.547474", "0.5472779", "0.54725933" ]
0.0
-1
POST /pagina_principals POST /pagina_principals.json
def create @pagina_principal = PaginaPrincipal.new(pagina_principal_params) respond_to do |format| if @pagina_principal.save format.html { redirect_to @pagina_principal, notice: 'Pagina principal was successfully created.' } format.json { render :show, status: :created, location: @pagina_principal } else format.html { render :new } format.json { render json: @pagina_principal.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def valid_principals; end", "def valid_principals=(_arg0); end", "def set_pagina_principal\n @pagina_principal = PaginaPrincipal.find(params[:id])\n end", "def pagina_principal_params\n params.require(:pagina_principal).permit(:index)\n end", "def principals=(principals)\n if principals.nil?\n fail ArgumentError, 'invalid value for \"principals\", principals cannot be nil.'\n end\n @principals = principals\n end", "def extraer_lista_principio\n ref = @principio\n @principio = ref.siguiente\n if @principio != nil\n @principio.anterior = nil\n else\n @final = @principio\n end\n ref\n end", "def create\n @principalgroupe = Principalgroupe.new(principalgroupe_params)\n\n respond_to do |format|\n if @principalgroupe.save\n format.html { redirect_to @principalgroupe, notice: 'Principalgroupe was successfully created.' }\n format.json { render :show, status: :created, location: @principalgroupe }\n else\n format.html { render :new }\n format.json { render json: @principalgroupe.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @slider_principals = SliderPrincipal.all\n end", "def service_principals()\n return MicrosoftGraph::ServicePrincipals::ServicePrincipalsRequestBuilder.new(@path_parameters, @request_adapter)\n end", "def insertar_lista_principio(referencia)\n if @principio != nil && @principio.siguiente != nil\n n = @principio\n @principio = Nodo.new(referencia, n, nil)\n n.anterior = @principio\n elsif @principio != nil\n n = @principio\n @principio = Nodo.new(referencia, n, nil)\n n.anterior = @principio\n @final = n\n else\n @principio = Nodo.new(referencia, nil, nil)\n @final = @principio\n end\n end", "def create\n @usuario_prestamo = UsuarioPrestamo.new(usuario_prestamo_params)\n authorize! :crear, @usuario_prestamo\n respond_to do |format|\n if @usuario_prestamo.save\n format.html { redirect_to @usuario_prestamo, notice: 'El usuario de préstamo fue agregado correctamente' }\n format.json { render :show, status: :created, location: @usuario_prestamo }\n else\n format.html { render :new }\n format.json { render json: @usuario_prestamo.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @persona_tipo = PersonaTipo.new(params[:persona_tipo])\n\n respond_to do |format|\n if @persona_tipo.save\n format.html { redirect_to @persona_tipo, notice: 'Tipo de Participante registrado correctamente.' }\n format.json { render json: @congreso, status: :created, location: @persona_tipo }\n else\n if current_user.is_admin?\n @congresos = Congreso.all(:order => \"nombre\")\n else\n @congresos = current_user.congresos(:order => \"nombre\")\n end\n format.html { render action: \"new\" }\n format.json { render json: @persona_tipo.errors, status: :unprocessable_entity }\n end\n end\n end", "def principals=(value)\n write(value)\n end", "def index\n @pagina_principals = PaginaPrincipal.all\n def index\n if( !(session[:cafe] != nil && session[:cafe] != '') )\n redirect_to '/'\n end\n end\n end", "def create\n @tipo_usuario = TipoUsuario.new(tipo_usuario_params)\n @tipo_usuarios = TipoUsuario.all.paginate(page: params[:page], per_page: 5)\n @action = { title: \"Novo\", button: \"Salvar\"}\n\n respond_to do |format|\n if @tipo_usuario.save\n format.html { redirect_to action: \"new\", notice: 'TIpo Usuário criada com sucesso.' }\n format.json { render :show, status: :created, location: @tipo_usuario }\n else\n format.html { render :new, location: @tipo_usuario}\n format.json { render json: @tipo_usuario.errors, status: :unprocessable_entity }\n end\n end\n end", "def search_principals(prefix_path, search_properties, test = 'allof')\n end", "def enter_pahma_authorizations(test_data)\n authorizations = test_data[UseOfCollections::AUTHORIZATION_GRP.name] || [UseOfCollections.empty_authorization]\n prep_fieldsets_for_test_data([fieldset(UseOfCollections::AUTHORIZATION_GRP.name)], authorizations)\n authorizations.each_with_index do |auth, index|\n enter_auto_complete(authorized_by_input(index), authorized_by_options(index), auth[UseOfCollections::AUTHORIZED_BY.name], 'PAHMA Persons')\n wait_for_element_and_type(authorization_date_input(index), auth[UseOfCollections::AUTHORIZATION_DATE.name])\n hit_enter\n wait_for_element_and_type(authorization_note_input(index), auth[UseOfCollections::AUTHORIZATION_NOTE.name])\n wait_for_options_and_select(authorization_status_input(index), authorization_status_options(index), auth[UseOfCollections::AUTHORIZATION_STATUS.name])\n end\n end", "def create\n \tauthorize! :create, @palestrante\n @palestrante = Palestrante.new(params[:palestrante])\n\n respond_to do |format|\n if @palestrante.save\n format.html { redirect_to @palestrante, :flash => { :notice => \"Palestrante cadastrado com sucesso!\"} }\n format.json { render json: @palestrante, status: :created, location: @palestrante }\n else\n format.html { render action: \"new\" }\n format.json { render json: @palestrante.errors, status: :unprocessable_entity }\n end\n end\n end", "def authorizations(params = {})\n scope 'default'\n post('authorizations/', params)\n end", "def create\n @school = School.new(school_params)\n @principals = User.with_role(:principal)\n\n respond_to do |format|\n if @school.save\n format.html { redirect_to @school, notice: 'School was successfully created.' }\n format.json { render :show, status: :created, location: @school }\n else\n format.html { render :new }\n format.json { render json: @school.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n verifica_user\n if (usu_total? || usu_publi?)\n @publicidad = Publicidad.new(publicidad_params)\n\n respond_to do |format|\n if @publicidad.save\n format.html { redirect_to @publicidad, notice: 'Publicidad was successfully created.' }\n format.json { render :show, status: :created, location: @publicidad }\n else\n format.html { render :new }\n format.json { render json: @publicidad.errors, status: :unprocessable_entity }\n end\n end\n else\n (redirect_to login_url, notice: \"Sin privilegios de publicista\")\n end\n end", "def save\n send(\"principals=\", client_principal.to_abbreviated)\n client.put(api_path, to_json, headers)\n true\n end", "def create\n @slider_principal = SliderPrincipal.new(slider_principal_params)\n\n respond_to do |format|\n if @slider_principal.save\n format.html { redirect_to @slider_principal, notice: 'Slider principal was successfully created.' }\n format.json { render :show, status: :created, location: @slider_principal }\n else\n format.html { render :new }\n format.json { render json: @slider_principal.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n #@usuarios = User.all.order_by([:email, :asc]).paginate(:page => params[:page], :per_page => @@page)\n @usuarios = User.accessible_by(current_ability).order_by([:email, :asc]).paginate(:page => params[:page], :per_page => @@page)\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @usuarios }\n end\n end", "def create\n @relatorio_pedagogicos = RelatorioPedagogico.all\n authorize @relatorio_pedagogicos\n\n @relatorio_pedagogico = RelatorioPedagogico.new(relatorio_pedagogico_params)\n\n respond_to do |format|\n if @relatorio_pedagogico.save\n format.html { redirect_to @relatorio_pedagogico, notice: 'Relatório pedagógico criado com sucesso!' }\n format.json { render :show, status: :created, location: @relatorio_pedagogico }\n else\n format.html { render :new }\n format.json { render json: @relatorio_pedagogico.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @perfil = Perfil.new(perfil_params)\n @perfil.usuario = current_usuario\n\n respond_to do |format|\n if @perfil.save\n format.html { redirect_to perfil_usuario_path, notice: 'Perfil criado com sucesso!' }\n format.json { render :show, status: :created, location: @perfil }\n else\n format.html { render :new }\n format.json { render json: @perfil.errors, status: :unprocessable_entity }\n end\n end\n end", "def paise_params\n params.require(:paise).permit(:nombre)\n end", "def principalgroupe_params\n params.require(:principalgroupe).permit(:name)\n end", "def create\n @os_groups_principal = OsGroupsPrincipal.new(os_groups_principal_params)\n\n respond_to do |format|\n if @os_groups_principal.save\n format.html { redirect_to @os_groups_principal, notice: 'Os groups principal was successfully created.' }\n format.json { render :show, status: :created, location: @os_groups_principal }\n else\n format.html { render :new }\n format.json { render json: @os_groups_principal.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @principal_establec = PrincipalEstablec.new(params[:principal_establec])\n\n respond_to do |format|\n if @principal_establec.save\n format.html { redirect_to @principal_establec, notice: 'Registro creado satisfactoriamente.' }\n format.json { render json: @principal_establec, status: :created, location: @principal_establec }\n else\n format.html { render action: \"new\" }\n format.json { render json: @principal_establec.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @personnel = User.new\n @personnel.first_name = params[\"first_name\"]\n @personnel.last_name = params[\"last_name\"]\n @personnel.phone_number = params[\"phone_number\"]\n @personnel.title = params[\"title\"]\n @personnel.email = params[\"email\"]\n @personnel.password = params[\"email\"]\n @personnel.admin_name = current_user.fullname\n @personnel.admin_update_time = DateTime.now\n if params[\"is_verified\"].nil?\n @personnel.is_verified = false\n else\n @personnel.is_verified = true\n end\n\n\n respond_to do |format|\n if @personnel.save\n @personnel.user_roles.create(:role_id => params[\"user_role\"][\"user_role_id\"])\n format.html { redirect_to personnel_path(@personnel), notice: 'Personnel was successfully created.' }\n format.json { render :show, status: :created, location: @personnel }\n else\n format.html { render :new }\n format.json { render json: @personnel.errors, status: :unprocessable_entity }\n end\n end\n end", "def mostrar_pag_apresentacao\n if @permissao === \"admin\" or @permissao === \"autenticado\" or @permissao === \"convidado\"\n puts \"esta é a pág de apresentação do usuario #{@email}\"\n else\n puts \"vc nao tem permissao para acessar esta página!\"\n end\n end", "def create\n @pagina = Pagina.new(pagina_params)\n\n respond_to do |format|\n if @pagina.save\n format.html { redirect_to @pagina, notice: 'Pagina was successfully created.' }\n format.json { render :show, status: :created, location: @pagina }\n else\n format.html { render :new }\n format.json { render json: @pagina.errors, status: :unprocessable_entity }\n end\n end\n end", "def risky_service_principals=(value)\n @risky_service_principals = value\n end", "def ayty_replicate_memberships\n # usuario que sera atualizado\n @user = User.find(params[:id])\n\n @user.ayty_replicate_memberships_by_user_id(params[:ayty_user_stunt_id])\n\n @principal = Principal.find(@user.id)\n\n respond_to do |format|\n format.html { redirect_to edit_polymorphic_path(principal, :tab => 'memberships') }\n format.js\n end\n end", "def destroy\n @pagina_principal.destroy\n respond_to do |format|\n format.html { redirect_to pagina_principals_url, notice: 'Pagina principal was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def create\n @ponto = Ponto.new(ponto_params)\n @ponto.user = current_user\n\n respond_to do |format|\n if @ponto.save\n format.html { redirect_to @ponto, notice: 'Ponto was successfully created.' }\n format.json { render :show, status: :created, location: @ponto }\n else\n format.html { render :new }\n format.json { render json: @ponto.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @permitido = Permitido.new(permitido_params)\n\n respond_to do |format|\n if @permitido.save\n addlog(\"Deu permissão a um usuário\")\n format.html { redirect_to @permitido, notice: 'Permissão criada com sucesso.' }\n format.json { render :show, status: :created, location: @permitido }\n else\n format.html { render :new }\n format.json { render json: @permitido.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 authorize! :create_almacen,Sigesp::Solicitud \n unidad = session['unidad'] \n return render json: { unidad: \"Esta Unidad Administrativa no tiene Numero de Control \" }, status: :unprocessable_entity if Sigesp::CtrlRequisicion.control_compra(unidad).nil?\n\n @solicitudes = Sigesp::Solicitud.crear_solicitudes_almacen(sigesp_solicitud_alamcen_params)\n @grupoSolicitud = SolicitudGrupo.new\n @solicitudes.each do |solicitud|\n @grupoSolicitud.solicitudes << solicitud \n end\n if @grupoSolicitud.valid? \n @grupoSolicitud.guardar(unidad,current_usuario)\n return render json: { url: sigesp_solicitudsalmacen_path(@grupoSolicitud.solicitudes[0])} \n else\n return render json:@grupoSolicitud.errors ,status: :unprocessable_entity\n end \n end", "def index\n @relatorio_pedagogicos = RelatorioPedagogico.all.page(params[:page]).per(15)\n authorize @relatorio_pedagogicos\n end", "def index\n @ventas_presupuestos = Ventas::Presupuesto.paginate(:page => params[:page], :per_page => 5)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ventas_presupuestos }\n end\n end", "def grab_professors\n professor_size = User.where(:professor => true).length\n current_offset = (params[:payload][:pagenumber] - 1)*10\n direction = params[:payload][:direction]\n\n respond_to do |format|\n format.json {\n\n if current_offset + direction < professor_size && current_offset + direction >= 0\n offset = current_offset + direction\n @professors = User.where(:professor => true).offset(offset).take(10)\n render :json => @professors\n else\n render :nothing => true, :status => 200, :content_type => 'text/html'\n end\n\n }\n end\n end", "def create\n @grupo = Grupo.new(params[:grupo])\n authorize! :create, @grupo\n\n respond_to do |format|\n if @grupo.save\n current_user.add_role :owner, @grupo\n \n format.html { redirect_to grupo_path(@grupo), notice: 'Grupo was successfully created.' }\n format.json { render json: @grupo, status: :created, location: @grupo }\n else\n format.html { render action: \"new\" }\n format.json { render json: @grupo.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @palabra = Palabra.new(params[:palabra])\n @palabra.significados = params[:significados] \n respond_to do |format|\n if @palabra.save\n format.html { redirect_to @palabra, notice: 'La palabra fue guardada correctamente.' }\n format.json { render json: @palabra, status: :created, location: @palabra }\n else\n format.html { render action: \"new\" }\n format.json { render json: @palabra.errors, status: :unprocessable_entity }\n end\n end\n end", "def es_propietario\n set_entrega\n if @entrega.recolector != current_user\n render json: {entrega: [\"No permitido para este usuario\"]}, status:401\n end\n end", "def create\n @analise_privacidade = AnalisePrivacidade.new(analise_privacidade_params)\n \n \n \n \n\n respond_to do |format|\n if @analise_privacidade.save\n format.html { redirect_to @analise_privacidade, notice: 'Analise privacidade was successfully created.' }\n format.json { render :show, status: :created, location: @analise_privacidade }\n else\n format.html { render :new }\n format.json { render json: @analise_privacidade.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @pagos_publicidad = PagosPublicidad.new(pagos_publicidad_params)\n\n respond_to do |format|\n if @pagos_publicidad.save\n format.html { redirect_to @pagos_publicidad, notice: 'Pagos publicidad was successfully created.' }\n format.json { render :show, status: :created, location: @pagos_publicidad }\n else\n format.html { render :new }\n format.json { render json: @pagos_publicidad.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @os_groups_principals = OsGroupsPrincipal.all\n end", "def get_ponto\n render json: Usuario.ultimo_ponto(params[:user_id], params[:evento_id]).to_json\n end", "def create\n @basico_persona_juridica = Basico::PersonaJuridica.new(basico_persona_juridica_params)\n\n respond_to do |format|\n if @basico_persona_juridica.save\n format.html { redirect_to @basico_persona_juridica, notice: 'Persona juridica was successfully created.' }\n format.json { render :show, status: :created, location: @basico_persona_juridica }\n else\n format.html { render :new }\n format.json { render json: @basico_persona_juridica.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @permiso = Permiso.new(permiso_params)\n\n respond_to do |format|\n if @permiso.save\n format.html { redirect_to permisos_path, notice: 'Permiso fue creado con éxito.' }\n format.json { render :show, status: :created, location: @permiso }\n else\n format.html { render :new }\n format.json { render json: @permiso.errors, status: :unprocessable_entity }\n end\n end\n end", "def inicia_analista\n current_usuario = Usuario.create!(PRUEBA_USUARIO_AN)\n current_usuario.grupo_ids = [20]\n current_usuario.save\n return current_usuario\n end", "def inicia_analista\n current_usuario = Usuario.create!(PRUEBA_USUARIO_AN)\n current_usuario.grupo_ids = [20]\n current_usuario.save\n return current_usuario\n end", "def inicia_analista\n current_usuario = Usuario.create!(PRUEBA_USUARIO_AN)\n current_usuario.grupo_ids = [20]\n current_usuario.save\n return current_usuario\n end", "def inicia_analista\n current_usuario = Usuario.create!(PRUEBA_USUARIO_AN)\n current_usuario.grupo_ids = [20]\n current_usuario.save\n return current_usuario\n end", "def inicia_analista\n current_usuario = Usuario.create!(PRUEBA_USUARIO_AN)\n current_usuario.grupo_ids = [20]\n current_usuario.save\n return current_usuario\n end", "def inicia_analista\n current_usuario = Usuario.create!(PRUEBA_USUARIO_AN)\n current_usuario.grupo_ids = [20]\n current_usuario.save\n return current_usuario\n end", "def create\n @jugador = Jugador.find_by(id: params[:pago][:jugador_id])\n @pago = @jugador.pagos.build(pago_params)\n #@pago.jugador_id = params[:jugador_id]\n\n respond_to do |format|\n if @pago.save\n format.html { redirect_to jugadores_path, notice: 'Se ha registrado exitosamente el pago.' }\n format.json { render :show, status: :created, location: @pago }\n else\n format.html { render :new }\n format.json { render json: @pago.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_new_person_authority(test_data)\n data_input_errors = enter_person_auth_data test_data\n click_top_save_button\n when_exists(delete_button, Config.short_wait)\n data_input_errors\n end", "def create\n @actividad = Actividad.new(params[:actividad])\n respond_to do |format|\n if @actividad.save \n @actividad.visitadors.each do |v|\n pu = PuntuacionesActividad.new(:actividad_id => @actividad.id, :visitador_id => v.id, :puntuacion => @actividad.puntuacion)\n pu.save\n end\n format.html { redirect_to @actividad, notice: 'Actividad was successfully created.' }\n format.json { render json: @actividad, status: :created, location: @actividad }\n else\n format.html { render action: \"new\" }\n format.json { render json: @actividad.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @pagamento = @venda.pagamentos.build(pagamento_params)\n\n respond_to do |format|\n if @pagamento.save\n format.html { redirect_to cliente_venda_path(@cliente, @venda), notice: 'O pagamento foi registrada!' }\n format.json { render :show, status: :created, location: @pagamento }\n else\n format.html { render :new }\n format.json { render json: @pagamento.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n\t\tauthorize! :index, Presupuesto\n @presupuestos = Presupuesto.all\n end", "def create\n @usuario_perfil = UsuarioPerfil.new(usuario_perfil_params)\n\n respond_to do |format|\n if @usuario_perfil.save\n format.html { redirect_to @usuario_perfil, notice: 'Usuario perfil was successfully created.' }\n format.json { render :show, status: :created, location: @usuario_perfil }\n else\n format.html { render :new }\n format.json { render json: @usuario_perfil.errors, status: :unprocessable_entity }\n end\n end\n end", "def physicians\n physicians = User.physicians\n render json: { status: 200, data: physicians }\n end", "def create\n @paciente = Paciente.new(paciente_params)\n @persona = @paciente.personas.new(persona_params)\n\n respond_to do |format|\n if @persona.save\n format.html { redirect_to pacientes_url, notice: 'Datos del paciente fueron guardados' }\n else\n format.html { render :new }\n format.json { render json: @paciente.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @paciente = Paciente.new(params[:paciente])\n\n respond_to do |format|\n if @paciente.save\n format.html { redirect_to @paciente, notice: 'Paciente registrado com sucesso.' }\n format.json { render json: @paciente, status: :created, location: @paciente }\n else\n format.html { render action: \"new\" }\n format.json { render json: @paciente.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @persona = Persona.new(persona_params)\n\n respond_to do |format|\n if @persona.save\n format.html { redirect_to @persona, notice: 'Datos personales registrados exitosamente.' }\n format.json { render :show, status: :created, location: @persona }\n else\n format.html { render :new }\n format.json { render json: @persona.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @cliente = Cliente.new(cliente_params)\n\n respond_to do |format|\n if @cliente.save\n #--ADICIONADO\n if params[:cliente][:perfil_ids]\n \t\t params[:cliente][:perfil_ids].each do |ss|\n \t\t\t @cliente.perfilclientes.create(:cliente_id => @cliente.id, :perfil_id => ss)\n \t\t end\n end\n #--ADICIONADO\n format.html { redirect_to clientes_url, notice: 'Cliente criado com sucesso.' }\n format.json { render action: 'show', status: :created, location: @cliente }\n else\n format.html { render action: 'new' }\n format.json { render json: @cliente.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n\t\tauthorize! :create, Presupuesto\n @presupuesto = Presupuesto.new(presupuesto_params)\n\n respond_to do |format|\n if @presupuesto.save\n sesion = Sesion.find_by(usuario_id: current_usuario.id, fechaFin: nil)\n\n Transaccion.create!(descripcion: \"Creación del presupuesto del proyecto #{@presupuesto.proyecto.nombre}: #{@presupuesto.attributes}\",\n sesion_id: sesion.id, \n proyecto_id: @presupuesto.proyecto.id)\n\n\n# Transaccion.create!(\n# descripcion: 'Creacion del presupuesto del proyecto'+@presupuesto.proyecto.nombre,\n# ‪ sesion_id‬: sesion.id,\n# ‪ proyecto_id‬: @presupuesto.proyecto.id\n# )\n format.html { redirect_to gestionar_presupuesto_path(@presupuesto) }#, notice: 'El Presupuesto fue creado exitosamente.' }\n #format.json { render :show, status: :created, location: @presupuesto }\n else\n format.html { redirect_to proyectos_mis_proyectos_path }\n #render :new }\n #format.json { render json: @presupuesto.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n\t\tauthorize! :create, EstadoPresupuesto\n @estado_presupuesto = EstadoPresupuesto.new(estado_presupuesto_params)\n\n respond_to do |format|\n if @estado_presupuesto.save\n format.html { redirect_to gestionar_estados_presupuestos_path}#@estado_presupuesto, notice: 'Estado presupuesto fue creado satisfactoriamente.' }\n format.json { render :show, status: :created, location: @estado_presupuesto }\n else\n format.html { render :new }\n format.json { render json: @estado_presupuesto.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n\t\tauthorize! :index, EstadoPresupuesto\n @estado_presupuestos = EstadoPresupuesto.all\n end", "def principal(request)\n end", "def create\n\n @pai.user_id = current_user.id\n respond_to do |format|\n if @pai.save\n format.html { redirect_to @pai, notice: 'Pais was successfully created.' }\n format.json { render :show, status: :created, location: @pai }\n else\n format.html { render :new }\n format.json { render json: @pai.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n authorize! :ver, UsuarioPrestamo.new\n @usuarios_prestamos = UsuarioPrestamo.all\n @alumnos = UsuarioPrestamo.where(:categoria => UsuarioPrestamo.categorias[:alumno])\n @profesores = UsuarioPrestamo.where(:categoria => UsuarioPrestamo.categorias[:profesor])\n @personal = UsuarioPrestamo.where(:categoria => UsuarioPrestamo.categorias[:personal])\n end", "def create\n\t\tauthorize! :create, Postulacion\n @postulacion = Postulacion.new(postulacion_params)\n @postulacion.aceptado=false\n\n respond_to do |format|\n if @postulacion.save\n sesion= Sesion.find_by(usuario_id: current_usuario.id, fechaFin: nil)\n Transaccion.create!(\n\t\t descripcion: \"Creación de la Postulación al proyecto #{@postulacion.proyecto.nombre} del usuario #{@postulacion.usuario.nombreUsuario}: aceptado = #{t @postulacion.aceptado.to_s}\",\n\t\t sesion_id: sesion.id ,\n\t\t proyecto_id: @postulacion.proyecto.id)\n\tformat.html {redirect_to :controller => 'proyectos', :action => 'index'\n\t flash[:success] = 'Se ha registrado tu participación' } \n format.json { render :show, status: :created, location: @postulacion }\n else\n format.html { render :new }\n format.json { render json: @postulacion.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @usuarios = Usuario.paginate(page: params[:page])\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @usuarios }\n end\n end", "def new\n @persona_tipo = PersonaTipo.new\n if current_user.is_admin?\n @congresos = Congreso.all(:order => \"nombre\")\n else\n @congresos = current_user.congresos(:order => \"nombre\")\n end\n\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @persona_tipo }\n end\n end", "def index\n\tperfilId = session[:perfilLogado]\n\n\tif(perfilId)\n\t\tperfil = Perfil.find(perfilId)\n\n\t\trender :json => perfil.grupos.to_json(), :callback => params['callback']\n\tend\n end", "def principals\n modify\n end", "def create\n @paciente = Paciente.new(paciente_params)\n @paciente.user=current_user\n\n respond_to do |format|\n if @paciente.save\n historial=Historial.new\n historial.paciente=@paciente\n historial.save\n\n format.html { redirect_to @paciente, notice: 'Paciente creado exitosamente.' }\n format.json { render :show, status: :created, location: @paciente }\n else\n format.html { render :new }\n format.json { render json: @paciente.errors, status: :unprocessable_entity }\n end\n end\n end", "def pagos_publicidad_params\n params.require(:pagos_publicidad).permit(:cliente_id, :promocionEventos_id)\n end", "def create\n megam_rest.post_accounts(to_hash)\n end", "def create\n pessoa = Pessoa.new(pessoa_params) \n \n if pessoa.save\n render json: {status: 'SUCCESSO', message:'Usuário cadastrado com sucesso!', data:pessoa},status: :ok\n else\n render json: {status: 'ERRO', message:'Usuário não pode ser cadastrado. Tente novamente mais tarde.', data:pessoa.errors},status: :unprocessable_entity\n end\n end", "def create\n @cliente = Cliente.find(params[:cliente_id])\n @pago = @cliente.pagos.new(params[:pago])\n\n respond_to do |format|\n if @pago.save\n format.html { redirect_to [@cliente, @pago], notice: 'Pago was successfully created.' }\n format.json { render json: @pago, status: :created, location: @pago }\n else\n format.html { render action: \"new\" }\n format.json { render json: @pago.errors, status: :unprocessable_entity }\n end\n end\n end", "def proyecto_params\n params.require(:proyecto).permit(:codigo, :nombre, :descripcion, :calle, :nroDomicilio, :piso, :dpto, :telefono, :email, :pagWeb, {:persona_ids => []}, :etapa_id, :pais_id, :provincia_id, :ciudad_id, :area_id)\n #{:persona_ids => []}\n end", "def create\n @principal_caracteristica = PrincipalCaracteristica.new(principal_caracteristica_params)\n\n respond_to do |format|\n if @principal_caracteristica.save\n format.html { redirect_to @principal_caracteristica, notice: 'Principal caracteristica was successfully created.' }\n format.json { render :show, status: :created, location: @principal_caracteristica }\n else\n format.html { render :new }\n format.json { render json: @principal_caracteristica.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @pagamento_aceito = PagamentoAceito.new(pagamento_aceito_params)\n\n respond_to do |format|\n if @pagamento_aceito.save\n format.html { redirect_to @pagamento_aceito, notice: 'Pagamento aceito was successfully created.' }\n format.json { render :show, status: :created, location: @pagamento_aceito }\n else\n format.html { render :new }\n format.json { render json: @pagamento_aceito.errors, status: :unprocessable_entity }\n end\n end\n end", "def pago_params\n params.require(:pago).permit(:farmacia_id, :numcomprobante, :verificado)\n end", "def create\n @perk = Perk.new(perk_params)\n authorize @perk\n\n respond_to do |format|\n if @perk.save\n format.html { redirect_to perks_path, notice: 'Perk was successfully created.' }\n format.json { render :show, status: :created, location: @perk }\n else\n format.html { render :new }\n format.json { render json: @perk.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @unidades = current_user.empresa.unidades.page params[:page]\n end", "def create\n @ventas_presupuesto = Ventas::Presupuesto.new(params[:ventas_presupuesto])\n @ventas_presupuesto.vendedor = current_user.id\n\n respond_to do |format|\n if @ventas_presupuesto.save\n format.html { redirect_to @ventas_presupuesto, notice: 'Presupuesto was successfully created.' }\n format.json { render json: @ventas_presupuesto, status: :created, location: @ventas_presupuesto }\n else\n format.html { render action: \"new\" }\n format.json { render json: @ventas_presupuesto.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @perfisusuario = Perfisusuario.new(perfisusuario_params)\n\n respond_to do |format|\n if @perfisusuario.save\n format.html { redirect_to perfisusuarios_url, notice: 'Perfil de Usuário criado com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render :new }\n format.json { render json: @perfisusuario.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @pt_accounts = current_user.pt_accounts.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @pt_accounts }\n end\n end", "def alta_profesores\n\t\t@tab = \"admin\"\n\t \tprof = params[:miembro]\n\t \t\n\t \t\tx = User.find(prof)\n\t \t\tx.profesor = true\t#se le dan derechos de profesor\n\t \t\tx.admin = false\n\t \t\tx.estudiante = false\n\t \t\tx.save\n\t \t\n\t \trespond_to do |format|\n\t\t format.html { redirect_to(alta_profesores_lista_path)}\n\t\t format.xml { head :ok }\n\t\tend\n\tend", "def create\n @pantry = current_user.pantries.new(\n pantry_params.merge({ user_id: current_user.id }) \n )\n\n respond_to do |format|\n if @pantry.save\n format.html { redirect_to @pantry }\n format.json\n else\n format.html { render :new }\n format.json { render json: @pantry.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @collaborator = Collaborator.new(collaborator_params)\n authorize! :create, @collaborator\n\n respond_to do |format|\n if @collaborator.save\n if @collaborator.role == \"consultant\"\n format.html { redirect_to creer_propositions_entity_path(@collaborator.entity), notice: \"Le Collaborateur #{@collaborator.name} a été créé avec succès.\" }\n # format.json { render action: 'show', status: :created, location: @collaborator }\n else\n format.html { redirect_to collaborators_path, notice: \"Le Collaborateur #{@collaborator.name} a été créé avec succès.\" }\n end\n else\n format.html { render action: 'new' }\n format.json { render json: @collaborator.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @pagenate = Pagenate.new(params[:pagenate])\n\n respond_to do |format|\n if @pagenate.save\n format.html { redirect_to @pagenate, notice: 'Pagenate was successfully created.' }\n format.json { render json: @pagenate, status: :created, location: @pagenate }\n else\n format.html { render action: \"new\" }\n format.json { render json: @pagenate.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n authorize! :manage, Pupil\n @pupil = Pupil.new(pupil_attrs)\n\n respond_to do |format|\n if @pupil.save\n format.html { redirect_to @pupil, notice: t('action.create.succeed', entity: Pupil.model_name.human) }\n format.json { render action: 'show', status: :created, location: @pupil }\n else\n format.html { render action: 'new' }\n format.json { render json: @pupil.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @intranet_associado = Intranet::Associado.new(intranet_associado_params)\n\n respond_to do |format|\n if @intranet_associado.save\n format.html { redirect_to @intranet_associado, notice: \"Associado was successfully created.\" }\n format.json { render :show, status: :created, location: @intranet_associado }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @intranet_associado.errors, status: :unprocessable_entity }\n end\n end\n end" ]
[ "0.6146954", "0.5881749", "0.58080065", "0.56739277", "0.5511896", "0.54970765", "0.5487306", "0.54829973", "0.54705435", "0.545323", "0.52862793", "0.5257387", "0.5177048", "0.5172978", "0.5170634", "0.5162392", "0.5156691", "0.51498526", "0.51335627", "0.5111573", "0.51102245", "0.51016706", "0.5100752", "0.51002365", "0.5100138", "0.5096182", "0.5095218", "0.50897384", "0.50877786", "0.508419", "0.5069609", "0.5066519", "0.5042782", "0.5041061", "0.5038676", "0.50382984", "0.50379467", "0.503142", "0.50298566", "0.50235337", "0.5010882", "0.50082517", "0.4999931", "0.49979717", "0.49963486", "0.49952206", "0.49935287", "0.49919632", "0.49812084", "0.49738774", "0.4965511", "0.49588805", "0.4955182", "0.4955182", "0.4955182", "0.4955182", "0.4955182", "0.4955182", "0.49541315", "0.49512586", "0.4949356", "0.49470568", "0.49460807", "0.49417263", "0.4934015", "0.49230546", "0.49188155", "0.4917265", "0.4901094", "0.48997012", "0.48993304", "0.48991323", "0.4894807", "0.48943204", "0.4888461", "0.48855022", "0.4881633", "0.48747915", "0.4869501", "0.4868901", "0.48672807", "0.48668128", "0.48568732", "0.48568645", "0.485081", "0.48422328", "0.48411217", "0.4840698", "0.483968", "0.48318204", "0.4824292", "0.48214757", "0.4819226", "0.48179755", "0.48169404", "0.48135722", "0.48118424", "0.4810462", "0.48058045", "0.4805632" ]
0.65687186
0
PATCH/PUT /pagina_principals/1 PATCH/PUT /pagina_principals/1.json
def update respond_to do |format| if @pagina_principal.update(pagina_principal_params) format.html { redirect_to @pagina_principal, notice: 'Pagina principal was successfully updated.' } format.json { render :show, status: :ok, location: @pagina_principal } else format.html { render :edit } format.json { render json: @pagina_principal.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_principal(path, prop_patch)\n end", "def update_principal(path, prop_patch)\n value = nil\n principal_index = nil\n principal = nil\n\n @principals.each_with_index do |value, i|\n principal_index = i\n if value['uri'] == path\n principal = value\n break\n end\n end\n\n return nil unless principal\n\n prop_patch.handle_remaining(\n lambda do |mutations|\n mutations.each do |prop, value|\n if value.nil? && principal.key?(prop)\n principal.delete(prop)\n else\n principal[prop] = value\n end\n end\n\n @principals[principal_index] = principal\n\n return true\n end\n )\n end", "def update\n respond_to do |format|\n if @principalgroupe.update(principalgroupe_params)\n format.html { redirect_to @principalgroupe, notice: 'Principalgroupe was successfully updated.' }\n format.json { render :show, status: :ok, location: @principalgroupe }\n else\n format.html { render :edit }\n format.json { render json: @principalgroupe.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @presupuesto = Presupuesto.find(params[:id])\n @trabajo = @presupuesto.trabajo\n \n es_el_proveedor = false\n if proveedor_signed_in?\n es_el_proveedor = @presupuesto.proveedor_id.eql?(current_proveedor.perfilable_id)\n end\n \n @path = @presupuesto\n respond_to do |format|\n if es_el_proveedor and not(@presupuesto.rechazado or @presupuesto.aprobado)\n if @presupuesto.update_attributes(params[:presupuesto])\n flash[:success] = \"Presupuesto actualizado satisfactoriamente.\"\n format.html { redirect_to @presupuesto }\n format.json { head :no_content }\n else\n flash[:error] = \"Ocurrió un error. Revisa el formulario.\"\n format.html { render action: \"edit\" }\n format.json { render json: @presupuesto.errors, status: :unprocessable_entity }\n end\n else\n flash[:warning] = \"No tienes permiso para editar la información del presupuesto.\"\n format.html { redirect_to @presupuesto }\n end\n end\n end", "def update\n @congreso = Congreso.find(params[:id])\n @datos_lucrativos = false\n @datos_lucrativos = true if @congreso.talleres.where(\"precio > 0\").count > 0 || @congreso.precio > 0\n\n if params[:congreso][:pago] == \"1\" or @datos_lucrativos\n @congreso.personas_confirmadas.each do |persona|\n persona.update_attribute(\"pago\", false)\n end\n else\n @congreso.personas_sin_confirmar.each do |persona|\n persona.update_attribute(\"pago\", true) \n end\n end\n\n respond_to do |format|\n if @congreso.update_attributes(params[:congreso])\n format.html do \n eliminar_campos_anteriores(params[:id])\n crear_campos_congreso(params, params[:id])\n redirect_to @congreso, notice: 'Congreso actualizado correctamente.'\n end\n format.json { head :ok }\n else\n @campos = Campo.all\n format.html { render action: \"edit\" }\n format.json { render json: @congreso.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_pagina_principal\n @pagina_principal = PaginaPrincipal.find(params[:id])\n end", "def update\n @principal_establec = PrincipalEstablec.find(params[:id])\n\n respond_to do |format|\n if @principal_establec.update_attributes(params[:principal_establec])\n format.html { redirect_to @principal_establec, notice: 'Registro editado satisfactoriamente.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @principal_establec.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n @listadeprecio.empresa = current_user.empresa\n if @listadeprecio.update(listadeprecio_params)\n format.html { redirect_to listadeprecios_url({:page => cookies[:current_page]}), notice: 'Listadeprecio was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @listadeprecio.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @palabra = Palabra.find(params[:id])\n @palabra.significados = params[:significados] \n respond_to do |format|\n if @palabra.update_attributes(params[:palabra])\n format.html { redirect_to @palabra, notice: 'La Palabra fue actualizada correctamente.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @palabra.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if not ( paziente_signed_in? or administrator_signed_in?)\n redirect_to root_path and return\n end\n respond_to do |format|\n if @profilopazienti.update(profilopazienti_params)\n format.html { redirect_to @profilopazienti, notice: \"Profilopazienti was successfully updated.\" }\n format.json { render :show, status: :ok, location: @profilopazienti }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @profilopazienti.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n \tauthorize! :update, @palestrante\n @palestrante = Palestrante.find(params[:id])\n\n respond_to do |format|\n if @palestrante.update_attributes(params[:palestrante])\n format.html { redirect_to @palestrante, notice: 'Palestrante alterado com sucesso!' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @palestrante.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n authorize! :manage, Pupil\n respond_to do |format|\n if @pupil.update(pupil_attrs)\n format.html { redirect_to @pupil, notice: t('action.update.succeed', entity: Pupil.model_name.human) }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @pupil.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n\n authorize! :update, @producto\n\n respond_to do |format|\n if @producto.update(producto_params)\n format.html { redirect_to productos_url({:page => cookies[:current_page]}), notice: 'Producto was successfully updated.' }\n format.json { head :no_content }\n else\n @unidades = current_user.empresa.unidades.load\n @listadeprecios = current_user.empresa.listadeprecios.load\n format.html { render action: 'edit' }\n format.json { render json: @producto.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @profesor = Profesor.find(params[:id])\n\n if @profesor.update(profesor_params)\n head :no_content\n else\n render json: @profesor.errors, status: :unprocessable_entity\n end\n end", "def update\n authorize! :editar, @usuario_prestamo\n respond_to do |format|\n if @usuario_prestamo.update(usuario_prestamo_params)\n format.html { redirect_to @usuario_prestamo, notice: 'La información del usuario de préstamos ha sido modificada correctamente' }\n format.json { render :show, status: :ok, location: @usuario_prestamo }\n else\n format.html { render :edit }\n format.json { render json: @usuario_prestamo.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @persona = Persona.find(params[:id])\n \n respond_to do |format|\n if @persona.update_attributes(params[:persona])\n format.json { head :ok }\n else\n format.json { render :json => @persona.errors,\n :status => :unprocessable_entity }\n end\n end\n end", "def update\n if (@user == @responsavel || admin_signed_in?)\n respond_to do |format|\n if @laboratorio.update(laboratorio_params)\n format.html { redirect_to @laboratorio, notice: 'Laboratorio was successfully updated.' }\n format.json { render :show, status: :ok, location: @laboratorio }\n else\n format.html { redirect_to laboratorios_url, notice: 'Sem permissão para editar laboratório.' }\n format.json { head :no_content }\n end\n end\n end\n end", "def update\n respond_to do |format|\n if !params[:roles].include?('president') && @member.has_role?(:president) && !Tenant.current.has_presidents\n format.html { redirect_to member_path(@member), notice: 'Please select other user as President.' }\n elsif @member.update(member_params)\n remove_roles\n add_roles(params[:roles])\n format.html { redirect_to member_path(@member), notice: 'Member was successfully updated.' }\n format.json { render :show, status: :ok, location: @member }\n else\n format.html { render :edit }\n format.json { render json: @member.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @principals = User.with_role(:principal)\n respond_to do |format|\n if @school.update(school_params)\n format.html { redirect_to @school, notice: 'School was successfully updated.' }\n format.json { render :show, status: :ok, location: @school }\n else\n format.html { render :edit }\n format.json { render json: @school.errors, status: :unprocessable_entity }\n end\n end\n end", "def principals\n modify\n end", "def update\n respond_to do |format|\n if @os_groups_principal.update(os_groups_principal_params)\n format.html { redirect_to @os_groups_principal, notice: 'Os groups principal was successfully updated.' }\n format.json { render :show, status: :ok, location: @os_groups_principal }\n else\n format.html { render :edit }\n format.json { render json: @os_groups_principal.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @premio = Premio.find(params[:id])\n\n respond_to do |format|\n if @premio.update_attributes(params[:premio])\n format.html { redirect_to @premio, :notice => 'Premio was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @premio.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @permiso.update(permiso_params)\n format.html { redirect_to permisos_path, notice: 'Permiso fue actualizado.' }\n format.json { render :show, status: :ok, location: @permiso }\n else\n format.html { render :edit }\n format.json { render json: @permiso.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @persona_proyecto.update(persona_proyecto_params)\n format.html { redirect_to @persona_proyecto, notice: 'Persona proyecto was successfully updated.' }\n format.json { render :show, status: :ok, location: @persona_proyecto }\n else\n format.html { render :edit }\n format.json { render json: @persona_proyecto.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n\n respond_to do |format|\n if @perfil.update(perfil_params)\n format.html { redirect_to perfil_usuario_path, notice: 'Perfil atualizado com sucesso.' }\n format.json { render :show, status: :ok, location: @perfil }\n else\n format.html { render :edit }\n format.json { render json: @perfil.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n\t\tauthorize! :update, EstadoPresupuesto\n respond_to do |format|\n if @estado_presupuesto.update(estado_presupuesto_params)\n format.html { redirect_to gestionar_estados_presupuestos_path}#@estado_presupuesto, notice: 'Estado presupuesto fue actualizado satisfactoriamente.' }\n #format.json { render :show, status: :ok, location: @estado_presupuesto }\n else\n format.html { render :edit }\n format.json { render json: @estado_presupuesto.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @perfisusuario.update(perfisusuario_params)\n format.html { redirect_to perfisusuarios_url, notice: 'Perfil de Usuário editado com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render :edit }\n format.json { render json: @perfisusuario.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @slider_principal.update(slider_principal_params)\n format.html { redirect_to @slider_principal, notice: 'Slider principal was successfully updated.' }\n format.json { render :show, status: :ok, location: @slider_principal }\n else\n format.html { render :edit }\n format.json { render json: @slider_principal.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @perfilnegocio = Perfilnegocio.find(params[:id])\n\n respond_to do |format|\n if @perfilnegocio.update_attributes(params[:perfilnegocio])\n format.html { redirect_to @perfilnegocio, notice: 'Perfilnegocio was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @perfilnegocio.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @relatorio_pedagogicos = RelatorioPedagogico.all\n authorize @relatorio_pedagogicos\n\n respond_to do |format|\n if @relatorio_pedagogico.update(relatorio_pedagogico_params)\n format.html { redirect_to @relatorio_pedagogico, notice: 'Relatório pedagógico atualizado com sucesso!' }\n format.json { render :show, status: :ok, location: @relatorio_pedagogico }\n else\n format.html { render :edit }\n format.json { render json: @relatorio_pedagogico.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @usuario = Usuario.find(params[:id])\n \n if !params[:clave_actual].nil?\n user = Usuario.authenticate(params[:usuario], params[:clave_actual])\n \n if !user\n format.html { render action: \"cambiar_clave\" }\n end\n end\n \n respond_to do |format|\n if @usuario.update_attributes(params[:usuario])\n format.html { redirect_to @usuario, notice: 'Usuario fue actualizado satisfactoriamente' }\n format.json { head :no_content }\n else\n if params[:perfil_id].nil?\n format.html { render action: \"cambiar_clave\" }\n else\n format.html { render action: \"edit\" }\n end\n \n format.json { render json: @usuario.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @proveedor = Proveedor.find(current_proveedor.perfilable_id)\n \n params[:proveedor][:pais_id] = 1 # Venezuela\n \n @localidad = params[:proveedor][:localidad_id]\n if Genericas::validar_parametros_a_objeto_sin_localidad(@proveedor, params[:proveedor])\n params[:proveedor][:localidad_id] = UbicacionGeografica.buscar_o_crear_id_de_localidad(@localidad,params[:proveedor][:municipio_id])\n end\n\n \n respond_to do |format|\n if @proveedor.update_attributes(params[:proveedor])\n flash[:success] = \"Perfil actualizado.\"\n format.html { redirect_to panel_proveedor_path }\n format.json { head :no_content }\n else\n flash[:error] = \"Ocurrió un error. Revisa el formulario.\"\n format.html { render action: \"edit\" }\n format.json { render json: @proveedor.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @premio = Premio.find(params[:id])\n\n respond_to do |format|\n if @premio.update_attributes(params[:premio])\n format.html { redirect_to @premio, notice: 'Premio was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @premio.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @paciente = Paciente.find(params[:id])\n\n @upersona = @paciente.personas.last\n @paciente_edit = @upersona.perstable\n respond_to do |format|\n if @paciente_edit.update(params[:paciente].permit(:domicilio, :civil, :nss, :edad, :peso, :talla, :imc, :t_sangre, :persona))\n format.html { redirect_to pacientes_path , notice: 'Paciente was successfully updated.' }\n format.json { render :show, status: :ok, location: pacientes_path }\n else\n format.html { render :edit }\n format.json { render json: @paciente.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @cliente = Cliente.find(params[:cliente_id])\n @pago = @cliente.pagos.find(params[:id])\n\n respond_to do |format|\n if @pago.update_attributes(params[:pago])\n format.html { redirect_to [@cliente, @pago], notice: 'Pago was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @pago.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @politico.update(politico_params) and @politico.update_attributes(:modificador => current_user.id)\n format.html { redirect_to @politico, notice: 'Politico was successfully updated.' }\n format.json { render :show, status: :ok, location: @politico }\n else\n format.html { render :edit }\n format.json { render json: @politico.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @paciente = Paciente.find(params[:id])\n\n respond_to do |format|\n if @paciente.update_attributes(params[:paciente])\n format.html { redirect_to @paciente, notice: 'Paciente atualizado com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @paciente.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @people.update(people_params)\n format.html { redirect_to root_path(@people), notice: 'VIP ' + @people.name.to_s + ' foi atualizado com sucesso!' }\n format.json { render :show, status: :ok, location: @people }\n else\n format.html { render :edit }\n format.json { render json: @people.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @persona = Persona.find(params[:id])\n\n respond_to do |format|\n if @persona.update_attributes(params[:persona])\n format.html { redirect_to personas_path, notice: 'Persona was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @persona.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @pagina.update(pagina_params)\n format.html { redirect_to @pagina, notice: 'Pagina was successfully updated.' }\n format.json { render :show, status: :ok, location: @pagina }\n else\n format.html { render :edit }\n format.json { render json: @pagina.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n authorize! :update, Conceptopersonal\n respond_to do |format|\n if @conceptopersonal.update(conceptopersonal_params)\n\n\n format.html { redirect_to conceptospersonales_path, notice: '<i class=\"fa fa-check-square fa-lg\"></i> Los datos del concepto fueron actualizados exitosamente.' }\n format.json { render :show, status: :ok, location: @conceptopersonal }\n else\n format.html { render :edit }\n format.json { render json: @conceptopersonal.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @principal_caracteristica.update(principal_caracteristica_params)\n format.html { redirect_to @principal_caracteristica, notice: 'Principal caracteristica was successfully updated.' }\n format.json { render :show, status: :ok, location: @principal_caracteristica }\n else\n format.html { render :edit }\n format.json { render json: @principal_caracteristica.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @paciente = Paciente.find(params[:id])\n\n respond_to do |format|\n if @paciente.update_attributes(params[:paciente])\n format.html { redirect_to \"/administrador/pacientes\" }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @paciente.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n\t\tauthorize! :update, HistorialEstadoPresupuesto\n respond_to do |format|\n if @historial_estado_presupuesto.update(historial_estado_presupuesto_params)\n format.html { redirect_to @historial_estado_presupuesto, notice: 'Historial estado presupuesto fue actualizado satisfactoriamente.' }\n format.json { render :show, status: :ok, location: @historial_estado_presupuesto }\n else\n format.html { render :edit }\n format.json { render json: @historial_estado_presupuesto.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n\n if session[:user]['perfil'] == 'Administrador'\n respond_to do |format|\n @user.nome = params[:user][:nome]\n @user.login = params[:user][:login]\n @user.email = params[:user][:email]\n @user.profile_id = params[:user][:profile_id]\n\n @user.password = User.encripitar_senha(params[:user][:password])\n @user.telefone = params[:user][:telefone]\n\n # Vincula perfis aos usuário\n # vincular_user_profiles\n\n # Vincula os módulos e dominios ao usuário\n vincular_modulos_ao_usuario\n\n if @user.save\n flash[:notice] = 'Usuário atualizado com sucesso.'\n format.html {redirect_to '/users/'}\n format.json {render :show, status: :ok, location: @user}\n else\n format.html {render :edit}\n format.json {render json: @user.errors, status: :unprocessable_entity}\n end\n end\n else\n respond_to do |format|\n flash[:warning] = 'Você não possui permissão para acessar esse recurso.'\n format.html {redirect_to '/'}\n format.json {head :no_content}\n end\n end\n # vincular_user_profiles\n end", "def update\n @propuesta = Propuesta.find(params[:id])\n\n respond_to do |format|\n if @propuesta.update_attributes(params[:propuesta])\n format.html { redirect_to propuestas_periodo_propuestas_path(:id=>@propuesta.periodo_propuesta.id), :notice => 'Propuesta fue actualizado correctamente.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @propuesta.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n @person = @profissional.person\n if @person.update(profissional_params[:person_attributes])\n if profissional_params[:specialization].present?\n @profissional.update_attributes(:specialization => profissional_params[:specialization])\n format.html { redirect_to @profissional, notice: 'Profissional was successfully updated.' }\n format.json { render :show, status: :ok, location: @profissional }\n else\n format.html { render :edit }\n format.json { render json: @profissional.errors, status: :unprocessable_entity }\n end\n\n end\n end\n end", "def update\n @perfile = Perfile.find(params[:id])\n @perfile.direccionusuario_attributes.where(:id => current_user.id)\n respond_to do |format|\n if @perfile.perfileusuarios_attributes(params[:perfile]) and @perfile.direccionusuario.direccionusuario_attributes(params[:perfilusuario])\n format.html { redirect_to @perfile, notice: 'Perfile was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @perfile.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @profesor = Profesor.find(params[:id])\n\n respond_to do |format|\n if @profesor.update_attributes(params[:profesor])\n format.html { redirect_to root_path, notice: 'Profesor actualizado' }\n format.js { redirect_to root_path }\n else\n format.html { render action: \"edit\" }\n format.js { render json: @profesor.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @pagos_servicio.update(pagos_servicio_params)\n format.html { redirect_to @pagos_servicio, notice: 'Pagos servicio was successfully updated.' }\n format.json { render :show, status: :ok, location: @pagos_servicio }\n else\n format.html { render :edit }\n format.json { render json: @pagos_servicio.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @persona_tipo = PersonaTipo.find(params[:id])\n\n respond_to do |format|\n if @persona_tipo.update_attributes(params[:persona_tipo])\n format.html { redirect_to @persona_tipo, notice: 'Tipo de participante actualizado correctamente.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @persona_tipo.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @realiza = Realiza.find(params[:id])\n @pagamento=Pagamento.new(:servico_id=>@realiza.servico_id,:cliente_id=>@realiza.cliente_id,:valor=>@realiza.servico.preco,\n :formapagamentoe_id=>params[:pagamento])\n respond_to do |format|\n if @realiza.update_attributes(params[:realiza]) and @pagamento.save\n format.html { redirect_to @realiza, notice: 'Realiza was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @realiza.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n\n # @personnel.first_name = params[\"first_name\"]\n # @personnel.last_name = params[\"last_name\"]\n # @personnel.phone_number = params[\"phone_number\"]\n # @personnel.title = params[\"title\"]\n # @personnel.email = params[\"email\"]\n\n respond_to do |format|\n if @personnel.update(personnel_params)\n @personnel.user_roles.update(:role_id => params[\"role_id\"][\"user_role_id\"])\n format.html { redirect_to personnel_path(@personnel), notice: 'Personnel was successfully updated.' }\n format.json { render :show, status: :ok, location: @personnel }\n else\n format.html { render :edit }\n format.json { render json: @personnel.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @ventas_presupuesto = Ventas::Presupuesto.find(params[:id])\n\n respond_to do |format|\n if @ventas_presupuesto.update_attributes(params[:ventas_presupuesto])\n format.html { redirect_to @ventas_presupuesto, notice: 'Presupuesto was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @ventas_presupuesto.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @pagina.update(pagina_params)\n format.html { redirect_to edit_produto_pagina_path(@produto, @pagina), notice: 'Pagina was successfully updated.' }\n format.json { render :show, status: :ok, location: @pagina }\n else\n format.html { render :edit }\n format.json { render json: @pagina.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @por = @campus.pors.find(params[:id])\n authorize! :update, @por, :message => 'Acceso denegado.'\n @modal_title = \"Editar Punto de Reciclaje\"\n\n respond_to do |format|\n if @por.update_attributes(params[:por])\n format.html { redirect_to([@university, @campus], :notice => 'El punto de reciclaje fue modificado exitosamente') }\n format.json { head :ok }\n format.js\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @por.errors, :status => :unprocessable_entity }\n\t\t\t\tformat.js\t\t{ render :action => \"edit\" }\n end\n end\n end", "def update\n @propose = Propose.find(params[:id])\n\n respond_to do |format|\n if @propose.update_attributes(params[:propose])\n format.html { redirect_to @propose, notice: 'Propuesta actualizada' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @propose.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @proximo_codigo = @tipo_usuario.codigo\n respond_to do |format|\n if @tipo_usuario.update(tipo_usuario_params)\n format.html { redirect_to action: \"new\", notice: 'TIpo Usuário atualizado com sucesso..' }\n format.json { render :show, status: :ok, location: @tipo_usuario }\n else\n format.html { render :edit }\n format.json { render json: @tipo_usuario.errors, status: :unprocessable_entity }\n end\n end\n end", "def save\n send(\"principals=\", client_principal.to_abbreviated)\n client.put(api_path, to_json, headers)\n true\n end", "def update\n @placa_casa = PlacaCasa.find(params[:id])\n @placa_casa.pessoa.update_attributes(params[:pessoa]) \n @placa_casa.placa.update_attributes(params[:placa])\n\n respond_to do |format|\n if @placa_casa.update_attributes(params[:placa_casa])\n format.html { redirect_to(@placa_casa, :notice => ' - Dados atualizados com sucesso.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @placa_casa.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n authorize! :update, Tipo\n respond_to do |format|\n if @tipo.update(tipo_params)\n log(\"Se ha editado la nomina #{@lt}\", 1)\n format.html { redirect_to tipos_path, notice: 'Los datos de la nómina fueron actualizados exitosamente.' }\n format.json { head :no_content }\n end\n end\n end", "def update\n @personaje = Personaje.find(params[:id])\n\n respond_to do |format|\n if @personaje.update_attributes(params[:personaje])\n format.html { redirect_to @personaje, notice: 'Personaje was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @personaje.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @permitido.update(permitido_params)\n addlog(\"Atualizou a permissão de um usuário\")\n format.html { redirect_to @permitido, notice: 'Permissão atualizada com sucesso.' }\n format.json { render :show, status: :ok, location: @permitido }\n else\n format.html { render :edit }\n format.json { render json: @permitido.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n valid = true\n to_add = []\n to_remove = []\n unless params[:author] == nil\n params[:author].each_key do |author_id|\n author_assoc = params[:author][author_id]\n unless author_assoc.blank?\n to_remove << PublicationAuthor.find_by_id(author_id)\n p = Person.find(author_assoc).user\n if @publication.asset.creators.include?(p)\n @publication.errors.add_to_base(\"Multiple authors cannot be associated with the same MethodBox person.\")\n valid = false\n else\n to_add << p\n end\n end\n end\n end\n \n #Check for duplicate authors\n if valid && (to_add.uniq.size != to_add.size)\n @publication.errors.add_to_base(\"Multiple authors cannot be associated with the same MethodBox person.\")\n valid = false\n end\n\n respond_to do |format|\n if valid && @publication.update_attributes(params[:publication]) \n to_add.each {|a| @publication.asset.creators << a}\n to_remove.each {|a| a.destroy}\n \n #Create policy if not present (should be)\n if @publication.asset.policy.nil?\n @publication.asset.policy = Policy.create(:name => \"publication_policy\", :sharing_scope => 3, :access_type => 1, :use_custom_sharing => true)\n @publication.asset.save\n end\n \n #Update policy so current authors have manage permissions\n @publication.asset.creators.each do |author|\n @publication.asset.policy.permissions.clear\n # @publication.asset.policy.permissions << Permission.create(:contributor => author.person, :policy => @publication.asset.policy, :access_type => 4)\n permis = Permission.create(:contributor => author.person, :policy => @publication.asset.policy, :access_type => 4)\n permis.save\n end \n # @publication.asset.policy.save\n #Add contributor\n @publication.asset.policy.permissions << Permission.create(:contributor => @publication.contributor.person, :policy => @publication.asset.policy, :access_type => 4)\n permis = Permission.create(:contributor => @publication.contributor.person, :policy => @publication.asset.policy, :access_type => 4)\n permis.save\n # @publication.asset.save\n flash[:notice] = 'Publication was successfully updated.'\n format.html { redirect_to(@publication) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @publication.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @empresa.update(empresa_params) and @empresa.update_attributes(:modificador => current_user.id)\n format.html { redirect_to @empresa, notice: 'Empresa was successfully updated.' }\n format.json { render :show, status: :ok, location: @empresa }\n else\n format.html { render :edit }\n format.json { render json: @empresa.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @persona = Persona.find(params[:id])\n\n respond_to do |format|\n if @persona.update_attributes(params[:persona])\n format.html { redirect_to(admin_path(@persona), :notice => t('adminactualizado')) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @persona.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @persona = Persona.find(params[:persona_id])\n respond_to do |format|\n if @persona.info_extra_pacientes.update(info_extra_paciente_params)\n format.html { redirect_to @info_extra_paciente, notice: 'Info extra actualizada.' }\n format.json { render :show, status: :ok, location: @info_extra_paciente }\n else\n format.html { render :edit }\n format.json { render json: @info_extra_paciente.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @prepagada = Prepagada.find(params[:id])\n\n respond_to do |format|\n if @prepagada.update_attributes(params[:prepagada])\n format.html { redirect_to @prepagada, notice: 'Prepagada was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @prepagada.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n\t\traise CanCan::AccessDenied if !Presupuesto.accessible_by(current_ability, :update).include?(@presupuesto) \n respond_to do |format|\n if @presupuesto.update(presupuesto_params)\n sesion = Sesion.find_by(usuario_id: current_usuario.id, fechaFin: nil)\n if @presupuesto.evaluado then #el presupuesto fue evaluado\n if @presupuesto.aprobado then #el presupuesto fue aprobado\n description = \"El presupuesto del proyecto #{@presupuesto.proyecto.nombre} fue Aprobado.\"\n else\n description = \"El presupuesto del proyecto #{@presupuesto.proyecto.nombre} fue Rechazado.\"\n end\n else\n description = \"El presupuesto del proyecto #{@presupuesto.proyecto.nombre} fue puesto para evaluar nuevamente.\"\n end\n # Creacion de la transaccion con mensaje personalizado\n Transaccion.create!(descripcion: description,\n sesion_id: sesion.id, \n proyecto_id: @presupuesto.proyecto.id)\n\n format.html { redirect_to evaluar_presupuestos_pendientes_path }#@presupuesto, notice: 'El Presupuesto fue creado exitosamente.' }\n #format.json { render :show, status: :ok, location: @presupuesto }\n else\n format.html { render :edit }\n format.json { render json: @presupuesto.errors, status: :unprocessable_entity }\n end\n #if @presupuesto.update_attributes presupuesto_params#:aprobado #presupuesto_params #params[:presupuesto]\n #format.html { redirect_to :back }#evaluar_presupuestos_pendientes_path }\n #end\n end\n end", "def update\n @personaje_mision = PersonajeMision.find(params[:id])\n\n respond_to do |format|\n if @personaje_mision.update_attributes(params[:personaje_mision])\n format.html { redirect_to @personaje_mision, notice: 'Personaje mision was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @personaje_mision.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n pai = params[:pai] ? Conta.find_by_id(params[:pai]): nil\n \n respond_to do |format|\n if @conta.update(nome: conta_params[:nome], status: conta_params[:status], pai: pai) \n #format.json { render :show, status: :ok, location: @conta }\n format.json { render json: @conta.to_json, status: :ok }\n else \n format.json { render json: @conta.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @persona.update(persona_params)\n format.html { redirect_to @persona, notice: 'Datos personales actualizados exitosamente.' }\n format.json { render :show, status: :ok, location: @persona }\n else\n format.html { render :edit }\n format.json { render json: @persona.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @persona.update(persona_params)\n format.html {redirect_to personas_url, notice: 'Persona was successfully updated.'}\n format.json {render :show, status: :ok, location: @persona}\n else\n format.html {render :edit}\n format.json {render json: @persona.errors, status: :unprocessable_entity}\n end\n end\n end", "def update\n @pagamento = Pagamento.find(params[:id])\n\n respond_to do |format|\n if @pagamento.update_attributes(params[:pagamento])\n format.html { redirect_to @pagamento, notice: 'Pagamento was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @pagamento.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @promocion = Promocion.find(params[:id])\n logger.debug \"-------------------------------------------------------\"\n logger.debug params[:promocion][:formadepago_ids]\n logger.debug \"-------------------------------------------------------\"\n if (params[:promocion][:comercializable_ids] == nil)\n params[:promocion][:comercializable_ids] = []\n end\n\n if (params[:promocion][:formadepago_ids] == nil)\n params[:promocion][:formadepago_ids] = []\n end\n\n respond_to do |format|\n if @promocion.update_attributes(params[:promocion])\n format.html { redirect_to @promocion, :notice => 'Promocion was successfully updated.' }\n format.json { render json: @promocion}\n else\n format.html { render :action => \"edit\" }\n format.json { render json: @promocion.errors }\n end\n end\n end", "def update \n authorize! :editar, @imagen_laboratorio.laboratorio\n respond_to do |format|\n if @imagen_laboratorio.update(imagen_laboratorio_params)\n format.html { redirect_to @imagen_laboratorio, notice: 'La imagen del laboratorio fue correctamente modificada.' }\n format.json { render :show, status: :ok, location: @imagen_laboratorio }\n else\n format.html { render :edit }\n format.json { render json: @imagen_laboratorio.errors, status: :unprocessable_entity }\n end\n end\n end", "def ayty_replicate_memberships\n # usuario que sera atualizado\n @user = User.find(params[:id])\n\n @user.ayty_replicate_memberships_by_user_id(params[:ayty_user_stunt_id])\n\n @principal = Principal.find(@user.id)\n\n respond_to do |format|\n format.html { redirect_to edit_polymorphic_path(principal, :tab => 'memberships') }\n format.js\n end\n end", "def update\n @profesor_pertenece_asignatura = ProfesorPerteneceAsignatura.find(params[:id])\n\n respond_to do |format|\n if @profesor_pertenece_asignatura.update_attributes(params[:profesor_pertenece_asignatura])\n format.html { redirect_to @profesor_pertenece_asignatura, notice: 'Profesor pertenece asignatura was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @profesor_pertenece_asignatura.errors, status: :unprocessable_entity }\n end\n end\n end", "def agregar_profesor\n @grupo = Grupo.find(params[:id])\n if request.get?\n @profesores = Profesor.search(params[:buscar])\n end\n if request.put?\n @profesor = Profesor.find(params[:profesor_id])\n @grupo.profesor = @profesor\n flash[:notice] = \"Se modificó el profesor al grupo #{@grupo.nombre_completo}\" if @grupo.save\n redirect_to grupo_path(@grupo)\n end\n end", "def update\n verifica_user\n if (usu_total? || usu_publi?)\n respond_to do |format|\n if @publicidad.update(publicidad_params)\n format.html { redirect_to @publicidad, notice: 'Publicidad was successfully updated.' }\n format.json { render :show, status: :ok, location: @publicidad }\n else\n format.html { render :edit }\n format.json { render json: @publicidad.errors, status: :unprocessable_entity }\n end\n end\n else\n (redirect_to login_url, notice: \"Sin privilegios de publicista\")\n end\n end", "def update\n if !@current_user || (@current_user.admin != 1 && @current_user.admin != 2)\n return head :forbidden\n end\n respond_to do |format|\n if @repasgcc.update(repasgcc_params)\n format.html { redirect_to @repasgcc, notice: 'Le formulaire pour le repas du grupo a bien été modifié.' }\n format.json { render :show, status: :ok, location: @repasgcc }\n else\n format.html { render :edit }\n format.json { render json: @repasgcc.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @page = Page.find(params[:page][:id])\n if current_user.id != @page.owner_id\n not_found\n end\n @page.partial_update(params)\n respond_to do |format|\n format.json {\n render partial: 'pages/page.json'\n }\n end\n end", "def update\n @premio = Premio.find(params[:id])\n\n respond_to do |format|\n if @premio.update_attributes(params[:premio])\n format.html { redirect_to(@premio, :notice => 'Premio was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @premio.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @cliente.update(cliente_params)\n #--ADICIONADO\n \t @cliente.perfilclientes.destroy_all()\n if params[:cliente][:perfil_ids]\n \t\tparams[:cliente][:perfil_ids].each do |ss|\n \t\t\t@cliente.perfilclientes.create(:cliente_id => @cliente.id, :perfil_id => ss)\n \t\tend\n end\n #--ADICIONADO\n format.html { redirect_to clientes_url, notice: 'Cliente actualizado com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @cliente.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @pessoa = Pessoa.find(params[:id])\n\n respond_to do |format|\n if @pessoa.update_attributes(params[:pessoa])\n format.html { redirect_to pessoas_path, notice: 'Pessoa atualizada com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @pessoa.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @pagamento_aceito.update(pagamento_aceito_params)\n format.html { redirect_to @pagamento_aceito, notice: 'Pagamento aceito was successfully updated.' }\n format.json { render :show, status: :ok, location: @pagamento_aceito }\n else\n format.html { render :edit }\n format.json { render json: @pagamento_aceito.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @presupuestooo.update(presupuestooo_params)\n format.html { redirect_to @presupuestooo, notice: 'Presupuesto actualizado.' }\n format.json { render :show, status: :ok, location: @presupuestooo }\n else\n format.html { render :edit }\n format.json { render json: @presupuestooo.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @tipo_persona.update(tipo_persona_params)\n format.html { redirect_to @tipo_persona, notice: 'Tipo persona was successfully updated.' }\n format.json { render :show, status: :ok, location: @tipo_persona }\n else\n format.html { render :edit }\n format.json { render json: @tipo_persona.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if params[:person][:company_name]\n params[:person][:company] = Company.find_or_create_by_name(params[:person][:company_name])\n params[:person].delete(:company_name)\n end\n @person = Person.find(params[:id])\n\n authorize! :edit, @person\n \n respond_to do |format|\n if @person.update_attributes(params[:person])\n format.html { redirect_to @person, notice: 'Person was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @person.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @periodo_academico = PeriodoAcademico.find(params[:id])\n\n if @periodo_academico.update(params[:periodo_academico])\n head :no_content\n else\n render json: @periodo_academico.errors, status: :unprocessable_entity\n end\n end", "def update\n @presenza = Presenza.find(params[:id])\n\n respond_to do |format|\n if @presenza.update_attributes(params[:presenza])\n format.html { redirect_to @presenza, notice: 'Presenza was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @presenza.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @pagina = Pagina.find(params[:id])\n\n respond_to do |format|\n if @pagina.update_attributes(params[:pagina])\n format.html { redirect_to(@pagina, :notice => t('exito')) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @pagina.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @person.update(person_params)\n if current_user\n if current_user.user?\n current_user.person_id = @person.id\n current_user.save\n end\n end\n format.html { redirect_to @person, notice: 'Uppgifterna uppdaterades. Tack' }\n format.json { render :show, status: :ok, location: @person }\n else\n format.html { render :edit }\n format.json { render json: @person.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n #parametros_autocomplete!(params[:estudiante][:persona])\n @estudiante = Estudiante.find(params[:id])\n \n begin\n @estudiante.persona_id = params[:persona][:id]\n rescue\n end\n\n respond_to do |format|\n if @estudiante.update_attributes(params[:estudiante])\n format.html { redirect_to @estudiante, notice: 'Estudiante actualizado' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @estudiante.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @usuario_perfil.update(usuario_perfil_params)\n format.html { redirect_to @usuario_perfil, notice: 'Usuario perfil was successfully updated.' }\n format.json { render :show, status: :ok, location: @usuario_perfil }\n else\n format.html { render :edit }\n format.json { render json: @usuario_perfil.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @basico_persona_juridica.update(basico_persona_juridica_params)\n format.html { redirect_to @basico_persona_juridica, notice: 'Persona juridica was successfully updated.' }\n format.json { render :show, status: :ok, location: @basico_persona_juridica }\n else\n format.html { render :edit }\n format.json { render json: @basico_persona_juridica.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @permissao.update(permissao_params)\n format.html { redirect_to @permissao, notice: 'As permissões do voluntário foram atualizadas.' }\n format.json { render :show, status: :ok, location: @permissao }\n else\n format.html { render :edit }\n format.json { render json: @permissao.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n account = current_organization.accounts.find(params[:id])\n return forbidden unless account && current_account.allowed_to_edit_account?(account, current_organization)\n return json(account) unless account.update_attributes pick(params, :first_name, :last_name, :email,:language, :document_language)\n\n role = pick(params, :role)\n #account.update_attributes(role) if !role.empty? && current_account.admin?\n membership = current_organization.role_of(account)\n membership.update_attributes(role) if !role.empty? && current_account.admin?\n password = pick(params, :password)[:password]\n if (current_account.id == account.id) && password\n account.update(password: password)\n end\n json account.canonical(membership: membership)\n end", "def atualiza_um_pet_existente(objeto)\n uri = \"#{ENV['BASE_URI']}/pet\"\n \n without_authentication('put', uri, objeto.to_json)\n end", "def update\n @permiso = Permiso.find(params[:id])\n\n respond_to do |format|\n if @permiso.update_attributes(params[:permiso])\n format.html { redirect_to(@permiso, :notice => 'Permiso fue modificado exitosamente.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @permiso.errors, :status => :unprocessable_entity }\n end\n end\n end" ]
[ "0.70489043", "0.6467016", "0.6143503", "0.6128833", "0.6063074", "0.604816", "0.6046974", "0.6044596", "0.6041435", "0.59922636", "0.5991825", "0.59721786", "0.59666413", "0.59430414", "0.59428984", "0.5942153", "0.5934267", "0.5930359", "0.592473", "0.5901405", "0.58866197", "0.5880492", "0.5877208", "0.58752644", "0.58743674", "0.58684856", "0.5868432", "0.5863904", "0.58567536", "0.5854388", "0.5851071", "0.5848357", "0.58443016", "0.5835687", "0.58330274", "0.5819838", "0.5814463", "0.5805951", "0.5782898", "0.5780583", "0.5779877", "0.57783777", "0.5777036", "0.57738864", "0.577309", "0.5756207", "0.57522964", "0.5741451", "0.5740682", "0.57315415", "0.5720219", "0.5713802", "0.5706241", "0.5702063", "0.56930304", "0.56895846", "0.5688794", "0.5684356", "0.56831264", "0.5679188", "0.5679121", "0.5677144", "0.56743956", "0.56662595", "0.56593424", "0.56383926", "0.5637515", "0.5634056", "0.5632427", "0.5626168", "0.56223965", "0.56202424", "0.5619819", "0.5617697", "0.5617695", "0.56152475", "0.56152284", "0.56095", "0.56085277", "0.5608", "0.5605994", "0.5602107", "0.560179", "0.5597178", "0.5593921", "0.5593326", "0.5591829", "0.5589204", "0.55873764", "0.5584832", "0.55847657", "0.5583318", "0.557868", "0.55777156", "0.5575679", "0.5574935", "0.557275", "0.55715764", "0.5571574", "0.55690944" ]
0.7072099
0
DELETE /pagina_principals/1 DELETE /pagina_principals/1.json
def destroy @pagina_principal.destroy respond_to do |format| format.html { redirect_to pagina_principals_url, notice: 'Pagina principal was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @persona = Persona.find(params[:id])\n @persona.destroy\n\n respond_to do |format|\n format.json { head :ok }\n end\n \n end", "def destroy\n @asignatura.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def destroy\n @principalgroupe.destroy\n respond_to do |format|\n format.html { redirect_to principalgroupes_url, notice: 'Principalgroupe was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @perfisusuario.destroy\n respond_to do |format|\n format.html { redirect_to perfisusuarios_url, notice: 'Perfil de Usuário excluído com sucesso.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @perfilnegocio = Perfilnegocio.find(params[:id])\n @perfilnegocio.destroy\n\n respond_to do |format|\n format.html { redirect_to perfilnegocios_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @basico_persona_juridica.destroy\n respond_to do |format|\n format.html { redirect_to basico_persona_juridicas_url, notice: 'Persona juridica was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @analise_privacidade.destroy\n respond_to do |format|\n format.html { redirect_to analise_privacidades_url, notice: 'Analise privacidade was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n\t\tauthorize! :destroy, HistorialEstadoPresupuesto\n @historial_estado_presupuesto.destroy\n respond_to do |format|\n format.html { redirect_to historial_estado_presupuestos_url, notice: 'Historial estado presupuesto fue borrado satisfactoriamente.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @permiso.destroy\n respond_to do |format|\n format.html { redirect_to permisos_url, notice: 'Permiso fue eliminado.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @visitante_credenciado = VisitanteCredenciado.find(params[:id])\n @visitante_credenciado.destroy\n\n respond_to do |format|\n format.html { redirect_to visitante_credenciados_url }\n format.json { head :no_content }\n end\n \n end", "def destroy\n if current_user.nil?\n redirect_to(log_in_path) and return\n end\n\n @persona_vinculada = PersonaVinculada.find(params[:id])\n @persona_vinculada.destroy\n\n respond_to do |format|\n format.html { redirect_to personas_vinculadas_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @persona_tipo = PersonaTipo.find(params[:id])\n @persona_tipo.destroy\n\n respond_to do |format|\n format.html { redirect_to persona_tipos_url }\n format.json { head :ok }\n end\n end", "def destroy\n @pagina.destroy\n respond_to do |format|\n format.html { redirect_to paginas_url, notice: 'Pagina was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @permitido.destroy\n addlog(\"Negou permissão de um usuário\")\n respond_to do |format|\n format.html { redirect_to permitidos_url, notice: 'Permissão apagada com sucesso' }\n format.json { head :no_content }\n end\n end", "def destroy\n authorize! :eliminar, @usuario_prestamo\n @usuario_prestamo.destroy\n respond_to do |format|\n format.html { redirect_to usuario_prestamos_url, notice: 'El usuario de préstamo fue eliminado correctamente' }\n format.json { head :no_content }\n end\n end", "def destroy\n @datos_personal.destroy\n respond_to do |format|\n format.html { redirect_to datos_personals_url, notice: 'Datos personal was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @gran_unidad.destroy\n respond_to do |format|\n format.html { redirect_to gran_unidad_index_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @principal_establec = PrincipalEstablec.find(params[:id])\n @principal_establec.destroy\n\n respond_to do |format|\n format.html { redirect_to principal_establecs_url, notice: 'Registro eliminado satisfactoriamente.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @persona.destroy\n respond_to do |format|\n format.html { redirect_to administradores_path, notice: 'Persona was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n \tauthorize! :destroy, @palestrante\n @palestrante = Palestrante.find(params[:id])\n @palestrante.destroy\n\n respond_to do |format|\n format.html { redirect_to palestrantes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @prueba_json.destroy\n respond_to do |format|\n format.html { redirect_to prueba_jsons_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @profesor_pertenece_asignatura = ProfesorPerteneceAsignatura.find(params[:id])\n @profesor_pertenece_asignatura.destroy\n\n respond_to do |format|\n format.html { redirect_to profesor_pertenece_asignaturas_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @persona = Persona.find(params[:id])\n @persona.destroy\n\n respond_to do |format|\n format.html { redirect_to personas_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @persona = Persona.find(params[:id])\n @persona.destroy\n\n respond_to do |format|\n format.html { redirect_to personas_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @persona = Persona.find(params[:id])\n @persona.destroy\n\n respond_to do |format|\n format.html { redirect_to personas_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @profilsekolah.destroy\n respond_to do |format|\n format.html { redirect_to profilsekolahs_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @premio = Premio.find(params[:id])\n @premio.destroy\n\n respond_to do |format|\n format.html { redirect_to premios_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @premio = Premio.find(params[:id])\n @premio.destroy\n\n respond_to do |format|\n format.html { redirect_to premios_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @slider_principal.destroy\n respond_to do |format|\n format.html { redirect_to slider_principals_url, notice: 'Slider principal was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @asignatura = Asignatura.find(params[:id])\n @asignatura.destroy\n\n respond_to do |format|\n format.html { redirect_to asignaturas_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @asignatura = Asignatura.find(params[:id])\n @asignatura.destroy\n\n respond_to do |format|\n format.html { redirect_to asignaturas_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @pagenate = Pagenate.find(params[:id])\n @pagenate.destroy\n\n respond_to do |format|\n format.html { redirect_to pagenates_url }\n format.json { head :ok }\n end\n end", "def destroy\n @persona.destroy\n respond_to do |format|\n format.html { redirect_to personas_url, notice: 'Datos personales eliminados exitosamente.' }\n format.json { head :no_content }\n end\n end", "def destroy\n #--ADICIONADO\n @cliente.perfilclientes.destroy\n #--ADICIONADO\n @cliente.destroy\n respond_to do |format|\n format.html { redirect_to clientes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @paciente = Paciente.find(params[:id])\n @paciente.destroy\n\n respond_to do |format|\n format.html { redirect_to paciente_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @usuario_perfil.destroy\n respond_to do |format|\n format.html { redirect_to usuario_perfils_url, notice: 'Usuario perfil was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @pagos_servicio.destroy\n respond_to do |format|\n format.html { redirect_to pagos_servicios_url, notice: 'Pagos servicio was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @persona_proyecto.destroy\n respond_to do |format|\n format.html { redirect_to personas_proyectos_url, notice: 'Persona proyecto was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @pagamento = Pagamento.find(params[:id])\n @pagamento.destroy\n\n respond_to do |format|\n format.html { redirect_to pagamentos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n \n @analise_privacidade = @tipo_comunicacao.analise_privacidade_id\n \n #render :text => @privacidadetipo_comunicacoes_url\n \n @tipo_comunicacao.destroy\n respond_to do |format|\n format.html { redirect_to tipo_comunicacoes_path(@analise_privacidade), notice: 'Tipo comunicacao was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @personaje = Personaje.find(params[:id])\n @personaje.destroy\n\n respond_to do |format|\n format.html { redirect_to personajes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @patrocinio = Patrocinio.find(params[:id])\n @patrocinio.destroy\n\n respond_to do |format|\n format.html { redirect_to patrocinios_url }\n format.json { head :ok }\n end\n end", "def destroy\r\n @sivic_userpermissao.destroy\r\n respond_to do |format|\r\n format.html { redirect_to sivic_userpermissaos_url }\r\n format.json { head :no_content }\r\n end\r\n end", "def destroy\n @presupuestooo.destroy\n respond_to do |format|\n format.html { redirect_to presupuestooos_url, notice: 'Presupuesto Eliminado.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @centro_usuario.destroy\n respond_to do |format|\n format.html { redirect_to centro_usuarios_url, notice: 'Centro usuario was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @principal_caracteristica.destroy\n respond_to do |format|\n format.html { redirect_to principal_caracteristicas_url, notice: 'Principal caracteristica was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @paciente = Paciente.find(params[:id])\n @paciente.destroy\n\n respond_to do |format|\n format.html { redirect_to \"/administrador/pacientes\" }\n format.json { head :no_content }\n end\n end", "def destroy\r\n @sivic_profissao.destroy\r\n respond_to do |format|\r\n format.html { redirect_to sivic_profissaos_url }\r\n format.json { head :no_content }\r\n end\r\n end", "def destroy\n @asociado = Asociado.find(params[:id])\n @asociado.destroy\n\n respond_to do |format|\n format.html { redirect_to asociados_url }\n format.json { head :ok }\n end\n end", "def destroy\n @personaje_mision = PersonajeMision.find(params[:id])\n @personaje_mision.destroy\n\n respond_to do |format|\n format.html { redirect_to personaje_misions_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @paise = Paise.find(params[:id])\n @paise.destroy\n\n respond_to do |format|\n format.html { redirect_to paises_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @tipo_usuario = TipoUsuario.find(params[:id])\n @tipo_usuario.destroy\n\n respond_to do |format|\n format.html { redirect_to tipo_usuarios_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @perdida.destroy\n respond_to do |format|\n format.html { redirect_to perdidas_url, notice: 'Se ha Borrado el Registro.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @datos_insumos_reactivo.destroy\n respond_to do |format|\n format.html { redirect_to datos_insumos_reactivos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @profesor = Profesor.find(params[:id])\n @profesor.destroy\n\n respond_to do |format|\n format.html { redirect_to root_path, notice: 'Profesor eliminado correctamente' }\n format.json { head :no_content }\n end\n end", "def destroy\n @pagamento = Pagamento.find(params[:id])\n os = @pagamento.os\n @pagamento.destroy\n\n respond_to do |format|\n #format.html { redirect_to pagamentos_url }\n format.html { redirect_to os }\n format.json { head :no_content }\n end\n end", "def destroy\n @personal_rubro.destroy\n respond_to do |format|\n format.html { redirect_to personal_rubros_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @capacidad = Capacidad.find(params[:id])\n @capacidad.destroy\n\n respond_to do |format|\n format.html { redirect_to capacidades_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @emailusuario = Emailusuario.find(params[:id])\n @emailusuario.destroy\n\n respond_to do |format|\n format.html { redirect_to verPerfil_path(:id => current_user.id) }\n format.json { head :no_content }\n end\n end", "def destroy\n @minha_pagina.destroy\n respond_to do |format|\n format.html { redirect_to minha_paginas_url, notice: 'Minha pagina was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @datos_usuario.destroy\n respond_to do |format|\n format.html { redirect_to datos_usuarios_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user_vacancy.destroy\n respond_to do |format|\n format.html { redirect_to user_vacancies_url, notice: 'Aplicación eliminada correctamente' }\n format.json { head :no_content }\n end\n end", "def destroy\r\n @sivic_permissao.destroy\r\n respond_to do |format|\r\n format.html { redirect_to sivic_permissaos_url }\r\n format.json { head :no_content }\r\n end\r\n end", "def destroy\n @paciente = Paciente.find(params[:id])\n @paciente.destroy\n\n respond_to do |format|\n format.html { redirect_to pacientes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @relatorio_pedagogicos = RelatorioPedagogico.all\n authorize @relatorio_pedagogicos\n\n @relatorio_pedagogico.destroy\n respond_to do |format|\n format.html { redirect_to relatorio_pedagogicos_url, notice: 'Relatório pedagógico deletado com sucesso!' }\n format.json { head :no_content }\n end\n end", "def destroy\n @suplente = Suplente.find(params[:id])\n @suplente.destroy\n\n respond_to do |format|\n format.html { redirect_to suplentes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @permiso = Permiso.find(params[:id])\n @permiso.destroy\n\n respond_to do |format|\n format.html { redirect_to(permisos_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @profesore = Profesore.find(params[:id])\n @profesore.destroy\n\n respond_to do |format|\n format.html { redirect_to profesores_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @ventas_presupuesto = Ventas::Presupuesto.find(params[:id])\n @ventas_presupuesto.destroy\n\n respond_to do |format|\n format.html { redirect_to ventas_presupuestos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @perfil_egresado.destroy\n respond_to do |format|\n format.html { redirect_to perfil_egresados_url, notice: 'Perfil egresado was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @servico_pacote.destroy\n respond_to do |format|\n format.html { redirect_to servico_pacotes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @pagamento_aceito.destroy\n respond_to do |format|\n format.html { redirect_to pagamento_aceitos_url, notice: 'Pagamento aceito was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n \n @lancamentorapido = Lancamentorapido.find(params[:id])\n @lancamentorapido.destroy \n\n respond_to do |format|\n format.html { redirect_to lancamentorapidos_path }\n format.json { head :no_content }\n end\n end", "def destroy\n @paise.destroy\n respond_to do |format|\n format.html { redirect_to paises_url, notice: 'Paise was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @anuncio = current_user.anuncios.find(params[:id])\n @anuncio.destroy\n \n respond_to do |format|\n format.html { redirect_to anuncios_url, notice: 'Anuncio excluido.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @cliente = Cliente.find(params[:cliente_id])\n @pago = @cliente.pagos.find(params[:id])\n @pago.destroy\n\n respond_to do |format|\n format.html { redirect_to [@cliente, @pago] }\n format.json { head :no_content }\n end\n end", "def destroy\n authorize @colaboradore\n @colaboradore.destroy\n respond_to do |format|\n format.html { redirect_to colaboradores_url, notice: 'Colaborador eliminado.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @medicos_autorizado = current_user.medicos_autorizados.find(params[:id])\n @medicos_autorizado.destroy\n\n respond_to do |format|\n format.html { redirect_to current_user }\n format.json { head :no_content }\n end\n end", "def destroy\n @unidad.destroy\n respond_to do |format|\n format.html { redirect_to unidades_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @uneautrepage.destroy\n respond_to do |format|\n format.html { redirect_to uneautrepages_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @pagina.destroy\n respond_to do |format|\n format.html { redirect_to produto_paginas_path(@produto), notice: 'Pagina was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @os_groups_principal.destroy\n respond_to do |format|\n format.html { redirect_to os_groups_principals_url, notice: 'Os groups principal was successfully destroyed.' }\n format.json { head :no_content }\n end\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 destroy\n # Delete profile\n @profil.destroy\n respond_to do |format|\n format.html { redirect_to profils_url, notice: 'Profil was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @tipo_pensum = TipoPensum.find(params[:id])\n @tipo_pensum.destroy\n\n respond_to do |format|\n format.html { redirect_to tipo_pensums_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @pagamento = Pagamento.find(params[:id])\n @pagamento.destroy\n\n respond_to do |format|\n format.html { redirect_to @pagamento.serata }\n format.json { head :no_content }\n end\n end", "def destroy\n @prepagada = Prepagada.find(params[:id])\n @prepagada.destroy\n\n respond_to do |format|\n format.html { redirect_to prepagadas_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @proyecto_patrocinador.destroy\n respond_to do |format|\n format.html { redirect_to proyecto_patrocinadors_url, notice: 'Proyecto patrocinador was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n if !@current_user || (@current_user.admin != 1 && @current_user.admin != 2)\n return head :forbidden\n end\n @repasgcc.destroy\n respond_to do |format|\n format.html { redirect_to repasgccs_url, notice: 'Le formulaire pour le repas du grupo a bien été supprimé.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @detalle_ot_presupuesto.destroy\n respond_to do |format|\n format.html { redirect_to detalle_ot_presupuestos_url, notice: 'Detalle ot presupuesto was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @autorizacion.destroy\n respond_to do |format|\n format.html { redirect_to autorizacions_url, notice: 'Autorizacion was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @estado_persona.destroy\n respond_to do |format|\n format.html { redirect_to estado_personas_url, notice: 'Se ha eliminado el estado.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @nivel_academico.destroy\n respond_to do |format|\n format.html { redirect_to nivel_academicos_url, notice: 'Nivel academico was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @pagos_publicidad.destroy\n respond_to do |format|\n format.html { redirect_to pagos_publicidads_url, notice: 'Pagos publicidad was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @pagina = Pagina.find(params[:id])\n @pagina.destroy\n\n respond_to do |format|\n format.html { redirect_to(paginas_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @servicio = Servicio.find(params[:id])\n @servicio.destroy\n\n respond_to do |format|\n format.html { redirect_to servicios_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @instituicao = Instituicao.find(params[:id])\n @instituicao.destroy\n\n respond_to do |format|\n format.html { redirect_to instituicoes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @accidente.destroy\n respond_to do |format|\n format.html { redirect_to accidentes_url, notice: 'Accidente was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @tipo_unidad.destroy\n respond_to do |format|\n format.html { redirect_to tipo_unidades_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @personal_account = PersonalAccount.find(params[:id])\n @personal_account.destroy\n\n respond_to do |format|\n format.html { redirect_to personal_accounts_url }\n format.json { head :ok }\n end\n end" ]
[ "0.7025209", "0.7020778", "0.69988394", "0.69913095", "0.6964188", "0.69519305", "0.6944103", "0.6919521", "0.69168353", "0.6915807", "0.6914297", "0.6909983", "0.6886086", "0.68858635", "0.68801904", "0.68636686", "0.6856292", "0.6855705", "0.68552876", "0.68535185", "0.6851897", "0.68500185", "0.68357885", "0.68357885", "0.68357885", "0.68341726", "0.6833685", "0.6833685", "0.68267554", "0.6825398", "0.6825398", "0.6815225", "0.68084854", "0.6808146", "0.6798217", "0.6781163", "0.677361", "0.67735904", "0.67729205", "0.6772437", "0.6772359", "0.6772225", "0.67677736", "0.675969", "0.6757995", "0.6757951", "0.6746293", "0.674064", "0.6736173", "0.67342085", "0.6733708", "0.6732072", "0.6731071", "0.67259943", "0.6721175", "0.6719283", "0.671909", "0.6717095", "0.67149216", "0.67114866", "0.67114204", "0.67110336", "0.6709076", "0.6708539", "0.67035383", "0.67016774", "0.6701138", "0.67009205", "0.66960096", "0.6695906", "0.6695075", "0.6693303", "0.6691951", "0.66910976", "0.6688318", "0.6687964", "0.6686985", "0.66868514", "0.66726583", "0.66681665", "0.6667104", "0.6664263", "0.6662907", "0.6660617", "0.66573393", "0.6655739", "0.6655021", "0.66536033", "0.6652903", "0.6651724", "0.6651596", "0.66463226", "0.6641429", "0.6639479", "0.663676", "0.6636592", "0.66333795", "0.6632845", "0.6631042", "0.66309065" ]
0.76799166
0
Use callbacks to share common setup or constraints between actions.
def set_pagina_principal @pagina_principal = PaginaPrincipal.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 pagina_principal_params params.require(:pagina_principal).permit(:index) 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
keep getting http error 500 still needs fix
def create_message(user_id, recipient_id, token , subject, message) response = self.class.post('/messages', body: { "user_id": user_id, "recipient_id": recipient_id,"token": token , "subject": subject, "stripped-text": message }, headers: { "authorization" => @auth_token }) puts response end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def error\n render plain: '500 Internal Server Error', status: :internal_server_error\n end", "def server_errors; end", "def status_error\n @status = 500\n end", "def status\n 500\n end", "def internal_error\n\t\tself.status = 500\n\t\tself.headers = {}\n\t\tself.content = [\"Internal error\"]\n\t\tself\n\tend", "def error_500\n render 'error/error500'\n end", "def server_error?; end", "def error_500\n if !request.xhr?\n render :template => \"errors/500\", :status => \"500 Internal Server Error\"\n else\n respond_to do |format|\n format.json {render :json => {\n :error => \"500\",\n }, :status => \"500\"}\n end\n end\n end", "def render_500\n error = { :message => \"Server error - Something went wrong at our end\"}\n render :json => error, :status => 500\n end", "def status_code\n 500 # This should not be called directly\n end", "def no_500_error!\n return true if browser.all(:css, 'head title', :text => 'Internal Server Error').empty?\n sleep 30 if ENV['GIMME_CRAP']\n raise Unexpected500, browser.body\n end", "def server_error\n\n end", "def internal_server_error\n @exception = env['action_dispatch.exception']\n #TODO: log exception information you want to log here\n # after removing it from the normal logging via lograge\n render status: 500\n end", "def send_error(e, res)\n res.status = 500\n res['Content-Type'] = 'application/json'\n body = { code: -1, error: \"#{e.class}: #{e.message}\" }\n body[:backtrace] = e.backtrace\n res.body = @shell.data(body).json(@shell.indent)\n @shell.logger.warn(Impl.format_error(e))\n\tend", "def internal_server_error\r\n redirect_to(request.referrer || root_path, alert: 'Internal Server Error', status: 500)\r\n end", "def render_500(exception = nil)\n if exception\n# twit_msg = \"http://www.megam.co: error, support issue created.\".slice! 0..140\n# client = Twitter::REST::Client.new do |config|\n# config.consumer_key = ENV['TWITTER_CLIENT_ID']\n# config.consumer_secret = ENV['TWITTER_SECRET_KEY']\n# config.access_token =ENV['TWITTER_ACCESS_TOKEN']\n# config.access_token_secret =ENV['TWITTER_ACCESS_TOKEN_SECRET']\n# end\n# begin\n# client.update(twit_msg)\n# rescue Twitter::Error\n# ## just ignore twitter errors.\n# end\n\n short_msg = \"(#{exception.message})\"\n filtered_trace = exception.backtrace.grep(/#{Regexp.escape(\"nilavu\")}/)\n if !filtered_trace.empty?\n full_stacktrace = filtered_trace.join(\"\\n\")\n Rails.logger.fatal \"\\n#{short_msg}\"\n Rails.logger.fatal \"#{full_stacktrace}\"\n UserMailer.error_email({:email => current_user[\"email\"], :message =>\"#{short_msg}\", :stacktrace => \"#{full_stacktrace}\" }).deliver\n end\n end\n respond_to do |format|\n format.html { render template: 'errors/internal_server_error', layout: 'application', status: 500 }\n format.js { render template: 'errors/internal_server_error', layout: 'application', status: 500 }\n format.all { render nothing: true, status: 500}\n end\n end", "def throw500(msg = \"\", details = nil)\n MU.log \"Returning 500 to client: #{msg}\", MU::ERR, details: details\n page = genHTMLMessage(title: \"500 Error\", headline: msg, msg: details)\n [\n 500,\n {\n 'Content-Type' => 'text/html',\n 'Content-Length' => page.length.to_s\n },\n [page]\n ]\nend", "def send_error(e, res)\n res.code = 500\n res['Content-Type'] = 'application/json'\n body = { code: -1, error: \"#{e.class}: #{e.message}\" }\n body[:backtrace] = e.backtrace\n res.body = @shell.data(body).json(@shell.indent)\n @shell.logger.warn(Impl.format_error(e))\n\tend", "def serve_exception(_exception); end", "def internal_server_error(object)\n render json: object, status: 500\n end", "def handle_request_error(exception)\n end", "def server_error?\n 500 <= code && code < 600\n end", "def error_403\n end", "def api_error; end", "def is_server_error?\n code.to_i >= 500 && code.to_i <= 599\n end", "def handle_500(exception = env[\"action_dispatch.exception\"])\n # Some one requested '/500' directly?\n if exception.blank?\n if (error_500_url_alias = Settler[:error_page_500]).present? && @node = Node.find_by_url_alias(error_500_url_alias)\n @page = @node.content\n render :template => 'pages/show', :status => :internal_server_error\n else\n render :template => 'errors/500', :status => :internal_server_error\n end\n return\n end\n\n if Rails.env.test?\n puts \"\\n#{exception.message}\"\n puts exception.backtrace.join(\"\\n\")\n end\n\n send_exception_notification(exception)\n error = { :error => \"#{exception} (#{exception.class})\", :backtrace => exception.backtrace.join('\\n') }\n @page_title = t('errors.internal_server_error')\n\n respond_to do |f|\n f.html do\n if request.xhr?\n render :json => error.to_json, :status => :internal_server_error\n else\n set_view_paths\n if (error_500_url_alias = Settler[:error_page_500]).present? && @node = Node.find_by_url_alias(error_500_url_alias)\n @page = @node.content\n render :template => 'pages/show', :status => :internal_server_error\n else\n render :template => 'errors/500', :status => :internal_server_error\n end\n end\n end\n f.xml { render :xml => error.to_xml, :status => :internal_server_error }\n f.any(:json, :js) { render :json => error.to_json, :status => :internal_server_error }\n f.any(:rss, :atom) { render :xml => error.to_xml, :status => :internal_server_error, :layout => false }\n f.all { render :nothing => true, :status => :internal_server_error }\n end\n end", "def before_server_error(exception); end", "def handle_error(error)\n # Can be overridden\n render plain: error.inspect, status: 500\n end", "def server_error\n messages = [\"Captain!\", \"Man overboard!\", \"Ekk!\"]\n MsteamsNotifier::Message.quick_message \"#{messages.sample} We've had a 500 error at #{request.referrer}\"\n render status: 500, layout: \"dash/error\"\n end", "def render_500\n render 'errors/index_500'\n end", "def check_for_errors\n info = MultiJson.load(self.body).first\n\n if info['result'] && info['result'] != 0\n if info['result'] == 500\n raise Webceo::Api::ServerError.new(self.status.to_i, self.body)\n else\n raise Webceo::Api::ClientError.new(self.status.to_i, self.body)\n end\n end\n end", "def error\n\t\t@page_title = '500 Error'\n\t\t@url_path = get_path\n\t\tflash.now[:error] = \"An error occurred while attempting to access ‘#{@path}’.\"\n\t\trender :action=>'error', :status=>'500 Error'\n\tend", "def render_500(exception = nil)\n puts_stacktrace(exception) if exception\n if !signed_in?\n # gflash error: \"#{exception.message}\"\n redirect_to signin_path, flash: { error: 'You must first sign in or sign up.' }\n else\n respond_to do |format|\n format.html { render template: 'errors/internal_server_error', layout: 'application', status: 500 }\n format.js { render template: 'errors/internal_server_error', layout: 'application', status: 500 }\n format.all { render nothing: true, status: 500 }\n end\n end\n end", "def bite\n raise @_error if @_error\n before\n response(handle_call)\n rescue Exception => e\n code, error = 500, e\n if Lunetas::Error::BaseError === e\n code = e.code\n elsif development?\n error = \"Error: #{e.message}\\nBacktrace: #{e.backtrace.join(\"\\n\")}\"\n end\n response(error, code)\n end", "def set_error(ex, backtrace=false)\n\n # set repsonse headers\n @status = 404;\n @header['content-type'] = \"text/html; charset=UTF-8\"\n\n # set response content\n @body = ''\n @body << <<-_end_of_html_\n \n <HTML>\n <HEAD>\n <TITLE>No page for you!</TITLE>\n\n <STYLE type=\"text/css\">\n BODY { font: 8pt/12pt verdana }\n H1 { font: 13pt/15pt verdana }\n H2 { font: 8pt/12pt verdana }\n A:link { color: black; text-decoration: none }\n A:visited { color: black; text-decoration: none }\n </STYLE>\n\n </HEAD><BODY>\n <TABLE width=500 border=0 cellspacing=10>\n <TR>\n <TD>\n\n <h1><a href=\"http://www.bindshell.net/tools/beef/\">These aren't the pages you're looking for</a></h1>\n \n </TD>\n </TR>\n </TABLE>\n </BODY>\n </HTML>\n \n _end_of_html_\n \n end", "def internal_error(exception)\n data = error('internal_error', 'We have been notified.', format_exception(exception))\n [500, hdrs(content_length: data_size(data)), [data]]\n end", "def render_error(msg, status)\n render_403\n end", "def respond_bad_request; make_response(nil, false, 400, \"Bad Request\") end", "def hastur_error!(code=501, message=\"FAIL\", bt=[])\n error = {\n :status => code,\n :message => message,\n :backtrace => bt.kind_of?(Array) ? bt[0..10] : bt\n }\n\n # remove this after getting the loggers to do the right thing\n STDERR.puts MultiJson.dump(error, :pretty => true)\n\n if self.is_a? Grape::API\n throw :error, error\n elsif self.is_a? Sinatra::Base\n error[:url] = request.url\n halt serialize(error, {})\n else\n abort \"BUG: not a Grape::API or Sinatra::Base\"\n end\n end", "def server_error?\n (500...600).include?(@status_code)\n end", "def standard_error(error)\n #When we rescue an error, we prevent our program from doing what\n #it normally would do - crashing, such as logging the details\n #and the backtrace. it's important to always log this information\n #when rescuing a general type\n\n #Use the logger.error method with an error's message to\n #log the error details again\n logger.error error.full_message\n\n render(\n status: 500,\n json:{\n status:500,\n errors:[{\n type: error.class.to_s,\n message: error.message\n }]\n }\n )\n end", "def five_hundred(_error)\n json_response({ message: Message.something_went_wrong }, :internal_server_error)\n end", "def render_error_500(error)\n notify_unhandled_exception(error)\n response = ErrorResponse.new(500)\n response.add(500, 'internal_server_error', meta: error_metadata(error))\n render_error(response)\n end", "def server_error?\n @status.between?(500, 599) if @status\n end", "def five_hundred(error)\n json_response(error.message, :internal_server_error)\n end", "def check_errors_or_500(object)\n \n if(object.errors.messages)\n render json: object.errors.messages.to_json, status: 400\n else\n render json: {error: \"Internal server error\"}.to_json, status: 500\n end\n\n end", "def server_error?\n (500..599).cover?(code)\n end", "def client_error?; end", "def is_server_error?\n @code.in? 500..599\n end", "def severe_error(note =\"\", excpt)\n if @controller and @controller.class < ApplicationController\n @controller.expires_now\n @controller.head :internal_server_error,\n x_error_details: 'Something is wrong with this relay. Try again later.'\n end\n _log_exception ERROR,note,excpt\n end", "def status_bad_request\n respond_to do |format|\n format.any { head :bad_request }\n end\n end", "def render_500(exception = nil)\n JsonApiServer.logger.error(exception.try(:message))\n JsonApiServer.logger.error(exception.try(:backtrace))\n\n errors = JsonApiServer.errors(\n status: 500,\n title: I18n.t('json_api_server.render_500.title'),\n detail: I18n.t('json_api_server.render_500.detail')\n )\n render json: errors.to_json, status: 500\n end", "def server_error_status_code\n _undefined\n end", "def error?\n (500..599).include?(status)\n end", "def foreign_server_failure\n [ 503, {'Content-Type'=>'text/plain', 'Content-Length' => '23'},\n ['Foreign server failure.'] ]\n end", "def render_error_status(status=500, log_msg = \"\")\n logger.error \"REQUEST **************** Rendering #{status}: #{log_msg}. Request URI: #{request.url} ****************\"\n render :file => \"#{Rails.root}/public/#{status}.html\", :status => status, :layout => false\n return false\n end", "def default_errors!\n configure :production do\n error ::Exception do\n boom = env['sinatra.error']\n logger.error [\"#{boom.class} - #{boom.message}:\", *boom.backtrace].join(\"\\n \")\n response.status = 500\n content_type 'text/html'\n '<h1>Internal Server Error</h1>'\n end\n end\n end", "def errorhandling\n end", "def rescue_action_in_public(exception)\n render :template => \"shared/error\", :status => \"500\"\n end", "def handle_exception(e, env)\n trace = e.backtrace.join \"\\n\"\n Tom::Log.logger.info e\n Tom::Log.logger.info trace\n [500, {}, {error: e,\n stacktrace: trace,\n url: env[\"REQUEST_URI\"]\n }.to_json]\n end", "def internal_server_error(exception = nil)\n error_rendering exception, __callee__\n end", "def error(code=500, body = nil)\n unless code.is_a?(Integer)\n body = code\n code = 500\n end\n\n response.status = code\n response.body = body if body\n halt\n end", "def unavailable\n render \"errors/503\", :status => 503 \n\tend", "def checkError\n status = Array.new\n if params[:offset]\n if params[:limit] != \"\"\n urlMasters = Urlmaster.limit(params[:limit].to_i).offset(params[:offset].to_i)\n else\n urlMasters = Urlmaster.offset(params[:offset].to_i)\n end\n else\n if params[:limit] != \"\"\n urlMasters = Urlmaster.limit(params[:limit].to_i).offset(0)\n else\n redirect_to crawler_path\n urlMasters = Urlmaster.all\n end\n end\n\n message = Array.new\n for url in urlMasters \n if url[\"venueFloorMapImageUrl\"] && url[\"venueFloorMapImageUrl\"] != \"NA\" && url[\"venueFloorMapImageUrl\"] != \"\"\n uri = URI(url[\"venueFloorMapImageUrl\"])\n begin \n res = Net::HTTP.get_response(uri)\n status << res.code\n message << url[\"venueFloorMapImageUrl\"] + res.code\n u = Urlmaster.find(url.id)\n u.update(:statusCode => res.code)\n rescue => e\n next\n end\n end\n if url[\"venueFloorMapUrl\"] && url[\"venueFloorMapUrl\"] != \"NA\" && url[\"venueFloorMapUrl\"] != \"\"\n uri = URI(url[\"venueFloorMapUrl\"])\n begin \n res = Net::HTTP.get_response(uri)\n status << res.code\n message << url[\"venueFloorMapUrl\"] + res.code\n u = Urlmaster.find(url.id)\n u.update(:statusCodeWeb => res.code)\n rescue => e\n next\n end\n end\n end\n flash[:success] = \"Refresh successfully!\"\n render :json => message\n end", "def check_error(response) #:nodoc:\n case response.code\n when 200 then # ignore, ok\n when 500 then\n raise Error, 'server error'\n when 601 then\n raise AddressError, 'missing address'\n when 602 then\n raise AddressError, 'unknown address'\n when 603 then\n raise AddressError, 'unavailable address'\n when 610 then\n raise CredentialsError, 'invalid key'\n when 620 then\n raise CredentialsError, 'too many queries'\n else\n raise Error, \"unknown error #{response.code}\"\n end\n end", "def status_code; end", "def bad_request\n #redirect_to \"#{Rails.root}/public/400.html\"\n raise ActionController::RoutingError.new('Bad Request')\n end", "def generic_exception(error)\n render json: {\n success: false,\n message: error.message\n }, status: :internal_server_error\n end", "def four_twenty_two(error)\n json_response(error.message, :unprocessable_entity)\n end", "def stuff_999_response(env, err)\n env.tap do\n _1.reason_phrase = \"#{err.class} #{err.message}\"\n _1.response_body = ''\n _1.response_headers = Faraday::Utils::Headers.new\n _1.status = HTTPDisk::ERROR_STATUS\n end\n Faraday::Response.new(env)\n end", "def render_error(exception = nil)\n\trespond_to do |format|\n\t\tformat.html{\n\t\t\trender :file => \"/app/views/errors/500.html.erb\", :status => 500, :layout => \"application\"\n\t\t}\n\t\tformat.xml { head :not_found }\n\t\tformat.any { head :not_found }\t\n\tend\n end", "def error code, body=nil\n code, body = 500, code if code.respond_to? :to_str\n @response.body = body unless body.nil?\n halt code\n end", "def error(url); end", "def generic_exception(error)\n render json: {\n error: error.message\n }, status: :internal_server_error\n end", "def unexpected_error(e)\n log_error(\"Unexpected error while processing request\", e)\n end", "def error?\n http_status >= 400 && http_status <= 599\n end", "def catch_exceptions; end", "def render_503(message = nil)\n errors = JsonApiServer.errors(\n status: 500,\n title: I18n.t('json_api_server.render_503.title'),\n detail: message || I18n.t('json_api_server.render_503.detail')\n )\n render json: errors.to_json, status: 503\n end", "def client_error?\n 400 <= code && code < 500\n end", "def exceptions; end", "def exception; end", "def exception; end", "def exception; end", "def exception; end", "def exception; end", "def render_error(err)\n json_response({ message: err }, :unprocessable_entity)\n end", "def handle_error(client, e)\n code = case e\n when EOFError,Errno::ECONNRESET,Errno::EPIPE,Errno::ENOTCONN\n # client disconnected on us and there's nothing we can do\n when Unicorn::RequestURITooLongError\n 414\n when Unicorn::RequestEntityTooLargeError\n 413\n when Unicorn::HttpParserError # try to tell the client they're bad\n 400\n else\n Unicorn.log_error(@logger, \"app error\", e)\n 500\n end\n if code\n client.kgio_trywrite(err_response(code, @request.response_start_sent))\n end\n client.close\n rescue\n end", "def __raise_transport_error(response)\n error = ERRORS[response.status] || ServerError\n raise error.new \"[#{response.status}] #{response.body}\"\n end", "def error; end", "def error; end", "def error; end", "def error; end", "def error; end", "def error; end", "def error; end", "def bad_request_status\n status_message(400)\n end", "def client_error?\n (400...500).include?(@status_code)\n end", "def error!(url); end", "def render_error exception\n\n logger.info\"==========error 500=========\"\n #Rails.logger.error(exception)\n #render :template => \"/errors/500.html.erb\", :status => 500\n logger.info \"#{'-'*100} #{request.format} #{'-'*100}\"\n @error = exception\n ActiveSupport::Notifications.instrument \"exception.action_controller\", message: @error.message, inspect: @error.inspect, backtrace: @error.backtrace\n respond_to do |format|\n format.html { render template: \"errors/error_500\", status: 500, layout:false }\n format.all { render nothing: true, status: 500}\n\n end\n log_exception_handler(exception)\n end", "def render_not_found\n respond_to do |f|\n f.html{ render :template => \"errors/500\", :status => 500}\n end\n end", "def error\n expires_in 1.month, public: true\n set_metadata({ 'title' => translate('errors.error') })\n render status: request.env['PATH_INFO'][1, 3].to_i\n end" ]
[ "0.72961783", "0.72279507", "0.7225323", "0.72223186", "0.7172752", "0.7141435", "0.7029317", "0.70184904", "0.70069003", "0.69799477", "0.6934629", "0.69206107", "0.6844465", "0.68157524", "0.6799318", "0.67815083", "0.67701286", "0.67473626", "0.6742689", "0.67346585", "0.67006457", "0.66891617", "0.6688817", "0.6612718", "0.6610243", "0.6603593", "0.6602125", "0.6597704", "0.6595915", "0.65947133", "0.65816194", "0.65812695", "0.65410846", "0.6539687", "0.6479442", "0.64446616", "0.64440125", "0.6432686", "0.64297247", "0.6412581", "0.6397974", "0.6377321", "0.6345718", "0.6334122", "0.63284177", "0.6324128", "0.62906134", "0.62745214", "0.6268668", "0.62597376", "0.62560505", "0.62516177", "0.62379533", "0.6232767", "0.6223378", "0.62148887", "0.6204767", "0.6204498", "0.61992675", "0.61980546", "0.61902654", "0.618835", "0.61683154", "0.6144503", "0.61403286", "0.6134275", "0.6116962", "0.6112913", "0.6105104", "0.6089794", "0.60865766", "0.6080983", "0.607524", "0.6072701", "0.60474205", "0.60262173", "0.60223716", "0.60218513", "0.6018117", "0.6012948", "0.59916764", "0.59916764", "0.59916764", "0.59916764", "0.59916764", "0.598805", "0.5987353", "0.5982973", "0.5980966", "0.5980966", "0.5980966", "0.5980966", "0.5980966", "0.5980966", "0.5980966", "0.59756917", "0.5969796", "0.59633046", "0.5946707", "0.59427005", "0.59354" ]
0.0
-1
type: 0 seed 1 links 2 backlinks
def parsetitle( titles, type, parentid ) apiurl='http://en.wikipedia.org/w/api.php' ## resulthash links=Hash.new #### First query, no plcontinue query = { 'action'=>'query', 'prop'=>'info', 'redirects'=>'', 'inprop'=>'url', 'format'=>'json', } ### Separate by type case type when 0 #### seed continueterm='incontinue' query['titles'] = titles when 1 #### links continueterm='gplcontinue' linksterm='links' query['generator']=linksterm query['titles'] = titles query['gplnamespace'] = '0' query['gpllimit'] = 'max' when 2 #### backlinks continueterm='gblcontinue' linksterm='backlinks' query['gbltitle'] = titles query['generator'] = 'backlinks' query['gblnamespace'] = '0' query['gbllimit'] = 'max' else puts "This shouldn't happen." exit -1 end # puts query # exit; postData = Net::HTTP.post_form(URI.parse(apiurl), query); ## parse and save result result = JSON.parse(postData.body) pages=result["query"]["pages"].keys <<<<<<< HEAD ======= i=0 >>>>>>> ff128337f961ce2c8d1c7273ff20bd093e5188a6 result["query"]["pages"].each do |page| if page[1]["title"] != nil and page[1]["length"] != nil links[page[1]["title"]] = { "length" => page[1]["length"], "url"=>page[1]["fullurl"], "pageid"=>page[1]["pageid"], "parentid"=>parentid } <<<<<<< HEAD ======= i=i+1; # if i>5 # break # end >>>>>>> ff128337f961ce2c8d1c7273ff20bd093e5188a6 end end ### Keep going? while true if result["query-continue"] == nil ##puts "breaking" break end ##puts "didn't break" plcontinue=result["query-continue"][linksterm][continueterm] ## puts plcontinue query[continueterm] = plcontinue postData = Net::HTTP.post_form(URI.parse(apiurl), query); result = JSON.parse(postData.body) pages=result["query"]["pages"].keys result["query"]["pages"].each do |page| if page[1]["title"] != nil and page[1]["length"] != nil links[page[1]["title"]] = { "length" => page[1]["length"], "url"=>page[1]["fullurl"], "pageid"=>page[1]["pageid"], "parentid"=>parentid } end end end return links end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def links; end", "def links; end", "def create_links\n end", "def create_links\n end", "def nlink() end", "def backlink; {color: :blue} end", "def my_links\n end", "def links(type = :local)\n @links = type == :all ? @all_links : @local_links\n end", "def links_feed\n end", "def link() url; end", "def link() url; end", "def links\n\t\t( 0...self.link_count ).collect do |i|\n\t\t\tself.link( i )\n\t\tend\n\tend", "def links\n @links = super || []\n end", "def link_through\n @link.increment_uses!\n redirect_to(@link.url)\n end", "def _AutoLink\n\n _save = self.pos\n while true # choice\n _tmp = apply(:_AutoLinkUrl)\n break if _tmp\n self.pos = _save\n _tmp = apply(:_AutoLinkEmail)\n break if _tmp\n self.pos = _save\n break\n end # end choice\n\n set_failed_rule :_AutoLink unless _tmp\n return _tmp\n end", "def link_self; end", "def follows; [] end", "def links\n @links ||= []\n @links\n end", "def link_value\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 12 )\n hash = nil\n link_target17 = nil\n link_rel18 = nil\n link_self19 = nil\n link_category20 = nil\n link_attributes21 = nil\n # - - - - @init action - - - -\n hash = Hashie::Mash.new \n\n begin\n # at line 73:6: link_target link_rel ( link_self )? ( link_category )? link_attributes ( SEMICOLON )?\n @state.following.push( TOKENS_FOLLOWING_link_target_IN_link_value_520 )\n link_target17 = link_target\n @state.following.pop\n # --> action\n hash[:target] = link_target17 \n # <-- action\n @state.following.push( TOKENS_FOLLOWING_link_rel_IN_link_value_529 )\n link_rel18 = link_rel\n @state.following.pop\n # --> action\n hash[:rel] = link_rel18 \n # <-- action\n # at line 75:6: ( link_self )?\n alt_17 = 2\n alt_17 = @dfa17.predict( @input )\n case alt_17\n when 1\n # at line 75:6: link_self\n @state.following.push( TOKENS_FOLLOWING_link_self_IN_link_value_538 )\n link_self19 = link_self\n @state.following.pop\n\n end\n # --> action\n hash[:self] = link_self19 \n # <-- action\n # at line 76:6: ( link_category )?\n alt_18 = 2\n alt_18 = @dfa18.predict( @input )\n case alt_18\n when 1\n # at line 76:6: link_category\n @state.following.push( TOKENS_FOLLOWING_link_category_IN_link_value_548 )\n link_category20 = link_category\n @state.following.pop\n\n end\n # --> action\n hash[:categories] = link_category20 \n # <-- action\n @state.following.push( TOKENS_FOLLOWING_link_attributes_IN_link_value_558 )\n link_attributes21 = link_attributes\n @state.following.pop\n # --> action\n hash[:attributes] = link_attributes21 \n # <-- action\n # at line 78:6: ( SEMICOLON )?\n alt_19 = 2\n look_19_0 = @input.peek( 1 )\n\n if ( look_19_0 == SEMICOLON )\n alt_19 = 1\n end\n case alt_19\n when 1\n # at line 78:6: SEMICOLON\n match( SEMICOLON, TOKENS_FOLLOWING_SEMICOLON_IN_link_value_567 )\n\n end\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__, 12 )\n\n end\n \n return hash\n end", "def determinate_back_link_url\n if history.nil? || history.size == 1\n default_url\n else\n \"#{url}?page=#{session.dig(:back_link_history, previous_step)}?back=true\"\n end\n end", "def test_add_link\n num_links0 = count_links\n test_link = 'http://news.ycombinator.com/'\n @ds.add_or_get_link(test_link)\n assert_equal(num_links0 + 1, count_links)\n assert_equal(1, count_links(test_link))\n assert_equal('Hacker News', get_link_title(test_link))\n delete_link(test_link)\n end", "def link!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 25 )\n\n type = LINK\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at line 159:8: 'link'\n match( \"link\" )\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__, 25 )\n\n end", "def links\n each_link.to_set\n end", "def link\n '-'\n end", "def AddLink()\n\t\t#Create a new internal link\n\t\tn=@links.length+1;\n\t\t@links[n]=[0,0];\n\t\treturn n;\n\tend", "def link_key!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 7 )\n\n type = LINK_KEY\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at line 133:4: 'Link'\n match( \"Link\" )\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__, 7 )\n\n end", "def clear_backlinks\n @backlinks = []\n end", "def link_value\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 12 )\n hash = nil\n link_target17 = nil\n link_rel18 = nil\n link_self19 = nil\n link_category20 = nil\n link_attributes21 = nil\n # - - - - @init action - - - -\n hash = Hashie::Mash.new\n\n begin\n # at line 100:6: link_target link_rel ( link_self )? ( link_category )? link_attributes ( ';' )?\n @state.following.push(TOKENS_FOLLOWING_link_target_IN_link_value_525)\n link_target17 = link_target\n @state.following.pop\n # --> action\n hash[:target] = link_target17\n # <-- action\n @state.following.push(TOKENS_FOLLOWING_link_rel_IN_link_value_534)\n link_rel18 = link_rel\n @state.following.pop\n # --> action\n hash[:rel] = link_rel18\n # <-- action\n # at line 102:6: ( link_self )?\n alt_19 = 2\n look_19_0 = @input.peek(1)\n\n if (look_19_0 == T__11)\n look_19_1 = @input.peek(2)\n\n if (look_19_1 == WS)\n look_19_3 = @input.peek(3)\n\n if (look_19_3 == T__24)\n alt_19 = 1\n end\n elsif (look_19_1 == T__24)\n alt_19 = 1\n end\n end\n case alt_19\n when 1\n # at line 102:6: link_self\n @state.following.push(TOKENS_FOLLOWING_link_self_IN_link_value_543)\n link_self19 = link_self\n @state.following.pop\n\n end\n # --> action\n hash[:self] = link_self19\n # <-- action\n # at line 103:6: ( link_category )?\n alt_20 = 2\n look_20_0 = @input.peek(1)\n\n if (look_20_0 == T__11)\n look_20_1 = @input.peek(2)\n\n if (look_20_1 == WS)\n look_20_3 = @input.peek(3)\n\n if (look_20_3 == T__25)\n alt_20 = 1\n end\n elsif (look_20_1 == T__25)\n alt_20 = 1\n end\n end\n case alt_20\n when 1\n # at line 103:6: link_category\n @state.following.push(TOKENS_FOLLOWING_link_category_IN_link_value_553)\n link_category20 = link_category\n @state.following.pop\n\n end\n # --> action\n hash[:category] = link_category20\n # <-- action\n @state.following.push(TOKENS_FOLLOWING_link_attributes_IN_link_value_563)\n link_attributes21 = link_attributes\n @state.following.pop\n # --> action\n hash[:attributes] = link_attributes21\n # <-- action\n # at line 105:6: ( ';' )?\n alt_21 = 2\n look_21_0 = @input.peek(1)\n\n if (look_21_0 == T__11)\n alt_21 = 1\n end\n case alt_21\n when 1\n # at line 105:6: ';'\n match(T__11, TOKENS_FOLLOWING_T__11_IN_link_value_572)\n\n end\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__, 12 )\n\n end\n\n return hash\n end", "def randomize\n @links.sample\n end", "def _Link\n\n _save = self.pos\n while true # choice\n _tmp = apply(:_ExplicitLink)\n break if _tmp\n self.pos = _save\n _tmp = apply(:_ReferenceLink)\n break if _tmp\n self.pos = _save\n _tmp = apply(:_AutoLink)\n break if _tmp\n self.pos = _save\n break\n end # end choice\n\n set_failed_rule :_Link unless _tmp\n return _tmp\n end", "def click_through_link\n\t\treturn '/items/' + self.items.first.slug if !self.items.first.blank?\n\t\treturn '/blog/' + self.blogs.first.slug if !self.blogs.first.blank?\n\t\treturn \"#\"\n\tend", "def send_early_hints(links); end", "def convert_links links, dropped_links_count\n TraceProtos::Span::Links.new \\\n link: links.map { |link| convert_link link },\n dropped_links_count: dropped_links_count\n end", "def backlinks(title, filter = \"all\")\n titles = []\n blcontinue = nil\n begin\n form_data =\n {'action' => 'query',\n 'list' => 'backlinks',\n 'bltitle' => title,\n 'blfilterredir' => filter,\n 'bllimit' => @options[:limit] }\n form_data['blcontinue'] = blcontinue if blcontinue\n res, blcontinue = make_api_request(form_data, '//query-continue/backlinks/@blcontinue')\n titles += REXML::XPath.match(res, \"//bl\").map { |x| x.attributes[\"title\"] }\n end while blcontinue\n titles\n end", "def links\n\t\t@links.keys\n\tend", "def test_links\n schema = Heroics::Schema.new(SAMPLE_SCHEMA)\n assert_equal(\n ['list', 'info', 'identify_resource', 'create', 'submit', 'update', 'delete'],\n schema.resource('resource').links.map { |link| link.name })\n end", "def href; end", "def link(index, next_index, prev_index)\n item = @lookup[index]\n item.next_link = @lookup[next_index]\n item.prev_link = @lookup[prev_index]\n end", "def insert_links\n @output << \"\\n\"\n @links.each_index do |index|\n @output << \" [#{index+1}]: #{@links[index]}\\n\"\n end\n end", "def urls\n \n # Go through the 3 urls in the record and retrieve the urls and associated \n # text for the caller\n references = []\n 1.upto(3) do |i|\n \n url = self.send(\"url#{i}\")\n break if url == ''\n \n url_text = self.send(\"url#{i}_name\")\n url_text = 'Reference' if url_text == ''\n references.push({ :text => url_text, :url => url })\n \n end\n \n references\n \n end", "def linked_to\n @linked_to ||= []\n end", "def mark_link game, ref\n\t$links[ref] << game\nend", "def links\n linked_to.map{|to|[self,to]}\n end", "def relationship_links(source)\n {}\n end", "def link *a; app.link *a end", "def link\n @link\n end", "def test_flatten_link\r\n link = @link_list.add_link(@measure, @perfind) \r\n assert_equal( { \"from_id\"=>1, \"to_id\"=>2 },\r\n link.flatten_data)\r\n end", "def links(options={})\n options = {:get_dataset => false, :type => Ecore::Link, :reload => false, :preconditions => {:hidden => false}}.merge(options)\n return @links_chache if @links_chache and !options[:get_dataset] and !options[:reload]\n query = Ecore::db[options[:type].table_name].store_preconditions((@group_ids || @user_id),self.class.get_type_if_has_superclass,self,nil,(options[:preconditions] || {:hidden => false}))\n query = query.where(:orig_document_id => id)\n return query if options[:get_dataset]\n @links_chache = query.order(:name,:created_at).receive(:all)\n end", "def prepare_links!\n links_def = find_links_definition or return\n \n links_def.rel2block.each do |link|\n links.update_link(Feature::Hypermedia::Hyperlink.new.tap do |hyperlink| # create Hyperlink representer.\n hyperlink.rel = link[:rel]\n hyperlink.href = run_link_block(link[:block])\n end)\n end\n end", "def directed?() false; end", "def link_chain_hash_creator(title)\n\tlink_chain = {}\n\tbroken = nil\n\tcurrent_title = title\n\twhile broken != true\n\t\tnext_title = $links[current_title] #|| $links[current_title.downcase]\n\t\t\n\t\t#puts \"Link chain: #{link_chain}\"\n\t\t#puts \"Current title: #{current_title}\"\n\t\t#puts \"Next title: #{next_title}\"\n\t\tunless next_title\n\t\t\tnext_title = $links[current_title.capitalize] if current_title\n\t\tend\n\n\t\tif link_chain.keys.include? next_title\t\t\t\n\t\t\t#alphabet_array = link_chain.alphat\n\t\t\t#link_chain.unshift(\"loop is\")\n\t\t\tbroken = true\n\t\tend\n\t\tlink_chain[current_title] = next_title\n\t\tcurrent_title = next_title\n\tend\n\tlink_chain\nend", "def parse_link_definition; end", "def save\n return false if !valid?\n @id = self.class.next_id\n $redis[attr_key :url] = @url\n $redis[attr_key :description] = @description\n $redis[attr_key :score] = @score\n $redis[attr_key :created_at] = DateTime.now\n $redis.push_head(\"links:list\", @id)\n true\n end", "def create_url (type,permalink,page)\n\t\tbase_url = \"http://api.crunchbase.com/v/2/\"\n\t\tuser_key = \"2f9f86ebf459116f9b1a6e86f24ba34b\" # This's Isabel's key\n\t\tuser_key2 = \"411490520ad9db1b432e77f1a25735a8\" # This's David's Key\n\t\tif permalink == \"\" then\n\t\t\tif @random_key == 1\n\t\t\t\turl = \"#{base_url}#{type}?page=#{page}&user_key=#{user_key}\"\n\t\t\t\t@random_key = 2\n\t\t\telsif @random_key == 2\n\t\t\t\turl = \"#{base_url}#{type}?page=#{page}&user_key=#{user_key2}\"\n\t\t\t\t@random_key = 1\n\t\t\tend\n\t\telse\n\t\t\tif @random_key == 1\n\t\t\t\turl = \"#{base_url}#{type}/#{permalink}?page=#{page}&user_key=#{user_key}\"\n\t\t\t\t@random_key = 2\n\t\t\telsif @random_key == 2\n\t\t\t\turl = \"#{base_url}#{type}/#{permalink}?page=#{page}&user_key=#{user_key2}\"\n\t\t\t\t@random_key = 1\n\t\t\tend\n\t\tend \n\t\treturn url \n\tend", "def test_add_pvt_link\n num_links0 = count_links\n test_link = 'http://www.avilayparekh.com/'\n @ds.add_or_get_link(test_link)\n assert_equal(num_links0 + 1, count_links)\n assert_equal(1, count_links(test_link))\n assert_empty(get_link_title(test_link))\n delete_link(test_link)\n end", "def link\n throw 'STUB'\n end", "def references; end", "def references; end", "def follow_symlinks=(_arg0); end", "def gather_links indexes\n sort_index = 0\n indexes.each do |index|\n link = Link.find(index)\n link.trail_id = self.id\n link.sort_index = sort_index\n link.save\n sort_index = sort_index + 1\n end\n end", "def test_chain\n #puts \"---------------test_chain-----------------\"\n\n t1 = t2 = t3 = t4 = nil\n GraphBuilder::Builder.build do |b|\n t1 = b.add(Thing1.new)\n b.chain do\n t2 = b.add(Thing2.new)\n t3 = b.add(Thing3.new)\n end\n t4 = b.add(Thing4.new)\n end\n\n r = Thing.links([t1,t2,t3,t4])\n assert_equal 3, r.size\n assert r.include? [t1,t2]\n assert r.include? [t2,t3]\n assert r.include? [t3,t4]\n end", "def bok_links\n [\n { :url => 'http://www.noagendashow.com/', :name => 'NoAgendaShow.com'},\n { :url => 'http://noagendachat.net/', :name => 'NoAgenda Chat'},\n { :url => 'http://www.noagendasoundboard.com/', :name => 'NoAgenda Soundboard'},\n { :url => 'http://noagendastream.com/', :name => 'NoAgenda Stream'},\n { :url => 'http://en.wikipedia.org/wiki/No_Agenda', :name => 'wikipedia'}\n ]\n end", "def traverse_links(seed_url, max_pages, output_dir, algo, spam_path, nonspam_path)\n spamCalc = SpamCalculator.new(spam_path, nonspam_path)\n #contains [link, spamScore] arrays for the sake of bestfirst\n links_to_visit = []\n links_to_visit.push([seed_url, 0])\n pages_visited = 0\n time_of_last_get = Time.now.to_f\n while (links_to_visit.length != 0 && pages_visited < max_pages)\n time_difference = Time.now.to_f - time_of_last_get\n if time_difference < 1\n sleep(1-time_difference)\n end\n time_of_last_get = Time.now.to_i\n link = links_to_visit.pop[0]\n puts \"link: \" + link\n if $index[link]\n next\n end\n process_results = process_link(link, output_dir, spamCalc, pages_visited)\n if !process_results\n puts \"error retrieving page at \" + link\n next\n end\n currentPage = process_results[0]\n currentScore = process_results[1]\n pages_visited += 1\n puts \"size: \" + $index.size.to_s\n links = find_links(process_results[0])\n for link in links\n if !link.is_a?(\"\".class)\n abort \"Non-string in link queue\"\n end\n if $index.has_key?(link) || links_to_visit.include?(link)\n next\n end\n if (algo == 'dfs' || algo == 'bestfirst')\n links_to_visit.push([link, currentScore])\n elsif (algo == 'bfs')\n links_to_visit.unshift([link, currentScore])\n else\n abort \"Not a valid algorithm name\"\n end\n end\n if (algo == 'bestfirst')\n links_to_visit.sort_by!{|item| -item[1]}\n end\n end\n path_to_index_file = File.join(output_dir + '../index.dat').to_s\n puts path_to_index_file\n output = File.new(path_to_index_file, \"w+\")\n for key in $index.keys\n scoreAndFilename = $index[key]\n output_line = scoreAndFilename[1] + \"\\t\" + scoreAndFilename[0].to_s + \"\\t\" + key + \"\\n\"\n output.write(output_line)\n end\n output.close\nend", "def index\n @global_links = GlobalLink.all\n @tier_two_links = TierTwoLink.all\n end", "def links=(value)\n @links = value\n end", "def links=(value)\n @links = value\n end", "def links=(value)\n @links = value\n end", "def gen_links (res, item, &block)\n\n if block # unique element\n\n [ link('via', res), link('self', res, block.call(item)) ]\n\n elsif item.respond_to?(:current_page) and item.total_pages > 1\n\n a = [\n link('via', ''),\n link('self', res, 'page' => item.current_page)\n ]\n a << link('prev', res, 'page' => item.current_page - 1) \\\n if item.current_page > 1\n a << link('next', res, 'page' => item.current_page + 1) \\\n if item.current_page < item.total_pages\n a\n\n else # collection\n\n [ link('via', ''), link('self', res) ]\n end\n end", "def copy_backlinks(new_record, t)\n backlinks.each do |l|\n new_back_record = l.record.add_delta(t, l.index, new_record)\n parent_rebalanced = new_back_record != l.record\n\n unless parent_rebalanced\n new_record.add_backlink(\n new_back_record,\n l.index\n )\n end\n end\n end", "def redirection_history; end", "def link!\n self.linkbutton = true\n self.save\n self.linkbutton\n end", "def link( index )\n\t\tLink.new( \n\t\t\tself.words[ self.link_lword(index) ],\n\t\t\tself.words[ self.link_rword(index) ],\n\t\t\tself.link_length(index),\n\t\t\tself.link_label(index),\n\t\t\tself.link_llabel(index),\n\t\t\tself.link_rlabel(index),\n\t\t\tLinkTypes[ self.link_label(index).gsub(/[^A-Z]+/, '').to_sym ]\n\t\t)\n\tend", "def is_linktype?(); @type == GRT_LINKTYPE; end", "def links\n @negative_balance_limit_links ||= Links.new(@links)\n end", "def link_twitter\n\n end", "def add_link(links)\n links = [links] if links.is_a?(String)\n self.class.get(\"/action/add/links/grabber0/start1/\"+links.join(\" \"))\n end", "def test_get_link\n num_links0 = count_links\n @ds.add_or_get_link('http://www.ml-class.com/') \n assert_equal(num_links0, count_links)\n end", "def link(state1, state2)\n\tstate1.transitions = [Transition.new( Hash.new, Array.new, state2 )]\nend", "def read_links(ltype, id)\n return {} if !v[ltype]\n return {} if !v[ltype][id]\n v[ltype][id]\n end", "def links\n @links ||= lambda do \n raw_links.map do |link|\n hash = {}\n link.keys.each do |key|\n hash[key] = link[key]\n end\n hash\n end\n end.call\n end", "def activate_links(fields, types)\n fields.each do |field|\n field[:type] = activate_field_links(field[:type], types, auto_link: true) if field[:type]\n field[:note] = activate_field_links(field[:note], types) if field[:note]\n field[:description] = activate_field_links(field[:description], types) if field[:description]\n end\n end", "def initialize_deep_link_for(id, start_states, opts)\n #add_deep_link if opts[:is_url_listener] ### DISCUSS: remove #add_de\n end", "def test_empty_chain\n #puts \"---------------test_chain-----------------\"\n\n t1 = t2 = t3 = t4 = nil\n GraphBuilder::Builder.build do |b|\n t1 = b.add(Thing1.new)\n b.chain do\n end\n t4 = b.add(Thing4.new)\n end\n\n r = Thing.links([t1,t4])\n assert_equal 1, r.size\n assert r.include? [t1,t4]\n end", "def associate_social_links(type)\n type_name = type.to_s.capitalize\n lt = LinkType.find_by_name(type_name)\n \n args = [type]\n type_links = @item.links.where(:link_type_id => lt.id)\n if type_links.count > 0\n # do not search for results that have already been added to the item's links\n args << ' AND -link:' + type_links.collect { |l| l.link_url }.join(' -link:')\n end\n city_links = @item.links\n current_size = city_links.size\n extract_social_links(*args).each do |link|\n if !@item.links.map(&:link_url).include?(link)\n @item.links << Link.create(:link_type_id => lt.id, :link_url => link, :name => type_name)\n end\n end\n if current_size < @item.links.size\n WhiskBatter.new(@item).delay.associate_social_links(type)\n end\n end", "def links\n data['links']\n end", "def is_linkkeys?(); @type == GRT_LINKKEYS; end", "def _ReferenceLink\n\n _save = self.pos\n while true # choice\n _tmp = apply(:_ReferenceLinkDouble)\n break if _tmp\n self.pos = _save\n _tmp = apply(:_ReferenceLinkSingle)\n break if _tmp\n self.pos = _save\n break\n end # end choice\n\n set_failed_rule :_ReferenceLink unless _tmp\n return _tmp\n end", "def generate_short_url\n random_chars = ['0'..'9','A'..'Z','a'..'z'].map{|range| range.to_a}.flatten\n self.assign_attributes(short_url: 6.times.map{ random_chars.sample }.join.prepend(\"http://\")) until self.short_url.present? && Link.find_by_short_url(short_url).nil?\n end", "def fwd\n\n url_id = params[:id]\n \n if !url_id.nil? && !url_id.empty?\n link_id = Base32::Crockford.decode(url_id)\n else\n # It will be catched by the next block now\n link_id = -1\n end\n \n begin\n link = Link.find(link_id)\n redirect_to_full_url(link.url, 301)\n rescue ActiveRecord::RecordNotFound\n redirect_to :controller => \"links\", :action => \"new\"\n end\n\n end", "def ruby_hard_way_urls\n urls = ['http://ruby.learncodethehardway.org/book/intro.html']\n (1..52).each do |val|\n urls << 'http://ruby.learncodethehardway.org/book/ex' + val.to_s.rjust(2,'0') + '.html'\n end\n urls << 'http://ruby.learncodethehardway.org/book/next.html'\n urls << 'http://ruby.learncodethehardway.org/book/advice.html'\n urls\nend", "def processLinks\n if params[:plant][:links_attributes]\n for i in 0..2\n @curLink = @plant.links[i]\n\n if !params[:plant][:links_attributes][i.to_s][:name].empty?\n @curLink.name = params[:plant][:links_attributes][i.to_s][:name]\n end\n if !params[:plant][:links_attributes][i.to_s][:link].empty?\n @curLink.link = params[:plant][:links_attributes][i.to_s][:link]\n end\n end\n end\n end", "def links\n typed_set(entities, Occi::Core::Link)\n end", "def parse_link; end", "def follow_symlinks; end", "def history_link_class record\n case record.change\n when 'add'; 'addlink'\n when 'delete'; 'deletelink'\n else 'changelink'\n end\n end", "def test_unflatten_link\r\n link = @link_list.add_link(@perfind, @proc) \r\n \r\n data = link.flatten_data\r\n \r\n @link_list.remove_link(link)\r\n \r\n livelink = @link_list.link_from_data(data)\r\n \r\n assert_equal(link.from, livelink.from) \r\n assert_equal(link.to, livelink.to) \r\n end", "def randomized_retailer_links\n @randomized_retailer_links ||= (active_retailer_links - preferred_retailer_links).sort_by{rand}\n end", "def test_add_edge_aliases\n Automaton.new(false) do |fa|\n s0 = fa.add_state(:initial => true)\n s1 = fa.create_state\n assert_not_nil fa.add_edge(s0,s1, 'a')\n assert_not_nil fa.create_edge(s0,s1,'b')\n assert_not_nil fa.connect(s0,s1,'c')\n end\n end", "def matching_links(type)\n link_pattern = config.public_send(\"link_#{type}_pattern\")\n return [] unless link_pattern\n\n metadata\n .select { |key| __send__(\"#{type}?\", key) }\n .map { |key, value| Allure::ResultUtils.public_send(\"#{type}_link\", key.to_s, value, link_pattern) }\n end", "def links(arg = nil)\n set_or_return(:links, arg, kind_of: Array)\n end", "def links\n json_hyperschema[\"links\"] || []\n end" ]
[ "0.67355895", "0.67355895", "0.6376958", "0.6376958", "0.62172997", "0.6088417", "0.5949736", "0.59450626", "0.5930141", "0.5739786", "0.5739786", "0.5707434", "0.5652366", "0.5619717", "0.55998516", "0.55829835", "0.55727756", "0.55674267", "0.55657953", "0.5540981", "0.5528703", "0.55124635", "0.55099446", "0.55071276", "0.54936934", "0.54818344", "0.5475169", "0.5463727", "0.54560727", "0.5453042", "0.5448871", "0.5434129", "0.5420359", "0.54050004", "0.53807837", "0.53645945", "0.5349787", "0.5346397", "0.5343181", "0.53333676", "0.53289884", "0.53252655", "0.5319412", "0.5311434", "0.5298893", "0.52896476", "0.5287852", "0.527901", "0.5273904", "0.5266129", "0.5240012", "0.52377224", "0.52374274", "0.5236825", "0.52275205", "0.5225779", "0.52120733", "0.52120733", "0.52115065", "0.5210788", "0.52040815", "0.5200231", "0.5196662", "0.5196655", "0.51932824", "0.51932824", "0.51932824", "0.5187837", "0.5184901", "0.5183565", "0.5181288", "0.5180692", "0.51633734", "0.51623565", "0.5161064", "0.5158929", "0.5155072", "0.51539755", "0.5149241", "0.5149201", "0.5149147", "0.5146066", "0.5144681", "0.51443696", "0.51391333", "0.5137893", "0.5136807", "0.5134933", "0.51334125", "0.51303357", "0.51281565", "0.51256174", "0.5125438", "0.5124363", "0.512399", "0.51236546", "0.51215893", "0.51215297", "0.51169956", "0.5114994", "0.5112173" ]
0.0
-1
require all array elements be unique
def unique? @unique end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def uniq(array)\nend", "def using_uniq(array)\n\n \nend", "def array_uniq!(a)\n a.uniq!\n end", "def no_mutter(arr)\n arr.uniq\nend", "def array_uniq!(a)\n a.uniq!\n end", "def using_uniq(array)\n array.uniq\n end", "def uniq(array)\n unique_values = []\n array.each do |el|\n unless unique_values.include?(el)\n unique_values << el\n end\n end\n unique_values\n end", "def using_uniq(array)\n \n array.uniq\n \nend", "def uniqify(array)\n encountered = Hash.new { |hash, key| hash[key] = false }\n uniqified_array = []\n array.each do |element|\n uniqified_array.push(element) unless encountered[element]\n encountered[element] = true\n end\n uniqified_array\nend", "def array_unique(array = [])\n raise 'incorrect array' unless array.is_a? Array\n\n uniq_values = []\n array.each do |el|\n unique_counter = 0\n array.each do |e|\n next if el != e\n\n unique_counter += 1\n end\n uniq_values << el if unique_counter == 1\n end\n uniq_values\nend", "def just_once(original_array)\n unique = []\n i = 0\n while i < original_array.length\n unique.push(original_array[i]) unless unique.include?(original_array[i])\n i += 1\n end\n return unique\n end", "def my_uniq(arr)\n uniques = []\n arr.each do |el|\n uniques << el unless uniques.include?(el)\n end\n uniques\nend", "def no_mutate(arr)\n arr.uniq!\nend", "def no_mutate(arr)\n arr.uniq!\nend", "def using_uniq(array)\n array.uniq()\nend", "def my_unique(arr)\n res = []\n arr.each do |item|\n res << item unless res.include?(item)\n end\n \n res\nend", "def set(arr)\n\treturn arr.uniq\nend", "def yes_mutate(arr)\n arr.uniq!\nend", "def yes_mutate(arr)\n arr.uniq!\nend", "def yes_mutate(arr)\n arr.uniq!\nend", "def ruby_unique(original_array)\n array.uniq\nend", "def no_mutate(arr)\n arr.uniq\nend", "def no_mutate(arr)\n arr.uniq\nend", "def no_mutate(arr)\n arr.uniq\nend", "def mutate(arr)\n arr.uniq!\nend", "def duplicate(array)\n array.uniq!\nend", "def custom_uniq(array)\n final = []\n array.each do |element|\n final << element if !final.include?(element)\n end \n final\nend", "def uniq!() end", "def using_uniq (array)\n return array.uniq!\nend", "def using_uniq(array)\n array.uniq\nend", "def using_uniq(array)\n array.uniq\nend", "def uniques(array)\n hash = Hash[array.map {|x| [x, nil]}]\n print hash.keys\nend", "def uniq(array)\n finalArray = []\n array.each do |element|\n if !finalArray.include?(element)\n finalArray.push(element)\n end\n end\n return finalArray\nend", "def remove_duplicates(array)\nend", "def my_uniq\n unique = []\n each_index { |i| unique << self[i] unless unique.include?(self[i]) }\n unique\n end", "def using_uniq(array)\n array.uniq\nend", "def using_uniq(array)\n array.uniq\nend", "def using_uniq(array)\n array.uniq\nend", "def using_uniq(array)\n array.uniq\nend", "def using_uniq(array)\n array.uniq\nend", "def using_uniq(array)\n array.uniq\nend", "def my_uniq(arr)\nend", "def unique_elements(arr)\n hash = {}\n arr.each { |ele| hash[ele] = true }\n return hash.keys\nend", "def unique_elements(arr)\n unique = {}\n\n arr.each { |ele| unique[ele] = true }\n\n return unique.keys\nend", "def uniq!\n im = Rubinius::IdentityMap.from self\n return if im.size == size\n\n Rubinius.check_frozen\n\n array = im.to_array\n @tuple = array.tuple\n @start = array.start\n @total = array.total\n\n self\n end", "def unique(array)\n unique_array = []\n\n array.each do |original_element|\n found = false\n\n unique_array.each do |unique_element|\n if original_element == unique_element\n found = true\n break\n end\n end\n\n if !found\n unique_array << original_element\n end\n end\n\n unique_array\nend", "def uniq() end", "def using_uniq(arr)\n arr.uniq\nend", "def using_uniq(arr)\n arr.uniq\nend", "def my_uniq(arr)\n unique_set = arr.reduce({}) do |acc, el|\n acc[el] = true\n acc\n end\n unique_set.keys\nend", "def uniq(array)\n counts = Hash.new(0)\n result = []\n array.each do |element|\n counts[element] += 1\n result << element unless counts[element] > 1\n end\n result\nend", "def unique_elements(arr)\n\thash = {}\n arr.each { |ele| hash[ele] = true }\n return hash.keys \t\nend", "def uniques(array)\n test_array=[]\n array.each do |i|\n if test_array.include?(i)==false\n test_array.push(i)\n else \n end\n end\n return test_array\nend", "def my_unique\n dict = Hash.new(false)\n self.each_with_index do |el, idx|\n self[idx] = nil if dict[el]\n dict[el] = true\n end\n self.compact!\n end", "def my_uniq(arr)\n \n output = []\n hash = Hash.new(false)\n \n arr.each do |x|\n output << x if !hash[x]\n hash[x] = true\n end\n output\n end", "def my_method(arr)\n arr.uniq!\nend", "def my_uniq(arr)\n hash = {}\n arr.each {|elem| hash[elem] = true}\n hash.keys\nend", "def unique_elements(array)\n hash = Hash.new(0)\n array.each { |ele| hash[ele] += 1 }\n\n hash.keys\nend", "def test_removes_duplicates\n stream = FromArray.new([2, 2, 3, 4, 1, 1, 2, 5, 4, 3, 6])\n collected = stream.distinct.collect\n assert(collected == collected.uniq)\n assert(collected.length == collected.uniq.length)\n end", "def find_unique_elements(arr)\n# Count how many times each element appears in the array, if an element appears\n# more than once, delete that element and any elements that are equal to it.\n \n arr.each do |i|\n\tif arr.count(i) > 1\n\t\tarr.delete(i)\n\tend\n end\n return arr\nend", "def unique(arr)\n uniq = Hash.new(0)\n arr.each { |x| uniq[x] += 1 }\n uniq.select { |k, v| v == 1 }.keys\nend", "def my_uniq\n unique = []\n self.each do |ele|\n unique << ele if !unique.include?(ele)\n end\n unique\n end", "def unique_elements(arr)\n hash = Hash.new(0)\n arr.each { |ele| hash[ele] += 1}\n hash.keys\nend", "def find_unique_elements(arr)\n \nend", "def unique_elements(arr)\n hash_elements = {}\n arr.each { |ele| hash_elements[ele] = true }\n return hash_elements.keys\nend", "def test_distinct_no_duplicates\n stream = FromArray.new([1, 2, 3, 4, 5])\n collected = stream.distinct.collect\n assert(collected == collected.uniq)\n assert(collected.length == collected.uniq.length)\n end", "def unique_items(ary)\r\n ary.select {|x| ary.count(x) == 1}\r\nend", "def dup_args_alt(arr)\n arr == arr.uniq ? false : true\nend", "def unique_elements(arr)\n hash = Hash.new(0)\n arr.each {|el| hash[el] += 1}\n return hash.keys\n\nend", "def my_uniq(array)\n result = []\n array.each { |ele| result << ele unless result.include?(ele) }\n result\nend", "def unique(integers)\n integers.to_set.to_a\nend", "def my_uniq(arr)\n hash = Hash.new(0)\n arr.each {|el| hash[el] = 1} #value doesnt matter this case\n hash.keys\nend", "def find_unique_elements(arr)\n arr.reject { |e| arr.count(e) > 1 }\nend", "def test_distinct_one_duplicate_element\n stream = FromArray.new([1, 1])\n collected = stream.distinct.collect\n assert(collected.length == 1)\n assert(collected == collected.uniq)\n end", "def remove_dups(arr)\n\treturn arr.uniq()\nend", "def unique_push!(*elements)\n elements.each do |element|\n self << element unless self.include?(element)\n end\n self\n end", "def only_unique_elements(arr)\n newHash = Hash.new(0)\n\n arr.each{|x|newHash[x]=1}\n \n newHash.to_a.flatten().select{|x|x.is_a?(String)==true}\nend", "def duplicate_elements?(arr)\n arr.uniq.length != arr.length\nend", "def my_uniq(arr)\n hash = {}\n arr.each { |obj| hash[obj] = true }\n hash.keys\nend", "def update_arr2(var)\n\tvar.uniq!\nend", "def my_uniq(arr)\n hsh = Hash.new(0)\n arr.each do |el|\n hsh[el] += 1\n end\n hsh.keys\nend", "def remove_duplicates(array)\n array.uniq!.length\nend", "def my_uniq(arr)\n answer = Hash.new\n arr.each_with_index do |el, i|\n answer[el] = 1\n end\n answer.keys\nend", "def uniq\n end", "def uniq\n end", "def has_no_duplicates?(arr)\n !(arr.uniq.size < arr.size)\n end", "def unique_elements(arr)\n my_hash = Hash.new(0)\n arr.each do |element|\n my_hash[element] += 1\n end\n return my_hash.keys\nend", "def some_method(array)\n array.uniq\nend", "def remove_duplicates(array)\n uniq_array = []\n array.each {|value| uniq_array << value unless uniq_array.include?(value) }\n return uniq_array\nend", "def uniq\n dup.uniq! or dup\n end", "def unique\n lambda do |rec, acc|\n acc.uniq!\n end\n end", "def unique_elements(arr)\n\n # hash count -> duplicate removed -> return a new array\n new = []\n\n # count = Hash.new(0) # create {} with default value 0\n arr.each do |ele|\n if !new.include?(ele)\n new << ele\n end\n end\n # print count # {\"a\"=>3, \"b\"=>2, \"c\"=>1}\n\n return new \nend", "def my_method(arr)\n arr.uniq\nend", "def my_method(arr)\n arr.uniq\nend", "def unique(integers)\n\n\t@arrayb4 = integers.to_a\n\t@arrayafter = []\n\n\t@arrayb4.map { |x|\n\t\tif @arrayafter.include?(x) == false\n\t\t\t@arrayafter << x\n\t\tend\n\t}\n\n\treturn @arrayafter\n\nend", "def nondupes(array)\n new_array = []\n array.each do |elem| \n if array.count(elem) == 1\n new_array << elem \n end\n end\n new_array\nend", "def uniq(arr)\n new_array = []\n arr = arr.sort\n arr.each_with_index do |num, idx|\n new_array << num if num != arr[idx + 1]\n end\n new_array\nend", "def uniq(array)\n\t\n\tcount = Hash.new 0\n\n array.each do |num|\n count[num] += 1\n end\n \n uniqueness = count.select { |k,v| v == 1 }\n uniqueness.select { |k,v| puts k }\n \nend", "def nondupes(array)\n array.map do |elem| \n array.count(elem) == 1\n \n end\n \nend", "def unique_arr?(arr)\n not_unique = false\n i = 0\n while (i < arr.length && !not_unique)\n j = i + 1\n while (j < arr.length && !not_unique)\n not_unique = true if arr[i] == arr[j] && arr[i] != '' && arr[i] != 0\n j += 1\n end\n i += 1\n end \n return !not_unique\n end", "def unique(integers)\narray = []\nintegers.map {|item| array << item unless array.include?(item)}\narray\nend" ]
[ "0.7609767", "0.7487446", "0.74629664", "0.73676455", "0.73541284", "0.727612", "0.7250225", "0.723578", "0.7235528", "0.72244024", "0.7220144", "0.7186752", "0.7184513", "0.7184513", "0.71772903", "0.71734923", "0.7160817", "0.71586806", "0.71586806", "0.71586806", "0.7152457", "0.7109989", "0.7109989", "0.7109989", "0.7104696", "0.7101697", "0.70950633", "0.70567447", "0.70374584", "0.7035595", "0.7035595", "0.70272696", "0.70248914", "0.70244217", "0.7010958", "0.7005781", "0.7005781", "0.7005781", "0.7005781", "0.7005781", "0.7005781", "0.7000177", "0.6980824", "0.6969662", "0.69664246", "0.6966359", "0.6947051", "0.6944452", "0.6944452", "0.6936791", "0.6923286", "0.6913439", "0.68725777", "0.6863029", "0.68415624", "0.68350756", "0.6821291", "0.6803617", "0.6799035", "0.67977417", "0.6797541", "0.67946124", "0.6791807", "0.679022", "0.6782346", "0.6779274", "0.67779636", "0.672188", "0.67202014", "0.6717936", "0.67169714", "0.67128736", "0.6701145", "0.6696026", "0.6681957", "0.66579485", "0.6637669", "0.6621839", "0.66187924", "0.66054916", "0.6592935", "0.6584753", "0.65715164", "0.6556801", "0.6556801", "0.6554066", "0.6549994", "0.651652", "0.65111935", "0.6492047", "0.6486884", "0.6455333", "0.64479595", "0.64479595", "0.64397216", "0.6436251", "0.6432229", "0.6419623", "0.64011204", "0.6400686", "0.63832504" ]
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def post_params params.fetch(:post, {}).permit( :title, :firstContent, :secondContent, :thirdContent, :forthContent, :fifthContent, :rname, :is_display, :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
Steps I need an empty variable to hold the final reversed string I need a variable to hold my iterations I need to concatinate to the front of the final string I need to check if the original string and the new string are equal My Attempt
def is_palindrome(word) reversed = "" i = 0 while i < word.length char = word[i] reversed = char + reversed i += 1 end if word == reversed return true else return false end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def solution(str)\n str.reverse\nend", "def string_rotation(str1, str2)\n arr1 = str1.split('')\n str1.length.times do |i|\n return true if arr1.unshift(arr1.pop).join == str2\n end\n return false\nend", "def solution(str)\n str.reverse\nend", "def is_palindrome(string)\n joined_str = string.gsub(/[^0-9a-z]/i, '').downcase\n reverse_str = reverser(joined_str.clone)\n difference_count = 0\n joined_str.length.times do |i|\n difference_count += 1 if joined_str[i] != reverse_str[i]\n end\n\n if difference_count != 0\n return false\n else\n return true\n end\n\nend", "def is_palindrome(word) # define method with one parameter\n i = 0 # set i to zero for first index value is 0\n reversed_string = \"\" # create empty string to store concatenated string\n \n while i < word.length # run while loop as long as word length is greater than i value which increments by one\n char = word[i] # this stores each iteration of string characters\n reversed_string = char + reversed_string # this concatenates string characters in reverse order\n i +=1 # raises increment by one \n end # end loop\n return reversed_string == word # if statement that evaluates whether new string equals original\nend", "def og_palindrome?(str)\n new_str = ''\n index = str.length - 1\n\n until index < 0\n new_str += str[index]\n index -= 1\n end\n\n str == new_str\nend", "def check_palindrome(s)\n\n if s == nil\n return false\n end\n\n result = \"\"\n\n (s.length-1).downto(0).each do |l|\n result << s[l]\n end\n p result\n\n return result == s\n\nend", "def palindrome_permutation(string)\n # new_string = string.gsub(/\\s+/, \"\")\n # p new_string.length\n # permutation = new_string.chars\n # p \n\n\n # if new_string.length % 2 != 0\n # puts \"True. permutation\"\n # end\n\n # pal_split = string.split\n\n # pal0_split = pal_split[0].chars\n # removed_last_letter = pal0_split.pop\n # word_one = pal0_split.join\n # if word_one == pal_split[1].reverse\n # puts \"True permutations \"\n # else\n # puts \"no\"\n # end\n\n new_string = string.gsub(/\\s+/, \"\")\n reversed_word = new_string.reverse\n if new_string == reversed_word\n puts \"true.\"\n else \n puts \"false\"\n end \nend", "def palindrome?(string)\n new_string = \"\"\n i = 1\n string.length.times do\n new_string << string[-i]\n i += 1\n end\n string == new_string\nend", "def palindrome?(string)\n newRevString = \"\"\n idx = string.length-1\n while idx >= 0\n newRevString = newRevString + string[idx]\n idx = idx - 1\n end\n return newRevString==string\nend", "def string_reverse(my_string)\r\n i_start = 0\r\n i_end = -1\r\n a = \"\"\r\n z = \"\"\r\n t = \"\"\r\n loop_times = my_string.length\r\n new_string = \"\"\r\n\r\n until loop_times == 0\r\n a = my_string[i_start]\r\n z = my_string[i_end]\r\n\r\n t = a\r\n a = z\r\n z = t\r\n\r\n new_string += a\r\n\r\n # puts \"a is at index #{i_start}, letter #{a}\"\r\n # puts \"z is at index #{i_end}, letter #{z}\"\r\n # puts \"t is currently #{t}\"\r\n\r\n my_string[i_start] = z\r\n my_string[i_end] = a\r\n\r\n i_start += 1\r\n i_end -= 1\r\n loop_times -= 1\r\n\r\n # puts \"i_start is #{i_start} and i_end is #{i_end}\"\r\n end\r\n\r\n puts \"my string: \" + my_string\r\n puts \"new string: \" + new_string\r\n # binding.pry\r\n my_string = new_string\r\n puts \"my string reassigned: \" + my_string\r\n # return new_string\r\n return my_string\r\nend", "def string_reverse(orig_string)\n puts \"#{orig_string}\"\n start = 0\n ending = orig_string.length - 1\n\n # while conditions ok\n while start < ending\n puts \"start: #{start}\"\n puts \"ending #{ending}\"\n\n #swap letters in place\n orig_string[start], orig_string[ending] = orig_string[ending], orig_string[start]\n\n #iterate\n start += 1\n ending -= 1\n end\n\n # return string\n puts \"#{orig_string}\"\n return orig_string\nend", "def string_reverse(my_string)\r\n return nil if my_string.nil?\r\n n = my_string.length\r\n i = 0\r\n j = n-i-1\r\n\r\n while i < j do\r\n memo = my_string[i]\r\n my_string[i] = my_string[j]\r\n my_string[j] = memo\r\n i = i+1\r\n j = j-1\r\n end\r\nend", "def is_palindrome(word)\nforwards = \"\"\nbackwards = \"\"\n \n i = 0\n while i < word.length\n char = word[i]\n forwards = forwards + char\n backwards = char + backwards\n\n i += 1\n end\n \n if forwards == backwards\n return \"true\"\n else\n return \"false\"\n end\nend", "def palindrome?(str)\n new_arry = []\n index = 1\n while index <= str.size\n new_arry << str[-index]\n index += 1\n end\n new_arry.join == str\nend", "def palindrome?(str)\n new_arry = []\n index = 1\n while index <= str.size\n new_arry << str[-index]\n index += 1\n end\n new_arry.join == str\nend", "def switch(string)\n forward = string.split('')\n reverse = []\n counter = -1\n until reverse.length == forward.length\n reverse << forward[counter]\n counter -= 1\n end\n reverse.join\nend", "def Palindrome(str)\n str = str.gsub(\" \", \"\")\n front = 0\n back = str.length - 1\n \n while front < back\n if str[front] != str[back]\n return \"false\"\n end\n front += 1\n back -= 1\n end\n \n return \"true\"\nend", "def string_reverse(my_string)\r\n return if my_string == nil || my_string.length < 1\r\n i = 0 #first ele\r\n j = my_string.length - 1 #last ele\r\n while i < j # until position of first ele meets last, so there is the center element in between\r\n temp = my_string[i] #stores frist ele in temp\r\n my_string[i] = my_string[j] #sets first ele to the last ele's position\r\n my_string[j] = temp #sets last element to first ele's position\r\n i += 1 #increment\r\n j -= 1\r\n end\r\n return my_string\r\nend", "def palindrome(string)\n puts \"is #{string} a palindrome?\" \n (string.length/2).times do |i|\n puts i\n puts \"checking if #{string[i]} is equal to #{string[string.length - 1 - i]}\"\n if string[i] != string[string.length - 1 - i]\n return false\n end\n end\n return true\nend", "def reverse(str)\n puts \"Your string: #{str}\"\n length = str.length\n current_char_index = 0\n mirror_char_index = str.length - 1\n\n until (current_char_index == mirror_char_index) || (mirror_char_index - current_char_index == 1)\n # set current and mirror chars\n current_char = str[current_char_index]\n mirror_char = str[mirror_char_index]\n\n # switch\n str[current_char_index] = mirror_char\n str[mirror_char_index] = current_char\n\n # increment and set next indices\n current_char_index += 1\n mirror_char_index = length - (current_char_index + 1)\n end\n\n puts \"Reversed string: #{str}\"\n str\nend", "def palindrome_substrings(string)\n\nend", "def rev(str, i)\n # str = \"75\", i = -1\n if i < 0 then\n return \"\";\n else\n # return \"5\" + \"7\" + \"\"\n return str[i, 1] + rev(str, i-1);\n end;\nend", "def palindrome_permutation str\n str_1 = str.downcase.chars.sort.join\n str_2 = str.downcase.chars.sort.join.reverse\n length = str.length\n for i in 0..length/2\n return false if str_1[i] != str_2[length-i-1]\n end\n return true\nend", "def string_reverse(my_string)\n if my_string == \"\"\n return my_string\n elsif my_string.nil?\n return nil\n else\n\n length = my_string.length\n count = length / 2\n count.times do |i|\n temp = my_string[i]\n my_string[i] = my_string[length - i - 1]\n my_string[length - i - 1] = temp\n end\n end\n return my_string\nend", "def string_reverse(my_string)\r\n if my_string == nil \r\n return nil\r\n elsif my_string != \"\"\r\n k = my_string.length / 2\r\n i = 0\r\n j = -1\r\n temp = \"\"\r\n k.times do\r\n temp = my_string[i]\r\n my_string[i] = my_string[j]\r\n my_string[j] = temp\r\n i += 1\r\n j -= 1\r\n end\r\n end\r\n return my_string \r\nend", "def shortest_palindrome_2(s)\n idx = 0\n front = \"\"\n back = \"\"\n (0...s.size).each { |i|\n front = front + s[i]\n back = s[i] + back\n idx = [idx, i].max if front == back\n }\n\n (s[idx + 1..-1] || \"\").reverse + s\nend", "def funny_string string\n my_string = string.chars\n rev_string = string.reverse.chars\n\n count = 0\n\n my_string.each_with_index do |x, xi|\n\n if xi > 0\n my_funny = (x.ord - (my_string[xi-1].ord)).abs\n rev_funny = (my_string[-(xi+1)].ord - my_string[-xi].ord).abs\n\n if my_funny == rev_funny\n count +=1\n else\n break\n end\n\n end\n\n end\n\n if count == (my_string.size) -1\n return true\n else\n false\n end\n\nend", "def shortest_palindrome(str)\n # find longest palindromic prefix\n n = str.size\n rev = str.reverse\n\n (0...n).each do |i|\n return rev[0...i] + str if str[0...(n - i)] == rev[i...n]\n end\n\n ''\nend", "def one_away(str1, str2)\n if str1 == str2\n return true\n elsif (str1.length - str2.length).abs > 1\n return false\n end\n\n num_edits =\n index_1 = 0\n index_2 = 0\n\n while index_1 < str1.length\n if str1[index_1] != str2[index_2]\n num_edits += 1\n index_2 += 1 if str1.length == str2.length\n else\n index_2 += 1\n end\n index_1 += 1\n\n \n p num_edits\n return false if num_edits > 1\n end\n\n true\nend", "def string_reverse(my_string)\r\n if my_string == nil\r\n return nil\r\n elsif my_string.length == 1\r\n return my_string\r\n else\r\n origin = my_string.length - 1\r\n target = 0\r\n temp = nil\r\n (my_string.length / 2).times do\r\n temp = my_string[target]\r\n my_string[target] = my_string[origin]\r\n my_string[origin] = temp\r\n origin -= 1\r\n target += 1\r\n end\r\n end\r\n return my_string\r\nend", "def crunch(str)\n new_string = ''\n counter = 0\n while counter <= str.length - 1\n new_string << str[counter] unless str[counter] == str[counter + 1]\n counter += 1\n end\n new_string\nend", "def reverse(s)\n return \"\" if s == nil || s.length == 0\n return reverse(s[1..-1]) + s[0] #s[1..-1] is creating a new substring using a new memory address(diff object id)\nend", "def reverse_string(string)\n rev_string = \"\"\n string.length.times do |i|\n rev_string = string[i] + rev_string\n end\n\n puts rev_string\nend", "def solve(s)\n answer = \"\"\n (0...s.length - 1).each do |idx|\n if s[idx] != s[idx + 1]\n answer += s[idx]\n end\n if idx == s.length - 2 && s[idx] == s[idx + 1]\n answer += s[idx]\n end\n end\n return answer\nend", "def is_palindrome(string)\n\n concate_array = string.downcase.split(\"\")\n backwards = \"\"\n concate_array_no_punc = \"\"\n\n concate_array.length.times do |i|\n if [\":\",\",\",\" \"].include?(concate_array[-1-i])\n nil \n else \n backwards += concate_array[-1-i]\n end\n\n if [\":\",\",\",\" \"].include?(concate_array[i])\n nil \n else \n concate_array_no_punc += concate_array[i]\n end\n end\n\n if backwards == concate_array_no_punc\n return true\n else \n return false\n end\nend", "def reverse_string_2(string)\n string = string.to_s\n result = ''\n for i in 1..string.length do\n result += string[-1 * i]\n end\n result\nend", "def reverse_string_3(string)\n string = string.to_s\n result = ''\n string.length.times { |i| result << string[(i + 1) * -1] }\n result\nend", "def palindrome?(string)\n chars_arr = string.chars\n new_arr = []\n chars_arr.each { |substring| new_arr.prepend(substring) }\n new_arr.join == string\nend", "def solve(s0, s1)\n # shift and push the first letter of the array length number of times\n # check if s0 == s1 each time\n return true if s0 == s1\n \n rotations = s0.length\n \n s0_arr = s0.split('')\n s1_arr = s1.split('')\n until s0_arr == s1_arr || rotations == 0\n s0_arr == s0_arr.push(s0_arr.shift)\n rotations -= 1\n return true if s0_arr == s1_arr\n end\n return false\nend", "def reverse_in_place (string_to_reverse)\n\n\tcount_down = string_to_reverse.length-1\n\tfor l in (0...string_to_reverse.length/2)\n\t\ttemp_var = string_to_reverse[l]\n\t\tstring_to_reverse[l] = string_to_reverse[count_down]\n\t\tstring_to_reverse[count_down] = temp_var\n\t\tputs string_to_reverse\n\t\tcount_down -= 1\n\n\tend\n\n\t string_to_reverse\n\nend", "def string_reverse(my_string)\r\n return my_string if my_string.nil? || my_string == \"\"\r\n\r\n middle = my_string.length / 2\r\n i = 0\r\n j = my_string.length - 1\r\n\r\n while i < middle\r\n placeholder = my_string[i]\r\n my_string[i] = my_string[j]\r\n my_string[j] = placeholder\r\n i += 1\r\n j -= 1\r\n end\r\n return my_string\r\nend", "def palindrome?(string)\n string.chars.reverse.join == string\nend", "def my_reverse(string)\n\t\ta = string.length - 1\n\t\t@new_string = \"\"\n\t\ta.downto(0) { |i| @new_string << string[i] }\n\t\tprint @new_string\n\tend", "def string_reverse(my_string, start_index, end_index)\n i = start_index\n j = end_index\n while i < j\n #flipflop characters using holding variable as a place to put one character while the other goes in its place.\n holding = my_string[i]\n my_string[i] = my_string[j]\n my_string[j] = holding\n\n #move up and move down the string.\n i += 1\n j -= 1\n end\n return my_string\nend", "def reverse (string_to_check)\n\n\tif string_to_check.bytes.last == 0\n\t\tputs \"yup\"\n\t\treturn string_to_check.reverse\n\tend\n\n\tnil\n\nend", "def reverse(string)\n # Create an empty String\n reversed_string = ''\n \n # Create counter\n i = 0\n \n # Loop through the lenght of the string, and build out the new reversed string\n while i < string.length\n reversed_string = string[i] + reversed_string\n # Incremnent by 1 to end loop\n i += 1\n end\n \n # Return our new string\n return reversed_string\n end", "def front_again(str)\n str[0..1] == str[-2..]\n end", "def rev(str)\n new_string = str.gsub(/(\\s|,|\\.)/,\"\")\n newer_string = str.gsub(/(\\s|,|\\.)/,\"\").split(\"\").reverse.join(\"\")\n p newer_string === new_string\nend", "def palindrome?(string)\n reversed_string = ''\n i = -1\n loop do \n reversed_string << string[i]\n i -= 1\n break if i < -string.length\n end\n reversed_string == string\nend", "def palindrome(string)\n result = Array.new\n\n new_string = string.chars\n string.size.times { result << new_string.pop }\n result.join\nend", "def palindrome?\n str = self.to_s\n len = str.size\n\n if len.odd?\n str[0, len/2] == str[len/2 + 1, len/2].reverse\n else\n str[0, len/2] == str[len/2, len/2].reverse\n end\n end", "def string_reverse (my_string, s_index, e_index)\n i = s_index\n j = e_index\n\n while i < j\n temp = my_string[i]\n my_string[i] = my_string[j]\n my_string[j] = temp\n\n i += 1\n j -= 1\n end\n return\nend", "def string_reverse(my_string)\r\n if my_string == nil\r\n return nil\r\n end\r\n if my_string == \"\"\r\n return \"\"\r\n end\r\n n = 1\r\n str_length = my_string.length\r\n (str_length / 2).times do |i|\r\n temp = my_string[i]\r\n my_string[i] = my_string[str_length - n]\r\n my_string[str_length - n] = temp\r\n n += 1\r\n end\r\n return my_string\r\nend", "def string_compress(string)\n original=string\n i=0\n while(i<string.length)\n j=i\n while (string[i]==string[j])\n j+=1\n end\n string[i..j-1]=\"#{string[i]}#{(j-i)}\"\n i+=2\n end\n return original if string.length>original.length \n return string\n \nend", "def reverse!(string, i, j) # \" I can do this! \" \n while i < j \n string[i], string[j] = string[j], string[i]\n\n # # same as above\n # temp = string[i]\n # string[i] = string[j] \n # string[j] = temp\n \n i += 1 \n j -= 1\n end \n\n return string # \" !siht od nac I \"\nend", "def is_palindrome(word)\n palindrome = \"\"\n i = 0\n while i < word.length\n palindrome = word[i] + palindrome #concats backwards into palindrome\n i += 1\n end\n return palindrome == word #compares the newly stored backward word, to the word inputted\nend", "def crunch(string)\n index = 0\n str_text = ''\n while index <= string.length - 1\n str_text << string[index] unless string[index] == string[index + 1]\n index += 1\n end\n str_text\nend", "def palindrome_permutation(str)\n\nend", "def palindrome_index string\n s1 = string.chars\n s2 = string.reverse.chars\n indices = []\n\n if s1 == s2\n puts -1\n else\n s1.each_with_index do |x,xi|\n indices << xi if x != s2[xi]\n end\n \n s1.delete_at(indices.first)\n puts s1 == s1.reverse ? indices.first : indices.last\n end\nend", "def reverse_inplace(s)\n # Input validation\n return nil if s == nil\n return '' if s.length == 0 \n i = 0\n j = s.length-1\n reverse_helper(s, i, j)\n return s \nend", "def reverse(string, start ,last)\n i = start\n j = last\n\n while i < j\n string[j], string[i] = string[i], string[j]\n i += 1\n j -= 1\n end\n return string\nend", "def reverse_string_5(string)\n string = string.to_s\n result = ''\n string.split('').each_index do |i|\n result += if i != 0\n string[-1 * (i + 1)]\n else\n string[i - 1]\n end\n end\n result\nend", "def palindrome (input_string)\n input_string == input_string.reverse\nend", "def one_away(str1, str2)\n if str1.length > str2.length\n longer = str1.length\n else\n longer = str2.length\n end\n\n different_counter = 0\n i = 0\n while i < longer\n if !str1[i]\n str1[i] = \" \"\n end\n\n if !str2[i]\n str2[i] = \" \"\n end\n\n if str1[0] != str2[0]\n different_counter += 1\n if different_counter > 1\n return false\n end\n end\n i += 1\n end\n\n true\nend", "def reverse_inplace(s)\n return reverse_helper(s, 0 , s.length - 1) \nend", "def reverse(string)\n #debugger\n arr = string.split(\"\")\n last_letter = arr.pop\n return \"\" if last_letter == nil\n new_string = arr.join(\"\")\n last_letter + reverse(new_string)\nend", "def reverse_a_string(string)\n split_string = string.split(\"\")\n reverse_string = []\n string.length.times { reverse_string << split_string.pop}\n reverse_string.join\nend", "def reverse!(string)\n length = string.length - 1\n (length / 2).times do |idx|\n string[idx], string[length - idx] = string[length - idx], string[idx]\n end\n string\nend", "def reverse_string_4(string)\n string = string.to_s\n result = ''\n index = 0\n while index < string.length\n result = string[index] + result\n index += 1\n end\n result\nend", "def reverse_string_in_place(str)\n last_index = str.length # start off as one more than last index\n\n (0...str.length).each do |i|\n last_index = last_index - 1 # keep track of corresponding later char\n current_char = str[i]\n later_char = str[last_index]\n\n next if i == last_index || i < last_index\n\n # swap them in str\n str[i] = later_char\n str[last_index] = current_char\n end\n\n p str\nend", "def string_reverse(my_string)\r\n return my_string if my_string.length < 2\r\n\r\n i = 0\r\n\r\n while i < my_string.length/2\r\n swap_in_place(my_string, i, my_string.length-i-1)\r\n i +=1\r\n end\r\n\r\n return my_string\r\nend", "def reverse(s)\n # create the string variable so we don't modify the string passed in as a parameter\n string = s\n if string.length < 2\n return s\n end\n\n last_el = string[-1]\n others = string[0...-1]\n others = reverse(others)\n return last_el + others\nend", "def crunch(str)\n if str == '' \n return ''\n end\n \n new_arr = str.split('')\n str_out = new_arr[0]\n \n (1..new_arr.size-1).each {|n|\n new_arr[n] != new_arr[n-1] ? \n str_out << new_arr[n]\n : n\n }\n \n str_out\nend", "def solution(sentence)\n sentence.split.reverse.join(\" \")\nend", "def reverse_inplace(s)\n\treturn reverse_helper(s, 0, (s.length - 1))\nend", "def palindrome?(str)\n length = str.length\n half1 = str.slice(0, length/2)\n if length.odd?\n half2 = str.slice(length/2 + 1, length)\n else\n half2 = str.slice(length/2, length)\n end\n half1 === half2.reverse\nend", "def reverse_string(string)\n reverse_array = []\n new_array = string.split(\" \")\n\n string.length.times do \n reverse_array << new_array.pop\n \n end\n\n reverse_array.join(' ').gsub('doing?', 'doing')\nend", "def shortest_palindrome(string)\n return string if palindrome?(string)\n\n for i in 0...string.length\n rev = string.length - i\n suffix = string[(rev - 1)...string.length]\n rev_suffix = suffix.reverse\n\n new_string = rev_suffix + string\n return new_string if palindrome?(new_string)\n end\nend", "def q5_reverse(str)\n str.split('').reverse.join('')\nend", "def string_reverse(my_string)\r\n if my_string == nil\r\n return my_string\r\n else\r\n i = 0\r\n len = my_string.length\r\n (len / 2).times do\r\n low = my_string[i]\r\n high = my_string[len - 1 - i]\r\n x = low\r\n my_string[i] = high\r\n my_string[len - 1 - i] = x\r\n i += 1\r\n end\r\n return my_string\r\n end\r\nend", "def reverse_string(string)\n #time complexity and space compexity O(n), there are 2 loops but they are not nested\n #each loop is O(n)\n return nil if string.class != String #check if input os correct\n local_stack = Stack.new() #create new Stack instance\n string.each_char do |char| #insert all character from string into stack\n local_stack.push(char)\n end\n string.length.times do |i| #reassign characters with stack values (FILO)\n string[i] = local_stack.pop()\n end\n string\nend", "def palindrome_check(my_phrase)\r\n string_fixed = my_phrase.split.join\r\n first_position = 0\r\n last_position = string_fixed.length - 1\r\n\r\n while first_position != last_position\r\n\r\n case\r\n when string_fixed[first_position] != string_fixed[last_position]\r\n return false\r\n exit\r\n when string_fixed[first_position] == string_fixed[last_position]\r\n first_position += 1\r\n last_position -= 1\r\n end\r\n return true\r\n end\r\nend", "def palindrome(sentence)\n line = sentence.downcase.split.join # same as line = sentence.downcase.gsub(\" \", \"\")\n if line = line.reverse\n # p line\n return true\n else\n return false\n end\n \n \nend", "def string_reverse(my_string)\r\n return my_string if my_string == nil\r\n\r\n i = 0\r\n j = my_string.length - 1\r\n\r\n while i < j\r\n b = my_string[i]\r\n my_string[i] = my_string[j]\r\n my_string[j] = b\r\n\r\n i += 1\r\n j -= 1\r\n end\r\n\r\n return my_string\r\nend", "def PalindromeTwo(str)\n backword_string = str.gsub(/[^a-zA-Z]/,\"\").downcase.reverse\n backword_string == str.gsub(/[^a-zA-Z]/,\"\").split(//).join.downcase ? puts(\"true\") : puts(\"false\")\nend", "def is_palindrome?(value)\n value.downcase!\n\n reversed = \"\"\n count = value.lentgth\n\nwhile count > 0\n count -= 1\n reversed += value[count]\nend\n\n if value == reversed\n return \"#{value} is a palindrome\"\n else\n return \"#{value} is not a palindrome\"\n end\nend", "def reverse!(str)\n\ti = 0\n\twhile i < str.length / 2\n\t\ttmp = str[i]\n\t\tstr[i] = str[str.length-1-i]\n\t\tstr[str.length-1-i] = tmp\n\t\ti += 1\n\t\t# puts str\n\tend\nend", "def palindrome?(string)\n \n begin_index = 0\n end_index = string.length - 1\n \n if string.length == 1\n return true\n end\n \n while begin_index < end_index || begin_index != end_index\n if string[begin_index] == string[end_index]\n begin_index += 1\n end_index -= 1\n palindrome = true\n else\n begin_index = end_index\n palindrome = false\n end\n end\n return palindrome\n \nend", "def reverse_inplace(s)\n return s if s.length == 0\n return s if s.length == 1\n\n reverse_helper(s, 0, s.length - 1)\n return s\nend", "def reverse_inplace(s)\n b = 0\n e = s.length - 1\n reverse_inplace_helper(b,e,s)\n return s\nend", "def palindrome_index string\n s1 = string.chars\n s2 = s1.reverse\n\n if s1 == s2\n -1\n else\n index = []\n\n s1.each_with_index do |x,xi|\n if x != s2[xi]\n index << xi\n end\n end\n\n s1.delete_at(index.first)\n\n # m2 = s1.delete_at(index.last)\n\n if s1 == s1.reverse\n index.first\n else\n index.last\n end\n end\nend", "def palindrome(string)\n result = []\n new_string = string.chars\n\n loop do\n result << new_string.pop\n break if new_string.size == 0\n end\n result.join\nend", "def is_palindrome(s)\n return true if s.empty?\n return false if s[0] != s[-1]\n return is_palindrome(s[1...-1])\n \n # To do this without creating new strings, make a helper method\n # that accepts additional parameters for left_char and right_char and increments\n # them inward each time, like I did for reverse_in_place with helper_reverse\nend", "def reverse(s)\n str =''\n index = s.length-1\n str= reverse_helper(s,str,index)\n return str\n\nend", "def FirstReverse(str)\n new_str = ''\n loop_t = str.length\n while loop_t > 0\n new_str << str[loop_t -1]\n loop_t -= 1\n end\n return new_str\nend", "def reverse_fun(s)\n reversed_string = s.reverse\n if reversed_string.size == 1\n reversed_string\n else\n reversed_string[0] + reverse_fun(reversed_string[1..-1])\n end\nend", "def crunch(string)\n counter = 0\n new_string = string[0]\n return new_string if string.length <= 1\n return string if string == ''\n loop do\n counter += 1\n new_string << string[counter] if string[counter - 1] != string[counter]\n\n break if counter == (string.length - 1)\n end\n new_string\nend", "def reverse(s)\n return '' if s == nil || s == ''\n\n i = 0\n puts \"#{s} #{s[i]}\"\n return reverse(s[i + 1..-1]) + s[i]\nend", "def solution(sentence)\n return sentence.split.reverse.join(\" \")\nend", "def isPalindrome(string)\n return string.reverse == string\nend" ]
[ "0.6819071", "0.68182075", "0.67821515", "0.6779305", "0.6774216", "0.6770996", "0.6744134", "0.6741999", "0.673775", "0.6630879", "0.66058594", "0.6592998", "0.6521769", "0.65190744", "0.65078026", "0.65078026", "0.6504867", "0.6472779", "0.6449276", "0.6448165", "0.6447041", "0.64348364", "0.6433581", "0.6422731", "0.64209074", "0.6419649", "0.64160323", "0.6413968", "0.64117515", "0.64056265", "0.6388562", "0.63823473", "0.6378518", "0.6376327", "0.6374744", "0.63655514", "0.634994", "0.6341605", "0.63385475", "0.6330157", "0.632272", "0.63194937", "0.6319458", "0.6318424", "0.6318423", "0.6313493", "0.630806", "0.6301785", "0.630001", "0.62745434", "0.6268694", "0.6268148", "0.62634367", "0.62633896", "0.6256588", "0.62540406", "0.6247828", "0.62473166", "0.6243551", "0.6238634", "0.62380934", "0.6227447", "0.62266797", "0.62236655", "0.6219555", "0.62188894", "0.6211181", "0.6208532", "0.620303", "0.6201416", "0.619952", "0.618908", "0.6184841", "0.6183398", "0.61823636", "0.6182102", "0.6181331", "0.61795515", "0.6177676", "0.61667615", "0.61612874", "0.61573", "0.61542577", "0.6151125", "0.61504143", "0.61489505", "0.61449146", "0.614478", "0.614436", "0.61425126", "0.613948", "0.6138407", "0.6138369", "0.6137886", "0.6137611", "0.6136832", "0.61366063", "0.61331123", "0.6128539", "0.61281306", "0.6127247" ]
0.0
-1
checks the album to see if there is a file with the same def has_same_photo?(album_id, f)
def has_same_photo?(fb_photos, f) # album = Mogli::Album.find(album_id, client) # fb_photos = album.photos has_photo = false fb_photos.each do |p| break if has_photo fb_photo_url = p.source fb_photo_file = get_photo_as_file_from_url(fb_photo_url) # Rails.logger.info "reference photo(from flickr): #{f.path} - exists? #{File.exists?(f.path)}" # Rails.logger.info "compared to (from fb): #{fb_photo_file.path} - exists? #{File.exists?(fb_photo_file.path)}" # Delayed::Worker.info "reference photo(from flickr): #{f.path} - exists? #{File.exists?(f.path)}" # Delayed::Worker.logger.info "comparing incoming flickr photo to fb photos: #{fb_photo_file.path} - exists? #{File.exists?(fb_photo_file.path)}" Delayed::Worker.logger.info "comparing incoming flickr photo to fb photos: #{p.name} - #{fb_photo_url}" comparer = ImageCompare.new(f.path, fb_photo_file.path) has_photo = true if comparer.identical?(:tolerance => 0.02) Delayed::Worker.logger.info "identical to flickr photo?: #{has_photo.inspect}" end Delayed::Worker.logger.info " ********** Found duplicate in album?: #{has_photo.inspect}" Delayed::Worker.logger.info " " return has_photo end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def same_files?(*files)\n images = files.map { |fname| Digest::MD5.digest(File.binread(fname)) }\n images.all? { |img| img == images[0] }\nend", "def has_photo?\n File.exists? photo_filename\n end", "def has_photo?\n File.exists? photo_filename\n end", "def has_photo?\n File.exists? photo_filename\n end", "def all_same_album?(tags)\n all_same_tag?(tags, :album)\n end", "def eql?(other)\n\t\t\tself.fileid.eql?(other.fileid)\n\t\tend", "def photo_exists?(event)\n (!event.photo_file_name.nil? && !event.photo_file_name.empty?) || (event.photo_content_type && event.photo_file_size)\n end", "def identical?(file1, file2)\n File.identical?(file1, file2)\n end", "def is_pic_url_dup?\n self.class.where(\"pic = ? and id != ?\", pic, id).count > 0\n end", "def files_are_same(file1, file2)\n begin\n File.open(file1, 'rb').read == File.open(file1, 'rb').read\n rescue\n false\n end\nend", "def album_unique?(album_object, artist_object)\n\n albums = self.albums.select{|album| album.artist.present?}\n non_nil_albums = albums.select{|album| album.artist.name == artist_object.name} << album_object.name\n non_nil_albums.length == non_nil_albums.uniq.length\n end", "def photo_exists?(db, filename)\n\n query = db.exec(\"select photo from imageuploader where photo = '#{filename}'\")\n query == nil ? true : false\n\n end", "def update_photo(album_id, photo_id, file, filename)\n \n end", "def image_exist(gallery_id, filename)\n gallery_id = \"Default\" if gallery_id.strip.empty?\n perform_with_session_expire_retry {\n auth_login unless logged_in?\n path = BSAPI+\"mem/image/query?format=xml\"\n boundary = Digest::MD5.hexdigest(gallery_id).to_s # just hash the collection_name itself\n headers = get_default_headers(\"Content-type\" => \"multipart/form-data, boundary=#{boundary}\")\n parts = []\n parts << key_value_to_multipart(\"gallery_id\", gallery_id)\n parts << key_value_to_multipart(\"file_name\", filename)\n body = combine_parts(parts, boundary)\n resp = @http.post(path, body, headers)\n handle_server_response(path, resp, resp.body)\n #@last_response_xml.write($stderr, 0)\n # dbgprint @last_response_xml.inspect\n exists = false\n total = 0\n total = @last_response_xml.get_elements(\"PhotoShelterAPI/data/total\").map {|e| e.text }.join\n if total.to_i > 0\n exists = true\n end\n #dbgprint \"image_exist('#{gallery_id}','#{filename}') = #{exists}\"\n exists\n }\n end", "def already_uploaded?\n false\n seen_before = Zaphod::PhotoStorage.get(\"seen_id_#{@post_id}\",\"recommendation\")\n if seen_before && seen_before == @post_id\n @log.debug(\"already uploaded ID #{seen_before}... skipping\")\n true\n end\n end", "def verify_ownership\n @photo = Photo.find_by(id: params[:id] || params[:photo][:id])\n\n unless owner?(@photo)\n flash[:alert] = I18n.t(\"photos.ownership.error\")\n redirect_to gallery_path\n end\n end", "def same_file?(a, b)\n File.expand_path(a) == File.expand_path(b)\n end", "def photoset_exist? name\n @flickr.photosets.getList.each do |x|\n return true if x.title == name\n end\n return false\n end", "def owner?(photo)\n !photo.nil? && photo.owner == current_user\n end", "def quick_equal?\n return nil unless old_file_exists?\n return true if new_file_size == old_file_size\n old_file, new_file = load_image_files(@old_file_name, @new_file_name)\n return true if old_file == new_file\n images = load_images(old_file, new_file)\n crop_images(images, @dimensions) if @dimensions\n\n old_img = images.first\n new_img = images.last\n\n return false if sizes_changed?(old_img, new_img)\n\n return true if old_img.pixels == new_img.pixels\n\n @left, @top, @right, @bottom = find_top(old_img, new_img)\n\n return true if @top.nil?\n\n if @area_size_limit\n @left, @top, @right, @bottom = find_diff_rectangle(old_img, new_img)\n return true if size <= @area_size_limit\n end\n\n false\n end", "def album_name_unique?(album_name, artist_name) \n album_names = self.albums.select{|album| album.artist.present?}\n .select{|album| album.artist.name == artist_name}\n .map{|album| album.name}\n\n album_names.select{|name| name == album_name}.blank?\n \n end", "def eql?(fe)\n @archive_filename.eql?(fe.archive_filename) and @sha512hash.eql?(fe.sha512hash) and @mtime.eql?(fe.mtime)\n end", "def files_same?(file1, file2) \n if (File.size(file1) != File.size(file2)) then\n return false\n end\n f1 = IO.readlines(file1)\n f2 = IO.readlines(file2)\n if ((f1 - f2).size == 0) then\n return true\n else\n return false\n end\n end", "def files_same?(file1, file2) \n if (File.size(file1) != File.size(file2)) then\n return false\n end\n f1 = IO.readlines(file1)\n f2 = IO.readlines(file2)\n if ((f1 - f2).size == 0) then\n return true\n else\n return false\n end\n end", "def files_same?(file1, file2) \n if (File.size(file1) != File.size(file2)) then\n return false\n end\n f1 = IO.readlines(file1)\n f2 = IO.readlines(file2)\n if ((f1 - f2).size == 0) then\n return true\n else\n return false\n end\n end", "def object_filepaths_unique?\n filepaths.count == filepaths.uniq.count\n end", "def has_photo?\n send('file_uploader_url').present?\n end", "def photo_album(id)\n backup_photo_albums.find_by_source_album_id(id)\n end", "def ignore_blanks_and_duplicates\n if (self.image_file_name.nil? || self.image_file_name.blank?) && (self.unique_image_file_name.nil? || self.unique_image_file_name.blank?)\n self.errors[:unique_image_file_name].push 'cannot be blank unless uploading from a browser'\n return false\n end\n \n master = self.variant.product.master\n if !master.nil?\n master.variant_images.each do |i|\n if i.unique_image_file_name==self.unique_image_file_name \n self.errors[:unique_image_file_name].push 'is a duplicate with a master image'\n return false\n end\n end\n end\n end", "def ==(other)\n return false unless @path && @file_id && other.path && other.file_id\n @path == other.path && @file_id == other.file_id\n end", "def has_any_photo\n recipe_photos.any?\n end", "def album_update_photo!(photo_data, photo_file)\n\n if album \n album.add_or_update_photo(photo_data, photo_file)\n end\n \n end", "def picture_exist?(filename)\n test_file_existence(filename, Pictures_Path, @picture_data)\n end", "def files_match?\n @fixture.files == @local.files\n end", "def sameFile( fileA, fileB )\n\n # If symlinks, make sure they link to the same thing.\n if File.symlink?( fileA ) || File.symlink?( fileB )\n return false unless File.symlink?( fileA ) and File.symlink?( fileB )\n linkA = File.readlink( fileA )\n linkB = File.readlink( fileB )\n return linkA == linkB\n end\n\n # Both exist.\n return false unless File.exists?( fileA ) and File.exists?( fileB )\n # Both are the same size.\n aBytes = File.stat( fileA ).size\n bBytes = File.stat( fileB ).size\n return false unless aBytes == bBytes\n\n # Random sample comparison.\n same = true\n $options[:samples].times do\n start = rand( aBytes )\n length = [aBytes, start + SampleSize].min - start + 1\n aSample = File.read( fileA, length, start )\n bSample = File.read( fileB, length, start )\n same = same && aSample == bSample\n end\n return same\nrescue\n STDOUT.puts \"ERROR: Can't read file [#{fileA}]\"\n $errorCount += 1\n return true # So we don't get two messages for the same file\nend", "def create_photo(album_id, photo_id, file, filename)\n \n end", "def find_same_files\n # loop over find_similar_files groups\n # diff -b file1 file2\n end", "def top_photo?\n if self.albums.length >= 3\n true\n else\n false\n end\n end", "def sameFile( fileA, fileB )\n\n\n # Both exist.\n return false unless File.exists?( fileA ) and File.exists?( fileB )\n # Both are the same size.\n aBytes = File.stat( fileA ).size\n bBytes = File.stat( fileB ).size\n return false unless aBytes == bBytes\n\n # Random sample comparison.\n same = true\n $options[:samples].times do \n start = rand( aBytes ) \n length = [aBytes, start + SampleSize].min - start + 1\n aSample = File.read( fileA, length, start )\n bSample = File.read( fileB, length, start )\n same = same && aSample == bSample\n end\n return same\nrescue\n STDOUT.puts \"ERROR: Can't read file [#{fileA}]\"\n $errorCount += 1\n return true # So we don't get two messages for the same file\nend", "def first?(photo_set)\n return ppsjoin(photo_set).first? \n end", "def correct_account\n @album = Album.find(params[:album_id])\n if current_account.fullname != @album.creator\n \tredirect_to(new_album_photo_path(@album))\n \tflash[:notice] = \"You can not add photo to this album.\"\n end\n \tend", "def has_file\n if id == nil \n false\n else\n FileTest.exists?( local_file_path )\n end\n end", "def uniq_tag?(tag)\n values = @selected_files.map { |file| file[tag] }\n values.reduce(true) { |r, v| r && (v.size == 1) } && (values.map { |v| v.first }.uniq.length == 1)\n end", "def pfile?\n @raw_image_files.first.pfile?\n end", "def remote_file_differs?(full_path, content)\n !remote_file_exists?(full_path) || remote_file_exists?(full_path) && !remote_file_content_same_as?(full_path, content)\n end", "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 file_matching_path\n !!container.stored_files.where(file_name: file_name, path: path).first\n end", "def target_albums(picture)\n self.albums.reject{ |album| album.pictures.include?(picture) }\n end", "def file_different?\n if @name && File.exist?( @name )\n Digest::MD5.hexdigest(\n @lines.join( \"\\n\" )\n ) != Digest::MD5.hexdigest(\n File.read( @name )\n )\n else\n true\n end\n end", "def thumbnail_image_exists?\n image.present? and image.thumbnail.file.exists?\n end", "def geifile?\n @raw_image_files.first.geifile?\n end", "def already_loaded?(uploaded_file)\n uploaded_file.reload\n originals = uploaded_file.original_inputs\n return false unless originals.present?\n sha2_hashes = []\n originals.each do |orig|\n return false if orig.nil? || orig.sha2_hash.nil?\n sha2_hashes << orig.sha2_hash\n end\n\n return false if sha2_hashes.empty?\n\n UploadedFile.joins(:original_inputs)\n .where(status: 'S')\n .where(validate_only: false)\n .where(original_input: {sha2_hash: sha2_hashes,\n mime_type: 'text/stix'}).count > 0\n end", "def path_is_unique\n return true if self.mp3.file.blank?\n\n # Guess what the audio path will be before it's actually saved there.\n # This is predictable for uploaded audio.\n # This could potentially fail if someone was uploading audio at exactly\n # midnight and some audio already existed for the next day.\n path = File.join(\n AUDIO_PATH_ROOT,\n self.store_dir,\n self.filename\n )\n\n if File.exist?(path)\n self.errors.add(:mp3, \"A file with that name already exists; \" \\\n \"please rename your local audio file and try again. \" \\\n \"If you are trying to replace the audio file, first delete the \" \\\n \"old audio.\")\n end\n end", "def has_access_to_file(file_id, user_id)\n if get_all_user_data(user_id).first[\"rank\"] >= 1\n return true\n end\n \n owner_id = $db.execute(\"SELECT owner_id FROM files WHERE file_id = ?\", file_id).first[\"owner_id\"]\n if owner_id == user_id\n return true\n end\n\n shared_users = $db.execute(\"SELECT user_id FROM shared_files WHERE file_id = ?\", file_id)\n shared_users.each do |user|\n if user[\"user_id\"] == user_id\n return true\n end\n end\n return false\nend", "def verify_identical_file!(bucket_file)\n disk_contents = IO.binread(path_for(bucket_file.bucket_path, bucket_file.checksum_data, 'contents'))\n\n # If the contents don't match, then we've found a conflict.\n # Unlikely, but quite bad.\n if disk_contents != bucket_file.contents\n raise Puppet::FileBucket::BucketError, \"Got passed new contents for sum #{bucket_file.checksum}\"\n else\n Puppet.info \"FileBucket got a duplicate file #{bucket_file.checksum}\"\n end\n end", "def belongs_to_me? file\n #The only difference between shared files that have been added to your Drive\n #and those that haven't is that those that have have a file path (parents)\n return true if @config['sync_shared_in_drive'] and file.parents != nil and file.parents != []\n file.shared_with_me_time.nil? and file.owners != nil and file.owners.select{|owner| owner.me}.count > 0\n end", "def has_image?\n \t# self.image.file?\n true\n end", "def add_photo?\n true\n end", "def already_stored?\n !file_uniqueness\n end", "def document_media_is_unique\n return if self.documents.count == 0\n\n valid = true\n\n corpus_media = Array.new\n\n self.documents.each { |d| corpus_media.push(:id => d.id, :media => d.media_descriptors) }\n\n last_media_urls = Array.new\n last = self.documents.last\n last.media_descriptors.each { |m| last_media_urls.push(m[:media_url]) }\n\n corpus_media.each do |m|\n if m[:id] != last.id then\n item_media_urls = Array.new\n m[:media].each { |m| item_media_urls.push(m[:media_url]) }\n\n if (last_media_urls == item_media_urls)\n valid = false\n break\n end\n end\n end\n\n errors.add :file, \"contains a media set already in this corpus.\" if valid == false\n end", "def identical?\n exists? && File.identical?(render, destination)\n end", "def exists?(file_hash)\n !!where(file_hash: file_hash).first\n end", "def exists?(remote_file, local_file = nil)\n if (file = find_by_path(remote_file)) == nil\n if local_file != nil\n if (file = find_by_md5(Digest::MD5.file(local_file).to_s)) != nil\n path = build_node_path(file)\n return {\n :success => true,\n :data => {\n \"message\" => \"File with same MD5 exists at #{path}: #{file.to_json}\",\n \"path_match\" => false,\n \"md5_match\" => true\n }\n }\n end\n end\n return {\n :success => false,\n :data => {\n \"message\" => \"File #{remote_file} does not exist\"\n }\n }\n end\n\n retval = {\n :success => true,\n :data => {\n \"message\" => \"File #{remote_file} exists\",\n \"path_match\" => true,\n \"md5_match\" => false,\n \"node\" => file\n }\n }\n\n if local_file != nil\n if file[\"contentProperties\"] != nil && file[\"contentProperties\"][\"md5\"] != nil\n if Digest::MD5.file(local_file).to_s != file[\"contentProperties\"][\"md5\"]\n retval[:data][\"message\"] = \"File #{remote_file} exists but checksum doesn't match\"\n else\n retval[:data][\"message\"] = \"File #{remote_file} exists and is identical\"\n retval[:data][\"md5_match\"] = true\n end\n else\n retval[:data][\"message\"] = \"File #{remote_file} exists, but no checksum is available\"\n end\n end\n\n retval\n end", "def check_file(local_file)\n # Immateriel.info binding, @url\n uniq_str = Digest::MD5.hexdigest(\"#{@url}:#{local_file}\")\n uri = URI.parse(@url)\n fn = \"/tmp/#{uniq_str}_\" + Digest::MD5.hexdigest(File.basename(uri.path)) + File.extname(uri.path)\n self.class.download(@url, fn)\n if File.exist?(fn)\n check_result = self.class.check_image(fn, local_file, uniq_str)\n FileUtils.rm_f(fn)\n if check_result\n true\n else\n false\n end\n else\n false\n end\n end", "def image?\n self.image.file?\n end", "def image?\n self.image.file?\n end", "def updatedb_file_group?(file, group)\n owner = updatedb_file_group(file)\n group == owner\n end", "def image?(new_file)\n self.file.content_type.include? 'image'\n end", "def has_image?\n File.exists? image_filename\n end", "def file_owned?(file, item)\n file.owner_item_type == item.class.name && file.owner_item_id == item.id\n end", "def expected_duplicate?(id)\n EXPECTED_DUPLICATES.include? id\n end", "def original_photo(photourl)\n if(current_user.upvotes.find_by(photourl: photourl) || current_user.downvotes.find_by(photourl: photourl)) \n return false\n end\n return true\nend", "def existing_file?(row)\n existing_files_by_filename.key?(row[\"filename\"])\n end", "def content_file_checksums_match?\n checksum_failures = \"\"\n described_datafiles.each do |datafile|\n info = datafile.checksum_info\n\n if File.exists?(datafile.datapath) == false\n checksum_failures << \"#{datafile['sip-path']} - missing; \"\n elsif info[0] != info[1]\n checksum_failures << \"#{datafile['sip-path']} - expected: #{info[0]} computed: #{info[1]}; \"\n else\n next\n end\n end\n\n if checksum_failures.length > 0\n metadata[\"checksum_failures\"] = checksum_failures\n return false\n else\n return true\n end\n end", "def has_image?\n return File.exists? image_filename \n end", "def has_image?\n return File.exists? image_filename \n end", "def compare_files(f1, f2)\n begin\n file1 = IO.read f1[:path]\n file2 = IO.read f2[:path]\n rescue => e # file doesn't exists, db have to be updated\n @show.call \"\\t[Error]: #{e} Please update your database\"\n return nil\n end\n # if 100% similarity and files have the same size\n if @options[\"p\"][:value] == 100\n return nil if f1[:size] != f2[:size]\n return 100 * (Algorithms.fdupes_match(file1, f1[:size], file2, f2[:size]) + 1)\n end\n Algorithms.diff(file1, file2)\n end", "def remote_file_content_same_as?(full_path, content)\n Digest::MD5.hexdigest(content) == capture(\"md5sum #{full_path} | awk '{ print $1 }'\").strip\n end", "def file_name_exist(file_name, owner_id)\n if $db.execute(\"SELECT file_name FROM files WHERE file_name = ? AND owner_id = ?\", file_name, owner_id) == []\n return false\n else\n return true\n end\nend", "def has_photos?\n photos.length > 0\n end", "def userCanSeePhoto?(photo)\r\n\t\t#f = false\r\n\t\t#if photo != nil\r\n\t\t#\tif @theme != nil\r\n\t\t#\t\tf = userCanSeeTheme?(@theme)\r\n\t\t#\telsif @photo_msg != nil\r\n\t\t#\t\tf = userCanSeeMessage?(@photo_msg)\r\n\t\t#\telsif @album != nil\r\n\t\t#\t\tf = userCanSeeAlbum?(@album) || (@album.status_id == 0 && @album.user == current_user)\r\n\t\t#\telsif @article != nil\r\n\t\t#\t\tf = isEntityOwner?(@article)\r\n\t\t#\telsif @event != nil\r\n\t\t#\t\tf = userCanSeeEvent?(@event)\r\n\t\t#\tend\r\n\t\t#end\r\n\t\treturn true\r\n\tend", "def add_or_update_photo(photo_data, photo_file, filename)\n\n if photo_data.has_key?(:photo_id)\n photo = Media::Photo.get(photo_data[:photo_id])\n else \n photo = Media::Photo.create({:album => self, \n :name => photo_data[:photo_name],\n :description => photo_data[:photo_description]})\n end\n\n photo.store_photo(photo_file, filename)\n\n return photo\n \n end", "def same_tracks_as?(other_pattern)\n @tracks.keys.each do |track_name|\n other_pattern_track = other_pattern.tracks[track_name]\n if other_pattern_track == nil || @tracks[track_name].rhythm != other_pattern_track.rhythm\n return false\n end\n end\n \n return @tracks.length == other_pattern.tracks.length\n end", "def files_different?(path, local_path, content=nil)\n end", "def image_exists?(listing_id, ndx)\n result = nil\n connect_to_s3() if ! @s3\n result = @bucket_files.select { |file_name| file_name =~ /#{listing_id}_#{ndx}/ }.present?\n result\n end", "def file_content_match?\n @fixture.full_files.zip(@local.full_files).all? do |fixture_file, local_file|\n if File.directory?(fixture_file)\n File.directory?(local_file)\n else\n !File.directory?(local_file) && IO.read(fixture_file) == IO.read(local_file)\n end\n end\n end", "def album_add_photo(photo_data, photo_file)\n \n if album \n album.add_or_update_photo(photo_data, photo_file) \n end\n\n end", "def uploaded?(uploaded_file)\n uploaded_file.storage_key == storage_key.to_s\n end", "def media_file_exist?(name)\n expaned_path =\n File.join(Media.media_path, name.gsub(/img\\//, ''))\n File.exist?(expaned_path) and name\n end", "def dirty?(fo, fd)\n (fo.sha1 == fd.sha1 and fo.perms == fd.perms) == false ? true : false\n end", "def name\n albums = tracks.map{|t| t.album}.compact\n albums.uniq.size == 1 and albums.first\n end", "def unique_song?(song)\n @queue.each do |song_from_queue|\n if song_from_queue.url == song.url\n respond('I have this track loaded. Slap it with a `repeat` to play it more.')\n return false\n end\n end\n true\n end", "def any_pix?\r\n pictures.detect { |x| x && !x.photo_file_name.nil? }\r\n end", "def quick_compare(another)\n self == another || (self.kind_of?(File) && another.kind_of?(File) && self.path == another.path)\n end", "def exists?\n # self.class.exists?(:filename => filename)\n 'CarrierWave::Storage::ActiveRecord::File#exists? FIXME!'\n end", "def identical?\n #Song.first.attributes.each { |v,k| Song.find(:all, :conditions => [\" #{v} like ?\", \"%blah%\"])}\n Song.find(:all, :conditions => [\"name = ? or length = ?\", \"#{self.name}\", self.length]) do |x| \n x.hash == self.hash\n end\n end", "def fexistf(fname)\n return $fframes.include? fname\nend", "def exists\n if @file && @mp3\n return true\n else\n return false\n end\n end", "def any_pix?\n pictures.detect { |x| x && !x.photo_file_name.nil? }\n end", "def has_local_match?(files)\n files.each do |file|\n return true if self.drive_path == file.sub_path\n end\n false\n end" ]
[ "0.692624", "0.6680751", "0.6680751", "0.6680751", "0.65596867", "0.65364087", "0.64193106", "0.6240499", "0.6178675", "0.61408794", "0.61218715", "0.6101617", "0.6097256", "0.6086178", "0.60632247", "0.5990265", "0.59662616", "0.5950601", "0.59047174", "0.59040934", "0.58802974", "0.58729625", "0.5848124", "0.5848124", "0.5823888", "0.58227074", "0.5820171", "0.5808317", "0.5797858", "0.57951677", "0.5764775", "0.57540005", "0.57342345", "0.5732589", "0.5693757", "0.56860185", "0.56748295", "0.5641386", "0.5619923", "0.55935615", "0.5592936", "0.55912524", "0.55886626", "0.55818594", "0.55807173", "0.55783165", "0.55684125", "0.5559183", "0.5550696", "0.5513811", "0.55037946", "0.5499808", "0.5495118", "0.5491364", "0.5466473", "0.5463063", "0.5462929", "0.5459288", "0.54508704", "0.54432684", "0.54374486", "0.54260767", "0.53820145", "0.537789", "0.537264", "0.537264", "0.53719115", "0.53633285", "0.5363004", "0.53580827", "0.53558654", "0.5343734", "0.5339786", "0.533925", "0.53382194", "0.53382194", "0.533609", "0.5331309", "0.53307176", "0.53242147", "0.53217155", "0.53152394", "0.529863", "0.52916396", "0.528898", "0.52883196", "0.52880895", "0.5287365", "0.5285017", "0.5281517", "0.5280827", "0.52802974", "0.52801555", "0.52797717", "0.5264926", "0.5264271", "0.5263698", "0.5258228", "0.5256132", "0.52538884" ]
0.82081425
0
Enlace que se muestra solo si el usuario ha ingresado al sistema
def link_usuario(titulo, enlace) link_to titulo, enlace if not session[:usuario] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def inicio_sesion?\n usuario_id.blank?\n end", "def logado?\n !current_user.nil?\n end", "def ha_accedido?\n\t\t!usuario_actual.nil?\n\tend", "def isRegistado?\n if session[:perm] == 0\n return true;\n else\n return false;\n end\n end", "def exibe_para_usuario?\n \t\tif usuario_signed_in?\n \t\t\tif current_usuario.admin?\n \t\t\t\treturn true\n \t\t\telse\n \t\t\t\treturn false\n \t\t\tend\n \t\telse\n \t\t\treturn false\n \t\tend\n \tend", "def verificar_autenticado_admin\n unless session[:usuario_admin] #else if,tiene quer ser falso\n bitacora \"Intento de accceso sin autenticacion a la zona del admin\"\n flash[:error]=\"Debe autenticarse como Administrador\"\n redirect_to :action => \"index\" , :controller => \"externo\"\n return false\n end\n end", "def user_have\n unless current_user\n redirect_to root_path, :alert => \"Зарегистрируйтесь или войдите\"\n end\n end", "def logado?\n !admin_atual.nil?\n end", "def logged_in?\n #Dependiendo de lo que regrese current_user\n if current_user\n #Regresa true si el usuario existe\n true\n else\n #Si no existe regresa false\n false\n end\n end", "def login_disponible(login)\n usuario = UsuarioService.new.listar_usuario(login)\n usuario.nil?\n end", "def registered(user)\n self.rsvped?(user) || self.isHost?(user)\n end", "def admin_logado?\n !!admin_logado\n end", "def hasuser? username\n\t\t@cf.usermanager.user? username\t\t\n\tend", "def revisar_usuario\n if session[:usuario].empty?\n flash[:notice] = \"Debe loguearsar para poder seguir\"\n redirect_to \"/login\"\n end\n end", "def existe_usuario_logeado?\n @usuarios.any? {|usuario| usuario.logeado}\n end", "def logged_in?\n \t#devuelve un booleano para saber si hay un usuario loggeado o no. \n \t#para eso sirven los dos signos de exclamacion !!\n \t!!usuario_actual\n end", "def system?\n id == User::SYSTEM_USER_ID\n end", "def system?\n id == User::SYSTEM_USER_ID\n end", "def not_host_already\n if host_user?(current_user) || current_user.nil?\n redirect_to(root_path)\n end\n end", "def logged_in?\n !current_utente.nil?\n end", "def comprobar_usuario_login\n @usuario_actual=nil\n return unless session[:user_id]\n @usuario_actual = Usuario.find_by_id(session[:user_id])\n end", "def user_login?\n\t\treval = user_info[:uid] > 0 ? true : false\n\t\tif reval\n\t\t\tuser_session_update user_info[:sid], user_info[:uid]\n\t\tend\n\t\treval\n\tend", "def usuario_actual?(usuario)\n\t\tusuario == usuario_actual\n\tend", "def active_for_authentication?\n super && bloqueado == 0\n end", "def cas_authed?\n !session[:cas_user].blank?\n end", "def current_user_exists?\n return false if config.current_user.nil?\n return true\n end", "def is_potential_user?\n\t\ttrue\n\tend", "def needs_login?() false end", "def check_user\n\n redirect_to root_path if current_user == nil\n if current_user \n redirect_to root_path if current_user.vendor == false\n end\n end", "def ingreso\n\t\t@titulo = \"Ingreso al portal\"\n\t\treset_session\n\t\tif params[:id] && params[:token]\n\t\t\tid = params[:id]\n\t\t\ttoken = params[:token]\n\t\t\tif __es_numero_entero?(id) && __es_token?(token)\n\t\t\t\tif @usuario = Usuario.validar_token(id,token)\n\t\t\t\t\tif @usuario.activo == 0\n\t\t\t\t\t\tbitacora \"Ingreso correcto al sistema para el usuario con id #{params[:id]} y token #{params[:token]}\"\n\t\t\t\t\t\treturn\n\t\t\t\t\telse\n\t\t\t\t\t\tflash[:error] = \"Disculpe, pero su usuario ya se encuentra activo.\"\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\n\t\tbitacora \"Intento fallido de ingreso al sistema con id #{params[:id]} y token #{params[:token]}\"\n\t\tredirect_to :action => \"index\", :controller => \"inicio\"\n\tend", "def service_is_nuniverse?(params = {})\n\t\tif params[:service]\n\t\t\t@user = User.find(:first, :conditions => ['login = ?', params[:service]] )\n\t\tend\n\t\treturn false if !@user.nil? && @user.role == \"service\"\n\t\treturn true\n\tend", "def is_user?\ncurrent_user.username == @userl.username\n end", "def registered?\n !guest?\n end", "def currentUserExists?\n # Get the current user.\n user = User.get(:current)\n \n # Check it exists.\n return User.exists?(user[\"id\"])\n rescue ActiveResource::UnauthorizedAccess\n @error = \"User unauthorized.\"\n return false\n rescue ActiveResource::ClientError => e\n @error = e.message\n return false\n rescue ActiveResource::ConnectionError => e\n @error = e.message\n return false\n rescue Errno::ECONNREFUSED => e\n @error = \"Unable to connect to #{@site}\"\n return false\n end", "def checkCurrentUserEmployee(empleado)\n \t\tif current_user.empleado_id == empleado.id\n \t\t\treturn true\n \t\tend\n \tend", "def requires_user_existence!\n if not e.user_exists?\n error \"You have to setup your user before you can perform this action.\"\n exit\n end\n end", "def to_already_logged_in?\n return if already_logged_in?\n end", "def dummy_user?\n (user_id.split('/').first == 'gofreerev')\n end", "def dummy_user?\n (user_id.split('/').first == 'gofreerev')\n end", "def usuario_actual\n \t#se guarda al usuario actual que esta loggeado por cuestion de eficiencia\n \t#para no accesar a la base de datos todo el tiempo\n \t@usuario_actual ||= Alumno.find(session[:alumno_id]) if session[:alumno_id]\n end", "def user_admin?\n \t@admin_user = Usuario.find(session[:user_id]).admin\n end", "def logged_in?\n \t#devuelve un booleano para saber si hay un usuario loggeado o no. \n \t#para eso sirven los dos signos de exclamacion !!\n \t!!current_user\n end", "def shadow_user?\n return !session[:shadow_user_id].blank?\n end", "def require_user\n unless logged_in?\n store_target_location\n flash[:notice] = \"Debe iniciar sesion para poder acceder a esta pagina\"\n redirect_to login_url\n return false\n end\n true\n end", "def user\n\t\tfalse\n\tend", "def user_login?\n\t !!current_user\n\tend", "def DispatchManager?\n\t\tif KitchenUser.find(session[:kitchen_user_id]).role.name ==\"Dispatch Manager\" \n true\n end\n\tend", "def ensure_cas_user_exists\n unless (User.all.map(&:username)).include? session[:cas_user]\n flash[:error] = \"You must be a registered user of Agi\"\n redirect_to projects_path\n end\n end", "def is_organizer\n \t@event = Event.find(params[:id])\n \tputs \"*\"*1000\n \tif current_user != @event.organizer && current_user.is_admin == false\n \t\tflash[:error] = \"Vous n'avez pas l'autorisation d'etre ici !\"\n \t\tredirect_to event_path\n \tend\n end", "def solo_perfilados\n redirect_to root_path if current_user.perfilado !=true\n end", "def exec_granted?(controler, xllave)\n\t\tauth = Execremotekey.where(\"controler= '#{controler}' AND llave = '#{xllave}' \").first\n\t\tif auth == nil\n\t\t\tredirect_to noautorizado_url, notice: \"No esta autorizado a entrar a esta opcion\"\n\t\t\tfalse\n\t\telse\n\t\t\tauth.delete #para que no se reutilice la misma validacion\n\t\t\ttrue\n\t\tend\n\tend", "def has_user?\n !user.nil?\n end", "def first_login\n if !current_user.adm? && (!current_user.last_name.present? || !current_user.email.present? || \n !current_user.job.present? || !current_user.cpf.present? || current_user.email == (0...6).map { ('a'..'z').to_a[rand(26)] }.join+\"@facebook.com\") \n redirect_to edit_user_path(current_user)\n flash[:info] = \"Complete seu cadastro!\"\n \n if !current_user.last_name.present?\n flash[:info] = \"Sobrenome não registrado.\"\n end\n \n if !current_user.email.present?\n flash[:info] = \"Email não registrado.\"\n end\n \n if !current_user.job.present?\n flash[:info] = \"Trabalho não registrado.\"\n end\n \n if !current_user.cpf.present?\n flash[:info] = \"CPF não registrado.\"\n end\n \n if current_user.email == (0...6).map { ('a'..'z').to_a[rand(26)] }.join+\"@facebook.com\"\n flash[:info] = \"Registre o seu email.\"\n end\n end\n end", "def update?\n if user.role == \"Recepção\" || user.admin?\n true\n elsif (user.role == \"Envio\" || user.role == \"Cadastro\") && user.institution == record.sender.institution\n true\n else\n false\n end\n end", "def verify_register_conclusion\n if !@user.face_confirmed?\n flash[:notice] = \"Insira um e-mail pessoal para receber nossos avisos.\"\n redirect_to email_completar_path\n return false\n end\n if !@user.is_completed?\n flash[:notice] = \"Conclua sua inscrição para acessar todas as funções do sistema\"\n #flash[:notice] = \"Não é possível finalizar seu cadastro. Aguarde até o dia 20 para se inscrever novamente!\"\n redirect_to cadastro_completar_path\n return false\n end\n end", "def reenviar_usuario\n @bandera = false\n if user_signed_in?\n unless current_user.employee.nil?\n @permiso_reenviar_usuario = false\n @security_role_type = Security::RoleType.find_by(name: \"Reenviar Usuario\").name\n current_user.employee.security_profile.security_role.security_role_menus.each do |security_role_menu| \n if security_role_menu.security_menu.controller == params[:controller] \n security_role_menu.security_role_type_menus.each do |role_type|\n if @security_role_type == role_type.security_role_type.name\n @permiso_reenviar_usuario = true\n break\n elsif role_type.security_role_type.name == \"Consultar\"\n @bandera = true\n end\n end\n end\n end\n if current_user.username == \"aadmin\"\n @permiso_reenviar_usuario = true\n end\n if @bandera == true\n elsif params[:action] == \"forget_username_list\" && @permiso_reenviar_usuario == false\n redirect_to root_path\n end\n return @permiso_reenviar_usuario\n end\n end\n end", "def user_exists?\n \t\tself.errors.add(:name, \"does not exist!\") unless self.user_id.present?\n \tend", "def check_user_background\n self.status = Status::PENDING_ADMIN_ACTION if offender && offender.new_user?\n end", "def require_no_user\n if current_user\n store_target_location\n flash[:notice] = \"Debe iniciar sesion para poder acceder a esta pagina\"\n redirect_to login_url\n return false\n end\n end", "def is_registered?\n # keep track of where we are: if no password in db\n # it means we still are at the registration step\n\n # Note that we use the \"_was\" suffix here (AR::Dirty) to check\n # the value of the field before the update\n !crypted_password_was.blank?\n end", "def check_saas\n @ok = (SETTINGS['saas_registration_mode'] && current_user.super_admin?)\n end", "def check_owner_user\n @guild = Guild.find(@invite[:guild_id])\n if self.admin?\n return 1\n end\n return (@guild[:owner_id] == session[:user_id]) ? 1 : nil\n end", "def impersonating_user?\n !session[ImpersonateController::IMPERSONATE_USER_PARAM].nil?\n end", "def impersonating_user?\n !session[ImpersonateController::IMPERSONATE_USER_PARAM].nil?\n end", "def validate_usuario\n if current_usuario.tipo!='Administrador' || !current_usuario.activo\n redirect_to root_path\n end\n end", "def reg_only!\n\tif !current_user || current_user.pro || current_user.administrator\n\t\tredirect \"/\"\n\tend\nend", "def user_present(host, username)\n case host['platform']\n when /eos/\n on(host, \"useradd #{username}\")\n else\n host.user_present(username)\n end\n end", "def revisa_conectado\n unless conectado?\n redirect_to root_path\n end\n end", "def logged_in_normal_user?\n normal_user.present?\n end", "def pide_login\n if !logado\n redirect_to login_path,:notice=>'Se requiere usuario y clave'\n\t end\n end", "def check_necessity\n User.any? and redirect_to root_path\n end", "def check_user\n if self.admin?\n return 1\n end\n return (session[:user_id] && User.find(session[:user_id])) ? 1 : nil\n end", "def es_propietario\n set_entrega\n if @entrega.recolector != current_user\n render json: {entrega: [\"No permitido para este usuario\"]}, status:401\n end\n end", "def user_present?\n current_user.present?\n end", "def user_is_current\n fetch_user\n\n unless current_user?(@user)\n flash[:error] = t(:not_authorized)\n redirect_to root_path\n end\n end", "def exists?(name)\n find_user(name)&.size != 0\n end", "def appHelper_ifUserLogged\n if session[:user_name] \n return true\n end\n return false\n end", "def check_user_info_initialized\n exists = UserInfo.exists?(current_user.id)\n create = controller_name == 'user_infos' && %w(new create).include?(action_name)\n if exists && create\n redirect_to(user_info_path)\n elsif !exists && !create\n flash[:notice] = \"Page will be available after filling in your information.\"\n redirect_to(new_user_info_path)\n end\n end", "def admin?\n return false unless authenticated?\n User.exists?(cas_username: session['cas']['user'])\n end", "def check_owner\n return if params[:id].blank? or @login_user.nil?\n\n begin\n owner_id = Location.find(params[:id]).user_id\n rescue\n owner_id = -1\n end\n if !@login_user.admin?(User::AUTH_LOCATION) and owner_id != @login_user.id\n Log.add_check(request, '[check_owner]'+request.to_s)\n\n flash[:notice] = t('msg.need_to_be_owner')\n redirect_to(:controller => 'desktop', :action => 'show')\n end\n end", "def Usuario_noLogueado\n redirect_to(root_url) unless logged_in?\n end", "def create?\n user.role == \"Envio\" || user.role == \"Cadastro\" || user.admin?\n end", "def ensure_user\n current_user? || deny_access('You must be logged in to perform this action.')\n end", "def verificar_session\n unless session[:usuario] and session[:usuario][:tipo] == 'admin'\n redirect_to \"/\"\n end\n end", "def user_check(resource)\n return true unless self[:name] == \"user\"\n return true unless self[:unless_system_user]\n\n resource[:audit] = :uid\n\n return false if system_users.include?(resource[:name])\n\n current_values = resource.retrieve_resource\n current_values[resource.property(:uid)] > self[:unless_system_user]\n end", "def check_user\n if (!user_signed_in?)\n redirect_to root_path, notice: 'You must log in to do that'\n end\n # if (!current_user.superadmin_role)\n # redirect_to root_path, notice: 'You do not have permissions to do that'\n # end\n end", "def loguear\n\t\tif !(verificaUsuario)\n\t\t\tif verificaPass\n\t\t\t\treturn \"correcto\" #Si puede loguearse\n\t\t\telse\n\t\t\t\treturn \"passincorrecto\" #no puede loguearse por que la contrasena no es correcta\n\t\t\tend\n\t\telse\n\t\t\treturn \"usuarioincorrecto\" #no puede loguearse por que el usuario no existe\n\t\tend\n\tend", "def manager_logged_in?\n !session[:manager_id].nil?\n end", "def user_is_old? user\n return user.logins_number > 1\n end", "def one_user_registered?\n if User.count == 1\n if user_signed_in?\n redirect_to root_path\n else\n redirect_to new_user_session_path\n end\n end \n end", "def apresentacao\n if @permissao === \"convidado\"\n puts \"o usuário selecionado possui a permissao de Convidado\"\n end\n if @permissao === \"autenticado\"\n puts \"o usuário selecionado possui a permissao de Autenticado\"\n end\n if @permissao === \"admin\"\n puts \"o usuário selecionado possui a permissao de Admin\"\n end\n end", "def check_if_user_has_company\n if @user_company.nil?\n else\n redirect_to root_path\n flash[:danger] = I18n.t 'flash.access_deny_text'\n end\n end", "def verificar_permiso\n if user_signed_in?\n unless current_user.employee.nil?\n @existe_permiso = false\n current_user.employee.security_profile.security_role.security_role_menus.each do |security_role_menu|\n if security_role_menu.security_menu.controller == params[:controller] \n @existe_permiso = true\n break\n elsif params[:controller] == \"service/services\" and session[:atender] == true\n @existe_permiso = true\n end\n if params[:controller] == \"security/role_type_menus\" || params[:controller] == \"security/role_menus\"\n @existe_permiso = true\n end\n end\n if current_user.username == \"aadmin\"\n @existe_permiso = true\n end\n if @existe_permiso == false\n redirect_to root_path\n end\n end\n end\n end", "def check_if_current_user\r\n User.current_user && User.current_user != self\r\n end", "def Usuario_noAdmin\n redirect_to(root_url) if current_usuario.admin?\n end", "def check_user_logged\n if current_user.type_access == 'User'\n flash[:danger] = 'Voçê não tem permissão para acessar essa pagina!'\n redirect_to root_path\n end\n end", "def mine?\n user && user.username == Codeplane.username\n end", "def eventunscrape?\n @user.is_admin?\n end", "def super_user?\n user = check_user\n # user.email == 'vetswithoutborderstamu@gmail.com'\n user.email == 'bryalara@tamu.edu'\n end", "def user_logged_in_sin_hogar\n\n\t\t redirect_to new_direccion_path if logged_in? && !tiene_hogar?\n\n \tend", "def is_hem\n if current_user.id == Order.find(params[:id]).user_id\n\n else\n redirect_to home_path\n end\n end" ]
[ "0.7026107", "0.69358766", "0.6930118", "0.688014", "0.6853501", "0.6839029", "0.67581594", "0.67500573", "0.67414856", "0.6644328", "0.6589127", "0.65551716", "0.65409815", "0.6535649", "0.6525826", "0.651072", "0.650614", "0.650614", "0.6461955", "0.6448556", "0.6428166", "0.63711923", "0.6362654", "0.6300468", "0.6257919", "0.6251162", "0.62425876", "0.6233627", "0.623282", "0.62235063", "0.62159073", "0.62020797", "0.61971074", "0.619593", "0.6175501", "0.61665237", "0.61518794", "0.6151194", "0.6151194", "0.6146319", "0.61351246", "0.61244965", "0.6118149", "0.6111904", "0.61080134", "0.6103901", "0.6095758", "0.60939753", "0.60886914", "0.6083398", "0.6083256", "0.60797817", "0.6072684", "0.6060053", "0.60584664", "0.60573775", "0.605713", "0.60557103", "0.60483646", "0.6038864", "0.6038584", "0.60270363", "0.6020912", "0.6020912", "0.6020568", "0.60079044", "0.59993035", "0.59959036", "0.5992844", "0.59853804", "0.5980355", "0.59787613", "0.5974355", "0.5968715", "0.59662384", "0.59619", "0.59605265", "0.5956843", "0.59544104", "0.59517854", "0.59497523", "0.5949052", "0.5947826", "0.5941654", "0.59399027", "0.5938913", "0.5932428", "0.59270275", "0.5921905", "0.5920907", "0.59190965", "0.59108615", "0.5908357", "0.5905575", "0.590391", "0.590239", "0.5902344", "0.5900924", "0.5900625", "0.59002316", "0.58939993" ]
0.0
-1
Enlace que se muestra solo si no hay un usuario logueado
def link_anonimo(titulo, enlace) link_to titulo, enlace if session[:usuario] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def logado?\n !current_user.nil?\n end", "def logado?\n !admin_atual.nil?\n end", "def inicio_sesion?\n usuario_id.blank?\n end", "def revisar_usuario\n if session[:usuario].empty?\n flash[:notice] = \"Debe loguearsar para poder seguir\"\n redirect_to \"/login\"\n end\n end", "def comprobar_usuario_login\n @usuario_actual=nil\n return unless session[:user_id]\n @usuario_actual = Usuario.find_by_id(session[:user_id])\n end", "def login_disponible(login)\n usuario = UsuarioService.new.listar_usuario(login)\n usuario.nil?\n end", "def ha_accedido?\n\t\t!usuario_actual.nil?\n\tend", "def logged_in?\n \t#devuelve un booleano para saber si hay un usuario loggeado o no. \n \t#para eso sirven los dos signos de exclamacion !!\n \t!!usuario_actual\n end", "def exibe_para_usuario?\n \t\tif usuario_signed_in?\n \t\t\tif current_usuario.admin?\n \t\t\t\treturn true\n \t\t\telse\n \t\t\t\treturn false\n \t\t\tend\n \t\telse\n \t\t\treturn false\n \t\tend\n \tend", "def logged_in?\n !current_utente.nil?\n end", "def logged_in?\n #Dependiendo de lo que regrese current_user\n if current_user\n #Regresa true si el usuario existe\n true\n else\n #Si no existe regresa false\n false\n end\n end", "def user_have\n unless current_user\n redirect_to root_path, :alert => \"Зарегистрируйтесь или войдите\"\n end\n end", "def Usuario_noLogueado\n redirect_to(root_url) unless logged_in?\n end", "def pide_login\n if !logado\n redirect_to login_path,:notice=>'Se requiere usuario y clave'\n\t end\n end", "def verificar_autenticado_admin\n unless session[:usuario_admin] #else if,tiene quer ser falso\n bitacora \"Intento de accceso sin autenticacion a la zona del admin\"\n flash[:error]=\"Debe autenticarse como Administrador\"\n redirect_to :action => \"index\" , :controller => \"externo\"\n return false\n end\n end", "def first_login\n if !current_user.adm? && (!current_user.last_name.present? || !current_user.email.present? || \n !current_user.job.present? || !current_user.cpf.present? || current_user.email == (0...6).map { ('a'..'z').to_a[rand(26)] }.join+\"@facebook.com\") \n redirect_to edit_user_path(current_user)\n flash[:info] = \"Complete seu cadastro!\"\n \n if !current_user.last_name.present?\n flash[:info] = \"Sobrenome não registrado.\"\n end\n \n if !current_user.email.present?\n flash[:info] = \"Email não registrado.\"\n end\n \n if !current_user.job.present?\n flash[:info] = \"Trabalho não registrado.\"\n end\n \n if !current_user.cpf.present?\n flash[:info] = \"CPF não registrado.\"\n end\n \n if current_user.email == (0...6).map { ('a'..'z').to_a[rand(26)] }.join+\"@facebook.com\"\n flash[:info] = \"Registre o seu email.\"\n end\n end\n end", "def needs_login?() false end", "def admin_logado?\n !!admin_logado\n end", "def loguear\n\t\tif !(verificaUsuario)\n\t\t\tif verificaPass\n\t\t\t\treturn \"correcto\" #Si puede loguearse\n\t\t\telse\n\t\t\t\treturn \"passincorrecto\" #no puede loguearse por que la contrasena no es correcta\n\t\t\tend\n\t\telse\n\t\t\treturn \"usuarioincorrecto\" #no puede loguearse por que el usuario no existe\n\t\tend\n\tend", "def usuario_actual?(usuario)\n\t\tusuario == usuario_actual\n\tend", "def user_login?\n\t\treval = user_info[:uid] > 0 ? true : false\n\t\tif reval\n\t\t\tuser_session_update user_info[:sid], user_info[:uid]\n\t\tend\n\t\treval\n\tend", "def to_already_logged_in?\n return if already_logged_in?\n end", "def solo_perfilados\n redirect_to root_path if current_user.perfilado !=true\n end", "def user_login?\n\t !!current_user\n\tend", "def no_login(user)\n # nada\n end", "def existe_usuario_logeado?\n @usuarios.any? {|usuario| usuario.logeado}\n end", "def logged_in?\n \t#devuelve un booleano para saber si hay un usuario loggeado o no. \n \t#para eso sirven los dos signos de exclamacion !!\n \t!!current_user\n end", "def check_if_login_required\n false\n end", "def user_logged?\n !session[:user_id].nil?\n end", "def no_log_show\n if !session[:user_id]\n flash[:notice] = \"Please log in or sign up!\"\n redirect_to root_path\n end\n end", "def is_user?\ncurrent_user.username == @userl.username\n end", "def usuario_actual\n \t#se guarda al usuario actual que esta loggeado por cuestion de eficiencia\n \t#para no accesar a la base de datos todo el tiempo\n \t@usuario_actual ||= Alumno.find(session[:alumno_id]) if session[:alumno_id]\n end", "def check_unlogin\n return unless curr_user\n redirect_to articles_path\n end", "def users_only\n deny_access(\"Necesitas crear una cuenta para entrar a esta sección\") unless signed_in?\n end", "def ensure_no_user\n !current_user? || redirect_back_or_default\n end", "def fully_authed?\n !(user.nil? || password.nil?)\n end", "def my_login_required\n login_required unless User.count==0\n end", "def check_login\n if !session[:user_name]\n redirect_to sign_in_path\n end\n end", "def is_login?\n !session[:user_id].nil?\n end", "def logged_in\n logged_in_user != nil\n end", "def usuario_correcto\n @user = User.find(params[:id])\n redirect_to(root_url) unless usuario_actual?(@user)\n end", "def require_no_user\n if current_user\n store_target_location\n flash[:notice] = \"Debe iniciar sesion para poder acceder a esta pagina\"\n redirect_to login_url\n return false\n end\n end", "def login_required\n return true unless session[:user_id].blank?\n return false\n end", "def logged_in_normal_user?\n normal_user.present?\n end", "def not_host_already\n if host_user?(current_user) || current_user.nil?\n redirect_to(root_path)\n end\n end", "def correct_user\n @user = User.find(params[:id])\n redirect_to(users_path,:notice =>'Accés non autorisé') unless( current_user?(@user)|| current_user.is_admin?)\n end", "def cas_authed?\n !session[:cas_user].blank?\n end", "def check_user_logged\n if current_user.type_access == 'User'\n flash[:danger] = 'Voçê não tem permissão para acessar essa pagina!'\n redirect_to root_path\n end\n end", "def validate_usuario\n if current_usuario.tipo!='Administrador' || !current_usuario.activo\n redirect_to root_path\n end\n end", "def check_necessity\n User.any? and redirect_to root_path\n end", "def dummy_user?\n (user_id.split('/').first == 'gofreerev')\n end", "def dummy_user?\n (user_id.split('/').first == 'gofreerev')\n end", "def control_usuario \n usuarios = Usuario.all\n usuarios.each do |u|\n if cuentum_signed_in? && current_cuentum.id == u.cuenta_id\n if u.rol == \"USUARIO\" \n redirect_to \"welcome/index\" \n end\n end\n end\n end", "def control_usuario \n usuarios = Usuario.all\n usuarios.each do |u|\n if cuentum_signed_in? && current_cuentum.id == u.cuenta_id\n if u.rol == \"USUARIO\" \n redirect_to \"welcome/index\" \n end\n end\n end\n end", "def require_no_authentication\n if professor_signed_in? && current_professor.email.to_s == \"root@hanyang.ac.kr\"\n return true#redirect_to new_professor_session_path, notice: \"루트 만이 관리자 계정을 만들 수 있습니다.\"\n else\n return super\n end\n end", "def check_user_id_presence\n if helpers.user_id.nil?\n cookies.encrypted.permanent[:user_id] = SecureRandom.hex\n helpers.initial_setup\n render 'welcome'\n end\n end", "def current_user? user\n if user == nil\n false\n elsif self.username == user.username\n true\n elsif\n false\n end\n end", "def isRegistado?\n if session[:perm] == 0\n return true;\n else\n return false;\n end\n end", "def verificar_session\n unless session[:usuario] and session[:usuario][:tipo] == 'admin'\n redirect_to \"/\"\n end\n end", "def require_login?\n !(Jiralicious.username.empty? && Jiralicious.password.empty?) && !alive?\n end", "def _is_login\n p session[:user]\n session[:user] ? true : false\n end", "def check_user\n if (!user_signed_in?)\n redirect_to root_path, notice: 'You must log in to do that'\n end\n # if (!current_user.superadmin_role)\n # redirect_to root_path, notice: 'You do not have permissions to do that'\n # end\n end", "def is_logged?\n if session[:clinica_id].nil?\n redirect_to root_url, :alert => \"Voce nao esta logado\"\n end\n end", "def correct_user\n @usuario = Usuario.find(params[:id])\n redirect_to(root_url) unless current_user?(@usuario)\n end", "def hasuser? username\n\t\t@cf.usermanager.user? username\t\t\n\tend", "def require_user\n unless logged_in?\n store_target_location\n flash[:notice] = \"Debe iniciar sesion para poder acceder a esta pagina\"\n redirect_to login_url\n return false\n end\n true\n end", "def loggedin?\n not session[:userid].nil?\nend", "def correсt_user\n @user = User.find(params[:id])\n redirect_to(root_path) unless (current_user?(@user) or is_admin?)\n\n end", "def current_account_has_username?\n logged_in? && current_account.username.present?\n end", "def loggedin?\n !(@auth=='' or @auth.nil?)\n end", "def usuario_correto\n @usuario = Usuario.find(params[:id])\n redirect_to(root_path) unless usuario_corrente?(@usuario)\n end", "def active_for_authentication?\n super && bloqueado == 0\n end", "def is_not_authenticated?\n # if yes, it is not nil.. else false\n session[:user].nil?\nend", "def redirecionar_usuario_logado\n if current_account != nil \n redirect_to accounts_url\n end\n end", "def user_authenticated?\n !session[:user_id].nil?\n end", "def check_for_login\n #if not, back home with you!\n redirect_to root_path unless @current_user.present?\n end", "def check_if_current_user\r\n User.current_user && User.current_user != self\r\n end", "def check_if_logged_in\n redirect_to(new_user_path) if @current_user.nil?\n end", "def check_if_logged_in\n redirect_to(new_user_path) if @current_user.nil?\n end", "def to_user_not_authenticated?\n return if user_not_authenticated?\n end", "def valida_usuario(correo, clave)\n data = Usuario.find_by(correo: correo, estado: ACTIVO, validado: VALIDADO)\n if data.blank?\n data1 = Usuario.find_by(correo: correo, estado: ACTIVO)\n if data1.blank? != true\n return [false, 'El usuario no ha sido validado, hágalo desde el mensaje que llego a su correo electrónico']\n else\n return [false, 'No existe usuario con ese correo electrónico']\n end\n else\n psw = data[:psw]\n clave_ing = crypttext(clave)\n res = psw <=> clave_ing\n if res == 0\n return [true, data]\n else\n return [false, 'contraseña incorrecta']\n end\n end\n end", "def check_login\n if (current_user.blank? or current_user.username.blank?) and !session[:user_id].blank? \n logger.error(\"logout occurred\")\n session[:user_id] = nil\n elsif session[:user_id].blank? and !current_user_model.blank? and !current_user.blank? \n session[:user_id] = current_user_model.id\n session[:user_id] = '1' if session[:user_id].blank?\n logger.error(\"login occurred\")\n log_request('login')\n end\n end", "def user_logged_in_sin_hogar\n\n\t\t redirect_to new_direccion_path if logged_in? && !tiene_hogar?\n\n \tend", "def logged_in?\n !real_user.nil?\n end", "def Usuario_noAdmin\n redirect_to(root_url) if current_usuario.admin?\n end", "def login_not_required\n false\n end", "def check_user\n if current_user.blank?\n puts\"false\"\n new_user_session_path\n else\n puts\"true\"\n end\n end", "def require_login\n !!current_user || access_denied\n end", "def revisa_conectado\n unless conectado?\n redirect_to root_path\n end\n end", "def logged_in?\n!current_user.nil?end", "def is_returning_user\n if cookies[:intervac_user].nil?\n return false\n end\n return true\n end", "def require_login\n end", "def cleared_required\n if current_user\n if current_user.cleared\n return\n end\n raise 'Du är ännu inte godkänd för att tippa.'\n end\n redirect_to \"/login\", notice: 'Logga in för att tippa.'\n end", "def authorize\n if current_user.nil? || current_user.tipo_usuario == \"Empleado\"\n redirect_to login_url, notice: \"No esta autorizado para ver esto. Por favor ingrese al sistema o reingrese como administrador.\"\n end\n end", "def verificar_session\n unless session[:estudiante] and session[:estudiante]#[:tipo] == 'admin'\n redirect_to \"/\"\n end\n end", "def logged_in_user\n unless logged_in?\n flash[:danger] = \"Você não está logado no sistema.\"\n redirect_to login_url\n end\n end", "def check_username\n @user=User.where('username=?',params[:username])\n @user=[] if user_signed_in? && @user && @user.first==current_user # this means they are editing their username and its themselves, that is ok\n end", "def logged_in_user\n unless logged_in?\n puts \"not logged in\"\n end\n end", "def ensure_user\n current_user? || deny_access('You must be logged in to perform this action.')\n end", "def no_blank(user)\n user.username != \"\" && user.username != nil\n user.password_digest != \"\" && user.password_digest != nil\n end", "def validate_username?\n @user = User.find_by username: self.usuario\n unless self.usuario == \"\"\n unless @user.nil? \n #Luego de que se verifica que el usuario si es usado, se pregunta si ese username pertenece al mismo\n #empleado que actualizara sus datos\n if self.usuario == self.user.username \n #si es el mismo username retorna true \n return true\n else\n #si es el mismo username retorna false \n errors.add(:usuario, :invalid)\n return false\n end\n else\n #no existe ningún usuario con este username que se intenta registrar\n return true\n end\n else\n errors.add(:usuario, \"Debe ingresar un usuario.\")\n return false\n end \n end" ]
[ "0.7750504", "0.73521215", "0.73299307", "0.71518093", "0.70934534", "0.7092077", "0.7082738", "0.7074484", "0.7066719", "0.70598406", "0.7052937", "0.7017047", "0.6973376", "0.69658285", "0.6925182", "0.6899391", "0.6810334", "0.67826337", "0.67476106", "0.67184323", "0.66960114", "0.6690745", "0.66895133", "0.6667772", "0.66421694", "0.6596872", "0.65903205", "0.6568828", "0.6564323", "0.65635586", "0.6537587", "0.6525965", "0.6524438", "0.6519162", "0.6517678", "0.64885753", "0.6470543", "0.64689606", "0.6453153", "0.64473677", "0.6442901", "0.64347523", "0.6407228", "0.6380061", "0.6373178", "0.6362168", "0.6361987", "0.6348484", "0.63458127", "0.6342939", "0.63429207", "0.63429207", "0.63315386", "0.63315386", "0.632987", "0.6312815", "0.63110065", "0.630307", "0.6300503", "0.62928367", "0.6284373", "0.6283229", "0.6283045", "0.6275182", "0.62679017", "0.62678504", "0.6261508", "0.6259066", "0.6259005", "0.62561154", "0.62406933", "0.62358254", "0.6232498", "0.6228025", "0.6226987", "0.6224595", "0.6220722", "0.6218946", "0.6218946", "0.6218169", "0.6218156", "0.6216221", "0.6214052", "0.6212729", "0.6212628", "0.6210177", "0.6209339", "0.62013865", "0.6190821", "0.6186606", "0.61757874", "0.6174665", "0.6173607", "0.6171524", "0.6166195", "0.61618716", "0.6161064", "0.6160162", "0.61573076", "0.6155809", "0.6155758" ]
0.0
-1
To invalidate token upon logout
def invalidate_token self.update_columns(auth_token: nil) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def logout\r\n self.update(token: nil) \r\n end", "def invalidate_token\n update_attribute(:token, nil)\n update_attribute(:token_created_at, Time.now)\n end", "def logout\n current_user.update(valid_jwt: false)\n end", "def invalidate_token\n self.update_columns(auth_token: nil)\n end", "def logout\n RefreshTokenOperation::RevokeRefreshToken.execute(current_user.id)\n\n # rubocop:disable Lint/UselessAssignment\n current_user = nil\n # rubocop:enable Lint/UselessAssignment\n reset_session\n\n { success: true }\n end", "def invalidate_auth_token\n self.update_columns(auth_token: nil)\n end", "def invalidate_auth_token\n self.update_columns(auth_token: nil)\n end", "def logout\n current_user.reset_session_token\n session[:session_token] = nil\n end", "def log_out\n current_user\n @current_user.auth_token = nil\n @current_user.save!\n @current_user = nil\n end", "def sign_out\n return unless current_user\n current_user.update_attribute(:session_token, nil)\n session.delete(:token)\n end", "def logout_internal\n self.current_user.forget_me if logged_in?\n reset_session\n cookies.delete :auth_token\n end", "def logout\n auth_token = request.headers['Authorization']\n if auth_token == nil\n \n auth_token = params[\"Authorization\"]\n end\n\t#if there is no token then you cant logout\n if auth_token == nil\n return json_response({message: \"Invalid token\", status_code: '422'})\n end\n is_token_valid = JsonWebToken.decode(auth_token)\n \n result = JsonWebToken.invalidate(auth_token)\n \n if result != nil\n respose = json_response({message: \"You have succesfully logged out...\", status_code: result})\n else\n response = json_response({message: \"Something went wrong...\", status_code: '422'})\n end\n \n return response\n end", "def logout!\n current_user.reset_session_token! unless current_user.nil?\n session[:session_token] = nil\n @current_user = nil\n end", "def logout\n current_user.reset_session_token!\n session[:session_token] = nil\n end", "def expire_tokens!\n update_tokens(nil)\n end", "def logout_user\n cookies.delete(:auth_token)\n end", "def log_out_api\n current_user_api.update_attribute(:user_token, nil)\n end", "def refreshToken\n # is there a token? (and is it's timestamp not older than 24h?)\n if @token.nil? or @tokenTimeStamp < Time.now - 86400\n @token = getToken(@email,@password)\n @tokenTimeStamp = Time.now\n end\n end", "def destroy_session_token!\n update_attribute(:session_token, nil)\n end", "def invalidate_token(user)\n user.renew_token\n user.save\n end", "def destroy\n self.current_person.forget_me if logged_in?\n cookies.delete :auth_token\n reset_session\n flash[:notice] = t('sessions.destroy.logged_out')\n redirect_to login_path\n end", "def token\n #@user = User.where(:id => params[:user_id]).first\n #@user.reset_authentication_token!\n redirect_to edit_user_registration_path(@user)\n end", "def token\n refresh_token! if token_expired?\n super\n end", "def clear_session\n session.delete(:token)\n redirect to('/')\n end", "def reset_token\r\n authentication_token true\r\n end", "def log_out\n current_user.reset_session_token!\n session[:session_token] = nil\n end", "def logout\n session_delete\n @token = ''\n @seqid = 0\n auth_header\n end", "def logout(token)\n request(\n __method__,\n :post,\n \"#{api_base}/auth/logout\",\n nil,\n Authorization: token\n )\n end", "def logout(token)\n request(\n __method__,\n :post,\n \"#{api_base}/auth/logout\",\n nil,\n Authorization: token\n )\n end", "def destroy\n self.current_user.forget_me if logged_in?\n cookies.delete :auth_token\n reset_session\n flash[:notice] = \"You have been logged out.\"\n redirect_back_or_default\n end", "def reset_auth_token!\n reset_auth_token\n save(:validate => false)\n end", "def invalidate_all_sessions!\n update(session_token: SecureRandom.hex)\n end", "def clear_expired_tokens\n access_tokens.where(\"token_expire < ?\", Time.now).destroy_all\n end", "def clear_expired_tokens\n access_tokens.where(\"token_expire < ?\", Time.now).destroy_all\n end", "def reset_auth_token\n self.auth_token = generate_token(:auth_token)\n end", "def destroy\n current_user.remove_token\n render json: { status: :success, data: 'Successfully signed out' }\n end", "def logout(token)\n return nil unless token.present?\n u_object = retrieve_storage_key(token.to_sym)\n u_object.disable_authentication_controls if u_object.present?\n end", "def refresh_auth_token\n generate_token(:auth_token)\n save!\n end", "def destroy\n # Delete the user access tokens on logout\n User.find(session[:user_id]).delete\n # Delete the session as well\n session = {}\n \n redirect_to root_path\n end", "def destroy\n destroy = REDIS_LOGIN.del(\"token:#{headers[\"Access-Token\"]}\")\n if destroy == 1\n render json: { status: \"Logged out\" }, status: 200\n else\n render json: { error: \"Trouble logging out. Make sure the user isn't already logged out\" }, status: 200\n end\n end", "def reset_token!\n self.session_token = User.generate_session_token\n self.save!\n self.session_token\n end", "def revoke_token\n raise 'To be implemented in child classes'\n end", "def logout\n decoded_access_token = JWT.decode(params[:accessToken], 's3cr3t', true, algorithm: 'HS256')\n # Check if token was decoded\n if decoded_access_token\n @user = User.find_by(id: decoded_access_token[0]['user_id'])\n if @user # user exists\n # Invalidate their access token\n # Next time they try to access resources with their access token they will be denied\n Blacklist.find_by(jwt: params[:accessToken]).delete\n render json: {status: \"User was succesfully logged out\"}\n else\n render json: {error: \"Invalid User\"}\n end\n else # token is null\n render json: {error: \"Invalid Token\"}\n end\n end", "def logout\n session[:access_token] = nil\n session[:current_user] = nil\n flash[:notice] = \"Logged out\"\n redirect_to welcome_index_path\n end", "def revoke_oauth_token\n current_user.revoke_token\n end", "def reset\n session.delete(:access_token)\n session.delete(:refresh_token)\n redirect('/auth/gowalla')\n end", "def log_out\n session.delete(:username)\n session.delete(:token)\n @current_user = nil\n end", "def sign_out\n @token.destroy\n render json: { message: 'Sign-out successfully' }, status: :ok\n end", "def logout!(options = {})\n session[:session_token] = session[:active_at] = nil\n end", "def destroy\n # expire auth token \n\t @user=User.where(:authentication_token=>params[:api_key]).first\n\t if @user.present?\n\t #@user.reset_authentication_token!\n token = Devise.friendly_token[0,20]\n unless @user.authentication_token == token\n @user.update_attributes(:authentication_token => token)\n end\n\t render :json => { :message => [\"Session deleted.\"], :success => true, :status => :ok}\n\t else\n\t\t respond_to do |format|\n format.json{ render :json => { :error => \"Api key is invalid.\" }}\n end\n\t end\n end", "def log_out\nforget(current_user)\nsession.delete(:user_id)\n@current_user = nil\n\nend", "def logout\n response = @session.delete\n @auth_token = nil\n @rest.default_headers = { 'Content-Type' => 'application/json' }\n response\n end", "def delete_cookie\n cookies.delete :auth_token\n end", "def deauthenticate\n token = params[:tok]\n if @user = Droom::User.find_by(authentication_token: token)\n @user.reset_session_id!\n @user.reset_authentication_token!\n render json: @user\n else\n head :unauthorized\n end\n end", "def forget\n self.remember_token = nil\n update_attribute(:remember_token_digest, nil)\n end", "def invalidate_token\n update_columns(token: nil)\n end", "def expire!\n token = nil\n save!\n end", "def destroy\n\t\tcookies.delete(:auth_token)\n\t\tredirect_to root_url\n\tend", "def forget\n update_attribute(:remember_token, nil)\n end", "def clear_reset_password_token; end", "def logout_with_remembrance!(options = {})\n logout_without_remembrance!\n if options[:forget]\n cookies.delete(:remembrance_token)\n end\n end", "def regenerate_auth_token\n self.auth_token = nil\n generate_token\n save!\n end", "def regenerate_auth_token\n self.auth_token = nil\n generate_token\n save!\n end", "def regenerate_token\n self.auth_token = nil\n generate_token\n save!\n end", "def sign_out\n token = AccessToken.find_by(access_token: @token)\n token.destroy unless token.nil?\n msg = { status: STATUS_SUCCESS, message: SUCCESS_MESSAGE }\n\n render json: msg\n end", "def log_out\n message = ''\n auth_token = params[:token]\n if auth_token.include?(':')\n user_id = auth_token.split(':').first\n user = User.where(id: user_id).first\n token = auth_token.split(':').last\n if user\n device = user.devices.find_by(token: token)\n if device && Devise.secure_compare(device.token, token)\n device.delete\n message = 'access revoked'\n sign_out(user)\n end\n end\n end\n render json: {message: message}\n end", "def mints_user_logout\r\n # Logout from mints\r\n # @mints_user.logout\r\n # Delete local cookie\r\n cookies.delete(:mints_user_session_token)\r\n end", "def token_reset\n current_owner.gen_api_token\n current_owner.save\n redirect_to \"/account\"\n end", "def logout\n self.current_user.forget_me if logged_in?\n cookies.delete :auth_token\n reset_session\n flash[:notice] = \"You have been logged out.\"\n redirect_back_or_default('/')\n #redirect_back_or_default(:controller => '/account', :action => 'index')\n end", "def clear_cookies\n \tcookies.delete(:auth_token)\n end", "def reset_session_token!\n self.session_token = User.generate_session_token\n self.save!\n self.session_token\n end", "def reset_authentication_token!\n reset_authentication_token\n save(:validate => false)\n end", "def sign_out\n if active_token = ActiveToken.find_by_device(current_device)\n active_token.destroy\n end\n end", "def logout\n logout!\n true\n rescue FmRest::V1::TokenSession::NoSessionTokenSet\n false\n end", "def refresh_token\n if remember_token?\n self.remember_token = make_token \n save(:validate => false) \n end\n end", "def invalidate_token\n self.update_columns(token: nil)\n end", "def invalidate_token\n self.update_columns(token: nil)\n end", "def revoke_token\n request @google + '/accounts/AuthSubRevokeToken'\n\n @session_token = false\n end", "def reset_session_token!\n self.session_token = User.generate_session_token\n self.save\n self.session_token\n end", "def sign_out\n reset_session\n end", "def refresh_token\n if remember_token?\n self.remember_token = self.class.make_token \n save(false) \n end\n end", "def sign_out\n send_request('sign_out', :delete) do |req|\n req.body = { auth_token: @auth_token }\n end\n end", "def log_out\n forget(current_user) #called from user.rb. it sets remember_token attribute to nil.\n session.delete(:user_id) #deletes session.\n @current_user = nil # new value of this instance variable.\n end", "def logout\n self.status = STATUS[:absent]\n self.logout_time = Time.zone.now\n self.access_token = nil\n self.expires = Time.zone.now.to_i - 60\n self.user_events.build(event_name: 'Logout', event_time: Time.zone.now)\n save\n end", "def invalidate_token\n \tupdate_columns(token: '')\n \ttouch(:token_created_at)\n \tend", "def log_out\n forget(current_user)\n session.delete(:user_id)\n # sessions.delete(:team_id)\n @current_user = nil\n # @current_team = nil\n\n end", "def log_out\n\t\t# current_user.delete_auth_token # won't work with curl, but html is good\n\t\tsession.delete(:user_id)\n\t\t@current_user = nil\n\tend", "def logout_by_token(did_token)\n issuer = token.get_issuer(did_token)\n logout_by_issuer(issuer)\n end", "def invalidate_token\n self.update_columns(token: nil)\n end", "def invalidate_token\n self.update_columns(token: nil)\n end", "def logout_user\n if Marty::User.current\n cookies.delete :autologin\n Marty::Token.delete_all([\"user_id = ?\", Marty::User.current.id]) unless\n Marty::Util.db_in_recovery?\n self.set_user(nil)\n end\n end", "def reset_session_token!\n self.update!(session_token: SecureRandom::urlsafe_base64)\n end", "def reset_session_token!\n self.session_token = self.class.generate_session_token\n self.save!\n self.session_token\n end", "def reset_session_token!\n self.session_token = self.class.generate_session_token\n self.save!\n self.session_token\n end", "def invalidate!\n self.active = false\n self.save!\n if controller\n cookies.delete(:user_session)\n end\n end", "def remove_token\n update(token: nil)\n end", "def sign_out\n logout\n end", "def log_out\n self.current_user = nil\n cookies.delete(:remember_token)\n end", "def reset\n reset_token\n end", "def log_out\n\tforget(current_user)\n\tsession.delete(:user_id)\n\t@current_user = nil\nend" ]
[ "0.8360604", "0.7862523", "0.77508974", "0.7671452", "0.7661084", "0.7619964", "0.7619964", "0.76088196", "0.75917846", "0.7552949", "0.75504", "0.75389063", "0.7469212", "0.74316716", "0.7423723", "0.74120265", "0.7405052", "0.7399541", "0.73699105", "0.73581076", "0.73067313", "0.7304433", "0.7301461", "0.7299044", "0.7295136", "0.72946364", "0.72629905", "0.7255593", "0.7255593", "0.7250921", "0.7231688", "0.7231209", "0.7224353", "0.7224353", "0.7205039", "0.7159294", "0.7157543", "0.713125", "0.70961756", "0.7095928", "0.7084072", "0.7080549", "0.7077687", "0.7071701", "0.7068631", "0.7060453", "0.704194", "0.7030759", "0.7024966", "0.70129544", "0.7004049", "0.70007277", "0.6995442", "0.69830626", "0.69794613", "0.69711906", "0.6955964", "0.6949103", "0.6942149", "0.69385237", "0.6936178", "0.6926709", "0.6926709", "0.6924745", "0.6918392", "0.69158304", "0.691161", "0.6902502", "0.6897411", "0.68907833", "0.6890608", "0.6882578", "0.68798107", "0.6878755", "0.6875835", "0.68742114", "0.68742114", "0.68668336", "0.686471", "0.6857791", "0.6857363", "0.6857328", "0.6853369", "0.68443924", "0.68404967", "0.68386406", "0.68343574", "0.68337387", "0.682607", "0.682607", "0.6817211", "0.68165815", "0.68144655", "0.68144655", "0.68112826", "0.6807381", "0.6805075", "0.6801787", "0.67943156", "0.6792584" ]
0.76320684
5
Accepts a file path to parse mp3 files from e.g. "./spec/fixtures/mp3s"
def initialize(file_path) @path = file_path @files_array = [] self.files end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def initialize(path)\n @path = path\n # accepts a file path to parse mp3 files from \n end", "def initialize(path)\n @path = path#accepts a file path to parse MP3 files from\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 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 files\n files = Dir.glob(\"#{@path}/*.mp3\")\n normalized = files.map do |file|\n file.split(\"./spec/fixtures/mp3s/\") \n end\n why = normalized.map do |file|\n file.reject {|c| c.empty?}\n end.flatten\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 glob_mp3_files_from_filespec(filespec)\n files = Dir[filespec]\n files.reject! { |fn| File.directory?(fn) }\n files.reject! { |fn| !(can_parse_id3?(fn)) } \n return files\nend", "def files\n Dir.entries(\"#{path}\").select {|song_filename| song_filename.include?(\"mp3\")}\n end", "def files\n @files ||= Dir.glob(\"#{path}/*.mp3\").collect{|file|\n#normalize the filename to just the MP3 filename with no path\n file.gsub(\"#{path}/\", \"\")}\n end", "def files #only wants mp3 files\n Dir.entries(path).select {|entry| entry.include?(\".mp3\")} #select returns an array itself\n end", "def files\n Dir[\"#{@path}/*.mp3\"].collect {|path| path.split('/')[-1]}\n end", "def files\n Dir.glob(\"#{path}/*.mp3\").collect {|file| file.gsub(\"#{path}/\",\"\")}\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 convert_to_mp3(file, file_dir)\n return if file_dir.include?(file)\n\n binding.pry\n file_name = file.split('.').first\n command = \"-i #{ file } -acodec libmp3lame #{ file_name }.mp3\"\n\n ffmpeg(command)\nend", "def initialize(path = './db/mp3s')\n MusicImporter.new(path).import\n end", "def files\n @files ||= Dir.glob(\"#{path}/*.mp3\").collect{ |filename|filename.gsub(\"#{path}/\", \"\")}\n end", "def scan_file!(file)\r\n AudioFile.transaction do\r\n\r\n file= File.expand_path(file)\r\n raise \"Unable to derive dirname and basename for #{file.inspect}\" unless file =~ /\\A(^.+)[\\\\\\/](.+)$\\Z/\r\n file_dirname,file_basename= $1,$2\r\n filesize= File.size(file)\r\n tags= []\r\n a= AudioContent.new\r\n content= File.read(file)\r\n file_ext= file_basename.sub(/^.+\\./,'') if file_basename.include?('.')\r\n if file_ext =~ /mp3/i\r\n a.format= 'mp3'\r\n Mp3Info.open(file){|mp3|\r\n start,len= mp3.audio_content\r\n\r\n # Read ID3 tag\r\n tags<< AudioTag.new({\r\n :format => 'id3',\r\n :version => mp3.tag2.version,\r\n :offset => 0,\r\n :data => content[0..start-1],\r\n }) if start > 0 and mp3.tag2\r\n # TODO footer id3 tags not supported\r\n content= content[start..start+len-1]\r\n\r\n # Read APE tag\r\n ape= ApeTag.new(file)\r\n if ape.exists?\r\n raise \"ape.tag_size != ape.raw.size\\n#{ape.inspect}\" unless ape.tag_size == ape.raw.size\r\n tags<< AudioTag.new({\r\n :format => 'ape',\r\n :version => '2',\r\n :offset => filesize - ape.tag_size,\r\n :data => ape.raw,\r\n })\r\n content= content[0..-ape.tag_size-1]\r\n end\r\n }\r\n\r\n # Scan forward to mp3 header\r\n content.sub!(/^\\x00+(?=\\xff)/, '').freeze\r\n\r\n # Read mp3 attributes from raw mp3 without tags\r\n stringio_fake_filename= File.filename_for_stringio(content)\r\n Mp3Info.open(stringio_fake_filename){|mp3|\r\n a.bitrate= mp3.bitrate\r\n a.length= mp3.length\r\n a.samplerate= mp3.samplerate\r\n a.vbr= mp3.vbr\r\n }\r\n else\r\n raise \"Unsupported format: #{file_ext.inspect}\\nFile: #{file}\"\r\n end\r\n\r\n # Albumart on tags\r\n tags.each{|t|\r\n if t.albumart_raw and t.albumart_mimetype\r\n img= Image.find_identical_or_create! :mimetype => t.albumart_mimetype, :data => t.albumart_raw\r\n t.albumart= img\r\n end\r\n }\r\n\r\n # Save audio content\r\n a.size= content.size\r\n a.md5= Digest::MD5.digest(content)\r\n a.sha2= Digest::SHA2.digest(content, 512)\r\n a= a.find_identical_or_save!\r\n\r\n # Save audio file\r\n f= AudioFile.find_identical_or_create!({\r\n :audio_content => a,\r\n :dirname => file_dirname,\r\n :basename => file_basename,\r\n :size => filesize,\r\n :location => @location,\r\n :mtime => File.mtime(file),\r\n })\r\n\r\n # Save tags\r\n albums= []\r\n tags_to_delete= f.audio_tags.dup\r\n tags.each{|t|\r\n t.audio_file= f\r\n\r\n # Save if this is a new tag\r\n matching_tags= f.audio_tags.select{|t2| get_tag_attributes(t) == get_tag_attributes(t2)}\r\n if matching_tags.empty?\r\n t.save!\r\n process_tag t, albums, f\r\n else\r\n matching_tags.each{|t2| tags_to_delete.delete t2}\r\n end\r\n }\r\n f.audio_tags.delete *tags_to_delete unless tags_to_delete.empty?\r\n\r\n # Update albumart on albums\r\n tags.each{|t|\r\n if albumart_raw= t.ta[:albumart]\r\n img= Image.find_identical_or_create! :data => albumart_raw, :size => albumart_raw.size\r\n t.albumart= img\r\n end\r\n }\r\n albums.uniq.each{|album| album.update_albumart!}\r\n\r\n # Remove old versions of the same audio file\r\n old_afs= AudioFile.find :all, :conditions => ['dirname=? AND basename=? AND id!=?',f.dirname, f.basename, f.id]\r\n old_afs.each(&:destroy)\r\n end\r\n\r\n # Remove any errors for this file\r\n ScannerError.delete_all :file => file\r\n end", "def files\n Dir.glob(\"#{path}/*.mp3\").collect do\n |file| file.gsub(\"#{path}/\",\"\")\n end\n end", "def files\n @files = Dir.glob(\"#{@path}/*.mp3\").collect{ |file| file.gsub(\"#{@path}/\", \"\") }\n end", "def files\n filename = Dir.glob(\"#{path}/*.mp3\")\n filename = filename.collect{|a_string| a_string.sub(\"#{path}/\", \"\")}\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 files\n files = Dir[\"#{path}/*.mp3\"].each {|file_name| next if File.directory? file_name}\n files.each {|filename| filename.gsub!(/\\A(.....................)/, \"\")}\n files\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 parse_file path\n self.filename = path\n open path do |f|\n parse f.read\n end\n end", "def parse_file path\n self.filename = path\n open path do |f|\n parse f.read\n end\n end", "def parse_file path\n self.filename = path\n open path do |f|\n parse f.read\n end\n end", "def parse_file path\n self.filename = path\n open path do |f|\n parse f.read\n end\n end", "def parse_file path\n self.filename = path\n open path do |f|\n parse f.read\n end\n end", "def parse_file path\n self.filename = path\n open path do |f|\n parse f.read\n end\n end", "def parse_file(path, options={})\n path = Pathname.new(path.to_str) unless Pathname === path\n parse(path, options)\n end", "def files\n\t\t@array_of_mp3s = Dir[\"#{@path}/*.mp3\"]\n\t\t@array_of_mp3s.map do |mp3|\n\t\t\tmp3.slice!(\"#{@path}/\")\n\t\t\tmp3\n\t\tend\n\tend", "def files \n @files = Dir.glob(\"#{path}/*.mp3\")\n @files.collect! {|filename| filename.gsub(/#{path}\\//, \"\")}\n @files\n end", "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 extract_audio(infile)\n\n infile = Path[infile]\n \n p infile\n \n unless infile.exists?\n STDERR.puts \"Couldn't find #{infile}\"\n return\n end\n\n #unless VALID_EXTS.include? infile.ext\n # STDERR.puts \"Unrecognized video format: #{infile.ext}\"\n # return\n #end\n \n if infile =~ %r{^/dev/fd/}\n outfile = Path.pwd/\"#{infile.filename}.mp3\" \n else \n outfile = infile.with(:ext=>\"mp3\")\n end\n\n if outfile.exists?\n puts \"Error: #{outfile} exists!\"\n return\n end \n \n puts\n puts \"Input: #{infile}\"\n puts \"Output: #{outfile}\"\n puts\n \n # -lameopts q=5\n cmd = %w[mencoder -of rawaudio -oac mp3lame -ovc copy -o] + [outfile.to_s, infile.to_s]\n system(*cmd)\n \nend", "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 initialize(path='./db/mp3s')\n @path = path\n MusicImporter.new(path).import\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 files\n @files ||= Dir.glob(\"#{path}/*.mp3\").collect{ |f| f.gsub(\"#{path}/\", \"\") }\n end", "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 files\n\t\t(Dir.glob(\"#{@path}/*.mp3\")).map do |path_filename|\n\t\t @files = File.basename(path_filename)\n\t\tend\n\tend", "def parse_file(path)\n if (!File.exists?(path))\n LOGGER.e {\"Unable to open specified file to parse: '#{path}'\"}\n return nil\n end\n \n File.open(path, 'r') do |f|\n parse_stream(f)\n end\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 random_media_file_in_path(path)\n raise \"Path does not exist:\" + path if !File.directory?(path)\n random_media_file_from_list(absolute_file_entries(path))\nend", "def import\n\t\tself.files.each do |mp3|\t\t\n\t\t\tSong.new_by_filename(mp3)\n\t\tend\n\tend", "def files\n files = Dir[\"#{path}/*.mp3\"].each {|file_name| next if File.directory? file_name}\n norm_files = files.collect {|filename| File.basename(filename)}\n norm_files\n end", "def files\n Dir.open @path do |dir|\n @files = dir.entries.delete_if{|element|\n !element.include? \".mp3\"\n }\n end\n end", "def files\n get_back_here = Dir.pwd\n Dir.chdir(@path)\n @files = Dir.glob(\"*.mp3\")\n Dir.chdir(get_back_here)\n @files\n end", "def call\n files.each do |file|\n parts = parse_filename(file)\n build_song(parts)\n end \n end", "def parse_file(path, **options)\n parse(::File.read(path), **options)\n end", "def parse_file(path, options={})\n File.open(path) do |puzfile|\n parse_io(puzfile, options)\n end\n end", "def files\n @files_array ||= Dir.glob(\"#{@path}/*.mp3\").collect do |filename|\n filename.rpartition(\"/\").last \n end \n end", "def loadMusic(directory)\n\tfileArray = [] #declare an empty file array\n\n\tDir.foreach(directory) do |fileName|\n\t\tif File.extname(fileName) == \".mp3\" #retrieve the music files\n\t\t\tfileArray.push(fileName) #push them to back of array\n\t\tend\n\tend \n\treturn fileArray #return the array of files\nend", "def play_songs\n MusicImporter.new(path).play_song\n end", "def read_track music_file\n\t# fill in the missing code\nend", "def parse_filepath(fname)\n \n if fname =~ /^(.*\\/)?(\\w+)(?: (.*?))?(?:\\.(\\d+k))?\\.(aif|wav|mp3)/i\n path, track_key, title, quality, filetype = $1, $2, $3, $4, $5\n if title && title =~ /^\\d+k$/ && !quality\n quality, title = title, nil\n end\n quality.downcase! if quality\n filetype.downcase!\n track_key.upcase!\n #STDERR.puts \"path: #{path}\\ntrack_key: #{track_key}\\n\\ntitle: #{title}\\nquality: #{quality}\\nfiletype: #{filetype}\\n\"\n return { 'path' => path, 'track_key' => track_key, 'title' => title, 'quality' => quality, 'filetype' => filetype }\n\n elsif fname =~ /^(.*\\/)?(?:([a-z]\\w*)\\.)?(\\d+)\\.(\\d+)(?:\\.([^\\/]*?))?(?:\\.(\\d+k))?(?:\\.(mp3|wav|aif))/i\n path, library, track_id, track_version_number, title, quality, filetype = $1, $2, $3, $4, $5, $6, $7\n if title && title =~ /^\\d+k$/ && !quality\n quality, title = title, nil\n end\n library.upcase! if library\n quality.downcase! if quality\n filetype.downcase!\n #STDERR.puts \"path: #{path}\\nlibrary: #{library}\\ntrack_id: #{track_id}\\nversion: #{track_version_number}\\ntitle: #{title}\\nquality: #{quality}\\nfiletype: #{filetype}\\n\"\n return { 'path' => path, 'library' => library, 'track_id' => track_id, 'track_version_number' => track_version_number, 'title' => title, 'quality' => quality, 'filetype' => filetype }\n else\n nil\n end\n end", "def files\n Dir.glob(self.path + '**/*.mp3').collect {|file| File.basename(file)}\n end", "def initialize(music_path)\n @music_path = music_path\n end", "def read_fixture( path )\n File.read(\"#{ fixtures_folder }/#{ path }\")\nend", "def initialize(path) \n @path = path \n @songs = []\n end", "def parse_args(*args)\n if args.size == 0\n args = [File.expand_path('.')]\n end\n\n @files = []\n args.each do |file|\n next unless File.exists?(file)\n file = File.expand_path(file)\n\n # If target is a dir, we add all music files in this dir\n if File.directory?(file)\n @files += Dir.glob(File.join(file, '**', '*.{mp3,ogg}')).map{|i| File.expand_path(i)}.sort\n else\n @files << file\n end\n end\n end", "def mp3?\n File.extname(@path).downcase.eql?('.mp3')\n end", "def parse_file(filename); end", "def file_fixture(path)\n return File.expand_path(File.join(File.dirname(__dir__), \"test\", \"fixtures\", \"files\", path))\nend", "def file_fixture(path)\n return File.expand_path(File.join(File.dirname(__dir__), \"test\", \"fixtures\", \"files\", path))\nend", "def file_fixture(path)\n return File.expand_path(File.join(File.dirname(__dir__), \"test\", \"fixtures\", \"files\", path))\nend", "def import\n self.files.each do |stringthing|\n Song.create_from_filename(stringthing)\n end\n end", "def files\n songs = Dir.entries(path) #this is a separate class within itself \n #this is saying delete each song in the array if it starts with a string of a period because they are all strings\n songs.reject {|song| song[0] == \".\"}\n end", "def import\n files.each{ |f| Song.create_from_filename(f) }\n end", "def read_track music_file\n\tname = music_file.gets()\n\tlocation = music_file.gets()\n\ttrack = Track.new(name, location)\n\treturn track\nend", "def xml_for_mp3 mp3\n m = /([^\\/]+\\/\\d{4}\\/\\d{2}\\/\\d{2}\\/\\d{4}\\s.*)\\.mp3$/.match mp3\n raise \"Ouch\" if m.nil?\n File.join 'stations', m[1] + \".xml\"\nend", "def read_track music_file\r\n\tname = music_file.gets.chomp\r\n location = music_file.gets\r\n track = Track.new(name, location)\r\n return track\r\nend", "def handle_music(music)\n return false if $config['music_file']['process'] != true\n log(\"handle_music -> do something with the music file #{music.file}\")\n ap $config['music_file']['storage'] if $opt[\"debug\"]\nend", "def add_mp3(file)\n begin\n mp3 = Mp3File.new(file)\n @mp3s.push(mp3)\n rescue Mp3InfoError => e\n puts \"Skipping #{file} as it has a problem: #{e}\"\n end\n end", "def read_track music_file\n\tname = music_file.gets\n\tlocation = music_file.gets\n\ttrack = Track.new(name, location)\n\ttrack\nend", "def fix_files\n Dir.glob(\"./audio/**/*.mp3\").each do |path|\n file_name = file_name_from_path(path)\n proper_file_name = file_name.gsub(/[^a-zA-Z1-9\\_\\.]/) { |char| \"_\" }\n unless file_name == proper_file_name\n `mv \"#{path}\" #{path.gsub(file_name, proper_file_name)}`\n end\n end\n end", "def read_unparsed_file(filename)\n File.read(\"spec/fixtures/files/responses/#{filename}\")\n end", "def audio_files(folder_name)\n Dir.glob(\"./audio/#{folder_name}/**/*\")\n end", "def getMP3\n return @MP3Files || []\n end", "def getAudioUri\n return @data.scan(/https:\\/\\/.*?\\.mp3/)[0]\nend", "def initialize (mp3File, nameFile)\n if File.exists?(mp3File)\n @mp3 = mp3File\n else\n puts \"File #{mp3File} does not exist!\"\n end\n \n if File.exists?(nameFile)\n if File.readable?(nameFile)\n @file = File.open(nameFile)\n @filename = nameFile\n else \n puts \"File is not readable! Are the permissions correct? :(\"\n end\n \n else\n puts \"File #{nameFile} does not exist!\"\n end\n end", "def read_track(music_file)\n\t# fill in the missing code\n\ttrack_name = music_file.gets()\n\ttrack_location = music_file.gets()\n\ttrack = Track.new(track_name, track_location)\nend", "def initialize(p_path)\n\n\t\t\t# The (absolute) path of the mp3 file, \n\t\t\t# used to read ID3 Tag-related information\n\t\t\t@path = p_path\n\t\t\t\n\t\t\t# Initialize the tag, an ID3Lib::Tag instance (a ID3 v1.x/v2.y Tag)\n\t\t\t@tag = nil\n\t\tend", "def is_mp3?\n if filename != nil\n filename.ends_with?('.mp3')\n else\n false\n end\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 import\n#song_by_filename\n files.each{|f| Song.new_by_filename(f)}\n\nend", "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 query_metadata filename\n song = File.basename(filename, File.extname(filename))\n track = filename[/[0-9]+ /]\n\n unless track.nil?\n song = song[track.size .. -1]\n track = track.to_i\n end\n\n return track,song\nend", "def import\n files.each do |e|\n Song.create_from_filename(e)\n end\n end", "def read_file(filename)\n JSON.parse(File.read(\"spec/fixtures/files/#{filename}\"))\n end", "def convert_to_mp3\n\t\tputs \"\\n=> look for m4a files and convert it to mp3\\n\"\n\t\t\n\t\t# grab directory names.\n\t\tdir_names = Dir.entries @@dir_temp\n\t\t# remove .prefixes\n\t\tdir_names = self.remove_hidden_files dir_names\n\t\t\n\t\t# go thru each sub directories.\n\t\tdir_names.each do |current_dir|\n\t\t\tputs \"\\n=> at \" + @@dir_temp + current_dir + \"\\n\"\n\t\t\t\n\t\t\t# grabs the files in the directory\n\t\t\tcurrent_files = Dir.entries(@@dir_temp + \"/\" + current_dir)\n\t\t\t\n\t\t\t# remove the . prefixes.\n\t\t\tcurrent_files = self.remove_hidden_files current_files\n\t\t\t\n\t\t\t# cycle thru the file\n\t\t\tcurrent_files.each do |current_file|\n\t\t\t\t# file names\n\t\t\t\tsrc_file = \"\"\n\t\t\t\tdest_file = \"\"\n\t\t\t\n\t\t\t\t# checks if it has a m4a extension\n\t\t\t\tif self.is_m4a? current_file\t\t\n\t\t\t\t\tputs \"\\n=> encoding \" + current_file\n\t\t\t\t\t\n\t\t\t\t\t# creating src and dest files.\n\t\t\t\t\tsrc_file = @@dir_temp + current_dir + '/' + current_file\n\t\t\t\t\tdest_file = @@dir_temp + current_dir + '/' + self.ext_to_mp3(current_file)\n\t\t\t\t\t\n\t\t\t\t\t#src_file = \"'\" + src_file + \"'\" \n\t\t\t\t\t#dest_file = \"'\" + dest_file + \"'\" \n\t\t\t\t\t\n\t\t\t\t\t# escape the names.\n\t\t\t\t\tsrc_file = self.escaped_file_name(src_file)\n\t\t\t\t\tdest_file = self.escaped_file_name(dest_file)\n\t\t\t\t\t\n\t\t\t\t\tputs \"=> src \" + src_file \n\t\t\t\t\tputs \"=> dest \" + dest_file\n\t\t\t\t\t\n\t\t\t\t\t# lame encoding.\n\t\t\t\t\tself.lame_str(@@opt_lame, src_file, dest_file)\n\t\t\t\telse\n\t\t\t\t\tdest_file = @@dir_temp + current_dir + '/' + current_file\n\t\t\t\t\tdest_file = self.escaped_file_name(dest_file)\n\t\t\t\tend\n\t\t\t\t\n\t\t\t\t# split the mp3...\n\t\t\t\tself.mp3splt_str(@@opt_mp3splt, dest_file)\n\t\t\t\t\n\t\t\t\t# delete the source file.\n\t\t\t\t# only want the split files.\n\t\t\t\tself.rm_str(\"\", dest_file)\n\t\t\t\tif (src_file != \"\")\n\t\t\t\t\tself.rm_str(\"\", src_file)\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend", "def audio?\n filename =~ /^audio/\n end", "def import\n self.files.each{ |filename| Song.create_from_filename(filename) }\n end", "def get_source_movs(path)\n files = []\n Find.find(path) do |filename|\n if !FileTest.directory?(filename)\n if filename =~ MOV_PATTERN\n files << Pathname.new(filename)\n end\n end\n end\n\n files.sort\nend", "def load_albums\n \tmusic_file = File.new(\"album.txt\",\"r\")\n albums = read_albums(music_file)\n albums\n end", "def read_album music_file\n\tartist = music_file.gets.chomp\n\ttitle = music_file.gets.chomp\n\tgenre = music_file.gets.chomp.to_i\n\n\talbum = Album.new(artist, title, genre, read_tracks(music_file))\nend", "def read_file(absolute_path); end", "def can_parse_id3?(filename)\n begin\n trash = Mp3Info.open(filename)\n return true\n rescue\n return false\n end\nend", "def parse_files(*files); end", "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 from_file path\n run File.read(path) if File.exists? path\n end", "def play_file(file)\n system(\"ogg123 #{file}\")\n end" ]
[ "0.7534987", "0.74295145", "0.714739", "0.6981381", "0.6809124", "0.66446036", "0.66320646", "0.6586375", "0.6549358", "0.6463051", "0.6306905", "0.63020617", "0.6241906", "0.62367743", "0.6211862", "0.61854947", "0.61727965", "0.61481977", "0.61297643", "0.611657", "0.6116201", "0.61140984", "0.61120355", "0.61099297", "0.61099297", "0.61099297", "0.61099297", "0.61099297", "0.61099297", "0.6099888", "0.6059204", "0.60504097", "0.60408133", "0.60381234", "0.6035687", "0.6022445", "0.5980416", "0.595623", "0.5931248", "0.5879454", "0.58602345", "0.5846084", "0.58381945", "0.5814077", "0.5807751", "0.5794916", "0.5780166", "0.57761467", "0.57440436", "0.5738194", "0.5736545", "0.5703019", "0.5698168", "0.5639808", "0.56368226", "0.5628205", "0.5592148", "0.5590481", "0.55882204", "0.55739474", "0.55461437", "0.55281776", "0.5499722", "0.5499722", "0.5499722", "0.5483709", "0.5482183", "0.54495", "0.5446651", "0.54443014", "0.5441277", "0.5439145", "0.54347396", "0.54338306", "0.54135066", "0.53931665", "0.5383361", "0.5383147", "0.53752476", "0.53678215", "0.53644484", "0.5357509", "0.5351794", "0.5345309", "0.5337402", "0.5322634", "0.53225684", "0.5320876", "0.5306859", "0.5300292", "0.5298169", "0.5286644", "0.5278583", "0.527786", "0.5273309", "0.5266007", "0.526172", "0.5258701", "0.5252992", "0.52342784", "0.52331585" ]
0.0
-1
Loads all the mp3 files in the path directory Normalizes the filename to just the mp3 filename with no path TEST: music_importer.files.size => 4
def files @files_array = Dir.entries(self.path).select {|f| !File.directory? f} # This returns: # ["Action Bronson - Larry Csonka - indie.mp3", # "Real Estate - Green Aisles - country.mp3", # "Real Estate - It's Real - hip-hop.mp3", # "Thundercat - For Love I Come - dance.mp3"] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "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 files\n @files ||= Dir.glob(\"#{path}/*.mp3\").collect{|file|\n#normalize the filename to just the MP3 filename with no path\n file.gsub(\"#{path}/\", \"\")}\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 files\n files = Dir[\"#{path}/*.mp3\"].each {|file_name| next if File.directory? file_name}\n norm_files = files.collect {|filename| File.basename(filename)}\n norm_files\n end", "def files\n\t\t@array_of_mp3s = Dir[\"#{@path}/*.mp3\"]\n\t\t@array_of_mp3s.map do |mp3|\n\t\t\tmp3.slice!(\"#{@path}/\")\n\t\t\tmp3\n\t\tend\n\tend", "def import\n\t\tself.files.each do |mp3|\t\t\n\t\t\tSong.new_by_filename(mp3)\n\t\tend\n\tend", "def files\n @files = Dir.glob(\"#{@path}/*.mp3\").collect{ |file| file.gsub(\"#{@path}/\", \"\") }\n end", "def loadMusic(directory)\n\tfileArray = [] #declare an empty file array\n\n\tDir.foreach(directory) do |fileName|\n\t\tif File.extname(fileName) == \".mp3\" #retrieve the music files\n\t\t\tfileArray.push(fileName) #push them to back of array\n\t\tend\n\tend \n\treturn fileArray #return the array of files\nend", "def files \n @files = Dir.glob(\"#{path}/*.mp3\")\n @files.collect! {|filename| filename.gsub(/#{path}\\//, \"\")}\n @files\n end", "def files\n Dir.glob(\"#{path}/*.mp3\").collect {|file| file.gsub(\"#{path}/\",\"\")}\n end", "def files\n Dir.glob(\"#{path}/*.mp3\").collect do\n |file| file.gsub(\"#{path}/\",\"\")\n end\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 files\n files = Dir[\"#{path}/*.mp3\"].each {|file_name| next if File.directory? file_name}\n files.each {|filename| filename.gsub!(/\\A(.....................)/, \"\")}\n files\n end", "def files\n @files ||= Dir.glob(\"#{path}/*.mp3\").collect{ |filename|filename.gsub(\"#{path}/\", \"\")}\n end", "def files\n filename = Dir.glob(\"#{path}/*.mp3\")\n filename = filename.collect{|a_string| a_string.sub(\"#{path}/\", \"\")}\n end", "def files\n @files ||= Dir.glob(\"#{path}/*.mp3\").collect{ |f| f.gsub(\"#{path}/\", \"\") }\n end", "def files\n\t\t(Dir.glob(\"#{@path}/*.mp3\")).map do |path_filename|\n\t\t @files = File.basename(path_filename)\n\t\tend\n\tend", "def files\n Dir[\"#{@path}/*.mp3\"].collect {|path| path.split('/')[-1]}\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 files\n Dir.open @path do |dir|\n @files = dir.entries.delete_if{|element|\n !element.include? \".mp3\"\n }\n end\n end", "def import\n files.each do |e|\n Song.create_from_filename(e)\n end\n end", "def files\n files = Dir.glob(\"#{@path}/*.mp3\")\n normalized = files.map do |file|\n file.split(\"./spec/fixtures/mp3s/\") \n end\n why = normalized.map do |file|\n file.reject {|c| c.empty?}\n end.flatten\n end", "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 import\n files.each{ |f| Song.create_from_filename(f) }\n end", "def files\n get_back_here = Dir.pwd\n Dir.chdir(@path)\n @files = Dir.glob(\"*.mp3\")\n Dir.chdir(get_back_here)\n @files\n end", "def files\n Dir.entries(\"#{path}\").select {|song_filename| song_filename.include?(\"mp3\")}\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 import\n self.files.each{ |filename| Song.create_from_filename(filename) }\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 import\n self.files.each do |stringthing|\n Song.create_from_filename(stringthing)\n end\n end", "def import\n files\n @files.each {|file|\n Song.create_from_filename(file)\n }\n end", "def import\n @@files_array.collect { |filename| Song.create_from_filename(filename) } \n end", "def files\n Dir.glob(self.path + '**/*.mp3').collect {|file| File.basename(file)}\n end", "def initialize(path = './db/mp3s')\n MusicImporter.new(path).import\n end", "def import\n files.each {|song_filename| Song.new_by_filename(song_filename)}\n end", "def songs\n MusicImporter.new(path).print_songs\n end", "def import\n self.files.each do |f|\n song = Song.new_by_filename(f)\n Artist.all << song.artist unless Artist.all.include?(song.artist)\n end \n end", "def files\n @files_array ||= Dir.glob(\"#{@path}/*.mp3\").collect do |filename|\n filename.rpartition(\"/\").last \n end \n end", "def import\n#song_by_filename\n files.each{|f| Song.new_by_filename(f)}\n\nend", "def play_songs\n MusicImporter.new(path).play_song\n end", "def import\n files.each{|f| Song.new_by_filename(f)}\n end", "def import\n files.each{|file| Song.new_by_filename(file)}\n end", "def import\n self.files.each do |filename|\n Song.new_by_filename(filename)\n end\n end", "def import\n self.files.each {|filename| Song.new_by_filename(filename)}\n end", "def files #only wants mp3 files\n Dir.entries(path).select {|entry| entry.include?(\".mp3\")} #select returns an array itself\n end", "def import\n files.each {|filename| Song.new_by_filename(filename)}\n end", "def import\n self.files.each {|filename| Song.new_by_filename(filename)}\n end", "def import\n self.files.each{ |filename| Song.new_by_filename(filename) }\n end", "def import\n files.each {|file_name| Song.new_by_filename(file_name)}\n end", "def import\n files.each do |filename|\n Song.new_by_filename(filename)\n end\n end", "def import\n files.each {|filename| Song.new_by_filename}\n end", "def initialize(path='./db/mp3s')\n @path = path\n MusicImporter.new(path).import\n end", "def files\n songs = Dir.entries(path) #this is a separate class within itself \n #this is saying delete each song in the array if it starts with a string of a period because they are all strings\n songs.reject {|song| song[0] == \".\"}\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 import\n self.files.each{|file| Song.new_by_filename(file)}\n end", "def import\n self.files.each do |file|\n Song.new_by_filename(file)\n end\n end", "def convert_to_mp3\n\t\tputs \"\\n=> look for m4a files and convert it to mp3\\n\"\n\t\t\n\t\t# grab directory names.\n\t\tdir_names = Dir.entries @@dir_temp\n\t\t# remove .prefixes\n\t\tdir_names = self.remove_hidden_files dir_names\n\t\t\n\t\t# go thru each sub directories.\n\t\tdir_names.each do |current_dir|\n\t\t\tputs \"\\n=> at \" + @@dir_temp + current_dir + \"\\n\"\n\t\t\t\n\t\t\t# grabs the files in the directory\n\t\t\tcurrent_files = Dir.entries(@@dir_temp + \"/\" + current_dir)\n\t\t\t\n\t\t\t# remove the . prefixes.\n\t\t\tcurrent_files = self.remove_hidden_files current_files\n\t\t\t\n\t\t\t# cycle thru the file\n\t\t\tcurrent_files.each do |current_file|\n\t\t\t\t# file names\n\t\t\t\tsrc_file = \"\"\n\t\t\t\tdest_file = \"\"\n\t\t\t\n\t\t\t\t# checks if it has a m4a extension\n\t\t\t\tif self.is_m4a? current_file\t\t\n\t\t\t\t\tputs \"\\n=> encoding \" + current_file\n\t\t\t\t\t\n\t\t\t\t\t# creating src and dest files.\n\t\t\t\t\tsrc_file = @@dir_temp + current_dir + '/' + current_file\n\t\t\t\t\tdest_file = @@dir_temp + current_dir + '/' + self.ext_to_mp3(current_file)\n\t\t\t\t\t\n\t\t\t\t\t#src_file = \"'\" + src_file + \"'\" \n\t\t\t\t\t#dest_file = \"'\" + dest_file + \"'\" \n\t\t\t\t\t\n\t\t\t\t\t# escape the names.\n\t\t\t\t\tsrc_file = self.escaped_file_name(src_file)\n\t\t\t\t\tdest_file = self.escaped_file_name(dest_file)\n\t\t\t\t\t\n\t\t\t\t\tputs \"=> src \" + src_file \n\t\t\t\t\tputs \"=> dest \" + dest_file\n\t\t\t\t\t\n\t\t\t\t\t# lame encoding.\n\t\t\t\t\tself.lame_str(@@opt_lame, src_file, dest_file)\n\t\t\t\telse\n\t\t\t\t\tdest_file = @@dir_temp + current_dir + '/' + current_file\n\t\t\t\t\tdest_file = self.escaped_file_name(dest_file)\n\t\t\t\tend\n\t\t\t\t\n\t\t\t\t# split the mp3...\n\t\t\t\tself.mp3splt_str(@@opt_mp3splt, dest_file)\n\t\t\t\t\n\t\t\t\t# delete the source file.\n\t\t\t\t# only want the split files.\n\t\t\t\tself.rm_str(\"\", dest_file)\n\t\t\t\tif (src_file != \"\")\n\t\t\t\t\tself.rm_str(\"\", src_file)\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend", "def import\n # this method is creating a song from filename\n # Sends filename to the Song class\n files.uniq do |f| \n Artist.all << f\n end \n# \n# Artist.all << songs = files.find do |filename| \n# Song.new_by_filename(filename)\n# \n end", "def call\n files.each do |file|\n parts = parse_filename(file)\n build_song(parts)\n end \n end", "def initialize(path)\n @path = path\n # accepts a file path to parse mp3 files from \n end", "def audio_files\n @audio_files ||= path.join(\"data\").each_child.select { |file| [\".wav\", \".mp3\"].include? file.extname }.map { |file| IngestableAudioFile.new(path: file) }\n end", "def initialize(path)\n @path = path#accepts a file path to parse MP3 files from\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 load\n chunked pattern do |subpattern|\n @songs.merge! extract_from(id3 subpattern)\n end\n end", "def import\n files.each{|filename| Song.new_by_filename(filename) } #Song.new_by_filename(filename) is calling the method in class Song\n end", "def getMP3\n return @MP3Files || []\n end", "def fix_files\n Dir.glob(\"./audio/**/*.mp3\").each do |path|\n file_name = file_name_from_path(path)\n proper_file_name = file_name.gsub(/[^a-zA-Z1-9\\_\\.]/) { |char| \"_\" }\n unless file_name == proper_file_name\n `mv \"#{path}\" #{path.gsub(file_name, proper_file_name)}`\n end\n end\n end", "def apply_to_dir(path_to_directory)\n files = Dir.open(path_to_directory) \n \n files.each do |file|\n next if file[0] == '.'\n convert_to_mp3(construct_file_path(file), files)\n end\n\n # remove the files from directory\n # files.each do |file|\n # if file.include?(\".wav\")\n # FileUtils.rm(construct_file_path(file))\n # end\n # end\n true\nend", "def created_mp3s(splitter = @splitter)\n Dir.glob(\"#{splitter.output_folder}/*.mp3\").map { |f| File.basename f }\nend", "def load_albums\n \tmusic_file = File.new(\"album.txt\",\"r\")\n albums = read_albums(music_file)\n albums\n end", "def initialize(path) \n @path = path \n @songs = []\n end", "def manageAudioFiles(maxNumFiles, folder)\n\n fileNumber = Dir[(Rails.root.to_s + \"/public/audio/#{folder}/*\")].count\n keepSeconds = 7200\n\n while fileNumber > maxNumFiles\n keepSeconds *= 0.5\n Dir[(Rails.root.to_s + \"/public/audio/#{folder}/*\")].each do |filename| \n deleteOldFile(filename, keepSeconds)\n end\n fileNumber = Dir[(Rails.root.to_s + \"/public/audio/#{folder}/*\")].count\n end\n\n end", "def audio_files(folder_name)\n Dir.glob(\"./audio/#{folder_name}/**/*\")\n end", "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 music_shuffle(filenames_array)\n filenames_array.each do |song|\n song_path = song.split '/'\n\n end\nend", "def glob_mp3_files_from_filespec(filespec)\n files = Dir[filespec]\n files.reject! { |fn| File.directory?(fn) }\n files.reject! { |fn| !(can_parse_id3?(fn)) } \n return files\nend", "def update_mp3_files(settings)\n songs.each do |song|\n song.update_file(settings)\n end\n end", "def parse_args(*args)\n if args.size == 0\n args = [File.expand_path('.')]\n end\n\n @files = []\n args.each do |file|\n next unless File.exists?(file)\n file = File.expand_path(file)\n\n # If target is a dir, we add all music files in this dir\n if File.directory?(file)\n @files += Dir.glob(File.join(file, '**', '*.{mp3,ogg}')).map{|i| File.expand_path(i)}.sort\n else\n @files << file\n end\n end\n end", "def create_playlist(path)\n Dir.chdir path # Always change path to the inner scope as long a neccesary (so that the program recognizes folders with File.directory?(x) )\n dir = Dir.new(path)\n arr = []\n tracks = []\n Dir.foreach(dir) do |x|\n next if x == \".\" || x == \"..\"\n if File.directory?(x)\n temp = create_playlist(path + \"/#{x}\")\n arr << temp unless temp == [] # Don't track empty folder OUTSIDE OF FOLDER (so that merging executes faster)\n Dir.chdir path # Change path back (to the outer scope)\n else\n # tracks << x # Dummy solution for easier readability while building program (just for reference)\n tracks << path + \"/#{x}\"\n end\n end\n shuffle(tracks) # Shuffle every rudimentary track-list before merging it with another\n arr << tracks unless tracks == [] # Don't create an array WITHIN AN EMPTY FOLDER (so that the merging executes faster)\n arr.length < 2 ? arr.flatten : merging(arr).flatten # return\nend", "def path # getter method \n # - this method will get the path passed through the MusicImporter object\n @path\n end", "def update_mp3_files(settings)\n self.songs.each { |song| song.update_file(settings) }\n end", "def queue_files_for_processing( args )\n\t\t# only queue up files that can have id3 tags to begin with.\n\t\tfiles = clean_file_list( args )\n\n\t\t# add the files to the queue\n\t\tif( files.length == 0 )\n\t\t\tputs \"None of the files were MP3s!!\"\n\t\t\t#FIXME: should this be an exception?\n\t\telse\n\n\t\t\t# Set the track number limits\n\t\t\tcount \t\t\t\t= @renumber_start_at\n\t\t\t@total_tracks = files.length\n\n\t\t\tfiles.each { |x|\n\t\t\t\tputs \"checking #{x}...\"\n\n\t\t\t\t# list its current id3 tag contents.\n\t\t\t\tputs \"\\tid3v2 says this:\"\n\t\t\t\tputs \"\\t\\t#{ID3Tagger::list_file( x )}\"\n\n\t\t\t\t# tell the user what the program intends to change\n\t\t\t\tputs build_proposal_string( count ) + \"\\n\"\n\n\t\t\t\t# add the file to the queue\n\t\t\t\tadd( x, count )\n\t\t\t\tcount = count + 1\n\t\t\t}\n\n\t\t\t# keep files in order\n\t\t\t@files.rehash\n\t\tend\n\tend", "def clean_mp4_files\n mp4_files = get_files(\"*.mp4\")\n\n mp4_files.each do |mp4|\n create_clean_file(mp4)\n destroy_dirty_file!(mp4)\n end\n end", "def show_songs_in_playlist\n \n file_name = params[:file_name]\n\n @song_list = []\n File.read(\"#{Rails.root}/public/Playlist/#{params[:file_name]}\").each_line do |line|\n @song_list << line.chop\n end\n end", "def load_files(options = {})\r\n files = files_newer_than(0).sort_by{|a| number_from_name(a).to_i}\r\n return if files.empty?\r\n log.debug \"files: #{files.inspect}\"\r\n \r\n last_bulk = files.select {|fn| bulk_file?(fn)}.last\r\n if last_bulk\r\n to_load = files[files.index(last_bulk)..-1]\r\n else\r\n to_load = files\r\n end\r\n\r\n counter = 0\r\n TranslationBundle.delete_all if options[:force]\r\n to_load.each {|fn| counter += load_file(fn, options)}\r\n @report << \"no files loaded - they are already in the database\\n\" if counter == 0\r\n counter\r\n end", "def clean_file_list( args )\n\t\tdirtyfiles = args\n\n\t\t# only allow .mp3 files into the clean list.\n\t\tfiles = Array.new\n\t\tdirtyfiles.each { |x|\n\t\t\tif ( x =~ /.*\\.[mM][pP]3$/ )\n\t\t\t\tfiles.push( x )\n\t\t\telse\n\t\t\t\tputs \"\\tWARNING: No .mp3 suffix in \\\"#{x}\\\"! *** skipping! ***\"\n\t\t\tend\n\t\t}\n\n\t\tfiles\n\tend", "def load_track_images(folder_path)\n files = Dir.entries(folder_path)\n arr = Array.new()\n\n i = 2\n while (i < files.size)\n arr << Gosu::Image.new(folder_path + files[i])\n i += 1\n end\n\n arr\nend", "def initialize(path = \"./db/mp3s\") #Default argument for the ending of the file given in path.\n @importer = MusicImporter.new(path).import\n #Create new instance (.new) of the MusicIMporter object (instantated in the MusicLibraryController class). And then you can call that MusicImporter's own class methods on this object (.import)\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 song_plays\n SongPlay.where(:song_path => path)\n end", "def load_song\n location = File.expand_path(\"..\", Dir.pwd) + \"/res/five.mid\"\n\t#location = location.gsub('/', '\\\\')\n\t#puts location\n\t@btn_play.enable\n\t@btn_pause.enable\n\t@btn_stop.enable\n\t\n @mc.load(location)\n\t\n\t#play_song\n end", "def genres\n MusicImporter.new(path).print_genres\n end", "def play()\n @files.shuffle.each do |file|\n play_file(file)\n end\n end", "def add_dir(dir)\n # we chdir into the directory so that file paths will be relative\n pwd = Dir.pwd\n Dir.chdir(dir)\n Find.find('.') do |f|\n if (f =~ /\\.mp3$/ && File.size?(f))\n f.sub!(%r{^./}, '') # remove leading './'\n add_mp3(f)\n end\n end\n # go back to original directory\n Dir.chdir(pwd)\n end", "def albums\n Dir[_(\"*\")].collect do |alb| \n album(File.basename(alb))\n end\n end", "def initialize(music_path)\n @music_path = music_path\n end", "def my_music_shuffle filenames\n \n return [] if filenames.empty? # get the empty case out of the way\n \n # split each filename into [path, file]\n filenames.map! {|name| Pathname.new(name).split}\n filenames.map! {|name| [name[0].to_s, name[1].to_s]}\n\n # initialise shuffle\n shufflednames = []\n tailend_flag = false\n pick = rand(filenames.length)\n \n # do the shuffling\n while !(filenames == []) do\n \n # stick pick on the end unless tailend flag is raised, in which case insert randomly\n if !tailend_flag then shufflednames << filenames[pick] else\n shufflednames.insert(rand(shufflednames.length), filenames[pick])\n end\n filenames.delete_at(pick)\n \n # set 'masknames' to list everything of a different genre\n masknames = filenames.select {|name| name[0] != shufflednames[-1][0]} \n \n # find a new pick, raising the tailend flag if we only have one genre left\n if !filenames.empty? then\n if !masknames.empty? then\n pickname = masknames.sample # pick a tune from a different genre\n pick = filenames.index(pickname) # find it in 'filenames' and point 'pick' to it\n else\n pick = rand(filenames.length) # pick any tune\n tailend_flag = true\n end\n end\n \n end # ends while loop\n \n #output the filenames merged back into strings\n shufflednames.map! {|name| name[0].to_s + '/' + name[1].to_s} \n \nend", "def parse_directory(clean = false)\n\n throw 'There is a process already searching music' if @@running_db_generation\n\n Task.do_task('Searching music...') do |task|\n begin\n @@running_db_generation = true\n @task = task\n\n # Be sure directory exists\n raise \"Music directory does not exist\" if ! Dir::exist? @settings.music_dir_path\n\n # Clean the database\n clean_db if clean\n\n puts \"Searching song files\"\n\n time_start = Time.now\n\n read_songs_db\n search_deleted_songs\n search_new_songs\n purge_empty_elements\n time_end = Time.now\n\n puts \"#{@songs.length} songs found in #{time_end - time_start} seconds\"\n\n # Search new metadata\n meta = MetaGeneration.new(@settings)\n meta.search_artists\n\n ensure\n @@running_db_generation = false\n end\n end\n\n end", "def initialize(directory)\n raise BadDirectory.new(\"#{directory} does not exist\") unless Dir.exists?(directory)\n @directory = directory\n @album_title = File.basename(directory)\n @tracks = Dir[\"#{directory}/*\"].map do |filepath|\n Track.new(filepath) rescue next\n end\n end", "def shuffle_songs(path_split_array)\n song_hash = {}\n shuffled_songs = []\n # idx 5 is the category and 6 is the file\n # go through each array entry and populate a hash\n # with a key for each category and an array of songs\n # for each key\n path_split_array.each do |entry| \n if song_hash[entry[5]]\n song_hash[entry[5]] << entry[6]\n else\n song_hash[entry[5]] = []\n song_hash[entry[5]] << entry[6]\n end\n end\n\n # Iterate through the categories and get a random song each time through\n # delete the hash location when array values are empty\n until song_hash.empty?\n song_hash.keys.each do |key|\n shuffled_songs << key\n shuffled_songs << song_hash[key].delete_at(rand(song_hash[key].size))\n song_hash.delete(key) if song_hash[key].empty?\n end\n end\n shuffled_songs\nend" ]
[ "0.80089545", "0.73722214", "0.7262233", "0.72063255", "0.7154327", "0.7137118", "0.7092597", "0.7090557", "0.70861024", "0.7047633", "0.7023163", "0.7004804", "0.69547623", "0.6939964", "0.6929856", "0.6852042", "0.6840113", "0.6838643", "0.6834355", "0.6834068", "0.68048316", "0.6804315", "0.6790392", "0.67660624", "0.67641354", "0.6763234", "0.67364526", "0.67073095", "0.6701045", "0.6676358", "0.6673069", "0.657286", "0.65541685", "0.654975", "0.65441114", "0.6542287", "0.6536716", "0.65346533", "0.65285236", "0.65220624", "0.6499961", "0.64857954", "0.64809763", "0.6478475", "0.6472701", "0.6471809", "0.6468174", "0.646351", "0.6463374", "0.64617217", "0.64580643", "0.64110756", "0.64036614", "0.6393411", "0.6388673", "0.6363873", "0.63497454", "0.62809455", "0.6239773", "0.6235766", "0.6207832", "0.61744606", "0.61663955", "0.61570674", "0.6093969", "0.6054785", "0.6035629", "0.6028285", "0.59778154", "0.5950115", "0.5946461", "0.58740896", "0.5833963", "0.576136", "0.57450104", "0.56364644", "0.5618887", "0.55243665", "0.5511112", "0.55101854", "0.55001545", "0.54694456", "0.5465034", "0.5446487", "0.5446306", "0.54456764", "0.5436348", "0.54273546", "0.54173386", "0.53990203", "0.5390867", "0.53879714", "0.53775066", "0.5362862", "0.5334283", "0.5327011", "0.53190297", "0.5314781", "0.5295029", "0.5288871" ]
0.5728664
75
GET /customers GET /customers.json
def index @customers = Customer.all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @customers = @user.customers.all\n render json: @customers\n end", "def customers(options = {})\n perform_get_with_object('/customers', options, Epages::CustomersResponse)\n end", "def index\n @user = current_user\n @customers = @user.customers\n\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @customers }\n end\n end", "def customer_list\n perform_get_request('/customer/list')\n end", "def get_customers\n return ShopifyAPI::Customer.all\n end", "def index\n \tcustomers = Customer.all\n \trender json: customers\n \tend", "def customers\n ShopifyAPI::Customer.all\n end", "def get_customer(id)\n get(\"customers/#{id}\")\n end", "def get_customer(id)\n get(\"customers/#{id}\")\n end", "def customer(options = nil)\n request = Request.new(@client)\n path = \"/authorization-requests/\" + CGI.escape(@id) + \"/customers\"\n data = {\n\n }\n\n response = Response.new(request.get(path, data, options))\n return_values = Array.new\n \n body = response.body\n body = body[\"customer\"]\n customer = Customer(self._client)\n return_values.push(customer.fill_with_data(body))\n\n \n return_values[0]\n end", "def index\n @customers = Customer.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @customers }\n end\n end", "def list\n @customers = Customer.all\n\n respond_to do |format|\n format.html { render action: \"index\" }\n format.json { render json: @customers }\n end\n end", "def get_all_customers\r\n begin\r\n @logger.info(\"get_all_customers called.\")\r\n\r\n # prepare query url\r\n @logger.info(\"Preparing query URL for get_all_customers.\")\r\n _query_builder = Configuration.get_base_uri().clone\r\n _query_builder << '/customers'\r\n _query_url = APIHelper.clean_url _query_builder\r\n\r\n # prepare headers\r\n @logger.info(\"Preparing headers for get_all_customers.\")\r\n _headers = {\r\n 'accept' => 'application/json'\r\n }\r\n\r\n # prepare and execute HttpRequest\r\n @logger.info('Preparing and executing HttpRequest for get_all_customers.')\r\n _request = @http_client.get _query_url, headers: _headers\r\n BasicAuth.apply(_request)\r\n _context = execute_request(_request, name: 'get_all_customers')\r\n validate_response(_context)\r\n\r\n # return appropriate response type\r\n @logger.info(\"Returning response for get_all_customers.\")\r\n decoded = APIHelper.json_deserialize(_context.response.raw_body)\r\n return decoded.map{|element| CustomerModel.from_hash(element)}\r\n\r\n rescue Exception => e\r\n @logger.error(e)\r\n raise e\r\n end\r\n end", "def customer(customer_id)\n client.get \"customers/#{inst_id}/#{customer_id}\"\n end", "def index\n if current_user.role == 'customer_admin'\n render json: current_user.customer and return\n else\n authorize! :read_all, Customer\n customers = Customer.order('name asc')\n render json: customers and return\n end\n end", "def index\n @customers = Customer.where(:company_id => current_user.company.id).paginate(:page => params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @customers }\n end\n end", "def customer(customer_id)\n perform_get_request(\"/customer/#{customer_id}\")\n end", "def customers\n @customers ||= new_resource(self, :customer, :customers)\n end", "def index\n if params[:search_term]\n customers = Customer.search_customer(params[:search_term])\n else\n if read_from_cache(\"customers\")\n customers = read_from_cache(\"customers\")\n else\n customers = apply_scopes(Customer).all\n write_to_cache(\"customers\", customers)\n end\n end\n\n if params[:page_no]\n result = pagy(customers)\n else\n result = customers\n end\n render :json => result\n end", "def show\n @customer = Customer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @customer }\n end\n end", "def show\n @customer = Customer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @customer }\n end\n end", "def show\n @customer = Customer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @customer }\n end\n end", "def show\n @customer = Customer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @customer }\n end\n end", "def show\n @customer = Customer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @customer }\n end\n end", "def show\n @customer = Customer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @customer }\n end\n end", "def get_customers(opts = {})\n data, _status_code, _headers = get_customers_with_http_info(opts)\n data\n end", "def show\n render json: Customer.find(params[:id]).to_response, status: :ok\n end", "def customer(id)\n response = get(\"customers/#{id}\")\n response.customer\n end", "def get_customers(opts = {})\n data, _status_code, _headers = get_customers_with_http_info(opts)\n return data\n end", "def show\r\n @customer = Customer.find(params[:id])\r\n\r\n respond_to do |format|\r\n format.html # show.html.erb\r\n format.json { render :json => @customer }\r\n end\r\n end", "def index\n respond_to do |format|\n format.html\n format.json { render json: CustomersDatatable.new(view_context) }\n end\n @customers = Customer.all\n end", "def customers\n Easybill::Api::Customers\n end", "def all(params = {})\n handle_all_request(\"/customers\", :customers, params)\n end", "def index\n respond_to do |format|\n format.html { @customers = Customer.all }\n format.json { @customers = Customer.order(:name) }\n end\n end", "def show\n @cust = Cust.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @cust }\n end\n end", "def show\n @customers = Customer.all\n end", "def show\n @customers = Customer.all\n end", "def show\n @customer = Customer.includes(:invoices).find(params[:id].split(\",\"))\n\n render json: @customer\n end", "def get_customers_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: CustomerApi.get_customers ...\"\n end\n if @api_client.config.client_side_validation && !opts[:'page'].nil? && opts[:'page'] > 10000000\n fail ArgumentError, 'invalid value for \"opts[:\"page\"]\" when calling CustomerApi.get_customers, must be smaller than or equal to 10000000.'\n end\n\n if @api_client.config.client_side_validation && !opts[:'page'].nil? && opts[:'page'] < 1\n fail ArgumentError, 'invalid value for \"opts[:\"page\"]\" when calling CustomerApi.get_customers, must be greater than or equal to 1.'\n end\n\n if @api_client.config.client_side_validation && !opts[:'size'].nil? && opts[:'size'] > 100\n fail ArgumentError, 'invalid value for \"opts[:\"size\"]\" when calling CustomerApi.get_customers, must be smaller than or equal to 100.'\n end\n\n if @api_client.config.client_side_validation && !opts[:'size'].nil? && opts[:'size'] < 1\n fail ArgumentError, 'invalid value for \"opts[:\"size\"]\" when calling CustomerApi.get_customers, must be greater than or equal to 1.'\n end\n\n # resource path\n local_var_path = \"/v1/customer\"\n\n # query parameters\n query_params = {}\n query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?\n query_params[:'size'] = opts[:'size'] if !opts[:'size'].nil?\n query_params[:'search'] = opts[:'search'] if !opts[:'search'].nil?\n query_params[:'sort'] = opts[:'sort'] if !opts[:'sort'].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 = ['basicAuth']\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 => 'CustomerSearch')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: CustomerApi#get_customers\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def show\n customer = Customer.find(params[:id])\n authorize! :read, customer\n render json: customer\n end", "def list_customers(opts = {})\n operation('ListCustomers')\n .add(opts)\n\n run\n end", "def retrieve_customer(customer_id:)\n new_api_call_builder\n .request(new_request_builder(HttpMethodEnum::GET,\n '/v2/customers/{customer_id}',\n 'default')\n .template_param(new_parameter(customer_id, key: 'customer_id')\n .should_encode(true))\n .header_param(new_parameter('application/json', key: 'accept'))\n .auth(Single.new('global')))\n .response(new_response_handler\n .deserializer(APIHelper.method(:json_deserialize))\n .is_api_response(true)\n .convertor(ApiResponse.method(:create)))\n .execute\n end", "def show\n @customer = Customer.find(params[:customer_id])\n @contact = @customer.contacts.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render \"show.html.erb\", :layout => false }\n end\n end", "def index\n\t@customers = Customer.all()\n end", "def show\n @customer = Customer.find(params[:id])\n #@customer_types = CustomerType.find_all_by_customer_id(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @customer }\n end\n end", "def show\n @customer = Customer.find(params[:customer_id])\n @cust_contact = @customer.cust_contacts.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @cust_contact }\n end\n end", "def all(options = { page: 1, page_size: 10 })\n response = JSON.parse(@client.get('Customers', options).body)\n customers = response.key?('Items') ? response['Items'] : []\n customers.map { |attributes| Unleashed::Customer.new(@client, attributes) }\n end", "def get_customers_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: CustomersApi.get_customers ...'\n end\n allowable_values = [\"es\", \"en\"]\n if @api_client.config.client_side_validation && opts[:'accept_language'] && !allowable_values.include?(opts[:'accept_language'])\n fail ArgumentError, \"invalid value for \\\"accept_language\\\", must be one of #{allowable_values}\"\n end\n if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] > 250\n fail ArgumentError, 'invalid value for \"opts[:\"limit\"]\" when calling CustomersApi.get_customers, must be smaller than or equal to 250.'\n end\n\n if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] < 1\n fail ArgumentError, 'invalid value for \"opts[:\"limit\"]\" when calling CustomersApi.get_customers, must be greater than or equal to 1.'\n end\n\n # resource path\n local_var_path = '/customers'\n\n # query parameters\n query_params = opts[:query_params] || {}\n query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?\n query_params[:'search'] = opts[:'search'] if !opts[:'search'].nil?\n query_params[:'next'] = opts[:'_next'] if !opts[:'_next'].nil?\n query_params[:'previous'] = opts[:'previous'] if !opts[:'previous'].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/vnd.conekta-v2.1.0+json'])\n header_params[:'Accept-Language'] = opts[:'accept_language'] if !opts[:'accept_language'].nil?\n header_params[:'X-Child-Company-Id'] = opts[:'x_child_company_id'] if !opts[:'x_child_company_id'].nil?\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:debug_body]\n\n # return_type\n return_type = opts[:debug_return_type] || 'CustomersResponse'\n\n # auth_names\n auth_names = opts[:debug_auth_names] || ['bearerAuth']\n\n new_options = opts.merge(\n :operation => :\"CustomersApi.get_customers\",\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: CustomersApi#get_customers\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def customer\n @customer ||= fetcher.get(Customer, customer_id)\n end", "def index\n #data = HTTParty.get(\"http://localhost:8081/customers.json\")\n #p data.parsed_response[0]['email']\n if params[:customerId].present?\n @orders = Order.where(\"customerId\": params[:customerId].to_i)\n render json: @orders, status: 200\n elsif params[:id].present?\n @orders = Order.find_by id: params[:id]\n render json: @orders, status:200\n elsif params[:email].present?\n res = HTTParty.get(\"http://localhost:8081/customers/?email=#{params['email']}\")\n p res\n res = res.parsed_response\n @orders = Order.where(\"customerId\": res['id'].to_i)\n render json: @orders, status:200\n else\n @orders = Order.all\n end\n end", "def get_customer(opts = {})\n data, _status_code, _headers = get_customer_with_http_info(opts)\n data\n end", "def customerGet(options={})\n assert_valid_keys(options, :customerId)\n assert_keys_exists(options, :customerId)\n execute(:customerGet, options)\n end", "def customerGet(options={})\n assert_valid_keys(options, :customerId)\n assert_keys_exists(options, :customerId)\n execute(:customerGet, options)\n end", "def show\n @customer = customers.find(params[:id])\n end", "def retrieve(params = {})\n req = WebPay::CustomerIdRequest.create(params)\n raw_response = @client._request(:get, 'customers' + '/' + req.id.to_s, req)\n WebPay::CustomerResponse.new(raw_response)\n end", "def index\n @my_customers = MyCustomer.all\n end", "def customer(customer)\n id = epages_id(customer)\n perform_get_with_object(\"/customers/#{id}\", {}, Epages::Customer)\n end", "def index\n @customers_addresses = CustomersAddress.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @customers_addresses }\n end\n end", "def index\n @customers = Customer.where(user_id: current_user.id)\n end", "def get_customer_all_using_get_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: CustomerApi.get_customer_all_using_get ...'\n end\n # resource path\n local_var_path = '/customer'\n\n # query parameters\n query_params = {}\n query_params[:'ascending'] = opts[:'ascending'] if !opts[:'ascending'].nil?\n query_params[:'filter'] = opts[:'filter'] if !opts[:'filter'].nil?\n query_params[:'order_by'] = opts[:'order_by'] if !opts[:'order_by'].nil?\n query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?\n query_params[:'size'] = opts[:'size'] if !opts[:'size'].nil?\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['*/*'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['oauth2']\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 => 'PageCustomer')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: CustomerApi#get_customer_all_using_get\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def get_customer_profile\n authenticate_request!\n json_response(current_customer)\n end", "def listall\n return render :json => Customer.all.as_json(:only => [:id, :custID, :interested, :bought])\n end", "def index\n @clients = current_user.clients\n render json: @clients\n end", "def all_customers\n if @customer_records_file.nil? || !File.exist?(@customer_records_file)\n raise ArgumentError, 'Customer records file must be provided'\n end\n\n File.open(@customer_records_file, 'r') do |f|\n f.each_line.map do |line|\n JSON.parse(line)\n end\n end\n end", "def index\n #byebug\n #CHECK AUTHORIZATION HERE NOT JUST JUST AUTHENTICATION\n \n render json: {farmers: Farmer.all, customers: CustomerUser.all} #User.all #CustomerUser.all #{users: User.all, customers: Customer_User.all}\n end", "def all(params = {})\n req = WebPay::BasicListRequest.create(params)\n raw_response = @client._request(:get, 'customers', req)\n WebPay::CustomerResponseList.new(raw_response)\n end", "def index\n @users = User.fetch_all_customers\n end", "def index\n @customer_infos = CustomerInfo.all\n end", "def show\n @potential_customer = PotentialCustomer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @potential_customer }\n end\n end", "def list_customers_with_http_info(authorization, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: CustomerApi.list_customers ...\"\n end\n # verify the required parameter 'authorization' is set\n fail ArgumentError, \"Missing the required parameter 'authorization' when calling CustomerApi.list_customers\" if authorization.nil?\n # resource path\n local_var_path = \"/v2/customers\".sub('{format}','json')\n\n # query parameters\n query_params = {}\n query_params[:'cursor'] = opts[:'cursor'] if !opts[:'cursor'].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 # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n header_params[:'Authorization'] = authorization\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = []\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 => 'ListCustomersResponse')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: CustomerApi#list_customers\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def index\n @customers = get_customers(:page => params[:page])\n\n respond_to do |format|\n format.html # index.html.haml\n format.js # index.js.rjs\n format.xml { render :xml => @customers }\n end\n end", "def find(id)\n response = JSON.parse(@client.get(\"Customers/#{id}\").body)\n Unleashed::Customer.new(@client, response)\n end", "def index\n @customers = current_user.customers.paginate(:per_page => 20, :page => params[:page], :order => 'name', :include => :transactions)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @customers }\n end\n end", "def customer_single_orders\n @orders = Order.where(customer_id: current_user.customer_id, category: :single)\n render json: @orders, status: 200\n\n end", "def get_buildings_for_customer\n puts \"get_buildings_for_customer\"\n puts params\n @buildings = Building.where(\"customer_id = ?\", params[:customer_id])\n puts \"here are the buildings:\"\n puts @buildings\n respond_to do |format|\n format.json { render :json => @buildings }\n end\n end", "def show\n @custo = Custo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @custo }\n end\n end", "def customers\r\n @customers ||= CustomersController.new(configuration: @configuration)\r\n end", "def list\n display_customers\n end", "def index\n if !session[:user_id]\n redirect_to customer_path(session[:customer_id]) , notice: 'Access Denied'\n return\n else\n @customers = Customer.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @customers }\n end\n end\n end", "def show\n @user = User.find(params[:user_id])\n @customer = @user.customers.find(params[:id])\n @album = Album.new\n @albums = @customer.albums\n @notes = @customer.notes.order(\"created_at DESC\")\n @note = Note.new\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @customer }\n end\n end", "def retrieve_customer(customer_id:)\n # Prepare query url.\n _query_builder = config.get_base_uri\n _query_builder << '/v2/customers/{customer_id}'\n _query_builder = APIHelper.append_url_with_template_parameters(\n _query_builder,\n 'customer_id' => { 'value' => customer_id, 'encode' => true }\n )\n _query_url = APIHelper.clean_url _query_builder\n\n # Prepare headers.\n _headers = {\n 'accept' => 'application/json'\n }\n\n # Prepare and execute HttpRequest.\n _request = config.http_client.get(\n _query_url,\n headers: _headers\n )\n OAuth2.apply(config, _request)\n _response = execute_request(_request)\n\n # Return appropriate response type.\n decoded = APIHelper.json_deserialize(_response.raw_body)\n _errors = APIHelper.map_response(decoded, ['errors'])\n ApiResponse.new(\n _response, data: decoded, errors: _errors\n )\n end", "def show\n @address_customer = AddressCustomer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @address_customer }\n end\n end", "def get_customer_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: CustomerApi.get_customer ...'\n end\n # unbox the parameters from the hash\n customer_id = opts[:'customer_id']\n # verify the required parameter 'customer_id' is set\n if @api_client.config.client_side_validation && customer_id.nil?\n fail ArgumentError, \"Missing the required parameter 'customer_id' when calling CustomerApi.get_customer\"\n end\n # resource path\n local_var_path = '/customer/{customer_id}'.sub('{' + 'customer_id' + '}', CGI.escape(customer_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\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:debug_body]\n\n # return_type\n return_type = opts[:debug_return_type] || 'CustomerResponse'\n\n # auth_names\n auth_names = opts[:debug_auth_names] || ['token']\n\n new_options = opts.merge(\n :operation => :\"CustomerApi.get_customer\",\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: CustomerApi#get_customer\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def get_customers()\n customers = Customer.where(company_id: self.id).order(:name)\n\n return customers\n end", "def get_customers()\n customers = Customer.where(company_id: self.id).order(:name)\n\n return customers\n end", "def get_customers()\n customers = Customer.where(company_id: self.id).order(:name)\n\n return customers\n end", "def show\n @customers_address = CustomersAddress.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @customers_address }\n end\n end", "def show\n @customer = current_user.customers.find(params[:id], :include => :orders)\n @orders = @customer.orders.paginate(:per_page => current_user.profile.orders_per_page, :page => params[:page])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @customer }\n end\n end", "def customerGet(options = {})\n assert_valid_keys(options, :accessKey, :testMode, :customerId)\n assert_keys_exists(options, :customerId)\n execute(:customerGet, options)\n end" ]
[ "0.80477434", "0.7958279", "0.78736347", "0.7785999", "0.7759871", "0.7743631", "0.7737657", "0.7650475", "0.7650475", "0.7644552", "0.76392215", "0.7563173", "0.7439835", "0.74304175", "0.74225414", "0.7395726", "0.72824943", "0.72764957", "0.7261613", "0.72505057", "0.72505057", "0.72505057", "0.72505057", "0.72505057", "0.72505057", "0.7246176", "0.7164159", "0.71540767", "0.71252036", "0.70998544", "0.7064369", "0.7044635", "0.704376", "0.7032128", "0.70233333", "0.701189", "0.701189", "0.7005285", "0.70026886", "0.6963286", "0.69387186", "0.69202554", "0.68890417", "0.6884998", "0.68841976", "0.68797255", "0.68703926", "0.68688864", "0.6851613", "0.6848811", "0.68399435", "0.6809864", "0.6809864", "0.6806203", "0.6769007", "0.67645335", "0.6760816", "0.6709328", "0.6703903", "0.6700306", "0.6696879", "0.6674654", "0.66438556", "0.6619208", "0.66068345", "0.6605628", "0.6602157", "0.65904576", "0.65882844", "0.6588044", "0.65839577", "0.6561115", "0.6544067", "0.6523796", "0.6518941", "0.650751", "0.6504687", "0.65005046", "0.6484343", "0.64840835", "0.6483176", "0.64816195", "0.6471336", "0.64588046", "0.64588046", "0.64588046", "0.6435654", "0.6434578", "0.64324784" ]
0.6973055
49
GET /customers/1 GET /customers/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_customer(id)\n get(\"customers/#{id}\")\n end", "def get_customer(id)\n get(\"customers/#{id}\")\n end", "def index\n @customers = @user.customers.all\n render json: @customers\n end", "def index\n @user = current_user\n @customers = @user.customers\n\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @customers }\n end\n end", "def index\n \tcustomers = Customer.all\n \trender json: customers\n \tend", "def customer(customer_id)\n client.get \"customers/#{inst_id}/#{customer_id}\"\n end", "def index\n @customers = Customer.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @customers }\n end\n end", "def show\n render json: Customer.find(params[:id]).to_response, status: :ok\n end", "def show\n @customer = Customer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @customer }\n end\n end", "def show\n @customer = Customer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @customer }\n end\n end", "def show\n @customer = Customer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @customer }\n end\n end", "def show\n @customer = Customer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @customer }\n end\n end", "def show\n @customer = Customer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @customer }\n end\n end", "def show\n @customer = Customer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @customer }\n end\n end", "def list\n @customers = Customer.all\n\n respond_to do |format|\n format.html { render action: \"index\" }\n format.json { render json: @customers }\n end\n end", "def customer(options = nil)\n request = Request.new(@client)\n path = \"/authorization-requests/\" + CGI.escape(@id) + \"/customers\"\n data = {\n\n }\n\n response = Response.new(request.get(path, data, options))\n return_values = Array.new\n \n body = response.body\n body = body[\"customer\"]\n customer = Customer(self._client)\n return_values.push(customer.fill_with_data(body))\n\n \n return_values[0]\n end", "def customers\n ShopifyAPI::Customer.all\n end", "def show\n @cust = Cust.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @cust }\n end\n end", "def show\r\n @customer = Customer.find(params[:id])\r\n\r\n respond_to do |format|\r\n format.html # show.html.erb\r\n format.json { render :json => @customer }\r\n end\r\n end", "def customer(customer_id)\n perform_get_request(\"/customer/#{customer_id}\")\n end", "def index\n @customers = Customer.where(:company_id => current_user.company.id).paginate(:page => params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @customers }\n end\n end", "def customer_list\n perform_get_request('/customer/list')\n end", "def customers(options = {})\n perform_get_with_object('/customers', options, Epages::CustomersResponse)\n end", "def show\n @customer = Customer.includes(:invoices).find(params[:id].split(\",\"))\n\n render json: @customer\n end", "def customer(id)\n response = get(\"customers/#{id}\")\n response.customer\n end", "def index\n if current_user.role == 'customer_admin'\n render json: current_user.customer and return\n else\n authorize! :read_all, Customer\n customers = Customer.order('name asc')\n render json: customers and return\n end\n end", "def get_customers\n return ShopifyAPI::Customer.all\n end", "def retrieve_customer(customer_id:)\n new_api_call_builder\n .request(new_request_builder(HttpMethodEnum::GET,\n '/v2/customers/{customer_id}',\n 'default')\n .template_param(new_parameter(customer_id, key: 'customer_id')\n .should_encode(true))\n .header_param(new_parameter('application/json', key: 'accept'))\n .auth(Single.new('global')))\n .response(new_response_handler\n .deserializer(APIHelper.method(:json_deserialize))\n .is_api_response(true)\n .convertor(ApiResponse.method(:create)))\n .execute\n end", "def index\n if params[:search_term]\n customers = Customer.search_customer(params[:search_term])\n else\n if read_from_cache(\"customers\")\n customers = read_from_cache(\"customers\")\n else\n customers = apply_scopes(Customer).all\n write_to_cache(\"customers\", customers)\n end\n end\n\n if params[:page_no]\n result = pagy(customers)\n else\n result = customers\n end\n render :json => result\n end", "def show\n customer = Customer.find(params[:id])\n authorize! :read, customer\n render json: customer\n end", "def show\n @customer = Customer.find(params[:id])\n #@customer_types = CustomerType.find_all_by_customer_id(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @customer }\n end\n end", "def show\n @customer = customers.find(params[:id])\n end", "def index\n #data = HTTParty.get(\"http://localhost:8081/customers.json\")\n #p data.parsed_response[0]['email']\n if params[:customerId].present?\n @orders = Order.where(\"customerId\": params[:customerId].to_i)\n render json: @orders, status: 200\n elsif params[:id].present?\n @orders = Order.find_by id: params[:id]\n render json: @orders, status:200\n elsif params[:email].present?\n res = HTTParty.get(\"http://localhost:8081/customers/?email=#{params['email']}\")\n p res\n res = res.parsed_response\n @orders = Order.where(\"customerId\": res['id'].to_i)\n render json: @orders, status:200\n else\n @orders = Order.all\n end\n end", "def retrieve(params = {})\n req = WebPay::CustomerIdRequest.create(params)\n raw_response = @client._request(:get, 'customers' + '/' + req.id.to_s, req)\n WebPay::CustomerResponse.new(raw_response)\n end", "def index\n respond_to do |format|\n format.html\n format.json { render json: CustomersDatatable.new(view_context) }\n end\n @customers = Customer.all\n end", "def index\n respond_to do |format|\n format.html { @customers = Customer.all }\n format.json { @customers = Customer.order(:name) }\n end\n end", "def show\n @customer = Customer.find(params[:customer_id])\n @cust_contact = @customer.cust_contacts.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @cust_contact }\n end\n end", "def customer_single_orders\n @orders = Order.where(customer_id: current_user.customer_id, category: :single)\n render json: @orders, status: 200\n\n end", "def show\n @customer = Customer.find(params[:customer_id])\n @contact = @customer.contacts.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render \"show.html.erb\", :layout => false }\n end\n end", "def show\n @customers = Customer.all\n end", "def show\n @customers = Customer.all\n end", "def index\n @customers = Customer.all\n end", "def index\n @customers = Customer.all\n end", "def index\n @customers = Customer.all\n end", "def index\n @customers = Customer.all\n end", "def index\n @customers = Customer.all\n end", "def index\n @customers = Customer.all\n end", "def index\n @customers = Customer.all\n end", "def index\n @customers = Customer.all\n end", "def index\n @customers = Customer.all\n end", "def index\n @customers = Customer.all\n end", "def index\n @customers = Customer.all\n end", "def index\n @customers = Customer.all\n end", "def get_customers_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: CustomerApi.get_customers ...\"\n end\n if @api_client.config.client_side_validation && !opts[:'page'].nil? && opts[:'page'] > 10000000\n fail ArgumentError, 'invalid value for \"opts[:\"page\"]\" when calling CustomerApi.get_customers, must be smaller than or equal to 10000000.'\n end\n\n if @api_client.config.client_side_validation && !opts[:'page'].nil? && opts[:'page'] < 1\n fail ArgumentError, 'invalid value for \"opts[:\"page\"]\" when calling CustomerApi.get_customers, must be greater than or equal to 1.'\n end\n\n if @api_client.config.client_side_validation && !opts[:'size'].nil? && opts[:'size'] > 100\n fail ArgumentError, 'invalid value for \"opts[:\"size\"]\" when calling CustomerApi.get_customers, must be smaller than or equal to 100.'\n end\n\n if @api_client.config.client_side_validation && !opts[:'size'].nil? && opts[:'size'] < 1\n fail ArgumentError, 'invalid value for \"opts[:\"size\"]\" when calling CustomerApi.get_customers, must be greater than or equal to 1.'\n end\n\n # resource path\n local_var_path = \"/v1/customer\"\n\n # query parameters\n query_params = {}\n query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?\n query_params[:'size'] = opts[:'size'] if !opts[:'size'].nil?\n query_params[:'search'] = opts[:'search'] if !opts[:'search'].nil?\n query_params[:'sort'] = opts[:'sort'] if !opts[:'sort'].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 = ['basicAuth']\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 => 'CustomerSearch')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: CustomerApi#get_customers\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def get_all_customers\r\n begin\r\n @logger.info(\"get_all_customers called.\")\r\n\r\n # prepare query url\r\n @logger.info(\"Preparing query URL for get_all_customers.\")\r\n _query_builder = Configuration.get_base_uri().clone\r\n _query_builder << '/customers'\r\n _query_url = APIHelper.clean_url _query_builder\r\n\r\n # prepare headers\r\n @logger.info(\"Preparing headers for get_all_customers.\")\r\n _headers = {\r\n 'accept' => 'application/json'\r\n }\r\n\r\n # prepare and execute HttpRequest\r\n @logger.info('Preparing and executing HttpRequest for get_all_customers.')\r\n _request = @http_client.get _query_url, headers: _headers\r\n BasicAuth.apply(_request)\r\n _context = execute_request(_request, name: 'get_all_customers')\r\n validate_response(_context)\r\n\r\n # return appropriate response type\r\n @logger.info(\"Returning response for get_all_customers.\")\r\n decoded = APIHelper.json_deserialize(_context.response.raw_body)\r\n return decoded.map{|element| CustomerModel.from_hash(element)}\r\n\r\n rescue Exception => e\r\n @logger.error(e)\r\n raise e\r\n end\r\n end", "def show\n @potential_customer = PotentialCustomer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @potential_customer }\n end\n end", "def show\n @custo = Custo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @custo }\n end\n end", "def customers\n @customers ||= new_resource(self, :customer, :customers)\n end", "def customer\n @customer ||= fetcher.get(Customer, customer_id)\n end", "def index\n\t@customers = Customer.all()\n end", "def find(id)\n response = JSON.parse(@client.get(\"Customers/#{id}\").body)\n Unleashed::Customer.new(@client, response)\n end", "def show\n @address_customer = AddressCustomer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @address_customer }\n end\n end", "def show\n @credit = Credit.find_by_customer_id(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @credit }\n end\n end", "def index\n @customers_addresses = CustomersAddress.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @customers_addresses }\n end\n end", "def show\n @customer = Customer.find(params[:id])\n end", "def show\n @customer = Customer.find(params[:id])\n end", "def index\n @my_customers = MyCustomer.all\n end", "def show\n @type_customer = TypeCustomer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @type_customer }\n end\n end", "def get_buildings_for_customer\n puts \"get_buildings_for_customer\"\n puts params\n @buildings = Building.where(\"customer_id = ?\", params[:customer_id])\n puts \"here are the buildings:\"\n puts @buildings\n respond_to do |format|\n format.json { render :json => @buildings }\n end\n end", "def customer(customer)\n id = epages_id(customer)\n perform_get_with_object(\"/customers/#{id}\", {}, Epages::Customer)\n end", "def show\n @customers_address = CustomersAddress.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @customers_address }\n end\n end", "def customerGet(options={})\n assert_valid_keys(options, :customerId)\n assert_keys_exists(options, :customerId)\n execute(:customerGet, options)\n end", "def customerGet(options={})\n assert_valid_keys(options, :customerId)\n assert_keys_exists(options, :customerId)\n execute(:customerGet, options)\n end", "def all(params = {})\n handle_all_request(\"/customers\", :customers, params)\n end", "def index\n @clients = current_user.clients\n render json: @clients\n end", "def retrieve_customer(customer_id:)\n # Prepare query url.\n _query_builder = config.get_base_uri\n _query_builder << '/v2/customers/{customer_id}'\n _query_builder = APIHelper.append_url_with_template_parameters(\n _query_builder,\n 'customer_id' => { 'value' => customer_id, 'encode' => true }\n )\n _query_url = APIHelper.clean_url _query_builder\n\n # Prepare headers.\n _headers = {\n 'accept' => 'application/json'\n }\n\n # Prepare and execute HttpRequest.\n _request = config.http_client.get(\n _query_url,\n headers: _headers\n )\n OAuth2.apply(config, _request)\n _response = execute_request(_request)\n\n # Return appropriate response type.\n decoded = APIHelper.json_deserialize(_response.raw_body)\n _errors = APIHelper.map_response(decoded, ['errors'])\n ApiResponse.new(\n _response, data: decoded, errors: _errors\n )\n end", "def show\n @customer_bill = CustomerBill.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @customer_bill }\n end\n end", "def index\n @customers = get_customers(:page => params[:page])\n\n respond_to do |format|\n format.html # index.html.haml\n format.js # index.js.rjs\n format.xml { render :xml => @customers }\n end\n end", "def show\n @customer = Customer.find(params[:id])\t\n end", "def customers\n Easybill::Api::Customers\n end", "def show\n @customer = Customer.where(:id => params[:id], :company_id => current_user.company.id).first\n @appointments = Appointment.where(:company_id => current_user.company.id, :customer_id => @customer.id).order('starts_at DESC').paginate(:page => params[:page])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @customer }\n end\n end", "def get_customer_profile\n authenticate_request!\n json_response(current_customer)\n end", "def get_customers_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: CustomersApi.get_customers ...'\n end\n allowable_values = [\"es\", \"en\"]\n if @api_client.config.client_side_validation && opts[:'accept_language'] && !allowable_values.include?(opts[:'accept_language'])\n fail ArgumentError, \"invalid value for \\\"accept_language\\\", must be one of #{allowable_values}\"\n end\n if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] > 250\n fail ArgumentError, 'invalid value for \"opts[:\"limit\"]\" when calling CustomersApi.get_customers, must be smaller than or equal to 250.'\n end\n\n if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] < 1\n fail ArgumentError, 'invalid value for \"opts[:\"limit\"]\" when calling CustomersApi.get_customers, must be greater than or equal to 1.'\n end\n\n # resource path\n local_var_path = '/customers'\n\n # query parameters\n query_params = opts[:query_params] || {}\n query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?\n query_params[:'search'] = opts[:'search'] if !opts[:'search'].nil?\n query_params[:'next'] = opts[:'_next'] if !opts[:'_next'].nil?\n query_params[:'previous'] = opts[:'previous'] if !opts[:'previous'].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/vnd.conekta-v2.1.0+json'])\n header_params[:'Accept-Language'] = opts[:'accept_language'] if !opts[:'accept_language'].nil?\n header_params[:'X-Child-Company-Id'] = opts[:'x_child_company_id'] if !opts[:'x_child_company_id'].nil?\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:debug_body]\n\n # return_type\n return_type = opts[:debug_return_type] || 'CustomersResponse'\n\n # auth_names\n auth_names = opts[:debug_auth_names] || ['bearerAuth']\n\n new_options = opts.merge(\n :operation => :\"CustomersApi.get_customers\",\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: CustomersApi#get_customers\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def listall\n return render :json => Customer.all.as_json(:only => [:id, :custID, :interested, :bought])\n end", "def show_customer\n @customer = Customer.find(params[:id])\n end", "def show\n @offer_customer = OfferCustomer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @offer_customer }\n end\n end", "def index\n @single_customers = SingleCustomer.managed_by_users(current_user.direct_subordinates_with_self.collect(&:id)).page params[:page]\n end", "def index\n @customer_infos = CustomerInfo.all\n end", "def get_customer_all_using_get_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: CustomerApi.get_customer_all_using_get ...'\n end\n # resource path\n local_var_path = '/customer'\n\n # query parameters\n query_params = {}\n query_params[:'ascending'] = opts[:'ascending'] if !opts[:'ascending'].nil?\n query_params[:'filter'] = opts[:'filter'] if !opts[:'filter'].nil?\n query_params[:'order_by'] = opts[:'order_by'] if !opts[:'order_by'].nil?\n query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?\n query_params[:'size'] = opts[:'size'] if !opts[:'size'].nil?\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['*/*'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['oauth2']\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 => 'PageCustomer')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: CustomerApi#get_customer_all_using_get\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def show\n client = Client.retrieve_by_id(params[:id])\n\n render json: client, serializer: SingleClientSerializer\n end", "def show\n @user = User.find(params[:user_id])\n @customer = @user.customers.find(params[:id])\n @album = Album.new\n @albums = @customer.albums\n @notes = @customer.notes.order(\"created_at DESC\")\n @note = Note.new\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @customer }\n end\n end", "def index\n @customers = Customer.where(user_id: current_user.id)\n end", "def get_customers(opts = {})\n data, _status_code, _headers = get_customers_with_http_info(opts)\n data\n end", "def show\n @customer_asset = CustomerAsset.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @customer_asset }\n end\n end", "def index\n if !session[:user_id]\n redirect_to customer_path(session[:customer_id]) , notice: 'Access Denied'\n return\n else\n @customers = Customer.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @customers }\n end\n end\n end", "def new\n @customer = Customer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @customer }\n end\n end", "def new\n @customer = Customer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @customer }\n end\n end", "def new\n @customer = Customer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @customer }\n end\n end", "def new\n @customer = Customer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @customer }\n end\n end", "def new\n @customer = Customer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @customer }\n end\n end", "def get_customer_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: CustomerApi.get_customer ...'\n end\n # unbox the parameters from the hash\n customer_id = opts[:'customer_id']\n # verify the required parameter 'customer_id' is set\n if @api_client.config.client_side_validation && customer_id.nil?\n fail ArgumentError, \"Missing the required parameter 'customer_id' when calling CustomerApi.get_customer\"\n end\n # resource path\n local_var_path = '/customer/{customer_id}'.sub('{' + 'customer_id' + '}', CGI.escape(customer_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\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:debug_body]\n\n # return_type\n return_type = opts[:debug_return_type] || 'CustomerResponse'\n\n # auth_names\n auth_names = opts[:debug_auth_names] || ['token']\n\n new_options = opts.merge(\n :operation => :\"CustomerApi.get_customer\",\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: CustomerApi#get_customer\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end" ]
[ "0.78554344", "0.78554344", "0.76806945", "0.76002246", "0.75336385", "0.75142324", "0.7499966", "0.7383746", "0.73374355", "0.73374355", "0.73374355", "0.73374355", "0.73374355", "0.73374355", "0.73158854", "0.7307321", "0.7280559", "0.7196479", "0.71882653", "0.7170412", "0.71687007", "0.71634656", "0.7156029", "0.7128544", "0.7062532", "0.70490026", "0.70394504", "0.70093465", "0.69680434", "0.69489646", "0.69230807", "0.6913869", "0.6898895", "0.68943906", "0.68752015", "0.6873907", "0.6847036", "0.6835131", "0.67868996", "0.6743083", "0.6743083", "0.67356193", "0.67356193", "0.67356193", "0.67356193", "0.67356193", "0.67356193", "0.67356193", "0.67356193", "0.67356193", "0.67356193", "0.67356193", "0.67356193", "0.67159927", "0.67145705", "0.67017853", "0.6699028", "0.6687688", "0.66403407", "0.6637866", "0.66378516", "0.6626242", "0.6612537", "0.6589904", "0.6585624", "0.6585624", "0.65846956", "0.6580105", "0.6563078", "0.6546706", "0.6536853", "0.65340304", "0.65340304", "0.6517796", "0.65038127", "0.6499956", "0.649454", "0.6491151", "0.64800376", "0.64747965", "0.64691156", "0.6462398", "0.6450213", "0.6413793", "0.6411974", "0.6410347", "0.640912", "0.63989264", "0.63975537", "0.6390816", "0.6388538", "0.63877213", "0.63801885", "0.63463145", "0.63452756", "0.6339775", "0.6339775", "0.6339775", "0.6339775", "0.6339775", "0.6324331" ]
0.0
-1
POST /customers POST /customers.json
def create coupon_id = params[:customer][:coupon_id] c = Coupon.find(coupon_id) @r = Restaurant.find(c.restaurant_id) @customer_phone = params[:customer][:phone_number] if Customer.find_by_phone_number(@customer_phone).nil? @customer = Customer.new(customer_params) respond_to do |format| if @customer.save Subscription.create(customer_id: @customer.id, restaurant_id: @r.id, status: true) send_sms(@customer.phone_number) format.html { redirect_to coupons_path, notice: 'Subscription was successfully created.' } format.json { render :show, status: :created, location: @customer } else format.html { render :new } format.json { render json: @customer.errors, status: :unprocessable_entity } end end else @current_customer = Customer.find_by_phone_number(@customer_phone) Subscription.create(customer_id: @current_customer.id, restaurant_id: @r.id, status: true) send_sms(@current_customer.phone_number) respond_to do |format| format.html { redirect_to coupons_path , notice: 'Subscription was successfully created.' } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @customer = @user.customers.build(customer_params)\n if @customer.save\n render json: @customer, status: :created\n else\n render json: @customer.errors, status: :unprocessable_entity\n end\n\n end", "def create_customer(*args)\n options = args.last.is_a?(Hash) ? args.pop : {}\n response = post(\"customers\",options)\n if response['success']\n return response['results']['customer']\n else\n return response\n end\n end", "def create\n @customer = Customer.new(customer_params)\n\n if @customer.save\n render json: @customer, status: :created, location: @customer\n else\n ap errors(@customer.errors)\n render json: errors(@customer.errors), status: :unprocessable_entity\n end\n end", "def send_customer(customer)\n request(customer, \"customer\", :post, {method: \"add\"})\n end", "def create(payload)\n client.post(make_path('/customers'), payload)\n end", "def create\n @customer = Customer.new(customer_params)\n\n respond_to do |format|\n if @customer.save\n format.html { redirect_to customers_path, notice: 'Customer was successfully created.' }\n format.json { render :show, status: :created, location: @customer }\n else\n format.html { render :new }\n format.json { render json: @customer.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @customer = Customer.new(customer_params)\n\n respond_to do |format|\n if @customer.save\n format.html { redirect_to @customer, notice: 'Customer was successfully created.' }\n format.json { render json: @customer, status: :created }\n else\n format.html { render :new }\n format.json { render json: @customer.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @customer = Customer.new(customer_params)\n\n respond_to do |format|\n if @customer.save\n format.html { redirect_to @customer, notice: 'Customer was successfully added.' }\n format.json { render :show, status: :created, location: @customer }\n else\n format.html { render :index }\n format.json { render json: @customer.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @customer = Customer.new(customer_params.map{|k,v| {k.to_sym => v.class == ActionController::Parameters ? [v.to_hash] : v.to_s}}.reduce({}, :merge))\n\n respond_to do |format|\n if @customer.save\n format.html { redirect_to @customer, notice: 'Customer was successfully created.' }\n format.json { render :show, status: :created, location: @customer }\n else\n format.html { render :new }\n format.json { render json: @customer.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @customer = Customer.new(params[:customer])\n\n respond_to do |format|\n if @customer.save\n format.html { redirect_to action: \"index\", notice: 'Customer was successfully created.' }\n format.json { render json: @customer, status: :created, location: @customer }\n else\n format.html { render action: \"new\" }\n format.json { render json: @customer.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_customer(options = {})\n perform_post_with_object('/customers', options, Epages::Customer)\n end", "def create_customer(body:)\n new_api_call_builder\n .request(new_request_builder(HttpMethodEnum::POST,\n '/v2/customers',\n 'default')\n .header_param(new_parameter('application/json', key: 'Content-Type'))\n .body_param(new_parameter(body))\n .header_param(new_parameter('application/json', key: 'accept'))\n .body_serializer(proc do |param| param.to_json unless param.nil? end)\n .auth(Single.new('global')))\n .response(new_response_handler\n .deserializer(APIHelper.method(:json_deserialize))\n .is_api_response(true)\n .convertor(ApiResponse.method(:create)))\n .execute\n end", "def create\n @customer = Customer.new(params[:customer])\n\n respond_to do |format|\n if @customer.save\n format.html { redirect_to @customer, notice: 'Customer was successfully created.' }\n format.json { render json: @customer, status: :created, location: @customer }\n else\n format.html { render action: \"new\" }\n format.json { render json: @customer.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @customer = Customer.new(params[:customer])\n\n respond_to do |format|\n if @customer.save\n format.html { redirect_to @customer, notice: 'Customer was successfully created.' }\n format.json { render json: @customer, status: :created, location: @customer }\n else\n format.html { render action: \"new\" }\n format.json { render json: @customer.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n\n @customer = Customer.new(customer_params)\n\n respond_to do |format|\n if @customer.save\n format.html { redirect_to @customer, notice: 'Customer was successfully created.' }\n format.json { render :show, status: :created, location: @customer }\n else\n format.html { render :new }\n format.json { render json: @customer.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_customer(customer_info, password)\n post_wrapper('/V1/customers',\n { customer: customer_info,\n password: password }.to_json,\n admin_headers)\n end", "def create\n @customer = Customer.new(customer_params)\n\n respond_to do |format|\n if @customer.save\n format.html { redirect_to @customer, notice: \"Customer was successfully created.\" }\n format.json { render :show, status: :created, location: @customer }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @customer.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @customer = Customer.new(customer_params)\n\n respond_to do |format|\n if @customer.save\n format.html { redirect_to @customer, notice: 'Customer was successfully created.' }\n format.json { render :show, status: :created, location: @customer }\n else\n format.html { render :new }\n format.json { render json: @customer.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @customer = Customer.new(customer_params)\n\n respond_to do |format|\n if @customer.save\n format.html { redirect_to @customer, notice: 'Customer was successfully created.' }\n format.json { render :show, status: :created, location: @customer }\n else\n format.html { render :new }\n format.json { render json: @customer.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @customer = Customer.new(customer_params)\n\n respond_to do |format|\n if @customer.save\n format.html { redirect_to @customer, notice: 'Customer was successfully created.' }\n format.json { render :show, status: :created, location: @customer }\n else\n format.html { render :new }\n format.json { render json: @customer.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @customer = Customer.new(customer_params)\n\n respond_to do |format|\n if @customer.save\n format.html { redirect_to @customer, notice: 'Customer was successfully created.' }\n format.json { render :show, status: :created, location: @customer }\n else\n format.html { render :new }\n format.json { render json: @customer.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @customer = Customer.new(customer_params)\n\n respond_to do |format|\n if @customer.save\n format.html { redirect_to @customer, notice: 'Customer was successfully created.' }\n format.json { render :show, status: :created, location: @customer }\n else\n format.html { render :new }\n format.json { render json: @customer.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @customer = Customer.new(customer_params)\n\n respond_to do |format|\n if @customer.save\n format.html { redirect_to @customer, notice: 'Customer was successfully created.' }\n format.json { render :show, status: :created, location: @customer }\n else\n format.html { render :new }\n format.json { render json: @customer.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @customer = Customer.new(customer_params)\n \n respond_to do |format|\n if @customer.save\n format.html { redirect_to @customer, notice: 'Customer was successfully created.' }\n format.json { render :show, status: :created, location: @customer }\n else\n format.html { render 'new' }\n format.json { render json: @customer.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n # whitelist params\n @customer = Customer.new(customer_params)\n respond_to do |format|\n if @customer.save\n format.html { redirect_to customers_path }\n format.json { render :show, status: :ok, location: @customer }\n format.json { render :json => @objects.map(&:attributes) }\n else\n format.html { render :new, warning: \"Customer record was NOT saved.\"}\n format.json { render json: @customer.errors, status: :unprocessable_entity }\n end\n end\n end", "def createCustomer(customer_properties)\n url_data = \"/api/customers/\"\n @json_customer_properties = customer_properties.to_json\n options = {\n :digest_auth => @auth_digest,\n :body => @json_customer_properties\n }\n url_request = \"#{url_data}\"\n postData(url_request, options)\n end", "def create\n @customer = Customer.new(customer_params)\n\n respond_to do |format|\n if @customer.save\n format.html { redirect_to @customer, notice: 'Cliente cadastrado com sucesso!' }\n format.json { render :show, status: :created, location: @customer }\n else\n format.html { render :new }\n format.json { render json: @customer.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @customer = Customer.new(customer_params)\n respond_to do |format|\n if @customer.save\n format.html { redirect_to @customer, notice: 'Customer was successfully created.' }\n format.json { render action: 'show', status: :created, location: @customer }\n else\n format.html { render action: 'new' }\n format.json { render json: @customer.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n authorize! :create, Customer\n @customer = Customer.new(customer_params)\n @customer.customer_admin = current_user\n\n if @customer.save\n render json: nil, status: :created\n else\n render json: @customer.errors.full_messages, status: :unprocessable_entity\n end\n end", "def create\n @customer = Customer.new(customer_params)\n\n respond_to do |format|\n if @customer.save\n format.html { redirect_to @customer, notice: 'Customer was successfully created.' }\n format.json { render action: 'show', status: :created, location: @customer }\n else\n format.html { render action: 'new' }\n format.json { render json: @customer.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\r\n @customer = Customer.new(params[:customer])\r\n\r\n respond_to do |format|\r\n if @customer.save\r\n format.html { redirect_to '/auth/identity/register', :notice => 'Customer was successfully created.' }\r\n format.json { render :json => @customer, :status => :created, :location => @customer }\r\n else\r\n format.html { render :action => \"new\" }\r\n format.json { render :json => @customer.errors, :status => :unprocessable_entity }\r\n end\r\n end\r\n end", "def create_customer\n begin\n customer = Stripe::Customer.create\n # Create customer successful - return its id\n log_info(\"Customer created with ID #{customer[:id]}\")\n rescue Stripe::StripeError => e\n return_error 402, \"Error creating customer #{e.message}\"\n end\n status 201\n { customer_id: customer.id }.to_json\n end", "def create\n #@customer = Customer.new(params[:customer].merge(:user_id => current_user.id))\n @customer = Customer.new(params[:customer])\n\n respond_to do |format|\n if @customer.save\n format.html { redirect_to customers_path, notice: 'Customer was successfully created.' }\n format.json { render json: @customer, status: :created, location: @customer }\n else\n format.html { render action: \"new\" }\n format.json { render json: @customer.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @customer = Customer.new(customer_params)\n\n respond_to do |format|\n if @customer.save\n format.html { redirect_to admin_customer_path(@customer), notice: 'Customer was successfully created.' }\n format.json { render :show, status: :created, location: @customer }\n else\n format.html { render :new }\n format.json { render json: @customer.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @customer = Customer.new(params[:customer])\n @customer.company = Company.find(current_user.company.id)\n\n respond_to do |format|\n if @customer.save\n format.html {\n flash[:notice] = I18n.t(:successfully_created, :model_name => Customer.model_name.human)\n redirect_to action: 'index'\n }\n format.json {\n render :json => {\n :listPartial => render_to_string(\n 'customers/_list',\n :formats => [:html],\n :layout => false,\n :locals => {\n :customers => Customer.where(:company_id => current_user.company.id).paginate(:page => params[:page])\n }\n ),\n status: :created,\n location: @customer\n }\n }\n else\n format.html { render action: \"new\" }\n format.json { render json: @customer.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n \n @customer = Customer.new(customer_params)\n @user = current_user\n respond_to do |format|\n if @customer.save\n @customer.update!(user_id: @user.id)\n format.html { redirect_to customers_path, notice: 'Customer was successfully created.' }\n format.json { render :show, status: :created, location: @customer }\n else\n format.html { render :new }\n format.json { render json: @customer.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @customer = Customer.new(customer_params)\n\n respond_to do |format|\n if @customer.save\n format.html { redirect_to @customer, notice: t(\"activerecord.controller_msg.customer.created\", :default => 'Customer was successfully created.') }\n format.json { render :show, status: :created, location: @customer }\n else\n format.html { render :new }\n format.json { render json: @customer.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @customer = Customer.new(customer_params)\n\n respond_to do |format|\n if @customer.save\n format.html { redirect_to @customer, \n notice: \"Customer #{@customer.email} was successfully created.\" }\n format.json { render action: \"show\", status: :created, location: @customer }\n else\n format.html { render action: \"new\" }\n format.json { render json: @customer.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @customer_customer = Customer::Customer.new(customer_customer_params)\n @customer_customer.admin = current_admin\n\n respond_to do |format|\n if @customer_customer.save\n format.html { redirect_to @customer_customer, notice: 'Customer was successfully created.' }\n format.json { render :show, status: :created, location: @customer_customer }\n else\n format.html { render :new }\n format.json { render json: @customer_customer.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @customers = @user.customers.all\n render json: @customers\n end", "def customer(options = nil)\n request = Request.new(@client)\n path = \"/authorization-requests/\" + CGI.escape(@id) + \"/customers\"\n data = {\n\n }\n\n response = Response.new(request.get(path, data, options))\n return_values = Array.new\n \n body = response.body\n body = body[\"customer\"]\n customer = Customer(self._client)\n return_values.push(customer.fill_with_data(body))\n\n \n return_values[0]\n end", "def create\n @customer = Customer.new(customer_params)\n\n respond_to do |format|\n if @customer.save\n format.html { redirect_to [:admin, @customer], notice: t('messages.created', model:Customer.model_name.human) }\n format.json { render action: 'show', status: :created, location: @customer }\n else\n format.html { render action: 'new' }\n format.json { render json: @customer.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @customer = Customer.new(customer_params)\n @customer.user = current_user\n authorize @customer, :create?\n\n respond_to do |format|\n if @customer.save\n @customer.works.create!(trackable_url: \"#{customer_path(@customer)}\", action: :create, user: current_user, \n parameters: @customer.to_json(except: {customer: [:fullname_and_address_and_pesel_nip_and_birth_date]}, \n include: { \n user: {\n only: [:id, :name, :email] } \n }))\n\n flash_message :success, t('activerecord.messages.successfull.created', data: @customer.fullname)\n format.html { redirect_to @customer }\n format.json { render :show, status: :created, location: @customer }\n else\n format.html { render :new }\n format.json { render json: @customer.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @customer = current_user.customers.new(params[:customer])\n\n respond_to do |format|\n if @customer.save\n format.xml { render :xml => @customer, :status => :created, :location => @customer }\n format.js\n else\n format.xml { render :xml => @customer.errors, :status => :unprocessable_entity }\n format.js\n end\n end\n end", "def create\n @cust = Cust.new(params[:cust])\n\n respond_to do |format|\n if @cust.save\n format.html { redirect_to @cust, notice: 'Cust was successfully created.' }\n format.json { render json: @cust, status: :created, location: @cust }\n else\n format.html { render action: \"new\" }\n format.json { render json: @cust.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @user = current_user\n @customer = @user.customers.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @customer }\n end\n end", "def customers\n @customers ||= new_resource(self, :customer, :customers)\n end", "def create\n @customer = Customer.new(params[:customer])\n\n respond_to do |format|\n if @customer.save\n format.html { redirect_to @customer, notice: 'Customer was successfully created.' }\n #format.html { redirect_to new_work_servey_path(:customer_id => @customer.id), notice: 'Customer was successfully created.' }\n format.json { render json: @customer, status: :created, location: @customer }\n else\n format.html { render action: \"new\" }\n format.json { render json: @customer.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_customer_using_post_with_http_info(customer, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: CustomerApi.create_customer_using_post ...'\n end\n # verify the required parameter 'customer' is set\n if @api_client.config.client_side_validation && customer.nil?\n fail ArgumentError, \"Missing the required parameter 'customer' when calling CustomerApi.create_customer_using_post\"\n end\n # resource path\n local_var_path = '/customer'\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(['*/*'])\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(customer)\n auth_names = ['oauth2']\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 => 'Customer')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: CustomerApi#create_customer_using_post\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def test_create_customer()\n # Parameters for the API call\n body = APIHelper.json_deserialize(\n '{\"given_name\":\"Amelia\",\"family_name\":\"Earhart\",\"email_address\":\"Amelia.Ear'\\\n 'hart@example.com\",\"address\":{\"address_line_1\":\"500 Electric Ave\",\"address_l'\\\n 'ine_2\":\"Suite 600\",\"locality\":\"New York\"},\"phone_number\":\"1-212-555-4240\",\"'\\\n 'reference_id\":\"YOUR_REFERENCE_ID\",\"note\":\"a customer\"}'\n )\n\n # Perform the API call through the SDK function\n result = @controller.create_customer(body: body)\n\n # Test response code\n assert_equal(200, @response_catcher.response.status_code)\n end", "def create\n @customer = Customer.new(customer_params)\n @projects = Project.all\n respond_to do |format|\n if @customer.save\n format.html { redirect_to @customer, notice: 'Customer was successfully created.' }\n format.json { render action: 'show', status: :created, location: @customer }\n else\n format.html { render action: 'new' }\n format.json { render json: @customer.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_customer(body:)\n # Prepare query url.\n _query_builder = config.get_base_uri\n _query_builder << '/v2/customers'\n _query_url = APIHelper.clean_url _query_builder\n\n # Prepare headers.\n _headers = {\n 'accept' => 'application/json',\n 'content-type' => 'application/json; charset=utf-8'\n }\n\n # Prepare and execute HttpRequest.\n _request = config.http_client.post(\n _query_url,\n headers: _headers,\n parameters: body.to_json\n )\n OAuth2.apply(config, _request)\n _response = execute_request(_request)\n\n # Return appropriate response type.\n decoded = APIHelper.json_deserialize(_response.raw_body)\n _errors = APIHelper.map_response(decoded, ['errors'])\n ApiResponse.new(\n _response, data: decoded, errors: _errors\n )\n end", "def customer_create\n @customer = Person.new(person_params)\n respond_to do |format|\n if @customer.save\n format.html { redirect_to new_customer_path, notice: 'データが新規作成されました。' }\n format.json { render :customer_show, status: :created, location: @customer }\n else\n format.html { redirect_to new_customer_path }\n format.json { render json: @customer.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_customer_with_http_info(customer, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: CustomersApi.create_customer ...'\n end\n # verify the required parameter 'customer' is set\n if @api_client.config.client_side_validation && customer.nil?\n fail ArgumentError, \"Missing the required parameter 'customer' when calling CustomersApi.create_customer\"\n end\n allowable_values = [\"es\", \"en\"]\n if @api_client.config.client_side_validation && opts[:'accept_language'] && !allowable_values.include?(opts[:'accept_language'])\n fail ArgumentError, \"invalid value for \\\"accept_language\\\", must be one of #{allowable_values}\"\n end\n # resource path\n local_var_path = '/customers'\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/vnd.conekta-v2.1.0+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 header_params[:'Accept-Language'] = opts[:'accept_language'] if !opts[:'accept_language'].nil?\n header_params[:'X-Child-Company-Id'] = opts[:'x_child_company_id'] if !opts[:'x_child_company_id'].nil?\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(customer)\n\n # return_type\n return_type = opts[:debug_return_type] || 'CustomerResponse'\n\n # auth_names\n auth_names = opts[:debug_auth_names] || ['bearerAuth']\n\n new_options = opts.merge(\n :operation => :\"CustomersApi.create_customer\",\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: CustomersApi#create_customer\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def create\n @customer = Customer.where(:fullname => params[:customer][:fullname], :phone => params[:customer][:phone]).first\n\n if @customer\n respond_to do |format|\n #format.html { redirect_to :back }\n format.json { render :json => @customer, :status => 200 }\n end\n else\n @customer = Customer.new(params[:customer])\n\n respond_to do |format|\n if @customer.save\n #format.html { redirect_to customers_path, notice: 'Customer was successfully created.' }\n format.json { render :json=> @customer, :status=> :created }\n else\n #format.html { render action: \"new\" }\n format.json { render :json=> @customer.errors, :status=> :unprocessable_entity }\n end\n end\n end\n end", "def create_customer\n @customer = ::Customer.create!(client_id: @client.id,\n status: GlobalConstant::Customer.active_status,\n details: @customer_details\n )\n success\n end", "def create\n @customer = Customer.new(params[:customer])\n\n respond_to do |format|\n if @customer.save\n UserMailer.welcome_customer(@customer).deliver\n format.html { redirect_to @customer, notice: 'Customer was successfully created.' }\n format.json { render json: @customer, status: :created, location: @customer }\n else\n format.html { render action: \"new\" }\n format.json { render json: @customer.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @customer = Customer.new(customer_params)\n if @customer.save\n # render json: {name:@customer.name,mobile:@customer.mobile,email:@customer.email,state_name:@customer.state.name,\n # city_name:@customer.city.name,state_id:@customer.state_id,city_id:@customer.city_id}\n render json: @customer.attributes.merge(state_name:@customer.state.name,city_name:@customer.city.name,customer_count:Customer.count);\n else\n render json:{error: @customer.errors.full_messages}\n end\n end", "def create\n @customer_add = CustomerAdd.new(customer_add_params)\n\n respond_to do |format|\n if @customer_add.save\n format.html { redirect_to @customer_add, notice: 'Customer add was successfully created.' }\n format.json { render :show, status: :created, location: @customer_add }\n else\n format.html { render :new }\n format.json { render json: @customer_add.errors, status: :unprocessable_entity }\n end\n end\n end", "def create(cust_token, data = {})\n pdata = build_payment_info(data)\n data = FiveDL.build_params(data.merge!(transtype: 'updatecustomer', token: cust_token).merge!(pdata))\n FiveDL::Response.new( FiveDL::Gateway.post('/Payments/Services_api.aspx', data) )\n end", "def customer(customer_id)\n perform_get_request(\"/customer/#{customer_id}\")\n end", "def customers(options = {})\n perform_get_with_object('/customers', options, Epages::CustomersResponse)\n end", "def customer(customer_id)\n client.get \"customers/#{inst_id}/#{customer_id}\"\n end", "def create\n @customer = customer_scope.new(customer_params)\n @customer.company_type_name = :customer\n\n puts \">>>>> Customer params\"\n puts customer_params.inspect\n\n respond_to do |format|\n if @customer.save\n CompanyRegisterMailer.send_request(@customer.id).deliver\n if customer_params[:plan_id].present?\n PlanRequest.upgrade(@customer.id, customer_params[:plan_id], current_user.id, true)\n end\n\n format.html {\n redirect = customer_path(@customer)\n redirect = company_reseller_path(current_company, @customer.parent_id) if params[:reseller_id]\n redirect = root_path() if params[:registration]\n redirect_to redirect, notice: I18n.t('customers.successfully_created')\n }\n format.json { render json: @customer, status: :created, location: @customer }\n else\n format.html { render action: \"new\" }\n format.json { render json: @customer.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @user = current_user\n @customers = @user.customers\n\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @customers }\n end\n end", "def create\n @customer = Customer.new(params[:customer])\n\n respond_to do |format|\n if @customer.save\n session[:customer_id] = @customer.id\n format.html { redirect_to new_order_path, method: :get, notice: \"Your account was successfully created.\" }\n format.json { render json: @customer, status: :created, location: @customer }\n else\n format.html { render action: \"new\" }\n format.json { render json: @customer.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @customer = Customer.find(params[:customer_id])\n @cust_contact = @customer.cust_contacts.new(params[:cust_contact])\n\n respond_to do |format|\n if @cust_contact.save\n format.html { redirect_to @cust_contact.customer, :notice => 'Contact was successfully created.' }\n format.json { render :json => @cust_contact, :status => :created, :location => @cust_contact }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @cust_contact.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @address_customer = AddressCustomer.new(params[:address_customer])\n\n respond_to do |format|\n if @address_customer.save\n format.html { redirect_to @address_customer, notice: 'Address customer was successfully created.' }\n format.json { render json: @address_customer, status: :created, location: @address_customer }\n else\n format.html { render action: \"new\" }\n format.json { render json: @address_customer.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_customer(body)\r\n begin\r\n @logger.info(\"create_customer called.\")\r\n\r\n # validate required parameters\r\n @logger.info(\"Validating required parameters for create_customer.\")\r\n validate_parameters({\r\n 'body' => body\r\n })\r\n\r\n # prepare query url\r\n @logger.info(\"Preparing query URL for create_customer.\")\r\n _query_builder = Configuration.get_base_uri().clone\r\n _query_builder << '/customers'\r\n _query_url = APIHelper.clean_url _query_builder\r\n\r\n # prepare headers\r\n @logger.info(\"Preparing headers for create_customer.\")\r\n _headers = {\r\n 'accept' => 'application/json',\r\n 'content-type' => 'application/json; charset=utf-8'\r\n }\r\n\r\n # prepare and execute HttpRequest\r\n @logger.info('Preparing and executing HttpRequest for create_customer.')\r\n _request = @http_client.post _query_url, headers: _headers, parameters: body.to_json\r\n BasicAuth.apply(_request)\r\n _context = execute_request(_request, name: 'create_customer')\r\n validate_response(_context)\r\n\r\n # return appropriate response type\r\n @logger.info(\"Returning response for create_customer.\")\r\n decoded = APIHelper.json_deserialize(_context.response.raw_body)\r\n return CustomerModel.from_hash(decoded)\r\n\r\n rescue Exception => e\r\n @logger.error(e)\r\n raise e\r\n end\r\n end", "def add_customer_data(post, options)\n a = options[:address] || {} # shipping address\n \n phone = get_phone_number(a[:phone])\n \n c = {\n :firstname => options[:first_name],\n :lastname => options[:last_name],\n :email => options[:email],\n :zippostal => a[:zip],\n :city => a[:city],\n :address1 => a[:address1],\n :address2 => nil,\n :stateregioniso => a[:state],\n :countryiso => iso_code_for(a[:country]),\n \n :phone1phone => phone[:number],\n :phone1country => phone[:country],\n :phone1area => phone[:area],\n \n :phone2phone => nil,\n :phone2country => nil,\n :phone2area => nil,\n \n :birthday => options[:birth_day] || 01,\n :birthmonth => options[:birth_month] || 01,\n :birthyear => options[:birth_year] || 1980,\n :ipaddress => options[:ip],\n :accountid => options[:id]\n }\n\n post[:customer] = c\n post\n end", "def create\n @customer = User.new(customer_params)\n @customer.authority = 'customer'\n respond_to do |format|\n if @customer.save\n if !current_user\n log_in @customer, :customer\n end\n format.html {redirect_to customer_path(@customer), notice: 'Customer was successfully created.'}\n format.json {render :show, status: :created, location: @customer}\n else\n format.html {render :new}\n format.json {render json: @customer.errors, status: :unprocessable_entity}\n end\n end\n end", "def create_customer_phone(customer_id, data)\n post(\"customers/#{customer_id}/phones\", { body: data })\n end", "def create\n @customer_detail = CustomerDetail.new(customer_detail_params)\n # When we make a new CustomerDetail, also make a Customer to go with it, using the Email from CustomerDetail\n customer_info = customer_detail_params['customer_attributes']\n customer_info['email'] = customer_detail_params['email']\n @customer = Customer.create(customer_info)\n @customer_detail.customer = @customer\n\n respond_to do |format|\n if @customer_detail.save\n format.html { redirect_to wines_url,\n notice: \"User #{@customer_detail.email} was successfully created. Please proceed to Login.\" }\n format.json { render :show, status: :created, location: @customer_detail }\n else\n format.html { render :new }\n format.json { render json: @customer_detail.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @customer_detail = CustomerDetail.new(customer_detail_params)\n\n respond_to do |format|\n if @customer_detail.save\n format.html { redirect_to @customer_detail, notice: \"Customer detail was successfully created.\" }\n format.json { render :show, status: :created, location: @customer_detail }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @customer_detail.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @customer = customers.new(params[:customer])\n\n if @customer.save\n redirect_to customers_path, notice: '客户信息保存成功' \n else\n render action: \"new\" \n end\n end", "def index\n \tcustomers = Customer.all\n \trender json: customers\n \tend", "def customers\n ShopifyAPI::Customer.all\n end", "def update_customer(id, data)\n put(\"customers/#{id}\", { body: data })\n end", "def create\n @customer = Customer.new(customer_params)\n\n respond_to do |format|\n if @customer.save\n set_favorite\n format.html { redirect_to @customer,\n notice: I18n.t('saved') }\n format.json { render action: 'show',\n status: :created, location: @customer }\n else\n format.html { render action: 'new' }\n format.json { render json: @customer.errors,\n status: :unprocessable_entity }\n end\n end\n end", "def create\n @customer = @representative.customers.new(params[:customer])\n\n respond_to do |format|\n if @customer.save\n flash[:notice] = 'Customer was successfully created.'\n format.html { redirect_to(representative_customers_path(@representative)) }\n format.xml { render :xml => @customer, :status => :created, :location => @customer }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @customer.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @customer = Customer.new(customer_params)\n respond_to do |format|\n if @customer.save\n format.html { redirect_to @customer, notice: 'Cliente registrado exitosamente.' }\n else\n format.html { render :new }\n end\n end\n end", "def create\n @customer_info = CustomerInfo.new(customer_info_params)\n\n respond_to do |format|\n if @customer_info.save\n format.html { redirect_to @customer_info, notice: 'Customer info was successfully created.' }\n format.json { render :show, status: :created, location: @customer_info }\n else\n format.html { render :new }\n format.json { render json: @customer_info.errors, status: :unprocessable_entity }\n end\n end\n end", "def customer_list\n perform_get_request('/customer/list')\n end", "def create\n params[:customer][:admitted_on] = Chronic.parse(params[:customer][:admitted_on])\n params[:customer][:released_on] = Chronic.parse(params[:customer][:released_on])\n unless params[:customer][:program].nil?\n params[:customer][:program] = Program.find(params[:customer][:program])\n end\n @customer = Customer.new(params[:customer])\n\n respond_to do |format|\n if @customer.save\n flash[:notice] = 'Customer was successfully created.'\n format.html { redirect_to new_customer_path }\n format.xml { render :xml => @customer, :status => :created, :location => @customer }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @customer.errors, :status => :unprocessable_entity }\n end\n end\n end", "def customer_params\n params.require(:customer).permit(:user_id, :company_name, requests_attributes: [:id, :customer_id, :contact_firstname, :contact_lastname, :title, :email, :phone, :street_address, :city, :date, :zip_code])\n end", "def index\n @customers = Customer.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @customers }\n end\n end", "def customer_params\n params.require(:customer).permit(:title, :first_name, :last_name, :email, :phone, :address, :city, :state, :zip, :country, :reservation_ids => [])\n end", "def search_customers(body:)\n new_api_call_builder\n .request(new_request_builder(HttpMethodEnum::POST,\n '/v2/customers/search',\n 'default')\n .header_param(new_parameter('application/json', key: 'Content-Type'))\n .body_param(new_parameter(body))\n .header_param(new_parameter('application/json', key: 'accept'))\n .body_serializer(proc do |param| param.to_json unless param.nil? end)\n .auth(Single.new('global')))\n .response(new_response_handler\n .deserializer(APIHelper.method(:json_deserialize))\n .is_api_response(true)\n .convertor(ApiResponse.method(:create)))\n .execute\n end", "def create_customer_using_post(customer, opts = {})\n data, _status_code, _headers = create_customer_using_post_with_http_info(customer, opts)\n data\n end", "def create\n @customer = Customer.new(params[:customer])\n\n respond_to do |format|\n if @customer.save\n format.html { redirect_to(@customer, :notice => 'Customer was successfully created.') }\n format.xml { render :xml => @customer, :status => :created, :location => @customer }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @customer.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @customer = Customer.new(customer_params)\n\n respond_to do |format|\n if @customer.save\n UserMailer.activation_email(@customer.user).deliver_now\n format.html { redirect_to home_path, notice: 'Customer was successfully created.' }\n format.json { render :show, status: :created, location: @customer }\n else\n format.html { render :new }\n format.json { render json: @customer.errors, status: :unprocessable_entity }\n end\n end\n end", "def customer_params\n params.require(:customer).permit(:code, :name, :customer_category_id, :user_id, :notes,\n {customer_branches_attributes: [:_destroy, :id, :name, :address, :notes]},\n {customer_contacts_attributes: [:_destroy, :id, :name, :phones, :email, :notes]})\n end", "def create(options = {})\n post(\"customers/#{customer_id}/deliveries\", options)\n end", "def create\n @customer_account = CustomerAccount.new(customer_account_params)\n\n respond_to do |format|\n if @customer_account.save\n flash[:success] = \"Customer account was successfully created!\"\n format.html { redirect_to @customer_account }\n format.json { render :show, status: :created, location: @customer_account }\n else\n format.html { render :new }\n format.json { render json: @customer_account.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n #render :text => params.inspect and return false\n params[:customer][:country] = params[:country]\n params[:customer][:status] = params[:status]\n @customer = Customer.new(params[:customer])\n \n # render :text => @customer.inspect and return false\n respond_to do |format|\n if @customer.save\n flash[:msg] = 'Customer was successfully created.'\n format.html { redirect_to :controller => 'customers', :action => 'index' }\n #format.json { render json: @customer, status: :created, location: @post }\n else\n format.html { render action: \"new\" }\n format.json { render json: @customer.errors, status: :unprocessable_entity }\n end\n end\n end", "def customer_params\n params.require(:customer).permit(:name, :phone_1, :phone_2, :email, :notes)\n end", "def customer_params\n params.require(:customer).permit(:name, :company_name, :address1, :address2, :postal_code)\n end", "def create\n @customer = Customer.new(params[:customer])\n @customer_types =\n CustomerType.new(\n :customer_type => params[:customer_type],\n :customer_type_name => params[:customer_type_name],\n :zip_number => params[:zip_number],\n :prefecture_cd => params[:prefecture_cd],\n :city => params[:city],\n :oaza => params[:oaza],\n :town => params[:town],\n :building_name => params[:building_name],\n :customer_type_memo => params[:customer_type_memo])\n\n @customer.customer_types << @customer_types\n\n respond_to do |format|\n if @customer.save\n format.html { redirect_to @customer, notice: '以下の情報が登録されました。' }\n format.json { render json: @customer, status: :created, location: @customer }\n else\n format.html { render action: \"new\" }\n format.json { render json: @customer.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @customer = Customer.new\n @customer_types = [CustomerType.new]\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @customer }\n end\n end", "def create(attributes)\n id = attributes[:Guid].present? ? attributes[:Guid] : ''\n response = JSON.parse(@client.post(\"Customers/#{id}\", attributes).body)\n Unleashed::Customer.new(@client, response)\n end", "def customer_params\n params.require(:customer).permit(:first_name, :last_name, :phone, :query, :email,\n :street_address, :city, :acct_open_date, :agreement_status, :trans_type,\n :last_trans_date, :street_address2, :postal, :province, :notes)\n end" ]
[ "0.7583026", "0.7368963", "0.72758555", "0.7225672", "0.7224766", "0.7142322", "0.7116918", "0.7109281", "0.7102696", "0.70753646", "0.7068943", "0.7054525", "0.70359194", "0.70359194", "0.70350176", "0.703466", "0.70175", "0.7017294", "0.7017294", "0.7017294", "0.7017294", "0.7017294", "0.7017294", "0.7011197", "0.6992751", "0.6984326", "0.6953537", "0.69506246", "0.6950355", "0.693838", "0.69177485", "0.690329", "0.68956757", "0.6893036", "0.689211", "0.68855834", "0.6819733", "0.6735079", "0.67301786", "0.67179143", "0.6695761", "0.6675084", "0.66611797", "0.6654872", "0.6638326", "0.6629095", "0.6591667", "0.65913165", "0.65908194", "0.65799236", "0.65622944", "0.65583175", "0.6558022", "0.6556248", "0.6537413", "0.65248156", "0.6519175", "0.65181625", "0.6511338", "0.64996046", "0.6488794", "0.64813", "0.6452624", "0.64486706", "0.6442164", "0.6440251", "0.6437413", "0.6432282", "0.6407193", "0.6400671", "0.6399971", "0.6389764", "0.6381177", "0.6377061", "0.63661236", "0.63508", "0.6346849", "0.6346006", "0.63451076", "0.63423294", "0.6333185", "0.63303983", "0.63239366", "0.6321749", "0.63213986", "0.63082653", "0.6301424", "0.62783664", "0.62691015", "0.62592316", "0.6255516", "0.6247079", "0.6246658", "0.6242503", "0.62380147", "0.6217102", "0.6215618", "0.6212986", "0.6212601", "0.6211069", "0.62105036" ]
0.0
-1
PATCH/PUT /customers/1 PATCH/PUT /customers/1.json
def update respond_to do |format| if @customer.update(customer_params) format.html { redirect_to @customer, notice: 'Customer was successfully updated.' } format.json { render :show, status: :ok, location: @customer } else format.html { render :edit } format.json { render json: @customer.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_customer(id, data)\n put(\"customers/#{id}\", { body: data })\n end", "def update\n @customer = Customer.find(params[:id])\n\n respond_to do |format|\n if @customer.update_attributes(params[:customer])\n #format.html { redirect_to customers_path }\n format.json { head :ok }\n else\n #format.html { render action: \"edit\" }\n format.json { render :json=> @customer.errors, :status=> :unprocessable_entity }\n end\n end\n end", "def update\n @customer = Customer.find(params[:id])\n\n if @customer.update(customer_params)\n head :no_content\n else\n render json: @customer.errors, status: :unprocessable_entity\n end\n end", "def update\n @customer = Customer.find(params[:id])\n\n respond_to do |format|\n if @customer.update_attributes(params[:customer])\n format.html { redirect_to @customer, notice: 'Customer was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @customer.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @customer = Customer.find(params[:id])\n\n respond_to do |format|\n if @customer.update_attributes(params[:customer])\n format.html { redirect_to @customer, notice: 'Customer was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @customer.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @customer = Customer.find(params[:id])\n\n respond_to do |format|\n if @customer.update_attributes(params[:customer])\n format.html { redirect_to @customer, notice: 'Customer was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @customer.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @customer = Customer.find(params[:id])\n\n respond_to do |format|\n if @customer.update_attributes(params[:customer])\n format.html { redirect_to @customer, notice: 'Customer was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @customer.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @customer = Customer.find(params[:id])\n\n respond_to do |format|\n if @customer.update_attributes(params[:customer])\n format.html { redirect_to @customer, notice: 'Customer was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @customer.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @customer = Customer.find(params[:id])\n\n respond_to do |format|\n if @customer.update_attributes(params[:customer])\n format.html { redirect_to @customer, notice: 'Customer was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @customer.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @customer = Customer.find(params[:id])\n\n respond_to do |format|\n if @customer.update_attributes(params[:customer])\n format.html { redirect_to @customer, notice: 'Customer was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @customer.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @customer = Customer.find(params[:id])\n\n respond_to do |format|\n if @customer.update_attributes(params[:customer])\n format.html { redirect_to action:\"index\", notice: 'Customer was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @customer.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @customer = Customer.find(params[:id])\n\n respond_to do |format|\n if @customer.update_attributes(params[:customer])\n format.html { redirect_to @customer, notice: 'Customer was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @customer.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @customer.update(customer_params)\n format.html { redirect_to @customer, notice: 'Customer was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @customer.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @customer.update(customer_params)\n format.html { redirect_to @customer, notice: 'Customer was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @customer.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @customer.update(customer_params)\n format.html { redirect_to @customer, notice: 'Customer was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @customer.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_customer(customer_id:,\n body:)\n new_api_call_builder\n .request(new_request_builder(HttpMethodEnum::PUT,\n '/v2/customers/{customer_id}',\n 'default')\n .template_param(new_parameter(customer_id, key: 'customer_id')\n .should_encode(true))\n .header_param(new_parameter('application/json', key: 'Content-Type'))\n .body_param(new_parameter(body))\n .header_param(new_parameter('application/json', key: 'accept'))\n .body_serializer(proc do |param| param.to_json unless param.nil? end)\n .auth(Single.new('global')))\n .response(new_response_handler\n .deserializer(APIHelper.method(:json_deserialize))\n .is_api_response(true)\n .convertor(ApiResponse.method(:create)))\n .execute\n end", "def update\n respond_to do |format|\n if @customer.update(customer_params)\n format.html {redirect_to customer_path(@customer), notice: 'Customer was successfully updated.'}\n format.json {render :show, status: :ok, location: @customer}\n else\n format.html {render :edit}\n format.json {render json: @customer.errors, status: :unprocessable_entity}\n end\n end\n end", "def update\n respond_to do |format|\n if @customer.update(customer_params)\n format.json { render action: 'show', status: :created, location: @customer }#format.html { redirect_to @customer, notice: 'Customer was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @customer.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @customer.update(customer_params)\n format.html { redirect_to customers_path, notice: 'Customer was successfully updated.' }\n format.json { render :show, status: :ok, location: @customer }\n else\n format.html { render :edit }\n format.json { render json: @customer.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @customer.update(customer_params)\n format.html { redirect_to @customer, \n notice: \"Customer #{@customer.email} was successfully updated.\" }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @customer.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n\n\n respond_to do |format|\n if @customer.update(customer_params)\n @@current_customer = @customer.id\n format.html { redirect_to @customer, notice: 'Customer was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @customer.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @customer.update(customer_params)\n format.html { redirect_to [:admin, @customer], notice: t('messages.updated', model:Customer.model_name.human) }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @customer.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n authorize! :update, @customer\n update_customer_params = ( current_user.role == 'kanari_admin' ? admin_customer_params : customer_params)\n if @customer.update(update_customer_params)\n render json: nil, status: 200\n else\n render json: @customer.errors, status: :unprocessable_entity\n end\n end", "def update\n @customer = Customer.find(params[:id])\n\n respond_to do |format|\n if @customer.update_attributes(params[:customer])\n #@customer.progress!\n format.html { redirect_to @customer, notice: 'Customer was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @customer.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @cust = Cust.find(params[:id])\n\n respond_to do |format|\n if @cust.update_attributes(params[:cust])\n format.html { redirect_to @cust, notice: 'Cust was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @cust.errors, status: :unprocessable_entity }\n end\n end\n end", "def update # it is impossible for a customer to update a referral, so no need to modify.\n @customer = Customer.find(params[:id])\n\n respond_to do |format|\n if @customer.update_attributes(params[:customer])\n format.html { redirect_to [@selector, @customer], :notice => 'Customer was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @customer.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @customer_customer.update(customer_customer_params)\n format.html { redirect_to @customer_customer, notice: 'Customer was successfully updated.' }\n format.json { render :show, status: :ok, location: @customer_customer }\n else\n format.html { render :edit }\n format.json { render json: @customer_customer.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @customer.update(customer_params)\n format.html { redirect_to @customer, notice: \"Customer was successfully updated.\" }\n format.json { render :show, status: :ok, location: @customer }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @customer.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @customer = Customer.find(params[:customer_id])\n @cust_contact = @customer.cust_contacts.find(params[:id])\n\n respond_to do |format|\n if @cust_contact.update_attributes(params[:cust_contact])\n format.html { redirect_to customer_path(@customer), :notice => 'Contact was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @cust_contact.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n \n if @customer.update(customer_params.keep_if{|p,q| q.class != ActionController::Parameters}) \n @customer.address.update(customer_params[:address_attributes])\n @customer.contact.update(customer_params[:contact_attributes])\n format.html { redirect_to @customer, notice: 'Customer was successfully updated.' }\n format.json { render :show, status: :ok, location: @customer }\n else\n format.html { render :edit }\n format.json { render json: @customer.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @customer.update(customer_params)\n format.html { redirect_to @customer, notice: 'Customer was successfully updated.' }\n format.json { render :show, status: :ok, location: @customer }\n else\n format.html { render :show }\n format.json { render json: @customer.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @Customer = Customer.find params[:id]\n if @Customer.update_attributes (customer_params)\n render :json => { :success => true, :Customer => @Customer, :message => 'customer add ok ' }\n else\n render :json => {:success => false, :message => \"Existe un error\"}\n end\n end", "def update\n respond_to do |format|\n if @customer.update(customer_params)\n format.html { redirect_to @customer, notice: t(\"activerecord.controller_msg.customer.updated\", :default => 'Customer was successfully updated.') }\n format.json { render :show, status: :ok, location: @customer }\n else\n format.html { render :edit }\n format.json { render json: @customer.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @customer = Customer.find(params[:id])\n\n respond_to do |format|\n if @customer.update_attributes(params[:customer])\n format.html { redirect_to customer_path(session[:customer_id]), notice: 'Your account was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @customer.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @my_customer.update(my_customer_params)\n format.html { redirect_to @my_customer, notice: 'My customer was successfully updated.' }\n format.json { render :show, status: :ok, location: @my_customer }\n else\n format.html { render :edit }\n format.json { render json: @my_customer.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @customer.update(customer_params)\n format.html { redirect_to @customer, notice: 'Cliente editado com sucesso!' }\n format.json { render :show, status: :ok, location: @customer }\n else\n format.html { render :edit }\n format.json { render json: @customer.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @customer.update(customer_params)\n set_favorite\n format.html { redirect_to @customer,\n notice: I18n.t('updated') }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @customer.errors,\n status: :unprocessable_entity }\n end\n end\n end", "def update\n @customer = Customer.where(:id => params[:id], :company_id => current_user.company.id).first\n\n respond_to do |format|\n if @customer.update_attributes(params[:customer])\n format.html {\n redirect_to @customer,\n notice: I18n.t(:successfully_updated, :model_name => Customer.model_name.human)\n }\n format.json { head :no_content }\n else\n @customer.errors.each do |name, error|\n flash[name] = error\n end\n format.html { render action: \"edit\" }\n format.json { render json: @customer.errors, status: :unprocessable_entity }\n end\n end\n end", "def customer_update\n respond_to do |format|\n if @customer.update(person_params)\n format.html { redirect_to customer_path, notice: 'データが更新されました。' }\n format.json { render :customer_show, status: :ok, location: @customer }\n else\n format.html { redirect_to edit_customer_path }\n format.json { render json: @customer.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_customer(customer, id)\n request(customer, \"customer\", :post, {id: id, method: \"edit\"})\n end", "def update\n respond_to do |format|\n if @customer.update(customer_params)\n format.html { redirect_to @customer, notice: 'Your Customer Account was successfully updated.' }\n format.json { render :show, status: :ok, location: @customer }\n else\n format.html { render :edit }\n format.json { render json: @customer.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @customer_set.update(customer_set_params)\n format.html { redirect_to @customer_set, notice: 'Customer set was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @customer_set.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n params[:customer][:admitted_on] = Chronic.parse(params[:customer][:admitted_on])\n params[:customer][:released_on] = Chronic.parse(params[:customer][:released_on])\n @customer = Customer.find(params[:id])\n unless params[:customer][:program].nil?\n params[:customer][:program] = Program.find(params[:customer][:program])\n end\n\n respond_to do |format|\n if @customer.update_attributes(params[:customer])\n flash[:notice] = 'Customer was successfully updated.'\n format.html { redirect_to(@customer) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @customer.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @customer = current_user.customers.find(params[:id])\n\n respond_to do |format|\n if @customer.update_attributes(params[:customer])\n format.xml { head :ok }\n format.js\n else\n format.xml { render :xml => @customer.errors, :status => :unprocessable_entity }\n format.js\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 update\n @self_service_customer = SelfService::Customer.find(params[:id])\n\n respond_to do |format|\n if @self_service_customer.update_attributes(params[:self_service_customer])\n format.html { redirect_to(@self_service_customer, :notice => 'Customer was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @self_service_customer.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @customer = Customer.find(params[:id])\n\n respond_to do |format|\n if @customer.update_attributes(params[:customer])\n format.html { redirect_to(@customer, :notice => 'Customer was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @customer.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @customer = Customer.find(params[:id])\n\n respond_to do |format|\n if @customer.update_attributes(params[:customer])\n format.html { redirect_to(:action => 'index', :notice => 'Customer was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @customer.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @customer.update(customer_params)\n format.html { redirect_to @customer, notice: 'Personendaten wurden erfolgreich aktualisiert.' }\n format.json { render :show, status: :ok, location: @customer }\n else\n format.html { render :edit }\n format.json { render json: @customer.errors, status: :unprocessable_entity }\n end\n end\n end", "def update(params = {})\n req = WebPay::CustomerRequestUpdate.create(params)\n raw_response = @client._request(:post, 'customers' + '/' + req.id.to_s, req)\n WebPay::CustomerResponse.new(raw_response)\n end", "def update\n respond_to do |format|\n if @customer.update(customer_params)\n format.html { redirect_to customers_path, success: \"Customer record updated\"}\n else\n format.html { render :edit }\n end\n end\n end", "def update_customer(customer)\n respond_with customer.to_vaulted_billing\n end", "def update_customer(customer)\n respond_with customer.to_vaulted_billing\n end", "def update\n @customer.user = current_user\n authorize @customer, :update?\n\n respond_to do |format|\n if @customer.update(customer_params)\n @customer.works.create!(trackable_url: \"#{customer_path(@customer)}\", action: :update, user: current_user, \n parameters: @customer.to_json(except: {customer: [:fullname_and_address_and_pesel_nip_and_birth_date]}, \n include: { \n user: {\n only: [:id, :name, :email] } \n }))\n\n flash_message :success, t('activerecord.messages.successfull.updated', data: @customer.fullname)\n format.html { redirect_to @customer }\n format.json { render :show, status: :ok, location: @customer }\n else\n format.html { render :edit }\n format.json { render json: @customer.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n \n @cPhone = CustomerPhone.where('customer_id=? and phone_id=?', params[:customer_id], phone_params[:id]).first \n @phone = @cPhone.phone\n \n respond_to do |format|\n if @phone.update(phone_params)\n format.json { head :no_content }\n else\n format.json { render json: @phone.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @customer = Customer.find(params[:id])\n\n respond_to do |format|\n if @customer.update_attributes(params[:customer])\n flash[:notice] = 'Customer was successfully updated.'\n format.html { redirect_to(representative_customers_path(@representative)) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @customer.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @customer = customer_scope.find(params[:id])\n\n respond_to do |format|\n if params[:company][:avatar] && @customer.update_attribute(:avatar, params[:company][:avatar])\n format.html { render action: \"edit\" }\n format.js #\n elsif @customer.update_attributes(customer_params)\n if customer_params[:plan_id].present?\n PlanRequest.upgrade(@customer.id, customer_params[:plan_id], current_user.id, true)\n end\n format.html {\n redirect = customer_path(@customer)\n redirect = root_path if current_company.is_customer?\n redirect = company_reseller_path(current_company, @customer.parent_id) if params[:reseller_id]\n redirect = company_reseller_customer_path(current_company, @customer.parent_id, @customer) if session[:by_reseller] && @customer.parent && @customer.parent.is_partner?\n redirect = step3_homes_path if session['homes.step'] == 2\n redirect_to redirect, notice: I18n.t('commons.successfully_updated')\n }\n format.json { head :no_content }\n format.js #\n else\n format.html { render action: \"edit\" }\n format.json { render json: @customer.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @customer_detail.update(customer_detail_params)\n format.html { redirect_to @customer_detail, notice: \"Customer detail was successfully updated.\" }\n format.json { render :show, status: :ok, location: @customer_detail }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @customer_detail.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_customer(customer, options = {})\n id = epages_id(customer)\n perform_patch_with_object(\"/customers/#{id}\", options, Epages::Customer)\n end", "def update\n @address_customer = AddressCustomer.find(params[:id])\n\n respond_to do |format|\n if @address_customer.update_attributes(params[:address_customer])\n format.html { redirect_to @address_customer, notice: 'Address customer was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @address_customer.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @customer = Customer.find(params[:customer_id])\n @contact = @customer.contacts.find(params[:id])\n\n respond_to do |format|\n if @contact.update_attributes(params[:contact])\n format.html { redirect_to([@contact.customer, @contact], :notice => t('forms.update.sucess')) }\n format.json { head :ok }\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 patch!\n request! :patch\n end", "def update\n respond_to do |format|\n if @customer_add.update(customer_add_params)\n format.html { redirect_to @customer_add, notice: 'Customer add was successfully updated.' }\n format.json { render :show, status: :ok, location: @customer_add }\n else\n format.html { render :edit }\n format.json { render json: @customer_add.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @customer_info.update(customer_info_params)\n format.html { redirect_to @customer_info, notice: 'Customer info was successfully updated.' }\n format.json { render :show, status: :ok, location: @customer_info }\n else\n format.html { render :edit }\n format.json { render json: @customer_info.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @potential_customer = PotentialCustomer.find(params[:id])\n\n respond_to do |format|\n if @potential_customer.update_attributes(params[:potential_customer])\n format.html { redirect_to @potential_customer, notice: 'Potential customer was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @potential_customer.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @customer.update(customer_params)\n format.html { redirect_to @customer, notice: 'Cliente editado exitosamente.' }\n else\n format.html { render :edit }\n end\n end\n end", "def update\n @custo = Custo.find(params[:id])\n\n respond_to do |format|\n if @custo.update_attributes(params[:custo])\n format.html { redirect_to @custo, notice: 'Custo was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @custo.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @customer.update(customer_params)\n format.html { redirect_to @customer, notice: t('views.flash_update_message') }\n format.json { render :show, status: :ok, location: @customer }\n else\n format.html { render :edit }\n format.json { render json: @customer.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @customer.update(customer_params)\n migrate_to_dropbox\n format.html { redirect_to @customer, notice: \"Customer was successfully updated.\" }\n format.json { render :show, status: :ok, location: @customer }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @customer.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @customer = Customer.find(params[:id])\n @user = User.find(session[:user_id])\n @customer.modified_by = @user.name\n respond_to do |format|\n if @customer.update_attributes(params[:customer])\n format.html { redirect_to(customers_path, :notice => 'Customer was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @customer.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 if @customer.update customer_params\n redirect_to @customer\n else\n render 'edit'\n end\n end", "def update\n @customer_bill = CustomerBill.find(params[:id])\n\n respond_to do |format|\n if @customer_bill.update_attributes(params[:customer_bill])\n format.html { redirect_to @customer_bill, notice: 'Customer bill was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @customer_bill.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_customer(customer_id:,\n body:)\n # Prepare query url.\n _query_builder = config.get_base_uri\n _query_builder << '/v2/customers/{customer_id}'\n _query_builder = APIHelper.append_url_with_template_parameters(\n _query_builder,\n 'customer_id' => { 'value' => customer_id, 'encode' => true }\n )\n _query_url = APIHelper.clean_url _query_builder\n\n # Prepare headers.\n _headers = {\n 'accept' => 'application/json',\n 'content-type' => 'application/json; charset=utf-8'\n }\n\n # Prepare and execute HttpRequest.\n _request = config.http_client.put(\n _query_url,\n headers: _headers,\n parameters: body.to_json\n )\n OAuth2.apply(config, _request)\n _response = execute_request(_request)\n\n # Return appropriate response type.\n decoded = APIHelper.json_deserialize(_response.raw_body)\n _errors = APIHelper.map_response(decoded, ['errors'])\n ApiResponse.new(\n _response, data: decoded, errors: _errors\n )\n end", "def update_customer_with_http_info(id, update_customer, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: CustomersApi.update_customer ...'\n end\n # verify the required parameter 'id' is set\n if @api_client.config.client_side_validation && id.nil?\n fail ArgumentError, \"Missing the required parameter 'id' when calling CustomersApi.update_customer\"\n end\n # verify the required parameter 'update_customer' is set\n if @api_client.config.client_side_validation && update_customer.nil?\n fail ArgumentError, \"Missing the required parameter 'update_customer' when calling CustomersApi.update_customer\"\n end\n allowable_values = [\"es\", \"en\"]\n if @api_client.config.client_side_validation && opts[:'accept_language'] && !allowable_values.include?(opts[:'accept_language'])\n fail ArgumentError, \"invalid value for \\\"accept_language\\\", must be one of #{allowable_values}\"\n end\n # resource path\n local_var_path = '/customers/{id}'.sub('{' + 'id' + '}', CGI.escape(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/vnd.conekta-v2.1.0+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 header_params[:'Accept-Language'] = opts[:'accept_language'] if !opts[:'accept_language'].nil?\n header_params[:'X-Child-Company-Id'] = opts[:'x_child_company_id'] if !opts[:'x_child_company_id'].nil?\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(update_customer)\n\n # return_type\n return_type = opts[:debug_return_type] || 'CustomerResponse'\n\n # auth_names\n auth_names = opts[:debug_auth_names] || ['bearerAuth']\n\n new_options = opts.merge(\n :operation => :\"CustomersApi.update_customer\",\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(:PUT, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: CustomersApi#update_customer\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def update\n @offer_customer = OfferCustomer.find(params[:id])\n\n respond_to do |format|\n if @offer_customer.update_attributes(params[:offer_customer])\n format.html { redirect_to @offer_customer, notice: 'Offer customer was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @offer_customer.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @type_customer = TypeCustomer.find(params[:id])\n\n respond_to do |format|\n if @type_customer.update_attributes(params[:type_customer])\n format.html { redirect_to @type_customer, notice: 'Type customer was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @type_customer.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 @customers_address = CustomersAddress.find(params[:id])\n\n respond_to do |format|\n if @customers_address.update_attributes(params[:customers_address])\n format.html { redirect_to @customers_address, notice: 'Customers address was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @customers_address.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @service = Service.find(params[:id])\n respond_to do |format|\n if @service.update_attributes(service_params)\n format.html { redirect_to @customer, success: 'Service was successfully updated.' }\n format.json { respond_with_bip(@service) }\n else\n format.html { render action: 'edit'}\n format.json { respond_with_bip(@service) }\n end\n end\n end", "def update\n respond_to do |format|\n if @customerservice.update(customerservice_params)\n format.html { redirect_to @customerservice, notice: 'Customerservice was successfully updated.' }\n format.json { render :show, status: :ok, location: @customerservice }\n else\n format.html { render :edit }\n format.json { render json: @customerservice.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @customer = customers.find(params[:id])\n\n if @customer.update_attributes(params[:customer])\n redirect_to customers_path, notice: '客户信息更新成功' \n else\n render action: \"edit\" \n end\n end", "def update\n\t\tfname= \"#{self.class.name}.#{__method__}\"\n\t\tLOG.debug (fname) {\"params=#{params.inspect}\"}\n\t\t@customer = Customer.find(params[:id])\n\t\t@types = Typesobject.get_types(:customer)\n\t\t@status = Statusobject.find_for(@customer)\n\t\t@customer.update_accessor(current_user)\n\t\tif commit_promote?\n\t\t\tctrl_promote(@customer)\n\t\telse\n\t\t\trespond_to do |format|\n\t\t\t\tif @customer.update_attributes(params[:customer])\n\t\t\t\t\tflash[:notice] = t(:ctrl_object_updated, :typeobj => t(:ctrl_customer), :ident => @customer.ident)\n\t\t\t\t\tformat.html { redirect_to(@customer) }\n\t\t\t\t\tformat.xml { head :ok }\n\t\t\t\telse\n\t\t\t\t\tflash[:error] = t(:ctrl_object_notupdated, :typeobj => t(:ctrl_customer), :ident => @customer.ident)\n\t\t\t\t\tformat.html { render :action => :edit }\n\t\t\t\t\tformat.xml { render :xml => @customer.errors, :status => :unprocessable_entity }\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend" ]
[ "0.6988014", "0.6921667", "0.6921389", "0.6746401", "0.6746401", "0.6746401", "0.6746401", "0.6746401", "0.6746401", "0.6746401", "0.67379916", "0.6729548", "0.669213", "0.669213", "0.669213", "0.6614732", "0.66107404", "0.6601309", "0.6599307", "0.6581087", "0.65642476", "0.65528435", "0.65495336", "0.65224195", "0.6521344", "0.6517462", "0.6504792", "0.6493295", "0.64776856", "0.6457318", "0.6456203", "0.64549035", "0.64447165", "0.6439166", "0.64264", "0.6406883", "0.6396675", "0.6395213", "0.6387667", "0.63603675", "0.6351255", "0.6351143", "0.6297615", "0.62898433", "0.62882054", "0.6285952", "0.6271253", "0.6269422", "0.6253447", "0.6251907", "0.62460697", "0.6244198", "0.6244198", "0.6213548", "0.61861336", "0.61684984", "0.61539996", "0.61523414", "0.6127079", "0.6125767", "0.6121538", "0.61150646", "0.61145186", "0.6112347", "0.6089436", "0.6088314", "0.6070272", "0.60669667", "0.6055655", "0.6049337", "0.60488063", "0.6045963", "0.60332125", "0.6032371", "0.6016146", "0.60120237", "0.6011633", "0.60063666", "0.60063666", "0.59956974", "0.5966501", "0.59659606", "0.5965954", "0.5965705" ]
0.6525123
37
DELETE /customers/1 DELETE /customers/1.json
def destroy @customer.destroy respond_to do |format| format.html { redirect_to customers_url, notice: 'Customer was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @customer = Customer.find(params[:id])\n @customer.destroy\n\n respond_to do |format|\n format.html { redirect_to customers_url }\n format.json { head :ok }\n end\n end", "def destroy\n @customer = Customer.find(params[:id])\n @customer.destroy\n\n respond_to do |format|\n format.html { redirect_to customers_url }\n format.json { head :ok }\n end\n end", "def destroy\n @customer = Customer.find(params[:id])\n @customer.destroy\n\n respond_to do |format|\n format.html { redirect_to customers_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @customer = Customer.find(params[:id])\n @customer.destroy\n\n respond_to do |format|\n format.html { redirect_to customers_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @customer = Customer.find(params[:id])\n @customer.destroy\n\n respond_to do |format|\n format.html { redirect_to customers_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @customer = Customer.find(params[:id])\n @customer.destroy\n\n respond_to do |format|\n format.html { redirect_to customers_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @customer = Customer.find(params[:id])\n @customer.destroy\n\n respond_to do |format|\n format.html { redirect_to customers_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @customer = Customer.find(params[:id])\n @customer.destroy\n\n respond_to do |format|\n format.html { redirect_to customers_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @customer = Customer.find(params[:id])\n @customer.destroy\n\n respond_to do |format|\n format.html { redirect_to customers_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @customer = Customer.find(params[:id])\n @customer.destroy\n respond_to do |format|\n format.html { redirect_to customers_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @customer.destroy\n respond_to do |format|\n format.html { redirect_to customers_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @customer.destroy\n respond_to do |format|\n format.html { redirect_to customers_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @customer.destroy\n respond_to do |format|\n format.html { redirect_to customers_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @customer.destroy\n respond_to do |format|\n format.html { redirect_to customers_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @customer.destroy\n respond_to do |format|\n format.html { redirect_to customers_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @customer.destroy\n respond_to do |format|\n format.html { redirect_to customers_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @customer.destroy\n respond_to do |format|\n format.html { redirect_to customers_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @customer.destroy\n respond_to do |format|\n format.html { redirect_to customers_url }\n format.json { head :no_content }\n end\n end", "def destroy\r\n @customer = Customer.find(params[:id])\r\n @customer.destroy\r\n\r\n respond_to do |format|\r\n format.html { redirect_to customers_url }\r\n format.json { head :ok }\r\n end\r\n end", "def destroy\n @customer = Customer.find(params[:id])\n @customer.destroy\n\n head :no_content\n end", "def destroy\n \n @customer = Customer.find(params[:id])\n @customer.destroy\n\n respond_to do |format|\n format.html { redirect_to user_customers_url(current_user) }\n format.json do\n render json: {\n customer: @customer,\n status: :deleted\n }.to_json\n end\n end\n end", "def destroy\n @single_customer.destroy\n respond_to do |format|\n format.html { redirect_to single_customers_url, notice: 'Single customer was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @cust = Cust.find(params[:id])\n @cust.destroy\n\n respond_to do |format|\n format.html { redirect_to custs_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @customer.destroy\n respond_to do |format|\n format.html { redirect_to customers_url, notice: 'customer was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @customer = Customer.where(:id => params[:id], :company_id => current_user.company.id).first\n @customer.destroy\n\n respond_to do |format|\n format.html { redirect_to customers_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @customer.destroy\n respond_to do |format|\n format.html { redirect_to customers_path, notice: 'Customer was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @customer.destroy\n respond_to do |format|\n format.html { redirect_to customers_url, notice: \"Customer was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @customer.destroy\n respond_to do |format|\n format.html { redirect_to customers_url, notice: \"Customer was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n # @customer.destroy\n # respond_to do |format|\n # format.html { redirect_to customers_url, notice: 'Customer was successfully destroyed.' }\n # format.json { head :no_content }\n # end\n end", "def destroy\n @customer_customer.destroy\n respond_to do |format|\n format.html { redirect_to customer_customers_url, notice: 'Customer was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @customer.destroy\n respond_to do |format|\n format.html { redirect_to customers_url, notice: 'データが削除されました。' }\n format.json { head :no_content }\n end\n end", "def destroy\n @customer.destroy\n respond_to do |format|\n format.html { redirect_to admin_customers_url, notice: 'Customer was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete_customer_by_id(customer_id)\n host = Swagger.configuration.host\n api_key = Swagger.configuration.private_api_key\n\n conn = Faraday.new\n resp = conn.delete do |req|\n req.url \"https://#{host}/api/customer/#{customer_id}\"\n req.headers['Content-Type'] = 'application/json'\n req.headers['Authorization'] = 'Basic ' + [\"#{api_key}:\"].pack('m').delete(\"\\r\\n\")\n end\n body = JSON.parse(resp.body)\n Swagger::Response.new(resp.status, body)\n return body\n end", "def delete_index\n @customer = Customer.with_deleted.find(params[:id])\n if params[:type]=='normal'\n @customer.delete\n elsif params[:type]=='restore'\n @customer.restore\n @customer.update(deleted_at: nil)\n end\n\n @customer.destroy\n respond_to do |format|\n format.html { redirect_to customers_path, notice: 'Customer was successfully removed.' }\n format.json { head :no_content }\n end\n end", "def delete(params = {})\n req = WebPay::CustomerIdRequest.create(params)\n raw_response = @client._request(:delete, 'customers' + '/' + req.id.to_s, req)\n WebPay::CustomerResponse.new(raw_response)\n end", "def customer_destroy\n @customer.destroy\n respond_to do |format|\n format.html { redirect_to customers_url, notice: 'データが削除されました。' }\n format.json { head :no_content }\n end\n end", "def destroy\n @customer = Customer.find(params[:id])\n @customer.destroy\n\n respond_to do |format|\n format.html { redirect_to(customers_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @customer = Customer.find(params[:id])\n @customer.destroy\n\n respond_to do |format|\n format.html { redirect_to(customers_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @customer = Customer.find(params[:id])\n @customer.destroy\n\n respond_to do |format|\n format.html { redirect_to(customers_url) }\n format.xml { head :ok }\n end\n end", "def delete\n client.delete(\"/#{id}\")\n end", "def destroy\n @my_customer.destroy\n respond_to do |format|\n format.html { redirect_to my_customers_url, notice: 'My customer was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @customer = Customer.find(params[:id])\n @customer.destroy\n\n respond_to do |format|\n #format.html { redirect_to customers_index_path }\n format.json { head :ok }\n format.js { render :nothing => true }\n end\n end", "def destroy\n authorize @customer, :destroy?\n @customer.destroy\n respond_to do |format|\n format.html { redirect_to customers_url, notice: 'Customer was successfully deleted.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @customer = Customer.find(params[:id])\n @customer.destroy\n\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @customer = Customer.find(params[:id])\n\n respond_to do |format|\n if @customer.destroy\n format.html { redirect_to customers_url }\n format.json { head :no_content }\n else\n format.html { redirect_to customer_url(@customer), :notice => \"customer can't be destroyed\" }\n format.json { render json: @customer.errors, status: :unprocessable_entity }\n end \n end\n end", "def destroy\n find_customer\n @customer.destroy\n\n respond_to do |format|\n format.html { redirect_to('/customers/overview') }\n format.xml { head :ok }\n end\n end", "def destroy\n @customer.destroy\n respond_to do |format|\n format.html { redirect_to customers_url,flash[:success] = \"Customer record successfully deleted.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @customer.destroy\n respond_to do |format|\n format.html { redirect_to customers_url, notice: 'Person wurde erfolgreich gelöscht.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @self_service_customer = SelfService::Customer.find(params[:id])\n @self_service_customer.destroy\n\n respond_to do |format|\n format.html { redirect_to(self_service_customers_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @custo = Custo.find(params[:id])\n @custo.destroy\n\n respond_to do |format|\n format.html { redirect_to custos_url }\n format.json { head :ok }\n end\n end", "def destroy\n @customer_add.destroy\n respond_to do |format|\n format.html { redirect_to customer_adds_url, notice: 'Customer add was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @customer = Customer.find(params[:customer_id])\n @cust_contact = @customer.cust_contacts.find(params[:id])\n @cust_contact.destroy\n\n respond_to do |format|\n format.html { redirect_to customer_url(@customer) }\n format.json { head :no_content }\n end\n end", "def delete_customer(customer_id:,\n version: nil)\n new_api_call_builder\n .request(new_request_builder(HttpMethodEnum::DELETE,\n '/v2/customers/{customer_id}',\n 'default')\n .template_param(new_parameter(customer_id, key: 'customer_id')\n .should_encode(true))\n .query_param(new_parameter(version, key: 'version'))\n .header_param(new_parameter('application/json', key: 'accept'))\n .auth(Single.new('global')))\n .response(new_response_handler\n .deserializer(APIHelper.method(:json_deserialize))\n .is_api_response(true)\n .convertor(ApiResponse.method(:create)))\n .execute\n end", "def destroy\n @address_customer = AddressCustomer.find(params[:id])\n @address_customer.destroy\n\n respond_to do |format|\n format.html { redirect_to address_customers_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @type_customer = TypeCustomer.find(params[:id])\n @type_customer.destroy\n\n respond_to do |format|\n format.html { redirect_to type_customers_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @customer.destroy\n respond_to do |format|\n format.html { redirect_to customers_url, notice: 'Cliente eliminado exitosamente.' }\n end\n end", "def destroy\n @customer.destroy\n respond_to do |format|\n format.html { redirect_to customers_url, notice: t(\"activerecord.controller_msg.customer.destroyed\", :default => 'Customer was successfully destroyed.') }\n format.json { head :no_content }\n end\n end", "def delete(customer_id)\n response, status = BeyondApi::Request.delete(@session, \"/customers/#{customer_id}\")\n\n handle_response(response, status, respond_with_true: true)\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 request(:delete)\n end", "def destroy\n @customer.destroy\n redirect_to customers_url\n end", "def delete(path)\n RestClient.delete request_base+path\n end", "def destroy\n Customer.destroy params #[not sure what to put in the params]\n redirect_to customers_path\n end", "def destroy\n @customer_detail.destroy\n respond_to do |format|\n format.html { redirect_to customer_details_url, notice: \"Customer detail was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @customer_detail.destroy\n respond_to do |format|\n format.html { redirect_to customer_details_url, notice: 'Customer detail was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @customer = Customer.find(params[:id])\n @customer.destroy\n redirect_to(action: \"index\")\n end", "def destroy\n @shop_customer.destroy\n respond_to do |format|\n format.html { redirect_to shop_customers_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @customer.destroy\n respond_to do |format|\n format.html { redirect_to customers_url, notice: 'Customer was successfully destroyed.' }\n end\n end", "def delete_customer(customer_id:)\n # Prepare query url.\n _query_builder = config.get_base_uri\n _query_builder << '/v2/customers/{customer_id}'\n _query_builder = APIHelper.append_url_with_template_parameters(\n _query_builder,\n 'customer_id' => { 'value' => customer_id, 'encode' => true }\n )\n _query_url = APIHelper.clean_url _query_builder\n\n # Prepare headers.\n _headers = {\n 'accept' => 'application/json'\n }\n\n # Prepare and execute HttpRequest.\n _request = config.http_client.delete(\n _query_url,\n headers: _headers\n )\n OAuth2.apply(config, _request)\n _response = execute_request(_request)\n\n # Return appropriate response type.\n decoded = APIHelper.json_deserialize(_response.raw_body)\n _errors = APIHelper.map_response(decoded, ['errors'])\n ApiResponse.new(\n _response, data: decoded, errors: _errors\n )\n end", "def destroy\n @customerservice.destroy\n respond_to do |format|\n format.html { redirect_to customerservices_url, notice: 'Customerservice was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete()\n sql = \"DELETE from customers WHERE id = $1\"\n values = [@id]\n SqlRunner.run(sql, values)\n# => Deleting customer record, nothing to return\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 if params[:customers]\n customers.where(id: params[:customers].values).delete_all\n elsif params[:id]\n customers.find_by_id(params[:id]).try(:destroy)\n end\n redirect_to customers_url(search: params[:search])\n end", "def destroy\n @customer.destroy\n end", "def delete path\n make_request(path, \"delete\", {})\n end", "def destroy\n @customer_info.destroy\n respond_to do |format|\n format.html { redirect_to customer_infos_url, notice: 'Customer info was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @reach_out_to_customer.destroy\n respond_to do |format|\n format.html { redirect_to reach_out_to_customers_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @customer_set.destroy\n respond_to do |format|\n format.html { redirect_to customer_sets_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @sixmonth_customer = SixmonthCustomer.find(params[:id])\n @sixmonth_customer.destroy\n\n respond_to do |format|\n format.html { redirect_to sixmonth_customers_url }\n format.json { head :no_content }\n end\n end", "def delete\n render json: Users.delete(params[\"id\"])\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" ]
[ "0.7459997", "0.7459997", "0.74485695", "0.74485695", "0.74485695", "0.74485695", "0.74485695", "0.74485695", "0.74485695", "0.7435839", "0.7429404", "0.7429404", "0.7429404", "0.7429404", "0.7429404", "0.7429404", "0.7429404", "0.7429404", "0.7364333", "0.732843", "0.72985286", "0.72831863", "0.7236284", "0.71671945", "0.71460426", "0.71443635", "0.7143448", "0.7143448", "0.7135988", "0.71215165", "0.7119578", "0.7108053", "0.7100693", "0.7094806", "0.709428", "0.7090288", "0.7078817", "0.7078817", "0.7078817", "0.70757055", "0.7075676", "0.7058505", "0.7056407", "0.7037161", "0.7028059", "0.70055234", "0.69809604", "0.6980533", "0.69780326", "0.69721895", "0.6955825", "0.69444925", "0.69270974", "0.69230574", "0.6898595", "0.68974566", "0.68970734", "0.6892207", "0.68822056", "0.68665344", "0.6862874", "0.6862019", "0.6833437", "0.6830371", "0.6830244", "0.6823991", "0.6812947", "0.6811358", "0.6802542", "0.6769426", "0.67567897", "0.67558765", "0.67558765", "0.6755757", "0.67547226", "0.67405546", "0.67126524", "0.6710435", "0.6703614", "0.67006505", "0.67001665", "0.6699188" ]
0.7141246
42
Use callbacks to share common setup or constraints between actions.
def set_customer @customer = Customer.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 set_actions\n actions :all\n end", "def define_action_helpers?; 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_handler\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 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 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 action\n end", "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 after_set_callback; end", "def initialize(*args)\n super\n @action = :set\nend", "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 around_hooks; 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 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 setup(&blk)\n @setup_block = blk\n end", "def default_action; end", "def callback_phase\n super\n end", "def advice\n end", "def _handle_action_missing(*args); end", "def call\n setup_context\n super\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 shared_action(name, &block)\n @controller.shared_actions[name] = block\n end", "def duas1(action)\n action.call\n action.call\nend" ]
[ "0.61637366", "0.60446453", "0.59452957", "0.591511", "0.58885515", "0.5834122", "0.57761765", "0.5702554", "0.5702554", "0.5652102", "0.5619581", "0.5423898", "0.5409782", "0.5409782", "0.5409782", "0.5394745", "0.53780794", "0.5356209", "0.5338898", "0.53381324", "0.5328622", "0.5309231", "0.5296901", "0.529641", "0.5296097", "0.5258364", "0.5242683", "0.5236372", "0.5236372", "0.5236372", "0.5236372", "0.5236372", "0.52346426", "0.52320486", "0.5225926", "0.52210605", "0.52171826", "0.52138335", "0.5207914", "0.52069265", "0.5176269", "0.5174653", "0.51730466", "0.51650184", "0.5161409", "0.5156175", "0.5154185", "0.5151096", "0.5151089", "0.51452935", "0.5138662", "0.51339483", "0.5113475", "0.51132", "0.51132", "0.5108031", "0.51075375", "0.5090693", "0.50892115", "0.5081523", "0.5081454", "0.5064919", "0.50545585", "0.50531805", "0.50501585", "0.50501585", "0.50329936", "0.5024674", "0.50203156", "0.50156844", "0.50149846", "0.50011337", "0.4999346", "0.49984375", "0.4988749", "0.4988749", "0.49842322", "0.49800175", "0.4979922", "0.49791628", "0.49666047", "0.49655434", "0.49559638", "0.49557537", "0.49554902", "0.4953974", "0.49519545", "0.49449277", "0.49440357", "0.49329734", "0.49315402", "0.49261367", "0.4925912", "0.4925598", "0.4924306", "0.49202663", "0.49167567", "0.49164373", "0.4915191", "0.49145022", "0.49140996" ]
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def customer_params params.require(:customer).permit(:phone_number, :latitude, :longitude) 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
A group is not destroyed, it's disbanded!
def disband_group destroy_collection({:table=>'groups', :on_success=>'You disbanded the group.'}) rescue flash[:notice] = "Could not find group." redirect_to :action=>'groups' end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def remove_group(group)\r\n\t\tsend('RMG', group.info[:guid])\r\n\t\t## XXX save changes locally?\r\n\t\treturn 1\r\n\tend", "def remove_group(group)\n self.groups.destroy group \n end", "def dissolve_groups\n groups.destroy_all\n end", "def refuse_group group\n group_invitations.where(group: group).first.destroy\n end", "def delete_group(group)\n\t\t\tend", "def delete_group(group)\n\t\t\tend", "def remove_group!( group )\n save if remove_group( group )\n end", "def remove_group\n create_group.tap do |r|\n r.action(:remove)\n end\n end", "def purge (group)\n ensure_group(group).purge\n end", "def destroy\n Group.rebuild! if nil.|Group.find(:first).rgt\n\t @group = Group.find(params[:id])\n @group.destroy\n\n respond_to do |format|\n format.html { redirect_to(groups_url) }\n format.xml { head :ok }\n end\n end", "def leave(group)\n group_membership_ids.include? group.id\n groups.destroy(group)\n end", "def destroy\n @group.destroy\n msg = [\"Destroyed group.\", rebuild_configs].join(\" \")\n redirect_to groups_url, notice: msg\n end", "def perform_destroy\n api.group_destroy(self)\n end", "def unlink_group\n if self.parentID != nil\n Group.find(self.parentID).remove_members([self.id.to_s])\n end\n end", "def remove_from_group(group)\n self.memberships.find_by(group_id: group.id).destroy!\n end", "def disown!(group)\n return if group.class != Group\n e = Entity.find_by(id: self.id)\n return if e.nil?\n relationship = EntityGroupRelationship.find_by(entity_id: self.id, group_id: group.id)\n return if relationship.nil?\n if relationship.position.nil?\n return relationship.destroy\n end\n index = relationship.position\n relationship.destroy\n # self.update_position(index)\n end", "def empty_group\n self.group_memberships.each {|m| m.destroy}\n end", "def on_tag_group_destroy( node, tag_group )\n\t\t\tself.log.debug \"unhandled on_tag_group_destroy: node %p no longer has tag group %p\" %\n\t\t\t \t[ node, tag_group ]\n\t\tend", "def test_delete\n g = [22058]\n Group.delete(g)\n end", "def delete_related_groups\n \n end", "def reset_group_membership\n shell_out!(\"group\", \"mod\", \"-n\", \"#{new_resource.group_name}_bak\", new_resource.group_name)\n\n shell_out!(\"group\", \"add\", set_options(overwrite_gid: true))\n\n shell_out!(\"group\", \"del\", \"#{new_resource.group_name}_bak\")\n end", "def destroy\n Group.delete_groups_and_acls([id])\n end", "def group_destroy(group)\n if(group.persisted?)\n request(\n :path => \"/groups/#{group.id}\",\n :method => :delete,\n :expects => 204\n )\n true\n else\n false\n end\n end", "def destroy\n @current_user.quit_group(@group)\n respond_to do |format|\n format.html { redirect_to groups_path }\n format.json { head :no_content }\n end\n end", "def disown_all!\n self.groups.each do |group|\n self.disown!(group)\n end\n end", "def unjoin(group)\n\t\t\treturn false unless group.is_a?(Group)\n\t\t\tgroup.remove(self)\n\t\tend", "def destroy\n if !self.insurance_sessions.blank?\n #check insurance session. If there is an insurance billng, then there must be a session.\n errors.add :base, \"The Group is associated to a session and/or claim. Group cannot be deleted\"\n else\n run_callbacks :destroy do\n self.update_column(:deleted, true)\n end\n end\n end", "def destroy\n @group.destroy\n\n head :no_content\n end", "def destroy\n return access_denied unless is_admin?(current_user)\n\n @group = Group.find(params[:id])\n @group.destroy\n redirect_to(groups_url)\n end", "def before_destroy_group\n controller = PublicActivity.get_controller\n\n # Return if seeding or nothing changes\n return if !controller\n\n current_user = PublicActivity.get_controller.current_user\n\n self.create_activity :destroy, owner: current_user,organization_id: self.organization_id, params: {:detail => I18n.t('logs.destroy_group', group_name: self.name)}\n end", "def destroy\n @group = Group.find(params[:id])\n @group.destroy\n\n redirect_to groups_path\n end", "def destroy\n @group = Group.find(params[:id])\n @group.destroy\n\n redirect_to groups_path\n end", "def group_absent(name, &block)\n execute(\"if dscl . -list /Groups/#{name}; then dscl . -delete /Groups/#{name}; fi\", {}, &block)\n end", "def may_destroy_group?(group)\n\t\t\tmay_administrate?\n\t\tend", "def check_out_group(group)\n @guests_in_room.pop(group.length)\n\n return group\n end", "def destroy\n @group = Group.find_by_param(params[:id])\n @group.tuners.clear\n @group.destroy\n\n respond_to do |format|\n format.html { redirect_to(groups_url) }\n format.xml { head :ok }\n end\n end", "def clear\n 1.upto(@gsize) do |j|\n 1.upto(@gsize) do |i|\n stone = @ban[j][i]\n stone.group.clear if stone.group\n end\n end\n # Collect all the groups and put them into @garbage_groups\n @killed_groups.shift # removes @@sentinel\n @merged_groups.shift # removes @@sentinel\n @garbage_groups.concat(@killed_groups)\n @garbage_groups.concat(@merged_groups)\n @killed_groups.clear\n @killed_groups.push(@@sentinel)\n @merged_groups.clear\n @merged_groups.push(@@sentinel)\n @num_groups = 0\n @history.clear\n end", "def destroy\n @group = Group.find(params[:group_id])\n authorize! :edit, @group\n Hydra::LDAP.remove_users_from_group(@group.code, [params[:id]])\n redirect_to edit_group_path(@group), :notice=>\"Removed member #{params[:id]}\"\n end", "def destroy\n redirect_to :action => :index and return unless is_owner?\n for member in @group.members\n member.destroy\n end\n @group.destroy\n respond_to do |format|\n format.html { redirect_to groups_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @group = Group.find(params[:group_id])\n @referred_user = User.find(params[:user_id])\n if @referred_user.is_admin?(@group)\n render_error(404, request.path, 20110, \"Admin cannot leave group.\") and return\n end\n # self or admin\n if current_user?(@referred_user) || @current_user.is_admin?(@group)\n @referred_user.is_member?(@group)\n if @referred_user.leave!(@group)\n render json: {result: 1}\n else\n render json: {result: 0}\n end\n else\n render_error(404, request.path, 20110, \"User is not group member.\")\n end\n end", "def remove_user_from_group(user, group)\n\t\t\tend", "def remove_old_sessions_in_group\n candidates = find_old_sessions\n candidates.where(group: @group).destroy_all\nend", "def destroy\n #@s_group.destroy\n @s_group = SGroup.find(params[:id].to_i)\n @s_group.delete_flg = 1\n @s_group.save!\n\n respond_to do |format|\n format.html { redirect_to s_groups_url, notice: 'S group was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @group.destroy\n audit(@group, \"destroy\", @group.name )\n respond_to do |format|\n format.html { redirect_to groups_path, notice: 'Group was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @group = Group.find(params[:id])\n\n mbs = Membership.where \"group_id = ?\", @group.id\n\n mbs.each do |m|\n m.destroy\n end\n\n @group.destroy\n\n respond_to do |format|\n format.html { redirect_to groups_url }\n format.json { head :ok }\n end\n end", "def remove_group_watcher(group)\n return nil unless group && group.is_a?(Group)\n GroupWatcher.delete_all \"watchable_type = '#{self.class}' AND watchable_id = #{self.id} AND group_id = #{group.id}\"\n end", "def destroy\n @group.destroy\n redirect_to groups_url, notice: \"Group was successfully destroyed.\" \n end", "def destroy\n @group = Group.find(params[:id])\n @user_id = @group.user_id\n @group.destroy\n\n respond_to do |format|\n format.html { redirect_to groups_url(:user_id=>@user_id) }\n # format.html { redirect_to groups_sidebartab_url(:user_id=>@user_id) }\n format.json { head :no_content }\n end\n end", "def clear_group!\n Vedeu.bind(:_clear_group_) do |name|\n Vedeu::Clear::NamedGroup.render(name)\n end\n end", "def delete_group\r\n if request.post?\r\n @group=Group.find_by_id(params[:id], :conditions=>['account_id = ?',session[:account_id]])\r\n if @group.nil?\r\n flash[:error] = \"Invalid action.\"\r\n else\r\n flash[:success]= \"Group \" + @group.name + \" was deleted successfully \"\r\n @group.destroy\r\n @group_devices = Device.find(:all, :conditions=>['group_id=?',@group.id])\r\n for device in @group_devices\r\n device.icon_id =\"1\"\r\n device.group_id = nil\r\n device.save\r\n end\r\n end\r\n end\r\n redirect_to :action=>\"groups\"\r\n end", "def destroy\n @groupDelete = @group.freeze\n @group.destroy\n @groupFirstId = current_user.groups.where(\"group_day = ?\", @groupDelete.group_day).first.id if !current_user.groups.where(\"group_day = ?\", @groupDelete.group_day).first.nil?\n if @groupFirstId.nil?\n redirect_to root_path, notice: 'You have deleted all your classes for that day'\n elsif $deletedFromEdit == true\n $deletedFromEdit = false\n redirect_to action: \"edit\", id: @groupFirstId\n else\n redirect_to root_path, notice: 'Class was incinerated'\n end\n end", "def destroy\n @assign_group_place.destroy\n end", "def remove_from_all_groups\n self.group_memberships.each {|m| m.destroy}\n end", "def remove_from_group(group)\n gm = Fl::Framework::Actor::GroupMember.query_for_actor_in_group(self, group).first\n return false if gm.nil?\n\n self.actor_containers.delete(gm)\n true\n end", "def action_remove\n notifying_block do\n remove_user\n remove_group if new_resource.group\n end\n end", "def deleteGroup _args\n \"deleteGroup _args;\" \n end", "def kill_group(i, j)\n group, adj = get_adj(i, j, -1)\n group.each{|i, j|\n set_stone_at(i, j, 0)\n }\n return group\n end", "def hcRemoveGroup _obj, _args\n \"_obj hcRemoveGroup _args;\" \n end", "def destroy\n if @group.destroy\n render json: {result: 1}\n else\n render json: {result: 0}\n end\n end", "def camaleon_post_clone_on_inactive(plugin)\n plugin.get_field_groups().destroy_all\n end", "def destroy\n Log.create! description: \"<b>#{current_user.email} </b> deleted group <b>#{@group.name} </b> at #{Time.zone.now.strftime '%d-%m-%Y %H:%M:%S'}\", role_id: current_user.roles.ids.first\n @group.destroy\n respond_to do |format|\n format.html { redirect_to groups_url, notice: 'Group was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def empty_group(group, opts)\n # unlink all resources from this group\n group.empty_group\n end", "def remove_agent_group_id(opts)\n opts = check_params(opts,[:group_id])\n super(opts)\n end", "def delete_group\n @mailing_list_group.destroy if @ok\n render 'update_list'\n end", "def destroy\n @flr = @group.flr\n @group.destroy\n redirect_to flr_groups_url(@flr), notice: 'Group was successfully destroyed.'\n end", "def delete(group)\n @queue[group.depth].delete(group)\n end", "def delete_vlan_group\n super\n end", "def destroy_google_group\n result = Gandalf::GoogleApiClient.delete_google_group(self.apps_id)\n result.data\n end", "def destroy_group_stage_game(game) \n # puts \"destroy: #{self.first_round.jornada}: #{game[0].name} vs #{game[1].name} \"\n \n @game = Game.find(:first, :conditions => [\"cup_id = ? and home_id = ? and away_id = ? and type_name = 'GroupStage'\", \n self.id, game[0].id, game[1].id])\n unless @game.nil?\n # puts \"destroy: #{self.first_round.jornada}: #{game[0].name} vs #{game[1].name} \"\n @game.destroy\n end\n end", "def destroy\n begin\n if Group.size > 1\n @group.destroy\n redirect_to(list_groups_path(:page => params[:page]), :notice => t(\"group.destroyed\"))\n else\n redirect_to(list_groups_path(:page => params[:page]), :notice => t(\"group.last_one\"))\n end\n rescue\n redirect_to(list_groups_path(:page => params[:page]), :error => t(\"group.not_destroyed\"))\n end\n end", "def remove_dependency_group!\n @dependency_groups.pop\n end", "def delete_group(group_id)\n\t\tself.group_list.delete(group_id)\n\t\tself.update_attribute(:group_list, self.group_list)\n\tend", "def remove_group(name)\n visit 'groups'\n click_link name\n\n page.accept_alert do\n click_button 'group_delete'\n end\n end", "def delete_group(uuid)\n Uploadcare::Group.delete(uuid)\n end", "def destroy\n # @group = @hub.groups.get(params[:id])\n @group.destroy\n\n respond_to do |format|\n format.html { redirect_to hub_groups_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @group = Group.find_by_guid(params[:id])\n @group.destroy\n\n respond_to do |format|\n format.html { redirect_to groups_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @group = Group.find(params[:id])\n @group.destroy\n\n head :no_content\n end", "def destroy_group\n group = Group.find(params[:id])\n\n if %w{Cookbook Tool}.include?(params[:resourceable_type])\n resource = params[:resourceable_type].constantize.find(\n params[:resourceable_id]\n )\n\n collaborator_users = group_collaborators(resource, group).map(&:user)\n\n remove_group_collaborators(group_collaborators(resource, group))\n\n GroupResource.where(group: group, resourceable: resource).each(&:destroy)\n\n flash[:notice] = t(\"collaborator.group_removed\", name: group.name) + \" \"\n\n dup_user_collaborators(collaborator_users, resource).each do |collaborator|\n flash[:notice] << if collaborator.group.present?\n \"#{collaborator.user.username} is still a collaborator associated with #{collaborator.group.name}\" + \" \"\n else\n \"#{collaborator.user.username} is still a collaborator on this #{params[:resourceable_type]}\" \" \"\n end\n end\n resource_path_str = \"#{params[:resourceable_type].underscore}_path\"\n redirect_to(\n send(resource_path_str, resource)\n )\n else\n not_found!\n end\n end", "def destroy\n @rebalancegroup = Rebalancegroup.find(params[:id])\n @name = @rebalancegroup.group_name\n if @rebalancegroup.destroy\n render :text =>\"--\"+@name +\"--delete success\"\n end\n end", "def destroy\n @mem_group.destroy\n respond_to do |format|\n format.html { redirect_to admin_mem_groups_url, notice: '会员分组成功删除.' }\n format.json { head :no_content }\n end\n end", "def destroy\n \n @gro_mem = GroupMember.find params[:id]\n @gro_num=@gro_mem.group_id\n @group_member = GroupMember.new\n \n @gro_mem.destroy\n redirect_to :controller => 'groups', :action => 'show', :id => @gro_num\n end", "def delete_group(group)\n\t\t\t\tgroupname = nil\n\t\t\t\tif(group.respond_to(:groupname))\n\t\t\t\t\tgroupname = group.groupname\n\t\t\t\telse\n\t\t\t\t\tgroupname = group\n\t\t\t\tend\n\n\t\t\t\t`pw groupdel #{groupname}`\n\t\t\tend", "def remove_watcher_group(group)\n return nil unless group && group.is_a?(Group)\n Watcher.delete_all \"watchable_type = '#{self.class}' AND watchable_id = #{self.id} AND user_id = #{group.id}\"\n end", "def remove_group( group )\n raise TypeError.new('not a group') unless group.is_a?(Ecore::Group)\n tmp_group_ids = self.group_ids.split(',')\n tmp_group_ids.delete(group.id)\n self.group_ids = tmp_group_ids.join(',')\n true\n end", "def destroy\n @group = Group.find(params[:id])\n @group.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_groups_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n if (user_signed_in? && ([2].include?(current_user.role)))\n @cultural_heritage_group = CulturalHeritage::Group.find(params[:id])\n mensaje = @cultural_heritage_group.erasable\n if mensaje.blank?\n @cultural_heritage_group.deleted = 1\n @cultural_heritage_group.save\n end\n respond_to do |format|\n format.html { redirect_to(cultural_heritage_groups_url, :notice => mensaje) }\n format.xml { head :ok }\n end\n else\n respond_to do |format|\n format.html { redirect_to(new_user_session_path) }\n end\n end\n end", "def destroy\n @group = GROUP.first_or_get(params[:id])\n @group.current_user = current_user\n @group.destroy if @group\n\n respond_to do |format|\n flash[:notice] = 'Group was successfully deleted.'\n format.html { redirect_to(groups_url) }\n format.xml { head :ok }\n end\n end", "def destroy_assignment( assignment_symbol, user ) \n if self.is_started == true \n return nil\n end\n \n GroupLoanAssignment.find(:all, :conditions => {\n :group_loan_id => self.id,\n :assignment_type => GROUP_LOAN_ASSIGNMENT[assignment_symbol],\n :user_id => user.id\n }).each do |gla|\n gla.destroy \n end\n \n return true # success in destroying \n end", "def remove_from_lb(group)\n @haproxy.identity_filter(@load_balancer)\n # We don't have to identify the nodes in the group\n # for every action. I'm doing it here to make each\n # method easier to read\n @rpcutil.class_filter(group)\n begin\n @rpcutil.ping.each do |node|\n hostname = node.results[:sender]\n # Disable the nodes\n @haproxy.disable(:backend => 'puppetcamp', :server => hostname).each do |rpcresult|\n if rpcresult.results[:statuscode] != 0\n raise LoadBalancerRemoveException, hostname\n end\n end\n end\n ensure\n @haproxy.reset_filter\n @rpcutil.reset_filter\n end\nend", "def destroy\n @dog_breed_group.destroy\n respond_to do |format|\n format.html { redirect_to dog_breed_groups_url }\n format.json { head :no_content }\n end\n end", "def delete_group group, &block\n\t\t\traise \"No group was given to delete\" if group.nil?\n\t\t\traise \"Group must be a NLHue::Group object\" unless group.is_a?(Group)\n\t\t\traise \"Group is not from this bridge\" unless group.bridge == self\n\t\t\traise \"Cannot delete group 0\" if group.id == 0\n\n\t\t\tdelete_api \"/groups/#{group.id}\", :lights do |response|\n\t\t\t\tstatus, result = check_json response\n\n\t\t\t\tif status\n\t\t\t\t\t@groups.delete group.id\n\t\t\t\tend\n\n\t\t\t\tyield status, result if block_given?\n\n\t\t\t\tif status\n\t\t\t\t\tBridge.notify_bridge_callbacks self, true\n\t\t\t\tend\n\t\t\tend\n\t\tend", "def destroy\n @reagent_group = ReagentGroup.find(params[:id])\n @reagent_group.destroy\n\n respond_to do |format|\n format.html { redirect_to reagent_groups_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @ail_group = AilGroup.find(params[:id])\n @ail_group.destroy\n\n respond_to do |format|\n format.html { redirect_to(ail_groups_url) }\n format.xml { head :ok }\n end\n end", "def delete_group\n @group = Group.find(params[:id])\n @created_g_u= Array.new\n @defalut_group = @login_user.default_group[0]\n @group.group_users.each do |g_u|\n g_u.destroy\n group = @login_user.belongs_to_group(g_u.user_id)\n if group.blank?\n group_user = GroupUser.new(:user_id=>g_u.user_id,:group_id=>@defalut_group.id) if group.blank?\n @created_g_u << group_user if group_user.save\n end \n end\n @group.destroy\n #redirect_to :back\n respond_to do |format|\n format.js\n end\n end", "def destroy\n \t# we can destroy group only if current user is owner or current user is admin\n \tif @group.owner_id = current_user.id || is_admin?(current_user)\n\t @group.destroy\n\t respond_to do |format|\n\t format.html { redirect_back_or mygroups_path }\n\t format.json { head :no_content }\n\t end\n\t end\n end", "def mark_dead_group(stone)\n group = self.search(stone).first.group\n @dead_groups << group\n end", "def destroy\n @group = Group.find(params[:id])\n authorize @group, :destroy?\n @group.destroy\n\n respond_to do |format|\n format.html { redirect_to(browse_groups_url) }\n format.xml { head :ok }\n end\n end", "def destroy_group_with_extension\n # INFO: currently only a superuser can destroy a group. See CartoDB/cartodb-postgresql#114\n organization.owner.in_database(as: :superuser) do |conn|\n Carto::Group.destroy_group_extension_query(conn, name)\n end\n end", "def destroy\n @group = Group.find(params[:id])\n @group.destroy\n\n respond_to do |format|\n flash[:success] = \"Группа успешно удалена.\"\n format.html { redirect_to groups_url }\n format.json { head :no_content }\n end\n end", "def deprovision_groups\n @attributes[:deprovision_groups]\n end" ]
[ "0.75015825", "0.7431315", "0.73753315", "0.7365237", "0.7246178", "0.7246178", "0.7214653", "0.71843475", "0.7062452", "0.7038382", "0.69918215", "0.6975259", "0.6952159", "0.6875535", "0.6863994", "0.6835459", "0.682714", "0.6824124", "0.68159384", "0.6806176", "0.676754", "0.6738527", "0.6694268", "0.6631011", "0.6626105", "0.66084826", "0.65995955", "0.65881866", "0.656899", "0.6560967", "0.6555389", "0.6555389", "0.6553048", "0.6546272", "0.6545357", "0.6528903", "0.6523057", "0.65151083", "0.6500483", "0.64953434", "0.64850456", "0.64837044", "0.64806217", "0.6476348", "0.64697427", "0.6469263", "0.6439718", "0.6437211", "0.64341056", "0.64195377", "0.6417736", "0.64140797", "0.640506", "0.63967675", "0.6396024", "0.63959986", "0.6389768", "0.6388049", "0.6387869", "0.6380177", "0.6368008", "0.63519245", "0.6349508", "0.6346427", "0.6346118", "0.633823", "0.63376117", "0.633202", "0.6331309", "0.6312159", "0.63042057", "0.6301361", "0.63002574", "0.6299455", "0.62873584", "0.62846863", "0.6280275", "0.62754214", "0.6266727", "0.62663335", "0.6259001", "0.6237119", "0.62217474", "0.6217927", "0.62152916", "0.6214204", "0.6207947", "0.6206778", "0.6203362", "0.62027436", "0.6201462", "0.6194002", "0.61872864", "0.6184698", "0.61841816", "0.6175091", "0.6173849", "0.6172116", "0.61698323", "0.6162959" ]
0.75392514
0
The user methods do not use the collection_methods module
def users @user_pages, @users = paginate :users, :per_page => 10 render 'admin/users' end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def detect_collection_methods; end", "def collection; end", "def collection; end", "def collection_methods\n (@_collection_methods ||= {})\n end", "def collections; end", "def collection_method name, &block\n collection_methods[name] = block\n end", "def method_missing(method, *args)\n if Array.method_defined?(method) && !Object.method_defined?(method)\n if block_given?\n collection.send(method, *args) { |*block_args| yield(*block_args) }\n else\n collection.send(method, *args)\n end\n else\n super\n #message = \"undefined method `#{method.to_s}' for \\\"#{collection}\\\":#{collection.class.to_s}\"\n #raise NoMethodError, message\n end\n end", "def method_missing(method_name, *args, &proc)\n collection.send(method_name, *args, &proc)\n end", "def methods; end", "def methods; end", "def methods; end", "def methods; end", "def collection\n raise(NotImplementedError, '#collection must be defined in the TypicalSituation implementation.')\n end", "def make_collection\n raise NotImplementedError\n end", "def make_collection\n NotImplemented\n end", "def make_collection\n NotImplemented\n end", "def internal_methods; end", "def methods() end", "def collection_names; end", "def collection\n klass.collection\n end", "def method_missing(method, *args, &block)\n @collection_desc = ActiveSupport::Inflector.humanize(method).downcase\n\n @collection_desc = ActiveSupport::Inflector.singularize(\n @collection_desc) if @expected == 1\n\n unless method == :characters and ''.respond_to?(:characters)\n @collection_name, @plural_collection_name =\n method, ActiveSupport::Inflector.pluralize(method.to_s).to_sym\n end\n\n self\n end", "def collection\n klass.collection\n end", "def private_method\n end", "def private; end", "def collection_node; end", "def collection_node; end", "def collection\n self.class.collection\n end", "def collection\n self.class.collection\n end", "def initialize\n @coll = self.class.collection\n end", "def collection?\n raise NotImplementedError\n end", "def initialize\n @coll=self.class.collection\n end", "def collection_name; end", "def collection_name; end", "def collection_name; end", "def helpers; end", "def helpers; end", "def helpers; end", "def method; end", "def method; end", "def method; end", "def method; end", "def method; end", "def method; end", "def method; end", "def method; end", "def method; end", "def method; end", "def method; end", "def method; end", "def method_missing symbol, *args\n if @klass.collection_methods[symbol]\n instance_exec *args, &@klass.collection_methods[symbol]\n else\n super\n end\n end", "def api\n methods - Object.public_methods\n end", "def collection_class\n defined?(Effective::StyleGuide) ? Effective::StyleGuide : super\n end", "def apis; end", "def detect_collection_methods(collection, options)\n sample = collection.first || collection.last\n case sample\n when Array\n label, value = :first, :last\n when Integer\n label, value = :to_s, :to_i\n when String, NilClass\n label, value = :to_s, :to_s\n end\n\n options[:label_method] ||= label || SimpleForm.collection_label_methods.find { |m| sample.respond_to?(m) }\n options[:value_method] ||= value || SimpleForm.collection_value_methods.find { |m| sample.respond_to?(m) }\n end", "def methods\n super + DELEGATED_METHODS\n end", "def public_method; end", "def collection(objectName)\n Hirsute::Collection.new(objectName)\nend", "def collection? \n true\n end", "def collection\n @collection ||= load_collection\n end", "def identify(_collection)\n raise NotImplementedError\n end", "def collection_scope; end", "def collection\n @collector.collection\n end", "def collection?\n NotImplemented\n end", "def collection?\n NotImplemented\n end", "def member_collections\n collections\n end", "def implementation; end", "def implementation; end", "def respond_to_missing?(method_name, _include_private = false)\n @collection.include?(method_name.to_s)\n end", "def collection?\n true\n end", "def method_missing(method_name, *_args, &_block)\n @collection.fetch(method_name.to_s) do\n raise \"Could not find `#{method_name}` in #{self.class.name}\"\n end\n end", "def collection_class\n OneToMany::Collection\n end", "def collection_class\n OneToMany::Collection\n end", "def private_method; end", "def initialize(attrs, collection_name, klass, client, method_name, method_options)\n @attrs = attrs\n @client = client\n @method_name = method_name\n @method_options = method_options\n @collection = Array(attrs[collection_name.to_sym]).map do |item|\n if klass\n klass.fetch_or_new(item)\n else\n item\n end\n end\n singleton_class.class_eval do\n alias_method(collection_name.to_sym, :collection)\n end\n end", "def filter_methods; end", "def collection? \n false\n end", "def collection\n @collection ||= collection_values\n end", "def collection\n @collection.is_a?(Proc) ? @collection.call : @collection\n end", "def finder_methods; end", "def double_collections_by_parameter_name; end", "def double_collections_by_parameter_name; end", "def collection\n @collection ||= Permission.all\n end", "def collection_decorator\n\n\n\n\n\n\n\n if decorator_class\n\n\n\n\n\n\n\n Wrapper.wrap decorator_class\n\n\n\n\n\n\n\n end\n\n\n\n\n\n\n\n end", "def expose; end", "def public; end", "def public; end", "def initialize(attrs, collection_name, klass, client, id, method_name, method_options)\n @attrs = attrs\n @client = client\n\t\t\t@id = id\n @method_name = method_name\n @method_options = method_options\n @collection = Array(attrs[:data]).map do |item|\n if klass\n klass.fetch_or_new(item)\n else\n item\n end\n end\n class_eval do\n alias_method(:data, :collection)\n end\n end", "def internal; end", "def accessibility; end", "def collection(name, options = {})\n set_default_options(name, options)\n super(name, options)\n end", "def finder_methods=(_arg0); end", "def is_collection_like\n return (self.is_collection || self.is_exhibition)\n end", "def method_missing(name, *args, &block)\n if @collection.respond_to? name\n @collection.send(name, *args, &block)\n else\n @collection[:all].send(name, *args, &block)\n end\n end", "def protected_method\n end", "def hidden_apis; end", "def members; end", "def members; end", "def members; end", "def members; end", "def members; end", "def members; end" ]
[ "0.7727173", "0.7489798", "0.7489798", "0.742187", "0.7111487", "0.6907021", "0.6797692", "0.67157626", "0.67014515", "0.67014515", "0.67014515", "0.67014515", "0.66918343", "0.656956", "0.6560988", "0.6560988", "0.6510211", "0.6497495", "0.6477487", "0.6399777", "0.635246", "0.6316013", "0.62719315", "0.6185211", "0.61665004", "0.61665004", "0.61613613", "0.61613613", "0.61610186", "0.6153201", "0.6135807", "0.61124724", "0.61124724", "0.61124724", "0.6105891", "0.6105891", "0.6105891", "0.6080501", "0.6080501", "0.6080501", "0.6080501", "0.6080501", "0.6080501", "0.6080501", "0.6080501", "0.6080501", "0.6080501", "0.6080501", "0.6080501", "0.6071337", "0.6064193", "0.60370106", "0.603118", "0.60286903", "0.6015485", "0.60143316", "0.5996353", "0.5983508", "0.59782827", "0.5966263", "0.59627634", "0.5959237", "0.5951035", "0.5951035", "0.59488463", "0.5935888", "0.5935888", "0.5934571", "0.59208643", "0.5920061", "0.59148985", "0.59148985", "0.5901732", "0.5898923", "0.58964527", "0.587299", "0.5870184", "0.5854957", "0.5830516", "0.58256763", "0.58256763", "0.5822726", "0.58160365", "0.58056253", "0.5772255", "0.5772255", "0.5771242", "0.5761928", "0.57601964", "0.5743678", "0.5734917", "0.5703171", "0.56982964", "0.5693614", "0.5691517", "0.5689975", "0.5689975", "0.5689975", "0.5689975", "0.5689975", "0.5689975" ]
0.0
-1
We can use these expectations to assert something affirmative
def test_capybara_can_find_element on_visiting_browserkoans_test_page do assert_equal __(true), page.has_selector?('#mypara') assert_nothing_raised do expect(page).to have_selector(__('#mypara')) end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def assertions; end", "def assertions; end", "def check_expectations\n expectations.each do |subject, matcher|\n expect(subject).to matcher if matcher\n end\n nil\n end", "def test_espresso_more_effective\n hipster = Human.new \"Hipster\"\n espresso = Espresso.new \"Espresso\"\n\n hipster.buy espresso\n assert espresso.drinks_before_empty == 1\n\n hipster.drink!\n assert (hipster.alertness > 0.4)\n\n end", "def assert(thing_to_be_asserted, message = nil)\n thing_to_be_asserted.should be true\nend", "def test_contains_four_eachface\n assert true == false\n end", "def assertions\n @@assertions\n end", "def check_entry(entry, expected_name, expected_number, expected_email)\n expect(entry.name).to eq expected_name\n expect(entry.phone_number).to eq expected_number\n expect(entry.email).to eq expected_email\n end", "def test_expectation_with_no_arguments\n @mock.expect(:status, :awesome)\n status = @mock.status\n assert_equal :awesome, status\n @mock.verify\n end", "def check_entry(entry, expected_name, expected_number, expected_email) #helper method used to consildate redundant code\n expect(entry.name).to eq expected_name\n expect(entry.phone_number).to eq expected_number\n expect(entry.email).to eq expected_email\n end", "def test_appellation_validity\n assert @valid_appellation_1.valid?\n assert @valid_appellation_2.valid?\n end", "def assert_pm_privilege_expectations(actual_privileges, expected_privileges)\n expected_privileges.each do |ep|\n u_id = ep[0].unique_identifier\n op_id = ep[1].unique_identifier\n obj_id = ep[2].unique_identifier\n\n found_actual_priv = actual_privileges.find do |priv|\n priv[0].unique_identifier == u_id &&\n priv[1].unique_identifier == op_id &&\n priv[2].unique_identifier == obj_id\n end\n\n pp(\"expected to find #{[u_id, op_id, obj_id]}\") if found_actual_priv.nil?\n\n expect(found_actual_priv).to_not be_nil\n end\n expect(actual_privileges.count).to eq(expected_privileges.size)\n assert_pm_scoped_privilege_expectations\nend", "def assert_expected_assertions expected = 1\n yield\n ensure\n actual = tc.assertions + spec.assertions\n assert_equal expected, actual, \"expected #{expected} assertions to be \" +\n \"fired during the test, not #{actual}\"\n end", "def test_acknowledgement\n valid = Netgiro.notification(http_raw_data, :credential2 => 'password')\n assert valid.acknowledge\n assert valid.success?\n assert valid.complete?\n \n invalid = Netgiro.notification(http_raw_data, :credential2 => 'bogus')\n assert !invalid.acknowledge\n assert !invalid.success?\n assert !invalid.complete?\n end", "def test_truth\n end", "def expected?\n false\n end", "def test_contains_13_eachsuit\n assert true == false\n end", "def _assert_exposes_for(asserted, expected, **options)\n passed, matches, last_failed = Assert.assert_attributes(asserted, expected, **options) do |_matches, last_failed|\n name, expected_value, actual_value, _passed, is_eq, error_msg = last_failed\n\n is_eq ? assert_equal(expected_value, actual_value, error_msg) : assert(expected_value, error_msg)\n\n return false\n end\n\n return true\n end", "def assert_silent; end", "def assert_alike(exp, act, msg=nil)\n LikeAssay.assert!(act, exp, :message=>msg, :backtrace=>caller)\n end", "def test_should_not_validate_double_claiming\n claiming = create_claiming\n assert claiming.valid?\n claiming = create_claiming\n assert !claiming.valid?\n end", "def assert_same(exp, act, msg=nil)\n IdentityAssay.assert!(act, exp, :message=>msg, :backtrace=>caller)\n end", "def test_truth\n assert true\n end", "def before_assert\n end", "def assert_equal(exp, act, msg=nil)\n EqualAssay.assert!(act, exp, :message=>msg, :backtrace=>caller)\n end", "def test_under_age\n\t\tassert_equal true, @user.age(14)\n\tend", "def assert_consistent test\n test.flunk unless state == A or state == Enter\n end", "def check_entry(entry, expected_name, expected_number, expected_email)\n expect(entry.name).to eq expected_name\n expect(entry.phone_number).to eq expected_number\n expect(entry.email).to eq expected_email\n end", "def verifyEqual(exp_val,act_val)\n assert_equal(exp_val, act_val,\"Wrong value Expected #{exp_val} Actual #{act_val}\")\n end", "def assert(actual, expected)\n\traise \"actual: #{actual}, expected: #{expected}\" unless expected == actual\nend", "def assertions=(_arg0); end", "def assertions=(_arg0); end", "def test_both_players_exceed_defcon\n scenario us: 4, ussr: 5, defcon: 3\n assert_no_award\n end", "def test_any_chance_of_working \n assert_equal(true, credit_cards(:cc_no_statuses_live).any_chance_of_working?)\n assert_equal(true, credit_cards(:cc_no_statuses_live).any_chance_of_working?(true))\n\n assert_equal(false, credit_cards(:cc_no_statuses_expired).any_chance_of_working?)\n assert_equal(true, credit_cards(:cc_no_statuses_expired).any_chance_of_working?(true))\n\n assert_equal(false, credit_cards(:cc_one_status_expired).any_chance_of_working?)\n assert_equal(true, credit_cards(:cc_one_status_expired).any_chance_of_working?(true))\n\n assert_equal(false, credit_cards(:cc_one_status_expired).any_chance_of_working?)\n assert_equal(true, credit_cards(:cc_one_status_expired).any_chance_of_working?(true))\n\n assert_equal(true, credit_cards(:cc_one_status_gateway).any_chance_of_working?)\n assert_equal(true, credit_cards(:cc_one_status_gateway).any_chance_of_working?(true))\n\n assert_equal(false, credit_cards(:cc_one_status_addrnomatch).any_chance_of_working?)\n assert_equal(false, credit_cards(:cc_one_status_addrnomatch).any_chance_of_working?(true))\n \n end", "def assert_equal( expected, obtained, msg = nil )\n unless expected == obtained\n fail \"*** assert_equal( #{expected.inspect}, #{obtained.inspect}, #{msg} )\"\n end\nend", "def test_bear_takes_fish_out_of_river\n @bear1.bear_catches_and_eats_fish(@river1)\n assert_equal(1,@bear1.amount_in_stomach())\n assert_equal(1,@river1.number_of_fishes())\n end", "def test_buncha_asserts\n \n # Assert equality.\n expected_result = 1\n actual_result = 1\n assert_equal(expected_result, actual_result, 'Description.')\n\n # Assert boolean.\n value = true\n assert(value, 'Description.')\n\n # Assert nil.\n value = nil\n assert_nil(value, 'Description.')\n\n # Assert object's class matches something.\n my_array = []\n assert_instance_of(Array, my_array, 'Description.')\n\n # Assert a block of code does not raise an exception.\n assert_nothing_raised do\n [1, 2].uniq\n end\n\n # Anyway, you get the idea. If you need something that's not in the\n # list above, look in testup/ruby/test/unit/assertions.rb for 'em all.\n end", "def assertive?\n true\n end", "def assert_required_properties_set!; end", "def assert_pm_scoped_privilege_expectations\n users_or_attributes = policy_machine.users | policy_machine.user_attributes\n objects_or_attributes = policy_machine.objects | policy_machine.object_attributes\n users_or_attributes.product(objects_or_attributes) do |u, o|\n expected_scoped_privileges = policy_machine.operations.reject(&:prohibition?).grep(->op{policy_machine.is_privilege?(u, op.unique_identifier, o)}) do |op|\n [u, op, o]\n end\n expect(policy_machine.scoped_privileges(u,o)).to match_array(expected_scoped_privileges)\n end\n\nend", "def test_hack\n assert(true)\n end", "def should; super end", "def check_entry(entry, expected_name, expected_phone, expected_email)\n expect(entry.name).to eq(expected_name)\n expect(entry.phone_number).to eq(expected_phone)\n expect(entry.email).to eq(expected_email)\n end", "def check_entry(entry, expected_name, expected_number, expected_email)\n expect(entry.name).to eq expected_name\n expect(entry.phone_number).to eq expected_number\n expect(entry.email).to eq expected_email\n end", "def test_verify\n # Start out unavailabl\n assert_raise(Puppet::Network::InvalidClientRequest) do\n @obj.verify(@request)\n end\n class << @obj\n def available?(req)\n true\n end\n end\n assert_raise(Puppet::Network::InvalidClientRequest) do\n @obj.verify(@request)\n end\n class << @obj\n def authorized?(req)\n true\n end\n end\n assert_nothing_raised do\n @obj.verify(@request)\n end\n end", "def test_acknowledgement \n assert @rbk_money.acknowledge\n end", "def has_these_basic_properties(messages_and_expected_returns = {})\n messages_and_expected_returns.each do |message, expected|\n specify \"##{message} returns #{expected.inspect}\" do\n actual = subject.send(message)\n _compare expected, actual\n end\n end\nend", "def test_lend_money_transfers_money\n #Setup\n lender_before =\n lender_after =\n lendee_before =\n lendee_after =\n loan =\n #act\n #assert\n assert_equal(loan, lender_before - lender_after)\n assert_equal(loan, lendee_after- lendee_before)\nend", "def is_expected(event)\n # TODO Implement this\n end", "def test_expectation_with_specific_argument\n date = Date.parse('2015-11-07')\n @mock.expect(:status_on, :awesome, [date])\n status = @mock.status_on(date)\n assert_equal :awesome, status\n @mock.verify\n end", "def test_truth\r\n assert true\r\n end", "def test_truth\r\n assert true\r\n end", "def test_truth\r\n assert true\r\n end", "def test_should_raise_exception_on_verify_if_call_counts_not_as_expected\n @mock.should.receive(:random_call).twice.with(\"a\",\"b\",\"c\").and.return(\"booh\")\n @mock.random_call(\"a\",\"b\",\"c\")\n assert_raise(MockExpectationError) do\n @mock.__verify\n end\n end", "def assert_same(exp, act, msg=nil)\n SameFailure.assert(exp, act, :message=>msg, :backtrace=>caller)\n end", "def test_person_validity\n assert people(:valid_person).valid?\n end", "def test_over_age\n\t\tassert_equal true, @user.age(19)\n\tend", "def test_that_kitty_can_eat\n assert_equal \"OHAI!\", @meme.i_can_has_cheezburger?\n end", "def assert_value(actual,expected,message)\n puts message\n puts actual == expected\nend", "def test_both_players_level_and_exceed_defcon\n scenario us: 4, ussr: 4, defcon: 3\n assert_no_award\n end", "def test_truth\n client = Client.new\n assert !client.valid?\n client.name = 'Alexandre'\n assert client.valid?\n end", "def test_acknowledgement\n assert @bancomer.acknowledge\n end", "def test_likes_to_eat__person3_true\n result = likes_to_eat(@person3, \"Scooby snacks\")\n assert_equal(true, result)\n end", "def assert actual, expected, message\n display message\n puts actual == expected || display_error(actual, expected)\nend", "def test_truth\n assert true\n end", "def test_truth\n assert true\n end", "def test_truth\n assert true\n end", "def test_truth\n assert true\n end", "def test_truth\n assert true\n end", "def test_truth\n assert true\n end", "def test_truth\n assert true\n end", "def test_truth\n assert true\n end", "def test_truth\n assert true\n end", "def test_truth\n assert true\n end", "def test_truth\n assert true\n end", "def test_truth\n assert true\n end", "def test_truth\n assert true\n end", "def test_truth\n assert true\n end", "def test_truth\n assert true\n end", "def test_truth\n assert true\n end", "def test_truth\n assert true\n end", "def test_truth\n assert true\n end", "def test_truth\n assert true\n end", "def test_truth\n assert true\n end", "def test_truth\n assert true\n end", "def test_truth\n assert true\n end", "def test_truth\n assert true\n end", "def test_truth\n assert true\n end", "def test_truth\n assert true\n end", "def test_truth\n assert true\n end", "def test_truth\n assert true\n end", "def test_truth\n assert true\n end", "def test_truth\n assert true\n end", "def test_truth\n assert true\n end", "def test_truth\n assert true\n end", "def test_truth\n assert true\n end", "def test_truth\n assert true\n end", "def test_truth\n assert true\n end", "def test_truth\n assert true\n end", "def test_truth\n assert true\n end", "def test_truth\n assert true\n end" ]
[ "0.7289056", "0.7289056", "0.6450548", "0.64220583", "0.639296", "0.63795066", "0.6366299", "0.6363982", "0.63499254", "0.6348415", "0.6346621", "0.634376", "0.6292701", "0.62822247", "0.6271838", "0.6253848", "0.62528414", "0.6246689", "0.62240785", "0.6211107", "0.62091184", "0.6193219", "0.6192323", "0.6191214", "0.6186315", "0.6184212", "0.61764634", "0.6176217", "0.61727613", "0.6148917", "0.6144138", "0.6144138", "0.6138636", "0.6137682", "0.61319387", "0.61243296", "0.6111403", "0.6111102", "0.610081", "0.60993016", "0.6095213", "0.60947084", "0.6086908", "0.6086401", "0.6076449", "0.606863", "0.60664606", "0.60587883", "0.605728", "0.6053128", "0.60516834", "0.60516834", "0.60516834", "0.6050952", "0.6049809", "0.6042117", "0.6039741", "0.60330707", "0.6016306", "0.60132", "0.6006732", "0.59976465", "0.5993336", "0.5993152", "0.59908366", "0.59908366", "0.59908366", "0.59908366", "0.59908366", "0.59908366", "0.59908366", "0.59908366", "0.59908366", "0.59908366", "0.59908366", "0.59908366", "0.59908366", "0.59908366", "0.59908366", "0.59908366", "0.59908366", "0.59908366", "0.59908366", "0.59908366", "0.59908366", "0.59908366", "0.59908366", "0.59908366", "0.59908366", "0.59908366", "0.59908366", "0.59908366", "0.59908366", "0.59908366", "0.59908366", "0.59908366", "0.59908366", "0.59908366", "0.59908366", "0.59908366", "0.59908366" ]
0.0
-1
We can also use the expectations to ensure a necessary negative
def test_capybara_can_ensure_something_is_not_found on_visiting_browserkoans_test_page do assert_equal __(false), page.has_selector?('#not-there') assert_nothing_raised do expect(page).to_not have_selector(__('#not-there')) end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_neg_prospectors\n\t\trefute check_args([1, -1])\n\tend", "def negative_test\r\n @negative = true\r\n end", "def test_print_books_negative\n\t\tassert_raises(\"Cannot have fewer than 0 books\") { print_books(-1,-1) }\n\tend", "def test_results_negative\r\n assert_raises('Cannot have a negative number of rubies found!') { @g.results(-1) }\r\n end", "def failure_message_when_negated; end", "def failure_message_when_negated; end", "def failure_message_when_negated; end", "def test_negative_argument\n\t\tc = Check.new\n\t\trefute c.check_arguments([1,1,-2])\n\tend", "def test_calculate_negative\n \tassert_equal '0', @gold_rush.calculate(-1, 0)\n end", "def test_negative\r\n args = Args.new\r\n assert_equal false, args.check_args(\"hello\")\r\n end", "def test_display_negative_fake\r\n assert_raises('total_fakes must be greater than or equal to 0!\\n') { @g.display_rubies(1, -1, 1, 2) }\r\n end", "def negative?; end", "def test_neg_check_success\n assert_nil neg_check(['0', '0', '0']) # pass\n assert_nil neg_check(['0', '2', '3'])# pass\n end", "def positive?; end", "def verify_not_before=(_arg0); end", "def verify_not_before=(_arg0); end", "def test_print_dinos_negative\n\t\tassert_raises(\"Cannot have fewer than 0 dinosaur toys\") { print_dinos(-1,-1) }\n\tend", "def when_negated_expectation(actual)\n expect(result(&actual)).not_to public_send(*expectation_args)\n end", "def test_promo_code_negative_value_bug\n # Setup / preverify\n promo = promotions(:fixed_rebate)\n promo_discount = 5000.00\n assert promo.update_attribute(:discount_amount, promo_discount)\n setup_new_order_with_items()\n assert promo.discount_amount > @o.total\n # Exercise\n @o.promotion_code = promo.code\n assert @o.save\n # Verify\n assert @o.total >= 0, \"Order total was: #{@o.total}\"\n end", "def test_returns_strength_value_halved\n skip\n end", "def negative_failure_message\n \"expected #{@target.name} not to provide #{@expected}, but it does\"\n end", "def test_display_negative_real\r\n assert_raises(\"total_rubies must be a number greater than or equal to 0.\\n\") { @g.display_rubies(-1, 1, 1, 2) }\r\n end", "def negative_failure_message\n end", "def test_negative_should_take_no_arguments\n assert_equal(0, cli_class.instance_method(:negative).arity)\n end", "def test_neg_check_fail\n assert_equal neg_check(['0', '-1', '0']), false # return false\n assert_equal neg_check(['0', '0', '-1']), false # return false\n assert_equal neg_check(['0', '-9', '-9']), false # return false\n end", "def test_correct_neg_val_print\n a_parse = Argparser.new\n assert_output(nil) do\n _unused = a_parse.correct?([-20, -5, 0])\n end\n end", "def test_arg_check_prospectors_negative\n def exit(x); 1; end\n ret = arg_check_prospectors '-1'\n assert_equal ret, -3\n end", "def test_lend_money_transfers_money\n #Setup\n lender_before =\n lender_after =\n lendee_before =\n lendee_after =\n loan =\n #act\n #assert\n assert_equal(loan, lender_before - lender_after)\n assert_equal(loan, lendee_after- lendee_before)\nend", "def test_both_players_exceed_defcon\n scenario us: 4, ussr: 5, defcon: 3\n assert_no_award\n end", "def test_more_than_one_variable\n assert_equal(20,minus(80,40,20))\t\n end", "def failure_message_when_negated\n \"expected #{@actual.inspect} not to be true or false\"\n end", "def test_should_not_validate_double_claiming\n claiming = create_claiming\n assert claiming.valid?\n claiming = create_claiming\n assert !claiming.valid?\n end", "def test_zero_prospectors\n\t\tassert check_args([1, 0])\n\tend", "def test_check_args_invalid_negative\n args = CheckArgs.new\n assert_equal false, args.check_args([6, -2, -3])\n end", "def test_subtract\n \tassert_equal 5, @calc.subtract(10,5)\n end", "def test_negative_trans\n assert_raises SystemExit do\n assert_output 'Line 0: Invalid amount of billcoins: (-12)\\nBLOCKCHAIN INVALID' do\n trans = '281974>669488(-12):281974>669488(17):281974>217151(12):281974>814708(5):SYSTEM>933987(100)'\n line_num = 0\n address = { '281974' => 100 }\n @verify.process_transactions(trans, line_num, address)\n end\n end\n end", "def expected?\n false\n end", "def verify_not_before; end", "def verify_not_before; end", "def test_both_players_level_and_exceed_defcon\n scenario us: 4, ussr: 4, defcon: 3\n assert_no_award\n end", "def failure_message_when_negated\n actual = prettify_args(@actual)\n\n if @description\n \"'#{actual}' should not #{@description}\"\n else\n \"'#{actual}' should not satisfy the requirements\"\n end\n end", "def test_cost_always_positive\n property_of {\n share_price = float\n num_shares = integer\n [share_price, num_shares]\n }.check { |share_price, num_shares|\n value = @market.calculate_cost(share_price, num_shares)\n assert value >= 0\n }\n end", "def test_rubie_number_negative\r\n random = Minitest::Mock.new(\"test_random\")\r\n assert_raises('max1 cannot be less than 0!') { @g.rubie_number(-1, random) }\r\n end", "def test_raises_incorrect_turns_input\n assert_raises \"Should raise error when turns input is less than or equal to 0!\\n\\n\" do\n ruby_rush=RubyRush.new(1, 2, 3)\n ruby_rush.turns_check(0)\n end\n \n assert_raises \"Should raise error when turns input is not an integer!\\n\\n\" do\n ruby_rush=RubyRush.new(1, 2, 3)\n ruby_rush.turns_check(1.1)\n end\n \n assert_raises \"Should raise error when turns input is not an integer and is less than or equal to 0!\\n\\n\" do\n ruby_rush=RubyRush.new(1, 2, 3)\n ruby_rush.turns_check(-1.1)\n end\n \n assert_raises \"Should raise error when turns input is not a number!\\n\\n\" do\n ruby_rush=RubyRush.new(1, 2, 3)\n ruby_rush.turns_check(\"\")\n end\n end", "def test_does_not_have_zero\n skip\n numbers = [3, 1, 3, 2, 4, 9, 8]\n has_zero = false\n # write code here\n refute has_zero\n end", "def test_positive\r\n args = Args.new\r\n assert_equal false, args.check_args(6)\r\n end", "def failure_message_when_negated\n actual = prettify_args(@actual)\n matcher = prettify_matcher(@metadata[:name])\n\n if @metadata[:args].count > 0\n args = prettify_args(*@metadata[:args])\n\n \"'#{actual}' should not #{matcher} '#{args}'\"\n else\n \"'#{actual}' should not #{matcher}\"\n end\n end", "def test_espresso_more_effective\n hipster = Human.new \"Hipster\"\n espresso = Espresso.new \"Espresso\"\n\n hipster.buy espresso\n assert espresso.drinks_before_empty == 1\n\n hipster.drink!\n assert (hipster.alertness > 0.4)\n\n end", "def test_transactions_negative_bal_false\r\n account_tracker = Minitest::Mock.new('test_account_tracker')\r\n block_checker = Minitest::Mock.new('test_block_checker')\r\n block_checker.expect(:parse, [\"SYSTEM>123456(100)\"], [\"SYSTEM>123456(100)\", \":\"])\r\n block_checker.expect(:parse, [\"SYSTEM\", \"123456(100)\"], [\"SYSTEM>123456(100)\", \">\"])\r\n block_checker.expect(:parse, [\"123456\", \"100)\"], [\"123456(100)\", \"(\"])\r\n block_checker.expect(:check_digits, true, [\"123456\"])\r\n block_checker.expect(:get_coins, \"100\", [\"123456(100)\"])\r\n def block_checker.check_coins(string); 100; end\r\n def block_checker.check_last_char(string, char); nil; end\r\n block_checker.expect(:add_account, 1, [account_tracker, \"123456\", 100])\r\n def account_tracker.negative_balance?; nil; end\r\n assert_nil @g.transactions( 'SYSTEM>123456(100)', account_tracker, block_checker, 1)\r\n end", "def assertions; end", "def assertions; end", "def wont_be_false(msg=nil)\n FalseAssay.refute!(self, :message=>msg, :backtrace=>caller)\n end", "def test_num_transactions_correct_not_0_true\n assert @bv.num_transactions_correct?(1, [0,2,3])\n end", "def negative_failure_message\n \"expected following text to not match selector #{@expected}:\\n#{@document}\"\n end", "def test_check_coins_alpah\r\n assert_nil @g.check_coins('a')\r\n end", "def test_negative_case\n #Open the page\n @driver.get(@base_url)\n\n #Click on the submit button without filling out the mandatory forms\n submitButton = @driver.find_element(:xpath, @loc.submitButton)\n submitButton.click\n\n #Verify that the required indicators are displayed for the mandatory fields\n reqText = @driver.find_element(:xpath,@loc.reqText)\n #name box input field would not have the required indicator as it should \n #automatically become active for input when submission is made without mandatory fields filled out\n nameBoxActive = @driver.find_element(:xpath,@loc.nameBoxActive)\n enjoyDevReq = @driver.find_element(:xpath,@loc.enjoyDevReq)\n enjoyDevReqTxt = @driver.find_element(:xpath,@loc.enjoyDevReqTxt)\n\n #Verify that required text is displayed at the top\n assert_equal(true, reqText.displayed?) \n #Verify that the name box does not show the required indicator as it is currently cursor-active\n assert_equal(true, nameBoxActive.displayed?) \n #Verify that the red box highlight indicator is applied for the 'do you enjoy dev? question\n assert_equal(true, enjoyDevReq.displayed?) \n #Verify that the 'This is a required question' text appears below the do you enjoy \n #developement section's checkboxes\n assert_equal(true, enjoyDevReqTxt.displayed?)\n\n #click elsewhere on the page to confirm that the name box field also has the required indicator\n enjoyDevReq.click\n #Verify that the red box highlight indicator is displayed for the name input field\n nameBoxReq = @driver.find_element(:xpath, @loc.nameBoxReq)\n assert_equal(true, nameBoxReq.displayed?)\n #Verify that the 'This is a required question' text appears below the name input field\n nameBoxReqTxt = @driver.find_element(:xpath,@loc.nameBoxReqTxt)\n assert_equal(true, nameBoxReq.displayed?) \n end", "def test_day_output_negative_rubies\r\n location = Minitest::Mock.new(\"test_location_arr\")\r\n assert_raises('Cannot have a negative number of rubies found!') { @g.day_output([-1, -1], 0, location) }\r\n end", "def test_raises_incorrect_prospectors_input\n assert_raises \"Should raise error when prospectors input is less than or equal to 0!\\n\\n\" do\n ruby_rush=RubyRush.new(1, 2, 3)\n ruby_rush.prospectors_check(0)\n end\n \n assert_raises \"Should raise error when prospectors input is not an integer!\\n\\n\" do\n ruby_rush=RubyRush.new(1, 2, 3)\n rb_rush.prospectors_check(1.1)\n end\n \n assert_raises \"Should raise error when prospectors input is not an integer and is less than or equal to 0!\\n\\n\" do\n ruby_rush=RubyRush.new(1, 2, 3)\n ruby_rush.prospectors_check(-1.1)\n end\n \n assert_raises \"Should raise error when prospectors input is not a number!\\n\\n\" do\n ruby_rush=RubyRush.new(1, 2, 3)\n ruby_rush.prospectors_check(\"\")\n end\n \n end", "def test_num_transactions_correct_0_true\n assert @bv.num_transactions_correct(0, [0])\n end", "def expected_value; end", "def expected_value; end", "def positive; end", "def positive; end", "def test_display_negative_rubyist\r\n assert_raises('rubyist_num must be greater than 0!\\n') { @g.display_rubies(1, 1, 0, 2) }\r\n end", "def test_display_negative_iterations\r\n assert_raises('rubyist_num must be greater than 0!\\n') { @g.display_rubies(1, 1, 1, 0) }\r\n end", "def __\n raise \"__ should be replaced with a value or expression to make the test pass.\"\nend", "def test_can_no_acct_credit_for\n # $ M $ M\n can_use_credit_test(products(:product_univstub_1), 0.0, 0, false, false)\n can_use_credit_test(products(:product_univstub_1), 5.0, 0, false, false)\n can_use_credit_test(products(:product_univstub_1), 0.0, 5, false, true)\n can_use_credit_test(products(:product_univstub_1), 5.0, 5, false, true)\n \n can_use_credit_test(products(:product1), 0, 0, false, false)\n can_use_credit_test(products(:product1), 10, 0, true, false)\n can_use_credit_test(products(:product1), 0, 10, false, false)\n can_use_credit_test(products(:product1), 10, 10, true, false)\n\n end", "def test_abnormal_usage\n test_args = [-9, -9, -9]\n args = Args.new test_args\n\n args.stub(:exit, 1) do\n assert_output(\"Usage:\\nruby ruby_rush.rb *seed* *num_prospectors* *num_turns\\n*seed* should be an integer\\n*num_prospectors* should be a non-negative integer\\n*num_turns* should be a non-negative integer\\n\"){args.validate_args}\n end\n end", "def miss_reason; end", "def test_arg_check_turns_negative\n def exit(x); 1; end\n ret = arg_check_turns '-1'\n assert_equal ret, -4\n end", "def test_check_coins_zero\r\n assert_nil @g.check_coins('0')\r\n end", "def test_args_check_less\n\t\targs_checker = ArgsChecker::new\n\t\tarr = []\n\t\tassert_raises(\"I need one number bud, try again\") { args_checker.check_args arr }\n\tend", "def assert_error_occurred\n @status.wont_equal 0\n end", "def test_check_num_args_invalid_negative\n args = CheckNumArgs.new\n assert_equal false, args.check_args([0,-1,-1])\n end", "def test_convert_currency_one_to_two\n #AGAIN....test passes if it doesn't work\n assert_raises ArgumentError do \n @apples_to_oranges.convert_currency_one_to_two\n end\n\n @converted_value = @apples_to_oranges.convert_currency_one_to_two(@amount)\n @expected_value = @amount*@apples_to_oranges.conversion_rate\n\n # This test will pass if it is right!\n assert_equal @expected_value, @converted_value\n end", "def negative?() @positive==false end", "def test_num_transactions_correct_false_not_0_false\n assert_equal(false, @bv.num_transactions_correct?(0, []))\n end", "def test_under_age\n\t\tassert_equal true, @user.age(14)\n\tend", "def negative_failure_message\n \"expected document to not #{description}; got: #{@rendered}\"\n end", "def negative_failure_message\n \"expected document to not #{description}; got: #{@rendered}\"\n end", "def test_withdraw_empty_account\n coins = 10\n sender = 112_233\n address = ['445566']\n output = -10\n assert_equal output, @verify.withdraw(coins, sender, address)\n end", "def test_positive\n args = Arguments.new\n assert_equal false, args.check_args(5)\n end", "def DISABLED_test_three_minus\n assert_does_not_parse [DecimalToken.new(3), SubtractOpToken.instance]\n end", "def test_order_line_item_quantity_is_postive\n a_towel = items(:towel)\n an_order_line_item = OrderLineItem.for_product(a_towel)\n an_order_line_item.quantity = -1;\n assert_raise(ActiveRecord::RecordInvalid) { \n an_order_line_item.save!\n }\n an_order_line_item.quantity = 0\n assert_raise(ActiveRecord::RecordInvalid) {\n an_order_line_item.save!\n }\n an_order_line_item.quantity = 1\n assert_nothing_raised {\n an_order_line_item.save!\n }\n end", "def test_dont_eat_icecream_in_winter\n time_to_eat = should_eat( \"ice cream\", \"winter\" )\n assert_equal( false, time_to_eat )\n end", "def failures; end", "def failures; end", "def failures; end", "def negative_failure_message\n \"expected following text to not match selector #{@expected}:\\n#{@document}\"\n end", "def negative_failure_message\n \"expected following text to not match selector #{@expected}:\\n#{@document}\"\n end", "def assert_not_true(exp, msg=nil)\n TrueFailure.refute(exp, :message=>msg, :backtrace=>caller)\n end", "def test_block_number_correct_false\n assert_equal(false, @bv.block_number_correct?(0, 1))\n end", "def must_be_false(msg=nil)\n FalseAssay.assert!(self, :message=>msg, :backtrace=>caller)\n end", "def test_get_coins_invalid\r\n assert_nil @g.get_coins('ab12')\r\n end", "def test_num_transactions_correct_0_true\n assert_equal(false, @bv.num_transactions_correct?(0, [0,1]))\n end", "def test_invoice_no_discount\r\n\r\n # Add an Invoice\r\n assert_difference 'Invoice.count' do\r\n \r\n #Create new Invoice and fill it up\r\n @user.creates_new_invoice\r\n fill_invoice_for @user \r\n\r\n #Customer Info \r\n current_customer = customers(\"heavy_user_customer_1\".to_sym)\r\n @user.enter_new_customer( \r\n :name => current_customer.name\r\n ) \r\n \r\n # quantity and price initial values\r\n quantity = 20\r\n price = 4.00\r\n \t \r\n #Add line items\r\n add_line_items(quantity, price)\r\n\t \r\n # Submit and verify\r\n assert_difference 'LineItem.count', @number_of_line_items do\r\n @user.submits \r\n end \r\n end \r\n end", "def test_missing_argument_invalid_argument\n\t\tc = Check.new\n\t\trefute c.check_arguments([1,1,'s'])\n\tend", "def expected_response_yes\n self.expected_response =\"+\"\n end", "def test_home_message_negative\n\t\ttest_main = Main.new(3, 1, 6)\n\t\tmocked_Graph = MiniTest::Mock.new(\"mocked graph\")\n\t\tmocked_Graph.expect(:get_curr_loc, Node.new(\"Enumerable Canyon\", 4, 5, 10))\n\t\ttest_main.real_rubies_found(-2)\n\t\ttest_main.home_message\n\t\tassert mocked_Graph\n\tend", "def test_reject_community\n assert !public_trap_passes?(\"test\")\n assert !public_trap_passes?([\"foo\", \"bar\"])\n assert !public_trap_passes?([])\n end", "def test_over_age\n\t\tassert_equal true, @user.age(19)\n\tend" ]
[ "0.7401456", "0.73384684", "0.7017624", "0.7015693", "0.7003195", "0.7003195", "0.7003195", "0.6969293", "0.6895535", "0.6742986", "0.6730589", "0.67154986", "0.67087793", "0.67071533", "0.67053705", "0.67053705", "0.6686283", "0.6631685", "0.6611565", "0.66021687", "0.6601905", "0.6593899", "0.656363", "0.6563463", "0.6560641", "0.6522504", "0.65215045", "0.6472549", "0.64404756", "0.64322156", "0.6412182", "0.6410488", "0.6408191", "0.63769823", "0.6373486", "0.63686574", "0.63513553", "0.63439333", "0.63439333", "0.63433415", "0.63367784", "0.6328298", "0.6322188", "0.6302213", "0.62660146", "0.62625647", "0.6252732", "0.6234595", "0.6232212", "0.62274176", "0.62274176", "0.6226344", "0.6221894", "0.62149847", "0.6209695", "0.6202391", "0.6197376", "0.6191935", "0.61858124", "0.6182032", "0.6182032", "0.61556983", "0.61556983", "0.615153", "0.61514705", "0.6147779", "0.6139187", "0.61389446", "0.6138906", "0.61383367", "0.6131954", "0.6129622", "0.61234987", "0.6115304", "0.6112223", "0.6110832", "0.6108978", "0.61052537", "0.6092917", "0.6092917", "0.6091606", "0.60893685", "0.6089365", "0.6087929", "0.6086649", "0.6082526", "0.6082526", "0.6082526", "0.6081656", "0.6081656", "0.60754114", "0.60748327", "0.6072899", "0.60723543", "0.60634375", "0.6063362", "0.60627156", "0.6062616", "0.60597724", "0.6058331", "0.6058268" ]
0.0
-1
GET /room_plants GET /room_plants.json
def index @room_plants = RoomPlant.all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n \n @plants = Plant.all\n @personal_plants = PersonalPlant.where(:user_id => session[:user][:id])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @plants }\n end\n end", "def index\n @plants = Plant.all\n\n respond_to do |format|\n format.html\n format.json { render :json => @plants }\n end\n end", "def index\n @plants = @project.plants\n end", "def index\n @rooms = Room.all\n respond_to do | format |\n format.html\n format.json\n end\n \n end", "def show\n @room = Room.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @room }\n end\n end", "def show\n @room = Room.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @room }\n end\n end", "def show\n @room = Room.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @room }\n end\n end", "def show\n @room = Room.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @room }\n end\n end", "def index\n @rooms = Room.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @rooms }\n end\n end", "def show\n @restroom = Restroom.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @restroom }\n end\n end", "def show\n @rooms = Room.all\n end", "def index\n @plants = Plant.all\n end", "def index\n @political_parties = PoliticalParty.all\n end", "def index\n rooms = Room.includes(:problems, :registrations, :users, :owner)\n if params[:name]\n render json: rooms.where(name: params[:name])\n else\n render json: rooms\n end\n end", "def index\n @plants = Plant.all\n end", "def get_rooms\n # DO NOT DELETE. Condition used for load testing\n @user_id = (params.has_key? :user_id) ? params[:user_id] : session[:user_id]\n @room_ids = Member.where(user_id: @user_id).pluck(:room_id)\n\n @rooms = Room.find(@room_ids)\n #render json: @rooms\n \n @roomList = []\n #@rooms.each { |room|\n for room in @rooms do\n #@room = Room.find_by(id: room_id)\n temp = {}\n temp.store(\"room_id\",room.id)\n temp.store(\"room_name\", room.name) \n temp.store(\"room_token\", room.token)\n @roomList.push(temp)\n end\n render json: {rooms: @roomList}, status: 200\n end", "def index\n respond_to do |format|\n\n @plants = Plant.order('lower(name) ASC').paginate(page: params[:page])\n format.html { render :html => @plants } # index.html.erb\n if params[:page].present?\n @jsonPlants = Plant.order('lower(name) ASC').paginate(page: params[:page], per_page: params[:per_page])\n else\n @jsonPlants = Plant.all\n end\n\n @jsonPlantsDub = [:Plant]\n\n if params[:name].present?\n @jsonPlants.each do |p|\n if !p.name.downcase.include?(params[:name].downcase)\n @jsonPlantsDub << p\n end\n end\n end\n\n @jsonPlants -= @jsonPlantsDub\n format.json { render :json => {admin: admin?, count: @plants.total_entries, plants: @jsonPlants} }\n end\n end", "def show\n\t\trender json: @room_user\n\tend", "def index\n ota_rooms = Array.new\n if params[:room].nil? && params[:ota].nil?\n # 自分の施設情報だけを返す\n\n current_user.ota.select do |otum|\n otum.provider == 'default'\n end.each do |otum|\n ota_rooms.concat(otum.ota_rooms)\n end\n elsif params[:ota].nil?\n room = Room.find_by(id: params[:room].to_i)\n # 部屋IDが存在しない場合\n if room.nil?\n response = {\n status: 'NotFound',\n message: 'room not found'\n }\n return render json: response, status: 404\n end\n # 権限がない場合\n if current_user.id != room.user.id\n response = {\n status: 'NotFound',\n message: 'room not found'\n }\n return render json: response, status: 404\n end\n ota_rooms.concat(room.ota_rooms)\n elsif params[:room].nil?\n otum = Otum.find_by(id: params[:ota].to_i)\n # OTA IDが存在しない場合\n if otum.nil?\n response = {\n status: 'NotFound',\n message: 'ota not found'\n }\n return render json: response, status: 404\n end\n # 権限がない場合\n if current_user.id != otum.user.id\n response = {\n status: 'NotFound',\n message: 'ota not found'\n }\n return render json: response, status: 404\n end\n ota_rooms.concat(otum.ota_rooms)\n else\n # facility=[facility_id]\n facility = Facility.find_by(id: params[:facility].to_i)\n # 施設IDが存在しない場合\n if facility.nil?\n response = {\n status: 'NotFound',\n message: 'ota_rooms not found'\n }\n return render json: response, status: 404\n end\n # ユーザーの施設IDでない場合\n if facility.user_id != current_user.id\n response = {\n status: 'NotFound',\n message: 'ota_rooms not found'\n }\n return render json: response, status: 404\n end\n ota_rooms.concat(facility.ota_rooms)\n end\n\n render json: {\n status: 'Success',\n message: '',\n ota_rooms: ota_rooms.as_json(except: [\n :created_at,\n :updated_at\n ])\n }, status: 200\n end", "def show\n @rooms = @blueprint.rooms\n end", "def show\n @pokeparty = Pokeparty.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @pokeparty }\n end\n end", "def show\n @room = current_user.rooms.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @room.to_hash_with_users(current_user).to_json }\n end\n end", "def show\n @hostel_room = HostelRoom.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @hostel_room }\n end\n end", "def index\n @user_plants = UserPlant.where(user: current_user)\n render json: @user_plants,\n include: { plant: { only: [:name, :water, :light_indoors, :light_outdoors] } },\n except: [:updated_at, :created_at, :user_id]\n end", "def show\n buildingId = params[:id]\n @room = Room.where(building_id: buildingId)\n end", "def show\n @room = Room.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @room }\n format.js {}\n end\n end", "def create\n @room_plant = RoomPlant.new(room_plant_params)\n\n if @room_plant.save\n render :show, status: :created, location: @room_plant\n else\n render json: @room_plant.errors, status: :unprocessable_entity\n end\n end", "def index\n @rooms = Room.paginate(:page => params[:page])\n end", "def index\n @hostel_rooms = HostelRoom.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @hostel_rooms }\n end\n end", "def get_rooms \n json_rooms = IO.popen(\"curl -u #{@config['campfire_config']['API_KEY']}:X #{@config['campfire_config']['URL']}/presence.json\") \n parsed_rooms = JSON.parse(json_rooms.readlines.first)[\"rooms\"]\n rooms = parsed_rooms.collect {|room| [room[\"name\"],room[\"id\"]]} \nend", "def new\n @room = Room.new\n\n render :json => @room \n end", "def show\n @hotel_room = HotelRoom.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @hotel_room }\n end\n end", "def show\n @papel = Papel.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @papel }\n end\n end", "def show\n @user = current_user\n @individual_plants = @user.individual_plants\n end", "def show\n @request = Request.find(params[:id])\n\n if current_user.admin?\n @available_rooms = get_available_rooms @request\n end\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @request }\n end\n end", "def show\n @booking = Booking.find(params[:id])\n @rooms = @booking.rooms\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @booking }\n end\n end", "def index\n @restrooms = Restroom.all\n end", "def show\n @room = Room.find(params[:id])\n\n render '/api/rooms/show'\n end", "def show\n @related_roles = @role.related_roles\n for person in @role.people\n if person # a role record may exist that no longer has a person joined to it\n if (@plaques == nil)\n @plaques = person.plaques\n else\n @plaques = @plaques + person.plaques\n end\n end\n end\n @zoom = 7\n respond_to do |format|\n format.html\n format.kml { render \"plaques/show\" }\n format.xml\n format.json { render :json => @role }\n end\n end", "def index\n @branch_rooms = Room.get_all_rooms(params[:branch_id])\n \n render json: @branch_rooms\n end", "def index\n @rooms = Room.all\n end", "def index\n @rooms = Room.all\n end", "def index\n @rooms = Room.all\n end", "def index\n @rooms = Room.all\n end", "def index\n @rooms = Room.all\n end", "def index\n @rooms = Room.all\n end", "def index\n @rooms = Room.all\n end", "def index\n @rooms = Room.all\n end", "def index\n @rooms = Room.all\n end", "def index\n @rooms = Room.all\n end", "def index\n @rooms = Room.all\n end", "def index\n @hotel_rooms = HotelRoom.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @hotel_rooms }\n end\n end", "def get_rooms(page)\n page.links.collect { |link| { :name => link.to_s, :uri => link.uri } if link.uri.to_s[\"#{uri.to_s}/room\"] }.reject { |room| room.nil? }\n end", "def show\n @tddbc_room = Tddbc::Room.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tddbc_room }\n end\n end", "def index\n\t\t@rooms = Room.order(updated_at: :desc)\n\t\trespond_to do |format|\n\t\t\tformat.html\n\t\t\tformat.json { render json: @rooms }\n\t\tend\n\tend", "def show\n plant = Plant.find(params[:id])\n render json: {status: 'SUCCESS', message:'Show a plant.', data: plant}, status: :ok\n end", "def show\n @room = Room.includes(:owner).find(params.require(:id))\n if @room\n success(body: @room, options: { include: [:owner] })\n else\n not_found\n end\n end", "def room_plant_params\n params.fetch(:room_plant, {})\n end", "def show\n #@restroom = Restroom.find(params[:id])\n @venue = client.venue(:query => params[:venue_id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @restroom }\n end\n end", "def room_list\n @roomtype = DetailRoom.all_types\n @time = Room.all_times\n @day_list = Room.all_days\n if session[:admin] == nil\n redirect_to rooms_path\n end\n @admin = session[:admin]\n @rooms = {} \n @roomtype.each do |type|\n @rooms[type] = DetailRoom.find_all_by_room_type(type)\n end \n end", "def show\n @roomrate = Roomrate.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @roomrate }\n end\n end", "def show\n @roombot = Roombot.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @roombot }\n end\n end", "def new\n @room = Room.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @room }\n end\n end", "def new\n @room = Room.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @room }\n end\n end", "def new\n @room = Room.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @room }\n end\n end", "def new\n @room = Room.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @room }\n end\n end", "def new\n @room = Room.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @room }\n end\n end", "def new\n @room = Room.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @room }\n end\n end", "def index\n @request_rooms = RequestRoom.all\n end", "def show\n @user=User.find(params[:user_id])\n @room=@user.rooms.find(params[:id])\n render json: @room if stale?(@room)\n end", "def index\n @kind_rooms = KindRoom.all\n end", "def new\n @restroom = Restroom.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @restroom }\n end\n end", "def new\n @restroom = Restroom.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @restroom }\n end\n end", "def show\n @room = Room.find(params[:id])\n end", "def show\n @room = Room.find(params[:id])\n end", "def index\n @rooms = Room.all\n \n respond_to do |f|\n f.html\n end\n end", "def room_list\n @rooms = Room.where(active: true)\n render partial: \"room_list\"\n end", "def show\n @party = Party.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @party }\n end\n end", "def index\n @plannings = Planning.all\n end", "def index\n case current_type\n when 'owner'\n @rooms = owner_rooms\n when 'access'\n @rooms = access_rooms\n else\n @rooms = public_rooms\n end\n end", "def show\n @classroom = classroom.find(params[:id])\n\n render json: @classroom\n end", "def show\n if authorise(request)\n room = EscapeRoom.select(:id, :name, :startVertex, :endVertex).find(params[:id])\n render json: { status: 'SUCCESS', message: 'Escape Rooms', data: room }, status: :ok\n else\n render json: { status: 'FAILED', message: 'Unauthorized' }, status: 401\n end\n rescue StandardError\n render json: { status: 'Fail', message: 'Escape Room might not exist' }, status: :not_found\n end", "def index\n @pacientes = Pacientes.all\n render json: @pacientes\n end", "def show\n if params[:id]\n current_user # initialize @current_user\n\n @room = {\n \t:name => params[:id],\n \t:url => RTCHelper::getRoomURL(params[:id]),\n \t:token => RTCHelper::getAuthToken(params[:id], @current_user)\n }\n else\n #\n # if there is no room, we really wanted to go to /rooms/index\n #\n redirect_to :action => 'index'\n end\n end", "def index\n @rooms = current_user.rooms.all\n end", "def show\n @screeningroom = Screeningroom.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @screeningroom }\n end\n end", "def index\n if current_user == @user\n @poems = @user.poems.all\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @poems }\n end\n else\n redirect_to root_path\n end\n end", "def list_all_rooms\n return @rooms\n end", "def set_room_plant\n @room_plant = RoomPlant.find(params[:id])\n end", "def show\n @partyroles = Partyrole.find(:all, :conditions => [\"party_id = ?\", $party_id])\n @partyrole = Person.find(:first, :conditions => [\"party_id = ?\", $party_id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @partyrole }\n end\n end", "def new\n @pokeparty = Pokeparty.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @pokeparty }\n end\n end", "def show\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @room_config }\n end\n end", "def new\n if not check_logged_in then\n return\n end\n \n ###NEED TO SEE WHAT THIS IS FOR\n if params[:plants] then\n @plant = Plant.find(JSON.parse(params[:plants])[0])\n else\n @plant = Plant.new\n end\n \n @garden_id = params[:garden_id]\n @plant_id = params[:plant_id]\n \n #@plant.personal_plants.build\n #@plant.personal_plants[0].personal_plant_waterings.build\n \n @plants = Plant.all\n @personal_plant = PersonalPlant.new\n @personal_plant[:garden_id] = @garden_id\n @personal_plant[:plant_id] = @plant_id\n #@a = render_to_string action: \"options\"\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @personal_plant }\n end\n end", "def show\n @room_items = RoomItem.all\n end", "def index\n if current_user.role_id.eql?(3)\n @class_rooms = ClassRoom.page(params[:page])\n else \n @class_rooms = ClassRoom.page(params[:page])\n end\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @class_rooms }\n end\n end", "def show\n @porter = Porter.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @porter }\n end\n end", "def show\n @plant = Plant.includes(\n :common_names, :harvests, :drawbacks, :habits, \n :habitats, :light_tolerances, :moisture_tolerances, \n :roles, :root_patterns).find(params[:id])\n\n render :json => @plant, :include => [\n :common_names, :harvests, :drawbacks, :habits, \n :habitats, :light_tolerances, :moisture_tolerances, \n :roles, :root_patterns]\n end", "def show\n @plate = Plate.find(params[:id])\n\n render json: @plate\n end", "def get_rooms(company, params = {})\n $LOG.i \"running \" + __method__.to_s\n @client.get '/messages/v3/' + company + '/rooms', params\n end", "def index\n @plantings = Planting.all\n end" ]
[ "0.6873085", "0.6651381", "0.66009724", "0.6308563", "0.6165632", "0.6165632", "0.6165632", "0.6165536", "0.613408", "0.6129944", "0.61185324", "0.6094506", "0.6074843", "0.6062588", "0.6046237", "0.6040447", "0.60214645", "0.60207134", "0.6010185", "0.59752303", "0.5973547", "0.5951997", "0.59297734", "0.5905282", "0.5903884", "0.59015536", "0.5898073", "0.5892815", "0.5870871", "0.5867078", "0.58529776", "0.58495337", "0.58403516", "0.5820714", "0.5816414", "0.5802411", "0.5796464", "0.579186", "0.57436615", "0.5738024", "0.5733912", "0.5733912", "0.5733912", "0.5733912", "0.5733912", "0.5733912", "0.5733912", "0.5733912", "0.5733912", "0.5733912", "0.5733912", "0.57311565", "0.573031", "0.5726241", "0.5726122", "0.57103837", "0.57030827", "0.5697221", "0.5680237", "0.5663593", "0.5661767", "0.5658674", "0.56584257", "0.56584257", "0.56584257", "0.56584257", "0.56584257", "0.56584257", "0.5657688", "0.56533605", "0.56470025", "0.5642061", "0.5642061", "0.56403327", "0.56403327", "0.5629111", "0.562874", "0.56168574", "0.5615655", "0.5599323", "0.5598431", "0.5592063", "0.55888104", "0.55791247", "0.55790025", "0.5575464", "0.55724466", "0.55723196", "0.5560351", "0.5559277", "0.5548381", "0.55435246", "0.55381155", "0.55360174", "0.5532492", "0.55303174", "0.5528068", "0.5525097", "0.5522791", "0.5522735" ]
0.7080606
0
GET /room_plants/1 GET /room_plants/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @room_plants = RoomPlant.all\n end", "def index\n \n @plants = Plant.all\n @personal_plants = PersonalPlant.where(:user_id => session[:user][:id])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @plants }\n end\n end", "def index\n @plants = Plant.all\n\n respond_to do |format|\n format.html\n format.json { render :json => @plants }\n end\n end", "def show\n @room = Room.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @room }\n end\n end", "def show\n @room = Room.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @room }\n end\n end", "def show\n @room = Room.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @room }\n end\n end", "def show\n @room = Room.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @room }\n end\n end", "def show\n @restroom = Restroom.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @restroom }\n end\n end", "def index\n @rooms = Room.all\n respond_to do | format |\n format.html\n format.json\n end\n \n end", "def index\n @plants = @project.plants\n end", "def show\n buildingId = params[:id]\n @room = Room.where(building_id: buildingId)\n end", "def show\n @hostel_room = HostelRoom.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @hostel_room }\n end\n end", "def index\n @rooms = Room.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @rooms }\n end\n end", "def new\n @room = Room.new\n\n render :json => @room \n end", "def index\n rooms = Room.includes(:problems, :registrations, :users, :owner)\n if params[:name]\n render json: rooms.where(name: params[:name])\n else\n render json: rooms\n end\n end", "def show\n @pokeparty = Pokeparty.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @pokeparty }\n end\n end", "def show\n @room = Room.find(params[:id])\n\n render '/api/rooms/show'\n end", "def show\n @hotel_room = HotelRoom.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @hotel_room }\n end\n end", "def show\n @room = Room.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @room }\n format.js {}\n end\n end", "def show\n @papel = Papel.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @papel }\n end\n end", "def show\n @rooms = Room.all\n end", "def show\n\t\trender json: @room_user\n\tend", "def show\n @tddbc_room = Tddbc::Room.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tddbc_room }\n end\n end", "def show\n @room = Room.find(params[:id])\n end", "def show\n @room = Room.find(params[:id])\n end", "def new\n @room = Room.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @room }\n end\n end", "def new\n @room = Room.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @room }\n end\n end", "def new\n @room = Room.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @room }\n end\n end", "def new\n @room = Room.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @room }\n end\n end", "def new\n @room = Room.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @room }\n end\n end", "def new\n @room = Room.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @room }\n end\n end", "def new\n @restroom = Restroom.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @restroom }\n end\n end", "def new\n @restroom = Restroom.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @restroom }\n end\n end", "def show\n @room = current_user.rooms.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @room.to_hash_with_users(current_user).to_json }\n end\n end", "def show\n @roomrate = Roomrate.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @roomrate }\n end\n end", "def show\n @rooms = @blueprint.rooms\n end", "def index\n @political_parties = PoliticalParty.all\n end", "def show\n @booking = Booking.find(params[:id])\n @rooms = @booking.rooms\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @booking }\n end\n end", "def index\n @plants = Plant.all\n end", "def get_rooms \n json_rooms = IO.popen(\"curl -u #{@config['campfire_config']['API_KEY']}:X #{@config['campfire_config']['URL']}/presence.json\") \n parsed_rooms = JSON.parse(json_rooms.readlines.first)[\"rooms\"]\n rooms = parsed_rooms.collect {|room| [room[\"name\"],room[\"id\"]]} \nend", "def show\n @classroom = classroom.find(params[:id])\n\n render json: @classroom\n end", "def show\n @roombot = Roombot.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @roombot }\n end\n end", "def show\n @porter = Porter.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @porter }\n end\n end", "def show\n #@restroom = Restroom.find(params[:id])\n @venue = client.venue(:query => params[:venue_id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @restroom }\n end\n end", "def show\n plant = Plant.find(params[:id])\n render json: {status: 'SUCCESS', message:'Show a plant.', data: plant}, status: :ok\n end", "def index\n @hostel_rooms = HostelRoom.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @hostel_rooms }\n end\n end", "def index\n @plants = Plant.all\n end", "def index\n @rooms = Room.paginate(:page => params[:page])\n end", "def show\n @user=User.find(params[:user_id])\n @room=@user.rooms.find(params[:id])\n render json: @room if stale?(@room)\n end", "def show\n @plate = Plate.find(params[:id])\n\n render json: @plate\n end", "def create\n @room_plant = RoomPlant.new(room_plant_params)\n\n if @room_plant.save\n render :show, status: :created, location: @room_plant\n else\n render json: @room_plant.errors, status: :unprocessable_entity\n end\n end", "def index\n respond_to do |format|\n\n @plants = Plant.order('lower(name) ASC').paginate(page: params[:page])\n format.html { render :html => @plants } # index.html.erb\n if params[:page].present?\n @jsonPlants = Plant.order('lower(name) ASC').paginate(page: params[:page], per_page: params[:per_page])\n else\n @jsonPlants = Plant.all\n end\n\n @jsonPlantsDub = [:Plant]\n\n if params[:name].present?\n @jsonPlants.each do |p|\n if !p.name.downcase.include?(params[:name].downcase)\n @jsonPlantsDub << p\n end\n end\n end\n\n @jsonPlants -= @jsonPlantsDub\n format.json { render :json => {admin: admin?, count: @plants.total_entries, plants: @jsonPlants} }\n end\n end", "def show\n @room_rate = RoomRate.find(params[:id])\n \n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @room_rate }\n end\n end", "def index\n ota_rooms = Array.new\n if params[:room].nil? && params[:ota].nil?\n # 自分の施設情報だけを返す\n\n current_user.ota.select do |otum|\n otum.provider == 'default'\n end.each do |otum|\n ota_rooms.concat(otum.ota_rooms)\n end\n elsif params[:ota].nil?\n room = Room.find_by(id: params[:room].to_i)\n # 部屋IDが存在しない場合\n if room.nil?\n response = {\n status: 'NotFound',\n message: 'room not found'\n }\n return render json: response, status: 404\n end\n # 権限がない場合\n if current_user.id != room.user.id\n response = {\n status: 'NotFound',\n message: 'room not found'\n }\n return render json: response, status: 404\n end\n ota_rooms.concat(room.ota_rooms)\n elsif params[:room].nil?\n otum = Otum.find_by(id: params[:ota].to_i)\n # OTA IDが存在しない場合\n if otum.nil?\n response = {\n status: 'NotFound',\n message: 'ota not found'\n }\n return render json: response, status: 404\n end\n # 権限がない場合\n if current_user.id != otum.user.id\n response = {\n status: 'NotFound',\n message: 'ota not found'\n }\n return render json: response, status: 404\n end\n ota_rooms.concat(otum.ota_rooms)\n else\n # facility=[facility_id]\n facility = Facility.find_by(id: params[:facility].to_i)\n # 施設IDが存在しない場合\n if facility.nil?\n response = {\n status: 'NotFound',\n message: 'ota_rooms not found'\n }\n return render json: response, status: 404\n end\n # ユーザーの施設IDでない場合\n if facility.user_id != current_user.id\n response = {\n status: 'NotFound',\n message: 'ota_rooms not found'\n }\n return render json: response, status: 404\n end\n ota_rooms.concat(facility.ota_rooms)\n end\n\n render json: {\n status: 'Success',\n message: '',\n ota_rooms: ota_rooms.as_json(except: [\n :created_at,\n :updated_at\n ])\n }, status: 200\n end", "def show\n @pem = Pem.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @pem }\n end\n end", "def get_rooms\n # DO NOT DELETE. Condition used for load testing\n @user_id = (params.has_key? :user_id) ? params[:user_id] : session[:user_id]\n @room_ids = Member.where(user_id: @user_id).pluck(:room_id)\n\n @rooms = Room.find(@room_ids)\n #render json: @rooms\n \n @roomList = []\n #@rooms.each { |room|\n for room in @rooms do\n #@room = Room.find_by(id: room_id)\n temp = {}\n temp.store(\"room_id\",room.id)\n temp.store(\"room_name\", room.name) \n temp.store(\"room_token\", room.token)\n @roomList.push(temp)\n end\n render json: {rooms: @roomList}, status: 200\n end", "def show\n @room = Room.includes(:owner).find(params.require(:id))\n if @room\n success(body: @room, options: { include: [:owner] })\n else\n not_found\n end\n end", "def show\n @party = Party.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @party }\n end\n end", "def show\n if params[:id]\n current_user # initialize @current_user\n\n @room = {\n \t:name => params[:id],\n \t:url => RTCHelper::getRoomURL(params[:id]),\n \t:token => RTCHelper::getAuthToken(params[:id], @current_user)\n }\n else\n #\n # if there is no room, we really wanted to go to /rooms/index\n #\n redirect_to :action => 'index'\n end\n end", "def show\n @screeningroom = Screeningroom.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @screeningroom }\n end\n end", "def show\n @class_room = ClassRoom.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @class_room }\n end\n end", "def index\n @restrooms = Restroom.all\n end", "def show\n @room = Room.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n end\n end", "def new\n @hostel_room = HostelRoom.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @hostel_room }\n end\n end", "def index\n @hotel_rooms = HotelRoom.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @hotel_rooms }\n end\n end", "def new\n @pokeparty = Pokeparty.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @pokeparty }\n end\n end", "def room\n Room.all.find { |room| room.id == room_id }\n end", "def index\n @rooms = Room.all\n end", "def index\n @rooms = Room.all\n end", "def index\n @rooms = Room.all\n end", "def index\n @rooms = Room.all\n end", "def index\n @rooms = Room.all\n end", "def index\n @rooms = Room.all\n end", "def index\n @rooms = Room.all\n end", "def index\n @rooms = Room.all\n end", "def index\n @rooms = Room.all\n end", "def index\n @rooms = Room.all\n end", "def index\n @rooms = Room.all\n end", "def index\n\t\t@rooms = Room.order(updated_at: :desc)\n\t\trespond_to do |format|\n\t\t\tformat.html\n\t\t\tformat.json { render json: @rooms }\n\t\tend\n\tend", "def show\n @politicalcommittee = Politicalcommittee.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @politicalcommittee }\n end\n end", "def new\n if not check_logged_in then\n return\n end\n \n ###NEED TO SEE WHAT THIS IS FOR\n if params[:plants] then\n @plant = Plant.find(JSON.parse(params[:plants])[0])\n else\n @plant = Plant.new\n end\n \n @garden_id = params[:garden_id]\n @plant_id = params[:plant_id]\n \n #@plant.personal_plants.build\n #@plant.personal_plants[0].personal_plant_waterings.build\n \n @plants = Plant.all\n @personal_plant = PersonalPlant.new\n @personal_plant[:garden_id] = @garden_id\n @personal_plant[:plant_id] = @plant_id\n #@a = render_to_string action: \"options\"\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @personal_plant }\n end\n end", "def show\n @rooms = { \n items: Room.all, \n }\n if room = Room.find_by(id: params[:id])\n response_data = {\n room: room,\n messages: module_get_messages(room)\n }\n status= :ok\n else \n status= :unprocessable_entity\n end\n\n #puts \"#######################\"\n #puts @room.as_json(:include => @messages)\n #puts Room.includes(:messages.limit(2)).find(params[:id] || 1).as_json(:include => :messages)\n\n respond_to do |format|\n format.html\n format.json { render json: response_data, status: status }\n end\n end", "def show\n @request = Request.find(params[:id])\n\n if current_user.admin?\n @available_rooms = get_available_rooms @request\n end\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @request }\n end\n end", "def new\n @hotel_room = HotelRoom.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @hotel_room }\n end\n end", "def index\n @branch_rooms = Room.get_all_rooms(params[:branch_id])\n \n render json: @branch_rooms\n end", "def new\n @serverroom = Serverroom.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @serverroom }\n end\n end", "def show\n # @passenger = Passenger.find(:name => params[:id])\n # render :json => @passenger\n end", "def show\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @room_config }\n end\n end", "def set_room_plant\n @room_plant = RoomPlant.find(params[:id])\n end", "def show\n @potluck = Potluck.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @potluck }\n end\n end", "def show\n @pony = Pony.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @pony }\n end\n end", "def new\n @room = Hotel.find(params[:hotel_id]).rooms.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @room }\n end\n end", "def index\n @rooms = Room.all\n \n respond_to do |f|\n f.html\n end\n end", "def room_descriptions_method\r\n my_port = 8081\r\n htttproomnumber = $roomnumber\r\n roomsNtext = \"/#{htttproomnumber}\"\r\n rooms_message = \"/rooms#{roomsNtext}\"\r\n url = URI.parse(\"http://localhost:#{my_port}#{rooms_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 return my_json[\"room\"].to_s\r\nend", "def index\n @kind_rooms = KindRoom.all\n end", "def show\n @plant = Plant.find(params[:id])\n end", "def show\n @prayers = Prayer.all\n @prayer = Prayer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @prayer }\n end\n end", "def room_id\n params[\"room_id\"]\n end", "def show\n @parliament = Parliament.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @parliament }\n end\n end", "def new\n @party = Party.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @party }\n end\n end", "def show\n @room = Room.find(params[:id])\n \n render :json => @room.as_json(:date => params[:date])\n end" ]
[ "0.69999033", "0.6849129", "0.6675932", "0.66178566", "0.6617773", "0.6617773", "0.6617773", "0.6593034", "0.6501112", "0.64346147", "0.63713616", "0.6353442", "0.63496196", "0.63173956", "0.6303042", "0.62894815", "0.627759", "0.626709", "0.6259189", "0.6237381", "0.6185674", "0.6153637", "0.61424816", "0.61348164", "0.61348164", "0.61308426", "0.61308426", "0.61308426", "0.61308426", "0.61308426", "0.61308426", "0.6124351", "0.6124351", "0.61220455", "0.61099035", "0.6073689", "0.6073162", "0.6072609", "0.60551804", "0.6045605", "0.6042835", "0.60422236", "0.60414255", "0.60412985", "0.6032554", "0.6022257", "0.6013913", "0.6011028", "0.59861904", "0.5981786", "0.59794456", "0.5969471", "0.59666705", "0.59630424", "0.5956585", "0.5952967", "0.5951979", "0.5950963", "0.5938729", "0.59370345", "0.5926365", "0.5926147", "0.59136313", "0.5911847", "0.5911052", "0.59077215", "0.5887916", "0.5885403", "0.5885403", "0.5885403", "0.5885403", "0.5885403", "0.5885403", "0.5885403", "0.5885403", "0.5885403", "0.5885403", "0.5885403", "0.58819276", "0.58724576", "0.5869065", "0.58681345", "0.5855314", "0.58448845", "0.58404374", "0.58398163", "0.58393383", "0.5835908", "0.58358705", "0.5832596", "0.5830131", "0.5812262", "0.5793046", "0.578837", "0.5777295", "0.57755244", "0.5771558", "0.5771343", "0.57688344", "0.57638603", "0.57479024" ]
0.0
-1
POST /room_plants POST /room_plants.json
def create @room_plant = RoomPlant.new(room_plant_params) if @room_plant.save render :show, status: :created, location: @room_plant else render json: @room_plant.errors, status: :unprocessable_entity end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n plant = Plant.create(plant_params)\n render json: plant, status: :created\n end", "def create\n @room = Room.new(room_params)\n\n respond_to do |format|\n if @room.save\n format.html { redirect_to hotelprofile_path, notice: 'Room was successfully created.' }\n format.json { render :show, status: :created, location: @room }\n else\n format.html { render :new }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @room = Room.new(params[:room])\n\n if @room.save\n render :json => @room, :status => :created, :location => @room\n else\n render :json => @room.errors, :status => :unprocessable_entity\n end\n end", "def create\n @room = Room.new(room_params)\n @room.name = \"Room \" +@room.name\n @room.admin_id = current_admin.id\n respond_to do |format|\n if @room.save\n format.html { redirect_to rooms_path , notice: 'Room was successfully created.' }\n format.json { render :show, status: :created, location: @room }\n else\n format.html { render :new }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n p = admin_room_params\n p[:building_id] = params[:building_id]\n @admin_room = Room.new(p)\n\n respond_to do |format|\n if @admin_room.save\n format.html { redirect_to [:admin, @admin_room.building], notice: 'Room was successfully created.' }\n # format.json { render :show, status: :created, location: @admin_room.building }\n else\n format.html { render :new }\n # format.json { render json: @admin_room.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @plant = @garden.plants.new(plant_params)\n\n respond_to do |format|\n if @plant.save\n format.html { redirect_to garden_plant_path(@garden, @plant), notice: 'Plant was successfully created.' }\n format.json { render action: 'show', status: :created, location: @plant }\n else\n format.html { render action: 'new' }\n format.json { render json: @plant.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @request_room = RequestRoom.new(request_room_params)\n\n respond_to do |format|\n if @request_room.save\n format.html { redirect_to @request_room, notice: 'Request room was successfully created.' }\n format.json { render :show, status: :created, location: @request_room }\n else\n format.html { render :new }\n format.json { render json: @request_room.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n param = room_params\n \n roomtype=Roomtype.new\n roomtype.AC=param[:AC]\n roomtype.beds=param[:beds].to_i\n param.delete(\"AC\")\n param.delete(\"beds\")\n @room = current_hotel.rooms.build(param)\n respond_to do |format|\n if @room.save\n roomtype.room_id=@room.id\n roomtype.save\n format.html { redirect_to @room, notice: \"Room was successfully created.\" }\n format.json { render :show, status: :created, location: @room }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @room = current_user.rooms.new(room_params)\n\n respond_to do |format|\n if @room.save\n format.html { redirect_to @room, notice: 'Room was successfully created.' }\n format.json { render :show, status: :created, location: @room }\n else\n format.html { render :new }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @user=User.find(params[:user_id])\n @room = @user.rooms.create(room_params)\n if @room.save\n render json: @room, status: :created\n else\n render json: @room.errors, status: :unprocessable_entity\n end\n end", "def create\n @plant = current_user.plants.create(plant_params)\n if @plant.valid?\n redirect_to plant_path(@plant)\n else\n render :new, status: :unprocessable_entity\n end\n end", "def create\n @room = Room.new(params[:room])\n\n respond_to do |format|\n if @room.save\n format.html { redirect_to hotel_path @room.hotel, notice: 'Room was successfully created.' }\n format.json { render json: @room, status: :created, location: @room }\n else\n format.html { render action: \"new\" }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n puts room_params\n puts params\n @room = Room.new(room_params)\n\n\n respond_to do |format|\n if @room.save\n format.html { redirect_to \"/rooms/new\", notice: 'Room was successfully created.' }\n format.json { render :show, status: :created, location: @room }\n else\n format.html { render :new }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @reserved_room = ReservedRoom.new(reserved_room_params)\n\n respond_to do |format|\n if @reserved_room.save\n format.html { redirect_to @reserved_room, notice: 'Reserved room was successfully created.' }\n format.json { render :show, status: :created, location: @reserved_room }\n else\n format.html { render :new }\n format.json { render json: @reserved_room.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @room = Room.new(room_params)\n @room.admin_id = current_user.id\n @room.users.push(current_user)\n\n respond_to do |format|\n if @room.save\n format.html { redirect_to @room, notice: \"Room was successfully created.\" }\n format.json { render :show, status: :created, location: @room }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @room = Room.new(room_params)\n\n respond_to do |format|\n if @room.save\n format.html { redirect_to @room, notice: 'Room was successfully created.' }\n format.json { render :show, status: :created, location: @room }\n else\n format.html { render :new }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @room = Room.new(room_params)\n\n respond_to do |format|\n if @room.save\n format.html { redirect_to @room, notice: 'Room was successfully created.' }\n format.json { render :show, status: :created, location: @room }\n else\n format.html { render :new }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @room = Room.new(room_params)\n\n respond_to do |format|\n if @room.save\n format.html { redirect_to @room, notice: 'Room was successfully created.' }\n format.json { render :show, status: :created, location: @room }\n else\n format.html { render :new }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @room = Room.new(params[:room])\n\n respond_to do |format|\n if @room.save\n format.html { redirect_to @room, notice: 'Room was successfully created.' }\n format.json { render json: @room, status: :created, location: @room }\n else\n format.html { render action: \"new\" }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @room = Room.new(params[:room])\n\n respond_to do |format|\n if @room.save\n format.html { redirect_to @room, notice: 'Room was successfully created.' }\n format.json { render json: @room, status: :created, location: @room }\n else\n format.html { render action: \"new\" }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @room = Room.new(room_params)\n\n respond_to do |format|\n if @room.save\n format.html { redirect_to @room, notice: 'Помещение успешно добавлено' }\n format.json { render :show, status: :created, location: @room }\n else\n format.html { render :new, alert: 'Что-то пошло не так' }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @restroom = Restroom.new(restroom_params)\n\n respond_to do |format|\n if @restroom.save\n format.html { redirect_to @restroom, notice: 'Restroom was successfully created.' }\n format.json { render action: 'show', status: :created, location: @restroom }\n else\n format.html { render action: 'new' }\n format.json { render json: @restroom.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n room = params[:room]\n if Room.find_by_room_id(room[\"room_id\"]) == nil\n @room = Room.new(params[:room])\n respond_to do |format|\n if @room.save\n format.html { redirect_to @room, notice: 'Room was successfully created.' }\n format.json { render json: @room, status: :created, location: @room }\n else\n format.html { render action: \"new\" }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n else\n flash[:notice] = \"can not add new room\"\n redirect_to new_room_path\n end\n end", "def create\n passenger = Passenger.new(:name => params[:name], :contact_number => params[:contact_number], :nationality => params[:nationality], :meal_pref => params[:meal_pref])\n passenger.save\n render :json => passenger\n end", "def create\n @admin_room = Room.new(admin_room_params)\n @room_detail = @admin_room.room_detail\n\n respond_to do |format|\n if @admin_room.save\n format.html { redirect_to @admin_room, notice: 'Room was successfully created.' }\n format.json { render action: 'show', status: :created, location: @admin_room }\n else\n format.html { render action: 'new' }\n format.json { render json: @admin_room.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @apartment = Apartment.all\n # binding.pry\n @masters_chatroom_apartment = ChatroomApartment.new(masters_chatroom_apartment_params)\n # apa = @apartment.@masters_chatroom_apartment.apartment_id.room_num\n binding.pry\n respond_to do |format|\n if @masters_chatroom_apartment.save\n format.html { redirect_to [:masters,@masters_chatroom_apartment], notice: 'Chatroom apartment was successfully created.' }\n format.json { render :show, status: :created, location: @masters_chatroom_apartment }\n else\n format.html { render :new }\n format.json { render json: @masters_chatroom_apartment.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n \n @room = Room.new(room_params)\n \n @room.user_id = current_user&.id\n \n\n respond_to do |format|\n if @room.save\n format.html { redirect_to @room, notice: 'Room was successfully created.' }\n format.json { render :show, status: :created, location: @room }\n else\n format.html { redirect_to rooms_path, notice: 'Room was failed.' }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @hotel_room = HotelRoom.new(params[:hotel_room])\n\n respond_to do |format|\n if @hotel_room.save\n format.html { redirect_to @hotel_room, notice: 'Hotel room was successfully created.' }\n format.json { render json: @hotel_room, status: :created, location: @hotel_room }\n else\n format.html { render action: \"new\" }\n format.json { render json: @hotel_room.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @room = Room.new(params[:room])\n @room.room_string = random_string\n\n respond_to do |format|\n if @room.save\n format.html { redirect_to room_path(@room.room_string), notice: 'Room was successfully created.' }\n format.json { render json: @room, status: :created, location: @room }\n else\n format.html { render action: \"new\" }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @hostel_room = HostelRoom.new(params[:hostel_room])\n\n respond_to do |format|\n if @hostel_room.save\n format.html { redirect_to @hostel_room, notice: 'Hostel room was successfully created.' }\n format.json { render json: @hostel_room, status: :created, location: @hostel_room }\n else\n format.html { render action: \"new\" }\n format.json { render json: @hostel_room.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @room = Room.new(room_params)\n\n respond_to do |format|\n if @room.save\n format.html { redirect_to @room, notice: 'La Sala ha sido creada correctamente!' }\n format.json { render :show, status: :created, location: @room }\n else\n format.html { render :new }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @room = Room.new(room_params)\n respond_to do |format|\n if @room.save\n if params[:hotel_id].present?\n @room.hotel = params[:hotel_id]\n end\n create_amenity\n create_damage\n format.html { redirect_to hotel_path(@room.hotel_id), notice: 'Room was successfully created.' }\n format.json { render :show, status: :created, location: @room }\n else\n format.html { render :new }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @room = Room.new(room_params)\n\n respond_to do |format|\n if @room.save\n format.html { redirect_to @room, :flash => { success: 'Room was successfully created.' } }\n format.json { render action: 'show', status: :created, location: @room }\n else\n format.html { render action: 'new' }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n #authorize! :create, @restroom\n @restroom = Restroom.new(params[:restroom])\n @restroom.user_id=current_user.id \n \n respond_to do |format|\n if @restroom.save\n format.html { redirect_to @restroom, notice: 'Restroom was successfully created.' }\n format.json { render json: @restroom, status: :created, location: @restroom }\n else\n format.html { render action: \"new\" }\n format.json { render json: @restroom.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n #authorize! :create, @restroom\n @restroom = Restroom.new(params[:restroom])\n @restroom.user_id=current_user.id \n \n respond_to do |format|\n if @restroom.save\n format.html { redirect_to @restroom, notice: 'Restroom was successfully created.' }\n format.json { render json: @restroom, status: :created, location: @restroom }\n else\n format.html { render action: \"new\" }\n format.json { render json: @restroom.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n if current_user.utype == \"admin\"\n @room = Room.new(room_params)\n\n respond_to do |format|\n if @room.save\n format.html { redirect_to @room }\n flash[:success] ='Room was successfully created.'\n format.json { render :show, status: :created, location: @room }\n else\n format.html { render :new }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n else\n redirect_to unauthorized_url\n end\n end", "def create_room(company, params = {})\n $LOG.i \"running \" + __method__.to_s\n @client.post '/messages/v3/' + company + '/rooms', params\n end", "def create\n @room = TmuAdmin::Room.new(room_params)\n\n if @room.save\n render :json => {}\n else\n error_messages = @room.errors.full_messages.collect { |error_message| \"<li>\" + error_message + \"</li>\" }\n\n render :json => {:errorMsg => \"<ul>\" + error_messages.join(\"\") + \"</ul>\"}\n end\n end", "def create\n if not check_logged_in then\n return\n end\n\n @personal_plant = PersonalPlant.new(params[:personal_plant])\n \n respond_to do |format|\n if @personal_plant.save\n format.html { redirect_to \"/gardens/\"+@personal_plant.garden[:id].to_s, notice: 'Personal plant was successfully created.' }\n format.json { render json: \"/gardens/\"+@personal_plant.garden[:id].to_s, status: :created, location: @personal_plant }\n else\n format.html { render action: \"new\" }\n format.json { render json: @personal_plant.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @room = Room.new(room_params)\n\n respond_to do |format|\n if @room.save\n format.html { redirect_to @room, notice: t('flash.room.create') }\n format.json { render :show, status: :created, location: @room }\n else\n format.html { render :new }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @serverroom = Serverroom.new(params[:serverroom])\n\n respond_to do |format|\n if @serverroom.save\n format.html { redirect_to @serverroom, notice: 'Serverroom was successfully created.' }\n format.json { render json: @serverroom, status: :created, location: @serverroom }\n else\n format.html { render action: \"new\" }\n format.json { render json: @serverroom.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n if not check_logged_in then\n return\n end\n \n ###NEED TO SEE WHAT THIS IS FOR\n if params[:plants] then\n @plant = Plant.find(JSON.parse(params[:plants])[0])\n else\n @plant = Plant.new\n end\n \n @garden_id = params[:garden_id]\n @plant_id = params[:plant_id]\n \n #@plant.personal_plants.build\n #@plant.personal_plants[0].personal_plant_waterings.build\n \n @plants = Plant.all\n @personal_plant = PersonalPlant.new\n @personal_plant[:garden_id] = @garden_id\n @personal_plant[:plant_id] = @plant_id\n #@a = render_to_string action: \"options\"\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @personal_plant }\n end\n end", "def create\n @room = Room.new(room_params)\n respond_to do |format|\n if @room.save\n format.html { redirect_to @room, notice: t('default.room.created') }\n format.json { render :show, status: :created, location: @room }\n else\n format.html { render :new }\n format.json { render json: @error, status: :unprocessable_entity }\n end\n end\n end", "def create\n @employee_room = EmployeeRoom.new(employee_room_params)\n\n respond_to do |format|\n if @employee_room.save\n format.html { redirect_to @employee_room, notice: 'Employee room was successfully created.' }\n format.json { render :show, status: :created, location: @employee_room }\n else\n format.html { render :new }\n format.json { render json: @employee_room.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @pokeparty = Pokeparty.new(params[:pokeparty])\n\n respond_to do |format|\n if @pokeparty.save\n format.html { redirect_to @pokeparty, notice: 'Pokeparty was successfully created.' }\n format.json { render json: @pokeparty, status: :created, location: @pokeparty }\n else\n format.html { render action: \"new\" }\n format.json { render json: @pokeparty.errors, status: :unprocessable_entity }\n end\n end\n end", "def room_plant_params\n params.fetch(:room_plant, {})\n end", "def create\n @planting = Planting.new(planting_params)\n\n respond_to do |format|\n if @planting.save\n format.html { redirect_to @planting, notice: 'Planting was successfully created.' }\n format.json { render :show, status: :created, location: @planting }\n else\n format.html { render :new }\n format.json { render json: @planting.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @painel = Painel.new(painel_params)\n\n respond_to do |format|\n if @painel.save\n format.html { redirect_to @painel, notice: 'Painel was successfully created.' }\n format.json { render action: 'show', status: :created, location: @painel }\n else\n format.html { render action: 'new' }\n format.json { render json: @painel.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @room = Room.new(room_params)\n \n if @room.user == nil\n room.user = \"\"\n end\n \n respond_to do |format|\n if @room.save\n format.html { redirect_to rooms_path, notice: \"Sala '\" + @room.name + \"' criada com sucesso!\" }\n format.json { render :show, status: :created, location: @room }\n else\n format.html { render :new }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @meetingroom = @space.meetingrooms.new(meetingroom_params)\n @meetingroom.user = current_user\n\n respond_to do |format|\n if @meetingroom.save\n format.html { redirect_to [@space, @meetingroom], notice: 'Meetingroom was successfully created.' }\n format.json { render :show, status: :created, location: [@space, @meetingroom] }\n else\n format.html { render :new }\n format.json { render json: @meetingroom.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n room = Room.new(room_params)\n if room.save\n response_data = {\n room: room,\n txt: ['投稿しました!'],\n }\n render json: response_data, status: :created\n else\n response_data = {\n txt: room.errors.full_messages,\n }\n render json: response_data, status: :unprocessable_entity\n end\n end", "def create\n @room = Room.new(room_params)\n\n if @room.save\n redirect_to admin_rooms_path, notice: 'Room was successfully created.'\n else\n render new\n end\n end", "def create\n @plundering = Plundering.new(plundering_params)\n\n respond_to do |format|\n if @plundering.save\n format.html { redirect_to @plundering, notice: 'Plundering was successfully created.' }\n format.json { render action: 'show', status: :created, location: @plundering }\n else\n format.html { render action: 'new' }\n format.json { render json: @plundering.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @papel = Papel.new(params[:papel])\n\n respond_to do |format|\n if @papel.save\n format.html { redirect_to @papel, notice: 'Papel was successfully created.' }\n format.json { render json: @papel, status: :created, location: @papel }\n else\n format.html { render action: \"new\" }\n format.json { render json: @papel.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @room_facility = RoomFacility.new(room_facility_params)\n\n respond_to do |format|\n if @room_facility.save\n format.html { redirect_to @room_facility, notice: 'Room facility was successfully created.' }\n format.json { render :show, status: :created, location: @room_facility }\n else\n format.html { render :new }\n format.json { render json: @room_facility.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @kind_room = KindRoom.new(kind_room_params)\n\n respond_to do |format|\n if @kind_room.save\n format.html { redirect_to @kind_room, notice: 'Kind room was successfully created.' }\n format.json { render :show, status: :created, location: @kind_room }\n else\n format.html { render :new }\n format.json { render json: @kind_room.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @spawner = Spawner.new(spawner_params)\n @fieldtrips = Fieldtrip.all\n\n respond_to do |format|\n if @spawner.save\n format.html { redirect_to @spawner, notice: 'Spawner was successfully created.' }\n format.json { render json: @spawner, status: :created, location: @spawner }\n else\n format.html { render action: \"new\" }\n format.json { render json: @spawner.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @occupied_room = OccupiedRoom.new(occupied_room_params)\n\n respond_to do |format|\n if @occupied_room.save\n format.html { redirect_to @occupied_room, notice: 'Occupied room was successfully created.' }\n format.json { render :show, status: :created, location: @occupied_room }\n else\n format.html { render :new }\n format.json { render json: @occupied_room.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n apartment = Apartment.create(apartment_params)\n render json: apartment\n end", "def index\n @room_plants = RoomPlant.all\n end", "def create\n @level = Level.find(params[:level_id])\n @compartment = @level.compartments.new(params[:compartment])\n \n \n\n\n respond_to do |format|\n if @compartment.save\n format.html { redirect_to ([@level, @compartment]), notice: 'Compartment was successfully created.' }\n format.json { render json: @compartment, status: :created, location: @compartment }\n else\n format.html { render action: \"new\" }\n format.json { render json: @compartment.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @pmtrainer = Pmtrainer.new(pmtrainer_params)\n\n respond_to do |format|\n if @pmtrainer.save\n format.html { redirect_to @pmtrainer, notice: 'Pmtrainer was successfully created.' }\n format.json { render :show, status: :created, location: @pmtrainer }\n else\n format.html { render :new }\n format.json { render json: @pmtrainer.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @room = Room.new(room_params)\n\n @room = Room.new(room_params)\n if @room.save\n redirect_to @room\n else\n render 'new'\n end\n end", "def create\n @bathroom = Bathroom.new(bathroom_params)\n\n respond_to do |format|\n if @bathroom.save\n format.html { redirect_to @bathroom, notice: 'Bathroom was successfully created.' }\n format.json { render :show, status: :created, location: @bathroom }\n else\n format.html { render :new }\n format.json { render json: @bathroom.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @reservation_room = ReservationRoom.new(reservation_room_params)\n @reservations = Reservation.all\n \n respond_to do |format|\n if @reservation_room.save\n format.html { redirect_to @reservation_room, notice: 'La habitacion se ha asignado a la reserva correctamente.' }\n format.json { render action: 'show', status: :created, location: @reservation_room }\n else\n format.html { render action: 'new' }\n format.json { render json: @reservation_room.errors, status: :unprocessable_entity }\n end\n end\n end", "def room_params\n params.require(:room).permit(:name, :ubication, :location_id, :noise, :sockets, :availability)\n end", "def create\n @roomrate = Roomrate.new(params[:roomrate])\n\n respond_to do |format|\n if @roomrate.save\n format.html { redirect_to [:admin,@roomrate], notice: 'Roomrate was successfully created.' }\n format.json { render json: @roomrate, status: :created, location: @roomrate }\n else\n format.html { render action: \"new\" }\n format.json { render json: @roomrate.errors, status: :unprocessable_entity }\n end\n end\n end", "def room_params\n params.require(:room).permit :name, :public\n end", "def set_room_plant\n @room_plant = RoomPlant.find(params[:id])\n end", "def consulting_room_params\n params.require(:consulting_room).permit(:name, :location, :typeroom)\n end", "def room_params\n params.require(:room).permit(:title, :code, :building_id)\n end", "def room_params\n params.require(:room).permit(:title, :code, :building_id)\n end", "def create\n @ptel_reup = PtelReup.new(ptel_reup_params)\n\n respond_to do |format|\n if @ptel_reup.save\n format.html { redirect_to @ptel_reup, notice: 'Ptel reup was successfully created.' }\n format.json { render action: 'show', status: :created, location: @ptel_reup }\n else\n format.html { render action: 'new' }\n format.json { render json: @ptel_reup.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n\t\t@room = Room.new(room_params) \n\n\t\trespond_to do |format|\n\t\t\tif @room.save\n\t\t\t\tformat.html { redirect_to @room, notice: 'Room was successfully created.' }\n\t\t\t\tformat.json { render json: @room, status: :created}\n\t\t\telse\n\t\t\t\tformat.html { render :new }\n\t\t\t\tformat.json { render json: @room.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend", "def room_params\n params.require(:room).permit(:name, :description, :floor_id, :capacity,\n :computers, :roomtype_id)\n end", "def create\n @room = Room.new(room_params)\n\n respond_to do |format|\n if @room.save\n seatQuantity = (@room.rows * @room.columns)\n (1..seatQuantity).each do |i|\n @seating = Seating.create! slot: true,\n room_id: @room.id\n @seating.save\n end\n format.html { redirect_to edit_room_path(@room), notice: 'Room was successfully created.' }\n format.json { render :show, status: :created, location: @room }\n else\n format.html { render :new }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end", "def room_params\n params.require(:room).permit(:code, :leader, :farmer_count, :robber_count, :investigator_count, :donator_count, :number_of_rounds, :time_per_round)\n end", "def create\n authorize room\n\n if room_params[:public]\n authorize room, :create_public?\n end\n\n respond_to do |format|\n if room.save\n current_or_guest_user.add_role :owner, room\n\n format.html { redirect_to room, notice: I18n.t('rooms.successfully_created') }\n format.json { render :show, status: :created, location: room }\n else\n format.html { render :new }\n format.json { render json: room.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @room = current_user.rooms.build(room_params)\n if @room.save\n flash[:success] = 'room was created'\n redirect_to rooms_path\n else\n render 'new'\n end\n end", "def room_params\n params.require(:room).permit(:name, :status, :price, :slot, :area_id,:admin_id,:r,:quantity,:deposit,:av)\n end", "def room_params\n params.require(:room).permit(:seats_count, :room_type)\n end", "def create\n @roomtable = Roomtable.new(roomtable_params)\n\n respond_to do |format|\n if @roomtable.save\n format.html { redirect_to @roomtable, notice: 'Roomtable was successfully created.' }\n format.json { render :show, status: :created, location: @roomtable }\n else\n format.html { render :new }\n format.json { render json: @roomtable.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @parliament = Parliament.new(params[:parliament])\n\n respond_to do |format|\n if @parliament.save\n format.html { redirect_to admin_parliaments_path, notice: t('app.msgs.success_created', :obj => t('activerecord.models.parliament')) }\n format.json { render json: @parliament, status: :created, location: @parliament }\n else\n format.html { render action: \"new\" }\n format.json { render json: @parliament.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n\n @room_item = RoomItem.create(params.require(:room_item).permit(:Room_id, :Item_id))\n respond_to do |format|\n if @room_item.save\n format.html { redirect_to @room_item, notice: \"Room item was successfully created.\" }\n format.json { render :show, status: :created, location: @room_item }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @room_item.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @room_management = RoomManagement.new(room_management_params)\n @room_management.user = current_user\n respond_to do |format|\n if @room_management.save\n format.html { redirect_to @room_management, notice: 'Room management was successfully created.' }\n format.json { render :show, status: :created, location: @room_management }\n # else\n # format.html { render :new }\n # format.json { render json: @room_management.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @political_party = PoliticalParty.new(political_party_params)\n\n respond_to do |format|\n if @political_party.save\n format.html { redirect_to @political_party, notice: 'Political party was successfully created.' }\n format.json { render :show, status: :created, location: @political_party }\n else\n format.html { render :new }\n format.json { render json: @political_party.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n \n filteredParams = params.require(:room).permit(:name, :owner_id, :privacy, :password)\n\n if filteredParams[\"privacy\"] && filteredParams[\"privacy\"] == \"on\"\n filteredParams[\"privacy\"] = \"private\"\n else\n filteredParams[\"privacy\"] = \"public\"\n end \n\n if filteredParams[\"name\"].empty?\n res_with_error(\"Invalid parameters\", :bad_request)\n return (false)\n end\n if filteredParams[\"privacy\"] == \"private\"\n if filteredParams[\"password\"].empty?\n res_with_error(\"None empty password required if the room is private\", :bad_request)\n return (false)\n else\n roomPassword = BCrypt::Password.create filteredParams[\"password\"]\n filteredParams[\"password\"] = roomPassword\n end\n end\n\n if !filteredParams[\"name\"] || filteredParams[\"name\"].length == 0 || filteredParams[\"name\"].blank?\n res_with_error(\"Empty Room Name\", :bad_request)\n return (false)\n elsif filteredParams[\"name\"] && filteredParams[\"name\"].length > 42\n res_with_error(\"Room name too long\", :bad_request)\n return (false)\n end\n\n @room = Room.create(filteredParams)\n if @room && !current_user.rooms_as_admin.include?(@room)\n @rla = RoomLinkAdmin.new(room: @room, user: current_user)\n @rla.save\n end\n \n respond_to do |format|\n if @room.save\n ActionCable.server.broadcast \"room_channel\", type: \"rooms\", description: \"create\", user: current_user\n format.html { redirect_to @room, notice: 'Room was successfully created.' }\n format.json { render :show, status: :created, location: @room }\n else\n format.html { render :new }\n format.json { render json: {alert: \"Name already taken\"}, status: :unprocessable_entity }\n end\n end\n end", "def create\n @services_room = ServicesRoom.new(services_room_params)\n\n respond_to do |format|\n if @services_room.save\n format.html { redirect_to room_services_rooms_path(@services_room.room_id,@services_room.id), notice: 'Services room was successfully created.' }\n format.json { render :show, status: :created, location: @services_room }\n else\n format.html { render :new }\n format.json { render json: @services_room.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @room = Room.new(room_params)\n \n respond_to do |format|\n if @room.save\n trivia_category = (@room.category.eql? \"any\") ? '' : \"category=\" + @room.category\n \n questions_response = RestClient::Request.execute(\n method: :get,\n url: 'https://opentdb.com/api.php?amount=7&type=multiple&' + trivia_category\n )\n questions = JSON.parse(questions_response)['results']\n\n questions.each do |question|\n Question.create(\n :problem => question['question'],\n :category => question['category'],\n :correct_answer => question[\"correct_answer\"],\n :incorrect_answer_one => question[\"incorrect_answers\"][0],\n :incorrect_answer_two => question[\"incorrect_answers\"][1],\n :incorrect_answer_three => question[\"incorrect_answers\"][2],\n :room_id => @room.id\n )\n end\n format.html { redirect_to @room, notice: 'Room was successfully created.' }\n format.json { render :show, status: :created, location: @room }\n else\n format.html { render :new }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end", "def room_params\n params.require(:room).permit(:appid,:name,:backgroud,:total_lest,:single_lest)\n end", "def room_params\n params.require(:room).permit(:room_name)\n end", "def new\n @room = Room.new\n\n render :json => @room \n end", "def create\n @room = Room.new(room_params)\n @room = @venue.rooms.new(room_params)\n\n if @room.save\n redirect_to venue_rooms_path\n else\n render :action => 'new'\n end\n end", "def create\n @papel = Papel.new(papel_params)\n\n respond_to do |format|\n if @papel.save\n format.html { redirect_to @papel, notice: 'Papel foi criado com sucesso' }\n format.json { render :show, status: :created, location: @papel }\n else\n format.html { render :new }\n format.json { render json: @papel.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @tddbc_room = Tddbc::Room.new(params[:tddbc_room])\n\n respond_to do |format|\n if @tddbc_room.save\n format.html { redirect_to @tddbc_room, notice: 'Room was successfully created.' }\n format.json { render json: @tddbc_room, status: :created, location: @tddbc_room }\n else\n format.html { render action: \"new\" }\n format.json { render json: @tddbc_room.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @partyrole = Partyrole.new(params[:partyrole])\n \n respond_to do |format|\n if @partyrole.save\n flash[:success] = \"Party role was successfully assigned.\"\n format.html { redirect_to(@partyrole) }\n format.xml { render :xml => @partyrole, :status => :created, :location => @partyrole }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @partyrole.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @room = current_user.rooms.create({name: params[:room][:name],\n max_user: params[:room][:max_user],\n host_id: current_user.id,\n salvo: params[:room][:salvo],\n occupancy: 1\n })\n @room.set_user_status(current_user, USER_STATUS[:join])\n @room.status = ROOM_STATUS[:open]\n # Broadcast a message\n channel = \"server_channel\"\n respond_message = {\n message: \"a room created\",\n }\n\n self.broadcast_message_to_channel(channel, :room_created, respond_message)\n\n respond_to do |format|\n if @room.save\n format.html { redirect_to @room, notice: 'Room was successfully created.' }\n format.json { render json: @room.to_hash_with_users(current_user).to_json, status: :created, location: @room }\n else\n format.html { render action: \"new\" }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n\n end", "def room_params\n params.fetch(:room).permit(:price, :capacity, :extendible, :occupied, :status, :view, :hotel_id, amenity_attributes: [:amenity_name, :room_id], damage_attributes: [:damage_name, :room_id])\n end", "def create\n @about_room = AboutRoom.new(about_room_params)\n\n respond_to do |format|\n if @about_room.save\n format.html { redirect_to @about_room, notice: 'About room was successfully created.' }\n format.json { render :show, status: :created, location: @about_room }\n else\n format.html { render :new }\n format.json { render json: @about_room.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @room.save\n respond_with(@room, location: bnb_rooms_url(@bnb))\n end" ]
[ "0.6517727", "0.63890606", "0.6387817", "0.6332335", "0.62932044", "0.62543356", "0.62041664", "0.6199585", "0.6198878", "0.618649", "0.61804456", "0.61730784", "0.61699", "0.61575717", "0.6154553", "0.61489403", "0.61489403", "0.61489403", "0.61406195", "0.61406195", "0.6125659", "0.61226845", "0.6112772", "0.6112758", "0.6111406", "0.6077154", "0.6074877", "0.6045741", "0.60136", "0.6004377", "0.6003409", "0.5996606", "0.5981905", "0.5979854", "0.5979854", "0.5977408", "0.59768414", "0.59682333", "0.59680545", "0.59661794", "0.596511", "0.59562725", "0.5947658", "0.59335625", "0.5931242", "0.5928292", "0.59277916", "0.5922878", "0.59218556", "0.59107095", "0.59037805", "0.58952546", "0.5895102", "0.58852476", "0.5872609", "0.58706486", "0.58513665", "0.5838983", "0.583559", "0.5834819", "0.58309454", "0.58219284", "0.58117414", "0.5808808", "0.5788257", "0.57776016", "0.5774701", "0.5766276", "0.57567596", "0.57566273", "0.5746682", "0.5746682", "0.5746509", "0.5742273", "0.5739513", "0.57326823", "0.5732477", "0.5729426", "0.5729103", "0.57261735", "0.5725396", "0.57240516", "0.572251", "0.5713915", "0.57088834", "0.5707144", "0.5706935", "0.5706242", "0.57042164", "0.57020897", "0.5698777", "0.5696537", "0.56909937", "0.56886744", "0.5688429", "0.56792057", "0.5675005", "0.5672094", "0.56681114", "0.5666623" ]
0.7071688
0
PATCH/PUT /room_plants/1 PATCH/PUT /room_plants/1.json
def update if @room_plant.update(room_plant_params) render :show, status: :ok, location: @room_plant else render json: @room_plant.errors, status: :unprocessable_entity end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @room = Room.find(params[:id])\n\n if @room.update_attributes(params[:room])\n head :ok\n else\n render :json => @room.errors, :status => :unprocessable_entity \n end\n end", "def update\n @restroom = Restroom.find(params[:id])\n authorize @restroom\n\n respond_to do |format|\n if @restroom.update_attributes(params[:restroom])\n format.html { redirect_to @restroom, notice: 'Restroom was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @restroom.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @restroom.update(restroom_params)\n format.html { redirect_to @restroom, notice: 'Restroom was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @restroom.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @restroom = Restroom.find(params[:id])\n authorize! :update, @restroom\n\n respond_to do |format|\n if @restroom.update_attributes(params[:restroom])\n format.html { redirect_to @restroom, notice: 'Restroom was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @restroom.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @restroom = Restroom.find(params[:id])\n authorize! :update, @restroom\n\n respond_to do |format|\n if @restroom.update_attributes(params[:restroom])\n format.html { redirect_to @restroom, notice: 'Restroom was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @restroom.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if @room.update(room_params)\n render json: @room, status: :ok, serializer: RoomSerializer\n else\n render json: @room.errors, status: :unprocessable_entity\n end\n end", "def update\n @room = Room.find(params[:id])\n respond_to do |format|\n if @room.update_attributes(params[:room])\n format.html { redirect_to staff_path(@room.id), notice: 'Room was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: staff_path(@room.id).errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @request_room.update(request_room_params)\n format.html { redirect_to @request_room, notice: 'Request room was successfully updated.' }\n format.json { render :show, status: :ok, location: @request_room }\n else\n format.html { render :edit }\n format.json { render json: @request_room.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @room.update_attributes(params[:room])\n format.html { redirect_to @room, notice: 'Room was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @room = Room.find(params[:id])\n\n respond_to do |format|\n if @room.update_attributes(params[:room])\n format.html { redirect_to @room, notice: 'Room was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @room = Room.find(params[:id])\n\n respond_to do |format|\n if @room.update_attributes(params[:room])\n format.html { redirect_to @room, notice: 'Room was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @room.update_attributes(room_params)\n format.html { redirect_to room_path(@room.slug), notice: 'Room was successfully updated.' }\n format.json { render :show, status: :ok, location: @room }\n else\n format.html { render :edit }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if @room.update(room_params)\n head :no_content\n else\n render json: @room.errors, status: :unprocessable_entity\n end\n end", "def update\n respond_to do |format|\n if @room.update(room_params)\n format.html { redirect_to hotelprofile_path, notice: 'Room was successfully updated.' }\n format.json { render :show, status: :ok, location: @room }\n else\n format.html { render :edit }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @room.update(room_params)\n format.html { redirect_to @room, notice: 'Room was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @room.update(room_params)\n format.html { redirect_to rooms_path, notice: \"Sala '\" + @room.name + \"' atualizada com sucesso!\" }\n format.json { render :show, status: :ok, location: @room }\n else\n format.html { render :edit }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @room.update(room_params)\n format.html { redirect_to rooms_path, notice: 'Room was successfully updated.' }\n format.json { render :show, status: :ok, location: @room }\n else\n format.html { render :edit }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @room.update(room_params)\n format.html { redirect_to @room, notice: 'Room was successfully updated.' }\n format.json { render :show, status: :ok, location: @room }\n else\n format.html { render :edit }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @room.update(room_params)\n format.html { redirect_to @room, notice: 'Room was successfully updated.' }\n format.json { render :show, status: :ok, location: @room }\n else\n format.html { render :edit }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @room.update(room_params)\n format.html { redirect_to @room, notice: 'Room was successfully updated.' }\n format.json { render :show, status: :ok, location: @room }\n else\n format.html { render :edit }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @room.update(room_params)\n format.html { redirect_to @room, notice: 'Room was successfully updated.' }\n format.json { render :show, status: :ok, location: @room }\n else\n format.html { render :edit }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @room.update(room_params)\n format.html { redirect_to @room, notice: 'Room was successfully updated.' }\n format.json { render :show, status: :ok, location: @room }\n else\n format.html { render :edit }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @room.update(room_params)\n format.html { redirect_to @room, notice: 'Room was successfully updated.' }\n format.json { render :show, status: :ok, location: @room }\n else\n format.html { render :edit }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @room.update(room_params)\n format.html { redirect_to @room, notice: 'Room was successfully updated.' }\n format.json { render :show, status: :ok, location: @room }\n else\n format.html { render :edit }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @room.update(room_params)\n format.html { redirect_to @room, notice: 'Room was successfully updated.' }\n format.json { render :show, status: :ok, location: @room }\n else\n format.html { render :edit }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @room.update(room_params)\n format.html { redirect_to @room, notice: 'Room was successfully updated.' }\n format.json { render :show, status: :ok, location: @room }\n else\n format.html { render :edit }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @room.update(room_params)\n format.html { redirect_to @room, notice: 'Room was successfully updated.' }\n format.json { render :show, status: :ok, location: @room }\n else\n format.html { render :edit }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @room.update(room_params)\n format.html { redirect_to @room, notice: \"Room was successfully updated.\" }\n format.json { render :show, status: :ok, location: @room }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n\n respond_to do |format|\n if @room.update(room_params_update)\n format.html { redirect_to @room, :flash => { success: 'Room was successfully updated.' } }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @serverroom = Serverroom.find(params[:id])\n\n respond_to do |format|\n if @serverroom.update_attributes(params[:serverroom])\n format.html { redirect_to @serverroom, notice: 'Serverroom was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @serverroom.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @ppl.update(ppl_params)\n format.html { redirect_to :back, notice: 'Ppl was successfully updated.' }\n format.json { render :show, status: :ok, location: @ppl }\n else\n format.html { render :edit }\n format.json { render json: @ppl.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @room.update(room_params)\n format.html { redirect_to @room, notice: 'Room was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @room.update(room_params)\n format.html { redirect_to @room, notice: t('default.room.updated') }\n format.json { render :show, status: :ok, location: @room }\n else\n format.html { render :edit }\n format.json { render json: @error, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @admin_room.update(admin_room_params)\n format.html { redirect_to [:admin, @admin_room.building], notice: 'Room was successfully updated.' }\n # format.json { render :show, status: :ok, location: @admin_room }\n else\n format.html { render :edit }\n # format.json { render json: @admin_room.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @admin_room.update(admin_room_params)\n format.html { redirect_to admin_rooms_path, notice: 'Room was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @admin_room.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @room.update(room_params)\n format.html { redirect_to hotel_path(@room.hotel_id), notice: 'Room was successfully updated.' }\n format.json { render :show, status: :ok, location: @room }\n else\n format.html { render :edit }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @papel = Papel.find(params[:id])\n\n respond_to do |format|\n if @papel.update_attributes(params[:papel])\n format.html { redirect_to @papel, notice: 'Papel was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @papel.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @room.update(room_params)\n format.html { redirect_to @room, notice: 'Room was successfully updated.' }\n format.json { render :show, status: :ok, location: @room }\n else\n format.html { render :edit, alert: 'Что-то пошло не так' }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @hotel_room = HotelRoom.find(params[:id])\n\n respond_to do |format|\n if @hotel_room.update_attributes(params[:hotel_room])\n format.html { redirect_to @hotel_room, notice: 'Hotel room was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @hotel_room.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @pokeparty = Pokeparty.find(params[:id])\n\n respond_to do |format|\n if @pokeparty.update_attributes(params[:pokeparty])\n format.html { redirect_to @pokeparty, notice: 'Pokeparty was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @pokeparty.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @room.update(room_params)\n format.html { redirect_to @room, notice: 'La Sala ha sido actualizada correctamente!' }\n format.json { render :show, status: :ok, location: @room }\n else\n format.html { render :edit }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @hostel_room = HostelRoom.find(params[:id])\n\n respond_to do |format|\n if @hostel_room.update_attributes(params[:hostel_room])\n format.html { redirect_to @hostel_room, notice: 'Hostel room was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @hostel_room.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @platoon.update(platoon_params)\n format.html { redirect_to @platoon, notice: 'Platoon was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @platoon.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n \n if @meeting_room.update(room_params)\n redirect_to meeting_rooms_path\n else\n render 'edit'\n end\n end", "def update\n respond_to do |format|\n if @room.update(room_params)\n format.html { redirect_to @room}\n flash[:success] ='Room was successfully updated.'\n format.json { render :show, status: :ok, location: @room }\n else\n format.html { render :edit }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @plato = Plato.find(params[:id])\n\n if @plato.update(plato_params)\n head :no_content\n else\n render json: @plato.errors, status: :unprocessable_entity\n end\n end", "def update\n respond_to do |format|\n if @kind_room.update(kind_room_params)\n format.html { redirect_to @kind_room, notice: 'Kind room was successfully updated.' }\n format.json { render :show, status: :ok, location: @kind_room }\n else\n format.html { render :edit }\n format.json { render json: @kind_room.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @meetingroom.update(meetingroom_params)\n format.html { redirect_to [@space, @meetingroom], notice: 'Meetingroom was successfully updated.' }\n format.json { render :show, status: :ok, location: [@space, @meetingroom] }\n else\n format.html { render :edit }\n format.json { render json: @meetingroom.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @painel.update(painel_params)\n format.html { redirect_to @painel, notice: 'Painel was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @painel.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n # Filter only those valid to be updated\n updated_attributes = {}\n updated_attributes[:name] = params[:room][:name]\n updated_attributes[:max_user] = params[:room][:max_user]\n @room = current_user.rooms.find(params[:id])\n\n respond_to do |format|\n if @room.update_attributes(updated_attributes)\n format.html { redirect_to @room, notice: 'Room was successfully updated.' }\n format.json { render json: @room.to_hash_with_users(current_user).to_json }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @employee_room.update(employee_room_params)\n format.html { redirect_to @employee_room, notice: 'Employee room was successfully updated.' }\n format.json { render :show, status: :ok, location: @employee_room }\n else\n format.html { render :edit }\n format.json { render json: @employee_room.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @bathroom.update(bathroom_params)\n format.html { redirect_to @bathroom, notice: 'Bathroom was successfully updated.' }\n format.json { render :show, status: :ok, location: @bathroom }\n else\n format.html { render :edit }\n format.json { render json: @bathroom.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n authorize room\n\n if room_params[:public]\n authorize room, :create_public?\n end\n\n respond_to do |format|\n if room.update(room_params)\n format.html { redirect_to room, notice: I18n.t('rooms.successfully_updated') }\n format.json { render :show, status: :ok, location: room }\n else\n format.html { render :edit }\n format.json { render json: room.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @masters_chatroom_apartment.update(masters_chatroom_apartment_params)\n format.html { redirect_to [:masters,@masters_chatroom_apartment], notice: 'Chatroom apartment was successfully updated.' }\n format.json { render :show, status: :ok, location: @masters_chatroom_apartment }\n else\n format.html { render :edit }\n format.json { render json: @masters_chatroom_apartment.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n\t\trespond_to do |format|\n\t\t\tif @room.update(room_params)\n\t\t\t\tformat.html { redirect_to @room, notice: 'Room was successfully updated.' }\n\t\t\t\tformat.json { render :show, status: :ok, location: @room }\n\t\t\telse\n\t\t\t\tformat.html { render :edit }\n\t\t\t\tformat.json { render json: @room.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend", "def update\n respond_to do |format|\n if @political_party.update(political_party_params)\n format.html { redirect_to @political_party, notice: 'Political party was successfully updated.' }\n format.json { render :show, status: :ok, location: @political_party }\n else\n format.html { render :edit }\n format.json { render json: @political_party.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @room.hotel = Hotel.find_by_name(params[:room][:hotel])\n \n respond_to do |format|\n if @room.update(room_params)\n format.html { redirect_to crew_rooms_path, notice: 'Quarto atualizado com sucesso.' }\n format.json { render :show, status: :ok, location: @room }\n else\n format.html { render :edit }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @cleaning_room.update(cleaning_room_params)\n format.html { redirect_to @cleaning_room, notice: 'Cleaning room was successfully updated.' }\n format.json { render :show, status: :ok, location: @cleaning_room }\n else\n format.html { render :edit }\n format.json { render json: @cleaning_room.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n apartment = Apartment.find(params[:id])\n apartment.update_attributes(apartment_params)\n render json: apartment\n end", "def update\n param=room_params\n actype=param[:AC]\n bedcount=param[:beds]\n param.delete(\"AC\")\n param.delete(\"beds\")\n @room=Room.find_by(roomid:param[:roomid])\n respond_to do |format|\n if @room.update(param)\n roomtype=@room.roomtype\n roomtype.update(AC:actype,beds:bedcount)\n format.html { redirect_to @room, notice: \"Room was successfully updated.\" }\n format.json { render :show, status: :ok, location: @room }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @room = Room.find(params[:id])\n\n respond_to do |format|\n if @room.update_attributes(params[:room])\n format.html { redirect_to(@room, :notice => 'Room was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @room.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @plant.update(plant_params)\n format.html { redirect_to @plant, notice: 'Your Swap whas been updated!' }\n format.json { render :show, status: :ok, location: @plant }\n else\n format.html { render :edit }\n format.json { render json: @plant.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @spawner = Spawner.find(params[:id])\n @fieldtrips = Fieldtrip.all\n\n respond_to do |format|\n if @spawner.update_attributes(spawner_params)\n format.html { redirect_to @spawner, notice: 'Spawner was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @spawner.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @plant.update(plant_params)\n format.html { redirect_to garden_plant_path(@garden, @plant), notice: 'Plant was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @plant.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @chatroom = Chatroom.find(params[:id])\n\n respond_to do |format|\n if @chatroom.update_attributes(params[:chatroom])\n format.html { redirect_to @chatroom, notice: 'Chatroom was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @chatroom.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if not check_logged_in then\n return\n end\n\n @plant = Plant.find(params[:id])\n\n respond_to do |format|\n if @plant.update_attributes(params[:plant])\n format.html { redirect_to @plant, notice: 'Plant was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @plant.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @room.update_attributes(params[:room])\n respond_with(@room, location: bnb_rooms_url(@room.bnb))\n end", "def update\n respond_to do |format|\n if @room.update(room_params)\n format.html { redirect_to school_room_path(@room.school,@room), notice: 'Room update successful.' }\n format.json { render :show, status: :ok, location: @room }\n else\n format.html { render :edit }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @lunch.update(lunch_params)\n format.html { redirect_to @lunch, notice: 'Lunch was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @lunch.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_room\n\t@room_options = {}\n\t@room_options[\"data\"] = {}\n\trooms = Room.where(\"building_id = ?\",params[:building_id])\n\tif rooms.length == 0\n\t\t@room_options[\"data\"][\"\"] = \"\"\n\telse\n\t\trooms.each {|room|\n\t\t\t@room_options[\"data\"][room.id.to_s] = room.room_name\n\t\t}\n\tend\n\t@room_options[\"select_id\"] = \"#room_select_\" + params[:course_id]\n\tcourse_assignment = get_course_assignment(params[:course_id])\n\troom_id = course_assignment.room_id.to_s\n\tif room_id != nil\n\t\t@room_options[\"selected_val\"] = room_id\n\telse\n\t\t@room_options[\"selected_val\"] = \"\"\n\tend\n\trespond_to do |format|\n\t\tformat.json {render json: @room_options}\n\tend\n end", "def update\n respond_to do |format|\n if @reserved_room.update(reserved_room_params)\n format.html { redirect_to @reserved_room, notice: 'Reserved room was successfully updated.' }\n format.json { render :show, status: :ok, location: @reserved_room }\n else\n format.html { render :edit }\n format.json { render json: @reserved_room.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @pol.update(pol_params)\n format.json { render :show, status: :ok, location: @pol }\n else\n format.json { render json: @pol.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @room = Room.find(params[:id])\n \n @room.criterias.delete_all\n params[:criteria].each_pair do |k,v|\n @room.criterias << Criteria.find(k.to_i) if v == \"1\"\n end\n\n @room.not_criterias.delete_all \n params[:not_criteria].each_pair do |k,v|\n @room.not_criterias << Criteria.find(k.to_i) if v == \"1\"\n end\n\n respond_to do |format|\n if @room.update_attributes(params[:room])\n flash[:notice] = 'Room was successfully updated.'\n format.html { redirect_to agency_site_room_path(params[:agency_id], params[:site_id], @room.id) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @room.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @room_facility.update(room_facility_params)\n format.html { redirect_to @room_facility, notice: 'Room facility was successfully updated.' }\n format.json { render :show, status: :ok, location: @room_facility }\n else\n format.html { render :edit }\n format.json { render json: @room_facility.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @room = Room.find(params[:id])\n\n if @room.update(room_params)\n redirect_to @room\n else\n render 'edit'\n end\n end", "def update\n respond_to do |format|\n if @roomtable.update(roomtable_params)\n format.html { redirect_to @roomtable, notice: 'Roomtable was successfully updated.' }\n format.json { render :show, status: :ok, location: @roomtable }\n else\n format.html { render :edit }\n format.json { render json: @roomtable.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @occupied_room.update(occupied_room_params)\n format.html { redirect_to @occupied_room, notice: 'Occupied room was successfully updated.' }\n format.json { render :show, status: :ok, location: @occupied_room }\n else\n format.html { render :edit }\n format.json { render json: @occupied_room.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @roomlist.update(roomlist_params)\n #format.html { redirect_to @roomlist, notice: 'Roomlist was successfully updated.' }\n format.html { redirect_to @roomlist, notice: 'Room was successfully Allocated.' }\n format.json { render :show, status: :ok, location: @roomlist }\n else\n format.html { render :edit }\n format.json { render json: @roomlist.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @room_information.update(room_information_params)\n format.html { redirect_to @room_information, notice: 'Room information was successfully updated.' }\n format.json { render :show, status: :ok, location: @room_information }\n else\n format.html { render :edit }\n format.json { render json: @room_information.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @roomrate = Roomrate.find(params[:id])\n\n respond_to do |format|\n if @roomrate.update_attributes(params[:roomrate])\n format.html { redirect_to [:admin,@roomrate] , notice: 'Roomrate was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @roomrate.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @about_room.update(about_room_params)\n format.html { redirect_to @about_room, notice: 'About room was successfully updated.' }\n format.json { render :show, status: :ok, location: @about_room }\n else\n format.html { render :edit }\n format.json { render json: @about_room.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @personel.update(personel_params)\n format.html { redirect_to @personel, notice: 'Personel was successfully updated.' }\n format.json { render :show, status: :ok, location: @personel }\n else\n format.html { render :edit }\n format.json { render json: @personel.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @plate = Plate.find(params[:id])\n\n if @plate.update(params[:plate])\n head :no_content\n else\n render json: @plate.errors, status: :unprocessable_entity\n end\n end", "def update\n @telecom_room = TelecomRoom.find(params[:id])\n\n respond_to do |format|\n if @telecom_room.update_attributes(params[:telecom_room])\n format.html { redirect_to(@telecom_room, :notice => 'TelecomRoom was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @telecom_room.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @pony = Pony.find(params[:id])\n\n respond_to do |format|\n if @pony.update_attributes(params[:pony])\n format.html { redirect_to @pony, notice: 'Pony was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @pony.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if @room.update(room_params)\n redirect_to admin_rooms_path, notice: 'Room was successfully updated.'\n else\n render :edit\n end\n end", "def update\n respond_to do |format|\n @person = @profissional.person\n if @person.update(profissional_params[:person_attributes])\n if profissional_params[:specialization].present?\n @profissional.update_attributes(:specialization => profissional_params[:specialization])\n format.html { redirect_to @profissional, notice: 'Profissional was successfully updated.' }\n format.json { render :show, status: :ok, location: @profissional }\n else\n format.html { render :edit }\n format.json { render json: @profissional.errors, status: :unprocessable_entity }\n end\n\n end\n end\n end", "def update\n respond_to do |format|\n if @prim.update(prim_params)\n format.html { redirect_to @prim, notice: 'Prim was successfully updated.' }\n format.json { render :show, status: :ok, location: @prim }\n else\n format.html { render :edit }\n format.json { render json: @prim.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @chat_room.update_attributes(params[:chat_room])\n format.html { redirect_to @chat_room, notice: 'Chat room was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @chat_room.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @empty_room.update(empty_room_params)\n format.html { redirect_to @empty_room, notice: 'Empty room was successfully updated.' }\n format.json { render :show, status: :ok, location: @empty_room }\n else\n format.html { render :edit }\n format.json { render json: @empty_room.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @roombot = Roombot.find(params[:id])\n\n respond_to do |format|\n if @roombot.update_attributes(params[:roombot])\n format.html { redirect_to @roombot, notice: 'Roombot was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @roombot.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @party = Party.find(params[:id])\n\n respond_to do |format|\n if @party.update_attributes(params[:party])\n format.html { redirect_to @party, notice: 'Party was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @party.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @livingroom = Livingroom.find(params[:id])\n\n respond_to do |format|\n if @livingroom.update_attributes(params[:livingroom])\n flash[:notice] = 'Livingroom was successfully updated.'\n format.html { redirect_to(@livingroom) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @livingroom.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @pacient.update(pacient_params)\n format.html { redirect_to @pacient, notice: 'Pacient was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @pacient.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @prayer_request = PrayerRequest.find(params[:id])\n\n respond_to do |format|\n if @prayer_request.update_attributes(params[:prayer_request])\n format.html { redirect_to @prayer_request, notice: 'Prayer request was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @prayer_request.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @plundering.update(plundering_params)\n format.html { redirect_to @plundering, notice: 'Plundering was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @plundering.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n room = Room.find(params[:id])\n\n if room.update(room_params)\n response_data = {\n room: room,\n txt: ['更新しました!'],\n }\n render json: response_data, status: :ok\n else\n response_data = {\n txt: room.errors.full_messages,\n }\n render json: response_data, status: :unprocessable_entity\n end\n end", "def update\n respond_to do |format|\n if @papel.update(papel_params)\n format.html { redirect_to @papel, notice: 'Papel foi atualizado com sucesso.' }\n format.json { render :show, status: :ok, location: @papel }\n else\n format.html { render :edit }\n format.json { render json: @papel.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @wall_plate.update(wall_plate_params)\n format.html { redirect_to @wall_plate, notice: 'Wall plate was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @wall_plate.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @pmtrainer.update(pmtrainer_params)\n format.html { redirect_to @pmtrainer, notice: 'Pmtrainer was successfully updated.' }\n format.json { render :show, status: :ok, location: @pmtrainer }\n else\n format.html { render :edit }\n format.json { render json: @pmtrainer.errors, status: :unprocessable_entity }\n end\n end\n end" ]
[ "0.6791316", "0.67780656", "0.6730887", "0.6712128", "0.6712128", "0.6681339", "0.6670187", "0.6633799", "0.6629523", "0.6588999", "0.6587691", "0.65767485", "0.65751785", "0.6564573", "0.6511559", "0.650831", "0.6496751", "0.6483593", "0.6483593", "0.6483593", "0.6483593", "0.6483593", "0.6483593", "0.6483593", "0.6483593", "0.6483593", "0.6483593", "0.6467676", "0.64179444", "0.64141095", "0.64123255", "0.64114285", "0.64011073", "0.63957155", "0.638358", "0.6375527", "0.6356911", "0.63414985", "0.6330237", "0.6329605", "0.632566", "0.6311284", "0.6262144", "0.62465656", "0.6237467", "0.6236123", "0.6233919", "0.6231975", "0.6231138", "0.622371", "0.62155014", "0.62120336", "0.6211772", "0.62054384", "0.61969995", "0.6182105", "0.616176", "0.6159335", "0.6150814", "0.61495215", "0.6143635", "0.6139872", "0.612931", "0.61282223", "0.6128155", "0.6127406", "0.61168796", "0.61159796", "0.6111361", "0.61083454", "0.6107548", "0.61031693", "0.6095118", "0.6092072", "0.6090293", "0.60796314", "0.60766757", "0.6067898", "0.6065582", "0.60548085", "0.60513586", "0.6045333", "0.60432935", "0.60347235", "0.60343933", "0.6029339", "0.6022199", "0.60212153", "0.60207355", "0.60205805", "0.6020019", "0.60179186", "0.6008495", "0.6007866", "0.5999064", "0.5996092", "0.5992561", "0.5991771", "0.59870976", "0.59849936" ]
0.7021614
0
DELETE /room_plants/1 DELETE /room_plants/1.json
def destroy @room_plant.destroy end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @restroom.destroy\n respond_to do |format|\n format.html { redirect_to restrooms_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @admin_room.destroy\n respond_to do |format|\n format.html { redirect_to admin_rooms_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @plant = @garden.plants.find(params[:id])\n @plant.destroy\n respond_to do |format|\n format.html { redirect_to @garden, notice: 'Plant deleted.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @room = Room.find(params[:id])\n @room.destroy\n\n head :ok \n end", "def destroy\n #Ao apagar uma sala, suas cartas devem ser apagadas.\n Poker.where(room: @room).destroy_all\n \n @room.destroy\n \n respond_to do |format|\n format.html { redirect_to rooms_url, notice: \"Sala '\" + @room.name + \"' foi apagada com sucesso!\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @room.destroy\n respond_to do |format|\n format.html { redirect_to crew_rooms_path, notice: 'Quarto foi apagado com sucesso.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @room = Room.find(params[:id])\n @room.destroy\n\n respond_to do |format|\n format.html { redirect_to rooms_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @room = Room.find(params[:id])\n @room.destroy\n\n respond_to do |format|\n format.html { redirect_to rooms_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @room.destroy\n\n respond_to do |format|\n format.html { redirect_to rooms_url }\n format.json { head :ok }\n end\n end", "def destroy\n @room = Room.find(params[:id])\n @room.destroy\n\n respond_to do |format|\n format.html { redirect_to rooms_url }\n format.json { head :ok }\n end\n end", "def destroy\n if not check_logged_in then\n return\n end\n @plant = Plant.find(params[:id])\n @plant.destroy\n\n respond_to do |format|\n format.html { redirect_to plants_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @restroom = Restroom.find(params[:id])\n authorize @restroom\n @restroom.destroy\n respond_to do |format|\n format.html { redirect_to restrooms_path, notice: 'Restroom deleted.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @serverroom = Serverroom.find(params[:id])\n @serverroom.destroy\n\n respond_to do |format|\n format.html { redirect_to serverrooms_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @room = Room.find(params[:id])\n @room.destroy\n\n respond_to do |format|\n format.html { redirect_to staffs_path, notice: 'Room was successfully deleted.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @room.destroy\n respond_to do |format|\n format.html { redirect_to admin_rooms_path(id: @room.hotel.id), notice: 'Room was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @restroom = Restroom.find(params[:id])\n @restroom.destroy\n authorize! :destroy, @restroom\n\n respond_to do |format|\n format.html { redirect_to restrooms_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @restroom = Restroom.find(params[:id])\n @restroom.destroy\n authorize! :destroy, @restroom\n\n respond_to do |format|\n format.html { redirect_to restrooms_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @hostel_room = HostelRoom.find(params[:id])\n @hostel_room.destroy\n\n respond_to do |format|\n format.html { redirect_to hostel_rooms_url }\n format.json { head :ok }\n end\n end", "def destroy\n @room.destroy\n respond_to do |format|\n format.html { redirect_to @room.floor, notice: t('flash.room.delete') }\n format.json { head :no_content }\n end\n end", "def destroy\n if not check_logged_in then\n return\n end\n @personal_plant = PersonalPlant.find(params[:id])\n @personal_plant.destroy\n\n respond_to do |format|\n format.html { redirect_to personal_plants_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @admin_room.destroy\n respond_to do |format|\n format.html { redirect_to admin_building_path(params[:building_id]), notice: 'Room was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @room.destroy\n respond_to do |format|\n format.html { redirect_to hotelprofile_path, notice: 'Room was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @hotel_room = HotelRoom.find(params[:id])\n @hotel_room.destroy\n\n respond_to do |format|\n format.html { redirect_to hotel_rooms_url }\n format.json { head :ok }\n end\n end", "def destroy\n @room = current_user.rooms.find(params[:id])\n @room.destroy\n\n respond_to do |format|\n format.html { redirect_to rooms_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @room = Room.find(params[:id])\n @room.destroy\n\n respond_to do |format|\n format.html { redirect_to(agency_site_rooms_url(params[:agency_id], params[:site_id])) }\n format.xml { head :ok }\n end\n end", "def destroy\n @roomtype.destroy\n respond_to do |format|\n format.html { redirect_to roomtypes_url, notice: 'Roomtype was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @room.destroy\n respond_to do |format|\n format.html { redirect_to location_path(@room.location), notice: 'La Sala ha sido eliminada correctamente!' }\n format.json { head :no_content }\n end\n end", "def destroy\n @plant.destroy\n respond_to do |format|\n format.html { redirect_to plants_url, notice: 'Your Swap was successfully deleted.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @room = Room.find(params[:id])\n @room.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 @tddbc_room = Tddbc::Room.find(params[:id])\n @tddbc_room.destroy\n\n respond_to do |format|\n format.html { redirect_to tddbc_rooms_url }\n format.json { head :ok }\n end\n end", "def destroy\n @roombot = Roombot.find(params[:id])\n @roombot.destroy\n\n respond_to do |format|\n format.html { redirect_to roombots_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @pokeparty = Pokeparty.find(params[:id])\n @pokeparty.destroy\n\n respond_to do |format|\n format.html { redirect_to pokeparties_url }\n format.json { head :ok }\n end\n end", "def destroy\n @bathroom.destroy\n respond_to do |format|\n format.html { redirect_to bathrooms_url, notice: 'Bathroom was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @bathroom.destroy\n respond_to do |format|\n format.html { redirect_to bathrooms_url, notice: 'Bathroom was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @papel = Papel.find(params[:id])\n @papel.destroy\n\n respond_to do |format|\n format.html { redirect_to papels_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @room.destroy\n respond_to do |format|\n format.html { redirect_to rooms_url, notice: t('default.room.destroyed') }\n format.json { head :no_content }\n end\n end", "def destroy\n @request_room.destroy\n respond_to do |format|\n format.html { redirect_to request_rooms_url, notice: 'Request room was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @room.destroy\n respond_to do |format|\n format.html { redirect_to rooms_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @room.destroy\n respond_to do |format|\n format.html { redirect_to rooms_url, notice: 'Room was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @room.destroy\n respond_to do |format|\n format.html { redirect_to rooms_url, notice: 'Room was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @room.destroy\n respond_to do |format|\n format.html { redirect_to rooms_url, notice: 'Room was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @room.destroy\n respond_to do |format|\n format.html { redirect_to rooms_url, notice: 'Room was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @room.destroy\n respond_to do |format|\n format.html { redirect_to rooms_url, notice: 'Room was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @room.destroy\n respond_to do |format|\n format.html { redirect_to rooms_url, notice: 'Room was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @room.destroy\n respond_to do |format|\n format.html { redirect_to rooms_url, notice: 'Room was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @room.destroy\n respond_to do |format|\n format.html { redirect_to rooms_url, notice: 'Room was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @room.destroy\n respond_to do |format|\n format.html { redirect_to rooms_url, notice: 'Room was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @room.destroy\n respond_to do |format|\n format.html { redirect_to rooms_url, notice: 'Room was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @room.destroy\n respond_to do |format|\n format.html { redirect_to rooms_url, notice: 'Room was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @room.destroy\n respond_to do |format|\n format.html { redirect_to rooms_url, notice: \"Room was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @room.destroy\n respond_to do |format|\n format.html { redirect_to rooms_url, notice: \"Room was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @pol.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def destroy\n @hotel = @room.hotel.id\n @room.destroy\n respond_to do |format|\n format.html { redirect_to hotel_url(@hotel), notice: 'Room was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n UserPlant.destroy(params[:id])\n end", "def destroy\n @painel.destroy\n respond_to do |format|\n format.html { redirect_to painels_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @room_occupation.destroy\n respond_to do |format|\n format.html { redirect_to room_occupations_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @room = Room.find(params[:id])\n @room.destroy\n\n redirect_to rooms_path\n end", "def destroy\n @floor_plan.destroy\n respond_to do |format|\n format.html { redirect_to location_path(@location) }\n format.json { head :no_content }\n end\n end", "def destroy\n Roommate.destroy(@roommate.id)\n set_roommates\n respond_to do |format|\n format.html { redirect_to roommates_url, notice: 'Roommate was successfully deleted.' }\n format.json { head :no_content }\n format.js\n end\n end", "def destroy\n @masters_chatroom_apartment.destroy\n respond_to do |format|\n format.html { redirect_to masters_chatroom_apartments_url, notice: 'Chatroom apartment was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @plant.destroy\n respond_to do |format|\n format.html { redirect_to plants_url, notice: 'Plant was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @relief_camp_admin.destroy\n respond_to do |format|\n format.html { redirect_to relief_camp_admins_url, notice: 'Relief camp admin was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @pharmacy.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def destroy\n @pony = Pony.find(params[:id])\n @pony.destroy\n\n respond_to do |format|\n format.html { redirect_to ponies_url }\n format.json { head :ok }\n end\n end", "def destroy\n @my_room = MyRoom.find(params[:my_room_id])\n @my_rack.destroy\n respond_to do |format|\n format.html { redirect_to @my_room, notice: 'Стелаж успешно удален.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @ppl.destroy\n respond_to do |format|\n format.html { redirect_to URI(request.referer || '').path, notice: 'Ppl was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @room.destroy\n redirect_to admin_rooms_path, notice: 'Room was successfully destroyed.'\n end", "def destroy\n @habitant.destroy\n respond_to do |format|\n format.html { redirect_to habitants_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @room = Room.find(params[:id])\n @room.destroy\n\n respond_to do |format|\n format.html { redirect_to(rooms_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @reservation_room.destroy\n respond_to do |format|\n format.html { redirect_to reservation_rooms_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @spawner = Spawner.find(params[:id])\n @spawner.destroy\n\n respond_to do |format|\n format.html { redirect_to spawners_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @party = Party.find(params[:id])\n @party.destroy\n\n respond_to do |format|\n format.html { redirect_to parties_url }\n format.json { head :no_content }\n end\n end", "def destroy\n room = Room.find(params[:id])\n if room.destroy\n head :no_content\n return\n else\n response_data = {\n txt: ['削除できませんでした!'],\n }\n render json: response_data, status: :unprocessable_entity\n end\n end", "def destroy\n @political_party.destroy\n respond_to do |format|\n format.html { redirect_to political_parties_url, notice: 'Political party was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @kind_room.destroy\n respond_to do |format|\n format.html { redirect_to kind_rooms_url, notice: 'Kind room was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @test_plant = TestPlant.find(params[:id])\n @test_plant.destroy\n\n respond_to do |format|\n format.html { redirect_to(test_plants_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @floor_ammenity.destroy\n respond_to do |format|\n format.html { redirect_to floor_ammenities_url, notice: 'Ammenity was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @telecom_room = TelecomRoom.find(params[:id])\n @telecom_room.destroy\n\n respond_to do |format|\n format.html { redirect_to(telecom_rooms_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @room.destroy\n respond_with(@room)\n end", "def destroy\n @room_facility.destroy\n respond_to do |format|\n format.html { redirect_to room_facilities_url, notice: 'Room facility was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @pacient.destroy\n respond_to do |format|\n format.html { redirect_to pacients_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @plundering.destroy\n respond_to do |format|\n format.html { redirect_to plunderings_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @chatroom = Chatroom.find(params[:id])\n @chatroom.destroy\n\n respond_to do |format|\n format.html { redirect_to chatrooms_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @planting.destroy\n respond_to do |format|\n format.html { redirect_to plantings_url, notice: 'Planting was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @occupied_room.destroy\n respond_to do |format|\n format.html { redirect_to occupied_rooms_url, notice: 'Occupied room was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @restaurant_floor_plan.destroy\n respond_to do |format|\n format.html { redirect_to restaurant_floor_plans_url, notice: 'Restaurant floor plan was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @roomrate = Roomrate.find(params[:id])\n @roomrate.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_roomrates_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @roomtable.destroy\n respond_to do |format|\n format.html { redirect_to roomtables_url, notice: 'Roomtable was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @plantation.destroy\n respond_to do |format|\n format.html { redirect_to farm_plantations_url(@farm), notice: 'Plantation enlevée.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @meetingroom.destroy\n respond_to do |format|\n format.html { redirect_to space_meetingrooms_url(@space), notice: 'Meetingroom was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @pinglun = Pinglun.find(params[:id])\n @pinglun.destroy\n\n respond_to do |format|\n format.html { redirect_to pingluns_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @room.destroy\n respond_to do |format|\n format.html { redirect_to rooms_url :flash => { success: 'Room was successfully destroyed.' } }\n format.json { head :no_content }\n end\n end", "def destroy\n @roomlist.destroy\n respond_to do |format|\n format.html { redirect_to roomlists_url, notice: 'Roomlist was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @livingroom = Livingroom.find(params[:id])\n @livingroom.destroy\n\n respond_to do |format|\n format.html { redirect_to(livingrooms_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @parliament = Parliament.find(params[:id])\n @parliament.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_parliaments_url }\n format.json { head :ok }\n end\n end", "def destroy\n @ptel_reup.destroy\n respond_to do |format|\n format.html { redirect_to ptel_reups_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @wall_plate.destroy\n respond_to do |format|\n format.html { redirect_to wall_plates_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @occupant = Occupant.find(params[:id])\n @occupant.destroy\n\n respond_to do |format|\n format.html { redirect_to occupants_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @aspirant = Aspirant.find(params[:id])\n @aspirant.destroy\n\n respond_to do |format|\n format.html { redirect_to aspirants_url }\n format.json { head :ok }\n end\n end", "def destroy\n @reserved_room.destroy\n respond_to do |format|\n format.html { redirect_to reserved_rooms_url, notice: 'Reserved room was successfully destroyed.' }\n format.json { head :no_content }\n end\n end" ]
[ "0.7271063", "0.72138345", "0.7201651", "0.71675795", "0.71072954", "0.7099285", "0.70901394", "0.70900524", "0.70890146", "0.7080594", "0.70632714", "0.70386904", "0.70239305", "0.7016282", "0.70043874", "0.6989799", "0.6989799", "0.698088", "0.6963748", "0.69513077", "0.6946946", "0.694442", "0.6927069", "0.6925894", "0.69236606", "0.6921173", "0.69194895", "0.6901368", "0.68839025", "0.688346", "0.686237", "0.6861429", "0.6847822", "0.6847822", "0.68341994", "0.6833365", "0.68280596", "0.68264735", "0.6818242", "0.6818242", "0.6818242", "0.6818242", "0.6818242", "0.6818242", "0.6818242", "0.6818242", "0.6818242", "0.6818242", "0.6816785", "0.681308", "0.681308", "0.6811896", "0.68093395", "0.68036306", "0.6803059", "0.6783693", "0.6775859", "0.6773804", "0.67722917", "0.67650884", "0.6760604", "0.6754413", "0.67524195", "0.6746879", "0.6735448", "0.6734988", "0.67277616", "0.6725362", "0.67202914", "0.67147166", "0.6702016", "0.67018795", "0.67004186", "0.6698022", "0.6683596", "0.6683449", "0.6679698", "0.66786003", "0.66768235", "0.66736805", "0.66733176", "0.6657244", "0.66549355", "0.6651836", "0.66423833", "0.66414756", "0.6639126", "0.6638832", "0.6638682", "0.6633355", "0.6622625", "0.66217977", "0.6618644", "0.6615693", "0.66113526", "0.6606961", "0.66016287", "0.66012", "0.65981364", "0.65978247" ]
0.72758394
0
Use callbacks to share common setup or constraints between actions.
def set_room_plant @room_plant = RoomPlant.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 room_plant_params params.fetch(:room_plant, {}) 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 filtering_params\n params.permit(:email)\n end", "def active_code_params\n params[:active_code].permit\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 url_whitelist; 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 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 permit_request_params\n params.permit(:address)\n end", "def sensitive_params=(params)\n @sensitive_params = params\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 user_params\n params.permit(:name, :age, :username, :display_photo, :password)\n end", "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 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.69780594", "0.678054", "0.6742781", "0.67387927", "0.67346025", "0.6590683", "0.6501642", "0.6495788", "0.6479752", "0.64763314", "0.645457", "0.6437739", "0.6377168", "0.6372484", "0.6363871", "0.63179374", "0.62981373", "0.6297456", "0.62916917", "0.6290227", "0.628954", "0.62877893", "0.62814754", "0.62416226", "0.6237962", "0.62168854", "0.62127215", "0.62084496", "0.61927646", "0.6176822", "0.6174079", "0.6171225", "0.6161419", "0.61507314", "0.6150071", "0.6145409", "0.61204594", "0.61135256", "0.6105225", "0.6103249", "0.6088041", "0.6079626", "0.6070542", "0.6060409", "0.60198915", "0.6016795", "0.6010659", "0.60103244", "0.6005393", "0.6005393", "0.6000696", "0.60000104", "0.59931517", "0.59916013", "0.5991397", "0.5990416", "0.5979021", "0.5965926", "0.59582806", "0.59579134", "0.5957629", "0.5956672", "0.59518754", "0.59510773", "0.5942638", "0.5937516", "0.59361875", "0.59361875", "0.59336793", "0.5928626", "0.5925229", "0.59243226", "0.59174913", "0.5907821", "0.5907719", "0.5906177", "0.59056896", "0.5897028", "0.5896294", "0.5895856", "0.5893494", "0.58926904", "0.589066", "0.58854234", "0.58809334", "0.5878489", "0.58727074", "0.5868653", "0.5866631", "0.58666086", "0.5866305", "0.586484", "0.58631617", "0.5861481", "0.5861059", "0.5859114", "0.5858489", "0.585326", "0.58530635", "0.5848788", "0.58479697" ]
0.0
-1
get the active tasks
def active_tasks request.method = :get request.uri = '_active_tasks' Couchdbtools.execute(request) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def active_tasks\n @tasks.select { | task | task.active }\n end", "def active_tasks\n output = []\n @@task_types.each do |association_symbol|\n output = output + self.send(association_symbol).active\n end\n output\n end", "def tasks\n task_list.tasks\n end", "def active_tasks(tasks)\n tasks.select { |task| task.completed_at.nil? }\n end", "def tasks\n return @tasks\n end", "def tasks\n return @tasks\n end", "def tasks\n return @tasks\n end", "def tasks\n @tasks ||= Task.find(self.task_ids)\n end", "def inactive_tasks\n @tasks.select { | task | ! task.active }\n end", "def get_available_tasks\n tasks_to_return = []\n @tasks_names.each{ |t_name|\n tasks_to_return.push(@tasks[t_name])\n } \n return tasks_to_return\n end", "def tasks\n @task_manager.tasks_in_scope(@scope)\n end", "def tasks\n @db[:tasks].keys.compact.uniq || []\n end", "def tasks\n return @tasks.values\n end", "def tasks\n @task_manager.tasks_in_scope(@scope)\n end", "def tasks\n @tasks ||= Evoke.tasks\n end", "def tasks\n if @tasks.nil?\n @tasks = tasks_by_filters\n @tasks = filter_by_tags(@tasks)\n @tasks += unread_tasks if session[:show_all_unread].to_i > 0\n @tasks = sort_tasks(@tasks)\n end\n\n return @tasks\n end", "def getTasklist\r\n\t\t\t\t\treturn @tasklist\r\n\t\t\t\tend", "def all\n return @tasks\n end", "def tasks\n EarLogger.instance.log \"Getting tasks for #{self}\"\n TaskManager.instance.get_tasks_for(self)\n end", "def own_tasks\n uri = self.uri\n query = Ruta::Sparql.select.where(\n [:task, RDF.type, Ruta::Class.task],\n [:task, Ruta::Property.has_creator, uri]\n )\n tasks = []\n query.each_solution { |sol| tasks.push(sol.task.as(Task)) }\n tasks\n end", "def getSubtasks\r\n\t\t\t\t\treturn @tasks\r\n\t\t\t\tend", "def tasks\n @tasks ||= {}\n end", "def all_tasks\n @task = Task.get_all_tasks_user_can_see(current_user)\n end", "def all_tasks\n @all_tasks ||= []\n end", "def tasks\n TapirLogger.instance.log \"Getting tasks for #{self}\"\n tasks = TaskManager.instance.get_tasks_for(self)\n tasks.sort_by{ |t| t.name.downcase }\n end", "def tasks\n TapirLogger.instance.log \"Getting tasks for #{self}\"\n tasks = TaskManager.instance.get_tasks_for(self)\n tasks.sort_by{ |t| t.name.downcase }\n end", "def current_context_task_names()\n @cached_tasks.fetch(@active_context.get_task_cache_id(),[]).dup\n end", "def work_tasks\n uri = self.uri\n query = Ruta::Sparql.select.where(\n [:task, RDF.type, Ruta::Class.task],\n [:task, Ruta::Property.has_worker, uri]\n )\n tasks = []\n query.each_solution { |sol| tasks.push(sol.task.as(Task)) }\n tasks\n end", "def tasks\n Easybill::Api::Tasks\n end", "def completed_tasks\n self.tasks.where('is_completed =?', is_completed = true)\n end", "def tasks\n @client.list_tasks(cluster: @cluster, service_name: @name)[0]\n end", "def index\n active_task\n completed_task\n end", "def running\n tasks.detect {|task| task.running? }\n end", "def running\n tasks.detect {|task| task.running? }\n end", "def index\n @task_lists = Task::List.all.active\n end", "def tasks\n if @tasks.nil?\n @tasks ||= (filtering_by_tags? ? tasks_by_tags : tasks_by_filters)\n @tasks = filter_by_properties(@tasks)\n @tasks = sort_tasks(@tasks)\n end\n\n return @tasks\n end", "def currentTasks _args\n \"currentTasks _args;\" \n end", "def task_list\n self.tasks.map do |task|\n task.text\n end\n end", "def immediate_tasks\n\t\tdocument.tasks.select(container_id: self.id)\n\tend", "def actionable_tasks\n\t\tnext_tasks.select{ |t| !t.deferred? }\n\tend", "def task_lists\n\t\t@task_lists ||= fetch_latest_task_lists\n\tend", "def list_all_tasks\n task = Task.all\nend", "def show\n @task_items = @task_list.items.active\n end", "def active_tasks\n @tasks = @buyer.tasks.available_tasks.paginate( page: params[:page], per_page: 30)\n render \"tasks\"\n end", "def tasks\n config[:tasks]\n end", "def active_permitted_tasks\n ( self.restricted? ) ? self.tasks.active : Task.active\n end", "def tasks\n Task.undone_for_user(goddamn_tfpid)\n end", "def getAssignedTasks\n\tassignedTasks = CrawlerTask.where(:carrier => $worker_name, :status => 0)\nend", "def tasks(wspace=workspace)\n\t\twspace.tasks\n\tend", "def open_tasks\n @open_tasks ||= tasks.open\n end", "def scheduled_tasks\n self.tasks.select { \n |t| t.interval != :startup && t.interval != :shutdown\n }\n end", "def startup_tasks\n self.tasks.select { |t| t.interval == :startup }\n end", "def get_tasks(param_map, *args)\n #Strip off the first element, since it is not a Task\n get(\"tasks\", param_map, Babar::Task, true, *args)\n end", "def invoked_tasks\n @invoked_tasks\n end", "def task\n Task.all.find {|task| task.id == self.task_id}\n end", "def fetch_tasks\n tasks = BgTask.all\n tasks = load_tasks if tasks.nil? || tasks.empty?\n tasks\n end", "def tasks\n\t\t@tasks ||= if self.id.nil?\n\t\t\t[]\n\t\telse\n\t\t\tt_arr = document.tasks.select(container_id: self.id)\n\t\t\ti = 0\n\t\t\twhile i < t_arr.size\n\t\t\t\ttask = t_arr[i]\n\t\t\t\tif task.has_subtasks?\n\t\t\t\t\tt_arr += t_arr.delete_at(i).tasks\n\t\t\t\telse\n\t\t\t\t\ti += 1\n\t\t\t\tend\n\t\t\tend\n\t\t\tt_arr\n\t\tend\n\tend", "def list_user_tasks\n\t\t@tasks = current_user.get_developer_tasks\n\tend", "def capable_tasks() @capable_tasks ||= Task.children; end", "def tasks\n return self.class.get('/tasks').parsed_response.map do |task|\n Task.new(\n task['task_id'],\n task['template_id'],\n task['status'],\n task['started_at']\n )\n end\n end", "def in_progress_tasks\n Task.joins('inner join task_statuses on tasks.task_status_id = task_statuses.id').where('tasks.person_id' => id, 'task_statuses.finish' => false).order('created_at DESC')\n end", "def tasks\n @tasks.values.sort_by { |t| t.name }\n end", "def show\n @tasks = Task.from_user(@current_user).by_status(:confirmed).ordered\n @new_tasks = Task.from_user(@current_user).by_status(:pending).ordered\n @completed_tasks = Task.from_user(@current_user).by_status(:complete).ordered\n end", "def client_tasks\n self.all(:conditions => {:client_task => true})\n end", "def tasks_list\n (self.tasks || EMPTY_STRING).scan(/\\d+/).map{|x| x.to_i}.sort.uniq\n end", "def task_triggers\n return @task_triggers\n end", "def get_tasks_targets\n @test_pack.get_active_tests\n end", "def tasks(tasklist_id = '@default')\n get gtasks_tasks_url(tasklist_id)\n end", "def unread_tasks\n notifications = current_user.notifications.unread\n notifications += current_user.task_owners.unread\n \n tasks = notifications.map { |n| n.task }\n tasks = tasks.uniq\n # only get open / in progress tasks\n tasks = tasks.select { |t| (t.status == 0 or t.status == 1) }\n\n return tasks\n end", "def tasks\n @tasks ||= Harvest::API::Tasks.new(credentials)\n end", "def get_finished\n @task_list.select { |task| task.status == \"finished\" }\n end", "def show_tasks\n\t\tputs \"here are the tasks on the #{self.name} list...\"\n\t\t@tasks.map.with_index {|task, i| puts \"#{i.next}. \" + task.description + \" | complete: \" + task.status.to_s}\n\t\tputs \"\\n\"\n\tend", "def show # Show tasks method\n all_tasks.map.with_index { |l, i| \"(#{i.next}): #{l}\"} # Show all tasks array in numerical order and whether a task is completed\n end", "def task\n return @task\n end", "def next_tasks\n\t\tincomplete_tasks.select{ |t| !t.blocked? }\n\tend", "def get_taskarray\n @task_array\n end", "def task_names\n @task_names ||= tasks.map { |task| task.name.underscore }\n end", "def registered_tasks\n @task_register_lock.synchronize do\n @registered_tasks.values\n end\n end", "def registered_tasks\n @task_register_lock.synchronize do\n @registered_tasks.values\n end\n end", "def get_tasks(tasklist)\n tasklist_id = tasklist[\"id\"]\n tasklist.tasks = @client.execute(\n api_method: @api.tasks.list,\n parameters: {tasklist: tasklist_id}\n ).data.to_hash[\"items\"]\n end", "def remove_inactive_tasks\n self.tasks = self.tasks.active\n end", "def index\n @tasks = @current_user.tasks\n end", "def tasks_for(list)\n\t\t@tasks[list] ||= fetch_latest_tasks_for(list)\n\tend", "def pending_tasks?\n hash = pending_tasks\n return nil unless hash.key? \"tasks\"\n hash[\"tasks\"].length > 0\n end", "def registered_tasks\n # Get the task folder that contains the tasks.\n taskCollection = root_folder.GetTasks(0)\n array = []\n taskCollection.each do |registeredTask|\n array.push(registeredTask)\n end\n array\n end", "def interviewer_tasks\n tasks.find(:all, :conditions => { :context => 'interviewers', :show_for_context_object_tasks => true })\n end", "def get_sorted_list_of_tasks\r\n tasks = @current_user.tasks.find(:all, :conditions => {:is_finished => false, :active_task => true})\r\n unstarted_tasks = @current_user.tasks.find(:all, :conditions => {:is_finished => false, :started_at => nil}).sort_by {|t| t.created_at}\r\n finished_tasks = @current_user.tasks.find(:all, :conditions => {:is_finished => true}).sort_by {|t| t.created_at}\r\n\r\n tasks.concat(unstarted_tasks).concat(finished_tasks)\r\n return tasks\r\n end", "def client_tasks_open\n self.find_all {|e| e.completed.nil? or !e.completed }\n end", "def active_instances\n Egi::Fedcloud::Vmhound::Log.info \"[#{self.class}] Retrieving running instances\"\n fetch_instances ['ACTIVE']\n end", "def task_names\n map do |task|\n task.name\n end\n end", "def task_find(task_class)\n tasks_active.to_a.find { |t| t.is_a?(task_class) }\n end", "def pending_tasks(params = {})\n response = client.get \"/_cluster/pending_tasks\", params.merge(action: \"cluster.pending_tasks\", rest_api: \"cluster.pending_tasks\")\n response.body\n end", "def task_lists(current_token)\n session = RedboothRuby::Session.new(token: current_token)\n client = RedboothRuby::Client.new(session)\n\n client.task_list(:index, project_id: self.id).all\n end", "def cultivation_tasks\n Cultivation::Task.in(user_ids: id)\n end", "def index\n @tasks = Task.where(user_id: current_user.id)\n end", "def ongoing_project_tasks\n query = user_channel_filter(ProjectTask.where(status: 'ongoing').order(started_at: :asc))\n @count = query.count\n query = query.limit(params[:limit]) if params[:limit].present?\n @project_tasks = query\n end", "def my_task\n @my_id = current_user.id # may be redundant4 but will head towards service objects\n @tasks = Task.where(user_id: @my_id)\n end", "def active_projects\n self.projects.where(:is_canceled => false, :is_finished => false )\n end", "def index\n if params[:active_tag]\n @activeTag = params[:active_tag].to_i\n else\n @activeTag = 0\n end\n if params[:active_task]\n @task = Task.find(params[:active_task])\n end\n @tasks = current_user.tasks(@activeTag)\n @tags = current_user.tags\n end", "def find_tasks\n\t Roby::Queries::Query.new(self)\n\tend" ]
[ "0.8875768", "0.7871919", "0.7786497", "0.7763841", "0.77072775", "0.77072775", "0.77072775", "0.7630675", "0.7594248", "0.7484615", "0.7460146", "0.7398383", "0.73976403", "0.7374667", "0.736281", "0.7312423", "0.7286491", "0.7282861", "0.7204003", "0.7187266", "0.7170786", "0.71376634", "0.7129875", "0.71246916", "0.71026", "0.71026", "0.7080908", "0.7041237", "0.70218736", "0.7018426", "0.70088863", "0.69888115", "0.6935568", "0.6935568", "0.69038594", "0.6888343", "0.68655306", "0.6847453", "0.68470544", "0.6842403", "0.68367743", "0.68335813", "0.6831169", "0.6829578", "0.6809915", "0.68088984", "0.6783856", "0.6777491", "0.6745466", "0.6728144", "0.67224234", "0.66861", "0.6672622", "0.6666798", "0.6645007", "0.66340876", "0.66255546", "0.6606841", "0.66054815", "0.660355", "0.6599747", "0.6590503", "0.6589937", "0.65741426", "0.6563935", "0.6551777", "0.65441984", "0.6540593", "0.6519102", "0.64978665", "0.6490451", "0.6482842", "0.64753294", "0.6472067", "0.6464556", "0.64642864", "0.64637315", "0.64622015", "0.6461927", "0.64471453", "0.64240885", "0.6421765", "0.6419817", "0.6416803", "0.64120245", "0.6407011", "0.63826525", "0.637256", "0.6371253", "0.6370894", "0.6357255", "0.63560826", "0.6351132", "0.63381755", "0.6333291", "0.63327503", "0.6327876", "0.63261366", "0.63226753", "0.6317242" ]
0.8051246
1
get all existing databases
def all_dbs request.method = :get request.uri = '_all_dbs' Couchdbtools.execute(request) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def databases\n get '_all_dbs'\n end", "def get_all_databases\n databases = ::MySQL::Database.find_all\n names = []\n databases.each do |database|\n names << database.name\n end\n names\n end", "def databases\n CouchRest.get \"#{@uri}/_all_dbs\"\n end", "def all_dbs\n @conn.query({url_path: \"_all_dbs\", method: :get})\n end", "def databases\n arrayCommand( \"show db\", DictItemArray, RESPONSE_DATABASES_FOLLOW, RESPONSE_NO_DATABASES )\n end", "def databases\n arrayCommand( \"show db\", DictItemArray, RESPONSE_DATABASES_FOLLOW, RESPONSE_NO_DATABASES )\n end", "def databases\n database_names.map { |name| database(name) }\n end", "def databases\n JSON.parse(RestClient.get(File.join(self.uri, \"_all_dbs\"))).collect do |database_name|\n Database.new(:name => database_name)\n end\n end", "def list_databases\n response = @connection.dbreq(\"GET\", @lbmgmthost, \"#{@lbmgmtpath}/instances/#{CloudDB.escape(@id.to_s)}/databases\",@lbmgmtport,@lbmgmtscheme)\n CloudDB::Exception.raise_exception(response) unless response.code.to_s.match(/^20.$/)\n CloudDB.symbolize_keys(JSON.parse(response.body)[\"databases\"])\n end", "def list_dbs(db=nil)\n db &&= db.gsub(/[\\\\\\']/){\"\\\\#{$&}\"}\n query(db ? \"show databases like '#{db}'\" : \"show databases\").map(&:first)\n end", "def databases_list(options = {})\n if block_given?\n Pagination::Cursor.new(self, :databases_list, options).each do |page|\n yield page\n end\n else\n get('databases', options)\n end\n end", "def list_databases(filter = {}, name_only = false, opts = {})\n cmd = { listDatabases: 1 }\n cmd[:nameOnly] = !!name_only\n cmd[:filter] = filter unless filter.empty?\n cmd[:authorizedDatabases] = true if opts[:authorized_databases]\n use(Database::ADMIN).database.read_command(cmd, opts).first[Database::DATABASES]\n end", "def database_names\n database_info.keys\n end", "def database_names\n database_info.keys\n end", "def list(queries: nil, search: nil)\n path = '/databases'\n\n params = {\n queries: queries,\n search: search,\n }\n \n headers = {\n \"content-type\": 'application/json',\n }\n\n @client.call(\n method: 'GET',\n path: path,\n headers: headers,\n params: params,\n response_type: Models::DatabaseList\n )\n end", "def glue_databases(client)\n databases = []\n client.get_databases.each do |resp|\n resp.database_list.each do |db|\n databases << db.name\n end\n end\n databases\n end", "def databases\n unless defined?(@databases)\n # only use mutex on initialization\n MUTEX.synchronize do\n # return if another process initialized while we were waiting\n return @databases if defined?(@databases)\n\n @databases = config[\"databases\"].map { |id, c| [id.to_sym, Database.new(id, c)] }.to_h\n end\n end\n\n @databases\n end", "def get_available_database_ids\n get_available_databases.map{|item| item[:id]}\n end", "def database_names( con )\n # MongoHQ does not let u sniff out the connection in this case return single db if any\n if @info['db_name']\n [ @info['db_name'] ]\n else\n excludes = %w[admin local slave]\n con.database_names - excludes\n end\n end", "def dbs\n @dbs_hash.keys\n end", "def all_database_names\n @specs_store.names\n end", "def get_dbs\n if @target_config['DBS'].empty?\n if @target_config['VERSION'].scan(/./)[0].to_i < 5 and not @target_config['VERSION'].nil?\n # MySQL < 5\n print_error(\"DB Version: #{@target_config['VERSION']}\")\n print_error(\"There is no information_schema to query.....\")\n print_error(\"Unable to enumerate databases for MySQL < 5\")\n elsif @target_config['VERSION'].scan(/./)[0].to_i >= 5 or @target_config['VERSION'].nil?\n # MySQL >= 5\n results = error_basic_inject('select count(schema_name) from information_schema.schemata')\n if results.nil?\n results = error_basic_inject('select count(distinct(db)) from mysql.db')\n dbs_count = 0 unless not results.nil?\n print_error(\"Unable to get database count, flying a bit blind!\") unless not results.nil?\n dbs_count = results unless results.nil?\n print_status(\"Requesting #{dbs_count} Databases Names....\") unless results.nil?\n else\n dbs_count = results\n print_status(\"Requesting #{dbs_count} Databases Names....\")\n end\n dbz=[]\n count = 0\n while not results.nil?\n results = error_basic_inject(\"select schema_name from information_schema.schemata limit #{count},1\")\n pad = ' ' * (results.size + 25) unless results.nil? or results == ''\n pad = ' ' * 50 if results.nil? or results == ''\n print \"\\r(#{count})> #{results}#{pad}\".cyan unless results == ''\n dbz << results unless results == ''\n count = count.to_i + 1\n end\n print_line(\"\")\n if dbz.empty?\n print_line(\"\")\n print_error(\"Unable to get any database names!\")\n print_error(\"Lack of privileges?\")\n print_status(\"Possible Solutions include:\")\n print_caution(\"A) Become HR's best friend by updating the code and sending him a copy\")\n print_caution(\"B) Tweak Settings and try things again\")\n print_caution(\"C) Be a bawz and do it manually\")\n print_line(\"\")\n else\t\n @target_config['DBS'] = dbz\n print_good(\"DBS: #{dbz.join(', ').sub(/, $/, '')}\")\n end\n end\n else\n print_good(\"DBS: #{@target_config['DBS'].join(', ').sub(/,$/, '')}\")\n end\n end", "def database_names\n connection.database_names.reject { |name| name == \"admin\" }\n end", "def list_mongo_databases(filter = {}, opts = {})\n database_names(filter, opts).collect do |name|\n Database.new(self, name, options)\n end\n end", "def get_available_databases # :nodoc:\n search({query: 'supercalifragilisticexpialidocious-supercalifragilisticexpialidocious',\n results_per_page: 1,\n mode: 'all',\n include_facets: false}).database_stats\n end", "def scan_databases_dir\n database_dir = config[:database_dir]\n list = %x|blastdbcmd -recursive -list #{database_dir} -list_outfmt \"%f\t%t\t%p\t%n\t%l\t%d\" 2>&1|\n list.each_line do |line|\n name = line.split('\t')[0]\n next if multipart_database_name?(name)\n self << Database.new(*line.split('\t'))\n end\n end", "def getDefaultDatabases\n if !$remoteDatabasesLoaded\n info \"Loading remote databases...\"\n\n $remoteDatabases = []\n\n failures = false\n\n if !loadDatabase \"boostslair\",\n \"https://boostslair.com/rubysetupsystem/database.json\",\n File.expand_path('rubysetupsystem.cert', __dir__)\n failures = true\n end\n\n if failures\n warning \"One or more databases failed to download.\"\n warning \"Precompiled and other features may be unavailable.\"\n end\n\n $remoteDatabasesLoaded = true\n info \"#{$remoteDatabases.length} remote databases loaded\"\n end\n\n $remoteDatabases\nend", "def try_databases\n db = Database.new(application_root, config, settings)\n db.configure\n end", "def get_dbs\n if @target_config['VERSION'].scan(/./)[0].to_i < 5 and not @target_config['VERSION'].nil?\n # MySQL < 5\n print_error(\"DB Version: #{@target_config['VERSION']}\")\n print_error(\"There is no information_schema to query.....\")\n print_error(\"Unable to enumerate databases for MySQL < 5\")\n elsif @target_config['VERSION'].scan(/./)[0].to_i >= 5 or @target_config['VERSION'].nil?\n # MySQL v5+\n results = union_basic_inject($config['INJECTOR']['MYSQL']['UNION']['VULN_COLUMN'].to_i, 'select count(schema_name) from information_schema.schemata')\n if results.nil?\n results = union_basic_inject($config['INJECTOR']['MYSQL']['UNION']['VULN_COLUMN'].to_i, 'select count(distinct(db)) from mysql.db') #This usually needs privs, but maybe in some case if info schema is blocked\n dbs_count=0 unless not results.nil?\n print_error(\"Unable to get database count, flying a bit blind!\") unless not results.nil?\n dbs_count=results unless results.nil?\n print_status(\"Requesting #{dbs_count} Databases Names....\") unless results.nil?\n else\n dbs_count=results\n print_status(\"Requesting #{dbs_count} Databases Names....\")\n end\n dbz=[]\n count=0\n while not results.nil?\n results = union_basic_inject($config['INJECTOR']['MYSQL']['UNION']['VULN_COLUMN'].to_i, \"select schema_name from information_schema.schemata limit #{count},1\")\n pad = ' ' * (results.size + 10) unless results == '' or results.nil?\n pad = ' ' * 50 if results.nil?\n print \"\\r(#{count})> #{results}#{pad}\".cyan unless results == ''\n dbz << results unless results == ''\n count = count.to_i + 1\n end\n print_line(\"\")\n if dbz.empty?\n print_line(\"\")\n print_error(\"Unable to get any database names!\")\n print_error(\"Lack of privileges?\")\n print_status(\"Possible Solutions include:\")\n print_caution(\"A) Become HR's best friend by updating the code and sending him a copy\")\n print_caution(\"B) Tweak Settings and try things again\")\n print_caution(\"C) Be a bawz and do it manually\")\n print_line(\"\")\n else\t\n @target_config['DBS'] += dbz\n @target_config['DBS'].uniq! unless @target_config['DBS'].nil? or @target_config['DBS'].size == 0\n print_good(\"DBS: #{dbz.join(', ').sub(/, $/, '')}\") unless dbz.nil? or dbz.size == 0\n print_good(\"DBS: #{@target_config['DBS'].join(', ').sub(/, $/, '')}\") if dbz.nil? or dbz.size == 0 and not @target_config['DBS'].nil?\n end\n end\n end", "def get_all_tables\n query = @db_connection.query('SHOW DATABASES;')\n @db_connection.close if @db_connection\n query.each do |x|\n begin\n db_connection = Mysql.connect(@host, @user, @pass, x[0], @port.to_i)\n print_good(\"Tables for #{x[0]}\")\n query = db_connection.query('SHOW TABLES;')\n query.each { |y| print_line(\"#{y[0]}\") }\n puts\n db_connection.close if db_connection\n rescue Mysql::Error => e\n print_error(\"Problem getting tables from #{x[0]}!\")\n print_error(\"#{e}\")\n end\n end\n @db_connection = Mysql.connect(@host, @user, @pass, @db, @port.to_i)\n end", "def database_names(filter = {}, opts = {})\n list_databases(filter, true, opts).collect{ |info| info['name'] }\n end", "def all_schemas\n query('SELECT schema_name FROM information_schema.schemata').flatten\n end", "def cloud_databases\n content[\"servers\"].map do |server, settings|\n settings[\"databases\"]\n end.flatten.uniq\n end", "def checkpoints\n db_pattern = \"#{sql_connection.escape(@db_backup)}\".gsub(\"_\", \"\\\\_\").gsub(\"%\", \"\\\\%\")\n # TODO: this should be quoted properly.\n result = sql_connection.execute(\"SHOW DATABASES LIKE '#{db_pattern}\\\\_%'\")\n prefix_length = @db_backup.length+1\n sql_connection.normalize_result(result).map {|db| db[prefix_length..-1] }\n end", "def backup_databases\n cloud_databases - ['redis']\n end", "def get_local_customer_databases(options)\n conn = PG.connect(options)\n all_customer_databases = []\n conn.exec(@@db_suite_query).each { |row|\n database = {}\n database[:server_name] = row['server_name']\n database[:db_name] = row['db_name']\n\n all_customer_databases.push(database)\n }\n conn.close\n\n local_customer_databases = all_customer_databases.select { |database|\n is_local_server?(database[:server_name])\n }\n local_customer_databases\n end", "def index\n @databases = Database.all.order(:name)\n end", "def referencing_databases\n ensure_service!\n\n @grpc.referencing_databases.map do |referencing_database|\n segments = referencing_database.split \"/\"\n database_grpc = service.get_database segments[3], segments[5]\n Database.from_grpc database_grpc, service\n end\n end", "def printGetSupportedDBs()\n printDebugMessage('printGetSupportedDBs', 'Begin', 1)\n dbInfoList = getDatabaseInfoList()\n dbInfoList.each{ |dbInfo|\n puts dbInfo.elements['name'].text\n }\n printDebugMessage('printGetSupportedDBs', 'End', 1)\n end", "def getDatabaseInfoList()\n printDebugMessage('getDatabaseInfoList', 'Begin', 11)\n if @dbInfoList == nil\n @dbInfoList = restGetMetaInformation()\n end\n printDebugMessage('getDatabaseInfoList', 'End', 11)\n return @dbInfoList\n end", "def dump_all_databases(num)\n timez = t.strftime(\"%m.%d.%Y\")\n logs = RESULTS + @host\n logdir = logs + '/dumps/'\n Dir.mkdir(logs) unless File.exists?(logs)\n Dir.mkdir(logdir) unless File.exists?(logdir)\n print_status(\"Attempting to dump ALL available databases....\")\n query = @db_connection.query('SHOW DATABASES;')\n query.each do |x|\n # Skip default databases to avoid issues with mysqldump --all-databases in newer clients\n # While longer this helps ensure cleaner DB Dump files as well\n # MYSQLDUMP Error: Couldn't read status information for table general_log (...)\n if not x[0] =~ /^mysql$|^information_schema$|^test$|^database$/i\n print_status(\"Dumping '#{x[0]}'....\")\n if num.to_i == 1\n system(\"`which mysqldump` --host=#{@host} --user=#{@user} --password=#{@pass} #{x[0]} --add-locks --create-options --disable-keys --extended-insert --lock-tables --quick -C --dump-date | gzip -c > #{logdir}#{x[0]}_#{timez}.sql.gz\")\n else\n system(\"`which mysqldump` --host=#{@host} --user=#{@user} --password=#{@pass} #{x[0]} --add-locks --create-options --disable-keys --extended-insert --lock-tables --quick -C --dump-date > #{logdir}#{x[0]}_#{timez}.sql\")\n end\n else\n print_caution(\"Skipping default database '#{x[0]}'...\")\n end\n end\n print_status(\"Database Dumping Completed!\")\n print_status(\"Dump file(s) saved to: #{logdir}\")\n system(\"ls -lua #{logdir} | grep --color -E '.sql.gz|.sql'\")\n end", "def database_info(*names)\n names = names.map(&:to_s)\n info = native.list_databases\n info = info.select { |e| names.include?(e[:name]) } unless names.empty?\n names.size == 1 ? info.first : info\n end", "def database_info\n doc = self['admin'].command(:listDatabases => 1)\n returning({}) do |info|\n doc['databases'].each { |db| info[db['name']] = db['sizeOnDisk'].to_i }\n end\n end", "def determine_databases\n db = @info[:db] = {}\n mysql_count_cmd = 'find /var/lib/mysql* -maxdepth 0 -type d ' \\\n '2>/dev/null|wc -l'\n db[:count] = @shell.query('DB_MYSQL_COUNT', mysql_count_cmd)\n db[:count] = db[:count].to_i\n\n mysql_size_cmd = \"du -s /var/lib/mysql 2>/dev/null|awk '{print $1}'\"\n db[:size] = @shell.query('DB_MYSQL_SIZE', mysql_size_cmd)\n db[:size] = db[:size].to_i\n end", "def database_info\n doc = single_db_command('admin', :listDatabases => 1)\n h = {}\n doc['databases'].each { |db|\n h[db['name']] = db['sizeOnDisk'].to_i\n }\n h\n end", "def db_info\n @conn.query({url_path: \"#{database}\", method: :get})\n end", "def index\n @databases = Database.where(:user => @user[\"uid\"])\n end", "def get_db\n manif = Project.miga_online_manif\n @downloadable = manif[:databases].map do |name, i|\n local = Project.find_by(path: name)\n local_v = (local.miga.metadata[:release] || 'unknown') if local && local.miga\n latest = i[:versions][i[:latest].to_sym]\n file = File.join(Settings.miga_projects, latest[:path])\n downloading = File.size(file) * 100 / latest[:size] if File.exist?(file)\n i.merge(name: name, local: local_v, downloading: downloading)\n end\n end", "def tables\n db_connection.select_values(\"show tables\")\n end", "def indexed_database_names\n index_specifications.map do |spec|\n spec.options[:database] || database_name\n end.uniq\n end", "def get_database(name)\n response = @glue_client.get_database(name: name)\n response.database\nrescue Aws::Glue::Errors::GlueException => e\n @logger.error(\"Glue could not get database #{name}: \\n#{e.message}\")\n raise\n end", "def index\n @dbconnections = Dbconnection.all\n end", "def database(args={})\n args[:connection_name] = @connection_name unless args.has_key?(:connection_name)\n req(:required => [:db_name],\n :args_object => args)\n data = {}\n dbh = Mysqladmin::Exec.new(:connection_name => args[:connection_name])\n dbh.use(args[:db_name])\n dbh.list_tables.each do |table_name|\n data[table_name] = table(:table_name => args[:table_name], :db_name => args[:db_name], :connection_name => args[:connection_name])\n end\n return data\n end", "def info\n specified_db_or_all { |db| display_db_info db }\n end", "def get_all()\n return JSON.parse(File.read(@database_file))\n \n # error handling\n rescue Errno::ENOENT\n File.open(@database_file, 'w+')\n File.write(@database_file, [])\n retry\n end", "def index\n if is_admin?\n @databases = Database.all :include => :user\n else\n @databases = current_user.databases.all\n end\n \n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @databases }\n end\n end", "def get_database(db_name)\n Monga::Database.new(@client, db_name)\n end", "def database(options = {})\n throw ArgumentError.new('Required arguments :database_id missing') if options[:database_id].nil?\n get(\"databases/#{options[:database_id]}\")\n end", "def index\n @users_dbs = UsersDb.all\n end", "def get_database\n\t\tdb = Mysql2::Client(:host => 'localhost',:user => 'root',:password => 'abcd0311')\n\n\t\tbegin\n\t\t\tdb.query(\"DROP DATABASE #{@month}_#{@year}_clients\")\n\t\t\tdb.query(\"CREATE DATABASE #{@month}_#{@year}_clients\")\n\t\trescue Exception => e\n\t\t\tdb.query(\"CREATE DATABASE #{@month}_#{@year}_clients\")\n\t\tend\n\n\t\tdb.query(\"USE #{@month}_#{@year}_clients\")\n\t\tdb.query(\"CREATE TABLE users(cID integer, name varchar(50), address varchar(50), prov varchar(50), postal varchar(50), email varchar(50), cost float);\")\n\t\tdb\n\tend", "def sqlite3_all_tables\n return @dbh.execute(\"select * from sqlite_master where type='table';\")\n end", "def info\n specified_db_or_all { |db| display_db_info db }\n end", "def create_default_databases()\n # Create subfolder for databases if needed.\n dir = \"./databases\"\n Dir.mkdir(dir) unless Dir.exist?(dir)\n # TODO: sanity check: if db-file exist, create copy first, make sure the\n # name of the copy makes it highly unlikely to match an already existing\n # file, e.g. current epoch.\n # TODO: Create DBs\nend", "def get_tables_db(db_name)\n if @target_config['VERSION'].scan(/./)[0].to_i >= 5\n # MySQL >= 5\n if not @target_config['DB_TABLES'].keys.include?(db_name)\n query = \"select count(table_name) from information_schema.tables where table_schema=#{db_name.mysqlhex}\"\n results = union_basic_inject($config['INJECTOR']['MYSQL']['UNION']['VULN_COLUMN'].to_i, query)\n if results.nil?\n print_error(\"Unable to determine number of tables in current database....\")\n else\n print_good(\"Fetching #{results} Tables from Current DB\")\n end\n count=0\n tables=[]\n while not results.nil?\n results = union_basic_inject($config['INJECTOR']['MYSQL']['UNION']['VULN_COLUMN'].to_i, \"select table_name from information_schema.tables where table_schema=#{db_name.mysqlhex} limit #{count},1\")\n pad = ' ' * (results.size + 25) unless results == '' or results.nil?\n pad = ' ' * 50 if results.nil?\n print \"\\r(#{count})> #{results}#{pad}\".cyan unless results == ''\n tables << results unless results == ''\n count = count.to_i + 1\n end\n print_line(\"\")\n if tables.empty?\n print_error(\"Unable to get any tables from the current database!\")\n print_error(\"Lack of privileges? IDK....\")\n print_status(\"Possible Solutions include:\")\n print_caution(\"A) Become HR's best friend by updating the code and sending him a copy\")\n print_caution(\"B) Tweak Settings and try things again\")\n print_caution(\"C) Be a bawz and do it manually\")\n print_line(\"\")\n return nil\n else\t\n @target_config['DB_TABLES'][\"#{db_name}\"] = tables\n print_good(\"DB: #{db_name}\")\n print_good(\"Tables: #{tables.join(', ').sub(/, $/, '')}\")\n return tables.join(' ')\n end\n else\n db = db_name\n tables = @target_config['DB_TABLES'][\"#{db_name}\"].join(', ').sub(/, $/, '')\n print_good(\"DB: #{db}\")\n print_good(\"Tables: #{tables}\")\n end\n else\n # MySQL < 5\n print_error(\"MySQL < 5: #{@target_config['VERSION']}\")\n print_error(\"There is no information_schema to query for tables as result.....\")\n if not @target_config['CURRENT_DB'].nil?\n print_error(\"Do you want to try Common Table Names (Y/N)?\")\n answer=gets.chomp\n print_line(\"\")\n if answer.upcase == 'Y' or answer.upcase == 'YES'\n tables = common_tables('CURRENT-DB', \"#{HOME}fuzz/common_tables.lst\")\n if tables.empty?\n print_error(\"OK, returning to menu...\")\n return nil\n else\n print_good(\"DB: #{db_name}\")\n print_good(\"Tables: #{tables.join(', ').sub(/, $/, '')}\")\n @target_config['DB_TABLES'][\"#{db_name}\"] = tables\n return tables.join(' ')\n end\n else\n print_error(\"OK, returning to menu...\")\n return nil\n end\n else\n print_error(\"OK, returning to menu...\")\n return nil\n end\n end\n end", "def get_table_names\n raise \"No database file selected.\" unless $current_db\n\n $tables = get_data \"select name from sqlite_master\"\n $tables.collect!{|x| x[0] } ## 1.9 hack, but will it run on 1.8 ??\n $tables\nend", "def soapGetSupportedDBs()\n printDebugMessage('soapGetSupportedDBs', 'Begin', 1)\n soapConnect\n res = @soap.getSupportedDBs({})\n if(2 <= @debugLevel)\n p res\n end\n printDebugMessage('soapGetSupportedDBs', 'End', 1)\n return res['getSupportedDBsReturn']\n end", "def schemas\n sql = \"SELECT nspname FROM pg_namespace WHERE nspname !~ '^pg_.*'\"\n ActiveRecord::Base.connection.query(sql).flatten\n end", "def clear_all_databases\n excluded_tables = [\"schema_migrations\", \"common_states\", \"common_activities\"]\n connection = ActiveRecord::Base.connection\n table_names = connection.tables.dup\n table_names.delete_if { |table_name| excluded_tables.include?(table_name) }\n \n table_names.each do |table_name|\n sql_command = \"DELETE FROM #{table_name};\"\n connection.execute sql_command\n end\nend", "def index\n \n @databases = Database.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json=> @databases }\n end\n end", "def db_instances(region)\n logger.info(\"fetching db instances of region #{region}\")\n rds_client = get_rds_client(region)\n next_token = nil\n rds_instances = []\n\n loop do\n options = { marker: next_token }\n resp = rds_client.describe_db_instances(options)\n rds_instances += resp.db_instances\n next_token = resp.marker\n break unless next_token\n end\n rds_instances\n end", "def master_db; machine_by_role('master_db'); end", "def establish_db_connection()\n @host = '127.0.0.1'\n @username = ''\n @password = ''\n\n my = Mysql.connect(@host, @username, @password)\n res = my.query('SHOW DATABASES;')\n puts res # need to be converted to string \n puts \"Tables_in_valutation\"\n res.each {|x| p x.to_s}\n res.free\nend", "def find_tables\n sql = <<-eos\n SELECT table_name\n FROM information_schema.tables\n WHERE table_type = 'BASE TABLE'\n AND table_schema = 'public'\n eos\n @tables = @connection.exec(sql).values.flatten\n end", "def get_all_data\n init_data\n\n Bot::DB[my_name]\n end", "def get_all_data\n init_data\n\n Bot::DB[my_name]\n end", "def tables_from(db=current_database)\n end", "def find_db\n db = nil\n if !database.nil?\n db = rds.db_instances[database]\n elsif !environment.nil?\n db = find_db_by_environment(environment)\n end\n db\n end", "def make_mysql_backup\n if @all_databases\n options = {\n :name => \"--all-databases\",\n :dump_options => \"\",\n :append_name => \"\"\n }\n file_name = mysqldump(options)\n compress_file(file_name)\n end\n if @databases && !@databases.empty?\n @databases.each do |db|\n options = {\n :name => db[:name].to_s,\n :dump_options => db[:dump_options].to_s,\n :append_name => db[:append_name].to_s\n }\n file_name = mysqldump(options)\n compress_file(file_name)\n end\n end\nend", "def db_listing\n lista = [] \n achado = $db.query \"SELECT * FROM produtos\" \n achado.each do |vals| \n lista.push vals\n end\n return lista\nend", "def each\n # First yield the results databases.\n yield 'results', @results_database unless @results_database.nil?\n # Then all other databases.\n @databases.each_key do |key|\n db = get_database(key)\n yield key, db unless db.nil?\n end\n end", "def tables\n execute('select table_name from information_schema.tables where table_schema = ?', [schema]).map(&:first)\n end", "def database\n database_name ? connection.db(database_name) : nil\n end", "def dbs_init\n @dbs_hash = Dir[\"#{dbs_store}/*.db\"]\n .map do |dbfile|\n File.open(dbfile){|f| JSON.parse(f.read, symbolize_names: true)}\n end\n .inject({}) do |h, db|\n h.update({\n db[:name].to_sym => LaPack::const_get(db[:clazz]).new(self, db[:params])\n })\n end\n end", "def get_tables(db)\n if db == @db\n query = @db_connection.query('SHOW TABLES;')\n query.each { |x| puts \"#{x[0]}\".white }\n else\n @db_connection.close if @db_connection\n begin\n db_connection = Mysql.connect(@host, @user, @pass, db, @port.to_i)\n query = db_connection.query('SHOW TABLES;')\n query.each { |x| puts \"#{x[0]}\".white }\n db_connection.close if db_connection\n rescue Mysql::Error => e\n print_error(\"Problem getting tables from #{db}!\")\n print_error(\"#{e}\")\n end\n @db_connection = Mysql.connect(@host, @user, @pass, @db, @port.to_i)\n end\n end", "def select_db(name)\n #This is a stub, used for indexing\n end", "def database! name\n create_db(name) rescue nil\n database name\n end", "def current_database #:nodoc:\n select_one(\"select sys_context('userenv','db_name') db from dual\")[\"db\"]\n end", "def index\n @databases = Database.all\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @databases }\n end\n end", "def list (database: Arango.current_database)\n result = Arango::Requests::Graph::ListAll.execute(server: database.server)\n result.graphs.map { |c| c[:name] }\n end", "def database\n \"--db='#{ name }'\" if name\n end", "def load_database(app_name, instance_name)\n app_config = RailsPwnerer::Config[app_name, instance_name]\n db_name, db_user, db_pass = app_config[:db_name], app_config[:db_user], app_config[:db_pass]\n \n Dir.chdir app_config[:backup_path] do\n # find the latest dump and load it in\n dump_file = Dir.glob(\"db/#{app_name}.#{instance_name}_*\").max\n unless dump_file\n dump_file = Dir.glob(\"db/#{app_name}.*\").max\n end\n Kernel.system \"mysql -u#{db_user} -p#{db_pass} #{db_name} < #{dump_file}\"\n end\n end", "def db\n @db ||= find_or_create_database\n end", "def db_exist?(db_name)\n list_schemas.include?(db_name)\n end", "def printGetSupportedDBs()\n printDebugMessage('printGetSupportedDBs', 'Begin', 1)\n paramsList = soapGetSupportedDBs()\n paramsList.each { |param|\n puts param\n }\n printDebugMessage('printGetSupportedDBs', 'End', 1)\n end", "def database\n @@db\n end", "def database\n @database\n end", "def database\n @database\n end", "def database\n @database ||= determine_database\n end", "def sqlite3_list_tables\n tables = @dbm.sqlite3_all_tables\n if !tables.empty?\n tables.each {|table|\n printf \"#{table[1]} | #{table[4]}\\n\"\n }\n else\n printf \"Database [#{@db_name}] is empty.\\n\" \n end\n end", "def get_all_from_database\n model.all\n end" ]
[ "0.8775021", "0.8339587", "0.8323108", "0.82303756", "0.8091986", "0.8091986", "0.80724907", "0.7886002", "0.76090693", "0.75427943", "0.74113053", "0.73977333", "0.73393494", "0.72764397", "0.7210918", "0.72076946", "0.7204332", "0.7193086", "0.7161016", "0.71276724", "0.7106156", "0.71037054", "0.70944536", "0.7091019", "0.706439", "0.70241326", "0.7019908", "0.70166093", "0.69698936", "0.69185394", "0.68841857", "0.6799943", "0.6698296", "0.66035044", "0.65906644", "0.65833616", "0.64788693", "0.64746034", "0.64723706", "0.6464898", "0.64311236", "0.6427923", "0.63612753", "0.6352938", "0.6295932", "0.6290784", "0.6257808", "0.62487674", "0.61626005", "0.6061487", "0.6042175", "0.60336626", "0.5993336", "0.5981719", "0.5939186", "0.5909094", "0.5908215", "0.5887078", "0.58724374", "0.58619237", "0.5838955", "0.5799527", "0.57975084", "0.5781503", "0.5776731", "0.57533276", "0.5749118", "0.57426083", "0.5727234", "0.5725186", "0.5712627", "0.57071066", "0.5696419", "0.5693179", "0.5693179", "0.5692147", "0.568913", "0.56787187", "0.56747055", "0.5673128", "0.5661747", "0.56611776", "0.56445414", "0.56403524", "0.5618156", "0.5617887", "0.5614814", "0.560257", "0.55994415", "0.55945265", "0.55848396", "0.5583793", "0.55799794", "0.5579019", "0.5577014", "0.5576738", "0.5576738", "0.5570098", "0.55523986", "0.5551056" ]
0.79987794
7
get the database events
def db_updates(params_hash = {}) begin raise_error_unless_params_is_a_hash(params_hash) request.method = :get request.uri = "_db_updates#{querystring(params_hash)}" Couchdbtools.execute(request) rescue Exception => exception exception.message end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def events(dbname, &block)\n # can't use RestClient.get b/c of :block_response\n RestClient::Request.execute(:method => :get,\n :url => root_url('events', @storage, dbname),\n :headers => {:accept => \"text/event-stream\"},\n :block_response => block, &HANDLE_RESPONSE)\n end", "def events\n event_lookup()\n end", "def events\n event_lookup()\n end", "def events\n collection(\"events\")\n end", "def events\n data.events\n end", "def events\n events = {}\n @db.each do |key, _|\n timestamp, object = parse_event(key)\n events[object] ||= []\n events[object].push(timestamp)\n end\n events\n end", "def events\n return @events\n end", "def events\n @@events\n end", "def events\n @events ||= []\n @events\n end", "def events\n data[\"events\"]\n end", "def events\n self.class.events\n end", "def get_events\n Resources::Event.parse(request(:get, \"Events\"))\n end", "def get_events()\n @client.make_request(:get, @client.concat_user_path(\"#{CALL_PATH}/#{id}/events\"))[0]\n end", "def events\n @events ||= {}\n end", "def event_list\n @_events\n end", "def events\n @finity.events.map { |name, _| name }\n end", "def read_event\n self.class.select(\"READ_EVENT(#{self.id})\").all\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 events\n event_enum\n end", "def events\n event_enum\n end", "def fetch_all_events(params={}, save_to_db=true)\n params = setup_params(params)\n self.model_class = ::Mixpanel::Event\n \n event_names = []\n if params[:event]\n if params[:event].is_a?(Array)\n event_names += params[:event]\n else\n event_names << params[:event]\n end\n else\n # Get names of events.\n event_names = self.fetch_event_names(params, false)\n end\n \n # Get events data.\n method_url = get_method_url('events')\n \n request_params = self.select_params(params, [:type, :unit, :interval, :format, :bucket])\n request_params[:resource] = method_url\n request_params[:event] = event_names.to_json\n puts \">>>>>>>>>>>>>>>>> #{request_params.inspect}\" \n event_data = send_request(request_params)\n puts \">>>>>>>>>>>>>>>>> #{event_data}\"\n # Detect event data is empty or not\n is_empty = (event_data.blank? || event_data[RESPONSE_KEYS[:legend_size]].to_i <= 0)\n if save_to_db && !is_empty\n self.model_class.transaction do \n # Get all target ids existing in DB, in order to detect data was changed or not.\n target_ids = get_target_ids(params)\n \n # Sample data:\n # {'data': {'series': ['2010-05-29',\n # '2010-05-30',\n # '2010-05-31',\n # ],\n # 'values': {'account-page': {'2010-05-30': 1,},\n # 'splash features': {'2010-05-29': 6,\n # '2010-05-30': 4,\n # '2010-05-31': 5,\n # }\n # }\n # },\n # 'legend_size': 2}\n\n # Goal: Store each event in a single record in DB. \n series_data = event_data['data']['series']\n values_data = event_data['data']['values']\n event_names.each do |event_name|\n event_values = values_data[event_name]\n next if event_values.blank?\n \n # Get only series related to the event.\n event_series = event_values.keys & series_data\n\n # Keep the original format of the event data (based on Mixpanel API spec).\n origin_data = {\n :data => {\n :series => event_series, \n :values => {event_name => event_values}\n },\n :legend_size => 1\n }\n \n # Format hash to JSON.\n json_data = origin_data.to_json\n \n self.insert_or_update(params, target_ids, \n event_name, json_data)\n end\n end\n end\n return event_data\n end", "def event_list\n events_list\n end", "def events\n end", "def all_events\n @events = Event.all\n end", "def events\n\t\t\t\treturn @events.values unless (@events.nil?)\n\t\t\t\treturn nil\n\t\t\tend", "def get_events()\n\t\tevents = []\n\n\t\t@DB[:events].order(:date).each do |event|\n\t\t\tnewTimeslots = []\n\t\t\t@DB[:timeslots].where(parent_table: 'events', parent_id: event[:'id']).each do |timeslot|\n\t\t\t\tnewTimeslots.push(DateTime.parse(timeslot[:'time']))\n\t\t\tend\n\n\t\t\tnewAttendees = []\n\t\t\t@DB[:attendees].where(parent_id: event[:'id']).each do |attendee|\n\t\t\t\tattendeeTimeslots = []\n\t\t\t\t@DB[:timeslots].where(parent_table: 'attendees', parent_id: attendee[:'id']).each do |timeslot|\n\t\t\t\t\tattendeeTimeslots.push(DateTime.parse(timeslot[:'time']))\n\t\t\t\tend\n\n\t\t\t\tnewAttendee = Attendee.new(attendee[:'name'], attendeeTimeslots)\n\t\t\t\tnewAttendees.push(newAttendee)\n\t\t\tend\n\n\t\t\tnewEvent = Event.new(event[:'name'], event[:'description'], newTimeslots, newAttendees, event[:'id'])\n\t\t\tif newEvent.get_date >= @epoch\n\t\t\t\tevents.push(newEvent)\n\t\t\tend\n\t\tend\n\n\t\treturn events\n\tend", "def events\n Vedeu::Events.registered\n end", "def events\n object.events.last(10)\n end", "def events\n @events = registered_application.events.group_by(&:name)\n end", "def events\n response = self.class.get('/v1/events.json')\n response.code == 200 ? JSON.parse(response.body) : nil\n end", "def info\n if @info.nil?\n filter = \"id = '#{@id}'\"\n @info = $database.all_with_filter(\"events\", filter)[0].to_h\n else\n @info\n end\n end", "def events\n @events ||= event_finder\n end", "def events\n @events ||= Array(context[:events]).reverse.map { |event| Concierge::SafeAccessHash.new(event) }\n end", "def fetch\n @start_time ||= (Time.current - 1.minute).to_i * 1000\n $mw_log.debug \"Catching Events since [#{@start_time}]\"\n\n new_events = @alerts_client.list_events(\"startTime\" => @start_time, \"tags\" => \"miq.event_type|*\", \"thin\" => true)\n @start_time = new_events.max_by(&:ctime).ctime + 1 unless new_events.empty? # add 1 ms to avoid dups with GTE filter\n new_events\n rescue => err\n $mw_log.info \"Error capturing events #{err}\"\n []\n end", "def events\n RoyalEvent::Event.where(\n \"id IN (#{subquery.to_sql})\"\n ).order(default_order)\n end", "def events\n requires :label, :application_name\n service.events.all({\n 'ApplicationName' => application_name,\n 'VersionLabel' => label\n })\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; end", "def events; end", "def events; end", "def events; end", "def events; end", "def events; end", "def events; end", "def events; end", "def list_events\n result = ''\n $events.find.each do |doc|\n result << doc['location'] + ' at ' + doc['time'] + \"\\n\"\n end\n if result.empty?\n 'The database is currently empty.'\n else\n result\n end\nend", "def events\n Enumerator.new(self,:each_event).to_a\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 index\n @events = Event.last_events(current_user, 3)\n end", "def available_events\n\t\treturn current_room.events || []\n\tend", "def events(params={})\n return Proxy.new(connection, \"./events\",params)\n end", "def events\r\n\tif session[\"fb_access_token\"].present?\r\n\t\t@graph = Koala::Facebook::API.new(session[\"fb_access_token\"])\r\n\t\t@string = @graph.get_connections(\"me\", \"events\")\r\n\t\t#@events.class\r\n\t\t#@events.first\r\n\tend\r\nend", "def get_events(trace: false, &block)\n r = dropbox_query(query: '2/team_log/get_events', trace: trace)\n r['events'].each(&block)\n while r['has_more']\n r = dropbox_query(query: '2/team_log/get_events/continue', query_data: \"{\\\"cursor\\\":\\\"#{r['cursor']}\\\"}\", trace: trace)\n r['events'].each(&block)\n end\n end", "def all_events\n events.keys\n end", "def events\n @execution.events if @execution\n end", "def fetch_event_names(params={}, save_to_db=true)\n params = setup_params(params)\n \n # Mixpanel does not support tracking events' names were changed.\n params[:update] = false\n \n self.model_class = ::Mixpanel::Event\n \n method_url = get_method_url('events', 'names')\n request_params = self.select_params(params, [:type, :unit, :interval, \n :limit, :bucket])\n request_params[:resource] = method_url\n \n data = send_request(request_params)\n \n if save_to_db && !data.blank?\n self.model_class.transaction do\n target_ids = get_target_ids(params)\n \n data.each do |name|\n self.insert_or_update(params, target_ids, \n name, name)\n end\n end\n end\n return data\n end", "def events\n @events ||= RubyEvents::Events.new(self)\n end", "def events\n event.user.events.where(:timestamp => beginning...ending)\n end", "def index\n\t\t@events = Event.all\n\tend", "def index\n\t\t@events = Event.all\n\tend", "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 owned_events\n events\n end", "def events\n lfm_path = \"artist.getevents&artist=#{@name}\"\n lfm_data = LastFm::fetch_data(lfm_path)\n return Event.create_from_hash(Hash.from_xml(lfm_data)['lfm']['events']['event']) \n end", "def events( params={} )\n events = get_connections(\"events\", params)\n return map_connections events, :to => Facebook::Graph::Event\n end", "def events(service, url, args)\n events = []\n ret = service.send_request(GData4Ruby::Request.new(:get, url, nil, nil, args))\n REXML::Document.new(ret.body).root.elements.each(\"entry\"){}.map do |entry|\n entry = GData4Ruby::Utils.add_namespaces(entry)\n e = GCal4Ruby::Event.new(service)\n if e.load(entry.to_s)\n events << e\n end\n end\n return events\nend", "def events\n metadata['events'].sort_by! { |event| event['timestamp'] }\n end", "def get_file_events(gf_pid, obj_identifier)\n query = \"select intellectual_object_id, institution_id, \" +\n \"identifier, event_type, date_time, detail, \" +\n \"outcome, outcome_detail, outcome_information, \" +\n \"object, agent, generic_file_id, generic_file_identifier \" +\n \"from premis_events_solr where generic_file_id = ?\"\n if @file_events_query.nil?\n @file_events_query = @db.prepare(query)\n end\n result_set = @file_events_query.execute(gf_pid)\n events = []\n result_set.each_hash do |row|\n events.push(get_event(row, obj_identifier))\n end\n events\n end", "def events(options = {})\n GeoCerts::Event.find_by_order_id(self.id, options)\n end", "def events\r\n load_private_events\r\n load_completed_private_events\r\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 get_events(queue_id, last_event_id=nil)\n connection.params = build_get_event_params(queue_id, last_event_id)\n event_response.fetch(\"events\")\n end", "def get_events(args)\n\tapi_url = \"#{@base_url}/#{args[:collection]}/#{args[:key]}/events/#{args[:event_type]}\"\n\tdo_the_get_call( url: api_url, user: @user )\nend", "def default_events()\n return @events\n end", "def listOfEvents\r\n puts (@BetESS.fDisplayEvents)\r\n end", "def all\n gen_feed Event.find(:all, :limit => @@limit, :order => 'id DESC'), 'All Events';\n end", "def registered_events\n return repository.find(name) if repository.registered?(name)\n\n Vedeu::Events::Aliases.find(name).map do |event_name|\n Vedeu::Events::Trigger.trigger(event_name, *args)\n end\n\n []\n end", "def registered_events\n return repository.find(name) if repository.registered?(name)\n\n Vedeu::Events::Aliases.find(name).map do |event_name|\n Vedeu::Events::Trigger.trigger(event_name, *args)\n end\n\n []\n end", "def index\n @events = Event.find(:all) \n end", "def index\n @events = Event.all()\n end", "def found_events\n @mood.events\n end", "def events\n @_events ||= self.class.events.dup\n end", "def find_events(query)\n event_lookup(\"?q=#{query}\")\n end", "def find_events(query)\n event_lookup(\"?q=#{query}\")\n end", "def events\n collection = Miasma::Models::Orchestration::Stack::Events.new(self)\n collection.define_singleton_method(:perform_population) { [] }\n collection\n end", "def events\n results = @cal_service.list_events(\n @calendar_id,\n order_by: 'startTime',\n q: 'LIVE',\n single_events: true,\n time_max: (DateTime.now + 7).to_s,\n time_min: DateTime.now.to_s,\n fields: 'items(start,end,summary)',\n )\n\n results.data.items.map do |event|\n summary = event.summary.gsub(/^LIVE:\\s+/, '')\n CalendarEvent.new(summary, event.start.date_time, event.end.date_time)\n end\n end", "def fetch_events(app_name, env_name, options={})\n @event_fetched_times += 1\n set_env_ready(app_name, env_name, true) # assume env become ready after it spit out all the events\n\n unless @events # unrestricted mode for testing if no explicit events set\n return [generate_event_from_messages(['Successfully deployed new configuration to environment',\n 'terminateEnvironment completed successfully',\n 'Successfully launched environment',\n 'Completed swapping CNAMEs for environments'\n ], Time.now + @event_fetched_times), nil]\n end\n\n events = @events[env_key(app_name, env_name)][@event_fetched_times - 1]\n\n if options.has_key?(:start_time)\n start_time = Time.parse(options[:start_time])\n events = events.select { |e| e[:event_date] >= start_time }\n end\n\n if limit = options[:max_records]\n events = events[0..limit]\n end\n\n [events, nil]\n end", "def index\n @events = Event.all.eventdesc\n end", "def index\n\t\t#@events = Event.all //by default it loads everything\n\tend", "def event\r\n @event\r\n @comments\r\n @replies \r\n end", "def event\n @event\n end", "def all\n ButterSand::Parser.to_array(get(PATH_SAIJI)).map {|event| ButterSand::Event.new(event)}\n end", "def index\n \t@event = Event.all\n end", "def fetch_events\n params = {'calendarId' => CONFIG[:cal_id], \n 'orderBy' => 'startTime',\n #'timeMax' => Time.utc(CONFIG[:year].to_i + 1, 4, 1).iso8601, \n #'timeMin' => Time.utc(CONFIG[:year].to_i, 4, 1).iso8601,\n 'singleEvents' => 'True'}\n \n result = @client.execute(:api_method => @cal.events.list, :parameters => params)\n\n @events_list = []\n result.data.items.each do |item|\n @events_list << item\n end\n end", "def index\n @events = Event.getRecords(params[:page])\n end", "def get_triggers\n connect_db.fetch(\"SELECT RDB$TRIGGER_NAME, RDB$TRIGGER_SOURCE FROM RDB$TRIGGERS WHERE RDB$SYSTEM_FLAG = 0\")\n end", "def events\n results = @client.execute(\n :api_method => @calendar.events.list,\n :authenticated => false,\n :parameters => {\n 'calendarId' => @config[:calendar_id],\n 'fields' => 'items(start,end,summary)',\n 'singleEvents' => true,\n 'orderBy' => 'startTime',\n 'timeMin' => DateTime.now.to_s,\n 'timeMax' => (DateTime.now + 7).to_s,\n 'q' => 'LIVE'\n }\n )\n\n results.data.items.map do |event|\n summary = event.summary.gsub(/^LIVE:\\s+/, '')\n CalendarEvent.new(summary, event.start.date_time, event.end.date_time)\n end\n end", "def db_listeners\n Thread.current[:db_listener] ||= Set.new\n end", "def list_of_events\n @events = Event.find(:all)\n @report_name = \"List of Events\"\n end", "def get_events\n events = [] \n @log ||= Rails.logger\n Appsterdam::Application.ical_subscriptions.each do |options|\n @log.info \"getting events from #{options[:url]}\"\n components = parse_ical(options[:url])\n events.concat(extract_events(components.first))\n end\n @log.info \"done importing iCal events.\"\n \n events\n end", "def events\n @events ||= Schedule.new\n end", "def index\n @events = Event.where( \"user_id = ?\", current_user.id )\n end" ]
[ "0.7372006", "0.735073", "0.735073", "0.7331979", "0.7262258", "0.72227776", "0.7114683", "0.71044487", "0.699481", "0.6977951", "0.68959826", "0.68478906", "0.6825873", "0.6782902", "0.6773882", "0.6751759", "0.6721162", "0.6703099", "0.66987103", "0.66987103", "0.6693622", "0.6688751", "0.6673", "0.6640974", "0.6637358", "0.66372406", "0.66266304", "0.6615264", "0.6610133", "0.6599566", "0.65846986", "0.6566442", "0.65428126", "0.65295166", "0.6508354", "0.6483637", "0.6479216", "0.6436873", "0.6436873", "0.6436873", "0.6436873", "0.6436873", "0.6436873", "0.6436873", "0.6436873", "0.643673", "0.64066285", "0.63933796", "0.636522", "0.63493764", "0.6318331", "0.6286044", "0.6281186", "0.62449104", "0.62259185", "0.62187433", "0.6212586", "0.62097025", "0.6208329", "0.6208329", "0.61806405", "0.61788815", "0.61779034", "0.61727417", "0.61629415", "0.6157495", "0.6147872", "0.61464125", "0.61441416", "0.61435753", "0.61434424", "0.61430746", "0.613047", "0.61253566", "0.6112279", "0.6093377", "0.6093377", "0.6090299", "0.6086417", "0.60761476", "0.6066734", "0.60665286", "0.60665286", "0.6061572", "0.60588753", "0.6045554", "0.60454845", "0.60416293", "0.60367054", "0.60241014", "0.6022584", "0.60138977", "0.5999204", "0.5998924", "0.59985584", "0.5996526", "0.59898233", "0.5986363", "0.5978773", "0.59665024", "0.5964689" ]
0.0
-1
get the log output
def log(params_hash = {}) begin raise_error_unless_params_is_a_hash(params_hash) request.method = :get request.uri = "_log#{querystring(params_hash)}" Couchdbtools.execute(request) rescue Exception => exception exception.message end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def log\n @log_output.string\n end", "def log\n @output || []\n end", "def logger_output; end", "def log_output()\n prefix = @global_opts[:prefix] ? (@global_opts[:prefix] + \"-\") : \"\"\n t = Time.now.strftime(\"%Y%m%d%H%M%S\")\n\n # Check for any returned records\n if (@successes > 0 and not [\"set\", \"unset\", \"check\"].include?(@cmd))\n any_records = true\n else\n any_records = false\n end\n\n # Data\n if any_records\n data_filename = prefix + \"wc-\" + @cmd + \"-\" + t + \".xml\"\n data = File.new(data_filename, \"w+:UTF-8\")\n data.write(@response_data)\n data.close\n end\n\n status_extension = @global_opts[:csv] ? \".csv\" : \".txt\"\n status_filename = prefix + \"wc-\" + @cmd + \"-\" + t + \"-log\" + status_extension\n\n # Summary\n summary = \"\"\n summary << <<~SUMMARY\n OCLC WorldCat Metadata API: #{@cmd.capitalize} operation\n #{PAST_TENSE[@cmd].capitalize} #{@successes.to_s} #{@successes != 1 ? \"records\" : \"record\"} and #{@failures.to_s} failed\n #{\"Records written to \" + data_filename if any_records}\n Log written to #{status_filename}\n SUMMARY\n\n # Status log\n status = File.new(status_filename, \"w+:UTF-8\")\n status.write(@debug_info) if @global_opts[:debug]\n status.write(summary + \"\\n\")\n status.write(@response_status)\n status.close\n\n puts summary\n end", "def output\n App.settings.log_output\n end", "def log_messages\n\t\treturn Thread.current[ 'logger-output' ] ||= []\n\tend", "def log\n @log ||= Logger.new($stdout)\n end", "def log\n @log\n end", "def result_log\n end", "def result_log\n end", "def result_log\n end", "def logs\n end", "def log\n @@log ||= Logger.new($stdout)\n end", "def get_log\n SimpleWorker.service.log(task_id)\n end", "def log\n advanced[:log]\n end", "def log()\n @log\n end", "def logs\n\n end", "def get_log(ssh, job)\n log_path = get_glite_output_to_file(ssh, job)\n\n out_log_content = ssh.exec!(tail(log_path, 25))\n # TODO: remove also output dir\n ssh.exec!(BashCommand.new.rm(log_path).to_s)\n\n <<-eos\n--- gLite info ---\n#{get_job_info(ssh, job.job_identifier)}\n--- Simulation Manager log ---\n#{out_log_content}\n eos\n end", "def log\n end", "def log\n @log || MPDClient.log\n end", "def log_contents\n if API_KEYS[\"logentries\"]\n account_key = API_KEYS[\"logentries\"][Rails.env][\"account_key\"]\n log_set = API_KEYS[\"logentries\"][Rails.env][\"log_set\"]\n log_name = \"nsc\"\n url = \"https://pull.logentries.com/#{account_key}/hosts/#{log_set}/#{log_name}/?filter=#{log_prefix}\"\n Rails.logger.debug { \"Fetching log from #{url}\" }\n open(url).read\n else\n File.read(log_path)\n end\n end", "def log; end", "def log; end", "def log; end", "def log; end", "def log; end", "def log; end", "def log; end", "def log; end", "def logs\n system \"tail -f ~/Library/Logs/Pow/access.log\"\n end", "def get_query_access_log\n lines=`find #{Environment.instance.vespa_home}/logs/vespa/qrs -name 'QueryAccessLog*'| xargs -n 1 cat`\n return lines\n end", "def get_log(which)\n log = _get_log(which)\n log.nil? ? [] : log.to_a\n end", "def log\n @log ||= Logger.new(STDOUT)\n end", "def logs\n @runner.log\n end", "def process_log\n @service.respond_to?(:process_log) ? @service.process_log : \"\"\n end", "def log_output output, exact=false\n return unless @telnet_options[:output_log]\n if exact\n @output_logger.print output\n else\n @output_logger.puts output\n end\n end", "def execute_output(send, line)\n return {:type => :log, :message => line}\n end", "def log(message)\n STDOUT.puts message\nend", "def log(text)\n puts text\n end", "def on_read_output(data)\n ::Chef::Log.info(data)\n end", "def get_log_entries\n command = \"svn log -v --xml #{@params[:url]}\"\n command += \" -r HEAD:#{@last_revision.to_i + 1}\" if @last_revision\n command += \" -l3\" unless @last_revision\n command += \" --username=#{@params[:username]}\" if @params[:username]\n command += \" --password=#{@params[:password]}\" if @params[:password]\n command += \" &\"\n\n cli_response = Open3.popen3(command)\n\n stdout = cli_response[1]\n stderr = cli_response[2]\n\n stderr.readlines.each do |line|\n @notifier_engine.log line.strip\n end\n\n doc = Nokogiri::XML(stdout.read)\n\n doc.css(\"logentry\")\n\n end", "def info(log)\n output.puts log if log_level <= INFO\n end", "def log\n @client.get(\"#{path}/log\")\n end", "def info(msg) log(6, msg); end", "def log\n File.read(SPEC_LOG) rescue \"\"\n end", "def log_and_stream(output)\n write_file output, runlog_filename if runlog_filename\n return @block.call(output) unless @block.nil?\n \"\"\n end", "def log\n @test_mode ? LogHelper::Redirect.instance.file : STDOUT\n end", "def get_log!(which)\n log = _get_log(which)\n log.nil? ? [] : log.drain\n end", "def log\n @log ||= Logging.logger[File.basename($0)]\n end", "def log\n @log ||= Bitcoin::Logger::LogWrapper.new(\"command:\", @node.log)\n end", "def log()\n return @log unless @log.nil?\n lg = find_task(:log)\n return lg unless lg.nil?\n @env.log\n end", "def sub_log \n send_cmd(\"sub_log\")\n end", "def info_msg(msg)\n @log.puts(msg)\n puts msg\nend", "def read_logs\n @@logs\n end", "def log_output_on &block\n out = ''\n orig,@should_log_output = @should_log_output,true\n if not block.nil?\n begin\n out = block.call\n ensure\n @should_log_output = orig\n end\n end\n out\n end", "def log\n Logger.instance\n end", "def get_ps_output(cmd_out, eof, read_wait = 5)\n results = ''\n\n if datastore['Powershell::Post::log_output']\n # Get target's computer name\n computer_name = session.sys.config.sysinfo['Computer']\n\n # Create unique log directory\n log_dir = ::File.join(Msf::Config.log_directory, 'scripts', 'powershell', computer_name)\n ::FileUtils.mkdir_p(log_dir)\n\n # Define log filename\n time_stamp = ::Time.now.strftime('%Y%m%d:%H%M%S')\n log_file = ::File.join(log_dir, \"#{time_stamp}.txt\")\n\n # Open log file for writing\n fd = ::File.new(log_file, 'w+')\n end\n\n # Read output until eof or nil return output and write to log\n loop do\n line = ::Timeout.timeout(read_wait) do\n cmd_out.channel.read\n end rescue nil\n break if line.nil?\n if line.sub!(/#{eof}/, '')\n results << line\n fd.write(line) if fd\n break\n end\n results << line\n fd.write(line) if fd\n end\n\n # Close log file\n fd.close if fd\n\n results\n end", "def stream_out(msg)\n if ($gTest_params[\"verbosity\"] != \"quiet\")\n print msg\n end\n if ($gTest_params[\"logfile\"])\n $fLOG.write(msg)\n end\nend", "def log\n out.sync = true\n @log ||= Logger.new(out)\n\n @log.formatter = proc do |severity, datetime, progname, msg|\n if verbose\n string = \"#{severity} [#{datetime.strftime('%Y-%m-%d %H:%M:%S.%2N')}]: \"\n else\n string = \"[#{datetime.strftime('%H:%M:%S')}]: \"\n end\n\n string += \"#{msg}\\n\"\n\n string\n end\n @log\n end", "def logger\n @log\n end", "def logger\n @log\n end", "def log\n count = default_log_lines(params)\n lines = get_file_lines(log: true, tail: count)\n respond_with(lines)\n end", "def log()\n return @log unless @log.nil?\n @flow.log()\n end", "def log\n STDOUT\n# @log_file ||= File.new(LOG_PATH, \"w\") # System.Text.Encoding.Unicode)\nend", "def log_lines\n\n self.each do |line|\n clean_line = line.to_s.chomp.gsub(\"\\\\n\",\"\")\n log.info(x) { line } if clean_line.length > 0\n end\n\n end", "def log(*args)\n @out.puts(*args)\n end", "def log_file\n end", "def log(msg)\n puts msg\n end", "def get_system_log\n if platform?('windows')\n Chef::Log.info \"#{Dir.glob(\"C:/ProgramData/RightScale/log/rs-instance*.log\")}\"\n return Dir.glob(\"C:/ProgramData/RightScale/log/rs-instance*.log\").max_by { |f| File.mtime(f)}\n\n# return Dir.glob(\"C:/ProgramData/RightScale/log/rs-instance*.log\")[0]\n else \n File.exists?(\"/var/log/syslog\") ? \"/var/log/syslog\" : \"/var/log/messages\" \n end\n end", "def stream_out(msg)\n if ($gTest_params[\"verbosity\"] != \"quiet\")\n print msg\n end\n if ($gTest_params[\"logfile\"])\n $fLOG.write(msg)\n end\nend", "def log(request, response)\n time = Time.new.strftime(\"%Y-%m-%d %H-%M-%S\")\n http_request = \"#{request.http_method} #{request.uri}\"\n http_response = \"#{response.code}\"\n @log_file.puts \"#{++@log_no} -- [#{time}] #{http_request} #{http_response}\"\n end", "def smartlog\n assert_in_repo\n SugarJar::Log.info(hub(\n 'log', '--graph', '--oneline', '--decorate', '--boundary',\n '--branches', \"#{most_master}..\"\n ).stdout.chomp)\n end", "def log\n LOGGER\n end", "def log\n @list\n end", "def fancy_log\n\n @log.collect { |msg| fancy_print(msg) }\n end", "def log_file\n return @log_file\n end", "def logs\n ret = @uri.logs\n render plain: ret[:message], status: ret[:status]\n end", "def log_file; end", "def log\n Chef::Log\n end", "def log\n ::Deployable::Log.log\n end", "def log\n @log ||= Logging.logger[self]\n end", "def combined_log\n messages.join.strip\n end", "def print_log(*string)\n @log.output(*string)\n end", "def log(output)\n the_time = Time.now.strftime(\"%Y-%m-%d %H:%M:%S\")\n puts \"#{the_time}: #{output}\"\nend", "def log(msg)\n puts\n puts msg\nend", "def log_file\n get_value :logfile\n end", "def logs_for(application)\n logs_at_url(get(\"/apps/#{application}/logs?logplex=true\", 2))\n end", "def log(msg)\n lines = msg.split(/\\n/)\n\n STDERR.puts \"** #{lines.first}\"\n lines[1..-1].each do |line|\n STDERR.puts\" #{line}\"\n end\n end", "def logger ; @log end", "def command_output\n [command.stdout, command.stderr].join(\"\\n\\n\")\n end", "def stdout\n @cmd_result.stdout\n end", "def error_log\n end", "def error_log\n end", "def error_log\n end", "def output\n @all[:output]\n end", "def log(phrase)\n puts \"INFO: \" + phrase\nend", "def logthis(input)\n\t\t@logmutex.lock\n\t\tfile = File.open('./serverlog','a')\n\t\twrite = \"#{Time.now}\\t#{input}\\n\"\n\t\tfile.write(write)\n\t\tputs write\n\t\t@logmutex.unlock\n\tend", "def log(message); logger.info(message); end", "def log\n each do |node|\n puts node.inspect\n end\n return nil\n end", "def show_kannel_log\n @header = 'Kannel Log'\n @lines = `tail -200 log/kannel.log`\n render(:template => \"admin/show_lines\")\n end", "def log(message)\n puts message\n end" ]
[ "0.81865406", "0.7616897", "0.74603134", "0.7017454", "0.69515413", "0.69006777", "0.6805505", "0.6791045", "0.6725854", "0.6725854", "0.6725854", "0.66410315", "0.6615037", "0.6612609", "0.6596438", "0.65742517", "0.65240276", "0.65085435", "0.6457799", "0.6419957", "0.6409676", "0.64009976", "0.64009976", "0.64009976", "0.64009976", "0.64009976", "0.64009976", "0.64009976", "0.64009976", "0.6390096", "0.63844436", "0.6358804", "0.63436997", "0.6328577", "0.6266194", "0.6243339", "0.62381244", "0.62315947", "0.6226006", "0.62249535", "0.62157714", "0.6191932", "0.61674756", "0.6126375", "0.6119739", "0.61028695", "0.61022645", "0.60989785", "0.60906506", "0.60745436", "0.60640895", "0.60629845", "0.6054325", "0.60341316", "0.6026114", "0.6010719", "0.6010009", "0.6006673", "0.60056734", "0.6004458", "0.6004458", "0.59900165", "0.59891516", "0.5988335", "0.5986227", "0.5981536", "0.5968702", "0.5964536", "0.59638274", "0.59583527", "0.5952011", "0.594006", "0.5938107", "0.59372467", "0.5931799", "0.592658", "0.5925152", "0.59218067", "0.5920911", "0.5919392", "0.59184897", "0.59172463", "0.5914854", "0.5910699", "0.5910231", "0.5900349", "0.58919704", "0.58719975", "0.5869472", "0.5858904", "0.58554804", "0.5854426", "0.5854426", "0.5854426", "0.5854088", "0.58487946", "0.58458966", "0.58418304", "0.58409", "0.5830615", "0.58295256" ]
0.0
-1
Sets the base url for this class. Note that it will not be inherited by subclasses.
def set_base_url(url) base_url = url end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_base_url\n uri = URI.parse(@page_url)\n @base_url = \"#{uri.scheme}://#{uri.host}\"\n end", "def set_base_url(url)\r\n @http_client.base_url = url\r\n end", "def base_url=(uri)\n @base_uri = uri\n end", "def base_url=(url)\n @base_url = url\n Prov.base_url=url\n end", "def with_base_url(base_url)\n @url_prefix = base_url\n self\n end", "def base_url(arg = nil)\n # TODO: Better URL validation\n set_or_return(:base_url, arg, kind_of: String, default: DEFAULT_BASE_URL)\n end", "def base_url\n self.class.base_url\n end", "def set_base_uri(base_uri)\n if base_uri =~ /^https?:\\/\\//\n self.base_uri = base_uri\n else\n self.base_uri = \"https://#{self.hostname}/#{base_uri.delete_prefix('/')}\"\n end\n end", "def base_uri=(value)\n raise ConfigurationInvalid, \"Invalid value for base uri, should be a string\" if !value.is_a?(String)\n @base_uri ||= value\n end", "def base_url\n base_href || url\n end", "def set_url\n @url = DEFAULT_URL\n end", "def base_uri(value)\n @config[:base_uri] = value\n end", "def base_path=(base_path)\n @base_path = base_path\n end", "def set_base_url(num = 0)\n return nil if num >= @api_servers.size\n @base_url = @api_servers[num]\n end", "def initialize(base_url)\n @base_url = base_url\n end", "def base_url\n @base_url||=@options['base_url']\n end", "def base_uri=(base_uri)\n default_application.base_uri = base_uri\n end", "def base_uri=(new_base_uri)\n @base_uri = new_base_uri\n end", "def base_url\n self.class.base_url\n end", "def base_url\n context[:base_url] || \"/\"\n end", "def set_base_uri(uri)\n @base_api_uri = uri\n end", "def base=(b)\n b = Addressable::URI.parse(b.to_s)\n b.fragment = nil\n @base = b.to_s\n end", "def base_uri=(uri)\n # If the baseUri does not end with a slash, we must add it\n uri += '/' unless uri[-1] == '/'\n @base_uri = uri\n end", "def base_url\n return url\n end", "def set_base_url\n $base_url = (ENV['base_url'].nil? || ENV['base_url'].empty?) ? CONFIG['default_base_url'] : ENV['base_url']\nend", "def base_uri(value)\n @document_builder.base_uri = value\n end", "def _base_url\n r = @_request\n scheme = r.scheme\n port = r.port\n \"#{scheme}://#{r.host}#{\":#{port}\" unless DEFAULT_PORTS[scheme] == port}\"\n end", "def initialize()\n print 'Base URL: ', @@base_url\n end", "def set_uri(base, path)\n @uri = \"#{base}/#{path}/#{self.identifier}\"\n end", "def url\n raise NotImplementedError, 'this should be overridden by subclass'\n end", "def base_url\n \"http://#{@host}:#{@port}\"\n end", "def base_url\n \"#{scheme}://#{host}\"\n end", "def set_git_urls\n self.url = GitHosting.repository_path(self) if url.blank?\n self.root_url = url if root_url.blank?\n end", "def setURL(url)\r\n\t\t\t\t\t@url = url\r\n\t\t\t\tend", "def setURL(url)\r\n\t\t\t\t\t@url = url\r\n\t\t\t\tend", "def setURL(url)\r\n\t\t\t\t\t@url = url\r\n\t\t\t\tend", "def setURL(url)\r\n\t\t\t\t\t@url = url\r\n\t\t\t\tend", "def setURL(url)\r\n\t\t\t\t\t@url = url\r\n\t\t\t\tend", "def set_url(url_value)\n @path = url_value.delete_prefix \"/\"\n @dir = File.dirname(@path)\n @url = url_value\n end", "def set_url_host \n @url_host = request.protocol() + request.host_with_port() + '/' \n end", "def setbase(base)\n\t\t\t@base = base\n\t\tend", "def baseurl; end", "def url=(new_url)\n super(new_url)\n unless URI.parse(self.url).scheme\n self.url.prepend(\"http://\")\n end\n rescue\n end", "def base_url_path=(_arg0); end", "def url\n super\n end", "def base_url\n File.join(host, path)\n end", "def base_url\n @client.instance_variable_get(:@base_url)\n end", "def baseurl=(_arg0); end", "def set_git_urls\n self.url = GitHosting.repository_path(self) if self.url.blank?\n self.root_url = self.url if self.root_url.blank?\n end", "def set_git_urls\n self.url = git_path if url.blank?\n self.root_url = url if root_url.blank?\n end", "def url=(value)\n if value.nil?\n @url = nil\n else\n @url = Addressable::URI.parse(value)\n @url.path << '/' unless @url.path.end_with?('/')\n end\n end", "def set_url\n self.update_column(:url, '/' + self.ancestry_url)\n end", "def base_url\n BASE_URL.dup % [\"%s\", \"%s\", @api_key, \"%s\"] \n end", "def base_uri\n \"#{self.class.base_uri}/#{name}\"\n end", "def start_url(url)\n @start_url = url\n end", "def base_url_path; end", "def base_uri\n @base_uri ||= guess_base_uri\n end", "def set_url(opts)\n opts = check_params(opts,[:urls])\n super(opts)\n end", "def url=(url)\n @@url = url\n end", "def url\n raise \"Implement in child class\"\n end", "def http_url\n context[:http_url] || context[:base_url]\n end", "def url(*args)\n super_url = super\n File.exists?(\"#{root}#{super_url}\") ? super_url : default_url\n end", "def with_base_url(path)\n u = @url.dup\n u.path += Puppet::Util.uri_encode(path)\n u\n end", "def base_uri=(uri)\n s9_document_builder.setBaseURI(java.net.URI.new(uri.to_s))\n end", "def url\n @url = \"#{@http_mode}://#{self.config.servers[0]}\"\n @url << \"/#{self.config.context}\" if(!self.config.context.empty?)\n #self.config.log.debug_msg(\"Request base URL: #{@url}\")\n @url\n end", "def base_uri(uri = nil)\n @base_uri = uri unless uri.nil?\n @base_uri\n end", "def base_uri\n @base_uri\n end", "def base_url\n current_base_href = base_href.to_s.strip.empty? ? nil : URL.absolutify(base_href, URL.new(url).root_url)\n current_base_href || url\n end", "def url(url)\n @url = url\n end", "def base_uri\n @options[:base_uri]\n end", "def base_uri\n @options[:base_uri]\n end", "def url=(url)\n @@url = url\n end", "def base_url\n Thread.current[\"GopDataTrust/Api/@base_url\"] || connect\n raise \"Must Connect To GOP Data Trust\" if Thread.current[\"GopDataTrust/Api/@base_url\"].nil?\n Thread.current[\"GopDataTrust/Api/@base_url\"]\n end", "def base_url\n URI::HTTPS.build(host: @server, port: @port, path: @api)\n end", "def url(arg = nil)\n set_or_return(:url,\n arg,\n kind_of: String,\n default: 'http://localhost:8000')\n end", "def base_uri\n attributes.fetch(:baseUri)\n end", "def base_uri\t\t\t\n\t\tURI.parse( \"http://\" + @factory.site_name + \".\" + @factory.api_host_base + @path )\n\tend", "def base_uri=(iri)\n @options[:base_uri] = RDF::URI(iri)\n end", "def base_path(val=nil)\n if val\n @base_path = val\n else\n @base_path || default_base_path_name\n end\n end", "def url\n sprintf(\"%s/%s\",\n ::Configuration.instance.handles[:base_url],\n self.handle)\n end", "def base_url\n if ENV['BASE_URL']\n ENV['BASE_URL']\n else\n 'https://beam.pro/'\n end\n end", "def initialize(options)\n @options = options\n @base_url = URI(ENVIRONMENTS.fetch(options[:environment]))\n end", "def set_url\n url 'set'\n end", "def initialize(driver, baseurl='/')\n super(driver, baseurl)\n end", "def url\n \"http://#{self.domain}/#{self.path}\"\n end", "def url=(url)\n @url = url\n @connection = nil\n end", "def web_url=(value)\n @web_url = value\n end", "def web_url=(value)\n @web_url = value\n end", "def web_url=(value)\n @web_url = value\n end", "def base_path\n @base_path || self.class.base_path\n end", "def base_url\n @is_sub_env_specific ? \"#{GlobalConstant::CompanyApi.root_url}#{GlobalConstant::Environment.url_prefix}/api/\"\n : \"#{GlobalConstant::CompanyApi.root_url}api/\"\n end", "def default_namespace=(url); end", "def default_namespace=(url); end", "def hyperlink_base=(v)\n Axlsx.validate_string v\n @hyperlink_base = v\n end", "def initialize(host = \"127.0.0.1\",port = 10025)\n self.class.base_uri \"http://#{host}:#{port}/\"\n end", "def base_url\n service.base_url\n end", "def url=(value)\n @url = value\n Curl.set_option(:url, value_for(value, :string), handle)\n end", "def base_url\n @url.to_s.split('?').first\n end", "def generate_base_uri request, set=nil\n b_uri= uri request.env['REQUEST_URI'].to_s[0..-request.env['PATH_INFO'].length]\n @base_uri = b_uri if set\n b_uri\n end", "def url(value)\n @url = value\n end" ]
[ "0.80746716", "0.79137087", "0.7639439", "0.7569167", "0.74566764", "0.73124325", "0.72121936", "0.718432", "0.7156618", "0.7123073", "0.70852757", "0.7073852", "0.7054508", "0.6979999", "0.6972563", "0.6944093", "0.6938912", "0.6921294", "0.6783741", "0.672607", "0.6711101", "0.6687828", "0.6653195", "0.6638476", "0.6624267", "0.662419", "0.65881854", "0.651575", "0.6505572", "0.65024817", "0.65007526", "0.6488769", "0.64824766", "0.645973", "0.645973", "0.645973", "0.645973", "0.645973", "0.64582306", "0.6439446", "0.64038867", "0.63989466", "0.63756317", "0.63593906", "0.63187444", "0.63077974", "0.63054615", "0.629021", "0.6287557", "0.623849", "0.6228279", "0.6224598", "0.6221937", "0.6195712", "0.61884665", "0.6182208", "0.6179855", "0.6176703", "0.61763126", "0.617201", "0.6161487", "0.6159818", "0.6156986", "0.61469626", "0.6135935", "0.611562", "0.61101836", "0.6107633", "0.60779095", "0.6044433", "0.6044433", "0.60426337", "0.60376775", "0.6037362", "0.6036516", "0.60316604", "0.60311013", "0.6024916", "0.60062027", "0.59905434", "0.59836066", "0.59831136", "0.5971192", "0.5961501", "0.59548336", "0.5953025", "0.5946669", "0.5946669", "0.5946669", "0.5937773", "0.5936342", "0.5932288", "0.5932288", "0.5931275", "0.59142375", "0.5912734", "0.59043115", "0.5900888", "0.58970094", "0.58943623" ]
0.83536834
0
Builds a new HTTP request and adds it to the +Config.hydra+ request queue. Registers a callback that invokes +handle_response+ when the request completes. Recognizes the following options: +headers+ a hash to add or update the request headers +timeout+ the timeout for the request (defaults to +Ladon.default_request_timeout+) +default_data+ passes this on to +handle_response+
def queue_request(url_or_path, options = {}, &block) url = absolute_url(url_or_path) headers = {:Accept => MEDIA_TYPE_JSON}.merge(options.fetch(:headers, {})) headers = merge_log_weasel_header(headers) timeout = options.fetch(:timeout, Ladon.default_request_timeout) request = Typhoeus::Request.new(url, headers: headers, timeout: timeout) request.on_complete do |response| handle_response(response, request: request, default_data: options[:default_data], &block) end Ladon.hydra.queue(request) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def request_and_handle http_method, path, options\n if http_method.is_a?(String) || http_method.is_a?(Symbol)\n http_method = HTTP_METHODS[http_method.to_s]\n raise \"Unknown http method: #{http_method}\" unless http_method\n end\n \n req_options = default_options.dup\n req_options = req_options.merge(options)\n \n raise ConfigurationError.new \"No endpoint defined\" if !path || path.empty?\n raise ConfigurationError.new \"No hostname defined\" if !req_options[:base_uri] || req_options[:base_uri].empty?\n \n # prepare request\n req = HTTParty::Request.new http_method, path, req_options\n req.options[:timeout] = CityGrid.custom_timeout if req.options && CityGrid.custom_timeout_set?\n\n # Sanitized request for logs\n safe_req_options = strip_unsafe_params(http_method, req_options)\n req_to_output = HTTParty::Request.new http_method, path, safe_req_options\n req_for_airbrake = { :method => http_method, :path => path, :options => safe_req_options }\n\n begin\n response = req.perform\n rescue => ex \n if defined?(Rails.logger)\n Rails.logger.error safe_req_options\n Rails.logger.error req_to_output\n Rails.logger.error req_for_airbrake\n Rails.logger.error ex\n end\n raise CityGridExceptions::RequestError.new req_for_airbrake, nil, ex.message, req_to_output.to_curl\n ensure\n if CityGrid.print_curls? \n if defined?(Rails.logger)\n Rails.logger.info req_to_output.to_curl\n puts req_to_output.to_curl\n else\n puts req_to_output.to_curl\n end\n end\n end\n\n response_status = parse_response_status response\n \n begin \n # catch unparsable responses (html etc)\n if !response.parsed_response.is_a?(Hash)\n #pp \"[gem] the response was unparsable (response was not a hash)\"\n raise CityGridExceptions::ResponseParseError.new req_for_airbrake, response, \"the response was unparsable (response was not a hash)\", req_to_output.to_curl\n else\n # Parse and handle new response codes \n if !response_status.nil? && response_status[\"code\"] != \"SUCCESS\" && response_status[\"code\"] != 200\n raise CityGridExceptions.appropriate_error(response_status[\"code\"]).new req_for_airbrake, response, response_status[\"message\"].to_s, req_to_output.to_curl\n else\n return CityGrid::API::Response.new response\n end\n end\n rescue => ex\n pp \"API ERROR: #{ex}\"\n raise ex if CityGrid.raise_errors?\n end\n end", "def make_request(file, url, hydra, &block)\n request = Typhoeus::Request.new(url, timeout: 15000)\n\n request.on_complete do |response|\n if response.success?\n block.call(response.body)\n else\n puts Rainbow(\"Failed to get #{url}\").red\n end\n\n file.close\n end\n\n if req_parallel and hydra\n hydra.queue(request)\n else\n request.run\n end\n end", "def request_and_handle http_method, path, options\n if http_method.is_a?(String) || http_method.is_a?(Symbol)\n http_method = HTTP_METHODS[http_method.to_s]\n raise \"Unknown http method: #{http_method}\" unless http_method\n end\n \n req_options = default_options.dup\n req_options = req_options.merge(options)\n \n raise ConfigurationError.new \"No endpoint defined\" if !path || path.empty?\n raise ConfigurationError.new \"No hostname defined\" if !req_options[:base_uri] || req_options[:base_uri].empty?\n \n req = HTTParty::Request.new http_method, path, req_options\n\n begin\n response = req.perform\n rescue => ex\n raise RequestError.new req, ex\n end\n \n if defined?(Rails.logger)\n Rails.logger.info req.to_curl\n else\n puts req.to_curl\n end\n \n if !response.parsed_response.is_a?(Hash)\n raise ResponseParseError.new req, response\n elsif response[\"errors\"]\n raise ResponseError.new req, response[\"errors\"], response\n elsif response[\"message\"] && response[\"message\"] == \"Invalid Token or Expired\"\n raise InvalidAuthToken.new\n else\n return CityGrid::API::Response.new response\n end\n \n rescue => ex\n raise ex if CityGrid.raise_errors?\n end", "def request_and_handle http_method, path, options\n if http_method.is_a?(String) || http_method.is_a?(Symbol)\n http_method = HTTP_METHODS[http_method.to_s]\n raise \"Unknown http method: #{http_method}\" unless http_method\n end\n \n req_options = default_options.dup\n req_options = req_options.merge(options)\n \n raise ConfigurationError.new \"No endpoint defined\" if !path || path.empty?\n raise ConfigurationError.new \"No hostname defined\" if !req_options[:base_uri] || req_options[:base_uri].empty?\n \n # prepare request\n req = HTTParty::Request.new http_method, path, req_options\n\n # Sanitized request for logs\n safe_req_options = strip_unsafe_params(http_method, req_options)\n req_to_output = HTTParty::Request.new http_method, path, safe_req_options\n req_for_airbrake = { :method => http_method, :path => path, :options => safe_req_options }\n\n begin\n response = req.perform\n rescue => ex\n raise CityGridExceptions::RequestError.new req_for_airbrake, ex\n ensure\n if CityGrid.print_curls? \n if defined?(Rails.logger)\n Rails.logger.info req_to_output.to_curl\n else\n puts req_to_output.to_curl\n end\n end\n end\n\n \n begin \n # catch unparsable responses (html etc)\n if !response.parsed_response.is_a?(Hash)\n #pp \"[gem] the response was unparsable (response was not a hash)\"\n raise CityGridExceptions::ResponseParseError.new req_for_airbrake, response\n # catch responses not in new response format\n elsif response[\"errors\"]\n #pp \"[gem] An error in the old response format was caught. Raising a general response error...\"\n raise CityGridExceptions::ResponseError.new req_for_airbrake, response[\"errors\"], response\n\n # Parse and handle new response codes \n elsif (response[\"response\"] && response[\"response\"][\"code\"] != \"SUCCESS\") && \n (response[\"response\"] && response[\"response\"][\"code\"] != 200) && \n (response[\"response\"] && response[\"response\"][\"code\"] != 400) \n error_code = response[\"response\"][\"code\"]\n #pp \"[gem] The response was contained in the first level of the response hash. Below:\"\n #pp response\n #pp \"found error code: #{error_code}\"\n #pp \"****************************************************************************\"\n raise CityGridExceptions.appropriate_error(error_code).new req_for_airbrake, response, response[\"response\"][\"message\"].to_s #+ \" \" + CityGridExceptions.print_superclasses(error_code)\n # if the response is a nested hash/nested hash containing arrays\n elsif response[\"totalNumEntries\"] && response[\"response\"].nil?\n #pp \"[gem] now parsing a response with multiple entries: #{response}\"\n error_code = parse_multiple_responses(response)\n #pp \"the error code that came back is #{error_code}\"\n if error_code.nil? || error_code == []\n #pp \"[gem] passing over this for now\"\n return CityGrid::API::Response.new response # pass over for now\n elsif error_code[0] == \"SUCCESS\" || error_code[0] == 200 || error_code[0] == 400\n return CityGrid::API::Response.new response\n else \n #pp \"[gem] we found an error and it was #{error_code[1]}\"\n raise CityGridExceptions.appropriate_error(error_code[0]).new req_for_airbrake, response, error_code[1].to_s + \" \"# + CityGridExceptions.print_superclasses(error_code[0])\n end\n else\n return CityGrid::API::Response.new response\n end\n rescue => ex\n pp \"The gem threw an error: #{ex}\"\n raise ex if CityGrid.raise_errors?\n end\n end", "def http_request\n @http_request ||= begin\n request = request_for_verb\n add_post_data(request)\n add_bearer_token(request)\n add_headers(request)\n request\n end\n end", "def build_request\n\n uri = URI.parse(@endpoint)\n # add uri\n params = [uri.host, uri.port]\n # add proxy\n params += @proxy.values_at(:host, :port, :user, :pass) unless @proxy.empty?\n\n @http = Net::HTTP.new(*params)\n # add ssl\n if @endpoint.start_with?('https')\n @http.use_ssl = true\n @http.verify_mode = OpenSSL::SSL::VERIFY_PEER\n end\n\n net_http = Kernel.const_get('Net::HTTP::' + @request_method[:method].capitalize)\n @request = add_request_headers(net_http.new(uri.request_uri))\n\n end", "def handle request, response\n\n options = {}\n options[:port] = request.port\n options[:ssl] = request.use_ssl?\n options[:proxy_uri] = request.proxy_uri\n options[:ssl_verify_peer] = request.ssl_verify_peer?\n options[:ssl_ca_file] = request.ssl_ca_file if request.ssl_ca_file\n options[:ssl_ca_path] = request.ssl_ca_path if request.ssl_ca_path\n\n connection = pool.connection_for(request.host, options)\n connection.read_timeout = request.read_timeout\n\n begin\n http_response = connection.request(build_net_http_request(request))\n response.body = http_response.body\n response.status = http_response.code.to_i\n response.headers = http_response.to_hash\n rescue Timeout::Error, Errno::ETIMEDOUT => e\n response.timeout = true\n end\n nil\n\n end", "def make_request\n response = @http.request(@request)\n end", "def build_request(req, http_method, path, opts = {})\n opts[:query_params].each_key do |key|\n if opts[:query_params][key].kind_of?(Array)\n opts[:query_params][key] = opts[:query_params][key].join[\",\"]\n end\n end\n if @config.http_request_timeout > 0\n req.options.timeout = @config.http_request_timeout\n end\n req.url path.sub(/^\\/+/, '')\n req.headers = opts[:header_params]\n req.params = opts[:query_params]\n req.body = build_request_body(req.headers, opts[:body], opts[:files])\n set_headers(req.headers)\n if @config.debugging\n @config.logger.debug \"HTTP request\\nMethod: #{req.method}\\nPath: #{req.path}\\nParams: #{req.params}\\nHeaders: #{req.headers}\\nBody: #{req.body}\\n\"\n end\n end", "def build_request(http_method, path, opts = {})\n url = build_request_url(path)\n http_method = http_method.to_sym.downcase\n\n header_params = @default_headers.merge(opts[:header_params] || {})\n query_params = opts[:query_params] || {}\n form_params = opts[:form_params] || {}\n\n\n # set ssl_verifyhosts option based on @config.verify_ssl_host (true/false)\n _verify_ssl_host = @config.verify_ssl_host ? 2 : 0\n\n req_opts = {\n :method => http_method,\n :headers => header_params,\n :params => query_params,\n :params_encoding => @config.params_encoding,\n :timeout => @config.timeout,\n :ssl_verifypeer => @config.verify_ssl,\n :ssl_verifyhost => _verify_ssl_host,\n :sslcert => @config.cert_file,\n :sslkey => @config.key_file,\n :verbose => @config.debugging,\n :proxy => @config.proxy\n }\n\n # set custom cert, if provided\n req_opts[:cainfo] = @config.ssl_ca_cert if @config.ssl_ca_cert\n\n if [:post, :patch, :put, :delete].include?(http_method)\n req_body = build_request_body(header_params, form_params, opts[:body])\n req_opts.update :body => req_body\n if @config.debugging\n @config.logger.debug \"HTTP request body param ~BEGIN~\\n#{req_body}\\n~END~\\n\"\n end\n end\n\n request = Typhoeus::Request.new(url, req_opts)\n download_file(request) if opts[:return_type] == 'File'\n request\n end", "def build_request(http_method, path, opts = {})\n url = build_request_url(path, opts)\n http_method = http_method.to_sym.downcase\n\n header_params = @default_headers.merge(opts[:header_params] || {})\n query_params = opts[:query_params] || {}\n form_params = opts[:form_params] || {}\n follow_location = opts[:follow_location] || true\n\n update_params_for_auth! header_params, query_params, opts[:auth_names]\n\n # set ssl_verifyhosts option based on @config.verify_ssl_host (true/false)\n _verify_ssl_host = @config.verify_ssl_host ? 2 : 0\n\n req_opts = {\n :method => http_method,\n :headers => header_params,\n :params => query_params,\n :params_encoding => @config.params_encoding,\n :timeout => @config.timeout,\n :ssl_verifypeer => @config.verify_ssl,\n :ssl_verifyhost => _verify_ssl_host,\n :sslcert => @config.cert_file,\n :sslkey => @config.key_file,\n :verbose => @config.debugging,\n :followlocation => follow_location\n }\n\n # set custom cert, if provided\n req_opts[:cainfo] = @config.ssl_ca_cert if @config.ssl_ca_cert\n\n if [:post, :patch, :put, :delete].include?(http_method)\n req_body = build_request_body(header_params, form_params, opts[:body])\n req_opts.update :body => req_body\n if @config.debugging\n @config.logger.debug \"HTTP request body param ~BEGIN~\\n#{req_body}\\n~END~\\n\"\n end\n end\n\n request = Typhoeus::Request.new(url, req_opts)\n download_file(request) if opts[:return_type] == 'File'\n request\n end", "def build_request(http_method, path, opts = {})\n url = build_request_url(path)\n http_method = http_method.to_sym.downcase\n\n header_params = @default_headers.merge(opts[:header_params] || {})\n query_params = opts[:query_params] || {}\n form_params = opts[:form_params] || {}\n\n\n # set ssl_verifyhosts option based on @config.verify_ssl_host (true/false)\n _verify_ssl_host = @config.verify_ssl_host ? 2 : 0\n\n req_opts = {\n :method => http_method,\n :headers => header_params,\n :params => query_params,\n :params_encoding => @config.params_encoding,\n :timeout => @config.timeout,\n :ssl_verifypeer => @config.verify_ssl,\n :ssl_verifyhost => _verify_ssl_host,\n :sslcert => @config.cert_file,\n :sslkey => @config.key_file,\n :verbose => @config.debugging\n }\n\n # set custom cert, if provided\n req_opts[:cainfo] = @config.ssl_ca_cert if @config.ssl_ca_cert\n\n if [:post, :patch, :put, :delete].include?(http_method)\n req_body = build_request_body(header_params, form_params, opts[:body])\n req_opts.update :body => req_body\n if @config.debugging\n @config.logger.debug \"HTTP request body param ~BEGIN~\\n#{req_body}\\n~END~\\n\"\n end\n end\n\n request = Typhoeus::Request.new(url, req_opts)\n download_file(request) if opts[:return_type] == 'File'\n request\n end", "def make_http_request(path, options={}, response_proc=nil, &block)\n start_time = Time.now\n\n connection = Net::HTTP.new(@base_uri.host, @base_uri.port)\n connection.open_timeout = @open_timeout if @open_timeout\n connection.read_timeout = @read_timeout if @read_timeout\n if @base_uri.scheme == 'https' then\n connection.use_ssl = true\n connection.verify_mode = OpenSSL::SSL::VERIFY_NONE\n end\n connection.start do\n path_as_string = case path\n when String then '/' + path\n when Array then '/' + path.join('/')\n end\n # remove any trailing string on the base_uri path\n complete_path = @base_uri.path.gsub(/\\/+$/, '') + path_as_string\n request = yield(complete_path)\n request.basic_auth(@username, @password)\n options[:headers].each {|k,v| request[k] = v} if options[:headers]\n request['Accept'] = 'application/json' if options.fetch(:json, true)\n log_http_request(request)\n\n response =\n if response_proc\n connection.request(request, &response_proc)\n else\n connection.request(request)\n end\n\n case response\n when nil\n log :warn, \"No response received\"\n raise HTTPError, \"No response received!\"\n when Net::HTTPClientError, Net::HTTPServerError\n log_http_response(start_time, request, response)\n raise HTTPError, \"#{response.code}: #{response.body}\"\n else\n log_http_response(start_time, request, response)\n if options.fetch(:json, true) && response.body\n\n # we inject a nasty instance variable to the client so that it\n # can lazy load any references to other objects - could be done\n # with thin_models, as this has built in support\n # for lazy loading attributes\n deserialized_object = parse_json(response.body) do |instance|\n instance.instance_variable_set(\"@__deserializing_client\", self)\n end\n\n deserialized_object.tap do |result|\n # not sure whether this should include the base_uri path\n # mung the uri on to the deserialized object - used for equality\n # and sort of replaces the old path_components property\n # also, some objects are coming back with a path_components\n # instance variable - where does that come from?\n result.respond_to?(:uri=) && result.uri = path_as_string\n end\n end\n end\n end\n end", "def run_request(method, url, body, headers)\n if !METHODS.include?(method)\n raise ArgumentError, \"unknown http method: #{method}\"\n end\n\n # Resets temp_proxy\n @temp_proxy = proxy_for_request(url)\n\n request = build_request(method) do |req|\n req.options = req.options.merge(:proxy => @temp_proxy)\n req.url(url) if url\n req.headers.update(headers) if headers\n req.body = body if body\n yield(req) if block_given?\n end\n\n builder.build_response(self, request)\n end", "def build_request(action, url, headers, options = {})\n # If the Expect header isn't set uploads are really slow\n headers['Expect'] ||= ''\n\n Request.new.tap do |req|\n req.action = action\n req.headers = self.headers.merge headers\n req.automatic_content_encoding = options.fetch :automatic_content_encoding, self.automatic_content_encoding\n req.timeout = options.fetch :timeout, self.timeout\n req.connect_timeout = options.fetch :connect_timeout, self.connect_timeout\n req.dns_cache_timeout = options.fetch :dns_cache_timeout, self.dns_cache_timeout\n req.low_speed_time = options.fetch :low_speed_time, self.low_speed_time\n req.low_speed_limit = options.fetch :low_speed_limit, self.low_speed_limit\n req.force_ipv4 = options.fetch :force_ipv4, self.force_ipv4\n req.max_redirects = options.fetch :max_redirects, self.max_redirects\n req.username = options.fetch :username, self.username\n req.password = options.fetch :password, self.password\n req.proxy = options.fetch :proxy, self.proxy\n req.proxy_type = options.fetch :proxy_type, self.proxy_type\n req.auth_type = options.fetch :auth_type, self.auth_type\n req.insecure = options.fetch :insecure, self.insecure\n req.ssl_version = options.fetch :ssl_version, self.ssl_version\n req.http_version = options.fetch :http_version, self.http_version\n req.cacert = options.fetch :cacert, self.cacert\n req.ignore_content_length = options.fetch :ignore_content_length, self.ignore_content_length\n req.buffer_size = options.fetch :buffer_size, self.buffer_size\n req.download_byte_limit = options.fetch :download_byte_limit, self.download_byte_limit\n req.progress_callback = options.fetch :progress_callback, self.progress_callback\n req.multipart = options[:multipart]\n req.upload_data = options[:data]\n req.file_name = options[:file]\n\n base_url = self.base_url.to_s\n url = url.to_s\n raise ArgumentError, \"Empty URL\" if base_url.empty? && url.empty?\n uri = URI.parse(base_url.empty? ? url : File.join(base_url, url))\n query = uri.query.to_s.split('&')\n query += options[:query].is_a?(Hash) ? Util.build_query_pairs_from_hash(options[:query]) : options[:query].to_s.split('&')\n uri.query = query.join('&')\n uri.query = nil if uri.query.empty?\n url = uri.to_s\n req.url = url\n end\n end", "def do_request\n\t\t\tself.response = post_request(options)\n\t\tend", "def request\n HTTP.headers(request_headers).timeout(timeout_options)\n end", "def perform(req, options)\n verify_connection!(req.uri)\n\n @state = :dirty\n\n begin\n @connection ||= HTTP::Connection.new(req, options)\n\n unless @connection.failed_proxy_connect?\n @connection.send_request(req)\n @connection.read_headers!\n end\n rescue Error => e\n options.features.each_value do |feature|\n feature.on_error(req, e)\n end\n raise\n end\n res = build_response(req, options)\n\n res = options.features.inject(res) do |response, (_name, feature)|\n feature.wrap_response(response)\n end\n\n @connection.finish_response if req.verb == :head\n @state = :clean\n\n res\n rescue\n close\n raise\n end", "def post_init\n @builder, @parser = Hatetepe::Builder.new, Hatetepe::Parser.new\n @builder.on_write << method(:send_data)\n # @builder.on_write {|data| p \"|--> #{data}\" }\n @parser.on_response << method(:receive_response)\n\n @queue = []\n\n @app = proc {|request| send_request(request) }\n\n self.comm_inactivity_timeout = config[:timeout]\n self.pending_connect_timeout = config[:connect_timeout]\n\n start_tls if config[:ssl]\n end", "def build_request(http_method, path, opts = {})\n url = build_request_url(path)\n http_method = http_method.to_sym.downcase\n\n header_params = @default_headers.merge(opts[:header_params] || {})\n query_params = opts[:query_params] || {}\n form_params = opts[:form_params] || {}\n\n update_params_for_auth! header_params, query_params, opts[:auth_names]\n\n # set ssl_verifyhosts option based on @config.verify_ssl_host (true/false)\n _verify_ssl_host = @config.verify_ssl_host ? 2 : 0\n\n req_opts = {\n :method => http_method,\n :headers => header_params,\n :params => query_params,\n :params_encoding => @config.params_encoding,\n :timeout => @config.timeout,\n :ssl_verifypeer => @config.verify_ssl,\n :ssl_verifyhost => _verify_ssl_host,\n :sslcert => @config.cert_file,\n :sslkey => @config.key_file,\n :verbose => @config.debugging\n }\n\n # set custom cert, if provided\n req_opts[:cainfo] = @config.ssl_ca_cert if @config.ssl_ca_cert\n\n if [:post, :patch, :put, :delete].include?(http_method)\n req_body = build_request_body(header_params, form_params, opts[:body])\n req_opts.update :body => req_body\n if @config.debugging\n @config.logger.debug \"HTTP request body param ~BEGIN~\\n#{req_body}\\n~END~\\n\"\n end\n end\n\n request = Typhoeus::Request.new(url, req_opts)\n download_file(request) if opts[:return_type] == 'File'\n request\n end", "def set_callback\n if request.streaming?\n response = nil\n easy.on_headers do |easy|\n response = Response.new(Ethon::Easy::Mirror.from_easy(easy).options)\n request.execute_headers_callbacks(response)\n end\n request.on_body.each do |callback|\n easy.on_body do |chunk, easy|\n callback.call(chunk, response)\n end\n end\n else\n easy.on_headers do |easy|\n request.execute_headers_callbacks(Response.new(Ethon::Easy::Mirror.from_easy(easy).options))\n end\n end\n request.on_progress.each do |callback|\n easy.on_progress do |dltotal, dlnow, ultotal, ulnow, easy|\n callback.call(dltotal, dlnow, ultotal, ulnow, response)\n end\n end\n easy.on_complete do |easy|\n request.finish(Response.new(easy.mirror.options))\n Typhoeus::Pool.release(easy)\n if hydra && !hydra.queued_requests.empty?\n hydra.dequeue_many\n end\n end\n end", "def create_new_http_request\n # Create a new HTTP request instance\n request_spec = @data[:request][:instance]\n http_class = \"Net::HTTP::#{request_spec.verb._camelize}\"\n http_request = http_class._constantize::new(request_spec.path)\n # Set the request body\n if request_spec.is_io?\n http_request.body_stream = request_spec.body\n else\n http_request.body = request_spec.body\n end\n # Copy headers\n request_spec.headers.each { |header, value| http_request[header] = value }\n # Save the new request\n request_spec.raw = http_request\n # Set user-agent\n if @data[:options].has_key?(:connection_user_agent)\n http_request['user-agent'] ||= @data[:options][:connection_user_agent]\n end\n http_request\n end", "def queue(link)\n\t\t####binding.pry\n\t\treq = request(link)\n\t\t######binding.pry\n\t\treq.on_complete {|res| \n\t\t\t######binding.pry\n\t\t\thandle_response(req, res)\n\t\t}\n\t\t#####binding.pry\n\t\thydra.queue(req)\n\t\t####binding.pry\n\tend", "def execute!\n validate_request!\n perform_request!\n\n build_response\n end", "def build_request(http_method, path, opts = {})\n url = build_request_url(path, opts)\n header_params = @default_headers.merge(opts[:header_params] || {})\n query_params = opts[:query_params] || {}\n form_params = opts[:form_params] || {}\n\n update_params_for_auth! header_params, query_params, opts[:auth_names]\n\n # set ssl_verifyhosts option based on @config.verify_ssl_host (true/false)\n _verify_ssl_host = @config.verify_ssl_host ? 2 : 0\n\n req_opts = {\n :method => http_method,\n :headers => header_params,\n :query => transform_hash(query_params),\n :timeout => @config.timeout,\n :verify_peer => @config.verify_ssl,\n :verify => _verify_ssl_host,\n :verbose => @config.debugging,\n :http_proxyaddr => @config.http_proxyaddr,\n :http_proxyport => @config.http_proxyport,\n :http_proxyuser => @config.http_proxyuser,\n :http_proxypass => @config.http_proxypass\n }\n\n req_opts[:pem] = File.read(@config.cert_file) if @config.cert_file\n req_opts[:pem_password] = File.read(@config.key_file) if @config.key_file\n\n opts[:stream_body] = true if opts[:return_type] == 'File'\n\n # set custom cert, if provided\n req_opts[:ssl_ca_file] = File.read(@config.ssl_ca_cert) if @config.ssl_ca_cert\n\n if [\"POST\", \"PATCH\", \"PUT\", \"DELETE\"].include?(http_method.const_get(:METHOD))\n req_body = build_request_body(header_params, form_params, opts[:body])\n req_opts.update :body => req_body\n if @config.debugging\n @config.logger.debug \"HTTP request body param ~BEGIN~\\n#{req_body}\\n~END~\\n\"\n end\n end\n\n HTTParty::Request.new(http_method, url, req_opts)\n end", "def build_request path, opts = {}\n connection.build_request path, opts\n end", "def request(\n method,\n path,\n headers = nil,\n body = nil,\n api_version = EasyPost::InternalUtilities::Constants::API_VERSION\n )\n # Remove leading slash from path.\n path = path[1..] if path[0] == '/'\n\n uri = URI.parse(\"#{@base_url}/#{api_version}/#{path}\")\n headers = @config[:headers].merge(headers || {})\n serialized_body = JSON.dump(EasyPost::InternalUtilities.objects_to_ids(body)) if body\n open_timeout = @config[:open_timeout]\n read_timeout = @config[:read_timeout]\n request_timestamp = Time.now\n request_uuid = SecureRandom.uuid\n\n if EasyPost::Hooks.any_subscribers?(:request)\n request_context = EasyPost::Hooks::RequestContext.new(\n method: method,\n path: uri.to_s,\n headers: headers,\n request_body: body,\n request_timestamp: request_timestamp,\n request_uuid: request_uuid,\n )\n EasyPost::Hooks.notify(:request, request_context)\n end\n\n # Execute the request, return the response.\n\n response = if @custom_client_exec\n @custom_client_exec.call(method, uri, headers, open_timeout, read_timeout, serialized_body)\n else\n default_request_execute(method, uri, headers, open_timeout, read_timeout, serialized_body)\n end\n response_timestamp = Time.now\n\n if EasyPost::Hooks.any_subscribers?(:response)\n response_context = {\n http_status: nil,\n method: method,\n path: uri.to_s,\n headers: nil,\n response_body: nil,\n request_timestamp: request_timestamp,\n response_timestamp: response_timestamp,\n client_response_object: response,\n request_uuid: request_uuid,\n }\n\n # If using a custom HTTP client, the user will have to infer these from the raw\n # client_response_object attribute\n if response.is_a?(Net::HTTPResponse)\n response_body = begin\n JSON.parse(response.body)\n rescue JSON::ParseError\n response.body\n end\n response_context.merge!(\n {\n http_status: response.code.to_i,\n headers: response.each_header.to_h,\n response_body: response_body,\n },\n )\n end\n\n EasyPost::Hooks.notify(:response, EasyPost::Hooks::ResponseContext.new(**response_context))\n end\n\n response\n end", "def execute_http_request (method, url, args)\n @http_request = method, url.clone, args.clone\n self.http_response = HTTParty.send method, url, args\n Log.debug \"#{@http_response.request.http_method.to_s.split('::').last.upcase} - URL: #{@http_response.request.last_uri}\"\n Log.debug 'HEADER:'\n Log.debug http_response.request.options[:headers]\n # Log.debug @http_response.request.options[:body] if @http_response.request.options[:body]\n Log.debug 'BODY:' if http_response\n Log.debug http_response if http_response\n http_response\n end", "def process_http_request\n # the http request details are available via the following instance variables:\n # @http_protocol\n # @http_request_method\n # @http_cookie\n # @http_if_none_match\n # @http_content_type\n # @http_path_info\n # @http_request_uri\n # @http_query_string\n # @http_post_content\n # @http_headers\n handle(@http_request_method, @http_post_content)\n\n send_ok()\n end", "def execute!\n validate_request!\n perform_request!\n\n build_response\n end", "def make_http_request( url, options, auth_info = {} )\n try_count = 0\n \n begin\n request = Net::HTTP::Post.new(url.path)\n request.basic_auth auth_info[:hapi_username], auth_info[:hapi_password] unless auth_info.empty?\n request.set_form_data(options)\n request.add_field('User-Agent', USER_AGENT)\n \n http = Net_HTTP.new(url.host, url.port)\n http.use_ssl = true\n http.request(request)\n rescue Errno::ECONNREFUSED\n if try_count < 2\n try_count += 1\n sleep 1\n retry\n else\n raise Backend, \"Connection refused trying to contact hAPI at #{@hapi_hostname}\"\n end\n end\n end", "def init_request(url)\n request = Typhoeus::Request.new(\n url,\n method: :get,\n headers: {'User-Agent' => user_agent}, \n followlocation: true\n # proxy: ...,\n # proxyuserpwd: ...\n )\n\n request.on_complete do |response|\n if response.success?\n # do nothing here\n elsif response.timed_out?\n raise Hubberlyzer::ResponseError, \"Time out when requesting: #{url}\"\n elsif response.code != 200\n raise Hubberlyzer::ResponseError, \"Response code #{response.code}, #{response.return_message} when requesting: #{url}\"\n else\n # Received a non-successful http response.\n raise Hubberlyzer::ResponseError, \"HTTP request failed. Response code #{response.code} when requesting: #{url}\"\n end\n end\n\n request\n end", "def build_request\n uri = @config[:endpoint]\n http = Net::HTTP.new(uri.host, uri.port)\n http.use_ssl = true\n http.start\n request = build_request_stream(uri)\n return http, request\n end", "def handle( request ) # note: all 'handle's return 'mlResponse' in a chain\n\n request.record_arrival_time\n mlResponse =\n case\n when request.get? then handle_get_muffin(request)\n when request.post? then handle_post(request)\n end\n request.record_completion_time\n mlResponse\n end", "def queue(request)\n request.hydra = self\n queued_requests << request\n end", "def process_http_request\n route_http_request\n end", "def initialize(url = nil, options = {})\n if url.is_a?(Hash)\n options = url\n url = options[:url]\n end\n @headers = Headers.new\n @params = {}\n @options = options[:request] || {}\n @ssl = options[:ssl] || {}\n @parallel_manager = options[:parallel]\n self.url_prefix = url if url\n proxy(options[:proxy])\n merge_params @params, options[:params] if options[:params]\n merge_headers @headers, options[:headers] if options[:headers]\n\n if block_given?\n @builder = Builder.create { |b| yield b }\n else\n @builder = options[:builder] || Builder.new\n end\n end", "def http_client\n @http_client ||=\n begin\n uri = URI(http_request[:url])\n Net::HTTP.new(uri.host, uri.port).tap { |e| e.read_timeout = dispatch_deadline }\n end\n end", "def make_request(http, request)\n response = http.request(request)\n Response.new(response)\n end", "def build_response(connection, request); end", "def with_http_handler(handler = nil, &blk)\n handler ||= Http::Handler.new(@http_handler, &blk)\n with_options(:http_handler => handler)\n end", "def with_http_handler(handler = nil, &blk)\n handler ||= Http::Handler.new(@http_handler, &blk)\n with_options(:http_handler => handler)\n end", "def make_request(request, options)\n gather_headers(request, options)\n response = @http.request(request)\n Validators::ResponseValidator.validate!(response)\n JSON.parse(response.body)\n end", "def do_it(http_method, url:, **options)\n err = nil\n timing = {}\n timing[:start] = Time.now\n begin\n faraday_init = {url: url}\n faraday_init[:ssl] = {verify: false} if options[:https_allow_unverified]\n faraday_init[:request] = {timeout: options[:timeout]} if options[:timeout]\n conn = Faraday.new(faraday_init) do |faraday|\n # Request encoders are relatively safe, as they have built-in checks for suitability.\n # faraday.request(:multipart) # multipart first, takes priority over url_encoded.\n faraday.request(:url_encoded)\n # faraday.response(:logger, nil, bodies: {response: true}) if Rails.env.development?\n faraday.proxy = options[:proxy] if options[:proxy]\n faraday.adapter(Faraday.default_adapter) # must be after middlewares\n faraday.basic_auth(options[:basic_auth][:username], options[:basic_auth][:password]) if options[:basic_auth]\n end\n timing[:start] = Time.now\n response = conn.run_request(http_method, nil, options[:body], options[:headers])\n rescue => e\n err = e\n end\n timing[:end] = Time.now\n timing[:duration] = timing[:end] - timing[:start]\n log_url = options[:log_url] || url\n if err\n Rails.logger.error(http_method.to_s.upcase+\" #{log_url} ERROR (#{(timing[:duration]*1000).round}ms): #{err.class}: #{err.message}\")\n raise err.class, err.message, caller(2)\n else\n Rails.logger.info(http_method.to_s.upcase+\" #{log_url} response (#{(timing[:duration]*1000).round}ms): #{response.status} \"+response.body.inspect.truncate(350, omission: \"... (#{response.body.to_s.length} total)\\\"\")) #\"\n end\n unless options[:return_failed_response] || response.success?\n err = ResponseError.new_from_response(response)\n err.set_backtrace(caller(2))\n raise err\n end\n {success: response.success?, status: response.status, body: response.body, headers: response.headers.to_h, timing: timing}\n end", "def http_request(action, data, method_type = 'POST', binary_key = nil)\n\n uri = \"#{@api_uri}/#{action}\"\n if method_type != \"POST\" && (!method_type.is_a? String)\n uri += \"?\" + data.map{ |key, value| \"#{CGI::escape(key.to_s)}=#{CGI::escape(value.to_s)}\" }.join(\"&\")\n end\n\n req = nil\n\n _uri = URI.parse(uri)\n\n headers = {\n \"Content-Type\": \"text/json\",\n \"Api-Key\":\"#{@api_key}\"\n }\n\n if method_type == 'POST'\n req = set_up_post_request(\n _uri, data, headers, binary_key\n )\n\n else\n request_uri = \"#{_uri.path}?#{_uri.query}\"\n if method_type == 'DELETE'\n req = Net::HTTP::Delete.new(request_uri, headers)\n else\n req = Net::HTTP::Get.new(request_uri, headers)\n end\n end\n\n begin\n http = Net::HTTP::Proxy(@proxy_host, @proxy_port).new(_uri.host, _uri.port)\n\n if _uri.scheme == 'https'\n http.ssl_version = :TLSv1\n http.use_ssl = true\n http.set_debug_output $stderr\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE if @verify_ssl != true # some openSSL client doesn't work without doing this\n http.ssl_timeout = @opts[:http_ssl_timeout] || 5\n end\n http.open_timeout = @opts[:http_open_timeout] || 5\n http.read_timeout = @opts[:http_read_timeout] || 10\n http.close_on_empty_response = @opts[:http_close_on_empty_response] || true\n\n\n response = http.start do\n http.request(req)\n end\n\n rescue Timeout::Error, Errno::ETIMEDOUT => e\n raise UnavailableError, \"Timed out: #{_uri}\"\n rescue => e\n raise ClientError, \"Unable to open stream to #{_uri}: #{e.message}\"\n end\n\n response.body || raise(ClientError, \"No response received from stream: #{_uri}\")\n end", "def run\n\n action Colors.grey(\"REQUEST \") + Colors.light_blue(\"#{options[:method].upcase} #{url}\")\n Console.instance.indent\n # run the request\n options[:ssl_verifypeer] = false\n options[:followlocation] = true\n\n Injector.decorate(options)\n\n # convert all headers keys to strings to avoid having symbols like :\"header\" when\n # declaring headers with colons instead of arrows\n if options.key?(:headers)\n new_opts = {}\n options[:headers].map do |k, v|\n new_opts[k.to_s] = v\n end\n options[:headers] = new_opts\n end\n\n if options.key?(:headers) and options[:headers].key?('Content-Type')\n ctype = options[:headers]['Content-Type']\n if ctype.include?('application/json')\n # automatically encode json content\n options[:body] = JSON.generate(options[:body], quirks_mode: true)\n end\n end\n\n\n\n self.response = Typhoeus::Request.new(url, options).run\n\n self.req_response = RequestResponse.new.tap { |r|\n r.raw_body = response.body\n r.headers = response.headers\n r.code = response.code\n r.total_time = response.total_time\n\n if !r.headers.nil? && r.headers.key?('Content-Type') && r.headers['Content-Type'].include?('application/json')\n r.body = JSON.parse(response.body)\n else\n r.body = response.body\n end\n }\n\n # reset assertion counter\n self.assert_no = 1\n\n # evaluate response against expectations\n begin\n instance_eval(&expectations)\n rescue AssertionException\n error error_msg + \" at #{expectations.source_location}\"\n raise RequestException\n rescue StandardError => e\n error 'Exception ' + e.message\n info e.backtrace.inspect\n _debug_info\n error error_msg\n raise RequestException\n ensure\n Console.instance.unindent\n end\n\n req_response\n\n end", "def initialize(options = {})\n @headers = options[:headers] || HEADERS\n @retries = options[:retries] || RETRIES\n @backoff_policy =\n options[:backoff_policy] || Sumologic::Metrics::BackoffPolicy.new\n\n uri = URI(options.fetch(:uri))\n http = Net::HTTP.new(uri.host, uri.port)\n http.set_debug_output(logger) if logger.level == Logger::DEBUG\n http.use_ssl = uri.scheme == 'https'\n http.read_timeout = 8\n http.open_timeout = 4\n\n @path = uri.path\n @http = http\n end", "def request(req)\n if opts[:retry_connections]\n request_with_timeout(req)\n else\n request_without_timeout(req)\n end\n end", "def request(data, timeout: nil, &callback)\n message = Message.new(data, type: :request)\n\n if block_given?\n # Async execution of request\n in_thread(callback, name: 'requesting') do |cb|\n cb.call(send_request_and_wait_for_response(message, timeout).data)\n end\n nil\n else\n send_request_and_wait_for_response(message, timeout).data\n end\n end", "def execute_request(request:, payload:, api_config:)\n http_request = HTTPI::Request.new(request.url.try(:to_s))\n http_request.body = payload\n\n if api_config[:http_basic_username] && api_config[:http_basic_password]\n http_request.auth.basic(api_config[:http_basic_username], api_config[:http_basic_password])\n end\n\n http_request.auth.ssl.verify_mode = api_config[:ssl_verify_mode] || :peer\n http_request.open_timeout = api_config[:timeout] || 30\n http_request.read_timeout = api_config[:timeout] || 30\n\n if block_given?\n http_request = yield http_request\n end\n\n request.http_request = http_request\n\n begin\n response = HTTPI.request(request.action.http_method, http_request)\n request.http_response = response\n rescue => e\n raise RequestError.new(e, request)\n end\n\n if response.error?\n raise RequestError.new(\"#{request.action.http_method} #{request.url} returned #{response.code}\", request)\n end\n\n request\n end", "def build_request(name, args)\n build_args(args) if args\n # build the request & http object\n build_http_request(name)\n # set the content type & request body\n update_content_type(name)\n make_request(@http, @request)\n end", "def initialize(options = {})\n options[:host] ||= Defaults::Request.host\n options[:port] ||= Defaults::Request.port\n options[:ssl] ||= Defaults::Request.ssl\n options[:headers] ||= Defaults::Request.headers\n @path = options[:path] || Defaults::Request.path\n\n http = Net::HTTP.new(options[:host], options[:port])\n http.use_ssl = options[:ssl]\n http.read_timeout = 8\n http.open_timeout = 4\n\n @http = http\n end", "def http_post_request\n begin\n return http_client.post(http_path_query, compressed_request, http_headers)\n rescue APIKeyError\n log 'error - you must set your api_key.'\n rescue TimeoutError\n log 'fail - timeout while contacting the api server.'\n rescue Exception => e\n log \"fail - exception raised during http post. (#{e.class.name}: #{e.message})\"\n end\n nil\n end", "def initialize(uri, options = {})\n self.url = uri\n options = options.dup\n @ready_state = CONNECTING\n @with_credentials = options.delete(:with_credentials) { false }\n @headers = default_request_headers.merge(options.fetch(:headers, {}))\n @read_timeout = options.fetch(:read_timeout, 0).to_i\n proxy = ENV['HTTP_PROXY'] || ENV['http_proxy'] || options[:proxy]\n if proxy\n proxyUri = URI(proxy)\n if proxyUri.scheme == 'http' || proxyUri.scheme == 'https'\n @proxy = proxyUri\n end\n end\n\n @reconnect_timeout = options.fetch(:reconnect_delay, 1)\n @on = { open: ->{}, message: ->(_) {}, error: ->(_) {} }\n\n @chunked = false\n\n yield self if block_given?\n\n async.listen\n end", "def handle( request ) # note: all 'handle's return 'ml_response' in a chain\n\n# not yet request.record_arrival_time\n ml_response =\n case\n when request.get? then handle_get_muffin(request)\n when request.post? then handle_post(request)\n end\n# not yet request.record_completion_time\n ml_response\n end", "def request\n self.response = prepare_response(http_communication.content)\n end", "def send\n http = EM::HttpRequest.new(@uri).post(@request_options)\n\n http.callback do\n process(http.response)\n end\n\n http.errback do\n fail(http.error)\n end\n end", "def request(action, url, headers, options = {})\n # If the Expect header isn't set uploads are really slow\n headers['Expect'] ||= ''\n\n req = Request.new\n req.action = action\n req.timeout = self.timeout\n req.connect_timeout = self.connect_timeout\n req.max_redirects = self.max_redirects\n req.headers = self.headers.merge(headers)\n req.username = self.username\n req.password = self.password\n req.upload_data = options[:data]\n req.file_name = options[:file]\n req.proxy = proxy\n req.auth_type = auth_type\n req.insecure = insecure\n\n req.url = self.base_url.to_s + url.to_s\n raise ArgumentError, \"Empty URL\" if req.url.empty?\n\n handle_request(req)\n end", "def http_with_extra_config\n http = http_without_extra_config\n http.open_timeout = open_timeout if open_timeout\n http.read_timeout = read_timeout if read_timeout\n http\n end", "def initialize_http_handler(args = {})\n @http = HTTPHandler.new(args)\n logger.debug { \"Connection Set: #{http.to_s}\" }\n end", "def initialize_http_handler(args = {})\n @http = HTTPHandler.new(args)\n logger.debug { \"Connection Set: #{http.to_s}\" }\n end", "def dispatch_request(cli, request)\n # Is the client requesting keep-alive?\n if ((request['Connection']) and\n (request['Connection'].downcase == 'Keep-Alive'.downcase))\n cli.keepalive = true\n end\n\n # Search for the resource handler for the requested URL. This is pretty\n # inefficient right now, but we can spruce it up later.\n p = nil\n len = 0\n root = nil\n\n resources.each_pair { |k, val|\n if (request.resource =~ /^#{k}/ and k.length > len)\n p = val\n len = k.length\n root = k\n end\n }\n\n if (p)\n # Create an instance of the handler for this resource\n handler = p[0].new(self, *p[2])\n\n # If the handler class requires a relative resource...\n if (handler.relative_resource_required?)\n # Substituted the mount point root in the request to make things\n # relative to the mount point.\n request.relative_resource = request.resource.gsub(/^#{root}/, '')\n request.relative_resource = '/' + request.relative_resource if (request.relative_resource !~ /^\\//)\n end\n\n\n # If we found the resource handler for this resource, call its\n # procedure.\n if (p[1] == true)\n Rex::ThreadFactory.spawn(\"HTTPServerRequestHandler\", false) {\n handler.on_request(cli, request)\n }\n else\n handler.on_request(cli, request)\n end\n else\n elog(\"Failed to find handler for resource: #{request.resource}\", LogSource)\n\n send_e404(cli, request)\n end\n\n # If keep-alive isn't enabled for this client, close the connection\n if (cli.keepalive == false)\n close_client(cli)\n end\n end", "def handler_request!\n response = Core::HandlerResponse.new(\n @req.body,\n @req.code,\n @req.header.to_hash.inspect\n )\n populate_properties! if response.request_successful? && check_request\n end", "def make_request(options={}, &block)\n config = request_config options, &block\n\n action = config.delete :action\n ajax = config.delete :ajax\n http_method = config.delete :method\n http_method ||= guess_method_from_action action\n parameters = config\n\n if http_method.blank? || action.blank?\n msg = if http_method.blank? && action.blank?\n \":method and :action are unconfigured\"\n elsif http_method.blank?\n \":method unconfigured\"\n elsif action.blank?\n \":action unconfigured\"\n end\n raise IncompleteRequestError, msg\n end\n args = [http_method, action, parameters]\n args.unshift :xhr if ajax\n\n send(*args)\n end", "def perform!\n @request_time = Time.now\n\n http_resp = adapter.make_request(@method, @resource.uri, @body, @header)\n @response = Resourceful::Response.new(uri, *http_resp)\n @response.request_time = @request_time\n @response.authoritative = true\n\n @response\n end", "def call( env )\n resource_request = RESTRack::ResourceRequest.new( :request => Rack::Request.new(env) )\n unless @request_hook.nil? or (RESTRack::CONFIG.has_key?(:PRE_PROCESSOR_DISABLED) and RESTRack::CONFIG[:PRE_PROCESSOR_DISABLED])\n @request_hook.pre_processor(resource_request)\n end\n response = RESTRack::Response.new(resource_request)\n unless resource_request.requires_async_defer\n unless @request_hook.nil? or (RESTRack::CONFIG.has_key?(:POST_PROCESSOR_DISABLED) and RESTRack::CONFIG[:POST_PROCESSOR_DISABLED])\n @request_hook.post_processor(response)\n end\n env['async.callback'].call response.output\n end\n AsyncResponse\n end", "def http_builder(&block)\n @connection_builder = block || nil\n end", "def build_http(host, port)\n params = [host, port]\n params += @proxy_options.values_at(:host, :port, :user, :pass) unless @proxy_options.empty?\n http = add_ssl(Net::HTTP.new(*params))\n http = add_http_options(http) unless @http_options.empty?\n http\n end", "def initialize(url = nil, options = nil)\n options = ConnectionOptions.from(options)\n\n if url.is_a?(Hash) || url.is_a?(ConnectionOptions)\n options = options.merge(url)\n url = options.url\n end\n\n @parallel_manager = nil\n @headers = Utils::Headers.new\n @params = Utils::ParamsHash.new\n @options = options.request\n @ssl = options.ssl\n @default_parallel_manager = options.parallel_manager\n\n @builder = options.builder || begin\n # pass an empty block to Builder so it doesn't assume default middleware\n options.new_builder(block_given? ? Proc.new { |b| } : nil)\n end\n\n self.url_prefix = url || 'http:/'\n\n @params.update(options.params) if options.params\n @headers.update(options.headers) if options.headers\n\n @manual_proxy = !!options.proxy\n @proxy = options.proxy ? ProxyOptions.from(options.proxy) : proxy_from_env(url)\n @temp_proxy = @proxy\n\n yield(self) if block_given?\n\n @headers[:user_agent] ||= \"Faraday v#{VERSION}\"\n end", "def request(message, response_size = 0, &the_block)\n @q.push([message, response_size, the_block])\n end", "def request(host, port, method, uri, params = {}, data = {}, headers = {}, auth = nil, timeout = nil) # rubocop:disable Metrics/MethodLength\n auth ||= @auth\n headers = generate_headers(method, headers)\n uri = build_uri(uri)\n\n if @logger\n @logger.debug('--BEGIN Twilio API Request--')\n @logger.debug(\"Request Method: <#{method}>\")\n\n headers.each do |key, value|\n @logger.debug(\"#{key}:#{value}\") unless key.downcase == 'authorization'\n end\n\n url = URI(uri)\n @logger.debug(\"Host:#{url.host}\")\n @logger.debug(\"Path:#{url.path}\")\n @logger.debug(\"Query:#{url.query}\")\n @logger.debug(\"Request Params:#{params}\")\n end\n\n response = @http_client.request(\n host,\n port,\n method,\n uri,\n params,\n data,\n headers,\n auth,\n timeout\n )\n\n if @logger\n @logger.debug(\"Response Status Code:#{response.status_code}\")\n @logger.debug(\"Response Headers:#{response.headers}\")\n @logger.debug('--END TWILIO API REQUEST--')\n end\n\n response\n end", "def make_request(req)\n if @http && @http.address == req.uri.host && !@http.started?\n @http.start\n else\n @http = Net::HTTP.new(req.uri.host, req.uri.port)\n @http.use_ssl = req.ssl?\n @http.verify_mode = OpenSSL::SSL::VERIFY_NONE if req.ssl?\n @http.set_debug_output($stderr) if req.debug\n @http.start\n end\n @http.request(req.http_request)\n end", "def dispatch request, options\n url = options.fetch :to\n\n if url.relative?\n url = URI.join \"#{OBIX.configuration.scheme}://#{OBIX.configuration.host}\", url\n end\n\n options = {\n open_timeout: 30,\n read_timeout: OBIX.configuration.timeout\n }\n\n if OBIX.configuration.scheme == \"https\"\n options[:use_ssl] = true\n options[:verify_mode] = OpenSSL::SSL::VERIFY_NONE\n end\n\n response_from(request, url, options)\n end", "def perform_request\n returned = nil\n @requests ||= 0\n @requests += 1\n @request_time ||= 0\n @request_time += Benchmark.realtime { returned = yield }\n returned\n ensure\n @handlers.each { |handler| handler.call(@requests, @request_time) }\n end", "def create_http_request(http_method, path, *arguments)\n http_method = http_method.to_sym\n\n if [:post, :put, :patch].include?(http_method)\n data = arguments.shift\n end\n\n # if the base site contains a path, add it now\n uri = URI.parse(site)\n path = uri.path + path if uri.path && uri.path != '/'\n\n headers = arguments.first.is_a?(Hash) ? arguments.shift : {}\n\n case http_method\n when :post\n request = Net::HTTP::Post.new(path,headers)\n request[\"Content-Length\"] = '0' # Default to 0\n when :put\n request = Net::HTTP::Put.new(path,headers)\n request[\"Content-Length\"] = '0' # Default to 0\n when :patch\n request = Net::HTTP::Patch.new(path,headers)\n request[\"Content-Length\"] = '0' # Default to 0\n when :get\n request = Net::HTTP::Get.new(path,headers)\n when :delete\n request = Net::HTTP::Delete.new(path,headers)\n when :head\n request = Net::HTTP::Head.new(path,headers)\n else\n raise ArgumentError, \"Don't know how to handle http_method: :#{http_method.to_s}\"\n end\n\n if data.is_a?(Hash)\n request.body = OAuth::Helper.normalize(data)\n request.content_type = 'application/x-www-form-urlencoded'\n elsif data\n if data.respond_to?(:read)\n request.body_stream = data\n if data.respond_to?(:length)\n request[\"Content-Length\"] = data.length.to_s\n elsif data.respond_to?(:stat) && data.stat.respond_to?(:size)\n request[\"Content-Length\"] = data.stat.size.to_s\n else\n raise ArgumentError, \"Don't know how to send a body_stream that doesn't respond to .length or .stat.size\"\n end\n else\n request.body = data.to_s\n request[\"Content-Length\"] = request.body.length.to_s\n end\n end\n\n request\n end", "def build_request\n client.request request_name\n end", "def create_http_request(http_method,path,*arguments)\n http_method=http_method.to_sym\n if [:post,:put].include?(http_method)\n data=arguments.shift\n end\n headers=(arguments.first.is_a?(Hash) ? arguments.shift : {})\n case http_method\n when :post\n request=Net::HTTP::Post.new(path,headers)\n request[\"Content-Length\"]=0 # Default to 0\n when :put\n request=Net::HTTP::Put.new(path,headers)\n request[\"Content-Length\"]=0 # Default to 0\n when :get\n request=Net::HTTP::Get.new(path,headers)\n when :delete\n request=Net::HTTP::Delete.new(path,headers)\n when :head\n request=Net::HTTP::Head.new(path,headers)\n else\n raise ArgumentError, \"Don't know how to handle http_method: :#{http_method.to_s}\"\n end\n if data.is_a?(Hash)\n request.set_form_data(data)\n elsif data\n request.body=data.to_s\n request[\"Content-Length\"]=request.body.length\n end\n request\n end", "def add_response_handler(&block)\n Listener.new(&block).tap do |listener|\n listener.stopback{ listener.succeed }\n add_to_listener_pool(listener)\n end\n end", "def perform_proxy_request(req, res)\n uri = req.request_uri\n header = setup_proxy_header(req, res)\n # upstream = setup_upstream_proxy_authentication(req, res, header)\n response = nil\n\n http = Net::HTTP.new(uri.host, uri.port) # upstream.host, upstream.port)\n\n # HERE is what I add: SSL support\n if http.use_ssl = (uri.scheme == 'https' || uri.port == 443)\n http.verify_mode = OpenSSL::SSL::VERIFY_PEER\n http.cert_store = ssl_cert_store\n end\n\n http.start do\n if @config[:ProxyTimeout]\n ################################## these issues are\n http.open_timeout = 30 # secs # necessary (maybe bacause\n http.read_timeout = 60 # secs # Ruby's bug, but why?)\n ##################################\n end\n response = yield(http, uri.request_uri, header)\n end\n\n # Persistent connection requirements are mysterious for me.\n # So I will close the connection in every response.\n res['proxy-connection'] = \"close\"\n res['connection'] = \"close\"\n\n # Convert Net::HTTP::HTTPResponse to WEBrick::HTTPResponse\n res.status = response.code.to_i\n choose_header(response, res)\n set_cookie(response, res)\n set_via(res)\n res.body = response.body\n end", "def execute_http_request(http, request)\n @response = http.request(request)\n @http_headers = {}\nend", "def api(method, url, options = {})\n unless [:get, :delete, :post, :put, :patch].include? method\n raise \"Unknown REST method: #{method}\"\n end\n \n config = RequestConfig.new\n config.authorization_bearer = @authorization_bearer\n config.method = method\n config.access_token = options[:access_token]\n config.request_params = options[:request_params]\n config.request_body = options[:request_body]\n config.content_type = \"application/json\" unless url == @refresh_token_url\n config.form_encoding = true if url == @refresh_token_url\n refresh_token = options[:refresh_token]\n user_uid = options[:user_uid]\n\n puts \"*\" * 88\n puts url.to_s\n puts method.to_s\n configp = config.dup\n puts configp.finalize!.to_hash.inspect\n puts \"*\" * 88\n \n request = Typhoeus::Request.new url, config.finalize!\n request.on_complete do |response|\n case\n when response.success?\n puts \"Success\"\n @callback_request_made.call\n return Echidna::Response.new response\n when response.timed_out?\n puts \"Timed out. Is google down?\"\n return Echidna::Error.new response\n when response.code == 401\n puts \"In refresh block\"\n if refresh_token && @client_id && @client_secret\n new_access_token = fetch_new_access_token(user_uid, refresh_token)\n options.delete(:refresh_token)\n options[:access_token] = new_access_token\n return api(method, url, options)\n else\n return Echidna::Error.new response\n end\n when response.code == 0\n puts\"Could not get an http response, something's wrong.\"\n return Echidna::Error.new response\n else\n puts \"HTTP request failed: #{response.code}\"\n return Echidna::Error.new response\n end\n end\n \n @hydra.queue(request)\n @hydra.run\n \n request\n end", "def call_options_builder(method, url, payload = nil, headers = nil)\n @http_opt[:headers].update(headers) unless headers.nil?\n options = { method: method, url: url }.merge(@http_opt)\n options[:payload] = payload unless payload.nil?\n options\n end", "def execute!\n validate_request!\n\n build_response!\n end", "def request_content\n @request_content ||= begin\n uri = URI(http_request[:url])\n req = Net::HTTP::Post.new(uri.path, http_request[:headers])\n\n # Add task headers\n req[Cloudtasker::Config::TASK_ID_HEADER] = id\n req[Cloudtasker::Config::RETRY_HEADER] = retries\n\n # Set job payload\n req.body = http_request[:body]\n req\n end\n end", "def request(method, *args, &response_cb)\n reqid = @request_id\n @request_id += 1\n\n @serializer.write([0, reqid, method, args])\n @pending_requests[reqid] = response_cb || Proc.new {}\n self\n end", "def async_http\n unless @proxy.empty?\n proxy_opts = @proxy.dup\n proxy_opts[:authorization] = [\n proxy_opts.delete(:username),\n proxy_opts.delete(:password)\n ] if proxy_opts[:username] || proxy_opts[:password]\n end\n\n EventMachine::HttpRequest.new @uri,\n :connect_timeout => @timeout,\n :inactivity_timeout => @timeout,\n :proxy => proxy_opts\n end", "def do_request(request, want_reply, data); end", "def setup_request\n return Typhoeus::Request.new(\n endpoint_url,\n method: @method,\n params: @params,\n body: @body,\n headers: @headers)\n end", "def create_http(_url = nil)\n\n\n if !request_endpoint.nil?\n _url = request_endpoint\n end\n\n\n if _url.nil? || _url[0] =~ /^\\//\n our_uri = URI.parse(site)\n else\n our_uri = URI.parse(_url)\n end\n\n\n if proxy.nil?\n http_object = Net::HTTP.new(our_uri.host, our_uri.port)\n else\n proxy_uri = proxy.is_a?(URI) ? proxy : URI.parse(proxy)\n http_object = Net::HTTP.new(our_uri.host, our_uri.port, proxy_uri.host, proxy_uri.port, proxy_uri.user, proxy_uri.password)\n end\n\n http_object.use_ssl = (our_uri.scheme == 'https')\n\n if @options[:ca_file] || CA_FILE\n http_object.ca_file = @options[:ca_file] || CA_FILE\n http_object.verify_mode = OpenSSL::SSL::VERIFY_PEER\n http_object.verify_depth = 5\n else\n http_object.verify_mode = OpenSSL::SSL::VERIFY_NONE\n end\n\n http_object.read_timeout = http_object.open_timeout = @options[:timeout] || 30\n http_object.open_timeout = @options[:open_timeout] if @options[:open_timeout]\n\n http_object\n end", "def set_callbacks\n Curl.set_option(:writefunction, body_write_callback, handle)\n Curl.set_option(:headerfunction, header_write_callback, handle)\n Curl.set_option(:debugfunction, debug_callback, handle)\n @response_body = String.new\n @response_headers = String.new\n @headers_called = false\n @debug_info = Ethon::Easy::DebugInfo.new\n end", "def initialize(options)\n initialize_options(options)\n initialize_headers\n http_request\n end", "def create_request(method, path, options)\n version = options.has_key?(:api_version) ? \"/#{options[:api_version]}\" : \"\"\n\n path = \"#{version}#{path}\"\n\n instance_eval <<-RUBY, __FILE__, __LINE__ + 1\n @client.#{method}(path) do |req|\n req.body = options[:body]\n req.headers.update(options[:headers])\n req.params.update(options[:query]) if options[:query]\n end\n RUBY\n end", "def wrapped_request(method, path, expected_responses, parameters = {})\n _wrapped_request(method, path, expected_responses, parameters)\n end", "def perform_request(command, request, additional = nil, server = nil)\n if server\n attempts = 1\n else\n server = case request\n when String\n Zlib.crc32(request)\n when Request\n request.crc32\n else\n raise ArgumentError, \"request argument must be String or Sphinx::Request\"\n end\n attempts = nil\n end\n\n with_server(server, attempts) do |server|\n logger.info { \"[sphinx] #{command} on server #{server}\" } if logger\n\n cmd = command.to_s.upcase\n command_id = Sphinx::Client.const_get(\"SEARCHD_COMMAND_#{cmd}\")\n command_ver = Sphinx::Client.const_get(\"VER_COMMAND_#{cmd}\")\n\n with_socket(server) do |socket|\n len = request.to_s.length + (additional.nil? ? 0 : 4)\n header = [command_id, command_ver, len].pack('nnN')\n header << [additional].pack('N') unless additional.nil?\n\n socket.write(header + request.to_s)\n\n if block_given?\n yield server, socket\n else\n parse_response(socket, command_ver)\n end\n end\n end\n end", "def request(req, body = nil, &block)\n response = alias_for_request(req, body)\n\n if NetRecorder.recording?\n scope = NetRecorder.scope || 'global'\n path = \"http://#{req.bauth if req.bauth}#{req['host']}#{req.path}\"\n\n existing_fake = @@fakes.detect{|fake| fake[0] == path && fake[1][scope] && fake[1][scope][:method] == req.method}\n existing_fake[1][scope][:response] << {:response => response} and return response if existing_fake\n\n @@fakes << [path, {scope => {:method => req.method, :response => [{:response => response}]}}]\n end\n\n yield response if block\n response\n end", "def make_request(type, headers = nil, body = nil)\n request = \"#{type.to_s.upcase} #{@path} HTTP/1.0\\r\\n\"\n request << add_headers(headers) if headers\n request << \"\\r\\n\"\n request << body if body\n request\n end", "def initialize(**args)\n raise ArgumentError, \"args must be a Hash!\" unless args.is_a?(Hash)\n\n @url = args.fetch(:url)\n @method = args.fetch(:method).to_s.downcase\n @headers = (args[:headers] || {}).dup\n @payload = args[:payload]\n @timeout = args.fetch(:timeout, ProxyFetcher.config.client_timeout)\n @ssl_options = args.fetch(:ssl_options, default_ssl_options)\n\n @proxy = args.fetch(:proxy)\n @max_redirects = args.fetch(:max_redirects, 10)\n\n @http = build_http_client\n end", "def make_request(*args)\n command = __callee__\n request_packet = @formatter.send(command, *args)\n request = Request.new(request_packet, command)\n res = get_response_with_logging(request)\n yield res if block_given?\n res\n end", "def create_request(url, options)\n @url = url\n @options = options\n end", "def send_request(request)\n connect\n @handler.enqueue_request(request)\n end" ]
[ "0.5867015", "0.5827443", "0.5689182", "0.56365407", "0.53842497", "0.5358803", "0.53440934", "0.5326121", "0.53191715", "0.5239235", "0.5218071", "0.5206298", "0.5198162", "0.51842266", "0.51709586", "0.5157912", "0.5140975", "0.5109453", "0.5106532", "0.51051325", "0.50820607", "0.5068523", "0.50433826", "0.50106746", "0.5003332", "0.50001746", "0.49751014", "0.4971967", "0.49555832", "0.4952096", "0.49111766", "0.49062216", "0.49026603", "0.4895991", "0.48890662", "0.48844296", "0.4882041", "0.4876447", "0.4871765", "0.48657435", "0.48610598", "0.48610598", "0.48475334", "0.48456374", "0.4838187", "0.48372832", "0.48304665", "0.48165253", "0.48149726", "0.48068872", "0.4806741", "0.479982", "0.47892827", "0.47852495", "0.4783583", "0.47790495", "0.47734928", "0.47601002", "0.47593713", "0.4755312", "0.47467166", "0.4739028", "0.47310936", "0.47299895", "0.47117034", "0.47093028", "0.46992537", "0.4696069", "0.46927056", "0.4691837", "0.46876815", "0.46863103", "0.46856895", "0.46733314", "0.46691442", "0.46645463", "0.4652201", "0.4651192", "0.4649118", "0.4646298", "0.46412733", "0.46304217", "0.4623568", "0.46180293", "0.46167374", "0.46159506", "0.46151498", "0.46119598", "0.46072066", "0.46024036", "0.45940673", "0.45927757", "0.459086", "0.45890555", "0.45837808", "0.45773622", "0.4576743", "0.4576525", "0.45743218", "0.45679766" ]
0.6955892
0
Sends a synchronous POST request. On success, yields any returned data; on error, yields any provided default data or +nil+. Recognizes the following options: +headers+ a hash to add or update the request headers +timeout+ the timeout for the request (defaults to +Ladon.default_request_timeout+) +default_data+ passes this on to +handle_response+
def fire_post(url_or_path, entity, options = {}, &block) url = absolute_url(url_or_path) headers = {:Accept => MEDIA_TYPE_JSON, :'Content-type' => ENCODED_MEDIA_TYPE_JSON}. merge(options.fetch(:headers, {})) headers = merge_log_weasel_header(headers) timeout = options.fetch(:timeout, Ladon.default_request_timeout) body = encode_entity(entity) response = Typhoeus::Request.post(url, headers: headers, timeout: timeout, body: body) handle_response(response, method: :post, url: url, default_data: options[:default_data], raise_on_error: options[:raise_on_error], &block) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def post(data = nil, options = nil)\n options ||= {}\n options[:method] = :post\n call data, options\n end", "def post(options={}, &block)\n response = http.post_uri(options.merge(:body => serialize), &block)\n handle_response(response)\n end", "def make_post_request url, body, headers = []\n make_request url, method: ::Rack::POST, body: body, headers: headers\n end", "def post(url, post_data, custom_headers = {})\n headers = @default_headers.merge(custom_headers)\n # slow down the request rate! otherwise you will get blocked\n sleep 1\n return @agent.post(url, post_data, headers)\n end", "def post(url, options = {}, &block)\n request HttpPost, url, options, &block\n end", "def do_request\n\t\t\tself.response = post_request(options)\n\t\tend", "def POST(data=nil, headers=nil)\n\n\t\tif not data.nil? #if request data passed in, use it.\n\t\t\t@data = data\n\t\tend\n\n\t\turi = URI(@url)\n\t\thttp = Net::HTTP.new(uri.host, uri.port)\n\t\thttp.use_ssl = true\n\t\trequest = Net::HTTP::Post.new(uri.path)\n\t\trequest.body = @data\n\n\t\tif @search_type == 'premium'\n\t\t\trequest['Authorization'] = \"Bearer #{@app_token}\"\n\t\telse\n\t\t\trequest.basic_auth(@app_token, @password)\n\t\tend\n\n\t\tbegin\n\t\t\tresponse = http.request(request)\n\t\trescue\n\t\t\tlogger()\n\t\t\tsleep 5\n\t\t\tresponse = http.request(request) #try again\n\t\tend\n\n\t\treturn response\n\tend", "def post(url, data={}, headers={}, http_options={})\n # determine the http options\n redirect_limit = http_options[:max_redirects] || max_redirects\n gateway_retries = http_options[:gateway_retry_limit] || gateway_retry_limit\n gateway_delay = http_options[:gateway_retry_delay] || gateway_retry_delay\n\n # parse the URL\n uri = URI.parse(url)\n\n # unless the data is already a string, assume JSON and convert to string\n data = data.to_json unless data.is_a? String\n # build the http object\n http = build_http(uri)\n # build the request\n request = Net::HTTP::Post.new(uri.request_uri, headers)\n request.body = data\n\n # send the request\n begin\n response = http.request(request)\n # handle the response\n case response\n # handle 302\n when Net::HTTPRedirection then\n if redirect_limit == -1\n HttpResponse.new(response)\n elsif redirect_limit == 0\n raise Net::HTTPFatalError.new(\"Too many redirects\", response)\n else\n post(response['location'], data, headers, http_options.merge({\n :max_redirects => redirect_limit - 1\n }))\n end\n # handle 502, 503, 504\n when Net::HTTPBadGateway, Net::HTTPServiceUnavailable, Net::HTTPGatewayTimeOut then\n if gateway_retries == -1\n HttpResponse.new(response)\n elsif gateway_retries == 0\n Kinetic::Platform.logger.info(\"HTTP response: #{response.code} #{response.message}\")\n raise Net::HTTPFatalError.new(\"#{response.code} #{response.message}\", response)\n else\n Kinetic::Platform.logger.info(\"#{response.code} #{response.message}, retrying in #{gateway_delay} seconds\")\n sleep(gateway_delay)\n post(url, data, headers, http_options.merge({\n :gateway_retry_limit => gateway_retries - 1\n }))\n end\n when Net::HTTPUnknownResponse, NilClass then\n Kinetic::Platform.logger.info(\"HTTP response code: 0\")\n e = Net::HTTPFatalError.new(\"Unknown response from server\", response)\n HttpResponse.new(e)\n else\n Kinetic::Platform.logger.info(\"HTTP response code: #{response.code}\")\n HttpResponse.new(response)\n end\n rescue Net::HTTPBadResponse => e\n Kinetic::Platform.logger.info(\"HTTP bad response: #{e.inspect}\")\n HttpResponse.new(e)\n rescue StandardError => e\n Kinetic::Platform.logger.info(\"HTTP error: #{e.inspect}\")\n HttpResponse.new(e)\n end\n end", "def post(data = {})\n call data, method: :post\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(url, data={}, headers={}, redirect_limit=max_redirects)\n # parse the URL\n uri = URI.parse(url)\n\n debug(\"POST #{uri} #{headers.inspect}\")\n\n # unless the data is already a string, assume JSON and convert to string\n data = data.to_json unless data.is_a? String\n # build the http object\n http = build_http(uri)\n # build the request\n request = Net::HTTP::Post.new(uri.request_uri, headers)\n request.body = data\n\n # send the request\n begin\n response = http.request(request)\n # handle the response\n case response\n when Net::HTTPRedirection then\n raise Net::HTTPFatalError.new(\"Too many redirects\", response) if redirect_limit == 0\n post_raw(response['location'], data, headers, redirect_limit - 1)\n else\n KineticHttpResponse.new(response)\n end\n rescue StandardError => e\n KineticHttpResponse.new(e)\n end\n end", "def post(url, data={}, headers={}, http_options=@options)\n # determine the http options\n redirect_limit = http_options[:max_redirects] || max_redirects\n gateway_retries = http_options[:gateway_retry_limit] || gateway_retry_limit\n gateway_delay = http_options[:gateway_retry_delay] || gateway_retry_delay\n\n # parse the URL\n uri = URI.parse(url)\n\n @logger.debug(\"POST #{uri} #{headers.inspect}\")\n\n # unless the data is already a string, assume JSON and convert to string\n data = data.to_json unless data.is_a? String\n # build the http object\n http = build_http(uri)\n # build the request\n request = Net::HTTP::Post.new(uri.request_uri, headers)\n request.body = data\n\n # send the request\n begin\n response = http.request(request)\n # handle the response\n case response\n when Net::HTTPRedirection then\n if redirect_limit == -1\n @logger.info(\"HTTP response code: #{response.code}\") unless @logger.debug?\n KineticHttpResponse.new(response)\n elsif redirect_limit == 0\n raise Net::HTTPFatalError.new(\"Too many redirects\", response)\n else\n post(response['location'], data, headers, http_options.merge({\n :max_redirects => redirect_limit - 1\n }))\n end\n # handle 502, 503, 504\n when Net::HTTPBadGateway, Net::HTTPServiceUnavailable, Net::HTTPGatewayTimeOut then\n if gateway_retries == -1\n KineticHttpResponse.new(response)\n elsif gateway_retries == 0\n @logger.info(\"HTTP response: #{response.code} #{response.message}\") unless @logger.debug?\n raise Net::HTTPFatalError.new(\"#{response.code} #{response.message}\", response)\n else\n @logger.info(\"#{response.code} #{response.message}, retrying in #{gateway_delay} seconds\")\n sleep(gateway_delay)\n post(url, data, headers, http_options.merge({\n :gateway_retry_limit => gateway_retries - 1\n }))\n end\n when Net::HTTPUnknownResponse, NilClass then\n @logger.info(\"HTTP response code: 0\") unless @logger.debug?\n e = Net::HTTPFatalError.new(\"Unknown response from server\", response)\n KineticHttpResponse.new(e)\n else\n @logger.info(\"HTTP response code: #{response.code}\") unless @logger.debug?\n KineticHttpResponse.new(response)\n end\n rescue Net::HTTPBadResponse => e\n @logger.info(\"HTTP bad response: #{e.inspect}\") unless @logger.debug?\n KineticHttpResponse.new(e)\n rescue StandardError => e\n @logger.info(\"HTTP error: #{e.inspect}\") unless @logger.debug?\n KineticHttpResponse.new(e)\n end\n end", "def send\n http = EM::HttpRequest.new(@uri).post(@request_options)\n\n http.callback do\n process(http.response)\n end\n\n http.errback do\n fail(http.error)\n end\n end", "def http_post(path, data, headers = {})\n clear_response\n path = process_path(path)\n @success_code = 201\n @response = http.post(path, data, headers)\n parse_response? ? parsed_response : response.body\n end", "def post(url, body, headers: {}, params: {}, options: {}, &block)\n raise ArgumentError, \"'post' requires a string 'body' argument\" unless body.is_a?(String)\n url = encode_query(url, params)\n\n request = Net::HTTP::Post.new(url, @default_headers.merge(headers))\n request.body = body\n request.content_length = body.bytesize\n\n raise ArgumentError, \"'post' requires a 'content-type' header\" unless request['Content-Type']\n\n execute_streaming(request, options: options, &block)\n end", "def post(url, options = {}, &block)\n run! Request.new(url, :post, options.slice(:headers, :params, :payload), &block)\n end", "def exec_post(req, data, exit_on_fail = false)\n response_hash = exec_api_call('POST', req, data, exit_on_fail)\n response_hash[:response]\n end", "def do_post(request, out_stream)\n raise Error.new(\"HTTPS over a proxy is not supported.\") if !@use_http and @proxy_host\n\n reset_response_data()\n\n request.basic_auth(@user_name, @api_key)\n request.add_field('User-Agent', @user_agent)\n\n while true\n begin\n return exec_request(request, out_stream)\n rescue Error => err\n if (err.getCode() == '502' or err.getCode() == '503') and @retry_count > @retry\n @retry += 1\n sleep(@retry * 0.1)\n else\n raise\n end\n end\n end\n end", "def post_request(request_data = {}, errback = DEFAULT_ERROR, &blk)\n req = create_test_request(request_data).post(request_data)\n hookup_request_callbacks(req, errback, &blk)\n end", "def post options={}, &block\n handle_exceptions do\n Chimps.log.info(\"POST #{url}\")\n Response.new(super(encoded_body, options, &block))\n end\n end", "def post\n RestClient.post(url, @body, @header) do |rso, req, res|\n setup(rso, req, res)\n end\n end", "def post(url, body = nil, headers = nil)\n faraday_response = faraday.post(url, body, headers) do\n _1.options[:proxy] = random_proxy\n end\n Response.new(faraday_response)\n end", "def post(path, data, params = {}, request_options = {})\n request(:post, path, data, params)\n end", "def post(url, data, headers = {})\n request(:post, url, headers, :data => data)\n end", "def post_request(path, params={}, options={})\n request(:post, path, params, options)\n end", "def post query=nil, content_type='application/x-www-form-urlencoded'\n\t\treq = Net::HTTP::Post.new(@uri.path)\n\n\t\treq.body= make_query query if query\n\t\treq.content_type=content_type if query\n\t\treq.content_length=query ? req.body.length : 0\n\n\t\tdo_http req\n\tend", "def post(path, body: nil, **params)\n return sync_post(path, params: params, body: body) unless Async::Task.current?\n\n async_post(path, params: params, body: body)\n end", "def post(options = {})\n url = build_url(options)\n ret = post_response(url, options)\n ret\n end", "def post(path, data, initheader = nil, dest = nil, &block) #:nodoc:\n res = nil\n\n req = Post.new(path, initheader); req.set_form_data(data)\n request(req) {|r| r.read_body dest, &block; res = r}\n\n unless @newimpl\n res.value\n return res, res.body\n end\n\n res\n end", "def post(path, options={}, raw=false)\n request(:post, path, options, raw)\n end", "def perform_post(path, options = {})\n perform_request(:post, path, options)\n end", "def post_request(url, data:, headers: { \"Content-Type\" => \"application/x-www-form-urlencoded\" })\n if driver_type == :mechanize\n begin\n set_delay(delay) if delay\n check_request_options\n\n self.class.stats[:requests] += 1\n stats[:requests] += 1\n logger.info \"Session: started post request to: #{visit_uri}\"\n\n driver.browser.agent.post(url, data, headers)\n\n self.class.stats[:responses] += 1\n stats[:responses] += 1\n logger.info \"Session: finished post request to: #{visit_uri}\"\n rescue => e\n raise e\n ensure\n print_stats\n end\n else\n raise \"Not implemented in this driver\"\n end\n end", "def post(path, options = {}, raw = false)\n request(:post, path, options, raw)\n end", "def post(path, options = {}, raw = false)\n request(:post, path, options, raw)\n end", "def http_post_request\n begin\n return http_client.post(http_path_query, compressed_request, http_headers)\n rescue APIKeyError\n log 'error - you must set your api_key.'\n rescue TimeoutError\n log 'fail - timeout while contacting the api server.'\n rescue Exception => e\n log \"fail - exception raised during http post. (#{e.class.name}: #{e.message})\"\n end\n nil\n end", "def post_async(body = '', headers = {}, parameters = {}, &block)\n @asynchronous_backend.execute(build_post(body, headers, parameters, &block))\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(path, headers, body, &callback)\n request('POST', path, headers, body, &callback)\n end", "def post(data, options={})\n @hal_client.post(href, data, options).tap do\n reset\n end\n end", "def post(uri, options = T.unsafe(nil)); end", "def post(path, options = {}, signature = false, raw = false, unformatted = false, no_response_wrapper = self.no_response_wrapper, signed = sign_requests)\n request(:post, path, options, signature, raw, unformatted, no_response_wrapper, signed)\n end", "def POST(data=nil)\n\n if not data.nil? #if request data passed in, use it.\n @data = data\n end\n\n uri = URI(@url)\n http = Net::HTTP.new(uri.host, uri.port)\n http.use_ssl = true\n if @set_cert_file\n http = set_cert_file(http)\n end\n request = Net::HTTP::Post.new(uri.path)\n request.body = @data\n request.basic_auth(@user_name, @password)\n\n response = http.request(request)\n return response\n end", "def send_request(req, timeout = nil)\n send_update(req, timeout)\n return read_response(timeout)\n end", "def post(path, data=nil)\n request(:post, path, data)\n end", "def post endpoint, data\n do_request :post, endpoint, data\n end", "def post(path, data={})\n request(:post, path, data)\n end", "def post(url, req_hash={})\n res = nil\n res = perform_op(:post, req_hash) do\n res = @wrapper.post(url, req_hash)\n end\n return res\n end", "def post(url, body, headers = {})\n do_request Net::HTTP::Post, url, headers, body\n end", "def post(path, data = { }, query = { }, headers = { })\n clear_response\n path = process_path(path, query)\n @success_code = 201\n @response = http.post(path, data, headers)\n parse_response? ? parsed_response : response.body\n end", "def post(path, *data, &block)\n map(path, R3::POST, *data, &block)\n end", "def post(path, options={})\n send_request 'post', path, options\n end", "def post(path, query_string, data)\n # ...and delegate to the Faraday connection we created on initilization\n @conn.post \"#{path}?#{query_string}\", data\n end", "def http_post(path, data, content_type = 'application/json')\n http_methods(path, :post, data, content_type)\n end", "def transactions_post_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: DefaultApi.transactions_post ...'\n end\n # resource path\n local_var_path = '/api/v1/transactions'\n\n # query parameters\n query_params = opts[:query_params] || {}\n query_params[:'addrs'] = opts[:'addrs'] if !opts[:'addrs'].nil?\n query_params[:'confirmed'] = opts[:'confirmed'] if !opts[:'confirmed'].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', 'application/xml', ])\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] || 'Object' \n\n # auth_names\n auth_names = opts[:auth_names] || ['csrfAuth']\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(:POST, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: DefaultApi#transactions_post\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def send(parameters = @parameters)\n raise 'the request has not been opened' unless opened?\n\n raise 'the request has already been sent' if sent?\n\n # try to circumvent caching setting an If-Modified-Since header with a very\n # old date\n unless cacheable?\n `#@native.setRequestHeader(\"If-Modified-Since\", \"Tue, 11 Sep 2001 12:46:00 GMT\")`\n end\n\n @headers.each {|name, value|\n `#@native.setRequestHeader(#{name.to_s}, #{value.to_s})`\n }\n\n if @content_type\n header = @content_type\n header += \"; charset=#{@encoding}\" if @encoding\n\n `#@native.setRequestHeader('Content-Type', header)`\n end\n\n if binary?\n if Buffer.supported?\n `#@native.responseType = 'arraybuffer'`\n else\n `#@native.overrideMimeType('text/plain; charset=x-user-defined')`\n end\n end\n\n if mime_type && !binary?\n `#@native.overrideMimeType(#@mime_type)`\n end\n\n @sent = true\n @response = Response.new(self)\n\n if String === parameters\n data = parameters\n elsif (Hash === parameters && !parameters.empty?) || FormData === parameters\n data = if Hash === parameters\n if FormData.contain_files?(parameters)\n FormData.build_form_data(parameters)\n else\n FormData.build_query(parameters)\n end\n else #if FormData === parameters\n parameters\n end\n\n unless @content_type\n if FormData === data\n # I thought it's done this way, but it isn't. It actually is\n # \"multipart/form-data; boundary=-----------.......\". Let's miss it\n # purposefully, because it's filled in automatically in this example.\n # `#@native.setRequestHeader('Content-Type', 'multipart/form-data')`\n else\n `#@native.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded')`\n end\n end\n\n data = data.to_n\n else\n data = `null`\n end\n\n `#@native.send(#{data})`\n\n @response\n end", "def post(path, options={}, &block)\n headers = options.delete :headers\n data = options.delete :data\n content_type = (headers && headers['Content-Type']) || content_type(data)\n\n request = Net::HTTP::Post.new path, headers\n\n # convert hash data to array data\n data = data.inject([]) do |memo, (key, value)|\n if value.is_a?(File)\n memo << [key.to_s, value, { content_type: Utils.mime_type(value.path) }]\n else\n memo << [key.to_s, value]\n end\n end\n\n request.set_form data, content_type\n\n @http.request request, &block\n end", "def send_request(batch)\n payload = batch.to_s\n request = Net::HTTP::Post.new(@path, @headers)\n\n if self.class.stub\n logger.debug \"stubbed request to #{@path}: \" \\\n \"batch = '#{batch}'\"\n\n [200, '', 'OK']\n else\n # If `start` is not called, Ruby adds a 'Connection: close' header to\n # all requests, preventing us from reusing a connection for multiple\n # HTTP requests\n @http.start unless @http.started?\n\n response = @http.request(request, payload)\n [response.code.to_i, response.body, response.message]\n end\n end", "def outputs_post_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: DefaultApi.outputs_post ...'\n end\n # resource path\n local_var_path = '/api/v1/outputs'\n\n # query parameters\n query_params = opts[:query_params] || {}\n query_params[:'address'] = opts[:'address'] if !opts[:'address'].nil?\n query_params[:'hash'] = opts[:'hash'] if !opts[:'hash'].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', 'application/xml', ])\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] || 'Object' \n\n # auth_names\n auth_names = opts[:auth_names] || ['csrfAuth']\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(:POST, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: DefaultApi#outputs_post\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def post(path, options = {}, &block)\n map(path, options, :post, &block)\n end", "def post(path, opts = {}, &block)\n request(:post, path, opts, &block)\n end", "def post(path, opts = {}, &block)\n request(:post, path, opts, &block)\n end", "def make_post_request(route:, headers: nil, body: nil)\n post route, params: body, headers: headers\nend", "def send!\n request = Net::HTTP::Post.new(uri.path, headers)\n request.body = @body\n request.content_type = @@content_type\n response = Net::HTTP.start(uri.host, uri.port) do |http|\n http.request(request)\n end\n ok?(response)\n end", "def post(path = nil, options = {})\n connection.post(path, options)\n end", "def raw_post(path, body, options = {})\n # Allow format override\n format = options.delete(:format) || @format\n # Clear cache\n expire_matching \"#{raw_path(path)}.*\"\n # Create POST request\n post = Typhoeus::Request.new(\"#{protocol}#{@server}#{path}\", \n :verbose => DEBUG,\n :method => \"post\",\n :body => body,\n :headers => { :'Content-type' => options[:content_type] || content_type(format) }\n )\n\n # Send request\n do_request(post, format)\n end", "def do_post(uri = \"\", body = \"\")\n @connection.post do |req|\n req.url uri\n req.headers['Content-Type'] = 'application/json'\n req.body = body\n end\n rescue Faraday::Error::ConnectionFailed => e\n $lxca_log.error \"XClarityClient::XclarityBase do_post\", \"Error trying to send a POST to #{uri}\"\n $lxca_log.error \"XClarityClient::XclarityBase do_post\", \"Request sent: #{body}\"\n Faraday::Response.new\n end", "def post(path, data, headers = {})\n request(:post, path, data, headers).body\n end", "def post(path, options={})\n response = request(path, :post, options)\n validate response\n parsed_response = parse response\n data = { headers: response.headers, body: parsed_response }\n end", "def post *args, &block\n handle @conn.post *args, &block\n end", "def post()\n return @http.request(@req)\n end", "def post(url, options)\n headers = options[:headers] || {}\n params = options[:params] || {}\n req = Net::HTTP::Post.new(url)\n req = request_with_headers(req, headers)\n request_with_params(req, params)\n end", "def queue_request(url_or_path, options = {}, &block)\n url = absolute_url(url_or_path)\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 request = Typhoeus::Request.new(url, headers: headers, timeout: timeout)\n request.on_complete do |response|\n handle_response(response, request: request, default_data: options[:default_data], &block)\n end\n Ladon.hydra.queue(request)\n end", "def post url, body, headers = {}\n http_request(url, Net::HTTP::Post, body, headers)\n end", "def post(path, options={})\n request :post, path, options\n end", "def post(url, headers, body)\n request(:post, url, headers, body)\n end", "def post(path, data, options = {})\n uri = build_uri(path, options)\n\n request = Net::HTTP::Post.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 post(body = nil, headers = {}, path = '')\n uri = URI.parse(\"#{@url}#{path}\")\n request = Net::HTTP::Post.new(uri.request_uri)\n request.body = body\n send_request(uri, request, headers)\n end", "def post(path, form_data)\n req = Net::HTTP::Post.new(path)\n req.set_form_data(form_data)\n request(req){|res| yield res }\n end", "def post(uri, request_headers, body)\n request('post', uri, request_headers, body) do |response_status_code, response_headers, response_body|\n yield response_status_code, response_headers, response_body\n end\n end", "def post_request(uri, params)\n begin\n \n # Request the data and return it\n doc = Nokogiri::HTML(open(uri, params.merge(:allow_redirections => :safe)))\n return doc.text\n #\n # Rescue in the case of a 404 or a redirect\n # \n # TODO - this should really log into the task?\n rescue OpenURI::HTTPError => e \n TapirLogger.instance.log \"Error, couldn't open #{uri} with error #{e}\"\n rescue Timeout::Error => e\n TapirLogger.instance.log \"Timeout! #{e}\"\n rescue OpenSSL::SSL::SSLError => e\n TapirLogger.instance.log \"Unable to connect: #{e}\"\n rescue Net::HTTPBadResponse => e\n TapirLogger.instance.log \"Unable to connect: #{e}\"\n rescue EOFError => e\n TapirLogger.instance.log \"Unable to connect: #{e}\"\n rescue SocketError => e\n TapirLogger.instance.log \"Unable to connect: #{e}\"\n rescue SystemCallError => e\n TapirLogger.instance.log \"Unable to connect: #{e}\"\n rescue ArgumentError => e\n TapirLogger.instance.log \"Argument Error #{e}\"\n rescue Encoding::InvalidByteSequenceError => e\n TapirLogger.instance.log \"Encoding error: #{e}\"\n rescue Encoding::UndefinedConversionError => e\n TapirLogger.instance.log \"Encoding error: #{e}\"\n #rescue RuntimeError => e\n # TapirLogger.instance.log \"Unknown Error: #{e}\"\n end\n # Default to sending nothing \n false\n end", "def post(uri, query = T.unsafe(nil), headers = T.unsafe(nil)); end", "def request(method, uri, options = {})\n opts = @default_options.merge(options)\n headers = opts.headers\n proxy = opts.proxy\n \n if opts.form\n body = URI.encode_www_form(opts.form)\n headers['Content-Type'] ||= 'application/x-www-form-urlencoded'\n end\n\n request = Request.new method, uri, headers, proxy, body\n\n opts.callbacks[:request].each { |c| c.call(request) }\n response = perform request\n opts.callbacks[:response].each { |c| c.call(response) }\n\n format_response method, response, opts.response\n end", "def raw_post_request raw_params\n json_body = raw_params.to_json\n Rubix.logger.log(Logger::DEBUG, \"SEND: #{json_body}\") if Rubix.logger\n Net::HTTP::Post.new(uri.path).tap do |req|\n req['Content-Type'] = 'application/json-rpc'\n req.body = json_body\n end\n end", "def post(*args)\n request, adapter = request_and_adapter_from(args)\n\n with_adapter :post, request, adapter do |adapter|\n yield adapter.client if block_given?\n adapter.post request\n end\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, 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(body = '', headers = {}, parameters = {}, &block)\n build_post(body, headers, parameters, &block).invoke\n end", "def http_post(uri, data)\n RestClient.post uri, data\n end", "def send_request(opts)\n request = prep_request(opts)\n response = relay_request(request, opts)\n return response if response.is_a?(Net::HTTPSuccess) || response.is_a?(Net::HTTPAccepted)\n\n handle_error_response(response, opts[:endpoint])\n end", "def http_post\n req = Net::HTTP::Post.new @uri.request_uri, request_headers\n req.set_form_data params\n req.basic_auth @proxy_user, @proxy_pass if @proxy_pass && @proxy_user\n req\n end", "def post(uri, query = {}, &block)\n request(:post, uri, query, &block)\n end", "def post(path, **options)\n execute :post, path, options\n end", "def post(path, body = nil, options = {})\n request = Net::HTTP::Post.new(request_uri(path))\n request.body = body\n make_request(request, options)\n end", "def post(body)\n body = body.to_s\n request = Net::HTTP::Post.new(@uri.path)\n request.content_length = body.size\n request.body = body\n request['Content-Type'] = @http_content_type\n\n # Server will disconnect @http_inactivity seconds after receiving previous client\n # response, unless it receives the post we are now sending.\n # Net::HTTP defaults to 60 seconds, which would not always be appropriate.\n # In particular, the default would not work if @http_wait is > 60!\n if @initial_post == true\n read_timeout = @http_connect\n @initial_post = false\n elsif @previous_send == Time.at(0)\n read_timeout = @http_inactivity + 1\n else\n read_timeout = (Time.now - @previous_send).ceil + @http_inactivity\n end\n\n opts = {\n :read_timeout => read_timeout, # wait this long for a response\n :use_ssl => @use_ssl # Set SSL/no SSL\n }\n opts[:verify_mode] = @verify_mode if @use_ssl # Allow caller to defeat certificate verify\n\n Jabber::debuglog(\"#{@protocol_name} REQUEST (#{@pending_requests + 1}/#{@http_requests}) with timeout #{read_timeout}:\\n#{request.body}\")\n response = @http.start(@uri.host, @uri.port, nil, nil, nil, nil, opts ) { |http|\n http.request(request)\n }\n Jabber::debuglog(\"#{@protocol_name} RESPONSE (#{@pending_requests + 1}/#{@http_requests}): #{response.class}\\n#{response.body}\")\n\n unless response.kind_of? Net::HTTPSuccess\n # Unfortunately, HTTPResponses aren't exceptions\n # TODO: rescue'ing code should be able to distinguish\n raise Net::HTTPBadResponse, \"#{response.class}\"\n end\n\n body = REXML::Document.new(response.body).root\n if body.name != 'body' and body.namespace != 'http://jabber.org/protocol/httpbind'\n raise REXML::ParseException.new('Malformed body')\n end\n body\n end", "def post(operation, data = {}, headers = {})\n headers = @default_headers.merge(headers)\n self.class.post(operation, :headers => headers, :body => data)\n end", "def send_request(http_method, path: \"\", body: nil)\n body = ActiveSupport::JSON.encode(body) if body.is_a? Hash\n @connection.run_request(http_method.downcase.to_sym,\n path.to_s,\n body,\n default_headers)\n end" ]
[ "0.61562717", "0.6011057", "0.59698796", "0.59425735", "0.5935013", "0.59187734", "0.5892428", "0.589223", "0.5851671", "0.5849568", "0.58440095", "0.578222", "0.5756816", "0.57542646", "0.5746432", "0.5741888", "0.57218045", "0.569039", "0.5688466", "0.5648442", "0.5639095", "0.5618822", "0.55823654", "0.55808896", "0.5579888", "0.5574798", "0.5568047", "0.5567335", "0.55520976", "0.5537934", "0.5532129", "0.55275834", "0.55257106", "0.5524698", "0.5519282", "0.551411", "0.55106384", "0.5499073", "0.5498059", "0.54964924", "0.54964185", "0.5485289", "0.54805195", "0.5476761", "0.54686236", "0.5467995", "0.54589003", "0.5454258", "0.5450163", "0.54475087", "0.54357046", "0.54206705", "0.54188323", "0.5412813", "0.5398306", "0.53889024", "0.53876203", "0.5381325", "0.53700477", "0.5369377", "0.5369377", "0.53660035", "0.53564143", "0.5355728", "0.5349331", "0.5346206", "0.5345894", "0.53431475", "0.5341816", "0.5332416", "0.532973", "0.53267205", "0.5314879", "0.53103846", "0.53038025", "0.52914995", "0.52819186", "0.5266531", "0.525583", "0.5247849", "0.52388483", "0.5236229", "0.52332383", "0.52253264", "0.52211463", "0.52211463", "0.52211463", "0.5217603", "0.5217603", "0.5217603", "0.5212289", "0.52054876", "0.5199486", "0.5198793", "0.5197129", "0.5192482", "0.519205", "0.51886773", "0.5186407", "0.5183351" ]
0.5492101
41
Sends a synchronous PUT request. On success, yields any returned data; on error, yields any provided default data or +nil+. Recognizes the following options: +headers+ a hash to add or update the request headers +timeout+ the timeout for the request (defaults to +Ladon.default_request_timeout+) +default_data+ passes this on to +handle_response+
def fire_put(url_or_path, entity, options = {}, &block) url = absolute_url(url_or_path) headers = {:Accept => MEDIA_TYPE_JSON, :'Content-type' => ENCODED_MEDIA_TYPE_JSON}. merge(options.fetch(:headers, {})) headers = merge_log_weasel_header(headers) timeout = options.fetch(:timeout, Ladon.default_request_timeout) body = encode_entity(entity) response = Typhoeus::Request.put(url, headers: headers, timeout: timeout, body: body) handle_response(response, method: :put, url: url, default_data: options[:default_data], raise_on_error: options[:raise_on_error], &block) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def put options={}, &block\n handle_exceptions do\n Chimps.log.info(\"PUT #{url}\")\n Response.new(super(encoded_body, options, &block))\n end\n end", "def put(data = nil, options = nil)\n options ||= {}\n options[:method] = :put\n call data, options\n end", "def put(options={}, &block)\n response = http.put_uri(options.merge(:body => serialize), &block)\n handle_response(response)\n self\n end", "def put(url, options = {}, &block)\n request HttpPut, url, options, &block\n end", "def put(path, options = {}, signature = false, raw = false, unformatted = false, no_response_wrapper = self.no_response_wrapper, signed = sign_requests)\n request(:put, path, options, signature, raw, unformatted, no_response_wrapper, signed)\n end", "def put(path, options = {}, raw = false)\n request(:put, path, options, raw)\n end", "def http_put(path, data, content_type = 'application/json')\n http_methods(path, :put, data, content_type)\n end", "def put(path, options={})\n response = request(path, :put, options)\n validate response\n responsed_response = parse response\n data = { headers: response.headers, body: parsed_response }\n end", "def put\n RestClient.put(url, @body, @header) do |rso, req, res|\n setup(rso, req, res)\n end\n end", "def perform_put(path, options = {})\n perform_request(:put, path, options)\n end", "def put(path, options={}, raw=false)\n request(:put, path, options, raw)\n end", "def put(url, data={}, headers={}, redirect_limit=max_redirects)\n # parse the URL\n uri = URI.parse(url)\n\n debug(\"PUT #{uri} #{headers.inspect}\")\n\n # unless the data is already a string, assume JSON and convert to string\n data = data.to_json unless data.is_a? String\n # build the http object\n http = build_http(uri)\n # build the request\n request = Net::HTTP::Put.new(uri.request_uri, headers)\n request.body = data\n\n # send the request\n begin\n response = http.request(request)\n # handle the response\n case response\n when Net::HTTPRedirection then\n raise Net::HTTPFatalError.new(\"Too many redirects\", response) if redirect_limit == 0\n put_raw(response['location'], data, headers, redirect_limit - 1)\n else\n KineticHttpResponse.new(response)\n end\n rescue StandardError => e\n KineticHttpResponse.new(e)\n end\n end", "def raw_put(path, body, options = {})\n # Allow format override\n format = options.delete(:format) || @format\n # Clear cache\n expire_matching \"#{parent_path(path)}.*\"\n # Create PUT request\n put = Typhoeus::Request.new(\"#{protocol}#{@server}#{path}\", \n :verbose => DEBUG,\n :method => \"put\",\n :body => body,\n :headers => { :'Content-type' => options[:content_type] || content_type(format) }\n )\n # Send request\n do_request(put, format)\n end", "def put(path, data=nil)\n request(:put, path, data)\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 put(url, data, headers = {})\n request(:put, url, headers, :data => data)\n end", "def put(url, data, headers = {})\n request(:put, url, headers, :data => data)\n end", "def put(url, options = {}, &block)\n run! Request.new(url, :put, options.slice(:headers, :params, :payload), &block)\n end", "def put(path, *data, &block)\n map(path, R3::PUT, *data, &block)\n end", "def put(data, options={})\n @hal_client.put(href, data, options).tap do\n reset\n end\n end", "def put(path, data, params = {}, request_options = {})\n request(:put, path, data, params)\n end", "def put(path, data={})\n request(:put, path, data)\n end", "def put(url, data={}, headers={}, http_options=@options)\n # determine the http options\n redirect_limit = http_options[:max_redirects] || max_redirects\n gateway_retries = http_options[:gateway_retry_limit] || gateway_retry_limit\n gateway_delay = http_options[:gateway_retry_delay] || gateway_retry_delay\n\n # parse the URL\n uri = URI.parse(url)\n\n @logger.debug(\"PUT #{uri} #{headers.inspect}\")\n\n # unless the data is already a string, assume JSON and convert to string\n data = data.to_json unless data.is_a? String\n # build the http object\n http = build_http(uri)\n # build the request\n request = Net::HTTP::Put.new(uri.request_uri, headers)\n request.body = data\n\n # send the request\n begin\n response = http.request(request)\n # handle the response\n case response\n when Net::HTTPRedirection then\n if redirect_limit == -1\n @logger.info(\"HTTP response code: #{response.code}\") unless @logger.debug?\n KineticHttpResponse.new(response)\n elsif redirect_limit == 0\n raise Net::HTTPFatalError.new(\"Too many redirects\", response)\n else\n put(response['location'], data, headers, http_options.merge({\n :max_redirects => redirect_limit - 1\n }))\n end\n # handle 502, 503, 504\n when Net::HTTPBadGateway, Net::HTTPServiceUnavailable, Net::HTTPGatewayTimeOut then\n if gateway_retries == -1\n KineticHttpResponse.new(response)\n elsif gateway_retries == 0\n @logger.info(\"HTTP response: #{response.code} #{response.message}\") unless @logger.debug?\n raise Net::HTTPFatalError.new(\"#{response.code} #{response.message}\", response)\n else\n @logger.info(\"#{response.code} #{response.message}, retrying in #{gateway_delay} seconds\")\n sleep(gateway_delay)\n put(url, data, headers, http_options.merge({\n :gateway_retry_limit => gateway_retries - 1\n }))\n end\n when Net::HTTPUnknownResponse, NilClass then\n @logger.info(\"HTTP response code: 0\") unless @logger.debug?\n e = Net::HTTPFatalError.new(\"Unknown response from server\", response)\n KineticHttpResponse.new(e)\n else\n @logger.info(\"HTTP response code: #{response.code}\") unless @logger.debug?\n KineticHttpResponse.new(response)\n end\n rescue Net::HTTPBadResponse => e\n @logger.info(\"HTTP bad response: #{e.inspect}\") unless @logger.debug?\n KineticHttpResponse.new(e)\n rescue StandardError => e\n @logger.info(\"HTTP error: #{e.inspect}\") unless @logger.debug?\n KineticHttpResponse.new(e)\n end\n end", "def put(path, options={})\n request :put, path, options\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 put_request(path, params={}, options={})\n request(:put, path, params, options)\n end", "def put(path, data = {})\n request 'PUT', path, body: data.to_json\n end", "def do_PUT(req, res)\n perform_proxy_request(req, res) do |http, path, header|\n http.put(path, req.body || '', header)\n end\n end", "def put(path, options={})\n send_request 'put', path, options\n end", "def put endpoint, data\n do_request :put, endpoint, data\n end", "def put(path, options = {})\n request(:put, parse_query_and_convenience_headers(path, options))\n end", "def do_put(uri = \"\", body = \"\")\n @connection.put do |req|\n req.url uri\n req.headers['Content-Type'] = 'application/json'\n req.body = body\n end\n rescue Faraday::Error::ConnectionFailed => e\n $lxca_log.error \"XClarityClient::XclarityBase do_put\", \"Error trying to send a PUT to #{uri}\"\n $lxca_log.error \"XClarityClient::XclarityBase do_put\", \"Request sent: #{body}\"\n Faraday::Response.new\n end", "def api_put(path, data = {})\n api_request(:put, path, :data => data)\n end", "def put_request(options)\n raise ArgumentError, t('invalid_bucket') if options[:bucket].empty?\n raise ArgumentError, t('empty_content') if options[:content].nil?\n options[:w] ||= @write_quorum unless @write_quorum.nil?\n options[:dw] ||= @replica_commit unless @replica_commit.nil?\n options[:return_body] = @return_body unless options.has_key?(:return_body)\n\n request = Riakpb::RpbPutReq.new(options.slice :bucket, :key, :vclock, :content, :w, :dw, :return_body)\n response = rpc.request(\n Util::MessageCode::PUT_REQUEST,\n request\n )\n\n return(true) if response == \"\"\n return(response)\n end", "def put(path, data, headers = { })\n path = \"/#{path}\" unless path.start_with?('/')\n request = Net::HTTP::Put.new(path, headers)\n process_put_and_post_requests(request, data)\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(path, headers = {})\n process :put, path, headers\n end", "def put(path, options = {}, &block)\n map(path, options, :put, &block)\n end", "def put(url, body, headers: {}, params: {}, options: {})\n raise ArgumentError, \"'put' requires a string 'body' argument\" unless body.is_a?(String)\n url = encode_query(url, params)\n\n request = Net::HTTP::Put.new(url, @default_headers.merge(headers))\n request.body = body\n request.content_length = body.bytesize\n\n raise ArgumentError, \"'put' requires a 'content-type' header\" unless request['Content-Type']\n\n execute_streaming(request, options: options)\n end", "def put(path, headers: {}, query: {}, payload: {})\n (headers, query, payload) = preprocess(headers, query, payload)\n respond_with super(path, headers: headers, query: query, payload: payload)\n end", "def put(path = nil, options = {})\n connection.put(path, options)\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(*args)\n request :put, *args\n end", "def put_async(body = '', headers = {}, parameters = {}, &block)\n @asynchronous_backend.execute(build_put(body, headers, parameters, &block))\n end", "def put(path, data, options = {})\n uri = build_uri(path, options)\n\n request = Net::HTTP::Put.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 put(body = nil, headers = {}, path = '')\n uri = URI.parse(\"#{@url}#{path}\")\n request = Net::HTTP::Put.new(uri.request_uri)\n request.body = body\n send_request(uri, request, headers)\n end", "def put(url, data={}, headers={}, http_options={})\n # determine the http options\n redirect_limit = http_options[:max_redirects] || max_redirects\n gateway_retries = http_options[:gateway_retry_limit] || gateway_retry_limit\n gateway_delay = http_options[:gateway_retry_delay] || gateway_retry_delay\n\n # parse the URL\n uri = URI.parse(url)\n\n # unless the data is already a string, assume JSON and convert to string\n data = data.to_json unless data.is_a? String\n # build the http object\n http = build_http(uri)\n # build the request\n request = Net::HTTP::Put.new(uri.request_uri, headers)\n request.body = data\n\n # send the request\n begin\n response = http.request(request)\n # handle the response\n case response\n # handle 302\n when Net::HTTPRedirection then\n if redirect_limit == -1\n HttpResponse.new(response)\n elsif redirect_limit == 0\n raise Net::HTTPFatalError.new(\"Too many redirects\", response)\n else\n put(response['location'], data, headers, http_options.merge({\n :max_redirects => redirect_limit - 1\n }))\n end\n # handle 502, 503, 504\n when Net::HTTPBadGateway, Net::HTTPServiceUnavailable, Net::HTTPGatewayTimeOut then\n if gateway_retries == -1\n HttpResponse.new(response)\n elsif gateway_retries == 0\n Kinetic::Platform.logger.info(\"HTTP response: #{response.code} #{response.message}\")\n raise Net::HTTPFatalError.new(\"#{response.code} #{response.message}\", response)\n else\n Kinetic::Platform.logger.info(\"#{response.code} #{response.message}, retrying in #{gateway_delay} seconds\")\n sleep(gateway_delay)\n put(url, data, headers, http_options.merge({\n :gateway_retry_limit => gateway_retries - 1\n }))\n end\n when Net::HTTPUnknownResponse, NilClass then\n Kinetic::Platform.logger.info(\"HTTP response code: 0\")\n e = Net::HTTPFatalError.new(\"Unknown response from server\", response)\n HttpResponse.new(e)\n else\n Kinetic::Platform.logger.info(\"HTTP response code: #{response.code}\")\n HttpResponse.new(response)\n end\n rescue Net::HTTPBadResponse => e\n Kinetic::Platform.logger.info(\"HTTP bad response: #{e.inspect}\")\n HttpResponse.new(e)\n rescue StandardError => e\n Kinetic::Platform.logger.info(\"HTTP error: #{e.inspect}\")\n HttpResponse.new(e)\n end\n end", "def put(url, resource_name, options = {})\n build_response(resource_name) do\n connection.put do |req|\n req.url url\n req.body = options.to_json\n end\n end\n end", "def put(path, options={})\n url = build_url path, options\n body, mime = build_payload options\n headers = (options[:headers] || {}).merge :content_type => mime\n Response.new(@client[url].put body, headers)\n rescue RestClient::Exception => e\n Response.new e.response\n end", "def put options\n rest_request({ method: :put }.merge(options))\n end", "def put options\n rest_request({ method: :put }.merge(options))\n end", "def put(path, body: {}, headers: nil)\n response = conn.put do |req|\n build_request(req, path: path, body: body, headers: headers)\n end\n puts response.body\n response.body unless response.blank?\n end", "def put(*args)\n request(:put, *args)\n end", "def put(path, options={}, format=format)\n request(:put, path, options, format)\n end", "def put(path, request_options = {}, resource_options = {})\n response(:put, resource(resource_options)[path], request_options)\n end", "def put(uri, request_headers, body)\n request('put', uri, request_headers, body) do |response_status_code, response_headers, response_body|\n yield response_status_code, response_headers, response_body\n end\n end", "def put(*args)\n request, adapter = request_and_adapter_from(args)\n\n with_adapter :put, request, adapter do |adapter|\n yield adapter.client if block_given?\n adapter.put request\n end\n end", "def put(*args)\n prepare_request(:put, args)\n @@client.add(:put, @path, *args)\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 url, body, headers = {}\n http_request(url, Net::HTTP::Put, body, headers)\n end", "def api_put_request(url_prefix, data, raw_response = false)\n to_put = URI.escape(url_prefix)\n request = Net::HTTP::Put.new(to_put)\n request.body = data\n @logger.info \"PUT #{to_put}\"\n exec_request(request, raw_response, data)\n end", "def put *args, &block\n handle @conn.put *args, &block\n end", "def put_request(request_data = {}, errback = DEFAULT_ERROR, &blk)\n req = create_test_request(request_data).put(request_data)\n hookup_request_callbacks(req, errback, &blk)\n end", "def make_put_request(url, data)\n headers = {\n \"Content-Type\" => \"application/json\",\n }\n\n response = HTTParty.put(url, body: data.to_json, headers: headers)\n\n if response.success?\n response\n else\n puts \"Request failed with response code: #{response.code}\"\n puts \"Response message: #{response.message}\"\n nil\n end\nend", "def put(*args, &block)\n self.client.put *args\n end", "def http_put(uri:, additional_headers: {}, data: {}, basic_auth: nil, debug: false)\n return nil if uri.blank?\n\n opts = options(additional_headers: additional_headers, debug: debug)\n opts[:body] = data\n opts[:basic_auth] = basic_auth if basic_auth.present?\n HTTParty.put(uri, opts)\n rescue URI::InvalidURIError => e\n handle_uri_failure(method: \"BaseService.http_put #{e.message}\", uri: uri)\n nil\n rescue HTTParty::Error => e\n handle_http_failure(method: \"BaseService.http_put #{e.message}\", http_response: nil)\n nil\n end", "def PUT(uri, data, type, credentials)\n put = Net::HTTP::Put.new(uri.path)\n put.content_type = type\n\n set_upload_body(put, data)\n\n response = submit(put, uri, credentials)\n\n case response\n when Net::HTTPOK, Net::HTTPAccepted\n # We've either set a parameter or started a run so we get 200 or 202\n # back from the server, respectively. Return true to indicate success.\n true\n when Net::HTTPCreated\n # We've uploaded data so we get 201 back from the server. Return the\n # uri of the created resource.\n URI.parse(response['location'])\n when Net::HTTPNoContent\n # We've modified data so we get 204 back from the server. Return the\n # uri of the modified resource.\n uri\n when Net::HTTPServiceUnavailable\n raise ServerAtCapacityError.new\n else\n report_error(\"PUT\", uri.path, response, credentials)\n end\n end", "def put url, object = nil\n request url, HTTP::Put, object\n end", "def put(path, params = {}, env = {}, &block)\n env[:request_method] = \"PUT\"\n mock_request(path, params, env, &block)\n end", "def put(*args)\n request, adapter = request_and_adapter_from(args)\n \n with request, adapter do |adapter|\n yield adapter.client if block_given?\n adapter.put request\n end\n end", "def put(url, payload, options={}, &block)\n http_options = options.merge(@basic_options)\n if block_given?\n RestClient.put(url, payload, http_options, &block)\n else\n RestClient.put(url, payload, http_options)\n end\n\n end", "def put(path, **options)\n execute :put, path, options\n end", "def put(uri, options = T.unsafe(nil)); end", "def put(object, url, headers={})\n do_request(\"put\", url, object, headers)\n end", "def put(request, response)\n NotImplemented\n end", "def put(request, response)\n NotImplemented\n end", "def put(path, data = {})\n # Allow format override\n format = data.delete(:format) || @format\n # Clear cache\n expire_matching \"#{parent_path(path)}.*\"\n # Extract return unit params\n query_params = {}\n query_params[:returnUnit] = data.delete(:returnUnit) if data[:returnUnit]\n query_params[:returnPerUnit] = data.delete(:returnPerUnit) if data[:returnPerUnit]\n # Create PUT request\n put_params = {\n :verbose => DEBUG,\n :method => \"put\",\n :body => form_encode(data)\n }\n put_params[:params] = query_params unless query_params.empty?\n put = Typhoeus::Request.new(\"#{protocol}#{@server}#{path}\", put_params)\n # Send request\n do_request(put, format)\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 put!\n request! :put\n end", "def put(resource, body = \"\", headers = {})\n prepare_request(:put, resource, body, headers)\n end", "def put_request(uri, body, token = nil, manage_errors = true)\n request = Net::HTTP::Put.new(uri.request_uri, initheader = build_headers(token))\n request.body = body.to_json\n return do_request(uri, request, manage_errors) \n end", "def perform_put_with_object(path, options, klass)\n perform_request_with_object(:put, path, options, klass)\n end", "def put(request)\n _request(request) { |client, options| client.put options }\n end", "def clear_put_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: ControlApi.clear_put ...'\n end\n # resource path\n local_var_path = 'mockserver/clear'\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\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(opts[:'http_request'])\n auth_names = []\n data, status_code, headers = @api_client.call_api(:PUT, 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 if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ControlApi#clear_put\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def put(path: nil, payload:, headers: {}, query: {}, auth_method: nil)\n execute(\n method: :put,\n path: path,\n headers: headers,\n query: query,\n payload: payload,\n auth_method: auth_method\n )\n end", "def put(request)\n do_request(request) { |client| client.http_put request.body }\n end", "def put(uri, options = {})\n if options[:multipart]\n form_input = build_multipart_data(options)\n build_response(request.put(uri, build_request_options({\"CONTENT_TYPE\" => \"multipart/form-data, boundary=Mack-boundary\", \"CONTENT_LENGTH\" => form_input.size, :input => form_input})))\n else\n build_response(request.put(uri, build_request_options({:input => options.to_params})))\n end\n end", "def put\n conn = @client.authorized_connection(url: @client.object_api_url)\n res = conn.put do |req|\n req.headers['Content-Type'] = \"application/json\"\n req.url resource_uri\n req.body = raw.to_json\n end\n if res.success?\n data = JSON.parse(res.body)\n self.class.new(data, @client)\n else\n nil\n end\n end", "def put(url, body = {})\n call(url: url, action: :put, body: body)\n end", "def put(body = '', headers = {}, parameters = {}, &block)\n build_put(body, headers, parameters, &block).invoke\n end", "def update(data, &block)\n request :put, @data[:id], data, &block\n end", "def put(request_uri, data = nil)\n url = base_uri + request_uri\n logger.debug(\"PUT #{url}\")\n\n uri = URI.parse(url)\n\n response = http_request(:put, uri, data)\n\n parse_body(response)\n end", "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 do_put(uri = '', body = '')\n build_request(:put, uri, body)\n end", "def put(path, opts = {})\n request(:put, path, opts).body\n end", "def stub_put(s3_client)\n data = {}\n s3_client.stub_responses(:put_object, ->(context) {\n data[:metadata] = context.params[:metadata]\n data[:enc_body] = context.params[:body].read\n {}\n })\n data\n end" ]
[ "0.67147917", "0.6701848", "0.6417074", "0.6389762", "0.63164777", "0.62826586", "0.62683374", "0.62661195", "0.62441283", "0.6243208", "0.62368053", "0.62349933", "0.62247276", "0.62232995", "0.6211339", "0.6174047", "0.6174047", "0.6142432", "0.6140279", "0.61127234", "0.6109936", "0.61020637", "0.60866237", "0.6062535", "0.6058342", "0.6052939", "0.6031895", "0.6031819", "0.60306215", "0.6024296", "0.60151255", "0.60144776", "0.5987775", "0.598666", "0.59827375", "0.5978039", "0.5978039", "0.5964839", "0.5951231", "0.59481966", "0.59442383", "0.5942102", "0.5941334", "0.5941334", "0.59369624", "0.5933773", "0.5932808", "0.5926213", "0.59078604", "0.5903695", "0.5902479", "0.5900012", "0.5900012", "0.58979416", "0.58713466", "0.5866739", "0.5852439", "0.585213", "0.58381003", "0.58260036", "0.58254826", "0.58254826", "0.5808699", "0.57990545", "0.57979685", "0.57679904", "0.575957", "0.5758698", "0.5743385", "0.5724884", "0.5724051", "0.5722537", "0.5710015", "0.56995505", "0.569589", "0.5689816", "0.5653055", "0.56514466", "0.56514466", "0.56398493", "0.5625351", "0.562524", "0.5623228", "0.56231046", "0.56213677", "0.56103486", "0.5609271", "0.5598109", "0.5595935", "0.55903095", "0.558383", "0.5556699", "0.5524503", "0.5518472", "0.55125386", "0.5511228", "0.5503063", "0.5492807", "0.54875857", "0.5483096" ]
0.6257976
8
Sends a synchronous DELETE request. On success, yields any returned data; on error, yields any provided default data or +nil+. Recognizes the following options: +headers+ a hash to add or update the request headers +timeout+ the timeout for the request (defaults to +Ladon.default_request_timeout+) +default_data+ passes this on to +handle_response+
def fire_delete(url_or_path, options = {}, &block) params = options.fetch(:params, {}) params.merge!(mapped_params(options)) url = absolute_url(url_or_path, params: params) headers = {:Accept => MEDIA_TYPE_JSON}.merge(options.fetch(:headers, {})) headers = merge_log_weasel_header(headers) timeout = options.fetch(:timeout, Ladon.default_request_timeout) response = Typhoeus::Request.delete(url, headers: headers, timeout: timeout) handle_response(response, method: :delete, default_data: options[:default_data], url: url, raise_on_error: options[:raise_on_error], &block) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete options={}, &block\n handle_exceptions do\n Chimps.log.info(\"DELETE #{url}\")\n Response.new(super(options, &block))\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 start { |connection| connection.request http :Delete }\n end", "def http_delete(path, data = nil, content_type = 'application/json')\n http_methods(path, :delete, data, content_type)\n end", "def delete(url, headers: {}, params: {}, options: {})\n url = encode_query(url, params)\n\n request = Net::HTTP::Delete.new(url, @default_headers.merge(headers))\n\n execute_streaming(request, options: options)\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 http_delete(path, headers = {})\n clear_response\n path = process_path(path)\n @success_code = 204\n @response = http.delete(path, headers)\n parse_response? ? parsed_response : response.body\n end", "def delete(data = nil, options = nil)\n options ||= {}\n options[:method] = :delete\n call data, options\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\n url = prefix + \"delete\"\n return response(url)\n end", "def delete\n url = prefix + \"delete\"\n return response(url)\n end", "def delete_async(parameters = {}, headers = {}, &block)\n @asynchronous_backend.execute(build_delete(parameters, headers, &block))\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 delete(url, options = {}, &block)\n run! Request.new(url, :delete, options.slice(:headers, :params, :payload), &block)\n end", "def delete(path, options = {})\n request = Net::HTTP::Delete.new(request_uri(path))\n make_request(request, options.merge(no_callbacks: true))\n end", "def delete\n RestClient.delete(url, @header) do |rso, req, res|\n setup(rso, req, res)\n end\n end", "def do_delete(uri = '')\n build_request(:delete, uri)\n end", "def delete(uri, request_headers)\n request('delete', uri, request_headers) do |response_status_code, response_headers, response_body|\n yield response_status_code, response_headers, response_body\n end\n end", "def delete(path, options={})\n response = request(path, :delete, options)\n validate response\n parsed_response = parse response\n data = { headers: response.headers, body: parsed_response }\n end", "def delete(url, options={}, &block)\n http_options = options.merge(@basic_options)\n if block_given?\n RestClient.delete(url, http_options, &block)\n else\n RestClient.delete(url, http_options)\n end\n end", "def delete(url, options = {}, &block)\n options = treat_params_as_query(options)\n request HttpDeleteWithEntity, url, options, &block\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 delete\n url = prefix + \"delete\" + id_param\n return response(url)\n end", "def delete(uri, options = {})\n build_response(request.delete(uri, build_request_options({:input => options.to_params})))\n end", "def delete *args, &block\n res = @conn.delete *args, &block\n handle res, parse: false\n end", "def delete(url, resource_name, options = {})\n build_response(resource_name) do\n connection.delete do |req|\n req.url url\n req.body = options.to_json\n end\n end\n end", "def send_delete_request(path)\n response = self.class.delete(path)\n # need auth\n case (response.code)\n when 200\n # just continue\n when 401\n authenticate(response)\n response = self.class.delete(path)\n else\n end\n if response.code != 200 && response.code != 202\n throw \"Could not finish request, status #{response.code}\"\n end\n response\n end", "def delete(url = nil, params = nil, headers = nil)\n run_request(:delete, url, nil, headers) { |request|\n # Original line from Faraday::Connection#delete method\n # request.params.update(params) if params\n\n # Monkey patch\n request.body = params if params\n\n yield(request) if block_given?\n }\n end", "def delete_data_stream request_pb, options = nil\n raise ::ArgumentError, \"request must be provided\" if request_pb.nil?\n\n verb, uri, query_string_params, body = ServiceStub.transcode_delete_data_stream_request request_pb\n query_string_params = if query_string_params.any?\n query_string_params.to_h { |p| p.split \"=\", 2 }\n else\n {}\n end\n\n response = @client_stub.make_http_request(\n verb,\n uri: uri,\n body: body || \"\",\n params: query_string_params,\n options: options\n )\n operation = ::Gapic::Rest::TransportOperation.new response\n result = ::Google::Protobuf::Empty.decode_json response.body, ignore_unknown_fields: true\n\n yield result, operation if block_given?\n result\n end", "def delete(headers = {}, path = '', parameters = {})\n full_path = [path, URI.encode_www_form(parameters)].join(PARAM_STARTER)\n uri = URI.parse(\"#{@url}#{full_path}\")\n request = Net::HTTP::Delete.new(uri.request_uri)\n request.body = nil\n send_request(uri, request, headers)\n end", "def delete(url, headers)\n conn = create_connection_object(url)\n\n http = conn.delete(:head => add_authorization_to_header(headers, @auth))\n\n action = proc do\n response = Response.new(http.response.parsed, http)#.response.raw)\n yield response if block_given?\n end\n\n http.callback &action\n http.errback &action \n end", "def delete(url, headers: {}, options: {})\n request_without_payload(:delete, url, headers, options)\n end", "def delete\n request(:delete)\n end", "def delete(request)\n do_request(request) { |client| client.http_delete }\n end", "def delete(path, options = {}, raw = false)\n request(:delete, path, options, raw)\n end", "def delete(path, headers: {}, query: {})\n (headers, query) = preprocess(headers, query)\n respond_with super(path, headers: headers, query: query)\n end", "def delete(path, options={}, raw=false)\n request(:delete, path, options, raw)\n end", "def delete(path, params = {}, env = {}, &block)\n env[:request_method] = \"DELETE\"\n mock_request(path, params, env, &block)\n end", "def delete(*args)\n request(:delete, *args)\n end", "def delete(uri, params = {}, env = {}, &block)\n super(uri, params, env, &block).tap do |response|\n record_request_response_pair!('delete')\n end\n end", "def delete!\n connection.delete(\n path: resource_path,\n status: 204\n ).data\n end", "def api_delete(path, data = {})\n api_request(:delete, path, :data => data)\n end", "def delete(parameters = {}, headers = {}, &block)\n build_delete(parameters, headers, &block).invoke\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\n make_request(path, \"delete\", {})\n end", "def delete!( opts = {} )\n http_action :delete, nil, opts\n end", "def delete(path, data={})\n request(:delete, path, data)\n end", "def delete options\n rest_request({ method: :delete }.merge(options))\n end", "def delete options\n rest_request({ method: :delete }.merge(options))\n end", "def perform_delete(path, options = {})\n perform_request(:delete, path, options)\n end", "def delete(uri = nil)\n requestor(Net::HTTP::Delete.new(build_uri(uri)))\n end", "def delete(url, headers={}, http_options={})\n # determine the http options\n redirect_limit = http_options[:max_redirects] || max_redirects\n gateway_retries = http_options[:gateway_retry_limit] || gateway_retry_limit\n gateway_delay = http_options[:gateway_retry_delay] || gateway_retry_delay\n\n # parse the URL\n uri = URI.parse(url)\n\n # build the http object\n http = build_http(uri)\n # build the request\n request = Net::HTTP::Delete.new(uri.request_uri, headers)\n\n # send the request\n begin\n response = http.request(request)\n # handle the response\n case response\n # handle 302\n when Net::HTTPRedirection then\n if redirect_limit == -1\n HttpResponse.new(response)\n elsif redirect_limit == 0\n raise Net::HTTPFatalError.new(\"Too many redirects\", response)\n else\n delete(response['location'], headers, http_options.merge({\n :max_redirects => redirect_limit - 1\n }))\n end\n # handle 502, 503, 504\n when Net::HTTPBadGateway, Net::HTTPServiceUnavailable, Net::HTTPGatewayTimeOut then\n if gateway_retries == -1\n HttpResponse.new(response)\n elsif gateway_retries == 0\n Kinetic::Platform.logger.info(\"HTTP response: #{response.code} #{response.message}\")\n raise Net::HTTPFatalError.new(\"#{response.code} #{response.message}\", response)\n else\n Kinetic::Platform.logger.info(\"#{response.code} #{response.message}, retrying in #{gateway_delay} seconds\")\n sleep(gateway_delay)\n delete(url, headers, http_options.merge({\n :gateway_retry_limit => gateway_retries - 1\n }))\n end\n when Net::HTTPUnknownResponse, NilClass then\n Kinetic::Platform.logger.info(\"HTTP response code: 0\")\n e = Net::HTTPFatalError.new(\"Unknown response from server\", response)\n HttpResponse.new(e)\n else\n Kinetic::Platform.logger.info(\"HTTP response code: #{response.code}\")\n HttpResponse.new(response)\n end\n rescue Net::HTTPBadResponse => e\n Kinetic::Platform.logger.info(\"HTTP bad response: #{e.inspect}\")\n HttpResponse.new(e)\n rescue StandardError => e\n Kinetic::Platform.logger.info(\"HTTP error: #{e.inspect}\")\n HttpResponse.new(e)\n end\n end", "def delete(path, headers: {}, query: {})\n headers = @default_headers.merge(headers)\n\n response = @http.delete(full_path(path, query: query), headers)\n ensure_success!(response)\n parse_response(response)\n end", "def delete(request)\n _request(request) { |client, options| client.delete options }\n end", "def delete(path, opts = {}, &block)\n request(:delete, path, opts, &block)\n end", "def delete(url, headers = {})\n request(:delete, url, headers)\n end", "def delete(url, headers = {})\n request(:delete, url, headers)\n end", "def delete(path, headers = {})\n request(:delete, path, nil, merge_default_headers(headers))\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, accept, content = {})\n execute HttpConnect::HttpDelete.new(path, nil, accept, content)\n end", "def delete\n execute_request { faraday_connection.delete }\n end", "def delete(url, headers={})\n RestClient.delete url, headers\n end", "def delete(uri, request_headers)\n request('delete', uri, request_headers)\n end", "def make_delete_request\n options = {\n use_ssl: true,\n cert: OpenSSL::X509::Certificate.new(@certificate),\n key: OpenSSL::PKey::RSA.new(@key),\n ca_file: @uw_ca_file,\n verify_mode: OpenSSL::SSL::VERIFY_PEER\n }\n Net::HTTP.start(@uri.host, @uri.port, options) do |http|\n request = Net::HTTP::Delete.new(@uri.request_uri)\n @response = http.request(request)\n end\n @response.body\n end", "def delete(url, headers = {})\n http :delete, \"#{url}.json\", headers\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(path, options={})\n send_request 'delete', path, options\n end", "def delete(uri, request_headers)\n raise NotImplementedError\n end", "def delete(path, query = { }, headers = {})\n clear_response\n path = process_path(path, query)\n @success_code = 204\n @response = http.delete(path, headers)\n parse_response? ? parsed_response : response.body\n end", "def delete(*args)\n prepare_request(:delete, args)\n @@client.add(:delete, @path, *args)\n end", "def delete_with_binary_response(relative_path, request_headers, request_parameters, context)\n connection = @session.connection\n request_parameter_list = request_parameters &&\n request_parameters.to_request_parameters\n uri = to_absolute_uri(relative_path, request_parameter_list)\n request_headers = [] if request_headers.nil?\n add_generic_headers('DELETE', uri, request_headers, context)\n\n response_status_code, response_headers, response_body = nil\n connection.delete(uri, request_headers) do |status_code, headers, content|\n response_status_code = status_code\n response_headers = headers\n response_body = process_binary_response(status_code, content, headers, context) do |h, c|\n yield h, c\n end\n end\n throw_exception_if_necessary(response_body, response_status_code, response_headers, relative_path)\n end", "def delete_request(uri, token = nil, manage_errors = true)\n request = Net::HTTP::Delete.new(uri.request_uri, initheader = build_headers(token))\n return do_request(uri, request, manage_errors)\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(uri, options = {})\n execute(uri, :delete, options)\n end", "def delete(relative_path, request_headers, request_parameters, response_type, context)\n connection = @session.connection\n request_parameter_list = request_parameters &&\n request_parameters.to_request_parameters\n uri = to_absolute_uri(relative_path, request_parameter_list)\n request_headers = [] if request_headers.nil?\n add_generic_headers('DELETE', uri, request_headers, context)\n\n response_status_code, response_headers, response_body = nil\n connection.delete(uri, request_headers) do |status_code, headers, content|\n response_status_code = status_code\n response_headers = headers\n response_body = content.read.force_encoding('UTF-8')\n end\n process_response(response_body, response_status_code, response_headers, response_type, relative_path, context)\n end", "def delete(endpoint, params = {})\n\n path = build_connect_url(endpoint)\n headers = build_headers(endpoint, 'DELETE', params)\n\n log \"DELETE \" + path + \" \" + params.to_s\n log headers.to_s\n\n begin\n response = RestClient::Request.execute(method: :delete, url: path, payload: params.to_json, headers: headers, timeout: 15)\n rescue RestClient::ExceptionWithResponse => e\n log e.http_code.to_s + \" \" + e.response.to_s\n return e.response\n end\n\n log response.code.to_s + \" \" + response.to_s\n\n response\n\n end", "def delete(request_configuration=nil)\n request_info = self.to_delete_request_information(\n request_configuration\n )\n error_mapping = Hash.new\n error_mapping[\"4XX\"] = lambda {|pn| MicrosoftGraph::Models::ODataErrorsODataError.create_from_discriminator_value(pn) }\n error_mapping[\"5XX\"] = lambda {|pn| MicrosoftGraph::Models::ODataErrorsODataError.create_from_discriminator_value(pn) }\n return @request_adapter.send_async(request_info, nil, error_mapping)\n end", "def delete(request_configuration=nil)\n request_info = self.to_delete_request_information(\n request_configuration\n )\n error_mapping = Hash.new\n error_mapping[\"4XX\"] = lambda {|pn| MicrosoftGraph::Models::ODataErrorsODataError.create_from_discriminator_value(pn) }\n error_mapping[\"5XX\"] = lambda {|pn| MicrosoftGraph::Models::ODataErrorsODataError.create_from_discriminator_value(pn) }\n return @request_adapter.send_async(request_info, nil, error_mapping)\n end", "def delete endpoint\n do_request :delete, endpoint\n end", "def delete(uri, opts = {}, &block)\n initialize_socket(uri, opts)\n HttpStream::delete(uri, opts, &block)\n rescue IOError => e\n raise e unless @intentional_termination\n end", "def delete(query_url,\r\n headers: {},\r\n parameters: {})\r\n HttpRequest.new(HttpMethodEnum::DELETE,\r\n query_url,\r\n headers: headers,\r\n parameters: parameters)\r\n end", "def delete(path, headers = {})\n process :delete, path, headers\n end", "def http_delete(request, response)\n path = request.path\n\n return false unless @server.emit('beforeUnbind', [path])\n\n @server.tree.delete(path)\n\n @server.emit('afterUnbind', [path])\n\n response.status = 204\n response.update_header('Content-Length', '0')\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 delete!\n request! :delete\n end", "def delete(path, request_options = {}, resource_options = {})\n response(:delete, resource(resource_options)[path], request_options)\n end", "def delete_identity_aware_proxy_client request_pb, options = nil\n raise ::ArgumentError, \"request must be provided\" if request_pb.nil?\n\n verb, uri, query_string_params, body = ServiceStub.transcode_delete_identity_aware_proxy_client_request request_pb\n query_string_params = if query_string_params.any?\n query_string_params.to_h { |p| p.split \"=\", 2 }\n else\n {}\n end\n\n response = @client_stub.make_http_request(\n verb,\n uri: uri,\n body: body || \"\",\n params: query_string_params,\n options: options\n )\n operation = ::Gapic::Rest::TransportOperation.new response\n result = ::Google::Protobuf::Empty.decode_json response.body, ignore_unknown_fields: true\n\n yield result, operation if block_given?\n result\n end", "def delete\n ensure_client && ensure_uri\n response = @client.rest_delete(@data['uri'], { 'Accept-Language' => 'en_US' }, @api_version)\n @client.response_handler(response)\n true\n end", "def delete(path, params = {}, request_options = {})\n request(:delete, path, params)\n end", "def delete request_pb, options = nil\n raise ::ArgumentError, \"request must be provided\" if request_pb.nil?\n\n verb, uri, query_string_params, body = ServiceStub.transcode_delete_request request_pb\n query_string_params = if query_string_params.any?\n query_string_params.to_h { |p| p.split \"=\", 2 }\n else\n {}\n end\n\n response = @client_stub.make_http_request(\n verb,\n uri: uri,\n body: body || \"\",\n params: query_string_params,\n options: options\n )\n operation = ::Gapic::Rest::TransportOperation.new response\n result = ::Google::Cloud::Compute::V1::Operation.decode_json response.body, ignore_unknown_fields: true\n\n yield result, operation if block_given?\n result\n end", "def delete(path, options = {})\n request(:delete, path, options)\n end", "def delete_stream request_pb, options = nil\n raise ::ArgumentError, \"request must be provided\" if request_pb.nil?\n\n verb, uri, query_string_params, body = ServiceStub.transcode_delete_stream_request request_pb\n query_string_params = if query_string_params.any?\n query_string_params.to_h { |p| p.split \"=\", 2 }\n else\n {}\n end\n\n response = @client_stub.make_http_request(\n verb,\n uri: uri,\n body: body || \"\",\n params: query_string_params,\n options: options\n )\n operation = ::Gapic::Rest::TransportOperation.new response\n result = ::Google::Longrunning::Operation.decode_json response.body, ignore_unknown_fields: true\n\n yield result, operation if block_given?\n result\n end", "def delete_stream request_pb, options = nil\n raise ::ArgumentError, \"request must be provided\" if request_pb.nil?\n\n verb, uri, query_string_params, body = ServiceStub.transcode_delete_stream_request request_pb\n query_string_params = if query_string_params.any?\n query_string_params.to_h { |p| p.split \"=\", 2 }\n else\n {}\n end\n\n response = @client_stub.make_http_request(\n verb,\n uri: uri,\n body: body || \"\",\n params: query_string_params,\n options: options\n )\n operation = ::Gapic::Rest::TransportOperation.new response\n result = ::Google::Longrunning::Operation.decode_json response.body, ignore_unknown_fields: true\n\n yield result, operation if block_given?\n result\n end", "def delete(path, options={}, format=format)\n request(:delete, path, options, format)\n end", "def delete(url, headers={}, redirect_limit=max_redirects)\n # parse the URL\n uri = URI.parse(url)\n\n debug(\"DELETE #{uri} #{headers.inspect}\")\n\n # build the http object\n http = build_http(uri)\n # build the request\n request = Net::HTTP::Delete.new(uri.request_uri, headers)\n\n # send the request\n begin\n response = http.request(request)\n # handle the response\n case response\n when Net::HTTPRedirection then\n raise Net::HTTPFatalError.new(\"Too many redirects\", response) if redirect_limit == 0\n delete_raw(response['location'], headers, redirect_limit - 1)\n else\n KineticHttpResponse.new(response)\n end\n rescue StandardError => e\n KineticHttpResponse.new(e)\n end\n end", "def delete(request_configuration=nil)\n request_info = self.to_delete_request_information(\n request_configuration\n )\n error_mapping = Hash.new\n error_mapping[\"4XX\"] = lambda {|pn| MicrosoftGraph::Models::ODataErrorsODataError.create_from_discriminator_value(pn) }\n error_mapping[\"5XX\"] = lambda {|pn| MicrosoftGraph::Models::ODataErrorsODataError.create_from_discriminator_value(pn) }\n return @request_adapter.send_async(request_info, nil, error_mapping)\n end", "def delete(request_configuration=nil)\n request_info = self.to_delete_request_information(\n request_configuration\n )\n error_mapping = Hash.new\n error_mapping[\"4XX\"] = lambda {|pn| MicrosoftGraph::Models::ODataErrorsODataError.create_from_discriminator_value(pn) }\n error_mapping[\"5XX\"] = lambda {|pn| MicrosoftGraph::Models::ODataErrorsODataError.create_from_discriminator_value(pn) }\n return @request_adapter.send_async(request_info, nil, error_mapping)\n end" ]
[ "0.69131684", "0.69060266", "0.6822546", "0.67484254", "0.67352724", "0.67244554", "0.67244554", "0.6722736", "0.67103326", "0.6703254", "0.66961753", "0.66961753", "0.6660535", "0.65779996", "0.654648", "0.6512669", "0.65105695", "0.64814013", "0.64459455", "0.64413345", "0.64261067", "0.6408918", "0.63963634", "0.6381152", "0.636512", "0.63408893", "0.633701", "0.628761", "0.6285832", "0.6284251", "0.627314", "0.6272496", "0.62644476", "0.6262874", "0.6262667", "0.6256107", "0.62371075", "0.62255734", "0.62173647", "0.6216688", "0.6203578", "0.62014747", "0.6199904", "0.6186992", "0.6184194", "0.6163072", "0.6162694", "0.61500394", "0.6142694", "0.6142694", "0.6134373", "0.61325747", "0.6118451", "0.61131096", "0.6104494", "0.60927784", "0.6084252", "0.6084252", "0.60764503", "0.60743856", "0.607267", "0.6055714", "0.605349", "0.6045416", "0.6041317", "0.6041171", "0.6040374", "0.6040374", "0.6040374", "0.6040374", "0.60311574", "0.6030303", "0.6027863", "0.601259", "0.6010728", "0.5983544", "0.59785295", "0.5978289", "0.59750676", "0.59618294", "0.5959439", "0.5959439", "0.5945843", "0.59454256", "0.5944284", "0.5943782", "0.5938606", "0.59283096", "0.5922814", "0.5910099", "0.5903662", "0.5897559", "0.5897447", "0.58950484", "0.58910143", "0.58910143", "0.589043", "0.58790827", "0.5876673", "0.5876673" ]
0.70708954
0
Sends a synchronous PATCH request. On success, yields any returned data; on error, yields any provided default data or +nil+. Recognizes the following options: +headers+ a hash to add or update the request headers +timeout+ the timeout for the request (defaults to +Ladon.default_request_timeout+) +default_data+ passes this on to +handle_response+
def fire_patch(url_or_path, entity, options = {}, &block) url = absolute_url(url_or_path) headers = {:Accept => MEDIA_TYPE_JSON, :'Content-type' => ENCODED_MEDIA_TYPE_JSON_PATCH}. merge(options.fetch(:headers, {})) headers = merge_log_weasel_header(headers) timeout = options.fetch(:timeout, Ladon.default_request_timeout) body = encode_entity(entity) response = Typhoeus::Request.run(url, headers: headers, timeout: timeout, body: body, method: :patch) handle_response(response, method: :patch, url: url, default_data: options[:default_data], raise_on_error: options[:raise_on_error], &block) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def patch(data = nil, options = nil)\n options ||= {}\n options[:method] = :patch\n call data, options\n end", "def patch(path, data, params = {}, request_options = {})\n request(:patch, path, data, params)\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 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 patch(url, options = {}, &block)\n request HttpPatch, url, options, &block\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 patch(data, options={})\n @hal_client.patch(href, data, options).tap do\n reset\n end\n end", "def patch(url, data={}, headers={}, redirect_limit=max_redirects)\n # parse the URL\n uri = URI.parse(url)\n\n debug(\"PATCH #{uri} #{headers.inspect}\")\n\n # unless the data is already a string, assume JSON and convert to string\n data = data.to_json unless data.is_a? String\n # build the http object\n http = build_http(uri)\n # build the request\n request = Net::HTTP::Patch.new(uri.request_uri, headers)\n request.body = data\n\n # send the request\n begin\n response = http.request(request)\n # handle the response\n case response\n when Net::HTTPRedirection then\n raise Net::HTTPFatalError.new(\"Too many redirects\", response) if redirect_limit == 0\n patch_raw(response['location'], data, headers, redirect_limit - 1)\n else\n KineticHttpResponse.new(response)\n end\n rescue StandardError => e\n KineticHttpResponse.new(e)\n end\n end", "def patch(url, data={}, headers={}, http_options=@options)\n # determine the http options\n redirect_limit = http_options[:max_redirects] || max_redirects\n gateway_retries = http_options[:gateway_retry_limit] || gateway_retry_limit\n gateway_delay = http_options[:gateway_retry_delay] || gateway_retry_delay\n\n # parse the URL\n uri = URI.parse(url)\n\n @logger.debug(\"PATCH #{uri} #{headers.inspect}\")\n\n # unless the data is already a string, assume JSON and convert to string\n data = data.to_json unless data.is_a? String\n # build the http object\n http = build_http(uri)\n # build the request\n request = Net::HTTP::Patch.new(uri.request_uri, headers)\n request.body = data\n\n # send the request\n begin\n response = http.request(request)\n # handle the response\n case response\n when Net::HTTPRedirection then\n if redirect_limit == -1\n @logger.info(\"HTTP response code: #{response.code}\") unless @logger.debug?\n KineticHttpResponse.new(response)\n elsif redirect_limit == 0\n raise Net::HTTPFatalError.new(\"Too many redirects\", response)\n else\n patch(response['location'], data, headers, http_options.merge({\n :max_redirects => redirect_limit - 1\n }))\n end\n # handle 502, 503, 504\n when Net::HTTPBadGateway, Net::HTTPServiceUnavailable, Net::HTTPGatewayTimeOut then\n if gateway_retries == -1\n KineticHttpResponse.new(response)\n elsif gateway_retries == 0\n @logger.info(\"HTTP response: #{response.code} #{response.message}\") unless @logger.debug?\n raise Net::HTTPFatalError.new(\"#{response.code} #{response.message}\", response)\n else\n @logger.info(\"#{response.code} #{response.message}, retrying in #{gateway_delay} seconds\")\n sleep(gateway_delay)\n patch(url, data, headers, http_options.merge({\n :gateway_retry_limit => gateway_retries - 1\n }))\n end\n when Net::HTTPUnknownResponse, NilClass then\n @logger.info(\"HTTP response code: 0\") unless @logger.debug?\n e = Net::HTTPFatalError.new(\"Unknown response from server\", response)\n KineticHttpResponse.new(e)\n else\n @logger.info(\"HTTP response code: #{response.code}\") unless @logger.debug?\n KineticHttpResponse.new(response)\n end\n rescue Net::HTTPBadResponse => e\n @logger.info(\"HTTP bad response: #{e.inspect}\") unless @logger.debug?\n KineticHttpResponse.new(e)\n rescue StandardError => e\n @logger.info(\"HTTP error: #{e.inspect}\") unless @logger.debug?\n KineticHttpResponse.new(e)\n end\n end", "def api_patch(path, data = {})\n api_request(:patch, path, :data => data)\n end", "def patch(url, data, headers = {})\n request(:patch, url, headers, :data => data)\n end", "def patch(path, data)\n request 'PATCH', path, body: data.to_json\n end", "def patch(path, opts = {}, &block)\n request(:patch, path, opts, &block)\n end", "def patch(path, opts = {}, &block)\n request(:patch, path, opts, &block)\n end", "def partial_update_with_http_info(rpm_remote_href, data, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: RemotesRpmApi.partial_update ...'\n end\n # verify the required parameter 'rpm_remote_href' is set\n if @api_client.config.client_side_validation && rpm_remote_href.nil?\n fail ArgumentError, \"Missing the required parameter 'rpm_remote_href' when calling RemotesRpmApi.partial_update\"\n end\n # verify the required parameter 'data' is set\n if @api_client.config.client_side_validation && data.nil?\n fail ArgumentError, \"Missing the required parameter 'data' when calling RemotesRpmApi.partial_update\"\n end\n # resource path\n local_var_path = '{rpm_remote_href}'.sub('{' + 'rpm_remote_href' + '}', rpm_remote_href.to_s)\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(data)\n auth_names = ['Basic']\n data, status_code, headers = @api_client.call_api(:PATCH, 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 => 'AsyncOperationResponse')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: RemotesRpmApi#partial_update\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def update(data, &block)\n request :patch, @data[:id], data, &block\n end", "def patch(uri, options = T.unsafe(nil)); end", "def patch\n conn = @client.authorized_connection(url: @client.object_api_url)\n res = conn.patch do |req|\n req.headers['Content-Type'] = \"application/json\"\n req.url resource_uri\n req.body = raw.to_json\n end\n if res.success?\n data = JSON.parse(res.body)\n self.class.new(data, @client)\n else\n nil\n end\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 patch_async(body = '', headers = {}, parameters = {}, &block)\n @asynchronous_backend.execute(build_patch(body, headers, parameters, &block))\n end", "def patch request_pb, options = nil\n raise ::ArgumentError, \"request must be provided\" if request_pb.nil?\n\n uri, body, query_string_params = transcode_patch_request request_pb\n response = @client_stub.make_patch_request(\n uri: uri,\n body: body,\n params: query_string_params,\n options: options\n )\n result = ::Google::Cloud::Compute::V1::Operation.decode_json response.body, ignore_unknown_fields: true\n\n yield result, response if block_given?\n result\n end", "def patch request_pb, options = nil\n raise ::ArgumentError, \"request must be provided\" if request_pb.nil?\n\n uri, body, query_string_params = transcode_patch_request request_pb\n response = @client_stub.make_patch_request(\n uri: uri,\n body: body,\n params: query_string_params,\n options: options\n )\n result = ::Google::Cloud::Compute::V1::Operation.decode_json response.body, ignore_unknown_fields: true\n\n yield result, response if block_given?\n result\n end", "def patch!\n request! :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 patch(body = '', headers = {}, parameters = {}, &block)\n build_patch(body, headers, parameters, &block).invoke\n end", "def partial_update_with_http_info(rpm_repository_href, data, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: RepositoriesRpmApi.partial_update ...'\n end\n # verify the required parameter 'rpm_repository_href' is set\n if @api_client.config.client_side_validation && rpm_repository_href.nil?\n fail ArgumentError, \"Missing the required parameter 'rpm_repository_href' when calling RepositoriesRpmApi.partial_update\"\n end\n # verify the required parameter 'data' is set\n if @api_client.config.client_side_validation && data.nil?\n fail ArgumentError, \"Missing the required parameter 'data' when calling RepositoriesRpmApi.partial_update\"\n end\n # resource path\n local_var_path = '{rpm_repository_href}'.sub('{' + 'rpm_repository_href' + '}', rpm_repository_href.to_s)\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(data)\n auth_names = ['Basic']\n data, status_code, headers = @api_client.call_api(:PATCH, 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 => 'RpmRpmRepository')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: RepositoriesRpmApi#partial_update\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def patch(path, opts = {})\n request(:patch, path, opts).body\n end", "def patch(attrs = nil)\n attrs ||= attributes.changed_attributes\n\n execute_request('PATCH') do |uri, headers|\n HTTP.http_client.patch(\n uri,\n body: adapter.serialize(attrs),\n header: headers.merge(CONTENT_TYPE_HEADERS)\n )\n end\n end", "def patch(path, headers: {}, query: {}, payload: {})\n (headers, query, payload) = preprocess(headers, query, payload)\n respond_with super(path, headers: headers, query: query, payload: payload)\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 patch(request)\n request.method = :patch\n request.call\n end", "def patch(*args, &block)\n map_method(:patch, args, &block)\n end", "def patch_request(request_data = {}, errback = DEFAULT_ERROR, &blk)\n req = create_test_request(request_data).patch(request_data)\n hookup_request_callbacks(req, errback, &blk)\n end", "def patch(resource, data)\n proxy(method: :patch, url: url_for(resource), data: data)\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 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 patch(query_url,\r\n headers: {},\r\n parameters: {})\r\n HttpRequest.new(HttpMethodEnum::PATCH,\r\n query_url,\r\n headers: headers,\r\n parameters: parameters)\r\n end", "def cards_partial_update_with_http_info(id, data, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: CardsApi.cards_partial_update ...'\n end\n # verify the required parameter 'id' is set\n if @api_client.config.client_side_validation && id.nil?\n fail ArgumentError, \"Missing the required parameter 'id' when calling CardsApi.cards_partial_update\"\n end\n # verify the required parameter 'data' is set\n if @api_client.config.client_side_validation && data.nil?\n fail ArgumentError, \"Missing the required parameter 'data' when calling CardsApi.cards_partial_update\"\n end\n # resource path\n local_var_path = '/cards/{id}/'.sub('{' + 'id' + '}', CGI.escape(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 header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:body] || @api_client.object_to_http_body(data) \n\n # return_type\n return_type = opts[:return_type] || 'Card' \n\n # auth_names\n auth_names = opts[:auth_names] || ['Basic', 'Token']\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(:PATCH, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: CardsApi#cards_partial_update\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def patch(attrs = nil)\n attrs ||= attributes.changed_attributes\n execute_request do\n faraday_connection.patch { |req| req.body = adapter.serialize(attrs) }\n end\n end", "def base_update(resource, id, options, format = nil, headers = nil)\n headers ||= {}\n headers[:accept] = \"#{format}\" if format\n format ||= @default_format\n headers[:content_type] = \"#{format}\"\n headers[:prefer] = @return_preference if @use_return_preference\n options = {} if options.nil?\n options[:resource] = resource.class\n options[:format] = format\n options[:id] = id\n reply = put resource_url(options), resource, fhir_headers(headers)\n reply.resource = parse_reply(resource.class, format, reply) if reply.body.present?\n reply.resource_class = resource.class\n reply\n end", "def patch(*args, &block); end", "def patch(url, payload, headers: {}, options: {})\n request_with_payload(:patch, url, payload, headers, options)\n end", "def patch(url, payload, headers={})\n RestClient.patch url, payload, headers\n end", "def patch(payload)\n post_like payload, Net::HTTP::Patch.new(@uri.path)\n end", "def order_items_partial_update_with_http_info(id, data, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: OrderItemsApi.order_items_partial_update ...'\n end\n # verify the required parameter 'id' is set\n if @api_client.config.client_side_validation && id.nil?\n fail ArgumentError, \"Missing the required parameter 'id' when calling OrderItemsApi.order_items_partial_update\"\n end\n # verify the required parameter 'data' is set\n if @api_client.config.client_side_validation && data.nil?\n fail ArgumentError, \"Missing the required parameter 'data' when calling OrderItemsApi.order_items_partial_update\"\n end\n # resource path\n local_var_path = '/order-items/{id}/'.sub('{' + 'id' + '}', CGI.escape(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 header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:body] || @api_client.object_to_http_body(data) \n\n # return_type\n return_type = opts[:return_type] || 'OrderItem' \n\n # auth_names\n auth_names = opts[:auth_names] || ['Basic', 'Token']\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(:PATCH, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: OrderItemsApi#order_items_partial_update\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def update_partial_patch_config_with_http_info(partial_patch_config, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: PolicySystemConfigurationNSXPartialPatchApi.update_partial_patch_config ...'\n end\n # verify the required parameter 'partial_patch_config' is set\n if @api_client.config.client_side_validation && partial_patch_config.nil?\n fail ArgumentError, \"Missing the required parameter 'partial_patch_config' when calling PolicySystemConfigurationNSXPartialPatchApi.update_partial_patch_config\"\n end\n # resource path\n local_var_path = '/system-config/nsx-partial-patch-config'\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(partial_patch_config)\n auth_names = ['BasicAuth']\n data, status_code, headers = @api_client.call_api(:PATCH, 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 if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: PolicySystemConfigurationNSXPartialPatchApi#update_partial_patch_config\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def update(data, params={})\n send_request @opts[:update_path], params, data\n end", "def stub_update(klass, options = {})\n define_implicit_request :update\n stub_find_one klass, options.merge(:current_object => true, :stub_ar => :update_attributes)\n end", "def update!(options = {}, &block)\n update(options.merge(save_response: true), &block)\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 patch\n patch! unless patched?\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_request_data_with_http_info(job_id, body, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: AsynchronousJobsBPMApi.update_request_data ...\"\n end\n # verify the required parameter 'job_id' is set\n if @api_client.config.client_side_validation && job_id.nil?\n fail ArgumentError, \"Missing the required parameter 'job_id' when calling AsynchronousJobsBPMApi.update_request_data\"\n end\n # verify the required parameter 'body' is set\n if @api_client.config.client_side_validation && body.nil?\n fail ArgumentError, \"Missing the required parameter 'body' when calling AsynchronousJobsBPMApi.update_request_data\"\n end\n # resource path\n local_var_path = \"/server/jobs/{jobId}/data\".sub('{' + 'jobId' + '}', job_id.to_s)\n\n # query parameters\n query_params = {}\n query_params[:'containerId'] = opts[:'container_id'] if !opts[:'container_id'].nil?\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/xml', 'application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = @api_client.object_to_http_body(body)\n auth_names = []\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 if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: AsynchronousJobsBPMApi#update_request_data\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def patch(body, request_configuration=nil)\n raise StandardError, 'body cannot be null' if body.nil?\n request_info = self.to_patch_request_information(\n body, request_configuration\n )\n error_mapping = Hash.new\n error_mapping[\"4XX\"] = lambda {|pn| MicrosoftGraph::Models::ODataErrorsODataError.create_from_discriminator_value(pn) }\n error_mapping[\"5XX\"] = lambda {|pn| MicrosoftGraph::Models::ODataErrorsODataError.create_from_discriminator_value(pn) }\n return @request_adapter.send_async(request_info, lambda {|pn| MicrosoftGraph::Models::Workbook.create_from_discriminator_value(pn) }, error_mapping)\n end", "def patch(path, **args); end", "def patch(body, request_configuration=nil)\n raise StandardError, 'body cannot be null' if body.nil?\n request_info = self.to_patch_request_information(\n body, request_configuration\n )\n error_mapping = Hash.new\n error_mapping[\"4XX\"] = lambda {|pn| MicrosoftGraph::Models::ODataErrorsODataError.create_from_discriminator_value(pn) }\n error_mapping[\"5XX\"] = lambda {|pn| MicrosoftGraph::Models::ODataErrorsODataError.create_from_discriminator_value(pn) }\n return @request_adapter.send_async(request_info, lambda {|pn| MicrosoftGraph::Models::ReportRoot.create_from_discriminator_value(pn) }, error_mapping)\n end", "def v1_employees_id_patch_with_http_info(id, json_patch_document, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: EmployeesApi.v1_employees_id_patch ...\"\n end\n # verify the required parameter 'id' is set\n if @api_client.config.client_side_validation && id.nil?\n fail ArgumentError, \"Missing the required parameter 'id' when calling EmployeesApi.v1_employees_id_patch\"\n end\n # verify the required parameter 'json_patch_document' is set\n if @api_client.config.client_side_validation && json_patch_document.nil?\n fail ArgumentError, \"Missing the required parameter 'json_patch_document' when calling EmployeesApi.v1_employees_id_patch\"\n end\n # resource path\n local_var_path = \"/v1/employees/{id}\".sub('{' + 'id' + '}', id.to_s)\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\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = @api_client.object_to_http_body(json_patch_document)\n auth_names = []\n data, status_code, headers = @api_client.call_api(:PATCH, 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 if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: EmployeesApi#v1_employees_id_patch\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def patch(header = {})\n url = \"#{ApiClient.config.path}#{self.class.resource_path}\"\n response = ApiClient::Dispatcher.patch(url, self.to_hash, header)\n attributes = ApiClient::Parser.response(response, url)\n update_attributes(attributes)\n end", "def update_with_http_info(rpm_remote_href, data, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: RemotesRpmApi.update ...'\n end\n # verify the required parameter 'rpm_remote_href' is set\n if @api_client.config.client_side_validation && rpm_remote_href.nil?\n fail ArgumentError, \"Missing the required parameter 'rpm_remote_href' when calling RemotesRpmApi.update\"\n end\n # verify the required parameter 'data' is set\n if @api_client.config.client_side_validation && data.nil?\n fail ArgumentError, \"Missing the required parameter 'data' when calling RemotesRpmApi.update\"\n end\n # resource path\n local_var_path = '{rpm_remote_href}'.sub('{' + 'rpm_remote_href' + '}', rpm_remote_href.to_s)\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(data)\n auth_names = ['Basic']\n data, status_code, headers = @api_client.call_api(:PUT, 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 => 'AsyncOperationResponse')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: RemotesRpmApi#update\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def webhooks_partial_update_with_http_info(owner, repo, identifier, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: WebhooksApi.webhooks_partial_update ...\"\n end\n # verify the required parameter 'owner' is set\n if @api_client.config.client_side_validation && owner.nil?\n fail ArgumentError, \"Missing the required parameter 'owner' when calling WebhooksApi.webhooks_partial_update\"\n end\n # verify the required parameter 'repo' is set\n if @api_client.config.client_side_validation && repo.nil?\n fail ArgumentError, \"Missing the required parameter 'repo' when calling WebhooksApi.webhooks_partial_update\"\n end\n # verify the required parameter 'identifier' is set\n if @api_client.config.client_side_validation && identifier.nil?\n fail ArgumentError, \"Missing the required parameter 'identifier' when calling WebhooksApi.webhooks_partial_update\"\n end\n # resource path\n local_var_path = \"/webhooks/{owner}/{repo}/{identifier}/\".sub('{' + 'owner' + '}', owner.to_s).sub('{' + 'repo' + '}', repo.to_s).sub('{' + 'identifier' + '}', identifier.to_s)\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\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(opts[:'data'])\n auth_names = ['apikey']\n data, status_code, headers = @api_client.call_api(:PATCH, 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 => 'RepositoryWebhook')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: WebhooksApi#webhooks_partial_update\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def patch(body, request_configuration=nil)\n raise StandardError, 'body cannot be null' if body.nil?\n request_info = self.to_patch_request_information(\n body, request_configuration\n )\n error_mapping = Hash.new\n error_mapping[\"4XX\"] = lambda {|pn| MicrosoftGraph::Models::ODataErrorsODataError.create_from_discriminator_value(pn) }\n error_mapping[\"5XX\"] = lambda {|pn| MicrosoftGraph::Models::ODataErrorsODataError.create_from_discriminator_value(pn) }\n return @request_adapter.send_async(request_info, lambda {|pn| MicrosoftGraph::Models::WorkbookFunctions.create_from_discriminator_value(pn) }, error_mapping)\n end", "def http_prop_patch(request, response)\n path = request.path\n\n begin\n prop_patch = @server.xml.expect('{DAV:}propertyupdate', request.body)\n rescue Tilia::Xml::ParseException => e\n raise Exception::BadRequest, e.message, nil, e\n end\n\n new_properties = prop_patch.properties\n\n result = @server.update_properties(path, new_properties)\n\n prefer = @server.http_prefer\n response.update_header('Vary', 'Brief,Prefer')\n\n if prefer['return'] == 'minimal'\n # If return-minimal is specified, we only have to check if the\n # request was succesful, and don't need to return the\n # multi-status.\n ok = true\n result.each do |_prop, code|\n ok = false if code.to_i > 299\n end\n\n if ok\n response.status = 204\n return false\n end\n end\n\n response.status = 207\n response.update_header('Content-Type', 'application/xml; charset=utf-8')\n\n # Reorganizing the result for generateMultiStatus\n multi_status = {}\n result.each do |property_name, code|\n if multi_status.key?(code)\n multi_status[code][property_name] = nil\n else\n multi_status[code] = { property_name => nil }\n end\n end\n multi_status['href'] = path\n\n response.body = @server.generate_multi_status([multi_status])\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 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 # PATCH\n raise NotImplementedError\n end", "def patch(endpoint)\n respond_with(\n connection(endpoint).patch(prepare(endpoint.uri),\n endpoint.req_params.nil? ? nil : custom_dump(endpoint.req_params)),\n endpoint\n )\n end", "def patch_contact_with_http_info(contact_id, list_id, contact_base_status_extra_no_removed, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: ContactsApi.patch_contact ...'\n end\n # verify the required parameter 'contact_id' is set\n if @api_client.config.client_side_validation && contact_id.nil?\n fail ArgumentError, \"Missing the required parameter 'contact_id' when calling ContactsApi.patch_contact\"\n end\n pattern = Regexp.new(/[a-fA-F\\d]{10}/)\n if @api_client.config.client_side_validation && contact_id !~ pattern\n fail ArgumentError, \"invalid value for 'contact_id' when calling ContactsApi.patch_contact, must conform to the pattern #{pattern}.\"\n end\n\n # verify the required parameter 'list_id' is set\n if @api_client.config.client_side_validation && list_id.nil?\n fail ArgumentError, \"Missing the required parameter 'list_id' when calling ContactsApi.patch_contact\"\n end\n if @api_client.config.client_side_validation && list_id < 1\n fail ArgumentError, 'invalid value for \"list_id\" when calling ContactsApi.patch_contact, must be greater than or equal to 1.'\n end\n\n # verify the required parameter 'contact_base_status_extra_no_removed' is set\n if @api_client.config.client_side_validation && contact_base_status_extra_no_removed.nil?\n fail ArgumentError, \"Missing the required parameter 'contact_base_status_extra_no_removed' when calling ContactsApi.patch_contact\"\n end\n # resource path\n local_var_path = '/lists/{list_id}/contacts/{contact_id}'.sub('{' + 'contact_id' + '}', CGI.escape(contact_id.to_s)).sub('{' + 'list_id' + '}', CGI.escape(list_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(contact_base_status_extra_no_removed)\n\n # return_type\n return_type = opts[:debug_return_type] || 'CreateContactResponse'\n\n # auth_names\n auth_names = opts[:debug_auth_names] || ['Apikey']\n\n new_options = opts.merge(\n :operation => :\"ContactsApi.patch_contact\",\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: ContactsApi#patch_contact\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def patch\n Rentlinx.client.patch(self)\n end", "def rm_request path, data = nil,method = nil, verbose = false\n reply = nil\n hdrs = {'Content-Type'=>'application/json', 'X-Redmine-API-Key' => $settings['redmine_api_key']}\n reply = Net::HTTP.start($settings['redmine_host'], $settings['redmine_port']) do |http|\n if data\n if !method || method == 'POST'\n puts \"POST #{path}\" if verbose\n http.request_post(path,data.to_json, hdrs)\n elsif method == 'PUT'\n # code for PUT here\n puts \"PUT #{path}\" if verbose\n http.send_request 'PUT', path, JSON.unparse(data), hdrs\n end\n else\n puts \"GET #{path}\" if verbose\n http.request_get(path, hdrs)\n end\n end\n return reply\nend", "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 patch_via_redirect(path, parameters = nil, headers = nil)\n request_via_redirect(:patch, path, parameters, headers)\n end", "def patch(operation, path, value = nil)\n ensure_client && ensure_uri\n body = [{ 'op' => operation, 'path' => path, 'value' => value }]\n patch_options = { 'If-Match' => @data['eTag'] }\n response = @client.rest_patch(@data['uri'], patch_options.merge('body' => body), @api_version)\n @client.response_handler(response)\n end", "def request(method, path, options)\n conn = connection(options)\n conn.instance_variable_set(:@parallel_manager, options[:parallel_manager]) if options[:parallel_manager]\n #binding.pry\n response = conn.send(method) do |request|\n #path = formatted_path(path) unless options[:unformatted] # || default_request?\n params = get_params(options)\n case method\n when :get, :delete\n request.url(path, params)\n # binding.pry\n when :post, :put\n request.path = path\n #if options['fileData']\n # request.headers['Content-type'] = 'multipart/form-data'\n # request.body = options\n #else\n #request.headers['Content-Type'] = 'application/json; charset=utf-8'\n request.body = params unless params.empty?\n #end\n end\n if options[:parallel_manager]\n env = request.to_env(conn)\n conn.parallel_manager.responses[env[:url].to_s] = {}\n conn.parallel_manager.responses[env[:url].to_s]['env'] = env\n end\n end\n #\n #binding.pry\n options[:raw] ? response : response.body\n #binding.pry\n end", "def patch_rule request_pb, options = nil\n raise ::ArgumentError, \"request must be provided\" if request_pb.nil?\n\n uri, body, query_string_params = transcode_patch_rule_request request_pb\n response = @client_stub.make_post_request(\n uri: uri,\n body: body,\n params: query_string_params,\n options: options\n )\n result = ::Google::Cloud::Compute::V1::Operation.decode_json response.body, ignore_unknown_fields: true\n\n yield result, response if block_given?\n result\n end", "def patch(body, request_configuration=nil)\n raise StandardError, 'body cannot be null' if body.nil?\n request_info = self.to_patch_request_information(\n body, request_configuration\n )\n error_mapping = Hash.new\n error_mapping[\"4XX\"] = lambda {|pn| MicrosoftGraph::Models::ODataErrorsODataError.create_from_discriminator_value(pn) }\n error_mapping[\"5XX\"] = lambda {|pn| MicrosoftGraph::Models::ODataErrorsODataError.create_from_discriminator_value(pn) }\n return @request_adapter.send_async(request_info, lambda {|pn| MicrosoftGraph::Models::OrgContact.create_from_discriminator_value(pn) }, error_mapping)\n end", "def patch\n fetch unless exist?\n return unless has_patches?\n dont_debug { patched_location.rmtree if patched_location.exist? } # Make sure that no previous patched copy exists\n dont_debug { @local_path.ditto patched_location }\n @local_path = patched_location\n # Download patches\n patched_location.dirname.cd do\n each_patch do |p|\n p.fetch\n end\n end\n # Apply patches\n patched_location.cd do\n each_patch do |p|\n p.apply\n end\n end\n end", "def patch(body, request_configuration=nil)\n raise StandardError, 'body cannot be null' if body.nil?\n request_info = self.to_patch_request_information(\n body, request_configuration\n )\n error_mapping = Hash.new\n error_mapping[\"4XX\"] = lambda {|pn| MicrosoftGraph::Models::ODataErrorsODataError.create_from_discriminator_value(pn) }\n error_mapping[\"5XX\"] = lambda {|pn| MicrosoftGraph::Models::ODataErrorsODataError.create_from_discriminator_value(pn) }\n return @request_adapter.send_async(request_info, lambda {|pn| MicrosoftGraph::Models::ListItem.create_from_discriminator_value(pn) }, error_mapping)\n end", "def update_inbox_replier_with_http_info(id, update_inbox_replier_options, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: InboxReplierControllerApi.update_inbox_replier ...'\n end\n # verify the required parameter 'id' is set\n if @api_client.config.client_side_validation && id.nil?\n fail ArgumentError, \"Missing the required parameter 'id' when calling InboxReplierControllerApi.update_inbox_replier\"\n end\n # verify the required parameter 'update_inbox_replier_options' is set\n if @api_client.config.client_side_validation && update_inbox_replier_options.nil?\n fail ArgumentError, \"Missing the required parameter 'update_inbox_replier_options' when calling InboxReplierControllerApi.update_inbox_replier\"\n end\n # resource path\n local_var_path = '/repliers/{id}'.sub('{' + 'id' + '}', CGI.escape(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(['*/*'])\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 = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:body] || @api_client.object_to_http_body(update_inbox_replier_options) \n\n # return_type\n return_type = opts[:return_type] || 'InboxReplierDto' \n\n # auth_names\n auth_names = opts[:auth_names] || ['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(:PUT, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: InboxReplierControllerApi#update_inbox_replier\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def device_update_with_http_info(device_id, body, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: DevicesApi.device_update ...'\n end\n # verify the required parameter 'device_id' is set\n if @api_client.config.client_side_validation && device_id.nil?\n fail ArgumentError, \"Missing the required parameter 'device_id' when calling DevicesApi.device_update\"\n end\n # verify the required parameter 'body' is set\n if @api_client.config.client_side_validation && body.nil?\n fail ArgumentError, \"Missing the required parameter 'body' when calling DevicesApi.device_update\"\n end\n # resource path\n local_var_path = '/h323/devices/{deviceId}'.sub('{' + 'deviceId' + '}', device_id.to_s)\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', 'application/xml'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json', 'multipart/form-data'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = @api_client.object_to_http_body(body)\n auth_names = ['OAuth']\n data, status_code, headers = @api_client.call_api(:PATCH, 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 if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: DevicesApi#device_update\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def patch(body, request_configuration=nil)\n raise StandardError, 'body cannot be null' if body.nil?\n request_info = self.to_patch_request_information(\n body, request_configuration\n )\n error_mapping = Hash.new\n error_mapping[\"4XX\"] = lambda {|pn| MicrosoftGraph::Models::ODataErrorsODataError.create_from_discriminator_value(pn) }\n error_mapping[\"5XX\"] = lambda {|pn| MicrosoftGraph::Models::ODataErrorsODataError.create_from_discriminator_value(pn) }\n return @request_adapter.send_async(request_info, lambda {|pn| MicrosoftGraph::Models::AuthenticationMethodsRoot.create_from_discriminator_value(pn) }, error_mapping)\n end", "def update_with_http_info(rpm_repository_href, data, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: RepositoriesRpmApi.update ...'\n end\n # verify the required parameter 'rpm_repository_href' is set\n if @api_client.config.client_side_validation && rpm_repository_href.nil?\n fail ArgumentError, \"Missing the required parameter 'rpm_repository_href' when calling RepositoriesRpmApi.update\"\n end\n # verify the required parameter 'data' is set\n if @api_client.config.client_side_validation && data.nil?\n fail ArgumentError, \"Missing the required parameter 'data' when calling RepositoriesRpmApi.update\"\n end\n # resource path\n local_var_path = '{rpm_repository_href}'.sub('{' + 'rpm_repository_href' + '}', rpm_repository_href.to_s)\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(data)\n auth_names = ['Basic']\n data, status_code, headers = @api_client.call_api(:PUT, 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 => 'AsyncOperationResponse')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: RepositoriesRpmApi#update\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def request(method, path, options, raw = false,\n unformatted = false, no_response_wrapper = false)\n response = @connection.send(method) do |request|\n path = formatted_path(path) unless unformatted\n puts \"PATH: #{path}\"\n\n case method\n when :get, :delete\n request.url(path, options)\n when :post, :put\n request.path = path\n request.body = options unless options.empty?\n end\n\n request.headers['Content-Type'] = 'application/json'\n\n end\n\n return response if raw\n return response.body if no_response_wrapper\n Response.create(response.body, response.status)\n end", "def company_management_it_solutions_id_patch_with_http_info(id, operations, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: ManagementItSolutionsApi.company_management_it_solutions_id_patch ...\"\n end\n # verify the required parameter 'id' is set\n if @api_client.config.client_side_validation && id.nil?\n fail ArgumentError, \"Missing the required parameter 'id' when calling ManagementItSolutionsApi.company_management_it_solutions_id_patch\"\n end\n # verify the required parameter 'operations' is set\n if @api_client.config.client_side_validation && operations.nil?\n fail ArgumentError, \"Missing the required parameter 'operations' when calling ManagementItSolutionsApi.company_management_it_solutions_id_patch\"\n end\n # resource path\n local_var_path = \"/company/managementItSolutions/{id}\".sub('{' + 'id' + '}', id.to_s)\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(operations)\n auth_names = ['BasicAuth']\n data, status_code, headers = @api_client.call_api(:PATCH, 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 => 'ManagementItSolution')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ManagementItSolutionsApi#company_management_it_solutions_id_patch\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def patch(_status, headers, env)\n check_precondition!(env)\n method = patch_types[env['CONTENT_TYPE']]\n\n raise UnsupportedMediaType unless method\n\n send(method, env['rack.input'], graph)\n set_last_modified\n [200, update_headers(headers), self]\n end", "def patch(body, request_configuration=nil)\n raise StandardError, 'body cannot be null' if body.nil?\n request_info = self.to_patch_request_information(\n body, request_configuration\n )\n error_mapping = Hash.new\n error_mapping[\"4XX\"] = lambda {|pn| MicrosoftGraph::Models::ODataErrorsODataError.create_from_discriminator_value(pn) }\n error_mapping[\"5XX\"] = lambda {|pn| MicrosoftGraph::Models::ODataErrorsODataError.create_from_discriminator_value(pn) }\n return @request_adapter.send_async(request_info, lambda {|pn| MicrosoftGraph::Models::ManagedDevice.create_from_discriminator_value(pn) }, error_mapping)\n end", "def update_inbox_with_http_info(inbox_id, update_inbox_options, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: InboxControllerApi.update_inbox ...'\n end\n # verify the required parameter 'inbox_id' is set\n if @api_client.config.client_side_validation && inbox_id.nil?\n fail ArgumentError, \"Missing the required parameter 'inbox_id' when calling InboxControllerApi.update_inbox\"\n end\n # verify the required parameter 'update_inbox_options' is set\n if @api_client.config.client_side_validation && update_inbox_options.nil?\n fail ArgumentError, \"Missing the required parameter 'update_inbox_options' when calling InboxControllerApi.update_inbox\"\n end\n # resource path\n local_var_path = '/inboxes/{inboxId}'.sub('{' + 'inboxId' + '}', CGI.escape(inbox_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(['*/*'])\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 = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:body] || @api_client.object_to_http_body(update_inbox_options) \n\n # return_type\n return_type = opts[:return_type] || 'InboxDto' \n\n # auth_names\n auth_names = opts[:auth_names] || ['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(:PATCH, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: InboxControllerApi#update_inbox\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def patch(path, to: nil, as: nil, **constraints, &blk)\n add_route(::Rack::PATCH, path, to, as, constraints, &blk)\n end", "def patch(body, request_configuration=nil)\n raise StandardError, 'body cannot be null' if body.nil?\n request_info = self.to_patch_request_information(\n body, request_configuration\n )\n error_mapping = Hash.new\n error_mapping[\"4XX\"] = lambda {|pn| MicrosoftGraph::Models::ODataErrorsODataError.create_from_discriminator_value(pn) }\n error_mapping[\"5XX\"] = lambda {|pn| MicrosoftGraph::Models::ODataErrorsODataError.create_from_discriminator_value(pn) }\n return @request_adapter.send_async(request_info, lambda {|pn| MicrosoftGraph::Models::Team.create_from_discriminator_value(pn) }, error_mapping)\n end", "def patch(body, request_configuration=nil)\n raise StandardError, 'body cannot be null' if body.nil?\n request_info = self.to_patch_request_information(\n body, request_configuration\n )\n error_mapping = Hash.new\n error_mapping[\"4XX\"] = lambda {|pn| MicrosoftGraph::Models::ODataErrorsODataError.create_from_discriminator_value(pn) }\n error_mapping[\"5XX\"] = lambda {|pn| MicrosoftGraph::Models::ODataErrorsODataError.create_from_discriminator_value(pn) }\n return @request_adapter.send_async(request_info, lambda {|pn| MicrosoftGraph::Models::PinnedChatMessageInfo.create_from_discriminator_value(pn) }, error_mapping)\n end", "def update_replication request_pb, options = nil\n raise ::ArgumentError, \"request must be provided\" if request_pb.nil?\n\n verb, uri, query_string_params, body = ServiceStub.transcode_update_replication_request request_pb\n query_string_params = if query_string_params.any?\n query_string_params.to_h { |p| p.split \"=\", 2 }\n else\n {}\n end\n\n response = @client_stub.make_http_request(\n verb,\n uri: uri,\n body: body || \"\",\n params: query_string_params,\n options: options\n )\n operation = ::Gapic::Rest::TransportOperation.new response\n result = ::Google::Longrunning::Operation.decode_json response.body, ignore_unknown_fields: true\n\n yield result, operation if block_given?\n result\n end", "def get_partial_patch_configuration_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: PolicySystemConfigurationNSXPartialPatchApi.get_partial_patch_configuration ...'\n end\n # resource path\n local_var_path = '/system-config/nsx-partial-patch-config'\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 = ['BasicAuth']\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 => 'PartialPatchConfig')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: PolicySystemConfigurationNSXPartialPatchApi#get_partial_patch_configuration\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def update(data, &block)\n request :put, @data[:id], data, &block\n end", "def request(method, args = {})\n params = args.merge({@method_param => method})\n params = params.merge(@default_params)\n endpoint = api_endpoint ? api_endpoint.base_url : @endpoint\n url = endpoint + URI.encode_www_form( params.reject{ |k,v| k == :force_update } )\n request_uri = URI.parse(url)\n response = nil\n begin\n MetaService.fetch_request_uri(args.merge(request_uri: request_uri, timeout: @timeout,\n api_endpoint: api_endpoint,\n user_agent: \"#{Site.default.name}/#{self.class}/#{SERVICE_VERSION}\"))\n rescue Timeout::Error\n raise Timeout::Error, \"#{@service_name} didn't respond within #{@timeout} seconds.\"\n end\n end", "def request(method, path, options, _raw = false)\n response = connection.send(method) do |request|\n request.headers[\"Accept\"] = \"application/json\"\n case method\n when :get, :delete\n request.url(path, options)\n when :post, :put\n request.path = path\n request.params = options[:params] if options[:params]\n request.body = options[:body] if options[:body]\n end\n end\n\n raise NonSuccessResponse, response if response.status >= 400\n\n response\n end", "def procurement_rma_statuses_id_notifications_notification_id_patch_with_http_info(id, notification_id, operations, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: RmaStatusNotificationsApi.procurement_rma_statuses_id_notifications_notification_id_patch ...\"\n end\n # verify the required parameter 'id' is set\n if @api_client.config.client_side_validation && id.nil?\n fail ArgumentError, \"Missing the required parameter 'id' when calling RmaStatusNotificationsApi.procurement_rma_statuses_id_notifications_notification_id_patch\"\n end\n # verify the required parameter 'notification_id' is set\n if @api_client.config.client_side_validation && notification_id.nil?\n fail ArgumentError, \"Missing the required parameter 'notification_id' when calling RmaStatusNotificationsApi.procurement_rma_statuses_id_notifications_notification_id_patch\"\n end\n # verify the required parameter 'operations' is set\n if @api_client.config.client_side_validation && operations.nil?\n fail ArgumentError, \"Missing the required parameter 'operations' when calling RmaStatusNotificationsApi.procurement_rma_statuses_id_notifications_notification_id_patch\"\n end\n # resource path\n local_var_path = \"/procurement/rmaStatuses/{id}/notifications/{notificationId}\".sub('{' + 'id' + '}', id.to_s).sub('{' + 'notificationId' + '}', notification_id.to_s)\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(operations)\n auth_names = ['BasicAuth']\n data, status_code, headers = @api_client.call_api(:PATCH, 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 => 'RmaStatusNotification')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: RmaStatusNotificationsApi#procurement_rma_statuses_id_notifications_notification_id_patch\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def update_pet_with_http_info(pet, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: PetApi.update_pet ...'\n end\n # verify the required parameter 'pet' is set\n if @api_client.config.client_side_validation && pet.nil?\n fail ArgumentError, \"Missing the required parameter 'pet' when calling PetApi.update_pet\"\n end\n # resource path\n local_var_path = '/pet'\n\n # query parameters\n query_params = opts[:query_params] || {}\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Content-Type'\n content_type = @api_client.select_header_content_type(['application/json', 'application/xml'])\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(pet)\n\n # return_type\n return_type = opts[:debug_return_type]\n\n # auth_names\n auth_names = opts[:debug_auth_names] || ['petstore_auth']\n\n new_options = opts.merge(\n :operation => :\"PetApi.update_pet\",\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(:PUT, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: PetApi#update_pet\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def update_a_live_call_with_http_info(call_id, update_call_request, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: DefaultApi.update_a_live_call ...'\n end\n\n # verify the required parameter 'call_id' is set\n if @api_client.config.client_side_validation && call_id.nil?\n fail ArgumentError, \"Missing the required parameter 'call_id' when calling DefaultApi.update_a_live_call\"\n end\n\n # verify the required parameter 'update_call_request' is set\n if @api_client.config.client_side_validation && update_call_request.nil?\n fail ArgumentError, \"Missing the required parameter 'update_call_request' when calling DefaultApi.update_a_live_call\"\n end\n # resource path\n local_var_path = '/Accounts/{accountId}/Calls/{callId}'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s)).sub('{' + 'callId' + '}', CGI.escape(call_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 '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(update_call_request)\n\n # return_type\n return_type = opts[:debug_return_type]\n\n # auth_names\n auth_names = opts[:debug_auth_names] || ['fc']\n\n new_options = opts.merge(\n :operation => :\"DefaultApi.update_a_live_call\",\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: DefaultApi#update_a_live_call\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def patch_resourcepool_pool_with_http_info(moid, resourcepool_pool, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: ResourcepoolApi.patch_resourcepool_pool ...'\n end\n # verify the required parameter 'moid' is set\n if @api_client.config.client_side_validation && moid.nil?\n fail ArgumentError, \"Missing the required parameter 'moid' when calling ResourcepoolApi.patch_resourcepool_pool\"\n end\n # verify the required parameter 'resourcepool_pool' is set\n if @api_client.config.client_side_validation && resourcepool_pool.nil?\n fail ArgumentError, \"Missing the required parameter 'resourcepool_pool' when calling ResourcepoolApi.patch_resourcepool_pool\"\n end\n # resource path\n local_var_path = '/api/v1/resourcepool/Pools/{Moid}'.sub('{' + 'Moid' + '}', CGI.escape(moid.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', 'application/json-patch+json'])\n if !content_type.nil?\n header_params['Content-Type'] = content_type\n end\n header_params[:'If-Match'] = opts[:'if_match'] if !opts[:'if_match'].nil?\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(resourcepool_pool)\n\n # return_type\n return_type = opts[:debug_return_type] || 'ResourcepoolPool'\n\n # auth_names\n auth_names = opts[:debug_auth_names] || ['cookieAuth', 'http_signature', 'oAuth2', 'oAuth2']\n\n new_options = opts.merge(\n :operation => :\"ResourcepoolApi.patch_resourcepool_pool\",\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: ResourcepoolApi#patch_resourcepool_pool\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def payment_methods_id_patch_with_http_info(id, patch_payment_method_request, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: PaymentMethodsApi.payment_methods_id_patch ...'\n end\n # verify the required parameter 'id' is set\n if @api_client.config.client_side_validation && id.nil?\n fail ArgumentError, \"Missing the required parameter 'id' when calling PaymentMethodsApi.payment_methods_id_patch\"\n end\n # verify the required parameter 'patch_payment_method_request' is set\n if @api_client.config.client_side_validation && patch_payment_method_request.nil?\n fail ArgumentError, \"Missing the required parameter 'patch_payment_method_request' when calling PaymentMethodsApi.payment_methods_id_patch\"\n end\n # resource path\n local_var_path = '/payment-methods/{id}'.sub('{' + 'id' + '}', CGI.escape(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 header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n header_params[:'Trace-Id'] = opts[:'trace_id'] if !opts[:'trace_id'].nil?\n header_params[:'User-Agent'] = opts[:'user_agent'] if !opts[:'user_agent'].nil?\n header_params[:'End-User-Device-Id'] = opts[:'end_user_device_id'] if !opts[:'end_user_device_id'].nil?\n header_params[:'End-User-Ip'] = opts[:'end_user_ip'] if !opts[:'end_user_ip'].nil?\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(patch_payment_method_request)\n\n # return_type\n return_type = opts[:debug_return_type] || 'PaymentMethod'\n\n # auth_names\n auth_names = opts[:debug_auth_names] || ['BearerAuth']\n\n new_options = opts.merge(\n :operation => :\"PaymentMethodsApi.payment_methods_id_patch\",\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: PaymentMethodsApi#payment_methods_id_patch\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end" ]
[ "0.67690635", "0.66018444", "0.65850794", "0.653295", "0.65206766", "0.64857477", "0.64857477", "0.6412761", "0.6395862", "0.6321682", "0.62371856", "0.6219795", "0.6063059", "0.6035184", "0.6035184", "0.60253274", "0.6017978", "0.59807795", "0.58862245", "0.5858433", "0.5807446", "0.5771307", "0.5771307", "0.5751566", "0.5740041", "0.57287365", "0.5706217", "0.56861126", "0.5626128", "0.5621272", "0.56115645", "0.56115645", "0.55942583", "0.55628717", "0.5559687", "0.55559045", "0.54842454", "0.5458485", "0.5442548", "0.54302245", "0.5384231", "0.53557366", "0.5344801", "0.5344386", "0.53404456", "0.5330972", "0.529846", "0.5289737", "0.528947", "0.52869624", "0.5280567", "0.5279076", "0.5273118", "0.52518153", "0.5250307", "0.5239565", "0.5224003", "0.5218949", "0.52054924", "0.51911527", "0.5169488", "0.51053435", "0.5105243", "0.5103701", "0.5102079", "0.50987774", "0.5082102", "0.5045022", "0.504015", "0.5022015", "0.5014671", "0.5003237", "0.49896878", "0.49793908", "0.49451908", "0.49448165", "0.49406067", "0.4917432", "0.49140447", "0.49011323", "0.48866454", "0.4883333", "0.48811817", "0.48732904", "0.48671547", "0.48638138", "0.48620716", "0.4851116", "0.48451775", "0.48443565", "0.48344472", "0.48342815", "0.48136747", "0.4811928", "0.480863", "0.48061696", "0.4783192", "0.47814316", "0.47779968", "0.4775209" ]
0.6176983
12
Negotiates the murky waters of HTTP response state. On success, parses the response body as a JSON object; on timeout or error, uses the default data instead. If a block is given, the data is yielded to it, and the block's return value is returned. IF no block is given, the data is returned directedly. Recognizes the following options: +request+ the Typhoeus request (optional) +method+ the HTTP method, handy if no request is provided +url+ the request URL, handy if no request is provided +default_data+ yielded or returned in case of timeout or error +silence_errors+ an array or range of status codes for which errors are not logged
def handle_response(response, options = {}, &block) request = options[:request] method = (request ? request.method : options[:method]) || '?' url = (request ? request.url : options[:url]) || '?' default_data = options[:default_data] default_data = HashWithIndifferentAccess.new(default_data) if default_data && default_data.is_a?(Hash) handler_options = {default_data: default_data, raise_on_error: options[:raise_on_error]} if response.timed_out? handle_timeout(response, method, url, handler_options, &block) elsif response.code == 0 handle_failure(response, method, url, handler_options, &block) else if !has_entity?(response) || acceptable?(response) entity = parse_entity(response.body) if response.body if response.success? handle_success_response(response, method, url, entity, &block) else handler_options[:silence_errors] = options[:silence_errors] handle_error_response(response, method, url, entity, handler_options, &block) end else handle_unacceptable_entity(response, method, url, handler_options, &block) end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "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 block_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: DefaultApi.block ...'\n end\n # resource path\n local_var_path = '/api/v1/block'\n\n # query parameters\n query_params = opts[:query_params] || {}\n query_params[:'hash'] = opts[:'hash'] if !opts[:'hash'].nil?\n query_params[:'seq'] = opts[:'seq'] if !opts[:'seq'].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', 'application/xml', ])\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<BlockSchema>' \n\n # auth_names\n auth_names = opts[:auth_names] || []\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: DefaultApi#block\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def do_get_block(req, proxy, conn, &block)\n @request_filter.each do |filter|\n filter.filter_request(req)\n end\n if str = @test_loopback_response.shift\n dump_dummy_request_response(req.body.dump, str) if @debug_dev\n conn.push(HTTP::Message.new_response(str))\n return\n end\n content = ''\n res = HTTP::Message.new_response(content)\n @debug_dev << \"= Request\\n\\n\" if @debug_dev\n sess = @session_manager.query(req, proxy)\n res.peer_cert = sess.ssl_peer_cert\n @debug_dev << \"\\n\\n= Response\\n\\n\" if @debug_dev\n do_get_header(req, res, sess)\n conn.push(res)\n sess.get_data() do |str|\n if block\n block.call(str)\n else\n content << str\n end\n end\n @session_manager.keep(sess) unless sess.closed?\n commands = @request_filter.collect { |filter|\n filter.filter_response(req, res)\n }\n if commands.find { |command| command == :retry }\n raise RetryableResponse.new\n end\n end", "def api_request(&block)\n response = block.call\n if response.status == 307 and response.body =~ /^\\/REST\\//\n response.body.sub!('/REST/','') \n response = get(response.body)\n end\n parse_response(JSON.parse(response.body || '{}'))\n end", "def request(uri, req = nil, &block)\n response = super(uri, req, &block)\n\n # Evaluate HTTP response.\n case response\n when Net::HTTPSuccess\n return response\n when Net::HTTPBadRequest\n hash = JSON.parse(response.body)\n description = hash[\"error_description\"]\n\n if hash[\"error\"]\n description ||= hash[\"error\"][\"description\"]\n code = hash[\"error\"][\"code\"]\n end\n\n raise Error.new(hash[\"error\"], description, code)\n when Net::HTTPUnauthorized\n raise Error.new(\"unauthorized\", \"Missing, invalid or expired access token.\")\n when Net::HTTPForbidden\n raise Error.new(\"forbidden\", \"Insufficient permission.\")\n when Net::HTTPNotFound\n return nil\n when Net::HTTPMethodNotAllowed\n raise Error.new(\"method_not_allowed\", \"Unexpected request method.\")\n when Net::HTTPServiceUnavailable\n raise Error.new(\"service_unavailable\", \"Exceeded rate limit.\")\n else\n raise Error.new(\"internal_server_error\", \"We are very sorry, but something went wrong.\")\n end\n end", "def blocks_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: DefaultApi.blocks ...'\n end\n # resource path\n local_var_path = '/api/v1/blocks'\n\n # query parameters\n query_params = opts[:query_params] || {}\n query_params[:'start'] = opts[:'start'] if !opts[:'start'].nil?\n query_params[:'end'] = opts[:'_end'] if !opts[:'_end'].nil?\n query_params[:'seq'] = @api_client.build_collection_param(opts[:'seq'], :multi) if !opts[:'seq'].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', 'application/xml', ])\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] || 'InlineResponse2001' \n\n # auth_names\n auth_names = opts[:auth_names] || []\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: DefaultApi#blocks\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def handle_request( request, &block )\n\t\tif block\n\t\t\treturn block.call( request )\n\t\telse\n\t\t\treturn request.response\n\t\tend\n\tend", "def blocks(opts = {})\n data, _status_code, _headers = blocks_with_http_info(opts)\n data\n end", "def request(endpoint, request, &block); end", "def get_request(request)\n\n wrapped_response = do_request(request)\n logger.debug \"#{self.class.to_s}:#{__method__}:#{__LINE__}: initial request: \"+request.to_s\n\n ## If required try to renew the token and redo the request.\n if wrapped_response.meta_status == WAPIStatus::UNKNOWN_ERROR &&\n wrapped_response.result.respond_to?('http_code') &&\n wrapped_response.result.http_code == WAPIStatus::HTTP_UNAUTHORIZED\n wrapped_response = renew_token()\n ## if the token renewed ok then try the request again.\n if wrapped_response.meta_status == WAPIStatus::SUCCESS\n wrapped_response = do_request(request)\n end\n end\n\n # If it didn't work just return that information.\n logger.debug \"#{self.class.to_s}:#{__method__}:#{__LINE__}: wrapped_response: meta_status: #{wrapped_response.meta_status}\"\n if wrapped_response.meta_status != WAPIStatus::SUCCESS\n return wrapped_response\n end\n\n ## Ran a query successfully. See if got partial data and need to keep going.\n\n logger.debug \"#{self.class.to_s}:#{__method__}:#{__LINE__}: wrapped_response: data length: #{wrapped_response.result.length}\"\n # See if there is a link header, if so get the rest of the data.\n if wrapped_response.meta_more.length > 0\n logger.debug \"#{self.class.to_s}:#{__method__}:#{__LINE__}: found link header: >>#{wrapped_response.meta_more}<<\"\n\n more_data = get_request(wrapped_response.meta_more)\n logger.debug \"#{self.class.to_s}:#{__method__}:#{__LINE__}: more_data status: #{more_data.meta}\"\n\n if more_data.meta_status == WAPIStatus::SUCCESS\n logger.debug \"#{self.class.to_s}:#{__method__}:#{__LINE__}: will merge data: initial wrapped_response: #{wrapped_response.result.length} more_data: #{more_data.result.length}\"\n wrapped_response = wrapped_response.append_json_results(more_data)\n else\n logger.error \"#{self.class.to_s}:#{__method__}:#{__LINE__}: can not merge more_data: #{more_data.inspect}\"\n end\n end\n logger.debug \"#{self.class.to_s}:#{__method__}:#{__LINE__}: final wrapped_response: result length: #{wrapped_response.result.length}\"\n wrapped_response\n end", "def request(uri, req = nil, &block)\n response = super(uri, req, &block)\n\n # Evaluate HTTP response.\n case response\n when Net::HTTPSuccess\n return response\n when Net::HTTPUnauthorized\n raise Error.new('unauthorized', 'Missing, invalid or expired access token.')\n when Net::HTTPForbidden\n raise Error.new('forbidden', 'Insufficient permission.')\n when Net::HTTPNotFound\n return nil\n when Net::HTTPMethodNotAllowed\n raise Error.new('method_not_allowed', 'Unexpected request method.')\n when Net::HTTPServiceUnavailable\n raise Error.new('service_unavailable', 'Exceeded rate limit.')\n else\n parsed_response = JSON.parse(response.body)\n raise Error.new(parsed_response['error'], parsed_response['error']['description'])\n end\n end", "def request(req, body = nil, &block) # :yield: +response+\n return orig_request req, body, &block unless started? #if not started don't log twice\n NetObserver::Base.instance.request_data(self, req, body)\n res = orig_request req, body, &block\n NetObserver::Base.instance.response_data(self, res)\n res\n end", "def response\n response = typhoeus_response\n ErrorHandler.precheck(response)\n parsed_body = MultiJson.load(response.body, JSON_OPTIONS)\n ErrorHandler.check(parsed_body.fetch(:meta))\n\n if @block\n @block.call(parsed_body)\n else\n parsed_body\n end\n rescue MultiJson::ParseError => e\n logger = Logger.new($stdout)\n logger.error(\"#{e.class}: #{e.message}\")\n\n if response\n logger.error('Response body:')\n logger.error(response.body.inspect)\n end\n\n raise Error::InternalError, 'AfterShip internal error, please try again.'\n end", "def request(params={}, &block)\n # @data has defaults, merge in new params to override\n datum = @data.merge(params)\n datum[:headers] = @data[:headers].merge(datum[:headers] || {})\n\n validate_params(:request, params, datum[:middlewares])\n # If the user passed in new middleware, we want to validate that the original connection parameters\n # are still valid with the provided middleware.\n if params[:middlewares]\n validate_params(:connection, @data, datum[:middlewares])\n end\n\n if datum[:user] || datum[:password]\n user, pass = Utils.unescape_uri(datum[:user].to_s), Utils.unescape_uri(datum[:password].to_s)\n datum[:headers]['Authorization'] ||= 'Basic ' + [\"#{user}:#{pass}\"].pack('m').delete(Excon::CR_NL)\n end\n\n host_key = datum[:headers].keys.detect {|k| k.casecmp('Host') == 0 } || 'Host'\n if datum[:scheme] == UNIX\n datum[:headers][host_key] ||= ''\n else\n datum[:headers][host_key] ||= datum[:host] + port_string(datum)\n end\n\n # RFC 7230, section 5.4, states that the Host header SHOULD be the first one # to be present.\n # Some web servers will reject the request if it comes too late, so let's hoist it to the top.\n if (host = datum[:headers].delete(host_key))\n datum[:headers] = { host_key => host }.merge(datum[:headers])\n end\n\n # default to GET if no method specified\n unless datum[:method]\n datum[:method] = :get\n end\n\n # if path is empty or doesn't start with '/', insert one\n unless datum[:path][0, 1] == '/'\n datum[:path] = datum[:path].dup.insert(0, '/')\n end\n\n if block_given?\n Excon.display_warning('Excon requests with a block are deprecated, pass :response_block instead.')\n datum[:response_block] = block\n end\n\n datum[:connection] = self\n\n # cleanup data left behind on persistent connection after interrupt\n if datum[:persistent] && !@persistent_socket_reusable\n reset\n end\n\n datum[:stack] = datum[:middlewares].map do |middleware|\n lambda {|stack| middleware.new(stack)}\n end.reverse.inject(self) do |middlewares, middleware|\n middleware.call(middlewares)\n end\n datum = datum[:stack].request_call(datum)\n\n unless datum[:pipeline]\n @persistent_socket_reusable = false\n datum = response(datum)\n @persistent_socket_reusable = true\n\n if datum[:persistent]\n if (key = datum[:response][:headers].keys.detect {|k| k.casecmp('Connection') == 0 })\n if datum[:response][:headers][key].casecmp('close') == 0\n reset\n end\n end\n else\n reset\n end\n\n Excon::Response.new(datum[:response])\n else\n datum\n end\n rescue => error\n reset\n\n # If we didn't get far enough to initialize datum and the middleware stack, just raise\n raise error if !datum\n\n datum[:error] = error\n if datum[:stack]\n datum[:stack].error_call(datum)\n else\n raise error\n end\n end", "def request_uncached request\n sleep 0.001 * options.delay.to_f # Sleep if requested\n\n if options.debug\n print \"Opening #{request[:uri]}...\"; $stdout.flush\n end\n\n if request[:method] == :get\n self.uri = request[:uri]\n else\n raise Exception, 'POST requests not supported yet'\n end\n \n puts 'done!' if options.debug\n \n if self.html_data?\n triples = extract(self.uri, html, self.kb, options.referenceable) # Extract data\n Dumper.dump self.uri, clean(triples), options.format if options.dump # Dump results to disk\n triples\n else\n []\n end\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 process_request(request,response,async=false,retries=0,&read_block) \n method = \"a#{request.http_method}\".downcase.to_sym # aget, apost, aput, adelete, ahead\n opts = fetch_request_options(request,method)\n opts[:async] = (async || opts[:async])\n url = fetch_url(request)\n begin\n http_response = fetch_response(url,method,opts,&read_block) \n unless opts[:async]\n response.status = http_response.response_header.status.to_i\n if response.status == 0\n if retries <= status_0_retries.to_i\n process_request(request,response,(retries + 1),&read_block)\n else\n response.network_error = true \n end\n else\n response.headers = fetch_response_headers(http_response)\n response.body = http_response.response\n end\n end\n rescue *AWS::Core::Http::NetHttpHandler::NETWORK_ERRORS\n response.network_error = true \n end\n end", "def api_request_raw(url, media_type = '')\n\n begin\n start_time = Time.now\n\n contents = do_request(url, media_type)\n total = Time.now.to_ms - start_time.to_ms\n info \"Successful request. URL: #{url}, Remaining: #{@remaining}, Total: #{total} ms\"\n\n contents\n rescue OpenURI::HTTPError => e\n @remaining = e.io.meta['x-ratelimit-remaining'].to_i\n @reset = e.io.meta['x-ratelimit-reset'].to_i\n\n case e.io.status[0].to_i\n # The following indicate valid Github return codes\n when 400, # Bad request\n 403, # Forbidden\n 404, # Not found\n 409, # Conflict -- returned on gets of empty repos\n 422 then # Unprocessable entity\n warn request_error_msg(url, e)\n return nil\n when 401 # Unauthorized\n warn request_error_msg(url, e)\n warn \"Unauthorised request with token: #{@token}\"\n raise e\n when 451 # DMCA takedown\n warn request_error_msg(url, e)\n warn \"Repo was taken down (DMCA)\"\n return nil\n else # Server error or HTTP conditions that Github does not report\n warn request_error_msg(url, e)\n raise e\n end\n rescue StandardError => e\n warn error_msg(url, e)\n raise e\n ensure\n # The exact limit is only enforced upon the first @reset\n # No idea how many requests are available on this key. Sleep if we have run out\n if @remaining < @req_limit\n to_sleep = @reset - Time.now.to_i + 2\n warn \"Request limit reached, reset in: #{to_sleep} secs\"\n t = Thread.new do\n slept = 0\n while true do\n debug \"Sleeping for #{to_sleep - slept} seconds\"\n sleep 1\n slept += 1\n end\n end\n sleep([0, to_sleep].max)\n t.exit\n end\n end\n end", "def request(req, body = nil, &block)\n response = alias_for_request(req, body)\n path = \"http://#{req.bauth if req.bauth}#{req['host']}#{req.path}\"\n if @@fakes[req.method][path]\n @@fakes[req.method][path] << {:body => response.body.to_s}\n else\n @@fakes[req.method][path] = [:body => response.body.to_s]\n end\n return response\n end", "def request(*args, &block); end", "def get options={}, &block\n handle_exceptions do\n Chimps.log.info(\"GET #{url}\")\n Response.new(super(options, &block))\n end\n end", "def _request(verb, uri, params={}, env={})\n send(\"rack_test_#{verb}\", uri, params, env)\n self.class.metadata[:session] = current_session\n\n response_data = begin\n JSON.load(last_response.body)\n rescue JSON::ParserError\n last_response.body\n end\n\n yield response_data if block_given?\n end", "def http_get(request)\n tries = 3\n begin\n curl = Curl::Easy.new request\n curl.useragent = USER_AGENT\n curl.perform\n begin\n JSON.parse curl.body_str\n rescue JSON::ParserError => err\n @log.warn \"Could not parse response for #{request} - this is probably not a json response: #{curl.body_str}\"\n return nil\n end\n rescue Curl::Err::ConnectionFailedError => err\n @log.error \"Connection failed: #{err}\"\n tries -= 1\n sleep 3\n if tries > 0\n retry\n else\n nil\n end\n rescue Curl::Err::RecvError => err\n @log.error \"Failure when receiving data from the peer: #{err}\"\n tries -= 1\n sleep 3\n if tries > 0\n retry\n else\n nil\n end\n rescue Curl::Err => err\n @log.error \"Failure in Curl call: #{err}\"\n tries -= 1\n sleep 3\n if tries > 0\n retry\n else\n nil\n end\n end\n end", "def connection_wrapper(&block)\n begin\n response = block.call\n raise ClientError.new(response.body['error']) if response.body.has_key?('error')\n rescue Faraday::ParsingError => e\n # Has gotten a response, but it is not formatted with JSON\n raise ClientError.new(e.message)\n rescue Faraday::ClientError => e\n # Failed to build a connection\n raise ConnectionError.new(e.message)\n end\n\n response\n end", "def retrieve opts={}, &block\n start_time = Time.now\n\n @response = stream opts, &block\n\n @response.body # make sure to read the full body from io\n @response.time = Time.now - start_time - @response.conn_time\n\n @response\n end", "def request(attrs={})\n request = her_api.request(attrs)\n\n if block_given?\n yield request[:parsed_data], request[:response]\n else\n { :parsed_data => request[:parsed_data], :response => request[:response] }\n end\n end", "def request method, url, opts={}, block=nil\n\t\t\tt0, m, attempt, chain = Time.now, method.downcase.to_sym, 0, []\n\t\t\topts = self.class.hash_keys_to_sym opts\n\t\t\topts[:data] = data_to_s opts[:data]\n\t\t\topts[:retry_45] = @retry_45 if opts[:retry_45].nil?\n\t\t\topts[:ignore_kill] = @ignore_kill if opts[:ignore_kill].nil?\n\t\t\topts[:norecode] = @req_norecode if opts[:norecode].nil?\n\t\t\topts[:attempts] = @req_attempts unless opts[:attempts]\n\t\t\topts[:retry_wait] = @req_retry_wait unless opts[:req_retry_wait]\n\t\t\tinitialize_curl unless @curb\n\t\t\tinitialize_request url, opts\n\t\t\twhile attempt < opts[:attempts]\n\t\t\t\tattempt += 1\n\t\t\t\treq_limit_check block if @reqs # request limitation enabled\n\t\t\t\tt = Time.now\n\t\t\t\tbegin\n\t\t\t\t\tcase m\n\t\t\t\t\t\twhen :head then\n\t\t\t\t\t\t\t@curb.http_head\n\t\t\t\t\t\twhen :post then\n\t\t\t\t\t\t\t@curb.http_post opts[:data]\n\t\t\t\t\t\twhen :put then\n\t\t\t\t\t\t\t@curb.http_put opts[:data]\n\t\t\t\t\t\twhen :delete then\n\t\t\t\t\t\t\t@curb.post_body = opts[:data]\n\t\t\t\t\t\t\t@curb.http_delete\n\t\t\t\t\t\telse # GET\n\t\t\t\t\t\t\t@curb.post_body = opts[:data]\n\t\t\t\t\t\t\topts[:data] ? @curb.http(:GET) : @curb.http_get\n\t\t\t\t\t\t\t # workaround for https://github.com/taf2/curb/issues/133\n\t\t\t\t\tend\n\t\t\t\t\tunless ['20', '30'].include? @curb.response_code.to_s[0,2]\n\t\t\t\t\t\tstatus = $1 if @curb.header_str.match(%r{ ([45]\\d{2} .*)\\r\\n})\n\t\t\t\t\t\traise Exception.new(status)\n\t\t\t\t\tend\n\t\t\t\t\tchain.push(['200 OK', (Time.now - t).round(6)])\n\t\t\t\t\trslt = get_result m, opts\n\t\t\t\t\t@reqs[:cnt] += 1 if @reqs # increase request limitation counter\n\t\t\t\t\tlog? && GLogg.log_d4? && GLogg.log_d4(sprintf( #_\n\t\t\t\t\t\t\t\"Curburger::Request#request:\\n %s %s\\n \" + #_\n\t\t\t\t\t\t\t'Done in %.6f secs (%u/%u attempt%s, %us/%us connect/timeout).',#_\n\t\t\t\t\t\t\tm.to_s.upcase, url, Time.now - t0, attempt, opts[:attempts], #_\n\t\t\t\t\t\t\topts[:attempts] == 1 ? '' : 's', #_\n\t\t\t\t\t\t\t@curb.connect_timeout, @curb.timeout)) #_\n\t\t\t\t\treturn rslt.merge({\n\t\t\t\t\t\t:last_url => @curb.last_effective_url,\n\t\t\t\t\t\t:attempts => attempt,\n\t\t\t\t\t\t:responses => chain,\n\t\t\t\t\t\t:time => (Time.now - t0).round(6),\n\t\t\t\t\t})\n\t\t\t\trescue interrupt_exception => e\n\t\t\t\t # method defined below to recognize exception based on message as well\n\t\t\t\t\tlog? && GLogg.log_d3? && GLogg.log_d3(sprintf(\n\t\t\t\t\t\t\t'Curburger::Request#request:' +\n\t\t\t\t\t\t\t\"\\n %s %s\\n %s attempt %u/%u: %s - %s\", m.to_s.upcase, url,\n\t\t\t\t\t\t\topts[:ignore_kill] ? 'Retrying interrupted' : 'Aborting',\n\t\t\t\t\t\t\tattempt, opts[:attempts], e.class, e.message))\n\t\t\t\t\tif opts[:ignore_kill] # reinitialize @curb and retry\n\t\t\t\t\t\tattempt -= 1 # decrease both counters\n\t\t\t\t\t\t@reqs[:cnt] -= 1 if @reqs\n\t\t\t\t\t\tinitialize_curl # reinitialize @curl instance\n\t\t\t\t\t\tinitialize_request url, opts # reinitialize @curl req. options\n\t\t\t\t\t\tredo\n\t\t\t\t\telse # abort\n\t\t\t\t\t\tchain.push(['Interrupted!', (Time.now - t).round(6)])\n\t\t\t\t\t\t@curl = nil\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t:attempts => attempt,\n\t\t\t\t\t\t\t:responses => chain,\n\t\t\t\t\t\t\t:time => (Time.now - t0).round(6),\n\t\t\t\t\t\t\t:error => chain[-1][0],\n\t\t\t\t\t\t}\n\t\t\t\t\tend\n\t\t\t\trescue Exception => e\n\t\t\t\t\tlog? && GLogg.log_i? && GLogg.log_i(sprintf(\n\t\t\t\t\t\t\t'Curburger::Request#request:' +\n\t\t\t\t\t\t\t\"\\n %s %s\\n Attempt %u/%u failed: %s - %s\",\n\t\t\t\t\t\t\tm.to_s.upcase, url, attempt, opts[:attempts], e.class, e.message))\n\t\t\t\t\tchain.push([e.message, (Time.now - t).round(6)])\n\t\t\t\t\tbreak if !opts[:retry_45] &&\n\t\t\t\t\t\t\t@curb.response_code >= 400 && @curb.response_code < 600\n\t\t\t\t\tsleep(1 + rand(opts[:retry_wait])) \\\n\t\t\t\t\t\t\tif opts[:retry_wait] > 0 && attempt < opts[:attempts]\n\t\t\t\t\tnext\n\t\t\t\tend\n\t\t\tend\n\t\t\trslt = get_result m, opts\n\t\t\tif !log? || GLogg.log_e?\n\t\t\t\tmsg = sprintf \"Curburger::Request#request:\\n %s %s\\n \" +\n\t\t\t\t\t\t'Failed in %.6f secs (%u/%u attempt%s, %us/%us connect/timeout).' +\n\t\t\t\t\t\t\"\\n Last error: %s\", m.to_s.upcase, url, Time.now - t,\n\t\t\t\t\t\tattempt, opts[:attempts], opts[:attempts] == 1 ? '' : 's',\n\t\t\t\t\t\t@curb.connect_timeout, @curb.timeout, chain[-1][0]\n\t\t\t\tlog? ? GLogg.log_e(msg) : warn(msg)\n\t\t\tend\n\t\t\treturn rslt.merge({\n\t\t\t\t:last_url => @curb.last_effective_url,\n\t\t\t\t:attempts => attempt,\n\t\t\t\t:responses => chain,\n\t\t\t\t:time => (Time.now - t0).round(6),\n\t\t\t\t:error => chain[-1][0],\n\t\t\t})\n\t\tend", "def request(req, body = nil, &block)\n response = alias_for_request(req, body)\n\n if NetRecorder.recording?\n scope = NetRecorder.scope || 'global'\n path = \"http://#{req.bauth if req.bauth}#{req['host']}#{req.path}\"\n\n existing_fake = @@fakes.detect{|fake| fake[0] == path && fake[1][scope] && fake[1][scope][:method] == req.method}\n existing_fake[1][scope][:response] << {:response => response} and return response if existing_fake\n\n @@fakes << [path, {scope => {:method => req.method, :response => [{:response => response}]}}]\n end\n\n yield response if block\n response\n end", "def request data, &blk\n json = JSON.generate data\n @dealer_sock.send json\n if block_given?\n blk.call JSON.parse(@dealer_sock.recv)\n end\n end", "def request(&block)\n self.with(&block)\n end", "def perform_sleepily!(timeout, &block)\n @on_complete = block if block_given?\n Thread.new {\n before_send.call(self) if before_send\n \n nap = sleepy.get(\"#{round_time(Time.new.to_i, timeout)}:#{uri}\") rescue nil\n \n unless nap.blank?\n STDERR.puts \"Return cached result #{nap.inspect}\"\n nap\n else\n req = http.request(request)\n \n response = Response.new(req, self)\n begin\n if response.redirected?\n response = response.follow_redirect\n else\n on_complete.call(response) if on_complete\n response\n end\n if response.code && response.code == 200\n sleepy.set(\"#{round_time(Time.new.to_i, timeout)}:#{uri}\", response)\n sleepy.set(\"0:#{uri}\", response)\n end\n rescue\n response = sleepy.get(\"0:#{uri}\") rescue nil\n end\n response\n end\n }\n end", "def run\n\n action Colors.grey(\"REQUEST \") + Colors.light_blue(\"#{options[:method].upcase} #{url}\")\n Console.instance.indent\n # run the request\n options[:ssl_verifypeer] = false\n options[:followlocation] = true\n\n Injector.decorate(options)\n\n # convert all headers keys to strings to avoid having symbols like :\"header\" when\n # declaring headers with colons instead of arrows\n if options.key?(:headers)\n new_opts = {}\n options[:headers].map do |k, v|\n new_opts[k.to_s] = v\n end\n options[:headers] = new_opts\n end\n\n if options.key?(:headers) and options[:headers].key?('Content-Type')\n ctype = options[:headers]['Content-Type']\n if ctype.include?('application/json')\n # automatically encode json content\n options[:body] = JSON.generate(options[:body], quirks_mode: true)\n end\n end\n\n\n\n self.response = Typhoeus::Request.new(url, options).run\n\n self.req_response = RequestResponse.new.tap { |r|\n r.raw_body = response.body\n r.headers = response.headers\n r.code = response.code\n r.total_time = response.total_time\n\n if !r.headers.nil? && r.headers.key?('Content-Type') && r.headers['Content-Type'].include?('application/json')\n r.body = JSON.parse(response.body)\n else\n r.body = response.body\n end\n }\n\n # reset assertion counter\n self.assert_no = 1\n\n # evaluate response against expectations\n begin\n instance_eval(&expectations)\n rescue AssertionException\n error error_msg + \" at #{expectations.source_location}\"\n raise RequestException\n rescue StandardError => e\n error 'Exception ' + e.message\n info e.backtrace.inspect\n _debug_info\n error error_msg\n raise RequestException\n ensure\n Console.instance.unindent\n end\n\n req_response\n\n end", "def block(opts = {})\n data, _status_code, _headers = block_with_http_info(opts)\n data\n end", "def response_options(&block)\n yield\n end", "def response_block\n create_response_block\n end", "def response_block\n create_response_block\n end", "def make_request_with_retries(connection, uri, http_request)\n disable_net_http_persistent_retries(connection)\n # Initialize retry vars:\n connection_retry_count = @data[:options][:connection_retry_count] || 3\n connection_retry_delay = @data[:options][:connection_retry_delay] || 0.5\n retries_performed = 0\n # If block is given - pass there all the chunks of a response and then stop\n # (don't do any parsing, analysis, etc)\n block = @data[:vars][:system][:block]\n begin\n if block\n # Response.body is a Net::ReadAdapter instance - it can't be read as a string.\n # WEB: On its own, Net::HTTP causes response.body to be a Net::ReadAdapter when you make a request with a block\n # that calls read_body on the response.\n connection.request(uri, http_request) do |response|\n # If we are at the point when we have started reading from the remote end\n # then there is no low level retry is allowed. Otherwise we would need to reset the\n # IO pointer, etc.\n connection_retry_count = 0\n if response.is_a?(Net::HTTPSuccess)\n set_http_response(response, :skip_body)\n response.read_body(&block)\n else\n set_http_response(response)\n end\n end\n else\n # Set text response\n response = connection.request(uri, http_request)\n set_http_response(response)\n end\n nil\n rescue => e\n # Parse both error message and error classname; for some errors it's not enough to parse only a message\n custom_error_msg = \"#{e.class.name}: #{e.message}\"\n # Initialize new error with full message including class name, so gw can catch it now\n custom_error = Error.new(custom_error_msg)\n # Fail if it is an unknown error\n fail(custom_error) if !(custom_error_msg[TIMEOUT_ERRORS] || custom_error_msg[OTHER_ERRORS])\n # Fail if it is a Timeout and timeouts are banned\n fail(custom_error) if custom_error_msg[TIMEOUT_ERRORS] && !!@data[:options][:abort_on_timeout]\n # Fail if there are no retries left...\n fail(custom_error) if (connection_retry_count -= 1) < 0\n # ... otherwise sleep a bit and retry.\n retries_performed += 1\n log(\"#{self.class.name}: Performing retry ##{retries_performed} caused by: #{e.class.name}: #{e.message}\")\n sleep(connection_retry_delay) unless connection_retry_delay._blank?\n connection_retry_delay *= 2\n retry\n end\n end", "def stream opts={}, &block\n retried = false\n opts = opts.merge(:request => self)\n\n begin\n start_time = Time.now\n conn = connection\n conn.start unless conn.started?\n conn_time = Time.now - start_time\n\n @response = conn.request http_request, nil, opts, &block\n @response.conn_time = conn_time\n\n @response\n\n rescue EOFError, Errno::EPIPE\n raise if retried\n @connection = nil\n retried = true\n retry\n end\n end", "def response(status, headers, body = '')\n body = yield if block_given?\n [status, headers, [body]]\nend", "def invoke\n res = catch(:halt) { yield }\n res = [res] if Fixnum === res || String === res\n if Array === res && Fixnum === res.first\n res = res.dup\n status(res.shift)\n body(res.pop)\n headers(*res)\n elsif res.respond_to? :each\n body res\n end\n nil # avoid double setting the same response tuple twice\n end", "def execute_streaming(request, options: {}, &block)\n redirector = Puppet::HTTP::Redirector.new(options.fetch(:redirect_limit, @default_redirect_limit))\n\n basic_auth = options.fetch(:basic_auth, nil)\n unless basic_auth\n if request.uri.user && request.uri.password\n basic_auth = { user: request.uri.user, password: request.uri.password }\n end\n end\n\n redirects = 0\n retries = 0\n response = nil\n done = false\n\n while !done do\n connect(request.uri, options: options) do |http|\n apply_auth(request, basic_auth)\n\n # don't call return within the `request` block\n http.request(request) do |nethttp|\n response = Puppet::HTTP::ResponseNetHTTP.new(request.uri, nethttp)\n begin\n Puppet.debug(\"HTTP #{request.method.upcase} #{request.uri} returned #{response.code} #{response.reason}\")\n\n if redirector.redirect?(request, response)\n request = redirector.redirect_to(request, response, redirects)\n redirects += 1\n next\n elsif @retry_after_handler.retry_after?(request, response)\n interval = @retry_after_handler.retry_after_interval(request, response, retries)\n retries += 1\n if interval\n if http.started?\n Puppet.debug(\"Closing connection for #{Puppet::HTTP::Site.from_uri(request.uri)}\")\n http.finish\n end\n Puppet.warning(_(\"Sleeping for %{interval} seconds before retrying the request\") % { interval: interval })\n ::Kernel.sleep(interval)\n next\n end\n end\n\n if block_given?\n yield response\n else\n response.body\n end\n ensure\n # we need to make sure the response body is fully consumed before\n # the connection is put back in the pool, otherwise the response\n # for one request could leak into a future response.\n response.drain\n end\n\n done = true\n end\n end\n end\n\n response\n end", "def go_get_raw(url)\n begin\n puts \"Connecting to URL: \" + url\n response = HTTParty.get(url, timeout: Rails.configuration.x.network_time_out)\n rescue Exception => e\n puts \"Connection ERROR: \" + e.message\n return nil\n end\n return response\n end", "def queue_request(url_or_path, options = {}, &block)\n url = absolute_url(url_or_path)\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 request = Typhoeus::Request.new(url, headers: headers, timeout: timeout)\n request.on_complete do |response|\n handle_response(response, request: request, default_data: options[:default_data], &block)\n end\n Ladon.hydra.queue(request)\n end", "def raw\n begin\n @raw ||= request_json(url)\n rescue OpenURI::HTTPError => e\n Rails.logger.error \"#{e.message}: #{url}\"\n raise\n end\n end", "def with_http_response(url, &block)\n uri = URI(url)\n\n request = Net::HTTP::Get.new(uri)\n request.initialize_http_header(request_headers)\n request_options[:use_ssl] = true\n\n environment_proxy = ignore_env_proxy ? nil : :ENV\n\n Net::HTTP.start(\n uri.host,\n uri.port,\n request_proxy&.host || environment_proxy,\n request_proxy&.port,\n request_proxy&.user,\n request_proxy&.password,\n request_options\n ) do |http|\n http.request(request, &block)\n end\n end", "def perform(no_block=false, &block)\n\n @results = {} if not @results.empty?\n\n @clients.each do |client|\n @threads << Thread.new do\n\n loop do\n break if @reqs.empty?\n (key, url) = @reqs.shift\n client.url = url\n client.http_get\n if block then\n yield(key, client.body_str)\n else\n @results[key] = client.body_str\n end\n end\n\n end\n end\n\n return {} if no_block\n\n join()\n return true if block\n\n ret = @results\n @results = {}\n return ret\n end", "def make_request(request, error)\n # URI request with timeouts\n uri = URI.parse(\"https://derpiboo.ru/#{request}\")\n http = Net::HTTP.new(uri.host, uri.port)\n http.open_timeout = 10\n http.read_timeout = 20\n http.use_ssl = true\n attempts = 1\n # Limit attempts so we dont annoy Derpibooru too badly\n response = nil\n while (attempts < 4) && response.nil?\n begin\n response = http.request_get(uri.request_uri)\n rescue\n sleep(attempts * 2)\n attempts += 1\n end\n end\n\n if response\n return JSON.parse(response.body)\n else\n error = \"Could not get a response from Derpibooru. Wait a few minutes and try again.\"\n return nil\n end\n end", "def request(options = nil, &block)\n if options.nil? && !block\n Request\n else\n Request.with(options, &block)\n end\n end", "def request!(&request)\n Transloadit::Response.new yield\n rescue RestClient::Exception => e\n Transloadit::Response.new e.response\n end", "def wrap_request\n outer_most = !request_info\n\n self.request_info = {} if outer_most\n yield\n ensure\n self.request_info = nil if outer_most\n end", "def handle_request request, usecase=Usecase, &block\n usecase = build_usecase( request, usecase, &block )\n usecase.response\n end", "def request(type, path)\n response = connection.send(type) do |req|\n req.url path\n req.params[\"maxResult\"] = 1_000\n req.headers.merge! headers\n yield req if block_given?\n end\n\n raise KontaktIo::Error.classify(response.status) unless response.success?\n\n response\n end", "def each(&block)\n response.read_body(&block)\n ensure\n session.end_request_hacked\n session.finish\n end", "def http_builder(&block)\n @connection_builder = block || nil\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 last_blocks_with_http_info(num, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: DefaultApi.last_blocks ...'\n end\n # verify the required parameter 'num' is set\n if @api_client.config.client_side_validation && num.nil?\n fail ArgumentError, \"Missing the required parameter 'num' when calling DefaultApi.last_blocks\"\n end\n # resource path\n local_var_path = '/api/v1/last_blocks'\n\n # query parameters\n query_params = opts[:query_params] || {}\n query_params[:'num'] = num\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', 'application/xml', ])\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] || 'Object' \n\n # auth_names\n auth_names = opts[:auth_names] || []\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: DefaultApi#last_blocks\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def call_block_for_request(request, parsed_response)\n if parsed_response[\"body\"].nil?\n request.on_complete_block.call(parsed_response) if request.on_complete_block\n else\n case request.token.gsub(/:.*/, \"\")\n when \"subscribe\"\n request.on_datastream_block.call(parsed_response) if request.on_datastream_block\n when \"get\"\n request.on_get_block.call(parsed_response) if request.on_get_block\n end\n end\n end", "def after_request(&block)\n @after_request = block if block\n @after_request || proc { |a| a }\n end", "def handle request, response\n\n options = {}\n options[:port] = request.port\n options[:ssl] = request.use_ssl?\n options[:proxy_uri] = request.proxy_uri\n options[:ssl_verify_peer] = request.ssl_verify_peer?\n options[:ssl_ca_file] = request.ssl_ca_file if request.ssl_ca_file\n options[:ssl_ca_path] = request.ssl_ca_path if request.ssl_ca_path\n\n connection = pool.connection_for(request.host, options)\n connection.read_timeout = request.read_timeout\n\n begin\n http_response = connection.request(build_net_http_request(request))\n response.body = http_response.body\n response.status = http_response.code.to_i\n response.headers = http_response.to_hash\n rescue Timeout::Error, Errno::ETIMEDOUT => e\n response.timeout = true\n end\n nil\n\n end", "def handle( request ) # note: all 'handle's return 'ml_response' in a chain\n\n# not yet request.record_arrival_time\n ml_response =\n case\n when request.get? then handle_get_muffin(request)\n when request.post? then handle_post(request)\n end\n# not yet request.record_completion_time\n ml_response\n end", "def requestHelper(url, method = 'Get', body = nil)\n\n # Set header value\n header = {\n 'Content-Type': 'text/json',\n 'Content-Security-Policy': 'default-src *'\n }\n\n # Set the uri value based on the url sent through.\n uri = URI(url)\n # Format request\n http = Net::HTTP.new(uri.host, uri.port)\n http.use_ssl = true\n\n # Create new request based on method\n request = Net::HTTP.const_get(method.capitalize).new(uri.request_uri, header)\n request.body = body\n\n # Send the request\n http.request(request) do |response|\n puts uri\n yield(JSON.parse(response.body))\n end\n end", "def get(options={}, &block)\n response = http.get_uri(options, &block)\n handle_response(response)\n end", "def trace_http_request( request )\n return yield unless NewRelic::Agent.is_execution_traced?\n\n begin\n t0, segment = start_trace( request )\n response = yield\n ensure\n finish_trace( t0, segment, request, response )\n end\n\n return response\n end", "def till_response attempt=1, max_attempts=5, &block\n response = block.call\n Rubix.logger.log(Logger::DEBUG, \"RECV: #{response.body}\") if Rubix.logger\n case\n when response.code.to_i >= 500 && attempt <= max_attempts\n sleep 1 # FIXME make the sleep time configurable...\n till_response(attempt + 1, max_attempts, &block)\n when response.code.to_i >= 500\n raise ConnectionError.new(\"Too many consecutive failed requests (#{max_attempts}) to the Zabbix API at (#{uri}).\")\n else\n @last_response = Response.new(response)\n end\n end", "def request_raw_response(options = {})\n # Need a deep clone here\n params = options.dup\n params[:params] = options.fetch(:params, {}).dup\n params[:headers] = options.fetch(:headers, {}).dup\n \n resp = transport(params[:params].delete(:region))\n .make_request(\n params[:method], \n params[:path],\n params[:params], \n request_headers_with(params[:headers])\n )\n\n unless Array(params[:expected]).include?(resp.status)\n fail Exception, \"Received status #{resp.status} which is not in #{params[:expected].inspect}\"\n end \n\n resp\n end", "def read_response(t = -1, opts = {})\n # Return a nil response if timeout is nil or 0\n return if t.nil? || t == 0\n\n resp = Response.new\n resp.max_data = config['read_max_data']\n\n Timeout.timeout((t < 0) ? nil : t) do\n\n rv = nil\n while (\n not conn.closed? and\n rv != Packet::ParseCode::Completed and\n rv != Packet::ParseCode::Error\n )\n\n begin\n\n buff = conn.get_once(resp.max_data, 1)\n rv = resp.parse(buff || '')\n\n # Handle unexpected disconnects\n rescue ::Errno::EPIPE, ::EOFError, ::IOError\n case resp.state\n when Packet::ParseState::ProcessingHeader\n resp = nil\n when Packet::ParseState::ProcessingBody\n # truncated request, good enough\n resp.error = :truncated\n end\n break\n end\n\n # This is a dirty hack for broken HTTP servers\n if rv == Packet::ParseCode::Completed\n rbody = resp.body\n rbufq = resp.bufq\n\n rblob = rbody.to_s + rbufq.to_s\n tries = 0\n begin\n # XXX: This doesn't deal with chunked encoding or \"Content-type: text/html; charset=...\"\n while tries < 1000 and resp.headers[\"Content-Type\"]== \"text/html\" and rblob !~ /<\\/html>/i\n buff = conn.get_once(-1, 0.05)\n break if not buff\n rblob += buff\n tries += 1\n end\n rescue ::Errno::EPIPE, ::EOFError, ::IOError\n end\n\n resp.bufq = \"\"\n resp.body = rblob\n end\n end\n end\n\n return resp if not resp\n\n # As a last minute hack, we check to see if we're dealing with a 100 Continue here.\n # Most of the time this is handled by the parser via check_100()\n if resp.proto == '1.1' and resp.code == 100 and not opts[:skip_100]\n # Read the real response from the body if we found one\n # If so, our real response became the body, so we re-parse it.\n if resp.body.to_s =~ /^HTTP/\n body = resp.body\n resp = Response.new\n resp.max_data = config['read_max_data']\n rv = resp.parse(body)\n # We found a 100 Continue but didn't read the real reply yet\n # Otherwise reread the reply, but don't try this hack again\n else\n resp = read_response(t, :skip_100 => true)\n end\n end\n\n resp\n rescue Timeout::Error\n # Allow partial response due to timeout\n resp if config['partial']\n end", "def do_restful_action(action, model, &block)\n begin\n # do block\n response = yield\n return parse_response(response)\n\n rescue RestClient::NotAcceptable => u\n # we might be able to glean errors from HTML in response\n logger.debug(\"Nagyo.#{action}:#{model}: #{u}\")\n error = parse_response(u.response)\n raise Exception.new([Exception.new(error), u]) if self.raise_errors\n rescue Exception => e\n logger.error(\"Nagyo.#{action}:#{model}: #{e}\")\n raise e if self.raise_errors\n end\n end", "def get_without_timeout(url, headers={}, &block)\n RestClient::Request.new(method: :get, url: url, headers: headers, timeout: nil).execute(& block)\n end", "def request(params, &block)\n begin\n # connection has defaults, merge in new params to override\n params = @connection.merge(params)\n params[:headers] = @connection[:headers].merge(params[:headers] || {})\n params[:headers]['Host'] ||= '' << params[:host] << ':' << params[:port]\n\n # if path is empty or doesn't start with '/', insert one\n unless params[:path][0, 1] == '/'\n params[:path].insert(0, '/')\n end\n\n if params[:mock]\n for stub, response in Excon.stubs\n # all specified non-headers params match and no headers were specified or all specified headers match\n if [stub.keys - [:headers]].all? {|key| stub[key] == params[key] } &&\n (!stub.has_key?(:headers) || stub[:headers].keys.all? {|key| stub[:headers][key] == params[:headers][key]})\n case response\n when Proc\n return Excon::Response.new(response.call(params))\n else\n return Excon::Response.new(response)\n end\n end\n end\n # if we reach here no stubs matched\n raise(Excon::Errors::StubNotFound.new('no stubs matched ' << params.inspect))\n end\n\n # start with \"METHOD /path\"\n request = params[:method].to_s.upcase << ' '\n if @proxy\n request << params[:scheme] << '://' << params[:host] << ':' << params[:port]\n end\n request << params[:path]\n\n # add query to path, if there is one\n case params[:query]\n when String\n request << '?' << params[:query]\n when Hash\n request << '?'\n for key, values in params[:query]\n if values.nil?\n request << key.to_s << '&'\n else\n for value in [*values]\n request << key.to_s << '=' << CGI.escape(value.to_s) << '&'\n end\n end\n end\n request.chop! # remove trailing '&'\n end\n\n # finish first line with \"HTTP/1.1\\r\\n\"\n request << HTTP_1_1\n\n # calculate content length and set to handle non-ascii\n unless params[:headers].has_key?('Content-Length')\n params[:headers]['Content-Length'] = case params[:body]\n when File\n params[:body].binmode\n File.size(params[:body])\n when String\n if FORCE_ENC\n params[:body].force_encoding('BINARY')\n end\n params[:body].length\n else\n 0\n end\n end\n\n # add headers to request\n for key, values in params[:headers]\n for value in [*values]\n request << key.to_s << ': ' << value.to_s << CR_NL\n end\n end\n\n # add additional \"\\r\\n\" to indicate end of headers\n request << CR_NL\n\n # write out the request, sans body\n socket.write(request)\n\n # write out the body\n if params[:body]\n if params[:body].is_a?(String)\n socket.write(params[:body])\n else\n while chunk = params[:body].read(CHUNK_SIZE)\n socket.write(chunk)\n end\n end\n end\n\n # read the response\n response = Excon::Response.parse(socket, params, &block)\n\n if response.headers['Connection'] == 'close'\n reset\n end\n\n response\n rescue Excon::Errors::StubNotFound => stub_not_found\n raise(stub_not_found)\n rescue => socket_error\n reset\n raise(Excon::Errors::SocketError.new(socket_error))\n end\n\n if params.has_key?(:expects) && ![*params[:expects]].include?(response.status)\n reset\n raise(Excon::Errors.status_error(params, response))\n else\n response\n end\n\n rescue => request_error\n if params[:idempotent] && [Excon::Errors::SocketError, Excon::Errors::HTTPStatusError].include?(request_error)\n retries_remaining ||= 4\n retries_remaining -= 1\n if retries_remaining > 0\n retry\n else\n raise(request_error)\n end\n else\n raise(request_error)\n end\n end", "def options(url, options = {}, &block)\n request HttpOptions, url, options, &block\n end", "def request_data(request_url)\n\n uri = URI.parse(request_url)\n response = Net::HTTP.get_response(uri)\n data = JSON.parse(response.body)\n return data\n\nend", "def process_request(request)\n request['User-Agent'] = @user_agent\n request['Content-Type'] = 'application/json'\n request['X-BitPay-Plugin-Info'] = 'Rubylib' + VERSION\n\n begin\n response = @https.request request\n rescue => error\n raise BitPay::ConnectionError, \"#{error.message}\"\n end\n\n if response.kind_of? Net::HTTPSuccess\n return JSON.parse(response.body)\n elsif JSON.parse(response.body)[\"error\"]\n raise(BitPayError, \"#{response.code}: #{JSON.parse(response.body)['error']}\")\n else\n raise BitPayError, \"#{response.code}: #{JSON.parse(response.body)}\"\n end\n\n end", "def request(&_)\n if block_given?\n @request ||= Request.new\n yield @request\n end\n @request\n end", "def run\n return if halted?\n\n http = request.em\n http.callback {\n Benchy.logger.info \"#{name}\\t| #{request.method.upcase} #{request.url} - HTTP #{http.response_header.status}\"\n run\n }\n http.errback {\n Benchy.logger.error \"#{name}\\t| Connection error!\"\n halt # TODO - Make this fail the ping and try again, not halt\n }\n end", "def method_missing(name, *args, &block)\n response.body.send(name, *args, &block)\n end", "def response(&_)\n if block_given?\n @response ||= Response.new\n yield @response\n end\n @response\n end", "def api_request(&block)\n response = begin\n block.call([])\n rescue RestClient::Exception => e\n if e.http_code == 401 # raise exception in case of token expiration\n raise e\n else\n e.response\n end\n end\n\n parse_and_format_response response\n end", "def do_request(request, want_reply, data); end", "def http_request(url, options = {})\n\t\t\treq = Net::HTTP::Get.new(url)\n\t\t\treq[\"user-agent\"] = @@user_agent # ensure returns XML\n\t\t\treq[\"cookie\"] = \"cookieMenu=all; cookieLangId=\" + options[:lang] + \"; cookies=true;\"\n\t\t\t\n\t\t\treq[\"cookie\"] += options[:cookie] if options[:cookie]\n\n\t\t\turi = URI.parse(URI.escape(url))\n\t\t\t\n\t\t\thttp = Net::HTTP.new(uri.host, uri.port)\n\t\t\t\n\t\t\tif (options[:secure])\n\t\t\t\tputs \"Secure authentication\" if options[:debug]\n\n\t\t\t\thttp.verify_mode = OpenSSL::SSL::VERIFY_NONE\n\t\t\t\thttp.use_ssl = true\n\t\t\tend\n\t\t \n\t\t\t\n\t\t\tbegin\n\t\t\t\ttries = 0\n\t\t\t http.start do\n\t\t\t\t puts \"Get URL \"+ url if options[:debug]\n\t\t\t res = http.request req\n\t\t\t\t\t# response = res.body\n\t\t\t\t\t\n\t\t\t\t\t# FIXME WoW Armory rate limiter. Simple version\n\t\t\t\t\t# Needs to work across instances and not sleep for 1.5 if the\n\t\t\t\t\t# request took more than 1.5\n\t\t\t\t\t# just need a 1.5 second wait until the start of the next request\n \n if options[:rate_limit]\n\t\t\t\t\t puts \"Sleeping for 1.5 seconds\" if options[:debug]\n \t\t\t\t\tsleep 1.5\n\t\t\t\t\tend\n\n\t\t\t\t\tresponse = case res\n\t\t\t\t\t\twhen Net::HTTPSuccess, Net::HTTPRedirection\n\t\t\t\t\t\t\tres.body\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\ttries += 1\n\t\t\t\t\t\t\tif tries > @@max_connection_tries\n\t\t\t\t\t\t\t\traise Wowr::Exceptions::NetworkTimeout.new('Timed out')\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\tredo\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\tend\n\t\t\t end\n\t\t\trescue Timeout::Error => e\n raise Wowr::Exceptions::NetworkTimeout.new('Timed out - Timeout::Error Exception')\n\t\t\trescue SocketError, Net::HTTPExceptions => e\n\t\t\t\traise Wowr::Exceptions::ServerDoesNotExist.new('Specified server at ' + url + ' does not exist.')\n\t\t\tend\n\t\tend", "def noop\n write_noop\n multi_response\n end", "def get_block(*params); raise('Stub or mock required.') end", "def request_and_handle http_method, path, options\n if http_method.is_a?(String) || http_method.is_a?(Symbol)\n http_method = HTTP_METHODS[http_method.to_s]\n raise \"Unknown http method: #{http_method}\" unless http_method\n end\n \n req_options = default_options.dup\n req_options = req_options.merge(options)\n \n raise ConfigurationError.new \"No endpoint defined\" if !path || path.empty?\n raise ConfigurationError.new \"No hostname defined\" if !req_options[:base_uri] || req_options[:base_uri].empty?\n \n # prepare request\n req = HTTParty::Request.new http_method, path, req_options\n req.options[:timeout] = CityGrid.custom_timeout if req.options && CityGrid.custom_timeout_set?\n\n # Sanitized request for logs\n safe_req_options = strip_unsafe_params(http_method, req_options)\n req_to_output = HTTParty::Request.new http_method, path, safe_req_options\n req_for_airbrake = { :method => http_method, :path => path, :options => safe_req_options }\n\n begin\n response = req.perform\n rescue => ex \n if defined?(Rails.logger)\n Rails.logger.error safe_req_options\n Rails.logger.error req_to_output\n Rails.logger.error req_for_airbrake\n Rails.logger.error ex\n end\n raise CityGridExceptions::RequestError.new req_for_airbrake, nil, ex.message, req_to_output.to_curl\n ensure\n if CityGrid.print_curls? \n if defined?(Rails.logger)\n Rails.logger.info req_to_output.to_curl\n puts req_to_output.to_curl\n else\n puts req_to_output.to_curl\n end\n end\n end\n\n response_status = parse_response_status response\n \n begin \n # catch unparsable responses (html etc)\n if !response.parsed_response.is_a?(Hash)\n #pp \"[gem] the response was unparsable (response was not a hash)\"\n raise CityGridExceptions::ResponseParseError.new req_for_airbrake, response, \"the response was unparsable (response was not a hash)\", req_to_output.to_curl\n else\n # Parse and handle new response codes \n if !response_status.nil? && response_status[\"code\"] != \"SUCCESS\" && response_status[\"code\"] != 200\n raise CityGridExceptions.appropriate_error(response_status[\"code\"]).new req_for_airbrake, response, response_status[\"message\"].to_s, req_to_output.to_curl\n else\n return CityGrid::API::Response.new response\n end\n end\n rescue => ex\n pp \"API ERROR: #{ex}\"\n raise ex if CityGrid.raise_errors?\n end\n end", "def default_request_options\n {:timeout => 0, :head => {}}\n end", "def request_and_handle http_method, path, options\n if http_method.is_a?(String) || http_method.is_a?(Symbol)\n http_method = HTTP_METHODS[http_method.to_s]\n raise \"Unknown http method: #{http_method}\" unless http_method\n end\n \n req_options = default_options.dup\n req_options = req_options.merge(options)\n \n raise ConfigurationError.new \"No endpoint defined\" if !path || path.empty?\n raise ConfigurationError.new \"No hostname defined\" if !req_options[:base_uri] || req_options[:base_uri].empty?\n \n # prepare request\n req = HTTParty::Request.new http_method, path, req_options\n\n # Sanitized request for logs\n safe_req_options = strip_unsafe_params(http_method, req_options)\n req_to_output = HTTParty::Request.new http_method, path, safe_req_options\n req_for_airbrake = { :method => http_method, :path => path, :options => safe_req_options }\n\n begin\n response = req.perform\n rescue => ex\n raise CityGridExceptions::RequestError.new req_for_airbrake, ex\n ensure\n if CityGrid.print_curls? \n if defined?(Rails.logger)\n Rails.logger.info req_to_output.to_curl\n else\n puts req_to_output.to_curl\n end\n end\n end\n\n \n begin \n # catch unparsable responses (html etc)\n if !response.parsed_response.is_a?(Hash)\n #pp \"[gem] the response was unparsable (response was not a hash)\"\n raise CityGridExceptions::ResponseParseError.new req_for_airbrake, response\n # catch responses not in new response format\n elsif response[\"errors\"]\n #pp \"[gem] An error in the old response format was caught. Raising a general response error...\"\n raise CityGridExceptions::ResponseError.new req_for_airbrake, response[\"errors\"], response\n\n # Parse and handle new response codes \n elsif (response[\"response\"] && response[\"response\"][\"code\"] != \"SUCCESS\") && \n (response[\"response\"] && response[\"response\"][\"code\"] != 200) && \n (response[\"response\"] && response[\"response\"][\"code\"] != 400) \n error_code = response[\"response\"][\"code\"]\n #pp \"[gem] The response was contained in the first level of the response hash. Below:\"\n #pp response\n #pp \"found error code: #{error_code}\"\n #pp \"****************************************************************************\"\n raise CityGridExceptions.appropriate_error(error_code).new req_for_airbrake, response, response[\"response\"][\"message\"].to_s #+ \" \" + CityGridExceptions.print_superclasses(error_code)\n # if the response is a nested hash/nested hash containing arrays\n elsif response[\"totalNumEntries\"] && response[\"response\"].nil?\n #pp \"[gem] now parsing a response with multiple entries: #{response}\"\n error_code = parse_multiple_responses(response)\n #pp \"the error code that came back is #{error_code}\"\n if error_code.nil? || error_code == []\n #pp \"[gem] passing over this for now\"\n return CityGrid::API::Response.new response # pass over for now\n elsif error_code[0] == \"SUCCESS\" || error_code[0] == 200 || error_code[0] == 400\n return CityGrid::API::Response.new response\n else \n #pp \"[gem] we found an error and it was #{error_code[1]}\"\n raise CityGridExceptions.appropriate_error(error_code[0]).new req_for_airbrake, response, error_code[1].to_s + \" \"# + CityGridExceptions.print_superclasses(error_code[0])\n end\n else\n return CityGrid::API::Response.new response\n end\n rescue => ex\n pp \"The gem threw an error: #{ex}\"\n raise ex if CityGrid.raise_errors?\n end\n end", "def send_request(method, params, &block); end", "def body(&block)\n call_once\n @body ||= begin\n if entity = @response.get_entity\n EntityConverter.new.read_entity(entity, &block)\n end\n rescue Java::JavaIo::IOException, Java::JavaNet::SocketException, IOError => e\n raise StreamClosedException.new(\"Could not read from stream: #{e.message}\")\n # ensure\n # @request.release_connection\n end\n end", "def enterprise_api_should_block_with_http_info(phone_number, user_phone_number, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: EnterpriseApiApi#enterprise_api_should_block ...\"\n end\n \n # verify the required parameter 'phone_number' is set\n fail \"Missing the required parameter 'phone_number' when calling enterprise_api_should_block\" if phone_number.nil?\n \n # verify the required parameter 'user_phone_number' is set\n fail \"Missing the required parameter 'user_phone_number' when calling enterprise_api_should_block\" if user_phone_number.nil?\n \n # resource path\n local_var_path = \"/api/2015-11-01/Enterprise/ShouldBlock/{phoneNumber}/{userPhoneNumber}\".sub('{format}','json').sub('{' + 'phoneNumber' + '}', phone_number.to_s).sub('{' + 'userPhoneNumber' + '}', user_phone_number.to_s)\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n\n # HTTP header 'Accept' (if needed)\n _header_accept = ['application/json', 'text/json', 'application/xml', 'text/xml']\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 = []\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 auth_names = []\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 => 'String')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: EnterpriseApiApi#enterprise_api_should_block\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def head_request(request_data = {}, errback = DEFAULT_ERROR, &blk)\n req = create_test_request(request_data).head(request_data)\n hookup_request_callbacks(req, errback, &blk)\n end", "def actions\n response = nil\n\n lambda do |reason, data|\n puts \"Execute block code with reason : #{reason}\"\n break response = data\n end\n\n response\n end", "def request_async uri\n options = Kronk.config[:no_uri_options] ? @options : options_for_uri(uri)\n\n rdir = options[:follow_redirects]\n\n handler = Proc.new do |resp, err|\n next yield(resp, err) if err\n\n resp.parser = options[:parser] if options[:parser]\n resp.stringify_opts = options\n\n if resp.redirect? && (rdir == true || Fixnum === rdir && rdir > 0)\n Cmd.verbose \"Following redirect to #{resp.location}\"\n\n rdir = rdir - 1 if Fixnum === rdir\n opts = options_for_uri resp.location\n resp.follow_redirect_async(opts, &handler)\n\n else\n @responses = [resp]\n @response = resp\n @diff = nil\n\n yield resp if block_given?\n\n resp\n end\n end\n\n if IO === uri\n Cmd.verbose \"Reading IO #{uri}\"\n Response.from_async_io(uri, &handler)\n\n elsif StringIO === uri\n Cmd.verbose \"Reading IO #{uri}\"\n handler.call Response.new(uri)\n\n elsif File.file? uri.to_s\n Cmd.verbose \"Reading file: #{uri}\\n\"\n handler.call Response.read_file(uri)\n\n else\n req = Request.new uri, options\n Cmd.verbose \"Retrieving URL: #{req.uri}\\n\"\n conn = req.retrieve_async(&handler)\n conn.callback{ Kronk.history << uri }\n end\n\n rescue => e\n yield nil, e\n end", "def request\n Timeout::timeout(timeout) { @request ||= open(url, {:allow_redirections => allow_redirections, 'User-Agent' => user_agent}) }\n\n rescue TimeoutError\n add_fatal_error 'Timeout!!!'\n rescue SocketError\n add_fatal_error 'Socket error: The url provided does not exist or is temporarily unavailable'\n rescue Exception => e\n add_fatal_error \"Scraping exception: #{e.message}\"\n end", "def request(method, path, params = {})\n req = create_request path\n req.request method.upcase, params do |response|\n if (200..300).cover?(response.status)\n yield response.json if block_given?\n else\n warn response.json['error']\n end\n end\n end", "def response\n @response ||= request!(true)\n end", "def with_exception_handling\r\n yield\r\n rescue Timeout::Error => exc\r\n return { code: Scrapers::StatusCodes::BLOCKED_REQUEST }\r\n rescue Exception => exc\r\n @logger.error(\"\\n#{self.class} error\")\r\n @logger.error(exc)\r\n @logger.error(exc.backtrace.join(\"\\n\"))\r\n @logger.error(body)\r\n\r\n return { code: Scrapers::StatusCodes::INTERNAL_ERROR }\r\n end", "def response\n http = Net::HTTP.new(@options[:url], 443)\n http.use_ssl = true\n path = '/nvp'\n headers = {\n 'Content-Type' => 'application/x-www-form-urlencoded'\n }\n\n # dryrun support, provides a 204 which is success without content\n return ResponseHandler.new(\n Net::HTTPNoContent.new(true, true,true)\n ) if dryrun?\n\n # request caching\n silence_warnings do\n return @cached_response if @cached_response\n resp, data = http.post(path, request_string, headers)\n @cached_response = ResponseHandler.new(resp, data)\n end\n end", "def request_with_retry(request, body=nil, attempts=2, time=10)\n loop do\n if debug\n puts \"\\n####\"\n puts \"## Making #{request.method} request to #{@http.address + request.path}\"\n puts \"## Request body: #{body}\" if body\n end\n @response = @http.request(request, body)\n @parsed_response = JSON.parse(@response.body) rescue nil\n if debug\n puts \"## Response code: #{@response.code}\"\n if debug == \"verbose\"\n puts \"## Response body: #{@response.body}\"\n elsif @parsed_response &&\n Hash === @parsed_response &&\n @parsed_response[\"message\"]\n puts \"## Error message: #{@parsed_response[\"message\"]}\"\n end\n end\n break unless @response.code =~ /^5\\d{2}$/\n\n attempts -= 1\n break if attempts.zero?\n\n if debug\n puts \"## Retries remaining: #{attempts}, pausing #{time} seconds.\"\n else\n print 'R'\n end\n\n sleep(time)\n end\n @parsed_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 http_get(request_uri)\n response = http.request(Net::HTTP::Get.new(request_uri))\n yield response.body if response.code == \"200\"\n end", "def send_get(url)\r\n result = @client.get(self.target_uri(url))\r\n raise \"Invalid status #{result.http_status} from server #{@host}:#{@port}\" if(result.http_status != '200')\r\n if block_given?\r\n yield(result.http_body)\r\n else\r\n result.http_body\r\n end\r\n end", "def patch_http\n ::Net::HTTP.class_eval do\n alias_method :request_without_datadog, :request\n remove_method :request\n\n def datadog_pin\n @datadog_pindatadog_pin ||= begin\n service = Datadog.configuration[:http][:service_name]\n tracer = Datadog.configuration[:http][:tracer]\n\n Datadog::Pin.new(service, app: Ext::APP, app_type: Datadog::Ext::AppTypes::WEB, tracer: tracer)\n end\n end\n\n def request(req, body = nil, &block) # :yield: +response+\n pin = datadog_pin\n return request_without_datadog(req, body, &block) unless pin && pin.tracer\n\n transport = pin.tracer.writer.transport\n\n if Datadog::Contrib::HTTP.should_skip_tracing?(req, @address, @port, transport, pin)\n return request_without_datadog(req, body, &block)\n end\n\n pin.tracer.trace(Ext::SPAN_REQUEST) do |span|\n begin\n span.service = pin.service\n span.span_type = Datadog::Ext::HTTP::TYPE\n\n span.resource = req.method\n # Using the method as a resource, as URL/path can trigger\n # a possibly infinite number of resources.\n span.set_tag(Datadog::Ext::HTTP::URL, req.path)\n span.set_tag(Datadog::Ext::HTTP::METHOD, req.method)\n\n if pin.tracer.enabled && !Datadog::Contrib::HTTP.should_skip_distributed_tracing?(pin)\n req.add_field(Datadog::Ext::DistributedTracing::HTTP_HEADER_TRACE_ID, span.trace_id)\n req.add_field(Datadog::Ext::DistributedTracing::HTTP_HEADER_PARENT_ID, span.span_id)\n if span.context.sampling_priority\n req.add_field(\n Datadog::Ext::DistributedTracing::HTTP_HEADER_SAMPLING_PRIORITY,\n span.context.sampling_priority\n )\n end\n end\n rescue StandardError => e\n Datadog::Tracer.log.error(\"error preparing span for http request: #{e}\")\n ensure\n response = request_without_datadog(req, body, &block)\n end\n span.set_tag(Datadog::Ext::HTTP::STATUS_CODE, response.code)\n if req.respond_to?(:uri) && req.uri\n span.set_tag(Datadog::Ext::NET::TARGET_HOST, req.uri.host)\n span.set_tag(Datadog::Ext::NET::TARGET_PORT, req.uri.port.to_s)\n else\n span.set_tag(Datadog::Ext::NET::TARGET_HOST, @address)\n span.set_tag(Datadog::Ext::NET::TARGET_PORT, @port.to_s)\n end\n\n case response.code.to_i / 100\n when 4\n span.set_error(response)\n when 5\n span.set_error(response)\n end\n\n response\n end\n end\n end\n end" ]
[ "0.58503574", "0.581427", "0.5748257", "0.56917125", "0.5664362", "0.5662406", "0.5619606", "0.560487", "0.55488604", "0.5483149", "0.5476715", "0.5455845", "0.5434253", "0.5422489", "0.5409693", "0.5383195", "0.5377444", "0.5372209", "0.5367742", "0.5367375", "0.5306031", "0.528991", "0.52861995", "0.5286045", "0.52805907", "0.52757126", "0.52460164", "0.52395266", "0.5230004", "0.52294064", "0.52249825", "0.520709", "0.5204144", "0.52041185", "0.5198053", "0.5198053", "0.5190395", "0.51798075", "0.5165848", "0.5158717", "0.51386267", "0.51189977", "0.51099193", "0.51096064", "0.5091077", "0.5087512", "0.5061623", "0.5057888", "0.505422", "0.5050514", "0.50474644", "0.5035599", "0.50305134", "0.5022979", "0.50111353", "0.50020325", "0.49752244", "0.49556518", "0.49523985", "0.49508205", "0.49452263", "0.4936341", "0.49224788", "0.49169478", "0.49115714", "0.4910605", "0.49056625", "0.4892793", "0.48681992", "0.4861711", "0.48585674", "0.48427376", "0.48357573", "0.48327512", "0.4827186", "0.48215628", "0.48140058", "0.48090672", "0.48018393", "0.47964907", "0.47891682", "0.47873232", "0.47857478", "0.4770662", "0.4768539", "0.4768427", "0.47537127", "0.4743884", "0.47436783", "0.47393957", "0.47363374", "0.47207123", "0.47191504", "0.47180548", "0.471537", "0.47042295", "0.47036016", "0.47001794", "0.46994847", "0.46891886" ]
0.57648283
2
Returns a copy of +headers+ that includes a LogWeasel header if a LogWeasel transaction is in progress.
def merge_log_weasel_header(headers) if LogWeasel::Transaction.id headers.merge(LogWeasel::Middleware::KEY_HEADER => LogWeasel::Transaction.id) else headers end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def headers\n call_once\n @headers\n end", "def headers\n @headers ||={}\n end", "def headers\n @headers ||= {}\n end", "def get_headers\n @headers = headers\n @headers\n end", "def headers\n @headers ||= {}\n end", "def headers\n @headers.reject {|k, v| k == :body }.map do |k, v|\n translate_header_name(k) + ': ' + v + \"\\n\"\n end.join\n end", "def headers(headers = nil)\n @headers.assign(headers) if headers\n @headers\n end", "def headers\n @headers ||= message.header_fields\n end", "def headers(hash=nil)\n @headers = hash unless hash.nil?\n @headers ||= {}\n end", "def headers(hash = nil || (return @headers))\n @headers.merge!(hash)\n end", "def headers\n res = parsed_headers\n if has_delta?\n res.concat(delta_headers)\n end\n res\n end", "def headers\n # units and source have to go last, so if we push in a new header, these go\n # at end\n @headers+['units','source']\n end", "def headers(_context)\n _context[:headers] || EMPTY_HEADERS\n end", "def headers\n if !@headers\n @headers = MultiMap.new(@j_del.headers)\n end\n @headers\n end", "def headers\n if !@headers\n @headers = MultiMap.new(@j_del.headers)\n end\n @headers\n end", "def headers\n if !@headers\n @headers = MultiMap.new(@j_del.headers)\n end\n @headers\n end", "def headers\n\t\t\thdr = @curb.header_str\n\t\t\tself.class.recode(log?, @curb.content_type, hdr) ?\n\t\t\t\tself.class.parse_headers(hdr) :\n\t\t\t\tself.class.parse_headers(@curb.header_str) # recode failed\n\t\tend", "def headers\r\n # NB: return value is supposed to be an array of strings\r\n @headers || []\r\n end", "def headers\n if !block_given?\n return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:headers, []).call(),::Vertx::MultiMap)\n end\n raise ArgumentError, \"Invalid arguments when calling headers()\"\n end", "def headers(new_headers = {})\n (@headers ||= {}).merge!(new_headers)\n end", "def headers\n @headers ||= HeaderHash.new(@http_response.to_hash)\n end", "def headers\n @headers.to_a\n end", "def headers\n @headers.to_a\n end", "def headers\n @headers || true if @use_headers\n end", "def headers\n @headers\n end", "def headers\n @headers ||= begin\n @mail.header.fields.inject({}) do |memo, field|\n name = field.name.downcase.to_s\n next memo if self.class.skipped_headers.include?(name)\n\n header = unquoted_header(name)\n memo.update(name => self.class.unescape(header))\n end\n end\n end", "def headers\n self.class.const_get(:HEADERS) rescue []\n end", "def getHeaders\n @headers\n end", "def headers(_context)\n {}\n end", "def headers\n {}\n end", "def headers\n {}\n end", "def headers\n {}\n end", "def with_headers(tmp_headers)\n current_headers = @headers\n add_headers(tmp_headers)\n yield\n ensure\n add_headers(current_headers)\n end", "def with_headers(tmp_headers)\n current_headers = @headers\n add_headers(tmp_headers)\n yield\n ensure\n add_headers(current_headers)\n end", "def all_headers current_class = nil\n current_class ||= self\n return {} if current_class == Object\n current_header = current_class.headers || {}\n return current_header.merge all_headers(current_class.superclass)\n end", "def target_headers\n @headers.select { |k, _| ALL.include? k }\n end", "def headers\n @headers ||= begin\n mail = Mail.new(self.raw_headers)\n mail.header.fields.each_with_object({}) do |field, hash|\n hash[field.name.downcase] ||= []\n hash[field.name.downcase] << field.decoded\n end\n end\n end", "def headers; return {}; end", "def headers; return {}; end", "def headers\n msg['headers']||{}\n end", "def headers(hash = {})\n hash.each_pair do |k,v|\n @header[k] = v\n end\n end", "def headers\n @headers ||= next_row\n end", "def with_headers(tmp_headers)\n current_headers = @headers\n set_headers(tmp_headers)\n yield\n ensure\n set_headers(current_headers)\n end", "def headers hash=nil\n @response.headers.merge! hash if hash\n @response.headers\n end", "def headers(headers); end", "def headers\n @attributes[:headers]\n end", "def headers(header = nil)\n if header.is_a?(Hash)\n @headers ||= {}\n @headers.merge!(header)\n end\n\n return @headers if @headers\n\n superclass.respond_to?(:headers) ? superclass.headers : nil\n end", "def headers\n h = {}\n raw.headers_hash.each {|k,v| h[k] = v }\n h\n end", "def headers\n @headers ||= begin\n [\n 'estimated_amount',\n 'country',\n 'kyc_confirm_date',\n 'kyc_approval_status',\n 'proof_of_support',\n 'alt_bonus',\n 'purchased_amount',\n 'phase_1_purchased_amount',\n 'phase_2_purchased_amount',\n 'number_of_transactions'\n ]\n end\n end", "def headers(hash = {})\n hash.each_pair do |k,v|\n header[k] = v\n end\n end", "def headers\n @headers ||= self.class.beautify_headers(@net_http_res.to_hash)\n end", "def log_headers(headers)\n @api.logger.debug(headers.map {|k, v| [k, v].join(': ')}.join(', '))\n end", "def join_headers; end", "def soap_headers\n @soap_headers ||= {}\n @soap_headers.merge!(:client_id => @client_id) if @client_id\n @soap_headers\n end", "def headers\n @headers ||= @s3.object_headers(@bucket, @key)\n end", "def to_hash\n @headers\n end", "def headers\n @request_headers\n end", "def scrub_headers(headers)\n headers.select {|h| UserMailer.legal_headers.include? h}\n end", "def raw_headers; end", "def headers\n @headers.merge({ \"Status\" => @status })\n end", "def headers(headers)\n @headers = headers\n end", "def headers\n @attributes + @includes.values.flatten\n end", "def get_headers_\n hin = ATS::Headers_in.new\n hin.all.reduce({}) do |memo, pair| \n memo[pair.first.downcase] = pair[1]; memo\n end\n end", "def headers=(headers={})\n @headers = headers.merge(\n \"x-amz-date\" => request_timestamp\n )\n end", "def headers\n cfg_get(:headers)\n end", "def freeze\n @headers.freeze\n super\n end", "def headers=(headers)\n @headers = headers if headers.kind_of? Hash\n end", "def headers=(hash); end", "def headers=(hash); end", "def stringify_headers(headers); end", "def headers\n begin\n JSON(data['message_headers'])\n rescue => e\n return []\n end\n end", "def headers\n @headers.tap do |headers|\n headers[:algorithm] = configuration.algorithm if verification?\n case configuration.claim\n when CLAIM_EXPIRATION_TIME\n headers.merge!(exp_headers)\n when CLAIM_NOT_BEFORE_TIME\n headers.merge!(nbf_headers)\n end\n end\n end", "def make_headers(user_headers); end", "def on_headers(headers)\n log.info { \">> headers (#{headers.size})\" }\n headers.each {|h| @node.queue.push([:block, h])}\n end", "def headers_to_store(headers)\n ignored_headers = headers.except('X-Storehouse', 'X-Storehouse-Expires-At')\n ignored_headers = ignored_headers.except(*Storehouse.ignore_headers)\n\n ignored_headers\n end", "def normalized_headers\n\t\theaders = self.headers.dup\n\n\t\theaders[:date] ||= Time.now.httpdate\n\n\t\tif self.bodiless? && !self.extended_reply?\n\t\t\theaders.delete( :content_length )\n\t\t\theaders.delete( :content_type )\n\t\telse\n\t\t\theaders[:content_length] ||= self.get_content_length\n\t\t\theaders[:content_type] ||= DEFAULT_CONTENT_TYPE.dup\n\t\tend\n\n\t\treturn headers\n\tend", "def internet_message_headers\n return @internet_message_headers\n end", "def each_request_target_with_headers(&block)\n\t\ttarget_requests('AND requests.headers IS NOT NULL').each do |req|\n\t\t\tblock.call(req)\n\t\tend\n\tend", "def processed_headers; end", "def request_headers\n @request_headers.map do |header, value|\n \"#{header}: #{value}\"\n end.join(\"\\n\")\n end", "def get_headers\n request_object.headers\n end", "def header(hash = {})\n @headers.merge!(hash)\n end", "def headers\n headers = {}\n headers['Content-Type'] = 'application/x-www-form-urlencoded'\n headers['X-SILENCE-LOGGER'] = 'true'\n headers['Dont-Chunk'] = 'true' unless self.class.long_polling\n\n headers\n end", "def request_headers\n {}\n end", "def each_request_target_with_headers(&block)\n\t\ttarget_requests('AND wmap_requests.headers IS NOT NULL').each do |req|\n\t\t\tblock.call(req)\n\t\tend\n\tend", "def csv_headers\n return @@csv_headers\n end", "def to_headers\n headers = {}\n h = data.merge(@deleted_hash)\n h.each_pair do |k,v|\n key = to_header_key(k,v)\n headers[key] = v || DUMMY_VALUE\n end\n\n headers\n end", "def append_headers(*headers)\n new_headers = headers.join(\"\\r\\n\")\n new_headers = \"#{new_headers}\\r\\n#{self.raw_headers}\"\n @raw_headers = new_headers\n @raw_validation = nil\n @headers = nil\n end", "def append_headers(*headers)\n new_headers = headers.join(\"\\r\\n\")\n new_headers = \"#{new_headers}\\r\\n#{self.raw_headers}\"\n @database.update(self.raw_table, {:data => new_headers}, :where => {:id => self.raw_headers_id})\n @raw_headers = new_headers\n @raw_message = nil\n @headers = nil\n end", "def headers_hash\n @headers_hash ||= Hash[@http_headers.split(\"\\x00\").map{|x| x.split(': ',2)}]\n end", "def str_headers(env, status, headers, res_info, lines, requests, client); end", "def response_headers\n @headers\n end", "def headers\n @headers ||= rack_environment.select{|k,v| k.start_with? 'HTTP_'}\n end", "def request_headers! header_hash\n errors = header_hash.each_with_object [] do |(key, val), errors|\n key = key.to_s; val = val.to_s\n rv = Wrapper.msc_add_n_request_header txn_ptr, (strptr key), key.bytesize, (strptr val), val.bytesize\n rv == 1 or errors << \"msc_add_n_request_header failed adding #{[key,val].inspect}\"\n end\n\n raise Error errors if errors.any?\n\n rv = Wrapper.msc_process_request_headers txn_ptr\n rv == 1 or raise \"msc_process_request_headers failed\"\n\n intervention!\n end", "def transactions_log\n @log ||= []\n end", "def headers(header = nil)\n @response.headers.merge!(header) if header\n @response.headers\n end", "def join_headers\n # join the headers array with crlfs, stick two on the end because\n # that ends the request header\n @request_header.join(CRLF) + (CRLF) * 2\n end", "def headers\n end", "def headers (bundle)\n data = capture(:headers, bundle)\n extract_bundle_headers(data)\n end", "def headers_with_indexes\n @headers_with_indexes ||= headers.each_with_index.to_h\n end" ]
[ "0.62355393", "0.6234131", "0.61439174", "0.6142247", "0.6125728", "0.61098045", "0.60988593", "0.60849", "0.608145", "0.60323966", "0.601206", "0.6000462", "0.5993433", "0.59727526", "0.59727526", "0.59727526", "0.5943301", "0.5892086", "0.58480734", "0.58279353", "0.57963645", "0.5777302", "0.5777302", "0.5759893", "0.5758523", "0.5749509", "0.57211757", "0.5714864", "0.5699226", "0.5688537", "0.5688537", "0.5688537", "0.56246996", "0.56246996", "0.56134915", "0.55719805", "0.55605185", "0.5546355", "0.5546355", "0.5541769", "0.54980105", "0.5491874", "0.54844767", "0.5478795", "0.54780596", "0.547029", "0.5470009", "0.5455632", "0.545478", "0.54532355", "0.54330117", "0.5429641", "0.54286623", "0.5368375", "0.5367374", "0.5367149", "0.5354427", "0.53536284", "0.5344784", "0.5343424", "0.5330917", "0.53259677", "0.53161716", "0.5312393", "0.53023964", "0.52988005", "0.52851874", "0.5275337", "0.5275337", "0.5271238", "0.52646565", "0.5263389", "0.52503175", "0.5249432", "0.5247077", "0.52400225", "0.52372575", "0.52330863", "0.52300763", "0.5213953", "0.5213927", "0.5205499", "0.520367", "0.5199608", "0.5197166", "0.51970655", "0.5193947", "0.51844156", "0.51825297", "0.5179995", "0.5173641", "0.51551104", "0.5153877", "0.51513416", "0.51369673", "0.51348996", "0.5130028", "0.5128717", "0.5119645", "0.51127285" ]
0.70551175
0
Returns the URL created by appending +url_or_path+ to the server's base URL, unless +url_or_path+ is alrady absolute.
def absolute_url(url_or_path, options= {}) url = url_or_path =~ /^#{base_url}/ ? url_or_path : "#{base_url}#{url_or_path}" params = options.fetch(:params, {}) query = params.inject([]) do |rv, param| rv.concat((param[1].is_a?(Array) ? param[1] : [param[1]]).map {|v| "#{uri_escape(param[0])}=#{uri_escape(v)}"}) rv end url += "?#{query.join('&')}" if query.any? url end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def base_url\n File.join(host, path)\n end", "def base_url(operation = nil)\n index = server_operation_index.fetch(operation, server_index)\n return \"#{scheme}://#{[host, base_path].join('/').gsub(/\\/+/, '/')}\".sub(/\\/+\\z/, '') if index == nil\n\n server_url(index, server_operation_variables.fetch(operation, server_variables), operation_server_settings[operation])\n end", "def path\n port == nil ? \"http://#{ip}#{suffix}\" : \"http://#{ip}:#{port}#{suffix}\"\n end", "def base_url(operation = nil)\n index = server_operation_index.fetch(operation.to_sym, server_index)\n return \"#{scheme}://#{[host, base_path].join('/').gsub(/\\/+/, '/')}\".sub(/\\/+\\z/, '') if index == nil\n\n server_url(index, server_operation_variables.fetch(operation.to_sym, server_variables), operation_server_settings[operation.to_sym])\n end", "def absolute_url(request, opts={})\n cdn_url(opts) || (request.protocol + request.host_with_port + public_filename)\n end", "def full_url_for(path)\n path = full_path_for(path)\n uri = request.request_uri\n host = uri.scheme + \"://\" + uri.host\n port = uri.port\n host << \":#{port}\" unless port == 80\n \"#{host}#{path}\"\n end", "def url(path = \"/\")\n uri = URI.join(\"http://#{self.base_domain}\", path)\n uri.to_s\n end", "def url(path)\n url = \"#{request.scheme}://#{request.host}\"\n\n if request.scheme == \"https\" && request.port != 443 ||\n request.scheme == \"http\" && request.port != 80\n url << \":#{request.port}\"\n end\n\n url << \"/\" unless path.index(\"/\").zero?\n url << path\n end", "def url_for(path)\n url = scheme + '://' + host\n\n if scheme == 'https' && port != 443 ||\n scheme == 'http' && port != 80\n url << \":#{port}\"\n end\n\n url << path\n end", "def base_url\n current_base_href = base_href.to_s.strip.empty? ? nil : URL.absolutify(base_href, URL.new(url).root_url)\n current_base_href || url\n end", "def uri(addr = nil, absolute = true, add_script_name = true)\n addr = addr.to_s if addr\n return addr if addr =~ /\\A[A-z][A-z0-9\\+\\.\\-]*:/\n uri = if absolute\n h = if @env.has_key?(\"HTTP_X_FORWARDED_HOST\") || port != (ssl? ? 443 : 80)\n host_with_port\n else\n host\n end\n [\"http#{'s' if ssl?}://#{h}\"]\n else\n ['']\n end\n uri << script_name.to_s if add_script_name\n uri << (addr || path_info)\n File.join(uri)\n end", "def absolute_url\n domain + path\n end", "def base_url\n base_href || url\n end", "def url_for_path path, options = {}\n unless options.delete :no_prefix\n url = ActionController::Base.relative_url_root + path\n else\n url = path.dup\n end\n \n options = default_url_options.merge options\n \n # Delete 'nil' parameters\n to_delete = []\n options.each{|k, v| to_delete << k if v.nil?}\n to_delete.each{|k| options.delete k}\n \n host = options.delete(:host) || options.delete('host')\n port = options.delete(:port) || options.delete('port')\n \n delimiter = path.include?('?') ? '&' : '?'\n \n url << \"#{delimiter}#{options.to_query}\" unless options.empty?\n url._url_format = options[:format] if options[:format] # hack for links with ajax support\n url\n \n if host.blank?\n url\n else\n %{http://#{host}#{\":#{port}\" unless port.blank?}#{url}}\n end\n end", "def full_url(path)\n \"#{base_url}#{path}\"\n end", "def url_for(path)\n url = scheme + '://' + host\n\n if scheme == 'https' && port != 443 ||\n scheme == 'http' && port != 80\n url << \":#{port}\"\n end\n\n url << path\n end", "def to_base\n return nil unless @uri.scheme && @uri.host\n\n base = \"#{@uri.scheme}://#{@uri.host}\"\n Wgit::Url.new(base)\n end", "def url\n if derivative\n derivative_url || regular_url\n elsif version\n version_url\n else\n regular_url\n end\n end", "def to_base\n return nil if @uri.scheme.nil? || @uri.host.nil?\n\n base = \"#{@uri.scheme}://#{@uri.host}\"\n Wgit::Url.new(base)\n end", "def with_base_url(path)\n u = @url.dup\n u.path += Puppet::Util.uri_encode(path)\n u\n end", "def build_url(path, params={})\n full_path = @uri.path + path\n full_url = \"#{@uri.scheme}://#{@uri.host}\"\n full_url += \":#{@uri.port}\" if @uri.port\n full_url += super(full_path, params, @uri.query)\n end", "def base_url(arg = nil)\n # TODO: Better URL validation\n set_or_return(:base_url, arg, kind_of: String, default: DEFAULT_BASE_URL)\n end", "def absolute_url\n return unless fileable?\n Rails.application.routes.default_url_options[:host] ||= \"http://localhost:3000\"\n Rails.application.routes.url_helpers.root_url[0..-2] + file.url\n end", "def join_url(base_url, path)\n return path if(path.include?(':')) # Absolute URL contains ':'\n if(path[0..0] == '/')\n new_url = base_url.clone\n new_url.path = path\n new_url.to_s\n else\n (base_file_url + path).to_s\n end\n end", "def absolute_url(*args)\n base_url + url(*args)\n end", "def path_to_url(path) # find something better, full url needed for redirects per HTTP\n \"http://#{self.request.host}:#{self.request.port}/#{path.sub(%r[^/],'')}\"\n end", "def url(addr = nil, absolute = true, add_script_name = true)\n return addr if addr =~ /\\A[A-z][A-z0-9\\+\\.\\-]*:/\n uri = [host = \"\"]\n if absolute\n host << \"http#{'s' if request.secure?}://\"\n if request.forwarded? or request.port != (request.secure? ? 443 : 80)\n host << request.host_with_port\n else\n host << request.host\n end\n end\n uri << request.script_name.to_s if add_script_name\n uri << (addr ? addr : request.path_info).to_s\n File.join uri\n end", "def url_to *args\n path = path_to(*args)\n\n return path if path =~ /\\A[A-z][A-z0-9\\+\\.\\-]*:/\n\n uri = [host = \"\"]\n host << \"http#{'s' if @request.ssl?}://\"\n\n if @request.forwarded? || @request.port != (@request.ssl? ? 443 : 80)\n host << @request.host_with_port\n else\n host << @request.host\n end\n\n uri << @request.script_name.to_s\n uri << path\n File.join uri\n end", "def full_url(url, path)\n if path.start_with?('http')\n path\n else\n url = url[0..1] if url.end_with?('/')\n path = path[1..-1] if path.start_with?('/')\n \"#{url}/#{path}\"\n end\n end", "def uri(path)\n return File.join(@base_url, path)\n end", "def build_url(host)\n host.protocol + host.url\n end", "def endPoint(path='')\n parts = ['https:/', $cfg['net.host'], 'api:1'] + @uriparts\n s = parts.map{|v| v.to_s}.join('/')\n URI(s + path.to_s)\n end", "def full_url(req)\n \"#{url_base}#{case req; when String: req; else req.path; end}\"\n end", "def uri_for(uri_or_path, params = nil)\n if uri_or_path.kind_of? URI\n u = uri_or_path.dup\n\n u.host = @uri.host\n u.port = @uri.port\n u.scheme = @uri.scheme\n else\n u = uri.dup\n u.path = File.join(uri.path, uri_or_path)\n end\n\n u.query = query_string_for(params) if params\n u.to_s\n end", "def full_url\n [ self.class.base, normalize_uri ].join('')\n end", "def url\n ::File.join \"/\", path.to_s\n end", "def url(options = {})\n if file.respond_to?(:url)\n tmp_url = file.method(:url).arity.zero? ? file.url : file.url(options)\n return tmp_url if tmp_url.present?\n end\n\n if file.respond_to?(:path)\n path = encode_path(file.path.sub(File.expand_path(root), ''))\n\n if (host = asset_host)\n if host.respond_to? :call\n \"#{host.call(file)}#{path}\"\n else\n \"#{host}#{path}\"\n end\n else\n (base_path || \"\") + path\n end\n end\n end", "def full_url(path)\n uri = URI.parse path\n uri.scheme, uri.host, uri.port = request.scheme, request.host, (request.port == 80 ? nil : request.port)\n uri.to_s\n end", "def _url\n URI.join(domain, path_gen.for_uri)\n end", "def url(*args)\n super_url = super\n File.exists?(\"#{root}#{super_url}\") ? super_url : default_url\n end", "def url\n File.join(server.url, path)\n end", "def full_url(path, params={})\n url = \"#{host[:protocol]}://\"\n url += \"#{host[:user]}:#{host[:password]}@\" if host[:user]\n url += \"#{host[:host]}:#{host[:port]}\"\n url += \"#{host[:path]}\" if host[:path]\n url += \"/#{full_path(path, params)}\"\n end", "def url(path = nil, params = nil)\n path = path[1..-1] if path&.chr == '/'\n \"https://#{URI.parse(beyond_api_url).host}/#{path}#{'?' +params&.to_query if params.present?}\"\n end", "def urlpath\n path = cleanpath\n path.blank? ? '/root' : '/' + path\n end", "def url\n host = @uploader.ucloud_cdn_host || @uploader.ucloud_bucket_host\n return nil unless host\n [host, @path].join(\"/\")\n end", "def build_as_url\n URI(build_as_string)\n rescue Urb::InvalidUrl => e\n URI('/')\n end", "def _base_url\n r = @_request\n scheme = r.scheme\n port = r.port\n \"#{scheme}://#{r.host}#{\":#{port}\" unless DEFAULT_PORTS[scheme] == port}\"\n end", "def url(p = path)\n \"/\" + relative_path(p).to_s.downcase.gsub(/\\s/, \" \")\n end", "def without_base\n base_url = to_base\n without_base = base_url ? gsub(base_url, '') : self\n\n return self if ['', '/'].include?(without_base)\n\n Wgit::Url.new(without_base).without_slashes\n end", "def absolute_url(*args)\n url_path = args.shift\n if url_path.is_a?(String) && !url_path.start_with?('/')\n url_path = request.env['PATH_INFO'].rpartition('/').first << '/' << url_path\n end\n uri url(url_path, *args), true, false\n end", "def base_url(link: nil)\n get_base = -> { @base.is_relative? ? @url.to_base.concat(@base) : @base }\n\n if link\n assert_type(link, Wgit::Url)\n raise \"link must be relative: #{link}\" unless link.is_relative?\n\n if link.is_anchor? || link.is_query_string?\n base_url = @base ? get_base.call : @url\n return base_url.without_anchor.without_query_string\n end\n end\n\n base_url = @base ? get_base.call : @url.base\n base_url.without_anchor.without_query_string\n end", "def without_trailing_slash\n end_with?('/') ? Wgit::Url.new(chop) : self\n end", "def base_url_path=(_arg0); end", "def get_url(is_local = true)\n is_local ? (return '../../../www/public/') : (return 'https://whimsy.apache.org/public/')\n end", "def uri_builder(path = nil)\n base = \"http://#{endpoint}/index.php/worker\"\n path.nil? ? base : File.join(base, path)\n end", "def path_uri(path = \"/\")\n p = @server.path_uri(\"/#{name}\")\n path ? p << \"/#{path}\" : p\n end", "def uds_path\n if mixed_http_and_uds?\n nil\n elsif parsed_url && unix_scheme?(parsed_url)\n path = parsed_url.to_s\n # Some versions of the built-in uri gem leave the original url untouched, and others remove the //, so this\n # supports both\n if path.start_with?('unix://')\n path.sub('unix://', '')\n else\n path.sub('unix:', '')\n end\n else\n uds_fallback\n end\n end", "def build_uri(base_uri, url)\n uri = URI(url)\n unless uri.host\n uri = base_uri.merge(url)\n end\n uri\n rescue => ex\n nil\n end", "def extended_url base_url, relative_url\n while base_url =~ /\\/$/\n base_url = base_url[0..-2]\n end\n while relative_url =~ /^\\//\n relative_url = relative_url[1..-1]\n end\n base_url + '/' + relative_url\n end", "def absolute_url(url)\n if url && !url.include?(\"http\") \n URI.join(root_url, url)\n else\n url\n end\n end", "def site_url(full: true)\n full ? root_url : \"#{request.host}:#{request.port}/\"\n end", "def base_uri\n url = URI.parse( @config[\"portal_url\"] )\n if url.path === \"/\"\n return \"\"\n else\n return url.path\n end\n end", "def to_path\n path = @uri.path\n return nil if path.nil? || path.empty?\n return Wgit::Url.new('/') if path == '/'\n\n Wgit::Url.new(path).without_slashes\n end", "def path\n @path ||= filters.uri_escape(absolute_url) if absolute_url\n end", "def path\n @path ||= filters.uri_escape(absolute_url) if absolute_url\n end", "def create_url(subpath='')\n paths = [ api_version, resources_path, subpath ]\n paths.select{|s| s != ''}.join('/')\n end", "def url\n @url ||= build_url\n\n if @url.is_a?(Hash)\n { only_path: true }.merge(@url)\n elsif @url.respond_to?(:call)\n @url.call\n else\n @url\n end\n end", "def final_url\n call_once\n last_request = context.get_attribute ExecutionContext::HTTP_REQUEST\n last_host = context.get_attribute ExecutionContext::HTTP_TARGET_HOST\n host = last_host.to_uri\n url = last_request.get_uri\n URI.join(host, url.to_s)\n end", "def complete_url(url, base)\n if url.start_with?(\"/\")\n resource_uri = base + url\n else\n resource_uri = url\n end \n return resource_uri\n end", "def url\n\t\tif relative? then\n\t\t\tif page.bases[0] then\n\t\t\t\t page.bases[0].href + src\n\t\t\telse\n\t\t\t\tpage.uri + src\n\t\t\tend\n\t\telse\n\t\t\tsrc\n\t\tend\n\tend", "def url\n @url ||= case @location_type\n when :country\n URI.join(BASE_URL, country_url(id))\n when :region\n URI.join(BASE_URL, region_url(id))\n else\n raise \"invalid location type: #{@location_type}\"\n end\n end", "def base_url\n \"#{scheme}://#{host}\"\n end", "def build_uri(path)\n path = path.to_s\n unless path.match(/^\\//)\n path = \"/#{path}\"\n end\n base_uri + path\n end", "def omit_trailing_slash\n end_with?('/') ? Wgit::Url.new(chop) : self\n end", "def _http_url\n HTTPURI + _uri_path\n end", "def url(*path)\n [\"#{request.scheme}://#{request.host_with_port}\", *path].join('/')\n end", "def url\n return nil unless @uploader.upyun_bucket_host\n\n [@uploader.upyun_bucket_host, @path].join(\"/\")\n end", "def base_uri(in_or_out = :in)\n Rails.my_config(\"base_uri_#{in_or_out}\".to_sym)\n end", "def here\n\n \"#{request.scheme}://#{request.host}:#{request.port}\" +\n \"#{request.fullpath}\"\n end", "def url\n '%s://%s%s' % [\n self.scheme,\n self.host,\n self.port_default? ? '' : (':%d' % self.port)\n ]\n end", "def path_uri(path=\"/\")\n p = @server.path_uri(\"/#{name}\")\n path ? p << \"/#{path}\" : p\n end", "def base_uri\t\t\t\n\t\tURI.parse( \"http://\" + @factory.site_name + \".\" + @factory.api_host_base + @path )\n\tend", "def to_path\n path = @uri.path\n return nil if path.nil? || path.empty?\n return Wgit::Url.new('/') if path == '/'\n\n Wgit::Url.new(path).omit_slashes\n end", "def old_url\n \"http://#{site.default_host.hostname}#{path}\"\n end", "def absolutize_url(url, base_path = '')\n ############# Refactor\n # original_url = url\n #unless original_url[URI::regexp(%w[http https])]\n # protocol = default_url_options[:protocol]\n # protocol = \"http://\" if protocol.blank?\n # protocol+= \"://\" unless protocol.include?(\"://\")\n\n # host = default_url_options[:host]\n\n # [host,protocol].each{|r| original_url.gsub!(r,\"\") }\n # host = protocol+host unless host[URI::regexp(%w[http https])]\n\n # url = URI.join host, base_path, original_url\n #end\n\n #url.to_s\n \n url\n end", "def request_uri\n return nil if absolute? && scheme !~ /^https?$/\n res = path.to_s.empty? ? \"/\" : path\n res += \"?#{self.query}\" if self.query\n return res\n end", "def build_url(query_params: nil)\n url = [add_version(''), *@url_path].join('/')\n url = build_query_params(url, query_params) if query_params\n URI.parse(\"#{@host}#{url}\")\n end", "def final_url\n return @final_url if !@final_url.nil?\n location = final_location(FaviconParty::HTTPClient.head(@query_url))\n if !location.nil?\n if location =~ /\\Ahttp/\n @final_url = WEBrick::HTTPUtils.escape location\n else\n uri = URI @query_url\n root = \"#{uri.scheme}://#{uri.host}\"\n @final_url = WEBrick::HTTPUtils.escape URI.join(root, location).to_s\n end\n end\n if !@final_url.nil?\n if %w( 127.0.0.1 localhost ).any? {|host| @final_url.include? host }\n # TODO Exception for invalid final urls\n @final_url = @query_url\n end\n return @final_url\n end\n @final_url = @query_url\n end", "def url(arg = nil)\n set_or_return(:url,\n arg,\n kind_of: String,\n default: 'http://localhost:8000')\n end", "def uri\n if host && !request_uri.host\n request_uri.dup.tap do |uri|\n uri.scheme = 'http'\n uri.host = host\n end\n else\n request_uri\n end\n end", "def build_url path, params={}\n full_path = @uri.path + path\n super full_path, params, @uri.query\n end", "def build_url path, params={}\n full_path = @uri.path + path\n super full_path, params, @uri.query\n end", "def build_url path, params={}\n full_path = @uri.path + path\n super full_path, params, @uri.query\n end", "def url\n return @url if @url\n\n url = permalink ?\n if site.config['relative_permalinks']\n File.join(@dir, permalink)\n else\n permalink\n end :\n {\n 'lang' => self.lang,\n 'categories' => self.categories,\n 'basename' => self.basename,\n }.inject(template) { |result, token|\n result.gsub(/:#{token.first}/, token.last)\n }.gsub(/\\/\\//, '/')\n\n # sanitize url\n @url = url.split('/').reject { |part| part =~ /^\\.+$/ }.join('/')\n @url += '/' if url =~ /\\/$/\n @url.gsub!(/\\A([^\\/])/, '/\\1')\n @url\n end", "def site_url(path = '', scheme = nil )\n get_site_url(nil, path, scheme )\n end", "def url\n [ Configuration.url, @path ].join\n end", "def to_host\n host = @uri.host\n host ? Wgit::Url.new(host) : nil\n end", "def to_host\n host = @uri.host\n host ? Wgit::Url.new(host) : nil\n end", "def full_url\n if school_site.start_with? 'http://'\n school_site\n else\n \"http://#{school_site}\"\n end\n end", "def uri(path=nil)\n (path and @uri = path) or @uri\n end" ]
[ "0.66544044", "0.65869874", "0.6545508", "0.65320575", "0.63942105", "0.6325804", "0.6305801", "0.63028127", "0.63006556", "0.62917066", "0.62789845", "0.62712216", "0.6268397", "0.6257448", "0.62521595", "0.62189317", "0.6212656", "0.62119657", "0.61598283", "0.6149283", "0.6128724", "0.61256635", "0.6115947", "0.61124426", "0.6108759", "0.6105705", "0.6105659", "0.6104501", "0.60960954", "0.60657984", "0.6061607", "0.60542196", "0.6032181", "0.60256964", "0.6025241", "0.59742653", "0.5972503", "0.5967263", "0.5967145", "0.5950207", "0.59463406", "0.59462863", "0.59423506", "0.59411466", "0.594034", "0.59380317", "0.59183645", "0.5902855", "0.58871037", "0.58655465", "0.5853806", "0.58424354", "0.5829156", "0.58160955", "0.58062303", "0.5803204", "0.58030677", "0.5784376", "0.5781592", "0.57746893", "0.5774153", "0.5773065", "0.57719755", "0.57682556", "0.57682556", "0.5768042", "0.575743", "0.5748886", "0.5747799", "0.5739986", "0.573899", "0.5733347", "0.5724114", "0.5719322", "0.57102656", "0.57065517", "0.5706534", "0.57001585", "0.5691678", "0.5687639", "0.56867176", "0.5685561", "0.5677818", "0.56772363", "0.56772107", "0.56717426", "0.5669617", "0.56634986", "0.5657713", "0.56471497", "0.5645938", "0.5645938", "0.5645938", "0.5645587", "0.56449115", "0.5642963", "0.5637737", "0.5637737", "0.56376237", "0.56357175" ]
0.6700565
0
Encodes +entity_ as a JSON string.
def encode_entity(entity) Yajl::Encoder.encode(entity) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def serialize(entity)\n value = entity.attribute(name)\n\n if value.nil?\n value = entity.write_attribute(name, default(entity))\n end\n\n serializer.serialize value, name: name\n end", "def _serialize(entity)\n @collection.serialize(entity)\n end", "def _serialize(entity)\n @collection.serialize(entity)\n end", "def _serialize(entity)\n serialized = @mapped_collection.serialize(entity)\n serialized.delete(:id)\n serialized[:_id] = Collection.to_mongodb_id(entity.id) unless entity.id.nil?\n serialized\n end", "def encode(object)\n object.to_json\n end", "def encode\n h = {\n :batch => @batch_hash,\n :job_id => @job_id\n }\n h.to_json.to_s\n end", "def body_entity(entity_id)\n {\n :entity_id => entity_id,\n :options => {\"pretty\"=>\"true\"}\n }\n end", "def to_json(*args)\n \n {:view_entity_model => view_entity_model, :view_entity_description => view_entity_description, :view_entity_fields => view_entity_fields}.to_json\n \n end", "def encode(obj); end", "def encode(object)\n engine.encode(object)\n end", "def entity entity_id\n raw(\"&#{entity_id};\")\n end", "def rubyify(entity)\n entity.map do |key, value|\n [key.to_s.gsub(/([A-Z])/) { '_' + $1.downcase }, value]\n end.to_h\n end", "def encode(value)\n Oj.dump value.as_json(options.dup)\n end", "def create(entity)\n post(resource_path_for_entity(entity), entity.to_json)\n end", "def encode\n # no op\n end", "def encode\n raise Errors::SerializerNotConfigured if serializer_missing?\n\n serializer.encode(self)\n end", "def add_entity\n res = {\n :success => false,\n :msg => '',\n :data => {}\n }\n if (params[:id].nil?)\n res[:msg] = 'order/update_entity was called without an :id'\n return render(:json => res.to_json, :layout => false)\n end\n \n order = Order.find_by_id(params[:id])\n entities = order.type.entities\n entities.each do |e|\n if (e.name == params[\"entity\"])\n data = params[e.name]\n data[:order_id] = params[:id]\n data[:order_type_entity_id] = e.id\n oe = OrderEntity.create(data)\n \n res[:success] = true\n res[:data][:entity] = oe.to_h\n res[:msg] = \"Added #{oe.type.name.capitalize}\" \n end\n end \n render :json => res.to_json, :layout => false \n end", "def encode(hash, options = nil)\n ActiveSupport::JSON.encode(hash, options)\n end", "def encode_payload(payload)\n payload = payload.is_a?(Hash) ? payload : payload.as_json\n JSON.dump(payload)\n end", "def encode_payload(payload)\n payload = payload.is_a?(Hash) ? payload : payload.as_json\n JSON.dump(payload)\n end", "def encode(object)\n ::MultiJson.encode(object)\n end", "def encode\n @content.serialize_to_string\n end", "def to_record(entity)\n end", "def article_representation article\r\n if @@count == 0 then\r\n @@count = 1\r\n\t\t \"\\\"articles\\\":\"+article.attributes.to_json\r\n else\r\n \", \\\"articles\\\":\"+article.attributes.to_json\r\n end\r\n\tend", "def to_s\n to_json\n end", "def encode\n transform :encode \n end", "def encode(data); ::BSON.serialize(data).to_s; end", "def encode(value)\n raise_on_circular_reference(value) do\n value.send(:to_json)\n end\n end", "def encode_entities(*instructions)\n return HTMLEntities.encode_entities(self, *instructions)\n end", "def encode_string; end", "def save_entity(entity)\n result = service.put(entity.path, entity)\n entity[:updatedAt] = result[:updatedAt]\n entity[:createdAt] = result[:createdAt]\n entity\n end", "def to_json_string\n MARC::JSONLWriter.encode(self)\n end", "def json\n \"#{self.to_s}&json=true\"\n end", "def format_entity(data)\n { \n uid: data['FixtureId'],\n name: name(data),\n tournament_name: tournament_name(data),\n country_name: country_name(data),\n team_names: team_names(data)\n }\n end", "def to_s\n to_json.to_s\n end", "def as_json(*args)\n { EXTENDED_JSON_KEY => to_s }\n end", "def serialize(value)\n return super unless value.is_a?(Hash) || implements_model?(value.class)\n\n ActiveSupport::JSON.encode(value, serialize_unknown_attributes: true)\n end", "def html_encode\n require 'htmlentities'\n \n coder = HTMLEntities.new\n \n ret = coder.encode(self, :named)\n \n return ret\n end", "def to_json(_context = nil)\n to_h.to_json\n end", "def encode(encoding)\n to_s.encode(encoding)\n end", "def encode_items\n self.items =\n ActiveSupport::JSON.encode(self.items) rescue self.items.to_json\n end", "def to_str\n body={\n id: @id,\n event: @event,\n data: @data,\n }\n if errors.any?\n body[:errors_count]=@errors.count\n body[:errors]=@errors\n end\n body.to_json\n end", "def to_s\n all_entities = @body.join(\"\\r\\n--#{@boundary}\\r\\n\")\n \"--#{@boundary}\\r\\n#{all_entities}\\r\\n--#{@boundary}--\\r\\n\"\n end", "def generate\n graph = crate.entities.map(&:properties).reject(&:empty?)\n JSON.pretty_generate('@context' => context, '@graph' => graph)\n end", "def as_json(*_args)\n to_s\n end", "def set_Entity(value)\n set_input(\"Entity\", value)\n end", "def json(obj)\n obj.to_json.html_safe\n end", "def json(obj)\n obj.to_json.html_safe\n end", "def convert_entity(entity)\n case entity\n when Twitter::Entity::URI\n \"<a href=\\\"#{h entity.expanded_url}\\\">#{h entity.display_url}</a>\"\n when Twitter::Entity::UserMention\n \"<a href=\\\"https://twitter.com/#{entity.screen_name}\\\">@#{entity.screen_name}</a>\"\n when Twitter::Entity::Hashtag\n \"<a href=\\\"https://twitter.com/hashtag/#{h encode_uri_component entity.text}\\\">##{h entity.text}</a>\"\n else\n ''\n end\n end", "def to_s\n {\n fullname: fullname,\n address: address,\n dob: dob,\n email: email,\n username: username\n }.to_json\n end", "def parse_entity(entity)\n entity = Yajl::Parser.parse(entity)\n entity.is_a?(Hash) ? HashWithIndifferentAccess.new(entity) : entity\n end", "def store_entity(entity, aliases, force=false)\n if !force && transaction?\n add_transaction_element(:store_entity, entity, aliases)\n else\n @entities[entity.id] = entity\n\n aliases.each do |a|\n @aliases[a] = entity.id\n map_to_aliases(entity.id) << a\n end\n end\n entity\n end", "def json_serialize\n end", "def escaped_json\n json = to_json(:include => :trade_lines)\n return CGI.escape(json)\n end", "def json(obj)\n content_type :json\n obj.to_json\n end", "def to_s\n JSON.dump(to_h)\n end", "def jsonify(input); end", "def to_s\n self.to_json\n end", "def serialize\n JSON.generate(to_h)\n end", "def to_json\n to_s.to_json\n end", "def encode_workitem\n\n workitem.as_json\n end", "def entities\n return bad_request unless params[:id] and request.format.json? || request.format.js?\n return not_found unless current_document\n @response = {'entities' => current_document.ordered_entity_hash}\n render_cross_origin_json\n end", "def serialize\n\t\tserialized = Serialized.new\n\t\t\n\t\t# to serialize an image you need the path to the file..\n\t\t# so I can't completely separate the Image loading from the Entity in space\n\t\t\n\t\treturn serialized\n\tend", "def js_name(entity)\n if !entity.id\n raise \"No identifier for #{entity.to_json}\"\n end\n entity.id.gsub(/\\W/, '_')\n end", "def json_encode hash\n middle = hash.inject([]){ |r, (k, v)|\n r << \"\\\"#{k}\\\":\\\"#{v.gsub('\"','\\\\\"')}\\\"\"\n }.join(',')\n \"{#{middle}}\"\n end", "def encode\n raise NotImplementedError\n end", "def serialize\n marshall.to_json\n end", "def to_s\n return @data.to_json\n end", "def instance_to_json\n { \n id: self.id,\n title: self.title,\n content: self.content,\n likes: self.likes,\n author: {\n id: self.author.id,\n name: self.author.name\n }\n }\n end", "def to_json\n to_raw.to_json\n end", "def encode_body\n encode_short(@id)\n end", "def encode_body\n encode_short(@id)\n end", "def encode_body\n encode_short(@id)\n end", "def to_s\n JSON.pretty_generate(raw)\n end", "def to_json(obj = contact)\n return simple_object if @simplify\n\n json = { code: obj.code, name: obj.name, ident: ident, phone: obj.phone,\n created_at: obj.created_at, auth_info: obj.auth_info, email: obj.email,\n statuses: statuses, disclosed_attributes: obj.disclosed_attributes,\n registrar: registrar }\n json[:address] = address if @show_address\n if @domain_params\n json[:domains] = domains\n json[:domains_count] = obj.qualified_domain_ids(@domain_params[:domain_filter]).size\n end\n json\n end", "def add entity\n @body.push(entity)\n end", "def stringify\n json_hash = {}\n\n begin\n json_hash = Serializer.serialize(self, class: self.class.name)\n rescue JSON::JSONError => e\n warn \"#{__FILE__}.#{__LINE__}: #{e.message}\"\n end\n\n json_hash.to_json\n end", "def encode!; end", "def as_json\n to_s.as_json\n end", "def json_\n hash = {\n \"Id\" => id,\n \"Created\" => created,\n \"CreatedBy\" => created_by,\n \"Modified\" => modified,\n \"ModifiedBy\" => modified_by\n }\n\n hash.to_json\n end", "def to_json(*args)\n \"{\\\"$oid\\\": \\\"#{to_s}\\\"}\"\n end", "def putEntity( type, scope, country, trust, our_data)\n params = Hash.new\n params['type'] = type\n params['scope'] = scope\n params['country'] = country\n params['trust'] = trust\n params['our_data'] = our_data\n return doCurl(\"put\",\"/entity\",params)\n end", "def entity_params\n params.require(:entity).permit(:name, :entity_type, :entity_id)\n end", "def encode(object)\n if @entity_factory.is_feature_collection?(object)\n {\n \"type\" => \"FeatureCollection\",\n \"features\" => @entity_factory.map_feature_collection(object) { |f| encode_feature(f) },\n }\n elsif @entity_factory.is_feature?(object)\n encode_feature(object)\n elsif object.nil?\n nil\n else\n encode_geometry(object)\n end\n end", "def encode_body(data)\n @serializer.encode(data)\n end", "def encode_body(data)\n @serializer.encode(data)\n end", "def to_json(what)\n what.to_hash.to_json\n end", "def payleven_encoded(h)\n\t\t\tencoded_string = \"\"\n\t\t\tordered_hash = ActiveSupport::OrderedHash.new\n\t\t\t\n\t\t\th.each do |field, key|\n\t\t\t\tnew_field = \"entity[\"+field.to_s+\"]\"\n\t\t\t\tencoded_string+= field.to_s + \":\" \n\t\t\t\tif key.is_a? DateTime\n\t\t\t\t\tencoded_string+= key.to_s.gsub(\"T\", \" \")[0,19]\n\t\t\t\t\tordered_hash[new_field.to_sym] = key.to_s.gsub(\"T\", \" \")[0,19]\n\t\t\t\t\n\t\t\t\telsif not key.is_a? String\n\t\t\t\t\tencoded_string+= key.to_s \n\t\t\t\t\tordered_hash[new_field.to_sym] = key\n\t\t\t\t\n\t\t\t\telse\n\t\t\t\t\tencoded_string+= key\n\t\t\t\t\tordered_hash[new_field.to_sym] = key\n\t\t\t\tend\n\t\t\t\tencoded_string+= \",\"\n\n\t\t\tend\n\t\t\t{payleven_string: encoded_string[0, encoded_string.length-1], ordered_hash: ordered_hash}\n\t\tend", "def to_json\n\t\tto_h.to_json\n\tend", "def to_json\n\t\tto_h.to_json\n\tend", "def encode\n type_byte + encode_data\n end", "def serialize\n self.to_hash.to_json\n end", "def e(object)\n require 'json'\n object.respond_to?(:to_json) ? object.to_json : object.to_s.to_json\n end", "def encoded_json_from_ordering(node)\n ordering = { 'id' => node[:id].to_s }\n\n order_list.each do |field|\n field_name = field.attribute_name\n ordering[field_name] = node[field_name].to_s\n end\n\n encode(ordering.to_json)\n end", "def encode to_encode\n CGI.escape(to_encode)\n end", "def to_json(*args)\n {\n 'json_class' => self.class.name,\n 'data' => to_s\n }.to_json(*args)\n end", "def events_jsonify(events)\n\t\t\tevents.collect do |event|\n\t\t\t\t{ id: event.id,\n\t\t\t\t\tname: event.name,\n\t\t\t\t\tsummary: event.summary,\n\t\t\t\t\tstart_era: event.start_era,\n\t\t\t\t\tstart_date: \"#{event.start_date or 0}/#{event.start_month or 0}/#{event.start_year}\",\n\t\t\t\t\tend_date: \"#{event.end_date or 0}/#{event.end_month or 0}/#{event.end_year or event.start_year}\",\n\t\t\t\t\tarcs: event.arcs,\n\t\t\t\t\tentities: event.entities }\n\t\t\tend.to_json\n\t\tend", "def serialize_track(track)\n json = \"{\\\"id\\\": #{track.id},\n \\\"name\\\": \\\"#{track.name}\\\",\n \\\"artist\\\": {\\\"id\\\": #{track.artist.id},\\\"name\\\": \\\"#{track.artist.name}\\\"},\n \\\"release\\\": {\\\"id\\\": #{track.release.id},\\\"name\\\": \\\"#{track.release.name}\\\"},\n \\\"file\\\": \\\"#{track.file.url}\\\"}\"\n end", "def encode(text)\n @char_to_entity ||= begin\n map = {}\n File.read(File.join(File.dirname(__FILE__), 'characters.txt')).scan(/^(\\d+)\\s*(.+)$/) do |key, value|\n map[[key.to_i].pack('U')] = value\n end\n map\n end\n\n text.gsub(/[^\\x00-\\x7F]|[\"'<>&]/) do |ch|\n ent = @char_to_entity[ch]\n ent ? \"&#{ent};\" : sprintf(\"&#x%02X;\", ch.unpack(\"U\")[0])\n end\n end", "def as_json_encrypted\n with_encrypted_attrs { as_json }\n end" ]
[ "0.66318667", "0.65506786", "0.65506786", "0.6237487", "0.6177159", "0.61610687", "0.60063857", "0.60053104", "0.5929432", "0.58121765", "0.5761164", "0.5731225", "0.57239187", "0.56732655", "0.56310195", "0.56063277", "0.55532664", "0.5545393", "0.55242205", "0.54877627", "0.5472059", "0.5443532", "0.5429258", "0.5416106", "0.5405069", "0.54027736", "0.53967005", "0.5383475", "0.5382311", "0.53743327", "0.5324828", "0.5321124", "0.53145415", "0.53069735", "0.5301528", "0.5294567", "0.52827096", "0.5279318", "0.52773285", "0.5273879", "0.52636385", "0.52613866", "0.52613866", "0.5258418", "0.52494967", "0.524512", "0.5244243", "0.5243475", "0.52417564", "0.52196175", "0.52150154", "0.5200091", "0.5197915", "0.5191752", "0.5178146", "0.5176636", "0.51763994", "0.5164869", "0.51623267", "0.51601666", "0.51536965", "0.5149881", "0.5146213", "0.5143263", "0.5142538", "0.51364076", "0.51234365", "0.51099455", "0.51044047", "0.50922394", "0.50918454", "0.50918454", "0.50918454", "0.50907654", "0.5068653", "0.5056431", "0.50533825", "0.5044631", "0.5036632", "0.5036198", "0.5033837", "0.5032449", "0.50276685", "0.50256646", "0.5020013", "0.5020013", "0.50144076", "0.5011898", "0.5010933", "0.5010933", "0.4999627", "0.49984485", "0.49978167", "0.49972877", "0.4996366", "0.49957037", "0.499324", "0.498732", "0.49747944", "0.49744913" ]
0.7911234
0
Converts +entity+ from a JSON string to an object.
def parse_entity(entity) entity = Yajl::Parser.parse(entity) entity.is_a?(Hash) ? HashWithIndifferentAccess.new(entity) : entity end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def json_to_obj json_str\n hash_to_obj(parse_json(json_str))\n end", "def _parse_entity(entity_string)\n entity_type = entity_string.split(\"#\").first\n\n # hack - fixes entities with full type\n unless entity_type =~ /::/\n entity_type = \"Intrigue::Entity::#{entity_type}\"\n end\n\n entity_name = entity_string.split(\"#\").last\n\n entity_hash = {\n \"type\" => entity_type,\n \"name\" => entity_name,\n \"details\" => { \"name\" => entity_name, \"whitelist\" => true }\n }\n\n #puts \"Got entity: #{entity_hash}\" if @debug\n\n entity_hash\n end", "def _parse_entity(entity_string)\n entity_type = entity_string.split(@delim).first\n entity_name = entity_string.split(@delim).last\n\n entity_hash = {\n \"type\" => entity_type,\n \"name\" => entity_name,\n \"details\" => { \"name\" => entity_name}\n }\n\n puts \"Got entity: #{entity_hash}\" if @debug\n\n entity_hash\n end", "def from_json string\n _assign_attributes JSON.parse(string)\n end", "def from_json(json)\n new JSON.parse(json)\n end", "def json_to_object(json)\n JSON(json)\nend", "def from_json\n return nil unless okay?\n\n require \"json\"\n\n JSON.parse(body)\n end", "def from_json(json:, klass:, use_alias: false)\n hash = JSON.load(json)\n from_hash(hash: hash, klass: klass, use_alias: use_alias)\n end", "def from_json(json:, klass:)\n hash = JSON.load(json)\n from_hash(hash: hash, klass: klass)\n end", "def _deserialize(entity)\n deserialize([entity])\n end", "def from_json(json)\n deserialize JSON.parse(json)\n end", "def from_json\n JSON.parse(self)\n end", "def from_json!(string)\n JSON.parse(string).each do |var, val|\n self.instance_variable_set var, val\n end\n end", "def from_json(data, _ = {} , spec: nil)\n data = JSON.parse(data) if data.is_a?(String)\n if spec\n Data.import(self.class.json_spec_path, spec, self, data)\n elsif defined?(super)\n super\n end\n end", "def parse_json(json_)\n from_json_object(::JSON.parse(json_))\n end", "def from_json(data)\n hash = Oj.load(data, symbol_keys: true)\n from_h(hash, :from_json)\n end", "def from_json(json)\n self.attributes = ActiveSupport::JSON.decode(json)\n self\n end", "def reparsed_from_json\n self.is_a?(String) ? JSON.parse(self) : JSON.parse(self.to_json)\n end", "def load_from_json_string(json)\n load_from_hash(JSON.parse(json))\n end", "def parse(json_str)\n Oj.load(json_str)\n end", "def convert_json(json)\n\n return JSON.parse(json)\n\nend", "def from_json(data)\n hash = Oj.load(data, symbol_keys: true)\n\n hash.each do |k, v|\n hash[k] = convert(v, k, :from_json)\n end\n\n from_h(hash)\n end", "def from_json(data, *args)\n data = ::JSON[data]\n from_hash(data, *args)\n end", "def new_from_json_string(json_string)\n hash = JSON.parse(json_string)\n new_from_response_data(hash.first[1])\n end", "def object\n @object ||= JSON.parse(body)\n rescue => error\n raise InvalidObjectError.new(error.to_s)\n end", "def serialize_in(json_string, options = {})\n super(ActiveSupport::JSON.decode(json_string), options)\n end", "def parse(json_str)\n e = Pointer.new(:object)\n NSJSONSerialization.JSONObjectWithData(\n json_str.dataUsingEncoding(NSUTF8StringEncoding),\n options: 0,\n error: e)\n end", "def load(json)\n require 'json'\n from_json(JSON.parse(json))\n end", "def from_json(source, opts = {})\n obj = parse(source, opts)\n\n # JSON gem requires top level object to be a Hash or Array (otherwise\n # you get the \"must contain two octets\" error). Yajl doesn't impose the\n # same limitation. For compatibility, we re-impose this condition.\n unless obj.kind_of?(Hash) || obj.kind_of?(Array)\n raise JSON::ParseError, \"Top level JSON object must be a Hash or Array. (actual: #{obj.class})\"\n end\n\n # The old default in the json gem (which we are mimicing because we\n # sadly rely on this misfeature) is to \"create additions\" i.e., convert\n # JSON objects into ruby objects. Explicit :create_additions => false\n # is required to turn it off.\n if opts[:create_additions].nil? || opts[:create_additions]\n map_to_rb_obj(obj)\n else\n obj\n end\n end", "def from_json(json_string)\n raise(ArgumentError, \"Argument 'json_string' must be a String.\") unless json_string.is_a?(String)\n # Split at every even number of unescaped quotes.\n # If it's not a string then replace : and null\n ruby_string = json_string.split(/(\\\"(?:.*?[^\\\\])*?\\\")/).\n collect{|s|\n (s[0..0] != '\"')? s.gsub(/\\:/, \"=>\").gsub(/null/, \"nil\").gsub(/undefined/, \"nil\") : s\n }.\n join()\n result = eval(ruby_string)\n return result\nrescue Exception\n {}\nend", "def from_json(resource_class, json)\n # e.g. DELETE\n return nil if json.nil? or json.size == 0\n data = JSON.parse json\n\n if data.is_a? Array\n records = Resources.new\n data.each do |data_element|\n if data_element.is_a? Enumerable\n records << instantiate_record_from_json(resource_class, data_element)\n else\n # Value (e.g. String)\n records << data_element\n end\n end\n records\n else\n instantiate_record_from_json(resource_class, data)\n end\n end", "def from_json(source, opts = {})\n ::JSON.parse(source, opts_add_max_nesting(opts))\n end", "def parse_json str\n JSON.parse str rescue raise ConfigError, \"Invalid JSON\"\n end", "def from_json(data, *args, &block)\n data = ::JSON[data]\n from_hash(data, *args, &block)\n end", "def deserialize(value)\n self.new(JSON.parse(value))\n end", "def from_json(attributes)\n JSON.parse(attributes).with_indifferent_access\n end", "def initialize(json)\n @id = json[:id]\n @entity_id = json[:entity_id]\n @role_id = json[:role_id]\n @destroy = false\n end", "def convert_json_trace_to_object(trace)\n JSON.parse(trace[1...-1].insert(0, '{'), object_class: OpenStruct)\n end", "def parse\n return if @id\n\n data = @json.is_a?(String) ? JSON.parse(@json) : @json\n @id = data[\"id\"]\n @time = data[\"created_at\"]\n @text = parse_text(data[\"text\"])\n end", "def convert(resp, key=nil)\n json = JSON.parse(resp)\n validate_parser(json, key)\n json = { key => json} if key\n\n objs = build_response_attr(json)\n ClassyJSON::Conversion.new(objs)\n end", "def load(string)\n ActiveSupport::JSON.decode string\n end", "def load(string)\n ActiveSupport::JSON.decode string\n end", "def parse_json(json)\n ::JSON.parse(json, :create_additions => false)\n end", "def from_json(source, opts = {})\n obj = ::Yajl::Parser.parse(source)\n # JSON gem requires top level object to be a Hash or Array (otherwise\n # you get the \"must contain two octets\" error). Yajl doesn't impose the\n # same limitation. For compatibility, we re-impose this condition.\n unless obj.kind_of?(Hash) or obj.kind_of?(Array)\n raise JSON::ParserError, \"Top level JSON object must be a Hash or Array. (actual: #{obj.class})\"\n end\n\n # The old default in the json gem (which we are mimicing because we\n # sadly rely on this misfeature) is to \"create additions\" i.e., convert\n # JSON objects into ruby objects. Explicit :create_additions => false\n # is required to turn it off.\n if opts[:create_additions].nil? || opts[:create_additions]\n map_to_rb_obj(obj)\n else\n obj\n end\n end", "def from_json(source)\n return if source.blank?\n\n case source\n when ::String\n from_hash Yajl::Parser.parse(source)\n when ::Hash\n from_hash source\n end\n end", "def from_json(source, opts = {})\n obj = ::Yajl::Parser.parse(source)\n\n # JSON gem requires top level object to be a Hash or Array (otherwise\n # you get the \"must contain two octets\" error). Yajl doesn't impose the\n # same limitation. For compatibility, we re-impose this condition.\n unless obj.kind_of?(Hash) or obj.kind_of?(Array)\n raise JSON::ParserError, \"Top level JSON object must be a Hash or Array. (actual: #{obj.class})\"\n end\n\n # The old default in the json gem (which we are mimicing because we\n # sadly rely on this misfeature) is to \"create additions\" i.e., convert\n # JSON objects into ruby objects. Explicit :create_additions => false\n # is required to turn it off.\n if opts[:create_additions].nil? || opts[:create_additions]\n map_to_rb_obj(obj)\n else\n obj\n end\n end", "def from_json json, response_key\n model = nil\n raw = JSON.parse(json)\n response_key ? from_parsed_json(raw[response_key].nil? ? raw : raw[response_key], response_key) : raw\n end", "def parse\n (type, subtype) = parse_object([@name], JSON.parse(@json))\n (subtype || type).to_s.gsub(/\\n\\n$/, \"\\n\")\n end", "def to_json(json)\n begin\n JSON.parse(json)\n rescue\n json\n end\n end", "def from data\n obj = new\n obj.decode data\n obj\n end", "def parse(json)\n JSON.parse(json) rescue nil\n end", "def parse_json(stream)\n ::JSON.parse(stream)\n end", "def unmarshal(json_string, klass)\n if json_string.nil?\n return nil\n elsif json_string.length == 0\n return ''\n end\n if klass.respond_to?(:new_from_hash)\n klass.new_from_hash(JSON.load(json_string))\n else\n raise NotImplementedError\n end\n end", "def update(entity)\n serialized_entity = _serialize(entity)\n update_one('$set' => serialized_entity)\n _deserialize(serialized_entity)\n end", "def instance_by_json(json_obj = {})\n obj = self.new \n obj.set_attributes_by_json( json_obj )\n return obj\n end", "def decode(object)\n return unless object\n begin\n JSON.parse(object)\n rescue JSON::ParserError\n end\n end", "def initialize(resource_json)\n @json = JSON.parse(resource_json)\n parse_base\n end", "def create(entity)\n post(resource_path_for_entity(entity), entity.to_json)\n end", "def parse json; return JSON.parse File.read json end", "def parse json; return JSON.parse File.read json end", "def parse_json(str)\n Yajl::Parser.parse(str)\n end", "def decode_json(value, context = Attributor::DEFAULT_ROOT_CONTEXT)\n raise Attributor::DeserializationError, context: context, from: value.class, encoding: 'JSON', value: value unless value.is_a? ::String\n\n # attempt to parse as JSON\n parsed_value = JSON.parse(value)\n unless valid_type?(parsed_value)\n raise Attributor::CoercionError, context: context, from: parsed_value.class, to: name, value: parsed_value\n end\n\n parsed_value\n rescue JSON::JSONError\n raise Attributor::DeserializationError, context: context, from: value.class, encoding: 'JSON', value: value\n end", "def json_parse(body)\n json = JSON.parse body\n convert_to_obj(json[\"response\"][\"result\"])\n end", "def decode_and_parse_json(string)\n JSON.parse(string)\nrescue\n JSON.parse(Base64.decode64(string))\nend", "def create_from_json(json)\n if(json[\"type\"] == \"subject\")\n subject = Subject.new(name: json[\"name\"])\n subject.save\n elsif(json[\"type\"] == \"blog\")\n subject = Subject.find_by(name: json[\"subject\"])\n \n # TODO: Is there a more elegant way of doing this without explicitly\n # assigning everything?\n blog = subject.blogs.new(name: json[\"name\"],\n date_created: json[\"date_created\"],\n content: json[\"content\"],\n tags: json[\"tags\"]\n )\n blog.save\n end\n end", "def parseJsonString(jsonString) \n $jsonObjectMain = JSON.parse(jsonString);\n return $jsonObjectMain;\nend", "def deserialize_json(s, type)\n headers = { 'Content-Type' => 'application/json' }\n response = double('response', headers: headers, body: s)\n API_CLIENT.deserialize(response, type)\nend", "def parse_json(json, &block)\n instantiate_classes_in_parsed_json(JSON.parse(json), &block)\n end", "def from_json(serialized_data)\n Yajl::Parser.parse(serialized_data, :symbolize_keys => true)\n end", "def json_parse (s)\n\n #defined?(ActiveSupport::JSON) ? ActiveSupport::JSON.decode(s) :\n #JSON.parse(s)\n OpenWFE::Json.decode( s )\nend", "def json_parse(str)\n results = JSON.parse(str)\n case results\n when Hash\n results.extend Sym_Keys_For_Hash\n results.symbolize_keys\n when Array\n results.symbolize_hash_keys\n else\n results\n end\nend", "def parse\n JSON.parse(raw)\n rescue RuntimeError\n raise \"cannot read from #{path}\"\n end", "def unserialize(string)\n data = JSON.parse(string)\n data\n end", "def load(node)\n key = @etcd_schema.parse(node.key)\n object = new(*key)\n object.from_json!(node.value)\n object\n end", "def typecast_value_json(value)\n case value\n when JSONObject\n value\n when String\n if typecast_json_strings\n JSONString.new(value)\n else\n _wrap_json(_parse_json(value))\n end\n when *JSON_WRAP_CLASSES\n JSONDatabaseMethods.json_primitive_wrapper(value).new(value)\n when JSONBObject\n value = value.__getobj__\n JSONDatabaseMethods.json_primitive_wrapper(value).new(value)\n else\n raise Sequel::InvalidValue, \"invalid value for json: #{value.inspect}\"\n end\n end", "def Entity(input, &block)\n result = case input\n when Sipity::Entity\n input\n when URI::GID, GlobalID\n Entity.find_by(proxy_for_global_id: input.to_s)\n when SolrDocument\n Entity(input.to_model)\n when Draper::Decorator\n Entity(input.model)\n when Sipity::Comment\n Entity(input.entity)\n when Valkyrie::Resource\n Entity(Hyrax::GlobalID(input))\n else\n Entity(input.to_global_id) if input.respond_to?(:to_global_id)\n end\n\n handle_conversion(input, result, :to_sipity_entity, &block)\n rescue URI::GID::MissingModelIdError\n Entity(nil)\n end", "def find_instance_from_json(json, instance_class)\n key = instance_class.table_name.singularize\n details = json[key]&.slice(*REQUIRED_ATTRIBUTES[instance_class])\n obj = nil\n if details\n obj = instance_class.new(details)\n obj = instance_class.find(obj.id) if obj.id\n end\n obj\n end", "def parse_json(str_data)\n return nil unless str_data\n data = str_data.respond_to?(:to_data) ? str_data.to_data : str_data\n opts = NSJSONReadingMutableContainers | NSJSONReadingMutableLeaves | NSJSONReadingAllowFragments\n error = Pointer.new(:id)\n obj = NSJSONSerialization.JSONObjectWithData(data, options:opts, error:error)\n raise StandardError, error[0].description if error[0]\n if block_given?\n yield obj\n else \n obj\n end\n end", "def decode(json)\n ::ActiveSupport::JSON.decode(json)\n end", "def from_hash(json, client: nil)\n res = self.new\n\n json.each do |k, v|\n # TODO: Better way to do this?\n attr = @attributes.find{|a| a.json_field == k.to_s}\n raise InvalidAttribute.new(\n \"`#{self.name.split('::').last}` did not define a `#{k}`.\"\n ) if attr.nil?\n\n # TODO: Better way to do this?\n case attr.type.to_s\n when Integer.to_s\n maybe_raise_invalid_value(attr, k, v) unless v.is_a?(Fixnum)\n value = v.to_i\n when Float.to_s\n maybe_raise_invalid_value(attr, k, v) unless v.is_a?(Float)\n value = v.to_f\n when String.to_s\n maybe_raise_invalid_value(attr, k, v) unless v.is_a?(String)\n value = v\n when Hash.to_s\n maybe_raise_invalid_value(attr, k, v) unless v.is_a?(Hash)\n value = v\n end\n\n # Lurk, there is probably a better way to do this.\n if !attr.expand_method.nil?\n client ||= Unchained::Client.new\n value = client.send(attr.expand_method, value)\n end\n\n res.send(\"#{attr.name}=\", value)\n end\n\n res\n end", "def decode(object)\n return unless object\n\n begin\n JSON.parse object\n rescue JSON::ParserError => e\n raise DecodeException, e.message, e.backtrace\n end\n end", "def jsonToActivity(jsonObject)\r\n\t\t\t\tactivity = Activity.new\r\n\t\t\t\t\r\n\t\t\t\tif jsonObject.has_key?(\"id\")\r\n\t\t\t\t\tactivity.setId(jsonObject[\"id\"])\r\n\t\t\t\tend\r\n\t\t\t\tif jsonObject.has_key?(\"name\")\r\n\t\t\t\t\tactivity.setName(jsonObject[\"name\"])\r\n\t\t\t\tend\r\n\t\t\t\tif jsonObject.has_key?(\"state\")\r\n\t\t\t\t\tactivity.setState(jsonObject[\"state\"])\r\n\t\t\t\tend\r\n\t\t\t\tif jsonObject.has_key?(\"activity_by\")\r\n\t\t\t\t\tactivity.setActivityBy(jsonObject[\"activity_by\"])\r\n\t\t\t\tend\r\n\t\t\t\tif jsonObject.has_key?(\"time_long\")\r\n\t\t\t\t\tactivity.setTimeLong(jsonObject[\"time_long\"])\r\n\t\t\t\tend\r\n\t\t\t\tif jsonObject.has_key?(\"display_time\")\r\n\t\t\t\t\tactivity.setDisplayTime(jsonObject[\"display_time\"])\r\n\t\t\t\tend\r\n\t\t\t\tif jsonObject.has_key?(\"time\")\r\n\t\t\t\t\tactivity.setTime(jsonObject[\"time\"])\r\n\t\t\t\tend\r\n\t\t\t\tif jsonObject.has_key?(\"activity_for\")\r\n\t\t\t\t\tactivity.setActivityFor(jsonObject[\"activity_for\"])\r\n\t\t\t\tend\r\n\t\t\t\t\t\r\n\t\t\t\treturn activity\r\n\t\t\t\t\r\n\t\t\tend", "def from_json(filename)\n require \"json\" unless defined?(JSON)\n from_hash(JSON.parse(IO.read(filename)))\n end", "def _parse_json(s)\n begin\n Sequel.parse_json(s)\n rescue Sequel.json_parser_error_class => e\n raise Sequel.convert_exception_class(e, Sequel::InvalidValue)\n end\n end", "def from_json(json, include_root=false)\n hash = ActiveSupport::JSON.decode(json)\n hash = hash.values.first if include_root\n self.all_attributes = hash\n end", "def load_entity(entity_id)\n return nil unless entity_id\n\n Entity.new_protected(entity_id) # FIXME: should we really query on this?\n end", "def json_create(o)\n new(*o[\"data\"])\n end", "def parse_fetched_json(json_from_url)\n JSON.parse(json_from_url)\n end", "def get_entity(entity_name)\n uri = URI(@config[:server] + \"/#{entity_name}\")\n uri.query = URI.encode_www_form({:filter => @config[:filter]})\n \n result = Net::HTTP.get_response(uri)\n raise Exception(\"The request to #{uri} failed.\") unless result.is_a?(Net::HTTPSuccess)\n \n JSON.parse(result.body)\n \n rescue\n @logger.error(\"Unable to retrieve entity:\\n#{$!}\")\n []\n end", "def from_json(json, save_cache = false)\n hash = ActiveSupport::JSON.decode(json)['errors'] || {} rescue {}\n from_hash hash, save_cache\n end", "def json_parse(json)\n JSON.parse(json, symbolize_names: true)\n end", "def load_entity(type, id)\n path = entity_path(type, id)\n data = service.get(path)\n create_entity(type, id, data)\n end", "def decode(object)\n return unless object\n\n begin\n JSON.load object\n rescue JSON::ParserError => e\n raise DecodeException, e.message, e.backtrace\n end\n end", "def json_to_ruby\n json = File.read('./database/townhalls.json')\n obj = JSON.parse(json)\n return obj\n end", "def decode_json(json_str)\n convert_dates_from(JSON.parse(json_str, symbolize_names: true))\n end", "def initialize(json)\n @info = json if json.is_a? Hash\n @info ||= JSON.parse(json)\n end", "def run\n super\n\n f = _get_entity_name\n\n # Read and split the file up\n begin\n json = JSON.parse (File.open(f,\"r\").read)\n rescue JSON::ParserError => e\n _log_error \"Unable to parse, failing...\"\n return\n end\n\n\n\n\n\n end", "def convert_it_to_hash_format(object)\n JSON.parse(object)\n end", "def parse_json (json)\n begin\n return json if json.class == Hash\n return json if json.class == Array\n return JSON.parse(json)\n rescue Exception => e\n # Assuming it would be string.\n # Boolean type\n return true if json =~ (/^(true)$/i)\n return false if json =~ (/^(false)$/i)\n # Fixnum type\n return json.to_i if (json.to_i.to_s == json)\n # Float type\n return json.to_f if (json.to_f.to_s == json)\n return json\n end\n end", "def load_from_json!(raw_data)\n begin\n hash = JSON.parse(raw_data, symbolize_names: true)\n rescue JSON::ParserError => e\n raise InvalidRequestError, \"Malformed JSON data.\"\n end\n\n load_from_hash!(hash)\n end" ]
[ "0.7105521", "0.66010773", "0.6512244", "0.6490825", "0.6428207", "0.6293814", "0.6285323", "0.61657053", "0.61343664", "0.61341286", "0.6125743", "0.5979551", "0.5973756", "0.59164816", "0.57833725", "0.57226646", "0.57207406", "0.5691729", "0.56381327", "0.5630607", "0.56163406", "0.5596726", "0.557482", "0.5558002", "0.5523836", "0.55104524", "0.55099267", "0.55012685", "0.5469495", "0.54613036", "0.54425627", "0.5437895", "0.5415209", "0.5412572", "0.53884625", "0.53795576", "0.53677744", "0.5367105", "0.5365683", "0.52892536", "0.5260407", "0.5260407", "0.52543396", "0.5217246", "0.520944", "0.52036667", "0.52026474", "0.5199498", "0.5187229", "0.518384", "0.51695544", "0.516503", "0.5154366", "0.5141055", "0.5138763", "0.5126643", "0.5126304", "0.5082306", "0.50683963", "0.50683963", "0.5062789", "0.5053489", "0.5049844", "0.5046896", "0.5043257", "0.5041584", "0.50150627", "0.50146455", "0.5012237", "0.5006704", "0.50051326", "0.49983612", "0.4995319", "0.49902445", "0.49893498", "0.4957152", "0.49445012", "0.4941229", "0.4935171", "0.49289522", "0.49279583", "0.4926947", "0.49231547", "0.49129155", "0.49052522", "0.48972866", "0.4895625", "0.4895359", "0.48896748", "0.4888682", "0.4884836", "0.48816568", "0.48809543", "0.48727915", "0.4868174", "0.48677155", "0.486613", "0.48623174", "0.48531297", "0.48517713" ]
0.68498087
1
Converts options to a pager. If none of the below described options is provided, returns +nil+.
def pager(options) pager = if options.include?(:pager) options[:pager] elsif options[:paged] || options[:pre_paged] || options[:page].present? || options[:per].present? Ladon::Pager.new(options) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parse_paging_options(options, default_opts = {})\n if default_opts.blank?\n # This conditions will order records by directory and name first.\n default_opts = {\n :sort_criteria => DEFAULT_ORDER\n }\n end\n paging_options(options, default_opts)\n end", "def parse_paging_options(options, default_opts = {})\n if default_opts.blank?\n # This conditions will order records by directory and name first.\n default_opts = {\n :sort_criteria => \"goals.created_at DESC\"\n }\n end\n paging_options(options, default_opts)\n end", "def parse_paging_options(options, default_opts = {})\n if default_opts.blank?\n # This conditions will order records by directory and name first.\n default_opts = {\n :sort_criteria => \"due_date ASC\"\n }\n end\n paging_options(options, default_opts)\n end", "def parse_paging_options(options, default_opts = {})\n if default_opts.blank?\n # This conditions will order records by directory and name first.\n default_opts = {\n :sort_criteria => \"curriculums.created_at DESC\"\n }\n end\n paging_options(options, default_opts)\n end", "def which_pager\n if @options[:pager] =~ /auto/i\n pagers = [ENV['GIT_PAGER'], ENV['PAGER'],\n 'bat', 'less', 'more', 'cat', 'pager']\n pagers.delete_if(&:nil?).select!(&:available?)\n return nil if pagers.empty?\n\n pg = pagers.first\n args = case pg\n when /^(less|more)$/\n '-r'\n when 'bat'\n if @options[:highlight]\n '--language Markdown --style plain'\n else\n '--style plain'\n end\n else\n ''\n end\n\n [pg, args].join(' ')\n else\n pg = @options[:pager].split(/ /)[0]\n if pg.available?\n @options[:pager]\n else\n warn 'Specified pager not found, switching to auto'\n @options[:pager] = 'auto'\n which_pager\n end\n end\n end", "def best_available\n if !_pry_.config.pager\n NullPager.new(_pry_.output)\n elsif !SystemPager.available? || Helpers::Platform.jruby?\n SimplePager.new(_pry_.output)\n else\n SystemPager.new(_pry_.output)\n end\n end", "def best_available\n if !_pry_.config.pager\n NullPager.new(_pry_.output)\n elsif !SystemPager.available? || Pry::Helpers::BaseHelpers.jruby?\n SimplePager.new(_pry_.output)\n else\n SystemPager.new(_pry_.output)\n end\n end", "def render_with_options_or_default options\n if paginate?\n render(results_to_render: paginated_results(page: options[:page].presence || 1))\n else\n render\n end\n end", "def pager\n Pry::Pager.new(self)\n end", "def setup_pager!\n page\n end", "def pager=(_arg0); end", "def populate_pagination_attributes_from_options(options={})\n self.page = options[:page] || page || 1\n self.per_page = options[:per_page] || per_page || 50\n end", "def extract_pagination(options)\n if (value = options.delete(AUTO_PAGINATION))\n api.auto_pagination = value\n end\n end", "def setup_pager\n return if @use_stdout\n\n jruby = RUBY_ENGINE == 'jruby'\n\n pagers = [ENV['RI_PAGER'], ENV['PAGER'], 'pager', 'less', 'more']\n\n pagers.compact.uniq.each do |pager|\n next unless pager\n\n pager_cmd = pager.split(' ').first\n\n next unless in_path? pager_cmd\n\n if jruby then\n case io = find_pager_jruby(pager)\n when nil then break\n when false then next\n else io\n end\n else\n io = IO.popen(pager, 'w') rescue next\n end\n\n next if $? and $?.pid == io.pid and $?.exited? # pager didn't work\n\n @paging = true\n\n return io\n end\n\n @use_stdout = true\n\n nil\n end", "def initialize(command: nil, **options)\n super(**options)\n @pager_io = nil\n @pager_command = nil\n pager_command(*Array(command))\n\n if pager_command.nil?\n raise TTY::Pager::Error,\n \"#{self.class.name} cannot be used on your system due to \" \\\n \"lack of appropriate pager executable. Install `less` like \" \\\n \"pager or try using `BasicPager` instead.\"\n end\n end", "def format_options(options)\n return if options.blank?\n\n opts = {}\n opts['page'] = options[:page] if options.key?(:page)\n opts['per_page'] = options[:per_page] if options.key?(:per_page)\n opts['sort_column'] = options[:sort_by] if options.key?(:sort_by)\n opts['organization_id'] = options[:organization_id] if options.key?(:organization_id)\n opts\n end", "def pager_options(model=nil)\n per_page = (model && model.respond_to?(:per_page)) ? model.send(:per_page) : 25\n {:page => params[:page], :per_page => params[:per_page] || per_page}\n end", "def paginate(options={})\n pg_options, find_options = options.partition{|k,v| [:page, :per_page, :total_entries].include?(k)}\n \n pg_options[:page] ||= 1\n pg_options[:per_page] ||= per_page\n \n WillPaginate::Collection.create(pg_options[:page], pg_options[:per_page], pg_options[:total_entries]) do |pager|\n find_options[:params] = (find_options[:params] || {}).merge(:offset => pager.offset, :limit => pager.per_page) \n \n arr = find(:all, find_options) || []\n if pg_options[:total_entries]\n pager.total_entries = pg_options[:total_entries]\n else \n pager.total_entries = arr.size > pager.per_page ? arr.size : count(find_options[:params])\n end\n \n if arr.size > per_page\n pager.replace arr[pager.offset, pager.per_page]\n else\n pager.replace arr\n end\n end\n end", "def pager; end", "def spawn_pager\n # In case there's a previous pager running:\n close\n\n command = pager_command\n status = self.class.run_command(command)\n # Issue running command, e.g. unsupported flag, fallback to just command\n unless status\n command = pager_command.split.first\n end\n\n PagerIO.new(command)\n end", "def apply_pagination?(options)\n JSONAPI.configuration.default_paginator != :none &&\n (options[:paginate].nil? || options[:paginate])\n end", "def extract_per_page(options)\n Api::Sanitize.per_page_hash(options)\n end", "def will_paginate(collection_or_options = nil, options = {})\n if collection_or_options.is_a? Hash\n options, collection_or_options = collection_or_options, nil\n end\n unless options[:renderer]\n options = options.merge :renderer => BootstrapPagination::Rails\n end\n super *[collection_or_options, options].compact\n end", "def will_paginate(collection_or_options = nil, options = {})\n if collection_or_options.is_a? Hash\n options, collection_or_options = collection_or_options, nil\n end\n unless options[:renderer]\n options = options.merge :renderer => BootstrapPagination::Rails\n end\n super *[collection_or_options, options].compact\n end", "def paginate(options = {})\n page = options.delete(:page) || raise(ArgumentError, \"paginate requires a :page argument\")\n per_page = options.delete(:per_page)\n raise ArgumentError, \"unknown argument #{options.keys.first.inspect} passed to paginate\" unless options.empty?\n @query.paginate(page, per_page)\n end", "def wire_jqgrid_pager(options)\n if options[:pager].keys.size > 0\n return <<-JS\n \tpginput: true,\n \tpgbuttons: true,\n \trowList:[#{options[:pager][:rows_options] || ''}],\n \trowNum:#{options[:pager][:rows] || 20},\n JS\n else\n return <<-JS\n \tpginput: false,\n \tpgbuttons: false,\n \trowList: [],\n \trowNum: -1,\n JS\n end\n end", "def pages( options = {} )\n options = {:kind => nil, :pages => @pages, :params => {}}.merge(options)\n if options[:pages] and options[:pages].page_count > 1\n html = <<-END\n <div class=\"pages\">\n Page: #{pagination_links(options[:pages], {:window_size => 6, :params => params.merge(options[:params]).reject { |key,value| key == 'controller' }}).sub(/\\d+(?=\\s|$)/, '<span class=\"this_page\">\\&</span>').sub(\"...\", '<span class=\"break\">...</span>')}\n #{options[:kind].nil? ? \"\" : \"(#{options[:pages].last_page.last_item} #{options[:kind]})\"}\n </div>\n END\n end\n end", "def page(options = {})\n if(@data.length > 0)\n default = {:url => \"/\" + @type.pluralize.downcase + \"/list/?\", :text => \"\", :bottom => true, :top => false}\n @page_action = default.merge(options) \n end\n return self \n end", "def paginate(scope, options = {}, &block)\n PaginationRenderer.new self, options.reverse_merge(:current_page => scope.current_page, :num_pages => scope.num_pages, :per_page => scope.limit_value, :remote => false)\n end", "def will_paginate(collection_or_options = nil, options = {})\n if collection_or_options.is_a? Hash\n options = collection_or_options\n collection_or_options = nil\n end\n unless options[:renderer]\n options = options.merge renderer: CustomLinkRenderer\n end\n super *[collection_or_options, options].compact\n end", "def opts_for_paginate\n paginate_opts = combined_options.reject { |k,v| !OPTIONS_FOR_PAGINATE.include?(k) }\n paginate_opts[:finder] = :find_all_by_id unless paginate_opts.include?(:finder)\n paginate_opts[:per_page] = klass.per_page if klass && !paginate_opts.include?(:per_page)\n paginate_opts\n end", "def will_paginate(collection_or_options = nil, options = {})\n if collection_or_options.is_a? Hash\n options = collection_or_options\n collection_or_options = nil\n end\n options = options.merge renderer: WillPaginate::ActionView::Bootstrap4LinkRenderer unless options[:renderer]\n super(*[collection_or_options, options].compact)\n end", "def paginate(options={})\n page = [options[:page].to_i, 1].max\n per_page = (options[:per_page] || per_page).to_i\n request[:args].update(start: (page - 1) * per_page, hit: per_page)\n self\n end", "def log_pagination_options(options = {})\n skip = page_to_skip(options.delete(:page))\n options[:max_count] = [options.delete(:per_page).to_i, per_page].max\n options[:skip] = skip if skip > 0\n options\n end", "def will_paginate(collection_or_options = nil, options = {})\n if collection_or_options.is_a? Hash\n options, collection_or_options = collection_or_options, nil\n end\n unless options[:renderer]\n options = options.merge :renderer => WillPaginateHelper::BootstrapLinkRenderer\n end\n super *[collection_or_options, options].compact\n end", "def will_paginate(collection_or_options = nil, options = {})\n if collection_or_options.is_a? Hash\n options, collection_or_options = collection_or_options, nil\n end\n unless options[:renderer]\n options = options.merge renderer: MaterializePaginationHelper::MaterializeRenderer\n end\n super *[collection_or_options, options].compact\n end", "def per_page; @opts['per_page']; end", "def configuration_from_options(options)\n Jekyll.configuration(options)\n end", "def transformer\n convert unless @options.empty?\n end", "def paginate_opts\n ({}).tap do |ret|\n ret[:per_page] = Spree::Config[:products_per_page]\n ret[:page] = params[:page]\n end\n end", "def paginate(options={})\n populate_pagination_attributes_from_options(options)\n limit(per_page)\n offset((page - 1) * per_page)\n self\n end", "def get_scanner_options(options); end", "def find_pager_jruby pager\n require 'java'\n require 'shellwords'\n\n return nil unless java.lang.ProcessBuilder.constants.include? :Redirect\n\n pager = Shellwords.split pager\n\n pb = java.lang.ProcessBuilder.new(*pager)\n pb = pb.redirect_output java.lang.ProcessBuilder::Redirect::INHERIT\n\n @jruby_pager_process = pb.start\n\n input = @jruby_pager_process.output_stream\n\n io = input.to_io\n io.sync = true\n io\n rescue java.io.IOException\n false\n end", "def initialize pager, page; @pager, @page = pager, page; end", "def paginate opts = {}\n @paginator = true\n page = (opts[:page] || 1).to_i\n per_page = (opts[:per_page] || 20).to_i\n page = 1 if page < 1\n limit( per_page, ( page - 1 ) * per_page )\n end", "def page(query_options={}, page_num=0, limit=15)\n return pages(@default_query_options.merge(query_options), page_num, limit, false, false)\n end", "def log_pagination_options(options = {})\n self.class.log_pagination_options(options)\n end", "def stagger_output(text, _out = nil)\n if defined?(_pry_) && _pry_\n _pry_.pager.page text\n else\n Pry.new.pager.page text\n end\n end", "def extract_current_page(options)\n Api::Sanitize.page(options[:current_page] || options[:page])\n end", "def locate options={}\n if options.is_a? Hash\n page_number = options[:page]\n chapter_number = options[:chapter]\n end\n if page_number\n self.live_pages[page_number-1]\n else\n self.live_chapters[chapter_number-1]\n end\n end", "def open\n pager = best_available\n yield pager\n rescue StopPaging\n ensure\n pager.close if pager\n end", "def pager_command(*commands)\n if @pager_command && commands.empty?\n @pager_command\n else\n @pager_command = self.class.find_executable(*commands)\n end\n end", "def _paginate r\n return r if params[:action]=='print'\n # will it obey the #page call?\n # is it without format or html or scrolling or with search?\n if (r.respond_to?( :page)) && (params[:format].nil? or params[:format]=='html' or params[:scrolling] or params[:s])\n params[:perpage] ||= 20\n params[:page] ||= 1\n return r.page(params[:page]).per(params[:perpage])\n else\n return r\n end\n end", "def stagger_output(text, out = nil)\n if _pry_\n _pry_.pager.page text\n else\n Pry.new.pager.page text\n end\n end", "def initialize(options = {})\n @paged_objects = {0 => options[:seed_page]}\n @total = options[:total].to_i\n @per_page = options[:per_page].to_i\n @pages = @per_page > 0 ? (@total.to_f / @per_page.to_f).ceil : 0\n @load_more_call = options[:load_more_call]\n @no_threads = options[:no_threads] || DEFAULT_NO_THREADS\n end", "def open\n pager = best_available\n yield pager\n rescue StopPaging\n ensure\n pager.close if pager\n end", "def paginate(*args, &block)\n options = args.pop\n page, per_page, total_entries = wp_parse_options(options)\n\n WillPaginate::Collection.create(page, per_page, total_entries) do |pager|\n query_options = options.except :page, :per_page, :total_entries\n wp_query(query_options, pager, args, &block)\n end\n end", "def handle_options\n options.tdplib = ['tdplib']\n options.templates = []\n\n OptionParser.new do |opts|\n opts.banner = \"tdp [-f tdp_file] {options} targets...\"\n opts.separator \"\"\n opts.separator \"Options are ...\"\n\n opts.on_tail(\"-h\", \"--help\", \"-H\", \"Display this help message.\") do\n puts opts\n exit\n end\n\n standard_tdp_options.each { |args| opts.on(*args) }\n opts.environment('TDPOPT')\n end.parse!\n end", "def twill_paginate(collection = nil, options = {})\n will_paginate collection, {:previous_label => t('commons.previous'), :next_label => t('commons.next')}.merge(options)\n end", "def paginate( options = {} )\n pp = options.delete(:per_page) || per_page\n all = options.delete(:all)\n\n options.delete(:category_id) if options[:category_id].nil?\n\n count = count_for( all, options[:category_id] )\n\n Paginator.new( count, per_page ) do |offset, per_page|\n all( default_options.merge(options).merge( :limit => pp, :offset => offset ) )\n end\n end", "def enable_paging\n return unless $stdout.tty?\n return unless Process.respond_to? :fork\n\n read, write = IO.pipe\n\n # Kernel.fork is not supported on all platforms and configurations.\n # As of Ruby 1.9, `Process.respond_to? :fork` should return false on\n # configurations that don't support it, but versions before 1.9 don't\n # seem to do this reliably and instead raise a NotImplementedError\n # (which is rescued below).\n\n if Kernel.fork\n $stdin.reopen read\n write.close\n read.close\n Kernel.select [$stdin]\n ENV['LESS'] = 'FSRX' unless ENV.key? 'LESS'\n pager = ENV['PAGER'] || 'less'\n exec pager rescue exec '/bin/sh', '-c', pager\n else\n # subprocess\n $stdout.reopen write\n $stderr.reopen write if $stderr.tty?\n write.close\n read.close\n end\n rescue NotImplementedError\n ensure\n write.close if write && !write.closed?\n read.close if read && !read.closed?\n end", "def eds_plink(options = nil)\n values, opt = extract_config_value(options)\n result = Array.wrap(values).reject(&:blank?)\n if rendering_non_html?(opt)\n (values.is_a?(Array) || (result.size > 1)) ? result : result.first\n elsif result.present?\n outlink(EDS_PLINK_LABEL, result.first)\n else\n return_empty(__method__)\n end\n end", "def toggle_pager\n config[:pager] = !config[:pager]\n end", "def run_pager\n return unless @pager\n return if Gem.win_platform?\n return unless STDOUT.tty?\n\n @color_scheme = ColorScheme::NONE unless get_pager == \"less\"\n\n read, write = IO.pipe\n\n unless Kernel.fork # Child process\n STDOUT.reopen(write)\n STDERR.reopen(write) if STDERR.tty?\n read.close\n write.close\n return\n end\n\n # Parent process, become pager\n STDIN.reopen(read)\n read.close\n write.close\n\n ENV['LESS'] = 'FSRX' # Don't page if the input is short enough\n\n Kernel.select [STDIN] # Wait until we have input before we start the pager\n pager = get_pager\n exec pager rescue exec \"/bin/sh\", \"-c\", pager\n end", "def initialize(collection, options = {})\n @page = Integer(options[:page] || 1)\n @per_page = Integer(options[:per_page] || Pagination.per_page)\n end", "def paginated(options = {})\n @klass.new(@full_collection, options).paginate\n end", "def paginate(options)\n proxy = create_collection_proxy(options)\n proxy.paginate(options)\n end", "def paginate(rds, opts)\n paginator_key = opts[:paginate_with] || raise(ArgumentError, 'Missing :paginate_with option')\n pagination = opts[:pagination] || {}\n paginator_proc = @paginators[paginator_key]\n\n unless paginator_proc\n paginator_keys = @paginators.keys.map(&:inspect).join(', ')\n msg = \"Paginator #{paginator_key.inspect} not found\"\n msg << \", available are #{paginator_keys}\" if paginator_keys.present?\n raise(ArgumentError, msg)\n end\n\n # Run the pagination block\n paginator_proc.call(rds, pagination)\n\n rds\n end", "def twill_paginate(collection = nil, options = {})\n #require 'will_paginate/array'\n will_paginate collection, {:previous_label => I18n.t('commons.previous'), :next_label => I18n.t('commons.next')}.merge(options)\n end", "def convert_options(opts); end", "def format_options(options)\n return if options.blank?\n options[:fields] = format_fields(options[:fields]) if options.has_key?(:fields)\n options[:limit] = options[:limit] if options.has_key?(:limit)\n options[:pageindex] = options[:page] if options.has_key?(:page)\n options[:q] = options[:q] if options.has_key?(:q)\n options[:wField] = options[:wField] if options.has_key?(:wField)\n options[:wOperator] = options[:wOperator] if options.has_key?(:wOperator)\n options[:wValue] = options[:wValue] if options.has_key?(:wValue)\n\n return options\n end", "def getOptions\n return OptionParser.new\n end", "def page(opts = {})\n class_name = opts.is_a?(Hash) ? opts.fetch(:class, nil) : opts\n puts get_android_inspect class_name\n nil\n end", "def paginate(arg, options = {})\n if arg.instance_of?(Symbol) or arg.instance_of?(String)\n # Use default paginate function.\n collection_id = arg # arg is, e.g., :specs or \"specs\"\n super(collection_id, options)\n else\n # Paginate by hand.\n items = arg # arg is a list of items, e.g., users\n items_per_page = options[:per_page] || 10\n page = (params[:page] || 1).to_i\n result_pages = Paginator.new(self, items.length, items_per_page, page)\n offset = (page - 1) * items_per_page\n [result_pages, items[offset..(offset + items_per_page - 1)]]\n end\n end", "def pager(&block)\n pager = self[KEY]\n return pager unless block\n self[KEY].start(&block)\n end", "def display_paginator(collection, options = {}, html_options = {})\n object_name = options[:object_name] || 'item'\n length = collection.is_a?(WillPaginate::Collection) ? collection.total_entries : collection.length\n per_page = collection.is_a?(WillPaginate::Collection) && !options[:no_per_page] ? collection.per_page : nil\n tag = options[:tag] || :p\n lengths = options[:per_page_lengths] || controller.class::PAGINATION_LENGTHS\n\n return content_tag(tag, html_options) do\n parts = [\n pagination_links(collection),\n length,\n length == 1 ? object_name : object_name.pluralize\n ]\n if per_page\n parts += [\n '| per page:',\n lengths.map {|l| change_pagination_length_link(per_page, l)}.join(', ')\n ]\n end\n parts.join(' ')\n end\n end", "def format_options(options)\n return if options.blank?\n\n opts = {}\n opts[options[:filter][:key]] = options[:filter][:value] if options.key?(:filter)\n opts['expand'] = options[:expand] if options.key?(:expand)\n opts['page'] = options[:page] if options.key?(:page)\n opts\n end", "def paginate(collection , options = {})\n #options = options.merge defaults\n options[:renderer] = BootstrapPagination::Rails\n will_paginate collection, options\n end", "def configure(ph_options = {}, options = {}, extensions = {})\n @@options ||= PageHubOptions.dup\n @@options.merge!(ph_options)\n\n @@renderer = Redcarpet::Markdown.new(\n HTMLWithAlbino.new(RendererOptions.merge(options)),\n RendererExtensions.merge(extensions))\n end", "def paginated(collection, options = {})\n respond_with_object_and_type collection, options, :paginated, false\n end", "def parse_options\n options[:markdown] = false\n o = OptionParser.new do |opts|\n opts.on('-m', '--markdown', 'Use Markdown Syntax') do\n options[:markdown] = true\n end\n opts.on('-l', '--html', 'Use HTML Syntax') do\n options[:html] = true\n end\n opts.on('-s', '--size PERCENTAGE', 'Image Size') do |value|\n options[:size] = value\n end\n opts.on('-t', '--title TITLE', 'Image Title') do |value|\n options[:title] = value\n end\n opts.on('-d', '--desc DESC', 'Image Title') do |value|\n options[:desc] = value\n end\n opts.on('-v', '--version', 'Print Version') do\n version\n quit\n end\n opts.on('-h', '--help', 'Print Help') do\n help\n quit\n end\n end\n begin\n o.parse!\n rescue OptionParser::MissingArgument => e\n puts \"Error: #{e.message}\"\n quit\n rescue OptionParser::InvalidOption => e\n puts \"Error: #{e.message}\"\n quit\n end\n end", "def render(options = nil, extra_options = {}, &block)\n # your code goes here\n prep_pagination_info(@results_h[:pagination_info]) if @results_h && @results_h[:pagination_info]\n \n # call the ActionController::Base render to show the page\n super\n end", "def manageable_pagination(options = {})\n current_page = options[:current_page] || 1\n num_pages = options[:num_pages] || 1\n outer_window = options[:outer_window] || 4\n page_param = options[:param_name] || :page\n\n if current_page <= num_pages\n previous_page = current_page - 1\n next_page = current_page + 1\n left_window = ((current_page - outer_window)...current_page).to_a.select{|i| i > 0}\n right_window = ((current_page + 1)..(current_page + outer_window)).to_a.select{|i| i <= num_pages}\n\n elements = []\n\n if 1 != current_page\n # First\n elements << {:value => t(\"manageable.pagination.first\"), :href => params.merge(page_param => 1)}\n\n # Previous\n elements << {:value => t(\"manageable.pagination.previous\"), :href => params.merge(page_param => previous_page)}\n end\n\n # Left Gap\n if left_window.first && left_window.first != 1\n elements << {:value => t(\"manageable.pagination.gap\")}\n end\n\n # Left window\n left_window.each do |i|\n elements << {:value => i, :href => params.merge(page_param => i)}\n end\n\n # Current Page\n elements << {:value => current_page, :html => {:class => \"current\"}}\n\n # Right window\n right_window.each do |i|\n elements << {:value => i, :href => params.merge(page_param => i)}\n end\n\n # Right Gap\n if right_window.last && right_window.last != num_pages\n elements << {:value => t(\"manageable.pagination.gap\")}\n end\n\n if num_pages != current_page\n # Next\n elements << {:value => t(\"manageable.pagination.next\"), :href => params.merge(page_param => next_page)}\n\n # Last\n elements << {:value => t(\"manageable.pagination.last\"), :href => params.merge(page_param => num_pages)}\n end\n\n content_tag :div, :class => \"pagination\" do\n elements.map do |options|\n if options[:href]\n link_to options[:value], options[:href]\n else\n content_tag(:span, options[:value], options[:html])\n end\n end.join.html_safe\n end\n end\n end", "def options ; @options ||= get(:options) end", "def options\n @options ||= Options.new\n end", "def options\n @options ||= Options.new\n end", "def paginate(options = {})\n raise ArgumentError, \"parameter hash expected (got #{options.inspect})\" unless Hash === options\n\n page = (options[:page] || 1).to_i\n per_page = (options[:per_page] || 30).to_i\n\n @total_entries = count\n @total_pages = (@total_entries / per_page.to_f).ceil\n @current_page = page\n\n query.update(offset: (page - 1) * per_page, limit: per_page)\n\n self\n end", "def paginate(path, options={})\n per_page = options[:per_page] || options[\"per_page\"] || @per_page\n page = options[:page] || options[\"page\"]\n response = get(path+\"?page=1&per_page=#{per_page}\")\n\n # return one page results without pagination.\n return response if !@auto_paginate\n\n # return all results when enabled auto paginate\n last_response = response.dup\n data = response[\"data\"]\n while last_response[\"next_page_url\"]\n last_response = get(last_response[\"next_page_url\"] + \"&per_page=#{per_page}\")\n data.concat(last_response[\"data\"]) if last_response[\"data\"].is_a?(Array)\n end\n\n return data\n end", "def _process_options(options); end", "def _process_options(options); end", "def parse\n opts = OptionParser.new(&method(:set_options))\n opts.parse!(@args)\n return process_url if url_present?\n opts.help\n end", "def set_pagination_buttons(data, options = {})\n return if data.nil? || data.empty?\n\n if data.next_page\n params = {\n :page => data.next_page,\n :per_page => data.per_page\n }.merge(options)\n\n @next_page = \"?#{Rack::Utils.build_query params}\"\n end\n\n if data.previous_page\n params = {\n :page => data.previous_page,\n :per_page => data.per_page\n }.merge(options)\n\n @prev_page = \"?#{Rack::Utils.build_query params}\"\n end\n end", "def set_pagination_buttons(data, options = {})\n return if data.nil? || data.empty?\n\n if data.next_page\n params = {\n :page => data.next_page,\n :per_page => data.per_page\n }.merge(options)\n\n @next_page = \"?#{Rack::Utils.build_query params}\"\n end\n\n if data.previous_page\n params = {\n :page => data.previous_page,\n :per_page => data.per_page\n }.merge(options)\n\n @prev_page = \"?#{Rack::Utils.build_query params}\"\n end\n end", "def paginate(model, options={})\n\t\t\n\t\t# if this method was called with 'nil', return a mock object. since templates\n\t\t# will expect the keys to be present in the output of this method, this is a\n\t\t# handy way to temporarily remove the data from a table without errors\n\t\tif model.nil?\n\t\t\treturn({\n\t\t\t\t:this_page =>1,\n\t\t\t\t:per_page =>20,\n\t\t\t\t:page_count =>1,\n\t\t\t\t:data =>[]\n\t\t\t})\n\t\tend\n\t\t\n\t\tthis_page = (options.delete(:page) || 1).to_i\n\t\tper_page = (options.delete(:per_page) || 20).to_i\n\t\t\n\t\t# make sure we're sorting to *something*, to make\n\t\t# sure the data doesn't come out in arbitrary order\n\t\t# (note that :id might not actually exist, but it's\n\t\t# a pretty sane default)\n\t\tunless options.has_key?(:order)\n\t\t\toptions[:order] = [:id.desc]\n\t\tend\n\t\t\n\t\t# fetch the total number of models, to calculate\n\t\t# the number of pages we'll need to list them all\n\t\tpage_count = (model.count(options).to_f / per_page).ceil\n\t\t\n\t\t# add the boundary options, leaving any other\n\t\t# options (conditions, orders, etc) intact\n\t\toptions.merge!({\n\t\t\t:offset => (this_page-1) * per_page,\n\t\t\t:limit => per_page\n\t\t})\n\t\t\n\t\t# return a whole bunch of data, to\n\t\t# be shunted straight into the view\n\t\t{ :this_page=>this_page, :per_page=>per_page, :page_count=>page_count, :data=>model.all(options) }\n\tend", "def parser\n create_option_parser if @parser.nil?\n @parser\n end", "def set_opts(options)\n @opt ||= options\n end", "def paginated_collected(options = {})\n paginated(options)\n end", "def first_two_result_pages(options = {})\n get_result_pages([1, 2], options)\n end", "def per_page\n @options[:limit] ||= @options[:per_page]\n @options[:limit] ||= 20\n @options[:limit].to_i\n end", "def initialize(opts={})\n assert_valid_opts(opts)\n setup_pages\n end" ]
[ "0.6366224", "0.6321129", "0.6264103", "0.613818", "0.59587413", "0.5934598", "0.5926572", "0.5889537", "0.5737416", "0.57153875", "0.56498396", "0.5614686", "0.5596935", "0.55710346", "0.55707645", "0.5552049", "0.5524171", "0.5480148", "0.5470236", "0.54599315", "0.5397454", "0.53831506", "0.5377525", "0.5377525", "0.53339034", "0.5330485", "0.52837217", "0.5216703", "0.5189586", "0.5181007", "0.51699466", "0.5132188", "0.5116227", "0.511379", "0.5111039", "0.5107867", "0.51054895", "0.50736135", "0.505291", "0.5050725", "0.50471044", "0.503828", "0.5033581", "0.50255734", "0.49271065", "0.49161303", "0.49091142", "0.48954892", "0.48866802", "0.48751044", "0.48682547", "0.48671886", "0.48631257", "0.485639", "0.48360297", "0.48283502", "0.4824594", "0.48213166", "0.4815903", "0.48118296", "0.48082495", "0.4807656", "0.4782483", "0.4776383", "0.47651696", "0.47480965", "0.47426564", "0.47259644", "0.47240782", "0.4707451", "0.47059664", "0.46887562", "0.46783516", "0.46587956", "0.46537915", "0.4634572", "0.4630259", "0.46276644", "0.46225566", "0.4608277", "0.46014112", "0.45961094", "0.45959795", "0.45929182", "0.45922336", "0.45922336", "0.4587784", "0.45875922", "0.4585712", "0.4585712", "0.45806816", "0.4577889", "0.45774093", "0.45739883", "0.45670417", "0.45652026", "0.4564849", "0.45536977", "0.45535356", "0.45534316" ]
0.7431409
0
TODO: chawarong ask P'Phob if payment_term and payment_term_day needs to be present
def validate_on_create @count_client_contact_record = ClientContactRecord.count(:all, :conditions => ['client_contract_id=?',client_contract_id]) if @count_client_contact_record == 0 errors.add_to_base('Please Add Client contact record first') return false else return true end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def payment_term; end", "def term_of_payments\n @term_of_payments ||= TermOfPaymentProxy.new(self)\n end", "def paymentterm\n paymentterms.first\n end", "def create\n @payment = Payment.new(payment_params) \n \n @payment.enterprise_id = current_enterprise.id\n @payment.nombre_empresa = current_enterprise.nombre\n @payment.tiempo_termino = Time.now\n\n if @payment.plane_id == 1\n @payment.tiempo_termino = @payment.tiempo_termino+ 62.days\n elsif @payment.plane_id == 2\n @payment.tiempo_termino = @payment.tiempo_termino + 183.days\n elsif @payment.plane_id == 3\n @payment.tiempo_termino = @payment.tiempo_termino + 366.days\n end\n respond_to do |format|\n if @payment.save\n \n format.html { redirect_to @payment, notice: 'Payment was successfully created.' }\n format.json { render :show, status: :created, location: @payment }\n else\n format.html { render :new }\n format.json { render json: @payment.errors, status: :unprocessable_entity }\n end\n end\n end", "def add_payment_entry_row\n @ac = ApplicationController.new\n \n @day = params[:payment_date][3..4]\n @month = params[:payment_date][0..1]\n @year = params[:payment_date][6..9]\n \n @total_payment = params[:amount].to_s\n 3.times do\n @total_payment.sub!(\",\", \"\")\n end\n @total_payment = @total_payment.to_f\n \n @pfd = PaymentFromDestination.create(:payment_date => \"#{@year}-#{@month}-#{@day}\", :payment_num => params[:payment_num], :destination_id => params[:destination_id], :job_id => params[:job_id], :tickets => params[:tickets], :net_mbf => params[:net_mbf], :tonnage => params[:tonnage], :total_payment => @total_payment, :wood_type => params[:wood_type])\n end", "def term_in_days\n if self.is_subscription?\n if RAILS_ENV == \"production\" && self.attributes.symbolize_keys.keys.include?(:term_in_days)\n self[:term_in_days] || self.monthly_term_days\n else\n # determine by configured sku codes\n if self.sku.match(/^S([0-9]*)$/i)\n self.anual_term_days\n elsif self.sku.match(/^P([0-9]*)$/i)\n self.monthly_term_days\n end\n end\n end\n end", "def create\n @fee = Fee.new(fee_params)\n student = Student.find(params[:fee][:student_id])\n temp = student.due_date.to_date\n if student.term == 'Monthly'\n student.due_date = (temp + 1.month).to_s\n elsif student.term == \"Quarterly\"\n student.due_date = (temp + 3.month).to_s\n elsif student.term = \"Bi-annualy\"\n student.due_date = (temp + 6.month).to_s\n end\n student.save\n @fee.save\n redirect_to fee_path(@fee.id), notice: \"Fee Submitted Successfully\"\n end", "def payment(rate, bal, term)\n # Convert annual rate to monthly and make it decimal.\n r = rate / 1200\n\n # Numerator\n n = r * bal\n\n # Denominator\n d = 1 - (1 + r)**-term\n\n # Calc the monthly payment.\n pmt = n / d\n end", "def _spent_on\n return payment\n end", "def save_edited_payment_entry\n @raw_date = params[:payment_date]\n \n @day = @raw_date[3..4]\n @month = @raw_date[0..1]\n @year = @raw_date[6..9]\n \n @payment_date = \"#{@year}-#{@month}-#{@day}\"\n \n @payment = PaymentFromDestination.find(params[:id])\n @payment.job_id = params[:job_id]\n @payment.destination_id = params[:destination_id]\n @payment.payment_date = @payment_date\n @payment.payment_num = params[:payment_num]\n @payment.wood_type = params[:wood_type_id]\n @payment.tickets = params[:tickets]\n @payment.tonnage = params[:tonnage]\n @payment.net_mbf = params[:net_mbf]\n \n #Because the total payment comes in as string in currency format\n # some parts have to be stripped off to be able to turn it into float correctly\n @total_payment = params[:amount].to_s\n 3.times do\n @total_payment.sub!(\",\", \"\")\n end\n @total_payment = @total_payment.to_f\n \n @payment.total_payment = @total_payment\n \n unless @payment.save\n render :status => 306, :nothing => true\n return\n else\n render :status => 200, :nothing => true\n return\n end\n end", "def check_terms_and_cond(params, options, payment)\n # Make sure they agreed to the terms and conditions; do it here\n # rather than above so the credit card info they typed in is\n # preserved on the page for them (@credit_card is used for that)\n if (!params[:terms_and_conditions] && options[:suppress_terms_and_conds_check].nil?)\n payment.fail!\n return CHECKOUT_TERMS\n end\n nil\n end", "def payment_method\n self.payments.last.andand.payment_method || \"none\"\n end", "def payment_params\n params.require(:payment).permit(:student_id, :section_id, :year, :month, :date, :payment_mode, :tuition_fee,:library_fund,:computer_fee,:science_lab_fee,:video_music_fee,:sports_fund,:workbook_charges,:AC_charges,:generator_charges, :fine, :previous_books, :annual_fund, :total)\n end", "def payment_params\n params.require(:payment).permit(:doc_number, :description, :due_date, :payment_date, :installments, :value_doc, :supplier_id, :type_doc, :status, :form_payment, :categ_payment_id)\n end", "def process_order_payment\n \n return \"No Order Paid Date not found, order NOT PROCESSED\" if self.paid_date.blank?\n return \"No Order Paid Amount not found, order NOT PROCESSED\" if self.paid_amount.blank?\n return \"No Order Ref Name not found, order NOT PROCESSED\" if self.name.blank? \n return \"No Order Ref Id not found, order NOT PROCESSED\" if self.order_master_id.blank? \n \n return \"Paid Amount #{self.paid_amount} is less than ORDER AMOUNT #{self.order_master.grand_total}\" if self.paid_amount.to_i < self.order_master.grand_total.to_i\n \n order_master = OrderMaster.new\n return order_master.process_order self.order_master_id\n \n end", "def get_payment_ticket\n end", "def payment_instruction\n end", "def kentrade_params\n params.require(:kentrade).permit(:idf_document_fee, :payment_date)\n end", "def pay_targeted_invoices_first!\n payments.each do |pm|\n if pm.invoice\n @remaining_amounts[pm.invoice.fy_year] ||= Hash.new(0)\n if pm.invoice.canceled?\n @remaining_amounts[pm.invoice.fy_year][pm.invoice.object_type] += pm.amount\n else\n paid_amount = [[pm.amount, pm.invoice.missing_amount].min, 0].max\n pm.invoice.increment!(:paid_amount, paid_amount)\n @remaining_amounts[pm.invoice.fy_year][pm.invoice.object_type] += pm.amount - paid_amount\n end\n else\n @remaining_amount += pm.amount\n end\n end\n end", "def generate_payments start_date, end_date\n \tdates = start_date.step( end_date ).\n \t select { |date| date.day == bill.due_on }.\n \t map { |date| Payment.from date, bill, self }\n end", "def create\n \n #se não informou a data do vencimento\n if payment_params[:due_date].blank?\n flash[:warning] = 'Informe a data do vencimento!'\n redirect_to new_payment_path and return\n end\n \n #se não informou a data do pagamento\n if payment_params[:payment_date].blank?\n flash[:warning] = 'Informe a data do pagamento!'\n redirect_to new_payment_path and return\n end\n \n \n @payment = Payment.new(payment_params)\n @qnt_parcela = payment_params[:installments].to_i\n \n #inserindo os valores fixos conforme solicitado pelo cliente\n #@payment.supplier_id = '9'\n @payment.type_doc = \"OUTROS\"\n @payment.form_payment = \"DINHEIRO\"\n \n #se for somente uma parcela ele só salva uma vez\n if @qnt_parcela == 1\n \n respond_to do |format|\n if @payment.save\n format.html { redirect_to @payment, notice: 'Pagamento cadastrado com sucesso.' }\n format.json { render :show, status: :created, location: @payment }\n else\n format.html { render :new }\n format.json { render json: @payment.errors, status: :unprocessable_entity }\n end\n end\n else\n #se tiver mais de uma parcela ele lança a quantidade de vezes no sistema\n if @qnt_parcela > 1\n @valor_total = payment_params[:value_doc].to_f\n @resultado = @valor_total / @qnt_parcela\n @resultado = (@resultado).round(2)\n @data_vencto = payment_params[:due_date]\n end\n \n while @qnt_parcela > 0\n @conta_parc = @conta_parc.to_i + 1 \n @data_vencto = @data_vencto.to_date + 1.month \n @payment.description = payment_params[:description] + ' Parc. ' + @conta_parc.to_s\n @payment.due_date = @data_vencto\n @payment.payment_date = Date.today\n @payment.value_doc = @resultado\n \n if @payment.save\n #só vai fazer o redirect quando finalizar\n else\n format.html { render :new }\n format.json { render json: @payment.errors, status: :unprocessable_entity }\n end\n @qnt_parcela = @qnt_parcela - 1\n @payment = Payment.new(payment_params) \n end \n redirect_to payments_path\n flash[:success] = 'Parcelamento realizado com sucesso!'\n end \n \n end", "def driver_service_agreement\n @job = Job.joins(:company).where(companies: { disabled: false }).where(id: params[:job])\n @months = %w[January February March April May June July August September October November December]\n\n if @job.length == 1\n @job = @job.first\n @job_start_day = @job.starts_on.day.to_s\n\n # rubocop:disable Metrics/LineLength\n if (@job_start_day[1] == \"1\") || (@job_start_day == \"1\") && (@job_start_day.to_i < 11) && (@job_start_day.to_i > 20)\n @job_start_day += \"st\"\n elsif (@job_start_day[1] == \"2\") || (@job_start_day == \"2\") && (@job_start_day.to_i < 11) && (@job_start_day.to_i > 20)\n @job_start_day += \"nd\"\n elsif (@job_start_day[1] == \"3\") || (@job_start_day == \"3\") && (@job_start_day.to_i < 11) && (@job_start_day.to_i > 20)\n @job_start_day += \"rd\"\n else\n @job_start_day += \"th\"\n end\n # rubocop:enable Metrics/LineLength\n\n @job_start_month = @months[@job.starts_on.month]\n\n @job_start_year = @job.starts_on.year\n\n if @job.driver.nil?\n @job = nil\n elsif current_user.driver? && @job.driver.id != current_user.id\n @job = nil\n elsif current_user.company_user? && @job.company.id != current_user.company.id\n @job = nil\n end\n else\n @job = nil\n end\n end", "def subscription_payment\n\n\n @sub = Subscription.where(return_token: params[:id]).first\n\n @amount = 0\n if @sub.subscription_type = \"Standard\"\n @amount = 3\n end\n \n if @sub.subscription_type = \"Pro\"\n @amount = 5\n end\n\n if @sub.subscription_type = \"Enterprise\"\n @amount = 10\n end\n\n @sub.payment_status = \"Paid\"\n @sub.save\n\n @sub_payment = SubscriptionPayment.new\n @sub_payment.subscription_type = @sub.subscription_type\n @sub_payment.amount = @amount\n @sub_payment.date_from = @sub.date_from\n @sub_payment.date_to = @sub.date_to\n @sub_payment.payment_for = \"Subscription\"\n @sub_payment.subscription_id = @sub.id\n @sub_payment.payment_date = Date.today\n\n @sub_payment.save\n\n redirect_to :controller => 'backend', :action => 'dashboard'\n\n end", "def pay(payment)\n retval\n end", "def book_sales(period='enddate', basis, exclude)\n royalty_period = Period.where([\"currentperiod = ? and client_id = ?\", true, self.client_id])\n if period == 'startdate'\n self.calculate_book_royalties(self, royalty_period.first.enddate, royalty_period.first.startdate, basis, exclude)\n else #if period isn't 'startdate'\n self.calculate_book_royalties(self, royalty_period.first.enddate, \"1900-01-01\", basis, exclude)\n end\n end", "def save_expiry_date_period(month, year, day, product_id, part_number)\n\n \t# First we check if the date is already in the table\n \tif(Calendar.where(year: year, month: month).blank?)\n \t c = Calendar.new(year: year, month: month)\n \t c.info = get_info(day, product_id, part_number)\n \t c.save\n \telse\n \t c = Calendar.where(month: month, year: year)\n \t string = c.info\n \t c.info = get_info(day, product_id, part_number, string)\n \t c.info.save\n \tend\n end", "def payment_params\n params.require(:payment).permit(:booking_id, :price_cents, :price_currency, :method)\n end", "def create_invoice\n invoice_data = {\n payplan_id: self.payplan.id, \n payertype: \"fiz\", \n paymenttype: \"creditcard\", \n service_handle: self.payplan.service_handle \n }\n if self.status\n if self.payplan_id == Payplan.favorite_free_id\n invoice = Invoice.create(invoice_data.merge!(status: \"Оплачен\"))\n payment = invoice.get_payment.update(paymentdate: Date.today, status: \"Оплачен\")\n else\n invoice = Invoice.create(invoice_data)\n end\n end\nend", "def due_by\n #occurring_days = ae_definition.occurring_days\n dob = profile.kids_type.birthdate.to_date\n dob + (ae_definition.occurring_days + ae_definition.due_by_days )\n end", "def lease_params\n params.require(:lease).permit(:unit_id, :start_date, :end_date, :payment_amount, :payment_first_date, :payment_reminder_days, :payment_days_until_late, :unit_id)\n end", "def add_payment_details(post, amount, payment, options)\n txn = {\n 'donationAmt': amount(amount),\n 'recurrpay': empty?(options[:recurrfreq]) ? 'N' : 'Y',\n 'recurrfreq': options[:recurrfreq],\n 'othamt4': options[:othamt4]\n }\n payment_details =\n if payment.respond_to?(:routing_number)\n { 'paymenttype': options[:payment_type].presence || 'ACH' }\n else\n options = {\n 'paymenttype': CARD_BRAND[payment.brand.to_sym],\n 'ccnumber': payment.number,\n 'ccexpire':\n \"#{format(payment.month, :two_digits)}#{format(payment.year, :two_digits)}\"\n }\n if payment.verification_value\n options['ccvv'] = payment.verification_value\n end\n options\n end\n\n # if we are processing a creditcard payment, we need to insert\n # the cardholder name in the supporter hash\n unless payment.respond_to?(:routing_number)\n post['supporter'].merge!('Credit Card Holder Name': payment.name)\n end\n post['transaction'] =\n txn.merge(payment_details).delete_if { |_, v| v.blank? }\n end", "def vdate_taxcomputation_amount\n \n if(taxOnAggregateInc && !vdate_is_valid_amount_range?(taxOnAggregateInc))\n errors.add(taxOnAggregateInc,'Tax Payable on Aggregate Income is out of valid range.')\n end\n \n if(rebateOnAgriInc && !vdate_is_valid_amount_range?(rebateOnAgriInc))\n errors.add(rebateOnAgriInc,'Rebate on Net Agricultural Income is out of valid range.')\n end\n \n if(totalTaxPayable && !vdate_is_valid_amount_range?(totalTaxPayable))\n errors.add(totalTaxPayable,'Total Tax Payable is out of valid range.')\n end\n \n if(surchargeOnTaxPayable && !vdate_is_valid_amount_range?(surchargeOnTaxPayable))\n errors.add(surchargeOnTaxPayable,'SurCharge on Total Tax is out of valid range.')\n end\n \n if(educationCess && !vdate_is_valid_amount_range?(educationCess))\n errors.add(educationCess,'Education Cess is out of valid range.')\n end\n \n if(grossTaxLiability && !vdate_is_valid_amount_range?(grossTaxLiability))\n errors.add(grossTaxLiability,'Gross Tax Liability is out of valid range.')\n end\n \n if(section89 && !vdate_is_valid_amount_range?(section89))\n errors.add(section89,'Relief under Section 89 is out of valid range.')\n end\n \n if(section90and91 && !vdate_is_valid_amount_range?(section90and91))\n errors.add(section90and91,'Relief under Section 90/91 is out of valid range.')\n end\n \n if(netTaxLiability && !vdate_is_valid_amount_range?(netTaxLiability))\n errors.add(netTaxLiability,'Net Tax Liability is out of valid range.')\n end\n \n if(intrstPayUs234A && !vdate_is_valid_amount_range?(intrstPayUs234A))\n errors.add(intrstPayUs234A,'Interest Payable u/s 234A is out of valid range.')\n end\n \n if(intrstPayUs234B && !vdate_is_valid_amount_range?(intrstPayUs234B))\n errors.add(intrstPayUs234A,'Interest Payable u/s 234B is out of valid range.')\n end\n \n if(intrstPayUs234C && !vdate_is_valid_amount_range?(intrstPayUs234C))\n errors.add(intrstPayUs234C,'Interest Payable u/s 234C is out of valid range.')\n end\n \n if(totalIntrstPay && !vdate_is_valid_amount_range?(totalIntrstPay))\n errors.add(totalIntrstPay,'Total Interest Payable u/s 234 is out of valid range.')\n end \n \n if(totTaxPlusIntrstPay && !vdate_is_valid_amount_range?(totTaxPlusIntrstPay))\n errors.add(totTaxPlusIntrstPay,'Tatal Tax and Interest on delayed tax is out of valid range.')\n end \n \nend", "def payment_params\n params.require(:payment).permit(:description, :payment_date, :payment_type_id)\n end", "def rent_payment_params\n params.require(:rent_payment).permit(:leaseID, :paymentAmount, :dateReceived, :name)\n end", "def unit_payment(mort_disc, interest, numberOfMonths,payment)\n (mort_disc * payment) / ((1.0 + interest) ** (numberOfMonths / 12.0))\n end", "def payment_params\n payment_validation.select {|k,v| k != \"account_number\" && k != \"password\" }\n end", "def pro_rata_start_date\n # \n # Tue Nov 23 00:53:04 IST 2010, ramonrails\n # * we will never use \"installation_datetime\"\n # * installation_datetime is the \"desired\" installation datetime\n # * Pro-rata is charged from the date a panic button is received making user ready to install\n #\n # * check panic button press\n _date = panic_received_at\n # * no panic? check shipping date\n _date ||= (shipped_at + 7.days) unless shipped_at.blank? # if ( _date.blank? && !shipped_at.blank? )\n # * no panic or shipping? nothing returned\n # # \n # # Wed Mar 30 03:46:04 IST 2011, ramonrails\n # # * https://redmine.corp.halomonitor.com/issues/4253\n # # * pick local values that were copied\n # # * when missing?, pick from device_model_prices\n # unless (order.blank? || order.product_cost.blank? || _date.blank?)\n # _date += ( order.cc_monthly_recurring || order.product_cost.recurring_delay).to_i.months\n # end\n # # \n # # Tue May 24 20:07:41 IST 2011, ramonrails\n # # * https://redmine.corp.halomonitor.com/issues/4486\n # # * https://redmine.corp.halomonitor.com/attachments/3294/invalid_prorate_start_dates.jpg\n # _date ||= Date.today\n # _date = Date.today if _date > Date.today\n # \n # Thu May 26 19:32:15 IST 2011, ramonrails\n # * https://redmine.corp.halomonitor.com/issues/4486#note-47\n _date = _date.to_date unless _date.blank?\n _date\n end", "def payment\n order.credit_card || payment_empty\n end", "def apply_payment_method\n payment_method_array = @payment_method.get_payment_methods_by_customer_id(@active_customer[0])\n # puts \"payment_method_array: #{payment_method_array}\"\n if payment_method_array.length != 0\n puts \"Choose a payment method\"\n count = 1\n payment_hash = Hash.new\n payment_method_array.each do |payment|\n puts \"#{count}. #{payment[2]} - Account: #{payment[3]}\"\n payment_hash[count] = payment\n count += 1\n end\n puts \" \"\n user_input = gets.chomp\n payment_hash.each do |key, val|\n if user_input.to_s == key.to_s\n puts \"Do you want to use #{val[2]}? (y/n)\"\n next_user_input = gets.chomp\n if next_user_input.downcase.to_s == \"y\"\n @order.close_order(val[0],@order_status)\n puts \" \"\n puts \"Success! Payment added and order completed\"\n puts \" \"\n puts \"Press any key to return to main menu.\"\n puts \" \"\n gets.chomp\n else\n puts \"Do you want to use another payment method? (y/n)\"\n another_payment_input = gets.chomp\n if another_payment_input.downcase.to_s == \"y\"\n apply_payment_method\n else\n puts \" \"\n puts \"Payment cancelled. Press any key to return to main menu.\"\n puts \" \"\n gets.chomp\n end\n end\n end\n end\n else\n # if user has no payment method, it prompts them to add one\n puts \" \"\n puts \"Please add a payment method to customer's account. Press any key to return to main menu.\"\n puts \" \"\n gets.chomp\n end\n end", "def paid_until\n last_payment&.end_date\n end", "def create_co_and_payment(company_number, payment_exp_date, member_pay_expires: Time.zone.today + 1.year, payment_create_date: Time.zone.now)\n\n u = create(:member_with_membership_app, company_number: company_number)\n u.shf_application.update(created_at: payment_create_date, updated_at: payment_create_date)\n\n co = u.shf_application.companies.first\n\n create(:payment,\n user: u,\n payment_type: Payment::PAYMENT_TYPE_MEMBER,\n status: SUCCESSFUL_PAYMENT,\n expire_date: member_pay_expires,\n created_at: payment_create_date,\n updated_at: payment_create_date)\n\n branding_payment = create(:payment,\n user: u,\n payment_type: Payment::PAYMENT_TYPE_BRANDING,\n status: SUCCESSFUL_PAYMENT,\n expire_date: payment_exp_date,\n created_at: payment_create_date,\n updated_at: payment_create_date)\n\n co.payments << branding_payment\n co\n end", "def make_payement(amount)\n if amount\n @paid_amount = amount\n end\n end", "def create\n\t\t# @payment = Payment.new({\n\t\t# :intent => \"sale\",\n\t\t# :payer => {\n\t\t# :payment_method => \"credit_card\",\n\t\t# :funding_instruments => [{\n\t\t# :credit_card => {\n\t\t# \t:type => params[:payment][:card_type], #\"visa\",\n\t\t# :number => params[:payment][:card_number], #\"4242424242424242\",\n\t\t# :expire_month => params[:payment][\"card_expires_on(2i)\"], #\"1\",\n\t\t# :expire_year => params[:payment][\"card_expires_on(1i)\"], #\"2018\",\n\t\t# :cvv2 => params[:payment][:cvv2], #\"874\",\n\t\t# :first_name => params[:payment][:first_name], #\"Joe\",\n\t\t# :last_name => params[:payment][:last_name], #\"Shopper\",\n\t\t# :billing_address => {\n\t\t# :line1 => params[:payment][:address], #\"52 N Main ST\",\n\t\t# :city => params[:payment][:city], #\"Johnstown\",\n\t\t# :state => params[:payment][:state], #\"OH\",\n\t\t# :postal_code => params[:payment][:postal_code], #\"43210\",\n\t\t# :country_code => params[:payment][:country_code] #\"US\" \n\t\t# }}}]},\n\t\t# :transactions => [{\n\t\t# :amount => {\n\t\t# :total => \"10.00\",\n\t\t# :currency => \"USD\" },\n\t\t# :description => \"This is the payment transaction description.\" }]})\n\n\t\t# @payment.create\n\t\t# if @payment.id.nil?\n\t\t# \terror = @payment.error\n\t\t# \tredirect_to payment_index_url, :alert => error.name+\"\\n\"+error.details.to_s\n\t\t# else\n\t\t# \tparams[:payment][:transaction_id] = @payment.id\n\t\t# \tparams[:payment][:amount] = 10\n\t\t# \t@data = current_user.build_payment(payment_params)\n\t\t# \tif @data.save\n\t\t# \t\tredirect_to payment_index_url, :notice => \"Payment Done with payment id #{@payment.id}\"\n\t\t# \telse\n\t\t# \t\tredirect_to payment_index_url, :alert => \"Something went wrong.\"\n\t\t# \tend\n\t\t# end\n\tend", "def shipping_charges_payment\n {'PaymentType' => payment_type,\n 'Payor' => {'AccountNumber' => @model.payor_account_number},\n :order! => ['PaymentType', 'Payor']}\n end", "def make_the_payment\n\n session[:purchasable] = nil\n if @order and @order.invoices.last\n @invoice = @order.generate_invoice_extra_entry(@current_user, params[:invoicing_info])\n else\n @invoice = @order.generate_invoice(@current_user, params[:invoicing_info]) \n end \t\n\n if params[:invoicing_info][:payment_medium] == \"cash\" or params[:invoicing_info][:payment_medium] == \"cheque\" or params[:invoicing_info][:payment_medium] == \"direct deposit\"\n @invoice.accept_cash_or_cheque_or_bank_payment(params[:invoicing_info][:payment_medium]) \n elsif params[:invoicing_info][:payment_medium] == \"paypal\"\n @invoice.validating(\"paypal\")\n else\n @invoice.validating\n end \t\n @current_object.invoice = @invoice\n @current_object.save\n invoice = Invoice.find(:last,:conditions=>[\"client_id = ? and purchasable_id = ?\",@current_user.id,@order.id])\n if @order.instance_of? CompetitionsUser\n note = \"no notes created\"\n note = @order.competition.timing.note if @order.competition.timing\n start_date = @order.competition.timing.starting_date.strftime(\"%d %b %Y\")\n end_date = @order.competition.timing.ending_date.strftime(\"%d %b %Y\")\n if params[:invoicing_info][:payment_medium] == \"cash\" or params[:invoicing_info][:payment_medium] == \"cheque\" or params[:invoicing_info][:payment_medium] == \"direct deposit\"\n if invoice\n\n p \"fdfgffggfdgfgd\"\n\n \n p \"i got the invoice and creating pdf\"\n\n create_pdf(invoice.id,invoice.number,start_date,invoice.client.profile.full_address_for_invoice,invoice.client.profile.full_name_for_invoice,@order.competition.title,invoice.final_amount.to_i,note,invoice.final_amount.to_i,0,false,end_date)\n end \n else\n create_pdf(invoice.id,invoice.number,invoice.sent_at.strftime(\"%d %b %Y\"),invoice.client.profile.full_address_for_invoice,invoice.client.profile.full_name_for_invoice,@order.competition.title,invoice.final_amount.to_i,note,\"\",invoice.final_amount.to_i,false,end_date)\n end\n elsif @order.instance_of? ExhibitionsUser\n note = \"no notes created\"\n note = @order.exhibition.timing.note if @order.exhibition.timing\n create_pdf(invoice.id,invoice.number,invoice.sent_at.strftime(\"%d %b %Y\"),invoice.client.profile.full_address_for_invoice,invoice.client.profile.full_name_for_invoice,@order.exhibition.title,invoice.final_amount.to_i,note)\n end\n #QueuedMail.add('UserMailer', 'send_invoice',[@invoice,@current_user], 0, send_now=true)\t\n #QueuedMail.create(:mailer => 'UserMailer', :mailer_method => 'send_invoice',:args => [@current_user.profile.email_address,\"invoice#{invoice.id}\",\"An Invoice Is Send To Your Email For Your Payment\"],:priority => 0,:tomail=>@current_user.profile.email_address,:frommail=>\"test@pragtech.co.in\")\n begin\n\n # email= UserMailer.create_send_invoice(invoice,@current_user)\n # UserMailer.deliver(email)\n\n p \"sending the emaillll\"\n email= UserMailer.create_send_invoice(invoice,@current_user)\n #UserMailer.deliver(email)\n\n rescue\n end\n session[:total_entry] = nil \n if @invoice.purchasable_type == \"Order\"\n session[:cart]=nil\n end\n end", "def preview_payment\n #just check an dates\n #check dummy\n @roombarname = []\n @respartner = ResPartner.find(session[:user_id_avail])\n @resname = @respartner.name\n checkindate = DateTime.new(session[:checkin].split(' ')[0].to_s.split('/')[2].to_i,session[:checkin].split(' ')[0].to_s.split('/')[0].to_i,session[:checkin].split(' ')[0].to_s.split('/')[1].to_i,session[:checkin].split(' ')[1].to_s.split(':')[0].to_i,session[:checkin].split(' ')[1].to_s.split(':')[1].to_i )\n checkoutdate = DateTime.new(session[:checkout].split(' ')[0].to_s.split('/')[2].to_i,session[:checkout].split(' ')[0].to_s.split('/')[0].to_i,session[:checkout].split(' ')[0].to_s.split('/')[1].to_i,session[:checkout].split(' ')[1].to_s.split(':')[0].to_i,session[:checkout].split(' ')[1].to_s.split(':')[1].to_i )\n session[:amount] = nil\n if session[:checkin].blank?\n redirect_to root_url ,:notice=>'Your Session Is Expired Please Select Room Again' and return;\n end\n if session[\"selectedroom\"]\n session[\"selectedroom\"].each do |roomid|\n pr = ProductProduct.find(roomid[0].to_i)\n @roombarname << pr.name\n price = pr.product_tmpl_id.list_price.to_f\n cknp = CheckoutConfiguration.find(:all,:domain=>[['shop_id','=',1]]).first.name\n if cknp == \"24hour\"\n #here i am copying checkin and checkout variables so that it will not make any conflict in its current flow\n checkindfortd = checkindate\n checkoutdfortd = checkoutdate\n while checkindfortd < checkoutdfortd\n session[:amount] = session[:amount].to_i + price.to_i\n checkindfortd = checkindfortd.next_day\n end\n else\n if ((checkoutdate - checkindate).to_i == 0)\n session[:amount] = session[:amount].to_i + price.to_i\n else\n session[:amount] = session[:amount].to_i + (price.to_i * (checkoutdate - checkindate).to_i )\n end\n end\n end\n end\n @currencyname = \"USD\"\n if ResCurrency.find(:all,:domain=>[['base','=',true]])[0]\n @currencyname = ResCurrency.find(:all,:domain=>[['base','=',true]])[0].name\n end\n available_paypal_array = [\"AUD\",\"CAD\",\"CZK\",\"DKK\",\"EUR\",\"HKD\",\"HUF\",\"JPY\",\"NOK\",\"NZD\",\"PLN\",\"GBP\",\"SGD\",\"SEK\",\"CHF\"]\n if available_paypal_array.include?(@currencyname)\n elsif @currencyname == \"USD\"\n else\n usdr = ResCurrency.find(:all,:domain=>[['name','=','USD' ]])[0]\n @convert_amount = session[:amount].to_i * usdr.rate\n end\n end", "def payment_params\n params.fetch(:payment, {}).permit(\n :effect,\n :description, \n :due_date,\n :due_value,\n :payment_date,\n :payment_value,\n :interest_value,\n :penalty_value,\n :discount_value,\n :payable_id,\n :payable_type\n )\n end", "def last_active_recurring_product_subscription_term_period_end_on\n if order = self.last_active_recurring_order\n order.created_at.to_date + last_active_recurring_product_subscription.term_in_days\n end\n end", "def payment\n {\n :credit_card => credit_card\n }\n end", "def servicetax\n if (self.orderid).present?\n servicetax = 0\n if self.product_master.sel_s_tax.blank? || self.product_master.sel_s_tax == 1\n\n servicetaxid = 10040\n servicetaxrate = Orderpaymentmode.find(servicetaxid).charges\n\n maharastracodextraid = 10020\n maharastracodextrarate = Orderpaymentmode.find(maharastracodextraid).charges\n\n maharastracodextracharge = self.total * maharastracodextrarate\n\n cashondeliveryid = 10001\n cashondeliveryrate = Orderpaymentmode.find(cashondeliveryid).charges\n cashondeliverycharge = self.total * cashondeliveryrate\n\n\n\n #add all charges\n servicetax = ((maharastracodextracharge || 0) + (cashondeliverycharge || 0)) * (servicetaxrate || 0)\n\n #check if address is selected\n if self.order_master.customer_address_id.present?\n #check if state is maharastra\n if self.order_master.customer_address.state.upcase == 'MAHARASHTRA'\n\n servicetax = ((maharastracodextracharge || 0) + (cashondeliverycharge || 0)) * (servicetaxrate || 0)\n else\n servicetax = (cashondeliverycharge || 0) * (servicetaxrate || 0)\n\n\n end\n end\n\n #check if paid using credit card is selected\n if self.order_master.orderpaymentmode_id.present?\n if self.order_master.orderpaymentmode_id == 10000\n return 0\n end\n end\n\n end\n\n end\n\n return servicetax.round(2)\nend", "def anticipated_fixed_payment(present_value, rate, term)\n\t\t((present_value.to_f) / ((1 - (1 - rate.to_f ) ** term ) / rate.to_f )).round(4)\n end", "def create_invoice(payment)\n logger.debug \"\\n----------- KlarnaPayment.create_invoice -----------\\n\"\n \n # Initialize Klarna connection\n init_klarna(payment)\n \n #ssn = \"411028-8083\" # Not approved\n #ssn = \"410321-9202\" # Approved\n \n ssn = self.social_security_number\n\n # Implement verification to Klarna to get secret\n sso_secret = @@klarna.send(:digest, payment.payment_method.preferred(:store_id), ssn, payment.payment_method.preferred(:store_secret))\n logger.debug \"\\n----------- SSO Secret #{sso_secret} for #{ssn} -----------\\n\"\n order_items = []\n \n payment_amount = 0\n \n default_tax_rate = Spree::TaxRate.find(1)\n \n # Add products\n payment.order.line_items.each do |item|\n logger.debug \"\\n----------- Item: #{item.quantity}, #{item.product.sku}, #{item.product.name}, #{item.price} -----------\\n\"\n flags = {}\n flags[:INC_VAT] = ::Klarna::API::GOODS[:INC_VAT] if default_tax_rate.included_in_price\n order_items << @@klarna.make_goods(item.quantity, item.product.sku, item.product.name, item.price * 100.00, default_tax_rate.amount*100, nil, flags)\n \n if ! default_tax_rate.included_in_price\n item.price = item.price * (default_tax_rate.amount + 1)\n end\n \n payment_amount += item.price * item.quantity\n end\n \n payment.order.adjustments.eligible.each do |adjustment|\n next if (adjustment.originator_type == 'Spree::TaxRate') or (adjustment.amount === 0)\n \n flags = {}\n flags[:INC_VAT] = ::Klarna::API::GOODS[:INC_VAT] if default_tax_rate.included_in_price\n flags[:IS_HANDLING] = ::Klarna::API::GOODS[:IS_HANDLING] if adjustment.label == I18n.t(:invoice_fee)\n flags[:IS_SHIPMENT] = ::Klarna::API::GOODS[:IS_SHIPMENT] if adjustment.originator_type == 'Spree::ShippingMethod'\n amount = 100 * adjustment.amount\n order_items << @@klarna.make_goods(1, '', adjustment.label, amount, default_tax_rate.amount * 100, nil, flags)\n \n if ! default_tax_rate.included_in_price\n adjustment.amount = adjustment.amount * (default_tax_rate.amount + 1)\n end\n \n payment_amount += adjustment.amount\n logger.info \"\\n----------- Order: #{payment.order.number} (#{payment.order.id}) | payment_amount: #{payment_amount} -----------\\n\" \n end\n \n # Create address\n address = @@klarna.make_address(\"\", payment.order.bill_address.address1, payment.order.bill_address.zipcode.delete(' ').to_i, payment.order.bill_address.city, payment.order.bill_address.country.iso, payment.order.bill_address.phone, nil, payment.order.email)\n\n # Do transaction and create invoice in Klarna\n begin\n logger.debug \"\\n----------- add_transaction -----------\\n\"\n \n #shipping_cost = payment.order.ship_total * 100\n #shipping_cost = shipping_cost * (1 + Spree::TaxRate.default) if Spree::Config[:shipment_inc_vat]\n \n # Client IP\n client_ip = payment.payment_method.preferred(:mode) == \"test\" ? \"85.230.98.196\" : payment.source.client_ip\n \n # Set ready date\n ready_date = payment.payment_method.preferred(:activate_in_days) > 0 ? (DateTime.now.to_date + payment.payment_method.preferred(:activate_in_days)).to_s : nil\n \n # Set flags\n flags = {}\n flags[:TEST_MODE] = TRUE unless payment.payment_method.preferred(:mode) == \"production\"\n flags[:AUTO_ACTIVATE] = TRUE if payment.payment_method.preferred(:auto_activate)\n \n # Debug output\n # logger.debug \"\\n----------- add_transaction - Shipping: #{shipping_cost.to_i} -----------\\n\"\n logger.debug \"\\n----------- add_transaction - Ready date: #{ready_date} -----------\\n\"\n logger.debug \"\\n----------- add_transaction - Flags: #{flags} -----------\\n\"\n logger.debug \"\\n----------- add_transaction - Client IP: #{payment.source.client_ip} -----------\\n\"\n \n invoice_no = @@klarna.add_transaction(\n \"USER-#{payment.order.user_id}\", # store_user_id,\n payment.order.number, # order_id,\n order_items, # articles,\n 0, # shipping_fee,\n 0, # handling_fee,\n :NORMAL, # shipment_type,\n ssn, # pno,\n (payment.order.bill_address.company.blank? ? payment.order.bill_address.firstname.encode(\"iso-8859-1\") : payment.order.bill_address.company.encode(\"iso-8859-1\")), # first_name,\n payment.order.bill_address.lastname.encode(\"iso-8859-1\"), # last_name,\n address, # address,\n client_ip, # client_ip,\n payment.payment_method.preferred(:currency_code), # currency, \n payment.payment_method.preferred(:country_code), # country, \n payment.payment_method.preferred(:language_code), # language, \n payment.payment_method.preferred(:country_code), # pno_encoding, \n nil, # pclass = nil,\n nil, # annual_salary = nil, \n nil, # password = nil,\n ready_date, # ready_date = nil,\n nil, # comment = nil, \n nil, # rand_string = nil, \n flags) # flags = nil\n \n logger.info \"\\n----------- Order: #{payment.order.number} (#{payment.order.id}) | Invoice: #{invoice_no} -----------\\n\" \n logger.info \"\\n----------- Order: #{payment.order.number} (#{payment.order.id}) | payment_amount: #{payment_amount} -----------\\n\" \n self.update_attribute(:invoice_number, invoice_no)\n payment.update_attribute(:amount, payment_amount)\n \n rescue ::Klarna::API::Errors::KlarnaServiceError => e\n payment.order.set_error e.error_message\n gateway_error(e.error_message)\n end\n end", "def transaction_filter_by_date\n @start_date, @end_date = params[:s_date], params[:e_date]\n all_fee_types = ['HostelFee', 'TransportFee', 'FinanceFee', 'Refund', 'BookMovement', 'InstantFee']\n salary = FinanceTransaction.get_transaction_category('Salary')\n joins = \"\"\n if params['transaction_type'] == t('advance_fees_text')\n @transactions = CancelledAdvanceFeeTransaction.paginate(:page => params[:page], :per_page => 20, \n :order => \"cancelled_advance_fee_transactions.created_at desc\",\n :joins => [:student, :transaction_receipt], \n :conditions => ['cancelled_advance_fee_transactions.created_at BETWEEN ? AND ?', @start_date, @end_date.to_date+1.day], \n :select => \"concat(students.first_name, ' ', students.middle_name, ' ', students.last_name) as payee_name, transaction_receipts.ef_receipt_number as receipt_no, 'Advance Fees' as finance_type, \n cancelled_advance_fee_transactions.fees_paid as amount, cancelled_advance_fee_transactions.user_id as user_id, cancelled_advance_fee_transactions.reason_for_cancel as cancel_reason, cancelled_advance_fee_transactions.created_at\")\n else\n if params['transaction_type'].present? and params['transaction_type'] == t('others')\n conditions = \"and (collection_name is null or finance_type not in (?)) and category_id <> ?\"\n elsif params['transaction_type'].present? and params['transaction_type'] == t('payslips')\n conditions = \"and (collection_name is null or finance_type not in (?)) and category_id = ?\"\n else\n joins = \"LEFT JOIN fee_accounts fa ON fa.id = ftrr.fee_account_id\"\n conditions = \"and (fa.id IS NULL OR fa.is_deleted = false) AND (collection_name is not null or finance_type in (?)) and category_id <> ?\"\n end\n \n @transactions = CancelledFinanceTransaction.paginate(:page => params[:page],\n :per_page => 20, :order => 'cancelled_finance_transactions.created_at desc',\n :select => \"cancelled_finance_transactions.*,\n IFNULL(CONCAT(IFNULL(tr.receipt_sequence, ''), tr.receipt_number), '-') AS receipt_no\",\n :joins => \"LEFT JOIN finance_transaction_receipt_records ftrr\n ON ftrr.finance_transaction_id = cancelled_finance_transactions.finance_transaction_id\n LEFT JOIN transaction_receipts tr ON tr.id = ftrr.transaction_receipt_id #{joins}\",\n :conditions => [\"cancelled_finance_transactions.created_at BETWEEN ? AND ?\n #{conditions}\", @start_date, @end_date, all_fee_types, salary])\n end\n render :update do |page|\n page.replace_html 'search_div', :partial => \"finance/search_by_date_deleted_transactions\"\n end\n end", "def acerto_forn\n \n #é obrigátorio informar o fornecedor\n if params[:supplier].blank? || params[:date1].blank? || params[:date2].blank?\n flash[:warning] = 'Você precisa selecionar o Fornecedor, informar o periodo e consultar para poder efetivar a baixa em seguida!'\n redirect_to payments_path and return\n end\n \n #verifica se foi selecionado contas já PAGAS, se sim, não faz o acerto pra não mexer em baixas já feitas\n if params[:tipo_consulta] == 'PAGA' || params[:tipo_consulta].blank?\n flash[:warning] = 'Você não pode fazer acerto de fornecedor sem selecionar a opção CONTAS Á PAGAR, verifique os dados!'\n redirect_to payments_path and return\n end\n \n @check_payment = HeaderInput.where(supplier_id: params[:supplier]).where(status: 'Á PAGAR').where('created_at::Date Between ? and ?', params[:date1],params[:date2]).count\n if @check_payment >= 1\n #atualizo para RECEBIDA todas as entradas com base no periodo informado\n HeaderInput.where(supplier_id: params[:supplier]).where(status: 'Á PAGAR').where('created_at::Date Between ? and ?', params[:date1],params[:date2]).update_all(status: 'PAGA') \n #atualizando todas as contas a receber do cliente informado e no periodo informado\n Payment.where(supplier_id: params[:supplier]).where(status: 'Á PAGAR').where('created_at::Date Between ? and ?', params[:date1],params[:date2]).update_all(status: 'PAGA', payment_date: Date.today) \n \n flash[:success] = 'Acerto realizado com sucesso!'\n redirect_to payments_path and return\n else\n flash[:warning] = 'Não existem dados para serem baixados!'\n redirect_to payments_path and return \n end \n \n end", "def create\n \n #viewで分解されたパラメータを、正常更新できるように復元させる。\n adjust_purchase_date_params\n\t \n #登録済みフラグをセット(伝票重複防止のため)\n #add180223\n get_registerd_flag_param\n \n\t@purchase_datum = PurchaseDatum.new(purchase_datum_params)\n \n \n #仕入単価を更新\n #if (params[:purchase_datum][:unit_price_not_update_flag] == '0')\n # #仕入先単価マスターへの新規追加又は更新\n\t# create_or_update_purchase_unit_prices\n\t# #資材Mも更新\n # update_params_list_price_and_maker\n\t# @purchase_datum.update_attributes(material_masters_params)\n\t#else\n\t# #資材マスターのみへの更新\n\t# #手入力のマスター反映(資材マスターのみ)\n # add_manual_input_except_unit_price\n #end \n #資材マスターへ品名などを反映させる処理(手入力&入出庫以外)\n\t#update_material_master\n\t#upd180627\n #資材マスターの分類を更新\n #update_material_category\n \n #add190124\n #外注の場合に請求用の外注費をセット\n \n #外注請求書を発行した場合にONになるが、この判定は不要と思われるので抹消する(200124)\n #outsourcing_invoice_flag = false\n #if params[:purchase_datum][:outsourcing_invoice_flag] == \"1\" \n \n outsourcing_invoice_flag = true\n @ajax_flag = false\n set_default_outsourcing_data #外注費データの初期値をセット\n #支払予定日を仕入データへもセットする\n @purchase_datum.payment_due_date = @payment_due_date\n @purchase_datum.closing_date = @closing_date #add210301\n \n #add200925\n #仕入日=作業完了日とする\n if @purchase_date.present?\n @purchase_datum.purchase_date = @purchase_date\n end\n \n \n respond_to do |format|\n \n \n #外注請求のチェック有りの場合は、ヴァリデーションを無効にする\n save_check = false\n #if outsourcing_invoice_flag == false\n # save_check = @purchase_datum.save\n #else\n \n #if request.format.symbol != :pdf #del200721 pdfでも保存する\n #ヴァリデーションを無効にする\n #確定申告などで編集する場合を考慮。\n save_check = @purchase_datum.save!(:validate => false)\n \n #else\n # save_check = true\n #end\n #end\n #\n \n\t #if @purchase_datum.save\n if save_check\n #add190125\n #外注用の請求書発行\n print_outsourcing_invoice(format)\n \n #伝票が重複しないように登録フラグをセット\n set_registerd_flag_to_headers\n \n #入出庫の場合は、在庫履歴データ、在庫マスターへも登録する。\n #moved180407\n trans = InventoriesController.set_inventory_history(params, @purchase_datum)\n\t\tif trans == \"new_inventory\"\n flash[:notice] = \"在庫マスターへ新規登録しました。資材マスターの在庫区分・在庫マスターの画像を登録してください。\"\n end\n \n #add200124\n #資金繰のデータへセット\n set_cash_flow = SetCashFlow.new\n set_cash_flow.set_cash_flow_detail_expected_for_outsourcing(params, @payment_due_date)\n #\n \n #if request.format.symbol == :pdf\n # redirect_to outsourcing_datum_path(@purchase_datum) and return\n #else\n format.html {redirect_to outsourcing_datum_path(@purchase_datum, :construction_id => params[:construction_id], \n :purchase_order_id => params[:purchase_order_id], :supplier_master_id => params[:supplier_master_id],\n :move_flag => params[:move_flag])}\n\t\t#end\n \n \n #format.html {redirect_to purchase_datum_path(@purchase_datum, :construction_id => params[:construction_id],\n \n #binding.pry\n #format.html { redirect_to controller: 'users', action: 'show', id: 8}\n #format.html { redirect_to controller: 'outsourcing_data', action: 'show', id: @purchase_datum.id}\n \n \n #入出庫の場合は、在庫履歴データ、在庫マスターへも登録する。\n #InventoriesController.set_inventory_history(params, @purchase_datum)\n\n else\n format.html { render :new }\n format.json { render json: @purchase_datum.errors, status: :unprocessable_entity }\n end\n\n \n end\n end", "def service_payment_information\n service_payment_elements =[]\n service_payment_elements << 'SVC'\n service_payment_elements << composite_med_proc_id\n service_payment_elements << service.amount('service_procedure_charge_amount')\n service_payment_elements << service.amount('service_paid_amount')\n service_payment_elements << revenue_code\n service_payment_elements.join(@element_seperator )\n end", "def payment_price_tax\n\t\t\t\t\treturn nil\n\t\t\t\tend", "def payment_params\n params.require(:payment).permit(:user_transaction_id, :programmed_date, :done_date, :amount, :confirm_payer, :confirm_payee)\n end", "def payment_params\n params[:payment]\n end", "def create_tax_charge!\n #puts \"Adjustments #{adjustments} TAX #{tax_total}\"\n #puts \"CREATE TAX for #{ship_address} \"\n all_rates = Spree::TaxRate.all\n matching_rates = all_rates.select { |rate| rate.zone.include?(ship_address) }\n if matching_rates.empty?\n matching_rates = all_rates.select{|rate| # get all rates that apply to default country \n rate.zone.country_list.collect{|c| c.id}.include?(Spree::Config[:default_country_id])\n }\n end\n adjustments.where(:originator_type => \"TaxRate\").each do |old_charge|\n old_charge.destroy\n end\n matching_rates.each do |rate|\n #puts \"Creating rate #{rate.amount}\" \n rate.create_adjustment( rate.tax_category.description , self, self, true)\n end\n end", "def create_payment_profile_entry(project, scheduled_days, start_period, end_period, created_payment_profiles)\n if scheduled_days > 0\n new_payment_profile = project.payment_profiles.new\n new_payment_profile.attributes = {\n :name => \"#{start_period.strftime(\"%d %b %Y\")} - #{end_period.strftime(\"%d %b %Y\")}\", \n :expected_payment_date => end_period, \n :generate_cost_from_time => true, \n :expected_days => scheduled_days\n }\n \n if new_payment_profile.save\n \n # Add service types too (Taken from project level) \n # if project.rate_card_projects.present?\n # project.rate_card_projects.each do |rate_card_project|\n # new_payment_profile.rate_card_payment_profiles.new(:rate_card_id => rate_card_project.rate_card_id, :percentage => rate_card_project.percentage)\n # end\n # new_payment_profile.save!\n # end\n \n # Add to return array\n created_payment_profiles << new_payment_profile\n end\n end\n created_payment_profiles\n end", "def payment_params\n params.require(:payment).permit(:amount, :refund_amount, :description, :method, :card_id, :scheduled_for)\n end", "def get_confirmed_payments(options_hash = {})\n query_info = options_hash[:query_info].nil? ? nil : options_hash[:query_info]\n # form can be... :technical_payments, :confirmed_payments\n form = options_hash[:form].nil? ? :confirmed_payments : options_hash[:form]\n \n return self.bitcoin_payments.map{|x| x.value}.sum if we_looked_up_blockchain_info_recently?\n \n \n checkout_wallet_info, latest_block = query_blockchain_for_new_payments_to_checkout_wallet(self.checkout_wallet.input_address, query_info)\n self.checkout_wallet.update_attributes(:last_successful_manual_lookup => Time.zone.now)\n self.checkout_wallet.calculate_if_payment_complete\n \n if checkout_wallet_info.nil?\n Message.emergency(\"a query_blockchain_for_new_payments_to_checkout_wallet returned a nil checkout_wallet_info somehow\", \n \"#{__FILE__}:#{__LINE__} \\n input_address#{self.checkout_wallet.input_address}\")\n return self.bitcoin_payments.map{|x| x.value}.sum\n end\n \n \n \n \n latest_height = latest_block['height']\n txs = checkout_wallet_info['txs']\n \n \n case form\n when :confirmed_payments\n correct_destination_values = self.bitcoin_payments.map{|x| x.value}.sum\n correct_destination_values += check_txs_for_unrecorded_properly_destined_values(txs, latest_height)\n when :technical_payments\n correct_destination_values = self.technical_bitcoin_payments.map{|x| x.value}.sum\n correct_destination_values += check_txs_just_to_see_that_payments_came_into_them(txs, latest_height)\n end\n \n correct_destination_values\n end", "def new\n @customer_payment = CustomerPayment.new\n @invoice = Invoice.unimported\n @customer_payment.cust_payment_date = Date.today\n @customer_payment.save!\n redirect_to edit_customer_payment_path(@customer_payment)\n \n \n end", "def add_payment(post, payment)\n case payment\n when String\n post[:token] = payment\n when CreditCard\n post[:creditCard] = payment.number\n post[:creditCardDateMmyy] = expdate(payment)\n post[:cvv2] = payment.verification_value\n end\n end", "def guard_process_payment_from_created; true; end", "def guard_process_payment_from_created; true; end", "def receipt_period_params\n params.require(:receipt_period).permit(:start_date, :end_date, :accompliched, :user_id)\n end", "def daily_data_payment_params\n params.require(:daily_data_payment).permit(:date, :student_id, :amount, :payment_type, :partial_payment, :referral_source, :student_action, :notes, :rate, :hours)\n end", "def additional_payment_params\n params.require(:additional_payment).permit(:category, :description, :charitable_donation, :market_price,\n :payment_price, :payment_amount, :payment_id, :payment_date,\n :user_event_id)\n end", "def get_recent_financial_info(start_date, end_date)\n recent_payments[Payment::PAYMENT_TYPE_MEMBER.to_sym] = Payment.member_fee.updated_in_date_range(start_date, end_date) # Payment.member_fee.where(status: 'betald', updated_at: start_date..end_date)\n recent_payments[Payment::PAYMENT_TYPE_BRANDING.to_sym] = Payment.branding_fee.updated_in_date_range(start_date, end_date) # where(status: 'betald', updated_at: start_date..end_date)\n\n recent_payments # return this to make testing easier\n end", "def valitation\n # Create a payment and send ID\n end", "def print_receipt_for(payment)\n @data.payment = payment\n @data.invoice = Invoice.create_for_payment(payment, Invoice::RECEIPT_TYPE)\n print_common\n end", "def payment_data(period_data = 'this_month')\n res = payments.completed\n range, daily_report = period_data.to_s.report_period_to_range\n data = [[period_data.to_s.report_period_to_title] + UserGroup::PAYMENT_GOALS.values]\n range.each do |d| \n r = [d.beginning_of_day, (daily_report ? d.end_of_day : d.end_of_month.end_of_day)]\n d = [d.strftime(daily_report ? '%d' : '%Y-%m')]\n UserGroup::PAYMENT_GOALS.each{|k, v| d << res.where(payment_at: r[0]..r[1], goal: k).sum(:amount).to_f }\n data << d\n end\n data\n end", "def pay_agreement_params\n params.require(:pay_agreement).permit(:fee_id, :user_registration_id,\n :discount, :discount_in_percent, :comment, :slug, :version, { details: [:information]})\n end", "def pay!\n #soap_server = VendorPayment.generate_soap_server\n #token = VendorPayment.generate_usa_epay_security_token\n #custNum = observed.vendor_payment_period.store.id\n #paymentMethodID = nil\n #parameters = generate_transaction_request\n #response = soap_server.runCustomerTransaction(token, custNum, paymentMethodID, parameters)\n #\n if self.vendor_payment_period.store.usa_epay_customer_number.blank?\n self.errors['usa_epay_customer_number'] = \"The USA ePay custNum must be set before a payment can be made.\"\n return\n end\n gateway = VendorPayment.gateway\n payment_methods_response = gateway.get_customer_payment_methods(:customer_number => self.vendor_payment_period.store.usa_epay_customer_number)\n monthly_transfer_method = nil\n items = if payment_methods_response.params['get_customer_payment_methods_return']\n payment_methods_response.params['get_customer_payment_methods_return']['item']\n else\n []\n end\n \n if items.is_a?(Hash)\n items = [items]\n end\n \n items.each do |payment_method|\n if payment_method['method_name'].strip == 'Monthly ACH Transfer'\n monthly_transfer_method = payment_method\n end\n end\n \n if monthly_transfer_method\n response = gateway.run_customer_transaction(:customer_number => self.vendor_payment_period.store.usa_epay_customer_number,\n :command => 'CheckCredit',\n # USA ePay does pennies for the amount, so it needs to be\n # multiplied by 100\n :payment_method_id => monthly_transfer_method['method_id'],\n :amount => self.amount * 100)\n \n \n self.state = if response.message['result_code'].strip == 'A'\n VendorPayment.status_codes[response.message['status_code']]\n else\n VendorPayment.status_codes[\"E\"]\n end\n self.response_data = YAML::dump(response)\n if !response.message['ref_num'].blank?\n self.response_code = response.message['ref_num']\n save\n else\n save\n self.errors['transaction'] = \"State: #{self.state}. There was an error with code #{response.message['error_code']}, while trying to make the payment. Check USA ePay for reference number #{response.message['ref_num']} if necessary.\\n\\nFull Message: #{response.message.inspect}\"\n end\n self.vendor_payment_period.update_payment_total!\n self.vendor_payment_period.update_state!\n else\n self.errors['payment_method'] = \"There is no payment method on the vendor called 'Monthly ACH Transfer'\"\n end\n end", "def process(txn, merchant_id, merchant_key)\n # Rails treats any blank field (x=\"\") as false (x=false), so any parameter that we wish to treat as optional\n # needs to be given a default value of \"\" here.\n optional = [:shipping]\n optional.each { |key| txn[key] ||= \"\" } # if it has a nil or false value, give it \"\" instead.\n\n=begin\n 1. ICT 220 – B&W IP Incendo Terminal\n APPID: INGETERMICT2200COUNAAE8USEN\n\n 2. ICT 250 – Color Incendo Terminal\n APPID: INGETERMICT2500COUNAAE9USEN\n=end\n\n @t_device_id = txn[:itid]\n\n case txn[:model]\n when 'ICT220' then @t_application_id = \"INGETERMICT2200COUNAAE8USEN\"\n when 'ICT250' then @t_application_id = \"INGETERMICT2500COUNAAE9USEN\"\n end\n\n\n\n\n\n # Kalopsia expects dates to be Date objects, but they might be Strings.\n dates = [:card_expiry_date, :start_date, :end_date]\n dates.each do |date_key|\n if txn[date_key].kind_of?(String)\n txn[date_key] = DateTime.parse(txn[date_key])\n end\n end\n\n actions = %w(sale sale_return pre_auth post_pre_auth force_sale void void_by_ton settlement batch_inquiry view_detail view_open view_settled)\n case txn[:action]\n when 'sale'\n case txn[:card_mode]\n when 'debit' then do_debit_sale(txn, merchant_id, merchant_key )\n when 'credit' then do_credit_sale(txn, merchant_id, merchant_key)\n else raise \"invalid card mode: #{txn[:card_mode]} (expected one of 'debit', 'credit')\"\n end\n when 'sale_return' then do_sale_return(txn, merchant_id, merchant_key)\n when 'pre_auth' then do_pre_auth(txn, merchant_id, merchant_key)\n when 'post_pre_auth' then do_post_pre_auth_http(txn, merchant_id, merchant_key)\n when \"force_sale\" then do_force_sale(txn, merchant_id, merchant_key)\n when \"void\" then do_void(txn, merchant_id, merchant_key)\n when \"void_by_ton\" then do_void_by_ton(txn, merchant_id, merchant_key)\n when \"settlement\" then do_settlement(txn, merchant_id, merchant_key)\n when \"batch_inquiry\" then do_batch_inquiry(txn, merchant_id, merchant_key)\n when \"view_detail\" then view_bankcard_settled_batch_detail(txn, merchant_id, merchant_key)\n when \"view_open\" then view_current_open_batch_listing(txn,merchant_id, merchant_key)\n when \"view_settled\" then view_settled_batch_summary(txn,merchant_id, merchant_key)\n else raise \"action not found: #{txn[:action]} (expected one of #{actions.inspect})\"\n end\n end", "def create_application_payment\n Payment.new application: self,\n amount: self.calculate_fee,\n description: \"Application fee (#{pluralize self.course_selections_count, 'course'})\"\n end", "def payments_report(period_data = 'last_month')\n res = payments.completed\n range, daily_report = period_data.to_s.report_period_to_range\n data = [[period_data.to_s.report_period_to_title, 'Tithe', 'Pledge', 'Partner', 'Donation', 'Offertory', 'Payment']]\n range.each do |d| \n r = d.beginning_of_day..(daily_report ? d.end_of_day : d.end_of_month.end_of_day)\n data << [d.strftime(daily_report ? '%d' : '%Y-%m'), \n res.where(payment_at: r, goal: 'tithe').sum(:amount).to_f,\n res.where(payment_at: r, goal: 'pledge').sum(:amount).to_f,\n res.where(payment_at: r, goal: 'partner').sum(:amount).to_f,\n res.where(payment_at: r, goal: 'donation').sum(:amount).to_f,\n res.where(payment_at: r, goal: 'offertory').sum(:amount).to_f,\n res.where(payment_at: r, goal: nil).sum(:amount).to_f\n ]\n end\n data\n end", "def extract_data_for_each_date(payment_detail)\n payment_detail[:dates].map do |date|\n {\n vrn: payment_detail[:vrn],\n charge: charge_in_pence(payment_detail[:charge]),\n travel_date: Date.parse(date).to_s,\n tariff_code: payment_detail[:tariff]\n }\n end\n end", "def complete_order\n @tire_listing = TireListing.find(params[:tire_listing_id])\n\n if !@tire_listing.can_do_ecomm?\n redirect_to @tire_listing, notice: \"Those tires are not eligible for online purchase.\"\n end\n\n @ar_months = Date::MONTHNAMES.each_with_index.collect{|m, i| [m, i.to_s.rjust(2, '0')]}\n @ar_years = [*Date.today.year..Date.today.year + 8]\n\n @qty = params[:qty].to_i\n @order = Order.new(:tire_listing_id => @tire_listing.id, :tire_quantity => @qty)\n @order.status = order_status_array[:created]\n @order.calculate_total_order\n @order.buyer_email = @order.buyer_name = @order.buyer_address1 = @order.buyer_city = @order.buyer_state = @order.buyer_zip = \"unknown\" # to prevent null error\n initialize_order\n @order.save\n end", "def agreement_renewal_params\n params.require(:agreement_renewal).permit! #(:franchisee_id, :renewed_date, :franchisee_document_id)\n end", "def recent_properties_for_quotes(payment_terms_params=nil, service_required_param=nil, status_param=nil, search_str=nil, property_for='Sale', buyer_id=nil, is_premium=false, page_number=1, count=false, latest_time=nil)\n results = []\n count = nil\n\n won_status = Agents::Branches::AssignedAgents::Quote::STATUS_HASH['Won']\n lost_status = Agents::Branches::AssignedAgents::Quote::STATUS_HASH['Lost']\n vendor = PropertyBuyer.where(id: buyer_id).select(:vendor_id).first if buyer_id\n vendor_id = vendor.vendor_id if vendor\n vendor_id ||= nil\n # udprns = quotes.where(district: self.branch.district).order('created_at DESC').pluck(:property_id)\n services_required = Agents::Branches::AssignedAgents::Quote::REVERSE_SERVICES_REQUIRED_HASH[service_required_param]\n new_status = Agents::Branches::AssignedAgents::Quote::STATUS_HASH['New']\n query = Agents::Branches::AssignedAgents::Quote\n klass = Agents::Branches::AssignedAgents::Quote\n\n ### District of that branch\n branch = self.branch\n query = klass.where(\"(district = ? OR (existing_agent_id = ?))\", branch.district, self.id)\n query = query.where('created_at > ?', Time.parse(latest_time)) if latest_time\n max_hours_for_expiry = Agents::Branches::AssignedAgents::Quote::MAX_VENDOR_QUOTE_WAIT_TIME\n\n ### 48 hour expiry deadline\n #query = query.where(\"(agent_id = ? AND status = ?) OR (agent_id is null and status = ? AND created_at > ?)\", self.id, won_status, new_status, max_hours_for_expiry.ago)\n query = query.where(vendor_id: vendor_id) if buyer_id\n query = query.where(payment_terms: payment_terms_params) if payment_terms_params\n query = query.where(services_required: services_required) if service_required_param\n query = query.where(\"((agent_id is null and status = ? and expired = 'f') OR ( agent_id = ? and ( expired= 't' OR status = ? OR status = ? ))) OR pre_agent_id = ? \", new_status, self.id, won_status, lost_status, self.id)\n \n \n\n if status_param == 'New'\n query = query.where(agent_id: nil).where(expired: false)\n elsif status_param == 'Lost'\n query = query.where(agent_id: self.id).where(status: lost_status)\n elsif status_param == 'Pending'\n query = query.where(agent_id: self.id).where(status: new_status).where(expired: false)\n elsif status_param == 'Won'\n query = query.where(agent_id: self.id).where(status: won_status)\n elsif status_param == 'Expired'\n query = query.where(expired: true)\n end\n\n final_results = []\n results = []\n\n if self.is_premium\n count = query.count\n results = query.order('created_at DESC')\n else\n #Rails.logger.info(query.to_sql)\n count = query.count\n page_number ||= 1\n page_number = page_number.to_i\n page_number -= 1\n results = query.order('created_at DESC').limit(PAGE_SIZE).offset(page_number*PAGE_SIZE)\n end\n\n property_ids = results.map(&:property_id)\n winning_quotes = klass.where(status: won_status).where(property_id: property_ids).select([:agent_id, :property_id])\n agents_property_hash = winning_quotes.reduce({}) { |acc_hash, hash| acc_hash.merge(hash.property_id => hash)}\n agent_ids = winning_quotes.map(&:agent_id).uniq\n agents_results = self.class.joins(:branch).where(id: agent_ids).select(['agents_branches_assigned_agents.id', 'agents_branches_assigned_agents.first_name', 'agents_branches.image_url', 'agents_branches_assigned_agents.last_name'])\n agent_result_hash = agents_results.reduce({}) { |acc_hash, hash| acc_hash.merge(hash.id => hash)}\n\n results.each do |each_quote|\n new_row = {}\n property_details = PropertyDetails.details(each_quote.property_id)['_source']\n ### Quotes status filter\n property_id = property_details['udprn'].to_i\n agent_quote = nil\n quote_status = nil\n if each_quote.status == won_status\n quote_status = 'Won'\n new_row[:locked_status] = false\n elsif each_quote.status == new_status && each_quote.agent_id.nil? && each_quote.expired == false\n agent_quote = Agents::Branches::AssignedAgents::Quote.where(agent_id: self.id).where(property_id: each_quote.property_id).where(expired: false).where(status: new_status).last\n\n if !agent_quote.nil?\n quote_status = 'Pending'\n new_row[:locked_status] = true\n else\n quote_status = 'New'\n new_row[:locked_status] = false\n end\n\n elsif each_quote.expired\n quote_status = 'Expired'\n new_row[:locked_status] = false\n else\n quote_status = 'Lost'\n new_row[:locked_status] = false\n end\n new_row[:id] = each_quote.id\n new_row[:credits_required] = ((each_quote.amount.to_f)*(0.01*0.01)).round/PER_CREDIT_COST\n new_row[:udprn] = property_id\n new_row[:terms_url] = agent_quote.terms_url if agent_quote\n new_row[:terms_url] ||= each_quote.terms_url\n new_row[:created_at] = each_quote.created_at\n new_row[:submitted_on] = agent_quote.created_at.to_s if agent_quote\n new_row[:submitted_on] ||= each_quote.created_at.to_s\n new_row[:quote_submitted] = !agent_quote.nil?\n\n new_row[:status] = klass::REVERSE_STATUS_HASH[each_quote.status]\n \n new_row[:status] = quote_status if quote_status == 'Expired'\n\n new_row[:property_status_type] = property_details['property_status_type']\n #new_row[:activated_on] = property_details['status_last_updated']\n new_row[:activated_on] = each_quote.created_at.to_s\n new_row[:type] = 'SALE'\n new_row[:photo_url] = property_details['pictures'] ? property_details['pictures'][0] : \"Image not available\"\n new_row[:vanity_url]= property_details[:vanity_url]\n\n new_row[:percent_completed] = property_details['percent_completed']\n new_row[:percent_completed] ||= PropertyService.new(property_details['udprn']).compute_percent_completed({}, property_details)\n\n new_row = new_row.merge(['property_type', 'beds', 'baths', 'receptions', 'floor_plan_url',\n 'verification_status','asking_price','fixed_price', 'dream_price', 'pictures', 'quotes', 'claimed_on', 'address'].reduce({}) {|h, k| h[k] = property_details[k]; h })\n new_row['payment_terms'] = nil\n new_row['payment_terms'] = agent_quote.payment_terms if agent_quote\n new_row['payment_terms'] ||= each_quote.payment_terms\n new_row['services_required'] = Agents::Branches::AssignedAgents::Quote::SERVICES_REQUIRED_HASH[each_quote.service_required.to_s.to_sym]\n\n new_row[:quote_details] = agent_quote.quote_details if agent_quote\n new_row[:quote_details] ||= each_quote.quote_details\n \n\n new_row[:assigned_agent_id] = property_details[:agent_id]\n new_row[:assigned_agent_name] = property_details[:assigned_agent_first_name].to_s + ' ' + property_details[:assigned_agent_last_name].to_s\n new_row[:assigned_branch_logo] = property_details[:assigned_agent_branch_logo]\n new_row[:assigned_branch_name] = property_details[:assigned_agent_branch_name]\n\n new_row['street_view_url'] = \"https://#{ENV['S3_STREET_VIEW_BUCKET']}.s3.#{ENV['S3_REGION']}.amazonaws.com/#{property_details[:udprn]}.jpg\"\n new_row[:current_valuation] = property_details['current_valuation']\n new_row[:latest_valuation] = property_details['current_valuation']\n\n ### Historical prices\n new_row[:historical_prices] = property_details['sale_prices']\n\n if (quote_status == 'Won') || property_details[:agent_id].to_i == self.id\n new_row[:vendor_id] = property_details['vendor_id']\n new_row[:vendor_first_name] = property_details['vendor_first_name']\n new_row[:vendor_last_name] = property_details['vendor_last_name']\n new_row[:vendor_email] = property_details['vendor_email']\n new_row[:vendor_mobile] = property_details['vendor_mobile_number']\n new_row[:vendor_image_url] = property_details['vendor_image_url']\n else\n new_row[:vendor_id] = nil\n new_row[:vendor_first_name] = nil\n new_row[:vendor_last_name] = nil\n new_row[:vendor_email] = nil\n new_row[:vendor_mobile] = nil\n new_row[:vendor_image_url] = nil\n new_row['address'] = PropertyDetails.street_address(property_details)\n end\n\n ### TODO: Fix for multiple lifetimes\n new_row[:quotes_received] = Agents::Branches::AssignedAgents::Quote.where(property_id: property_id).where.not(agent_id: nil).where(expired: false).count\n\n ### TODO: Fix for multiple lifetimes\n #### WINNING AGENT\n if quote_status == 'Won' || quote_status == 'Lost'\n winning_agent = agent_result_hash[agents_property_hash[each_quote.property_id].agent_id] rescue nil\n if winning_agent\n new_row[:winning_agent_name] = winning_agent.first_name.to_s + ' ' + winning_agent.last_name.to_s\n new_row[:winning_agent_branch_logo] = winning_agent.image_url\n end\n end\n new_row[:claimed_on] = each_quote.created_at\n new_row[:deadline] = (each_quote.created_at + Agents::Branches::AssignedAgents::Quote::MAX_AGENT_QUOTE_WAIT_TIME).to_s\n new_row[:vendor_deadline_end] = (each_quote.created_at + Agents::Branches::AssignedAgents::Quote::MAX_VENDOR_QUOTE_WAIT_TIME).to_s\n new_row[:vendor_deadline_start] = (each_quote.created_at + Agents::Branches::AssignedAgents::Quote::MAX_AGENT_QUOTE_WAIT_TIME).to_s\n new_row[:claimed_on] = Time.parse(new_row['claimed_on']).strftime(\"%Y-%m-%dT%H:%M:%SZ\") if new_row['claimed_on']\n new_row[:submitted_on] = Time.parse(new_row[:submitted_on]).strftime(\"%Y-%m-%dT%H:%M:%SZ\") if new_row[:submitted_on]\n new_row[:deadline] = Time.parse(new_row[:deadline]).strftime(\"%Y-%m-%dT%H:%M:%SZ\") if new_row[:deadline]\n new_row[:activated_on] = Time.parse(new_row[:activated_on]).strftime(\"%Y-%m-%dT%H:%M:%SZ\") if new_row[:activated_on]\n\n final_results.push(new_row)\n\n end\n\n return final_results, count\n end", "def payment_params\n params.require(:payment).permit(:price, :payment_type, :description, :client_id, :date_payment)\n end", "def this_iz_payday(driver, hash)\n # TODO :\n # hash is a hash list, key : person, value : amount of dollz\n\n # for each couple, Access.has_paid(driver, person, amount)\n\n # need a timestamp TODO\n end", "def payment_params\n params.require(:payment).permit(:ref, :company_id, :user_id, :paymethod_id, :companyaccount_id, :price, :vat, :total, :date, :inc_type, :notes, :state)\n end", "def summer_module_opendates\n verify_summer_dates = Moduledate.select(\"opendate,closedate,termvalue\").where(\"name = 'Verify Your Information' AND termvalue=?\", @current_summer_term_in)\n \n if verify_summer_dates.count > 0 \n verify_summer_dates.each do |s|\n @verify_module_summer_open = s.opendate\n @verify_module_summer_close = s.closedate\n @verify_module_summer_term = s.termvalue\n end \n end\n \n comm_summer_dates = Moduledate.select(\"opendate,closedate,termvalue\").where(\"name = 'Communication Preference' AND termvalue=?\", @current_summer_term_in)\n if verify_summer_dates.count > 0 \n comm_summer_dates.each do |s|\n @comm_module_summer_open = s.opendate\n @comm_module_summer_close = s.closedate\n @comm_module_summer_term = s.termvalue \n end\n end\n\n deposit_summer_dates = Moduledate.select(\"opendate,closedate,termvalue\").where(\"name = 'Pay Deposit' AND termvalue=?\", @current_summer_term_in)\n if deposit_summer_dates.count > 0 \n deposit_summer_dates.each do |s|\n @deposit_module_summer_open = s.opendate\n @deposit_module_summer_close = s.closedate\n @deposit_module_summer_term = s.termvalue \n end\n end\n\n immunization_summer_dates = Moduledate.select(\"opendate,closedate,termvalue\").where(\"name = 'Immunization Holds' AND termvalue=?\", @current_summer_term_in)\n if immunization_summer_dates.count > 0 \n immunization_summer_dates.each do |s|\n @immune_module_summer_open = s.opendate\n @immune_module_summer_close = s.closedate\n @immune_module_summer_term = s.termvalue \n end\n end\n\n residency_summer_dates = Moduledate.select(\"opendate,closedate,termvalue\").where(\"name = 'Residency Validation' AND termvalue=?\", @current_summer_term_in)\n if residency_summer_dates.count > 0 \n residency_summer_dates.each do |s|\n @residency_module_summer_open = s.opendate\n @residency_module_summer_close = s.closedate\n @residency_module_summer_term = s.termvalue \n end\n end\n\n housing_summer_dates = Moduledate.select(\"opendate,closedate,termvalue\").where(\"name = 'Housing Contract & Meal Plans' AND termvalue=?\", @current_summer_term_in)\n if housing_summer_dates.count > 0 \n housing_summer_dates.each do |s|\n @housing_module_summer_open = s.opendate\n @housing_module_summer_close = s.closedate\n @housing_module_summer_term = s.termvalue \n end\n end\n\n aleks_summer_dates = Moduledate.select(\"opendate,closedate,termvalue\").where(\"name = 'Math Placement Exam - ALEKS' AND termvalue=?\", @current_summer_term_in)\n if aleks_summer_dates.count > 0 \n aleks_summer_dates.each do |s|\n @aleks_module_summer_open = s.opendate\n @aleks_module_summer_close = s.closedate\n @aleks_module_summer_term = s.termvalue \n end\n end\n\n orientation_summer_dates = Moduledate.select(\"opendate,closedate,termvalue\").where(\"name = 'Orientation' AND termvalue=?\", @current_summer_term_in)\n if orientation_summer_dates.count > 0 \n orientation_summer_dates.each do |s|\n @orientation_module_summer_open = s.opendate\n @orientation_module_summer_close = s.closedate\n @orientation_module_summer_term = s.termvalue \n end\n end\n\n oars_summer_dates = Moduledate.select(\"opendate,closedate,termvalue\").where(\"name = 'Online Adivision & Resource System - OARS' AND termvalue=?\", @current_summer_term_in)\n if oars_summer_dates.count > 0 \n oars_summer_dates.each do |s|\n @oars_module_summer_open = s.opendate\n @oars_module_summer_close = s.closedate\n @oars_module_summer_term = s.termvalue \n end\n end\n\n faualert_summer_dates = Moduledate.select(\"opendate,closedate,termvalue\").where(\"name = 'FAU Alert Information' AND termvalue=?\", @current_summer_term_in)\n if faualert_summer_dates.count > 0 \n faualert_summer_dates.each do |s|\n @faualert_module_summer_open = s.opendate\n @faualert_module_summer_close = s.closedate\n @faualert_module_summer_term = s.termvalue \n end\n end\n\n registration_summer_dates = Moduledate.select(\"opendate,closedate,termvalue\").where(\"name = 'Registration & Holds' AND termvalue=?\", @current_summer_term_in)\n if registration_summer_dates.count > 0 \n registration_summer_dates.each do |s|\n @registration_module_summer_open = s.opendate\n @registration_module_summer_close = s.closedate\n @registration_module_summer_term = s.termvalue \n end\n end\n\n tuition_summer_dates = Moduledate.select(\"opendate,closedate,termvalue\").where(\"name = 'Tuition Payment' AND termvalue=?\", @current_summer_term_in)\n if tuition_summer_dates.count > 0 \n tuition_summer_dates.each do |s|\n @tuition_module_summer_open = s.opendate\n @tuition_module_summer_close = s.closedate\n @tuition_module_summer_term = s.termvalue \n end\n end\n\n emergency_summer_dates = Moduledate.select(\"opendate,closedate,termvalue\").where(\"name = 'Emergency Contacts' AND termvalue=?\", @current_summer_term_in)\n if emergency_summer_dates.count > 0 \n emergency_summer_dates.each do |s|\n @emergency_module_summer_open = s.opendate\n @emergency_module_summer_close = s.closedate\n @emergency_module_summer_term = s.termvalue \n end\n end\n\n owlcard_summer_dates = Moduledate.select(\"opendate,closedate,termvalue\").where(\"name = 'Owl Card' AND termvalue=?\", @current_summer_term_in)\n if owlcard_summer_dates.count > 0 \n owlcard_summer_dates.each do |s|\n @owlcard_module_summer_open = s.opendate\n @owlcard_module_summer_close = s.closedate\n @owlcard_module_summer_term = s.termvalue \n end\n end\n\n book_summer_dates = Moduledate.select(\"opendate,closedate,termvalue\").where(\"name = 'Book Advance Program' AND termvalue=?\", @current_summer_term_in)\n if book_summer_dates.count > 0 \n book_summer_dates.each do |s|\n @book_module_summer_open = s.opendate\n @book_module_summer_close = s.closedate\n @book_module_summer_term = s.termvalue \n end\n end\n\n regvehicle_summer_dates = Moduledate.select(\"opendate,closedate,termvalue\").where(\"name = 'Register Your Vehicle' AND termvalue=?\", @current_summer_term_in)\n if regvehicle_summer_dates.count > 0 \n regvehicle_summer_dates.each do |s|\n @regvehicle_module_summer_open = s.opendate\n @regvehicle_module_summer_close = s.closedate\n @regvehicle_module_summer_term = s.termvalue \n end\n end\n\n @fin_aid_summer_dates = Moduledate.select(\"opendate,closedate,termvalue\").where(\"name = 'Financial Aid' AND termvalue=?\", @current_summer_term_in)\n if @fin_aid_summer_dates.count > 0 \n @fin_aid_summer_dates.each do |s|\n @fin_aid_module_summer_open = s.opendate\n @fin_aid_module_summer_close = s.closedate\n @fin_aid_module_summer_term = s.termvalue \n end\n end\n\n end", "def get_fee_params(npo_ein = '68-0480736')\n {\n DonationLineItems: {\n DonationItem: {\n NpoEin: npo_ein,\n Designation: 'annual_fund',\n Dedication: 'For my grandfather',\n donorVis: 'ProvideAll',\n ItemAmount: 100.00,\n RecurType: 'NotRecurring',\n AddOrDeduct: 'Add',\n TransactionType: 'Donation'\n }\n },\n TipAmount: 1.00,\n CardType: 'Visa'\n }\nend", "def last_payment_detail\n\n\t\tbl = BillingLog.where.not(transaction_type_id: TransactionType.find_by_name(\"Transferencia Formulario\").id).where(:company_id => self.id).where('trx_id in (?) or trx_id in (?)', PuntoPagosConfirmation.where(:response => \"00\").pluck(:trx_id), PayUNotification.where(:state_pol => \"4\").pluck(:reference_sale)).order('created_at desc').first\n\t\trec = BillingRecord.where(:company_id => self.id).order('date desc').first\n\t\tbwt = BillingWireTransfer.where(:company_id => self.id, :approved => true).order('payment_date desc').first\n\t\tpl = PlanLog.where(:company_id => self.id).where('trx_id in (?) or trx_id in (?)', PuntoPagosConfirmation.where(:response => \"00\").pluck(:trx_id), PayUNotification.where(:state_pol => \"4\").pluck(:reference_sale)).order('created_at desc').first\n\n\t\tlast_payment_date = \"\"\n\t\tpaid_amount = \"0\"\n\t\tlast_payment_method = \"\"\n\n\t\tif bl.nil? && rec.nil? && bwt.nil? && pl.nil?\n\n\t\t\tlast_payment_date = \"No existen pagos\"\n\t\t\tresponse_array = []\n\t\t\tresponse_array[0] = last_payment_date\n\t\t\tresponse_array[1] = paid_amount\n\t\t\tresponse_array[2] = last_payment_method\n\n\t\t\treturn response_array\n\n\t\telse\n\n\t\t\tdate1 = Time.at(0).to_datetime\n\t\t\tdate2 = date1\n\t\t\tdate3 = date1\n\t\t\tdate4 = date1\n\n\t\tend\n\n\t\tif !bl.nil?\n\t\t date1 = bl.created_at + self.country.timezone_offset.hours\n\t\tend\n\t\tif !rec.nil?\n\t\t date2 = rec.date.to_datetime\n\t\tend\n\t\tif !bwt.nil?\n\t\t date3 = bwt.payment_date\n\t\tend\n\t\tif !pl.nil?\n\t\t date4 = pl.created_at + self.country.timezone_offset.hours\n\t\tend\n\n\t\tif date1 >= date2 && date1 >= date3 && date1 >= date4\n\t\t last_payment_date = (bl.created_at + self.country.timezone_offset.hours).strftime('%d/%m/%Y %R')\n\t\t paid_amount = \"$\" + bl.payment.to_s\n\t\t last_payment_method = \"Automático\"\n\t\telsif date2 >= date1 && date2 >= date3 && date2 >= date4\n\t\t last_payment_date = rec.date.strftime('%d/%m/%Y %R')\n\t\t paid_amount = \"$\" + rec.amount.to_s\n\t\t last_payment_method = \"Manual - \" + (rec.transaction_type ? rec.transaction_type.name : \"No definido\")\n\t\telsif date3 >= date1 && date3 >= date2 && date3 >= date4\n\t\t last_payment_date = bwt.payment_date.strftime('%d/%m/%Y %R')\n\t\t paid_amount = \"$\" + bwt.amount.to_s\n\t\t last_payment_method = \"Transferencia\"\n\t\telse\n\t\t last_payment_date = (pl.created_at + self.country.timezone_offset.hours).strftime('%d/%m/%Y %R')\n\t\t paid_amount = \"$\" + pl.amount.to_s\n\t\t last_payment_method = \"Automático\"\n\t\tend\n\n\t\tresponse_array = []\n\t\tresponse_array[0] = last_payment_date\n\t\tresponse_array[1] = paid_amount\n\t\tresponse_array[2] = last_payment_method\n\n\t\treturn response_array\n\n\tend", "def investment_return_from_ownership\n @initial_costs = {}\n @recuring_costs = {}\n @closing_costs = {}\n @home_appreciation = {}\n @costs_compare_sum = {}\n\n @rent_security_deposit = (@home_price/(12*@price_to_rent_ratio))*-1\n @costs_of_buying_house = {}\n @costs_of_buying_house[:rent] = (@home_price/(12*@price_to_rent_ratio)*0.25)*-1\n @costs_of_buying_house[:buy] = (@home_price*0.02467)*-1\n\n @initial_costs[:rent] = (@home_price/(12*@price_to_rent_ratio))*-1 + (@home_price/(12*@price_to_rent_ratio)*0.25)*-1\n @initial_costs[:buy] = @down_payment*-1 + (@home_price*0.02467)*-1\n\n @recuring_costs[:rent] = (@home_price/@price_to_rent_ratio*@mortgage_term*(1+0.025)**@mortgage_term+@home_price/@price_to_rent_ratio*@mortgage_term*0.0132)*-1\n @recuring_costs[:buy] =\n ((@monthly_exp_breakdown[:mortgage_principal][:total] + @monthly_exp_breakdown[:mortgage_interest][:total])*-1) + (@monthly_exp_breakdown[:property_tax][:total]*-1) + (@monthly_exp_breakdown[:home_insurance][:total]*-1) + (@monthly_exp_breakdown[:pmi_insurance][:total]*-1) + ((((1+0.054/12)**@number_of_payments-1)*@down_payment)*-1)\n\n @total_monthly_rents = (@home_price/@price_to_rent_ratio*@mortgage_term*(1+0.025)**@mortgage_term)\n @mortgage_payments = (@monthly_exp_breakdown[:mortgage_principal][:total] + @monthly_exp_breakdown[:mortgage_interest][:total])*-1\n @renter_insurance = (@home_price/@price_to_rent_ratio*@mortgage_term*0.0132)*-1\n @returns_for_investment = ((((1+0.054/12)**@number_of_payments-1)*@down_payment)*-1)\n\n @closing_costs[:rent] = 0.0\n @closing_costs[:buy] = (@home_price*0.03)*-1\n\n @home_appreciation[:rent] = @initial_costs[:rent]*-1\n @home_appreciation[:buy] = @home_price*(1.054)**@mortgage_term*0.85\n\n @costs_compare_sum[:rent] =(@initial_costs[:rent] + @recuring_costs[:rent] + @closing_costs[:rent] + @home_appreciation[:rent])\n @costs_compare_sum[:buy] = @initial_costs[:buy] + @recuring_costs[:buy] + @closing_costs[:buy] + @home_appreciation[:buy]\n\n if (@calculate_loan_payment<=750000)\n @mortgage_interest_deduction = (@calculate_monthly_payment*@number_of_payments-@calculate_loan_payment)/@mortgage_term\n else\n @mortgage_interest_deduction = ((@calculate_monthly_payment*@number_of_payments-@calculate_loan_payment)/@mortgage_term)*750000/@calculate_loan_payment\n end\n\n if (@costs_compare_sum[:buy].abs <=0)\n @costs_compare_sum[:benifit] = \"Buying is better than renting even if you could rent for free! In addition, you can save average #{ ActionController::Base.helpers.number_to_currency(@mortgage_interest_deduction.round(2)) } per year from your federal taxable income. Increase your profit by visiting our <a href='JavaScript:void(0);'>mortgage rates</a> and getting a more favorable mortgages.\"\n else\n if (@costs_compare_sum[:buy].abs >0 && @costs_compare_sum[:rent].abs > @costs_compare_sum[:buy].abs)\n @costs_compare_sum[:benifit] = \"Buying is cheaper than renting! You’ll earn an extra #{ActionController::Base.helpers.number_to_currency(((@costs_compare_sum[:buy] - @costs_compare_sum[:rent]).round(2)))} after #{@mortgage_term} years of buying a house. In addition, you can save average #{ActionController::Base.helpers.number_to_currency(@mortgage_interest_deduction.round(2))} per year from your federal taxable income. If you lower your mortgage interest rate, you could save more! Come to visit our <a href='JavaScript:void(0);'>mortgage rates</a> and find other favorable mortgages.\"\n else\n if (@costs_compare_sum[:buy].abs >0 && @costs_compare_sum[:rent].abs == @costs_compare_sum[:buy].abs )\n @costs_compare_sum[:benifit] = \"The cost of buying a house is about the same as renting a house for #{@mortgage_term} years! However, you could save more through lowering your mortgage interest rate. Come to visit our <a href='JavaScript:void(0);'>mortgage rates</a> to get more favorable mortgages.\"\n else\n @costs_compare_sum[:benifit] = \"You'd better to rent a house instead pf buying. Or you could lower your mortgage interest rate to save the cost of buying. Come to visit our <a href='JavaScript:void(0);'>mortgage rates</a> to get more favorable mortgages.\"\n end\n end\n end\n end", "def payment_params\n params.require(:payment).permit(:total, :collector_id, :company_id, :debt_id)\n end", "def agreement_params\n params.require(:agreement).permit(:restaurant_id, :user_id, :start_date, :end_date, :agreement_length, :term_of_notice_in_months, :responsible_user_id, :invoicing_period_length, :invoicing_payment_time, :invoicing_date, :signed_by_customer)\n end", "def rent_payment_params\n params.require(:rent_payment).permit(:renter_id, :subunit_id, :amount, :payment_method_id, :subunit_rent_id, :receipt_number, :payment_date)\n end", "def save_with_payment\n if(self.merchandise_id.present?) #if a purchase is being made\n puts \"13x\" ##########\n @merchandise = Merchandise.find(self.merchandise_id)\n self.pricesold = @merchandise.price\n self.author_id = @merchandise.user_id \n seller = User.find(@merchandise.user_id)\n amt = (@merchandise.price * 100).to_i \n desc = @merchandise.name \n %%if self.group_id.present?\n self.groupcut = ((@merchandise.price * 5).to_i).to_f/100\n self.authorcut = ((@merchandise.price * 92).to_i - 30).to_f/100 - self.groupcut\n else%\n self.groupcut = 0.0\n self.authorcut = ((@merchandise.price * 92.1).to_i - 30).to_f/100\n %%end%\n\n else #If a donation is being made\n puts \"14x\" ##########\n self.pricesold = pricesold\n self.author_id = author_id\n seller = User.find(self.author_id)\n amt = (pricesold * 100).to_i\n self.authorcut = ((pricesold * 92.1).to_i - 30).to_f/100\n if self.user_id.present?\n purchaser = User.find(self.user_id)\n desc = \"Donation of $\" + String(pricesold) + \" from \" + purchaser.name\n else\n desc = \"Donation of $\" + String(pricesold) + \" from anonymous customer\"\n end\n end\n\n sellerstripeaccount = Stripe::Account.retrieve(seller.stripeid)\n puts seller.stripeid + \" <-- SELLER stripeid\" ###########\n %%if self.group_id.present? #not used right now\n group = Group.find(self.group_id)\n groupstripeaccount = Stripe::Account.retrieve(group.stripeid)\n end%\n\n if self.email.present?\n puts \"15x\" ##########\n #\n customer = Stripe::Customer.create(\n :source => stripe_card_token, #token from? purchases.js.coffee?\n :description => \"anonymous customer\", # what info do I really want here\n :email => self.email\n )\n puts customer.id ###########\n puts customer.email\n\n else\n puts \"16x\" ##########\n @purchaser = User.find(self.user_id)\n puts @purchaser.name + \" here 16x\" ###########################\n if(@purchaser.stripe_customer_token).present?\n puts \"17x stripe customer token is present\" ##########\n customer = Stripe::Customer.retrieve(@purchaser.stripe_customer_token)\n puts customer.id + \" getting customer id from stripe customer token \"########### CHECKING\n if stripe_card_token.present?\n customer.source = stripe_card_token\n customer.save\n end\n else\n puts \"18x\" ##########\n customer = Stripe::Customer.create(\n :source => stripe_card_token, #token from? purchases.js.coffee?\n :description => @purchaser.name, # what info do I really want here\n :email => @purchaser.email\n )\n @purchaser.update_attribute(:stripe_customer_token, customer.id)\n puts customer.id + \" BUYER customer id\"######## this is customer id for the buyer\n # works upto here\n end\n end\n\n if seller.id == 143 || seller.id == 1403 || seller.id == 1452 || seller.id == 1338 || seller.id == 1442\n puts \"19x\" ##########\n charge = Stripe::Charge.create({\n :amount => amt,\n :currency => \"usd\",\n :customer => customer.id,\n :description => desc\n })\n else\n puts \"20x\" ##########\n # transfergrp = \"purchase\" + (Purchase.maximum(:id) + 1).to_s #won't work when lots of simultaneous purchases\n appfee = ((amt * 5)/100)\n\n puts customer.id ########\n puts sellerstripeaccount.id ########\n token = Stripe::Token.create({\n :customer => customer.id,\n }, {:stripe_account => sellerstripeaccount.id} )\n\n puts \"token end here 20x\" #############\n\n charge = Stripe::Charge.create( {\n :amount => amt, # amt charged to customer's credit card\n :currency => \"usd\",\n :source => token.id, #token from? purchases.js.coffee?\n # :customer => customer.id, # This will be necessary for subscriptions. See Stripe Docs & Stackoverflow\n :description => desc,\n :application_fee => appfee, #this is amt crowdpublishtv keeps - it includes groupcut since group gets paid some time later\n # :transfer_group => transfergrp\n } ,\n {:stripe_account => sellerstripeaccount.id } #appfee only needed for old way of 1 connected acct per transaction\n )\n # transfer = Stripe::Transfer.create({\n # :amount => (self.authorcut * 100).to_i,\n # :currency => \"usd\",\n # :destination => sellerstripeaccount.id,\n # :source_transaction => charge.id, # stripe attempts transfer when this isn't here, even when transfer_group is\n # :transfer_group => transfergrp #does this mean anything when there is a source transaction?\n # })\n puts \"charge here 20x\" #############\n if self.group_id.present? #this is for when groups affiliate to help sell\n puts \"21x\" #############\n transfer = Stripe::Transfer.create({\n :amount => (self.groupcut * 100).to_i,\n :currency => \"usd\",\n :destination => groupstripeaccount.id,\n :source_transaction => charge.id,\n :transfer_group => transfergrp\n })\n end\n end\n\n puts \"23x\" #############\n save!\n\n rescue Stripe::InvalidRequestError => e\n puts \"Stripe error in model!\"\n logger.error \"Stripe error while creating customer: #{e.message}\"\n errors.add :base, \"There was a problem with your credit card.\"\n false\n\n end", "def make_payment\n if request.post?\n \n @product = Product.find_by_id(params[:id])\n\n\n @today = Time.now.in_time_zone(\"Eastern Time (US & Canada)\").to_datetime\n\n offer_token = (session[:_csrf_token] ||= SecureRandom.base64(32))\n ip = request.remote_ip\n @offer = @product.last_offer(ip,offer_token)\n unless @offer\n @offer = Offer.create(:product_id => @product.id,:price => @product.regular_price,:response => \"counter\", :token => offer_token, :ip => ip,:counter => 1)\n end\n \n if @offer.nil?\n redirect_to root_path\n return\n end\n session[@offer.id] = @offer.product.regular_price if session[@offer.id].nil?\n @month = Date.today.month\n @payment = Payment.find_or_initialize_by_offer_id(@offer.id) \n @payment.price = @offer.price\n @payment.save(:validates => false)\n redirect_to payments_path(@payment)\n else\n redirect_to root_path\n end\n end", "def create\n # checkin_date = session[:booking][:checkin]\n # checkout_date = session[:booking][:checkout]\n # room_type_id = session[:booking][:room_type_id]\n checkin_date = params[:booking][:checkin]\n checkout_date = params[:booking][:checkout]\n room_type_id = params[:booking][:room_type]\n\n days = (checkout_date.to_date - checkin_date.to_date).to_i\n \n #@room = Room.where(\"room_type_id = ? AND (id NOT IN (?))\", room_type_id, Booking.joins(:room_occupation).where(\"start_at >= ? OR end_at <= ?\", checkin_date, checkout_date).select(:room_id) ).first\n #@room = Room.where(\"room_type_id = ?\", room_type_id).first\n @room = Room.empty_rooms(checkin_date, checkout_date).where(:room_type_id => room_type_id).first\n \n if @room.nil?\n redirect_to :back, :alert => \"No room avalible\"\n return\n end\n \n Payment.transaction do\n visit_params = Hash.new()\n visit_params[:customer_id] = current_user.id\n visit_params[:should_checkin_at] = checkin_date\n visit_params[:should_checkout_at] = checkout_date\n visit_params[:rate] = @room.base_rate\n visit_params[:room_id] = @room.id\n visit_params[:days] = days\n\n @visit = Visit.new(visit_params)\n @visit.save\n\n date = checkin_date.to_date\n while(date < checkout_date.to_date)\n occupancy_params = Hash.new()\n occupancy_params[:date] = date\n occupancy_params[:room_id] = @room.id\n occupancy_params[:visit_id] = @visit.id\n @occupance = Occupancy.new(occupancy_params)\n @occupance.save\n date = date + 1.day\n end\n\n @payment = current_user.build_payment(payment_params)\n @payment.price = (@room.base_rate * days).to_f\n @payment.visit_id = @visit.id\n @payment.save\n \n end\n redirect_to payment_path(@payment)\n\n end", "def add_or_create_downpayment_from_price_adjustment(amount)\n # puts \"in the payment#add_or_create_downpayment_from_price_adjustment\"\n # puts \"amount: #{amount}\"\n if not self.addition_downpayment.nil?\n puts \"not nil, just add\"\n dp = self.addition_downpayment \n dp.amount += amount\n dp.save \n self.downpayment_addition_amount += amount\n self.save\n else\n # puts \"nil shite, create downpayment history, amount:#{amount} \"\n self.downpayment_addition_amount = amount\n self.save \n DownpaymentHistory.create_downpayment_addition_history( self ) \n end\n \n \n customer = self.customer\n \n customer.update_remaining_downpayment\n \n end", "def create_the_payment_exhibition\n if((params[:invoicing_info][:payment_medium] == \"visa\") or (params[:invoicing_info][:payment_medium] == \"paypal\") or (params[:invoicing_info][:payment_medium] == \"master_card\")) \n credit_card = CreditCard.find_by_user_id(current_user.id)\n if credit_card.blank?\n credit_card = CreditCard.new()\n end\n credit_card.number = params[:credit_card][:number0]+params[:credit_card][:number1]+params[:credit_card][:number2]+params[:credit_card][:number3]+params[:credit_card][:number4]+params[:credit_card][:number5]+params[:credit_card][:number6]+params[:credit_card][:number7]+params[:credit_card][:number8]+params[:credit_card][:number9]+params[:credit_card][:number10]+params[:credit_card][:number11]+params[:credit_card][:number12]+params[:credit_card][:number13]+params[:credit_card][:number14]+params[:credit_card][:number15]\n credit_card.user_id = current_user.id\n credit_card.first_name = params[:credit_card][:first_name]\n credit_card.last_name = params[:credit_card][:last_name]\n credit_card.expiring_date = Date.civil(params[:credit_card][\"expiring_date(1i)\"].to_i,params[:credit_card][\"expiring_date(2i)\"].to_i,params[:credit_card][\"expiring_date(3i)\"].to_i).strftime(\"%y-%m-%d\") \n credit_card.save\n else\n end \n creditcardnumber = params[:credit_card][:number0]+params[:credit_card][:number1]+params[:credit_card][:number2]+params[:credit_card][:number3]+params[:credit_card][:number4]+params[:credit_card][:number5]+params[:credit_card][:number6]+params[:credit_card][:number7]+params[:credit_card][:number8]+params[:credit_card][:number9]+params[:credit_card][:number10]+params[:credit_card][:number11]+params[:credit_card][:number12]+params[:credit_card][:number13]+params[:credit_card][:number14]+params[:credit_card][:number15]\n #######################################this is im copying here is something from payment controller create method\n @order = session[:purchasable] \n if @order.blank?\n render :text =>\"Please Refresh The Page And Try Again\"\n return\n else \n @order.save\n current_user.profile.biography = params[:biography]\n current_user.profile.save\n end\n @current_object = Payment.new(params[:payment])\t\t#@invoice = session[:invoice]\t\t\n \n if @order.instance_of? ExhibitionsUser\n @current_object.amount_in_cents =params[:invoice_amount].to_i*100\n elsif @order.instance_of? CompetitionsUser\n @current_object.amount_in_cents = (@order.find_price(@order.competition.id) ) * 100\n else \n end\n @current_object.user = @current_user\t\t#@current_object.invoice = @invoice\n if @order.instance_of? ExhibitionsUser\n if params[:invoicing_info][:payment_medium] == \"visa\" or params[:invoicing_info][:payment_medium] == \"master_card\" \n @current_object.common_wealth_bank_process((params[:invoice_amount].to_i*100),params,creditcardnumber)\n \n elsif params[:invoicing_info][:payment_medium] == \"cash\" or params[:invoicing_info][:payment_medium] == \"cheque\" or params[:invoicing_info][:payment_medium] == \"direct deposit\"\n elsif params[:invoicing_info][:payment_medium] == \"paypal\" \n #@current_object.make_paypal_payment((params[:invoice_amount].to_i),params) \n session[:paypal_amount] = params[:invoice_amount].to_i*100\n set_the_token#from here i need to redirect him to paypal after getting the token\n session[:invoice_id] = params[:invoice_id]\n session[:order] = @order\n session[:exhibition_id] = @order.exhibition.id\n session[:current_object_id] = @current_object\n render :update do |page|\n page[\"modal_space_answer\"].hide \n page[\"paypal_form\"].replace_html :partial=>\"paypal_form\",:locals=>{:token =>@token,:amt=>params[:invoice_amount].to_i}\n page.call 'submit_my_form'\n end\n return\n end\n elsif @order.instance_of? CompetitionsUser\n if @order.invoices.last \n total_amount = 0\n @order.invoices.each {|x| total_amount = total_amount + x.final_amount}\n if total_amount < @order.find_price(@order.competition.id) \n more_amount = (@order.find_price(@order.competition.id) ) - total_amount\n @current_object.amount_in_cents = more_amount * 100\n if params[:invoicing_info][:payment_medium] == \"visa\" or params[:invoicing_info][:payment_medium] == \"master card\" \n @current_object.common_wealth_bank_process((more_amount * 100),params)\n elsif params[:invoicing_info][:payment_medium] == \"cash\" or params[:invoicing_info][:payment_medium] == \"cheque\" or params[:invoicing_info][:payment_medium] == \"direct deposit\"\n elsif params[:invoicing_info][:payment_medium] == \"paypal\" \n @current_object.make_paypal_payment((more_amount * 100),params) \n end\n else\n render :text=>\"You Did not changed the entry field or if you decremented it then send email to admin \"\n return\n end \n else\n if params[:invoicing_info][:payment_medium] == \"visa\" or params[:invoicing_info][:payment_medium] == \"master card\" \n @current_object.common_wealth_bank_process(((@order.find_price(@order.competition.id) ) * 100),params)#payment is done if invoice is not yet created. for competition user\n elsif params[:invoicing_info][:payment_medium] == \"cash\" or params[:invoicing_info][:payment_medium] == \"cheque\" or params[:invoicing_info][:payment_medium] == \"direct deposit\"\n elsif params[:invoicing_info][:payment_medium] == \"paypal\" \n @current_object.make_paypal_payment(((@order.find_price(@order.competition.id) ) * 100),params) \n end \n end \n else #here it may be come that while working in this method and it fails somewhere and session[:purchasable] = nil. generaly this is not the normal case\n if @order.instance_of? Order\n make_order_payment\n return\n else\n render :text=>\"There Is Internal Error While Making the payment Please Try Go Back And Try Again<a href='/admin/profiles/#{current_user.id}'>Back</a> \"\n end\n return\n end#bank procedure if end\n\t\t#here after the payment is done what message is required to be sent is get decided and the invoice is get generated\n if @current_object.state == 'online_validated'\t # flash[:notice] = 'Your Payment Is Done And Invoice Will Be Sent To You By Email'\n if @order.instance_of? CompetitionsUser \n if @order and @order.invoices.last\n total_amount = 0\n @order.invoices.each {|x| total_amount = total_amount + x.final_amount}\n if total_amount < @order.find_price(@order.competition.id) \n make_the_payment\n render :partial=>\"extra_payment_done\",:locals=>{:competition=>@order.competition,:order=>@order} \n return \n else\n # flash[:error] = \"Your Payment Is Already Done Please Go To Home Page <a href='/admin/competitions/#{@order.competition.id}'>Go Back To see the competition</a>\"\n end\n render :text => @template.blank_main_div(:title => 'System error', :hsize => 'sixH', :modal => true), :layout => false\n return\n else \n make_the_payment\n end\n else\n if @order.instance_of? ExhibitionsUser \n make_the_payment_exhibition\n end\n end \n if @order.instance_of? ExhibitionsUser \n \n if params[:invoicing_info][:payment_medium] == \"cash\" or params[:invoicing_info][:payment_medium] == \"cheque\" or params[:invoicing_info][:payment_medium] == \"direct deposit\"\n render :text=>\"After Your Payment Is Done Admin Will Validate You. After That Your Artwork Will Be Selected. <a href='/admin/exhibitions/#{@order.exhibition.id}'>Select Artwork</a>\"\n else\n invoice = Invoice.find(:last,:conditions=>[\"purchasable_type = ? and client_id = ? and purchasable_id = ?\",\"ExhibitionsUser\" , @order.user,@order.id])\n \n if invoice.state == \"created\"\n alreadypaidamt = @order.price - invoice.final_amount\n note = \"no notes created\"\n note = @order.exhibition.timing.note if @order.exhibition.timing\n create_pdf(invoice.id,invoice.number,@order.exhibition.timing.starting_date.strftime(\"%d %b %Y\"),invoice.client.profile.full_address_for_invoice,invoice.client.profile.full_name_for_invoice,@order.exhibition.title,@order.price.to_i,note,@order.price - alreadypaidamt,alreadypaidamt,true,@order.exhibition.timing.ending_date,\"\")\n QueuedMail.add('UserMailer','send_invoice_exhibition',[@current_object.user.profile.email_address,\"invoice#{invoice.id}\",\"Your Exhibition Payment Is Done And An Invoice Is Sent to Your Email.\",invoice, @current_object.user],0,true,@current_object.user.profile.email_address,\"test@pragtech.co.in\") \n end \n \n #render :text=>\"Your Payment Is Done Now Upload And Then Select The Artworks <a href='/admin/exhibitions/#{@order.exhibition.id}'>Select Artwork</a>\"\n #render :partial => \"online_response_exhibition_payment\",:locals=>{:exhibition_user_id=>@order.id,:artwork_count=>0}\n add_exhibition_artwork_insamediv\n\t\t\t \n end \n elsif @order.instance_of? CompetitionsUser\n if params[:invoicing_info][:payment_medium] == \"cash\" or params[:invoicing_info][:payment_medium] == \"cheque\" or params[:invoicing_info][:payment_medium] == \"direct deposit\"\n #render :text=>\"After Your Payment Is Done Admin Will Validate You. After That Your Artwork Will Be Selected. Please Make The Payment Before #{@order.submission_date} <a href='/admin/competitions/#{@order.competition.id}'>Go Back To see the competition</a>\"\n render :partial=> \"cash_cheque_response\",:locals=>{:competition_id=>@order.competition.id,:artwork_count=>0,:order_id=>@order.id,:total_entry=>@order.total_entry}\n else\n #session[:total_entry] = @order.total_entry\n #render :update do |page|\n # session[:store_for_submitting_the_artwork] = @order.id\n #page[\"show_me_the_error\"].replace_html :partial=>\"add_artwork_link\",:locals=>{:competition_id=>@order.competition.id,:artwork_count=>0,:order_id=>@order.id}\n #end\n render :partial=>\"add_artwork_link\",:locals=>{:competition_id=>@order.competition.id,:artwork_count=>0,:order_id=>@order.id}\n #render :text=>\"Your Payment Is Done . The Invoice Is Sent To You By Email. <a href='/admin/competitions/#{@order.competition.id}'>Go Back To see the competition</a>\"\n end \t \n end\n else\n if params[:invoicing_info][:payment_medium] == \"cash\" or params[:invoicing_info][:payment_medium] == \"cheque\" or params[:invoicing_info][:payment_medium] == \"direct deposit\"\n if @order.instance_of? CompetitionsUser\n make_the_payment\n else\n make_the_payment_exhibition\n invoice = Invoice.find(:last,:conditions=>[\"purchasable_type = ? and client_id = ? and purchasable_id = ?\",\"ExhibitionsUser\" , @order.user,@order.id])\n if invoice.state == \"created\"\n note = \"no notes created\"\n note = @order.exhibition.timing.note if @order.exhibition.timing\n senttime \n if invoice.sent_at\n senttime = invoice.sent_at.strftime(\"%d %b %Y\")\n else\n senttime = Time.now.strftime(\"%d %b %Y\")\n end\n \n \n create_pdf(invoice.id,invoice.number,senttime,invoice.client.profile.full_address_for_invoice,invoice.client.profile.full_name_for_invoice,@order.exhibition.title,invoice.final_amount.to_i,note)\n \n QueuedMail.add('UserMailer', 'send_invoice_exhibition', [invoice, @order.user], 0, true)\n end \n end \n if @order.instance_of? CompetitionsUser \n # render :text=>\"After Your Payment Is Done Admin Will Validate You. After That Your Artwork Will Be Selected. Please Make The Payment Before #{@order.competition.submission_deadline} <a href='/admin/competitions/#{@order.competition.id}'>Go Back To see the competition</a>\"\n render :partial=> \"cash_cheque_response\",:locals=>{:competition_id=>@order.competition.id,:artwork_count=>0,:order=>@order,:total_entry=>@order.total_entry}\n return \n else\n #exhibition cash_cheque_response\n # render :partial => \"cash_cheque_response_exhibition\",:locals=>{:exhibition_user_id=>@order.id,:artwork_count=>0}\n #instead of this response i need to give the option to add the artwork to user\n \n render :update do |page|\n page[\"add_the_artwork0\"].replace_html :partial=>\"add_the_artwork_exhibition\",:locals=>{:exhibition_user_id => @order.id,:exhibition_id=>@order.exhibition.id,:messageforimageuploaded=>\"After Your Payment Is Done Admin Will Validate You. Please Upload The Artwork\"}\n page[\"description_competition_ex_py\"].hide\n page[\"enterartworkcompetition\"].show\n page[\"add_the_artwork0\"].show\n page[\"iteam_image0\"].show\n page[\"iteam_image_uploaded\"].hide\n \n end\n #render :text=>\"After Your Payment Is Done Admin Will Validate You. After That Your Artwork Will Be Selected. <a href='admin/exhibitions/#{@order.exhibition.id}'>Select Artwork</a>\"\n end \t \n return\n end\n\t \n #flash[:error] = 'Error during the payment save '+@current_object.state.to_s\n\t \n #render :partial => 'new', :layout => false\n render :text=>\"Your payment has not been successful. Please check your details and try again\"\n end\n\n end", "def payment_status\n if paid\n return 'green'\n elsif payment_date < Date.today\n return 'red'\n else \n return 'pending'\n end\n end", "def purchase_return_quantity_amount_in_period(start_date, end_date, branch_id)\n if branch_id.present?\n purchase_retrn_qty = purchase_return_line_items.select(\"sum(quantity) as purchase_return_quantity, sum(amount) as purchase_return_amount\").joins(:purchase_return)\n .where(:purchase_returns => {:company_id => company_id, :record_date => start_date..end_date, :branch_id => branch_id})\n else\n purchase_retrn_qty = purchase_return_line_items.select(\"sum(quantity) as purchase_return_quantity, sum(amount) as purchase_return_amount\").joins(:purchase_return)\n .where(:purchase_returns => {:company_id => company_id, :record_date => start_date..end_date, :branch_id => branch_id}) \n end\n end", "def payment\r\n return (deposit + credit_card_charge) if (payment_mode =~ /deposit/)\r\n return (balance + credit_card_charge) if (payment_mode =~ /balance/)\r\n raise \"Bad payment mode #{payment_mode}\"\r\n end" ]
[ "0.7256648", "0.5937413", "0.58850175", "0.5865144", "0.58521664", "0.5812185", "0.57938576", "0.56561565", "0.5629154", "0.55757344", "0.55501074", "0.54809415", "0.5457617", "0.5453679", "0.54233056", "0.539911", "0.53963554", "0.5374325", "0.535959", "0.5348487", "0.5338213", "0.5328985", "0.53162897", "0.53141606", "0.52947533", "0.529065", "0.5282995", "0.5279332", "0.5272142", "0.52704626", "0.52613276", "0.5260337", "0.52577627", "0.5226376", "0.522172", "0.5220509", "0.5201025", "0.5200147", "0.5194277", "0.5193421", "0.51907104", "0.51884395", "0.51863736", "0.51832104", "0.5182078", "0.517917", "0.51786846", "0.51762074", "0.5171628", "0.5171611", "0.51459056", "0.51369685", "0.5132912", "0.5131726", "0.5130316", "0.5128917", "0.5118352", "0.51172835", "0.5117275", "0.51141167", "0.51132256", "0.5111562", "0.5107238", "0.5105045", "0.5104249", "0.50999147", "0.50999147", "0.5099292", "0.509865", "0.50962955", "0.50949544", "0.50940204", "0.5090081", "0.5089823", "0.5088106", "0.5087993", "0.5085625", "0.50848544", "0.50814545", "0.5074565", "0.50729924", "0.5072666", "0.5071324", "0.50708926", "0.5070735", "0.5068901", "0.50684685", "0.50657225", "0.50635576", "0.5061237", "0.5060353", "0.5053759", "0.5051133", "0.504884", "0.5048117", "0.5045009", "0.50425744", "0.5037313", "0.50326085", "0.50228196", "0.502051" ]
0.0
-1
with an argument, and children maybe
def a(object, arg, *children) b(object.as(:statement) >> space >> arg.as(:argument), *children) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def children=(_arg0); end", "def children=(_arg0); end", "def apply_children\n \n end", "def children; end", "def children; end", "def children; end", "def children; end", "def children; end", "def children; end", "def children; end", "def children; end", "def children; end", "def children; end", "def children; end", "def children; end", "def arguments\n children[1..-1]\n end", "def process_child_nodes(node); end", "def add(child); end", "def children() []; end", "def find_in_children(*args)\n child = nil\n Capybara.current_session.within(element) do\n child = self.class.new(:child, *args)\n child.element\n end\n\n child\n end", "def add_child(node_or_tags); end", "def add_child(node_or_tags); end", "def taskChildren _args\n \"taskChildren _args;\" \n end", "def multiple_children(paths)\n end", "def children_for page, title\n page.children.create({\n :title => title,\n :deletable => true,\n :status => 'live',\n :show_in_menu => true,\n :parent_id => page.id\n })\nend", "def get_children(args = '', output = :OBJECT)\n kids = {}\n if args.blank?\n if $GLOBALS['post']\n args = { post_parent: $GLOBALS['post'].post_parent }\n else\n return kids\n end\n elsif args.is_a? Integer\n args = { post_parent: args}\n elsif args.is_a? String\n args = { post_parent: args.to_i}\n elsif args.is_a? Railspress::WpPost\n args = { post_parent: args.post_parent }\n end\n\n defaults = {\n numberposts: -1,\n post_type: 'any',\n post_status: 'any',\n post_parent: 0,\n }\n\n r = defaults.merge args\n\n children = get_posts(r)\n\n return kids if children.nil?\n\n return children unless r[:fields].blank?\n\n # update_post_cache(children)\n\n children.each do |child|\n kids[child.id] = child\n end\n\n if output == :OBJECT\n kids\n elsif output == :ARRAY_A\n weeuns = {}\n kids.values.each do |kid|\n weeuns[kid.id] = kid.attributes\n end\n return weeuns\n elsif output == :ARRAY_N\n babes = {}\n kids.values.each do |kid|\n babes[kid.id] = kid.attributes.values\n end\n return babes\n else\n kids\n end\n end", "def children=(node_or_tags); end", "def children=(node_or_tags); end", "def children; []; end", "def children(*args)\n self.class.send(:with_scope, :find=>{:conditions=>['parent_node_id=?', self.child_node_id]}) do\n self.class.find(:all, *args)\n end\n end", "def third_child\n child 2\n end", "def children\n raise NotImplementedError\n end", "def each_child\n \n end", "def getObjectChildren _obj, _args\n \"_obj getObjectChildren _args;\" \n end", "def second_child\n child 1\n end", "def children\n @id = fix_id(params[:id], params[:format], params[:extra])\n if params[:root]==\"source\" then\n @isRoot = true;\n @work = DcmWork.new(@id)\n @children = [@work.pi]\n else\n @isRoot = false;\n @children = get_children(\"nla.\"+params[:root])\n end\n render :action => \"children.json\"\n end", "def children\n examples + steps + tags\n end", "def get_child!(children)\n children[1] || children\n end", "def s(type, *children); end", "def child_node; end", "def get_children\n \t@children\n end", "def function\n children[0]\n end", "def allowed_children; end", "def children\n []\n end", "def replace_with(child); end", "def direct_children_by_id(*args)\n scope = args.last.is_a?(Hash) ? args.pop : {}\n ids = args.flatten.compact.uniq\n self.class.find_in_nested_set(:all, { \n :conditions => [\"#{scope_condition} AND #{prefixed_parent_col_name} = #{self.id} AND #{self.class.table_name}.#{self.class.primary_key} IN (?)\", ids]\n }, scope) \n end", "def index(child); end", "def get_children(children, level, array)\n return if children.nil?\n\n children.each do |child|\n \n blocked = (child.blocked == \"true\") ? \"BLOCKED\" : \"\" # syntax highlighting matches 'BLOCKED' word\n display_str = \" \" * (level*2) + \"#{child.formatted_i_d}: #{StringUtils.html2text(child.name)}\"\n array << \"#{display_str.rjust(display_str.length, ' ').ljust(65, ' ')} #{formatted_story_state(child.schedule_state).ljust(15, ' ')} #{blocked}\\n\"\n get_children(child.children, level+1, array)\n end\n end", "def add_child(aChild)\n children << aChild\n end", "def children\n Feature.find(:all, :conditions => [ 'parent_id=?', self.id] )\n end", "def fourth_child\n child 3\n end", "def children\n child_check\n super\n end", "def insert_before(child1, child2); end", "def children\n @children\n end", "def children\n @children\n end", "def _children\n expected_amount == 1 ? 'child' : 'children'\n end", "def insert_after(child1, child2); end", "def subnodes\n Array(args)\n end", "def find_child(method, *args); end", "def to_html *args\n children.to_html(*args)\n end", "def children\n self.class.children(self) \n end", "def children_for(list)\n list.map do |key, value|\n value = Array(value).flatten\n if value.any?\n after = \" \" * string.inspect.length + \" \"\n description = Hansi.render(THEME[:orange], key.to_s)\n Tree.new(description, *value, after: after, prefix_color: PREFIX_COLOR)\n end\n end\n end", "def children\n rows + tags\n end", "def parameter_children\n []\n end", "def _children\n @children\n end", "def _children\n @children\n end", "def _children\n @children\n end", "def _children\n @children\n end", "def children= (c)\n end", "def render_children options = {}\n return if children.empty?\n\n flattened_children.map{ |child| render_child(child, options) }.join\n end", "def get_children\n @children\n end", "def child_node=(_); end", "def children\n Brand.where(:parent => self.name).order('sort_order, name')\n end", "def walk(arg=true, &block)\n children do |child|\n if ch_arg = block.call(arg, child)\n child.walk(ch_arg, &block)\n end\n end\n end", "def prepend_child(node_or_tags); end", "def prepend_child(node_or_tags); end", "def add_child(child)\n \t\t@children << child\n \tend", "def child_nodes_from_params(child_nodes)\n if child_nodes.is_a? String and !child_nodes.empty?\n JSON.parse(child_nodes)\n else\n child_nodes\n end\n end", "def add_children *nodes\n nodes.flatten!\n raise \"Non-node child given!\" if nodes.any? { |node| node.class != Node }\n nodes.each { |node| node.parent = self }\n @children.concat nodes\n end", "def children\n if no_child?\n []\n else\n [ body ]\n end\n end", "def add_child_node_and_reparent_attrs(node); end", "def add_child_node_and_reparent_attrs(node); end", "def children\n []\n end", "def children\n children = []\n children << up_child unless up_child.nil?\n children << down_child unless down_child.nil?\n children << left_child unless left_child.nil?\n children << right_child unless right_child.nil?\n children\n end", "def child *a; CssString.new a.flatten.unshift(self).join ' > ' end", "def _children\n @children\n end", "def children\n []\n end", "def children\n []\n end", "def children\n []\n end", "def children\n attributes.fetch(:children)\n end", "def children()\n #Ressource.filter(:parent_id => self.id, :parent_service_id => self.service_id).all\n end", "def create_tree(father,tree)\n tree.each do |name|\n n = Meta::create_class(father, name[0], name[1])\n create_tree(n, name[2])\n end\nend", "def post_initialize(args)\n begin\n specify_children()\n specify_attributes()\n if(!args.nil?)\n if(args.is_a?(Hash))\n if(args.has_key? :children)\n bulk_children(args[:children])\n end\n if(args.has_key? :attributes)\n #puts \"Has attributes\"\n args[:attributes].keys.each do |a|\n #puts \"Writing attribute:\", a\n @attributes[a] = args[:attributes][a] #TODO, this should have better error checking in it, like is a field required but is passed nil?\n end\n end\n if(args.has_key? :text)\n #puts \"Added text\", args[:text]\n @text = args[:text]\n else\n #TODO #put error that the proper hash keys were not identified.\n end\n end\n else\n #TODO give some indication that no arguments were provided\n end\n #TODO - make this active only on a boolean, possibly filter\n delete_unwanted_children()\n rescue => error\n puts \"Could not create the BuildingSync element properly.\"\n puts error.inspect, error.backtrace\n end\n end", "def findChildren (parent, structure)\n #search for items in structure where item.manager = parent\n children = []\n \n #puts parent\n \n structure.each do |employee|\n \n #puts '> ' + employee.join(', ')\n \n if employee[2].eql? parent\n \n #puts 'got it!'\n \n children << employee\n end\n end\n \n return children\n\nend", "def children\n # return students\n return offerings\n end", "def permitted_children(*args)\n return @permitted_children ||= PermittedChildren.all if args.empty?\n\n @permitted_children = if %i[all none].include?(args.first)\n PermittedChildren.send(args.first)\n else\n PermittedChildren[args]\n end\n end", "def initialize name=nil, child=nil\r\n super name\r\n @child = child\r\n end", "def children\n TkWinfo.children(content)\n end", "def children\n []\n end", "def children\n []\n end", "def argument_node; end" ]
[ "0.77445525", "0.77445525", "0.7105807", "0.7085406", "0.7085406", "0.7085406", "0.7085406", "0.7085406", "0.7085406", "0.7085406", "0.7085406", "0.7085406", "0.7085406", "0.7085406", "0.7085406", "0.69586897", "0.66827446", "0.655008", "0.6490435", "0.644617", "0.64059067", "0.64059067", "0.63592523", "0.6267898", "0.6256486", "0.62364906", "0.6220922", "0.6220922", "0.6217636", "0.6185137", "0.618179", "0.6146246", "0.6121192", "0.60916823", "0.6090831", "0.6082268", "0.6047553", "0.60166466", "0.6014631", "0.5999059", "0.59765804", "0.5973646", "0.5964454", "0.5943054", "0.59413433", "0.5910721", "0.589477", "0.5841511", "0.5815292", "0.5807909", "0.5794946", "0.5788259", "0.5766253", "0.5743736", "0.5743736", "0.5741586", "0.5739827", "0.57352304", "0.5732128", "0.5730223", "0.5726902", "0.57142395", "0.5706132", "0.5698543", "0.5695152", "0.5695152", "0.5695152", "0.5695152", "0.5691024", "0.5679567", "0.5677053", "0.56626374", "0.564098", "0.5638029", "0.56274706", "0.56274706", "0.56238353", "0.5622375", "0.56134546", "0.5610406", "0.5606929", "0.5606929", "0.55920875", "0.558754", "0.558316", "0.5581567", "0.55801857", "0.55801857", "0.55801857", "0.5574916", "0.5565226", "0.5537804", "0.55368245", "0.5533965", "0.55246174", "0.55239487", "0.55191666", "0.55186343", "0.5515763", "0.5515763", "0.5509752" ]
0.0
-1
Define our authenticate token
def authenticate_token authenticate_with_http_token do |token, options| @current_user = User.find_by(token: token) @current_user end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def authentication_token\n generate_token(:authentication_token)\n end", "def authenticate_token\n authenticate_with_http_token do |token, options|\n token == 'ABC'\n end\n end", "def token_auth(*args, &block); end", "def token\n authenticated\n end", "def token_auth\n Hash['type' => 'token',\n 'token' => @token,]\n end", "def token\n authenticate_username_password || render_unauthorized\n end", "def authenticate_token \n\t\tauthenticate_with_http_token do | token, options| \n\t\t\tUser.find_by(auth_token: token)\n\t\tend\n\tend", "def token(auth_code = T.unsafe(nil), headers = T.unsafe(nil)); end", "def token\n authenticate_username_password || render_unauthorized\n end", "def authentication_token\n @authentication_token ||= JWT.encode(payload, secret, algorithm)\n end", "def authenticate\n \n authenticate_token || render_unauthorized\n end", "def auth_token\n TokenProvider.issue_token(\n first_name: object.first_name,\n last_name: object.last_name,\n username: object.username,\n user_id: object.id,\n role: object.role\n )\n end", "def authenticate\n authenticate_token || render_unauthorized\n end", "def authentication_token\n @authentication_token ||= OohAuth::Token.first(:token_key=>token)\n end", "def authenticate!\n Authenticator.verify!(params['token'])\n end", "def authenticate\n authenticate_token || render_unauthorized\n end", "def authenticate_token\n @is_authenticated = false\n if request.headers[\"TOKEN\"]\n if request.headers[\"TOKEN\"] == \"AppDipre\"\n @is_authenticated = true\n end\n end\n end", "def authenticate_token\n @is_authenticated = false\n if request.headers[\"TOKEN\"]\n if request.headers[\"TOKEN\"] == \"AppDipre\"\n @is_authenticated = true\n end\n end\n end", "def token(request)\n end", "def authenticate_token\n render_401 if @token.blank? || !@token.active?\n end", "def auth_token\n @auth_token ||= ActionController::HttpAuthentication::Token.token_and_options(request)\n end", "def authenticate\n\t\tauthenticate_token || render_unauthorized\n\tend", "def generate_authentication_token\n self.auth_token = User.new_token\n\t\t\tself.auth_expires_at = Time.now + 240.hours\n\tend", "def token_handler(token, options)\n authentication = TokenAuthenticateMe::Authentication.new(token: token)\n authentication.authenticate(options)\n end", "def api_token\n if @token.nil?\n raise ArgumentError, 'username is missing' if username.blank?\n raise ArgumentError, 'password is missing' if password.blank?\n response = connection.post do |req|\n req.url '/Authentication/V2.0'\n req.headers['x-dnb-user'] = username\n req.headers['x-dnb-pwd'] = password\n end\n @token = response.headers['Authorization']\n end\n @token\n end", "def initialize\n @token_type = 'bearer'\n end", "def ensure_authentication_token\n self.authentication_token ||= generate_authentication_token\n end", "def auth_token\n auth_token_for(DEFAULT_AUTH_TOKEN_KEY)\n end", "def assign_authentication_token\n self.authentication_token = generate_authentication_token\n end", "def authenticate\n authenticate_or_request_with_http_token do |token _options|\n @current_user = User.find_by token: token\n end\n end", "def authenticate!\n error!(\"401 Unauthorized\", 401) unless check_auth_token \n end", "def authenticate_token\n authenticate_with_http_token do |token, options|\n User.find_by(auth_token: token)\n end\n end", "def authentication_token\n @authentication_token ||= authorization_header.gsub(BEARER_PATTERN, '')\n end", "def authenticate\n token = CrownAuthenticate.new().token\nend", "def token_secret; end", "def token_secret; end", "def token_secret; end", "def ensure_authentication_token\n self.authentication_token ||= generate_authentication_token\n end", "def ensure_authentication_token\n if authentication_token.blank?\n self.authentication_token = generate_authentication_token\n end\n end", "def tokenizing\n authenticate_api || unauthorized_api\n end", "def authenticate_token!\n return render_error(\"Problem with Authentication Token\",401, 401) unless Token.find_by(access_token: params[:access_token])\n end", "def authenticate_with_api_key\n\t @current_bearer = authenticate_with_http_token &method(:authenticator)\n\t end", "def auth_token\n @@auth_token\n end", "def authenticate\n # if valid_access_token?\n # fetch_access_token\n # else\n get_new_access_token\n # end\n end", "def authenticate_with_api_key!\n \t\t@current_bearer = authenticate_or_request_with_http_token &method(:authenticator)\n \tend", "def authenticate!\n if !authenticated?\n response = request_token\n\n @token = response[\"token\"]\n @expires_at = DateTime.parse(response[\"expires_at\"])\n end\n\n [@token, @expires_at]\n end", "def auth_token(opts = {})\n get_config_auth_token() || create_authorization(opts)\n end", "def request_token\n self.token = Pivotal::Client.fetch_token(email, password)\n end", "def authenticate_token\n render json: {message: \"Unauthorized\"}, status: 401 unless decode_token(bearer_token)\n end", "def auth_param; end", "def authenticate\n unless FfcrmVend.config.token == params[:token]\n render :text => \"\", :status => :unauthorized\n end\n end", "def authenticate\n authenticate_token || render_unauthorized\nend", "def auth_token\n @auth_token ||= request.headers.fetch('Authorization', '').split(' ').last\n end", "def create_set_and_add_token\n token = SecureRandom.urlsafe_base64\n @user.token = token\n response.headers['X-AUTH-TOKEN'] = token\n end", "def login_by_token\n\n end", "def ensure_authentication_token\n if authentication_token.blank?\n self.authentication_token = generate_authentication_token\n end\n end", "def token\n\n authenticate_with_http_basic do |email, password|\n user = User.find_by(email: email)\n if user && user.authenticate(password) \n render json: { token: user.api_token }\n else\n render json: { error: 'Incorrect credentials' }, status: 401\n end\n\n end\n end", "def make_auth_token\n Carto::Common::EncryptionService.make_token(length: 64)\n end", "def token_secret=(_arg0); end", "def token_secret=(_arg0); end", "def token_secret=(_arg0); end", "def auth(value); end", "def auth_token_param\n params[:auth_token]\n end", "def set_auth_token\n return if auth_token.present?\n self.auth_token = generate_auth_token\n end", "def authenticate\n auth_token =\n AuthenticateUser.new(auth_params[:email], auth_params[:password]).call\n # kindly refactor and add more keys to the response object when needed\n response = { \n status: Message.success,\n data: {\n token: auth_token\n } \n }\n json_response(response, 200)\n end", "def token_secret; config[:token_secret]; end", "def authenticate_user!\n token, options = ActionController::HttpAuthentication::Token.token_and_options(request)\n\n super unless token == 'rbMmEeoH8RxRDyN24PQv'\n end", "def authenticate\n \n authenticate_or_request_with_http_token do |token|\n begin\n decoded = decode(token)\n @current_user = User.find_by(id: decoded[0][\"user_id\"]) \n \n rescue JWT::DecodeError\n render json: {authorized: false }, status: 401 \n end\n end \n end", "def token; config[:token]; end", "def token\n end", "def principal_token=(token)\n end", "def auth_token(auth)\n validate_auth(auth, %i[token])\n auth[:token]\n end", "def request_token\n @token=current_client_application.create_request_token\n if @token\n render :text=>@token.to_query\n else\n render :nothing => true, :status => 401\n end\n end", "def authenticate\n #render :text => params[:action]\n if (params[:controller] != \"api/sessions\")\n if (params[:controller] == \"api/users\" && params[:action] == \"create\")\n return\n end\n user = User.find_by(token: params[:token])\n if !user || user.valid_up < DateTime.now\n render json: '{\"error\":\"Unauthorized\"}', status: 401\n end\n end\n if (params[:controller] == \"api/sessions\" && params[:action] == \"chekToken\")\n user = User.find_by(token: params[:token])\n if !user || user.valid_up < DateTime.now\n render json: '{\"error\":\"Unauthorized\"}', status: 401\n end\n end\n #\"controller\":\"users\",\"action\":\"show\",\"id\":\"login\" si se va a registrar dejar pasar\n #@product = '[{\"mytoken\":\"'+params[:token]+'\"}]'\n # if !User.find_by(token: params[:token])\n # #render json: '[{\"error\":\"Unauthorized\"}]', status: 401\n # end\n end", "def initialize\n auth_login_response = auth.login_with_token(EbanqApi.token,\n EbanqApi.secret)\n @auth_token = auth_login_response['token']\n end", "def authenticate_user_from_token!\n auth_token = request.headers['Authorization']\n\n if auth_token\n authenticate_with_auth_token auth_token\n # else\n # authentication_error\n end\n end", "def setup_token\n token = SecureRandom.hex(16)\n @token = token\n token\n end", "def ensure_authentication_token\n if authentication_token.blank?\n self.authentication_token = generate_authentication_token\n end\n end", "def ensure_authentication_token\n if authentication_token.blank?\n self.authentication_token = generate_authentication_token\n end\n end", "def ensure_authentication_token\n if authentication_token.blank?\n self.authentication_token = generate_authentication_token\n end\n end", "def generate_token\n new_token =\n SimpleTokenAuthentication::TokenGenerator.instance.generate_token\n update(authentication_token: new_token)\n self\n end", "def get_authentication_header\n \"#{token_type} #{token}\"\n end", "def set_auth_token(token)\n @auth_token = token.to_s\n end", "def token\n request.headers[\"Authorization\"]\n end", "def authenticate\n token_id = AuthenticateUser.new(auth_params[:email], auth_params[:password]).user.token_id\n token = Token.find token_id\n if token.created_at < Time.now - 1.hour\n raise(\n ExceptionHandler::InvalidToken,\n (\"#{Message.expired_token} #{e.message}\")\n )\n end\n json_response(token: token.token)\n end", "def authenticate_with_token\n # get the token from the header\n # get the token from the post body\n # get the token from json post\n \n token = request.headers[\"HTTP_AUTHORIZATION\"]\n \n if (!token)\n if (not_protected self.controller_name, self.action_name)\n return nil\n end\n\n redirect_to controller: 'application', action: 'index' \n end\n\n #@user = get_user_by_token(token)\n end", "def w000thenticate\n check_token\n end", "def initialize\n setup_token\n end", "def create_auth_token(key)\n\t\tself.auth_token = Digest::SHA1.hexdigest(\"#{random_string}--#{Time.now}---#{key}\")\n\tend", "def generate_auth_token\n self.auth_token = SecureRandom.hex\n end", "def authToken(secretkey)\n # get 'authToken', {secretkey: secretkey} { |x| x['authToken'] }\n new_auth_token\n end", "def token\n request.headers['Authorization']\n end", "def authenticate_api_token\n if request.headers[\"Authorization\"].present?\n \n auth_header = request.headers['Authorization'].split(' ').last\n \n #try to get the data from jwt token\n @payload = decode auth_header\n \n #couldnt get data for whatever reason\n if !@payload\n render json: { error: \"Problem med autentiseringssträngen. Försök att logga in igen.\" }, status: :bad_request \n #success!\n else\n @payload\n end\n #no token was sent with header \n else\n render json: { error: \"En autentiseringssträng krävs.\"}, status: :forbidden # The header isn´t present\n end\n end", "def set_token\n @token ||= request.env[\"omniauth.auth\"].credentials.token\n end", "def set_AuthenticationToken(value)\n set_input(\"AuthenticationToken\", value)\n end", "def set_AuthenticationToken(value)\n set_input(\"AuthenticationToken\", value)\n end", "def request_token\n @token = current_client_application.create_request_token\n if @token\n render :text => @token.to_query\n else\n render :nothing => true, :status => 401\n end\n end", "def token\n validate_arguments!\n\n display Turbot::Auth.api_key\n end", "def set_internal_token!\n self.token ||= generate_token\n end", "def authenticator_token\n @authenticator ||= self.get_authenticator_token\n end" ]
[ "0.80306274", "0.7988433", "0.79778945", "0.78356504", "0.7763641", "0.7677836", "0.76623094", "0.7605179", "0.7595217", "0.75554085", "0.7550475", "0.7494795", "0.7475905", "0.74648124", "0.7432958", "0.7426934", "0.7401358", "0.7401358", "0.73334134", "0.7332143", "0.7321109", "0.73113835", "0.7305701", "0.7304225", "0.7302551", "0.7285848", "0.72857326", "0.7279999", "0.7269576", "0.7254641", "0.72488624", "0.7231391", "0.7227795", "0.7227642", "0.72217447", "0.72217447", "0.72217447", "0.7220798", "0.71967006", "0.71822417", "0.7160859", "0.7159513", "0.715859", "0.71565497", "0.71544224", "0.71525186", "0.7150967", "0.71492213", "0.7146183", "0.714616", "0.7126794", "0.7121636", "0.7120605", "0.7114015", "0.710714", "0.7093171", "0.70901245", "0.70890826", "0.70841277", "0.70841277", "0.70841277", "0.70802855", "0.70742965", "0.7058185", "0.7056708", "0.7056622", "0.7051052", "0.7044966", "0.704223", "0.70377463", "0.7016995", "0.70081335", "0.7003869", "0.69939023", "0.699075", "0.6982768", "0.6952039", "0.6951039", "0.6951039", "0.6951039", "0.6949641", "0.69478315", "0.6945737", "0.6943004", "0.6941862", "0.6937775", "0.69281787", "0.69280374", "0.69276434", "0.69275033", "0.69261956", "0.6921564", "0.6919235", "0.6915912", "0.6915815", "0.6915815", "0.6910008", "0.6903794", "0.68936116", "0.6892908" ]
0.7236569
31
define what happens If user is unauthorized
def render_unauthorized logger.debug " *** UNAUTHORIZED REQUEST: '#{request.env['HTTP_AUTHORIZATION']}' ***" self.headers['WWW-Authenticate'] = 'Token realm="Application"' render json: {error: "Bad credentials"}, status: 401 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def unauthorized\n end", "def unauthorized\n\n render_error( :unauthorized )\n\n end", "def unauthorized\n head :unauthorized\n end", "def unauthenticated\n end", "def rescue_unauthorized\n render nothing: true, status: 403\n end", "def rescue_unauthorized\n render nothing: true, status: 403\n end", "def unauthorised\n flash[:notice] = 'Unauthorised operation. Please try another option '\n redirect_to robots_path\n end", "def access_denied\n end", "def user_not_authorized\n redirect_to((request.referrer || root_path) ,notice: \"Authorization error.\")\n end", "def unauthorized_user!\n if @user != current_user\n redirect_to root_path, status: :unauthorized, alert: 'You can only perform this action on your own user!'\n end\n end", "def access_denied\n\n end", "def user_not_authorized\n \tflash[:alert] = \"You are not authorized to perform this action.\"\n \tredirect_to(request.referrer || root_path)\n end", "def unauthorized\n render_json error: 'Access Not Authorized', status: :forbidden\n end", "def unauthorized\n render :text => \"You are not authorized to perform this action\", :status => 401\n end", "def unauthorized\n error(t('messages.generics.errors.access'), 401)\n end", "def user_not_authorized\n flash[:danger] = \"Access denied.\"\n redirect_to (request.referrer || root_path)\n end", "def user_not_authorized\n flash[:warning] = \"You are not authorized to perform this action.\"\n redirect_to(request.referrer || root_path)\n end", "def user_not_authorized\n flash[:alert] = \"Vous n'êtes pas autorisé à exécuter cette action.\"\n redirect_to(root_path)\n end", "def skip_authorization; end", "def user_not_authorized\n flash[:alert] = t('messages.non_authorized_action')\n redirect_to(request.referrer || root_path)\n end", "def not_authorized\n redirect_to home_path\n flash[:error] = \"You are not authorized to do that.\"\n end", "def access_denied\n render status: 401, text: \"nice try\"\n end", "def authorization_denied\n head :unauthorized\n end", "def user_not_authorized\n flash[:alert] = \"Access denied.\"\n redirect_to (request.referrer || root_path)\n end", "def is_not_authorized?\n @code == 401\n end", "def user_not_authorized\n #flash[:alert] = \"You are not cool enough to do this - go back from whence you came.\"\n redirect_to root_path\n end", "def user_not_authorized\n flash[:alert] = \"You are not authorized to perform that action.\"\n redirect_to(request.referrer || root_path)\n end", "def unauthorized\n render :json => \"You are not authorized for access.\", :status => :unauthorized\n end", "def user_not_authorized\n flash[:alert] = \"You are not authorized to perform this action.\"\n redirect_to(request.referrer || root_path)\n end", "def unauthorized\n flash[:alert] = \"You are not authorized to view that page.\"\n redirect_to '/'\n end", "def unauthorized_access\n flash[:notice] = \"Unauthorized access\"\n redirect_to \"/\"\n return false\n end", "def user_not_authorized\n flash[:alert] = \"You are not authorized to perform this action.\"\n redirect_to root_path\n end", "def user_not_authorized\n flash[:alert] = \"You are not authorized to perform this action.\"\n redirect_to(root_path)\n end", "def not_authorized\n flash[:error] = I18n.t :forbidden\n response.headers['Status-Code'] = '403'\n redirect_to root_path\n end", "def denied\n end", "def not_authorised\n flash[:notice] = 'You are not authorized to perform this action!'\n redirect_back(fallback_location: root_path)\n end", "def unauthorized_request(e)\n\t\tjson_response({ message: e.message }, :unauthorized)\n\tend", "def unauthorized_access_response(err)\n error_with_data(\n err,\n 'unauthorized_access_response',\n GlobalConstant::ErrorAction.default\n )\n end", "def user_not_authorized\n respond_to do |format|\n format.json do\n render json: ErrorReport.generate( { id: [t(\"errors.messages.not_authorized\")] }, 403 ), status: :forbidden\n end\n end\n end", "def access_denied\n head 401\n end", "def unauthorized_request(e)\n json_response({ message: e.message }, :unauthorized)\n end", "def unauthorized\n render \"errors/401\", :status => 401\n\tend", "def render_unauthorized(message)\n head :unauthorized\n end", "def not_allowed! redirect = root_url\n raise Exceptional::Unauthorized.new(\"Sorry, I was could not perform the action you requested!\")\n end", "def unauthorized\n render json: {error: 'Unauthorized'}, status: 401\n end", "def access_denied!\n render partial: 'errors/401', status: 401 && return\n end", "def login_required\nauthorized? || access_denied\nend", "def restrict_access\n head :unauthorized and return false unless current_user\n end", "def user_not_authorized\n flash[:alert] = I18n.t('pundit.default')\n redirect_to(request.referrer || authenticated_root_path || unauthenticated_root_path)\n end", "def unauthorized\n reset_session\n flash[:alert] = \"You are Not Authorized to View this Page. Your Session has expired !!!\"\n render :login\n end", "def require_authorization( message=\"You are not authorized to access this resource.\" )\n\t\tfinish_with( HTTP::FORBIDDEN, message )\n\tend", "def access_denied\n respond_to do |format|\n format.html {\n flash[:error] = \"Sie sind nicht angemeldet oder nicht berechtigt, auf die angeforderte Seite zuzugreifen.\"\n render text: \"\", layout: true, status: :unauthorized\n }\n \n format.any {\n head status: :unauthorized\n }\n end\n end", "def user_not_authorized(exception)\n\t\tpolicy_name = exception.policy.class.to_s.underscore\n\t\tredirect_to current_user_root_path, alert: I18n.t(\"pundit.#{policy_name}.#{exception.query}\")\n\tend", "def skip_authorization\n @_authorization_performed = true\n end", "def access_denied\n if @current_user\n render_401\n else\n redirect_to \"#{FUSESOURCE_URL}/login?return_to=#{external_url_to(request.request_uri)}\"\n end\n end", "def unauthorized\n [ 401, {'Content-Type' => 'text/plain', 'Content-Length' => '13'},\n ['Unauthorized.'] ]\n end", "def block_unauthenticated_user!\n unless current_user\n return render_unauthorized\n end\n end", "def authorize_unauthenticated_user\n target_action = params[:controller] + '#' + params[:action]\n unless User::DEFAULT_PERMISSIONS.include?(target_action)\n head :unauthorized and return\n end\n end", "def unauthorized_request(e)\n json_response({ message: e.message }, :unauthorized)\n end", "def unauthorized_request(e)\n json_response({ message: e.message }, :unauthorized)\n end", "def access_forbidden\n if !@authenticated.nil?\n send_response_document :forbidden\n else\n flash.keep\n authentication_needed!\n end\n end", "def unauthenticated\n render_json status: :unauthorized\n end", "def redirect_unauthorized!\n redirect_to not_authorized_path\n end", "def not_authorized\r\n render :file => 'public/401.html', :status => 401, :layout => false\r\n end", "def unauthorized\n respond_to do |format|\n format.html do\n if admin?\n flash.now[:error] = I18n.t(:authorization_failure)\n redirect_to login_path and return\n elsif current_user || admin?\n flash.now[:error] = I18n.t(:authorization_failure)\n render 'shared/unauthorized'\n else\n store_location\n redirect_to login_path and return\n end\n end\n format.xml do\n request_http_basic_authentication 'Web Password'\n end\n format.json do\n render :text => \"Not Authorized \\n\", :status => 401\n end\n end\n end", "def unauthorized_request(e)\n render json: { message: e.message }, status: :unauthorized\n end", "def unauthorized_request(e)\n render json: { message: e.message }, status: :unauthorized\n end", "def unauthorized_error\n error!(\"401 Unauthorized\", 401)\n end", "def umn_access_denied\n redirect_to(login_and_redirect_url)\n end", "def not_auth(status = :unauthorized)\n render json: {\n result: 'Error',\n message: 'Unauthorized Access',\n status: 'Unauthorized'\n }, status: status\n end", "def failure(oid, request, session)\n unauthorized\n end", "def unauthorized\n @email = session_user.cas_email\n end", "def unauthorized_request(err)\n json_response({ message: err.message }, :unauthorized)\n end", "def access_denied\n {\n :html => 'Sorry, we cannot verify that you are a user. Please reinstall this Raplet.',\n :status => 401\n }\n end", "def user_not_authorized(exception)\n wiki_policy = exception.policy.class.to_s.underscore\n\n flash[:alert] = \"You are not authorized to do that!\"\n redirect_to(request.referrer || root_path)\n end", "def access_denied\n clear_session\n redirect_to login_path and return false\n end", "def user_not_authorized(exception)\n case exception.query\n when 'approve?',\n 'can_add_attachment?',\n /^add_response_to_flagged_case/,\n 'upload_responses?',\n 'update_closure?'\n super(exception, case_path(@case))\n else\n super\n end\n end", "def not_authorized\n redirect_to volunteer_positions_url, alert: \"You are not authorized to perform the requested action!\"\n end", "def login_required\n authorized? || access_denied\n end", "def login_required\n authorized? || access_denied\n end", "def login_required\n authorized? || access_denied\n end", "def not_authorized(msg = \"Access Denied. You don't have access to this resource.\")\n flash[:error] = msg\n redirect_to root_path\n end", "def access_denied\n case content_type\n when :html\n store_location\n redirect url(:login)\n when :xml\n headers[\"Status\"] = \"Unauthorized\"\n headers[\"WWW-Authenticate\"] = %(Basic realm=\"Web Password\")\n set_status(401)\n render :text => \"Couldn't authenticate you\"\n end\n end", "def unauthorized_request(e)\n render json: jsonData(e), status: :unauthorized\n end", "def access_denied\n store_location\n redirect_to root_path(:target => request.request_uri)\n #respond_to do |format|\n # format.json do\n # render :partial => \"json/response\",\n # :locals => {\n # :success => false,\n # :message => \"Authorization Required\",\n # :body => nil}\n # end\n # format.html do \n # redirect_to root_path#(:after_login => request.request_uri)\n # end\n #end\n end", "def login_required\n authorized? || throw(:halt, :access_denied)\n end", "def user_not_authorized(exception)\n clear_session_and_token_data\n\n redirect_to root_url, flash: { error: \"It appears you are not provisioned with the proper permissions to access the MMT for Non-NASA Users. Please try again or contact #{view_context.mail_to('support@earthdata.nasa.gov', 'Earthdata Support')}.\" }\n end", "def access_denied\n redirect_to main_app.root_url, alert: \"Not authorized\"\n end", "def access_denied\n redirect '/login'\n end", "def user_not_authorized(exception)\n render json: {\n error: \"Unauthorized #{exception.policy.class.to_s.underscore.camelize}.#{exception.query}\"\n }, status: :unauthorized\n end", "def deny_wrong_user\n redirect_to signin_path, notice: \"Sorry, you can't access that page.\"\n end", "def render_must_sign_in\n render status: :unauthorized\n end", "def unauthorized_entity(entity_name)\n render json: {error: 'Unauthorized request'}, status:\n :unauthorized\n end", "def authenticate\n logged_in? || access_denied\n end", "def access_denied\n case content_type\n when :html\n store_location\n redirect url(:login)\n when :xml\n basic_authentication.request\n end\n end", "def authorize!(user)\n redirect '/not_authorized' unless authorized?(user)\nend", "def access_denied\n store_location\n if session[:userid]\n redirect_to :new_user\n else\n redirect_to :login\n end\n end", "def access_denied\n redirect_to login_path, :notice => \"Veuillez vous enregistrer pour continuer\" and return false\n end", "def check_is_login_required\n authorized_denied unless logged_in?\n end", "def authorize\n (render :json => { :error => \"Authentication error\" }, :status => :unauthorized and return) unless User.current.present?\n authorized ? true : deny_access\n end", "def not_authenticated\n\t\tredirect_to new_session_path, :alert => \"Please login first.\"\n\tend" ]
[ "0.8591791", "0.8004358", "0.7894204", "0.78164095", "0.77745914", "0.77745914", "0.77708644", "0.7736684", "0.7720517", "0.7718378", "0.77095544", "0.76775473", "0.7623666", "0.75876665", "0.75839794", "0.7555163", "0.7525265", "0.75153214", "0.75013334", "0.75005937", "0.7491779", "0.74887085", "0.7426327", "0.7393571", "0.7390007", "0.7382763", "0.7363301", "0.7361345", "0.7359865", "0.73313195", "0.73234624", "0.73017967", "0.72948366", "0.72759396", "0.7268611", "0.7266501", "0.7249825", "0.72405356", "0.7237461", "0.7221513", "0.72103244", "0.72045994", "0.7196882", "0.7187971", "0.71749324", "0.7159317", "0.71562", "0.7154759", "0.71492094", "0.71445376", "0.71386904", "0.7136455", "0.7134232", "0.71224135", "0.711189", "0.7108478", "0.7101787", "0.7099847", "0.70995456", "0.70995456", "0.7099397", "0.709821", "0.70887893", "0.7068385", "0.7067819", "0.7061974", "0.7061974", "0.70588344", "0.7054038", "0.7039917", "0.7031795", "0.7026842", "0.7024451", "0.7021877", "0.70139307", "0.70127606", "0.69967794", "0.69821036", "0.69552714", "0.69552714", "0.69552714", "0.69472957", "0.6945784", "0.69428056", "0.6940457", "0.69230014", "0.6922102", "0.6915262", "0.6904055", "0.6902923", "0.69021297", "0.68892145", "0.68844956", "0.68838334", "0.6881538", "0.6877592", "0.6871564", "0.6868754", "0.68681467", "0.68634915", "0.68544906" ]
0.0
-1
Subject can be set in your I18n file at config/locales/en.yml with the following lookup: en.student_notify.notification.subject
def notification(user,fname,grade, comment,labname) @grade = grade @fname = fname @comment = comment @lab_name = labname mail(to: user, subject: 'Lab Grade') end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def translate(mapping, key)\n I18n.t(:\"notifications_subject\", :scope => [:eventifier, :notifications, key],\n :default => [:subject, key.to_s.humanize])\n end", "def subject (recipient)\n subject_variables = alert_variables[:subject].dup\n subject_variables.merge!(recipient_details(recipient))\n subject = \"#{I18n.t(\"#{recipient_type.to_s}_subject_#{alert_name.to_s}\", subject_variables)}\"\n subject\n end", "def message_subject=(value)\n @message_subject = value\n end", "def subject\n self['subject'] || msg['subject']\n end", "def translate(mapping, key)\n I18n.t(:\"#{mapping.name}_subject\", :scope => [:devise, :mailer, key],\n :default => [:subject, key.to_s.humanize])\n end", "def course_notification_item_details(course)\n t('notifications.subscribe_course')\n end", "def subject=(subject); @message_impl.setSubject subject; end", "def subject\n @subject ||= Envelope::MessageTools.normalize(message.subject || '')\n end", "def subject_for(template, attributes = {})\n subject = EmailTemplate.subject_for(template)\n subject = I18n.t(\"email_templates.#{template}.default_subject\") if subject.nil?\n subject = \"No Subject\" if subject.nil?\n Florrick.convert(subject, add_default_attributes(attributes))\n end", "def subject=(string)\n set('Subject', string)\n end", "def notification_msg\n author_name = author.firstname\n \"An issue has been reported by #{author_name}\"\n end", "def formatted_subject(text)\n name = PersonMailer.global_prefs.app_name\n label = name.blank? ? \"\" : \"[#{name}] \"\n \"#{label}#{text}\"\n end", "def subject() self.headers[\"Subject\"] || \"[NO SUBJECT]\" end", "def subject\n @mail.subject\n end", "def subject_name\n subject_full_name\n end", "def notify(type,subject,target=nil)\n self.notices.create :type => type, :subject => subject, :target => target\n end", "def subject\n self['subject']\n end", "def subject\n @subject ||= \"(sans sujet)\"\n if @no_header_subject.nil?\n \"#{header_subject}#{@subject}\"\n else\n @subject\n end\n end", "def notify(msg, subject)\n end", "def subject_name=(value)\n @subject_name = value\n end", "def create_notification\n subject = \"#{student_request.name} \"\n body = \"#{student_request.name} (#{student_request.email}) needs tutorial.\"\n tutor_request.notify(subject, body, self)\n end", "def message_subject\n return @message_subject\n end", "def subject\n message.subject\n end", "def subject=(value)\n @subject = value\n end", "def subject=(value)\n @subject = value\n end", "def subject=(value)\n @subject = value\n end", "def subject=(value)\n @subject = value\n end", "def subject=(value)\n @subject = value\n end", "def subject=(value)\n @subject = value\n end", "def subject_name\n return @subject_name\n end", "def subject; @message_impl.getSubject; end", "def subject\n @options.fetch(:subject) { \"Invitation\" }\n end", "def set_EmailSubject(value)\n set_input(\"EmailSubject\", value)\n end", "def set_EmailSubject(value)\n set_input(\"EmailSubject\", value)\n end", "def set_subject(subject)\n\t\tend", "def subject\n title \n end", "def default_i18n_subject(interpolations = {})\n ''\n end", "def set_Subject(value)\n set_input(\"Subject\", value)\n end", "def set_Subject(value)\n set_input(\"Subject\", value)\n end", "def set_Subject(value)\n set_input(\"Subject\", value)\n end", "def set_Subject(value)\n set_input(\"Subject\", value)\n end", "def set_Subject(value)\n set_input(\"Subject\", value)\n end", "def set_Subject(value)\n set_input(\"Subject\", value)\n end", "def set_Subject(value)\n set_input(\"Subject\", value)\n end", "def set_Subject(value)\n set_input(\"Subject\", value)\n end", "def set_EmailSubject(value)\n set_input(\"EmailSubject\", value)\n end", "def set_EmailSubject(value)\n set_input(\"EmailSubject\", value)\n end", "def get_subject\n\t\tend", "def subject_titles\n @subject_titles ||= sw_subject_titles\n end", "def question_notification(asker, subject, details)\n @asker = asker\n @subject = subject\n @details = details\n\n mail to: \"Alex Yang <alexyang.personal@gmail.com>\",\n from: \"BaseRails <notifications@baserails.com>\",\n subject: \"#{asker} posted a new question on BaseRails\"\n end", "def setSubject(subject)\n @fields['subject'] = subject\n self\n end", "def setSubject(subject)\n @fields['subject'] = subject\n self\n end", "def setSubject(subject)\n @fields['subject'] = subject\n self\n end", "def setSubject(subject)\n @fields['subject'] = subject\n self\n end", "def email_subject\n sponsor_name = @config.plan.sponsor_name\n display_date = @date.to_s()\n if @config.div_id.present?\n email_subject = \"Payroll report for #{sponsor_name} for division #{@config.division_name}: #{display_date}\"\n else\n email_subject = \"Payroll report for #{sponsor_name}: #{display_date}\"\n end\n return email_subject\n end", "def deliver_invitation(options = {})\n super(options.merge(subject: _('A Data Management Plan in %{application_name} has been shared with you') % {application_name: Rails.configuration.branding[:application][:name]}))\n end", "def notify_course_teaching_assignment( user , course ) \n @course = course\n @subject = @course.subject \n @school = @subject.school\n @user = user\n mail( :to => user.email, \n :subject => \"potoSchool | Tuga Mengajar pelajaran #{@subject.name}, kelas #{@course.name} \" )\n end", "def email_subject(form)\n \"#{form.type_of_enquiry} - #{reference}\"\n end", "def new_notification_email(notification,receiver)\n @notification = notification\n @receiver = receiver\n #DIFFERENT FROM ORIGINAL----------------------\n subject = notification.subject.to_s\n subject = decode_basic_notification(subject,notification.notified_object)\n subject = subject.gsub(/\\n/,'')\n #END OF DIFFERENCE----------------------------\n subject = strip_tags(subject) unless subject.html_safe?\n mail(:to => receiver.send(Mailboxer.email_method,notification), :subject => t('mailboxer.notification_mailer.subject', :subject => subject)) do |format|\n format.text {render __method__}\n format.html {render __method__}\n end\n end", "def course_notification\n @course = Course.first\n @teacher = @course.teachers.first\n @students = @course.students\n @title = \"一个好消息\"\n @content = \"今天不上课\\n大家好好休息\"\n NotificationMailer.course_notification @teacher, @course, @students, @title, @content\n end", "def notice(notification)\n @notification = notification\n\n mail to: @notification.user_email, :subject => \"Cipher-tech wants you to know: #{@notification.notifier_type} #{@notification.message}\"\n end", "def title_for_user_applied_to_travel\n I18n.t(\"notification.user_applied_to_travel.title\")\n end", "def SetSubject(subject)\n\t\t#Subject of document\n\t\t@subject = subject\n\tend", "def course_notification_card_text(course)\n t('notifications.new_course_created_html', title: course.title)\n end", "def mmm_test_subj_call\n ->(candidate) { I18n.t('email.test_monthly_mail_subject_initial_input', candidate_account_name: candidate.account_name) }\n end", "def push_message_title\n case notification_type\n when 'conversation_creation'\n I18n.t('notifications.notification_title.conversation_creation', display_id: primary_actor.display_id, inbox_name: primary_actor.inbox.name)\n when 'conversation_assignment'\n I18n.t('notifications.notification_title.conversation_assignment', display_id: primary_actor.display_id)\n when 'assigned_conversation_new_message'\n I18n.t(\n 'notifications.notification_title.assigned_conversation_new_message',\n display_id: conversation.display_id,\n content: primary_actor.content&.truncate_words(10)\n )\n when 'conversation_mention'\n \"[##{conversation.display_id}] #{transform_user_mention_content primary_actor.content}\"\n else\n ''\n end\n end", "def subject_names\n @subject_names ||= sw_subject_names\n end", "def get_email_subject(email_type)\n email_subject = email_type\n case(email_type)\n when \"welcome\"\n email_subject = \"Welcome to Aspera Files\"\n when \"reset\"\n email_subject = \"Password Reset\"\n end\n return email_subject\n end", "def subject\n 'Report a problem'.freeze\n end", "def choose_subject(action, params = {})\n scope = [:mailers, mailer_name, action]\n key = :subject\n experiment_name = \"#{mailer_name}_mailer_#{action}_subject\".to_sym\n if experiment_active?(experiment_name)\n scope << key\n key = ab_test(experiment_name)\n end\n params.merge!(scope: scope)\n I18n.t(key, params)\n end", "def ezm_subject_and_status(message)\r\n if message.receiver_deleted?\r\n message.subject + \" (Deleted)\" \r\n elsif message.read_at.nil?\r\n message.subject + \" (Unread)\" \r\n else \r\n message.subject\r\n end\r\n end", "def i18n_label\n \"email.#{name}_label\"\n end", "def title_for_received_review\n I18n.t(\"notification.user_received_review.title\")\n end", "def subject(options)\n case [options[:person], options[:plurality]]\n when %i[first singular]\n 'I'\n when %i[first plural]\n 'we'\n when %i[second singular], %i[second plural]\n 'you'\n when %i[third singular]\n 'he'\n when %i[third plural]\n 'they'\n end\n end", "def compose_email\n @title = t 'conclusion_draft_review.send_by_email'\n end", "def subject\n @subject\n end", "def subject\n @subject\n end", "def set_subject_and_message(form, subject, message)\n raise Impostor::MissingTemplateMethodError.new(\"set_subject_and_message must be implemented\")\n end", "def subject\n @subject=EzCrypto::Name.new(@cert.subject) unless @subject\n @subject\n end", "def notify_english(dest)\n mail(dest, ENGLISH_SUBJECT, mail_content(english_model_file))\n end", "def set_title\n @title = t(:message_2, :scope => [:controller, :exams])\n end", "def send_ta_notification(user, msg)\n\t\t@user = user\n\t\t@msg = msg\n\t\tmail( :to => @user.email, :subject => 'You have just been assigned to a course!')\n\tend", "def subject\n raise \"Override #subject in the service class\"\n end", "def data_subject=(value)\n @data_subject = value\n end", "def raf_submitted(study_subject)\n#\t\t@greeting = \"Hi\"\n\t\t@study_subject = study_subject\n\n\t\tmail to: \"magee@berkeley.edu\"\n\t\tmail cc: [\"jakewendt@berkeley.edu\", \"notifyccls@berkeley.edu\"]\n\t\tmail subject: \"TEST [CCLS Patient Notification Received] Identifier: #{@study_subject.icf_master_id_to_s}\"\n\tend", "def subject(options = {})\n options = { :capitalize => true, :case => Grammar::Case::SUBJECT }.merge(options)\n pronoun_or_noun(@subject, @audience, options)\n end", "def rezm_subject_and_status(message)\n if message.receiver_deleted?\n message.subject + \" (Deleted)\" \n elsif message.read_at.nil?\n message.subject + \" (Unread)\" \n else \n message.subject\n end\n end", "def subject\n @subject\n end", "def email_subject(&blk)\n @email_subject_block = blk if blk\n @email_subject_block\n end", "def subject=(subject)\n self.subjects = [subject]\n end", "def twiki_created_notification(person, options={})\n @person = person\n mail(:to=>[@person.personal_email],\n :subject=>options[:subject] || \"Twiki account information (\"+@person.email+\")\",\n :date=>Time.now)\n end", "def get_subject_name\n subject_name = subject_header.text.sub! 'Subject:', ''\n subject_name = subject_name.strip!\n subject_name\n end", "def send_notification(user, questionnaire)\n I18n.default_locale = I18n.locale = questionnaire.language.locale\n headers = {\n :from => 'Bnei Baruch <internet@kbb1.com>',\n :subject => I18n.t('notification.mailer.new_questionnaire_for_you'),\n :to => user.email,\n :date => Time.now.to_formatted_s(:rfc822)\n }\n @user = user\n @questionnaire = questionnaire\n mail(headers)\n end", "def subject_name\n subject&.name\n end", "def subject_alternative_name\n extensions[R509::Cert::Extensions::SubjectAlternativeName]\n end", "def set_subject\n url = Settings.hqva_mobile.url\n icn = user.icn\n appointment_id = data[:appointment_id]\n\n {\n use: SUBJECT_USE,\n value: \"#{url}/appointments/v1/patients/#{icn}/Appointment/#{appointment_id}\"\n }\n end", "def send_devise_notification(notification, *args)\n I18n.with_locale(locale) { super notification, *args }\n end", "def set_title\n @title = t(:message_0, :scope => [:controller, :scholarships])\n end", "def normalize_subject_name\n self.subject = subject.downcase.titleize\n end", "def subject(*args)\n subject = \"#{Settings['application']['name']} | \"\n subject << args.join(' ') if args.present?\n subject\n end" ]
[ "0.7157698", "0.7098418", "0.70005596", "0.6957115", "0.67419237", "0.66515714", "0.66185635", "0.6615139", "0.6565871", "0.6501085", "0.6434303", "0.6397224", "0.6366727", "0.6330911", "0.63286847", "0.6312967", "0.63118714", "0.63083154", "0.6276631", "0.62706125", "0.6270332", "0.6254126", "0.6253283", "0.62274724", "0.62274724", "0.62274724", "0.62274724", "0.62274724", "0.62274724", "0.62026346", "0.6138665", "0.6134445", "0.61285985", "0.6126724", "0.60929567", "0.60929114", "0.60749984", "0.6064731", "0.6064731", "0.6064731", "0.6064731", "0.6064731", "0.6064731", "0.6064731", "0.6064731", "0.60495025", "0.60474145", "0.5988823", "0.5980883", "0.5980386", "0.59800327", "0.59800327", "0.59800327", "0.59800327", "0.5978585", "0.5977719", "0.5910228", "0.58920956", "0.5876948", "0.5871751", "0.5863893", "0.5821642", "0.581486", "0.5811481", "0.5805608", "0.5804913", "0.5803668", "0.580317", "0.5801091", "0.5772732", "0.5767053", "0.57214653", "0.57180816", "0.5707201", "0.57020456", "0.5678157", "0.5678157", "0.5670755", "0.56702656", "0.5668281", "0.56563264", "0.5641949", "0.56407875", "0.563008", "0.562419", "0.56234616", "0.5605765", "0.56032765", "0.5597379", "0.5591308", "0.55472726", "0.552867", "0.55179447", "0.5514857", "0.5495561", "0.5484709", "0.5474334", "0.5471303", "0.54703885", "0.5465813" ]
0.5610621
86
returns lowest sum of the winning and losing teams' scores
def lowest_total_score total_game_scores = games.map { |game| game.home_goals + game.away_goals} total_game_scores.min end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def winning_scores\n high_score = scores.max{|score| score.total}.total\n scores.select {|score| score.total == high_score}\n end", "def winning_team\n final_scores = player_collection.reduce(home: 0, away: 0) { |teams_points, next_player|\n case \n when next_player[:location] === :away\n teams_points[:away] += next_player[:points];\n when next_player[:location] === :home\n teams_points[:home] += next_player[:points];\n end\n teams_points; \n }\n winner = final_scores.reduce { |highest_points, team_points| \n highest_points[1] > team_points[1] ? highest_points : team_points; \n }\n game_hash[winner[0]][:team_name]; \nend", "def winning_team\n home_team_sum = 0\n away_team_sum = 0\n game_hash.each do |team, team_stats|\n if team_stats[:team_name] == \"Brooklyn Nets\"\n team_stats[:players].each do |player_stats|\n home_team_sum += player_stats[:points]\n end\n elsif team_stats[:team_name] == \"Charlotte Hornets\"\n team_stats[:players].each do |player_stats|\n away_team_sum += player_stats[:points]\n end\n end\n end\n if home_team_sum > away_team_sum\n game_hash[:home][:team_name]\n elsif home_team_sum < away_team_sum\n game_hash[:away][:team_name]\n end\nend", "def winning_team\n home_team_points = game_hash[:home][:players].sum { |e| e[:points] }\n away_team_points = game_hash[:away][:players].sum { |e| e[:points] }\n\n if home_team_points > away_team_points\n return game_hash[:home][:team_name]\n else\n return game_hash[:away][:team_name]\n end\nend", "def winning_team\n nets = []\n hornets = []\n\n game_hash.values.each do |nets_stats|\n if nets_stats[:team_name] == \"Brooklyn Nets\"\n nets_stats[:players].each do |bk|\n nets << bk[:points]\n end\n end\n end\n\n game_hash.values.each do |hornets_stats|\n if hornets_stats[:team_name] == \"Charlotte Hornets\"\n hornets_stats[:players].each do |ch|\n hornets << ch[:points]\n end\n end\n end\n\n if nets.reduce(:+) > hornets.reduce(:+)\n return \"Brooklyn Nets\"\n else\n return \"Charlotte Hornets\"\n end\nend", "def winning_team\n if homeTeamPoints.sum > awayTeamPoints.sum\n \"Brooklyn Nets\"\n else\n \"Charlotte Hornets\"\n end\nend", "def find_best_score(total_per_player)\n best_score = 0\n winner = ''\n total_per_player.each do |player_name,total|\n\n if total > best_score\n best_score = total\n winner = player_name\n end\n end\n return winner\n end", "def winning_team\n team_p = []\n team_n = []\n\n game_hash.each do | location, team_data|\n temp = 0\n team_data[:players].each do |p_name, stats|\n temp += stats[:points]\n end\n team_n << team_data[:team_name]\n team_p << temp\n end\n\n team_p[0] > team_p[1] ? team_n[0] : team_n[1]\n\nend", "def winning_team\n home_score = 0\n away_score = 0\n game_hash[:home][:players].keys.each do |name|\n home_score += game_hash[:home][:players][name][:points]\n end\n game_hash[:away][:players].keys.each do |name|\n away_score += game_hash[:away][:players][name][:points]\n end\n home_score > away_score ? game_hash[:home][:team_name] : game_hash[:away][:team_name]\nend", "def total_team_score(teams_id)\n total_score = 0\n @league_data.each do\n |team| \n # binding.pry\n if team.home_team_id == teams_id\n total_score += team.home_team_score\n elsif team.away_team_id == teams_id\n total_score += team.away_team_score\n end\n end\n return total_score\n end", "def lowest_scoring_visitor\n @teams.min_by { |team| team.average_away_goals }.team_name\n end", "def most_points_scored\n points_scored = 0 # starting score to compare with players shoe sizes\n game_hash.each do |location, team_data| # iterates through each team\n players_array = team_data[:players] # finds the :players info in team_data and puts the players into players_array\n players_array.each do |player_name, data| # iterates through each player..\n if data[:points] > points_scored # if their points scored is greater than 0 (we set this earlier in the top of method)\n points_scored = data[:shoe] # take that players score and make it the new points_scored value\n end # this repeats (iterates) through all players until you don't have any more.. meaning the end result is\n end # the player with the highest score\n end\n return points_scored\nend", "def get_standings(games)\n teams = Hash.new\n games.each do |game|\n division_id = game.division_id\n home_team = game.home_team\n away_team = game.visiting_team\n if(teams[home_team.name].nil?)\n teams[home_team.name] = {:win => 0, :loss => 0, :tie => 0, :point=> 0}\n end\n\n if(teams[away_team.name].nil?)\n teams[away_team.name] = {:win => 0, :loss => 0, :tie => 0, :point => 0}\n end\n if(game.home_team_score && game.visiting_team_score)\n if(game.home_team_score > game.visiting_team_score)\n # home team won\n teams[home_team.name][:win] += 1\n teams[home_team.name][:point] += 5\n # visiting team loss\n teams[away_team.name][:loss] += 1\n elsif(game.home_team_score < game.visiting_team_score)\n # home team loss\n teams[home_team.name][:loss] += 1\n #visiting team won\n teams[away_team.name][:win] += 1\n teams[away_team.name][:point] += 5\n else\n # tie game\n teams[home_team.name][:tie] += 1\n teams[home_team.name][:point] += 1\n teams[away_team.name][:tie] += 1\n teams[away_team.name][:point] += 1\n end\n end\n end\n teams.each do |team, value|\n puts team\n total_games = value[:win] + value[:loss] + value[:tie]\n if total_games > 0 \n win_percentage = value[:win]/total_games.to_f\n else\n win_percentage = 0\n end \n value[:percentage] = win_percentage\n end\n teams_sorted = teams.sort_by{ |k, v| v[:point]}.reverse\n return teams_sorted\n end", "def lowest_scoring_home_team\n @teams.min_by { |team| team.average_home_goals }.team_name\n end", "def compute_team_winner\n if completed?\n team_winner\n else\n if first_team && second_team\n if sets_won(first_team) == min_sets_to_play\n first_team\n elsif sets_won(second_team) == min_sets_to_play\n second_team\n end\n end\n end\n end", "def winning_team\n home_points = collection_by_prop(game_hash[:home], :points).reduce(0, :+)\n away_points = collection_by_prop(game_hash[:away], :points).reduce(0, :+)\n home_points > away_points ? game_hash[:home][:team_name] : game_hash[:away][:team_name]\n end", "def fewest_goals_scored(team_id)\n team_id = team_id.to_i\n goals_per_game = @game_teams.map do |game|\n if game.team_id == team_id\n game.goals\n end\n end\n goals_per_game.compact.min\n end", "def determine_winner game\n winner = game.max_by {|team| team[:score]}\n team_standings = get_team_by_name(winner)\n team_standings[:winnings] += 3\nend", "def winning_team\n self.teams.order('score DESC').first\n end", "def worst_offense\n teams_total_goals = total_goals_helper\n teams_total_games = total_games_helper\n\n worst_team_goals_avg = 1000\n worst_offense_team_id = 0\n this_team_goals_avg = 0\n\n teams_total_games.each do |games_key, games_value|\n teams_total_goals.each do |goals_key, goals_value|\n if goals_key == games_key\n this_team_goals_avg = (goals_value / games_value.to_f)\n if this_team_goals_avg < worst_team_goals_avg\n worst_team_goals_avg = this_team_goals_avg\n worst_offense_team_id = games_key\n end\n end\n end\n end\n\n team_with_worst_offense = nil\n self.teams.each_value do |team_obj|\n if team_obj.team_id. == worst_offense_team_id\n team_with_worst_offense = team_obj.team_name\n end\n end\n team_with_worst_offense\n end", "def total_score\n\t\tall_scores = picks.collect { |pick|\n\t\t\tpicks_golfers = TournamentGolfer.where(golfer_id: pick.golfer_id, tournament_id: pick.pool.tournament_id).pluck(:total)[0]\n\t\t} - [nil] - [\"CUT\"]\n\t\tif all_scores.count < 5\n\t\t\treturn \"DQ\"\n\t\telse \n\t\t\tall_scores = all_scores.map {|score| score.to_i}\n\t\t\tall_scores = all_scores.sort\n\t\t\treturn all_scores[0..(pool.number_golfers_for_scoring-1)].sum\n\t\tend\n\tend", "def winning_team\n home_points = 0\n away_points = 0\n result = \"\"\n i = 0\n game_hash.each do |team, about|\n about[:players].each do |name , stats|\n if i == 0\n home_points += stats[:points]\n else\n away_points += stats[:points]\n end\n end\n i += 1\n end\n home_points > away_points ? result = game_hash[:home][:team_name] : result = game_hash[:away][:team_name]\nend", "def score(board, player)\n winner = board.find_winner\n return 1000000 if winner && winner == player\n return -1000000 if winner && winner == opponent(player)\n score_for(board, player) - score_for(board, opponent(player))\n end", "def calculate_overall_winner\n points_per_player = {}\n @matches.each do | match |\n !points_per_player[match.winner].nil? ? (points_per_player[match.winner] += 1) : (points_per_player[match.winner] = 1)\n end\n max_points = points_per_player.values.max\n points_per_player.key(max_points)\n end", "def points(games)\n games.sum { |score| [1, 3, 0][score[0] <=> score[2]] }\nend", "def determine_match_winner\n @games_to_win = ((total_number_of_games / 2.0).floor) + 1\n if player1.score == games_to_win\n return player1\n elsif player2.score == games_to_win\n return player2\n else\n return nil\n end\n end", "def calculate_score(team)\n scores.includes(:wattball_player).where(:wattball_players => {:team_id => team}).sum(:amount) \n end", "def lowest_score\n sort\n all.last.score\n end", "def rank_top_teams # DO NOT USE THIS METHOD, outdated, slow\n @top_teams = {}\n @top_teams = Score.in_challenge(self.id).teams_in_all_divisions.limit(5).\n order(\"sum_points DESC, MAX(#{Score.table_name}.\n earned_at) DESC\").sum(:points) \n return @top_teams\n end", "def calculate_team_ranking_score(number_of_meetings = 2, number_of_bests = 3)\n team_ranking_results = []\n events = []\n if @badge.category_type.code != 'U25' &&\n @badge.meetings.distinct.count >= number_of_meetings\n get_results.each do |meeting_individual_result|\n next unless meeting_individual_result.get_scheduled_date.year - @swimmer.year_of_birth >= 25\n\n next if events.include?(meeting_individual_result.event_type.code)\n\n team_ranking_results << meeting_individual_result\n events << meeting_individual_result.event_type.code\n break if team_ranking_results.count == number_of_bests\n end\n end\n BestLimitedRankingDAO.new(team_ranking_results)\n end", "def best_defense\n teams_total_goals_allowed = total_goals_allowed_helper\n teams_total_games = total_games_helper\n\n best_team_goals_allowed_avg = 100\n best_defense_team_id = 0\n this_team_goals_allowed_avg = 0\n\n teams_total_games.each do |games_key, games_value|\n teams_total_goals_allowed.each do |goals_key, goals_value|\n if goals_key == games_key\n this_team_goals_allowed_avg = (goals_value / games_value.to_f)\n if this_team_goals_allowed_avg < best_team_goals_allowed_avg\n best_team_goals_allowed_avg = this_team_goals_allowed_avg\n best_defense_team_id = games_key\n end\n end\n end\n end\n\n team_with_best_defense = nil\n self.teams.each_value do |team_obj|\n if team_obj.team_id. == best_defense_team_id\n team_with_best_defense = team_obj.team_name\n end\n end\n team_with_best_defense\n end", "def most_points_scored\n most_points = 0\n most_points_player = nil\n game_hash.each do |team, team_stats|\n team_stats[:players].each do |player_stats|\n if most_points < player_stats[:points]\n most_points = player_stats[:points]\n most_points_player = player_stats[:player_name]\n end\n end\n end\n most_points_player\nend", "def total_score\n @all_games.map do |games|\n games[\"home_goals\"].to_i + games[\"away_goals\"].to_i\n end\n end", "def winning_team_with_spread\n\t\tif self.final?\n\t\t\treturn home_team_id if home_team_score > away_team_score + point_spread\n\t\t\treturn away_team_id if away_team_score + point_spread > home_team_score\n\t\t\treturn \"tie\" if home_team_score == away_team_score + point_spread\n\t\telse\n\t\t\treturn nil\n\t\tend\n\tend", "def compute_best_score(team, pilots, pilot_contests)\n combination = []\n total = 0.0\n total_possible = 0\n puts 'compute_score TBD'\nend", "def winning_team\n points_home = 0\n points_away = 0\n result = \"\"\n\n game_hash.each do |side,team|\n team.each do |specs,info|\n if specs == :players\n info.each do |player|\n if side = :home\n points_home += player[:points]\n else\n points_away += player[:points]\n end\n end\n end\n end\n end\n if points_home > points_away\n result = game_hash[:home][:team_name]\n else\n result = game_hash[:away][:team_name]\n end\n result\nend", "def points(team)\n first = 0\n res = self.result\n\n if res\n if team == 1\n first_team = res[0]\n sec_team = res[1]\n elsif team == 2\n first_team = res[1]\n sec_team = res[0]\n else \n raise \"Invalid Team chosen\"\n end\n\n p first_team <=> sec_team\n # Compare the results\n outcome = first_team <=> sec_team\n\n if outcome > 0\n # Win\n result = 3\n elsif outcome < 0\n # Loss\n result = 0\n else \n # Draw\n result = 1\n end\n else\n result = nil\n end\n\n result\n end", "def max_score\n return score if @state != STATE_OK\n\n next_boards.map(&:min_score).min\n end", "def minmax_score(board)\n if won?(board)\n if winner(board) == self.token\n 1\n else\n -1\n end\n elsif draw?(board)\n 0\n end\n end", "def winningest_team\n @teams.max_by { |team| team.total_win_percentage }.team_name\n end", "def winning_team\n home_points = 0\n away_points = 0\n team1 = \"Brooklyn Nets\"\n team2 = \"Charlotte Hornets\"\n game_hash.each do |team,info|\n info.each do |team_info,team_data|\n if team_data.is_a? (Array) \n if team_info != :colors\n if info[:team_name] == \"Brooklyn Nets\"\n team_data.each do |player_index|\n home_points += player_index[:points]\n end\n else \n team_data.each do |player_index|\n away_points += player_index[:points]\n winning_team end\n end\n end\n end\n end\n end\n\n if home_points > away_points\n team1\n else\n team2\n end\n\nend", "def best_score\n submissions.min(:score)\n end", "def winner(game)\nwinner = \"\"\nwinner_points = 0\n game.each do |team, team_contents|\n total = 0\n team_contents[:roster].each do |player, player_contents| \n total += player_contents[:points]\n end\n if total > winner_points\n winner = team_contents[:team_name]\n winner_points = total\n elsif total == winner_points\n winner = \"tie\"\n end\n end\n\n if winner == \"tie\"\n puts \"The game was a tie, with each team scoring #{winner_points} points\"\n else\n puts \"#{winner} scored #{winner_points} points and won the game\"\n end\nend", "def sets_won(team)\n match_sets.reduce(0) do |sum, set|\n winner = set.compute_team_winner\n sum + (winner && winner == team ? 1 : 0)\n end\n end", "def total_score\n sum = self.games.sum{|game|game.points}\n sum.to_i / self.games.count\n end", "def worst_offense\n @teams.min_by { |team| team.average_goals_scored }.team_name\n end", "def winning_team\n total_points = 0 #initialize points at zero \n \n win_team = '' #set win team to an empty string \n \n game_hash.each do |location, team| #iterating over game hash\n team_points = 0 #initialize team points at zero \n team_name = game_hash[location][:team_name] \n # set team name = to game_hash at the the location at the # :team name \n \n team[:players].each do |player| #iterate over players \n points = player[:points] # set points = player points \n team_points += points #team points is the addition of every single point value from each player\n \n #binding.pry \n end\n \n win_team, total_points = team_name, team_points if team_points > total_points\n \n #binding.pry \n \n end\n \n return win_team\n\nend", "def score(cells)\n if winner(cells) == 2\n return 10\n elsif winner(cells) == 1\n return -10\n else\n return 0\n end\n end", "def worst_season(team_id)\n team_id = team_id.to_i\n team = @teams.select { |each_team| each_team.team_id == team_id }.first\n team.season_win_percentages.min_by { |season, percentage| percentage }.first.to_s\n end", "def worst_defense\n teams_total_goals_allowed = total_goals_allowed_helper\n teams_total_games = total_games_helper\n\n worst_team_goals_allowed_avg = 0\n worst_defense_team_id = 0\n this_team_goals_allowed_avg = 0\n\n teams_total_games.each do |games_key, games_value|\n\n teams_total_goals_allowed.each do |goals_key, goals_value|\n if goals_key == games_key\n this_team_goals_allowed_avg = (goals_value / games_value.to_f)\n if this_team_goals_allowed_avg > worst_team_goals_allowed_avg\n worst_team_goals_allowed_avg = this_team_goals_allowed_avg\n worst_defense_team_id = games_key\n end\n end\n end\n end\n team_with_worst_defense = team_name_finder_helper(worst_defense_team_id)\n\n team_with_worst_defense\n end", "def get_expected_score(player_rating, opponent_rating)\n 1.0 / (1.0 + 10.0 ** ((opponent_rating.to_f - player_rating.to_f) / 400.0))\n end", "def score_for_team(team)\n team ||= winner_team\n winner_team?(team) ? score : scores.reverse.join(':')\n end", "def percentage_home_wins\n home_wins = @teams.map { |team| team.home_wins }.sum\n home_games = @teams.map { |team| team.home_games }.sum\n (home_wins.to_f / home_games.to_f).round(2)\n end", "def get_total_score\n scores.map(&:score).sum\n end", "def overall_WLR\n overall_losses = 0\n overall_wins = 0\n @player_champs_list.each do |champ|\n overall_losses += champ.total_losses\n overall_wins += champ.total_wins\n end\n overall_losses > 0 ? (overall_wins.to_f / overall_losses).round(2) : overall_wins.to_f\n end", "def worst_loss(team_id)\n @games.map do |game|\n if game.away_team_id.to_s == team_id\n game.home_goals - game.away_goals\n elsif game.home_team_id.to_s == team_id\n game.away_goals - game.home_goals\n end\n end.compact.max\n end", "def calculate_winnings\n result = 0\n self.bookings.each do |booking|\n if booking.match.status == \"FINISHED\"\n if booking.won\n result += booking.stake * booking.odd.odds\n else\n booking.stake ? result -= booking.stake : result\n end\n end\n end\n return result.round(2)\n end", "def minimum_rounds(teams_count)\n Math.log2(teams_count).ceil\n end", "def week_1_total\n total = 0\n rostered_players.each do |rostered_player|\n total += rostered_player.player.week_1_score\n end\n return total\n end", "def score\n p1_score = players.first.score \n p2_score = players[1].score\n\n if p1_score == p2_score\n score_word = SCORE_NUMBER_TO_WORD_MAP[0..-2][p1_score]\n return score_word ? score_word + \"-All\" : \"Deuce\"\n elsif p1_score <= 3 && p2_score <= 3\n return players.map{|player| SCORE_NUMBER_TO_WORD_MAP[player.score] }.join(\"-\")\n else\n winning_player = players.sort{|a, b| a.score <=> b.score}.last\n return (p1_score - p2_score).abs == 1 ? \"Advantage #{winning_player.name}\" : \"Win for #{winning_player.name}\"\n end\n end", "def winner\n @players.max_by do |player|\n player.score\n end\n end", "def score(game)\n if game.winner.nil?\n 0\n elsif game.winner == game.computer_player\n 1\n else\n -1\n end\n end", "def most_points_scored\nbest_player = \"\"\npoints = 0\ngame_hash.each do |location, team_data|\n team_data[:players].each do |name, stats|\n if stats[:points] > points\n points = stats[:points]\n best_player= name\n end\n end\nend\nbest_player\nend", "def smallest_team\n self.teams.min{|t1,t2| t1.runners.size <=> t2.runners.size }\n end", "def get_alternative_total_score()\n # TODO The method get_total_score() above does not seem correct. Replace with this method.\n total_score = 0\n\n self.scores.each { |score| total_score = total_score + score.score }\n\n total_score\n end", "def compare_ranking_lines(a, b)\n res = 0\n\n if a['points'] < b['points']\n res = 1\n\n elsif b['points'] < a['points']\n res = -1\n\n else\n a_won_games = a['3_points'] + a['2_points']\n b_won_games = b['3_points'] + b['2_points']\n\n if a_won_games < b_won_games\n res = 1\n\n elsif b_won_games < a_won_games\n res = -1\n\n else\n #tied in won games, look at ratio won sets/lost sets\n a_ratio = a['won_sets'].to_f / a['lost_sets']\n b_ratio = b['won_sets'].to_f / b['lost_sets']\n\n if a_ratio < b_ratio\n res = 1\n elsif b_ratio < a_ratio\n res = -1\n end\n end\n end\n\n return res\n end", "def energy()\n score = 0\n @matches.each do |m|\n # Teams Same School\n if m.team_a.school == m.team_b.school\n score -= @penalties[:teams_same_school]\n end\n # Judges Same School\n m.judges.each do |j|\n if j.school == m.team_a.school\n score -= @penalties[:judge_same_school]\n end\n if j.school == m.team_b.school\n score -= @penalties[:judge_same_school]\n end\n end\n # Different Win/Loss\n if m.team_a.num_wins != m.team_b.num_wins\n score -= (1 + @penalties[:different_win_loss]) **\n (m.team_a.num_wins - m.team_b.num_wins).abs\n score -= 1 # No, really, this makes sense...\n end\n end\n score\n end", "def minimum_rounds(driver)\n Algorithm::Swiss.minimum_rounds(driver.seeded_teams.length)\n end", "def minimum_rounds(driver)\n Algorithm::Swiss.minimum_rounds(driver.seeded_teams.length)\n end", "def ranks\n @teams = Team.where(\"wins > 0\t\").order(win_percentage: :desc)\n end", "def winner\n @players.max_by{ |player| player.score}\n end", "def big_shoe_rebounds\n big_shoe = 0\n result = 0\n game_hash.each do |team, about|\n about[:players].each do |name , stats|\n stats.each do |stat, value|\n if stat == :shoe\n if big_shoe < value \n result = stats[:rebounds]\n big_shoe = value\n end\n end\n end\n end\n end\n result\nend", "def worst_case board\n\t\tworst = 0\n\t\topp_board = board.rotate 7\n\t\t6.times {|i|\n\t\t\t\ts = score_for(opp_board, i)\n\t\t\t\tworst = s if worst < s\n\t\t\t}\n\t\t\tworst\n\tend", "def wins\n wins = 0\n self.teams.each do |team|\n wins += team.games_won.length\n end\n wins\n end", "def goals_against(team)\n valid = ((team == self.home_team or team == self.away_team) and self.final)\n\n if (valid)\n if (self.home_team == team)\n return self.awayScore\n else\n return self.homeScore\n end\n else\n return 0\n end\n end", "def goals_for(team)\n valid = ((team == self.home_team or team == self.away_team) and self.final)\n\n if (valid)\n if (self.home_team == team)\n return self.homeScore\n else\n return self.awayScore\n end\n else\n return 0\n end\n end", "def overall_winner?(p1_wins,p2_wins)\n if p1_wins > p2_wins\n return 1\n elsif p2_wins > p1_wins\n return 2\n else\n return nil\n end\nend", "def best_defense\n @teams.min_by { |team| team.average_goals_allowed }.team_name\n end", "def wins_losses\n GAME_INFO.each do |game|\n @team_records.each do |team|\n if game[:home_team] == team.name && game[:home_score] > game[:away_score] #refactor later\n team.wins += 1\n elsif game[:home_team] == team.name && game[:home_score] < game[:away_score]\n team.losses += 1\n end\n end\n end\n\n GAME_INFO.each do |game|\n @team_records.each do |team|\n if game[:away_team] == team.name && game[:away_score] > game[:home_score] #refactor later\n team.wins += 1\n elsif game[:away_team] == team.name && game[:away_score] < game[:home_score]\n team.losses += 1\n end\n end\n end\n\n end", "def team_with_more_points(game)\n home_points = game[:home_team][:players].collect do |player|\n player[:stats][:points]\n end.inject {|sum, n| sum + n}\n away_points = game[:away_team][:players].collect do |player|\n player[:stats][:points]\n end.inject {|sum, n| sum + n}\n home_points > away_points ? game[:home_team][:team_name] : game[:away_team][:team_name]\nend", "def calculate_team_points\n # If the bracket is complete, we can calculate points based on the\n # teams' `final_rank`s.\n if @state == \"complete\"\n calculate_team_points_by_final_rank\n return\n end\n\n # For each team, look at the matches that it is in, look at the point\n # values of those matches, and take the maximum point value. That's the\n # number of points that the team has earned so far in the bracket.\n base_point_value = @config.base_point_value\n\n @teams.each do |team|\n matches_with_team = @matches.select { |match| match.has_team?(team.id) }\n\n puts \"Team #{team.name} was in #{matches_with_team.size} matches\"\n\n points_earned = matches_with_team.max_by(&:points).points\n\n puts \"The largest point value of those matches is #{points_earned}\" \\\n \"#{\" + #{base_point_value} base\" if base_point_value > 0}\"\n\n team.points = points_earned + base_point_value\n end\n end", "def most_points(game)\n player_name_with_points = []\n game[:home_team][:players].each do |player_hash|\n player_name_with_points << {player_hash[:player_name] => player_hash[:stats][:points]}\n end\n game[:away_team][:players].each do |player_hash|\n player_name_with_points << {player_hash[:player_name] => player_hash[:stats][:points]}\n end\n player_most_points = {\"test\" => 0}\n player_name_with_points.each do |name_and_points_hash|\n player_most_points = name_and_points_hash if name_and_points_hash.values[0] > player_most_points.values[0]\n end\n player_most_points.keys[0]\nend", "def evaluate\r\n score = 0\r\n # Evaluate score for each wining combination\r\n WIN_COMBINATIONS.each do |combo|\r\n score += evaluate_combo(combo)\r\n end\r\n\r\n score\r\n end", "def most_points_scored\n most_points = 0\n leading_scorer = \"\"\n\n game_hash.values.each do |roster|\n roster[:players].each do |player|\n if player[:points] > most_points\n most_points = player[:points]\n leading_scorer = player[:player_name]\n end\n end\n end\n return leading_scorer\nend", "def near_team_winner?(team)\n unless completed?\n sets_won(team) + 1 == min_sets_to_play\n end\n end", "def total_score\n total = 0\n @cards.each do |card|\n total += card.value\n end\n\n sorted_cards = @cards.sort\n\n straights = get_straight(sorted_cards).reverse\n straights.each do |straight|\n total += 40\n sorted_cards.slice!(straight[0]..straight[1])\n end\n\n three_cards = get_number_of_a_kind(sorted_cards, 3)\n three_cards.each do |three|\n total += 20\n sorted_cards.slice!(three[0]..three[1])\n end\n\n pairs = get_number_of_a_kind(sorted_cards, 2)\n pairs.each do |pair|\n total += 10\n sorted_cards.slice!(pair[0]..pair[1])\n end\n\n total\n end", "def best_season(team_id)\n team_id = team_id.to_i\n team = @teams.select { |each_team| each_team.team_id == team_id }.first\n team.season_win_percentages.max_by { |season, percentage| percentage }.first.to_s\n end", "def average_win_percentage(team_id)\n team_id = team_id.to_i\n team = @teams.select { |each_team| each_team.team_id == team_id }.first\n team.total_win_percentage.round(2)\n end", "def rating\n position_sum = 0\n games = []\n number_of_teams = 0\n Participation.find_all_by_player_id(self.id).each do |participation|\n position_sum += participation.position\n games.push Game.find(participation.game_id)\n end\n\n games.each do |game|\n number_of_teams += game.number_of_teams\n end\n\n if position_sum == 0\n position_sum = number_of_teams.to_f-0.5\n end\n\n (1 - position_sum.to_f/number_of_teams).round 2\n end", "def total_score\n plays.inject(0) { |sum, word| sum + Scoring.score(word) }\n end", "def leader_score\n score = 0\n ungrouped_users = []\n users = User.all\n \n users.each do |user|\n ungrouped_users << user if user.groups.empty?\n end\n \n ungrouped_users.each do |ungrouped_user|\n if self.has_compatible_meeting_time_with(ungrouped_user)\n score += (self.number_of_compatible_meeting_times_with(ungrouped_user) * 2) + self.number_of_compatible_time_blocks_with(ungrouped_user.schedule)\n end\n end\n \n score\n end", "def get_win_percentage(strategy)\n score = 0\n @turns.each do |t|\n score += t.result.to_i if t.strategy.include?(strategy)\n end\n score\n end", "def game_score\n \n if (@player1.points > 3 || @player2.points > 3) && (@player2.points - @player1.points > 1 || @player1.points - @player2.points > 1)\n return \"#{@player1.score}\"\n elsif (@player1.points >= 3 && @player2.points >= 3) && (@player2.points - @player1.points == 1 || @player1.points - @player2.points == 1)\n return \"#{@player1.score}\"\n elsif @player1.points >= 3 && @player2.points - @player1.points == 0\n return \"#{@player1.score}\"\n elsif @player1.points == @player2.points && @player1.points < 3 \n return \"#{@player1.score} all\"\n elsif @player1.points != @player2.points && @player1.points <= 3 && @player2.points <= 3 \n return \"#{@player1.score}: #{@player2.score}\"\n else\n return \"this is an unfamiliar scoring situation\"\n end\n end", "def winner\n if (self.homeScore > self.awayScore)\n return self.home_team\n elsif (self.awayScore > self.homeScore)\n return self.away_team\n else\n return nil\n end\n end", "def highest_total_score\n total_goals.max\n end", "def goals_against()\n\t self.as_regular_contestants.select{|c| c.opponent.score}.collect{|c| c.opponent.score}.inject{|gf, c| gf + c} || 0\n\tend", "def total_points\n\n points = 0\n wattball_matches_as_team1.each do |match|\n points += match.points(1) || 0\n end\n\n wattball_matches_as_team2.each do |match|\n points += match.points(2) || 0\n end\n\n points\n end", "def calculate_fairness\n strengths = @teams.map(&:strength)\n scores = @scores.values\n\n FairnessCheck.pearson_product_moment_correlation_coefficient strengths, scores\n end", "def score_round(scores={})\n\n return nil if scores.nil?\n return nil unless game.in_play?\n \n total = scores.values.inject(0){|score,value| score+value}\n\n return nil unless (total == 26 or total == 78)\n\n scores.each_pair do |name,score|\n playa = game.players.select{|p| p.name == name}.first\n pr = playa.player_rounds.select{|pr| pr.round_id == self.id}.first\n if pr\n pr.score = score\n pr.mon_shot = true if (total == 78 and pr.score == 0)\n pr.save\n end\n end\n\n game.calculate_totals\n \n end", "def best(n)\n @score.sort{|a,b| b[1][0] <=> a[1][0]}[0..n-1]\n end" ]
[ "0.7851294", "0.74098927", "0.73059714", "0.721409", "0.7213303", "0.7185231", "0.71397245", "0.7136335", "0.71146756", "0.70175725", "0.7000605", "0.6939029", "0.6937342", "0.6914247", "0.69123906", "0.6910729", "0.6878701", "0.6810575", "0.67979", "0.6797448", "0.6790686", "0.6776617", "0.6733782", "0.6726106", "0.67049277", "0.6701285", "0.66984874", "0.66929024", "0.66794884", "0.6640392", "0.6631947", "0.6627691", "0.66220266", "0.6619579", "0.6609602", "0.6609114", "0.65936995", "0.6579599", "0.6576359", "0.6567365", "0.65653384", "0.654562", "0.65423346", "0.6529492", "0.65255153", "0.65246135", "0.65226513", "0.6513734", "0.648151", "0.6471114", "0.6466276", "0.6460198", "0.6460159", "0.6455283", "0.64389575", "0.6437421", "0.6432754", "0.64216614", "0.6409039", "0.6392752", "0.638874", "0.6386603", "0.6383991", "0.6376458", "0.63705724", "0.63555527", "0.6354373", "0.63498914", "0.63498914", "0.6344364", "0.63105035", "0.6309948", "0.6308394", "0.63038045", "0.6302435", "0.6301421", "0.63003355", "0.6299366", "0.6293357", "0.6288517", "0.62879974", "0.62798715", "0.6275", "0.62739235", "0.6268546", "0.6262777", "0.6257472", "0.6250374", "0.62492365", "0.6246908", "0.6246827", "0.6246491", "0.6233031", "0.6229365", "0.6229125", "0.62269974", "0.6225918", "0.62249666", "0.62226725", "0.6222426" ]
0.79345125
0
returns highest score difference
def biggest_blowout score_difference = games.map { |game| (game.home_goals - game.away_goals).abs} score_difference.max end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def highest_score\n sort\n all.first.score\n end", "def highest_score\n sorted_all_scores = self.leaderboard_entries.order(score: :DESC)\n sorted_all_scores[0]\n end", "def best_score\n submissions.min(:score)\n end", "def get_maximum_score()\n max_score = 0\n\n self.scores.each { |score| max_score = max_score + score.question.questionnaire.max_question_score }\n\n max_score\n end", "def highest_total_score\n total_goals.max\n end", "def highest_player_score\n players.max_by{|player| player.score}.score\n end", "def max_score\n return score if @state != STATE_OK\n\n next_boards.map(&:min_score).min\n end", "def highest_word_score\n \t@scores_array.max\n end", "def highest_word_score\n word = highest_scoring_word\n highest_score = Scrabble::Scoring.score(word)\n return highest_score\n end", "def highest_word_score\n Scrabble::Scoring.score(Scrabble::Scoring.highest_score_from(@plays_array))\n end", "def highest_word_score\n Scoring.score(highest_scoring_word)\n end", "def highest_word_score\n return Scrabble::Scoring.score(highest_scoring_word)\n end", "def highest_total_score\n @game_manager.highest_total_score\n end", "def score\n regions.map(&:score).max\n end", "def highest_word_score\n return highest_scoring_value = Scrabble::Scoring.score(highest_scoring_word)\n end", "def highest_scoring_word\n \tScoring.highest_score_from(@words_played)\n end", "def highest_predicted_localization\n @score_hash.max{ |a,b|\n a[1] <=> b[1]\n }[0]\n end", "def max\n @raw.max_by(&:score)\n end", "def max_score\n return nil if metrics.empty?\n metrics.sum(&:weighted_max_score)\n end", "def max_score\n problem.weight\n end", "def max_score\n @max_score ||= raw_response['response']['maxScore'].to_f\n end", "def lowest_score\n sort\n all.last.score\n end", "def get_max_score(list)\n max = list[0].value\n list.each do |l|\n max = l.value if l.value > max\n end\n return max\n end", "def best_score(a_of_g)\n best_score = a_of_g.flatten.return_objects_with(:attempts, 0).max_attribute(:adjusted_goodness)\n end", "def highest_scoring_visitor\n @teams.max_by { |team| team.average_away_goals }.team_name\n end", "def max_total_score\n review_criterions.collect{|c| c.max_score}.sum\n end", "def max_score\n @solr_data[:max_score]\n end", "def highest_scoring_word\n Scrabble::Scoring.highest_score_from(@plays_array)\n end", "def high(x)\r\n x.split.max_by{|x| score_word(w)} end", "def best(n)\n @score.sort{|a,b| b[1][0] <=> a[1][0]}[0..n-1]\n end", "def max_score\n @solr_data[:max_score]\n end", "def high_score\n if self.end_date < Date.today\n self.teams.max_by { |team| team.score }.score\n end\n end", "def get_alternative_total_score()\n # TODO The method get_total_score() above does not seem correct. Replace with this method.\n total_score = 0\n\n self.scores.each { |score| total_score = total_score + score.score }\n\n total_score\n end", "def best_offense\n @teams.max_by { |team| team.average_goals_scored }.team_name\n end", "def highest_scoring_word\n Scoring.highest_score_from(plays)\n end", "def highest_match_value\n values = @hand.select { |dice| @hand.count(dice) == highest_match_count }\n values.max\n end", "def score\n last_30_score\n end", "def max_scores\n next_boards.map(&:max_score)\n end", "def highest_score_from(words)\n all_words_scores = []\n\n # Calculate scores of all words\n words.each do |word|\n each_word_score = {}\n each_word_score[:word] = word\n each_word_score[:score] = score_word(word)\n all_words_scores << each_word_score\n end\n\n word_rank = all_words_scores.each.sort_by {|hash| hash[:score]}.reverse\n\n puts \"word rank: #{word_rank}\"\n\n best_word = word_rank[0]\n\n word_rank.each_with_index do |hash, index|\n\n if word_rank[index][:score] > best_word[:score]\n best_word = word_rank[index]\n\n # Tie Handling\n elsif word_rank[index][:score] == best_word[:score]\n if best_word[:word].length != 10\n if word_rank[index][:word].length == 10\n best_word = word_rank[index]\n elsif word_rank[index][:word].length < best_word[:word].length\n best_word = word_rank[index]\n end\n end\n end\n index += 1\n end\n return best_word\nend", "def highest_score_from(words)\n highest_score = 0\n winning_words = []\n words.each do |word|\n if score_word(word) > highest_score\n highest_score = score_word(word)\n winning_words.clear << word\n elsif score_word(word) == highest_score\n winning_words << word\n end\n end\n\n # no tie scenario\n if winning_words.count == 1\n return {word: winning_words[0], score: highest_score}\n else \n\n # tie scenario\n winning_words.each do |word|\n # determines whether word is 10 letters long\n if word.length == 10\n return {word: word, score: highest_score}\n end\n end\n # if there is no 10 letter word, find shortest word\n winner = winning_words.min_by do |word|\n word.length\n end \n\n return {word: winner, score: highest_score}\n end \nend", "def worst_loss(team_id)\n @games.map do |game|\n if game.away_team_id.to_s == team_id\n game.home_goals - game.away_goals\n elsif game.home_team_id.to_s == team_id\n game.away_goals - game.home_goals\n end\n end.compact.max\n end", "def highest_scoring_home_team\n @teams.max_by { |team| team.average_home_goals }.team_name\n end", "def worst_offense\n @teams.min_by { |team| team.average_goals_scored }.team_name\n end", "def highest_scoring_word\n return Scrabble::Scoring.highest_score_from(@plays)\n end", "def worst_offense\n teams_total_goals = total_goals_helper\n teams_total_games = total_games_helper\n\n worst_team_goals_avg = 1000\n worst_offense_team_id = 0\n this_team_goals_avg = 0\n\n teams_total_games.each do |games_key, games_value|\n teams_total_goals.each do |goals_key, goals_value|\n if goals_key == games_key\n this_team_goals_avg = (goals_value / games_value.to_f)\n if this_team_goals_avg < worst_team_goals_avg\n worst_team_goals_avg = this_team_goals_avg\n worst_offense_team_id = games_key\n end\n end\n end\n end\n\n team_with_worst_offense = nil\n self.teams.each_value do |team_obj|\n if team_obj.team_id. == worst_offense_team_id\n team_with_worst_offense = team_obj.team_name\n end\n end\n team_with_worst_offense\n end", "def most_points_scored\n big_score_player = player_collection.reduce { |memo, next_player|\n memo[:points] > next_player[:points] ? memo : next_player; \n }\n big_score_player[:player_name];\nend", "def get_score\n\t\tscore = ((360000/((@end_time - @start_time).to_f + @save_time.to_f))*((@number_of_correct-@number_of_hint).fdiv(@number_of_correct+1))).truncate(2)\n\t\tif score < 0\n\t\t\treturn 0\n\t\telse\n\t\t\treturn score\n\t\tend\n\tend", "def winning_scores\n high_score = scores.max{|score| score.total}.total\n scores.select {|score| score.total == high_score}\n end", "def best_defense\n teams_total_goals_allowed = total_goals_allowed_helper\n teams_total_games = total_games_helper\n\n best_team_goals_allowed_avg = 100\n best_defense_team_id = 0\n this_team_goals_allowed_avg = 0\n\n teams_total_games.each do |games_key, games_value|\n teams_total_goals_allowed.each do |goals_key, goals_value|\n if goals_key == games_key\n this_team_goals_allowed_avg = (goals_value / games_value.to_f)\n if this_team_goals_allowed_avg < best_team_goals_allowed_avg\n best_team_goals_allowed_avg = this_team_goals_allowed_avg\n best_defense_team_id = games_key\n end\n end\n end\n end\n\n team_with_best_defense = nil\n self.teams.each_value do |team_obj|\n if team_obj.team_id. == best_defense_team_id\n team_with_best_defense = team_obj.team_name\n end\n end\n team_with_best_defense\n end", "def worst_defense\n @teams.max_by { |team| team.average_goals_allowed }.team_name\n end", "def highest_score_from(words)\n maximum_score = words.map { |word| score_word(word) }.max\n highest = words.select { |word| score_word(word) == maximum_score }\n if highest.length == 1 \n winning_word = highest.first\n else\n highest_lengths = highest.map {|i| i.length}\n if highest_lengths.any? { |x| x == 10}\n index_of_length_10 = highest_lengths.find_index(10)\n winning_word = highest[index_of_length_10]\n else\n winning_word = highest[highest_lengths.find_index(highest_lengths.min)]\n end \n end\n\n results = Hash.new\n results[:score] = maximum_score\n results[:word] = winning_word \n\n return results\nend", "def winningest_team\n @teams.max_by { |team| team.total_win_percentage }.team_name\n end", "def calculate_result\n max_conv = @conversions.first\n @conversions.each { |conv| max_conv = conv if @scores[conv.key] > @scores[max_conv.key] }\n\n max_conv\n end", "def max_score(creative_quality)\n max_score = 0\n self.question_responses\n .select{|el| max_score += el.question.question_choices.max{|el| el.score}.score if el.question_choice.creative_quality.name === creative_quality}\n max_score\n end", "def winner\n @players.max_by{ |player| player.score}\n end", "def find_best_score(total_per_player)\n best_score = 0\n winner = ''\n total_per_player.each do |player_name,total|\n\n if total > best_score\n best_score = total\n winner = player_name\n end\n end\n return winner\n end", "def base_score\n rank.last\n end", "def highest_scoring_word\n word = Scrabble::Scoring.highest_score_from(plays)\n return word\n end", "def total_score\n score || 0 #pos - neg\n end", "def player_w_biggest_feet\n all_players[1].max_by { |stats| stats[:shoe] }\n end", "def calculate_final_score\n self.scores.average(:total_score)\n end", "def highest_score_from(words)\n winner = {\n word: \"\",\n score: 0,\n }\n\n words.each do |word|\n if score_word(word) > winner[:score]\n winner = { word: word, score: score_word(word) }\n elsif score_word(word) == winner[:score]\n if ((word.length < winner[:word].length) || (word.length == 10)) && (winner[:word].length != 10)\n winner = { word: word, score: score_word(word) }\n end\n end\n end\n return winner\nend", "def max\n if self.root.right_child.nil?\n return {self.root.title => self.root.score}\n else\n recursive_max(self.root.right_child)\n end\n end", "def highest_score_from(words) \n all_scores = []\n\n words.each do |word|\n score = score_word(word)\n all_scores << {:word => word, :score => score}\n end\n \n highest_score = all_scores.max_by{|word_with_score| word_with_score[:score]}\n p \"This is one max score: #{highest_score}\"\n \n all_highscores = all_scores.select{|word_with_score| word_with_score[:score] == highest_score[:score]}\n puts \"This is ALL the words that match high score: #{all_highscores}\"\n \n tied_words = []\n all_highscores.each do |hash|\n tied_words << hash[:word]\n end\n\n winning_word = break_ties(tied_words)\n\n puts \"This is our winning word: #{winning_word}\"\n return {:word => winning_word, :score => (highest_score[:score])}\nend", "def winner\n @players.max_by do |player|\n player.score\n end\n end", "def weighted_max_score\n max_score * weight\n end", "def fitness(matches)\n max_match = matches[0]\n matches.each do |match|\n if max_match[2] < match[2]\n max_match = match\n end\n end\n return max_match\n end", "def mostPoints\n players.max_by do|name, stats|\n stats[:points]\n end\nend", "def highest_score_from(words)\n\n best_word = {\n word: [],\n score: 0\n }\n\n words.each do |word|\n\n score = score_word(word)\n\n if score > best_word[:score]\n best_word[:word].clear\n best_word[:word] << word\n best_word[:score] = score\n end\n\n if score == best_word[:score]\n best_word[:word] << word\n end\n\n end\n\n # applies rules for ties:\n # - shortest word wins unless there is a 10 letter word\n # - if multiple 10 letter words, the first word wins\n shortest_word = best_word[:word].min_by do |word|\n word.length\n end\n\n all_tiles_words = best_word[:word].select do |word|\n word.length == 10\n end\n\n if all_tiles_words.empty?\n best_word[:word] = shortest_word\n else\n best_word[:word] = all_tiles_words[0]\n end\n\n return best_word\n\nend", "def most_points_scored\n stat_by_player = collect_stat_by_name(:points)\n player_with_max_stat = find_max_stat_by_player(stat_by_player)\n player_with_max_stat\nend", "def best_defense\n @teams.min_by { |team| team.average_goals_allowed }.team_name\n end", "def most_points_scored\n max = nil\n name = nil \n game_hash.each do |team, team_values|\n team_values[:players].each do |player|\n if max == nil || player[:points] > max\n max = player[:points]\n name = player[:player_name]\n end\n end\n end\n name\nend", "def worst_defense\n teams_total_goals_allowed = total_goals_allowed_helper\n teams_total_games = total_games_helper\n\n worst_team_goals_allowed_avg = 0\n worst_defense_team_id = 0\n this_team_goals_allowed_avg = 0\n\n teams_total_games.each do |games_key, games_value|\n\n teams_total_goals_allowed.each do |goals_key, goals_value|\n if goals_key == games_key\n this_team_goals_allowed_avg = (goals_value / games_value.to_f)\n if this_team_goals_allowed_avg > worst_team_goals_allowed_avg\n worst_team_goals_allowed_avg = this_team_goals_allowed_avg\n worst_defense_team_id = games_key\n end\n end\n end\n end\n team_with_worst_defense = team_name_finder_helper(worst_defense_team_id)\n\n team_with_worst_defense\n end", "def personal_top_three\n scores.max([scores.length, 3].min)\n end", "def latest\n scores.last\n end", "def high(sentence)\n alpha_score = (\"a\"..\"z\").zip(1..26).to_h\n arr_sentence = sentence.split\n \n score_array = []\n \n arr_sentence.each do |word|\n score = 0\n word.chars.each do |char|\n score += alpha_score[char]\n end\n score_array << score\n end\n score_of_words = arr_sentence.zip(score_array).to_h\n \n result = score_of_words.max_by {|k,v| v}\n result.first\nend", "def score\n self.up_votes - self.down_votes\n end", "def highest_scoring_word\n highest_scoring_word = Scrabble::Scoring.highest_score_from(@array_of_words)\n\n return highest_scoring_word\n end", "def score\n @result.to_i\n end", "def most_points_scored\n most_points = 0\n leading_scorer = \"\"\n\n game_hash.values.each do |roster|\n roster[:players].each do |player|\n if player[:points] > most_points\n most_points = player[:points]\n leading_scorer = player[:player_name]\n end\n end\n end\n return leading_scorer\nend", "def lowest_total_score\n total_game_scores = games.map { |game| game.home_goals + game.away_goals}\n total_game_scores.min\n end", "def calculate_best_score()\n tz_start_yesterday = (self.now().beginning_of_day()) - 1.days\n tz_end_yesterday = tz_start_yesterday + 1.days\n\n # score for the day of yesterday\n daily_score = Point.for_user(self)\n .for_period(tz_start_yesterday,tz_end_yesterday)\n .map(&:number).inject(:+) || 0\n\n puts \"daily score for user '#{self.username}' for #{tz_start_yesterday}: #{daily_score} - best score: #{self.best_daily_score}\"\n if (self.best_daily_score < daily_score)\n self.update_attributes(:best_daily_score => daily_score)\n end\n end", "def score\n return @score\n end", "def highest_score_from(words)\n contestants = words.map{ |word| [word, score_word(word)] }.to_h\n\n winning_word = {word: \"\", score: 0}\n\n contestants.each do |word, score|\n if score > winning_word[:score]\n winning_word = {word: word, score: score}\n elsif score == winning_word[:score] \n if winning_word[:word].length == 10\n next\n elsif word.length == 10\n winning_word = {word: word, score: score}\n elsif word.length < winning_word[:word].length\n winning_word = {word: word, score: score}\n end\n end \n end\n return winning_word\nend", "def score\n @score ||= phonetic_levenshtein_distance + penalties\n end", "def winning_team\n self.teams.order('score DESC').first\n end", "def max_score\n mapping.select{ |x,v| v.present? }.keys.map { |k| k.gsub(/#{MAP_KEY}/,'').to_i }.max || -1\n end", "def score\n handscore = possible_scores.sort.reverse\n handscore.detect { |value| value <= 21 } or handscore.last\n end", "def score\n\n return NULL_SCORE if query_words.empty?\n return NULL_SCORE if reference_words.empty?\n my_scores = []\n\n query_words.each_with_index do |query_word, i|\n query_word_best_score = NULL_SCORE\n reference_words.each_with_index do |reference_word, j|\n score = word_score(query_word, reference_word)\n score -= word_position_penalty(i, j)\n query_word_best_score = [query_word_best_score, score].max\n end\n my_scores << query_word_best_score\n end\n # debug your scores?\n #pp Hash[query_words.zip(my_scores)]\n\n return NULL_SCORE if my_scores.empty?\n my_scores = my_scores.sort.reverse.take(reference_words.length)\n score_sum = my_scores.inject(:+)\n final_score = score_sum / my_scores.length\n return final_score\n end", "def energy()\n score = 0\n @matches.each do |m|\n # Teams Same School\n if m.team_a.school == m.team_b.school\n score -= @penalties[:teams_same_school]\n end\n # Judges Same School\n m.judges.each do |j|\n if j.school == m.team_a.school\n score -= @penalties[:judge_same_school]\n end\n if j.school == m.team_b.school\n score -= @penalties[:judge_same_school]\n end\n end\n # Different Win/Loss\n if m.team_a.num_wins != m.team_b.num_wins\n score -= (1 + @penalties[:different_win_loss]) **\n (m.team_a.num_wins - m.team_b.num_wins).abs\n score -= 1 # No, really, this makes sense...\n end\n end\n score\n end", "def biggest_surprise(season)\n season = season.to_i\n @teams.max_by{ |team| team.preseason_to_regular_increase[season] }.team_name\n end", "def best_fans\n @teams.max_by { |team| team.home_minus_away_percentage }.team_name\n end", "def players_with_highest_score\n players.select{|player| player.score >= highest_player_score}\n end", "def score\n @score\n end", "def factor_max_labs\n \tfactors.map do |factor|\n \t\tfactor.max_score\n \tend\n end", "def most_points_scored\nbest_player = \"\"\npoints = 0\ngame_hash.each do |location, team_data|\n team_data[:players].each do |name, stats|\n if stats[:points] > points\n points = stats[:points]\n best_player= name\n end\n end\nend\nbest_player\nend", "def score\n \"#{score1}-#{score2}\"\n end", "def most_points(game)\n player_name_with_points = []\n game[:home_team][:players].each do |player_hash|\n player_name_with_points << {player_hash[:player_name] => player_hash[:stats][:points]}\n end\n game[:away_team][:players].each do |player_hash|\n player_name_with_points << {player_hash[:player_name] => player_hash[:stats][:points]}\n end\n player_most_points = {\"test\" => 0}\n player_name_with_points.each do |name_and_points_hash|\n player_most_points = name_and_points_hash if name_and_points_hash.values[0] > player_most_points.values[0]\n end\n player_most_points.keys[0]\nend", "def most_points_scored\n points_scored = 0 # starting score to compare with players shoe sizes\n game_hash.each do |location, team_data| # iterates through each team\n players_array = team_data[:players] # finds the :players info in team_data and puts the players into players_array\n players_array.each do |player_name, data| # iterates through each player..\n if data[:points] > points_scored # if their points scored is greater than 0 (we set this earlier in the top of method)\n points_scored = data[:shoe] # take that players score and make it the new points_scored value\n end # this repeats (iterates) through all players until you don't have any more.. meaning the end result is\n end # the player with the highest score\n end\n return points_scored\nend", "def get_max_over(stat)\n max = 0\n $data_enemies.each { |enemy|\n next if enemy.nil?\n next if enemy.hidden_best\n next unless $game_party.known_enemy?(enemy.id)\n value = enemy.get_stat(stat)\n max = value if value > max\n }\n max\n end" ]
[ "0.7862773", "0.78582394", "0.7702384", "0.757764", "0.7564873", "0.7546964", "0.7512956", "0.74753463", "0.74460906", "0.74084884", "0.73247623", "0.7280755", "0.72600883", "0.7238816", "0.72349036", "0.71750605", "0.7164938", "0.71564656", "0.7105108", "0.7085629", "0.70678234", "0.7067452", "0.7022116", "0.7016232", "0.69971794", "0.6977976", "0.6908864", "0.68884784", "0.6874495", "0.68672335", "0.6866171", "0.6859786", "0.68590367", "0.68556714", "0.6843432", "0.6831328", "0.68264544", "0.6805866", "0.6798298", "0.6791017", "0.6782737", "0.6772461", "0.6744416", "0.67436606", "0.67239624", "0.67172277", "0.671533", "0.66662985", "0.66405", "0.66394305", "0.6634632", "0.66159874", "0.66156936", "0.6606098", "0.6605696", "0.65997344", "0.65991676", "0.65939754", "0.65931904", "0.6581428", "0.65788054", "0.6568547", "0.65678877", "0.65520626", "0.65364957", "0.6535871", "0.652091", "0.6513451", "0.6491284", "0.6481782", "0.64763755", "0.6470962", "0.6465008", "0.64639026", "0.6460689", "0.6442256", "0.6427138", "0.64196044", "0.6415689", "0.64030975", "0.63993675", "0.63988376", "0.6397989", "0.6383682", "0.63667125", "0.636416", "0.63485414", "0.63446814", "0.6342817", "0.63388455", "0.6335422", "0.6317173", "0.6313373", "0.63056004", "0.6301074", "0.6300208", "0.6299664", "0.62895536", "0.62857634", "0.62843406" ]
0.7093493
19
returns venue with most games played
def most_popular_venue venues = @games.group_by { |game| game.venue} venues.max_by { |venue, games| games.count }.first end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def least_popular_venue\n venues = @games.group_by { |game| game.venue}\n venues.min_by { |venue, games| games.count }.first\n end", "def season_with_most_games\n seasons = @games.group_by { |game| game.season }\n seasons.max_by { |season, games| games.count }.first\n end", "def most_hits(seasonasstring) # shots in game team stats\n #get a list of all teams that played in that season\n #use above list to sum all shots across all games in season\n #find highest across list\n #return team name as found in 139\n end", "def biggestShoes\n players.max_by do|name, stats|\n stats[:shoe]\n end\nend", "def most_points(game)\n player_name_with_points = []\n game[:home_team][:players].each do |player_hash|\n player_name_with_points << {player_hash[:player_name] => player_hash[:stats][:points]}\n end\n game[:away_team][:players].each do |player_hash|\n player_name_with_points << {player_hash[:player_name] => player_hash[:stats][:points]}\n end\n player_most_points = {\"test\" => 0}\n player_name_with_points.each do |name_and_points_hash|\n player_most_points = name_and_points_hash if name_and_points_hash.values[0] > player_most_points.values[0]\n end\n player_most_points.keys[0]\nend", "def get_top_games\n game_count = {}\n self.subscriptions.each do |subscription|\n game_id = Channel.find(subscription.channel_id).game_id\n game_count[game_id] ||= 0\n game_count[game_id] += 1\n end\n game_count.sort_by {|key, value| value}.reverse.to_h.keys\n end", "def season_with_fewest_games\n seasons = @games.group_by { |game| game.season }\n seasons.min_by { |season, games| games.count }.first\n end", "def winningest_team\n @teams.max_by { |team| team.total_win_percentage }.team_name\n end", "def most_points_scored\n max = nil\n name = nil \n game_hash.each do |team, team_values|\n team_values[:players].each do |player|\n if max == nil || player[:points] > max\n max = player[:points]\n name = player[:player_name]\n end\n end\n end\n name\nend", "def most_games\n options = {\n :select => 'count(*) as field',\n :order => 'field DESC'\n }\n\n render_users params[:name], options\n end", "def player_w_biggest_feet\n all_players[1].max_by { |stats| stats[:shoe] }\n end", "def highest_scoring_visitor\n @teams.max_by { |team| team.average_away_goals }.team_name\n end", "def most_points_scored\n most_points = 0\n player = \"\"\n game_hash.each do |k, team|\n team[:players].each do |e|\n if e[:points] > most_points\n most_points = e[:points]\n player = e[:player_name]\n end\n end\n end\n player\nend", "def biggest_blowout\n score_difference = games.map { |game| (game.home_goals - game.away_goals).abs}\n score_difference.max\n end", "def games_played\n games.size\n end", "def games_played\n games.size\n end", "def determine_winner game\n winner = game.max_by {|team| team[:score]}\n team_standings = get_team_by_name(winner)\n team_standings[:winnings] += 3\nend", "def winningest_coach(seasonasstring) # coach name in game team stats\n #per season, get list of all coaches - given by arg\n #per coach, find all games played by that coach\n #then count of all games won / count of all games played\n #find highest\n #return name of coach found in 114\n end", "def big_shoe_rebounds\n max_shoe = 0 \n max_rebounds = 0 \n game_hash.each do |place, team|\n # team.each do |attribute, data|\n team[:players].each do |player|\n if player[:shoe] > max_shoe\n max_shoe = player[:shoe]\n max_rebounds = player[:rebounds]\n # if attribute == :players\n # data.each do |player|\n #this gives me the player hashes\n # data.max_by{|player| player[:shoe] }\n # data.max_by{|player| player[:shoe] }[:rebounds]\n # player.max_by{|player| player[:shoe] \n # player.max_by{|player| player[:shoe] }[:rebounds]\n end\n end\n end\n return max_rebounds\n end", "def most_points_scored_helper\n point_array = []\n \n game_hash.each do |key, value|\n players = value[:players]\n players.each do |element|\n point_array << element[:point]\n end\n end\n point_array.max\nend", "def most_goals_scored(team_id)\n team_id = team_id.to_i\n goals_per_game = @game_teams.map do |game|\n if game.team_id == team_id\n game.goals\n end\n end\n goals_per_game.compact.max\n end", "def big_shoe_rebounds_helper\n shoes_array = []\n \n game_hash.each do |key, value|\n players = value[:players]\n players.each do |element|\n shoes_array << element[:shoe]\n end\n end\n shoes_array.max\nend", "def mostPoints\n players.max_by do|name, stats|\n stats[:points]\n end\nend", "def most_steals\r\n result={}\r\n game_hash.each do |k, v|\r\n v.each do| p, d|\r\n if p==:players\r\n d.each do |t, s|\r\n result[t]=s[:steals]\r\n end\r\n end\r\n end\r\n end \r\n result.max_by {|name, steal| steal}[0]\r\nend", "def biggest_shoe\r\n player_name= []\r\n game_hash.each do |team, data|\r\n data.each do |team_info, value|\r\n if team_info == \"players\".to_sym\r\n obj=value.max_by {|key, value| value[:shoe]}\r\n player_name<< obj.first\r\n end\r\n end\r\n end\r\n player_name.first\r\nend", "def most_steal\n steals_array = []\n \n game_hash.each do |key, value|\n players = value[:players]\n players.each do |element|\n steals_array << element[:steals]\n end\n end\n steals_array.max\nend", "def most_points_scored\n points = 0\n result = \"\"\n game_hash.each do |team, about|\n about[:players].each do |name , stats|\n if points < stats[:points]\n points = stats[:points]\n result = name\n end\n end\n end\n result\nend", "def biggest_bust(seasonasstring)\n #get all teams in data\n #find all games played by team in season - given by arg\n #get subset of 95 where p is in season marker\n #count games won in subset on 95 / total games in subset on 95\n #get subset of 85 where r is in season marker\n #count games won in subset on 98 / total games in subset on 98\n #result of line 97 - line 99\n #find highest number\n #return team name of result of line 101\n end", "def big_shoe_rebounds\n game_hash.values.each do |attribute|\n hash = attribute[:players]\n hash.values.each do |h|\n h.select { |k, v| k == :shoe }.sort.max\n return h[:rebounds]\n end\n end\nend", "def most_popular_screening_film\n most_popular = nil\n unsold_tickets = 2 #max capacity of the cinema\n screenings = return_film_screenings\n screenings.each do |screening|\n if screening.tickets_left.to_i < unsold_tickets\n most_popular = screening\n end\n end\n return most_popular\n end", "def worst_offense\n teams_total_goals = total_goals_helper\n teams_total_games = total_games_helper\n\n worst_team_goals_avg = 1000\n worst_offense_team_id = 0\n this_team_goals_avg = 0\n\n teams_total_games.each do |games_key, games_value|\n teams_total_goals.each do |goals_key, goals_value|\n if goals_key == games_key\n this_team_goals_avg = (goals_value / games_value.to_f)\n if this_team_goals_avg < worst_team_goals_avg\n worst_team_goals_avg = this_team_goals_avg\n worst_offense_team_id = games_key\n end\n end\n end\n end\n\n team_with_worst_offense = nil\n self.teams.each_value do |team_obj|\n if team_obj.team_id. == worst_offense_team_id\n team_with_worst_offense = team_obj.team_name\n end\n end\n team_with_worst_offense\n end", "def teams_with_score_max(a_game)\n teams_with_score_max = {}\n game_teams_with_score_max = a_game.teams_with_score_max(a_game.game_teams)\n game_teams_with_score_max.each do |game_team_with_score_max|\n # find team instance matching game_team instance\n team_with_score_max = @teams[game_team_with_score_max.name.to_sym]\n teams_with_score_max[game_team_with_score_max.name.to_sym] = team_with_score_max\n end\n teams_with_score_max\n end", "def mostSteals\n players.max_by do|name, stats|\n stats[:steals]\n end\nend", "def big_shoe_rebounds\n\nhighest_rebounds = 0\nbiggest_shoe = 0\n\n game_hash.each do |location, team_info|\n game_hash.dig(location, :players).each do |player_name, stats|\n stats.each do |stat, number|\n if stat == :shoe\n if number > biggest_shoe\n biggest_shoe = number\n stats.each do |stat, number|\n if stat == :rebounds\n highest_rebounds = number\n end\n end\n end\n end\n end\n end\n end\n puts highest_rebounds\n return highest_rebounds\nend", "def big_shoe_rebounds\n all_players = game_hash[:home][:players].merge(game_hash[:home][:players])\n big_object = all_players.max_by do |key,value|\n value[:shoe]\n end \n big_object[1][:rebounds]\nend", "def winning_team\n self.teams.order('score DESC').first\n end", "def most_points_scored\n most_points = 0\n most_points_player = nil\n game_hash.each do |team, team_stats|\n team_stats[:players].each do |player_stats|\n if most_points < player_stats[:points]\n most_points = player_stats[:points]\n most_points_player = player_stats[:player_name]\n end\n end\n end\n most_points_player\nend", "def team_with_more_points(game)\n home_points = game[:home_team][:players].collect do |player|\n player[:stats][:points]\n end.inject {|sum, n| sum + n}\n away_points = game[:away_team][:players].collect do |player|\n player[:stats][:points]\n end.inject {|sum, n| sum + n}\n home_points > away_points ? game[:home_team][:team_name] : game[:away_team][:team_name]\nend", "def best_offense\n @teams.max_by { |team| team.average_goals_scored }.team_name\n end", "def most_points_scored\n big_score_player = player_collection.reduce { |memo, next_player|\n memo[:points] > next_player[:points] ? memo : next_player; \n }\n big_score_player[:player_name];\nend", "def player_with_most_steal\n most_steals = nil\n most_steal_player = nil\n\n all_players(game_hash).each do |player|\n if most_steals == nil || player[:steals] > most_steals\n most_steals = player[:steals]\n most_steal_player = player[:player_name]\n end\n end\n\n most_steal_player\nend", "def most_points_scored()\n points = 0\n result = \"\"\n\n game_hash.each do |side,team|\n team.each do |specs,info|\n if specs == :players\n info.each do |player|\n if player[:points] > points\n points = player[:points]\n result = player[:player_name]\n\n end\n end\n end\n end\n end\n result\nend", "def most_popular_profession\n sql = <<-SQL\n SELECT guest_occupation,\n COUNT(id) as occupation_count\n FROM guest_appearances\n GROUP BY guest_occupation\n ORDER BY occupation_count DESC\n LIMIT 1;\n SQL\n mp = DB[:conn].execute(sql)[0]\n puts \"#{mp[0]}: #{mp[1]} appearances.\"\nend", "def most_points_scored\nbest_player = \"\"\npoints = 0\ngame_hash.each do |location, team_data|\n team_data[:players].each do |name, stats|\n if stats[:points] > points\n points = stats[:points]\n best_player= name\n end\n end\nend\nbest_player\nend", "def retrieve_season_hall_of_fame\n seasons_hall_of_fame = []\n get_involved_teams unless @involved_teams\n\n @involved_teams.each do |team|\n team_placement = {}\n team_placement[:team] = team\n %w[first_place second_place third_place].each_with_index do |rank, index|\n placement = index + 1\n team_placement[rank.to_sym] = team.computed_season_ranking.joins(:season).where(\"seasons.season_type_id = #{@season_type.id} AND computed_season_rankings.rank = #{placement}\").count\n end\n seasons_hall_of_fame << team_placement\n end\n seasons_hall_of_fame.sort { |p, n| (n[:first_place] * 10_000 + n[:second_place] * 100 + n[:third_place]) <=> (p[:first_place] * 10_000 + p[:second_place] * 100 + p[:third_place]) }\n end", "def most_popular_profession\n \"SELECT googleknowledge_occupation, COUNT(googleknowledge_occupation) FROM daily_show_guests GROUP BY googleknowledge_occupation ORDER BY COUNT(googleknowledge_occupation) DESC LIMIT 1;\"\nend", "def max_sets_to_play\n case scoring.to_sym\n when :two_six_game_ten_point\n 3\n when :one_eight_game\n 1\n else # :three_six_game\n 3\n end\n end", "def get_total_games_played\n return games.size\n end", "def rank_top_teams # DO NOT USE THIS METHOD, outdated, slow\n @top_teams = {}\n @top_teams = Score.in_challenge(self.id).teams_in_all_divisions.limit(5).\n order(\"sum_points DESC, MAX(#{Score.table_name}.\n earned_at) DESC\").sum(:points) \n return @top_teams\n end", "def most_points_scored\nplayer_with_most(:points)\nend", "def player_longest_name(game)\n player_names = []\n game[:home_team][:players].each do |player_hash|\n player_names << player_hash[:player_name]\n end\n game[:away_team][:players].each do |player_hash|\n player_names << player_hash[:player_name]\n end\n longest_name = player_names.max_by { |name| name.length }\nend", "def most_points(game)\nmax_points = 0\nmax_points_player = \"\"\ngame.each do |team, team_contents|\n team_contents[:roster].each do |player, player_contents| \n if player_contents[:points] == max_points\n max_points_player = max_points_player + \" and #{player_contents[:player_name]}\"\n elsif player_contents[:points] > max_points\n max_points = player_contents[:points]\n max_points_player = player_contents[:player_name]\n end\n end\nend\nputs \"#{max_points_player} scored #{max_points}\"\nend", "def big_shoe_rebounds\n biggest_shoe_size = 0\n player_rebounds = 0\n game_hash.each do |k, team|\n team[:players].each do |e|\n if e[:shoe] > biggest_shoe_size\n biggest_shoe_size = e[:shoe]\n player_rebounds = e[:rebounds]\n end\n end\n end\n player_rebounds\nend", "def most_points_scored\n most_points_scored = 0\n player_with_the_most_points_scored = \"\"\n game_hash.each do |team,info|\n info.each do |team_info,team_data|\n if team_data.is_a? (Array) \n if team_info != :colors\n team_data.each do |player_index|\n if most_points_scored == 0 || player_index[:points] > most_points_scored \n most_points_scored = player_index[:points]\n player_with_the_most_points_scored = player_index[:player_name]\n end\n end\n end\n end\n end\n end\n player_with_the_most_points_scored\nend", "def most_points_scored\n\tpoints_array = []\n\tgame_hash.each do |location, team_data|\n\t\tteam_data[:players].each do |attribute, data|\t\n\t\t\tdata.each do |type, amount|\n\t\t\t\tif type == :points\n\t\t\t\t\tpoints_array << amount\n\t\t\t\tend \n\t\t\tend\n\t\tend\n\tend\n\tgame_hash.each do |l, data|\n\t\tdata[:players].each do |a, d|\n\t\t\td.each do |t, amt|\n\t\t\t\tif t == :points && points_array.max == amt\n\t\t\t\t\treturn a\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend\nend", "def guest_with_most_appearances\n sql = <<-SQL\n SELECT guest_name,\n \tCOUNT(id) as appearance_count\n FROM guest_appearances\n GROUP BY guest_name\n ORDER BY appearance_count DESC\n LIMIT 1;\n SQL\n fg = DB[:conn].execute(sql)[0]\n puts \"#{fg[0]}: #{fg[1]} appearances.\"\nend", "def big_shoe_rebounds_2\n\nhighest_rebounds = 0\nbiggest_shoe = 0\n\n\n game_hash.dig(:home, :players).each do |player_name, stats|\n stats.each do |stat, number|\n if stat == :shoe\n if number > biggest_shoe\n biggest_shoe = number\n stats.each do |stat, number|\n if stat == :rebounds\n highest_rebounds = number\n\n end\n end\n end\n end\n end\nend\n\n puts highest_rebounds\n return highest_rebounds\nend", "def most_points_scored\n stat_by_player = collect_stat_by_name(:points)\n player_with_max_stat = find_max_stat_by_player(stat_by_player)\n player_with_max_stat\nend", "def games_played\n self.results.to_a.count\n end", "def guest_with_most_appearances\n \"SELECT\n name,\n count(*) AS total\n FROM guests\n GROUP BY name\n ORDER BY total\n DESC\n LIMIT 1;\"\nend", "def big_shoe_rebounds\nans = 0\nshoe_arr = []\nbig = 0\n\n game_hash.collect do |where, stats| \n \n game_hash[where][:players].collect do |p_name,p_stats|\n p_stats.collect do |stat_name,info|\n puts \n if stat_name == :shoe\n shoe_arr << info\n # puts shoe_arr.max_by{|x| x}\n big = shoe_arr.sort.last\n \n if game_hash[where][:players][p_name][:shoe] == big\n \n ans = game_hash[where][:players][p_name][:rebounds]\n\n end\n end\n end\n end\n end\nans \nend", "def highest_match_count\n match_count = Hash.new(0)\n\n @hand.each { |dice| match_count[dice] += 1 }\n\n match_count.values.max\n end", "def player_with_most_steals\n name = \"\"\n most_steals = 0\n\n game_hash.each do | team, details_hash |\n players_array = details_hash[:players]\n players_array.each do | player_details_hash |\n if player_details_hash[:steals] > most_steals\n most_steals = player_details_hash[:steals]\n name = player_details_hash[:player_name]\n end\n end\n end\n name\nend", "def winner\n @players.max_by do |player|\n player.score\n end\n end", "def winner\n @players.max_by{ |player| player.score}\n end", "def biggest_team_blowout(team_id)\n @games.map do |game|\n if game.away_team_id.to_s == team_id\n game.away_goals - game.home_goals\n elsif game.home_team_id.to_s == team_id\n game.home_goals - game.away_goals\n end\n end.compact.max\n end", "def most_points_scored\n most_points = 0 \n name = nil\n game_hash.each { |keys, values|\n i = 0\n while i < game_hash[keys][:players].length do \n if game_hash[keys][:players][i][:points] > most_points\n most_points = game_hash[keys][:players][i][:points]\n name = game_hash[keys][:players][i][:player_name]\n end\n i += 1\n end\n }\n name\n # binding.pry\nend", "def most_points_scored\n points_scored = 0 # starting score to compare with players shoe sizes\n game_hash.each do |location, team_data| # iterates through each team\n players_array = team_data[:players] # finds the :players info in team_data and puts the players into players_array\n players_array.each do |player_name, data| # iterates through each player..\n if data[:points] > points_scored # if their points scored is greater than 0 (we set this earlier in the top of method)\n points_scored = data[:shoe] # take that players score and make it the new points_scored value\n end # this repeats (iterates) through all players until you don't have any more.. meaning the end result is\n end # the player with the highest score\n end\n return points_scored\nend", "def get_total_games_played\n\t\treturn games.size\n\tend", "def biggest_shoe(hashketball)\r\n player_number_with_biggest_shoe = \"\"\r\n biggest_shoe_size = 0\r\n \r\n hashketball[:home][:players].each do |name, player|\r\n if player[:shoe_size] > biggest_shoe_size\r\n player_number_with_biggest_shoe = name\r\n biggest_shoe_size = player[:shoe_size]\r\n end\r\n end\r\n hashketball[:away][:players].each do |name, player|\r\n if player[:shoe_size] > biggest_shoe_size\r\n player_number_with_biggest_shoe = name\r\n biggest_shoe_size = player[:shoe_size]\r\n end\r\n end\r\n \r\n \" #{player_number_with_biggest_shoe} : #{biggest_shoe_size} \"\r\nend", "def big_shoe_rebounds\n player_with_the_largest_shoe_size = 0\n most_rebounds = 0\n game_hash.each do |team,info|\n info.each do |team_info,team_data|\n if team_data.is_a? (Array) \n if team_info != :colors\n team_data.each do |player_index|\n if player_with_the_largest_shoe_size == 0 || player_index[:shoe] > player_with_the_largest_shoe_size \n player_with_the_largest_shoe_size = player_index[:shoe]\n most_rebounds = player_index[:rebounds]\n end\n end\n end\n end\n end\n end\n most_rebounds\nend", "def big_shoe_rebounds\n biggest = 0\n rebounds = 0\n game_hash.each do |team, team_data|\n team_data[:players].each do |player|\n size = player[:shoe]\n if size > biggest\n biggest = size\n rebounds = player[:rebounds]\n end\n end\n end\n rebounds\nend", "def guest_with_most_appearances\n puts \"Q: Who did Jon Stewart have on the Daily Show the most?\"\n most_guest = @db.execute( \"SELECT COUNT(guests), guests FROM daily_show_guests GROUP BY guests ORDER BY COUNT(guests) DESC LIMIT 1\" )[0]\n puts \"A: #{most_guest[1]}, with #{most_guest[0]} appearances.\"\n puts \"\"\nend", "def winning_team\n home_team_points = game_hash[:home][:players].sum { |e| e[:points] }\n away_team_points = game_hash[:away][:players].sum { |e| e[:points] }\n\n if home_team_points > away_team_points\n return game_hash[:home][:team_name]\n else\n return game_hash[:away][:team_name]\n end\nend", "def top_5_leagues\n league_names = []\n leagues = UserLeague.all.collect{|league| league.league_id}\n most_common_value = leagues.uniq.sort_by{ |i| leagues.count( i ) }.reverse[0..4]\n most_common_value.each do |league|\n league_names << get_league_name_by_id(League.find(league).api_league_id)\n end\n league_names\nend", "def winning_team\n final_scores = player_collection.reduce(home: 0, away: 0) { |teams_points, next_player|\n case \n when next_player[:location] === :away\n teams_points[:away] += next_player[:points];\n when next_player[:location] === :home\n teams_points[:home] += next_player[:points];\n end\n teams_points; \n }\n winner = final_scores.reduce { |highest_points, team_points| \n highest_points[1] > team_points[1] ? highest_points : team_points; \n }\n game_hash[winner[0]][:team_name]; \nend", "def fewest_hits(seasonasstring) # shots in game team stats\n #inverse of above\n end", "def popular\n act = self.listings.map {|l| l.activity_id}\n activities = act.map {|a| Activity.find(a)}\n counts = Hash.new 0\n act.each do |id|\n counts[id] += 1\n end\n popular = 0\n appearances = 0\n counts.each do |id, value|\n if value > appearances \n appearances = value\n popular = id\n end\n end\n Activity.find(popular)\n end", "def most_rooms\n has_info = 0\n has_info = $postings.select{|p| p.to_s.downcase[/\\d+(?=bedroom|br)/]}\n max_post = has_info.max{|a,b| a.to_s.downcase[/\\d+(?=bedroom|br)/].to_i <=> b.to_s.downcase[/\\d+(?=bedroom|br)/].to_i}\n max_room = max_post.to_s.downcase[/\\d+(?=bedroom|br)/].to_i\n max_room_ads = has_info.select{|p| p.to_s.downcase[/\\d+(?=bedroom|br)/].to_i == max_room}\n list_apt(max_room_ads)\nend", "def highest_scoring_home_team\n @teams.max_by { |team| team.average_home_goals }.team_name\n end", "def election_winner(votes)\n candidate_votes = Hash.new(0)\n\n votes.each { |vote| candidate_votes[vote] += 1 }\n\n max_votes = candidate_votes.values.max\n candidate_votes.select { |_, v| v == max_votes }.sort.reverse[0][0]\nend", "def top_winners\n max_val = history.list.values.map { |ary| ary.reduce(:-) }.max\n history.list.select { |_, val| val.reduce(:-) == max_val }.keys\n end", "def sort_games\n games.order(:score).limit(5)\n end", "def top_5_teams\n team_names = []\n teams = UserTeam.all.collect{|team| team.team_id}\n most_common_value = teams.uniq.sort_by{ |i| teams.count( i ) }.reverse[0..4]\n most_common_value.each do |team|\n team_names << get_team_name_by_id(Team.find(team).api_team_id)\n end\n team_names\nend", "def winning_team\n team_p = []\n team_n = []\n\n game_hash.each do | location, team_data|\n temp = 0\n team_data[:players].each do |p_name, stats|\n temp += stats[:points]\n end\n team_n << team_data[:team_name]\n team_p << temp\n end\n\n team_p[0] > team_p[1] ? team_n[0] : team_n[1]\n\nend", "def highest_player_score\n players.max_by{|player| player.score}.score\n end", "def wins\n wins = 0\n self.teams.each do |team|\n wins += team.games_won.length\n end\n wins\n end", "def worst_defense\n @teams.max_by { |team| team.average_goals_allowed }.team_name\n end", "def big_shoe_rebounds\n hash = game_hash\n #first find largest shoe size\n max_size = 0\n hash.each do |location, team_data|\n\n hash[location][:players].each do |name, values|\n if hash[location][:players][name][:shoe] > max_size\n max_size = hash[location][:players][name][:shoe]\n end\n end\n end\n\n #then return the player's number of rebounds\n hash.each do |location, team_data|\n hash[location][:players].each do |name, values|\n if hash[location][:players][name][:shoe] == max_size\n return hash[location][:players][name][:rebounds]\n end\n end\n end\n\nend", "def this_teams_top_players(number_of_players)\n \tnfl_players.order(:points).last(number_of_players)\n end", "def big_shoe_rebounds\n\tbiggest_shoes_player = nil\n\tshoe_size_tracker = 0\n\trebounds_stat = nil\n\tgame_hash.each do |home_or_away, data|\n\t\tdata.each do |attribute, more_data|\n\t\t\tif attribute == :players\n\t\t\t\tmore_data.each do |player|\n\t\t\t\t\tplayer.each do |name, stats|\n\t\t\t\t\t\tstats.each do |stat, val|\n\t\t\t\t\t\t\tif stat == :shoe\n\t\t\t\t\t\t\t\tif !biggest_shoes_player || val > shoe_size_tracker\n\t\t\t\t\t\t\t\t\tshoe_size_tracker = val\n\t\t\t\t\t\t\t\t\tbiggest_shoes_player = name\n\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\tend\n\t\t\t\t\t\trebounds_stat = stats[:rebounds]\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend\n\trebounds_stat\nend", "def largest_shoes(game)\nmax_shoes = 0\nrebounds = 0\nmax_shoes_player = \"\"\ngame.each do |team, team_contents|\n team_contents[:roster].each do |player, player_contents| \n if player_contents[:shoe_size] == max_shoes\n max_shoes_player = max_shoes_player + \" and #{player_contents[:player_name]}\"\n rebounds = player_contents[:rebounds]\n elsif player_contents[:shoe_size] > max_shoes\n max_shoes = player_contents[:shoe_size]\n max_shoes_player = player_contents[:player_name]\n rebounds = player_contents[:rebounds]\n end\n end\nend\nputs \"#{max_shoes_player} has size #{max_shoes} shoes and #{rebounds} rebounds\"\nend", "def big_shoe_rebounds\n players[player_with_most(:shoe)][:rebounds]\nend", "def biggest_investment\n arr = []\n FundingRound.all.select do |s|\n if s.venture_capitalist == self\n arr << s.investment\n end\n end\n arr.max\n end", "def most_accurate_team(seasonasstring) # shots in game team stats\n #get a list of all teams that played in that season - given by arg\n #use above list to sum all shots across all games in season\n #divide above by goals made across all games in season\n #find highest percentage\n #return team name as found in 127\n end", "def guest_with_most_appearances\n sql = <<-SQL\n SELECT guest_name FROM (\n SELECT guest_name, count(guest_name)\n FROM guests\n GROUP BY guest_name\n ORDER BY count(guest_name) DESC LIMIT 1\n );\n SQL\n DB[:conn].execute(sql)[0][0]\nend", "def biggest_surprise(season)\n season = season.to_i\n @teams.max_by{ |team| team.preseason_to_regular_increase[season] }.team_name\n end", "def biggest_investment\n self.funding_rounds.max_by do |round|\n round.startup.uniq \n end\n end", "def guest_with_most_appearances(db)\n db.execute(\n \"SELECT guest_name, COUNT(appearance_date) \n FROM guests \n GROUP BY guest_name \n ORDER BY COUNT(appearance_date) DESC \n LIMIT 1\")\nend", "def top_10_fans\n users_array = UserTeam.all.collect{|user| user.user_id}\n most_common_value = users_array.uniq.sort_by{ |i| users_array.count( i ) }.reverse\n biggest_fans = most_common_value.map {|user| User.find(user).name}[0..9]\n users_teams_count = most_common_value.map {|user| User.find(user).teams.count}[0..9]\n counter = 0\n return_hash = {}\n until counter == biggest_fans.length do\n return_hash[biggest_fans[counter].to_s] = users_teams_count[counter].to_s\n counter += 1\n end\n return_hash\nend" ]
[ "0.765993", "0.7615187", "0.70569223", "0.69957685", "0.6989212", "0.6966518", "0.68768334", "0.6811023", "0.676626", "0.67556614", "0.67386675", "0.67024064", "0.66293275", "0.6609352", "0.66087717", "0.66087717", "0.6598287", "0.6582044", "0.6576285", "0.65722543", "0.65484667", "0.6540098", "0.6536927", "0.65274984", "0.6520122", "0.64817363", "0.64754957", "0.6474436", "0.64602387", "0.64544344", "0.64503944", "0.6447618", "0.643715", "0.6431032", "0.6417556", "0.6391081", "0.63881356", "0.63806206", "0.6374377", "0.6369216", "0.6366423", "0.6363056", "0.6360759", "0.63600886", "0.63316643", "0.6325949", "0.6325858", "0.63245153", "0.63188785", "0.63150525", "0.63111895", "0.63097703", "0.6305887", "0.62965155", "0.6294848", "0.6291024", "0.628784", "0.6285772", "0.6285649", "0.62831557", "0.627709", "0.6276526", "0.627024", "0.62674093", "0.6253955", "0.6252828", "0.625171", "0.62361753", "0.6233499", "0.6228953", "0.6223012", "0.6221451", "0.62188834", "0.62129676", "0.62033933", "0.6202422", "0.61909825", "0.61836934", "0.61833465", "0.6172169", "0.61656386", "0.61597157", "0.61386496", "0.6126584", "0.6125882", "0.61248547", "0.6119625", "0.6116034", "0.6106899", "0.6093032", "0.60871863", "0.6080413", "0.60790163", "0.6075967", "0.60714126", "0.60695547", "0.6066727", "0.6065765", "0.606405", "0.6056401" ]
0.8410583
0
returns venue with least games played
def least_popular_venue venues = @games.group_by { |game| game.venue} venues.min_by { |venue, games| games.count }.first end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def season_with_fewest_games\n seasons = @games.group_by { |game| game.season }\n seasons.min_by { |season, games| games.count }.first\n end", "def most_popular_venue\n venues = @games.group_by { |game| game.venue}\n venues.max_by { |venue, games| games.count }.first\n end", "def lowest_total_score\n total_game_scores = games.map { |game| game.home_goals + game.away_goals}\n total_game_scores.min\n end", "def season_with_most_games\n seasons = @games.group_by { |game| game.season }\n seasons.max_by { |season, games| games.count }.first\n end", "def lowest_scoring_visitor\n @teams.min_by { |team| team.average_away_goals }.team_name\n end", "def most_points(game)\n player_name_with_points = []\n game[:home_team][:players].each do |player_hash|\n player_name_with_points << {player_hash[:player_name] => player_hash[:stats][:points]}\n end\n game[:away_team][:players].each do |player_hash|\n player_name_with_points << {player_hash[:player_name] => player_hash[:stats][:points]}\n end\n player_most_points = {\"test\" => 0}\n player_name_with_points.each do |name_and_points_hash|\n player_most_points = name_and_points_hash if name_and_points_hash.values[0] > player_most_points.values[0]\n end\n player_most_points.keys[0]\nend", "def smallest_team\n self.teams.min{|t1,t2| t1.runners.size <=> t2.runners.size }\n end", "def player_with_most_steal\n most_steals = nil\n most_steal_player = nil\n\n all_players(game_hash).each do |player|\n if most_steals == nil || player[:steals] > most_steals\n most_steals = player[:steals]\n most_steal_player = player[:player_name]\n end\n end\n\n most_steal_player\nend", "def fewest_goals_scored(team_id)\n team_id = team_id.to_i\n goals_per_game = @game_teams.map do |game|\n if game.team_id == team_id\n game.goals\n end\n end\n goals_per_game.compact.min\n end", "def lowest_scoring_home_team\n @teams.min_by { |team| team.average_home_goals }.team_name\n end", "def worst_offense\n @teams.min_by { |team| team.average_goals_scored }.team_name\n end", "def lowest_score\n sort\n all.last.score\n end", "def big_shoe_rebounds\n biggest_shoe_size = 0\n player_rebounds = 0\n game_hash.each do |k, team|\n team[:players].each do |e|\n if e[:shoe] > biggest_shoe_size\n biggest_shoe_size = e[:shoe]\n player_rebounds = e[:rebounds]\n end\n end\n end\n player_rebounds\nend", "def most_points_scored\n most_points = 0\n player = \"\"\n game_hash.each do |k, team|\n team[:players].each do |e|\n if e[:points] > most_points\n most_points = e[:points]\n player = e[:player_name]\n end\n end\n end\n player\nend", "def winningest_coach(seasonasstring) # coach name in game team stats\n #per season, get list of all coaches - given by arg\n #per coach, find all games played by that coach\n #then count of all games won / count of all games played\n #find highest\n #return name of coach found in 114\n end", "def fewest_hits(seasonasstring) # shots in game team stats\n #inverse of above\n end", "def winning_team\n team_p = []\n team_n = []\n\n game_hash.each do | location, team_data|\n temp = 0\n team_data[:players].each do |p_name, stats|\n temp += stats[:points]\n end\n team_n << team_data[:team_name]\n team_p << temp\n end\n\n team_p[0] > team_p[1] ? team_n[0] : team_n[1]\n\nend", "def most_points_scored\nbest_player = \"\"\npoints = 0\ngame_hash.each do |location, team_data|\n team_data[:players].each do |name, stats|\n if stats[:points] > points\n points = stats[:points]\n best_player= name\n end\n end\nend\nbest_player\nend", "def player_w_biggest_feet\n all_players[1].max_by { |stats| stats[:shoe] }\n end", "def minimum_rounds(driver)\n Algorithm::Swiss.minimum_rounds(driver.seeded_teams.length)\n end", "def minimum_rounds(driver)\n Algorithm::Swiss.minimum_rounds(driver.seeded_teams.length)\n end", "def winning_team\n nets = []\n hornets = []\n\n game_hash.values.each do |nets_stats|\n if nets_stats[:team_name] == \"Brooklyn Nets\"\n nets_stats[:players].each do |bk|\n nets << bk[:points]\n end\n end\n end\n\n game_hash.values.each do |hornets_stats|\n if hornets_stats[:team_name] == \"Charlotte Hornets\"\n hornets_stats[:players].each do |ch|\n hornets << ch[:points]\n end\n end\n end\n\n if nets.reduce(:+) > hornets.reduce(:+)\n return \"Brooklyn Nets\"\n else\n return \"Charlotte Hornets\"\n end\nend", "def winning_team\n self.teams.order('score DESC').first\n end", "def winningest_team\n @teams.max_by { |team| team.total_win_percentage }.team_name\n end", "def biggestShoes\n players.max_by do|name, stats|\n stats[:shoe]\n end\nend", "def most_steals\r\n result={}\r\n game_hash.each do |k, v|\r\n v.each do| p, d|\r\n if p==:players\r\n d.each do |t, s|\r\n result[t]=s[:steals]\r\n end\r\n end\r\n end\r\n end \r\n result.max_by {|name, steal| steal}[0]\r\nend", "def min_sets_to_play\n max = max_sets_to_play\n raise Exceptions::ApplicationError, 'Unexpected game count' if max.even?\n (max + 1) / 2\n end", "def winning_team\n home_team_points = game_hash[:home][:players].sum { |e| e[:points] }\n away_team_points = game_hash[:away][:players].sum { |e| e[:points] }\n\n if home_team_points > away_team_points\n return game_hash[:home][:team_name]\n else\n return game_hash[:away][:team_name]\n end\nend", "def big_shoe_rebounds\n game_hash.values.each do |attribute|\n hash = attribute[:players]\n hash.values.each do |h|\n h.select { |k, v| k == :shoe }.sort.max\n return h[:rebounds]\n end\n end\nend", "def big_shoe_rebounds\nans = 0\nshoe_arr = []\nbig = 0\n\n game_hash.collect do |where, stats| \n \n game_hash[where][:players].collect do |p_name,p_stats|\n p_stats.collect do |stat_name,info|\n puts \n if stat_name == :shoe\n shoe_arr << info\n # puts shoe_arr.max_by{|x| x}\n big = shoe_arr.sort.last\n \n if game_hash[where][:players][p_name][:shoe] == big\n \n ans = game_hash[where][:players][p_name][:rebounds]\n\n end\n end\n end\n end\n end\nans \nend", "def most_points_scored\n points = 0\n result = \"\"\n game_hash.each do |team, about|\n about[:players].each do |name , stats|\n if points < stats[:points]\n points = stats[:points]\n result = name\n end\n end\n end\n result\nend", "def best_defense\n @teams.min_by { |team| team.average_goals_allowed }.team_name\n end", "def team_with_more_points(game)\n home_points = game[:home_team][:players].collect do |player|\n player[:stats][:points]\n end.inject {|sum, n| sum + n}\n away_points = game[:away_team][:players].collect do |player|\n player[:stats][:points]\n end.inject {|sum, n| sum + n}\n home_points > away_points ? game[:home_team][:team_name] : game[:away_team][:team_name]\nend", "def big_shoe_rebounds\n all_players = game_hash[:home][:players].merge(game_hash[:home][:players])\n big_object = all_players.max_by do |key,value|\n value[:shoe]\n end \n big_object[1][:rebounds]\nend", "def big_shoe_rebounds\n max_shoe = 0 \n max_rebounds = 0 \n game_hash.each do |place, team|\n # team.each do |attribute, data|\n team[:players].each do |player|\n if player[:shoe] > max_shoe\n max_shoe = player[:shoe]\n max_rebounds = player[:rebounds]\n # if attribute == :players\n # data.each do |player|\n #this gives me the player hashes\n # data.max_by{|player| player[:shoe] }\n # data.max_by{|player| player[:shoe] }[:rebounds]\n # player.max_by{|player| player[:shoe] \n # player.max_by{|player| player[:shoe] }[:rebounds]\n end\n end\n end\n return max_rebounds\n end", "def most_hits(seasonasstring) # shots in game team stats\n #get a list of all teams that played in that season\n #use above list to sum all shots across all games in season\n #find highest across list\n #return team name as found in 139\n end", "def most_points_scored\n max = nil\n name = nil \n game_hash.each do |team, team_values|\n team_values[:players].each do |player|\n if max == nil || player[:points] > max\n max = player[:points]\n name = player[:player_name]\n end\n end\n end\n name\nend", "def most_points_scored\n points_scored = 0 # starting score to compare with players shoe sizes\n game_hash.each do |location, team_data| # iterates through each team\n players_array = team_data[:players] # finds the :players info in team_data and puts the players into players_array\n players_array.each do |player_name, data| # iterates through each player..\n if data[:points] > points_scored # if their points scored is greater than 0 (we set this earlier in the top of method)\n points_scored = data[:shoe] # take that players score and make it the new points_scored value\n end # this repeats (iterates) through all players until you don't have any more.. meaning the end result is\n end # the player with the highest score\n end\n return points_scored\nend", "def retrieve_season_hall_of_fame\n seasons_hall_of_fame = []\n get_involved_teams unless @involved_teams\n\n @involved_teams.each do |team|\n team_placement = {}\n team_placement[:team] = team\n %w[first_place second_place third_place].each_with_index do |rank, index|\n placement = index + 1\n team_placement[rank.to_sym] = team.computed_season_ranking.joins(:season).where(\"seasons.season_type_id = #{@season_type.id} AND computed_season_rankings.rank = #{placement}\").count\n end\n seasons_hall_of_fame << team_placement\n end\n seasons_hall_of_fame.sort { |p, n| (n[:first_place] * 10_000 + n[:second_place] * 100 + n[:third_place]) <=> (p[:first_place] * 10_000 + p[:second_place] * 100 + p[:third_place]) }\n end", "def big_shoe_rebounds\n biggest = 0\n rebounds = 0\n game_hash.each do |team, team_data|\n team_data[:players].each do |player|\n size = player[:shoe]\n if size > biggest\n biggest = size\n rebounds = player[:rebounds]\n end\n end\n end\n rebounds\nend", "def most_points_scored\n most_points = 0\n most_points_player = nil\n game_hash.each do |team, team_stats|\n team_stats[:players].each do |player_stats|\n if most_points < player_stats[:points]\n most_points = player_stats[:points]\n most_points_player = player_stats[:player_name]\n end\n end\n end\n most_points_player\nend", "def determine_winner game\n winner = game.max_by {|team| team[:score]}\n team_standings = get_team_by_name(winner)\n team_standings[:winnings] += 3\nend", "def big_shoe_rebounds\n player_with_the_largest_shoe_size = 0\n most_rebounds = 0\n game_hash.each do |team,info|\n info.each do |team_info,team_data|\n if team_data.is_a? (Array) \n if team_info != :colors\n team_data.each do |player_index|\n if player_with_the_largest_shoe_size == 0 || player_index[:shoe] > player_with_the_largest_shoe_size \n player_with_the_largest_shoe_size = player_index[:shoe]\n most_rebounds = player_index[:rebounds]\n end\n end\n end\n end\n end\n end\n most_rebounds\nend", "def most_points_scored()\n points = 0\n result = \"\"\n\n game_hash.each do |side,team|\n team.each do |specs,info|\n if specs == :players\n info.each do |player|\n if player[:points] > points\n points = player[:points]\n result = player[:player_name]\n\n end\n end\n end\n end\n end\n result\nend", "def worst_offense\n teams_total_goals = total_goals_helper\n teams_total_games = total_games_helper\n\n worst_team_goals_avg = 1000\n worst_offense_team_id = 0\n this_team_goals_avg = 0\n\n teams_total_games.each do |games_key, games_value|\n teams_total_goals.each do |goals_key, goals_value|\n if goals_key == games_key\n this_team_goals_avg = (goals_value / games_value.to_f)\n if this_team_goals_avg < worst_team_goals_avg\n worst_team_goals_avg = this_team_goals_avg\n worst_offense_team_id = games_key\n end\n end\n end\n end\n\n team_with_worst_offense = nil\n self.teams.each_value do |team_obj|\n if team_obj.team_id. == worst_offense_team_id\n team_with_worst_offense = team_obj.team_name\n end\n end\n team_with_worst_offense\n end", "def upcoming_games_player\n games = []\n self.reservations.each do |r|\n games << r.game if r.game.date >= Date.today\n end\n games.sort\n end", "def top_winners\n max_val = history.list.values.map { |ary| ary.reduce(:-) }.max\n history.list.select { |_, val| val.reduce(:-) == max_val }.keys\n end", "def big_shoe_rebounds\n big_shoe = 0\n result = 0\n game_hash.each do |team, about|\n about[:players].each do |name , stats|\n stats.each do |stat, value|\n if stat == :shoe\n if big_shoe < value \n result = stats[:rebounds]\n big_shoe = value\n end\n end\n end\n end\n end\n result\nend", "def big_shoe_rebounds\n shoe_sizes = []\n output = nil\n game_hash.each do |team, att|\n game_hash[team][:players].each { |k, v| shoe_sizes << k[:shoe] }\n game_hash[team][:players].each { |k, v|\n k[:shoe] == shoe_sizes.sort.pop ? output = k[:rebounds] : nil }\n end\n output \nend", "def poolplay_games\n self.games.select { |game| game.version == 'poolplay'}\n end", "def big_shoe_rebounds_helper\n shoes_array = []\n \n game_hash.each do |key, value|\n players = value[:players]\n players.each do |element|\n shoes_array << element[:shoe]\n end\n end\n shoes_array.max\nend", "def most_points_scored\n big_score_player = player_collection.reduce { |memo, next_player|\n memo[:points] > next_player[:points] ? memo : next_player; \n }\n big_score_player[:player_name];\nend", "def most_points_scored_helper\n point_array = []\n \n game_hash.each do |key, value|\n players = value[:players]\n players.each do |element|\n point_array << element[:point]\n end\n end\n point_array.max\nend", "def most_points_scored\n most_points = 0\n leading_scorer = \"\"\n\n game_hash.values.each do |roster|\n roster[:players].each do |player|\n if player[:points] > most_points\n most_points = player[:points]\n leading_scorer = player[:player_name]\n end\n end\n end\n return leading_scorer\nend", "def big_shoe_rebounds\n\nhighest_rebounds = 0\nbiggest_shoe = 0\n\n game_hash.each do |location, team_info|\n game_hash.dig(location, :players).each do |player_name, stats|\n stats.each do |stat, number|\n if stat == :shoe\n if number > biggest_shoe\n biggest_shoe = number\n stats.each do |stat, number|\n if stat == :rebounds\n highest_rebounds = number\n end\n end\n end\n end\n end\n end\n end\n puts highest_rebounds\n return highest_rebounds\nend", "def biggest_shoe\r\n player_name= []\r\n game_hash.each do |team, data|\r\n data.each do |team_info, value|\r\n if team_info == \"players\".to_sym\r\n obj=value.max_by {|key, value| value[:shoe]}\r\n player_name<< obj.first\r\n end\r\n end\r\n end\r\n player_name.first\r\nend", "def biggest_bust(season)\n season = season.to_i\n @teams.min_by{ |team| team.preseason_to_regular_increase[season] }.team_name\n end", "def player_with_most_steals\n name = \"\"\n most_steals = 0\n\n game_hash.each do | team, details_hash |\n players_array = details_hash[:players]\n players_array.each do | player_details_hash |\n if player_details_hash[:steals] > most_steals\n most_steals = player_details_hash[:steals]\n name = player_details_hash[:player_name]\n end\n end\n end\n name\nend", "def grab_shoe\n j, k = [], 0\n game_hash.each do |location, team_data|\n team_data.each do |attribute, data|\n if attribute = :players\n j = game_hash[location][attribute].keys\n j.each do |name|\n if game_hash[location][attribute][name][:shoe] > k\n k = game_hash[location][attribute][name][:shoe]\n end#if\n end#j\n end#if\n end#team\n end#game\n k\nend", "def winning_team\n final_scores = player_collection.reduce(home: 0, away: 0) { |teams_points, next_player|\n case \n when next_player[:location] === :away\n teams_points[:away] += next_player[:points];\n when next_player[:location] === :home\n teams_points[:home] += next_player[:points];\n end\n teams_points; \n }\n winner = final_scores.reduce { |highest_points, team_points| \n highest_points[1] > team_points[1] ? highest_points : team_points; \n }\n game_hash[winner[0]][:team_name]; \nend", "def most_steal\n steals_array = []\n \n game_hash.each do |key, value|\n players = value[:players]\n players.each do |element|\n steals_array << element[:steals]\n end\n end\n steals_array.max\nend", "def most_points_scored\n most_points_scored = 0\n player_with_the_most_points_scored = \"\"\n game_hash.each do |team,info|\n info.each do |team_info,team_data|\n if team_data.is_a? (Array) \n if team_info != :colors\n team_data.each do |player_index|\n if most_points_scored == 0 || player_index[:points] > most_points_scored \n most_points_scored = player_index[:points]\n player_with_the_most_points_scored = player_index[:player_name]\n end\n end\n end\n end\n end\n end\n player_with_the_most_points_scored\nend", "def games_played\n games.size\n end", "def games_played\n games.size\n end", "def get_top_games\n game_count = {}\n self.subscriptions.each do |subscription|\n game_id = Channel.find(subscription.channel_id).game_id\n game_count[game_id] ||= 0\n game_count[game_id] += 1\n end\n game_count.sort_by {|key, value| value}.reverse.to_h.keys\n end", "def big_shoe_rebounds\n\tbiggest_shoes_player = nil\n\tshoe_size_tracker = 0\n\trebounds_stat = nil\n\tgame_hash.each do |home_or_away, data|\n\t\tdata.each do |attribute, more_data|\n\t\t\tif attribute == :players\n\t\t\t\tmore_data.each do |player|\n\t\t\t\t\tplayer.each do |name, stats|\n\t\t\t\t\t\tstats.each do |stat, val|\n\t\t\t\t\t\t\tif stat == :shoe\n\t\t\t\t\t\t\t\tif !biggest_shoes_player || val > shoe_size_tracker\n\t\t\t\t\t\t\t\t\tshoe_size_tracker = val\n\t\t\t\t\t\t\t\t\tbiggest_shoes_player = name\n\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\tend\n\t\t\t\t\t\trebounds_stat = stats[:rebounds]\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend\n\trebounds_stat\nend", "def big_shoe_points\n big_shoes_guy = 0\n points = 0\n game_hash.each do | location, attributes|\n attributes[:players].each do |player, stats|\n if stats[:shoe] > big_shoes_guy\n big_shoes_guy = stats[:shoe]\n points = stats[:points]\n end\n end\n end\n points\nend", "def big_shoe_rebounds\n largest = 0\n player = \"\"\n game_hash.each do |location, team_data|\n team_data[:players].each do |k, v|\n if largest < shoe_size(k)\n largest = shoe_size(k)\n player = k\n end\n end\n end\n return player_stats(player)[:rebounds]\nend", "def players_with_highest_score\n players.select{|player| player.score >= highest_player_score}\n end", "def biggest_bust(seasonasstring)\n #get all teams in data\n #find all games played by team in season - given by arg\n #get subset of 95 where p is in season marker\n #count games won in subset on 95 / total games in subset on 95\n #get subset of 85 where r is in season marker\n #count games won in subset on 98 / total games in subset on 98\n #result of line 97 - line 99\n #find highest number\n #return team name of result of line 101\n end", "def big_shoe_rebounds\n players[player_with_most(:shoe)][:rebounds]\nend", "def winning_team\n home_points = collection_by_prop(game_hash[:home], :points).reduce(0, :+)\n away_points = collection_by_prop(game_hash[:away], :points).reduce(0, :+)\n home_points > away_points ? game_hash[:home][:team_name] : game_hash[:away][:team_name]\n end", "def most_points_scored\n\tpoints_array = []\n\tgame_hash.each do |location, team_data|\n\t\tteam_data[:players].each do |attribute, data|\t\n\t\t\tdata.each do |type, amount|\n\t\t\t\tif type == :points\n\t\t\t\t\tpoints_array << amount\n\t\t\t\tend \n\t\t\tend\n\t\tend\n\tend\n\tgame_hash.each do |l, data|\n\t\tdata[:players].each do |a, d|\n\t\t\td.each do |t, amt|\n\t\t\t\tif t == :points && points_array.max == amt\n\t\t\t\t\treturn a\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend\nend", "def big_shoe_rebounds\n big_shoe_player = player_collection.reduce { |memo, next_player|\n memo[:shoe] > next_player[:shoe] ? memo : next_player; \n }\n big_shoe_player[:rebounds];\nend", "def wins\n wins = 0\n self.teams.each do |team|\n wins += team.games_won.length\n end\n wins\n end", "def least_duplicates\r\n smallest = 1000\r\n @schedule_datasets.each do |ds|\r\n smallest = ds.most_duplicates if ds.most_duplicates < smallest\r\n end\r\n return smallest\r\n end", "def least_rooms\n has_info = 0\n has_info = $postings.select{|p| p.to_s.downcase[/\\d+(?=bedroom|br)/]}\n min_post = has_info.min{|a,b| a.to_s.downcase[/\\d+(?=bedroom|br)/].to_i <=> b.to_s.downcase[/\\d+(?=bedroom|br)/].to_i}\n min_room = min_post.to_s.downcase[/\\d+(?=bedroom|br)/].to_i\n min_room_ads = has_info.select{|p| p.to_s.downcase[/\\d+(?=bedroom|br)/].to_i == min_room}\n list_apt(min_room_ads)\nend", "def big_shoe_rebounds\n biggest_shoe = 0\n rebounds = 0\n game_hash.each do |team, all_info_hash|\n all_info_hash[:players].each do |player_information_hash|\n if player_information_hash[:shoe] > biggest_shoe\n biggest_shoe = player_information_hash[:shoe] \n rebounds = player_information_hash[:rebounds] \n end\n end\n end\n rebounds\nend", "def take_worst\n roll_all.min\n end", "def rebounds_for_player_with_largest_shoe_size(game)\n shoe_sizes_with_player_names = []\n game[:home_team][:players].each do |player_hash|\n shoe_sizes_with_player_names << {player_hash[:player_name] => player_hash[:shoe_size]}\n end\n game[:away_team][:players].each do |player_hash|\n shoe_sizes_with_player_names << {player_hash[:player_name] => player_hash[:shoe_size]}\n end\n biggest_shoe_size = {\"test\" => 0}\n shoe_sizes_with_player_names.each do |shoe_size_and_name_hash|\n biggest_shoe_size = shoe_size_and_name_hash if shoe_size_and_name_hash.values[0] > biggest_shoe_size.values[0]\n end\n game[:home_team][:players].each do |player_hash|\n return player_hash[:stats][:rebounds] if player_hash[:player_name] == biggest_shoe_size.keys[0]\n end\n game[:away_team][:players].each do |player_hash|\n return player_hash[:stats][:rebounds] if player_hash[:player_name] == biggest_shoe_size.keys[0]\n end\nend", "def big_shoe_rebounds()\n shoe_size = 0\n result = 0\n\n game_hash.each do |side,team|\n team.each do |specs,info|\n if specs == :players\n info.each do |player|\n if player[:shoe] > shoe_size\n shoe_size = player[:shoe]\n result = player[:rebounds]\n\n end\n end\n end\n end\n end\n result\nend", "def winning_scores\n high_score = scores.max{|score| score.total}.total\n scores.select {|score| score.total == high_score}\n end", "def most_popular_screening_film\n most_popular = nil\n unsold_tickets = 2 #max capacity of the cinema\n screenings = return_film_screenings\n screenings.each do |screening|\n if screening.tickets_left.to_i < unsold_tickets\n most_popular = screening\n end\n end\n return most_popular\n end", "def biggest_blowout\n score_difference = games.map { |game| (game.home_goals - game.away_goals).abs}\n score_difference.max\n end", "def winning_player\n played_cards.max_by { |_, card| card_scores[card] }.first\n end", "def best_offense\n @teams.max_by { |team| team.average_goals_scored }.team_name\n end", "def big_shoe_rebounds\n big_shoes = []\n max_shoe = []\n what_team = []\n game_hash.each do |location, team_color_player|\n team_color_player.each do |tcp, players|\n if tcp == :players\n players.each do |player, stat|\n stat.each do |statistic, actual|\n if statistic == :shoe\n max_shoe.push(actual)\n if max_shoe.max == actual\n big_shoes.push(player)\n what_team.push(location)\n end\n end\n end\n end\n end\n end\n end\n return game_hash[what_team.last][:players][big_shoes.last][:rebounds]\nend", "def least_accurate_team(seasonasstring) # shots in game team stats\n #inverse of above\n end", "def heaviest_rock(rock_array)\n max_rock = 0\n\n rocks.each do |rock|\n max_rock = rock if max_rock < rock \n end\nend", "def best_score\n submissions.min(:score)\n end", "def big_shoe_rebounds\n hash = game_hash\n #first find largest shoe size\n max_size = 0\n hash.each do |location, team_data|\n\n hash[location][:players].each do |name, values|\n if hash[location][:players][name][:shoe] > max_size\n max_size = hash[location][:players][name][:shoe]\n end\n end\n end\n\n #then return the player's number of rebounds\n hash.each do |location, team_data|\n hash[location][:players].each do |name, values|\n if hash[location][:players][name][:shoe] == max_size\n return hash[location][:players][name][:rebounds]\n end\n end\n end\n\nend", "def big_shoe_rebounds_2\n\nhighest_rebounds = 0\nbiggest_shoe = 0\n\n\n game_hash.dig(:home, :players).each do |player_name, stats|\n stats.each do |stat, number|\n if stat == :shoe\n if number > biggest_shoe\n biggest_shoe = number\n stats.each do |stat, number|\n if stat == :rebounds\n highest_rebounds = number\n\n end\n end\n end\n end\n end\nend\n\n puts highest_rebounds\n return highest_rebounds\nend", "def most_points_scored\nplayer_with_most(:points)\nend", "def winner\n @player_positions.max_by{|player, position| position}[0]\n end", "def games(complete = nil)\n games_scope = Game.where('challenger_id = ? OR challenged_id = ?', self.id, self.id)\n games_scope.includes(:challenged, :challenger)\n games_scope.where('complete = ?', complete) if complete\n games_scope = games_scope.order('created_at DESC')\n\n games_scope\n end", "def winner\n @players.max_by do |player|\n player.score\n end\n end", "def upcoming_games_all\n (upcoming_games_host | upcoming_games_player).sort\n end", "def candidates_above_default\n Array(@ranking[0...@default_rank]).flatten.sort\n end", "def best_defense\n teams_total_goals_allowed = total_goals_allowed_helper\n teams_total_games = total_games_helper\n\n best_team_goals_allowed_avg = 100\n best_defense_team_id = 0\n this_team_goals_allowed_avg = 0\n\n teams_total_games.each do |games_key, games_value|\n teams_total_goals_allowed.each do |goals_key, goals_value|\n if goals_key == games_key\n this_team_goals_allowed_avg = (goals_value / games_value.to_f)\n if this_team_goals_allowed_avg < best_team_goals_allowed_avg\n best_team_goals_allowed_avg = this_team_goals_allowed_avg\n best_defense_team_id = games_key\n end\n end\n end\n end\n\n team_with_best_defense = nil\n self.teams.each_value do |team_obj|\n if team_obj.team_id. == best_defense_team_id\n team_with_best_defense = team_obj.team_name\n end\n end\n team_with_best_defense\n end", "def wins()\n\t\tself.as_regular_contestants.select{|c| c.win()}.size()\n\tend" ]
[ "0.76161486", "0.7056655", "0.69582653", "0.6757273", "0.6731888", "0.6489541", "0.6412171", "0.63426536", "0.63326377", "0.6292713", "0.6252597", "0.62505406", "0.62498", "0.6233365", "0.62034404", "0.61901", "0.61881024", "0.6171604", "0.6169676", "0.61607593", "0.61607593", "0.6152641", "0.6142674", "0.6138549", "0.61194605", "0.61071885", "0.61036146", "0.609152", "0.608817", "0.6087676", "0.6080709", "0.60722387", "0.6069896", "0.6068533", "0.60647345", "0.6063816", "0.606315", "0.6058532", "0.60542566", "0.60537547", "0.60413736", "0.60356176", "0.603278", "0.6030278", "0.6023579", "0.60189974", "0.6016397", "0.6011326", "0.59960884", "0.59955394", "0.59944767", "0.59807503", "0.5979374", "0.59602964", "0.595821", "0.5955685", "0.59470254", "0.59442484", "0.5940424", "0.59352875", "0.5927396", "0.5926761", "0.59206885", "0.59206885", "0.59185565", "0.59178203", "0.5914948", "0.5910365", "0.59001845", "0.5893992", "0.58900297", "0.58894336", "0.5880164", "0.58739746", "0.58682835", "0.58653563", "0.5856724", "0.58546567", "0.58536536", "0.58375776", "0.58352643", "0.5811575", "0.5804881", "0.5800446", "0.57943046", "0.5786567", "0.57766634", "0.5772357", "0.57698166", "0.5769798", "0.57689035", "0.5764544", "0.57611346", "0.57510906", "0.57477665", "0.5744227", "0.57437074", "0.57409817", "0.57326436", "0.5725216" ]
0.8513803
0
returns percentage of games a home team has won
def percentage_home_wins home_wins = @teams.map { |team| team.home_wins }.sum home_games = @teams.map { |team| team.home_games }.sum (home_wins.to_f / home_games.to_f).round(2) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def player_win_percentage\n (games_won/user_games)\n end", "def percentage_visitor_wins\n visitor_wins = @teams.map { |team| team.away_wins }.sum\n visitor_games = @teams.map { |team| team.away_games }.sum\n (visitor_wins.to_f / visitor_games.to_f).round(2)\n end", "def percent_wins(wins)\n ((wins.to_f / @num_games.to_f) * 100).round(4)\n end", "def win_percent\n matchmade_games < 1 ? 0 : ((total_exp.to_f/matchmade_games.to_f) * 100).to_d\n end", "def coach_win_percent_in_season(coach, game_ids)\n (total_wins_of_coach_in_season(coach, game_ids) / total_coach_games_in_season(coach, game_ids).to_f).round(2)\n end", "def average_goals_per_game\n total_goals = @teams.map {|team| team.total_goals_scored}.sum\n total_games = @teams.map {|team| team.home_games}.sum\n (total_goals.to_f / total_games.to_f).round(2)\n end", "def get_standings(games)\n teams = Hash.new\n games.each do |game|\n division_id = game.division_id\n home_team = game.home_team\n away_team = game.visiting_team\n if(teams[home_team.name].nil?)\n teams[home_team.name] = {:win => 0, :loss => 0, :tie => 0, :point=> 0}\n end\n\n if(teams[away_team.name].nil?)\n teams[away_team.name] = {:win => 0, :loss => 0, :tie => 0, :point => 0}\n end\n if(game.home_team_score && game.visiting_team_score)\n if(game.home_team_score > game.visiting_team_score)\n # home team won\n teams[home_team.name][:win] += 1\n teams[home_team.name][:point] += 5\n # visiting team loss\n teams[away_team.name][:loss] += 1\n elsif(game.home_team_score < game.visiting_team_score)\n # home team loss\n teams[home_team.name][:loss] += 1\n #visiting team won\n teams[away_team.name][:win] += 1\n teams[away_team.name][:point] += 5\n else\n # tie game\n teams[home_team.name][:tie] += 1\n teams[home_team.name][:point] += 1\n teams[away_team.name][:tie] += 1\n teams[away_team.name][:point] += 1\n end\n end\n end\n teams.each do |team, value|\n puts team\n total_games = value[:win] + value[:loss] + value[:tie]\n if total_games > 0 \n win_percentage = value[:win]/total_games.to_f\n else\n win_percentage = 0\n end \n value[:percentage] = win_percentage\n end\n teams_sorted = teams.sort_by{ |k, v| v[:point]}.reverse\n return teams_sorted\n end", "def home_shoot_percent\n home_shoot_percent = @schedule.home_score / game_stat.home_sog.to_f * 100\n home_shoot_percent.round(2)\n end", "def winning_team\n home_team_sum = 0\n away_team_sum = 0\n game_hash.each do |team, team_stats|\n if team_stats[:team_name] == \"Brooklyn Nets\"\n team_stats[:players].each do |player_stats|\n home_team_sum += player_stats[:points]\n end\n elsif team_stats[:team_name] == \"Charlotte Hornets\"\n team_stats[:players].each do |player_stats|\n away_team_sum += player_stats[:points]\n end\n end\n end\n if home_team_sum > away_team_sum\n game_hash[:home][:team_name]\n elsif home_team_sum < away_team_sum\n game_hash[:away][:team_name]\n end\nend", "def power_play_goal_percentage(seasonasstring) # power_play info in game team stat\n #find list of all games in season given by arg\n #sum all power play goals\n #sum all power play oppertunities\n #divide line 146 and line 147\n #return total of above\n end", "def winning_team\n home_score = 0\n away_score = 0\n game_hash[:home][:players].keys.each do |name|\n home_score += game_hash[:home][:players][name][:points]\n end\n game_hash[:away][:players].keys.each do |name|\n away_score += game_hash[:away][:players][name][:points]\n end\n home_score > away_score ? game_hash[:home][:team_name] : game_hash[:away][:team_name]\nend", "def wins\n wins = 0\n self.teams.each do |team|\n wins += team.games_won.length\n end\n wins\n end", "def calc_pct(wins, losses)\n return (wins + losses) == 0 ? 0.0 : wins.to_f / (wins + losses).to_f\nend", "def rounds_won_percentage\n (@rounds_played > 0) ? @rounds_won.to_f / @rounds_played : 0\n end", "def get_win_percentage(strategy)\n score = 0\n @turns.each do |t|\n score += t.result.to_i if t.strategy.include?(strategy)\n end\n score\n end", "def winning_team\n home_points = collection_by_prop(game_hash[:home], :points).reduce(0, :+)\n away_points = collection_by_prop(game_hash[:away], :points).reduce(0, :+)\n home_points > away_points ? game_hash[:home][:team_name] : game_hash[:away][:team_name]\n end", "def test_percentage_home_wins\n assert_equal 0.44, @stat_tracker.percentage_home_wins\n end", "def total_score\n @all_games.map do |games|\n games[\"home_goals\"].to_i + games[\"away_goals\"].to_i\n end\n end", "def total_score\n sum = self.games.sum{|game|game.points}\n sum.to_i / self.games.count\n end", "def oppg\n (opp_possessions.to_f)/games\n end", "def oppg\n (opp_possessions.to_f)/games\n end", "def pct()\n\t (self.wins()==0) ? 0 : self.wins().to_f/(self.wins()+self.losses()) \n\tend", "def winning_team\n home_team_points = game_hash[:home][:players].sum { |e| e[:points] }\n away_team_points = game_hash[:away][:players].sum { |e| e[:points] }\n\n if home_team_points > away_team_points\n return game_hash[:home][:team_name]\n else\n return game_hash[:away][:team_name]\n end\nend", "def winning_team\n final_scores = player_collection.reduce(home: 0, away: 0) { |teams_points, next_player|\n case \n when next_player[:location] === :away\n teams_points[:away] += next_player[:points];\n when next_player[:location] === :home\n teams_points[:home] += next_player[:points];\n end\n teams_points; \n }\n winner = final_scores.reduce { |highest_points, team_points| \n highest_points[1] > team_points[1] ? highest_points : team_points; \n }\n game_hash[winner[0]][:team_name]; \nend", "def pick_percentage\n self.score.to_f / Matchup.amount_finished.to_f\n end", "def pri_tdef\n team_stats.opp_goals_per_game / team_stats.opp_avg_goals_against_per_game\n end", "def winning_team\n if homeTeamPoints.sum > awayTeamPoints.sum\n \"Brooklyn Nets\"\n else\n \"Charlotte Hornets\"\n end\nend", "def winning_team\n home_points = 0\n away_points = 0\n result = \"\"\n i = 0\n game_hash.each do |team, about|\n about[:players].each do |name , stats|\n if i == 0\n home_points += stats[:points]\n else\n away_points += stats[:points]\n end\n end\n i += 1\n end\n home_points > away_points ? result = game_hash[:home][:team_name] : result = game_hash[:away][:team_name]\nend", "def get_percent_of_vote\n\t\t(@votes.count(@winner).to_f / @votes.count.to_f * 100).round\n\tend", "def winning_team\n points_home = 0\n points_away = 0\n result = \"\"\n\n game_hash.each do |side,team|\n team.each do |specs,info|\n if specs == :players\n info.each do |player|\n if side = :home\n points_home += player[:points]\n else\n points_away += player[:points]\n end\n end\n end\n end\n end\n if points_home > points_away\n result = game_hash[:home][:team_name]\n else\n result = game_hash[:away][:team_name]\n end\n result\nend", "def get_games_won()\n return @score_count.get_games_won()\n end", "def game_ratio(nick)\n pa = $db[:player_action]\n udb = $db[:uno]\n\n games = udb.where(nick: nick).all[0]\n\n dataset = $db[\"SELECT count(game) FROM player_action pa where pa.action = 0 and pa.player = ?\n and exists (select game from player_action pa2 where pa.game = pa2.game and pa2.action = 0 and pa2.player like 'unobot%')\n and exists (select 1 from games where id = pa.game and end is not null)\", nick]\n puts dataset.all[0].to_a[0][1].to_f, games[:games].to_f\n dataset.all[0].to_a[0][1].to_f / games[:games].to_f\nend", "def goals_for(team)\n valid = ((team == self.home_team or team == self.away_team) and self.final)\n\n if (valid)\n if (self.home_team == team)\n return self.homeScore\n else\n return self.awayScore\n end\n else\n return 0\n end\n end", "def goals_against()\n\t self.as_regular_contestants.select{|c| c.opponent.score}.collect{|c| c.opponent.score}.inject{|gf, c| gf + c} || 0\n\tend", "def goals_against(team)\n valid = ((team == self.home_team or team == self.away_team) and self.final)\n\n if (valid)\n if (self.home_team == team)\n return self.awayScore\n else\n return self.homeScore\n end\n else\n return 0\n end\n end", "def get_total_games_played\n\t\treturn games.size\n\tend", "def get_total_games_played\n return games.size\n end", "def average_goals_by_season\n goals_by_season = @games.group_by { |game| game.season.to_s }\n goals_by_season.each do |season, games|\n season_goals = games.map { |game| game.home_goals + game.away_goals }.sum\n goals_by_season[season] = (season_goals.to_f / games.count.to_f).round(2)\n end\n end", "def pri_goal_percentage\n shots_on_goal > 0 ? goals.to_f / shots_on_goal : 1.0\n end", "def determine_winner game\n winner = game.max_by {|team| team[:score]}\n team_standings = get_team_by_name(winner)\n team_standings[:winnings] += 3\nend", "def achievements_percentage\n achievements_done.to_f / @achievements.size\n end", "def percent_high_ranking\n percent = high_ranking_cards.length / cards.length.to_f\n end", "def away_shoot_percent\n away_shoot_percent = @schedule.away_score / game_stat.away_sog.to_f * 100\n away_shoot_percent.round(2)\n end", "def get_game_stats(game)\n agent = Mechanize.new\n html = agent.get(\"http://espn.go.com/ncb/boxscore?gameId=#{game.gameID}\").body\n doc = Nokogiri::HTML(html)\n\n awayRecs = doc.xpath(\"//div[@class = 'team-info']\").css(\"p\")[0].text\n awayOvrRaw = awayRecs.scan(/(\\d+)-(\\d+),.*/)\n if(awayOvrRaw != [] )\n awayOvrPer = awayOvrRaw[0][0].to_f / (awayOvrRaw[0][1].to_f + awayOvrRaw[0][0].to_f)\n else\n awayOvrPer = 0.05\n end\n awayRaw = awayRecs.scan(/.*, (\\d+)-(\\d+)/)\n if(awayRaw != [])\n awayPer = awayRaw[0][0].to_f / (awayRaw[0][1].to_f + awayRaw[0][0].to_f)\n else\n awayPer = 0.05 \n end\n homeRecs = doc.xpath(\"//div[@class = 'team-info']\").css(\"p\")[1].text\n homeOvrRaw = homeRecs.scan(/(\\d+)-(\\d+),.*/)\n if(homeOvrRaw != [])\n homeOvrPer = homeOvrRaw[0][0].to_f / (homeOvrRaw[0][1].to_f + homeOvrRaw[0][0].to_f) \n else\n homeOvrPer = 0.05\n end\n homeRaw = homeRecs.scan(/.*, (\\d+)-(\\d+)/)\n if(homeRaw != [])\n homePer = homeRaw[0][0].to_f / (homeRaw[0][1].to_f + homeRaw[0][0].to_f)\n else\n homePer = 0.05\n end\n # Find the table with information\n table = doc.xpath('//table[@class = \"mod-data\"]')\n rows = table.css('tbody')\n\n # Declare variables\n isHome = false\n homePoints = 0\n awayPoints = 0\n\n # Get data for game\n rows.each do |row|\n col = row.css('td')\n if(col.count == 18)\n fg = col[1].text.scan((/(\\d+)-(\\d+)/)) \n fgm = fg[0][0].to_f\n fga = fg[0][1].to_f\n fgPer = fgm / fga\n\n threeP = col[2].text.scan((/(\\d+)-(\\d+)/))\n threePM = threeP[0][0].to_f\n threePA = threeP[0][1].to_f\n threePer = threePM / threePA\n\n twoPM = fgm - threePM\n twoPA = fga - threePA\n twoPer = twoPM.to_f / twoPA.to_f\n\n ft = col[3].text.scan((/(\\d+)-(\\d+)/))\n ftm = ft[0][0].to_f\n fta = ft[0][1].to_f\n ftPer = ftm / fta\n\n offReb = col[4].text.to_f\n defReb = col[5].text.to_f\n totReb = col[6].text.to_f\n assists = col[7].text.to_f\n steals = col[8].text.to_f\n blocks = col[9].text.to_f\n to = col[10].text.to_f\n pf = col[11].text.to_f\n\n points = col[12].text.to_f\n pps = points / fga\n adjFG = ((points - ftm)/ fga)/ 2\n\n apto = assists / to\n spto = steals / to\n spf = steals / pf\n bpf = blocks / pf\n \n # Updates specific game entry with newly scraped data\n if(isHome)\n game.update(homePoints: points, homefgm: fgm, homefga: fga, homefgPer: fgPer, hometwoMade: twoPM, hometwoAtt: twoPA, hometwoPer: twoPer, homethreeMade: threePM, homethreeAtt: threePA, homethreePer: threePer, homeftm: ftm, homefta: fta, homeftPer: ftPer, homeoffReb: offReb, homedefReb: defReb, hometotalReb: totReb, homepps: pps, homeadjFG: adjFG, homeassist: assists, hometo: to, homeapto: apto, homesteals: steals, homefouls: pf, homestealPerTO: spto, homestealPerFoul: spf, homeblocks: blocks, homeblocksPerFoul: bpf, homeOvrWL: homeOvrPer, homeHomeWL: homePer)\n elsif\n game.update(awaypoints: points, awayfgm: fgm, awayfga: fga, awayfgPer: fgPer, awaytwoMade: twoPM, awaytwoAtt: twoPA, awaytwoPer: twoPer, awaythreeMade: threePM, awaythreeAtt: threePA, awaythreePer: threePer, awayftm: ftm, awayfta: fta, awayftPer: ftPer, awayoffReb: offReb, awaydefReb: defReb, awaytotalReb: totReb, awaypps: pps, awayadjFG: adjFG, awayassist: assists, awayto: to, awayapto: apto, awaysteals: steals, awayfouls: pf, awaystealPerTO: spto, awaystealPerFoul: spf, awayblocks: blocks, awayblocksPerFoul: bpf, awayOvrWL: homeOvrPer, awayAwayWL: awayPer)\n end\n\n # Always two rows, first is away, second is home\n isHome = true\n end\n end \n end", "def hours_spent_percentage\n return 1 if hours_planned == 0\n (hours_spent.to_f / hours_planned).round(2)\n end", "def hours_spent_percentage\n return 1 if hours_planned == 0\n (hours_spent.to_f / hours_planned).round(2)\n end", "def grade_percentage\n passed_tests = boating_tests.select { |tests| tests.test_status == \"Pass\" }\n (passed_tests.count.to_f / boating_tests.count.to_f) * 100\n end", "def pri_toff\n team_stats.goals_per_game / team_stats.opp_avg_goals_per_game\n end", "def game_score\n previous_hands = self.game_player.hand_players.joins(:hand).where(\n \"hands.position <= ?\", self.hand.position\n )\n gs = 0\n for h in previous_hands\n gs += h.hand_score\n end\n return gs\n end", "def score\n w = 0.3\n time = diff_time()\n sum_goods = goods()\n sum_bads = bads()\n total = sum_goods + sum_bads\n (w * sum_goods * (sum_goods/total.to_f)**3 * (total/time)).floor\n end", "def calculate_score\n statuses = Tile::STATUSES\n missed_shots = starting_shots - shots_remaining\n hit_shots = board.board.flatten.select do |tile|\n [statuses[:hit], statuses[:sunk]].include?(tile.status)\n end\n hit_shots = hit_shots.count\n total_time = (Time.now - starting_time).round\n ((500 * hit_shots) - (50 * missed_shots)) / total_time\n end", "def num_points_scored (searched_player)\n player_points = 0\n game_hash[:away][:players].each do |player_data|\n if player_data[:player_name] == searched_player\n player_points = player_data[:points]\n end\n end\n game_hash[:home][:players].each do |player_data|\n if player_data[:player_name] == searched_player\n player_points = player_data[:points]\n end\n end\n player_points\nend", "def score\n goals = self.match_events.select { |e| e.event_type == MatchEvent::EventType::GOAL }\n goals.reduce({away: 0, home: 0}) do |score, e|\n if e.event_author == MatchEvent::EventAuthor::HOME\n score[:home] += 1\n elsif e.event_author == MatchEvent::EventAuthor::AWAY\n score[:away] += 1\n end\n score\n end\n end", "def get_other_games_won()\n @score_count.get_other_games_won()\n end", "def outcome\n if self.final\n \th = home_team\n \ta = away_team\n \t# h.wins=0 if h.wins==nil\n \t# h.losses=0 if h.losses==nil\n \t# a.wins=0 if a.wins==nil\n \t# a.losses=0 if a.losses==nil\n \tif home_score == away_score\n \t\treturn 'T'\n \telsif home_score > away_score\n \t\tif !self.recorded\n \t \t\th.wins += 1\n \t \t\ta.losses += 1\n \t \t\th.save\n \t \t\ta.save\n \t \t\tself.recorded=true\n \t \t\tself.save\n \t \tend\n \t\tif overtime\n \t\t\treturn 'h'\n \t\telse\n \t\t\treturn 'H'\n \t\tend\n \telse\n \t\tif !self.recorded\n \t \t\th.losses += 1\n \t \t\ta.wins += 1\n \t \t\ta.save\n \t \t\th.save\n \t \t\tself.recorded=true\n \t \t\tself.save\n \t \tend\n \t\tif overtime\n \t\t\treturn 'a'\n \t\telse\n \t\t\treturn 'A'\n \t\tend\n \tend\n end\n end", "def winning_team\n nets = []\n hornets = []\n\n game_hash.values.each do |nets_stats|\n if nets_stats[:team_name] == \"Brooklyn Nets\"\n nets_stats[:players].each do |bk|\n nets << bk[:points]\n end\n end\n end\n\n game_hash.values.each do |hornets_stats|\n if hornets_stats[:team_name] == \"Charlotte Hornets\"\n hornets_stats[:players].each do |ch|\n hornets << ch[:points]\n end\n end\n end\n\n if nets.reduce(:+) > hornets.reduce(:+)\n return \"Brooklyn Nets\"\n else\n return \"Charlotte Hornets\"\n end\nend", "def calculate_winnings\n result = 0\n self.bookings.each do |booking|\n if booking.match.status == \"FINISHED\"\n if booking.won\n result += booking.stake * booking.odd.odds\n else\n booking.stake ? result -= booking.stake : result\n end\n end\n end\n return result.round(2)\n end", "def num_games win_condition\n total_games = 0\n @game_objects.each do |game|\n total_games += 1 if game_meets_win_cond?(win_condition, game)\n end \n total_games\n end", "def alive_percentage\n hp.to_f / hit_points\n end", "def winning_team\n team_p = []\n team_n = []\n\n game_hash.each do | location, team_data|\n temp = 0\n team_data[:players].each do |p_name, stats|\n temp += stats[:points]\n end\n team_n << team_data[:team_name]\n team_p << temp\n end\n\n team_p[0] > team_p[1] ? team_n[0] : team_n[1]\n\nend", "def percent_high_ranking\n number_of_high_cards = self.high_ranking_cards.length.to_f\n number_of_all_cards = self.cards.length.to_f\n\n percentage = number_of_high_cards / number_of_all_cards\n percentage_rounded = (percentage * 100).round(2)\n\n return percentage_rounded\n end", "def grade_percentage\n tests = BoatingTest.all.select {|test| test.student.first_name == self.first_name}\n passed_tests = tests.select {|test| test.test_status == \"passed\"}\n per = (passed_tests.length.to_f / tests.length.to_f)*100\n \n end", "def avarage_calories_burned\n total_workout_calories / set_sport_by_user.count\n rescue\n 0\n end", "def problem_percentage\n @summary[:total_score].to_f / Constants::THRESHOLDS[\"Project\"].to_f\n end", "def games_played\n self.results.to_a.count\n end", "def average_win_percentage(team_id)\n team_id = team_id.to_i\n team = @teams.select { |each_team| each_team.team_id == team_id }.first\n team.total_win_percentage.round(2)\n end", "def percent_high_ranking\n (high_ranking_cards.count.fdiv(@cards.count) * 100).round(2)\n end", "def points_in_team(team)\r\n perfs = self.performances.where(team: team)\r\n perfs.map(&:points).inject(:+) / perfs.length\r\n end", "def percent_of_house\n house_capacity.zero? ? 100 : (100.0 * total_sales.size / house_capacity).floor\n end", "def percent_high_ranking\n ((high_ranking_cards.count.to_f / @cards.count.to_f) * 100).round(2)\n end", "def percent_passes; end", "def percent_passes; end", "def games_played\n games.size\n end", "def games_played\n games.size\n end", "def problem_percentage\n score.to_f / Constants::THRESHOLDS[@class_type].to_f\n end", "def grade_percentage\n studentTests= BoatingTest.all.find_all{|test| test.student.first_name == self.first_name}\n totalTests= studentTests.length.to_f\n totalPassed= studentTests.find_all{|test| test.status == \"passed\"}\n numPassed= totalPassed.length.to_f\n percent= (numPassed/totalTests)*100\n end", "def probability_by_win_ratio(delta)\n # A team wins between 0% and 100% of its games\n # Comparing two teams, the difference in percentages will also be between 0% and 100%\n # If they have equal win percentages, then it is a tossup--50/50\n # If one team has won 100% and the other has won 0%,\n # ...then there is a 100% win percentage different between them\n # ...in that case, the odds should be 100% in favor of the 100% team.\n 0.5 + 0.5 * delta\nend", "def team_with_more_points(game)\n home_points = game[:home_team][:players].collect do |player|\n player[:stats][:points]\n end.inject {|sum, n| sum + n}\n away_points = game[:away_team][:players].collect do |player|\n player[:stats][:points]\n end.inject {|sum, n| sum + n}\n home_points > away_points ? game[:home_team][:team_name] : game[:away_team][:team_name]\nend", "def total_games_by_coach_by_season\n @total_games_by_coach = Hash.new{ |hash, key| hash[key] = 0}\n @by_season_game_team_objects.each do |game_by_season|\n @total_games_by_coach[game_by_season[\"head_coach\"]] += 1\n end\n end", "def heuristic_score(state)\n pieces = state[:pieces]\n player = state[:player]\n total_value(pieces[player]) - total_value(pieces[opponent(player)])\n end", "def overall_WLR\n overall_losses = 0\n overall_wins = 0\n @player_champs_list.each do |champ|\n overall_losses += champ.total_losses\n overall_wins += champ.total_wins\n end\n overall_losses > 0 ? (overall_wins.to_f / overall_losses).round(2) : overall_wins.to_f\n end", "def weeks_spent_percentage\n return 0 if self.total_weeks == 0\n (1 - (weeks_left.to_f / total_weeks)).round(2)\n end", "def grade_percentage\n passed_tests.count / my_tests.count\n end", "def percent_against\n (votes_against.to_f * 100 / (self.votes.size + 0.0001)).round\n end", "def total_points\n\n points = 0\n wattball_matches_as_team1.each do |match|\n points += match.points(1) || 0\n end\n\n wattball_matches_as_team2.each do |match|\n points += match.points(2) || 0\n end\n\n points\n end", "def grade_percentage\n # This is the total number of tests a student (self) has taken.\n student_tests = BoatingTest.all.select do |test|\n test.student == self\n end\n\n # From the total number of tests taken by that student (self), we just want\n # the one's that have passed.\n passed_test = student_tests.select do |test|\n test.status == \"passed\"\n end\n # From the total number of tests taken by that student (self), we just want\n # the one's that have failed.\n failed_test = student_tests.select do |test|\n test.status == \"failed\"\n end\n\n # Now we need to find the percent of tests that this student (self) has\n # passed compared to the total number of tests they have taken.\n # Multiply by 100 to get a % value instead of decimal.\n # ratio = (passed_test.length.to_f)/(student_tests.length)\n # ratio * 100 SAME AS BELOW\n ratio = \"%.2f\" % (passed_test.length.fdiv(student_tests.length)*100).to_s + \"%\"\n # The \"%.2f\"\n end", "def win_ratio_adjustment\n adjustment = 0\n wins = @stats[:wins].to_i\n losses = @stats[:losses].to_i\n player_games = @stats[:games].to_i\n total_games = ::Game.where('status = ?','finished').count\n\n percentage_of_games = (player_games.to_f / total_games.to_f)\n\n if wins > 0 or losses > 0\n adjustment += ((@user.wl_ratio * @ratios[:win_loss_ratio_multiplier])*(percentage_of_games*@ratios[:match_percentage_multiplier]))\n end\n\n adjustment\n end", "def num_points_scored(player_name)\n game_hash.each do |home_or_away, team_values|\n team_values[:players].each do |player|\n if player[:player_name] == player_name \n return player[:points]\n end\n end \n end \nend", "def num_rounds\n (Math.log(teams.size) / Math.log(2)).to_i\n end", "def percent_high_ranking\n\n count_high = 0\n\n cards.each do |card|\n\n if card.rank >= 11\n count_high += 1\n end\n\n end\n\n\n count_high_f = count_high.to_f\n count_total = cards.length\n count_total_f = count_total.to_f\n\n (100 * (count_high_f/count_total_f)).round(2)\n\n end", "def its_a_tie game\n game.each do |team|\n team_standings = get_team_by_name(team)\n team_standings[:winnings] += 1\n end\nend", "def calculate!\n ov = self[:overall]\n ov[:high_night] = {}\n ov[:winners] = {}\n\n self.each do |player_id, st|\n next if player_id == :overall\n\n ## calculate computed stats for player\n st[:nights] += st[:dates].keys.length # if st[:nights] == 0\n st[:high_night] = st[:dates].values.max\n st[:gold_stars] = 1 if st[:nights] == 29\n st[:warps_per_game] = 1.0 * st[:warps] / st[:games] rescue 0\n st[:warps_per_night] = 1.0 * st[:warps] / st[:nights] rescue 0\n st[:games_per_night] = 1.0 * st[:games] / st[:nights] rescue 0\n st[:wins_per_night] = 1.0 * st[:wins] / st[:nights] rescue 0\n st[:wins_per_game] = 1.0 * st[:wins] / st[:games] rescue 0\n\n ## accumulate overall stats\n [:warps, :wins, :cfbs,\n :mystery_factors, :gold_stars]. each do |field|\n ov[field] += st[field]\n end\n [:wimps, :come_ons].each do |field|\n if st[field]\n ov[field] ||= 0\n ov[field] += st[field]\n end\n end\n # nights won calculation\n st[:dates].each do |date,warps|\n ov[:dates][date] += warps\n hnd = ov[:high_night][date] ||= {:players => [], :warps => 0}\n if hnd[:warps] < warps\n hnd[:players] = [player_id]\n hnd[:warps] = warps\n elsif hnd[:warps] == warps\n hnd[:players].push(player_id)\n end\n end\n end\n\n ## update overall computed stats\n st = self[:overall]\n ov[:games] = ov[:wins]\n ov[:nights] = ov[:dates].keys.length\n ov[:nights] = 29 if ov[:nights] == 0 ## provide sane default\n ov[:nights] = ov[:nights_real] if ov[:nights_real]\n ov[:warps_per_game] = 1.0 * ov[:warps] / ov[:games] rescue 0\n ov[:warps_per_night] = 1.0 * ov[:warps] / ov[:nights] rescue 0\n ov[:games_per_night] = 1.0 * ov[:games] / ov[:nights] rescue 0\n ov[:high_night].each do |date,h|\n h[:players].each {|p| self[p][:nights_won] += 1}\n end\n\n ## determine per-stat winners\n # fuck everyone but the top 50 OR those with 50+ warps\n # the 51 below is not a bug\n sorted_players = self.keys.sort{|a,b| self[b][:warps] <=> self[a][:warps]}\n fifty_plus = self.keys.select{|p| self[p][:warps] >= 50}\n eligible = (sorted_players[0..51] | fifty_plus).\n inject(Hash.new(false)) {|acc,p| acc.merge(p => true)}\n [:warps, :games, :nights, :wins, :nights_won, :cfbs,\n :come_ons, :wimps, :warps_per_game, :warps_per_night,\n :games_per_night, :wins_per_game, :high_night].each do |field|\n owf = ov[:winners][field] = {:players => [], :value => 0}\n self.each do |player, st|\n next if player == :overall\n next unless eligible[player]\n if st[field].to_f > owf[:value]\n owf[:players] = [player]\n owf[:value] = st[field]\n elsif st[field] == owf[:value]\n owf[:players].push(player)\n end\n end\n end\n\n ## mark per-stat winners\n ov[:winners].each do |field, win|\n win[:players].each do |player|\n self[player][:winner][field] = true\n end\n end\n\n self\n end", "def wins()\n\t\tself.as_regular_contestants.select{|c| c.win()}.size()\n\tend", "def rating\n position_sum = 0\n games = []\n number_of_teams = 0\n Participation.find_all_by_player_id(self.id).each do |participation|\n position_sum += participation.position\n games.push Game.find(participation.game_id)\n end\n\n games.each do |game|\n number_of_teams += game.number_of_teams\n end\n\n if position_sum == 0\n position_sum = number_of_teams.to_f-0.5\n end\n\n (1 - position_sum.to_f/number_of_teams).round 2\n end", "def grade_percentage\n all_tests = BoatingTest.all.select do |test|\n test.student == self\n end\n passed_tests = all_tests.select do |test|\n test.status == \"passed\"\n end\n passed_tests.length.to_f/all_tests.length.to_f\n end", "def ranks\n @teams = Team.where(\"wins > 0\t\").order(win_percentage: :desc)\n end", "def grade_percentage\n # get the number of passing tests as a float\n passing_tests = tests.select { |test| test.test_status == \"passed\" }.length.to_f\n # get total number of all that students tests\n all_tests = tests.length.to_f\n # calculate their passing_tests as a % of their total tests\n passing_tests / all_tests * 100\n end", "def test_percentage_visitor_wins\n assert_equal 0.36, @stat_tracker.percentage_visitor_wins\n end", "def bp_odds_on_favorite\n\t\tfav_team=Teamseason.new\n\t\tfav_team.year=self.matchup_year\n\t\tfav_team.team=self.favorite \n\t\tunderdog_team=Teamseason.new\n\t\tunderdog_team.year=self.matchup_year\n\t\tunderdog_team.team=self.underdog\n\t\treturn fav_team.bp_ros_win_pct.to_f.odds_against_opponent(underdog_team.bp_ros_win_pct.to_f)\n\tend", "def most_accurate_team(seasonasstring) # shots in game team stats\n #get a list of all teams that played in that season - given by arg\n #use above list to sum all shots across all games in season\n #divide above by goals made across all games in season\n #find highest percentage\n #return team name as found in 127\n end" ]
[ "0.8364513", "0.82717276", "0.801916", "0.79849905", "0.7951478", "0.7703494", "0.7587434", "0.75775856", "0.73771405", "0.73579997", "0.7319697", "0.7281446", "0.72513896", "0.7229507", "0.72288597", "0.71901476", "0.71892023", "0.7121625", "0.7121457", "0.70859313", "0.70859313", "0.7064331", "0.7041693", "0.7030677", "0.70210034", "0.701862", "0.7017986", "0.7014494", "0.6966313", "0.69576603", "0.69574547", "0.6937472", "0.6907183", "0.686937", "0.6868283", "0.686261", "0.6858086", "0.6845763", "0.6825527", "0.6798864", "0.6788334", "0.6788043", "0.67688715", "0.67665493", "0.6750812", "0.6750812", "0.67313915", "0.67201084", "0.67069566", "0.6702481", "0.67011595", "0.66986686", "0.669714", "0.6693388", "0.66822195", "0.66795367", "0.66779023", "0.66655433", "0.66642976", "0.66617924", "0.66603726", "0.6655592", "0.66518104", "0.664465", "0.66359407", "0.6635933", "0.6634715", "0.66221994", "0.6621336", "0.6613165", "0.6601661", "0.6601661", "0.659092", "0.659092", "0.6589928", "0.65885293", "0.65832263", "0.65814835", "0.65417236", "0.65344554", "0.6527752", "0.6513087", "0.6505684", "0.65003574", "0.6496972", "0.6496391", "0.6492475", "0.6489571", "0.6480901", "0.64697057", "0.646949", "0.64693284", "0.6466207", "0.64633137", "0.6460777", "0.64601177", "0.6449879", "0.6439599", "0.64314926", "0.64314234" ]
0.91415334
0
returns percentage of games an away team has won
def percentage_visitor_wins visitor_wins = @teams.map { |team| team.away_wins }.sum visitor_games = @teams.map { |team| team.away_games }.sum (visitor_wins.to_f / visitor_games.to_f).round(2) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def percentage_home_wins\n home_wins = @teams.map { |team| team.home_wins }.sum\n home_games = @teams.map { |team| team.home_games }.sum\n (home_wins.to_f / home_games.to_f).round(2)\n end", "def player_win_percentage\n (games_won/user_games)\n end", "def coach_win_percent_in_season(coach, game_ids)\n (total_wins_of_coach_in_season(coach, game_ids) / total_coach_games_in_season(coach, game_ids).to_f).round(2)\n end", "def percent_wins(wins)\n ((wins.to_f / @num_games.to_f) * 100).round(4)\n end", "def win_percent\n matchmade_games < 1 ? 0 : ((total_exp.to_f/matchmade_games.to_f) * 100).to_d\n end", "def average_goals_per_game\n total_goals = @teams.map {|team| team.total_goals_scored}.sum\n total_games = @teams.map {|team| team.home_games}.sum\n (total_goals.to_f / total_games.to_f).round(2)\n end", "def get_standings(games)\n teams = Hash.new\n games.each do |game|\n division_id = game.division_id\n home_team = game.home_team\n away_team = game.visiting_team\n if(teams[home_team.name].nil?)\n teams[home_team.name] = {:win => 0, :loss => 0, :tie => 0, :point=> 0}\n end\n\n if(teams[away_team.name].nil?)\n teams[away_team.name] = {:win => 0, :loss => 0, :tie => 0, :point => 0}\n end\n if(game.home_team_score && game.visiting_team_score)\n if(game.home_team_score > game.visiting_team_score)\n # home team won\n teams[home_team.name][:win] += 1\n teams[home_team.name][:point] += 5\n # visiting team loss\n teams[away_team.name][:loss] += 1\n elsif(game.home_team_score < game.visiting_team_score)\n # home team loss\n teams[home_team.name][:loss] += 1\n #visiting team won\n teams[away_team.name][:win] += 1\n teams[away_team.name][:point] += 5\n else\n # tie game\n teams[home_team.name][:tie] += 1\n teams[home_team.name][:point] += 1\n teams[away_team.name][:tie] += 1\n teams[away_team.name][:point] += 1\n end\n end\n end\n teams.each do |team, value|\n puts team\n total_games = value[:win] + value[:loss] + value[:tie]\n if total_games > 0 \n win_percentage = value[:win]/total_games.to_f\n else\n win_percentage = 0\n end \n value[:percentage] = win_percentage\n end\n teams_sorted = teams.sort_by{ |k, v| v[:point]}.reverse\n return teams_sorted\n end", "def wins\n wins = 0\n self.teams.each do |team|\n wins += team.games_won.length\n end\n wins\n end", "def winning_team\n home_team_sum = 0\n away_team_sum = 0\n game_hash.each do |team, team_stats|\n if team_stats[:team_name] == \"Brooklyn Nets\"\n team_stats[:players].each do |player_stats|\n home_team_sum += player_stats[:points]\n end\n elsif team_stats[:team_name] == \"Charlotte Hornets\"\n team_stats[:players].each do |player_stats|\n away_team_sum += player_stats[:points]\n end\n end\n end\n if home_team_sum > away_team_sum\n game_hash[:home][:team_name]\n elsif home_team_sum < away_team_sum\n game_hash[:away][:team_name]\n end\nend", "def rounds_won_percentage\n (@rounds_played > 0) ? @rounds_won.to_f / @rounds_played : 0\n end", "def winning_team\n home_score = 0\n away_score = 0\n game_hash[:home][:players].keys.each do |name|\n home_score += game_hash[:home][:players][name][:points]\n end\n game_hash[:away][:players].keys.each do |name|\n away_score += game_hash[:away][:players][name][:points]\n end\n home_score > away_score ? game_hash[:home][:team_name] : game_hash[:away][:team_name]\nend", "def winning_team\n if homeTeamPoints.sum > awayTeamPoints.sum\n \"Brooklyn Nets\"\n else\n \"Charlotte Hornets\"\n end\nend", "def calc_pct(wins, losses)\n return (wins + losses) == 0 ? 0.0 : wins.to_f / (wins + losses).to_f\nend", "def power_play_goal_percentage(seasonasstring) # power_play info in game team stat\n #find list of all games in season given by arg\n #sum all power play goals\n #sum all power play oppertunities\n #divide line 146 and line 147\n #return total of above\n end", "def get_win_percentage(strategy)\n score = 0\n @turns.each do |t|\n score += t.result.to_i if t.strategy.include?(strategy)\n end\n score\n end", "def winning_team\n home_points = collection_by_prop(game_hash[:home], :points).reduce(0, :+)\n away_points = collection_by_prop(game_hash[:away], :points).reduce(0, :+)\n home_points > away_points ? game_hash[:home][:team_name] : game_hash[:away][:team_name]\n end", "def away_shoot_percent\n away_shoot_percent = @schedule.away_score / game_stat.away_sog.to_f * 100\n away_shoot_percent.round(2)\n end", "def oppg\n (opp_possessions.to_f)/games\n end", "def oppg\n (opp_possessions.to_f)/games\n end", "def winning_team\n home_team_points = game_hash[:home][:players].sum { |e| e[:points] }\n away_team_points = game_hash[:away][:players].sum { |e| e[:points] }\n\n if home_team_points > away_team_points\n return game_hash[:home][:team_name]\n else\n return game_hash[:away][:team_name]\n end\nend", "def pct()\n\t (self.wins()==0) ? 0 : self.wins().to_f/(self.wins()+self.losses()) \n\tend", "def winning_team\n final_scores = player_collection.reduce(home: 0, away: 0) { |teams_points, next_player|\n case \n when next_player[:location] === :away\n teams_points[:away] += next_player[:points];\n when next_player[:location] === :home\n teams_points[:home] += next_player[:points];\n end\n teams_points; \n }\n winner = final_scores.reduce { |highest_points, team_points| \n highest_points[1] > team_points[1] ? highest_points : team_points; \n }\n game_hash[winner[0]][:team_name]; \nend", "def winning_team\n home_points = 0\n away_points = 0\n result = \"\"\n i = 0\n game_hash.each do |team, about|\n about[:players].each do |name , stats|\n if i == 0\n home_points += stats[:points]\n else\n away_points += stats[:points]\n end\n end\n i += 1\n end\n home_points > away_points ? result = game_hash[:home][:team_name] : result = game_hash[:away][:team_name]\nend", "def goals_against()\n\t self.as_regular_contestants.select{|c| c.opponent.score}.collect{|c| c.opponent.score}.inject{|gf, c| gf + c} || 0\n\tend", "def total_score\n @all_games.map do |games|\n games[\"home_goals\"].to_i + games[\"away_goals\"].to_i\n end\n end", "def achievements_percentage\n achievements_done.to_f / @achievements.size\n end", "def get_games_won()\n return @score_count.get_games_won()\n end", "def get_percent_of_vote\n\t\t(@votes.count(@winner).to_f / @votes.count.to_f * 100).round\n\tend", "def total_score\n sum = self.games.sum{|game|game.points}\n sum.to_i / self.games.count\n end", "def winning_team\n points_home = 0\n points_away = 0\n result = \"\"\n\n game_hash.each do |side,team|\n team.each do |specs,info|\n if specs == :players\n info.each do |player|\n if side = :home\n points_home += player[:points]\n else\n points_away += player[:points]\n end\n end\n end\n end\n end\n if points_home > points_away\n result = game_hash[:home][:team_name]\n else\n result = game_hash[:away][:team_name]\n end\n result\nend", "def goals_against(team)\n valid = ((team == self.home_team or team == self.away_team) and self.final)\n\n if (valid)\n if (self.home_team == team)\n return self.awayScore\n else\n return self.homeScore\n end\n else\n return 0\n end\n end", "def goals_for(team)\n valid = ((team == self.home_team or team == self.away_team) and self.final)\n\n if (valid)\n if (self.home_team == team)\n return self.homeScore\n else\n return self.awayScore\n end\n else\n return 0\n end\n end", "def determine_winner game\n winner = game.max_by {|team| team[:score]}\n team_standings = get_team_by_name(winner)\n team_standings[:winnings] += 3\nend", "def test_percentage_home_wins\n assert_equal 0.44, @stat_tracker.percentage_home_wins\n end", "def average_win_percentage(team_id)\n team_id = team_id.to_i\n team = @teams.select { |each_team| each_team.team_id == team_id }.first\n team.total_win_percentage.round(2)\n end", "def home_shoot_percent\n home_shoot_percent = @schedule.home_score / game_stat.home_sog.to_f * 100\n home_shoot_percent.round(2)\n end", "def calculate_winnings\n result = 0\n self.bookings.each do |booking|\n if booking.match.status == \"FINISHED\"\n if booking.won\n result += booking.stake * booking.odd.odds\n else\n booking.stake ? result -= booking.stake : result\n end\n end\n end\n return result.round(2)\n end", "def pick_percentage\n self.score.to_f / Matchup.amount_finished.to_f\n end", "def pri_tdef\n team_stats.opp_goals_per_game / team_stats.opp_avg_goals_against_per_game\n end", "def outcome\n if self.final\n \th = home_team\n \ta = away_team\n \t# h.wins=0 if h.wins==nil\n \t# h.losses=0 if h.losses==nil\n \t# a.wins=0 if a.wins==nil\n \t# a.losses=0 if a.losses==nil\n \tif home_score == away_score\n \t\treturn 'T'\n \telsif home_score > away_score\n \t\tif !self.recorded\n \t \t\th.wins += 1\n \t \t\ta.losses += 1\n \t \t\th.save\n \t \t\ta.save\n \t \t\tself.recorded=true\n \t \t\tself.save\n \t \tend\n \t\tif overtime\n \t\t\treturn 'h'\n \t\telse\n \t\t\treturn 'H'\n \t\tend\n \telse\n \t\tif !self.recorded\n \t \t\th.losses += 1\n \t \t\ta.wins += 1\n \t \t\ta.save\n \t \t\th.save\n \t \t\tself.recorded=true\n \t \t\tself.save\n \t \tend\n \t\tif overtime\n \t\t\treturn 'a'\n \t\telse\n \t\t\treturn 'A'\n \t\tend\n \tend\n end\n end", "def game_ratio(nick)\n pa = $db[:player_action]\n udb = $db[:uno]\n\n games = udb.where(nick: nick).all[0]\n\n dataset = $db[\"SELECT count(game) FROM player_action pa where pa.action = 0 and pa.player = ?\n and exists (select game from player_action pa2 where pa.game = pa2.game and pa2.action = 0 and pa2.player like 'unobot%')\n and exists (select 1 from games where id = pa.game and end is not null)\", nick]\n puts dataset.all[0].to_a[0][1].to_f, games[:games].to_f\n dataset.all[0].to_a[0][1].to_f / games[:games].to_f\nend", "def get_other_games_won()\n @score_count.get_other_games_won()\n end", "def avarage_calories_burned\n total_workout_calories / set_sport_by_user.count\n rescue\n 0\n end", "def pri_toff\n team_stats.goals_per_game / team_stats.opp_avg_goals_per_game\n end", "def average_goals_by_season\n goals_by_season = @games.group_by { |game| game.season.to_s }\n goals_by_season.each do |season, games|\n season_goals = games.map { |game| game.home_goals + game.away_goals }.sum\n goals_by_season[season] = (season_goals.to_f / games.count.to_f).round(2)\n end\n end", "def winning_team\n team_p = []\n team_n = []\n\n game_hash.each do | location, team_data|\n temp = 0\n team_data[:players].each do |p_name, stats|\n temp += stats[:points]\n end\n team_n << team_data[:team_name]\n team_p << temp\n end\n\n team_p[0] > team_p[1] ? team_n[0] : team_n[1]\n\nend", "def overall_WLR\n overall_losses = 0\n overall_wins = 0\n @player_champs_list.each do |champ|\n overall_losses += champ.total_losses\n overall_wins += champ.total_wins\n end\n overall_losses > 0 ? (overall_wins.to_f / overall_losses).round(2) : overall_wins.to_f\n end", "def team_with_more_points(game)\n home_points = game[:home_team][:players].collect do |player|\n player[:stats][:points]\n end.inject {|sum, n| sum + n}\n away_points = game[:away_team][:players].collect do |player|\n player[:stats][:points]\n end.inject {|sum, n| sum + n}\n home_points > away_points ? game[:home_team][:team_name] : game[:away_team][:team_name]\nend", "def pri_goal_percentage\n shots_on_goal > 0 ? goals.to_f / shots_on_goal : 1.0\n end", "def grade_percentage\n passed_tests = boating_tests.select { |tests| tests.test_status == \"Pass\" }\n (passed_tests.count.to_f / boating_tests.count.to_f) * 100\n end", "def get_total_games_played\n return games.size\n end", "def bp_odds_on_favorite\n\t\tfav_team=Teamseason.new\n\t\tfav_team.year=self.matchup_year\n\t\tfav_team.team=self.favorite \n\t\tunderdog_team=Teamseason.new\n\t\tunderdog_team.year=self.matchup_year\n\t\tunderdog_team.team=self.underdog\n\t\treturn fav_team.bp_ros_win_pct.to_f.odds_against_opponent(underdog_team.bp_ros_win_pct.to_f)\n\tend", "def winning_team\n nets = []\n hornets = []\n\n game_hash.values.each do |nets_stats|\n if nets_stats[:team_name] == \"Brooklyn Nets\"\n nets_stats[:players].each do |bk|\n nets << bk[:points]\n end\n end\n end\n\n game_hash.values.each do |hornets_stats|\n if hornets_stats[:team_name] == \"Charlotte Hornets\"\n hornets_stats[:players].each do |ch|\n hornets << ch[:points]\n end\n end\n end\n\n if nets.reduce(:+) > hornets.reduce(:+)\n return \"Brooklyn Nets\"\n else\n return \"Charlotte Hornets\"\n end\nend", "def probability_by_win_ratio(delta)\n # A team wins between 0% and 100% of its games\n # Comparing two teams, the difference in percentages will also be between 0% and 100%\n # If they have equal win percentages, then it is a tossup--50/50\n # If one team has won 100% and the other has won 0%,\n # ...then there is a 100% win percentage different between them\n # ...in that case, the odds should be 100% in favor of the 100% team.\n 0.5 + 0.5 * delta\nend", "def get_total_games_played\n\t\treturn games.size\n\tend", "def alive_percentage\n hp.to_f / hit_points\n end", "def percent_passes; end", "def percent_passes; end", "def calculate_created_odds_won\n counter = 0\n counter += self.odds.joins(:match).where(matches: {status: 'FINISHED'}).where(odds: {outcome: 'Away'}).where(\"matches.goals_home_team < matches.goals_away_team\").count\n counter += self.odds.joins(:match).where(matches: {status: 'FINISHED'}).where(odds: {outcome: 'Home'}).where(\"matches.goals_home_team > matches.goals_away_team\").count\n counter += self.odds.joins(:match).where(matches: {status: 'FINISHED'}).where(odds: {outcome: 'Draw'}).where(\"matches.goals_home_team = matches.goals_away_team\").count\n return counter\n end", "def worst_offense\n teams_total_goals = total_goals_helper\n teams_total_games = total_games_helper\n\n worst_team_goals_avg = 1000\n worst_offense_team_id = 0\n this_team_goals_avg = 0\n\n teams_total_games.each do |games_key, games_value|\n teams_total_goals.each do |goals_key, goals_value|\n if goals_key == games_key\n this_team_goals_avg = (goals_value / games_value.to_f)\n if this_team_goals_avg < worst_team_goals_avg\n worst_team_goals_avg = this_team_goals_avg\n worst_offense_team_id = games_key\n end\n end\n end\n end\n\n team_with_worst_offense = nil\n self.teams.each_value do |team_obj|\n if team_obj.team_id. == worst_offense_team_id\n team_with_worst_offense = team_obj.team_name\n end\n end\n team_with_worst_offense\n end", "def points_in_team(team)\r\n perfs = self.performances.where(team: team)\r\n perfs.map(&:points).inject(:+) / perfs.length\r\n end", "def calculate_score\n statuses = Tile::STATUSES\n missed_shots = starting_shots - shots_remaining\n hit_shots = board.board.flatten.select do |tile|\n [statuses[:hit], statuses[:sunk]].include?(tile.status)\n end\n hit_shots = hit_shots.count\n total_time = (Time.now - starting_time).round\n ((500 * hit_shots) - (50 * missed_shots)) / total_time\n end", "def wins_losses\n GAME_INFO.each do |game|\n @team_records.each do |team|\n if game[:home_team] == team.name && game[:home_score] > game[:away_score] #refactor later\n team.wins += 1\n elsif game[:home_team] == team.name && game[:home_score] < game[:away_score]\n team.losses += 1\n end\n end\n end\n\n GAME_INFO.each do |game|\n @team_records.each do |team|\n if game[:away_team] == team.name && game[:away_score] > game[:home_score] #refactor later\n team.wins += 1\n elsif game[:away_team] == team.name && game[:away_score] < game[:home_score]\n team.losses += 1\n end\n end\n end\n\n end", "def get_game_stats(game)\n agent = Mechanize.new\n html = agent.get(\"http://espn.go.com/ncb/boxscore?gameId=#{game.gameID}\").body\n doc = Nokogiri::HTML(html)\n\n awayRecs = doc.xpath(\"//div[@class = 'team-info']\").css(\"p\")[0].text\n awayOvrRaw = awayRecs.scan(/(\\d+)-(\\d+),.*/)\n if(awayOvrRaw != [] )\n awayOvrPer = awayOvrRaw[0][0].to_f / (awayOvrRaw[0][1].to_f + awayOvrRaw[0][0].to_f)\n else\n awayOvrPer = 0.05\n end\n awayRaw = awayRecs.scan(/.*, (\\d+)-(\\d+)/)\n if(awayRaw != [])\n awayPer = awayRaw[0][0].to_f / (awayRaw[0][1].to_f + awayRaw[0][0].to_f)\n else\n awayPer = 0.05 \n end\n homeRecs = doc.xpath(\"//div[@class = 'team-info']\").css(\"p\")[1].text\n homeOvrRaw = homeRecs.scan(/(\\d+)-(\\d+),.*/)\n if(homeOvrRaw != [])\n homeOvrPer = homeOvrRaw[0][0].to_f / (homeOvrRaw[0][1].to_f + homeOvrRaw[0][0].to_f) \n else\n homeOvrPer = 0.05\n end\n homeRaw = homeRecs.scan(/.*, (\\d+)-(\\d+)/)\n if(homeRaw != [])\n homePer = homeRaw[0][0].to_f / (homeRaw[0][1].to_f + homeRaw[0][0].to_f)\n else\n homePer = 0.05\n end\n # Find the table with information\n table = doc.xpath('//table[@class = \"mod-data\"]')\n rows = table.css('tbody')\n\n # Declare variables\n isHome = false\n homePoints = 0\n awayPoints = 0\n\n # Get data for game\n rows.each do |row|\n col = row.css('td')\n if(col.count == 18)\n fg = col[1].text.scan((/(\\d+)-(\\d+)/)) \n fgm = fg[0][0].to_f\n fga = fg[0][1].to_f\n fgPer = fgm / fga\n\n threeP = col[2].text.scan((/(\\d+)-(\\d+)/))\n threePM = threeP[0][0].to_f\n threePA = threeP[0][1].to_f\n threePer = threePM / threePA\n\n twoPM = fgm - threePM\n twoPA = fga - threePA\n twoPer = twoPM.to_f / twoPA.to_f\n\n ft = col[3].text.scan((/(\\d+)-(\\d+)/))\n ftm = ft[0][0].to_f\n fta = ft[0][1].to_f\n ftPer = ftm / fta\n\n offReb = col[4].text.to_f\n defReb = col[5].text.to_f\n totReb = col[6].text.to_f\n assists = col[7].text.to_f\n steals = col[8].text.to_f\n blocks = col[9].text.to_f\n to = col[10].text.to_f\n pf = col[11].text.to_f\n\n points = col[12].text.to_f\n pps = points / fga\n adjFG = ((points - ftm)/ fga)/ 2\n\n apto = assists / to\n spto = steals / to\n spf = steals / pf\n bpf = blocks / pf\n \n # Updates specific game entry with newly scraped data\n if(isHome)\n game.update(homePoints: points, homefgm: fgm, homefga: fga, homefgPer: fgPer, hometwoMade: twoPM, hometwoAtt: twoPA, hometwoPer: twoPer, homethreeMade: threePM, homethreeAtt: threePA, homethreePer: threePer, homeftm: ftm, homefta: fta, homeftPer: ftPer, homeoffReb: offReb, homedefReb: defReb, hometotalReb: totReb, homepps: pps, homeadjFG: adjFG, homeassist: assists, hometo: to, homeapto: apto, homesteals: steals, homefouls: pf, homestealPerTO: spto, homestealPerFoul: spf, homeblocks: blocks, homeblocksPerFoul: bpf, homeOvrWL: homeOvrPer, homeHomeWL: homePer)\n elsif\n game.update(awaypoints: points, awayfgm: fgm, awayfga: fga, awayfgPer: fgPer, awaytwoMade: twoPM, awaytwoAtt: twoPA, awaytwoPer: twoPer, awaythreeMade: threePM, awaythreeAtt: threePA, awaythreePer: threePer, awayftm: ftm, awayfta: fta, awayftPer: ftPer, awayoffReb: offReb, awaydefReb: defReb, awaytotalReb: totReb, awaypps: pps, awayadjFG: adjFG, awayassist: assists, awayto: to, awayapto: apto, awaysteals: steals, awayfouls: pf, awaystealPerTO: spto, awaystealPerFoul: spf, awayblocks: blocks, awayblocksPerFoul: bpf, awayOvrWL: homeOvrPer, awayAwayWL: awayPer)\n end\n\n # Always two rows, first is away, second is home\n isHome = true\n end\n end \n end", "def heuristic_score(state)\n pieces = state[:pieces]\n player = state[:player]\n total_value(pieces[player]) - total_value(pieces[opponent(player)])\n end", "def worst_defense\n teams_total_goals_allowed = total_goals_allowed_helper\n teams_total_games = total_games_helper\n\n worst_team_goals_allowed_avg = 0\n worst_defense_team_id = 0\n this_team_goals_allowed_avg = 0\n\n teams_total_games.each do |games_key, games_value|\n\n teams_total_goals_allowed.each do |goals_key, goals_value|\n if goals_key == games_key\n this_team_goals_allowed_avg = (goals_value / games_value.to_f)\n if this_team_goals_allowed_avg > worst_team_goals_allowed_avg\n worst_team_goals_allowed_avg = this_team_goals_allowed_avg\n worst_defense_team_id = games_key\n end\n end\n end\n end\n team_with_worst_defense = team_name_finder_helper(worst_defense_team_id)\n\n team_with_worst_defense\n end", "def win_ratio_adjustment\n adjustment = 0\n wins = @stats[:wins].to_i\n losses = @stats[:losses].to_i\n player_games = @stats[:games].to_i\n total_games = ::Game.where('status = ?','finished').count\n\n percentage_of_games = (player_games.to_f / total_games.to_f)\n\n if wins > 0 or losses > 0\n adjustment += ((@user.wl_ratio * @ratios[:win_loss_ratio_multiplier])*(percentage_of_games*@ratios[:match_percentage_multiplier]))\n end\n\n adjustment\n end", "def hours_spent_percentage\n return 1 if hours_planned == 0\n (hours_spent.to_f / hours_planned).round(2)\n end", "def hours_spent_percentage\n return 1 if hours_planned == 0\n (hours_spent.to_f / hours_planned).round(2)\n end", "def its_a_tie game\n game.each do |team|\n team_standings = get_team_by_name(team)\n team_standings[:winnings] += 1\n end\nend", "def total_team_score(teams_id)\n total_score = 0\n @league_data.each do\n |team| \n # binding.pry\n if team.home_team_id == teams_id\n total_score += team.home_team_score\n elsif team.away_team_id == teams_id\n total_score += team.away_team_score\n end\n end\n return total_score\n end", "def num_rounds\n (Math.log(teams.size) / Math.log(2)).to_i\n end", "def total\n wins + losses\n end", "def score\n goals = self.match_events.select { |e| e.event_type == MatchEvent::EventType::GOAL }\n goals.reduce({away: 0, home: 0}) do |score, e|\n if e.event_author == MatchEvent::EventAuthor::HOME\n score[:home] += 1\n elsif e.event_author == MatchEvent::EventAuthor::AWAY\n score[:away] += 1\n end\n score\n end\n end", "def game_score\n previous_hands = self.game_player.hand_players.joins(:hand).where(\n \"hands.position <= ?\", self.hand.position\n )\n gs = 0\n for h in previous_hands\n gs += h.hand_score\n end\n return gs\n end", "def total_points\n\n points = 0\n wattball_matches_as_team1.each do |match|\n points += match.points(1) || 0\n end\n\n wattball_matches_as_team2.each do |match|\n points += match.points(2) || 0\n end\n\n points\n end", "def games_played\n self.results.to_a.count\n end", "def percent_high_ranking\n percent = high_ranking_cards.length / cards.length.to_f\n end", "def num_points_scored (searched_player)\n player_points = 0\n game_hash[:away][:players].each do |player_data|\n if player_data[:player_name] == searched_player\n player_points = player_data[:points]\n end\n end\n game_hash[:home][:players].each do |player_data|\n if player_data[:player_name] == searched_player\n player_points = player_data[:points]\n end\n end\n player_points\nend", "def wins()\n\t\tself.as_regular_contestants.select{|c| c.win()}.size()\n\tend", "def grade_percentage\n tests = BoatingTest.all.select {|test| test.student.first_name == self.first_name}\n passed_tests = tests.select {|test| test.test_status == \"passed\"}\n per = (passed_tests.length.to_f / tests.length.to_f)*100\n \n end", "def games_played\n games.size\n end", "def games_played\n games.size\n end", "def best_defense\n teams_total_goals_allowed = total_goals_allowed_helper\n teams_total_games = total_games_helper\n\n best_team_goals_allowed_avg = 100\n best_defense_team_id = 0\n this_team_goals_allowed_avg = 0\n\n teams_total_games.each do |games_key, games_value|\n teams_total_goals_allowed.each do |goals_key, goals_value|\n if goals_key == games_key\n this_team_goals_allowed_avg = (goals_value / games_value.to_f)\n if this_team_goals_allowed_avg < best_team_goals_allowed_avg\n best_team_goals_allowed_avg = this_team_goals_allowed_avg\n best_defense_team_id = games_key\n end\n end\n end\n end\n\n team_with_best_defense = nil\n self.teams.each_value do |team_obj|\n if team_obj.team_id. == best_defense_team_id\n team_with_best_defense = team_obj.team_name\n end\n end\n team_with_best_defense\n end", "def overall_KDR\n overall_deaths = 0\n overall_kills = 0\n @player_champs_list.each do |champ|\n overall_deaths += champ.total_deaths\n overall_kills += champ.total_kills\n end\n overall_deaths > 0 ? (overall_kills.to_f / overall_deaths).round(2) : overall_kills.to_f\n end", "def num_points_scored(player_name)\n game_hash.each do |home_or_away, team_values|\n team_values[:players].each do |player|\n if player[:player_name] == player_name \n return player[:points]\n end\n end \n end \nend", "def winning_team\n home_points = 0\n away_points = 0\n team1 = \"Brooklyn Nets\"\n team2 = \"Charlotte Hornets\"\n game_hash.each do |team,info|\n info.each do |team_info,team_data|\n if team_data.is_a? (Array) \n if team_info != :colors\n if info[:team_name] == \"Brooklyn Nets\"\n team_data.each do |player_index|\n home_points += player_index[:points]\n end\n else \n team_data.each do |player_index|\n away_points += player_index[:points]\n winning_team end\n end\n end\n end\n end\n end\n\n if home_points > away_points\n team1\n else\n team2\n end\n\nend", "def calculate!\n ov = self[:overall]\n ov[:high_night] = {}\n ov[:winners] = {}\n\n self.each do |player_id, st|\n next if player_id == :overall\n\n ## calculate computed stats for player\n st[:nights] += st[:dates].keys.length # if st[:nights] == 0\n st[:high_night] = st[:dates].values.max\n st[:gold_stars] = 1 if st[:nights] == 29\n st[:warps_per_game] = 1.0 * st[:warps] / st[:games] rescue 0\n st[:warps_per_night] = 1.0 * st[:warps] / st[:nights] rescue 0\n st[:games_per_night] = 1.0 * st[:games] / st[:nights] rescue 0\n st[:wins_per_night] = 1.0 * st[:wins] / st[:nights] rescue 0\n st[:wins_per_game] = 1.0 * st[:wins] / st[:games] rescue 0\n\n ## accumulate overall stats\n [:warps, :wins, :cfbs,\n :mystery_factors, :gold_stars]. each do |field|\n ov[field] += st[field]\n end\n [:wimps, :come_ons].each do |field|\n if st[field]\n ov[field] ||= 0\n ov[field] += st[field]\n end\n end\n # nights won calculation\n st[:dates].each do |date,warps|\n ov[:dates][date] += warps\n hnd = ov[:high_night][date] ||= {:players => [], :warps => 0}\n if hnd[:warps] < warps\n hnd[:players] = [player_id]\n hnd[:warps] = warps\n elsif hnd[:warps] == warps\n hnd[:players].push(player_id)\n end\n end\n end\n\n ## update overall computed stats\n st = self[:overall]\n ov[:games] = ov[:wins]\n ov[:nights] = ov[:dates].keys.length\n ov[:nights] = 29 if ov[:nights] == 0 ## provide sane default\n ov[:nights] = ov[:nights_real] if ov[:nights_real]\n ov[:warps_per_game] = 1.0 * ov[:warps] / ov[:games] rescue 0\n ov[:warps_per_night] = 1.0 * ov[:warps] / ov[:nights] rescue 0\n ov[:games_per_night] = 1.0 * ov[:games] / ov[:nights] rescue 0\n ov[:high_night].each do |date,h|\n h[:players].each {|p| self[p][:nights_won] += 1}\n end\n\n ## determine per-stat winners\n # fuck everyone but the top 50 OR those with 50+ warps\n # the 51 below is not a bug\n sorted_players = self.keys.sort{|a,b| self[b][:warps] <=> self[a][:warps]}\n fifty_plus = self.keys.select{|p| self[p][:warps] >= 50}\n eligible = (sorted_players[0..51] | fifty_plus).\n inject(Hash.new(false)) {|acc,p| acc.merge(p => true)}\n [:warps, :games, :nights, :wins, :nights_won, :cfbs,\n :come_ons, :wimps, :warps_per_game, :warps_per_night,\n :games_per_night, :wins_per_game, :high_night].each do |field|\n owf = ov[:winners][field] = {:players => [], :value => 0}\n self.each do |player, st|\n next if player == :overall\n next unless eligible[player]\n if st[field].to_f > owf[:value]\n owf[:players] = [player]\n owf[:value] = st[field]\n elsif st[field] == owf[:value]\n owf[:players].push(player)\n end\n end\n end\n\n ## mark per-stat winners\n ov[:winners].each do |field, win|\n win[:players].each do |player|\n self[player][:winner][field] = true\n end\n end\n\n self\n end", "def damaged_percentage\n 1 - alive_percentage\n end", "def matches_won(user)\n home_matches = user.home_matches.find_all_by_ended(true)\n away_matches = user.away_matches.find_all_by_ended(true)\n home_matches.select { |match| match.homegoals > match.awaygoals }.count +\n away_matches.select { |match| match.homegoals < match.awaygoals }.count\n end", "def test_percentage_visitor_wins\n assert_equal 0.36, @stat_tracker.percentage_visitor_wins\n end", "def grade_percentage\n all_tests = BoatingTest.all.select do |test|\n test.student == self\n end\n passed_tests = all_tests.select do |test|\n test.status == \"passed\"\n end\n passed_tests.length.to_f/all_tests.length.to_f\n end", "def most_accurate_team(seasonasstring) # shots in game team stats\n #get a list of all teams that played in that season - given by arg\n #use above list to sum all shots across all games in season\n #divide above by goals made across all games in season\n #find highest percentage\n #return team name as found in 127\n end", "def away_stat\n @away.team_stat\n end", "def rating\n position_sum = 0\n games = []\n number_of_teams = 0\n Participation.find_all_by_player_id(self.id).each do |participation|\n position_sum += participation.position\n games.push Game.find(participation.game_id)\n end\n\n games.each do |game|\n number_of_teams += game.number_of_teams\n end\n\n if position_sum == 0\n position_sum = number_of_teams.to_f-0.5\n end\n\n (1 - position_sum.to_f/number_of_teams).round 2\n end", "def winningest_team\n @teams.max_by { |team| team.total_win_percentage }.team_name\n end", "def weeks_spent_percentage\n return 0 if self.total_weeks == 0\n (1 - (weeks_left.to_f / total_weeks)).round(2)\n end", "def games_won(player)\n\t\ttiebreak_win = tiebreak && tiebreak.winner_id.eql?(player.id) ? 1 : 0\n\t\tgames.where(winner_id: player.id).count + tiebreak_win\n\tend", "def achievements_percentage\n @achievements.size.to_f / @schema.achievements.size\n end", "def score\n w = 0.3\n time = diff_time()\n sum_goods = goods()\n sum_bads = bads()\n total = sum_goods + sum_bads\n (w * sum_goods * (sum_goods/total.to_f)**3 * (total/time)).floor\n end" ]
[ "0.84977627", "0.8304312", "0.79963154", "0.78871727", "0.78340447", "0.7650898", "0.7477629", "0.744048", "0.7373127", "0.7345225", "0.7310578", "0.730852", "0.7298018", "0.72615695", "0.7252617", "0.7251755", "0.7215588", "0.7140742", "0.7140742", "0.71305853", "0.7126685", "0.71074826", "0.7068733", "0.70652145", "0.70353657", "0.6996249", "0.6956974", "0.6955357", "0.6947225", "0.694206", "0.6926069", "0.690988", "0.69094616", "0.6884948", "0.6880983", "0.68617195", "0.68609357", "0.68434024", "0.68248045", "0.68228173", "0.68068606", "0.6806089", "0.67989564", "0.67923313", "0.67888135", "0.6787407", "0.6777011", "0.676889", "0.67540205", "0.67463523", "0.67404217", "0.67329735", "0.67311174", "0.6726426", "0.6715532", "0.6708958", "0.6703724", "0.6703724", "0.66912764", "0.66900074", "0.668032", "0.6675693", "0.6675002", "0.66654646", "0.66610515", "0.6652109", "0.66230667", "0.66217965", "0.66217965", "0.6599587", "0.6597697", "0.6592713", "0.65870655", "0.6580353", "0.65752566", "0.6568817", "0.6565431", "0.6558831", "0.65547734", "0.6550923", "0.65478146", "0.6545744", "0.6545744", "0.6536197", "0.65337837", "0.65034735", "0.65007323", "0.6490333", "0.6488613", "0.64859974", "0.6484305", "0.6482004", "0.6472314", "0.64709455", "0.64660543", "0.64632046", "0.6462569", "0.6444813", "0.64408034", "0.643799" ]
0.84204584
1
returns season with most games played
def season_with_most_games seasons = @games.group_by { |game| game.season } seasons.max_by { |season, games| games.count }.first end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def season_with_fewest_games\n seasons = @games.group_by { |game| game.season }\n seasons.min_by { |season, games| games.count }.first\n end", "def most_hits(seasonasstring) # shots in game team stats\n #get a list of all teams that played in that season\n #use above list to sum all shots across all games in season\n #find highest across list\n #return team name as found in 139\n end", "def biggest_surprise(season)\n season = season.to_i\n @teams.max_by{ |team| team.preseason_to_regular_increase[season] }.team_name\n end", "def biggest_bust(seasonasstring)\n #get all teams in data\n #find all games played by team in season - given by arg\n #get subset of 95 where p is in season marker\n #count games won in subset on 95 / total games in subset on 95\n #get subset of 85 where r is in season marker\n #count games won in subset on 98 / total games in subset on 98\n #result of line 97 - line 99\n #find highest number\n #return team name of result of line 101\n end", "def count_of_games_by_season\n games_by_season = @games.group_by { |game| game.season.to_s }\n games_by_season.each { |season, games| games_by_season[season] = games.count }\n end", "def best_season(id)\n wins = total_wins_per_team_per_season(id)\n totals = total_games_per_team_per_season(id)\n totals.each do |season, total|\n totals[season] = (wins[season] / total.to_f * 100).round(2)\n end\n totals.max_by {|k,v| v}[0]\n end", "def biggest_bust(season)\n season = season.to_i\n @teams.min_by{ |team| team.preseason_to_regular_increase[season] }.team_name\n end", "def winningest_coach(seasonasstring) # coach name in game team stats\n #per season, get list of all coaches - given by arg\n #per coach, find all games played by that coach\n #then count of all games won / count of all games played\n #find highest\n #return name of coach found in 114\n end", "def most_popular_venue\n venues = @games.group_by { |game| game.venue}\n venues.max_by { |venue, games| games.count }.first\n end", "def best_season(team_id)\n team_id = team_id.to_i\n team = @teams.select { |each_team| each_team.team_id == team_id }.first\n team.season_win_percentages.max_by { |season, percentage| percentage }.first.to_s\n end", "def most_accurate_team(seasonasstring) # shots in game team stats\n #get a list of all teams that played in that season - given by arg\n #use above list to sum all shots across all games in season\n #divide above by goals made across all games in season\n #find highest percentage\n #return team name as found in 127\n end", "def retrieve_season_hall_of_fame\n seasons_hall_of_fame = []\n get_involved_teams unless @involved_teams\n\n @involved_teams.each do |team|\n team_placement = {}\n team_placement[:team] = team\n %w[first_place second_place third_place].each_with_index do |rank, index|\n placement = index + 1\n team_placement[rank.to_sym] = team.computed_season_ranking.joins(:season).where(\"seasons.season_type_id = #{@season_type.id} AND computed_season_rankings.rank = #{placement}\").count\n end\n seasons_hall_of_fame << team_placement\n end\n seasons_hall_of_fame.sort { |p, n| (n[:first_place] * 10_000 + n[:second_place] * 100 + n[:third_place]) <=> (p[:first_place] * 10_000 + p[:second_place] * 100 + p[:third_place]) }\n end", "def worst_season(team_id)\n team_id = team_id.to_i\n team = @teams.select { |each_team| each_team.team_id == team_id }.first\n team.season_win_percentages.min_by { |season, percentage| percentage }.first.to_s\n end", "def winningest_team\n @teams.max_by { |team| team.total_win_percentage }.team_name\n end", "def fewest_hits(seasonasstring) # shots in game team stats\n #inverse of above\n end", "def determine_winner game\n winner = game.max_by {|team| team[:score]}\n team_standings = get_team_by_name(winner)\n team_standings[:winnings] += 3\nend", "def least_popular_venue\n venues = @games.group_by { |game| game.venue}\n venues.min_by { |venue, games| games.count }.first\n end", "def calculate_most_common_year\n self.calculate_plays_by_year.sort_by{ |year, times_played| times_played }.last\n end", "def highest_scoring_visitor\n @teams.max_by { |team| team.average_away_goals }.team_name\n end", "def biggestShoes\n players.max_by do|name, stats|\n stats[:shoe]\n end\nend", "def current_season\n self.seasons.find(:first,\n :conditions => {:date => Season.maximum('date')})\n end", "def least_accurate_team(seasonasstring) # shots in game team stats\n #inverse of above\n end", "def max_sets_to_play\n case scoring.to_sym\n when :two_six_game_ten_point\n 3\n when :one_eight_game\n 1\n else # :three_six_game\n 3\n end\n end", "def played_matchs_season(round, season = nil)\n count = 0\n matchs = find_matchs(round, season)\n\n matchs.each do |match|\n if match.finished?\n count += 1\n end\n end\n count\n end", "def biggest_suprise(seasonasstring)\n #as above, but change line 100 to reverse operations, regular percentage - postseason percentage\n end", "def games_played\n games.size\n end", "def games_played\n games.size\n end", "def most_points_scored\n max = nil\n name = nil \n game_hash.each do |team, team_values|\n team_values[:players].each do |player|\n if max == nil || player[:points] > max\n max = player[:points]\n name = player[:player_name]\n end\n end\n end\n name\nend", "def worst_coach(seasonasstring) # coach name in game team stats\n #inverse of above\n end", "def highest_scoring_home_team\n @teams.max_by { |team| team.average_home_goals }.team_name\n end", "def win_matchs_season(round, season = nil)\n count = 0\n matchs = find_matchs(round, season)\n\n matchs.each do |match|\n if match.is_winner?(self) and match.finished?\n count += 1\n end\n end\n count\n end", "def teams_with_score_max(a_game)\n teams_with_score_max = {}\n game_teams_with_score_max = a_game.teams_with_score_max(a_game.game_teams)\n game_teams_with_score_max.each do |game_team_with_score_max|\n # find team instance matching game_team instance\n team_with_score_max = @teams[game_team_with_score_max.name.to_sym]\n teams_with_score_max[game_team_with_score_max.name.to_sym] = team_with_score_max\n end\n teams_with_score_max\n end", "def get_top_games\n game_count = {}\n self.subscriptions.each do |subscription|\n game_id = Channel.find(subscription.channel_id).game_id\n game_count[game_id] ||= 0\n game_count[game_id] += 1\n end\n game_count.sort_by {|key, value| value}.reverse.to_h.keys\n end", "def test_count_of_games_by_season\n\n expected = {\n \"20122013\"=>806,\n \"20162017\"=>1317,\n \"20142015\"=>1319,\n \"20152016\"=>1321,\n \"20132014\"=>1323,\n \"20172018\"=>1355\n }\n assert_equal expected, @stat_tracker.count_of_games_by_season\n\n end", "def next_game_ordinal\n last_set ? last_set.set_games.count + 1 : 0\n end", "def player_w_biggest_feet\n all_players[1].max_by { |stats| stats[:shoe] }\n end", "def worst_defense\n @teams.max_by { |team| team.average_goals_allowed }.team_name\n end", "def per_game_stats(season = nil)\n season_id = season ? season.id : Season.current.id\n StatLine.find_by_sql('SELECT AVG(fgm) as fgm, AVG(fga) as fga, coalesce(AVG(fgm)/nullif(AVG(fga), 0), 0) as fgpct, AVG(twom) as twom, AVG(twoa) as twoa, coalesce(AVG(twom)/nullif(AVG(twoa), 0), 0) as twopct, AVG(threem) as threem, AVG(threea) as threea, coalesce(AVG(threem)/nullif(AVG(threea), 0), 0) as threepct,' \\\n 'AVG(ftm) as ftm, AVG(fta) as fta, coalesce(AVG(ftm)/nullif(AVG(fta), 0), 0) as ftpct, AVG(orb) as orb, AVG(drb) as drb, AVG(trb) as trb, AVG(ast) as ast, AVG(stl) as stl, AVG(blk) as blk, AVG(fl) as fl, AVG(\"to\") as to,' \\\n 'AVG(points) as points, COUNT(*) as game_count, sums.league_id FROM (SELECT SUM(fgm) as fgm, SUM(fga) as fga, SUM(twom) as twom, SUM(twoa) as twoa, SUM(threem) as threem, SUM(threea) as threea,' \\\n 'SUM(ftm) as ftm, SUM(fta) as fta, SUM(orb) as orb, SUM(drb) as drb, SUM(trb) as trb, SUM(ast) as ast, SUM(stl) as stl, SUM(blk) as blk, SUM(fl) as fl, SUM(\"to\") as to,' \\\n \"SUM(points) as points, g.league_id as league_id FROM stat_lines sl INNER JOIN games g ON sl.game_id = g.id \" \\\n \"WHERE g.winner is not null AND (g.forfeit is null or not g.forfeit) AND (sl.dnp is null OR not sl.dnp) AND team_id = #{self.id} AND g.season_id = #{season_id} GROUP BY game_id, g.league_id) sums GROUP BY sums.league_id\")\n end", "def most_points_scored\n most_points_scored = 0\n player_with_the_most_points_scored = \"\"\n game_hash.each do |team,info|\n info.each do |team_info,team_data|\n if team_data.is_a? (Array) \n if team_info != :colors\n team_data.each do |player_index|\n if most_points_scored == 0 || player_index[:points] > most_points_scored \n most_points_scored = player_index[:points]\n player_with_the_most_points_scored = player_index[:player_name]\n end\n end\n end\n end\n end\n end\n player_with_the_most_points_scored\nend", "def most_points(game)\n player_name_with_points = []\n game[:home_team][:players].each do |player_hash|\n player_name_with_points << {player_hash[:player_name] => player_hash[:stats][:points]}\n end\n game[:away_team][:players].each do |player_hash|\n player_name_with_points << {player_hash[:player_name] => player_hash[:stats][:points]}\n end\n player_most_points = {\"test\" => 0}\n player_name_with_points.each do |name_and_points_hash|\n player_most_points = name_and_points_hash if name_and_points_hash.values[0] > player_most_points.values[0]\n end\n player_most_points.keys[0]\nend", "def most_points_scored\n most_points = 0\n player = \"\"\n game_hash.each do |k, team|\n team[:players].each do |e|\n if e[:points] > most_points\n most_points = e[:points]\n player = e[:player_name]\n end\n end\n end\n player\nend", "def most_points_scored\n stat_by_player = collect_stat_by_name(:points)\n player_with_max_stat = find_max_stat_by_player(stat_by_player)\n player_with_max_stat\nend", "def points_season(round, season = nil)\n count = 0\n matchs = find_matchs(round, season)\n\n matchs.each do |match|\n if match.is_winner?(self) and match.finished?\n count += MatchGeneral::PT_WIN\n end\n if match.deal? and match.finished?\n count += MatchGeneral::PT_DEAL\n end\n end\n\n count\n end", "def most_popular_group_per_year\n sql = <<-SQL\n WITH mp AS (\n SELECT show_year,\n guest_group,\n COUNT(id) as group_count\n FROM guest_appearances\n GROUP BY guest_group, show_year)\n SELECT show_year, guest_group, MAX(group_count) as frequency\n FROM mp\n GROUP BY show_year;\n SQL\n DB[:conn].execute(sql).each {|record| puts \"#{record[0]}: #{record[1]}, #{record[2]}.\"}\nend", "def biggest_shoe\r\n player_name= []\r\n game_hash.each do |team, data|\r\n data.each do |team_info, value|\r\n if team_info == \"players\".to_sym\r\n obj=value.max_by {|key, value| value[:shoe]}\r\n player_name<< obj.first\r\n end\r\n end\r\n end\r\n player_name.first\r\nend", "def retrieve_closed_seasons\n @season_type.seasons.where(['end_date < ?', Date.today])\n .sort_season_by_begin_date('DESC')\n end", "def highest_scoring_word\n Scrabble::Scoring.highest_score_from(@plays_array)\n end", "def highest_player_score\n players.max_by{|player| player.score}.score\n end", "def get_closed_seasons\n @closed_seasons ||= retrieve_closed_seasons\n end", "def rank_top_teams # DO NOT USE THIS METHOD, outdated, slow\n @top_teams = {}\n @top_teams = Score.in_challenge(self.id).teams_in_all_divisions.limit(5).\n order(\"sum_points DESC, MAX(#{Score.table_name}.\n earned_at) DESC\").sum(:points) \n return @top_teams\n end", "def big_shoe_rebounds\n max_shoe = 0 \n max_rebounds = 0 \n game_hash.each do |place, team|\n # team.each do |attribute, data|\n team[:players].each do |player|\n if player[:shoe] > max_shoe\n max_shoe = player[:shoe]\n max_rebounds = player[:rebounds]\n # if attribute == :players\n # data.each do |player|\n #this gives me the player hashes\n # data.max_by{|player| player[:shoe] }\n # data.max_by{|player| player[:shoe] }[:rebounds]\n # player.max_by{|player| player[:shoe] \n # player.max_by{|player| player[:shoe] }[:rebounds]\n end\n end\n end\n return max_rebounds\n end", "def best_offense\n @teams.max_by { |team| team.average_goals_scored }.team_name\n end", "def goals_favor_season(round, season = nil)\n count = 0\n matchs = find_matchs(round, season)\n\n matchs.each do |match|\n count += match.goals_favor(self) if match.finished?\n end\n\n count\n end", "def most_popular_profession_per_year\n sql = <<-SQL\n WITH mp AS (\n SELECT show_year,\n guest_occupation,\n \tCOUNT(id) as occupation_count\n FROM guest_appearances\n GROUP BY guest_occupation, show_year)\n SELECT show_year, guest_occupation, MAX(occupation_count) as frequency\n FROM mp\n GROUP BY show_year;\n SQL\n DB[:conn].execute(sql).each {|record| puts \"#{record[0]}: #{record[1]}, #{record[2]}.\"}\nend", "def winning_team\n self.teams.order('score DESC').first\n end", "def get_standings(games)\n teams = Hash.new\n games.each do |game|\n division_id = game.division_id\n home_team = game.home_team\n away_team = game.visiting_team\n if(teams[home_team.name].nil?)\n teams[home_team.name] = {:win => 0, :loss => 0, :tie => 0, :point=> 0}\n end\n\n if(teams[away_team.name].nil?)\n teams[away_team.name] = {:win => 0, :loss => 0, :tie => 0, :point => 0}\n end\n if(game.home_team_score && game.visiting_team_score)\n if(game.home_team_score > game.visiting_team_score)\n # home team won\n teams[home_team.name][:win] += 1\n teams[home_team.name][:point] += 5\n # visiting team loss\n teams[away_team.name][:loss] += 1\n elsif(game.home_team_score < game.visiting_team_score)\n # home team loss\n teams[home_team.name][:loss] += 1\n #visiting team won\n teams[away_team.name][:win] += 1\n teams[away_team.name][:point] += 5\n else\n # tie game\n teams[home_team.name][:tie] += 1\n teams[home_team.name][:point] += 1\n teams[away_team.name][:tie] += 1\n teams[away_team.name][:point] += 1\n end\n end\n end\n teams.each do |team, value|\n puts team\n total_games = value[:win] + value[:loss] + value[:tie]\n if total_games > 0 \n win_percentage = value[:win]/total_games.to_f\n else\n win_percentage = 0\n end \n value[:percentage] = win_percentage\n end\n teams_sorted = teams.sort_by{ |k, v| v[:point]}.reverse\n return teams_sorted\n end", "def lost_matchs_season(round, season = nil)\n count = 0\n matchs = find_matchs(round, season)\n\n matchs.each do |match|\n if match.is_looser?(self) and match.finished?\n count += 1\n end\n end\n\n count\n end", "def most_points_scored\n most_points = 0\n most_points_player = nil\n game_hash.each do |team, team_stats|\n team_stats[:players].each do |player_stats|\n if most_points < player_stats[:points]\n most_points = player_stats[:points]\n most_points_player = player_stats[:player_name]\n end\n end\n end\n most_points_player\nend", "def highest_scoring_word\n Scoring.highest_score_from(plays)\n end", "def get_total_games_played\n return games.size\n end", "def get_total_games_played\n\t\treturn games.size\n\tend", "def worst_offense\n teams_total_goals = total_goals_helper\n teams_total_games = total_games_helper\n\n worst_team_goals_avg = 1000\n worst_offense_team_id = 0\n this_team_goals_avg = 0\n\n teams_total_games.each do |games_key, games_value|\n teams_total_goals.each do |goals_key, goals_value|\n if goals_key == games_key\n this_team_goals_avg = (goals_value / games_value.to_f)\n if this_team_goals_avg < worst_team_goals_avg\n worst_team_goals_avg = this_team_goals_avg\n worst_offense_team_id = games_key\n end\n end\n end\n end\n\n team_with_worst_offense = nil\n self.teams.each_value do |team_obj|\n if team_obj.team_id. == worst_offense_team_id\n team_with_worst_offense = team_obj.team_name\n end\n end\n team_with_worst_offense\n end", "def winner\n @players.max_by do |player|\n player.score\n end\n end", "def worst_offense\n @teams.min_by { |team| team.average_goals_scored }.team_name\n end", "def max_teams(rounds)\n 2**rounds\n end", "def max_teams(rounds)\n 2**rounds\n end", "def winner\n @players.max_by{ |player| player.score}\n end", "def most_goals_scored(team_id)\n team_id = team_id.to_i\n goals_per_game = @game_teams.map do |game|\n if game.team_id == team_id\n game.goals\n end\n end\n goals_per_game.compact.max\n end", "def winning_player\n played_cards.max_by { |_, card| card_scores[card] }.first\n end", "def wins\n wins = 0\n self.teams.each do |team|\n wins += team.games_won.length\n end\n wins\n end", "def select_series_title_with_most_human_characters\n \"SELECT series.title FROM characters INNER JOIN series ON series.id = characters.series_id GROUP BY(characters.species) ORDER BY(COUNT(characters.species)) LIMIT 1;\"\nend", "def most_points_scored()\n points = 0\n result = \"\"\n\n game_hash.each do |side,team|\n team.each do |specs,info|\n if specs == :players\n info.each do |player|\n if player[:points] > points\n points = player[:points]\n result = player[:player_name]\n\n end\n end\n end\n end\n end\n result\nend", "def has_more_rounds_left_in_season?\n next_round = current_round + 1\n next_round <= total_rounds\n end", "def mostSteals\n players.max_by do|name, stats|\n stats[:steals]\n end\nend", "def most_points_scored\n points = 0\n result = \"\"\n game_hash.each do |team, about|\n about[:players].each do |name , stats|\n if points < stats[:points]\n points = stats[:points]\n result = name\n end\n end\n end\n result\nend", "def goals_by_game_situation(season = nil)\n stats_request(\"goalsByGameSituation\", season).first\n end", "def most_wrs\n @mode = params.fetch(:mode, -1).to_i\n @mode = -1 unless @mode.between?(0, 3)\n @players = WorldRecord.most_world_records @mode\n end", "def select_series_title_with_most_human_characters\n \"SELECT series.title\n FROM series\n JOIN characters\n ON series.id = characters.series_id\n WHERE characters.species = 'human'\n GROUP BY series.title\n ORDER BY COUNT(characters.species) DESC LIMIT 1;\"\nend", "def biggest_blowout\n score_difference = games.map { |game| (game.home_goals - game.away_goals).abs}\n score_difference.max\n end", "def highest_scoring_word\n return Scrabble::Scoring.highest_score_from(@plays)\n end", "def most_points_scored\n big_score_player = player_collection.reduce { |memo, next_player|\n memo[:points] > next_player[:points] ? memo : next_player; \n }\n big_score_player[:player_name];\nend", "def most_common_nationalities_list\n nationalities_hash = self.players.group_by{\n |player| player.nationality\n }\n count_hash={}\n nationalities_string = nationalities_hash.map do |nationality, players|\n # puts \"Number of players from \" + nationality + \": \" + players.count.to_s\n count_hash[nationality]=players.count\n end\n count_hash.sort_by {|nationality, num| num}.reverse\n end", "def heaviest_rock(rock_array)\n max_rock = 0\n\n rocks.each do |rock|\n max_rock = rock if max_rock < rock \n end\nend", "def most_points_scored\nplayer_with_most(:points)\nend", "def most_points_scored\n\tpoints_array = []\n\tgame_hash.each do |location, team_data|\n\t\tteam_data[:players].each do |attribute, data|\t\n\t\t\tdata.each do |type, amount|\n\t\t\t\tif type == :points\n\t\t\t\t\tpoints_array << amount\n\t\t\t\tend \n\t\t\tend\n\t\tend\n\tend\n\tgame_hash.each do |l, data|\n\t\tdata[:players].each do |a, d|\n\t\t\td.each do |t, amt|\n\t\t\t\tif t == :points && points_array.max == amt\n\t\t\t\t\treturn a\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend\nend", "def big_shoe_rebounds\n\nhighest_rebounds = 0\nbiggest_shoe = 0\n\n game_hash.each do |location, team_info|\n game_hash.dig(location, :players).each do |player_name, stats|\n stats.each do |stat, number|\n if stat == :shoe\n if number > biggest_shoe\n biggest_shoe = number\n stats.each do |stat, number|\n if stat == :rebounds\n highest_rebounds = number\n end\n end\n end\n end\n end\n end\n end\n puts highest_rebounds\n return highest_rebounds\nend", "def most_points_scored\nbest_player = \"\"\npoints = 0\ngame_hash.each do |location, team_data|\n team_data[:players].each do |name, stats|\n if stats[:points] > points\n points = stats[:points]\n best_player= name\n end\n end\nend\nbest_player\nend", "def regular_season_rankings(season = nil)\n stats_request(\"regularSeasonStatRankings\", season).first\n end", "def highest_scoring_word\n \tScoring.highest_score_from(@words_played)\n end", "def goals_against_season(round, season = nil)\n count = 0\n matchs = find_matchs(round, season)\n\n matchs.each do |match|\n count += match.goals_against(self) if match.finished?\n end\n\n count\n end", "def highest_word_score\n Scrabble::Scoring.score(Scrabble::Scoring.highest_score_from(@plays_array))\n end", "def average_goals_by_season\n goals_by_season = @games.group_by { |game| game.season.to_s }\n goals_by_season.each do |season, games|\n season_goals = games.map { |game| game.home_goals + game.away_goals }.sum\n goals_by_season[season] = (season_goals.to_f / games.count.to_f).round(2)\n end\n end", "def worst_loss(team_id)\n @games.map do |game|\n if game.away_team_id.to_s == team_id\n game.home_goals - game.away_goals\n elsif game.home_team_id.to_s == team_id\n game.away_goals - game.home_goals\n end\n end.compact.max\n end", "def most_steals\r\n result={}\r\n game_hash.each do |k, v|\r\n v.each do| p, d|\r\n if p==:players\r\n d.each do |t, s|\r\n result[t]=s[:steals]\r\n end\r\n end\r\n end\r\n end \r\n result.max_by {|name, steal| steal}[0]\r\nend", "def player_longest_name(game)\n player_names = []\n game[:home_team][:players].each do |player_hash|\n player_names << player_hash[:player_name]\n end\n game[:away_team][:players].each do |player_hash|\n player_names << player_hash[:player_name]\n end\n longest_name = player_names.max_by { |name| name.length }\nend", "def high_score\n if self.end_date < Date.today\n self.teams.max_by { |team| team.score }.score\n end\n end", "def year_with_most_guests\n sql = <<-SQL\n SELECT show_year, count(id) AS guest_count\n FROM guest_appearances\n GROUP BY show_year\n ORDER BY guest_count DESC\n LIMIT 1;\n SQL\n mg = DB[:conn].execute(sql)[0]\n puts \"#{mg[0]}: #{mg[1]} guests.\"\nend", "def most_points_scored_helper\n point_array = []\n \n game_hash.each do |key, value|\n players = value[:players]\n players.each do |element|\n point_array << element[:point]\n end\n end\n point_array.max\nend", "def most_points(game)\nmax_points = 0\nmax_points_player = \"\"\ngame.each do |team, team_contents|\n team_contents[:roster].each do |player, player_contents| \n if player_contents[:points] == max_points\n max_points_player = max_points_player + \" and #{player_contents[:player_name]}\"\n elsif player_contents[:points] > max_points\n max_points = player_contents[:points]\n max_points_player = player_contents[:player_name]\n end\n end\nend\nputs \"#{max_points_player} scored #{max_points}\"\nend", "def best_fans\n @teams.max_by { |team| team.home_minus_away_percentage }.team_name\n end" ]
[ "0.8302358", "0.74612236", "0.73398393", "0.73084134", "0.72868294", "0.7167453", "0.71511513", "0.69784075", "0.69425094", "0.69318867", "0.67980033", "0.67972773", "0.67909807", "0.66709185", "0.6615492", "0.64948076", "0.64731365", "0.64715165", "0.6459137", "0.64026684", "0.63974", "0.6351856", "0.63354445", "0.63066274", "0.6223715", "0.6204896", "0.6204896", "0.6200175", "0.6170895", "0.6154221", "0.61178875", "0.60980976", "0.6094676", "0.607803", "0.6073493", "0.6072994", "0.60678536", "0.6047154", "0.6039017", "0.6029805", "0.60149693", "0.6011528", "0.6009808", "0.6004822", "0.6002669", "0.60015255", "0.5984433", "0.5982164", "0.59682214", "0.59634477", "0.596212", "0.59574896", "0.59493315", "0.5944881", "0.59395224", "0.59376514", "0.5936493", "0.5934223", "0.5934061", "0.59204906", "0.5919184", "0.5918695", "0.5915787", "0.59144133", "0.5914262", "0.5914262", "0.5912646", "0.5911172", "0.5892876", "0.5891704", "0.5884606", "0.5880254", "0.58775145", "0.5870699", "0.5869037", "0.5859185", "0.5857773", "0.58546835", "0.5834492", "0.58315915", "0.5827933", "0.5823559", "0.5819362", "0.58157533", "0.5814682", "0.58094794", "0.5808398", "0.57897663", "0.5784863", "0.57798713", "0.5779641", "0.577938", "0.577783", "0.5772376", "0.5766727", "0.57636994", "0.57618153", "0.5760025", "0.57587934", "0.5752462" ]
0.90422076
0
returns season with fewest games played
def season_with_fewest_games seasons = @games.group_by { |game| game.season } seasons.min_by { |season, games| games.count }.first end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def season_with_most_games\n seasons = @games.group_by { |game| game.season }\n seasons.max_by { |season, games| games.count }.first\n end", "def fewest_hits(seasonasstring) # shots in game team stats\n #inverse of above\n end", "def count_of_games_by_season\n games_by_season = @games.group_by { |game| game.season.to_s }\n games_by_season.each { |season, games| games_by_season[season] = games.count }\n end", "def most_hits(seasonasstring) # shots in game team stats\n #get a list of all teams that played in that season\n #use above list to sum all shots across all games in season\n #find highest across list\n #return team name as found in 139\n end", "def biggest_bust(seasonasstring)\n #get all teams in data\n #find all games played by team in season - given by arg\n #get subset of 95 where p is in season marker\n #count games won in subset on 95 / total games in subset on 95\n #get subset of 85 where r is in season marker\n #count games won in subset on 98 / total games in subset on 98\n #result of line 97 - line 99\n #find highest number\n #return team name of result of line 101\n end", "def winningest_coach(seasonasstring) # coach name in game team stats\n #per season, get list of all coaches - given by arg\n #per coach, find all games played by that coach\n #then count of all games won / count of all games played\n #find highest\n #return name of coach found in 114\n end", "def least_accurate_team(seasonasstring) # shots in game team stats\n #inverse of above\n end", "def retrieve_season_hall_of_fame\n seasons_hall_of_fame = []\n get_involved_teams unless @involved_teams\n\n @involved_teams.each do |team|\n team_placement = {}\n team_placement[:team] = team\n %w[first_place second_place third_place].each_with_index do |rank, index|\n placement = index + 1\n team_placement[rank.to_sym] = team.computed_season_ranking.joins(:season).where(\"seasons.season_type_id = #{@season_type.id} AND computed_season_rankings.rank = #{placement}\").count\n end\n seasons_hall_of_fame << team_placement\n end\n seasons_hall_of_fame.sort { |p, n| (n[:first_place] * 10_000 + n[:second_place] * 100 + n[:third_place]) <=> (p[:first_place] * 10_000 + p[:second_place] * 100 + p[:third_place]) }\n end", "def best_season(id)\n wins = total_wins_per_team_per_season(id)\n totals = total_games_per_team_per_season(id)\n totals.each do |season, total|\n totals[season] = (wins[season] / total.to_f * 100).round(2)\n end\n totals.max_by {|k,v| v}[0]\n end", "def played_matchs_season(round, season = nil)\n count = 0\n matchs = find_matchs(round, season)\n\n matchs.each do |match|\n if match.finished?\n count += 1\n end\n end\n count\n end", "def worst_season(team_id)\n team_id = team_id.to_i\n team = @teams.select { |each_team| each_team.team_id == team_id }.first\n team.season_win_percentages.min_by { |season, percentage| percentage }.first.to_s\n end", "def biggest_bust(season)\n season = season.to_i\n @teams.min_by{ |team| team.preseason_to_regular_increase[season] }.team_name\n end", "def biggest_surprise(season)\n season = season.to_i\n @teams.max_by{ |team| team.preseason_to_regular_increase[season] }.team_name\n end", "def win_matchs_season(round, season = nil)\n count = 0\n matchs = find_matchs(round, season)\n\n matchs.each do |match|\n if match.is_winner?(self) and match.finished?\n count += 1\n end\n end\n count\n end", "def best_season(team_id)\n team_id = team_id.to_i\n team = @teams.select { |each_team| each_team.team_id == team_id }.first\n team.season_win_percentages.max_by { |season, percentage| percentage }.first.to_s\n end", "def mz_seasons\n age - System::JUNIOR_START_AGE\n end", "def most_accurate_team(seasonasstring) # shots in game team stats\n #get a list of all teams that played in that season - given by arg\n #use above list to sum all shots across all games in season\n #divide above by goals made across all games in season\n #find highest percentage\n #return team name as found in 127\n end", "def test_count_of_games_by_season\n\n expected = {\n \"20122013\"=>806,\n \"20162017\"=>1317,\n \"20142015\"=>1319,\n \"20152016\"=>1321,\n \"20132014\"=>1323,\n \"20172018\"=>1355\n }\n assert_equal expected, @stat_tracker.count_of_games_by_season\n\n end", "def points_season(round, season = nil)\n count = 0\n matchs = find_matchs(round, season)\n\n matchs.each do |match|\n if match.is_winner?(self) and match.finished?\n count += MatchGeneral::PT_WIN\n end\n if match.deal? and match.finished?\n count += MatchGeneral::PT_DEAL\n end\n end\n\n count\n end", "def has_more_rounds_left_in_season?\n next_round = current_round + 1\n next_round <= total_rounds\n end", "def lost_matchs_season(round, season = nil)\n count = 0\n matchs = find_matchs(round, season)\n\n matchs.each do |match|\n if match.is_looser?(self) and match.finished?\n count += 1\n end\n end\n\n count\n end", "def biggest_suprise(seasonasstring)\n #as above, but change line 100 to reverse operations, regular percentage - postseason percentage\n end", "def least_popular_venue\n venues = @games.group_by { |game| game.venue}\n venues.min_by { |venue, games| games.count }.first\n end", "def goals_favor_season(round, season = nil)\n count = 0\n matchs = find_matchs(round, season)\n\n matchs.each do |match|\n count += match.goals_favor(self) if match.finished?\n end\n\n count\n end", "def two_season\n if month<=3\n 0\n elsif month>=10\n 2\n else\n 1\n end\n end", "def average_goals_by_season\n goals_by_season = @games.group_by { |game| game.season.to_s }\n goals_by_season.each do |season, games|\n season_goals = games.map { |game| game.home_goals + game.away_goals }.sum\n goals_by_season[season] = (season_goals.to_f / games.count.to_f).round(2)\n end\n end", "def retrieve_closed_seasons\n @season_type.seasons.where(['end_date < ?', Date.today])\n .sort_season_by_begin_date('DESC')\n end", "def season\n number = ((self.day - 1) / 30) % 4\n case number\n when 0\n return \"spring\"\n when 1\n return \"summer\"\n when 2\n return \"fall\"\n when 3\n return \"winter\"\n end\n end", "def current_season\n self.seasons.find(:first,\n :conditions => {:date => Season.maximum('date')})\n end", "def determine_winner game\n winner = game.max_by {|team| team[:score]}\n team_standings = get_team_by_name(winner)\n team_standings[:winnings] += 3\nend", "def worst_coach(seasonasstring) # coach name in game team stats\n #inverse of above\n end", "def current_season\n season = nil\n\n { \n winter: [ 12, 1, 2 ], \n spring: [ 3, 4, 5 ], \n summer: [ 6, 7, 8 ],\n fall: [ 9, 10, 11 ]\n \n }.each do |key, range|\n if range.include? current_month\n season = key\n break\n end\n end\n\n season\n end", "def calculate_most_common_year\n self.calculate_plays_by_year.sort_by{ |year, times_played| times_played }.last\n end", "def goals_against_season(round, season = nil)\n count = 0\n matchs = find_matchs(round, season)\n\n matchs.each do |match|\n count += match.goals_against(self) if match.finished?\n end\n\n count\n end", "def scrape_season\n doc = Nokogiri::HTML(open(url))\n \n seasonality_url = doc.search(\"#survival-guide ul li:nth-child(2) a\").attr(\"href\").text #get country weather url\n weather_pg = Nokogiri::HTML(open(seasonality_url))\n \n #get high, low, and best time to visit information\n @high_season = weather_pg.search(\"div.card--page__content p:nth-child(1)\").text\n @low_season = weather_pg.search(\"div.card--page__content p:nth-child(5)\").first.text\n\n shoulder_season = weather_pg.search(\"div.card--page__content p:nth-child(3)\").first.text\n @best_visit_season = \"Best time to visit \" + shoulder_season[16..-1]\n end", "def get_closed_seasons\n @closed_seasons ||= retrieve_closed_seasons\n end", "def flu_season\n event_display(\"It's flu season!\\n One player has been infected and needs some time to recuperate.\")\n {Game.last.players.sample.id.to_s =>\n {wellbeing: -100}\n }\n end", "def deal_matchs_season(round, season = nil)\n count = 0\n matchs = find_matchs(round, season)\n\n matchs.each do |match|\n if match.deal? and match.finished?\n count += 1\n end\n end\n count\n end", "def get_contemporary_seasons_involved_into(season)\n @swimmer.seasons.is_in_range(season.begin_date, season.end_date)\n end", "def calculate_least_common_year\n self.calculate_plays_by_year.select{ |year,times_played| times_played > 0 }.sort_by{ |year, times_played| times_played }.first\n end", "def get_standings(games)\n teams = Hash.new\n games.each do |game|\n division_id = game.division_id\n home_team = game.home_team\n away_team = game.visiting_team\n if(teams[home_team.name].nil?)\n teams[home_team.name] = {:win => 0, :loss => 0, :tie => 0, :point=> 0}\n end\n\n if(teams[away_team.name].nil?)\n teams[away_team.name] = {:win => 0, :loss => 0, :tie => 0, :point => 0}\n end\n if(game.home_team_score && game.visiting_team_score)\n if(game.home_team_score > game.visiting_team_score)\n # home team won\n teams[home_team.name][:win] += 1\n teams[home_team.name][:point] += 5\n # visiting team loss\n teams[away_team.name][:loss] += 1\n elsif(game.home_team_score < game.visiting_team_score)\n # home team loss\n teams[home_team.name][:loss] += 1\n #visiting team won\n teams[away_team.name][:win] += 1\n teams[away_team.name][:point] += 5\n else\n # tie game\n teams[home_team.name][:tie] += 1\n teams[home_team.name][:point] += 1\n teams[away_team.name][:tie] += 1\n teams[away_team.name][:point] += 1\n end\n end\n end\n teams.each do |team, value|\n puts team\n total_games = value[:win] + value[:loss] + value[:tie]\n if total_games > 0 \n win_percentage = value[:win]/total_games.to_f\n else\n win_percentage = 0\n end \n value[:percentage] = win_percentage\n end\n teams_sorted = teams.sort_by{ |k, v| v[:point]}.reverse\n return teams_sorted\n end", "def games_played\n games.size\n end", "def games_played\n games.size\n end", "def get_involved_season_best_for_event(involved_seasons, event_type, pool_type)\n best = nil\n involved_seasons.each do |season|\n next unless @swimmer.meeting_individual_results.for_season(season)\n .for_pool_type(pool_type)\n .for_event_type(event_type)\n .is_not_disqualified.exists?\n\n tmp_best = @swimmer.meeting_individual_results.for_season(season)\n .for_pool_type(pool_type)\n .for_event_type(event_type)\n .is_not_disqualified\n .sort_by_timing('ASC')\n .first\n .get_timing_instance\n best = tmp_best if best.nil? || best.to_hundreds > tmp_best.to_hundreds\n end\n best\n end", "def regular_season_rankings(season = nil)\n stats_request(\"regularSeasonStatRankings\", season).first\n end", "def per_game_stats(season = nil)\n season_id = season ? season.id : Season.current.id\n StatLine.find_by_sql('SELECT AVG(fgm) as fgm, AVG(fga) as fga, coalesce(AVG(fgm)/nullif(AVG(fga), 0), 0) as fgpct, AVG(twom) as twom, AVG(twoa) as twoa, coalesce(AVG(twom)/nullif(AVG(twoa), 0), 0) as twopct, AVG(threem) as threem, AVG(threea) as threea, coalesce(AVG(threem)/nullif(AVG(threea), 0), 0) as threepct,' \\\n 'AVG(ftm) as ftm, AVG(fta) as fta, coalesce(AVG(ftm)/nullif(AVG(fta), 0), 0) as ftpct, AVG(orb) as orb, AVG(drb) as drb, AVG(trb) as trb, AVG(ast) as ast, AVG(stl) as stl, AVG(blk) as blk, AVG(fl) as fl, AVG(\"to\") as to,' \\\n 'AVG(points) as points, COUNT(*) as game_count, sums.league_id FROM (SELECT SUM(fgm) as fgm, SUM(fga) as fga, SUM(twom) as twom, SUM(twoa) as twoa, SUM(threem) as threem, SUM(threea) as threea,' \\\n 'SUM(ftm) as ftm, SUM(fta) as fta, SUM(orb) as orb, SUM(drb) as drb, SUM(trb) as trb, SUM(ast) as ast, SUM(stl) as stl, SUM(blk) as blk, SUM(fl) as fl, SUM(\"to\") as to,' \\\n \"SUM(points) as points, g.league_id as league_id FROM stat_lines sl INNER JOIN games g ON sl.game_id = g.id \" \\\n \"WHERE g.winner is not null AND (g.forfeit is null or not g.forfeit) AND (sl.dnp is null OR not sl.dnp) AND team_id = #{self.id} AND g.season_id = #{season_id} GROUP BY game_id, g.league_id) sums GROUP BY sums.league_id\")\n end", "def season_number\n @ole.SeasonNumber\n end", "def season\n case merch_month\n when 1,2,3,4,5,6\n \"Spring/Summer\"\n when 7,8,9,10,11,12\n \"Fall/Winter\"\n end\n end", "def goals_by_game_situation(season = nil)\n stats_request(\"goalsByGameSituation\", season).first\n end", "def season_status\n season_st = []\n @organization = Organization.where(:_id => session[:current_org]).first\n @organization.seasons.each do |each_seasons|\n season_st << each_seasons.is_current\n end\n return season_st\n end", "def season_summary(season, team_id)\n season = season.to_i\n team_id = team_id.to_i\n season_summary_hash(season, team_id)\n end", "def winningest_team\n @teams.max_by { |team| team.total_win_percentage }.team_name\n end", "def get_season_hall_of_fame\n @seasons_hall_of_fame ||= retrieve_season_hall_of_fame\n end", "def wins\n wins = 0\n self.teams.each do |team|\n wins += team.games_won.length\n end\n wins\n end", "def season\n @season ||= Season.find(@importer_hash.meeting.season_id)\n end", "def poolplay_games\n self.games.select { |game| game.version == 'poolplay'}\n end", "def season(yday)\n case yday\n when 80..171\n :midseason\n when 172..265\n :summer\n when 266..355\n :midseason\n else\n :winter\n end\n end", "def not_in_season\n OfferSeason.find(:all) - OfferSeason.find_by_id(1)\n end", "def seasons(season = nil)\n @server.make_json_request('show.seasons', tvdbid: @tvdbid, season: season)['data']\n end", "def matchup_count(season = 2015)\n r = Record.find_by(team_id: self.id, year: season)\n r.wins + r.losses + r.ties\n end", "def min_sets_to_play\n max = max_sets_to_play\n raise Exceptions::ApplicationError, 'Unexpected game count' if max.even?\n (max + 1) / 2\n end", "def season\n season_id.nil? ? nil : organization_membership.seasons.find(season_id)\n end", "def get_average_age_for_season(data, season)\n age_total = 0\n num_of_contestants = 0\n data[season].each do |contestant_hash|\n age_total += (contestant_hash[\"age\"]).to_i\n num_of_contestants += 1\n end\n (age_total / num_of_contestants.to_f).round(0)\nend", "def total_wins_by_season_by_team_id(passed_id)\n @by_team_id_game_objects.each do |game|\n if helper_for_win_count(passed_id, game)\n @total_wins_by_season[game[\"season\"]] += 1\n elsif helper_for_loss_count(passed_id, game)\n @total_wins_by_season[game[\"season\"]] += 0\n end\n end\n end", "def worst_offense\n @teams.min_by { |team| team.average_goals_scored }.team_name\n end", "def max_sets_to_play\n case scoring.to_sym\n when :two_six_game_ten_point\n 3\n when :one_eight_game\n 1\n else # :three_six_game\n 3\n end\n end", "def worst_offense\n teams_total_goals = total_goals_helper\n teams_total_games = total_games_helper\n\n worst_team_goals_avg = 1000\n worst_offense_team_id = 0\n this_team_goals_avg = 0\n\n teams_total_games.each do |games_key, games_value|\n teams_total_goals.each do |goals_key, goals_value|\n if goals_key == games_key\n this_team_goals_avg = (goals_value / games_value.to_f)\n if this_team_goals_avg < worst_team_goals_avg\n worst_team_goals_avg = this_team_goals_avg\n worst_offense_team_id = games_key\n end\n end\n end\n end\n\n team_with_worst_offense = nil\n self.teams.each_value do |team_obj|\n if team_obj.team_id. == worst_offense_team_id\n team_with_worst_offense = team_obj.team_name\n end\n end\n team_with_worst_offense\n end", "def get_average_age_for_season(data, season)\n data.each do |season_iteration, stats|\n if season_iteration == season\n total_ages = 0\n ages = stats.each do |age|\n total_ages = (total_ages + age[\"age\"].to_i).to_f\n end\n return (total_ages/ages.length).round\n end\n end\nend", "def what_rank\n 10 - all_ranks.find_index{ |truth| truth != 2014} \n end", "def minimum_rounds(driver)\n Algorithm::Swiss.minimum_rounds(driver.seeded_teams.length)\n end", "def minimum_rounds(driver)\n Algorithm::Swiss.minimum_rounds(driver.seeded_teams.length)\n end", "def game_week\n now = DateTime.now\n all_games = NflSchedule.where(year: Date.today.year)\n .order(:start_time)\n week_started = 0\n all_games.each { |game|\n if (week_started < game.week) && (now > game.start_time)\n week_started = game.week\n end\n }\n return week_started\n end", "def most_points_scored\n most_points_scored = 0\n player_with_the_most_points_scored = \"\"\n game_hash.each do |team,info|\n info.each do |team_info,team_data|\n if team_data.is_a? (Array) \n if team_info != :colors\n team_data.each do |player_index|\n if most_points_scored == 0 || player_index[:points] > most_points_scored \n most_points_scored = player_index[:points]\n player_with_the_most_points_scored = player_index[:player_name]\n end\n end\n end\n end\n end\n end\n player_with_the_most_points_scored\nend", "def get_season()\n\t\ttime = Time.new\n\n\t\tif(time.month >= 3) && (time.month <= 5)\n\t\t\t\tseason_type = \"Yeah it is Spring\"\n\t\t\telsif (time.month > 5) && (time.month <= 8)\n\t\t\t\tseason_type = \"Everyone Loves Summer\"\n\t\t\telsif (time.month > 8) && (time.month <= 10)\n\t\t\t\tseason_type = \"Put on Your Coat because Autumn is here\"\n\t\t\telse\n\t\t\t\tseason_type = \"Yuck, it's now Winter\"\n\t\tend\n\tend", "def get_total_games_played\n return games.size\n end", "def show\n @rounds = set_rounds\n @matches = @competition.matches.select { |match| match.season == @competition.curr_season }\n @matches = @matches.sort_by{ |m| m.round }\n end", "def season(year, **options) = get(\"/seasons/#{year}\", **{ sportId: 1 }.merge(options))", "def get_involved_season_last_best_for_event(involved_seasons, event_type, pool_type)\n involved_seasons.each do |season|\n if @swimmer.meeting_individual_results.for_season(season).for_pool_type(pool_type).for_event_type(event_type).is_not_disqualified.exists?\n return @swimmer.meeting_individual_results.for_season(season).for_pool_type(pool_type).for_event_type(event_type).is_not_disqualified.sort_by_timing('ASC').first.get_timing_instance\n end\n end\n nil\n end", "def get_closed_seasons_involved_into(season_type = nil, ended_before = nil)\n seasons = season_type ?\n @swimmer.seasons.for_season_type(season_type).is_ended.sort_season_by_begin_date('DESC') :\n @swimmer.seasons.is_ended.sort_season_by_begin_date('DESC')\n seasons = seasons.reject { |s| s.end_date > ended_before } if ended_before\n seasons\n end", "def get_average_age_for_season(data, season)\n age = 0\n count = 0\n data[season].each do |contestant_data|\n age += (contestant_data[\"age\"]).to_f\n count += 1\n end\n (age / count).round\nend", "def games_played\n self.results.to_a.count\n end", "def get_total_games_played\n\t\treturn games.size\n\tend", "def num_games win_condition\n total_games = 0\n @game_objects.each do |game|\n total_games += 1 if game_meets_win_cond?(win_condition, game)\n end \n total_games\n end", "def most_popular_venue\n venues = @games.group_by { |game| game.venue}\n venues.max_by { |venue, games| games.count }.first\n end", "def round_actual?\n self.current_season.round_actual?\n end", "def winning_team\n nets = []\n hornets = []\n\n game_hash.values.each do |nets_stats|\n if nets_stats[:team_name] == \"Brooklyn Nets\"\n nets_stats[:players].each do |bk|\n nets << bk[:points]\n end\n end\n end\n\n game_hash.values.each do |hornets_stats|\n if hornets_stats[:team_name] == \"Charlotte Hornets\"\n hornets_stats[:players].each do |ch|\n hornets << ch[:points]\n end\n end\n end\n\n if nets.reduce(:+) > hornets.reduce(:+)\n return \"Brooklyn Nets\"\n else\n return \"Charlotte Hornets\"\n end\nend", "def get_active_season\n today = Date.today\n season = Season.where('start_date < ? AND end_date > ?', today, today).first\n if season.nil?\n season = Season.where('start_date > ? AND start_date < ?', today, (today + 7.days)).first\n if season.nil?\n season = Season.where('end_date > ?', today).last\n end \n end\n return season\n end", "def get_average_age_for_season(data, season)\n array_of_ages = []\n average = 0\n data.each do |season_in_hash, contestant_array|\n if season_in_hash.to_s == season\n contestant_array.each do |contestant|\n array_of_ages << contestant[\"age\"].to_f\n end \n average = (array_of_ages.inject{ |sum, num| sum + num }.to_f / array_of_ages.size).round\n end\n end\n average\nend", "def winning_team\n team_p = []\n team_n = []\n\n game_hash.each do | location, team_data|\n temp = 0\n team_data[:players].each do |p_name, stats|\n temp += stats[:points]\n end\n team_n << team_data[:team_name]\n team_p << temp\n end\n\n team_p[0] > team_p[1] ? team_n[0] : team_n[1]\n\nend", "def all_games\n return self.stages\n .map{ |stage| stage.games }\n .flatten\n .sort do |game0, game1|\n if game0.starts_at.nil?\n -1\n elsif game1.starts_at.nil?\n 1\n else\n game0.starts_at <=> game1.starts_at\n end\n end\n end", "def lowest_scoring_visitor\n @teams.min_by { |team| team.average_away_goals }.team_name\n end", "def power_play_goal_percentage(seasonasstring) # power_play info in game team stat\n #find list of all games in season given by arg\n #sum all power play goals\n #sum all power play oppertunities\n #divide line 146 and line 147\n #return total of above\n end", "def team_with_more_points(game)\n home_points = game[:home_team][:players].collect do |player|\n player[:stats][:points]\n end.inject {|sum, n| sum + n}\n away_points = game[:away_team][:players].collect do |player|\n player[:stats][:points]\n end.inject {|sum, n| sum + n}\n home_points > away_points ? game[:home_team][:team_name] : game[:away_team][:team_name]\nend", "def winning_team\n final_scores = player_collection.reduce(home: 0, away: 0) { |teams_points, next_player|\n case \n when next_player[:location] === :away\n teams_points[:away] += next_player[:points];\n when next_player[:location] === :home\n teams_points[:home] += next_player[:points];\n end\n teams_points; \n }\n winner = final_scores.reduce { |highest_points, team_points| \n highest_points[1] > team_points[1] ? highest_points : team_points; \n }\n game_hash[winner[0]][:team_name]; \nend", "def matches_played_by_season(table_of_teams)\n matches_played = Hash.new { |hash, key| hash[key] = Hash.new(0) }\n\n table_of_teams.each do |table_row|\n matches_played[table_row['season']][table_row['team1']] += 1\n matches_played[table_row['season']][table_row['team2']] += 1\n end\n matches_played\nend", "def get_first_name_of_season_winner(data, season)\n data.each do |season_iteration, stats|\n if season_iteration == season\n stats.find do |winner|\n if winner[\"status\"] == \"Winner\"\n return winner[\"name\"].split.first\n end\n end\n end\n end\nend", "def test_average_goals_by_season\n\n expected = {\n \"20122013\"=>4.12,\n \"20162017\"=>4.23,\n \"20142015\"=>4.14,\n \"20152016\"=>4.16,\n \"20132014\"=>4.19,\n \"20172018\"=>4.44\n }\n assert_equal expected, @stat_tracker.average_goals_by_season\n\n end", "def big_shoe_rebounds\n player_with_the_largest_shoe_size = 0\n most_rebounds = 0\n game_hash.each do |team,info|\n info.each do |team_info,team_data|\n if team_data.is_a? (Array) \n if team_info != :colors\n team_data.each do |player_index|\n if player_with_the_largest_shoe_size == 0 || player_index[:shoe] > player_with_the_largest_shoe_size \n player_with_the_largest_shoe_size = player_index[:shoe]\n most_rebounds = player_index[:rebounds]\n end\n end\n end\n end\n end\n end\n most_rebounds\nend", "def current_season\n curr_season = seasons.where(\"current_season = ?\", true).first\n\n if curr_season == nil\n curr_season = seasons.last\n end\n\n curr_season\n end", "def best_defense\n teams_total_goals_allowed = total_goals_allowed_helper\n teams_total_games = total_games_helper\n\n best_team_goals_allowed_avg = 100\n best_defense_team_id = 0\n this_team_goals_allowed_avg = 0\n\n teams_total_games.each do |games_key, games_value|\n teams_total_goals_allowed.each do |goals_key, goals_value|\n if goals_key == games_key\n this_team_goals_allowed_avg = (goals_value / games_value.to_f)\n if this_team_goals_allowed_avg < best_team_goals_allowed_avg\n best_team_goals_allowed_avg = this_team_goals_allowed_avg\n best_defense_team_id = games_key\n end\n end\n end\n end\n\n team_with_best_defense = nil\n self.teams.each_value do |team_obj|\n if team_obj.team_id. == best_defense_team_id\n team_with_best_defense = team_obj.team_name\n end\n end\n team_with_best_defense\n end" ]
[ "0.81187767", "0.7266228", "0.7246461", "0.7089269", "0.7068895", "0.7017991", "0.7016008", "0.6981696", "0.6862327", "0.68551326", "0.68269414", "0.6818776", "0.67922515", "0.6693926", "0.66721785", "0.6660897", "0.6649636", "0.6544526", "0.6537491", "0.6488219", "0.64121807", "0.64102685", "0.6402413", "0.63813865", "0.6320156", "0.63047796", "0.6259013", "0.62393177", "0.6231394", "0.6229067", "0.62235546", "0.62233657", "0.62147933", "0.62085587", "0.6192607", "0.61837333", "0.61822283", "0.61762077", "0.6145235", "0.6127587", "0.61208725", "0.61169255", "0.61169255", "0.6083885", "0.6079115", "0.60392207", "0.60323274", "0.60226136", "0.6010134", "0.59860414", "0.5985332", "0.59744304", "0.59544986", "0.5942869", "0.5933265", "0.5932922", "0.592961", "0.5928268", "0.59267783", "0.5913251", "0.59048796", "0.586793", "0.5862658", "0.5853787", "0.58469176", "0.5845916", "0.58455414", "0.58443993", "0.581834", "0.58079195", "0.58079195", "0.5806533", "0.58034074", "0.5802817", "0.5786853", "0.5784919", "0.5784819", "0.5783368", "0.5779351", "0.57782346", "0.57771814", "0.5775902", "0.5775313", "0.57648957", "0.576045", "0.57382184", "0.5736886", "0.57368726", "0.5730009", "0.5729472", "0.57285047", "0.57230574", "0.5713124", "0.570943", "0.56925154", "0.5690857", "0.5690413", "0.5685148", "0.56639713", "0.5661603" ]
0.870494
0
returns a hash with season names as keys and counts of games as values
def count_of_games_by_season games_by_season = @games.group_by { |game| game.season.to_s } games_by_season.each { |season, games| games_by_season[season] = games.count } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_count_of_games_by_season\n\n expected = {\n \"20122013\"=>806,\n \"20162017\"=>1317,\n \"20142015\"=>1319,\n \"20152016\"=>1321,\n \"20132014\"=>1323,\n \"20172018\"=>1355\n }\n assert_equal expected, @stat_tracker.count_of_games_by_season\n\n end", "def matches_played_by_season(table_of_teams)\n matches_played = Hash.new { |hash, key| hash[key] = Hash.new(0) }\n\n table_of_teams.each do |table_row|\n matches_played[table_row['season']][table_row['team1']] += 1\n matches_played[table_row['season']][table_row['team2']] += 1\n end\n matches_played\nend", "def total_games_by_coach_by_season\n @total_games_by_coach = Hash.new{ |hash, key| hash[key] = 0}\n @by_season_game_team_objects.each do |game_by_season|\n @total_games_by_coach[game_by_season[\"head_coach\"]] += 1\n end\n end", "def matchup_count(season = 2015)\n r = Record.find_by(team_id: self.id, year: season)\n r.wins + r.losses + r.ties\n end", "def played_matchs_season(round, season = nil)\n count = 0\n matchs = find_matchs(round, season)\n\n matchs.each do |match|\n if match.finished?\n count += 1\n end\n end\n count\n end", "def retrieve_season_hall_of_fame\n seasons_hall_of_fame = []\n get_involved_teams unless @involved_teams\n\n @involved_teams.each do |team|\n team_placement = {}\n team_placement[:team] = team\n %w[first_place second_place third_place].each_with_index do |rank, index|\n placement = index + 1\n team_placement[rank.to_sym] = team.computed_season_ranking.joins(:season).where(\"seasons.season_type_id = #{@season_type.id} AND computed_season_rankings.rank = #{placement}\").count\n end\n seasons_hall_of_fame << team_placement\n end\n seasons_hall_of_fame.sort { |p, n| (n[:first_place] * 10_000 + n[:second_place] * 100 + n[:third_place]) <=> (p[:first_place] * 10_000 + p[:second_place] * 100 + p[:third_place]) }\n end", "def total_wins_by_season_by_team_id(passed_id)\n @by_team_id_game_objects.each do |game|\n if helper_for_win_count(passed_id, game)\n @total_wins_by_season[game[\"season\"]] += 1\n elsif helper_for_loss_count(passed_id, game)\n @total_wins_by_season[game[\"season\"]] += 0\n end\n end\n end", "def season_summary(season, team_id)\n season = season.to_i\n team_id = team_id.to_i\n season_summary_hash(season, team_id)\n end", "def season_prepare\n ret = {\n :competitions_to_draw => League.all\n }\n \n ret[:competitions_to_draw]\n \n return ret\n end", "def skater_stats(stats)\n skater_stats = Hash.new\n skater_stats[:seasons] = stats.seasons\nend", "def current_season\n season = nil\n\n { \n winter: [ 12, 1, 2 ], \n spring: [ 3, 4, 5 ], \n summer: [ 6, 7, 8 ],\n fall: [ 9, 10, 11 ]\n \n }.each do |key, range|\n if range.include? current_month\n season = key\n break\n end\n end\n\n season\n end", "def genre_count(hash)\n\thash.group_by { |k, v| v[:genre] }.map { |k, v| { k => v.count } }\nend", "def standards_counts\n standards = {}\n standards.default(0)\n\n self.breaches.each do |b|\n standards[b.subject] += 1\n end\n return standards\n end", "def points_season(round, season = nil)\n count = 0\n matchs = find_matchs(round, season)\n\n matchs.each do |match|\n if match.is_winner?(self) and match.finished?\n count += MatchGeneral::PT_WIN\n end\n if match.deal? and match.finished?\n count += MatchGeneral::PT_DEAL\n end\n end\n\n count\n end", "def get_standings(games)\n teams = Hash.new\n games.each do |game|\n division_id = game.division_id\n home_team = game.home_team\n away_team = game.visiting_team\n if(teams[home_team.name].nil?)\n teams[home_team.name] = {:win => 0, :loss => 0, :tie => 0, :point=> 0}\n end\n\n if(teams[away_team.name].nil?)\n teams[away_team.name] = {:win => 0, :loss => 0, :tie => 0, :point => 0}\n end\n if(game.home_team_score && game.visiting_team_score)\n if(game.home_team_score > game.visiting_team_score)\n # home team won\n teams[home_team.name][:win] += 1\n teams[home_team.name][:point] += 5\n # visiting team loss\n teams[away_team.name][:loss] += 1\n elsif(game.home_team_score < game.visiting_team_score)\n # home team loss\n teams[home_team.name][:loss] += 1\n #visiting team won\n teams[away_team.name][:win] += 1\n teams[away_team.name][:point] += 5\n else\n # tie game\n teams[home_team.name][:tie] += 1\n teams[home_team.name][:point] += 1\n teams[away_team.name][:tie] += 1\n teams[away_team.name][:point] += 1\n end\n end\n end\n teams.each do |team, value|\n puts team\n total_games = value[:win] + value[:loss] + value[:tie]\n if total_games > 0 \n win_percentage = value[:win]/total_games.to_f\n else\n win_percentage = 0\n end \n value[:percentage] = win_percentage\n end\n teams_sorted = teams.sort_by{ |k, v| v[:point]}.reverse\n return teams_sorted\n end", "def win_matchs_season(round, season = nil)\n count = 0\n matchs = find_matchs(round, season)\n\n matchs.each do |match|\n if match.is_winner?(self) and match.finished?\n count += 1\n end\n end\n count\n end", "def average_goals_by_season\n goals_by_season = @games.group_by { |game| game.season.to_s }\n goals_by_season.each do |season, games|\n season_goals = games.map { |game| game.home_goals + game.away_goals }.sum\n goals_by_season[season] = (season_goals.to_f / games.count.to_f).round(2)\n end\n end", "def seasons(season = nil)\n @server.make_json_request('show.seasons', tvdbid: @tvdbid, season: season)['data']\n end", "def its_a_tie game\n game.each do |team|\n team_standings = get_team_by_name(team)\n team_standings[:winnings] += 1\n end\nend", "def popularities\n result = {}\n @courses.each do |cl|\n result[cl.name] = Hash.new(0)\n end\n @students.each do |student|\n student.each_with_index do |course_choice, i|\n result[course_choice.name][i] += 1\n end\n end\n result\n end", "def gross_per_studio(collection)\n new_hash = {}\n counter = 0 \n while counter < collection.length do \n studio_name = collection[counter][:studio]\n ww_gross = collection[counter][:worldwide_gross]\n if !new_hash[studio_name]\n new_hash[studio_name] = ww_gross\n else \n new_hash[studio_name] += ww_gross\n end \n counter += 1 \nend\nreturn new_hash\nend", "def count_plays(year)\n s = get_shakey[\"William Shakespeare\"]\n .select { |k, v|\n v[\"finished\"] == year\n }.each { |key, val|\n puts val[\"title\"]\n }.count\nend", "def goals_against_season(round, season = nil)\n count = 0\n matchs = find_matchs(round, season)\n\n matchs.each do |match|\n count += match.goals_against(self) if match.finished?\n end\n\n count\n end", "def most_hits(seasonasstring) # shots in game team stats\n #get a list of all teams that played in that season\n #use above list to sum all shots across all games in season\n #find highest across list\n #return team name as found in 139\n end", "def season_with_most_games\n seasons = @games.group_by { |game| game.season }\n seasons.max_by { |season, games| games.count }.first\n end", "def sporters_by_country\n \tresult = { }\n \tCountry.all.map do |c|\n \t\tresult[c.name] = c.sporters.count\n \tend\n \trender json: [{name: 'Count', data: result}]\n end", "def better_tracks_query\n albums = self.albums.select(\"albums.*, COUNT(*) AS tracks_count\")\n .joins(:tracks).group(\"albums.id\")\n\n album_counts = {}\n albums.each do |album|\n album_counts[album.title] = album.tracks_count\n end\n\n album_counts\n end", "def count_contestants_by_hometown(data, hometown)\n counter = 0\n data.each do |season_hash, info|\n info.each do |detail|\n if detail[\"hometown\"] == hometown\n counter += 1 \n end\n end\n end\n return counter\nend", "def season_names_for_date(date)\n seasons = case date.strftime('%-m').to_i\n when 3..5 then %w[Spring]\n when 6..8 then %w[Summer]\n when 9..11 then %w[Autumn Fall]\n else %w[Winter]\n end\n year = date.year\n seasons.map { |season| \"#{season} #{year}\" }\n end", "def stats\n {\n 'Living souls' => souls.where(alive: true).count,\n 'Dead souls' => souls.where(alive: false).count,\n 'Free souls' => players.sum(:free_souls),\n 'Players' => players.count,\n 'Rocks' => souls.where(alive: true, role: 'rock').count,\n 'Papers' => souls.where(alive: true, role: 'paper').count,\n 'Scissors' => souls.where(alive: true, role: 'scissor').count,\n 'Giants' => souls.where(alive: true, role: ['rock giant', 'paper giant', 'scissors giant']).count,\n 'Dragons' => souls.where(alive: true, role: ['rock dragon', 'paper dragon', 'scissors dragon']).count,\n 'Average soul age' => souls.average(:age).to_i\n }\n end", "def deal_matchs_season(round, season = nil)\n count = 0\n matchs = find_matchs(round, season)\n\n matchs.each do |match|\n if match.deal? and match.finished?\n count += 1\n end\n end\n count\n end", "def per_game_stats(season = nil)\n season_id = season ? season.id : Season.current.id\n StatLine.find_by_sql('SELECT AVG(fgm) as fgm, AVG(fga) as fga, coalesce(AVG(fgm)/nullif(AVG(fga), 0), 0) as fgpct, AVG(twom) as twom, AVG(twoa) as twoa, coalesce(AVG(twom)/nullif(AVG(twoa), 0), 0) as twopct, AVG(threem) as threem, AVG(threea) as threea, coalesce(AVG(threem)/nullif(AVG(threea), 0), 0) as threepct,' \\\n 'AVG(ftm) as ftm, AVG(fta) as fta, coalesce(AVG(ftm)/nullif(AVG(fta), 0), 0) as ftpct, AVG(orb) as orb, AVG(drb) as drb, AVG(trb) as trb, AVG(ast) as ast, AVG(stl) as stl, AVG(blk) as blk, AVG(fl) as fl, AVG(\"to\") as to,' \\\n 'AVG(points) as points, COUNT(*) as game_count, sums.league_id FROM (SELECT SUM(fgm) as fgm, SUM(fga) as fga, SUM(twom) as twom, SUM(twoa) as twoa, SUM(threem) as threem, SUM(threea) as threea,' \\\n 'SUM(ftm) as ftm, SUM(fta) as fta, SUM(orb) as orb, SUM(drb) as drb, SUM(trb) as trb, SUM(ast) as ast, SUM(stl) as stl, SUM(blk) as blk, SUM(fl) as fl, SUM(\"to\") as to,' \\\n \"SUM(points) as points, g.league_id as league_id FROM stat_lines sl INNER JOIN games g ON sl.game_id = g.id \" \\\n \"WHERE g.winner is not null AND (g.forfeit is null or not g.forfeit) AND (sl.dnp is null OR not sl.dnp) AND team_id = #{self.id} AND g.season_id = #{season_id} GROUP BY game_id, g.league_id) sums GROUP BY sums.league_id\")\n end", "def interceptions_per_game\n interceptions.joins(:game).group(\"armchair_analysis_games.wk\").count\n end", "def get_average_age_for_season(data, season)\n age_total = 0\n num_of_contestants = 0\n data[season].each do |contestant_hash|\n age_total += (contestant_hash[\"age\"]).to_i\n num_of_contestants += 1\n end\n (age_total / num_of_contestants.to_f).round(0)\nend", "def get_average_age_for_season(data, season)\n age = 0\n num_of_ages = 0\n \n data[season].each do |season_hash|\n season_hash.each do |detail, info|\n if detail == \"age\"\n num_of_ages += 1 \n age += info.to_f\n end\n end\n end\n return (age/num_of_ages).round\nend", "def get_all_seasons_by_status\n dateNow = DateTime.now.end_of_day\n all_seasons = Hash.new\n all_seasons[:upcoming] = Array.new\n all_seasons[:current] = Array.new\n all_seasons[:past] = Array.new\n seasons = Season.all\n\n seasons.each do |season|\n if (season.is_active) # current or upcoming season\n # going to assume if today is part the season end date that the league owner intentionally wanted the season to be current\n if (season.date_start <= dateNow)\n all_seasons[:current].push(season)\n else\n all_seasons[:upcoming].push(season)\n end\n else # past season\n all_seasons[:past].push(season)\n end\n end\n all_seasons\n end", "def season_with_fewest_games\n seasons = @games.group_by { |game| game.season }\n seasons.min_by { |season, games| games.count }.first\n end", "def get_average_age_for_season(data, season)\n count = 0\n age = 0\n data[season].each do |info|\n info.each do |k,v|\n if k == \"age\"\n count += 1\n age += v.to_f\n end\n end\n end\n avg_age = (age / count).round\n return avg_age\nend", "def yearly_play_chart_data\n self.yearly_play_data.map do |year, times_played|\n {name: year, plays: times_played}\n end\n end", "def lost_matchs_season(round, season = nil)\n count = 0\n matchs = find_matchs(round, season)\n\n matchs.each do |match|\n if match.is_looser?(self) and match.finished?\n count += 1\n end\n end\n\n count\n end", "def total_runs_by_teams(table_of_teams)\n hash_of_teams = Hash.new(0)\n table_of_teams.each do |table_row|\n hash_of_teams[table_row['batting_team']] += table_row['total_runs'].to_i\n end\n hash_of_teams['Rising Pune Supergiants'] += hash_of_teams['Rising Pune Supergiant']\n hash_of_teams.delete('Rising Pune Supergiant')\n hash_of_teams\nend", "def getGamesPlayedArray()\n standings = JSON.parse((RestClient.get \"https://statsapi.web.nhl.com/api/v1/standings\"))[\"records\"]#[0][\"teamRecords\"][0]\n for division in standings\n divisionRecords = division[\"teamRecords\"]\n for team in divisionRecords\n teamName = team[\"team\"][\"name\"]\n if teamName.include? \"Canadiens\"\n teamName = \"Montreal Canadiens\"\n end\n @games_played[teamName] = team[\"gamesPlayed\"]\n end\n end\n @games_played[\"N/A\"] = 82\nend", "def gross_per_studio(collection)\n result = {}\n i = 0\n while i < collection.size do\n studio = collection[i][:studio]\n total_earnings = collection[i][:worldwide_gross]\n if !result[studio]\n result[studio] = total_earnings\n else\n result[studio] += total_earnings\n end\n i += 1\n end\n \n # GOAL: Given an AoH where each Hash is a movie, return a Hash that includes\n # the total worldwide_gross of all the movies from each studio.\n #\n # INPUT: (collection) AoH where each Hash represents a movie\n #\n # RETURN: Hash where the keys are the studios and the values are the sum of\n # all the worldwide_gross numbers for every movie in the input Hash\n \n result\nend", "def total_medals_per_team(olympic_data)\n counts = olympic_data.group_by{ |x| x[:\"Team\"] }.map{ |x,y| [x,y.count] }\n counts = Hash[counts]\n return counts\nend", "def goals_favor_season(round, season = nil)\n count = 0\n matchs = find_matchs(round, season)\n\n matchs.each do |match|\n count += match.goals_favor(self) if match.finished?\n end\n\n count\n end", "def results_by_country\n \tresult = Country.all.map do |c|\n \t\tplaces = { }\n \t\t(1..6).each do |place|\n \t\t\tplaces[place] = c.sporters.joins(:competition_results).where(\"competition_results.place = #{place}\").count\n \t\tend\n \t\t{\n \t\t\tname: c.name,\n \t\t\tdata: places\n \t\t}\n \tend\n \trender json: result\n end", "def season\n @season ||= Season.find(@importer_hash.meeting.season_id)\n end", "def games_played\n games.size\n end", "def games_played\n games.size\n end", "def winningest_coach(seasonasstring) # coach name in game team stats\n #per season, get list of all coaches - given by arg\n #per coach, find all games played by that coach\n #then count of all games won / count of all games played\n #find highest\n #return name of coach found in 114\n end", "def get_top_games\n game_count = {}\n self.subscriptions.each do |subscription|\n game_id = Channel.find(subscription.channel_id).game_id\n game_count[game_id] ||= 0\n game_count[game_id] += 1\n end\n game_count.sort_by {|key, value| value}.reverse.to_h.keys\n end", "def season\n number = ((self.day - 1) / 30) % 4\n case number\n when 0\n return \"spring\"\n when 1\n return \"summer\"\n when 2\n return \"fall\"\n when 3\n return \"winter\"\n end\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 initiateSeasonDivision( hash, season, division )\n\n hash[ season ] = {} unless hash.keys.include?( season )\n hash[ season ][ division ] = {} unless hash[ season ].keys.include?( division )\n\n return hash[ season ][ division ]\n\n end", "def generate_games(season)\n unless season.blank?\n player_ids = season.approved_players.map(&:id).uniq\n player_ids.each do |player_id|\n opponent_ids = player_ids - [ player_id ]\n opponent_ids.each do |opponent_id|\n # Runner\n runner_game = {\n league_id: season.league_id,\n season_id: season.id,\n runner_player_id: player_id,\n corp_player_id: opponent_id\n }\n Game.create(runner_game) unless Game.where(runner_game).any?\n\n # Corp\n corp_game = {\n league_id: season.league_id,\n season_id: season.id,\n runner_player_id: opponent_id,\n corp_player_id: player_id\n }\n Game.create(corp_game) unless Game.where(corp_game).any?\n end\n end\n\n season.update_table!\n end\n end", "def mz_seasons\n age - System::JUNIOR_START_AGE\n end", "def games_played\n self.results.to_a.count\n end", "def competition_by_year\n \tresult = CompetitionResult.group_by_year(:created_at, format: '%Y').count\n \trender json: [{ name: 'Count', data: result}]\n end", "def season_number\n @ole.SeasonNumber\n end", "def num_games win_condition\n total_games = 0\n @game_objects.each do |game|\n total_games += 1 if game_meets_win_cond?(win_condition, game)\n end \n total_games\n end", "def studios_totals(nds)\n a_o_a_movies_with_director_names = movies_with_directors_set(nds)\n movies_with_director_names = flatten_a_o_a(a_o_a_movies_with_director_names)\n return gross_per_studio(movies_with_director_names)\nend", "def studios_totals(nds)\n a_o_a_movies_with_director_names = movies_with_directors_set(nds)\n movies_with_director_names = flatten_a_o_a(a_o_a_movies_with_director_names)\n return gross_per_studio(movies_with_director_names)\nend", "def studios_totals(nds)\n a_o_a_movies_with_director_names = movies_with_directors_set(nds)\n movies_with_director_names = flatten_a_o_a(a_o_a_movies_with_director_names)\n return gross_per_studio(movies_with_director_names)\nend", "def studios_totals(nds)\n a_o_a_movies_with_director_names = movies_with_directors_set(nds)\n movies_with_director_names = flatten_a_o_a(a_o_a_movies_with_director_names)\n return gross_per_studio(movies_with_director_names)\nend", "def studios_totals(nds)\n a_o_a_movies_with_director_names = movies_with_directors_set(nds)\n movies_with_director_names = flatten_a_o_a(a_o_a_movies_with_director_names)\n return gross_per_studio(movies_with_director_names)\nend", "def studios_totals(nds)\n a_o_a_movies_with_director_names = movies_with_directors_set(nds)\n movies_with_director_names = flatten_a_o_a(a_o_a_movies_with_director_names)\n return gross_per_studio(movies_with_director_names)\nend", "def studios_totals(nds)\n a_o_a_movies_with_director_names = movies_with_directors_set(nds)\n movies_with_director_names = flatten_a_o_a(a_o_a_movies_with_director_names)\n return gross_per_studio(movies_with_director_names)\nend", "def studios_totals(nds)\n a_o_a_movies_with_director_names = movies_with_directors_set(nds)\n movies_with_director_names = flatten_a_o_a(a_o_a_movies_with_director_names)\n return gross_per_studio(movies_with_director_names)\nend", "def studios_totals(nds)\n a_o_a_movies_with_director_names = movies_with_directors_set(nds)\n movies_with_director_names = flatten_a_o_a(a_o_a_movies_with_director_names)\n return gross_per_studio(movies_with_director_names)\nend", "def studios_totals(nds)\n a_o_a_movies_with_director_names = movies_with_directors_set(nds)\n movies_with_director_names = flatten_a_o_a(a_o_a_movies_with_director_names)\n return gross_per_studio(movies_with_director_names)\nend", "def studios_totals(nds)\n a_o_a_movies_with_director_names = movies_with_directors_set(nds)\n movies_with_director_names = flatten_a_o_a(a_o_a_movies_with_director_names)\n return gross_per_studio(movies_with_director_names)\nend", "def studios_totals(nds)\n a_o_a_movies_with_director_names = movies_with_directors_set(nds)\n movies_with_director_names = flatten_a_o_a(a_o_a_movies_with_director_names)\n return gross_per_studio(movies_with_director_names)\nend", "def studios_totals(nds)\n a_o_a_movies_with_director_names = movies_with_directors_set(nds)\n movies_with_director_names = flatten_a_o_a(a_o_a_movies_with_director_names)\n return gross_per_studio(movies_with_director_names)\nend", "def season_status\n season_st = []\n @organization = Organization.where(:_id => session[:current_org]).first\n @organization.seasons.each do |each_seasons|\n season_st << each_seasons.is_current\n end\n return season_st\n end", "def get_average_age_for_season(data, season)\n age = 0\n count = 0\n data[season].each do |contestant_data|\n age += (contestant_data[\"age\"]).to_f\n count += 1\n end\n (age / count).round\nend", "def count_occurrences(vehicles)\n my_hash = Hash.new\n vehicles.each do |vehicle|\n if my_hash.has_key?(vehicle)\n my_hash[vehicle]+=1\n else\n my_hash[vehicle] = 1\n end\n end\n puts my_hash\nend", "def get_total_games_played\n\t\treturn games.size\n\tend", "def get_average_age_for_season(data, season)\n array_of_ages = []\n average = 0\n data.each do |season_in_hash, contestant_array|\n if season_in_hash.to_s == season\n contestant_array.each do |contestant|\n array_of_ages << contestant[\"age\"].to_f\n end \n average = (array_of_ages.inject{ |sum, num| sum + num }.to_f / array_of_ages.size).round\n end\n end\n average\nend", "def occurences_count\n\t\t\t\t\t\tHash.new(0).tap do |result|\n\t\t\t\t\t\t each { |item| result[item] += 1 }\n\t\t\t\t\t\tend\n\t\t\t\tend", "def get_average_age_for_season(data, season)\n data.each do |season_iteration, stats|\n if season_iteration == season\n total_ages = 0\n ages = stats.each do |age|\n total_ages = (total_ages + age[\"age\"].to_i).to_f\n end\n return (total_ages/ages.length).round\n end\n end\nend", "def all_leagues_hash(season=\"2018\")\n leagues = {}\n response = parse_api_request(\"#{BASE_URL}leagues/season/#{season}\")[\"leagues\"].values\n response.each do |league_data|\n leagues[league_data[\"league_id\"]] = \"#{league_data[\"country\"]} - #{league_data[\"name\"]}\"\n end\n leagues\nend", "def fewest_hits(seasonasstring) # shots in game team stats\n #inverse of above\n end", "def get_total_games_played\n return games.size\n end", "def count_occurrences(vehicles)\n occurences = {}\n\n vehicles.each do |vehicle|\n occurences[vehicle] = vehicles.count(vehicle)\n end\n\n occurences.each do |vehicle, count|\n puts \"#{vehicle} => #{count}\"\n end\nend", "def num_points_scored (name)\n gh=game_hash\n gh.each do |team, stats|\n stats[:players].each_key do |nameval|\n if (nameval==name)\n return gh[team][:players][nameval][:points]\n end\n end\n end\nend", "def test_average_goals_by_season\n\n expected = {\n \"20122013\"=>4.12,\n \"20162017\"=>4.23,\n \"20142015\"=>4.14,\n \"20152016\"=>4.16,\n \"20132014\"=>4.19,\n \"20172018\"=>4.44\n }\n assert_equal expected, @stat_tracker.average_goals_by_season\n\n end", "def total_medals_per_team(olympic_data)\n\n team_medals_hash = {}\n\n olympic_data.each do |data|\n\n if team_medals_hash.key?(data[\"Team\"])\n if [\"Gold\", \"Silver\", \"Bronze\"].include?(data[\"Medal\"]) #SAME TEAM, MEDAL\n team_medals_hash[data[\"Team\"]] += 1\n end\n else\n\n if [\"Gold\", \"Silver\", \"Bronze\"].include?(data[\"Medal\"]) # NEW TEAM, MEDAL\n team_medals_hash[data[\"Team\"]] = 1\n else\n team_medals_hash[data[\"Team\"]] = 0\n\n end\n end\n end\n return team_medals_hash\nend", "def count_contestants_by_hometown(data, hometown)\n counter = 0 # COUNTER VALUE HAS TO BE HERE\n data.each do |season, season_array|\n season_array.each do |into_array|\n if into_array[\"hometown\"] == hometown\n counter += 1\n # binding.pry\n end \n end \n end\n counter\nend", "def initialize(n) # The state of a season is just its \n @n = n # index in the NAMES and INSTANCES arrays\n end", "def initialize(n) # The state of a season is just its \n @n = n # index in the NAMES and INSTANCES arrays\n end", "def court_quantity sport=nil\n \n if @sports.blank?\n @sports = self.courts.includes(:sport).map {|c| c.sport.name }\n end\n \n qty_hash = Hash.new 0\n\n @sports.each do |sp|\n qty_hash[sp.downcase] += 1\n end\n\n return qty_hash[sport.downcase] unless sport.blank?\n \n qty_hash\n\n end", "def game_info(year, input)\r\n x = get_games(year, input).sort.to_h\r\n\r\n #determine if the team did not exist during the given year\r\n if x == {}\r\n puts \"The #{self.chosen_team_full_name} did not play any games in #{year}.\"\r\n end\r\n\r\n if self.chosen_team_full_name != nil\r\n self.chosen_team_nickname = self.chosen_team_full_name.split(\" \").last\r\n end\r\n\r\n counter = 0\r\n x.each do |key, value|\r\n counter += 1\r\n if value[\"home_team\"] == @chosen_team_full_name && value[\"home_team_score\"] > value[\"visitor_team_score\"]\r\n puts \"#{value[\"date\"]} -- #{value[\"visitor_team\"]}: #{self.chosen_team_nickname} win #{value[\"home_team_score\"]} to #{value[\"visitor_team_score\"]}.\".green\r\n sleep(0.2)\r\n elsif value[\"home_team\"] == @chosen_team_full_name && value[\"home_team_score\"] < value[\"visitor_team_score\"]\r\n puts \"#{value[\"date\"]} -- #{value[\"visitor_team\"]}: #{self.chosen_team_nickname} lose #{value[\"visitor_team_score\"]} to #{value[\"home_team_score\"]}.\".colorize(:red)\r\n sleep(0.2)\r\n elsif value[\"visitor_team\"] == @chosen_team_full_name && value[\"home_team_score\"] > value[\"visitor_team_score\"]\r\n puts \"#{value[\"date\"]} -- @#{value[\"home_team\"]}: #{self.chosen_team_nickname} lose #{value[\"home_team_score\"]} to #{value[\"visitor_team_score\"]}.\".colorize(:red)\r\n sleep(0.2)\r\n elsif value[\"visitor_team\"] == @chosen_team_full_name && value[\"home_team_score\"] < value[\"visitor_team_score\"]\r\n puts \"#{value[\"date\"]} -- @#{value[\"home_team\"]}: #{self.chosen_team_nickname} win #{value[\"visitor_team_score\"]} to #{value[\"home_team_score\"]}.\".colorize(:green)\r\n sleep(0.2)\r\n end\r\n \r\n if counter % 20 == 0\r\n puts \"Type 'n' if you do not want to see more games. Otherwise press 'Enter'\"\r\n input = gets.chomp \r\n\r\n if input == \"n\"\r\n break\r\n end\r\n\r\n end\r\n\r\n end\r\n end", "def get_games(year, input)\r\n page = 1\r\n query = 'https://www.balldontlie.io/api/v1/games' + '?seasons[]=' + year.to_s + '&team_ids[]=' + input.to_s + '&page=' + page.to_s\r\n response_meta = HTTParty.get(query)[\"meta\"]\r\n response_data = HTTParty.get(query)[\"data\"]\r\n total_pages = response_meta[\"total_pages\"]\r\n games_hash = {}\r\n\r\n while page <= total_pages\r\n\r\n #Go back and maximize the per_page limit to minimize the number of calls\r\n query = 'https://www.balldontlie.io/api/v1/games' + '?seasons[]=' + year.to_s + '&team_ids[]=' + input.to_s + '&page=' + page.to_s + '&per_page=50'\r\n HTTParty.get(query)[\"data\"].each do |i|\r\n\r\n\r\n #change formatting of date\r\n date = i[\"date\"].split(\"-\")\r\n day_value = date[2].split(/T/).shift\r\n key_date = \"#{date[0]}/#{date[1]}/#{day_value}\"\r\n formatted_date = \"#{date[1]}/#{day_value}/#{date[0]}\"\r\n\r\n \r\n\r\n games_hash[key_date] = {\r\n \"date\" => formatted_date,\r\n \"home_team\" => i[\"home_team\"][\"full_name\"],\r\n \"visitor_team\" => i[\"visitor_team\"][\"full_name\"],\r\n \"home_team_score\" => i[\"home_team_score\"],\r\n \"visitor_team_score\" => i[\"visitor_team_score\"]\r\n }\r\n \r\n\r\n end\r\n page += 1 \r\n end\r\n games_hash\r\n end", "def count_occurrences(vehicles)\n occurrences = Hash.new(0)\n vehicles.each { |vehicle| occurrences[vehicle] += 1 }\n occurrences.each { |key, value| puts \"#{key} => #{value}\" }\nend", "def count_contestants_by_hometown(data, hometown)\n home_town = 0\n data.each do |season_iteration, stats|\n stats.each do |town|\n if town[\"hometown\"] == hometown\n home_town = home_town + 1\n end\n end\n end\n return home_town\nend", "def determine_winner game\n winner = game.max_by {|team| team[:score]}\n team_standings = get_team_by_name(winner)\n team_standings[:winnings] += 3\nend", "def teams_in_game(a_game)\n teams_in_game = {}\n a_game.game_teams.each do |game_team|\n team_in_game = @teams[game_team.name.to_sym]\n teams_in_game[game_team.name.to_sym] = team_in_game\n end\n teams_in_game\n end", "def season(year, **options) = get(\"/seasons/#{year}\", **{ sportId: 1 }.merge(options))", "def flu_season\n event_display(\"It's flu season!\\n One player has been infected and needs some time to recuperate.\")\n {Game.last.players.sample.id.to_s =>\n {wellbeing: -100}\n }\n end", "def color_counts\n color_counts = Hash.new(0)\n @pegs.each do |color|\n color_counts[color] += 1\n end\n color_counts\n end" ]
[ "0.7383524", "0.7337395", "0.72860044", "0.663687", "0.6600385", "0.6486747", "0.6486122", "0.6407198", "0.63750285", "0.6307263", "0.6301293", "0.6264373", "0.62578285", "0.6215657", "0.61690485", "0.6119021", "0.6094209", "0.60921717", "0.6081048", "0.6075426", "0.6061621", "0.60434926", "0.6008586", "0.59808993", "0.5979727", "0.5925491", "0.59230006", "0.5918951", "0.59039783", "0.58855623", "0.5881565", "0.5864245", "0.5860005", "0.5843541", "0.58299994", "0.58241117", "0.58161104", "0.5803616", "0.57994974", "0.57725906", "0.57722783", "0.57690847", "0.5763383", "0.57380307", "0.5734018", "0.5712662", "0.5710025", "0.5708179", "0.5708179", "0.5689291", "0.568386", "0.56748486", "0.56660134", "0.5661168", "0.563856", "0.5635858", "0.5615987", "0.560406", "0.5603225", "0.55805534", "0.5578591", "0.55784565", "0.55784565", "0.55784565", "0.55784565", "0.55784565", "0.55784565", "0.55784565", "0.55784565", "0.55784565", "0.55784565", "0.55784565", "0.55784565", "0.55670214", "0.5565864", "0.556456", "0.5563888", "0.55632234", "0.5562894", "0.55554146", "0.55527425", "0.554805", "0.554803", "0.554755", "0.55422235", "0.55400604", "0.55177516", "0.5513743", "0.5512331", "0.5512331", "0.5509643", "0.55042285", "0.5501304", "0.55005926", "0.54982597", "0.5496222", "0.5491085", "0.5490726", "0.5490723", "0.5482212" ]
0.85778594
0
returns average number of goals scored in a game across all seasons
def average_goals_per_game total_goals = @teams.map {|team| team.total_goals_scored}.sum total_games = @teams.map {|team| team.home_games}.sum (total_goals.to_f / total_games.to_f).round(2) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def average_goals_by_season\n goals_by_season = @games.group_by { |game| game.season.to_s }\n goals_by_season.each do |season, games|\n season_goals = games.map { |game| game.home_goals + game.away_goals }.sum\n goals_by_season[season] = (season_goals.to_f / games.count.to_f).round(2)\n end\n end", "def get_average_age_for_season(data, season)\n age_total = 0\n num_of_contestants = 0\n data[season].each do |contestant_hash|\n age_total += (contestant_hash[\"age\"]).to_i\n num_of_contestants += 1\n end\n (age_total / num_of_contestants.to_f).round(0)\nend", "def get_average_age_for_season(data, season)\n data.each do |season_iteration, stats|\n if season_iteration == season\n total_ages = 0\n ages = stats.each do |age|\n total_ages = (total_ages + age[\"age\"].to_i).to_f\n end\n return (total_ages/ages.length).round\n end\n end\nend", "def get_average_age_for_season(data, season)\n age = 0\n count = 0\n data[season].each do |contestant_data|\n age += (contestant_data[\"age\"]).to_f\n count += 1\n end\n (age / count).round\nend", "def total_score\n @all_games.map do |games|\n games[\"home_goals\"].to_i + games[\"away_goals\"].to_i\n end\n end", "def power_play_goal_percentage(seasonasstring) # power_play info in game team stat\n #find list of all games in season given by arg\n #sum all power play goals\n #sum all power play oppertunities\n #divide line 146 and line 147\n #return total of above\n end", "def lacrosse_scoring_average(sport, player)\n\t\tgoals = 0\n\t\tgames = sport.teams.find(player.team_id).gameschedules\n\n\t\tgames.each do |g|\n\t\t\tstat = g.lacrosstats.find_by(athlete_id: player.id)\n\t\t\tgoals += stat.lacross_scorings.count if stat.lacross_scorings.any?\n\t\tend\n\n\t\tif games > 0\n\t\t\treturn goals / games.count\n\t\telse\n\t\t\treturn 0.0\n\t\tend\n\tend", "def get_average_age_for_season(data, season)\n array_of_ages = []\n average = 0\n data.each do |season_in_hash, contestant_array|\n if season_in_hash.to_s == season\n contestant_array.each do |contestant|\n array_of_ages << contestant[\"age\"].to_f\n end \n average = (array_of_ages.inject{ |sum, num| sum + num }.to_f / array_of_ages.size).round\n end\n end\n average\nend", "def per_game_stats(season = nil)\n season_id = season ? season.id : Season.current.id\n StatLine.find_by_sql('SELECT AVG(fgm) as fgm, AVG(fga) as fga, coalesce(AVG(fgm)/nullif(AVG(fga), 0), 0) as fgpct, AVG(twom) as twom, AVG(twoa) as twoa, coalesce(AVG(twom)/nullif(AVG(twoa), 0), 0) as twopct, AVG(threem) as threem, AVG(threea) as threea, coalesce(AVG(threem)/nullif(AVG(threea), 0), 0) as threepct,' \\\n 'AVG(ftm) as ftm, AVG(fta) as fta, coalesce(AVG(ftm)/nullif(AVG(fta), 0), 0) as ftpct, AVG(orb) as orb, AVG(drb) as drb, AVG(trb) as trb, AVG(ast) as ast, AVG(stl) as stl, AVG(blk) as blk, AVG(fl) as fl, AVG(\"to\") as to,' \\\n 'AVG(points) as points, COUNT(*) as game_count, sums.league_id FROM (SELECT SUM(fgm) as fgm, SUM(fga) as fga, SUM(twom) as twom, SUM(twoa) as twoa, SUM(threem) as threem, SUM(threea) as threea,' \\\n 'SUM(ftm) as ftm, SUM(fta) as fta, SUM(orb) as orb, SUM(drb) as drb, SUM(trb) as trb, SUM(ast) as ast, SUM(stl) as stl, SUM(blk) as blk, SUM(fl) as fl, SUM(\"to\") as to,' \\\n \"SUM(points) as points, g.league_id as league_id FROM stat_lines sl INNER JOIN games g ON sl.game_id = g.id \" \\\n \"WHERE g.winner is not null AND (g.forfeit is null or not g.forfeit) AND (sl.dnp is null OR not sl.dnp) AND team_id = #{self.id} AND g.season_id = #{season_id} GROUP BY game_id, g.league_id) sums GROUP BY sums.league_id\")\n end", "def coach_win_percent_in_season(coach, game_ids)\n (total_wins_of_coach_in_season(coach, game_ids) / total_coach_games_in_season(coach, game_ids).to_f).round(2)\n end", "def get_average_age_for_season(data, season)\n age = 0\n num_of_ages = 0\n \n data[season].each do |season_hash|\n season_hash.each do |detail, info|\n if detail == \"age\"\n num_of_ages += 1 \n age += info.to_f\n end\n end\n end\n return (age/num_of_ages).round\nend", "def get_average_age_for_season(data, season)\n a = []; data[season].each { |c| a << c[\"age\"].to_f }; (a.reduce(:+) / a.count).round\nend", "def count_of_games_by_season\n games_by_season = @games.group_by { |game| game.season.to_s }\n games_by_season.each { |season, games| games_by_season[season] = games.count }\n end", "def total_wins_by_season_by_team_id(passed_id)\n @by_team_id_game_objects.each do |game|\n if helper_for_win_count(passed_id, game)\n @total_wins_by_season[game[\"season\"]] += 1\n elsif helper_for_loss_count(passed_id, game)\n @total_wins_by_season[game[\"season\"]] += 0\n end\n end\n end", "def goals_against_season(round, season = nil)\n count = 0\n matchs = find_matchs(round, season)\n\n matchs.each do |match|\n count += match.goals_against(self) if match.finished?\n end\n\n count\n end", "def get_average_age_for_season(data, season)\n age_array = []\n average = 0\n \n # Get ages\n data[season].each do |person| \n age_array << person[\"age\"].to_f\n end \n \n # Average and round ages\n average = (age_array.sum / age_array.length).round\nend", "def get_average_age_for_season(bachelortv, season)\n bachelortv.each do |season_number, contestant_data|\n if season == season_number\n contestant_data.each do |contestant|\n contestant[\"age\"].reduce(0) do |sum|\n sum += age\n end\n end\n end\n end\nend", "def goals_favor_season(round, season = nil)\n count = 0\n matchs = find_matchs(round, season)\n\n matchs.each do |match|\n count += match.goals_favor(self) if match.finished?\n end\n\n count\n end", "def batting_average(year: nil, team: nil)\n hits, at_bats = 0, 0\n\n seasonal_stats.each do |stat_line|\n year_match = stat_line.year == year || year == nil\n team_match = stat_line.team == team || team == nil\n if year_match && team_match\n hits += stat_line.hits\n at_bats += stat_line.at_bats\n end\n end\n\n if (at_bats != 0)\n return (hits.to_f / at_bats)\n else\n return 0.0\n end\n end", "def total_games_by_coach_by_season\n @total_games_by_coach = Hash.new{ |hash, key| hash[key] = 0}\n @by_season_game_team_objects.each do |game_by_season|\n @total_games_by_coach[game_by_season[\"head_coach\"]] += 1\n end\n end", "def get_average_age_for_season(data, season)\n count = 0\n age = 0\n data[season].each do |info|\n info.each do |k,v|\n if k == \"age\"\n count += 1\n age += v.to_f\n end\n end\n end\n avg_age = (age / count).round\n return avg_age\nend", "def team_average\n # This version is implemented as a database AVG operation,\n # but it cannot be eager loaded so it results in an extra\n # database query for each project:\n #\n # avg = students_projects.select(:points).average :points\n # avg ? avg.round : 0\n\n # This version programmatically finds the average of the points:\n #self.reload\n no_of_students = self.students_projects.length\n return 0 if no_of_students == 0\n total = 0\n self.students_projects.each { |s| total += s.points }\n (total / no_of_students).round\n end", "def total_score\n sum = self.games.sum{|game|game.points}\n sum.to_i / self.games.count\n end", "def goals_by_game_situation(season = nil)\n stats_request(\"goalsByGameSituation\", season).first\n end", "def test_average_goals_by_season\n\n expected = {\n \"20122013\"=>4.12,\n \"20162017\"=>4.23,\n \"20142015\"=>4.14,\n \"20152016\"=>4.16,\n \"20132014\"=>4.19,\n \"20172018\"=>4.44\n }\n assert_equal expected, @stat_tracker.average_goals_by_season\n\n end", "def get_standings(games)\n teams = Hash.new\n games.each do |game|\n division_id = game.division_id\n home_team = game.home_team\n away_team = game.visiting_team\n if(teams[home_team.name].nil?)\n teams[home_team.name] = {:win => 0, :loss => 0, :tie => 0, :point=> 0}\n end\n\n if(teams[away_team.name].nil?)\n teams[away_team.name] = {:win => 0, :loss => 0, :tie => 0, :point => 0}\n end\n if(game.home_team_score && game.visiting_team_score)\n if(game.home_team_score > game.visiting_team_score)\n # home team won\n teams[home_team.name][:win] += 1\n teams[home_team.name][:point] += 5\n # visiting team loss\n teams[away_team.name][:loss] += 1\n elsif(game.home_team_score < game.visiting_team_score)\n # home team loss\n teams[home_team.name][:loss] += 1\n #visiting team won\n teams[away_team.name][:win] += 1\n teams[away_team.name][:point] += 5\n else\n # tie game\n teams[home_team.name][:tie] += 1\n teams[home_team.name][:point] += 1\n teams[away_team.name][:tie] += 1\n teams[away_team.name][:point] += 1\n end\n end\n end\n teams.each do |team, value|\n puts team\n total_games = value[:win] + value[:loss] + value[:tie]\n if total_games > 0 \n win_percentage = value[:win]/total_games.to_f\n else\n win_percentage = 0\n end \n value[:percentage] = win_percentage\n end\n teams_sorted = teams.sort_by{ |k, v| v[:point]}.reverse\n return teams_sorted\n end", "def studios_totals(nds)\n a_o_a_movies_with_director_names = movies_with_directors_set(nds)\n movies_with_director_names = flatten_a_o_a(a_o_a_movies_with_director_names)\n return gross_per_studio(movies_with_director_names)\nend", "def studios_totals(nds)\n a_o_a_movies_with_director_names = movies_with_directors_set(nds)\n movies_with_director_names = flatten_a_o_a(a_o_a_movies_with_director_names)\n return gross_per_studio(movies_with_director_names)\nend", "def studios_totals(nds)\n a_o_a_movies_with_director_names = movies_with_directors_set(nds)\n movies_with_director_names = flatten_a_o_a(a_o_a_movies_with_director_names)\n return gross_per_studio(movies_with_director_names)\nend", "def studios_totals(nds)\n a_o_a_movies_with_director_names = movies_with_directors_set(nds)\n movies_with_director_names = flatten_a_o_a(a_o_a_movies_with_director_names)\n return gross_per_studio(movies_with_director_names)\nend", "def studios_totals(nds)\n a_o_a_movies_with_director_names = movies_with_directors_set(nds)\n movies_with_director_names = flatten_a_o_a(a_o_a_movies_with_director_names)\n return gross_per_studio(movies_with_director_names)\nend", "def studios_totals(nds)\n a_o_a_movies_with_director_names = movies_with_directors_set(nds)\n movies_with_director_names = flatten_a_o_a(a_o_a_movies_with_director_names)\n return gross_per_studio(movies_with_director_names)\nend", "def studios_totals(nds)\n a_o_a_movies_with_director_names = movies_with_directors_set(nds)\n movies_with_director_names = flatten_a_o_a(a_o_a_movies_with_director_names)\n return gross_per_studio(movies_with_director_names)\nend", "def studios_totals(nds)\n a_o_a_movies_with_director_names = movies_with_directors_set(nds)\n movies_with_director_names = flatten_a_o_a(a_o_a_movies_with_director_names)\n return gross_per_studio(movies_with_director_names)\nend", "def studios_totals(nds)\n a_o_a_movies_with_director_names = movies_with_directors_set(nds)\n movies_with_director_names = flatten_a_o_a(a_o_a_movies_with_director_names)\n return gross_per_studio(movies_with_director_names)\nend", "def studios_totals(nds)\n a_o_a_movies_with_director_names = movies_with_directors_set(nds)\n movies_with_director_names = flatten_a_o_a(a_o_a_movies_with_director_names)\n return gross_per_studio(movies_with_director_names)\nend", "def studios_totals(nds)\n a_o_a_movies_with_director_names = movies_with_directors_set(nds)\n movies_with_director_names = flatten_a_o_a(a_o_a_movies_with_director_names)\n return gross_per_studio(movies_with_director_names)\nend", "def studios_totals(nds)\n a_o_a_movies_with_director_names = movies_with_directors_set(nds)\n movies_with_director_names = flatten_a_o_a(a_o_a_movies_with_director_names)\n return gross_per_studio(movies_with_director_names)\nend", "def studios_totals(nds)\n a_o_a_movies_with_director_names = movies_with_directors_set(nds)\n movies_with_director_names = flatten_a_o_a(a_o_a_movies_with_director_names)\n return gross_per_studio(movies_with_director_names)\nend", "def points_season(round, season = nil)\n count = 0\n matchs = find_matchs(round, season)\n\n matchs.each do |match|\n if match.is_winner?(self) and match.finished?\n count += MatchGeneral::PT_WIN\n end\n if match.deal? and match.finished?\n count += MatchGeneral::PT_DEAL\n end\n end\n\n count\n end", "def most_hits(seasonasstring) # shots in game team stats\n #get a list of all teams that played in that season\n #use above list to sum all shots across all games in season\n #find highest across list\n #return team name as found in 139\n end", "def percentage_visitor_wins\n visitor_wins = @teams.map { |team| team.away_wins }.sum\n visitor_games = @teams.map { |team| team.away_games }.sum\n (visitor_wins.to_f / visitor_games.to_f).round(2)\n end", "def avarage_calories_burned\n total_workout_calories / set_sport_by_user.count\n rescue\n 0\n end", "def get_total_games_played\n\t\treturn games.size\n\tend", "def percentage_home_wins\n home_wins = @teams.map { |team| team.home_wins }.sum\n home_games = @teams.map { |team| team.home_games }.sum\n (home_wins.to_f / home_games.to_f).round(2)\n end", "def get_total_games_played\n return games.size\n end", "def score\n goals = self.match_events.select { |e| e.event_type == MatchEvent::EventType::GOAL }\n goals.reduce({away: 0, home: 0}) do |score, e|\n if e.event_author == MatchEvent::EventAuthor::HOME\n score[:home] += 1\n elsif e.event_author == MatchEvent::EventAuthor::AWAY\n score[:away] += 1\n end\n score\n end\n end", "def average_calories\n dessert_cal = desserts.map do |dessert|\n dessert.calories || 0\n end\n dessert_cal.reduce(:+)/dessert_cal.length\n end", "def season_with_fewest_games\n seasons = @games.group_by { |game| game.season }\n seasons.min_by { |season, games| games.count }.first\n end", "def gross_per_studio(collection)\n result = {}\n i = 0\n while i < collection.size do\n studio = collection[i][:studio]\n total_earnings = collection[i][:worldwide_gross]\n if !result[studio]\n result[studio] = total_earnings\n else\n result[studio] += total_earnings\n end\n i += 1\n end\n \n # GOAL: Given an AoH where each Hash is a movie, return a Hash that includes\n # the total worldwide_gross of all the movies from each studio.\n #\n # INPUT: (collection) AoH where each Hash represents a movie\n #\n # RETURN: Hash where the keys are the studios and the values are the sum of\n # all the worldwide_gross numbers for every movie in the input Hash\n \n result\nend", "def game_score\n previous_hands = self.game_player.hand_players.joins(:hand).where(\n \"hands.position <= ?\", self.hand.position\n )\n gs = 0\n for h in previous_hands\n gs += h.hand_score\n end\n return gs\n end", "def rankings\n self.total_against_goals = 0\n self.total_goals = 0\n if self.players != []\n self.players.each do |player|\n if player.scores.first != nil\n Game.all.each do |game|\n unless self.total_goals.nil? || self.total_against_goals.nil? || game.scores.last.goals.nil? || game.scores.first.goals.nil?\n if game.scores.first.player == player\n self.total_goals += game.scores.first.goals\n self.total_against_goals += game.scores.last.goals\n else\n self.total_goals += game.scores.last.goals\n self.total_against_goals += game.scores.first.goals\n end\n self.save\n end\n end\n end\n end\n end\n end", "def average_finish_time(game, nb_game)\n\n#On initialise la somme des nombres de laps\nsomme = 0\n\n#On teste si le nombre de parties > 100, si non on n'accpete pas\n\tif nb_game < 100 then puts \"Il faut un nombre > 100 !\"\n\n#Si oui, on lance nb_parties (en l'occurence 150) fois le jeu (en l'occurence Stairways)\n\telse\n\t\t\tnb_game.times do game\n\t\t\tsomme += stairway\n\t\t\tend\n\n#On affiche la moyenne du nombre de parties\n\t\tputs \"**************************************************************************\"\n\t\tputs \"Le score moyen de vos #{nb_game} parties est de #{somme/nb_game} !\"\n\t\tputs \"**************************************************************************\"\n\n\tend\n\nend", "def average_of(raitingss)\n raitingss.sum(&:score).to_f / raitingss.count\n end", "def average_assignment_score\n assignment_average_scores.inject(:+).to_f/num_assignments\n rescue ZeroDivisionError\n 0\n end", "def num_games win_condition\n total_games = 0\n @game_objects.each do |game|\n total_games += 1 if game_meets_win_cond?(win_condition, game)\n end \n total_games\n end", "def matchup_count(season = 2015)\n r = Record.find_by(team_id: self.id, year: season)\n r.wins + r.losses + r.ties\n end", "def rating\n position_sum = 0\n games = []\n number_of_teams = 0\n Participation.find_all_by_player_id(self.id).each do |participation|\n position_sum += participation.position\n games.push Game.find(participation.game_id)\n end\n\n games.each do |game|\n number_of_teams += game.number_of_teams\n end\n\n if position_sum == 0\n position_sum = number_of_teams.to_f-0.5\n end\n\n (1 - position_sum.to_f/number_of_teams).round 2\n end", "def team_score\n team_member = @current_user.team.users\n team_comment = Comment.where(user_id: team_member.pluck('id'))\n emotion_scores = team_comment.where('created_at BETWEEN ? AND ?', DateTime.now.beginning_of_day, DateTime.now.end_of_day).average(:score)\n emotion_scores\n end", "def average_player_age\n players.average(:age)\n end", "def fewest_hits(seasonasstring) # shots in game team stats\n #inverse of above\n end", "def wins\n wins = 0\n self.teams.each do |team|\n wins += team.games_won.length\n end\n wins\n end", "def oppg\n (opp_possessions.to_f)/games\n end", "def oppg\n (opp_possessions.to_f)/games\n end", "def total_score(play)\n sum = 0;\n play.decision_array.each_with_index{|v, i|\n sum += 1 if v == decision_array[i] && i != 0 # exclude an example\n }\n sum\n end", "def most_accurate_team(seasonasstring) # shots in game team stats\n #get a list of all teams that played in that season - given by arg\n #use above list to sum all shots across all games in season\n #divide above by goals made across all games in season\n #find highest percentage\n #return team name as found in 127\n end", "def avg_of_toryo_turn_max\n s = lose_scope\n s = s.joins(:battle)\n s = s.where(Swars::Battle.arel_table[:final_key].eq(\"TORYO\"))\n if v = s.average(Swars::Battle.arel_table[:turn_max])\n v.to_i\n end\n end", "def num_points_scored(player_name)\npoints_scored = 0\ngame_hash.each do |location, team_data|\n team_data.each do |attribute, data|\n if attribute == :players\n data.each do |player, stats|\n if player == player_name\n points_scored = stats[:points]\n end\n end\n end\n end\nend\npoints_scored\nend", "def goals_against()\n\t self.as_regular_contestants.select{|c| c.opponent.score}.collect{|c| c.opponent.score}.inject{|gf, c| gf + c} || 0\n\tend", "def calculate!\n ov = self[:overall]\n ov[:high_night] = {}\n ov[:winners] = {}\n\n self.each do |player_id, st|\n next if player_id == :overall\n\n ## calculate computed stats for player\n st[:nights] += st[:dates].keys.length # if st[:nights] == 0\n st[:high_night] = st[:dates].values.max\n st[:gold_stars] = 1 if st[:nights] == 29\n st[:warps_per_game] = 1.0 * st[:warps] / st[:games] rescue 0\n st[:warps_per_night] = 1.0 * st[:warps] / st[:nights] rescue 0\n st[:games_per_night] = 1.0 * st[:games] / st[:nights] rescue 0\n st[:wins_per_night] = 1.0 * st[:wins] / st[:nights] rescue 0\n st[:wins_per_game] = 1.0 * st[:wins] / st[:games] rescue 0\n\n ## accumulate overall stats\n [:warps, :wins, :cfbs,\n :mystery_factors, :gold_stars]. each do |field|\n ov[field] += st[field]\n end\n [:wimps, :come_ons].each do |field|\n if st[field]\n ov[field] ||= 0\n ov[field] += st[field]\n end\n end\n # nights won calculation\n st[:dates].each do |date,warps|\n ov[:dates][date] += warps\n hnd = ov[:high_night][date] ||= {:players => [], :warps => 0}\n if hnd[:warps] < warps\n hnd[:players] = [player_id]\n hnd[:warps] = warps\n elsif hnd[:warps] == warps\n hnd[:players].push(player_id)\n end\n end\n end\n\n ## update overall computed stats\n st = self[:overall]\n ov[:games] = ov[:wins]\n ov[:nights] = ov[:dates].keys.length\n ov[:nights] = 29 if ov[:nights] == 0 ## provide sane default\n ov[:nights] = ov[:nights_real] if ov[:nights_real]\n ov[:warps_per_game] = 1.0 * ov[:warps] / ov[:games] rescue 0\n ov[:warps_per_night] = 1.0 * ov[:warps] / ov[:nights] rescue 0\n ov[:games_per_night] = 1.0 * ov[:games] / ov[:nights] rescue 0\n ov[:high_night].each do |date,h|\n h[:players].each {|p| self[p][:nights_won] += 1}\n end\n\n ## determine per-stat winners\n # fuck everyone but the top 50 OR those with 50+ warps\n # the 51 below is not a bug\n sorted_players = self.keys.sort{|a,b| self[b][:warps] <=> self[a][:warps]}\n fifty_plus = self.keys.select{|p| self[p][:warps] >= 50}\n eligible = (sorted_players[0..51] | fifty_plus).\n inject(Hash.new(false)) {|acc,p| acc.merge(p => true)}\n [:warps, :games, :nights, :wins, :nights_won, :cfbs,\n :come_ons, :wimps, :warps_per_game, :warps_per_night,\n :games_per_night, :wins_per_game, :high_night].each do |field|\n owf = ov[:winners][field] = {:players => [], :value => 0}\n self.each do |player, st|\n next if player == :overall\n next unless eligible[player]\n if st[field].to_f > owf[:value]\n owf[:players] = [player]\n owf[:value] = st[field]\n elsif st[field] == owf[:value]\n owf[:players].push(player)\n end\n end\n end\n\n ## mark per-stat winners\n ov[:winners].each do |field, win|\n win[:players].each do |player|\n self[player][:winner][field] = true\n end\n end\n\n self\n end", "def average poss\n '%.2f' % ( @stat_data.map{|n| n[poss].to_f}.reduce(:+) / @stat_data.length )\n end", "def avg_kills_per_shot\n 1 / avg_shots_per_kill\n end", "def avg_kills_per_shot\n 1 / avg_shots_per_kill\n end", "def played_matchs_season(round, season = nil)\n count = 0\n matchs = find_matchs(round, season)\n\n matchs.each do |match|\n if match.finished?\n count += 1\n end\n end\n count\n end", "def average_score\n count = 0.0\n avrg = 0.0\n if self.cadets.empty?\n return 0.0\n else\n self.cadets.each do |cdt|\n unless cdt.discharged?\n avrg += cdt.average_score\n count += 1.0\n end\n end\n return count != 0.0 ? (avrg/count).round(1) : 0.0\n end\n end", "def goals_by_hoa_id_suite\n goals_by_away_id\n goals_by_home_id\n average_score_per_away_game_by_team_id\n average_score_per_home_game_by_team_id\n end", "def goals_by_hoa_id_suite\n goals_by_away_id\n goals_by_home_id\n average_score_per_away_game_by_team_id\n average_score_per_home_game_by_team_id\n end", "def starters_average\n total = self.players.starter.inject(0) {|result, element| result + element.average_qualities}\n return total / MIN_PLAYERS\n end", "def winning_team\n home_team_sum = 0\n away_team_sum = 0\n game_hash.each do |team, team_stats|\n if team_stats[:team_name] == \"Brooklyn Nets\"\n team_stats[:players].each do |player_stats|\n home_team_sum += player_stats[:points]\n end\n elsif team_stats[:team_name] == \"Charlotte Hornets\"\n team_stats[:players].each do |player_stats|\n away_team_sum += player_stats[:points]\n end\n end\n end\n if home_team_sum > away_team_sum\n game_hash[:home][:team_name]\n elsif home_team_sum < away_team_sum\n game_hash[:away][:team_name]\n end\nend", "def calculate_average(params, current_user, ret_fp = false)\n sport_name = self.sport.name\n played_games_ids = StatEvent.where(\"player_stats_id='#{params[:player_ids]}' AND quantity != 0\").\n pluck('DISTINCT game_stats_id')\n games = Game.where(stats_id: played_games_ids)\n last_year_ids = games.where(season_year: (Time.now.utc - 4).year - 1).map(&:stats_id).uniq\n this_year_ids = games.where(season_year: (Time.now.utc - 4).year).select { |i| i.stat_events.any? }.map(&:stats_id).uniq\n events = StatEvent.where(player_stats_id: params[:player_ids],\n game_stats_id: played_games_ids)\n if games.last and sport_name == 'MLB'\n recent_games = games.where(season_year: (Time.now.utc - 4).year).order(\"game_time DESC\").first(50)\n else\n recent_games = games.order(\"game_time DESC\").first(5)\n end\n recent_ids = recent_games.map(&:stats_id)\n recent_ids.uniq!\n recent_events = events.where(game_stats_id: recent_ids)\n last_year_events = events.where(game_stats_id: last_year_ids)\n this_year_events = events.where(game_stats_id: this_year_ids)\n recent_stats = SportStrategy.for(sport_name).collect_stats(recent_events, params[:position])\n last_year_stats = SportStrategy.for(sport_name).collect_stats(last_year_events, params[:position])\n this_year_stats = SportStrategy.for(sport_name).collect_stats(this_year_events, params[:position])\n total_stats = SportStrategy.for(sport_name).collect_stats(events, params[:position])\n\n if params[:market_id] == 'undefined'\n bid_ids = []\n else\n bid_ids = current_bid_ids(params[:market_id], self.id, current_user.id) if current_user\n bid_ids ||= []\n end\n\n data = []\n total_stats.each do |k, v|\n if games.last.sport.name == 'MLB'\n ip_per_game = 9.0\n #last_year_points = last_year_stats[k] || 0.to_d\n #this_year_points = (this_year_stats[k] || 0).to_d/this_year_ids.count if this_year_ids.count != 0\n if k == 'Era (earned run avg)'.to_sym\n recent = ip_per_game * this_year_stats[k].to_f/this_year_stats[:'Inning Pitched'].to_f\n history_val = if self.total_games.zero?\n recent\n else\n era = (last_year_stats[k].to_f*self.total_games + this_year_stats[k].to_f)\n ip = this_year_stats[:'Inning Pitched'].to_f + last_year_stats[:'Inning Pitched'].to_f*self.total_games\n ip_per_game * era/ip\n end\n else\n history_val = ((last_year_stats[k] || 0.to_d)*self.total_games + (this_year_stats[k] || 0).to_d)/(this_year_ids.count + self.total_games)\n #history = last_year != 0 ? [last_year * (last_year - 2 * this_year)/last_year + this_year, 0].max : this_year\n recent = (recent_stats[k] || 0.to_d)/recent_ids.count if recent_ids.count != 0\n recent ||= 0\n end\n\n if last_year_ids.count == 0\n Honeybadger.notify(\n :error_class => \"NoLastYearMLBStats\",\n :error_message => \"NoLastYearMLBStats: #{Player.where(stats_id: params[:player_ids]).name} #{self.name}\",\n :parameters => params\n )\n end\n\n if this_year_stats[:'Inning Pitched'].to_i > 15 or self.stat_events.where(:activity => 'At Bats').select { |st| st.game.game_time.year == Time.now.year }.size > 50\n koef = 0.2\n else\n # batter\n if (self.positions.first.try(:position) =~ /(C|1B|DH|2B|3B|SS|OF)/).present?\n koef = 0.2*(self.stat_events.where(:activity => 'At Bats').select { |st| st.game.game_time.year == Time.now.year }.size/50.0)\n else\n koef = 0.2*(this_year_stats[:'Inning Pitched'].to_i/15.0)\n end\n end\n\n value = koef.to_d * recent.to_f + (1.0 - koef).to_d * history_val.to_f\n\n value = this_year_stats[k].to_f/this_year_ids.count if k != 'Era (earned run avg)'.to_sym && (self.legionnaire? || self.total_games.zero?)\n return value if ret_fp && k == 'Fantasy Points'.to_sym\n else\n value = v.to_d / BigDecimal.new(played_games_ids.count)\n value = value * 0.7 + (recent_stats[k] || 0.to_d)/recent_ids.count * 0.3\n end\n\n value = value.round(2)\n next if value == 0\n\n bid_less = false\n bid_more = false\n if bid_ids.any?\n less = EventPrediction.where(event_type: k.to_s, diff: 'less', individual_prediction_id: bid_ids).count\n more = EventPrediction.where(event_type: k.to_s, diff: 'more', individual_prediction_id: bid_ids).count\n value = with_formula_value(value, bid_ids.count, more, less)\n bid_less = true if less != 0\n bid_more = true if more != 0\n end\n\n less_pt = IndividualPrediction.get_pt_value(value, 'less')\n more_pt = IndividualPrediction.get_pt_value(value, 'more')\n\n data << { name: k, value: value, bid_less: bid_less, bid_more: bid_more, less_pt: less_pt, more_pt: more_pt }\n end\n\n adjust_wins(data, this_year_stats)\n end", "def average_calories\n calories = self.desserts.map {|dessert| dessert.calories}\n length = calories.length\n calories.sum.to_f / length.to_f\n end", "def avg_shots_per_kill\n @avg_shots_per_kill = @shots.to_f / @kills if @avg_shots_per_kill.nil?\n\n @avg_shots_per_kill\n end", "def average_test(limit)\n (0..15).each do |skill|\n gamecount = 0\n pintotal = 0\n minscore = 300\n maxscore = 0\n\n until gamecount == limit\n newgame\n @players << skill\n reset_arrays\n playgame\n gamecount += 1\n pintotal += @game_scores[0][-1]\n \n minscore = @game_scores[0][-1] if @game_scores[0][-1] < minscore\n maxscore = @game_scores[0][-1] if @game_scores[0][-1] > maxscore\n end\n\n print \"#{skill}\\t#{gamecount}\\tavg\"\n print \"#{(pintotal / gamecount)}\".rjust(4), \"#{minscore}/#{maxscore}\".rjust(9), \"\\n\"\n puts\n end\nend", "def average_calories\n total = 0\n self.desserts.each do |dessert|\n total + dessert.calories / dessert.ingreidents.length\n end\n total\n end", "def determine_winner game\n winner = game.max_by {|team| team[:score]}\n team_standings = get_team_by_name(winner)\n team_standings[:winnings] += 3\nend", "def total_team_score(teams_id)\n total_score = 0\n @league_data.each do\n |team| \n # binding.pry\n if team.home_team_id == teams_id\n total_score += team.home_team_score\n elsif team.away_team_id == teams_id\n total_score += team.away_team_score\n end\n end\n return total_score\n end", "def test_count_of_games_by_season\n\n expected = {\n \"20122013\"=>806,\n \"20162017\"=>1317,\n \"20142015\"=>1319,\n \"20152016\"=>1321,\n \"20132014\"=>1323,\n \"20172018\"=>1355\n }\n assert_equal expected, @stat_tracker.count_of_games_by_season\n\n end", "def num_points_scored (sportsman)\ngame_hash\nscores = 0\n game_hash.each do |team_position, team_data|\n team_data.each do | player_name, information|\n # binding.pry\n if player_name == :players \n information.each do |name, numbers|\n #binding.pry\n if name == sportsman \n numbers.each do |key, value|\n #binding.pry\n if key == :points\n #binding.pry\n return scores = value.to_i\n #binding.pry\n end\n end\n end\n end\n end\n end\n end \n #return scores\n end", "def score\n total = 0\n achievements.each do |a|\n total += a.task.score\n end\n total\n end", "def plays_yards_average(stats_xml)\n {\n plays: stats_xml[:plays].to_i,\n yards: stats_xml[:yds].to_f,\n average: stats_xml[:avg].to_f,\n }\n end", "def retrieve_season_hall_of_fame\n seasons_hall_of_fame = []\n get_involved_teams unless @involved_teams\n\n @involved_teams.each do |team|\n team_placement = {}\n team_placement[:team] = team\n %w[first_place second_place third_place].each_with_index do |rank, index|\n placement = index + 1\n team_placement[rank.to_sym] = team.computed_season_ranking.joins(:season).where(\"seasons.season_type_id = #{@season_type.id} AND computed_season_rankings.rank = #{placement}\").count\n end\n seasons_hall_of_fame << team_placement\n end\n seasons_hall_of_fame.sort { |p, n| (n[:first_place] * 10_000 + n[:second_place] * 100 + n[:third_place]) <=> (p[:first_place] * 10_000 + p[:second_place] * 100 + p[:third_place]) }\n end", "def lowest_total_score\n total_game_scores = games.map { |game| game.home_goals + game.away_goals}\n total_game_scores.min\n end", "def worst_defense\n teams_total_goals_allowed = total_goals_allowed_helper\n teams_total_games = total_games_helper\n\n worst_team_goals_allowed_avg = 0\n worst_defense_team_id = 0\n this_team_goals_allowed_avg = 0\n\n teams_total_games.each do |games_key, games_value|\n\n teams_total_goals_allowed.each do |goals_key, goals_value|\n if goals_key == games_key\n this_team_goals_allowed_avg = (goals_value / games_value.to_f)\n if this_team_goals_allowed_avg > worst_team_goals_allowed_avg\n worst_team_goals_allowed_avg = this_team_goals_allowed_avg\n worst_defense_team_id = games_key\n end\n end\n end\n end\n team_with_worst_defense = team_name_finder_helper(worst_defense_team_id)\n\n team_with_worst_defense\n end", "def gross_for_director(director_data)\n sum = 0\n\t\n\tdirector_data[:movies].each do |movie|\n\t\tsum += movie[:worldwide_gross]\n\tend\n\t\n\treturn sum\nend", "def gross_for_director(director_data)\n total = 0\n movies = director_data[:movies]\n movies.length.times do |movie_idx|\n total+=movies[movie_idx][:worldwide_gross]\n end\n return total\nend", "def total_score\n plays.inject(0) { |sum, word| sum + Scoring.score(word) }\n end", "def its_a_tie game\n game.each do |team|\n team_standings = get_team_by_name(team)\n team_standings[:winnings] += 1\n end\nend", "def average_score(report_cycle)\n report_cycle_scores = report_cycle.scores.where(set_pupil: object)\n return 0 if report_cycle_scores.length < 1\n average = (report_cycle_scores.map(&:value).reduce(:+)) / (report_cycle_scores.length).to_f\n return average.round(1)\n end", "def games_played\n games.size\n end", "def games_played\n games.size\n end" ]
[ "0.8866286", "0.76044863", "0.7357629", "0.7340187", "0.7151395", "0.7151123", "0.709436", "0.7049922", "0.7022711", "0.70215654", "0.701866", "0.7007527", "0.7006993", "0.700472", "0.6991013", "0.6956978", "0.69391805", "0.69037896", "0.6882887", "0.6875325", "0.68327737", "0.6813233", "0.679033", "0.66983914", "0.66096675", "0.66047555", "0.6574395", "0.6573921", "0.6573921", "0.6573921", "0.6573921", "0.6573921", "0.6573921", "0.6573921", "0.6573921", "0.6573921", "0.6573921", "0.6573921", "0.6573921", "0.6569435", "0.6438162", "0.64323515", "0.6431185", "0.64179534", "0.64127517", "0.64096034", "0.63995653", "0.63636863", "0.63558567", "0.63507944", "0.6348979", "0.6347402", "0.63416946", "0.633933", "0.6328433", "0.63174295", "0.6307143", "0.62938625", "0.6273572", "0.6273016", "0.6260597", "0.62597096", "0.6250936", "0.6250936", "0.62446475", "0.6243616", "0.6236365", "0.6226481", "0.62134534", "0.6199861", "0.61844164", "0.61805266", "0.61805266", "0.6176335", "0.6176078", "0.61753994", "0.61753994", "0.61682343", "0.61643976", "0.6162466", "0.6160772", "0.6159875", "0.61445457", "0.613961", "0.6137237", "0.61300105", "0.61220163", "0.61206615", "0.61199635", "0.61143565", "0.6102207", "0.60963297", "0.6089237", "0.6084769", "0.60834396", "0.6079295", "0.6079245", "0.6072519", "0.6065632", "0.6065632" ]
0.79668844
1
returns a hash with season names as keys and average goals that season as a value
def average_goals_by_season goals_by_season = @games.group_by { |game| game.season.to_s } goals_by_season.each do |season, games| season_goals = games.map { |game| game.home_goals + game.away_goals }.sum goals_by_season[season] = (season_goals.to_f / games.count.to_f).round(2) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_average_age_for_season(data, season)\n age_total = 0\n num_of_contestants = 0\n data[season].each do |contestant_hash|\n age_total += (contestant_hash[\"age\"]).to_i\n num_of_contestants += 1\n end\n (age_total / num_of_contestants.to_f).round(0)\nend", "def get_average_age_for_season(data, season)\n age = 0\n num_of_ages = 0\n \n data[season].each do |season_hash|\n season_hash.each do |detail, info|\n if detail == \"age\"\n num_of_ages += 1 \n age += info.to_f\n end\n end\n end\n return (age/num_of_ages).round\nend", "def get_average_age_for_season(data, season)\n a = []; data[season].each { |c| a << c[\"age\"].to_f }; (a.reduce(:+) / a.count).round\nend", "def get_average_age_for_season(data, season)\n array_of_ages = []\n average = 0\n data.each do |season_in_hash, contestant_array|\n if season_in_hash.to_s == season\n contestant_array.each do |contestant|\n array_of_ages << contestant[\"age\"].to_f\n end \n average = (array_of_ages.inject{ |sum, num| sum + num }.to_f / array_of_ages.size).round\n end\n end\n average\nend", "def get_average_age_for_season(data, season)\n age = 0\n count = 0\n data[season].each do |contestant_data|\n age += (contestant_data[\"age\"]).to_f\n count += 1\n end\n (age / count).round\nend", "def get_average_age_for_season(data, season)\n count = 0\n age = 0\n data[season].each do |info|\n info.each do |k,v|\n if k == \"age\"\n count += 1\n age += v.to_f\n end\n end\n end\n avg_age = (age / count).round\n return avg_age\nend", "def get_average_age_for_season(data, season)\n data.each do |season_iteration, stats|\n if season_iteration == season\n total_ages = 0\n ages = stats.each do |age|\n total_ages = (total_ages + age[\"age\"].to_i).to_f\n end\n return (total_ages/ages.length).round\n end\n end\nend", "def test_average_goals_by_season\n\n expected = {\n \"20122013\"=>4.12,\n \"20162017\"=>4.23,\n \"20142015\"=>4.14,\n \"20152016\"=>4.16,\n \"20132014\"=>4.19,\n \"20172018\"=>4.44\n }\n assert_equal expected, @stat_tracker.average_goals_by_season\n\n end", "def get_average_age_for_season(data, season)\n age_array = []\n average = 0\n \n # Get ages\n data[season].each do |person| \n age_array << person[\"age\"].to_f\n end \n \n # Average and round ages\n average = (age_array.sum / age_array.length).round\nend", "def get_average_age_for_season(bachelortv, season)\n bachelortv.each do |season_number, contestant_data|\n if season == season_number\n contestant_data.each do |contestant|\n contestant[\"age\"].reduce(0) do |sum|\n sum += age\n end\n end\n end\n end\nend", "def season_summary(season, team_id)\n season = season.to_i\n team_id = team_id.to_i\n season_summary_hash(season, team_id)\n end", "def count_of_games_by_season\n games_by_season = @games.group_by { |game| game.season.to_s }\n games_by_season.each { |season, games| games_by_season[season] = games.count }\n end", "def gross_per_studio(collection)\n result = {}\n i = 0\n while i < collection.size do\n studio = collection[i][:studio]\n total_earnings = collection[i][:worldwide_gross]\n if !result[studio]\n result[studio] = total_earnings\n else\n result[studio] += total_earnings\n end\n i += 1\n end\n \n # GOAL: Given an AoH where each Hash is a movie, return a Hash that includes\n # the total worldwide_gross of all the movies from each studio.\n #\n # INPUT: (collection) AoH where each Hash represents a movie\n #\n # RETURN: Hash where the keys are the studios and the values are the sum of\n # all the worldwide_gross numbers for every movie in the input Hash\n \n result\nend", "def per_game_stats(season = nil)\n season_id = season ? season.id : Season.current.id\n StatLine.find_by_sql('SELECT AVG(fgm) as fgm, AVG(fga) as fga, coalesce(AVG(fgm)/nullif(AVG(fga), 0), 0) as fgpct, AVG(twom) as twom, AVG(twoa) as twoa, coalesce(AVG(twom)/nullif(AVG(twoa), 0), 0) as twopct, AVG(threem) as threem, AVG(threea) as threea, coalesce(AVG(threem)/nullif(AVG(threea), 0), 0) as threepct,' \\\n 'AVG(ftm) as ftm, AVG(fta) as fta, coalesce(AVG(ftm)/nullif(AVG(fta), 0), 0) as ftpct, AVG(orb) as orb, AVG(drb) as drb, AVG(trb) as trb, AVG(ast) as ast, AVG(stl) as stl, AVG(blk) as blk, AVG(fl) as fl, AVG(\"to\") as to,' \\\n 'AVG(points) as points, COUNT(*) as game_count, sums.league_id FROM (SELECT SUM(fgm) as fgm, SUM(fga) as fga, SUM(twom) as twom, SUM(twoa) as twoa, SUM(threem) as threem, SUM(threea) as threea,' \\\n 'SUM(ftm) as ftm, SUM(fta) as fta, SUM(orb) as orb, SUM(drb) as drb, SUM(trb) as trb, SUM(ast) as ast, SUM(stl) as stl, SUM(blk) as blk, SUM(fl) as fl, SUM(\"to\") as to,' \\\n \"SUM(points) as points, g.league_id as league_id FROM stat_lines sl INNER JOIN games g ON sl.game_id = g.id \" \\\n \"WHERE g.winner is not null AND (g.forfeit is null or not g.forfeit) AND (sl.dnp is null OR not sl.dnp) AND team_id = #{self.id} AND g.season_id = #{season_id} GROUP BY game_id, g.league_id) sums GROUP BY sums.league_id\")\n end", "def total_games_by_coach_by_season\n @total_games_by_coach = Hash.new{ |hash, key| hash[key] = 0}\n @by_season_game_team_objects.each do |game_by_season|\n @total_games_by_coach[game_by_season[\"head_coach\"]] += 1\n end\n end", "def batting_average(year: nil, team: nil)\n hits, at_bats = 0, 0\n\n seasonal_stats.each do |stat_line|\n year_match = stat_line.year == year || year == nil\n team_match = stat_line.team == team || team == nil\n if year_match && team_match\n hits += stat_line.hits\n at_bats += stat_line.at_bats\n end\n end\n\n if (at_bats != 0)\n return (hits.to_f / at_bats)\n else\n return 0.0\n end\n end", "def skater_stats(stats)\n skater_stats = Hash.new\n skater_stats[:seasons] = stats.seasons\nend", "def get_standings(games)\n teams = Hash.new\n games.each do |game|\n division_id = game.division_id\n home_team = game.home_team\n away_team = game.visiting_team\n if(teams[home_team.name].nil?)\n teams[home_team.name] = {:win => 0, :loss => 0, :tie => 0, :point=> 0}\n end\n\n if(teams[away_team.name].nil?)\n teams[away_team.name] = {:win => 0, :loss => 0, :tie => 0, :point => 0}\n end\n if(game.home_team_score && game.visiting_team_score)\n if(game.home_team_score > game.visiting_team_score)\n # home team won\n teams[home_team.name][:win] += 1\n teams[home_team.name][:point] += 5\n # visiting team loss\n teams[away_team.name][:loss] += 1\n elsif(game.home_team_score < game.visiting_team_score)\n # home team loss\n teams[home_team.name][:loss] += 1\n #visiting team won\n teams[away_team.name][:win] += 1\n teams[away_team.name][:point] += 5\n else\n # tie game\n teams[home_team.name][:tie] += 1\n teams[home_team.name][:point] += 1\n teams[away_team.name][:tie] += 1\n teams[away_team.name][:point] += 1\n end\n end\n end\n teams.each do |team, value|\n puts team\n total_games = value[:win] + value[:loss] + value[:tie]\n if total_games > 0 \n win_percentage = value[:win]/total_games.to_f\n else\n win_percentage = 0\n end \n value[:percentage] = win_percentage\n end\n teams_sorted = teams.sort_by{ |k, v| v[:point]}.reverse\n return teams_sorted\n end", "def matches_played_by_season(table_of_teams)\n matches_played = Hash.new { |hash, key| hash[key] = Hash.new(0) }\n\n table_of_teams.each do |table_row|\n matches_played[table_row['season']][table_row['team1']] += 1\n matches_played[table_row['season']][table_row['team2']] += 1\n end\n matches_played\nend", "def test_count_of_games_by_season\n\n expected = {\n \"20122013\"=>806,\n \"20162017\"=>1317,\n \"20142015\"=>1319,\n \"20152016\"=>1321,\n \"20132014\"=>1323,\n \"20172018\"=>1355\n }\n assert_equal expected, @stat_tracker.count_of_games_by_season\n\n end", "def gross_per_studio(collection)\n new_hash = {}\n counter = 0 \n while counter < collection.length do \n studio_name = collection[counter][:studio]\n ww_gross = collection[counter][:worldwide_gross]\n if !new_hash[studio_name]\n new_hash[studio_name] = ww_gross\n else \n new_hash[studio_name] += ww_gross\n end \n counter += 1 \nend\nreturn new_hash\nend", "def average_goals_per_game\n total_goals = @teams.map {|team| team.total_goals_scored}.sum\n total_games = @teams.map {|team| team.home_games}.sum\n (total_goals.to_f / total_games.to_f).round(2)\n end", "def power_play_goal_percentage(seasonasstring) # power_play info in game team stat\n #find list of all games in season given by arg\n #sum all power play goals\n #sum all power play oppertunities\n #divide line 146 and line 147\n #return total of above\n end", "def plays_yards_average(stats_xml)\n {\n plays: stats_xml[:plays].to_i,\n yards: stats_xml[:yds].to_f,\n average: stats_xml[:avg].to_f,\n }\n end", "def current_season\n season = nil\n\n { \n winter: [ 12, 1, 2 ], \n spring: [ 3, 4, 5 ], \n summer: [ 6, 7, 8 ],\n fall: [ 9, 10, 11 ]\n \n }.each do |key, range|\n if range.include? current_month\n season = key\n break\n end\n end\n\n season\n end", "def compute_avg_and_ranges_hash\n scores = {}\n contributors = self.contributors # assignment_teams\n if self.varying_rubrics_by_round?\n rounds = self.rounds_of_reviews\n for round in 1..rounds\n review_questionnaire_id = review_questionnaire_id(round)\n questions = Question.where(['questionnaire_id = ?', review_questionnaire_id])\n contributors.each do |contributor|\n assessments = ReviewResponseMap.get_assessments_for(contributor)\n assessments = assessments.reject {|assessment| assessment.round != round }\n scores[contributor.id] = {} if round == 1\n scores[contributor.id][round] = {}\n scores[contributor.id][round] = Answer.compute_scores(assessments, questions)\n end\n end\n else\n review_questionnaire_id = review_questionnaire_id()\n questions = Question.where(['questionnaire_id = ?', review_questionnaire_id])\n contributors.each do |contributor|\n assessments = ReviewResponseMap.get_assessments_for(contributor)\n scores[contributor.id] = {}\n scores[contributor.id] = Answer.compute_scores(assessments, questions)\n end\n end\n scores\n end", "def studios_totals(nds)\n a_o_a_movies_with_director_names = movies_with_directors_set(nds)\n movies_with_director_names = flatten_a_o_a(a_o_a_movies_with_director_names)\n return gross_per_studio(movies_with_director_names)\nend", "def studios_totals(nds)\n a_o_a_movies_with_director_names = movies_with_directors_set(nds)\n movies_with_director_names = flatten_a_o_a(a_o_a_movies_with_director_names)\n return gross_per_studio(movies_with_director_names)\nend", "def studios_totals(nds)\n a_o_a_movies_with_director_names = movies_with_directors_set(nds)\n movies_with_director_names = flatten_a_o_a(a_o_a_movies_with_director_names)\n return gross_per_studio(movies_with_director_names)\nend", "def studios_totals(nds)\n a_o_a_movies_with_director_names = movies_with_directors_set(nds)\n movies_with_director_names = flatten_a_o_a(a_o_a_movies_with_director_names)\n return gross_per_studio(movies_with_director_names)\nend", "def studios_totals(nds)\n a_o_a_movies_with_director_names = movies_with_directors_set(nds)\n movies_with_director_names = flatten_a_o_a(a_o_a_movies_with_director_names)\n return gross_per_studio(movies_with_director_names)\nend", "def studios_totals(nds)\n a_o_a_movies_with_director_names = movies_with_directors_set(nds)\n movies_with_director_names = flatten_a_o_a(a_o_a_movies_with_director_names)\n return gross_per_studio(movies_with_director_names)\nend", "def studios_totals(nds)\n a_o_a_movies_with_director_names = movies_with_directors_set(nds)\n movies_with_director_names = flatten_a_o_a(a_o_a_movies_with_director_names)\n return gross_per_studio(movies_with_director_names)\nend", "def studios_totals(nds)\n a_o_a_movies_with_director_names = movies_with_directors_set(nds)\n movies_with_director_names = flatten_a_o_a(a_o_a_movies_with_director_names)\n return gross_per_studio(movies_with_director_names)\nend", "def studios_totals(nds)\n a_o_a_movies_with_director_names = movies_with_directors_set(nds)\n movies_with_director_names = flatten_a_o_a(a_o_a_movies_with_director_names)\n return gross_per_studio(movies_with_director_names)\nend", "def studios_totals(nds)\n a_o_a_movies_with_director_names = movies_with_directors_set(nds)\n movies_with_director_names = flatten_a_o_a(a_o_a_movies_with_director_names)\n return gross_per_studio(movies_with_director_names)\nend", "def studios_totals(nds)\n a_o_a_movies_with_director_names = movies_with_directors_set(nds)\n movies_with_director_names = flatten_a_o_a(a_o_a_movies_with_director_names)\n return gross_per_studio(movies_with_director_names)\nend", "def studios_totals(nds)\n a_o_a_movies_with_director_names = movies_with_directors_set(nds)\n movies_with_director_names = flatten_a_o_a(a_o_a_movies_with_director_names)\n return gross_per_studio(movies_with_director_names)\nend", "def studios_totals(nds)\n a_o_a_movies_with_director_names = movies_with_directors_set(nds)\n movies_with_director_names = flatten_a_o_a(a_o_a_movies_with_director_names)\n return gross_per_studio(movies_with_director_names)\nend", "def total_wins_by_season_by_team_id(passed_id)\n @by_team_id_game_objects.each do |game|\n if helper_for_win_count(passed_id, game)\n @total_wins_by_season[game[\"season\"]] += 1\n elsif helper_for_loss_count(passed_id, game)\n @total_wins_by_season[game[\"season\"]] += 0\n end\n end\n end", "def retrieve_season_hall_of_fame\n seasons_hall_of_fame = []\n get_involved_teams unless @involved_teams\n\n @involved_teams.each do |team|\n team_placement = {}\n team_placement[:team] = team\n %w[first_place second_place third_place].each_with_index do |rank, index|\n placement = index + 1\n team_placement[rank.to_sym] = team.computed_season_ranking.joins(:season).where(\"seasons.season_type_id = #{@season_type.id} AND computed_season_rankings.rank = #{placement}\").count\n end\n seasons_hall_of_fame << team_placement\n end\n seasons_hall_of_fame.sort { |p, n| (n[:first_place] * 10_000 + n[:second_place] * 100 + n[:third_place]) <=> (p[:first_place] * 10_000 + p[:second_place] * 100 + p[:third_place]) }\n end", "def seasonal_summary(team_id)\n team_id = team_id.to_i\n seasonal_summary_hash(team_id)\n end", "def most_hits(seasonasstring) # shots in game team stats\n #get a list of all teams that played in that season\n #use above list to sum all shots across all games in season\n #find highest across list\n #return team name as found in 139\n end", "def score\n goals = self.match_events.select { |e| e.event_type == MatchEvent::EventType::GOAL }\n goals.reduce({away: 0, home: 0}) do |score, e|\n if e.event_author == MatchEvent::EventAuthor::HOME\n score[:home] += 1\n elsif e.event_author == MatchEvent::EventAuthor::AWAY\n score[:away] += 1\n end\n score\n end\n end", "def team_average\n # This version is implemented as a database AVG operation,\n # but it cannot be eager loaded so it results in an extra\n # database query for each project:\n #\n # avg = students_projects.select(:points).average :points\n # avg ? avg.round : 0\n\n # This version programmatically finds the average of the points:\n #self.reload\n no_of_students = self.students_projects.length\n return 0 if no_of_students == 0\n total = 0\n self.students_projects.each { |s| total += s.points }\n (total / no_of_students).round\n end", "def averages(grade_hash)\n\n averages = grade_hash.map do |key, value|\n total = 1\n sum = grade_hash[key].reduce do |sum, grade|\n total += 1\n sum += grade\n end\n avg = sum / total\n [key, avg]\n end\n\n averages.to_h\nend", "def goals_by_game_situation(season = nil)\n stats_request(\"goalsByGameSituation\", season).first\n end", "def total_score\n @all_games.map do |games|\n games[\"home_goals\"].to_i + games[\"away_goals\"].to_i\n end\n end", "def goals_favor_season(round, season = nil)\n count = 0\n matchs = find_matchs(round, season)\n\n matchs.each do |match|\n count += match.goals_favor(self) if match.finished?\n end\n\n count\n end", "def goals_against_season(round, season = nil)\n count = 0\n matchs = find_matchs(round, season)\n\n matchs.each do |match|\n count += match.goals_against(self) if match.finished?\n end\n\n count\n end", "def season_prepare\n ret = {\n :competitions_to_draw => League.all\n }\n \n ret[:competitions_to_draw]\n \n return ret\n end", "def most_accurate_team(seasonasstring) # shots in game team stats\n #get a list of all teams that played in that season - given by arg\n #use above list to sum all shots across all games in season\n #divide above by goals made across all games in season\n #find highest percentage\n #return team name as found in 127\n end", "def load_stats\n[\n {\n home_team: \"Jets\",\n away_team: \"Giants\",\n home_score: 21,\n away_score: 3\n },\n {\n home_team: \"Steelers\",\n away_team: \"Giants\",\n home_score: 21,\n away_score: 3\n },\n {\n home_team: \"Patriots\",\n away_team: \"Giants\",\n home_score: 21,\n away_score: 3\n },\n {\n home_team: \"Chargers\",\n away_team: \"Jets\",\n home_score: 13,\n away_score: 6\n },\n {\n home_team: \"Patriots\",\n away_team: \"Jets\",\n home_score: 13,\n away_score: 6\n },\n {\n home_team: \"Steelers\",\n away_team: \"Jets\",\n home_score: 3,\n away_score: 6\n },\n {\n home_team: \"Dolphins\",\n away_team: \"Jets\",\n home_score: 0,\n away_score: 3\n },\n{\n home_team: \"Browns\",\n away_team: \"Jets\",\n home_score: 0,\n away_score: 21\n },\n {\n home_team: \"Chargers\",\n away_team: \"Jets\",\n home_score: 7,\n away_score: 21\n },\n {\n home_team: \"Steelers\",\n away_team: \"Broncos\",\n home_score: 7,\n away_score: 13\n },\n {\n home_team: \"Patriots\",\n away_team: \"Broncos\",\n home_score: 7,\n away_score: 3\n },\n {\n home_team: \"Broncos\",\n away_team: \"Colts\",\n home_score: 3,\n away_score: 0\n },\n {\n home_team: \"Patriots\",\n away_team: \"Colts\",\n home_score: 11,\n away_score: 7\n },\n {\n home_team: \"Steelers\",\n away_team: \"Patriots\",\n home_score: 7,\n away_score: 21\n },\n {\n home_team: \"Steelers\",\n away_team: \"Colts\",\n home_score: 24,\n away_score: 21\n },\n {\n home_team: \"Steelers\",\n away_team: \"Colts\",\n home_score: 24,\n away_score: 21\n }\n]\nend", "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 get_all_seasons_by_status\n dateNow = DateTime.now.end_of_day\n all_seasons = Hash.new\n all_seasons[:upcoming] = Array.new\n all_seasons[:current] = Array.new\n all_seasons[:past] = Array.new\n seasons = Season.all\n\n seasons.each do |season|\n if (season.is_active) # current or upcoming season\n # going to assume if today is part the season end date that the league owner intentionally wanted the season to be current\n if (season.date_start <= dateNow)\n all_seasons[:current].push(season)\n else\n all_seasons[:upcoming].push(season)\n end\n else # past season\n all_seasons[:past].push(season)\n end\n end\n all_seasons\n end", "def assignment_average_score(grade_hash, assignment_num)\n a = []\n grade_hash.values.each { |dude| a.push(dude[assignment_num - 1]) }\n sum = a.sum\n average = sum/a.length\nend", "def mz_seasons\n age - System::JUNIOR_START_AGE\n end", "def season_with_fewest_games\n seasons = @games.group_by { |game| game.season }\n seasons.min_by { |season, games| games.count }.first\n end", "def flu_season\n event_display(\"It's flu season!\\n One player has been infected and needs some time to recuperate.\")\n {Game.last.players.sample.id.to_s =>\n {wellbeing: -100}\n }\n end", "def total_runs_by_teams(table_of_teams)\n hash_of_teams = Hash.new(0)\n table_of_teams.each do |table_row|\n hash_of_teams[table_row['batting_team']] += table_row['total_runs'].to_i\n end\n hash_of_teams['Rising Pune Supergiants'] += hash_of_teams['Rising Pune Supergiant']\n hash_of_teams.delete('Rising Pune Supergiant')\n hash_of_teams\nend", "def season\n @season ||= Season.find(@importer_hash.meeting.season_id)\n end", "def create_avg_age_hash(positions_hash)\n res = {}\n positions_hash.each_key do |position|\n num_players = positions_hash[position][\"total_players_at_position\"]\n total_age = positions_hash[position][\"total_age\"]\n res[position] = total_age / num_players\n end\n res\n end", "def initiateSeasonDivision( hash, season, division )\n\n hash[ season ] = {} unless hash.keys.include?( season )\n hash[ season ][ division ] = {} unless hash[ season ].keys.include?( division )\n\n return hash[ season ][ division ]\n\n end", "def best_season(id)\n wins = total_wins_per_team_per_season(id)\n totals = total_games_per_team_per_season(id)\n totals.each do |season, total|\n totals[season] = (wins[season] / total.to_f * 100).round(2)\n end\n totals.max_by {|k,v| v}[0]\n end", "def averages(grade_hash)\n student_average_array = grade_hash.map do |key, value|\n average = value.sum / value.length\n [key, average]\n end\n student_average_array.to_h\nend", "def average poss\n '%.2f' % ( @stat_data.map{|n| n[poss].to_f}.reduce(:+) / @stat_data.length )\n end", "def assignment_average_score(data, assignment)\n all_scores = data.values.map do |scores|\n scores[assignment - 1]\n end\n (all_scores.sum)/(all_scores.length)\nend", "def calculate!\n ov = self[:overall]\n ov[:high_night] = {}\n ov[:winners] = {}\n\n self.each do |player_id, st|\n next if player_id == :overall\n\n ## calculate computed stats for player\n st[:nights] += st[:dates].keys.length # if st[:nights] == 0\n st[:high_night] = st[:dates].values.max\n st[:gold_stars] = 1 if st[:nights] == 29\n st[:warps_per_game] = 1.0 * st[:warps] / st[:games] rescue 0\n st[:warps_per_night] = 1.0 * st[:warps] / st[:nights] rescue 0\n st[:games_per_night] = 1.0 * st[:games] / st[:nights] rescue 0\n st[:wins_per_night] = 1.0 * st[:wins] / st[:nights] rescue 0\n st[:wins_per_game] = 1.0 * st[:wins] / st[:games] rescue 0\n\n ## accumulate overall stats\n [:warps, :wins, :cfbs,\n :mystery_factors, :gold_stars]. each do |field|\n ov[field] += st[field]\n end\n [:wimps, :come_ons].each do |field|\n if st[field]\n ov[field] ||= 0\n ov[field] += st[field]\n end\n end\n # nights won calculation\n st[:dates].each do |date,warps|\n ov[:dates][date] += warps\n hnd = ov[:high_night][date] ||= {:players => [], :warps => 0}\n if hnd[:warps] < warps\n hnd[:players] = [player_id]\n hnd[:warps] = warps\n elsif hnd[:warps] == warps\n hnd[:players].push(player_id)\n end\n end\n end\n\n ## update overall computed stats\n st = self[:overall]\n ov[:games] = ov[:wins]\n ov[:nights] = ov[:dates].keys.length\n ov[:nights] = 29 if ov[:nights] == 0 ## provide sane default\n ov[:nights] = ov[:nights_real] if ov[:nights_real]\n ov[:warps_per_game] = 1.0 * ov[:warps] / ov[:games] rescue 0\n ov[:warps_per_night] = 1.0 * ov[:warps] / ov[:nights] rescue 0\n ov[:games_per_night] = 1.0 * ov[:games] / ov[:nights] rescue 0\n ov[:high_night].each do |date,h|\n h[:players].each {|p| self[p][:nights_won] += 1}\n end\n\n ## determine per-stat winners\n # fuck everyone but the top 50 OR those with 50+ warps\n # the 51 below is not a bug\n sorted_players = self.keys.sort{|a,b| self[b][:warps] <=> self[a][:warps]}\n fifty_plus = self.keys.select{|p| self[p][:warps] >= 50}\n eligible = (sorted_players[0..51] | fifty_plus).\n inject(Hash.new(false)) {|acc,p| acc.merge(p => true)}\n [:warps, :games, :nights, :wins, :nights_won, :cfbs,\n :come_ons, :wimps, :warps_per_game, :warps_per_night,\n :games_per_night, :wins_per_game, :high_night].each do |field|\n owf = ov[:winners][field] = {:players => [], :value => 0}\n self.each do |player, st|\n next if player == :overall\n next unless eligible[player]\n if st[field].to_f > owf[:value]\n owf[:players] = [player]\n owf[:value] = st[field]\n elsif st[field] == owf[:value]\n owf[:players].push(player)\n end\n end\n end\n\n ## mark per-stat winners\n ov[:winners].each do |field, win|\n win[:players].each do |player|\n self[player][:winner][field] = true\n end\n end\n\n self\n end", "def scrape_season\n doc = Nokogiri::HTML(open(url))\n \n seasonality_url = doc.search(\"#survival-guide ul li:nth-child(2) a\").attr(\"href\").text #get country weather url\n weather_pg = Nokogiri::HTML(open(seasonality_url))\n \n #get high, low, and best time to visit information\n @high_season = weather_pg.search(\"div.card--page__content p:nth-child(1)\").text\n @low_season = weather_pg.search(\"div.card--page__content p:nth-child(5)\").first.text\n\n shoulder_season = weather_pg.search(\"div.card--page__content p:nth-child(3)\").first.text\n @best_visit_season = \"Best time to visit \" + shoulder_season[16..-1]\n end", "def assignment_average_score(grade_hash, assignment_num)\n assignment = grade_hash.map do |key, value|\n value[assignment_num - 1]\n end\n\n sum = assignment.reduce do |sum, x|\n sum += x\n end\n\n sum / assignment.length\nend", "def total_medals_per_team(olympic_data)\n\n team_medals_hash = {}\n\n olympic_data.each do |data|\n\n if team_medals_hash.key?(data[\"Team\"])\n if [\"Gold\", \"Silver\", \"Bronze\"].include?(data[\"Medal\"]) #SAME TEAM, MEDAL\n team_medals_hash[data[\"Team\"]] += 1\n end\n else\n\n if [\"Gold\", \"Silver\", \"Bronze\"].include?(data[\"Medal\"]) # NEW TEAM, MEDAL\n team_medals_hash[data[\"Team\"]] = 1\n else\n team_medals_hash[data[\"Team\"]] = 0\n\n end\n end\n end\n return team_medals_hash\nend", "def fewest_hits(seasonasstring) # shots in game team stats\n #inverse of above\n end", "def assignment_average_score(grade_hash, assignment_num)\n grade_hash\n .map { |key, value| value[assignment_num -1] }\n .reduce(:+) / grade_hash.length\nend", "def averages(grade_hash)\n grade_hash.transform_values{|v| v.inject(:+)/v.length}\n # hash = {}\n # grade_hash.map do |name, grades|\n # score = 0\n # grades.each do |grade|\n # score += grade\n # end\n # average = score/grades.length\n # hash[name] = average\n # end\n # hash\n # sum = 0\n # grade_hash.each { |x| sum += x }\n # average = sum/grade_hash.length\nend", "def assignment_average_score(grade_hash, assignment_num)\n grade_hash\n .map {|key, value| value[assignment_num - 1]}\n .reduce(:+) / grade_hash.length\nend", "def assignment_average_score(grade_hash, assignment_score)\n sum = 0\n grade_hash.each do |key, value|\n sum += value[assignment_score - 1]\n end\n average = sum / grade_hash.keys.length\n average\nend", "def gross_for_director(director_data)\n \n result = {}\n movie_gross = 0\n movie_index = 0\n \n director_movies = director_data[:movies] # this is pointing to an array of hashes\n puts director_movies\n director_name = director_data[:name] # √\n \n while movie_index < director_movies.count do\n movie_gross += director_movies[movie_index][:worldwide_gross]\n movie_index +=1\n end\n \n movie_gross \nend", "def stats\n Stats.all.inject({}) do |acc_hash, keyval|\n key, val = keyval\n acc_hash.merge(key => val[self.name])\n end\n end", "def summary\n score = Hash.new 0\n\n masses.each do |hash, mass|\n sexps = hashes[hash]\n mass_per_file = mass.to_f / sexps.size\n sexps.each do |sexp|\n score[sexp.file] += mass_per_file\n end\n end\n\n score\n end", "def stats\n {\n 'Living souls' => souls.where(alive: true).count,\n 'Dead souls' => souls.where(alive: false).count,\n 'Free souls' => players.sum(:free_souls),\n 'Players' => players.count,\n 'Rocks' => souls.where(alive: true, role: 'rock').count,\n 'Papers' => souls.where(alive: true, role: 'paper').count,\n 'Scissors' => souls.where(alive: true, role: 'scissor').count,\n 'Giants' => souls.where(alive: true, role: ['rock giant', 'paper giant', 'scissors giant']).count,\n 'Dragons' => souls.where(alive: true, role: ['rock dragon', 'paper dragon', 'scissors dragon']).count,\n 'Average soul age' => souls.average(:age).to_i\n }\n end", "def mot_m_total(params = { season: Date.current.year })\n if params[:season]\n (mot_m_firsts.select { |x| x.match.season == params[:season] }.length * 3) + (mot_m_seconds.select { |x| x.match.season == params[:season] }.length * 2) + (mot_m_thirds.select { |x| x.match.season == params[:season] }.length * 1)\n else\n (mot_m_firsts.select { |x| x.match_id.in? [params[:match_id]].flatten }.length * 3) + (mot_m_seconds.select { |x| x.match_id.in? [params[:match_id]].flatten }.length * 2) + (mot_m_thirds.select { |x| x.match_id.in? [params[:match_id]].flatten }.length * 1)\n end\n end", "def starters_average\n total = self.players.starter.inject(0) {|result, element| result + element.average_qualities}\n return total / MIN_PLAYERS\n end", "def assignment_average_score(grade_hash, assignment_num)\n marks = assignment_scores(grade_hash, assignment_num)\n marks.sum / marks.length\nend", "def fetch_averages(player_id)\n url = \"http://sports.yahoo.com/nba/players/#{player_id}\"\n#game_html = Web.clean(File.open('file.html', 'r').read())\n puts \"Getting URL #{url}\"\n game_html = Web.fetch_clean(url)\n\n career_totals = game_html.scan(/table summary=\"Player Season Totals.*?<\\/table>/)\n return [] if career_totals.size() == 0\n career = career_totals.first.scan(/<tbody>.*?<\\/tbody>/).first\n rows = career.scan(/<tr>.*?<\\/tr>/)\n\n seasons = (rows.collect do |row|\n tds = row.scan(/<th.*?<\\/th>/) + row.scan(/<td.*?<\\/td>/)\n min = tds[3].remove_tags.split(':')\n\n games = tds[2].remove_tags.to_f\n\n # 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18\n # Year Team G Min FGM FGA 3P 3PA FT FTA OR DR Reb Ast TO Stl Blk PF Pts\n # don't want overall career averages\n tds.first.remove_tags == \"Totals\" ? [] :\n {\n 'player_id' => player_id,\n 'season' => tds[0].remove_tags,\n 'team' => tds[1].remove_tags.downcase,\n 'games' => games,\n 'min' => tds[3].remove_tags.to_f,\n 'fgm' => tds[4].remove_tags.to_f,\n 'fga' => tds[5].remove_tags.to_f,\n 'tpm' => tds[6].remove_tags.to_f,\n 'tpa' => tds[7].remove_tags.to_f,\n 'ftm' => tds[8].remove_tags.to_f,\n 'fta' => tds[9].remove_tags.to_f,\n 'off' => tds[10].remove_tags.to_f,\n 'def' => tds[11].remove_tags.to_f,\n 'reb' => tds[12].remove_tags.to_f,\n 'ast' => tds[13].remove_tags.to_f,\n 'turnovers' => tds[14].remove_tags.to_f,\n 'stl' => tds[15].remove_tags.to_f,\n 'blk' => tds[16].remove_tags.to_f,\n 'pf' => tds[17].remove_tags.to_f,\n 'pts' => tds[18].remove_tags.to_f,\n }\n end).flatten\n combine_seasons(seasons)\nend", "def stats(season = nil)\n stats_request(\"statsSingleSeason\", season).first\n end", "def assignment_average_score(grade_hash, assignment_num)\n sum = 0\n grade_hash.each do |key, value|\n sum += grade_hash[key][assignment_num - 1]\n end\n average = sum / grade_hash.length\nend", "def calculate_average(params, current_user, ret_fp = false)\n sport_name = self.sport.name\n played_games_ids = StatEvent.where(\"player_stats_id='#{params[:player_ids]}' AND quantity != 0\").\n pluck('DISTINCT game_stats_id')\n games = Game.where(stats_id: played_games_ids)\n last_year_ids = games.where(season_year: (Time.now.utc - 4).year - 1).map(&:stats_id).uniq\n this_year_ids = games.where(season_year: (Time.now.utc - 4).year).select { |i| i.stat_events.any? }.map(&:stats_id).uniq\n events = StatEvent.where(player_stats_id: params[:player_ids],\n game_stats_id: played_games_ids)\n if games.last and sport_name == 'MLB'\n recent_games = games.where(season_year: (Time.now.utc - 4).year).order(\"game_time DESC\").first(50)\n else\n recent_games = games.order(\"game_time DESC\").first(5)\n end\n recent_ids = recent_games.map(&:stats_id)\n recent_ids.uniq!\n recent_events = events.where(game_stats_id: recent_ids)\n last_year_events = events.where(game_stats_id: last_year_ids)\n this_year_events = events.where(game_stats_id: this_year_ids)\n recent_stats = SportStrategy.for(sport_name).collect_stats(recent_events, params[:position])\n last_year_stats = SportStrategy.for(sport_name).collect_stats(last_year_events, params[:position])\n this_year_stats = SportStrategy.for(sport_name).collect_stats(this_year_events, params[:position])\n total_stats = SportStrategy.for(sport_name).collect_stats(events, params[:position])\n\n if params[:market_id] == 'undefined'\n bid_ids = []\n else\n bid_ids = current_bid_ids(params[:market_id], self.id, current_user.id) if current_user\n bid_ids ||= []\n end\n\n data = []\n total_stats.each do |k, v|\n if games.last.sport.name == 'MLB'\n ip_per_game = 9.0\n #last_year_points = last_year_stats[k] || 0.to_d\n #this_year_points = (this_year_stats[k] || 0).to_d/this_year_ids.count if this_year_ids.count != 0\n if k == 'Era (earned run avg)'.to_sym\n recent = ip_per_game * this_year_stats[k].to_f/this_year_stats[:'Inning Pitched'].to_f\n history_val = if self.total_games.zero?\n recent\n else\n era = (last_year_stats[k].to_f*self.total_games + this_year_stats[k].to_f)\n ip = this_year_stats[:'Inning Pitched'].to_f + last_year_stats[:'Inning Pitched'].to_f*self.total_games\n ip_per_game * era/ip\n end\n else\n history_val = ((last_year_stats[k] || 0.to_d)*self.total_games + (this_year_stats[k] || 0).to_d)/(this_year_ids.count + self.total_games)\n #history = last_year != 0 ? [last_year * (last_year - 2 * this_year)/last_year + this_year, 0].max : this_year\n recent = (recent_stats[k] || 0.to_d)/recent_ids.count if recent_ids.count != 0\n recent ||= 0\n end\n\n if last_year_ids.count == 0\n Honeybadger.notify(\n :error_class => \"NoLastYearMLBStats\",\n :error_message => \"NoLastYearMLBStats: #{Player.where(stats_id: params[:player_ids]).name} #{self.name}\",\n :parameters => params\n )\n end\n\n if this_year_stats[:'Inning Pitched'].to_i > 15 or self.stat_events.where(:activity => 'At Bats').select { |st| st.game.game_time.year == Time.now.year }.size > 50\n koef = 0.2\n else\n # batter\n if (self.positions.first.try(:position) =~ /(C|1B|DH|2B|3B|SS|OF)/).present?\n koef = 0.2*(self.stat_events.where(:activity => 'At Bats').select { |st| st.game.game_time.year == Time.now.year }.size/50.0)\n else\n koef = 0.2*(this_year_stats[:'Inning Pitched'].to_i/15.0)\n end\n end\n\n value = koef.to_d * recent.to_f + (1.0 - koef).to_d * history_val.to_f\n\n value = this_year_stats[k].to_f/this_year_ids.count if k != 'Era (earned run avg)'.to_sym && (self.legionnaire? || self.total_games.zero?)\n return value if ret_fp && k == 'Fantasy Points'.to_sym\n else\n value = v.to_d / BigDecimal.new(played_games_ids.count)\n value = value * 0.7 + (recent_stats[k] || 0.to_d)/recent_ids.count * 0.3\n end\n\n value = value.round(2)\n next if value == 0\n\n bid_less = false\n bid_more = false\n if bid_ids.any?\n less = EventPrediction.where(event_type: k.to_s, diff: 'less', individual_prediction_id: bid_ids).count\n more = EventPrediction.where(event_type: k.to_s, diff: 'more', individual_prediction_id: bid_ids).count\n value = with_formula_value(value, bid_ids.count, more, less)\n bid_less = true if less != 0\n bid_more = true if more != 0\n end\n\n less_pt = IndividualPrediction.get_pt_value(value, 'less')\n more_pt = IndividualPrediction.get_pt_value(value, 'more')\n\n data << { name: k, value: value, bid_less: bid_less, bid_more: bid_more, less_pt: less_pt, more_pt: more_pt }\n end\n\n adjust_wins(data, this_year_stats)\n end", "def assignment_average_score(grade_hash, assignment_num)\n sum, n = 0, 0\n grade_hash.each do |k,v|\n n += 1\n sum += v[assignment_num-1]\n end\n return sum/n\nend", "def assignment_average_score(grade_hash, assignment_num)\n assignment_score = grade_hash.map do |key, value|\n value [assignment_num - 1]\n end\n total = assignment_score.reduce do |total, grade|\n total += grade\n end\n total / assignment_score.length\nend", "def calculate_average_stats(stats)\n # selling price for unsold securities\n stats[:selling_unsold_price] = quote.price * stats[:unsold_amount]\n # difference between selling and buying price of unsold securities\n stats[:selling_unsold_income_price] = stats[:selling_unsold_price] - stats[:buying_unsold_price]\n # average prices\n stats[:buying_unsold_average_price] =\n stats[:unsold_amount].zero? ? 0 : (stats[:buying_unsold_price].to_f / stats[:unsold_amount]).round(4)\n stats[:exchange_profit] =\n stats[:buying_unsold_price].zero? ? 0 : ((stats[:selling_unsold_income_price] / stats[:buying_unsold_price]) * 100).round(2)\n # dividents\n stats[:dividents_amount_price] = dividents_amount_price(quote, stats[:unsold_amount])\n stats\n end", "def points_season(round, season = nil)\n count = 0\n matchs = find_matchs(round, season)\n\n matchs.each do |match|\n if match.is_winner?(self) and match.finished?\n count += MatchGeneral::PT_WIN\n end\n if match.deal? and match.finished?\n count += MatchGeneral::PT_DEAL\n end\n end\n\n count\n end", "def least_accurate_team(seasonasstring) # shots in game team stats\n #inverse of above\n end", "def averages(grade_hash)\n# a_new_hash = my_hash.inject({}) { |h, (k, v)| h[k] = v.upcase; h }\naverages = grade_hash.inject({}) { |h, (k,v)| h[k] = v.reduce{|x,n| x += n}/v.length ; h}\nend", "def getMidSeasonStatistics()\n for player in @skater_data\n begin\n stats = JSON.parse((RestClient.get \"https://statsapi.web.nhl.com/api/v1/people/#{player[5]}/stats?stats=statsSingleSeason\"))[\"stats\"][0][\"splits\"][0][\"stat\"]\n gamesLeft = 82 - @games_played[player[player.length-1]]\n player[6] = ((player[6].to_f/82)*gamesLeft + stats[\"goals\"]).to_i\n player[7] = ((player[7].to_f/82)*gamesLeft + stats[\"assists\"]).to_i\n player[8] = ((player[8].to_f/82)*gamesLeft + stats[\"powerPlayPoints\"]).to_i\n player[9] = ((player[9].to_f/82)*gamesLeft + stats[\"plusMinus\"]).to_i\n player[10] = ((player[10].to_f/82)*gamesLeft + stats[\"shots\"]).to_i\n player[11] = ((player[11].to_f/82)*gamesLeft + stats[\"hits\"]).to_i\n rescue\n gamesLeft = 82 - @games_played[player[player.length-1]]\n player[6] = ((player[6].to_f/82)*gamesLeft).to_i\n player[7] = ((player[7].to_f/82)*gamesLeft).to_i\n player[8] = ((player[8].to_f/82)*gamesLeft).to_i\n player[9] = ((player[9].to_f/82)*gamesLeft).to_i\n player[10] = ((player[10].to_f/82)*gamesLeft).to_i\n player[11] = ((player[11].to_f/82)*gamesLeft).to_i\n end\n puts player\n end\n for goalie in @goalie_data\n begin\n stats = JSON.parse((RestClient.get \"https://statsapi.web.nhl.com/api/v1/people/#{goalie[5]}/stats?stats=statsSingleSeason\"))[\"stats\"][0][\"splits\"][0][\"stat\"]\n gamesLeft = 82 - @games_played[goalie[goalie.length-1]]\n goalie[6] = ((goalie[6].to_f/82)*gamesLeft + stats[\"gamesStarted\"]).to_i\n goalie[7] = ((goalie[7].to_f/82)*gamesLeft + stats[\"wins\"]).to_i\n goalie[9] = (((goalie[9].to_f)*gamesLeft + stats[\"savePercentage\"]*@games_played[goalie[13]])/82).round(4)\n goalie[11] = (((goalie[11].to_f)*gamesLeft + stats[\"goalAgainstAverage\"]*@games_played[goalie[13]])/82).round(4)\n goalie[12] = ((goalie[12].to_f/82)*gamesLeft + stats[\"shutouts\"]).to_i\n rescue\n gamesLeft = 82 - @games_played[goalie[goalie.length-1]]\n goalie[6] = ((goalie[6].to_f/82)*gamesLeft).to_i\n goalie[7] = ((goalie[7].to_f/82)*gamesLeft).to_i\n goalie[9] = ((goalie[9].to_f/82)*gamesLeft).to_i\n goalie[11] = ((goalie[11].to_f/82)*gamesLeft).to_i\n goalie[12] = ((goalie[12].to_f/82)*gamesLeft).to_i\n end\n puts goalie\n end\nend", "def gross_for_director(director_data)\n movie_index = 0 \n total_gross = 0\n while director_data[:movies][movie_index] do \n movie_hash = director_data[:movies][movie_index]\n total_gross += movie_hash[:worldwide_gross]\n movie_index += 1\n end \n total_gross\nend", "def goals_by_hoa_id_suite\n goals_by_away_id\n goals_by_home_id\n average_score_per_away_game_by_team_id\n average_score_per_home_game_by_team_id\n end", "def goals_by_hoa_id_suite\n goals_by_away_id\n goals_by_home_id\n average_score_per_away_game_by_team_id\n average_score_per_home_game_by_team_id\n end", "def drivers_average_ratings_hash(data_hash)\n each_driver_average_rating = {}\n data_hash.each do |driver, rides_array|\n sum_of_ratings = 0\n rides_array.each do |ride|\n sum_of_ratings += ride[:rating]\n end\n each_driver_average_rating[driver] = (sum_of_ratings / rides_array.length.to_f).round(1)\n end\n each_driver_average_rating\nend", "def yearly_play_chart_data\n self.yearly_play_data.map do |year, times_played|\n {name: year, plays: times_played}\n end\n end", "def lacrosse_scoring_average(sport, player)\n\t\tgoals = 0\n\t\tgames = sport.teams.find(player.team_id).gameschedules\n\n\t\tgames.each do |g|\n\t\t\tstat = g.lacrosstats.find_by(athlete_id: player.id)\n\t\t\tgoals += stat.lacross_scorings.count if stat.lacross_scorings.any?\n\t\tend\n\n\t\tif games > 0\n\t\t\treturn goals / games.count\n\t\telse\n\t\t\treturn 0.0\n\t\tend\n\tend" ]
[ "0.755202", "0.74871576", "0.74111605", "0.7379598", "0.73434645", "0.7338489", "0.73198545", "0.72864354", "0.714075", "0.6826755", "0.66681606", "0.6568482", "0.6498531", "0.6463916", "0.6439715", "0.6393833", "0.63890535", "0.635506", "0.63490826", "0.627884", "0.6264705", "0.623208", "0.6202423", "0.62013835", "0.6169449", "0.6159147", "0.61302763", "0.61302763", "0.61302763", "0.61302763", "0.61302763", "0.61302763", "0.61302763", "0.61302763", "0.61302763", "0.61302763", "0.61302763", "0.61302763", "0.6129809", "0.60986197", "0.6045635", "0.59970945", "0.59529704", "0.58834225", "0.58479553", "0.581872", "0.5818558", "0.5807099", "0.57900727", "0.5780203", "0.5779755", "0.5775674", "0.57342976", "0.57212454", "0.5714607", "0.57086676", "0.5705363", "0.5694007", "0.5685618", "0.56797355", "0.5678193", "0.5669965", "0.5662112", "0.56560767", "0.56552154", "0.5653529", "0.5649263", "0.5647508", "0.56433606", "0.5642969", "0.5631188", "0.5630844", "0.5620657", "0.5618872", "0.5614391", "0.5603281", "0.55962574", "0.55950344", "0.559434", "0.5590688", "0.559021", "0.5568395", "0.5568251", "0.55656594", "0.5565451", "0.5560034", "0.5558481", "0.55532354", "0.5547539", "0.5529433", "0.5527621", "0.5527145", "0.5526907", "0.5524952", "0.5519728", "0.5515287", "0.5515287", "0.5514286", "0.55095404", "0.550535" ]
0.8301376
0
returns total number of teams
def count_of_teams @teams.count end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def team_count\n @teams.length\n end", "def team_count\n @teams.length\n end", "def total_num_assignment_teams\n assignment_team_counts.inject(:+)\n end", "def size\n @teams.size\n end", "def wins\n wins = 0\n self.teams.each do |team|\n wins += team.games_won.length\n end\n wins\n end", "def num_rounds\n (Math.log(teams.size) / Math.log(2)).to_i\n end", "def get_total_games_played\n return games.size\n end", "def num_district_teams\n num_teams = 0\n novice_division = Division.find_by_name('District Novice')\n experienced_division = Division.find_by_name('District Experienced')\n teams.each do |team|\n if team.division == novice_division or team.division == experienced_division\n if team.team_registration.complete?\n num_teams += 1\n end\n end\n end\n num_teams\n end", "def get_total_games_played\n\t\treturn games.size\n\tend", "def team_member_count\n self.teams.count < TOTAL_TEAMS\n end", "def total_team_score(teams_id)\n total_score = 0\n @league_data.each do\n |team| \n # binding.pry\n if team.home_team_id == teams_id\n total_score += team.home_team_score\n elsif team.away_team_id == teams_id\n total_score += team.away_team_score\n end\n end\n return total_score\n end", "def total_rounds(teams_count)\n Math.log2(teams_count).ceil\n end", "def total_rounds(teams_count)\n Math.log2(teams_count).ceil\n end", "def team_player_count\n\t\tif team.players.size >= 5\n\t\t\terrors.add(:team, \"error, team already has 5 players\")\n\t\tend\n\tend", "def total_medals_per_team(olympic_data)\n counts = olympic_data.group_by{ |x| x[:\"Team\"] }.map{ |x,y| [x,y.count] }\n counts = Hash[counts]\n return counts\nend", "def team_size_vasilescu(pr, months_back)\n (committer_team(pr, months_back) + merger_team(pr, months_back)).uniq.size\n end", "def total_runs_by_teams(table_of_teams)\n hash_of_teams = Hash.new(0)\n table_of_teams.each do |table_row|\n hash_of_teams[table_row['batting_team']] += table_row['total_runs'].to_i\n end\n hash_of_teams['Rising Pune Supergiants'] += hash_of_teams['Rising Pune Supergiant']\n hash_of_teams.delete('Rising Pune Supergiant')\n hash_of_teams\nend", "def total_num_team_reviews\n team_review_counts.inject(:+)\n end", "def games_played\n games.size\n end", "def games_played\n games.size\n end", "def count_results\n team = Team.find_by_id( params[:id] )\n if team\n render( json: ( team.meeting_individual_results.count + team.meeting_relay_results.count ) )\n else\n render( json: 0 )\n end\n end", "def total_rounds(driver)\n Algorithm::SingleBracket.total_rounds(driver.seeded_teams.length)\n end", "def total_games_by_coach_by_season\n @total_games_by_coach = Hash.new{ |hash, key| hash[key] = 0}\n @by_season_game_team_objects.each do |game_by_season|\n @total_games_by_coach[game_by_season[\"head_coach\"]] += 1\n end\n end", "def total_points\n\n points = 0\n wattball_matches_as_team1.each do |match|\n points += match.points(1) || 0\n end\n\n wattball_matches_as_team2.each do |match|\n points += match.points(2) || 0\n end\n\n points\n end", "def count_results\n # TODO respond with xml, only if valid session, otherwise return nil\n team = Team.find_by_id( params[:id] )\n if team\n render json: ( team.meeting_individual_results.count + team.meeting_relay_results.count )\n else\n render json: 0\n end\n end", "def competitive_teams\n res = 0\n @teams.each { |team| res += 1 unless TeamLevel.is_primary?(team.team_level) }\n res\n end", "def total_workouts\n set_sport_by_user.count || 0\n end", "def total_point(team)\n team[:players].collect { |player| player[:points] }.sum\nend", "def matchup_count(season = 2015)\n r = Record.find_by(team_id: self.id, year: season)\n r.wins + r.losses + r.ties\n end", "def test_number_of_people_in_group\n group_size = @group2.people() #speak to instructor about output\n assert_equal(6, group_size.count)\n end", "def potential_teammate_count\n potential_teammate_count = 0\n ungrouped_users = []\n users = User.all\n \n users.each do |user|\n ungrouped_users << user if user.groups.empty?\n end\n \n ungrouped_users.each do |ungrouped_user|\n if self.has_compatible_meeting_time_with(ungrouped_user) and self.number_of_compatible_time_blocks_with(ungrouped_user.schedule) > 0\n potential_teammate_count += 1\n end\n end\n \n potential_teammate_count\n end", "def num_points_scored (player_name)\n game_hash.each do |place_name, team|\n \n team[:players].each do |player|\n \n if player[:player_name] == player_name\n return player[:points]\n end\n \n end\n \n end\n\n nba_match\nend", "def num_points_scored (player_name)\n game_hash.each do |place_name, team|\n \n team[:players].each do |player|\n \n if player[:player_name] == player_name\n return player[:points]\n end\n \n end\n \n end\nend", "def total_medals_per_team(olympic_data)\n\n teams_medals = get_all_olympic_athletes(olympic_data).group_by { |athlete| athlete[\"Team\"] }.map { |k, v| [k, v.size] }.to_h\n\n return ap teams_medals\nend", "def games_played\n self.results.to_a.count\n end", "def count_tickets\n tickets = self.tickets\n total_tickets = tickets.count\n return total_tickets\n end", "def num_points_scored(team_member)\n game_hash.each do |location, team_data|\n team_data.each do |attribute, data|\n # if attribute == :players\n next unless attribute == :players\n data.each do |player|\n return player[:points] if player[:player_name] == team_member\n end\n end\n end\nend", "def count_details\n team = Team.find_by_id( params[:id] )\n if team\n render(\n json: \"#{I18n.t('meeting.total_attended_meetings')}: \" +\n team.meetings.collect{|row| row.id}.uniq.size.to_s +\n \", #{I18n.t('meeting.total_results_short')}: \" +\n ( team.meeting_individual_results.count + team.meeting_relay_results.count ).to_s\n )\n else\n render( json: '' )\n end\n end", "def num_of_tickets()\n result = films()\n @number_of_tickets = result.count\n end", "def num_points_scored (name)\n gh=game_hash\n gh.each do |team, stats|\n stats[:players].each_key do |nameval|\n if (nameval==name)\n return gh[team][:players][nameval][:points]\n end\n end\n end\nend", "def on_team\n tweets = Tweet.select(\"text\").map{|tweet| tweet.text}\n players = Player.where(\"team_name = ?\", params[:team_name]).select(\"name\").map{|player| player.name}\n counts = Hash[*players.zip([0]*players.length).flatten]\n\n tweets.each do |tweet|\n players.each do |name, count|\n # Split name into first name and last name\n fragments = name.downcase.split\n first = fragments[0..-2].join(' ')\n last = fragments.last\n full = name.downcase\n if (tweet.downcase.include? first and tweet.downcase.include? last) or tweet.downcase.include? full\n counts[name] += 1\n end\n end\n end\n\n respond_to do |format|\n format.html # on_team.html.erb\n format.json { render json: counts.sort_by{|_key, value|}.reverse[0..9] }\n end\n end", "def total_score\n @all_games.map do |games|\n games[\"home_goals\"].to_i + games[\"away_goals\"].to_i\n end\n end", "def num_games win_condition\n total_games = 0\n @game_objects.each do |game|\n total_games += 1 if game_meets_win_cond?(win_condition, game)\n end \n total_games\n end", "def num_points_scored(name)\n game_hash.each do |team, attributes|\n game_hash[team][:players].each do |player, stats|\n if name == player \n return game_hash[team][:players][name][:points]\n end\n end\n end\nend", "def teams\n return team_1 + team_2;\n end", "def its_a_tie game\n game.each do |team|\n team_standings = get_team_by_name(team)\n team_standings[:winnings] += 1\n end\nend", "def group_size_count\n if plan_year.estimate_group_size?\n targeted_census_employees_participation.select(&:expected_to_enroll?).length\n else\n all_active_health_enrollments.length\n end\n end", "def count_meetings\n team = Team.find_by_id( params[:id] )\n if team\n render( json: team.meetings.collect{|row| row.id}.uniq.size )\n else\n render( json: 0 )\n end\n end", "def num_points_scored(players_name)\n game_hash.each do |place, team|\n team.each do |attr, data|\n if attr == :players\n data.each do |player|\n if player[:player_name] == players_name\n return player[:points]\n end\n end\n end\n end\n end\nend", "def num_points_scored(player_lookup) \n game_hash.each do |location, team_data|\n#return the number of points scored for that player\n team_data[:players].each do |player|\n if player[:player_name] == player_lookup\n return player[:points]\n end\n end\n end\nend", "def num_points_scored(name)\n game_hash.each do | team, team_data_hash |\n team_data_hash.each do | attribute, data |\n if attribute == :players\n data.each do | player, player_data_hash |\n if player == name\n return game_hash[team][attribute][player][:points]\n end\n end\n end\n end\n end\nend", "def count_meetings\n # TODO respond with xml, only if valid session, otherwise return nil\n team = Team.find_by_id( params[:id] )\n if team\n render json: team.meetings.collect{|row| row.id}.uniq.size\n else\n render json: 0\n end\n end", "def total_wins_by_season_by_team_id(passed_id)\n @by_team_id_game_objects.each do |game|\n if helper_for_win_count(passed_id, game)\n @total_wins_by_season[game[\"season\"]] += 1\n elsif helper_for_loss_count(passed_id, game)\n @total_wins_by_season[game[\"season\"]] += 0\n end\n end\n end", "def team_points\n return @total if @total\n # This version is implemented as a database sum operation,\n # but it cannot be eager loaded so it results in 5 more\n # database queries:\n #\n # students_projects.select(:points).sum :points\n\n # This version programmatically adds the points:\n total = 0\n students_projects.each { |s| total += s.points }\n @total = total\n total\n end", "def tokenizer_stats_teams_tot\n TokenExtractor.new(\n :teams_tot,\n /\\s{2}\\d/i,\n 10 # (max size)\n )\n end", "def number_of_monsters\n if team\n unless team.total_mosnters_count\n errors.add(:base, 'Reached the number of monsters for a team')\n end\n end\n end", "def player_numbers(teamName)\n teamSelect(teamName)[:players].collect do|name, stats|\n stats[:number]\n end\nend", "def num_points_scored (name)\n points_scored = 0\n game_hash.each do | team, details_hash |\n players_array = details_hash[:players]\n\n players_array.each do | player_details_hash |\n\n if player_details_hash[:player_name] == name\n points_scored = player_details_hash[:points]\n end\n end\n end\n points_scored\nend", "def num_points_scored(player)\n game_hash.each do |k, team|\n team[:players].each do |e|\n if e[:player_name] == player\n return e[:points]\n end\n end\n end\nend", "def update_tournament_count\n if self.tournament\n m_with_t = Match.where(\"tournament_id is not null\")\n num = m_with_t.map(&:games).flatten.map(&:runner_user).map(&:userid).uniq.size\n self.tournament.num_players = num\n self.tournament.save\n end\n end", "def num_points_scored(player_name)\npoints_scored = 0\ngame_hash.each do |location, team_data|\n team_data.each do |attribute, data|\n if attribute == :players\n data.each do |player, stats|\n if player == player_name\n points_scored = stats[:points]\n end\n end\n end\n end\nend\npoints_scored\nend", "def winning_team\n home_team_sum = 0\n away_team_sum = 0\n game_hash.each do |team, team_stats|\n if team_stats[:team_name] == \"Brooklyn Nets\"\n team_stats[:players].each do |player_stats|\n home_team_sum += player_stats[:points]\n end\n elsif team_stats[:team_name] == \"Charlotte Hornets\"\n team_stats[:players].each do |player_stats|\n away_team_sum += player_stats[:points]\n end\n end\n end\n if home_team_sum > away_team_sum\n game_hash[:home][:team_name]\n elsif home_team_sum < away_team_sum\n game_hash[:away][:team_name]\n end\nend", "def count_details\n # TODO respond with xml, only if valid session, otherwise return nil\n team = Team.find_by_id( params[:id] )\n if team\n render json: \"#{I18n.t('meeting.total_attended_meetings')}: \" +\n team.meetings.collect{|row| row.id}.uniq.size.to_s +\n \", #{I18n.t('meeting.total_results_short')}: \" +\n ( team.meeting_individual_results.count + team.meeting_relay_results.count ).to_s\n else\n render json: ''\n end\n end", "def num_points_scored(player_name)\n player_points = nil\n game_hash.each do |team, team_stats|\n team_stats[:players].each do |player_stats|\n if player_stats[:player_name] == player_name\n player_points = player_stats[:points]\n end\n end\n end\n player_points\nend", "def get_players_num\n\t\treturn @players.length\n\tend", "def player_numbers(team_name)\n team = all_team_info(team_name)\n team[:players].map do |player|\n player[:number]\n end\nend", "def participants_size\n participants.size\n end", "def num_points_scored(player_name)\n game_hash.each do |home_or_away, team_values|\n team_values[:players].each do |player|\n if player[:player_name] == player_name \n return player[:points]\n end\n end \n end \nend", "def num_points_scored(player_name)\n game_hash.each do |side, team|\n team.each do |specs, info|\n if specs == :players\n\n info.each do |player|\n if player[:player_name] == player_name\n return player[:points]\n end\n end\n end\n end\n end\nend", "def total\n #use group matches instead of numFound for grouped response\n if response[:numFound].nil? \n self[:grouped][blacklight_config['index']['group']]['matches'].to_s.to_i \n else \n response[:numFound].to_s.to_i\n end\n end", "def num_points_scored(player_name)\ngame_hash.values.each do |team|\n team[:players].each do |player|\n return player[:points] if player.has_value?(player_name)\n end\n end\nend", "def num_points_scored(player_name)\n game_hash.each do |location, team_data|\n team_data.each do |attribute, data|\n if attribute == :players\n if data.keys.include?(player_name)\n return data[player_name][:points]\n end\n end\n end\n end\nend", "def count_of_games_by_season\n games_by_season = @games.group_by { |game| game.season.to_s }\n games_by_season.each { |season, games| games_by_season[season] = games.count }\n end", "def numbers_of_planes\n\t\t@landed_planes.count \n\tend", "def num_points_scored(str)\n # get number of points for named player\n game_hash.values.map do |teams|\n if teams[:players].include?(str)\n teams[:players][str][:points]\n end\n end.compact.join.to_i\nend", "def num_points_scored(name)\n game_hash().each do |location, team_data|\n team_data[:players].each do |player_name, player_stat|\n if name == player_name\n return player_stat[:points]\n end\n end\n end\nend", "def num_points_scored(player_name)\n game_hash.each do |location, team_data|\n team_data[:players].each do |data_item, stats|\n if data_item == player_name\n return stats[:points]\n end\n end\n end\nend", "def size\n @players.size\n end", "def player_numbers(team_name)\n player_number = []\n game_hash.each do |place, team|\n if team[:team_name] == team_name \n team[:players].each do |player|\n player_number<< player[:number]\n end\n end\n end\n player_number\n end", "def number_of_members()\n return members().count\n end", "def num_points_scored(name)\n players = get_all_players\n find_player(players, name)[:points]\nend", "def num_participants\n self.participants.count\n end", "def num_participants\n self.participants.count\n end", "def num_points_scored(player_name)\n result = nil\n game_hash.each do |team, about|\n about[:players].each do |name, stats|\n if player_name == name\n result = stats[:points]\n end\n end\n end\n result\nend", "def num_groups\n\t\t\t@groups.length\n\t\tend", "def player_numbers(team)\n numbers = []\n game_hash.each do |location, team_data|\n if team_data[:team_name] == team\n team_data[:players].each do |player_name, stat|\n numbers << stat[:number]\n end\n end\n end\n return numbers\nend", "def num_points_scored(player)\n game_hash.each_value do |team|\n team[:players].each do |name, player_data|\n if name == player\n points = player_data[:points]\n return points\n end\n end\n end\nend", "def num_points_scored (player_name)\n points_scored = nil\n\n game_hash.each do |team, team_information_hash|\n players_array = team_information_hash[:players]\n players_array.each do |player_information_hash|\n if player_information_hash[:player_name] == player_name\n points_scored = player_information_hash[:points]\n end\n end\n end\n points_scored\nend", "def total_cards\n cards.count\n end", "def winning_team\n home_points = 0\n away_points = 0\n result = \"\"\n i = 0\n game_hash.each do |team, about|\n about[:players].each do |name , stats|\n if i == 0\n home_points += stats[:points]\n else\n away_points += stats[:points]\n end\n end\n i += 1\n end\n home_points > away_points ? result = game_hash[:home][:team_name] : result = game_hash[:away][:team_name]\nend", "def tbs_turn_count\n $game_troop.turn_count\n end", "def total_goals\n Score.joins(:player).where(players: { user_id: self.id }).count\n end", "def team_with_more_points(game)\n home_points = game[:home_team][:players].collect do |player|\n player[:stats][:points]\n end.inject {|sum, n| sum + n}\n away_points = game[:away_team][:players].collect do |player|\n player[:stats][:points]\n end.inject {|sum, n| sum + n}\n home_points > away_points ? game[:home_team][:team_name] : game[:away_team][:team_name]\nend", "def get_total_stat_boxes\n return @stats.length\n end", "def test_point_counter\n team = SportsTeam.new(\"Celtic\", [\"Hendrik Larsson\", \"Captain Football\", \"Some Guy\"], \"Mr. Manager\")\n team.point_counter(\"Win\")\n assert_equal(1, team.points)\n end", "def num_points_scored(name)\n game_hash.each do |place, team|\n\n team.each do | atribute , data|\n \n if atribute == :players\n data.each do |player|\n # binding.pry\n if player[:player_name ] == name\n return player[:points]\n end\n end\n end\n end\n end\nend", "def GamesForSecond(teams)\n return teams+1\nend", "def player_numbers(team_name)\n team_numbers = nil\n game_hash.map do |team, team_stats|\n if team_stats[:team_name] == team_name\n team_numbers = team_stats[:players].map do |player_stats|\n player_stats[:number]\n end\n end\n end\n team_numbers\nend", "def game_objects_count\n @game_objects.count\n end", "def num_points_scored(player_name)\n game_hash.each do |location, team_data|\n team_data[:players].each do |attributes|\n if attributes[:player_name] == player_name\n return attributes[:points]\n end\n end\n end\nend" ]
[ "0.8592525", "0.8592525", "0.8034738", "0.7829387", "0.761724", "0.7573287", "0.7515038", "0.75088435", "0.7387394", "0.7226305", "0.710069", "0.70098764", "0.70098764", "0.6994083", "0.69900537", "0.6964335", "0.69448733", "0.6931533", "0.6913846", "0.6913846", "0.689817", "0.68874985", "0.6862412", "0.6837719", "0.68237984", "0.6726421", "0.66168183", "0.65857124", "0.6567506", "0.6563698", "0.6554175", "0.65378803", "0.6514879", "0.6504433", "0.6504228", "0.6502034", "0.65002525", "0.6494725", "0.64921075", "0.64865905", "0.6478227", "0.64647794", "0.64602345", "0.64501446", "0.64400345", "0.6421753", "0.64175594", "0.640284", "0.63949424", "0.6386152", "0.6378866", "0.6372845", "0.6362859", "0.63618946", "0.6354593", "0.6333243", "0.6332711", "0.6323675", "0.6318209", "0.63007903", "0.6297817", "0.6290018", "0.6280745", "0.627588", "0.62719494", "0.6271546", "0.62709063", "0.6261282", "0.6260454", "0.6249458", "0.6247519", "0.6245394", "0.6241104", "0.6240563", "0.6237681", "0.6236018", "0.6222547", "0.6219954", "0.6219646", "0.62141174", "0.62020534", "0.62018293", "0.62018293", "0.6201494", "0.6200137", "0.6195926", "0.61959225", "0.619585", "0.6190216", "0.6189587", "0.618681", "0.6183457", "0.61832273", "0.6181211", "0.61806923", "0.6178676", "0.61785793", "0.6168364", "0.6163887", "0.61486894" ]
0.86259216
0
returns team with highest average number of goals
def best_offense @teams.max_by { |team| team.average_goals_scored }.team_name end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def worst_offense\n teams_total_goals = total_goals_helper\n teams_total_games = total_games_helper\n\n worst_team_goals_avg = 1000\n worst_offense_team_id = 0\n this_team_goals_avg = 0\n\n teams_total_games.each do |games_key, games_value|\n teams_total_goals.each do |goals_key, goals_value|\n if goals_key == games_key\n this_team_goals_avg = (goals_value / games_value.to_f)\n if this_team_goals_avg < worst_team_goals_avg\n worst_team_goals_avg = this_team_goals_avg\n worst_offense_team_id = games_key\n end\n end\n end\n end\n\n team_with_worst_offense = nil\n self.teams.each_value do |team_obj|\n if team_obj.team_id. == worst_offense_team_id\n team_with_worst_offense = team_obj.team_name\n end\n end\n team_with_worst_offense\n end", "def average_goals_per_game\n total_goals = @teams.map {|team| team.total_goals_scored}.sum\n total_games = @teams.map {|team| team.home_games}.sum\n (total_goals.to_f / total_games.to_f).round(2)\n end", "def highest_total_score\n total_goals.max\n end", "def highest_scoring_visitor\n @teams.max_by { |team| team.average_away_goals }.team_name\n end", "def most_goals_scored(team_id)\n team_id = team_id.to_i\n goals_per_game = @game_teams.map do |game|\n if game.team_id == team_id\n game.goals\n end\n end\n goals_per_game.compact.max\n end", "def worst_defense\n teams_total_goals_allowed = total_goals_allowed_helper\n teams_total_games = total_games_helper\n\n worst_team_goals_allowed_avg = 0\n worst_defense_team_id = 0\n this_team_goals_allowed_avg = 0\n\n teams_total_games.each do |games_key, games_value|\n\n teams_total_goals_allowed.each do |goals_key, goals_value|\n if goals_key == games_key\n this_team_goals_allowed_avg = (goals_value / games_value.to_f)\n if this_team_goals_allowed_avg > worst_team_goals_allowed_avg\n worst_team_goals_allowed_avg = this_team_goals_allowed_avg\n worst_defense_team_id = games_key\n end\n end\n end\n end\n team_with_worst_defense = team_name_finder_helper(worst_defense_team_id)\n\n team_with_worst_defense\n end", "def highest_scoring_home_team\n @teams.max_by { |team| team.average_home_goals }.team_name\n end", "def worst_offense\n @teams.min_by { |team| team.average_goals_scored }.team_name\n end", "def worst_defense\n @teams.max_by { |team| team.average_goals_allowed }.team_name\n end", "def best_defense\n teams_total_goals_allowed = total_goals_allowed_helper\n teams_total_games = total_games_helper\n\n best_team_goals_allowed_avg = 100\n best_defense_team_id = 0\n this_team_goals_allowed_avg = 0\n\n teams_total_games.each do |games_key, games_value|\n teams_total_goals_allowed.each do |goals_key, goals_value|\n if goals_key == games_key\n this_team_goals_allowed_avg = (goals_value / games_value.to_f)\n if this_team_goals_allowed_avg < best_team_goals_allowed_avg\n best_team_goals_allowed_avg = this_team_goals_allowed_avg\n best_defense_team_id = games_key\n end\n end\n end\n end\n\n team_with_best_defense = nil\n self.teams.each_value do |team_obj|\n if team_obj.team_id. == best_defense_team_id\n team_with_best_defense = team_obj.team_name\n end\n end\n team_with_best_defense\n end", "def winningest_team\n @teams.max_by { |team| team.total_win_percentage }.team_name\n end", "def fewest_goals_scored(team_id)\n team_id = team_id.to_i\n goals_per_game = @game_teams.map do |game|\n if game.team_id == team_id\n game.goals\n end\n end\n goals_per_game.compact.min\n end", "def most_accurate_team(seasonasstring) # shots in game team stats\n #get a list of all teams that played in that season - given by arg\n #use above list to sum all shots across all games in season\n #divide above by goals made across all games in season\n #find highest percentage\n #return team name as found in 127\n end", "def best_defense\n @teams.min_by { |team| team.average_goals_allowed }.team_name\n end", "def worst_loss(team_id)\n @games.map do |game|\n if game.away_team_id.to_s == team_id\n game.home_goals - game.away_goals\n elsif game.home_team_id.to_s == team_id\n game.away_goals - game.home_goals\n end\n end.compact.max\n end", "def biggest_blowout\n score_difference = games.map { |game| (game.home_goals - game.away_goals).abs}\n score_difference.max\n end", "def best_fans\n @teams.max_by { |team| team.home_minus_away_percentage }.team_name\n end", "def team_average\n # This version is implemented as a database AVG operation,\n # but it cannot be eager loaded so it results in an extra\n # database query for each project:\n #\n # avg = students_projects.select(:points).average :points\n # avg ? avg.round : 0\n\n # This version programmatically finds the average of the points:\n #self.reload\n no_of_students = self.students_projects.length\n return 0 if no_of_students == 0\n total = 0\n self.students_projects.each { |s| total += s.points }\n (total / no_of_students).round\n end", "def biggest_team_blowout(team_id)\n @games.map do |game|\n if game.away_team_id.to_s == team_id\n game.away_goals - game.home_goals\n elsif game.home_team_id.to_s == team_id\n game.home_goals - game.away_goals\n end\n end.compact.max\n end", "def winning_team\n self.teams.order('score DESC').first\n end", "def avg_of_toryo_turn_max\n s = lose_scope\n s = s.joins(:battle)\n s = s.where(Swars::Battle.arel_table[:final_key].eq(\"TORYO\"))\n if v = s.average(Swars::Battle.arel_table[:turn_max])\n v.to_i\n end\n end", "def goals_for(team)\n valid = ((team == self.home_team or team == self.away_team) and self.final)\n\n if (valid)\n if (self.home_team == team)\n return self.homeScore\n else\n return self.awayScore\n end\n else\n return 0\n end\n end", "def player_w_biggest_feet\n all_players[1].max_by { |stats| stats[:shoe] }\n end", "def average_goals_by_season\n goals_by_season = @games.group_by { |game| game.season.to_s }\n goals_by_season.each do |season, games|\n season_goals = games.map { |game| game.home_goals + game.away_goals }.sum\n goals_by_season[season] = (season_goals.to_f / games.count.to_f).round(2)\n end\n end", "def most_hits(seasonasstring) # shots in game team stats\n #get a list of all teams that played in that season\n #use above list to sum all shots across all games in season\n #find highest across list\n #return team name as found in 139\n end", "def most_points_scored\n max = nil\n name = nil \n game_hash.each do |team, team_values|\n team_values[:players].each do |player|\n if max == nil || player[:points] > max\n max = player[:points]\n name = player[:player_name]\n end\n end\n end\n name\nend", "def mostSteals\n players.max_by do|name, stats|\n stats[:steals]\n end\nend", "def winning_team\n final_scores = player_collection.reduce(home: 0, away: 0) { |teams_points, next_player|\n case \n when next_player[:location] === :away\n teams_points[:away] += next_player[:points];\n when next_player[:location] === :home\n teams_points[:home] += next_player[:points];\n end\n teams_points; \n }\n winner = final_scores.reduce { |highest_points, team_points| \n highest_points[1] > team_points[1] ? highest_points : team_points; \n }\n game_hash[winner[0]][:team_name]; \nend", "def lowest_scoring_visitor\n @teams.min_by { |team| team.average_away_goals }.team_name\n end", "def average_win_percentage(team_id)\n team_id = team_id.to_i\n team = @teams.select { |each_team| each_team.team_id == team_id }.first\n team.total_win_percentage.round(2)\n end", "def goals_against(team)\n valid = ((team == self.home_team or team == self.away_team) and self.final)\n\n if (valid)\n if (self.home_team == team)\n return self.awayScore\n else\n return self.homeScore\n end\n else\n return 0\n end\n end", "def total_team_score(teams_id)\n total_score = 0\n @league_data.each do\n |team| \n # binding.pry\n if team.home_team_id == teams_id\n total_score += team.home_team_score\n elsif team.away_team_id == teams_id\n total_score += team.away_team_score\n end\n end\n return total_score\n end", "def lowest_total_score\n total_game_scores = games.map { |game| game.home_goals + game.away_goals}\n total_game_scores.min\n end", "def lowest_scoring_home_team\n @teams.min_by { |team| team.average_home_goals }.team_name\n end", "def high_score\n if self.end_date < Date.today\n self.teams.max_by { |team| team.score }.score\n end\n end", "def best_season(team_id)\n team_id = team_id.to_i\n team = @teams.select { |each_team| each_team.team_id == team_id }.first\n team.season_win_percentages.max_by { |season, percentage| percentage }.first.to_s\n end", "def worst_season(team_id)\n team_id = team_id.to_i\n team = @teams.select { |each_team| each_team.team_id == team_id }.first\n team.season_win_percentages.min_by { |season, percentage| percentage }.first.to_s\n end", "def winning_team\n home_team_points = game_hash[:home][:players].sum { |e| e[:points] }\n away_team_points = game_hash[:away][:players].sum { |e| e[:points] }\n\n if home_team_points > away_team_points\n return game_hash[:home][:team_name]\n else\n return game_hash[:away][:team_name]\n end\nend", "def winning_team\n home_points = collection_by_prop(game_hash[:home], :points).reduce(0, :+)\n away_points = collection_by_prop(game_hash[:away], :points).reduce(0, :+)\n home_points > away_points ? game_hash[:home][:team_name] : game_hash[:away][:team_name]\n end", "def team_with_more_points(game)\n home_points = game[:home_team][:players].collect do |player|\n player[:stats][:points]\n end.inject {|sum, n| sum + n}\n away_points = game[:away_team][:players].collect do |player|\n player[:stats][:points]\n end.inject {|sum, n| sum + n}\n home_points > away_points ? game[:home_team][:team_name] : game[:away_team][:team_name]\nend", "def most_points_scored\n most_points = 0\n most_points_player = nil\n game_hash.each do |team, team_stats|\n team_stats[:players].each do |player_stats|\n if most_points < player_stats[:points]\n most_points = player_stats[:points]\n most_points_player = player_stats[:player_name]\n end\n end\n end\n most_points_player\nend", "def highest_total_score\n @game_manager.highest_total_score\n end", "def calculate_team_ranking_score(number_of_meetings = 2, number_of_bests = 3)\n team_ranking_results = []\n events = []\n if @badge.category_type.code != 'U25' &&\n @badge.meetings.distinct.count >= number_of_meetings\n get_results.each do |meeting_individual_result|\n next unless meeting_individual_result.get_scheduled_date.year - @swimmer.year_of_birth >= 25\n\n next if events.include?(meeting_individual_result.event_type.code)\n\n team_ranking_results << meeting_individual_result\n events << meeting_individual_result.event_type.code\n break if team_ranking_results.count == number_of_bests\n end\n end\n BestLimitedRankingDAO.new(team_ranking_results)\n end", "def winning_team\n home_team_sum = 0\n away_team_sum = 0\n game_hash.each do |team, team_stats|\n if team_stats[:team_name] == \"Brooklyn Nets\"\n team_stats[:players].each do |player_stats|\n home_team_sum += player_stats[:points]\n end\n elsif team_stats[:team_name] == \"Charlotte Hornets\"\n team_stats[:players].each do |player_stats|\n away_team_sum += player_stats[:points]\n end\n end\n end\n if home_team_sum > away_team_sum\n game_hash[:home][:team_name]\n elsif home_team_sum < away_team_sum\n game_hash[:away][:team_name]\n end\nend", "def most_points_scored\n points_scored = 0 # starting score to compare with players shoe sizes\n game_hash.each do |location, team_data| # iterates through each team\n players_array = team_data[:players] # finds the :players info in team_data and puts the players into players_array\n players_array.each do |player_name, data| # iterates through each player..\n if data[:points] > points_scored # if their points scored is greater than 0 (we set this earlier in the top of method)\n points_scored = data[:shoe] # take that players score and make it the new points_scored value\n end # this repeats (iterates) through all players until you don't have any more.. meaning the end result is\n end # the player with the highest score\n end\n return points_scored\nend", "def determine_winner game\n winner = game.max_by {|team| team[:score]}\n team_standings = get_team_by_name(winner)\n team_standings[:winnings] += 3\nend", "def most_steals \n num_steals = 0\n game_hash.each do |team,info|\n info.each do |team_info,team_data|\n if team_data.is_a? (Array) \n if team_info != :colors\n team_data.each do |player_index|\n if num_steals == 0 || player_index[:steals] > num_steals \n num_steals = player_index[:steals] \n end\n end\n end\n end\n end\n end\nnum_steals\nend", "def rank_top_teams # DO NOT USE THIS METHOD, outdated, slow\n @top_teams = {}\n @top_teams = Score.in_challenge(self.id).teams_in_all_divisions.limit(5).\n order(\"sum_points DESC, MAX(#{Score.table_name}.\n earned_at) DESC\").sum(:points) \n return @top_teams\n end", "def winning_team\n team_p = []\n team_n = []\n\n game_hash.each do | location, team_data|\n temp = 0\n team_data[:players].each do |p_name, stats|\n temp += stats[:points]\n end\n team_n << team_data[:team_name]\n team_p << temp\n end\n\n team_p[0] > team_p[1] ? team_n[0] : team_n[1]\n\nend", "def highest_player_score\n players.max_by{|player| player.score}.score\n end", "def winning_team\n home_score = 0\n away_score = 0\n game_hash[:home][:players].keys.each do |name|\n home_score += game_hash[:home][:players][name][:points]\n end\n game_hash[:away][:players].keys.each do |name|\n away_score += game_hash[:away][:players][name][:points]\n end\n home_score > away_score ? game_hash[:home][:team_name] : game_hash[:away][:team_name]\nend", "def biggest_surprise(season)\n season = season.to_i\n @teams.max_by{ |team| team.preseason_to_regular_increase[season] }.team_name\n end", "def big_shoe_rebounds\n max_shoe = 0 \n max_rebounds = 0 \n game_hash.each do |place, team|\n # team.each do |attribute, data|\n team[:players].each do |player|\n if player[:shoe] > max_shoe\n max_shoe = player[:shoe]\n max_rebounds = player[:rebounds]\n # if attribute == :players\n # data.each do |player|\n #this gives me the player hashes\n # data.max_by{|player| player[:shoe] }\n # data.max_by{|player| player[:shoe] }[:rebounds]\n # player.max_by{|player| player[:shoe] \n # player.max_by{|player| player[:shoe] }[:rebounds]\n end\n end\n end\n return max_rebounds\n end", "def teams_with_score_max(a_game)\n teams_with_score_max = {}\n game_teams_with_score_max = a_game.teams_with_score_max(a_game.game_teams)\n game_teams_with_score_max.each do |game_team_with_score_max|\n # find team instance matching game_team instance\n team_with_score_max = @teams[game_team_with_score_max.name.to_sym]\n teams_with_score_max[game_team_with_score_max.name.to_sym] = team_with_score_max\n end\n teams_with_score_max\n end", "def pri_tdef\n team_stats.opp_goals_per_game / team_stats.opp_avg_goals_against_per_game\n end", "def player_with_most_steals\n name = \"\"\n most_steals = 0\n\n game_hash.each do | team, details_hash |\n players_array = details_hash[:players]\n players_array.each do | player_details_hash |\n if player_details_hash[:steals] > most_steals\n most_steals = player_details_hash[:steals]\n name = player_details_hash[:player_name]\n end\n end\n end\n name\nend", "def biggestShoes\n players.max_by do|name, stats|\n stats[:shoe]\n end\nend", "def winning_team\n if homeTeamPoints.sum > awayTeamPoints.sum\n \"Brooklyn Nets\"\n else\n \"Charlotte Hornets\"\n end\nend", "def get_max_over(stat)\n max = 0\n $data_enemies.each { |enemy|\n next if enemy.nil?\n next if enemy.hidden_best\n next unless $game_party.known_enemy?(enemy.id)\n value = enemy.get_stat(stat)\n max = value if value > max\n }\n max\n end", "def most_points_scored\n most_points = 0\n player = \"\"\n game_hash.each do |k, team|\n team[:players].each do |e|\n if e[:points] > most_points\n most_points = e[:points]\n player = e[:player_name]\n end\n end\n end\n player\nend", "def most_points_scored\n stat_by_player = collect_stat_by_name(:points)\n player_with_max_stat = find_max_stat_by_player(stat_by_player)\n player_with_max_stat\nend", "def worst_fans\n teams_with_bad_fans = @teams.find_all { |team| team.home_minus_away_percentage.negative? }\n teams_with_bad_fans.map { |team| team.team_name }\n end", "def winning_scores\n high_score = scores.max{|score| score.total}.total\n scores.select {|score| score.total == high_score}\n end", "def most_points_scored\nbest_player = \"\"\npoints = 0\ngame_hash.each do |location, team_data|\n team_data[:players].each do |name, stats|\n if stats[:points] > points\n points = stats[:points]\n best_player= name\n end\n end\nend\nbest_player\nend", "def most_steals\r\n result={}\r\n game_hash.each do |k, v|\r\n v.each do| p, d|\r\n if p==:players\r\n d.each do |t, s|\r\n result[t]=s[:steals]\r\n end\r\n end\r\n end\r\n end \r\n result.max_by {|name, steal| steal}[0]\r\nend", "def most_steals(game)\nmax_steals = 0\nmax_steals_player = \"\"\ngame.each do |team, team_contents|\n team_contents[:roster].each do |player, player_contents| \n if player_contents[:steals] == max_steals\n max_steals_player = max_steals_player + \" and #{player_contents[:player_name]}\"\n elsif player_contents[:steals] > max_steals\n max_steals = player_contents[:steals]\n max_steals_player = player_contents[:player_name]\n end\n end\nend\nmax_steals_player\nend", "def get_standings(games)\n teams = Hash.new\n games.each do |game|\n division_id = game.division_id\n home_team = game.home_team\n away_team = game.visiting_team\n if(teams[home_team.name].nil?)\n teams[home_team.name] = {:win => 0, :loss => 0, :tie => 0, :point=> 0}\n end\n\n if(teams[away_team.name].nil?)\n teams[away_team.name] = {:win => 0, :loss => 0, :tie => 0, :point => 0}\n end\n if(game.home_team_score && game.visiting_team_score)\n if(game.home_team_score > game.visiting_team_score)\n # home team won\n teams[home_team.name][:win] += 1\n teams[home_team.name][:point] += 5\n # visiting team loss\n teams[away_team.name][:loss] += 1\n elsif(game.home_team_score < game.visiting_team_score)\n # home team loss\n teams[home_team.name][:loss] += 1\n #visiting team won\n teams[away_team.name][:win] += 1\n teams[away_team.name][:point] += 5\n else\n # tie game\n teams[home_team.name][:tie] += 1\n teams[home_team.name][:point] += 1\n teams[away_team.name][:tie] += 1\n teams[away_team.name][:point] += 1\n end\n end\n end\n teams.each do |team, value|\n puts team\n total_games = value[:win] + value[:loss] + value[:tie]\n if total_games > 0 \n win_percentage = value[:win]/total_games.to_f\n else\n win_percentage = 0\n end \n value[:percentage] = win_percentage\n end\n teams_sorted = teams.sort_by{ |k, v| v[:point]}.reverse\n return teams_sorted\n end", "def most_points(game)\n player_name_with_points = []\n game[:home_team][:players].each do |player_hash|\n player_name_with_points << {player_hash[:player_name] => player_hash[:stats][:points]}\n end\n game[:away_team][:players].each do |player_hash|\n player_name_with_points << {player_hash[:player_name] => player_hash[:stats][:points]}\n end\n player_most_points = {\"test\" => 0}\n player_name_with_points.each do |name_and_points_hash|\n player_most_points = name_and_points_hash if name_and_points_hash.values[0] > player_most_points.values[0]\n end\n player_most_points.keys[0]\nend", "def best_offense\n offense_suite\n best_offense_id = @average_goals_by_id.invert.max[1]\n @team_name_by_id[best_offense_id]\n end", "def total_score\n @all_games.map do |games|\n games[\"home_goals\"].to_i + games[\"away_goals\"].to_i\n end\n end", "def mostPoints\n players.max_by do|name, stats|\n stats[:points]\n end\nend", "def most_points_scored\n most_points_scored = 0\n player_with_the_most_points_scored = \"\"\n game_hash.each do |team,info|\n info.each do |team_info,team_data|\n if team_data.is_a? (Array) \n if team_info != :colors\n team_data.each do |player_index|\n if most_points_scored == 0 || player_index[:points] > most_points_scored \n most_points_scored = player_index[:points]\n player_with_the_most_points_scored = player_index[:player_name]\n end\n end\n end\n end\n end\n end\n player_with_the_most_points_scored\nend", "def most_popular_venue\n venues = @games.group_by { |game| game.venue}\n venues.max_by { |venue, games| games.count }.first\n end", "def most_points(game)\nmax_points = 0\nmax_points_player = \"\"\ngame.each do |team, team_contents|\n team_contents[:roster].each do |player, player_contents| \n if player_contents[:points] == max_points\n max_points_player = max_points_player + \" and #{player_contents[:player_name]}\"\n elsif player_contents[:points] > max_points\n max_points = player_contents[:points]\n max_points_player = player_contents[:player_name]\n end\n end\nend\nputs \"#{max_points_player} scored #{max_points}\"\nend", "def most_points_scored\n\tpoints_array = []\n\tgame_hash.each do |location, team_data|\n\t\tteam_data[:players].each do |attribute, data|\t\n\t\t\tdata.each do |type, amount|\n\t\t\t\tif type == :points\n\t\t\t\t\tpoints_array << amount\n\t\t\t\tend \n\t\t\tend\n\t\tend\n\tend\n\tgame_hash.each do |l, data|\n\t\tdata[:players].each do |a, d|\n\t\t\td.each do |t, amt|\n\t\t\t\tif t == :points && points_array.max == amt\n\t\t\t\t\treturn a\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend\nend", "def highest_score\n sort\n all.first.score\n end", "def test_average_goals_per_game\n\n assert_equal 4.22, @stat_tracker.average_goals_per_game\n end", "def best_score(a_of_g)\n best_score = a_of_g.flatten.return_objects_with(:attempts, 0).max_attribute(:adjusted_goodness)\n end", "def max_total_score\n review_criterions.collect{|c| c.max_score}.sum\n end", "def pri_toff\n team_stats.goals_per_game / team_stats.opp_avg_goals_per_game\n end", "def winning_team\n home_points = 0\n away_points = 0\n result = \"\"\n i = 0\n game_hash.each do |team, about|\n about[:players].each do |name , stats|\n if i == 0\n home_points += stats[:points]\n else\n away_points += stats[:points]\n end\n end\n i += 1\n end\n home_points > away_points ? result = game_hash[:home][:team_name] : result = game_hash[:away][:team_name]\nend", "def most_points_scored()\n points = 0\n result = \"\"\n\n game_hash.each do |side,team|\n team.each do |specs,info|\n if specs == :players\n info.each do |player|\n if player[:points] > points\n points = player[:points]\n result = player[:player_name]\n\n end\n end\n end\n end\n end\n result\nend", "def get_project_score(teamArr,proj_id)\n counter=0\n teamArr.each do |x|\n if (proj_id == @preferences_hash[x][:first]) then\n counter = counter+4\n elsif (proj_id == @preferences_hash[x][:second]) then\n counter = counter+2\n elsif (proj_id == @preferences_hash[x][:third]) then\n counter = counter+1\n else \n counter = counter-1\n end\n end\n return counter.to_f/teamArr.size \n #range of [-1, 4]\n end", "def total_score\n sum = self.games.sum{|game|game.points}\n sum.to_i / self.games.count\n end", "def find_best_score(total_per_player)\n best_score = 0\n winner = ''\n total_per_player.each do |player_name,total|\n\n if total > best_score\n best_score = total\n winner = player_name\n end\n end\n return winner\n end", "def most_points_scored\n points = 0\n result = \"\"\n game_hash.each do |team, about|\n about[:players].each do |name , stats|\n if points < stats[:points]\n points = stats[:points]\n result = name\n end\n end\n end\n result\nend", "def batting_average(year: nil, team: nil)\n hits, at_bats = 0, 0\n\n seasonal_stats.each do |stat_line|\n year_match = stat_line.year == year || year == nil\n team_match = stat_line.team == team || team == nil\n if year_match && team_match\n hits += stat_line.hits\n at_bats += stat_line.at_bats\n end\n end\n\n if (at_bats != 0)\n return (hits.to_f / at_bats)\n else\n return 0.0\n end\n end", "def calculate_score(team)\n scores.includes(:wattball_player).where(:wattball_players => {:team_id => team}).sum(:amount) \n end", "def big_shoe_rebounds\n\nhighest_rebounds = 0\nbiggest_shoe = 0\n\n game_hash.each do |location, team_info|\n game_hash.dig(location, :players).each do |player_name, stats|\n stats.each do |stat, number|\n if stat == :shoe\n if number > biggest_shoe\n biggest_shoe = number\n stats.each do |stat, number|\n if stat == :rebounds\n highest_rebounds = number\n end\n end\n end\n end\n end\n end\n end\n puts highest_rebounds\n return highest_rebounds\nend", "def percentage_visitor_wins\n visitor_wins = @teams.map { |team| team.away_wins }.sum\n visitor_games = @teams.map { |team| team.away_games }.sum\n (visitor_wins.to_f / visitor_games.to_f).round(2)\n end", "def percentage_home_wins\n home_wins = @teams.map { |team| team.home_wins }.sum\n home_games = @teams.map { |team| team.home_games }.sum\n (home_wins.to_f / home_games.to_f).round(2)\n end", "def calculate_final_score\n self.scores.average(:total_score)\n end", "def goals_against()\n\t self.as_regular_contestants.select{|c| c.opponent.score}.collect{|c| c.opponent.score}.inject{|gf, c| gf + c} || 0\n\tend", "def favorite_opponent(team_id)\n team_id = team_id.to_i\n team = @teams.select { |each_team| each_team.team_id == team_id }.first\n favorite_opponent_id = team.matchup_win_percentage.max_by{|each_team, percentage| percentage}.first\n @teams.select { |each_team| each_team.team_id == favorite_opponent_id }.first.team_name\n end", "def worst(num = nil)\n temp = @user.scores.group(:sentence).sum(:val).sort_by{|_,v| +v}\n filter_by_num(temp, num)\n end", "def big_shoe_rebounds_2\n\nhighest_rebounds = 0\nbiggest_shoe = 0\n\n\n game_hash.dig(:home, :players).each do |player_name, stats|\n stats.each do |stat, number|\n if stat == :shoe\n if number > biggest_shoe\n biggest_shoe = number\n stats.each do |stat, number|\n if stat == :rebounds\n highest_rebounds = number\n\n end\n end\n end\n end\n end\nend\n\n puts highest_rebounds\n return highest_rebounds\nend", "def personal_top_three\n scores.max([scores.length, 3].min)\n end", "def biggest_bust(seasonasstring)\n #get all teams in data\n #find all games played by team in season - given by arg\n #get subset of 95 where p is in season marker\n #count games won in subset on 95 / total games in subset on 95\n #get subset of 85 where r is in season marker\n #count games won in subset on 98 / total games in subset on 98\n #result of line 97 - line 99\n #find highest number\n #return team name of result of line 101\n end", "def biggest_shoe\r\n player_name= []\r\n game_hash.each do |team, data|\r\n data.each do |team_info, value|\r\n if team_info == \"players\".to_sym\r\n obj=value.max_by {|key, value| value[:shoe]}\r\n player_name<< obj.first\r\n end\r\n end\r\n end\r\n player_name.first\r\nend", "def winning_team\n nets = []\n hornets = []\n\n game_hash.values.each do |nets_stats|\n if nets_stats[:team_name] == \"Brooklyn Nets\"\n nets_stats[:players].each do |bk|\n nets << bk[:points]\n end\n end\n end\n\n game_hash.values.each do |hornets_stats|\n if hornets_stats[:team_name] == \"Charlotte Hornets\"\n hornets_stats[:players].each do |ch|\n hornets << ch[:points]\n end\n end\n end\n\n if nets.reduce(:+) > hornets.reduce(:+)\n return \"Brooklyn Nets\"\n else\n return \"Charlotte Hornets\"\n end\nend" ]
[ "0.7896064", "0.77971333", "0.7757615", "0.7737617", "0.77260804", "0.76853526", "0.76414925", "0.7635805", "0.76236326", "0.753786", "0.7494346", "0.74940646", "0.73139346", "0.73136693", "0.73004293", "0.72291195", "0.712955", "0.70123017", "0.6988422", "0.69180375", "0.6901607", "0.6897385", "0.6871205", "0.6863381", "0.68294245", "0.68284", "0.68251306", "0.67937636", "0.6792903", "0.67467654", "0.67412007", "0.6729876", "0.67155164", "0.66936105", "0.6674677", "0.66645193", "0.6661134", "0.66551185", "0.66477", "0.6644983", "0.6637618", "0.6628876", "0.662671", "0.66208756", "0.66100883", "0.6603549", "0.65818775", "0.6555664", "0.6541797", "0.6516528", "0.6504126", "0.64976513", "0.6490341", "0.6477928", "0.64672244", "0.6456467", "0.6439437", "0.6439396", "0.64137447", "0.64110196", "0.6406742", "0.6397596", "0.6393679", "0.6393336", "0.63921237", "0.63904727", "0.6389945", "0.6377109", "0.63767165", "0.6361302", "0.63586605", "0.6355767", "0.6355376", "0.63428843", "0.63377106", "0.63363886", "0.63268495", "0.63236725", "0.6313702", "0.6304907", "0.6301145", "0.62999743", "0.6292927", "0.6285098", "0.6283302", "0.6270431", "0.6266979", "0.6265289", "0.6263062", "0.6260974", "0.62599295", "0.6259367", "0.62504524", "0.624976", "0.6233414", "0.6211988", "0.6210254", "0.62063795", "0.62004733", "0.6199599" ]
0.7686035
5
returns team with lowest average number of goals
def worst_offense @teams.min_by { |team| team.average_goals_scored }.team_name end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def average_goals_per_game\n total_goals = @teams.map {|team| team.total_goals_scored}.sum\n total_games = @teams.map {|team| team.home_games}.sum\n (total_goals.to_f / total_games.to_f).round(2)\n end", "def fewest_goals_scored(team_id)\n team_id = team_id.to_i\n goals_per_game = @game_teams.map do |game|\n if game.team_id == team_id\n game.goals\n end\n end\n goals_per_game.compact.min\n end", "def lowest_total_score\n total_game_scores = games.map { |game| game.home_goals + game.away_goals}\n total_game_scores.min\n end", "def lowest_scoring_visitor\n @teams.min_by { |team| team.average_away_goals }.team_name\n end", "def lowest_scoring_home_team\n @teams.min_by { |team| team.average_home_goals }.team_name\n end", "def team_average\n # This version is implemented as a database AVG operation,\n # but it cannot be eager loaded so it results in an extra\n # database query for each project:\n #\n # avg = students_projects.select(:points).average :points\n # avg ? avg.round : 0\n\n # This version programmatically finds the average of the points:\n #self.reload\n no_of_students = self.students_projects.length\n return 0 if no_of_students == 0\n total = 0\n self.students_projects.each { |s| total += s.points }\n (total / no_of_students).round\n end", "def best_defense\n @teams.min_by { |team| team.average_goals_allowed }.team_name\n end", "def worst_offense\n teams_total_goals = total_goals_helper\n teams_total_games = total_games_helper\n\n worst_team_goals_avg = 1000\n worst_offense_team_id = 0\n this_team_goals_avg = 0\n\n teams_total_games.each do |games_key, games_value|\n teams_total_goals.each do |goals_key, goals_value|\n if goals_key == games_key\n this_team_goals_avg = (goals_value / games_value.to_f)\n if this_team_goals_avg < worst_team_goals_avg\n worst_team_goals_avg = this_team_goals_avg\n worst_offense_team_id = games_key\n end\n end\n end\n end\n\n team_with_worst_offense = nil\n self.teams.each_value do |team_obj|\n if team_obj.team_id. == worst_offense_team_id\n team_with_worst_offense = team_obj.team_name\n end\n end\n team_with_worst_offense\n end", "def average_goals_by_season\n goals_by_season = @games.group_by { |game| game.season.to_s }\n goals_by_season.each do |season, games|\n season_goals = games.map { |game| game.home_goals + game.away_goals }.sum\n goals_by_season[season] = (season_goals.to_f / games.count.to_f).round(2)\n end\n end", "def best_defense\n teams_total_goals_allowed = total_goals_allowed_helper\n teams_total_games = total_games_helper\n\n best_team_goals_allowed_avg = 100\n best_defense_team_id = 0\n this_team_goals_allowed_avg = 0\n\n teams_total_games.each do |games_key, games_value|\n teams_total_goals_allowed.each do |goals_key, goals_value|\n if goals_key == games_key\n this_team_goals_allowed_avg = (goals_value / games_value.to_f)\n if this_team_goals_allowed_avg < best_team_goals_allowed_avg\n best_team_goals_allowed_avg = this_team_goals_allowed_avg\n best_defense_team_id = games_key\n end\n end\n end\n end\n\n team_with_best_defense = nil\n self.teams.each_value do |team_obj|\n if team_obj.team_id. == best_defense_team_id\n team_with_best_defense = team_obj.team_name\n end\n end\n team_with_best_defense\n end", "def smallest_team\n self.teams.min{|t1,t2| t1.runners.size <=> t2.runners.size }\n end", "def worst_defense\n teams_total_goals_allowed = total_goals_allowed_helper\n teams_total_games = total_games_helper\n\n worst_team_goals_allowed_avg = 0\n worst_defense_team_id = 0\n this_team_goals_allowed_avg = 0\n\n teams_total_games.each do |games_key, games_value|\n\n teams_total_goals_allowed.each do |goals_key, goals_value|\n if goals_key == games_key\n this_team_goals_allowed_avg = (goals_value / games_value.to_f)\n if this_team_goals_allowed_avg > worst_team_goals_allowed_avg\n worst_team_goals_allowed_avg = this_team_goals_allowed_avg\n worst_defense_team_id = games_key\n end\n end\n end\n end\n team_with_worst_defense = team_name_finder_helper(worst_defense_team_id)\n\n team_with_worst_defense\n end", "def best_offense\n @teams.max_by { |team| team.average_goals_scored }.team_name\n end", "def pri_tdef\n team_stats.opp_goals_per_game / team_stats.opp_avg_goals_against_per_game\n end", "def average_win_percentage(team_id)\n team_id = team_id.to_i\n team = @teams.select { |each_team| each_team.team_id == team_id }.first\n team.total_win_percentage.round(2)\n end", "def winningest_team\n @teams.max_by { |team| team.total_win_percentage }.team_name\n end", "def goals_for(team)\n valid = ((team == self.home_team or team == self.away_team) and self.final)\n\n if (valid)\n if (self.home_team == team)\n return self.homeScore\n else\n return self.awayScore\n end\n else\n return 0\n end\n end", "def points_in_team(team)\r\n perfs = self.performances.where(team: team)\r\n perfs.map(&:points).inject(:+) / perfs.length\r\n end", "def most_accurate_team(seasonasstring) # shots in game team stats\n #get a list of all teams that played in that season - given by arg\n #use above list to sum all shots across all games in season\n #divide above by goals made across all games in season\n #find highest percentage\n #return team name as found in 127\n end", "def winning_team\n home_points = collection_by_prop(game_hash[:home], :points).reduce(0, :+)\n away_points = collection_by_prop(game_hash[:away], :points).reduce(0, :+)\n home_points > away_points ? game_hash[:home][:team_name] : game_hash[:away][:team_name]\n end", "def worst_season(team_id)\n team_id = team_id.to_i\n team = @teams.select { |each_team| each_team.team_id == team_id }.first\n team.season_win_percentages.min_by { |season, percentage| percentage }.first.to_s\n end", "def highest_scoring_home_team\n @teams.max_by { |team| team.average_home_goals }.team_name\n end", "def most_goals_scored(team_id)\n team_id = team_id.to_i\n goals_per_game = @game_teams.map do |game|\n if game.team_id == team_id\n game.goals\n end\n end\n goals_per_game.compact.max\n end", "def winning_team\n final_scores = player_collection.reduce(home: 0, away: 0) { |teams_points, next_player|\n case \n when next_player[:location] === :away\n teams_points[:away] += next_player[:points];\n when next_player[:location] === :home\n teams_points[:home] += next_player[:points];\n end\n teams_points; \n }\n winner = final_scores.reduce { |highest_points, team_points| \n highest_points[1] > team_points[1] ? highest_points : team_points; \n }\n game_hash[winner[0]][:team_name]; \nend", "def highest_scoring_visitor\n @teams.max_by { |team| team.average_away_goals }.team_name\n end", "def worst_defense\n @teams.max_by { |team| team.average_goals_allowed }.team_name\n end", "def winning_team\n home_team_sum = 0\n away_team_sum = 0\n game_hash.each do |team, team_stats|\n if team_stats[:team_name] == \"Brooklyn Nets\"\n team_stats[:players].each do |player_stats|\n home_team_sum += player_stats[:points]\n end\n elsif team_stats[:team_name] == \"Charlotte Hornets\"\n team_stats[:players].each do |player_stats|\n away_team_sum += player_stats[:points]\n end\n end\n end\n if home_team_sum > away_team_sum\n game_hash[:home][:team_name]\n elsif home_team_sum < away_team_sum\n game_hash[:away][:team_name]\n end\nend", "def pri_toff\n team_stats.goals_per_game / team_stats.opp_avg_goals_per_game\n end", "def batting_average(year: nil, team: nil)\n hits, at_bats = 0, 0\n\n seasonal_stats.each do |stat_line|\n year_match = stat_line.year == year || year == nil\n team_match = stat_line.team == team || team == nil\n if year_match && team_match\n hits += stat_line.hits\n at_bats += stat_line.at_bats\n end\n end\n\n if (at_bats != 0)\n return (hits.to_f / at_bats)\n else\n return 0.0\n end\n end", "def winning_team\n team_p = []\n team_n = []\n\n game_hash.each do | location, team_data|\n temp = 0\n team_data[:players].each do |p_name, stats|\n temp += stats[:points]\n end\n team_n << team_data[:team_name]\n team_p << temp\n end\n\n team_p[0] > team_p[1] ? team_n[0] : team_n[1]\n\nend", "def percentage_home_wins\n home_wins = @teams.map { |team| team.home_wins }.sum\n home_games = @teams.map { |team| team.home_games }.sum\n (home_wins.to_f / home_games.to_f).round(2)\n end", "def winning_team\n self.teams.order('score DESC').first\n end", "def winning_team\n home_team_points = game_hash[:home][:players].sum { |e| e[:points] }\n away_team_points = game_hash[:away][:players].sum { |e| e[:points] }\n\n if home_team_points > away_team_points\n return game_hash[:home][:team_name]\n else\n return game_hash[:away][:team_name]\n end\nend", "def total_team_score(teams_id)\n total_score = 0\n @league_data.each do\n |team| \n # binding.pry\n if team.home_team_id == teams_id\n total_score += team.home_team_score\n elsif team.away_team_id == teams_id\n total_score += team.away_team_score\n end\n end\n return total_score\n end", "def highest_total_score\n total_goals.max\n end", "def starters_average\n total = self.players.starter.inject(0) {|result, element| result + element.average_qualities}\n return total / MIN_PLAYERS\n end", "def team_with_more_points(game)\n home_points = game[:home_team][:players].collect do |player|\n player[:stats][:points]\n end.inject {|sum, n| sum + n}\n away_points = game[:away_team][:players].collect do |player|\n player[:stats][:points]\n end.inject {|sum, n| sum + n}\n home_points > away_points ? game[:home_team][:team_name] : game[:away_team][:team_name]\nend", "def goals_against(team)\n valid = ((team == self.home_team or team == self.away_team) and self.final)\n\n if (valid)\n if (self.home_team == team)\n return self.awayScore\n else\n return self.homeScore\n end\n else\n return 0\n end\n end", "def calculate_score(team)\n scores.includes(:wattball_player).where(:wattball_players => {:team_id => team}).sum(:amount) \n end", "def get_standings(games)\n teams = Hash.new\n games.each do |game|\n division_id = game.division_id\n home_team = game.home_team\n away_team = game.visiting_team\n if(teams[home_team.name].nil?)\n teams[home_team.name] = {:win => 0, :loss => 0, :tie => 0, :point=> 0}\n end\n\n if(teams[away_team.name].nil?)\n teams[away_team.name] = {:win => 0, :loss => 0, :tie => 0, :point => 0}\n end\n if(game.home_team_score && game.visiting_team_score)\n if(game.home_team_score > game.visiting_team_score)\n # home team won\n teams[home_team.name][:win] += 1\n teams[home_team.name][:point] += 5\n # visiting team loss\n teams[away_team.name][:loss] += 1\n elsif(game.home_team_score < game.visiting_team_score)\n # home team loss\n teams[home_team.name][:loss] += 1\n #visiting team won\n teams[away_team.name][:win] += 1\n teams[away_team.name][:point] += 5\n else\n # tie game\n teams[home_team.name][:tie] += 1\n teams[home_team.name][:point] += 1\n teams[away_team.name][:tie] += 1\n teams[away_team.name][:point] += 1\n end\n end\n end\n teams.each do |team, value|\n puts team\n total_games = value[:win] + value[:loss] + value[:tie]\n if total_games > 0 \n win_percentage = value[:win]/total_games.to_f\n else\n win_percentage = 0\n end \n value[:percentage] = win_percentage\n end\n teams_sorted = teams.sort_by{ |k, v| v[:point]}.reverse\n return teams_sorted\n end", "def best_fans\n @teams.max_by { |team| team.home_minus_away_percentage }.team_name\n end", "def average_difficulty\n @p = live_problems\n if @p.size > 0\n @avg = @p.inject(0.0){|sum, i| sum + Difficulty.to_int(i.difficulty) } / @p.size\n else\n @avg = nil\n end\n end", "def rating\n position_sum = 0\n games = []\n number_of_teams = 0\n Participation.find_all_by_player_id(self.id).each do |participation|\n position_sum += participation.position\n games.push Game.find(participation.game_id)\n end\n\n games.each do |game|\n number_of_teams += game.number_of_teams\n end\n\n if position_sum == 0\n position_sum = number_of_teams.to_f-0.5\n end\n\n (1 - position_sum.to_f/number_of_teams).round 2\n end", "def winning_team\n if homeTeamPoints.sum > awayTeamPoints.sum\n \"Brooklyn Nets\"\n else\n \"Charlotte Hornets\"\n end\nend", "def get_project_score(teamArr,proj_id)\n counter=0\n teamArr.each do |x|\n if (proj_id == @preferences_hash[x][:first]) then\n counter = counter+4\n elsif (proj_id == @preferences_hash[x][:second]) then\n counter = counter+2\n elsif (proj_id == @preferences_hash[x][:third]) then\n counter = counter+1\n else \n counter = counter-1\n end\n end\n return counter.to_f/teamArr.size \n #range of [-1, 4]\n end", "def lacrosse_scoring_average(sport, player)\n\t\tgoals = 0\n\t\tgames = sport.teams.find(player.team_id).gameschedules\n\n\t\tgames.each do |g|\n\t\t\tstat = g.lacrosstats.find_by(athlete_id: player.id)\n\t\t\tgoals += stat.lacross_scorings.count if stat.lacross_scorings.any?\n\t\tend\n\n\t\tif games > 0\n\t\t\treturn goals / games.count\n\t\telse\n\t\t\treturn 0.0\n\t\tend\n\tend", "def winning_team\n home_score = 0\n away_score = 0\n game_hash[:home][:players].keys.each do |name|\n home_score += game_hash[:home][:players][name][:points]\n end\n game_hash[:away][:players].keys.each do |name|\n away_score += game_hash[:away][:players][name][:points]\n end\n home_score > away_score ? game_hash[:home][:team_name] : game_hash[:away][:team_name]\nend", "def goals_against()\n\t self.as_regular_contestants.select{|c| c.opponent.score}.collect{|c| c.opponent.score}.inject{|gf, c| gf + c} || 0\n\tend", "def least_popular_venue\n venues = @games.group_by { |game| game.venue}\n venues.min_by { |venue, games| games.count }.first\n end", "def best_season(team_id)\n team_id = team_id.to_i\n team = @teams.select { |each_team| each_team.team_id == team_id }.first\n team.season_win_percentages.max_by { |season, percentage| percentage }.first.to_s\n end", "def total_score\n sum = self.games.sum{|game|game.points}\n sum.to_i / self.games.count\n end", "def test_average_goals_per_game\n\n assert_equal 4.22, @stat_tracker.average_goals_per_game\n end", "def goals_for()\n\t self.as_regular_contestants.select{|c| c.score}.collect{|c| c.score}.inject{|gf, c| gf + c} || 0\n\tend", "def calculate_team_ranking_score(number_of_meetings = 2, number_of_bests = 3)\n team_ranking_results = []\n events = []\n if @badge.category_type.code != 'U25' &&\n @badge.meetings.distinct.count >= number_of_meetings\n get_results.each do |meeting_individual_result|\n next unless meeting_individual_result.get_scheduled_date.year - @swimmer.year_of_birth >= 25\n\n next if events.include?(meeting_individual_result.event_type.code)\n\n team_ranking_results << meeting_individual_result\n events << meeting_individual_result.event_type.code\n break if team_ranking_results.count == number_of_bests\n end\n end\n BestLimitedRankingDAO.new(team_ranking_results)\n end", "def percentage_visitor_wins\n visitor_wins = @teams.map { |team| team.away_wins }.sum\n visitor_games = @teams.map { |team| team.away_games }.sum\n (visitor_wins.to_f / visitor_games.to_f).round(2)\n end", "def season_with_fewest_games\n seasons = @games.group_by { |game| game.season }\n seasons.min_by { |season, games| games.count }.first\n end", "def total_score\n @all_games.map do |games|\n games[\"home_goals\"].to_i + games[\"away_goals\"].to_i\n end\n end", "def most_points_scored\n points_scored = 0 # starting score to compare with players shoe sizes\n game_hash.each do |location, team_data| # iterates through each team\n players_array = team_data[:players] # finds the :players info in team_data and puts the players into players_array\n players_array.each do |player_name, data| # iterates through each player..\n if data[:points] > points_scored # if their points scored is greater than 0 (we set this earlier in the top of method)\n points_scored = data[:shoe] # take that players score and make it the new points_scored value\n end # this repeats (iterates) through all players until you don't have any more.. meaning the end result is\n end # the player with the highest score\n end\n return points_scored\nend", "def avg_kills_per_shot\n 1 / avg_shots_per_kill\n end", "def avg_kills_per_shot\n 1 / avg_shots_per_kill\n end", "def worst_loss(team_id)\n @games.map do |game|\n if game.away_team_id.to_s == team_id\n game.home_goals - game.away_goals\n elsif game.home_team_id.to_s == team_id\n game.away_goals - game.home_goals\n end\n end.compact.max\n end", "def winning_team\n home_points = 0\n away_points = 0\n result = \"\"\n i = 0\n game_hash.each do |team, about|\n about[:players].each do |name , stats|\n if i == 0\n home_points += stats[:points]\n else\n away_points += stats[:points]\n end\n end\n i += 1\n end\n home_points > away_points ? result = game_hash[:home][:team_name] : result = game_hash[:away][:team_name]\nend", "def least_accurate_team(seasonasstring) # shots in game team stats\n #inverse of above\n end", "def rating_average(team, match)\n if match.ended?\n sum = 0; team.each { |u| sum += u['rating'].to_i }\n else\n sum = 0; team.users.each { |u| sum += u['rating'].to_i }\n end\n sum / 5\n end", "def most_points_scored\n most_points = 0\n most_points_player = nil\n game_hash.each do |team, team_stats|\n team_stats[:players].each do |player_stats|\n if most_points < player_stats[:points]\n most_points = player_stats[:points]\n most_points_player = player_stats[:player_name]\n end\n end\n end\n most_points_player\nend", "def average_player_age\n players.average(:age)\n end", "def best_score\n submissions.min(:score)\n end", "def determine_winner game\n winner = game.max_by {|team| team[:score]}\n team_standings = get_team_by_name(winner)\n team_standings[:winnings] += 3\nend", "def average_fitness\n total_fitness = 0\n @all_persons.each do |person|\n total_fitness += person.get_energy_level\n end\n if @all_persons.empty?\n return 0\n else\n total_fitness / @total_people\n end\n end", "def minimum_rounds(teams_count)\n Math.log2(teams_count).ceil\n end", "def winning_team\n nets = []\n hornets = []\n\n game_hash.values.each do |nets_stats|\n if nets_stats[:team_name] == \"Brooklyn Nets\"\n nets_stats[:players].each do |bk|\n nets << bk[:points]\n end\n end\n end\n\n game_hash.values.each do |hornets_stats|\n if hornets_stats[:team_name] == \"Charlotte Hornets\"\n hornets_stats[:players].each do |ch|\n hornets << ch[:points]\n end\n end\n end\n\n if nets.reduce(:+) > hornets.reduce(:+)\n return \"Brooklyn Nets\"\n else\n return \"Charlotte Hornets\"\n end\nend", "def avg_shots_per_kill\n @avg_shots_per_kill = @shots.to_f / @kills if @avg_shots_per_kill.nil?\n\n @avg_shots_per_kill\n end", "def rank_top_teams # DO NOT USE THIS METHOD, outdated, slow\n @top_teams = {}\n @top_teams = Score.in_challenge(self.id).teams_in_all_divisions.limit(5).\n order(\"sum_points DESC, MAX(#{Score.table_name}.\n earned_at) DESC\").sum(:points) \n return @top_teams\n end", "def winning_team\n points_home = 0\n points_away = 0\n result = \"\"\n\n game_hash.each do |side,team|\n team.each do |specs,info|\n if specs == :players\n info.each do |player|\n if side = :home\n points_home += player[:points]\n else\n points_away += player[:points]\n end\n end\n end\n end\n end\n if points_home > points_away\n result = game_hash[:home][:team_name]\n else\n result = game_hash[:away][:team_name]\n end\n result\nend", "def winning_team\n home_points = 0\n away_points = 0\n team1 = \"Brooklyn Nets\"\n team2 = \"Charlotte Hornets\"\n game_hash.each do |team,info|\n info.each do |team_info,team_data|\n if team_data.is_a? (Array) \n if team_info != :colors\n if info[:team_name] == \"Brooklyn Nets\"\n team_data.each do |player_index|\n home_points += player_index[:points]\n end\n else \n team_data.each do |player_index|\n away_points += player_index[:points]\n winning_team end\n end\n end\n end\n end\n end\n\n if home_points > away_points\n team1\n else\n team2\n end\n\nend", "def load_stats\n[\n {\n home_team: \"Jets\",\n away_team: \"Giants\",\n home_score: 21,\n away_score: 3\n },\n {\n home_team: \"Steelers\",\n away_team: \"Giants\",\n home_score: 21,\n away_score: 3\n },\n {\n home_team: \"Patriots\",\n away_team: \"Giants\",\n home_score: 21,\n away_score: 3\n },\n {\n home_team: \"Chargers\",\n away_team: \"Jets\",\n home_score: 13,\n away_score: 6\n },\n {\n home_team: \"Patriots\",\n away_team: \"Jets\",\n home_score: 13,\n away_score: 6\n },\n {\n home_team: \"Steelers\",\n away_team: \"Jets\",\n home_score: 3,\n away_score: 6\n },\n {\n home_team: \"Dolphins\",\n away_team: \"Jets\",\n home_score: 0,\n away_score: 3\n },\n{\n home_team: \"Browns\",\n away_team: \"Jets\",\n home_score: 0,\n away_score: 21\n },\n {\n home_team: \"Chargers\",\n away_team: \"Jets\",\n home_score: 7,\n away_score: 21\n },\n {\n home_team: \"Steelers\",\n away_team: \"Broncos\",\n home_score: 7,\n away_score: 13\n },\n {\n home_team: \"Patriots\",\n away_team: \"Broncos\",\n home_score: 7,\n away_score: 3\n },\n {\n home_team: \"Broncos\",\n away_team: \"Colts\",\n home_score: 3,\n away_score: 0\n },\n {\n home_team: \"Patriots\",\n away_team: \"Colts\",\n home_score: 11,\n away_score: 7\n },\n {\n home_team: \"Steelers\",\n away_team: \"Patriots\",\n home_score: 7,\n away_score: 21\n },\n {\n home_team: \"Steelers\",\n away_team: \"Colts\",\n home_score: 24,\n away_score: 21\n },\n {\n home_team: \"Steelers\",\n away_team: \"Colts\",\n home_score: 24,\n away_score: 21\n }\n]\nend", "def minimum_rounds(driver)\n Algorithm::Swiss.minimum_rounds(driver.seeded_teams.length)\n end", "def minimum_rounds(driver)\n Algorithm::Swiss.minimum_rounds(driver.seeded_teams.length)\n end", "def total_points\n\n points = 0\n wattball_matches_as_team1.each do |match|\n points += match.points(1) || 0\n end\n\n wattball_matches_as_team2.each do |match|\n points += match.points(2) || 0\n end\n\n points\n end", "def avg_of_toryo_turn_max\n s = lose_scope\n s = s.joins(:battle)\n s = s.where(Swars::Battle.arel_table[:final_key].eq(\"TORYO\"))\n if v = s.average(Swars::Battle.arel_table[:turn_max])\n v.to_i\n end\n end", "def biggest_blowout\n score_difference = games.map { |game| (game.home_goals - game.away_goals).abs}\n score_difference.max\n end", "def most_hits(seasonasstring) # shots in game team stats\n #get a list of all teams that played in that season\n #use above list to sum all shots across all games in season\n #find highest across list\n #return team name as found in 139\n end", "def most_steals \n num_steals = 0\n game_hash.each do |team,info|\n info.each do |team_info,team_data|\n if team_data.is_a? (Array) \n if team_info != :colors\n team_data.each do |player_index|\n if num_steals == 0 || player_index[:steals] > num_steals \n num_steals = player_index[:steals] \n end\n end\n end\n end\n end\n end\nnum_steals\nend", "def team_score\n team_member = @current_user.team.users\n team_comment = Comment.where(user_id: team_member.pluck('id'))\n emotion_scores = team_comment.where('created_at BETWEEN ? AND ?', DateTime.now.beginning_of_day, DateTime.now.end_of_day).average(:score)\n emotion_scores\n end", "def avg_shots_per_kill\n @shots.to_f / @kills\n end", "def score\n total = 0\n achievements.each do |a|\n total += a.task.score\n end\n total\n end", "def num_rounds\n (Math.log(teams.size) / Math.log(2)).to_i\n end", "def most_points_scored\nbest_player = \"\"\npoints = 0\ngame_hash.each do |location, team_data|\n team_data[:players].each do |name, stats|\n if stats[:points] > points\n points = stats[:points]\n best_player= name\n end\n end\nend\nbest_player\nend", "def best_score(a_of_g)\n best_score = a_of_g.flatten.return_objects_with(:attempts, 0).max_attribute(:adjusted_goodness)\n end", "def lowest_score\n sort\n all.last.score\n end", "def calculate_team_points\n # If the bracket is complete, we can calculate points based on the\n # teams' `final_rank`s.\n if @state == \"complete\"\n calculate_team_points_by_final_rank\n return\n end\n\n # For each team, look at the matches that it is in, look at the point\n # values of those matches, and take the maximum point value. That's the\n # number of points that the team has earned so far in the bracket.\n base_point_value = @config.base_point_value\n\n @teams.each do |team|\n matches_with_team = @matches.select { |match| match.has_team?(team.id) }\n\n puts \"Team #{team.name} was in #{matches_with_team.size} matches\"\n\n points_earned = matches_with_team.max_by(&:points).points\n\n puts \"The largest point value of those matches is #{points_earned}\" \\\n \"#{\" + #{base_point_value} base\" if base_point_value > 0}\"\n\n team.points = points_earned + base_point_value\n end\n end", "def player_with_most_steals\n name = \"\"\n most_steals = 0\n\n game_hash.each do | team, details_hash |\n players_array = details_hash[:players]\n players_array.each do | player_details_hash |\n if player_details_hash[:steals] > most_steals\n most_steals = player_details_hash[:steals]\n name = player_details_hash[:player_name]\n end\n end\n end\n name\nend", "def goal_difference\n total_diff = 0\n\n wattball_matches_as_team1.each do |match|\n total_diff += match.goal_difference[0]\n end\n\n wattball_matches_as_team2.each do |match|\n total_diff += match.goal_difference[1]\n end\n \n total_diff\n end", "def most_points_scored\n most_points_scored = 0\n player_with_the_most_points_scored = \"\"\n game_hash.each do |team,info|\n info.each do |team_info,team_data|\n if team_data.is_a? (Array) \n if team_info != :colors\n team_data.each do |player_index|\n if most_points_scored == 0 || player_index[:points] > most_points_scored \n most_points_scored = player_index[:points]\n player_with_the_most_points_scored = player_index[:player_name]\n end\n end\n end\n end\n end\n end\n player_with_the_most_points_scored\nend", "def total_score\n\t\tall_scores = picks.collect { |pick|\n\t\t\tpicks_golfers = TournamentGolfer.where(golfer_id: pick.golfer_id, tournament_id: pick.pool.tournament_id).pluck(:total)[0]\n\t\t} - [nil] - [\"CUT\"]\n\t\tif all_scores.count < 5\n\t\t\treturn \"DQ\"\n\t\telse \n\t\t\tall_scores = all_scores.map {|score| score.to_i}\n\t\t\tall_scores = all_scores.sort\n\t\t\treturn all_scores[0..(pool.number_golfers_for_scoring-1)].sum\n\t\tend\n\tend", "def find_best_score(total_per_player)\n best_score = 0\n winner = ''\n total_per_player.each do |player_name,total|\n\n if total > best_score\n best_score = total\n winner = player_name\n end\n end\n return winner\n end", "def most_points_scored\n max = nil\n name = nil \n game_hash.each do |team, team_values|\n team_values[:players].each do |player|\n if max == nil || player[:points] > max\n max = player[:points]\n name = player[:player_name]\n end\n end\n end\n name\nend", "def average_test(limit)\n (0..15).each do |skill|\n gamecount = 0\n pintotal = 0\n minscore = 300\n maxscore = 0\n\n until gamecount == limit\n newgame\n @players << skill\n reset_arrays\n playgame\n gamecount += 1\n pintotal += @game_scores[0][-1]\n \n minscore = @game_scores[0][-1] if @game_scores[0][-1] < minscore\n maxscore = @game_scores[0][-1] if @game_scores[0][-1] > maxscore\n end\n\n print \"#{skill}\\t#{gamecount}\\tavg\"\n print \"#{(pintotal / gamecount)}\".rjust(4), \"#{minscore}/#{maxscore}\".rjust(9), \"\\n\"\n puts\n end\nend", "def most_points_scored\n most_points = 0\n player = \"\"\n game_hash.each do |k, team|\n team[:players].each do |e|\n if e[:points] > most_points\n most_points = e[:points]\n player = e[:player_name]\n end\n end\n end\n player\nend", "def wins\n wins = 0\n self.teams.each do |team|\n wins += team.games_won.length\n end\n wins\n end" ]
[ "0.7819011", "0.7769936", "0.77371097", "0.7561385", "0.75141984", "0.74485373", "0.73008007", "0.71629214", "0.7153772", "0.7087543", "0.7032626", "0.6950318", "0.6821733", "0.6725882", "0.67237425", "0.66868424", "0.6644543", "0.66217196", "0.6561751", "0.655602", "0.65555924", "0.65529144", "0.65242463", "0.6513157", "0.6511269", "0.6504979", "0.6498987", "0.64945817", "0.64723897", "0.6468598", "0.6466338", "0.64580405", "0.6450385", "0.6449745", "0.64406925", "0.6428054", "0.6422512", "0.64118093", "0.640121", "0.63979256", "0.6397245", "0.6393614", "0.63929933", "0.63912255", "0.63683397", "0.6359697", "0.63541037", "0.6342193", "0.63359857", "0.6327456", "0.6312323", "0.6309547", "0.6304144", "0.6299073", "0.6292941", "0.6261259", "0.6255419", "0.62390095", "0.6195608", "0.6195608", "0.61888915", "0.6184007", "0.6165728", "0.6165495", "0.61638707", "0.614916", "0.6141612", "0.6133049", "0.6120209", "0.61077", "0.6106542", "0.609292", "0.6079236", "0.60783005", "0.60738826", "0.6051662", "0.60458654", "0.60458654", "0.60424846", "0.6038018", "0.603659", "0.6035213", "0.60278547", "0.60259926", "0.5989736", "0.5985132", "0.59835154", "0.5982919", "0.5976034", "0.59658504", "0.59624416", "0.5955081", "0.5942111", "0.5929778", "0.5912101", "0.5911209", "0.5909881", "0.59095114", "0.5906884", "0.5903383" ]
0.73491526
6
returns team with lowest average goals allowed
def best_defense @teams.min_by { |team| team.average_goals_allowed }.team_name end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def lowest_total_score\n total_game_scores = games.map { |game| game.home_goals + game.away_goals}\n total_game_scores.min\n end", "def fewest_goals_scored(team_id)\n team_id = team_id.to_i\n goals_per_game = @game_teams.map do |game|\n if game.team_id == team_id\n game.goals\n end\n end\n goals_per_game.compact.min\n end", "def lowest_scoring_visitor\n @teams.min_by { |team| team.average_away_goals }.team_name\n end", "def lowest_scoring_home_team\n @teams.min_by { |team| team.average_home_goals }.team_name\n end", "def average_goals_per_game\n total_goals = @teams.map {|team| team.total_goals_scored}.sum\n total_games = @teams.map {|team| team.home_games}.sum\n (total_goals.to_f / total_games.to_f).round(2)\n end", "def worst_offense\n @teams.min_by { |team| team.average_goals_scored }.team_name\n end", "def team_average\n # This version is implemented as a database AVG operation,\n # but it cannot be eager loaded so it results in an extra\n # database query for each project:\n #\n # avg = students_projects.select(:points).average :points\n # avg ? avg.round : 0\n\n # This version programmatically finds the average of the points:\n #self.reload\n no_of_students = self.students_projects.length\n return 0 if no_of_students == 0\n total = 0\n self.students_projects.each { |s| total += s.points }\n (total / no_of_students).round\n end", "def best_defense\n teams_total_goals_allowed = total_goals_allowed_helper\n teams_total_games = total_games_helper\n\n best_team_goals_allowed_avg = 100\n best_defense_team_id = 0\n this_team_goals_allowed_avg = 0\n\n teams_total_games.each do |games_key, games_value|\n teams_total_goals_allowed.each do |goals_key, goals_value|\n if goals_key == games_key\n this_team_goals_allowed_avg = (goals_value / games_value.to_f)\n if this_team_goals_allowed_avg < best_team_goals_allowed_avg\n best_team_goals_allowed_avg = this_team_goals_allowed_avg\n best_defense_team_id = games_key\n end\n end\n end\n end\n\n team_with_best_defense = nil\n self.teams.each_value do |team_obj|\n if team_obj.team_id. == best_defense_team_id\n team_with_best_defense = team_obj.team_name\n end\n end\n team_with_best_defense\n end", "def worst_offense\n teams_total_goals = total_goals_helper\n teams_total_games = total_games_helper\n\n worst_team_goals_avg = 1000\n worst_offense_team_id = 0\n this_team_goals_avg = 0\n\n teams_total_games.each do |games_key, games_value|\n teams_total_goals.each do |goals_key, goals_value|\n if goals_key == games_key\n this_team_goals_avg = (goals_value / games_value.to_f)\n if this_team_goals_avg < worst_team_goals_avg\n worst_team_goals_avg = this_team_goals_avg\n worst_offense_team_id = games_key\n end\n end\n end\n end\n\n team_with_worst_offense = nil\n self.teams.each_value do |team_obj|\n if team_obj.team_id. == worst_offense_team_id\n team_with_worst_offense = team_obj.team_name\n end\n end\n team_with_worst_offense\n end", "def smallest_team\n self.teams.min{|t1,t2| t1.runners.size <=> t2.runners.size }\n end", "def worst_defense\n teams_total_goals_allowed = total_goals_allowed_helper\n teams_total_games = total_games_helper\n\n worst_team_goals_allowed_avg = 0\n worst_defense_team_id = 0\n this_team_goals_allowed_avg = 0\n\n teams_total_games.each do |games_key, games_value|\n\n teams_total_goals_allowed.each do |goals_key, goals_value|\n if goals_key == games_key\n this_team_goals_allowed_avg = (goals_value / games_value.to_f)\n if this_team_goals_allowed_avg > worst_team_goals_allowed_avg\n worst_team_goals_allowed_avg = this_team_goals_allowed_avg\n worst_defense_team_id = games_key\n end\n end\n end\n end\n team_with_worst_defense = team_name_finder_helper(worst_defense_team_id)\n\n team_with_worst_defense\n end", "def best_offense\n @teams.max_by { |team| team.average_goals_scored }.team_name\n end", "def worst_defense\n @teams.max_by { |team| team.average_goals_allowed }.team_name\n end", "def average_goals_by_season\n goals_by_season = @games.group_by { |game| game.season.to_s }\n goals_by_season.each do |season, games|\n season_goals = games.map { |game| game.home_goals + game.away_goals }.sum\n goals_by_season[season] = (season_goals.to_f / games.count.to_f).round(2)\n end\n end", "def goals_for(team)\n valid = ((team == self.home_team or team == self.away_team) and self.final)\n\n if (valid)\n if (self.home_team == team)\n return self.homeScore\n else\n return self.awayScore\n end\n else\n return 0\n end\n end", "def pri_tdef\n team_stats.opp_goals_per_game / team_stats.opp_avg_goals_against_per_game\n end", "def best_fans\n @teams.max_by { |team| team.home_minus_away_percentage }.team_name\n end", "def average_win_percentage(team_id)\n team_id = team_id.to_i\n team = @teams.select { |each_team| each_team.team_id == team_id }.first\n team.total_win_percentage.round(2)\n end", "def winningest_team\n @teams.max_by { |team| team.total_win_percentage }.team_name\n end", "def highest_scoring_visitor\n @teams.max_by { |team| team.average_away_goals }.team_name\n end", "def highest_scoring_home_team\n @teams.max_by { |team| team.average_home_goals }.team_name\n end", "def worst_season(team_id)\n team_id = team_id.to_i\n team = @teams.select { |each_team| each_team.team_id == team_id }.first\n team.season_win_percentages.min_by { |season, percentage| percentage }.first.to_s\n end", "def goals_against(team)\n valid = ((team == self.home_team or team == self.away_team) and self.final)\n\n if (valid)\n if (self.home_team == team)\n return self.awayScore\n else\n return self.homeScore\n end\n else\n return 0\n end\n end", "def best_score\n submissions.min(:score)\n end", "def points_in_team(team)\r\n perfs = self.performances.where(team: team)\r\n perfs.map(&:points).inject(:+) / perfs.length\r\n end", "def winning_team\n home_points = collection_by_prop(game_hash[:home], :points).reduce(0, :+)\n away_points = collection_by_prop(game_hash[:away], :points).reduce(0, :+)\n home_points > away_points ? game_hash[:home][:team_name] : game_hash[:away][:team_name]\n end", "def highest_total_score\n total_goals.max\n end", "def most_accurate_team(seasonasstring) # shots in game team stats\n #get a list of all teams that played in that season - given by arg\n #use above list to sum all shots across all games in season\n #divide above by goals made across all games in season\n #find highest percentage\n #return team name as found in 127\n end", "def most_goals_scored(team_id)\n team_id = team_id.to_i\n goals_per_game = @game_teams.map do |game|\n if game.team_id == team_id\n game.goals\n end\n end\n goals_per_game.compact.max\n end", "def starters_average\n total = self.players.starter.inject(0) {|result, element| result + element.average_qualities}\n return total / MIN_PLAYERS\n end", "def pri_toff\n team_stats.goals_per_game / team_stats.opp_avg_goals_per_game\n end", "def winning_team\n final_scores = player_collection.reduce(home: 0, away: 0) { |teams_points, next_player|\n case \n when next_player[:location] === :away\n teams_points[:away] += next_player[:points];\n when next_player[:location] === :home\n teams_points[:home] += next_player[:points];\n end\n teams_points; \n }\n winner = final_scores.reduce { |highest_points, team_points| \n highest_points[1] > team_points[1] ? highest_points : team_points; \n }\n game_hash[winner[0]][:team_name]; \nend", "def winning_team\n self.teams.order('score DESC').first\n end", "def team_with_more_points(game)\n home_points = game[:home_team][:players].collect do |player|\n player[:stats][:points]\n end.inject {|sum, n| sum + n}\n away_points = game[:away_team][:players].collect do |player|\n player[:stats][:points]\n end.inject {|sum, n| sum + n}\n home_points > away_points ? game[:home_team][:team_name] : game[:away_team][:team_name]\nend", "def winning_team\n home_team_points = game_hash[:home][:players].sum { |e| e[:points] }\n away_team_points = game_hash[:away][:players].sum { |e| e[:points] }\n\n if home_team_points > away_team_points\n return game_hash[:home][:team_name]\n else\n return game_hash[:away][:team_name]\n end\nend", "def winning_team\n home_team_sum = 0\n away_team_sum = 0\n game_hash.each do |team, team_stats|\n if team_stats[:team_name] == \"Brooklyn Nets\"\n team_stats[:players].each do |player_stats|\n home_team_sum += player_stats[:points]\n end\n elsif team_stats[:team_name] == \"Charlotte Hornets\"\n team_stats[:players].each do |player_stats|\n away_team_sum += player_stats[:points]\n end\n end\n end\n if home_team_sum > away_team_sum\n game_hash[:home][:team_name]\n elsif home_team_sum < away_team_sum\n game_hash[:away][:team_name]\n end\nend", "def winning_team\n home_score = 0\n away_score = 0\n game_hash[:home][:players].keys.each do |name|\n home_score += game_hash[:home][:players][name][:points]\n end\n game_hash[:away][:players].keys.each do |name|\n away_score += game_hash[:away][:players][name][:points]\n end\n home_score > away_score ? game_hash[:home][:team_name] : game_hash[:away][:team_name]\nend", "def winning_team\n if homeTeamPoints.sum > awayTeamPoints.sum\n \"Brooklyn Nets\"\n else\n \"Charlotte Hornets\"\n end\nend", "def winning_team\n team_p = []\n team_n = []\n\n game_hash.each do | location, team_data|\n temp = 0\n team_data[:players].each do |p_name, stats|\n temp += stats[:points]\n end\n team_n << team_data[:team_name]\n team_p << temp\n end\n\n team_p[0] > team_p[1] ? team_n[0] : team_n[1]\n\nend", "def average_difficulty\n @p = live_problems\n if @p.size > 0\n @avg = @p.inject(0.0){|sum, i| sum + Difficulty.to_int(i.difficulty) } / @p.size\n else\n @avg = nil\n end\n end", "def goals_against()\n\t self.as_regular_contestants.select{|c| c.opponent.score}.collect{|c| c.opponent.score}.inject{|gf, c| gf + c} || 0\n\tend", "def best_season(team_id)\n team_id = team_id.to_i\n team = @teams.select { |each_team| each_team.team_id == team_id }.first\n team.season_win_percentages.max_by { |season, percentage| percentage }.first.to_s\n end", "def goals_for()\n\t self.as_regular_contestants.select{|c| c.score}.collect{|c| c.score}.inject{|gf, c| gf + c} || 0\n\tend", "def batting_average(year: nil, team: nil)\n hits, at_bats = 0, 0\n\n seasonal_stats.each do |stat_line|\n year_match = stat_line.year == year || year == nil\n team_match = stat_line.team == team || team == nil\n if year_match && team_match\n hits += stat_line.hits\n at_bats += stat_line.at_bats\n end\n end\n\n if (at_bats != 0)\n return (hits.to_f / at_bats)\n else\n return 0.0\n end\n end", "def least_popular_venue\n venues = @games.group_by { |game| game.venue}\n venues.min_by { |venue, games| games.count }.first\n end", "def lacrosse_scoring_average(sport, player)\n\t\tgoals = 0\n\t\tgames = sport.teams.find(player.team_id).gameschedules\n\n\t\tgames.each do |g|\n\t\t\tstat = g.lacrosstats.find_by(athlete_id: player.id)\n\t\t\tgoals += stat.lacross_scorings.count if stat.lacross_scorings.any?\n\t\tend\n\n\t\tif games > 0\n\t\t\treturn goals / games.count\n\t\telse\n\t\t\treturn 0.0\n\t\tend\n\tend", "def least_accurate_team(seasonasstring) # shots in game team stats\n #inverse of above\n end", "def total_team_score(teams_id)\n total_score = 0\n @league_data.each do\n |team| \n # binding.pry\n if team.home_team_id == teams_id\n total_score += team.home_team_score\n elsif team.away_team_id == teams_id\n total_score += team.away_team_score\n end\n end\n return total_score\n end", "def rating\n position_sum = 0\n games = []\n number_of_teams = 0\n Participation.find_all_by_player_id(self.id).each do |participation|\n position_sum += participation.position\n games.push Game.find(participation.game_id)\n end\n\n games.each do |game|\n number_of_teams += game.number_of_teams\n end\n\n if position_sum == 0\n position_sum = number_of_teams.to_f-0.5\n end\n\n (1 - position_sum.to_f/number_of_teams).round 2\n end", "def get_standings(games)\n teams = Hash.new\n games.each do |game|\n division_id = game.division_id\n home_team = game.home_team\n away_team = game.visiting_team\n if(teams[home_team.name].nil?)\n teams[home_team.name] = {:win => 0, :loss => 0, :tie => 0, :point=> 0}\n end\n\n if(teams[away_team.name].nil?)\n teams[away_team.name] = {:win => 0, :loss => 0, :tie => 0, :point => 0}\n end\n if(game.home_team_score && game.visiting_team_score)\n if(game.home_team_score > game.visiting_team_score)\n # home team won\n teams[home_team.name][:win] += 1\n teams[home_team.name][:point] += 5\n # visiting team loss\n teams[away_team.name][:loss] += 1\n elsif(game.home_team_score < game.visiting_team_score)\n # home team loss\n teams[home_team.name][:loss] += 1\n #visiting team won\n teams[away_team.name][:win] += 1\n teams[away_team.name][:point] += 5\n else\n # tie game\n teams[home_team.name][:tie] += 1\n teams[home_team.name][:point] += 1\n teams[away_team.name][:tie] += 1\n teams[away_team.name][:point] += 1\n end\n end\n end\n teams.each do |team, value|\n puts team\n total_games = value[:win] + value[:loss] + value[:tie]\n if total_games > 0 \n win_percentage = value[:win]/total_games.to_f\n else\n win_percentage = 0\n end \n value[:percentage] = win_percentage\n end\n teams_sorted = teams.sort_by{ |k, v| v[:point]}.reverse\n return teams_sorted\n end", "def average_player_age\n players.average(:age)\n end", "def calculate_score(team)\n scores.includes(:wattball_player).where(:wattball_players => {:team_id => team}).sum(:amount) \n end", "def percentage_home_wins\n home_wins = @teams.map { |team| team.home_wins }.sum\n home_games = @teams.map { |team| team.home_games }.sum\n (home_wins.to_f / home_games.to_f).round(2)\n end", "def most_points_scored\n points_scored = 0 # starting score to compare with players shoe sizes\n game_hash.each do |location, team_data| # iterates through each team\n players_array = team_data[:players] # finds the :players info in team_data and puts the players into players_array\n players_array.each do |player_name, data| # iterates through each player..\n if data[:points] > points_scored # if their points scored is greater than 0 (we set this earlier in the top of method)\n points_scored = data[:shoe] # take that players score and make it the new points_scored value\n end # this repeats (iterates) through all players until you don't have any more.. meaning the end result is\n end # the player with the highest score\n end\n return points_scored\nend", "def worst_loss(team_id)\n @games.map do |game|\n if game.away_team_id.to_s == team_id\n game.home_goals - game.away_goals\n elsif game.home_team_id.to_s == team_id\n game.away_goals - game.home_goals\n end\n end.compact.max\n end", "def rating_average(team, match)\n if match.ended?\n sum = 0; team.each { |u| sum += u['rating'].to_i }\n else\n sum = 0; team.users.each { |u| sum += u['rating'].to_i }\n end\n sum / 5\n end", "def calculate_team_ranking_score(number_of_meetings = 2, number_of_bests = 3)\n team_ranking_results = []\n events = []\n if @badge.category_type.code != 'U25' &&\n @badge.meetings.distinct.count >= number_of_meetings\n get_results.each do |meeting_individual_result|\n next unless meeting_individual_result.get_scheduled_date.year - @swimmer.year_of_birth >= 25\n\n next if events.include?(meeting_individual_result.event_type.code)\n\n team_ranking_results << meeting_individual_result\n events << meeting_individual_result.event_type.code\n break if team_ranking_results.count == number_of_bests\n end\n end\n BestLimitedRankingDAO.new(team_ranking_results)\n end", "def determine_winner game\n winner = game.max_by {|team| team[:score]}\n team_standings = get_team_by_name(winner)\n team_standings[:winnings] += 3\nend", "def best_score(a_of_g)\n best_score = a_of_g.flatten.return_objects_with(:attempts, 0).max_attribute(:adjusted_goodness)\n end", "def minimum_rounds(driver)\n Algorithm::Swiss.minimum_rounds(driver.seeded_teams.length)\n end", "def minimum_rounds(driver)\n Algorithm::Swiss.minimum_rounds(driver.seeded_teams.length)\n end", "def avg_of_toryo_turn_max\n s = lose_scope\n s = s.joins(:battle)\n s = s.where(Swars::Battle.arel_table[:final_key].eq(\"TORYO\"))\n if v = s.average(Swars::Battle.arel_table[:turn_max])\n v.to_i\n end\n end", "def test_average_goals_per_game\n\n assert_equal 4.22, @stat_tracker.average_goals_per_game\n end", "def get_project_score(teamArr,proj_id)\n counter=0\n teamArr.each do |x|\n if (proj_id == @preferences_hash[x][:first]) then\n counter = counter+4\n elsif (proj_id == @preferences_hash[x][:second]) then\n counter = counter+2\n elsif (proj_id == @preferences_hash[x][:third]) then\n counter = counter+1\n else \n counter = counter-1\n end\n end\n return counter.to_f/teamArr.size \n #range of [-1, 4]\n end", "def percentage_visitor_wins\n visitor_wins = @teams.map { |team| team.away_wins }.sum\n visitor_games = @teams.map { |team| team.away_games }.sum\n (visitor_wins.to_f / visitor_games.to_f).round(2)\n end", "def most_points_scored\n most_points = 0\n most_points_player = nil\n game_hash.each do |team, team_stats|\n team_stats[:players].each do |player_stats|\n if most_points < player_stats[:points]\n most_points = player_stats[:points]\n most_points_player = player_stats[:player_name]\n end\n end\n end\n most_points_player\nend", "def total_score\n sum = self.games.sum{|game|game.points}\n sum.to_i / self.games.count\n end", "def winning_team\n home_points = 0\n away_points = 0\n result = \"\"\n i = 0\n game_hash.each do |team, about|\n about[:players].each do |name , stats|\n if i == 0\n home_points += stats[:points]\n else\n away_points += stats[:points]\n end\n end\n i += 1\n end\n home_points > away_points ? result = game_hash[:home][:team_name] : result = game_hash[:away][:team_name]\nend", "def winning_team\n nets = []\n hornets = []\n\n game_hash.values.each do |nets_stats|\n if nets_stats[:team_name] == \"Brooklyn Nets\"\n nets_stats[:players].each do |bk|\n nets << bk[:points]\n end\n end\n end\n\n game_hash.values.each do |hornets_stats|\n if hornets_stats[:team_name] == \"Charlotte Hornets\"\n hornets_stats[:players].each do |ch|\n hornets << ch[:points]\n end\n end\n end\n\n if nets.reduce(:+) > hornets.reduce(:+)\n return \"Brooklyn Nets\"\n else\n return \"Charlotte Hornets\"\n end\nend", "def most_points_scored\nbest_player = \"\"\npoints = 0\ngame_hash.each do |location, team_data|\n team_data[:players].each do |name, stats|\n if stats[:points] > points\n points = stats[:points]\n best_player= name\n end\n end\nend\nbest_player\nend", "def minimum_rounds(teams_count)\n Math.log2(teams_count).ceil\n end", "def player_w_biggest_feet\n all_players[1].max_by { |stats| stats[:shoe] }\n end", "def average_fitness\n total_fitness = 0\n @all_persons.each do |person|\n total_fitness += person.get_energy_level\n end\n if @all_persons.empty?\n return 0\n else\n total_fitness / @total_people\n end\n end", "def season_with_fewest_games\n seasons = @games.group_by { |game| game.season }\n seasons.min_by { |season, games| games.count }.first\n end", "def avg_kills_per_shot\n 1 / avg_shots_per_kill\n end", "def avg_kills_per_shot\n 1 / avg_shots_per_kill\n end", "def lowest_score\n sort\n all.last.score\n end", "def get_score(formation)\n lowest_score = Float::MAX\n formation.each do |proj_id, teamArr|\n #TODO multiply each score by the weight from the professor\n score = @professor_preferences[:scheduleWeight]*get_schedule_score(teamArr) + \n @professor_preferences[:codingWeight]*get_coding_score(teamArr) + \n @professor_preferences[:partnerWeight]*get_partner_score(teamArr) + \n @professor_preferences[:projectWeight]*get_project_score(teamArr,proj_id)\n # puts \"each score is\",score\n if (score < lowest_score) then\n lowest_score = score\n end\n end\n return lowest_score\n end", "def most_points_scored\n max = nil\n name = nil \n game_hash.each do |team, team_values|\n team_values[:players].each do |player|\n if max == nil || player[:points] > max\n max = player[:points]\n name = player[:player_name]\n end\n end\n end\n name\nend", "def calculate_team_points\n # If the bracket is complete, we can calculate points based on the\n # teams' `final_rank`s.\n if @state == \"complete\"\n calculate_team_points_by_final_rank\n return\n end\n\n # For each team, look at the matches that it is in, look at the point\n # values of those matches, and take the maximum point value. That's the\n # number of points that the team has earned so far in the bracket.\n base_point_value = @config.base_point_value\n\n @teams.each do |team|\n matches_with_team = @matches.select { |match| match.has_team?(team.id) }\n\n puts \"Team #{team.name} was in #{matches_with_team.size} matches\"\n\n points_earned = matches_with_team.max_by(&:points).points\n\n puts \"The largest point value of those matches is #{points_earned}\" \\\n \"#{\" + #{base_point_value} base\" if base_point_value > 0}\"\n\n team.points = points_earned + base_point_value\n end\n end", "def biggest_blowout\n score_difference = games.map { |game| (game.home_goals - game.away_goals).abs}\n score_difference.max\n end", "def winning_team\n home_points = 0\n away_points = 0\n team1 = \"Brooklyn Nets\"\n team2 = \"Charlotte Hornets\"\n game_hash.each do |team,info|\n info.each do |team_info,team_data|\n if team_data.is_a? (Array) \n if team_info != :colors\n if info[:team_name] == \"Brooklyn Nets\"\n team_data.each do |player_index|\n home_points += player_index[:points]\n end\n else \n team_data.each do |player_index|\n away_points += player_index[:points]\n winning_team end\n end\n end\n end\n end\n end\n\n if home_points > away_points\n team1\n else\n team2\n end\n\nend", "def rank_top_teams # DO NOT USE THIS METHOD, outdated, slow\n @top_teams = {}\n @top_teams = Score.in_challenge(self.id).teams_in_all_divisions.limit(5).\n order(\"sum_points DESC, MAX(#{Score.table_name}.\n earned_at) DESC\").sum(:points) \n return @top_teams\n end", "def winning_team\n points_home = 0\n points_away = 0\n result = \"\"\n\n game_hash.each do |side,team|\n team.each do |specs,info|\n if specs == :players\n info.each do |player|\n if side = :home\n points_home += player[:points]\n else\n points_away += player[:points]\n end\n end\n end\n end\n end\n if points_home > points_away\n result = game_hash[:home][:team_name]\n else\n result = game_hash[:away][:team_name]\n end\n result\nend", "def worst_user\n @group_users.min_by(&:get_rate)\n end", "def avg_shots_per_kill\n @avg_shots_per_kill = @shots.to_f / @kills if @avg_shots_per_kill.nil?\n\n @avg_shots_per_kill\n end", "def find_best_score(total_per_player)\n best_score = 0\n winner = ''\n total_per_player.each do |player_name,total|\n\n if total > best_score\n best_score = total\n winner = player_name\n end\n end\n return winner\n end", "def winning_team_with_spread\n\t\tif self.final?\n\t\t\treturn home_team_id if home_team_score > away_team_score + point_spread\n\t\t\treturn away_team_id if away_team_score + point_spread > home_team_score\n\t\t\treturn \"tie\" if home_team_score == away_team_score + point_spread\n\t\telse\n\t\t\treturn nil\n\t\tend\n\tend", "def team_score\n team_member = @current_user.team.users\n team_comment = Comment.where(user_id: team_member.pluck('id'))\n emotion_scores = team_comment.where('created_at BETWEEN ? AND ?', DateTime.now.beginning_of_day, DateTime.now.end_of_day).average(:score)\n emotion_scores\n end", "def select_performant(game, trials = 10)\n max_avg, max_move = 0, nil\n game.valid_moves.each do |move|\n scores = trials.times.map do\n game.mark *move\n n, moves = 0, [move]\n while m = select_naive(game)\n game.mark *m\n n += 1\n moves << m\n end\n game.unmark *moves.pop while moves.any?\n n\n end\n avg = scores.inject(:+).fdiv trials\n if avg > max_avg\n max_avg = avg\n max_move = move\n end\n end\n max_move\nend", "def near_team_winner?(team)\n unless completed?\n sets_won(team) + 1 == min_sets_to_play\n end\n end", "def total_score\n @all_games.map do |games|\n games[\"home_goals\"].to_i + games[\"away_goals\"].to_i\n end\n end", "def worst_fans\n teams_with_bad_fans = @teams.find_all { |team| team.home_minus_away_percentage.negative? }\n teams_with_bad_fans.map { |team| team.team_name }\n end", "def most_points_scored\n most_points = 0\n player = \"\"\n game_hash.each do |k, team|\n team[:players].each do |e|\n if e[:points] > most_points\n most_points = e[:points]\n player = e[:player_name]\n end\n end\n end\n player\nend", "def most_steals \n num_steals = 0\n game_hash.each do |team,info|\n info.each do |team_info,team_data|\n if team_data.is_a? (Array) \n if team_info != :colors\n team_data.each do |player_index|\n if num_steals == 0 || player_index[:steals] > num_steals \n num_steals = player_index[:steals] \n end\n end\n end\n end\n end\n end\nnum_steals\nend", "def average_test(limit)\n (0..15).each do |skill|\n gamecount = 0\n pintotal = 0\n minscore = 300\n maxscore = 0\n\n until gamecount == limit\n newgame\n @players << skill\n reset_arrays\n playgame\n gamecount += 1\n pintotal += @game_scores[0][-1]\n \n minscore = @game_scores[0][-1] if @game_scores[0][-1] < minscore\n maxscore = @game_scores[0][-1] if @game_scores[0][-1] > maxscore\n end\n\n print \"#{skill}\\t#{gamecount}\\tavg\"\n print \"#{(pintotal / gamecount)}\".rjust(4), \"#{minscore}/#{maxscore}\".rjust(9), \"\\n\"\n puts\n end\nend", "def get_hitme_step\n a = c_pics.map { |p| p.step }.compact.min\n b = tutors.map { |t| t.pics.map { |p| p.step } }.flatten.compact.min\n [a, b].compact.min || 0\n end", "def avg_points_per_serve\n return nil if self.served == 0 || self.served.nil? || self.reward.nil?\n return self.reward / self.served.to_f\n end", "def mostSteals\n players.max_by do|name, stats|\n stats[:steals]\n end\nend", "def total_score\n\t\tall_scores = picks.collect { |pick|\n\t\t\tpicks_golfers = TournamentGolfer.where(golfer_id: pick.golfer_id, tournament_id: pick.pool.tournament_id).pluck(:total)[0]\n\t\t} - [nil] - [\"CUT\"]\n\t\tif all_scores.count < 5\n\t\t\treturn \"DQ\"\n\t\telse \n\t\t\tall_scores = all_scores.map {|score| score.to_i}\n\t\t\tall_scores = all_scores.sort\n\t\t\treturn all_scores[0..(pool.number_golfers_for_scoring-1)].sum\n\t\tend\n\tend" ]
[ "0.78174543", "0.77868104", "0.7761091", "0.7663627", "0.75829405", "0.7494507", "0.73580366", "0.7258172", "0.7168765", "0.7121664", "0.70700765", "0.6916417", "0.6795183", "0.6791942", "0.6788021", "0.6728191", "0.66309506", "0.6611697", "0.65998656", "0.6596353", "0.6585199", "0.6568074", "0.6541047", "0.65402657", "0.65355045", "0.65308785", "0.6525162", "0.6495447", "0.648379", "0.6477877", "0.6470996", "0.64707184", "0.645004", "0.6442447", "0.64215416", "0.6395594", "0.6381626", "0.6362867", "0.6351715", "0.63443947", "0.6315021", "0.6303217", "0.62973374", "0.6289971", "0.6277431", "0.62652683", "0.6241253", "0.6240567", "0.62372833", "0.6218693", "0.6216528", "0.6202155", "0.62005836", "0.6195192", "0.6190827", "0.6186874", "0.61820626", "0.61640596", "0.6154628", "0.6153135", "0.6153135", "0.6146051", "0.6143892", "0.6137228", "0.6112643", "0.61025256", "0.60931355", "0.60831445", "0.6082599", "0.607516", "0.60598814", "0.60576636", "0.60569614", "0.60475165", "0.6037227", "0.6037227", "0.6022206", "0.60199064", "0.60066116", "0.60057586", "0.59947866", "0.59834814", "0.597272", "0.5966883", "0.5958309", "0.59557265", "0.59329814", "0.59323287", "0.5923421", "0.5921324", "0.591988", "0.59155995", "0.5887234", "0.5883273", "0.5866469", "0.5865542", "0.5860567", "0.586045", "0.5858514", "0.58551174" ]
0.7665398
3
returns team with highest average goals allowed
def worst_defense @teams.max_by { |team| team.average_goals_allowed }.team_name end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def worst_offense\n teams_total_goals = total_goals_helper\n teams_total_games = total_games_helper\n\n worst_team_goals_avg = 1000\n worst_offense_team_id = 0\n this_team_goals_avg = 0\n\n teams_total_games.each do |games_key, games_value|\n teams_total_goals.each do |goals_key, goals_value|\n if goals_key == games_key\n this_team_goals_avg = (goals_value / games_value.to_f)\n if this_team_goals_avg < worst_team_goals_avg\n worst_team_goals_avg = this_team_goals_avg\n worst_offense_team_id = games_key\n end\n end\n end\n end\n\n team_with_worst_offense = nil\n self.teams.each_value do |team_obj|\n if team_obj.team_id. == worst_offense_team_id\n team_with_worst_offense = team_obj.team_name\n end\n end\n team_with_worst_offense\n end", "def worst_defense\n teams_total_goals_allowed = total_goals_allowed_helper\n teams_total_games = total_games_helper\n\n worst_team_goals_allowed_avg = 0\n worst_defense_team_id = 0\n this_team_goals_allowed_avg = 0\n\n teams_total_games.each do |games_key, games_value|\n\n teams_total_goals_allowed.each do |goals_key, goals_value|\n if goals_key == games_key\n this_team_goals_allowed_avg = (goals_value / games_value.to_f)\n if this_team_goals_allowed_avg > worst_team_goals_allowed_avg\n worst_team_goals_allowed_avg = this_team_goals_allowed_avg\n worst_defense_team_id = games_key\n end\n end\n end\n end\n team_with_worst_defense = team_name_finder_helper(worst_defense_team_id)\n\n team_with_worst_defense\n end", "def highest_total_score\n total_goals.max\n end", "def best_defense\n teams_total_goals_allowed = total_goals_allowed_helper\n teams_total_games = total_games_helper\n\n best_team_goals_allowed_avg = 100\n best_defense_team_id = 0\n this_team_goals_allowed_avg = 0\n\n teams_total_games.each do |games_key, games_value|\n teams_total_goals_allowed.each do |goals_key, goals_value|\n if goals_key == games_key\n this_team_goals_allowed_avg = (goals_value / games_value.to_f)\n if this_team_goals_allowed_avg < best_team_goals_allowed_avg\n best_team_goals_allowed_avg = this_team_goals_allowed_avg\n best_defense_team_id = games_key\n end\n end\n end\n end\n\n team_with_best_defense = nil\n self.teams.each_value do |team_obj|\n if team_obj.team_id. == best_defense_team_id\n team_with_best_defense = team_obj.team_name\n end\n end\n team_with_best_defense\n end", "def worst_offense\n @teams.min_by { |team| team.average_goals_scored }.team_name\n end", "def highest_scoring_visitor\n @teams.max_by { |team| team.average_away_goals }.team_name\n end", "def best_offense\n @teams.max_by { |team| team.average_goals_scored }.team_name\n end", "def most_goals_scored(team_id)\n team_id = team_id.to_i\n goals_per_game = @game_teams.map do |game|\n if game.team_id == team_id\n game.goals\n end\n end\n goals_per_game.compact.max\n end", "def average_goals_per_game\n total_goals = @teams.map {|team| team.total_goals_scored}.sum\n total_games = @teams.map {|team| team.home_games}.sum\n (total_goals.to_f / total_games.to_f).round(2)\n end", "def best_defense\n @teams.min_by { |team| team.average_goals_allowed }.team_name\n end", "def highest_scoring_home_team\n @teams.max_by { |team| team.average_home_goals }.team_name\n end", "def fewest_goals_scored(team_id)\n team_id = team_id.to_i\n goals_per_game = @game_teams.map do |game|\n if game.team_id == team_id\n game.goals\n end\n end\n goals_per_game.compact.min\n end", "def winningest_team\n @teams.max_by { |team| team.total_win_percentage }.team_name\n end", "def worst_loss(team_id)\n @games.map do |game|\n if game.away_team_id.to_s == team_id\n game.home_goals - game.away_goals\n elsif game.home_team_id.to_s == team_id\n game.away_goals - game.home_goals\n end\n end.compact.max\n end", "def best_fans\n @teams.max_by { |team| team.home_minus_away_percentage }.team_name\n end", "def most_accurate_team(seasonasstring) # shots in game team stats\n #get a list of all teams that played in that season - given by arg\n #use above list to sum all shots across all games in season\n #divide above by goals made across all games in season\n #find highest percentage\n #return team name as found in 127\n end", "def biggest_blowout\n score_difference = games.map { |game| (game.home_goals - game.away_goals).abs}\n score_difference.max\n end", "def goals_for(team)\n valid = ((team == self.home_team or team == self.away_team) and self.final)\n\n if (valid)\n if (self.home_team == team)\n return self.homeScore\n else\n return self.awayScore\n end\n else\n return 0\n end\n end", "def avg_of_toryo_turn_max\n s = lose_scope\n s = s.joins(:battle)\n s = s.where(Swars::Battle.arel_table[:final_key].eq(\"TORYO\"))\n if v = s.average(Swars::Battle.arel_table[:turn_max])\n v.to_i\n end\n end", "def biggest_team_blowout(team_id)\n @games.map do |game|\n if game.away_team_id.to_s == team_id\n game.away_goals - game.home_goals\n elsif game.home_team_id.to_s == team_id\n game.home_goals - game.away_goals\n end\n end.compact.max\n end", "def player_w_biggest_feet\n all_players[1].max_by { |stats| stats[:shoe] }\n end", "def team_average\n # This version is implemented as a database AVG operation,\n # but it cannot be eager loaded so it results in an extra\n # database query for each project:\n #\n # avg = students_projects.select(:points).average :points\n # avg ? avg.round : 0\n\n # This version programmatically finds the average of the points:\n #self.reload\n no_of_students = self.students_projects.length\n return 0 if no_of_students == 0\n total = 0\n self.students_projects.each { |s| total += s.points }\n (total / no_of_students).round\n end", "def goals_against(team)\n valid = ((team == self.home_team or team == self.away_team) and self.final)\n\n if (valid)\n if (self.home_team == team)\n return self.awayScore\n else\n return self.homeScore\n end\n else\n return 0\n end\n end", "def winning_team\n self.teams.order('score DESC').first\n end", "def most_points_scored\n max = nil\n name = nil \n game_hash.each do |team, team_values|\n team_values[:players].each do |player|\n if max == nil || player[:points] > max\n max = player[:points]\n name = player[:player_name]\n end\n end\n end\n name\nend", "def mostSteals\n players.max_by do|name, stats|\n stats[:steals]\n end\nend", "def lowest_scoring_visitor\n @teams.min_by { |team| team.average_away_goals }.team_name\n end", "def team_with_more_points(game)\n home_points = game[:home_team][:players].collect do |player|\n player[:stats][:points]\n end.inject {|sum, n| sum + n}\n away_points = game[:away_team][:players].collect do |player|\n player[:stats][:points]\n end.inject {|sum, n| sum + n}\n home_points > away_points ? game[:home_team][:team_name] : game[:away_team][:team_name]\nend", "def winning_team\n final_scores = player_collection.reduce(home: 0, away: 0) { |teams_points, next_player|\n case \n when next_player[:location] === :away\n teams_points[:away] += next_player[:points];\n when next_player[:location] === :home\n teams_points[:home] += next_player[:points];\n end\n teams_points; \n }\n winner = final_scores.reduce { |highest_points, team_points| \n highest_points[1] > team_points[1] ? highest_points : team_points; \n }\n game_hash[winner[0]][:team_name]; \nend", "def lowest_total_score\n total_game_scores = games.map { |game| game.home_goals + game.away_goals}\n total_game_scores.min\n end", "def high_score\n if self.end_date < Date.today\n self.teams.max_by { |team| team.score }.score\n end\n end", "def get_max_over(stat)\n max = 0\n $data_enemies.each { |enemy|\n next if enemy.nil?\n next if enemy.hidden_best\n next unless $game_party.known_enemy?(enemy.id)\n value = enemy.get_stat(stat)\n max = value if value > max\n }\n max\n end", "def highest_total_score\n @game_manager.highest_total_score\n end", "def average_win_percentage(team_id)\n team_id = team_id.to_i\n team = @teams.select { |each_team| each_team.team_id == team_id }.first\n team.total_win_percentage.round(2)\n end", "def lowest_scoring_home_team\n @teams.min_by { |team| team.average_home_goals }.team_name\n end", "def big_shoe_rebounds\n max_shoe = 0 \n max_rebounds = 0 \n game_hash.each do |place, team|\n # team.each do |attribute, data|\n team[:players].each do |player|\n if player[:shoe] > max_shoe\n max_shoe = player[:shoe]\n max_rebounds = player[:rebounds]\n # if attribute == :players\n # data.each do |player|\n #this gives me the player hashes\n # data.max_by{|player| player[:shoe] }\n # data.max_by{|player| player[:shoe] }[:rebounds]\n # player.max_by{|player| player[:shoe] \n # player.max_by{|player| player[:shoe] }[:rebounds]\n end\n end\n end\n return max_rebounds\n end", "def worst_season(team_id)\n team_id = team_id.to_i\n team = @teams.select { |each_team| each_team.team_id == team_id }.first\n team.season_win_percentages.min_by { |season, percentage| percentage }.first.to_s\n end", "def worst_fans\n teams_with_bad_fans = @teams.find_all { |team| team.home_minus_away_percentage.negative? }\n teams_with_bad_fans.map { |team| team.team_name }\n end", "def determine_winner game\n winner = game.max_by {|team| team[:score]}\n team_standings = get_team_by_name(winner)\n team_standings[:winnings] += 3\nend", "def winning_team\n home_points = collection_by_prop(game_hash[:home], :points).reduce(0, :+)\n away_points = collection_by_prop(game_hash[:away], :points).reduce(0, :+)\n home_points > away_points ? game_hash[:home][:team_name] : game_hash[:away][:team_name]\n end", "def winning_team\n home_team_points = game_hash[:home][:players].sum { |e| e[:points] }\n away_team_points = game_hash[:away][:players].sum { |e| e[:points] }\n\n if home_team_points > away_team_points\n return game_hash[:home][:team_name]\n else\n return game_hash[:away][:team_name]\n end\nend", "def average_goals_by_season\n goals_by_season = @games.group_by { |game| game.season.to_s }\n goals_by_season.each do |season, games|\n season_goals = games.map { |game| game.home_goals + game.away_goals }.sum\n goals_by_season[season] = (season_goals.to_f / games.count.to_f).round(2)\n end\n end", "def most_hits(seasonasstring) # shots in game team stats\n #get a list of all teams that played in that season\n #use above list to sum all shots across all games in season\n #find highest across list\n #return team name as found in 139\n end", "def best_season(team_id)\n team_id = team_id.to_i\n team = @teams.select { |each_team| each_team.team_id == team_id }.first\n team.season_win_percentages.max_by { |season, percentage| percentage }.first.to_s\n end", "def highest_player_score\n players.max_by{|player| player.score}.score\n end", "def total_team_score(teams_id)\n total_score = 0\n @league_data.each do\n |team| \n # binding.pry\n if team.home_team_id == teams_id\n total_score += team.home_team_score\n elsif team.away_team_id == teams_id\n total_score += team.away_team_score\n end\n end\n return total_score\n end", "def winning_team\n home_team_sum = 0\n away_team_sum = 0\n game_hash.each do |team, team_stats|\n if team_stats[:team_name] == \"Brooklyn Nets\"\n team_stats[:players].each do |player_stats|\n home_team_sum += player_stats[:points]\n end\n elsif team_stats[:team_name] == \"Charlotte Hornets\"\n team_stats[:players].each do |player_stats|\n away_team_sum += player_stats[:points]\n end\n end\n end\n if home_team_sum > away_team_sum\n game_hash[:home][:team_name]\n elsif home_team_sum < away_team_sum\n game_hash[:away][:team_name]\n end\nend", "def calculate_team_ranking_score(number_of_meetings = 2, number_of_bests = 3)\n team_ranking_results = []\n events = []\n if @badge.category_type.code != 'U25' &&\n @badge.meetings.distinct.count >= number_of_meetings\n get_results.each do |meeting_individual_result|\n next unless meeting_individual_result.get_scheduled_date.year - @swimmer.year_of_birth >= 25\n\n next if events.include?(meeting_individual_result.event_type.code)\n\n team_ranking_results << meeting_individual_result\n events << meeting_individual_result.event_type.code\n break if team_ranking_results.count == number_of_bests\n end\n end\n BestLimitedRankingDAO.new(team_ranking_results)\n end", "def teams_with_score_max(a_game)\n teams_with_score_max = {}\n game_teams_with_score_max = a_game.teams_with_score_max(a_game.game_teams)\n game_teams_with_score_max.each do |game_team_with_score_max|\n # find team instance matching game_team instance\n team_with_score_max = @teams[game_team_with_score_max.name.to_sym]\n teams_with_score_max[game_team_with_score_max.name.to_sym] = team_with_score_max\n end\n teams_with_score_max\n end", "def winning_team\n home_score = 0\n away_score = 0\n game_hash[:home][:players].keys.each do |name|\n home_score += game_hash[:home][:players][name][:points]\n end\n game_hash[:away][:players].keys.each do |name|\n away_score += game_hash[:away][:players][name][:points]\n end\n home_score > away_score ? game_hash[:home][:team_name] : game_hash[:away][:team_name]\nend", "def most_points_scored\n points_scored = 0 # starting score to compare with players shoe sizes\n game_hash.each do |location, team_data| # iterates through each team\n players_array = team_data[:players] # finds the :players info in team_data and puts the players into players_array\n players_array.each do |player_name, data| # iterates through each player..\n if data[:points] > points_scored # if their points scored is greater than 0 (we set this earlier in the top of method)\n points_scored = data[:shoe] # take that players score and make it the new points_scored value\n end # this repeats (iterates) through all players until you don't have any more.. meaning the end result is\n end # the player with the highest score\n end\n return points_scored\nend", "def most_points_scored\n most_points = 0\n most_points_player = nil\n game_hash.each do |team, team_stats|\n team_stats[:players].each do |player_stats|\n if most_points < player_stats[:points]\n most_points = player_stats[:points]\n most_points_player = player_stats[:player_name]\n end\n end\n end\n most_points_player\nend", "def most_points_scored\n stat_by_player = collect_stat_by_name(:points)\n player_with_max_stat = find_max_stat_by_player(stat_by_player)\n player_with_max_stat\nend", "def mostPoints\n players.max_by do|name, stats|\n stats[:points]\n end\nend", "def pri_tdef\n team_stats.opp_goals_per_game / team_stats.opp_avg_goals_against_per_game\n end", "def best_score(a_of_g)\n best_score = a_of_g.flatten.return_objects_with(:attempts, 0).max_attribute(:adjusted_goodness)\n end", "def most_points(game)\nmax_points = 0\nmax_points_player = \"\"\ngame.each do |team, team_contents|\n team_contents[:roster].each do |player, player_contents| \n if player_contents[:points] == max_points\n max_points_player = max_points_player + \" and #{player_contents[:player_name]}\"\n elsif player_contents[:points] > max_points\n max_points = player_contents[:points]\n max_points_player = player_contents[:player_name]\n end\n end\nend\nputs \"#{max_points_player} scored #{max_points}\"\nend", "def most_steals \n num_steals = 0\n game_hash.each do |team,info|\n info.each do |team_info,team_data|\n if team_data.is_a? (Array) \n if team_info != :colors\n team_data.each do |player_index|\n if num_steals == 0 || player_index[:steals] > num_steals \n num_steals = player_index[:steals] \n end\n end\n end\n end\n end\n end\nnum_steals\nend", "def biggest_surprise(season)\n season = season.to_i\n @teams.max_by{ |team| team.preseason_to_regular_increase[season] }.team_name\n end", "def winning_team\n team_p = []\n team_n = []\n\n game_hash.each do | location, team_data|\n temp = 0\n team_data[:players].each do |p_name, stats|\n temp += stats[:points]\n end\n team_n << team_data[:team_name]\n team_p << temp\n end\n\n team_p[0] > team_p[1] ? team_n[0] : team_n[1]\n\nend", "def best_offense\n offense_suite\n best_offense_id = @average_goals_by_id.invert.max[1]\n @team_name_by_id[best_offense_id]\n end", "def most_steals(game)\nmax_steals = 0\nmax_steals_player = \"\"\ngame.each do |team, team_contents|\n team_contents[:roster].each do |player, player_contents| \n if player_contents[:steals] == max_steals\n max_steals_player = max_steals_player + \" and #{player_contents[:player_name]}\"\n elsif player_contents[:steals] > max_steals\n max_steals = player_contents[:steals]\n max_steals_player = player_contents[:player_name]\n end\n end\nend\nmax_steals_player\nend", "def most_points_scored\nbest_player = \"\"\npoints = 0\ngame_hash.each do |location, team_data|\n team_data[:players].each do |name, stats|\n if stats[:points] > points\n points = stats[:points]\n best_player= name\n end\n end\nend\nbest_player\nend", "def max_total_score\n review_criterions.collect{|c| c.max_score}.sum\n end", "def rank_top_teams # DO NOT USE THIS METHOD, outdated, slow\n @top_teams = {}\n @top_teams = Score.in_challenge(self.id).teams_in_all_divisions.limit(5).\n order(\"sum_points DESC, MAX(#{Score.table_name}.\n earned_at) DESC\").sum(:points) \n return @top_teams\n end", "def winning_team\n if homeTeamPoints.sum > awayTeamPoints.sum\n \"Brooklyn Nets\"\n else\n \"Charlotte Hornets\"\n end\nend", "def biggestShoes\n players.max_by do|name, stats|\n stats[:shoe]\n end\nend", "def most_points_scored\n\tpoints_array = []\n\tgame_hash.each do |location, team_data|\n\t\tteam_data[:players].each do |attribute, data|\t\n\t\t\tdata.each do |type, amount|\n\t\t\t\tif type == :points\n\t\t\t\t\tpoints_array << amount\n\t\t\t\tend \n\t\t\tend\n\t\tend\n\tend\n\tgame_hash.each do |l, data|\n\t\tdata[:players].each do |a, d|\n\t\t\td.each do |t, amt|\n\t\t\t\tif t == :points && points_array.max == amt\n\t\t\t\t\treturn a\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend\nend", "def most_points(game)\n player_name_with_points = []\n game[:home_team][:players].each do |player_hash|\n player_name_with_points << {player_hash[:player_name] => player_hash[:stats][:points]}\n end\n game[:away_team][:players].each do |player_hash|\n player_name_with_points << {player_hash[:player_name] => player_hash[:stats][:points]}\n end\n player_most_points = {\"test\" => 0}\n player_name_with_points.each do |name_and_points_hash|\n player_most_points = name_and_points_hash if name_and_points_hash.values[0] > player_most_points.values[0]\n end\n player_most_points.keys[0]\nend", "def player_with_most_steals\n name = \"\"\n most_steals = 0\n\n game_hash.each do | team, details_hash |\n players_array = details_hash[:players]\n players_array.each do | player_details_hash |\n if player_details_hash[:steals] > most_steals\n most_steals = player_details_hash[:steals]\n name = player_details_hash[:player_name]\n end\n end\n end\n name\nend", "def most_points_scored\n most_points = 0\n player = \"\"\n game_hash.each do |k, team|\n team[:players].each do |e|\n if e[:points] > most_points\n most_points = e[:points]\n player = e[:player_name]\n end\n end\n end\n player\nend", "def max_teams(rounds)\n 2**rounds\n end", "def max_teams(rounds)\n 2**rounds\n end", "def worst(num = nil)\n temp = @user.scores.group(:sentence).sum(:val).sort_by{|_,v| +v}\n filter_by_num(temp, num)\n end", "def most_steals\r\n result={}\r\n game_hash.each do |k, v|\r\n v.each do| p, d|\r\n if p==:players\r\n d.each do |t, s|\r\n result[t]=s[:steals]\r\n end\r\n end\r\n end\r\n end \r\n result.max_by {|name, steal| steal}[0]\r\nend", "def goals_against()\n\t self.as_regular_contestants.select{|c| c.opponent.score}.collect{|c| c.opponent.score}.inject{|gf, c| gf + c} || 0\n\tend", "def winning_scores\n high_score = scores.max{|score| score.total}.total\n scores.select {|score| score.total == high_score}\n end", "def big_shoe_rebounds\n\nhighest_rebounds = 0\nbiggest_shoe = 0\n\n game_hash.each do |location, team_info|\n game_hash.dig(location, :players).each do |player_name, stats|\n stats.each do |stat, number|\n if stat == :shoe\n if number > biggest_shoe\n biggest_shoe = number\n stats.each do |stat, number|\n if stat == :rebounds\n highest_rebounds = number\n end\n end\n end\n end\n end\n end\n end\n puts highest_rebounds\n return highest_rebounds\nend", "def pri_toff\n team_stats.goals_per_game / team_stats.opp_avg_goals_per_game\n end", "def get_standings(games)\n teams = Hash.new\n games.each do |game|\n division_id = game.division_id\n home_team = game.home_team\n away_team = game.visiting_team\n if(teams[home_team.name].nil?)\n teams[home_team.name] = {:win => 0, :loss => 0, :tie => 0, :point=> 0}\n end\n\n if(teams[away_team.name].nil?)\n teams[away_team.name] = {:win => 0, :loss => 0, :tie => 0, :point => 0}\n end\n if(game.home_team_score && game.visiting_team_score)\n if(game.home_team_score > game.visiting_team_score)\n # home team won\n teams[home_team.name][:win] += 1\n teams[home_team.name][:point] += 5\n # visiting team loss\n teams[away_team.name][:loss] += 1\n elsif(game.home_team_score < game.visiting_team_score)\n # home team loss\n teams[home_team.name][:loss] += 1\n #visiting team won\n teams[away_team.name][:win] += 1\n teams[away_team.name][:point] += 5\n else\n # tie game\n teams[home_team.name][:tie] += 1\n teams[home_team.name][:point] += 1\n teams[away_team.name][:tie] += 1\n teams[away_team.name][:point] += 1\n end\n end\n end\n teams.each do |team, value|\n puts team\n total_games = value[:win] + value[:loss] + value[:tie]\n if total_games > 0 \n win_percentage = value[:win]/total_games.to_f\n else\n win_percentage = 0\n end \n value[:percentage] = win_percentage\n end\n teams_sorted = teams.sort_by{ |k, v| v[:point]}.reverse\n return teams_sorted\n end", "def player_with_most_steal\n most_steals = nil\n most_steal_player = nil\n\n all_players(game_hash).each do |player|\n if most_steals == nil || player[:steals] > most_steals\n most_steals = player[:steals]\n most_steal_player = player[:player_name]\n end\n end\n\n most_steal_player\nend", "def big_shoe_rebounds_2\n\nhighest_rebounds = 0\nbiggest_shoe = 0\n\n\n game_hash.dig(:home, :players).each do |player_name, stats|\n stats.each do |stat, number|\n if stat == :shoe\n if number > biggest_shoe\n biggest_shoe = number\n stats.each do |stat, number|\n if stat == :rebounds\n highest_rebounds = number\n\n end\n end\n end\n end\n end\nend\n\n puts highest_rebounds\n return highest_rebounds\nend", "def find_best_score(total_per_player)\n best_score = 0\n winner = ''\n total_per_player.each do |player_name,total|\n\n if total > best_score\n best_score = total\n winner = player_name\n end\n end\n return winner\n end", "def highest_score\n sort\n all.first.score\n end", "def best_score\n submissions.min(:score)\n end", "def calculate_team_points\n # If the bracket is complete, we can calculate points based on the\n # teams' `final_rank`s.\n if @state == \"complete\"\n calculate_team_points_by_final_rank\n return\n end\n\n # For each team, look at the matches that it is in, look at the point\n # values of those matches, and take the maximum point value. That's the\n # number of points that the team has earned so far in the bracket.\n base_point_value = @config.base_point_value\n\n @teams.each do |team|\n matches_with_team = @matches.select { |match| match.has_team?(team.id) }\n\n puts \"Team #{team.name} was in #{matches_with_team.size} matches\"\n\n points_earned = matches_with_team.max_by(&:points).points\n\n puts \"The largest point value of those matches is #{points_earned}\" \\\n \"#{\" + #{base_point_value} base\" if base_point_value > 0}\"\n\n team.points = points_earned + base_point_value\n end\n end", "def winning_team\n home_points = 0\n away_points = 0\n result = \"\"\n i = 0\n game_hash.each do |team, about|\n about[:players].each do |name , stats|\n if i == 0\n home_points += stats[:points]\n else\n away_points += stats[:points]\n end\n end\n i += 1\n end\n home_points > away_points ? result = game_hash[:home][:team_name] : result = game_hash[:away][:team_name]\nend", "def get_max_past_teammates(participant)\n past_team_associations = TeamsUser.find_all_by_user_id(participant.user_id)\n past_team_associations -= TeamsUser.find_all_by_team_id(id)\n past_team_ids = past_team_associations.map{|association| association.team_id}\n past_teams = past_team_ids.map{|team_id| Team.find_by_id(team_id)}\n past_assignments = past_teams.map{|team| Assignment.find_by_id(team.parent_id)}\n past_assignments.delete_if {|assignment| assignment.course_id != Assignment.find_by_id(parent_id).course_id}\n return past_assignments.inject(0) {|sum, assignment| sum += assignment.team_count - 1}\n end", "def winning_team\n nets = []\n hornets = []\n\n game_hash.values.each do |nets_stats|\n if nets_stats[:team_name] == \"Brooklyn Nets\"\n nets_stats[:players].each do |bk|\n nets << bk[:points]\n end\n end\n end\n\n game_hash.values.each do |hornets_stats|\n if hornets_stats[:team_name] == \"Charlotte Hornets\"\n hornets_stats[:players].each do |ch|\n hornets << ch[:points]\n end\n end\n end\n\n if nets.reduce(:+) > hornets.reduce(:+)\n return \"Brooklyn Nets\"\n else\n return \"Charlotte Hornets\"\n end\nend", "def favorite_opponent(team_id)\n team_id = team_id.to_i\n team = @teams.select { |each_team| each_team.team_id == team_id }.first\n favorite_opponent_id = team.matchup_win_percentage.max_by{|each_team, percentage| percentage}.first\n @teams.select { |each_team| each_team.team_id == favorite_opponent_id }.first.team_name\n end", "def test_average_goals_per_game\n\n assert_equal 4.22, @stat_tracker.average_goals_per_game\n end", "def most_points_scored\n most_points_scored = 0\n player_with_the_most_points_scored = \"\"\n game_hash.each do |team,info|\n info.each do |team_info,team_data|\n if team_data.is_a? (Array) \n if team_info != :colors\n team_data.each do |player_index|\n if most_points_scored == 0 || player_index[:points] > most_points_scored \n most_points_scored = player_index[:points]\n player_with_the_most_points_scored = player_index[:player_name]\n end\n end\n end\n end\n end\n end\n player_with_the_most_points_scored\nend", "def points_in_team(team)\r\n perfs = self.performances.where(team: team)\r\n perfs.map(&:points).inject(:+) / perfs.length\r\n end", "def most_popular_venue\n venues = @games.group_by { |game| game.venue}\n venues.max_by { |venue, games| games.count }.first\n end", "def most_steal\n steals_array = []\n \n game_hash.each do |key, value|\n players = value[:players]\n players.each do |element|\n steals_array << element[:steals]\n end\n end\n steals_array.max\nend", "def most_points_scored()\n points = 0\n result = \"\"\n\n game_hash.each do |side,team|\n team.each do |specs,info|\n if specs == :players\n info.each do |player|\n if player[:points] > points\n points = player[:points]\n result = player[:player_name]\n\n end\n end\n end\n end\n end\n result\nend", "def winner_team(game)\n result = nil\n if game.team1_goals.present? && game.team2_goals.present?\n result = game.team1 if game.team1_goals > game.team2_goals\n result = game.team2 if game.team1_goals < game.team2_goals\n end\n\n result\n end", "def biggest_shoe\r\n player_name= []\r\n game_hash.each do |team, data|\r\n data.each do |team_info, value|\r\n if team_info == \"players\".to_sym\r\n obj=value.max_by {|key, value| value[:shoe]}\r\n player_name<< obj.first\r\n end\r\n end\r\n end\r\n player_name.first\r\nend", "def max_score\n return score if @state != STATE_OK\n\n next_boards.map(&:min_score).min\n end", "def goals_for()\n\t self.as_regular_contestants.select{|c| c.score}.collect{|c| c.score}.inject{|gf, c| gf + c} || 0\n\tend" ]
[ "0.7942869", "0.7871697", "0.7831481", "0.77460885", "0.7745515", "0.77451336", "0.7736173", "0.7715104", "0.7661803", "0.76352316", "0.7570155", "0.75428635", "0.73730713", "0.735033", "0.7304062", "0.72660065", "0.71962935", "0.70869416", "0.70550275", "0.70122427", "0.7005578", "0.69530475", "0.69089276", "0.6868838", "0.6868583", "0.68519706", "0.68408847", "0.6750487", "0.6744813", "0.67289776", "0.67137855", "0.6698323", "0.6690738", "0.6675144", "0.66748625", "0.6668915", "0.6649951", "0.6640413", "0.6629703", "0.66264045", "0.66254926", "0.66123796", "0.66078895", "0.65947115", "0.6587837", "0.65759176", "0.6550289", "0.65439105", "0.65411824", "0.6532234", "0.6519704", "0.6518168", "0.64828193", "0.64687425", "0.64604396", "0.6457863", "0.6454228", "0.6452944", "0.6434628", "0.64314216", "0.6427305", "0.64140874", "0.6412722", "0.6408465", "0.64079034", "0.6404753", "0.6394532", "0.6378452", "0.63659537", "0.6331194", "0.632319", "0.63180447", "0.63180447", "0.6317078", "0.6314", "0.631278", "0.6284354", "0.62777674", "0.62472683", "0.6237536", "0.6236497", "0.6233531", "0.62254536", "0.6224346", "0.6218792", "0.62173116", "0.62152755", "0.62120634", "0.61917824", "0.619162", "0.6189698", "0.617735", "0.6170935", "0.6164207", "0.61630714", "0.61606836", "0.61604583", "0.6160443", "0.61573553", "0.61553127" ]
0.7922498
1
returns team with highest average away goals
def highest_scoring_visitor @teams.max_by { |team| team.average_away_goals }.team_name end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def worst_offense\n teams_total_goals = total_goals_helper\n teams_total_games = total_games_helper\n\n worst_team_goals_avg = 1000\n worst_offense_team_id = 0\n this_team_goals_avg = 0\n\n teams_total_games.each do |games_key, games_value|\n teams_total_goals.each do |goals_key, goals_value|\n if goals_key == games_key\n this_team_goals_avg = (goals_value / games_value.to_f)\n if this_team_goals_avg < worst_team_goals_avg\n worst_team_goals_avg = this_team_goals_avg\n worst_offense_team_id = games_key\n end\n end\n end\n end\n\n team_with_worst_offense = nil\n self.teams.each_value do |team_obj|\n if team_obj.team_id. == worst_offense_team_id\n team_with_worst_offense = team_obj.team_name\n end\n end\n team_with_worst_offense\n end", "def best_offense\n @teams.max_by { |team| team.average_goals_scored }.team_name\n end", "def highest_scoring_home_team\n @teams.max_by { |team| team.average_home_goals }.team_name\n end", "def worst_defense\n teams_total_goals_allowed = total_goals_allowed_helper\n teams_total_games = total_games_helper\n\n worst_team_goals_allowed_avg = 0\n worst_defense_team_id = 0\n this_team_goals_allowed_avg = 0\n\n teams_total_games.each do |games_key, games_value|\n\n teams_total_goals_allowed.each do |goals_key, goals_value|\n if goals_key == games_key\n this_team_goals_allowed_avg = (goals_value / games_value.to_f)\n if this_team_goals_allowed_avg > worst_team_goals_allowed_avg\n worst_team_goals_allowed_avg = this_team_goals_allowed_avg\n worst_defense_team_id = games_key\n end\n end\n end\n end\n team_with_worst_defense = team_name_finder_helper(worst_defense_team_id)\n\n team_with_worst_defense\n end", "def worst_offense\n @teams.min_by { |team| team.average_goals_scored }.team_name\n end", "def average_goals_per_game\n total_goals = @teams.map {|team| team.total_goals_scored}.sum\n total_games = @teams.map {|team| team.home_games}.sum\n (total_goals.to_f / total_games.to_f).round(2)\n end", "def worst_defense\n @teams.max_by { |team| team.average_goals_allowed }.team_name\n end", "def highest_total_score\n total_goals.max\n end", "def most_goals_scored(team_id)\n team_id = team_id.to_i\n goals_per_game = @game_teams.map do |game|\n if game.team_id == team_id\n game.goals\n end\n end\n goals_per_game.compact.max\n end", "def best_defense\n teams_total_goals_allowed = total_goals_allowed_helper\n teams_total_games = total_games_helper\n\n best_team_goals_allowed_avg = 100\n best_defense_team_id = 0\n this_team_goals_allowed_avg = 0\n\n teams_total_games.each do |games_key, games_value|\n teams_total_goals_allowed.each do |goals_key, goals_value|\n if goals_key == games_key\n this_team_goals_allowed_avg = (goals_value / games_value.to_f)\n if this_team_goals_allowed_avg < best_team_goals_allowed_avg\n best_team_goals_allowed_avg = this_team_goals_allowed_avg\n best_defense_team_id = games_key\n end\n end\n end\n end\n\n team_with_best_defense = nil\n self.teams.each_value do |team_obj|\n if team_obj.team_id. == best_defense_team_id\n team_with_best_defense = team_obj.team_name\n end\n end\n team_with_best_defense\n end", "def biggest_blowout\n score_difference = games.map { |game| (game.home_goals - game.away_goals).abs}\n score_difference.max\n end", "def worst_loss(team_id)\n @games.map do |game|\n if game.away_team_id.to_s == team_id\n game.home_goals - game.away_goals\n elsif game.home_team_id.to_s == team_id\n game.away_goals - game.home_goals\n end\n end.compact.max\n end", "def winningest_team\n @teams.max_by { |team| team.total_win_percentage }.team_name\n end", "def best_defense\n @teams.min_by { |team| team.average_goals_allowed }.team_name\n end", "def fewest_goals_scored(team_id)\n team_id = team_id.to_i\n goals_per_game = @game_teams.map do |game|\n if game.team_id == team_id\n game.goals\n end\n end\n goals_per_game.compact.min\n end", "def biggest_team_blowout(team_id)\n @games.map do |game|\n if game.away_team_id.to_s == team_id\n game.away_goals - game.home_goals\n elsif game.home_team_id.to_s == team_id\n game.home_goals - game.away_goals\n end\n end.compact.max\n end", "def best_fans\n @teams.max_by { |team| team.home_minus_away_percentage }.team_name\n end", "def goals_for(team)\n valid = ((team == self.home_team or team == self.away_team) and self.final)\n\n if (valid)\n if (self.home_team == team)\n return self.homeScore\n else\n return self.awayScore\n end\n else\n return 0\n end\n end", "def most_accurate_team(seasonasstring) # shots in game team stats\n #get a list of all teams that played in that season - given by arg\n #use above list to sum all shots across all games in season\n #divide above by goals made across all games in season\n #find highest percentage\n #return team name as found in 127\n end", "def goals_against(team)\n valid = ((team == self.home_team or team == self.away_team) and self.final)\n\n if (valid)\n if (self.home_team == team)\n return self.awayScore\n else\n return self.homeScore\n end\n else\n return 0\n end\n end", "def avg_of_toryo_turn_max\n s = lose_scope\n s = s.joins(:battle)\n s = s.where(Swars::Battle.arel_table[:final_key].eq(\"TORYO\"))\n if v = s.average(Swars::Battle.arel_table[:turn_max])\n v.to_i\n end\n end", "def winning_team\n final_scores = player_collection.reduce(home: 0, away: 0) { |teams_points, next_player|\n case \n when next_player[:location] === :away\n teams_points[:away] += next_player[:points];\n when next_player[:location] === :home\n teams_points[:home] += next_player[:points];\n end\n teams_points; \n }\n winner = final_scores.reduce { |highest_points, team_points| \n highest_points[1] > team_points[1] ? highest_points : team_points; \n }\n game_hash[winner[0]][:team_name]; \nend", "def winning_team\n self.teams.order('score DESC').first\n end", "def player_w_biggest_feet\n all_players[1].max_by { |stats| stats[:shoe] }\n end", "def winning_team\n home_points = collection_by_prop(game_hash[:home], :points).reduce(0, :+)\n away_points = collection_by_prop(game_hash[:away], :points).reduce(0, :+)\n home_points > away_points ? game_hash[:home][:team_name] : game_hash[:away][:team_name]\n end", "def high_score\n if self.end_date < Date.today\n self.teams.max_by { |team| team.score }.score\n end\n end", "def winning_team\n home_team_points = game_hash[:home][:players].sum { |e| e[:points] }\n away_team_points = game_hash[:away][:players].sum { |e| e[:points] }\n\n if home_team_points > away_team_points\n return game_hash[:home][:team_name]\n else\n return game_hash[:away][:team_name]\n end\nend", "def lowest_scoring_visitor\n @teams.min_by { |team| team.average_away_goals }.team_name\n end", "def team_with_more_points(game)\n home_points = game[:home_team][:players].collect do |player|\n player[:stats][:points]\n end.inject {|sum, n| sum + n}\n away_points = game[:away_team][:players].collect do |player|\n player[:stats][:points]\n end.inject {|sum, n| sum + n}\n home_points > away_points ? game[:home_team][:team_name] : game[:away_team][:team_name]\nend", "def average_goals_by_season\n goals_by_season = @games.group_by { |game| game.season.to_s }\n goals_by_season.each do |season, games|\n season_goals = games.map { |game| game.home_goals + game.away_goals }.sum\n goals_by_season[season] = (season_goals.to_f / games.count.to_f).round(2)\n end\n end", "def winning_team\n home_team_sum = 0\n away_team_sum = 0\n game_hash.each do |team, team_stats|\n if team_stats[:team_name] == \"Brooklyn Nets\"\n team_stats[:players].each do |player_stats|\n home_team_sum += player_stats[:points]\n end\n elsif team_stats[:team_name] == \"Charlotte Hornets\"\n team_stats[:players].each do |player_stats|\n away_team_sum += player_stats[:points]\n end\n end\n end\n if home_team_sum > away_team_sum\n game_hash[:home][:team_name]\n elsif home_team_sum < away_team_sum\n game_hash[:away][:team_name]\n end\nend", "def total_team_score(teams_id)\n total_score = 0\n @league_data.each do\n |team| \n # binding.pry\n if team.home_team_id == teams_id\n total_score += team.home_team_score\n elsif team.away_team_id == teams_id\n total_score += team.away_team_score\n end\n end\n return total_score\n end", "def team_average\n # This version is implemented as a database AVG operation,\n # but it cannot be eager loaded so it results in an extra\n # database query for each project:\n #\n # avg = students_projects.select(:points).average :points\n # avg ? avg.round : 0\n\n # This version programmatically finds the average of the points:\n #self.reload\n no_of_students = self.students_projects.length\n return 0 if no_of_students == 0\n total = 0\n self.students_projects.each { |s| total += s.points }\n (total / no_of_students).round\n end", "def mostSteals\n players.max_by do|name, stats|\n stats[:steals]\n end\nend", "def winning_team\n home_score = 0\n away_score = 0\n game_hash[:home][:players].keys.each do |name|\n home_score += game_hash[:home][:players][name][:points]\n end\n game_hash[:away][:players].keys.each do |name|\n away_score += game_hash[:away][:players][name][:points]\n end\n home_score > away_score ? game_hash[:home][:team_name] : game_hash[:away][:team_name]\nend", "def lowest_scoring_home_team\n @teams.min_by { |team| team.average_home_goals }.team_name\n end", "def most_points_scored\n max = nil\n name = nil \n game_hash.each do |team, team_values|\n team_values[:players].each do |player|\n if max == nil || player[:points] > max\n max = player[:points]\n name = player[:player_name]\n end\n end\n end\n name\nend", "def worst_fans\n teams_with_bad_fans = @teams.find_all { |team| team.home_minus_away_percentage.negative? }\n teams_with_bad_fans.map { |team| team.team_name }\n end", "def most_hits(seasonasstring) # shots in game team stats\n #get a list of all teams that played in that season\n #use above list to sum all shots across all games in season\n #find highest across list\n #return team name as found in 139\n end", "def lowest_total_score\n total_game_scores = games.map { |game| game.home_goals + game.away_goals}\n total_game_scores.min\n end", "def highest_total_score\n @game_manager.highest_total_score\n end", "def average_win_percentage(team_id)\n team_id = team_id.to_i\n team = @teams.select { |each_team| each_team.team_id == team_id }.first\n team.total_win_percentage.round(2)\n end", "def winning_team\n if homeTeamPoints.sum > awayTeamPoints.sum\n \"Brooklyn Nets\"\n else\n \"Charlotte Hornets\"\n end\nend", "def winning_team\n team_p = []\n team_n = []\n\n game_hash.each do | location, team_data|\n temp = 0\n team_data[:players].each do |p_name, stats|\n temp += stats[:points]\n end\n team_n << team_data[:team_name]\n team_p << temp\n end\n\n team_p[0] > team_p[1] ? team_n[0] : team_n[1]\n\nend", "def worst_season(team_id)\n team_id = team_id.to_i\n team = @teams.select { |each_team| each_team.team_id == team_id }.first\n team.season_win_percentages.min_by { |season, percentage| percentage }.first.to_s\n end", "def best_offense\n offense_suite\n best_offense_id = @average_goals_by_id.invert.max[1]\n @team_name_by_id[best_offense_id]\n end", "def best_season(team_id)\n team_id = team_id.to_i\n team = @teams.select { |each_team| each_team.team_id == team_id }.first\n team.season_win_percentages.max_by { |season, percentage| percentage }.first.to_s\n end", "def determine_winner game\n winner = game.max_by {|team| team[:score]}\n team_standings = get_team_by_name(winner)\n team_standings[:winnings] += 3\nend", "def winning_team\n home_points = 0\n away_points = 0\n result = \"\"\n i = 0\n game_hash.each do |team, about|\n about[:players].each do |name , stats|\n if i == 0\n home_points += stats[:points]\n else\n away_points += stats[:points]\n end\n end\n i += 1\n end\n home_points > away_points ? result = game_hash[:home][:team_name] : result = game_hash[:away][:team_name]\nend", "def teams_with_score_max(a_game)\n teams_with_score_max = {}\n game_teams_with_score_max = a_game.teams_with_score_max(a_game.game_teams)\n game_teams_with_score_max.each do |game_team_with_score_max|\n # find team instance matching game_team instance\n team_with_score_max = @teams[game_team_with_score_max.name.to_sym]\n teams_with_score_max[game_team_with_score_max.name.to_sym] = team_with_score_max\n end\n teams_with_score_max\n end", "def most_points_scored\n most_points = 0\n most_points_player = nil\n game_hash.each do |team, team_stats|\n team_stats[:players].each do |player_stats|\n if most_points < player_stats[:points]\n most_points = player_stats[:points]\n most_points_player = player_stats[:player_name]\n end\n end\n end\n most_points_player\nend", "def rank_top_teams # DO NOT USE THIS METHOD, outdated, slow\n @top_teams = {}\n @top_teams = Score.in_challenge(self.id).teams_in_all_divisions.limit(5).\n order(\"sum_points DESC, MAX(#{Score.table_name}.\n earned_at) DESC\").sum(:points) \n return @top_teams\n end", "def get_standings(games)\n teams = Hash.new\n games.each do |game|\n division_id = game.division_id\n home_team = game.home_team\n away_team = game.visiting_team\n if(teams[home_team.name].nil?)\n teams[home_team.name] = {:win => 0, :loss => 0, :tie => 0, :point=> 0}\n end\n\n if(teams[away_team.name].nil?)\n teams[away_team.name] = {:win => 0, :loss => 0, :tie => 0, :point => 0}\n end\n if(game.home_team_score && game.visiting_team_score)\n if(game.home_team_score > game.visiting_team_score)\n # home team won\n teams[home_team.name][:win] += 1\n teams[home_team.name][:point] += 5\n # visiting team loss\n teams[away_team.name][:loss] += 1\n elsif(game.home_team_score < game.visiting_team_score)\n # home team loss\n teams[home_team.name][:loss] += 1\n #visiting team won\n teams[away_team.name][:win] += 1\n teams[away_team.name][:point] += 5\n else\n # tie game\n teams[home_team.name][:tie] += 1\n teams[home_team.name][:point] += 1\n teams[away_team.name][:tie] += 1\n teams[away_team.name][:point] += 1\n end\n end\n end\n teams.each do |team, value|\n puts team\n total_games = value[:win] + value[:loss] + value[:tie]\n if total_games > 0 \n win_percentage = value[:win]/total_games.to_f\n else\n win_percentage = 0\n end \n value[:percentage] = win_percentage\n end\n teams_sorted = teams.sort_by{ |k, v| v[:point]}.reverse\n return teams_sorted\n end", "def highest_player_score\n players.max_by{|player| player.score}.score\n end", "def get_max_over(stat)\n max = 0\n $data_enemies.each { |enemy|\n next if enemy.nil?\n next if enemy.hidden_best\n next unless $game_party.known_enemy?(enemy.id)\n value = enemy.get_stat(stat)\n max = value if value > max\n }\n max\n end", "def most_points(game)\n player_name_with_points = []\n game[:home_team][:players].each do |player_hash|\n player_name_with_points << {player_hash[:player_name] => player_hash[:stats][:points]}\n end\n game[:away_team][:players].each do |player_hash|\n player_name_with_points << {player_hash[:player_name] => player_hash[:stats][:points]}\n end\n player_most_points = {\"test\" => 0}\n player_name_with_points.each do |name_and_points_hash|\n player_most_points = name_and_points_hash if name_and_points_hash.values[0] > player_most_points.values[0]\n end\n player_most_points.keys[0]\nend", "def pri_toff\n team_stats.goals_per_game / team_stats.opp_avg_goals_per_game\n end", "def most_steals \n num_steals = 0\n game_hash.each do |team,info|\n info.each do |team_info,team_data|\n if team_data.is_a? (Array) \n if team_info != :colors\n team_data.each do |player_index|\n if num_steals == 0 || player_index[:steals] > num_steals \n num_steals = player_index[:steals] \n end\n end\n end\n end\n end\n end\nnum_steals\nend", "def most_points_scored\n points_scored = 0 # starting score to compare with players shoe sizes\n game_hash.each do |location, team_data| # iterates through each team\n players_array = team_data[:players] # finds the :players info in team_data and puts the players into players_array\n players_array.each do |player_name, data| # iterates through each player..\n if data[:points] > points_scored # if their points scored is greater than 0 (we set this earlier in the top of method)\n points_scored = data[:shoe] # take that players score and make it the new points_scored value\n end # this repeats (iterates) through all players until you don't have any more.. meaning the end result is\n end # the player with the highest score\n end\n return points_scored\nend", "def biggest_surprise(season)\n season = season.to_i\n @teams.max_by{ |team| team.preseason_to_regular_increase[season] }.team_name\n end", "def winner_team(game)\n result = nil\n if game.team1_goals.present? && game.team2_goals.present?\n result = game.team1 if game.team1_goals > game.team2_goals\n result = game.team2 if game.team1_goals < game.team2_goals\n end\n\n result\n end", "def calculate_team_ranking_score(number_of_meetings = 2, number_of_bests = 3)\n team_ranking_results = []\n events = []\n if @badge.category_type.code != 'U25' &&\n @badge.meetings.distinct.count >= number_of_meetings\n get_results.each do |meeting_individual_result|\n next unless meeting_individual_result.get_scheduled_date.year - @swimmer.year_of_birth >= 25\n\n next if events.include?(meeting_individual_result.event_type.code)\n\n team_ranking_results << meeting_individual_result\n events << meeting_individual_result.event_type.code\n break if team_ranking_results.count == number_of_bests\n end\n end\n BestLimitedRankingDAO.new(team_ranking_results)\n end", "def big_shoe_rebounds\n max_shoe = 0 \n max_rebounds = 0 \n game_hash.each do |place, team|\n # team.each do |attribute, data|\n team[:players].each do |player|\n if player[:shoe] > max_shoe\n max_shoe = player[:shoe]\n max_rebounds = player[:rebounds]\n # if attribute == :players\n # data.each do |player|\n #this gives me the player hashes\n # data.max_by{|player| player[:shoe] }\n # data.max_by{|player| player[:shoe] }[:rebounds]\n # player.max_by{|player| player[:shoe] \n # player.max_by{|player| player[:shoe] }[:rebounds]\n end\n end\n end\n return max_rebounds\n end", "def favorite_opponent(team_id)\n team_id = team_id.to_i\n team = @teams.select { |each_team| each_team.team_id == team_id }.first\n favorite_opponent_id = team.matchup_win_percentage.max_by{|each_team, percentage| percentage}.first\n @teams.select { |each_team| each_team.team_id == favorite_opponent_id }.first.team_name\n end", "def pri_tdef\n team_stats.opp_goals_per_game / team_stats.opp_avg_goals_against_per_game\n end", "def total_score\n @all_games.map do |games|\n games[\"home_goals\"].to_i + games[\"away_goals\"].to_i\n end\n end", "def most_steals(game)\nmax_steals = 0\nmax_steals_player = \"\"\ngame.each do |team, team_contents|\n team_contents[:roster].each do |player, player_contents| \n if player_contents[:steals] == max_steals\n max_steals_player = max_steals_player + \" and #{player_contents[:player_name]}\"\n elsif player_contents[:steals] > max_steals\n max_steals = player_contents[:steals]\n max_steals_player = player_contents[:player_name]\n end\n end\nend\nmax_steals_player\nend", "def goals_against()\n\t self.as_regular_contestants.select{|c| c.opponent.score}.collect{|c| c.opponent.score}.inject{|gf, c| gf + c} || 0\n\tend", "def most_points_scored\nbest_player = \"\"\npoints = 0\ngame_hash.each do |location, team_data|\n team_data[:players].each do |name, stats|\n if stats[:points] > points\n points = stats[:points]\n best_player= name\n end\n end\nend\nbest_player\nend", "def winning_team\n points_home = 0\n points_away = 0\n result = \"\"\n\n game_hash.each do |side,team|\n team.each do |specs,info|\n if specs == :players\n info.each do |player|\n if side = :home\n points_home += player[:points]\n else\n points_away += player[:points]\n end\n end\n end\n end\n end\n if points_home > points_away\n result = game_hash[:home][:team_name]\n else\n result = game_hash[:away][:team_name]\n end\n result\nend", "def away_stat\n @away.team_stat\n end", "def player_with_most_steals\n name = \"\"\n most_steals = 0\n\n game_hash.each do | team, details_hash |\n players_array = details_hash[:players]\n players_array.each do | player_details_hash |\n if player_details_hash[:steals] > most_steals\n most_steals = player_details_hash[:steals]\n name = player_details_hash[:player_name]\n end\n end\n end\n name\nend", "def goals_by_hoa_id_suite\n goals_by_away_id\n goals_by_home_id\n average_score_per_away_game_by_team_id\n average_score_per_home_game_by_team_id\n end", "def goals_by_hoa_id_suite\n goals_by_away_id\n goals_by_home_id\n average_score_per_away_game_by_team_id\n average_score_per_home_game_by_team_id\n end", "def test_average_goals_per_game\n\n assert_equal 4.22, @stat_tracker.average_goals_per_game\n end", "def goal_difference\n total_diff = 0\n\n wattball_matches_as_team1.each do |match|\n total_diff += match.goal_difference[0]\n end\n\n wattball_matches_as_team2.each do |match|\n total_diff += match.goal_difference[1]\n end\n \n total_diff\n end", "def most_points_scored\n most_points = 0\n player = \"\"\n game_hash.each do |k, team|\n team[:players].each do |e|\n if e[:points] > most_points\n most_points = e[:points]\n player = e[:player_name]\n end\n end\n end\n player\nend", "def winning_team\n home_points = 0\n away_points = 0\n team1 = \"Brooklyn Nets\"\n team2 = \"Charlotte Hornets\"\n game_hash.each do |team,info|\n info.each do |team_info,team_data|\n if team_data.is_a? (Array) \n if team_info != :colors\n if info[:team_name] == \"Brooklyn Nets\"\n team_data.each do |player_index|\n home_points += player_index[:points]\n end\n else \n team_data.each do |player_index|\n away_points += player_index[:points]\n winning_team end\n end\n end\n end\n end\n end\n\n if home_points > away_points\n team1\n else\n team2\n end\n\nend", "def most_points_scored\n stat_by_player = collect_stat_by_name(:points)\n player_with_max_stat = find_max_stat_by_player(stat_by_player)\n player_with_max_stat\nend", "def batting_average(year: nil, team: nil)\n hits, at_bats = 0, 0\n\n seasonal_stats.each do |stat_line|\n year_match = stat_line.year == year || year == nil\n team_match = stat_line.team == team || team == nil\n if year_match && team_match\n hits += stat_line.hits\n at_bats += stat_line.at_bats\n end\n end\n\n if (at_bats != 0)\n return (hits.to_f / at_bats)\n else\n return 0.0\n end\n end", "def mostPoints\n players.max_by do|name, stats|\n stats[:points]\n end\nend", "def biggestShoes\n players.max_by do|name, stats|\n stats[:shoe]\n end\nend", "def calculate_score(team)\n scores.includes(:wattball_player).where(:wattball_players => {:team_id => team}).sum(:amount) \n end", "def most_points(game)\nmax_points = 0\nmax_points_player = \"\"\ngame.each do |team, team_contents|\n team_contents[:roster].each do |player, player_contents| \n if player_contents[:points] == max_points\n max_points_player = max_points_player + \" and #{player_contents[:player_name]}\"\n elsif player_contents[:points] > max_points\n max_points = player_contents[:points]\n max_points_player = player_contents[:player_name]\n end\n end\nend\nputs \"#{max_points_player} scored #{max_points}\"\nend", "def most_steals\r\n result={}\r\n game_hash.each do |k, v|\r\n v.each do| p, d|\r\n if p==:players\r\n d.each do |t, s|\r\n result[t]=s[:steals]\r\n end\r\n end\r\n end\r\n end \r\n result.max_by {|name, steal| steal}[0]\r\nend", "def winning_team\n nets = []\n hornets = []\n\n game_hash.values.each do |nets_stats|\n if nets_stats[:team_name] == \"Brooklyn Nets\"\n nets_stats[:players].each do |bk|\n nets << bk[:points]\n end\n end\n end\n\n game_hash.values.each do |hornets_stats|\n if hornets_stats[:team_name] == \"Charlotte Hornets\"\n hornets_stats[:players].each do |ch|\n hornets << ch[:points]\n end\n end\n end\n\n if nets.reduce(:+) > hornets.reduce(:+)\n return \"Brooklyn Nets\"\n else\n return \"Charlotte Hornets\"\n end\nend", "def most_points_scored\n\tpoints_array = []\n\tgame_hash.each do |location, team_data|\n\t\tteam_data[:players].each do |attribute, data|\t\n\t\t\tdata.each do |type, amount|\n\t\t\t\tif type == :points\n\t\t\t\t\tpoints_array << amount\n\t\t\t\tend \n\t\t\tend\n\t\tend\n\tend\n\tgame_hash.each do |l, data|\n\t\tdata[:players].each do |a, d|\n\t\t\td.each do |t, amt|\n\t\t\t\tif t == :points && points_array.max == amt\n\t\t\t\t\treturn a\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend\nend", "def biggest_shoe\r\n player_name= []\r\n game_hash.each do |team, data|\r\n data.each do |team_info, value|\r\n if team_info == \"players\".to_sym\r\n obj=value.max_by {|key, value| value[:shoe]}\r\n player_name<< obj.first\r\n end\r\n end\r\n end\r\n player_name.first\r\nend", "def winning_scores\n high_score = scores.max{|score| score.total}.total\n scores.select {|score| score.total == high_score}\n end", "def load_stats\n[\n {\n home_team: \"Jets\",\n away_team: \"Giants\",\n home_score: 21,\n away_score: 3\n },\n {\n home_team: \"Steelers\",\n away_team: \"Giants\",\n home_score: 21,\n away_score: 3\n },\n {\n home_team: \"Patriots\",\n away_team: \"Giants\",\n home_score: 21,\n away_score: 3\n },\n {\n home_team: \"Chargers\",\n away_team: \"Jets\",\n home_score: 13,\n away_score: 6\n },\n {\n home_team: \"Patriots\",\n away_team: \"Jets\",\n home_score: 13,\n away_score: 6\n },\n {\n home_team: \"Steelers\",\n away_team: \"Jets\",\n home_score: 3,\n away_score: 6\n },\n {\n home_team: \"Dolphins\",\n away_team: \"Jets\",\n home_score: 0,\n away_score: 3\n },\n{\n home_team: \"Browns\",\n away_team: \"Jets\",\n home_score: 0,\n away_score: 21\n },\n {\n home_team: \"Chargers\",\n away_team: \"Jets\",\n home_score: 7,\n away_score: 21\n },\n {\n home_team: \"Steelers\",\n away_team: \"Broncos\",\n home_score: 7,\n away_score: 13\n },\n {\n home_team: \"Patriots\",\n away_team: \"Broncos\",\n home_score: 7,\n away_score: 3\n },\n {\n home_team: \"Broncos\",\n away_team: \"Colts\",\n home_score: 3,\n away_score: 0\n },\n {\n home_team: \"Patriots\",\n away_team: \"Colts\",\n home_score: 11,\n away_score: 7\n },\n {\n home_team: \"Steelers\",\n away_team: \"Patriots\",\n home_score: 7,\n away_score: 21\n },\n {\n home_team: \"Steelers\",\n away_team: \"Colts\",\n home_score: 24,\n away_score: 21\n },\n {\n home_team: \"Steelers\",\n away_team: \"Colts\",\n home_score: 24,\n away_score: 21\n }\n]\nend", "def highest_score\n sort\n all.first.score\n end", "def percentage_visitor_wins\n visitor_wins = @teams.map { |team| team.away_wins }.sum\n visitor_games = @teams.map { |team| team.away_games }.sum\n (visitor_wins.to_f / visitor_games.to_f).round(2)\n end", "def score_for_team(team)\n team ||= winner_team\n winner_team?(team) ? score : scores.reverse.join(':')\n end", "def calculate_final_score\n self.scores.average(:total_score)\n end", "def get_max_past_teammates(participant)\n past_team_associations = TeamsUser.find_all_by_user_id(participant.user_id)\n past_team_associations -= TeamsUser.find_all_by_team_id(id)\n past_team_ids = past_team_associations.map{|association| association.team_id}\n past_teams = past_team_ids.map{|team_id| Team.find_by_id(team_id)}\n past_assignments = past_teams.map{|team| Assignment.find_by_id(team.parent_id)}\n past_assignments.delete_if {|assignment| assignment.course_id != Assignment.find_by_id(parent_id).course_id}\n return past_assignments.inject(0) {|sum, assignment| sum += assignment.team_count - 1}\n end", "def big_shoe_rebounds\n\nhighest_rebounds = 0\nbiggest_shoe = 0\n\n game_hash.each do |location, team_info|\n game_hash.dig(location, :players).each do |player_name, stats|\n stats.each do |stat, number|\n if stat == :shoe\n if number > biggest_shoe\n biggest_shoe = number\n stats.each do |stat, number|\n if stat == :rebounds\n highest_rebounds = number\n end\n end\n end\n end\n end\n end\n end\n puts highest_rebounds\n return highest_rebounds\nend", "def biggest_investment\n funding_rounds.max_by {|funding_round| funding_round.investment}\n end", "def calculate_team_points\n # If the bracket is complete, we can calculate points based on the\n # teams' `final_rank`s.\n if @state == \"complete\"\n calculate_team_points_by_final_rank\n return\n end\n\n # For each team, look at the matches that it is in, look at the point\n # values of those matches, and take the maximum point value. That's the\n # number of points that the team has earned so far in the bracket.\n base_point_value = @config.base_point_value\n\n @teams.each do |team|\n matches_with_team = @matches.select { |match| match.has_team?(team.id) }\n\n puts \"Team #{team.name} was in #{matches_with_team.size} matches\"\n\n points_earned = matches_with_team.max_by(&:points).points\n\n puts \"The largest point value of those matches is #{points_earned}\" \\\n \"#{\" + #{base_point_value} base\" if base_point_value > 0}\"\n\n team.points = points_earned + base_point_value\n end\n end", "def biggest_investment\n self.funding_rounds.max_by {|funding| funding.investment }\n end", "def player_with_most_steal\n most_steals = nil\n most_steal_player = nil\n\n all_players(game_hash).each do |player|\n if most_steals == nil || player[:steals] > most_steals\n most_steals = player[:steals]\n most_steal_player = player[:player_name]\n end\n end\n\n most_steal_player\nend" ]
[ "0.8070359", "0.7879713", "0.7840369", "0.7836435", "0.78173316", "0.78173184", "0.77899235", "0.7775409", "0.76927173", "0.7652448", "0.75883156", "0.7549996", "0.74793136", "0.743047", "0.7401185", "0.73860943", "0.7366877", "0.72851044", "0.7222358", "0.7200977", "0.7026634", "0.70081896", "0.6997021", "0.6955576", "0.69469726", "0.69278085", "0.68835014", "0.68523705", "0.6846296", "0.6835432", "0.68307126", "0.680511", "0.680024", "0.6794969", "0.6755046", "0.67446166", "0.67363703", "0.67035806", "0.66844344", "0.6649976", "0.6611029", "0.6609161", "0.6605823", "0.65873283", "0.6579164", "0.657076", "0.6550384", "0.65493727", "0.6509618", "0.6483948", "0.6474997", "0.6473451", "0.6467088", "0.64593005", "0.64521646", "0.6444501", "0.6438089", "0.64198714", "0.6418062", "0.6404755", "0.6404119", "0.6398259", "0.6395798", "0.63825417", "0.63733053", "0.636655", "0.63574433", "0.63470995", "0.6330617", "0.63275826", "0.6326714", "0.63199586", "0.63049126", "0.63049126", "0.6301845", "0.62873083", "0.6286333", "0.6284886", "0.62838167", "0.6282789", "0.62807506", "0.62733066", "0.6269089", "0.6267985", "0.6265032", "0.6251448", "0.62240255", "0.6220655", "0.6211669", "0.6200857", "0.6194574", "0.61824924", "0.6178828", "0.6173567", "0.61715996", "0.6168693", "0.6168494", "0.6161734", "0.61574745", "0.61566025" ]
0.79167306
1
returns team with highest average home goals
def highest_scoring_home_team @teams.max_by { |team| team.average_home_goals }.team_name end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def average_goals_per_game\n total_goals = @teams.map {|team| team.total_goals_scored}.sum\n total_games = @teams.map {|team| team.home_games}.sum\n (total_goals.to_f / total_games.to_f).round(2)\n end", "def worst_offense\n teams_total_goals = total_goals_helper\n teams_total_games = total_games_helper\n\n worst_team_goals_avg = 1000\n worst_offense_team_id = 0\n this_team_goals_avg = 0\n\n teams_total_games.each do |games_key, games_value|\n teams_total_goals.each do |goals_key, goals_value|\n if goals_key == games_key\n this_team_goals_avg = (goals_value / games_value.to_f)\n if this_team_goals_avg < worst_team_goals_avg\n worst_team_goals_avg = this_team_goals_avg\n worst_offense_team_id = games_key\n end\n end\n end\n end\n\n team_with_worst_offense = nil\n self.teams.each_value do |team_obj|\n if team_obj.team_id. == worst_offense_team_id\n team_with_worst_offense = team_obj.team_name\n end\n end\n team_with_worst_offense\n end", "def highest_scoring_visitor\n @teams.max_by { |team| team.average_away_goals }.team_name\n end", "def worst_defense\n teams_total_goals_allowed = total_goals_allowed_helper\n teams_total_games = total_games_helper\n\n worst_team_goals_allowed_avg = 0\n worst_defense_team_id = 0\n this_team_goals_allowed_avg = 0\n\n teams_total_games.each do |games_key, games_value|\n\n teams_total_goals_allowed.each do |goals_key, goals_value|\n if goals_key == games_key\n this_team_goals_allowed_avg = (goals_value / games_value.to_f)\n if this_team_goals_allowed_avg > worst_team_goals_allowed_avg\n worst_team_goals_allowed_avg = this_team_goals_allowed_avg\n worst_defense_team_id = games_key\n end\n end\n end\n end\n team_with_worst_defense = team_name_finder_helper(worst_defense_team_id)\n\n team_with_worst_defense\n end", "def best_defense\n teams_total_goals_allowed = total_goals_allowed_helper\n teams_total_games = total_games_helper\n\n best_team_goals_allowed_avg = 100\n best_defense_team_id = 0\n this_team_goals_allowed_avg = 0\n\n teams_total_games.each do |games_key, games_value|\n teams_total_goals_allowed.each do |goals_key, goals_value|\n if goals_key == games_key\n this_team_goals_allowed_avg = (goals_value / games_value.to_f)\n if this_team_goals_allowed_avg < best_team_goals_allowed_avg\n best_team_goals_allowed_avg = this_team_goals_allowed_avg\n best_defense_team_id = games_key\n end\n end\n end\n end\n\n team_with_best_defense = nil\n self.teams.each_value do |team_obj|\n if team_obj.team_id. == best_defense_team_id\n team_with_best_defense = team_obj.team_name\n end\n end\n team_with_best_defense\n end", "def best_offense\n @teams.max_by { |team| team.average_goals_scored }.team_name\n end", "def highest_total_score\n total_goals.max\n end", "def worst_offense\n @teams.min_by { |team| team.average_goals_scored }.team_name\n end", "def goals_for(team)\n valid = ((team == self.home_team or team == self.away_team) and self.final)\n\n if (valid)\n if (self.home_team == team)\n return self.homeScore\n else\n return self.awayScore\n end\n else\n return 0\n end\n end", "def worst_defense\n @teams.max_by { |team| team.average_goals_allowed }.team_name\n end", "def best_fans\n @teams.max_by { |team| team.home_minus_away_percentage }.team_name\n end", "def lowest_scoring_home_team\n @teams.min_by { |team| team.average_home_goals }.team_name\n end", "def goals_against(team)\n valid = ((team == self.home_team or team == self.away_team) and self.final)\n\n if (valid)\n if (self.home_team == team)\n return self.awayScore\n else\n return self.homeScore\n end\n else\n return 0\n end\n end", "def most_goals_scored(team_id)\n team_id = team_id.to_i\n goals_per_game = @game_teams.map do |game|\n if game.team_id == team_id\n game.goals\n end\n end\n goals_per_game.compact.max\n end", "def best_defense\n @teams.min_by { |team| team.average_goals_allowed }.team_name\n end", "def biggest_blowout\n score_difference = games.map { |game| (game.home_goals - game.away_goals).abs}\n score_difference.max\n end", "def winningest_team\n @teams.max_by { |team| team.total_win_percentage }.team_name\n end", "def winning_team\n home_points = collection_by_prop(game_hash[:home], :points).reduce(0, :+)\n away_points = collection_by_prop(game_hash[:away], :points).reduce(0, :+)\n home_points > away_points ? game_hash[:home][:team_name] : game_hash[:away][:team_name]\n end", "def most_accurate_team(seasonasstring) # shots in game team stats\n #get a list of all teams that played in that season - given by arg\n #use above list to sum all shots across all games in season\n #divide above by goals made across all games in season\n #find highest percentage\n #return team name as found in 127\n end", "def winning_team\n final_scores = player_collection.reduce(home: 0, away: 0) { |teams_points, next_player|\n case \n when next_player[:location] === :away\n teams_points[:away] += next_player[:points];\n when next_player[:location] === :home\n teams_points[:home] += next_player[:points];\n end\n teams_points; \n }\n winner = final_scores.reduce { |highest_points, team_points| \n highest_points[1] > team_points[1] ? highest_points : team_points; \n }\n game_hash[winner[0]][:team_name]; \nend", "def worst_loss(team_id)\n @games.map do |game|\n if game.away_team_id.to_s == team_id\n game.home_goals - game.away_goals\n elsif game.home_team_id.to_s == team_id\n game.away_goals - game.home_goals\n end\n end.compact.max\n end", "def fewest_goals_scored(team_id)\n team_id = team_id.to_i\n goals_per_game = @game_teams.map do |game|\n if game.team_id == team_id\n game.goals\n end\n end\n goals_per_game.compact.min\n end", "def winning_team\n home_team_sum = 0\n away_team_sum = 0\n game_hash.each do |team, team_stats|\n if team_stats[:team_name] == \"Brooklyn Nets\"\n team_stats[:players].each do |player_stats|\n home_team_sum += player_stats[:points]\n end\n elsif team_stats[:team_name] == \"Charlotte Hornets\"\n team_stats[:players].each do |player_stats|\n away_team_sum += player_stats[:points]\n end\n end\n end\n if home_team_sum > away_team_sum\n game_hash[:home][:team_name]\n elsif home_team_sum < away_team_sum\n game_hash[:away][:team_name]\n end\nend", "def winning_team\n home_team_points = game_hash[:home][:players].sum { |e| e[:points] }\n away_team_points = game_hash[:away][:players].sum { |e| e[:points] }\n\n if home_team_points > away_team_points\n return game_hash[:home][:team_name]\n else\n return game_hash[:away][:team_name]\n end\nend", "def winning_team\n home_score = 0\n away_score = 0\n game_hash[:home][:players].keys.each do |name|\n home_score += game_hash[:home][:players][name][:points]\n end\n game_hash[:away][:players].keys.each do |name|\n away_score += game_hash[:away][:players][name][:points]\n end\n home_score > away_score ? game_hash[:home][:team_name] : game_hash[:away][:team_name]\nend", "def average_goals_by_season\n goals_by_season = @games.group_by { |game| game.season.to_s }\n goals_by_season.each do |season, games|\n season_goals = games.map { |game| game.home_goals + game.away_goals }.sum\n goals_by_season[season] = (season_goals.to_f / games.count.to_f).round(2)\n end\n end", "def percentage_home_wins\n home_wins = @teams.map { |team| team.home_wins }.sum\n home_games = @teams.map { |team| team.home_games }.sum\n (home_wins.to_f / home_games.to_f).round(2)\n end", "def lowest_total_score\n total_game_scores = games.map { |game| game.home_goals + game.away_goals}\n total_game_scores.min\n end", "def lowest_scoring_visitor\n @teams.min_by { |team| team.average_away_goals }.team_name\n end", "def biggest_team_blowout(team_id)\n @games.map do |game|\n if game.away_team_id.to_s == team_id\n game.away_goals - game.home_goals\n elsif game.home_team_id.to_s == team_id\n game.home_goals - game.away_goals\n end\n end.compact.max\n end", "def high_score\n if self.end_date < Date.today\n self.teams.max_by { |team| team.score }.score\n end\n end", "def team_with_more_points(game)\n home_points = game[:home_team][:players].collect do |player|\n player[:stats][:points]\n end.inject {|sum, n| sum + n}\n away_points = game[:away_team][:players].collect do |player|\n player[:stats][:points]\n end.inject {|sum, n| sum + n}\n home_points > away_points ? game[:home_team][:team_name] : game[:away_team][:team_name]\nend", "def winning_team\n self.teams.order('score DESC').first\n end", "def team_average\n # This version is implemented as a database AVG operation,\n # but it cannot be eager loaded so it results in an extra\n # database query for each project:\n #\n # avg = students_projects.select(:points).average :points\n # avg ? avg.round : 0\n\n # This version programmatically finds the average of the points:\n #self.reload\n no_of_students = self.students_projects.length\n return 0 if no_of_students == 0\n total = 0\n self.students_projects.each { |s| total += s.points }\n (total / no_of_students).round\n end", "def player_w_biggest_feet\n all_players[1].max_by { |stats| stats[:shoe] }\n end", "def most_hits(seasonasstring) # shots in game team stats\n #get a list of all teams that played in that season\n #use above list to sum all shots across all games in season\n #find highest across list\n #return team name as found in 139\n end", "def total_team_score(teams_id)\n total_score = 0\n @league_data.each do\n |team| \n # binding.pry\n if team.home_team_id == teams_id\n total_score += team.home_team_score\n elsif team.away_team_id == teams_id\n total_score += team.away_team_score\n end\n end\n return total_score\n end", "def get_standings(games)\n teams = Hash.new\n games.each do |game|\n division_id = game.division_id\n home_team = game.home_team\n away_team = game.visiting_team\n if(teams[home_team.name].nil?)\n teams[home_team.name] = {:win => 0, :loss => 0, :tie => 0, :point=> 0}\n end\n\n if(teams[away_team.name].nil?)\n teams[away_team.name] = {:win => 0, :loss => 0, :tie => 0, :point => 0}\n end\n if(game.home_team_score && game.visiting_team_score)\n if(game.home_team_score > game.visiting_team_score)\n # home team won\n teams[home_team.name][:win] += 1\n teams[home_team.name][:point] += 5\n # visiting team loss\n teams[away_team.name][:loss] += 1\n elsif(game.home_team_score < game.visiting_team_score)\n # home team loss\n teams[home_team.name][:loss] += 1\n #visiting team won\n teams[away_team.name][:win] += 1\n teams[away_team.name][:point] += 5\n else\n # tie game\n teams[home_team.name][:tie] += 1\n teams[home_team.name][:point] += 1\n teams[away_team.name][:tie] += 1\n teams[away_team.name][:point] += 1\n end\n end\n end\n teams.each do |team, value|\n puts team\n total_games = value[:win] + value[:loss] + value[:tie]\n if total_games > 0 \n win_percentage = value[:win]/total_games.to_f\n else\n win_percentage = 0\n end \n value[:percentage] = win_percentage\n end\n teams_sorted = teams.sort_by{ |k, v| v[:point]}.reverse\n return teams_sorted\n end", "def highest_total_score\n @game_manager.highest_total_score\n end", "def avg_of_toryo_turn_max\n s = lose_scope\n s = s.joins(:battle)\n s = s.where(Swars::Battle.arel_table[:final_key].eq(\"TORYO\"))\n if v = s.average(Swars::Battle.arel_table[:turn_max])\n v.to_i\n end\n end", "def calculate_team_ranking_score(number_of_meetings = 2, number_of_bests = 3)\n team_ranking_results = []\n events = []\n if @badge.category_type.code != 'U25' &&\n @badge.meetings.distinct.count >= number_of_meetings\n get_results.each do |meeting_individual_result|\n next unless meeting_individual_result.get_scheduled_date.year - @swimmer.year_of_birth >= 25\n\n next if events.include?(meeting_individual_result.event_type.code)\n\n team_ranking_results << meeting_individual_result\n events << meeting_individual_result.event_type.code\n break if team_ranking_results.count == number_of_bests\n end\n end\n BestLimitedRankingDAO.new(team_ranking_results)\n end", "def winning_team\n home_points = 0\n away_points = 0\n result = \"\"\n i = 0\n game_hash.each do |team, about|\n about[:players].each do |name , stats|\n if i == 0\n home_points += stats[:points]\n else\n away_points += stats[:points]\n end\n end\n i += 1\n end\n home_points > away_points ? result = game_hash[:home][:team_name] : result = game_hash[:away][:team_name]\nend", "def most_points_scored\n max = nil\n name = nil \n game_hash.each do |team, team_values|\n team_values[:players].each do |player|\n if max == nil || player[:points] > max\n max = player[:points]\n name = player[:player_name]\n end\n end\n end\n name\nend", "def most_points(game)\n player_name_with_points = []\n game[:home_team][:players].each do |player_hash|\n player_name_with_points << {player_hash[:player_name] => player_hash[:stats][:points]}\n end\n game[:away_team][:players].each do |player_hash|\n player_name_with_points << {player_hash[:player_name] => player_hash[:stats][:points]}\n end\n player_most_points = {\"test\" => 0}\n player_name_with_points.each do |name_and_points_hash|\n player_most_points = name_and_points_hash if name_and_points_hash.values[0] > player_most_points.values[0]\n end\n player_most_points.keys[0]\nend", "def winning_team\n team_p = []\n team_n = []\n\n game_hash.each do | location, team_data|\n temp = 0\n team_data[:players].each do |p_name, stats|\n temp += stats[:points]\n end\n team_n << team_data[:team_name]\n team_p << temp\n end\n\n team_p[0] > team_p[1] ? team_n[0] : team_n[1]\n\nend", "def rank_top_teams # DO NOT USE THIS METHOD, outdated, slow\n @top_teams = {}\n @top_teams = Score.in_challenge(self.id).teams_in_all_divisions.limit(5).\n order(\"sum_points DESC, MAX(#{Score.table_name}.\n earned_at) DESC\").sum(:points) \n return @top_teams\n end", "def total_score\n @all_games.map do |games|\n games[\"home_goals\"].to_i + games[\"away_goals\"].to_i\n end\n end", "def load_stats\n[\n {\n home_team: \"Jets\",\n away_team: \"Giants\",\n home_score: 21,\n away_score: 3\n },\n {\n home_team: \"Steelers\",\n away_team: \"Giants\",\n home_score: 21,\n away_score: 3\n },\n {\n home_team: \"Patriots\",\n away_team: \"Giants\",\n home_score: 21,\n away_score: 3\n },\n {\n home_team: \"Chargers\",\n away_team: \"Jets\",\n home_score: 13,\n away_score: 6\n },\n {\n home_team: \"Patriots\",\n away_team: \"Jets\",\n home_score: 13,\n away_score: 6\n },\n {\n home_team: \"Steelers\",\n away_team: \"Jets\",\n home_score: 3,\n away_score: 6\n },\n {\n home_team: \"Dolphins\",\n away_team: \"Jets\",\n home_score: 0,\n away_score: 3\n },\n{\n home_team: \"Browns\",\n away_team: \"Jets\",\n home_score: 0,\n away_score: 21\n },\n {\n home_team: \"Chargers\",\n away_team: \"Jets\",\n home_score: 7,\n away_score: 21\n },\n {\n home_team: \"Steelers\",\n away_team: \"Broncos\",\n home_score: 7,\n away_score: 13\n },\n {\n home_team: \"Patriots\",\n away_team: \"Broncos\",\n home_score: 7,\n away_score: 3\n },\n {\n home_team: \"Broncos\",\n away_team: \"Colts\",\n home_score: 3,\n away_score: 0\n },\n {\n home_team: \"Patriots\",\n away_team: \"Colts\",\n home_score: 11,\n away_score: 7\n },\n {\n home_team: \"Steelers\",\n away_team: \"Patriots\",\n home_score: 7,\n away_score: 21\n },\n {\n home_team: \"Steelers\",\n away_team: \"Colts\",\n home_score: 24,\n away_score: 21\n },\n {\n home_team: \"Steelers\",\n away_team: \"Colts\",\n home_score: 24,\n away_score: 21\n }\n]\nend", "def winning_team\n if homeTeamPoints.sum > awayTeamPoints.sum\n \"Brooklyn Nets\"\n else\n \"Charlotte Hornets\"\n end\nend", "def teams_with_score_max(a_game)\n teams_with_score_max = {}\n game_teams_with_score_max = a_game.teams_with_score_max(a_game.game_teams)\n game_teams_with_score_max.each do |game_team_with_score_max|\n # find team instance matching game_team instance\n team_with_score_max = @teams[game_team_with_score_max.name.to_sym]\n teams_with_score_max[game_team_with_score_max.name.to_sym] = team_with_score_max\n end\n teams_with_score_max\n end", "def pri_tdef\n team_stats.opp_goals_per_game / team_stats.opp_avg_goals_against_per_game\n end", "def most_points_scored\n points_scored = 0 # starting score to compare with players shoe sizes\n game_hash.each do |location, team_data| # iterates through each team\n players_array = team_data[:players] # finds the :players info in team_data and puts the players into players_array\n players_array.each do |player_name, data| # iterates through each player..\n if data[:points] > points_scored # if their points scored is greater than 0 (we set this earlier in the top of method)\n points_scored = data[:shoe] # take that players score and make it the new points_scored value\n end # this repeats (iterates) through all players until you don't have any more.. meaning the end result is\n end # the player with the highest score\n end\n return points_scored\nend", "def winning_team\n points_home = 0\n points_away = 0\n result = \"\"\n\n game_hash.each do |side,team|\n team.each do |specs,info|\n if specs == :players\n info.each do |player|\n if side = :home\n points_home += player[:points]\n else\n points_away += player[:points]\n end\n end\n end\n end\n end\n if points_home > points_away\n result = game_hash[:home][:team_name]\n else\n result = game_hash[:away][:team_name]\n end\n result\nend", "def worst_fans\n teams_with_bad_fans = @teams.find_all { |team| team.home_minus_away_percentage.negative? }\n teams_with_bad_fans.map { |team| team.team_name }\n end", "def determine_winner game\n winner = game.max_by {|team| team[:score]}\n team_standings = get_team_by_name(winner)\n team_standings[:winnings] += 3\nend", "def mostSteals\n players.max_by do|name, stats|\n stats[:steals]\n end\nend", "def goals_by_hoa_id_suite\n goals_by_away_id\n goals_by_home_id\n average_score_per_away_game_by_team_id\n average_score_per_home_game_by_team_id\n end", "def goals_by_hoa_id_suite\n goals_by_away_id\n goals_by_home_id\n average_score_per_away_game_by_team_id\n average_score_per_home_game_by_team_id\n end", "def most_points_scored\n most_points = 0\n most_points_player = nil\n game_hash.each do |team, team_stats|\n team_stats[:players].each do |player_stats|\n if most_points < player_stats[:points]\n most_points = player_stats[:points]\n most_points_player = player_stats[:player_name]\n end\n end\n end\n most_points_player\nend", "def winning_team\n home_points = 0\n away_points = 0\n team1 = \"Brooklyn Nets\"\n team2 = \"Charlotte Hornets\"\n game_hash.each do |team,info|\n info.each do |team_info,team_data|\n if team_data.is_a? (Array) \n if team_info != :colors\n if info[:team_name] == \"Brooklyn Nets\"\n team_data.each do |player_index|\n home_points += player_index[:points]\n end\n else \n team_data.each do |player_index|\n away_points += player_index[:points]\n winning_team end\n end\n end\n end\n end\n end\n\n if home_points > away_points\n team1\n else\n team2\n end\n\nend", "def pri_toff\n team_stats.goals_per_game / team_stats.opp_avg_goals_per_game\n end", "def best_offense\n offense_suite\n best_offense_id = @average_goals_by_id.invert.max[1]\n @team_name_by_id[best_offense_id]\n end", "def big_shoe_rebounds\n max_shoe = 0 \n max_rebounds = 0 \n game_hash.each do |place, team|\n # team.each do |attribute, data|\n team[:players].each do |player|\n if player[:shoe] > max_shoe\n max_shoe = player[:shoe]\n max_rebounds = player[:rebounds]\n # if attribute == :players\n # data.each do |player|\n #this gives me the player hashes\n # data.max_by{|player| player[:shoe] }\n # data.max_by{|player| player[:shoe] }[:rebounds]\n # player.max_by{|player| player[:shoe] \n # player.max_by{|player| player[:shoe] }[:rebounds]\n end\n end\n end\n return max_rebounds\n end", "def batting_average(year: nil, team: nil)\n hits, at_bats = 0, 0\n\n seasonal_stats.each do |stat_line|\n year_match = stat_line.year == year || year == nil\n team_match = stat_line.team == team || team == nil\n if year_match && team_match\n hits += stat_line.hits\n at_bats += stat_line.at_bats\n end\n end\n\n if (at_bats != 0)\n return (hits.to_f / at_bats)\n else\n return 0.0\n end\n end", "def average_win_percentage(team_id)\n team_id = team_id.to_i\n team = @teams.select { |each_team| each_team.team_id == team_id }.first\n team.total_win_percentage.round(2)\n end", "def most_points_scored\nbest_player = \"\"\npoints = 0\ngame_hash.each do |location, team_data|\n team_data[:players].each do |name, stats|\n if stats[:points] > points\n points = stats[:points]\n best_player= name\n end\n end\nend\nbest_player\nend", "def winner_team(game)\n result = nil\n if game.team1_goals.present? && game.team2_goals.present?\n result = game.team1 if game.team1_goals > game.team2_goals\n result = game.team2 if game.team1_goals < game.team2_goals\n end\n\n result\n end", "def most_steals \n num_steals = 0\n game_hash.each do |team,info|\n info.each do |team_info,team_data|\n if team_data.is_a? (Array) \n if team_info != :colors\n team_data.each do |player_index|\n if num_steals == 0 || player_index[:steals] > num_steals \n num_steals = player_index[:steals] \n end\n end\n end\n end\n end\n end\nnum_steals\nend", "def winning_team\n nets = []\n hornets = []\n\n game_hash.values.each do |nets_stats|\n if nets_stats[:team_name] == \"Brooklyn Nets\"\n nets_stats[:players].each do |bk|\n nets << bk[:points]\n end\n end\n end\n\n game_hash.values.each do |hornets_stats|\n if hornets_stats[:team_name] == \"Charlotte Hornets\"\n hornets_stats[:players].each do |ch|\n hornets << ch[:points]\n end\n end\n end\n\n if nets.reduce(:+) > hornets.reduce(:+)\n return \"Brooklyn Nets\"\n else\n return \"Charlotte Hornets\"\n end\nend", "def highest_score\n sort\n all.first.score\n end", "def best_season(team_id)\n team_id = team_id.to_i\n team = @teams.select { |each_team| each_team.team_id == team_id }.first\n team.season_win_percentages.max_by { |season, percentage| percentage }.first.to_s\n end", "def highest_player_score\n players.max_by{|player| player.score}.score\n end", "def calculate_final_score\n self.scores.average(:total_score)\n end", "def worst_season(team_id)\n team_id = team_id.to_i\n team = @teams.select { |each_team| each_team.team_id == team_id }.first\n team.season_win_percentages.min_by { |season, percentage| percentage }.first.to_s\n end", "def biggest_surprise(season)\n season = season.to_i\n @teams.max_by{ |team| team.preseason_to_regular_increase[season] }.team_name\n end", "def calculate_score(team)\n scores.includes(:wattball_player).where(:wattball_players => {:team_id => team}).sum(:amount) \n end", "def goals_against()\n\t self.as_regular_contestants.select{|c| c.opponent.score}.collect{|c| c.opponent.score}.inject{|gf, c| gf + c} || 0\n\tend", "def winning_scores\n high_score = scores.max{|score| score.total}.total\n scores.select {|score| score.total == high_score}\n end", "def most_points_scored\n most_points = 0\n player = \"\"\n game_hash.each do |k, team|\n team[:players].each do |e|\n if e[:points] > most_points\n most_points = e[:points]\n player = e[:player_name]\n end\n end\n end\n player\nend", "def best_score(a_of_g)\n best_score = a_of_g.flatten.return_objects_with(:attempts, 0).max_attribute(:adjusted_goodness)\n end", "def score_for_team(team)\n team ||= winner_team\n winner_team?(team) ? score : scores.reverse.join(':')\n end", "def most_steals\r\n result={}\r\n game_hash.each do |k, v|\r\n v.each do| p, d|\r\n if p==:players\r\n d.each do |t, s|\r\n result[t]=s[:steals]\r\n end\r\n end\r\n end\r\n end \r\n result.max_by {|name, steal| steal}[0]\r\nend", "def biggestShoes\n players.max_by do|name, stats|\n stats[:shoe]\n end\nend", "def biggest_shoe\r\n player_name= []\r\n game_hash.each do |team, data|\r\n data.each do |team_info, value|\r\n if team_info == \"players\".to_sym\r\n obj=value.max_by {|key, value| value[:shoe]}\r\n player_name<< obj.first\r\n end\r\n end\r\n end\r\n player_name.first\r\nend", "def score\n goals = self.match_events.select { |e| e.event_type == MatchEvent::EventType::GOAL }\n goals.reduce({away: 0, home: 0}) do |score, e|\n if e.event_author == MatchEvent::EventAuthor::HOME\n score[:home] += 1\n elsif e.event_author == MatchEvent::EventAuthor::AWAY\n score[:away] += 1\n end\n score\n end\n end", "def percentage_visitor_wins\n visitor_wins = @teams.map { |team| team.away_wins }.sum\n visitor_games = @teams.map { |team| team.away_games }.sum\n (visitor_wins.to_f / visitor_games.to_f).round(2)\n end", "def most_points_scored\n\tpoints_array = []\n\tgame_hash.each do |location, team_data|\n\t\tteam_data[:players].each do |attribute, data|\t\n\t\t\tdata.each do |type, amount|\n\t\t\t\tif type == :points\n\t\t\t\t\tpoints_array << amount\n\t\t\t\tend \n\t\t\tend\n\t\tend\n\tend\n\tgame_hash.each do |l, data|\n\t\tdata[:players].each do |a, d|\n\t\t\td.each do |t, amt|\n\t\t\t\tif t == :points && points_array.max == amt\n\t\t\t\t\treturn a\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend\nend", "def big_shoe_rebounds\n\nhighest_rebounds = 0\nbiggest_shoe = 0\n\n game_hash.each do |location, team_info|\n game_hash.dig(location, :players).each do |player_name, stats|\n stats.each do |stat, number|\n if stat == :shoe\n if number > biggest_shoe\n biggest_shoe = number\n stats.each do |stat, number|\n if stat == :rebounds\n highest_rebounds = number\n end\n end\n end\n end\n end\n end\n end\n puts highest_rebounds\n return highest_rebounds\nend", "def player_with_most_steals\n name = \"\"\n most_steals = 0\n\n game_hash.each do | team, details_hash |\n players_array = details_hash[:players]\n players_array.each do | player_details_hash |\n if player_details_hash[:steals] > most_steals\n most_steals = player_details_hash[:steals]\n name = player_details_hash[:player_name]\n end\n end\n end\n name\nend", "def home_stat\n @home.team_stat\n end", "def most_popular_venue\n venues = @games.group_by { |game| game.venue}\n venues.max_by { |venue, games| games.count }.first\n end", "def most_steals(game)\nmax_steals = 0\nmax_steals_player = \"\"\ngame.each do |team, team_contents|\n team_contents[:roster].each do |player, player_contents| \n if player_contents[:steals] == max_steals\n max_steals_player = max_steals_player + \" and #{player_contents[:player_name]}\"\n elsif player_contents[:steals] > max_steals\n max_steals = player_contents[:steals]\n max_steals_player = player_contents[:player_name]\n end\n end\nend\nmax_steals_player\nend", "def most_points_scored\n most_points_scored = 0\n player_with_the_most_points_scored = \"\"\n game_hash.each do |team,info|\n info.each do |team_info,team_data|\n if team_data.is_a? (Array) \n if team_info != :colors\n team_data.each do |player_index|\n if most_points_scored == 0 || player_index[:points] > most_points_scored \n most_points_scored = player_index[:points]\n player_with_the_most_points_scored = player_index[:player_name]\n end\n end\n end\n end\n end\n end\n player_with_the_most_points_scored\nend", "def big_shoe_rebounds_2\n\nhighest_rebounds = 0\nbiggest_shoe = 0\n\n\n game_hash.dig(:home, :players).each do |player_name, stats|\n stats.each do |stat, number|\n if stat == :shoe\n if number > biggest_shoe\n biggest_shoe = number\n stats.each do |stat, number|\n if stat == :rebounds\n highest_rebounds = number\n\n end\n end\n end\n end\n end\nend\n\n puts highest_rebounds\n return highest_rebounds\nend", "def points_in_team(team)\r\n perfs = self.performances.where(team: team)\r\n perfs.map(&:points).inject(:+) / perfs.length\r\n end", "def favorite_opponent(team_id)\n team_id = team_id.to_i\n team = @teams.select { |each_team| each_team.team_id == team_id }.first\n favorite_opponent_id = team.matchup_win_percentage.max_by{|each_team, percentage| percentage}.first\n @teams.select { |each_team| each_team.team_id == favorite_opponent_id }.first.team_name\n end", "def total_score\n sum = self.games.sum{|game|game.points}\n sum.to_i / self.games.count\n end", "def get_max_over(stat)\n max = 0\n $data_enemies.each { |enemy|\n next if enemy.nil?\n next if enemy.hidden_best\n next unless $game_party.known_enemy?(enemy.id)\n value = enemy.get_stat(stat)\n max = value if value > max\n }\n max\n end", "def highest_score\n sorted_all_scores = self.leaderboard_entries.order(score: :DESC)\n sorted_all_scores[0]\n end", "def winning_team_with_spread\n\t\tif self.final?\n\t\t\treturn home_team_id if home_team_score > away_team_score + point_spread\n\t\t\treturn away_team_id if away_team_score + point_spread > home_team_score\n\t\t\treturn \"tie\" if home_team_score == away_team_score + point_spread\n\t\telse\n\t\t\treturn nil\n\t\tend\n\tend" ]
[ "0.80123246", "0.7909811", "0.77517873", "0.77261543", "0.7618676", "0.7615613", "0.7570791", "0.75446874", "0.7477106", "0.7451328", "0.7443151", "0.74076194", "0.7354226", "0.73370004", "0.72952014", "0.72820723", "0.72547835", "0.7205332", "0.71723086", "0.71403384", "0.7104653", "0.7084394", "0.70750564", "0.70562124", "0.7045489", "0.70089567", "0.70067924", "0.7000277", "0.69567496", "0.68997866", "0.6890523", "0.68846154", "0.68627524", "0.6857968", "0.6844046", "0.68103665", "0.6750127", "0.6740897", "0.6708698", "0.6682726", "0.6665251", "0.66627055", "0.66491985", "0.66350204", "0.66290826", "0.6616883", "0.6607591", "0.6588201", "0.6580599", "0.657666", "0.65716684", "0.6558803", "0.6554911", "0.6550393", "0.6543125", "0.65328616", "0.64674985", "0.64674985", "0.6457397", "0.6433514", "0.6433391", "0.6403793", "0.64022803", "0.63930583", "0.63865393", "0.6385283", "0.6381586", "0.6377002", "0.6373346", "0.6333822", "0.6326263", "0.63229966", "0.6319391", "0.6314067", "0.6287343", "0.6272872", "0.62710273", "0.62710047", "0.62535006", "0.6251605", "0.6246015", "0.6230253", "0.6229562", "0.6228333", "0.62193125", "0.6210123", "0.6207348", "0.61969477", "0.6180191", "0.6175071", "0.6163925", "0.6163638", "0.61619747", "0.6160311", "0.6152379", "0.61518604", "0.6142825", "0.6136148", "0.6112261", "0.60995716" ]
0.8277581
0
returns team with lowest average away goals
def lowest_scoring_visitor @teams.min_by { |team| team.average_away_goals }.team_name end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def average_goals_per_game\n total_goals = @teams.map {|team| team.total_goals_scored}.sum\n total_games = @teams.map {|team| team.home_games}.sum\n (total_goals.to_f / total_games.to_f).round(2)\n end", "def lowest_total_score\n total_game_scores = games.map { |game| game.home_goals + game.away_goals}\n total_game_scores.min\n end", "def fewest_goals_scored(team_id)\n team_id = team_id.to_i\n goals_per_game = @game_teams.map do |game|\n if game.team_id == team_id\n game.goals\n end\n end\n goals_per_game.compact.min\n end", "def lowest_scoring_home_team\n @teams.min_by { |team| team.average_home_goals }.team_name\n end", "def worst_offense\n @teams.min_by { |team| team.average_goals_scored }.team_name\n end", "def best_defense\n @teams.min_by { |team| team.average_goals_allowed }.team_name\n end", "def worst_offense\n teams_total_goals = total_goals_helper\n teams_total_games = total_games_helper\n\n worst_team_goals_avg = 1000\n worst_offense_team_id = 0\n this_team_goals_avg = 0\n\n teams_total_games.each do |games_key, games_value|\n teams_total_goals.each do |goals_key, goals_value|\n if goals_key == games_key\n this_team_goals_avg = (goals_value / games_value.to_f)\n if this_team_goals_avg < worst_team_goals_avg\n worst_team_goals_avg = this_team_goals_avg\n worst_offense_team_id = games_key\n end\n end\n end\n end\n\n team_with_worst_offense = nil\n self.teams.each_value do |team_obj|\n if team_obj.team_id. == worst_offense_team_id\n team_with_worst_offense = team_obj.team_name\n end\n end\n team_with_worst_offense\n end", "def team_average\n # This version is implemented as a database AVG operation,\n # but it cannot be eager loaded so it results in an extra\n # database query for each project:\n #\n # avg = students_projects.select(:points).average :points\n # avg ? avg.round : 0\n\n # This version programmatically finds the average of the points:\n #self.reload\n no_of_students = self.students_projects.length\n return 0 if no_of_students == 0\n total = 0\n self.students_projects.each { |s| total += s.points }\n (total / no_of_students).round\n end", "def best_defense\n teams_total_goals_allowed = total_goals_allowed_helper\n teams_total_games = total_games_helper\n\n best_team_goals_allowed_avg = 100\n best_defense_team_id = 0\n this_team_goals_allowed_avg = 0\n\n teams_total_games.each do |games_key, games_value|\n teams_total_goals_allowed.each do |goals_key, goals_value|\n if goals_key == games_key\n this_team_goals_allowed_avg = (goals_value / games_value.to_f)\n if this_team_goals_allowed_avg < best_team_goals_allowed_avg\n best_team_goals_allowed_avg = this_team_goals_allowed_avg\n best_defense_team_id = games_key\n end\n end\n end\n end\n\n team_with_best_defense = nil\n self.teams.each_value do |team_obj|\n if team_obj.team_id. == best_defense_team_id\n team_with_best_defense = team_obj.team_name\n end\n end\n team_with_best_defense\n end", "def worst_defense\n teams_total_goals_allowed = total_goals_allowed_helper\n teams_total_games = total_games_helper\n\n worst_team_goals_allowed_avg = 0\n worst_defense_team_id = 0\n this_team_goals_allowed_avg = 0\n\n teams_total_games.each do |games_key, games_value|\n\n teams_total_goals_allowed.each do |goals_key, goals_value|\n if goals_key == games_key\n this_team_goals_allowed_avg = (goals_value / games_value.to_f)\n if this_team_goals_allowed_avg > worst_team_goals_allowed_avg\n worst_team_goals_allowed_avg = this_team_goals_allowed_avg\n worst_defense_team_id = games_key\n end\n end\n end\n end\n team_with_worst_defense = team_name_finder_helper(worst_defense_team_id)\n\n team_with_worst_defense\n end", "def best_offense\n @teams.max_by { |team| team.average_goals_scored }.team_name\n end", "def goals_for(team)\n valid = ((team == self.home_team or team == self.away_team) and self.final)\n\n if (valid)\n if (self.home_team == team)\n return self.homeScore\n else\n return self.awayScore\n end\n else\n return 0\n end\n end", "def average_goals_by_season\n goals_by_season = @games.group_by { |game| game.season.to_s }\n goals_by_season.each do |season, games|\n season_goals = games.map { |game| game.home_goals + game.away_goals }.sum\n goals_by_season[season] = (season_goals.to_f / games.count.to_f).round(2)\n end\n end", "def winning_team\n home_points = collection_by_prop(game_hash[:home], :points).reduce(0, :+)\n away_points = collection_by_prop(game_hash[:away], :points).reduce(0, :+)\n home_points > away_points ? game_hash[:home][:team_name] : game_hash[:away][:team_name]\n end", "def goals_against(team)\n valid = ((team == self.home_team or team == self.away_team) and self.final)\n\n if (valid)\n if (self.home_team == team)\n return self.awayScore\n else\n return self.homeScore\n end\n else\n return 0\n end\n end", "def highest_scoring_home_team\n @teams.max_by { |team| team.average_home_goals }.team_name\n end", "def smallest_team\n self.teams.min{|t1,t2| t1.runners.size <=> t2.runners.size }\n end", "def highest_scoring_visitor\n @teams.max_by { |team| team.average_away_goals }.team_name\n end", "def winning_team\n final_scores = player_collection.reduce(home: 0, away: 0) { |teams_points, next_player|\n case \n when next_player[:location] === :away\n teams_points[:away] += next_player[:points];\n when next_player[:location] === :home\n teams_points[:home] += next_player[:points];\n end\n teams_points; \n }\n winner = final_scores.reduce { |highest_points, team_points| \n highest_points[1] > team_points[1] ? highest_points : team_points; \n }\n game_hash[winner[0]][:team_name]; \nend", "def winningest_team\n @teams.max_by { |team| team.total_win_percentage }.team_name\n end", "def best_fans\n @teams.max_by { |team| team.home_minus_away_percentage }.team_name\n end", "def winning_team\n home_team_sum = 0\n away_team_sum = 0\n game_hash.each do |team, team_stats|\n if team_stats[:team_name] == \"Brooklyn Nets\"\n team_stats[:players].each do |player_stats|\n home_team_sum += player_stats[:points]\n end\n elsif team_stats[:team_name] == \"Charlotte Hornets\"\n team_stats[:players].each do |player_stats|\n away_team_sum += player_stats[:points]\n end\n end\n end\n if home_team_sum > away_team_sum\n game_hash[:home][:team_name]\n elsif home_team_sum < away_team_sum\n game_hash[:away][:team_name]\n end\nend", "def winning_team\n home_team_points = game_hash[:home][:players].sum { |e| e[:points] }\n away_team_points = game_hash[:away][:players].sum { |e| e[:points] }\n\n if home_team_points > away_team_points\n return game_hash[:home][:team_name]\n else\n return game_hash[:away][:team_name]\n end\nend", "def worst_defense\n @teams.max_by { |team| team.average_goals_allowed }.team_name\n end", "def pri_toff\n team_stats.goals_per_game / team_stats.opp_avg_goals_per_game\n end", "def pri_tdef\n team_stats.opp_goals_per_game / team_stats.opp_avg_goals_against_per_game\n end", "def average_win_percentage(team_id)\n team_id = team_id.to_i\n team = @teams.select { |each_team| each_team.team_id == team_id }.first\n team.total_win_percentage.round(2)\n end", "def winning_team\n home_score = 0\n away_score = 0\n game_hash[:home][:players].keys.each do |name|\n home_score += game_hash[:home][:players][name][:points]\n end\n game_hash[:away][:players].keys.each do |name|\n away_score += game_hash[:away][:players][name][:points]\n end\n home_score > away_score ? game_hash[:home][:team_name] : game_hash[:away][:team_name]\nend", "def winning_team\n self.teams.order('score DESC').first\n end", "def team_with_more_points(game)\n home_points = game[:home_team][:players].collect do |player|\n player[:stats][:points]\n end.inject {|sum, n| sum + n}\n away_points = game[:away_team][:players].collect do |player|\n player[:stats][:points]\n end.inject {|sum, n| sum + n}\n home_points > away_points ? game[:home_team][:team_name] : game[:away_team][:team_name]\nend", "def winning_team\n if homeTeamPoints.sum > awayTeamPoints.sum\n \"Brooklyn Nets\"\n else\n \"Charlotte Hornets\"\n end\nend", "def highest_total_score\n total_goals.max\n end", "def worst_season(team_id)\n team_id = team_id.to_i\n team = @teams.select { |each_team| each_team.team_id == team_id }.first\n team.season_win_percentages.min_by { |season, percentage| percentage }.first.to_s\n end", "def total_team_score(teams_id)\n total_score = 0\n @league_data.each do\n |team| \n # binding.pry\n if team.home_team_id == teams_id\n total_score += team.home_team_score\n elsif team.away_team_id == teams_id\n total_score += team.away_team_score\n end\n end\n return total_score\n end", "def winning_team\n team_p = []\n team_n = []\n\n game_hash.each do | location, team_data|\n temp = 0\n team_data[:players].each do |p_name, stats|\n temp += stats[:points]\n end\n team_n << team_data[:team_name]\n team_p << temp\n end\n\n team_p[0] > team_p[1] ? team_n[0] : team_n[1]\n\nend", "def most_goals_scored(team_id)\n team_id = team_id.to_i\n goals_per_game = @game_teams.map do |game|\n if game.team_id == team_id\n game.goals\n end\n end\n goals_per_game.compact.max\n end", "def worst_loss(team_id)\n @games.map do |game|\n if game.away_team_id.to_s == team_id\n game.home_goals - game.away_goals\n elsif game.home_team_id.to_s == team_id\n game.away_goals - game.home_goals\n end\n end.compact.max\n end", "def most_accurate_team(seasonasstring) # shots in game team stats\n #get a list of all teams that played in that season - given by arg\n #use above list to sum all shots across all games in season\n #divide above by goals made across all games in season\n #find highest percentage\n #return team name as found in 127\n end", "def points_in_team(team)\r\n perfs = self.performances.where(team: team)\r\n perfs.map(&:points).inject(:+) / perfs.length\r\n end", "def batting_average(year: nil, team: nil)\n hits, at_bats = 0, 0\n\n seasonal_stats.each do |stat_line|\n year_match = stat_line.year == year || year == nil\n team_match = stat_line.team == team || team == nil\n if year_match && team_match\n hits += stat_line.hits\n at_bats += stat_line.at_bats\n end\n end\n\n if (at_bats != 0)\n return (hits.to_f / at_bats)\n else\n return 0.0\n end\n end", "def get_standings(games)\n teams = Hash.new\n games.each do |game|\n division_id = game.division_id\n home_team = game.home_team\n away_team = game.visiting_team\n if(teams[home_team.name].nil?)\n teams[home_team.name] = {:win => 0, :loss => 0, :tie => 0, :point=> 0}\n end\n\n if(teams[away_team.name].nil?)\n teams[away_team.name] = {:win => 0, :loss => 0, :tie => 0, :point => 0}\n end\n if(game.home_team_score && game.visiting_team_score)\n if(game.home_team_score > game.visiting_team_score)\n # home team won\n teams[home_team.name][:win] += 1\n teams[home_team.name][:point] += 5\n # visiting team loss\n teams[away_team.name][:loss] += 1\n elsif(game.home_team_score < game.visiting_team_score)\n # home team loss\n teams[home_team.name][:loss] += 1\n #visiting team won\n teams[away_team.name][:win] += 1\n teams[away_team.name][:point] += 5\n else\n # tie game\n teams[home_team.name][:tie] += 1\n teams[home_team.name][:point] += 1\n teams[away_team.name][:tie] += 1\n teams[away_team.name][:point] += 1\n end\n end\n end\n teams.each do |team, value|\n puts team\n total_games = value[:win] + value[:loss] + value[:tie]\n if total_games > 0 \n win_percentage = value[:win]/total_games.to_f\n else\n win_percentage = 0\n end \n value[:percentage] = win_percentage\n end\n teams_sorted = teams.sort_by{ |k, v| v[:point]}.reverse\n return teams_sorted\n end", "def biggest_blowout\n score_difference = games.map { |game| (game.home_goals - game.away_goals).abs}\n score_difference.max\n end", "def calculate_score(team)\n scores.includes(:wattball_player).where(:wattball_players => {:team_id => team}).sum(:amount) \n end", "def winning_team\n home_points = 0\n away_points = 0\n result = \"\"\n i = 0\n game_hash.each do |team, about|\n about[:players].each do |name , stats|\n if i == 0\n home_points += stats[:points]\n else\n away_points += stats[:points]\n end\n end\n i += 1\n end\n home_points > away_points ? result = game_hash[:home][:team_name] : result = game_hash[:away][:team_name]\nend", "def goals_against()\n\t self.as_regular_contestants.select{|c| c.opponent.score}.collect{|c| c.opponent.score}.inject{|gf, c| gf + c} || 0\n\tend", "def percentage_home_wins\n home_wins = @teams.map { |team| team.home_wins }.sum\n home_games = @teams.map { |team| team.home_games }.sum\n (home_wins.to_f / home_games.to_f).round(2)\n end", "def best_season(team_id)\n team_id = team_id.to_i\n team = @teams.select { |each_team| each_team.team_id == team_id }.first\n team.season_win_percentages.max_by { |season, percentage| percentage }.first.to_s\n end", "def winning_team\n points_home = 0\n points_away = 0\n result = \"\"\n\n game_hash.each do |side,team|\n team.each do |specs,info|\n if specs == :players\n info.each do |player|\n if side = :home\n points_home += player[:points]\n else\n points_away += player[:points]\n end\n end\n end\n end\n end\n if points_home > points_away\n result = game_hash[:home][:team_name]\n else\n result = game_hash[:away][:team_name]\n end\n result\nend", "def starters_average\n total = self.players.starter.inject(0) {|result, element| result + element.average_qualities}\n return total / MIN_PLAYERS\n end", "def goals_for()\n\t self.as_regular_contestants.select{|c| c.score}.collect{|c| c.score}.inject{|gf, c| gf + c} || 0\n\tend", "def winning_team\n home_points = 0\n away_points = 0\n team1 = \"Brooklyn Nets\"\n team2 = \"Charlotte Hornets\"\n game_hash.each do |team,info|\n info.each do |team_info,team_data|\n if team_data.is_a? (Array) \n if team_info != :colors\n if info[:team_name] == \"Brooklyn Nets\"\n team_data.each do |player_index|\n home_points += player_index[:points]\n end\n else \n team_data.each do |player_index|\n away_points += player_index[:points]\n winning_team end\n end\n end\n end\n end\n end\n\n if home_points > away_points\n team1\n else\n team2\n end\n\nend", "def test_average_goals_per_game\n\n assert_equal 4.22, @stat_tracker.average_goals_per_game\n end", "def percentage_visitor_wins\n visitor_wins = @teams.map { |team| team.away_wins }.sum\n visitor_games = @teams.map { |team| team.away_games }.sum\n (visitor_wins.to_f / visitor_games.to_f).round(2)\n end", "def total_score\n @all_games.map do |games|\n games[\"home_goals\"].to_i + games[\"away_goals\"].to_i\n end\n end", "def winning_team\n nets = []\n hornets = []\n\n game_hash.values.each do |nets_stats|\n if nets_stats[:team_name] == \"Brooklyn Nets\"\n nets_stats[:players].each do |bk|\n nets << bk[:points]\n end\n end\n end\n\n game_hash.values.each do |hornets_stats|\n if hornets_stats[:team_name] == \"Charlotte Hornets\"\n hornets_stats[:players].each do |ch|\n hornets << ch[:points]\n end\n end\n end\n\n if nets.reduce(:+) > hornets.reduce(:+)\n return \"Brooklyn Nets\"\n else\n return \"Charlotte Hornets\"\n end\nend", "def avg_of_toryo_turn_max\n s = lose_scope\n s = s.joins(:battle)\n s = s.where(Swars::Battle.arel_table[:final_key].eq(\"TORYO\"))\n if v = s.average(Swars::Battle.arel_table[:turn_max])\n v.to_i\n end\n end", "def biggest_team_blowout(team_id)\n @games.map do |game|\n if game.away_team_id.to_s == team_id\n game.away_goals - game.home_goals\n elsif game.home_team_id.to_s == team_id\n game.home_goals - game.away_goals\n end\n end.compact.max\n end", "def average_player_age\n players.average(:age)\n end", "def rating_average(team, match)\n if match.ended?\n sum = 0; team.each { |u| sum += u['rating'].to_i }\n else\n sum = 0; team.users.each { |u| sum += u['rating'].to_i }\n end\n sum / 5\n end", "def goal_difference\n total_diff = 0\n\n wattball_matches_as_team1.each do |match|\n total_diff += match.goal_difference[0]\n end\n\n wattball_matches_as_team2.each do |match|\n total_diff += match.goal_difference[1]\n end\n \n total_diff\n end", "def determine_winner game\n winner = game.max_by {|team| team[:score]}\n team_standings = get_team_by_name(winner)\n team_standings[:winnings] += 3\nend", "def least_accurate_team(seasonasstring) # shots in game team stats\n #inverse of above\n end", "def load_stats\n[\n {\n home_team: \"Jets\",\n away_team: \"Giants\",\n home_score: 21,\n away_score: 3\n },\n {\n home_team: \"Steelers\",\n away_team: \"Giants\",\n home_score: 21,\n away_score: 3\n },\n {\n home_team: \"Patriots\",\n away_team: \"Giants\",\n home_score: 21,\n away_score: 3\n },\n {\n home_team: \"Chargers\",\n away_team: \"Jets\",\n home_score: 13,\n away_score: 6\n },\n {\n home_team: \"Patriots\",\n away_team: \"Jets\",\n home_score: 13,\n away_score: 6\n },\n {\n home_team: \"Steelers\",\n away_team: \"Jets\",\n home_score: 3,\n away_score: 6\n },\n {\n home_team: \"Dolphins\",\n away_team: \"Jets\",\n home_score: 0,\n away_score: 3\n },\n{\n home_team: \"Browns\",\n away_team: \"Jets\",\n home_score: 0,\n away_score: 21\n },\n {\n home_team: \"Chargers\",\n away_team: \"Jets\",\n home_score: 7,\n away_score: 21\n },\n {\n home_team: \"Steelers\",\n away_team: \"Broncos\",\n home_score: 7,\n away_score: 13\n },\n {\n home_team: \"Patriots\",\n away_team: \"Broncos\",\n home_score: 7,\n away_score: 3\n },\n {\n home_team: \"Broncos\",\n away_team: \"Colts\",\n home_score: 3,\n away_score: 0\n },\n {\n home_team: \"Patriots\",\n away_team: \"Colts\",\n home_score: 11,\n away_score: 7\n },\n {\n home_team: \"Steelers\",\n away_team: \"Patriots\",\n home_score: 7,\n away_score: 21\n },\n {\n home_team: \"Steelers\",\n away_team: \"Colts\",\n home_score: 24,\n away_score: 21\n },\n {\n home_team: \"Steelers\",\n away_team: \"Colts\",\n home_score: 24,\n away_score: 21\n }\n]\nend", "def winning_team_with_spread\n\t\tif self.final?\n\t\t\treturn home_team_id if home_team_score > away_team_score + point_spread\n\t\t\treturn away_team_id if away_team_score + point_spread > home_team_score\n\t\t\treturn \"tie\" if home_team_score == away_team_score + point_spread\n\t\telse\n\t\t\treturn nil\n\t\tend\n\tend", "def most_points_scored\n points_scored = 0 # starting score to compare with players shoe sizes\n game_hash.each do |location, team_data| # iterates through each team\n players_array = team_data[:players] # finds the :players info in team_data and puts the players into players_array\n players_array.each do |player_name, data| # iterates through each player..\n if data[:points] > points_scored # if their points scored is greater than 0 (we set this earlier in the top of method)\n points_scored = data[:shoe] # take that players score and make it the new points_scored value\n end # this repeats (iterates) through all players until you don't have any more.. meaning the end result is\n end # the player with the highest score\n end\n return points_scored\nend", "def improve_teams\n @teams = steepest_ascent_hill(@teams)\n end", "def player_w_biggest_feet\n all_players[1].max_by { |stats| stats[:shoe] }\n end", "def calculate_team_ranking_score(number_of_meetings = 2, number_of_bests = 3)\n team_ranking_results = []\n events = []\n if @badge.category_type.code != 'U25' &&\n @badge.meetings.distinct.count >= number_of_meetings\n get_results.each do |meeting_individual_result|\n next unless meeting_individual_result.get_scheduled_date.year - @swimmer.year_of_birth >= 25\n\n next if events.include?(meeting_individual_result.event_type.code)\n\n team_ranking_results << meeting_individual_result\n events << meeting_individual_result.event_type.code\n break if team_ranking_results.count == number_of_bests\n end\n end\n BestLimitedRankingDAO.new(team_ranking_results)\n end", "def rank_top_teams # DO NOT USE THIS METHOD, outdated, slow\n @top_teams = {}\n @top_teams = Score.in_challenge(self.id).teams_in_all_divisions.limit(5).\n order(\"sum_points DESC, MAX(#{Score.table_name}.\n earned_at) DESC\").sum(:points) \n return @top_teams\n end", "def calculate_team_points\n # If the bracket is complete, we can calculate points based on the\n # teams' `final_rank`s.\n if @state == \"complete\"\n calculate_team_points_by_final_rank\n return\n end\n\n # For each team, look at the matches that it is in, look at the point\n # values of those matches, and take the maximum point value. That's the\n # number of points that the team has earned so far in the bracket.\n base_point_value = @config.base_point_value\n\n @teams.each do |team|\n matches_with_team = @matches.select { |match| match.has_team?(team.id) }\n\n puts \"Team #{team.name} was in #{matches_with_team.size} matches\"\n\n points_earned = matches_with_team.max_by(&:points).points\n\n puts \"The largest point value of those matches is #{points_earned}\" \\\n \"#{\" + #{base_point_value} base\" if base_point_value > 0}\"\n\n team.points = points_earned + base_point_value\n end\n end", "def average_difficulty\n @p = live_problems\n if @p.size > 0\n @avg = @p.inject(0.0){|sum, i| sum + Difficulty.to_int(i.difficulty) } / @p.size\n else\n @avg = nil\n end\n end", "def most_points_scored\n most_points = 0\n most_points_player = nil\n game_hash.each do |team, team_stats|\n team_stats[:players].each do |player_stats|\n if most_points < player_stats[:points]\n most_points = player_stats[:points]\n most_points_player = player_stats[:player_name]\n end\n end\n end\n most_points_player\nend", "def winner_team(game)\n result = nil\n if game.team1_goals.present? && game.team2_goals.present?\n result = game.team1 if game.team1_goals > game.team2_goals\n result = game.team2 if game.team1_goals < game.team2_goals\n end\n\n result\n end", "def rating\n position_sum = 0\n games = []\n number_of_teams = 0\n Participation.find_all_by_player_id(self.id).each do |participation|\n position_sum += participation.position\n games.push Game.find(participation.game_id)\n end\n\n games.each do |game|\n number_of_teams += game.number_of_teams\n end\n\n if position_sum == 0\n position_sum = number_of_teams.to_f-0.5\n end\n\n (1 - position_sum.to_f/number_of_teams).round 2\n end", "def team_score\n team_member = @current_user.team.users\n team_comment = Comment.where(user_id: team_member.pluck('id'))\n emotion_scores = team_comment.where('created_at BETWEEN ? AND ?', DateTime.now.beginning_of_day, DateTime.now.end_of_day).average(:score)\n emotion_scores\n end", "def best_score\n submissions.min(:score)\n end", "def lacrosse_scoring_average(sport, player)\n\t\tgoals = 0\n\t\tgames = sport.teams.find(player.team_id).gameschedules\n\n\t\tgames.each do |g|\n\t\t\tstat = g.lacrosstats.find_by(athlete_id: player.id)\n\t\t\tgoals += stat.lacross_scorings.count if stat.lacross_scorings.any?\n\t\tend\n\n\t\tif games > 0\n\t\t\treturn goals / games.count\n\t\telse\n\t\t\treturn 0.0\n\t\tend\n\tend", "def awayTeamPoints\n teamSelect(\"Charlotte Hornets\")[:players].collect do|name, stats|\n stats[:points]\n end\nend", "def worst_fans\n teams_with_bad_fans = @teams.find_all { |team| team.home_minus_away_percentage.negative? }\n teams_with_bad_fans.map { |team| team.team_name }\n end", "def least_popular_venue\n venues = @games.group_by { |game| game.venue}\n venues.min_by { |venue, games| games.count }.first\n end", "def most_points_scored\nbest_player = \"\"\npoints = 0\ngame_hash.each do |location, team_data|\n team_data[:players].each do |name, stats|\n if stats[:points] > points\n points = stats[:points]\n best_player= name\n end\n end\nend\nbest_player\nend", "def goals_by_hoa_id_suite\n goals_by_away_id\n goals_by_home_id\n average_score_per_away_game_by_team_id\n average_score_per_home_game_by_team_id\n end", "def goals_by_hoa_id_suite\n goals_by_away_id\n goals_by_home_id\n average_score_per_away_game_by_team_id\n average_score_per_home_game_by_team_id\n end", "def total_score\n sum = self.games.sum{|game|game.points}\n sum.to_i / self.games.count\n end", "def high_score\n if self.end_date < Date.today\n self.teams.max_by { |team| team.score }.score\n end\n end", "def total_points\n\n points = 0\n wattball_matches_as_team1.each do |match|\n points += match.points(1) || 0\n end\n\n wattball_matches_as_team2.each do |match|\n points += match.points(2) || 0\n end\n\n points\n end", "def winning_team\n total_points = 0 #initialize points at zero \n \n win_team = '' #set win team to an empty string \n \n game_hash.each do |location, team| #iterating over game hash\n team_points = 0 #initialize team points at zero \n team_name = game_hash[location][:team_name] \n # set team name = to game_hash at the the location at the # :team name \n \n team[:players].each do |player| #iterate over players \n points = player[:points] # set points = player points \n team_points += points #team points is the addition of every single point value from each player\n \n #binding.pry \n end\n \n win_team, total_points = team_name, team_points if team_points > total_points\n \n #binding.pry \n \n end\n \n return win_team\n\nend", "def most_points_scored\n max = nil\n name = nil \n game_hash.each do |team, team_values|\n team_values[:players].each do |player|\n if max == nil || player[:points] > max\n max = player[:points]\n name = player[:player_name]\n end\n end\n end\n name\nend", "def rival(team_id)\n team_id = team_id.to_i\n team = @teams.select { |each_team| each_team.team_id == team_id }.first\n rival_id = team.matchup_win_percentage.min_by{|each_team, percentage| percentage}.first\n @teams.select { |each_team| each_team.team_id == rival_id }.first.team_name\n end", "def most_hits(seasonasstring) # shots in game team stats\n #get a list of all teams that played in that season\n #use above list to sum all shots across all games in season\n #find highest across list\n #return team name as found in 139\n end", "def goal_difference\n p1 = calculate_score(team1)\n p2 = calculate_score(team2)\n\n return 0 if p1.nil? or p2.nil?\n\n diff = p1 - p2\n\n diff_1 = diff\n diff_1 = 0 if diff_1 < 0\n\n # The goal difference for second team is the inverse\n diff_2 = -diff\n diff_2 = 0 if diff_2 < 0\n\n [diff_1, diff_2]\n end", "def avg_shots_per_kill\n @avg_shots_per_kill = @shots.to_f / @kills if @avg_shots_per_kill.nil?\n\n @avg_shots_per_kill\n end", "def most_steals \n num_steals = 0\n game_hash.each do |team,info|\n info.each do |team_info,team_data|\n if team_data.is_a? (Array) \n if team_info != :colors\n team_data.each do |player_index|\n if num_steals == 0 || player_index[:steals] > num_steals \n num_steals = player_index[:steals] \n end\n end\n end\n end\n end\n end\nnum_steals\nend", "def mostSteals\n players.max_by do|name, stats|\n stats[:steals]\n end\nend", "def best_score(a_of_g)\n best_score = a_of_g.flatten.return_objects_with(:attempts, 0).max_attribute(:adjusted_goodness)\n end", "def find_best_score(total_per_player)\n best_score = 0\n winner = ''\n total_per_player.each do |player_name,total|\n\n if total > best_score\n best_score = total\n winner = player_name\n end\n end\n return winner\n end", "def player_with_most_steals\n name = \"\"\n most_steals = 0\n\n game_hash.each do | team, details_hash |\n players_array = details_hash[:players]\n players_array.each do | player_details_hash |\n if player_details_hash[:steals] > most_steals\n most_steals = player_details_hash[:steals]\n name = player_details_hash[:player_name]\n end\n end\n end\n name\nend", "def homeTeamPoints\n teamSelect(\"Brooklyn Nets\")[:players].collect do |name, stats|\n stats[:points]\n end\nend", "def score\n goals = self.match_events.select { |e| e.event_type == MatchEvent::EventType::GOAL }\n goals.reduce({away: 0, home: 0}) do |score, e|\n if e.event_author == MatchEvent::EventAuthor::HOME\n score[:home] += 1\n elsif e.event_author == MatchEvent::EventAuthor::AWAY\n score[:away] += 1\n end\n score\n end\n end", "def most_points_scored\n most_points = 0\n player = \"\"\n game_hash.each do |k, team|\n team[:players].each do |e|\n if e[:points] > most_points\n most_points = e[:points]\n player = e[:player_name]\n end\n end\n end\n player\nend" ]
[ "0.78745216", "0.7797572", "0.7740544", "0.77272207", "0.7659458", "0.7543639", "0.74583966", "0.7351377", "0.73151785", "0.72058874", "0.715637", "0.7123159", "0.712085", "0.6971932", "0.6961435", "0.69253594", "0.6876042", "0.68631893", "0.6857849", "0.68461275", "0.68137765", "0.6802539", "0.67974037", "0.6796233", "0.6741408", "0.6707522", "0.6705222", "0.67016625", "0.6693422", "0.6674845", "0.6670655", "0.6629185", "0.6616407", "0.6608339", "0.6605862", "0.6592221", "0.6581212", "0.6558451", "0.65582556", "0.65519124", "0.6548968", "0.6548927", "0.65021926", "0.6469964", "0.6456496", "0.6431041", "0.6370693", "0.63683224", "0.63655645", "0.63535887", "0.6334698", "0.6327228", "0.6293721", "0.6288363", "0.6270101", "0.62586766", "0.6258664", "0.62514323", "0.622808", "0.6217734", "0.61994517", "0.61979043", "0.61978126", "0.61927813", "0.6189659", "0.617787", "0.61561614", "0.6152538", "0.61505616", "0.6136898", "0.61333025", "0.6126314", "0.61099994", "0.6103315", "0.60994494", "0.60915697", "0.60835755", "0.6082733", "0.60827166", "0.6075855", "0.60622245", "0.6035553", "0.6035553", "0.6027692", "0.6018866", "0.5998248", "0.5978088", "0.59708935", "0.59689856", "0.59571755", "0.59468424", "0.5942507", "0.5938941", "0.5931414", "0.5920533", "0.59202725", "0.5918676", "0.5906704", "0.5901393", "0.589679" ]
0.7782403
2
returns team with lowest average home goals
def lowest_scoring_home_team @teams.min_by { |team| team.average_home_goals }.team_name end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def lowest_total_score\n total_game_scores = games.map { |game| game.home_goals + game.away_goals}\n total_game_scores.min\n end", "def average_goals_per_game\n total_goals = @teams.map {|team| team.total_goals_scored}.sum\n total_games = @teams.map {|team| team.home_games}.sum\n (total_goals.to_f / total_games.to_f).round(2)\n end", "def lowest_scoring_visitor\n @teams.min_by { |team| team.average_away_goals }.team_name\n end", "def fewest_goals_scored(team_id)\n team_id = team_id.to_i\n goals_per_game = @game_teams.map do |game|\n if game.team_id == team_id\n game.goals\n end\n end\n goals_per_game.compact.min\n end", "def best_defense\n @teams.min_by { |team| team.average_goals_allowed }.team_name\n end", "def worst_offense\n @teams.min_by { |team| team.average_goals_scored }.team_name\n end", "def highest_scoring_home_team\n @teams.max_by { |team| team.average_home_goals }.team_name\n end", "def team_average\n # This version is implemented as a database AVG operation,\n # but it cannot be eager loaded so it results in an extra\n # database query for each project:\n #\n # avg = students_projects.select(:points).average :points\n # avg ? avg.round : 0\n\n # This version programmatically finds the average of the points:\n #self.reload\n no_of_students = self.students_projects.length\n return 0 if no_of_students == 0\n total = 0\n self.students_projects.each { |s| total += s.points }\n (total / no_of_students).round\n end", "def worst_offense\n teams_total_goals = total_goals_helper\n teams_total_games = total_games_helper\n\n worst_team_goals_avg = 1000\n worst_offense_team_id = 0\n this_team_goals_avg = 0\n\n teams_total_games.each do |games_key, games_value|\n teams_total_goals.each do |goals_key, goals_value|\n if goals_key == games_key\n this_team_goals_avg = (goals_value / games_value.to_f)\n if this_team_goals_avg < worst_team_goals_avg\n worst_team_goals_avg = this_team_goals_avg\n worst_offense_team_id = games_key\n end\n end\n end\n end\n\n team_with_worst_offense = nil\n self.teams.each_value do |team_obj|\n if team_obj.team_id. == worst_offense_team_id\n team_with_worst_offense = team_obj.team_name\n end\n end\n team_with_worst_offense\n end", "def best_defense\n teams_total_goals_allowed = total_goals_allowed_helper\n teams_total_games = total_games_helper\n\n best_team_goals_allowed_avg = 100\n best_defense_team_id = 0\n this_team_goals_allowed_avg = 0\n\n teams_total_games.each do |games_key, games_value|\n teams_total_goals_allowed.each do |goals_key, goals_value|\n if goals_key == games_key\n this_team_goals_allowed_avg = (goals_value / games_value.to_f)\n if this_team_goals_allowed_avg < best_team_goals_allowed_avg\n best_team_goals_allowed_avg = this_team_goals_allowed_avg\n best_defense_team_id = games_key\n end\n end\n end\n end\n\n team_with_best_defense = nil\n self.teams.each_value do |team_obj|\n if team_obj.team_id. == best_defense_team_id\n team_with_best_defense = team_obj.team_name\n end\n end\n team_with_best_defense\n end", "def goals_for(team)\n valid = ((team == self.home_team or team == self.away_team) and self.final)\n\n if (valid)\n if (self.home_team == team)\n return self.homeScore\n else\n return self.awayScore\n end\n else\n return 0\n end\n end", "def percentage_home_wins\n home_wins = @teams.map { |team| team.home_wins }.sum\n home_games = @teams.map { |team| team.home_games }.sum\n (home_wins.to_f / home_games.to_f).round(2)\n end", "def winning_team\n home_points = collection_by_prop(game_hash[:home], :points).reduce(0, :+)\n away_points = collection_by_prop(game_hash[:away], :points).reduce(0, :+)\n home_points > away_points ? game_hash[:home][:team_name] : game_hash[:away][:team_name]\n end", "def average_goals_by_season\n goals_by_season = @games.group_by { |game| game.season.to_s }\n goals_by_season.each do |season, games|\n season_goals = games.map { |game| game.home_goals + game.away_goals }.sum\n goals_by_season[season] = (season_goals.to_f / games.count.to_f).round(2)\n end\n end", "def worst_defense\n teams_total_goals_allowed = total_goals_allowed_helper\n teams_total_games = total_games_helper\n\n worst_team_goals_allowed_avg = 0\n worst_defense_team_id = 0\n this_team_goals_allowed_avg = 0\n\n teams_total_games.each do |games_key, games_value|\n\n teams_total_goals_allowed.each do |goals_key, goals_value|\n if goals_key == games_key\n this_team_goals_allowed_avg = (goals_value / games_value.to_f)\n if this_team_goals_allowed_avg > worst_team_goals_allowed_avg\n worst_team_goals_allowed_avg = this_team_goals_allowed_avg\n worst_defense_team_id = games_key\n end\n end\n end\n end\n team_with_worst_defense = team_name_finder_helper(worst_defense_team_id)\n\n team_with_worst_defense\n end", "def goals_against(team)\n valid = ((team == self.home_team or team == self.away_team) and self.final)\n\n if (valid)\n if (self.home_team == team)\n return self.awayScore\n else\n return self.homeScore\n end\n else\n return 0\n end\n end", "def winning_team\n home_team_sum = 0\n away_team_sum = 0\n game_hash.each do |team, team_stats|\n if team_stats[:team_name] == \"Brooklyn Nets\"\n team_stats[:players].each do |player_stats|\n home_team_sum += player_stats[:points]\n end\n elsif team_stats[:team_name] == \"Charlotte Hornets\"\n team_stats[:players].each do |player_stats|\n away_team_sum += player_stats[:points]\n end\n end\n end\n if home_team_sum > away_team_sum\n game_hash[:home][:team_name]\n elsif home_team_sum < away_team_sum\n game_hash[:away][:team_name]\n end\nend", "def winning_team\n home_score = 0\n away_score = 0\n game_hash[:home][:players].keys.each do |name|\n home_score += game_hash[:home][:players][name][:points]\n end\n game_hash[:away][:players].keys.each do |name|\n away_score += game_hash[:away][:players][name][:points]\n end\n home_score > away_score ? game_hash[:home][:team_name] : game_hash[:away][:team_name]\nend", "def winning_team\n home_team_points = game_hash[:home][:players].sum { |e| e[:points] }\n away_team_points = game_hash[:away][:players].sum { |e| e[:points] }\n\n if home_team_points > away_team_points\n return game_hash[:home][:team_name]\n else\n return game_hash[:away][:team_name]\n end\nend", "def winning_team\n final_scores = player_collection.reduce(home: 0, away: 0) { |teams_points, next_player|\n case \n when next_player[:location] === :away\n teams_points[:away] += next_player[:points];\n when next_player[:location] === :home\n teams_points[:home] += next_player[:points];\n end\n teams_points; \n }\n winner = final_scores.reduce { |highest_points, team_points| \n highest_points[1] > team_points[1] ? highest_points : team_points; \n }\n game_hash[winner[0]][:team_name]; \nend", "def best_offense\n @teams.max_by { |team| team.average_goals_scored }.team_name\n end", "def best_fans\n @teams.max_by { |team| team.home_minus_away_percentage }.team_name\n end", "def smallest_team\n self.teams.min{|t1,t2| t1.runners.size <=> t2.runners.size }\n end", "def pri_tdef\n team_stats.opp_goals_per_game / team_stats.opp_avg_goals_against_per_game\n end", "def get_standings(games)\n teams = Hash.new\n games.each do |game|\n division_id = game.division_id\n home_team = game.home_team\n away_team = game.visiting_team\n if(teams[home_team.name].nil?)\n teams[home_team.name] = {:win => 0, :loss => 0, :tie => 0, :point=> 0}\n end\n\n if(teams[away_team.name].nil?)\n teams[away_team.name] = {:win => 0, :loss => 0, :tie => 0, :point => 0}\n end\n if(game.home_team_score && game.visiting_team_score)\n if(game.home_team_score > game.visiting_team_score)\n # home team won\n teams[home_team.name][:win] += 1\n teams[home_team.name][:point] += 5\n # visiting team loss\n teams[away_team.name][:loss] += 1\n elsif(game.home_team_score < game.visiting_team_score)\n # home team loss\n teams[home_team.name][:loss] += 1\n #visiting team won\n teams[away_team.name][:win] += 1\n teams[away_team.name][:point] += 5\n else\n # tie game\n teams[home_team.name][:tie] += 1\n teams[home_team.name][:point] += 1\n teams[away_team.name][:tie] += 1\n teams[away_team.name][:point] += 1\n end\n end\n end\n teams.each do |team, value|\n puts team\n total_games = value[:win] + value[:loss] + value[:tie]\n if total_games > 0 \n win_percentage = value[:win]/total_games.to_f\n else\n win_percentage = 0\n end \n value[:percentage] = win_percentage\n end\n teams_sorted = teams.sort_by{ |k, v| v[:point]}.reverse\n return teams_sorted\n end", "def highest_scoring_visitor\n @teams.max_by { |team| team.average_away_goals }.team_name\n end", "def team_with_more_points(game)\n home_points = game[:home_team][:players].collect do |player|\n player[:stats][:points]\n end.inject {|sum, n| sum + n}\n away_points = game[:away_team][:players].collect do |player|\n player[:stats][:points]\n end.inject {|sum, n| sum + n}\n home_points > away_points ? game[:home_team][:team_name] : game[:away_team][:team_name]\nend", "def pri_toff\n team_stats.goals_per_game / team_stats.opp_avg_goals_per_game\n end", "def winning_team\n team_p = []\n team_n = []\n\n game_hash.each do | location, team_data|\n temp = 0\n team_data[:players].each do |p_name, stats|\n temp += stats[:points]\n end\n team_n << team_data[:team_name]\n team_p << temp\n end\n\n team_p[0] > team_p[1] ? team_n[0] : team_n[1]\n\nend", "def winningest_team\n @teams.max_by { |team| team.total_win_percentage }.team_name\n end", "def winning_team\n if homeTeamPoints.sum > awayTeamPoints.sum\n \"Brooklyn Nets\"\n else\n \"Charlotte Hornets\"\n end\nend", "def winning_team\n home_points = 0\n away_points = 0\n result = \"\"\n i = 0\n game_hash.each do |team, about|\n about[:players].each do |name , stats|\n if i == 0\n home_points += stats[:points]\n else\n away_points += stats[:points]\n end\n end\n i += 1\n end\n home_points > away_points ? result = game_hash[:home][:team_name] : result = game_hash[:away][:team_name]\nend", "def winning_team\n points_home = 0\n points_away = 0\n result = \"\"\n\n game_hash.each do |side,team|\n team.each do |specs,info|\n if specs == :players\n info.each do |player|\n if side = :home\n points_home += player[:points]\n else\n points_away += player[:points]\n end\n end\n end\n end\n end\n if points_home > points_away\n result = game_hash[:home][:team_name]\n else\n result = game_hash[:away][:team_name]\n end\n result\nend", "def batting_average(year: nil, team: nil)\n hits, at_bats = 0, 0\n\n seasonal_stats.each do |stat_line|\n year_match = stat_line.year == year || year == nil\n team_match = stat_line.team == team || team == nil\n if year_match && team_match\n hits += stat_line.hits\n at_bats += stat_line.at_bats\n end\n end\n\n if (at_bats != 0)\n return (hits.to_f / at_bats)\n else\n return 0.0\n end\n end", "def winning_team\n self.teams.order('score DESC').first\n end", "def load_stats\n[\n {\n home_team: \"Jets\",\n away_team: \"Giants\",\n home_score: 21,\n away_score: 3\n },\n {\n home_team: \"Steelers\",\n away_team: \"Giants\",\n home_score: 21,\n away_score: 3\n },\n {\n home_team: \"Patriots\",\n away_team: \"Giants\",\n home_score: 21,\n away_score: 3\n },\n {\n home_team: \"Chargers\",\n away_team: \"Jets\",\n home_score: 13,\n away_score: 6\n },\n {\n home_team: \"Patriots\",\n away_team: \"Jets\",\n home_score: 13,\n away_score: 6\n },\n {\n home_team: \"Steelers\",\n away_team: \"Jets\",\n home_score: 3,\n away_score: 6\n },\n {\n home_team: \"Dolphins\",\n away_team: \"Jets\",\n home_score: 0,\n away_score: 3\n },\n{\n home_team: \"Browns\",\n away_team: \"Jets\",\n home_score: 0,\n away_score: 21\n },\n {\n home_team: \"Chargers\",\n away_team: \"Jets\",\n home_score: 7,\n away_score: 21\n },\n {\n home_team: \"Steelers\",\n away_team: \"Broncos\",\n home_score: 7,\n away_score: 13\n },\n {\n home_team: \"Patriots\",\n away_team: \"Broncos\",\n home_score: 7,\n away_score: 3\n },\n {\n home_team: \"Broncos\",\n away_team: \"Colts\",\n home_score: 3,\n away_score: 0\n },\n {\n home_team: \"Patriots\",\n away_team: \"Colts\",\n home_score: 11,\n away_score: 7\n },\n {\n home_team: \"Steelers\",\n away_team: \"Patriots\",\n home_score: 7,\n away_score: 21\n },\n {\n home_team: \"Steelers\",\n away_team: \"Colts\",\n home_score: 24,\n away_score: 21\n },\n {\n home_team: \"Steelers\",\n away_team: \"Colts\",\n home_score: 24,\n away_score: 21\n }\n]\nend", "def points_in_team(team)\r\n perfs = self.performances.where(team: team)\r\n perfs.map(&:points).inject(:+) / perfs.length\r\n end", "def total_team_score(teams_id)\n total_score = 0\n @league_data.each do\n |team| \n # binding.pry\n if team.home_team_id == teams_id\n total_score += team.home_team_score\n elsif team.away_team_id == teams_id\n total_score += team.away_team_score\n end\n end\n return total_score\n end", "def total_score\n @all_games.map do |games|\n games[\"home_goals\"].to_i + games[\"away_goals\"].to_i\n end\n end", "def worst_defense\n @teams.max_by { |team| team.average_goals_allowed }.team_name\n end", "def winning_team\n home_points = 0\n away_points = 0\n team1 = \"Brooklyn Nets\"\n team2 = \"Charlotte Hornets\"\n game_hash.each do |team,info|\n info.each do |team_info,team_data|\n if team_data.is_a? (Array) \n if team_info != :colors\n if info[:team_name] == \"Brooklyn Nets\"\n team_data.each do |player_index|\n home_points += player_index[:points]\n end\n else \n team_data.each do |player_index|\n away_points += player_index[:points]\n winning_team end\n end\n end\n end\n end\n end\n\n if home_points > away_points\n team1\n else\n team2\n end\n\nend", "def most_accurate_team(seasonasstring) # shots in game team stats\n #get a list of all teams that played in that season - given by arg\n #use above list to sum all shots across all games in season\n #divide above by goals made across all games in season\n #find highest percentage\n #return team name as found in 127\n end", "def highest_total_score\n total_goals.max\n end", "def calculate_score(team)\n scores.includes(:wattball_player).where(:wattball_players => {:team_id => team}).sum(:amount) \n end", "def least_popular_venue\n venues = @games.group_by { |game| game.venue}\n venues.min_by { |venue, games| games.count }.first\n end", "def average_win_percentage(team_id)\n team_id = team_id.to_i\n team = @teams.select { |each_team| each_team.team_id == team_id }.first\n team.total_win_percentage.round(2)\n end", "def calculate_team_ranking_score(number_of_meetings = 2, number_of_bests = 3)\n team_ranking_results = []\n events = []\n if @badge.category_type.code != 'U25' &&\n @badge.meetings.distinct.count >= number_of_meetings\n get_results.each do |meeting_individual_result|\n next unless meeting_individual_result.get_scheduled_date.year - @swimmer.year_of_birth >= 25\n\n next if events.include?(meeting_individual_result.event_type.code)\n\n team_ranking_results << meeting_individual_result\n events << meeting_individual_result.event_type.code\n break if team_ranking_results.count == number_of_bests\n end\n end\n BestLimitedRankingDAO.new(team_ranking_results)\n end", "def starters_average\n total = self.players.starter.inject(0) {|result, element| result + element.average_qualities}\n return total / MIN_PLAYERS\n end", "def winning_team\n nets = []\n hornets = []\n\n game_hash.values.each do |nets_stats|\n if nets_stats[:team_name] == \"Brooklyn Nets\"\n nets_stats[:players].each do |bk|\n nets << bk[:points]\n end\n end\n end\n\n game_hash.values.each do |hornets_stats|\n if hornets_stats[:team_name] == \"Charlotte Hornets\"\n hornets_stats[:players].each do |ch|\n hornets << ch[:points]\n end\n end\n end\n\n if nets.reduce(:+) > hornets.reduce(:+)\n return \"Brooklyn Nets\"\n else\n return \"Charlotte Hornets\"\n end\nend", "def most_points_scored\n points_scored = 0 # starting score to compare with players shoe sizes\n game_hash.each do |location, team_data| # iterates through each team\n players_array = team_data[:players] # finds the :players info in team_data and puts the players into players_array\n players_array.each do |player_name, data| # iterates through each player..\n if data[:points] > points_scored # if their points scored is greater than 0 (we set this earlier in the top of method)\n points_scored = data[:shoe] # take that players score and make it the new points_scored value\n end # this repeats (iterates) through all players until you don't have any more.. meaning the end result is\n end # the player with the highest score\n end\n return points_scored\nend", "def best_score\n submissions.min(:score)\n end", "def lacrosse_scoring_average(sport, player)\n\t\tgoals = 0\n\t\tgames = sport.teams.find(player.team_id).gameschedules\n\n\t\tgames.each do |g|\n\t\t\tstat = g.lacrosstats.find_by(athlete_id: player.id)\n\t\t\tgoals += stat.lacross_scorings.count if stat.lacross_scorings.any?\n\t\tend\n\n\t\tif games > 0\n\t\t\treturn goals / games.count\n\t\telse\n\t\t\treturn 0.0\n\t\tend\n\tend", "def goals_against()\n\t self.as_regular_contestants.select{|c| c.opponent.score}.collect{|c| c.opponent.score}.inject{|gf, c| gf + c} || 0\n\tend", "def worst_season(team_id)\n team_id = team_id.to_i\n team = @teams.select { |each_team| each_team.team_id == team_id }.first\n team.season_win_percentages.min_by { |season, percentage| percentage }.first.to_s\n end", "def lowest_score\n sort\n all.last.score\n end", "def most_goals_scored(team_id)\n team_id = team_id.to_i\n goals_per_game = @game_teams.map do |game|\n if game.team_id == team_id\n game.goals\n end\n end\n goals_per_game.compact.max\n end", "def rank_top_teams # DO NOT USE THIS METHOD, outdated, slow\n @top_teams = {}\n @top_teams = Score.in_challenge(self.id).teams_in_all_divisions.limit(5).\n order(\"sum_points DESC, MAX(#{Score.table_name}.\n earned_at) DESC\").sum(:points) \n return @top_teams\n end", "def goals_for()\n\t self.as_regular_contestants.select{|c| c.score}.collect{|c| c.score}.inject{|gf, c| gf + c} || 0\n\tend", "def biggest_blowout\n score_difference = games.map { |game| (game.home_goals - game.away_goals).abs}\n score_difference.max\n end", "def winning_team_with_spread\n\t\tif self.final?\n\t\t\treturn home_team_id if home_team_score > away_team_score + point_spread\n\t\t\treturn away_team_id if away_team_score + point_spread > home_team_score\n\t\t\treturn \"tie\" if home_team_score == away_team_score + point_spread\n\t\telse\n\t\t\treturn nil\n\t\tend\n\tend", "def rating_average(team, match)\n if match.ended?\n sum = 0; team.each { |u| sum += u['rating'].to_i }\n else\n sum = 0; team.users.each { |u| sum += u['rating'].to_i }\n end\n sum / 5\n end", "def percentage_visitor_wins\n visitor_wins = @teams.map { |team| team.away_wins }.sum\n visitor_games = @teams.map { |team| team.away_games }.sum\n (visitor_wins.to_f / visitor_games.to_f).round(2)\n end", "def least_accurate_team(seasonasstring) # shots in game team stats\n #inverse of above\n end", "def total_score\n sum = self.games.sum{|game|game.points}\n sum.to_i / self.games.count\n end", "def determine_winner game\n winner = game.max_by {|team| team[:score]}\n team_standings = get_team_by_name(winner)\n team_standings[:winnings] += 3\nend", "def cost_function(state, home_team, away_team)\n match_set = Set[home_team, away_team]\n cost = 0\n\n # Reduce score distance between teams\n cost += ((state.scores[home_team] || 0) - (state.scores[away_team] || 0)).abs\n\n # The cost of a duplicate is the score range + 1\n cost += (state.score_range + 1) * state.matches[match_set] unless state.allow_duplicates\n\n # Add cost for bye matches not on the preferred side\n push_byes_to = state.push_byes_to\n if match_set.include?(nil) && push_byes_to != :none\n index = state.team_index_map[home_team || away_team]\n\n if (push_byes_to == :bottom_half && index < state.teams.length / 2) ||\n (push_byes_to == :top_half && index > state.teams.length / 2)\n cost += state.score_range\n elsif push_byes_to == :lowest_score\n cost += state.score_range * (state.teams.length - index)**2\n end\n end\n\n cost\n end", "def most_points_scored\nbest_player = \"\"\npoints = 0\ngame_hash.each do |location, team_data|\n team_data[:players].each do |name, stats|\n if stats[:points] > points\n points = stats[:points]\n best_player= name\n end\n end\nend\nbest_player\nend", "def average_difficulty\n @p = live_problems\n if @p.size > 0\n @avg = @p.inject(0.0){|sum, i| sum + Difficulty.to_int(i.difficulty) } / @p.size\n else\n @avg = nil\n end\n end", "def most_points_scored\n most_points = 0\n most_points_player = nil\n game_hash.each do |team, team_stats|\n team_stats[:players].each do |player_stats|\n if most_points < player_stats[:points]\n most_points = player_stats[:points]\n most_points_player = player_stats[:player_name]\n end\n end\n end\n most_points_player\nend", "def goals_by_hoa_id_suite\n goals_by_away_id\n goals_by_home_id\n average_score_per_away_game_by_team_id\n average_score_per_home_game_by_team_id\n end", "def goals_by_hoa_id_suite\n goals_by_away_id\n goals_by_home_id\n average_score_per_away_game_by_team_id\n average_score_per_home_game_by_team_id\n end", "def home_stat\n @home.team_stat\n end", "def best_season(team_id)\n team_id = team_id.to_i\n team = @teams.select { |each_team| each_team.team_id == team_id }.first\n team.season_win_percentages.max_by { |season, percentage| percentage }.first.to_s\n end", "def most_points(game)\n player_name_with_points = []\n game[:home_team][:players].each do |player_hash|\n player_name_with_points << {player_hash[:player_name] => player_hash[:stats][:points]}\n end\n game[:away_team][:players].each do |player_hash|\n player_name_with_points << {player_hash[:player_name] => player_hash[:stats][:points]}\n end\n player_most_points = {\"test\" => 0}\n player_name_with_points.each do |name_and_points_hash|\n player_most_points = name_and_points_hash if name_and_points_hash.values[0] > player_most_points.values[0]\n end\n player_most_points.keys[0]\nend", "def score\n goals = self.match_events.select { |e| e.event_type == MatchEvent::EventType::GOAL }\n goals.reduce({away: 0, home: 0}) do |score, e|\n if e.event_author == MatchEvent::EventAuthor::HOME\n score[:home] += 1\n elsif e.event_author == MatchEvent::EventAuthor::AWAY\n score[:away] += 1\n end\n score\n end\n end", "def worst_loss(team_id)\n @games.map do |game|\n if game.away_team_id.to_s == team_id\n game.home_goals - game.away_goals\n elsif game.home_team_id.to_s == team_id\n game.away_goals - game.home_goals\n end\n end.compact.max\n end", "def average_player_age\n players.average(:age)\n end", "def best_score(a_of_g)\n best_score = a_of_g.flatten.return_objects_with(:attempts, 0).max_attribute(:adjusted_goodness)\n end", "def improve_teams\n @teams = steepest_ascent_hill(@teams)\n end", "def player_w_biggest_feet\n all_players[1].max_by { |stats| stats[:shoe] }\n end", "def winner_team(game)\n result = nil\n if game.team1_goals.present? && game.team2_goals.present?\n result = game.team1 if game.team1_goals > game.team2_goals\n result = game.team2 if game.team1_goals < game.team2_goals\n end\n\n result\n end", "def most_hits(seasonasstring) # shots in game team stats\n #get a list of all teams that played in that season\n #use above list to sum all shots across all games in season\n #find highest across list\n #return team name as found in 139\n end", "def average_fitness\n total_fitness = 0\n @all_persons.each do |person|\n total_fitness += person.get_energy_level\n end\n if @all_persons.empty?\n return 0\n else\n total_fitness / @total_people\n end\n end", "def test_average_goals_per_game\n\n assert_equal 4.22, @stat_tracker.average_goals_per_game\n end", "def avg_score\n deploy_average_scoring? ? self[:avg_score] : 0\n end", "def season_with_fewest_games\n seasons = @games.group_by { |game| game.season }\n seasons.min_by { |season, games| games.count }.first\n end", "def mean_overall\n sum_overall / hits_overall\n end", "def team_hits(hits, team)\n if team.current_units <= hits\n team.units.all.each do |u|\n u.update(count:0)\n end\n else\n u = team.units.where(priority:1).first\n while hits > 0 and team.current_units > 0\n if u.count > 0 and hits > 0\n u.update(count: u.count-1)\n hits-=1\n else\n u = u.next\n end\n end\n return team\n end\n end", "def energy()\n score = 0\n @matches.each do |m|\n # Teams Same School\n if m.team_a.school == m.team_b.school\n score -= @penalties[:teams_same_school]\n end\n # Judges Same School\n m.judges.each do |j|\n if j.school == m.team_a.school\n score -= @penalties[:judge_same_school]\n end\n if j.school == m.team_b.school\n score -= @penalties[:judge_same_school]\n end\n end\n # Different Win/Loss\n if m.team_a.num_wins != m.team_b.num_wins\n score -= (1 + @penalties[:different_win_loss]) **\n (m.team_a.num_wins - m.team_b.num_wins).abs\n score -= 1 # No, really, this makes sense...\n end\n end\n score\n end", "def rating\n position_sum = 0\n games = []\n number_of_teams = 0\n Participation.find_all_by_player_id(self.id).each do |participation|\n position_sum += participation.position\n games.push Game.find(participation.game_id)\n end\n\n games.each do |game|\n number_of_teams += game.number_of_teams\n end\n\n if position_sum == 0\n position_sum = number_of_teams.to_f-0.5\n end\n\n (1 - position_sum.to_f/number_of_teams).round 2\n end", "def high_score\n if self.end_date < Date.today\n self.teams.max_by { |team| team.score }.score\n end\n end", "def get_score(formation)\n lowest_score = Float::MAX\n formation.each do |proj_id, teamArr|\n #TODO multiply each score by the weight from the professor\n score = @professor_preferences[:scheduleWeight]*get_schedule_score(teamArr) + \n @professor_preferences[:codingWeight]*get_coding_score(teamArr) + \n @professor_preferences[:partnerWeight]*get_partner_score(teamArr) + \n @professor_preferences[:projectWeight]*get_project_score(teamArr,proj_id)\n # puts \"each score is\",score\n if (score < lowest_score) then\n lowest_score = score\n end\n end\n return lowest_score\n end", "def calculate_team_points\n # If the bracket is complete, we can calculate points based on the\n # teams' `final_rank`s.\n if @state == \"complete\"\n calculate_team_points_by_final_rank\n return\n end\n\n # For each team, look at the matches that it is in, look at the point\n # values of those matches, and take the maximum point value. That's the\n # number of points that the team has earned so far in the bracket.\n base_point_value = @config.base_point_value\n\n @teams.each do |team|\n matches_with_team = @matches.select { |match| match.has_team?(team.id) }\n\n puts \"Team #{team.name} was in #{matches_with_team.size} matches\"\n\n points_earned = matches_with_team.max_by(&:points).points\n\n puts \"The largest point value of those matches is #{points_earned}\" \\\n \"#{\" + #{base_point_value} base\" if base_point_value > 0}\"\n\n team.points = points_earned + base_point_value\n end\n end", "def homeTeamPoints\n teamSelect(\"Brooklyn Nets\")[:players].collect do |name, stats|\n stats[:points]\n end\nend", "def calculate_final_score\n self.scores.average(:total_score)\n end", "def most_points_scored\n max = nil\n name = nil \n game_hash.each do |team, team_values|\n team_values[:players].each do |player|\n if max == nil || player[:points] > max\n max = player[:points]\n name = player[:player_name]\n end\n end\n end\n name\nend", "def team_score\n team_member = @current_user.team.users\n team_comment = Comment.where(user_id: team_member.pluck('id'))\n emotion_scores = team_comment.where('created_at BETWEEN ? AND ?', DateTime.now.beginning_of_day, DateTime.now.end_of_day).average(:score)\n emotion_scores\n end", "def one_team_stats(team_name)\n game_hash.each do |home_or_away, team_stats|\n if team_stats[:team_name] == team_name\n return team_stats\n end\n end\nend", "def most_points_scored\n most_points = 0\n player = \"\"\n game_hash.each do |k, team|\n team[:players].each do |e|\n if e[:points] > most_points\n most_points = e[:points]\n player = e[:player_name]\n end\n end\n end\n player\nend", "def avg_of_toryo_turn_max\n s = lose_scope\n s = s.joins(:battle)\n s = s.where(Swars::Battle.arel_table[:final_key].eq(\"TORYO\"))\n if v = s.average(Swars::Battle.arel_table[:turn_max])\n v.to_i\n end\n end" ]
[ "0.8073401", "0.78645605", "0.7827987", "0.7360488", "0.7327204", "0.7295785", "0.72853065", "0.71943265", "0.71651137", "0.71547544", "0.713908", "0.71190727", "0.7097124", "0.7079516", "0.69551605", "0.69438064", "0.6908398", "0.68860847", "0.6848193", "0.68428135", "0.6806161", "0.6788171", "0.67870915", "0.6733521", "0.66597795", "0.6615088", "0.65847355", "0.6575093", "0.65288365", "0.65150964", "0.6510798", "0.65011704", "0.6471703", "0.6471659", "0.6467525", "0.6467384", "0.6456514", "0.6394108", "0.63707745", "0.6369927", "0.63523644", "0.6350912", "0.63481", "0.6320312", "0.6312031", "0.6294031", "0.62870675", "0.6275378", "0.6274021", "0.62718225", "0.6269783", "0.62559325", "0.62317705", "0.62248105", "0.6193559", "0.618611", "0.6176605", "0.61718714", "0.6163372", "0.61527544", "0.61526144", "0.6127739", "0.6110531", "0.6091204", "0.6078001", "0.6076107", "0.6074113", "0.6071241", "0.6067794", "0.6050651", "0.6050651", "0.60379106", "0.60292184", "0.6022697", "0.60221124", "0.6020031", "0.6016734", "0.59964186", "0.59793854", "0.59757775", "0.5961461", "0.5961102", "0.5953873", "0.5938329", "0.59378266", "0.5928615", "0.5925031", "0.59248173", "0.59191966", "0.5898553", "0.5881736", "0.58667445", "0.58659875", "0.5862684", "0.58575445", "0.5856735", "0.58556247", "0.5850825", "0.5843281", "0.5830004" ]
0.8341824
0
returns team with highest win percentage
def winningest_team @teams.max_by { |team| team.total_win_percentage }.team_name end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def best_offense\n @teams.max_by { |team| team.average_goals_scored }.team_name\n end", "def best_fans\n @teams.max_by { |team| team.home_minus_away_percentage }.team_name\n end", "def winning_team\n self.teams.order('score DESC').first\n end", "def highest_scoring_visitor\n @teams.max_by { |team| team.average_away_goals }.team_name\n end", "def worst_offense\n @teams.min_by { |team| team.average_goals_scored }.team_name\n end", "def worst_offense\n teams_total_goals = total_goals_helper\n teams_total_games = total_games_helper\n\n worst_team_goals_avg = 1000\n worst_offense_team_id = 0\n this_team_goals_avg = 0\n\n teams_total_games.each do |games_key, games_value|\n teams_total_goals.each do |goals_key, goals_value|\n if goals_key == games_key\n this_team_goals_avg = (goals_value / games_value.to_f)\n if this_team_goals_avg < worst_team_goals_avg\n worst_team_goals_avg = this_team_goals_avg\n worst_offense_team_id = games_key\n end\n end\n end\n end\n\n team_with_worst_offense = nil\n self.teams.each_value do |team_obj|\n if team_obj.team_id. == worst_offense_team_id\n team_with_worst_offense = team_obj.team_name\n end\n end\n team_with_worst_offense\n end", "def highest_scoring_home_team\n @teams.max_by { |team| team.average_home_goals }.team_name\n end", "def most_accurate_team(seasonasstring) # shots in game team stats\n #get a list of all teams that played in that season - given by arg\n #use above list to sum all shots across all games in season\n #divide above by goals made across all games in season\n #find highest percentage\n #return team name as found in 127\n end", "def worst_defense\n @teams.max_by { |team| team.average_goals_allowed }.team_name\n end", "def winner\n @players.max_by do |player|\n player.score\n end\n end", "def best_season(team_id)\n team_id = team_id.to_i\n team = @teams.select { |each_team| each_team.team_id == team_id }.first\n team.season_win_percentages.max_by { |season, percentage| percentage }.first.to_s\n end", "def winner\n @players.max_by{ |player| player.score}\n end", "def determine_winner game\n winner = game.max_by {|team| team[:score]}\n team_standings = get_team_by_name(winner)\n team_standings[:winnings] += 3\nend", "def most_goals_scored(team_id)\n team_id = team_id.to_i\n goals_per_game = @game_teams.map do |game|\n if game.team_id == team_id\n game.goals\n end\n end\n goals_per_game.compact.max\n end", "def highest_total_score\n total_goals.max\n end", "def worst_defense\n teams_total_goals_allowed = total_goals_allowed_helper\n teams_total_games = total_games_helper\n\n worst_team_goals_allowed_avg = 0\n worst_defense_team_id = 0\n this_team_goals_allowed_avg = 0\n\n teams_total_games.each do |games_key, games_value|\n\n teams_total_goals_allowed.each do |goals_key, goals_value|\n if goals_key == games_key\n this_team_goals_allowed_avg = (goals_value / games_value.to_f)\n if this_team_goals_allowed_avg > worst_team_goals_allowed_avg\n worst_team_goals_allowed_avg = this_team_goals_allowed_avg\n worst_defense_team_id = games_key\n end\n end\n end\n end\n team_with_worst_defense = team_name_finder_helper(worst_defense_team_id)\n\n team_with_worst_defense\n end", "def average_win_percentage(team_id)\n team_id = team_id.to_i\n team = @teams.select { |each_team| each_team.team_id == team_id }.first\n team.total_win_percentage.round(2)\n end", "def winning_team\n final_scores = player_collection.reduce(home: 0, away: 0) { |teams_points, next_player|\n case \n when next_player[:location] === :away\n teams_points[:away] += next_player[:points];\n when next_player[:location] === :home\n teams_points[:home] += next_player[:points];\n end\n teams_points; \n }\n winner = final_scores.reduce { |highest_points, team_points| \n highest_points[1] > team_points[1] ? highest_points : team_points; \n }\n game_hash[winner[0]][:team_name]; \nend", "def worst_season(team_id)\n team_id = team_id.to_i\n team = @teams.select { |each_team| each_team.team_id == team_id }.first\n team.season_win_percentages.min_by { |season, percentage| percentage }.first.to_s\n end", "def best_defense\n teams_total_goals_allowed = total_goals_allowed_helper\n teams_total_games = total_games_helper\n\n best_team_goals_allowed_avg = 100\n best_defense_team_id = 0\n this_team_goals_allowed_avg = 0\n\n teams_total_games.each do |games_key, games_value|\n teams_total_goals_allowed.each do |goals_key, goals_value|\n if goals_key == games_key\n this_team_goals_allowed_avg = (goals_value / games_value.to_f)\n if this_team_goals_allowed_avg < best_team_goals_allowed_avg\n best_team_goals_allowed_avg = this_team_goals_allowed_avg\n best_defense_team_id = games_key\n end\n end\n end\n end\n\n team_with_best_defense = nil\n self.teams.each_value do |team_obj|\n if team_obj.team_id. == best_defense_team_id\n team_with_best_defense = team_obj.team_name\n end\n end\n team_with_best_defense\n end", "def find_best_score(total_per_player)\n best_score = 0\n winner = ''\n total_per_player.each do |player_name,total|\n\n if total > best_score\n best_score = total\n winner = player_name\n end\n end\n return winner\n end", "def highest_player_score\n players.max_by{|player| player.score}.score\n end", "def winning_scores\n high_score = scores.max{|score| score.total}.total\n scores.select {|score| score.total == high_score}\n end", "def best_defense\n @teams.min_by { |team| team.average_goals_allowed }.team_name\n end", "def winning_team\n home_points = collection_by_prop(game_hash[:home], :points).reduce(0, :+)\n away_points = collection_by_prop(game_hash[:away], :points).reduce(0, :+)\n home_points > away_points ? game_hash[:home][:team_name] : game_hash[:away][:team_name]\n end", "def player_w_biggest_feet\n all_players[1].max_by { |stats| stats[:shoe] }\n end", "def biggest_blowout\n score_difference = games.map { |game| (game.home_goals - game.away_goals).abs}\n score_difference.max\n end", "def favorite_opponent(team_id)\n team_id = team_id.to_i\n team = @teams.select { |each_team| each_team.team_id == team_id }.first\n favorite_opponent_id = team.matchup_win_percentage.max_by{|each_team, percentage| percentage}.first\n @teams.select { |each_team| each_team.team_id == favorite_opponent_id }.first.team_name\n end", "def winning_team\n home_team_points = game_hash[:home][:players].sum { |e| e[:points] }\n away_team_points = game_hash[:away][:players].sum { |e| e[:points] }\n\n if home_team_points > away_team_points\n return game_hash[:home][:team_name]\n else\n return game_hash[:away][:team_name]\n end\nend", "def worst_loss(team_id)\n @games.map do |game|\n if game.away_team_id.to_s == team_id\n game.home_goals - game.away_goals\n elsif game.home_team_id.to_s == team_id\n game.away_goals - game.home_goals\n end\n end.compact.max\n end", "def winning_team\n if homeTeamPoints.sum > awayTeamPoints.sum\n \"Brooklyn Nets\"\n else\n \"Charlotte Hornets\"\n end\nend", "def most_points_scored\n max = nil\n name = nil \n game_hash.each do |team, team_values|\n team_values[:players].each do |player|\n if max == nil || player[:points] > max\n max = player[:points]\n name = player[:player_name]\n end\n end\n end\n name\nend", "def high_score\n if self.end_date < Date.today\n self.teams.max_by { |team| team.score }.score\n end\n end", "def calculate_overall_winner\n points_per_player = {}\n @matches.each do | match |\n !points_per_player[match.winner].nil? ? (points_per_player[match.winner] += 1) : (points_per_player[match.winner] = 1)\n end\n max_points = points_per_player.values.max\n points_per_player.key(max_points)\n end", "def biggest_team_blowout(team_id)\n @games.map do |game|\n if game.away_team_id.to_s == team_id\n game.away_goals - game.home_goals\n elsif game.home_team_id.to_s == team_id\n game.home_goals - game.away_goals\n end\n end.compact.max\n end", "def winning_team\n team_p = []\n team_n = []\n\n game_hash.each do | location, team_data|\n temp = 0\n team_data[:players].each do |p_name, stats|\n temp += stats[:points]\n end\n team_n << team_data[:team_name]\n team_p << temp\n end\n\n team_p[0] > team_p[1] ? team_n[0] : team_n[1]\n\nend", "def most_points_scored\n stat_by_player = collect_stat_by_name(:points)\n player_with_max_stat = find_max_stat_by_player(stat_by_player)\n player_with_max_stat\nend", "def highest_total_score\n @game_manager.highest_total_score\n end", "def winning_team\n home_team_sum = 0\n away_team_sum = 0\n game_hash.each do |team, team_stats|\n if team_stats[:team_name] == \"Brooklyn Nets\"\n team_stats[:players].each do |player_stats|\n home_team_sum += player_stats[:points]\n end\n elsif team_stats[:team_name] == \"Charlotte Hornets\"\n team_stats[:players].each do |player_stats|\n away_team_sum += player_stats[:points]\n end\n end\n end\n if home_team_sum > away_team_sum\n game_hash[:home][:team_name]\n elsif home_team_sum < away_team_sum\n game_hash[:away][:team_name]\n end\nend", "def winning_team\n home_score = 0\n away_score = 0\n game_hash[:home][:players].keys.each do |name|\n home_score += game_hash[:home][:players][name][:points]\n end\n game_hash[:away][:players].keys.each do |name|\n away_score += game_hash[:away][:players][name][:points]\n end\n home_score > away_score ? game_hash[:home][:team_name] : game_hash[:away][:team_name]\nend", "def percentage_visitor_wins\n visitor_wins = @teams.map { |team| team.away_wins }.sum\n visitor_games = @teams.map { |team| team.away_games }.sum\n (visitor_wins.to_f / visitor_games.to_f).round(2)\n end", "def player_win_percentage\n (games_won/user_games)\n end", "def fewest_goals_scored(team_id)\n team_id = team_id.to_i\n goals_per_game = @game_teams.map do |game|\n if game.team_id == team_id\n game.goals\n end\n end\n goals_per_game.compact.min\n end", "def winning_team\n nets = []\n hornets = []\n\n game_hash.values.each do |nets_stats|\n if nets_stats[:team_name] == \"Brooklyn Nets\"\n nets_stats[:players].each do |bk|\n nets << bk[:points]\n end\n end\n end\n\n game_hash.values.each do |hornets_stats|\n if hornets_stats[:team_name] == \"Charlotte Hornets\"\n hornets_stats[:players].each do |ch|\n hornets << ch[:points]\n end\n end\n end\n\n if nets.reduce(:+) > hornets.reduce(:+)\n return \"Brooklyn Nets\"\n else\n return \"Charlotte Hornets\"\n end\nend", "def most_points_scored\n most_points = 0\n most_points_player = nil\n game_hash.each do |team, team_stats|\n team_stats[:players].each do |player_stats|\n if most_points < player_stats[:points]\n most_points = player_stats[:points]\n most_points_player = player_stats[:player_name]\n end\n end\n end\n most_points_player\nend", "def win_percent\n matchmade_games < 1 ? 0 : ((total_exp.to_f/matchmade_games.to_f) * 100).to_d\n end", "def ranks\n @teams = Team.where(\"wins > 0\t\").order(win_percentage: :desc)\n end", "def mostSteals\n players.max_by do|name, stats|\n stats[:steals]\n end\nend", "def most_points_scored\n points_scored = 0 # starting score to compare with players shoe sizes\n game_hash.each do |location, team_data| # iterates through each team\n players_array = team_data[:players] # finds the :players info in team_data and puts the players into players_array\n players_array.each do |player_name, data| # iterates through each player..\n if data[:points] > points_scored # if their points scored is greater than 0 (we set this earlier in the top of method)\n points_scored = data[:shoe] # take that players score and make it the new points_scored value\n end # this repeats (iterates) through all players until you don't have any more.. meaning the end result is\n end # the player with the highest score\n end\n return points_scored\nend", "def percentage_home_wins\n home_wins = @teams.map { |team| team.home_wins }.sum\n home_games = @teams.map { |team| team.home_games }.sum\n (home_wins.to_f / home_games.to_f).round(2)\n end", "def most_points_scored\nbest_player = \"\"\npoints = 0\ngame_hash.each do |location, team_data|\n team_data[:players].each do |name, stats|\n if stats[:points] > points\n points = stats[:points]\n best_player= name\n end\n end\nend\nbest_player\nend", "def winning_player\n played_cards.max_by { |_, card| card_scores[card] }.first\n end", "def most_points_scored\n most_points = 0\n player = \"\"\n game_hash.each do |k, team|\n team[:players].each do |e|\n if e[:points] > most_points\n most_points = e[:points]\n player = e[:player_name]\n end\n end\n end\n player\nend", "def percent_wins(wins)\n ((wins.to_f / @num_games.to_f) * 100).round(4)\n end", "def most_hits(seasonasstring) # shots in game team stats\n #get a list of all teams that played in that season\n #use above list to sum all shots across all games in season\n #find highest across list\n #return team name as found in 139\n end", "def best_season(id)\n wins = total_wins_per_team_per_season(id)\n totals = total_games_per_team_per_season(id)\n totals.each do |season, total|\n totals[season] = (wins[season] / total.to_f * 100).round(2)\n end\n totals.max_by {|k,v| v}[0]\n end", "def winner\n\t\ts = {}\n\t\t@vPlayers.each {|player|\n\t\t\ts[player.name.to_s] = player.score.totalScore\n\t\t}\n\t\tmax = s.values.max\n\t\tname = s.select{|k, v| v == max}.keys\n\t\tscore = s.select{|k, v| v == max}.values\n\t\t\n\t\tprint \"The winner is \" + name[0].to_s + \" with a total score of \" + score[0].to_s\n\t\tputs \"\",\"\"\n\t\t\n\tend", "def winning_team\n home_points = 0\n away_points = 0\n result = \"\"\n i = 0\n game_hash.each do |team, about|\n about[:players].each do |name , stats|\n if i == 0\n home_points += stats[:points]\n else\n away_points += stats[:points]\n end\n end\n i += 1\n end\n home_points > away_points ? result = game_hash[:home][:team_name] : result = game_hash[:away][:team_name]\nend", "def most_points(game)\nmax_points = 0\nmax_points_player = \"\"\ngame.each do |team, team_contents|\n team_contents[:roster].each do |player, player_contents| \n if player_contents[:points] == max_points\n max_points_player = max_points_player + \" and #{player_contents[:player_name]}\"\n elsif player_contents[:points] > max_points\n max_points = player_contents[:points]\n max_points_player = player_contents[:player_name]\n end\n end\nend\nputs \"#{max_points_player} scored #{max_points}\"\nend", "def get_win_percentage(strategy)\n score = 0\n @turns.each do |t|\n score += t.result.to_i if t.strategy.include?(strategy)\n end\n score\n end", "def lowest_scoring_visitor\n @teams.min_by { |team| team.average_away_goals }.team_name\n end", "def score_for_team(team)\n team ||= winner_team\n winner_team?(team) ? score : scores.reverse.join(':')\n end", "def max_teams(rounds)\n 2**rounds\n end", "def max_teams(rounds)\n 2**rounds\n end", "def biggestShoes\n players.max_by do|name, stats|\n stats[:shoe]\n end\nend", "def get_max_over(stat)\n max = 0\n $data_enemies.each { |enemy|\n next if enemy.nil?\n next if enemy.hidden_best\n next unless $game_party.known_enemy?(enemy.id)\n value = enemy.get_stat(stat)\n max = value if value > max\n }\n max\n end", "def biggest_surprise(season)\n season = season.to_i\n @teams.max_by{ |team| team.preseason_to_regular_increase[season] }.team_name\n end", "def mostPoints\n players.max_by do|name, stats|\n stats[:points]\n end\nend", "def most_points_scored()\n points = 0\n result = \"\"\n\n game_hash.each do |side,team|\n team.each do |specs,info|\n if specs == :players\n info.each do |player|\n if player[:points] > points\n points = player[:points]\n result = player[:player_name]\n\n end\n end\n end\n end\n end\n result\nend", "def most_points(game)\n player_name_with_points = []\n game[:home_team][:players].each do |player_hash|\n player_name_with_points << {player_hash[:player_name] => player_hash[:stats][:points]}\n end\n game[:away_team][:players].each do |player_hash|\n player_name_with_points << {player_hash[:player_name] => player_hash[:stats][:points]}\n end\n player_most_points = {\"test\" => 0}\n player_name_with_points.each do |name_and_points_hash|\n player_most_points = name_and_points_hash if name_and_points_hash.values[0] > player_most_points.values[0]\n end\n player_most_points.keys[0]\nend", "def worst_fans\n teams_with_bad_fans = @teams.find_all { |team| team.home_minus_away_percentage.negative? }\n teams_with_bad_fans.map { |team| team.team_name }\n end", "def winner_team(game)\n result = nil\n if game.team1_goals.present? && game.team2_goals.present?\n result = game.team1 if game.team1_goals > game.team2_goals\n result = game.team2 if game.team1_goals < game.team2_goals\n end\n\n result\n end", "def determine_match_winner\n @games_to_win = ((total_number_of_games / 2.0).floor) + 1\n if player1.score == games_to_win\n return player1\n elsif player2.score == games_to_win\n return player2\n else\n return nil\n end\n end", "def most_points_scored\n big_score_player = player_collection.reduce { |memo, next_player|\n memo[:points] > next_player[:points] ? memo : next_player; \n }\n big_score_player[:player_name];\nend", "def percent_high_ranking\n ((high_ranking_cards.count.to_f / @cards.count.to_f) * 100).round(2)\n end", "def percent_high_ranking\n (high_ranking_cards.count.fdiv(@cards.count) * 100).round(2)\n end", "def big_shoe_rebounds\n max_shoe = 0 \n max_rebounds = 0 \n game_hash.each do |place, team|\n # team.each do |attribute, data|\n team[:players].each do |player|\n if player[:shoe] > max_shoe\n max_shoe = player[:shoe]\n max_rebounds = player[:rebounds]\n # if attribute == :players\n # data.each do |player|\n #this gives me the player hashes\n # data.max_by{|player| player[:shoe] }\n # data.max_by{|player| player[:shoe] }[:rebounds]\n # player.max_by{|player| player[:shoe] \n # player.max_by{|player| player[:shoe] }[:rebounds]\n end\n end\n end\n return max_rebounds\n end", "def total_team_score(teams_id)\n total_score = 0\n @league_data.each do\n |team| \n # binding.pry\n if team.home_team_id == teams_id\n total_score += team.home_team_score\n elsif team.away_team_id == teams_id\n total_score += team.away_team_score\n end\n end\n return total_score\n end", "def compute_team_winner\n if completed?\n team_winner\n else\n if first_team && second_team\n if sets_won(first_team) == min_sets_to_play\n first_team\n elsif sets_won(second_team) == min_sets_to_play\n second_team\n end\n end\n end\n end", "def winner\n if (self.homeScore > self.awayScore)\n return self.home_team\n elsif (self.awayScore > self.homeScore)\n return self.away_team\n else\n return nil\n end\n end", "def lowest_scoring_home_team\n @teams.min_by { |team| team.average_home_goals }.team_name\n end", "def max_score\n return score if @state != STATE_OK\n\n next_boards.map(&:min_score).min\n end", "def winning_team_with_spread\n\t\tif self.final?\n\t\t\treturn home_team_id if home_team_score > away_team_score + point_spread\n\t\t\treturn away_team_id if away_team_score + point_spread > home_team_score\n\t\t\treturn \"tie\" if home_team_score == away_team_score + point_spread\n\t\telse\n\t\t\treturn nil\n\t\tend\n\tend", "def percent_high_ranking\n number_of_high_cards = self.high_ranking_cards.length.to_f\n number_of_all_cards = self.cards.length.to_f\n\n percentage = number_of_high_cards / number_of_all_cards\n percentage_rounded = (percentage * 100).round(2)\n\n return percentage_rounded\n end", "def most_points_scored\n\tpoints_array = []\n\tgame_hash.each do |location, team_data|\n\t\tteam_data[:players].each do |attribute, data|\t\n\t\t\tdata.each do |type, amount|\n\t\t\t\tif type == :points\n\t\t\t\t\tpoints_array << amount\n\t\t\t\tend \n\t\t\tend\n\t\tend\n\tend\n\tgame_hash.each do |l, data|\n\t\tdata[:players].each do |a, d|\n\t\t\td.each do |t, amt|\n\t\t\t\tif t == :points && points_array.max == amt\n\t\t\t\t\treturn a\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend\nend", "def rank_top_teams # DO NOT USE THIS METHOD, outdated, slow\n @top_teams = {}\n @top_teams = Score.in_challenge(self.id).teams_in_all_divisions.limit(5).\n order(\"sum_points DESC, MAX(#{Score.table_name}.\n earned_at) DESC\").sum(:points) \n return @top_teams\n end", "def most_points_scored\n points = 0\n result = \"\"\n game_hash.each do |team, about|\n about[:players].each do |name , stats|\n if points < stats[:points]\n points = stats[:points]\n result = name\n end\n end\n end\n result\nend", "def team_with_more_points(game)\n home_points = game[:home_team][:players].collect do |player|\n player[:stats][:points]\n end.inject {|sum, n| sum + n}\n away_points = game[:away_team][:players].collect do |player|\n player[:stats][:points]\n end.inject {|sum, n| sum + n}\n home_points > away_points ? game[:home_team][:team_name] : game[:away_team][:team_name]\nend", "def highest_score\n sorted_all_scores = self.leaderboard_entries.order(score: :DESC)\n sorted_all_scores[0]\n end", "def rival(team_id)\n team_id = team_id.to_i\n team = @teams.select { |each_team| each_team.team_id == team_id }.first\n rival_id = team.matchup_win_percentage.min_by{|each_team, percentage| percentage}.first\n @teams.select { |each_team| each_team.team_id == rival_id }.first.team_name\n end", "def winning_team\n most_points_scored_helper\n winning_team = \"\"\n \n game_hash.each do |key, value|\n players = value[:players]\n players.each do |element|\n if most_points_scored_helper == element[:points]\n winning_team = value[:team_name]\n end\n end\n end\n winning_team\nend", "def winning_team\n points_home = 0\n points_away = 0\n result = \"\"\n\n game_hash.each do |side,team|\n team.each do |specs,info|\n if specs == :players\n info.each do |player|\n if side = :home\n points_home += player[:points]\n else\n points_away += player[:points]\n end\n end\n end\n end\n end\n if points_home > points_away\n result = game_hash[:home][:team_name]\n else\n result = game_hash[:away][:team_name]\n end\n result\nend", "def get_standings(games)\n teams = Hash.new\n games.each do |game|\n division_id = game.division_id\n home_team = game.home_team\n away_team = game.visiting_team\n if(teams[home_team.name].nil?)\n teams[home_team.name] = {:win => 0, :loss => 0, :tie => 0, :point=> 0}\n end\n\n if(teams[away_team.name].nil?)\n teams[away_team.name] = {:win => 0, :loss => 0, :tie => 0, :point => 0}\n end\n if(game.home_team_score && game.visiting_team_score)\n if(game.home_team_score > game.visiting_team_score)\n # home team won\n teams[home_team.name][:win] += 1\n teams[home_team.name][:point] += 5\n # visiting team loss\n teams[away_team.name][:loss] += 1\n elsif(game.home_team_score < game.visiting_team_score)\n # home team loss\n teams[home_team.name][:loss] += 1\n #visiting team won\n teams[away_team.name][:win] += 1\n teams[away_team.name][:point] += 5\n else\n # tie game\n teams[home_team.name][:tie] += 1\n teams[home_team.name][:point] += 1\n teams[away_team.name][:tie] += 1\n teams[away_team.name][:point] += 1\n end\n end\n end\n teams.each do |team, value|\n puts team\n total_games = value[:win] + value[:loss] + value[:tie]\n if total_games > 0 \n win_percentage = value[:win]/total_games.to_f\n else\n win_percentage = 0\n end \n value[:percentage] = win_percentage\n end\n teams_sorted = teams.sort_by{ |k, v| v[:point]}.reverse\n return teams_sorted\n end", "def percent_high_ranking\n high = 0.0\n low = 0.0\n cards.each do |card|\n if card.rank >= 11\n high += 1\n else\n low += 1\n end\n end\n (high * 100 / (high + low)).ceil(2)\n end", "def big_shoe_rebounds\n\nhighest_rebounds = 0\nbiggest_shoe = 0\n\n game_hash.each do |location, team_info|\n game_hash.dig(location, :players).each do |player_name, stats|\n stats.each do |stat, number|\n if stat == :shoe\n if number > biggest_shoe\n biggest_shoe = number\n stats.each do |stat, number|\n if stat == :rebounds\n highest_rebounds = number\n end\n end\n end\n end\n end\n end\n end\n puts highest_rebounds\n return highest_rebounds\nend", "def best_offense\n offense_suite\n best_offense_id = @average_goals_by_id.invert.max[1]\n @team_name_by_id[best_offense_id]\n end", "def winning_team\n blue_team.winner? ? blue_team : red_team\n end", "def goals_for(team)\n valid = ((team == self.home_team or team == self.away_team) and self.final)\n\n if (valid)\n if (self.home_team == team)\n return self.homeScore\n else\n return self.awayScore\n end\n else\n return 0\n end\n end", "def player_with_most_steals\n name = \"\"\n most_steals = 0\n\n game_hash.each do | team, details_hash |\n players_array = details_hash[:players]\n players_array.each do | player_details_hash |\n if player_details_hash[:steals] > most_steals\n most_steals = player_details_hash[:steals]\n name = player_details_hash[:player_name]\n end\n end\n end\n name\nend", "def guess_round(driver)\n driver.team_matches_hash.values.map(&:length).max || 0\n end" ]
[ "0.7832164", "0.77665305", "0.77201337", "0.76693183", "0.7600592", "0.75982714", "0.7582269", "0.7509363", "0.7494715", "0.7465297", "0.74483234", "0.74413943", "0.74051833", "0.73354596", "0.73294055", "0.7321826", "0.7306663", "0.73024404", "0.729635", "0.7288597", "0.7288246", "0.7284007", "0.72769094", "0.72654945", "0.7235728", "0.72216463", "0.72071666", "0.71899563", "0.71619505", "0.7141771", "0.71307683", "0.71165496", "0.70638", "0.7048117", "0.7023722", "0.7005763", "0.6961093", "0.69554806", "0.69391996", "0.6934384", "0.693159", "0.69303864", "0.69243467", "0.6918512", "0.6916181", "0.6915061", "0.68880767", "0.68830806", "0.68721914", "0.6861523", "0.68333", "0.6802624", "0.67924196", "0.67803437", "0.67730767", "0.67244506", "0.6715798", "0.67105824", "0.6703536", "0.67032105", "0.66991776", "0.66952145", "0.6693095", "0.6693095", "0.6681619", "0.6675505", "0.66750574", "0.6670316", "0.6651049", "0.6650169", "0.6647034", "0.66423607", "0.6626593", "0.6625333", "0.66155404", "0.6610386", "0.6605791", "0.65930265", "0.65895295", "0.6588002", "0.65857244", "0.65809125", "0.65729326", "0.65717304", "0.65516365", "0.65482235", "0.654261", "0.65368193", "0.65299857", "0.6521614", "0.6520761", "0.6509937", "0.6505898", "0.6505597", "0.65045315", "0.6495979", "0.64947534", "0.64740336", "0.6472727", "0.6468905" ]
0.85681796
0
returns team with biggest difference between home and away win percentages
def best_fans @teams.max_by { |team| team.home_minus_away_percentage }.team_name end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def winningest_team\n @teams.max_by { |team| team.total_win_percentage }.team_name\n end", "def winning_team\n home_points = collection_by_prop(game_hash[:home], :points).reduce(0, :+)\n away_points = collection_by_prop(game_hash[:away], :points).reduce(0, :+)\n home_points > away_points ? game_hash[:home][:team_name] : game_hash[:away][:team_name]\n end", "def worst_offense\n teams_total_goals = total_goals_helper\n teams_total_games = total_games_helper\n\n worst_team_goals_avg = 1000\n worst_offense_team_id = 0\n this_team_goals_avg = 0\n\n teams_total_games.each do |games_key, games_value|\n teams_total_goals.each do |goals_key, goals_value|\n if goals_key == games_key\n this_team_goals_avg = (goals_value / games_value.to_f)\n if this_team_goals_avg < worst_team_goals_avg\n worst_team_goals_avg = this_team_goals_avg\n worst_offense_team_id = games_key\n end\n end\n end\n end\n\n team_with_worst_offense = nil\n self.teams.each_value do |team_obj|\n if team_obj.team_id. == worst_offense_team_id\n team_with_worst_offense = team_obj.team_name\n end\n end\n team_with_worst_offense\n end", "def worst_defense\n teams_total_goals_allowed = total_goals_allowed_helper\n teams_total_games = total_games_helper\n\n worst_team_goals_allowed_avg = 0\n worst_defense_team_id = 0\n this_team_goals_allowed_avg = 0\n\n teams_total_games.each do |games_key, games_value|\n\n teams_total_goals_allowed.each do |goals_key, goals_value|\n if goals_key == games_key\n this_team_goals_allowed_avg = (goals_value / games_value.to_f)\n if this_team_goals_allowed_avg > worst_team_goals_allowed_avg\n worst_team_goals_allowed_avg = this_team_goals_allowed_avg\n worst_defense_team_id = games_key\n end\n end\n end\n end\n team_with_worst_defense = team_name_finder_helper(worst_defense_team_id)\n\n team_with_worst_defense\n end", "def best_defense\n teams_total_goals_allowed = total_goals_allowed_helper\n teams_total_games = total_games_helper\n\n best_team_goals_allowed_avg = 100\n best_defense_team_id = 0\n this_team_goals_allowed_avg = 0\n\n teams_total_games.each do |games_key, games_value|\n teams_total_goals_allowed.each do |goals_key, goals_value|\n if goals_key == games_key\n this_team_goals_allowed_avg = (goals_value / games_value.to_f)\n if this_team_goals_allowed_avg < best_team_goals_allowed_avg\n best_team_goals_allowed_avg = this_team_goals_allowed_avg\n best_defense_team_id = games_key\n end\n end\n end\n end\n\n team_with_best_defense = nil\n self.teams.each_value do |team_obj|\n if team_obj.team_id. == best_defense_team_id\n team_with_best_defense = team_obj.team_name\n end\n end\n team_with_best_defense\n end", "def best_offense\n @teams.max_by { |team| team.average_goals_scored }.team_name\n end", "def winning_team\n final_scores = player_collection.reduce(home: 0, away: 0) { |teams_points, next_player|\n case \n when next_player[:location] === :away\n teams_points[:away] += next_player[:points];\n when next_player[:location] === :home\n teams_points[:home] += next_player[:points];\n end\n teams_points; \n }\n winner = final_scores.reduce { |highest_points, team_points| \n highest_points[1] > team_points[1] ? highest_points : team_points; \n }\n game_hash[winner[0]][:team_name]; \nend", "def biggest_blowout\n score_difference = games.map { |game| (game.home_goals - game.away_goals).abs}\n score_difference.max\n end", "def highest_scoring_home_team\n @teams.max_by { |team| team.average_home_goals }.team_name\n end", "def worst_offense\n @teams.min_by { |team| team.average_goals_scored }.team_name\n end", "def winning_team\n home_team_points = game_hash[:home][:players].sum { |e| e[:points] }\n away_team_points = game_hash[:away][:players].sum { |e| e[:points] }\n\n if home_team_points > away_team_points\n return game_hash[:home][:team_name]\n else\n return game_hash[:away][:team_name]\n end\nend", "def winning_team\n home_score = 0\n away_score = 0\n game_hash[:home][:players].keys.each do |name|\n home_score += game_hash[:home][:players][name][:points]\n end\n game_hash[:away][:players].keys.each do |name|\n away_score += game_hash[:away][:players][name][:points]\n end\n home_score > away_score ? game_hash[:home][:team_name] : game_hash[:away][:team_name]\nend", "def percentage_home_wins\n home_wins = @teams.map { |team| team.home_wins }.sum\n home_games = @teams.map { |team| team.home_games }.sum\n (home_wins.to_f / home_games.to_f).round(2)\n end", "def winning_team\n home_team_sum = 0\n away_team_sum = 0\n game_hash.each do |team, team_stats|\n if team_stats[:team_name] == \"Brooklyn Nets\"\n team_stats[:players].each do |player_stats|\n home_team_sum += player_stats[:points]\n end\n elsif team_stats[:team_name] == \"Charlotte Hornets\"\n team_stats[:players].each do |player_stats|\n away_team_sum += player_stats[:points]\n end\n end\n end\n if home_team_sum > away_team_sum\n game_hash[:home][:team_name]\n elsif home_team_sum < away_team_sum\n game_hash[:away][:team_name]\n end\nend", "def worst_loss(team_id)\n @games.map do |game|\n if game.away_team_id.to_s == team_id\n game.home_goals - game.away_goals\n elsif game.home_team_id.to_s == team_id\n game.away_goals - game.home_goals\n end\n end.compact.max\n end", "def most_accurate_team(seasonasstring) # shots in game team stats\n #get a list of all teams that played in that season - given by arg\n #use above list to sum all shots across all games in season\n #divide above by goals made across all games in season\n #find highest percentage\n #return team name as found in 127\n end", "def goals_against(team)\n valid = ((team == self.home_team or team == self.away_team) and self.final)\n\n if (valid)\n if (self.home_team == team)\n return self.awayScore\n else\n return self.homeScore\n end\n else\n return 0\n end\n end", "def goals_for(team)\n valid = ((team == self.home_team or team == self.away_team) and self.final)\n\n if (valid)\n if (self.home_team == team)\n return self.homeScore\n else\n return self.awayScore\n end\n else\n return 0\n end\n end", "def winning_team\n if homeTeamPoints.sum > awayTeamPoints.sum\n \"Brooklyn Nets\"\n else\n \"Charlotte Hornets\"\n end\nend", "def worst_defense\n @teams.max_by { |team| team.average_goals_allowed }.team_name\n end", "def team_with_more_points(game)\n home_points = game[:home_team][:players].collect do |player|\n player[:stats][:points]\n end.inject {|sum, n| sum + n}\n away_points = game[:away_team][:players].collect do |player|\n player[:stats][:points]\n end.inject {|sum, n| sum + n}\n home_points > away_points ? game[:home_team][:team_name] : game[:away_team][:team_name]\nend", "def winning_team\n home_points = 0\n away_points = 0\n result = \"\"\n i = 0\n game_hash.each do |team, about|\n about[:players].each do |name , stats|\n if i == 0\n home_points += stats[:points]\n else\n away_points += stats[:points]\n end\n end\n i += 1\n end\n home_points > away_points ? result = game_hash[:home][:team_name] : result = game_hash[:away][:team_name]\nend", "def get_standings(games)\n teams = Hash.new\n games.each do |game|\n division_id = game.division_id\n home_team = game.home_team\n away_team = game.visiting_team\n if(teams[home_team.name].nil?)\n teams[home_team.name] = {:win => 0, :loss => 0, :tie => 0, :point=> 0}\n end\n\n if(teams[away_team.name].nil?)\n teams[away_team.name] = {:win => 0, :loss => 0, :tie => 0, :point => 0}\n end\n if(game.home_team_score && game.visiting_team_score)\n if(game.home_team_score > game.visiting_team_score)\n # home team won\n teams[home_team.name][:win] += 1\n teams[home_team.name][:point] += 5\n # visiting team loss\n teams[away_team.name][:loss] += 1\n elsif(game.home_team_score < game.visiting_team_score)\n # home team loss\n teams[home_team.name][:loss] += 1\n #visiting team won\n teams[away_team.name][:win] += 1\n teams[away_team.name][:point] += 5\n else\n # tie game\n teams[home_team.name][:tie] += 1\n teams[home_team.name][:point] += 1\n teams[away_team.name][:tie] += 1\n teams[away_team.name][:point] += 1\n end\n end\n end\n teams.each do |team, value|\n puts team\n total_games = value[:win] + value[:loss] + value[:tie]\n if total_games > 0 \n win_percentage = value[:win]/total_games.to_f\n else\n win_percentage = 0\n end \n value[:percentage] = win_percentage\n end\n teams_sorted = teams.sort_by{ |k, v| v[:point]}.reverse\n return teams_sorted\n end", "def best_defense\n @teams.min_by { |team| team.average_goals_allowed }.team_name\n end", "def biggest_team_blowout(team_id)\n @games.map do |game|\n if game.away_team_id.to_s == team_id\n game.away_goals - game.home_goals\n elsif game.home_team_id.to_s == team_id\n game.home_goals - game.away_goals\n end\n end.compact.max\n end", "def highest_scoring_visitor\n @teams.max_by { |team| team.average_away_goals }.team_name\n end", "def winning_team\n points_home = 0\n points_away = 0\n result = \"\"\n\n game_hash.each do |side,team|\n team.each do |specs,info|\n if specs == :players\n info.each do |player|\n if side = :home\n points_home += player[:points]\n else\n points_away += player[:points]\n end\n end\n end\n end\n end\n if points_home > points_away\n result = game_hash[:home][:team_name]\n else\n result = game_hash[:away][:team_name]\n end\n result\nend", "def determine_winner game\n winner = game.max_by {|team| team[:score]}\n team_standings = get_team_by_name(winner)\n team_standings[:winnings] += 3\nend", "def winning_team\n self.teams.order('score DESC').first\n end", "def winning_team\n nets = []\n hornets = []\n\n game_hash.values.each do |nets_stats|\n if nets_stats[:team_name] == \"Brooklyn Nets\"\n nets_stats[:players].each do |bk|\n nets << bk[:points]\n end\n end\n end\n\n game_hash.values.each do |hornets_stats|\n if hornets_stats[:team_name] == \"Charlotte Hornets\"\n hornets_stats[:players].each do |ch|\n hornets << ch[:points]\n end\n end\n end\n\n if nets.reduce(:+) > hornets.reduce(:+)\n return \"Brooklyn Nets\"\n else\n return \"Charlotte Hornets\"\n end\nend", "def winning_team\n team_p = []\n team_n = []\n\n game_hash.each do | location, team_data|\n temp = 0\n team_data[:players].each do |p_name, stats|\n temp += stats[:points]\n end\n team_n << team_data[:team_name]\n team_p << temp\n end\n\n team_p[0] > team_p[1] ? team_n[0] : team_n[1]\n\nend", "def percentage_visitor_wins\n visitor_wins = @teams.map { |team| team.away_wins }.sum\n visitor_games = @teams.map { |team| team.away_games }.sum\n (visitor_wins.to_f / visitor_games.to_f).round(2)\n end", "def worst_fans\n teams_with_bad_fans = @teams.find_all { |team| team.home_minus_away_percentage.negative? }\n teams_with_bad_fans.map { |team| team.team_name }\n end", "def winner_team(game)\n result = nil\n if game.team1_goals.present? && game.team2_goals.present?\n result = game.team1 if game.team1_goals > game.team2_goals\n result = game.team2 if game.team1_goals < game.team2_goals\n end\n\n result\n end", "def average_goals_per_game\n total_goals = @teams.map {|team| team.total_goals_scored}.sum\n total_games = @teams.map {|team| team.home_games}.sum\n (total_goals.to_f / total_games.to_f).round(2)\n end", "def pri_toff\n team_stats.goals_per_game / team_stats.opp_avg_goals_per_game\n end", "def best_season(team_id)\n team_id = team_id.to_i\n team = @teams.select { |each_team| each_team.team_id == team_id }.first\n team.season_win_percentages.max_by { |season, percentage| percentage }.first.to_s\n end", "def worst_season(team_id)\n team_id = team_id.to_i\n team = @teams.select { |each_team| each_team.team_id == team_id }.first\n team.season_win_percentages.min_by { |season, percentage| percentage }.first.to_s\n end", "def player_w_biggest_feet\n all_players[1].max_by { |stats| stats[:shoe] }\n end", "def winning_team_with_spread\n\t\tif self.final?\n\t\t\treturn home_team_id if home_team_score > away_team_score + point_spread\n\t\t\treturn away_team_id if away_team_score + point_spread > home_team_score\n\t\t\treturn \"tie\" if home_team_score == away_team_score + point_spread\n\t\telse\n\t\t\treturn nil\n\t\tend\n\tend", "def goal_difference\n total_diff = 0\n\n wattball_matches_as_team1.each do |match|\n total_diff += match.goal_difference[0]\n end\n\n wattball_matches_as_team2.each do |match|\n total_diff += match.goal_difference[1]\n end\n \n total_diff\n end", "def average_win_percentage(team_id)\n team_id = team_id.to_i\n team = @teams.select { |each_team| each_team.team_id == team_id }.first\n team.total_win_percentage.round(2)\n end", "def most_goals_scored(team_id)\n team_id = team_id.to_i\n goals_per_game = @game_teams.map do |game|\n if game.team_id == team_id\n game.goals\n end\n end\n goals_per_game.compact.max\n end", "def winner\n if (self.homeScore > self.awayScore)\n return self.home_team\n elsif (self.awayScore > self.homeScore)\n return self.away_team\n else\n return nil\n end\n end", "def fewest_goals_scored(team_id)\n team_id = team_id.to_i\n goals_per_game = @game_teams.map do |game|\n if game.team_id == team_id\n game.goals\n end\n end\n goals_per_game.compact.min\n end", "def lowest_scoring_home_team\n @teams.min_by { |team| team.average_home_goals }.team_name\n end", "def winning_team\n home_points = 0\n away_points = 0\n team1 = \"Brooklyn Nets\"\n team2 = \"Charlotte Hornets\"\n game_hash.each do |team,info|\n info.each do |team_info,team_data|\n if team_data.is_a? (Array) \n if team_info != :colors\n if info[:team_name] == \"Brooklyn Nets\"\n team_data.each do |player_index|\n home_points += player_index[:points]\n end\n else \n team_data.each do |player_index|\n away_points += player_index[:points]\n winning_team end\n end\n end\n end\n end\n end\n\n if home_points > away_points\n team1\n else\n team2\n end\n\nend", "def cost_function(state, home_team, away_team)\n match_set = Set[home_team, away_team]\n cost = 0\n\n # Reduce score distance between teams\n cost += ((state.scores[home_team] || 0) - (state.scores[away_team] || 0)).abs\n\n # The cost of a duplicate is the score range + 1\n cost += (state.score_range + 1) * state.matches[match_set] unless state.allow_duplicates\n\n # Add cost for bye matches not on the preferred side\n push_byes_to = state.push_byes_to\n if match_set.include?(nil) && push_byes_to != :none\n index = state.team_index_map[home_team || away_team]\n\n if (push_byes_to == :bottom_half && index < state.teams.length / 2) ||\n (push_byes_to == :top_half && index > state.teams.length / 2)\n cost += state.score_range\n elsif push_byes_to == :lowest_score\n cost += state.score_range * (state.teams.length - index)**2\n end\n end\n\n cost\n end", "def total_team_score(teams_id)\n total_score = 0\n @league_data.each do\n |team| \n # binding.pry\n if team.home_team_id == teams_id\n total_score += team.home_team_score\n elsif team.away_team_id == teams_id\n total_score += team.away_team_score\n end\n end\n return total_score\n end", "def outcome\n if self.final\n \th = home_team\n \ta = away_team\n \t# h.wins=0 if h.wins==nil\n \t# h.losses=0 if h.losses==nil\n \t# a.wins=0 if a.wins==nil\n \t# a.losses=0 if a.losses==nil\n \tif home_score == away_score\n \t\treturn 'T'\n \telsif home_score > away_score\n \t\tif !self.recorded\n \t \t\th.wins += 1\n \t \t\ta.losses += 1\n \t \t\th.save\n \t \t\ta.save\n \t \t\tself.recorded=true\n \t \t\tself.save\n \t \tend\n \t\tif overtime\n \t\t\treturn 'h'\n \t\telse\n \t\t\treturn 'H'\n \t\tend\n \telse\n \t\tif !self.recorded\n \t \t\th.losses += 1\n \t \t\ta.wins += 1\n \t \t\ta.save\n \t \t\th.save\n \t \t\tself.recorded=true\n \t \t\tself.save\n \t \tend\n \t\tif overtime\n \t\t\treturn 'a'\n \t\telse\n \t\t\treturn 'A'\n \t\tend\n \tend\n end\n end", "def big_shoe_rebounds\n max_shoe = 0 \n max_rebounds = 0 \n game_hash.each do |place, team|\n # team.each do |attribute, data|\n team[:players].each do |player|\n if player[:shoe] > max_shoe\n max_shoe = player[:shoe]\n max_rebounds = player[:rebounds]\n # if attribute == :players\n # data.each do |player|\n #this gives me the player hashes\n # data.max_by{|player| player[:shoe] }\n # data.max_by{|player| player[:shoe] }[:rebounds]\n # player.max_by{|player| player[:shoe] \n # player.max_by{|player| player[:shoe] }[:rebounds]\n end\n end\n end\n return max_rebounds\n end", "def most_points(game)\n player_name_with_points = []\n game[:home_team][:players].each do |player_hash|\n player_name_with_points << {player_hash[:player_name] => player_hash[:stats][:points]}\n end\n game[:away_team][:players].each do |player_hash|\n player_name_with_points << {player_hash[:player_name] => player_hash[:stats][:points]}\n end\n player_most_points = {\"test\" => 0}\n player_name_with_points.each do |name_and_points_hash|\n player_most_points = name_and_points_hash if name_and_points_hash.values[0] > player_most_points.values[0]\n end\n player_most_points.keys[0]\nend", "def favorite_opponent(team_id)\n team_id = team_id.to_i\n team = @teams.select { |each_team| each_team.team_id == team_id }.first\n favorite_opponent_id = team.matchup_win_percentage.max_by{|each_team, percentage| percentage}.first\n @teams.select { |each_team| each_team.team_id == favorite_opponent_id }.first.team_name\n end", "def goal_difference\n p1 = calculate_score(team1)\n p2 = calculate_score(team2)\n\n return 0 if p1.nil? or p2.nil?\n\n diff = p1 - p2\n\n diff_1 = diff\n diff_1 = 0 if diff_1 < 0\n\n # The goal difference for second team is the inverse\n diff_2 = -diff\n diff_2 = 0 if diff_2 < 0\n\n [diff_1, diff_2]\n end", "def pri_tdef\n team_stats.opp_goals_per_game / team_stats.opp_avg_goals_against_per_game\n end", "def player_win_percentage\n (games_won/user_games)\n end", "def win_percent\n matchmade_games < 1 ? 0 : ((total_exp.to_f/matchmade_games.to_f) * 100).to_d\n end", "def winning_team\n blue_team.winner? ? blue_team : red_team\n end", "def high_score\n if self.end_date < Date.today\n self.teams.max_by { |team| team.score }.score\n end\n end", "def compute_team_winner\n if completed?\n team_winner\n else\n if first_team && second_team\n if sets_won(first_team) == min_sets_to_play\n first_team\n elsif sets_won(second_team) == min_sets_to_play\n second_team\n end\n end\n end\n end", "def highest_total_score\n total_goals.max\n end", "def winning_scores\n high_score = scores.max{|score| score.total}.total\n scores.select {|score| score.total == high_score}\n end", "def max_teams(rounds)\n 2**rounds\n end", "def max_teams(rounds)\n 2**rounds\n end", "def winning_team\n total_points = 0 #initialize points at zero \n \n win_team = '' #set win team to an empty string \n \n game_hash.each do |location, team| #iterating over game hash\n team_points = 0 #initialize team points at zero \n team_name = game_hash[location][:team_name] \n # set team name = to game_hash at the the location at the # :team name \n \n team[:players].each do |player| #iterate over players \n points = player[:points] # set points = player points \n team_points += points #team points is the addition of every single point value from each player\n \n #binding.pry \n end\n \n win_team, total_points = team_name, team_points if team_points > total_points\n \n #binding.pry \n \n end\n \n return win_team\n\nend", "def most_hits(seasonasstring) # shots in game team stats\n #get a list of all teams that played in that season\n #use above list to sum all shots across all games in season\n #find highest across list\n #return team name as found in 139\n end", "def winning_team(result)\n goals = result.split(\"-\")\n if goals[0] == goals[1]\n \"draw\"\n elsif goals[0].to_i > goals[1].to_i\n \"home\"\n else\n \"away\"\n end\n end", "def find_best_score(total_per_player)\n best_score = 0\n winner = ''\n total_per_player.each do |player_name,total|\n\n if total > best_score\n best_score = total\n winner = player_name\n end\n end\n return winner\n end", "def score_for_team(team)\n team ||= winner_team\n winner_team?(team) ? score : scores.reverse.join(':')\n end", "def biggest_surprise(season)\n season = season.to_i\n @teams.max_by{ |team| team.preseason_to_regular_increase[season] }.team_name\n end", "def points_in_team(team)\r\n perfs = self.performances.where(team: team)\r\n perfs.map(&:points).inject(:+) / perfs.length\r\n end", "def calculate_overall_winner\n points_per_player = {}\n @matches.each do | match |\n !points_per_player[match.winner].nil? ? (points_per_player[match.winner] += 1) : (points_per_player[match.winner] = 1)\n end\n max_points = points_per_player.values.max\n points_per_player.key(max_points)\n end", "def lowest_scoring_visitor\n @teams.min_by { |team| team.average_away_goals }.team_name\n end", "def most_points_scored\n max = nil\n name = nil \n game_hash.each do |team, team_values|\n team_values[:players].each do |player|\n if max == nil || player[:points] > max\n max = player[:points]\n name = player[:player_name]\n end\n end\n end\n name\nend", "def big_shoe_rebounds\n\nhighest_rebounds = 0\nbiggest_shoe = 0\n\n game_hash.each do |location, team_info|\n game_hash.dig(location, :players).each do |player_name, stats|\n stats.each do |stat, number|\n if stat == :shoe\n if number > biggest_shoe\n biggest_shoe = number\n stats.each do |stat, number|\n if stat == :rebounds\n highest_rebounds = number\n end\n end\n end\n end\n end\n end\n end\n puts highest_rebounds\n return highest_rebounds\nend", "def probability_by_win_ratio(delta)\n # A team wins between 0% and 100% of its games\n # Comparing two teams, the difference in percentages will also be between 0% and 100%\n # If they have equal win percentages, then it is a tossup--50/50\n # If one team has won 100% and the other has won 0%,\n # ...then there is a 100% win percentage different between them\n # ...in that case, the odds should be 100% in favor of the 100% team.\n 0.5 + 0.5 * delta\nend", "def away_stat\n @away.team_stat\n end", "def winner\n @players.max_by do |player|\n player.score\n end\n end", "def calculate_team_points\n # If the bracket is complete, we can calculate points based on the\n # teams' `final_rank`s.\n if @state == \"complete\"\n calculate_team_points_by_final_rank\n return\n end\n\n # For each team, look at the matches that it is in, look at the point\n # values of those matches, and take the maximum point value. That's the\n # number of points that the team has earned so far in the bracket.\n base_point_value = @config.base_point_value\n\n @teams.each do |team|\n matches_with_team = @matches.select { |match| match.has_team?(team.id) }\n\n puts \"Team #{team.name} was in #{matches_with_team.size} matches\"\n\n points_earned = matches_with_team.max_by(&:points).points\n\n puts \"The largest point value of those matches is #{points_earned}\" \\\n \"#{\" + #{base_point_value} base\" if base_point_value > 0}\"\n\n team.points = points_earned + base_point_value\n end\n end", "def overall_WLR\n overall_losses = 0\n overall_wins = 0\n @player_champs_list.each do |champ|\n overall_losses += champ.total_losses\n overall_wins += champ.total_wins\n end\n overall_losses > 0 ? (overall_wins.to_f / overall_losses).round(2) : overall_wins.to_f\n end", "def winner\n @players.max_by{ |player| player.score}\n end", "def bp_odds_on_favorite\n\t\tfav_team=Teamseason.new\n\t\tfav_team.year=self.matchup_year\n\t\tfav_team.team=self.favorite \n\t\tunderdog_team=Teamseason.new\n\t\tunderdog_team.year=self.matchup_year\n\t\tunderdog_team.team=self.underdog\n\t\treturn fav_team.bp_ros_win_pct.to_f.odds_against_opponent(underdog_team.bp_ros_win_pct.to_f)\n\tend", "def most_points_scored\n most_points = 0\n most_points_player = nil\n game_hash.each do |team, team_stats|\n team_stats[:players].each do |player_stats|\n if most_points < player_stats[:points]\n most_points = player_stats[:points]\n most_points_player = player_stats[:player_name]\n end\n end\n end\n most_points_player\nend", "def wins_losses\n GAME_INFO.each do |game|\n @team_records.each do |team|\n if game[:home_team] == team.name && game[:home_score] > game[:away_score] #refactor later\n team.wins += 1\n elsif game[:home_team] == team.name && game[:home_score] < game[:away_score]\n team.losses += 1\n end\n end\n end\n\n GAME_INFO.each do |game|\n @team_records.each do |team|\n if game[:away_team] == team.name && game[:away_score] > game[:home_score] #refactor later\n team.wins += 1\n elsif game[:away_team] == team.name && game[:away_score] < game[:home_score]\n team.losses += 1\n end\n end\n end\n\n end", "def ranks\n @teams = Team.where(\"wins > 0\t\").order(win_percentage: :desc)\n end", "def calculate_team_ranking_score(number_of_meetings = 2, number_of_bests = 3)\n team_ranking_results = []\n events = []\n if @badge.category_type.code != 'U25' &&\n @badge.meetings.distinct.count >= number_of_meetings\n get_results.each do |meeting_individual_result|\n next unless meeting_individual_result.get_scheduled_date.year - @swimmer.year_of_birth >= 25\n\n next if events.include?(meeting_individual_result.event_type.code)\n\n team_ranking_results << meeting_individual_result\n events << meeting_individual_result.event_type.code\n break if team_ranking_results.count == number_of_bests\n end\n end\n BestLimitedRankingDAO.new(team_ranking_results)\n end", "def big_shoe_rebounds_2\n\nhighest_rebounds = 0\nbiggest_shoe = 0\n\n\n game_hash.dig(:home, :players).each do |player_name, stats|\n stats.each do |stat, number|\n if stat == :shoe\n if number > biggest_shoe\n biggest_shoe = number\n stats.each do |stat, number|\n if stat == :rebounds\n highest_rebounds = number\n\n end\n end\n end\n end\n end\nend\n\n puts highest_rebounds\n return highest_rebounds\nend", "def wins\n wins = 0\n self.teams.each do |team|\n wins += team.games_won.length\n end\n wins\n end", "def team_hitting_pull_up\n return nil unless pull_up?\n team1.stats.wins > team2.stats.wins ? team1 : team2\n end", "def rebounds_for_player_with_largest_shoe_size(game)\n shoe_sizes_with_player_names = []\n game[:home_team][:players].each do |player_hash|\n shoe_sizes_with_player_names << {player_hash[:player_name] => player_hash[:shoe_size]}\n end\n game[:away_team][:players].each do |player_hash|\n shoe_sizes_with_player_names << {player_hash[:player_name] => player_hash[:shoe_size]}\n end\n biggest_shoe_size = {\"test\" => 0}\n shoe_sizes_with_player_names.each do |shoe_size_and_name_hash|\n biggest_shoe_size = shoe_size_and_name_hash if shoe_size_and_name_hash.values[0] > biggest_shoe_size.values[0]\n end\n game[:home_team][:players].each do |player_hash|\n return player_hash[:stats][:rebounds] if player_hash[:player_name] == biggest_shoe_size.keys[0]\n end\n game[:away_team][:players].each do |player_hash|\n return player_hash[:stats][:rebounds] if player_hash[:player_name] == biggest_shoe_size.keys[0]\n end\nend", "def least_accurate_team(seasonasstring) # shots in game team stats\n #inverse of above\n end", "def most_points_scored\n points_scored = 0 # starting score to compare with players shoe sizes\n game_hash.each do |location, team_data| # iterates through each team\n players_array = team_data[:players] # finds the :players info in team_data and puts the players into players_array\n players_array.each do |player_name, data| # iterates through each player..\n if data[:points] > points_scored # if their points scored is greater than 0 (we set this earlier in the top of method)\n points_scored = data[:shoe] # take that players score and make it the new points_scored value\n end # this repeats (iterates) through all players until you don't have any more.. meaning the end result is\n end # the player with the highest score\n end\n return points_scored\nend", "def lowest_total_score\n total_game_scores = games.map { |game| game.home_goals + game.away_goals}\n total_game_scores.min\n end", "def highest_total_score\n @game_manager.highest_total_score\n end", "def energy()\n score = 0\n @matches.each do |m|\n # Teams Same School\n if m.team_a.school == m.team_b.school\n score -= @penalties[:teams_same_school]\n end\n # Judges Same School\n m.judges.each do |j|\n if j.school == m.team_a.school\n score -= @penalties[:judge_same_school]\n end\n if j.school == m.team_b.school\n score -= @penalties[:judge_same_school]\n end\n end\n # Different Win/Loss\n if m.team_a.num_wins != m.team_b.num_wins\n score -= (1 + @penalties[:different_win_loss]) **\n (m.team_a.num_wins - m.team_b.num_wins).abs\n score -= 1 # No, really, this makes sense...\n end\n end\n score\n end", "def coach_win_percent_in_season(coach, game_ids)\n (total_wins_of_coach_in_season(coach, game_ids) / total_coach_games_in_season(coach, game_ids).to_f).round(2)\n end", "def teams_with_score_max(a_game)\n teams_with_score_max = {}\n game_teams_with_score_max = a_game.teams_with_score_max(a_game.game_teams)\n game_teams_with_score_max.each do |game_team_with_score_max|\n # find team instance matching game_team instance\n team_with_score_max = @teams[game_team_with_score_max.name.to_sym]\n teams_with_score_max[game_team_with_score_max.name.to_sym] = team_with_score_max\n end\n teams_with_score_max\n end", "def winning_team\n most_points_scored_helper\n winning_team = \"\"\n \n game_hash.each do |key, value|\n players = value[:players]\n players.each do |element|\n if most_points_scored_helper == element[:points]\n winning_team = value[:team_name]\n end\n end\n end\n winning_team\nend", "def team_hits(hits, team)\n if team.current_units <= hits\n team.units.all.each do |u|\n u.update(count:0)\n end\n else\n u = team.units.where(priority:1).first\n while hits > 0 and team.current_units > 0\n if u.count > 0 and hits > 0\n u.update(count: u.count-1)\n hits-=1\n else\n u = u.next\n end\n end\n return team\n end\n end", "def improve_teams\n @teams = steepest_ascent_hill(@teams)\n end" ]
[ "0.8112752", "0.78451234", "0.7827476", "0.7651408", "0.75903213", "0.74962246", "0.74860215", "0.74774885", "0.7475335", "0.744287", "0.7434385", "0.7423453", "0.74211466", "0.7407326", "0.7397977", "0.73921394", "0.73618555", "0.7359654", "0.73264456", "0.72402686", "0.7211193", "0.71542585", "0.7153965", "0.7150895", "0.71399254", "0.71207446", "0.71156996", "0.70652527", "0.70644194", "0.7040586", "0.7026589", "0.70009494", "0.688188", "0.6858029", "0.683804", "0.6834305", "0.6802593", "0.67885584", "0.6787915", "0.67851865", "0.67790127", "0.67656267", "0.6747673", "0.6739669", "0.6713477", "0.6685008", "0.66770333", "0.66690415", "0.6660474", "0.66570807", "0.6645032", "0.6634505", "0.6634073", "0.6628506", "0.6627197", "0.6625517", "0.66078025", "0.6596336", "0.6581972", "0.6581222", "0.6558578", "0.6536636", "0.65218306", "0.65218306", "0.65208054", "0.6517633", "0.6499435", "0.64892375", "0.64569765", "0.6443553", "0.6439111", "0.6425588", "0.64248174", "0.64239293", "0.6421903", "0.64171064", "0.63681173", "0.6364577", "0.63637704", "0.6363504", "0.6355233", "0.63415456", "0.6340139", "0.6332695", "0.6330872", "0.6328858", "0.63242537", "0.6323924", "0.6320719", "0.6307882", "0.63058937", "0.63046", "0.63045996", "0.62998486", "0.6298135", "0.62868655", "0.6277344", "0.6260436", "0.6250321", "0.62479645" ]
0.76920617
3
returns array with all teams with better away than home records
def worst_fans teams_with_bad_fans = @teams.find_all { |team| team.home_minus_away_percentage.negative? } teams_with_bad_fans.map { |team| team.team_name } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_teams\n res = Array.new\n\n @games.each do |g|\n #check if home team is in the result array\n if !res.include?(g.home_team)\n res.push(g.home_team)\n end\n\n #check if away team is in the result array\n if !res.include?(g.away_team)\n res.push(g.away_team)\n end\n end\n\n return res\n end", "def get_team_games(team)\n res = Array.new\n\n @games.each do |g|\n if team == g.home_team\n res.push(g)\n end\n\n if team == g.away_team\n res.push(g)\n end\n end\n\n return res\n end", "def find_teams(league)\n teams = []\n league.each do |team|\n teams << team[:home_team]\n teams << team[:away_team]\n end\n uniq_teams = teams.uniq!\nend", "def teams\n standings_data = self.standings\n display_teams = []\n\n object.teams.each do |t|\n display_teams << t if standings_data[:data].key?(t.id) && standings_data[:data][t.id][:played] > 0\n end\n\n display_teams\n end", "def return_teams\r\n result = Array.new(@teams) { [] }\r\n allocation = @neighbourhoods_list[0].l_best_position\r\n (0..@length - 1).each do |x|\r\n (0..@teams - 1).each do |y|\r\n result[y].append(@table[x]['id']) if allocation[x][y] == 1\r\n end\r\n end\r\n # If there are any separated students\r\n # Assign them to teams\r\n assign_separated(result) unless @separated.nil?\r\n result\r\n end", "def winning_team\n home_points = collection_by_prop(game_hash[:home], :points).reduce(0, :+)\n away_points = collection_by_prop(game_hash[:away], :points).reduce(0, :+)\n home_points > away_points ? game_hash[:home][:team_name] : game_hash[:away][:team_name]\n end", "def teams\n return [away_team, home_team].compact\n end", "def improve_teams\n @teams = steepest_ascent_hill(@teams)\n end", "def winning_team\n points_home = 0\n points_away = 0\n result = \"\"\n\n game_hash.each do |side,team|\n team.each do |specs,info|\n if specs == :players\n info.each do |player|\n if side = :home\n points_home += player[:points]\n else\n points_away += player[:points]\n end\n end\n end\n end\n end\n if points_home > points_away\n result = game_hash[:home][:team_name]\n else\n result = game_hash[:away][:team_name]\n end\n result\nend", "def team_names\n teams = []\n teams << game_hash[:home][:team_name]\n teams << game_hash[:away][:team_name]\n return teams\nend", "def team_names\n data = game_hash\n all_teams = []\n \n data.each_pair do |home_away, home_away_hash|\n home_away_hash.each_pair do |team_key, team_value|\n \n if team_key == :team_name\n all_teams << team_value\n end\n \n end\n end\n all_teams\nend", "def team_with_more_points(game)\n home_points = game[:home_team][:players].collect do |player|\n player[:stats][:points]\n end.inject {|sum, n| sum + n}\n away_points = game[:away_team][:players].collect do |player|\n player[:stats][:points]\n end.inject {|sum, n| sum + n}\n home_points > away_points ? game[:home_team][:team_name] : game[:away_team][:team_name]\nend", "def get_standings(games)\n teams = Hash.new\n games.each do |game|\n division_id = game.division_id\n home_team = game.home_team\n away_team = game.visiting_team\n if(teams[home_team.name].nil?)\n teams[home_team.name] = {:win => 0, :loss => 0, :tie => 0, :point=> 0}\n end\n\n if(teams[away_team.name].nil?)\n teams[away_team.name] = {:win => 0, :loss => 0, :tie => 0, :point => 0}\n end\n if(game.home_team_score && game.visiting_team_score)\n if(game.home_team_score > game.visiting_team_score)\n # home team won\n teams[home_team.name][:win] += 1\n teams[home_team.name][:point] += 5\n # visiting team loss\n teams[away_team.name][:loss] += 1\n elsif(game.home_team_score < game.visiting_team_score)\n # home team loss\n teams[home_team.name][:loss] += 1\n #visiting team won\n teams[away_team.name][:win] += 1\n teams[away_team.name][:point] += 5\n else\n # tie game\n teams[home_team.name][:tie] += 1\n teams[home_team.name][:point] += 1\n teams[away_team.name][:tie] += 1\n teams[away_team.name][:point] += 1\n end\n end\n end\n teams.each do |team, value|\n puts team\n total_games = value[:win] + value[:loss] + value[:tie]\n if total_games > 0 \n win_percentage = value[:win]/total_games.to_f\n else\n win_percentage = 0\n end \n value[:percentage] = win_percentage\n end\n teams_sorted = teams.sort_by{ |k, v| v[:point]}.reverse\n return teams_sorted\n end", "def player_data_by_team(team)\n players = []\n if team == game_hash[:home][:team_name]\n players << game_hash[:home][:players]\n else\n players << game_hash[:away][:players]\n end\n return players.flatten\nend", "def winning_team\n home_team_sum = 0\n away_team_sum = 0\n game_hash.each do |team, team_stats|\n if team_stats[:team_name] == \"Brooklyn Nets\"\n team_stats[:players].each do |player_stats|\n home_team_sum += player_stats[:points]\n end\n elsif team_stats[:team_name] == \"Charlotte Hornets\"\n team_stats[:players].each do |player_stats|\n away_team_sum += player_stats[:points]\n end\n end\n end\n if home_team_sum > away_team_sum\n game_hash[:home][:team_name]\n elsif home_team_sum < away_team_sum\n game_hash[:away][:team_name]\n end\nend", "def team_names\n team_names = []\n game_hash.each do |home_or_away, team_stats|\n team_names << team_stats[:team_name]\n end\n team_names\nend", "def all_players_for_a_team(team_name, game)\n player_names = []\n game[:home_team][:players].each do |player_hash|\n player_names << player_hash[:player_name] if game[:home_team][:team_name] == team_name\n end\n game[:away_team][:players].each do |player_hash|\n player_names << player_hash[:player_name] if game[:away_team][:team_name] == team_name\n end\n player_names\nend", "def retrieve_season_hall_of_fame\n seasons_hall_of_fame = []\n get_involved_teams unless @involved_teams\n\n @involved_teams.each do |team|\n team_placement = {}\n team_placement[:team] = team\n %w[first_place second_place third_place].each_with_index do |rank, index|\n placement = index + 1\n team_placement[rank.to_sym] = team.computed_season_ranking.joins(:season).where(\"seasons.season_type_id = #{@season_type.id} AND computed_season_rankings.rank = #{placement}\").count\n end\n seasons_hall_of_fame << team_placement\n end\n seasons_hall_of_fame.sort { |p, n| (n[:first_place] * 10_000 + n[:second_place] * 100 + n[:third_place]) <=> (p[:first_place] * 10_000 + p[:second_place] * 100 + p[:third_place]) }\n end", "def winning_team\n team_p = []\n team_n = []\n\n game_hash.each do | location, team_data|\n temp = 0\n team_data[:players].each do |p_name, stats|\n temp += stats[:points]\n end\n team_n << team_data[:team_name]\n team_p << temp\n end\n\n team_p[0] > team_p[1] ? team_n[0] : team_n[1]\n\nend", "def worst_offense\n teams_total_goals = total_goals_helper\n teams_total_games = total_games_helper\n\n worst_team_goals_avg = 1000\n worst_offense_team_id = 0\n this_team_goals_avg = 0\n\n teams_total_games.each do |games_key, games_value|\n teams_total_goals.each do |goals_key, goals_value|\n if goals_key == games_key\n this_team_goals_avg = (goals_value / games_value.to_f)\n if this_team_goals_avg < worst_team_goals_avg\n worst_team_goals_avg = this_team_goals_avg\n worst_offense_team_id = games_key\n end\n end\n end\n end\n\n team_with_worst_offense = nil\n self.teams.each_value do |team_obj|\n if team_obj.team_id. == worst_offense_team_id\n team_with_worst_offense = team_obj.team_name\n end\n end\n team_with_worst_offense\n end", "def winning_team\n home_points = 0\n away_points = 0\n result = \"\"\n i = 0\n game_hash.each do |team, about|\n about[:players].each do |name , stats|\n if i == 0\n home_points += stats[:points]\n else\n away_points += stats[:points]\n end\n end\n i += 1\n end\n home_points > away_points ? result = game_hash[:home][:team_name] : result = game_hash[:away][:team_name]\nend", "def team_names\n teams = []\n teams << game_hash[:home][:team_name] << game_hash[:away][:team_name]\nend", "def winning_team\n home_score = 0\n away_score = 0\n game_hash[:home][:players].keys.each do |name|\n home_score += game_hash[:home][:players][name][:points]\n end\n game_hash[:away][:players].keys.each do |name|\n away_score += game_hash[:away][:players][name][:points]\n end\n home_score > away_score ? game_hash[:home][:team_name] : game_hash[:away][:team_name]\nend", "def winning_team\n home_team_points = game_hash[:home][:players].sum { |e| e[:points] }\n away_team_points = game_hash[:away][:players].sum { |e| e[:points] }\n\n if home_team_points > away_team_points\n return game_hash[:home][:team_name]\n else\n return game_hash[:away][:team_name]\n end\nend", "def get_live_league_games\n\tcurrent_matches = []\n\tDota.live_leagues.each do |match|\n\t\tif match.raw_live_league['dire_team'] && match.raw_live_league['radiant_team']\n\t\t\tcurrent_matches.push(match)\n\n\t\tend\n\tend\n\n\t#puts 'New Matches:'\n\tcurrent_matches.sort! { |a, b| b.lobby_id <=> a.lobby_id }\n\tcurrent_matches\nend", "def load_stats\n[\n {\n home_team: \"Jets\",\n away_team: \"Giants\",\n home_score: 21,\n away_score: 3\n },\n {\n home_team: \"Steelers\",\n away_team: \"Giants\",\n home_score: 21,\n away_score: 3\n },\n {\n home_team: \"Patriots\",\n away_team: \"Giants\",\n home_score: 21,\n away_score: 3\n },\n {\n home_team: \"Chargers\",\n away_team: \"Jets\",\n home_score: 13,\n away_score: 6\n },\n {\n home_team: \"Patriots\",\n away_team: \"Jets\",\n home_score: 13,\n away_score: 6\n },\n {\n home_team: \"Steelers\",\n away_team: \"Jets\",\n home_score: 3,\n away_score: 6\n },\n {\n home_team: \"Dolphins\",\n away_team: \"Jets\",\n home_score: 0,\n away_score: 3\n },\n{\n home_team: \"Browns\",\n away_team: \"Jets\",\n home_score: 0,\n away_score: 21\n },\n {\n home_team: \"Chargers\",\n away_team: \"Jets\",\n home_score: 7,\n away_score: 21\n },\n {\n home_team: \"Steelers\",\n away_team: \"Broncos\",\n home_score: 7,\n away_score: 13\n },\n {\n home_team: \"Patriots\",\n away_team: \"Broncos\",\n home_score: 7,\n away_score: 3\n },\n {\n home_team: \"Broncos\",\n away_team: \"Colts\",\n home_score: 3,\n away_score: 0\n },\n {\n home_team: \"Patriots\",\n away_team: \"Colts\",\n home_score: 11,\n away_score: 7\n },\n {\n home_team: \"Steelers\",\n away_team: \"Patriots\",\n home_score: 7,\n away_score: 21\n },\n {\n home_team: \"Steelers\",\n away_team: \"Colts\",\n home_score: 24,\n away_score: 21\n },\n {\n home_team: \"Steelers\",\n away_team: \"Colts\",\n home_score: 24,\n away_score: 21\n }\n]\nend", "def winning_team\n home_points = 0\n away_points = 0\n team1 = \"Brooklyn Nets\"\n team2 = \"Charlotte Hornets\"\n game_hash.each do |team,info|\n info.each do |team_info,team_data|\n if team_data.is_a? (Array) \n if team_info != :colors\n if info[:team_name] == \"Brooklyn Nets\"\n team_data.each do |player_index|\n home_points += player_index[:points]\n end\n else \n team_data.each do |player_index|\n away_points += player_index[:points]\n winning_team end\n end\n end\n end\n end\n end\n\n if home_points > away_points\n team1\n else\n team2\n end\n\nend", "def poolplay_team_objects\n self.teams.select { |team| !team.playoffs }\n end", "def winning_team\n nets = []\n hornets = []\n\n game_hash.values.each do |nets_stats|\n if nets_stats[:team_name] == \"Brooklyn Nets\"\n nets_stats[:players].each do |bk|\n nets << bk[:points]\n end\n end\n end\n\n game_hash.values.each do |hornets_stats|\n if hornets_stats[:team_name] == \"Charlotte Hornets\"\n hornets_stats[:players].each do |ch|\n hornets << ch[:points]\n end\n end\n end\n\n if nets.reduce(:+) > hornets.reduce(:+)\n return \"Brooklyn Nets\"\n else\n return \"Charlotte Hornets\"\n end\nend", "def teams\n return [og, oo, cg, co];\n end", "def winning_team\n final_scores = player_collection.reduce(home: 0, away: 0) { |teams_points, next_player|\n case \n when next_player[:location] === :away\n teams_points[:away] += next_player[:points];\n when next_player[:location] === :home\n teams_points[:home] += next_player[:points];\n end\n teams_points; \n }\n winner = final_scores.reduce { |highest_points, team_points| \n highest_points[1] > team_points[1] ? highest_points : team_points; \n }\n game_hash[winner[0]][:team_name]; \nend", "def top_5_teams\n team_names = []\n teams = UserTeam.all.collect{|team| team.team_id}\n most_common_value = teams.uniq.sort_by{ |i| teams.count( i ) }.reverse[0..4]\n most_common_value.each do |team|\n team_names << get_team_name_by_id(Team.find(team).api_team_id)\n end\n team_names\nend", "def all_teams_in_league\n \treturnArray = []\n\t\tbase_uri = 'https://www.thesportsdb.com/api/v1/json/1/search_all_teams.php?l=' + @league_name.to_s\n\t\tresponse = RestClient.get(base_uri)\n\t\tjson_response = JSON.parse(response)\n\t\thashIds = json_response['teams'] \n\t\thashIds.length.times do |i|\n\t\t\treturnArray[i] = \"Team ID: #{hashIds[i]['idTeam']}, Name: #{hashIds[i]['strTeam']}, Short Name: #{hashIds[i]['strTeamShort']}, Formed Year: #{hashIds[i]['intFormedYear']}, Sport: #{hashIds[i]['strSport']}, Alternate Name: #{hashIds[i]['strAlternateName']}\"\n\t\tend\n\t\treturn returnArray\n\tend", "def team_names\n arrayOfTeamNames = [] #initialize new hash\n arrayOfTeamNames << game_hash[:home][:team_name]\n arrayOfTeamNames << game_hash[:away][:team_name] #shovel it with the data\nend", "def past_teams\n Team.find_by_sql([\"SELECT t.* FROM teams t INNER JOIN teams_people tp ON ( t.id = tp.team_id) INNER JOIN users u ON (tp.person_id = u.id) INNER JOIN courses c ON (t.course_id = c.id) WHERE u.id = ? AND (c.semester <> ? OR c.year <> ?)\", self.id, AcademicCalendar.current_semester(), Date.today.year])\n end", "def best_fans\n @teams.max_by { |team| team.home_minus_away_percentage }.team_name\n end", "def games\n self.teams.map{|team| team.game }\n end", "def team_names\n fin_arr = []\n fin_arr << game_hash[:home][:team_name]\n fin_arr << game_hash[:away][:team_name]\n fin_arr\nend", "def worst_defense\n teams_total_goals_allowed = total_goals_allowed_helper\n teams_total_games = total_games_helper\n\n worst_team_goals_allowed_avg = 0\n worst_defense_team_id = 0\n this_team_goals_allowed_avg = 0\n\n teams_total_games.each do |games_key, games_value|\n\n teams_total_goals_allowed.each do |goals_key, goals_value|\n if goals_key == games_key\n this_team_goals_allowed_avg = (goals_value / games_value.to_f)\n if this_team_goals_allowed_avg > worst_team_goals_allowed_avg\n worst_team_goals_allowed_avg = this_team_goals_allowed_avg\n worst_defense_team_id = games_key\n end\n end\n end\n end\n team_with_worst_defense = team_name_finder_helper(worst_defense_team_id)\n\n team_with_worst_defense\n end", "def team_names\n [\n game_hash.dig(:home, :team_name),\n game_hash.dig(:away, :team_name)\n ]\nend", "def create_team_list(game_matchups)\n home_team_list = game_matchups.map{|game_info| game_info[\"home_team\"]}\n away_team_list = game_matchups.map{|game_info| game_info[\"away_team\"]}\n duplicate_team_list = home_team_list.concat(away_team_list)\n #remove dupicate team names from team list\n duplicate_team_list.map{|team| team}.uniq\nend", "def create_team_list(game_matchups)\n home_team_list = game_matchups.map{|game_info| game_info[\"home_team\"]}\n away_team_list = game_matchups.map{|game_info| game_info[\"away_team\"]}\n duplicate_team_list = home_team_list.concat(away_team_list)\n #remove dupicate team names from team list\n duplicate_team_list.map{|team| team}.uniq\nend", "def past_teams\n Team.find_by_sql([\"SELECT t.* FROM teams t INNER JOIN team_assignments ta ON ( t.id = ta.team_id) INNER JOIN users u ON (ta.user_id = u.id) INNER JOIN courses c ON (t.course_id = c.id) WHERE u.id = ? AND (c.semester <> ? OR c.year <> ?)\", self.id, AcademicCalendar.current_semester(), Date.today.year])\n end", "def best_defense\n teams_total_goals_allowed = total_goals_allowed_helper\n teams_total_games = total_games_helper\n\n best_team_goals_allowed_avg = 100\n best_defense_team_id = 0\n this_team_goals_allowed_avg = 0\n\n teams_total_games.each do |games_key, games_value|\n teams_total_goals_allowed.each do |goals_key, goals_value|\n if goals_key == games_key\n this_team_goals_allowed_avg = (goals_value / games_value.to_f)\n if this_team_goals_allowed_avg < best_team_goals_allowed_avg\n best_team_goals_allowed_avg = this_team_goals_allowed_avg\n best_defense_team_id = games_key\n end\n end\n end\n end\n\n team_with_best_defense = nil\n self.teams.each_value do |team_obj|\n if team_obj.team_id. == best_defense_team_id\n team_with_best_defense = team_obj.team_name\n end\n end\n team_with_best_defense\n end", "def team_names\n # built an empty array called teams\n teams = []\n # game_hash.each do |team, random| iterates over the hash to return all of the team_names\n game_hash.each do |team, random|\n teams.push(game_hash[team][:team_name])\n end\n return teams\nend", "def teams\n return ['FFA (Free For All)'] if ffa?\n\n teams = []\n @doc.css('map teams').xpath('./team').each do |t|\n name = localized_sting(t.text)\n min = t.attr('min')\n max = t.attr('max')\n teams << \"<h3 style='color: #{color_to_html(t.attr('color'))}'>#{name} <small style='color: black'>(#{min} - #{max} players)</small></h3>\"\n end\n teams\n end", "def team_names\n new_array = []\n new_array<< game_hash[:home][:team_name]\n new_array<< game_hash[:away][:team_name]\n return new_array\nend", "def standings_including(team)\n placings.reject { |p| p.team.exhibition? && p.team != team }\n end", "def get_possible_teams( query, swimmers_found )\n teams = TeamFinder.new( params[:query] ).search()\n # Add all the teams from the swimmer results but only if no matches where found:\n if teams.count < 1\n teams = swimmers_found.map{ |swimmer| swimmer.teams }.flatten.uniq\n end\n teams.each do |team|\n @result << {\n class: 'Team',\n id: team.id,\n description: team.get_verbose_name,\n date: Format.a_date( team.updated_at )\n }\n end\n teams\n end", "def teams\n requests.where(is_accepted: true).map(&:team).flatten\n end", "def team_names\n team_names = []\n #top level\n game_hash.each do |location, team_data|\n #2nd level\n team_data.each do |team_deets, values|\n #find team name pair\n if team_deets == :team_name\n team_names << team_data[team_deets]\n end\n end\n end\n team_names = team_names.flatten\nend", "def both_team_names(game)\n both_teams = []\n both_teams << game[:home_team][:team_name]\n both_teams << game[:away_team][:team_name]\n both_teams\nend", "def one_team_stats(team_name)\n game_hash.each do |home_or_away, team_stats|\n if team_stats[:team_name] == team_name\n return team_stats\n end\n end\nend", "def get_team_games(team)\n # Set Up\n doc = getHTML(\"http://espn.go.com/mens-college-basketball/team/schedule/_/id/#{team.webExt}\")\n\n table = doc.xpath('//table[@class = \"tablehead\"]')\n rows = table.css('tr')\n\n # Loop through each row\n rows.each do |row|\n if(row.css('li').count > 3)\n linkHref = row.css('li[@class =\"score\"]')[0].css('a[href]')[0]\n if(linkHref != nil)\n link = linkHref[\"href\"].scan(/(.*=)(\\d+)/)\n gameID = link[0][1] \n if(Game.where(gameID: gameID).empty?)\n # get Date\n date = row.css(\"td\")[0].text\n # get opp\n opp = row.css('li[@class =\"team-name\"]').text\n # get HOME/away (vs/@)\n loc = row.css('li[@class =\"game-status\"]').text\n if(loc == \"@\")\n homeTeam = team.name\n awayTeam = opp\n else\n homeTeam = opp\n awayTeam = team.name\n end\n \n # Creates Game Entry\n game = Game.create(gameID: gameID, date: date, homeTeam: homeTeam, awayTeam: awayTeam)\n # Gets more game stats\n get_game_stats(game)\n end\n end\n end\n end\n end", "def team_names\n game_hash.collect {|home_or_away, stats| team_name = stats[:team_name].to_s}\nend", "def awayTeamPoints\n teamSelect(\"Charlotte Hornets\")[:players].collect do|name, stats|\n stats[:points]\n end\nend", "def winningest_team\n @teams.max_by { |team| team.total_win_percentage }.team_name\n end", "def worst_offense\n @teams.min_by { |team| team.average_goals_scored }.team_name\n end", "def team_names\n hash = game_hash\n array = []\n hash.each do |location, attributes|\n attributes.each do |attribute, info|\n if attribute == :team_name\n array << info\n end\n end\n end\n return array\nend", "def teams\n @teams\n end", "def team_names\n game = Game.find(self.game_id)\n type = self.bet_type\n if over_under?\n return \"#{game.away_team} vs #{game.home_team}\"\n elsif type == \"lay\"\n if game.spread <= 0\n return game.home_team\n else\n return game.away_team\n end\n else\n if game.spread <= 0\n return game.away_team\n else\n return game.home_team\n end\n end\n end", "def winning_team\n self.teams.order('score DESC').first\n end", "def teams\n game_hash.values\n end", "def retrieve_involved_teams\n Team.joins(computed_season_ranking: :season).where(\"seasons.season_type_id = #{@season_type.id}\").distinct\n end", "def standings\n placings.reject { |p| p.team.exhibition? }\n end", "def split_teams\n @split_teams ||= shuffled_teams.each_slice(team_count/2).to_a\n end", "def away_stat\n @away.team_stat\n end", "def team_names()\n result = []\n game_hash.each do |side,team|\n result.push(team[:team_name])\n end\n result\nend", "def get_eligible_teams\n eligible_teams = []\n if current_user && current_user.stat.nil? == false\n tier_hash = { 1 => \"BRONZE\", 2 => \"SILVER\", 3 => \"GOLD\",\n 4 => \"PLATINUM\", 5 => \"DIAMOND\", 6 => \"MASTER\" }\n tier_hash.each do |k,v|\n if v == current_user.stat.tier\n eligible_teams << [ tier_hash[k-1], tier_hash[k], tier_hash[k+1] ]\n end\n end\n eligible_teams.flatten! unless eligible_teams.empty?\n end\n eligible_teams\n end", "def all_players\n home_team = game_hash.fetch(:home).fetch(:players)\n away_team = game_hash.fetch(:away).fetch(:players)\n return home_team + away_team\nend", "def get_teams\n sparql = SPARQL.parse(\"SELECT DISTINCT ?uri ?name\n WHERE {\n ?group_uri <http://www.bbc.co.uk/ontologies/sport/hasCompetitor> ?uri .\n ?uri <#{RDF::RDFS.label}> ?name .\n }\n ORDER BY ASC(?name)\n \")\n solutions = QUERYABLE.query(sparql)\n end", "def teams_unaccepted\n requests.where(is_accepted: false).map(&:team).flatten\n end", "def team_by_name(team_name)\n game_hash[:home].has_value?(team_name) ? game_hash[:home] : game_hash[:away]\n end", "def teams_in_game(a_game)\n teams_in_game = {}\n a_game.game_teams.each do |game_team|\n team_in_game = @teams[game_team.name.to_sym]\n teams_in_game[game_team.name.to_sym] = team_in_game\n end\n teams_in_game\n end", "def wins_losses\n GAME_INFO.each do |game|\n @team_records.each do |team|\n if game[:home_team] == team.name && game[:home_score] > game[:away_score] #refactor later\n team.wins += 1\n elsif game[:home_team] == team.name && game[:home_score] < game[:away_score]\n team.losses += 1\n end\n end\n end\n\n GAME_INFO.each do |game|\n @team_records.each do |team|\n if game[:away_team] == team.name && game[:away_score] > game[:home_score] #refactor later\n team.wins += 1\n elsif game[:away_team] == team.name && game[:away_score] < game[:home_score]\n team.losses += 1\n end\n end\n end\n\n end", "def biggest_team_blowout(team_id)\n @games.map do |game|\n if game.away_team_id.to_s == team_id\n game.away_goals - game.home_goals\n elsif game.home_team_id.to_s == team_id\n game.home_goals - game.away_goals\n end\n end.compact.max\n end", "def teams_with_score_max(a_game)\n teams_with_score_max = {}\n game_teams_with_score_max = a_game.teams_with_score_max(a_game.game_teams)\n game_teams_with_score_max.each do |game_team_with_score_max|\n # find team instance matching game_team instance\n team_with_score_max = @teams[game_team_with_score_max.name.to_sym]\n teams_with_score_max[game_team_with_score_max.name.to_sym] = team_with_score_max\n end\n teams_with_score_max\n end", "def rank_top_teams # DO NOT USE THIS METHOD, outdated, slow\n @top_teams = {}\n @top_teams = Score.in_challenge(self.id).teams_in_all_divisions.limit(5).\n order(\"sum_points DESC, MAX(#{Score.table_name}.\n earned_at) DESC\").sum(:points) \n return @top_teams\n end", "def teams\ngame_hash.keys.reduce([]) do |memo, key|\n memo << game_hash[key]\n end\nend", "def query_5\n relevant_team_members = []\n all_projects = Perpetuity[Project].all.to_a\n all_projects.each do |proj|\n ptms = Perpetuity[ProjectsTeamMember].select {|ptm| ptm.project.id == proj.id }.to_a\n Perpetuity[ProjectsTeamMember].load_association! ptms, :team_member\n Perpetuity[ProjectsTeamMember].load_association! ptms, :project\n\n ptms.each do |pt|\n tm_created_at = pt.team_member.created_at\n pt_created_at = pt.project.created_at\n\n if tm_created_at < pt_created_at\n relevant_team_members << pt.team_member\n end\n end\n\n return relevant_team_members.size\n end\nend", "def final_results_list\n winners = sort_group_of_teams(self.teams.select { |team| team.playoffs && team.court_id == 100 })\n losers = sort_group_of_teams(self.teams.select { |team| team.playoffs && team.court_id != 100 })\n\n #only for kob, game play will not have a losers court\n ## winner of consolation court kob, become overall 4th place\n if (losers)\n third_place = losers.shift\n winners.insert(3, third_place).concat(losers)\n end\n winners\n end", "def home_stat\n @home.team_stat\n end", "def worst_loss(team_id)\n @games.map do |game|\n if game.away_team_id.to_s == team_id\n game.home_goals - game.away_goals\n elsif game.home_team_id.to_s == team_id\n game.away_goals - game.home_goals\n end\n end.compact.max\n end", "def winning_team\n if homeTeamPoints.sum > awayTeamPoints.sum\n \"Brooklyn Nets\"\n else\n \"Charlotte Hornets\"\n end\nend", "def team_names\n # team_array = []\n # team_array.push(game_hash[:home][:team_name])\n # team_array.push(game_hash[:away][:team_name])\n # team_array\n game_hash.map do |location, team_data|\n team_data[:team_name]\n end\nend", "def players(team)\n\t\t# select all the games including that team, and then get that teams roster from each game, flatten, and remove dups.\n\t\t@rounds.select{|g| g.teams.include?(team)}.map {|g| g.players[g.teams.index(team)]}.flatten.uniq\n\tend", "def team_names\n game_hash.collect do |location, team_data|\n team_data[:team_name]\n end\nend", "def fewest_goals_scored(team_id)\n team_id = team_id.to_i\n goals_per_game = @game_teams.map do |game|\n if game.team_id == team_id\n game.goals\n end\n end\n goals_per_game.compact.min\n end", "def teams\n return team_1 + team_2;\n end", "def team_names\n array = [] \n game_hash.each do |team, attributes|\n attributes.each do |key, value|\n if key == :team_name\n array.push(value)\n \n end\n end\n end\n array\nend", "def matchups\n\t# we will create a temporary array\n\t# for use only in this method,\n\t# so we don't effect the original\n\t# @teams array with an deletions\n\ttemp_arr = []\n\t@teams.each do |t|\n\t\ttemp_arr.push(t)\n\tend\n\n\tif temp_arr.length % 2 != 0\n\t\t# check if there is an odd number of teams,\n\t\t# if there is an odd number, we pull pull\n\t\t# out the top one and give them a bye week\n\t\tputs \"(1) #{temp_arr.delete_at(0).name} has a bye\"\n\t\t# and now we have an even number of teams\n\tend\n\n\t# match up the even amount of teams,\n\t# assuming there are any teams...\n\twhile temp_arr.length > 0\n\t\tteam1 = temp_arr.delete_at(0)\n\t\t# team 1 is the first one in array\n\t\tteam2 = temp_arr.pop\n\t\t# team 2 is last in array\n\t\tputs \"(#{team1.ranking}) #{team1.name} versus (#{team2.ranking}) #{team2.name}\"\n\t\t# this continues until no teams are left in the array\n\t\t# Example: \n\t\t# [1,2,3,4,5,6]\n\t\t# team1 = 1\n\t\t# team2 = 6\n\t\t# [2,3,4,5]\n\t\t# team1 = 2\n\t\t# team2 = 5\n\t\t# [3,4]\n\t\t# team1 = 3\n\t\t# team2 = 4\n\tend\n\n\treturn_to_menu\nend", "def get_teams\n self.get_page\n # this step above sets @ec_HtmlTable equal to the HTML code responsible for displaying !!DONE!!\n # the top 8 Eastern Conference Teams, and their seed, record, and name !!DONE!!\n i = 0\n @ecTeams = []\n @wcTeams = []\n # Tables are divided by conference. Table 1 is Eastern !!DONE!!\n @ec_HtmlTable = @html_doc.css(\".wikitable\")[1]\n until i == 8 \n newTeamHtml = @ec_HtmlTable.css(\"tr\")[2 + i].text.split(\"\\n\")\n thisRank = newTeamHtml[1].to_i\n thisName = newTeamHtml[2]\n thisRecord = newTeamHtml[3]\n newTeam = Team.create(thisName, thisRank, 'Eastern', thisRecord)\n @ecTeams << newTeam\n i = i + 1\n end\n # Tables are divided by conference. Table 2 is Western !!DONE!!\n @wc_HtmlTable = @html_doc.css(\".wikitable\")[2]\n j = 0\n until j == 8\n newTeamHtml = @wc_HtmlTable.css(\"tr\")[2 + j].text.split(\"\\n\")\n thisRank = newTeamHtml[1].to_i\n thisName = newTeamHtml[2]\n thisRecord = newTeamHtml[3]\n newTeam = Team.create(thisName, thisRank, 'Western', thisRecord)\n @wcTeams << newTeam\n j = j + 1\n end\n \n end", "def player_numbers(team_name)\n outcome = []\n game_hash.each do |home_or_away, team_details|\n team_details.each do |key,value|\n if value == team_name\n game_hash[home_or_away][:players].each do |one_hash|\n one_hash.each do |key1,value1|\n if key1 == :number \n outcome << one_hash[key1]\n end\n end\n end \n end\n end\n end\n outcome\nend", "def is_not_on_staff\n #Team.find(:all) - self.teams\n Team.all - self.teams\n end", "def team_names\n names = []\n game_hash.each do | team, attributes|\n names << game_hash[team][:team_name]\n end\n return names\nend", "def teams\n # find all my TeamColor relationship information\n # my_team_colors = TeamColor.all.select do |team_color|\n # team_color.color == self\n # end\n # from those relations, grab out the teams\n # Array of TeamColor instances\n self.team_colors.map do |team_color|\n team_color.team\n end\n # Array of Team instances\n end", "def calculate_team_ranking_score(number_of_meetings = 2, number_of_bests = 3)\n team_ranking_results = []\n events = []\n if @badge.category_type.code != 'U25' &&\n @badge.meetings.distinct.count >= number_of_meetings\n get_results.each do |meeting_individual_result|\n next unless meeting_individual_result.get_scheduled_date.year - @swimmer.year_of_birth >= 25\n\n next if events.include?(meeting_individual_result.event_type.code)\n\n team_ranking_results << meeting_individual_result\n events << meeting_individual_result.event_type.code\n break if team_ranking_results.count == number_of_bests\n end\n end\n BestLimitedRankingDAO.new(team_ranking_results)\n end", "def team_names\n team_names = []\n for location in game_hash.keys\n team_names.push(game_hash[location][:team_name])\n end\n return team_names\nend", "def team_names\n output =[]\n game_hash.each do |location, team_data|\n output.push(team_data[:team_name])\n end\n output\nend", "def team\n teams.where(hubstats: true).first\n end" ]
[ "0.8108445", "0.76042056", "0.74595654", "0.74204546", "0.7261254", "0.71992743", "0.7165851", "0.7146855", "0.7050696", "0.6960195", "0.69472575", "0.6947156", "0.6926212", "0.69255716", "0.69076914", "0.68787795", "0.6869827", "0.6869329", "0.68567395", "0.68326974", "0.6779601", "0.6698881", "0.66972846", "0.66879207", "0.6683921", "0.6645234", "0.6633192", "0.6625919", "0.66256905", "0.6621589", "0.6598024", "0.6588327", "0.6545222", "0.65406406", "0.65367544", "0.6523489", "0.650942", "0.64961404", "0.64955413", "0.6472542", "0.64679754", "0.64679754", "0.64509684", "0.64353967", "0.64272356", "0.6420516", "0.641938", "0.6417933", "0.6374568", "0.63738596", "0.6363001", "0.6358363", "0.6323861", "0.6321009", "0.6319513", "0.6315986", "0.6312695", "0.6305408", "0.63019675", "0.62933135", "0.6278712", "0.62684464", "0.62639195", "0.6254111", "0.6244467", "0.6234207", "0.6228755", "0.62183064", "0.62018377", "0.618995", "0.61873627", "0.61803114", "0.6172717", "0.6170128", "0.61685514", "0.61623514", "0.615312", "0.61499405", "0.61464196", "0.61414766", "0.61407393", "0.6133829", "0.61335075", "0.6133487", "0.61251265", "0.6121668", "0.6120287", "0.61198664", "0.61038834", "0.6100592", "0.6100384", "0.61002564", "0.6096594", "0.60921794", "0.6086914", "0.6078829", "0.60772675", "0.6073841", "0.60665166", "0.606623" ]
0.702236
9
returns team with biggest decrease between preseason and regular season win percentage
def biggest_bust(season) season = season.to_i @teams.min_by{ |team| team.preseason_to_regular_increase[season] }.team_name end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def worst_season(team_id)\n team_id = team_id.to_i\n team = @teams.select { |each_team| each_team.team_id == team_id }.first\n team.season_win_percentages.min_by { |season, percentage| percentage }.first.to_s\n end", "def best_season(team_id)\n team_id = team_id.to_i\n team = @teams.select { |each_team| each_team.team_id == team_id }.first\n team.season_win_percentages.max_by { |season, percentage| percentage }.first.to_s\n end", "def winningest_team\n @teams.max_by { |team| team.total_win_percentage }.team_name\n end", "def biggest_surprise(season)\n season = season.to_i\n @teams.max_by{ |team| team.preseason_to_regular_increase[season] }.team_name\n end", "def most_accurate_team(seasonasstring) # shots in game team stats\n #get a list of all teams that played in that season - given by arg\n #use above list to sum all shots across all games in season\n #divide above by goals made across all games in season\n #find highest percentage\n #return team name as found in 127\n end", "def worst_offense\n teams_total_goals = total_goals_helper\n teams_total_games = total_games_helper\n\n worst_team_goals_avg = 1000\n worst_offense_team_id = 0\n this_team_goals_avg = 0\n\n teams_total_games.each do |games_key, games_value|\n teams_total_goals.each do |goals_key, goals_value|\n if goals_key == games_key\n this_team_goals_avg = (goals_value / games_value.to_f)\n if this_team_goals_avg < worst_team_goals_avg\n worst_team_goals_avg = this_team_goals_avg\n worst_offense_team_id = games_key\n end\n end\n end\n end\n\n team_with_worst_offense = nil\n self.teams.each_value do |team_obj|\n if team_obj.team_id. == worst_offense_team_id\n team_with_worst_offense = team_obj.team_name\n end\n end\n team_with_worst_offense\n end", "def worst_offense\n @teams.min_by { |team| team.average_goals_scored }.team_name\n end", "def least_accurate_team(seasonasstring) # shots in game team stats\n #inverse of above\n end", "def best_season(id)\n wins = total_wins_per_team_per_season(id)\n totals = total_games_per_team_per_season(id)\n totals.each do |season, total|\n totals[season] = (wins[season] / total.to_f * 100).round(2)\n end\n totals.max_by {|k,v| v}[0]\n end", "def worst_defense\n teams_total_goals_allowed = total_goals_allowed_helper\n teams_total_games = total_games_helper\n\n worst_team_goals_allowed_avg = 0\n worst_defense_team_id = 0\n this_team_goals_allowed_avg = 0\n\n teams_total_games.each do |games_key, games_value|\n\n teams_total_goals_allowed.each do |goals_key, goals_value|\n if goals_key == games_key\n this_team_goals_allowed_avg = (goals_value / games_value.to_f)\n if this_team_goals_allowed_avg > worst_team_goals_allowed_avg\n worst_team_goals_allowed_avg = this_team_goals_allowed_avg\n worst_defense_team_id = games_key\n end\n end\n end\n end\n team_with_worst_defense = team_name_finder_helper(worst_defense_team_id)\n\n team_with_worst_defense\n end", "def best_defense\n teams_total_goals_allowed = total_goals_allowed_helper\n teams_total_games = total_games_helper\n\n best_team_goals_allowed_avg = 100\n best_defense_team_id = 0\n this_team_goals_allowed_avg = 0\n\n teams_total_games.each do |games_key, games_value|\n teams_total_goals_allowed.each do |goals_key, goals_value|\n if goals_key == games_key\n this_team_goals_allowed_avg = (goals_value / games_value.to_f)\n if this_team_goals_allowed_avg < best_team_goals_allowed_avg\n best_team_goals_allowed_avg = this_team_goals_allowed_avg\n best_defense_team_id = games_key\n end\n end\n end\n end\n\n team_with_best_defense = nil\n self.teams.each_value do |team_obj|\n if team_obj.team_id. == best_defense_team_id\n team_with_best_defense = team_obj.team_name\n end\n end\n team_with_best_defense\n end", "def determine_winner game\n winner = game.max_by {|team| team[:score]}\n team_standings = get_team_by_name(winner)\n team_standings[:winnings] += 3\nend", "def worst_defense\n @teams.max_by { |team| team.average_goals_allowed }.team_name\n end", "def best_offense\n @teams.max_by { |team| team.average_goals_scored }.team_name\n end", "def biggest_suprise(seasonasstring)\n #as above, but change line 100 to reverse operations, regular percentage - postseason percentage\n end", "def highest_scoring_visitor\n @teams.max_by { |team| team.average_away_goals }.team_name\n end", "def best_defense\n @teams.min_by { |team| team.average_goals_allowed }.team_name\n end", "def worst_loss(team_id)\n @games.map do |game|\n if game.away_team_id.to_s == team_id\n game.home_goals - game.away_goals\n elsif game.home_team_id.to_s == team_id\n game.away_goals - game.home_goals\n end\n end.compact.max\n end", "def best_fans\n @teams.max_by { |team| team.home_minus_away_percentage }.team_name\n end", "def most_hits(seasonasstring) # shots in game team stats\n #get a list of all teams that played in that season\n #use above list to sum all shots across all games in season\n #find highest across list\n #return team name as found in 139\n end", "def winning_team\n self.teams.order('score DESC').first\n end", "def high_score\n if self.end_date < Date.today\n self.teams.max_by { |team| team.score }.score\n end\n end", "def highest_scoring_home_team\n @teams.max_by { |team| team.average_home_goals }.team_name\n end", "def pri_toff\n team_stats.goals_per_game / team_stats.opp_avg_goals_per_game\n end", "def biggest_bust(seasonasstring)\n #get all teams in data\n #find all games played by team in season - given by arg\n #get subset of 95 where p is in season marker\n #count games won in subset on 95 / total games in subset on 95\n #get subset of 85 where r is in season marker\n #count games won in subset on 98 / total games in subset on 98\n #result of line 97 - line 99\n #find highest number\n #return team name of result of line 101\n end", "def compute_team_winner\n if completed?\n team_winner\n else\n if first_team && second_team\n if sets_won(first_team) == min_sets_to_play\n first_team\n elsif sets_won(second_team) == min_sets_to_play\n second_team\n end\n end\n end\n end", "def winning_team\n final_scores = player_collection.reduce(home: 0, away: 0) { |teams_points, next_player|\n case \n when next_player[:location] === :away\n teams_points[:away] += next_player[:points];\n when next_player[:location] === :home\n teams_points[:home] += next_player[:points];\n end\n teams_points; \n }\n winner = final_scores.reduce { |highest_points, team_points| \n highest_points[1] > team_points[1] ? highest_points : team_points; \n }\n game_hash[winner[0]][:team_name]; \nend", "def winning_team\n home_points = collection_by_prop(game_hash[:home], :points).reduce(0, :+)\n away_points = collection_by_prop(game_hash[:away], :points).reduce(0, :+)\n home_points > away_points ? game_hash[:home][:team_name] : game_hash[:away][:team_name]\n end", "def biggest_blowout\n score_difference = games.map { |game| (game.home_goals - game.away_goals).abs}\n score_difference.max\n end", "def get_standings(games)\n teams = Hash.new\n games.each do |game|\n division_id = game.division_id\n home_team = game.home_team\n away_team = game.visiting_team\n if(teams[home_team.name].nil?)\n teams[home_team.name] = {:win => 0, :loss => 0, :tie => 0, :point=> 0}\n end\n\n if(teams[away_team.name].nil?)\n teams[away_team.name] = {:win => 0, :loss => 0, :tie => 0, :point => 0}\n end\n if(game.home_team_score && game.visiting_team_score)\n if(game.home_team_score > game.visiting_team_score)\n # home team won\n teams[home_team.name][:win] += 1\n teams[home_team.name][:point] += 5\n # visiting team loss\n teams[away_team.name][:loss] += 1\n elsif(game.home_team_score < game.visiting_team_score)\n # home team loss\n teams[home_team.name][:loss] += 1\n #visiting team won\n teams[away_team.name][:win] += 1\n teams[away_team.name][:point] += 5\n else\n # tie game\n teams[home_team.name][:tie] += 1\n teams[home_team.name][:point] += 1\n teams[away_team.name][:tie] += 1\n teams[away_team.name][:point] += 1\n end\n end\n end\n teams.each do |team, value|\n puts team\n total_games = value[:win] + value[:loss] + value[:tie]\n if total_games > 0 \n win_percentage = value[:win]/total_games.to_f\n else\n win_percentage = 0\n end \n value[:percentage] = win_percentage\n end\n teams_sorted = teams.sort_by{ |k, v| v[:point]}.reverse\n return teams_sorted\n end", "def goals_for(team)\n valid = ((team == self.home_team or team == self.away_team) and self.final)\n\n if (valid)\n if (self.home_team == team)\n return self.homeScore\n else\n return self.awayScore\n end\n else\n return 0\n end\n end", "def max_teams(rounds)\n 2**rounds\n end", "def max_teams(rounds)\n 2**rounds\n end", "def percentage_visitor_wins\n visitor_wins = @teams.map { |team| team.away_wins }.sum\n visitor_games = @teams.map { |team| team.away_games }.sum\n (visitor_wins.to_f / visitor_games.to_f).round(2)\n end", "def winning_team\n if homeTeamPoints.sum > awayTeamPoints.sum\n \"Brooklyn Nets\"\n else\n \"Charlotte Hornets\"\n end\nend", "def winning_team\n blue_team.winner? ? blue_team : red_team\n end", "def power_play_goal_percentage(seasonasstring) # power_play info in game team stat\n #find list of all games in season given by arg\n #sum all power play goals\n #sum all power play oppertunities\n #divide line 146 and line 147\n #return total of above\n end", "def rival(team_id)\n team_id = team_id.to_i\n team = @teams.select { |each_team| each_team.team_id == team_id }.first\n rival_id = team.matchup_win_percentage.min_by{|each_team, percentage| percentage}.first\n @teams.select { |each_team| each_team.team_id == rival_id }.first.team_name\n end", "def score_for_team(team)\n team ||= winner_team\n winner_team?(team) ? score : scores.reverse.join(':')\n end", "def lowest_scoring_visitor\n @teams.min_by { |team| team.average_away_goals }.team_name\n end", "def average_win_percentage(team_id)\n team_id = team_id.to_i\n team = @teams.select { |each_team| each_team.team_id == team_id }.first\n team.total_win_percentage.round(2)\n end", "def goals_against(team)\n valid = ((team == self.home_team or team == self.away_team) and self.final)\n\n if (valid)\n if (self.home_team == team)\n return self.awayScore\n else\n return self.homeScore\n end\n else\n return 0\n end\n end", "def season_with_most_games\n seasons = @games.group_by { |game| game.season }\n seasons.max_by { |season, games| games.count }.first\n end", "def winner_team(game)\n result = nil\n if game.team1_goals.present? && game.team2_goals.present?\n result = game.team1 if game.team1_goals > game.team2_goals\n result = game.team2 if game.team1_goals < game.team2_goals\n end\n\n result\n end", "def team_with_more_points(game)\n home_points = game[:home_team][:players].collect do |player|\n player[:stats][:points]\n end.inject {|sum, n| sum + n}\n away_points = game[:away_team][:players].collect do |player|\n player[:stats][:points]\n end.inject {|sum, n| sum + n}\n home_points > away_points ? game[:home_team][:team_name] : game[:away_team][:team_name]\nend", "def pri_sos\n team_stats.opp_pyth / 50.0 \n end", "def worst_coach(seasonasstring) # coach name in game team stats\n #inverse of above\n end", "def biggest_team_blowout(team_id)\n @games.map do |game|\n if game.away_team_id.to_s == team_id\n game.away_goals - game.home_goals\n elsif game.home_team_id.to_s == team_id\n game.home_goals - game.away_goals\n end\n end.compact.max\n end", "def fewest_hits(seasonasstring) # shots in game team stats\n #inverse of above\n end", "def winner\n @players.max_by do |player|\n player.score\n end\n end", "def stats_vs_team(team, season = nil)\n id = find_id(team, Team)\n data = stats_request(\"vsTeam\", season)\n data.find do |s| s[\"opponent\"][\"id\"] == id end\n end", "def coach_win_percent_in_season(coach, game_ids)\n (total_wins_of_coach_in_season(coach, game_ids) / total_coach_games_in_season(coach, game_ids).to_f).round(2)\n end", "def player_win_percentage\n (games_won/user_games)\n end", "def favorite_opponent(team_id)\n team_id = team_id.to_i\n team = @teams.select { |each_team| each_team.team_id == team_id }.first\n favorite_opponent_id = team.matchup_win_percentage.max_by{|each_team, percentage| percentage}.first\n @teams.select { |each_team| each_team.team_id == favorite_opponent_id }.first.team_name\n end", "def winning_team\n home_team_points = game_hash[:home][:players].sum { |e| e[:points] }\n away_team_points = game_hash[:away][:players].sum { |e| e[:points] }\n\n if home_team_points > away_team_points\n return game_hash[:home][:team_name]\n else\n return game_hash[:away][:team_name]\n end\nend", "def winner\n @players.max_by{ |player| player.score}\n end", "def player_w_biggest_feet\n all_players[1].max_by { |stats| stats[:shoe] }\n end", "def worst_fans\n teams_with_bad_fans = @teams.find_all { |team| team.home_minus_away_percentage.negative? }\n teams_with_bad_fans.map { |team| team.team_name }\n end", "def season_with_fewest_games\n seasons = @games.group_by { |game| game.season }\n seasons.min_by { |season, games| games.count }.first\n end", "def winning_team\n team_p = []\n team_n = []\n\n game_hash.each do | location, team_data|\n temp = 0\n team_data[:players].each do |p_name, stats|\n temp += stats[:points]\n end\n team_n << team_data[:team_name]\n team_p << temp\n end\n\n team_p[0] > team_p[1] ? team_n[0] : team_n[1]\n\nend", "def pri_tdef\n team_stats.opp_goals_per_game / team_stats.opp_avg_goals_against_per_game\n end", "def total_team_score(teams_id)\n total_score = 0\n @league_data.each do\n |team| \n # binding.pry\n if team.home_team_id == teams_id\n total_score += team.home_team_score\n elsif team.away_team_id == teams_id\n total_score += team.away_team_score\n end\n end\n return total_score\n end", "def bp_odds_on_favorite\n\t\tfav_team=Teamseason.new\n\t\tfav_team.year=self.matchup_year\n\t\tfav_team.team=self.favorite \n\t\tunderdog_team=Teamseason.new\n\t\tunderdog_team.year=self.matchup_year\n\t\tunderdog_team.team=self.underdog\n\t\treturn fav_team.bp_ros_win_pct.to_f.odds_against_opponent(underdog_team.bp_ros_win_pct.to_f)\n\tend", "def winning_team\n nets = []\n hornets = []\n\n game_hash.values.each do |nets_stats|\n if nets_stats[:team_name] == \"Brooklyn Nets\"\n nets_stats[:players].each do |bk|\n nets << bk[:points]\n end\n end\n end\n\n game_hash.values.each do |hornets_stats|\n if hornets_stats[:team_name] == \"Charlotte Hornets\"\n hornets_stats[:players].each do |ch|\n hornets << ch[:points]\n end\n end\n end\n\n if nets.reduce(:+) > hornets.reduce(:+)\n return \"Brooklyn Nets\"\n else\n return \"Charlotte Hornets\"\n end\nend", "def winning_team\n home_team_sum = 0\n away_team_sum = 0\n game_hash.each do |team, team_stats|\n if team_stats[:team_name] == \"Brooklyn Nets\"\n team_stats[:players].each do |player_stats|\n home_team_sum += player_stats[:points]\n end\n elsif team_stats[:team_name] == \"Charlotte Hornets\"\n team_stats[:players].each do |player_stats|\n away_team_sum += player_stats[:points]\n end\n end\n end\n if home_team_sum > away_team_sum\n game_hash[:home][:team_name]\n elsif home_team_sum < away_team_sum\n game_hash[:away][:team_name]\n end\nend", "def winning_team\n home_score = 0\n away_score = 0\n game_hash[:home][:players].keys.each do |name|\n home_score += game_hash[:home][:players][name][:points]\n end\n game_hash[:away][:players].keys.each do |name|\n away_score += game_hash[:away][:players][name][:points]\n end\n home_score > away_score ? game_hash[:home][:team_name] : game_hash[:away][:team_name]\nend", "def big_shoe_rebounds\n max_shoe = 0 \n max_rebounds = 0 \n game_hash.each do |place, team|\n # team.each do |attribute, data|\n team[:players].each do |player|\n if player[:shoe] > max_shoe\n max_shoe = player[:shoe]\n max_rebounds = player[:rebounds]\n # if attribute == :players\n # data.each do |player|\n #this gives me the player hashes\n # data.max_by{|player| player[:shoe] }\n # data.max_by{|player| player[:shoe] }[:rebounds]\n # player.max_by{|player| player[:shoe] \n # player.max_by{|player| player[:shoe] }[:rebounds]\n end\n end\n end\n return max_rebounds\n end", "def outcome\n if self.final\n \th = home_team\n \ta = away_team\n \t# h.wins=0 if h.wins==nil\n \t# h.losses=0 if h.losses==nil\n \t# a.wins=0 if a.wins==nil\n \t# a.losses=0 if a.losses==nil\n \tif home_score == away_score\n \t\treturn 'T'\n \telsif home_score > away_score\n \t\tif !self.recorded\n \t \t\th.wins += 1\n \t \t\ta.losses += 1\n \t \t\th.save\n \t \t\ta.save\n \t \t\tself.recorded=true\n \t \t\tself.save\n \t \tend\n \t\tif overtime\n \t\t\treturn 'h'\n \t\telse\n \t\t\treturn 'H'\n \t\tend\n \telse\n \t\tif !self.recorded\n \t \t\th.losses += 1\n \t \t\ta.wins += 1\n \t \t\ta.save\n \t \t\th.save\n \t \t\tself.recorded=true\n \t \t\tself.save\n \t \tend\n \t\tif overtime\n \t\t\treturn 'a'\n \t\telse\n \t\t\treturn 'A'\n \t\tend\n \tend\n end\n end", "def highest_player_score\n players.max_by{|player| player.score}.score\n end", "def probability_by_win_ratio(delta)\n # A team wins between 0% and 100% of its games\n # Comparing two teams, the difference in percentages will also be between 0% and 100%\n # If they have equal win percentages, then it is a tossup--50/50\n # If one team has won 100% and the other has won 0%,\n # ...then there is a 100% win percentage different between them\n # ...in that case, the odds should be 100% in favor of the 100% team.\n 0.5 + 0.5 * delta\nend", "def winning_team_with_spread\n\t\tif self.final?\n\t\t\treturn home_team_id if home_team_score > away_team_score + point_spread\n\t\t\treturn away_team_id if away_team_score + point_spread > home_team_score\n\t\t\treturn \"tie\" if home_team_score == away_team_score + point_spread\n\t\telse\n\t\t\treturn nil\n\t\tend\n\tend", "def find_best_score(total_per_player)\n best_score = 0\n winner = ''\n total_per_player.each do |player_name,total|\n\n if total > best_score\n best_score = total\n winner = player_name\n end\n end\n return winner\n end", "def winner\n if (self.homeScore > self.awayScore)\n return self.home_team\n elsif (self.awayScore > self.homeScore)\n return self.away_team\n else\n return nil\n end\n end", "def lowest_scoring_home_team\n @teams.min_by { |team| team.average_home_goals }.team_name\n end", "def win_percent\n matchmade_games < 1 ? 0 : ((total_exp.to_f/matchmade_games.to_f) * 100).to_d\n end", "def get_team(game)\n team = 0\n get_participation_by_game game do |participation|\n team = participation.team\n end\n team\n end", "def percentage_home_wins\n home_wins = @teams.map { |team| team.home_wins }.sum\n home_games = @teams.map { |team| team.home_games }.sum\n (home_wins.to_f / home_games.to_f).round(2)\n end", "def energy()\n score = 0\n @matches.each do |m|\n # Teams Same School\n if m.team_a.school == m.team_b.school\n score -= @penalties[:teams_same_school]\n end\n # Judges Same School\n m.judges.each do |j|\n if j.school == m.team_a.school\n score -= @penalties[:judge_same_school]\n end\n if j.school == m.team_b.school\n score -= @penalties[:judge_same_school]\n end\n end\n # Different Win/Loss\n if m.team_a.num_wins != m.team_b.num_wins\n score -= (1 + @penalties[:different_win_loss]) **\n (m.team_a.num_wins - m.team_b.num_wins).abs\n score -= 1 # No, really, this makes sense...\n end\n end\n score\n end", "def uefa_euro_2016(teams, scores)\n if scores[0] < scores[1]\n return \"At match \" + teams[0] + \" - \" + teams[1] + \", \" + teams[1] + \" won!\"\n elsif scores[0] > scores[1]\n return \"At match \" + teams[0] + \" - \" + teams[1] + \", \" + teams[0] + \" won!\"\n else\n return \"At match \" + teams[0] + \" - \" + teams[1] + \", teams played draw.\"\n end\nend", "def determine_match_winner\n @games_to_win = ((total_number_of_games / 2.0).floor) + 1\n if player1.score == games_to_win\n return player1\n elsif player2.score == games_to_win\n return player2\n else\n return nil\n end\n end", "def points(team)\n first = 0\n res = self.result\n\n if res\n if team == 1\n first_team = res[0]\n sec_team = res[1]\n elsif team == 2\n first_team = res[1]\n sec_team = res[0]\n else \n raise \"Invalid Team chosen\"\n end\n\n p first_team <=> sec_team\n # Compare the results\n outcome = first_team <=> sec_team\n\n if outcome > 0\n # Win\n result = 3\n elsif outcome < 0\n # Loss\n result = 0\n else \n # Draw\n result = 1\n end\n else\n result = nil\n end\n\n result\n end", "def winningest_coach(seasonasstring) # coach name in game team stats\n #per season, get list of all coaches - given by arg\n #per coach, find all games played by that coach\n #then count of all games won / count of all games played\n #find highest\n #return name of coach found in 114\n end", "def winning_team\n home_points = 0\n away_points = 0\n result = \"\"\n i = 0\n game_hash.each do |team, about|\n about[:players].each do |name , stats|\n if i == 0\n home_points += stats[:points]\n else\n away_points += stats[:points]\n end\n end\n i += 1\n end\n home_points > away_points ? result = game_hash[:home][:team_name] : result = game_hash[:away][:team_name]\nend", "def wins_losses\n GAME_INFO.each do |game|\n @team_records.each do |team|\n if game[:home_team] == team.name && game[:home_score] > game[:away_score] #refactor later\n team.wins += 1\n elsif game[:home_team] == team.name && game[:home_score] < game[:away_score]\n team.losses += 1\n end\n end\n end\n\n GAME_INFO.each do |game|\n @team_records.each do |team|\n if game[:away_team] == team.name && game[:away_score] > game[:home_score] #refactor later\n team.wins += 1\n elsif game[:away_team] == team.name && game[:away_score] < game[:home_score]\n team.losses += 1\n end\n end\n end\n\n end", "def ranks\n @teams = Team.where(\"wins > 0\t\").order(win_percentage: :desc)\n end", "def update_teams(a_game)\n\n add_new_teams(a_game)\n\n teams_in_game = teams_in_game(a_game)\n teams_with_score_max = teams_with_score_max(a_game)\n\n teams_in_game.each_value do |team_in_game|\n\n if !teams_with_score_max.has_key?(team_in_game.name.to_sym)\n # team isn't in group with high score\n team_in_game.lost += 1\n\n else\n # team is in group with high score.\n # team won or tied\n if (1 == teams_with_score_max.length)\n # only one team has high score\n # team won\n team_in_game.won += 1\n elsif (2 <= teams_with_score_max.length)\n # more than one team has high score\n # team tied\n team_in_game.tied += 1\n end\n end\n end\n end", "def near_team_winner?(team)\n unless completed?\n sets_won(team) + 1 == min_sets_to_play\n end\n end", "def fewest_goals_scored(team_id)\n team_id = team_id.to_i\n goals_per_game = @game_teams.map do |game|\n if game.team_id == team_id\n game.goals\n end\n end\n goals_per_game.compact.min\n end", "def trend\n won_games_in_last_48_hours = self.won_games.\n where('updated_at > ?', DateTime.now - 48.hours).\n count\n lost_games_in_last_48_hours = self.games.\n where('updated_at > ?', DateTime.now - 48.hours).count -\n won_games_in_last_48_hours\n\n if won_games_in_last_48_hours > lost_games_in_last_48_hours\n return :up\n elsif lost_games_in_last_48_hours > won_games_in_last_48_hours\n return :down\n else\n return :same\n end\n end", "def team_size_vasilescu(pr, months_back)\n (committer_team(pr, months_back) + merger_team(pr, months_back)).uniq.size\n end", "def get_max_over(stat)\n max = 0\n $data_enemies.each { |enemy|\n next if enemy.nil?\n next if enemy.hidden_best\n next unless $game_party.known_enemy?(enemy.id)\n value = enemy.get_stat(stat)\n max = value if value > max\n }\n max\n end", "def retrieve_season_hall_of_fame\n seasons_hall_of_fame = []\n get_involved_teams unless @involved_teams\n\n @involved_teams.each do |team|\n team_placement = {}\n team_placement[:team] = team\n %w[first_place second_place third_place].each_with_index do |rank, index|\n placement = index + 1\n team_placement[rank.to_sym] = team.computed_season_ranking.joins(:season).where(\"seasons.season_type_id = #{@season_type.id} AND computed_season_rankings.rank = #{placement}\").count\n end\n seasons_hall_of_fame << team_placement\n end\n seasons_hall_of_fame.sort { |p, n| (n[:first_place] * 10_000 + n[:second_place] * 100 + n[:third_place]) <=> (p[:first_place] * 10_000 + p[:second_place] * 100 + p[:third_place]) }\n end", "def overall_WLR\n overall_losses = 0\n overall_wins = 0\n @player_champs_list.each do |champ|\n overall_losses += champ.total_losses\n overall_wins += champ.total_wins\n end\n overall_losses > 0 ? (overall_wins.to_f / overall_losses).round(2) : overall_wins.to_f\n end", "def get_win_percentage(strategy)\n score = 0\n @turns.each do |t|\n score += t.result.to_i if t.strategy.include?(strategy)\n end\n score\n end", "def hotness_vasilescu(pr, months_back)\n commits_per_file = commits_on_pr_files(pr, months_back).map{|x| x[1].size}.sort\n med = commits_per_file[commits_per_file.size/2]\n med / commits_last_x_months(pr, true, months_back).to_f\n end", "def find_score \n player = self.find_winner\n if player == 1\n return @player_1.life\n end\n return @player_2.life\n end", "def winning_team\n home_points = 0\n away_points = 0\n team1 = \"Brooklyn Nets\"\n team2 = \"Charlotte Hornets\"\n game_hash.each do |team,info|\n info.each do |team_info,team_data|\n if team_data.is_a? (Array) \n if team_info != :colors\n if info[:team_name] == \"Brooklyn Nets\"\n team_data.each do |player_index|\n home_points += player_index[:points]\n end\n else \n team_data.each do |player_index|\n away_points += player_index[:points]\n winning_team end\n end\n end\n end\n end\n end\n\n if home_points > away_points\n team1\n else\n team2\n end\n\nend", "def highest_total_score\n @game_manager.highest_total_score\n end", "def teams_with_score_max(a_game)\n teams_with_score_max = {}\n game_teams_with_score_max = a_game.teams_with_score_max(a_game.game_teams)\n game_teams_with_score_max.each do |game_team_with_score_max|\n # find team instance matching game_team instance\n team_with_score_max = @teams[game_team_with_score_max.name.to_sym]\n teams_with_score_max[game_team_with_score_max.name.to_sym] = team_with_score_max\n end\n teams_with_score_max\n end", "def calculate_team_points\n # If the bracket is complete, we can calculate points based on the\n # teams' `final_rank`s.\n if @state == \"complete\"\n calculate_team_points_by_final_rank\n return\n end\n\n # For each team, look at the matches that it is in, look at the point\n # values of those matches, and take the maximum point value. That's the\n # number of points that the team has earned so far in the bracket.\n base_point_value = @config.base_point_value\n\n @teams.each do |team|\n matches_with_team = @matches.select { |match| match.has_team?(team.id) }\n\n puts \"Team #{team.name} was in #{matches_with_team.size} matches\"\n\n points_earned = matches_with_team.max_by(&:points).points\n\n puts \"The largest point value of those matches is #{points_earned}\" \\\n \"#{\" + #{base_point_value} base\" if base_point_value > 0}\"\n\n team.points = points_earned + base_point_value\n end\n end" ]
[ "0.78238744", "0.77875507", "0.7736871", "0.7703502", "0.7640446", "0.7188193", "0.7187627", "0.7163401", "0.7148411", "0.7130576", "0.70652765", "0.70518076", "0.70220566", "0.70122427", "0.69603455", "0.69397897", "0.68740314", "0.68569106", "0.68417865", "0.6693621", "0.6671367", "0.6662123", "0.66601735", "0.66588295", "0.6631763", "0.6627174", "0.6582616", "0.6549724", "0.6516317", "0.6490647", "0.6488446", "0.64673007", "0.64673007", "0.6446425", "0.64321744", "0.6419543", "0.6419421", "0.6410516", "0.6406399", "0.6389608", "0.6380111", "0.63746464", "0.63620305", "0.6327658", "0.63077", "0.62916875", "0.62763286", "0.6267607", "0.6265859", "0.6264627", "0.6260295", "0.62498254", "0.6248262", "0.6239876", "0.6235321", "0.6225091", "0.62228715", "0.6220762", "0.6207226", "0.61979383", "0.6192596", "0.6182072", "0.61764306", "0.6162353", "0.61605006", "0.61573404", "0.6156048", "0.6113733", "0.6113025", "0.6096327", "0.60944635", "0.6089713", "0.6082202", "0.6063948", "0.6061311", "0.60610753", "0.6060223", "0.6058842", "0.6049995", "0.6030352", "0.6010582", "0.6009362", "0.5998174", "0.5991321", "0.59796923", "0.5961642", "0.59412116", "0.5936882", "0.593469", "0.5929448", "0.5923819", "0.59221876", "0.59216124", "0.5915806", "0.59157526", "0.5915735", "0.59143007", "0.5914024", "0.5905849", "0.5902563" ]
0.7194257
5
returns team with biggest increase between preseason and regular season win percentage
def biggest_surprise(season) season = season.to_i @teams.max_by{ |team| team.preseason_to_regular_increase[season] }.team_name end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def best_season(team_id)\n team_id = team_id.to_i\n team = @teams.select { |each_team| each_team.team_id == team_id }.first\n team.season_win_percentages.max_by { |season, percentage| percentage }.first.to_s\n end", "def worst_season(team_id)\n team_id = team_id.to_i\n team = @teams.select { |each_team| each_team.team_id == team_id }.first\n team.season_win_percentages.min_by { |season, percentage| percentage }.first.to_s\n end", "def winningest_team\n @teams.max_by { |team| team.total_win_percentage }.team_name\n end", "def most_accurate_team(seasonasstring) # shots in game team stats\n #get a list of all teams that played in that season - given by arg\n #use above list to sum all shots across all games in season\n #divide above by goals made across all games in season\n #find highest percentage\n #return team name as found in 127\n end", "def determine_winner game\n winner = game.max_by {|team| team[:score]}\n team_standings = get_team_by_name(winner)\n team_standings[:winnings] += 3\nend", "def least_accurate_team(seasonasstring) # shots in game team stats\n #inverse of above\n end", "def best_season(id)\n wins = total_wins_per_team_per_season(id)\n totals = total_games_per_team_per_season(id)\n totals.each do |season, total|\n totals[season] = (wins[season] / total.to_f * 100).round(2)\n end\n totals.max_by {|k,v| v}[0]\n end", "def worst_offense\n teams_total_goals = total_goals_helper\n teams_total_games = total_games_helper\n\n worst_team_goals_avg = 1000\n worst_offense_team_id = 0\n this_team_goals_avg = 0\n\n teams_total_games.each do |games_key, games_value|\n teams_total_goals.each do |goals_key, goals_value|\n if goals_key == games_key\n this_team_goals_avg = (goals_value / games_value.to_f)\n if this_team_goals_avg < worst_team_goals_avg\n worst_team_goals_avg = this_team_goals_avg\n worst_offense_team_id = games_key\n end\n end\n end\n end\n\n team_with_worst_offense = nil\n self.teams.each_value do |team_obj|\n if team_obj.team_id. == worst_offense_team_id\n team_with_worst_offense = team_obj.team_name\n end\n end\n team_with_worst_offense\n end", "def worst_offense\n @teams.min_by { |team| team.average_goals_scored }.team_name\n end", "def biggest_bust(season)\n season = season.to_i\n @teams.min_by{ |team| team.preseason_to_regular_increase[season] }.team_name\n end", "def winning_team\n final_scores = player_collection.reduce(home: 0, away: 0) { |teams_points, next_player|\n case \n when next_player[:location] === :away\n teams_points[:away] += next_player[:points];\n when next_player[:location] === :home\n teams_points[:home] += next_player[:points];\n end\n teams_points; \n }\n winner = final_scores.reduce { |highest_points, team_points| \n highest_points[1] > team_points[1] ? highest_points : team_points; \n }\n game_hash[winner[0]][:team_name]; \nend", "def worst_defense\n teams_total_goals_allowed = total_goals_allowed_helper\n teams_total_games = total_games_helper\n\n worst_team_goals_allowed_avg = 0\n worst_defense_team_id = 0\n this_team_goals_allowed_avg = 0\n\n teams_total_games.each do |games_key, games_value|\n\n teams_total_goals_allowed.each do |goals_key, goals_value|\n if goals_key == games_key\n this_team_goals_allowed_avg = (goals_value / games_value.to_f)\n if this_team_goals_allowed_avg > worst_team_goals_allowed_avg\n worst_team_goals_allowed_avg = this_team_goals_allowed_avg\n worst_defense_team_id = games_key\n end\n end\n end\n end\n team_with_worst_defense = team_name_finder_helper(worst_defense_team_id)\n\n team_with_worst_defense\n end", "def best_defense\n teams_total_goals_allowed = total_goals_allowed_helper\n teams_total_games = total_games_helper\n\n best_team_goals_allowed_avg = 100\n best_defense_team_id = 0\n this_team_goals_allowed_avg = 0\n\n teams_total_games.each do |games_key, games_value|\n teams_total_goals_allowed.each do |goals_key, goals_value|\n if goals_key == games_key\n this_team_goals_allowed_avg = (goals_value / games_value.to_f)\n if this_team_goals_allowed_avg < best_team_goals_allowed_avg\n best_team_goals_allowed_avg = this_team_goals_allowed_avg\n best_defense_team_id = games_key\n end\n end\n end\n end\n\n team_with_best_defense = nil\n self.teams.each_value do |team_obj|\n if team_obj.team_id. == best_defense_team_id\n team_with_best_defense = team_obj.team_name\n end\n end\n team_with_best_defense\n end", "def winning_team\n home_points = collection_by_prop(game_hash[:home], :points).reduce(0, :+)\n away_points = collection_by_prop(game_hash[:away], :points).reduce(0, :+)\n home_points > away_points ? game_hash[:home][:team_name] : game_hash[:away][:team_name]\n end", "def percentage_visitor_wins\n visitor_wins = @teams.map { |team| team.away_wins }.sum\n visitor_games = @teams.map { |team| team.away_games }.sum\n (visitor_wins.to_f / visitor_games.to_f).round(2)\n end", "def best_offense\n @teams.max_by { |team| team.average_goals_scored }.team_name\n end", "def get_standings(games)\n teams = Hash.new\n games.each do |game|\n division_id = game.division_id\n home_team = game.home_team\n away_team = game.visiting_team\n if(teams[home_team.name].nil?)\n teams[home_team.name] = {:win => 0, :loss => 0, :tie => 0, :point=> 0}\n end\n\n if(teams[away_team.name].nil?)\n teams[away_team.name] = {:win => 0, :loss => 0, :tie => 0, :point => 0}\n end\n if(game.home_team_score && game.visiting_team_score)\n if(game.home_team_score > game.visiting_team_score)\n # home team won\n teams[home_team.name][:win] += 1\n teams[home_team.name][:point] += 5\n # visiting team loss\n teams[away_team.name][:loss] += 1\n elsif(game.home_team_score < game.visiting_team_score)\n # home team loss\n teams[home_team.name][:loss] += 1\n #visiting team won\n teams[away_team.name][:win] += 1\n teams[away_team.name][:point] += 5\n else\n # tie game\n teams[home_team.name][:tie] += 1\n teams[home_team.name][:point] += 1\n teams[away_team.name][:tie] += 1\n teams[away_team.name][:point] += 1\n end\n end\n end\n teams.each do |team, value|\n puts team\n total_games = value[:win] + value[:loss] + value[:tie]\n if total_games > 0 \n win_percentage = value[:win]/total_games.to_f\n else\n win_percentage = 0\n end \n value[:percentage] = win_percentage\n end\n teams_sorted = teams.sort_by{ |k, v| v[:point]}.reverse\n return teams_sorted\n end", "def most_hits(seasonasstring) # shots in game team stats\n #get a list of all teams that played in that season\n #use above list to sum all shots across all games in season\n #find highest across list\n #return team name as found in 139\n end", "def coach_win_percent_in_season(coach, game_ids)\n (total_wins_of_coach_in_season(coach, game_ids) / total_coach_games_in_season(coach, game_ids).to_f).round(2)\n end", "def best_defense\n @teams.min_by { |team| team.average_goals_allowed }.team_name\n end", "def average_win_percentage(team_id)\n team_id = team_id.to_i\n team = @teams.select { |each_team| each_team.team_id == team_id }.first\n team.total_win_percentage.round(2)\n end", "def winning_team\n self.teams.order('score DESC').first\n end", "def compute_team_winner\n if completed?\n team_winner\n else\n if first_team && second_team\n if sets_won(first_team) == min_sets_to_play\n first_team\n elsif sets_won(second_team) == min_sets_to_play\n second_team\n end\n end\n end\n end", "def pri_toff\n team_stats.goals_per_game / team_stats.opp_avg_goals_per_game\n end", "def biggest_suprise(seasonasstring)\n #as above, but change line 100 to reverse operations, regular percentage - postseason percentage\n end", "def power_play_goal_percentage(seasonasstring) # power_play info in game team stat\n #find list of all games in season given by arg\n #sum all power play goals\n #sum all power play oppertunities\n #divide line 146 and line 147\n #return total of above\n end", "def player_win_percentage\n (games_won/user_games)\n end", "def highest_scoring_visitor\n @teams.max_by { |team| team.average_away_goals }.team_name\n end", "def best_fans\n @teams.max_by { |team| team.home_minus_away_percentage }.team_name\n end", "def winning_team\n if homeTeamPoints.sum > awayTeamPoints.sum\n \"Brooklyn Nets\"\n else\n \"Charlotte Hornets\"\n end\nend", "def percentage_home_wins\n home_wins = @teams.map { |team| team.home_wins }.sum\n home_games = @teams.map { |team| team.home_games }.sum\n (home_wins.to_f / home_games.to_f).round(2)\n end", "def worst_defense\n @teams.max_by { |team| team.average_goals_allowed }.team_name\n end", "def high_score\n if self.end_date < Date.today\n self.teams.max_by { |team| team.score }.score\n end\n end", "def goals_for(team)\n valid = ((team == self.home_team or team == self.away_team) and self.final)\n\n if (valid)\n if (self.home_team == team)\n return self.homeScore\n else\n return self.awayScore\n end\n else\n return 0\n end\n end", "def winning_team\n team_p = []\n team_n = []\n\n game_hash.each do | location, team_data|\n temp = 0\n team_data[:players].each do |p_name, stats|\n temp += stats[:points]\n end\n team_n << team_data[:team_name]\n team_p << temp\n end\n\n team_p[0] > team_p[1] ? team_n[0] : team_n[1]\n\nend", "def team_with_more_points(game)\n home_points = game[:home_team][:players].collect do |player|\n player[:stats][:points]\n end.inject {|sum, n| sum + n}\n away_points = game[:away_team][:players].collect do |player|\n player[:stats][:points]\n end.inject {|sum, n| sum + n}\n home_points > away_points ? game[:home_team][:team_name] : game[:away_team][:team_name]\nend", "def winning_team\n home_team_sum = 0\n away_team_sum = 0\n game_hash.each do |team, team_stats|\n if team_stats[:team_name] == \"Brooklyn Nets\"\n team_stats[:players].each do |player_stats|\n home_team_sum += player_stats[:points]\n end\n elsif team_stats[:team_name] == \"Charlotte Hornets\"\n team_stats[:players].each do |player_stats|\n away_team_sum += player_stats[:points]\n end\n end\n end\n if home_team_sum > away_team_sum\n game_hash[:home][:team_name]\n elsif home_team_sum < away_team_sum\n game_hash[:away][:team_name]\n end\nend", "def highest_scoring_home_team\n @teams.max_by { |team| team.average_home_goals }.team_name\n end", "def winning_team\n home_team_points = game_hash[:home][:players].sum { |e| e[:points] }\n away_team_points = game_hash[:away][:players].sum { |e| e[:points] }\n\n if home_team_points > away_team_points\n return game_hash[:home][:team_name]\n else\n return game_hash[:away][:team_name]\n end\nend", "def lowest_scoring_visitor\n @teams.min_by { |team| team.average_away_goals }.team_name\n end", "def winning_team\n home_score = 0\n away_score = 0\n game_hash[:home][:players].keys.each do |name|\n home_score += game_hash[:home][:players][name][:points]\n end\n game_hash[:away][:players].keys.each do |name|\n away_score += game_hash[:away][:players][name][:points]\n end\n home_score > away_score ? game_hash[:home][:team_name] : game_hash[:away][:team_name]\nend", "def biggest_bust(seasonasstring)\n #get all teams in data\n #find all games played by team in season - given by arg\n #get subset of 95 where p is in season marker\n #count games won in subset on 95 / total games in subset on 95\n #get subset of 85 where r is in season marker\n #count games won in subset on 98 / total games in subset on 98\n #result of line 97 - line 99\n #find highest number\n #return team name of result of line 101\n end", "def winning_team\n blue_team.winner? ? blue_team : red_team\n end", "def win_percent\n matchmade_games < 1 ? 0 : ((total_exp.to_f/matchmade_games.to_f) * 100).to_d\n end", "def max_teams(rounds)\n 2**rounds\n end", "def max_teams(rounds)\n 2**rounds\n end", "def goals_against(team)\n valid = ((team == self.home_team or team == self.away_team) and self.final)\n\n if (valid)\n if (self.home_team == team)\n return self.awayScore\n else\n return self.homeScore\n end\n else\n return 0\n end\n end", "def winning_team\n nets = []\n hornets = []\n\n game_hash.values.each do |nets_stats|\n if nets_stats[:team_name] == \"Brooklyn Nets\"\n nets_stats[:players].each do |bk|\n nets << bk[:points]\n end\n end\n end\n\n game_hash.values.each do |hornets_stats|\n if hornets_stats[:team_name] == \"Charlotte Hornets\"\n hornets_stats[:players].each do |ch|\n hornets << ch[:points]\n end\n end\n end\n\n if nets.reduce(:+) > hornets.reduce(:+)\n return \"Brooklyn Nets\"\n else\n return \"Charlotte Hornets\"\n end\nend", "def rival(team_id)\n team_id = team_id.to_i\n team = @teams.select { |each_team| each_team.team_id == team_id }.first\n rival_id = team.matchup_win_percentage.min_by{|each_team, percentage| percentage}.first\n @teams.select { |each_team| each_team.team_id == rival_id }.first.team_name\n end", "def fewest_hits(seasonasstring) # shots in game team stats\n #inverse of above\n end", "def score_for_team(team)\n team ||= winner_team\n winner_team?(team) ? score : scores.reverse.join(':')\n end", "def worst_loss(team_id)\n @games.map do |game|\n if game.away_team_id.to_s == team_id\n game.home_goals - game.away_goals\n elsif game.home_team_id.to_s == team_id\n game.away_goals - game.home_goals\n end\n end.compact.max\n end", "def total_team_score(teams_id)\n total_score = 0\n @league_data.each do\n |team| \n # binding.pry\n if team.home_team_id == teams_id\n total_score += team.home_team_score\n elsif team.away_team_id == teams_id\n total_score += team.away_team_score\n end\n end\n return total_score\n end", "def winning_team\n home_points = 0\n away_points = 0\n result = \"\"\n i = 0\n game_hash.each do |team, about|\n about[:players].each do |name , stats|\n if i == 0\n home_points += stats[:points]\n else\n away_points += stats[:points]\n end\n end\n i += 1\n end\n home_points > away_points ? result = game_hash[:home][:team_name] : result = game_hash[:away][:team_name]\nend", "def season_with_fewest_games\n seasons = @games.group_by { |game| game.season }\n seasons.min_by { |season, games| games.count }.first\n end", "def pri_sos\n team_stats.opp_pyth / 50.0 \n end", "def wins\n wins = 0\n self.teams.each do |team|\n wins += team.games_won.length\n end\n wins\n end", "def determine_match_winner\n @games_to_win = ((total_number_of_games / 2.0).floor) + 1\n if player1.score == games_to_win\n return player1\n elsif player2.score == games_to_win\n return player2\n else\n return nil\n end\n end", "def bp_odds_on_favorite\n\t\tfav_team=Teamseason.new\n\t\tfav_team.year=self.matchup_year\n\t\tfav_team.team=self.favorite \n\t\tunderdog_team=Teamseason.new\n\t\tunderdog_team.year=self.matchup_year\n\t\tunderdog_team.team=self.underdog\n\t\treturn fav_team.bp_ros_win_pct.to_f.odds_against_opponent(underdog_team.bp_ros_win_pct.to_f)\n\tend", "def winning_team_with_spread\n\t\tif self.final?\n\t\t\treturn home_team_id if home_team_score > away_team_score + point_spread\n\t\t\treturn away_team_id if away_team_score + point_spread > home_team_score\n\t\t\treturn \"tie\" if home_team_score == away_team_score + point_spread\n\t\telse\n\t\t\treturn nil\n\t\tend\n\tend", "def pri_tdef\n team_stats.opp_goals_per_game / team_stats.opp_avg_goals_against_per_game\n end", "def lowest_scoring_home_team\n @teams.min_by { |team| team.average_home_goals }.team_name\n end", "def near_team_winner?(team)\n unless completed?\n sets_won(team) + 1 == min_sets_to_play\n end\n end", "def probability_by_win_ratio(delta)\n # A team wins between 0% and 100% of its games\n # Comparing two teams, the difference in percentages will also be between 0% and 100%\n # If they have equal win percentages, then it is a tossup--50/50\n # If one team has won 100% and the other has won 0%,\n # ...then there is a 100% win percentage different between them\n # ...in that case, the odds should be 100% in favor of the 100% team.\n 0.5 + 0.5 * delta\nend", "def points_in_team(team)\r\n perfs = self.performances.where(team: team)\r\n perfs.map(&:points).inject(:+) / perfs.length\r\n end", "def winner_team(game)\n result = nil\n if game.team1_goals.present? && game.team2_goals.present?\n result = game.team1 if game.team1_goals > game.team2_goals\n result = game.team2 if game.team1_goals < game.team2_goals\n end\n\n result\n end", "def percent_wins(wins)\n ((wins.to_f / @num_games.to_f) * 100).round(4)\n end", "def winner\n @players.max_by do |player|\n player.score\n end\n end", "def winning_team\n home_points = 0\n away_points = 0\n team1 = \"Brooklyn Nets\"\n team2 = \"Charlotte Hornets\"\n game_hash.each do |team,info|\n info.each do |team_info,team_data|\n if team_data.is_a? (Array) \n if team_info != :colors\n if info[:team_name] == \"Brooklyn Nets\"\n team_data.each do |player_index|\n home_points += player_index[:points]\n end\n else \n team_data.each do |player_index|\n away_points += player_index[:points]\n winning_team end\n end\n end\n end\n end\n end\n\n if home_points > away_points\n team1\n else\n team2\n end\n\nend", "def ranks\n @teams = Team.where(\"wins > 0\t\").order(win_percentage: :desc)\n end", "def calculate_overall_winner\n points_per_player = {}\n @matches.each do | match |\n !points_per_player[match.winner].nil? ? (points_per_player[match.winner] += 1) : (points_per_player[match.winner] = 1)\n end\n max_points = points_per_player.values.max\n points_per_player.key(max_points)\n end", "def outcome\n if self.final\n \th = home_team\n \ta = away_team\n \t# h.wins=0 if h.wins==nil\n \t# h.losses=0 if h.losses==nil\n \t# a.wins=0 if a.wins==nil\n \t# a.losses=0 if a.losses==nil\n \tif home_score == away_score\n \t\treturn 'T'\n \telsif home_score > away_score\n \t\tif !self.recorded\n \t \t\th.wins += 1\n \t \t\ta.losses += 1\n \t \t\th.save\n \t \t\ta.save\n \t \t\tself.recorded=true\n \t \t\tself.save\n \t \tend\n \t\tif overtime\n \t\t\treturn 'h'\n \t\telse\n \t\t\treturn 'H'\n \t\tend\n \telse\n \t\tif !self.recorded\n \t \t\th.losses += 1\n \t \t\ta.wins += 1\n \t \t\ta.save\n \t \t\th.save\n \t \t\tself.recorded=true\n \t \t\tself.save\n \t \tend\n \t\tif overtime\n \t\t\treturn 'a'\n \t\telse\n \t\t\treturn 'A'\n \t\tend\n \tend\n end\n end", "def biggest_blowout\n score_difference = games.map { |game| (game.home_goals - game.away_goals).abs}\n score_difference.max\n end", "def winningest_coach(seasonasstring) # coach name in game team stats\n #per season, get list of all coaches - given by arg\n #per coach, find all games played by that coach\n #then count of all games won / count of all games played\n #find highest\n #return name of coach found in 114\n end", "def get_win_percentage(strategy)\n score = 0\n @turns.each do |t|\n score += t.result.to_i if t.strategy.include?(strategy)\n end\n score\n end", "def total_wins_by_season_by_team_id(passed_id)\n @by_team_id_game_objects.each do |game|\n if helper_for_win_count(passed_id, game)\n @total_wins_by_season[game[\"season\"]] += 1\n elsif helper_for_loss_count(passed_id, game)\n @total_wins_by_season[game[\"season\"]] += 0\n end\n end\n end", "def average_goals_by_season\n goals_by_season = @games.group_by { |game| game.season.to_s }\n goals_by_season.each do |season, games|\n season_goals = games.map { |game| game.home_goals + game.away_goals }.sum\n goals_by_season[season] = (season_goals.to_f / games.count.to_f).round(2)\n end\n end", "def season_with_most_games\n seasons = @games.group_by { |game| game.season }\n seasons.max_by { |season, games| games.count }.first\n end", "def find_best_score(total_per_player)\n best_score = 0\n winner = ''\n total_per_player.each do |player_name,total|\n\n if total > best_score\n best_score = total\n winner = player_name\n end\n end\n return winner\n end", "def winning_team\n points_home = 0\n points_away = 0\n result = \"\"\n\n game_hash.each do |side,team|\n team.each do |specs,info|\n if specs == :players\n info.each do |player|\n if side = :home\n points_home += player[:points]\n else\n points_away += player[:points]\n end\n end\n end\n end\n end\n if points_home > points_away\n result = game_hash[:home][:team_name]\n else\n result = game_hash[:away][:team_name]\n end\n result\nend", "def big_shoe_rebounds\n max_shoe = 0 \n max_rebounds = 0 \n game_hash.each do |place, team|\n # team.each do |attribute, data|\n team[:players].each do |player|\n if player[:shoe] > max_shoe\n max_shoe = player[:shoe]\n max_rebounds = player[:rebounds]\n # if attribute == :players\n # data.each do |player|\n #this gives me the player hashes\n # data.max_by{|player| player[:shoe] }\n # data.max_by{|player| player[:shoe] }[:rebounds]\n # player.max_by{|player| player[:shoe] \n # player.max_by{|player| player[:shoe] }[:rebounds]\n end\n end\n end\n return max_rebounds\n end", "def overall_WLR\n overall_losses = 0\n overall_wins = 0\n @player_champs_list.each do |champ|\n overall_losses += champ.total_losses\n overall_wins += champ.total_wins\n end\n overall_losses > 0 ? (overall_wins.to_f / overall_losses).round(2) : overall_wins.to_f\n end", "def winner\n @players.max_by{ |player| player.score}\n end", "def favorite_opponent(team_id)\n team_id = team_id.to_i\n team = @teams.select { |each_team| each_team.team_id == team_id }.first\n favorite_opponent_id = team.matchup_win_percentage.max_by{|each_team, percentage| percentage}.first\n @teams.select { |each_team| each_team.team_id == favorite_opponent_id }.first.team_name\n end", "def stats_vs_team(team, season = nil)\n id = find_id(team, Team)\n data = stats_request(\"vsTeam\", season)\n data.find do |s| s[\"opponent\"][\"id\"] == id end\n end", "def wins_losses\n GAME_INFO.each do |game|\n @team_records.each do |team|\n if game[:home_team] == team.name && game[:home_score] > game[:away_score] #refactor later\n team.wins += 1\n elsif game[:home_team] == team.name && game[:home_score] < game[:away_score]\n team.losses += 1\n end\n end\n end\n\n GAME_INFO.each do |game|\n @team_records.each do |team|\n if game[:away_team] == team.name && game[:away_score] > game[:home_score] #refactor later\n team.wins += 1\n elsif game[:away_team] == team.name && game[:away_score] < game[:home_score]\n team.losses += 1\n end\n end\n end\n\n end", "def points_season(round, season = nil)\n count = 0\n matchs = find_matchs(round, season)\n\n matchs.each do |match|\n if match.is_winner?(self) and match.finished?\n count += MatchGeneral::PT_WIN\n end\n if match.deal? and match.finished?\n count += MatchGeneral::PT_DEAL\n end\n end\n\n count\n end", "def num_rounds\n (Math.log(teams.size) / Math.log(2)).to_i\n end", "def team_hits(hits, team)\n if team.current_units <= hits\n team.units.all.each do |u|\n u.update(count:0)\n end\n else\n u = team.units.where(priority:1).first\n while hits > 0 and team.current_units > 0\n if u.count > 0 and hits > 0\n u.update(count: u.count-1)\n hits-=1\n else\n u = u.next\n end\n end\n return team\n end\n end", "def matchup_count(season = 2015)\n r = Record.find_by(team_id: self.id, year: season)\n r.wins + r.losses + r.ties\n end", "def energy()\n score = 0\n @matches.each do |m|\n # Teams Same School\n if m.team_a.school == m.team_b.school\n score -= @penalties[:teams_same_school]\n end\n # Judges Same School\n m.judges.each do |j|\n if j.school == m.team_a.school\n score -= @penalties[:judge_same_school]\n end\n if j.school == m.team_b.school\n score -= @penalties[:judge_same_school]\n end\n end\n # Different Win/Loss\n if m.team_a.num_wins != m.team_b.num_wins\n score -= (1 + @penalties[:different_win_loss]) **\n (m.team_a.num_wins - m.team_b.num_wins).abs\n score -= 1 # No, really, this makes sense...\n end\n end\n score\n end", "def winner\n if (self.homeScore > self.awayScore)\n return self.home_team\n elsif (self.awayScore > self.homeScore)\n return self.away_team\n else\n return nil\n end\n end", "def points(team)\n first = 0\n res = self.result\n\n if res\n if team == 1\n first_team = res[0]\n sec_team = res[1]\n elsif team == 2\n first_team = res[1]\n sec_team = res[0]\n else \n raise \"Invalid Team chosen\"\n end\n\n p first_team <=> sec_team\n # Compare the results\n outcome = first_team <=> sec_team\n\n if outcome > 0\n # Win\n result = 3\n elsif outcome < 0\n # Loss\n result = 0\n else \n # Draw\n result = 1\n end\n else\n result = nil\n end\n\n result\n end", "def calculate_team_points\n # If the bracket is complete, we can calculate points based on the\n # teams' `final_rank`s.\n if @state == \"complete\"\n calculate_team_points_by_final_rank\n return\n end\n\n # For each team, look at the matches that it is in, look at the point\n # values of those matches, and take the maximum point value. That's the\n # number of points that the team has earned so far in the bracket.\n base_point_value = @config.base_point_value\n\n @teams.each do |team|\n matches_with_team = @matches.select { |match| match.has_team?(team.id) }\n\n puts \"Team #{team.name} was in #{matches_with_team.size} matches\"\n\n points_earned = matches_with_team.max_by(&:points).points\n\n puts \"The largest point value of those matches is #{points_earned}\" \\\n \"#{\" + #{base_point_value} base\" if base_point_value > 0}\"\n\n team.points = points_earned + base_point_value\n end\n end", "def update_teams(a_game)\n\n add_new_teams(a_game)\n\n teams_in_game = teams_in_game(a_game)\n teams_with_score_max = teams_with_score_max(a_game)\n\n teams_in_game.each_value do |team_in_game|\n\n if !teams_with_score_max.has_key?(team_in_game.name.to_sym)\n # team isn't in group with high score\n team_in_game.lost += 1\n\n else\n # team is in group with high score.\n # team won or tied\n if (1 == teams_with_score_max.length)\n # only one team has high score\n # team won\n team_in_game.won += 1\n elsif (2 <= teams_with_score_max.length)\n # more than one team has high score\n # team tied\n team_in_game.tied += 1\n end\n end\n end\n end", "def winning_scores\n high_score = scores.max{|score| score.total}.total\n scores.select {|score| score.total == high_score}\n end", "def fewest_goals_scored(team_id)\n team_id = team_id.to_i\n goals_per_game = @game_teams.map do |game|\n if game.team_id == team_id\n game.goals\n end\n end\n goals_per_game.compact.min\n end", "def set_winner_for_total_xp(user_or_team)\n return if Date.today < end_date \n units = competable_registrations.collect{|comp_s| comp_s.send(user_or_team)}\n winner = units.max { |a, b| a.total_xp_for_competition(self) <=> b.total_xp_for_competition(self) } \n set_winner(winner)\n end", "def rating\n position_sum = 0\n games = []\n number_of_teams = 0\n Participation.find_all_by_player_id(self.id).each do |participation|\n position_sum += participation.position\n games.push Game.find(participation.game_id)\n end\n\n games.each do |game|\n number_of_teams += game.number_of_teams\n end\n\n if position_sum == 0\n position_sum = number_of_teams.to_f-0.5\n end\n\n (1 - position_sum.to_f/number_of_teams).round 2\n end", "def retrieve_season_hall_of_fame\n seasons_hall_of_fame = []\n get_involved_teams unless @involved_teams\n\n @involved_teams.each do |team|\n team_placement = {}\n team_placement[:team] = team\n %w[first_place second_place third_place].each_with_index do |rank, index|\n placement = index + 1\n team_placement[rank.to_sym] = team.computed_season_ranking.joins(:season).where(\"seasons.season_type_id = #{@season_type.id} AND computed_season_rankings.rank = #{placement}\").count\n end\n seasons_hall_of_fame << team_placement\n end\n seasons_hall_of_fame.sort { |p, n| (n[:first_place] * 10_000 + n[:second_place] * 100 + n[:third_place]) <=> (p[:first_place] * 10_000 + p[:second_place] * 100 + p[:third_place]) }\n end" ]
[ "0.7733624", "0.7723793", "0.77036023", "0.7624202", "0.7428437", "0.7232556", "0.71246934", "0.7100648", "0.7068172", "0.706483", "0.70164055", "0.70026904", "0.69976693", "0.6909588", "0.69074035", "0.68988293", "0.68712324", "0.68307143", "0.68154", "0.6814275", "0.68062127", "0.68038476", "0.6803814", "0.6802584", "0.67717344", "0.6763701", "0.6752576", "0.67460716", "0.6720029", "0.6719018", "0.6716754", "0.6691504", "0.6643704", "0.6631378", "0.662641", "0.66179305", "0.66094214", "0.66004354", "0.65964717", "0.6595435", "0.6572214", "0.65559846", "0.65344876", "0.65279377", "0.65170866", "0.65170866", "0.65013266", "0.6476416", "0.6475316", "0.6471805", "0.64713943", "0.64692456", "0.64594114", "0.64234346", "0.6414968", "0.6410937", "0.64038306", "0.64019924", "0.6393078", "0.63863695", "0.63847905", "0.6382054", "0.6374563", "0.6366496", "0.635162", "0.6337902", "0.63371044", "0.6335903", "0.63337165", "0.63218683", "0.63152426", "0.62985605", "0.6289023", "0.62805855", "0.62804234", "0.6280123", "0.627989", "0.62796783", "0.62715554", "0.6267256", "0.6262328", "0.62411124", "0.6240508", "0.6236007", "0.6232026", "0.6229323", "0.62234324", "0.6223313", "0.6218685", "0.6218614", "0.6194579", "0.61932397", "0.61892766", "0.618602", "0.6182724", "0.61711514", "0.6169245", "0.61658406", "0.6160306", "0.6146502" ]
0.746648
4
A hash with two keys (:preseason, and :regular_season) each pointing to a hash with the keys :win_percentage, :goals_scored, and :goals_against
def season_summary(season, team_id) season = season.to_i team_id = team_id.to_i season_summary_hash(season, team_id) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_standings(games)\n teams = Hash.new\n games.each do |game|\n division_id = game.division_id\n home_team = game.home_team\n away_team = game.visiting_team\n if(teams[home_team.name].nil?)\n teams[home_team.name] = {:win => 0, :loss => 0, :tie => 0, :point=> 0}\n end\n\n if(teams[away_team.name].nil?)\n teams[away_team.name] = {:win => 0, :loss => 0, :tie => 0, :point => 0}\n end\n if(game.home_team_score && game.visiting_team_score)\n if(game.home_team_score > game.visiting_team_score)\n # home team won\n teams[home_team.name][:win] += 1\n teams[home_team.name][:point] += 5\n # visiting team loss\n teams[away_team.name][:loss] += 1\n elsif(game.home_team_score < game.visiting_team_score)\n # home team loss\n teams[home_team.name][:loss] += 1\n #visiting team won\n teams[away_team.name][:win] += 1\n teams[away_team.name][:point] += 5\n else\n # tie game\n teams[home_team.name][:tie] += 1\n teams[home_team.name][:point] += 1\n teams[away_team.name][:tie] += 1\n teams[away_team.name][:point] += 1\n end\n end\n end\n teams.each do |team, value|\n puts team\n total_games = value[:win] + value[:loss] + value[:tie]\n if total_games > 0 \n win_percentage = value[:win]/total_games.to_f\n else\n win_percentage = 0\n end \n value[:percentage] = win_percentage\n end\n teams_sorted = teams.sort_by{ |k, v| v[:point]}.reverse\n return teams_sorted\n end", "def results_hash\r\n if self.home_score > self.away_score\r\n {winner: self.home_team,loser: self.away_team}\r\n else \r\n {winner: self.away_team,loser: self.home_team}\r\n end\r\n end", "def matches_played_by_season(table_of_teams)\n matches_played = Hash.new { |hash, key| hash[key] = Hash.new(0) }\n\n table_of_teams.each do |table_row|\n matches_played[table_row['season']][table_row['team1']] += 1\n matches_played[table_row['season']][table_row['team2']] += 1\n end\n matches_played\nend", "def skater_stats(stats)\n skater_stats = Hash.new\n skater_stats[:seasons] = stats.seasons\nend", "def season_prepare\n ret = {\n :competitions_to_draw => League.all\n }\n \n ret[:competitions_to_draw]\n \n return ret\n end", "def total_games_by_coach_by_season\n @total_games_by_coach = Hash.new{ |hash, key| hash[key] = 0}\n @by_season_game_team_objects.each do |game_by_season|\n @total_games_by_coach[game_by_season[\"head_coach\"]] += 1\n end\n end", "def game_hash\n game_hash = { :home => { :team_name => \"Brooklyn Nets\", \n :colors => [\"Black\", \"White\"], \n :players => { :alan_anderson => { :number => 0,\n :shoe => 16,\n :points => 22,\n :rebounds => 12,\n :assists => 12,\n :steals => 3,\n :blocks => 1,\n :slam_dunks => 1 },\n :reggie_evans => { :number => 30,\n :shoe => 14,\n :points => 12,\n :rebounds => 12,\n :assists => 12,\n :steals => 12,\n :blocks => 12,\n :slam_dunks => 7 },\n :brook_lopez => { :number => 11,\n :shoe => 17,\n :points => 17,\n :rebounds => 19,\n :assists => 10,\n :steals => 3,\n :blocks => 1,\n :slam_dunks => 15 },\n :mason_plumlee => { :number => 1,\n :shoe => 19,\n :points => 26,\n :rebounds => 12,\n :assists => 6,\n :steals => 3,\n :blocks => 8,\n :slam_dunks => 5 },\n :jason_terry => { :number => 31,\n :shoe => 15,\n :points => 19,\n :rebounds => 2,\n :assists => 2,\n :steals => 4,\n :blocks => 11,\n :slam_dunks => 1 }\n }\n }, \n\n :away => { :team_name => \"Charlotte Hornets\", \n :colors => [\"Turquoise\", \"Purple\"], \n :players => { :jeff_adrien => { :number => 4,\n :shoe => 18,\n :points => 10,\n :rebounds => 1,\n :assists => 1,\n :steals => 2,\n :blocks => 7,\n :slam_dunks => 2 },\n :bismak_biyombo => { :number => 0,\n :shoe => 16,\n :points => 12,\n :rebounds => 4,\n :assists => 7,\n :steals => 7,\n :blocks => 15,\n :slam_dunks => 10 },\n :desagna_diop => { :number => 2,\n :shoe => 14,\n :points => 24,\n :rebounds => 12,\n :assists => 12,\n :steals => 4,\n :blocks => 5,\n :slam_dunks => 5 },\n :ben_gordon => { :number => 8,\n :shoe => 15,\n :points => 33,\n :rebounds => 3,\n :assists => 2,\n :steals => 1,\n :blocks => 1,\n :slam_dunks => 0 },\n :brendan_haywood => { :number => 33,\n :shoe => 15,\n :points => 6,\n :rebounds => 12,\n :assists => 12,\n :steals => 22,\n :blocks => 5,\n :slam_dunks => 12 }\n }\n } \n }\n return game_hash\nend", "def setup_winners_right_now\n # create a Hash with ongoing games\n @honorable_hash = Hash.new\n @games.each do |g|\n if g.started?\n tips = Tip.joins(:user).where(\"game_id =? and home_score = ? and away_score = ?\", g.id, g.home_score, g.away_score).order(\"users.points DESC\")\n @honorable_hash[g.id] = tips\n end\n end\n end", "def average_goals_by_season\n goals_by_season = @games.group_by { |game| game.season.to_s }\n goals_by_season.each do |season, games|\n season_goals = games.map { |game| game.home_goals + game.away_goals }.sum\n goals_by_season[season] = (season_goals.to_f / games.count.to_f).round(2)\n end\n end", "def game_hash \n stats = {\n home: {\n team_name: \"Brooklyn Nets\",\n colors: ['Black', 'White'],\n players: [\n {'Alan Anderson' => { number: 0, shoe: 16, points: 22, rebounds: 12, assists: 12, steals: 3, blocks: 1, slam_dunks: 1}},\n {'Reggie Evans' => { number: 30, shoe: 14, points: 12, rebounds: 12, assists: 12, steals: 12, blocks: 12, slam_dunks: 7}},\n {'Brook Lopez' => { number: 11, shoe: 17, points: 17, rebounds: 19, assists: 10, steals: 3, blocks: 1, slam_dunks: 15}},\n {'Mason Plumlee' => { number: 1, shoe: 19, points: 26, rebounds: 11, assists: 6, steals: 3, blocks: 8, slam_dunks: 5}},\n {'Jason Terry' => { number: 31, shoe: 15, points: 19, rebounds: 2, assists: 2, steals: 4, blocks: 11, slam_dunks: 1}}\n ]\n },\n away: {\n team_name: \"Charlotte Hornets\",\n colors: ['Turquoise', 'Purple'],\n players: [\n {'Jeff Adrien' => { number: 4, shoe: 18, points: 10, rebounds: 1, assists: 1, steals: 2, blocks: 7, slam_dunks: 2}},\n {'Bismack Biyombo' => { number: 0, shoe: 16, points: 12, rebounds: 4, assists: 7, steals: 22, blocks: 15, slam_dunks: 10}},\n {'DeSagna Diop' => { number: 2, shoe: 14, points: 24, rebounds: 12, assists: 12, steals: 4, blocks: 5, slam_dunks: 5}},\n {'Ben Gordon' => { number: 8, shoe: 15, points: 33, rebounds: 3, assists: 2, steals: 1, blocks: 1, slam_dunks: 0}},\n {'Kemba Walker' => { number: 33, shoe: 15, points: 6, rebounds: 12, assists: 12, steals: 7, blocks: 5, slam_dunks: 12}}\n ]\n }\n }\nend", "def test_average_goals_by_season\n\n expected = {\n \"20122013\"=>4.12,\n \"20162017\"=>4.23,\n \"20142015\"=>4.14,\n \"20152016\"=>4.16,\n \"20132014\"=>4.19,\n \"20172018\"=>4.44\n }\n assert_equal expected, @stat_tracker.average_goals_by_season\n\n end", "def calculate!\n ov = self[:overall]\n ov[:high_night] = {}\n ov[:winners] = {}\n\n self.each do |player_id, st|\n next if player_id == :overall\n\n ## calculate computed stats for player\n st[:nights] += st[:dates].keys.length # if st[:nights] == 0\n st[:high_night] = st[:dates].values.max\n st[:gold_stars] = 1 if st[:nights] == 29\n st[:warps_per_game] = 1.0 * st[:warps] / st[:games] rescue 0\n st[:warps_per_night] = 1.0 * st[:warps] / st[:nights] rescue 0\n st[:games_per_night] = 1.0 * st[:games] / st[:nights] rescue 0\n st[:wins_per_night] = 1.0 * st[:wins] / st[:nights] rescue 0\n st[:wins_per_game] = 1.0 * st[:wins] / st[:games] rescue 0\n\n ## accumulate overall stats\n [:warps, :wins, :cfbs,\n :mystery_factors, :gold_stars]. each do |field|\n ov[field] += st[field]\n end\n [:wimps, :come_ons].each do |field|\n if st[field]\n ov[field] ||= 0\n ov[field] += st[field]\n end\n end\n # nights won calculation\n st[:dates].each do |date,warps|\n ov[:dates][date] += warps\n hnd = ov[:high_night][date] ||= {:players => [], :warps => 0}\n if hnd[:warps] < warps\n hnd[:players] = [player_id]\n hnd[:warps] = warps\n elsif hnd[:warps] == warps\n hnd[:players].push(player_id)\n end\n end\n end\n\n ## update overall computed stats\n st = self[:overall]\n ov[:games] = ov[:wins]\n ov[:nights] = ov[:dates].keys.length\n ov[:nights] = 29 if ov[:nights] == 0 ## provide sane default\n ov[:nights] = ov[:nights_real] if ov[:nights_real]\n ov[:warps_per_game] = 1.0 * ov[:warps] / ov[:games] rescue 0\n ov[:warps_per_night] = 1.0 * ov[:warps] / ov[:nights] rescue 0\n ov[:games_per_night] = 1.0 * ov[:games] / ov[:nights] rescue 0\n ov[:high_night].each do |date,h|\n h[:players].each {|p| self[p][:nights_won] += 1}\n end\n\n ## determine per-stat winners\n # fuck everyone but the top 50 OR those with 50+ warps\n # the 51 below is not a bug\n sorted_players = self.keys.sort{|a,b| self[b][:warps] <=> self[a][:warps]}\n fifty_plus = self.keys.select{|p| self[p][:warps] >= 50}\n eligible = (sorted_players[0..51] | fifty_plus).\n inject(Hash.new(false)) {|acc,p| acc.merge(p => true)}\n [:warps, :games, :nights, :wins, :nights_won, :cfbs,\n :come_ons, :wimps, :warps_per_game, :warps_per_night,\n :games_per_night, :wins_per_game, :high_night].each do |field|\n owf = ov[:winners][field] = {:players => [], :value => 0}\n self.each do |player, st|\n next if player == :overall\n next unless eligible[player]\n if st[field].to_f > owf[:value]\n owf[:players] = [player]\n owf[:value] = st[field]\n elsif st[field] == owf[:value]\n owf[:players].push(player)\n end\n end\n end\n\n ## mark per-stat winners\n ov[:winners].each do |field, win|\n win[:players].each do |player|\n self[player][:winner][field] = true\n end\n end\n\n self\n end", "def winning_team\n home_team_sum = 0\n away_team_sum = 0\n game_hash.each do |team, team_stats|\n if team_stats[:team_name] == \"Brooklyn Nets\"\n team_stats[:players].each do |player_stats|\n home_team_sum += player_stats[:points]\n end\n elsif team_stats[:team_name] == \"Charlotte Hornets\"\n team_stats[:players].each do |player_stats|\n away_team_sum += player_stats[:points]\n end\n end\n end\n if home_team_sum > away_team_sum\n game_hash[:home][:team_name]\n elsif home_team_sum < away_team_sum\n game_hash[:away][:team_name]\n end\nend", "def game_hash\n\tgame_hash = {\n\t\t:home => {\n\t\t\t:team_name => \"Brooklyn Nets\",\n\t\t\t:colors => [\"Black\", \"White\"],\n\t\t\t:players => {\n\t\t\t\t\"Alan Anderson\" => {:number => 0, \n\t\t\t\t\t\t\t\t\t:shoe => 16, \n\t\t\t\t\t\t\t\t\t:points => 22,\n\t\t\t\t\t\t\t\t\t:rebounds => 12,\n\t\t\t\t\t\t\t\t\t:assists => 12,\n\t\t\t\t\t\t\t\t\t:steals => 3,\n\t\t\t\t\t\t\t\t\t:blocks => 1,\n\t\t\t\t\t\t\t\t\t:slam_dunks => 1\n\t\t\t\t},\n\t\t\t\t\"Reggie Evans\" =>{:number => 30,\n\t\t\t\t\t\t\t\t :shoe => 14,\n\t\t\t\t\t\t\t\t :points => 12,\n\t\t\t\t\t\t\t\t :rebounds => 12,\n\t\t\t\t\t\t\t\t :assists => 12,\n\t\t\t\t\t\t\t\t :steals => 12,\n\t\t\t\t\t\t\t\t :blocks => 12,\n\t\t\t\t\t\t\t\t :slam_dunks => 7\n\n\t\t\t\t},\n\t\t\t\t\"Brook Lopez\" => {:number => 11,\n\t\t\t\t\t\t\t\t :shoe => 17,\n\t\t\t\t\t\t\t :points => 17,\n\t\t\t\t\t\t\t :rebounds => 19,\n\t\t\t\t\t\t\t\t :assists => 10,\n\t\t\t\t\t\t\t :steals => 3,\n\t\t\t\t\t\t\t\t :blocks => 1,\n\t\t\t\t\t\t\t\t :slam_dunks => 15\n\n\t\t\t\t},\n\t\t\t\t\"Mason Plumlee\" => {:number => 1,\n\t\t\t\t\t\t\t\t\t:shoe => 19,\n\t\t\t\t\t\t\t\t\t:points => 26,\n\t\t\t\t\t\t\t\t\t:rebounds => 12,\n\t\t\t\t\t\t\t\t\t:assists => 6,\n\t\t\t\t\t\t\t :steals => 3,\n\t\t\t\t\t\t\t\t :blocks => 8,\n\t\t\t\t\t\t\t\t :slam_dunks => 5\n\t\t\t\t},\n\t\t\t\t\"Jason Terry\" => {:number => 31,\n\t\t\t\t\t\t\t\t :shoe => 15,\n\t\t\t\t\t\t\t\t :points => 19,\n\t\t\t\t\t\t\t\t :rebounds => 2,\n\t\t\t\t\t\t\t\t :assists => 2,\n\t\t\t\t\t\t\t :steals => 4,\n\t\t\t\t\t\t\t\t :blocks => 11,\n\t\t\t\t\t\t\t\t :slam_dunks => 1\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\t:away => {\n\t\t\t:team_name => \"Charlotte Hornets\",\n\t\t\t:colors => [\"Turquoise\", \"Purple\"],\n\t\t\t:players => {\n\t\t\t\t\"Jeff Adrien\" => {:number => 4,\n\t\t\t\t\t\t\t\t :shoe => 18,\n\t\t\t\t\t\t\t\t :points => 10,\n\t\t\t\t\t\t\t\t :rebounds => 1,\n\t\t\t\t\t\t\t\t :assists => 1,\n\t\t\t\t\t\t\t :steals => 2,\n\t\t\t\t\t\t\t\t :blocks => 7,\n\t\t\t\t\t\t\t\t :slam_dunks => 2\n\t\t\t\t},\n\t\t\t\t\"Bismak Biyombo\" => {:number => 0,\n\t\t\t\t\t\t\t\t\t :shoe => 16,\n\t\t\t\t\t\t\t\t\t :points => 12,\n\t\t\t\t\t\t\t\t\t :rebounds => 4,\n\t\t\t\t\t\t\t\t\t :assists => 7,\n\t\t\t\t\t\t\t :steals => 7,\n\t\t\t\t\t\t\t\t :blocks => 15,\n\t\t\t\t\t\t\t\t :slam_dunks => 10\n\t\t\t\t},\n\t\t\t\t\"DeSagna Diop\" => {:number => 2,\n\t\t\t\t\t\t\t\t :shoe => 14,\n\t\t\t\t\t\t\t\t :points => 24,\n\t\t\t\t\t\t\t\t :rebounds => 12,\n\t\t\t\t\t\t\t\t :assists => 12,\n\t\t\t\t\t\t\t :steals => 4, \n\t\t\t\t\t\t\t\t :blocks => 5,\n\t\t\t\t\t\t\t\t :slam_dunks => 5\n\t\t\t\t},\n\t\t\t\t\"Ben Gordon\" => {:number => 8,\n\t\t\t\t\t\t\t\t :shoe => 15,\n\t\t\t\t\t\t\t\t :points => 33,\n\t\t\t\t\t\t\t\t :rebounds => 3,\n\t\t\t\t\t\t\t\t :assists => 2,\n\t\t\t\t\t\t\t :steals => 1,\n\t\t\t\t\t\t\t\t :blocks => 1,\n\t\t\t\t\t\t\t\t :slam_dunks => 0\n\t\t\t\t},\n\t\t\t\t\"Brendan Haywood\" => {:number => 33,\n\t\t\t\t\t\t\t\t\t :shoe => 15,\n\t\t\t\t\t\t\t\t\t :points => 6,\n\t\t\t\t\t\t\t\t\t :rebounds => 12,\n\t\t\t\t\t\t\t\t\t :assists => 12,\n\t\t\t\t\t\t\t \t :steals => 22,\n\t\t\t\t\t\t\t\t \t :blocks => 5,\n\t\t\t\t\t\t\t\t \t :slam_dunks => 12\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\nend", "def its_a_tie game\n game.each do |team|\n team_standings = get_team_by_name(team)\n team_standings[:winnings] += 1\n end\nend", "def game_hash\n hash = {\n :home => {\n :team_name => \"Brooklyn Nets\",\n :colors => [\"Black\", \"White\"],\n :players => {\n \"Alan Anderson\" => {\n :number => \"0\",\n :shoe => \"16\",\n :points => \"22\",\n :rebounds => \"12\",\n :assists => \"12\",\n :steals => \"3\",\n :blocks => \"1\",\n :slam_dunks => \"1\"\n },\n \"Reggie Evans\" => {\n :number => \"30\",\n :shoe => \"14\",\n :points => \"12\",\n :rebounds => \"12\",\n :assists => \"12\",\n :steals => \"12\",\n :blocks => \"12\",\n :slam_dunks => \"7\"\n },\n \"Brook Lopez\" => {\n :number => \"11\",\n :shoe => \"17\",\n :points => \"17\",\n :rebounds => \"19\",\n :assists => \"10\",\n :steals => \"3\",\n :blocks => \"1\",\n :slam_dunks => \"15\"\n },\n \"Mason Plumlee\" => {\n :number => \"1\",\n :shoe => \"19\",\n :points => \"26\",\n :rebounds => \"12\",\n :assists => \"6\",\n :steals => \"3\",\n :blocks => \"8\",\n :slam_dunks => \"5\"\n },\n \"Jason Terry\" => {\n :number => \"31\",\n :shoe => \"15\",\n :points => \"19\",\n :rebounds => \"2\",\n :assists => \"2\",\n :steals => \"4\",\n :blocks => \"11\",\n :slam_dunks => \"1\"\n }\n }\n },\n :away => {\n :team_name => \"Charlotte Hornets\",\n :colors => [\"Turquoise\", \"Purple\"],\n :players => {\n \"Jeff Adrien\" => {\n :number => \"4\",\n :shoe => \"18\",\n :points => \"10\",\n :rebounds => \"1\",\n :assists => \"1\",\n :steals => \"2\",\n :blocks => \"7\",\n :slam_dunks => \"2\"\n },\n \"Bismak Biyombo\" => {\n :number => \"0\",\n :shoe => \"16\",\n :points => \"12\",\n :rebounds => \"4\",\n :assists => \"7\",\n :steals => \"7\",\n :blocks => \"15\",\n :slam_dunks => \"10\"\n },\n \"DeSagna Diop\" => {\n :number => \"2\",\n :shoe => \"14\",\n :points => \"24\",\n :rebounds => \"12\",\n :assists => \"12\",\n :steals => \"4\",\n :blocks => \"5\",\n :slam_dunks => \"5\"\n },\n \"Ben Gordon\" => {\n :number => \"8\",\n :shoe => \"15\",\n :points => \"33\",\n :rebounds => \"3\",\n :assists => \"2\",\n :steals => \"1\",\n :blocks => \"1\",\n :slam_dunks => \"0\"\n },\n \"Brendan Haywood\" => {\n :number => \"33\",\n :shoe => \"15\",\n :points => \"6\",\n :rebounds => \"12\",\n :assists => \"12\",\n :steals => \"22\",\n :blocks => \"5\",\n :slam_dunks => \"12\"\n }\n }\n }\n }\nend", "def winning_play\n {paper: [:rock, :spock], rock: [:lizard, :scissors], scissors: [:paper, :lizard], lizard: [:spock, :paper], spock: [:rock, :scissors], scratch: [:scratch]}\n end", "def game_hash\n { :home => {\n :team_name => \"Brooklyn Nets\",\n :colors => [\"Black\", \"White\"],\n :players => {\n \"Alan Anderson\" =>{\n :number => 0,\n :shoe => 16,\n :points => 22,\n :rebounds => 12,\n :assists => 12,\n :steals => 3,\n :blocks => 1,\n :slam_dunks => 1\n },\n \"Reggie Evans\" => {\n :number => 30,\n :shoe => 14,\n :points => 12,\n :rebounds =>12,\n :assists => 12,\n :steals => 12,\n :blocks => 12,\n :slam_dunks => 7\n \n },\n \"Brook Lopez\" => {\n :number => 11,\n :shoe => 17,\n :points => 17,\n :rebounds => 19,\n :assists => 10,\n :steals => 3,\n :blocks => 1,\n :slam_dunks => 15\n },\n \n \"Mason Plumlee\" => {\n :number => 1,\n :shoe => 19,\n :points => 26,\n :rebounds => 12,\n :assists => 6,\n :steals => 3,\n :blocks => 8,\n :slam_dunks => 5\n },\n \"Jason Terry\" =>{\n :number => 31,\n :shoe => 15,\n :points => 19,\n :rebounds => 2,\n :assists => 2,\n :steals => 4,\n :blocks => 11,\n :slam_dunks => 1\n }\n }\n \n \n },\n \n :away =>{\n :team_name => \"Charlotte Hornets\",\n :colors => [\"Turquoise\", \"Purple\"],\n :players =>{\n \"Jeff Adrien\" =>{\n :number => 4,\n :shoe => 18,\n :points => 10,\n :rebounds => 1,\n :assists => 1,\n :steals => 2,\n :blocks => 7,\n :slam_dunks => 2\n },\n \"Bismak Biyombo\"=>{\n :number => 0,\n :shoe => 16,\n :points => 12,\n :rebounds => 4,\n :assists => 7,\n :steals => 7,\n :blocks => 15,\n :slam_dunks => 10\n },\n \"DeSagna Diop\" =>{\n :number => 2,\n :shoe => 14,\n :points => 24,\n :rebounds => 12,\n :assists => 12,\n :steals => 4,\n :blocks => 5,\n :slam_dunks => 5\n },\n \"Ben Gordon\" =>{\n :number => 8,\n :shoe => 15,\n :points => 33,\n :rebounds => 3,\n :assists => 2,\n :steals => 1,\n :blocks =>1 ,\n :slam_dunks => 0\n },\n \"Brendan Haywood\" =>{\n :number => 33,\n :shoe => 15,\n :points => 6,\n :rebounds => 12,\n :assists => 12,\n :steals => 22 ,\n :blocks => 5,\n :slam_dunks => 12\n \n }\n }\n }\n }\n \nend", "def game_hash\n {\n :home => {\n team_name: \"Brooklyn Nets\",\n colors: [\"Black\", \"White\"],\n :players => {\n \"Alan Anderson\" => {\n number: 0,\n shoe: 16,\n points: 22,\n rebounds: 12,\n assists: 12,\n steals: 3,\n blocks: 1,\n slam_dunks: 1\n },\n \"Reggie Evans\" => {\n number: 30,\n shoe: 14,\n points: 12,\n rebounds: 12,\n assists: 12,\n steals: 12,\n blocks: 12,\n slam_dunks: 7\n },\n \"Brook Lopez\" => {\n number: 11,\n shoe: 17,\n points: 17,\n rebounds: 19,\n assists: 10,\n steals: 3,\n blocks: 1,\n slam_dunks: 15\n },\n \"Mason Plumlee\" => {\n number: 1,\n shoe: 19,\n points: 26,\n rebounds: 12,\n assists: 6,\n steals: 3,\n blocks: 8,\n slam_dunks: 5\n },\n \"Jason Terry\" => {\n number: 31,\n shoe: 15,\n points: 19,\n rebounds: 2,\n assists: 2,\n steals: 4,\n blocks: 11,\n slam_dunks: 1\n }\n }\n },\n :away => {\n team_name: \"Charlotte Hornets\",\n colors: [\"Turquoise\", \"Purple\"],\n :players => {\n \"Jeff Adrien\" => {\n number: 4,\n shoe: 18,\n points: 10,\n rebounds: 1,\n assists: 1,\n steals: 2,\n blocks: 7,\n slam_dunks: 2\n },\n \"Bismak Biyombo\" => {\n number: 0,\n shoe: 16,\n points: 12,\n rebounds: 4,\n assists: 7,\n steals: 7,\n blocks: 15,\n slam_dunks: 10\n },\n \"DeSagna Diop\" => {\n number: 2,\n shoe: 14,\n points: 24,\n rebounds: 12,\n assists: 12,\n steals: 4,\n blocks: 5,\n slam_dunks: 5\n },\n \"Ben Gordon\" => {\n number: 8,\n shoe: 15,\n points: 33,\n rebounds: 3,\n assists: 2,\n steals: 1,\n blocks: 1,\n slam_dunks: 0\n },\n \"Brendan Haywood\" => {\n number: 33,\n shoe: 15,\n points: 6,\n rebounds: 12,\n assists: 12,\n steals: 22,\n blocks: 5,\n slam_dunks: 12\n }\n }\n }\n }\nend", "def winning_team\n final_scores = player_collection.reduce(home: 0, away: 0) { |teams_points, next_player|\n case \n when next_player[:location] === :away\n teams_points[:away] += next_player[:points];\n when next_player[:location] === :home\n teams_points[:home] += next_player[:points];\n end\n teams_points; \n }\n winner = final_scores.reduce { |highest_points, team_points| \n highest_points[1] > team_points[1] ? highest_points : team_points; \n }\n game_hash[winner[0]][:team_name]; \nend", "def winner_comb\n $the_win_comb = { flash_straight: flash_straight, for_of_kind: four_of_kind, full_house: full_house,\n flush: flush, straight: straight, three: three, two_pair: two_pair,\n one_pair: one_pair, high_card: high_card }\n end", "def game_hash\n hash = {\n :home => {\n :team_name => \"Brooklyn Nets\",\n :colors => [\"Black\",\"White\"],\n :players => {\n \"Alan Anderson\": {\n :number => 0,\n :shoe => 16,\n :points => 22,\n :rebounds => 12,\n :assists => 12,\n :steals => 3,\n :blocks => 1,\n :slam_dunks => 1\n },\n \"Reggie Evans\": {\n :number => 30,\n :shoe => 14,\n :points => 12,\n :rebounds => 12,\n :assists => 12,\n :steals => 12,\n :blocks => 12,\n :slam_dunks => 7\n },\n \"Brook Lopez\": {\n :number => 11,\n :shoe => 17,\n :points => 17,\n :rebounds => 19,\n :assists => 10,\n :steals => 3,\n :blocks => 1,\n :slam_dunks => 15\n },\n \"Mason Plumlee\": {\n :number => 1,\n :shoe => 19,\n :points => 26,\n :rebounds => 12,\n :assists => 6,\n :steals => 3,\n :blocks => 8,\n :slam_dunks => 5\n },\n \"Jason Terry\": {\n :number => 31,\n :shoe => 15,\n :points => 19,\n :rebounds => 2,\n :assists => 2,\n :steals => 4,\n :blocks => 11,\n :slam_dunks => 1\n }\n }\n },\n :away => {\n :team_name => \"Charlotte Hornets\",\n :colors => [\"Turquoise\",\"Purple\"],\n :players => {\n \"Jeff Adrien\": {\n :number => 4,\n :shoe => 18,\n :points => 10,\n :rebounds => 1,\n :assists => 1,\n :steals => 2,\n :blocks => 7,\n :slam_dunks => 2\n },\n \"Bismak Biyombo\": {\n :number => 0,\n :shoe => 16,\n :points => 12,\n :rebounds => 4,\n :assists => 7,\n :steals => 7,\n :blocks => 15,\n :slam_dunks => 10\n },\n \"DeSagna Diop\": {\n :number => 2,\n :shoe => 14,\n :points => 24,\n :rebounds => 12,\n :assists => 12,\n :steals => 4,\n :blocks => 5,\n :slam_dunks => 5\n },\n \"Ben Gordon\": {\n :number => 8,\n :shoe => 15,\n :points => 33,\n :rebounds => 3,\n :assists => 2,\n :steals => 1,\n :blocks => 1,\n :slam_dunks => 0\n },\n \"Brendan Haywood\": {\n :number => 33,\n :shoe => 15,\n :points => 6,\n :rebounds => 12,\n :assists => 12,\n :steals => 22,\n :blocks => 5,\n :slam_dunks => 12\n }\n }\n }\n }\nend", "def game_hash\n hash = {\n :home => {\n :team_name => \"Brooklyn Nets\",\n :colors => [\"Black\", \"White\"],\n :players => {\n \"Alan Anderson\" => {\n :number => 0,\n :shoe => 16,\n :points => 22,\n :rebounds => 12,\n :assists => 12,\n :steals => 3,\n :blocks => 1,\n :slam_dunks => 1\n },\n \"Reggie Evans\" => {\n :number => 30,\n :shoe => 14,\n :points => 12,\n :rebounds => 12,\n :assists => 12,\n :steals => 12,\n :blocks => 12,\n :slam_dunks => 7\n },\n \"Brook Lopez\" => {\n :number => 11,\n :shoe => 17,\n :points => 17,\n :rebounds => 19,\n :assists => 10,\n :steals => 3,\n :blocks => 1,\n :slam_dunks => 15\n },\n \"Mason Plumlee\" => {\n :number => 1,\n :shoe => 19,\n :points => 26,\n :rebounds => 11,\n :assists => 6,\n :steals => 3,\n :blocks => 8,\n :slam_dunks => 5\n },\n \"Jason Terry\" => {\n :number => 31,\n :shoe => 15,\n :points => 19,\n :rebounds => 2,\n :assists => 2,\n :steals => 4,\n :blocks => 11,\n :slam_dunks => 1\n }\n }\n },\n :away => {\n :team_name => \"Charlotte Hornets\",\n :colors => [\"Turquoise\", \"Purple\"],\n :players => {\n \"Jeff Adrien\" => {\n :number => 4,\n :shoe => 18,\n :points => 10,\n :rebounds => 1,\n :assists => 1,\n :steals => 2,\n :blocks => 7,\n :slam_dunks => 2\n },\n \"Bismack Biyombo\" => {\n :number => 0,\n :shoe => 16,\n :points => 12,\n :rebounds => 4,\n :assists => 7,\n :steals => 22,\n :blocks => 15,\n :slam_dunks => 10\n },\n \"DeSagna Diop\" => {\n :number => 2,\n :shoe => 14,\n :points => 24,\n :rebounds => 12,\n :assists => 12,\n :steals => 4,\n :blocks => 5,\n :slam_dunks => 5\n },\n \"Ben Gordon\" => {\n :number => 8,\n :shoe => 15,\n :points => 33,\n :rebounds => 3,\n :assists => 2,\n :steals => 1,\n :blocks => 1,\n :slam_dunks => 0\n },\n \"Kemba Walker\" => {\n :number => 33,\n :shoe => 15,\n :points => 6,\n :rebounds => 12,\n :assists => 12,\n :steals => 7,\n :blocks => 5,\n :slam_dunks => 12\n }\n }\n }\n }\nend", "def game_hash\n {\n :home => {\n :team_name => \"Brooklyn Nets\",\n :colors => [\"Black\", \"White\"],\n :players => {\n \"Alan Anderson\" => {:number => 0, :shoe => 16, :points => 22, :rebounds => 12, :assists => 12, :steals => 3, :blocks => 1, :slam_dunks => 1},\n \"Reggie Evans\" => {:number => 30, :shoe => 14, :points => 12, :rebounds => 12, :assists => 12, :steals => 12, :blocks => 12, :slam_dunks => 7},\n \"Brook Lopez\" => {:number => 11, :shoe => 17, :points => 17, :rebounds => 19, :assists => 10, :steals => 3, :blocks => 1, :slam_dunks => 15},\n \"Mason Plumlee\" => {:number => 1, :shoe => 19, :points => 26, :rebounds => 12, :assists => 6, :steals => 3, :blocks => 8, :slam_dunks => 5},\n \"Jason Terry\" => {:number => 31, :shoe => 15, :points => 19, :rebounds => 2, :assists => 2, :steals => 4, :blocks => 11, :slam_dunks => 1}\n }\n },\n\n :away => {\n :team_name => \"Charlotte Hornets\",\n :colors => [\"Turquoise\", \"Purple\"],\n :players => {\n \"Jeff Adrien\" => {:number => 4, :shoe => 18, :points => 10, :rebounds => 1, :assists => 1, :steals => 2, :blocks => 7, :slam_dunks => 2},\n \"Bismak Biyombo\" => {:number => 0, :shoe => 16, :points => 12, :rebounds => 4, :assists => 7, :steals => 7, :blocks => 15, :slam_dunks => 10},\n \"DeSagna Diop\" => {:number => 2, :shoe => 14, :points => 24, :rebounds => 12, :assists => 12, :steals => 4, :blocks => 5, :slam_dunks => 5},\n \"Ben Gordon\" => {:number => 8, :shoe => 15, :points => 33, :rebounds => 3, :assists => 2, :steals => 1, :blocks => 1, :slam_dunks => 0},\n \"Brendan Haywood\" => {:number => 33, :shoe => 15, :points => 6, :rebounds => 12, :assists => 12, :steals => 22, :blocks => 5, :slam_dunks => 12}\n }\n }\n }\n\nend", "def game_hash \n hash = {:home => {\n :team_name => \"Brooklyn Nets\",\n :colors => [\"Black\", \"White\"],\n :players => {\n \"Alan Anderson\" => {\n :number => 0,\n :shoe => 16,\n :points => 22,\n :rebounds => 12,\n :assists => 12,\n :steals => 3,\n :blocks => 1,\n :slam_dunks => 1\n },\n \"Reggie Evans\" => {\n :number => 30,\n :shoe => 14,\n :points => 12,\n :rebounds => 12,\n :assists => 12,\n :steals => 12,\n :blocks => 12,\n :slam_dunks => 7\n },\n \"Brook Lopez\" => {\n :number => 11,\n :shoe => 17,\n :points => 17,\n :rebounds => 19,\n :assists => 10,\n :steals => 3,\n :blocks => 1,\n :slam_dunks => 15\n },\n \"Mason Plumlee\" => {\n :number => 1,\n :shoe => 19,\n :points => 26,\n :rebounds => 11,\n :assists => 6,\n :steals => 3,\n :blocks => 8,\n :slam_dunks => 5\n },\n \"Jason Terry\" => {\n :number => 31,\n :shoe => 15,\n :points => 19,\n :rebounds => 2,\n :assists => 2,\n :steals => 4,\n :blocks => 11,\n :slam_dunks => 1\n }\n }\n },\n :away => {:team_name => \"Charlotte Hornets\",\n :colors => [\"Turquoise\", \"Purple\"],\n :players => {\n \"Jeff Adrien\" => {\n :number => 4,\n :shoe => 18,\n :points => 10,\n :rebounds => 1,\n :assists => 1,\n :steals => 2,\n :blocks => 7,\n :slam_dunks => 2\n },\n \"Bismack Biyombo\" => {\n :number => 0,\n :shoe => 16,\n :points => 12,\n :rebounds => 4,\n :assists => 7,\n :steals => 22,\n :blocks => 15,\n :slam_dunks => 10\n },\n \"DeSagna Diop\" => {\n :number => 2,\n :shoe => 14,\n :points => 24,\n :rebounds => 12,\n :assists => 12,\n :steals => 4,\n :blocks => 5,\n :slam_dunks => 5\n },\n \"Ben Gordon\" => {\n :number => 8,\n :shoe => 15,\n :points => 33,\n :rebounds => 3,\n :assists => 2,\n :steals => 1,\n :blocks => 1,\n :slam_dunks => 0\n },\n \"Kemba Walker\" => {\n :number => 33,\n :shoe => 15,\n :points => 6,\n :rebounds => 12,\n :assists => 12,\n :steals => 7,\n :blocks => 5,\n :slam_dunks => 12\n }\n }\n }\n }\n \nend", "def game_hash\n #binding.pry\n hash = Hash.new\n hash[:home] = {:team_name => \"Brooklyn Nets\", :colors => [\"Black\", \"White\"], :players => {\"Alan Anderson\" =>\n {:number => 0, :shoe => 16, :points => 22, :rebounds => 12, :assists => 12, :steals => 3, :blocks => 1, :slam_dunks => 1}, \"Reggie Evans\" => {:number => 30, :shoe => 14, :points => 12, :rebounds => 12, :assists => 12, :steals => 12, :blocks => 12, :slam_dunks => 7}, \"Brook Lopez\" => {:number => 11, :shoe => 17, :points => 17, :rebounds => 19, :assists => 10, :steals => 3, :blocks => 1, :slam_dunks => 15}, \"Mason Plumlee\" => {:number => 1, :shoe => 19, :points => 26, :rebounds => 12, :assists => 6, :steals => 3, :blocks => 8, :slam_dunks => 5}, \"Jason Terry\" => {:number => 31, :shoe => 15, :points => 19, :rebounds => 2, :assists => 2, :steals => 4, :blocks => 11, :slam_dunks => 1}}}\n hash[:away] = {\n :team_name => \"Charlotte Hornets\",\n :colors => [\"Turquoise\", \"Purple\"],\n :players => {\n \"Jeff Adrien\" => {\n :number => 4,\n :shoe =>18,\n :points => 10,\n :rebounds => 1,\n :assists => 1,\n :steals => 2,\n :blocks => 7,\n :slam_dunks => 2\n },\n \"Bismak Biyombo\" => {\n :number => 0,\n :shoe => 16,\n :points => 12,\n :rebounds => 4,\n :assists => 7,\n :steals => 7,\n :blocks => 15,\n :slam_dunks => 10\n \n },\n \"DeSagna Diop\" => {\n :number => 2,\n :shoe => 14, :points => 24, :rebounds => 12, :assists => 12, :steals => 4, :blocks => 5, :slam_dunks => 5},\n \"Ben Gordon\" => {:number => 8, :shoe => 15, :points => 33, :rebounds => 3, :assists => 2, :steals => 1, :blocks => 1, :slam_dunks => 0 },\n \"Brendan Haywood\" => {:number => 33, :shoe => 15, :points => 6, :rebounds => 12, :assists => 12, :steals => 22, :blocks => 5, :slam_dunks => 12}}}\n hash\nend", "def load_stats\n[\n {\n home_team: \"Jets\",\n away_team: \"Giants\",\n home_score: 21,\n away_score: 3\n },\n {\n home_team: \"Steelers\",\n away_team: \"Giants\",\n home_score: 21,\n away_score: 3\n },\n {\n home_team: \"Patriots\",\n away_team: \"Giants\",\n home_score: 21,\n away_score: 3\n },\n {\n home_team: \"Chargers\",\n away_team: \"Jets\",\n home_score: 13,\n away_score: 6\n },\n {\n home_team: \"Patriots\",\n away_team: \"Jets\",\n home_score: 13,\n away_score: 6\n },\n {\n home_team: \"Steelers\",\n away_team: \"Jets\",\n home_score: 3,\n away_score: 6\n },\n {\n home_team: \"Dolphins\",\n away_team: \"Jets\",\n home_score: 0,\n away_score: 3\n },\n{\n home_team: \"Browns\",\n away_team: \"Jets\",\n home_score: 0,\n away_score: 21\n },\n {\n home_team: \"Chargers\",\n away_team: \"Jets\",\n home_score: 7,\n away_score: 21\n },\n {\n home_team: \"Steelers\",\n away_team: \"Broncos\",\n home_score: 7,\n away_score: 13\n },\n {\n home_team: \"Patriots\",\n away_team: \"Broncos\",\n home_score: 7,\n away_score: 3\n },\n {\n home_team: \"Broncos\",\n away_team: \"Colts\",\n home_score: 3,\n away_score: 0\n },\n {\n home_team: \"Patriots\",\n away_team: \"Colts\",\n home_score: 11,\n away_score: 7\n },\n {\n home_team: \"Steelers\",\n away_team: \"Patriots\",\n home_score: 7,\n away_score: 21\n },\n {\n home_team: \"Steelers\",\n away_team: \"Colts\",\n home_score: 24,\n away_score: 21\n },\n {\n home_team: \"Steelers\",\n away_team: \"Colts\",\n home_score: 24,\n away_score: 21\n }\n]\nend", "def game_hash\n hash = {\n :home => {\n :team_name => \"Brooklyn Nets\",\n :colors => [\"Black\", \"White\"],\n :players => [\n {\n :player_name => \"Alan Anderson\",\n :number => 0,\n :shoe => 16,\n :points => 22,\n :rebounds => 12,\n :assists => 12,\n :steals => 3,\n :blocks => 1,\n :slam_dunks => 1\n },\n {\n :player_name => \"Reggie Evans\",\n :number => 30,\n :shoe => 14,\n :points => 12,\n :rebounds => 12,\n :assists => 12,\n :steals => 12,\n :blocks => 12,\n :slam_dunks => 7\n },\n {\n :player_name => \"Brook Lopez\",\n :number => 11,\n :shoe => 17,\n :points => 17,\n :rebounds => 19,\n :assists => 10,\n :steals => 3,\n :blocks => 1,\n :slam_dunks => 15\n },\n {\n :player_name => \"Mason Plumlee\",\n :number => 1,\n :shoe => 19,\n :points => 26,\n :rebounds => 11,\n :assists => 6,\n :steals => 3,\n :blocks => 8,\n :slam_dunks => 5\n },\n {\n :player_name => \"Jason Terry\",\n :number => 31,\n :shoe => 15,\n :points => 19,\n :rebounds => 2,\n :assists => 2,\n :steals => 4,\n :blocks => 11,\n :slam_dunks => 1\n }\n ]\n },\n :away => {\n :team_name => \"Charlotte Hornets\",\n :colors => [\"Turquoise\", \"Purple\"],\n :players => [\n {\n :player_name => \"Jeff Adrien\",\n :number => 4,\n :shoe => 18,\n :points => 10,\n :rebounds => 1,\n :assists => 1,\n :steals => 2,\n :blocks => 7,\n :slam_dunks => 2\n },\n {\n :player_name => \"Bismack Biyombo\",\n :number => 0,\n :shoe => 16,\n :points => 12,\n :rebounds => 4,\n :assists => 7,\n :steals => 22,\n :blocks => 15,\n :slam_dunks => 10\n },\n {\n :player_name => \"DeSagna Diop\",\n :number => 2,\n :shoe => 14,\n :points => 24,\n :rebounds => 12,\n :assists => 12,\n :steals => 4,\n :blocks => 5,\n :slam_dunks => 5\n },\n {\n :player_name => \"Ben Gordon\",\n :number => 8,\n :shoe => 15,\n :points => 33,\n :rebounds => 3,\n :assists => 2,\n :steals => 1,\n :blocks => 1,\n :slam_dunks => 0\n },\n {\n :player_name => \"Kemba Walker\",\n :number => 33,\n :shoe => 15,\n :points => 6,\n :rebounds => 12,\n :assists => 12,\n :steals => 7,\n :blocks => 5,\n :slam_dunks => 12\n }\n ]\n }\n }\n hash\nend", "def game_hash \n {\n :home => {:team_name =>\"Brooklyn Nets\", :colors =>[\"Black\", \"White\"],:players =>[\n \n {:player_name => \"Alan Anderson\", :number => 0,:shoe => 16, :points => 22, :rebounds => 12, :assists => 12, :steals => 3, :blocks => 1, :slam_dunks => 1},\n \n {:player_name => \"Reggie Evans\", :number => 30,:shoe => 14, :points => 12, :rebounds => 12, :assists => 12, :steals => 12, :blocks => 12, :slam_dunks => 7},\n \n {:player_name => \"Brook Lopez\", :number => 11, :shoe => 17, :points => 17, :rebounds => 19, :assists => 10, :steals => 3, :blocks => 1, :slam_dunks => 15}, \n \n {:player_name => \"Mason Plumlee\", :number => 1, :shoe => 19, :points => 26, :rebounds => 11, :assists =>6, :steals =>3, :blocks => 8, :slam_dunks => 5},\n \n {:player_name => \"Jason Terry\", :number =>31 , :shoe =>15, :points =>19, :rebounds => 2, :assists =>2, :steals =>4, :blocks =>11, :slam_dunks =>1}]},\n \n \n \n :away => {:team_name =>\"Charlotte Hornets\", :colors => [\"Turquoise\", \"Purple\"], :players => [\n {:player_name => \"Jeff Adrien\", :number => 4, :shoe => 18, :points => 10, :rebounds => 1, :assists => 1, :steals => 2, :blocks => 7, :slam_dunks => 2 }, {:player_name => \"Bismack Biyombo\", :number => 0,:shoe => 16, :points => 12, :rebounds => 4, :assists => 7, :steals => 22, :blocks => 15, :slam_dunks => 10},{:player_name => \"DeSagna Diop\", :number => 2, :shoe => 14, :points => 24, :rebounds => 12, :assists => 12, :steals => 4, :blocks => 5, :slam_dunks => 5},{:player_name => \"Ben Gordon\", :number => 8, :shoe => 15, :points => 33, :rebounds => 3, :assists =>2, :steals =>1, :blocks => 1, :slam_dunks => 0},{:player_name => \"Kemba Walker\", :number =>33 , :shoe =>15, :points =>6, :rebounds => 12, :assists =>12, :steals =>7, :blocks =>5, :slam_dunks =>12\n }]}}\n \nend", "def update_score\n games = Hash.new([])\n predictions.each do |prediction|\n key = prediction.match_id\n games[key] = {}\n games[key][:teams] = []\n games[key][:round] = prediction.round_id\n unless prediction.winner.nil?\n games[key][:teams] << prediction.winner.id\n end\n end\n Game.includes(:team1, :team2).find_each do |game|\n key = game.match_id\n unless game.winner.nil?\n games[key][:teams] << game.winner.id\n end\n end\n\n puts games.inspect\n\n score = 0\n games.each do |key, data|\n round = games[key][:round]\n winners = games[key][:teams]\n if winners.length == 2 and winners.first == winners.last\n score += (2 ** (round))\n end\n end\n self.update_attributes :score => score\n end", "def game_hash\n{\n\t:home => {\n\t\t:team_name => \"Brooklyn Nets\",\n\t\t:colors => [\"Black\", \"White\"],\n\t\t:players => {\n\t\t\t\"Alan Anderson\" => {\n\t\t\t\t:number => 0,\n\t\t\t\t:shoe => 16,\n\t\t\t\t:points => 22,\n\t\t\t\t:rebounds => 12,\n\t\t\t\t:assists => 12,\n\t\t\t\t:steals => 3,\n\t\t\t\t:blocks => 1,\n\t\t\t\t:slam_dunks => 1\n\t\t\t},\n\t\t\t\"Reggie Evans\" => {\n\t\t\t\t:number => 30,\n\t\t\t\t:shoe => 14,\n\t\t\t\t:points => 12,\n\t\t\t\t:rebounds => 12,\n\t\t\t\t:assists => 12,\n\t\t\t\t:steals => 12,\n\t\t\t\t:blocks => 12,\n\t\t\t\t:slam_dunks => 7\n\t\t\t},\n\t\t\t\"Brook Lopez\" => {\n\t\t\t\t:number => 11,\n\t\t\t\t:shoe => 17,\n\t\t\t\t:points => 17,\n\t\t\t\t:rebounds => 19,\n\t\t\t\t:assists => 10,\n\t\t\t\t:steals => 3,\n\t\t\t\t:blocks => 1,\n\t\t\t\t:slam_dunks => 15\n\t\t\t},\n\t\t\t\"Mason Plumlee\" => {\n\t\t\t\t:number => 1,\n\t\t\t\t:shoe => 19,\n\t\t\t\t:points => 26,\n\t\t\t\t:rebounds => 12,\n\t\t\t\t:assists => 6,\n\t\t\t\t:steals => 3,\n\t\t\t\t:blocks => 8,\n\t\t\t\t:slam_dunks => 5\n\t\t\t},\n\t\t\t\"Jason Terry\" => {\n\t\t\t\t:number => 31,\n\t\t\t\t:shoe => 15,\n\t\t\t\t:points => 19,\n\t\t\t\t:rebounds => 2,\n\t\t\t\t:assists => 2,\n\t\t\t\t:steals => 4,\n\t\t\t\t:blocks => 11,\n\t\t\t\t:slam_dunks => 1\n\t\t\t}\n\t\t}\n\t},\n\t:away => {\n\t\t:team_name => \"Charlotte Hornets\",\n\t\t:colors => [\"Turquoise\", \"Purple\"],\n\t\t:players => {\n\t\t\t\"Jeff Adrien\" => {\n\t\t\t\t:number => 4,\n\t\t\t\t:shoe => 18,\n\t\t\t\t:points => 10,\n\t\t\t\t:rebounds => 1,\n\t\t\t\t:assists => 1,\n\t\t\t\t:steals => 2,\n\t\t\t\t:blocks => 7,\n\t\t\t\t:slam_dunks => 2\n\t\t\t},\n\t\t\t\"Bismack Biyombo\" => {\n\t\t\t\t:number => 0,\n\t\t\t\t:shoe => 16,\n\t\t\t\t:points => 12,\n\t\t\t\t:rebounds => 4,\n\t\t\t\t:assists => 7,\n\t\t\t\t:steals => 7,\n\t\t\t\t:blocks => 15,\n\t\t\t\t:slam_dunks => 10\n\t\t\t},\n\t\t\t\"DeSagna Diop\" => {\n\t\t\t\t:number => 2,\n\t\t\t\t:shoe => 14,\n\t\t\t\t:points => 24,\n\t\t\t\t:rebounds => 12,\n\t\t\t\t:assists => 12,\n\t\t\t\t:steals => 4,\n\t\t\t\t:blocks => 5,\n\t\t\t\t:slam_dunks => 5\n\t\t\t},\n\t\t\t\"Ben Gordon\" => {\n\t\t\t\t:number => 8,\n\t\t\t\t:shoe => 15,\n\t\t\t\t:points => 33,\n\t\t\t\t:rebounds => 3,\n\t\t\t\t:assists => 2,\n\t\t\t\t:steals => 1,\n\t\t\t\t:blocks => 1,\n\t\t\t\t:slam_dunks => 0\n\t\t\t},\n\t\t\t\"Brendan Haywood\" => {\n\t\t\t\t:number => 33,\n\t\t\t\t:shoe => 15,\n\t\t\t\t:points => 6,\n\t\t\t\t:rebounds => 12,\n\t\t\t\t:assists => 12,\n\t\t\t\t:steals => 22,\n\t\t\t\t:blocks => 5,\n\t\t\t\t:slam_dunks => 12\n\t\t\t}\n\t\t}\n\t}\n}\nend", "def game_hash\n hash = {\n home: {\n team_name: \"Brooklyn Nets\" ,\n colors: ['Black', 'White'],\n players: {\n \"Alan Anderson\" => {\n :number => 0,\n :shoe => 16,\n :points => 22,\n :rebounds => 12,\n :assists => 12,\n :steals => 3,\n :blocks => 1,\n :slam_dunks => 1\n },\n \"Reggie Evans\" => {\n :number => 30,\n :shoe => 14,\n :points => 12,\n :rebounds => 12,\n :assists => 12,\n :steals => 12,\n :blocks => 12,\n :slam_dunks => 7\n },\n \"Brook Lopez\" => {\n number: 11,\n shoe: 17,\n points: 17,\n rebounds: 19,\n assists: 10,\n steals: 3,\n blocks: 1,\n slam_dunks: 15\n },\n \"Mason Plumlee\" => {\n number: 1,\n shoe: 19,\n points: 26,\n rebounds: 12,\n assists: 6,\n steals: 3,\n blocks: 8,\n slam_dunks: 5\n },\n \"Jason Terry\" => {\n number: 31,\n shoe: 15,\n points: 19,\n rebounds: 2,\n assists: 2,\n steals: 4,\n blocks: 11,\n slam_dunks: 1\n }\n }\n },\n\n away: {\n team_name: \"Charlotte Hornets\" ,\n colors: [\"Turquoise\", \"Purple\"],\n players: {\n \"Jeff Adrien\" => {\n number: 4,\n shoe: 18,\n points: 10,\n rebounds: 1,\n assists: 1,\n steals: 2,\n blocks: 7,\n slam_dunks: 2\n },\n \"Bismak Biyombo\" => {\n number: 0,\n shoe: 16,\n points: 12,\n rebounds: 4,\n assists: 7,\n steals: 7,\n blocks: 15,\n slam_dunks: 10\n },\n \"DeSagna Diop\" => {\n number: 2,\n shoe: 14,\n points: 24,\n rebounds: 12,\n assists: 12,\n steals: 4,\n blocks: 5,\n slam_dunks: 5\n },\n \"Ben Gordon\" => {\n number: 8,\n shoe: 15,\n points: 33,\n rebounds: 3,\n assists: 2,\n steals: 1,\n blocks: 1,\n slam_dunks: 0\n },\n \"Brendan Haywood\" => {\n number: 33,\n shoe: 15,\n points: 6,\n rebounds: 12,\n assists: 12,\n steals: 22,\n blocks: 5,\n slam_dunks: 12\n }\n }\n }\n}\nend", "def buildTeamToStandingsMap(year)\n teamToStandingsMap = {}\n\n MlbStanding.where(year: year).each do |mlbStanding|\n teamToStandingsMap[mlbStanding.mlb_team_id] = mlbStanding\n end\n return teamToStandingsMap\n end", "def game_hash\n game_hash = {\n :home => {\n :team_name =>\"Brooklyn Nets\",\n :colors => [\"Black\", \"White\"],\n :players => [\n {\n :player_name => \"Alan Anderson\",\n :number => 0,\n :shoe => 16,\n :points => 22,\n :rebounds => 12,\n :assists => 12,\n :steals => 3,\n :blocks => 1,\n :slam_dunks => 1 \n },\n {\n :player_name => \"Reggie Evans\",\n :number => 30,\n :shoe => 14,\n :points => 12,\n :rebounds => 12,\n :assists => 12,\n :steals => 12,\n :blocks => 12,\n :slam_dunks => 7 \n },\n {\n :player_name => \"Brook Lopez\",\n :number => 11,\n :shoe => 17,\n :points => 17,\n :rebounds => 19,\n :assists => 10,\n :steals => 3,\n :blocks => 1,\n :slam_dunks => 15 \n },\n {\n :player_name => \"Mason Plumlee\",\n :number => 1,\n :shoe => 19,\n :points => 26,\n :rebounds => 11,\n :assists => 6,\n :steals => 3,\n :blocks => 8,\n :slam_dunks => 5\n },\n {\n :player_name => \"Jason Terry\",\n :number => 31,\n :shoe => 15,\n :points => 19,\n :rebounds => 2,\n :assists => 2,\n :steals => 4,\n :blocks => 11,\n :slam_dunks => 1 \n }\n ]\n }, \n :away => {\n :team_name =>\"Charlotte Hornets\",\n :colors => [\"Turquoise\", \"Purple\"],\n :players => [\n {\n :player_name => \"Jeff Adrien\",\n :number => 4,\n :shoe => 18,\n :points => 10,\n :rebounds => 1,\n :assists => 1,\n :steals => 2,\n :blocks => 7,\n :slam_dunks => 2 \n },\n {\n :player_name => \"Bismack Biyombo\",\n :number => 0,\n :shoe => 16,\n :points => 12,\n :rebounds => 4,\n :assists => 7,\n :steals => 22,\n :blocks => 15,\n :slam_dunks => 10 \n },\n {\n :player_name => \"DeSagna Diop\",\n :number => 2,\n :shoe => 14,\n :points => 24,\n :rebounds => 12,\n :assists => 12,\n :steals => 4,\n :blocks => 5,\n :slam_dunks => 5\n },\n {\n :player_name => \"Ben Gordon\",\n :number => 8,\n :shoe => 15,\n :points => 33,\n :rebounds => 3,\n :assists => 2,\n :steals => 1,\n :blocks => 1,\n :slam_dunks => 0 \n },\n {\n :player_name => \"Kemba Walker\",\n :number => 33,\n :shoe => 15,\n :points => 6,\n :rebounds => 12,\n :assists => 12,\n :steals => 7,\n :blocks => 5,\n :slam_dunks => 12 \n }\n ]\n }\n }\n game_hash\nend", "def game_hash\n game_hash = {\n :home => {\n :team_name => \"Brooklyn Nets\",\n :colors => [\"Black\",\"White\"],\n :players => [\n {:player_name => \"Alan Anderson\",\n :number => 0,\n :shoe => 16,\n :points => 22,\n :rebounds => 12,\n :assists => 12,\n :steals => 3,\n :blocks => 1,\n :slam_dunks => 1 \n },\n {\n :player_name => \"Reggie Evans\",\n :number => 30,\n :shoe => 14,\n :points => 12,\n :rebounds => 12,\n :assists => 12,\n :steals => 12,\n :blocks => 12,\n :slam_dunks => 7\n },\n {\n :player_name => \"Brook Lopez\",\n :number => 11,\n :shoe => 17,\n :points => 17,\n :rebounds => 19,\n :assists => 10,\n :steals => 3,\n :blocks => 1,\n :slam_dunks => 15\n },\n {\n :player_name => \"Mason Plumlee\",\n :number => 1,\n :shoe => 19,\n :points => 26,\n :rebounds => 11,\n :assists => 6,\n :steals => 3,\n :blocks => 8,\n :slam_dunks => 5 \n },\n {\n :player_name => \"Jason Terry\",\n :number => 31,\n :shoe => 15,\n :points => 19,\n :rebounds => 2,\n :assists => 2,\n :steals => 4,\n :blocks => 11,\n :slam_dunks => 1 \n }\n ]\n },\n :away => {\n :team_name => \"Charlotte Hornets\",\n :colors => [\"Turquoise\", \"Purple\" ],\n :players => [\n {:player_name => \"Jeff Adrien\",\n :number => 4,\n :shoe => 18,\n :points => 10,\n :rebounds => 1,\n :assists => 1,\n :steals => 2,\n :blocks => 7,\n :slam_dunks => 2 \n },\n {\n :player_name => \"Bismack Biyombo\",\n :number => 0,\n :shoe => 16,\n :points => 12,\n :rebounds => 4,\n :assists => 7,\n :steals => 22,\n :blocks => 15,\n :slam_dunks => 10\n },\n {\n :player_name => \"DeSagna Diop\",\n :number => 2,\n :shoe => 14,\n :points => 24,\n :rebounds => 12,\n :assists => 12,\n :steals => 4,\n :blocks => 5,\n :slam_dunks => 5\n },\n {\n :player_name => \"Ben Gordon\",\n :number => 8,\n :shoe => 15,\n :points => 33,\n :rebounds => 3,\n :assists => 2,\n :steals => 1,\n :blocks => 1,\n :slam_dunks => 0\n },\n {\n :player_name => \"Kemba Walker\",\n :number => 33,\n :shoe => 15,\n :points => 6,\n :rebounds => 12,\n :assists => 12,\n :steals => 7,\n :blocks => 5,\n :slam_dunks => 12 \n }\n ]\n }\n }\n game_hash\nend", "def determine_winner game\n winner = game.max_by {|team| team[:score]}\n team_standings = get_team_by_name(winner)\n team_standings[:winnings] += 3\nend", "def winning_team\n home_score = 0\n away_score = 0\n game_hash[:home][:players].keys.each do |name|\n home_score += game_hash[:home][:players][name][:points]\n end\n game_hash[:away][:players].keys.each do |name|\n away_score += game_hash[:away][:players][name][:points]\n end\n home_score > away_score ? game_hash[:home][:team_name] : game_hash[:away][:team_name]\nend", "def game_hash\n{\n :home => {\n :team_name => \"Brooklyn Nets\",\n :colors => [\"Black\", \"White\"],\n :players => [\n {\n :player_name => \"Alan Anderson\",\n :number => 0,\n :shoe => 16,\n :points => 22,\n :rebounds => 12,\n :assists => 12,\n :steals => 3,\n :blocks => 1,\n :slam_dunks => 1\n },\n {\n :player_name => \"Reggie Evans\",\n :number => 30,\n :shoe => 14,\n :points => 12,\n :rebounds => 12,\n :assists => 12,\n :steals => 12,\n :blocks => 12,\n :slam_dunks => 7\n },\n {\n :player_name => \"Brook Lopez\",\n :number => 11,\n :shoe => 17,\n :points => 17,\n :rebounds => 19,\n :assists => 10,\n :steals => 3,\n :blocks => 1,\n :slam_dunks => 15\n },\n {\n :player_name => \"Mason Plumlee\",\n :number => 1,\n :shoe => 19,\n :points => 26,\n :rebounds => 11,\n :assists => 6,\n :steals => 3,\n :blocks => 8,\n :slam_dunks => 5\n },\n {\n :player_name => \"Jason Terry\",\n :number => 31,\n :shoe => 15,\n :points => 19,\n :rebounds => 2,\n :assists => 2,\n :steals => 4,\n :blocks => 11,\n :slam_dunks => 1\n }\n ]\n },\n :away => {\n :team_name => \"Charlotte Hornets\",\n :colors => [\"Turquoise\", \"Purple\"],\n :players => [\n {\n :player_name => \"Jeff Adrien\",\n :number => 4,\n :shoe => 18,\n :points => 10,\n :rebounds => 1,\n :assists => 1,\n :steals => 2,\n :blocks => 7,\n :slam_dunks => 2\n },\n {\n :player_name => \"Bismack Biyombo\",\n :number => 0,\n :shoe => 16,\n :points => 12,\n :rebounds => 4,\n :assists => 7,\n :steals => 22,\n :blocks => 15,\n :slam_dunks => 10\n },\n {\n :player_name => \"DeSagna Diop\",\n :number => 2,\n :shoe => 14,\n :points => 24,\n :rebounds => 12,\n :assists => 12,\n :steals => 4,\n :blocks => 5,\n :slam_dunks => 5\n },\n {\n :player_name => \"Ben Gordon\",\n :number => 8,\n :shoe => 15,\n :points => 33,\n :rebounds => 3,\n :assists => 2,\n :steals => 1,\n :blocks => 1,\n :slam_dunks => 0\n },\n {\n :player_name => \"Kemba Walker\",\n :number => 33,\n :shoe => 15,\n :points => 6,\n :rebounds => 12,\n :assists => 12,\n :steals => 7,\n :blocks => 5,\n :slam_dunks => 12\n }\n ]\n }\n}\nend", "def game_hash\n {\n :home => {\n :team_name=> \"Brooklyn Nets\",\n :colors=> [\"Black\", \"White\"],\n :players=> [\n {\n :name=> \"Alan Anderson\",\n :number=>0,\n :shoe=>16,\n :points=>22,\n :rebounds=>12,\n :assists=>12,\n :steals=>3,\n :blocks=>1,\n :slam_dunks=>1,\n },\n {\n :name=> \"Reggie Evans\",\n :number=>30,\n :shoe=>14,\n :points=>12,\n :rebounds=>12,\n :assists=>12,\n :steals=>12,\n :blocks=>12,\n :slam_dunks=>7,\n },\n {\n :name=> \"Brook Lopez\",\n :number=>11,\n :shoe=>17,\n :points=>17,\n :rebounds=>19,\n :assists=>10,\n :steals=>3,\n :blocks=>1,\n :slam_dunks=>15,\n },\n {\n :name=> \"Mason Plumlee\",\n :number=>1,\n :shoe=>19,\n :points=>26,\n :rebounds=>12,\n :assists=>6,\n :steals=>3,\n :blocks=>8,\n :slam_dunks=>5,\n },\n {\n :name=> \"Jason Terry\",\n :number=>31,\n :shoe=>15,\n :points=>19,\n :rebounds=>2,\n :assists=>2,\n :steals=>4,\n :blocks=>11,\n :slam_dunks=>1,\n },\n ],\n },\n\n :away => {\n :team_name=> \"Charlotte Hornets\",\n :colors=> [\"Turquoise\", \"Purple\"],\n :players=> [\n {\n :name=> \"Jeff Adrien\",\n :number=>4,\n :shoe=>18,\n :points=>10,\n :rebounds=>1,\n :assists=>1,\n :steals=>2,\n :blocks=>7,\n :slam_dunks=>2,\n },\n {\n :name=> \"Bismak Biyombo\",\n :number=>0,\n :shoe=>16,\n :points=>12,\n :rebounds=>4,\n :assists=>7,\n :steals=>7,\n :blocks=>15,\n :slam_dunks=>10,\n },\n {\n :name=> \"DeSagna Diop\",\n :number=>2,\n :shoe=>14,\n :points=>24,\n :rebounds=>12,\n :assists=>12,\n :steals=>4,\n :blocks=>5,\n :slam_dunks=>5,\n },\n {\n :name=> \"Ben Gordon\",\n :number=>8,\n :shoe=>15,\n :points=>33,\n :rebounds=>3,\n :assists=>2,\n :steals=>1,\n :blocks=>1,\n :slam_dunks=>0,\n },\n {\n :name=> \"Brendan Haywood\",\n :number=>33,\n :shoe=>15,\n :points=>6,\n :rebounds=>12,\n :assists=>12,\n :steals=>22,\n :blocks=>5,\n :slam_dunks=>12,\n },\n ],\n }\n}\nend", "def scoring_hash\n pfh = player_fixture_history\n {\n id: id,\n role: role,\n position_id: position_id,\n player_id: player_id,\n status: player.status,\n minutes: pfh.nil? ? 0 : pfh['minutes'],\n points: pfh.nil? ? 0 : pfh['total_points'],\n team_id: player.team_id\n }\n end", "def gross_per_studio(collection)\n new_hash = {}\n counter = 0 \n while counter < collection.length do \n studio_name = collection[counter][:studio]\n ww_gross = collection[counter][:worldwide_gross]\n if !new_hash[studio_name]\n new_hash[studio_name] = ww_gross\n else \n new_hash[studio_name] += ww_gross\n end \n counter += 1 \nend\nreturn new_hash\nend", "def game_hash\n {\n :home => {\n :team_name => \"Brooklyn Nets\",\n :colors => [\"Black\", \"White\"],\n :players => [\n {:player_name => \"Alan Anderson\",\n :number => 0,\n :shoe => 16,\n :points => 22,\n :rebounds => 12,\n :assists => 12,\n :steals => 3,\n :blocks => 1,\n :slam_dunks => 1\n },\n {:player_name => \"Reggie Evans\", \n :number => 30,\n :shoe => 14,\n :points => 12,\n :rebounds => 12,\n :assists => 12,\n :steals => 12,\n :blocks => 12,\n :slam_dunks => 7\n },\n {:player_name => \"Brook Lopez\",\n :number => 11,\n :shoe => 17,\n :points => 17,\n :rebounds => 19,\n :assists => 10,\n :steals => 3,\n :blocks => 1,\n :slam_dunks => 15\n },\n {:player_name => \"Mason Plumlee\",\n :number => 1,\n :shoe => 19,\n :points => 26,\n :rebounds => 11,\n :assists => 6,\n :steals => 3,\n :blocks => 8,\n :slam_dunks => 5\n },\n {:player_name => \"Jason Terry\",\n :number => 31,\n :shoe => 15,\n :points => 19,\n :rebounds => 2,\n :assists => 2,\n :steals => 4,\n :blocks => 11,\n :slam_dunks => 1\n }\n ]\n },\n :away => {\n :team_name => \"Charlotte Hornets\",\n :colors => [\"Turquoise\", \"Purple\"],\n :players => [\n {:player_name => \"Jeff Adrien\",\n :number => 4,\n :shoe => 18,\n :points => 10,\n :rebounds => 1,\n :assists => 1,\n :steals => 2,\n :blocks => 7,\n :slam_dunks => 2\n },\n {:player_name => \"Bismack Biyombo\",\n :number => 0,\n :shoe => 16,\n :points => 12,\n :rebounds => 4,\n :assists => 7,\n :steals => 22,\n :blocks => 15,\n :slam_dunks => 10\n },\n {:player_name => \"DeSagna Diop\",\n :number => 2,\n :shoe => 14,\n :points => 24,\n :rebounds => 12,\n :assists => 12,\n :steals => 4,\n :blocks => 5,\n :slam_dunks => 5\n },\n {:player_name => \"Ben Gordon\",\n :number => 8,\n :shoe => 15,\n :points => 33,\n :rebounds => 3,\n :assists => 2,\n :steals => 1,\n :blocks => 1,\n :slam_dunks => 0\n },\n {:player_name => \"Kemba Walker\",\n :number => 33,\n :shoe => 15,\n :points => 6,\n :rebounds => 12,\n :assists => 12,\n :steals => 7,\n :blocks => 5,\n :slam_dunks => 12\n }\n ]\n }\n }\nend", "def game_hash\n {\n :home => {\n :team_name => \"Brooklyn Nets\",\n :colors => [\"Black\", \"White\"],\n :players => [\n {\n :name => \"Alan Anderson\",\n :number => 0,\n :shoe => 16,\n :points => 22,\n :rebounds => 12,\n :assists => 12,\n :steals => 3,\n :blocks => 1,\n :slam_dunks => 1\n },\n {\n :name => \"Reggie Evans\",\n :number => 30,\n :shoe => 14,\n :points => 12,\n :rebounds => 12,\n :assists => 12,\n :steals => 12,\n :blocks => 12,\n :slam_dunks => 7\n },\n {\n :name => \"Brook Lopez\",\n :number => 11,\n :shoe => 17,\n :points => 17,\n :rebounds => 19,\n :assists => 10,\n :steals => 3,\n :blocks => 1,\n :slam_dunks => 15\n },\n {\n :name => \"Mason Plumlee\",\n :number => 1,\n :shoe => 19,\n :points => 26,\n :rebounds => 11,\n :assists => 6,\n :steals => 3,\n :blocks => 8,\n :slam_dunks => 5\n },\n {\n :name => \"Jason Terry\",\n :number => 31,\n :shoe => 15,\n :points => 19,\n :rebounds => 2,\n :assists => 2,\n :steals => 4,\n :blocks => 11,\n :slam_dunks => 1\n }\n ]\n },\n :away => {\n :team_name => \"Charlotte Hornets\",\n :colors => [\"Turquoise\", \"Purple\"],\n :players => [\n {\n :name => \"Jeff Adrien\",\n :number => 4,\n :shoe => 18,\n :points => 10,\n :rebounds => 1,\n :assists => 1,\n :steals => 2,\n :blocks => 7,\n :slam_dunks => 2\n },\n {\n :name => \"Bismack Biyombo\", \n :number => 0,\n :shoe => 16,\n :points => 12,\n :rebounds => 4,\n :assists => 7,\n :steals => 22,\n :blocks => 15,\n :slam_dunks => 10\n },\n {\n :name => \"DeSagna Diop\", \n :number => 2,\n :shoe => 14,\n :points => 24,\n :rebounds => 12,\n :assists => 12,\n :steals => 4,\n :blocks => 5,\n :slam_dunks => 5\n },\n {\n :name => \"Ben Gordon\",\n :number => 8,\n :shoe => 15,\n :points => 33,\n :rebounds => 3,\n :assists => 2,\n :steals => 1,\n :blocks => 1,\n :slam_dunks => 0\n },\n {\n :name => \"Kemba Walker\",\n :number => 33,\n :shoe => 15,\n :points => 6,\n :rebounds => 12,\n :assists => 12,\n :steals => 7,\n :blocks => 5,\n :slam_dunks => 12\n }\n ]\n }\n}\nend", "def game_hash \n {home: \n {team_name: \"Brooklyn Nets\", colors: [\"Black\", \"White\"], \n players: {:AlanAnderson=> \n {player_name: \"Alan Anderson\", number: \"0\", shoe: \"16\", points: \"22\", \n rebounds: \"12\", assists: \"12\", steals: \"3\", blocks: \"1\", slam_dunks: \"1\"}, \n :ReggieEvans=> {player_name: \"Reggie Evans\", number: \"30\", shoe: \"14\", points: \"12\", \n rebounds: \"12\", assists: \"12\", steals: \"12\", blocks: \"12\", slam_dunks: \"7\"}, \n :BrookLopez=> {player_name: \"Brook Lopez\", number: \"11\", shoe: \"17\", points: \"17\", \n rebounds: \"19\", assists: \"10\", steals: \"3\", blocks: \"1\", slam_dunks: \"15\"},\n :MasonPlumlee=> {player_name: \"Mason Plumlee\", number: \"1\", shoe: \"19\", points: \"26\", \n rebounds: \"12\", assists: \"6\", steals: \"3\", blocks: \"8\", slam_dunks: \"5\"},\n :JasonTerry=> {player_name: \"Jason Terry\", number: \"31\", shoe: \"15\", points: \"19\", \n rebounds: \"2\", assists: \"2\", steals: \"4\", blocks: \"11\", slam_dunks: \"1\"}\n }}, \naway: \n {team_name: \"Charlotte Hornets\", colors: [\"Turquoise\", \"Purple\"], \n players: {:JeffAdrien=> \n {player_name: \"Jeff Adrien\", number: \"4\", shoe: \"18\", points: \"10\", \n rebounds: \"1\", assists: \"1\", steals: \"2\", blocks: \"7\", slam_dunks: \"2\"}, \n :BismakBiyombo=> {player_name: \"Bismak Biyombo\", number: \"0\", shoe: \"16\", points: \"12\", \n rebounds: \"4\", assists: \"7\", steals: \"7\", blocks: \"15\", slam_dunks: \"10\"}, \n :DeSagnaDiop=> {player_name: \"DeSagna Diop\", number: \"2\", shoe: \"14\", points: \"24\", \n rebounds: \"12\", assists: \"12\", steals: \"4\", blocks: \"5\", slam_dunks: \"5\"},\n :BenGordon=> {player_name: \"Ben Gordon\", number: \"8\", shoe: \"15\", points: \"33\", \n rebounds: \"3\", assists: \"2\", steals: \"1\", blocks: \"1\", slam_dunks: \"0\"},\n :BrendanHaywood=> {player_name: \"Brendan Haywood\", number: \"33\", shoe: \"15\", points: \"6\", \n rebounds: \"12\", assists: \"12\", steals: \"22\", blocks: \"5\", slam_dunks: \"12\"}\n }}}\n\nend", "def game_hash\n game = {\n home: {\n team_name: \"Brooklyn Nets\",\n colors:[\"Black\", \"White\"],\n players: {\n \"Alan Anderson\" => {\n number: 0,\n shoe: 16,\n points: 22,\n rebounds: 12,\n assists: 12,\n steals: 3,\n blocks: 1,\n slam_dunks: 1\n },\n\n \"Reggie Evans\" => {\n number: 30,\n shoe: 14,\n points: 12,\n rebounds: 12,\n assists: 12,\n steals: 12,\n blocks: 12,\n slam_dunks: 7\n },\n\n \"Brook Lopez\" => {\n number: 11,\n shoe: 17,\n points: 17,\n rebounds: 19,\n assists: 10,\n steals: 3,\n blocks: 1,\n slam_dunks: 15\n },\n\n \"Mason Plumlee\" => {\n number: 1,\n shoe: 19,\n points: 26,\n rebounds: 12,\n assists: 6,\n steals: 3,\n blocks: 8,\n slam_dunks: 5\n },\n\n \"Jason Terry\" => {\n number: 31,\n shoe: 15,\n points: 19,\n rebounds: 2,\n assists: 2,\n steals: 4,\n blocks: 11,\n slam_dunks: 1\n }\n }\n },\n\n away: {\n team_name:\"Charlotte Hornets\",\n colors:[\"Turquoise\", \"Purple\"] ,\n players: {\n \"Jeff Adrien\" => {\n number: 4,\n shoe: 18,\n points: 10,\n rebounds: 1,\n assists: 1,\n steals: 2,\n blocks: 7,\n slam_dunks: 2\n },\n\n \"Bismak Biyombo\" => {\n number: 0,\n shoe: 16,\n points: 12,\n rebounds: 4,\n assists: 7,\n steals: 7,\n blocks: 15,\n slam_dunks: 10\n },\n\n \"DeSagna Diop\" => {\n number: 2,\n shoe: 14,\n points: 24,\n rebounds: 12,\n assists: 12,\n steals: 4,\n blocks: 5,\n slam_dunks: 5\n },\n\n \"Ben Gordon\" => {\n number: 8,\n shoe: 15,\n points: 33,\n rebounds: 3,\n assists: 2,\n steals: 1,\n blocks: 1,\n slam_dunks: 0\n },\n\n \"Brendan Haywood\" => {\n number: 33,\n shoe: 15,\n points: 6,\n rebounds: 12,\n assists: 12,\n steals: 22,\n blocks: 5,\n slam_dunks: 12\n }\n }\n }\n }\nend", "def test_count_of_games_by_season\n\n expected = {\n \"20122013\"=>806,\n \"20162017\"=>1317,\n \"20142015\"=>1319,\n \"20152016\"=>1321,\n \"20132014\"=>1323,\n \"20172018\"=>1355\n }\n assert_equal expected, @stat_tracker.count_of_games_by_season\n\n end", "def game_hash\n {\n home: {\n team_name: \"Brooklyn Nets\",\n colors: [\n \"Black\",\n \"White\"\n ],\n players: {\n \"Alan Anderson\" => {\n number: 0,\n shoe: 16,\n points: 22,\n rebounds: 12,\n assists: 12,\n steals: 3,\n blocks: 1,\n slam_dunks: 1\n },\n \"Reggie Evans\" => {\n number: 30,\n shoe: 14,\n points: 12,\n rebounds: 12,\n assists: 12,\n steals: 12,\n blocks: 12,\n slam_dunks: 7\n },\n \"Brook Lopez\" => {\n number: 11,\n shoe: 17,\n points: 17,\n rebounds: 19,\n assists: 10,\n steals: 3,\n blocks: 1,\n slam_dunks: 15\n },\n \"Mason Plumlee\" => {\n number: 1,\n shoe: 19,\n points: 26,\n rebounds: 12,\n assists: 6,\n steals: 3,\n blocks: 8,\n slam_dunks: 5\n },\n \"Jason Terry\" => {\n number: 31,\n shoe: 15,\n points: 19,\n rebounds: 2,\n assists: 2,\n steals: 4,\n blocks: 11,\n slam_dunks: 1\n }\n }\n },\n away: {\n team_name: \"Charlotte Hornets\",\n colors: [\n \"Turquoise\",\n \"Purple\"\n ],\n players: {\n \"Jeff Adrien\" => {\n number: 4,\n shoe: 18,\n points: 10,\n rebounds: 1,\n assists: 1,\n steals: 2,\n blocks: 7,\n slam_dunks: 2\n },\n \"Bismak Biyombo\" => {\n number: 0,\n shoe: 16,\n points: 12,\n rebounds: 4,\n assists: 7,\n steals: 7,\n blocks: 15,\n slam_dunks: 10\n },\n \"DeSagna Diop\" => {\n number: 2,\n shoe: 14,\n points: 24,\n rebounds: 12,\n assists: 12,\n steals: 4,\n blocks: 5,\n slam_dunks: 5\n },\n \"Ben Gordon\" => {\n number: 8,\n shoe: 15,\n points: 33,\n rebounds: 3,\n assists: 2,\n steals: 1,\n blocks: 1,\n slam_dunks: 0\n },\n \"Brendan Haywood\" => {\n number: 33,\n shoe: 15,\n points: 6,\n rebounds: 12,\n assists: 12,\n steals: 22,\n blocks: 5,\n slam_dunks: 12\n }\n }\n }\n }\nend", "def game_hash\n game_hash = {\n home: {\n team_name: \"Brooklyn Nets\",\n colors: [\"Black\", \"White\"],\n players: {\n \"Alan Anderson\" => {\n number: 0,\n shoe: 16,\n points: 22,\n rebounds: 12,\n assists: 12,\n steals: 3,\n blocks: 1,\n slam_dunks: 1\n },\n \"Reggie Evans\" => {\n number: 30,\n shoe: 14,\n points: 12,\n rebounds: 12,\n assists: 12,\n steals: 12,\n blocks: 12,\n slam_dunks: 7\n },\n \"Brook Lopez\" => {\n number: 11,\n shoe: 17,\n points: 17,\n rebounds: 19,\n assists: 10,\n steals: 3,\n blocks: 1,\n slam_dunks: 15\n },\n \"Mason Plumlee\" => {\n number: 1,\n shoe: 19,\n points: 26,\n rebounds: 11,\n assists: 6,\n steals: 3,\n blocks: 8,\n slam_dunks: 5\n },\n \"Jason Terry\" => {\n number: 31,\n shoe: 15,\n points: 19,\n rebounds: 2,\n assists: 2,\n steals: 4,\n blocks: 11,\n slam_dunks: 1\n }\n }\n },\n away: {\n team_name: \"Charlotte Hornets\",\n colors: [\"Turquoise\", \"Purple\"],\n players: {\n \"Jeff Adrien\" => {\n number: 4,\n shoe: 18,\n points: 10,\n rebounds: 1,\n assists: 1,\n steals: 2,\n blocks: 7,\n slam_dunks: 2\n },\n \"Bismack Biyombo\" => {\n number: 0,\n shoe: 16,\n points: 12,\n rebounds: 4,\n assists: 7,\n steals: 22,\n blocks: 15,\n slam_dunks: 10\n },\n \"DeSagna Diop\" => {\n number: 2,\n shoe: 14,\n points: 24,\n rebounds: 12,\n assists: 12,\n steals: 4,\n blocks: 5,\n slam_dunks: 5\n },\n \"Ben Gordon\" => {\n number: 8,\n shoe: 15,\n points: 33,\n rebounds: 3,\n assists: 2,\n steals: 1,\n blocks: 1,\n slam_dunks: 0\n },\n \"Kemba Walker\" => {\n number: 33,\n shoe: 15,\n points: 6,\n rebounds: 12,\n assists: 12,\n steals: 7,\n blocks: 5,\n slam_dunks: 12\n }\n }\n }\n }\nend", "def game_hash\n game_hash = {\n home: {\n team_name: \"Brooklyn Nets\",\n colors: [\"Black\", \"White\"],\n players: {\n \"Alan Anderson\" => {\n number: 0,\n shoe: 16,\n points: 22,\n rebounds: 12,\n assists: 12,\n steals: 3,\n blocks: 1,\n slam_dunks: 1\n },\n \"Reggie Evans\" => {\n number: 30,\n shoe: 14,\n points: 12,\n rebounds: 12,\n assists: 12,\n steals: 12,\n blocks: 12,\n slam_dunks: 7\n },\n \"Brook Lopez\" => {\n number: 11,\n shoe: 17,\n points: 17,\n rebounds: 19,\n assists: 10,\n steals: 3,\n blocks: 1,\n slam_dunks: 15\n },\n \"Mason Plumlee\" => {\n number: 1,\n shoe: 19,\n points: 26,\n rebounds: 12,\n assists: 6,\n steals: 3,\n blocks: 8,\n slam_dunks: 5\n },\n \"Jason Terry\" => {\n number: 31,\n shoe: 15,\n points: 19,\n rebounds: 2,\n assists: 2,\n steals: 4,\n blocks: 11,\n slam_dunks: 1\n }\n }\n },\n away: {\n team_name: \"Charlotte Hornets\",\n colors: [\"Turquoise\", \"Purple\"],\n players: {\n \"Jeff Adrien\" => {\n number: 4,\n shoe: 18,\n points: 10,\n rebounds: 1,\n assists: 1,\n steals: 2,\n blocks: 7,\n slam_dunks: 2\n },\n \"Bismak Biyombo\" => {\n number: 0,\n shoe: 16,\n points: 12,\n rebounds: 4,\n assists: 7,\n steals: 7,\n blocks: 15,\n slam_dunks: 10\n },\n \"DeSagna Diop\" => {\n number: 2,\n shoe: 14,\n points: 24,\n rebounds: 12,\n assists: 12,\n steals: 4,\n blocks: 5,\n slam_dunks: 5\n },\n \"Ben Gordon\" => {\n number: 8,\n shoe: 15,\n points: 33,\n rebounds: 3,\n assists: 2,\n steals: 1,\n blocks: 1,\n slam_dunks: 0\n },\n \"Brendan Haywood\" => {\n number: 33,\n shoe: 15,\n points: 6,\n rebounds: 12,\n assists: 12,\n steals: 22,\n blocks: 5,\n slam_dunks: 12\n }\n }\n }\n }\nend", "def game_hash\n game_hash = {\n home: {\n team_name: \"Brooklyn Nets\",\n colors: [\"Black\", \"White\"],\n players: {\n \"Alan Anderson\" => {\n number: 0,\n shoe: 16,\n points: 22,\n rebounds: 12,\n assists: 12,\n steals: 3,\n blocks: 1,\n slam_dunks: 1\n },\n \"Reggie Evans\" => {\n number: 30,\n shoe: 14,\n points: 12,\n rebounds: 12,\n assists: 12,\n steals: 12,\n blocks: 12,\n slam_dunks: 7\n },\n \"Brook Lopez\" => {\n number: 11,\n shoe: 17,\n points: 17,\n rebounds: 19,\n assists: 10,\n steals: 3,\n blocks: 1,\n slam_dunks: 15\n },\n \"Mason Plumlee\" => {\n number: 1,\n shoe: 19,\n points: 26,\n rebounds: 12,\n assists: 6,\n steals: 3,\n blocks: 8,\n slam_dunks: 5\n },\n \"Jason Terry\" => {\n number: 31,\n shoe: 15,\n points: 19,\n rebounds: 2,\n assists: 2,\n steals: 4,\n blocks: 11,\n slam_dunks: 1\n }\n }\n },\n away: {\n team_name: \"Charlotte Hornets\",\n colors: [\"Turquoise\", \"Purple\"],\n players: {\n \"Jeff Adrien\" => {\n number: 4,\n shoe: 18,\n points: 10,\n rebounds: 1,\n assists: 1,\n steals: 2,\n blocks: 7,\n slam_dunks: 2\n },\n \"Bismak Biyombo\" => {\n number: 0,\n shoe: 16,\n points: 12,\n rebounds: 4,\n assists: 7,\n steals: 7,\n blocks: 15,\n slam_dunks: 10\n },\n \"DeSagna Diop\" => {\n number: 2,\n shoe: 14,\n points: 24,\n rebounds: 12,\n assists: 12,\n steals: 4,\n blocks: 5,\n slam_dunks: 5\n },\n \"Ben Gordon\" => {\n number: 8,\n shoe: 15,\n points: 33,\n rebounds: 3,\n assists: 2,\n steals: 1,\n blocks: 1,\n slam_dunks: 0\n },\n \"Brendan Haywood\" => {\n number: 33,\n shoe: 15,\n points: 6,\n rebounds: 12,\n assists: 12,\n steals: 22,\n blocks: 5,\n slam_dunks: 12\n }\n }\n }\n }\nend", "def game_hash\n {\n :home => {\n :team_name => 'Brooklyn Nets',\n :colors => [\"Black\", \"White\"],\n :players => [\n {\n :name => \"Alan Anderson\",\n :number => 0,\n :shoe => 16,\n :points => 22,\n :rebounds => 12,\n :assists => 12,\n :steals => 3,\n :blocks => 1,\n :slam_dunks => 1\n },\n {\n :name => \"Reggie Evans\",\n :number => 30,\n :shoe => 14,\n :points => 12,\n :rebounds => 12,\n :assists => 12,\n :steals => 12,\n :blocks => 12,\n :slam_dunks => 7\n }, \n {\n :name => \"Brook Lopez\",\n :number => 11,\n :shoe => 17,\n :points => 17,\n :rebounds => 19,\n :assists => 10,\n :steals => 3,\n :blocks => 1,\n :slam_dunks => 15\n },\n {\n :name => \"Mason Plumlee\",\n :number => 1,\n :shoe => 19,\n :points => 26,\n :rebounds => 12,\n :assists => 6,\n :steals => 3,\n :blocks => 8,\n :slam_dunks => 5 \n },\n {\n :name => \"Jason Terry\",\n :number => 31,\n :shoe => 15,\n :points => 19,\n :rebounds => 2,\n :assists => 2,\n :steals => 4,\n :blocks => 11,\n :slam_dunks => 1\n }\n ]\n },\n :away => {\n :team_name => \"Charlotte Hornets\",\n :colors => [\"Turquoise\", \"Purple\"],\n :players => [ \n {\n :name => \"Jeff Adrien\",\n :number => 4,\n :shoe => 18,\n :points => 10,\n :rebounds => 1,\n :assists => 1,\n :steals => 2,\n :blocks => 7,\n :slam_dunks => 2\n }, \n {\n :name => \"Bismak Biyombo\",\n :number => 0,\n :shoe => 16,\n :points => 12,\n :rebounds => 4,\n :assists => 7,\n :steals => 7,\n :blocks => 15,\n :slam_dunks => 10\n \n },\n {\n :name => \"DeSagna Diop\",\n :number => 2,\n :shoe => 14,\n :points => 24,\n :rebounds => 12,\n :assists => 12,\n :steals => 4,\n :blocks => 5,\n :slam_dunks => 5\n },\n {\n :name => \"Ben Gordon\",\n :number => 8,\n :shoe => 15,\n :points => 33,\n :rebounds => 3,\n :assists => 2,\n :steals => 1,\n :blocks => 1,\n :slam_dunks => 0\n },\n {\n :name => \"Brendan Haywood\",\n :number => 33,\n :shoe => 15,\n :points => 6,\n :rebounds => 12,\n :assists => 12,\n :steals => 22,\n :blocks => 5,\n :slam_dunks => 12\n },\n ] \n }\n }\nend", "def game_hash\n {\n :home => {\n :team_name => \"Brooklyn Nets\", #is a separate line for each key, or one long list preferred for hash display?\n :colors => [\"Black\", \"White\"],\n :players => {\n \"Alan Anderson\" => {\n :number => 0,\n :shoe => 16,\n :points => 22,\n :rebounds => 12,\n :assists => 12,\n :steals => 3,\n :blocks => 1,\n :slam_dunks => 1\n },\n \"Reggie Evans\" => {\n :number => 30,\n :shoe => 14,\n :points => 12,\n :rebounds => 12,\n :assists => 12,\n :steals => 12,\n :blocks => 12,\n :slam_dunks => 7\n },\n \"Brook Lopez\" => {\n :number => 11,\n :shoe => 17,\n :points => 17,\n :rebounds => 19,\n :assists => 10,\n :steals => 3,\n :blocks => 1,\n :slam_dunks => 15 #damn.\n },\n \"Mason Plumlee\" => {\n :number => 1,\n :shoe => 19,\n :points => 26,\n :rebounds => 12,\n :assists => 6,\n :steals => 3,\n :blocks => 8,\n :slam_dunks => 5\n },\n \"Jason Terry\" => {\n :number => 31,\n :shoe => 15,\n :points => 19,\n :rebounds => 2,\n :assists => 2,\n :steals => 4,\n :blocks => 11,\n :slam_dunks => 1\n }\n }\n },\n :away => {\n :team_name => \"Charlotte Hornets\",\n :colors => [\"Turquoise\", \"Purple\"], #wow I can't spell turquoise. Whats the etymology?\n :players => {\n \"Jeff Adrien\" => {\n :number => 4,\n :shoe => 18,\n :points => 10,\n :rebounds => 1,\n :assists => 1,\n :steals => 2,\n :blocks => 7,\n :slam_dunks => 2\n },\n \"Bismak Biyombo\" => {\n :number => 0,\n :shoe => 16,\n :points => 12,\n :rebounds => 4,\n :assists => 7,\n :steals => 7,\n :blocks => 15,\n :slam_dunks => 10\n },\n \"DeSagna Diop\" => {\n :number => 2,\n :shoe => 14,\n :points => 24,\n :rebounds => 12,\n :assists => 12,\n :steals => 4,\n :blocks => 5,\n :slam_dunks => 5\n },\n \"Ben Gordon\" => {\n :number => 8,\n :shoe => 15,\n :points => 33,\n :rebounds => 3,\n :assists => 2,\n :steals => 1,\n :blocks => 1,\n :slam_dunks => 0\n },\n \"Brendan Haywood\" => {\n :number => 33,\n :shoe => 15,\n :points => 6,\n :rebounds => 12,\n :assists => 12,\n :steals => 22,\n :blocks => 5,\n :slam_dunks => 12\n }\n }\n }\n }\nend", "def create\n sport_id = user_session.get(:filter_sport_id) # okay that's how mistakes happen.... TODO!!!\n sport = Sport.find(sport_id)\n team_points = Hash.new(0)\n team_games = Hash.new(0)\n team_goals_for = Hash.new(0)\n team_goals_against = Hash.new(0)\n\n sport.leagues.each do |league|\n league.games.each do |game| #iterate through EVERY game in EVERY league, calculate points, set it in team table\n if game.tie == false and not game.winner_id.nil? # no tie and winner exists\n team_points[game.winner_id] += 2\n team_games[game.team_1_id] += 1\n team_games[game.team_2_id] += 1\n elsif game.tie == true\n team_points[game.team_1_id] += 1\n team_points[game.team_2_id] += 1\n team_games[game.team_1_id] += 1\n team_games[game.team_2_id] += 1\n end # else, game has not been played yet\n\n # go through all the sets and calculate goal difference\n game.gamesets.each do |set|\n team_goals_for[game.team_1_id] += set.points_team_1.to_i\n team_goals_for[game.team_2_id] += set.points_team_2.to_i\n team_goals_against[game.team_1_id] += set.points_team_2.to_i\n team_goals_against[game.team_2_id] += set.points_team_1.to_i\n end\n\n end\n\n league.teams.each do |team|\n team.points = team_points[team.id] #|| 0 should work without this\n team.game_count = team_games[team.id]\n team.goals_for = team_goals_for[team.id]\n team.goals_against = team_goals_against[team.id]\n team.goals_difference = team_goals_for[team.id] - team_goals_against[team.id]\n team.save\n end\n end\n redirect_to rankings_path, success: t(:object_created)\n end", "def game_hash\n game_hash = {home:{team_name:\"Brooklyn Nets\", colors:[\"Black\", \"White\"], players:{\"Alan Anderson\"=>{number: 0, shoe: 16, points: 22, rebounds: 12, assists: 12, steals: 3, blocks: 1, slam_dunks: 1},\n \"Reggie Evans\"=>{number: 30, shoe: 14, points: 12, rebounds: 12, assists: 12, steals: 12, blocks: 12, slam_dunks: 7},\n \"Brook Lopez\"=>{number: 11, shoe: 17, points: 17, rebounds: 19, assists: 10, steals: 3, blocks: 1, slam_dunks: 15},\n \"Mason Plumlee\"=>{number: 1, shoe: 19, points: 26, rebounds: 12, assists: 6, steals: 3, blocks: 8, slam_dunks: 5},\n \"Jason Terry\"=>{number: 31, shoe: 15, points: 19, rebounds: 2, assists: 2, steals: 4, blocks: 11, slam_dunks: 1}}},\n away:{team_name:\"Charlotte Hornets\", colors:[\"Turquoise\", \"Purple\"], players:{\"Jeff Adrien\"=>{number: 4, shoe: 18, points: 10, rebounds: 1, assists: 1, steals: 2, blocks: 7, slam_dunks: 2},\n \"Bismak Biyombo\"=>{number: 0, shoe: 16, points: 12, rebounds: 4, assists: 7, steals: 7, blocks: 15, slam_dunks: 10},\n \"DeSagna Diop\"=>{number: 2, shoe: 14, points: 24, rebounds: 12, assists: 12, steals: 4, blocks: 5, slam_dunks: 5},\n \"Ben Gordon\"=>{number: 8, shoe: 15, points: 33, rebounds: 3, assists: 2, steals: 1, blocks: 1, slam_dunks: 0},\n \"Brendan Haywood\"=>{number: 33, shoe: 15, points: 6, rebounds: 12, assists: 12, steals: 22, blocks: 5, slam_dunks: 12}}}}\n game_hash\nend", "def game_hash\n\t#game_hash = \n\t{\n\t\thome: {\n\t\t\tteam_name: \"Brooklyn Nets\",\n\t\t\tcolors: [\"Black\", \"White\"],\n\t\t\tplayers: {\n\t\t\t\t\"Alan Anderson\" => {\n\t\t\t\t\tnumber: 0,\n\t\t\t\t\tshoe: 16,\n\t\t\t\t\tpoints: 22,\n\t\t\t\t\trebounds: 12,\n\t\t\t\t\tassists: 12,\n\t\t\t\t\tsteals: 3,\n\t\t\t\t\tblocks: 1,\n\t\t\t\t\tslam_dunks: 1\n\t\t\t\t},\n\t\t\t\t\"Reggie Evans\" => {\n\t\t\t\t\tnumber: 30,\n\t\t\t\t\tshoe: 14,\n\t\t\t\t\tpoints: 12,\n\t\t\t\t\trebounds: 12,\n\t\t\t\t\tassists: 12,\n\t\t\t\t\tsteals: 12,\n\t\t\t\t\tblocks: 12,\n\t\t\t\t\tslam_dunks: 7\n\t\t\t\t},\n\t\t\t\t\"Brook Lopez\" => {\n\t\t\t\t\tnumber: 11,\n\t\t\t\t\tshoe: 17,\n\t\t\t\t\tpoints:17,\n\t\t\t\t\trebounds: 19,\n\t\t\t\t\tassists: 10,\n\t\t\t\t\tsteals: 3,\n\t\t\t\t\tblocks: 1,\n\t\t\t\t\tslam_dunks: 15\n\t\t\t\t},\n\t\t\t\t\"Mason Plumlee\" => {\n\t\t\t\t\tnumber: 1,\n\t\t\t\t\tshoe: 19,\n\t\t\t\t\tpoints: 26,\n\t\t\t\t\trebounds: 12,\n\t\t\t\t\tassists: 6,\n\t\t\t\t\tsteals: 3,\n\t\t\t\t\tblocks: 8,\n\t\t\t\t\tslam_dunks: 5\n\t\t\t\t},\n\t\t\t\t\"Jason Terry\" => {\n\t\t\t\t\tnumber: 31,\n\t\t\t\t\tshoe: 15,\n\t\t\t\t\tpoints: 19,\n\t\t\t\t\trebounds: 2,\n\t\t\t\t\tassists: 2,\n\t\t\t\t\tsteals: 4,\n\t\t\t\t\tblocks: 11,\n\t\t\t\t\tslam_dunks: 1\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\taway: {\n\t\t\tteam_name: \"Charlotte Hornets\",\n\t\t\tcolors: [\"Turquoise\", \"Purple\"],\n\t\t\tplayers: {\n\t\t\t\t\"Jeff Adrien\" => {\n\t\t\t\t\tnumber: 4,\n\t\t\t\t\tshoe: 18,\n\t\t\t\t\tpoints: 10,\n\t\t\t\t\trebounds: 1,\n\t\t\t\t\tassists: 1,\n\t\t\t\t\tsteals: 2,\n\t\t\t\t\tblocks: 7,\n\t\t\t\t\tslam_dunks: 2\n\t\t\t\t},\n\t\t\t\t\"Bismak Biyombo\" => {\n\t\t\t\t\tnumber: 0,\n\t\t\t\t\tshoe: 16,\n\t\t\t\t\tpoints: 12,\n\t\t\t\t\trebounds: 4,\n\t\t\t\t\tassists: 7,\n\t\t\t\t\tsteals: 7,\n\t\t\t\t\tblocks: 15,\n\t\t\t\t\tslam_dunks: 10\n\t\t\t\t},\n\t\t\t\t\"DeSagna Diop\" => {\n\t\t\t\t\tnumber: 2,\n\t\t\t\t\tshoe: 14,\n\t\t\t\t\tpoints: 24,\n\t\t\t\t\trebounds: 12,\n\t\t\t\t\tassists: 12,\n\t\t\t\t\tsteals: 4,\n\t\t\t\t\tblocks: 5,\n\t\t\t\t\tslam_dunks: 5\n\t\t\t\t},\n\t\t\t\t\"Ben Gordon\" => {\n\t\t\t\t\tnumber: 8,\n\t\t\t\t\tshoe: 15,\n\t\t\t\t\tpoints: 33,\n\t\t\t\t\trebounds: 3,\n\t\t\t\t\tassists: 2,\n\t\t\t\t\tsteals: 1,\n\t\t\t\t\tblocks: 1,\n\t\t\t\t\tslam_dunks: 0\n\t\t\t\t},\n\t\t\t\t\"Brendan Haywood\" => {\n\t\t\t\t\tnumber: 33,\n\t\t\t\t\tshoe: 15,\n\t\t\t\t\tpoints: 6,\n\t\t\t\t\trebounds: 12,\n\t\t\t\t\tassists: 12,\n\t\t\t\t\tsteals: 22,\n\t\t\t\t\tblocks: 5,\n\t\t\t\t\tslam_dunks: 12\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\nend", "def call stat\n data = Hash.new { |h, k| h[k] = {} }\n @matches.each do |m|\n teams = [m.home_team, m.away_team]\n scaffs = StatScaffold.call(teams)\n scaffs[m.home_id], scaffs[m.away_id] = StatParser.call(m, scaffs[m.home_id], scaffs[m.away_id])\n data[m.home_team.name][m.round] = scaffs[m.home_id][stat]\n data[m.away_team.name][m.round] = scaffs[m.away_id][stat]\n end\n data.map {|team| {:name => team[0], :data => team[1]}}\n end", "def game_hash\n {\n home: {\n team_name: \"Brooklyn Nets\",\n colors: [\"Black\", \"White\"],\n players: [\n {\n player_name: \"Alan Anderson\",\n number: 0,\n shoe: 16,\n points: 22,\n rebounds: 12,\n assists: 12,\n steals: 3,\n blocks: 1,\n slam_dunks: 1\n }, {\n player_name: \"Reggie Evans\",\n number: 30,\n shoe: 14,\n points: 12,\n rebounds: 12,\n assists: 12,\n steals: 12,\n blocks: 12,\n slam_dunks: 7\n }, {\n player_name: \"Brook Lopez\",\n number: 11,\n shoe: 17,\n points: 17,\n rebounds: 19,\n assists: 10,\n steals: 3,\n blocks: 1,\n slam_dunks: 15\n }, {\n player_name: \"Mason Plumlee\",\n number: 1,\n shoe: 19,\n points: 26,\n rebounds: 12,\n assists: 6,\n steals: 3,\n blocks: 8,\n slam_dunks: 5\n }, {\n player_name: \"Jason Terry\",\n number: 31,\n shoe: 15,\n points: 19,\n rebounds: 2,\n assists: 2,\n steals: 4,\n blocks: 11,\n slam_dunks: 1\n }\n ]\n },\n away: {\n team_name: \"Charlotte Hornets\",\n colors: [\"Turquoise\", \"Purple\"],\n players: [\n {\n player_name: \"Jeff Adrien\",\n number: 4,\n shoe: 18,\n points: 10,\n rebounds: 1,\n assists: 1,\n steals: 2,\n blocks: 7,\n slam_dunks: 2\n }, {\n player_name: \"Bismak Biyombo\",\n number: 0,\n shoe: 16,\n points: 12,\n rebounds: 4,\n assists: 7,\n steals: 7,\n blocks: 15,\n slam_dunks: 10\n }, {\n player_name: \"DeSagna Diop\",\n number: 2,\n shoe: 14,\n points: 24,\n rebounds: 12,\n assists: 12,\n steals: 4,\n blocks: 5,\n slam_dunks: 5\n }, {\n player_name: \"Ben Gordon\",\n number: 8,\n shoe: 15,\n points: 33,\n rebounds: 3,\n assists: 2,\n steals: 1,\n blocks: 1,\n slam_dunks: 0\n }, {\n player_name: \"Brendan Haywood\",\n number: 33,\n shoe: 15,\n points: 6,\n rebounds: 12,\n assists: 12,\n steals: 22,\n blocks: 5,\n slam_dunks: 12\n }\n ]\n }\n }\nend", "def get_rankings\n #create tmp hash storage for all the rows in the rankings table\n row_holder = Hash.new { |hash, key| hash[key] =\n {'played' => 0, '3_points' => 0, '2_points' => 0, '1_point' => 0,\n '0_points' => 0, 'won_sets' => 0, 'lost_sets' => 0, 'points' => 0,\n 'name' => key}}\n\n @games.each do |g|\n if g.has_been_played?\n #add played game for both teams\n row_holder[g.home_team]['played'] += 1\n row_holder[g.away_team]['played'] += 1\n\n #add won sets for each team\n row_holder[g.home_team]['won_sets'] += g.home_sets\n row_holder[g.away_team]['won_sets'] += g.away_sets\n\n #add lost sets for each team\n row_holder[g.home_team]['lost_sets'] += g.away_sets\n row_holder[g.away_team]['lost_sets'] += g.home_sets\n\n #handle all different game outcomes, prepare for ugly code\n #handle 3-0 and 3-1\n if (g.home_sets == 3) && (g.away_sets < 2)\n row_holder[g.home_team]['points'] += 3\n row_holder[g.home_team]['3_points'] += 1\n row_holder[g.away_team]['0_points'] += 1\n\n #handle 3-2\n elsif (g.home_sets == 3) && (g.away_sets == 2)\n row_holder[g.home_team]['points'] += 2\n row_holder[g.away_team]['points'] += 1\n row_holder[g.home_team]['2_points'] += 1\n row_holder[g.away_team]['1_point'] += 1\n\n #handle 2-3\n elsif (g.home_sets == 2) && (g.away_sets ==3)\n row_holder[g.away_team]['points'] += 2\n row_holder[g.home_team]['points'] += 1\n row_holder[g.home_team]['1_point'] += 1\n row_holder[g.away_team]['2_points'] += 1\n\n #handle 0-3 and 1-3\n elsif (g.home_sets < 2) && (g.away_sets == 3)\n row_holder[g.away_team]['points'] += 3\n row_holder[g.home_team]['0_points'] += 1\n row_holder[g.away_team]['3_points'] += 1\n end\n\n # make sure hash is generated when no games have been played yet\n else\n row_holder[g.home_team]['played'] += 0\n row_holder[g.away_team]['played'] += 0\n end\n end\n\n\n\n #convert the row_holder hash to a sorted array\n sort_ranking(row_holder)\n end", "def game_hash\n {\n home: {\n team_name: \"Brooklyn Nets\",\n colors: [\"Black\", \"White\"],\n players: [\n {\n player_name: \"Alan Anderson\",\n number: 0,\n shoe: 16,\n points: 22,\n rebounds: 12,\n assists: 12,\n steals: 3,\n blocks: 1,\n slam_dunks: 1\n },\n {\n player_name: \"Reggie Evans\",\n number: 30,\n shoe: 14,\n points: 12,\n rebounds: 12,\n assists: 12,\n steals: 12,\n blocks: 12,\n slam_dunks: 7\n },\n {\n player_name: \"Brook Lopez\",\n number: 11,\n shoe: 17,\n points: 17,\n rebounds: 19,\n assists: 10,\n steals: 3,\n blocks: 1,\n slam_dunks: 15\n },\n {\n player_name: \"Mason Plumlee\",\n number: 1,\n shoe: 19,\n points: 26,\n rebounds: 11,\n assists: 6,\n steals: 3,\n blocks: 8,\n slam_dunks: 5\n },\n {\n player_name: \"Jason Terry\",\n number: 31,\n shoe: 15,\n points: 19,\n rebounds: 2,\n assists: 2,\n steals: 4,\n blocks: 11,\n slam_dunks: 1\n }\n ]\n },\n away: {\n team_name: \"Charlotte Hornets\",\n colors: [\"Turquoise\", \"Purple\"],\n players: [\n {\n player_name: \"Jeff Adrien\",\n number: 4,\n shoe: 18,\n points: 10,\n rebounds: 1,\n assists: 1,\n steals: 2,\n blocks: 7,\n slam_dunks: 2\n },\n {\n player_name: \"Bismack Biyombo\",\n number: 0,\n shoe: 16,\n points: 12,\n rebounds: 4,\n assists: 7,\n steals: 22,\n blocks: 15,\n slam_dunks: 10\n },\n {\n player_name: \"DeSagna Diop\",\n number: 2,\n shoe: 14,\n points: 24,\n rebounds: 12,\n assists: 12,\n steals: 4,\n blocks: 5,\n slam_dunks: 5\n },\n {\n player_name: \"Ben Gordon\",\n number: 8,\n shoe: 15,\n points: 33,\n rebounds: 3,\n assists: 2,\n steals: 1,\n blocks: 1,\n slam_dunks: 0\n },\n {\n player_name: \"Kemba Walker\",\n number: 33,\n shoe: 15,\n points: 6,\n rebounds: 12,\n assists: 12,\n steals: 7,\n blocks: 5,\n slam_dunks: 12\n }\n ]\n }\n }\nend", "def game_hash\n {\n home: {\n team_name: \"Brooklyn Nets\",\n colors: [\"Black\", \"White\"],\n players: [\n {\n player_name: \"Alan Anderson\",\n number: 0,\n shoe: 16,\n points: 22,\n rebounds: 12,\n assists: 12,\n steals: 3,\n blocks: 1,\n slam_dunks: 1\n },\n {\n player_name: \"Reggie Evans\",\n number: 30,\n shoe: 14,\n points: 12,\n rebounds: 12,\n assists: 12,\n steals: 12,\n blocks: 12,\n slam_dunks: 7\n },\n {\n player_name: \"Brook Lopez\",\n number: 11,\n shoe: 17,\n points: 17,\n rebounds: 19,\n assists: 10,\n steals: 3,\n blocks: 1,\n slam_dunks: 15\n },\n {\n player_name: \"Mason Plumlee\",\n number: 1,\n shoe: 19,\n points: 26,\n rebounds: 11,\n assists: 6,\n steals: 3,\n blocks: 8,\n slam_dunks: 5\n },\n {\n player_name: \"Jason Terry\",\n number: 31,\n shoe: 15,\n points: 19,\n rebounds: 2,\n assists: 2,\n steals: 4,\n blocks: 11,\n slam_dunks: 1\n }\n ]\n },\n away: {\n team_name: \"Charlotte Hornets\",\n colors: [\"Turquoise\", \"Purple\"],\n players: [\n {\n player_name: \"Jeff Adrien\",\n number: 4,\n shoe: 18,\n points: 10,\n rebounds: 1,\n assists: 1,\n steals: 2,\n blocks: 7,\n slam_dunks: 2\n },\n {\n player_name: \"Bismack Biyombo\",\n number: 0,\n shoe: 16,\n points: 12,\n rebounds: 4,\n assists: 7,\n steals: 22,\n blocks: 15,\n slam_dunks: 10\n },\n {\n player_name: \"DeSagna Diop\",\n number: 2,\n shoe: 14,\n points: 24,\n rebounds: 12,\n assists: 12,\n steals: 4,\n blocks: 5,\n slam_dunks: 5\n },\n {\n player_name: \"Ben Gordon\",\n number: 8,\n shoe: 15,\n points: 33,\n rebounds: 3,\n assists: 2,\n steals: 1,\n blocks: 1,\n slam_dunks: 0\n },\n {\n player_name: \"Kemba Walker\",\n number: 33,\n shoe: 15,\n points: 6,\n rebounds: 12,\n assists: 12,\n steals: 7,\n blocks: 5,\n slam_dunks: 12\n }\n ]\n }\n }\nend", "def game_hash\n {\n home: {\n team_name: \"Brooklyn Nets\",\n colors: [\"Black\", \"White\"],\n players: [\n {\n player_name: \"Alan Anderson\",\n number: 0,\n shoe: 16,\n points: 22,\n rebounds: 12,\n assists: 12,\n steals: 3,\n blocks: 1,\n slam_dunks: 1\n },\n {\n player_name: \"Reggie Evans\",\n number: 30,\n shoe: 14,\n points: 12,\n rebounds: 12,\n assists: 12,\n steals: 12,\n blocks: 12,\n slam_dunks: 7\n },\n {\n player_name: \"Brook Lopez\",\n number: 11,\n shoe: 17,\n points: 17,\n rebounds: 19,\n assists: 10,\n steals: 3,\n blocks: 1,\n slam_dunks: 15\n },\n {\n player_name: \"Mason Plumlee\",\n number: 1,\n shoe: 19,\n points: 26,\n rebounds: 11,\n assists: 6,\n steals: 3,\n blocks: 8,\n slam_dunks: 5\n },\n {\n player_name: \"Jason Terry\",\n number: 31,\n shoe: 15,\n points: 19,\n rebounds: 2,\n assists: 2,\n steals: 4,\n blocks: 11,\n slam_dunks: 1\n }\n ]\n },\n away: {\n team_name: \"Charlotte Hornets\",\n colors: [\"Turquoise\", \"Purple\"],\n players: [\n {\n player_name: \"Jeff Adrien\",\n number: 4,\n shoe: 18,\n points: 10,\n rebounds: 1,\n assists: 1,\n steals: 2,\n blocks: 7,\n slam_dunks: 2\n },\n {\n player_name: \"Bismack Biyombo\",\n number: 0,\n shoe: 16,\n points: 12,\n rebounds: 4,\n assists: 7,\n steals: 22,\n blocks: 15,\n slam_dunks: 10\n },\n {\n player_name: \"DeSagna Diop\",\n number: 2,\n shoe: 14,\n points: 24,\n rebounds: 12,\n assists: 12,\n steals: 4,\n blocks: 5,\n slam_dunks: 5\n },\n {\n player_name: \"Ben Gordon\",\n number: 8,\n shoe: 15,\n points: 33,\n rebounds: 3,\n assists: 2,\n steals: 1,\n blocks: 1,\n slam_dunks: 0\n },\n {\n player_name: \"Kemba Walker\",\n number: 33,\n shoe: 15,\n points: 6,\n rebounds: 12,\n assists: 12,\n steals: 7,\n blocks: 5,\n slam_dunks: 12\n }\n ]\n }\n }\nend", "def game_hash\n {\n home: {\n team_name: \"Brooklyn Nets\",\n colors: [\"Black\", \"White\"],\n players: [\n {\n player_name: \"Alan Anderson\",\n number: 0,\n shoe: 16,\n points: 22,\n rebounds: 12,\n assists: 12,\n steals: 3,\n blocks: 1,\n slam_dunks: 1\n },\n {\n player_name: \"Reggie Evans\",\n number: 30,\n shoe: 14,\n points: 12,\n rebounds: 12,\n assists: 12,\n steals: 12,\n blocks: 12,\n slam_dunks: 7\n },\n {\n player_name: \"Brook Lopez\",\n number: 11,\n shoe: 17,\n points: 17,\n rebounds: 19,\n assists: 10,\n steals: 3,\n blocks: 1,\n slam_dunks: 15\n },\n {\n player_name: \"Mason Plumlee\",\n number: 1,\n shoe: 19,\n points: 26,\n rebounds: 11,\n assists: 6,\n steals: 3,\n blocks: 8,\n slam_dunks: 5\n },\n {\n player_name: \"Jason Terry\",\n number: 31,\n shoe: 15,\n points: 19,\n rebounds: 2,\n assists: 2,\n steals: 4,\n blocks: 11,\n slam_dunks: 1\n }\n ]\n },\n away: {\n team_name: \"Charlotte Hornets\",\n colors: [\"Turquoise\", \"Purple\"],\n players: [\n {\n player_name: \"Jeff Adrien\",\n number: 4,\n shoe: 18,\n points: 10,\n rebounds: 1,\n assists: 1,\n steals: 2,\n blocks: 7,\n slam_dunks: 2\n },\n {\n player_name: \"Bismack Biyombo\",\n number: 0,\n shoe: 16,\n points: 12,\n rebounds: 4,\n assists: 7,\n steals: 22,\n blocks: 15,\n slam_dunks: 10\n },\n {\n player_name: \"DeSagna Diop\",\n number: 2,\n shoe: 14,\n points: 24,\n rebounds: 12,\n assists: 12,\n steals: 4,\n blocks: 5,\n slam_dunks: 5\n },\n {\n player_name: \"Ben Gordon\",\n number: 8,\n shoe: 15,\n points: 33,\n rebounds: 3,\n assists: 2,\n steals: 1,\n blocks: 1,\n slam_dunks: 0\n },\n {\n player_name: \"Kemba Walker\",\n number: 33,\n shoe: 15,\n points: 6,\n rebounds: 12,\n assists: 12,\n steals: 7,\n blocks: 5,\n slam_dunks: 12\n }\n ]\n }\n }\nend", "def game_hash\n {\n home: {\n team_name: \"Brooklyn Nets\",\n colors: [\"Black\", \"White\"],\n players: [\n {\n player_name: \"Alan Anderson\",\n number: 0,\n shoe: 16,\n points: 22,\n rebounds: 12,\n assists: 12,\n steals: 3,\n blocks: 1,\n slam_dunks: 1\n },\n {\n player_name: \"Reggie Evans\",\n number: 30,\n shoe: 14,\n points: 12,\n rebounds: 12,\n assists: 12,\n steals: 12,\n blocks: 12,\n slam_dunks: 7\n },\n {\n player_name: \"Brook Lopez\",\n number: 11,\n shoe: 17,\n points: 17,\n rebounds: 19,\n assists: 10,\n steals: 3,\n blocks: 1,\n slam_dunks: 15\n },\n {\n player_name: \"Mason Plumlee\",\n number: 1,\n shoe: 19,\n points: 26,\n rebounds: 11,\n assists: 6,\n steals: 3,\n blocks: 8,\n slam_dunks: 5\n },\n {\n player_name: \"Jason Terry\",\n number: 31,\n shoe: 15,\n points: 19,\n rebounds: 2,\n assists: 2,\n steals: 4,\n blocks: 11,\n slam_dunks: 1\n }\n ]\n },\n away: {\n team_name: \"Charlotte Hornets\",\n colors: [\"Turquoise\", \"Purple\"],\n players: [\n {\n player_name: \"Jeff Adrien\",\n number: 4,\n shoe: 18,\n points: 10,\n rebounds: 1,\n assists: 1,\n steals: 2,\n blocks: 7,\n slam_dunks: 2\n },\n {\n player_name: \"Bismack Biyombo\",\n number: 0,\n shoe: 16,\n points: 12,\n rebounds: 4,\n assists: 7,\n steals: 22,\n blocks: 15,\n slam_dunks: 10\n },\n {\n player_name: \"DeSagna Diop\",\n number: 2,\n shoe: 14,\n points: 24,\n rebounds: 12,\n assists: 12,\n steals: 4,\n blocks: 5,\n slam_dunks: 5\n },\n {\n player_name: \"Ben Gordon\",\n number: 8,\n shoe: 15,\n points: 33,\n rebounds: 3,\n assists: 2,\n steals: 1,\n blocks: 1,\n slam_dunks: 0\n },\n {\n player_name: \"Kemba Walker\",\n number: 33,\n shoe: 15,\n points: 6,\n rebounds: 12,\n assists: 12,\n steals: 7,\n blocks: 5,\n slam_dunks: 12\n }\n ]\n }\n }\nend", "def game_hash\n {\n home: {\n team_name: \"Brooklyn Nets\",\n colors: [\"Black\", \"White\"],\n players: [\n {\n player_name: \"Alan Anderson\",\n number: 0,\n shoe: 16,\n points: 22,\n rebounds: 12,\n assists: 12,\n steals: 3,\n blocks: 1,\n slam_dunks: 1\n },\n {\n player_name: \"Reggie Evans\",\n number: 30,\n shoe: 14,\n points: 12,\n rebounds: 12,\n assists: 12,\n steals: 12,\n blocks: 12,\n slam_dunks: 7\n },\n {\n player_name: \"Brook Lopez\",\n number: 11,\n shoe: 17,\n points: 17,\n rebounds: 19,\n assists: 10,\n steals: 3,\n blocks: 1,\n slam_dunks: 15\n },\n {\n player_name: \"Mason Plumlee\",\n number: 1,\n shoe: 19,\n points: 26,\n rebounds: 11,\n assists: 6,\n steals: 3,\n blocks: 8,\n slam_dunks: 5\n },\n {\n player_name: \"Jason Terry\",\n number: 31,\n shoe: 15,\n points: 19,\n rebounds: 2,\n assists: 2,\n steals: 4,\n blocks: 11,\n slam_dunks: 1\n }\n ]\n },\n away: {\n team_name: \"Charlotte Hornets\",\n colors: [\"Turquoise\", \"Purple\"],\n players: [\n {\n player_name: \"Jeff Adrien\",\n number: 4,\n shoe: 18,\n points: 10,\n rebounds: 1,\n assists: 1,\n steals: 2,\n blocks: 7,\n slam_dunks: 2\n },\n {\n player_name: \"Bismack Biyombo\",\n number: 0,\n shoe: 16,\n points: 12,\n rebounds: 4,\n assists: 7,\n steals: 22,\n blocks: 15,\n slam_dunks: 10\n },\n {\n player_name: \"DeSagna Diop\",\n number: 2,\n shoe: 14,\n points: 24,\n rebounds: 12,\n assists: 12,\n steals: 4,\n blocks: 5,\n slam_dunks: 5\n },\n {\n player_name: \"Ben Gordon\",\n number: 8,\n shoe: 15,\n points: 33,\n rebounds: 3,\n assists: 2,\n steals: 1,\n blocks: 1,\n slam_dunks: 0\n },\n {\n player_name: \"Kemba Walker\",\n number: 33,\n shoe: 15,\n points: 6,\n rebounds: 12,\n assists: 12,\n steals: 7,\n blocks: 5,\n slam_dunks: 12\n }\n ]\n }\n }\nend", "def game_hash\n {\n home: {\n team_name: \"Brooklyn Nets\",\n colors: [\"Black\", \"White\"],\n players: [\n {\n player_name: \"Alan Anderson\",\n number: 0,\n shoe: 16,\n points: 22,\n rebounds: 12,\n assists: 12,\n steals: 3,\n blocks: 1,\n slam_dunks: 1\n },\n {\n player_name: \"Reggie Evans\",\n number: 30,\n shoe: 14,\n points: 12,\n rebounds: 12,\n assists: 12,\n steals: 12,\n blocks: 12,\n slam_dunks: 7\n },\n {\n player_name: \"Brook Lopez\",\n number: 11,\n shoe: 17,\n points: 17,\n rebounds: 19,\n assists: 10,\n steals: 3,\n blocks: 1,\n slam_dunks: 15\n },\n {\n player_name: \"Mason Plumlee\",\n number: 1,\n shoe: 19,\n points: 26,\n rebounds: 11,\n assists: 6,\n steals: 3,\n blocks: 8,\n slam_dunks: 5\n },\n {\n player_name: \"Jason Terry\",\n number: 31,\n shoe: 15,\n points: 19,\n rebounds: 2,\n assists: 2,\n steals: 4,\n blocks: 11,\n slam_dunks: 1\n }\n ]\n },\n away: {\n team_name: \"Charlotte Hornets\",\n colors: [\"Turquoise\", \"Purple\"],\n players: [\n {\n player_name: \"Jeff Adrien\",\n number: 4,\n shoe: 18,\n points: 10,\n rebounds: 1,\n assists: 1,\n steals: 2,\n blocks: 7,\n slam_dunks: 2\n },\n {\n player_name: \"Bismack Biyombo\",\n number: 0,\n shoe: 16,\n points: 12,\n rebounds: 4,\n assists: 7,\n steals: 22,\n blocks: 15,\n slam_dunks: 10\n },\n {\n player_name: \"DeSagna Diop\",\n number: 2,\n shoe: 14,\n points: 24,\n rebounds: 12,\n assists: 12,\n steals: 4,\n blocks: 5,\n slam_dunks: 5\n },\n {\n player_name: \"Ben Gordon\",\n number: 8,\n shoe: 15,\n points: 33,\n rebounds: 3,\n assists: 2,\n steals: 1,\n blocks: 1,\n slam_dunks: 0\n },\n {\n player_name: \"Kemba Walker\",\n number: 33,\n shoe: 15,\n points: 6,\n rebounds: 12,\n assists: 12,\n steals: 7,\n blocks: 5,\n slam_dunks: 12\n }\n ]\n }\n }\nend", "def game_hash\n {\n home: {\n team_name: \"Brooklyn Nets\",\n colors: [\"Black\", \"White\"],\n players: [\n {\n player_name: \"Alan Anderson\",\n number: 0,\n shoe: 16,\n points: 22,\n rebounds: 12,\n assists: 12,\n steals: 3,\n blocks: 1,\n slam_dunks: 1\n },\n {\n player_name: \"Reggie Evans\",\n number: 30,\n shoe: 14,\n points: 12,\n rebounds: 12,\n assists: 12,\n steals: 12,\n blocks: 12,\n slam_dunks: 7\n },\n {\n player_name: \"Brook Lopez\",\n number: 11,\n shoe: 17,\n points: 17,\n rebounds: 19,\n assists: 10,\n steals: 3,\n blocks: 1,\n slam_dunks: 15\n },\n {\n player_name: \"Mason Plumlee\",\n number: 1,\n shoe: 19,\n points: 26,\n rebounds: 11,\n assists: 6,\n steals: 3,\n blocks: 8,\n slam_dunks: 5\n },\n {\n player_name: \"Jason Terry\",\n number: 31,\n shoe: 15,\n points: 19,\n rebounds: 2,\n assists: 2,\n steals: 4,\n blocks: 11,\n slam_dunks: 1\n }\n ]\n },\n away: {\n team_name: \"Charlotte Hornets\",\n colors: [\"Turquoise\", \"Purple\"],\n players: [\n {\n player_name: \"Jeff Adrien\",\n number: 4,\n shoe: 18,\n points: 10,\n rebounds: 1,\n assists: 1,\n steals: 2,\n blocks: 7,\n slam_dunks: 2\n },\n {\n player_name: \"Bismack Biyombo\",\n number: 0,\n shoe: 16,\n points: 12,\n rebounds: 4,\n assists: 7,\n steals: 22,\n blocks: 15,\n slam_dunks: 10\n },\n {\n player_name: \"DeSagna Diop\",\n number: 2,\n shoe: 14,\n points: 24,\n rebounds: 12,\n assists: 12,\n steals: 4,\n blocks: 5,\n slam_dunks: 5\n },\n {\n player_name: \"Ben Gordon\",\n number: 8,\n shoe: 15,\n points: 33,\n rebounds: 3,\n assists: 2,\n steals: 1,\n blocks: 1,\n slam_dunks: 0\n },\n {\n player_name: \"Kemba Walker\",\n number: 33,\n shoe: 15,\n points: 6,\n rebounds: 12,\n assists: 12,\n steals: 7,\n blocks: 5,\n slam_dunks: 12\n }\n ]\n }\n }\nend", "def game_hash\n {\n home: {\n team_name: \"Brooklyn Nets\",\n colors: [\"Black\", \"White\"],\n players: [\n {\n player_name: \"Alan Anderson\",\n number: 0,\n shoe: 16,\n points: 22,\n rebounds: 12,\n assists: 12,\n steals: 3,\n blocks: 1,\n slam_dunks: 1\n },\n {\n player_name: \"Reggie Evans\",\n number: 30,\n shoe: 14,\n points: 12,\n rebounds: 12,\n assists: 12,\n steals: 12,\n blocks: 12,\n slam_dunks: 7\n },\n {\n player_name: \"Brook Lopez\",\n number: 11,\n shoe: 17,\n points: 17,\n rebounds: 19,\n assists: 10,\n steals: 3,\n blocks: 1,\n slam_dunks: 15\n },\n {\n player_name: \"Mason Plumlee\",\n number: 1,\n shoe: 19,\n points: 26,\n rebounds: 11,\n assists: 6,\n steals: 3,\n blocks: 8,\n slam_dunks: 5\n },\n {\n player_name: \"Jason Terry\",\n number: 31,\n shoe: 15,\n points: 19,\n rebounds: 2,\n assists: 2,\n steals: 4,\n blocks: 11,\n slam_dunks: 1\n }\n ]\n },\n away: {\n team_name: \"Charlotte Hornets\",\n colors: [\"Turquoise\", \"Purple\"],\n players: [\n {\n player_name: \"Jeff Adrien\",\n number: 4,\n shoe: 18,\n points: 10,\n rebounds: 1,\n assists: 1,\n steals: 2,\n blocks: 7,\n slam_dunks: 2\n },\n {\n player_name: \"Bismack Biyombo\",\n number: 0,\n shoe: 16,\n points: 12,\n rebounds: 4,\n assists: 7,\n steals: 22,\n blocks: 15,\n slam_dunks: 10\n },\n {\n player_name: \"DeSagna Diop\",\n number: 2,\n shoe: 14,\n points: 24,\n rebounds: 12,\n assists: 12,\n steals: 4,\n blocks: 5,\n slam_dunks: 5\n },\n {\n player_name: \"Ben Gordon\",\n number: 8,\n shoe: 15,\n points: 33,\n rebounds: 3,\n assists: 2,\n steals: 1,\n blocks: 1,\n slam_dunks: 0\n },\n {\n player_name: \"Kemba Walker\",\n number: 33,\n shoe: 15,\n points: 6,\n rebounds: 12,\n assists: 12,\n steals: 7,\n blocks: 5,\n slam_dunks: 12\n }\n ]\n }\n }\nend", "def game_hash\n {\n home: {\n team_name: \"Brooklyn Nets\",\n colors: [\"Black\", \"White\"],\n players: [\n {\n player_name: \"Alan Anderson\",\n number: 0,\n shoe: 16,\n points: 22,\n rebounds: 12,\n assists: 12,\n steals: 3,\n blocks: 1,\n slam_dunks: 1\n },\n {\n player_name: \"Reggie Evans\",\n number: 30,\n shoe: 14,\n points: 12,\n rebounds: 12,\n assists: 12,\n steals: 12,\n blocks: 12,\n slam_dunks: 7\n },\n {\n player_name: \"Brook Lopez\",\n number: 11,\n shoe: 17,\n points: 17,\n rebounds: 19,\n assists: 10,\n steals: 3,\n blocks: 1,\n slam_dunks: 15\n },\n {\n player_name: \"Mason Plumlee\",\n number: 1,\n shoe: 19,\n points: 26,\n rebounds: 11,\n assists: 6,\n steals: 3,\n blocks: 8,\n slam_dunks: 5\n },\n {\n player_name: \"Jason Terry\",\n number: 31,\n shoe: 15,\n points: 19,\n rebounds: 2,\n assists: 2,\n steals: 4,\n blocks: 11,\n slam_dunks: 1\n }\n ]\n },\n away: {\n team_name: \"Charlotte Hornets\",\n colors: [\"Turquoise\", \"Purple\"],\n players: [\n {\n player_name: \"Jeff Adrien\",\n number: 4,\n shoe: 18,\n points: 10,\n rebounds: 1,\n assists: 1,\n steals: 2,\n blocks: 7,\n slam_dunks: 2\n },\n {\n player_name: \"Bismack Biyombo\",\n number: 0,\n shoe: 16,\n points: 12,\n rebounds: 4,\n assists: 7,\n steals: 22,\n blocks: 15,\n slam_dunks: 10\n },\n {\n player_name: \"DeSagna Diop\",\n number: 2,\n shoe: 14,\n points: 24,\n rebounds: 12,\n assists: 12,\n steals: 4,\n blocks: 5,\n slam_dunks: 5\n },\n {\n player_name: \"Ben Gordon\",\n number: 8,\n shoe: 15,\n points: 33,\n rebounds: 3,\n assists: 2,\n steals: 1,\n blocks: 1,\n slam_dunks: 0\n },\n {\n player_name: \"Kemba Walker\",\n number: 33,\n shoe: 15,\n points: 6,\n rebounds: 12,\n assists: 12,\n steals: 7,\n blocks: 5,\n slam_dunks: 12\n }\n ]\n }\n }\nend", "def game_hash\n {\n home: {\n team_name: \"Brooklyn Nets\",\n colors: [\"Black\", \"White\"],\n players: [\n {\n player_name: \"Alan Anderson\",\n number: 0,\n shoe: 16,\n points: 22,\n rebounds: 12,\n assists: 12,\n steals: 3,\n blocks: 1,\n slam_dunks: 1\n },\n {\n player_name: \"Reggie Evans\",\n number: 30,\n shoe: 14,\n points: 12,\n rebounds: 12,\n assists: 12,\n steals: 12,\n blocks: 12,\n slam_dunks: 7\n },\n {\n player_name: \"Brook Lopez\",\n number: 11,\n shoe: 17,\n points: 17,\n rebounds: 19,\n assists: 10,\n steals: 3,\n blocks: 1,\n slam_dunks: 15\n },\n {\n player_name: \"Mason Plumlee\",\n number: 1,\n shoe: 19,\n points: 26,\n rebounds: 11,\n assists: 6,\n steals: 3,\n blocks: 8,\n slam_dunks: 5\n },\n {\n player_name: \"Jason Terry\",\n number: 31,\n shoe: 15,\n points: 19,\n rebounds: 2,\n assists: 2,\n steals: 4,\n blocks: 11,\n slam_dunks: 1\n }\n ]\n },\n away: {\n team_name: \"Charlotte Hornets\",\n colors: [\"Turquoise\", \"Purple\"],\n players: [\n {\n player_name: \"Jeff Adrien\",\n number: 4,\n shoe: 18,\n points: 10,\n rebounds: 1,\n assists: 1,\n steals: 2,\n blocks: 7,\n slam_dunks: 2\n },\n {\n player_name: \"Bismack Biyombo\",\n number: 0,\n shoe: 16,\n points: 12,\n rebounds: 4,\n assists: 7,\n steals: 22,\n blocks: 15,\n slam_dunks: 10\n },\n {\n player_name: \"DeSagna Diop\",\n number: 2,\n shoe: 14,\n points: 24,\n rebounds: 12,\n assists: 12,\n steals: 4,\n blocks: 5,\n slam_dunks: 5\n },\n {\n player_name: \"Ben Gordon\",\n number: 8,\n shoe: 15,\n points: 33,\n rebounds: 3,\n assists: 2,\n steals: 1,\n blocks: 1,\n slam_dunks: 0\n },\n {\n player_name: \"Kemba Walker\",\n number: 33,\n shoe: 15,\n points: 6,\n rebounds: 12,\n assists: 12,\n steals: 7,\n blocks: 5,\n slam_dunks: 12\n }\n ]\n }\n }\nend", "def game_hash\n {\n home: {\n team_name: \"Brooklyn Nets\",\n colors: [\"Black\", \"White\"],\n players: [\n {\n player_name: \"Alan Anderson\",\n number: 0,\n shoe: 16,\n points: 22,\n rebounds: 12,\n assists: 12,\n steals: 3,\n blocks: 1,\n slam_dunks: 1\n },\n {\n player_name: \"Reggie Evans\",\n number: 30,\n shoe: 14,\n points: 12,\n rebounds: 12,\n assists: 12,\n steals: 12,\n blocks: 12,\n slam_dunks: 7\n },\n {\n player_name: \"Brook Lopez\",\n number: 11,\n shoe: 17,\n points: 17,\n rebounds: 19,\n assists: 10,\n steals: 3,\n blocks: 1,\n slam_dunks: 15\n },\n {\n player_name: \"Mason Plumlee\",\n number: 1,\n shoe: 19,\n points: 26,\n rebounds: 11,\n assists: 6,\n steals: 3,\n blocks: 8,\n slam_dunks: 5\n },\n {\n player_name: \"Jason Terry\",\n number: 31,\n shoe: 15,\n points: 19,\n rebounds: 2,\n assists: 2,\n steals: 4,\n blocks: 11,\n slam_dunks: 1\n }\n ]\n },\n away: {\n team_name: \"Charlotte Hornets\",\n colors: [\"Turquoise\", \"Purple\"],\n players: [\n {\n player_name: \"Jeff Adrien\",\n number: 4,\n shoe: 18,\n points: 10,\n rebounds: 1,\n assists: 1,\n steals: 2,\n blocks: 7,\n slam_dunks: 2\n },\n {\n player_name: \"Bismack Biyombo\",\n number: 0,\n shoe: 16,\n points: 12,\n rebounds: 4,\n assists: 7,\n steals: 22,\n blocks: 15,\n slam_dunks: 10\n },\n {\n player_name: \"DeSagna Diop\",\n number: 2,\n shoe: 14,\n points: 24,\n rebounds: 12,\n assists: 12,\n steals: 4,\n blocks: 5,\n slam_dunks: 5\n },\n {\n player_name: \"Ben Gordon\",\n number: 8,\n shoe: 15,\n points: 33,\n rebounds: 3,\n assists: 2,\n steals: 1,\n blocks: 1,\n slam_dunks: 0\n },\n {\n player_name: \"Kemba Walker\",\n number: 33,\n shoe: 15,\n points: 6,\n rebounds: 12,\n assists: 12,\n steals: 7,\n blocks: 5,\n slam_dunks: 12\n }\n ]\n }\n }\nend", "def game_hash\n {\n home: {\n team_name: \"Brooklyn Nets\",\n colors: [\"Black\", \"White\"],\n players: [\n {\n player_name: \"Alan Anderson\",\n number: 0,\n shoe: 16,\n points: 22,\n rebounds: 12,\n assists: 12,\n steals: 3,\n blocks: 1,\n slam_dunks: 1\n },\n {\n player_name: \"Reggie Evans\",\n number: 30,\n shoe: 14,\n points: 12,\n rebounds: 12,\n assists: 12,\n steals: 12,\n blocks: 12,\n slam_dunks: 7\n },\n {\n player_name: \"Brook Lopez\",\n number: 11,\n shoe: 17,\n points: 17,\n rebounds: 19,\n assists: 10,\n steals: 3,\n blocks: 1,\n slam_dunks: 15\n },\n {\n player_name: \"Mason Plumlee\",\n number: 1,\n shoe: 19,\n points: 26,\n rebounds: 11,\n assists: 6,\n steals: 3,\n blocks: 8,\n slam_dunks: 5\n },\n {\n player_name: \"Jason Terry\",\n number: 31,\n shoe: 15,\n points: 19,\n rebounds: 2,\n assists: 2,\n steals: 4,\n blocks: 11,\n slam_dunks: 1\n }\n ]\n },\n away: {\n team_name: \"Charlotte Hornets\",\n colors: [\"Turquoise\", \"Purple\"],\n players: [\n {\n player_name: \"Jeff Adrien\",\n number: 4,\n shoe: 18,\n points: 10,\n rebounds: 1,\n assists: 1,\n steals: 2,\n blocks: 7,\n slam_dunks: 2\n },\n {\n player_name: \"Bismack Biyombo\",\n number: 0,\n shoe: 16,\n points: 12,\n rebounds: 4,\n assists: 7,\n steals: 22,\n blocks: 15,\n slam_dunks: 10\n },\n {\n player_name: \"DeSagna Diop\",\n number: 2,\n shoe: 14,\n points: 24,\n rebounds: 12,\n assists: 12,\n steals: 4,\n blocks: 5,\n slam_dunks: 5\n },\n {\n player_name: \"Ben Gordon\",\n number: 8,\n shoe: 15,\n points: 33,\n rebounds: 3,\n assists: 2,\n steals: 1,\n blocks: 1,\n slam_dunks: 0\n },\n {\n player_name: \"Kemba Walker\",\n number: 33,\n shoe: 15,\n points: 6,\n rebounds: 12,\n assists: 12,\n steals: 7,\n blocks: 5,\n slam_dunks: 12\n }\n ]\n }\n }\nend", "def game_hash\n {\n home: {\n team_name: \"Brooklyn Nets\",\n colors: [\"Black\", \"White\"],\n players: [\n {\n player_name: \"Alan Anderson\",\n number: 0,\n shoe: 16,\n points: 22,\n rebounds: 12,\n assists: 12,\n steals: 3,\n blocks: 1,\n slam_dunks: 1\n },\n {\n player_name: \"Reggie Evans\",\n number: 30,\n shoe: 14,\n points: 12,\n rebounds: 12,\n assists: 12,\n steals: 12,\n blocks: 12,\n slam_dunks: 7\n },\n {\n player_name: \"Brook Lopez\",\n number: 11,\n shoe: 17,\n points: 17,\n rebounds: 19,\n assists: 10,\n steals: 3,\n blocks: 1,\n slam_dunks: 15\n },\n {\n player_name: \"Mason Plumlee\",\n number: 1,\n shoe: 19,\n points: 26,\n rebounds: 11,\n assists: 6,\n steals: 3,\n blocks: 8,\n slam_dunks: 5\n },\n {\n player_name: \"Jason Terry\",\n number: 31,\n shoe: 15,\n points: 19,\n rebounds: 2,\n assists: 2,\n steals: 4,\n blocks: 11,\n slam_dunks: 1\n }\n ]\n },\n away: {\n team_name: \"Charlotte Hornets\",\n colors: [\"Turquoise\", \"Purple\"],\n players: [\n {\n player_name: \"Jeff Adrien\",\n number: 4,\n shoe: 18,\n points: 10,\n rebounds: 1,\n assists: 1,\n steals: 2,\n blocks: 7,\n slam_dunks: 2\n },\n {\n player_name: \"Bismack Biyombo\",\n number: 0,\n shoe: 16,\n points: 12,\n rebounds: 4,\n assists: 7,\n steals: 22,\n blocks: 15,\n slam_dunks: 10\n },\n {\n player_name: \"DeSagna Diop\",\n number: 2,\n shoe: 14,\n points: 24,\n rebounds: 12,\n assists: 12,\n steals: 4,\n blocks: 5,\n slam_dunks: 5\n },\n {\n player_name: \"Ben Gordon\",\n number: 8,\n shoe: 15,\n points: 33,\n rebounds: 3,\n assists: 2,\n steals: 1,\n blocks: 1,\n slam_dunks: 0\n },\n {\n player_name: \"Kemba Walker\",\n number: 33,\n shoe: 15,\n points: 6,\n rebounds: 12,\n assists: 12,\n steals: 7,\n blocks: 5,\n slam_dunks: 12\n }\n ]\n }\n }\nend", "def game_hash\n {\n home: {\n team_name: \"Brooklyn Nets\",\n colors: [\"Black\", \"White\"],\n players: [\n {\n player_name: \"Alan Anderson\",\n number: 0,\n shoe: 16,\n points: 22,\n rebounds: 12,\n assists: 12,\n steals: 3,\n blocks: 1,\n slam_dunks: 1\n },\n {\n player_name: \"Reggie Evans\",\n number: 30,\n shoe: 14,\n points: 12,\n rebounds: 12,\n assists: 12,\n steals: 12,\n blocks: 12,\n slam_dunks: 7\n },\n {\n player_name: \"Brook Lopez\",\n number: 11,\n shoe: 17,\n points: 17,\n rebounds: 19,\n assists: 10,\n steals: 3,\n blocks: 1,\n slam_dunks: 15\n },\n {\n player_name: \"Mason Plumlee\",\n number: 1,\n shoe: 19,\n points: 26,\n rebounds: 11,\n assists: 6,\n steals: 3,\n blocks: 8,\n slam_dunks: 5\n },\n {\n player_name: \"Jason Terry\",\n number: 31,\n shoe: 15,\n points: 19,\n rebounds: 2,\n assists: 2,\n steals: 4,\n blocks: 11,\n slam_dunks: 1\n }\n ]\n },\n away: {\n team_name: \"Charlotte Hornets\",\n colors: [\"Turquoise\", \"Purple\"],\n players: [\n {\n player_name: \"Jeff Adrien\",\n number: 4,\n shoe: 18,\n points: 10,\n rebounds: 1,\n assists: 1,\n steals: 2,\n blocks: 7,\n slam_dunks: 2\n },\n {\n player_name: \"Bismack Biyombo\",\n number: 0,\n shoe: 16,\n points: 12,\n rebounds: 4,\n assists: 7,\n steals: 22,\n blocks: 15,\n slam_dunks: 10\n },\n {\n player_name: \"DeSagna Diop\",\n number: 2,\n shoe: 14,\n points: 24,\n rebounds: 12,\n assists: 12,\n steals: 4,\n blocks: 5,\n slam_dunks: 5\n },\n {\n player_name: \"Ben Gordon\",\n number: 8,\n shoe: 15,\n points: 33,\n rebounds: 3,\n assists: 2,\n steals: 1,\n blocks: 1,\n slam_dunks: 0\n },\n {\n player_name: \"Kemba Walker\",\n number: 33,\n shoe: 15,\n points: 6,\n rebounds: 12,\n assists: 12,\n steals: 7,\n blocks: 5,\n slam_dunks: 12\n }\n ]\n }\n }\nend", "def update_score_from_games!\n return if self.games.count == 0\n score_by_steam_id = {}\n self.games.each do |g|\n # Add one point to winning team, 0 to losing team so that they show up in the keyset when we check later\n if g.radiant_win === true\n score_by_steam_id[g.radiant_team_id] = score_by_steam_id[g.radiant_team_id].to_i + 1\n score_by_steam_id[g.dire_team_id] = score_by_steam_id[g.dire_team_id].to_i\n elsif g.radiant_win === false\n score_by_steam_id[g.radiant_team_id] = score_by_steam_id[g.radiant_team_id].to_i\n score_by_steam_id[g.dire_team_id] = score_by_steam_id[g.dire_team_id].to_i + 1\n end\n end\n\n # OK the keys are team ids, so now save them\n if score_by_steam_id[self.home_participant.id] != nil && score_by_steam_id[self.away_participant.id] != nil\n self.home_score = score_by_steam_id[self.home_participant.id]\n self.away_score = score_by_steam_id[self.away_participant.id]\n self.save!\n else\n puts score_by_steam_id.inspect\n puts self.home_participant_id.inspect\n puts self.away_participant_id.inspect\n puts \"WARNING: teams did not match, not updating match score\"\n end\n end", "def gross_per_studio(collection)\n result = {}\n i = 0\n while i < collection.size do\n studio = collection[i][:studio]\n total_earnings = collection[i][:worldwide_gross]\n if !result[studio]\n result[studio] = total_earnings\n else\n result[studio] += total_earnings\n end\n i += 1\n end\n \n # GOAL: Given an AoH where each Hash is a movie, return a Hash that includes\n # the total worldwide_gross of all the movies from each studio.\n #\n # INPUT: (collection) AoH where each Hash represents a movie\n #\n # RETURN: Hash where the keys are the studios and the values are the sum of\n # all the worldwide_gross numbers for every movie in the input Hash\n \n result\nend", "def power_play_goal_percentage(seasonasstring) # power_play info in game team stat\n #find list of all games in season given by arg\n #sum all power play goals\n #sum all power play oppertunities\n #divide line 146 and line 147\n #return total of above\n end", "def players\n all_players = {}\n game_hash.each do |home_or_away, team_stats|\n all_players.merge!(team_stats[:players])\n end\n all_players\nend", "def winning_team\n home_points = 0\n away_points = 0\n result = \"\"\n i = 0\n game_hash.each do |team, about|\n about[:players].each do |name , stats|\n if i == 0\n home_points += stats[:points]\n else\n away_points += stats[:points]\n end\n end\n i += 1\n end\n home_points > away_points ? result = game_hash[:home][:team_name] : result = game_hash[:away][:team_name]\nend", "def roster_entries_needed(year: Time.now.year)\n ym = Ygg::Acao::Year.find_by!(year: year)\n\n membership = acao_memberships.find_by(reference_year: ym)\n return nil if !membership\n\n needed = {\n total: 2,\n high_season: 1,\n }\n\n if birth_date && compute_completed_years(birth_date, ym.renew_opening_time) >= 65\n needed[:total] = 0\n needed[:high_season] = 0\n elsif membership.board_member\n needed[:total] = 1\n needed[:high_season] = 0\n elsif membership.tug_pilot\n needed[:total] = 1\n needed[:high_season] = 0\n elsif membership.instructor\n needed[:total] = 0\n needed[:high_season] = 0\n end\n\n needed\n end", "def compute_avg_and_ranges_hash\n scores = {}\n contributors = self.contributors # assignment_teams\n if self.varying_rubrics_by_round?\n rounds = self.rounds_of_reviews\n for round in 1..rounds\n review_questionnaire_id = review_questionnaire_id(round)\n questions = Question.where(['questionnaire_id = ?', review_questionnaire_id])\n contributors.each do |contributor|\n assessments = ReviewResponseMap.get_assessments_for(contributor)\n assessments = assessments.reject {|assessment| assessment.round != round }\n scores[contributor.id] = {} if round == 1\n scores[contributor.id][round] = {}\n scores[contributor.id][round] = Answer.compute_scores(assessments, questions)\n end\n end\n else\n review_questionnaire_id = review_questionnaire_id()\n questions = Question.where(['questionnaire_id = ?', review_questionnaire_id])\n contributors.each do |contributor|\n assessments = ReviewResponseMap.get_assessments_for(contributor)\n scores[contributor.id] = {}\n scores[contributor.id] = Answer.compute_scores(assessments, questions)\n end\n end\n scores\n end", "def game_hash\n game_hash = {\n home: {\n team_name: \"Brooklyn Nets\",\n colors: [\"Black\", \"White\"],\n players: {\n \"Alan Anderson\" => {\n number: 0, \n shoe: 16, \n points: 22, \n rebounds: 12, \n assists: 12, \n steals: 3, \n blocks: 1, \n slam_dunks: 1\n },\n \"Reggie Evans\" => {\n number: 30, \n shoe: 14, \n points: 12, \n rebounds: 12, \n assists: 12, \n steals: 12, \n blocks: 12, \n slam_dunks: 7\n }, \n \"Brook Lopez\" => {\n number: 11, \n shoe: 17, \n points: 17, \n rebounds: 19, \n assists: 10, \n steals: 3, \n blocks: 1, \n slam_dunks: 15\n },\n \"Mason Plumlee\" => {\n number: 1, \n shoe: 19, \n points: 26, \n rebounds: 12, \n assists: 6, \n steals: 3, \n blocks: 8, \n slam_dunks: 5\n },\n \"Jason Terry\" => {\n number: 31, \n shoe: 15, \n points: 19, \n rebounds: 2, \n assists: 2, \n steals: 4, \n blocks: 11, \n slam_dunks: 1\n }\n }\n },\n\n away: {\n team_name: \"Charlotte Hornets\",\n colors: [\"Turquoise\", \"Purple\"],\n players: {\n \"Jeff Adrien\" => {\n number: 4, \n shoe: 18, \n points: 10, \n rebounds: 1, \n assists: 1, \n steals: 2, \n blocks: 7, \n slam_dunks: 2\n },\n \"Bismak Biyombo\" => {\n number: 0, \n shoe: 16, \n points: 12, \n rebounds: 4, \n assists: 7, \n steals: 7, \n blocks: 15, \n slam_dunks: 10\n }, \n \"DeSagna Diop\" => {\n number: 2, \n shoe: 14, \n points: 24, \n rebounds: 12, \n assists: 12, \n steals: 4, \n blocks: 5, \n slam_dunks: 5\n },\n \"Ben Gordon\" => {\n number: 8, \n shoe: 15, \n points: 33, \n rebounds: 3, \n assists: 2, \n steals: 1, \n blocks: 1, \n slam_dunks: 0\n },\n \"Brendan Haywood\" => {\n number: 33, \n shoe: 15, \n points: 6, \n rebounds: 12, \n assists: 12, \n steals: 22, \n blocks: 5, \n slam_dunks: 12\n }\n }\n }\n }\nend", "def winning_team\n points_home = 0\n points_away = 0\n result = \"\"\n\n game_hash.each do |side,team|\n team.each do |specs,info|\n if specs == :players\n info.each do |player|\n if side = :home\n points_home += player[:points]\n else\n points_away += player[:points]\n end\n end\n end\n end\n end\n if points_home > points_away\n result = game_hash[:home][:team_name]\n else\n result = game_hash[:away][:team_name]\n end\n result\nend", "def buildTeamToWinMap(year)\n teamToWinMap = {}\n MlbWin.where(year: year).each do |win|\n teamToWinMap[win.mlb_team_id] = win\n end\n return teamToWinMap\n end", "def find_rcb_batsman_scores(table_of_teams)\n rcb_batsman = Hash.new(0)\n # fetch total runs of each batsman of RCB\n table_of_teams.each do |table_row|\n rcb_batsman[table_row['batsman']] += table_row['total_runs'].to_i if table_row['batting_team'] == 'Royal Challengers Bangalore'\n end\n # extract the data of top 10 batsman\n rcb_batsman = rcb_batsman.sort_by { |_name, runs| runs }.reverse\n hash = {}\n rcb_batsman[..9].each do |name, runs|\n hash[name] = runs\n end\n hash\nend", "def calculate_scores(goal,l_obj,m_obj,h_obj,s_obj)\n serial = CarreerSerializer.new(goal)\n unless goal.weighing?\n return {scores:nil,carreer:serial.as_json}\n end\n scores = {language:stats(get_essays(1)), math:stats(get_essays(2)),history:stats(get_essays(3)),science:stats(get_essays(4))}\n l_essays = scores[:language].nil?\n m_essays = scores[:math].nil?\n s_essays = scores[:science].nil?\n h_essays = scores[:history].nil?\n if goal.weighing.science && goal.weighing.history\n if !(l_essays || m_essays)\n if !s_essays\n max_score_science = (goal.weighing.NEM * current_user.nem + goal.weighing.ranking*current_user.ranking +\n goal.weighing.language * scores[:language][:max] + goal.weighing.math * scores[:math][:max] +\n goal.weighing.science * scores[:science][:max]) /100\n avg_score_science = (goal.weighing.NEM * current_user.nem + goal.weighing.ranking*current_user.ranking +\n goal.weighing.language * scores[:language][:expectation] + goal.weighing.math * scores[:math][:expectation] +\n goal.weighing.science * scores[:science][:expectation]) /100\n else\n max_score_science = nil\n avg_score_science = nil\n end\n if !h_essays\n avg_score_history = (goal.weighing.NEM * current_user.nem + goal.weighing.ranking*current_user.ranking +\n goal.weighing.language * scores[:language][:expectation] + goal.weighing.math * scores[:math][:expectation] +\n goal.weighing.history * scores[:history][:expectation]) /100\n max_score_history = (goal.weighing.NEM * current_user.nem + goal.weighing.ranking*current_user.ranking +\n goal.weighing.language * scores[:language][:max] + goal.weighing.math * scores[:math][:max] +\n goal.weighing.history * scores[:history][:max]) /100\n else\n avg_score_history = nil\n max_score_history = nil\n end\n else\n max_score_science = nil\n avg_score_science = nil\n max_score_history = nil\n avg_score_history = nil\n end\n if !(h_obj.nil? || m_obj.nil? || l_obj.nil?)\n obj_score_history= ((goal.weighing.NEM * current_user.nem + goal.weighing.ranking*current_user.ranking +\n goal.weighing.language * l_obj.score + goal.weighing.math * m_obj.score +\n goal.weighing.history * h_obj.score) /100).to_i\n else\n obj_score_history = nil\n end\n if !(s_obj.nil? || m_obj.nil? || l_obj.nil?)\n obj_score_science = ((goal.weighing.NEM * current_user.nem + goal.weighing.ranking*current_user.ranking +\n goal.weighing.language * l_obj.score + goal.weighing.math * m_obj.score +\n goal.weighing.science * s_obj.score) /100).to_i\n else\n obj_score_science = nil\n end\n return {scores:{science:{max: max_score_science, avg: avg_score_science, obj:obj_score_science},history:{max: max_score_history, avg:avg_score_history, obj:obj_score_history},last_cut:goal.last_cut},carreer:serial.as_json}\n elsif goal.weighing.science\n if !(l_essays || m_essays || s_essays)\n max_score_science = ((goal.weighing.NEM * current_user.nem + goal.weighing.ranking*current_user.ranking +\n goal.weighing.language * scores[:language][:max] + goal.weighing.math * scores[:math][:max] +\n goal.weighing.science * scores[:science][:max]) /100).to_i\n avg_score_science = ((goal.weighing.NEM * current_user.nem + goal.weighing.ranking*current_user.ranking +\n goal.weighing.language * scores[:language][:expectation] + goal.weighing.math * scores[:math][:expectation] +\n goal.weighing.science * scores[:science][:expectation]) /100).to_i\n else\n max_score_science = nil\n avg_score_science = nil\n end\n if !(s_obj.nil? || m_obj.nil? || l_obj.nil?)\n obj_score_science = ((goal.weighing.NEM * current_user.nem + goal.weighing.ranking*current_user.ranking +\n goal.weighing.language * l_obj.score + goal.weighing.math * m_obj.score +\n goal.weighing.science * s_obj.score) /100).to_i\n else\n obj_score_science = nil\n end\n return {scores:{science:{max: max_score_science, avg: avg_score_science,obj:obj_score_science},history:nil,last_cut:goal.last_cut},carreer:serial.as_json}\n else\n if !(l_essays || m_essays || h_essays)\n avg_score_history = ((goal.weighing.NEM * current_user.nem + goal.weighing.ranking*current_user.ranking +\n goal.weighing.language * scores[:language][:expectation] + goal.weighing.math * scores[:math][:expectation] +\n goal.weighing.history * scores[:history][:expectation]) /100).to_i\n max_score_history = ((goal.weighing.NEM * current_user.nem + goal.weighing.ranking*current_user.ranking +\n goal.weighing.language * scores[:language][:max] + goal.weighing.math * scores[:math][:max] +\n goal.weighing.history * scores[:history][:max]) /100).to_i\n else\n avg_score_history = nil\n max_score_history = nil\n end\n if !(h_obj.nil? || m_obj.nil? || l_obj.nil?)\n obj_score_history= ((goal.weighing.NEM * current_user.nem + goal.weighing.ranking*current_user.ranking +\n goal.weighing.language * l_obj.score + goal.weighing.math * m_obj.score +\n goal.weighing.history * h_obj.score) /100).to_i\n else\n obj_score_history = nil\n end\n return {scores:{history:{max: max_score_history, avg:avg_score_history,obj:obj_score_history},science:nil,last_cut:goal.last_cut},carreer:serial.as_json}\n end\n end", "def calculate_results\n players = {}\n @rounds.each do |round|\n round[:results].each do |player,result|\n if not players.has_key?(player)\n players[player] = 0\n end\n if result[:result] == \"Win\"\n players[player] += 1\n end\n end\n end\n winner = players.max_by{|k,v| v}\n players.each do |player, wins|\n @match[player] = {\n \"result\": (player == winner[0]) ? \"Win\" : \"Loss\",\n \"score\": wins\n }\n\t if @duplicate_players then\n\t\t@match[player][:result]= \"Tie\"\n\t end\n\t \n end\n end", "def calculate_results\n players = {}\n @rounds.each do |round|\n round[:results].each do |player, result|\n if not players.has_key?(player)\n players[player] = 0\n end\n if result[:result] == \"Win\"\n players[player] += 1\n end\n end\n end\n winner = players.max_by { |k, v| v }\n players.each do |player, wins|\n @match[player] = {\n \"result\": (player == winner[0]) ? \"Win\" : \"Loss\",\n \"score\": wins,\n }\n if @duplicate_players\n @match[player][:result] = \"Tie\"\n end\n end\n end", "def game\n {\n starting_decision: :stormy_night,\n decisions: {\n stormy_night: {\n description: 'It was a dark and stormy night. (storyline located in decision.rb)',\n option_one: {\n description: 'Go to sleep.',\n decision: :nap\n },\n option_two: {\n description: 'Watch a movie.',\n decision: :movie\n },\n option_three: {\n description: 'Go outside.',\n decision: :go_outside\n },\n option_four: {\n description: 'Get a snack.',\n decision: :get_a_snack\n }\n },\n nap: {\n description: 'You took a nap. The end.',\n option_one: {\n description: 'Start over.',\n decision: :stormy_night\n }\n }\n }\n }\nend", "def update_standings(match)\n\t\thome_team, away_team = get_match_teams(match) \n\t\thome_team_goals, away_team_goals = get_match_goals(match)\n\t\tsave_match_result(home_team, home_team_goals, away_team_goals)\n\t\tsave_match_result(away_team, away_team_goals, home_team_goals)\n\tend", "def player_with_round_scores(first, second, third, today, fourth = '-')\n name = Faker::Name::first_name\n PlayerResults.new(Hashie::Mash.new({first_round: first.to_s, \n second_round: second.to_s, third_round: third.to_s, today: today, \n fourth_round: fourth, name: name}), 70)\n end", "def buildMlbTeamNameToStandingMap(year)\n teamNameToStandingMap = {}\n MlbStanding.includes(:mlb_team).where(year: year).each do |mlb_standing|\n teamNameToStandingMap[mlb_standing.mlb_team.name] = mlb_standing\n end\n return teamNameToStandingMap\n end", "def winning_team\n home_points = collection_by_prop(game_hash[:home], :points).reduce(0, :+)\n away_points = collection_by_prop(game_hash[:away], :points).reduce(0, :+)\n home_points > away_points ? game_hash[:home][:team_name] : game_hash[:away][:team_name]\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 get_contest_standings\n\t\tcontest_standing_records = ContestProgress.where(contest_id: self.id)\n\t\tcontest_standings_unique = Hash.new\n\t\tcontest_standing_records.each do |record|\n\t\t\twrong_answers = ContestProgress.where(contest_id: self.id,\n\t\t\t\tstudent_id: record.student.id,\n\t\t\t\tstatus: false).count\n\t\t\ttime_spent = 0\n\t\t\tContestProgress.where(contest_id: self.id,\n\t\t\t\tstudent_id: record.student.id).each do |progress|\n\t\t\t\tupdated_at = ContestProgress.where(contest_id: self.id, cproblem_id:\n\t\t\t\t\tprogress.cproblem_id, student_id: record.student.id).take.updated_at\n\t\t\t\tstart_time = Contest.find(self.id).start_time\n\t\t\t\ttime_spent = time_spent + ((updated_at - start_time)/60).to_i\n\t\t\tend\n\t\t\tcontest_standings_unique[record.student_id] = {wrong_answers: wrong_answers,\n\t\t\t\trecord: record, time_spent: time_spent}\n\t\tend\n\t\treturn Hash[contest_standings_unique.sort_by {|key, value| [value[:wrong_answers],\n\t\t\tvalue[:time_spent]]}.to_a]\n\tend", "def total_wins_by_season_by_team_id(passed_id)\n @by_team_id_game_objects.each do |game|\n if helper_for_win_count(passed_id, game)\n @total_wins_by_season[game[\"season\"]] += 1\n elsif helper_for_loss_count(passed_id, game)\n @total_wins_by_season[game[\"season\"]] += 0\n end\n end\n end", "def game_hash \n\ngame_hash =\t{\n\thome: {\n\t\tteam_name: \"Brooklyn Nets\",\n\t\tcolors: [\"Black\", \"White\"], \t\t\t#array of strings\n\t\tplayers: {\n\t\t\t\"Alan Anderson\": {\n\t\t\t\tnumber: 0, \n\t\t\t\tshoe: 16, \n\t\t\t\tpoints: 22, \n\t\t\t\trebounds: 12, \n\t\t\t\tassists: 12, \n\t\t\t\tsteals: 3, \n\t\t\t\tblocks: 1, \n\t\t\t\tslam_dunks: 1\n\t\t\t}, \n\n\t\t\t\"Reggie Evans\": {\n\t\t\t\tnumber: 30,\n\t\t\t\tshoe: 14, \n\t\t\t\tpoints: 12, \n\t\t\t\trebounds: 12, \n\t\t\t\tassists: 12, \n\t\t\t\tsteals: 12, \n\t\t\t\tblocks: 12, \n\t\t\t\tslam_dunks: 7\n\t\t\t},\n\t\t\t\"Brook Lopez\": {\n\t\t\t\tnumber: 11, \n\t\t\t\tshoe: 17, \n\t\t\t\tpoints: 17, \n\t\t\t\trebounds: 19, \n\t\t\t\tassists: 10, \n\t\t\t\tsteals: 3, \n\t\t\t\tblocks: 1, \n\t\t\t\tslam_dunks: 15\n\t\t\t},\n\t\t\t\"Mason Plumlee\": {\n\t\t\t\tnumber: 1, \n\t\t\t\tshoe: 19, \n\t\t\t\tpoints: 26, \n\t\t\t\trebounds: 12, \n\t\t\t\tassists: 6, \n\t\t\t\tsteals: 3, \n\t\t\t\tblocks: 8, \n\t\t\t\tslam_dunks: 5\n\t\t\t},\n\t\t\t\"Jason Terry\": {\n\t\t\t\tnumber: 31, \n\t\t\t\tshoe: 15, \n\t\t\t\tpoints: 19, \n\t\t\t\trebounds: 2, \n\t\t\t\tassists: 2, \n\t\t\t\tsteals: 4, \n\t\t\t\tblocks: 11, \n\t\t\t\tslam_dunks: 1\n\t\t\t}\n\n\t\t}\n\t}, \n\n\taway: {\n\t\tteam_name: \"Charlotte Hornets\",\n\t\tcolors: [\"Turquoise\", \"Purple\"], \t\t#array of strings\n\t\tplayers: {\n\t\t\t\"Jeff Adrien\": {\n\t\t\t\tnumber: 4, \n\t\t\t\tshoe: 18, \n\t\t\t\tpoints: 10, \n\t\t\t\trebounds: 1, \n\t\t\t\tassists: 1, \n\t\t\t\tsteals: 2, \n\t\t\t\tblocks: 7, \n\t\t\t\tslam_dunks: 2\n\t\t\t}, \n\n\t\t\t\"Bismack Biyombo\": {\n\t\t\t\tnumber: 0, \n\t\t\t\tshoe: 16, \n\t\t\t\tpoints: 12, \n\t\t\t\trebounds: 4, \n\t\t\t\tassists: 7, \n\t\t\t\tsteals: 7, \n\t\t\t\tblocks: 15, \n\t\t\t\tslam_dunks: 10\n\t\t\t},\n\t\t\t\"DeSagna Diop\": {\n\t\t\t\tnumber: 2, \n\t\t\t\tshoe: 14, \n\t\t\t\tpoints: 24, \n\t\t\t\trebounds: 12, \n\t\t\t\tassists: 12, \n\t\t\t\tsteals: 4, \n\t\t\t\tblocks: 5, \n\t\t\t\tslam_dunks: 5\n\t\t\t},\n\t\t\t\"Ben Gordon\": {\n\t\t\t\tnumber: 8, \n\t\t\t\tshoe: 15, \n\t\t\t\tpoints: 33, \n\t\t\t\trebounds: 3, \n\t\t\t\tassists: 2, \n\t\t\t\tsteals: 1, \n\t\t\t\tblocks: 1, \n\t\t\t\tslam_dunks: 0 \n\t\t\t},\n\t\t\t\"Brendan Haywood\": {\n\t\t\t\tnumber: 33, \n\t\t\t\tshoe: 15, \n\t\t\t\tpoints: 6, \n\t\t\t\trebounds: 12, \n\t\t\t\tassists: 12, \n\t\t\t\tsteals: 22, \n\t\t\t\tblocks: 5, \n\t\t\t\tslam_dunks: 12\n\t\t\t}\n\t\t}\n\n\t}\n}\n\nreturn game_hash\n\nend", "def per_game_stats(season = nil)\n season_id = season ? season.id : Season.current.id\n StatLine.find_by_sql('SELECT AVG(fgm) as fgm, AVG(fga) as fga, coalesce(AVG(fgm)/nullif(AVG(fga), 0), 0) as fgpct, AVG(twom) as twom, AVG(twoa) as twoa, coalesce(AVG(twom)/nullif(AVG(twoa), 0), 0) as twopct, AVG(threem) as threem, AVG(threea) as threea, coalesce(AVG(threem)/nullif(AVG(threea), 0), 0) as threepct,' \\\n 'AVG(ftm) as ftm, AVG(fta) as fta, coalesce(AVG(ftm)/nullif(AVG(fta), 0), 0) as ftpct, AVG(orb) as orb, AVG(drb) as drb, AVG(trb) as trb, AVG(ast) as ast, AVG(stl) as stl, AVG(blk) as blk, AVG(fl) as fl, AVG(\"to\") as to,' \\\n 'AVG(points) as points, COUNT(*) as game_count, sums.league_id FROM (SELECT SUM(fgm) as fgm, SUM(fga) as fga, SUM(twom) as twom, SUM(twoa) as twoa, SUM(threem) as threem, SUM(threea) as threea,' \\\n 'SUM(ftm) as ftm, SUM(fta) as fta, SUM(orb) as orb, SUM(drb) as drb, SUM(trb) as trb, SUM(ast) as ast, SUM(stl) as stl, SUM(blk) as blk, SUM(fl) as fl, SUM(\"to\") as to,' \\\n \"SUM(points) as points, g.league_id as league_id FROM stat_lines sl INNER JOIN games g ON sl.game_id = g.id \" \\\n \"WHERE g.winner is not null AND (g.forfeit is null or not g.forfeit) AND (sl.dnp is null OR not sl.dnp) AND team_id = #{self.id} AND g.season_id = #{season_id} GROUP BY game_id, g.league_id) sums GROUP BY sums.league_id\")\n end", "def total_runs_by_teams(table_of_teams)\n hash_of_teams = Hash.new(0)\n table_of_teams.each do |table_row|\n hash_of_teams[table_row['batting_team']] += table_row['total_runs'].to_i\n end\n hash_of_teams['Rising Pune Supergiants'] += hash_of_teams['Rising Pune Supergiant']\n hash_of_teams.delete('Rising Pune Supergiant')\n hash_of_teams\nend", "def current_week\n standings = Standing.all.order(:wins).reverse\n\n user_standing_index = nil\n standings.each_with_index do |st, index|\n user_standing_index = index if st.user_id == current_user.id\n end\n\n ahead_user_standings = standings[user_standing_index - 1]\n behind_user_standings = standings[user_standing_index + 1]\n\n ahead_user = User.find(ahead_user_standings.user_id)\n behind_user = User.find(behind_user_standings.user_id)\n\n @user_standing = {\n place: user_standing_index + 1,\n wins: standings[user_standing_index].wins\n }\n\n @current_week = Week.last\n games = Game.where(week_id: @current_week.id)\n @games = games.order(:game_finished, :date, :start_time)\n\n if games.order(updated_at: :desc).first\n @last_upd = games.order(updated_at: :desc).first.updated_at\n else\n @last_upd = @current_week.updated_at\n end\n\n @correct = 0\n ahead_correct = 0\n behind_correct = 0\n\n @picks = {}\n @games.each do |g|\n user_pick = g.picks.where(user_id: current_user.id)\n ahead_pick = g.picks.where(user_id: ahead_user.id)\n behind_pick = g.picks.where(user_id: behind_user.id)\n\n pick_count = g.picks.count.to_f\n away_count = g.picks.where(away_home: 'away').count.to_f\n home_count = g.picks.where(away_home: 'home').count.to_f\n\n if away_count > home_count\n field = \"#{g.away} (#{(away_count / pick_count) * 100}%)\"\n elsif home_count > away_count\n field = \"#{g.home} (#{(home_count / pick_count) * 100}%)\"\n else\n field = 'split 50/50'\n end\n\n if user_pick[0] != nil\n if user_pick[0].pick\n @picks[user_pick[0].game_id] = { \n :pick => user_pick[0].pick, \n :away_home => user_pick[0].away_home,\n :field => field\n }\n end\n\n if user_pick[0].tbreak_pts != nil\n @tbreak_pts = user_pick[0].tbreak_pts\n end\n\n if g[:game_finished] == true\n @correct += 1 if user_pick[0].away_home == g.winner\n ahead_correct += 1 if ahead_pick[0].away_home == g.winner\n behind_correct += 1 if behind_pick[0].away_home == g.winner\n end\n end\n end\n\n @ahead = {\n user: ahead_user.username,\n wins: ahead_user_standings.wins,\n correct_this_week: ahead_correct\n }\n\n @behind = {\n user: behind_user.username,\n wins: behind_user_standings.wins,\n correct_this_week: behind_correct\n }\n end", "def game_hash\n { #top-level hash = game_hash\n home: { # top-level key\n team_name: \"Brooklyn Nets\", # team-level key/value pairs \n colors: [\"Black\", \"White\"], # look, an array as a value\n players: [\n {\n player_name: \"Alan Anderson\",\n number: 0,\n shoe: 16,\n points: 22,\n rebounds: 12,\n assists: 12,\n steals: 3,\n blocks: 1,\n slam_dunks: 1\n }, {\n player_name: \"Reggie Evans\",\n number: 30,\n shoe: 14,\n points: 12,\n rebounds: 12,\n assists: 12,\n steals: 12,\n blocks: 12,\n slam_dunks: 7\n }, {\n player_name: \"Brook Lopez\",\n number: 11,\n shoe: 17,\n points: 17,\n rebounds: 19,\n assists: 10,\n steals: 3,\n blocks: 1,\n slam_dunks: 15\n }, {\n player_name: \"Mason Plumlee\",\n number: 1,\n shoe: 19,\n points: 26,\n rebounds: 12,\n assists: 6,\n steals: 3,\n blocks: 8,\n slam_dunks: 5\n }, {\n player_name: \"Jason Terry\",\n number: 31,\n shoe: 15,\n points: 19,\n rebounds: 2,\n assists: 2,\n steals: 4,\n blocks: 11,\n slam_dunks: 1\n }\n ]\n },\n away: {\n team_name: \"Charlotte Hornets\",\n colors: [\"Turquoise\", \"Purple\"],\n players: [\n {\n player_name: \"Jeff Adrien\",\n number: 4,\n shoe: 18,\n points: 10,\n rebounds: 1,\n assists: 1,\n steals: 2,\n blocks: 7,\n slam_dunks: 2\n }, {\n player_name: \"Bismak Biyombo\",\n number: 0,\n shoe: 16,\n points: 12,\n rebounds: 4,\n assists: 7,\n steals: 7,\n blocks: 15,\n slam_dunks: 10\n }, {\n player_name: \"DeSagna Diop\",\n number: 2,\n shoe: 14,\n points: 24,\n rebounds: 12,\n assists: 12,\n steals: 4,\n blocks: 5,\n slam_dunks: 5\n }, {\n player_name: \"Ben Gordon\",\n number: 8,\n shoe: 15,\n points: 33,\n rebounds: 3,\n assists: 2,\n steals: 1,\n blocks: 1,\n slam_dunks: 0\n }, {\n player_name: \"Brendan Haywood\",\n number: 33,\n shoe: 15,\n points: 6,\n rebounds: 12,\n assists: 12,\n steals: 22,\n blocks: 5,\n slam_dunks: 12\n }\n ]\n }\n }\nend", "def total_medals_per_team(olympic_data)\n\n team_medals_hash = {}\n\n olympic_data.each do |data|\n\n if team_medals_hash.key?(data[\"Team\"])\n if [\"Gold\", \"Silver\", \"Bronze\"].include?(data[\"Medal\"]) #SAME TEAM, MEDAL\n team_medals_hash[data[\"Team\"]] += 1\n end\n else\n\n if [\"Gold\", \"Silver\", \"Bronze\"].include?(data[\"Medal\"]) # NEW TEAM, MEDAL\n team_medals_hash[data[\"Team\"]] = 1\n else\n team_medals_hash[data[\"Team\"]] = 0\n\n end\n end\n end\n return team_medals_hash\nend" ]
[ "0.6799233", "0.6579108", "0.65554285", "0.64792335", "0.6328934", "0.63089025", "0.6281106", "0.627701", "0.6263929", "0.6234951", "0.62244684", "0.6215755", "0.6213788", "0.62107366", "0.62015295", "0.6201038", "0.61962277", "0.61788225", "0.6172803", "0.6172652", "0.616674", "0.61629534", "0.6160964", "0.61543643", "0.61492896", "0.61431485", "0.61157674", "0.6108842", "0.6108746", "0.6101296", "0.60996056", "0.6096406", "0.6093969", "0.60923696", "0.6090938", "0.6078329", "0.60736084", "0.6070994", "0.60552686", "0.6034936", "0.6029304", "0.60291743", "0.60153353", "0.60149074", "0.60115397", "0.5998179", "0.598994", "0.5971045", "0.5968683", "0.5968683", "0.59599495", "0.59472203", "0.59414595", "0.59384334", "0.5914539", "0.5912119", "0.5901599", "0.5896254", "0.58959067", "0.58959067", "0.58959067", "0.58959067", "0.58959067", "0.58959067", "0.58959067", "0.58959067", "0.58959067", "0.58959067", "0.58959067", "0.58959067", "0.58959067", "0.58959067", "0.58959067", "0.5888613", "0.58872676", "0.58797514", "0.587647", "0.5860714", "0.58511406", "0.5826794", "0.5821336", "0.5820999", "0.5809904", "0.58058286", "0.5802308", "0.5801412", "0.57902026", "0.57646954", "0.5764085", "0.57438034", "0.57358474", "0.5720403", "0.5716225", "0.57140094", "0.57096064", "0.5706095", "0.5692749", "0.568868", "0.5674533", "0.56693137", "0.5664606" ]
0.0
-1
returns a hash with key/value pairs for each of the attributes of a team
def team_info(team_id) team_info_hash(team_id) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def team_names\n array = [] \n game_hash.each do |team, attributes|\n attributes.each do |key, value|\n if key == :team_name\n array.push(value)\n \n end\n end\n end\n array\nend", "def team_names\n hash = game_hash\n array = []\n hash.each do |location, attributes|\n attributes.each do |attribute, info|\n if attribute == :team_name\n array << info\n end\n end\n end\n return array\nend", "def team_names\n names = []\n game_hash.each do | team, attributes|\n names << game_hash[team][:team_name]\n end\n return names\nend", "def team_names\n game_hash.collect do |location, attributes|\n attributes[:team_name]\n end\nend", "def team_names\n game_hash.collect do |team, all_info_hash|\n all_info_hash[:team_name]\n end\nend", "def team_colors(team_name)\n \n game_hash.each do |team, attributes|\n attributes.each do |key, value|\n if value == team_name \n return game_hash[team][:colors]\n \n end\n end\n end\n \nend", "def team_names\n team = []\n game_hash.values.each do |team_info|\n team << team_info[:team_name]\n end\n team\nend", "def team_names\n game_hash.map do |team, team_stats|\n team_stats[:team_name]\n end\nend", "def users_by_team\n result = {}\n \n memberships.each do |membership|\n result[membership.team] ||= []\n result[membership.team] << membership.user.nickname\n end\n \n result\n end", "def team_names\n teams.collect do|key|\n key[:team_name]\n end\nend", "def team_names\n team_name = []\n game_hash.each do |team,info|\n team_name << info[:team_name]\n end\n team_name\nend", "def rails_attributes\n [\"id\", \"team1\", \"team2\"]\n end", "def team_names\n data = game_hash\n all_teams = []\n \n data.each_pair do |home_away, home_away_hash|\n home_away_hash.each_pair do |team_key, team_value|\n \n if team_key == :team_name\n all_teams << team_value\n end\n \n end\n end\n all_teams\nend", "def team_names\n\tnew_hash = game_hash\n\tnew_hash.map{|key, value| new_hash[key][:team_name]}\nend", "def team_colors(team)\n game_hash.each do |location, attributes|\n if attributes[:team_name] == team\n return attributes[:colors]\n end\n end\nend", "def team_names\n game_hash.collect do |team_key, team_value|\n team_value[:team_name]\n end\nend", "def create_team(team_xml)\n team = Hash.new\n word_pattern = /[A-Za-z]/\n float_pattern = /([0-9]\\.)+/\n # put team info in a hash, convert it to the correct data type\n team_xml.attributes.each do |k, v|\n if word_pattern.match(v.value)\n team[k.to_sym] = v.value\n elsif float_pattern.match(v.value)\n team[k.to_sym] = v.value.to_f\n else\n team[k.to_sym] = v.value.to_i\n end\n end\n streak_xml = team_xml.xpath('streak').first\n word = streak_xml.xpath('win').empty? ? 'loss' : 'win'\n team[:streak] = create_streak(word, streak_xml.xpath(word).first)\n records = Hash.new\n %w(atlantic central conference division home last_10 last_10_home last_10_road metropolitan pacific road).each do |cat|\n records[cat.to_sym] = create_record(team_xml.xpath(\"records/#{cat}\").first)\n end\n team[:records] = records\n team\n end", "def teams\n game_hash.values\n end", "def team_names\n game_hash.map do |location, team_data|\n team_data[:team_name]\n end\nend", "def team_names\n game_hash.map do |location, team_data|\n team_data[:team_name]\n end\nend", "def all_teams_hash_by_leagues(league_ids)\n teams = {}\n league_ids.each do |league_id|\n teams_in_league = parse_api_request(\"#{BASE_URL}teams/league/#{league_id}\")[\"teams\"]\n teams_in_league.each {|team_data|\n teams[team_data[1][\"team_id\"]] = team_data[1][\"name\"]}\n end\n teams\nend", "def team_names\n game_hash.map do |place, team|\n team[:team_name]\n end\nend", "def team_names\n [\n game_hash.dig(:home, :team_name),\n game_hash.dig(:away, :team_name)\n ]\nend", "def team_names\n team_names = []\n \n game_hash.each do |key, value|\n team_names << value[:team_name]\n end\n team_names\nend", "def team_names\n game_hash.collect do |location, team_data|\n team_data[:team_name]\n end\nend", "def team_names\n team_names = []\n game_hash.each do |home_or_away, team_stats|\n team_names << team_stats[:team_name]\n end\n team_names\nend", "def rails_attributes\n [\"id\", \"param\", \"team1tot\",\"team2tot\"]\n end", "def team_names\n names = []\n game_hash.each do |k, team|\n names.push(team[:team_name])\n end\n names\nend", "def all_team_info(team_name)\n team_info = game_hash.find do |color, team_data|\n team_data[:team_name] == team_name\n end\n team_info[1]\nend", "def team_names\n # built an empty array called teams\n teams = []\n # game_hash.each do |team, random| iterates over the hash to return all of the team_names\n game_hash.each do |team, random|\n teams.push(game_hash[team][:team_name])\n end\n return teams\nend", "def player_numbers(team)\n player_numbers = []\n game_hash.each do |location, attributes|\n if attributes[:team_name] == team\n attributes[:players].each do |player, stats|\n player_numbers << stats[:number]\n end\n end\n end\n player_numbers\nend", "def team_names\n names = []\n game_hash.each do |location, data|\n names << data[:team_name]\n end\n names\nend", "def team_names\n arrayOfTeamNames = [] #initialize new hash\n arrayOfTeamNames << game_hash[:home][:team_name]\n arrayOfTeamNames << game_hash[:away][:team_name] #shovel it with the data\nend", "def team_names()\n result = []\n game_hash.each do |side,team|\n result.push(team[:team_name])\n end\n result\nend", "def team_names\n teams = []\n teams << game_hash[:home][:team_name]\n teams << game_hash[:away][:team_name]\n return teams\nend", "def team_colors(team_name)\n found_team = all_team_info(team_name)\n found_team[:colors]\nend", "def find_teams(league)\n teams = []\n league.each do |team|\n teams << team[:home_team]\n teams << team[:away_team]\n end\n uniq_teams = teams.uniq!\nend", "def team_colors (team_name)\n colors = nil\n game_hash.each do |team, all_info_hash|\n if all_info_hash[:team_name] == team_name\n colors = all_info_hash[:colors].flatten\n end\n end\n colors\nend", "def team_names\n teams = []\n teams << game_hash[:home][:team_name] << game_hash[:away][:team_name]\nend", "def teams_in_game(a_game)\n teams_in_game = {}\n a_game.game_teams.each do |game_team|\n team_in_game = @teams[game_team.name.to_sym]\n teams_in_game[game_team.name.to_sym] = team_in_game\n end\n teams_in_game\n end", "def teams\n standings_data = self.standings\n display_teams = []\n\n object.teams.each do |t|\n display_teams << t if standings_data[:data].key?(t.id) && standings_data[:data][t.id][:played] > 0\n end\n\n display_teams\n end", "def player_numbers(team_name)\n jersey_nums = []\n game_hash.each do |place, team|\n if team[:team_name] == team_name\n team.each do |attribute, player_info|\n if attribute == :players\n player_info.each do |data|\n jersey_nums << data[:number]\n end\n end\n end\n end\n end\n jersey_nums\nend", "def buildTeamToStandingsMap(year)\n teamToStandingsMap = {}\n\n MlbStanding.where(year: year).each do |mlbStanding|\n teamToStandingsMap[mlbStanding.mlb_team_id] = mlbStanding\n end\n return teamToStandingsMap\n end", "def team_names\n team_names = []\n #top level\n game_hash.each do |location, team_data|\n #2nd level\n team_data.each do |team_deets, values|\n #find team name pair\n if team_deets == :team_name\n team_names << team_data[team_deets]\n end\n end\n end\n team_names = team_names.flatten\nend", "def team_names\n team_names = []\n for location in game_hash.keys\n team_names.push(game_hash[location][:team_name])\n end\n return team_names\nend", "def team_names\n new_array = []\n game_hash.each do |k,v|\n new_array.push(v[:team_name])\n end\nnew_array\nend", "def team_colors(team_name)\n\tright_team = nil\n\tgame_hash.each do |home_or_away, data|\n\t\tdata.each do |attribute, value|\n\t\t\tif attribute == :team_name && value == team_name\n\t\t\t\tright_team = home_or_away\n\t\t\tend\n\t\tend\n\tend\n\treturn game_hash[right_team][:colors]\nend", "def team_names\n game_hash.collect {|home_or_away, stats| team_name = stats[:team_name].to_s}\nend", "def team_names\n # team_array = []\n # team_array.push(game_hash[:home][:team_name])\n # team_array.push(game_hash[:away][:team_name])\n # team_array\n game_hash.map do |location, team_data|\n team_data[:team_name]\n end\nend", "def team_colors(team)\n # PREVIOUS SOLUTION\n # if game_hash[:home][:team_name] == team\n\t# \tteam_colors = game_hash[:home][:colors]\n\t# elsif game_hash[:away][:team_name] == team\n\t# \tteam_colors = game_hash[:away][:colors]\n\t# end\n game_hash.each do |location, team_info_hash|\n # location = :home,:away; players_hash = :team_name, :colors, :players\n return team_info_hash[:colors] if team_info_hash[:team_name] == team\n end\nend", "def players_names_array \n player_names = []\n game_hash.each do |place,team|\n team.each do |attribute, data|\n next unless attribute == :players\n data.each do |player| \n player_names.push(player[:player_name])\n end\n end\n end\n player_names\nend", "def team_colors(team_name)\n result = nil\n game_hash.each do |team, about|\n if about[:team_name] == team_name\n result = about[:colors]\n end\n end\n result\nend", "def team_names \n # team_array = []\n # game_hash.each do |location, team_data|\n # team_array << team_data[:team_name]\n # end\n # team_array\n game_hash.collect do |location, team_data|\n team_data[:team_name]\n end\nend", "def team_colors(team_name)\n team_colors = nil\n game_hash.map do |team, team_stats|\n if team_stats[:team_name] == team_name\n team_colors = team_stats[:colors]\n end\n end\n team_colors\nend", "def team\n @team ||= Struct.new(:name, :domain).new(@team_name, @domain)\n end", "def team_names\n output =[]\n game_hash.each do |location, team_data|\n output.push(team_data[:team_name])\n end\n output\nend", "def player_data_by_team(team)\n players = []\n if team == game_hash[:home][:team_name]\n players << game_hash[:home][:players]\n else\n players << game_hash[:away][:players]\n end\n return players.flatten\nend", "def find_team_attribute_definitions(params={}, headers=default_headers)\n @logger.info(\"Finding Team Attribute Definitions\")\n get(\"#{@api_url}/teamAttributeDefinitions\", params, headers)\n end", "def team_names\n fin_arr = []\n fin_arr << game_hash[:home][:team_name]\n fin_arr << game_hash[:away][:team_name]\n fin_arr\nend", "def team_colors(team)\n game_hash.each do |side, value|\n if value[:team_name] == team\n return value[:colors]\n end\n end\n end", "def team_colors(team_name, game)\n return game[:home_team][:team_colors] if game[:home_team][:team_name] == team_name\n return game[:away_team][:team_colors] if game[:away_team][:team_name] == team_name\nend", "def both_team_names(game)\n both_teams = []\n both_teams << game[:home_team][:team_name]\n both_teams << game[:away_team][:team_name]\n both_teams\nend", "def team_colors(name_of_team)\n # using .each do |team, random| game_hash[team].each do |name, random| to iterate over each piece of data\n # then, if the name_of_team is equal to random, we'll get a return value of the colors of each team.\n game_hash.each do |team, random|\n game_hash[team].each do |name, random|\n if name_of_team == random\n return game_hash[team][:colors]\n end\n end\n end\nend", "def team_colors(team_name)\n game_hash.each do |place, team|\n if team[:team_name] == team_name\n return team[:colors]\n end\n end\nend", "def attributes\n super.merge({team_id: team_id})\n end", "def team_names\n new_array = []\n new_array<< game_hash[:home][:team_name]\n new_array<< game_hash[:away][:team_name]\n return new_array\nend", "def team_colors(team_name)\n team_colors =[]\n \n game_hash.each do |key, value|\n if team_name == value[:team_name]\n team_colors = value[:colors]\n end\n end\n team_colors\nend", "def team_colors(team)\n game_hash.each do |location, team_data|\n if team_data[:team_name] == team\n return team_data[:colors]\n end\n end\nend", "def one_team_stats(team_name)\n game_hash.each do |home_or_away, team_stats|\n if team_stats[:team_name] == team_name\n return team_stats\n end\n end\nend", "def to_attr_hash\n to_hash.reject { |key, _| %i[id live_games].include? key }\n end", "def buildMlbTeamNameToStandingMap(year)\n teamNameToStandingMap = {}\n MlbStanding.includes(:mlb_team).where(year: year).each do |mlb_standing|\n teamNameToStandingMap[mlb_standing.mlb_team.name] = mlb_standing\n end\n return teamNameToStandingMap\n end", "def team_names\n names = []\n game_hash.each do |location, team_hash|\n names << team_hash.fetch_values(:team_name)\n end\n \n names.flatten # flatten is necessary because fetch was putting two arrays inside names\n\nend", "def record_attrs\n %i[\n championship\n serie\n round\n team\n opponent\n id_match\n team_score\n opponent_score\n updates\n date\n start_at\n place\n ]\n end", "def all_players_for_a_team(team_name, game)\n player_names = []\n game[:home_team][:players].each do |player_hash|\n player_names << player_hash[:player_name] if game[:home_team][:team_name] == team_name\n end\n game[:away_team][:players].each do |player_hash|\n player_names << player_hash[:player_name] if game[:away_team][:team_name] == team_name\n end\n player_names\nend", "def team_names\n # team_array = []\n game_hash.map do |location, team_data|\n # p team_data[:team_name]\n team_data[:team_name]\n end\nend", "def player_collection \n all_players = [];\n game_hash.each_pair { |h_or_a, team_info|\n team_info[:players].map { |player|\n player[:location] = h_or_a;\n player[:team_name] = game_hash[h_or_a][:team_name];\n player[:team_colors] = game_hash[h_or_a][:colors];\n all_players << player;\n }\n }\n all_players; \nend", "def get_all_players\n ## Version 2.0 ##\n\n all_players = []\n\n # Same steps, but since we don't care about team, let's use .values to just\n # iterate over the team_data:\n game_hash.values.each do |team_data|\n team_data[:players].each do |player|\n all_players << player\n end\n end\n\n all_players\nend", "def teams\n @teams\n end", "def fetch_data(team, start, end_date)\n team.users.map do |u|\n { capacity: u.capacity(start, end_date),\n gravatar: u.gravatar_url,\n name: u.name }\n end\n end", "def player_stats(player_name)\nplayer_stats = {}\n game_hash.each do |location, attributes|\n attributes[:players].each do |player, stats|\n if player == player_name\n player_stats = stats\n end\n end\n end\n player_stats\nend", "def team_colors(team_name)\n team_color = []\n game_hash.find do |team,info|\n if info[:team_name] == team_name\n team_color = info[:colors]\n end\n info[:team_name] == team_name\n end\n team_color\nend", "def get_team_details(params)\n get('team', params)\n end", "def teams_data\n # selected_team = self.class.all[prompt.to_i-1]\n puts \"\"\n puts \"---------------------------\"\n puts \"Team Name: \" + self.full_name\n puts \"City: \" + self.city\n puts \"Division: \" + self.division\n puts \"Conference: \" + self.conference\n puts \"\"\n puts \"---------------------------\"\n end", "def get_all_players\n ## Version 2.0 ##\n\n # Same steps, but with a slight tweak...\n all_players = {}\n\n # We don't need team. We only want to loop through the data.\n # So, why don't we use .values to and then just loop through the values\n # in the hash!\n game_hash.values.each do |team_data|\n all_players.merge! team_data[:players]\n end\n\n all_players\nend", "def total_medals_per_team(olympic_data)\n\n team_medals_hash = {}\n\n olympic_data.each do |data|\n\n if team_medals_hash.key?(data[\"Team\"])\n if [\"Gold\", \"Silver\", \"Bronze\"].include?(data[\"Medal\"]) #SAME TEAM, MEDAL\n team_medals_hash[data[\"Team\"]] += 1\n end\n else\n\n if [\"Gold\", \"Silver\", \"Bronze\"].include?(data[\"Medal\"]) # NEW TEAM, MEDAL\n team_medals_hash[data[\"Team\"]] = 1\n else\n team_medals_hash[data[\"Team\"]] = 0\n\n end\n end\n end\n return team_medals_hash\nend", "def team_colors(user_team_name)\n game_hash.each do |k, team|\n if team[:team_name] == user_team_name\n return team[:colors]\n end\n end\nend", "def raw_players_and_stats(data)\n # Need to put team_players_members inside an array to group the 2 team arrays together\n all_players_stats = []\n \n data.each_pair do |team, team_stats|\n team_stats.each_pair do |team_players, team_players_members|\n \n if team_players == :players \n \tall_players_stats << team_players_members \n end\n \n end\n end\n all_players_stats\nend", "def team_names(hashketball)\r\n puts \"The #{hashketball[:home][:team_name]} welcome the #{hashketball[:away][:team_name]}\"\r\n puts \r\nend", "def find_team_values\n #sets the total investments as an empty hash\n team_investments = {}\n #iterates through every team\n @teams.each do |team, value|\n #initializes the value for the team\n investment_values = 0\n #finds every investment for the team\n Investment.where(team_id: team.id).each do |i|\n #only adds the investment if it is in the selected quarter\n Feature.find(i.feature_id).quater == @quater ? investment_values += i.investment : a=0\n end\n team_investments[team.id] = investment_values\n end\n return team_investments\n end", "def team_members\n @team_members ||= team.map { |key, value| value unless key == 'private' }\n .compact\n .concat((team['private'] || {}).values)\n end", "def player_stats(player_name)\n player_stats = {}\n game_hash.each do |team, all_info_hash|\n all_info_hash[:players].each do |stats|\n if stats[:player_name] == player_name\n player_stats = stats\n end\n end\n end\n player_stats\nend", "def buildTeamToWinMap(year)\n teamToWinMap = {}\n MlbWin.where(year: year).each do |win|\n teamToWinMap[win.mlb_team_id] = win\n end\n return teamToWinMap\n end", "def team\n fetch('esport.teams')\n end", "def teams\n synchronize { return @teams if @teams }\n\n teams = {}\n orgs = settings.github_orgs || []\n orgs.each do |org|\n octokit.organization_teams(org).each do |team|\n team = team.to_h\n team[:organization] = org\n teams[team[:id]] = team\n end\n end\n\n synchronize { @teams = teams }\n end", "def player_numbers(input_team)\nnumbers = []\ngame_hash.each do |place, team|\n if team[:team_name] == input_team\n team.each do |attribute, data|\n next unless attribute == :players\n data.each do |player| #passing through an array \n numbers.push(player[:number])\n end \n end\n end\n end\nnumbers\nend", "def team_names\n cala=[]\n game_hash.each do |status,information|\n # puts status\n # puts information[:team_name]\n cala<< information[:team_name]\n end\n p cala\nend", "def team_colors(team_name)\n one_team_stats(team_name)[:colors]\nend", "def call stat\n data = Hash.new { |h, k| h[k] = {} }\n @matches.each do |m|\n teams = [m.home_team, m.away_team]\n scaffs = StatScaffold.call(teams)\n scaffs[m.home_id], scaffs[m.away_id] = StatParser.call(m, scaffs[m.home_id], scaffs[m.away_id])\n data[m.home_team.name][m.round] = scaffs[m.home_id][stat]\n data[m.away_team.name][m.round] = scaffs[m.away_id][stat]\n end\n data.map {|team| {:name => team[0], :data => team[1]}}\n end", "def player_data\n players = []\n game_hash.each do |home_away, team_details|\n players << team_details[:players]\n end\n return players.flatten\nend", "def team_colors(team_name)\n game_hash.each do |home_away, keys|\n if keys[:team_name] == team_name\n return keys[:colors].map(&:capitalize)\n end\n end\nend" ]
[ "0.7650856", "0.7482051", "0.7402176", "0.7116695", "0.6868259", "0.6865669", "0.68168306", "0.6794725", "0.6773995", "0.67668587", "0.67591715", "0.66435635", "0.6642832", "0.66403997", "0.6618498", "0.6599596", "0.6591629", "0.659084", "0.65677464", "0.65677464", "0.6520581", "0.6500077", "0.6465441", "0.6456497", "0.6435059", "0.6384854", "0.637849", "0.6361671", "0.63577414", "0.6351465", "0.6331028", "0.6313179", "0.62918514", "0.6286779", "0.62781787", "0.6259385", "0.62352955", "0.62175804", "0.62133795", "0.6163206", "0.6092087", "0.6085348", "0.6081463", "0.6076072", "0.607195", "0.6053488", "0.6012417", "0.6001817", "0.5998652", "0.5991153", "0.5984708", "0.598295", "0.59825027", "0.5980472", "0.5970112", "0.59663045", "0.595809", "0.59565747", "0.5925074", "0.5910191", "0.59099555", "0.5909108", "0.58974415", "0.5889193", "0.5888972", "0.5878732", "0.5875115", "0.585884", "0.58560413", "0.585495", "0.58538455", "0.58361876", "0.5830499", "0.581049", "0.58094996", "0.58058625", "0.5798141", "0.579594", "0.57942295", "0.5785663", "0.57769084", "0.57575345", "0.57556003", "0.5753689", "0.57536316", "0.57517505", "0.5741006", "0.5734819", "0.57182354", "0.5717272", "0.5710549", "0.57083404", "0.5705235", "0.56997937", "0.5698941", "0.5690973", "0.5688564", "0.56741434", "0.5673657", "0.5669653" ]
0.6650423
11
returns the season with the highest win percentage for a team
def best_season(team_id) team_id = team_id.to_i team = @teams.select { |each_team| each_team.team_id == team_id }.first team.season_win_percentages.max_by { |season, percentage| percentage }.first.to_s end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def worst_season(team_id)\n team_id = team_id.to_i\n team = @teams.select { |each_team| each_team.team_id == team_id }.first\n team.season_win_percentages.min_by { |season, percentage| percentage }.first.to_s\n end", "def best_season(id)\n wins = total_wins_per_team_per_season(id)\n totals = total_games_per_team_per_season(id)\n totals.each do |season, total|\n totals[season] = (wins[season] / total.to_f * 100).round(2)\n end\n totals.max_by {|k,v| v}[0]\n end", "def winningest_team\n @teams.max_by { |team| team.total_win_percentage }.team_name\n end", "def most_accurate_team(seasonasstring) # shots in game team stats\n #get a list of all teams that played in that season - given by arg\n #use above list to sum all shots across all games in season\n #divide above by goals made across all games in season\n #find highest percentage\n #return team name as found in 127\n end", "def biggest_surprise(season)\n season = season.to_i\n @teams.max_by{ |team| team.preseason_to_regular_increase[season] }.team_name\n end", "def season_with_most_games\n seasons = @games.group_by { |game| game.season }\n seasons.max_by { |season, games| games.count }.first\n end", "def highest_scoring_visitor\n @teams.max_by { |team| team.average_away_goals }.team_name\n end", "def biggest_bust(season)\n season = season.to_i\n @teams.min_by{ |team| team.preseason_to_regular_increase[season] }.team_name\n end", "def best_offense\n @teams.max_by { |team| team.average_goals_scored }.team_name\n end", "def worst_offense\n @teams.min_by { |team| team.average_goals_scored }.team_name\n end", "def most_hits(seasonasstring) # shots in game team stats\n #get a list of all teams that played in that season\n #use above list to sum all shots across all games in season\n #find highest across list\n #return team name as found in 139\n end", "def highest_scoring_home_team\n @teams.max_by { |team| team.average_home_goals }.team_name\n end", "def worst_defense\n @teams.max_by { |team| team.average_goals_allowed }.team_name\n end", "def worst_offense\n teams_total_goals = total_goals_helper\n teams_total_games = total_games_helper\n\n worst_team_goals_avg = 1000\n worst_offense_team_id = 0\n this_team_goals_avg = 0\n\n teams_total_games.each do |games_key, games_value|\n teams_total_goals.each do |goals_key, goals_value|\n if goals_key == games_key\n this_team_goals_avg = (goals_value / games_value.to_f)\n if this_team_goals_avg < worst_team_goals_avg\n worst_team_goals_avg = this_team_goals_avg\n worst_offense_team_id = games_key\n end\n end\n end\n end\n\n team_with_worst_offense = nil\n self.teams.each_value do |team_obj|\n if team_obj.team_id. == worst_offense_team_id\n team_with_worst_offense = team_obj.team_name\n end\n end\n team_with_worst_offense\n end", "def biggest_bust(seasonasstring)\n #get all teams in data\n #find all games played by team in season - given by arg\n #get subset of 95 where p is in season marker\n #count games won in subset on 95 / total games in subset on 95\n #get subset of 85 where r is in season marker\n #count games won in subset on 98 / total games in subset on 98\n #result of line 97 - line 99\n #find highest number\n #return team name of result of line 101\n end", "def best_fans\n @teams.max_by { |team| team.home_minus_away_percentage }.team_name\n end", "def determine_winner game\n winner = game.max_by {|team| team[:score]}\n team_standings = get_team_by_name(winner)\n team_standings[:winnings] += 3\nend", "def winning_team\n self.teams.order('score DESC').first\n end", "def worst_defense\n teams_total_goals_allowed = total_goals_allowed_helper\n teams_total_games = total_games_helper\n\n worst_team_goals_allowed_avg = 0\n worst_defense_team_id = 0\n this_team_goals_allowed_avg = 0\n\n teams_total_games.each do |games_key, games_value|\n\n teams_total_goals_allowed.each do |goals_key, goals_value|\n if goals_key == games_key\n this_team_goals_allowed_avg = (goals_value / games_value.to_f)\n if this_team_goals_allowed_avg > worst_team_goals_allowed_avg\n worst_team_goals_allowed_avg = this_team_goals_allowed_avg\n worst_defense_team_id = games_key\n end\n end\n end\n end\n team_with_worst_defense = team_name_finder_helper(worst_defense_team_id)\n\n team_with_worst_defense\n end", "def least_accurate_team(seasonasstring) # shots in game team stats\n #inverse of above\n end", "def high_score\n if self.end_date < Date.today\n self.teams.max_by { |team| team.score }.score\n end\n end", "def best_defense\n teams_total_goals_allowed = total_goals_allowed_helper\n teams_total_games = total_games_helper\n\n best_team_goals_allowed_avg = 100\n best_defense_team_id = 0\n this_team_goals_allowed_avg = 0\n\n teams_total_games.each do |games_key, games_value|\n teams_total_goals_allowed.each do |goals_key, goals_value|\n if goals_key == games_key\n this_team_goals_allowed_avg = (goals_value / games_value.to_f)\n if this_team_goals_allowed_avg < best_team_goals_allowed_avg\n best_team_goals_allowed_avg = this_team_goals_allowed_avg\n best_defense_team_id = games_key\n end\n end\n end\n end\n\n team_with_best_defense = nil\n self.teams.each_value do |team_obj|\n if team_obj.team_id. == best_defense_team_id\n team_with_best_defense = team_obj.team_name\n end\n end\n team_with_best_defense\n end", "def season_with_fewest_games\n seasons = @games.group_by { |game| game.season }\n seasons.min_by { |season, games| games.count }.first\n end", "def worst_loss(team_id)\n @games.map do |game|\n if game.away_team_id.to_s == team_id\n game.home_goals - game.away_goals\n elsif game.home_team_id.to_s == team_id\n game.away_goals - game.home_goals\n end\n end.compact.max\n end", "def best_defense\n @teams.min_by { |team| team.average_goals_allowed }.team_name\n end", "def biggest_suprise(seasonasstring)\n #as above, but change line 100 to reverse operations, regular percentage - postseason percentage\n end", "def winner\n @players.max_by do |player|\n player.score\n end\n end", "def average_win_percentage(team_id)\n team_id = team_id.to_i\n team = @teams.select { |each_team| each_team.team_id == team_id }.first\n team.total_win_percentage.round(2)\n end", "def favorite_opponent(team_id)\n team_id = team_id.to_i\n team = @teams.select { |each_team| each_team.team_id == team_id }.first\n favorite_opponent_id = team.matchup_win_percentage.max_by{|each_team, percentage| percentage}.first\n @teams.select { |each_team| each_team.team_id == favorite_opponent_id }.first.team_name\n end", "def winner\n @players.max_by{ |player| player.score}\n end", "def highest_player_score\n players.max_by{|player| player.score}.score\n end", "def most_goals_scored(team_id)\n team_id = team_id.to_i\n goals_per_game = @game_teams.map do |game|\n if game.team_id == team_id\n game.goals\n end\n end\n goals_per_game.compact.max\n end", "def coach_win_percent_in_season(coach, game_ids)\n (total_wins_of_coach_in_season(coach, game_ids) / total_coach_games_in_season(coach, game_ids).to_f).round(2)\n end", "def winning_team\n final_scores = player_collection.reduce(home: 0, away: 0) { |teams_points, next_player|\n case \n when next_player[:location] === :away\n teams_points[:away] += next_player[:points];\n when next_player[:location] === :home\n teams_points[:home] += next_player[:points];\n end\n teams_points; \n }\n winner = final_scores.reduce { |highest_points, team_points| \n highest_points[1] > team_points[1] ? highest_points : team_points; \n }\n game_hash[winner[0]][:team_name]; \nend", "def player_w_biggest_feet\n all_players[1].max_by { |stats| stats[:shoe] }\n end", "def find_best_score(total_per_player)\n best_score = 0\n winner = ''\n total_per_player.each do |player_name,total|\n\n if total > best_score\n best_score = total\n winner = player_name\n end\n end\n return winner\n end", "def worst_coach(seasonasstring) # coach name in game team stats\n #inverse of above\n end", "def score_for_team(team)\n team ||= winner_team\n winner_team?(team) ? score : scores.reverse.join(':')\n end", "def winning_team\n home_points = collection_by_prop(game_hash[:home], :points).reduce(0, :+)\n away_points = collection_by_prop(game_hash[:away], :points).reduce(0, :+)\n home_points > away_points ? game_hash[:home][:team_name] : game_hash[:away][:team_name]\n end", "def biggest_blowout\n score_difference = games.map { |game| (game.home_goals - game.away_goals).abs}\n score_difference.max\n end", "def most_popular_venue\n venues = @games.group_by { |game| game.venue}\n venues.max_by { |venue, games| games.count }.first\n end", "def winningest_coach(seasonasstring) # coach name in game team stats\n #per season, get list of all coaches - given by arg\n #per coach, find all games played by that coach\n #then count of all games won / count of all games played\n #find highest\n #return name of coach found in 114\n end", "def winner_team(game)\n result = nil\n if game.team1_goals.present? && game.team2_goals.present?\n result = game.team1 if game.team1_goals > game.team2_goals\n result = game.team2 if game.team1_goals < game.team2_goals\n end\n\n result\n end", "def lowest_scoring_visitor\n @teams.min_by { |team| team.average_away_goals }.team_name\n end", "def rival(team_id)\n team_id = team_id.to_i\n team = @teams.select { |each_team| each_team.team_id == team_id }.first\n rival_id = team.matchup_win_percentage.min_by{|each_team, percentage| percentage}.first\n @teams.select { |each_team| each_team.team_id == rival_id }.first.team_name\n end", "def most_points_scored\n max = nil\n name = nil \n game_hash.each do |team, team_values|\n team_values[:players].each do |player|\n if max == nil || player[:points] > max\n max = player[:points]\n name = player[:player_name]\n end\n end\n end\n name\nend", "def biggest_team_blowout(team_id)\n @games.map do |game|\n if game.away_team_id.to_s == team_id\n game.away_goals - game.home_goals\n elsif game.home_team_id.to_s == team_id\n game.home_goals - game.away_goals\n end\n end.compact.max\n end", "def mostSteals\n players.max_by do|name, stats|\n stats[:steals]\n end\nend", "def get_standings(games)\n teams = Hash.new\n games.each do |game|\n division_id = game.division_id\n home_team = game.home_team\n away_team = game.visiting_team\n if(teams[home_team.name].nil?)\n teams[home_team.name] = {:win => 0, :loss => 0, :tie => 0, :point=> 0}\n end\n\n if(teams[away_team.name].nil?)\n teams[away_team.name] = {:win => 0, :loss => 0, :tie => 0, :point => 0}\n end\n if(game.home_team_score && game.visiting_team_score)\n if(game.home_team_score > game.visiting_team_score)\n # home team won\n teams[home_team.name][:win] += 1\n teams[home_team.name][:point] += 5\n # visiting team loss\n teams[away_team.name][:loss] += 1\n elsif(game.home_team_score < game.visiting_team_score)\n # home team loss\n teams[home_team.name][:loss] += 1\n #visiting team won\n teams[away_team.name][:win] += 1\n teams[away_team.name][:point] += 5\n else\n # tie game\n teams[home_team.name][:tie] += 1\n teams[home_team.name][:point] += 1\n teams[away_team.name][:tie] += 1\n teams[away_team.name][:point] += 1\n end\n end\n end\n teams.each do |team, value|\n puts team\n total_games = value[:win] + value[:loss] + value[:tie]\n if total_games > 0 \n win_percentage = value[:win]/total_games.to_f\n else\n win_percentage = 0\n end \n value[:percentage] = win_percentage\n end\n teams_sorted = teams.sort_by{ |k, v| v[:point]}.reverse\n return teams_sorted\n end", "def most_points_scored\n stat_by_player = collect_stat_by_name(:points)\n player_with_max_stat = find_max_stat_by_player(stat_by_player)\n player_with_max_stat\nend", "def determine_match_winner\n @games_to_win = ((total_number_of_games / 2.0).floor) + 1\n if player1.score == games_to_win\n return player1\n elsif player2.score == games_to_win\n return player2\n else\n return nil\n end\n end", "def winner\n\t\ts = {}\n\t\t@vPlayers.each {|player|\n\t\t\ts[player.name.to_s] = player.score.totalScore\n\t\t}\n\t\tmax = s.values.max\n\t\tname = s.select{|k, v| v == max}.keys\n\t\tscore = s.select{|k, v| v == max}.values\n\t\t\n\t\tprint \"The winner is \" + name[0].to_s + \" with a total score of \" + score[0].to_s\n\t\tputs \"\",\"\"\n\t\t\n\tend", "def fewest_hits(seasonasstring) # shots in game team stats\n #inverse of above\n end", "def highest_total_score\n @game_manager.highest_total_score\n end", "def worst_fans\n teams_with_bad_fans = @teams.find_all { |team| team.home_minus_away_percentage.negative? }\n teams_with_bad_fans.map { |team| team.team_name }\n end", "def winning_scores\n high_score = scores.max{|score| score.total}.total\n scores.select {|score| score.total == high_score}\n end", "def stats_vs_team(team, season = nil)\n id = find_id(team, Team)\n data = stats_request(\"vsTeam\", season)\n data.find do |s| s[\"opponent\"][\"id\"] == id end\n end", "def ranks\n @teams = Team.where(\"wins > 0\t\").order(win_percentage: :desc)\n end", "def calculate_overall_winner\n points_per_player = {}\n @matches.each do | match |\n !points_per_player[match.winner].nil? ? (points_per_player[match.winner] += 1) : (points_per_player[match.winner] = 1)\n end\n max_points = points_per_player.values.max\n points_per_player.key(max_points)\n end", "def winning_team\n blue_team.winner? ? blue_team : red_team\n end", "def compute_team_winner\n if completed?\n team_winner\n else\n if first_team && second_team\n if sets_won(first_team) == min_sets_to_play\n first_team\n elsif sets_won(second_team) == min_sets_to_play\n second_team\n end\n end\n end\n end", "def retrieve_season_hall_of_fame\n seasons_hall_of_fame = []\n get_involved_teams unless @involved_teams\n\n @involved_teams.each do |team|\n team_placement = {}\n team_placement[:team] = team\n %w[first_place second_place third_place].each_with_index do |rank, index|\n placement = index + 1\n team_placement[rank.to_sym] = team.computed_season_ranking.joins(:season).where(\"seasons.season_type_id = #{@season_type.id} AND computed_season_rankings.rank = #{placement}\").count\n end\n seasons_hall_of_fame << team_placement\n end\n seasons_hall_of_fame.sort { |p, n| (n[:first_place] * 10_000 + n[:second_place] * 100 + n[:third_place]) <=> (p[:first_place] * 10_000 + p[:second_place] * 100 + p[:third_place]) }\n end", "def player_win_percentage\n (games_won/user_games)\n end", "def biggestShoes\n players.max_by do|name, stats|\n stats[:shoe]\n end\nend", "def winning_team\n home_team_points = game_hash[:home][:players].sum { |e| e[:points] }\n away_team_points = game_hash[:away][:players].sum { |e| e[:points] }\n\n if home_team_points > away_team_points\n return game_hash[:home][:team_name]\n else\n return game_hash[:away][:team_name]\n end\nend", "def highest_total_score\n total_goals.max\n end", "def max_teams(rounds)\n 2**rounds\n end", "def max_teams(rounds)\n 2**rounds\n end", "def winning_player\n played_cards.max_by { |_, card| card_scores[card] }.first\n end", "def most_points_scored\n points_scored = 0 # starting score to compare with players shoe sizes\n game_hash.each do |location, team_data| # iterates through each team\n players_array = team_data[:players] # finds the :players info in team_data and puts the players into players_array\n players_array.each do |player_name, data| # iterates through each player..\n if data[:points] > points_scored # if their points scored is greater than 0 (we set this earlier in the top of method)\n points_scored = data[:shoe] # take that players score and make it the new points_scored value\n end # this repeats (iterates) through all players until you don't have any more.. meaning the end result is\n end # the player with the highest score\n end\n return points_scored\nend", "def winning_team_with_spread\n\t\tif self.final?\n\t\t\treturn home_team_id if home_team_score > away_team_score + point_spread\n\t\t\treturn away_team_id if away_team_score + point_spread > home_team_score\n\t\t\treturn \"tie\" if home_team_score == away_team_score + point_spread\n\t\telse\n\t\t\treturn nil\n\t\tend\n\tend", "def percentage_visitor_wins\n visitor_wins = @teams.map { |team| team.away_wins }.sum\n visitor_games = @teams.map { |team| team.away_games }.sum\n (visitor_wins.to_f / visitor_games.to_f).round(2)\n end", "def lowest_scoring_home_team\n @teams.min_by { |team| team.average_home_goals }.team_name\n end", "def winner\n if (self.homeScore > self.awayScore)\n return self.home_team\n elsif (self.awayScore > self.homeScore)\n return self.away_team\n else\n return nil\n end\n end", "def best_offense\n offense_suite\n best_offense_id = @average_goals_by_id.invert.max[1]\n @team_name_by_id[best_offense_id]\n end", "def win_percent\n matchmade_games < 1 ? 0 : ((total_exp.to_f/matchmade_games.to_f) * 100).to_d\n end", "def avg_of_toryo_turn_max\n s = lose_scope\n s = s.joins(:battle)\n s = s.where(Swars::Battle.arel_table[:final_key].eq(\"TORYO\"))\n if v = s.average(Swars::Battle.arel_table[:turn_max])\n v.to_i\n end\n end", "def winning_team\n team_p = []\n team_n = []\n\n game_hash.each do | location, team_data|\n temp = 0\n team_data[:players].each do |p_name, stats|\n temp += stats[:points]\n end\n team_n << team_data[:team_name]\n team_p << temp\n end\n\n team_p[0] > team_p[1] ? team_n[0] : team_n[1]\n\nend", "def get_win_percentage(strategy)\n score = 0\n @turns.each do |t|\n score += t.result.to_i if t.strategy.include?(strategy)\n end\n score\n end", "def season_summary(season, team_id)\n season = season.to_i\n team_id = team_id.to_i\n season_summary_hash(season, team_id)\n end", "def most_points_scored\n most_points = 0\n most_points_player = nil\n game_hash.each do |team, team_stats|\n team_stats[:players].each do |player_stats|\n if most_points < player_stats[:points]\n most_points = player_stats[:points]\n most_points_player = player_stats[:player_name]\n end\n end\n end\n most_points_player\nend", "def percent_wins(wins)\n ((wins.to_f / @num_games.to_f) * 100).round(4)\n end", "def bp_odds_on_favorite\n\t\tfav_team=Teamseason.new\n\t\tfav_team.year=self.matchup_year\n\t\tfav_team.team=self.favorite \n\t\tunderdog_team=Teamseason.new\n\t\tunderdog_team.year=self.matchup_year\n\t\tunderdog_team.team=self.underdog\n\t\treturn fav_team.bp_ros_win_pct.to_f.odds_against_opponent(underdog_team.bp_ros_win_pct.to_f)\n\tend", "def power_play_goal_percentage(seasonasstring) # power_play info in game team stat\n #find list of all games in season given by arg\n #sum all power play goals\n #sum all power play oppertunities\n #divide line 146 and line 147\n #return total of above\n end", "def per_game_stats(season = nil)\n season_id = season ? season.id : Season.current.id\n StatLine.find_by_sql('SELECT AVG(fgm) as fgm, AVG(fga) as fga, coalesce(AVG(fgm)/nullif(AVG(fga), 0), 0) as fgpct, AVG(twom) as twom, AVG(twoa) as twoa, coalesce(AVG(twom)/nullif(AVG(twoa), 0), 0) as twopct, AVG(threem) as threem, AVG(threea) as threea, coalesce(AVG(threem)/nullif(AVG(threea), 0), 0) as threepct,' \\\n 'AVG(ftm) as ftm, AVG(fta) as fta, coalesce(AVG(ftm)/nullif(AVG(fta), 0), 0) as ftpct, AVG(orb) as orb, AVG(drb) as drb, AVG(trb) as trb, AVG(ast) as ast, AVG(stl) as stl, AVG(blk) as blk, AVG(fl) as fl, AVG(\"to\") as to,' \\\n 'AVG(points) as points, COUNT(*) as game_count, sums.league_id FROM (SELECT SUM(fgm) as fgm, SUM(fga) as fga, SUM(twom) as twom, SUM(twoa) as twoa, SUM(threem) as threem, SUM(threea) as threea,' \\\n 'SUM(ftm) as ftm, SUM(fta) as fta, SUM(orb) as orb, SUM(drb) as drb, SUM(trb) as trb, SUM(ast) as ast, SUM(stl) as stl, SUM(blk) as blk, SUM(fl) as fl, SUM(\"to\") as to,' \\\n \"SUM(points) as points, g.league_id as league_id FROM stat_lines sl INNER JOIN games g ON sl.game_id = g.id \" \\\n \"WHERE g.winner is not null AND (g.forfeit is null or not g.forfeit) AND (sl.dnp is null OR not sl.dnp) AND team_id = #{self.id} AND g.season_id = #{season_id} GROUP BY game_id, g.league_id) sums GROUP BY sums.league_id\")\n end", "def winning_team\n if homeTeamPoints.sum > awayTeamPoints.sum\n \"Brooklyn Nets\"\n else\n \"Charlotte Hornets\"\n end\nend", "def rank_top_teams # DO NOT USE THIS METHOD, outdated, slow\n @top_teams = {}\n @top_teams = Score.in_challenge(self.id).teams_in_all_divisions.limit(5).\n order(\"sum_points DESC, MAX(#{Score.table_name}.\n earned_at) DESC\").sum(:points) \n return @top_teams\n end", "def get_max_over(stat)\n max = 0\n $data_enemies.each { |enemy|\n next if enemy.nil?\n next if enemy.hidden_best\n next unless $game_party.known_enemy?(enemy.id)\n value = enemy.get_stat(stat)\n max = value if value > max\n }\n max\n end", "def calculate_most_common_year\n self.calculate_plays_by_year.sort_by{ |year, times_played| times_played }.last\n end", "def most_points_scored\nbest_player = \"\"\npoints = 0\ngame_hash.each do |location, team_data|\n team_data[:players].each do |name, stats|\n if stats[:points] > points\n points = stats[:points]\n best_player= name\n end\n end\nend\nbest_player\nend", "def fewest_goals_scored(team_id)\n team_id = team_id.to_i\n goals_per_game = @game_teams.map do |game|\n if game.team_id == team_id\n game.goals\n end\n end\n goals_per_game.compact.min\n end", "def winning_team\n nets = []\n hornets = []\n\n game_hash.values.each do |nets_stats|\n if nets_stats[:team_name] == \"Brooklyn Nets\"\n nets_stats[:players].each do |bk|\n nets << bk[:points]\n end\n end\n end\n\n game_hash.values.each do |hornets_stats|\n if hornets_stats[:team_name] == \"Charlotte Hornets\"\n hornets_stats[:players].each do |ch|\n hornets << ch[:points]\n end\n end\n end\n\n if nets.reduce(:+) > hornets.reduce(:+)\n return \"Brooklyn Nets\"\n else\n return \"Charlotte Hornets\"\n end\nend", "def max_score\n return score if @state != STATE_OK\n\n next_boards.map(&:min_score).min\n end", "def winning_team\n home_team_sum = 0\n away_team_sum = 0\n game_hash.each do |team, team_stats|\n if team_stats[:team_name] == \"Brooklyn Nets\"\n team_stats[:players].each do |player_stats|\n home_team_sum += player_stats[:points]\n end\n elsif team_stats[:team_name] == \"Charlotte Hornets\"\n team_stats[:players].each do |player_stats|\n away_team_sum += player_stats[:points]\n end\n end\n end\n if home_team_sum > away_team_sum\n game_hash[:home][:team_name]\n elsif home_team_sum < away_team_sum\n game_hash[:away][:team_name]\n end\nend", "def total_team_score(teams_id)\n total_score = 0\n @league_data.each do\n |team| \n # binding.pry\n if team.home_team_id == teams_id\n total_score += team.home_team_score\n elsif team.away_team_id == teams_id\n total_score += team.away_team_score\n end\n end\n return total_score\n end", "def get_highest_for(turn)\n\t\tif @highs[1][turn] > @highs[2][turn] then 1 else 2 end\n\tend", "def worst_case board\n\t\tworst = 0\n\t\topp_board = board.rotate 7\n\t\t6.times {|i|\n\t\t\t\ts = score_for(opp_board, i)\n\t\t\t\tworst = s if worst < s\n\t\t\t}\n\t\t\tworst\n\tend", "def percentage_home_wins\n home_wins = @teams.map { |team| team.home_wins }.sum\n home_games = @teams.map { |team| team.home_games }.sum\n (home_wins.to_f / home_games.to_f).round(2)\n end", "def pri_toff\n team_stats.goals_per_game / team_stats.opp_avg_goals_per_game\n end", "def biggest_investment\n self.funding_rounds.max_by do |round|\n round.startup.uniq \n end\n end" ]
[ "0.85101134", "0.81221753", "0.8106581", "0.79300624", "0.78303117", "0.7537648", "0.7438727", "0.74318486", "0.7318221", "0.7310928", "0.72841966", "0.7256713", "0.7243815", "0.71725464", "0.71719307", "0.71607524", "0.7129009", "0.70744485", "0.703709", "0.69910413", "0.6959619", "0.6924638", "0.68819284", "0.6875261", "0.684171", "0.68195635", "0.6809851", "0.68058467", "0.67805815", "0.6770948", "0.66741234", "0.66632533", "0.6609532", "0.6571148", "0.65465856", "0.6543638", "0.65435356", "0.6498457", "0.6493484", "0.648479", "0.64601475", "0.64597124", "0.64504397", "0.64480644", "0.6435237", "0.6435073", "0.6412982", "0.63959754", "0.6391527", "0.63911325", "0.63810426", "0.63803554", "0.6360707", "0.635309", "0.6340772", "0.63404757", "0.633108", "0.6323255", "0.6319748", "0.6313981", "0.6311029", "0.6306651", "0.62990785", "0.62958145", "0.6282052", "0.6279038", "0.62696934", "0.62696934", "0.6268859", "0.6265716", "0.62613815", "0.62601763", "0.6244919", "0.6241598", "0.6232759", "0.62320644", "0.6221237", "0.62193894", "0.6197862", "0.6184789", "0.61752945", "0.61685187", "0.61602676", "0.61240077", "0.61233383", "0.61148316", "0.61089814", "0.60995835", "0.60955846", "0.6089361", "0.6087244", "0.60740674", "0.606924", "0.6067531", "0.60633063", "0.6060315", "0.60506296", "0.60440785", "0.60279626", "0.60200775" ]
0.8627173
0
returns the season with the lowest win percentage for a team
def worst_season(team_id) team_id = team_id.to_i team = @teams.select { |each_team| each_team.team_id == team_id }.first team.season_win_percentages.min_by { |season, percentage| percentage }.first.to_s end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def best_season(team_id)\n team_id = team_id.to_i\n team = @teams.select { |each_team| each_team.team_id == team_id }.first\n team.season_win_percentages.max_by { |season, percentage| percentage }.first.to_s\n end", "def best_season(id)\n wins = total_wins_per_team_per_season(id)\n totals = total_games_per_team_per_season(id)\n totals.each do |season, total|\n totals[season] = (wins[season] / total.to_f * 100).round(2)\n end\n totals.max_by {|k,v| v}[0]\n end", "def lowest_scoring_visitor\n @teams.min_by { |team| team.average_away_goals }.team_name\n end", "def lowest_scoring_home_team\n @teams.min_by { |team| team.average_home_goals }.team_name\n end", "def season_with_fewest_games\n seasons = @games.group_by { |game| game.season }\n seasons.min_by { |season, games| games.count }.first\n end", "def least_accurate_team(seasonasstring) # shots in game team stats\n #inverse of above\n end", "def biggest_bust(season)\n season = season.to_i\n @teams.min_by{ |team| team.preseason_to_regular_increase[season] }.team_name\n end", "def winningest_team\n @teams.max_by { |team| team.total_win_percentage }.team_name\n end", "def biggest_surprise(season)\n season = season.to_i\n @teams.max_by{ |team| team.preseason_to_regular_increase[season] }.team_name\n end", "def worst_offense\n @teams.min_by { |team| team.average_goals_scored }.team_name\n end", "def lowest_total_score\n total_game_scores = games.map { |game| game.home_goals + game.away_goals}\n total_game_scores.min\n end", "def best_defense\n @teams.min_by { |team| team.average_goals_allowed }.team_name\n end", "def most_accurate_team(seasonasstring) # shots in game team stats\n #get a list of all teams that played in that season - given by arg\n #use above list to sum all shots across all games in season\n #divide above by goals made across all games in season\n #find highest percentage\n #return team name as found in 127\n end", "def coach_win_percent_in_season(coach, game_ids)\n (total_wins_of_coach_in_season(coach, game_ids) / total_coach_games_in_season(coach, game_ids).to_f).round(2)\n end", "def minimum_rounds(driver)\n Algorithm::Swiss.minimum_rounds(driver.seeded_teams.length)\n end", "def minimum_rounds(driver)\n Algorithm::Swiss.minimum_rounds(driver.seeded_teams.length)\n end", "def average_win_percentage(team_id)\n team_id = team_id.to_i\n team = @teams.select { |each_team| each_team.team_id == team_id }.first\n team.total_win_percentage.round(2)\n end", "def smallest_team\n self.teams.min{|t1,t2| t1.runners.size <=> t2.runners.size }\n end", "def least_popular_venue\n venues = @games.group_by { |game| game.venue}\n venues.min_by { |venue, games| games.count }.first\n end", "def compute_team_winner\n if completed?\n team_winner\n else\n if first_team && second_team\n if sets_won(first_team) == min_sets_to_play\n first_team\n elsif sets_won(second_team) == min_sets_to_play\n second_team\n end\n end\n end\n end", "def winning_team\n self.teams.order('score DESC').first\n end", "def season_with_most_games\n seasons = @games.group_by { |game| game.season }\n seasons.max_by { |season, games| games.count }.first\n end", "def rival(team_id)\n team_id = team_id.to_i\n team = @teams.select { |each_team| each_team.team_id == team_id }.first\n rival_id = team.matchup_win_percentage.min_by{|each_team, percentage| percentage}.first\n @teams.select { |each_team| each_team.team_id == rival_id }.first.team_name\n end", "def determine_winner game\n winner = game.max_by {|team| team[:score]}\n team_standings = get_team_by_name(winner)\n team_standings[:winnings] += 3\nend", "def fewest_goals_scored(team_id)\n team_id = team_id.to_i\n goals_per_game = @game_teams.map do |game|\n if game.team_id == team_id\n game.goals\n end\n end\n goals_per_game.compact.min\n end", "def season_summary(season, team_id)\n season = season.to_i\n team_id = team_id.to_i\n season_summary_hash(season, team_id)\n end", "def player_win_percentage\n (games_won/user_games)\n end", "def get_first_name_of_season_winner(data, season)\n data.each do |season_iteration, stats|\n if season_iteration == season\n stats.find do |winner|\n if winner[\"status\"] == \"Winner\"\n return winner[\"name\"].split.first\n end\n end\n end\n end\nend", "def determine_match_winner\n @games_to_win = ((total_number_of_games / 2.0).floor) + 1\n if player1.score == games_to_win\n return player1\n elsif player2.score == games_to_win\n return player2\n else\n return nil\n end\n end", "def get_standings(games)\n teams = Hash.new\n games.each do |game|\n division_id = game.division_id\n home_team = game.home_team\n away_team = game.visiting_team\n if(teams[home_team.name].nil?)\n teams[home_team.name] = {:win => 0, :loss => 0, :tie => 0, :point=> 0}\n end\n\n if(teams[away_team.name].nil?)\n teams[away_team.name] = {:win => 0, :loss => 0, :tie => 0, :point => 0}\n end\n if(game.home_team_score && game.visiting_team_score)\n if(game.home_team_score > game.visiting_team_score)\n # home team won\n teams[home_team.name][:win] += 1\n teams[home_team.name][:point] += 5\n # visiting team loss\n teams[away_team.name][:loss] += 1\n elsif(game.home_team_score < game.visiting_team_score)\n # home team loss\n teams[home_team.name][:loss] += 1\n #visiting team won\n teams[away_team.name][:win] += 1\n teams[away_team.name][:point] += 5\n else\n # tie game\n teams[home_team.name][:tie] += 1\n teams[home_team.name][:point] += 1\n teams[away_team.name][:tie] += 1\n teams[away_team.name][:point] += 1\n end\n end\n end\n teams.each do |team, value|\n puts team\n total_games = value[:win] + value[:loss] + value[:tie]\n if total_games > 0 \n win_percentage = value[:win]/total_games.to_f\n else\n win_percentage = 0\n end \n value[:percentage] = win_percentage\n end\n teams_sorted = teams.sort_by{ |k, v| v[:point]}.reverse\n return teams_sorted\n end", "def fewest_hits(seasonasstring) # shots in game team stats\n #inverse of above\n end", "def winning_team\n home_points = collection_by_prop(game_hash[:home], :points).reduce(0, :+)\n away_points = collection_by_prop(game_hash[:away], :points).reduce(0, :+)\n home_points > away_points ? game_hash[:home][:team_name] : game_hash[:away][:team_name]\n end", "def best_fans\n @teams.max_by { |team| team.home_minus_away_percentage }.team_name\n end", "def pri_toff\n team_stats.goals_per_game / team_stats.opp_avg_goals_per_game\n end", "def get_first_name_of_season_winner(data, season)\n winner = match_contestant(data[season], 'status', 'Winner')\n winner['name'].split[0]\nend", "def win_percent\n matchmade_games < 1 ? 0 : ((total_exp.to_f/matchmade_games.to_f) * 100).to_d\n end", "def pri_sos\n team_stats.opp_pyth / 50.0 \n end", "def best_offense\n @teams.max_by { |team| team.average_goals_scored }.team_name\n end", "def best_defense\n teams_total_goals_allowed = total_goals_allowed_helper\n teams_total_games = total_games_helper\n\n best_team_goals_allowed_avg = 100\n best_defense_team_id = 0\n this_team_goals_allowed_avg = 0\n\n teams_total_games.each do |games_key, games_value|\n teams_total_goals_allowed.each do |goals_key, goals_value|\n if goals_key == games_key\n this_team_goals_allowed_avg = (goals_value / games_value.to_f)\n if this_team_goals_allowed_avg < best_team_goals_allowed_avg\n best_team_goals_allowed_avg = this_team_goals_allowed_avg\n best_defense_team_id = games_key\n end\n end\n end\n end\n\n team_with_best_defense = nil\n self.teams.each_value do |team_obj|\n if team_obj.team_id. == best_defense_team_id\n team_with_best_defense = team_obj.team_name\n end\n end\n team_with_best_defense\n end", "def most_hits(seasonasstring) # shots in game team stats\n #get a list of all teams that played in that season\n #use above list to sum all shots across all games in season\n #find highest across list\n #return team name as found in 139\n end", "def biggest_bust(seasonasstring)\n #get all teams in data\n #find all games played by team in season - given by arg\n #get subset of 95 where p is in season marker\n #count games won in subset on 95 / total games in subset on 95\n #get subset of 85 where r is in season marker\n #count games won in subset on 98 / total games in subset on 98\n #result of line 97 - line 99\n #find highest number\n #return team name of result of line 101\n end", "def retrieve_season_hall_of_fame\n seasons_hall_of_fame = []\n get_involved_teams unless @involved_teams\n\n @involved_teams.each do |team|\n team_placement = {}\n team_placement[:team] = team\n %w[first_place second_place third_place].each_with_index do |rank, index|\n placement = index + 1\n team_placement[rank.to_sym] = team.computed_season_ranking.joins(:season).where(\"seasons.season_type_id = #{@season_type.id} AND computed_season_rankings.rank = #{placement}\").count\n end\n seasons_hall_of_fame << team_placement\n end\n seasons_hall_of_fame.sort { |p, n| (n[:first_place] * 10_000 + n[:second_place] * 100 + n[:third_place]) <=> (p[:first_place] * 10_000 + p[:second_place] * 100 + p[:third_place]) }\n end", "def biggest_suprise(seasonasstring)\n #as above, but change line 100 to reverse operations, regular percentage - postseason percentage\n end", "def winning_team_with_spread\n\t\tif self.final?\n\t\t\treturn home_team_id if home_team_score > away_team_score + point_spread\n\t\t\treturn away_team_id if away_team_score + point_spread > home_team_score\n\t\t\treturn \"tie\" if home_team_score == away_team_score + point_spread\n\t\telse\n\t\t\treturn nil\n\t\tend\n\tend", "def percent_wins(wins)\n ((wins.to_f / @num_games.to_f) * 100).round(4)\n end", "def total_wins_by_season_by_team_id(passed_id)\n @by_team_id_game_objects.each do |game|\n if helper_for_win_count(passed_id, game)\n @total_wins_by_season[game[\"season\"]] += 1\n elsif helper_for_loss_count(passed_id, game)\n @total_wins_by_season[game[\"season\"]] += 0\n end\n end\n end", "def percentage_home_wins\n home_wins = @teams.map { |team| team.home_wins }.sum\n home_games = @teams.map { |team| team.home_games }.sum\n (home_wins.to_f / home_games.to_f).round(2)\n end", "def near_team_winner?(team)\n unless completed?\n sets_won(team) + 1 == min_sets_to_play\n end\n end", "def calculate_least_common_year\n self.calculate_plays_by_year.select{ |year,times_played| times_played > 0 }.sort_by{ |year, times_played| times_played }.first\n end", "def find_best_score(total_per_player)\n best_score = 0\n winner = ''\n total_per_player.each do |player_name,total|\n\n if total > best_score\n best_score = total\n winner = player_name\n end\n end\n return winner\n end", "def percentage_visitor_wins\n visitor_wins = @teams.map { |team| team.away_wins }.sum\n visitor_games = @teams.map { |team| team.away_games }.sum\n (visitor_wins.to_f / visitor_games.to_f).round(2)\n end", "def worst_offense\n teams_total_goals = total_goals_helper\n teams_total_games = total_games_helper\n\n worst_team_goals_avg = 1000\n worst_offense_team_id = 0\n this_team_goals_avg = 0\n\n teams_total_games.each do |games_key, games_value|\n teams_total_goals.each do |goals_key, goals_value|\n if goals_key == games_key\n this_team_goals_avg = (goals_value / games_value.to_f)\n if this_team_goals_avg < worst_team_goals_avg\n worst_team_goals_avg = this_team_goals_avg\n worst_offense_team_id = games_key\n end\n end\n end\n end\n\n team_with_worst_offense = nil\n self.teams.each_value do |team_obj|\n if team_obj.team_id. == worst_offense_team_id\n team_with_worst_offense = team_obj.team_name\n end\n end\n team_with_worst_offense\n end", "def power_play_goal_percentage(seasonasstring) # power_play info in game team stat\n #find list of all games in season given by arg\n #sum all power play goals\n #sum all power play oppertunities\n #divide line 146 and line 147\n #return total of above\n end", "def average_goals_by_season\n goals_by_season = @games.group_by { |game| game.season.to_s }\n goals_by_season.each do |season, games|\n season_goals = games.map { |game| game.home_goals + game.away_goals }.sum\n goals_by_season[season] = (season_goals.to_f / games.count.to_f).round(2)\n end\n end", "def applied_season(season_id)\n seasons.where(org_season_id: BSON::ObjectId.from_string(season_id)).first\n end", "def minimum_rounds(teams_count)\n Math.log2(teams_count).ceil\n end", "def winning_team\n final_scores = player_collection.reduce(home: 0, away: 0) { |teams_points, next_player|\n case \n when next_player[:location] === :away\n teams_points[:away] += next_player[:points];\n when next_player[:location] === :home\n teams_points[:home] += next_player[:points];\n end\n teams_points; \n }\n winner = final_scores.reduce { |highest_points, team_points| \n highest_points[1] > team_points[1] ? highest_points : team_points; \n }\n game_hash[winner[0]][:team_name]; \nend", "def best_score\n submissions.min(:score)\n end", "def ranks\n @teams = Team.where(\"wins > 0\t\").order(win_percentage: :desc)\n end", "def head_to_head(team_id)\n team_id = team_id.to_i\n head_to_head_hash = {}\n team = @teams.select { |each_team| each_team.team_id == team_id }.first\n head_to_head_id_hash = team.matchup_win_percentage\n head_to_head_id_hash.each do |each_team_id, win_percentage|\n @teams.each do |each_team|\n if each_team.team_id == each_team_id\n head_to_head_hash[each_team.team_name] = win_percentage\n end\n end\n end\n head_to_head_hash\n end", "def seasonal_summary(team_id)\n team_id = team_id.to_i\n seasonal_summary_hash(team_id)\n end", "def winning_team\n blue_team.winner? ? blue_team : red_team\n end", "def get_score(formation)\n lowest_score = Float::MAX\n formation.each do |proj_id, teamArr|\n #TODO multiply each score by the weight from the professor\n score = @professor_preferences[:scheduleWeight]*get_schedule_score(teamArr) + \n @professor_preferences[:codingWeight]*get_coding_score(teamArr) + \n @professor_preferences[:partnerWeight]*get_partner_score(teamArr) + \n @professor_preferences[:projectWeight]*get_project_score(teamArr,proj_id)\n # puts \"each score is\",score\n if (score < lowest_score) then\n lowest_score = score\n end\n end\n return lowest_score\n end", "def season\n @season ||= Season.find(@importer_hash.meeting.season_id)\n end", "def regular_season_rankings(season = nil)\n stats_request(\"regularSeasonStatRankings\", season).first\n end", "def winning_team\n team_p = []\n team_n = []\n\n game_hash.each do | location, team_data|\n temp = 0\n team_data[:players].each do |p_name, stats|\n temp += stats[:points]\n end\n team_n << team_data[:team_name]\n team_p << temp\n end\n\n team_p[0] > team_p[1] ? team_n[0] : team_n[1]\n\nend", "def lacrosse_scoring_average(sport, player)\n\t\tgoals = 0\n\t\tgames = sport.teams.find(player.team_id).gameschedules\n\n\t\tgames.each do |g|\n\t\t\tstat = g.lacrosstats.find_by(athlete_id: player.id)\n\t\t\tgoals += stat.lacross_scorings.count if stat.lacross_scorings.any?\n\t\tend\n\n\t\tif games > 0\n\t\t\treturn goals / games.count\n\t\telse\n\t\t\treturn 0.0\n\t\tend\n\tend", "def winningest_coach(seasonasstring) # coach name in game team stats\n #per season, get list of all coaches - given by arg\n #per coach, find all games played by that coach\n #then count of all games won / count of all games played\n #find highest\n #return name of coach found in 114\n end", "def min_sets_to_play\n max = max_sets_to_play\n raise Exceptions::ApplicationError, 'Unexpected game count' if max.even?\n (max + 1) / 2\n end", "def winner\n if (self.homeScore > self.awayScore)\n return self.home_team\n elsif (self.awayScore > self.homeScore)\n return self.away_team\n else\n return nil\n end\n end", "def get_win_percentage(strategy)\n score = 0\n @turns.each do |t|\n score += t.result.to_i if t.strategy.include?(strategy)\n end\n score\n end", "def flu_season\n event_display(\"It's flu season!\\n One player has been infected and needs some time to recuperate.\")\n {Game.last.players.sample.id.to_s =>\n {wellbeing: -100}\n }\n end", "def highest_scoring_home_team\n @teams.max_by { |team| team.average_home_goals }.team_name\n end", "def rating\n position_sum = 0\n games = []\n number_of_teams = 0\n Participation.find_all_by_player_id(self.id).each do |participation|\n position_sum += participation.position\n games.push Game.find(participation.game_id)\n end\n\n games.each do |game|\n number_of_teams += game.number_of_teams\n end\n\n if position_sum == 0\n position_sum = number_of_teams.to_f-0.5\n end\n\n (1 - position_sum.to_f/number_of_teams).round 2\n end", "def per_game_stats(season = nil)\n season_id = season ? season.id : Season.current.id\n StatLine.find_by_sql('SELECT AVG(fgm) as fgm, AVG(fga) as fga, coalesce(AVG(fgm)/nullif(AVG(fga), 0), 0) as fgpct, AVG(twom) as twom, AVG(twoa) as twoa, coalesce(AVG(twom)/nullif(AVG(twoa), 0), 0) as twopct, AVG(threem) as threem, AVG(threea) as threea, coalesce(AVG(threem)/nullif(AVG(threea), 0), 0) as threepct,' \\\n 'AVG(ftm) as ftm, AVG(fta) as fta, coalesce(AVG(ftm)/nullif(AVG(fta), 0), 0) as ftpct, AVG(orb) as orb, AVG(drb) as drb, AVG(trb) as trb, AVG(ast) as ast, AVG(stl) as stl, AVG(blk) as blk, AVG(fl) as fl, AVG(\"to\") as to,' \\\n 'AVG(points) as points, COUNT(*) as game_count, sums.league_id FROM (SELECT SUM(fgm) as fgm, SUM(fga) as fga, SUM(twom) as twom, SUM(twoa) as twoa, SUM(threem) as threem, SUM(threea) as threea,' \\\n 'SUM(ftm) as ftm, SUM(fta) as fta, SUM(orb) as orb, SUM(drb) as drb, SUM(trb) as trb, SUM(ast) as ast, SUM(stl) as stl, SUM(blk) as blk, SUM(fl) as fl, SUM(\"to\") as to,' \\\n \"SUM(points) as points, g.league_id as league_id FROM stat_lines sl INNER JOIN games g ON sl.game_id = g.id \" \\\n \"WHERE g.winner is not null AND (g.forfeit is null or not g.forfeit) AND (sl.dnp is null OR not sl.dnp) AND team_id = #{self.id} AND g.season_id = #{season_id} GROUP BY game_id, g.league_id) sums GROUP BY sums.league_id\")\n end", "def highest_scoring_visitor\n @teams.max_by { |team| team.average_away_goals }.team_name\n end", "def winning_team\n home_team_points = game_hash[:home][:players].sum { |e| e[:points] }\n away_team_points = game_hash[:away][:players].sum { |e| e[:points] }\n\n if home_team_points > away_team_points\n return game_hash[:home][:team_name]\n else\n return game_hash[:away][:team_name]\n end\nend", "def bp_odds_on_favorite\n\t\tfav_team=Teamseason.new\n\t\tfav_team.year=self.matchup_year\n\t\tfav_team.team=self.favorite \n\t\tunderdog_team=Teamseason.new\n\t\tunderdog_team.year=self.matchup_year\n\t\tunderdog_team.team=self.underdog\n\t\treturn fav_team.bp_ros_win_pct.to_f.odds_against_opponent(underdog_team.bp_ros_win_pct.to_f)\n\tend", "def worst_defense\n teams_total_goals_allowed = total_goals_allowed_helper\n teams_total_games = total_games_helper\n\n worst_team_goals_allowed_avg = 0\n worst_defense_team_id = 0\n this_team_goals_allowed_avg = 0\n\n teams_total_games.each do |games_key, games_value|\n\n teams_total_goals_allowed.each do |goals_key, goals_value|\n if goals_key == games_key\n this_team_goals_allowed_avg = (goals_value / games_value.to_f)\n if this_team_goals_allowed_avg > worst_team_goals_allowed_avg\n worst_team_goals_allowed_avg = this_team_goals_allowed_avg\n worst_defense_team_id = games_key\n end\n end\n end\n end\n team_with_worst_defense = team_name_finder_helper(worst_defense_team_id)\n\n team_with_worst_defense\n end", "def points_season(round, season = nil)\n count = 0\n matchs = find_matchs(round, season)\n\n matchs.each do |match|\n if match.is_winner?(self) and match.finished?\n count += MatchGeneral::PT_WIN\n end\n if match.deal? and match.finished?\n count += MatchGeneral::PT_DEAL\n end\n end\n\n count\n end", "def stats_vs_team(team, season = nil)\n id = find_id(team, Team)\n data = stats_request(\"vsTeam\", season)\n data.find do |s| s[\"opponent\"][\"id\"] == id end\n end", "def stats_when_win(season = nil)\n data = stats_request(\"winLoss\", season)\n data.find do |s| s[\"isWin\"] && !s[\"isOT\"] end\n end", "def winning_team\n if homeTeamPoints.sum > awayTeamPoints.sum\n \"Brooklyn Nets\"\n else\n \"Charlotte Hornets\"\n end\nend", "def get_involved_season_best_for_event(involved_seasons, event_type, pool_type)\n best = nil\n involved_seasons.each do |season|\n next unless @swimmer.meeting_individual_results.for_season(season)\n .for_pool_type(pool_type)\n .for_event_type(event_type)\n .is_not_disqualified.exists?\n\n tmp_best = @swimmer.meeting_individual_results.for_season(season)\n .for_pool_type(pool_type)\n .for_event_type(event_type)\n .is_not_disqualified\n .sort_by_timing('ASC')\n .first\n .get_timing_instance\n best = tmp_best if best.nil? || best.to_hundreds > tmp_best.to_hundreds\n end\n best\n end", "def points(team)\n first = 0\n res = self.result\n\n if res\n if team == 1\n first_team = res[0]\n sec_team = res[1]\n elsif team == 2\n first_team = res[1]\n sec_team = res[0]\n else \n raise \"Invalid Team chosen\"\n end\n\n p first_team <=> sec_team\n # Compare the results\n outcome = first_team <=> sec_team\n\n if outcome > 0\n # Win\n result = 3\n elsif outcome < 0\n # Loss\n result = 0\n else \n # Draw\n result = 1\n end\n else\n result = nil\n end\n\n result\n end", "def batting_average(year: nil, team: nil)\n hits, at_bats = 0, 0\n\n seasonal_stats.each do |stat_line|\n year_match = stat_line.year == year || year == nil\n team_match = stat_line.team == team || team == nil\n if year_match && team_match\n hits += stat_line.hits\n at_bats += stat_line.at_bats\n end\n end\n\n if (at_bats != 0)\n return (hits.to_f / at_bats)\n else\n return 0.0\n end\n end", "def worst_coach(seasonasstring) # coach name in game team stats\n #inverse of above\n end", "def wins\n determine_stats[:wins]\n end", "def winning_team\n nets = []\n hornets = []\n\n game_hash.values.each do |nets_stats|\n if nets_stats[:team_name] == \"Brooklyn Nets\"\n nets_stats[:players].each do |bk|\n nets << bk[:points]\n end\n end\n end\n\n game_hash.values.each do |hornets_stats|\n if hornets_stats[:team_name] == \"Charlotte Hornets\"\n hornets_stats[:players].each do |ch|\n hornets << ch[:points]\n end\n end\n end\n\n if nets.reduce(:+) > hornets.reduce(:+)\n return \"Brooklyn Nets\"\n else\n return \"Charlotte Hornets\"\n end\nend", "def favorite_opponent(team_id)\n team_id = team_id.to_i\n team = @teams.select { |each_team| each_team.team_id == team_id }.first\n favorite_opponent_id = team.matchup_win_percentage.max_by{|each_team, percentage| percentage}.first\n @teams.select { |each_team| each_team.team_id == favorite_opponent_id }.first.team_name\n end", "def winner_team(game)\n result = nil\n if game.team1_goals.present? && game.team2_goals.present?\n result = game.team1 if game.team1_goals > game.team2_goals\n result = game.team2 if game.team1_goals < game.team2_goals\n end\n\n result\n end", "def wins\n wins = 0\n self.teams.each do |team|\n wins += team.games_won.length\n end\n wins\n end", "def winner\n @players.max_by do |player|\n player.score\n end\n end", "def most_points_scored\n points_scored = 0 # starting score to compare with players shoe sizes\n game_hash.each do |location, team_data| # iterates through each team\n players_array = team_data[:players] # finds the :players info in team_data and puts the players into players_array\n players_array.each do |player_name, data| # iterates through each player..\n if data[:points] > points_scored # if their points scored is greater than 0 (we set this earlier in the top of method)\n points_scored = data[:shoe] # take that players score and make it the new points_scored value\n end # this repeats (iterates) through all players until you don't have any more.. meaning the end result is\n end # the player with the highest score\n end\n return points_scored\nend", "def minmax_score(board)\n if won?(board)\n if winner(board) == self.token\n 1\n else\n -1\n end\n elsif draw?(board)\n 0\n end\n end", "def score_for_team(team)\n team ||= winner_team\n winner_team?(team) ? score : scores.reverse.join(':')\n end", "def recommended_min_portfolio\n annualized_portfolio_amount_needed / withdrawal_rate\n end", "def winning_team\n home_team_sum = 0\n away_team_sum = 0\n game_hash.each do |team, team_stats|\n if team_stats[:team_name] == \"Brooklyn Nets\"\n team_stats[:players].each do |player_stats|\n home_team_sum += player_stats[:points]\n end\n elsif team_stats[:team_name] == \"Charlotte Hornets\"\n team_stats[:players].each do |player_stats|\n away_team_sum += player_stats[:points]\n end\n end\n end\n if home_team_sum > away_team_sum\n game_hash[:home][:team_name]\n elsif home_team_sum < away_team_sum\n game_hash[:away][:team_name]\n end\nend", "def win_matchs_season(round, season = nil)\n count = 0\n matchs = find_matchs(round, season)\n\n matchs.each do |match|\n if match.is_winner?(self) and match.finished?\n count += 1\n end\n end\n count\n end", "def lowest_score\n sort\n all.last.score\n end" ]
[ "0.8135413", "0.7703922", "0.7569027", "0.7443136", "0.7322702", "0.72461", "0.699618", "0.69553375", "0.69253457", "0.6865913", "0.67372066", "0.6735379", "0.67120963", "0.66092753", "0.65934414", "0.65934414", "0.65020823", "0.6454325", "0.6442626", "0.6419464", "0.636962", "0.6311353", "0.6307884", "0.63024473", "0.6293924", "0.62421906", "0.6239973", "0.6220353", "0.6218823", "0.62067753", "0.6184302", "0.6180468", "0.6174976", "0.6174518", "0.6172484", "0.61634606", "0.61622304", "0.6136125", "0.6119299", "0.611606", "0.6099994", "0.6090091", "0.6088214", "0.6088181", "0.60778683", "0.606597", "0.6064911", "0.60603917", "0.6055069", "0.6040915", "0.6033908", "0.6033059", "0.60173553", "0.6009149", "0.60076034", "0.6005228", "0.59919906", "0.59885573", "0.5985095", "0.59791946", "0.5972344", "0.59715724", "0.59569097", "0.59554136", "0.5953554", "0.59446096", "0.5917942", "0.591019", "0.5906302", "0.59013784", "0.5890807", "0.5886575", "0.5869166", "0.58612484", "0.58567613", "0.5852231", "0.5832394", "0.5819973", "0.5818683", "0.58104986", "0.57988983", "0.5798405", "0.57850003", "0.57735074", "0.57452214", "0.5741872", "0.57400215", "0.5731722", "0.57182956", "0.57140714", "0.5712133", "0.5712087", "0.56998533", "0.5683656", "0.56759864", "0.5675723", "0.56751806", "0.56741834", "0.56695575", "0.5653489" ]
0.8291316
0
returns average win percentage of all games for a team
def average_win_percentage(team_id) team_id = team_id.to_i team = @teams.select { |each_team| each_team.team_id == team_id }.first team.total_win_percentage.round(2) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def average_goals_per_game\n total_goals = @teams.map {|team| team.total_goals_scored}.sum\n total_games = @teams.map {|team| team.home_games}.sum\n (total_goals.to_f / total_games.to_f).round(2)\n end", "def percentage_home_wins\n home_wins = @teams.map { |team| team.home_wins }.sum\n home_games = @teams.map { |team| team.home_games }.sum\n (home_wins.to_f / home_games.to_f).round(2)\n end", "def percentage_visitor_wins\n visitor_wins = @teams.map { |team| team.away_wins }.sum\n visitor_games = @teams.map { |team| team.away_games }.sum\n (visitor_wins.to_f / visitor_games.to_f).round(2)\n end", "def player_win_percentage\n (games_won/user_games)\n end", "def average_goals_by_season\n goals_by_season = @games.group_by { |game| game.season.to_s }\n goals_by_season.each do |season, games|\n season_goals = games.map { |game| game.home_goals + game.away_goals }.sum\n goals_by_season[season] = (season_goals.to_f / games.count.to_f).round(2)\n end\n end", "def coach_win_percent_in_season(coach, game_ids)\n (total_wins_of_coach_in_season(coach, game_ids) / total_coach_games_in_season(coach, game_ids).to_f).round(2)\n end", "def percent_wins(wins)\n ((wins.to_f / @num_games.to_f) * 100).round(4)\n end", "def get_standings(games)\n teams = Hash.new\n games.each do |game|\n division_id = game.division_id\n home_team = game.home_team\n away_team = game.visiting_team\n if(teams[home_team.name].nil?)\n teams[home_team.name] = {:win => 0, :loss => 0, :tie => 0, :point=> 0}\n end\n\n if(teams[away_team.name].nil?)\n teams[away_team.name] = {:win => 0, :loss => 0, :tie => 0, :point => 0}\n end\n if(game.home_team_score && game.visiting_team_score)\n if(game.home_team_score > game.visiting_team_score)\n # home team won\n teams[home_team.name][:win] += 1\n teams[home_team.name][:point] += 5\n # visiting team loss\n teams[away_team.name][:loss] += 1\n elsif(game.home_team_score < game.visiting_team_score)\n # home team loss\n teams[home_team.name][:loss] += 1\n #visiting team won\n teams[away_team.name][:win] += 1\n teams[away_team.name][:point] += 5\n else\n # tie game\n teams[home_team.name][:tie] += 1\n teams[home_team.name][:point] += 1\n teams[away_team.name][:tie] += 1\n teams[away_team.name][:point] += 1\n end\n end\n end\n teams.each do |team, value|\n puts team\n total_games = value[:win] + value[:loss] + value[:tie]\n if total_games > 0 \n win_percentage = value[:win]/total_games.to_f\n else\n win_percentage = 0\n end \n value[:percentage] = win_percentage\n end\n teams_sorted = teams.sort_by{ |k, v| v[:point]}.reverse\n return teams_sorted\n end", "def team_average\n # This version is implemented as a database AVG operation,\n # but it cannot be eager loaded so it results in an extra\n # database query for each project:\n #\n # avg = students_projects.select(:points).average :points\n # avg ? avg.round : 0\n\n # This version programmatically finds the average of the points:\n #self.reload\n no_of_students = self.students_projects.length\n return 0 if no_of_students == 0\n total = 0\n self.students_projects.each { |s| total += s.points }\n (total / no_of_students).round\n end", "def win_percent\n matchmade_games < 1 ? 0 : ((total_exp.to_f/matchmade_games.to_f) * 100).to_d\n end", "def batting_average(year: nil, team: nil)\n hits, at_bats = 0, 0\n\n seasonal_stats.each do |stat_line|\n year_match = stat_line.year == year || year == nil\n team_match = stat_line.team == team || team == nil\n if year_match && team_match\n hits += stat_line.hits\n at_bats += stat_line.at_bats\n end\n end\n\n if (at_bats != 0)\n return (hits.to_f / at_bats)\n else\n return 0.0\n end\n end", "def winning_team\n home_team_sum = 0\n away_team_sum = 0\n game_hash.each do |team, team_stats|\n if team_stats[:team_name] == \"Brooklyn Nets\"\n team_stats[:players].each do |player_stats|\n home_team_sum += player_stats[:points]\n end\n elsif team_stats[:team_name] == \"Charlotte Hornets\"\n team_stats[:players].each do |player_stats|\n away_team_sum += player_stats[:points]\n end\n end\n end\n if home_team_sum > away_team_sum\n game_hash[:home][:team_name]\n elsif home_team_sum < away_team_sum\n game_hash[:away][:team_name]\n end\nend", "def total_score\n sum = self.games.sum{|game|game.points}\n sum.to_i / self.games.count\n end", "def get_win_percentage(strategy)\n score = 0\n @turns.each do |t|\n score += t.result.to_i if t.strategy.include?(strategy)\n end\n score\n end", "def total_team_score(teams_id)\n total_score = 0\n @league_data.each do\n |team| \n # binding.pry\n if team.home_team_id == teams_id\n total_score += team.home_team_score\n elsif team.away_team_id == teams_id\n total_score += team.away_team_score\n end\n end\n return total_score\n end", "def calculate_score(team)\n scores.includes(:wattball_player).where(:wattball_players => {:team_id => team}).sum(:amount) \n end", "def lacrosse_scoring_average(sport, player)\n\t\tgoals = 0\n\t\tgames = sport.teams.find(player.team_id).gameschedules\n\n\t\tgames.each do |g|\n\t\t\tstat = g.lacrosstats.find_by(athlete_id: player.id)\n\t\t\tgoals += stat.lacross_scorings.count if stat.lacross_scorings.any?\n\t\tend\n\n\t\tif games > 0\n\t\t\treturn goals / games.count\n\t\telse\n\t\t\treturn 0.0\n\t\tend\n\tend", "def power_play_goal_percentage(seasonasstring) # power_play info in game team stat\n #find list of all games in season given by arg\n #sum all power play goals\n #sum all power play oppertunities\n #divide line 146 and line 147\n #return total of above\n end", "def calc_pct(wins, losses)\n return (wins + losses) == 0 ? 0.0 : wins.to_f / (wins + losses).to_f\nend", "def wins\n wins = 0\n self.teams.each do |team|\n wins += team.games_won.length\n end\n wins\n end", "def rating_average(team, match)\n if match.ended?\n sum = 0; team.each { |u| sum += u['rating'].to_i }\n else\n sum = 0; team.users.each { |u| sum += u['rating'].to_i }\n end\n sum / 5\n end", "def points_in_team(team)\r\n perfs = self.performances.where(team: team)\r\n perfs.map(&:points).inject(:+) / perfs.length\r\n end", "def total_score\n @all_games.map do |games|\n games[\"home_goals\"].to_i + games[\"away_goals\"].to_i\n end\n end", "def total_wins_by_season_by_team_id(passed_id)\n @by_team_id_game_objects.each do |game|\n if helper_for_win_count(passed_id, game)\n @total_wins_by_season[game[\"season\"]] += 1\n elsif helper_for_loss_count(passed_id, game)\n @total_wins_by_season[game[\"season\"]] += 0\n end\n end\n end", "def determine_winner game\n winner = game.max_by {|team| team[:score]}\n team_standings = get_team_by_name(winner)\n team_standings[:winnings] += 3\nend", "def worst_offense\n teams_total_goals = total_goals_helper\n teams_total_games = total_games_helper\n\n worst_team_goals_avg = 1000\n worst_offense_team_id = 0\n this_team_goals_avg = 0\n\n teams_total_games.each do |games_key, games_value|\n teams_total_goals.each do |goals_key, goals_value|\n if goals_key == games_key\n this_team_goals_avg = (goals_value / games_value.to_f)\n if this_team_goals_avg < worst_team_goals_avg\n worst_team_goals_avg = this_team_goals_avg\n worst_offense_team_id = games_key\n end\n end\n end\n end\n\n team_with_worst_offense = nil\n self.teams.each_value do |team_obj|\n if team_obj.team_id. == worst_offense_team_id\n team_with_worst_offense = team_obj.team_name\n end\n end\n team_with_worst_offense\n end", "def calculate!\n ov = self[:overall]\n ov[:high_night] = {}\n ov[:winners] = {}\n\n self.each do |player_id, st|\n next if player_id == :overall\n\n ## calculate computed stats for player\n st[:nights] += st[:dates].keys.length # if st[:nights] == 0\n st[:high_night] = st[:dates].values.max\n st[:gold_stars] = 1 if st[:nights] == 29\n st[:warps_per_game] = 1.0 * st[:warps] / st[:games] rescue 0\n st[:warps_per_night] = 1.0 * st[:warps] / st[:nights] rescue 0\n st[:games_per_night] = 1.0 * st[:games] / st[:nights] rescue 0\n st[:wins_per_night] = 1.0 * st[:wins] / st[:nights] rescue 0\n st[:wins_per_game] = 1.0 * st[:wins] / st[:games] rescue 0\n\n ## accumulate overall stats\n [:warps, :wins, :cfbs,\n :mystery_factors, :gold_stars]. each do |field|\n ov[field] += st[field]\n end\n [:wimps, :come_ons].each do |field|\n if st[field]\n ov[field] ||= 0\n ov[field] += st[field]\n end\n end\n # nights won calculation\n st[:dates].each do |date,warps|\n ov[:dates][date] += warps\n hnd = ov[:high_night][date] ||= {:players => [], :warps => 0}\n if hnd[:warps] < warps\n hnd[:players] = [player_id]\n hnd[:warps] = warps\n elsif hnd[:warps] == warps\n hnd[:players].push(player_id)\n end\n end\n end\n\n ## update overall computed stats\n st = self[:overall]\n ov[:games] = ov[:wins]\n ov[:nights] = ov[:dates].keys.length\n ov[:nights] = 29 if ov[:nights] == 0 ## provide sane default\n ov[:nights] = ov[:nights_real] if ov[:nights_real]\n ov[:warps_per_game] = 1.0 * ov[:warps] / ov[:games] rescue 0\n ov[:warps_per_night] = 1.0 * ov[:warps] / ov[:nights] rescue 0\n ov[:games_per_night] = 1.0 * ov[:games] / ov[:nights] rescue 0\n ov[:high_night].each do |date,h|\n h[:players].each {|p| self[p][:nights_won] += 1}\n end\n\n ## determine per-stat winners\n # fuck everyone but the top 50 OR those with 50+ warps\n # the 51 below is not a bug\n sorted_players = self.keys.sort{|a,b| self[b][:warps] <=> self[a][:warps]}\n fifty_plus = self.keys.select{|p| self[p][:warps] >= 50}\n eligible = (sorted_players[0..51] | fifty_plus).\n inject(Hash.new(false)) {|acc,p| acc.merge(p => true)}\n [:warps, :games, :nights, :wins, :nights_won, :cfbs,\n :come_ons, :wimps, :warps_per_game, :warps_per_night,\n :games_per_night, :wins_per_game, :high_night].each do |field|\n owf = ov[:winners][field] = {:players => [], :value => 0}\n self.each do |player, st|\n next if player == :overall\n next unless eligible[player]\n if st[field].to_f > owf[:value]\n owf[:players] = [player]\n owf[:value] = st[field]\n elsif st[field] == owf[:value]\n owf[:players].push(player)\n end\n end\n end\n\n ## mark per-stat winners\n ov[:winners].each do |field, win|\n win[:players].each do |player|\n self[player][:winner][field] = true\n end\n end\n\n self\n end", "def rating\n position_sum = 0\n games = []\n number_of_teams = 0\n Participation.find_all_by_player_id(self.id).each do |participation|\n position_sum += participation.position\n games.push Game.find(participation.game_id)\n end\n\n games.each do |game|\n number_of_teams += game.number_of_teams\n end\n\n if position_sum == 0\n position_sum = number_of_teams.to_f-0.5\n end\n\n (1 - position_sum.to_f/number_of_teams).round 2\n end", "def avg_shots_per_kill\n @avg_shots_per_kill = @shots.to_f / @kills if @avg_shots_per_kill.nil?\n\n @avg_shots_per_kill\n end", "def team_score\n team_member = @current_user.team.users\n team_comment = Comment.where(user_id: team_member.pluck('id'))\n emotion_scores = team_comment.where('created_at BETWEEN ? AND ?', DateTime.now.beginning_of_day, DateTime.now.end_of_day).average(:score)\n emotion_scores\n end", "def winning_team\n home_score = 0\n away_score = 0\n game_hash[:home][:players].keys.each do |name|\n home_score += game_hash[:home][:players][name][:points]\n end\n game_hash[:away][:players].keys.each do |name|\n away_score += game_hash[:away][:players][name][:points]\n end\n home_score > away_score ? game_hash[:home][:team_name] : game_hash[:away][:team_name]\nend", "def winning_team\n final_scores = player_collection.reduce(home: 0, away: 0) { |teams_points, next_player|\n case \n when next_player[:location] === :away\n teams_points[:away] += next_player[:points];\n when next_player[:location] === :home\n teams_points[:home] += next_player[:points];\n end\n teams_points; \n }\n winner = final_scores.reduce { |highest_points, team_points| \n highest_points[1] > team_points[1] ? highest_points : team_points; \n }\n game_hash[winner[0]][:team_name]; \nend", "def avg_shots_per_kill\n @shots.to_f / @kills\n end", "def per_game_stats(season = nil)\n season_id = season ? season.id : Season.current.id\n StatLine.find_by_sql('SELECT AVG(fgm) as fgm, AVG(fga) as fga, coalesce(AVG(fgm)/nullif(AVG(fga), 0), 0) as fgpct, AVG(twom) as twom, AVG(twoa) as twoa, coalesce(AVG(twom)/nullif(AVG(twoa), 0), 0) as twopct, AVG(threem) as threem, AVG(threea) as threea, coalesce(AVG(threem)/nullif(AVG(threea), 0), 0) as threepct,' \\\n 'AVG(ftm) as ftm, AVG(fta) as fta, coalesce(AVG(ftm)/nullif(AVG(fta), 0), 0) as ftpct, AVG(orb) as orb, AVG(drb) as drb, AVG(trb) as trb, AVG(ast) as ast, AVG(stl) as stl, AVG(blk) as blk, AVG(fl) as fl, AVG(\"to\") as to,' \\\n 'AVG(points) as points, COUNT(*) as game_count, sums.league_id FROM (SELECT SUM(fgm) as fgm, SUM(fga) as fga, SUM(twom) as twom, SUM(twoa) as twoa, SUM(threem) as threem, SUM(threea) as threea,' \\\n 'SUM(ftm) as ftm, SUM(fta) as fta, SUM(orb) as orb, SUM(drb) as drb, SUM(trb) as trb, SUM(ast) as ast, SUM(stl) as stl, SUM(blk) as blk, SUM(fl) as fl, SUM(\"to\") as to,' \\\n \"SUM(points) as points, g.league_id as league_id FROM stat_lines sl INNER JOIN games g ON sl.game_id = g.id \" \\\n \"WHERE g.winner is not null AND (g.forfeit is null or not g.forfeit) AND (sl.dnp is null OR not sl.dnp) AND team_id = #{self.id} AND g.season_id = #{season_id} GROUP BY game_id, g.league_id) sums GROUP BY sums.league_id\")\n end", "def winning_team\n team_p = []\n team_n = []\n\n game_hash.each do | location, team_data|\n temp = 0\n team_data[:players].each do |p_name, stats|\n temp += stats[:points]\n end\n team_n << team_data[:team_name]\n team_p << temp\n end\n\n team_p[0] > team_p[1] ? team_n[0] : team_n[1]\n\nend", "def worst_defense\n teams_total_goals_allowed = total_goals_allowed_helper\n teams_total_games = total_games_helper\n\n worst_team_goals_allowed_avg = 0\n worst_defense_team_id = 0\n this_team_goals_allowed_avg = 0\n\n teams_total_games.each do |games_key, games_value|\n\n teams_total_goals_allowed.each do |goals_key, goals_value|\n if goals_key == games_key\n this_team_goals_allowed_avg = (goals_value / games_value.to_f)\n if this_team_goals_allowed_avg > worst_team_goals_allowed_avg\n worst_team_goals_allowed_avg = this_team_goals_allowed_avg\n worst_defense_team_id = games_key\n end\n end\n end\n end\n team_with_worst_defense = team_name_finder_helper(worst_defense_team_id)\n\n team_with_worst_defense\n end", "def game_ratio(nick)\n pa = $db[:player_action]\n udb = $db[:uno]\n\n games = udb.where(nick: nick).all[0]\n\n dataset = $db[\"SELECT count(game) FROM player_action pa where pa.action = 0 and pa.player = ?\n and exists (select game from player_action pa2 where pa.game = pa2.game and pa2.action = 0 and pa2.player like 'unobot%')\n and exists (select 1 from games where id = pa.game and end is not null)\", nick]\n puts dataset.all[0].to_a[0][1].to_f, games[:games].to_f\n dataset.all[0].to_a[0][1].to_f / games[:games].to_f\nend", "def winning_team\n home_points = 0\n away_points = 0\n result = \"\"\n i = 0\n game_hash.each do |team, about|\n about[:players].each do |name , stats|\n if i == 0\n home_points += stats[:points]\n else\n away_points += stats[:points]\n end\n end\n i += 1\n end\n home_points > away_points ? result = game_hash[:home][:team_name] : result = game_hash[:away][:team_name]\nend", "def num_rounds\n (Math.log(teams.size) / Math.log(2)).to_i\n end", "def pct()\n\t (self.wins()==0) ? 0 : self.wins().to_f/(self.wins()+self.losses()) \n\tend", "def win_ratio_adjustment\n adjustment = 0\n wins = @stats[:wins].to_i\n losses = @stats[:losses].to_i\n player_games = @stats[:games].to_i\n total_games = ::Game.where('status = ?','finished').count\n\n percentage_of_games = (player_games.to_f / total_games.to_f)\n\n if wins > 0 or losses > 0\n adjustment += ((@user.wl_ratio * @ratios[:win_loss_ratio_multiplier])*(percentage_of_games*@ratios[:match_percentage_multiplier]))\n end\n\n adjustment\n end", "def avg_payoff\n payoff = []\n n_player_payoffs.each do |p|\n payoff << p.payoff \n end\n \n payoff.sum / payoff.length.to_f\n end", "def winning_team\n home_points = collection_by_prop(game_hash[:home], :points).reduce(0, :+)\n away_points = collection_by_prop(game_hash[:away], :points).reduce(0, :+)\n home_points > away_points ? game_hash[:home][:team_name] : game_hash[:away][:team_name]\n end", "def winning_team\n points_home = 0\n points_away = 0\n result = \"\"\n\n game_hash.each do |side,team|\n team.each do |specs,info|\n if specs == :players\n info.each do |player|\n if side = :home\n points_home += player[:points]\n else\n points_away += player[:points]\n end\n end\n end\n end\n end\n if points_home > points_away\n result = game_hash[:home][:team_name]\n else\n result = game_hash[:away][:team_name]\n end\n result\nend", "def avg_kills_per_shot\n 1 / avg_shots_per_kill\n end", "def avg_kills_per_shot\n 1 / avg_shots_per_kill\n end", "def average_difficulty\n @p = live_problems\n if @p.size > 0\n @avg = @p.inject(0.0){|sum, i| sum + Difficulty.to_int(i.difficulty) } / @p.size\n else\n @avg = nil\n end\n end", "def calculate_winnings\n result = 0\n self.bookings.each do |booking|\n if booking.match.status == \"FINISHED\"\n if booking.won\n result += booking.stake * booking.odd.odds\n else\n booking.stake ? result -= booking.stake : result\n end\n end\n end\n return result.round(2)\n end", "def mean_overall\n sum_overall / hits_overall\n end", "def rounds_won_percentage\n (@rounds_played > 0) ? @rounds_won.to_f / @rounds_played : 0\n end", "def winning_team\n nets = []\n hornets = []\n\n game_hash.values.each do |nets_stats|\n if nets_stats[:team_name] == \"Brooklyn Nets\"\n nets_stats[:players].each do |bk|\n nets << bk[:points]\n end\n end\n end\n\n game_hash.values.each do |hornets_stats|\n if hornets_stats[:team_name] == \"Charlotte Hornets\"\n hornets_stats[:players].each do |ch|\n hornets << ch[:points]\n end\n end\n end\n\n if nets.reduce(:+) > hornets.reduce(:+)\n return \"Brooklyn Nets\"\n else\n return \"Charlotte Hornets\"\n end\nend", "def most_accurate_team(seasonasstring) # shots in game team stats\n #get a list of all teams that played in that season - given by arg\n #use above list to sum all shots across all games in season\n #divide above by goals made across all games in season\n #find highest percentage\n #return team name as found in 127\n end", "def winning_team\n home_team_points = game_hash[:home][:players].sum { |e| e[:points] }\n away_team_points = game_hash[:away][:players].sum { |e| e[:points] }\n\n if home_team_points > away_team_points\n return game_hash[:home][:team_name]\n else\n return game_hash[:away][:team_name]\n end\nend", "def total_runs_by_teams(table_of_teams)\n hash_of_teams = Hash.new(0)\n table_of_teams.each do |table_row|\n hash_of_teams[table_row['batting_team']] += table_row['total_runs'].to_i\n end\n hash_of_teams['Rising Pune Supergiants'] += hash_of_teams['Rising Pune Supergiant']\n hash_of_teams.delete('Rising Pune Supergiant')\n hash_of_teams\nend", "def week_1_total\n total = 0\n rostered_players.each do |rostered_player|\n total += rostered_player.player.week_1_score\n end\n return total\n end", "def total_rounds(teams_count)\n Math.log2(teams_count).ceil\n end", "def total_rounds(teams_count)\n Math.log2(teams_count).ceil\n end", "def average_test(limit)\n (0..15).each do |skill|\n gamecount = 0\n pintotal = 0\n minscore = 300\n maxscore = 0\n\n until gamecount == limit\n newgame\n @players << skill\n reset_arrays\n playgame\n gamecount += 1\n pintotal += @game_scores[0][-1]\n \n minscore = @game_scores[0][-1] if @game_scores[0][-1] < minscore\n maxscore = @game_scores[0][-1] if @game_scores[0][-1] > maxscore\n end\n\n print \"#{skill}\\t#{gamecount}\\tavg\"\n print \"#{(pintotal / gamecount)}\".rjust(4), \"#{minscore}/#{maxscore}\".rjust(9), \"\\n\"\n puts\n end\nend", "def overall_WLR\n overall_losses = 0\n overall_wins = 0\n @player_champs_list.each do |champ|\n overall_losses += champ.total_losses\n overall_wins += champ.total_wins\n end\n overall_losses > 0 ? (overall_wins.to_f / overall_losses).round(2) : overall_wins.to_f\n end", "def its_a_tie game\n game.each do |team|\n team_standings = get_team_by_name(team)\n team_standings[:winnings] += 1\n end\nend", "def best_defense\n teams_total_goals_allowed = total_goals_allowed_helper\n teams_total_games = total_games_helper\n\n best_team_goals_allowed_avg = 100\n best_defense_team_id = 0\n this_team_goals_allowed_avg = 0\n\n teams_total_games.each do |games_key, games_value|\n teams_total_goals_allowed.each do |goals_key, goals_value|\n if goals_key == games_key\n this_team_goals_allowed_avg = (goals_value / games_value.to_f)\n if this_team_goals_allowed_avg < best_team_goals_allowed_avg\n best_team_goals_allowed_avg = this_team_goals_allowed_avg\n best_defense_team_id = games_key\n end\n end\n end\n end\n\n team_with_best_defense = nil\n self.teams.each_value do |team_obj|\n if team_obj.team_id. == best_defense_team_id\n team_with_best_defense = team_obj.team_name\n end\n end\n team_with_best_defense\n end", "def probability_by_win_ratio(delta)\n # A team wins between 0% and 100% of its games\n # Comparing two teams, the difference in percentages will also be between 0% and 100%\n # If they have equal win percentages, then it is a tossup--50/50\n # If one team has won 100% and the other has won 0%,\n # ...then there is a 100% win percentage different between them\n # ...in that case, the odds should be 100% in favor of the 100% team.\n 0.5 + 0.5 * delta\nend", "def oppg\n (opp_possessions.to_f)/games\n end", "def oppg\n (opp_possessions.to_f)/games\n end", "def update_score\n games = Hash.new([])\n predictions.each do |prediction|\n key = prediction.match_id\n games[key] = {}\n games[key][:teams] = []\n games[key][:round] = prediction.round_id\n unless prediction.winner.nil?\n games[key][:teams] << prediction.winner.id\n end\n end\n Game.includes(:team1, :team2).find_each do |game|\n key = game.match_id\n unless game.winner.nil?\n games[key][:teams] << game.winner.id\n end\n end\n\n puts games.inspect\n\n score = 0\n games.each do |key, data|\n round = games[key][:round]\n winners = games[key][:teams]\n if winners.length == 2 and winners.first == winners.last\n score += (2 ** (round))\n end\n end\n self.update_attributes :score => score\n end", "def total_games_by_coach_by_season\n @total_games_by_coach = Hash.new{ |hash, key| hash[key] = 0}\n @by_season_game_team_objects.each do |game_by_season|\n @total_games_by_coach[game_by_season[\"head_coach\"]] += 1\n end\n end", "def ranks\n @teams = Team.where(\"wins > 0\t\").order(win_percentage: :desc)\n end", "def average_player_age\n players.average(:age)\n end", "def pri_tdef\n team_stats.opp_goals_per_game / team_stats.opp_avg_goals_against_per_game\n end", "def num_games win_condition\n total_games = 0\n @game_objects.each do |game|\n total_games += 1 if game_meets_win_cond?(win_condition, game)\n end \n total_games\n end", "def total_rounds(driver)\n Algorithm::SingleBracket.total_rounds(driver.seeded_teams.length)\n end", "def winningest_team\n @teams.max_by { |team| team.total_win_percentage }.team_name\n end", "def wins_losses\n GAME_INFO.each do |game|\n @team_records.each do |team|\n if game[:home_team] == team.name && game[:home_score] > game[:away_score] #refactor later\n team.wins += 1\n elsif game[:home_team] == team.name && game[:home_score] < game[:away_score]\n team.losses += 1\n end\n end\n end\n\n GAME_INFO.each do |game|\n @team_records.each do |team|\n if game[:away_team] == team.name && game[:away_score] > game[:home_score] #refactor later\n team.wins += 1\n elsif game[:away_team] == team.name && game[:away_score] < game[:home_score]\n team.losses += 1\n end\n end\n end\n\n end", "def win_ratio\n\t\t\n\t\t(((self.wins_total.to_f) / (self.wins_total.to_f + self.loss_total.to_f))*100).round(2)\n\n\t\t#Ruby naturally returns the last line that was executed\n\t\t#do not need any other variable named win_ratio\n\n\tend", "def winning_team\n home_points = 0\n away_points = 0\n team1 = \"Brooklyn Nets\"\n team2 = \"Charlotte Hornets\"\n game_hash.each do |team,info|\n info.each do |team_info,team_data|\n if team_data.is_a? (Array) \n if team_info != :colors\n if info[:team_name] == \"Brooklyn Nets\"\n team_data.each do |player_index|\n home_points += player_index[:points]\n end\n else \n team_data.each do |player_index|\n away_points += player_index[:points]\n winning_team end\n end\n end\n end\n end\n end\n\n if home_points > away_points\n team1\n else\n team2\n end\n\nend", "def starters_average\n total = self.players.starter.inject(0) {|result, element| result + element.average_qualities}\n return total / MIN_PLAYERS\n end", "def test_average_goals_per_game\n\n assert_equal 4.22, @stat_tracker.average_goals_per_game\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 calculate_final_score\n self.scores.average(:total_score)\n end", "def average_finish_time(game, nb_game)\n\n#On initialise la somme des nombres de laps\nsomme = 0\n\n#On teste si le nombre de parties > 100, si non on n'accpete pas\n\tif nb_game < 100 then puts \"Il faut un nombre > 100 !\"\n\n#Si oui, on lance nb_parties (en l'occurence 150) fois le jeu (en l'occurence Stairways)\n\telse\n\t\t\tnb_game.times do game\n\t\t\tsomme += stairway\n\t\t\tend\n\n#On affiche la moyenne du nombre de parties\n\t\tputs \"**************************************************************************\"\n\t\tputs \"Le score moyen de vos #{nb_game} parties est de #{somme/nb_game} !\"\n\t\tputs \"**************************************************************************\"\n\n\tend\n\nend", "def calculate_round_score(match)\n round_score = 0\n scores = Holescore.where(user: current_user, match: match)\n scores.each do |score|\n round_score += score.gross_score\n end\n round_score\n end", "def winning_team\n if homeTeamPoints.sum > awayTeamPoints.sum\n \"Brooklyn Nets\"\n else\n \"Charlotte Hornets\"\n end\nend", "def average_of(raitingss)\n raitingss.sum(&:score).to_f / raitingss.count\n end", "def recalculate_average_ranking\r\n self.funk_count = Ranking.find_average_ranking_by_story(self.id)\r\n end", "def get_avg\n recentReviewed = get_user_cards(Result.all)\n filteredDates = get_dates(recentReviewed)\n totalScore = filteredDates.reduce(0) {|curr,n| curr + n.score} \n totalScore/filteredDates.count \n end", "def avg_adjusted_payoff\n \tpayoff = []\n \tn_player_adjusted_payoffs.each do |p|\n \t\tpayoff << p.payoff\n \tend\n\n \tpayoff.sum.to_f / payoff.length.to_f\n end", "def total_points\n\n points = 0\n wattball_matches_as_team1.each do |match|\n points += match.points(1) || 0\n end\n\n wattball_matches_as_team2.each do |match|\n points += match.points(2) || 0\n end\n\n points\n end", "def get_win_damage(load_file)\n data = JSON.parse(File.open(\"#{load_file}\", \"r\").read) # Parse the json into an array\n deck_1_number_wins = 0\n deck_2_number_wins = 0 \n deck_1_win_damage = 0\n deck_2_win_damage = 0 \n total_win_damage = 0.0\n \n # Get the total number of times each player won\n data.each do |item|\n if item['random_winner'] == 'Deck_1' \n deck_1_number_wins = deck_1_number_wins +1\n deck_1_win_damage = deck_1_win_damage + item['damge_dealt_on_final_turn']\n total_win_damage = total_win_damage + item['damge_dealt_on_final_turn']\n else\n deck_2_number_wins = deck_2_number_wins +1\n deck_2_win_damage = deck_2_win_damage + item['damge_dealt_on_final_turn']\n total_win_damage = total_win_damage + item['damge_dealt_on_final_turn']\n end\n end\n \n # Calculate win damage and convert that number to a float\n deck_1_avg_win_damage = deck_1_win_damage/deck_1_number_wins.to_f\n deck_2_avg_win_damage = deck_2_win_damage/deck_2_number_wins.to_f\n total_win_damage = total_win_damage/data.size.to_f\n\n puts \"Deck 1 on avgerage wins by dealing #{deck_1_avg_win_damage}\"\n puts \"Deck 2 on avgerage wins by dealing #{deck_2_avg_win_damage}\"\n puts \"On avgerage the game ends by dealing #{total_win_damage}\" \n end", "def average_score\n responses = Response.all\n sum = 0\n count = 0\n\n responses.each do |response|\n r_summary = response.summarize\n if r_summary[self.name][:nrm]\n sum += r_summary[self.name][:nrm]\n count += 1\n end\n end\n\n return (sum/count).round\n end", "def rankings\n self.total_against_goals = 0\n self.total_goals = 0\n if self.players != []\n self.players.each do |player|\n if player.scores.first != nil\n Game.all.each do |game|\n unless self.total_goals.nil? || self.total_against_goals.nil? || game.scores.last.goals.nil? || game.scores.first.goals.nil?\n if game.scores.first.player == player\n self.total_goals += game.scores.first.goals\n self.total_against_goals += game.scores.last.goals\n else\n self.total_goals += game.scores.last.goals\n self.total_against_goals += game.scores.first.goals\n end\n self.save\n end\n end\n end\n end\n end\n end", "def winning_scores\n high_score = scores.max{|score| score.total}.total\n scores.select {|score| score.total == high_score}\n end", "def get_average_age_for_season(data, season)\n age_total = 0\n num_of_contestants = 0\n data[season].each do |contestant_hash|\n age_total += (contestant_hash[\"age\"]).to_i\n num_of_contestants += 1\n end\n (age_total / num_of_contestants.to_f).round(0)\nend", "def sets_won(team)\n match_sets.reduce(0) do |sum, set|\n winner = set.compute_team_winner\n sum + (winner && winner == team ? 1 : 0)\n end\n end", "def calculate_overall_winner\n points_per_player = {}\n @matches.each do | match |\n !points_per_player[match.winner].nil? ? (points_per_player[match.winner] += 1) : (points_per_player[match.winner] = 1)\n end\n max_points = points_per_player.values.max\n points_per_player.key(max_points)\n end", "def get_percent_of_vote\n\t\t(@votes.count(@winner).to_f / @votes.count.to_f * 100).round\n\tend", "def game_score\n previous_hands = self.game_player.hand_players.joins(:hand).where(\n \"hands.position <= ?\", self.hand.position\n )\n gs = 0\n for h in previous_hands\n gs += h.hand_score\n end\n return gs\n end", "def average_score\n count = 0.0\n avrg = 0.0\n if self.cadets.empty?\n return 0.0\n else\n self.cadets.each do |cdt|\n unless cdt.discharged?\n avrg += cdt.average_score\n count += 1.0\n end\n end\n return count != 0.0 ? (avrg/count).round(1) : 0.0\n end\n end", "def bp_odds_on_favorite\n\t\tfav_team=Teamseason.new\n\t\tfav_team.year=self.matchup_year\n\t\tfav_team.team=self.favorite \n\t\tunderdog_team=Teamseason.new\n\t\tunderdog_team.year=self.matchup_year\n\t\tunderdog_team.team=self.underdog\n\t\treturn fav_team.bp_ros_win_pct.to_f.odds_against_opponent(underdog_team.bp_ros_win_pct.to_f)\n\tend", "def lowest_total_score\n total_game_scores = games.map { |game| game.home_goals + game.away_goals}\n total_game_scores.min\n end", "def get_game_stats(game)\n agent = Mechanize.new\n html = agent.get(\"http://espn.go.com/ncb/boxscore?gameId=#{game.gameID}\").body\n doc = Nokogiri::HTML(html)\n\n awayRecs = doc.xpath(\"//div[@class = 'team-info']\").css(\"p\")[0].text\n awayOvrRaw = awayRecs.scan(/(\\d+)-(\\d+),.*/)\n if(awayOvrRaw != [] )\n awayOvrPer = awayOvrRaw[0][0].to_f / (awayOvrRaw[0][1].to_f + awayOvrRaw[0][0].to_f)\n else\n awayOvrPer = 0.05\n end\n awayRaw = awayRecs.scan(/.*, (\\d+)-(\\d+)/)\n if(awayRaw != [])\n awayPer = awayRaw[0][0].to_f / (awayRaw[0][1].to_f + awayRaw[0][0].to_f)\n else\n awayPer = 0.05 \n end\n homeRecs = doc.xpath(\"//div[@class = 'team-info']\").css(\"p\")[1].text\n homeOvrRaw = homeRecs.scan(/(\\d+)-(\\d+),.*/)\n if(homeOvrRaw != [])\n homeOvrPer = homeOvrRaw[0][0].to_f / (homeOvrRaw[0][1].to_f + homeOvrRaw[0][0].to_f) \n else\n homeOvrPer = 0.05\n end\n homeRaw = homeRecs.scan(/.*, (\\d+)-(\\d+)/)\n if(homeRaw != [])\n homePer = homeRaw[0][0].to_f / (homeRaw[0][1].to_f + homeRaw[0][0].to_f)\n else\n homePer = 0.05\n end\n # Find the table with information\n table = doc.xpath('//table[@class = \"mod-data\"]')\n rows = table.css('tbody')\n\n # Declare variables\n isHome = false\n homePoints = 0\n awayPoints = 0\n\n # Get data for game\n rows.each do |row|\n col = row.css('td')\n if(col.count == 18)\n fg = col[1].text.scan((/(\\d+)-(\\d+)/)) \n fgm = fg[0][0].to_f\n fga = fg[0][1].to_f\n fgPer = fgm / fga\n\n threeP = col[2].text.scan((/(\\d+)-(\\d+)/))\n threePM = threeP[0][0].to_f\n threePA = threeP[0][1].to_f\n threePer = threePM / threePA\n\n twoPM = fgm - threePM\n twoPA = fga - threePA\n twoPer = twoPM.to_f / twoPA.to_f\n\n ft = col[3].text.scan((/(\\d+)-(\\d+)/))\n ftm = ft[0][0].to_f\n fta = ft[0][1].to_f\n ftPer = ftm / fta\n\n offReb = col[4].text.to_f\n defReb = col[5].text.to_f\n totReb = col[6].text.to_f\n assists = col[7].text.to_f\n steals = col[8].text.to_f\n blocks = col[9].text.to_f\n to = col[10].text.to_f\n pf = col[11].text.to_f\n\n points = col[12].text.to_f\n pps = points / fga\n adjFG = ((points - ftm)/ fga)/ 2\n\n apto = assists / to\n spto = steals / to\n spf = steals / pf\n bpf = blocks / pf\n \n # Updates specific game entry with newly scraped data\n if(isHome)\n game.update(homePoints: points, homefgm: fgm, homefga: fga, homefgPer: fgPer, hometwoMade: twoPM, hometwoAtt: twoPA, hometwoPer: twoPer, homethreeMade: threePM, homethreeAtt: threePA, homethreePer: threePer, homeftm: ftm, homefta: fta, homeftPer: ftPer, homeoffReb: offReb, homedefReb: defReb, hometotalReb: totReb, homepps: pps, homeadjFG: adjFG, homeassist: assists, hometo: to, homeapto: apto, homesteals: steals, homefouls: pf, homestealPerTO: spto, homestealPerFoul: spf, homeblocks: blocks, homeblocksPerFoul: bpf, homeOvrWL: homeOvrPer, homeHomeWL: homePer)\n elsif\n game.update(awaypoints: points, awayfgm: fgm, awayfga: fga, awayfgPer: fgPer, awaytwoMade: twoPM, awaytwoAtt: twoPA, awaytwoPer: twoPer, awaythreeMade: threePM, awaythreeAtt: threePA, awaythreePer: threePer, awayftm: ftm, awayfta: fta, awayftPer: ftPer, awayoffReb: offReb, awaydefReb: defReb, awaytotalReb: totReb, awaypps: pps, awayadjFG: adjFG, awayassist: assists, awayto: to, awayapto: apto, awaysteals: steals, awayfouls: pf, awaystealPerTO: spto, awaystealPerFoul: spf, awayblocks: blocks, awayblocksPerFoul: bpf, awayOvrWL: homeOvrPer, awayAwayWL: awayPer)\n end\n\n # Always two rows, first is away, second is home\n isHome = true\n end\n end \n end" ]
[ "0.82220864", "0.81050754", "0.7811368", "0.7612407", "0.7587351", "0.75753987", "0.7478595", "0.73588836", "0.7306268", "0.7217924", "0.7104949", "0.7067641", "0.703548", "0.7023692", "0.6947532", "0.69440997", "0.69225234", "0.68818915", "0.68685067", "0.68294066", "0.6812262", "0.6800547", "0.6764071", "0.67082673", "0.6669416", "0.66493773", "0.66331387", "0.66002816", "0.6598271", "0.6593341", "0.65890545", "0.6586193", "0.6573821", "0.6567239", "0.65594685", "0.6550932", "0.6532793", "0.6491376", "0.6487501", "0.64772207", "0.6445862", "0.6443884", "0.6432607", "0.643026", "0.64279586", "0.64279586", "0.64179415", "0.64123255", "0.63987434", "0.63915527", "0.63855505", "0.63823956", "0.6373366", "0.63609624", "0.633607", "0.63299954", "0.63299954", "0.63031423", "0.62964845", "0.6295305", "0.62949586", "0.6289001", "0.6275718", "0.6275718", "0.62753135", "0.62733996", "0.6269491", "0.6264717", "0.6239955", "0.62316126", "0.62234634", "0.62198603", "0.6217559", "0.6207571", "0.6192961", "0.6189007", "0.6179263", "0.612928", "0.6128349", "0.6118693", "0.6117134", "0.61070263", "0.6103688", "0.60932195", "0.6091673", "0.6091602", "0.60909355", "0.60864353", "0.6077528", "0.60770774", "0.6076769", "0.60753244", "0.60681427", "0.6064345", "0.6060154", "0.60600555", "0.6058433", "0.6050301", "0.6050037", "0.60498095" ]
0.8292118
0
returns the highest number of goals a particular team has scored in a game
def most_goals_scored(team_id) team_id = team_id.to_i goals_per_game = @game_teams.map do |game| if game.team_id == team_id game.goals end end goals_per_game.compact.max end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def highest_total_score\n total_goals.max\n end", "def fewest_goals_scored(team_id)\n team_id = team_id.to_i\n goals_per_game = @game_teams.map do |game|\n if game.team_id == team_id\n game.goals\n end\n end\n goals_per_game.compact.min\n end", "def biggest_blowout\n score_difference = games.map { |game| (game.home_goals - game.away_goals).abs}\n score_difference.max\n end", "def biggest_team_blowout(team_id)\n @games.map do |game|\n if game.away_team_id.to_s == team_id\n game.away_goals - game.home_goals\n elsif game.home_team_id.to_s == team_id\n game.home_goals - game.away_goals\n end\n end.compact.max\n end", "def highest_scoring_visitor\n @teams.max_by { |team| team.average_away_goals }.team_name\n end", "def worst_loss(team_id)\n @games.map do |game|\n if game.away_team_id.to_s == team_id\n game.home_goals - game.away_goals\n elsif game.home_team_id.to_s == team_id\n game.away_goals - game.home_goals\n end\n end.compact.max\n end", "def most_points_scored\n max = nil\n name = nil \n game_hash.each do |team, team_values|\n team_values[:players].each do |player|\n if max == nil || player[:points] > max\n max = player[:points]\n name = player[:player_name]\n end\n end\n end\n name\nend", "def winningest_team\n @teams.max_by { |team| team.total_win_percentage }.team_name\n end", "def big_shoe_rebounds\n max_shoe = 0 \n max_rebounds = 0 \n game_hash.each do |place, team|\n # team.each do |attribute, data|\n team[:players].each do |player|\n if player[:shoe] > max_shoe\n max_shoe = player[:shoe]\n max_rebounds = player[:rebounds]\n # if attribute == :players\n # data.each do |player|\n #this gives me the player hashes\n # data.max_by{|player| player[:shoe] }\n # data.max_by{|player| player[:shoe] }[:rebounds]\n # player.max_by{|player| player[:shoe] \n # player.max_by{|player| player[:shoe] }[:rebounds]\n end\n end\n end\n return max_rebounds\n end", "def highest_scoring_home_team\n @teams.max_by { |team| team.average_home_goals }.team_name\n end", "def worst_defense\n @teams.max_by { |team| team.average_goals_allowed }.team_name\n end", "def most_points_scored\n points_scored = 0 # starting score to compare with players shoe sizes\n game_hash.each do |location, team_data| # iterates through each team\n players_array = team_data[:players] # finds the :players info in team_data and puts the players into players_array\n players_array.each do |player_name, data| # iterates through each player..\n if data[:points] > points_scored # if their points scored is greater than 0 (we set this earlier in the top of method)\n points_scored = data[:shoe] # take that players score and make it the new points_scored value\n end # this repeats (iterates) through all players until you don't have any more.. meaning the end result is\n end # the player with the highest score\n end\n return points_scored\nend", "def goals_for(team)\n valid = ((team == self.home_team or team == self.away_team) and self.final)\n\n if (valid)\n if (self.home_team == team)\n return self.homeScore\n else\n return self.awayScore\n end\n else\n return 0\n end\n end", "def most_points_scored\n most_points = 0\n most_points_player = nil\n game_hash.each do |team, team_stats|\n team_stats[:players].each do |player_stats|\n if most_points < player_stats[:points]\n most_points = player_stats[:points]\n most_points_player = player_stats[:player_name]\n end\n end\n end\n most_points_player\nend", "def best_offense\n @teams.max_by { |team| team.average_goals_scored }.team_name\n end", "def determine_winner game\n winner = game.max_by {|team| team[:score]}\n team_standings = get_team_by_name(winner)\n team_standings[:winnings] += 3\nend", "def big_shoe_rebounds\n\nhighest_rebounds = 0\nbiggest_shoe = 0\n\n game_hash.each do |location, team_info|\n game_hash.dig(location, :players).each do |player_name, stats|\n stats.each do |stat, number|\n if stat == :shoe\n if number > biggest_shoe\n biggest_shoe = number\n stats.each do |stat, number|\n if stat == :rebounds\n highest_rebounds = number\n end\n end\n end\n end\n end\n end\n end\n puts highest_rebounds\n return highest_rebounds\nend", "def player_w_biggest_feet\n all_players[1].max_by { |stats| stats[:shoe] }\n end", "def most_points_scored\n most_points = 0\n player = \"\"\n game_hash.each do |k, team|\n team[:players].each do |e|\n if e[:points] > most_points\n most_points = e[:points]\n player = e[:player_name]\n end\n end\n end\n player\nend", "def most_hits(seasonasstring) # shots in game team stats\n #get a list of all teams that played in that season\n #use above list to sum all shots across all games in season\n #find highest across list\n #return team name as found in 139\n end", "def goals_against(team)\n valid = ((team == self.home_team or team == self.away_team) and self.final)\n\n if (valid)\n if (self.home_team == team)\n return self.awayScore\n else\n return self.homeScore\n end\n else\n return 0\n end\n end", "def most_points(game)\n player_name_with_points = []\n game[:home_team][:players].each do |player_hash|\n player_name_with_points << {player_hash[:player_name] => player_hash[:stats][:points]}\n end\n game[:away_team][:players].each do |player_hash|\n player_name_with_points << {player_hash[:player_name] => player_hash[:stats][:points]}\n end\n player_most_points = {\"test\" => 0}\n player_name_with_points.each do |name_and_points_hash|\n player_most_points = name_and_points_hash if name_and_points_hash.values[0] > player_most_points.values[0]\n end\n player_most_points.keys[0]\nend", "def big_shoe_rebounds_2\n\nhighest_rebounds = 0\nbiggest_shoe = 0\n\n\n game_hash.dig(:home, :players).each do |player_name, stats|\n stats.each do |stat, number|\n if stat == :shoe\n if number > biggest_shoe\n biggest_shoe = number\n stats.each do |stat, number|\n if stat == :rebounds\n highest_rebounds = number\n\n end\n end\n end\n end\n end\nend\n\n puts highest_rebounds\n return highest_rebounds\nend", "def most_points(game)\nmax_points = 0\nmax_points_player = \"\"\ngame.each do |team, team_contents|\n team_contents[:roster].each do |player, player_contents| \n if player_contents[:points] == max_points\n max_points_player = max_points_player + \" and #{player_contents[:player_name]}\"\n elsif player_contents[:points] > max_points\n max_points = player_contents[:points]\n max_points_player = player_contents[:player_name]\n end\n end\nend\nputs \"#{max_points_player} scored #{max_points}\"\nend", "def mostSteals\n players.max_by do|name, stats|\n stats[:steals]\n end\nend", "def winning_team\n self.teams.order('score DESC').first\n end", "def team_with_more_points(game)\n home_points = game[:home_team][:players].collect do |player|\n player[:stats][:points]\n end.inject {|sum, n| sum + n}\n away_points = game[:away_team][:players].collect do |player|\n player[:stats][:points]\n end.inject {|sum, n| sum + n}\n home_points > away_points ? game[:home_team][:team_name] : game[:away_team][:team_name]\nend", "def biggestShoes\n players.max_by do|name, stats|\n stats[:shoe]\n end\nend", "def winning_team\n home_team_points = game_hash[:home][:players].sum { |e| e[:points] }\n away_team_points = game_hash[:away][:players].sum { |e| e[:points] }\n\n if home_team_points > away_team_points\n return game_hash[:home][:team_name]\n else\n return game_hash[:away][:team_name]\n end\nend", "def worst_offense\n teams_total_goals = total_goals_helper\n teams_total_games = total_games_helper\n\n worst_team_goals_avg = 1000\n worst_offense_team_id = 0\n this_team_goals_avg = 0\n\n teams_total_games.each do |games_key, games_value|\n teams_total_goals.each do |goals_key, goals_value|\n if goals_key == games_key\n this_team_goals_avg = (goals_value / games_value.to_f)\n if this_team_goals_avg < worst_team_goals_avg\n worst_team_goals_avg = this_team_goals_avg\n worst_offense_team_id = games_key\n end\n end\n end\n end\n\n team_with_worst_offense = nil\n self.teams.each_value do |team_obj|\n if team_obj.team_id. == worst_offense_team_id\n team_with_worst_offense = team_obj.team_name\n end\n end\n team_with_worst_offense\n end", "def highest_total_score\n @game_manager.highest_total_score\n end", "def highest_player_score\n players.max_by{|player| player.score}.score\n end", "def max_sets_to_play\n case scoring.to_sym\n when :two_six_game_ten_point\n 3\n when :one_eight_game\n 1\n else # :three_six_game\n 3\n end\n end", "def most_steals(game)\nmax_steals = 0\nmax_steals_player = \"\"\ngame.each do |team, team_contents|\n team_contents[:roster].each do |player, player_contents| \n if player_contents[:steals] == max_steals\n max_steals_player = max_steals_player + \" and #{player_contents[:player_name]}\"\n elsif player_contents[:steals] > max_steals\n max_steals = player_contents[:steals]\n max_steals_player = player_contents[:player_name]\n end\n end\nend\nmax_steals_player\nend", "def winning_scores\n high_score = scores.max{|score| score.total}.total\n scores.select {|score| score.total == high_score}\n end", "def winning_team\n home_points = collection_by_prop(game_hash[:home], :points).reduce(0, :+)\n away_points = collection_by_prop(game_hash[:away], :points).reduce(0, :+)\n home_points > away_points ? game_hash[:home][:team_name] : game_hash[:away][:team_name]\n end", "def most_steals \n num_steals = 0\n game_hash.each do |team,info|\n info.each do |team_info,team_data|\n if team_data.is_a? (Array) \n if team_info != :colors\n team_data.each do |player_index|\n if num_steals == 0 || player_index[:steals] > num_steals \n num_steals = player_index[:steals] \n end\n end\n end\n end\n end\n end\nnum_steals\nend", "def worst_defense\n teams_total_goals_allowed = total_goals_allowed_helper\n teams_total_games = total_games_helper\n\n worst_team_goals_allowed_avg = 0\n worst_defense_team_id = 0\n this_team_goals_allowed_avg = 0\n\n teams_total_games.each do |games_key, games_value|\n\n teams_total_goals_allowed.each do |goals_key, goals_value|\n if goals_key == games_key\n this_team_goals_allowed_avg = (goals_value / games_value.to_f)\n if this_team_goals_allowed_avg > worst_team_goals_allowed_avg\n worst_team_goals_allowed_avg = this_team_goals_allowed_avg\n worst_defense_team_id = games_key\n end\n end\n end\n end\n team_with_worst_defense = team_name_finder_helper(worst_defense_team_id)\n\n team_with_worst_defense\n end", "def winning_team\n final_scores = player_collection.reduce(home: 0, away: 0) { |teams_points, next_player|\n case \n when next_player[:location] === :away\n teams_points[:away] += next_player[:points];\n when next_player[:location] === :home\n teams_points[:home] += next_player[:points];\n end\n teams_points; \n }\n winner = final_scores.reduce { |highest_points, team_points| \n highest_points[1] > team_points[1] ? highest_points : team_points; \n }\n game_hash[winner[0]][:team_name]; \nend", "def most_points_scored\n points = 0\n result = \"\"\n game_hash.each do |team, about|\n about[:players].each do |name , stats|\n if points < stats[:points]\n points = stats[:points]\n result = name\n end\n end\n end\n result\nend", "def big_shoe_rebounds\n # Set two objects to equal integer values of 0 to be called/changed by the method\n biggest_shoe_size = 0\n number_of_rebounds = 0\n \n game_hash.each do |location, team_data|\n team_data[:players].each do |attributes| # Calls the stats of each player within the :players array \n if attributes[:shoe] > biggest_shoe_size # Finds and calls the largest integer value in the shoe key\n biggest_shoe_size = attributes[:shoe] # Sets value for biggest_shoe_size to equal the shoe value\n number_of_rebounds = attributes[:rebounds] # Sets value for number_of_rebounds to equal the rebounds value\n end\n end\n end\n return number_of_rebounds\nend", "def most_points_scored\n\tpoints_array = []\n\tgame_hash.each do |location, team_data|\n\t\tteam_data[:players].each do |attribute, data|\t\n\t\t\tdata.each do |type, amount|\n\t\t\t\tif type == :points\n\t\t\t\t\tpoints_array << amount\n\t\t\t\tend \n\t\t\tend\n\t\tend\n\tend\n\tgame_hash.each do |l, data|\n\t\tdata[:players].each do |a, d|\n\t\t\td.each do |t, amt|\n\t\t\t\tif t == :points && points_array.max == amt\n\t\t\t\t\treturn a\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend\nend", "def most_points_scored\n stat_by_player = collect_stat_by_name(:points)\n player_with_max_stat = find_max_stat_by_player(stat_by_player)\n player_with_max_stat\nend", "def worst_offense\n @teams.min_by { |team| team.average_goals_scored }.team_name\n end", "def winning_team\n home_team_sum = 0\n away_team_sum = 0\n game_hash.each do |team, team_stats|\n if team_stats[:team_name] == \"Brooklyn Nets\"\n team_stats[:players].each do |player_stats|\n home_team_sum += player_stats[:points]\n end\n elsif team_stats[:team_name] == \"Charlotte Hornets\"\n team_stats[:players].each do |player_stats|\n away_team_sum += player_stats[:points]\n end\n end\n end\n if home_team_sum > away_team_sum\n game_hash[:home][:team_name]\n elsif home_team_sum < away_team_sum\n game_hash[:away][:team_name]\n end\nend", "def most_accurate_team(seasonasstring) # shots in game team stats\n #get a list of all teams that played in that season - given by arg\n #use above list to sum all shots across all games in season\n #divide above by goals made across all games in season\n #find highest percentage\n #return team name as found in 127\n end", "def player_with_most_steals\n name = \"\"\n most_steals = 0\n\n game_hash.each do | team, details_hash |\n players_array = details_hash[:players]\n players_array.each do | player_details_hash |\n if player_details_hash[:steals] > most_steals\n most_steals = player_details_hash[:steals]\n name = player_details_hash[:player_name]\n end\n end\n end\n name\nend", "def best_defense\n teams_total_goals_allowed = total_goals_allowed_helper\n teams_total_games = total_games_helper\n\n best_team_goals_allowed_avg = 100\n best_defense_team_id = 0\n this_team_goals_allowed_avg = 0\n\n teams_total_games.each do |games_key, games_value|\n teams_total_goals_allowed.each do |goals_key, goals_value|\n if goals_key == games_key\n this_team_goals_allowed_avg = (goals_value / games_value.to_f)\n if this_team_goals_allowed_avg < best_team_goals_allowed_avg\n best_team_goals_allowed_avg = this_team_goals_allowed_avg\n best_defense_team_id = games_key\n end\n end\n end\n end\n\n team_with_best_defense = nil\n self.teams.each_value do |team_obj|\n if team_obj.team_id. == best_defense_team_id\n team_with_best_defense = team_obj.team_name\n end\n end\n team_with_best_defense\n end", "def most_points_scored\nbest_player = \"\"\npoints = 0\ngame_hash.each do |location, team_data|\n team_data[:players].each do |name, stats|\n if stats[:points] > points\n points = stats[:points]\n best_player= name\n end\n end\nend\nbest_player\nend", "def goals_against()\n\t self.as_regular_contestants.select{|c| c.opponent.score}.collect{|c| c.opponent.score}.inject{|gf, c| gf + c} || 0\n\tend", "def big_shoe_rebounds\n biggest = 0\n rebounds = 0\n game_hash.each do |team, team_data|\n team_data[:players].each do |player|\n size = player[:shoe]\n if size > biggest\n biggest = size\n rebounds = player[:rebounds]\n end\n end\n end\n rebounds\nend", "def most_points_scored()\n points = 0\n result = \"\"\n\n game_hash.each do |side,team|\n team.each do |specs,info|\n if specs == :players\n info.each do |player|\n if player[:points] > points\n points = player[:points]\n result = player[:player_name]\n\n end\n end\n end\n end\n end\n result\nend", "def highest_match_count\n match_count = Hash.new(0)\n\n @hand.each { |dice| match_count[dice] += 1 }\n\n match_count.values.max\n end", "def most_points_scored\n most_points_scored = 0\n player_with_the_most_points_scored = \"\"\n game_hash.each do |team,info|\n info.each do |team_info,team_data|\n if team_data.is_a? (Array) \n if team_info != :colors\n team_data.each do |player_index|\n if most_points_scored == 0 || player_index[:points] > most_points_scored \n most_points_scored = player_index[:points]\n player_with_the_most_points_scored = player_index[:player_name]\n end\n end\n end\n end\n end\n end\n player_with_the_most_points_scored\nend", "def get_max_over(stat)\n max = 0\n $data_enemies.each { |enemy|\n next if enemy.nil?\n next if enemy.hidden_best\n next unless $game_party.known_enemy?(enemy.id)\n value = enemy.get_stat(stat)\n max = value if value > max\n }\n max\n end", "def most_steals\r\n result={}\r\n game_hash.each do |k, v|\r\n v.each do| p, d|\r\n if p==:players\r\n d.each do |t, s|\r\n result[t]=s[:steals]\r\n end\r\n end\r\n end\r\n end \r\n result.max_by {|name, steal| steal}[0]\r\nend", "def winning_team\n home_score = 0\n away_score = 0\n game_hash[:home][:players].keys.each do |name|\n home_score += game_hash[:home][:players][name][:points]\n end\n game_hash[:away][:players].keys.each do |name|\n away_score += game_hash[:away][:players][name][:points]\n end\n home_score > away_score ? game_hash[:home][:team_name] : game_hash[:away][:team_name]\nend", "def winning_team\n team_p = []\n team_n = []\n\n game_hash.each do | location, team_data|\n temp = 0\n team_data[:players].each do |p_name, stats|\n temp += stats[:points]\n end\n team_n << team_data[:team_name]\n team_p << temp\n end\n\n team_p[0] > team_p[1] ? team_n[0] : team_n[1]\n\nend", "def big_shoe_rebounds\n biggest_shoe_size = 0\n player_rebounds = 0\n game_hash.each do |k, team|\n team[:players].each do |e|\n if e[:shoe] > biggest_shoe_size\n biggest_shoe_size = e[:shoe]\n player_rebounds = e[:rebounds]\n end\n end\n end\n player_rebounds\nend", "def most_points_scored\n most_points = 0 \n name = nil\n game_hash.each { |keys, values|\n i = 0\n while i < game_hash[keys][:players].length do \n if game_hash[keys][:players][i][:points] > most_points\n most_points = game_hash[keys][:players][i][:points]\n name = game_hash[keys][:players][i][:player_name]\n end\n i += 1\n end\n }\n name\n # binding.pry\nend", "def get_highest_for(turn)\n\t\tif @highs[1][turn] > @highs[2][turn] then 1 else 2 end\n\tend", "def big_shoe_rebounds\n hash = game_hash\n #first find largest shoe size\n max_size = 0\n hash.each do |location, team_data|\n\n hash[location][:players].each do |name, values|\n if hash[location][:players][name][:shoe] > max_size\n max_size = hash[location][:players][name][:shoe]\n end\n end\n end\n\n #then return the player's number of rebounds\n hash.each do |location, team_data|\n hash[location][:players].each do |name, values|\n if hash[location][:players][name][:shoe] == max_size\n return hash[location][:players][name][:rebounds]\n end\n end\n end\n\nend", "def player_with_most_steal\n most_steals = nil\n most_steal_player = nil\n\n all_players(game_hash).each do |player|\n if most_steals == nil || player[:steals] > most_steals\n most_steals = player[:steals]\n most_steal_player = player[:player_name]\n end\n end\n\n most_steal_player\nend", "def big_shoe_rebounds\n player_with_the_largest_shoe_size = 0\n most_rebounds = 0\n game_hash.each do |team,info|\n info.each do |team_info,team_data|\n if team_data.is_a? (Array) \n if team_info != :colors\n team_data.each do |player_index|\n if player_with_the_largest_shoe_size == 0 || player_index[:shoe] > player_with_the_largest_shoe_size \n player_with_the_largest_shoe_size = player_index[:shoe]\n most_rebounds = player_index[:rebounds]\n end\n end\n end\n end\n end\n end\n most_rebounds\nend", "def highest_match_value\n values = @hand.select { |dice| @hand.count(dice) == highest_match_count }\n values.max\n end", "def big_shoe_rebounds\n biggest_shoe = 0\n rebounds = 0\n game_hash.each do |team, all_info_hash|\n all_info_hash[:players].each do |player_information_hash|\n if player_information_hash[:shoe] > biggest_shoe\n biggest_shoe = player_information_hash[:shoe] \n rebounds = player_information_hash[:rebounds] \n end\n end\n end\n rebounds\nend", "def mostPoints\n players.max_by do|name, stats|\n stats[:points]\n end\nend", "def big_shoe_rebounds\n game_hash.values.each do |attribute|\n hash = attribute[:players]\n hash.values.each do |h|\n h.select { |k, v| k == :shoe }.sort.max\n return h[:rebounds]\n end\n end\nend", "def teams_with_score_max(a_game)\n teams_with_score_max = {}\n game_teams_with_score_max = a_game.teams_with_score_max(a_game.game_teams)\n game_teams_with_score_max.each do |game_team_with_score_max|\n # find team instance matching game_team instance\n team_with_score_max = @teams[game_team_with_score_max.name.to_sym]\n teams_with_score_max[game_team_with_score_max.name.to_sym] = team_with_score_max\n end\n teams_with_score_max\n end", "def best_defense\n @teams.min_by { |team| team.average_goals_allowed }.team_name\n end", "def winning_team\n home_points = 0\n away_points = 0\n result = \"\"\n i = 0\n game_hash.each do |team, about|\n about[:players].each do |name , stats|\n if i == 0\n home_points += stats[:points]\n else\n away_points += stats[:points]\n end\n end\n i += 1\n end\n home_points > away_points ? result = game_hash[:home][:team_name] : result = game_hash[:away][:team_name]\nend", "def most_steal\n steals_array = []\n \n game_hash.each do |key, value|\n players = value[:players]\n players.each do |element|\n steals_array << element[:steals]\n end\n end\n steals_array.max\nend", "def wins\n wins = 0\n self.teams.each do |team|\n wins += team.games_won.length\n end\n wins\n end", "def best_fans\n @teams.max_by { |team| team.home_minus_away_percentage }.team_name\n end", "def winner_team(game)\n result = nil\n if game.team1_goals.present? && game.team2_goals.present?\n result = game.team1 if game.team1_goals > game.team2_goals\n result = game.team2 if game.team1_goals < game.team2_goals\n end\n\n result\n end", "def winning_player\n played_cards.max_by { |_, card| card_scores[card] }.first\n end", "def most_points_scored\n big_score_player = player_collection.reduce { |memo, next_player|\n memo[:points] > next_player[:points] ? memo : next_player; \n }\n big_score_player[:player_name];\nend", "def most_popular_venue\n venues = @games.group_by { |game| game.venue}\n venues.max_by { |venue, games| games.count }.first\n end", "def total_score\n @all_games.map do |games|\n games[\"home_goals\"].to_i + games[\"away_goals\"].to_i\n end\n end", "def winning_team\n if homeTeamPoints.sum > awayTeamPoints.sum\n \"Brooklyn Nets\"\n else\n \"Charlotte Hornets\"\n end\nend", "def big_shoe_rebounds\n largest = 0\n player = \"\"\n game_hash.each do |location, team_data|\n team_data[:players].each do |k, v|\n if largest < shoe_size(k)\n largest = shoe_size(k)\n player = k\n end\n end\n end\n return player_stats(player)[:rebounds]\nend", "def average_goals_per_game\n total_goals = @teams.map {|team| team.total_goals_scored}.sum\n total_games = @teams.map {|team| team.home_games}.sum\n (total_goals.to_f / total_games.to_f).round(2)\n end", "def winner\n @players.max_by{ |player| player.score}\n end", "def get_total_games_played\n return games.size\n end", "def winningest_coach(seasonasstring) # coach name in game team stats\n #per season, get list of all coaches - given by arg\n #per coach, find all games played by that coach\n #then count of all games won / count of all games played\n #find highest\n #return name of coach found in 114\n end", "def rebounds_for_player_with_largest_shoe_size(game)\n shoe_sizes_with_player_names = []\n game[:home_team][:players].each do |player_hash|\n shoe_sizes_with_player_names << {player_hash[:player_name] => player_hash[:shoe_size]}\n end\n game[:away_team][:players].each do |player_hash|\n shoe_sizes_with_player_names << {player_hash[:player_name] => player_hash[:shoe_size]}\n end\n biggest_shoe_size = {\"test\" => 0}\n shoe_sizes_with_player_names.each do |shoe_size_and_name_hash|\n biggest_shoe_size = shoe_size_and_name_hash if shoe_size_and_name_hash.values[0] > biggest_shoe_size.values[0]\n end\n game[:home_team][:players].each do |player_hash|\n return player_hash[:stats][:rebounds] if player_hash[:player_name] == biggest_shoe_size.keys[0]\n end\n game[:away_team][:players].each do |player_hash|\n return player_hash[:stats][:rebounds] if player_hash[:player_name] == biggest_shoe_size.keys[0]\n end\nend", "def goals_for()\n\t self.as_regular_contestants.select{|c| c.score}.collect{|c| c.score}.inject{|gf, c| gf + c} || 0\n\tend", "def biggest_shoe(hashketball)\r\n player_number_with_biggest_shoe = \"\"\r\n biggest_shoe_size = 0\r\n \r\n hashketball[:home][:players].each do |name, player|\r\n if player[:shoe_size] > biggest_shoe_size\r\n player_number_with_biggest_shoe = name\r\n biggest_shoe_size = player[:shoe_size]\r\n end\r\n end\r\n hashketball[:away][:players].each do |name, player|\r\n if player[:shoe_size] > biggest_shoe_size\r\n player_number_with_biggest_shoe = name\r\n biggest_shoe_size = player[:shoe_size]\r\n end\r\n end\r\n \r\n \" #{player_number_with_biggest_shoe} : #{biggest_shoe_size} \"\r\nend", "def high_score\n if self.end_date < Date.today\n self.teams.max_by { |team| team.score }.score\n end\n end", "def rank_top_teams # DO NOT USE THIS METHOD, outdated, slow\n @top_teams = {}\n @top_teams = Score.in_challenge(self.id).teams_in_all_divisions.limit(5).\n order(\"sum_points DESC, MAX(#{Score.table_name}.\n earned_at) DESC\").sum(:points) \n return @top_teams\n end", "def calculate_overall_winner\n points_per_player = {}\n @matches.each do | match |\n !points_per_player[match.winner].nil? ? (points_per_player[match.winner] += 1) : (points_per_player[match.winner] = 1)\n end\n max_points = points_per_player.values.max\n points_per_player.key(max_points)\n end", "def max_scores\n next_boards.map(&:max_score)\n end", "def num_points_scored(player_name)\n game_hash.each do |home_or_away, team_values|\n team_values[:players].each do |player|\n if player[:player_name] == player_name \n return player[:points]\n end\n end \n end \nend", "def winning_team\n nets = []\n hornets = []\n\n game_hash.values.each do |nets_stats|\n if nets_stats[:team_name] == \"Brooklyn Nets\"\n nets_stats[:players].each do |bk|\n nets << bk[:points]\n end\n end\n end\n\n game_hash.values.each do |hornets_stats|\n if hornets_stats[:team_name] == \"Charlotte Hornets\"\n hornets_stats[:players].each do |ch|\n hornets << ch[:points]\n end\n end\n end\n\n if nets.reduce(:+) > hornets.reduce(:+)\n return \"Brooklyn Nets\"\n else\n return \"Charlotte Hornets\"\n end\nend", "def max_teams(rounds)\n 2**rounds\n end", "def max_teams(rounds)\n 2**rounds\n end", "def total_team_score(teams_id)\n total_score = 0\n @league_data.each do\n |team| \n # binding.pry\n if team.home_team_id == teams_id\n total_score += team.home_team_score\n elsif team.away_team_id == teams_id\n total_score += team.away_team_score\n end\n end\n return total_score\n end", "def winner\n @players.max_by do |player|\n player.score\n end\n end", "def most_points_scored\nplayer_with_most(:points)\nend", "def player_with_most_of(statistic)\n player_name = nil\n amount_of_stat = 0\n\n game_hash.each do |team, game_data|\n game_data[:players].each do |player|\n if player[statistic].is_a? String\n if player[statistic].length > amount_of_stat\n amount_of_stat = player[statistic].length\n player_name = player[:player_name]\n end\n elsif player[statistic] > amount_of_stat\n amount_of_stat = player[statistic]\n player_name = player[:player_name]\n end\n end\n end\n\n player_name\nend" ]
[ "0.7753501", "0.76269555", "0.73716176", "0.72548187", "0.72235227", "0.7204195", "0.71957093", "0.7175517", "0.7128617", "0.708833", "0.7086374", "0.7078452", "0.7075454", "0.70709544", "0.7035616", "0.7020289", "0.701274", "0.69712836", "0.6949245", "0.6948047", "0.693717", "0.6933009", "0.69271255", "0.69064593", "0.6864235", "0.68391305", "0.68349934", "0.6820079", "0.6814833", "0.6803894", "0.68002695", "0.6794203", "0.6784912", "0.6777356", "0.67660606", "0.67595214", "0.675499", "0.6750678", "0.6733145", "0.6719113", "0.67062485", "0.6703786", "0.6701896", "0.66973555", "0.6690598", "0.66772264", "0.6676915", "0.66685706", "0.6667029", "0.66605306", "0.6657915", "0.6655916", "0.66495234", "0.661151", "0.66013426", "0.6592251", "0.65833825", "0.6581713", "0.6580186", "0.6579987", "0.656725", "0.65544045", "0.65540326", "0.6496409", "0.6496111", "0.64942175", "0.6488734", "0.64806426", "0.6479495", "0.6476868", "0.64626837", "0.6449616", "0.64343506", "0.642487", "0.642335", "0.64136446", "0.64038223", "0.6399643", "0.63963956", "0.63939905", "0.6393936", "0.6383548", "0.6383351", "0.63746357", "0.6369287", "0.6356073", "0.63555795", "0.63534695", "0.63515425", "0.63493794", "0.63420504", "0.6333818", "0.63324237", "0.63323337", "0.6326667", "0.6326667", "0.6326352", "0.6322134", "0.6321634", "0.631992" ]
0.84425735
0
returns the lowest number of goals a particular team has scored in a game
def fewest_goals_scored(team_id) team_id = team_id.to_i goals_per_game = @game_teams.map do |game| if game.team_id == team_id game.goals end end goals_per_game.compact.min end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def lowest_total_score\n total_game_scores = games.map { |game| game.home_goals + game.away_goals}\n total_game_scores.min\n end", "def most_goals_scored(team_id)\n team_id = team_id.to_i\n goals_per_game = @game_teams.map do |game|\n if game.team_id == team_id\n game.goals\n end\n end\n goals_per_game.compact.max\n end", "def lowest_scoring_visitor\n @teams.min_by { |team| team.average_away_goals }.team_name\n end", "def lowest_scoring_home_team\n @teams.min_by { |team| team.average_home_goals }.team_name\n end", "def smallest_team\n self.teams.min{|t1,t2| t1.runners.size <=> t2.runners.size }\n end", "def most_points_scored\n points_scored = 0 # starting score to compare with players shoe sizes\n game_hash.each do |location, team_data| # iterates through each team\n players_array = team_data[:players] # finds the :players info in team_data and puts the players into players_array\n players_array.each do |player_name, data| # iterates through each player..\n if data[:points] > points_scored # if their points scored is greater than 0 (we set this earlier in the top of method)\n points_scored = data[:shoe] # take that players score and make it the new points_scored value\n end # this repeats (iterates) through all players until you don't have any more.. meaning the end result is\n end # the player with the highest score\n end\n return points_scored\nend", "def most_points_scored\n most_points = 0\n most_points_player = nil\n game_hash.each do |team, team_stats|\n team_stats[:players].each do |player_stats|\n if most_points < player_stats[:points]\n most_points = player_stats[:points]\n most_points_player = player_stats[:player_name]\n end\n end\n end\n most_points_player\nend", "def best_defense\n @teams.min_by { |team| team.average_goals_allowed }.team_name\n end", "def goals_for(team)\n valid = ((team == self.home_team or team == self.away_team) and self.final)\n\n if (valid)\n if (self.home_team == team)\n return self.homeScore\n else\n return self.awayScore\n end\n else\n return 0\n end\n end", "def winning_team\n home_points = collection_by_prop(game_hash[:home], :points).reduce(0, :+)\n away_points = collection_by_prop(game_hash[:away], :points).reduce(0, :+)\n home_points > away_points ? game_hash[:home][:team_name] : game_hash[:away][:team_name]\n end", "def goals_against()\n\t self.as_regular_contestants.select{|c| c.opponent.score}.collect{|c| c.opponent.score}.inject{|gf, c| gf + c} || 0\n\tend", "def worst_offense\n @teams.min_by { |team| team.average_goals_scored }.team_name\n end", "def winning_team\n home_team_points = game_hash[:home][:players].sum { |e| e[:points] }\n away_team_points = game_hash[:away][:players].sum { |e| e[:points] }\n\n if home_team_points > away_team_points\n return game_hash[:home][:team_name]\n else\n return game_hash[:away][:team_name]\n end\nend", "def most_points_scored\n most_points = 0\n player = \"\"\n game_hash.each do |k, team|\n team[:players].each do |e|\n if e[:points] > most_points\n most_points = e[:points]\n player = e[:player_name]\n end\n end\n end\n player\nend", "def goals_for()\n\t self.as_regular_contestants.select{|c| c.score}.collect{|c| c.score}.inject{|gf, c| gf + c} || 0\n\tend", "def winning_team\n team_p = []\n team_n = []\n\n game_hash.each do | location, team_data|\n temp = 0\n team_data[:players].each do |p_name, stats|\n temp += stats[:points]\n end\n team_n << team_data[:team_name]\n team_p << temp\n end\n\n team_p[0] > team_p[1] ? team_n[0] : team_n[1]\n\nend", "def team_with_more_points(game)\n home_points = game[:home_team][:players].collect do |player|\n player[:stats][:points]\n end.inject {|sum, n| sum + n}\n away_points = game[:away_team][:players].collect do |player|\n player[:stats][:points]\n end.inject {|sum, n| sum + n}\n home_points > away_points ? game[:home_team][:team_name] : game[:away_team][:team_name]\nend", "def num_points_scored(player)\n game_hash.each do |k, team|\n team[:players].each do |e|\n if e[:player_name] == player\n return e[:points]\n end\n end\n end\nend", "def winning_team\n home_team_sum = 0\n away_team_sum = 0\n game_hash.each do |team, team_stats|\n if team_stats[:team_name] == \"Brooklyn Nets\"\n team_stats[:players].each do |player_stats|\n home_team_sum += player_stats[:points]\n end\n elsif team_stats[:team_name] == \"Charlotte Hornets\"\n team_stats[:players].each do |player_stats|\n away_team_sum += player_stats[:points]\n end\n end\n end\n if home_team_sum > away_team_sum\n game_hash[:home][:team_name]\n elsif home_team_sum < away_team_sum\n game_hash[:away][:team_name]\n end\nend", "def num_points_scored(player_name)\n game_hash.each do |home_or_away, team_values|\n team_values[:players].each do |player|\n if player[:player_name] == player_name \n return player[:points]\n end\n end \n end \nend", "def winningest_team\n @teams.max_by { |team| team.total_win_percentage }.team_name\n end", "def goals_against(team)\n valid = ((team == self.home_team or team == self.away_team) and self.final)\n\n if (valid)\n if (self.home_team == team)\n return self.awayScore\n else\n return self.homeScore\n end\n else\n return 0\n end\n end", "def winning_team\n self.teams.order('score DESC').first\n end", "def minimum_rounds(driver)\n Algorithm::Swiss.minimum_rounds(driver.seeded_teams.length)\n end", "def minimum_rounds(driver)\n Algorithm::Swiss.minimum_rounds(driver.seeded_teams.length)\n end", "def winning_team\n home_score = 0\n away_score = 0\n game_hash[:home][:players].keys.each do |name|\n home_score += game_hash[:home][:players][name][:points]\n end\n game_hash[:away][:players].keys.each do |name|\n away_score += game_hash[:away][:players][name][:points]\n end\n home_score > away_score ? game_hash[:home][:team_name] : game_hash[:away][:team_name]\nend", "def most_points_scored\nbest_player = \"\"\npoints = 0\ngame_hash.each do |location, team_data|\n team_data[:players].each do |name, stats|\n if stats[:points] > points\n points = stats[:points]\n best_player= name\n end\n end\nend\nbest_player\nend", "def winning_scores\n high_score = scores.max{|score| score.total}.total\n scores.select {|score| score.total == high_score}\n end", "def least_popular_venue\n venues = @games.group_by { |game| game.venue}\n venues.min_by { |venue, games| games.count }.first\n end", "def wins\n wins = 0\n self.teams.each do |team|\n wins += team.games_won.length\n end\n wins\n end", "def num_points_scored(player_name)\n # if you were trying to explain this to someone in prework\n # who's stuck in hashketball, how would you explain how to do this?\n\n # find the num points scored as it relates to the name\n # we have all_players array\n # each value in all players has a smaller value that is the name of the player\n # that is also connected to the number of points they scored\n # find a way to sort the method / just find the value of points attributed to that name\n\n # hash of teams\n # visit each team\n # ask them for the player name list\n # check the list for the name\n # if i find it, then I have their points\n # I would return their points\n\n # argument pass in each player\n # try to return the amount of points associated with that player\n\n # pseudocode\n\n # i want all the players first <= simplify it ideally\n # home_players = game_hash[:home][:players]\n # away_players = game_hash[:away][:players]\n # all_players = home_players + away_players\n\n # so i can look through them\n # .each with an if\n # search, find, gofish\n # array of hashes\n # found_player = all_players.find do |player| # Hash\n # # find the player that matches the name\n # # binding.pry\n # # if player[:player_name] == player_name\n # # true\n # # else\n # # false\n # # end\n # player[:player_name] == player_name\n # end\n\n # get the points for that player\n found_player(player_name)[:points]\nend", "def winning_team\n final_scores = player_collection.reduce(home: 0, away: 0) { |teams_points, next_player|\n case \n when next_player[:location] === :away\n teams_points[:away] += next_player[:points];\n when next_player[:location] === :home\n teams_points[:home] += next_player[:points];\n end\n teams_points; \n }\n winner = final_scores.reduce { |highest_points, team_points| \n highest_points[1] > team_points[1] ? highest_points : team_points; \n }\n game_hash[winner[0]][:team_name]; \nend", "def highest_total_score\n total_goals.max\n end", "def determine_winner game\n winner = game.max_by {|team| team[:score]}\n team_standings = get_team_by_name(winner)\n team_standings[:winnings] += 3\nend", "def competitive_teams\n res = 0\n @teams.each { |team| res += 1 unless TeamLevel.is_primary?(team.team_level) }\n res\n end", "def most_points_scored\n max = nil\n name = nil \n game_hash.each do |team, team_values|\n team_values[:players].each do |player|\n if max == nil || player[:points] > max\n max = player[:points]\n name = player[:player_name]\n end\n end\n end\n name\nend", "def big_shoe_rebounds\n max_shoe = 0 \n max_rebounds = 0 \n game_hash.each do |place, team|\n # team.each do |attribute, data|\n team[:players].each do |player|\n if player[:shoe] > max_shoe\n max_shoe = player[:shoe]\n max_rebounds = player[:rebounds]\n # if attribute == :players\n # data.each do |player|\n #this gives me the player hashes\n # data.max_by{|player| player[:shoe] }\n # data.max_by{|player| player[:shoe] }[:rebounds]\n # player.max_by{|player| player[:shoe] \n # player.max_by{|player| player[:shoe] }[:rebounds]\n end\n end\n end\n return max_rebounds\n end", "def most_points(game)\n player_name_with_points = []\n game[:home_team][:players].each do |player_hash|\n player_name_with_points << {player_hash[:player_name] => player_hash[:stats][:points]}\n end\n game[:away_team][:players].each do |player_hash|\n player_name_with_points << {player_hash[:player_name] => player_hash[:stats][:points]}\n end\n player_most_points = {\"test\" => 0}\n player_name_with_points.each do |name_and_points_hash|\n player_most_points = name_and_points_hash if name_and_points_hash.values[0] > player_most_points.values[0]\n end\n player_most_points.keys[0]\nend", "def most_points_scored()\n points = 0\n result = \"\"\n\n game_hash.each do |side,team|\n team.each do |specs,info|\n if specs == :players\n info.each do |player|\n if player[:points] > points\n points = player[:points]\n result = player[:player_name]\n\n end\n end\n end\n end\n end\n result\nend", "def num_points_scored (player_name)\n game_hash.each do |place_name, team|\n \n team[:players].each do |player|\n \n if player[:player_name] == player_name\n return player[:points]\n end\n \n end\n \n end\n\n nba_match\nend", "def most_points_scored\n points = 0\n result = \"\"\n game_hash.each do |team, about|\n about[:players].each do |name , stats|\n if points < stats[:points]\n points = stats[:points]\n result = name\n end\n end\n end\n result\nend", "def big_shoe_rebounds\n biggest_shoe_size = 0\n player_rebounds = 0\n game_hash.each do |k, team|\n team[:players].each do |e|\n if e[:shoe] > biggest_shoe_size\n biggest_shoe_size = e[:shoe]\n player_rebounds = e[:rebounds]\n end\n end\n end\n player_rebounds\nend", "def winning_team\n if homeTeamPoints.sum > awayTeamPoints.sum\n \"Brooklyn Nets\"\n else\n \"Charlotte Hornets\"\n end\nend", "def num_points_scored (player_name)\n game_hash.each do |place_name, team|\n \n team[:players].each do |player|\n \n if player[:player_name] == player_name\n return player[:points]\n end\n \n end\n \n end\nend", "def num_points_scored(player_name)\n player_points = nil\n game_hash.each do |team, team_stats|\n team_stats[:players].each do |player_stats|\n if player_stats[:player_name] == player_name\n player_points = player_stats[:points]\n end\n end\n end\n player_points\nend", "def num_points_scored(player_name)\n this_player = player_name\n game_hash.each do |team, team_data|\n team_data[:players].each do |player_name, player_data|\n if player_name == this_player\n return player_data[:points]\n #over thought it, got stuck too long.\n end\n end\n end\n end", "def best_defense\n teams_total_goals_allowed = total_goals_allowed_helper\n teams_total_games = total_games_helper\n\n best_team_goals_allowed_avg = 100\n best_defense_team_id = 0\n this_team_goals_allowed_avg = 0\n\n teams_total_games.each do |games_key, games_value|\n teams_total_goals_allowed.each do |goals_key, goals_value|\n if goals_key == games_key\n this_team_goals_allowed_avg = (goals_value / games_value.to_f)\n if this_team_goals_allowed_avg < best_team_goals_allowed_avg\n best_team_goals_allowed_avg = this_team_goals_allowed_avg\n best_defense_team_id = games_key\n end\n end\n end\n end\n\n team_with_best_defense = nil\n self.teams.each_value do |team_obj|\n if team_obj.team_id. == best_defense_team_id\n team_with_best_defense = team_obj.team_name\n end\n end\n team_with_best_defense\n end", "def most_points_scored\n most_points_scored = 0\n player_with_the_most_points_scored = \"\"\n game_hash.each do |team,info|\n info.each do |team_info,team_data|\n if team_data.is_a? (Array) \n if team_info != :colors\n team_data.each do |player_index|\n if most_points_scored == 0 || player_index[:points] > most_points_scored \n most_points_scored = player_index[:points]\n player_with_the_most_points_scored = player_index[:player_name]\n end\n end\n end\n end\n end\n end\n player_with_the_most_points_scored\nend", "def big_shoe_rebounds\n biggest = 0\n rebounds = 0\n game_hash.each do |team, team_data|\n team_data[:players].each do |player|\n size = player[:shoe]\n if size > biggest\n biggest = size\n rebounds = player[:rebounds]\n end\n end\n end\n rebounds\nend", "def minimum_rounds(teams_count)\n Math.log2(teams_count).ceil\n end", "def player_with_most_steal\n most_steals = nil\n most_steal_player = nil\n\n all_players(game_hash).each do |player|\n if most_steals == nil || player[:steals] > most_steals\n most_steals = player[:steals]\n most_steal_player = player[:player_name]\n end\n end\n\n most_steal_player\nend", "def winning_team\n nets = []\n hornets = []\n\n game_hash.values.each do |nets_stats|\n if nets_stats[:team_name] == \"Brooklyn Nets\"\n nets_stats[:players].each do |bk|\n nets << bk[:points]\n end\n end\n end\n\n game_hash.values.each do |hornets_stats|\n if hornets_stats[:team_name] == \"Charlotte Hornets\"\n hornets_stats[:players].each do |ch|\n hornets << ch[:points]\n end\n end\n end\n\n if nets.reduce(:+) > hornets.reduce(:+)\n return \"Brooklyn Nets\"\n else\n return \"Charlotte Hornets\"\n end\nend", "def winning_team\n home_points = 0\n away_points = 0\n result = \"\"\n i = 0\n game_hash.each do |team, about|\n about[:players].each do |name , stats|\n if i == 0\n home_points += stats[:points]\n else\n away_points += stats[:points]\n end\n end\n i += 1\n end\n home_points > away_points ? result = game_hash[:home][:team_name] : result = game_hash[:away][:team_name]\nend", "def season_with_fewest_games\n seasons = @games.group_by { |game| game.season }\n seasons.min_by { |season, games| games.count }.first\n end", "def num_points_scored(player_name)\n game_hash.each do |side, team|\n team.each do |specs, info|\n if specs == :players\n\n info.each do |player|\n if player[:player_name] == player_name\n return player[:points]\n end\n end\n end\n end\n end\nend", "def num_points_scored(player)\n game_hash.each do |location, team|\n team[:players].each do |name, stats|\n if name == player\n return stats[:points]\n end\n end\n end\nend", "def num_points_scored(player)\n game_hash.each_value do |team|\n team[:players].each do |name, player_data|\n if name == player\n points = player_data[:points]\n return points\n end\n end\n end\nend", "def num_points_scored(name)\n game_hash.each do | team, team_data_hash |\n team_data_hash.each do | attribute, data |\n if attribute == :players\n data.each do | player, player_data_hash |\n if player == name\n return game_hash[team][attribute][player][:points]\n end\n end\n end\n end\n end\nend", "def num_points_scored(players_name)\n game_hash.each do |place, team|\n team.each do |attr, data|\n if attr == :players\n data.each do |player|\n if player[:player_name] == players_name\n return player[:points]\n end\n end\n end\n end\n end\nend", "def num_points_scored (searched_player)\n player_points = 0\n game_hash[:away][:players].each do |player_data|\n if player_data[:player_name] == searched_player\n player_points = player_data[:points]\n end\n end\n game_hash[:home][:players].each do |player_data|\n if player_data[:player_name] == searched_player\n player_points = player_data[:points]\n end\n end\n player_points\nend", "def num_points_scored(player_name)\ngame_hash.values.each do |team|\n team[:players].each do |player|\n return player[:points] if player.has_value?(player_name)\n end\n end\nend", "def big_shoe_rebounds\n big_shoe = 0\n result = 0\n game_hash.each do |team, about|\n about[:players].each do |name , stats|\n stats.each do |stat, value|\n if stat == :shoe\n if big_shoe < value \n result = stats[:rebounds]\n big_shoe = value\n end\n end\n end\n end\n end\n result\nend", "def num_points_scored(name)\n game_hash().each do |location, team_data|\n team_data[:players].each do |player_name, player_stat|\n if name == player_name\n return player_stat[:points]\n end\n end\n end\nend", "def num_points_scored (name)\n gh=game_hash\n gh.each do |team, stats|\n stats[:players].each_key do |nameval|\n if (nameval==name)\n return gh[team][:players][nameval][:points]\n end\n end\n end\nend", "def big_shoe_rebounds\n\nhighest_rebounds = 0\nbiggest_shoe = 0\n\n game_hash.each do |location, team_info|\n game_hash.dig(location, :players).each do |player_name, stats|\n stats.each do |stat, number|\n if stat == :shoe\n if number > biggest_shoe\n biggest_shoe = number\n stats.each do |stat, number|\n if stat == :rebounds\n highest_rebounds = number\n end\n end\n end\n end\n end\n end\n end\n puts highest_rebounds\n return highest_rebounds\nend", "def average_goals_per_game\n total_goals = @teams.map {|team| team.total_goals_scored}.sum\n total_games = @teams.map {|team| team.home_games}.sum\n (total_goals.to_f / total_games.to_f).round(2)\n end", "def num_points_scored(player_name)\n if !game_hash.keys.include?(:players)\n game_hash.each do |location, team_info|\n if team_info.keys.include?(:players)\n team_info.each do |attribute, quanity|\n if attribute == :players\n quanity.each do |name, stats|\n if name == player_name\n stats.each do |stat, quanity|\n if stat == :points\n return quanity\n end\n end\n end\n end\n end\n end\n end\n end\n end\nend", "def num_points_scored(player_lookup) \n game_hash.each do |location, team_data|\n#return the number of points scored for that player\n team_data[:players].each do |player|\n if player[:player_name] == player_lookup\n return player[:points]\n end\n end\n end\nend", "def num_points_scored(player_name)\n game_hash.each do |location, team_data|\n team_data.each do |attribute, data|\n if attribute == :players\n if data.keys.include?(player_name)\n return data[player_name][:points]\n end\n end\n end\n end\nend", "def team_hits(hits, team)\n if team.current_units <= hits\n team.units.all.each do |u|\n u.update(count:0)\n end\n else\n u = team.units.where(priority:1).first\n while hits > 0 and team.current_units > 0\n if u.count > 0 and hits > 0\n u.update(count: u.count-1)\n hits-=1\n else\n u = u.next\n end\n end\n return team\n end\n end", "def best_offense\n @teams.max_by { |team| team.average_goals_scored }.team_name\n end", "def num_points_scored (player_name)\n points_scored = nil\n\n game_hash.each do |team, team_information_hash|\n players_array = team_information_hash[:players]\n players_array.each do |player_information_hash|\n if player_information_hash[:player_name] == player_name\n points_scored = player_information_hash[:points]\n end\n end\n end\n points_scored\nend", "def player_with_most_steals\n name = \"\"\n most_steals = 0\n\n game_hash.each do | team, details_hash |\n players_array = details_hash[:players]\n players_array.each do | player_details_hash |\n if player_details_hash[:steals] > most_steals\n most_steals = player_details_hash[:steals]\n name = player_details_hash[:player_name]\n end\n end\n end\n name\nend", "def big_shoe_rebounds\n # Set two objects to equal integer values of 0 to be called/changed by the method\n biggest_shoe_size = 0\n number_of_rebounds = 0\n \n game_hash.each do |location, team_data|\n team_data[:players].each do |attributes| # Calls the stats of each player within the :players array \n if attributes[:shoe] > biggest_shoe_size # Finds and calls the largest integer value in the shoe key\n biggest_shoe_size = attributes[:shoe] # Sets value for biggest_shoe_size to equal the shoe value\n number_of_rebounds = attributes[:rebounds] # Sets value for number_of_rebounds to equal the rebounds value\n end\n end\n end\n return number_of_rebounds\nend", "def biggest_blowout\n score_difference = games.map { |game| (game.home_goals - game.away_goals).abs}\n score_difference.max\n end", "def min_sets_to_play\n max = max_sets_to_play\n raise Exceptions::ApplicationError, 'Unexpected game count' if max.even?\n (max + 1) / 2\n end", "def most_steals \n num_steals = 0\n game_hash.each do |team,info|\n info.each do |team_info,team_data|\n if team_data.is_a? (Array) \n if team_info != :colors\n team_data.each do |player_index|\n if num_steals == 0 || player_index[:steals] > num_steals \n num_steals = player_index[:steals] \n end\n end\n end\n end\n end\n end\nnum_steals\nend", "def big_shoe_points\n big_shoes_guy = 0\n points = 0\n game_hash.each do | location, attributes|\n attributes[:players].each do |player, stats|\n if stats[:shoe] > big_shoes_guy\n big_shoes_guy = stats[:shoe]\n points = stats[:points]\n end\n end\n end\n points\nend", "def most_points_scored\n\tpoints_array = []\n\tgame_hash.each do |location, team_data|\n\t\tteam_data[:players].each do |attribute, data|\t\n\t\t\tdata.each do |type, amount|\n\t\t\t\tif type == :points\n\t\t\t\t\tpoints_array << amount\n\t\t\t\tend \n\t\t\tend\n\t\tend\n\tend\n\tgame_hash.each do |l, data|\n\t\tdata[:players].each do |a, d|\n\t\t\td.each do |t, amt|\n\t\t\t\tif t == :points && points_array.max == amt\n\t\t\t\t\treturn a\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend\nend", "def num_points_scored(player_name)\n game_hash.each do |location, team_data|\n team_data[:players].each do |data_item, stats|\n if data_item == player_name\n return stats[:points]\n end\n end\n end\nend", "def num_points_scored(player_name)\npoints_scored = 0\ngame_hash.each do |location, team_data|\n team_data.each do |attribute, data|\n if attribute == :players\n data.each do |player, stats|\n if player == player_name\n points_scored = stats[:points]\n end\n end\n end\n end\nend\npoints_scored\nend", "def num_points_scored(player_name)\n result = nil\n game_hash.each do |team, about|\n about[:players].each do |name, stats|\n if player_name == name\n result = stats[:points]\n end\n end\n end\n result\nend", "def num_points_scored(player_name)\n game_hash.each do |location, team_data|\n team_data[:players].each do |attributes|\n if attributes[:player_name] == player_name\n return attributes[:points]\n end\n end\n end\nend", "def num_points_scored(player_name)\n points = nil\n game_hash.each do |location, team_data|\n team_data[:players].each do |name, stats|\n binding.pry\n if name == player_name\n points = team_data[:players][player_name][:points]\n end\n end\n end\n points\n end", "def winning_team\n points_home = 0\n points_away = 0\n result = \"\"\n\n game_hash.each do |side,team|\n team.each do |specs,info|\n if specs == :players\n info.each do |player|\n if side = :home\n points_home += player[:points]\n else\n points_away += player[:points]\n end\n end\n end\n end\n end\n if points_home > points_away\n result = game_hash[:home][:team_name]\n else\n result = game_hash[:away][:team_name]\n end\n result\nend", "def num_points_scored(player_name)\n scored_points = 0\n game_hash.each do |team,info|\n info.each do |team_info,team_data|\n if team_data.is_a? (Array) \n if team_info != :colors\n team_data.find do |player_index|\n if player_index[:player_name] == player_name\n scored_points = player_index[:points]\n end\n end\n end\n end\n end\n end\n scored_points\nend", "def num_points_scored(name)\n game_hash.each do |team, attributes|\n game_hash[team][:players].each do |player, stats|\n if name == player \n return game_hash[team][:players][name][:points]\n end\n end\n end\nend", "def best_score\n submissions.min(:score)\n end", "def num_points_scored(team_member)\n game_hash.each do |location, team_data|\n team_data.each do |attribute, data|\n # if attribute == :players\n next unless attribute == :players\n data.each do |player|\n return player[:points] if player[:player_name] == team_member\n end\n end\n end\nend", "def big_shoe_rebounds\n biggest_shoe = 0\n rebounds = 0\n game_hash.each do |team, all_info_hash|\n all_info_hash[:players].each do |player_information_hash|\n if player_information_hash[:shoe] > biggest_shoe\n biggest_shoe = player_information_hash[:shoe] \n rebounds = player_information_hash[:rebounds] \n end\n end\n end\n rebounds\nend", "def big_shoe_rebounds_2\n\nhighest_rebounds = 0\nbiggest_shoe = 0\n\n\n game_hash.dig(:home, :players).each do |player_name, stats|\n stats.each do |stat, number|\n if stat == :shoe\n if number > biggest_shoe\n biggest_shoe = number\n stats.each do |stat, number|\n if stat == :rebounds\n highest_rebounds = number\n\n end\n end\n end\n end\n end\nend\n\n puts highest_rebounds\n return highest_rebounds\nend", "def get_project_score(teamArr,proj_id)\n counter=0\n teamArr.each do |x|\n if (proj_id == @preferences_hash[x][:first]) then\n counter = counter+4\n elsif (proj_id == @preferences_hash[x][:second]) then\n counter = counter+2\n elsif (proj_id == @preferences_hash[x][:third]) then\n counter = counter+1\n else \n counter = counter-1\n end\n end\n return counter.to_f/teamArr.size \n #range of [-1, 4]\n end", "def worst_offense\n teams_total_goals = total_goals_helper\n teams_total_games = total_games_helper\n\n worst_team_goals_avg = 1000\n worst_offense_team_id = 0\n this_team_goals_avg = 0\n\n teams_total_games.each do |games_key, games_value|\n teams_total_goals.each do |goals_key, goals_value|\n if goals_key == games_key\n this_team_goals_avg = (goals_value / games_value.to_f)\n if this_team_goals_avg < worst_team_goals_avg\n worst_team_goals_avg = this_team_goals_avg\n worst_offense_team_id = games_key\n end\n end\n end\n end\n\n team_with_worst_offense = nil\n self.teams.each_value do |team_obj|\n if team_obj.team_id. == worst_offense_team_id\n team_with_worst_offense = team_obj.team_name\n end\n end\n team_with_worst_offense\n end", "def find_best_score(total_per_player)\n best_score = 0\n winner = ''\n total_per_player.each do |player_name,total|\n\n if total > best_score\n best_score = total\n winner = player_name\n end\n end\n return winner\n end", "def winning_player\n played_cards.max_by { |_, card| card_scores[card] }.first\n end", "def big_shoe_rebounds\n largest = 0\n player = \"\"\n game_hash.each do |location, team_data|\n team_data[:players].each do |k, v|\n if largest < shoe_size(k)\n largest = shoe_size(k)\n player = k\n end\n end\n end\n return player_stats(player)[:rebounds]\nend", "def num_points_scored(player_name)\n\n game_hash.each do |team, team_data|\n team_data[:players].each do |player|\n if player[:player_name] == player_name\n return player[:points]\n end\n end\n end\n\n # SOLUTION 3\n # get a list of all the players\n # all_players = game_hash.values.collect do |team|\n # team[:players]\n # end.flatten\n\n # find the player whose name matches the argument 'player_name'\n # return that player's points\n # all_players.each do |player|\n # return player[:points] if player[:player_name] == player_name\n # end\nend", "def max_sets_to_play\n case scoring.to_sym\n when :two_six_game_ten_point\n 3\n when :one_eight_game\n 1\n else # :three_six_game\n 3\n end\n end", "def total_score\n @all_games.map do |games|\n games[\"home_goals\"].to_i + games[\"away_goals\"].to_i\n end\n end", "def pri_tdef\n team_stats.opp_goals_per_game / team_stats.opp_avg_goals_against_per_game\n end" ]
[ "0.7822871", "0.72564715", "0.71507573", "0.711415", "0.70092106", "0.69469666", "0.6866441", "0.6851049", "0.68009114", "0.67771", "0.6758502", "0.6734367", "0.67328876", "0.668021", "0.6645249", "0.66174126", "0.66110116", "0.66101235", "0.65892303", "0.65609336", "0.65485305", "0.6547819", "0.6545967", "0.654337", "0.654337", "0.65401495", "0.65286744", "0.65276796", "0.6522133", "0.6517718", "0.6510453", "0.6508007", "0.65008956", "0.6496765", "0.6484778", "0.648421", "0.6455074", "0.6443307", "0.64423066", "0.6437006", "0.6436732", "0.6430431", "0.64295703", "0.6409195", "0.64019173", "0.6399929", "0.63986266", "0.63931066", "0.6388323", "0.6380631", "0.63758695", "0.63712335", "0.63650775", "0.63628936", "0.6360577", "0.63601273", "0.6354138", "0.63521284", "0.6351022", "0.6341623", "0.63346064", "0.6334265", "0.6332962", "0.63303304", "0.633015", "0.63288325", "0.6323969", "0.63170695", "0.63168424", "0.6314459", "0.6309652", "0.630696", "0.63063383", "0.62836945", "0.62761414", "0.62739426", "0.62725085", "0.6269673", "0.6264993", "0.62584203", "0.62569183", "0.6242245", "0.62318057", "0.6222521", "0.6222152", "0.6221327", "0.6217635", "0.6215082", "0.6208759", "0.6203998", "0.6202192", "0.61955655", "0.61936426", "0.6192753", "0.61791265", "0.6177759", "0.6173493", "0.6173154", "0.616532", "0.6156667" ]
0.8330991
0
returns the name of the opponent that has the lowest win percentage against the given team
def favorite_opponent(team_id) team_id = team_id.to_i team = @teams.select { |each_team| each_team.team_id == team_id }.first favorite_opponent_id = team.matchup_win_percentage.max_by{|each_team, percentage| percentage}.first @teams.select { |each_team| each_team.team_id == favorite_opponent_id }.first.team_name end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def lowest_scoring_visitor\n @teams.min_by { |team| team.average_away_goals }.team_name\n end", "def lowest_scoring_home_team\n @teams.min_by { |team| team.average_home_goals }.team_name\n end", "def winningest_team\n @teams.max_by { |team| team.total_win_percentage }.team_name\n end", "def worst_offense\n @teams.min_by { |team| team.average_goals_scored }.team_name\n end", "def best_defense\n @teams.min_by { |team| team.average_goals_allowed }.team_name\n end", "def best_offense\n @teams.max_by { |team| team.average_goals_scored }.team_name\n end", "def winning_team\n home_points = collection_by_prop(game_hash[:home], :points).reduce(0, :+)\n away_points = collection_by_prop(game_hash[:away], :points).reduce(0, :+)\n home_points > away_points ? game_hash[:home][:team_name] : game_hash[:away][:team_name]\n end", "def worst_season(team_id)\n team_id = team_id.to_i\n team = @teams.select { |each_team| each_team.team_id == team_id }.first\n team.season_win_percentages.min_by { |season, percentage| percentage }.first.to_s\n end", "def best_fans\n @teams.max_by { |team| team.home_minus_away_percentage }.team_name\n end", "def find_best_score(total_per_player)\n best_score = 0\n winner = ''\n total_per_player.each do |player_name,total|\n\n if total > best_score\n best_score = total\n winner = player_name\n end\n end\n return winner\n end", "def best_season(team_id)\n team_id = team_id.to_i\n team = @teams.select { |each_team| each_team.team_id == team_id }.first\n team.season_win_percentages.max_by { |season, percentage| percentage }.first.to_s\n end", "def winning_team\n self.teams.order('score DESC').first\n end", "def winning_team\n home_team_points = game_hash[:home][:players].sum { |e| e[:points] }\n away_team_points = game_hash[:away][:players].sum { |e| e[:points] }\n\n if home_team_points > away_team_points\n return game_hash[:home][:team_name]\n else\n return game_hash[:away][:team_name]\n end\nend", "def highest_scoring_home_team\n @teams.max_by { |team| team.average_home_goals }.team_name\n end", "def smallest_team\n self.teams.min{|t1,t2| t1.runners.size <=> t2.runners.size }\n end", "def highest_scoring_visitor\n @teams.max_by { |team| team.average_away_goals }.team_name\n end", "def winning_team\n if homeTeamPoints.sum > awayTeamPoints.sum\n \"Brooklyn Nets\"\n else\n \"Charlotte Hornets\"\n end\nend", "def most_accurate_team(seasonasstring) # shots in game team stats\n #get a list of all teams that played in that season - given by arg\n #use above list to sum all shots across all games in season\n #divide above by goals made across all games in season\n #find highest percentage\n #return team name as found in 127\n end", "def winning_team\n home_points = 0\n away_points = 0\n result = \"\"\n i = 0\n game_hash.each do |team, about|\n about[:players].each do |name , stats|\n if i == 0\n home_points += stats[:points]\n else\n away_points += stats[:points]\n end\n end\n i += 1\n end\n home_points > away_points ? result = game_hash[:home][:team_name] : result = game_hash[:away][:team_name]\nend", "def worst_defense\n @teams.max_by { |team| team.average_goals_allowed }.team_name\n end", "def biggest_surprise(season)\n season = season.to_i\n @teams.max_by{ |team| team.preseason_to_regular_increase[season] }.team_name\n end", "def lowest_total_score\n total_game_scores = games.map { |game| game.home_goals + game.away_goals}\n total_game_scores.min\n end", "def rival(team_id)\n team_id = team_id.to_i\n team = @teams.select { |each_team| each_team.team_id == team_id }.first\n rival_id = team.matchup_win_percentage.min_by{|each_team, percentage| percentage}.first\n @teams.select { |each_team| each_team.team_id == rival_id }.first.team_name\n end", "def least_accurate_team(seasonasstring) # shots in game team stats\n #inverse of above\n end", "def winning_team\n most_points_scored_helper\n winning_team = \"\"\n \n game_hash.each do |key, value|\n players = value[:players]\n players.each do |element|\n if most_points_scored_helper == element[:points]\n winning_team = value[:team_name]\n end\n end\n end\n winning_team\nend", "def biggest_bust(season)\n season = season.to_i\n @teams.min_by{ |team| team.preseason_to_regular_increase[season] }.team_name\n end", "def best_defense\n teams_total_goals_allowed = total_goals_allowed_helper\n teams_total_games = total_games_helper\n\n best_team_goals_allowed_avg = 100\n best_defense_team_id = 0\n this_team_goals_allowed_avg = 0\n\n teams_total_games.each do |games_key, games_value|\n teams_total_goals_allowed.each do |goals_key, goals_value|\n if goals_key == games_key\n this_team_goals_allowed_avg = (goals_value / games_value.to_f)\n if this_team_goals_allowed_avg < best_team_goals_allowed_avg\n best_team_goals_allowed_avg = this_team_goals_allowed_avg\n best_defense_team_id = games_key\n end\n end\n end\n end\n\n team_with_best_defense = nil\n self.teams.each_value do |team_obj|\n if team_obj.team_id. == best_defense_team_id\n team_with_best_defense = team_obj.team_name\n end\n end\n team_with_best_defense\n end", "def determine_winner game\n winner = game.max_by {|team| team[:score]}\n team_standings = get_team_by_name(winner)\n team_standings[:winnings] += 3\nend", "def worst_offense\n teams_total_goals = total_goals_helper\n teams_total_games = total_games_helper\n\n worst_team_goals_avg = 1000\n worst_offense_team_id = 0\n this_team_goals_avg = 0\n\n teams_total_games.each do |games_key, games_value|\n teams_total_goals.each do |goals_key, goals_value|\n if goals_key == games_key\n this_team_goals_avg = (goals_value / games_value.to_f)\n if this_team_goals_avg < worst_team_goals_avg\n worst_team_goals_avg = this_team_goals_avg\n worst_offense_team_id = games_key\n end\n end\n end\n end\n\n team_with_worst_offense = nil\n self.teams.each_value do |team_obj|\n if team_obj.team_id. == worst_offense_team_id\n team_with_worst_offense = team_obj.team_name\n end\n end\n team_with_worst_offense\n end", "def winner\n\t\ts = {}\n\t\t@vPlayers.each {|player|\n\t\t\ts[player.name.to_s] = player.score.totalScore\n\t\t}\n\t\tmax = s.values.max\n\t\tname = s.select{|k, v| v == max}.keys\n\t\tscore = s.select{|k, v| v == max}.values\n\t\t\n\t\tprint \"The winner is \" + name[0].to_s + \" with a total score of \" + score[0].to_s\n\t\tputs \"\",\"\"\n\t\t\n\tend", "def most_points_scored\nbest_player = \"\"\npoints = 0\ngame_hash.each do |location, team_data|\n team_data[:players].each do |name, stats|\n if stats[:points] > points\n points = stats[:points]\n best_player= name\n end\n end\nend\nbest_player\nend", "def winning_team\n nets = []\n hornets = []\n\n game_hash.values.each do |nets_stats|\n if nets_stats[:team_name] == \"Brooklyn Nets\"\n nets_stats[:players].each do |bk|\n nets << bk[:points]\n end\n end\n end\n\n game_hash.values.each do |hornets_stats|\n if hornets_stats[:team_name] == \"Charlotte Hornets\"\n hornets_stats[:players].each do |ch|\n hornets << ch[:points]\n end\n end\n end\n\n if nets.reduce(:+) > hornets.reduce(:+)\n return \"Brooklyn Nets\"\n else\n return \"Charlotte Hornets\"\n end\nend", "def winning_team\n team_p = []\n team_n = []\n\n game_hash.each do | location, team_data|\n temp = 0\n team_data[:players].each do |p_name, stats|\n temp += stats[:points]\n end\n team_n << team_data[:team_name]\n team_p << temp\n end\n\n team_p[0] > team_p[1] ? team_n[0] : team_n[1]\n\nend", "def best_offense\n offense_suite\n best_offense_id = @average_goals_by_id.invert.max[1]\n @team_name_by_id[best_offense_id]\n end", "def winning_team\n points_home = 0\n points_away = 0\n result = \"\"\n\n game_hash.each do |side,team|\n team.each do |specs,info|\n if specs == :players\n info.each do |player|\n if side = :home\n points_home += player[:points]\n else\n points_away += player[:points]\n end\n end\n end\n end\n end\n if points_home > points_away\n result = game_hash[:home][:team_name]\n else\n result = game_hash[:away][:team_name]\n end\n result\nend", "def winning_team\n home_score = 0\n away_score = 0\n game_hash[:home][:players].keys.each do |name|\n home_score += game_hash[:home][:players][name][:points]\n end\n game_hash[:away][:players].keys.each do |name|\n away_score += game_hash[:away][:players][name][:points]\n end\n home_score > away_score ? game_hash[:home][:team_name] : game_hash[:away][:team_name]\nend", "def most_points_scored()\n points = 0\n result = \"\"\n\n game_hash.each do |side,team|\n team.each do |specs,info|\n if specs == :players\n info.each do |player|\n if player[:points] > points\n points = player[:points]\n result = player[:player_name]\n\n end\n end\n end\n end\n end\n result\nend", "def determine_match_winner\n @games_to_win = ((total_number_of_games / 2.0).floor) + 1\n if player1.score == games_to_win\n return player1\n elsif player2.score == games_to_win\n return player2\n else\n return nil\n end\n end", "def player_with_most_of(statistic)\n player_name = nil\n amount_of_stat = 0\n\n game_hash.each do |team, game_data|\n game_data[:players].each do |player|\n if player[statistic].is_a? String\n if player[statistic].length > amount_of_stat\n amount_of_stat = player[statistic].length\n player_name = player[:player_name]\n end\n elsif player[statistic] > amount_of_stat\n amount_of_stat = player[statistic]\n player_name = player[:player_name]\n end\n end\n end\n\n player_name\nend", "def compute_team_winner\n if completed?\n team_winner\n else\n if first_team && second_team\n if sets_won(first_team) == min_sets_to_play\n first_team\n elsif sets_won(second_team) == min_sets_to_play\n second_team\n end\n end\n end\n end", "def winner\n @players.max_by do |player|\n player.score\n end\n end", "def player_with_most_of(statistic)\r\n player_name = \"\"\r\n amount_of_stat = 0\r\n\r\n game_hash.each do |team, stats|\r\n stats[:players].each do |players|\r\n if players[statistic].is_a? String\r\n if players[statistic].length > player_name.length\r\n player_name = players[:player_name]\r\n end\r\n elsif players[statistic] > amount_of_stat\r\n amount_of_stat = players[statistic]\r\n player_name = players[:player_name]\r\n end\r\n end\r\n end\r\n\r\n player_name\r\nend", "def winning_team_with_spread\n\t\tif self.final?\n\t\t\treturn home_team_id if home_team_score > away_team_score + point_spread\n\t\t\treturn away_team_id if away_team_score + point_spread > home_team_score\n\t\t\treturn \"tie\" if home_team_score == away_team_score + point_spread\n\t\telse\n\t\t\treturn nil\n\t\tend\n\tend", "def fewest_goals_scored(team_id)\n team_id = team_id.to_i\n goals_per_game = @game_teams.map do |game|\n if game.team_id == team_id\n game.goals\n end\n end\n goals_per_game.compact.min\n end", "def most_points_scored\n most_points = 0\n player = \"\"\n game_hash.each do |k, team|\n team[:players].each do |e|\n if e[:points] > most_points\n most_points = e[:points]\n player = e[:player_name]\n end\n end\n end\n player\nend", "def winning_team\n home_team_sum = 0\n away_team_sum = 0\n game_hash.each do |team, team_stats|\n if team_stats[:team_name] == \"Brooklyn Nets\"\n team_stats[:players].each do |player_stats|\n home_team_sum += player_stats[:points]\n end\n elsif team_stats[:team_name] == \"Charlotte Hornets\"\n team_stats[:players].each do |player_stats|\n away_team_sum += player_stats[:points]\n end\n end\n end\n if home_team_sum > away_team_sum\n game_hash[:home][:team_name]\n elsif home_team_sum < away_team_sum\n game_hash[:away][:team_name]\n end\nend", "def winning_player\n played_cards.max_by { |_, card| card_scores[card] }.first\n end", "def winner_name\n comp = Competitor.find_by_id(self.winner)\n name = comp.name\n return name\n end", "def player_win_percentage\n (games_won/user_games)\n end", "def winner\n if (self.homeScore > self.awayScore)\n return self.home_team\n elsif (self.awayScore > self.homeScore)\n return self.away_team\n else\n return nil\n end\n end", "def minimum_rounds(driver)\n Algorithm::Swiss.minimum_rounds(driver.seeded_teams.length)\n end", "def minimum_rounds(driver)\n Algorithm::Swiss.minimum_rounds(driver.seeded_teams.length)\n end", "def winner\n @players.max_by{ |player| player.score}\n end", "def best_season(id)\n wins = total_wins_per_team_per_season(id)\n totals = total_games_per_team_per_season(id)\n totals.each do |season, total|\n totals[season] = (wins[season] / total.to_f * 100).round(2)\n end\n totals.max_by {|k,v| v}[0]\n end", "def most_points_scored\n most_points = 0\n leading_scorer = \"\"\n\n game_hash.values.each do |roster|\n roster[:players].each do |player|\n if player[:points] > most_points\n most_points = player[:points]\n leading_scorer = player[:player_name]\n end\n end\n end\n return leading_scorer\nend", "def most_points_scored\n max = nil\n name = nil \n game_hash.each do |team, team_values|\n team_values[:players].each do |player|\n if max == nil || player[:points] > max\n max = player[:points]\n name = player[:player_name]\n end\n end\n end\n name\nend", "def most_expensive_player_on_team \n\n the_club = choose_club #user chooses club they want to see most expensive player for\n my_club = Club.find_by(name: the_club) #use class instance find_by to find the instance of club with the name provided by user (the_club)\n club_players = my_club.players.sort_by do |player| #loops through instance of club and sorts the players by their market value (remember to change market_value from string to integer)\n player.market_value.to_i\n end\n\n most_expensive_player = club_players.last #in ascending order the last item of the sorted array is the player with the highest market value\n puts \"#{the_club}'s most expensive player is #{most_expensive_player.name}. He is worth £#{most_expensive_player.market_value}M\"\n #the_club --> user choice of club name\n #most_expensive_player.name --> use the_club name to find the specific instance of Club class. \n #Use \".players\" method to find all player instances of that specifc club (the instances of players that \n #belong to that instance of club). Use \".name\" method to retrieve attribute \"name\" of player instance. \n #Use \".market_value\" to retrieve attribute \"market_value\" of the player instance. \n\nend", "def winning_team\n final_scores = player_collection.reduce(home: 0, away: 0) { |teams_points, next_player|\n case \n when next_player[:location] === :away\n teams_points[:away] += next_player[:points];\n when next_player[:location] === :home\n teams_points[:home] += next_player[:points];\n end\n teams_points; \n }\n winner = final_scores.reduce { |highest_points, team_points| \n highest_points[1] > team_points[1] ? highest_points : team_points; \n }\n game_hash[winner[0]][:team_name]; \nend", "def winningest_coach(seasonasstring) # coach name in game team stats\n #per season, get list of all coaches - given by arg\n #per coach, find all games played by that coach\n #then count of all games won / count of all games played\n #find highest\n #return name of coach found in 114\n end", "def key_for_min_value(name_hash)\n smallest = 0 #define state?\n winner = \"\"\n first_time = true\n if name_hash.empty? #test if empty\n winner = nil\n else\n name_hash.each do |name, points| #find smallest value\n if points < smallest || first_time #is this name the smallest?\n first_time = false\n smallest = points #set new low score\n winner = name #set new winner\n end\n end\n end\n winner\nend", "def head_to_head(team_id)\n team_id = team_id.to_i\n head_to_head_hash = {}\n team = @teams.select { |each_team| each_team.team_id == team_id }.first\n head_to_head_id_hash = team.matchup_win_percentage\n head_to_head_id_hash.each do |each_team_id, win_percentage|\n @teams.each do |each_team|\n if each_team.team_id == each_team_id\n head_to_head_hash[each_team.team_name] = win_percentage\n end\n end\n end\n head_to_head_hash\n end", "def winner\n tie_string = \"\"\n @players.each do |player|\n if @position[player] == @length\n tie_string << \"#{player}\"\n end\n end\n\n if tie_string.length > 1\n return \"no one\"\n else\n return tie_string[0]\n end\n\n end", "def winner\n @board.sort_by {|player, board_position| board_position}.last.first\n end", "def winning_team(result)\n goals = result.split(\"-\")\n if goals[0] == goals[1]\n \"draw\"\n elsif goals[0].to_i > goals[1].to_i\n \"home\"\n else\n \"away\"\n end\n end", "def most_points_scored\n most_points = 0\n most_points_player = nil\n game_hash.each do |team, team_stats|\n team_stats[:players].each do |player_stats|\n if most_points < player_stats[:points]\n most_points = player_stats[:points]\n most_points_player = player_stats[:player_name]\n end\n end\n end\n most_points_player\nend", "def win_percent\n matchmade_games < 1 ? 0 : ((total_exp.to_f/matchmade_games.to_f) * 100).to_d\n end", "def average_win_percentage(team_id)\n team_id = team_id.to_i\n team = @teams.select { |each_team| each_team.team_id == team_id }.first\n team.total_win_percentage.round(2)\n end", "def winning_team\n blue_team.winner? ? blue_team : red_team\n end", "def player_stats(player_name)\n game_hash.each do |place, team|\n team[:players].each do |player|\n if player[:player_name] == player_name\n return player\n end\n end\n end\n end", "def worst_defense\n teams_total_goals_allowed = total_goals_allowed_helper\n teams_total_games = total_games_helper\n\n worst_team_goals_allowed_avg = 0\n worst_defense_team_id = 0\n this_team_goals_allowed_avg = 0\n\n teams_total_games.each do |games_key, games_value|\n\n teams_total_goals_allowed.each do |goals_key, goals_value|\n if goals_key == games_key\n this_team_goals_allowed_avg = (goals_value / games_value.to_f)\n if this_team_goals_allowed_avg > worst_team_goals_allowed_avg\n worst_team_goals_allowed_avg = this_team_goals_allowed_avg\n worst_defense_team_id = games_key\n end\n end\n end\n end\n team_with_worst_defense = team_name_finder_helper(worst_defense_team_id)\n\n team_with_worst_defense\n end", "def score_for_team(team)\n team ||= winner_team\n winner_team?(team) ? score : scores.reverse.join(':')\n end", "def least_popular_venue\n venues = @games.group_by { |game| game.venue}\n venues.min_by { |venue, games| games.count }.first\n end", "def winner(game)\nwinner = \"\"\nwinner_points = 0\n game.each do |team, team_contents|\n total = 0\n team_contents[:roster].each do |player, player_contents| \n total += player_contents[:points]\n end\n if total > winner_points\n winner = team_contents[:team_name]\n winner_points = total\n elsif total == winner_points\n winner = \"tie\"\n end\n end\n\n if winner == \"tie\"\n puts \"The game was a tie, with each team scoring #{winner_points} points\"\n else\n puts \"#{winner} scored #{winner_points} points and won the game\"\n end\nend", "def get_first_name_of_season_winner(data, season)\n winner = match_contestant(data[season], 'status', 'Winner')\n winner['name'].split[0]\nend", "def best_score\n submissions.min(:score)\n end", "def winner\n players.sort.last\n end", "def most_points_scored\n most_points_scored = 0\n player_with_the_most_points_scored = \"\"\n game_hash.each do |team,info|\n info.each do |team_info,team_data|\n if team_data.is_a? (Array) \n if team_info != :colors\n team_data.each do |player_index|\n if most_points_scored == 0 || player_index[:points] > most_points_scored \n most_points_scored = player_index[:points]\n player_with_the_most_points_scored = player_index[:player_name]\n end\n end\n end\n end\n end\n end\n player_with_the_most_points_scored\nend", "def winning_player_id\n return nil if draw?\n player_score.value > opponent_score.value ? player_id : opponent_id\n end", "def best_move_for(player)\n return minimax(player)[1]\n end", "def most_points_scored\n points = 0\n result = \"\"\n game_hash.each do |team, about|\n about[:players].each do |name , stats|\n if points < stats[:points]\n points = stats[:points]\n result = name\n end\n end\n end\n result\nend", "def player_with_most_steals\n name = \"\"\n most_steals = 0\n\n game_hash.each do | team, details_hash |\n players_array = details_hash[:players]\n players_array.each do | player_details_hash |\n if player_details_hash[:steals] > most_steals\n most_steals = player_details_hash[:steals]\n name = player_details_hash[:player_name]\n end\n end\n end\n name\nend", "def score\n p1_score = players.first.score \n p2_score = players[1].score\n\n if p1_score == p2_score\n score_word = SCORE_NUMBER_TO_WORD_MAP[0..-2][p1_score]\n return score_word ? score_word + \"-All\" : \"Deuce\"\n elsif p1_score <= 3 && p2_score <= 3\n return players.map{|player| SCORE_NUMBER_TO_WORD_MAP[player.score] }.join(\"-\")\n else\n winning_player = players.sort{|a, b| a.score <=> b.score}.last\n return (p1_score - p2_score).abs == 1 ? \"Advantage #{winning_player.name}\" : \"Win for #{winning_player.name}\"\n end\n end", "def most_hits(seasonasstring) # shots in game team stats\n #get a list of all teams that played in that season\n #use above list to sum all shots across all games in season\n #find highest across list\n #return team name as found in 139\n end", "def ranks\n @teams = Team.where(\"wins > 0\t\").order(win_percentage: :desc)\n end", "def get_first_name_of_season_winner(data, season)\n data.each do |season_iteration, stats|\n if season_iteration == season\n stats.find do |winner|\n if winner[\"status\"] == \"Winner\"\n return winner[\"name\"].split.first\n end\n end\n end\n end\nend", "def winner_team(game)\n result = nil\n if game.team1_goals.present? && game.team2_goals.present?\n result = game.team1 if game.team1_goals > game.team2_goals\n result = game.team2 if game.team1_goals < game.team2_goals\n end\n\n result\n end", "def winner\n count1, count2 = @cups[6].count, @cups[13].count\n if count1 > count2\n @name1\n elsif count2 > count1\n @name2\n else\n :draw\n end\n end", "def most_points_scored\n points_scored = 0 # starting score to compare with players shoe sizes\n game_hash.each do |location, team_data| # iterates through each team\n players_array = team_data[:players] # finds the :players info in team_data and puts the players into players_array\n players_array.each do |player_name, data| # iterates through each player..\n if data[:points] > points_scored # if their points scored is greater than 0 (we set this earlier in the top of method)\n points_scored = data[:shoe] # take that players score and make it the new points_scored value\n end # this repeats (iterates) through all players until you don't have any more.. meaning the end result is\n end # the player with the highest score\n end\n return points_scored\nend", "def overall_winner_message()\n if @score_count.get_determine_set_winner() == 1\n return \"#{@player.get_name()} won the set of games with a score of #{@score_count.get_games_won()} vs. #{@score_count.get_other_games_won()}. Both players tied #{@score_count.get_games_tied} time(s).\"\n\n elsif @score_count.get_determine_set_winner() == 2\n return \"#{@player.get_other_name()} won the set of games with a score of #{@score_count.get_other_games_won()} vs. #{@score_count.get_games_won()}. Both players tied #{@score_count.get_games_tied} time(s).\"\n \n else @score_count.get_determine_set_winner() == 0\n return \"It was a tie, guys. You're both just super duper.\"\n end\n end", "def percent_wins(wins)\n ((wins.to_f / @num_games.to_f) * 100).round(4)\n end", "def winning_team\n total_points = 0 #initialize points at zero \n \n win_team = '' #set win team to an empty string \n \n game_hash.each do |location, team| #iterating over game hash\n team_points = 0 #initialize team points at zero \n team_name = game_hash[location][:team_name] \n # set team name = to game_hash at the the location at the # :team name \n \n team[:players].each do |player| #iterate over players \n points = player[:points] # set points = player points \n team_points += points #team points is the addition of every single point value from each player\n \n #binding.pry \n end\n \n win_team, total_points = team_name, team_points if team_points > total_points\n \n #binding.pry \n \n end\n \n return win_team\n\nend", "def find_winner\n # Searches for Player that won most recent Tournament\n tournament_champion = \"\"\n players = Player.all\n players.each do |player|\n if player.id == Player.find(player.id).tournaments.last.player_standings.sort { |a,b| a.ranking <=> b.ranking }.first.player_id\n tournament_champion = player\n end\n end\n #Searches League for User with winning Player on their team\n winner = \"\"\n users = self.users\n users.each do |user|\n if user.players.include? Player.find(tournament_champion.id)\n winner = user\n winner.save\n end\n end\n return winner\n end", "def determine_game_winner(player1,player2)\n if player1.score > player2.score\n puts \"#{player1.name} is the winner!\"\n elsif player1.score < player2.score\n puts \"#{player2.name} is the winner!\"\n else\n puts \"It's a tie.\"\n end\nend", "def player_with_most(stat)\n value = nil\n owner = nil\n players.each do |player, stats|\n if value == nil || stats[stat] > value\n value = stats[stat]\n owner = player\n end\n end\n owner\nend", "def winner\n @players.each do |current_player|\n if current_player.position >= length\n #puts \"#{current_player.name} JUST WON!!!\"\n return \"#{current_player.name}\"\n end\n end\n end", "def determine_winner\n @active_players.sort! do |player1, player2|\n if player1.strongest_hand > player2.strongest_hand\n -1\n elsif player1.strongest_hand < player2.strongest_hand\n 1\n else\n 0\n end\n end\nend", "def worst_coach(seasonasstring) # coach name in game team stats\n #inverse of above\n end", "def get_winning_player\n # if one player has all the cards\n players.map{|p| @winning_player = p if p.num_cards_remaining == Deck.num_cards}\n\n # if that's not the case, take the player with the highest number of cards\n if @winning_player.blank?\n @winning_player = CardFuncs::player_with_highest_card_count players\n end\n @winning_player\n end", "def winning_team\n home_points = 0\n away_points = 0\n team1 = \"Brooklyn Nets\"\n team2 = \"Charlotte Hornets\"\n game_hash.each do |team,info|\n info.each do |team_info,team_data|\n if team_data.is_a? (Array) \n if team_info != :colors\n if info[:team_name] == \"Brooklyn Nets\"\n team_data.each do |player_index|\n home_points += player_index[:points]\n end\n else \n team_data.each do |player_index|\n away_points += player_index[:points]\n winning_team end\n end\n end\n end\n end\n end\n\n if home_points > away_points\n team1\n else\n team2\n end\n\nend", "def counting_recommended_bet(player)\n count = @shoe.count\n if count <= 1\n bet = player.min_bet\n elsif count <= 10\n bet = player.min_bet + player.betting_unit * count\n else\n bet = player.min_bet + player.betting_unit * 10 + (player.betting_unit * (count/3))\n end\n \"#{player.name}, your recommended bet is $#{bet}. \"\n end" ]
[ "0.80596846", "0.7952112", "0.78971463", "0.76187414", "0.75939834", "0.72935563", "0.7212153", "0.7100145", "0.7084808", "0.7050331", "0.702519", "0.6839693", "0.6749604", "0.67208624", "0.66996473", "0.66627526", "0.66451025", "0.65876585", "0.65501934", "0.6528336", "0.6515771", "0.6511277", "0.6503783", "0.6499711", "0.6498968", "0.6484944", "0.6433398", "0.64139104", "0.63994634", "0.63967675", "0.63960594", "0.6394617", "0.6381858", "0.63799524", "0.6377022", "0.63636416", "0.6362447", "0.63579285", "0.6353721", "0.63448966", "0.6338089", "0.6324775", "0.6322064", "0.62833977", "0.6270401", "0.62499255", "0.62459743", "0.62369436", "0.62185055", "0.6214268", "0.6207296", "0.6207296", "0.6186016", "0.6183503", "0.61833435", "0.61777383", "0.61720175", "0.6166937", "0.6164945", "0.61444855", "0.6142049", "0.61415815", "0.61157924", "0.61078155", "0.6105748", "0.61029804", "0.6082012", "0.60712874", "0.60701984", "0.6057841", "0.6057692", "0.60490584", "0.6044783", "0.60358125", "0.60342807", "0.60290515", "0.6014138", "0.6007946", "0.6005743", "0.60034597", "0.59929436", "0.59881335", "0.59658635", "0.596404", "0.5957269", "0.59450454", "0.5941781", "0.5931465", "0.59302336", "0.5927835", "0.5921414", "0.59033585", "0.5901656", "0.588791", "0.5887815", "0.5883531", "0.5880986", "0.58809054", "0.58799314", "0.58754927" ]
0.69553727
11
returns the name of the opponent that has the highest win percentage against the given team
def rival(team_id) team_id = team_id.to_i team = @teams.select { |each_team| each_team.team_id == team_id }.first rival_id = team.matchup_win_percentage.min_by{|each_team, percentage| percentage}.first @teams.select { |each_team| each_team.team_id == rival_id }.first.team_name end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def winningest_team\n @teams.max_by { |team| team.total_win_percentage }.team_name\n end", "def best_offense\n @teams.max_by { |team| team.average_goals_scored }.team_name\n end", "def highest_scoring_visitor\n @teams.max_by { |team| team.average_away_goals }.team_name\n end", "def highest_scoring_home_team\n @teams.max_by { |team| team.average_home_goals }.team_name\n end", "def worst_defense\n @teams.max_by { |team| team.average_goals_allowed }.team_name\n end", "def best_fans\n @teams.max_by { |team| team.home_minus_away_percentage }.team_name\n end", "def favorite_opponent(team_id)\n team_id = team_id.to_i\n team = @teams.select { |each_team| each_team.team_id == team_id }.first\n favorite_opponent_id = team.matchup_win_percentage.max_by{|each_team, percentage| percentage}.first\n @teams.select { |each_team| each_team.team_id == favorite_opponent_id }.first.team_name\n end", "def worst_offense\n @teams.min_by { |team| team.average_goals_scored }.team_name\n end", "def most_accurate_team(seasonasstring) # shots in game team stats\n #get a list of all teams that played in that season - given by arg\n #use above list to sum all shots across all games in season\n #divide above by goals made across all games in season\n #find highest percentage\n #return team name as found in 127\n end", "def best_defense\n @teams.min_by { |team| team.average_goals_allowed }.team_name\n end", "def winning_team\n self.teams.order('score DESC').first\n end", "def best_offense\n offense_suite\n best_offense_id = @average_goals_by_id.invert.max[1]\n @team_name_by_id[best_offense_id]\n end", "def worst_offense\n teams_total_goals = total_goals_helper\n teams_total_games = total_games_helper\n\n worst_team_goals_avg = 1000\n worst_offense_team_id = 0\n this_team_goals_avg = 0\n\n teams_total_games.each do |games_key, games_value|\n teams_total_goals.each do |goals_key, goals_value|\n if goals_key == games_key\n this_team_goals_avg = (goals_value / games_value.to_f)\n if this_team_goals_avg < worst_team_goals_avg\n worst_team_goals_avg = this_team_goals_avg\n worst_offense_team_id = games_key\n end\n end\n end\n end\n\n team_with_worst_offense = nil\n self.teams.each_value do |team_obj|\n if team_obj.team_id. == worst_offense_team_id\n team_with_worst_offense = team_obj.team_name\n end\n end\n team_with_worst_offense\n end", "def best_season(team_id)\n team_id = team_id.to_i\n team = @teams.select { |each_team| each_team.team_id == team_id }.first\n team.season_win_percentages.max_by { |season, percentage| percentage }.first.to_s\n end", "def biggest_surprise(season)\n season = season.to_i\n @teams.max_by{ |team| team.preseason_to_regular_increase[season] }.team_name\n end", "def winner\n @players.max_by do |player|\n player.score\n end\n end", "def winner\n @players.max_by{ |player| player.score}\n end", "def find_best_score(total_per_player)\n best_score = 0\n winner = ''\n total_per_player.each do |player_name,total|\n\n if total > best_score\n best_score = total\n winner = player_name\n end\n end\n return winner\n end", "def winning_team\n home_points = collection_by_prop(game_hash[:home], :points).reduce(0, :+)\n away_points = collection_by_prop(game_hash[:away], :points).reduce(0, :+)\n home_points > away_points ? game_hash[:home][:team_name] : game_hash[:away][:team_name]\n end", "def most_points_scored\n max = nil\n name = nil \n game_hash.each do |team, team_values|\n team_values[:players].each do |player|\n if max == nil || player[:points] > max\n max = player[:points]\n name = player[:player_name]\n end\n end\n end\n name\nend", "def worst_season(team_id)\n team_id = team_id.to_i\n team = @teams.select { |each_team| each_team.team_id == team_id }.first\n team.season_win_percentages.min_by { |season, percentage| percentage }.first.to_s\n end", "def determine_winner game\n winner = game.max_by {|team| team[:score]}\n team_standings = get_team_by_name(winner)\n team_standings[:winnings] += 3\nend", "def worst_defense\n teams_total_goals_allowed = total_goals_allowed_helper\n teams_total_games = total_games_helper\n\n worst_team_goals_allowed_avg = 0\n worst_defense_team_id = 0\n this_team_goals_allowed_avg = 0\n\n teams_total_games.each do |games_key, games_value|\n\n teams_total_goals_allowed.each do |goals_key, goals_value|\n if goals_key == games_key\n this_team_goals_allowed_avg = (goals_value / games_value.to_f)\n if this_team_goals_allowed_avg > worst_team_goals_allowed_avg\n worst_team_goals_allowed_avg = this_team_goals_allowed_avg\n worst_defense_team_id = games_key\n end\n end\n end\n end\n team_with_worst_defense = team_name_finder_helper(worst_defense_team_id)\n\n team_with_worst_defense\n end", "def highest_player_score\n players.max_by{|player| player.score}.score\n end", "def winner\n\t\ts = {}\n\t\t@vPlayers.each {|player|\n\t\t\ts[player.name.to_s] = player.score.totalScore\n\t\t}\n\t\tmax = s.values.max\n\t\tname = s.select{|k, v| v == max}.keys\n\t\tscore = s.select{|k, v| v == max}.values\n\t\t\n\t\tprint \"The winner is \" + name[0].to_s + \" with a total score of \" + score[0].to_s\n\t\tputs \"\",\"\"\n\t\t\n\tend", "def best_defense\n teams_total_goals_allowed = total_goals_allowed_helper\n teams_total_games = total_games_helper\n\n best_team_goals_allowed_avg = 100\n best_defense_team_id = 0\n this_team_goals_allowed_avg = 0\n\n teams_total_games.each do |games_key, games_value|\n teams_total_goals_allowed.each do |goals_key, goals_value|\n if goals_key == games_key\n this_team_goals_allowed_avg = (goals_value / games_value.to_f)\n if this_team_goals_allowed_avg < best_team_goals_allowed_avg\n best_team_goals_allowed_avg = this_team_goals_allowed_avg\n best_defense_team_id = games_key\n end\n end\n end\n end\n\n team_with_best_defense = nil\n self.teams.each_value do |team_obj|\n if team_obj.team_id. == best_defense_team_id\n team_with_best_defense = team_obj.team_name\n end\n end\n team_with_best_defense\n end", "def biggestShoes\n players.max_by do|name, stats|\n stats[:shoe]\n end\nend", "def most_hits(seasonasstring) # shots in game team stats\n #get a list of all teams that played in that season\n #use above list to sum all shots across all games in season\n #find highest across list\n #return team name as found in 139\n end", "def player_w_biggest_feet\n all_players[1].max_by { |stats| stats[:shoe] }\n end", "def most_goals_scored(team_id)\n team_id = team_id.to_i\n goals_per_game = @game_teams.map do |game|\n if game.team_id == team_id\n game.goals\n end\n end\n goals_per_game.compact.max\n end", "def winning_team\n home_team_points = game_hash[:home][:players].sum { |e| e[:points] }\n away_team_points = game_hash[:away][:players].sum { |e| e[:points] }\n\n if home_team_points > away_team_points\n return game_hash[:home][:team_name]\n else\n return game_hash[:away][:team_name]\n end\nend", "def mostSteals\n players.max_by do|name, stats|\n stats[:steals]\n end\nend", "def worst_loss(team_id)\n @games.map do |game|\n if game.away_team_id.to_s == team_id\n game.home_goals - game.away_goals\n elsif game.home_team_id.to_s == team_id\n game.away_goals - game.home_goals\n end\n end.compact.max\n end", "def most_expensive_player_on_team \n\n the_club = choose_club #user chooses club they want to see most expensive player for\n my_club = Club.find_by(name: the_club) #use class instance find_by to find the instance of club with the name provided by user (the_club)\n club_players = my_club.players.sort_by do |player| #loops through instance of club and sorts the players by their market value (remember to change market_value from string to integer)\n player.market_value.to_i\n end\n\n most_expensive_player = club_players.last #in ascending order the last item of the sorted array is the player with the highest market value\n puts \"#{the_club}'s most expensive player is #{most_expensive_player.name}. He is worth £#{most_expensive_player.market_value}M\"\n #the_club --> user choice of club name\n #most_expensive_player.name --> use the_club name to find the specific instance of Club class. \n #Use \".players\" method to find all player instances of that specifc club (the instances of players that \n #belong to that instance of club). Use \".name\" method to retrieve attribute \"name\" of player instance. \n #Use \".market_value\" to retrieve attribute \"market_value\" of the player instance. \n\nend", "def biggest_team_blowout(team_id)\n @games.map do |game|\n if game.away_team_id.to_s == team_id\n game.away_goals - game.home_goals\n elsif game.home_team_id.to_s == team_id\n game.home_goals - game.away_goals\n end\n end.compact.max\n end", "def output_driver_with_most_money(earned_per_each_driver)\n max_earned = earned_per_each_driver.max_by do |current_driver|\n current_driver[:driver_earned]\n end\n\n puts \"\\nDriver #{max_earned[:driver_id]} earned the most money $#{max_earned[:driver_earned]}.\"\nend", "def biggest_bust(season)\n season = season.to_i\n @teams.min_by{ |team| team.preseason_to_regular_increase[season] }.team_name\n end", "def player_longest_name(game)\n player_names = []\n game[:home_team][:players].each do |player_hash|\n player_names << player_hash[:player_name]\n end\n game[:away_team][:players].each do |player_hash|\n player_names << player_hash[:player_name]\n end\n longest_name = player_names.max_by { |name| name.length }\nend", "def most_points(game)\nmax_points = 0\nmax_points_player = \"\"\ngame.each do |team, team_contents|\n team_contents[:roster].each do |player, player_contents| \n if player_contents[:points] == max_points\n max_points_player = max_points_player + \" and #{player_contents[:player_name]}\"\n elsif player_contents[:points] > max_points\n max_points = player_contents[:points]\n max_points_player = player_contents[:player_name]\n end\n end\nend\nputs \"#{max_points_player} scored #{max_points}\"\nend", "def biggest_blowout\n score_difference = games.map { |game| (game.home_goals - game.away_goals).abs}\n score_difference.max\n end", "def player_with_most_of(statistic)\n player_name = nil\n amount_of_stat = 0\n\n game_hash.each do |team, game_data|\n game_data[:players].each do |player|\n if player[statistic].is_a? String\n if player[statistic].length > amount_of_stat\n amount_of_stat = player[statistic].length\n player_name = player[:player_name]\n end\n elsif player[statistic] > amount_of_stat\n amount_of_stat = player[statistic]\n player_name = player[:player_name]\n end\n end\n end\n\n player_name\nend", "def winning_player\n played_cards.max_by { |_, card| card_scores[card] }.first\n end", "def most_points_scored\n stat_by_player = collect_stat_by_name(:points)\n player_with_max_stat = find_max_stat_by_player(stat_by_player)\n player_with_max_stat\nend", "def biggest_bust(seasonasstring)\n #get all teams in data\n #find all games played by team in season - given by arg\n #get subset of 95 where p is in season marker\n #count games won in subset on 95 / total games in subset on 95\n #get subset of 85 where r is in season marker\n #count games won in subset on 98 / total games in subset on 98\n #result of line 97 - line 99\n #find highest number\n #return team name of result of line 101\n end", "def most_points_scored\n most_points = 0\n player = \"\"\n game_hash.each do |k, team|\n team[:players].each do |e|\n if e[:points] > most_points\n most_points = e[:points]\n player = e[:player_name]\n end\n end\n end\n player\nend", "def most_points_scored()\n points = 0\n result = \"\"\n\n game_hash.each do |side,team|\n team.each do |specs,info|\n if specs == :players\n info.each do |player|\n if player[:points] > points\n points = player[:points]\n result = player[:player_name]\n\n end\n end\n end\n end\n end\n result\nend", "def biggest_shoe\r\n player_name= []\r\n game_hash.each do |team, data|\r\n data.each do |team_info, value|\r\n if team_info == \"players\".to_sym\r\n obj=value.max_by {|key, value| value[:shoe]}\r\n player_name<< obj.first\r\n end\r\n end\r\n end\r\n player_name.first\r\nend", "def lowest_scoring_visitor\n @teams.min_by { |team| team.average_away_goals }.team_name\n end", "def winning_team\n if homeTeamPoints.sum > awayTeamPoints.sum\n \"Brooklyn Nets\"\n else\n \"Charlotte Hornets\"\n end\nend", "def most_points_scored\nbest_player = \"\"\npoints = 0\ngame_hash.each do |location, team_data|\n team_data[:players].each do |name, stats|\n if stats[:points] > points\n points = stats[:points]\n best_player= name\n end\n end\nend\nbest_player\nend", "def most_steals(game)\nmax_steals = 0\nmax_steals_player = \"\"\ngame.each do |team, team_contents|\n team_contents[:roster].each do |player, player_contents| \n if player_contents[:steals] == max_steals\n max_steals_player = max_steals_player + \" and #{player_contents[:player_name]}\"\n elsif player_contents[:steals] > max_steals\n max_steals = player_contents[:steals]\n max_steals_player = player_contents[:player_name]\n end\n end\nend\nmax_steals_player\nend", "def player_with_most_of(statistic)\r\n player_name = \"\"\r\n amount_of_stat = 0\r\n\r\n game_hash.each do |team, stats|\r\n stats[:players].each do |players|\r\n if players[statistic].is_a? String\r\n if players[statistic].length > player_name.length\r\n player_name = players[:player_name]\r\n end\r\n elsif players[statistic] > amount_of_stat\r\n amount_of_stat = players[statistic]\r\n player_name = players[:player_name]\r\n end\r\n end\r\n end\r\n\r\n player_name\r\nend", "def highest_total_score\n total_goals.max\n end", "def score_for_team(team)\n team ||= winner_team\n winner_team?(team) ? score : scores.reverse.join(':')\n end", "def highest_total_score\n @game_manager.highest_total_score\n end", "def mostPoints\n players.max_by do|name, stats|\n stats[:points]\n end\nend", "def player_with_longest_name\n longest_name = 0\n longest_player_name = nil\n game_hash.each do |team, team_stats|\n team_stats[:players].each do |player_stats|\n if longest_name < player_stats[:player_name].length\n longest_name = player_stats[:player_name].length\n longest_player_name = player_stats[:player_name]\n end\n end\n end\n longest_player_name\nend", "def winning_team\n most_points_scored_helper\n winning_team = \"\"\n \n game_hash.each do |key, value|\n players = value[:players]\n players.each do |element|\n if most_points_scored_helper == element[:points]\n winning_team = value[:team_name]\n end\n end\n end\n winning_team\nend", "def winning_team\n home_points = 0\n away_points = 0\n result = \"\"\n i = 0\n game_hash.each do |team, about|\n about[:players].each do |name , stats|\n if i == 0\n home_points += stats[:points]\n else\n away_points += stats[:points]\n end\n end\n i += 1\n end\n home_points > away_points ? result = game_hash[:home][:team_name] : result = game_hash[:away][:team_name]\nend", "def player_with_most_steals\n name = \"\"\n most_steals = 0\n\n game_hash.each do | team, details_hash |\n players_array = details_hash[:players]\n players_array.each do | player_details_hash |\n if player_details_hash[:steals] > most_steals\n most_steals = player_details_hash[:steals]\n name = player_details_hash[:player_name]\n end\n end\n end\n name\nend", "def winner\n players.sort.last\n end", "def winningest_coach(seasonasstring) # coach name in game team stats\n #per season, get list of all coaches - given by arg\n #per coach, find all games played by that coach\n #then count of all games won / count of all games played\n #find highest\n #return name of coach found in 114\n end", "def winner_team(game)\n result = nil\n if game.team1_goals.present? && game.team2_goals.present?\n result = game.team1 if game.team1_goals > game.team2_goals\n result = game.team2 if game.team1_goals < game.team2_goals\n end\n\n result\n end", "def worst_coach(seasonasstring) # coach name in game team stats\n #inverse of above\n end", "def winning_team\n final_scores = player_collection.reduce(home: 0, away: 0) { |teams_points, next_player|\n case \n when next_player[:location] === :away\n teams_points[:away] += next_player[:points];\n when next_player[:location] === :home\n teams_points[:home] += next_player[:points];\n end\n teams_points; \n }\n winner = final_scores.reduce { |highest_points, team_points| \n highest_points[1] > team_points[1] ? highest_points : team_points; \n }\n game_hash[winner[0]][:team_name]; \nend", "def driver_with_highest_income(all_rides)\n all_income = total_income_per_driver(all_rides)\n highest_income = all_income.values.max\n driver = all_income.key(highest_income)\n puts \"#{driver} made the most money, earning $#{'%.2f' % highest_income}\"\nend", "def most_popular_venue\n venues = @games.group_by { |game| game.venue}\n venues.max_by { |venue, games| games.count }.first\n end", "def worst_fans\n teams_with_bad_fans = @teams.find_all { |team| team.home_minus_away_percentage.negative? }\n teams_with_bad_fans.map { |team| team.team_name }\n end", "def high_score\n if self.end_date < Date.today\n self.teams.max_by { |team| team.score }.score\n end\n end", "def lowest_scoring_home_team\n @teams.min_by { |team| team.average_home_goals }.team_name\n end", "def most_points_scored\n most_points = 0\n most_points_player = nil\n game_hash.each do |team, team_stats|\n team_stats[:players].each do |player_stats|\n if most_points < player_stats[:points]\n most_points = player_stats[:points]\n most_points_player = player_stats[:player_name]\n end\n end\n end\n most_points_player\nend", "def winning_team\n home_score = 0\n away_score = 0\n game_hash[:home][:players].keys.each do |name|\n home_score += game_hash[:home][:players][name][:points]\n end\n game_hash[:away][:players].keys.each do |name|\n away_score += game_hash[:away][:players][name][:points]\n end\n home_score > away_score ? game_hash[:home][:team_name] : game_hash[:away][:team_name]\nend", "def biggest_investment\n funding_rounds.max_by {|funding_round| funding_round.investment}\n end", "def team_names\n game = Game.find(self.game_id)\n type = self.bet_type\n if over_under?\n return \"#{game.away_team} vs #{game.home_team}\"\n elsif type == \"lay\"\n if game.spread <= 0\n return game.home_team\n else\n return game.away_team\n end\n else\n if game.spread <= 0\n return game.away_team\n else\n return game.home_team\n end\n end\n end", "def long_name_steals_a_ton?()\n\n def most_steals()\n steals = 0\n result = \"\"\n\n game_hash.each do |side,team|\n team.each do |specs,info|\n if specs == :players\n info.each do |player|\n if player[:steals] > steals\n steals = player[:steals]\n result = player[:player_name]\n\n end\n end\n end\n end\n end\n result\n end\n\n return player_with_longest_name() == most_steals()\nend", "def best_season(id)\n wins = total_wins_per_team_per_season(id)\n totals = total_games_per_team_per_season(id)\n totals.each do |season, total|\n totals[season] = (wins[season] / total.to_f * 100).round(2)\n end\n totals.max_by {|k,v| v}[0]\n end", "def winning_team\n nets = []\n hornets = []\n\n game_hash.values.each do |nets_stats|\n if nets_stats[:team_name] == \"Brooklyn Nets\"\n nets_stats[:players].each do |bk|\n nets << bk[:points]\n end\n end\n end\n\n game_hash.values.each do |hornets_stats|\n if hornets_stats[:team_name] == \"Charlotte Hornets\"\n hornets_stats[:players].each do |ch|\n hornets << ch[:points]\n end\n end\n end\n\n if nets.reduce(:+) > hornets.reduce(:+)\n return \"Brooklyn Nets\"\n else\n return \"Charlotte Hornets\"\n end\nend", "def player_with_most_steal\n most_steals = nil\n most_steal_player = nil\n\n all_players(game_hash).each do |player|\n if most_steals == nil || player[:steals] > most_steals\n most_steals = player[:steals]\n most_steal_player = player[:player_name]\n end\n end\n\n most_steal_player\nend", "def highest_earner(drivers)\n # hash data for the highest earning driver\n highest_earner_data = drivers.max { |a, b| a[:total_earned] <=> b[:total_earned]}\n # extracts the driver ID\n highest_earner = highest_earner_data[:driver_id]\n return highest_earner\nend", "def biggest_shoe(hashketball)\r\n player_number_with_biggest_shoe = \"\"\r\n biggest_shoe_size = 0\r\n \r\n hashketball[:home][:players].each do |name, player|\r\n if player[:shoe_size] > biggest_shoe_size\r\n player_number_with_biggest_shoe = name\r\n biggest_shoe_size = player[:shoe_size]\r\n end\r\n end\r\n hashketball[:away][:players].each do |name, player|\r\n if player[:shoe_size] > biggest_shoe_size\r\n player_number_with_biggest_shoe = name\r\n biggest_shoe_size = player[:shoe_size]\r\n end\r\n end\r\n \r\n \" #{player_number_with_biggest_shoe} : #{biggest_shoe_size} \"\r\nend", "def winning_team\n team_p = []\n team_n = []\n\n game_hash.each do | location, team_data|\n temp = 0\n team_data[:players].each do |p_name, stats|\n temp += stats[:points]\n end\n team_n << team_data[:team_name]\n team_p << temp\n end\n\n team_p[0] > team_p[1] ? team_n[0] : team_n[1]\n\nend", "def most_points_scored\n points = 0\n result = \"\"\n game_hash.each do |team, about|\n about[:players].each do |name , stats|\n if points < stats[:points]\n points = stats[:points]\n result = name\n end\n end\n end\n result\nend", "def most_points(game)\n player_name_with_points = []\n game[:home_team][:players].each do |player_hash|\n player_name_with_points << {player_hash[:player_name] => player_hash[:stats][:points]}\n end\n game[:away_team][:players].each do |player_hash|\n player_name_with_points << {player_hash[:player_name] => player_hash[:stats][:points]}\n end\n player_most_points = {\"test\" => 0}\n player_name_with_points.each do |name_and_points_hash|\n player_most_points = name_and_points_hash if name_and_points_hash.values[0] > player_most_points.values[0]\n end\n player_most_points.keys[0]\nend", "def most_points_scored\n big_score_player = player_collection.reduce { |memo, next_player|\n memo[:points] > next_player[:points] ? memo : next_player; \n }\n big_score_player[:player_name];\nend", "def long_name_steals_a_ton?\n highest_number_steals = 0\n player_most_steals = nil\n game_hash.each do |team, team_stats|\n team_stats[:players].each do |player_stats|\n if highest_number_steals < player_stats[:steals]\n highest_number_steals = player_stats[:steals]\n player_most_steals = player_stats[:player_name]\n end\n end\n end\n if player_most_steals == player_with_longest_name\n true\n else\n false\n end\nend", "def winner_name\n comp = Competitor.find_by_id(self.winner)\n name = comp.name\n return name\n end", "def winner\n if (self.homeScore > self.awayScore)\n return self.home_team\n elsif (self.awayScore > self.homeScore)\n return self.away_team\n else\n return nil\n end\n end", "def biggest_investment\n self.funding_rounds.max_by {|funding| funding.investment }\n end", "def get_max_over(stat)\n max = 0\n $data_enemies.each { |enemy|\n next if enemy.nil?\n next if enemy.hidden_best\n next unless $game_party.known_enemy?(enemy.id)\n value = enemy.get_stat(stat)\n max = value if value > max\n }\n max\n end", "def most_points_scored\n most_points_scored = 0\n player_with_the_most_points_scored = \"\"\n game_hash.each do |team,info|\n info.each do |team_info,team_data|\n if team_data.is_a? (Array) \n if team_info != :colors\n team_data.each do |player_index|\n if most_points_scored == 0 || player_index[:points] > most_points_scored \n most_points_scored = player_index[:points]\n player_with_the_most_points_scored = player_index[:player_name]\n end\n end\n end\n end\n end\n end\n player_with_the_most_points_scored\nend", "def player_with_most(stat)\n value = nil\n owner = nil\n players.each do |player, stats|\n if value == nil || stats[stat] > value\n value = stats[stat]\n owner = player\n end\n end\n owner\nend", "def winning_team\n home_team_sum = 0\n away_team_sum = 0\n game_hash.each do |team, team_stats|\n if team_stats[:team_name] == \"Brooklyn Nets\"\n team_stats[:players].each do |player_stats|\n home_team_sum += player_stats[:points]\n end\n elsif team_stats[:team_name] == \"Charlotte Hornets\"\n team_stats[:players].each do |player_stats|\n away_team_sum += player_stats[:points]\n end\n end\n end\n if home_team_sum > away_team_sum\n game_hash[:home][:team_name]\n elsif home_team_sum < away_team_sum\n game_hash[:away][:team_name]\n end\nend", "def winning_team\n points_home = 0\n points_away = 0\n result = \"\"\n\n game_hash.each do |side,team|\n team.each do |specs,info|\n if specs == :players\n info.each do |player|\n if side = :home\n points_home += player[:points]\n else\n points_away += player[:points]\n end\n end\n end\n end\n end\n if points_home > points_away\n result = game_hash[:home][:team_name]\n else\n result = game_hash[:away][:team_name]\n end\n result\nend", "def winner\n @player_positions.max_by{|player, position| position}[0]\n end", "def winning_team_with_spread\n\t\tif self.final?\n\t\t\treturn home_team_id if home_team_score > away_team_score + point_spread\n\t\t\treturn away_team_id if away_team_score + point_spread > home_team_score\n\t\t\treturn \"tie\" if home_team_score == away_team_score + point_spread\n\t\telse\n\t\t\treturn nil\n\t\tend\n\tend", "def overall_winner_message()\n if @score_count.get_determine_set_winner() == 1\n return \"#{@player.get_name()} won the set of games with a score of #{@score_count.get_games_won()} vs. #{@score_count.get_other_games_won()}. Both players tied #{@score_count.get_games_tied} time(s).\"\n\n elsif @score_count.get_determine_set_winner() == 2\n return \"#{@player.get_other_name()} won the set of games with a score of #{@score_count.get_other_games_won()} vs. #{@score_count.get_games_won()}. Both players tied #{@score_count.get_games_tied} time(s).\"\n \n else @score_count.get_determine_set_winner() == 0\n return \"It was a tie, guys. You're both just super duper.\"\n end\n end", "def highest_score\n sorted_all_scores = self.leaderboard_entries.order(score: :DESC)\n sorted_all_scores[0]\n end", "def determine_match_winner\n @games_to_win = ((total_number_of_games / 2.0).floor) + 1\n if player1.score == games_to_win\n return player1\n elsif player2.score == games_to_win\n return player2\n else\n return nil\n end\n end", "def most_points_scored\n points_scored = 0 # starting score to compare with players shoe sizes\n game_hash.each do |location, team_data| # iterates through each team\n players_array = team_data[:players] # finds the :players info in team_data and puts the players into players_array\n players_array.each do |player_name, data| # iterates through each player..\n if data[:points] > points_scored # if their points scored is greater than 0 (we set this earlier in the top of method)\n points_scored = data[:shoe] # take that players score and make it the new points_scored value\n end # this repeats (iterates) through all players until you don't have any more.. meaning the end result is\n end # the player with the highest score\n end\n return points_scored\nend", "def driver_who_earned_most(earnings_hash)\n driver_who_earned_most = \"\"\n most_earned_so_far = 0\n earnings_hash.each do |driver, total_earnings|\n if total_earnings > most_earned_so_far\n most_earned_so_far = total_earnings\n driver_who_earned_most = driver\n end\n end\n driver_who_earned_most\nend" ]
[ "0.8780233", "0.8214541", "0.80745155", "0.7930188", "0.7915673", "0.78216046", "0.777723", "0.7762187", "0.74965173", "0.73907983", "0.72995514", "0.7244865", "0.7242243", "0.7241609", "0.7222115", "0.72114503", "0.71903205", "0.7189977", "0.71860856", "0.70977014", "0.7028762", "0.6992774", "0.6977564", "0.6953501", "0.69460803", "0.693438", "0.6930788", "0.6897319", "0.6893527", "0.68549025", "0.6850665", "0.68329746", "0.67749995", "0.676252", "0.67439824", "0.67334795", "0.67329454", "0.6732868", "0.67213535", "0.6714592", "0.6708323", "0.67002827", "0.6693621", "0.6653485", "0.6633477", "0.6629728", "0.6629075", "0.6628321", "0.6619859", "0.6605291", "0.6599124", "0.65965337", "0.65836173", "0.65793866", "0.6568481", "0.65270406", "0.65257055", "0.6524294", "0.65195364", "0.65070385", "0.64900875", "0.6465007", "0.64611065", "0.64597714", "0.6458071", "0.6457537", "0.6453715", "0.6453495", "0.645062", "0.6449585", "0.6412711", "0.6406149", "0.6378838", "0.6378035", "0.6369394", "0.635905", "0.6353466", "0.63499635", "0.63439226", "0.6341994", "0.63346606", "0.6330999", "0.6325342", "0.63093865", "0.63088673", "0.6298217", "0.6297961", "0.62953985", "0.6295201", "0.6294667", "0.62938905", "0.62780213", "0.62734413", "0.6269392", "0.6256506", "0.6255753", "0.62374055", "0.623501", "0.6215662", "0.62091464" ]
0.6372604
74
returns the biggest difference between team goals and opponent goals for a win for the given team
def biggest_team_blowout(team_id) @games.map do |game| if game.away_team_id.to_s == team_id game.away_goals - game.home_goals elsif game.home_team_id.to_s == team_id game.home_goals - game.away_goals end end.compact.max end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def worst_loss(team_id)\n @games.map do |game|\n if game.away_team_id.to_s == team_id\n game.home_goals - game.away_goals\n elsif game.home_team_id.to_s == team_id\n game.away_goals - game.home_goals\n end\n end.compact.max\n end", "def winningest_team\n @teams.max_by { |team| team.total_win_percentage }.team_name\n end", "def winning_team\n home_points = collection_by_prop(game_hash[:home], :points).reduce(0, :+)\n away_points = collection_by_prop(game_hash[:away], :points).reduce(0, :+)\n home_points > away_points ? game_hash[:home][:team_name] : game_hash[:away][:team_name]\n end", "def biggest_blowout\n score_difference = games.map { |game| (game.home_goals - game.away_goals).abs}\n score_difference.max\n end", "def winner_team(game)\n result = nil\n if game.team1_goals.present? && game.team2_goals.present?\n result = game.team1 if game.team1_goals > game.team2_goals\n result = game.team2 if game.team1_goals < game.team2_goals\n end\n\n result\n end", "def worst_offense\n teams_total_goals = total_goals_helper\n teams_total_games = total_games_helper\n\n worst_team_goals_avg = 1000\n worst_offense_team_id = 0\n this_team_goals_avg = 0\n\n teams_total_games.each do |games_key, games_value|\n teams_total_goals.each do |goals_key, goals_value|\n if goals_key == games_key\n this_team_goals_avg = (goals_value / games_value.to_f)\n if this_team_goals_avg < worst_team_goals_avg\n worst_team_goals_avg = this_team_goals_avg\n worst_offense_team_id = games_key\n end\n end\n end\n end\n\n team_with_worst_offense = nil\n self.teams.each_value do |team_obj|\n if team_obj.team_id. == worst_offense_team_id\n team_with_worst_offense = team_obj.team_name\n end\n end\n team_with_worst_offense\n end", "def winning_team\n self.teams.order('score DESC').first\n end", "def goals_against(team)\n valid = ((team == self.home_team or team == self.away_team) and self.final)\n\n if (valid)\n if (self.home_team == team)\n return self.awayScore\n else\n return self.homeScore\n end\n else\n return 0\n end\n end", "def winning_team\n home_team_points = game_hash[:home][:players].sum { |e| e[:points] }\n away_team_points = game_hash[:away][:players].sum { |e| e[:points] }\n\n if home_team_points > away_team_points\n return game_hash[:home][:team_name]\n else\n return game_hash[:away][:team_name]\n end\nend", "def most_goals_scored(team_id)\n team_id = team_id.to_i\n goals_per_game = @game_teams.map do |game|\n if game.team_id == team_id\n game.goals\n end\n end\n goals_per_game.compact.max\n end", "def goals_for(team)\n valid = ((team == self.home_team or team == self.away_team) and self.final)\n\n if (valid)\n if (self.home_team == team)\n return self.homeScore\n else\n return self.awayScore\n end\n else\n return 0\n end\n end", "def goal_difference\n p1 = calculate_score(team1)\n p2 = calculate_score(team2)\n\n return 0 if p1.nil? or p2.nil?\n\n diff = p1 - p2\n\n diff_1 = diff\n diff_1 = 0 if diff_1 < 0\n\n # The goal difference for second team is the inverse\n diff_2 = -diff\n diff_2 = 0 if diff_2 < 0\n\n [diff_1, diff_2]\n end", "def best_offense\n @teams.max_by { |team| team.average_goals_scored }.team_name\n end", "def best_defense\n teams_total_goals_allowed = total_goals_allowed_helper\n teams_total_games = total_games_helper\n\n best_team_goals_allowed_avg = 100\n best_defense_team_id = 0\n this_team_goals_allowed_avg = 0\n\n teams_total_games.each do |games_key, games_value|\n teams_total_goals_allowed.each do |goals_key, goals_value|\n if goals_key == games_key\n this_team_goals_allowed_avg = (goals_value / games_value.to_f)\n if this_team_goals_allowed_avg < best_team_goals_allowed_avg\n best_team_goals_allowed_avg = this_team_goals_allowed_avg\n best_defense_team_id = games_key\n end\n end\n end\n end\n\n team_with_best_defense = nil\n self.teams.each_value do |team_obj|\n if team_obj.team_id. == best_defense_team_id\n team_with_best_defense = team_obj.team_name\n end\n end\n team_with_best_defense\n end", "def worst_defense\n teams_total_goals_allowed = total_goals_allowed_helper\n teams_total_games = total_games_helper\n\n worst_team_goals_allowed_avg = 0\n worst_defense_team_id = 0\n this_team_goals_allowed_avg = 0\n\n teams_total_games.each do |games_key, games_value|\n\n teams_total_goals_allowed.each do |goals_key, goals_value|\n if goals_key == games_key\n this_team_goals_allowed_avg = (goals_value / games_value.to_f)\n if this_team_goals_allowed_avg > worst_team_goals_allowed_avg\n worst_team_goals_allowed_avg = this_team_goals_allowed_avg\n worst_defense_team_id = games_key\n end\n end\n end\n end\n team_with_worst_defense = team_name_finder_helper(worst_defense_team_id)\n\n team_with_worst_defense\n end", "def worst_defense\n @teams.max_by { |team| team.average_goals_allowed }.team_name\n end", "def fewest_goals_scored(team_id)\n team_id = team_id.to_i\n goals_per_game = @game_teams.map do |game|\n if game.team_id == team_id\n game.goals\n end\n end\n goals_per_game.compact.min\n end", "def worst_offense\n @teams.min_by { |team| team.average_goals_scored }.team_name\n end", "def highest_scoring_visitor\n @teams.max_by { |team| team.average_away_goals }.team_name\n end", "def goal_difference\n total_diff = 0\n\n wattball_matches_as_team1.each do |match|\n total_diff += match.goal_difference[0]\n end\n\n wattball_matches_as_team2.each do |match|\n total_diff += match.goal_difference[1]\n end\n \n total_diff\n end", "def winning_team\n home_team_sum = 0\n away_team_sum = 0\n game_hash.each do |team, team_stats|\n if team_stats[:team_name] == \"Brooklyn Nets\"\n team_stats[:players].each do |player_stats|\n home_team_sum += player_stats[:points]\n end\n elsif team_stats[:team_name] == \"Charlotte Hornets\"\n team_stats[:players].each do |player_stats|\n away_team_sum += player_stats[:points]\n end\n end\n end\n if home_team_sum > away_team_sum\n game_hash[:home][:team_name]\n elsif home_team_sum < away_team_sum\n game_hash[:away][:team_name]\n end\nend", "def winning_team\n final_scores = player_collection.reduce(home: 0, away: 0) { |teams_points, next_player|\n case \n when next_player[:location] === :away\n teams_points[:away] += next_player[:points];\n when next_player[:location] === :home\n teams_points[:home] += next_player[:points];\n end\n teams_points; \n }\n winner = final_scores.reduce { |highest_points, team_points| \n highest_points[1] > team_points[1] ? highest_points : team_points; \n }\n game_hash[winner[0]][:team_name]; \nend", "def winning_team\n home_score = 0\n away_score = 0\n game_hash[:home][:players].keys.each do |name|\n home_score += game_hash[:home][:players][name][:points]\n end\n game_hash[:away][:players].keys.each do |name|\n away_score += game_hash[:away][:players][name][:points]\n end\n home_score > away_score ? game_hash[:home][:team_name] : game_hash[:away][:team_name]\nend", "def favorite_opponent(team_id)\n team_id = team_id.to_i\n team = @teams.select { |each_team| each_team.team_id == team_id }.first\n favorite_opponent_id = team.matchup_win_percentage.max_by{|each_team, percentage| percentage}.first\n @teams.select { |each_team| each_team.team_id == favorite_opponent_id }.first.team_name\n end", "def winning_team\n team_p = []\n team_n = []\n\n game_hash.each do | location, team_data|\n temp = 0\n team_data[:players].each do |p_name, stats|\n temp += stats[:points]\n end\n team_n << team_data[:team_name]\n team_p << temp\n end\n\n team_p[0] > team_p[1] ? team_n[0] : team_n[1]\n\nend", "def winning_team\n if homeTeamPoints.sum > awayTeamPoints.sum\n \"Brooklyn Nets\"\n else\n \"Charlotte Hornets\"\n end\nend", "def winning_team\n home_points = 0\n away_points = 0\n result = \"\"\n i = 0\n game_hash.each do |team, about|\n about[:players].each do |name , stats|\n if i == 0\n home_points += stats[:points]\n else\n away_points += stats[:points]\n end\n end\n i += 1\n end\n home_points > away_points ? result = game_hash[:home][:team_name] : result = game_hash[:away][:team_name]\nend", "def highest_scoring_home_team\n @teams.max_by { |team| team.average_home_goals }.team_name\n end", "def team_with_more_points(game)\n home_points = game[:home_team][:players].collect do |player|\n player[:stats][:points]\n end.inject {|sum, n| sum + n}\n away_points = game[:away_team][:players].collect do |player|\n player[:stats][:points]\n end.inject {|sum, n| sum + n}\n home_points > away_points ? game[:home_team][:team_name] : game[:away_team][:team_name]\nend", "def determine_winner game\n winner = game.max_by {|team| team[:score]}\n team_standings = get_team_by_name(winner)\n team_standings[:winnings] += 3\nend", "def winning_team\n nets = []\n hornets = []\n\n game_hash.values.each do |nets_stats|\n if nets_stats[:team_name] == \"Brooklyn Nets\"\n nets_stats[:players].each do |bk|\n nets << bk[:points]\n end\n end\n end\n\n game_hash.values.each do |hornets_stats|\n if hornets_stats[:team_name] == \"Charlotte Hornets\"\n hornets_stats[:players].each do |ch|\n hornets << ch[:points]\n end\n end\n end\n\n if nets.reduce(:+) > hornets.reduce(:+)\n return \"Brooklyn Nets\"\n else\n return \"Charlotte Hornets\"\n end\nend", "def winning_team\n points_home = 0\n points_away = 0\n result = \"\"\n\n game_hash.each do |side,team|\n team.each do |specs,info|\n if specs == :players\n info.each do |player|\n if side = :home\n points_home += player[:points]\n else\n points_away += player[:points]\n end\n end\n end\n end\n end\n if points_home > points_away\n result = game_hash[:home][:team_name]\n else\n result = game_hash[:away][:team_name]\n end\n result\nend", "def best_defense\n @teams.min_by { |team| team.average_goals_allowed }.team_name\n end", "def player_w_biggest_feet\n all_players[1].max_by { |stats| stats[:shoe] }\n end", "def winner(game)\n result = nil\n if game.team1_goals.present? && game.team2_goals.present?\n result = TEAM1_WIN if game.team1_goals > game.team2_goals\n result = TEAM2_WIN if game.team1_goals < game.team2_goals\n result = DRAW if game.team1_goals == game.team2_goals\n end\n\n result\n end", "def winning_team_with_spread\n\t\tif self.final?\n\t\t\treturn home_team_id if home_team_score > away_team_score + point_spread\n\t\t\treturn away_team_id if away_team_score + point_spread > home_team_score\n\t\t\treturn \"tie\" if home_team_score == away_team_score + point_spread\n\t\telse\n\t\t\treturn nil\n\t\tend\n\tend", "def best_fans\n @teams.max_by { |team| team.home_minus_away_percentage }.team_name\n end", "def compute_team_winner\n if completed?\n team_winner\n else\n if first_team && second_team\n if sets_won(first_team) == min_sets_to_play\n first_team\n elsif sets_won(second_team) == min_sets_to_play\n second_team\n end\n end\n end\n end", "def most_accurate_team(seasonasstring) # shots in game team stats\n #get a list of all teams that played in that season - given by arg\n #use above list to sum all shots across all games in season\n #divide above by goals made across all games in season\n #find highest percentage\n #return team name as found in 127\n end", "def winning_team\n blue_team.winner? ? blue_team : red_team\n end", "def winning_team\n total_points = 0 #initialize points at zero \n \n win_team = '' #set win team to an empty string \n \n game_hash.each do |location, team| #iterating over game hash\n team_points = 0 #initialize team points at zero \n team_name = game_hash[location][:team_name] \n # set team name = to game_hash at the the location at the # :team name \n \n team[:players].each do |player| #iterate over players \n points = player[:points] # set points = player points \n team_points += points #team points is the addition of every single point value from each player\n \n #binding.pry \n end\n \n win_team, total_points = team_name, team_points if team_points > total_points\n \n #binding.pry \n \n end\n \n return win_team\n\nend", "def big_shoe_rebounds\n max_shoe = 0 \n max_rebounds = 0 \n game_hash.each do |place, team|\n # team.each do |attribute, data|\n team[:players].each do |player|\n if player[:shoe] > max_shoe\n max_shoe = player[:shoe]\n max_rebounds = player[:rebounds]\n # if attribute == :players\n # data.each do |player|\n #this gives me the player hashes\n # data.max_by{|player| player[:shoe] }\n # data.max_by{|player| player[:shoe] }[:rebounds]\n # player.max_by{|player| player[:shoe] \n # player.max_by{|player| player[:shoe] }[:rebounds]\n end\n end\n end\n return max_rebounds\n end", "def highest_total_score\n total_goals.max\n end", "def best_season(team_id)\n team_id = team_id.to_i\n team = @teams.select { |each_team| each_team.team_id == team_id }.first\n team.season_win_percentages.max_by { |season, percentage| percentage }.first.to_s\n end", "def score_for_team(team)\n team ||= winner_team\n winner_team?(team) ? score : scores.reverse.join(':')\n end", "def winning_team\n home_points = 0\n away_points = 0\n team1 = \"Brooklyn Nets\"\n team2 = \"Charlotte Hornets\"\n game_hash.each do |team,info|\n info.each do |team_info,team_data|\n if team_data.is_a? (Array) \n if team_info != :colors\n if info[:team_name] == \"Brooklyn Nets\"\n team_data.each do |player_index|\n home_points += player_index[:points]\n end\n else \n team_data.each do |player_index|\n away_points += player_index[:points]\n winning_team end\n end\n end\n end\n end\n end\n\n if home_points > away_points\n team1\n else\n team2\n end\n\nend", "def worst_season(team_id)\n team_id = team_id.to_i\n team = @teams.select { |each_team| each_team.team_id == team_id }.first\n team.season_win_percentages.min_by { |season, percentage| percentage }.first.to_s\n end", "def winner\n if (self.homeScore > self.awayScore)\n return self.home_team\n elsif (self.awayScore > self.homeScore)\n return self.away_team\n else\n return nil\n end\n end", "def most_steals(game)\nmax_steals = 0\nmax_steals_player = \"\"\ngame.each do |team, team_contents|\n team_contents[:roster].each do |player, player_contents| \n if player_contents[:steals] == max_steals\n max_steals_player = max_steals_player + \" and #{player_contents[:player_name]}\"\n elsif player_contents[:steals] > max_steals\n max_steals = player_contents[:steals]\n max_steals_player = player_contents[:player_name]\n end\n end\nend\nmax_steals_player\nend", "def player_with_most_steals\n name = \"\"\n most_steals = 0\n\n game_hash.each do | team, details_hash |\n players_array = details_hash[:players]\n players_array.each do | player_details_hash |\n if player_details_hash[:steals] > most_steals\n most_steals = player_details_hash[:steals]\n name = player_details_hash[:player_name]\n end\n end\n end\n name\nend", "def winning_team(result)\n goals = result.split(\"-\")\n if goals[0] == goals[1]\n \"draw\"\n elsif goals[0].to_i > goals[1].to_i\n \"home\"\n else\n \"away\"\n end\n end", "def most_points(game)\n player_name_with_points = []\n game[:home_team][:players].each do |player_hash|\n player_name_with_points << {player_hash[:player_name] => player_hash[:stats][:points]}\n end\n game[:away_team][:players].each do |player_hash|\n player_name_with_points << {player_hash[:player_name] => player_hash[:stats][:points]}\n end\n player_most_points = {\"test\" => 0}\n player_name_with_points.each do |name_and_points_hash|\n player_most_points = name_and_points_hash if name_and_points_hash.values[0] > player_most_points.values[0]\n end\n player_most_points.keys[0]\nend", "def winning_team\n most_points_scored_helper\n winning_team = \"\"\n \n game_hash.each do |key, value|\n players = value[:players]\n players.each do |element|\n if most_points_scored_helper == element[:points]\n winning_team = value[:team_name]\n end\n end\n end\n winning_team\nend", "def winner\n @players.max_by{ |player| player.score}\n end", "def biggest_surprise(season)\n season = season.to_i\n @teams.max_by{ |team| team.preseason_to_regular_increase[season] }.team_name\n end", "def winner\n @players.max_by do |player|\n player.score\n end\n end", "def most_points_scored\n max = nil\n name = nil \n game_hash.each do |team, team_values|\n team_values[:players].each do |player|\n if max == nil || player[:points] > max\n max = player[:points]\n name = player[:player_name]\n end\n end\n end\n name\nend", "def pri_toff\n team_stats.goals_per_game / team_stats.opp_avg_goals_per_game\n end", "def best_offense\n offense_suite\n best_offense_id = @average_goals_by_id.invert.max[1]\n @team_name_by_id[best_offense_id]\n end", "def points(team)\n first = 0\n res = self.result\n\n if res\n if team == 1\n first_team = res[0]\n sec_team = res[1]\n elsif team == 2\n first_team = res[1]\n sec_team = res[0]\n else \n raise \"Invalid Team chosen\"\n end\n\n p first_team <=> sec_team\n # Compare the results\n outcome = first_team <=> sec_team\n\n if outcome > 0\n # Win\n result = 3\n elsif outcome < 0\n # Loss\n result = 0\n else \n # Draw\n result = 1\n end\n else\n result = nil\n end\n\n result\n end", "def get_max_over(stat)\n max = 0\n $data_enemies.each { |enemy|\n next if enemy.nil?\n next if enemy.hidden_best\n next unless $game_party.known_enemy?(enemy.id)\n value = enemy.get_stat(stat)\n max = value if value > max\n }\n max\n end", "def biggest_shoe\r\n player_name= []\r\n game_hash.each do |team, data|\r\n data.each do |team_info, value|\r\n if team_info == \"players\".to_sym\r\n obj=value.max_by {|key, value| value[:shoe]}\r\n player_name<< obj.first\r\n end\r\n end\r\n end\r\n player_name.first\r\nend", "def team_hitting_pull_up\n return nil unless pull_up?\n team1.stats.wins > team2.stats.wins ? team1 : team2\n end", "def max_teams(rounds)\n 2**rounds\n end", "def max_teams(rounds)\n 2**rounds\n end", "def goal_diff()\n\t self.goals_for() - self.goals_against()\n\tend", "def get_highest_for(turn)\n\t\tif @highs[1][turn] > @highs[2][turn] then 1 else 2 end\n\tend", "def winning_player\n played_cards.max_by { |_, card| card_scores[card] }.first\n end", "def most_steals \n num_steals = 0\n game_hash.each do |team,info|\n info.each do |team_info,team_data|\n if team_data.is_a? (Array) \n if team_info != :colors\n team_data.each do |player_index|\n if num_steals == 0 || player_index[:steals] > num_steals \n num_steals = player_index[:steals] \n end\n end\n end\n end\n end\n end\nnum_steals\nend", "def smallest_team\n self.teams.min{|t1,t2| t1.runners.size <=> t2.runners.size }\n end", "def calculate_overall_winner\n points_per_player = {}\n @matches.each do | match |\n !points_per_player[match.winner].nil? ? (points_per_player[match.winner] += 1) : (points_per_player[match.winner] = 1)\n end\n max_points = points_per_player.values.max\n points_per_player.key(max_points)\n end", "def big_shoe_rebounds\n player_with_the_largest_shoe_size = 0\n most_rebounds = 0\n game_hash.each do |team,info|\n info.each do |team_info,team_data|\n if team_data.is_a? (Array) \n if team_info != :colors\n team_data.each do |player_index|\n if player_with_the_largest_shoe_size == 0 || player_index[:shoe] > player_with_the_largest_shoe_size \n player_with_the_largest_shoe_size = player_index[:shoe]\n most_rebounds = player_index[:rebounds]\n end\n end\n end\n end\n end\n end\n most_rebounds\nend", "def determine_match_winner\n @games_to_win = ((total_number_of_games / 2.0).floor) + 1\n if player1.score == games_to_win\n return player1\n elsif player2.score == games_to_win\n return player2\n else\n return nil\n end\n end", "def get_max_past_teammates(participant)\n past_team_associations = TeamsUser.find_all_by_user_id(participant.user_id)\n past_team_associations -= TeamsUser.find_all_by_team_id(id)\n past_team_ids = past_team_associations.map{|association| association.team_id}\n past_teams = past_team_ids.map{|team_id| Team.find_by_id(team_id)}\n past_assignments = past_teams.map{|team| Assignment.find_by_id(team.parent_id)}\n past_assignments.delete_if {|assignment| assignment.course_id != Assignment.find_by_id(parent_id).course_id}\n return past_assignments.inject(0) {|sum, assignment| sum += assignment.team_count - 1}\n end", "def big_shoe_rebounds\n\nhighest_rebounds = 0\nbiggest_shoe = 0\n\n game_hash.each do |location, team_info|\n game_hash.dig(location, :players).each do |player_name, stats|\n stats.each do |stat, number|\n if stat == :shoe\n if number > biggest_shoe\n biggest_shoe = number\n stats.each do |stat, number|\n if stat == :rebounds\n highest_rebounds = number\n end\n end\n end\n end\n end\n end\n end\n puts highest_rebounds\n return highest_rebounds\nend", "def get_team(game)\n team = 0\n get_participation_by_game game do |participation|\n team = participation.team\n end\n team\n end", "def biggestShoes\n players.max_by do|name, stats|\n stats[:shoe]\n end\nend", "def total_team_score(teams_id)\n total_score = 0\n @league_data.each do\n |team| \n # binding.pry\n if team.home_team_id == teams_id\n total_score += team.home_team_score\n elsif team.away_team_id == teams_id\n total_score += team.away_team_score\n end\n end\n return total_score\n end", "def biggest_investment\n self.funding_rounds.max_by {|funding| funding.investment }\n end", "def big_shoe_rebounds\n biggest_shoe_size = 0\n player_rebounds = 0\n game_hash.each do |k, team|\n team[:players].each do |e|\n if e[:shoe] > biggest_shoe_size\n biggest_shoe_size = e[:shoe]\n player_rebounds = e[:rebounds]\n end\n end\n end\n player_rebounds\nend", "def biggest_investment\n funding_rounds.max_by {|funding_round| funding_round.investment}\n end", "def big_shoe_rebounds\n biggest = 0\n rebounds = 0\n game_hash.each do |team, team_data|\n team_data[:players].each do |player|\n size = player[:shoe]\n if size > biggest\n biggest = size\n rebounds = player[:rebounds]\n end\n end\n end\n rebounds\nend", "def min_max(dept, player, alpha, beta)\r\n best_move = -1\r\n score = 0\r\n\r\n # Return best move when Game over or dept reached\r\n if over? || dept == 0\r\n score = evaluate\r\n return [score, best_move]\r\n end\r\n\r\n # Try each possible move\r\n possible_moves.each do |move|\r\n board.cells[move] = player\r\n\r\n if token == player # Current move is for self\r\n score = min_max(dept-1, rival_token, alpha, beta)[0]\r\n if score > alpha\r\n alpha = score\r\n best_move = move\r\n end\r\n else # Current move is for opponent\r\n score = min_max(dept-1, token, alpha, beta)[0]\r\n if score < beta\r\n beta = score\r\n best_move = move\r\n end\r\n end\r\n\r\n # undo move\r\n board.cells[move] = \" \"\r\n\r\n #Prune: stop iteration when alpha >= beta\r\n break if alpha >= beta\r\n end\r\n score = player == token ? alpha : beta\r\n\r\n [score, best_move]\r\n end", "def mostSteals\n players.max_by do|name, stats|\n stats[:steals]\n end\nend", "def outcome\n if self.final\n \th = home_team\n \ta = away_team\n \t# h.wins=0 if h.wins==nil\n \t# h.losses=0 if h.losses==nil\n \t# a.wins=0 if a.wins==nil\n \t# a.losses=0 if a.losses==nil\n \tif home_score == away_score\n \t\treturn 'T'\n \telsif home_score > away_score\n \t\tif !self.recorded\n \t \t\th.wins += 1\n \t \t\ta.losses += 1\n \t \t\th.save\n \t \t\ta.save\n \t \t\tself.recorded=true\n \t \t\tself.save\n \t \tend\n \t\tif overtime\n \t\t\treturn 'h'\n \t\telse\n \t\t\treturn 'H'\n \t\tend\n \telse\n \t\tif !self.recorded\n \t \t\th.losses += 1\n \t \t\ta.wins += 1\n \t \t\ta.save\n \t \t\th.save\n \t \t\tself.recorded=true\n \t \t\tself.save\n \t \tend\n \t\tif overtime\n \t\t\treturn 'a'\n \t\telse\n \t\t\treturn 'A'\n \t\tend\n \tend\n end\n end", "def avg_of_toryo_turn_max\n s = lose_scope\n s = s.joins(:battle)\n s = s.where(Swars::Battle.arel_table[:final_key].eq(\"TORYO\"))\n if v = s.average(Swars::Battle.arel_table[:turn_max])\n v.to_i\n end\n end", "def player_with_most_steal\n most_steals = nil\n most_steal_player = nil\n\n all_players(game_hash).each do |player|\n if most_steals == nil || player[:steals] > most_steals\n most_steals = player[:steals]\n most_steal_player = player[:player_name]\n end\n end\n\n most_steal_player\nend", "def worst_case board\n\t\tworst = 0\n\t\topp_board = board.rotate 7\n\t\t6.times {|i|\n\t\t\t\ts = score_for(opp_board, i)\n\t\t\t\tworst = s if worst < s\n\t\t\t}\n\t\t\tworst\n\tend", "def rebounds_for_player_with_largest_shoe_size(game)\n shoe_sizes_with_player_names = []\n game[:home_team][:players].each do |player_hash|\n shoe_sizes_with_player_names << {player_hash[:player_name] => player_hash[:shoe_size]}\n end\n game[:away_team][:players].each do |player_hash|\n shoe_sizes_with_player_names << {player_hash[:player_name] => player_hash[:shoe_size]}\n end\n biggest_shoe_size = {\"test\" => 0}\n shoe_sizes_with_player_names.each do |shoe_size_and_name_hash|\n biggest_shoe_size = shoe_size_and_name_hash if shoe_size_and_name_hash.values[0] > biggest_shoe_size.values[0]\n end\n game[:home_team][:players].each do |player_hash|\n return player_hash[:stats][:rebounds] if player_hash[:player_name] == biggest_shoe_size.keys[0]\n end\n game[:away_team][:players].each do |player_hash|\n return player_hash[:stats][:rebounds] if player_hash[:player_name] == biggest_shoe_size.keys[0]\n end\nend", "def most_points(game)\nmax_points = 0\nmax_points_player = \"\"\ngame.each do |team, team_contents|\n team_contents[:roster].each do |player, player_contents| \n if player_contents[:points] == max_points\n max_points_player = max_points_player + \" and #{player_contents[:player_name]}\"\n elsif player_contents[:points] > max_points\n max_points = player_contents[:points]\n max_points_player = player_contents[:player_name]\n end\n end\nend\nputs \"#{max_points_player} scored #{max_points}\"\nend", "def find_best_score(total_per_player)\n best_score = 0\n winner = ''\n total_per_player.each do |player_name,total|\n\n if total > best_score\n best_score = total\n winner = player_name\n end\n end\n return winner\n end", "def high_score\n if self.end_date < Date.today\n self.teams.max_by { |team| team.score }.score\n end\n end", "def wins\n wins = 0\n self.teams.each do |team|\n wins += team.games_won.length\n end\n wins\n end", "def big_shoe_rebounds_2\n\nhighest_rebounds = 0\nbiggest_shoe = 0\n\n\n game_hash.dig(:home, :players).each do |player_name, stats|\n stats.each do |stat, number|\n if stat == :shoe\n if number > biggest_shoe\n biggest_shoe = number\n stats.each do |stat, number|\n if stat == :rebounds\n highest_rebounds = number\n\n end\n end\n end\n end\n end\nend\n\n puts highest_rebounds\n return highest_rebounds\nend", "def max(board)\n #Generate moves array\n moves = minmax_moves(board, self)\n #Placeholder for max score, even the worst score is > -2\n max = -2\n #Find terminal and check terminal nodes and delete them from move array. If any of them are 1 instantly return\n moves.delete_if do |index, board|\n if over?(board)\n #If board is terminal get score\n res = minmax_score(board)\n #If terminal is winning instantly return it\n return res if res == 1\n max = res if res > max\n true\n else\n false\n end\n end\n\n #Else get worst scores of new states\n moves.each do |index, board|\n res = min(board)\n return res if res == 1\n max = res if res > max\n end\n max\n end", "def rival(team_id)\n team_id = team_id.to_i\n team = @teams.select { |each_team| each_team.team_id == team_id }.first\n rival_id = team.matchup_win_percentage.min_by{|each_team, percentage| percentage}.first\n @teams.select { |each_team| each_team.team_id == rival_id }.first.team_name\n end", "def best_move_for(player)\n return minimax(player)[1]\n end", "def big_shoe_rebounds\n biggest_shoe = 0\n rebounds = 0\n game_hash.each do |team, all_info_hash|\n all_info_hash[:players].each do |player_information_hash|\n if player_information_hash[:shoe] > biggest_shoe\n biggest_shoe = player_information_hash[:shoe] \n rebounds = player_information_hash[:rebounds] \n end\n end\n end\n rebounds\nend", "def near_team_winner?(team)\n unless completed?\n sets_won(team) + 1 == min_sets_to_play\n end\n end", "def highest_player_score\n players.max_by{|player| player.score}.score\n end" ]
[ "0.77380055", "0.7728651", "0.73598915", "0.7259523", "0.7244735", "0.720186", "0.70930254", "0.7074973", "0.70716393", "0.70628035", "0.70560294", "0.7047119", "0.70119333", "0.6950264", "0.69316876", "0.69123924", "0.6862988", "0.68436104", "0.6769966", "0.6761037", "0.6758388", "0.67517126", "0.6740203", "0.67291677", "0.672362", "0.67208874", "0.67157584", "0.6675441", "0.6638162", "0.66373456", "0.6609545", "0.660054", "0.6599914", "0.6573724", "0.6553008", "0.65509105", "0.65458524", "0.65451205", "0.65049756", "0.65009695", "0.6475029", "0.6421513", "0.6413067", "0.6408895", "0.63769394", "0.63675094", "0.6347065", "0.6291783", "0.62633896", "0.62558186", "0.62533593", "0.62427104", "0.62363374", "0.62190044", "0.620131", "0.6189976", "0.6170126", "0.6144041", "0.6139539", "0.6131683", "0.61252093", "0.6123105", "0.6115742", "0.6102519", "0.6102519", "0.6099008", "0.60955846", "0.6094132", "0.6067109", "0.60607517", "0.60585237", "0.6046279", "0.60424393", "0.60404456", "0.60400295", "0.603522", "0.602468", "0.60094213", "0.6007564", "0.60066074", "0.59986246", "0.59926265", "0.599121", "0.5987954", "0.5985989", "0.5979768", "0.59698546", "0.5966084", "0.59620064", "0.59429514", "0.5941927", "0.5939935", "0.593935", "0.5937374", "0.59359163", "0.5933085", "0.59324706", "0.5923096", "0.5909837", "0.5907998" ]
0.7481996
2
returns the biggest difference between team goals and opponent goals for a loss for the given team
def worst_loss(team_id) @games.map do |game| if game.away_team_id.to_s == team_id game.home_goals - game.away_goals elsif game.home_team_id.to_s == team_id game.away_goals - game.home_goals end end.compact.max end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def winningest_team\n @teams.max_by { |team| team.total_win_percentage }.team_name\n end", "def biggest_team_blowout(team_id)\n @games.map do |game|\n if game.away_team_id.to_s == team_id\n game.away_goals - game.home_goals\n elsif game.home_team_id.to_s == team_id\n game.home_goals - game.away_goals\n end\n end.compact.max\n end", "def worst_defense\n @teams.max_by { |team| team.average_goals_allowed }.team_name\n end", "def biggest_blowout\n score_difference = games.map { |game| (game.home_goals - game.away_goals).abs}\n score_difference.max\n end", "def worst_offense\n teams_total_goals = total_goals_helper\n teams_total_games = total_games_helper\n\n worst_team_goals_avg = 1000\n worst_offense_team_id = 0\n this_team_goals_avg = 0\n\n teams_total_games.each do |games_key, games_value|\n teams_total_goals.each do |goals_key, goals_value|\n if goals_key == games_key\n this_team_goals_avg = (goals_value / games_value.to_f)\n if this_team_goals_avg < worst_team_goals_avg\n worst_team_goals_avg = this_team_goals_avg\n worst_offense_team_id = games_key\n end\n end\n end\n end\n\n team_with_worst_offense = nil\n self.teams.each_value do |team_obj|\n if team_obj.team_id. == worst_offense_team_id\n team_with_worst_offense = team_obj.team_name\n end\n end\n team_with_worst_offense\n end", "def best_offense\n @teams.max_by { |team| team.average_goals_scored }.team_name\n end", "def goal_difference\n p1 = calculate_score(team1)\n p2 = calculate_score(team2)\n\n return 0 if p1.nil? or p2.nil?\n\n diff = p1 - p2\n\n diff_1 = diff\n diff_1 = 0 if diff_1 < 0\n\n # The goal difference for second team is the inverse\n diff_2 = -diff\n diff_2 = 0 if diff_2 < 0\n\n [diff_1, diff_2]\n end", "def best_defense\n teams_total_goals_allowed = total_goals_allowed_helper\n teams_total_games = total_games_helper\n\n best_team_goals_allowed_avg = 100\n best_defense_team_id = 0\n this_team_goals_allowed_avg = 0\n\n teams_total_games.each do |games_key, games_value|\n teams_total_goals_allowed.each do |goals_key, goals_value|\n if goals_key == games_key\n this_team_goals_allowed_avg = (goals_value / games_value.to_f)\n if this_team_goals_allowed_avg < best_team_goals_allowed_avg\n best_team_goals_allowed_avg = this_team_goals_allowed_avg\n best_defense_team_id = games_key\n end\n end\n end\n end\n\n team_with_best_defense = nil\n self.teams.each_value do |team_obj|\n if team_obj.team_id. == best_defense_team_id\n team_with_best_defense = team_obj.team_name\n end\n end\n team_with_best_defense\n end", "def worst_defense\n teams_total_goals_allowed = total_goals_allowed_helper\n teams_total_games = total_games_helper\n\n worst_team_goals_allowed_avg = 0\n worst_defense_team_id = 0\n this_team_goals_allowed_avg = 0\n\n teams_total_games.each do |games_key, games_value|\n\n teams_total_goals_allowed.each do |goals_key, goals_value|\n if goals_key == games_key\n this_team_goals_allowed_avg = (goals_value / games_value.to_f)\n if this_team_goals_allowed_avg > worst_team_goals_allowed_avg\n worst_team_goals_allowed_avg = this_team_goals_allowed_avg\n worst_defense_team_id = games_key\n end\n end\n end\n end\n team_with_worst_defense = team_name_finder_helper(worst_defense_team_id)\n\n team_with_worst_defense\n end", "def worst_offense\n @teams.min_by { |team| team.average_goals_scored }.team_name\n end", "def highest_scoring_visitor\n @teams.max_by { |team| team.average_away_goals }.team_name\n end", "def goals_against(team)\n valid = ((team == self.home_team or team == self.away_team) and self.final)\n\n if (valid)\n if (self.home_team == team)\n return self.awayScore\n else\n return self.homeScore\n end\n else\n return 0\n end\n end", "def best_defense\n @teams.min_by { |team| team.average_goals_allowed }.team_name\n end", "def most_goals_scored(team_id)\n team_id = team_id.to_i\n goals_per_game = @game_teams.map do |game|\n if game.team_id == team_id\n game.goals\n end\n end\n goals_per_game.compact.max\n end", "def most_accurate_team(seasonasstring) # shots in game team stats\n #get a list of all teams that played in that season - given by arg\n #use above list to sum all shots across all games in season\n #divide above by goals made across all games in season\n #find highest percentage\n #return team name as found in 127\n end", "def winning_team\n self.teams.order('score DESC').first\n end", "def winner_team(game)\n result = nil\n if game.team1_goals.present? && game.team2_goals.present?\n result = game.team1 if game.team1_goals > game.team2_goals\n result = game.team2 if game.team1_goals < game.team2_goals\n end\n\n result\n end", "def goals_for(team)\n valid = ((team == self.home_team or team == self.away_team) and self.final)\n\n if (valid)\n if (self.home_team == team)\n return self.homeScore\n else\n return self.awayScore\n end\n else\n return 0\n end\n end", "def goal_difference\n total_diff = 0\n\n wattball_matches_as_team1.each do |match|\n total_diff += match.goal_difference[0]\n end\n\n wattball_matches_as_team2.each do |match|\n total_diff += match.goal_difference[1]\n end\n \n total_diff\n end", "def highest_scoring_home_team\n @teams.max_by { |team| team.average_home_goals }.team_name\n end", "def player_w_biggest_feet\n all_players[1].max_by { |stats| stats[:shoe] }\n end", "def favorite_opponent(team_id)\n team_id = team_id.to_i\n team = @teams.select { |each_team| each_team.team_id == team_id }.first\n favorite_opponent_id = team.matchup_win_percentage.max_by{|each_team, percentage| percentage}.first\n @teams.select { |each_team| each_team.team_id == favorite_opponent_id }.first.team_name\n end", "def highest_total_score\n total_goals.max\n end", "def winning_team\n home_points = collection_by_prop(game_hash[:home], :points).reduce(0, :+)\n away_points = collection_by_prop(game_hash[:away], :points).reduce(0, :+)\n home_points > away_points ? game_hash[:home][:team_name] : game_hash[:away][:team_name]\n end", "def fewest_goals_scored(team_id)\n team_id = team_id.to_i\n goals_per_game = @game_teams.map do |game|\n if game.team_id == team_id\n game.goals\n end\n end\n goals_per_game.compact.min\n end", "def get_max_over(stat)\n max = 0\n $data_enemies.each { |enemy|\n next if enemy.nil?\n next if enemy.hidden_best\n next unless $game_party.known_enemy?(enemy.id)\n value = enemy.get_stat(stat)\n max = value if value > max\n }\n max\n end", "def winning_team\n home_team_points = game_hash[:home][:players].sum { |e| e[:points] }\n away_team_points = game_hash[:away][:players].sum { |e| e[:points] }\n\n if home_team_points > away_team_points\n return game_hash[:home][:team_name]\n else\n return game_hash[:away][:team_name]\n end\nend", "def worst_season(team_id)\n team_id = team_id.to_i\n team = @teams.select { |each_team| each_team.team_id == team_id }.first\n team.season_win_percentages.min_by { |season, percentage| percentage }.first.to_s\n end", "def best_season(team_id)\n team_id = team_id.to_i\n team = @teams.select { |each_team| each_team.team_id == team_id }.first\n team.season_win_percentages.max_by { |season, percentage| percentage }.first.to_s\n end", "def best_offense\n offense_suite\n best_offense_id = @average_goals_by_id.invert.max[1]\n @team_name_by_id[best_offense_id]\n end", "def min_max(dept, player, alpha, beta)\r\n best_move = -1\r\n score = 0\r\n\r\n # Return best move when Game over or dept reached\r\n if over? || dept == 0\r\n score = evaluate\r\n return [score, best_move]\r\n end\r\n\r\n # Try each possible move\r\n possible_moves.each do |move|\r\n board.cells[move] = player\r\n\r\n if token == player # Current move is for self\r\n score = min_max(dept-1, rival_token, alpha, beta)[0]\r\n if score > alpha\r\n alpha = score\r\n best_move = move\r\n end\r\n else # Current move is for opponent\r\n score = min_max(dept-1, token, alpha, beta)[0]\r\n if score < beta\r\n beta = score\r\n best_move = move\r\n end\r\n end\r\n\r\n # undo move\r\n board.cells[move] = \" \"\r\n\r\n #Prune: stop iteration when alpha >= beta\r\n break if alpha >= beta\r\n end\r\n score = player == token ? alpha : beta\r\n\r\n [score, best_move]\r\n end", "def best_fans\n @teams.max_by { |team| team.home_minus_away_percentage }.team_name\n end", "def biggest_surprise(season)\n season = season.to_i\n @teams.max_by{ |team| team.preseason_to_regular_increase[season] }.team_name\n end", "def determine_winner game\n winner = game.max_by {|team| team[:score]}\n team_standings = get_team_by_name(winner)\n team_standings[:winnings] += 3\nend", "def score_for_team(team)\n team ||= winner_team\n winner_team?(team) ? score : scores.reverse.join(':')\n end", "def team_with_more_points(game)\n home_points = game[:home_team][:players].collect do |player|\n player[:stats][:points]\n end.inject {|sum, n| sum + n}\n away_points = game[:away_team][:players].collect do |player|\n player[:stats][:points]\n end.inject {|sum, n| sum + n}\n home_points > away_points ? game[:home_team][:team_name] : game[:away_team][:team_name]\nend", "def winning_team\n blue_team.winner? ? blue_team : red_team\n end", "def winning_team\n if homeTeamPoints.sum > awayTeamPoints.sum\n \"Brooklyn Nets\"\n else\n \"Charlotte Hornets\"\n end\nend", "def winning_team\n home_score = 0\n away_score = 0\n game_hash[:home][:players].keys.each do |name|\n home_score += game_hash[:home][:players][name][:points]\n end\n game_hash[:away][:players].keys.each do |name|\n away_score += game_hash[:away][:players][name][:points]\n end\n home_score > away_score ? game_hash[:home][:team_name] : game_hash[:away][:team_name]\nend", "def winning_team\n team_p = []\n team_n = []\n\n game_hash.each do | location, team_data|\n temp = 0\n team_data[:players].each do |p_name, stats|\n temp += stats[:points]\n end\n team_n << team_data[:team_name]\n team_p << temp\n end\n\n team_p[0] > team_p[1] ? team_n[0] : team_n[1]\n\nend", "def winning_team\n nets = []\n hornets = []\n\n game_hash.values.each do |nets_stats|\n if nets_stats[:team_name] == \"Brooklyn Nets\"\n nets_stats[:players].each do |bk|\n nets << bk[:points]\n end\n end\n end\n\n game_hash.values.each do |hornets_stats|\n if hornets_stats[:team_name] == \"Charlotte Hornets\"\n hornets_stats[:players].each do |ch|\n hornets << ch[:points]\n end\n end\n end\n\n if nets.reduce(:+) > hornets.reduce(:+)\n return \"Brooklyn Nets\"\n else\n return \"Charlotte Hornets\"\n end\nend", "def goal_diff()\n\t self.goals_for() - self.goals_against()\n\tend", "def highest_player_score\n players.max_by{|player| player.score}.score\n end", "def winning_team\n home_team_sum = 0\n away_team_sum = 0\n game_hash.each do |team, team_stats|\n if team_stats[:team_name] == \"Brooklyn Nets\"\n team_stats[:players].each do |player_stats|\n home_team_sum += player_stats[:points]\n end\n elsif team_stats[:team_name] == \"Charlotte Hornets\"\n team_stats[:players].each do |player_stats|\n away_team_sum += player_stats[:points]\n end\n end\n end\n if home_team_sum > away_team_sum\n game_hash[:home][:team_name]\n elsif home_team_sum < away_team_sum\n game_hash[:away][:team_name]\n end\nend", "def winning_team\n final_scores = player_collection.reduce(home: 0, away: 0) { |teams_points, next_player|\n case \n when next_player[:location] === :away\n teams_points[:away] += next_player[:points];\n when next_player[:location] === :home\n teams_points[:home] += next_player[:points];\n end\n teams_points; \n }\n winner = final_scores.reduce { |highest_points, team_points| \n highest_points[1] > team_points[1] ? highest_points : team_points; \n }\n game_hash[winner[0]][:team_name]; \nend", "def max_loss_severity\n @peer_group.try(:max_loss).to_f\n end", "def winning_team\n home_points = 0\n away_points = 0\n result = \"\"\n i = 0\n game_hash.each do |team, about|\n about[:players].each do |name , stats|\n if i == 0\n home_points += stats[:points]\n else\n away_points += stats[:points]\n end\n end\n i += 1\n end\n home_points > away_points ? result = game_hash[:home][:team_name] : result = game_hash[:away][:team_name]\nend", "def big_shoe_rebounds\n max_shoe = 0 \n max_rebounds = 0 \n game_hash.each do |place, team|\n # team.each do |attribute, data|\n team[:players].each do |player|\n if player[:shoe] > max_shoe\n max_shoe = player[:shoe]\n max_rebounds = player[:rebounds]\n # if attribute == :players\n # data.each do |player|\n #this gives me the player hashes\n # data.max_by{|player| player[:shoe] }\n # data.max_by{|player| player[:shoe] }[:rebounds]\n # player.max_by{|player| player[:shoe] \n # player.max_by{|player| player[:shoe] }[:rebounds]\n end\n end\n end\n return max_rebounds\n end", "def max(board)\n #Generate moves array\n moves = minmax_moves(board, self)\n #Placeholder for max score, even the worst score is > -2\n max = -2\n #Find terminal and check terminal nodes and delete them from move array. If any of them are 1 instantly return\n moves.delete_if do |index, board|\n if over?(board)\n #If board is terminal get score\n res = minmax_score(board)\n #If terminal is winning instantly return it\n return res if res == 1\n max = res if res > max\n true\n else\n false\n end\n end\n\n #Else get worst scores of new states\n moves.each do |index, board|\n res = min(board)\n return res if res == 1\n max = res if res > max\n end\n max\n end", "def mostSteals\n players.max_by do|name, stats|\n stats[:steals]\n end\nend", "def highest_total_score\n @game_manager.highest_total_score\n end", "def winning_team_with_spread\n\t\tif self.final?\n\t\t\treturn home_team_id if home_team_score > away_team_score + point_spread\n\t\t\treturn away_team_id if away_team_score + point_spread > home_team_score\n\t\t\treturn \"tie\" if home_team_score == away_team_score + point_spread\n\t\telse\n\t\t\treturn nil\n\t\tend\n\tend", "def most_steals(game)\nmax_steals = 0\nmax_steals_player = \"\"\ngame.each do |team, team_contents|\n team_contents[:roster].each do |player, player_contents| \n if player_contents[:steals] == max_steals\n max_steals_player = max_steals_player + \" and #{player_contents[:player_name]}\"\n elsif player_contents[:steals] > max_steals\n max_steals = player_contents[:steals]\n max_steals_player = player_contents[:player_name]\n end\n end\nend\nmax_steals_player\nend", "def biggest_shoe\r\n player_name= []\r\n game_hash.each do |team, data|\r\n data.each do |team_info, value|\r\n if team_info == \"players\".to_sym\r\n obj=value.max_by {|key, value| value[:shoe]}\r\n player_name<< obj.first\r\n end\r\n end\r\n end\r\n player_name.first\r\nend", "def compute_team_winner\n if completed?\n team_winner\n else\n if first_team && second_team\n if sets_won(first_team) == min_sets_to_play\n first_team\n elsif sets_won(second_team) == min_sets_to_play\n second_team\n end\n end\n end\n end", "def winner\n @players.max_by{ |player| player.score}\n end", "def player_with_most_steals\n name = \"\"\n most_steals = 0\n\n game_hash.each do | team, details_hash |\n players_array = details_hash[:players]\n players_array.each do | player_details_hash |\n if player_details_hash[:steals] > most_steals\n most_steals = player_details_hash[:steals]\n name = player_details_hash[:player_name]\n end\n end\n end\n name\nend", "def avg_of_toryo_turn_max\n s = lose_scope\n s = s.joins(:battle)\n s = s.where(Swars::Battle.arel_table[:final_key].eq(\"TORYO\"))\n if v = s.average(Swars::Battle.arel_table[:turn_max])\n v.to_i\n end\n end", "def find_best_score(total_per_player)\n best_score = 0\n winner = ''\n total_per_player.each do |player_name,total|\n\n if total > best_score\n best_score = total\n winner = player_name\n end\n end\n return winner\n end", "def biggestShoes\n players.max_by do|name, stats|\n stats[:shoe]\n end\nend", "def pri_toff\n team_stats.goals_per_game / team_stats.opp_avg_goals_per_game\n end", "def elo_delta(rating_a, score_a, rating_b, score_b,\n k_factor, win_weight, max_score)\n # elo math please never quiz me on this\n expected_a = 1 / (1 + 10**((rating_b - rating_a) / 800.to_f))\n expected_b = 1 / (1 + 10**((rating_a - rating_b) / 800.to_f))\n\n outcome_a = score_a / (score_a + score_b).to_f\n if outcome_a < 0.5\n # a won\n outcome_a **= win_weight\n outcome_b = 1 - outcome_a\n else\n # b won\n outcome_b = (1 - outcome_a)**win_weight\n outcome_a = 1 - outcome_b\n end\n\n # divide elo change to be smaller if it wasn't a full game to 10\n ratio = [score_a, score_b].max / max_score.to_f\n\n # calculate elo change\n delta_a = (k_factor * (outcome_a - expected_a) * ratio).round\n delta_b = (k_factor * (outcome_b - expected_b) * ratio).round\n [delta_a, delta_b]\nend", "def most_points_scored\n max = nil\n name = nil \n game_hash.each do |team, team_values|\n team_values[:players].each do |player|\n if max == nil || player[:points] > max\n max = player[:points]\n name = player[:player_name]\n end\n end\n end\n name\nend", "def player_with_most_steal\n most_steals = nil\n most_steal_player = nil\n\n all_players(game_hash).each do |player|\n if most_steals == nil || player[:steals] > most_steals\n most_steals = player[:steals]\n most_steal_player = player[:player_name]\n end\n end\n\n most_steal_player\nend", "def worst_case board\n\t\tworst = 0\n\t\topp_board = board.rotate 7\n\t\t6.times {|i|\n\t\t\t\ts = score_for(opp_board, i)\n\t\t\t\tworst = s if worst < s\n\t\t\t}\n\t\t\tworst\n\tend", "def player_longest_name(game)\n player_names = []\n game[:home_team][:players].each do |player_hash|\n player_names << player_hash[:player_name]\n end\n game[:away_team][:players].each do |player_hash|\n player_names << player_hash[:player_name]\n end\n longest_name = player_names.max_by { |name| name.length }\nend", "def energy()\n score = 0\n @matches.each do |m|\n # Teams Same School\n if m.team_a.school == m.team_b.school\n score -= @penalties[:teams_same_school]\n end\n # Judges Same School\n m.judges.each do |j|\n if j.school == m.team_a.school\n score -= @penalties[:judge_same_school]\n end\n if j.school == m.team_b.school\n score -= @penalties[:judge_same_school]\n end\n end\n # Different Win/Loss\n if m.team_a.num_wins != m.team_b.num_wins\n score -= (1 + @penalties[:different_win_loss]) **\n (m.team_a.num_wins - m.team_b.num_wins).abs\n score -= 1 # No, really, this makes sense...\n end\n end\n score\n end", "def biggest_investment\n self.funding_rounds.max_by {|funding| funding.investment }\n end", "def biggest_investment\n funding_rounds.max_by {|funding_round| funding_round.investment}\n end", "def winner\n @players.max_by do |player|\n player.score\n end\n end", "def player_with_longest_name\n longest_name = 0\n longest_player_name = nil\n game_hash.each do |team, team_stats|\n team_stats[:players].each do |player_stats|\n if longest_name < player_stats[:player_name].length\n longest_name = player_stats[:player_name].length\n longest_player_name = player_stats[:player_name]\n end\n end\n end\n longest_player_name\nend", "def get_team(game)\n team = 0\n get_participation_by_game game do |participation|\n team = participation.team\n end\n team\n end", "def winning_team\n points_home = 0\n points_away = 0\n result = \"\"\n\n game_hash.each do |side,team|\n team.each do |specs,info|\n if specs == :players\n info.each do |player|\n if side = :home\n points_home += player[:points]\n else\n points_away += player[:points]\n end\n end\n end\n end\n end\n if points_home > points_away\n result = game_hash[:home][:team_name]\n else\n result = game_hash[:away][:team_name]\n end\n result\nend", "def winning_team\n total_points = 0 #initialize points at zero \n \n win_team = '' #set win team to an empty string \n \n game_hash.each do |location, team| #iterating over game hash\n team_points = 0 #initialize team points at zero \n team_name = game_hash[location][:team_name] \n # set team name = to game_hash at the the location at the # :team name \n \n team[:players].each do |player| #iterate over players \n points = player[:points] # set points = player points \n team_points += points #team points is the addition of every single point value from each player\n \n #binding.pry \n end\n \n win_team, total_points = team_name, team_points if team_points > total_points\n \n #binding.pry \n \n end\n \n return win_team\n\nend", "def most_points(game)\n player_name_with_points = []\n game[:home_team][:players].each do |player_hash|\n player_name_with_points << {player_hash[:player_name] => player_hash[:stats][:points]}\n end\n game[:away_team][:players].each do |player_hash|\n player_name_with_points << {player_hash[:player_name] => player_hash[:stats][:points]}\n end\n player_most_points = {\"test\" => 0}\n player_name_with_points.each do |name_and_points_hash|\n player_most_points = name_and_points_hash if name_and_points_hash.values[0] > player_most_points.values[0]\n end\n player_most_points.keys[0]\nend", "def big_shoe_rebounds\n\nhighest_rebounds = 0\nbiggest_shoe = 0\n\n game_hash.each do |location, team_info|\n game_hash.dig(location, :players).each do |player_name, stats|\n stats.each do |stat, number|\n if stat == :shoe\n if number > biggest_shoe\n biggest_shoe = number\n stats.each do |stat, number|\n if stat == :rebounds\n highest_rebounds = number\n end\n end\n end\n end\n end\n end\n end\n puts highest_rebounds\n return highest_rebounds\nend", "def most_steals \n num_steals = 0\n game_hash.each do |team,info|\n info.each do |team_info,team_data|\n if team_data.is_a? (Array) \n if team_info != :colors\n team_data.each do |player_index|\n if num_steals == 0 || player_index[:steals] > num_steals \n num_steals = player_index[:steals] \n end\n end\n end\n end\n end\n end\nnum_steals\nend", "def worst_fans\n teams_with_bad_fans = @teams.find_all { |team| team.home_minus_away_percentage.negative? }\n teams_with_bad_fans.map { |team| team.team_name }\n end", "def biggest_bust(season)\n season = season.to_i\n @teams.min_by{ |team| team.preseason_to_regular_increase[season] }.team_name\n end", "def best_move_for(player)\n return minimax(player)[1]\n end", "def remaining_players\n losses.count { |_, v| v < MAX_LOSS_COUNT}\n end", "def winner(game)\n result = nil\n if game.team1_goals.present? && game.team2_goals.present?\n result = TEAM1_WIN if game.team1_goals > game.team2_goals\n result = TEAM2_WIN if game.team1_goals < game.team2_goals\n result = DRAW if game.team1_goals == game.team2_goals\n end\n\n result\n end", "def big_shoe_rebounds_2\n\nhighest_rebounds = 0\nbiggest_shoe = 0\n\n\n game_hash.dig(:home, :players).each do |player_name, stats|\n stats.each do |stat, number|\n if stat == :shoe\n if number > biggest_shoe\n biggest_shoe = number\n stats.each do |stat, number|\n if stat == :rebounds\n highest_rebounds = number\n\n end\n end\n end\n end\n end\nend\n\n puts highest_rebounds\n return highest_rebounds\nend", "def loss()\n\t return false if (self.score.nil? or self.opponent.score.nil?)\n\t self.score() ? self.score() < self.opponent.score() : false\n\tend", "def long_name_steals_a_ton?\n highest_number_steals = 0\n player_most_steals = nil\n game_hash.each do |team, team_stats|\n team_stats[:players].each do |player_stats|\n if highest_number_steals < player_stats[:steals]\n highest_number_steals = player_stats[:steals]\n player_most_steals = player_stats[:player_name]\n end\n end\n end\n if player_most_steals == player_with_longest_name\n true\n else\n false\n end\nend", "def winning_player\n played_cards.max_by { |_, card| card_scores[card] }.first\n end", "def big_shoe_rebounds\n player_with_the_largest_shoe_size = 0\n most_rebounds = 0\n game_hash.each do |team,info|\n info.each do |team_info,team_data|\n if team_data.is_a? (Array) \n if team_info != :colors\n team_data.each do |player_index|\n if player_with_the_largest_shoe_size == 0 || player_index[:shoe] > player_with_the_largest_shoe_size \n player_with_the_largest_shoe_size = player_index[:shoe]\n most_rebounds = player_index[:rebounds]\n end\n end\n end\n end\n end\n end\n most_rebounds\nend", "def winning_team\n home_points = 0\n away_points = 0\n team1 = \"Brooklyn Nets\"\n team2 = \"Charlotte Hornets\"\n game_hash.each do |team,info|\n info.each do |team_info,team_data|\n if team_data.is_a? (Array) \n if team_info != :colors\n if info[:team_name] == \"Brooklyn Nets\"\n team_data.each do |player_index|\n home_points += player_index[:points]\n end\n else \n team_data.each do |player_index|\n away_points += player_index[:points]\n winning_team end\n end\n end\n end\n end\n end\n\n if home_points > away_points\n team1\n else\n team2\n end\n\nend", "def get_highest_for(turn)\n\t\tif @highs[1][turn] > @highs[2][turn] then 1 else 2 end\n\tend", "def winning_team\n most_points_scored_helper\n winning_team = \"\"\n \n game_hash.each do |key, value|\n players = value[:players]\n players.each do |element|\n if most_points_scored_helper == element[:points]\n winning_team = value[:team_name]\n end\n end\n end\n winning_team\nend", "def max_score\n return score if @state != STATE_OK\n\n next_boards.map(&:min_score).min\n end", "def rebounds_for_player_with_largest_shoe_size(game)\n shoe_sizes_with_player_names = []\n game[:home_team][:players].each do |player_hash|\n shoe_sizes_with_player_names << {player_hash[:player_name] => player_hash[:shoe_size]}\n end\n game[:away_team][:players].each do |player_hash|\n shoe_sizes_with_player_names << {player_hash[:player_name] => player_hash[:shoe_size]}\n end\n biggest_shoe_size = {\"test\" => 0}\n shoe_sizes_with_player_names.each do |shoe_size_and_name_hash|\n biggest_shoe_size = shoe_size_and_name_hash if shoe_size_and_name_hash.values[0] > biggest_shoe_size.values[0]\n end\n game[:home_team][:players].each do |player_hash|\n return player_hash[:stats][:rebounds] if player_hash[:player_name] == biggest_shoe_size.keys[0]\n end\n game[:away_team][:players].each do |player_hash|\n return player_hash[:stats][:rebounds] if player_hash[:player_name] == biggest_shoe_size.keys[0]\n end\nend", "def player_with_most_of(statistic)\n player_name = nil\n amount_of_stat = 0\n\n game_hash.each do |team, game_data|\n game_data[:players].each do |player|\n if player[statistic].is_a? String\n if player[statistic].length > amount_of_stat\n amount_of_stat = player[statistic].length\n player_name = player[:player_name]\n end\n elsif player[statistic] > amount_of_stat\n amount_of_stat = player[statistic]\n player_name = player[:player_name]\n end\n end\n end\n\n player_name\nend", "def outcome\n if self.final\n \th = home_team\n \ta = away_team\n \t# h.wins=0 if h.wins==nil\n \t# h.losses=0 if h.losses==nil\n \t# a.wins=0 if a.wins==nil\n \t# a.losses=0 if a.losses==nil\n \tif home_score == away_score\n \t\treturn 'T'\n \telsif home_score > away_score\n \t\tif !self.recorded\n \t \t\th.wins += 1\n \t \t\ta.losses += 1\n \t \t\th.save\n \t \t\ta.save\n \t \t\tself.recorded=true\n \t \t\tself.save\n \t \tend\n \t\tif overtime\n \t\t\treturn 'h'\n \t\telse\n \t\t\treturn 'H'\n \t\tend\n \telse\n \t\tif !self.recorded\n \t \t\th.losses += 1\n \t \t\ta.wins += 1\n \t \t\ta.save\n \t \t\th.save\n \t \t\tself.recorded=true\n \t \t\tself.save\n \t \tend\n \t\tif overtime\n \t\t\treturn 'a'\n \t\telse\n \t\t\treturn 'A'\n \t\tend\n \tend\n end\n end", "def winning_team(result)\n goals = result.split(\"-\")\n if goals[0] == goals[1]\n \"draw\"\n elsif goals[0].to_i > goals[1].to_i\n \"home\"\n else\n \"away\"\n end\n end", "def most_hits(seasonasstring) # shots in game team stats\n #get a list of all teams that played in that season\n #use above list to sum all shots across all games in season\n #find highest across list\n #return team name as found in 139\n end", "def least_accurate_team(seasonasstring) # shots in game team stats\n #inverse of above\n end", "def maximum_of_two_players\n # TODO implement\n end", "def away_stat\n @away.team_stat\n end", "def long_name_steals_a_ton?\n\t # returns true if the player with the longest name had the most steals\n\tlongest_name_length = 0\n\tlongest_name_name = []\n\tmost_steals = 0\n\tmost_steals_name = []\n\tall_players = []\t\t\t\t# Is all players, home & away. Renamed! \n\tsteals_array = []\n\ttrue_flag = nil\n\n\n\t# OKAY, prints -- calculates max # of steals, currently array w 3 / was one name (winner or tie possible...)\n\tgame_hash.each do |h_or_a, team_infos|\n\t\tteam_infos.collect do |info_type, stats|\n\t\t\tif (info_type == :players)\n\t\t\t\tstats.each do |stat, stat_value|\n\t\t\t\t\tif game_hash[h_or_a][:players][stat][:steals] > most_steals\n\t\t\t\t\t\tmost_steals = game_hash[h_or_a][:players][stat][:steals]\n\t\t\t\t\t\t#most_steals_name = game_hash[h_or_a][:players].keys \t#> [:\"Alan Anderson\", :\"Reggie Evans\", :\"Brook Lopez\", :\"Mason Plumlee\", :\"Jason Terry\"]\n\t\t\t\t\t\tmost_steals_name = stat\n\t\t\t\t\t\tputs(\"one players w Max steals name : #{most_steals_name}\")\n\t\t\t\t\tend\t\t\t\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend\n\n\n\n\n# compare to each player's # / steals to the max steals and put all winner / (winners, if tie) to an array\n# Prev. version: put all players w a winning # steals in an array (to accomodate ties). \n\tgame_hash.each do |h_or_a, team_infos|\n\t\tteam_infos.collect do |info_type, stats|\n\t\t\tif (info_type == :players)\n\t\t\t\t# stats.each do |stat, stat_value|\n\t\t\t\t# \t most_steals = game_hash[h_or_a][:players][stat][:steals].max_by {|stat2, statval2 | stat2.to_s.to_f <=> statval2 }\n\t\t\t\tall_players.each do |name| \t\t\t# ONLY HAS ONE ITEM IN PIPES! | |\n\t\t\t\t\tif game_hash[h_or_a][:players][name][:steals] = most_steals\n\t\t\t\t\t\tsteals_array << name\n\t\t\t\t\t\t#most_steals = game_hash[h_or_a][:players][stat][:steals]\n\t\t\t\t\t\t#most_steals_name = game_hash[h_or_a][:players].keys \t#> [:\"Alan Anderson\", :\"Reggie Evans\", :\"Brook Lopez\", :\"Mason Plumlee\", :\"Jason Terry\"]\n\t\t\t\t\t\t# most_steals_name << stat\n\t\t\t\t\t\tputs(\"Most steals V2** name : #{steals_array}\")\n\t\t\t\t\tend\t\t\t\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend\n\n\n\n\n\n\tgame_hash[:home][:players].each do |k, v|\n\t\t#puts (\"v.flatten is -- #{k.to_s}\")\n\t\tall_players << k.to_s \t\t\t#v.flatten \n\tend\n\tgame_hash[:away][:players].each do |k, v|\n\t\tall_players << k.to_s\n\tend\n\n\tputs (\"all_players is : #{all_players}\")\n\n\n# Attempt to get all max values of steals\n# max = my_hash.values.max\n# Hash[my_hash.select { |k, v| v == max}]\n\n\n# game_hash =\t{\n# \thome: {\n# \t\tteam_name: \"Brooklyn Nets\",\n# \t\tcolors: [\"Black\", \"White\"], \t\t\t#array of strings\n# \t\tplayers: {\n# \t\t\t\"Alan Anderson\": {\n# \t\t\t\tnumber: 0, \n# \t\t\t\tshoe: 16, \n\n\n\tgame_hash.each do |h_or_a, team_infos|\n\t\tteam_infos.collect do |info_type, names|\n\t\t\tif (info_type == :players)\n\t\t\t\t# stats.each do |stat, stat_value|\n\t\t\t\t# \t most_steals = game_hash[h_or_a][:players][stat][:steals].max_by {|stat2, statval2 | stat2.to_s.to_f <=> statval2 }\n\t\t\t\tall_players.each do |name, stats| \n\t\t\t\t\tsteals_array = game_hash[h_or_a][:players][name][:steals].select { |stats, stat_val | stat_val == max }\t#undefined method `[]' for nil:NilClass\n\t\t\t\t\tputs(\"Most steals V3** array names : #{steals_array}\")\n\t\t\t\t\t#end\t\t\t\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend\n\nhome_steals = game_hash[:home][:players][name][:steals].select { |stats, stat_val | stat_val == max }\n\n\n# ERROR - doesn't find away players, returns nil. // Create parallel array just holding each player's max # of steals. \n\n\tall_players.each do |name|\n\t\tputs(\"number of steals is #{game_hash[:home][:players][name.to_sym][:steals]}, name is- #{ name}\")\t\t\n\t\t\tsteals_array << game_hash[:home][:players][name.to_sym][:steals]\n\t\t\n\tend\n\n\n\n\tall_players.each do |name|\n\t\tputs(\"Name.length is #{name.length}, name is- #{name}\")\t\t\n\t\tif name.length > longest_name_length\n\t\t\tlongest_name_length = name.length\n\t\t\tlongest_name_name << name\n\t\tend\n\tend\n\n\n\t#### NEED TO DO SORT BY LENGTH, THEN CALC LENGTH OF EACH, RETURN ALL MAX TIES TO NEW ARRAY\n\tlongest_name_name = all_players.max(1) { |name, b| name.length <=> b.length}\n\tlongest_name_length = longest_name_name.length\n\n\tprint \"Longest Name Length Is : \"\n\tputs longest_name_length\n\n\tprint \"Final Longest Name Is : \"\n\tputs longest_name_name\n\n\tprint \" Most Steals Is : \"\n\tputs most_steals_name\n\n\tlongest_name_name.each do |name|\n\t\tif most_steals_name.include?(name)\n\t\t\ttrue_flag = true\n\n\t\tend\n\tend\n\tputs true_flag\n\treturn true_flag\nend" ]
[ "0.7359655", "0.71997166", "0.7125405", "0.7116956", "0.7082419", "0.69981635", "0.6952013", "0.6930093", "0.6922774", "0.6859059", "0.67804253", "0.6644592", "0.6631284", "0.6584522", "0.65740126", "0.6527247", "0.65219086", "0.65129304", "0.65063685", "0.64938587", "0.6398615", "0.6385412", "0.6374221", "0.6372671", "0.6309929", "0.62805635", "0.62497383", "0.6243248", "0.62276125", "0.6198737", "0.6189535", "0.6167453", "0.6140176", "0.61375517", "0.6103618", "0.6091277", "0.6065241", "0.605238", "0.603789", "0.60318017", "0.60104346", "0.6008012", "0.60025203", "0.597972", "0.597758", "0.59748125", "0.59645224", "0.5962985", "0.59408796", "0.59320986", "0.59175885", "0.58926415", "0.5873651", "0.58681107", "0.58594656", "0.5831289", "0.5828635", "0.58274096", "0.5822241", "0.58136386", "0.58101135", "0.58050615", "0.5795531", "0.5792841", "0.57895464", "0.5785901", "0.5781445", "0.57808226", "0.5780716", "0.5775284", "0.57733804", "0.57424873", "0.5732481", "0.57294303", "0.57256675", "0.57219607", "0.5712292", "0.57055664", "0.5702351", "0.5699608", "0.5693181", "0.5691524", "0.5689626", "0.5688391", "0.5680995", "0.56739724", "0.567203", "0.5666978", "0.5658841", "0.5654018", "0.5650221", "0.5647687", "0.5641682", "0.56404376", "0.5635544", "0.5635041", "0.56325704", "0.56323904", "0.5625541", "0.5625412" ]
0.8180372
0
For each season a team has played, returns a hash that has two keys (:preseason, and :regular_season), that each point to a hash with the following keys: :win_percentage, :total_goals_scored, :total_goals_against, :average_goals_scored, :average_goals_against
def seasonal_summary(team_id) team_id = team_id.to_i seasonal_summary_hash(team_id) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def average_goals_by_season\n goals_by_season = @games.group_by { |game| game.season.to_s }\n goals_by_season.each do |season, games|\n season_goals = games.map { |game| game.home_goals + game.away_goals }.sum\n goals_by_season[season] = (season_goals.to_f / games.count.to_f).round(2)\n end\n end", "def get_standings(games)\n teams = Hash.new\n games.each do |game|\n division_id = game.division_id\n home_team = game.home_team\n away_team = game.visiting_team\n if(teams[home_team.name].nil?)\n teams[home_team.name] = {:win => 0, :loss => 0, :tie => 0, :point=> 0}\n end\n\n if(teams[away_team.name].nil?)\n teams[away_team.name] = {:win => 0, :loss => 0, :tie => 0, :point => 0}\n end\n if(game.home_team_score && game.visiting_team_score)\n if(game.home_team_score > game.visiting_team_score)\n # home team won\n teams[home_team.name][:win] += 1\n teams[home_team.name][:point] += 5\n # visiting team loss\n teams[away_team.name][:loss] += 1\n elsif(game.home_team_score < game.visiting_team_score)\n # home team loss\n teams[home_team.name][:loss] += 1\n #visiting team won\n teams[away_team.name][:win] += 1\n teams[away_team.name][:point] += 5\n else\n # tie game\n teams[home_team.name][:tie] += 1\n teams[home_team.name][:point] += 1\n teams[away_team.name][:tie] += 1\n teams[away_team.name][:point] += 1\n end\n end\n end\n teams.each do |team, value|\n puts team\n total_games = value[:win] + value[:loss] + value[:tie]\n if total_games > 0 \n win_percentage = value[:win]/total_games.to_f\n else\n win_percentage = 0\n end \n value[:percentage] = win_percentage\n end\n teams_sorted = teams.sort_by{ |k, v| v[:point]}.reverse\n return teams_sorted\n end", "def matches_played_by_season(table_of_teams)\n matches_played = Hash.new { |hash, key| hash[key] = Hash.new(0) }\n\n table_of_teams.each do |table_row|\n matches_played[table_row['season']][table_row['team1']] += 1\n matches_played[table_row['season']][table_row['team2']] += 1\n end\n matches_played\nend", "def season_prepare\n ret = {\n :competitions_to_draw => League.all\n }\n \n ret[:competitions_to_draw]\n \n return ret\n end", "def total_games_by_coach_by_season\n @total_games_by_coach = Hash.new{ |hash, key| hash[key] = 0}\n @by_season_game_team_objects.each do |game_by_season|\n @total_games_by_coach[game_by_season[\"head_coach\"]] += 1\n end\n end", "def season_summary(season, team_id)\n season = season.to_i\n team_id = team_id.to_i\n season_summary_hash(season, team_id)\n end", "def per_game_stats(season = nil)\n season_id = season ? season.id : Season.current.id\n StatLine.find_by_sql('SELECT AVG(fgm) as fgm, AVG(fga) as fga, coalesce(AVG(fgm)/nullif(AVG(fga), 0), 0) as fgpct, AVG(twom) as twom, AVG(twoa) as twoa, coalesce(AVG(twom)/nullif(AVG(twoa), 0), 0) as twopct, AVG(threem) as threem, AVG(threea) as threea, coalesce(AVG(threem)/nullif(AVG(threea), 0), 0) as threepct,' \\\n 'AVG(ftm) as ftm, AVG(fta) as fta, coalesce(AVG(ftm)/nullif(AVG(fta), 0), 0) as ftpct, AVG(orb) as orb, AVG(drb) as drb, AVG(trb) as trb, AVG(ast) as ast, AVG(stl) as stl, AVG(blk) as blk, AVG(fl) as fl, AVG(\"to\") as to,' \\\n 'AVG(points) as points, COUNT(*) as game_count, sums.league_id FROM (SELECT SUM(fgm) as fgm, SUM(fga) as fga, SUM(twom) as twom, SUM(twoa) as twoa, SUM(threem) as threem, SUM(threea) as threea,' \\\n 'SUM(ftm) as ftm, SUM(fta) as fta, SUM(orb) as orb, SUM(drb) as drb, SUM(trb) as trb, SUM(ast) as ast, SUM(stl) as stl, SUM(blk) as blk, SUM(fl) as fl, SUM(\"to\") as to,' \\\n \"SUM(points) as points, g.league_id as league_id FROM stat_lines sl INNER JOIN games g ON sl.game_id = g.id \" \\\n \"WHERE g.winner is not null AND (g.forfeit is null or not g.forfeit) AND (sl.dnp is null OR not sl.dnp) AND team_id = #{self.id} AND g.season_id = #{season_id} GROUP BY game_id, g.league_id) sums GROUP BY sums.league_id\")\n end", "def total_wins_by_season_by_team_id(passed_id)\n @by_team_id_game_objects.each do |game|\n if helper_for_win_count(passed_id, game)\n @total_wins_by_season[game[\"season\"]] += 1\n elsif helper_for_loss_count(passed_id, game)\n @total_wins_by_season[game[\"season\"]] += 0\n end\n end\n end", "def count_of_games_by_season\n games_by_season = @games.group_by { |game| game.season.to_s }\n games_by_season.each { |season, games| games_by_season[season] = games.count }\n end", "def generate_games(season)\n unless season.blank?\n player_ids = season.approved_players.map(&:id).uniq\n player_ids.each do |player_id|\n opponent_ids = player_ids - [ player_id ]\n opponent_ids.each do |opponent_id|\n # Runner\n runner_game = {\n league_id: season.league_id,\n season_id: season.id,\n runner_player_id: player_id,\n corp_player_id: opponent_id\n }\n Game.create(runner_game) unless Game.where(runner_game).any?\n\n # Corp\n corp_game = {\n league_id: season.league_id,\n season_id: season.id,\n runner_player_id: opponent_id,\n corp_player_id: player_id\n }\n Game.create(corp_game) unless Game.where(corp_game).any?\n end\n end\n\n season.update_table!\n end\n end", "def retrieve_season_hall_of_fame\n seasons_hall_of_fame = []\n get_involved_teams unless @involved_teams\n\n @involved_teams.each do |team|\n team_placement = {}\n team_placement[:team] = team\n %w[first_place second_place third_place].each_with_index do |rank, index|\n placement = index + 1\n team_placement[rank.to_sym] = team.computed_season_ranking.joins(:season).where(\"seasons.season_type_id = #{@season_type.id} AND computed_season_rankings.rank = #{placement}\").count\n end\n seasons_hall_of_fame << team_placement\n end\n seasons_hall_of_fame.sort { |p, n| (n[:first_place] * 10_000 + n[:second_place] * 100 + n[:third_place]) <=> (p[:first_place] * 10_000 + p[:second_place] * 100 + p[:third_place]) }\n end", "def test_average_goals_by_season\n\n expected = {\n \"20122013\"=>4.12,\n \"20162017\"=>4.23,\n \"20142015\"=>4.14,\n \"20152016\"=>4.16,\n \"20132014\"=>4.19,\n \"20172018\"=>4.44\n }\n assert_equal expected, @stat_tracker.average_goals_by_season\n\n end", "def skater_stats(stats)\n skater_stats = Hash.new\n skater_stats[:seasons] = stats.seasons\nend", "def gross_per_studio(collection)\n result = {}\n i = 0\n while i < collection.size do\n studio = collection[i][:studio]\n total_earnings = collection[i][:worldwide_gross]\n if !result[studio]\n result[studio] = total_earnings\n else\n result[studio] += total_earnings\n end\n i += 1\n end\n \n # GOAL: Given an AoH where each Hash is a movie, return a Hash that includes\n # the total worldwide_gross of all the movies from each studio.\n #\n # INPUT: (collection) AoH where each Hash represents a movie\n #\n # RETURN: Hash where the keys are the studios and the values are the sum of\n # all the worldwide_gross numbers for every movie in the input Hash\n \n result\nend", "def generate_games(divisions, fields, seasons)\n seasons.each do |season|\n divisions.each do |division|\n teamsD = TeamDivision.where(:division_id => division.id)\n season_start = season.start_date\n game_start = season_start\n generate_schedule(teamsD, fields, season, division.id)\n end\n end\n end", "def test_count_of_games_by_season\n\n expected = {\n \"20122013\"=>806,\n \"20162017\"=>1317,\n \"20142015\"=>1319,\n \"20152016\"=>1321,\n \"20132014\"=>1323,\n \"20172018\"=>1355\n }\n assert_equal expected, @stat_tracker.count_of_games_by_season\n\n end", "def buildTeamToStandingsMap(year)\n teamToStandingsMap = {}\n\n MlbStanding.where(year: year).each do |mlbStanding|\n teamToStandingsMap[mlbStanding.mlb_team_id] = mlbStanding\n end\n return teamToStandingsMap\n end", "def get_all_seasons_by_status\n dateNow = DateTime.now.end_of_day\n all_seasons = Hash.new\n all_seasons[:upcoming] = Array.new\n all_seasons[:current] = Array.new\n all_seasons[:past] = Array.new\n seasons = Season.all\n\n seasons.each do |season|\n if (season.is_active) # current or upcoming season\n # going to assume if today is part the season end date that the league owner intentionally wanted the season to be current\n if (season.date_start <= dateNow)\n all_seasons[:current].push(season)\n else\n all_seasons[:upcoming].push(season)\n end\n else # past season\n all_seasons[:past].push(season)\n end\n end\n all_seasons\n end", "def addTeams( hash )\n\n CSV.foreach( TEAM_CSV, headers: true ) do | row |\n\n # Assign to Variables\n season = row[ 0 ].strip.to_i\n division = row[ 1 ].strip.to_i\n team = row[ 2 ].strip\n\n seasonDivisions = initiateSeasonDivision( hash, season, division )\n seasonDivisions[ team ] = { p: 0, w: 0, d: 0, l: 0, f: 0, a: 0, gd: 0, pts: 0 } unless seasonDivisions.keys.include?( team )\n\n end\n\n end", "def gross_per_studio(collection)\n new_hash = {}\n counter = 0 \n while counter < collection.length do \n studio_name = collection[counter][:studio]\n ww_gross = collection[counter][:worldwide_gross]\n if !new_hash[studio_name]\n new_hash[studio_name] = ww_gross\n else \n new_hash[studio_name] += ww_gross\n end \n counter += 1 \nend\nreturn new_hash\nend", "def get_games(year, input)\r\n page = 1\r\n query = 'https://www.balldontlie.io/api/v1/games' + '?seasons[]=' + year.to_s + '&team_ids[]=' + input.to_s + '&page=' + page.to_s\r\n response_meta = HTTParty.get(query)[\"meta\"]\r\n response_data = HTTParty.get(query)[\"data\"]\r\n total_pages = response_meta[\"total_pages\"]\r\n games_hash = {}\r\n\r\n while page <= total_pages\r\n\r\n #Go back and maximize the per_page limit to minimize the number of calls\r\n query = 'https://www.balldontlie.io/api/v1/games' + '?seasons[]=' + year.to_s + '&team_ids[]=' + input.to_s + '&page=' + page.to_s + '&per_page=50'\r\n HTTParty.get(query)[\"data\"].each do |i|\r\n\r\n\r\n #change formatting of date\r\n date = i[\"date\"].split(\"-\")\r\n day_value = date[2].split(/T/).shift\r\n key_date = \"#{date[0]}/#{date[1]}/#{day_value}\"\r\n formatted_date = \"#{date[1]}/#{day_value}/#{date[0]}\"\r\n\r\n \r\n\r\n games_hash[key_date] = {\r\n \"date\" => formatted_date,\r\n \"home_team\" => i[\"home_team\"][\"full_name\"],\r\n \"visitor_team\" => i[\"visitor_team\"][\"full_name\"],\r\n \"home_team_score\" => i[\"home_team_score\"],\r\n \"visitor_team_score\" => i[\"visitor_team_score\"]\r\n }\r\n \r\n\r\n end\r\n page += 1 \r\n end\r\n games_hash\r\n end", "def current_season\n season = nil\n\n { \n winter: [ 12, 1, 2 ], \n spring: [ 3, 4, 5 ], \n summer: [ 6, 7, 8 ],\n fall: [ 9, 10, 11 ]\n \n }.each do |key, range|\n if range.include? current_month\n season = key\n break\n end\n end\n\n season\n end", "def regular_season_rankings(season = nil)\n stats_request(\"regularSeasonStatRankings\", season).first\n end", "def get_average_age_for_season(data, season)\n age_total = 0\n num_of_contestants = 0\n data[season].each do |contestant_hash|\n age_total += (contestant_hash[\"age\"]).to_i\n num_of_contestants += 1\n end\n (age_total / num_of_contestants.to_f).round(0)\nend", "def least_accurate_team(seasonasstring) # shots in game team stats\n #inverse of above\n end", "def points_season(round, season = nil)\n count = 0\n matchs = find_matchs(round, season)\n\n matchs.each do |match|\n if match.is_winner?(self) and match.finished?\n count += MatchGeneral::PT_WIN\n end\n if match.deal? and match.finished?\n count += MatchGeneral::PT_DEAL\n end\n end\n\n count\n end", "def its_a_tie game\n game.each do |team|\n team_standings = get_team_by_name(team)\n team_standings[:winnings] += 1\n end\nend", "def initiateSeasonDivision( hash, season, division )\n\n hash[ season ] = {} unless hash.keys.include?( season )\n hash[ season ][ division ] = {} unless hash[ season ].keys.include?( division )\n\n return hash[ season ][ division ]\n\n end", "def total_runs_by_teams(table_of_teams)\n hash_of_teams = Hash.new(0)\n table_of_teams.each do |table_row|\n hash_of_teams[table_row['batting_team']] += table_row['total_runs'].to_i\n end\n hash_of_teams['Rising Pune Supergiants'] += hash_of_teams['Rising Pune Supergiant']\n hash_of_teams.delete('Rising Pune Supergiant')\n hash_of_teams\nend", "def power_play_goal_percentage(seasonasstring) # power_play info in game team stat\n #find list of all games in season given by arg\n #sum all power play goals\n #sum all power play oppertunities\n #divide line 146 and line 147\n #return total of above\n end", "def scrape_season\n doc = Nokogiri::HTML(open(url))\n \n seasonality_url = doc.search(\"#survival-guide ul li:nth-child(2) a\").attr(\"href\").text #get country weather url\n weather_pg = Nokogiri::HTML(open(seasonality_url))\n \n #get high, low, and best time to visit information\n @high_season = weather_pg.search(\"div.card--page__content p:nth-child(1)\").text\n @low_season = weather_pg.search(\"div.card--page__content p:nth-child(5)\").first.text\n\n shoulder_season = weather_pg.search(\"div.card--page__content p:nth-child(3)\").first.text\n @best_visit_season = \"Best time to visit \" + shoulder_season[16..-1]\n end", "def getGamesPlayedArray()\n standings = JSON.parse((RestClient.get \"https://statsapi.web.nhl.com/api/v1/standings\"))[\"records\"]#[0][\"teamRecords\"][0]\n for division in standings\n divisionRecords = division[\"teamRecords\"]\n for team in divisionRecords\n teamName = team[\"team\"][\"name\"]\n if teamName.include? \"Canadiens\"\n teamName = \"Montreal Canadiens\"\n end\n @games_played[teamName] = team[\"gamesPlayed\"]\n end\n end\n @games_played[\"N/A\"] = 82\nend", "def get_team_season_stats_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: StatsApi.get_team_season_stats ...'\n end\n # resource path\n local_var_path = '/stats/season'\n\n # query parameters\n query_params = {}\n query_params[:'year'] = opts[:'year'] if !opts[:'year'].nil?\n query_params[:'team'] = opts[:'team'] if !opts[:'team'].nil?\n query_params[:'conference'] = opts[:'conference'] if !opts[:'conference'].nil?\n query_params[:'startWeek'] = opts[:'start_week'] if !opts[:'start_week'].nil?\n query_params[:'endWeek'] = opts[:'end_week'] if !opts[:'end_week'].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 = []\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<TeamSeasonStat>')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: StatsApi#get_team_season_stats\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def buildTeamToWinMap(year)\n teamToWinMap = {}\n MlbWin.where(year: year).each do |win|\n teamToWinMap[win.mlb_team_id] = win\n end\n return teamToWinMap\n end", "def calculate!\n ov = self[:overall]\n ov[:high_night] = {}\n ov[:winners] = {}\n\n self.each do |player_id, st|\n next if player_id == :overall\n\n ## calculate computed stats for player\n st[:nights] += st[:dates].keys.length # if st[:nights] == 0\n st[:high_night] = st[:dates].values.max\n st[:gold_stars] = 1 if st[:nights] == 29\n st[:warps_per_game] = 1.0 * st[:warps] / st[:games] rescue 0\n st[:warps_per_night] = 1.0 * st[:warps] / st[:nights] rescue 0\n st[:games_per_night] = 1.0 * st[:games] / st[:nights] rescue 0\n st[:wins_per_night] = 1.0 * st[:wins] / st[:nights] rescue 0\n st[:wins_per_game] = 1.0 * st[:wins] / st[:games] rescue 0\n\n ## accumulate overall stats\n [:warps, :wins, :cfbs,\n :mystery_factors, :gold_stars]. each do |field|\n ov[field] += st[field]\n end\n [:wimps, :come_ons].each do |field|\n if st[field]\n ov[field] ||= 0\n ov[field] += st[field]\n end\n end\n # nights won calculation\n st[:dates].each do |date,warps|\n ov[:dates][date] += warps\n hnd = ov[:high_night][date] ||= {:players => [], :warps => 0}\n if hnd[:warps] < warps\n hnd[:players] = [player_id]\n hnd[:warps] = warps\n elsif hnd[:warps] == warps\n hnd[:players].push(player_id)\n end\n end\n end\n\n ## update overall computed stats\n st = self[:overall]\n ov[:games] = ov[:wins]\n ov[:nights] = ov[:dates].keys.length\n ov[:nights] = 29 if ov[:nights] == 0 ## provide sane default\n ov[:nights] = ov[:nights_real] if ov[:nights_real]\n ov[:warps_per_game] = 1.0 * ov[:warps] / ov[:games] rescue 0\n ov[:warps_per_night] = 1.0 * ov[:warps] / ov[:nights] rescue 0\n ov[:games_per_night] = 1.0 * ov[:games] / ov[:nights] rescue 0\n ov[:high_night].each do |date,h|\n h[:players].each {|p| self[p][:nights_won] += 1}\n end\n\n ## determine per-stat winners\n # fuck everyone but the top 50 OR those with 50+ warps\n # the 51 below is not a bug\n sorted_players = self.keys.sort{|a,b| self[b][:warps] <=> self[a][:warps]}\n fifty_plus = self.keys.select{|p| self[p][:warps] >= 50}\n eligible = (sorted_players[0..51] | fifty_plus).\n inject(Hash.new(false)) {|acc,p| acc.merge(p => true)}\n [:warps, :games, :nights, :wins, :nights_won, :cfbs,\n :come_ons, :wimps, :warps_per_game, :warps_per_night,\n :games_per_night, :wins_per_game, :high_night].each do |field|\n owf = ov[:winners][field] = {:players => [], :value => 0}\n self.each do |player, st|\n next if player == :overall\n next unless eligible[player]\n if st[field].to_f > owf[:value]\n owf[:players] = [player]\n owf[:value] = st[field]\n elsif st[field] == owf[:value]\n owf[:players].push(player)\n end\n end\n end\n\n ## mark per-stat winners\n ov[:winners].each do |field, win|\n win[:players].each do |player|\n self[player][:winner][field] = true\n end\n end\n\n self\n end", "def season\n @season ||= Season.find(@importer_hash.meeting.season_id)\n end", "def call stat\n data = Hash.new { |h, k| h[k] = {} }\n @matches.each do |m|\n teams = [m.home_team, m.away_team]\n scaffs = StatScaffold.call(teams)\n scaffs[m.home_id], scaffs[m.away_id] = StatParser.call(m, scaffs[m.home_id], scaffs[m.away_id])\n data[m.home_team.name][m.round] = scaffs[m.home_id][stat]\n data[m.away_team.name][m.round] = scaffs[m.away_id][stat]\n end\n data.map {|team| {:name => team[0], :data => team[1]}}\n end", "def update_score\n games = Hash.new([])\n predictions.each do |prediction|\n key = prediction.match_id\n games[key] = {}\n games[key][:teams] = []\n games[key][:round] = prediction.round_id\n unless prediction.winner.nil?\n games[key][:teams] << prediction.winner.id\n end\n end\n Game.includes(:team1, :team2).find_each do |game|\n key = game.match_id\n unless game.winner.nil?\n games[key][:teams] << game.winner.id\n end\n end\n\n puts games.inspect\n\n score = 0\n games.each do |key, data|\n round = games[key][:round]\n winners = games[key][:teams]\n if winners.length == 2 and winners.first == winners.last\n score += (2 ** (round))\n end\n end\n self.update_attributes :score => score\n end", "def all_leagues_hash(season=\"2018\")\n leagues = {}\n response = parse_api_request(\"#{BASE_URL}leagues/season/#{season}\")[\"leagues\"].values\n response.each do |league_data|\n leagues[league_data[\"league_id\"]] = \"#{league_data[\"country\"]} - #{league_data[\"name\"]}\"\n end\n leagues\nend", "def index\n @team_years = TeamYear.all\n\n #\n ## Get TeamYears grouped by year\n #\n @year_groups = {}\n\n # get unique team_years\n @yrs = @team_years.map{|ty| ty.year }.uniq!\n # for each unique season\n @yrs.each{|yr|\n # create the array we'll feed the final hash\n @year_bucket = []\n # for each team_season in each year\n @team_years.where( year: yr).each{|row|\n @year_bucket << row.attributes\n }\n @year_groups[yr.to_sym] = @year_bucket#.sort_by{|hsh| -hsh[:year] }\n }\n\n\n end", "def winning_team\n home_team_sum = 0\n away_team_sum = 0\n game_hash.each do |team, team_stats|\n if team_stats[:team_name] == \"Brooklyn Nets\"\n team_stats[:players].each do |player_stats|\n home_team_sum += player_stats[:points]\n end\n elsif team_stats[:team_name] == \"Charlotte Hornets\"\n team_stats[:players].each do |player_stats|\n away_team_sum += player_stats[:points]\n end\n end\n end\n if home_team_sum > away_team_sum\n game_hash[:home][:team_name]\n elsif home_team_sum < away_team_sum\n game_hash[:away][:team_name]\n end\nend", "def getMidSeasonStatistics()\n for player in @skater_data\n begin\n stats = JSON.parse((RestClient.get \"https://statsapi.web.nhl.com/api/v1/people/#{player[5]}/stats?stats=statsSingleSeason\"))[\"stats\"][0][\"splits\"][0][\"stat\"]\n gamesLeft = 82 - @games_played[player[player.length-1]]\n player[6] = ((player[6].to_f/82)*gamesLeft + stats[\"goals\"]).to_i\n player[7] = ((player[7].to_f/82)*gamesLeft + stats[\"assists\"]).to_i\n player[8] = ((player[8].to_f/82)*gamesLeft + stats[\"powerPlayPoints\"]).to_i\n player[9] = ((player[9].to_f/82)*gamesLeft + stats[\"plusMinus\"]).to_i\n player[10] = ((player[10].to_f/82)*gamesLeft + stats[\"shots\"]).to_i\n player[11] = ((player[11].to_f/82)*gamesLeft + stats[\"hits\"]).to_i\n rescue\n gamesLeft = 82 - @games_played[player[player.length-1]]\n player[6] = ((player[6].to_f/82)*gamesLeft).to_i\n player[7] = ((player[7].to_f/82)*gamesLeft).to_i\n player[8] = ((player[8].to_f/82)*gamesLeft).to_i\n player[9] = ((player[9].to_f/82)*gamesLeft).to_i\n player[10] = ((player[10].to_f/82)*gamesLeft).to_i\n player[11] = ((player[11].to_f/82)*gamesLeft).to_i\n end\n puts player\n end\n for goalie in @goalie_data\n begin\n stats = JSON.parse((RestClient.get \"https://statsapi.web.nhl.com/api/v1/people/#{goalie[5]}/stats?stats=statsSingleSeason\"))[\"stats\"][0][\"splits\"][0][\"stat\"]\n gamesLeft = 82 - @games_played[goalie[goalie.length-1]]\n goalie[6] = ((goalie[6].to_f/82)*gamesLeft + stats[\"gamesStarted\"]).to_i\n goalie[7] = ((goalie[7].to_f/82)*gamesLeft + stats[\"wins\"]).to_i\n goalie[9] = (((goalie[9].to_f)*gamesLeft + stats[\"savePercentage\"]*@games_played[goalie[13]])/82).round(4)\n goalie[11] = (((goalie[11].to_f)*gamesLeft + stats[\"goalAgainstAverage\"]*@games_played[goalie[13]])/82).round(4)\n goalie[12] = ((goalie[12].to_f/82)*gamesLeft + stats[\"shutouts\"]).to_i\n rescue\n gamesLeft = 82 - @games_played[goalie[goalie.length-1]]\n goalie[6] = ((goalie[6].to_f/82)*gamesLeft).to_i\n goalie[7] = ((goalie[7].to_f/82)*gamesLeft).to_i\n goalie[9] = ((goalie[9].to_f/82)*gamesLeft).to_i\n goalie[11] = ((goalie[11].to_f/82)*gamesLeft).to_i\n goalie[12] = ((goalie[12].to_f/82)*gamesLeft).to_i\n end\n puts goalie\n end\nend", "def win_matchs_season(round, season = nil)\n count = 0\n matchs = find_matchs(round, season)\n\n matchs.each do |match|\n if match.is_winner?(self) and match.finished?\n count += 1\n end\n end\n count\n end", "def get_average_age_for_season(data, season)\n data.each do |season_iteration, stats|\n if season_iteration == season\n total_ages = 0\n ages = stats.each do |age|\n total_ages = (total_ages + age[\"age\"].to_i).to_f\n end\n return (total_ages/ages.length).round\n end\n end\nend", "def seasons(season = nil)\n @server.make_json_request('show.seasons', tvdbid: @tvdbid, season: season)['data']\n end", "def determine_winner game\n winner = game.max_by {|team| team[:score]}\n team_standings = get_team_by_name(winner)\n team_standings[:winnings] += 3\nend", "def goals_against_season(round, season = nil)\n count = 0\n matchs = find_matchs(round, season)\n\n matchs.each do |match|\n count += match.goals_against(self) if match.finished?\n end\n\n count\n end", "def buildMlbTeamNameToStandingMap(year)\n teamNameToStandingMap = {}\n MlbStanding.includes(:mlb_team).where(year: year).each do |mlb_standing|\n teamNameToStandingMap[mlb_standing.mlb_team.name] = mlb_standing\n end\n return teamNameToStandingMap\n end", "def get_average_age_for_season(data, season)\n age = 0\n num_of_ages = 0\n \n data[season].each do |season_hash|\n season_hash.each do |detail, info|\n if detail == \"age\"\n num_of_ages += 1 \n age += info.to_f\n end\n end\n end\n return (age/num_of_ages).round\nend", "def flu_season\n event_display(\"It's flu season!\\n One player has been infected and needs some time to recuperate.\")\n {Game.last.players.sample.id.to_s =>\n {wellbeing: -100}\n }\n end", "def get_average_age_for_season(data, season)\n age = 0\n count = 0\n data[season].each do |contestant_data|\n age += (contestant_data[\"age\"]).to_f\n count += 1\n end\n (age / count).round\nend", "def goals_by_game_situation(season = nil)\n stats_request(\"goalsByGameSituation\", season).first\n end", "def create\n sport_id = user_session.get(:filter_sport_id) # okay that's how mistakes happen.... TODO!!!\n sport = Sport.find(sport_id)\n team_points = Hash.new(0)\n team_games = Hash.new(0)\n team_goals_for = Hash.new(0)\n team_goals_against = Hash.new(0)\n\n sport.leagues.each do |league|\n league.games.each do |game| #iterate through EVERY game in EVERY league, calculate points, set it in team table\n if game.tie == false and not game.winner_id.nil? # no tie and winner exists\n team_points[game.winner_id] += 2\n team_games[game.team_1_id] += 1\n team_games[game.team_2_id] += 1\n elsif game.tie == true\n team_points[game.team_1_id] += 1\n team_points[game.team_2_id] += 1\n team_games[game.team_1_id] += 1\n team_games[game.team_2_id] += 1\n end # else, game has not been played yet\n\n # go through all the sets and calculate goal difference\n game.gamesets.each do |set|\n team_goals_for[game.team_1_id] += set.points_team_1.to_i\n team_goals_for[game.team_2_id] += set.points_team_2.to_i\n team_goals_against[game.team_1_id] += set.points_team_2.to_i\n team_goals_against[game.team_2_id] += set.points_team_1.to_i\n end\n\n end\n\n league.teams.each do |team|\n team.points = team_points[team.id] #|| 0 should work without this\n team.game_count = team_games[team.id]\n team.goals_for = team_goals_for[team.id]\n team.goals_against = team_goals_against[team.id]\n team.goals_difference = team_goals_for[team.id] - team_goals_against[team.id]\n team.save\n end\n end\n redirect_to rankings_path, success: t(:object_created)\n end", "def compute_avg_and_ranges_hash\n scores = {}\n contributors = self.contributors # assignment_teams\n if self.varying_rubrics_by_round?\n rounds = self.rounds_of_reviews\n for round in 1..rounds\n review_questionnaire_id = review_questionnaire_id(round)\n questions = Question.where(['questionnaire_id = ?', review_questionnaire_id])\n contributors.each do |contributor|\n assessments = ReviewResponseMap.get_assessments_for(contributor)\n assessments = assessments.reject {|assessment| assessment.round != round }\n scores[contributor.id] = {} if round == 1\n scores[contributor.id][round] = {}\n scores[contributor.id][round] = Answer.compute_scores(assessments, questions)\n end\n end\n else\n review_questionnaire_id = review_questionnaire_id()\n questions = Question.where(['questionnaire_id = ?', review_questionnaire_id])\n contributors.each do |contributor|\n assessments = ReviewResponseMap.get_assessments_for(contributor)\n scores[contributor.id] = {}\n scores[contributor.id] = Answer.compute_scores(assessments, questions)\n end\n end\n scores\n end", "def get_average_age_for_season(data, season)\n array_of_ages = []\n average = 0\n data.each do |season_in_hash, contestant_array|\n if season_in_hash.to_s == season\n contestant_array.each do |contestant|\n array_of_ages << contestant[\"age\"].to_f\n end \n average = (array_of_ages.inject{ |sum, num| sum + num }.to_f / array_of_ages.size).round\n end\n end\n average\nend", "def winning_team\n final_scores = player_collection.reduce(home: 0, away: 0) { |teams_points, next_player|\n case \n when next_player[:location] === :away\n teams_points[:away] += next_player[:points];\n when next_player[:location] === :home\n teams_points[:home] += next_player[:points];\n end\n teams_points; \n }\n winner = final_scores.reduce { |highest_points, team_points| \n highest_points[1] > team_points[1] ? highest_points : team_points; \n }\n game_hash[winner[0]][:team_name]; \nend", "def by_season_team_parser\n by_season_team_data = []\n target_dir = by_season_team_dir\n Dir.foreach(target_dir) do |file|\n next if file == '.' or file == '..'\n json_file = File.open(target_dir + file)\n parsed_file = JSON.parse(File.read(json_file))\n player_values = parsed_file[\"api\"][\"players\"]\n\n player_values.each do |value|\n # Add team_id to parsed value\n value[:team_id] = file.split(\"_\")[0].to_i\n # Add season to parsed value\n value[:season] = file.split(\"_\")[1].to_i\n # Add coaches to parsed value\n value[:coaches] = parsed_file[\"api\"][\"coachs\"] # sic (as spelled in API)\n by_season_team_data.push(value.deep_symbolize_keys!)\n end\n end\n\n by_season_team_data\n end", "def to_seasons(seasons)\n if seasons\n seasons.collect do |season|\n season = season.values[0]\n Season.new(\n Date.strptime(season['start'], '%m-%d'),\n Date.strptime(season['end'], '%m-%d'),\n season['rate'][1..-1].to_f\n )\n end\n end\n end", "def played_matchs_season(round, season = nil)\n count = 0\n matchs = find_matchs(round, season)\n\n matchs.each do |match|\n if match.finished?\n count += 1\n end\n end\n count\n end", "def results_hash\r\n if self.home_score > self.away_score\r\n {winner: self.home_team,loser: self.away_team}\r\n else \r\n {winner: self.away_team,loser: self.home_team}\r\n end\r\n end", "def matchup_count(season = 2015)\n r = Record.find_by(team_id: self.id, year: season)\n r.wins + r.losses + r.ties\n end", "def calculate_results\n players = {}\n @rounds.each do |round|\n round[:results].each do |player, result|\n if not players.has_key?(player)\n players[player] = 0\n end\n if result[:result] == \"Win\"\n players[player] += 1\n end\n end\n end\n winner = players.max_by { |k, v| v }\n players.each do |player, wins|\n @match[player] = {\n \"result\": (player == winner[0]) ? \"Win\" : \"Loss\",\n \"score\": wins,\n }\n if @duplicate_players\n @match[player][:result] = \"Tie\"\n end\n end\n end", "def teams_in_game(a_game)\n teams_in_game = {}\n a_game.game_teams.each do |game_team|\n team_in_game = @teams[game_team.name.to_sym]\n teams_in_game[game_team.name.to_sym] = team_in_game\n end\n teams_in_game\n end", "def players\n all_players = {}\n game_hash.each do |home_or_away, team_stats|\n all_players.merge!(team_stats[:players])\n end\n all_players\nend", "def goals_favor_season(round, season = nil)\n count = 0\n matchs = find_matchs(round, season)\n\n matchs.each do |match|\n count += match.goals_favor(self) if match.finished?\n end\n\n count\n end", "def best_season(id)\n wins = total_wins_per_team_per_season(id)\n totals = total_games_per_team_per_season(id)\n totals.each do |season, total|\n totals[season] = (wins[season] / total.to_f * 100).round(2)\n end\n totals.max_by {|k,v| v}[0]\n end", "def get_team_season_stats(opts = {})\n data, _status_code, _headers = get_team_season_stats_with_http_info(opts)\n data\n end", "def calculate_results\n players = {}\n @rounds.each do |round|\n round[:results].each do |player,result|\n if not players.has_key?(player)\n players[player] = 0\n end\n if result[:result] == \"Win\"\n players[player] += 1\n end\n end\n end\n winner = players.max_by{|k,v| v}\n players.each do |player, wins|\n @match[player] = {\n \"result\": (player == winner[0]) ? \"Win\" : \"Loss\",\n \"score\": wins\n }\n\t if @duplicate_players then\n\t\t@match[player][:result]= \"Tie\"\n\t end\n\t \n end\n end", "def get_rankings\n #create tmp hash storage for all the rows in the rankings table\n row_holder = Hash.new { |hash, key| hash[key] =\n {'played' => 0, '3_points' => 0, '2_points' => 0, '1_point' => 0,\n '0_points' => 0, 'won_sets' => 0, 'lost_sets' => 0, 'points' => 0,\n 'name' => key}}\n\n @games.each do |g|\n if g.has_been_played?\n #add played game for both teams\n row_holder[g.home_team]['played'] += 1\n row_holder[g.away_team]['played'] += 1\n\n #add won sets for each team\n row_holder[g.home_team]['won_sets'] += g.home_sets\n row_holder[g.away_team]['won_sets'] += g.away_sets\n\n #add lost sets for each team\n row_holder[g.home_team]['lost_sets'] += g.away_sets\n row_holder[g.away_team]['lost_sets'] += g.home_sets\n\n #handle all different game outcomes, prepare for ugly code\n #handle 3-0 and 3-1\n if (g.home_sets == 3) && (g.away_sets < 2)\n row_holder[g.home_team]['points'] += 3\n row_holder[g.home_team]['3_points'] += 1\n row_holder[g.away_team]['0_points'] += 1\n\n #handle 3-2\n elsif (g.home_sets == 3) && (g.away_sets == 2)\n row_holder[g.home_team]['points'] += 2\n row_holder[g.away_team]['points'] += 1\n row_holder[g.home_team]['2_points'] += 1\n row_holder[g.away_team]['1_point'] += 1\n\n #handle 2-3\n elsif (g.home_sets == 2) && (g.away_sets ==3)\n row_holder[g.away_team]['points'] += 2\n row_holder[g.home_team]['points'] += 1\n row_holder[g.home_team]['1_point'] += 1\n row_holder[g.away_team]['2_points'] += 1\n\n #handle 0-3 and 1-3\n elsif (g.home_sets < 2) && (g.away_sets == 3)\n row_holder[g.away_team]['points'] += 3\n row_holder[g.home_team]['0_points'] += 1\n row_holder[g.away_team]['3_points'] += 1\n end\n\n # make sure hash is generated when no games have been played yet\n else\n row_holder[g.home_team]['played'] += 0\n row_holder[g.away_team]['played'] += 0\n end\n end\n\n\n\n #convert the row_holder hash to a sorted array\n sort_ranking(row_holder)\n end", "def get_contest_standings\n\t\tcontest_standing_records = ContestProgress.where(contest_id: self.id)\n\t\tcontest_standings_unique = Hash.new\n\t\tcontest_standing_records.each do |record|\n\t\t\twrong_answers = ContestProgress.where(contest_id: self.id,\n\t\t\t\tstudent_id: record.student.id,\n\t\t\t\tstatus: false).count\n\t\t\ttime_spent = 0\n\t\t\tContestProgress.where(contest_id: self.id,\n\t\t\t\tstudent_id: record.student.id).each do |progress|\n\t\t\t\tupdated_at = ContestProgress.where(contest_id: self.id, cproblem_id:\n\t\t\t\t\tprogress.cproblem_id, student_id: record.student.id).take.updated_at\n\t\t\t\tstart_time = Contest.find(self.id).start_time\n\t\t\t\ttime_spent = time_spent + ((updated_at - start_time)/60).to_i\n\t\t\tend\n\t\t\tcontest_standings_unique[record.student_id] = {wrong_answers: wrong_answers,\n\t\t\t\trecord: record, time_spent: time_spent}\n\t\tend\n\t\treturn Hash[contest_standings_unique.sort_by {|key, value| [value[:wrong_answers],\n\t\t\tvalue[:time_spent]]}.to_a]\n\tend", "def coach_win_percent_in_season(coach, game_ids)\n (total_wins_of_coach_in_season(coach, game_ids) / total_coach_games_in_season(coach, game_ids).to_f).round(2)\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 worst_season(team_id)\n team_id = team_id.to_i\n team = @teams.select { |each_team| each_team.team_id == team_id }.first\n team.season_win_percentages.min_by { |season, percentage| percentage }.first.to_s\n end", "def load_stats\n[\n {\n home_team: \"Jets\",\n away_team: \"Giants\",\n home_score: 21,\n away_score: 3\n },\n {\n home_team: \"Steelers\",\n away_team: \"Giants\",\n home_score: 21,\n away_score: 3\n },\n {\n home_team: \"Patriots\",\n away_team: \"Giants\",\n home_score: 21,\n away_score: 3\n },\n {\n home_team: \"Chargers\",\n away_team: \"Jets\",\n home_score: 13,\n away_score: 6\n },\n {\n home_team: \"Patriots\",\n away_team: \"Jets\",\n home_score: 13,\n away_score: 6\n },\n {\n home_team: \"Steelers\",\n away_team: \"Jets\",\n home_score: 3,\n away_score: 6\n },\n {\n home_team: \"Dolphins\",\n away_team: \"Jets\",\n home_score: 0,\n away_score: 3\n },\n{\n home_team: \"Browns\",\n away_team: \"Jets\",\n home_score: 0,\n away_score: 21\n },\n {\n home_team: \"Chargers\",\n away_team: \"Jets\",\n home_score: 7,\n away_score: 21\n },\n {\n home_team: \"Steelers\",\n away_team: \"Broncos\",\n home_score: 7,\n away_score: 13\n },\n {\n home_team: \"Patriots\",\n away_team: \"Broncos\",\n home_score: 7,\n away_score: 3\n },\n {\n home_team: \"Broncos\",\n away_team: \"Colts\",\n home_score: 3,\n away_score: 0\n },\n {\n home_team: \"Patriots\",\n away_team: \"Colts\",\n home_score: 11,\n away_score: 7\n },\n {\n home_team: \"Steelers\",\n away_team: \"Patriots\",\n home_score: 7,\n away_score: 21\n },\n {\n home_team: \"Steelers\",\n away_team: \"Colts\",\n home_score: 24,\n away_score: 21\n },\n {\n home_team: \"Steelers\",\n away_team: \"Colts\",\n home_score: 24,\n away_score: 21\n }\n]\nend", "def all\n @week = Season.find(params[:season_id]).weeks.where(slug: params[:week_slug])[0] if params[:week_slug]\n if params[:league_id]\n if _is_commish_of?(@league)\n @teams = @league.teams.includes(:league, :coaches)\n else\n @teams = @league.teams.active.includes(:league, :coaches)\n end\n else\n @week ||= @season.current_week # if no week we need current week for 'My Teams'\n @teams = current_user.teams.joins(:league).where('season_id = ?', params[:season_id]).includes(league: [ :start_week, :season ]).includes(:coaches)\n end\n @teams = @teams.map { |team| TeamDecorator.decorate(team, @user, @week) }\n respond_with @teams # rendered via app/views/api/teams/all.json.rabl\n end", "def studios_totals(nds)\n a_o_a_movies_with_director_names = movies_with_directors_set(nds)\n movies_with_director_names = flatten_a_o_a(a_o_a_movies_with_director_names)\n return gross_per_studio(movies_with_director_names)\nend", "def studios_totals(nds)\n a_o_a_movies_with_director_names = movies_with_directors_set(nds)\n movies_with_director_names = flatten_a_o_a(a_o_a_movies_with_director_names)\n return gross_per_studio(movies_with_director_names)\nend", "def studios_totals(nds)\n a_o_a_movies_with_director_names = movies_with_directors_set(nds)\n movies_with_director_names = flatten_a_o_a(a_o_a_movies_with_director_names)\n return gross_per_studio(movies_with_director_names)\nend", "def studios_totals(nds)\n a_o_a_movies_with_director_names = movies_with_directors_set(nds)\n movies_with_director_names = flatten_a_o_a(a_o_a_movies_with_director_names)\n return gross_per_studio(movies_with_director_names)\nend", "def studios_totals(nds)\n a_o_a_movies_with_director_names = movies_with_directors_set(nds)\n movies_with_director_names = flatten_a_o_a(a_o_a_movies_with_director_names)\n return gross_per_studio(movies_with_director_names)\nend", "def studios_totals(nds)\n a_o_a_movies_with_director_names = movies_with_directors_set(nds)\n movies_with_director_names = flatten_a_o_a(a_o_a_movies_with_director_names)\n return gross_per_studio(movies_with_director_names)\nend", "def studios_totals(nds)\n a_o_a_movies_with_director_names = movies_with_directors_set(nds)\n movies_with_director_names = flatten_a_o_a(a_o_a_movies_with_director_names)\n return gross_per_studio(movies_with_director_names)\nend", "def studios_totals(nds)\n a_o_a_movies_with_director_names = movies_with_directors_set(nds)\n movies_with_director_names = flatten_a_o_a(a_o_a_movies_with_director_names)\n return gross_per_studio(movies_with_director_names)\nend", "def studios_totals(nds)\n a_o_a_movies_with_director_names = movies_with_directors_set(nds)\n movies_with_director_names = flatten_a_o_a(a_o_a_movies_with_director_names)\n return gross_per_studio(movies_with_director_names)\nend", "def studios_totals(nds)\n a_o_a_movies_with_director_names = movies_with_directors_set(nds)\n movies_with_director_names = flatten_a_o_a(a_o_a_movies_with_director_names)\n return gross_per_studio(movies_with_director_names)\nend", "def studios_totals(nds)\n a_o_a_movies_with_director_names = movies_with_directors_set(nds)\n movies_with_director_names = flatten_a_o_a(a_o_a_movies_with_director_names)\n return gross_per_studio(movies_with_director_names)\nend", "def studios_totals(nds)\n a_o_a_movies_with_director_names = movies_with_directors_set(nds)\n movies_with_director_names = flatten_a_o_a(a_o_a_movies_with_director_names)\n return gross_per_studio(movies_with_director_names)\nend", "def studios_totals(nds)\n a_o_a_movies_with_director_names = movies_with_directors_set(nds)\n movies_with_director_names = flatten_a_o_a(a_o_a_movies_with_director_names)\n return gross_per_studio(movies_with_director_names)\nend", "def update_score_from_games!\n return if self.games.count == 0\n score_by_steam_id = {}\n self.games.each do |g|\n # Add one point to winning team, 0 to losing team so that they show up in the keyset when we check later\n if g.radiant_win === true\n score_by_steam_id[g.radiant_team_id] = score_by_steam_id[g.radiant_team_id].to_i + 1\n score_by_steam_id[g.dire_team_id] = score_by_steam_id[g.dire_team_id].to_i\n elsif g.radiant_win === false\n score_by_steam_id[g.radiant_team_id] = score_by_steam_id[g.radiant_team_id].to_i\n score_by_steam_id[g.dire_team_id] = score_by_steam_id[g.dire_team_id].to_i + 1\n end\n end\n\n # OK the keys are team ids, so now save them\n if score_by_steam_id[self.home_participant.id] != nil && score_by_steam_id[self.away_participant.id] != nil\n self.home_score = score_by_steam_id[self.home_participant.id]\n self.away_score = score_by_steam_id[self.away_participant.id]\n self.save!\n else\n puts score_by_steam_id.inspect\n puts self.home_participant_id.inspect\n puts self.away_participant_id.inspect\n puts \"WARNING: teams did not match, not updating match score\"\n end\n end", "def get_advanced_team_season_stats(opts = {})\n data, _status_code, _headers = get_advanced_team_season_stats_with_http_info(opts)\n data\n end", "def buildDivisionToStandingsMap(teamToStandingsMap)\n divisionToStandingsMap = {}\n teamToStandingsMap.keys.each do |team_id|\n standing = teamToStandingsMap[team_id]\n team = standing.mlb_team\n if !divisionToStandingsMap.has_key?(team.league + team.division)\n divisionToStandingsMap[team.league + team.division] = [standing]\n else\n divisionToStandingsMap[team.league + team.division] << standing\n end\n end\n return divisionToStandingsMap\n end", "def season(year, **options) = get(\"/seasons/#{year}\", **{ sportId: 1 }.merge(options))", "def get_advanced_team_season_stats_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: StatsApi.get_advanced_team_season_stats ...'\n end\n # resource path\n local_var_path = '/stats/season/advanced'\n\n # query parameters\n query_params = {}\n query_params[:'year'] = opts[:'year'] if !opts[:'year'].nil?\n query_params[:'team'] = opts[:'team'] if !opts[:'team'].nil?\n query_params[:'excludeGarbageTime'] = opts[:'exclude_garbage_time'] if !opts[:'exclude_garbage_time'].nil?\n query_params[:'startWeek'] = opts[:'start_week'] if !opts[:'start_week'].nil?\n query_params[:'endWeek'] = opts[:'end_week'] if !opts[:'end_week'].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 = []\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<AdvancedSeasonStat>')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: StatsApi#get_advanced_team_season_stats\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def stats_vs_team(team, season = nil)\n id = find_id(team, Team)\n data = stats_request(\"vsTeam\", season)\n data.find do |s| s[\"opponent\"][\"id\"] == id end\n end", "def scoreboard\n teams.sort { |team1, team2| team1.score == team2.score ? team1.name <=> team2.name : team2.score <=> team1.score }.each_with_object([]) do |team, scoreboard|\n scoreboard << { name: team.name, score: team.score, goals: team.goals }\n end\n end", "def total_medals_per_team(olympic_data)\n\n team_medals_hash = {}\n\n olympic_data.each do |data|\n\n if team_medals_hash.key?(data[\"Team\"])\n if [\"Gold\", \"Silver\", \"Bronze\"].include?(data[\"Medal\"]) #SAME TEAM, MEDAL\n team_medals_hash[data[\"Team\"]] += 1\n end\n else\n\n if [\"Gold\", \"Silver\", \"Bronze\"].include?(data[\"Medal\"]) # NEW TEAM, MEDAL\n team_medals_hash[data[\"Team\"]] = 1\n else\n team_medals_hash[data[\"Team\"]] = 0\n\n end\n end\n end\n return team_medals_hash\nend", "def collect_stat_by_name (stat) #returns hash of \"name\" => stat value\n team_names_array = team_names\n player_stats_array = []\n roster = []\n player_stat = {}\n \n team_names_array.each do |team|\n roster << search_team_data(team, :players)\n roster.flatten!\n roster.each do |player_entry|\n player_stats_array << player_entry.slice(:player_name, stat)\n end\n end\n player_stats_array.each do |player_stat_hash|\n player_stat[player_stat_hash[:player_name]] = player_stat_hash[stat]\n end\n player_stat\nend", "def game_info(year, input)\r\n x = get_games(year, input).sort.to_h\r\n\r\n #determine if the team did not exist during the given year\r\n if x == {}\r\n puts \"The #{self.chosen_team_full_name} did not play any games in #{year}.\"\r\n end\r\n\r\n if self.chosen_team_full_name != nil\r\n self.chosen_team_nickname = self.chosen_team_full_name.split(\" \").last\r\n end\r\n\r\n counter = 0\r\n x.each do |key, value|\r\n counter += 1\r\n if value[\"home_team\"] == @chosen_team_full_name && value[\"home_team_score\"] > value[\"visitor_team_score\"]\r\n puts \"#{value[\"date\"]} -- #{value[\"visitor_team\"]}: #{self.chosen_team_nickname} win #{value[\"home_team_score\"]} to #{value[\"visitor_team_score\"]}.\".green\r\n sleep(0.2)\r\n elsif value[\"home_team\"] == @chosen_team_full_name && value[\"home_team_score\"] < value[\"visitor_team_score\"]\r\n puts \"#{value[\"date\"]} -- #{value[\"visitor_team\"]}: #{self.chosen_team_nickname} lose #{value[\"visitor_team_score\"]} to #{value[\"home_team_score\"]}.\".colorize(:red)\r\n sleep(0.2)\r\n elsif value[\"visitor_team\"] == @chosen_team_full_name && value[\"home_team_score\"] > value[\"visitor_team_score\"]\r\n puts \"#{value[\"date\"]} -- @#{value[\"home_team\"]}: #{self.chosen_team_nickname} lose #{value[\"home_team_score\"]} to #{value[\"visitor_team_score\"]}.\".colorize(:red)\r\n sleep(0.2)\r\n elsif value[\"visitor_team\"] == @chosen_team_full_name && value[\"home_team_score\"] < value[\"visitor_team_score\"]\r\n puts \"#{value[\"date\"]} -- @#{value[\"home_team\"]}: #{self.chosen_team_nickname} win #{value[\"visitor_team_score\"]} to #{value[\"home_team_score\"]}.\".colorize(:green)\r\n sleep(0.2)\r\n end\r\n \r\n if counter % 20 == 0\r\n puts \"Type 'n' if you do not want to see more games. Otherwise press 'Enter'\"\r\n input = gets.chomp \r\n\r\n if input == \"n\"\r\n break\r\n end\r\n\r\n end\r\n\r\n end\r\n end", "def create_team(team_xml)\n team = Hash.new\n word_pattern = /[A-Za-z]/\n float_pattern = /([0-9]\\.)+/\n # put team info in a hash, convert it to the correct data type\n team_xml.attributes.each do |k, v|\n if word_pattern.match(v.value)\n team[k.to_sym] = v.value\n elsif float_pattern.match(v.value)\n team[k.to_sym] = v.value.to_f\n else\n team[k.to_sym] = v.value.to_i\n end\n end\n streak_xml = team_xml.xpath('streak').first\n word = streak_xml.xpath('win').empty? ? 'loss' : 'win'\n team[:streak] = create_streak(word, streak_xml.xpath(word).first)\n records = Hash.new\n %w(atlantic central conference division home last_10 last_10_home last_10_road metropolitan pacific road).each do |cat|\n records[cat.to_sym] = create_record(team_xml.xpath(\"records/#{cat}\").first)\n end\n team[:records] = records\n team\n end", "def get_average_age_for_season(data, season)\n count = 0\n age = 0\n data[season].each do |info|\n info.each do |k,v|\n if k == \"age\"\n count += 1\n age += v.to_f\n end\n end\n end\n avg_age = (age / count).round\n return avg_age\nend" ]
[ "0.7121842", "0.70724684", "0.6951655", "0.68207276", "0.6794257", "0.6682035", "0.664376", "0.66129464", "0.6571687", "0.6488379", "0.64104545", "0.63874316", "0.63773996", "0.63418156", "0.6329258", "0.6302109", "0.6300947", "0.6289", "0.6213245", "0.6196532", "0.61747855", "0.61592335", "0.6126216", "0.60577196", "0.60403824", "0.60373026", "0.599833", "0.5990079", "0.59864527", "0.5983694", "0.59836763", "0.59781086", "0.5973678", "0.59683675", "0.5968275", "0.5960311", "0.59566087", "0.5924476", "0.5923558", "0.59168136", "0.5891345", "0.58821714", "0.587964", "0.5857679", "0.5853491", "0.58484864", "0.5832421", "0.5827293", "0.58157647", "0.58040285", "0.580141", "0.5791727", "0.57916814", "0.57809466", "0.5778568", "0.5767245", "0.5766745", "0.5765931", "0.5761702", "0.57477486", "0.5741754", "0.5740311", "0.57377756", "0.5735678", "0.5729199", "0.5712358", "0.5709936", "0.5705374", "0.5703614", "0.56982166", "0.56882846", "0.5677026", "0.56712484", "0.56573737", "0.56563497", "0.56465095", "0.5646015", "0.5646015", "0.5646015", "0.5646015", "0.5646015", "0.5646015", "0.5646015", "0.5646015", "0.5646015", "0.5646015", "0.5646015", "0.5646015", "0.5635142", "0.563484", "0.56332916", "0.56213665", "0.5600349", "0.55875957", "0.55782014", "0.5570383", "0.5565699", "0.5559469", "0.55582285", "0.555592" ]
0.57748497
55
returns record (as a hash win/loss) against each opponent
def head_to_head(team_id) team_id = team_id.to_i head_to_head_hash = {} team = @teams.select { |each_team| each_team.team_id == team_id }.first head_to_head_id_hash = team.matchup_win_percentage head_to_head_id_hash.each do |each_team_id, win_percentage| @teams.each do |each_team| if each_team.team_id == each_team_id head_to_head_hash[each_team.team_name] = win_percentage end end end head_to_head_hash end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def calculate_results\n players = {}\n @rounds.each do |round|\n round[:results].each do |player,result|\n if not players.has_key?(player)\n players[player] = 0\n end\n if result[:result] == \"Win\"\n players[player] += 1\n end\n end\n end\n winner = players.max_by{|k,v| v}\n players.each do |player, wins|\n @match[player] = {\n \"result\": (player == winner[0]) ? \"Win\" : \"Loss\",\n \"score\": wins\n }\n\t if @duplicate_players then\n\t\t@match[player][:result]= \"Tie\"\n\t end\n\t \n end\n end", "def calculate_results\n players = {}\n @rounds.each do |round|\n round[:results].each do |player, result|\n if not players.has_key?(player)\n players[player] = 0\n end\n if result[:result] == \"Win\"\n players[player] += 1\n end\n end\n end\n winner = players.max_by { |k, v| v }\n players.each do |player, wins|\n @match[player] = {\n \"result\": (player == winner[0]) ? \"Win\" : \"Loss\",\n \"score\": wins,\n }\n if @duplicate_players\n @match[player][:result] = \"Tie\"\n end\n end\n end", "def winner_comb\n $the_win_comb = { flash_straight: flash_straight, for_of_kind: four_of_kind, full_house: full_house,\n flush: flush, straight: straight, three: three, two_pair: two_pair,\n one_pair: one_pair, high_card: high_card }\n end", "def record\n wins.to_s + '-' + losses.to_s\n end", "def wins_losses\n GAME_INFO.each do |game|\n @team_records.each do |team|\n if game[:home_team] == team.name && game[:home_score] > game[:away_score] #refactor later\n team.wins += 1\n elsif game[:home_team] == team.name && game[:home_score] < game[:away_score]\n team.losses += 1\n end\n end\n end\n\n GAME_INFO.each do |game|\n @team_records.each do |team|\n if game[:away_team] == team.name && game[:away_score] > game[:home_score] #refactor later\n team.wins += 1\n elsif game[:away_team] == team.name && game[:away_score] < game[:home_score]\n team.losses += 1\n end\n end\n end\n\n end", "def track_victory(winnerofturn) #algorythmic\n if winnerofturn == @Player1\n @win_counter[\"P1\"] += 1\n elsif winnerofturn == @Player2\n @win_counter[\"P2\"] += 1\n end\n end", "def win_loss_array\n win_count = 0\n loss_count = 0\n\n waiting_players.each do |player|\n player.matches.each do |match| \n if match.winner_id == player.id\n win_count += 1\n elsif !match.winner_id.nil?\n loss_count += 1\n end\n end\n end\n \n [win_count, loss_count]\n end", "def winning_team\n team_p = []\n team_n = []\n\n game_hash.each do | location, team_data|\n temp = 0\n team_data[:players].each do |p_name, stats|\n temp += stats[:points]\n end\n team_n << team_data[:team_name]\n team_p << temp\n end\n\n team_p[0] > team_p[1] ? team_n[0] : team_n[1]\n\nend", "def determine_winner game\n winner = game.max_by {|team| team[:score]}\n team_standings = get_team_by_name(winner)\n team_standings[:winnings] += 3\nend", "def setup_winners_right_now\n # create a Hash with ongoing games\n @honorable_hash = Hash.new\n @games.each do |g|\n if g.started?\n tips = Tip.joins(:user).where(\"game_id =? and home_score = ? and away_score = ?\", g.id, g.home_score, g.away_score).order(\"users.points DESC\")\n @honorable_hash[g.id] = tips\n end\n end\n end", "def winning_team\n points_home = 0\n points_away = 0\n result = \"\"\n\n game_hash.each do |side,team|\n team.each do |specs,info|\n if specs == :players\n info.each do |player|\n if side = :home\n points_home += player[:points]\n else\n points_away += player[:points]\n end\n end\n end\n end\n end\n if points_home > points_away\n result = game_hash[:home][:team_name]\n else\n result = game_hash[:away][:team_name]\n end\n result\nend", "def wins\n determine_stats[:wins]\n end", "def wins()\n wins = []\n matches.each do |match|\n if match.winner_id == @id\n wins << match\n end\n end\n return wins\n end", "def outcome\n if self.final\n \th = home_team\n \ta = away_team\n \t# h.wins=0 if h.wins==nil\n \t# h.losses=0 if h.losses==nil\n \t# a.wins=0 if a.wins==nil\n \t# a.losses=0 if a.losses==nil\n \tif home_score == away_score\n \t\treturn 'T'\n \telsif home_score > away_score\n \t\tif !self.recorded\n \t \t\th.wins += 1\n \t \t\ta.losses += 1\n \t \t\th.save\n \t \t\ta.save\n \t \t\tself.recorded=true\n \t \t\tself.save\n \t \tend\n \t\tif overtime\n \t\t\treturn 'h'\n \t\telse\n \t\t\treturn 'H'\n \t\tend\n \telse\n \t\tif !self.recorded\n \t \t\th.losses += 1\n \t \t\ta.wins += 1\n \t \t\ta.save\n \t \t\th.save\n \t \t\tself.recorded=true\n \t \t\tself.save\n \t \tend\n \t\tif overtime\n \t\t\treturn 'a'\n \t\telse\n \t\t\treturn 'A'\n \t\tend\n \tend\n end\n end", "def winning_team\n final_scores = player_collection.reduce(home: 0, away: 0) { |teams_points, next_player|\n case \n when next_player[:location] === :away\n teams_points[:away] += next_player[:points];\n when next_player[:location] === :home\n teams_points[:home] += next_player[:points];\n end\n teams_points; \n }\n winner = final_scores.reduce { |highest_points, team_points| \n highest_points[1] > team_points[1] ? highest_points : team_points; \n }\n game_hash[winner[0]][:team_name]; \nend", "def log_results!(player, computer, player_log, computer_log)\n if win_round?(player, computer)\n player_log << 1\n computer_log << 0\n return player_log, computer_log\n elsif player == computer\n player_log << 0\n computer_log << 0\n return player_log, computer_log\n else\n player_log << 0\n computer_log << 1\n return player_log, computer_log\n end\nend", "def compare_hands\n players_hash = Hash.new(0)\n @active_players.each do |player|\n players_hash[player] = player.hand.analyze_hand_value\n end\n\n highest_val = players_hash.values.max\n winners = players_hash.reject { |_, val| val != highest_val }\n\n winners.keys.each do |winner|\n winner.chip_count += @pot.to_f / winners.length.to_f\n end\n winners_str = \"This rounds winner(s) is/are\"\n winners.keys.each do |winner|\n winners_str << \" #{winner.name}\"\n end\n winners_str << \"!!!!\\n\"\n puts winners_str\n end", "def winning_team\n home_points = 0\n away_points = 0\n result = \"\"\n i = 0\n game_hash.each do |team, about|\n about[:players].each do |name , stats|\n if i == 0\n home_points += stats[:points]\n else\n away_points += stats[:points]\n end\n end\n i += 1\n end\n home_points > away_points ? result = game_hash[:home][:team_name] : result = game_hash[:away][:team_name]\nend", "def winner\r\n self.results_hash[:winner]\r\n end", "def update_record game\n @wins += 1 if game.game_result == 'W'\n @losses += 1 if game.game_result == 'L'\n @ties += 1 if game.game_result == 'T'\n end", "def opponent_score_array win_condition \n if win_condition == 'W'\n win_condition = 'L'\n elsif win_condition == 'L'\n win_condition = 'W'\n end\n \n score_array = @game_objects.map{|game| game_meets_win_cond?(win_condition, game) ? game.score_opponent.to_i : -1}\n score_array.delete(-1)\n return score_array\n end", "def calculate!\n ov = self[:overall]\n ov[:high_night] = {}\n ov[:winners] = {}\n\n self.each do |player_id, st|\n next if player_id == :overall\n\n ## calculate computed stats for player\n st[:nights] += st[:dates].keys.length # if st[:nights] == 0\n st[:high_night] = st[:dates].values.max\n st[:gold_stars] = 1 if st[:nights] == 29\n st[:warps_per_game] = 1.0 * st[:warps] / st[:games] rescue 0\n st[:warps_per_night] = 1.0 * st[:warps] / st[:nights] rescue 0\n st[:games_per_night] = 1.0 * st[:games] / st[:nights] rescue 0\n st[:wins_per_night] = 1.0 * st[:wins] / st[:nights] rescue 0\n st[:wins_per_game] = 1.0 * st[:wins] / st[:games] rescue 0\n\n ## accumulate overall stats\n [:warps, :wins, :cfbs,\n :mystery_factors, :gold_stars]. each do |field|\n ov[field] += st[field]\n end\n [:wimps, :come_ons].each do |field|\n if st[field]\n ov[field] ||= 0\n ov[field] += st[field]\n end\n end\n # nights won calculation\n st[:dates].each do |date,warps|\n ov[:dates][date] += warps\n hnd = ov[:high_night][date] ||= {:players => [], :warps => 0}\n if hnd[:warps] < warps\n hnd[:players] = [player_id]\n hnd[:warps] = warps\n elsif hnd[:warps] == warps\n hnd[:players].push(player_id)\n end\n end\n end\n\n ## update overall computed stats\n st = self[:overall]\n ov[:games] = ov[:wins]\n ov[:nights] = ov[:dates].keys.length\n ov[:nights] = 29 if ov[:nights] == 0 ## provide sane default\n ov[:nights] = ov[:nights_real] if ov[:nights_real]\n ov[:warps_per_game] = 1.0 * ov[:warps] / ov[:games] rescue 0\n ov[:warps_per_night] = 1.0 * ov[:warps] / ov[:nights] rescue 0\n ov[:games_per_night] = 1.0 * ov[:games] / ov[:nights] rescue 0\n ov[:high_night].each do |date,h|\n h[:players].each {|p| self[p][:nights_won] += 1}\n end\n\n ## determine per-stat winners\n # fuck everyone but the top 50 OR those with 50+ warps\n # the 51 below is not a bug\n sorted_players = self.keys.sort{|a,b| self[b][:warps] <=> self[a][:warps]}\n fifty_plus = self.keys.select{|p| self[p][:warps] >= 50}\n eligible = (sorted_players[0..51] | fifty_plus).\n inject(Hash.new(false)) {|acc,p| acc.merge(p => true)}\n [:warps, :games, :nights, :wins, :nights_won, :cfbs,\n :come_ons, :wimps, :warps_per_game, :warps_per_night,\n :games_per_night, :wins_per_game, :high_night].each do |field|\n owf = ov[:winners][field] = {:players => [], :value => 0}\n self.each do |player, st|\n next if player == :overall\n next unless eligible[player]\n if st[field].to_f > owf[:value]\n owf[:players] = [player]\n owf[:value] = st[field]\n elsif st[field] == owf[:value]\n owf[:players].push(player)\n end\n end\n end\n\n ## mark per-stat winners\n ov[:winners].each do |field, win|\n win[:players].each do |player|\n self[player][:winner][field] = true\n end\n end\n\n self\n end", "def results_hash\r\n if self.home_score > self.away_score\r\n {winner: self.home_team,loser: self.away_team}\r\n else \r\n {winner: self.away_team,loser: self.home_team}\r\n end\r\n end", "def winner\n @best_hand = {}\n @eg_users.each do |user|\n @usr = user[0]\n @best_hand[@usr] = []\n cards = []\n cards = Array.new(@communal_cards)\n cards << user[1]\n cards << user[2]\n calculate_hand cards\n end\n best_hnd_key = determine_winner\n end", "def tie_winner \n\t\t# Store the winner information if there is a tie for player 1 and 2 \n\t\t@tie_1 = Array.new\n\t\t@tie_2 = Array.new\n\n\t\tfor i in 0..@best_hand_value_1.length-1 do \n\n\t\t\tif @best_hand_value_1[i] == @best_hand_value_2[i]\n\n\t\t\t\t# This cannot happen but included to be complete \n\t\t\t\tif @combo_name_1[i][0] == \"A Royal Flush\"\n\t\t\t\t\t@tie_1[i] = 0 \n\t\t\t\t\t@tie_2[i] = 0 \n\t\t\t\tend \n\t\t\t\t# find winner with two straight flushes\n\t\t\t\t# larger straight flush will be the largest value in the values array\n\t\t\t\tif @combo_name_1[i][0] == \"A Straight Flush\"\n\t\t\t\t\tif @hand_information_player_1[i]['vals'].sort[-1] > @hand_information_player_2[i]['vals'].sort[-1]\n\t\t\t\t\t\t@tie_1[i] = @hand_information_player_1[i]['vals'].sort[-1]\n\t\t\t\t\t\t@tie_2[i] = 0 \n\t\t\t\t\telsif @hand_information_player_1[i]['vals'].sort[-1] < @hand_information_player_2[i]['vals'].sort[-1]\n\t\t\t\t\t\t@tie_1[i] = 0\n\t\t\t\t\t\t@tie_2[i] = @hand_information_player_2[i]['vals'].sort[-1]\n\t\t\t\t\tend \n\t\t\t\tend\n\t\t\t\t# find winner with 2 four of a kinds\n\t\t\t\t# larger 4 of a kind will be the mode of the value array\n\t\t\t\tif @combo_name_1[i][0] == \"Four of a Kind\"\n\t\t\t\t\tif @hand_information_player_1[i]['vals'].mode > @hand_information_player_2[i]['vals'].mode\n\t\t\t\t\t\t@tie_1[i] = @hand_information_player_1[i]['vals'].mode\n\t\t\t\t\t\t@tie_2[i] = 0 \n\t\t\t\t\telsif @hand_information_player_1[i]['vals'].mode < @hand_information_player_2[i]['vals'].mode\n\t\t\t\t \t\t@tie_1[i] = 0\n\t\t\t\t \t\t@tie_2[i] = @hand_information_player_2[i]['vals'].mode\n\t\t\t\t \tend \n\t\t\t\tend \n\t\t\t\t# find winner with two three of a kinds\n\t\t\t\t# larger 3 of a kind will be the mode of the values array \n\t\t\t\tif @combo_name_1[i][0] == \"Three of a Kind\"\n\t\t\t\t\tif @hand_information_player_1[i]['vals'].mode > @hand_information_player_2[i]['vals'].mode\n\t\t\t\t\t\t@tie_1[i] = @hand_information_player_1[i]['vals'].mode\n\t\t\t\t\t\t@tie_2[i] = 0 \n\t\t\t\t\telsif @hand_information_player_1[i]['vals'].mode < @hand_information_player_2[i]['vals'].mode\n\t\t\t\t \t\t@tie_1[i] = 0\n\t\t\t\t \t\t@tie_2[i] = @hand_information_player_2[i]['vals'].mode\n\t\t\t\t \tend \n\t\t\t\tend \n\t\t\t\t# find winner with two full houses. Larger full house will be larger 3 of a kind, \n\t\t\t\t# which can be found as the mode of the values array \n\t\t\t\tif @combo_name_1[i][0] == \"A Full House\"\n\t\t\t\t\tif @hand_information_player_1[i]['vals'].mode > @hand_information_player_2[i]['vals'].mode\n\t\t\t\t\t\t@tie_1[i] = @hand_information_player_1[i]['vals'].mode\n\t\t\t\t\t\t@tie_2[i] = 0 \n\t\t\t\t\telsif @hand_information_player_1[i]['vals'].mode < @hand_information_player_2[i]['vals'].mode\n\t\t\t\t \t\t@tie_1[i] = 0\n\t\t\t\t \t\t@tie_2[i] = @hand_information_player_2[i]['vals'].mode\n\t\t\t\t \tend \n\t\t\t\tend \n\t\t\t\t# find winner with two flushes. Since a flush is 5 cards, max will store largest. \n\t\t\t\tif @combo_name_1[i][0] == \"A Flush\"\n\t\t\t\t\tif @hand_information_player_1[i]['max'] > @hand_information_player_2[i]['max'] \n\t\t\t\t\t\t@tie_1[i] = @hand_information_player_1[i]['max']\n\t\t\t\t\t\t@tie_2[i] = 0\n\t\t\t\t\telsif @hand_information_player_1[i]['max'] < @hand_information_player_2[i]['max'] \n\t\t\t\t\t\t@tie_1[i] = 0\n\t\t\t\t\t\t@tie_2[i] = @hand_information_player_2[i]['max']\n\t\t\t\t\tend \n\t\t\t\tend \n\t\t\t\t# find winner with two straights. Since a straight is 5 cards, the max will have \n\t\t\t\t# the larger of the two saved \n\t\t\t\tif @combo_name_1[i][0] == \"A Straight\"\n\t\t\t\t\tif @hand_information_player_1[i]['max'] > @hand_information_player_2[i]['max'] \n\t\t\t\t\t\t@tie_1[i] = @hand_information_player_1[i]['max']\n\t\t\t\t\t\t@tie_2[i] = 0\n\t\t\t\t\telsif @hand_information_player_1[i]['max'] < @hand_information_player_2[i]['max'] \n\t\t\t\t\t\t@tie_1[i] = 0\n\t\t\t\t\t\t@tie_2[i] = @hand_information_player_2[i]['max']\n\t\t\t\t\tend \n\t\t\t\tend \n\t\t\t\t# find winner with same high card. Itterate through all 5 cards until one is bigger (in order from highest)\n\t\t\t\tif @combo_name_1[i][0] == \"High Card\"\n\t\t\t\t\tfor k in 1..5 do\n\t\t\t\t\t\tif @hand_information_player_1[i]['vals'].sort[-k] > @hand_information_player_2[i]['vals'].sort[-k]\n\t\t\t\t\t\t\t@tie_1[i] = @hand_information_player_1[i]['vals'].sort[-k]\n\t\t\t\t\t\t\t@tie_2[i] = 0\n\t\t\t\t\t\t\tbreak \n\t\t\t\t\t\telsif @hand_information_player_1[i]['vals'].sort[-k] < @hand_information_player_2[i]['vals'].sort[-k]\n\t\t\t\t\t\t\t@tie_1[i] = 0\n\t\t\t\t\t\t\t@tie_2[i] = @hand_information_player_2[i]['vals'].sort[-k]\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\tend \n\t\t\t\t\tend \n\t\t\t\tend\n\t\t\t\t# find winner with same two pairs. First check each of the pair values (high to low) then check\n\t\t\t\t# the remaining cards high to low \n\t\t\t\tif @combo_name_1[i][0] == \"Two Pair\" \n\t\t\t\t\tif @hand_information_player_1[i]['pairvals'].sort[-1] > @hand_information_player_2[i]['pairvals'].sort[-1]\n\t\t\t\t\t\t@tie_1[i] = @hand_information_player_1[i]['pairvals'].sort[-1]\n\t\t\t\t\t\t@tie_2[i] = 0\n\t\t\t\t\telsif @hand_information_player_1[i]['pairvals'].sort[-1] < @hand_information_player_2[i]['pairvals'].sort[-1]\n\t\t\t\t\t\t@tie_1[i] = 0\n\t\t\t\t\t\t@tie_2[i] = @hand_information_player_2[i]['pairvals'].sort[-1]\n\t\t\t\t\telsif @hand_information_player_1[i]['pairvals'].sort[-1] == @hand_information_player_2[i]['pairvals'].sort[-1]\n\t\t\t\t\t\tif @hand_information_player_1[i]['pairvals'].sort[-2] > @hand_information_player_2[i]['pairvals'].sort[-2]\n\t\t\t\t\t\t\t@tie_1[i] = @hand_information_player_1[i]['pairvals'].sort[-2]\n\t\t\t\t\t\t\t@tie_2[i] = 0\n\t\t\t\t\t\telsif @hand_information_player_1[i]['pairvals'].sort[-2] < @hand_information_player_2[i]['pairvals'].sort[-2]\n\t\t\t\t\t\t\t@tie_1[i] = 0\n\t\t\t\t\t\t\t@tie_2[i] = @hand_information_player_2[i]['pairvals'].sort[-2]\n\t\t\t\t\t\telsif @hand_information_player_1[i]['pairvals'].sort[-2] == @hand_information_player_2[i]['pairvals'].sort[-2]\n\t\t\t\t\t\t\tfor k in 1..3 do\n\t\t\t\t\t\t\t\tif @hand_information_player_1[i]['vals'].sort[-k] > @hand_information_player_2[i]['vals'].sort[-k]\n\t\t\t\t\t\t\t\t\t@tie_1[i] = @hand_information_player_1[i]['vals'].sort[-k]\n\t\t\t\t\t\t\t\t\t@tie_2[i] = 0\n\t\t\t\t\t\t\t\t\tbreak \n\t\t\t\t\t\t\t\telsif @hand_information_player_1[i]['vals'].sort[-k] < @hand_information_player_2[i]['vals'].sort[-k]\n\t\t\t\t\t\t\t\t\t@tie_1[i] = 0\n\t\t\t\t\t\t\t\t\t@tie_2[i] = @hand_information_player_2[i]['vals'].sort[-k]\n\t\t\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t\t\tend \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\t\t\t\t# find winner with same pairs, first check pair value (high to low), then itterate through all remaining cards\n\t\t\t\t# high to low \n\t\t\t\tif @combo_name_1[i][0] == \"A Pair\"\n\t\t\t\t\tif @hand_information_player_1[i]['pairvals'][0] > @hand_information_player_2[i]['pairvals'][0]\n\t\t\t\t\t\t@tie_1[i] = @hand_information_player_1[i]['pairvals'][0]\n\t\t\t\t\t\t@tie_2[i] = 0\n\t\t\t\t\telsif @hand_information_player_1[i]['pairvals'][0] < @hand_information_player_2[i]['pairvals'][0]\n\t\t\t\t\t\t@tie_1[i] = 0\n\t\t\t\t\t\t@tie_2[i] = @hand_information_player_2[i]['pairvals'][0]\n\t\t\t\t\telsif @hand_information_player_1[i]['pairvals'][0] == @hand_information_player_2[i]['pairvals'][0]\n\t\t\t\t\t\tfor k in 1..4 do\n\t\t\t\t\t\t\tif @hand_information_player_1[i]['vals'].sort[-k] > @hand_information_player_2[i]['vals'].sort[-k]\n\t\t\t\t\t\t\t\t@tie_1[i] = @hand_information_player_1[i]['vals'].sort[-k]\n\t\t\t\t\t\t\t\t@tie_2[i] = 0\n\t\t\t\t\t\t\t\tbreak \n\t\t\t\t\t\t\telsif @hand_information_player_1[i]['vals'].sort[-k] < @hand_information_player_2[i]['vals'].sort[-k]\n\t\t\t\t\t\t\t\t@tie_1[i] = 0\n\t\t\t\t\t\t\t\t@tie_2[i] = @hand_information_player_2[i]['vals'].sort[-k]\n\t\t\t\t\t\t\t\tbreak\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\t\t\telse \n\t\t\t\t# if no tie, tie should be zero\n\t\t\t\t@tie_1[i] = 0\n\t\t\t\t@tie_2[i] = 0\n\t\t\tend\n\n\t\tend # Ends the loop for the different types of tied hands \n\n\tend", "def offensive_row_for_ai(board)\n offensive_play = {}\n WINNING_COMBINATIONS.each { |offense| offensive_play[offense] = 0 }\n WINNING_COMBINATIONS.each do |offense|\n offense.each do |is_x|\n offensive_play[offense] += 1 if board[is_x] == COMPUTER_MARKER\n if board[is_x] == PLAYER_MARKER\n offensive_play[offense] = 0\n break\n end\n end\n end\n offensive_play\nend", "def winner\n row_winners = rows.select{|r| identical_symbols(r)}.map{|r| r[0]}\n column_winners = columns.select{|c| identical_symbols(c)}.map{|c| c[0]}\n diagonal_winners = diagonals.select{|d| identical_symbols(d)}.map{|d| d[0]}\n winners = (row_winners + column_winners + diagonal_winners).uniq - %w(_)\n players = winners.map{|w| to_player_number(w)}\n players[0] # this would default to nil if players is empty\n end", "def who_win\n @players.each do |player|\n result_sum = 0\n player.cards_wins.each do |cards|\n result_sum += cards.value.to_i\n end\n player.points = result_sum\n end\n players_win = @players.sort_by(&:points).reverse![0]\n puts 'GANADOR--------GANADOR---------GANADOR----'\n puts \"Nombre: #{players_win.name} || Puntos: #{players_win.points}\"\n #players_win.cards_wins.each do |cards|\n # puts cards.id\n #end\n @players.each do |player|\n puts ''\n puts player.name\n puts 'Cartas: '\n player.cards_wins.each do |cards|\n print \"#{cards.id}\"\n print ' || '\n end\n end\n end", "def winning_play\n {paper: [:rock, :spock], rock: [:lizard, :scissors], scissors: [:paper, :lizard], lizard: [:spock, :paper], spock: [:rock, :scissors], scratch: [:scratch]}\n end", "def end_game_scoring\n # for each founded hotel pay shareholders\n self.game_hotels.each do |hotel|\n if hotel.chain_size > 0\n find_shareholders(hotel, hotel.chain_size)\n end\n end\n\n # for each player, sell stock at current share price\n self.game_players.each do |player|\n player.stock_cards.each do |stock|\n hotel = self.game_hotels.where(name: stock.hotel).first\n player.cash = player.cash + hotel.share_price\n player.save\n end\n end\n \n # determine winner\n most_money = 0\n winner = 0\n self.game_players.each do |player|\n if player.cash > most_money\n winner = player\n most_money = player.cash\n end\n end\n\n #notify players of results\n msg2 = 'Player ' + winner.username + ' won ' + self.name \n self.game_players.each do |player|\n if player == winner\n msg1 = 'You won ' + self.name\n Notification.create(message: msg1, user_id: player.user.id)\n else\n Notification.create(message: msg2, user_id: player.user.id)\n end\n end\n\n return winner.username\n end", "def win_game\n @win.each do |m|\n if @board[m[0]].strip == @board[m[1]] && @board[m[1]] == @board[m[2]]\n @winner = true\n end\n end\n @winner\n end", "def report_winner\n\t\tif reason = won_by?(:hunter)\n\t\t\tputs \"\\n\\nHunter (#{@hunter.username}) wins (#{reason}) at turn #{@current_turn}\\n\\n\"\n\t\t\t@hunter.write(\"GAMEOVER #{current_round} WINNER HUNTER #{reason}\")\n\t\t\t@prey.write(\"GAMEOVER #{current_round} LOSER PREY #{reason}\")\n\t\t\t@spectators.each{|s| s.puts \"GAMEOVER #{current_round} WINNER HUNTER #{reason}\"}\n\t\t\treturn {:winner => @hunter.username, :role => \"Hunter\", :time => current_round, :reason => reason}\n\t\telsif reason = won_by?(:prey)\n\t\t\tputs \"\\n\\Prey (#{@prey.username}) wins (#{reason}) at turn #{@current_turn}\\n\\n\"\n\t\t\t@hunter.write(\"GAMEOVER #{current_round} LOSER HUNTER #{reason}\")\n\t\t\t@prey.write(\"GAMEOVER #{current_round} WINNER PREY #{reason}\")\n\t\t\t@spectators.each{|s| s.puts \"GAMEOVER #{current_round} WINNER PREY #{reason}\"}\n\t\t\treturn {:winner => @prey.username, :role => \"Prey\", :time => current_round, :reason => reason}\n\t\tend\n\tend", "def winning_team\n home_team_sum = 0\n away_team_sum = 0\n game_hash.each do |team, team_stats|\n if team_stats[:team_name] == \"Brooklyn Nets\"\n team_stats[:players].each do |player_stats|\n home_team_sum += player_stats[:points]\n end\n elsif team_stats[:team_name] == \"Charlotte Hornets\"\n team_stats[:players].each do |player_stats|\n away_team_sum += player_stats[:points]\n end\n end\n end\n if home_team_sum > away_team_sum\n game_hash[:home][:team_name]\n elsif home_team_sum < away_team_sum\n game_hash[:away][:team_name]\n end\nend", "def winner\n win_hash = { basic: basic_winner,\n war: war_winner,\n mutually_assured_destruction: \"No Winner\"\n }\n win_hash[type]\n end", "def get_wins(user_id, friend_id, game_id)\n Match.where(winner_id: user_id, loser_id: friend_id, game_id: game_id).count(:winner_id)\n end", "def winner\n if winning_combo = won?\n @board[winning_combo.first]\n end\n end", "def winning_team\n nets = []\n hornets = []\n\n game_hash.values.each do |nets_stats|\n if nets_stats[:team_name] == \"Brooklyn Nets\"\n nets_stats[:players].each do |bk|\n nets << bk[:points]\n end\n end\n end\n\n game_hash.values.each do |hornets_stats|\n if hornets_stats[:team_name] == \"Charlotte Hornets\"\n hornets_stats[:players].each do |ch|\n hornets << ch[:points]\n end\n end\n end\n\n if nets.reduce(:+) > hornets.reduce(:+)\n return \"Brooklyn Nets\"\n else\n return \"Charlotte Hornets\"\n end\nend", "def result_update_to player, dealer_player, odds\r\n if player[:state] == 'won' \r\n amount = (player[:bet].to_f * odds).to_i\r\n player[:total_chips] = player[:total_chips] + amount\r\n\tdealer_player[:total_chips] = dealer_player[:total_chips] - amount\r\n\tplayer[:total_win] = player[:total_win] + 1\r\n\tplayer[:history].push('won')\r\n elsif player[:state] == 'lost'\r\n player[:total_chips] = player[:total_chips] - player[:bet]\r\n\tdealer_player[:total_chips] = dealer_player[:total_chips] + player[:bet]\r\n player[:history].push('lost')\r\n else\r\n player[:history].push('push')\r\n end\r\n player[:total_round] = (player[:state] == 'won' || player[:state] == 'lost')? player[:total_round] + 1 : player[:total_round]\r\n player[:rate] = (player[:total_round] > 0)? player[:total_win].to_f / player[:total_round].to_f : player[:rate]\r\nend", "def record_won_ball!\n # Check to see if a win-point results in a win-game outcome. \n if @points > 3 && @points >= @opponent.points + 2\n @game_points += 1\n \n record_won_game!\n reset_points\n\n else\n @points +=1 \n end \n end", "def h_wins\n h = []\n @rows.each do |row|\n @columns.each do |column|\n h.push([row, column].join(''))\n end\n end\n h.each_slice(@size).to_a\n end", "def report_results(winner_name)\n @players.each do |player_name, socket|\n if player_name == winner_name\n result = \"Win\"\n else\n result = \"Loss\"\n end\n score = rand(1...5) #meaningless\n result_string = player_name.strip + \"|\" + result + \"|\" + score.to_s\n @wrapper_connection.puts(result_string)\n end\n return\n end", "def its_a_tie game\n game.each do |team|\n team_standings = get_team_by_name(team)\n team_standings[:winnings] += 1\n end\nend", "def update_score\n games = Hash.new([])\n predictions.each do |prediction|\n key = prediction.match_id\n games[key] = {}\n games[key][:teams] = []\n games[key][:round] = prediction.round_id\n unless prediction.winner.nil?\n games[key][:teams] << prediction.winner.id\n end\n end\n Game.includes(:team1, :team2).find_each do |game|\n key = game.match_id\n unless game.winner.nil?\n games[key][:teams] << game.winner.id\n end\n end\n\n puts games.inspect\n\n score = 0\n games.each do |key, data|\n round = games[key][:round]\n winners = games[key][:teams]\n if winners.length == 2 and winners.first == winners.last\n score += (2 ** (round))\n end\n end\n self.update_attributes :score => score\n end", "def play\n\n @all_moves = Move.all\n @summary_stats = Summary.all\n\n # Rails, behind the scenes:\n # params = {\"move\"=>\"rock\"}\n\n @user_move = params[\"the_move\"]\n\n @computer_move = [\"rock\", \"paper\", \"scissors\"].sample\n\n if @user_move == @computer_move\n @outcome = \"tie\"\n elsif @user_move == \"paper\" && @computer_move == \"rock\"\n @outcome = \"won\"\n elsif @user_move == \"paper\" && @computer_move == \"scissors\"\n @outcome = \"lost\"\n elsif @user_move == \"scissors\" && @computer_move == \"rock\"\n @outcome = \"lost\"\n elsif @user_move == \"scissors\" && @computer_move == \"paper\"\n @outcome = \"won\"\n elsif @user_move == \"rock\" && @computer_move == \"paper\"\n @outcome = \"lost\"\n elsif @user_move == \"rock\" && @computer_move == \"scissors\"\n @outcome = \"won\"\n end\n\n m = Move.new\n m.user_move = @user_move.to_s\n m.computer_move = @computer_move.to_s\n if @outcome == \"won\"\n m.user_wins = 1\n m.computer_wins = 0\n m.tie = 0\n elsif @outcome == \"lost\"\n m.user_wins = 0\n m.computer_wins = 1\n m.tie = 0\n elsif @outcome == \"tie\"\n m.user_wins = 0\n m.computer_wins = 0\n m.tie = 1\n end\n m.save\n\n s = Summary.new\n if @user_move == \"rock\" && @outcome == \"won\"\n s.rock_won = 1\n s.rock_lost = 0\n s.rock_tied = 0\n elsif @user_move == \"rock\" && @outcome == \"lost\"\n s.rock_won = 0\n s.rock_lost = 1\n s.rock_tied = 0\n elsif @user_move == \"rock\" && @outcome == \"tie\"\n s.rock_won = 0\n s.rock_lost = 0\n s.rock_tied = 1\n elsif @user_move == \"paper\" && @outcome == \"won\"\n s.paper_won = 1\n s.paper_lost = 0\n s.paper_tied = 0\n elsif @user_move == \"paper\" && @outcome == \"lost\"\n s.paper_won = 0\n s.paper_lost = 1\n s.paper_tied = 0\n elsif @user_move == \"paper\" && @outcome == \"tie\"\n s.paper_won = 0\n s.paper_lost = 0\n s.paper_tied = 1\n elsif @user_move == \"scissors\" && @outcome == \"won\"\n s.scissors_won = 1\n s.scissors_lost = 0\n s.scissors_tied = 0\n elsif @user_move == \"scissors\" && @outcome == \"lost\"\n s.scissors_won = 0\n s.scissors_lost = 1\n s.scissors_tied = 0\n elsif @user_move == \"scissors\" && @outcome == \"tie\"\n s.scissors_won = 0\n s.scissors_lost = 0\n s.scissors_tied = 1\n end\n s.save\n\n\n render(\"play.html.erb\")\n end", "def wins_ball(winner)\n winner.record_won_ball!\n end", "def wins_ball(winner)\n winner.record_won_ball!\n end", "def win_test\n \t# Create a hash from entries where the value matches player @letter\n\tpositions_hash = $board.select { |key, value| value == @letter }\n\t# Now make an array of the key values. We will compare this against \n\t# the winning_combos\n\tpositions_array = positions_hash.keys\n\t\t# Did the current move win the game?\n\t\t$winning_combos.each { \n\t\t\t|x| if x == positions_array\n\t\t\t\tputs \"#{@name} WINS!\"\n\t\t\t\t$game_end = true\n\t\t\t\treturn\n\t\t\t\tend\n\t\t\t}\n\nend", "def win_round\n interface.win_round\n player.win_round\n croupier.lost_round\n overall_result\n end", "def get_other_games_won()\n @score_count.get_other_games_won()\n end", "def track_p2_wins(winner)\n if winner == 2\n return 1\n else\n return 0\n end\nend", "def update_coach_win_loss\n \t#this should make the coach of the winning team hae one more win\n \t#and the coach of the losing team have one more loss\n winning_coach.update_attribute :wins, winning_coach.wins + 1\n losing_coach.update_attribute :losses, losing_coach.losses + 1\n end", "def tied_games\n Game.joins(:players).where( players: { user_id: self.id }, winning_color: Game::TIED_GAME).count\n end", "def determine_match_winner\n @games_to_win = ((total_number_of_games / 2.0).floor) + 1\n if player1.score == games_to_win\n return player1\n elsif player2.score == games_to_win\n return player2\n else\n return nil\n end\n end", "def winning_player_id\n return nil if draw?\n player_score.value > opponent_score.value ? player_id : opponent_id\n end", "def played\n won + drawn + lost + noresult\n end", "def find_winning_hand\n results = self.hands.collect { |x| [x.id, x.rank] }.sort { |x, y|\n [Hand::RANKS[x.last[0]][:rank], Hand::CARD_ORDER[x.last.last.first]] <=> [Hand::RANKS[y.last[0]][:rank], Hand::CARD_ORDER[y.last.last.first]] }\n Win.find_or_create_by!(round: self, hand_id: results.last.first, status: true, rank: results.last.last.first)\n end", "def winner(board)\nif winning_combination = won?(board)\nboard[winning_combination[0]]\nend\nend", "def set_results winner\n winner = winner[0]\n loser = (winner == :white) ? :black : :white\n @state_store[winner].each do |state|\n state = ActiveSupport::JSON.encode(state)\n ai_board_state = AiBoardState.find_or_create_by(state: state)\n ai_board_state.score += 1\n ai_board_state.save!\n end\n\n @state_store[loser].each do |state|\n state = ActiveSupport::JSON.encode(state)\n ai_board_state = AiBoardState.find_or_create_by(state: state)\n ai_board_state.score -= 1\n ai_board_state.save!\n end\n puts \"finished storing!\"\n end", "def winning_team\n total_points = 0 #initialize points at zero \n \n win_team = '' #set win team to an empty string \n \n game_hash.each do |location, team| #iterating over game hash\n team_points = 0 #initialize team points at zero \n team_name = game_hash[location][:team_name] \n # set team name = to game_hash at the the location at the # :team name \n \n team[:players].each do |player| #iterate over players \n points = player[:points] # set points = player points \n team_points += points #team points is the addition of every single point value from each player\n \n #binding.pry \n end\n \n win_team, total_points = team_name, team_points if team_points > total_points\n \n #binding.pry \n \n end\n \n return win_team\n\nend", "def winner_take_hand\n from_war = @state == 'war'\n\n #save this for use in the stats display later\n @hand_played.freeze \n\n @winning_player = get_player_by_name @hand_played.try(:first).try(:owner)\n # @hand_played.each{|x| cards_played.push(x)}\n\n unless @winning_player.blank? \n # first calculate the loser's lost cards and metadata\n @cards_on_table.each do |c|\n get_player_by_name( c.try(:owner) ).in_battle\n get_player_by_name( c.try(:owner) ).lose_cards [c]\n end\n\n # winner puts all cards on table at the end of their deck, change ownership\n @winning_player.gain_cards(@cards_on_table)\n @winning_player.won_battle\n\n # reset var to empty array\n @cards_on_table = []\n end\n\n # check if all players can continue\n players.each do |p|\n player_leaves_game(p) if p.try(:cards).try(:count) < 1\n end\n\n display_battle_results\n set_game_state 'play'\n end", "def rps\n\n\n @user_move=params[\"the_move\"]\n @computer_move= [\"rock\", \"paper\", \"scissors\"].sample\n\n\n if @user_move == @computer_move\n @outcome = \"tied\"\n elsif @user_move == \"paper\" && @computer_move == \"rock\"\n @outcome = \"won\"\n elsif @user_move == \"paper\" && @computer_move == \"scissors\"\n @outcome = \"lost\"\n elsif @user_move == \"scissors\" && @computer_move == \"rock\"\n @outcome = \"lost\"\n elsif @user_move == \"scissors\" && @computer_move == \"paper\"\n @outcome = \"won\"\n elsif @user_move == \"rock\" && @computer_move == \"paper\"\n @outcome = \"lost\"\n elsif @user_move == \"rock\" && @computer_move == \"scissors\"\n @outcome = \"won\"\n end\n\n\n m = Move.new\n m.user_move = @user_move\n m.computer_move = @computer_move\n if @outcome == \"won\"\n m.user_wins = 1\n m.computer_wins = 0\n m.tie= 0\n elsif @outcome == \"lost\"\n m.user_wins = 0\n m.computer_wins = 1\n m.tie= 0\n else\n m.user_wins = 0\n m.computer_wins=0\n m.tie= 1\n end\n\n m.save\n\n @all_moves= Move.all\n @rockwin=Move.where({:user_move => \"rock\",:user_wins => \"1\"}).count\n @paperwin=Move.where({:user_move => \"paper\",:user_wins => \"1\"}).count\n @scissorswin=Move.where({:user_move => \"scissors\",:user_wins => \"1\"}).count\n\n @rocklose=Move.where({:user_move => \"rock\",:computer_wins => \"1\"}).count\n @paperlose=Move.where({:user_move => \"paper\",:computer_wins => \"1\"}).count\n @scissorslose=Move.where({:user_move => \"scissors\",:computer_wins => \"1\"}).count\n\n\n @rocktie=Move.where({:user_move => \"rock\",:user_wins => \"0\", :computer_wins => \"0\"}).count\n @papertie=Move.where({:user_move => \"paper\",:user_wins => \"0\", :computer_wins => \"0\"}).count\n @scissorstie=Move.where({:user_move => \"scissors\",:user_wins => \"0\", :computer_wins => \"0\"}).count\n\n @totalwin=Move.where({:user_wins => \"1\", }).count\n @totallose=Move.where({:computer_wins => \"1\"}).count\n @totaltie=Move.where({:tie => \"1\",}).count\n\n @total = @totalwin + @totallose + @totaltie\n\n\n\n\n render \"rps.html.erb\"\n end", "def winning_team\n home_team_points = game_hash[:home][:players].sum { |e| e[:points] }\n away_team_points = game_hash[:away][:players].sum { |e| e[:points] }\n\n if home_team_points > away_team_points\n return game_hash[:home][:team_name]\n else\n return game_hash[:away][:team_name]\n end\nend", "def self_records\n\n arrselftotal = GameSession.all.select do |game|\n game.user_id == self.id\n end\n arrselftotal = arrselftotal.select do |game|\n game.word_id != nil\n end\n arrselfwin = arrselftotal.select do |game| \n game.win == true\n end\n percent = arrselfwin.length.to_f/arrselftotal.length * 100\n if arrselftotal.length > 0\n username = self.name\n percent = percent.round(2)\n numgames = arrselftotal.length\n percent = percent.to_s\n numgames = numgames.to_s\n i = 0\n name = \"\"\n line_name = \"\"\n percentw = \"\"\n line_percent = \"\"\n line_games = \"\"\n gamesw = \"\"\n s_username = \"Username\"\n s_percent = \"Win %\"\n s_games = \"Total\"\n s_name = \"\"\n s_percentw = \"\"\n s_gamesw = \"\"\n for i in 0..10\n if s_username[i] != nil\n s_name << s_username[i]\n else\n s_name << \" \"\n end\n if username[i] != nil\n name << username[i]\n else\n name << \" \"\n end\n line_name << \"═\"\n end\n \n for i in 0..5\n if s_percent[i] != nil\n s_percentw << s_percent[i]\n else\n s_percentw << \" \"\n end\n if percent[i] != nil\n percentw << percent[i]\n else\n percentw << \" \"\n end\n line_percent << \"═\"\n end\n for i in 0..5\n if s_games[i] != nil\n s_gamesw << s_games[i]\n else\n s_gamesw << \" \"\n end\n if numgames[i] != nil\n gamesw << numgames[i]\n else\n gamesw << \" \"\n end\n line_games << \"═\"\n end\n puts \"╔═\" + line_name + \"═╦═\" + line_percent + \"═╦═\" + line_games + \"═╗\"\n puts \"║ \" + s_name + \" ║ \" + s_percentw + \" ║ \" + s_gamesw + \" ║\"\n puts \"╠═\" + line_name + \"═╬═\" + line_percent + \"═╬═\" + line_games + \"═╣\"\n puts \"║ \" + name + \" ║ \" + percentw + \" ║ \" + gamesw + \" ║\"\n puts \"╚═\" + line_name + \"═╩═\" + line_percent + \"═╩═\" + line_games + \"═╝\"\n puts \"\\n\\n\\n\"\n else\n puts \"#{self.name} has not played any games!\\n\\n\\n\"\n end\n self.list_my_words\n puts \"Press Enter to Continue...\"\n gets.chomp\n system('clear')\n menu(self)\n end", "def get_rankings\n #create tmp hash storage for all the rows in the rankings table\n row_holder = Hash.new { |hash, key| hash[key] =\n {'played' => 0, '3_points' => 0, '2_points' => 0, '1_point' => 0,\n '0_points' => 0, 'won_sets' => 0, 'lost_sets' => 0, 'points' => 0,\n 'name' => key}}\n\n @games.each do |g|\n if g.has_been_played?\n #add played game for both teams\n row_holder[g.home_team]['played'] += 1\n row_holder[g.away_team]['played'] += 1\n\n #add won sets for each team\n row_holder[g.home_team]['won_sets'] += g.home_sets\n row_holder[g.away_team]['won_sets'] += g.away_sets\n\n #add lost sets for each team\n row_holder[g.home_team]['lost_sets'] += g.away_sets\n row_holder[g.away_team]['lost_sets'] += g.home_sets\n\n #handle all different game outcomes, prepare for ugly code\n #handle 3-0 and 3-1\n if (g.home_sets == 3) && (g.away_sets < 2)\n row_holder[g.home_team]['points'] += 3\n row_holder[g.home_team]['3_points'] += 1\n row_holder[g.away_team]['0_points'] += 1\n\n #handle 3-2\n elsif (g.home_sets == 3) && (g.away_sets == 2)\n row_holder[g.home_team]['points'] += 2\n row_holder[g.away_team]['points'] += 1\n row_holder[g.home_team]['2_points'] += 1\n row_holder[g.away_team]['1_point'] += 1\n\n #handle 2-3\n elsif (g.home_sets == 2) && (g.away_sets ==3)\n row_holder[g.away_team]['points'] += 2\n row_holder[g.home_team]['points'] += 1\n row_holder[g.home_team]['1_point'] += 1\n row_holder[g.away_team]['2_points'] += 1\n\n #handle 0-3 and 1-3\n elsif (g.home_sets < 2) && (g.away_sets == 3)\n row_holder[g.away_team]['points'] += 3\n row_holder[g.home_team]['0_points'] += 1\n row_holder[g.away_team]['3_points'] += 1\n end\n\n # make sure hash is generated when no games have been played yet\n else\n row_holder[g.home_team]['played'] += 0\n row_holder[g.away_team]['played'] += 0\n end\n end\n\n\n\n #convert the row_holder hash to a sorted array\n sort_ranking(row_holder)\n end", "def state_wins\n WINS.map { |win| [ $state[win[0]], $state[win[1]], $state[win[2]] ] }\nend", "def winning_team\n most_points_scored_helper\n winning_team = \"\"\n \n game_hash.each do |key, value|\n players = value[:players]\n players.each do |element|\n if most_points_scored_helper == element[:points]\n winning_team = value[:team_name]\n end\n end\n end\n winning_team\nend", "def wins_ball(winner)\n # this is where we increment the winner of each ball by 1 point\n if winner == 1\n @player1.record_won_ball!\n #Player.record_won_ball!(@player1)\n elsif winner == 2\n @player2.record_won_ball!\n end\n\n\n end", "def tabulate_outcomes(state)\n #return early if we have a cached solution for the given [state]\n if out = @TAB_CACHE[state.board_bits]\n return out\n end\n \n @iteration_count += 1\n out = {x: 0, o: 0, cat:0}\n \n #if this state has a winner, it's easy\n if w = state.winner\n out[w] = 1\n case w\n when @opponent\n out[:worst] = -1\n when @playing_mark\n out[:worst] = 1\n else\n out[:worst] = 0\n end\n \n return out\n end\n \n #loop through each possible move\n state.legal_moves.each do |q|\n outcomes = tabulate_outcomes q\n \n #raw counts\n [:x, :o, :cat].each {|k| out[k] += outcomes[k]}\n \n #if it's the other player's turn assume they make the best move they can, and vice versa\n if state.next_turn_taker == @opponent\n out[:worst] = outcomes[:worst] if (!out[:worst] || (outcomes[:worst] < out[:worst]))\n else\n out[:worst] = outcomes[:worst] if (!out[:worst] || (outcomes[:worst] > out[:worst]))\n end\n end\n \n cache_solution(state, out)\n \n return out\n end", "def record_won_game!\n if @game_points >= 5 && @game_points >= @opponent.game_points + 2\n\n record_won_set!\n end\n end", "def update_player_record\n winner = self.winner.player\n loser = self.loser.player\n\n Player.find(winner.id).add_win\n Player.find(loser.id).add_loss\n\n Player.find(winner.id).calculate_win_percentage\n Player.find(loser.id).calculate_win_percentage\n\n # General Elo update\n EloRating.k_factor = 36\n elo_match = EloRating::Match.new\n elo_match.add_player(rating: winner.elo, winner: true)\n elo_match.add_player(rating: loser.elo)\n\n new_winner_elo = elo_match.updated_ratings[0]\n new_loser_elo = elo_match.updated_ratings[1]\n\n self.elo_delta = loser.elo - new_loser_elo\n\n winner.max_elo_check(new_winner_elo)\n\n winner.update_elo(new_winner_elo)\n loser.update_elo(new_loser_elo)\n\n # Format Elo update\n format_match = EloRating::Match.new\n\n format = self.tournament.format\n if format == 'Dark Draft'\n format_match.add_player(rating: winner.dark_draft_elo, winner: true)\n format_match.add_player(rating: loser.dark_draft_elo)\n\n new_winner_elo = format_match.updated_ratings[0]\n new_loser_elo = format_match.updated_ratings[1]\n\n self.format_elo_delta = loser.dark_draft_elo - new_loser_elo\n\n winner.max_dark_draft_elo_check(new_winner_elo)\n\n winner.update_dark_draft_elo(new_winner_elo)\n loser.update_dark_draft_elo(new_loser_elo)\n elsif format == 'Constructed'\n format_match.add_player(rating: winner.constructed_elo, winner: true)\n format_match.add_player(rating: loser.constructed_elo)\n\n new_winner_elo = format_match.updated_ratings[0]\n new_loser_elo = format_match.updated_ratings[1]\n\n self.format_elo_delta = loser.constructed_elo - new_loser_elo\n\n winner.max_constructed_elo_check(new_winner_elo)\n\n winner.update_constructed_elo(new_winner_elo)\n loser.update_constructed_elo(new_loser_elo)\n end\n end", "def play_game_with_current_moves\n winners = get_games_winners\n save_winners(winners) unless winners.nil?\n winners\n end", "def games(meeting, record)\n meeting.each do |play|\n if play[:home_score].to_i > play[:away_score].to_i\n record[play[:home_team]][\"W\"] += 1\n record[play[:away_team]][\"L\"] += 1\n else play[:home_score].to_i < play[:away_score].to_i\n record[play[:away_team]][\"W\"] += 1\n record[play[:home_team]][\"L\"] += 1\n end\n end\n record\nend", "def record_results(winner, loser, is_tie)\n if !user_exist?(winner)\n add_user(winner)\n end\n if !user_exist?(loser)\n add_user(loser)\n end\n \n increment_field(winner, 'Played')\n increment_field(loser, 'Played')\n if !is_tie\n increment_field(winner, 'Wins')\n increment_field(loser, 'Losses')\n end\n end", "def rps_game_winner(game)\n hash = Hash[*game.flatten()]\n raise WrongNumberOfPlayersError unless (game.length && hash.size) == 2 \n strat_check(hash)\n winner = comp_to(hash)\n puts \"#{winner}\"\nend", "def view_leaderboard(user)\n system('clear')\n winpercenthash = {}\n gd = {}\n i = 0\n noncheated = GameSession.all.select do |game| \n game.word_id != nil\n end\n arrtotal = noncheated.map do |game|\n User.find(game.user_id)\n end\n arrwin = noncheated.select do |game|\n game.win == true\n end\n arrwin.map! do |game|\n User.find(game.user_id)\n end\n ftotal = freq(arrtotal)\n fwin = freq(arrwin)\n arrtotal.each do |user|\n winpercenthash[user] = fwin[user].to_f / ftotal[user] * 100\n end\n ordered_array = ftotal.sort_by {|k,v| v}.reverse\n for i in 0..ordered_array.length-1 do\n gd[ordered_array[i][0]] = winpercenthash[ordered_array[i][0]] \n end \n ordered_array = gd.sort_by {|k,v| v}.reverse\n if ordered_array.length == 0\n puts \"There are no records to show yet!\\n\"\n elsif ordered_array.length < 5 && ordered_array.length > 0\n for i in 0..ordered_array.length-1 \n puts \"#{ordered_array[i][0].name} won #{ordered_array[i][1].round(2)}% of their games over the course of #{ftotal[ordered_array[i][0]]} games\" \n username = ordered_array[i][0].name\n percent = ordered_array[i][1].round(2)\n numgames = ftotal[ordered_array[i][0]]\n forindex = i\n indexmax = ordered_array.length-1\n print_table(username, percent, numgames, forindex, indexmax)\n end\n else\n for i in 0..4\n username = ordered_array[i][0].name\n percent = ordered_array[i][1].round(2)\n numgames = ftotal[ordered_array[i][0]]\n forindex = i\n print_table(username, percent, numgames, forindex, 4) \n end\n end\n puts \"Press Enter to Continue...\"\n gets.chomp\n system('clear')\n menu(user)\nend", "def games_won(player)\n\t\ttiebreak_win = tiebreak && tiebreak.winner_id.eql?(player.id) ? 1 : 0\n\t\tgames.where(winner_id: player.id).count + tiebreak_win\n\tend", "def play\n log = []\n round = 1\n while round <= 9 && @winner.nil?\n log << make_move(@current_player)\n @winner = has_winner?\n puts \"Win for #{@winner.stone}\" if @winner && @display_output\n round += 1\n @current_player = @current_player == @player_one? @player_two : @player_one\n end\n outcome = has_winner? ? @winner.value : 0.0\n # append the outcome to each row of the log\n return log, outcome\n end", "def calculate_money\n return_data = {lose: 0.0, win: 0.0}\n \n self.bet_scores.each do |e|\n if e.match.result && e.match.result == e.score\n return_data[:win] += e.money\n else\n return_data[:lose] += e.money\n end\n end\n\n self.update_attributes({lose: return_data[:lose], win: return_data[:win]})\n end", "def matches\n @wins + @losses + @draws\n end", "def winning_team\n home_points = collection_by_prop(game_hash[:home], :points).reduce(0, :+)\n away_points = collection_by_prop(game_hash[:away], :points).reduce(0, :+)\n home_points > away_points ? game_hash[:home][:team_name] : game_hash[:away][:team_name]\n end", "def winner(board)\n if winning_combination = won?(board)\n board[winning_combination[0]]\n end\nend", "def player_moves(board)\n\t\tnew_hash_o = {} # Holds the winning combination positions the other player is occupying\n\t\tnew_hash_c = {} # Holds the winning combination positions the current player is occupying\n\t\tfinal_hash_o = {} # Holds the other player winning combination that need to be blocked on the next move\n\t\tfinal_hash_c = {} # Holds the move to be made for the current player winning combination\n\t\tWIN_COMBINATIONS.each do |k,v| # Check which of the other player's and current player's positions are part of a winning combination\n\t\t new_hash_o[k] = []\n\t\t new_hash_c[k] = []\n\t\t @other_player_positions.each do |t| # Check which of the other player's positions are part of a winning combination\n\t\t\t if v.include?(t)\n\t\t\t \tnew_hash_o[k] << t # If the position is part of a winning combination include it in the new hash\n\t\t \tend\n\t\t end\n\t\t @current_player_positions.each do |t| # Check which of the current player's positions are part of a winning combination\n\t\t\t if v.include?(t)\n\t\t\t \tnew_hash_c[k] << t # If the position is part of a winning combination include it in the new hash\n\t\t \tend\n\t\t end\n\t\tend\n\t\t@other_player_positions = [] # Clear the other player position results ready for the next turn\n\t\t@current_player_positions = [] # Clear the current player position results ready for the next turn\n\t\tnew_hash_o.each do |k,v| # Check whether the other player has one move to go on a winning combination\n\t\t\t# If there are two positions of a winning combination held by the other player include the combination in the final hash\n\t\t\tif new_hash_o[k].size > 1\n\t\t\t\tfinal_hash_o[k] = new_hash_o[k] # Final hash holds the vulnerable positions that need to be filled\n\t\t\tend\n\t\tend\n\t\tnew_hash_c.each do |k,v| # Check whether the current player has one move to go on a winning combination\n\t\t\t# If there are two positions of a winning combination held by the current player include the combination in the final hash\n\t\t\tif new_hash_c[k].size > 1\n\t\t\t\tfinal_hash_c[k] = new_hash_c[k] # Final hash holds the winning positions that need to be filled\n\t\t\tend\n\t\tend\n\t\t# Find the final position to move to block the other player's winning combination\n\t\t # Find the final position for current player to move to win\n\t\tWIN_COMBINATIONS.each do |k,v|\n\t\t\tif final_hash_o.include?(k)\n\t\t\t\t@move_o << WIN_COMBINATIONS[k] - final_hash_o[k]\n\t\t\t\tif !board.valid_move?(@move_o[0][0]) # Check whether the final position is a valid move\n\t\t\t\t\t@move_o.shift # If not a valid position remove the final move\n\t\t\t\tend\n\t\t\tend\n\t\t\tif final_hash_c.include?(k)\n\t\t\t\t@move_c << WIN_COMBINATIONS[k] - final_hash_c[k]\n\t\t\t\tif !board.valid_move?(@move_c[0][0]) # Check whether the final position is a valid move\n\t\t\t\t\t@move_c.shift # If not a valid position remove the final move from the array\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\tif !@move_o.empty? # Don't test and pass an empty array\n\t\t\t\t@move_o = @move_o.sample # Only one move can be made\n\t\t\t\t@move_o # Final move to block the other player's winning combination\n\t\tend\n\t\tif !@move_c.empty? # Don't test and pass an empty array\n\t\t\t\t@move_c = @move_c.sample # Only one move can be made\n\t\t\t\t@move_c # Final move to block the other player's winning combination\n\t\tend\n\tend", "def player_outcome(plays)\n return :WIN if ProtectedConstants::WINNERS.include?(plays)\n return :LOSE if ProtectedConstants::LOSERS.include?(plays)\n return :TIE if !:WIN | !:LOSE\n end", "def find_winner()\n\t\tingame_players = 0\n\t\tlast_cards = []\n\n\t\t#puts \"In find winner method\"\n\t\tputs to_s\n\n\t\t@players.each do |player|\n\t\t\n\n\t\t\tif !player.is_fold\n\t\t\t\tlast_cards << player.get_cards\n\t\t\t\t\n\t\t\tend\n\n\t\tend\n\t\t@players.each do |player|\n\t\t\t\n\n\t\t\tif !player.is_fold\n\t\t\t\t\n\t\t\t\tputs\n\t\t\t\tplayer.increase_game\n\t\t\t\t#i = last_cards.index(player.get_cards)\n\t\t\t\t#last_cards.insert(0, last_cards.delete_at(i)) \n\t\t\t\tcards_of_players = \"#{last_cards.join(\"\")}\"\n\t\t\t\t#puts \"Order of cards: \" + cards_in_order\n\t\t\t\t#puts \"get cards: \" + get_cards\n\t\t\t\twinner = @pokeroddsproxy.get_winnercards(cards_of_players, get_cards)\n\t\t\t\t#odds = @pokeroddsproxy.get_odds(cards_in_order, get_cards, ingame_players)\n\t\t\t\t#puts odds\n\n\t\t\t\tif winner == player.get_cards #If winner's cards are same with the player\n\t\t\t\t\tputs \"#{player.get_name} is the winner\"\n\t\t\t\t\tplayer.addmoney(@pot)\n\t\t\t\t\tplayer.increase_win\n\t\t\t\telse\n\t\t\t\t\tputs \"#{player.get_name} is the loser\"\n\t\t\t\t\tplayer.increase_lose\n\t\t\t\tend\n\n\t\t\tend\n\n\t\tend\n\n\tend", "def check_for_win(game)\n return nil if game.turns.size < 5 \n\n xs = game.turns.where(mark: 'X').map {|turn| turn.board_index }\n os = game.turns.where(mark: 'O').map {|turn| turn.board_index }\n\n @@win_conditions.each do |win|\n # Check if xs or os contain indices combo that meet win condition\n if (win-xs).empty?\n return [\"X\", win.join(' ')]\n elsif (win-os).empty?\n return [\"O\",win.join(' ')]\n end\n end\n\n if game.turns.size > 8\n return [\"TIE\",\"\"]\n else\n return nil\n end\n end", "def get_games_winners\n tally = all_player_tally #tally is a hash with the combination of scores between all players\n winner_tally = hash_select_by_max_key(tally)\n return convert_hash_keys_to_array(winner_tally)\n end", "def winner\n if winning_array = won?\n @board[winning_array[0]]\n end\n end", "def winner\n @winner\n end", "def match_over(winning_side)\n self.update!(status: \"over\")\n \n create_results(winning_side)\n end", "def edge\n competition.matches.where(\"(player_id = ? OR opponent_id = ?) AND round = ?\", winner_id, winner_id, round + 1).first\n end", "def determine_win\n\t\t@win_combos.each do |combo|\n\t\t\tp1 = (@p1_spaces & combo).length\n\t\t\tp2 = (@p2_spaces & combo).length\n\n\t\t\tif p1 == 3\n\t\t\t\treturn 1\n\t\t\t\tp1.games_won += 1\n\t\t\telsif p2 == 3\n\t\t\t\treturn 2\n\t\t\t\tp2.games_won += 1\n\t\t\tend\n\t\tend\n\t\t0\n\tend", "def update_score_from_games!\n return if self.games.count == 0\n score_by_steam_id = {}\n self.games.each do |g|\n # Add one point to winning team, 0 to losing team so that they show up in the keyset when we check later\n if g.radiant_win === true\n score_by_steam_id[g.radiant_team_id] = score_by_steam_id[g.radiant_team_id].to_i + 1\n score_by_steam_id[g.dire_team_id] = score_by_steam_id[g.dire_team_id].to_i\n elsif g.radiant_win === false\n score_by_steam_id[g.radiant_team_id] = score_by_steam_id[g.radiant_team_id].to_i\n score_by_steam_id[g.dire_team_id] = score_by_steam_id[g.dire_team_id].to_i + 1\n end\n end\n\n # OK the keys are team ids, so now save them\n if score_by_steam_id[self.home_participant.id] != nil && score_by_steam_id[self.away_participant.id] != nil\n self.home_score = score_by_steam_id[self.home_participant.id]\n self.away_score = score_by_steam_id[self.away_participant.id]\n self.save!\n else\n puts score_by_steam_id.inspect\n puts self.home_participant_id.inspect\n puts self.away_participant_id.inspect\n puts \"WARNING: teams did not match, not updating match score\"\n end\n end", "def result\n loser = game_players.find do |game_player|\n game_player.ships.all?(&:sunk?) && game_player.ships.size > 0\n end\n\n if loser\n return game_players.find { |game_player| game_player.id != loser.id }\n end\n end", "def compute_fight_statistics(fighter1, fighter2, punches_counter)\n fight_result = {}\n\n # Fighter 1 win (KO or decision)\n if fighter2.health <= 0 || (fighter1.health.positive? && punches_counter[fighter1.id] > punches_counter[fighter2.id])\n fight_result[:winner_id] = fighter1.id\n fight_result[:winner_punches] = punches_counter[fighter1.id]\n\n fight_result[:looser_id] = fighter2.id\n fight_result[:looser_punches] = punches_counter[fighter2.id]\n \n # Fighter 2 win (KO or decision)\n elsif fighter1.health <= 0 || (fighter2.health.positive? && punches_counter[fighter2.id] > punches_counter[fighter1.id])\n fight_result[:winner_id] = fighter2.id\n fight_result[:winner_punches] = punches_counter[fighter2.id]\n\n fight_result[:looser_id] = fighter1.id\n fight_result[:looser_punches] = punches_counter[fighter1.id]\n\n # Random winner according to really nice artistic move during fight judged by jury (exceptionnal case)\n else\n winner_looser = fighter_order\n\n fight_result[:winner_id] = winner_looser[0].id\n fight_result[:winner_punches] = punches_counter[winner_looser[0].id]\n\n fight_result[:looser_id] = winner_looser[1].id\n fight_result[:looser_punches] = punches_counter[winner_looser[1].id]\n end\n\n fight_result[:victory_type]= fighter1.health <= 0 || fighter2.health <= 0 ? :KO : :decision\n\n fight_result\n end", "def status\r\n \r\n {:player_cards => @player_hand.cards,\r\n :player_value => @player_hand.value,\r\n :dealer_cards => @dealer_hand.cards,\r\n :dealer_value => @dealer_hand.value,\r\n :winner => @winner}\r\n if @player_hand.value > 21 or @dealer_hand.value > 21\r\n @winner = determine_winner(@player_hand.value, @dealer_hand.value) \r\n puts \"BUSTED\"\r\n puts \"player-value = #{@player_hand.value}\"\r\n puts \"dealer-value = #{@dealer_hand.value}\"\r\n puts \"winner is #{@winner}\"\r\n else\r\n #puts \"player-cards = #{@player_hand.cards}\"\r\n #puts \"dealer-cards = #{@dealer_hand.cards}\"\r\n puts \"player-value = #{@player_hand.value}\"\r\n puts \"dealer-value = #{@dealer_hand.value}\" \r\n end\r\n end", "def winning_team\n home_score = 0\n away_score = 0\n game_hash[:home][:players].keys.each do |name|\n home_score += game_hash[:home][:players][name][:points]\n end\n game_hash[:away][:players].keys.each do |name|\n away_score += game_hash[:away][:players][name][:points]\n end\n home_score > away_score ? game_hash[:home][:team_name] : game_hash[:away][:team_name]\nend", "def winner\n winners = []\n @players.each do | player |\n winners << player[\"player_symbol\"] if player[\"player_position\"] == 29\n end\n winners.length > 0 ? winners.flatten : nil\n end", "def winner\n return nil if player_one_move == player_two_move\n winning_combinations = { 'rock' => 'scissors', 'scissors' => 'paper', 'paper' => 'rock' }\n {\n true => player_one,\n false => player_two,\n }[winning_combinations[player_one_move] == player_two_move]\n end", "def winner(board)\n if win_combo = won?(board)\n board[win_combo.first]\n end\nend", "def populate_winner\n if competitor_1_score > competitor_2_score\n self.winner_id = match.get_competitor_1.id\n elsif competitor_1_score < competitor_2_score\n self.winner_id = match.get_competitor_2.id\n else\n self.winner_id = nil\n end\n end", "def winner\r\n win_combination = won?\r\n if win_combination\r\n win_index = win_combination[0]\r\n @board[win_index]\r\n end\r\n end" ]
[ "0.6623447", "0.6613258", "0.6560347", "0.6535278", "0.65263253", "0.6525705", "0.6408602", "0.64023167", "0.6400197", "0.6385025", "0.6358206", "0.63417935", "0.6323447", "0.63146174", "0.6302956", "0.6301062", "0.63010114", "0.6291477", "0.6261969", "0.6261372", "0.6259742", "0.62597", "0.6244814", "0.6241988", "0.62183875", "0.6208101", "0.61957306", "0.6188885", "0.6180813", "0.6152541", "0.6146859", "0.61406755", "0.61274046", "0.612698", "0.61138314", "0.6106277", "0.6104233", "0.6103745", "0.60918987", "0.6090665", "0.6086936", "0.6083101", "0.60819536", "0.6081517", "0.6076744", "0.6076744", "0.6069509", "0.60692126", "0.6068952", "0.60672116", "0.6053482", "0.6053447", "0.6051478", "0.6048844", "0.604466", "0.6038968", "0.6033312", "0.60205406", "0.60186315", "0.6018068", "0.6012124", "0.59981656", "0.5982862", "0.5970822", "0.5960547", "0.5953742", "0.59464794", "0.59424126", "0.594187", "0.59401023", "0.59325445", "0.592365", "0.5923027", "0.59175146", "0.59156305", "0.59081167", "0.5899845", "0.5899505", "0.5889696", "0.5883199", "0.5879679", "0.5873409", "0.58723116", "0.5860106", "0.5859764", "0.5856963", "0.5855226", "0.5850033", "0.58447677", "0.5824222", "0.5822296", "0.5819737", "0.5818499", "0.5817032", "0.5812693", "0.580879", "0.5808409", "0.58076745", "0.58064115", "0.58044076", "0.58035076" ]
0.0
-1
GET /fault_books GET /fault_books.json
def index @fault_books = FaultBook.where(:truck_fleet_id => current_user.truck_fleet.id) @fault_books = FaultBook.belongs_to_truck_fleet(current_user.truck_fleet, @fault_books) if current_user.admin? respond_to do |format| format.html # index.html.erb format.json { render json: @fault_books } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def list_books\n books = Book.all\n \n if books.count > 0\n render json: books\n else\n render json: {e:\"No books added\"}, :status => :error\n end\n end", "def fetch_books(term)\n response = RestClient.get(\"https://www.googleapis.com/books/v1/volumes?q=#{term}\")\n\n JSON.parse(response.body)\n end", "def order_book(params)\n Client.current.get(\"#{resource_url}/book\", params)\n end", "def fetch_books(term)\n response = RestClient.get(\"https://www.googleapis.com/books/v1/volumes?q=#{term}\")\n\n JSON.parse(response.body)\nend", "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 index\n @resumes = Resume.where(:book_id => params[:book_id])\n\n render json: @resumes\n end", "def index\n @books = Book.get_avaible_books\n end", "def index\n if params[:book_id]\n @book = Book.find(params[:book_id])\n recipes = @book.recipes\n render json: RecipeSerializer.new(recipes).to_serialized_json\n else \n recipes = Recipe.all.order(:name)\n render json: RecipeSerializer.new(recipes).to_serialized_json\n end\n end", "def index\n # @bookings = Booking.all\n begin\n @response = Booking.get_bookings\n rescue RestClient::Exception => exception\n @error = exception.response\n end\n # binding.pry\n end", "def book\n fetch('harry_potter.books')\n end", "def get_books(response)\n response[\"items\"]\nend", "def cmd_get_faults argv\n setup argv\n uuid = @hash['uuid']\n response = @api.get_faults(uuid)\n if response.is_a?(Array)\n response.each do | r |\n msg r\n end\n else\n msg response\n end\n return response\n end", "def show\n @library_book = LibraryBook.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @library_book }\n end\n end", "def get_address_books\n self.class.get('https://api.yesgraph.com/v0/address-books', :headers => @options)\n end", "def index\n @books = Book.all\n render json: @books\n end", "def index\n @books = Book.all\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @books }\n end\n end", "def new\n @fault_book = FaultBook.new\n @fault_book.fault_date = Date.today.strftime(\"%d-%m-%Y\")\n \n @drivers = current_user.truck_fleet.drivers\n @fleets = current_user.truck_fleet.fleets\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @fault_book }\n end\n end", "def index\n @death_record_books = DeathRecordBook.all\n @death_record_books = DeathRecordBook.order(params[:sort])\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @death_record_books }\n end\n end", "def index\n @books = Book.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @books }\n end\n end", "def fetch_book_info\n url = \"#{BASE_URL}/#{book_id}\"\n resp = RestClient::Request.execute(url: url, method: \"GET\")\n resp_obj = JSON.parse(resp)\n\n {\n id: book_id,\n title: resp_obj[\"volumeInfo\"][\"title\"],\n author: resp_obj[\"volumeInfo\"][\"authors\"][0],\n image: resp_obj[\"volumeInfo\"][\"imageLinks\"] ? resp_obj[\"volumeInfo\"][\"imageLinks\"][\"thumbnail\"] : DEFAULT_IMAGE\n }\n end", "def index\n @books = Book.extended_details\n\n render json: @books.as_json(\n only: [:id, :title, :author, :created_at, :total_income_cents, :copies_count, :remaining_copies_count, :loaned_copies_count]\n )\n end", "def index\n @cookbooks = Cookbook.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @cookbooks }\n end\n end", "def book\n @book = Book.published.find(params[:id])\n render json: @book\n end", "def index\n @books = Book.find(:all, :conditions => { :deleted => false })\n @book_request = Book.count(:request, :conditions => { :request => false})\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @books }\n end\n end", "def index\n authorize! :query, Book\n @books = Book.order(:title)\n respond_to do |format|\n format.html\n format.json {render text: @books.to_json}\n format.xml {render text: @books.to_xml}\n end\n end", "def index\n @library_books = LibraryBook.all\n end", "def index\n @book_pages = @book.book_pages\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @book_pages }\n end\n end", "def index\n @books = @collection.books\n #original: @books = Book.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @books }\n end\n end", "def index\n @book = Book.find(params[:book_id])\n end", "def show\n if (params[:print])\n @fault_book = FaultBook.find(params[:id])\n\n respond_to do |format|\n format.html { render :layout => 'print' }# show.html.erb\n format.json { render json: @fault_book, :layout => 'print' }\n end\n else \n @fault_book = FaultBook.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @fault_book }\n end\n end\n end", "def index\n @borrowed_books = BorrowedBook.all\n end", "def index\n @borrowed_books = BorrowedBook.all\n end", "def index\n @borrowed_books = BorrowedBook.all\n end", "def index\n @book_steps = @book.book_steps.all\n @book = @book\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @book_steps }\n end\n end", "def index\n @order_books = OrderBook.all\n end", "def get_books()\n @books_out\n end", "def get_books()\n @books_out\n end", "def set_book\n @book = Book.find(params[:id])\n rescue ActiveRecord::RecordNotFound\n render json: book_not_found, :status => 404\n rescue\n render json: internal_server_error, :status => 500\n end", "def index\n @damagebooks = Damagebook.all\n end", "def show\n @book = Book.find(params[:id])\n\n respond_to do |format|\n\n format.json { render json: @book }\n end\n end", "def index\n @books = Book.find_all_by_user_id(current_user)\n\n respond_to do |format|\n format.html\n format.json { render json: @books }\n end\n end", "def index\n load_data\n @books = Book.all\n end", "def index\n @user_books = UserBook.all\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @user_books }\n end\n end", "def book_info_goodreads_library\n client = Goodreads::Client.new(Goodreads.configuration)\n results = client.book_by_title(params[:q])\n rescue\n []\n end", "def show\n render json: @api_book\n end", "def book_info_open_library\n client = Openlibrary::Client.new\n results = client.search(params[:q])\n rescue\n []\n end", "def index\n @confirmation_books = ConfirmationBook.all\n @confirmation_books = ConfirmationBook.order(params[:sort])\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @confirmation_books }\n end\n end", "def index\n @books = Book.order('created_at DESC').page(params[:page]).per_page(10).search(params[:search], params[:id])\n respond_to do |format|\n format.json\n format.html\n end\n end", "def index\n @books = Book.all\n @submitted_books = Book.submitted\n @approved_books = Book.approved\n @deactivated_books = Book.deactivated\n @book=Book.first\n end", "def index\n @author_books = AuthorBook.all\n end", "def set_book\n @book = Book.find(params[:id])\n rescue ActiveRecord::RecordNotFound\n render json: { object: 'Book'}, status: :not_found\n end", "def get_book\n @book_series = BookSeries.find(params[:book_series_id])\n @book_series_1 = BookSeries.first\n @collection = @book_series.collections.find(params[:collection_id])\n @book = @collection.books.find(params[:book_id])\n end", "def get_book\n @book_series = BookSeries.find(params[:book_series_id])\n @book_series_1 = BookSeries.first\n @collection = @book_series.collections.find(params[:collection_id])\n @book = @collection.books.find(params[:book_id])\n end", "def index\n books = current_user.books.all\n render json: { books: books }\n end", "def index\r\n @books = Book.paginate(:page => params[:page], :per_page => 30)\r\n\r\n respond_to do |format|\r\n format.html # index.html.erb\r\n format.json { render json: @books }\r\n end\r\n end", "def retrieve_book\n @book = Book.find(params[:book_id])\n end", "def index\n #@books = Book.all\n end", "def index\n @book_items = BookItem.all\n end", "def index\n @book_items = BookItem.all\n end", "def get_book( book_id )\n response = if book_id.to_s.length >= 10\n Amazon::Ecs.item_lookup( book_id, :id_type => 'ISBN', :search_index => 'Books', \n :response_group => 'Large,Reviews,Similarities,AlternateVersions' )\n else\n Amazon::Ecs.item_lookup( book_id, :response_group => 'Large,Reviews,Similarities' )\n end\n response.items.each do |item|\n binding = item.get('ItemAttributes/Binding')\n next if binding.match(/Kindle/i)\n return Book.new( item )\n end\n return nil\n end", "def show\n find_book(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @book }\n end\n end", "def show\n @cookbook = Cookbook.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @cookbook }\n end\n end", "def index\n @books = []\n if (params[:q])\n @books = Book.where(params[:q])\n end\n render :json => @books\n end", "def index\n @service_faults = ServiceFault.all\n end", "def show\n @cook_book = CookBook.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @cook_book }\n end\n end", "def show\n @book = Book.find(params[:id])\n @book.book_visit_count\n if(current_user.present?)\n @book.book_visit_user(current_user.id)\n end\n # if stale?(:etag => @book.id, :last_modified => @book.updated_at, :public => true)\n render json: @book \n # end\n rescue => e\n render json: {error_code: Code[:error_rescue], error_message: e.message}, status: Code[:status_error]\n end", "def show\n @book = Book.find(params[:id])\n @book.book_visit_count\n if(current_user.present?)\n @book.book_visit_user(current_user.id)\n end\n # if stale?(:etag => @book.id, :last_modified => @book.updated_at, :public => true)\n render json: @book \n # end\n rescue => e\n render json: {error_code: Code[:error_rescue], error_message: e.message}, status: Code[:status_error]\n end", "def index\n @book_infos = BookInfo.all\n @book_details = BookDetail.all\n end", "def get_book(search)\n\trequest_string = \"https://www.googleapis.com/books/v1/volumes?q=#{search.gsub(\" \",\"+\")}\"\n\t\n\tsample_uri = URI(request_string) #opens a portal to the data at that link\n\tsample_response = Net::HTTP.get(sample_uri) #go grab the data in the portal\n\tsample_parsedResponse = JSON.parse(sample_response) #makes data easy to read\n\tsample_parsedResponse[\"items\"]\nend", "def list\n @books = Book.all\n end", "def show\n @death_record_book = DeathRecordBook.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @death_record_book }\n end\n end", "def update\n @fault_book = FaultBook.find(params[:id])\n\n respond_to do |format|\n if @fault_book.update_attributes(params[:fault_book])\n format.html { redirect_to @fault_book, notice: 'Fault book was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @fault_book.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @title = \"List Books\"\n @books = Book.paginate :page=>params[:page], :per_page => 100, :order => 'title'\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @books }\n end\n end", "def index\n @books = Book.all\n end", "def index\n @books = Book.all\n end", "def index\n @books = Book.all\n end", "def index\n @books = Book.all\n end", "def index\n @books = Book.all\n end", "def index\n @books = Book.all\n end", "def index\n @books = Book.all\n end", "def index\n @books = Book.all\n end", "def index\n @books = Book.all\n end", "def index\n @books = Book.all\n end", "def index\n @books = Book.all\n end", "def index\n @books = Book.all\n end", "def index\n @books = Book.all\n end", "def index\n @books = Book.all\n end", "def index\n @books = Book.all\n end", "def index\n @books = Book.all\n end", "def index\n @books = Book.all\n end", "def index\n @books = Book.all\n end", "def index\n @books = Book.all\n end", "def index\n @books = Book.all\n end", "def index\n @books = Book.all\n end", "def index\n @books = Book.all\n end", "def index\n @books = Book.all\n end", "def index\n @books = Book.all\n end", "def index\n @books = Book.all\n end", "def index\n @books = Book.all\n end", "def search_book_by_name(book)\n url = \"https://www.googleapis.com/books/v1/volumes?q=#{URI::encode(book)}&key=#{get_access_key}\"\n\tres = JSON.load(RestClient.get(url))\n return res\t\nend" ]
[ "0.63696027", "0.6341354", "0.6305479", "0.62837493", "0.6243981", "0.6160719", "0.61571926", "0.6149036", "0.611919", "0.6108336", "0.608437", "0.606763", "0.605276", "0.6035397", "0.60019034", "0.59929997", "0.59777415", "0.5968184", "0.59578407", "0.5952363", "0.5929105", "0.5918226", "0.59107137", "0.58869684", "0.5875281", "0.5873167", "0.5869583", "0.5869145", "0.58568573", "0.58184206", "0.5795432", "0.5795432", "0.5795432", "0.5792815", "0.5790755", "0.5790395", "0.5790395", "0.57880145", "0.578134", "0.5776403", "0.5776081", "0.5770691", "0.5757921", "0.5748602", "0.5730047", "0.5713165", "0.57104325", "0.5709856", "0.57067406", "0.5705666", "0.5701206", "0.5698124", "0.5698124", "0.5697797", "0.56952316", "0.56944305", "0.5693872", "0.56934637", "0.56934637", "0.56921875", "0.56874925", "0.5685219", "0.5682305", "0.5677857", "0.5675837", "0.56737363", "0.56737363", "0.56714296", "0.5665327", "0.5664752", "0.566074", "0.56591636", "0.56523013", "0.56511676", "0.56511676", "0.56511676", "0.56511676", "0.56511676", "0.56511676", "0.56511676", "0.56511676", "0.56511676", "0.56511676", "0.56511676", "0.56511676", "0.56511676", "0.56511676", "0.56511676", "0.56511676", "0.56511676", "0.56511676", "0.56511676", "0.56511676", "0.56511676", "0.56511676", "0.56511676", "0.56511676", "0.56511676", "0.56511676", "0.5644621" ]
0.72194237
0
GET /fault_books/1 GET /fault_books/1.json
def show if (params[:print]) @fault_book = FaultBook.find(params[:id]) respond_to do |format| format.html { render :layout => 'print' }# show.html.erb format.json { render json: @fault_book, :layout => 'print' } end else @fault_book = FaultBook.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render json: @fault_book } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @fault_books = FaultBook.where(:truck_fleet_id => current_user.truck_fleet.id)\n @fault_books = FaultBook.belongs_to_truck_fleet(current_user.truck_fleet, @fault_books) if current_user.admin?\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @fault_books }\n end\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 fetch_books(term)\n response = RestClient.get(\"https://www.googleapis.com/books/v1/volumes?q=#{term}\")\n\n JSON.parse(response.body)\nend", "def fetch_books(term)\n response = RestClient.get(\"https://www.googleapis.com/books/v1/volumes?q=#{term}\")\n\n JSON.parse(response.body)\n end", "def show\n @library_book = LibraryBook.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @library_book }\n end\n end", "def index\n @resumes = Resume.where(:book_id => params[:book_id])\n\n render json: @resumes\n end", "def order_book(params)\n Client.current.get(\"#{resource_url}/book\", params)\n end", "def index\n if params[:book_id]\n @book = Book.find(params[:book_id])\n recipes = @book.recipes\n render json: RecipeSerializer.new(recipes).to_serialized_json\n else \n recipes = Recipe.all.order(:name)\n render json: RecipeSerializer.new(recipes).to_serialized_json\n end\n end", "def book\n @book = Book.published.find(params[:id])\n render json: @book\n end", "def index\n # @bookings = Booking.all\n begin\n @response = Booking.get_bookings\n rescue RestClient::Exception => exception\n @error = exception.response\n end\n # binding.pry\n end", "def new\n @fault_book = FaultBook.new\n @fault_book.fault_date = Date.today.strftime(\"%d-%m-%Y\")\n \n @drivers = current_user.truck_fleet.drivers\n @fleets = current_user.truck_fleet.fleets\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @fault_book }\n end\n end", "def fetch_book_info\n url = \"#{BASE_URL}/#{book_id}\"\n resp = RestClient::Request.execute(url: url, method: \"GET\")\n resp_obj = JSON.parse(resp)\n\n {\n id: book_id,\n title: resp_obj[\"volumeInfo\"][\"title\"],\n author: resp_obj[\"volumeInfo\"][\"authors\"][0],\n image: resp_obj[\"volumeInfo\"][\"imageLinks\"] ? resp_obj[\"volumeInfo\"][\"imageLinks\"][\"thumbnail\"] : DEFAULT_IMAGE\n }\n end", "def list_books\n books = Book.all\n \n if books.count > 0\n render json: books\n else\n render json: {e:\"No books added\"}, :status => :error\n end\n end", "def show\n @book = Book.find(params[:id])\n\n respond_to do |format|\n\n format.json { render json: @book }\n end\n end", "def show\n @cookbook = Cookbook.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @cookbook }\n end\n end", "def index\n @books = Book.all\n render json: @books\n end", "def get_books(response)\n response[\"items\"]\nend", "def index\n @books = Book.all\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @books }\n end\n end", "def index\n @books = Book.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @books }\n end\n end", "def index\n @cookbooks = Cookbook.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @cookbooks }\n end\n end", "def index\n @books = Book.extended_details\n\n render json: @books.as_json(\n only: [:id, :title, :author, :created_at, :total_income_cents, :copies_count, :remaining_copies_count, :loaned_copies_count]\n )\n end", "def book\n fetch('harry_potter.books')\n end", "def show\n @cook_book = CookBook.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @cook_book }\n end\n end", "def show\n find_book(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @book }\n end\n end", "def set_book\n @book = Book.find(params[:id])\n rescue ActiveRecord::RecordNotFound\n render json: book_not_found, :status => 404\n rescue\n render json: internal_server_error, :status => 500\n end", "def show\n render json: @api_book\n end", "def show\n\n @book = Book.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @book }\n end\n end", "def show\n\n @book = Book.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @book }\n end\n end", "def show\n @book = Book.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @book }\n end\n end", "def show\n @book = Book.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @book }\n end\n end", "def show\n @book = Book.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @book }\n end\n end", "def show\n @book = Book.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @book }\n end\n end", "def show\n @book = Book.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @book }\n end\n end", "def show\n @book = Book.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @book }\n end\n end", "def show\n @book = Book.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @book }\n end\n end", "def show\n @book = Book.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @book }\n end\n end", "def show\n @book = Book.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @book }\n end\n end", "def index\n @book = Book.find(params[:book_id])\n end", "def set_book\n @book = Book.find(params[:id])\n rescue ActiveRecord::RecordNotFound\n render json: { object: 'Book'}, status: :not_found\n end", "def cmd_get_faults argv\n setup argv\n uuid = @hash['uuid']\n response = @api.get_faults(uuid)\n if response.is_a?(Array)\n response.each do | r |\n msg r\n end\n else\n msg response\n end\n return response\n end", "def show\n @book = Book.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @book }\n end\n end", "def show\n @death_record_book = DeathRecordBook.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @death_record_book }\n end\n end", "def retrieve_book\n @book = Book.find(params[:book_id])\n end", "def show\r\n @book = Book.find(params[:id])\r\n\r\n respond_to do |format|\r\n format.html # show.html.erb\r\n format.json { render json: @book }\r\n end\r\n end", "def show\n @book = Book.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @book }\n end\n end", "def index\n @books = @collection.books\n #original: @books = Book.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @books }\n end\n end", "def get_book\n @book_series = BookSeries.find(params[:book_series_id])\n @book_series_1 = BookSeries.first\n @collection = @book_series.collections.find(params[:collection_id])\n @book = @collection.books.find(params[:book_id])\n end", "def get_book\n @book_series = BookSeries.find(params[:book_series_id])\n @book_series_1 = BookSeries.first\n @collection = @book_series.collections.find(params[:collection_id])\n @book = @collection.books.find(params[:book_id])\n end", "def get_address_books\n self.class.get('https://api.yesgraph.com/v0/address-books', :headers => @options)\n end", "def index\n @books = Book.get_avaible_books\n end", "def show\n @book_shelf = BookShelf.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @book_shelf }\n end\n end", "def index\n @book_pages = @book.book_pages\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @book_pages }\n end\n end", "def index\n @death_record_books = DeathRecordBook.all\n @death_record_books = DeathRecordBook.order(params[:sort])\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @death_record_books }\n end\n end", "def index\n @books = Book.find(:all, :conditions => { :deleted => false })\n @book_request = Book.count(:request, :conditions => { :request => false})\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @books }\n end\n end", "def show\n begin\n @response = Booking.get_booking(params[:id])\n rescue RestClient::Exception => exception\n @error = exception.response\n end\n end", "def get_book(search)\n\trequest_string = \"https://www.googleapis.com/books/v1/volumes?q=#{search.gsub(\" \",\"+\")}\"\n\t\n\tsample_uri = URI(request_string) #opens a portal to the data at that link\n\tsample_response = Net::HTTP.get(sample_uri) #go grab the data in the portal\n\tsample_parsedResponse = JSON.parse(sample_response) #makes data easy to read\n\tsample_parsedResponse[\"items\"]\nend", "def show\n @authors_book = AuthorsBook.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @authors_book }\n end\n end", "def show\n @book = Book.find(params[:id])\n @book.book_visit_count\n if(current_user.present?)\n @book.book_visit_user(current_user.id)\n end\n # if stale?(:etag => @book.id, :last_modified => @book.updated_at, :public => true)\n render json: @book \n # end\n rescue => e\n render json: {error_code: Code[:error_rescue], error_message: e.message}, status: Code[:status_error]\n end", "def show\n @book = Book.find(params[:id])\n @book.book_visit_count\n if(current_user.present?)\n @book.book_visit_user(current_user.id)\n end\n # if stale?(:etag => @book.id, :last_modified => @book.updated_at, :public => true)\n render json: @book \n # end\n rescue => e\n render json: {error_code: Code[:error_rescue], error_message: e.message}, status: Code[:status_error]\n end", "def index\n authorize! :query, Book\n @books = Book.order(:title)\n respond_to do |format|\n format.html\n format.json {render text: @books.to_json}\n format.xml {render text: @books.to_xml}\n end\n end", "def show\n render json: @book\n end", "def get_book_with_api(title)\n uri = URI.parse(URI.encode(\"https://www.googleapis.com/books/v1/volumes?q=#{title}\"))\n service = Books::ApiConnectService.new(uri)\n book_response = service.execute[\"items\"].first[\"volumeInfo\"]\n .select{ |key, value| key == \"title\" || key == \"description\" || key == \"publisher\" || key == \"publishedDate\" || key == \"imageLinks\"}\n @book_info_hash = book_response.inject({}) do |hash, (key, value)|\n if key.underscore == \"image_links\"\n hash[key.underscore] = book_response[\"imageLinks\"][\"smallThumbnail\"]\n else\n hash[key.underscore] = value\n end\n hash\n end\n end", "def get_book( book_id )\n response = if book_id.to_s.length >= 10\n Amazon::Ecs.item_lookup( book_id, :id_type => 'ISBN', :search_index => 'Books', \n :response_group => 'Large,Reviews,Similarities,AlternateVersions' )\n else\n Amazon::Ecs.item_lookup( book_id, :response_group => 'Large,Reviews,Similarities' )\n end\n response.items.each do |item|\n binding = item.get('ItemAttributes/Binding')\n next if binding.match(/Kindle/i)\n return Book.new( item )\n end\n return nil\n end", "def get_book\n @book = Book.where(id: params[:book_id]).first\n end", "def update\n @fault_book = FaultBook.find(params[:id])\n\n respond_to do |format|\n if @fault_book.update_attributes(params[:fault_book])\n format.html { redirect_to @fault_book, notice: 'Fault book was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @fault_book.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @book_steps = @book.book_steps.all\n @book = @book\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @book_steps }\n end\n end", "def index\n @books = Book.find_all_by_user_id(current_user)\n\n respond_to do |format|\n format.html\n format.json { render json: @books }\n end\n end", "def new\n @book_shelf = BookShelf.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @book_shelf }\n end\n end", "def index\n @refund_requests = RefundRequest.order 'created_at DESC'\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @refund_requests }\n end\n end", "def show\n @book = @collection.books.find(params[:id])\n #original: @book = Book.find(params[:id])\n\n respond_to do |format|\n format.html { redirect_to book_series_collection_book_chapters_url(@book_series, @collection, @book) }\n format.json { head :no_content }\n\n# respond_to do |format|\n# format.html # show.html.erb\n# format.json { render json: @book }\n end\n end", "def index\n @user_books = UserBook.all\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @user_books }\n end\n end", "def book_info_goodreads_library\n client = Goodreads::Client.new(Goodreads.configuration)\n results = client.book_by_title(params[:q])\n rescue\n []\n end", "def search_book_by_name(book)\n url = \"https://www.googleapis.com/books/v1/volumes?q=#{URI::encode(book)}&key=#{get_access_key}\"\n\tres = JSON.load(RestClient.get(url))\n return res\t\nend", "def index\n @books = Book.order('created_at DESC').page(params[:page]).per_page(10).search(params[:search], params[:id])\n respond_to do |format|\n format.json\n format.html\n end\n end", "def show\n @confirmation_book = ConfirmationBook.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @confirmation_book }\n end\n end", "def show\n @book = Book.find_by_sql(\"SELECT * FROM Books B WHERE B.id = \" + params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @book }\n end\n end", "def show\r\n @book = Book.find(params[:id])\r\n lookup_permission @book.id\r\n\r\n respond_to do |format|\r\n format.html # show.html.erb\r\n format.json { render json: @book }\r\n end\r\n end", "def get_book( book_id )\n response = if book_id.to_s.length >= 10\n Amazon::Ecs.item_lookup( book_id, :id_type => 'ISBN', :search_index => 'Books', :response_group => 'Large,Reviews,Similarities' )\n else\n Amazon::Ecs.item_lookup( book_id, :response_group => 'Large,Reviews,Similarities' )\n end\n response.items.each do |item|\n binding = item.get('ItemAttributes/Binding')\n next if binding.match(/Kindle/i)\n return parse_item( item )\n end\n end", "def index\n @book_genres = BookGenre.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @book_genres }\n end\n end", "def new\n @book = Book.new\n @people = Person.find_by_sql(\"SELECT * FROM People\")\n @authors = Author.find_by_sql(\"SELECT * FROM Authors\")\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @book }\n end\n end", "def show\n @title = \"Show Book\"\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @book }\n end\n end", "def search_for_google_books(search_term)\n url = \"https://www.googleapis.com/books/v1/volumes?q=#{search_term}\"\n response = RestClient.get(url)\n hash = JSON.parse(response)\n hash[\"items\"]\nend", "def index\n @books = Book.all\n do_response @books\n #\n #respond_to do |format|\n # format.html # index.html.erb\n #format.json { render :json => @books }\n #end\n end", "def book(id)\n\t\t\tresponse = request('/book/show', :id => id)\n\t\t\tHashie::Mash.new(response['book'])\n\t\tend", "def new\n @library_book = LibraryBook.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @library_book }\n end\n end", "def load_book\n @book = Book.find(params[:id])\n end", "def index\r\n @books = Book.paginate(:page => params[:page], :per_page => 30)\r\n\r\n respond_to do |format|\r\n format.html # index.html.erb\r\n format.json { render json: @books }\r\n end\r\n end", "def book\n @books=Book.all\n @book=Book.find(params[:id])\n end", "def index\n @library_books = LibraryBook.all\n end", "def index\n @title = \"List Books\"\n @books = Book.paginate :page=>params[:page], :per_page => 100, :order => 'title'\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @books }\n end\n end", "def set_book\n @book = Book.includes(:price_reduction).find_by(id: params[:id])\n render json: {status: \"not ok\", message: \"Book not found.\"}, status: :not_found unless @book\n end", "def index\n books_with_isbn = Book.where(isbn: params[:search])\n if books_with_isbn.any? and not request.format.json?\n redirect_to books_with_isbn.first\n return\n else\n search\n @books = @books.first(params[:limit].to_i) if params[:limit]\n @query = params[:search]\n unless request.format.json?\n @books = @books.paginate(page: params['page'])\n end\n end\n respond_to do |format|\n format.html\n format.json { 'show' }\n end\n end", "def show\n @book_page = @book.book_pages.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @book_page }\n end\n end", "def send_request_to_bibs_microservice\n 20.times do |x|\n stub_request(:get, \"#{ENV.fetch('BIBS_MICROSERVICE_URL_V01', nil)}?standardNumber=#{ 9781896580601 + x }\").\n with(\n headers: {\n 'Authorization' => 'Bearer testoken',\n 'Content-Type' => 'application/json'\n }).to_return(status: 200, body: MODIFIED_BOOK_JSON_FOR_ISBN_9782917623268, headers: {})\n end\n stub_request(:get, \"#{ENV.fetch('BIBS_MICROSERVICE_URL_V01', nil)}?standardNumber=123456789\").\n with(\n headers: {\n 'Authorization' => 'Bearer testoken',\n 'Content-Type' => 'application/json'\n }).to_return(status: 200, body: JSON_FOR_BOOK_WITH_ISBN_AND_TITLE_TOO_LONG, headers: {})\n end", "def book_info_open_library\n client = Openlibrary::Client.new\n results = client.search(params[:q])\n rescue\n []\n end", "def index\n @books = []\n if (params[:q])\n @books = Book.where(params[:q])\n end\n render :json => @books\n end", "def index\n @confirmation_books = ConfirmationBook.all\n @confirmation_books = ConfirmationBook.order(params[:sort])\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @confirmation_books }\n end\n end", "def show\n @book_catalog_entrie = BookCatalogEntrie.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @book_catalog_entrie }\n end\n end", "def make_request(search_term)\n response = RestClient.get(\"https://www.googleapis.com/books/v1/volumes?q=#{search_term}\")\n final_response = JSON.parse(response)\nend", "def show\n @businessbook = Businessbook.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @businessbook }\n end\n end" ]
[ "0.70453316", "0.6452588", "0.64246726", "0.63075763", "0.6263612", "0.6224477", "0.6182557", "0.6142781", "0.61366713", "0.611634", "0.6098845", "0.60978496", "0.60863024", "0.6083412", "0.6044977", "0.6015791", "0.59944427", "0.59824455", "0.5969227", "0.5955293", "0.5946506", "0.5945531", "0.59373015", "0.59363705", "0.5916578", "0.59121704", "0.5901141", "0.5901141", "0.58998084", "0.58998084", "0.58998084", "0.58998084", "0.58998084", "0.58998084", "0.58998084", "0.58998084", "0.58998084", "0.589303", "0.5889473", "0.58764815", "0.5861231", "0.58492774", "0.584434", "0.58438224", "0.5827963", "0.58262646", "0.5819613", "0.5819613", "0.58116376", "0.5809046", "0.57962316", "0.5784281", "0.57793874", "0.5778678", "0.5777364", "0.5769449", "0.5763996", "0.5758902", "0.5758902", "0.57559896", "0.57557595", "0.5745959", "0.5740746", "0.57350004", "0.57258886", "0.5719767", "0.5686252", "0.5682584", "0.5670794", "0.5662674", "0.5660669", "0.56533283", "0.5649955", "0.5621039", "0.56199336", "0.5614791", "0.5612102", "0.56113464", "0.5606413", "0.56031275", "0.5595017", "0.559366", "0.5591158", "0.5589969", "0.558691", "0.5581272", "0.55797625", "0.55792236", "0.55751735", "0.5574624", "0.5573429", "0.5568744", "0.5567669", "0.55595666", "0.55581456", "0.5558137", "0.5552403", "0.554991", "0.5541024", "0.55378914" ]
0.5961374
19
GET /fault_books/new GET /fault_books/new.json
def new @fault_book = FaultBook.new @fault_book.fault_date = Date.today.strftime("%d-%m-%Y") @drivers = current_user.truck_fleet.drivers @fleets = current_user.truck_fleet.fleets respond_to do |format| format.html # new.html.erb format.json { render json: @fault_book } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n load_data\n @book = Book.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @book }\n end\n end", "def new\n @title = \"New Book\"\n @book = Book.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @book }\n end\n end", "def new\n @book = Book.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @book }\n end\n end", "def new\n @book = Book.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @book }\n end\n end", "def new\n @library_book = LibraryBook.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @library_book }\n end\n end", "def new\n @book = Book.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @book }\n end\n end", "def new\n @book = Book.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @book }\n end\n end", "def new\n @book = Book.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @book }\n end\n end", "def new\n @book = Book.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @book }\n end\n end", "def new\n @book = Book.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @book }\n end\n end", "def new\n @book = Book.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @book }\n end\n end", "def new\n @book = Book.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @book }\n end\n end", "def new\n @book = Book.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @book }\n end\n end", "def new\n @book = Book.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @book }\n end\n end", "def new\n @book = Book.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @book }\n end\n end", "def new\n @book = Book.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @book }\n end\n end", "def new\n @book = Book.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @book }\n end\n end", "def new\r\n @book = Book.new\r\n\r\n respond_to do |format|\r\n format.html # new.html.erb\r\n format.json { render json: @book }\r\n end\r\n end", "def new\n @cookbook = Cookbook.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @cookbook }\n end\n end", "def new\n\t\t@book = Book.new\n\n\t\trespond_to do |format|\n\t\t\tformat.html # new.html.erb\n\t\t\tformat.json { render :json => @book }\n\t\tend\n\tend", "def new\n @cook_book = CookBook.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @cook_book }\n end\n end", "def new\n @book = Book.new\n\n do_response @book\n end", "def new\n # @collection = Collection.find(params[:collection_id])\n @book = @collection.books.build\n #original: @book = Book.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @book }\n end\n end", "def new\r\n @page_title = '書籍情報作成'\r\n @book = Book.new\r\n\r\n respond_to do |format|\r\n format.html # new.html.erb\r\n format.json { render json: @book }\r\n end\r\n end", "def new\n @book_shelf = BookShelf.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @book_shelf }\n end\n end", "def new\n @current_book = Book.find_by_id(params[:book_id])\n @chapter = Chapter.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :json => @chapter }\n end\n end", "def new\n @authors_book = AuthorsBook.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @authors_book }\n end\n end", "def new\n @confirmation_book = ConfirmationBook.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @confirmation_book }\n end\n end", "def new\n @death_record_book = DeathRecordBook.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @death_record_book }\n end\n end", "def new\n @look_book = LookBook.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @look_book }\n end\n end", "def new\n @book_of_class = BookOfClass.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @book_of_class }\n end\n end", "def new\n @book = Book.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render xml: @book }\n format.json { render json: @book }\n end\n end", "def new\n @book = current_user.books.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @book }\n end\n end", "def new\n @chapter.book = Book.find params[:book]\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @chapter }\n end\n end", "def new\n @book = Book.new :copies => 1\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @book }\n end\n end", "def new\n @book_catalog_entrie = BookCatalogEntrie.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @book_catalog_entrie }\n end\n end", "def new\n @books = Book.all\n @knowledge_point = KnowledgePoint.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @knowledge_point }\n end\n end", "def new\n @borrow_request = BorrowRequest.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @borrow_request }\n end\n end", "def new\n @bookwork = Bookwork.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @bookwork }\n end\n end", "def new\n @bookself = Bookself.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @bookself }\n end\n end", "def new\n @businessbook = Businessbook.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @businessbook }\n end\n end", "def new\n @book = Book.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @book }\n end\n end", "def new\n @borrow = Borrow.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @borrow }\n end\n end", "def new\n @book = Book.new\n @publishers = Publisher.all\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @book }\n end\n end", "def new\n @book_format = BookFormat.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @book_format }\n end\n end", "def create\n @book = Book.new(params[:book])\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to manage_books_path, notice: 'Book was successfully created.' }\n format.json { render json: @book, status: :created, location: @book }\n else\n format.html { render action: \"new\" }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @book = Book.new(:serial_id => params[:serial_id])\n article = @book.articles.build\n article.authorships.build\n book = @book.editorships.build\n\n respond_to do |format|\n format.html { render layout: 'form' }# new.html.erb\n format.json { render json: @book }\n end\n end", "def create\n\n @book = Book.new(params[:book])\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to \"/books\", notice: 'Book was successfully created.' }\n format.json { render json: @book, status: :created, location: @book }\n else\n format.html { render action: \"new\" }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @book_review = BookReview.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @book_review }\n end\n end", "def new\n @usersbook = Usersbook.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @usersbook }\n end\n end", "def create\n @book = Book.create( params[:book] )\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to books_path, notice: 'Book was successfully created.' }\n format.json { render json: @book, status: :created, location: @book }\n else\n format.html { render action: \"new\" }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @librarybook = Librarybook.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @librarybook }\n end\n end", "def create\n @book = Book.new(book_params)\n\n if @book.save\n render json: @book, status: :created, location: @book\n else\n render json: @book.errors, status: :unprocessable_entity\n end\n end", "def new\n @book_page = @book.book_pages.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @book_page }\n end\n end", "def create\n @book = Book.new(params[:book])\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, notice: 'Book was successfully created.' }\n format.json { render json: @book, status: :created, location: @book }\n else\n format.html { render action: \"new\" }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @book = Book.new(params[:book])\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, notice: 'Book was successfully created.' }\n format.json { render json: @book, status: :created, location: @book }\n else\n format.html { render action: \"new\" }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @book = Book.new(params[:book])\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, notice: 'Book was successfully created.' }\n format.json { render json: @book, status: :created, location: @book }\n else\n format.html { render action: \"new\" }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @book = Book.new(params[:book])\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, notice: 'Book was successfully created.' }\n format.json { render json: @book, status: :created, location: @book }\n else\n format.html { render action: \"new\" }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @book = Book.new(params[:book])\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, notice: 'Book was successfully created.' }\n format.json { render json: @book, status: :created, location: @book }\n else\n format.html { render action: \"new\" }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @library_book = LibraryBook.new(params[:library_book])\n\n respond_to do |format|\n if @library_book.save\n format.html { redirect_to @library_book, notice: 'Library book was successfully created.' }\n format.json { render json: @library_book, status: :created, location: @library_book }\n else\n format.html { render action: \"new\" }\n format.json { render json: @library_book.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @book = Book.new(params[:book])\n \n\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, notice: 'Book was successfully created.' }\n format.json { render json: @book, status: :created, location: @book }\n else\n format.html { render action: \"new\" }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @book_step = BookStep.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @book_step }\n end\n end", "def new\n @ebook = Ebook.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @ebook }\n end\n end", "def new\n\t\t@book = Book.new\n\tend", "def new\n @book = Book.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @book }\n end\n end", "def new\n @book = Book.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @book }\n end\n end", "def new\n @book = Book.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @book }\n end\n end", "def new\n @book = Book.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @book }\n end\n end", "def new\n @book = Book.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @book }\n end\n end", "def new\n @book = Book.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @book }\n end\n end", "def new\n @book = Book.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @book }\n end\n end", "def new\n @book = Book.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @book }\n end\n end", "def create\n @api_book = Api::Book.new(api_book_params)\n\n if @api_book.save\n render json: @api_book, status: :created, location: @api_book\n else\n render json: @api_book.errors, status: :unprocessable_entity\n end\n end", "def create\n @lib_book = LibBook.new(lib_book_params)\n\n respond_to do |format|\n if @lib_book.save\n format.html { redirect_to university_library_lib_books_path, notice: 'Lib book was successfully created.' }\n format.json { render :show, status: :created, location: @lib_book }\n else\n format.html { render :new }\n format.json { render json: @lib_book.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @book = Book.new(book_params)\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book }\n format.json { render action: 'show', status: :created, location: @book }\n else\n format.html { render action: 'new' }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @book = Book.new(params[:book])\n\n respond_to do |format|\n if @book.save\n #flash[:notice] = 'Book was successfully created.'\n format.html { redirect_to @book, :notice => 'Book was successfully created.' }\n format.json { render :json => @book, :status => :created, :location => @book }\n else\n load_data\n\n format.html { render :action => \"new\" }\n format.json { render :json => @book.errors, :status => :unprocessable_entity }\n end\n end\n end", "def new\n @borrower = Borrower.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @borrower }\n end\n end", "def new\n @borrower = Borrower.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @borrower }\n end\n end", "def create\n byebug\n @book = Book.new(book_params)\n respond_to do |format|\n if @book.save\n format.html { redirect_to [:admin, @book], notice: 'Book was successfully created.' }\n format.json { render action: 'show', status: :created, location: @book }\n else\n load_data\n format.html { render action: 'new' }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @book = Book.new\n @people = Person.find_by_sql(\"SELECT * FROM People\")\n @authors = Author.find_by_sql(\"SELECT * FROM Authors\")\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @book }\n end\n end", "def create\n @book = Book.new(book_params)\n Rails.logger = Logger.new(STDOUT)\n logger.debug \"params passed is #{book_params}\"\n @book.is_deleted = false\n\n if !@current_librarian.nil?\n @book[:library_id] = @current_librarian.library_id\n @book[:associated_library] = @current_librarian.library.name\n end\n\n respond_to do |format|\n if @book.save\n logger.debug \"Book saved with id #{@book.id}\"\n format.html { redirect_to @book, notice: 'Book was successfully added.' }\n format.json { render :show, status: :created, location: @book }\n else\n format.html { render :new }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @booking = Booking.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @booking }\n end\n end", "def new\n @booking = Booking.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @booking }\n end\n end", "def create\n @book = Book.new(book_params)\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book}\n format.json { render action: 'show', status: :created, location: @book }\n else\n format.html { render action: 'new' }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n logger.debug \"#{book_params}\"\n @book = Book.new(book_params)\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, notice: 'Book was successfully created.' }\n format.json { render :show, status: :created, location: @book }\n else\n format.html { render :new }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @book_edition = BookEdition.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @book_edition }\n end\n end", "def create\n @book = Book.new(book_params)\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, notice: 'Book was successfully created.' }\n format.json { render json: @book, status: :created, location: @book }\n else\n format.html { render action: \"new\" }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @book = Book.new \n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @book }\n end\n end", "def new\n @book = Book.new\n end", "def new\n @book = Book.new\n end", "def new\n\n @user = User.find(current_user.id)\n @book = Book.new\n @book.user_id = @user.id\n\n @book = Book.new(:title => params[:rtitle],:author => params[:rauthor], :isbn => params[:risbn])\n # @book = Book.find_by_user_id(@user.id)\n\n isbn = @book.isbn\n user_id = @user.id\n books = Book.find_by_isbn_and_user_id(isbn,user_id)\n if books.nil?\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @book }\n end\n else\n redirect_to \"/books/search\"\n flash[:alert] = \"the book '#{@book.title}' already exist - please search for another book!!!\"\n end\n end", "def create\n @book = Book.new(params[:book])\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, notice: 'Book was successfully created.' }\n format.xml { head :ok }\n format.json { render json: @book, status: :created, location: @book }\n\n else\n format.html { render action: \"new\" }\n format.xml { render xml: @book.errors, status: :unprocessable_entity}\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @book = @collection.books.build(params[:book])\n #original: @book = Book.new(params[:book])\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to book_series_collection_books_url(@book_series, @collection), notice: 'Book was successfully created.' }\n format.json { render json: @book, status: :created, location: @book }\n else\n format.html { render action: \"new\" }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @loan = Loan.new(loan_params)\n @book = Book.find_by( params[:book_id] )\n\n respond_to do |format|\n if @loan.save\n format.html { redirect_to @loan, notice: 'Book successfully borrowed' }\n format.json { render :show, status: :created, location: @loan }\n else\n format.html { redirect_to books_path, alert: 'Book not available' }\n end\n end\n end", "def new\n @title = t('view.banks.new_title')\n @bank = Bank.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @bank }\n end\n end", "def new\n\n # This puts \"My fancy title\" in the blank title field\n # @book = Book.new :title => \"My fancy title\"\n\n @book = Book.new \n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @book }\n end\n end", "def new\n @addbook = Addbook.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @addbook }\n end\n end", "def create\n @book = Book.new(book_params)\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, notice: 'Book was successfully created.' }\n format.json { render action: 'show', status: :created, location: @book }\n else\n format.html { render action: 'new' }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @book = Book.new\n end", "def new\n @book = Book.new\n end" ]
[ "0.7430907", "0.7305153", "0.7304712", "0.7304712", "0.7222088", "0.7215761", "0.7215761", "0.7215761", "0.7215761", "0.7215761", "0.7215761", "0.7215761", "0.7215761", "0.7215761", "0.7215761", "0.7215761", "0.72094405", "0.71909344", "0.7131054", "0.7104822", "0.7073409", "0.70636916", "0.704043", "0.7009151", "0.7005385", "0.69376177", "0.6923683", "0.6919288", "0.6914701", "0.69052064", "0.6894216", "0.6888804", "0.68518984", "0.68445426", "0.6829402", "0.67869776", "0.67777574", "0.67766076", "0.6760924", "0.67511517", "0.67165756", "0.67047554", "0.67019707", "0.6698218", "0.66742134", "0.66712475", "0.66694057", "0.66681457", "0.66475344", "0.66320825", "0.6607262", "0.66044545", "0.6603826", "0.66037005", "0.6602849", "0.6602849", "0.6602849", "0.6602849", "0.6602849", "0.65889233", "0.658647", "0.65818506", "0.65719646", "0.6560702", "0.65487313", "0.65487313", "0.65487313", "0.65487313", "0.65487313", "0.65487313", "0.65487313", "0.65487313", "0.6546299", "0.6546256", "0.65364903", "0.65317273", "0.65224266", "0.65224266", "0.65160465", "0.6512123", "0.65106845", "0.6510658", "0.6510658", "0.6502661", "0.6500414", "0.6493631", "0.64907926", "0.6486832", "0.64866054", "0.64866054", "0.6485774", "0.6485577", "0.6475314", "0.64669275", "0.64641744", "0.6461782", "0.64598554", "0.6456832", "0.64513475", "0.64513475" ]
0.7049447
22
POST /fault_books POST /fault_books.json
def create @fault_book = FaultBook.new(params[:fault_book]) @fault_book.truck_fleet_id = @fault_book.fleet.truck_fleet_id respond_to do |format| if @fault_book.save s = Serviceable.find_by_fleet_id(params['fault_book']['fleet_id']) s.next_service_date = @fault_book.fault_date s.save format.html { redirect_to @fault_book, notice: 'Fault book was successfully created.' } format.json { render json: @fault_book, status: :created, location: @fault_book } else format.html { render action: "new" } format.json { render json: @fault_book.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @fault_books = FaultBook.where(:truck_fleet_id => current_user.truck_fleet.id)\n @fault_books = FaultBook.belongs_to_truck_fleet(current_user.truck_fleet, @fault_books) if current_user.admin?\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @fault_books }\n end\n end", "def new\n @fault_book = FaultBook.new\n @fault_book.fault_date = Date.today.strftime(\"%d-%m-%Y\")\n \n @drivers = current_user.truck_fleet.drivers\n @fleets = current_user.truck_fleet.fleets\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @fault_book }\n end\n end", "def create\n @api_book = Api::Book.new(api_book_params)\n\n if @api_book.save\n render json: @api_book, status: :created, location: @api_book\n else\n render json: @api_book.errors, status: :unprocessable_entity\n end\n end", "def create\n decoded_token = JWT.decode book_params[:swipeChefToken], \"spaghetti\", true, { algorithm: 'HS256' }\n\n if decoded_token\n\n user_id = decoded_token[0]['id'].to_i\n\n @book = Book.find_or_create_by(user_id: user_id, recipe_id: params[:recipe_id])\n\n respond_to do |format|\n format.json { render json: @book}\n end\n end\n end", "def create\n @book = Book.new(book_params)\n resort_orders\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, notice: 'Book was successfully created.' }\n format.json { render :show, status: :created, location: @book }\n else\n format.html { render :new }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @book = Book.new(book_params)\n\n # 書籍情報を取得\n get_info\n\n if @res.present? && !@res.has_error? && @res.total_results != 0\n @book.isbn = @res.first_item.get('ItemAttributes/ISBN')\n @book.asin = @res.first_item.get('ASIN')\n @book.title = @res.first_item.get('ItemAttributes/Title')\n @book.publisher = @res.first_item.get('ItemAttributes/Manufacturer')\n @book.author = @res.first_item.get('ItemAttributes/Author')\n @book.description = @res.first_item.get('EditorialReviews/EditorialReview/Content')\n @book.image = @res.first_item.get('MediumImage/URL')\n @book.publish_date = @res.first_item.get('ItemAttributes/PublicationDate')\n @book.number_of_pages = @res.first_item.get('ItemAttributes/NumberOfPages')\n @book.price = @res.first_item.get('ItemAttributes/ListPrice/Amount')\n\n # 取得したISBNが登録されてない場合のみ、取得した書籍を登録する\n @find_book = Book.find_by(isbn: @book.isbn)\n if @find_book.nil?\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, notice: @book.title + ' を新規登録しました。' }\n format.json { render :show, status: :created, location: @book }\n else\n format.html { render :new }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n else\n respond_to do |format|\n format.html { redirect_to @find_book, notice: @book.title + ' は既に登録されています。' }\n format.json { render :show, status: :created, location: @find_book }\n end\n end\n else\n respond_to do |format|\n format.html { redirect_to books_url, notice: '本が見つかりませんでした。' }\n format.json { head :no_content }\n end\n end\n end", "def create\n @book = Book.find(book_request_params[:book_id])\n @account = Account.find(params[:account_id])\n @book_request = BookRequest.new(book: @book, reader: @account, holder: @book.account)\n respond_to do |format|\n if @book_request.save\n format.json {\n render json:\n {\n book_id: @book_request.book_id,\n book_request_state: @book_request.state_name\n }\n }\n else\n format.json { render json: @book_request.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @book = Book.new(book_params)\n\n if @book.save\n render json: @book, status: :created, location: @book\n else\n render json: @book.errors, status: :unprocessable_entity\n end\n end", "def update\n @fault_book = FaultBook.find(params[:id])\n\n respond_to do |format|\n if @fault_book.update_attributes(params[:fault_book])\n format.html { redirect_to @fault_book, notice: 'Fault book was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @fault_book.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @book = Book.new(book_params)\n Rails.logger = Logger.new(STDOUT)\n logger.debug \"params passed is #{book_params}\"\n @book.is_deleted = false\n\n if !@current_librarian.nil?\n @book[:library_id] = @current_librarian.library_id\n @book[:associated_library] = @current_librarian.library.name\n end\n\n respond_to do |format|\n if @book.save\n logger.debug \"Book saved with id #{@book.id}\"\n format.html { redirect_to @book, notice: 'Book was successfully added.' }\n format.json { render :show, status: :created, location: @book }\n else\n format.html { render :new }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @lib_book = LibBook.new(lib_book_params)\n\n respond_to do |format|\n if @lib_book.save\n format.html { redirect_to university_library_lib_books_path, notice: 'Lib book was successfully created.' }\n format.json { render :show, status: :created, location: @lib_book }\n else\n format.html { render :new }\n format.json { render json: @lib_book.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @instance_fault = InstanceFault.new(params[:instance_fault])\n\n respond_to do |format|\n if @instance_fault.save\n format.html { redirect_to @instance_fault, notice: 'Instance fault was successfully created.' }\n format.json { render json: @instance_fault, status: :created, location: @instance_fault }\n else\n format.html { render action: \"new\" }\n format.json { render json: @instance_fault.errors, status: :unprocessable_entity }\n end\n end\n end", "def add_book(book_title)\n @books << {\n title: book_title,\n rental_details: {\n student_name: \"\",\n date: \"\"\n }\n }\n end", "def create\n @book = @collection.books.build(params[:book])\n #original: @book = Book.new(params[:book])\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to book_series_collection_books_url(@book_series, @collection), notice: 'Book was successfully created.' }\n format.json { render json: @book, status: :created, location: @book }\n else\n format.html { render action: \"new\" }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n byebug\n @book = Book.new(book_params)\n respond_to do |format|\n if @book.save\n format.html { redirect_to [:admin, @book], notice: 'Book was successfully created.' }\n format.json { render action: 'show', status: :created, location: @book }\n else\n load_data\n format.html { render action: 'new' }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @tags_book = TagsBook.new(tags_book_params)\n\n @books = Book.all\n @tags = Tag.all\n\n respond_to do |format|\n if @tags_book.save\n format.html { redirect_to @tags_book, notice: \"Tags book was successfully created.\" }\n format.json { render :show, status: :created, location: @tags_book }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @tags_book.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @user = current_user\n if verify_admin || verify_librarian\n @book = Book.new(book_params)\n @book.nums_request = 0\n @book.library = @user.library if (@user.role == 'librarian')\n @book.is_delete = false\n @book.nums_borrowed = 0\n @library = Library.find_by_name(@book.library)\n @book.university = @library.university\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, notice: 'Book was successfully created.' }\n format.json { render :show, status: :created, location: @book }\n\n else\n format.html { render :new }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n\n end\n end\n else\n redirect_to books_url, notice: 'Unauthorized action!'\n\n end\n end", "def create\n @cook_book = CookBook.new(params[:cook_book])\n\n respond_to do |format|\n if @cook_book.save\n format.html { redirect_to @cook_book, notice: 'Cook book was successfully created.' }\n format.json { render json: @cook_book, status: :created, location: @cook_book }\n else\n format.html { render action: \"new\" }\n format.json { render json: @cook_book.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @library_book = LibraryBook.new(params[:library_book])\n\n respond_to do |format|\n if @library_book.save\n format.html { redirect_to @library_book, notice: 'Library book was successfully created.' }\n format.json { render json: @library_book, status: :created, location: @library_book }\n else\n format.html { render action: \"new\" }\n format.json { render json: @library_book.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @book = Book.new(params[:book])\n respond_to do |format|\n begin\n if @book.save\n format.html { redirect_to @book, notice: 'Book was successfully created.' }\n format.json { render json: @book, status: :created, location: @book }\n else\n format.html { render action: \"new\" }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n #This will take care of duplicate book entry in the scope of same authors only. \n rescue InvalidBook => e\n @book.errors[:base] << e.to_s\n format.html { render action: \"new\" }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n\n @book = Book.new(params[:book])\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to \"/books\", notice: 'Book was successfully created.' }\n format.json { render json: @book, status: :created, location: @book }\n else\n format.html { render action: \"new\" }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @realistic_fiction_book = current_user.realistic_fiction_books.build(realistic_fiction_book_params)\n\n respond_to do |format|\n if @realistic_fiction_book.save\n format.html { redirect_to @realistic_fiction_book, notice: \"Realistic fiction review was successfully created.\" }\n format.json { render :show, status: :created, location: @realistic_fiction_book }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @realistic_fiction_book.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @book = Book.new\n @book.isbn = params[:book][:isbn]\n @book.title = params[:book][:title]\n @book.language = params[:book][:language]\n @book.author = params[:book][:author]\n @book.published = params[:book][:published]\n @book.edition = params[:book][:edition]\n @book.image = params[:book][:image]\n @book.subject = params[:book][:subject]\n @book.summary = params[:book][:summary]\n @book.special = params[:book][:special]\n \n respond_to do |format|\n if @book.save\n @book_library_mapping = BookLibraryMapping.new \n @book_library_mapping.book_id = @book.id\n @book_library_mapping.quantity = params[:quantity]\n @book_library_mapping.library_id = params[:library]\n @book_library_mapping.save\n\n format.html { redirect_to @book, notice: 'Book was successfully created.' }\n format.json { render :show, status: :created, location: @book }\n else\n format.html { render :new }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @book = Book.new(get_book_with_api(book_params[:title]))\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, notice: '本を新規登録しました。' }\n format.json { render :show, status: :created, location: @book }\n else\n format.html { render :new }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @book = Book.create( params[:book] )\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to books_path, notice: 'Book was successfully created.' }\n format.json { render json: @book, status: :created, location: @book }\n else\n format.html { render action: \"new\" }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @book_issue = BookIssue.new(book_issue_params)\n\n respond_to do |format|\n if @book_issue.save\n format.html { redirect_to @book_issue, notice: 'Book issue was successfully created.' }\n format.json { render :show, status: :created, location: @book_issue }\n else\n format.html { render :new }\n format.json { render json: @book_issue.errors, status: :unprocessable_entity }\n end\n end\n end", "def unaffirmedbook_params\n params.require(:unaffirmedbook).permit(:bookid, :booktitle, :expected_return, :returndate, :overdue)\n end", "def create\n @order_book = OrderBook.new(order_book_params)\n\n respond_to do |format|\n if @order_book.save\n format.html { redirect_to @order_book, notice: 'Order book was successfully created.' }\n format.json { render :show, status: :created, location: @order_book }\n else\n format.html { render :new }\n format.json { render json: @order_book.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @book = Book.new(params[:book])\n\n respond_to do |format|\n if @book.save\n #flash[:notice] = 'Book was successfully created.'\n format.html { redirect_to @book, :notice => 'Book was successfully created.' }\n format.json { render :json => @book, :status => :created, :location => @book }\n else\n load_data\n\n format.html { render :action => \"new\" }\n format.json { render :json => @book.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @service_fault = ServiceFault.new(service_fault_params)\n\n respond_to do |format|\n if @service_fault.save\n format.html { redirect_to @service_fault, notice: 'Service fault was successfully created.' }\n format.json { render :show, status: :created, location: @service_fault }\n else\n format.html { render :new }\n format.json { render json: @service_fault.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @cook_book = CookBook.new(cook_book_params)\n\n respond_to do |format|\n if @cook_book.save\n format.html { redirect_to @cook_book, notice: 'Cook book was successfully created.' }\n format.json { render :show, status: :created, location: @cook_book }\n else\n format.html { render :new }\n format.json { render json: @cook_book.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @book = Book.new(book_params)\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, notice: t('common.message.created_success')}\n format.json { render :show, status: :created, location: @book }\n else\n format.html { render :new }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @book = params[:book]\n add(@book)\n end", "def test_add_new_book\n @library.add_new_book(\"catch_22\")\n expected = {\n title: 'catch_22',\n rental_details: {\n student_name: '',\n date: ''\n }\n }\n assert_equal(expected, @library.get_book('catch_22'))\n end", "def create\n @library_book = LibraryBook.new(library_book_params)\n\n respond_to do |format|\n if @library_book.save\n format.html { redirect_to @library_book, notice: 'Library book was successfully created.' }\n format.json { render :show, status: :created, location: @library_book }\n else\n format.html { render :new }\n format.json { render json: @library_book.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @book = Book.new(params[:book])\n \n\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, notice: 'Book was successfully created.' }\n format.json { render json: @book, status: :created, location: @book }\n else\n format.html { render action: \"new\" }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @book = Book.new(params[:book])\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, notice: 'Book was successfully created.' }\n format.json { render json: @book, status: :created, location: @book }\n else\n format.html { render action: \"new\" }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @book = Book.new(params[:book])\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, notice: 'Book was successfully created.' }\n format.json { render json: @book, status: :created, location: @book }\n else\n format.html { render action: \"new\" }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @book = Book.new(params[:book])\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, notice: 'Book was successfully created.' }\n format.json { render json: @book, status: :created, location: @book }\n else\n format.html { render action: \"new\" }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @book = Book.new(params[:book])\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, notice: 'Book was successfully created.' }\n format.json { render json: @book, status: :created, location: @book }\n else\n format.html { render action: \"new\" }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @book = Book.new(params[:book])\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, notice: 'Book was successfully created.' }\n format.json { render json: @book, status: :created, location: @book }\n else\n format.html { render action: \"new\" }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @book_request = BookRequest.new(book_request_params)\n\n respond_to do |format|\n if @book_request.save\n format.html { redirect_to @book_request, notice: 'Book request was successfully created.' }\n format.json { render :show, status: :created, location: @book_request }\n else\n format.html { render :new }\n format.json { render json: @book_request.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @book = Book.new(params[:book])\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, notice: 'Book was successfully created.' }\n format.xml { head :ok }\n format.json { render json: @book, status: :created, location: @book }\n\n else\n format.html { render action: \"new\" }\n format.xml { render xml: @book.errors, status: :unprocessable_entity}\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @book = Book.new(book_params)\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, notice: \"Book was successfully created.\" }\n format.json { render :show, status: :created, location: @book }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @book = Book.new(book_params)\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, notice: \"Book was successfully created.\" }\n format.json { render :show, status: :created, location: @book }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @book = Book.new(params[:book])\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to manage_books_path, notice: 'Book was successfully created.' }\n format.json { render json: @book, status: :created, location: @book }\n else\n format.html { render action: \"new\" }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n logger.debug \"#{book_params}\"\n @book = Book.new(book_params)\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, notice: 'Book was successfully created.' }\n format.json { render :show, status: :created, location: @book }\n else\n format.html { render :new }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @book = Book.new(book_params)\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, notice: 'Book was successfully created.' }\n format.json { render :show, status: :created, location: @book }\n else\n format.html { render :new }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n getBookId = Book.where(name:@book.name)\n getBookId.each do |id_book|\n params[:amount_code].each do |value|\n Amount.new(code: value, book_id: id_book.id, active: 0).save\n end\n end\n end", "def create\n @book = Book.new(book_params)\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book }\n format.json { render action: 'show', status: :created, location: @book }\n else\n format.html { render action: 'new' }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n \n \n @booktitle = Book.find_by_title(book_params[:title])\n if Book.where(:title => book_params[:title]).present?\n @book = Book.find(@booktitle.id)\n @book.count = @book.count + book_params[:count].to_i\n else\n if !(Author.where(:name => book_params[:author_name]).present?)\n @author = Author.create(:name => book_params[:author_name],\n :category => book_params[:category])\n end\n @book = Book.new(book_params)\n @book.author_id = Author.find_by_name(book_params[:author_name]).id\n end\n\n \n respond_to do |format|\n if @book.save\n \n format.json { render json: @book, status: :created, location: @book }\n else\n \n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n puts \"post_params\"\n puts post_params\n if post_params[:book]\n response = RestClient::Request.execute(\n method: :get,\n url: post_params[:book]['self_link'],\n )\n response=JSON.parse(response)\n @book = Book.where(self_link: post_params[:book]['self_link']).first_or_create do |book|\n book.title=response['volumeInfo']['title']\n book.subtitle=response['volumeInfo']['subtitle']\n book.description=response['volumeInfo']['description']\n book.publisher=response['volumeInfo']['publisher']\n book.publication_date=response['volumeInfo']['publishedDate']\n if response['volumeInfo']['authors'] then book.author=response['volumeInfo']['authors'].join(', ') end\n if response['saleInfo']['listPrice'] then book.list_price=response['saleInfo']['listPrice']['amount'] end\n end\n puts @book\n if response['volumeInfo']['industryIdentifiers']\n response['volumeInfo']['industryIdentifiers'].each do |isbn_type|\n if isbn_type['type']=='ISBN_13'\n @book['ISBN_13']=isbn_type['identifier']\n elsif isbn_type['type']=='ISBN_10'\n @book['ISBN_10']=isbn_type['identifier']\n end\n end\n end\n if response['volumeInfo']['imageLinks']\n if response['volumeInfo']['imageLinks']['thumbnail']\n @book['cover_image']=response['volumeInfo']['imageLinks']['thumbnail']\n elsif response['volumeInfo']['imageLinks']['smallThumbnail']\n @book['cover_image']=response['volumeInfo']['imageLinks']['smallThumbnail']\n end\n end\n if @book.save\n # @posts.book_id=@book.id\n @post = current_user.posts.new(post_params.merge({book: @book}))\n\n respond_to do |format|\n if @post.save\n if params[:images]\n params[:images]['actual_product_image'].each do |image|\n @image = @post.images.create!(:actual_product_image => image)\n end\n end\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n if post_params['post_type']=='offer'\n format.html { render :new_offer }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n else\n format.html { render :new_request }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end\n end\n else\n if post_params['post_type']==\"offer\"\n redirect_to posts_new_offer_path, notice:\"Need Book Information\"\n else\n redirect_to posts_new_request_path, notice:\"Need Book Information\"\n end\n end\nend", "def create\n book_id = params[:book_id]\n book_title = params[:book_title]\n damage_date = params[:damage_date]\n borrower_id = params[:borrower_id]\n level = damagebook_params[:level]\n @damagebook = Damagebook.new(:bookid => book_id, :bookname => book_title, :date => damage_date, :level => level )\n unaffirmedbook = Unaffirmedbook.find_by bookid: book_id\n unaffirmedbook.destroy\n book = Book.find(book_id)\n book.state = \"已损坏\"\n book.save!\n student = Student.find(borrower_id)\n student.credit = student.credit - 10\n student.save!\n\n respond_to do |format|\n if @damagebook.save\n format.html { redirect_to @damagebook, notice: '成功加入损坏图书列表!' }\n format.json { render :show, status: :created, location: @damagebook }\n else\n format.html { render :new }\n format.json { render json: @damagebook.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @borrowed_book = BorrowedBook.new(borrowed_book_params)\n\n respond_to do |format|\n if @borrowed_book.save\n format.html { redirect_to @borrowed_book, notice: \"Borrowed book was successfully created.\" }\n format.json { render :show, status: :created, location: @borrowed_book }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @borrowed_book.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @book = Book.new(book_params)\n @categories = Category.all.order('name asc')\n respond_to do |format|\n if @book.save\n format.html { redirect_to books_url, notice: 'Book was successfully created.' }\n format.json { render :show, status: :created, location: @book }\n else\n @categories = Category.all.order('name asc')\n format.html { render :new }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @unaffirmedbook = Unaffirmedbook.new(unaffirmedbook_params)\n\n respond_to do |format|\n if @unaffirmedbook.save\n format.html { redirect_to @unaffirmedbook, notice: 'Unaffirmedbook was successfully created.' }\n format.json { render :show, status: :created, location: @unaffirmedbook }\n else\n format.html { render :new }\n format.json { render json: @unaffirmedbook.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @book = Book.new(book_params)\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book}\n format.json { render action: 'show', status: :created, location: @book }\n else\n format.html { render action: 'new' }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @book_catalog_entrie = BookCatalogEntrie.new(params[:book_catalog_entrie])\n\n respond_to do |format|\n if @book_catalog_entrie.save\n format.html { redirect_to @book_catalog_entrie, notice: 'Book was successfully created.' }\n format.json { render json: @book_catalog_entrie, status: :created, location: @book }\n else\n format.html { render action: \"new\" }\n format.json { render json: @book_catalog_entrie.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @book = Book.new(book_params)\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, notice: 'Book was successfully created.' }\n format.json { render json: @book, status: :created, location: @book }\n else\n format.html { render action: \"new\" }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @book = Book.new(book_params)\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to books_path }\n else\n format.html { render :new, status: :unprocessable_entity }\n end\n end\n end", "def create\n @book = Book.new(book_params)\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, notice: 'Book was successfully created.' }\n format.json { render :show, status: :created, location: @book }\n else\n format.html { render :new }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @book = Book.new(book_params)\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, notice: 'Book was successfully created.' }\n format.json { render :show, status: :created, location: @book }\n else\n format.html { render :new }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @book = Book.new(book_params)\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, notice: 'Book was successfully created.' }\n format.json { render :show, status: :created, location: @book }\n else\n format.html { render :new }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @book = Book.new(book_params)\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, notice: 'Book was successfully created.' }\n format.json { render :show, status: :created, location: @book }\n else\n format.html { render :new }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @book = Book.new(book_params)\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, notice: 'Book was successfully created.' }\n format.json { render :show, status: :created, location: @book }\n else\n format.html { render :new }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @book = Book.new(book_params)\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, notice: 'Book was successfully created.' }\n format.json { render :show, status: :created, location: @book }\n else\n format.html { render :new }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @book = Book.new(book_params)\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, notice: 'Book was successfully created.' }\n format.json { render :show, status: :created, location: @book }\n else\n format.html { render :new }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @book = Book.new(book_params)\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, notice: 'Book was successfully created.' }\n format.json { render :show, status: :created, location: @book }\n else\n format.html { render :new }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @book = Book.new(book_params)\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, notice: 'Book was successfully created.' }\n format.json { render :show, status: :created, location: @book }\n else\n format.html { render :new }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @book = Book.new(book_params)\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, notice: 'Book was successfully created.' }\n format.json { render :show, status: :created, location: @book }\n else\n format.html { render :new }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @book = Book.new(book_params)\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, notice: 'Book was successfully created.' }\n format.json { render :show, status: :created, location: @book }\n else\n format.html { render :new }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @book = Book.new(book_params)\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, notice: 'Book was successfully created.' }\n format.json { render :show, status: :created, location: @book }\n else\n format.html { render :new }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @book = Book.new(book_params)\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, notice: 'Book was successfully created.' }\n format.json { render :show, status: :created, location: @book }\n else\n format.html { render :new }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @book = Book.new(book_params)\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, notice: 'Book was successfully created.' }\n format.json { render action: 'show', status: :created, location: @book }\n else\n format.html { render action: 'new' }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @borrowed_book = BorrowedBook.new(borrowed_book_params)\n respond_to do |format|\n if @borrowed_book.save\n borrow(@borrowed_book)\n format.html { redirect_to @borrowed_book, notice: 'Borrowed book was successfully created.' }\n format.json { render :show, status: :created, location: @borrowed_book }\n else\n format.html { render :new }\n format.json { render json: @borrowed_book.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @library_book = current_user.books.new(library_book_params)\n\n respond_to do |format|\n if @library_book.save\n format.html { redirect_to @library_book, notice: 'Book was successfully created.' }\n format.json { render :show, status: :created, location: @library_book }\n else\n format.html { render :new }\n format.json { render json: @library_book.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n\n\n @book = Book.new(book_params)\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, notice: 'Book was successfully created.' }\n puts @book.as_json \n format.json { render :show, status: :created, location: @book }\n else\n \n format.html { render :new }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def add_book(book)\n\t\t@books << book\n\t\t@book_status[book.title] = book.get_status\n\tend", "def create\n @title = \"Create New Book\"\n\n process_publisher\n\n all_book_params= params[:book]\n\n @book = Book.new(params[:book])\n\n process_authors\n\n process_subjects\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to edit_book_path(@book), notice: 'Book was successfully created.' }\n format.json { render json: @book, status: :created, location: @book }\n else\n format.html { render action: \"new\" }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @authors_book = AuthorsBook.new(params[:authors_book])\n\n respond_to do |format|\n if @authors_book.save\n format.html { redirect_to @authors_book, notice: 'Authors book was successfully created.' }\n format.json { render json: @authors_book, status: :created, location: @authors_book }\n else\n format.html { render action: \"new\" }\n format.json { render json: @authors_book.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @loan = Loan.new(loan_params)\n @book = Book.find_by( params[:book_id] )\n\n respond_to do |format|\n if @loan.save\n format.html { redirect_to @loan, notice: 'Book successfully borrowed' }\n format.json { render :show, status: :created, location: @loan }\n else\n format.html { redirect_to books_path, alert: 'Book not available' }\n end\n end\n end", "def add_book(title)\n new_book = {\n title: title,\n rental_details: {\n student_name: \"\",\n date: \"\"\n }\n }\n @books.push(new_book)\n return @books.length\n end", "def create\n\n @book = Book.new(book_params)\n book = GoogleBooks.search('isbn:'+@book.ISBN.to_s)\n first_book = book.first\n @book.name = first_book.title\n @book.publication_year = first_book.published_date\n @book.author= first_book.authors_array[0]\n\n category_name = first_book.categories.split(\",\")[0]\n category = Category.where(name: category_name ).take\n\n if(category == nil)\n category = Category.new(:name=>category_name)\n category.save\n end\n\n @book.category_id = category.id\n\n\n\n\n\n respond_to do |format|\n @book_search = Book.where(ISBN: @book.ISBN).take\n\n if(@book_search != nil)\n book_library_search = BookLibraryRelation.where(book_id: @book_search.id , library_id: current_admin.library_id).take\n msg ='Book is already in library'\n if(book_library_search == nil)\n @book_library = BookLibraryRelation.new(:book_id=>@book_search.id,:library_id=> current_admin.library_id)\n @book_library.save\n msg = 'Book was successfully created'\n end\n format.html { redirect_to @book_search, notice: msg }\n format.json { render :show, status: :created, location: @book_search }\n else\n\n if @book.save\n @book_library = BookLibraryRelation.new(:book_id=>@book.id,:library_id=> current_admin.library_id)\n @book_library.save\n\n format.html { redirect_to @book, notice: 'Book was successfully created.' }\n format.json { render :show, status: :created, location: @book }\n else\n format.html { render :new }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end\n end", "def create\n @book = Book.new(book_params)\n puts \"*** From create: \" \n\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, notice: 'Book was successfully created.' }\n format.json { render :show, status: :created, location: @book }\n else\n format.html { render :new }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @book = Book.new(params[:book])\n\n for article in @book.articles\n current_aspect.references << article\n end\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, notice: 'Book was successfully created.' }\n format.json { render json: @book, status: :created, location: @book }\n else\n format.html { render layout: 'form', action: \"new\" }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def service_fault_params\n params.require(:service_fault).permit(:service_id, :fault_id)\n end", "def create\r\n @book = Book.new(book_params)\r\n\r\n respond_to do |format|\r\n if @book.save\r\n format.html { redirect_to @book, notice: 'Book was successfully created.' }\r\n format.json { render :show, status: :created, location: @book }\r\n else\r\n format.html { render :new }\r\n format.json { render json: @book.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end", "def create\n @booking = Booking.new(booking_params)\n begin\n @response = Booking.create_booking(booking_options)\n @booking.log = @response\n @booking.picap_id = @response[\"_id\"]\n notice = \"Booking was successfully created.\"\n rescue RestClient::Exception => exception\n @booking.log = exception.response\n alert = exception.response\n end\n\n respond_to do |format|\n if @booking.save\n format.html { redirect_to root_path, notice: notice, alert: alert }\n format.json { render :show, status: :created, location: @booking }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @booking.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @cookbook = Cookbook.new(cookbook_params)\n\n respond_to do |format|\n if @cookbook.save\n format.html { redirect_to cookbook_path(@cookbook), notice: 'Cookbook was successfully created.' }\n format.json { render action: 'show', status: :created, location: @cookbook }\n else\n format.html { render action: 'new' }\n format.json { render json: @cookbook.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @book_exemplar = BookExemplar.new(book_exemplar_params)\n\n respond_to do |format|\n if @book_exemplar.save\n format.html { redirect_to @book_exemplar, notice: 'Book exemplar was successfully created.' }\n format.json { render :show, status: :created, location: @book_exemplar }\n else\n format.html { render :new }\n format.json { render json: @book_exemplar.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @traditional_literature_book = current_user.traditional_literature_books.build(traditional_literature_book_params)\n\n respond_to do |format|\n if @traditional_literature_book.save\n format.html { redirect_to @traditional_literature_book, notice: \"Traditional literature review was successfully created.\" }\n format.json { render :show, status: :created, location: @traditional_literature_book }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @traditional_literature_book.errors, status: :unprocessable_entity }\n end\n end\n end", "def addBook(book)\n\t\tinventories.create(book_id: book.id)\n\tend", "def create\n @author_book = AuthorBook.new(author_book_params)\n\n respond_to do |format|\n if @author_book.save\n format.html { redirect_to @author_book, notice: 'Author book was successfully created.' }\n format.json { render :show, status: :created, location: @author_book }\n else\n format.html { render :new }\n format.json { render json: @author_book.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @book = Book.new(book_params_create)\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, notice: '添加成功!' }\n format.json { render :show, status: :created, location: @book }\n else\n format.html { render :new }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @science_fiction_book = current_user.science_fiction_books.build(science_fiction_book_params)\n\n respond_to do |format|\n if @science_fiction_book.save\n format.html { redirect_to @science_fiction_book, notice: \"Science fiction review was successfully created.\" }\n format.json { render :show, status: :created, location: @science_fiction_book }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @science_fiction_book.errors, status: :unprocessable_entity }\n end\n end\n end", "def send_request_to_bibs_microservice\n 20.times do |x|\n stub_request(:get, \"#{ENV.fetch('BIBS_MICROSERVICE_URL_V01', nil)}?standardNumber=#{ 9781896580601 + x }\").\n with(\n headers: {\n 'Authorization' => 'Bearer testoken',\n 'Content-Type' => 'application/json'\n }).to_return(status: 200, body: MODIFIED_BOOK_JSON_FOR_ISBN_9782917623268, headers: {})\n end\n stub_request(:get, \"#{ENV.fetch('BIBS_MICROSERVICE_URL_V01', nil)}?standardNumber=123456789\").\n with(\n headers: {\n 'Authorization' => 'Bearer testoken',\n 'Content-Type' => 'application/json'\n }).to_return(status: 200, body: JSON_FOR_BOOK_WITH_ISBN_AND_TITLE_TOO_LONG, headers: {})\n end", "def create\n @abook = Abook.new(abook_params)\n\n respond_to do |format|\n if @abook.save\n format.html { redirect_to @abook, notice: 'Abook was successfully created.' }\n format.json { render :show, status: :created, location: @abook }\n else\n format.html { render :new }\n format.json { render json: @abook.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @read_book = ReadBook.new(read_book_params)\n\n respond_to do |format|\n if @read_book.save\n flash[:notice] = 'Read book was successfully created.'\n format.html { redirect_to read_books_url }\n format.json { render :show, status: :created, location: @read_book }\n else\n flash[:warning] = 'Failed'\n format.html { redirect_to read_books_url }\n format.json { render json: @read_book.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @book = Book.new(params[:book])\n \n respond_to do |format|\n if @book.save_and_index\n flash[:notice] = 'Book was successfully created.'\n format.html { redirect_to(@book) }\n format.xml { render :xml => @book, :status => :created, :location => @book }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @book.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @my_book = MyBook.new(my_book_params)\n\n respond_to do |format|\n if @my_book.save\n format.html { redirect_to @my_book, notice: 'My book was successfully created.' }\n format.json { render :show, status: :created, location: @my_book }\n else\n format.html { render :new }\n format.json { render json: @my_book.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @book = Book.new(params[:book])\n\n respond_to do |format|\n if @book.save\n flash[:notice] = 'Book was successfully created.'\n format.html { redirect_to book_url(@book) }\n format.xml { head :created, :location => book_url(@book) }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @book.errors.to_xml }\n end\n end\n end" ]
[ "0.59933865", "0.59741753", "0.5942001", "0.58830196", "0.58563834", "0.5853052", "0.57975334", "0.5781987", "0.5751532", "0.5688442", "0.5680656", "0.5669777", "0.56482714", "0.56337124", "0.55965096", "0.55886114", "0.55798995", "0.55778706", "0.55567425", "0.5550062", "0.5548738", "0.55477804", "0.5524097", "0.5514362", "0.55091006", "0.55061984", "0.55025405", "0.5499628", "0.5489608", "0.5488449", "0.5486957", "0.54814297", "0.54727143", "0.5464089", "0.54630643", "0.546235", "0.54431677", "0.54431677", "0.54431677", "0.54431677", "0.54431677", "0.5438208", "0.5436465", "0.54336184", "0.54336184", "0.54323626", "0.54310393", "0.5427743", "0.5417976", "0.54110336", "0.54102695", "0.5403757", "0.5400992", "0.5399841", "0.5392731", "0.5387272", "0.536481", "0.53623414", "0.535869", "0.53557", "0.53557", "0.53557", "0.53557", "0.53557", "0.53557", "0.53557", "0.53557", "0.53557", "0.53557", "0.53557", "0.53557", "0.53557", "0.5347355", "0.5342539", "0.5338072", "0.531357", "0.53121364", "0.53069556", "0.5305978", "0.5304959", "0.5304788", "0.52926326", "0.5289447", "0.528209", "0.528176", "0.527801", "0.5265132", "0.52611727", "0.5255162", "0.52471995", "0.5245731", "0.5240943", "0.5239226", "0.52349913", "0.5232446", "0.5224847", "0.5217601", "0.5200502", "0.5196713", "0.51953423" ]
0.62262523
0